@mcp-use/inspector 0.14.0-canary.1 → 0.14.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -1
- package/dist/client/assets/{base-Aouj1Yhj.js → base-Bnm339-a.js} +1 -1
- package/dist/client/assets/{base-ZEkF4ver.js → base-RWAdy9P6.js} +1 -1
- package/dist/client/assets/{browser-BWolhM7l.js → browser-9kmymM9X.js} +1 -1
- package/dist/client/assets/{embeddings-BTUgP3x_.js → embeddings-C7cRBw1j.js} +1 -1
- package/dist/client/assets/{index-BOIA9kd1.js → index-Apq2pBJl.js} +1 -1
- package/dist/client/assets/{index-CNfmoBX-.js → index-BsLLCsBP.js} +6 -6
- package/dist/client/assets/{index-Bfe1ynAS.js → index-C2UfjD9L.js} +1 -1
- package/dist/client/assets/{index-CSZqqrHs.js → index-C69r9Nt9.js} +1 -1
- package/dist/client/assets/{index-CtWrgdCi.js → index-CtpnfKmY.js} +1 -1
- package/dist/client/assets/{index-C88Q8iJs.js → index-DIa0UgbZ.js} +1 -1
- package/dist/client/assets/{index-DIlJ2WcE.js → index-DKR-Owed.js} +1 -1
- package/dist/client/assets/{index-BSuQO5pd.js → index-DXrgZUfu.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/{chunk-YLX7JQDX.js → chunk-BC23UV5D.js} +3 -1
- package/dist/server/{chunk-Y4GX3FDV.js → chunk-NOEIHEAG.js} +1 -1
- package/dist/server/cli.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/middleware.js +2 -2
- package/dist/server/server.js +1 -1
- package/dist/server/shared-static.d.ts.map +1 -1
- package/dist/server/shared-static.js +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C69r9Nt9.js","assets/index-C2UfjD9L.js","assets/base-RWAdy9P6.js","assets/index-DKR-Owed.js","assets/base-Bnm339-a.js","assets/embeddings-C7cRBw1j.js","assets/index-CtpnfKmY.js","assets/index-DXrgZUfu.js","assets/index-Apq2pBJl.js","assets/browser-9kmymM9X.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var vJ=Object.defineProperty;var yJ=(e,t,n)=>t in e?vJ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var fg=(e,t,n)=>yJ(e,typeof t!="symbol"?t+"":t,n);function wJ(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const r in a)if(r!=="default"&&!(r in e)){const i=Object.getOwnPropertyDescriptor(a,r);i&&Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>a[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&a(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();function ay(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vx={exports:{}},zf={};var mM;function xJ(){if(mM)return zf;mM=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,r,i){var s=null;if(i!==void 0&&(s=""+i),r.key!==void 0&&(s=""+r.key),"key"in r){i={};for(var c in r)c!=="key"&&(i[c]=r[c])}else i=r;return r=i.ref,{$$typeof:e,type:a,key:s,ref:r!==void 0?r:null,props:i}}return zf.Fragment=t,zf.jsx=n,zf.jsxs=n,zf}var hM;function SJ(){return hM||(hM=1,Vx.exports=xJ()),Vx.exports}var d=SJ();const EJ="modulepreload",_J=function(e){return"/inspector/"+e},gM={},Mr=function(t,n,a){let r=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 s=document.querySelector("meta[property=csp-nonce]"),c=s?.nonce||s?.getAttribute("nonce");r=u(n.map(f=>{if(f=_J(f),f in gM)return;gM[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":EJ,m||(g.as="script"),g.crossOrigin="",g.href=f,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,E)=>{g.addEventListener("load",v),g.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(s){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=s,window.dispatchEvent(c),!c.defaultPrevented)throw s}return r.then(s=>{for(const c of s||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var kJ=Object.defineProperty,je=(e,t)=>kJ(e,"name",{value:t,configurable:!0});function hF(e){return e==="localhost"||e==="127.0.0.1"||e.startsWith("127.")||e.startsWith("192.168.")||e.startsWith("10.")||e.startsWith("172.")}je(hF,"isLocalServer");function gF(e){const t=e.split(".");return t.length<=2?e:t.slice(t.length-2).join(".")}je(gF,"getBaseDomain");function bF(e){return new Promise((t,n)=>{const a=new FileReader;a.onloadend=()=>{t(a.result)},a.onerror=n,a.readAsDataURL(e)})}je(bF,"blobToBase64");async function vF(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],hF(t))return null;const n=gF(t),a=t!==n?[t,n]:[t];for(const r of a)try{const i=`https://favicon.tools.mcp-use.com/${r}`,s=new AbortController,c=setTimeout(()=>s.abort(),2e3);try{const u=await fetch(i,{signal:s.signal});if(clearTimeout(c),!u.ok)continue;const f=await u.blob();return await bF(f)}catch{clearTimeout(c);continue}}catch{continue}return null}catch(t){return console.warn("[favicon-detector] Error detecting favicon:",t),null}}je(vF,"detectFavicon");function Gs(e){return e.replace(/[^a-zA-Z0-9-_]/g,"_").toLowerCase()}je(Gs,"sanitizeServerName");function tc(e){return e.replace(/[^a-zA-Z0-9]/g,"_").toUpperCase().replace(/^_+|_+$/g,"")}je(tc,"headerToEnvVar");function iy(e,t,n){const a={url:e};if(n&&Object.keys(n).length>0){const s={};for(const[c]of Object.entries(n)){const u=tc(c);s[c]=`{{${u}}}`}a.headers=s}const r=JSON.stringify(a);return`cursor://anysphere.cursor-deeplink/mcp/install?config=${btoa(r)}&name=${encodeURIComponent(Gs(t))}`}je(iy,"generateCursorDeepLink");function oy(e,t,n){const a={url:e,name:Gs(t),type:"http"};if(n&&Object.keys(n).length>0){const s={};for(const[c]of Object.entries(n)){const u=tc(c);s[c]=`your-${u}-value`}a.headers=s}const r=JSON.stringify(a);return`vscode:mcp/install?${encodeURIComponent(r)}`}je(oy,"generateVSCodeDeepLink");function yF(e,t,n){const a={url:e,name:Gs(t)};if(n&&Object.keys(n).length>0){const r={};for(const[i]of Object.entries(n)){const s=tc(i);r[i]=`your-${s}-value`}a.headers=r}return a}je(yF,"generateMcpbConfig");function sy(e,t,n){try{const a=yF(e,t,n),r=JSON.stringify(a,null,2),i=globalThis.Blob,s=new i([r],{type:"application/json"}),c=URL.createObjectURL(s),u=document.createElement("a");u.href=c,u.download=`${Gs(t)}.mcpb`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(c)}catch(a){throw console.error("Failed to download .mcpb file:",a),a}}je(sy,"downloadMcpbFile");function ly(e,t,n){let r=`claude mcp add --transport http "${Gs(t)}" \\
|
|
3
3
|
"${e}"`;const i=[];if(n&&Object.keys(n).length>0)for(const[s]of Object.entries(n)){const c=tc(s);r+=` \\
|
|
4
4
|
--header '${s}:\${${c}}'`,i.push({name:c,header:s})}return{command:r,envVars:i}}je(ly,"generateClaudeCodeCommand");function cy(e,t,n){let r=`gemini mcp add --transport http "${Gs(t)}" "${e}"`;const i=[];if(n&&Object.keys(n).length>0)for(const[s]of Object.entries(n)){const c=tc(s);r+=` \\
|
|
@@ -10,7 +10,7 @@ http_headers = { ${s.join(", ")} }`,i.length>0){r+=`
|
|
|
10
10
|
# env_http_headers = { `;const c=i.map(({name:u,header:f})=>`"${f}" = "${u}"`);r+=c.join(", "),r+=" }"}}return{config:r,envVars:i}}je(uy,"generateCodexConfig");function kp(e){if(e.length===0)return"";let t=`Set these environment variables in your shell:
|
|
11
11
|
|
|
12
12
|
`;for(const{name:n}of e)t+=`export ${n}="your-${n}-value"
|
|
13
|
-
`;return t}je(kp,"getEnvVarInstructions");function fk(e,t){if(!t?.proxyAddress)return{url:e,headers:t?.customHeaders||{}};const n=new URL(t.proxyAddress),a=new URL(e),r=`${n.origin}${n.pathname}${a.pathname}${a.search}`,i={"X-Target-URL":e,...t.customHeaders};return{url:r,headers:i}}je(fk,"applyProxyConfig");var Yf={},wF="mcp-use";function uE(e){switch((typeof process<"u"&&Yf?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}je(uE,"resolveLevel");function xF(e){return e.length===0?"":e.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ")}je(xF,"formatArgs");var Ou,TJ=(Ou=class{_level;name;format;constructor(t=wF,n="info",a="minimal"){this.name=t,this._level=n,this.format=a}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],a=n.indexOf(this._level);return n.indexOf(t)<=a}formatMessage(t,n,a){const r=new Date().toLocaleTimeString("en-US",{hour12:!1}),i=xF(a),s=i?`${n} ${i}`:n;switch(this.format){case"detailed":return`${r} [${this.name}] ${t.toUpperCase()}: ${s}`;case"emoji":{const c={error:"❌",warn:"⚠️",info:"ℹ️",http:"🌐",verbose:"📝",debug:"🔍",silly:"🤪"};return`${r} [${this.name}] ${c[t]||""} ${t.toUpperCase()}: ${s}`}case"minimal":default:return`${r} [${this.name}] ${t}: ${s}`}}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}},je(Ou,"SimpleConsoleLogger"),Ou),Rs,NJ=(Rs=class{static get(t=wF){if(!this.instances[t]){const n=typeof process<"u"&&Yf?.DEBUG||void 0;this.instances[t]=new TJ(t,uE(n),this.currentFormat)}return this.instances[t]}static configure(t={}){const{level:n,format:a="minimal"}=t,r=typeof process<"u"&&Yf?.DEBUG||void 0,i=n??uE(r);this.currentFormat=a,Object.values(this.instances).forEach(s=>{s.level=i,s.setFormat(a)})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.instances).forEach(a=>{a.level=n}),typeof process<"u"&&Yf&&(Yf.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},je(Rs,"Logger"),fg(Rs,"instances",{}),fg(Rs,"currentFormat","minimal"),Rs),$e=NJ.get(),CJ="1.12.0-canary.1";function pk(){return CJ}je(pk,"getPackageVersion");var Du,Ci=(Du=class{},je(Du,"BaseTelemetryEvent"),Du),ju,RJ=(ju=class extends Ci{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}}},je(ju,"MCPAgentExecutionEvent"),ju);function SF(e,t){const n=Array.from(e.registrations.tools.values()),a=Array.from(e.registrations.prompts.values()),r=Array.from(e.registrations.resources.values()),i=Array.from(e.registrations.resourceTemplates.values()),s=r.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,uri:m.config.uri??null,mime_type:m.config.mimeType??null})),c=s.filter(m=>m.mime_type==="text/html+skybridge"),u=s.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),f=s.filter(m=>m.mime_type==="text/html+mcp");return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,input_schema:m.config.schema?JSON.stringify(m.config.schema):null,output_schema:m.config.outputSchema?JSON.stringify(m.config.outputSchema):null})):null,resources:s.length>0?s:null,prompts:a.length>0?a.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,args:m.config.args?JSON.stringify(m.config.args):null})):null,templates:i.length>0?i.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:c.length>0?c:null,appsSdkResourcesNumber:c.length,mcpUiResources:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:f.length>0?f:null,mcpAppsResourcesNumber:f.length}}je(SF,"createServerRunEventData");var Lu,AJ=(Lu=class extends Ci{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}}},je(Lu,"ServerRunEvent"),Lu),$u,IJ=($u=class extends Ci{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}}},je($u,"ServerInitializeEvent"),$u),Mu,OJ=(Mu=class extends Ci{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}}},je(Mu,"ServerToolCallEvent"),Mu),Pu,DJ=(Pu=class extends Ci{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}}},je(Pu,"ServerResourceCallEvent"),Pu),zu,jJ=(zu=class extends Ci{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}}},je(zu,"ServerPromptCallEvent"),zu),Uu,LJ=(Uu=class extends Ci{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}}},je(Uu,"ServerContextEvent"),Uu),Fu,$J=(Fu=class extends Ci{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}}},je(Fu,"MCPClientInitEvent"),Fu),Bu,MJ=(Bu=class extends Ci{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}}},je(Bu,"ConnectorInitEvent"),Bu),Hu,PJ=(Hu=class extends Ci{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,a=n.url;return{server_name:t,server_url_domain:a?this._extractHostname(a):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},je(Hu,"ClientAddServerEvent"),Hu),Vu,zJ=(Vu=class extends Ci{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},je(Vu,"ClientRemoveServerEvent"),Vu);function EF(e){return e._llm_type||e.constructor.name.toLowerCase()}je(EF,"getModelProvider");function _F(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}je(_F,"getModelName");function UJ(e){return[EF(e),_F(e)]}je(UJ,"extractModelInfo");function Nb(){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)}`}je(Nb,"generateUUID");function Cb(){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)}je(Cb,"secureRandomString");var bM="mcp_use_user_id";function kF(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}je(kF,"detectRuntimeEnvironment");function TF(e){if(e==="browser")try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only"}je(TF,"getStorageCapability");var Gx=null;function NF(){return Gx===null&&(Gx=kF()),Gx}je(NF,"getRuntimeEnvironment");var gi,CF=(gi=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=NF(),this._storageCapability=TF(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";t?(this._posthogBrowserClient=null,$e.debug("Telemetry disabled via localStorage")):n?($e.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable."),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,$e.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(typeof localStorage<"u")return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE")}catch{}return null}_checkTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHogBrowser(){try{const n=await Mr(()=>import("./module-D4IOASh4.js"),[]),a=n.default||n.posthog;if(!a||typeof a.init!="function")throw new Error("posthog-js module did not export expected interface");a.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:je(()=>{$e.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=a}catch(t){$e.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return gi.instance||(gi.instance=new gi),gi.instance}setSource(t){this._source=t;try{typeof localStorage<"u"&&localStorage.setItem("MCP_USE_TELEMETRY_SOURCE",t)}catch{}$e.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-${Nb()}`}catch{this._currUserId=`session-${Date.now()}-${Cb()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(typeof localStorage>"u")throw new Error("localStorage is not available");try{localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__")}catch(n){throw new Error(`localStorage is not writable: ${n}`)}let t=localStorage.getItem(bM);if(!t){try{t=Nb()}catch{t=`${Date.now()}-${Cb()}`}localStorage.setItem(bM,t)}return t}catch(t){$e.debug(`Failed to access localStorage for user ID: ${t}`);let n;try{n=`session-${Nb()}`}catch{n=`session-${Date.now()}-${Cb()}`}return n}}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;const n=this.userId,a={...t.properties};if(a.mcp_use_version=pk(),a.language="typescript",a.source=this._source,a.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(t.name,{...a,distinct_id:n})}catch(r){$e.debug(`Failed to track PostHog Browser event ${t.name}: ${r}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new RJ(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const a=SF(t,n),r=new AJ(a);await this.capture(r)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new IJ(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new OJ(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new DJ(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new jJ(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new LJ(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new $J(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new MJ(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const a=new PJ({serverName:t,serverConfig:n});await this.capture(a)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new zJ({serverName:t});await this.capture(n)}async trackUseMcpConnection(t){this.isEnabled&&await this.capture({name:"usemcp_connection",properties:{url_domain:new URL(t.url).hostname,transport_type:t.transportType,success:t.success,error_type:t.errorType??null,connection_time_ms:t.connectionTimeMs??null,has_oauth:t.hasOAuth,has_sampling:t.hasSampling,has_elicitation:t.hasElicitation}})}async trackUseMcpToolCall(t){this.isEnabled&&await this.capture({name:"usemcp_tool_call",properties:{tool_name:t.toolName,success:t.success,error_type:t.errorType??null,execution_time_ms:t.executionTimeMs??null}})}async trackUseMcpResourceRead(t){this.isEnabled&&await this.capture({name:"usemcp_resource_read",properties:{resource_uri_scheme:t.resourceUri.split(":")[0],success:t.success,error_type:t.errorType??null}})}identify(t,n){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(t,n)}catch(a){$e.debug(`Failed to identify user: ${a}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){$e.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(t){}},je(gi,"Telemetry"),fg(gi,"instance",null),gi),Ui=CF;function FJ(e){Ui.getInstance().setSource(e)}je(FJ,"setTelemetrySource");const RF=Object.freeze({status:"aborted"});function ge(e,t,n){function a(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const f=s.prototype,m=Object.keys(f);for(let h=0;h<m.length;h++){const g=m[h];g in c||(c[g]=f[g].bind(c))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(c){var u;const f=n?.Parent?new i:this;a(f,c),(u=f._zod).deferred??(u.deferred=[]);for(const m of f._zod.deferred)m();return f}return Object.defineProperty(s,"init",{value:a}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}const AF=Symbol("zod_brand");class $l extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class dy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const tv={};function Zr(e){return e&&Object.assign(tv,e),tv}function BJ(e){return e}function HJ(e){return e}function VJ(e){}function GJ(e){throw new Error("Unexpected value in exhaustive check")}function WJ(e){}function mk(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function Be(e,t="|"){return e.map(n=>bt(n)).join(t)}function nv(e,t){return typeof t=="bigint"?t.toString():t}function um(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function nc(e){return e==null}function fy(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function IF(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const u=a.match(/\d?e-(\d?)/);u?.[1]&&(r=Number.parseInt(u[1]))}const i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}const vM=Symbol("evaluating");function Kt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==vM)return a===void 0&&(a=vM,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function KJ(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Ws(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function ZJ(e){return Fo(e._zod.def)}function YJ(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function qJ(e){const t=Object.keys(e),n=t.map(a=>e[a]);return Promise.all(n).then(a=>{const r={};for(let i=0;i<t.length;i++)r[t[i]]=a[i];return r})}function XJ(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let a=0;a<e;a++)n+=t[Math.floor(Math.random()*t.length)];return n}function dE(e){return JSON.stringify(e)}function OF(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const hk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Qu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const DF=um(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Bl(e){if(Qu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Qu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function py(e){return Bl(e)?{...e}:Array.isArray(e)?[...e]:e}function JJ(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const QJ=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},rv=new Set(["string","number","symbol"]),jF=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Do(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ni(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function Ie(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 eQ(e){let t;return new Proxy({},{get(n,a,r){return t??(t=e()),Reflect.get(t,a,r)},set(n,a,r,i){return t??(t=e()),Reflect.set(t,a,r,i)},has(n,a){return t??(t=e()),Reflect.has(t,a)},deleteProperty(n,a){return t??(t=e()),Reflect.deleteProperty(t,a)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,a){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(n,a,r){return t??(t=e()),Reflect.defineProperty(t,a,r)}})}function bt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function LF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const $F={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]},MF={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function PF(e,t){const n=e._zod.def,a=Fo(e._zod.def,{get shape(){const r={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return Ws(this,"shape",r),r},checks:[]});return ni(e,a)}function zF(e,t){const n=e._zod.def,a=Fo(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return Ws(this,"shape",r),r},checks:[]});return ni(e,a)}function UF(e,t){if(!Bl(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=Fo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Ws(this,"shape",i),i},checks:[]});return ni(e,r)}function FF(e,t){if(!Bl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const a={...e._zod.def.shape,...t};return Ws(this,"shape",a),a},checks:e._zod.def.checks};return ni(e,n)}function BF(e,t){const n=Fo(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Ws(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ni(e,n)}function HF(e,t,n){const a=Fo(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)i[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return Ws(this,"shape",i),i},checks:[]});return ni(t,a)}function VF(e,t,n){const a=Fo(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return Ws(this,"shape",i),i},checks:[]});return ni(t,a)}function Al(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 bi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function qf(e){return typeof e=="string"?e:e?.message}function ti(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=qf(e.inst?._zod.def?.error?.(e))??qf(t?.error?.(e))??qf(n.customError?.(e))??qf(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function my(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function hy(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ed(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function tQ(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function GF(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function WF(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function nQ(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return GF(t+n)}function rQ(e){return WF(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function aQ(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let a=0;a<t.length;a+=2)n[a/2]=Number.parseInt(t.slice(a,a+2),16);return n}function iQ(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class oQ{constructor(...t){}}const KF=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:MF,Class:oQ,NUMBER_FORMAT_RANGES:$F,aborted:Al,allowsEval:DF,assert:WJ,assertEqual:BJ,assertIs:VJ,assertNever:GJ,assertNotEqual:HJ,assignProp:Ws,base64ToUint8Array:GF,base64urlToUint8Array:nQ,cached:um,captureStackTrace:hk,cleanEnum:tQ,cleanRegex:fy,clone:ni,cloneDef:ZJ,createTransparentProxy:eQ,defineLazy:Kt,esc:dE,escapeRegex:Do,extend:UF,finalizeIssue:ti,floatSafeRemainder:IF,getElementAtPath:YJ,getEnumValues:mk,getLengthableOrigin:hy,getParsedType:QJ,getSizableOrigin:my,hexToUint8Array:aQ,isObject:Qu,isPlainObject:Bl,issue:ed,joinValues:Be,jsonStringifyReplacer:nv,merge:BF,mergeDefs:Fo,normalizeParams:Ie,nullish:nc,numKeys:JJ,objectClone:KJ,omit:zF,optionalKeys:LF,partial:HF,pick:PF,prefixIssues:bi,primitiveTypes:jF,promiseAllObject:qJ,propertyKeyTypes:rv,randomString:XJ,required:VF,safeExtend:FF,shallowClone:py,slugify:OF,stringifyPrimitive:bt,uint8ArrayToBase64:WF,uint8ArrayToBase64url:rQ,uint8ArrayToHex:iQ,unwrapMessage:qf},Symbol.toStringTag,{value:"Module"})),ZF=(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,nv,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},gk=ge("$ZodError",ZF),Ma=ge("$ZodError",ZF,{Parent:Error});function bk(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function vk(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>a({issues:s}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(t(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return a(e),n}function YF(e,t=n=>n.message){const n={errors:[]},a=(r,i=[])=>{var s,c;for(const u of r.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(f=>a({issues:f},u.path));else if(u.code==="invalid_key")a({issues:u.issues},u.path);else if(u.code==="invalid_element")a({issues:u.issues},u.path);else{const f=[...i,...u.path];if(f.length===0){n.errors.push(t(u));continue}let m=n,h=0;for(;h<f.length;){const g=f[h],v=h===f.length-1;typeof g=="string"?(m.properties??(m.properties={}),(s=m.properties)[g]??(s[g]={errors:[]}),m=m.properties[g]):(m.items??(m.items=[]),(c=m.items)[g]??(c[g]={errors:[]}),m=m.items[g]),v&&m.errors.push(t(u)),h++}}};return a(e),n}function qF(e){const t=[],n=e.map(a=>typeof a=="object"?a.key:a);for(const a of n)typeof a=="number"?t.push(`[${a}]`):typeof a=="symbol"?t.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?t.push(`[${JSON.stringify(a)}]`):(t.length&&t.push("."),t.push(a));return t.join("")}function XF(e){const t=[],n=[...e.issues].sort((a,r)=>(a.path??[]).length-(r.path??[]).length);for(const a of n)t.push(`✖ ${a.message}`),a.path?.length&&t.push(` → at ${qF(a.path)}`);return t.join(`
|
|
13
|
+
`;return t}je(kp,"getEnvVarInstructions");function fk(e,t){if(!t?.proxyAddress)return{url:e,headers:t?.customHeaders||{}};const n=new URL(t.proxyAddress),a=new URL(e),r=`${n.origin}${n.pathname}${a.pathname}${a.search}`,i={"X-Target-URL":e,...t.customHeaders};return{url:r,headers:i}}je(fk,"applyProxyConfig");var Yf={},wF="mcp-use";function uE(e){switch((typeof process<"u"&&Yf?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}je(uE,"resolveLevel");function xF(e){return e.length===0?"":e.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ")}je(xF,"formatArgs");var Ou,TJ=(Ou=class{_level;name;format;constructor(t=wF,n="info",a="minimal"){this.name=t,this._level=n,this.format=a}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],a=n.indexOf(this._level);return n.indexOf(t)<=a}formatMessage(t,n,a){const r=new Date().toLocaleTimeString("en-US",{hour12:!1}),i=xF(a),s=i?`${n} ${i}`:n;switch(this.format){case"detailed":return`${r} [${this.name}] ${t.toUpperCase()}: ${s}`;case"emoji":{const c={error:"❌",warn:"⚠️",info:"ℹ️",http:"🌐",verbose:"📝",debug:"🔍",silly:"🤪"};return`${r} [${this.name}] ${c[t]||""} ${t.toUpperCase()}: ${s}`}case"minimal":default:return`${r} [${this.name}] ${t}: ${s}`}}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}},je(Ou,"SimpleConsoleLogger"),Ou),Rs,NJ=(Rs=class{static get(t=wF){if(!this.instances[t]){const n=typeof process<"u"&&Yf?.DEBUG||void 0;this.instances[t]=new TJ(t,uE(n),this.currentFormat)}return this.instances[t]}static configure(t={}){const{level:n,format:a="minimal"}=t,r=typeof process<"u"&&Yf?.DEBUG||void 0,i=n??uE(r);this.currentFormat=a,Object.values(this.instances).forEach(s=>{s.level=i,s.setFormat(a)})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.instances).forEach(a=>{a.level=n}),typeof process<"u"&&Yf&&(Yf.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},je(Rs,"Logger"),fg(Rs,"instances",{}),fg(Rs,"currentFormat","minimal"),Rs),$e=NJ.get(),CJ="1.12.0-canary.2";function pk(){return CJ}je(pk,"getPackageVersion");var Du,Ci=(Du=class{},je(Du,"BaseTelemetryEvent"),Du),ju,RJ=(ju=class extends Ci{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}}},je(ju,"MCPAgentExecutionEvent"),ju);function SF(e,t){const n=Array.from(e.registrations.tools.values()),a=Array.from(e.registrations.prompts.values()),r=Array.from(e.registrations.resources.values()),i=Array.from(e.registrations.resourceTemplates.values()),s=r.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,uri:m.config.uri??null,mime_type:m.config.mimeType??null})),c=s.filter(m=>m.mime_type==="text/html+skybridge"),u=s.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),f=s.filter(m=>m.mime_type==="text/html+mcp");return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,input_schema:m.config.schema?JSON.stringify(m.config.schema):null,output_schema:m.config.outputSchema?JSON.stringify(m.config.outputSchema):null})):null,resources:s.length>0?s:null,prompts:a.length>0?a.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,args:m.config.args?JSON.stringify(m.config.args):null})):null,templates:i.length>0?i.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:c.length>0?c:null,appsSdkResourcesNumber:c.length,mcpUiResources:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:f.length>0?f:null,mcpAppsResourcesNumber:f.length}}je(SF,"createServerRunEventData");var Lu,AJ=(Lu=class extends Ci{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}}},je(Lu,"ServerRunEvent"),Lu),$u,IJ=($u=class extends Ci{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}}},je($u,"ServerInitializeEvent"),$u),Mu,OJ=(Mu=class extends Ci{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}}},je(Mu,"ServerToolCallEvent"),Mu),Pu,DJ=(Pu=class extends Ci{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}}},je(Pu,"ServerResourceCallEvent"),Pu),zu,jJ=(zu=class extends Ci{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}}},je(zu,"ServerPromptCallEvent"),zu),Uu,LJ=(Uu=class extends Ci{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}}},je(Uu,"ServerContextEvent"),Uu),Fu,$J=(Fu=class extends Ci{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}}},je(Fu,"MCPClientInitEvent"),Fu),Bu,MJ=(Bu=class extends Ci{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}}},je(Bu,"ConnectorInitEvent"),Bu),Hu,PJ=(Hu=class extends Ci{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,a=n.url;return{server_name:t,server_url_domain:a?this._extractHostname(a):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},je(Hu,"ClientAddServerEvent"),Hu),Vu,zJ=(Vu=class extends Ci{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},je(Vu,"ClientRemoveServerEvent"),Vu);function EF(e){return e._llm_type||e.constructor.name.toLowerCase()}je(EF,"getModelProvider");function _F(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}je(_F,"getModelName");function UJ(e){return[EF(e),_F(e)]}je(UJ,"extractModelInfo");function Nb(){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)}`}je(Nb,"generateUUID");function Cb(){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)}je(Cb,"secureRandomString");var bM="mcp_use_user_id";function kF(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}je(kF,"detectRuntimeEnvironment");function TF(e){if(e==="browser")try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only"}je(TF,"getStorageCapability");var Gx=null;function NF(){return Gx===null&&(Gx=kF()),Gx}je(NF,"getRuntimeEnvironment");var gi,CF=(gi=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=NF(),this._storageCapability=TF(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";t?(this._posthogBrowserClient=null,$e.debug("Telemetry disabled via localStorage")):n?($e.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable."),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,$e.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(typeof localStorage<"u")return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE")}catch{}return null}_checkTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHogBrowser(){try{const n=await Mr(()=>import("./module-D4IOASh4.js"),[]),a=n.default||n.posthog;if(!a||typeof a.init!="function")throw new Error("posthog-js module did not export expected interface");a.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:je(()=>{$e.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=a}catch(t){$e.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return gi.instance||(gi.instance=new gi),gi.instance}setSource(t){this._source=t;try{typeof localStorage<"u"&&localStorage.setItem("MCP_USE_TELEMETRY_SOURCE",t)}catch{}$e.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-${Nb()}`}catch{this._currUserId=`session-${Date.now()}-${Cb()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(typeof localStorage>"u")throw new Error("localStorage is not available");try{localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__")}catch(n){throw new Error(`localStorage is not writable: ${n}`)}let t=localStorage.getItem(bM);if(!t){try{t=Nb()}catch{t=`${Date.now()}-${Cb()}`}localStorage.setItem(bM,t)}return t}catch(t){$e.debug(`Failed to access localStorage for user ID: ${t}`);let n;try{n=`session-${Nb()}`}catch{n=`session-${Date.now()}-${Cb()}`}return n}}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;const n=this.userId,a={...t.properties};if(a.mcp_use_version=pk(),a.language="typescript",a.source=this._source,a.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(t.name,{...a,distinct_id:n})}catch(r){$e.debug(`Failed to track PostHog Browser event ${t.name}: ${r}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new RJ(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const a=SF(t,n),r=new AJ(a);await this.capture(r)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new IJ(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new OJ(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new DJ(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new jJ(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new LJ(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new $J(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new MJ(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const a=new PJ({serverName:t,serverConfig:n});await this.capture(a)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new zJ({serverName:t});await this.capture(n)}async trackUseMcpConnection(t){this.isEnabled&&await this.capture({name:"usemcp_connection",properties:{url_domain:new URL(t.url).hostname,transport_type:t.transportType,success:t.success,error_type:t.errorType??null,connection_time_ms:t.connectionTimeMs??null,has_oauth:t.hasOAuth,has_sampling:t.hasSampling,has_elicitation:t.hasElicitation}})}async trackUseMcpToolCall(t){this.isEnabled&&await this.capture({name:"usemcp_tool_call",properties:{tool_name:t.toolName,success:t.success,error_type:t.errorType??null,execution_time_ms:t.executionTimeMs??null}})}async trackUseMcpResourceRead(t){this.isEnabled&&await this.capture({name:"usemcp_resource_read",properties:{resource_uri_scheme:t.resourceUri.split(":")[0],success:t.success,error_type:t.errorType??null}})}identify(t,n){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(t,n)}catch(a){$e.debug(`Failed to identify user: ${a}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){$e.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(t){}},je(gi,"Telemetry"),fg(gi,"instance",null),gi),Ui=CF;function FJ(e){Ui.getInstance().setSource(e)}je(FJ,"setTelemetrySource");const RF=Object.freeze({status:"aborted"});function ge(e,t,n){function a(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const f=s.prototype,m=Object.keys(f);for(let h=0;h<m.length;h++){const g=m[h];g in c||(c[g]=f[g].bind(c))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(c){var u;const f=n?.Parent?new i:this;a(f,c),(u=f._zod).deferred??(u.deferred=[]);for(const m of f._zod.deferred)m();return f}return Object.defineProperty(s,"init",{value:a}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}const AF=Symbol("zod_brand");class $l extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class dy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const tv={};function Zr(e){return e&&Object.assign(tv,e),tv}function BJ(e){return e}function HJ(e){return e}function VJ(e){}function GJ(e){throw new Error("Unexpected value in exhaustive check")}function WJ(e){}function mk(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function Be(e,t="|"){return e.map(n=>bt(n)).join(t)}function nv(e,t){return typeof t=="bigint"?t.toString():t}function um(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function nc(e){return e==null}function fy(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function IF(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const u=a.match(/\d?e-(\d?)/);u?.[1]&&(r=Number.parseInt(u[1]))}const i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}const vM=Symbol("evaluating");function Kt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==vM)return a===void 0&&(a=vM,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function KJ(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Ws(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function ZJ(e){return Fo(e._zod.def)}function YJ(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function qJ(e){const t=Object.keys(e),n=t.map(a=>e[a]);return Promise.all(n).then(a=>{const r={};for(let i=0;i<t.length;i++)r[t[i]]=a[i];return r})}function XJ(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let a=0;a<e;a++)n+=t[Math.floor(Math.random()*t.length)];return n}function dE(e){return JSON.stringify(e)}function OF(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const hk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Qu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const DF=um(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Bl(e){if(Qu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Qu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function py(e){return Bl(e)?{...e}:Array.isArray(e)?[...e]:e}function JJ(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const QJ=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},rv=new Set(["string","number","symbol"]),jF=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Do(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ni(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function Ie(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 eQ(e){let t;return new Proxy({},{get(n,a,r){return t??(t=e()),Reflect.get(t,a,r)},set(n,a,r,i){return t??(t=e()),Reflect.set(t,a,r,i)},has(n,a){return t??(t=e()),Reflect.has(t,a)},deleteProperty(n,a){return t??(t=e()),Reflect.deleteProperty(t,a)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,a){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(n,a,r){return t??(t=e()),Reflect.defineProperty(t,a,r)}})}function bt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function LF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const $F={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]},MF={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function PF(e,t){const n=e._zod.def,a=Fo(e._zod.def,{get shape(){const r={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return Ws(this,"shape",r),r},checks:[]});return ni(e,a)}function zF(e,t){const n=e._zod.def,a=Fo(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return Ws(this,"shape",r),r},checks:[]});return ni(e,a)}function UF(e,t){if(!Bl(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=Fo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Ws(this,"shape",i),i},checks:[]});return ni(e,r)}function FF(e,t){if(!Bl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const a={...e._zod.def.shape,...t};return Ws(this,"shape",a),a},checks:e._zod.def.checks};return ni(e,n)}function BF(e,t){const n=Fo(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Ws(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ni(e,n)}function HF(e,t,n){const a=Fo(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)i[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return Ws(this,"shape",i),i},checks:[]});return ni(t,a)}function VF(e,t,n){const a=Fo(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return Ws(this,"shape",i),i},checks:[]});return ni(t,a)}function Al(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 bi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function qf(e){return typeof e=="string"?e:e?.message}function ti(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=qf(e.inst?._zod.def?.error?.(e))??qf(t?.error?.(e))??qf(n.customError?.(e))??qf(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function my(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function hy(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ed(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function tQ(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function GF(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function WF(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function nQ(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return GF(t+n)}function rQ(e){return WF(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function aQ(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let a=0;a<t.length;a+=2)n[a/2]=Number.parseInt(t.slice(a,a+2),16);return n}function iQ(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class oQ{constructor(...t){}}const KF=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:MF,Class:oQ,NUMBER_FORMAT_RANGES:$F,aborted:Al,allowsEval:DF,assert:WJ,assertEqual:BJ,assertIs:VJ,assertNever:GJ,assertNotEqual:HJ,assignProp:Ws,base64ToUint8Array:GF,base64urlToUint8Array:nQ,cached:um,captureStackTrace:hk,cleanEnum:tQ,cleanRegex:fy,clone:ni,cloneDef:ZJ,createTransparentProxy:eQ,defineLazy:Kt,esc:dE,escapeRegex:Do,extend:UF,finalizeIssue:ti,floatSafeRemainder:IF,getElementAtPath:YJ,getEnumValues:mk,getLengthableOrigin:hy,getParsedType:QJ,getSizableOrigin:my,hexToUint8Array:aQ,isObject:Qu,isPlainObject:Bl,issue:ed,joinValues:Be,jsonStringifyReplacer:nv,merge:BF,mergeDefs:Fo,normalizeParams:Ie,nullish:nc,numKeys:JJ,objectClone:KJ,omit:zF,optionalKeys:LF,partial:HF,pick:PF,prefixIssues:bi,primitiveTypes:jF,promiseAllObject:qJ,propertyKeyTypes:rv,randomString:XJ,required:VF,safeExtend:FF,shallowClone:py,slugify:OF,stringifyPrimitive:bt,uint8ArrayToBase64:WF,uint8ArrayToBase64url:rQ,uint8ArrayToHex:iQ,unwrapMessage:qf},Symbol.toStringTag,{value:"Module"})),ZF=(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,nv,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},gk=ge("$ZodError",ZF),Ma=ge("$ZodError",ZF,{Parent:Error});function bk(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function vk(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>a({issues:s}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(t(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return a(e),n}function YF(e,t=n=>n.message){const n={errors:[]},a=(r,i=[])=>{var s,c;for(const u of r.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(f=>a({issues:f},u.path));else if(u.code==="invalid_key")a({issues:u.issues},u.path);else if(u.code==="invalid_element")a({issues:u.issues},u.path);else{const f=[...i,...u.path];if(f.length===0){n.errors.push(t(u));continue}let m=n,h=0;for(;h<f.length;){const g=f[h],v=h===f.length-1;typeof g=="string"?(m.properties??(m.properties={}),(s=m.properties)[g]??(s[g]={errors:[]}),m=m.properties[g]):(m.items??(m.items=[]),(c=m.items)[g]??(c[g]={errors:[]}),m=m.items[g]),v&&m.errors.push(t(u)),h++}}};return a(e),n}function qF(e){const t=[],n=e.map(a=>typeof a=="object"?a.key:a);for(const a of n)typeof a=="number"?t.push(`[${a}]`):typeof a=="symbol"?t.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?t.push(`[${JSON.stringify(a)}]`):(t.length&&t.push("."),t.push(a));return t.join("")}function XF(e){const t=[],n=[...e.issues].sort((a,r)=>(a.path??[]).length-(r.path??[]).length);for(const a of n)t.push(`✖ ${a.message}`),a.path?.length&&t.push(` → at ${qF(a.path)}`);return t.join(`
|
|
14
14
|
`)}const dm=e=>(t,n,a,r)=>{const i=a?Object.assign(a,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new $l;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>ti(u,i,Zr())));throw hk(c,r?.callee),c}return s.value},fE=dm(Ma),fm=e=>async(t,n,a,r)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>ti(u,i,Zr())));throw hk(c,r?.callee),c}return s.value},pE=fm(Ma),pm=e=>(t,n,a)=>{const r=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new $l;return i.issues.length?{success:!1,error:new(e??gk)(i.issues.map(s=>ti(s,r,Zr())))}:{success:!0,data:i.value}},yk=pm(Ma),mm=e=>async(t,n,a)=>{const r=a?Object.assign(a,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>ti(s,r,Zr())))}:{success:!0,data:i.value}},JF=mm(Ma),wk=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return dm(e)(t,n,r)},sQ=wk(Ma),xk=e=>(t,n,a)=>dm(e)(t,n,a),lQ=xk(Ma),Sk=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return fm(e)(t,n,r)},cQ=Sk(Ma),Ek=e=>async(t,n,a)=>fm(e)(t,n,a),uQ=Ek(Ma),_k=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return pm(e)(t,n,r)},dQ=_k(Ma),kk=e=>(t,n,a)=>pm(e)(t,n,a),fQ=kk(Ma),Tk=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return mm(e)(t,n,r)},pQ=Tk(Ma),Nk=e=>async(t,n,a)=>mm(e)(t,n,a),mQ=Nk(Ma),QF=/^[cC][^\s-]{8,}$/,e3=/^[0-9a-z]+$/,t3=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,n3=/^[0-9a-vA-V]{20}$/,r3=/^[A-Za-z0-9]{27}$/,a3=/^[a-zA-Z0-9_-]{21}$/,i3=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hQ=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,o3=/^([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})$/,td=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)$/,gQ=td(4),bQ=td(6),vQ=td(7),s3=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,yQ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,wQ=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,l3=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,xQ=l3,SQ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,EQ="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function c3(){return new RegExp(EQ,"u")}const u3=/^(?:(?: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])$/,d3=/^(([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}|:))$/,f3=e=>{const t=Do(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},p3=/^((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])$/,m3=/^(([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])$/,h3=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ck=/^[A-Za-z0-9_-]*$/,g3=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,b3=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,v3=/^\+(?:[0-9]){6,14}[0-9]$/,y3="(?:(?:\\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])))",w3=new RegExp(`^${y3}$`);function x3(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 S3(e){return new RegExp(`^${x3(e)}$`)}function E3(e){const t=x3({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${y3}T(?:${a})$`)}const _3=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},k3=/^-?\d+n?$/,T3=/^-?\d+$/,N3=/^-?\d+(?:\.\d+)?/,C3=/^(?:true|false)$/i,R3=/^null$/i,A3=/^undefined$/i,I3=/^[^A-Z]*$/,O3=/^[^a-z]*$/,D3=/^[0-9a-fA-F]*$/;function hm(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function gm(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const _Q=/^[0-9a-fA-F]{32}$/,kQ=hm(22,"=="),TQ=gm(22),NQ=/^[0-9a-fA-F]{40}$/,CQ=hm(27,"="),RQ=gm(27),AQ=/^[0-9a-fA-F]{64}$/,IQ=hm(43,"="),OQ=gm(43),DQ=/^[0-9a-fA-F]{96}$/,jQ=hm(64,""),LQ=gm(64),$Q=/^[0-9a-fA-F]{128}$/,MQ=hm(86,"=="),PQ=gm(86),Rk=Object.freeze(Object.defineProperty({__proto__:null,base64:h3,base64url:Ck,bigint:k3,boolean:C3,browserEmail:SQ,cidrv4:p3,cidrv6:m3,cuid:QF,cuid2:e3,date:w3,datetime:E3,domain:b3,duration:i3,e164:v3,email:s3,emoji:c3,extendedDuration:hQ,guid:o3,hex:D3,hostname:g3,html5Email:yQ,idnEmail:xQ,integer:T3,ipv4:u3,ipv6:d3,ksuid:r3,lowercase:I3,mac:f3,md5_base64:kQ,md5_base64url:TQ,md5_hex:_Q,nanoid:a3,null:R3,number:N3,rfc5322Email:wQ,sha1_base64:CQ,sha1_base64url:RQ,sha1_hex:NQ,sha256_base64:IQ,sha256_base64url:OQ,sha256_hex:AQ,sha384_base64:jQ,sha384_base64url:LQ,sha384_hex:DQ,sha512_base64:MQ,sha512_base64url:PQ,sha512_hex:$Q,string:_3,time:S3,ulid:t3,undefined:A3,unicodeEmail:l3,uppercase:O3,uuid:td,uuid4:gQ,uuid6:bQ,uuid7:vQ,xid:n3},Symbol.toStringTag,{value:"Module"})),Fn=ge("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),j3={number:"number",bigint:"bigint",object:"date"},Ak=ge("$ZodCheckLessThan",(e,t)=>{Fn.init(e,t);const n=j3[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ik=ge("$ZodCheckGreaterThan",(e,t)=>{Fn.init(e,t);const n=j3[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),L3=ge("$ZodCheckMultipleOf",(e,t)=>{Fn.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):IF(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})}}),$3=ge("$ZodCheckNumberFormat",(e,t)=>{Fn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[r,i]=$F[t.format];e._zod.onattach.push(s=>{const c=s._zod.bag;c.format=t.format,c.minimum=r,c.maximum=i,n&&(c.pattern=T3)}),e._zod.check=s=>{const c=s.value;if(n){if(!Number.isInteger(c)){s.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,continue:!t.abort}):s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,continue:!t.abort});return}}c<r&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inst:e})}}),M3=ge("$ZodCheckBigIntFormat",(e,t)=>{Fn.init(e,t);const[n,a]=MF[t.format];e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,i.minimum=n,i.maximum=a}),e._zod.check=r=>{const i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>a&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:a,inst:e})}}),P3=ge("$ZodCheckMaxSize",(e,t)=>{var n;Fn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!nc(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;r.size<=t.maximum||a.issues.push({origin:my(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),z3=ge("$ZodCheckMinSize",(e,t)=>{var n;Fn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!nc(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;r.size>=t.minimum||a.issues.push({origin:my(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),U3=ge("$ZodCheckSizeEquals",(e,t)=>{var n;Fn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!nc(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=a=>{const r=a.value,i=r.size;if(i===t.size)return;const s=i>t.size;a.issues.push({origin:my(r),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),F3=ge("$ZodCheckMaxLength",(e,t)=>{var n;Fn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!nc(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;if(r.length<=t.maximum)return;const s=hy(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),B3=ge("$ZodCheckMinLength",(e,t)=>{var n;Fn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!nc(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;if(r.length>=t.minimum)return;const s=hy(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),H3=ge("$ZodCheckLengthEquals",(e,t)=>{var n;Fn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!nc(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=a=>{const r=a.value,i=r.length;if(i===t.length)return;const s=hy(r),c=i>t.length;a.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),bm=ge("$ZodCheckStringFormat",(e,t)=>{var n,a;Fn.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),V3=ge("$ZodCheckRegex",(e,t)=>{bm.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})}}),G3=ge("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=I3),bm.init(e,t)}),W3=ge("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=O3),bm.init(e,t)}),K3=ge("$ZodCheckIncludes",(e,t)=>{Fn.init(e,t);const n=Do(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Z3=ge("$ZodCheckStartsWith",(e,t)=>{Fn.init(e,t);const n=new RegExp(`^${Do(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),Y3=ge("$ZodCheckEndsWith",(e,t)=>{Fn.init(e,t);const n=new RegExp(`.*${Do(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}});function yM(e,t,n){e.issues.length&&t.issues.push(...bi(n,e.issues))}const q3=ge("$ZodCheckProperty",(e,t)=>{Fn.init(e,t),e._zod.check=n=>{const a=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(a instanceof Promise)return a.then(r=>yM(r,n,t.property));yM(a,n,t.property)}}),X3=ge("$ZodCheckMimeType",(e,t)=>{Fn.init(e,t);const n=new Set(t.mime);e._zod.onattach.push(a=>{a._zod.bag.mime=t.mime}),e._zod.check=a=>{n.has(a.value.type)||a.issues.push({code:"invalid_value",values:t.mime,input:a.value.type,inst:e,continue:!t.abort})}}),J3=ge("$ZodCheckOverwrite",(e,t)=>{Fn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Q3{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
|
|
15
15
|
`).filter(s=>s),r=Math.min(...a.map(s=>s.length-s.trimStart().length)),i=a.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
|
|
16
16
|
`))}}const eB={major:4,minor:2,patch:0},_t=ge("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=eB;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const r of a)for(const i of r._zod.onattach)i(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(s,c,u)=>{let f=Al(s),m;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(s))continue}else if(f)continue;const g=s.issues.length,v=h._zod.check(s);if(v instanceof Promise&&u?.async===!1)throw new $l;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,s.issues.length!==g&&(f||(f=Al(s,g)))});else{if(s.issues.length===g)continue;f||(f=Al(s,g))}}return m?m.then(()=>s):s},i=(s,c,u)=>{if(Al(s))return s.aborted=!0,s;const f=r(c,a,u);if(f instanceof Promise){if(u.async===!1)throw new $l;return f.then(m=>e._zod.parse(m,u))}return e._zod.parse(f,u)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const f=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return f instanceof Promise?f.then(m=>i(m,s,c)):i(f,s,c)}const u=e._zod.parse(s,c);if(u instanceof Promise){if(c.async===!1)throw new $l;return u.then(f=>r(f,a,c))}return r(u,a,c)}}e["~standard"]={validate:r=>{try{const i=yk(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return JF(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),vm=ge("$ZodString",(e,t)=>{_t.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??_3(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Cn=ge("$ZodStringFormat",(e,t)=>{bm.init(e,t),vm.init(e,t)}),tB=ge("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=o3),Cn.init(e,t)}),nB=ge("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=td(a))}else t.pattern??(t.pattern=td());Cn.init(e,t)}),rB=ge("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=s3),Cn.init(e,t)}),aB=ge("$ZodURL",(e,t)=>{Cn.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),r=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),iB=ge("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=c3()),Cn.init(e,t)}),oB=ge("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=a3),Cn.init(e,t)}),sB=ge("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=QF),Cn.init(e,t)}),lB=ge("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=e3),Cn.init(e,t)}),cB=ge("$ZodULID",(e,t)=>{t.pattern??(t.pattern=t3),Cn.init(e,t)}),uB=ge("$ZodXID",(e,t)=>{t.pattern??(t.pattern=n3),Cn.init(e,t)}),dB=ge("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=r3),Cn.init(e,t)}),fB=ge("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=E3(t)),Cn.init(e,t)}),pB=ge("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=w3),Cn.init(e,t)}),mB=ge("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=S3(t)),Cn.init(e,t)}),hB=ge("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=i3),Cn.init(e,t)}),gB=ge("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=u3),Cn.init(e,t),e._zod.bag.format="ipv4"}),bB=ge("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=d3),Cn.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})}}}),vB=ge("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=f3(t.delimiter)),Cn.init(e,t),e._zod.bag.format="mac"}),yB=ge("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=p3),Cn.init(e,t)}),wB=ge("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=m3),Cn.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[r,i]=a;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ok(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const xB=ge("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=h3),Cn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ok(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function SB(e){if(!Ck.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ok(n)}const EB=ge("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ck),Cn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{SB(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),_B=ge("$ZodE164",(e,t)=>{t.pattern??(t.pattern=v3),Cn.init(e,t)});function kB(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const r=JSON.parse(atob(a));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const TB=ge("$ZodJWT",(e,t)=>{Cn.init(e,t),e._zod.check=n=>{kB(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),NB=ge("$ZodCustomStringFormat",(e,t)=>{Cn.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),Dk=ge("$ZodNumber",(e,t)=>{_t.init(e,t),e._zod.pattern=e._zod.bag.pattern??N3,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),CB=ge("$ZodNumberFormat",(e,t)=>{$3.init(e,t),Dk.init(e,t)}),jk=ge("$ZodBoolean",(e,t)=>{_t.init(e,t),e._zod.pattern=C3,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Lk=ge("$ZodBigInt",(e,t)=>{_t.init(e,t),e._zod.pattern=k3,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),RB=ge("$ZodBigIntFormat",(e,t)=>{M3.init(e,t),Lk.init(e,t)}),AB=ge("$ZodSymbol",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),IB=ge("$ZodUndefined",(e,t)=>{_t.init(e,t),e._zod.pattern=A3,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,a)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),OB=ge("$ZodNull",(e,t)=>{_t.init(e,t),e._zod.pattern=R3,e._zod.values=new Set([null]),e._zod.parse=(n,a)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),DB=ge("$ZodAny",(e,t)=>{_t.init(e,t),e._zod.parse=n=>n}),jB=ge("$ZodUnknown",(e,t)=>{_t.init(e,t),e._zod.parse=n=>n}),LB=ge("$ZodNever",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),$B=ge("$ZodVoid",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),MB=ge("$ZodDate",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:e}),n}});function wM(e,t,n){e.issues.length&&t.issues.push(...bi(n,e.issues)),t.value[n]=e.value}const PB=ge("$ZodArray",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const c=r[s],u=t.element._zod.run({value:c,issues:[]},a);u instanceof Promise?i.push(u.then(f=>wM(f,n,s))):wM(u,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function av(e,t,n,a){e.issues.length&&t.issues.push(...bi(n,e.issues)),e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function zB(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=LF(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function UB(e,t,n,a,r,i){const s=[],c=r.keySet,u=r.catchall._zod,f=u.def.type;for(const m in t){if(c.has(m))continue;if(f==="never"){s.push(m);continue}const h=u.run({value:t[m],issues:[]},a);h instanceof Promise?e.push(h.then(g=>av(g,n,m,t))):av(h,n,m,t)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const FB=ge("$ZodObject",(e,t)=>{if(_t.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}const a=um(()=>zB(t));Kt(e._zod,"propValues",()=>{const c=t.shape,u={};for(const f in c){const m=c[f]._zod;if(m.values){u[f]??(u[f]=new Set);for(const h of m.values)u[f].add(h)}}return u});const r=Qu,i=t.catchall;let s;e._zod.parse=(c,u)=>{s??(s=a.value);const f=c.value;if(!r(f))return c.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),c;c.value={};const m=[],h=s.shape;for(const g of s.keys){const E=h[g]._zod.run({value:f[g],issues:[]},u);E instanceof Promise?m.push(E.then(x=>av(x,c,g,f))):av(E,c,g,f)}return i?UB(m,f,c,u,a.value,e):m.length?Promise.all(m).then(()=>c):c}}),BB=ge("$ZodObjectJIT",(e,t)=>{FB.init(e,t);const n=e._zod.parse,a=um(()=>zB(t)),r=g=>{const v=new Q3(["shape","payload","ctx"]),E=a.value,x=k=>{const N=dE(k);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};v.write("const input = payload.value;");const w=Object.create(null);let S=0;for(const k of E.keys)w[k]=`key_${S++}`;v.write("const newResult = {};");for(const k of E.keys){const N=w[k],C=dE(k);v.write(`const ${N} = ${x(k)};`),v.write(`
|
|
@@ -43,7 +43,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
43
43
|
`;break;case"id":c=w.includes("\0")?void 0:w;break;case"retry":/^\d+$/.test(w)?a(parseInt(w,10)):n(new iz(`Invalid \`retry\` value: "${w}"`,{type:"invalid-retry",value:w,line:S}));break;default:n(new iz(`Unknown field "${x.length>20?`${x.slice(0,20)}…`:x}"`,{type:"unknown-field",field:x,value:w,line:S}));break}}function v(){u.length>0&&t({id:c,event:f||void 0,data:u.endsWith(`
|
|
44
44
|
`)?u.slice(0,-1):u}),c=void 0,u="",f=""}function E(x={}){i&&x.consume&&h(i),s=!0,c=void 0,u="",f="",i=""}return{feed:m,reset:E}}function _oe(e){const t=[];let n="",a=0;for(;a<e.length;){const r=e.indexOf("\r",a),i=e.indexOf(`
|
|
45
45
|
`,a);let s=-1;if(r!==-1&&i!==-1?s=Math.min(r,i):r!==-1?r===e.length-1?s=-1:s=r:i!==-1&&(s=i),s===-1){n=e.slice(a);break}else{const c=e.slice(a,s);t.push(c),a=s+1,e[a-1]==="\r"&&e[a]===`
|
|
46
|
-
`&&a++}}return[t,n]}class koe extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(i){r=c9({onEvent:s=>{i.enqueue(s)},onError(s){t==="terminate"?i.error(s):typeof t=="function"&&t(s)},onRetry:n,onComment:a})},transform(i){r.feed(i)}})}}const Toe={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Tl extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class Noe{constructor(t,n){var a;this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=YV(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(a=n?.reconnectionOptions)!==null&&a!==void 0?a:Toe}async _authThenStart(){var t;if(!this._authProvider)throw new qa("No auth provider");let n;try{n=await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new qa;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=hv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}async _startOrAuthSse(t){var n,a,r,i;const{resumptionToken:s}=t;try{const c=await this._commonHeaders();c.set("Accept","text/event-stream"),s&&c.set("last-event-id",s);const u=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,{method:"GET",headers:c,signal:(a=this._abortController)===null||a===void 0?void 0:a.signal});if(!u.ok){if(await((r=u.body)===null||r===void 0?void 0:r.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new Tl(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(c){throw(i=this.onerror)===null||i===void 0||i.call(this,c),c}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,a=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(a,t),r)}_scheduleReconnection(t,n=0){var a;const r=this._reconnectionOptions.maxRetries;if(n>=r){(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const i=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,n+1)})},i)}_handleSseStream(t,n,a){if(!t)return;const{onresumptiontoken:r,replayMessageId:i}=n;let s,c=!1,u=!1;(async()=>{var m,h,g,v;try{const E=t.pipeThrough(new TextDecoderStream).pipeThrough(new koe({onRetry:S=>{this._serverRetryMs=S}})).getReader();for(;;){const{value:S,done:_}=await E.read();if(_)break;if(S.id&&(s=S.id,c=!0,r?.(S.id)),!!S.data&&(!S.event||S.event==="message"))try{const k=Ab.parse(JSON.parse(S.data));Qf(k)&&(u=!0,i!==void 0&&(k.id=i)),(m=this.onmessage)===null||m===void 0||m.call(this,k)}catch(k){(h=this.onerror)===null||h===void 0||h.call(this,k)}}(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(E){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${E}`)),(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(S){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${S instanceof Error?S.message:String(S)}`))}}})()}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 qa("No auth provider");if(await Io(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa("Failed to authorize")}async close(){var t,n;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)===null||t===void 0||t.abort(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(t,n){var a,r,i,s,c,u,f;try{const{resumptionToken:m,onresumptiontoken:h}=n||{};if(m){this._startOrAuthSse({resumptionToken:m,replayMessageId:yE(t)?t.id:void 0}).catch(k=>{var N;return(N=this.onerror)===null||N===void 0?void 0:N.call(this,k)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const v={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(t),signal:(a=this._abortController)===null||a===void 0?void 0:a.signal},E=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,v),x=E.headers.get("mcp-session-id");if(x&&(this._sessionId=x),!E.ok){const k=await E.text().catch(()=>null);if(E.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Tl(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:N,scope:C}=Dp(E);if(this._resourceMetadataUrl=N,this._scope=C,await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa;return this._hasCompletedAuthFlow=!0,this.send(t)}if(E.status===403&&this._authProvider){const{resourceMetadataUrl:N,scope:C,error:A}=Dp(E);if(A==="insufficient_scope"){const I=E.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===I)throw new Tl(403,"Server returned 403 after trying upscoping");if(C&&(this._scope=C),N&&(this._resourceMetadataUrl=N),this._lastUpscopingHeader=I??void 0,await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new qa;return this.send(t)}}throw new Tl(E.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,E.status===202){await((i=E.body)===null||i===void 0?void 0:i.cancel()),vre(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var N;return(N=this.onerror)===null||N===void 0?void 0:N.call(this,k)});return}const S=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,_=E.headers.get("content-type");if(S)if(_?.includes("text/event-stream"))this._handleSseStream(E.body,{onresumptiontoken:h},!1);else if(_?.includes("application/json")){const k=await E.json(),N=Array.isArray(k)?k.map(C=>Ab.parse(C)):[Ab.parse(k)];for(const C of N)(s=this.onmessage)===null||s===void 0||s.call(this,C)}else throw await((c=E.body)===null||c===void 0?void 0:c.cancel()),new Tl(-1,`Unexpected content type: ${_}`);else await((u=E.body)===null||u===void 0?void 0:u.cancel())}catch(m){throw(f=this.onerror)===null||f===void 0||f.call(this,m),m}}get sessionId(){return this._sessionId}async terminateSession(){var t,n,a,r;if(this._sessionId)try{const i=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},c=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,s);if(await((a=c.body)===null||a===void 0?void 0:a.cancel()),!c.ok&&c.status!==405)throw new Tl(c.status,`Failed to terminate session: ${c.statusText}`);this._sessionId=void 0}catch(i){throw(r=this.onerror)===null||r===void 0||r.call(this,i),i}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class oz extends Event{constructor(t,n){var a,r;super(t),this.code=(a=n?.code)!=null?a:void 0,this.message=(r=n?.message)!=null?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,a){return a(sz(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(sz(this),n)}}function Coe(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function OE(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(OE).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${OE(e.cause)}`:e.message:`${e}`}function sz(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var u9=e=>{throw TypeError(e)},kN=(e,t,n)=>t.has(e)||u9("Cannot "+n),Gt=(e,t,n)=>(kN(e,t,"read from private field"),n?n.call(e):t.get(e)),dr=(e,t,n)=>t.has(e)?u9("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Pn=(e,t,n,a)=>(kN(e,t,"write to private field"),t.set(e,n),n),No=(e,t,n)=>(kN(e,t,"access private method"),n),ya,Cl,Qc,Ob,wv,dp,uu,fp,Ts,eu,xu,tu,ep,fi,DE,jE,LE,lz,$E,ME,tp,PE,zE;class Db extends EventTarget{constructor(t,n){var a,r;super(),dr(this,fi),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,dr(this,ya),dr(this,Cl),dr(this,Qc),dr(this,Ob),dr(this,wv),dr(this,dp),dr(this,uu),dr(this,fp,null),dr(this,Ts),dr(this,eu),dr(this,xu,null),dr(this,tu,null),dr(this,ep,null),dr(this,jE,async i=>{var s;Gt(this,eu).reset();const{body:c,redirected:u,status:f,headers:m}=i;if(f===204){No(this,fi,tp).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?Pn(this,Qc,new URL(i.url)):Pn(this,Qc,void 0),f!==200){No(this,fi,tp).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){No(this,fi,tp).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(Gt(this,ya)===this.CLOSED)return;Pn(this,ya,this.OPEN);const h=new Event("open");if((s=Gt(this,ep))==null||s.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){No(this,fi,tp).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const g=new TextDecoder,v=c.getReader();let E=!0;do{const{done:x,value:w}=await v.read();w&&Gt(this,eu).feed(g.decode(w,{stream:!x})),x&&(E=!1,Gt(this,eu).reset(),No(this,fi,PE).call(this))}while(E)}),dr(this,LE,i=>{Pn(this,Ts,void 0),!(i.name==="AbortError"||i.type==="aborted")&&No(this,fi,PE).call(this,OE(i))}),dr(this,$E,i=>{typeof i.id=="string"&&Pn(this,fp,i.id);const s=new MessageEvent(i.event||"message",{data:i.data,origin:Gt(this,Qc)?Gt(this,Qc).origin:Gt(this,Cl).origin,lastEventId:i.id||""});Gt(this,tu)&&(!i.event||i.event==="message")&&Gt(this,tu).call(this,s),this.dispatchEvent(s)}),dr(this,ME,i=>{Pn(this,dp,i)}),dr(this,zE,()=>{Pn(this,uu,void 0),Gt(this,ya)===this.CONNECTING&&No(this,fi,DE).call(this)});try{if(t instanceof URL)Pn(this,Cl,t);else if(typeof t=="string")Pn(this,Cl,new URL(t,Roe()));else throw new Error("Invalid URL")}catch{throw Coe("An invalid or illegal string was specified")}Pn(this,eu,c9({onEvent:Gt(this,$E),onRetry:Gt(this,ME)})),Pn(this,ya,this.CONNECTING),Pn(this,dp,3e3),Pn(this,wv,(a=n?.fetch)!=null?a:globalThis.fetch),Pn(this,Ob,(r=n?.withCredentials)!=null?r:!1),No(this,fi,DE).call(this)}get readyState(){return Gt(this,ya)}get url(){return Gt(this,Cl).href}get withCredentials(){return Gt(this,Ob)}get onerror(){return Gt(this,xu)}set onerror(t){Pn(this,xu,t)}get onmessage(){return Gt(this,tu)}set onmessage(t){Pn(this,tu,t)}get onopen(){return Gt(this,ep)}set onopen(t){Pn(this,ep,t)}addEventListener(t,n,a){const r=n;super.addEventListener(t,r,a)}removeEventListener(t,n,a){const r=n;super.removeEventListener(t,r,a)}close(){Gt(this,uu)&&clearTimeout(Gt(this,uu)),Gt(this,ya)!==this.CLOSED&&(Gt(this,Ts)&&Gt(this,Ts).abort(),Pn(this,ya,this.CLOSED),Pn(this,Ts,void 0))}}ya=new WeakMap,Cl=new WeakMap,Qc=new WeakMap,Ob=new WeakMap,wv=new WeakMap,dp=new WeakMap,uu=new WeakMap,fp=new WeakMap,Ts=new WeakMap,eu=new WeakMap,xu=new WeakMap,tu=new WeakMap,ep=new WeakMap,fi=new WeakSet,DE=function(){Pn(this,ya,this.CONNECTING),Pn(this,Ts,new AbortController),Gt(this,wv)(Gt(this,Cl),No(this,fi,lz).call(this)).then(Gt(this,jE)).catch(Gt(this,LE))},jE=new WeakMap,LE=new WeakMap,lz=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Gt(this,fp)?{"Last-Event-ID":Gt(this,fp)}:void 0},cache:"no-store",signal:(e=Gt(this,Ts))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},$E=new WeakMap,ME=new WeakMap,tp=function(e,t){var n;Gt(this,ya)!==this.CLOSED&&Pn(this,ya,this.CLOSED);const a=new oz("error",{code:t,message:e});(n=Gt(this,xu))==null||n.call(this,a),this.dispatchEvent(a)},PE=function(e,t){var n;if(Gt(this,ya)===this.CLOSED)return;Pn(this,ya,this.CONNECTING);const a=new oz("error",{code:t,message:e});(n=Gt(this,xu))==null||n.call(this,a),this.dispatchEvent(a),Pn(this,uu,setTimeout(Gt(this,zE),Gt(this,dp)))},zE=new WeakMap,Db.CONNECTING=0,Db.OPEN=1,Db.CLOSED=2;function Roe(){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 Aoe extends Error{constructor(t,n,a){super(`SSE error: ${n}`),this.code=t,this.event=a}}class Ioe{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=YV(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new qa("No auth provider");let n;try{n=await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new qa;return await this._startOrAuth()}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=hv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}_startOrAuth(){var t,n,a;const r=(a=(n=(t=this===null||this===void 0?void 0:this._eventSourceInit)===null||t===void 0?void 0:t.fetch)!==null&&n!==void 0?n:this._fetch)!==null&&a!==void 0?a:fetch;return new Promise((i,s)=>{this._eventSource=new Db(this._url.href,{...this._eventSourceInit,fetch:async(c,u)=>{const f=await this._commonHeaders();f.set("Accept","text/event-stream");const m=await r(c,{...u,headers:f});if(m.status===401&&m.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=Dp(m);this._resourceMetadataUrl=h,this._scope=g}return m}}),this._abortController=new AbortController,this._eventSource.onerror=c=>{var u;if(c.code===401&&this._authProvider){this._authThenStart().then(i,s);return}const f=new Aoe(c.code,c.message,c);s(f),(u=this.onerror)===null||u===void 0||u.call(this,f)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",c=>{var u;const f=c;try{if(this._endpoint=new URL(f.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(m){s(m),(u=this.onerror)===null||u===void 0||u.call(this,m),this.close();return}i()}),this._eventSource.onmessage=c=>{var u,f;const m=c;let h;try{h=Ab.parse(JSON.parse(m.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(f=this.onmessage)===null||f===void 0||f.call(this,h)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new qa("No auth provider");if(await Io(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa("Failed to authorize")}async close(){var t,n,a;(t=this._abortController)===null||t===void 0||t.abort(),(n=this._eventSource)===null||n===void 0||n.close(),(a=this.onclose)===null||a===void 0||a.call(this)}async send(t){var n,a,r,i;if(!this._endpoint)throw new Error("Not connected");try{const s=await this._commonHeaders();s.set("content-type","application/json");const c={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},u=await((a=this._fetch)!==null&&a!==void 0?a:fetch)(this._endpoint,c);if(!u.ok){const f=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:m,scope:h}=Dp(u);if(this._resourceMetadataUrl=m,this._scope=h,await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${f}`)}await((r=u.body)===null||r===void 0?void 0:r.cancel())}catch(s){throw(i=this.onerror)===null||i===void 0||i.call(this,s),s}}setProtocolVersion(t){this._protocolVersion=t}}var Gu,Ooe=(Gu=class{connector;autoConnect;constructor(t,n=!0){this.connector=t,this.autoConnect=n}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(t,n){t==="notification"&&this.connector.onNotification(n)}async setRoots(t){return this.connector.setRoots(t)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(t){return this.connector.listTools(t)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(t,n={},a){return this.connector.callTool(t,n,a)}async listResources(t,n){return this.connector.listResources(t,n)}async listAllResources(t){return this.connector.listAllResources(t)}async listResourceTemplates(t){return this.connector.listResourceTemplates(t)}async readResource(t,n){return this.connector.readResource(t,n)}async subscribeToResource(t,n){return this.connector.subscribeToResource(t,n)}async unsubscribeFromResource(t,n){return this.connector.unsubscribeFromResource(t,n)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(t,n){return this.connector.getPrompt(t,n)}async request(t,n=null,a){return this.connector.request(t,n,a)}},je(Gu,"MCPSession"),Gu),Wu,Doe=(Wu=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,Ui.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Ui.getInstance().trackClientRemoveServer(t))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(t){return this.config.mcpServers?.[t]}getConfig(){return this.config??{}}async createSession(t,n=!0){const a=this.config.mcpServers??{};if(Object.keys(a).length===0&&$e.warn("No MCP servers defined in config"),!a[t])throw new Error(`Server '${t}' not found in config`);const r=this.createConnectorFromConfig(a[t]),i=new Ooe(r);return n&&await i.initialize(),this.sessions[t]=i,this.activeSessions.includes(t)||this.activeSessions.push(t),i}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&$e.warn("No MCP servers defined in config");for(const a of Object.keys(n))await this.createSession(a,t);return this.sessions}getSession(t){const n=this.sessions[t];return n||null}requireSession(t){const n=this.sessions[t];if(!n)throw new Error(`Session '${t}' not found. Available sessions: ${this.activeSessions.join(", ")||"none"}`);return n}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){$e.warn(`No session exists for server ${t}, nothing to close`);return}try{$e.debug(`Closing session for server ${t}`),await n.disconnect()}catch(a){$e.error(`Error closing session for server '${t}': ${a}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(a=>a!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const a of t)try{$e.debug(`Closing session for server ${a}`),await this.closeSession(a)}catch(r){const i=`Failed to close session for server '${a}': ${r}`;$e.error(i),n.push(i)}n.length?$e.error(`Encountered ${n.length} errors while closing sessions`):$e.debug("All sessions closed successfully")}},je(Wu,"BaseMCPClient"),Wu),Ku,joe=(Ku=class{client=null;connectionManager=null;toolsCache=null;capabilitiesCache=null;serverInfoCache=null;connected=!1;opts;notificationHandlers=[];rootsCache=[];constructor(t={}){this.opts=t,t.roots&&(this.rootsCache=[...t.roots])}trackConnectorInit(t){const n=this.constructor.name;CF.getInstance().trackConnectorInit({connectorType:n,...t}).catch(a=>$e.debug(`Failed to track connector init: ${a}`))}onNotification(t){this.notificationHandlers.push(t),this.client&&this.setupNotificationHandler()}setupNotificationHandler(){this.client&&(this.client.fallbackNotificationHandler=async t=>{switch(t.method){case"notifications/tools/list_changed":await this.refreshToolsCache();break;case"notifications/resources/list_changed":await this.onResourcesListChanged();break;case"notifications/prompts/list_changed":await this.onPromptsListChanged();break}for(const n of this.notificationHandlers)try{await n(t)}catch(a){$e.error("Error in notification handler:",a)}})}async refreshToolsCache(){if(this.client)try{$e.debug("[Auto] Refreshing tools cache due to list_changed notification");const t=await this.client.listTools();this.toolsCache=t.tools??[],$e.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(t){$e.warn("[Auto] Failed to refresh tools cache:",t)}}async onResourcesListChanged(){$e.debug("[Auto] Resources list changed - clients should re-fetch if needed")}async onPromptsListChanged(){$e.debug("[Auto] Prompts list changed - clients should re-fetch if needed")}async setRoots(t){this.rootsCache=[...t],this.client&&($e.debug(`Sending roots/list_changed notification with ${t.length} root(s)`),await this.client.sendRootsListChanged())}getRoots(){return[...this.rootsCache]}setupRootsHandler(){this.client&&this.client.setRequestHandler(zV,async(t,n)=>($e.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`),{roots:this.rootsCache}))}setupSamplingHandler(){if(!this.client){$e.debug("setupSamplingHandler: No client available");return}if(!this.opts.samplingCallback){$e.debug("setupSamplingHandler: No sampling callback provided");return}$e.debug("setupSamplingHandler: Setting up sampling request handler"),this.client.setRequestHandler(gN,async(t,n)=>($e.debug("Server requested sampling, forwarding to callback"),await this.opts.samplingCallback(t.params))),$e.debug("setupSamplingHandler: Sampling handler registered successfully")}setupElicitationHandler(){if(!this.client){$e.debug("setupElicitationHandler: No client available");return}if(!this.opts.elicitationCallback){$e.debug("setupElicitationHandler: No elicitation callback provided");return}$e.debug("setupElicitationHandler: Setting up elicitation request handler"),this.client.setRequestHandler(vN,async(t,n)=>($e.debug("Server requested elicitation, forwarding to callback"),await this.opts.elicitationCallback(t.params))),$e.debug("setupElicitationHandler: Elicitation handler registered successfully")}async disconnect(){if(!this.connected){$e.debug("Not connected to MCP implementation");return}$e.debug("Disconnecting from MCP implementation"),await this.cleanupResources(),this.connected=!1,$e.debug("Disconnected from MCP implementation")}get isClientConnected(){return this.client!=null}async initialize(t=this.opts.defaultRequestOptions??{}){if(!this.client)throw new Error("MCP client is not connected");$e.debug("Caching server capabilities & tools");const n=this.client.getServerCapabilities();this.capabilitiesCache=n||null;const a=this.client.getServerVersion();this.serverInfoCache=a||null;const r=await this.client.listTools(void 0,t);return this.toolsCache=r.tools??[],$e.debug(`Fetched ${this.toolsCache.length} tools from server`),$e.debug("Server capabilities:",n),$e.debug("Server info:",a),n}get tools(){if(!this.toolsCache)throw new Error("MCP client is not initialized; call initialize() first");return this.toolsCache}get serverCapabilities(){return this.capabilitiesCache||{}}get serverInfo(){return this.serverInfoCache}async callTool(t,n,a){if(!this.client)throw new Error("MCP client is not connected");const r=a?{...a}:void 0;r?.resetTimeoutOnProgress&&!r.onprogress&&(r.onprogress=()=>{},$e.debug(`[BaseConnector] Added onprogress callback for tool '${t}' to enable progressToken`)),$e.debug(`Calling tool '${t}' with args`,n);const i=await this.client.callTool({name:t,arguments:n},void 0,r);return $e.debug(`Tool '${t}' returned`,i),i}async listTools(t){if(!this.client)throw new Error("MCP client is not connected");return(await this.client.listTools(void 0,t)).tools??[]}async listResources(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug("Listing resources",t?`with cursor: ${t}`:""),await this.client.listResources({cursor:t},n)}async listAllResources(t){if(!this.client)throw new Error("MCP client is not connected");if(!this.capabilitiesCache?.resources)return $e.debug("Server does not advertise resources capability, skipping"),{resources:[]};try{$e.debug("Listing all resources (with auto-pagination)");const n=[];let a;do{const r=await this.client.listResources({cursor:a},t);n.push(...r.resources||[]),a=r.nextCursor}while(a);return{resources:n}}catch(n){if(n.code===-32601)return $e.debug("Server advertised resources but method not found"),{resources:[]};throw n}}async listResourceTemplates(t){if(!this.client)throw new Error("MCP client is not connected");return $e.debug("Listing resource templates"),await this.client.listResourceTemplates(void 0,t)}async readResource(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Reading resource ${t}`),await this.client.readResource({uri:t},n)}async subscribeToResource(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Subscribing to resource: ${t}`),await this.client.subscribeResource({uri:t},n)}async unsubscribeFromResource(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Unsubscribing from resource: ${t}`),await this.client.unsubscribeResource({uri:t},n)}async listPrompts(){if(!this.client)throw new Error("MCP client is not connected");if(!this.capabilitiesCache?.prompts)return $e.debug("Server does not advertise prompts capability, skipping"),{prompts:[]};try{return $e.debug("Listing prompts"),await this.client.listPrompts()}catch(t){if(t.code===-32601)return $e.debug("Server advertised prompts but method not found"),{prompts:[]};throw t}}async getPrompt(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Getting prompt ${t}`),await this.client.getPrompt({name:t,arguments:n})}async request(t,n=null,a){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Sending raw request '${t}' with params`,n),await this.client.request({method:t,params:n??{}},void 0,a)}async cleanupResources(){const t=[];if(this.client)try{typeof this.client.close=="function"&&await this.client.close()}catch(n){const a=`Error closing client: ${n}`;$e.warn(a),t.push(a)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(n){const a=`Error stopping connection manager: ${n}`;$e.warn(a),t.push(a)}finally{this.connectionManager=null}this.toolsCache=null,t.length&&$e.warn(`Resource cleanup finished with ${t.length} issue(s)`)}},je(Ku,"BaseConnector"),Ku),Zu,Loe=(Zu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),$e.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){$e.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?$e.debug(`${this.constructor.name} task aborted successfully`):$e.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,$e.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(){$e.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),$e.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,$e.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){$e.warn(`Error closing connection in ${this.constructor.name}: ${t}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((t,n)=>{if(!this._abortController)return;const a=this._abortController.signal;if(a.aborted){t();return}const r=je(()=>{a.removeEventListener("abort",r),t()},"onAbort");a.addEventListener("abort",r)})}},je(Zu,"ConnectionManager"),Zu),Yu,$oe=(Yu=class extends Loe{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 Ioe(this.url,this.opts),n=t.send.bind(t);return t.send=async a=>{const r=je(async i=>{if(Array.isArray(i))for(const s of i)await n(s);else await n(i)},"sendMessage");try{await r(a)}catch(i){if(i?.code===404&&t.sessionId&&!this.reinitializing){$e.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),$e.info("[SSE] Re-initialization successful, retrying request"),await r(a)}finally{this.reinitializing=!1}}else throw i}},this._transport=t,$e.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){$e.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){$e.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},je(Yu,"SseConnectionManager"),Yu),qu,Moe=(qu=class extends joe{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;transportType=null;streamableTransport=null;constructor(t,n={}){super(n),this.baseUrl=t.replace(/\/$/,""),this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.gatewayUrl=n.gatewayUrl,this.serverId=n.serverId,this.gatewayUrl&&(this.headers["X-Target-URL"]=this.baseUrl,this.serverId&&(this.headers["X-Server-Id"]=this.serverId)),this.timeout=n.timeout??3e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1,this.disableSseFallback=n.disableSseFallback??!1}async connect(){if(this.connected){$e.debug("Already connected to MCP implementation");return}const t=this.gatewayUrl?this.gatewayUrl.replace(/\/$/,""):this.baseUrl;if(this.preferSse){$e.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}$e.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{$e.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),$e.info("✅ Successfully connected via streamable HTTP")}catch(n){let a="Unknown error",r=!1;if(n instanceof Tl){const i=n;r=i.code===401,i.code===400&&i.message.includes("Missing session ID")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",$e.warn(`⚠️ ${a}`)):i.code===404||i.code===405?(a=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,$e.debug(a)):(a=`Server returned ${i.code}: ${i.message}`,$e.debug(a))}else if(n instanceof Error){const i=n.toString(),s=n.message||"";r=i.includes("401")||s.includes("Unauthorized"),i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||s.includes("FastMCP session ID error")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",$e.warn(`⚠️ ${a}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(a="Server doesn't support streamable HTTP (405/404)",$e.debug(a)):(a=`Streamable HTTP failed: ${n.message}`,$e.debug(a))}if(r){$e.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}if(this.disableSseFallback)throw $e.info("SSE fallback disabled - failing connection"),await this.cleanupResources(),new Error(`Streamable HTTP connection failed: ${a}`);$e.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if($e.error("Failed to connect with both transports:"),$e.error(` Streamable HTTP: ${a}`),$e.error(` SSE: ${i}`),await this.cleanupResources(),i?.message?.includes("401")||i?.message?.includes("Unauthorized")){const c=new Error("Authentication required");throw c.code=401,c}throw new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(t){try{const n=new Noe(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let a=n;if(this.opts.wrapTransport){const i=this.baseUrl;a=this.opts.wrapTransport(a,i)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};$e.debug("Creating Client with capabilities:",JSON.stringify(r.capabilities,null,2)),this.client=new tz(this.clientInfo,r),this.setupRootsHandler(),$e.debug("Roots handler registered before connect");try{await this.client.connect(a,{timeout:Math.min(this.timeout,3e3)});const i=n.sessionId;i?$e.debug(`Session ID obtained: ${i}`):$e.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(i){if(i instanceof Error){const s=i.message||i.toString();if(s.includes("Missing session ID")||s.includes("Bad Request: Missing session ID")||s.includes("Mcp-Session-Id header is required")){const c=new Error(`Session ID error: ${s}. The SDK should automatically extract session ID from initialize response.`);throw c.cause=i,c}}throw i}this.streamableTransport=n,this.connectionManager={stop:je(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){$e.warn(`Error closing Streamable HTTP transport: ${i}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$e.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 $oe(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const r=this.baseUrl;n=this.opts.wrapTransport(n,r)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};$e.debug("Creating Client with capabilities (SSE):",JSON.stringify(a.capabilities,null,2)),this.client=new tz(this.clientInfo,a),this.setupRootsHandler(),$e.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$e.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}},je(qu,"HttpConnector"),qu),Fl,Poe=(Fl=class extends Doe{static getPackageVersion(){return pk()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Ui.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>$e.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new Fl(t)}createConnectorFromConfig(t){const{url:n,headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:f,disableSseFallback:m,preferSse:h}=t;if(!n)throw new Error("Server URL is required");const g={headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:f,disableSseFallback:m,preferSse:h};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new Moe(n,g)}},je(Fl,"BrowserMCPClient"),Fl);function du(e){const t=je(()=>{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(d9).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}je(du,"sanitizeUrl");function d9([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}je(d9,"sanitizeParam");var Xu,jb=(Xu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;useRedirectFlow;onPopupWindow;constructor(t,n={}){this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||"mcp:auth",this.serverUrlHash=this.hashString(t),this.clientName=n.clientName||"mcp-use",this.clientUri=n.clientUri||(typeof window<"u"?window.location.origin:""),this.callbackUrl=du(n.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=n.preventAutoAuth,this.useRedirectFlow=n.useRedirectFlow,this.onPopupWindow=n.onPopupWindow}get redirectUrl(){return du(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:"none",grant_types:["authorization_code","refresh_token"],response_types:["code"],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){const t=this.getKey("client_info"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,a),localStorage.removeItem(t);return}}async saveClientInformation(t){const n=this.getKey("client_info");localStorage.setItem(n,JSON.stringify(t))}async tokens(){const t=this.getKey("tokens"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,a),localStorage.removeItem(t);return}}async saveTokens(t){const n=this.getKey("tokens");localStorage.setItem(n,JSON.stringify(t)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(t){const n=this.getKey("code_verifier");localStorage.setItem(n,t)}async codeVerifier(){const t=this.getKey("code_verifier"),n=localStorage.getItem(t);if(!n)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${t}. Auth flow likely corrupted or timed out.`);return n}async prepareAuthorizationUrl(t){const n=globalThis.crypto.randomUUID(),a=`${this.storageKeyPrefix}:state_${n}`,r={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:this.useRedirectFlow&&typeof window<"u"?window.location.href:void 0};localStorage.setItem(a,JSON.stringify(r)),t.searchParams.set("state",n);const i=t.toString(),s=du(i);return localStorage.setItem(this.getKey("last_auth_url"),s),s}async redirectToAuthorization(t){const n=await this.prepareAuthorizationUrl(t);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=n;return}const a="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const r=window.open(n,`mcp_auth_${this.serverUrlHash}`,a);this.onPopupWindow&&this.onPopupWindow(n,a,r),!r||r.closed||typeof r.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(r.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(r){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,r)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?du(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,a=[];let r=0;for(let s=0;s<localStorage.length;s++){const c=localStorage.key(s);if(c){if(c.startsWith(t))a.push(c);else if(c.startsWith(n))try{const u=localStorage.getItem(c);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&a.push(c)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${c} during clearStorage:`,u)}}}return[...new Set(a)].forEach(s=>{localStorage.removeItem(s),r++}),r}hashString(t){let n=0;for(let a=0;a<t.length;a++){const r=t.charCodeAt(a);n=(n<<5)-n+r,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},je(Xu,"BrowserOAuthClientProvider"),Xu);async function TN(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),a=e.get("error"),r=e.get("error_description"),i="[mcp-callback]";console.log(`${i} Handling callback...`,{code:t,state:n,error:a,errorDescription:r});let s=null,c=null;const u=n?`mcp:auth:state_${n}`:null;try{if(a)throw new Error(`OAuth error: ${a} - ${r||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!u)throw new Error("State parameter not found or invalid in callback query parameters.");const f=localStorage.getItem(u);if(!f)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(f)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!c.expiry||c.expiry<Date.now())throw localStorage.removeItem(u),new Error("OAuth state has expired. Please try initiating authentication again.");if(!c.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:m,...h}=c.providerOptions;console.log(`${i} Re-instantiating provider for server: ${m}`),s=new jb(m,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await Io(s,{serverUrl:g,authorizationCode:t});if(v==="AUTHORIZED")if(console.log(`${i} Authorization successful via SDK auth().`),c.flowType==="redirect"&&c.returnUrl)console.log(`${i} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(u),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${i} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(u),window.close();else{console.warn(`${i} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(u);const x=window.location.pathname.split("/").filter(Boolean),w=x.length>0&&x[x.length-1]==="callback"?"/"+x.slice(0,-2).join("/"):"/";window.location.href=w||"/"}else throw console.warn(`${i} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(f){console.error(`${i} 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 v=document.createElement("p");v.style.color="red",v.style.backgroundColor="#ffebeb",v.style.border="1px solid red",v.style.padding="10px",v.style.borderRadius="4px",v.textContent=m,h.appendChild(v);const 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(`${i} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),s&&(localStorage.removeItem(s.getKey("code_verifier")),localStorage.removeItem(s.getKey("last_auth_url")))}}je(TN,"onMcpAuthorization");var cS={exports:{}},Et={};var cz;function zoe(){if(cz)return Et;cz=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(P){return P===null||typeof P!="object"?null:(P=g&&P[g]||P["@@iterator"],typeof P=="function"?P:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function S(P,F,U){this.props=P,this.context=F,this.refs=w,this.updater=U||E}S.prototype.isReactComponent={},S.prototype.setState=function(P,F){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,F,"setState")},S.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function _(){}_.prototype=S.prototype;function k(P,F,U){this.props=P,this.context=F,this.refs=w,this.updater=U||E}var N=k.prototype=new _;N.constructor=k,x(N,S.prototype),N.isPureReactComponent=!0;var C=Array.isArray;function A(){}var I={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(P,F,U){var L=U.ref;return{$$typeof:e,type:P,key:F,ref:L!==void 0?L:null,props:U}}function j(P,F){return M(P.type,F,P.props)}function B(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function G(P){var F={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(U){return F[U]})}var ee=/\/+/g;function te(P,F){return typeof P=="object"&&P!==null&&P.key!=null?G(""+P.key):F.toString(36)}function ae(P){switch(P.status){case"fulfilled":return P.value;case"rejected":throw P.reason;default:switch(typeof P.status=="string"?P.then(A,A):(P.status="pending",P.then(function(F){P.status==="pending"&&(P.status="fulfilled",P.value=F)},function(F){P.status==="pending"&&(P.status="rejected",P.reason=F)})),P.status){case"fulfilled":return P.value;case"rejected":throw P.reason}}throw P}function V(P,F,U,L,$){var W=typeof P;(W==="undefined"||W==="boolean")&&(P=null);var K=!1;if(P===null)K=!0;else switch(W){case"bigint":case"string":case"number":K=!0;break;case"object":switch(P.$$typeof){case e:case t:K=!0;break;case m:return K=P._init,V(K(P._payload),F,U,L,$)}}if(K)return $=$(P),K=L===""?"."+te(P,0):L,C($)?(U="",K!=null&&(U=K.replace(ee,"$&/")+"/"),V($,F,U,"",function(oe){return oe})):$!=null&&(B($)&&($=j($,U+($.key==null||P&&P.key===$.key?"":(""+$.key).replace(ee,"$&/")+"/")+K)),F.push($)),1;K=0;var Y=L===""?".":L+":";if(C(P))for(var se=0;se<P.length;se++)L=P[se],W=Y+te(L,se),K+=V(L,F,U,W,$);else if(se=v(P),typeof se=="function")for(P=se.call(P),se=0;!(L=P.next()).done;)L=L.value,W=Y+te(L,se++),K+=V(L,F,U,W,$);else if(W==="object"){if(typeof P.then=="function")return V(ae(P),F,U,L,$);throw F=String(P),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.")}return K}function q(P,F,U){if(P==null)return P;var L=[],$=0;return V(P,L,"","",function(W){return F.call(U,W,$++)}),L}function H(P){if(P._status===-1){var F=P._result;F=F(),F.then(function(U){(P._status===0||P._status===-1)&&(P._status=1,P._result=U)},function(U){(P._status===0||P._status===-1)&&(P._status=2,P._result=U)}),P._status===-1&&(P._status=0,P._result=F)}if(P._status===1)return P._result.default;throw P._result}var ie=typeof reportError=="function"?reportError:function(P){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var F=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof P=="object"&&P!==null&&typeof P.message=="string"?String(P.message):String(P),error:P});if(!window.dispatchEvent(F))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",P);return}console.error(P)},re={map:q,forEach:function(P,F,U){q(P,function(){F.apply(this,arguments)},U)},count:function(P){var F=0;return q(P,function(){F++}),F},toArray:function(P){return q(P,function(F){return F})||[]},only:function(P){if(!B(P))throw Error("React.Children.only expected to receive a single React element child.");return P}};return Et.Activity=h,Et.Children=re,Et.Component=S,Et.Fragment=n,Et.Profiler=r,Et.PureComponent=k,Et.StrictMode=a,Et.Suspense=u,Et.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,Et.__COMPILER_RUNTIME={__proto__:null,c:function(P){return I.H.useMemoCache(P)}},Et.cache=function(P){return function(){return P.apply(null,arguments)}},Et.cacheSignal=function(){return null},Et.cloneElement=function(P,F,U){if(P==null)throw Error("The argument must be a React element, but you passed "+P+".");var L=x({},P.props),$=P.key;if(F!=null)for(W in F.key!==void 0&&($=""+F.key),F)!O.call(F,W)||W==="key"||W==="__self"||W==="__source"||W==="ref"&&F.ref===void 0||(L[W]=F[W]);var W=arguments.length-2;if(W===1)L.children=U;else if(1<W){for(var K=Array(W),Y=0;Y<W;Y++)K[Y]=arguments[Y+2];L.children=K}return M(P.type,$,L)},Et.createContext=function(P){return P={$$typeof:s,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null},P.Provider=P,P.Consumer={$$typeof:i,_context:P},P},Et.createElement=function(P,F,U){var L,$={},W=null;if(F!=null)for(L in F.key!==void 0&&(W=""+F.key),F)O.call(F,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&($[L]=F[L]);var K=arguments.length-2;if(K===1)$.children=U;else if(1<K){for(var Y=Array(K),se=0;se<K;se++)Y[se]=arguments[se+2];$.children=Y}if(P&&P.defaultProps)for(L in K=P.defaultProps,K)$[L]===void 0&&($[L]=K[L]);return M(P,W,$)},Et.createRef=function(){return{current:null}},Et.forwardRef=function(P){return{$$typeof:c,render:P}},Et.isValidElement=B,Et.lazy=function(P){return{$$typeof:m,_payload:{_status:-1,_result:P},_init:H}},Et.memo=function(P,F){return{$$typeof:f,type:P,compare:F===void 0?null:F}},Et.startTransition=function(P){var F=I.T,U={};I.T=U;try{var L=P(),$=I.S;$!==null&&$(U,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(A,ie)}catch(W){ie(W)}finally{F!==null&&U.types!==null&&(F.types=U.types),I.T=F}},Et.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},Et.use=function(P){return I.H.use(P)},Et.useActionState=function(P,F,U){return I.H.useActionState(P,F,U)},Et.useCallback=function(P,F){return I.H.useCallback(P,F)},Et.useContext=function(P){return I.H.useContext(P)},Et.useDebugValue=function(){},Et.useDeferredValue=function(P,F){return I.H.useDeferredValue(P,F)},Et.useEffect=function(P,F){return I.H.useEffect(P,F)},Et.useEffectEvent=function(P){return I.H.useEffectEvent(P)},Et.useId=function(){return I.H.useId()},Et.useImperativeHandle=function(P,F,U){return I.H.useImperativeHandle(P,F,U)},Et.useInsertionEffect=function(P,F){return I.H.useInsertionEffect(P,F)},Et.useLayoutEffect=function(P,F){return I.H.useLayoutEffect(P,F)},Et.useMemo=function(P,F){return I.H.useMemo(P,F)},Et.useOptimistic=function(P,F){return I.H.useOptimistic(P,F)},Et.useReducer=function(P,F,U){return I.H.useReducer(P,F,U)},Et.useRef=function(P){return I.H.useRef(P)},Et.useState=function(P){return I.H.useState(P)},Et.useSyncExternalStore=function(P,F,U){return I.H.useSyncExternalStore(P,F,U)},Et.useTransition=function(){return I.H.useTransition()},Et.version="19.2.3",Et}var uz;function NN(){return uz||(uz=1,cS.exports=zoe()),cS.exports}var y=NN();const Q=ay(y),kd=wJ({__proto__:null,default:Q},[y]);function UE(e,t){if(!e)throw new Error(t)}je(UE,"assert");var dz=3e3,Uoe=5e3;function CN(e){const{url:t,enabled:n=!0,clientName:a,clientUri:r,callbackUrl:i=typeof window<"u"?du(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:s="mcp:auth",clientConfig:c={},customHeaders:u={},debug:f=!1,autoRetry:m=!1,autoReconnect:h=dz,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:E=!1,onPopupWindow:x,timeout:w=3e4,sseReadTimeout:S=3e5,wrapTransport:_,onNotification:k,samplingCallback:N,onElicitation:C}=e,[A,I]=y.useState("discovering"),[O,M]=y.useState([]),[j,B]=y.useState([]),[G,ee]=y.useState([]),[te,ae]=y.useState([]),[V,q]=y.useState(),[H,ie]=y.useState(),[re,P]=y.useState(void 0),[F,U]=y.useState([]),[L,$]=y.useState(void 0),[W,K]=y.useState(void 0),Y=y.useRef(null),se=y.useRef(null),oe=y.useRef(null),X=y.useRef(!1),J=y.useRef(!0),le=y.useRef(0),pe=y.useRef(null),me=y.useRef(A),_e=y.useRef(h),ze=y.useRef(null);y.useEffect(()=>{me.current=A,_e.current=h},[A,h]);const ue=y.useCallback((Se,Oe,...Ge)=>{const lt=Ge.length>0?`${Oe} ${Ge.map(Xe=>JSON.stringify(Xe)).join(" ")}`:Oe;console[Se](`[useMcp] ${lt}`),J.current&&U(Xe=>[...Xe.slice(-100),{level:Se,message:lt,timestamp:Date.now()}])},[]),Pe=y.useCallback(async(Se=!1)=>{if(Se||ue("info","Disconnecting..."),X.current=!1,pe.current&&clearTimeout(pe.current),pe.current=null,Y.current)try{const Oe="inspector-server",Ge=Y.current.getSession(Oe);Ge&&Ge._healthCheckCleanup&&(Ge._healthCheckCleanup(),Ge._healthCheckCleanup=null),await Y.current.closeSession(Oe)}catch(Oe){Se||ue("warn","Error closing session:",Oe)}Y.current=null,J.current&&!Se&&(I("discovering"),M([]),B([]),ee([]),ae([]),P(void 0),$(void 0))},[ue]),Ye=y.useCallback((Se,Oe)=>{if(ue("error",Se,Oe??""),J.current){I("failed"),P(Se);const Ge=se.current?.getLastAttemptedAuthUrl();Ge&&($(Ge),ue("info","Manual authentication URL may be available.",Ge))}X.current=!1,t&&Ui.getInstance().trackUseMcpConnection({url:t,transportType:g,success:!1,errorType:Oe?.name||"UnknownError",hasOAuth:!!se.current,hasSampling:!!N,hasElicitation:!!C}).catch(()=>{})},[ue,t,g,N,C]),fe=y.useCallback(async()=>{if(!n||!t){ue("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(X.current){ue("debug","Connection attempt already in progress.");return}if(!J.current){ue("debug","Connect called after unmount, aborting.");return}X.current=!0,le.current+=1,P(void 0),$(void 0),ze.current=null,I("discovering"),ue("info",`Connecting attempt #${le.current} to ${t}...`),se.current||(se.current=new jb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:E,onPopupWindow:x}),ue("debug","BrowserOAuthClientProvider initialized in connect.")),Y.current||(Y.current=new Poe,ue("debug","BrowserMCPClient initialized in connect."));const Se=je(async(Ge,lt=!1)=>{ue("info",`Attempting connection with transport: ${Ge}`);try{const Xe="inspector-server",it={url:t,transport:Ge==="sse"?"http":Ge,disableSseFallback:Ge==="http",preferSse:Ge==="sse"};if(u&&Object.keys(u).length>0&&(it.headers=u),se.current){const et=await se.current.tokens();et?.access_token&&(it.headers={...it.headers,Authorization:`Bearer ${et.access_token}`})}Y.current.addServer(Xe,{...it,authProvider:se.current,clientOptions:c,samplingCallback:N,elicitationCallback:C,wrapTransport:_?et=>(console.log("[useMcp] Applying transport wrapper for server:",Xe,"url:",t),_(et,t)):void 0});const mt=await Y.current.createSession(Xe,!1);mt.on("notification",et=>{k?.(et),et.method==="notifications/tools/list_changed"?(ue("info","Tools list changed, auto-refreshing..."),at().catch(Lt=>ue("warn","Auto-refresh tools failed:",Lt))):et.method==="notifications/resources/list_changed"?(ue("info","Resources list changed, auto-refreshing..."),yt().catch(Lt=>ue("warn","Auto-refresh resources failed:",Lt))):et.method==="notifications/prompts/list_changed"&&(ue("info","Prompts list changed, auto-refreshing..."),xn().catch(Lt=>ue("warn","Auto-refresh prompts failed:",Lt)))}),await mt.initialize(),ue("info","✅ Successfully connected to MCP server"),ue("info","Server info:",mt.connector.serverInfo),ue("info","Server capabilities:",mt.connector.serverCapabilities),console.log("[useMcp] Server info:",mt.connector.serverInfo),console.log("[useMcp] Server capabilities:",mt.connector.serverCapabilities),I("ready"),ze.current=Ge;const Ze=je(()=>{let et=null,Lt=Date.now();const dn=1e4,nn=3e4;return et=setInterval(je(async()=>{if(!J.current||me.current!=="ready"){et&&(clearInterval(et),et=null);return}try{await mt.connector.listTools(),Lt=Date.now()}catch{const Nt=Date.now()-Lt;Nt>nn&&(ue("warn",`Connection appears to be broken (no response for ${Math.round(Nt/1e3)}s), attempting to reconnect...`),et&&(clearInterval(et),et=null),_e.current&&J.current&&(I("discovering"),ue("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{J.current&&me.current==="discovering"&&fe()},typeof _e.current=="number"?_e.current:dz)))}},"checkConnectionHealth"),dn),()=>{et&&(clearInterval(et),et=null)}},"setupConnectionMonitoring");if(h){const et=Ze();mt._healthCheckCleanup=et}Ui.getInstance().trackUseMcpConnection({url:t,transportType:Ge,success:!0,hasOAuth:!!se.current,hasSampling:!!N,hasElicitation:!!C}).catch(()=>{}),M(mt.connector.tools||[]);const vt=await mt.connector.listAllResources();B(vt.resources||[]);const wt=await mt.connector.listPrompts();ae(wt.prompts||[]);const kt=mt.connector.serverInfo,Wn=mt.connector.serverCapabilities;if(kt){console.log("[useMcp] Server info:",kt),q(kt);const et=(async()=>{try{const Lt=kt.icons;if(Lt&&Array.isArray(Lt)&&Lt.length>0){const dn=Lt[0].src||Lt[0].url;if(dn){ue("info","Server provided icon:",dn);const on=await(await fetch(dn)).blob(),gr=await new Promise((Nt,Qr)=>{const br=new FileReader;br.onloadend=()=>Nt(br.result),br.onerror=Qr,br.readAsDataURL(on)});return J.current&&(q(Nt=>Nt?{...Nt,icon:gr}:void 0),ue("debug","Server icon converted to base64")),gr}}if(t){const dn=await vF(t);if(dn&&J.current)return q(nn=>nn?{...nn,icon:dn}:void 0),ue("debug","Favicon detected and added to serverInfo"),dn}return null}catch(Lt){return ue("debug","Icon loading failed (non-critical):",Lt),null}})();oe.current=et}if(Wn&&(console.log("[useMcp] Server capabilities:",Wn),ie(Wn)),se.current){const et=await se.current.tokens();if(et?.access_token){const Lt=et.expires_in?Date.now()+et.expires_in*1e3:void 0;K({access_token:et.access_token,token_type:et.token_type||"Bearer",expires_at:Lt,refresh_token:et.refresh_token,scope:et.scope})}}return"success"}catch(Xe){const it=Xe,mt=it?.message||String(Xe);if(it.code===401||mt.includes("401")||mt.includes("Unauthorized")){if(se.current){ue("info","Authentication required. OAuth provider available.");try{const{auth:Ze}=await Mr(async()=>{const{auth:wt}=await Promise.resolve().then(()=>az);return{auth:wt}},void 0),vt=new URL(t).origin;Ze(se.current,{serverUrl:vt}).catch(()=>{}),setTimeout(()=>{if(J.current){const wt=se.current?.getLastAttemptedAuthUrl();wt?($(wt),ue("info","Manual authentication URL available:",wt)):ue("warn","Could not generate authentication URL")}},100)}catch(Ze){ue("warn","Error generating auth URL:",Ze)}return J.current&&I("pending_auth"),X.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(Ye("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Ye("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Ye(mt,it instanceof Error?it:new Error(String(it))),"failed"}},"tryConnectWithTransport");let Oe="failed";if(g==="sse")ue("debug","Using SSE-only transport mode"),Oe=await Se("sse");else if(g==="http")ue("debug","Using HTTP-only transport mode"),Oe=await Se("http");else{ue("debug","Using auto transport mode (HTTP with SSE fallback)");const Ge=await Se("http");Ge==="fallback"&&J.current&&me.current!=="authenticating"?(ue("info","HTTP failed, attempting SSE fallback..."),Oe=await Se("sse")):Oe=Ge}(Oe==="success"||Oe==="failed"||Oe==="auth_redirect")&&(X.current=!1),ue("debug",`Connection sequence finished with status: ${Oe}`)},[ue,Ye,Pe,t,s,a,r,i,c.name,c.version,u,g,v,E,x,n,w,S]),De=y.useCallback(async(Se,Oe,Ge)=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot call tool "${Se}".`);ue("info",`Calling tool: ${Se}`,Oe);const lt=Date.now();try{const it=Y.current.getSession("inspector-server");if(!it)throw new Error("No active session found");const mt=await it.connector.callTool(Se,Oe||{},Ge);return ue("info",`Tool "${Se}" call successful:`,mt),Ui.getInstance().trackUseMcpToolCall({toolName:Se,success:!0,executionTimeMs:Date.now()-lt}).catch(()=>{}),mt}catch(Xe){throw ue("error",`Tool "${Se}" call failed:`,Xe),Ui.getInstance().trackUseMcpToolCall({toolName:Se,success:!1,errorType:Xe instanceof Error?Xe.name:"UnknownError",executionTimeMs:Date.now()-lt}).catch(()=>{}),Xe}},[A]),He=y.useCallback(()=>{me.current==="failed"?(ue("info","Retry requested..."),fe()):ue("warn",`Retry called but state is not 'failed' (state: ${me.current}). Ignoring.`)},[ue,fe]),Ee=y.useCallback(async()=>{ue("info","Manual authentication requested...");const Se=me.current;if(Se==="failed")ue("info","Attempting to reconnect and authenticate via retry..."),He();else if(Se==="pending_auth"){ue("info","Proceeding with authentication from pending state...");try{UE(se.current,"Auth Provider not available for manual auth"),UE(t,"Server URL is required for authentication"),ue("info","Clearing all OAuth state and initiating fresh flow...");const Oe=`${s}:${se.current.serverUrlHash}`;Object.keys(localStorage).forEach(it=>{it.startsWith(Oe)&&(ue("debug",`Removing stale OAuth key: ${it}`),localStorage.removeItem(it)),it.startsWith(`${s}:state_`)&&(ue("debug",`Removing orphaned state: ${it}`),localStorage.removeItem(it))}),I("authenticating");const Ge=new jb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:E,onPopupWindow:x});se.current=Ge,ue("info","Triggering fresh OAuth authorization...");const{auth:lt}=await Mr(async()=>{const{auth:it}=await Promise.resolve().then(()=>az);return{auth:it}},void 0),Xe=new URL(t).origin;lt(Ge,{serverUrl:Xe}).catch(it=>{ue("info","OAuth flow initiated:",it instanceof Error?it.message:"Redirecting...")})}catch(Oe){if(!J.current)return;I("pending_auth"),ue("error",`Manual authentication failed: ${Oe instanceof Error?Oe.message:String(Oe)}`)}}else if(Se==="authenticating"){ue("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Oe=se.current?.getLastAttemptedAuthUrl();Oe&&!L&&($(Oe),ue("info","Manual authentication URL retrieved:",Oe))}else ue("info",`Client not in a state requiring manual authentication trigger (state: ${Se}). If needed, try disconnecting and reconnecting.`)},[ue,He,L,t,E,x,s,a,r,i]),Ne=y.useCallback(()=>{if(se.current){const Se=se.current.clearStorage();ue("info",`Cleared ${Se} item(s) from localStorage for ${t}.`),$(void 0),Pe()}else ue("warn","Auth provider not initialized, cannot clear storage.")},[t,ue,Pe]),Ae=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list resources.`);ue("info","Listing resources");try{const Oe=Y.current.getSession("inspector-server");if(!Oe)throw new Error("No active session found");const Ge=await Oe.connector.listAllResources();B(Ge.resources||[]),ue("info","Resources listed successfully")}catch(Se){throw ue("error","List resources failed:",Se),Se}},[A]),We=y.useCallback(async Se=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot read resource.`);ue("info",`Reading resource: ${Se}`);try{const Ge=Y.current.getSession("inspector-server");if(!Ge)throw new Error("No active session found");const lt=await Ge.connector.readResource(Se);return ue("info","Resource read successful:",lt),Ui.getInstance().trackUseMcpResourceRead({resourceUri:Se,success:!0}).catch(()=>{}),lt}catch(Oe){throw ue("error","Resource read failed:",Oe),Ui.getInstance().trackUseMcpResourceRead({resourceUri:Se,success:!1,errorType:Oe instanceof Error?Oe.name:"UnknownError"}).catch(()=>{}),Oe}},[A]),ft=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list prompts.`);ue("info","Listing prompts");try{const Oe=Y.current.getSession("inspector-server");if(!Oe)throw new Error("No active session found");const Ge=await Oe.connector.listPrompts();ae(Ge.prompts||[]),ue("info","Prompts listed successfully")}catch(Se){throw ue("error","List prompts failed:",Se),Se}},[A]),at=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current){ue("debug","Cannot refresh tools - client not ready");return}ue("debug","Refreshing tools list");try{const Oe=Y.current.getSession("inspector-server");if(!Oe){ue("warn","No active session found for tools refresh");return}const Ge=await Oe.connector.listTools();M(Ge||[]),ue("info","Tools list refreshed successfully")}catch(Se){ue("warn","Failed to refresh tools:",Se)}},[ue]),yt=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current){ue("debug","Cannot refresh resources - client not ready");return}ue("debug","Refreshing resources list");try{const Oe=Y.current.getSession("inspector-server");if(!Oe){ue("warn","No active session found for resources refresh");return}const Ge=await Oe.connector.listAllResources();B(Ge.resources||[]),ue("info","Resources list refreshed successfully")}catch(Se){ue("warn","Failed to refresh resources:",Se)}},[ue]),xn=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current){ue("debug","Cannot refresh prompts - client not ready");return}ue("debug","Refreshing prompts list");try{const Oe=Y.current.getSession("inspector-server");if(!Oe){ue("warn","No active session found for prompts refresh");return}const Ge=await Oe.connector.listPrompts();ae(Ge.prompts||[]),ue("info","Prompts list refreshed successfully")}catch(Se){ue("warn","Failed to refresh prompts:",Se)}},[ue]),pt=y.useCallback(async()=>{ue("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([at(),yt(),xn()])},[at,yt,xn,ue]),Gn=y.useCallback(async()=>me.current!=="ready"?(ue("warn","Cannot ensure icon loaded - not connected"),null):V?.icon?V.icon:oe.current?(ue("debug","Waiting for icon to finish loading..."),await oe.current):(ue("debug","No icon available and no loading in progress"),null),[V,ue]),hn=y.useCallback(async(Se,Oe)=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot get prompt.`);ue("info",`Getting prompt: ${Se}`,Oe);try{const lt=Y.current.getSession("inspector-server");if(!lt)throw new Error("No active session found");const Xe=await lt.connector.getPrompt(Se,Oe||{});return ue("info",`Prompt "${Se}" retrieved successfully:`,Xe),Xe}catch(Ge){throw ue("error",`Prompt "${Se}" retrieval failed:`,Ge),Ge}},[A]),Ve=y.useRef(fe),Ue=y.useRef(Ye);return y.useEffect(()=>{Ve.current=fe,Ue.current=Ye}),y.useEffect(()=>{const Se=je(Oe=>{Oe.origin===window.location.origin&&Oe.data?.type==="mcp_auth_callback"&&(ue("info","Received auth callback message.",Oe.data),pe.current&&clearTimeout(pe.current),pe.current=null,Oe.data.success?(ue("info","Authentication successful via popup. Reconnecting client..."),X.current&&ue("debug","Connection attempt already in progress, resetting flag to allow reconnection."),X.current=!1,setTimeout(()=>{J.current&&(ue("debug","Initiating reconnection after successful auth callback."),Ve.current())},100)):Ue.current(`Authentication failed in callback: ${Oe.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Se),ue("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Se),ue("debug","Auth callback message listener removed."),pe.current&&clearTimeout(pe.current)}},[ue]),y.useEffect(()=>(J.current=!0,!n||!t?(ue("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),I("discovering"),()=>{J.current=!1}):(ue("debug","useMcp mounted, initiating connection."),le.current=0,(!se.current||se.current.serverUrl!==t)&&(se.current=new jb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:E,onPopupWindow:x}),ue("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),fe(),()=>{J.current=!1,ue("debug","useMcp unmounting, disconnecting."),Pe(!0)})),[t,n,s,i,a,r,c.name,c.version,E]),y.useEffect(()=>{let Se=null;if(A==="failed"&&m&&le.current>0){const Oe=typeof m=="number"?m:Uoe;ue("info",`Connection failed, auto-retrying in ${Oe}ms...`),Se=setTimeout(()=>{J.current&&me.current==="failed"&&He()},Oe)}return()=>{Se&&clearTimeout(Se)}},[A,m,He,ue]),{state:A,tools:O,resources:j,resourceTemplates:G,prompts:te,serverInfo:V,capabilities:H,error:re,log:F,authUrl:L,authTokens:W,client:Y.current,callTool:De,readResource:We,listResources:Ae,listPrompts:ft,getPrompt:hn,refreshTools:at,refreshResources:yt,refreshPrompts:xn,refreshAll:pt,retry:He,disconnect:Pe,authenticate:Ee,clearStorage:Ne,ensureIconLoaded:Gn}}je(CN,"useMcp");function Foe({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:a="",onSuccess:r,onError:i,trigger:s}){const[c,u]=y.useState(!1),[f,m]=y.useState(null),[h,g]=y.useState(!1),[v,E]=y.useState(!1),{url:x,name:w,headers:S}=e,_=je(()=>{try{const j=iy(x,w,S);window.location.href=j,r?.("Cursor")}catch(j){console.error("Failed to generate Cursor deep link:",j),i?.(j)}},"handleCursorClick"),k=je(()=>{try{const j=oy(x,w,S);window.location.href=j,r?.("VS Code")}catch(j){console.error("Failed to generate VS Code deep link:",j),i?.(j)}},"handleVSCodeClick"),N=je(()=>{try{sy(x,w,S),r?.("Claude Desktop")}catch(j){console.error("Failed to download .mcpb file:",j),i?.(j)}},"handleClaudeDesktopClick"),C=je(()=>{m("claude-code"),u(!0)},"handleClaudeCodeClick"),A=je(()=>{m("gemini-cli"),u(!0)},"handleGeminiCLIClick"),I=je(()=>{m("codex-cli"),u(!0)},"handleCodexCLIClick"),O=je(async j=>{try{await navigator.clipboard.writeText(j),g(!0),setTimeout(()=>g(!1),2e3)}catch(B){console.error("Failed to copy:",B),i?.(B)}},"handleCopy"),M=je(()=>{if(f==="claude-code"){const{command:j,envVars:B}=ly(x,w,S),G=kp(B);return Q.createElement("div",{className:"space-y-4"},Q.createElement("div",null,Q.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Claude Code"),Q.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Execute the following command in your shell to add this server to Claude Code.")),Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),Q.createElement("ol",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400"},Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"1."),Q.createElement("span",null,"Ensure the Claude Code executable is available in your path")),Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"2."),Q.createElement("span",null,"Execute the following snippet in your shell:")))),Q.createElement("div",{className:"relative"},Q.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>O(j)},h?"✓ Copied":"Copy"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,j))),G&&Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Environment Variables"),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2"},"After installation, set these environment variables in your shell:"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,G))),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"The MCP configuration supports environment variable expansion using"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"${VAR}")," ","syntax."))}if(f==="gemini-cli"){const{command:j,envVars:B}=cy(x,w,S),G=kp(B);return Q.createElement("div",{className:"space-y-4"},Q.createElement("div",null,Q.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Gemini CLI"),Q.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Execute the following command in your shell to add this server to Gemini CLI.")),Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),Q.createElement("ol",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400"},Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"1."),Q.createElement("span",null,"Ensure the Gemini CLI executable is available in your path")),G&&Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"2."),Q.createElement("span",null,"Set these environment variables in your shell before running the command:")),Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},G?"3.":"2."),Q.createElement("span",null,"Execute the following snippet in your shell:")))),G&&Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Environment Variables"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,G))),Q.createElement("div",{className:"relative"},Q.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>O(j)},h?"✓ Copied":"Copy"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,j))),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Restart Gemini CLI to load the new configuration."))}if(f==="codex-cli"){const{config:j,envVars:B}=uy(x,w,S);return Q.createElement("div",{className:"space-y-4"},Q.createElement("div",null,Q.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Codex CLI"),Q.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Add this configuration to your"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"~/.codex/config.toml")," ","file.")),Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Add this configuration to your"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"~/.codex/config.toml"),":")),Q.createElement("div",{className:"relative"},Q.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>O(j)},h?"✓ Copied":"Copy"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,j))),B.length>0&&Q.createElement("div",null,Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"(optional) If you would rather use variables from your system's environment, replace the"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"http_headers")," ","key with the"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"env_http_headers")," ","key as shown in the commented section above.")),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Restart Codex CLI to load the new configuration."))}return null},"renderModalContent");return Q.createElement(Q.Fragment,null,Q.createElement("div",{className:"relative inline-block"},s?Q.createElement("div",{onClick:j=>{j.stopPropagation(),E(!v)},className:"cursor-pointer"},typeof s=="function"?s({isOpen:v,onClick:je(()=>E(!v),"onClick")}):Q.isValidElement(s)?Q.cloneElement(s,{onClick:je(j=>{j.preventDefault(),j.stopPropagation(),E(!v)},"onClick")}):s):Q.createElement("button",{onClick:()=>E(!v),className:`inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${a}`},Q.createElement("span",null,"Add to Client"),Q.createElement("svg",{className:`w-4 h-4 transition-transform ${v?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Q.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),v&&Q.createElement(Q.Fragment,null,Q.createElement("div",{className:"fixed inset-0 z-40",onClick:()=>E(!1)}),Q.createElement("div",{className:"absolute right-0 mt-2 w-48 rounded-md shadow-lg bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 z-50"},Q.createElement("div",{className:"py-1"},t.map(j=>Q.createElement("button",{key:j.id,onClick:async()=>{E(!1),await j.onClick()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},j.icon,Q.createElement("span",null,j.label))),t.length>0&&Q.createElement("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),n.cursor&&Q.createElement("button",{onClick:()=>{E(!1),_()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),Q.createElement("span",null,"Cursor")),n.claudeCode&&Q.createElement("button",{onClick:()=>{E(!1),C()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),Q.createElement("span",null,"Claude Code")),n.claudeDesktop&&Q.createElement("button",{onClick:()=>{E(!1),N()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),Q.createElement("span",null,"Claude Desktop")),n.vsCode&&Q.createElement("button",{onClick:()=>{E(!1),k()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor"},Q.createElement("path",{d:"M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z"})),Q.createElement("span",null,"VS Code")),n.geminiCli&&Q.createElement("button",{onClick:()=>{E(!1),A()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),Q.createElement("span",null,"Gemini CLI")),n.codexCli&&Q.createElement("button",{onClick:()=>{E(!1),I()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://inspector-cdn.mcp-use.com/providers/openai.png",alt:"Codex",className:"h-4 w-4"}),Q.createElement("span",null,"Codex CLI")))))),c&&Q.createElement(Q.Fragment,null,Q.createElement("div",{className:"fixed inset-0 bg-black/50 z-50",onClick:()=>u(!1)}),Q.createElement("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4"},Q.createElement("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] overflow-y-auto border border-gray-200 dark:border-gray-700 p-6",onClick:j=>j.stopPropagation()},M(),Q.createElement("div",{className:"mt-6 flex justify-end"},Q.createElement("button",{onClick:()=>u(!1),className:"px-4 py-2 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"},"Close"))))))}je(Foe,"AddToClientDropdown");var Ju,Boe=(Ju=class extends Q.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?Q.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"},Q.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),Q.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},je(Ju,"ErrorBoundary"),Ju),pp="openai:set_globals";function di(e){return y.useSyncExternalStore(t=>{const n=je(a=>{a.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(pp,n),()=>{typeof window<"u"&&window.removeEventListener(pp,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}je(di,"useOpenAiGlobal");function Td(e){const[t,n]=y.useState(()=>typeof window<"u"&&!!window.openai);y.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const j=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(j))},100),B=je(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(j))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(pp,B);const G=setTimeout(()=>{clearInterval(j),typeof window<"u"&&window.removeEventListener(pp,B)},5e3);return()=>{clearInterval(j),clearTimeout(G),typeof window<"u"&&window.removeEventListener(pp,B)}},[]);const a=y.useMemo(()=>t?"openai":"mcp-ui",[t]),r=typeof window<"u"?window.location.search:"",i=y.useMemo(()=>{const j=new URLSearchParams(r);return j.has("mcpUseParams")?JSON.parse(j.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[r]),s=a==="openai"?di("toolInput"):i.toolInput,c=a==="openai"?di("toolOutput"):i.toolOutput,u=di("toolResponseMetadata"),f=y.useMemo(()=>{if(u&&typeof u=="object"){const j=u["mcp-use/props"];if(j)return j}return e||{}},[u,e]),m=di("widgetState"),h=di("theme"),g=di("displayMode"),v=di("safeArea"),E=di("maxHeight"),x=di("userAgent"),w=di("locale"),S=y.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,k]=y.useState(null);y.useEffect(()=>{m!==void 0&&k(m)},[m]);const N=y.useCallback(async(j,B)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(j,B)},[]),C=y.useCallback(async j=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:j})},[]),A=y.useCallback(j=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:j})},[]),I=y.useCallback(async j=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:j})},[]),O=y.useCallback(async j=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const G=typeof j=="function"?j(m!==void 0?m:_):j;return k(G),window.openai.setWidgetState(G)},[m,_]),M=y.useMemo(()=>a==="openai"&&u===null,[a,u]);return{props:f,toolInput:s||{},output:c??null,metadata:u??null,state:_,setState:O,theme:h||"light",displayMode:g||"inline",safeArea:v||{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:N,sendFollowUpMessage:C,openExternal:A,requestDisplayMode:I,isAvailable:t,isPending:M}}je(Td,"useWidget");function Hoe(e){const{props:t}=Td(e);return t}je(Hoe,"useWidgetProps");function Voe(){const{theme:e}=Td();return e}je(Voe,"useWidgetTheme");function Goe(e){const{state:t,setState:n}=Td();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}je(Goe,"useWidgetState");var fz=je(({children:e})=>{const{theme:t,isAvailable:n}=Td();console.log("theme",t);const[a,r]=y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");y.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),c=je(u=>{r(u.matches?"dark":"light")},"handleChange");return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]);const i=n?t:a;return y.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),Q.createElement(Q.Fragment,null,e)},"ThemeProvider");function f9({children:e,className:t="",position:n="top-right",attachTo:a,showLabels:r=!0,debugger:i=!1,viewControls:s=!1}){const{props:c,output:u,metadata:f,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:E,userAgent:x,locale:w,isAvailable:S,callTool:_,sendFollowUpMessage:k,openExternal:N,requestDisplayMode:C,setState:A}=Td(),[I,O]=y.useState(!1),[M,j]=y.useState(!1),B=y.useRef(null),G=y.useRef(null),[ee,te]=y.useState([]),[ae,V]=y.useState(""),[q,H]=y.useState("get-my-city"),[ie,re]=y.useState("{}"),[P,F]=y.useState("Test follow-up message"),[U,L]=y.useState("https://docs.mcp-use.com"),$=g==="fullscreen"&&S,W=g==="pip"&&S,K=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const Ee=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const Ne=Object.keys(window.openai);te(Ne)}catch{te([])}else te([])},100);return()=>{clearTimeout(Ee)}},[]);const Y=h==="dark",se=je(()=>{const Ee=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",I?"opacity-100":"opacity-0",I?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...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"),oe=je(()=>{const Ne=v?.insets?.top?Math.max(16,v.insets.top+8):16,Ae=v?.insets?.right?Math.max(16,v.insets.right+8):16,We=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,ft=v?.insets?.left?Math.max(16,v.insets.left+8):16,at={};switch(n){case"top-left":at.top=`${Ne}px`,at.left=`${ft}px`;break;case"top-center":at.top=`${Ne}px`;break;case"top-right":at.top=`${Ne}px`,at.right=`${Ae}px`;break;case"center-left":at.left=`${ft}px`;break;case"center-right":at.right=`${Ae}px`;break;case"bottom-left":at.bottom=`${We}px`,at.left=`${ft}px`;break;case"bottom-center":at.bottom=`${We}px`;break;case"bottom-right":at.bottom=`${We}px`,at.right=`${Ae}px`;break;default:at.top=`${Ne}px`,at.right=`${Ae}px`;break}return at},"getPositionOffsetStyles");y.useEffect(()=>{if(!a)return;const Ee=je(()=>O(!0),"handleMouseEnter"),Ne=je(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",Ee),a.addEventListener("mouseleave",Ne),()=>{a.removeEventListener("mouseenter",Ee),a.removeEventListener("mouseleave",Ne)}},[a]),y.useEffect(()=>{if(!M)return;const Ee=je(Ne=>{G.current&&!G.current.contains(Ne.target)&&j(!1)},"handleClickOutside");return document.addEventListener("mousedown",Ee),()=>{document.removeEventListener("mousedown",Ee)}},[M]),y.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const X=je(()=>{j(!M)},"handleToggleOverlay"),J=je(async()=>{try{V("Calling tool...");const Ee=ie.trim()?JSON.parse(ie):{},Ne=await _(q,Ee);V(`Success: ${JSON.stringify(Ne,null,2)}`)}catch(Ee){V(`Error: ${Ee.message}`)}},"handleCallTool"),le=je(async()=>{try{V("Sending follow-up message..."),await k(P),V("Follow-up message sent successfully")}catch(Ee){V(`Error: ${Ee.message}`)}},"handleSendFollowUpMessage"),pe=je(()=>{try{N(U),V(`Opened external link: ${U}`)}catch(Ee){V(`Error: ${Ee.message}`)}},"handleOpenExternal"),me=je(async Ee=>{try{V(`Requesting display mode: ${Ee}...`);const Ne=await C(Ee);V(`Display mode granted: ${Ne.mode}`)}catch(Ne){V(`Error: ${Ne.message}`)}},"handleRequestDisplayMode"),_e=je(async()=>{try{const Ee=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};V("Setting state..."),await A(Ee),V(`State updated: ${JSON.stringify(Ee,null,2)}`)}catch(Ee){V(`Error: ${Ee.message}`)}},"handleSetState"),ze=je(async()=>{try{await C("fullscreen")}catch(Ee){console.error("Failed to go fullscreen:",Ee)}},"handleFullscreen"),ue=je(async()=>{try{await C("pip")}catch(Ee){console.error("Failed to go pip:",Ee)}},"handlePip"),Pe=je(()=>{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"),Ye=je(({onClick:Ee,label:Ne,children:Ae})=>{const[We,ft]=y.useState(!1),at=Pe();return Q.createElement("button",{className:`p-2 ${Y?"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 ${Y?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>ft(!0),onMouseLeave:()=>ft(!1),onClick:Ee,"aria-label":Ne},Q.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"},Ae),r&&Q.createElement("span",{className:`${at.join(" ")} ${We?"opacity-100":"opacity-0"}`},Ne))},"IconButton"),fe=je(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"),De=je(Ee=>Ee?`${Ee.device?.type||"unknown"}`:"N/A","formatUserAgent"),He=je(Ee=>{if(!Ee?.insets)return"N/A";const{top:Ne,bottom:Ae,left:We,right:ft}=Ee.insets;return`T:${Ne} B:${Ae} L:${We} R:${ft}`},"formatSafeArea");return Q.createElement(Q.Fragment,null,Q.createElement("div",{ref:B,className:`${t} relative h-fit`,onMouseEnter:()=>!a&&O(!0),onMouseLeave:()=>!a&&O(!1)},Q.createElement("div",{className:se().join(" "),style:oe()},!K&&Q.createElement(Q.Fragment,null,!$&&!W&&Q.createElement(Q.Fragment,null,(s===!0||s==="fullscreen")&&Q.createElement(Ye,{onClick:ze,label:"Fullscreen"},Q.createElement("path",{d:"M15 3h6v6"}),Q.createElement("path",{d:"m21 3-7 7"}),Q.createElement("path",{d:"m3 21 7-7"}),Q.createElement("path",{d:"M9 21H3v-6"})),(s===!0||s==="pip")&&Q.createElement(Ye,{onClick:ue,label:"Picture in Picture"},Q.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),Q.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&Q.createElement(Ye,{onClick:X,label:"Debug Info"},Q.createElement("path",{d:"M12 20v-9"}),Q.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),Q.createElement("path",{d:"M14.12 3.88 16 2"}),Q.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),Q.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),Q.createElement("path",{d:"M22 13h-4"}),Q.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),Q.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),Q.createElement("path",{d:"M6 13H2"}),Q.createElement("path",{d:"m8 2 1.88 1.88"}),Q.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),M&&i&&Q.createElement("div",{ref:G,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:Ee=>{Ee.target===G.current&&j(!1)}},Q.createElement("button",{onClick:()=>j(!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"},"×"),Q.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},Q.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),Q.createElement("table",{className:"w-full border-collapse border-spacing-0"},Q.createElement("tbody",null,Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),Q.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(c))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),Q.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(u))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),Q.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(f))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),Q.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(m))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),Q.createElement("td",{className:"p-2"},h)),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),Q.createElement("td",{className:"p-2"},g)),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),Q.createElement("td",{className:"p-2"},w)),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),Q.createElement("td",{className:"p-2"},E,"px")),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),Q.createElement("td",{className:"p-2"},De(x))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),Q.createElement("td",{className:"p-2"},He(v))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),Q.createElement("td",{className:"p-2"},S?"Yes":"No")),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),Q.createElement("td",{className:"p-2"},ee.length>0?ee.join(", "):"N/A")))),Q.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),Q.createElement("div",{className:"flex flex-col gap-3"},Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("input",{type:"text",value:q,onChange:Ee=>H(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]"}),Q.createElement("input",{type:"text",value:ie,onChange:Ee=>re(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"}),Q.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")),Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("input",{type:"text",value:P,onChange:Ee=>F(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"}),Q.createElement("button",{onClick:le,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")),Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("input",{type:"text",value:U,onChange:Ee=>L(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"}),Q.createElement("button",{onClick:pe,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),Q.createElement("button",{onClick:()=>me("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"),Q.createElement("button",{onClick:()=>me("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"),Q.createElement("button",{onClick:()=>me("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")),Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("button",{onClick:_e,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Set State (Add Timestamp)")),ae&&Q.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"},Q.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ae,Q.createElement("button",{onClick:()=>V(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}je(f9,"WidgetControls");function p9(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}je(p9,"getBasename");var Woe=150,Koe=5;function Zoe({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=p9(),i=y.useRef(null),s=y.useRef(0),c=y.useRef(null),u=y.useRef(!1),[f,m]=y.useState(null),[h,g]=y.useState(null),[v,E]=y.useState(!0);y.useEffect(()=>{let _=!0;return(async()=>{try{const k=await Mr(()=>import("./index-C88Q8iJs.js"),[]);_&&(m(()=>k.BrowserRouter),E(!1))}catch{_&&(g(new Error(`❌ react-router not installed!
|
|
46
|
+
`&&a++}}return[t,n]}class koe extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(i){r=c9({onEvent:s=>{i.enqueue(s)},onError(s){t==="terminate"?i.error(s):typeof t=="function"&&t(s)},onRetry:n,onComment:a})},transform(i){r.feed(i)}})}}const Toe={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Tl extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class Noe{constructor(t,n){var a;this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=YV(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(a=n?.reconnectionOptions)!==null&&a!==void 0?a:Toe}async _authThenStart(){var t;if(!this._authProvider)throw new qa("No auth provider");let n;try{n=await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new qa;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=hv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}async _startOrAuthSse(t){var n,a,r,i;const{resumptionToken:s}=t;try{const c=await this._commonHeaders();c.set("Accept","text/event-stream"),s&&c.set("last-event-id",s);const u=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,{method:"GET",headers:c,signal:(a=this._abortController)===null||a===void 0?void 0:a.signal});if(!u.ok){if(await((r=u.body)===null||r===void 0?void 0:r.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new Tl(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(c){throw(i=this.onerror)===null||i===void 0||i.call(this,c),c}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,a=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(a,t),r)}_scheduleReconnection(t,n=0){var a;const r=this._reconnectionOptions.maxRetries;if(n>=r){(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const i=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,n+1)})},i)}_handleSseStream(t,n,a){if(!t)return;const{onresumptiontoken:r,replayMessageId:i}=n;let s,c=!1,u=!1;(async()=>{var m,h,g,v;try{const E=t.pipeThrough(new TextDecoderStream).pipeThrough(new koe({onRetry:S=>{this._serverRetryMs=S}})).getReader();for(;;){const{value:S,done:_}=await E.read();if(_)break;if(S.id&&(s=S.id,c=!0,r?.(S.id)),!!S.data&&(!S.event||S.event==="message"))try{const k=Ab.parse(JSON.parse(S.data));Qf(k)&&(u=!0,i!==void 0&&(k.id=i)),(m=this.onmessage)===null||m===void 0||m.call(this,k)}catch(k){(h=this.onerror)===null||h===void 0||h.call(this,k)}}(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(E){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${E}`)),(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(S){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${S instanceof Error?S.message:String(S)}`))}}})()}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 qa("No auth provider");if(await Io(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa("Failed to authorize")}async close(){var t,n;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)===null||t===void 0||t.abort(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(t,n){var a,r,i,s,c,u,f;try{const{resumptionToken:m,onresumptiontoken:h}=n||{};if(m){this._startOrAuthSse({resumptionToken:m,replayMessageId:yE(t)?t.id:void 0}).catch(k=>{var N;return(N=this.onerror)===null||N===void 0?void 0:N.call(this,k)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const v={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(t),signal:(a=this._abortController)===null||a===void 0?void 0:a.signal},E=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,v),x=E.headers.get("mcp-session-id");if(x&&(this._sessionId=x),!E.ok){const k=await E.text().catch(()=>null);if(E.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Tl(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:N,scope:C}=Dp(E);if(this._resourceMetadataUrl=N,this._scope=C,await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa;return this._hasCompletedAuthFlow=!0,this.send(t)}if(E.status===403&&this._authProvider){const{resourceMetadataUrl:N,scope:C,error:A}=Dp(E);if(A==="insufficient_scope"){const I=E.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===I)throw new Tl(403,"Server returned 403 after trying upscoping");if(C&&(this._scope=C),N&&(this._resourceMetadataUrl=N),this._lastUpscopingHeader=I??void 0,await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new qa;return this.send(t)}}throw new Tl(E.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,E.status===202){await((i=E.body)===null||i===void 0?void 0:i.cancel()),vre(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var N;return(N=this.onerror)===null||N===void 0?void 0:N.call(this,k)});return}const S=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,_=E.headers.get("content-type");if(S)if(_?.includes("text/event-stream"))this._handleSseStream(E.body,{onresumptiontoken:h},!1);else if(_?.includes("application/json")){const k=await E.json(),N=Array.isArray(k)?k.map(C=>Ab.parse(C)):[Ab.parse(k)];for(const C of N)(s=this.onmessage)===null||s===void 0||s.call(this,C)}else throw await((c=E.body)===null||c===void 0?void 0:c.cancel()),new Tl(-1,`Unexpected content type: ${_}`);else await((u=E.body)===null||u===void 0?void 0:u.cancel())}catch(m){throw(f=this.onerror)===null||f===void 0||f.call(this,m),m}}get sessionId(){return this._sessionId}async terminateSession(){var t,n,a,r;if(this._sessionId)try{const i=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},c=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,s);if(await((a=c.body)===null||a===void 0?void 0:a.cancel()),!c.ok&&c.status!==405)throw new Tl(c.status,`Failed to terminate session: ${c.statusText}`);this._sessionId=void 0}catch(i){throw(r=this.onerror)===null||r===void 0||r.call(this,i),i}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class oz extends Event{constructor(t,n){var a,r;super(t),this.code=(a=n?.code)!=null?a:void 0,this.message=(r=n?.message)!=null?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,a){return a(sz(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(sz(this),n)}}function Coe(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function OE(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(OE).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${OE(e.cause)}`:e.message:`${e}`}function sz(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var u9=e=>{throw TypeError(e)},kN=(e,t,n)=>t.has(e)||u9("Cannot "+n),Gt=(e,t,n)=>(kN(e,t,"read from private field"),n?n.call(e):t.get(e)),dr=(e,t,n)=>t.has(e)?u9("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Pn=(e,t,n,a)=>(kN(e,t,"write to private field"),t.set(e,n),n),No=(e,t,n)=>(kN(e,t,"access private method"),n),ya,Cl,Qc,Ob,wv,dp,uu,fp,Ts,eu,xu,tu,ep,fi,DE,jE,LE,lz,$E,ME,tp,PE,zE;class Db extends EventTarget{constructor(t,n){var a,r;super(),dr(this,fi),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,dr(this,ya),dr(this,Cl),dr(this,Qc),dr(this,Ob),dr(this,wv),dr(this,dp),dr(this,uu),dr(this,fp,null),dr(this,Ts),dr(this,eu),dr(this,xu,null),dr(this,tu,null),dr(this,ep,null),dr(this,jE,async i=>{var s;Gt(this,eu).reset();const{body:c,redirected:u,status:f,headers:m}=i;if(f===204){No(this,fi,tp).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?Pn(this,Qc,new URL(i.url)):Pn(this,Qc,void 0),f!==200){No(this,fi,tp).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){No(this,fi,tp).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(Gt(this,ya)===this.CLOSED)return;Pn(this,ya,this.OPEN);const h=new Event("open");if((s=Gt(this,ep))==null||s.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){No(this,fi,tp).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const g=new TextDecoder,v=c.getReader();let E=!0;do{const{done:x,value:w}=await v.read();w&&Gt(this,eu).feed(g.decode(w,{stream:!x})),x&&(E=!1,Gt(this,eu).reset(),No(this,fi,PE).call(this))}while(E)}),dr(this,LE,i=>{Pn(this,Ts,void 0),!(i.name==="AbortError"||i.type==="aborted")&&No(this,fi,PE).call(this,OE(i))}),dr(this,$E,i=>{typeof i.id=="string"&&Pn(this,fp,i.id);const s=new MessageEvent(i.event||"message",{data:i.data,origin:Gt(this,Qc)?Gt(this,Qc).origin:Gt(this,Cl).origin,lastEventId:i.id||""});Gt(this,tu)&&(!i.event||i.event==="message")&&Gt(this,tu).call(this,s),this.dispatchEvent(s)}),dr(this,ME,i=>{Pn(this,dp,i)}),dr(this,zE,()=>{Pn(this,uu,void 0),Gt(this,ya)===this.CONNECTING&&No(this,fi,DE).call(this)});try{if(t instanceof URL)Pn(this,Cl,t);else if(typeof t=="string")Pn(this,Cl,new URL(t,Roe()));else throw new Error("Invalid URL")}catch{throw Coe("An invalid or illegal string was specified")}Pn(this,eu,c9({onEvent:Gt(this,$E),onRetry:Gt(this,ME)})),Pn(this,ya,this.CONNECTING),Pn(this,dp,3e3),Pn(this,wv,(a=n?.fetch)!=null?a:globalThis.fetch),Pn(this,Ob,(r=n?.withCredentials)!=null?r:!1),No(this,fi,DE).call(this)}get readyState(){return Gt(this,ya)}get url(){return Gt(this,Cl).href}get withCredentials(){return Gt(this,Ob)}get onerror(){return Gt(this,xu)}set onerror(t){Pn(this,xu,t)}get onmessage(){return Gt(this,tu)}set onmessage(t){Pn(this,tu,t)}get onopen(){return Gt(this,ep)}set onopen(t){Pn(this,ep,t)}addEventListener(t,n,a){const r=n;super.addEventListener(t,r,a)}removeEventListener(t,n,a){const r=n;super.removeEventListener(t,r,a)}close(){Gt(this,uu)&&clearTimeout(Gt(this,uu)),Gt(this,ya)!==this.CLOSED&&(Gt(this,Ts)&&Gt(this,Ts).abort(),Pn(this,ya,this.CLOSED),Pn(this,Ts,void 0))}}ya=new WeakMap,Cl=new WeakMap,Qc=new WeakMap,Ob=new WeakMap,wv=new WeakMap,dp=new WeakMap,uu=new WeakMap,fp=new WeakMap,Ts=new WeakMap,eu=new WeakMap,xu=new WeakMap,tu=new WeakMap,ep=new WeakMap,fi=new WeakSet,DE=function(){Pn(this,ya,this.CONNECTING),Pn(this,Ts,new AbortController),Gt(this,wv)(Gt(this,Cl),No(this,fi,lz).call(this)).then(Gt(this,jE)).catch(Gt(this,LE))},jE=new WeakMap,LE=new WeakMap,lz=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Gt(this,fp)?{"Last-Event-ID":Gt(this,fp)}:void 0},cache:"no-store",signal:(e=Gt(this,Ts))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},$E=new WeakMap,ME=new WeakMap,tp=function(e,t){var n;Gt(this,ya)!==this.CLOSED&&Pn(this,ya,this.CLOSED);const a=new oz("error",{code:t,message:e});(n=Gt(this,xu))==null||n.call(this,a),this.dispatchEvent(a)},PE=function(e,t){var n;if(Gt(this,ya)===this.CLOSED)return;Pn(this,ya,this.CONNECTING);const a=new oz("error",{code:t,message:e});(n=Gt(this,xu))==null||n.call(this,a),this.dispatchEvent(a),Pn(this,uu,setTimeout(Gt(this,zE),Gt(this,dp)))},zE=new WeakMap,Db.CONNECTING=0,Db.OPEN=1,Db.CLOSED=2;function Roe(){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 Aoe extends Error{constructor(t,n,a){super(`SSE error: ${n}`),this.code=t,this.event=a}}class Ioe{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=YV(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new qa("No auth provider");let n;try{n=await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new qa;return await this._startOrAuth()}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=hv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}_startOrAuth(){var t,n,a;const r=(a=(n=(t=this===null||this===void 0?void 0:this._eventSourceInit)===null||t===void 0?void 0:t.fetch)!==null&&n!==void 0?n:this._fetch)!==null&&a!==void 0?a:fetch;return new Promise((i,s)=>{this._eventSource=new Db(this._url.href,{...this._eventSourceInit,fetch:async(c,u)=>{const f=await this._commonHeaders();f.set("Accept","text/event-stream");const m=await r(c,{...u,headers:f});if(m.status===401&&m.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=Dp(m);this._resourceMetadataUrl=h,this._scope=g}return m}}),this._abortController=new AbortController,this._eventSource.onerror=c=>{var u;if(c.code===401&&this._authProvider){this._authThenStart().then(i,s);return}const f=new Aoe(c.code,c.message,c);s(f),(u=this.onerror)===null||u===void 0||u.call(this,f)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",c=>{var u;const f=c;try{if(this._endpoint=new URL(f.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(m){s(m),(u=this.onerror)===null||u===void 0||u.call(this,m),this.close();return}i()}),this._eventSource.onmessage=c=>{var u,f;const m=c;let h;try{h=Ab.parse(JSON.parse(m.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(f=this.onmessage)===null||f===void 0||f.call(this,h)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new qa("No auth provider");if(await Io(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa("Failed to authorize")}async close(){var t,n,a;(t=this._abortController)===null||t===void 0||t.abort(),(n=this._eventSource)===null||n===void 0||n.close(),(a=this.onclose)===null||a===void 0||a.call(this)}async send(t){var n,a,r,i;if(!this._endpoint)throw new Error("Not connected");try{const s=await this._commonHeaders();s.set("content-type","application/json");const c={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},u=await((a=this._fetch)!==null&&a!==void 0?a:fetch)(this._endpoint,c);if(!u.ok){const f=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:m,scope:h}=Dp(u);if(this._resourceMetadataUrl=m,this._scope=h,await Io(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${f}`)}await((r=u.body)===null||r===void 0?void 0:r.cancel())}catch(s){throw(i=this.onerror)===null||i===void 0||i.call(this,s),s}}setProtocolVersion(t){this._protocolVersion=t}}var Gu,Ooe=(Gu=class{connector;autoConnect;constructor(t,n=!0){this.connector=t,this.autoConnect=n}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(t,n){t==="notification"&&this.connector.onNotification(n)}async setRoots(t){return this.connector.setRoots(t)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(t){return this.connector.listTools(t)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(t,n={},a){return this.connector.callTool(t,n,a)}async listResources(t,n){return this.connector.listResources(t,n)}async listAllResources(t){return this.connector.listAllResources(t)}async listResourceTemplates(t){return this.connector.listResourceTemplates(t)}async readResource(t,n){return this.connector.readResource(t,n)}async subscribeToResource(t,n){return this.connector.subscribeToResource(t,n)}async unsubscribeFromResource(t,n){return this.connector.unsubscribeFromResource(t,n)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(t,n){return this.connector.getPrompt(t,n)}async request(t,n=null,a){return this.connector.request(t,n,a)}},je(Gu,"MCPSession"),Gu),Wu,Doe=(Wu=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,Ui.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Ui.getInstance().trackClientRemoveServer(t))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(t){return this.config.mcpServers?.[t]}getConfig(){return this.config??{}}async createSession(t,n=!0){const a=this.config.mcpServers??{};if(Object.keys(a).length===0&&$e.warn("No MCP servers defined in config"),!a[t])throw new Error(`Server '${t}' not found in config`);const r=this.createConnectorFromConfig(a[t]),i=new Ooe(r);return n&&await i.initialize(),this.sessions[t]=i,this.activeSessions.includes(t)||this.activeSessions.push(t),i}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&$e.warn("No MCP servers defined in config");for(const a of Object.keys(n))await this.createSession(a,t);return this.sessions}getSession(t){const n=this.sessions[t];return n||null}requireSession(t){const n=this.sessions[t];if(!n)throw new Error(`Session '${t}' not found. Available sessions: ${this.activeSessions.join(", ")||"none"}`);return n}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){$e.warn(`No session exists for server ${t}, nothing to close`);return}try{$e.debug(`Closing session for server ${t}`),await n.disconnect()}catch(a){$e.error(`Error closing session for server '${t}': ${a}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(a=>a!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const a of t)try{$e.debug(`Closing session for server ${a}`),await this.closeSession(a)}catch(r){const i=`Failed to close session for server '${a}': ${r}`;$e.error(i),n.push(i)}n.length?$e.error(`Encountered ${n.length} errors while closing sessions`):$e.debug("All sessions closed successfully")}},je(Wu,"BaseMCPClient"),Wu),Ku,joe=(Ku=class{client=null;connectionManager=null;toolsCache=null;capabilitiesCache=null;serverInfoCache=null;connected=!1;opts;notificationHandlers=[];rootsCache=[];constructor(t={}){this.opts=t,t.roots&&(this.rootsCache=[...t.roots])}trackConnectorInit(t){const n=this.constructor.name;CF.getInstance().trackConnectorInit({connectorType:n,...t}).catch(a=>$e.debug(`Failed to track connector init: ${a}`))}onNotification(t){this.notificationHandlers.push(t),this.client&&this.setupNotificationHandler()}setupNotificationHandler(){this.client&&(this.client.fallbackNotificationHandler=async t=>{switch(t.method){case"notifications/tools/list_changed":await this.refreshToolsCache();break;case"notifications/resources/list_changed":await this.onResourcesListChanged();break;case"notifications/prompts/list_changed":await this.onPromptsListChanged();break}for(const n of this.notificationHandlers)try{await n(t)}catch(a){$e.error("Error in notification handler:",a)}})}async refreshToolsCache(){if(this.client)try{$e.debug("[Auto] Refreshing tools cache due to list_changed notification");const t=await this.client.listTools();this.toolsCache=t.tools??[],$e.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(t){$e.warn("[Auto] Failed to refresh tools cache:",t)}}async onResourcesListChanged(){$e.debug("[Auto] Resources list changed - clients should re-fetch if needed")}async onPromptsListChanged(){$e.debug("[Auto] Prompts list changed - clients should re-fetch if needed")}async setRoots(t){this.rootsCache=[...t],this.client&&($e.debug(`Sending roots/list_changed notification with ${t.length} root(s)`),await this.client.sendRootsListChanged())}getRoots(){return[...this.rootsCache]}setupRootsHandler(){this.client&&this.client.setRequestHandler(zV,async(t,n)=>($e.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`),{roots:this.rootsCache}))}setupSamplingHandler(){if(!this.client){$e.debug("setupSamplingHandler: No client available");return}if(!this.opts.samplingCallback){$e.debug("setupSamplingHandler: No sampling callback provided");return}$e.debug("setupSamplingHandler: Setting up sampling request handler"),this.client.setRequestHandler(gN,async(t,n)=>($e.debug("Server requested sampling, forwarding to callback"),await this.opts.samplingCallback(t.params))),$e.debug("setupSamplingHandler: Sampling handler registered successfully")}setupElicitationHandler(){if(!this.client){$e.debug("setupElicitationHandler: No client available");return}if(!this.opts.elicitationCallback){$e.debug("setupElicitationHandler: No elicitation callback provided");return}$e.debug("setupElicitationHandler: Setting up elicitation request handler"),this.client.setRequestHandler(vN,async(t,n)=>($e.debug("Server requested elicitation, forwarding to callback"),await this.opts.elicitationCallback(t.params))),$e.debug("setupElicitationHandler: Elicitation handler registered successfully")}async disconnect(){if(!this.connected){$e.debug("Not connected to MCP implementation");return}$e.debug("Disconnecting from MCP implementation"),await this.cleanupResources(),this.connected=!1,$e.debug("Disconnected from MCP implementation")}get isClientConnected(){return this.client!=null}async initialize(t=this.opts.defaultRequestOptions??{}){if(!this.client)throw new Error("MCP client is not connected");$e.debug("Caching server capabilities & tools");const n=this.client.getServerCapabilities();this.capabilitiesCache=n||null;const a=this.client.getServerVersion();this.serverInfoCache=a||null;const r=await this.client.listTools(void 0,t);return this.toolsCache=r.tools??[],$e.debug(`Fetched ${this.toolsCache.length} tools from server`),$e.debug("Server capabilities:",n),$e.debug("Server info:",a),n}get tools(){if(!this.toolsCache)throw new Error("MCP client is not initialized; call initialize() first");return this.toolsCache}get serverCapabilities(){return this.capabilitiesCache||{}}get serverInfo(){return this.serverInfoCache}async callTool(t,n,a){if(!this.client)throw new Error("MCP client is not connected");const r=a?{...a}:void 0;r?.resetTimeoutOnProgress&&!r.onprogress&&(r.onprogress=()=>{},$e.debug(`[BaseConnector] Added onprogress callback for tool '${t}' to enable progressToken`)),$e.debug(`Calling tool '${t}' with args`,n);const i=await this.client.callTool({name:t,arguments:n},void 0,r);return $e.debug(`Tool '${t}' returned`,i),i}async listTools(t){if(!this.client)throw new Error("MCP client is not connected");return(await this.client.listTools(void 0,t)).tools??[]}async listResources(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug("Listing resources",t?`with cursor: ${t}`:""),await this.client.listResources({cursor:t},n)}async listAllResources(t){if(!this.client)throw new Error("MCP client is not connected");if(!this.capabilitiesCache?.resources)return $e.debug("Server does not advertise resources capability, skipping"),{resources:[]};try{$e.debug("Listing all resources (with auto-pagination)");const n=[];let a;do{const r=await this.client.listResources({cursor:a},t);n.push(...r.resources||[]),a=r.nextCursor}while(a);return{resources:n}}catch(n){if(n.code===-32601)return $e.debug("Server advertised resources but method not found"),{resources:[]};throw n}}async listResourceTemplates(t){if(!this.client)throw new Error("MCP client is not connected");return $e.debug("Listing resource templates"),await this.client.listResourceTemplates(void 0,t)}async readResource(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Reading resource ${t}`),await this.client.readResource({uri:t},n)}async subscribeToResource(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Subscribing to resource: ${t}`),await this.client.subscribeResource({uri:t},n)}async unsubscribeFromResource(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Unsubscribing from resource: ${t}`),await this.client.unsubscribeResource({uri:t},n)}async listPrompts(){if(!this.client)throw new Error("MCP client is not connected");if(!this.capabilitiesCache?.prompts)return $e.debug("Server does not advertise prompts capability, skipping"),{prompts:[]};try{return $e.debug("Listing prompts"),await this.client.listPrompts()}catch(t){if(t.code===-32601)return $e.debug("Server advertised prompts but method not found"),{prompts:[]};throw t}}async getPrompt(t,n){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Getting prompt ${t}`),await this.client.getPrompt({name:t,arguments:n})}async request(t,n=null,a){if(!this.client)throw new Error("MCP client is not connected");return $e.debug(`Sending raw request '${t}' with params`,n),await this.client.request({method:t,params:n??{}},void 0,a)}async cleanupResources(){const t=[];if(this.client)try{typeof this.client.close=="function"&&await this.client.close()}catch(n){const a=`Error closing client: ${n}`;$e.warn(a),t.push(a)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(n){const a=`Error stopping connection manager: ${n}`;$e.warn(a),t.push(a)}finally{this.connectionManager=null}this.toolsCache=null,t.length&&$e.warn(`Resource cleanup finished with ${t.length} issue(s)`)}},je(Ku,"BaseConnector"),Ku),Zu,Loe=(Zu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),$e.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){$e.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?$e.debug(`${this.constructor.name} task aborted successfully`):$e.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,$e.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(){$e.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),$e.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,$e.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){$e.warn(`Error closing connection in ${this.constructor.name}: ${t}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((t,n)=>{if(!this._abortController)return;const a=this._abortController.signal;if(a.aborted){t();return}const r=je(()=>{a.removeEventListener("abort",r),t()},"onAbort");a.addEventListener("abort",r)})}},je(Zu,"ConnectionManager"),Zu),Yu,$oe=(Yu=class extends Loe{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 Ioe(this.url,this.opts),n=t.send.bind(t);return t.send=async a=>{const r=je(async i=>{if(Array.isArray(i))for(const s of i)await n(s);else await n(i)},"sendMessage");try{await r(a)}catch(i){if(i?.code===404&&t.sessionId&&!this.reinitializing){$e.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),$e.info("[SSE] Re-initialization successful, retrying request"),await r(a)}finally{this.reinitializing=!1}}else throw i}},this._transport=t,$e.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){$e.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){$e.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},je(Yu,"SseConnectionManager"),Yu),qu,Moe=(qu=class extends joe{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;transportType=null;streamableTransport=null;constructor(t,n={}){super(n),this.baseUrl=t.replace(/\/$/,""),this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.gatewayUrl=n.gatewayUrl,this.serverId=n.serverId,this.gatewayUrl&&(this.headers["X-Target-URL"]=this.baseUrl,this.serverId&&(this.headers["X-Server-Id"]=this.serverId)),this.timeout=n.timeout??3e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1,this.disableSseFallback=n.disableSseFallback??!1}async connect(){if(this.connected){$e.debug("Already connected to MCP implementation");return}const t=this.gatewayUrl?this.gatewayUrl.replace(/\/$/,""):this.baseUrl;if(this.preferSse){$e.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}$e.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{$e.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),$e.info("✅ Successfully connected via streamable HTTP")}catch(n){let a="Unknown error",r=!1;if(n instanceof Tl){const i=n;r=i.code===401,i.code===400&&i.message.includes("Missing session ID")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",$e.warn(`⚠️ ${a}`)):i.code===404||i.code===405?(a=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,$e.debug(a)):(a=`Server returned ${i.code}: ${i.message}`,$e.debug(a))}else if(n instanceof Error){const i=n.toString(),s=n.message||"";r=i.includes("401")||s.includes("Unauthorized"),i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||s.includes("FastMCP session ID error")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",$e.warn(`⚠️ ${a}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(a="Server doesn't support streamable HTTP (405/404)",$e.debug(a)):(a=`Streamable HTTP failed: ${n.message}`,$e.debug(a))}if(r){$e.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}if(this.disableSseFallback)throw $e.info("SSE fallback disabled - failing connection"),await this.cleanupResources(),new Error(`Streamable HTTP connection failed: ${a}`);$e.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if($e.error("Failed to connect with both transports:"),$e.error(` Streamable HTTP: ${a}`),$e.error(` SSE: ${i}`),await this.cleanupResources(),i?.message?.includes("401")||i?.message?.includes("Unauthorized")){const c=new Error("Authentication required");throw c.code=401,c}throw new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(t){try{const n=new Noe(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let a=n;if(this.opts.wrapTransport){const i=this.baseUrl;a=this.opts.wrapTransport(a,i)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};$e.debug("Creating Client with capabilities:",JSON.stringify(r.capabilities,null,2)),this.client=new tz(this.clientInfo,r),this.setupRootsHandler(),$e.debug("Roots handler registered before connect");try{await this.client.connect(a,{timeout:Math.min(this.timeout,3e3)});const i=n.sessionId;i?$e.debug(`Session ID obtained: ${i}`):$e.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(i){if(i instanceof Error){const s=i.message||i.toString();if(s.includes("Missing session ID")||s.includes("Bad Request: Missing session ID")||s.includes("Mcp-Session-Id header is required")){const c=new Error(`Session ID error: ${s}. The SDK should automatically extract session ID from initialize response.`);throw c.cause=i,c}}throw i}this.streamableTransport=n,this.connectionManager={stop:je(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){$e.warn(`Error closing Streamable HTTP transport: ${i}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$e.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 $oe(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const r=this.baseUrl;n=this.opts.wrapTransport(n,r)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};$e.debug("Creating Client with capabilities (SSE):",JSON.stringify(a.capabilities,null,2)),this.client=new tz(this.clientInfo,a),this.setupRootsHandler(),$e.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$e.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}},je(qu,"HttpConnector"),qu),Fl,Poe=(Fl=class extends Doe{static getPackageVersion(){return pk()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Ui.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>$e.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new Fl(t)}createConnectorFromConfig(t){const{url:n,headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:f,disableSseFallback:m,preferSse:h}=t;if(!n)throw new Error("Server URL is required");const g={headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:f,disableSseFallback:m,preferSse:h};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new Moe(n,g)}},je(Fl,"BrowserMCPClient"),Fl);function du(e){const t=je(()=>{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(d9).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}je(du,"sanitizeUrl");function d9([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}je(d9,"sanitizeParam");var Xu,jb=(Xu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;useRedirectFlow;onPopupWindow;constructor(t,n={}){this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||"mcp:auth",this.serverUrlHash=this.hashString(t),this.clientName=n.clientName||"mcp-use",this.clientUri=n.clientUri||(typeof window<"u"?window.location.origin:""),this.callbackUrl=du(n.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=n.preventAutoAuth,this.useRedirectFlow=n.useRedirectFlow,this.onPopupWindow=n.onPopupWindow}get redirectUrl(){return du(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:"none",grant_types:["authorization_code","refresh_token"],response_types:["code"],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){const t=this.getKey("client_info"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,a),localStorage.removeItem(t);return}}async saveClientInformation(t){const n=this.getKey("client_info");localStorage.setItem(n,JSON.stringify(t))}async tokens(){const t=this.getKey("tokens"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,a),localStorage.removeItem(t);return}}async saveTokens(t){const n=this.getKey("tokens");localStorage.setItem(n,JSON.stringify(t)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(t){const n=this.getKey("code_verifier");localStorage.setItem(n,t)}async codeVerifier(){const t=this.getKey("code_verifier"),n=localStorage.getItem(t);if(!n)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${t}. Auth flow likely corrupted or timed out.`);return n}async prepareAuthorizationUrl(t){const n=globalThis.crypto.randomUUID(),a=`${this.storageKeyPrefix}:state_${n}`,r={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:this.useRedirectFlow&&typeof window<"u"?window.location.href:void 0};localStorage.setItem(a,JSON.stringify(r)),t.searchParams.set("state",n);const i=t.toString(),s=du(i);return localStorage.setItem(this.getKey("last_auth_url"),s),s}async redirectToAuthorization(t){const n=await this.prepareAuthorizationUrl(t);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=n;return}const a="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const r=window.open(n,`mcp_auth_${this.serverUrlHash}`,a);this.onPopupWindow&&this.onPopupWindow(n,a,r),!r||r.closed||typeof r.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(r.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(r){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,r)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?du(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,a=[];let r=0;for(let s=0;s<localStorage.length;s++){const c=localStorage.key(s);if(c){if(c.startsWith(t))a.push(c);else if(c.startsWith(n))try{const u=localStorage.getItem(c);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&a.push(c)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${c} during clearStorage:`,u)}}}return[...new Set(a)].forEach(s=>{localStorage.removeItem(s),r++}),r}hashString(t){let n=0;for(let a=0;a<t.length;a++){const r=t.charCodeAt(a);n=(n<<5)-n+r,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},je(Xu,"BrowserOAuthClientProvider"),Xu);async function TN(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),a=e.get("error"),r=e.get("error_description"),i="[mcp-callback]";console.log(`${i} Handling callback...`,{code:t,state:n,error:a,errorDescription:r});let s=null,c=null;const u=n?`mcp:auth:state_${n}`:null;try{if(a)throw new Error(`OAuth error: ${a} - ${r||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!u)throw new Error("State parameter not found or invalid in callback query parameters.");const f=localStorage.getItem(u);if(!f)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(f)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!c.expiry||c.expiry<Date.now())throw localStorage.removeItem(u),new Error("OAuth state has expired. Please try initiating authentication again.");if(!c.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:m,...h}=c.providerOptions;console.log(`${i} Re-instantiating provider for server: ${m}`),s=new jb(m,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await Io(s,{serverUrl:g,authorizationCode:t});if(v==="AUTHORIZED")if(console.log(`${i} Authorization successful via SDK auth().`),c.flowType==="redirect"&&c.returnUrl)console.log(`${i} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(u),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${i} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(u),window.close();else{console.warn(`${i} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(u);const x=window.location.pathname.split("/").filter(Boolean),w=x.length>0&&x[x.length-1]==="callback"?"/"+x.slice(0,-2).join("/"):"/";window.location.href=w||"/"}else throw console.warn(`${i} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(f){console.error(`${i} 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 v=document.createElement("p");v.style.color="red",v.style.backgroundColor="#ffebeb",v.style.border="1px solid red",v.style.padding="10px",v.style.borderRadius="4px",v.textContent=m,h.appendChild(v);const 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(`${i} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),s&&(localStorage.removeItem(s.getKey("code_verifier")),localStorage.removeItem(s.getKey("last_auth_url")))}}je(TN,"onMcpAuthorization");var cS={exports:{}},Et={};var cz;function zoe(){if(cz)return Et;cz=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(P){return P===null||typeof P!="object"?null:(P=g&&P[g]||P["@@iterator"],typeof P=="function"?P:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function S(P,F,U){this.props=P,this.context=F,this.refs=w,this.updater=U||E}S.prototype.isReactComponent={},S.prototype.setState=function(P,F){if(typeof P!="object"&&typeof P!="function"&&P!=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,P,F,"setState")},S.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function _(){}_.prototype=S.prototype;function k(P,F,U){this.props=P,this.context=F,this.refs=w,this.updater=U||E}var N=k.prototype=new _;N.constructor=k,x(N,S.prototype),N.isPureReactComponent=!0;var C=Array.isArray;function A(){}var I={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(P,F,U){var L=U.ref;return{$$typeof:e,type:P,key:F,ref:L!==void 0?L:null,props:U}}function j(P,F){return M(P.type,F,P.props)}function B(P){return typeof P=="object"&&P!==null&&P.$$typeof===e}function G(P){var F={"=":"=0",":":"=2"};return"$"+P.replace(/[=:]/g,function(U){return F[U]})}var ee=/\/+/g;function te(P,F){return typeof P=="object"&&P!==null&&P.key!=null?G(""+P.key):F.toString(36)}function ae(P){switch(P.status){case"fulfilled":return P.value;case"rejected":throw P.reason;default:switch(typeof P.status=="string"?P.then(A,A):(P.status="pending",P.then(function(F){P.status==="pending"&&(P.status="fulfilled",P.value=F)},function(F){P.status==="pending"&&(P.status="rejected",P.reason=F)})),P.status){case"fulfilled":return P.value;case"rejected":throw P.reason}}throw P}function V(P,F,U,L,$){var W=typeof P;(W==="undefined"||W==="boolean")&&(P=null);var K=!1;if(P===null)K=!0;else switch(W){case"bigint":case"string":case"number":K=!0;break;case"object":switch(P.$$typeof){case e:case t:K=!0;break;case m:return K=P._init,V(K(P._payload),F,U,L,$)}}if(K)return $=$(P),K=L===""?"."+te(P,0):L,C($)?(U="",K!=null&&(U=K.replace(ee,"$&/")+"/"),V($,F,U,"",function(oe){return oe})):$!=null&&(B($)&&($=j($,U+($.key==null||P&&P.key===$.key?"":(""+$.key).replace(ee,"$&/")+"/")+K)),F.push($)),1;K=0;var Y=L===""?".":L+":";if(C(P))for(var se=0;se<P.length;se++)L=P[se],W=Y+te(L,se),K+=V(L,F,U,W,$);else if(se=v(P),typeof se=="function")for(P=se.call(P),se=0;!(L=P.next()).done;)L=L.value,W=Y+te(L,se++),K+=V(L,F,U,W,$);else if(W==="object"){if(typeof P.then=="function")return V(ae(P),F,U,L,$);throw F=String(P),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(P).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.")}return K}function q(P,F,U){if(P==null)return P;var L=[],$=0;return V(P,L,"","",function(W){return F.call(U,W,$++)}),L}function H(P){if(P._status===-1){var F=P._result;F=F(),F.then(function(U){(P._status===0||P._status===-1)&&(P._status=1,P._result=U)},function(U){(P._status===0||P._status===-1)&&(P._status=2,P._result=U)}),P._status===-1&&(P._status=0,P._result=F)}if(P._status===1)return P._result.default;throw P._result}var ie=typeof reportError=="function"?reportError:function(P){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var F=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof P=="object"&&P!==null&&typeof P.message=="string"?String(P.message):String(P),error:P});if(!window.dispatchEvent(F))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",P);return}console.error(P)},re={map:q,forEach:function(P,F,U){q(P,function(){F.apply(this,arguments)},U)},count:function(P){var F=0;return q(P,function(){F++}),F},toArray:function(P){return q(P,function(F){return F})||[]},only:function(P){if(!B(P))throw Error("React.Children.only expected to receive a single React element child.");return P}};return Et.Activity=h,Et.Children=re,Et.Component=S,Et.Fragment=n,Et.Profiler=r,Et.PureComponent=k,Et.StrictMode=a,Et.Suspense=u,Et.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,Et.__COMPILER_RUNTIME={__proto__:null,c:function(P){return I.H.useMemoCache(P)}},Et.cache=function(P){return function(){return P.apply(null,arguments)}},Et.cacheSignal=function(){return null},Et.cloneElement=function(P,F,U){if(P==null)throw Error("The argument must be a React element, but you passed "+P+".");var L=x({},P.props),$=P.key;if(F!=null)for(W in F.key!==void 0&&($=""+F.key),F)!O.call(F,W)||W==="key"||W==="__self"||W==="__source"||W==="ref"&&F.ref===void 0||(L[W]=F[W]);var W=arguments.length-2;if(W===1)L.children=U;else if(1<W){for(var K=Array(W),Y=0;Y<W;Y++)K[Y]=arguments[Y+2];L.children=K}return M(P.type,$,L)},Et.createContext=function(P){return P={$$typeof:s,_currentValue:P,_currentValue2:P,_threadCount:0,Provider:null,Consumer:null},P.Provider=P,P.Consumer={$$typeof:i,_context:P},P},Et.createElement=function(P,F,U){var L,$={},W=null;if(F!=null)for(L in F.key!==void 0&&(W=""+F.key),F)O.call(F,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&($[L]=F[L]);var K=arguments.length-2;if(K===1)$.children=U;else if(1<K){for(var Y=Array(K),se=0;se<K;se++)Y[se]=arguments[se+2];$.children=Y}if(P&&P.defaultProps)for(L in K=P.defaultProps,K)$[L]===void 0&&($[L]=K[L]);return M(P,W,$)},Et.createRef=function(){return{current:null}},Et.forwardRef=function(P){return{$$typeof:c,render:P}},Et.isValidElement=B,Et.lazy=function(P){return{$$typeof:m,_payload:{_status:-1,_result:P},_init:H}},Et.memo=function(P,F){return{$$typeof:f,type:P,compare:F===void 0?null:F}},Et.startTransition=function(P){var F=I.T,U={};I.T=U;try{var L=P(),$=I.S;$!==null&&$(U,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(A,ie)}catch(W){ie(W)}finally{F!==null&&U.types!==null&&(F.types=U.types),I.T=F}},Et.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},Et.use=function(P){return I.H.use(P)},Et.useActionState=function(P,F,U){return I.H.useActionState(P,F,U)},Et.useCallback=function(P,F){return I.H.useCallback(P,F)},Et.useContext=function(P){return I.H.useContext(P)},Et.useDebugValue=function(){},Et.useDeferredValue=function(P,F){return I.H.useDeferredValue(P,F)},Et.useEffect=function(P,F){return I.H.useEffect(P,F)},Et.useEffectEvent=function(P){return I.H.useEffectEvent(P)},Et.useId=function(){return I.H.useId()},Et.useImperativeHandle=function(P,F,U){return I.H.useImperativeHandle(P,F,U)},Et.useInsertionEffect=function(P,F){return I.H.useInsertionEffect(P,F)},Et.useLayoutEffect=function(P,F){return I.H.useLayoutEffect(P,F)},Et.useMemo=function(P,F){return I.H.useMemo(P,F)},Et.useOptimistic=function(P,F){return I.H.useOptimistic(P,F)},Et.useReducer=function(P,F,U){return I.H.useReducer(P,F,U)},Et.useRef=function(P){return I.H.useRef(P)},Et.useState=function(P){return I.H.useState(P)},Et.useSyncExternalStore=function(P,F,U){return I.H.useSyncExternalStore(P,F,U)},Et.useTransition=function(){return I.H.useTransition()},Et.version="19.2.3",Et}var uz;function NN(){return uz||(uz=1,cS.exports=zoe()),cS.exports}var y=NN();const Q=ay(y),kd=wJ({__proto__:null,default:Q},[y]);function UE(e,t){if(!e)throw new Error(t)}je(UE,"assert");var dz=3e3,Uoe=5e3;function CN(e){const{url:t,enabled:n=!0,clientName:a,clientUri:r,callbackUrl:i=typeof window<"u"?du(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:s="mcp:auth",clientConfig:c={},customHeaders:u={},debug:f=!1,autoRetry:m=!1,autoReconnect:h=dz,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:E=!1,onPopupWindow:x,timeout:w=3e4,sseReadTimeout:S=3e5,wrapTransport:_,onNotification:k,samplingCallback:N,onElicitation:C}=e,[A,I]=y.useState("discovering"),[O,M]=y.useState([]),[j,B]=y.useState([]),[G,ee]=y.useState([]),[te,ae]=y.useState([]),[V,q]=y.useState(),[H,ie]=y.useState(),[re,P]=y.useState(void 0),[F,U]=y.useState([]),[L,$]=y.useState(void 0),[W,K]=y.useState(void 0),Y=y.useRef(null),se=y.useRef(null),oe=y.useRef(null),X=y.useRef(!1),J=y.useRef(!0),le=y.useRef(0),pe=y.useRef(null),me=y.useRef(A),_e=y.useRef(h),ze=y.useRef(null);y.useEffect(()=>{me.current=A,_e.current=h},[A,h]);const ue=y.useCallback((Se,Oe,...Ge)=>{const lt=Ge.length>0?`${Oe} ${Ge.map(Xe=>JSON.stringify(Xe)).join(" ")}`:Oe;console[Se](`[useMcp] ${lt}`),J.current&&U(Xe=>[...Xe.slice(-100),{level:Se,message:lt,timestamp:Date.now()}])},[]),Pe=y.useCallback(async(Se=!1)=>{if(Se||ue("info","Disconnecting..."),X.current=!1,pe.current&&clearTimeout(pe.current),pe.current=null,Y.current)try{const Oe="inspector-server",Ge=Y.current.getSession(Oe);Ge&&Ge._healthCheckCleanup&&(Ge._healthCheckCleanup(),Ge._healthCheckCleanup=null),await Y.current.closeSession(Oe)}catch(Oe){Se||ue("warn","Error closing session:",Oe)}Y.current=null,J.current&&!Se&&(I("discovering"),M([]),B([]),ee([]),ae([]),P(void 0),$(void 0))},[ue]),Ye=y.useCallback((Se,Oe)=>{if(ue("error",Se,Oe??""),J.current){I("failed"),P(Se);const Ge=se.current?.getLastAttemptedAuthUrl();Ge&&($(Ge),ue("info","Manual authentication URL may be available.",Ge))}X.current=!1,t&&Ui.getInstance().trackUseMcpConnection({url:t,transportType:g,success:!1,errorType:Oe?.name||"UnknownError",hasOAuth:!!se.current,hasSampling:!!N,hasElicitation:!!C}).catch(()=>{})},[ue,t,g,N,C]),fe=y.useCallback(async()=>{if(!n||!t){ue("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(X.current){ue("debug","Connection attempt already in progress.");return}if(!J.current){ue("debug","Connect called after unmount, aborting.");return}X.current=!0,le.current+=1,P(void 0),$(void 0),ze.current=null,I("discovering"),ue("info",`Connecting attempt #${le.current} to ${t}...`),se.current||(se.current=new jb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:E,onPopupWindow:x}),ue("debug","BrowserOAuthClientProvider initialized in connect.")),Y.current||(Y.current=new Poe,ue("debug","BrowserMCPClient initialized in connect."));const Se=je(async(Ge,lt=!1)=>{ue("info",`Attempting connection with transport: ${Ge}`);try{const Xe="inspector-server",it={url:t,transport:Ge==="sse"?"http":Ge,disableSseFallback:Ge==="http",preferSse:Ge==="sse"};if(u&&Object.keys(u).length>0&&(it.headers=u),se.current){const et=await se.current.tokens();et?.access_token&&(it.headers={...it.headers,Authorization:`Bearer ${et.access_token}`})}Y.current.addServer(Xe,{...it,authProvider:se.current,clientOptions:c,samplingCallback:N,elicitationCallback:C,wrapTransport:_?et=>(console.log("[useMcp] Applying transport wrapper for server:",Xe,"url:",t),_(et,t)):void 0});const mt=await Y.current.createSession(Xe,!1);mt.on("notification",et=>{k?.(et),et.method==="notifications/tools/list_changed"?(ue("info","Tools list changed, auto-refreshing..."),at().catch(Lt=>ue("warn","Auto-refresh tools failed:",Lt))):et.method==="notifications/resources/list_changed"?(ue("info","Resources list changed, auto-refreshing..."),yt().catch(Lt=>ue("warn","Auto-refresh resources failed:",Lt))):et.method==="notifications/prompts/list_changed"&&(ue("info","Prompts list changed, auto-refreshing..."),xn().catch(Lt=>ue("warn","Auto-refresh prompts failed:",Lt)))}),await mt.initialize(),ue("info","✅ Successfully connected to MCP server"),ue("info","Server info:",mt.connector.serverInfo),ue("info","Server capabilities:",mt.connector.serverCapabilities),console.log("[useMcp] Server info:",mt.connector.serverInfo),console.log("[useMcp] Server capabilities:",mt.connector.serverCapabilities),I("ready"),ze.current=Ge;const Ze=je(()=>{let et=null,Lt=Date.now();const dn=1e4,nn=3e4;return et=setInterval(je(async()=>{if(!J.current||me.current!=="ready"){et&&(clearInterval(et),et=null);return}try{await mt.connector.listTools(),Lt=Date.now()}catch{const Nt=Date.now()-Lt;Nt>nn&&(ue("warn",`Connection appears to be broken (no response for ${Math.round(Nt/1e3)}s), attempting to reconnect...`),et&&(clearInterval(et),et=null),_e.current&&J.current&&(I("discovering"),ue("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{J.current&&me.current==="discovering"&&fe()},typeof _e.current=="number"?_e.current:dz)))}},"checkConnectionHealth"),dn),()=>{et&&(clearInterval(et),et=null)}},"setupConnectionMonitoring");if(h){const et=Ze();mt._healthCheckCleanup=et}Ui.getInstance().trackUseMcpConnection({url:t,transportType:Ge,success:!0,hasOAuth:!!se.current,hasSampling:!!N,hasElicitation:!!C}).catch(()=>{}),M(mt.connector.tools||[]);const vt=await mt.connector.listAllResources();B(vt.resources||[]);const wt=await mt.connector.listPrompts();ae(wt.prompts||[]);const kt=mt.connector.serverInfo,Wn=mt.connector.serverCapabilities;if(kt){console.log("[useMcp] Server info:",kt),q(kt);const et=(async()=>{try{const Lt=kt.icons;if(Lt&&Array.isArray(Lt)&&Lt.length>0){const dn=Lt[0].src||Lt[0].url;if(dn){ue("info","Server provided icon:",dn);const on=await(await fetch(dn)).blob(),gr=await new Promise((Nt,Qr)=>{const br=new FileReader;br.onloadend=()=>Nt(br.result),br.onerror=Qr,br.readAsDataURL(on)});return J.current&&(q(Nt=>Nt?{...Nt,icon:gr}:void 0),ue("debug","Server icon converted to base64")),gr}}if(t){const dn=await vF(t);if(dn&&J.current)return q(nn=>nn?{...nn,icon:dn}:void 0),ue("debug","Favicon detected and added to serverInfo"),dn}return null}catch(Lt){return ue("debug","Icon loading failed (non-critical):",Lt),null}})();oe.current=et}if(Wn&&(console.log("[useMcp] Server capabilities:",Wn),ie(Wn)),se.current){const et=await se.current.tokens();if(et?.access_token){const Lt=et.expires_in?Date.now()+et.expires_in*1e3:void 0;K({access_token:et.access_token,token_type:et.token_type||"Bearer",expires_at:Lt,refresh_token:et.refresh_token,scope:et.scope})}}return"success"}catch(Xe){const it=Xe,mt=it?.message||String(Xe);if(it.code===401||mt.includes("401")||mt.includes("Unauthorized")){if(se.current){ue("info","Authentication required. OAuth provider available.");try{const{auth:Ze}=await Mr(async()=>{const{auth:wt}=await Promise.resolve().then(()=>az);return{auth:wt}},void 0),vt=new URL(t).origin;Ze(se.current,{serverUrl:vt}).catch(()=>{}),setTimeout(()=>{if(J.current){const wt=se.current?.getLastAttemptedAuthUrl();wt?($(wt),ue("info","Manual authentication URL available:",wt)):ue("warn","Could not generate authentication URL")}},100)}catch(Ze){ue("warn","Error generating auth URL:",Ze)}return J.current&&I("pending_auth"),X.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(Ye("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Ye("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Ye(mt,it instanceof Error?it:new Error(String(it))),"failed"}},"tryConnectWithTransport");let Oe="failed";if(g==="sse")ue("debug","Using SSE-only transport mode"),Oe=await Se("sse");else if(g==="http")ue("debug","Using HTTP-only transport mode"),Oe=await Se("http");else{ue("debug","Using auto transport mode (HTTP with SSE fallback)");const Ge=await Se("http");Ge==="fallback"&&J.current&&me.current!=="authenticating"?(ue("info","HTTP failed, attempting SSE fallback..."),Oe=await Se("sse")):Oe=Ge}(Oe==="success"||Oe==="failed"||Oe==="auth_redirect")&&(X.current=!1),ue("debug",`Connection sequence finished with status: ${Oe}`)},[ue,Ye,Pe,t,s,a,r,i,c.name,c.version,u,g,v,E,x,n,w,S]),De=y.useCallback(async(Se,Oe,Ge)=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot call tool "${Se}".`);ue("info",`Calling tool: ${Se}`,Oe);const lt=Date.now();try{const it=Y.current.getSession("inspector-server");if(!it)throw new Error("No active session found");const mt=await it.connector.callTool(Se,Oe||{},Ge);return ue("info",`Tool "${Se}" call successful:`,mt),Ui.getInstance().trackUseMcpToolCall({toolName:Se,success:!0,executionTimeMs:Date.now()-lt}).catch(()=>{}),mt}catch(Xe){throw ue("error",`Tool "${Se}" call failed:`,Xe),Ui.getInstance().trackUseMcpToolCall({toolName:Se,success:!1,errorType:Xe instanceof Error?Xe.name:"UnknownError",executionTimeMs:Date.now()-lt}).catch(()=>{}),Xe}},[A]),He=y.useCallback(()=>{me.current==="failed"?(ue("info","Retry requested..."),fe()):ue("warn",`Retry called but state is not 'failed' (state: ${me.current}). Ignoring.`)},[ue,fe]),Ee=y.useCallback(async()=>{ue("info","Manual authentication requested...");const Se=me.current;if(Se==="failed")ue("info","Attempting to reconnect and authenticate via retry..."),He();else if(Se==="pending_auth"){ue("info","Proceeding with authentication from pending state...");try{UE(se.current,"Auth Provider not available for manual auth"),UE(t,"Server URL is required for authentication"),ue("info","Clearing all OAuth state and initiating fresh flow...");const Oe=`${s}:${se.current.serverUrlHash}`;Object.keys(localStorage).forEach(it=>{it.startsWith(Oe)&&(ue("debug",`Removing stale OAuth key: ${it}`),localStorage.removeItem(it)),it.startsWith(`${s}:state_`)&&(ue("debug",`Removing orphaned state: ${it}`),localStorage.removeItem(it))}),I("authenticating");const Ge=new jb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:E,onPopupWindow:x});se.current=Ge,ue("info","Triggering fresh OAuth authorization...");const{auth:lt}=await Mr(async()=>{const{auth:it}=await Promise.resolve().then(()=>az);return{auth:it}},void 0),Xe=new URL(t).origin;lt(Ge,{serverUrl:Xe}).catch(it=>{ue("info","OAuth flow initiated:",it instanceof Error?it.message:"Redirecting...")})}catch(Oe){if(!J.current)return;I("pending_auth"),ue("error",`Manual authentication failed: ${Oe instanceof Error?Oe.message:String(Oe)}`)}}else if(Se==="authenticating"){ue("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Oe=se.current?.getLastAttemptedAuthUrl();Oe&&!L&&($(Oe),ue("info","Manual authentication URL retrieved:",Oe))}else ue("info",`Client not in a state requiring manual authentication trigger (state: ${Se}). If needed, try disconnecting and reconnecting.`)},[ue,He,L,t,E,x,s,a,r,i]),Ne=y.useCallback(()=>{if(se.current){const Se=se.current.clearStorage();ue("info",`Cleared ${Se} item(s) from localStorage for ${t}.`),$(void 0),Pe()}else ue("warn","Auth provider not initialized, cannot clear storage.")},[t,ue,Pe]),Ae=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list resources.`);ue("info","Listing resources");try{const Oe=Y.current.getSession("inspector-server");if(!Oe)throw new Error("No active session found");const Ge=await Oe.connector.listAllResources();B(Ge.resources||[]),ue("info","Resources listed successfully")}catch(Se){throw ue("error","List resources failed:",Se),Se}},[A]),We=y.useCallback(async Se=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot read resource.`);ue("info",`Reading resource: ${Se}`);try{const Ge=Y.current.getSession("inspector-server");if(!Ge)throw new Error("No active session found");const lt=await Ge.connector.readResource(Se);return ue("info","Resource read successful:",lt),Ui.getInstance().trackUseMcpResourceRead({resourceUri:Se,success:!0}).catch(()=>{}),lt}catch(Oe){throw ue("error","Resource read failed:",Oe),Ui.getInstance().trackUseMcpResourceRead({resourceUri:Se,success:!1,errorType:Oe instanceof Error?Oe.name:"UnknownError"}).catch(()=>{}),Oe}},[A]),ft=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list prompts.`);ue("info","Listing prompts");try{const Oe=Y.current.getSession("inspector-server");if(!Oe)throw new Error("No active session found");const Ge=await Oe.connector.listPrompts();ae(Ge.prompts||[]),ue("info","Prompts listed successfully")}catch(Se){throw ue("error","List prompts failed:",Se),Se}},[A]),at=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current){ue("debug","Cannot refresh tools - client not ready");return}ue("debug","Refreshing tools list");try{const Oe=Y.current.getSession("inspector-server");if(!Oe){ue("warn","No active session found for tools refresh");return}const Ge=await Oe.connector.listTools();M(Ge||[]),ue("info","Tools list refreshed successfully")}catch(Se){ue("warn","Failed to refresh tools:",Se)}},[ue]),yt=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current){ue("debug","Cannot refresh resources - client not ready");return}ue("debug","Refreshing resources list");try{const Oe=Y.current.getSession("inspector-server");if(!Oe){ue("warn","No active session found for resources refresh");return}const Ge=await Oe.connector.listAllResources();B(Ge.resources||[]),ue("info","Resources list refreshed successfully")}catch(Se){ue("warn","Failed to refresh resources:",Se)}},[ue]),xn=y.useCallback(async()=>{if(me.current!=="ready"||!Y.current){ue("debug","Cannot refresh prompts - client not ready");return}ue("debug","Refreshing prompts list");try{const Oe=Y.current.getSession("inspector-server");if(!Oe){ue("warn","No active session found for prompts refresh");return}const Ge=await Oe.connector.listPrompts();ae(Ge.prompts||[]),ue("info","Prompts list refreshed successfully")}catch(Se){ue("warn","Failed to refresh prompts:",Se)}},[ue]),pt=y.useCallback(async()=>{ue("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([at(),yt(),xn()])},[at,yt,xn,ue]),Gn=y.useCallback(async()=>me.current!=="ready"?(ue("warn","Cannot ensure icon loaded - not connected"),null):V?.icon?V.icon:oe.current?(ue("debug","Waiting for icon to finish loading..."),await oe.current):(ue("debug","No icon available and no loading in progress"),null),[V,ue]),hn=y.useCallback(async(Se,Oe)=>{if(me.current!=="ready"||!Y.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot get prompt.`);ue("info",`Getting prompt: ${Se}`,Oe);try{const lt=Y.current.getSession("inspector-server");if(!lt)throw new Error("No active session found");const Xe=await lt.connector.getPrompt(Se,Oe||{});return ue("info",`Prompt "${Se}" retrieved successfully:`,Xe),Xe}catch(Ge){throw ue("error",`Prompt "${Se}" retrieval failed:`,Ge),Ge}},[A]),Ve=y.useRef(fe),Ue=y.useRef(Ye);return y.useEffect(()=>{Ve.current=fe,Ue.current=Ye}),y.useEffect(()=>{const Se=je(Oe=>{Oe.origin===window.location.origin&&Oe.data?.type==="mcp_auth_callback"&&(ue("info","Received auth callback message.",Oe.data),pe.current&&clearTimeout(pe.current),pe.current=null,Oe.data.success?(ue("info","Authentication successful via popup. Reconnecting client..."),X.current&&ue("debug","Connection attempt already in progress, resetting flag to allow reconnection."),X.current=!1,setTimeout(()=>{J.current&&(ue("debug","Initiating reconnection after successful auth callback."),Ve.current())},100)):Ue.current(`Authentication failed in callback: ${Oe.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Se),ue("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Se),ue("debug","Auth callback message listener removed."),pe.current&&clearTimeout(pe.current)}},[ue]),y.useEffect(()=>(J.current=!0,!n||!t?(ue("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),I("discovering"),()=>{J.current=!1}):(ue("debug","useMcp mounted, initiating connection."),le.current=0,(!se.current||se.current.serverUrl!==t)&&(se.current=new jb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:E,onPopupWindow:x}),ue("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),fe(),()=>{J.current=!1,ue("debug","useMcp unmounting, disconnecting."),Pe(!0)})),[t,n,s,i,a,r,c.name,c.version,E]),y.useEffect(()=>{let Se=null;if(A==="failed"&&m&&le.current>0){const Oe=typeof m=="number"?m:Uoe;ue("info",`Connection failed, auto-retrying in ${Oe}ms...`),Se=setTimeout(()=>{J.current&&me.current==="failed"&&He()},Oe)}return()=>{Se&&clearTimeout(Se)}},[A,m,He,ue]),{state:A,tools:O,resources:j,resourceTemplates:G,prompts:te,serverInfo:V,capabilities:H,error:re,log:F,authUrl:L,authTokens:W,client:Y.current,callTool:De,readResource:We,listResources:Ae,listPrompts:ft,getPrompt:hn,refreshTools:at,refreshResources:yt,refreshPrompts:xn,refreshAll:pt,retry:He,disconnect:Pe,authenticate:Ee,clearStorage:Ne,ensureIconLoaded:Gn}}je(CN,"useMcp");function Foe({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:a="",onSuccess:r,onError:i,trigger:s}){const[c,u]=y.useState(!1),[f,m]=y.useState(null),[h,g]=y.useState(!1),[v,E]=y.useState(!1),{url:x,name:w,headers:S}=e,_=je(()=>{try{const j=iy(x,w,S);window.location.href=j,r?.("Cursor")}catch(j){console.error("Failed to generate Cursor deep link:",j),i?.(j)}},"handleCursorClick"),k=je(()=>{try{const j=oy(x,w,S);window.location.href=j,r?.("VS Code")}catch(j){console.error("Failed to generate VS Code deep link:",j),i?.(j)}},"handleVSCodeClick"),N=je(()=>{try{sy(x,w,S),r?.("Claude Desktop")}catch(j){console.error("Failed to download .mcpb file:",j),i?.(j)}},"handleClaudeDesktopClick"),C=je(()=>{m("claude-code"),u(!0)},"handleClaudeCodeClick"),A=je(()=>{m("gemini-cli"),u(!0)},"handleGeminiCLIClick"),I=je(()=>{m("codex-cli"),u(!0)},"handleCodexCLIClick"),O=je(async j=>{try{await navigator.clipboard.writeText(j),g(!0),setTimeout(()=>g(!1),2e3)}catch(B){console.error("Failed to copy:",B),i?.(B)}},"handleCopy"),M=je(()=>{if(f==="claude-code"){const{command:j,envVars:B}=ly(x,w,S),G=kp(B);return Q.createElement("div",{className:"space-y-4"},Q.createElement("div",null,Q.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Claude Code"),Q.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Execute the following command in your shell to add this server to Claude Code.")),Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),Q.createElement("ol",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400"},Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"1."),Q.createElement("span",null,"Ensure the Claude Code executable is available in your path")),Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"2."),Q.createElement("span",null,"Execute the following snippet in your shell:")))),Q.createElement("div",{className:"relative"},Q.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>O(j)},h?"✓ Copied":"Copy"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,j))),G&&Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Environment Variables"),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2"},"After installation, set these environment variables in your shell:"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,G))),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"The MCP configuration supports environment variable expansion using"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"${VAR}")," ","syntax."))}if(f==="gemini-cli"){const{command:j,envVars:B}=cy(x,w,S),G=kp(B);return Q.createElement("div",{className:"space-y-4"},Q.createElement("div",null,Q.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Gemini CLI"),Q.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Execute the following command in your shell to add this server to Gemini CLI.")),Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),Q.createElement("ol",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400"},Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"1."),Q.createElement("span",null,"Ensure the Gemini CLI executable is available in your path")),G&&Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"2."),Q.createElement("span",null,"Set these environment variables in your shell before running the command:")),Q.createElement("li",{className:"flex gap-2"},Q.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},G?"3.":"2."),Q.createElement("span",null,"Execute the following snippet in your shell:")))),G&&Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Environment Variables"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,G))),Q.createElement("div",{className:"relative"},Q.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>O(j)},h?"✓ Copied":"Copy"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,j))),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Restart Gemini CLI to load the new configuration."))}if(f==="codex-cli"){const{config:j,envVars:B}=uy(x,w,S);return Q.createElement("div",{className:"space-y-4"},Q.createElement("div",null,Q.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Codex CLI"),Q.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Add this configuration to your"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"~/.codex/config.toml")," ","file.")),Q.createElement("div",null,Q.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Add this configuration to your"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"~/.codex/config.toml"),":")),Q.createElement("div",{className:"relative"},Q.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>O(j)},h?"✓ Copied":"Copy"),Q.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},Q.createElement("code",null,j))),B.length>0&&Q.createElement("div",null,Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"(optional) If you would rather use variables from your system's environment, replace the"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"http_headers")," ","key with the"," ",Q.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"env_http_headers")," ","key as shown in the commented section above.")),Q.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Restart Codex CLI to load the new configuration."))}return null},"renderModalContent");return Q.createElement(Q.Fragment,null,Q.createElement("div",{className:"relative inline-block"},s?Q.createElement("div",{onClick:j=>{j.stopPropagation(),E(!v)},className:"cursor-pointer"},typeof s=="function"?s({isOpen:v,onClick:je(()=>E(!v),"onClick")}):Q.isValidElement(s)?Q.cloneElement(s,{onClick:je(j=>{j.preventDefault(),j.stopPropagation(),E(!v)},"onClick")}):s):Q.createElement("button",{onClick:()=>E(!v),className:`inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${a}`},Q.createElement("span",null,"Add to Client"),Q.createElement("svg",{className:`w-4 h-4 transition-transform ${v?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Q.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),v&&Q.createElement(Q.Fragment,null,Q.createElement("div",{className:"fixed inset-0 z-40",onClick:()=>E(!1)}),Q.createElement("div",{className:"absolute right-0 mt-2 w-48 rounded-md shadow-lg bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 z-50"},Q.createElement("div",{className:"py-1"},t.map(j=>Q.createElement("button",{key:j.id,onClick:async()=>{E(!1),await j.onClick()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},j.icon,Q.createElement("span",null,j.label))),t.length>0&&Q.createElement("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),n.cursor&&Q.createElement("button",{onClick:()=>{E(!1),_()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),Q.createElement("span",null,"Cursor")),n.claudeCode&&Q.createElement("button",{onClick:()=>{E(!1),C()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),Q.createElement("span",null,"Claude Code")),n.claudeDesktop&&Q.createElement("button",{onClick:()=>{E(!1),N()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),Q.createElement("span",null,"Claude Desktop")),n.vsCode&&Q.createElement("button",{onClick:()=>{E(!1),k()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor"},Q.createElement("path",{d:"M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z"})),Q.createElement("span",null,"VS Code")),n.geminiCli&&Q.createElement("button",{onClick:()=>{E(!1),A()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),Q.createElement("span",null,"Gemini CLI")),n.codexCli&&Q.createElement("button",{onClick:()=>{E(!1),I()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},Q.createElement("img",{src:"https://inspector-cdn.mcp-use.com/providers/openai.png",alt:"Codex",className:"h-4 w-4"}),Q.createElement("span",null,"Codex CLI")))))),c&&Q.createElement(Q.Fragment,null,Q.createElement("div",{className:"fixed inset-0 bg-black/50 z-50",onClick:()=>u(!1)}),Q.createElement("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4"},Q.createElement("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] overflow-y-auto border border-gray-200 dark:border-gray-700 p-6",onClick:j=>j.stopPropagation()},M(),Q.createElement("div",{className:"mt-6 flex justify-end"},Q.createElement("button",{onClick:()=>u(!1),className:"px-4 py-2 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"},"Close"))))))}je(Foe,"AddToClientDropdown");var Ju,Boe=(Ju=class extends Q.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?Q.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"},Q.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),Q.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},je(Ju,"ErrorBoundary"),Ju),pp="openai:set_globals";function di(e){return y.useSyncExternalStore(t=>{const n=je(a=>{a.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(pp,n),()=>{typeof window<"u"&&window.removeEventListener(pp,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}je(di,"useOpenAiGlobal");function Td(e){const[t,n]=y.useState(()=>typeof window<"u"&&!!window.openai);y.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const j=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(j))},100),B=je(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(j))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(pp,B);const G=setTimeout(()=>{clearInterval(j),typeof window<"u"&&window.removeEventListener(pp,B)},5e3);return()=>{clearInterval(j),clearTimeout(G),typeof window<"u"&&window.removeEventListener(pp,B)}},[]);const a=y.useMemo(()=>t?"openai":"mcp-ui",[t]),r=typeof window<"u"?window.location.search:"",i=y.useMemo(()=>{const j=new URLSearchParams(r);return j.has("mcpUseParams")?JSON.parse(j.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[r]),s=a==="openai"?di("toolInput"):i.toolInput,c=a==="openai"?di("toolOutput"):i.toolOutput,u=di("toolResponseMetadata"),f=y.useMemo(()=>{if(u&&typeof u=="object"){const j=u["mcp-use/props"];if(j)return j}return e||{}},[u,e]),m=di("widgetState"),h=di("theme"),g=di("displayMode"),v=di("safeArea"),E=di("maxHeight"),x=di("userAgent"),w=di("locale"),S=y.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,k]=y.useState(null);y.useEffect(()=>{m!==void 0&&k(m)},[m]);const N=y.useCallback(async(j,B)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(j,B)},[]),C=y.useCallback(async j=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:j})},[]),A=y.useCallback(j=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:j})},[]),I=y.useCallback(async j=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:j})},[]),O=y.useCallback(async j=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const G=typeof j=="function"?j(m!==void 0?m:_):j;return k(G),window.openai.setWidgetState(G)},[m,_]),M=y.useMemo(()=>a==="openai"&&u===null,[a,u]);return{props:f,toolInput:s||{},output:c??null,metadata:u??null,state:_,setState:O,theme:h||"light",displayMode:g||"inline",safeArea:v||{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:N,sendFollowUpMessage:C,openExternal:A,requestDisplayMode:I,isAvailable:t,isPending:M}}je(Td,"useWidget");function Hoe(e){const{props:t}=Td(e);return t}je(Hoe,"useWidgetProps");function Voe(){const{theme:e}=Td();return e}je(Voe,"useWidgetTheme");function Goe(e){const{state:t,setState:n}=Td();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}je(Goe,"useWidgetState");var fz=je(({children:e})=>{const{theme:t,isAvailable:n}=Td();console.log("theme",t);const[a,r]=y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");y.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),c=je(u=>{r(u.matches?"dark":"light")},"handleChange");return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]);const i=n?t:a;return y.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),Q.createElement(Q.Fragment,null,e)},"ThemeProvider");function f9({children:e,className:t="",position:n="top-right",attachTo:a,showLabels:r=!0,debugger:i=!1,viewControls:s=!1}){const{props:c,output:u,metadata:f,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:E,userAgent:x,locale:w,isAvailable:S,callTool:_,sendFollowUpMessage:k,openExternal:N,requestDisplayMode:C,setState:A}=Td(),[I,O]=y.useState(!1),[M,j]=y.useState(!1),B=y.useRef(null),G=y.useRef(null),[ee,te]=y.useState([]),[ae,V]=y.useState(""),[q,H]=y.useState("get-my-city"),[ie,re]=y.useState("{}"),[P,F]=y.useState("Test follow-up message"),[U,L]=y.useState("https://docs.mcp-use.com"),$=g==="fullscreen"&&S,W=g==="pip"&&S,K=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const Ee=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const Ne=Object.keys(window.openai);te(Ne)}catch{te([])}else te([])},100);return()=>{clearTimeout(Ee)}},[]);const Y=h==="dark",se=je(()=>{const Ee=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",I?"opacity-100":"opacity-0",I?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...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"),oe=je(()=>{const Ne=v?.insets?.top?Math.max(16,v.insets.top+8):16,Ae=v?.insets?.right?Math.max(16,v.insets.right+8):16,We=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,ft=v?.insets?.left?Math.max(16,v.insets.left+8):16,at={};switch(n){case"top-left":at.top=`${Ne}px`,at.left=`${ft}px`;break;case"top-center":at.top=`${Ne}px`;break;case"top-right":at.top=`${Ne}px`,at.right=`${Ae}px`;break;case"center-left":at.left=`${ft}px`;break;case"center-right":at.right=`${Ae}px`;break;case"bottom-left":at.bottom=`${We}px`,at.left=`${ft}px`;break;case"bottom-center":at.bottom=`${We}px`;break;case"bottom-right":at.bottom=`${We}px`,at.right=`${Ae}px`;break;default:at.top=`${Ne}px`,at.right=`${Ae}px`;break}return at},"getPositionOffsetStyles");y.useEffect(()=>{if(!a)return;const Ee=je(()=>O(!0),"handleMouseEnter"),Ne=je(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",Ee),a.addEventListener("mouseleave",Ne),()=>{a.removeEventListener("mouseenter",Ee),a.removeEventListener("mouseleave",Ne)}},[a]),y.useEffect(()=>{if(!M)return;const Ee=je(Ne=>{G.current&&!G.current.contains(Ne.target)&&j(!1)},"handleClickOutside");return document.addEventListener("mousedown",Ee),()=>{document.removeEventListener("mousedown",Ee)}},[M]),y.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const X=je(()=>{j(!M)},"handleToggleOverlay"),J=je(async()=>{try{V("Calling tool...");const Ee=ie.trim()?JSON.parse(ie):{},Ne=await _(q,Ee);V(`Success: ${JSON.stringify(Ne,null,2)}`)}catch(Ee){V(`Error: ${Ee.message}`)}},"handleCallTool"),le=je(async()=>{try{V("Sending follow-up message..."),await k(P),V("Follow-up message sent successfully")}catch(Ee){V(`Error: ${Ee.message}`)}},"handleSendFollowUpMessage"),pe=je(()=>{try{N(U),V(`Opened external link: ${U}`)}catch(Ee){V(`Error: ${Ee.message}`)}},"handleOpenExternal"),me=je(async Ee=>{try{V(`Requesting display mode: ${Ee}...`);const Ne=await C(Ee);V(`Display mode granted: ${Ne.mode}`)}catch(Ne){V(`Error: ${Ne.message}`)}},"handleRequestDisplayMode"),_e=je(async()=>{try{const Ee=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};V("Setting state..."),await A(Ee),V(`State updated: ${JSON.stringify(Ee,null,2)}`)}catch(Ee){V(`Error: ${Ee.message}`)}},"handleSetState"),ze=je(async()=>{try{await C("fullscreen")}catch(Ee){console.error("Failed to go fullscreen:",Ee)}},"handleFullscreen"),ue=je(async()=>{try{await C("pip")}catch(Ee){console.error("Failed to go pip:",Ee)}},"handlePip"),Pe=je(()=>{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"),Ye=je(({onClick:Ee,label:Ne,children:Ae})=>{const[We,ft]=y.useState(!1),at=Pe();return Q.createElement("button",{className:`p-2 ${Y?"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 ${Y?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>ft(!0),onMouseLeave:()=>ft(!1),onClick:Ee,"aria-label":Ne},Q.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"},Ae),r&&Q.createElement("span",{className:`${at.join(" ")} ${We?"opacity-100":"opacity-0"}`},Ne))},"IconButton"),fe=je(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"),De=je(Ee=>Ee?`${Ee.device?.type||"unknown"}`:"N/A","formatUserAgent"),He=je(Ee=>{if(!Ee?.insets)return"N/A";const{top:Ne,bottom:Ae,left:We,right:ft}=Ee.insets;return`T:${Ne} B:${Ae} L:${We} R:${ft}`},"formatSafeArea");return Q.createElement(Q.Fragment,null,Q.createElement("div",{ref:B,className:`${t} relative h-fit`,onMouseEnter:()=>!a&&O(!0),onMouseLeave:()=>!a&&O(!1)},Q.createElement("div",{className:se().join(" "),style:oe()},!K&&Q.createElement(Q.Fragment,null,!$&&!W&&Q.createElement(Q.Fragment,null,(s===!0||s==="fullscreen")&&Q.createElement(Ye,{onClick:ze,label:"Fullscreen"},Q.createElement("path",{d:"M15 3h6v6"}),Q.createElement("path",{d:"m21 3-7 7"}),Q.createElement("path",{d:"m3 21 7-7"}),Q.createElement("path",{d:"M9 21H3v-6"})),(s===!0||s==="pip")&&Q.createElement(Ye,{onClick:ue,label:"Picture in Picture"},Q.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),Q.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&Q.createElement(Ye,{onClick:X,label:"Debug Info"},Q.createElement("path",{d:"M12 20v-9"}),Q.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),Q.createElement("path",{d:"M14.12 3.88 16 2"}),Q.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),Q.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),Q.createElement("path",{d:"M22 13h-4"}),Q.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),Q.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),Q.createElement("path",{d:"M6 13H2"}),Q.createElement("path",{d:"m8 2 1.88 1.88"}),Q.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),M&&i&&Q.createElement("div",{ref:G,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:Ee=>{Ee.target===G.current&&j(!1)}},Q.createElement("button",{onClick:()=>j(!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"},"×"),Q.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},Q.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),Q.createElement("table",{className:"w-full border-collapse border-spacing-0"},Q.createElement("tbody",null,Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),Q.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(c))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),Q.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(u))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),Q.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(f))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),Q.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(m))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),Q.createElement("td",{className:"p-2"},h)),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),Q.createElement("td",{className:"p-2"},g)),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),Q.createElement("td",{className:"p-2"},w)),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),Q.createElement("td",{className:"p-2"},E,"px")),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),Q.createElement("td",{className:"p-2"},De(x))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),Q.createElement("td",{className:"p-2"},He(v))),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),Q.createElement("td",{className:"p-2"},S?"Yes":"No")),Q.createElement("tr",{className:"border-b border-gray-700"},Q.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),Q.createElement("td",{className:"p-2"},ee.length>0?ee.join(", "):"N/A")))),Q.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),Q.createElement("div",{className:"flex flex-col gap-3"},Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("input",{type:"text",value:q,onChange:Ee=>H(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]"}),Q.createElement("input",{type:"text",value:ie,onChange:Ee=>re(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"}),Q.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")),Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("input",{type:"text",value:P,onChange:Ee=>F(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"}),Q.createElement("button",{onClick:le,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")),Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("input",{type:"text",value:U,onChange:Ee=>L(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"}),Q.createElement("button",{onClick:pe,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),Q.createElement("button",{onClick:()=>me("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"),Q.createElement("button",{onClick:()=>me("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"),Q.createElement("button",{onClick:()=>me("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")),Q.createElement("div",{className:"flex gap-2 items-center"},Q.createElement("button",{onClick:_e,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Set State (Add Timestamp)")),ae&&Q.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"},Q.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ae,Q.createElement("button",{onClick:()=>V(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}je(f9,"WidgetControls");function p9(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}je(p9,"getBasename");var Woe=150,Koe=5;function Zoe({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=p9(),i=y.useRef(null),s=y.useRef(0),c=y.useRef(null),u=y.useRef(!1),[f,m]=y.useState(null),[h,g]=y.useState(null),[v,E]=y.useState(!0);y.useEffect(()=>{let _=!0;return(async()=>{try{const k=await Mr(()=>import("./index-DIa0UgbZ.js"),[]);_&&(m(()=>k.BrowserRouter),E(!1))}catch{_&&(g(new Error(`❌ react-router not installed!
|
|
47
47
|
|
|
48
48
|
To use MCP widgets with McpUseProvider, you need to install:
|
|
49
49
|
|
|
@@ -101,7 +101,7 @@ Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}
|
|
|
101
101
|
`)},Jz=function(){var e=parseInt(document.body.getAttribute(Eu)||"0",10);return isFinite(e)?e:0},nfe=function(){y.useEffect(function(){return document.body.setAttribute(Eu,(Jz()+1).toString()),function(){var e=Jz()-1;e<=0?document.body.removeAttribute(Eu):document.body.setAttribute(Eu,e.toString())}},[])},rfe=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,r=a===void 0?"margin":a;nfe();var i=y.useMemo(function(){return Qde(r)},[r]);return y.createElement(efe,{styles:tfe(i,!t,r,n?"":"!important")})},qE=!1;if(typeof window<"u")try{var cb=Object.defineProperty({},"passive",{get:function(){return qE=!0,!0}});window.addEventListener("test",cb,cb),window.removeEventListener("test",cb,cb)}catch{qE=!1}var Yc=qE?{passive:!1}:!1,afe=function(e){return e.tagName==="TEXTAREA"},j8=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!afe(e)&&n[t]==="visible")},ife=function(e){return j8(e,"overflowY")},ofe=function(e){return j8(e,"overflowX")},Qz=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var r=L8(e,a);if(r){var i=$8(e,a),s=i[1],c=i[2];if(s>c)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},sfe=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},lfe=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},L8=function(e,t){return e==="v"?ife(t):ofe(t)},$8=function(e,t){return e==="v"?sfe(t):lfe(t)},cfe=function(e,t){return e==="h"&&t==="rtl"?-1:1},ufe=function(e,t,n,a,r){var i=cfe(e,window.getComputedStyle(t).direction),s=i*a,c=n.target,u=t.contains(c),f=!1,m=s>0,h=0,g=0;do{if(!c)break;var v=$8(e,c),E=v[0],x=v[1],w=v[2],S=x-w-i*E;(E||S)&&L8(e,c)&&(h+=S,g+=E);var _=c.parentNode;c=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(m&&Math.abs(h)<1||!m&&Math.abs(g)<1)&&(f=!0),f},ub=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},eU=function(e){return[e.deltaX,e.deltaY]},tU=function(e){return e&&"current"in e?e.current:e},dfe=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ffe=function(e){return`
|
|
102
102
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
103
103
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
104
|
-
`)},pfe=0,qc=[];function mfe(e){var t=y.useRef([]),n=y.useRef([0,0]),a=y.useRef(),r=y.useState(pfe++)[0],i=y.useState(D8)[0],s=y.useRef(e);y.useEffect(function(){s.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var x=Lde([e.lockRef.current],(e.shards||[]).map(tU),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=y.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!s.current.allowPinchZoom;var S=ub(x),_=n.current,k="deltaX"in x?x.deltaX:_[0]-S[0],N="deltaY"in x?x.deltaY:_[1]-S[1],C,A=x.target,I=Math.abs(k)>Math.abs(N)?"h":"v";if("touches"in x&&I==="h"&&A.type==="range")return!1;var O=window.getSelection(),M=O&&O.anchorNode,j=M?M===A||M.contains(A):!1;if(j)return!1;var B=Qz(I,A);if(!B)return!0;if(B?C=I:(C=I==="v"?"h":"v",B=Qz(I,A)),!B)return!1;if(!a.current&&"changedTouches"in x&&(k||N)&&(a.current=C),!C)return!0;var G=a.current||C;return ufe(G,w,x,G==="h"?k:N)},[]),u=y.useCallback(function(x){var w=x;if(!(!qc.length||qc[qc.length-1]!==i)){var S="deltaY"in w?eU(w):ub(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&dfe(C.delta,S)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var k=(s.current.shards||[]).map(tU).filter(Boolean).filter(function(C){return C.contains(w.target)}),N=k.length>0?c(w,k[0]):!s.current.noIsolation;N&&w.cancelable&&w.preventDefault()}}},[]),f=y.useCallback(function(x,w,S,_){var k={name:x,delta:w,target:S,should:_,shadowParent:hfe(S)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(N){return N!==k})},1)},[]),m=y.useCallback(function(x){n.current=ub(x),a.current=void 0},[]),h=y.useCallback(function(x){f(x.type,eU(x),x.target,c(x,e.lockRef.current))},[]),g=y.useCallback(function(x){f(x.type,ub(x),x.target,c(x,e.lockRef.current))},[]);y.useEffect(function(){return qc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Yc),document.addEventListener("touchmove",u,Yc),document.addEventListener("touchstart",m,Yc),function(){qc=qc.filter(function(x){return x!==i}),document.removeEventListener("wheel",u,Yc),document.removeEventListener("touchmove",u,Yc),document.removeEventListener("touchstart",m,Yc)}},[]);var v=e.removeScrollBar,E=e.inert;return y.createElement(y.Fragment,null,E?y.createElement(i,{styles:ffe(r)}):null,v?y.createElement(rfe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function hfe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const gfe=Vde(O8,mfe);var Dm=y.forwardRef(function(e,t){return y.createElement(qy,Fi({},e,{ref:t,sideCar:gfe}))});Dm.classNames=qy.classNames;var XE=["Enter"," "],bfe=["ArrowDown","PageUp","Home"],M8=["ArrowUp","PageDown","End"],vfe=[...bfe,...M8],yfe={ltr:[...XE,"ArrowRight"],rtl:[...XE,"ArrowLeft"]},wfe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},jm="Menu",[Mp,xfe,Sfe]=LN(jm),[ac,P8]=Ii(jm,[Sfe,Ys,_8]),Xy=Ys(),z8=_8(),[Efe,ic]=ac(jm),[_fe,Lm]=ac(jm),U8=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=Xy(t),[u,f]=y.useState(null),m=y.useRef(!1),h=Ji(i),g=$N(r);return y.useEffect(()=>{const v=()=>{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",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),d.jsx(Wy,{...c,children:d.jsx(Efe,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:f,children:d.jsx(_fe,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};U8.displayName=jm;var kfe="MenuAnchor",WN=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Xy(n);return d.jsx(Im,{...r,...a,ref:t})});WN.displayName=kfe;var KN="MenuPortal",[Tfe,F8]=ac(KN,{forceMount:void 0}),B8=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=ic(KN,t);return d.jsx(Tfe,{scope:t,forceMount:n,children:d.jsx(za,{present:n||i.open,children:d.jsx($d,{asChild:!0,container:r,children:a})})})};B8.displayName=KN;var Qa="MenuContent",[Nfe,ZN]=ac(Qa),H8=y.forwardRef((e,t)=>{const n=F8(Qa,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ic(Qa,e.__scopeMenu),s=Lm(Qa,e.__scopeMenu);return d.jsx(Mp.Provider,{scope:e.__scopeMenu,children:d.jsx(za,{present:a||i.open,children:d.jsx(Mp.Slot,{scope:e.__scopeMenu,children:s.modal?d.jsx(Cfe,{...r,ref:t}):d.jsx(Rfe,{...r,ref:t})})})})}),Cfe=y.forwardRef((e,t)=>{const n=ic(Qa,e.__scopeMenu),a=y.useRef(null),r=tn(t,a);return y.useEffect(()=>{const i=a.current;if(i)return Yy(i)},[]),d.jsx(YN,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ke(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Rfe=y.forwardRef((e,t)=>{const n=ic(Qa,e.__scopeMenu);return d.jsx(YN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Afe=Gl("MenuContent.ScrollLock"),YN=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:E,...x}=e,w=ic(Qa,n),S=Lm(Qa,n),_=Xy(n),k=z8(n),N=xfe(n),[C,A]=y.useState(null),I=y.useRef(null),O=tn(t,I,w.onContentChange),M=y.useRef(0),j=y.useRef(""),B=y.useRef(0),G=y.useRef(null),ee=y.useRef("right"),te=y.useRef(0),ae=E?Dm:y.Fragment,V=E?{as:Afe,allowPinchZoom:!0}:void 0,q=ie=>{const re=j.current+ie,P=N().filter(K=>!K.disabled),F=document.activeElement,U=P.find(K=>K.ref.current===F)?.textValue,L=P.map(K=>K.textValue),$=Bfe(L,re,U),W=P.find(K=>K.textValue===$)?.ref.current;(function K(Y){j.current=Y,window.clearTimeout(M.current),Y!==""&&(M.current=window.setTimeout(()=>K(""),1e3))})(re),W&&setTimeout(()=>W.focus())};y.useEffect(()=>()=>window.clearTimeout(M.current),[]),Fy();const H=y.useCallback(ie=>ee.current===G.current?.side&&Vfe(ie,G.current?.area),[]);return d.jsx(Nfe,{scope:n,searchRef:j,onItemEnter:y.useCallback(ie=>{H(ie)&&ie.preventDefault()},[H]),onItemLeave:y.useCallback(ie=>{H(ie)||(I.current?.focus(),A(null))},[H]),onTriggerLeave:y.useCallback(ie=>{H(ie)&&ie.preventDefault()},[H]),pointerGraceTimerRef:B,onPointerGraceIntentChange:y.useCallback(ie=>{G.current=ie},[]),children:d.jsx(ae,{...V,children:d.jsx(Rm,{asChild:!0,trapped:r,onMountAutoFocus:Ke(i,ie=>{ie.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:d.jsx(Dd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:d.jsx(Ade,{asChild:!0,...k,dir:S.dir,orientation:"vertical",loop:a,currentTabStopId:C,onCurrentTabStopIdChange:A,onEntryFocus:Ke(u,ie=>{S.isUsingKeyboardRef.current||ie.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(Ky,{role:"menu","aria-orientation":"vertical","data-state":iG(w.open),"data-radix-menu-content":"",dir:S.dir,..._,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:Ke(x.onKeyDown,ie=>{const P=ie.target.closest("[data-radix-menu-content]")===ie.currentTarget,F=ie.ctrlKey||ie.altKey||ie.metaKey,U=ie.key.length===1;P&&(ie.key==="Tab"&&ie.preventDefault(),!F&&U&&q(ie.key));const L=I.current;if(ie.target!==L||!vfe.includes(ie.key))return;ie.preventDefault();const W=N().filter(K=>!K.disabled).map(K=>K.ref.current);M8.includes(ie.key)&&W.reverse(),Ufe(W)}),onBlur:Ke(e.onBlur,ie=>{ie.currentTarget.contains(ie.target)||(window.clearTimeout(M.current),j.current="")}),onPointerMove:Ke(e.onPointerMove,Pp(ie=>{const re=ie.target,P=te.current!==ie.clientX;if(ie.currentTarget.contains(re)&&P){const F=ie.clientX>te.current?"right":"left";ee.current=F,te.current=ie.clientX}}))})})})})})})});H8.displayName=Qa;var Ife="MenuGroup",qN=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Ot.div,{role:"group",...a,ref:t})});qN.displayName=Ife;var Ofe="MenuLabel",V8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Ot.div,{...a,ref:t})});V8.displayName=Ofe;var Cv="MenuItem",nU="menu.itemSelect",Jy=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=y.useRef(null),s=Lm(Cv,e.__scopeMenu),c=ZN(Cv,e.__scopeMenu),u=tn(t,i),f=y.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(nU,{bubbles:!0,cancelable:!0});h.addEventListener(nU,v=>a?.(v),{once:!0}),J9(h,g),g.defaultPrevented?f.current=!1:s.onClose()}};return d.jsx(G8,{...r,ref:u,disabled:n,onClick:Ke(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:Ke(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:Ke(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||XE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Jy.displayName=Cv;var G8=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=ZN(Cv,n),c=z8(n),u=y.useRef(null),f=tn(t,u),[m,h]=y.useState(!1),[g,v]=y.useState("");return y.useEffect(()=>{const E=u.current;E&&v((E.textContent??"").trim())},[i.children]),d.jsx(Mp.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:d.jsx(Ide,{asChild:!0,...c,focusable:!a,children:d.jsx(Ot.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:f,onPointerMove:Ke(e.onPointerMove,Pp(E=>{a?s.onItemLeave(E):(s.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ke(e.onPointerLeave,Pp(E=>s.onItemLeave(E))),onFocus:Ke(e.onFocus,()=>h(!0)),onBlur:Ke(e.onBlur,()=>h(!1))})})})}),Dfe="MenuCheckboxItem",W8=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return d.jsx(X8,{scope:e.__scopeMenu,checked:n,children:d.jsx(Jy,{role:"menuitemcheckbox","aria-checked":Rv(n)?"mixed":n,...r,ref:t,"data-state":JN(n),onSelect:Ke(r.onSelect,()=>a?.(Rv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});W8.displayName=Dfe;var K8="MenuRadioGroup",[jfe,Lfe]=ac(K8,{value:void 0,onValueChange:()=>{}}),Z8=y.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Ji(a);return d.jsx(jfe,{scope:e.__scopeMenu,value:n,onValueChange:i,children:d.jsx(qN,{...r,ref:t})})});Z8.displayName=K8;var Y8="MenuRadioItem",q8=y.forwardRef((e,t)=>{const{value:n,...a}=e,r=Lfe(Y8,e.__scopeMenu),i=n===r.value;return d.jsx(X8,{scope:e.__scopeMenu,checked:i,children:d.jsx(Jy,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":JN(i),onSelect:Ke(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});q8.displayName=Y8;var XN="MenuItemIndicator",[X8,$fe]=ac(XN,{checked:!1}),J8=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=$fe(XN,n);return d.jsx(za,{present:a||Rv(i.checked)||i.checked===!0,children:d.jsx(Ot.span,{...r,ref:t,"data-state":JN(i.checked)})})});J8.displayName=XN;var Mfe="MenuSeparator",Q8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Ot.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});Q8.displayName=Mfe;var Pfe="MenuArrow",eG=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Xy(n);return d.jsx(Zy,{...r,...a,ref:t})});eG.displayName=Pfe;var zfe="MenuSub",[dNe,tG]=ac(zfe),np="MenuSubTrigger",nG=y.forwardRef((e,t)=>{const n=ic(np,e.__scopeMenu),a=Lm(np,e.__scopeMenu),r=tG(np,e.__scopeMenu),i=ZN(np,e.__scopeMenu),s=y.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=i,f={__scopeMenu:e.__scopeMenu},m=y.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return y.useEffect(()=>m,[m]),y.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),u(null)}},[c,u]),d.jsx(WN,{asChild:!0,...f,children:d.jsx(G8,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":iG(n.open),...e,ref:Xi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ke(e.onPointerMove,Pp(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Ke(e.onPointerLeave,Pp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,E=v==="right",x=E?-5:5,w=g[E?"left":"right"],S=g[E?"right":"left"];i.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:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ke(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||yfe[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});nG.displayName=np;var rG="MenuSubContent",aG=y.forwardRef((e,t)=>{const n=F8(Qa,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ic(Qa,e.__scopeMenu),s=Lm(Qa,e.__scopeMenu),c=tG(rG,e.__scopeMenu),u=y.useRef(null),f=tn(t,u);return d.jsx(Mp.Provider,{scope:e.__scopeMenu,children:d.jsx(za,{present:a||i.open,children:d.jsx(Mp.Slot,{scope:e.__scopeMenu,children:d.jsx(YN,{id:c.contentId,"aria-labelledby":c.triggerId,...r,ref:f,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{s.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Ke(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ke(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ke(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=wfe[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});aG.displayName=rG;function iG(e){return e?"open":"closed"}function Rv(e){return e==="indeterminate"}function JN(e){return Rv(e)?"indeterminate":e?"checked":"unchecked"}function Ufe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ffe(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Bfe(e,t,n){const r=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Ffe(e,Math.max(i,0));r.length===1&&(s=s.filter(f=>f!==n));const u=s.find(f=>f.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function Hfe(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],f=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-f)*(a-m)/(g-m)+f&&(r=!r)}return r}function Vfe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Hfe(n,t)}function Pp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Gfe=U8,Wfe=WN,Kfe=B8,Zfe=H8,Yfe=qN,qfe=V8,Xfe=Jy,Jfe=W8,Qfe=Z8,epe=q8,tpe=J8,npe=Q8,rpe=eG,ape=nG,ipe=aG,Qy="DropdownMenu",[ope]=Ii(Qy,[P8]),ca=P8(),[spe,oG]=ope(Qy),sG=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ca(t),f=y.useRef(null),[m,h]=Lo({prop:r,defaultProp:i??!1,onChange:s,caller:Qy});return d.jsx(spe,{scope:t,triggerId:zr(),triggerRef:f,contentId:zr(),open:m,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:c,children:d.jsx(Gfe,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};sG.displayName=Qy;var lG="DropdownMenuTrigger",cG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=oG(lG,n),s=ca(n);return d.jsx(Wfe,{asChild:!0,...s,children:d.jsx(Ot.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...r,ref:Xi(t,i.triggerRef),onPointerDown:Ke(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ke(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});cG.displayName=lG;var lpe="DropdownMenuPortal",uG=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ca(t);return d.jsx(Kfe,{...a,...n})};uG.displayName=lpe;var dG="DropdownMenuContent",fG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=oG(dG,n),i=ca(n),s=y.useRef(!1);return d.jsx(Zfe,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ke(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ke(e.onInteractOutside,c=>{const u=c.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;(!r.modal||m)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});fG.displayName=dG;var cpe="DropdownMenuGroup",upe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Yfe,{...r,...a,ref:t})});upe.displayName=cpe;var dpe="DropdownMenuLabel",pG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(qfe,{...r,...a,ref:t})});pG.displayName=dpe;var fpe="DropdownMenuItem",mG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Xfe,{...r,...a,ref:t})});mG.displayName=fpe;var ppe="DropdownMenuCheckboxItem",hG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Jfe,{...r,...a,ref:t})});hG.displayName=ppe;var mpe="DropdownMenuRadioGroup",hpe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Qfe,{...r,...a,ref:t})});hpe.displayName=mpe;var gpe="DropdownMenuRadioItem",gG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(epe,{...r,...a,ref:t})});gG.displayName=gpe;var bpe="DropdownMenuItemIndicator",vpe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(tpe,{...r,...a,ref:t})});vpe.displayName=bpe;var ype="DropdownMenuSeparator",bG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(npe,{...r,...a,ref:t})});bG.displayName=ype;var wpe="DropdownMenuArrow",xpe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(rpe,{...r,...a,ref:t})});xpe.displayName=wpe;var Spe="DropdownMenuSubTrigger",vG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(ape,{...r,...a,ref:t})});vG.displayName=Spe;var Epe="DropdownMenuSubContent",yG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(ipe,{...r,...a,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});yG.displayName=Epe;var _pe=sG,kpe=cG,Tpe=uG,wG=fG,xG=pG,SG=mG,Npe=hG,Cpe=gG,EG=bG,Rpe=vG,Ape=yG;const Av=_pe,Iv=kpe;Rpe.displayName;Ape.displayName;function zp({ref:e,className:t,sideOffset:n=4,...a}){return d.jsx(Tpe,{children:d.jsx(wG,{ref:e,sideOffset:n,className:Me("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})})}zp.displayName=wG.displayName;function ia({ref:e,className:t,inset:n,...a}){return d.jsx(SG,{ref:e,className:Me("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...a})}ia.displayName=SG.displayName;Npe.displayName;Cpe.displayName;function JE({ref:e,className:t,inset:n,...a}){return d.jsx(xG,{ref:e,className:Me("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}JE.displayName=xG.displayName;function rp({ref:e,className:t,...n}){return d.jsx(EG,{ref:e,className:Me("-mx-1 my-1 h-px bg-muted",t),...n})}rp.displayName=EG.displayName;var Ipe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Vo=Ipe.reduce((e,t)=>{const n=D9(`Primitive.${t}`),a=y.forwardRef((r,i)=>{const{asChild:s,...c}=r,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),Ope="Label",_G=y.forwardRef((e,t)=>d.jsx(Vo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));_G.displayName=Ope;var Dpe=_G;function Xt({className:e,...t}){return d.jsx(Dpe,{"data-slot":"label",className:Me("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function Md({message:e,className:t="",vertical:n,noBorder:a}){return d.jsx("div",{className:Me(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:d.jsxs("p",{className:Me("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 kG({className:e,color:t,children:n,grayscaled:a=!1}){const r=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return a?0:.2},[t,a]),i=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return a?.3:.4},[t,a]),s=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[2]||"0")}return Math.floor(Math.random()*360)},[t]),c=y.useMemo(()=>t||`oklch(${Math.min(i,1)} ${r} ${s})`,[s,r,i]),u=y.useMemo(()=>`oklch(${Math.min(i*2,1)} ${r} ${s})`,[s,r,i,t]),f=y.useMemo(()=>Math.floor(Math.random()*360),[s]),m=y.useMemo(()=>"1000%",[]);return d.jsx("section",{className:Me("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, ${c}, 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})]})})}function QN(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var e0="Switch",[jpe]=Ii(e0),[Lpe,$pe]=jpe(e0),TG=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:f,form:m,...h}=e,[g,v]=y.useState(null),E=tn(t,k=>v(k)),x=y.useRef(!1),w=g?m||!!g.closest("form"):!0,[S,_]=Lo({prop:r,defaultProp:i??!1,onChange:f,caller:e0});return d.jsxs(Lpe,{scope:n,checked:S,disabled:c,children:[d.jsx(Ot.button,{type:"button",role:"switch","aria-checked":S,"aria-required":s,"data-state":AG(S),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:E,onClick:Ke(e.onClick,k=>{_(N=>!N),w&&(x.current=k.isPropagationStopped(),x.current||k.stopPropagation())})}),w&&d.jsx(RG,{control:g,bubbles:!x.current,name:a,value:u,checked:S,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});TG.displayName=e0;var NG="SwitchThumb",CG=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=$pe(NG,n);return d.jsx(Ot.span,{"data-state":AG(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});CG.displayName=NG;var Mpe="SwitchBubbleInput",RG=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=y.useRef(null),c=tn(s,i),u=QN(n),f=HN(t);return y.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const E=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(E)}},[u,n,a]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:c,style:{...r.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});RG.displayName=Mpe;function AG(e){return e?"checked":"unchecked"}var IG=TG,Ppe=CG;function t0({ref:e,className:t,...n}){return d.jsx(IG,{className:Me("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:d.jsx(Ppe,{className:Me("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})}t0.displayName=IG.displayName;var OG=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"}),zpe="VisuallyHidden",DG=y.forwardRef((e,t)=>d.jsx(Ot.span,{...e,ref:t,style:{...OG,...e.style}}));DG.displayName=zpe;var Upe=DG,[n0]=Ii("Tooltip",[Ys]),r0=Ys(),jG="TooltipProvider",Fpe=700,QE="tooltip.open",[Bpe,eC]=n0(jG),LG=e=>{const{__scopeTooltip:t,delayDuration:n=Fpe,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,s=y.useRef(!0),c=y.useRef(!1),u=y.useRef(0);return y.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),d.jsx(Bpe,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,a)},[a]),isPointerInTransitRef:c,onPointerInTransitChange:y.useCallback(f=>{c.current=f},[]),disableHoverableContent:r,children:i})};LG.displayName=jG;var Up="Tooltip",[Hpe,$m]=n0(Up),$G=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=eC(Up,e.__scopeTooltip),f=r0(t),[m,h]=y.useState(null),g=zr(),v=y.useRef(0),E=s??u.disableHoverableContent,x=c??u.delayDuration,w=y.useRef(!1),[S,_]=Lo({prop:a,defaultProp:r??!1,onChange:I=>{I?(u.onOpen(),document.dispatchEvent(new CustomEvent(QE))):u.onClose(),i?.(I)},caller:Up}),k=y.useMemo(()=>S?w.current?"delayed-open":"instant-open":"closed",[S]),N=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w.current=!1,_(!0)},[_]),C=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_(!1)},[_]),A=y.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{w.current=!0,_(!0),v.current=0},x)},[x,_]);return y.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),d.jsx(Wy,{...f,children:d.jsx(Hpe,{scope:t,contentId:g,open:S,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{u.isOpenDelayedRef.current?A():N()},[u.isOpenDelayedRef,A,N]),onTriggerLeave:y.useCallback(()=>{E?C():(window.clearTimeout(v.current),v.current=0)},[C,E]),onOpen:N,onClose:C,disableHoverableContent:E,children:n})})};$G.displayName=Up;var e_="TooltipTrigger",MG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=$m(e_,n),i=eC(e_,n),s=r0(n),c=y.useRef(null),u=tn(t,c,r.onTriggerChange),f=y.useRef(!1),m=y.useRef(!1),h=y.useCallback(()=>f.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),d.jsx(Im,{asChild:!0,...s,children:d.jsx(Ot.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ke(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ke(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ke(e.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ke(e.onFocus,()=>{f.current||r.onOpen()}),onBlur:Ke(e.onBlur,r.onClose),onClick:Ke(e.onClick,r.onClose)})})});MG.displayName=e_;var tC="TooltipPortal",[Vpe,Gpe]=n0(tC,{forceMount:void 0}),PG=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=$m(tC,t);return d.jsx(Vpe,{scope:t,forceMount:n,children:d.jsx(za,{present:n||i.open,children:d.jsx($d,{asChild:!0,container:r,children:a})})})};PG.displayName=tC;var fd="TooltipContent",zG=y.forwardRef((e,t)=>{const n=Gpe(fd,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=$m(fd,e.__scopeTooltip);return d.jsx(za,{present:a||s.open,children:s.disableHoverableContent?d.jsx(UG,{side:r,...i,ref:t}):d.jsx(Wpe,{side:r,...i,ref:t})})}),Wpe=y.forwardRef((e,t)=>{const n=$m(fd,e.__scopeTooltip),a=eC(fd,e.__scopeTooltip),r=y.useRef(null),i=tn(t,r),[s,c]=y.useState(null),{trigger:u,onClose:f}=n,m=r.current,{onPointerInTransitChange:h}=a,g=y.useCallback(()=>{c(null),h(!1)},[h]),v=y.useCallback((E,x)=>{const w=E.currentTarget,S={x:E.clientX,y:E.clientY},_=qpe(S,w.getBoundingClientRect()),k=Xpe(S,_),N=Jpe(x.getBoundingClientRect()),C=eme([...k,...N]);c(C),h(!0)},[h]);return y.useEffect(()=>()=>g(),[g]),y.useEffect(()=>{if(u&&m){const E=w=>v(w,m),x=w=>v(w,u);return u.addEventListener("pointerleave",E),m.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",E),m.removeEventListener("pointerleave",x)}}},[u,m,v,g]),y.useEffect(()=>{if(s){const E=x=>{const w=x.target,S={x:x.clientX,y:x.clientY},_=u?.contains(w)||m?.contains(w),k=!Qpe(S,s);_?g():k&&(g(),f())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[u,m,s,f,g]),d.jsx(UG,{...e,ref:i})}),[Kpe,Zpe]=n0(Up,{isInside:!1}),Ype=Rce("TooltipContent"),UG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=$m(fd,n),f=r0(n),{onClose:m}=u;return y.useEffect(()=>(document.addEventListener(QE,m),()=>document.removeEventListener(QE,m)),[m]),y.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(Dd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:d.jsxs(Ky,{"data-state":u.stateAttribute,...f,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[d.jsx(Ype,{children:a}),d.jsx(Kpe,{scope:n,isInside:!0,children:d.jsx(Upe,{id:u.contentId,role:"tooltip",children:r||a})})]})})});zG.displayName=fd;var FG="TooltipArrow",BG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=r0(n);return Zpe(FG,n).isInside?null:d.jsx(Zy,{...r,...a,ref:t})});BG.displayName=FG;function qpe(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,a,r,i)){case i:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Xpe(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function Jpe(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Qpe(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],f=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-f)*(a-m)/(g-m)+f&&(r=!r)}return r}function eme(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),tme(t)}function tme(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var nme=LG,rme=$G,ame=MG,ime=PG,ome=zG,sme=BG;function nC({delayDuration:e=0,...t}){return d.jsx(nme,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Rt({...e}){return d.jsx(nC,{children:d.jsx(rme,{"data-slot":"tooltip",...e})})}function At({...e}){return d.jsx(ame,{"data-slot":"tooltip-trigger",...e})}function It({className:e,sideOffset:t=0,children:n,...a}){return d.jsx(ime,{children:d.jsxs(ome,{"data-slot":"tooltip-content",sideOffset:t,className:Me("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...a,children:[n,d.jsx(sme,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function lme({requestId:e,serverName:t,mode:n,message:a,url:r,onViewDetails:i,onOpenUrl:s,onCancel:c}){return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Elicitation Request Received"}),d.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",a]}),n==="url"&&r&&d.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:r})]}),d.jsxs("div",{className:"flex gap-2 flex-wrap",children:[d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),i()},children:"View Details"}),n==="url"&&s&&d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),s()},children:"Open URL"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),c()},children:"Cancel"})]})]})}const cme={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function ume({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){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:i=>{i.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:i=>{i.stopPropagation(),a(cme)},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:i=>{i.stopPropagation(),r()},children:"Deny"})]})]})}class dme{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class rU{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 aU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class iU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class oU{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 fme{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 pme{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class mme{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class hme{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function CS(){try{return"0.14.0-canary.1"}catch{return"0.0.0"}}var gme={};function RS(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class sU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(a),!r.ok)throw new Error(`HTTP error! status: ${r.status}`)}catch{}}}function vs(e){return`mcp_inspector_telemetry_${e}`}class _r{static instance=null;POSTHOG_PROXY_URL="/inspector/api/tel/posthog";SCARF_PROXY_URL="/inspector/api/tel/scarf";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogClient=null;_scarfClient=null;_source="inspector";constructor(){const t=RS(),n=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||"inspector",n)this._posthogClient=null,this._scarfClient=null;else if(!t)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new sU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new sU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(vs("disabled"))==="true"||typeof process<"u"&&gme?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(vs("source")):null}static getInstance(){return _r.instance||(_r.instance=new _r),_r.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(vs("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!RS())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(vs("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(vs("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 a=Array.from(n).map(r=>r.toString(16).padStart(2,"0")).join("");return a.slice(0,8)+"-"+a.slice(8,12)+"-"+a.slice(12,16)+"-"+a.slice(16,20)+"-"+a.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const a=Math.random()*16|0;return(n==="x"?a:a&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:CS(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=CS(),n.user_id=this.userId,n.event=t.name,n.language="typescript",n.source=this._source,n.package="inspector",await this._scarfClient.logEvent(n)}catch{}}}async trackPackageDownload(t){if(this._scarfClient&&RS())try{const n=CS();let a=!1,r=!1;const i=localStorage.getItem(vs("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(vs("download_version"),n)):(a=!0,r=!0,localStorage.setItem(vs("download_version"),n)),a){const s={...t||{}};s.mcp_use_version=n,s.user_id=this.userId,s.event="package_download",s.first_download=r,s.language="typescript",s.source=this._source,s.package="inspector",await this._scarfClient.logEvent(s)}}catch{}}async trackInspectorOpen(t){const n=new dme(t);await this.capture(n)}}const db=()=>{},fb=()=>{},pb=()=>{},mb=()=>{},HG=y.createContext(null);function rC(){const e=y.use(HG);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function bme({url:e,name:t,proxyConfig:n,transportType:a,connectionId:r,onUpdate:i,onRemove:s,embedded:c}){const u=c?"mcp-embedded:auth":"mcp:auth",f=`${u}:${e}`,m=(()=>{if(typeof window>"u"||c)return!1;try{return localStorage.getItem(f)!==null}catch{return!1}})(),h=typeof window<"u"?new URL("/inspector/oauth/callback",window.location.origin).toString():"/inspector/oauth/callback",{url:g,headers:v}=fk(e,n),[E,x]=y.useState([]),w=y.useRef(0),[S,_]=y.useState([]),k=y.useRef(0),N=y.useMemo(()=>E.map(Y=>({id:Y.id,request:Y.request,timestamp:Y.timestamp,serverName:Y.serverName})),[E]),C=y.useMemo(()=>S.map(Y=>({id:Y.id,request:Y.request,timestamp:Y.timestamp,serverName:Y.serverName})),[S]),A=y.useRef(null),[I,O]=y.useState(!1),M=y.useRef(!1);y.useEffect(()=>{typeof window<"u"&&!M.current&&(M.current=!0,Mr(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(Y=>{A.current=Y.wrapTransportForLogging,O(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(Y=>{console.error("[McpContext] Failed to load transport wrapper:",Y)}))},[]);const j=y.useMemo(()=>{if(!(!I||!A.current))return(Y,se)=>{const oe=r;return console.log("[McpContext] Applying transport wrapper, serverId:",oe,"from connector:",se),A.current(Y,oe)}},[I,r]),B=`mcp-inspector-notifications-${r}`,G=500,[ee,te]=y.useState([]);y.useEffect(()=>{try{const Y=localStorage.getItem(B);if(Y){const se=JSON.parse(Y);Array.isArray(se)&&te(se)}}catch(Y){console.error("Failed to load notifications from localStorage:",Y)}},[B]),y.useEffect(()=>{try{localStorage.setItem(B,JSON.stringify(ee))}catch(Y){console.error("Failed to save notifications to localStorage:",Y)}},[ee,B]);const ae=y.useCallback(Y=>{te(se=>se.map(oe=>oe.id===Y?{...oe,read:!0}:oe))},[]),V=y.useCallback(()=>{te(Y=>Y.map(se=>({...se,read:!0})))},[]),q=y.useCallback(()=>{te([])},[]),H=y.useCallback(Y=>{te(se=>{const oe=[Y,...se];return oe.length>G?oe.slice(0,G):oe})},[]),ie=y.useCallback((Y,se)=>{x(oe=>{const X=oe.find(J=>J.id===Y);return X?(X.resolve(se),oe.filter(J=>J.id!==Y)):oe})},[]),re=y.useCallback((Y,se)=>{x(oe=>{const X=oe.find(J=>J.id===Y);return X?(X.reject(new Error(se||"User rejected sampling request")),oe.filter(J=>J.id!==Y)):oe})},[]),P=y.useCallback((Y,se)=>{_(oe=>{const X=oe.find(J=>J.id===Y);return X?(X.resolve(se),oe.filter(J=>J.id!==Y)):oe})},[]),F=y.useCallback((Y,se)=>{_(oe=>{const X=oe.find(J=>J.id===Y);return X?(X.reject(new Error(se||"User rejected elicitation request")),oe.filter(J=>J.id!==Y)):oe})},[]),U=y.useCallback(async Y=>new Promise((se,oe)=>{const X=`sampling-${w.current++}`,J={id:X,request:{method:"sampling/createMessage",params:Y},timestamp:Date.now(),serverName:t,resolve:se,reject:oe};x(le=>[...le,J]),typeof window<"u"&&Mr(async()=>{const{toast:le}=await Promise.resolve().then(()=>mU);return{toast:le}},void 0).then(({toast:le})=>{const pe=le(d.jsx(ume,{requestId:X,serverName:t,onViewDetails:()=>{const me=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:X}});window.dispatchEvent(me),le.dismiss(pe)},onApprove:me=>{x(_e=>{const ze=_e.find(ue=>ue.id===X);return ze?(ze.resolve(me),le.success("Sampling request approved"),_e.filter(ue=>ue.id!==X)):_e}),le.dismiss(pe)},onDeny:()=>{x(me=>{const _e=me.find(ze=>ze.id===X);return _e?(_e.reject(new Error("User denied sampling request from toast")),le.error("Sampling request denied"),me.filter(ze=>ze.id!==X)):me}),le.dismiss(pe)}}),{duration:5e3})})}),[t]),L=y.useCallback(async Y=>new Promise((se,oe)=>{const X=`elicitation-${k.current++}`,J={id:X,request:Y,timestamp:Date.now(),serverName:t,resolve:se,reject:oe};_(le=>[...le,J]),typeof window<"u"&&Mr(async()=>{const{toast:le}=await Promise.resolve().then(()=>mU);return{toast:le}},void 0).then(({toast:le})=>{const pe=le(d.jsx(lme,{requestId:X,serverName:t,mode:Y.mode||"form",message:Y.message,url:Y.mode==="url"?Y.url:void 0,onViewDetails:()=>{const me=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:X}});window.dispatchEvent(me),le.dismiss(pe)},onOpenUrl:Y.mode==="url"?()=>{window.open(Y.url,"_blank"),le.dismiss(pe)}:void 0,onCancel:()=>{_(me=>{const _e=me.find(ze=>ze.id===X);return _e?(_e.reject(new Error("User cancelled elicitation request from toast")),le.error("Elicitation request cancelled"),me.filter(ze=>ze.id!==X)):me}),le.dismiss(pe)}}),{duration:5e3})})}),[t]),$=CN({url:g,callbackUrl:h,timeout:5e3,customHeaders:Object.keys(v).length>0?v:void 0,transportType:a||"http",preventAutoAuth:!m,useRedirectFlow:!0,enabled:I,wrapTransport:j,storageKeyPrefix:u,onNotification:Y=>{H({id:globalThis.crypto.randomUUID(),method:Y.method,params:Y.params,timestamp:Date.now(),read:!1})},samplingCallback:U,onElicitation:L}),W=y.useRef(i),K=y.useRef(null);return y.useEffect(()=>{W.current=i},[i]),y.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{$.state==="ready"&&$.serverInfo&&console.log("[McpContext] Server info available:",$.serverInfo);const Y=ee.filter(X=>!X.read).length,se={id:r,url:e,name:$.serverInfo?.name||t,state:$.state,tools:$.tools,resources:$.resources,prompts:$.prompts,error:$.error??null,authUrl:$.authUrl??null,customHeaders:v,transportType:a,proxyConfig:n,serverInfo:$.serverInfo,capabilities:$.capabilities,notifications:ee,unreadNotificationCount:Y,markNotificationRead:ae,markAllNotificationsRead:V,clearNotifications:q,pendingSamplingRequests:N,approveSampling:ie,rejectSampling:re,pendingElicitationRequests:C,approveElicitation:P,rejectElicitation:F,callTool:$.callTool,readResource:$.readResource,listPrompts:$.listPrompts,getPrompt:$.getPrompt,authenticate:$.authenticate,retry:$.retry,clearStorage:$.clearStorage,disconnect:$.disconnect,client:$.client},oe=K.current;(!oe||oe.state!==se.state||oe.error!==se.error||oe.authUrl!==se.authUrl||oe.name!==se.name||oe.tools.length!==se.tools.length||oe.resources.length!==se.resources.length||oe.prompts.length!==se.prompts.length||oe.serverInfo!==se.serverInfo||oe.capabilities!==se.capabilities||oe.notifications.length!==se.notifications.length||oe.unreadNotificationCount!==se.unreadNotificationCount||oe.pendingSamplingRequests.length!==se.pendingSamplingRequests.length||oe.pendingElicitationRequests.length!==se.pendingElicitationRequests.length||!oe.client)&&(K.current=se,W.current(se))});else{const Y=ee.filter(X=>!X.read).length,se={id:r,url:e,name:$.serverInfo?.name||t,state:$.state,tools:$.tools,resources:$.resources,prompts:$.prompts,error:$.error??null,authUrl:$.authUrl??null,customHeaders:v,transportType:a,proxyConfig:n,serverInfo:$.serverInfo,capabilities:$.capabilities,notifications:ee,unreadNotificationCount:Y,markNotificationRead:ae,markAllNotificationsRead:V,clearNotifications:q,pendingSamplingRequests:N,approveSampling:ie,rejectSampling:re,pendingElicitationRequests:C,approveElicitation:P,rejectElicitation:F,callTool:$.callTool,readResource:$.readResource,listPrompts:$.listPrompts,getPrompt:$.getPrompt,authenticate:$.authenticate,retry:$.retry,clearStorage:$.clearStorage,disconnect:$.disconnect,client:$.client},oe=K.current;(!oe||oe.state!==se.state||oe.error!==se.error||oe.authUrl!==se.authUrl||oe.name!==se.name||oe.tools.length!==se.tools.length||oe.resources.length!==se.resources.length||oe.prompts.length!==se.prompts.length||oe.serverInfo!==se.serverInfo||oe.capabilities!==se.capabilities||oe.notifications.length!==se.notifications.length||oe.unreadNotificationCount!==se.unreadNotificationCount||oe.pendingSamplingRequests.length!==se.pendingSamplingRequests.length||oe.pendingElicitationRequests.length!==se.pendingElicitationRequests.length||!oe.client)&&(K.current=se,W.current(se))}},[e,t,a,n,v,r,$.state,$.tools,$.resources,$.prompts,$.error,$.authUrl,$.serverInfo,$.capabilities,$.client,ee,ae,V,q,$.callTool,$.readResource,$.listPrompts,$.getPrompt,$.authenticate,$.retry,$.clearStorage,E,ie,re,C,P,F]),null}function vme({children:e,embedded:t=!1}){const[n,a]=y.useState([]),[r,i]=y.useState(!1),[s,c]=y.useState(!0),[u,f]=y.useState([]);y.useEffect(()=>{if(t){i(!0);return}try{const S=localStorage.getItem("mcp-inspector-connections");if(S){const k=JSON.parse(S);Array.isArray(k)&&(f(k),a(k.map(N=>({id:N.id||N.url,url:N.url,name:N.name||"MCP Server",state:"discovering",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:N.proxyConfig?.customHeaders,transportType:N.transportType,proxyConfig:N.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:db,rejectSampling:fb,pendingElicitationRequests:[],approveElicitation:pb,rejectElicitation:mb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&c(_==="true")}catch(S){console.error("Failed to load connections from localStorage:",S)}finally{i(!0)}},[t]),y.useEffect(()=>{!r||t||localStorage.setItem("mcp-inspector-connections",JSON.stringify(u))},[u,r,t]),y.useEffect(()=>{!r||t||localStorage.setItem("mcp-inspector-auto-connect",String(s))},[s,r,t]);const m=y.useCallback((S,_,k,N)=>{const C=u.find(O=>O.url===S),A=n.find(O=>O.url===S);if(C&&A){if(JSON.stringify(C.proxyConfig)!==JSON.stringify(k)&&k){f(M=>M.filter(j=>j.url!==S)),a(M=>M.filter(j=>j.url!==S)),setTimeout(()=>{const M={id:S,url:S,name:_||C.name||"MCP Server",proxyConfig:k,transportType:N||C.transportType};f(j=>[...j,M]),a(j=>[...j,{id:S,url:S,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k?.customHeaders,transportType:N||C.transportType,proxyConfig:k,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:db,rejectSampling:fb,pendingElicitationRequests:[],approveElicitation:pb,rejectElicitation:mb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!A){(k||N)&&f(O=>O.map(M=>M.url===S?{...M,proxyConfig:k||M.proxyConfig,transportType:N||M.transportType,name:_||M.name}:M)),a(O=>[...O,{id:C.id||S,url:S,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k?.customHeaders||C.proxyConfig?.customHeaders,transportType:N||C.transportType,proxyConfig:k||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:db,rejectSampling:fb,pendingElicitationRequests:[],approveElicitation:pb,rejectElicitation:mb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const I={id:S,url:S,name:_||"MCP Server",proxyConfig:k,transportType:N};f(O=>[...O,I]),a(O=>[...O,{id:S,url:S,name:_||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k?.customHeaders,transportType:N,proxyConfig:k,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:db,rejectSampling:fb,pendingElicitationRequests:[],approveElicitation:pb,rejectElicitation:mb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[u,n]),h=y.useCallback(S=>{const _=n.find(N=>N.id===S);_&&(console.log(`[McpContext] Cleaning up connection: ${S}`),_.disconnect&&(console.log(`[McpContext] Disconnecting from server: ${S}`),_.disconnect()),_.clearStorage&&(console.log(`[McpContext] Clearing OAuth storage for connection: ${S}`),_.clearStorage())),f(N=>N.filter(C=>C.id!==S)),a(N=>N.filter(C=>C.id!==S));const k=localStorage.getItem("mcp-inspector-connections");if(k)try{const C=JSON.parse(k).filter(A=>(A.id||A.url)!==S);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(N){console.error("Failed to update localStorage on remove:",N)}_r.getInstance().capture(new pme({serverId:S}))},[n]),g=y.useCallback((S,_)=>{f(k=>k.map(N=>N.id===S||N.url===S?{...N,..._}:N)),a(k=>k.map(N=>N.id===S?{...N,..._}:N))},[]),v=y.useCallback(S=>{a(_=>{const k=_.findIndex(A=>A.id===S.id);if(k===-1)return _;const N=_[k];if(N.state===S.state&&N.tools===S.tools&&N.resources===S.resources&&N.prompts===S.prompts&&N.error===S.error&&N.serverInfo===S.serverInfo&&N.client===S.client&&N.notifications===S.notifications&&N.unreadNotificationCount===S.unreadNotificationCount&&N.pendingSamplingRequests.length===S.pendingSamplingRequests.length&&N.pendingElicitationRequests.length===S.pendingElicitationRequests.length)return _;const C=[..._];return C[k]=S,C})},[]),E=y.useCallback(S=>{console.log("Connect requested for:",S)},[]),x=y.useCallback(S=>{console.log("Disconnect requested for:",S)},[]),w=y.useMemo(()=>({connections:n,addConnection:m,removeConnection:h,updateConnectionConfig:g,autoConnect:s,setAutoConnect:c,connectServer:E,disconnectServer:x,configLoaded:r}),[n,m,h,g,s,E,x,r]);return d.jsxs(HG.Provider,{value:w,children:[e,r&&s&&u.map(S=>{const _=`${S.id||S.url}-${S.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",S.proxyConfig),d.jsx(bme,{url:S.url,name:S.name,proxyConfig:S.proxyConfig,transportType:S.transportType,connectionId:S.id||S.url,onUpdate:v,onRemove:()=>h(S.id||S.url),embedded:t},_)})]})}const yme=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),wme=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),lU=e=>{const t=wme(e);return t.charAt(0).toUpperCase()+t.slice(1)},VG=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),xme=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Sme={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 Eme=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...c},u)=>y.createElement("svg",{ref:u,...Sme,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:VG("lucide",r),...!i&&!xme(c)&&{"aria-hidden":"true"},...c},[...s.map(([f,m])=>y.createElement(f,m)),...Array.isArray(i)?i:[i]]));const nt=(e,t)=>{const n=y.forwardRef(({className:a,...r},i)=>y.createElement(Eme,{ref:i,iconNode:t,className:VG(`lucide-${yme(lU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=lU(e),n};const _me=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],kme=nt("arrow-down-to-line",_me);const Tme=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Nme=nt("arrow-up-from-line",Tme);const Cme=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Rme=nt("arrow-up",Cme);const Ame=[["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"}]],aC=nt("bell",Ame);const Ime=[["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"}]],GG=nt("brush",Ime);const Ome=[["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"}]],Dme=nt("bug",Ome);const jme=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],mr=nt("check",jme);const Lme=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],qs=nt("chevron-down",Lme);const $me=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],a0=nt("chevron-left",$me);const Mme=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],WG=nt("chevron-right",Mme);const Pme=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],zme=nt("chevron-up",Pme);const Ume=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Fme=nt("chevrons-up-down",Ume);const Bme=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],cU=nt("circle-minus",Bme);const Hme=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Fp=nt("clock",Hme);const Vme=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],iC=nt("code",Vme);const Gme=[["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"}]],Wme=nt("cog",Gme);const Kme=[["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"}]],Zme=nt("command",Kme);const Yme=[["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"}]],er=nt("copy",Yme);const qme=[["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"}]],i0=nt("database",qme);const Xme=[["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"}]],Mm=nt("download",Xme);const Jme=[["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"}]],Qme=nt("ellipsis-vertical",Jme);const ehe=[["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"}]],t_=nt("external-link",ehe);const the=[["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"}]],KG=nt("eye-off",the);const nhe=[["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"}]],n_=nt("eye",nhe);const rhe=[["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"}]],ahe=nt("file-code",rhe);const ihe=[["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"}]],ohe=nt("file-image",ihe);const she=[["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"}]],oC=nt("file-text",she);const lhe=[["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"}]],che=nt("file",lhe);const uhe=[["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"}]],dhe=nt("folder-open",uhe);const fhe=[["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"}]],phe=nt("globe",fhe);const mhe=[["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"}]],hhe=nt("grip-vertical",mhe);const ghe=[["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"}]],ZG=nt("hash",ghe);const bhe=[["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"}]],Bp=nt("history",bhe);const vhe=[["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"}]],YG=nt("key",vhe);const yhe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Fs=nt("loader-circle",yhe);const whe=[["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"}]],sC=nt("maximize-2",whe);const xhe=[["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"}]],Hp=nt("maximize",xhe);const She=[["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"}]],Ehe=nt("message-circle",She);const _he=[["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"}]],Vp=nt("message-square",_he);const khe=[["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"}]],qG=nt("minimize",khe);const The=[["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"}]],uU=nt("monitor",The);const Nhe=[["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"}]],Che=nt("moon",Nhe);const Rhe=[["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"}]],Ahe=nt("picture-in-picture",Rhe);const Ihe=[["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"}]],XG=nt("play",Ihe);const Ohe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],JG=nt("plus",Ohe);const Dhe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],dU=nt("rotate-ccw",Dhe);const jhe=[["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"}]],lC=nt("save",jhe);const Lhe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Pd=nt("search",Lhe);const $he=[["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"}]],Mhe=nt("send",$he);const Phe=[["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"}]],zhe=nt("server",Phe);const Uhe=[["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"}]],_u=nt("settings",Uhe);const Fhe=[["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"}]],Bhe=nt("shield",Fhe);const Hhe=[["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"}]],Vhe=nt("sparkles",Hhe);const Ghe=[["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"}]],QG=nt("square-check-big",Ghe);const Whe=[["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"}]],Khe=nt("square-pen",Whe);const Zhe=[["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"}]],Yhe=nt("sun-dim",Zhe);const qhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],AS=nt("terminal",qhe);const Xhe=[["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"}]],Po=nt("trash-2",Xhe);const Jhe=[["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"}]],Qhe=nt("trash",Jhe);const ege=[["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"}]],Kl=nt("wrench",ege);const tge=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],no=nt("x",tge);const nge=[["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"}]],Gp=nt("zap",nge);function rge(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const age=e=>{switch(e){case"success":return sge;case"info":return cge;case"warning":return lge;case"error":return uge;default:return null}},ige=Array(12).fill(0),oge=({visible:e,className:t})=>Q.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},Q.createElement("div",{className:"sonner-spinner"},ige.map((n,a)=>Q.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),sge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Q.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),lge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Q.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),cge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Q.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),uge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Q.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),dge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Q.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Q.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),fge=()=>{const[e,t]=Q.useState(document.hidden);return Q.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let r_=1;class pge{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:a,...r}=t,i=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:r_++,s=this.toasts.find(u=>u.id===i),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),s?this.toasts=this.toasts.map(u=>u.id===i?(this.publish({...u,...t,id:i,title:a}),{...u,...t,id:i,dismissible:c,title:a}):u):this.addToast({title:a,...r,dismissible:c,id:i}),i},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(a=>a({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let a;n.loading!==void 0&&(a=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const r=Promise.resolve(t instanceof Function?t():t);let i=a!==void 0,s;const c=r.then(async f=>{if(s=["resolve",f],Q.isValidElement(f))i=!1,this.create({id:a,type:"default",message:f});else if(hge(f)&&!f.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${f.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${f.status}`):n.description,E=typeof h=="object"&&!Q.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...E})}else if(f instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(f):n.error,g=typeof n.description=="function"?await n.description(f):n.description,E=typeof h=="object"&&!Q.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...E})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(f):n.success,g=typeof n.description=="function"?await n.description(f):n.description,E=typeof h=="object"&&!Q.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...E})}}).catch(async f=>{if(s=["reject",f],n.error!==void 0){i=!1;const m=typeof n.error=="function"?await n.error(f):n.error,h=typeof n.description=="function"?await n.description(f):n.description,v=typeof m=="object"&&!Q.isValidElement(m)?m:{message:m};this.create({id:a,type:"error",description:h,...v})}}).finally(()=>{i&&(this.dismiss(a),a=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((f,m)=>c.then(()=>s[0]==="reject"?m(s[1]):f(s[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:u}:Object.assign(a,{unwrap:u})},this.custom=(t,n)=>{const a=n?.id||r_++;return this.create({jsx:t(a),id:a,...n}),a},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const va=new pge,mge=(e,t)=>{const n=t?.id||r_++;return va.addToast({title:e,...t,id:n}),n},hge=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",gge=mge,bge=()=>va.toasts,vge=()=>va.getActiveToasts(),ct=Object.assign(gge,{success:va.success,info:va.info,warning:va.warning,error:va.error,custom:va.custom,message:va.message,promise:va.promise,dismiss:va.dismiss,loading:va.loading},{getHistory:bge,getToasts:vge});rge("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function hb(e){return e.label!==void 0}const yge=3,wge="24px",xge="16px",fU=4e3,Sge=356,Ege=14,_ge=45,kge=200;function zi(...e){return e.filter(Boolean).join(" ")}function Tge(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const Nge=e=>{var t,n,a,r,i,s,c,u,f;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:E,visibleToasts:x,heights:w,index:S,toasts:_,expanded:k,removeToast:N,defaultRichColors:C,closeButton:A,style:I,cancelButtonStyle:O,actionButtonStyle:M,className:j="",descriptionClassName:B="",duration:G,position:ee,gap:te,expandByDefault:ae,classNames:V,icons:q,closeButtonAriaLabel:H="Close toast"}=e,[ie,re]=Q.useState(null),[P,F]=Q.useState(null),[U,L]=Q.useState(!1),[$,W]=Q.useState(!1),[K,Y]=Q.useState(!1),[se,oe]=Q.useState(!1),[X,J]=Q.useState(!1),[le,pe]=Q.useState(0),[me,_e]=Q.useState(0),ze=Q.useRef(h.duration||G||fU),ue=Q.useRef(null),Pe=Q.useRef(null),Ye=S===0,fe=S+1<=x,De=h.type,He=h.dismissible!==!1,Ee=h.className||"",Ne=h.descriptionClassName||"",Ae=Q.useMemo(()=>w.findIndex(Ze=>Ze.toastId===h.id)||0,[w,h.id]),We=Q.useMemo(()=>{var Ze;return(Ze=h.closeButton)!=null?Ze:A},[h.closeButton,A]),ft=Q.useMemo(()=>h.duration||G||fU,[h.duration,G]),at=Q.useRef(0),yt=Q.useRef(0),xn=Q.useRef(0),pt=Q.useRef(null),[Gn,hn]=ee.split("-"),Ve=Q.useMemo(()=>w.reduce((Ze,vt,wt)=>wt>=Ae?Ze:Ze+vt.height,0),[w,Ae]),Ue=fge(),Se=h.invert||m,Oe=De==="loading";yt.current=Q.useMemo(()=>Ae*te+Ve,[Ae,Ve]),Q.useEffect(()=>{ze.current=ft},[ft]),Q.useEffect(()=>{L(!0)},[]),Q.useEffect(()=>{const Ze=Pe.current;if(Ze){const vt=Ze.getBoundingClientRect().height;return _e(vt),E(wt=>[{toastId:h.id,height:vt,position:h.position},...wt]),()=>E(wt=>wt.filter(kt=>kt.toastId!==h.id))}},[E,h.id]),Q.useLayoutEffect(()=>{if(!U)return;const Ze=Pe.current,vt=Ze.style.height;Ze.style.height="auto";const wt=Ze.getBoundingClientRect().height;Ze.style.height=vt,_e(wt),E(kt=>kt.find(et=>et.toastId===h.id)?kt.map(et=>et.toastId===h.id?{...et,height:wt}:et):[{toastId:h.id,height:wt,position:h.position},...kt])},[U,h.title,h.description,E,h.id,h.jsx,h.action,h.cancel]);const Ge=Q.useCallback(()=>{W(!0),pe(yt.current),E(Ze=>Ze.filter(vt=>vt.toastId!==h.id)),setTimeout(()=>{N(h)},kge)},[h,N,E,yt]);Q.useEffect(()=>{if(h.promise&&De==="loading"||h.duration===1/0||h.type==="loading")return;let Ze;return k||v||Ue?(()=>{if(xn.current<at.current){const kt=new Date().getTime()-at.current;ze.current=ze.current-kt}xn.current=new Date().getTime()})():ze.current!==1/0&&(at.current=new Date().getTime(),Ze=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),Ge()},ze.current)),()=>clearTimeout(Ze)},[k,v,h,De,Ue,Ge]),Q.useEffect(()=>{h.delete&&(Ge(),h.onDismiss==null||h.onDismiss.call(h,h))},[Ge,h.delete]);function lt(){var Ze;if(q?.loading){var vt;return Q.createElement("div",{className:zi(V?.loader,h==null||(vt=h.classNames)==null?void 0:vt.loader,"sonner-loader"),"data-visible":De==="loading"},q.loading)}return Q.createElement(oge,{className:zi(V?.loader,h==null||(Ze=h.classNames)==null?void 0:Ze.loader),visible:De==="loading"})}const Xe=h.icon||q?.[De]||age(De);var it,mt;return Q.createElement("li",{tabIndex:0,ref:Pe,className:zi(j,Ee,V?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,V?.default,V?.[De],h==null||(n=h.classNames)==null?void 0:n[De]),"data-sonner-toast":"","data-rich-colors":(it=h.richColors)!=null?it:C,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":U,"data-promise":!!h.promise,"data-swiped":X,"data-removed":$,"data-visible":fe,"data-y-position":Gn,"data-x-position":hn,"data-index":S,"data-front":Ye,"data-swiping":K,"data-dismissible":He,"data-type":De,"data-invert":Se,"data-swipe-out":se,"data-swipe-direction":P,"data-expanded":!!(k||ae&&U),"data-testid":h.testId,style:{"--index":S,"--toasts-before":S,"--z-index":_.length-S,"--offset":`${$?le:yt.current}px`,"--initial-height":ae?"auto":`${me}px`,...I,...h.style},onDragEnd:()=>{Y(!1),re(null),pt.current=null},onPointerDown:Ze=>{Ze.button!==2&&(Oe||!He||(ue.current=new Date,pe(yt.current),Ze.target.setPointerCapture(Ze.pointerId),Ze.target.tagName!=="BUTTON"&&(Y(!0),pt.current={x:Ze.clientX,y:Ze.clientY})))},onPointerUp:()=>{var Ze,vt,wt;if(se||!He)return;pt.current=null;const kt=Number(((Ze=Pe.current)==null?void 0:Ze.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Wn=Number(((vt=Pe.current)==null?void 0:vt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),et=new Date().getTime()-((wt=ue.current)==null?void 0:wt.getTime()),Lt=ie==="x"?kt:Wn,dn=Math.abs(Lt)/et;if(Math.abs(Lt)>=_ge||dn>.11){pe(yt.current),h.onDismiss==null||h.onDismiss.call(h,h),F(ie==="x"?kt>0?"right":"left":Wn>0?"down":"up"),Ge(),oe(!0);return}else{var nn,on;(nn=Pe.current)==null||nn.style.setProperty("--swipe-amount-x","0px"),(on=Pe.current)==null||on.style.setProperty("--swipe-amount-y","0px")}J(!1),Y(!1),re(null)},onPointerMove:Ze=>{var vt,wt,kt;if(!pt.current||!He||((vt=window.getSelection())==null?void 0:vt.toString().length)>0)return;const et=Ze.clientY-pt.current.y,Lt=Ze.clientX-pt.current.x;var dn;const nn=(dn=e.swipeDirections)!=null?dn:Tge(ee);!ie&&(Math.abs(Lt)>1||Math.abs(et)>1)&&re(Math.abs(Lt)>Math.abs(et)?"x":"y");let on={x:0,y:0};const gr=Nt=>1/(1.5+Math.abs(Nt)/20);if(ie==="y"){if(nn.includes("top")||nn.includes("bottom"))if(nn.includes("top")&&et<0||nn.includes("bottom")&&et>0)on.y=et;else{const Nt=et*gr(et);on.y=Math.abs(Nt)<Math.abs(et)?Nt:et}}else if(ie==="x"&&(nn.includes("left")||nn.includes("right")))if(nn.includes("left")&&Lt<0||nn.includes("right")&&Lt>0)on.x=Lt;else{const Nt=Lt*gr(Lt);on.x=Math.abs(Nt)<Math.abs(Lt)?Nt:Lt}(Math.abs(on.x)>0||Math.abs(on.y)>0)&&J(!0),(wt=Pe.current)==null||wt.style.setProperty("--swipe-amount-x",`${on.x}px`),(kt=Pe.current)==null||kt.style.setProperty("--swipe-amount-y",`${on.y}px`)}},We&&!h.jsx&&De!=="loading"?Q.createElement("button",{"aria-label":H,"data-disabled":Oe,"data-close-button":!0,onClick:Oe||!He?()=>{}:()=>{Ge(),h.onDismiss==null||h.onDismiss.call(h,h)},className:zi(V?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(mt=q?.close)!=null?mt:dge):null,(De||h.icon||h.promise)&&h.icon!==null&&(q?.[De]!==null||h.icon)?Q.createElement("div",{"data-icon":"",className:zi(V?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||lt():null,h.type!=="loading"?Xe:null):null,Q.createElement("div",{"data-content":"",className:zi(V?.content,h==null||(i=h.classNames)==null?void 0:i.content)},Q.createElement("div",{"data-title":"",className:zi(V?.title,h==null||(s=h.classNames)==null?void 0:s.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?Q.createElement("div",{"data-description":"",className:zi(B,Ne,V?.description,h==null||(c=h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),Q.isValidElement(h.cancel)?h.cancel:h.cancel&&hb(h.cancel)?Q.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ze=>{hb(h.cancel)&&He&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ze),Ge())},className:zi(V?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,Q.isValidElement(h.action)?h.action:h.action&&hb(h.action)?Q.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Ze=>{hb(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ze),!Ze.defaultPrevented&&Ge())},className:zi(V?.actionButton,h==null||(f=h.classNames)==null?void 0:f.actionButton)},h.action.label):null)};function pU(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Cge(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?xge:wge;function u(f){["top","right","bottom","left"].forEach(m=>{n[`${s}-${m}`]=typeof f=="number"?`${f}px`:f})}typeof a=="number"||typeof a=="string"?u(a):typeof a=="object"?["top","right","bottom","left"].forEach(f=>{a[f]===void 0?n[`${s}-${f}`]=c:n[`${s}-${f}`]=typeof a[f]=="number"?`${a[f]}px`:a[f]}):u(c)}),n}const e7=Q.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:f,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:E,style:x,visibleToasts:w=yge,toastOptions:S,dir:_=pU(),gap:k=Ege,icons:N,containerAriaLabel:C="Notifications"}=t,[A,I]=Q.useState([]),O=Q.useMemo(()=>a?A.filter(U=>U.toasterId===a):A.filter(U=>!U.toasterId),[A,a]),M=Q.useMemo(()=>Array.from(new Set([i].concat(O.filter(U=>U.position).map(U=>U.position)))),[O,i]),[j,B]=Q.useState([]),[G,ee]=Q.useState(!1),[te,ae]=Q.useState(!1),[V,q]=Q.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=Q.useRef(null),ie=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),re=Q.useRef(null),P=Q.useRef(!1),F=Q.useCallback(U=>{I(L=>{var $;return($=L.find(W=>W.id===U.id))!=null&&$.delete||va.dismiss(U.id),L.filter(({id:W})=>W!==U.id)})},[]);return Q.useEffect(()=>va.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{I(L=>L.map($=>$.id===U.id?{...$,delete:!0}:$))});return}setTimeout(()=>{q9.flushSync(()=>{I(L=>{const $=L.findIndex(W=>W.id===U.id);return $!==-1?[...L.slice(0,$),{...L[$],...U},...L.slice($+1)]:[U,...L]})})})}),[A]),Q.useEffect(()=>{if(g!=="system"){q(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:L})=>{q(L?"dark":"light")})}catch{U.addListener(({matches:$})=>{try{q($?"dark":"light")}catch(W){console.error(W)}})}},[g]),Q.useEffect(()=>{A.length<=1&&ee(!1)},[A]),Q.useEffect(()=>{const U=L=>{var $;if(s.every(Y=>L[Y]||L.code===Y)){var K;ee(!0),(K=H.current)==null||K.focus()}L.code==="Escape"&&(document.activeElement===H.current||($=H.current)!=null&&$.contains(document.activeElement))&&ee(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[s]),Q.useEffect(()=>{if(H.current)return()=>{re.current&&(re.current.focus({preventScroll:!0}),re.current=null,P.current=!1)}},[H.current]),Q.createElement("section",{ref:n,"aria-label":`${C} ${ie}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((U,L)=>{var $;const[W,K]=U.split("-");return O.length?Q.createElement("ol",{key:U,dir:_==="auto"?pU():_,tabIndex:-1,ref:H,className:f,"data-sonner-toaster":!0,"data-sonner-theme":V,"data-y-position":W,"data-x-position":K,style:{"--front-toast-height":`${(($=j[0])==null?void 0:$.height)||0}px`,"--width":`${Sge}px`,"--gap":`${k}px`,...x,...Cge(m,h)},onBlur:Y=>{P.current&&!Y.currentTarget.contains(Y.relatedTarget)&&(P.current=!1,re.current&&(re.current.focus({preventScroll:!0}),re.current=null))},onFocus:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||P.current||(P.current=!0,re.current=Y.relatedTarget)},onMouseEnter:()=>ee(!0),onMouseMove:()=>ee(!0),onMouseLeave:()=>{te||ee(!1)},onDragEnd:()=>ee(!1),onPointerDown:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},O.filter(Y=>!Y.position&&L===0||Y.position===U).map((Y,se)=>{var oe,X;return Q.createElement(Nge,{key:Y.id,icons:N,index:se,toast:Y,defaultRichColors:v,duration:(oe=S?.duration)!=null?oe:E,className:S?.className,descriptionClassName:S?.descriptionClassName,invert:r,visibleToasts:w,closeButton:(X=S?.closeButton)!=null?X:u,interacting:te,position:U,style:S?.style,unstyled:S?.unstyled,classNames:S?.classNames,cancelButtonStyle:S?.cancelButtonStyle,actionButtonStyle:S?.actionButtonStyle,closeButtonAriaLabel:S?.closeButtonAriaLabel,removeToast:F,toasts:O.filter(J=>J.position==Y.position),heights:j.filter(J=>J.position==Y.position),setHeights:B,expandByDefault:c,gap:k,expanded:G,swipeDirections:t.swipeDirections})})):null}))}),mU=Object.freeze(Object.defineProperty({__proto__:null,Toaster:e7,toast:ct},Symbol.toStringTag,{value:"Module"}));var o0="Dialog",[t7]=Ii(o0),[Rge,Oi]=t7(o0),n7=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:s=!0}=e,c=y.useRef(null),u=y.useRef(null),[f,m]=Lo({prop:a,defaultProp:r??!1,onChange:i,caller:o0});return d.jsx(Rge,{scope:t,triggerRef:c,contentRef:u,contentId:zr(),titleId:zr(),descriptionId:zr(),open:f,onOpenChange:m,onOpenToggle:y.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};n7.displayName=o0;var r7="DialogTrigger",a7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(r7,n),i=tn(t,r.triggerRef);return d.jsx(Ot.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":dC(r.open),...a,ref:i,onClick:Ke(e.onClick,r.onOpenToggle)})});a7.displayName=r7;var cC="DialogPortal",[Age,i7]=t7(cC,{forceMount:void 0}),o7=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Oi(cC,t);return d.jsx(Age,{scope:t,forceMount:n,children:y.Children.map(a,s=>d.jsx(za,{present:n||i.open,children:d.jsx($d,{asChild:!0,container:r,children:s})}))})};o7.displayName=cC;var Ov="DialogOverlay",s7=y.forwardRef((e,t)=>{const n=i7(Ov,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Oi(Ov,e.__scopeDialog);return i.modal?d.jsx(za,{present:a||i.open,children:d.jsx(Oge,{...r,ref:t})}):null});s7.displayName=Ov;var Ige=Gl("DialogOverlay.RemoveScroll"),Oge=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(Ov,n);return d.jsx(Dm,{as:Ige,allowPinchZoom:!0,shards:[r.contentRef],children:d.jsx(Ot.div,{"data-state":dC(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),Zl="DialogContent",l7=y.forwardRef((e,t)=>{const n=i7(Zl,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Oi(Zl,e.__scopeDialog);return d.jsx(za,{present:a||i.open,children:i.modal?d.jsx(Dge,{...r,ref:t}):d.jsx(jge,{...r,ref:t})})});l7.displayName=Zl;var Dge=y.forwardRef((e,t)=>{const n=Oi(Zl,e.__scopeDialog),a=y.useRef(null),r=tn(t,n.contentRef,a);return y.useEffect(()=>{const i=a.current;if(i)return Yy(i)},[]),d.jsx(c7,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ke(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ke(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ke(e.onFocusOutside,i=>i.preventDefault())})}),jge=y.forwardRef((e,t)=>{const n=Oi(Zl,e.__scopeDialog),a=y.useRef(!1),r=y.useRef(!1);return d.jsx(c7,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(a.current||n.triggerRef.current?.focus(),i.preventDefault()),a.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(a.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),c7=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=Oi(Zl,n),u=y.useRef(null),f=tn(t,u);return Fy(),d.jsxs(d.Fragment,{children:[d.jsx(Rm,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:d.jsx(Dd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":dC(c.open),...s,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Lge,{titleId:c.titleId}),d.jsx(Mge,{contentRef:u,descriptionId:c.descriptionId})]})]})}),uC="DialogTitle",u7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(uC,n);return d.jsx(Ot.h2,{id:r.titleId,...a,ref:t})});u7.displayName=uC;var d7="DialogDescription",f7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(d7,n);return d.jsx(Ot.p,{id:r.descriptionId,...a,ref:t})});f7.displayName=d7;var p7="DialogClose",m7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(p7,n);return d.jsx(Ot.button,{type:"button",...a,ref:t,onClick:Ke(e.onClick,()=>r.onOpenChange(!1))})});m7.displayName=p7;function dC(e){return e?"open":"closed"}var h7="DialogTitleWarning",[fNe,g7]=Ece(h7,{contentName:Zl,titleName:uC,docsSlug:"dialog"}),Lge=({titleId:e})=>{const t=g7(h7),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
104
|
+
`)},pfe=0,qc=[];function mfe(e){var t=y.useRef([]),n=y.useRef([0,0]),a=y.useRef(),r=y.useState(pfe++)[0],i=y.useState(D8)[0],s=y.useRef(e);y.useEffect(function(){s.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var x=Lde([e.lockRef.current],(e.shards||[]).map(tU),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=y.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!s.current.allowPinchZoom;var S=ub(x),_=n.current,k="deltaX"in x?x.deltaX:_[0]-S[0],N="deltaY"in x?x.deltaY:_[1]-S[1],C,A=x.target,I=Math.abs(k)>Math.abs(N)?"h":"v";if("touches"in x&&I==="h"&&A.type==="range")return!1;var O=window.getSelection(),M=O&&O.anchorNode,j=M?M===A||M.contains(A):!1;if(j)return!1;var B=Qz(I,A);if(!B)return!0;if(B?C=I:(C=I==="v"?"h":"v",B=Qz(I,A)),!B)return!1;if(!a.current&&"changedTouches"in x&&(k||N)&&(a.current=C),!C)return!0;var G=a.current||C;return ufe(G,w,x,G==="h"?k:N)},[]),u=y.useCallback(function(x){var w=x;if(!(!qc.length||qc[qc.length-1]!==i)){var S="deltaY"in w?eU(w):ub(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&dfe(C.delta,S)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var k=(s.current.shards||[]).map(tU).filter(Boolean).filter(function(C){return C.contains(w.target)}),N=k.length>0?c(w,k[0]):!s.current.noIsolation;N&&w.cancelable&&w.preventDefault()}}},[]),f=y.useCallback(function(x,w,S,_){var k={name:x,delta:w,target:S,should:_,shadowParent:hfe(S)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(N){return N!==k})},1)},[]),m=y.useCallback(function(x){n.current=ub(x),a.current=void 0},[]),h=y.useCallback(function(x){f(x.type,eU(x),x.target,c(x,e.lockRef.current))},[]),g=y.useCallback(function(x){f(x.type,ub(x),x.target,c(x,e.lockRef.current))},[]);y.useEffect(function(){return qc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Yc),document.addEventListener("touchmove",u,Yc),document.addEventListener("touchstart",m,Yc),function(){qc=qc.filter(function(x){return x!==i}),document.removeEventListener("wheel",u,Yc),document.removeEventListener("touchmove",u,Yc),document.removeEventListener("touchstart",m,Yc)}},[]);var v=e.removeScrollBar,E=e.inert;return y.createElement(y.Fragment,null,E?y.createElement(i,{styles:ffe(r)}):null,v?y.createElement(rfe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function hfe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const gfe=Vde(O8,mfe);var Dm=y.forwardRef(function(e,t){return y.createElement(qy,Fi({},e,{ref:t,sideCar:gfe}))});Dm.classNames=qy.classNames;var XE=["Enter"," "],bfe=["ArrowDown","PageUp","Home"],M8=["ArrowUp","PageDown","End"],vfe=[...bfe,...M8],yfe={ltr:[...XE,"ArrowRight"],rtl:[...XE,"ArrowLeft"]},wfe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},jm="Menu",[Mp,xfe,Sfe]=LN(jm),[ac,P8]=Ii(jm,[Sfe,Ys,_8]),Xy=Ys(),z8=_8(),[Efe,ic]=ac(jm),[_fe,Lm]=ac(jm),U8=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=Xy(t),[u,f]=y.useState(null),m=y.useRef(!1),h=Ji(i),g=$N(r);return y.useEffect(()=>{const v=()=>{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",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),d.jsx(Wy,{...c,children:d.jsx(Efe,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:f,children:d.jsx(_fe,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};U8.displayName=jm;var kfe="MenuAnchor",WN=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Xy(n);return d.jsx(Im,{...r,...a,ref:t})});WN.displayName=kfe;var KN="MenuPortal",[Tfe,F8]=ac(KN,{forceMount:void 0}),B8=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=ic(KN,t);return d.jsx(Tfe,{scope:t,forceMount:n,children:d.jsx(za,{present:n||i.open,children:d.jsx($d,{asChild:!0,container:r,children:a})})})};B8.displayName=KN;var Qa="MenuContent",[Nfe,ZN]=ac(Qa),H8=y.forwardRef((e,t)=>{const n=F8(Qa,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ic(Qa,e.__scopeMenu),s=Lm(Qa,e.__scopeMenu);return d.jsx(Mp.Provider,{scope:e.__scopeMenu,children:d.jsx(za,{present:a||i.open,children:d.jsx(Mp.Slot,{scope:e.__scopeMenu,children:s.modal?d.jsx(Cfe,{...r,ref:t}):d.jsx(Rfe,{...r,ref:t})})})})}),Cfe=y.forwardRef((e,t)=>{const n=ic(Qa,e.__scopeMenu),a=y.useRef(null),r=tn(t,a);return y.useEffect(()=>{const i=a.current;if(i)return Yy(i)},[]),d.jsx(YN,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ke(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Rfe=y.forwardRef((e,t)=>{const n=ic(Qa,e.__scopeMenu);return d.jsx(YN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Afe=Gl("MenuContent.ScrollLock"),YN=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:E,...x}=e,w=ic(Qa,n),S=Lm(Qa,n),_=Xy(n),k=z8(n),N=xfe(n),[C,A]=y.useState(null),I=y.useRef(null),O=tn(t,I,w.onContentChange),M=y.useRef(0),j=y.useRef(""),B=y.useRef(0),G=y.useRef(null),ee=y.useRef("right"),te=y.useRef(0),ae=E?Dm:y.Fragment,V=E?{as:Afe,allowPinchZoom:!0}:void 0,q=ie=>{const re=j.current+ie,P=N().filter(K=>!K.disabled),F=document.activeElement,U=P.find(K=>K.ref.current===F)?.textValue,L=P.map(K=>K.textValue),$=Bfe(L,re,U),W=P.find(K=>K.textValue===$)?.ref.current;(function K(Y){j.current=Y,window.clearTimeout(M.current),Y!==""&&(M.current=window.setTimeout(()=>K(""),1e3))})(re),W&&setTimeout(()=>W.focus())};y.useEffect(()=>()=>window.clearTimeout(M.current),[]),Fy();const H=y.useCallback(ie=>ee.current===G.current?.side&&Vfe(ie,G.current?.area),[]);return d.jsx(Nfe,{scope:n,searchRef:j,onItemEnter:y.useCallback(ie=>{H(ie)&&ie.preventDefault()},[H]),onItemLeave:y.useCallback(ie=>{H(ie)||(I.current?.focus(),A(null))},[H]),onTriggerLeave:y.useCallback(ie=>{H(ie)&&ie.preventDefault()},[H]),pointerGraceTimerRef:B,onPointerGraceIntentChange:y.useCallback(ie=>{G.current=ie},[]),children:d.jsx(ae,{...V,children:d.jsx(Rm,{asChild:!0,trapped:r,onMountAutoFocus:Ke(i,ie=>{ie.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:d.jsx(Dd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:d.jsx(Ade,{asChild:!0,...k,dir:S.dir,orientation:"vertical",loop:a,currentTabStopId:C,onCurrentTabStopIdChange:A,onEntryFocus:Ke(u,ie=>{S.isUsingKeyboardRef.current||ie.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(Ky,{role:"menu","aria-orientation":"vertical","data-state":iG(w.open),"data-radix-menu-content":"",dir:S.dir,..._,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:Ke(x.onKeyDown,ie=>{const P=ie.target.closest("[data-radix-menu-content]")===ie.currentTarget,F=ie.ctrlKey||ie.altKey||ie.metaKey,U=ie.key.length===1;P&&(ie.key==="Tab"&&ie.preventDefault(),!F&&U&&q(ie.key));const L=I.current;if(ie.target!==L||!vfe.includes(ie.key))return;ie.preventDefault();const W=N().filter(K=>!K.disabled).map(K=>K.ref.current);M8.includes(ie.key)&&W.reverse(),Ufe(W)}),onBlur:Ke(e.onBlur,ie=>{ie.currentTarget.contains(ie.target)||(window.clearTimeout(M.current),j.current="")}),onPointerMove:Ke(e.onPointerMove,Pp(ie=>{const re=ie.target,P=te.current!==ie.clientX;if(ie.currentTarget.contains(re)&&P){const F=ie.clientX>te.current?"right":"left";ee.current=F,te.current=ie.clientX}}))})})})})})})});H8.displayName=Qa;var Ife="MenuGroup",qN=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Ot.div,{role:"group",...a,ref:t})});qN.displayName=Ife;var Ofe="MenuLabel",V8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Ot.div,{...a,ref:t})});V8.displayName=Ofe;var Cv="MenuItem",nU="menu.itemSelect",Jy=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=y.useRef(null),s=Lm(Cv,e.__scopeMenu),c=ZN(Cv,e.__scopeMenu),u=tn(t,i),f=y.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(nU,{bubbles:!0,cancelable:!0});h.addEventListener(nU,v=>a?.(v),{once:!0}),J9(h,g),g.defaultPrevented?f.current=!1:s.onClose()}};return d.jsx(G8,{...r,ref:u,disabled:n,onClick:Ke(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:Ke(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:Ke(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||XE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Jy.displayName=Cv;var G8=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=ZN(Cv,n),c=z8(n),u=y.useRef(null),f=tn(t,u),[m,h]=y.useState(!1),[g,v]=y.useState("");return y.useEffect(()=>{const E=u.current;E&&v((E.textContent??"").trim())},[i.children]),d.jsx(Mp.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:d.jsx(Ide,{asChild:!0,...c,focusable:!a,children:d.jsx(Ot.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:f,onPointerMove:Ke(e.onPointerMove,Pp(E=>{a?s.onItemLeave(E):(s.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ke(e.onPointerLeave,Pp(E=>s.onItemLeave(E))),onFocus:Ke(e.onFocus,()=>h(!0)),onBlur:Ke(e.onBlur,()=>h(!1))})})})}),Dfe="MenuCheckboxItem",W8=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return d.jsx(X8,{scope:e.__scopeMenu,checked:n,children:d.jsx(Jy,{role:"menuitemcheckbox","aria-checked":Rv(n)?"mixed":n,...r,ref:t,"data-state":JN(n),onSelect:Ke(r.onSelect,()=>a?.(Rv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});W8.displayName=Dfe;var K8="MenuRadioGroup",[jfe,Lfe]=ac(K8,{value:void 0,onValueChange:()=>{}}),Z8=y.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Ji(a);return d.jsx(jfe,{scope:e.__scopeMenu,value:n,onValueChange:i,children:d.jsx(qN,{...r,ref:t})})});Z8.displayName=K8;var Y8="MenuRadioItem",q8=y.forwardRef((e,t)=>{const{value:n,...a}=e,r=Lfe(Y8,e.__scopeMenu),i=n===r.value;return d.jsx(X8,{scope:e.__scopeMenu,checked:i,children:d.jsx(Jy,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":JN(i),onSelect:Ke(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});q8.displayName=Y8;var XN="MenuItemIndicator",[X8,$fe]=ac(XN,{checked:!1}),J8=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=$fe(XN,n);return d.jsx(za,{present:a||Rv(i.checked)||i.checked===!0,children:d.jsx(Ot.span,{...r,ref:t,"data-state":JN(i.checked)})})});J8.displayName=XN;var Mfe="MenuSeparator",Q8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(Ot.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});Q8.displayName=Mfe;var Pfe="MenuArrow",eG=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Xy(n);return d.jsx(Zy,{...r,...a,ref:t})});eG.displayName=Pfe;var zfe="MenuSub",[dNe,tG]=ac(zfe),np="MenuSubTrigger",nG=y.forwardRef((e,t)=>{const n=ic(np,e.__scopeMenu),a=Lm(np,e.__scopeMenu),r=tG(np,e.__scopeMenu),i=ZN(np,e.__scopeMenu),s=y.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=i,f={__scopeMenu:e.__scopeMenu},m=y.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return y.useEffect(()=>m,[m]),y.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),u(null)}},[c,u]),d.jsx(WN,{asChild:!0,...f,children:d.jsx(G8,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":iG(n.open),...e,ref:Xi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ke(e.onPointerMove,Pp(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Ke(e.onPointerLeave,Pp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,E=v==="right",x=E?-5:5,w=g[E?"left":"right"],S=g[E?"right":"left"];i.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:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ke(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||yfe[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});nG.displayName=np;var rG="MenuSubContent",aG=y.forwardRef((e,t)=>{const n=F8(Qa,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ic(Qa,e.__scopeMenu),s=Lm(Qa,e.__scopeMenu),c=tG(rG,e.__scopeMenu),u=y.useRef(null),f=tn(t,u);return d.jsx(Mp.Provider,{scope:e.__scopeMenu,children:d.jsx(za,{present:a||i.open,children:d.jsx(Mp.Slot,{scope:e.__scopeMenu,children:d.jsx(YN,{id:c.contentId,"aria-labelledby":c.triggerId,...r,ref:f,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{s.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Ke(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ke(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ke(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=wfe[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});aG.displayName=rG;function iG(e){return e?"open":"closed"}function Rv(e){return e==="indeterminate"}function JN(e){return Rv(e)?"indeterminate":e?"checked":"unchecked"}function Ufe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ffe(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Bfe(e,t,n){const r=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Ffe(e,Math.max(i,0));r.length===1&&(s=s.filter(f=>f!==n));const u=s.find(f=>f.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function Hfe(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],f=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-f)*(a-m)/(g-m)+f&&(r=!r)}return r}function Vfe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Hfe(n,t)}function Pp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Gfe=U8,Wfe=WN,Kfe=B8,Zfe=H8,Yfe=qN,qfe=V8,Xfe=Jy,Jfe=W8,Qfe=Z8,epe=q8,tpe=J8,npe=Q8,rpe=eG,ape=nG,ipe=aG,Qy="DropdownMenu",[ope]=Ii(Qy,[P8]),ca=P8(),[spe,oG]=ope(Qy),sG=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ca(t),f=y.useRef(null),[m,h]=Lo({prop:r,defaultProp:i??!1,onChange:s,caller:Qy});return d.jsx(spe,{scope:t,triggerId:zr(),triggerRef:f,contentId:zr(),open:m,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:c,children:d.jsx(Gfe,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};sG.displayName=Qy;var lG="DropdownMenuTrigger",cG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=oG(lG,n),s=ca(n);return d.jsx(Wfe,{asChild:!0,...s,children:d.jsx(Ot.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...r,ref:Xi(t,i.triggerRef),onPointerDown:Ke(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ke(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});cG.displayName=lG;var lpe="DropdownMenuPortal",uG=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ca(t);return d.jsx(Kfe,{...a,...n})};uG.displayName=lpe;var dG="DropdownMenuContent",fG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=oG(dG,n),i=ca(n),s=y.useRef(!1);return d.jsx(Zfe,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ke(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ke(e.onInteractOutside,c=>{const u=c.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;(!r.modal||m)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});fG.displayName=dG;var cpe="DropdownMenuGroup",upe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Yfe,{...r,...a,ref:t})});upe.displayName=cpe;var dpe="DropdownMenuLabel",pG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(qfe,{...r,...a,ref:t})});pG.displayName=dpe;var fpe="DropdownMenuItem",mG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Xfe,{...r,...a,ref:t})});mG.displayName=fpe;var ppe="DropdownMenuCheckboxItem",hG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Jfe,{...r,...a,ref:t})});hG.displayName=ppe;var mpe="DropdownMenuRadioGroup",hpe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Qfe,{...r,...a,ref:t})});hpe.displayName=mpe;var gpe="DropdownMenuRadioItem",gG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(epe,{...r,...a,ref:t})});gG.displayName=gpe;var bpe="DropdownMenuItemIndicator",vpe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(tpe,{...r,...a,ref:t})});vpe.displayName=bpe;var ype="DropdownMenuSeparator",bG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(npe,{...r,...a,ref:t})});bG.displayName=ype;var wpe="DropdownMenuArrow",xpe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(rpe,{...r,...a,ref:t})});xpe.displayName=wpe;var Spe="DropdownMenuSubTrigger",vG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(ape,{...r,...a,ref:t})});vG.displayName=Spe;var Epe="DropdownMenuSubContent",yG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(ipe,{...r,...a,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});yG.displayName=Epe;var _pe=sG,kpe=cG,Tpe=uG,wG=fG,xG=pG,SG=mG,Npe=hG,Cpe=gG,EG=bG,Rpe=vG,Ape=yG;const Av=_pe,Iv=kpe;Rpe.displayName;Ape.displayName;function zp({ref:e,className:t,sideOffset:n=4,...a}){return d.jsx(Tpe,{children:d.jsx(wG,{ref:e,sideOffset:n,className:Me("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})})}zp.displayName=wG.displayName;function ia({ref:e,className:t,inset:n,...a}){return d.jsx(SG,{ref:e,className:Me("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...a})}ia.displayName=SG.displayName;Npe.displayName;Cpe.displayName;function JE({ref:e,className:t,inset:n,...a}){return d.jsx(xG,{ref:e,className:Me("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}JE.displayName=xG.displayName;function rp({ref:e,className:t,...n}){return d.jsx(EG,{ref:e,className:Me("-mx-1 my-1 h-px bg-muted",t),...n})}rp.displayName=EG.displayName;var Ipe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Vo=Ipe.reduce((e,t)=>{const n=D9(`Primitive.${t}`),a=y.forwardRef((r,i)=>{const{asChild:s,...c}=r,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),Ope="Label",_G=y.forwardRef((e,t)=>d.jsx(Vo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));_G.displayName=Ope;var Dpe=_G;function Xt({className:e,...t}){return d.jsx(Dpe,{"data-slot":"label",className:Me("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function Md({message:e,className:t="",vertical:n,noBorder:a}){return d.jsx("div",{className:Me(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:d.jsxs("p",{className:Me("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 kG({className:e,color:t,children:n,grayscaled:a=!1}){const r=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return a?0:.2},[t,a]),i=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return a?.3:.4},[t,a]),s=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[2]||"0")}return Math.floor(Math.random()*360)},[t]),c=y.useMemo(()=>t||`oklch(${Math.min(i,1)} ${r} ${s})`,[s,r,i]),u=y.useMemo(()=>`oklch(${Math.min(i*2,1)} ${r} ${s})`,[s,r,i,t]),f=y.useMemo(()=>Math.floor(Math.random()*360),[s]),m=y.useMemo(()=>"1000%",[]);return d.jsx("section",{className:Me("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, ${c}, 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})]})})}function QN(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var e0="Switch",[jpe]=Ii(e0),[Lpe,$pe]=jpe(e0),TG=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:f,form:m,...h}=e,[g,v]=y.useState(null),E=tn(t,k=>v(k)),x=y.useRef(!1),w=g?m||!!g.closest("form"):!0,[S,_]=Lo({prop:r,defaultProp:i??!1,onChange:f,caller:e0});return d.jsxs(Lpe,{scope:n,checked:S,disabled:c,children:[d.jsx(Ot.button,{type:"button",role:"switch","aria-checked":S,"aria-required":s,"data-state":AG(S),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:E,onClick:Ke(e.onClick,k=>{_(N=>!N),w&&(x.current=k.isPropagationStopped(),x.current||k.stopPropagation())})}),w&&d.jsx(RG,{control:g,bubbles:!x.current,name:a,value:u,checked:S,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});TG.displayName=e0;var NG="SwitchThumb",CG=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=$pe(NG,n);return d.jsx(Ot.span,{"data-state":AG(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});CG.displayName=NG;var Mpe="SwitchBubbleInput",RG=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=y.useRef(null),c=tn(s,i),u=QN(n),f=HN(t);return y.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const E=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(E)}},[u,n,a]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:c,style:{...r.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});RG.displayName=Mpe;function AG(e){return e?"checked":"unchecked"}var IG=TG,Ppe=CG;function t0({ref:e,className:t,...n}){return d.jsx(IG,{className:Me("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:d.jsx(Ppe,{className:Me("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})}t0.displayName=IG.displayName;var OG=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"}),zpe="VisuallyHidden",DG=y.forwardRef((e,t)=>d.jsx(Ot.span,{...e,ref:t,style:{...OG,...e.style}}));DG.displayName=zpe;var Upe=DG,[n0]=Ii("Tooltip",[Ys]),r0=Ys(),jG="TooltipProvider",Fpe=700,QE="tooltip.open",[Bpe,eC]=n0(jG),LG=e=>{const{__scopeTooltip:t,delayDuration:n=Fpe,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,s=y.useRef(!0),c=y.useRef(!1),u=y.useRef(0);return y.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),d.jsx(Bpe,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,a)},[a]),isPointerInTransitRef:c,onPointerInTransitChange:y.useCallback(f=>{c.current=f},[]),disableHoverableContent:r,children:i})};LG.displayName=jG;var Up="Tooltip",[Hpe,$m]=n0(Up),$G=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=eC(Up,e.__scopeTooltip),f=r0(t),[m,h]=y.useState(null),g=zr(),v=y.useRef(0),E=s??u.disableHoverableContent,x=c??u.delayDuration,w=y.useRef(!1),[S,_]=Lo({prop:a,defaultProp:r??!1,onChange:I=>{I?(u.onOpen(),document.dispatchEvent(new CustomEvent(QE))):u.onClose(),i?.(I)},caller:Up}),k=y.useMemo(()=>S?w.current?"delayed-open":"instant-open":"closed",[S]),N=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w.current=!1,_(!0)},[_]),C=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_(!1)},[_]),A=y.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{w.current=!0,_(!0),v.current=0},x)},[x,_]);return y.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),d.jsx(Wy,{...f,children:d.jsx(Hpe,{scope:t,contentId:g,open:S,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{u.isOpenDelayedRef.current?A():N()},[u.isOpenDelayedRef,A,N]),onTriggerLeave:y.useCallback(()=>{E?C():(window.clearTimeout(v.current),v.current=0)},[C,E]),onOpen:N,onClose:C,disableHoverableContent:E,children:n})})};$G.displayName=Up;var e_="TooltipTrigger",MG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=$m(e_,n),i=eC(e_,n),s=r0(n),c=y.useRef(null),u=tn(t,c,r.onTriggerChange),f=y.useRef(!1),m=y.useRef(!1),h=y.useCallback(()=>f.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),d.jsx(Im,{asChild:!0,...s,children:d.jsx(Ot.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ke(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ke(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ke(e.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ke(e.onFocus,()=>{f.current||r.onOpen()}),onBlur:Ke(e.onBlur,r.onClose),onClick:Ke(e.onClick,r.onClose)})})});MG.displayName=e_;var tC="TooltipPortal",[Vpe,Gpe]=n0(tC,{forceMount:void 0}),PG=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=$m(tC,t);return d.jsx(Vpe,{scope:t,forceMount:n,children:d.jsx(za,{present:n||i.open,children:d.jsx($d,{asChild:!0,container:r,children:a})})})};PG.displayName=tC;var fd="TooltipContent",zG=y.forwardRef((e,t)=>{const n=Gpe(fd,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=$m(fd,e.__scopeTooltip);return d.jsx(za,{present:a||s.open,children:s.disableHoverableContent?d.jsx(UG,{side:r,...i,ref:t}):d.jsx(Wpe,{side:r,...i,ref:t})})}),Wpe=y.forwardRef((e,t)=>{const n=$m(fd,e.__scopeTooltip),a=eC(fd,e.__scopeTooltip),r=y.useRef(null),i=tn(t,r),[s,c]=y.useState(null),{trigger:u,onClose:f}=n,m=r.current,{onPointerInTransitChange:h}=a,g=y.useCallback(()=>{c(null),h(!1)},[h]),v=y.useCallback((E,x)=>{const w=E.currentTarget,S={x:E.clientX,y:E.clientY},_=qpe(S,w.getBoundingClientRect()),k=Xpe(S,_),N=Jpe(x.getBoundingClientRect()),C=eme([...k,...N]);c(C),h(!0)},[h]);return y.useEffect(()=>()=>g(),[g]),y.useEffect(()=>{if(u&&m){const E=w=>v(w,m),x=w=>v(w,u);return u.addEventListener("pointerleave",E),m.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",E),m.removeEventListener("pointerleave",x)}}},[u,m,v,g]),y.useEffect(()=>{if(s){const E=x=>{const w=x.target,S={x:x.clientX,y:x.clientY},_=u?.contains(w)||m?.contains(w),k=!Qpe(S,s);_?g():k&&(g(),f())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[u,m,s,f,g]),d.jsx(UG,{...e,ref:i})}),[Kpe,Zpe]=n0(Up,{isInside:!1}),Ype=Rce("TooltipContent"),UG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=$m(fd,n),f=r0(n),{onClose:m}=u;return y.useEffect(()=>(document.addEventListener(QE,m),()=>document.removeEventListener(QE,m)),[m]),y.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(Dd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:d.jsxs(Ky,{"data-state":u.stateAttribute,...f,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[d.jsx(Ype,{children:a}),d.jsx(Kpe,{scope:n,isInside:!0,children:d.jsx(Upe,{id:u.contentId,role:"tooltip",children:r||a})})]})})});zG.displayName=fd;var FG="TooltipArrow",BG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=r0(n);return Zpe(FG,n).isInside?null:d.jsx(Zy,{...r,...a,ref:t})});BG.displayName=FG;function qpe(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,a,r,i)){case i:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Xpe(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function Jpe(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function Qpe(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],f=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-f)*(a-m)/(g-m)+f&&(r=!r)}return r}function eme(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),tme(t)}function tme(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var nme=LG,rme=$G,ame=MG,ime=PG,ome=zG,sme=BG;function nC({delayDuration:e=0,...t}){return d.jsx(nme,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Rt({...e}){return d.jsx(nC,{children:d.jsx(rme,{"data-slot":"tooltip",...e})})}function At({...e}){return d.jsx(ame,{"data-slot":"tooltip-trigger",...e})}function It({className:e,sideOffset:t=0,children:n,...a}){return d.jsx(ime,{children:d.jsxs(ome,{"data-slot":"tooltip-content",sideOffset:t,className:Me("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...a,children:[n,d.jsx(sme,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function lme({requestId:e,serverName:t,mode:n,message:a,url:r,onViewDetails:i,onOpenUrl:s,onCancel:c}){return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Elicitation Request Received"}),d.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",a]}),n==="url"&&r&&d.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:r})]}),d.jsxs("div",{className:"flex gap-2 flex-wrap",children:[d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),i()},children:"View Details"}),n==="url"&&s&&d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),s()},children:"Open URL"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),c()},children:"Cancel"})]})]})}const cme={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function ume({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){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:i=>{i.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:i=>{i.stopPropagation(),a(cme)},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:i=>{i.stopPropagation(),r()},children:"Deny"})]})]})}class dme{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class rU{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 aU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class iU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class oU{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 fme{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 pme{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class mme{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class hme{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function CS(){try{return"0.14.0-canary.2"}catch{return"0.0.0"}}var gme={};function RS(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class sU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(a),!r.ok)throw new Error(`HTTP error! status: ${r.status}`)}catch{}}}function vs(e){return`mcp_inspector_telemetry_${e}`}class _r{static instance=null;POSTHOG_PROXY_URL="/inspector/api/tel/posthog";SCARF_PROXY_URL="/inspector/api/tel/scarf";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogClient=null;_scarfClient=null;_source="inspector";constructor(){const t=RS(),n=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||"inspector",n)this._posthogClient=null,this._scarfClient=null;else if(!t)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new sU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new sU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(vs("disabled"))==="true"||typeof process<"u"&&gme?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(vs("source")):null}static getInstance(){return _r.instance||(_r.instance=new _r),_r.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(vs("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!RS())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(vs("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(vs("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 a=Array.from(n).map(r=>r.toString(16).padStart(2,"0")).join("");return a.slice(0,8)+"-"+a.slice(8,12)+"-"+a.slice(12,16)+"-"+a.slice(16,20)+"-"+a.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const a=Math.random()*16|0;return(n==="x"?a:a&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:CS(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=CS(),n.user_id=this.userId,n.event=t.name,n.language="typescript",n.source=this._source,n.package="inspector",await this._scarfClient.logEvent(n)}catch{}}}async trackPackageDownload(t){if(this._scarfClient&&RS())try{const n=CS();let a=!1,r=!1;const i=localStorage.getItem(vs("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(vs("download_version"),n)):(a=!0,r=!0,localStorage.setItem(vs("download_version"),n)),a){const s={...t||{}};s.mcp_use_version=n,s.user_id=this.userId,s.event="package_download",s.first_download=r,s.language="typescript",s.source=this._source,s.package="inspector",await this._scarfClient.logEvent(s)}}catch{}}async trackInspectorOpen(t){const n=new dme(t);await this.capture(n)}}const db=()=>{},fb=()=>{},pb=()=>{},mb=()=>{},HG=y.createContext(null);function rC(){const e=y.use(HG);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function bme({url:e,name:t,proxyConfig:n,transportType:a,connectionId:r,onUpdate:i,onRemove:s,embedded:c}){const u=c?"mcp-embedded:auth":"mcp:auth",f=`${u}:${e}`,m=(()=>{if(typeof window>"u"||c)return!1;try{return localStorage.getItem(f)!==null}catch{return!1}})(),h=typeof window<"u"?new URL("/inspector/oauth/callback",window.location.origin).toString():"/inspector/oauth/callback",{url:g,headers:v}=fk(e,n),[E,x]=y.useState([]),w=y.useRef(0),[S,_]=y.useState([]),k=y.useRef(0),N=y.useMemo(()=>E.map(Y=>({id:Y.id,request:Y.request,timestamp:Y.timestamp,serverName:Y.serverName})),[E]),C=y.useMemo(()=>S.map(Y=>({id:Y.id,request:Y.request,timestamp:Y.timestamp,serverName:Y.serverName})),[S]),A=y.useRef(null),[I,O]=y.useState(!1),M=y.useRef(!1);y.useEffect(()=>{typeof window<"u"&&!M.current&&(M.current=!0,Mr(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(Y=>{A.current=Y.wrapTransportForLogging,O(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(Y=>{console.error("[McpContext] Failed to load transport wrapper:",Y)}))},[]);const j=y.useMemo(()=>{if(!(!I||!A.current))return(Y,se)=>{const oe=r;return console.log("[McpContext] Applying transport wrapper, serverId:",oe,"from connector:",se),A.current(Y,oe)}},[I,r]),B=`mcp-inspector-notifications-${r}`,G=500,[ee,te]=y.useState([]);y.useEffect(()=>{try{const Y=localStorage.getItem(B);if(Y){const se=JSON.parse(Y);Array.isArray(se)&&te(se)}}catch(Y){console.error("Failed to load notifications from localStorage:",Y)}},[B]),y.useEffect(()=>{try{localStorage.setItem(B,JSON.stringify(ee))}catch(Y){console.error("Failed to save notifications to localStorage:",Y)}},[ee,B]);const ae=y.useCallback(Y=>{te(se=>se.map(oe=>oe.id===Y?{...oe,read:!0}:oe))},[]),V=y.useCallback(()=>{te(Y=>Y.map(se=>({...se,read:!0})))},[]),q=y.useCallback(()=>{te([])},[]),H=y.useCallback(Y=>{te(se=>{const oe=[Y,...se];return oe.length>G?oe.slice(0,G):oe})},[]),ie=y.useCallback((Y,se)=>{x(oe=>{const X=oe.find(J=>J.id===Y);return X?(X.resolve(se),oe.filter(J=>J.id!==Y)):oe})},[]),re=y.useCallback((Y,se)=>{x(oe=>{const X=oe.find(J=>J.id===Y);return X?(X.reject(new Error(se||"User rejected sampling request")),oe.filter(J=>J.id!==Y)):oe})},[]),P=y.useCallback((Y,se)=>{_(oe=>{const X=oe.find(J=>J.id===Y);return X?(X.resolve(se),oe.filter(J=>J.id!==Y)):oe})},[]),F=y.useCallback((Y,se)=>{_(oe=>{const X=oe.find(J=>J.id===Y);return X?(X.reject(new Error(se||"User rejected elicitation request")),oe.filter(J=>J.id!==Y)):oe})},[]),U=y.useCallback(async Y=>new Promise((se,oe)=>{const X=`sampling-${w.current++}`,J={id:X,request:{method:"sampling/createMessage",params:Y},timestamp:Date.now(),serverName:t,resolve:se,reject:oe};x(le=>[...le,J]),typeof window<"u"&&Mr(async()=>{const{toast:le}=await Promise.resolve().then(()=>mU);return{toast:le}},void 0).then(({toast:le})=>{const pe=le(d.jsx(ume,{requestId:X,serverName:t,onViewDetails:()=>{const me=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:X}});window.dispatchEvent(me),le.dismiss(pe)},onApprove:me=>{x(_e=>{const ze=_e.find(ue=>ue.id===X);return ze?(ze.resolve(me),le.success("Sampling request approved"),_e.filter(ue=>ue.id!==X)):_e}),le.dismiss(pe)},onDeny:()=>{x(me=>{const _e=me.find(ze=>ze.id===X);return _e?(_e.reject(new Error("User denied sampling request from toast")),le.error("Sampling request denied"),me.filter(ze=>ze.id!==X)):me}),le.dismiss(pe)}}),{duration:5e3})})}),[t]),L=y.useCallback(async Y=>new Promise((se,oe)=>{const X=`elicitation-${k.current++}`,J={id:X,request:Y,timestamp:Date.now(),serverName:t,resolve:se,reject:oe};_(le=>[...le,J]),typeof window<"u"&&Mr(async()=>{const{toast:le}=await Promise.resolve().then(()=>mU);return{toast:le}},void 0).then(({toast:le})=>{const pe=le(d.jsx(lme,{requestId:X,serverName:t,mode:Y.mode||"form",message:Y.message,url:Y.mode==="url"?Y.url:void 0,onViewDetails:()=>{const me=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:X}});window.dispatchEvent(me),le.dismiss(pe)},onOpenUrl:Y.mode==="url"?()=>{window.open(Y.url,"_blank"),le.dismiss(pe)}:void 0,onCancel:()=>{_(me=>{const _e=me.find(ze=>ze.id===X);return _e?(_e.reject(new Error("User cancelled elicitation request from toast")),le.error("Elicitation request cancelled"),me.filter(ze=>ze.id!==X)):me}),le.dismiss(pe)}}),{duration:5e3})})}),[t]),$=CN({url:g,callbackUrl:h,timeout:5e3,customHeaders:Object.keys(v).length>0?v:void 0,transportType:a||"http",preventAutoAuth:!m,useRedirectFlow:!0,enabled:I,wrapTransport:j,storageKeyPrefix:u,onNotification:Y=>{H({id:globalThis.crypto.randomUUID(),method:Y.method,params:Y.params,timestamp:Date.now(),read:!1})},samplingCallback:U,onElicitation:L}),W=y.useRef(i),K=y.useRef(null);return y.useEffect(()=>{W.current=i},[i]),y.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{$.state==="ready"&&$.serverInfo&&console.log("[McpContext] Server info available:",$.serverInfo);const Y=ee.filter(X=>!X.read).length,se={id:r,url:e,name:$.serverInfo?.name||t,state:$.state,tools:$.tools,resources:$.resources,prompts:$.prompts,error:$.error??null,authUrl:$.authUrl??null,customHeaders:v,transportType:a,proxyConfig:n,serverInfo:$.serverInfo,capabilities:$.capabilities,notifications:ee,unreadNotificationCount:Y,markNotificationRead:ae,markAllNotificationsRead:V,clearNotifications:q,pendingSamplingRequests:N,approveSampling:ie,rejectSampling:re,pendingElicitationRequests:C,approveElicitation:P,rejectElicitation:F,callTool:$.callTool,readResource:$.readResource,listPrompts:$.listPrompts,getPrompt:$.getPrompt,authenticate:$.authenticate,retry:$.retry,clearStorage:$.clearStorage,disconnect:$.disconnect,client:$.client},oe=K.current;(!oe||oe.state!==se.state||oe.error!==se.error||oe.authUrl!==se.authUrl||oe.name!==se.name||oe.tools.length!==se.tools.length||oe.resources.length!==se.resources.length||oe.prompts.length!==se.prompts.length||oe.serverInfo!==se.serverInfo||oe.capabilities!==se.capabilities||oe.notifications.length!==se.notifications.length||oe.unreadNotificationCount!==se.unreadNotificationCount||oe.pendingSamplingRequests.length!==se.pendingSamplingRequests.length||oe.pendingElicitationRequests.length!==se.pendingElicitationRequests.length||!oe.client)&&(K.current=se,W.current(se))});else{const Y=ee.filter(X=>!X.read).length,se={id:r,url:e,name:$.serverInfo?.name||t,state:$.state,tools:$.tools,resources:$.resources,prompts:$.prompts,error:$.error??null,authUrl:$.authUrl??null,customHeaders:v,transportType:a,proxyConfig:n,serverInfo:$.serverInfo,capabilities:$.capabilities,notifications:ee,unreadNotificationCount:Y,markNotificationRead:ae,markAllNotificationsRead:V,clearNotifications:q,pendingSamplingRequests:N,approveSampling:ie,rejectSampling:re,pendingElicitationRequests:C,approveElicitation:P,rejectElicitation:F,callTool:$.callTool,readResource:$.readResource,listPrompts:$.listPrompts,getPrompt:$.getPrompt,authenticate:$.authenticate,retry:$.retry,clearStorage:$.clearStorage,disconnect:$.disconnect,client:$.client},oe=K.current;(!oe||oe.state!==se.state||oe.error!==se.error||oe.authUrl!==se.authUrl||oe.name!==se.name||oe.tools.length!==se.tools.length||oe.resources.length!==se.resources.length||oe.prompts.length!==se.prompts.length||oe.serverInfo!==se.serverInfo||oe.capabilities!==se.capabilities||oe.notifications.length!==se.notifications.length||oe.unreadNotificationCount!==se.unreadNotificationCount||oe.pendingSamplingRequests.length!==se.pendingSamplingRequests.length||oe.pendingElicitationRequests.length!==se.pendingElicitationRequests.length||!oe.client)&&(K.current=se,W.current(se))}},[e,t,a,n,v,r,$.state,$.tools,$.resources,$.prompts,$.error,$.authUrl,$.serverInfo,$.capabilities,$.client,ee,ae,V,q,$.callTool,$.readResource,$.listPrompts,$.getPrompt,$.authenticate,$.retry,$.clearStorage,E,ie,re,C,P,F]),null}function vme({children:e,embedded:t=!1}){const[n,a]=y.useState([]),[r,i]=y.useState(!1),[s,c]=y.useState(!0),[u,f]=y.useState([]);y.useEffect(()=>{if(t){i(!0);return}try{const S=localStorage.getItem("mcp-inspector-connections");if(S){const k=JSON.parse(S);Array.isArray(k)&&(f(k),a(k.map(N=>({id:N.id||N.url,url:N.url,name:N.name||"MCP Server",state:"discovering",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:N.proxyConfig?.customHeaders,transportType:N.transportType,proxyConfig:N.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:db,rejectSampling:fb,pendingElicitationRequests:[],approveElicitation:pb,rejectElicitation:mb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&c(_==="true")}catch(S){console.error("Failed to load connections from localStorage:",S)}finally{i(!0)}},[t]),y.useEffect(()=>{!r||t||localStorage.setItem("mcp-inspector-connections",JSON.stringify(u))},[u,r,t]),y.useEffect(()=>{!r||t||localStorage.setItem("mcp-inspector-auto-connect",String(s))},[s,r,t]);const m=y.useCallback((S,_,k,N)=>{const C=u.find(O=>O.url===S),A=n.find(O=>O.url===S);if(C&&A){if(JSON.stringify(C.proxyConfig)!==JSON.stringify(k)&&k){f(M=>M.filter(j=>j.url!==S)),a(M=>M.filter(j=>j.url!==S)),setTimeout(()=>{const M={id:S,url:S,name:_||C.name||"MCP Server",proxyConfig:k,transportType:N||C.transportType};f(j=>[...j,M]),a(j=>[...j,{id:S,url:S,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k?.customHeaders,transportType:N||C.transportType,proxyConfig:k,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:db,rejectSampling:fb,pendingElicitationRequests:[],approveElicitation:pb,rejectElicitation:mb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!A){(k||N)&&f(O=>O.map(M=>M.url===S?{...M,proxyConfig:k||M.proxyConfig,transportType:N||M.transportType,name:_||M.name}:M)),a(O=>[...O,{id:C.id||S,url:S,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k?.customHeaders||C.proxyConfig?.customHeaders,transportType:N||C.transportType,proxyConfig:k||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:db,rejectSampling:fb,pendingElicitationRequests:[],approveElicitation:pb,rejectElicitation:mb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const I={id:S,url:S,name:_||"MCP Server",proxyConfig:k,transportType:N};f(O=>[...O,I]),a(O=>[...O,{id:S,url:S,name:_||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k?.customHeaders,transportType:N,proxyConfig:k,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:db,rejectSampling:fb,pendingElicitationRequests:[],approveElicitation:pb,rejectElicitation:mb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[u,n]),h=y.useCallback(S=>{const _=n.find(N=>N.id===S);_&&(console.log(`[McpContext] Cleaning up connection: ${S}`),_.disconnect&&(console.log(`[McpContext] Disconnecting from server: ${S}`),_.disconnect()),_.clearStorage&&(console.log(`[McpContext] Clearing OAuth storage for connection: ${S}`),_.clearStorage())),f(N=>N.filter(C=>C.id!==S)),a(N=>N.filter(C=>C.id!==S));const k=localStorage.getItem("mcp-inspector-connections");if(k)try{const C=JSON.parse(k).filter(A=>(A.id||A.url)!==S);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(N){console.error("Failed to update localStorage on remove:",N)}_r.getInstance().capture(new pme({serverId:S}))},[n]),g=y.useCallback((S,_)=>{f(k=>k.map(N=>N.id===S||N.url===S?{...N,..._}:N)),a(k=>k.map(N=>N.id===S?{...N,..._}:N))},[]),v=y.useCallback(S=>{a(_=>{const k=_.findIndex(A=>A.id===S.id);if(k===-1)return _;const N=_[k];if(N.state===S.state&&N.tools===S.tools&&N.resources===S.resources&&N.prompts===S.prompts&&N.error===S.error&&N.serverInfo===S.serverInfo&&N.client===S.client&&N.notifications===S.notifications&&N.unreadNotificationCount===S.unreadNotificationCount&&N.pendingSamplingRequests.length===S.pendingSamplingRequests.length&&N.pendingElicitationRequests.length===S.pendingElicitationRequests.length)return _;const C=[..._];return C[k]=S,C})},[]),E=y.useCallback(S=>{console.log("Connect requested for:",S)},[]),x=y.useCallback(S=>{console.log("Disconnect requested for:",S)},[]),w=y.useMemo(()=>({connections:n,addConnection:m,removeConnection:h,updateConnectionConfig:g,autoConnect:s,setAutoConnect:c,connectServer:E,disconnectServer:x,configLoaded:r}),[n,m,h,g,s,E,x,r]);return d.jsxs(HG.Provider,{value:w,children:[e,r&&s&&u.map(S=>{const _=`${S.id||S.url}-${S.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",S.proxyConfig),d.jsx(bme,{url:S.url,name:S.name,proxyConfig:S.proxyConfig,transportType:S.transportType,connectionId:S.id||S.url,onUpdate:v,onRemove:()=>h(S.id||S.url),embedded:t},_)})]})}const yme=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),wme=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),lU=e=>{const t=wme(e);return t.charAt(0).toUpperCase()+t.slice(1)},VG=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),xme=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Sme={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 Eme=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...c},u)=>y.createElement("svg",{ref:u,...Sme,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:VG("lucide",r),...!i&&!xme(c)&&{"aria-hidden":"true"},...c},[...s.map(([f,m])=>y.createElement(f,m)),...Array.isArray(i)?i:[i]]));const nt=(e,t)=>{const n=y.forwardRef(({className:a,...r},i)=>y.createElement(Eme,{ref:i,iconNode:t,className:VG(`lucide-${yme(lU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=lU(e),n};const _me=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],kme=nt("arrow-down-to-line",_me);const Tme=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Nme=nt("arrow-up-from-line",Tme);const Cme=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Rme=nt("arrow-up",Cme);const Ame=[["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"}]],aC=nt("bell",Ame);const Ime=[["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"}]],GG=nt("brush",Ime);const Ome=[["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"}]],Dme=nt("bug",Ome);const jme=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],mr=nt("check",jme);const Lme=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],qs=nt("chevron-down",Lme);const $me=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],a0=nt("chevron-left",$me);const Mme=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],WG=nt("chevron-right",Mme);const Pme=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],zme=nt("chevron-up",Pme);const Ume=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Fme=nt("chevrons-up-down",Ume);const Bme=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],cU=nt("circle-minus",Bme);const Hme=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Fp=nt("clock",Hme);const Vme=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],iC=nt("code",Vme);const Gme=[["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"}]],Wme=nt("cog",Gme);const Kme=[["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"}]],Zme=nt("command",Kme);const Yme=[["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"}]],er=nt("copy",Yme);const qme=[["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"}]],i0=nt("database",qme);const Xme=[["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"}]],Mm=nt("download",Xme);const Jme=[["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"}]],Qme=nt("ellipsis-vertical",Jme);const ehe=[["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"}]],t_=nt("external-link",ehe);const the=[["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"}]],KG=nt("eye-off",the);const nhe=[["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"}]],n_=nt("eye",nhe);const rhe=[["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"}]],ahe=nt("file-code",rhe);const ihe=[["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"}]],ohe=nt("file-image",ihe);const she=[["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"}]],oC=nt("file-text",she);const lhe=[["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"}]],che=nt("file",lhe);const uhe=[["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"}]],dhe=nt("folder-open",uhe);const fhe=[["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"}]],phe=nt("globe",fhe);const mhe=[["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"}]],hhe=nt("grip-vertical",mhe);const ghe=[["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"}]],ZG=nt("hash",ghe);const bhe=[["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"}]],Bp=nt("history",bhe);const vhe=[["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"}]],YG=nt("key",vhe);const yhe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Fs=nt("loader-circle",yhe);const whe=[["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"}]],sC=nt("maximize-2",whe);const xhe=[["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"}]],Hp=nt("maximize",xhe);const She=[["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"}]],Ehe=nt("message-circle",She);const _he=[["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"}]],Vp=nt("message-square",_he);const khe=[["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"}]],qG=nt("minimize",khe);const The=[["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"}]],uU=nt("monitor",The);const Nhe=[["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"}]],Che=nt("moon",Nhe);const Rhe=[["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"}]],Ahe=nt("picture-in-picture",Rhe);const Ihe=[["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"}]],XG=nt("play",Ihe);const Ohe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],JG=nt("plus",Ohe);const Dhe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],dU=nt("rotate-ccw",Dhe);const jhe=[["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"}]],lC=nt("save",jhe);const Lhe=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Pd=nt("search",Lhe);const $he=[["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"}]],Mhe=nt("send",$he);const Phe=[["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"}]],zhe=nt("server",Phe);const Uhe=[["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"}]],_u=nt("settings",Uhe);const Fhe=[["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"}]],Bhe=nt("shield",Fhe);const Hhe=[["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"}]],Vhe=nt("sparkles",Hhe);const Ghe=[["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"}]],QG=nt("square-check-big",Ghe);const Whe=[["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"}]],Khe=nt("square-pen",Whe);const Zhe=[["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"}]],Yhe=nt("sun-dim",Zhe);const qhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],AS=nt("terminal",qhe);const Xhe=[["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"}]],Po=nt("trash-2",Xhe);const Jhe=[["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"}]],Qhe=nt("trash",Jhe);const ege=[["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"}]],Kl=nt("wrench",ege);const tge=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],no=nt("x",tge);const nge=[["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"}]],Gp=nt("zap",nge);function rge(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const age=e=>{switch(e){case"success":return sge;case"info":return cge;case"warning":return lge;case"error":return uge;default:return null}},ige=Array(12).fill(0),oge=({visible:e,className:t})=>Q.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},Q.createElement("div",{className:"sonner-spinner"},ige.map((n,a)=>Q.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),sge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Q.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),lge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Q.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),cge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Q.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),uge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Q.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),dge=Q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Q.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Q.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),fge=()=>{const[e,t]=Q.useState(document.hidden);return Q.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let r_=1;class pge{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:a,...r}=t,i=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:r_++,s=this.toasts.find(u=>u.id===i),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),s?this.toasts=this.toasts.map(u=>u.id===i?(this.publish({...u,...t,id:i,title:a}),{...u,...t,id:i,dismissible:c,title:a}):u):this.addToast({title:a,...r,dismissible:c,id:i}),i},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(a=>a({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let a;n.loading!==void 0&&(a=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const r=Promise.resolve(t instanceof Function?t():t);let i=a!==void 0,s;const c=r.then(async f=>{if(s=["resolve",f],Q.isValidElement(f))i=!1,this.create({id:a,type:"default",message:f});else if(hge(f)&&!f.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${f.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${f.status}`):n.description,E=typeof h=="object"&&!Q.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...E})}else if(f instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(f):n.error,g=typeof n.description=="function"?await n.description(f):n.description,E=typeof h=="object"&&!Q.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...E})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(f):n.success,g=typeof n.description=="function"?await n.description(f):n.description,E=typeof h=="object"&&!Q.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...E})}}).catch(async f=>{if(s=["reject",f],n.error!==void 0){i=!1;const m=typeof n.error=="function"?await n.error(f):n.error,h=typeof n.description=="function"?await n.description(f):n.description,v=typeof m=="object"&&!Q.isValidElement(m)?m:{message:m};this.create({id:a,type:"error",description:h,...v})}}).finally(()=>{i&&(this.dismiss(a),a=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((f,m)=>c.then(()=>s[0]==="reject"?m(s[1]):f(s[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:u}:Object.assign(a,{unwrap:u})},this.custom=(t,n)=>{const a=n?.id||r_++;return this.create({jsx:t(a),id:a,...n}),a},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const va=new pge,mge=(e,t)=>{const n=t?.id||r_++;return va.addToast({title:e,...t,id:n}),n},hge=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",gge=mge,bge=()=>va.toasts,vge=()=>va.getActiveToasts(),ct=Object.assign(gge,{success:va.success,info:va.info,warning:va.warning,error:va.error,custom:va.custom,message:va.message,promise:va.promise,dismiss:va.dismiss,loading:va.loading},{getHistory:bge,getToasts:vge});rge("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function hb(e){return e.label!==void 0}const yge=3,wge="24px",xge="16px",fU=4e3,Sge=356,Ege=14,_ge=45,kge=200;function zi(...e){return e.filter(Boolean).join(" ")}function Tge(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const Nge=e=>{var t,n,a,r,i,s,c,u,f;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:E,visibleToasts:x,heights:w,index:S,toasts:_,expanded:k,removeToast:N,defaultRichColors:C,closeButton:A,style:I,cancelButtonStyle:O,actionButtonStyle:M,className:j="",descriptionClassName:B="",duration:G,position:ee,gap:te,expandByDefault:ae,classNames:V,icons:q,closeButtonAriaLabel:H="Close toast"}=e,[ie,re]=Q.useState(null),[P,F]=Q.useState(null),[U,L]=Q.useState(!1),[$,W]=Q.useState(!1),[K,Y]=Q.useState(!1),[se,oe]=Q.useState(!1),[X,J]=Q.useState(!1),[le,pe]=Q.useState(0),[me,_e]=Q.useState(0),ze=Q.useRef(h.duration||G||fU),ue=Q.useRef(null),Pe=Q.useRef(null),Ye=S===0,fe=S+1<=x,De=h.type,He=h.dismissible!==!1,Ee=h.className||"",Ne=h.descriptionClassName||"",Ae=Q.useMemo(()=>w.findIndex(Ze=>Ze.toastId===h.id)||0,[w,h.id]),We=Q.useMemo(()=>{var Ze;return(Ze=h.closeButton)!=null?Ze:A},[h.closeButton,A]),ft=Q.useMemo(()=>h.duration||G||fU,[h.duration,G]),at=Q.useRef(0),yt=Q.useRef(0),xn=Q.useRef(0),pt=Q.useRef(null),[Gn,hn]=ee.split("-"),Ve=Q.useMemo(()=>w.reduce((Ze,vt,wt)=>wt>=Ae?Ze:Ze+vt.height,0),[w,Ae]),Ue=fge(),Se=h.invert||m,Oe=De==="loading";yt.current=Q.useMemo(()=>Ae*te+Ve,[Ae,Ve]),Q.useEffect(()=>{ze.current=ft},[ft]),Q.useEffect(()=>{L(!0)},[]),Q.useEffect(()=>{const Ze=Pe.current;if(Ze){const vt=Ze.getBoundingClientRect().height;return _e(vt),E(wt=>[{toastId:h.id,height:vt,position:h.position},...wt]),()=>E(wt=>wt.filter(kt=>kt.toastId!==h.id))}},[E,h.id]),Q.useLayoutEffect(()=>{if(!U)return;const Ze=Pe.current,vt=Ze.style.height;Ze.style.height="auto";const wt=Ze.getBoundingClientRect().height;Ze.style.height=vt,_e(wt),E(kt=>kt.find(et=>et.toastId===h.id)?kt.map(et=>et.toastId===h.id?{...et,height:wt}:et):[{toastId:h.id,height:wt,position:h.position},...kt])},[U,h.title,h.description,E,h.id,h.jsx,h.action,h.cancel]);const Ge=Q.useCallback(()=>{W(!0),pe(yt.current),E(Ze=>Ze.filter(vt=>vt.toastId!==h.id)),setTimeout(()=>{N(h)},kge)},[h,N,E,yt]);Q.useEffect(()=>{if(h.promise&&De==="loading"||h.duration===1/0||h.type==="loading")return;let Ze;return k||v||Ue?(()=>{if(xn.current<at.current){const kt=new Date().getTime()-at.current;ze.current=ze.current-kt}xn.current=new Date().getTime()})():ze.current!==1/0&&(at.current=new Date().getTime(),Ze=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),Ge()},ze.current)),()=>clearTimeout(Ze)},[k,v,h,De,Ue,Ge]),Q.useEffect(()=>{h.delete&&(Ge(),h.onDismiss==null||h.onDismiss.call(h,h))},[Ge,h.delete]);function lt(){var Ze;if(q?.loading){var vt;return Q.createElement("div",{className:zi(V?.loader,h==null||(vt=h.classNames)==null?void 0:vt.loader,"sonner-loader"),"data-visible":De==="loading"},q.loading)}return Q.createElement(oge,{className:zi(V?.loader,h==null||(Ze=h.classNames)==null?void 0:Ze.loader),visible:De==="loading"})}const Xe=h.icon||q?.[De]||age(De);var it,mt;return Q.createElement("li",{tabIndex:0,ref:Pe,className:zi(j,Ee,V?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,V?.default,V?.[De],h==null||(n=h.classNames)==null?void 0:n[De]),"data-sonner-toast":"","data-rich-colors":(it=h.richColors)!=null?it:C,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":U,"data-promise":!!h.promise,"data-swiped":X,"data-removed":$,"data-visible":fe,"data-y-position":Gn,"data-x-position":hn,"data-index":S,"data-front":Ye,"data-swiping":K,"data-dismissible":He,"data-type":De,"data-invert":Se,"data-swipe-out":se,"data-swipe-direction":P,"data-expanded":!!(k||ae&&U),"data-testid":h.testId,style:{"--index":S,"--toasts-before":S,"--z-index":_.length-S,"--offset":`${$?le:yt.current}px`,"--initial-height":ae?"auto":`${me}px`,...I,...h.style},onDragEnd:()=>{Y(!1),re(null),pt.current=null},onPointerDown:Ze=>{Ze.button!==2&&(Oe||!He||(ue.current=new Date,pe(yt.current),Ze.target.setPointerCapture(Ze.pointerId),Ze.target.tagName!=="BUTTON"&&(Y(!0),pt.current={x:Ze.clientX,y:Ze.clientY})))},onPointerUp:()=>{var Ze,vt,wt;if(se||!He)return;pt.current=null;const kt=Number(((Ze=Pe.current)==null?void 0:Ze.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Wn=Number(((vt=Pe.current)==null?void 0:vt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),et=new Date().getTime()-((wt=ue.current)==null?void 0:wt.getTime()),Lt=ie==="x"?kt:Wn,dn=Math.abs(Lt)/et;if(Math.abs(Lt)>=_ge||dn>.11){pe(yt.current),h.onDismiss==null||h.onDismiss.call(h,h),F(ie==="x"?kt>0?"right":"left":Wn>0?"down":"up"),Ge(),oe(!0);return}else{var nn,on;(nn=Pe.current)==null||nn.style.setProperty("--swipe-amount-x","0px"),(on=Pe.current)==null||on.style.setProperty("--swipe-amount-y","0px")}J(!1),Y(!1),re(null)},onPointerMove:Ze=>{var vt,wt,kt;if(!pt.current||!He||((vt=window.getSelection())==null?void 0:vt.toString().length)>0)return;const et=Ze.clientY-pt.current.y,Lt=Ze.clientX-pt.current.x;var dn;const nn=(dn=e.swipeDirections)!=null?dn:Tge(ee);!ie&&(Math.abs(Lt)>1||Math.abs(et)>1)&&re(Math.abs(Lt)>Math.abs(et)?"x":"y");let on={x:0,y:0};const gr=Nt=>1/(1.5+Math.abs(Nt)/20);if(ie==="y"){if(nn.includes("top")||nn.includes("bottom"))if(nn.includes("top")&&et<0||nn.includes("bottom")&&et>0)on.y=et;else{const Nt=et*gr(et);on.y=Math.abs(Nt)<Math.abs(et)?Nt:et}}else if(ie==="x"&&(nn.includes("left")||nn.includes("right")))if(nn.includes("left")&&Lt<0||nn.includes("right")&&Lt>0)on.x=Lt;else{const Nt=Lt*gr(Lt);on.x=Math.abs(Nt)<Math.abs(Lt)?Nt:Lt}(Math.abs(on.x)>0||Math.abs(on.y)>0)&&J(!0),(wt=Pe.current)==null||wt.style.setProperty("--swipe-amount-x",`${on.x}px`),(kt=Pe.current)==null||kt.style.setProperty("--swipe-amount-y",`${on.y}px`)}},We&&!h.jsx&&De!=="loading"?Q.createElement("button",{"aria-label":H,"data-disabled":Oe,"data-close-button":!0,onClick:Oe||!He?()=>{}:()=>{Ge(),h.onDismiss==null||h.onDismiss.call(h,h)},className:zi(V?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(mt=q?.close)!=null?mt:dge):null,(De||h.icon||h.promise)&&h.icon!==null&&(q?.[De]!==null||h.icon)?Q.createElement("div",{"data-icon":"",className:zi(V?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||lt():null,h.type!=="loading"?Xe:null):null,Q.createElement("div",{"data-content":"",className:zi(V?.content,h==null||(i=h.classNames)==null?void 0:i.content)},Q.createElement("div",{"data-title":"",className:zi(V?.title,h==null||(s=h.classNames)==null?void 0:s.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?Q.createElement("div",{"data-description":"",className:zi(B,Ne,V?.description,h==null||(c=h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),Q.isValidElement(h.cancel)?h.cancel:h.cancel&&hb(h.cancel)?Q.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ze=>{hb(h.cancel)&&He&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ze),Ge())},className:zi(V?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,Q.isValidElement(h.action)?h.action:h.action&&hb(h.action)?Q.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Ze=>{hb(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ze),!Ze.defaultPrevented&&Ge())},className:zi(V?.actionButton,h==null||(f=h.classNames)==null?void 0:f.actionButton)},h.action.label):null)};function pU(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Cge(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?xge:wge;function u(f){["top","right","bottom","left"].forEach(m=>{n[`${s}-${m}`]=typeof f=="number"?`${f}px`:f})}typeof a=="number"||typeof a=="string"?u(a):typeof a=="object"?["top","right","bottom","left"].forEach(f=>{a[f]===void 0?n[`${s}-${f}`]=c:n[`${s}-${f}`]=typeof a[f]=="number"?`${a[f]}px`:a[f]}):u(c)}),n}const e7=Q.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:f,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:E,style:x,visibleToasts:w=yge,toastOptions:S,dir:_=pU(),gap:k=Ege,icons:N,containerAriaLabel:C="Notifications"}=t,[A,I]=Q.useState([]),O=Q.useMemo(()=>a?A.filter(U=>U.toasterId===a):A.filter(U=>!U.toasterId),[A,a]),M=Q.useMemo(()=>Array.from(new Set([i].concat(O.filter(U=>U.position).map(U=>U.position)))),[O,i]),[j,B]=Q.useState([]),[G,ee]=Q.useState(!1),[te,ae]=Q.useState(!1),[V,q]=Q.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=Q.useRef(null),ie=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),re=Q.useRef(null),P=Q.useRef(!1),F=Q.useCallback(U=>{I(L=>{var $;return($=L.find(W=>W.id===U.id))!=null&&$.delete||va.dismiss(U.id),L.filter(({id:W})=>W!==U.id)})},[]);return Q.useEffect(()=>va.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{I(L=>L.map($=>$.id===U.id?{...$,delete:!0}:$))});return}setTimeout(()=>{q9.flushSync(()=>{I(L=>{const $=L.findIndex(W=>W.id===U.id);return $!==-1?[...L.slice(0,$),{...L[$],...U},...L.slice($+1)]:[U,...L]})})})}),[A]),Q.useEffect(()=>{if(g!=="system"){q(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:L})=>{q(L?"dark":"light")})}catch{U.addListener(({matches:$})=>{try{q($?"dark":"light")}catch(W){console.error(W)}})}},[g]),Q.useEffect(()=>{A.length<=1&&ee(!1)},[A]),Q.useEffect(()=>{const U=L=>{var $;if(s.every(Y=>L[Y]||L.code===Y)){var K;ee(!0),(K=H.current)==null||K.focus()}L.code==="Escape"&&(document.activeElement===H.current||($=H.current)!=null&&$.contains(document.activeElement))&&ee(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[s]),Q.useEffect(()=>{if(H.current)return()=>{re.current&&(re.current.focus({preventScroll:!0}),re.current=null,P.current=!1)}},[H.current]),Q.createElement("section",{ref:n,"aria-label":`${C} ${ie}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((U,L)=>{var $;const[W,K]=U.split("-");return O.length?Q.createElement("ol",{key:U,dir:_==="auto"?pU():_,tabIndex:-1,ref:H,className:f,"data-sonner-toaster":!0,"data-sonner-theme":V,"data-y-position":W,"data-x-position":K,style:{"--front-toast-height":`${(($=j[0])==null?void 0:$.height)||0}px`,"--width":`${Sge}px`,"--gap":`${k}px`,...x,...Cge(m,h)},onBlur:Y=>{P.current&&!Y.currentTarget.contains(Y.relatedTarget)&&(P.current=!1,re.current&&(re.current.focus({preventScroll:!0}),re.current=null))},onFocus:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||P.current||(P.current=!0,re.current=Y.relatedTarget)},onMouseEnter:()=>ee(!0),onMouseMove:()=>ee(!0),onMouseLeave:()=>{te||ee(!1)},onDragEnd:()=>ee(!1),onPointerDown:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},O.filter(Y=>!Y.position&&L===0||Y.position===U).map((Y,se)=>{var oe,X;return Q.createElement(Nge,{key:Y.id,icons:N,index:se,toast:Y,defaultRichColors:v,duration:(oe=S?.duration)!=null?oe:E,className:S?.className,descriptionClassName:S?.descriptionClassName,invert:r,visibleToasts:w,closeButton:(X=S?.closeButton)!=null?X:u,interacting:te,position:U,style:S?.style,unstyled:S?.unstyled,classNames:S?.classNames,cancelButtonStyle:S?.cancelButtonStyle,actionButtonStyle:S?.actionButtonStyle,closeButtonAriaLabel:S?.closeButtonAriaLabel,removeToast:F,toasts:O.filter(J=>J.position==Y.position),heights:j.filter(J=>J.position==Y.position),setHeights:B,expandByDefault:c,gap:k,expanded:G,swipeDirections:t.swipeDirections})})):null}))}),mU=Object.freeze(Object.defineProperty({__proto__:null,Toaster:e7,toast:ct},Symbol.toStringTag,{value:"Module"}));var o0="Dialog",[t7]=Ii(o0),[Rge,Oi]=t7(o0),n7=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:s=!0}=e,c=y.useRef(null),u=y.useRef(null),[f,m]=Lo({prop:a,defaultProp:r??!1,onChange:i,caller:o0});return d.jsx(Rge,{scope:t,triggerRef:c,contentRef:u,contentId:zr(),titleId:zr(),descriptionId:zr(),open:f,onOpenChange:m,onOpenToggle:y.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};n7.displayName=o0;var r7="DialogTrigger",a7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(r7,n),i=tn(t,r.triggerRef);return d.jsx(Ot.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":dC(r.open),...a,ref:i,onClick:Ke(e.onClick,r.onOpenToggle)})});a7.displayName=r7;var cC="DialogPortal",[Age,i7]=t7(cC,{forceMount:void 0}),o7=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Oi(cC,t);return d.jsx(Age,{scope:t,forceMount:n,children:y.Children.map(a,s=>d.jsx(za,{present:n||i.open,children:d.jsx($d,{asChild:!0,container:r,children:s})}))})};o7.displayName=cC;var Ov="DialogOverlay",s7=y.forwardRef((e,t)=>{const n=i7(Ov,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Oi(Ov,e.__scopeDialog);return i.modal?d.jsx(za,{present:a||i.open,children:d.jsx(Oge,{...r,ref:t})}):null});s7.displayName=Ov;var Ige=Gl("DialogOverlay.RemoveScroll"),Oge=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(Ov,n);return d.jsx(Dm,{as:Ige,allowPinchZoom:!0,shards:[r.contentRef],children:d.jsx(Ot.div,{"data-state":dC(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),Zl="DialogContent",l7=y.forwardRef((e,t)=>{const n=i7(Zl,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Oi(Zl,e.__scopeDialog);return d.jsx(za,{present:a||i.open,children:i.modal?d.jsx(Dge,{...r,ref:t}):d.jsx(jge,{...r,ref:t})})});l7.displayName=Zl;var Dge=y.forwardRef((e,t)=>{const n=Oi(Zl,e.__scopeDialog),a=y.useRef(null),r=tn(t,n.contentRef,a);return y.useEffect(()=>{const i=a.current;if(i)return Yy(i)},[]),d.jsx(c7,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ke(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ke(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ke(e.onFocusOutside,i=>i.preventDefault())})}),jge=y.forwardRef((e,t)=>{const n=Oi(Zl,e.__scopeDialog),a=y.useRef(!1),r=y.useRef(!1);return d.jsx(c7,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(a.current||n.triggerRef.current?.focus(),i.preventDefault()),a.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(a.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),c7=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=Oi(Zl,n),u=y.useRef(null),f=tn(t,u);return Fy(),d.jsxs(d.Fragment,{children:[d.jsx(Rm,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:d.jsx(Dd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":dC(c.open),...s,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Lge,{titleId:c.titleId}),d.jsx(Mge,{contentRef:u,descriptionId:c.descriptionId})]})]})}),uC="DialogTitle",u7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(uC,n);return d.jsx(Ot.h2,{id:r.titleId,...a,ref:t})});u7.displayName=uC;var d7="DialogDescription",f7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(d7,n);return d.jsx(Ot.p,{id:r.descriptionId,...a,ref:t})});f7.displayName=d7;var p7="DialogClose",m7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Oi(p7,n);return d.jsx(Ot.button,{type:"button",...a,ref:t,onClick:Ke(e.onClick,()=>r.onOpenChange(!1))})});m7.displayName=p7;function dC(e){return e?"open":"closed"}var h7="DialogTitleWarning",[fNe,g7]=Ece(h7,{contentName:Zl,titleName:uC,docsSlug:"dialog"}),Lge=({titleId:e})=>{const t=g7(h7),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
105
105
|
|
|
106
106
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
107
107
|
|
|
@@ -1668,7 +1668,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1668
1668
|
<\/script>
|
|
1669
1669
|
</body>
|
|
1670
1670
|
</html>`,EY=1,E2=2,_Y=3,_2=4,kY=5,k2=Symbol.for("quilt.threads.serialize"),Eke=Symbol.for("quilt.threads.transferable");class _ke extends AbortController{constructor(...t){super();const n=t.find(a=>a.aborted);if(n)this.abort(n.reason);else{const a=i=>this.abort(i.target.reason),r={signal:this.signal};for(const i of t)i.addEventListener("abort",a,r)}}}class T2 extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let kke="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function TY(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let a=0;a<e;a++)t+=kke[63&n[a]];return t}var sp,iu,lp,Jb,ik,NY;class Tke{constructor(){hi(this,ik),hi(this,sp,new Map),hi(this,iu,new Map),hi(this,lp,new Map),hi(this,Jb,new WeakMap)}get(t){return zn(this,iu).get(t)}release(t){const n=zn(this,iu).get(t);return n&&(zn(this,iu).delete(t),zn(this,sp).delete(n)),!!n}serialize(t){let n=zn(this,sp).get(t);return n==null&&(n=TY(),zn(this,sp).set(t,n),zn(this,iu).set(n,t)),n}deserialize(t,n){var a,r;let i=(a=zn(this,lp).get(t))==null?void 0:a.deref();return i||(i=(...s)=>{if(!zn(this,lp).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((c,u,f)=>{n.messages.send([_Y,c,t,u],f)},s)},(r=Dr(this,ik,NY).call(this,n))==null||r.register(i,t),zn(this,lp).set(t,new WeakRef(i)),i)}}sp=new WeakMap,iu=new WeakMap,lp=new WeakMap,Jb=new WeakMap,ik=new WeakSet,NY=function(e){let t=zn(this,Jb).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([kY,n])}),zn(this,Jb).set(e,t)),t};function Nke(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function N2(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const aE="_@f",C2="_@i";var Ep,_p,Ya,Qb,Ss;class Cke{constructor(t){hi(this,Ya),hi(this,Ep),hi(this,_p),rk(this,Ep,t?.serialize),rk(this,_p,t?.deserialize)}serialize(t,n,a){return Dr(this,Ya,Qb).call(this,t,n,a)}deserialize(t,n){return Dr(this,Ya,Ss).call(this,t,n)}}Ep=new WeakMap,_p=new WeakMap,Ya=new WeakSet,Qb=function(e,t,n,a=new Map,r=!1){if(e==null)return e;if(a.has(e))return a.get(e);if(a.set(e,void 0),typeof e=="object"){if(zn(this,Ep)&&!r){const c=zn(this,Ep).call(this,e,u=>Dr(this,Ya,Qb).call(this,u,t,n,a,!0),t,n);if(c!==void 0)return a.set(e,c),c}if(e[Eke])return n?.push(e),a.set(e,e),e;const i=c=>Dr(this,Ya,Qb).call(this,c,t,n,a);if(typeof e[k2]=="function"){const c=e[k2]({serialize:i});return a.set(e,c),c}if(Array.isArray(e)){const c=e.map(u=>i(u));return a.set(e,c),c}if(e instanceof Map){const c=[...e.entries()].map(([f,m])=>[i(f),i(m)]),u=new Map(c);return a.set(e,u),u}if(e instanceof Set){const c=[...e].map(f=>i(f)),u=new Set(c);return a.set(e,u),u}const s=Nke(e);if(N2(e)||s){const c={};for(const u of Object.keys(e))c[u]=i(e[u]);return s&&(c.next??(c.next=i(e.next.bind(e))),c.return??(c.return=i(e.return.bind(e))),c.throw??(c.throw=i(e.throw.bind(e))),c[C2]=!0),a.set(e,c),c}}if(typeof e=="function"){const i=t.functions.serialize(e,t,n),s={[aE]:i};return a.set(e,s),s}return a.set(e,e),e},Ss=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if(zn(this,_p)&&!n){const r=zn(this,_p).call(this,e,i=>Dr(this,Ya,Ss).call(this,i,t,!0),t);if(r!==void 0)return r}if(e==null)return e;if(Array.isArray(e))return e.map(r=>Dr(this,Ya,Ss).call(this,r,t));if(e instanceof Map)return new Map([...e].map(([r,i])=>[Dr(this,Ya,Ss).call(this,r,t),Dr(this,Ya,Ss).call(this,i,t)]));if(e instanceof Set)return new Set([...e].map(r=>Dr(this,Ya,Ss).call(this,r,t)));if(aE in e)return t.functions.deserialize(e[aE],t);if(!N2(e))return e;const a={};for(const r of Object.keys(e))r===C2?a[Symbol.asyncIterator]=()=>a:a[r]=Dr(this,Ya,Ss).call(this,e[r],t);return a}return e};var ou,Ll,Es,ok,CY,sk,RY;class Rke{constructor(t,{imports:n,exports:a,functions:r=new Tke,serialization:i=new Cke,signal:s}={}){hi(this,Es),hi(this,ou),hi(this,Ll,new Map);var c,u,f,m;this.messages=t,rk(this,ou,s?new _ke(s):new AbortController),this.exports=a??{},this.imports=Ake(Dr(this,Es,CY).bind(this),n),this.functions=r,this.serialization=i,(u=(c=this.functions).start)==null||u.call(c,this),(m=(f=this.serialization).start)==null||m.call(f,this),this.signal.addEventListener("abort",()=>{for(const h of zn(this,Ll).keys())Dr(this,Es,sk).call(this,h,void 0,new T2);zn(this,Ll).clear()},{once:!0}),t.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case EY:{const[,v,E,x]=g,w=this.exports[E]??(()=>{throw new Error(`No '${E}' method is exported from this thread`)});await Dr(this,Es,ok).call(this,w,x,(S,_,k)=>{this.messages.send([E2,v,S,_],k)});break}case _Y:{const[,v,E,x]=g,w=this.functions.get(E,this)??Ike;await Dr(this,Es,ok).call(this,w,x,(S,_,k)=>{this.messages.send([_2,v,S,_],k)});break}case E2:case _2:{Dr(this,Es,sk).call(this,...g.slice(1));break}case kY:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return zn(this,ou).signal}get closed(){return zn(this,ou).signal.aborted}close(){zn(this,ou).abort()}call(t,n){if(this.closed)return Promise.reject(new T2);const a=[],r=this.serialization.serialize(n,this,a),i=TY(),s=Dr(this,Es,RY).call(this,i);return t(i,r,a),s}}ou=new WeakMap,Ll=new WeakMap,Es=new WeakSet,ok=async function(e,t,n){try{const a=this.functions.call?await this.functions.call(e,t,this):await e(...this.serialization.deserialize(t,this)),r=[],i=this.serialization.serialize(a,this,r);n(i,void 0,r)}catch(a){n(void 0,this.serialization.serialize(a,this))}},CY=function(e){return(...t)=>{try{if(typeof e!="string"&&typeof e!="number")throw new Error(`Can’t call a symbol method on a thread: ${e.toString()}`);return this.call((n,a,r)=>{this.messages.send([EY,n,e,a],r)},t)}catch(n){return Promise.reject(n)}}},sk=function(...e){const t=e[0],n=zn(this,Ll).get(t);n&&(n(...e),zn(this,Ll).delete(t))},RY=function(e){const t=new Promise((n,a)=>{zn(this,Ll).set(e,(r,i,s)=>{s==null?n(this.serialization.deserialize(i,this)):a(this.serialization.deserialize(s,this))})});return Object.defineProperty(t,Symbol.asyncIterator,{async*value(){const n=await t;Object.defineProperty(n,Symbol.asyncIterator,{value:()=>n}),yield*n}}),t};function Ake(e,t){let n;if(t==null){if(typeof Proxy!="function")throw new Error("You must pass an array of callable methods in environments without Proxies.");const a=new Map;n=new Proxy({},{get(r,i){if(a.has(i))return a.get(i);const s=e(i);return a.set(i,s),s}})}else{n={};for(const a of t)Object.defineProperty(n,a,{value:e(a),writable:!1,configurable:!0,enumerable:!0})}return n}function Ike(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const Oke="quilt.threads.ping",R2="quilt.threads.pong";function Dke(e,{targetOrigin:t="*"}={}){let n=!1;const a=function(i,s){e.postMessage(i,t,s)},r=new Promise(i=>{const s=new AbortController;globalThis.window.addEventListener("message",c=>{c.source===e&&c.data===R2&&(n=!0,s.abort(),i())},{signal:s.signal}),s.signal.addEventListener("abort",()=>i(),{once:!0}),a(Oke)});return{send(i,s){return n?a(i,s):r.then(()=>{if(n)return a(i,s)})},listen(i,{signal:s}){self.addEventListener("message",c=>{c.source===e&&c.data!==R2&&i(c.data)},{signal:s})}}}class jke extends Rke{constructor(t,{targetOrigin:n="*",...a}={}){super(Dke(t.contentWindow,{targetOrigin:n}),a),this.iframe=t}}const AY=Q.forwardRef(({content:e,children:t,...n},a)=>d.jsx("span",{ref:a,...n,children:e||t}));AY.displayName="UIText";const IY=Q.forwardRef(({label:e,onPress:t,onClick:n,children:a,...r},i)=>d.jsx("button",{ref:i,onClick:s=>{t&&t(),n&&n(s)},style:{padding:"8px 16px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},...r,children:e||a}));IY.displayName="UIButton";const OY=Q.forwardRef(({direction:e="vertical",spacing:t="8",align:n="stretch",justify:a="flex-start",children:r,...i},s)=>d.jsx("div",{ref:s,style:{display:"flex",flexDirection:e==="horizontal"?"row":"column",gap:`${t}px`,alignItems:n,justifyContent:a},...i,children:r}));OY.displayName="UIStack";const DY=Q.forwardRef(({src:e,alt:t,width:n,height:a,children:r,...i},s)=>d.jsx("img",{ref:s,src:e,alt:t,width:n,height:a,style:{maxWidth:"100%",height:"auto",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)"},...i}));DY.displayName="UIImage";const TD={name:"basic",elements:[{tagName:"ui-text",component:AY,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:IY,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:OY,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:DY,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},Lke=({receiver:e})=>{const t=y.useRef(null);return y.useEffect(()=>{if(t.current)return e.connect(t.current),()=>{e.disconnect()}},[e]),d.jsx("div",{ref:t,"data-testid":"standard-dom-renderer-container"})},$ke=({resource:e,library:t,remoteElements:n=[],onUIAction:a})=>{const r=y.useRef(null),i=y.useRef(null),[s,c]=y.useState(null),u=y.useMemo(()=>(e.mimeType||"").includes("framework=react")?"react":"webcomponents",[e.mimeType]),f=`${t?.name}-${u}`,{receiver:m,components:h}=y.useMemo(()=>{switch(u){case"react":{const v=new pke,E=t||TD,x=new Map;return E&&E.elements.forEach(w=>{const S=yke(w.component);x.set(w.tagName,S)}),{receiver:v,components:x}}case"webcomponents":default:return{receiver:new mke,components:null}}},[e,t,n]);y.useEffect(()=>{function v(E){var x;if(r.current&&E.source===r.current.contentWindow){const w=E.data;if(!w)return;(x=a?.(w))==null||x.catch(S=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",S)})}}return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[a]),y.useEffect(()=>{const v=i.current;return i.current=null,()=>{v?.close()}},[f]);const g=()=>{const v=r.current;if(!v||i.current)return;const E=new jke(v);i.current=E;const{code:x,error:w}=ake(e);if(w){c(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 s?d.jsx("p",{className:"text-red-500",children:s}):d.jsxs(d.Fragment,{children:[d.jsx("iframe",{ref:r,srcDoc:Ske,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},f),u==="react"&&h?d.jsx(xke,{receiver:m,components:h}):d.jsx(Lke,{receiver:m})]})};function Mke(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 ND=e=>{const{resource:t,onUIAction:n,supportedContentTypes:a,htmlProps:r,remoteDomProps:i}=e,s=Mke(t);if(a&&s&&!a.includes(s))return d.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",s,"."]});switch(s){case"rawHtml":case"externalUrl":return d.jsx(bY,{resource:t,onUIAction:n,...r});case"remoteDom":return d.jsx($ke,{resource:t,onUIAction:n,library:i?.library||TD,...i});default:return d.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};ND.displayName="UIResourceRenderer";const Pke={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},zke={tagName:"ui-text",remoteAttributes:["content"]},Uke={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},Fke={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},Bke=y.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(ND,{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 A2({toolName:e,toolArgs:t,result:n,serverId:a,readResource:r,toolMeta:i}){const[s,c]=y.useState(null);y.useEffect(()=>{console.log("[ToolResultRenderer] Rendering:",{toolName:e,hasToolMeta:!!i,outputTemplate:i?.["openai/outputTemplate"],hasResult:!!n,hasServerId:!!a,hasReadResource:!!r})},[e,i,n,a,r]);const u=y.useMemo(()=>{if(typeof n=="string")try{return JSON.parse(n)}catch(v){return console.error("[ToolResultRenderer] Failed to parse result:",v),n}return n},[n]),f=y.useMemo(()=>!!i?.["openai/outputTemplate"],[i]),m=y.useMemo(()=>!!(u?.content&&Array.isArray(u.content)&&u.content.some(v=>v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType==="text/html+skybridge")),[u]),h=y.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(y.useEffect(()=>{if(h){c(h);return}if(f&&i&&r){const v=i["openai/outputTemplate"];console.log("[ToolResultRenderer] Fetching resource for Apps SDK tool:",v),r(v).then(E=>{console.log("[ToolResultRenderer] Resource fetched:",E),E?.contents&&Array.isArray(E.contents)&&E.contents.length>0?c(E.contents[0]):console.warn("[ToolResultRenderer] No contents in fetched resource:",E)}).catch(E=>{console.error("[ToolResultRenderer] Failed to fetch resource:",E)})}},[h,f,i,r]),(f||m)&&s&&a&&r)return d.jsx(xD,{componentUrl:s.uri,toolName:e,toolArgs:t,toolResult:u,serverId:a,readResource:r,noWrapper:!0,className:"my-4",showConsole:!1});if((f||m)&&!s)return d.jsx("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:d.jsx(ki,{className:"size-5"})});if(f&&(!a||!r))return console.error("[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:",{toolName:e,hasServerId:!!a,hasReadResource:!!r}),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 v of u.content)v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType!=="text/html+skybridge"&&g.push(v.resource);return g.length>0?d.jsx(d.Fragment,{children:g.map(v=>d.jsx(Bke,{resource:v},`${e}-mcp-ui-${v.uri}`))}):(console.log("[ToolResultRenderer] Not rendering (no UI resources found):",{toolName:e,isAppsSdkTool:f,hasAppsSdkComponent:m,hasResourceData:!!s,contentLength:u?.content?.length}),null)}function Hke({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 Vke=y.memo(({messages:e,isLoading:t,serverId:n,readResource:a,tools:r})=>{const i=y.useRef(null),s=f=>r?.find(h=>h.name===f)?._meta;y.useEffect(()=>{e.length>0&&i.current&&i.current.scrollIntoView({behavior:t?"auto":"smooth",block:"start"})},[e.length,t]);const c=t&&(()=>{if(e.length===0)return!0;const 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(Hke,{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 v=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(p2,{content:h.text||"",timestamp:g===f.parts.length-1?f.timestamp:void 0,_isStreaming:u(f)},v):h.type==="tool-invocation"&&h.toolInvocation?d.jsxs("div",{children:[d.jsx(m2,{toolName:h.toolInvocation.toolName,args:h.toolInvocation.args,result:h.toolInvocation.result,state:h.toolInvocation.result?"result":"call"}),h.toolInvocation.result&&d.jsx(A2,{toolName:h.toolInvocation.toolName,toolArgs:h.toolInvocation.args,result:h.toolInvocation.result,serverId:n,readResource:a,toolMeta:s(h.toolInvocation.toolName)})]},v):null}):d.jsxs(d.Fragment,{children:[d.jsx(p2,{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(m2,{toolName:h.toolName,args:h.args,result:h.result,state:h.result?"result":"call"}),h.result&&d.jsx(A2,{toolName:h.toolName,toolArgs:h.args,result:h.result,serverId:n,readResource:a,toolMeta:s(h.toolName)})]},g)})})]})},f.id):null}),c&&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(uSe,{duration:2,spread:1,children:"Thinking..."})})})})})}),d.jsx("div",{ref:i})]})});function jY(e){let t=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);t=(t<<5)-t+a,t=t&t}return Math.abs(t).toString(16)}function Gke({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:a}){const[r,i]=y.useState([]),[s,c]=y.useState(!1),u=y.useCallback(async m=>{if(!m.trim()||!t||!a)return;const h={id:`user-${Date.now()}`,role:"user",content:m.trim(),timestamp:Date.now()};i(g=>[...g,h]),c(!0);try{let g=n;if(n?.type==="oauth")try{const N="mcp:auth",C=jY(e),A=`${N}_${C}_tokens`,I=localStorage.getItem(A);if(I){const O=JSON.parse(I);g={...n,oauthTokens:O}}else console.warn("No OAuth tokens found in localStorage for key:",A)}catch(N){console.warn("Failed to retrieve OAuth tokens:",N)}const v=await fetch("/inspector/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServerUrl:e,llmConfig:t,authConfig:g,messages:[...r,h].map(N=>({role:N.role,content:N.content}))})});if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);const E=`assistant-${Date.now()}`;let x="";const w=[];i(N=>[...N,{id:E,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);const S=v.body?.getReader(),_=new TextDecoder;if(!S)throw new Error("No response body");let k="";for(;;){const{done:N,value:C}=await S.read();if(N)break;k+=_.decode(C,{stream:!0});const A=k.split(`
|
|
1671
|
-
`);k=A.pop()||"";for(const I of A)if(I.trim()&&I.startsWith("data: "))try{const O=JSON.parse(I.slice(6));if(console.log("[Client received event]",O.type,O.toolName||O.content?.slice?.(0,30)),O.type==="message")console.log("[Message started]",O.id);else if(O.type==="text"){x+=O.content;const M=w[w.length-1];M&&M.type==="text"?M.text=x:w.push({type:"text",text:x}),console.log("[Parts after text]",w.length,"parts, text length:",x.length),i(j=>j.map(B=>B.id===E?{...B,parts:[...w]}:B))}else if(O.type==="tool-call")x&&(x=""),w.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",w.length,"parts, tool:",O.toolName),i(M=>M.map(j=>j.id===E?{...j,parts:[...w]}:j));else if(O.type==="tool-result"){const M=w.find(j=>j.type==="tool-invocation"&&j.toolInvocation?.toolName===O.toolName&&!j.toolInvocation?.result);M&&M.toolInvocation?(M.toolInvocation.result=O.result,M.toolInvocation.state="result",console.log("[Parts after tool-result]",w.length,"parts, updated:",O.toolName),i(j=>j.map(B=>B.id===E?{...B,parts:[...w]}:B))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",w.length),i(M=>M.map(j=>j.id===E?{...j,parts:[...w],content:""}:j));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,I)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const x=g;x.status&&(v=`HTTP ${x.status}: ${v}`),(x.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const E={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(x=>[...x,E])}finally{c(!1)}},[t,a,e,r,n]),f=y.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:f}}function Wke({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=y.useState([]),[s,c]=y.useState(!1),u=y.useRef(null),f=y.useRef(null),m=y.useRef(null),h=y.useCallback(async v=>{if(!v.trim()||!t||!n)return;const E={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(S=>[...S,E]),c(!0),u.current=new AbortController;const x=Date.now();let w=0;try{const S=`assistant-${Date.now()}`;let _="";const k=[];if(i(N=>[...N,{id:S,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 N;if(t.provider==="openai"){const{ChatOpenAI:C}=await Mr(async()=>{const{ChatOpenAI:A}=await import("./index-CSZqqrHs.js");return{ChatOpenAI:A}},__vite__mapDeps([0,1,2,3,4,5,6]));N=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:C}=await Mr(async()=>{const{ChatAnthropic:A}=await import("./index-BSuQO5pd.js");return{ChatAnthropic:A}},__vite__mapDeps([7,3,2,4,1,6]));N=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:C}=await Mr(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-BOIA9kd1.js");return{ChatGoogleGenerativeAI:A}},__vite__mapDeps([8,3,2,4,1,5]));N=new C({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:N,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!f.current||f.current.llm!==m.current.instance){const{MCPAgent:N}=await Mr(async()=>{const{MCPAgent:C}=await import("./browser-BWolhM7l.js");return{MCPAgent:C}},__vite__mapDeps([9,6,2,4]));f.current=new N({llm:m.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await f.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",f.current.conversationHistory?.length);for await(const N of f.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(N.event==="on_chat_model_stream"&&N.data?.chunk?.text){const C=N.data.chunk.text;if(typeof C=="string"&&C.length>0){_+=C;const A=k[k.length-1];A&&A.type==="text"?A.text=_:k.push({type:"text",text:_}),i(I=>I.map(O=>O.id===S?{...O,parts:[...k]}:O))}}else if(N.event==="on_tool_start"){_&&(_="");let C={};N.data?.input?C=N.data.input:N.data?.tool_input?C=N.data.tool_input:N.data&&(C=N.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:N.name,eventData:N.data,extractedArgs:C}),w++,k.push({type:"tool-invocation",toolInvocation:{toolName:N.name||"unknown",args:C,state:"pending"}}),i(A=>A.map(I=>I.id===S?{...I,parts:[...k]}:I))}else if(N.event==="on_tool_end"){const C=k.find(A=>A.type==="tool-invocation"&&A.toolInvocation?.toolName===N.name&&!A.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:N.name,hasToolPart:!!C,output:N.data?.output}),C&&C.toolInvocation){let A=N.data?.output;if(A?.kwargs?.content&&typeof A.kwargs.content=="string")try{A=JSON.parse(A.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),A=A.kwargs.content}else if(A?.content&&typeof A.content=="string")try{A=JSON.parse(A.content)}catch{A=A.content}C.toolInvocation.result=A,C.toolInvocation.state="result";const I=A?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:N.name,hasMeta:!!A?._meta,hasStructuredContent:!!A?.structuredContent,appsSdkUri:I}),I&&typeof I=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",I);try{const O=await a(I);console.log("[useChatMessagesClientSide] Resource fetched:",O);const M=A?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const j=O.contents.map(G=>({type:"resource",resource:G}));console.log("[useChatMessagesClientSide] Created MCP resources:",j);const B={...A,content:[...A.content||[],...j],structuredContent:M};C.toolInvocation.result=B,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}i(O=>O.map(M=>M.id===S?{...M,parts:[...k]}:M))}}}i(N=>N.map(C=>C.id===S?{...C,parts:[...k],content:""}:C)),t&&_r.getInstance().capture(new oU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:w,success:!0,executionMode:"client-side",duration:Date.now()-x})).catch(()=>{})}catch(S){console.error("Client-side agent error:",S);let _="Unknown error occurred";if(S instanceof Error){_=S.message;const N=S;N.status&&(_=`HTTP ${N.status}: ${_}`),(N.code===401||_.includes("401")||_.includes("Unauthorized"))&&(_="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&_r.getInstance().capture(new oU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:w,success:!1,executionMode:"client-side",duration:Date.now()-x,error:_})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${_}`,timestamp:Date.now()};i(N=>[...N,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=y.useCallback(()=>{i([]),f.current&&f.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const I2={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function LY({mcpServerUrl:e}){const[t,n]=y.useState(null),[a,r]=y.useState(null),[i,s]=y.useState(!1),[c,u]=y.useState("openai"),[f,m]=y.useState(""),[h,g]=y.useState(I2.openai),v=y.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(j){return console.error("Failed to load API keys:",j),{}}return{}},[]),E=y.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[x,w]=y.useState("none"),[S,_]=y.useState(""),[k,N]=y.useState(""),[C,A]=y.useState("");y.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),j=v();if(M)try{const B=JSON.parse(M);n(B),u(B.provider),m(j[B.provider]||B.apiKey||""),g(B.model)}catch(B){console.error("Failed to load LLM config:",B)}},[v]),y.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const j=JSON.parse(M);r(j),w(j.type),j.username&&_(j.username),j.password&&N(j.password),j.token&&A(j.token)}catch(j){console.error("Failed to load auth config:",j)}else try{const j="mcp:auth",B=jY(e),G=`${j}_${B}_tokens`;localStorage.getItem(G)&&(r({type:"oauth"}),w("oauth"))}catch(j){console.error("Failed to check for OAuth tokens:",j)}},[e]),y.useEffect(()=>{g(I2[c]);const M=v();m(M[c]||"")},[c,v]);const I=y.useCallback(()=>{if(!f.trim())return;const M=v();M[c]=f,E(M);const j={provider:c,apiKey:f,model:h},B={type:x,...x==="basic"&&{username:S.trim(),password:k.trim()},...x==="bearer"&&{token:C.trim()}};n(j),r(B),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(j)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(B)),s(!1)},[c,f,h,x,S,k,C,v,E]),O=y.useCallback(()=>{n(null),r(null);const M=v();delete M[c],E(M),m(""),_(""),N(""),A(""),w("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,E]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:f,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:I,clearConfig:O}}function Kke({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=y.useState(""),s=y.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:f,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:E,tempModel:x,setTempModel:w,saveLLMConfig:S,clearConfig:_}=LY({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},N=Gke({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),C=Wke(k),{messages:A,isLoading:I,sendMessage:O,clearMessages:M}=n?C:N;OK({onNewChat:M}),y.useEffect(()=>{c&&A.length===0&&s.current&&s.current.focus()},[c,A.length]),y.useEffect(()=>{!I&&A.length>0&&s.current&&s.current.focus()},[I,A.length]);const j=y.useCallback(()=>{r.trim()&&(O(r),i(""))},[r,O]),B=y.useCallback(ee=>{ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),j())},[j]),G=y.useCallback(()=>{_(),M()},[_,M]);return c&&A.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(D_,{open:f,onOpenChange:m,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSave:S,onClear:G,showClearButton:!0,buttonLabel:"Change API Key"})}),d.jsx(lSe,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:I,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:B,onSubmit:ee=>{ee.preventDefault(),j()},onConfigDialogOpenChange:m})]}):d.jsxs("div",{className:"flex flex-col h-full relative",children:[d.jsx(iSe,{llmConfig:c,hasMessages:A.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSaveConfig:S,onClearConfig:G}),d.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?d.jsx(Vke,{messages:A,isLoading:I,serverId:e.url,readResource:a,tools:e.tools}):d.jsx(cSe,{onConfigureClick:()=>m(!0)})}),c&&d.jsx(oSe,{inputValue:r,isConnected:t,isLoading:I,textareaRef:s,onInputChange:i,onKeyDown:B,onSendMessage:j})]})}const O0=y.createContext(null);O0.displayName="PanelGroupContext";const qn={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"},CD=10,Ul=y.useLayoutEffect,O2=kd.useId,Zke=typeof O2=="function"?O2:()=>null;let Yke=0;function RD(e=null){const t=Zke(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+Yke++),e??n.current}function $Y({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:f,onExpand:m,onResize:h,order:g,style:v,tagName:E="div",...x}){const w=y.useContext(O0);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:S,expandPanel:_,getPanelSize:k,getPanelStyle:N,groupId:C,isPanelCollapsed:A,reevaluatePanelConstraints:I,registerPanel:O,resizePanel:M,unregisterPanel:j}=w,B=RD(s),G=y.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:a,defaultSize:r,maxSize:c,minSize:u},id:B,idIsFromProps:s!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),Ul(()=>{const{callbacks:te,constraints:ae}=G.current,V={...ae};G.current.id=B,G.current.idIsFromProps=s!==void 0,G.current.order=g,te.onCollapse=f,te.onExpand=m,te.onResize=h,ae.collapsedSize=n,ae.collapsible=a,ae.defaultSize=r,ae.maxSize=c,ae.minSize=u,(V.collapsedSize!==ae.collapsedSize||V.collapsible!==ae.collapsible||V.maxSize!==ae.maxSize||V.minSize!==ae.minSize)&&I(G.current,V)}),Ul(()=>{const te=G.current;return O(te),()=>{j(te)}},[g,B,O,j]),y.useImperativeHandle(i,()=>({collapse:()=>{S(G.current)},expand:te=>{_(G.current,te)},getId(){return B},getSize(){return k(G.current)},isCollapsed(){return A(G.current)},isExpanded(){return!A(G.current)},resize:te=>{M(G.current,te)}}),[S,_,k,A,B,M]);const ee=N(G.current,r);return y.createElement(E,{...x,children:e,className:t,id:B,style:{...ee,...v},[qn.groupId]:C,[qn.panel]:"",[qn.panelCollapsible]:a||void 0,[qn.panelId]:B,[qn.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const MY=y.forwardRef((e,t)=>y.createElement($Y,{...e,forwardedRef:t}));$Y.displayName="Panel";MY.displayName="forwardRef(Panel)";let lk=null,ev=-1,Ns=null;function qke(e,t,n){const a=(t&BY)!==0,r=(t&HY)!==0,i=(t&VY)!==0,s=(t&GY)!==0;if(t){if(a)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Xke(){Ns!==null&&(document.head.removeChild(Ns),lk=null,Ns=null,ev=-1)}function iE(e,t,n){var a,r;const i=qke(e,t);if(lk!==i){if(lk=i,Ns===null&&(Ns=document.createElement("style"),document.head.appendChild(Ns)),ev>=0){var s;(s=Ns.sheet)===null||s===void 0||s.removeRule(ev)}ev=(a=(r=Ns.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function PY(e){return e.type==="keydown"}function zY(e){return e.type.startsWith("pointer")}function UY(e){return e.type.startsWith("mouse")}function D0(e){if(zY(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(UY(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Jke(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Qke(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 eTe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:L2(e),b:L2(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;$t(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:j2(D2(n.a)),b:j2(D2(n.b))};if(r.a===r.b){const i=a.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let c=i.length;for(;c--;){const u=i[c];if(u===s.a)return 1;if(u===s.b)return-1}}return Math.sign(r.a-r.b)}const tTe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function nTe(e){var t;const n=getComputedStyle((t=FY(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function rTe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||nTe(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"||tTe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function D2(e){let t=e.length;for(;t--;){const n=e[t];if($t(n,"Missing node"),rTe(n))return n}return null}function j2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function L2(e){const t=[];for(;e;)t.push(e),e=FY(e);return t}function FY(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const BY=1,HY=2,VY=4,GY=8,aTe=Jke()==="coarse";let wi=[],Au=!1,Cs=new Map,j0=new Map;const lm=new Set;function iTe(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=Cs.get(s))!==null&&i!==void 0?i:0;return Cs.set(s,u+1),lm.add(c),ty(),function(){var m;j0.delete(e),lm.delete(c);const h=(m=Cs.get(s))!==null&&m!==void 0?m:1;if(Cs.set(s,h-1),ty(),h===1&&Cs.delete(s),wi.includes(c)){const g=wi.indexOf(c);g>=0&&wi.splice(g,1),L0(),r("up",!0,null)}}}function oTe(e){const{target:t}=e,{x:n,y:a}=D0(e);Au=!0,AD({target:t,x:n,y:a}),ty(),wi.length>0&&(ny("down",e),L0(),e.preventDefault(),WY(t)||e.stopImmediatePropagation())}function oE(e){const{x:t,y:n}=D0(e);if(Au&&e.type!=="pointerleave"&&e.buttons===0&&(Au=!1,ny("up",e)),!Au){const{target:a}=e;AD({target:a,x:t,y:n})}ny("move",e),L0(),wi.length>0&&e.preventDefault()}function sE(e){const{target:t}=e,{x:n,y:a}=D0(e);j0.clear(),Au=!1,wi.length>0&&(e.preventDefault(),WY(t)||e.stopImmediatePropagation()),ny("up",e),AD({target:t,x:n,y:a}),L0(),ty()}function WY(e){let t=e;for(;t;){if(t.hasAttribute(qn.resizeHandle))return!0;t=t.parentElement}return!1}function AD({target:e,x:t,y:n}){wi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),lm.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:f,right:m,top:h}=c,g=aTe?s.coarse:s.fine;if(t>=f-g&&t<=m+g&&n>=h-g&&n<=u+g){if(a!==null&&document.contains(a)&&i!==a&&!i.contains(a)&&!a.contains(i)&&eTe(a,i)>0){let E=a,x=!1;for(;E&&!E.contains(i);){if(Qke(E.getBoundingClientRect(),c)){x=!0;break}E=E.parentElement}if(x)return}wi.push(r)}})}function lE(e,t){j0.set(e,t)}function L0(){let e=!1,t=!1;wi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;j0.forEach(a=>{n|=a}),e&&t?iE("intersection",n):e?iE("horizontal",n):t?iE("vertical",n):Xke()}let cE;function ty(){var e;(e=cE)===null||e===void 0||e.abort(),cE=new AbortController;const t={capture:!0,signal:cE.signal};lm.size&&(Au?(wi.length>0&&Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",sE,t),r.addEventListener("pointerleave",oE,t),r.addEventListener("pointermove",oE,t))}),Cs.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",sE,t),r.addEventListener("pointercancel",sE,t)})):Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",oTe,t),r.addEventListener("pointermove",oE,t))}))}function ny(e,t){lm.forEach(n=>{const{setResizeHandlerState:a}=n,r=wi.includes(n);a(e,r,t)})}function sTe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function $t(e,t){if(!e)throw console.error(t),Error(t)}function ec(e,t,n=CD){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Ro(e,t,n=CD){return ec(e,t,n)===0}function Da(e,t,n){return ec(e,t,n)===0}function lTe(e,t,n){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++){const r=e[a],i=t[a];if(!Da(r,i,n))return!1}return!0}function wu({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];$t(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(ec(n,c)<0)if(i){const u=(r+c)/2;ec(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(CD)),n}function cp({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Da(e,0))return t;const s=[...t],[c,u]=a;$t(c!=null,"Invalid first pivot index"),$t(u!=null,"Invalid second pivot index");let f=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];$t(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if($t(w!=null,`Previous layout not found for panel index ${h}`),Da(w,v)){const S=x-w;ec(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const h=e<0?c:u,g=n[h];$t(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if($t(w!=null,`Previous layout not found for panel index ${h}`),Da(w,x)){const S=w-v;ec(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const x=t[g];$t(x!=null,`Previous layout not found for panel index ${g}`);const S=wu({panelConstraints:n,panelIndex:g,size:100})-x;if(v+=S,g+=h,g<0||g>=n.length)break}const E=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-E:E}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(f),E=t[g];$t(E!=null,`Previous layout not found for panel index ${g}`);const x=E-v,w=wu({panelConstraints:n,panelIndex:g,size:x});if(!Da(E,w)&&(f+=E-w,s[g]=w,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(lTe(r,s))return r;{const h=e<0?u:c,g=t[h];$t(g!=null,`Previous layout not found for panel index ${h}`);const v=g+f,E=wu({panelConstraints:n,panelIndex:h,size:v});if(s[h]=E,!Da(E,v)){let x=v-E,S=e<0?u:c;for(;S>=0&&S<n.length;){const _=s[S];$t(_!=null,`Previous layout not found for panel index ${S}`);const k=_+x,N=wu({panelConstraints:n,panelIndex:S,size:k});if(Da(_,N)||(x-=N-_,s[S]=N),Da(x,0))break;e>0?S--:S++}}}const m=s.reduce((h,g)=>g+h,0);return Da(m,100)?s:r}function cTe({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];$t(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:E=100,minSize:x=0}=v;g===c?(a=x,r=E):(i+=x,s+=E)});const u=Math.min(r,100-i),f=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:f,valueNow:m}}function cm(e,t=document){return Array.from(t.querySelectorAll(`[${qn.resizeHandleId}][data-panel-group-id="${e}"]`))}function KY(e,t,n=document){const r=cm(e,n).findIndex(i=>i.getAttribute(qn.resizeHandleId)===t);return r??null}function ZY(e,t,n){const a=KY(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function uTe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function YY(e,t=document){if(uTe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function $0(e,t=document){const n=t.querySelector(`[${qn.resizeHandleId}="${e}"]`);return n||null}function dTe(e,t,n,a=document){var r,i,s,c;const u=$0(t,a),f=cm(e,a),m=u?f.indexOf(u):-1,h=(r=(i=n[m])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,g=(s=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[h,g]}function fTe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){y.useRef({didWarnAboutMissingResizeHandle:!1}),Ul(()=>{if(!i)return;const c=cm(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:f,valueMin:m,valueNow:h}=cTe({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];$t(v,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",v.id),g.setAttribute("aria-valuemax",""+Math.round(f)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{c.forEach((u,f)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,a,r,i]),y.useEffect(()=>{if(!i)return;const c=t.current;$t(c,"Eager values not found");const{panelDataArray:u}=c,f=YY(n,i);$t(f!=null,`No group found for id "${n}"`);const m=cm(n,i);$t(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(qn.resizeHandleId);$t(v,"Resize handle element has no handle id attribute");const[E,x]=dTe(n,v,u,i);if(E==null||x==null)return()=>{};const w=S=>{if(!S.defaultPrevented)switch(S.key){case"Enter":{S.preventDefault();const _=u.findIndex(k=>k.id===E);if(_>=0){const k=u[_];$t(k,`No panel data found for index ${_}`);const N=a[_],{collapsedSize:C=0,collapsible:A,minSize:I=0}=k.constraints;if(N!=null&&A){const O=cp({delta:Da(N,C)?I-C:C-N,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:ZY(n,v,i),prevLayout:a,trigger:"keyboard"});a!==O&&s(O)}}break}}};return g.addEventListener("keydown",w),()=>{g.removeEventListener("keydown",w)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,a,r,s])}function $2(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 qY(e,t){const n=e==="horizontal",{x:a,y:r}=D0(t);return n?a:r}function pTe(e,t,n,a,r){const i=n==="horizontal",s=$0(t,r);$t(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(qn.groupId);$t(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const f=qY(n,e),m=YY(c,r);$t(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(f-u)/g*100}function mTe(e,t,n,a,r,i){if(PY(e)){const s=n==="horizontal";let c=0;e.shiftKey?c=100:r!=null?c=r:c=10;let u=0;switch(e.key){case"ArrowDown":u=s?0:c;break;case"ArrowLeft":u=s?-c:0;break;case"ArrowRight":u=s?c:0;break;case"ArrowUp":u=s?0:-c;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return a==null?0:pTe(e,t,n,a,i)}function hTe({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let a=0,r=100;for(let i=0;i<e.length;i++){const s=n[i];$t(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;c!=null&&(a++,t[i]=c,r-=c)}for(let i=0;i<e.length;i++){const s=n[i];$t(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;if(c!=null)continue;const u=e.length-a,f=r/u;a++,t[i]=f,r-=f}return t}function Jc(e,t,n){t.forEach((a,r)=>{const i=e[r];$t(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:f=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:E}=s;E&&E(a,h),m&&(g||v)&&(v&&(h==null||Ro(h,f))&&!Ro(a,f)&&v(),g&&(h==null||!Ro(h,f))&&Ro(a,f)&&g())}})}function Tb(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 gTe({defaultSize:e,dragState:t,layout:n,panelData:a,panelIndex:r,precision:i=3}){const s=n[r];let c;return s==null?c=e!=null?e.toFixed(i):"1":a.length===1?c="1":c=s.toFixed(i),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function bTe(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function M2(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 XY(e){return`react-resizable-panels:${e}`}function JY(e){return e.map(t=>{const{constraints:n,id:a,idIsFromProps:r,order:i}=t;return r?a:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function QY(e,t){try{const n=XY(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function vTe(e,t,n){var a,r;const i=(a=QY(e,n))!==null&&a!==void 0?a:{},s=JY(t);return(r=i[s])!==null&&r!==void 0?r:null}function yTe(e,t,n,a,r){var i;const s=XY(e),c=JY(t),u=(i=QY(e,r))!==null&&i!==void 0?i:{};u[c]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{r.setItem(s,JSON.stringify(u))}catch(f){console.error(f)}}function P2({layout:e,panelConstraints:t}){const n=[...e],a=n.reduce((i,s)=>i+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Da(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];$t(s!=null,`No layout data found for index ${i}`);const c=100/a*s;n[i]=c}let r=0;for(let i=0;i<t.length;i++){const s=n[i];$t(s!=null,`No layout data found for index ${i}`);const c=wu({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Da(r,0))for(let i=0;i<t.length;i++){const s=n[i];$t(s!=null,`No layout data found for index ${i}`);const c=s+r,u=wu({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Da(r,0)))break}return n}const wTe=100,up={getItem:e=>(M2(up),up.getItem(e)),setItem:(e,t)=>{M2(up),up.setItem(e,t)}},z2={};function eq({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=up,style:f,tagName:m="div",...h}){const g=RD(i),v=y.useRef(null),[E,x]=y.useState(null),[w,S]=y.useState([]),_=sTe(),k=y.useRef({}),N=y.useRef(new Map),C=y.useRef(0),A=y.useRef({autoSaveId:e,direction:a,dragState:E,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),I=y.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});y.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),y.useImperativeHandle(r,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:U}=I.current;return U},setLayout:U=>{const{onLayout:L}=A.current,{layout:$,panelDataArray:W}=I.current,K=P2({layout:U,panelConstraints:W.map(Y=>Y.constraints)});$2($,K)||(S(K),I.current.layout=K,L&&L(K),Jc(W,K,k.current))}}),[]),Ul(()=>{A.current.autoSaveId=e,A.current.direction=a,A.current.dragState=E,A.current.id=g,A.current.onLayout=s,A.current.storage=u}),fTe({committedValuesRef:A,eagerValuesRef:I,groupId:g,layout:w,panelDataArray:I.current.panelDataArray,setLayout:S,panelGroupElement:v.current}),y.useEffect(()=>{const{panelDataArray:U}=I.current;if(e){if(w.length===0||w.length!==U.length)return;let L=z2[e];L==null&&(L=bTe(yTe,wTe),z2[e]=L);const $=[...U],W=new Map(N.current);L(e,$,W,w,u)}},[e,w,u]),y.useEffect(()=>{});const O=y.useCallback(U=>{const{onLayout:L}=A.current,{layout:$,panelDataArray:W}=I.current;if(U.constraints.collapsible){const K=W.map(X=>X.constraints),{collapsedSize:Y=0,panelSize:se,pivotIndices:oe}=kl(W,U,$);if($t(se!=null,`Panel size not found for panel "${U.id}"`),!Ro(se,Y)){N.current.set(U.id,se);const J=su(W,U)===W.length-1?se-Y:Y-se,le=cp({delta:J,initialLayout:$,panelConstraints:K,pivotIndices:oe,prevLayout:$,trigger:"imperative-api"});Tb($,le)||(S(le),I.current.layout=le,L&&L(le),Jc(W,le,k.current))}}},[]),M=y.useCallback((U,L)=>{const{onLayout:$}=A.current,{layout:W,panelDataArray:K}=I.current;if(U.constraints.collapsible){const Y=K.map(pe=>pe.constraints),{collapsedSize:se=0,panelSize:oe=0,minSize:X=0,pivotIndices:J}=kl(K,U,W),le=L??X;if(Ro(oe,se)){const pe=N.current.get(U.id),me=pe!=null&&pe>=le?pe:le,ze=su(K,U)===K.length-1?oe-me:me-oe,ue=cp({delta:ze,initialLayout:W,panelConstraints:Y,pivotIndices:J,prevLayout:W,trigger:"imperative-api"});Tb(W,ue)||(S(ue),I.current.layout=ue,$&&$(ue),Jc(K,ue,k.current))}}},[]),j=y.useCallback(U=>{const{layout:L,panelDataArray:$}=I.current,{panelSize:W}=kl($,U,L);return $t(W!=null,`Panel size not found for panel "${U.id}"`),W},[]),B=y.useCallback((U,L)=>{const{panelDataArray:$}=I.current,W=su($,U);return gTe({defaultSize:L,dragState:E,layout:w,panelData:$,panelIndex:W})},[E,w]),G=y.useCallback(U=>{const{layout:L,panelDataArray:$}=I.current,{collapsedSize:W=0,collapsible:K,panelSize:Y}=kl($,U,L);return $t(Y!=null,`Panel size not found for panel "${U.id}"`),K===!0&&Ro(Y,W)},[]),ee=y.useCallback(U=>{const{layout:L,panelDataArray:$}=I.current,{collapsedSize:W=0,collapsible:K,panelSize:Y}=kl($,U,L);return $t(Y!=null,`Panel size not found for panel "${U.id}"`),!K||ec(Y,W)>0},[]),te=y.useCallback(U=>{const{panelDataArray:L}=I.current;L.push(U),L.sort(($,W)=>{const K=$.order,Y=W.order;return K==null&&Y==null?0:K==null?-1:Y==null?1:K-Y}),I.current.panelDataArrayChanged=!0,_()},[_]);Ul(()=>{if(I.current.panelDataArrayChanged){I.current.panelDataArrayChanged=!1;const{autoSaveId:U,onLayout:L,storage:$}=A.current,{layout:W,panelDataArray:K}=I.current;let Y=null;if(U){const oe=vTe(U,K,$);oe&&(N.current=new Map(Object.entries(oe.expandToSizes)),Y=oe.layout)}Y==null&&(Y=hTe({panelDataArray:K}));const se=P2({layout:Y,panelConstraints:K.map(oe=>oe.constraints)});$2(W,se)||(S(se),I.current.layout=se,L&&L(se),Jc(K,se,k.current))}}),Ul(()=>{const U=I.current;return()=>{U.layout=[]}},[]);const ae=y.useCallback(U=>{let L=!1;const $=v.current;return $&&window.getComputedStyle($,null).getPropertyValue("direction")==="rtl"&&(L=!0),function(K){K.preventDefault();const Y=v.current;if(!Y)return()=>null;const{direction:se,dragState:oe,id:X,keyboardResizeBy:J,onLayout:le}=A.current,{layout:pe,panelDataArray:me}=I.current,{initialLayout:_e}=oe??{},ze=ZY(X,U,Y);let ue=mTe(K,U,se,oe,J,Y);const Pe=se==="horizontal";Pe&&L&&(ue=-ue);const Ye=me.map(He=>He.constraints),fe=cp({delta:ue,initialLayout:_e??pe,panelConstraints:Ye,pivotIndices:ze,prevLayout:pe,trigger:PY(K)?"keyboard":"mouse-or-touch"}),De=!Tb(pe,fe);(zY(K)||UY(K))&&C.current!=ue&&(C.current=ue,!De&&ue!==0?Pe?lE(U,ue<0?BY:HY):lE(U,ue<0?VY:GY):lE(U,0)),De&&(S(fe),I.current.layout=fe,le&&le(fe),Jc(me,fe,k.current))}},[]),V=y.useCallback((U,L)=>{const{onLayout:$}=A.current,{layout:W,panelDataArray:K}=I.current,Y=K.map(pe=>pe.constraints),{panelSize:se,pivotIndices:oe}=kl(K,U,W);$t(se!=null,`Panel size not found for panel "${U.id}"`);const J=su(K,U)===K.length-1?se-L:L-se,le=cp({delta:J,initialLayout:W,panelConstraints:Y,pivotIndices:oe,prevLayout:W,trigger:"imperative-api"});Tb(W,le)||(S(le),I.current.layout=le,$&&$(le),Jc(K,le,k.current))},[]),q=y.useCallback((U,L)=>{const{layout:$,panelDataArray:W}=I.current,{collapsedSize:K=0,collapsible:Y}=L,{collapsedSize:se=0,collapsible:oe,maxSize:X=100,minSize:J=0}=U.constraints,{panelSize:le}=kl(W,U,$);le!=null&&(Y&&oe&&Ro(le,K)?Ro(K,se)||V(U,se):le<J?V(U,J):le>X&&V(U,X))},[V]),H=y.useCallback((U,L)=>{const{direction:$}=A.current,{layout:W}=I.current;if(!v.current)return;const K=$0(U,v.current);$t(K,`Drag handle element not found for id "${U}"`);const Y=qY($,L);x({dragHandleId:U,dragHandleRect:K.getBoundingClientRect(),initialCursorPosition:Y,initialLayout:W})},[]),ie=y.useCallback(()=>{x(null)},[]),re=y.useCallback(U=>{const{panelDataArray:L}=I.current,$=su(L,U);$>=0&&(L.splice($,1),delete k.current[U.id],I.current.panelDataArrayChanged=!0,_())},[_]),P=y.useMemo(()=>({collapsePanel:O,direction:a,dragState:E,expandPanel:M,getPanelSize:j,getPanelStyle:B,groupId:g,isPanelCollapsed:G,isPanelExpanded:ee,reevaluatePanelConstraints:q,registerPanel:te,registerResizeHandle:ae,resizePanel:V,startDragging:H,stopDragging:ie,unregisterPanel:re,panelGroupElement:v.current}),[O,E,a,M,j,B,g,G,ee,q,te,ae,V,H,ie,re]),F={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return y.createElement(O0.Provider,{value:P},y.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...F,...f},[qn.group]:"",[qn.groupDirection]:a,[qn.groupId]:g}))}const tq=y.forwardRef((e,t)=>y.createElement(eq,{...e,forwardedRef:t}));eq.displayName="PanelGroup";tq.displayName="forwardRef(PanelGroup)";function su(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function kl(e,t,n){const a=su(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function xTe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){y.useEffect(()=>{if(e||n==null||a==null)return;const r=$0(t,a);if(r==null)return;const i=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const c=r.getAttribute(qn.groupId);$t(c,`No group element found for id "${c}"`);const u=cm(c,a),f=KY(c,t,a);$t(f!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?f>0?f-1:u.length-1:f+1<u.length?f+1:0;u[m].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[a,e,t,n])}function nq({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:f,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...E}){var x,w;const S=y.useRef(null),_=y.useRef({onClick:s,onDragging:c,onPointerDown:f,onPointerUp:m});y.useEffect(()=>{_.current.onClick=s,_.current.onDragging=c,_.current.onPointerDown=f,_.current.onPointerUp=m});const k=y.useContext(O0);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:N,groupId:C,registerResizeHandle:A,startDragging:I,stopDragging:O,panelGroupElement:M}=k,j=RD(r),[B,G]=y.useState("inactive"),[ee,te]=y.useState(!1),[ae,V]=y.useState(null),q=y.useRef({state:B});Ul(()=>{q.current.state=B}),y.useEffect(()=>{if(n)V(null);else{const P=A(j);V(()=>P)}},[n,j,A]);const H=(x=a?.coarse)!==null&&x!==void 0?x:15,ie=(w=a?.fine)!==null&&w!==void 0?w:5;y.useEffect(()=>{if(n||ae==null)return;const P=S.current;$t(P,"Element ref not attached");let F=!1;return iTe(j,P,N,{coarse:H,fine:ie},(L,$,W)=>{if(!$){G("inactive");return}switch(L){case"down":{G("drag"),F=!1,$t(W,'Expected event to be defined for "down" action'),I(j,W);const{onDragging:K,onPointerDown:Y}=_.current;K?.(!0),Y?.();break}case"move":{const{state:K}=q.current;F=!0,K!=="drag"&&G("hover"),$t(W,'Expected event to be defined for "move" action'),ae(W);break}case"up":{G("hover"),O();const{onClick:K,onDragging:Y,onPointerUp:se}=_.current;Y?.(!1),se?.(),F||K?.();break}}})},[H,N,n,ie,A,j,ae,I,O]),xTe({disabled:n,handleId:j,resizeHandler:ae,panelGroupElement:M});const re={touchAction:"none",userSelect:"none"};return y.createElement(v,{...E,children:e,className:t,id:r,onBlur:()=>{te(!1),i?.()},onFocus:()=>{te(!0),u?.()},ref:S,role:"separator",style:{...re,...h},tabIndex:g,[qn.groupDirection]:N,[qn.groupId]:C,[qn.resizeHandle]:"",[qn.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[qn.resizeHandleEnabled]:!n,[qn.resizeHandleId]:j,[qn.resizeHandleState]:B})}nq.displayName="PanelResizeHandle";function sa({className:e,...t}){return d.jsx(tq,{"data-slot":"resizable-panel-group",className:Me("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function In({...e}){return d.jsx(MY,{"data-slot":"resizable-panel",...e})}function xi({withHandle:e,className:t,...n}){return d.jsx(nq,{"data-slot":"resizable-handle",className:Me("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(hhe,{className:"size-2.5"})})})}function th({className:e,...t}){return d.jsx("kbd",{"data-slot":"kbd",className:Me("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 STe({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,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(Tn,{ref:u,placeholder:"Search notifications...",value:t,onChange:f=>i(f.target.value),onBlur:s,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(hr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(Pd,{className:"h-4 w-4"})})}),d.jsxs(It,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(th,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(Po,{className:"h-4 w-4"})})}),d.jsx(It,{side:"bottom",children:"Clear all"})]})})]})}function tl({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return d.jsx("button",{id:e,type:"button",onClick:c,className:Me("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:[a&&d.jsx("div",{className:"flex-shrink-0 mt-1",children:d.jsx("div",{className:Me("p-2.5 rounded-full transition-colors",t?"bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600"),children:a})}),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:Me("font-medium truncate font-mono text-sm"),children:r})}),i&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function ETe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Md,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>d.jsx(tl,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=r(s.timestamp),f=s.params&&Object.keys(s.params).length>0?Object.keys(s.params).length:0,m=f>0?` | ${f} param${f>1?"s":""}`:"";return u+m})(),onClick:()=>n(s)},s.id))})}function _Te({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){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(Fp,{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(iC,{className:"h-4 w-4 mr-1"}):d.jsx(GG,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,children:s?d.jsx(mr,{className:"h-4 w-4"}):d.jsx(er,{className:"h-4 w-4"})}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,children:d.jsx(Mm,{className:"h-4 w-4"})}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:i,children:d.jsx(Hp,{className:"h-4 w-4"})}),c&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,children:d.jsx(no,{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(Qn,{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(aC,{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 ry(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<60?"just now":r<60?`${r}m ago`:i<24?`${i}h ago`:s<7?`${s}d ago`:new Date(e).toLocaleDateString()}function kTe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,E]=y.useState(!0),[x,w]=y.useState(!1),[S,_]=y.useState(!0),[k,N]=y.useState(!1),C=y.useRef(null),A=y.useRef(null),I=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const q=C.current;if(!q)return;const H=()=>{q.scrollTop>0&&(O.current=!0,E(!1))};return q.addEventListener("scroll",H),()=>q.removeEventListener("scroll",H)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const M=y.useCallback(()=>{f.trim()||w(!1)},[f]),j=y.useMemo(()=>{if(!f.trim())return e;const q=f.toLowerCase();return e.filter(H=>H.method.toLowerCase().includes(q)||JSON.stringify(H.params||{}).toLowerCase().includes(q))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const q=H=>{const ie=H.target;if(ie.tagName==="INPUT"||ie.tagName==="TEXTAREA"||ie.contentEditable==="true"||H.metaKey||H.ctrlKey||H.altKey)return;const P=j;if(H.key==="ArrowDown")H.preventDefault(),g(F=>{const U=F+1;return U>=P.length?0:U});else if(H.key==="ArrowUp")H.preventDefault(),g(F=>{const U=F-1;return U<0?P.length-1:U});else if(H.key==="Enter"&&h>=0){H.preventDefault();const F=j[h];F&&B(F)}};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[h,j]),y.useEffect(()=>{if(h>=0){const q=`notification-${j[h]?.id}`,H=document.getElementById(q);H&&H.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,j]);const B=y.useCallback(q=>{u(q)},[]),G=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),ee=y.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)),N(!0),setTimeout(()=>N(!1),2e3)}catch(q){console.error("[NotificationsTab] Failed to copy notification:",q)}},[c]),te=y.useCallback(()=>{if(c)try{const q=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),H=URL.createObjectURL(q),ie=document.createElement("a");ie.href=H,ie.download=`notification-${Date.now()}.json`,document.body.appendChild(ie),ie.click(),document.body.removeChild(ie),URL.revokeObjectURL(H)}catch(q){console.error("[NotificationsTab] Failed to download notification:",q)}},[c]),ae=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(q){console.error("[NotificationsTab] Failed to toggle fullscreen:",q)}},[]),V=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:ry}:null;return s?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(In,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(In,{defaultSize:75,minSize:30,children:[d.jsx(STe,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:j.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onClearAll:G,searchInputRef:I}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(ETe,{notifications:j,selectedNotification:c,onNotificationSelect:B,focusedIndex:h,formatRelativeTime:ry,listRef:C})})]})})}),d.jsx(xi,{}),d.jsx(In,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(_Te,{notification:V,previewMode:S,onTogglePreview:()=>_(!S),onCopy:ee,onDownload:te,onFullscreen:ae,onClose:()=>u(null),isCopied:k})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(aC,{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 rq({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:f="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,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(Tn,{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?a:r}),w&&d.jsxs(d.Fragment,{children:[d.jsx(hr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:d.jsx(Pd,{className:"h-4 w-4"})})}),d.jsxs(It,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(th,{children:"F"})]})]})]})]})}),d.jsxs(Le,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[w?d.jsx(c,{}):d.jsx(u,{}),d.jsx("span",{className:"hidden sm:inline",children:w?r:a}),w&&s>0&&d.jsx(hr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function U2({prompts:e,selectedPrompt:t,onPromptSelect:n,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(Vp,{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((r,i)=>d.jsx(tl,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:d.jsx(Vp,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&d.jsxs(hr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[r.arguments.length," args"]}),onClick:()=>n(r)},r.name))})}function F2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:f}){return d.jsx(rq,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:Vp,secondaryIcon:Fp,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:f})}function B2({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,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(Fp,{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((i,s)=>d.jsx(tl,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:d.jsx(Fp,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function TTe({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.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 i=s=>{const c=s.name,u=t[c],f=typeof u=="string"?u:JSON.stringify(u);return s.type==="boolean"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.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:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),d.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Tn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Jl,{id:c,value:f,onChange:m=>{try{const h=JSON.parse(m.target.value);n(c,h)}catch{n(c,m.target.value)}},placeholder:s.description||`Enter ${c} as JSON`,className:"font-mono text-sm min-h-[100px]"}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Tn,{id:c,value:f,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return d.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function H2({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return y.useEffect(()=>{const c=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&a&&(u.preventDefault(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,a,i]),e?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:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?d.jsxs(d.Fragment,{children:[d.jsx(ki,{className:"mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):d.jsxs(d.Fragment,{children:[d.jsx(XG,{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:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[d.jsx(lC,{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(TTe,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):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 NTe(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function CTe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function RTe(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 ATe({message:e,index:t}){const[n,a]=y.useState(!1),r=async()=>{const s=RTe(e.content);await navigator.clipboard.writeText(s),a(!0),setTimeout(()=>a(!1),2e3)},i=()=>{const s=e.content;return typeof s=="string"?d.jsx(Xb,{content:s}):s.type==="text"&&s.text?d.jsx(Xb,{content:s.text}):s.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: ",s.mimeType||"unknown type"]}),s.data&&d.jsx("img",{src:`data:${s.mimeType};base64,${s.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):s.type==="resource"&&s.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:s.resource.uri})]}),s.resource.text&&d.jsx("div",{className:"mt-2",children:d.jsx(Xb,{content:s.resource.text})})]}):d.jsx("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:d.jsx("code",{children:JSON.stringify(s,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(hr,{variant:NTe(e.role),children:CTe(e.role)}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-6 px-2",title:"Copy message content",children:n?d.jsx(mr,{className:"h-3.5 w-3.5"}):d.jsx(er,{className:"h-3.5 w-3.5"})})]}),d.jsx("div",{className:"px-4 py-3",children:i()})]})}function ITe(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<10?"now":a<60?`${a}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${s}d ago`}function OTe(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 V2({results:e,copiedResult:t,previewMode:n=!0,onCopy:a,onDelete:r,onFullscreen:i,onTogglePreview:s,onMaximize:c,isMaximized:u=!1}){const[f,m]=y.useState(0),[h,g]=y.useState(""),[v,E]=y.useState(!0),x=e[0],w=x?e.filter(C=>C.promptName===x.promptName):[],S=w[f]||w[0],_=e.findIndex(C=>C===S);if(y.useEffect(()=>{w.length>0&&f>=w.length&&m(0)},[w.length,f]),y.useEffect(()=>{const C=()=>{S&&g(ITe(S.timestamp))};C();const A=setInterval(C,1e3);return()=>clearInterval(A)},[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(Md,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const k=S.error||OTe(S.result),N="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(Gp,{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"]})]}),N&&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 ${v?"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 ${v?"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(Bp,{className:"h-3 w-3 text-gray-400"}),d.jsxs(Gi,{value:f.toString(),onValueChange:C=>m(parseInt(C)),children:[d.jsx(Ki,{className:"h-7 w-[120px] text-xs",children:d.jsx(Wi,{})}),d.jsx(Zi,{children:w.map((C,A)=>d.jsx(Er,{value:A.toString(),children:A===0?"Latest":`${A+1} call ago`},A))})]})]}),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:()=>a(_,S.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?d.jsx(mr,{className:"h-4 w-4"}):d.jsx(er,{className:"h-4 w-4"})}),r&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>r(_),className:"h-7 w-7 p-0",title:"Delete result",children:d.jsx(Po,{className:"h-4 w-4"})}),i&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>i(_),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:d.jsx(Hp,{className:"h-4 w-4"})}),c&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0 hidden sm:flex",title:u?"Restore":"Maximize",children:u?d.jsx(qG,{className:"h-4 w-4"}):d.jsx(Hp,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:k?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:k})]}):v&&N?d.jsx("div",{className:"space-y-3",children:S.result.messages.map((C,A)=>d.jsx(ATe,{message:C,index:A},A))}):d.jsx(Qn,{data:S.result,filename:`prompt-result-${S.promptName}-${Date.now()}.json`})})]})})})}function ID({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=y.useState([]),i=y.useRef(null),[s,c]=y.useState(new Set),[u]=y.useState(""),f=v=>{c(E=>{const x=new Set(E);return x.has(v)?x.delete(v):x.add(v),x})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const E=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});E.ok||console.warn("[RPC Logger] Failed to clear server buffer:",E.status)}catch(v){console.warn("[RPC Logger] Error clearing server buffer:",v)}},h=y.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);y.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),y.useEffect(()=>{t?.(a.length)},[a.length,t]),y.useEffect(()=>{let v=null;try{const E=new URLSearchParams;E.set("replay","50"),E.set("_t",Date.now().toString()),e&&e.length>0&&E.set("serverIds",e.join(","));const x=`/inspector/api/rpc/stream?${E.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",x),v=new globalThis.EventSource(x),v.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},v.onmessage=w=>{try{const S=JSON.parse(w.data);if(!S||S.type!=="rpc")return;const{serverId:_,direction:k,message:N,timestamp:C}=S,A=N,I=typeof A?.method=="string"?A.method:A?.result!==void 0?"result":A?.error!==void 0?"error":"unknown",O={id:`${C??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof _=="string"?_:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:I,timestamp:C??new Date().toISOString(),payload:N};console.log("[RPC Logger] Received RPC event:",{method:I,direction:k,serverId:_}),r(M=>{const j=[O,...M].slice(0,1e3);return t?.(j.length),j})}catch(S){console.error("[RPC Logger] Error parsing SSE message:",S)}},v.onerror=w=>{console.error("[RPC Logger] SSE connection error:",w);try{v?.close()}catch{}}}catch(E){console.error("[RPC Logger] Failed to create SSE connection:",E)}return()=>{try{v?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=y.useMemo(()=>{let v=a;if(e&&e.length>0){const E=new Set(e);v=v.filter(x=>E.has(x.serverId))}if(u.trim()){const E=u.toLowerCase();v=v.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 v=[...v].sort((E,x)=>new Date(x.timestamp).getTime()-new Date(E.timestamp).getTime()),v},[a,u,e]);return d.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:d.jsx("div",{ref:i,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(v=>{const E=s.has(v.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(v.id),children:[d.jsx("div",{className:"flex-shrink-0",children:E?d.jsx(qs,{className:"h-3 w-3 text-muted-foreground transition-transform"}):d.jsx(WG,{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(v.timestamp).toLocaleTimeString()}),d.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${v.direction==="RECEIVE"?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"bg-green-500/10 text-green-600 dark:text-green-400"}`,title:v.direction==="RECEIVE"?"Incoming":"Outgoing",children:v.direction==="RECEIVE"?d.jsx(kme,{className:"h-3 w-3"}):d.jsx(Nme,{className:"h-3 w-3"})}),d.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.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(Qn,{data:v.payload})})})})]},v.id)})})})}const G2="mcp-inspector-saved-prompts";function aq({ref:e,prompts:t,callPrompt:n,serverId:a,isConnected:r}){const[i,s]=y.useState(null),[c,u]=y.useState(null),{selectedPromptName:f,setSelectedPromptName:m}=oc(),[h,g]=y.useState({}),[v,E]=y.useState([]),[x,w]=y.useState(!1),[S,_]=y.useState(null),[k,N]=y.useState(""),[C,A]=y.useState("prompts"),[I,O]=y.useState([]),[M,j]=y.useState(!1),[B,G]=y.useState(""),[ee,te]=y.useState(!1),[ae,V]=y.useState(-1),q=y.useRef(null),[H,ie]=y.useState(!1),[re,P]=y.useState("list"),[F,U]=y.useState(0),[L,$]=y.useState(!0),[W,K]=y.useState(!1),Y=y.useRef(null),se=y.useRef(null),oe=y.useRef(null),X=y.useRef(null);y.useEffect(()=>{const Ne=()=>{ie(window.innerWidth<1024)};return Ne(),window.addEventListener("resize",Ne),()=>window.removeEventListener("resize",Ne)},[]),y.useEffect(()=>{P(i?"detail":"list")},[i]),y.useEffect(()=>{H&&v.length>0&&!x&&P("response")},[v,x,H]),y.useImperativeHandle(e,()=>({focusSearch:()=>{te(!0),setTimeout(()=>{q.current&&q.current.focus()},0)},blurSearch:()=>{N(""),te(!1),q.current&&q.current.blur()}})),y.useEffect(()=>{try{const Ne=localStorage.getItem(G2);if(Ne){const Ae=JSON.parse(Ne);O(Ae)}}catch(Ne){console.error("[PromptsTab] Failed to load saved prompts:",Ne)}},[]);const J=y.useCallback(Ne=>{try{localStorage.setItem(G2,JSON.stringify(Ne))}catch(Ae){console.error("[PromptsTab] Failed to save prompts:",Ae)}},[]);y.useEffect(()=>{ee&&q.current&&q.current.focus()},[ee]);const le=y.useCallback(()=>{k.trim()||te(!1)},[k]),pe=y.useMemo(()=>{if(!k.trim())return t;const Ne=k.toLowerCase();return t.filter(Ae=>Ae.name.toLowerCase().includes(Ne)||Ae.description?.toLowerCase().includes(Ne))},[t,k]),me=y.useCallback(Ne=>{s(Ne);const Ae={};Ne.arguments&&Ne.arguments.forEach(We=>{We.default!==void 0?Ae[We.name]=We.default:We.type==="string"?Ae[We.name]="":We.type==="number"?Ae[We.name]=0:We.type==="boolean"?Ae[We.name]=!1:We.type==="array"?Ae[We.name]=[]:We.type==="object"&&(Ae[We.name]={})}),g(Ae)},[]),_e=y.useCallback(Ne=>{const Ae=t.find(We=>We.name===Ne.promptName);Ae&&(s(Ae),g(Ne.args),u(Ne))},[t]);y.useEffect(()=>{V(-1)},[k,C]),y.useEffect(()=>{const Ne=Ae=>{const We=Ae.target;if(We.tagName==="INPUT"||We.tagName==="TEXTAREA"||We.contentEditable==="true"||Ae.metaKey||Ae.ctrlKey||Ae.altKey)return;const at=C==="prompts"?pe:I;if(Ae.key==="ArrowDown")Ae.preventDefault(),V(yt=>{const xn=yt+1;return xn>=at.length?0:xn});else if(Ae.key==="ArrowUp")Ae.preventDefault(),V(yt=>{const xn=yt-1;return xn<0?at.length-1:xn});else if(Ae.key==="Enter"&&ae>=0)if(Ae.preventDefault(),C==="prompts"){const yt=pe[ae];yt&&me(yt)}else{const yt=I[ae];yt&&_e(yt)}};return document.addEventListener("keydown",Ne),()=>document.removeEventListener("keydown",Ne)},[ae,pe,I,C,me,_e]),y.useEffect(()=>{if(ae>=0){const Ne=C==="prompts"?`prompt-${pe[ae]?.name}`:`saved-prompt-${I[ae]?.id}`,Ae=document.getElementById(Ne);Ae&&Ae.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ae,pe,I,C]),y.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:f,promptsCount:t.length,currentSelectedPrompt:i?.name}),f&&t.length>0){const Ne=t.find(Ae=>Ae.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!Ne,promptName:Ne?.name,shouldSelect:Ne&&i?.name!==Ne.name}),Ne&&i?.name!==Ne.name){console.warn("[PromptsTab] Selecting prompt:",Ne.name),m(null);const Ae=setTimeout(()=>{me(Ne);const We=document.getElementById(`prompt-${Ne.name}`);We&&(console.warn("[PromptsTab] Scrolling to prompt element"),We.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(Ae)}}},[f,t,i,me,m]);const ze=y.useCallback((Ne,Ae)=>{g(We=>({...We,[Ne]:Ae}))},[]),ue=y.useCallback(async()=>{if(!i||x)return;w(!0);const Ne=Date.now();try{const Ae=await n(i.name,h),We=Date.now()-Ne;_r.getInstance().capture(new iU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),E(at=>[{promptName:i.name,args:h,result:Ae,timestamp:Ne,duration:We},...at])}catch(Ae){_r.getInstance().capture(new iU({promptName:i.name,serverId:a,success:!1,error:Ae instanceof Error?Ae.message:"Unknown error"})).catch(()=>{});const ft={promptName:i.name,args:h,result:null,error:Ae instanceof Error?Ae.message:String(Ae),timestamp:Ne,duration:Date.now()-Ne};E(at=>[ft,...at])}finally{w(!1)}},[i,h,x,n,a]),Pe=y.useCallback(async(Ne,Ae)=>{try{await navigator.clipboard.writeText(JSON.stringify(Ae,null,2)),_(Ne),setTimeout(()=>_(null),2e3)}catch(We){console.error("[PromptsTab] Failed to copy result:",We)}},[]),Ye=y.useCallback(Ne=>{E(Ae=>Ae.filter((We,ft)=>ft!==Ne))},[]),fe=y.useCallback(Ne=>{if(H)P("response");else{const Ae=v[Ne];if(Ae){const We=window.open("","_blank","width=800,height=600");if(We){const ft=Ae.result;We.document.write(`
|
|
1671
|
+
`);k=A.pop()||"";for(const I of A)if(I.trim()&&I.startsWith("data: "))try{const O=JSON.parse(I.slice(6));if(console.log("[Client received event]",O.type,O.toolName||O.content?.slice?.(0,30)),O.type==="message")console.log("[Message started]",O.id);else if(O.type==="text"){x+=O.content;const M=w[w.length-1];M&&M.type==="text"?M.text=x:w.push({type:"text",text:x}),console.log("[Parts after text]",w.length,"parts, text length:",x.length),i(j=>j.map(B=>B.id===E?{...B,parts:[...w]}:B))}else if(O.type==="tool-call")x&&(x=""),w.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",w.length,"parts, tool:",O.toolName),i(M=>M.map(j=>j.id===E?{...j,parts:[...w]}:j));else if(O.type==="tool-result"){const M=w.find(j=>j.type==="tool-invocation"&&j.toolInvocation?.toolName===O.toolName&&!j.toolInvocation?.result);M&&M.toolInvocation?(M.toolInvocation.result=O.result,M.toolInvocation.state="result",console.log("[Parts after tool-result]",w.length,"parts, updated:",O.toolName),i(j=>j.map(B=>B.id===E?{...B,parts:[...w]}:B))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",w.length),i(M=>M.map(j=>j.id===E?{...j,parts:[...w],content:""}:j));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,I)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const x=g;x.status&&(v=`HTTP ${x.status}: ${v}`),(x.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const E={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(x=>[...x,E])}finally{c(!1)}},[t,a,e,r,n]),f=y.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:f}}function Wke({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=y.useState([]),[s,c]=y.useState(!1),u=y.useRef(null),f=y.useRef(null),m=y.useRef(null),h=y.useCallback(async v=>{if(!v.trim()||!t||!n)return;const E={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(S=>[...S,E]),c(!0),u.current=new AbortController;const x=Date.now();let w=0;try{const S=`assistant-${Date.now()}`;let _="";const k=[];if(i(N=>[...N,{id:S,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 N;if(t.provider==="openai"){const{ChatOpenAI:C}=await Mr(async()=>{const{ChatOpenAI:A}=await import("./index-C69r9Nt9.js");return{ChatOpenAI:A}},__vite__mapDeps([0,1,2,3,4,5,6]));N=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:C}=await Mr(async()=>{const{ChatAnthropic:A}=await import("./index-DXrgZUfu.js");return{ChatAnthropic:A}},__vite__mapDeps([7,3,2,4,1,6]));N=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:C}=await Mr(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-Apq2pBJl.js");return{ChatGoogleGenerativeAI:A}},__vite__mapDeps([8,3,2,4,1,5]));N=new C({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:N,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!f.current||f.current.llm!==m.current.instance){const{MCPAgent:N}=await Mr(async()=>{const{MCPAgent:C}=await import("./browser-9kmymM9X.js");return{MCPAgent:C}},__vite__mapDeps([9,6,2,4]));f.current=new N({llm:m.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await f.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",f.current.conversationHistory?.length);for await(const N of f.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(N.event==="on_chat_model_stream"&&N.data?.chunk?.text){const C=N.data.chunk.text;if(typeof C=="string"&&C.length>0){_+=C;const A=k[k.length-1];A&&A.type==="text"?A.text=_:k.push({type:"text",text:_}),i(I=>I.map(O=>O.id===S?{...O,parts:[...k]}:O))}}else if(N.event==="on_tool_start"){_&&(_="");let C={};N.data?.input?C=N.data.input:N.data?.tool_input?C=N.data.tool_input:N.data&&(C=N.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:N.name,eventData:N.data,extractedArgs:C}),w++,k.push({type:"tool-invocation",toolInvocation:{toolName:N.name||"unknown",args:C,state:"pending"}}),i(A=>A.map(I=>I.id===S?{...I,parts:[...k]}:I))}else if(N.event==="on_tool_end"){const C=k.find(A=>A.type==="tool-invocation"&&A.toolInvocation?.toolName===N.name&&!A.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:N.name,hasToolPart:!!C,output:N.data?.output}),C&&C.toolInvocation){let A=N.data?.output;if(A?.kwargs?.content&&typeof A.kwargs.content=="string")try{A=JSON.parse(A.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),A=A.kwargs.content}else if(A?.content&&typeof A.content=="string")try{A=JSON.parse(A.content)}catch{A=A.content}C.toolInvocation.result=A,C.toolInvocation.state="result";const I=A?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:N.name,hasMeta:!!A?._meta,hasStructuredContent:!!A?.structuredContent,appsSdkUri:I}),I&&typeof I=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",I);try{const O=await a(I);console.log("[useChatMessagesClientSide] Resource fetched:",O);const M=A?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const j=O.contents.map(G=>({type:"resource",resource:G}));console.log("[useChatMessagesClientSide] Created MCP resources:",j);const B={...A,content:[...A.content||[],...j],structuredContent:M};C.toolInvocation.result=B,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}i(O=>O.map(M=>M.id===S?{...M,parts:[...k]}:M))}}}i(N=>N.map(C=>C.id===S?{...C,parts:[...k],content:""}:C)),t&&_r.getInstance().capture(new oU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:w,success:!0,executionMode:"client-side",duration:Date.now()-x})).catch(()=>{})}catch(S){console.error("Client-side agent error:",S);let _="Unknown error occurred";if(S instanceof Error){_=S.message;const N=S;N.status&&(_=`HTTP ${N.status}: ${_}`),(N.code===401||_.includes("401")||_.includes("Unauthorized"))&&(_="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&_r.getInstance().capture(new oU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:w,success:!1,executionMode:"client-side",duration:Date.now()-x,error:_})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${_}`,timestamp:Date.now()};i(N=>[...N,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=y.useCallback(()=>{i([]),f.current&&f.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const I2={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function LY({mcpServerUrl:e}){const[t,n]=y.useState(null),[a,r]=y.useState(null),[i,s]=y.useState(!1),[c,u]=y.useState("openai"),[f,m]=y.useState(""),[h,g]=y.useState(I2.openai),v=y.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(j){return console.error("Failed to load API keys:",j),{}}return{}},[]),E=y.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[x,w]=y.useState("none"),[S,_]=y.useState(""),[k,N]=y.useState(""),[C,A]=y.useState("");y.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),j=v();if(M)try{const B=JSON.parse(M);n(B),u(B.provider),m(j[B.provider]||B.apiKey||""),g(B.model)}catch(B){console.error("Failed to load LLM config:",B)}},[v]),y.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const j=JSON.parse(M);r(j),w(j.type),j.username&&_(j.username),j.password&&N(j.password),j.token&&A(j.token)}catch(j){console.error("Failed to load auth config:",j)}else try{const j="mcp:auth",B=jY(e),G=`${j}_${B}_tokens`;localStorage.getItem(G)&&(r({type:"oauth"}),w("oauth"))}catch(j){console.error("Failed to check for OAuth tokens:",j)}},[e]),y.useEffect(()=>{g(I2[c]);const M=v();m(M[c]||"")},[c,v]);const I=y.useCallback(()=>{if(!f.trim())return;const M=v();M[c]=f,E(M);const j={provider:c,apiKey:f,model:h},B={type:x,...x==="basic"&&{username:S.trim(),password:k.trim()},...x==="bearer"&&{token:C.trim()}};n(j),r(B),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(j)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(B)),s(!1)},[c,f,h,x,S,k,C,v,E]),O=y.useCallback(()=>{n(null),r(null);const M=v();delete M[c],E(M),m(""),_(""),N(""),A(""),w("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,E]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:f,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:I,clearConfig:O}}function Kke({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=y.useState(""),s=y.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:f,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:E,tempModel:x,setTempModel:w,saveLLMConfig:S,clearConfig:_}=LY({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},N=Gke({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),C=Wke(k),{messages:A,isLoading:I,sendMessage:O,clearMessages:M}=n?C:N;OK({onNewChat:M}),y.useEffect(()=>{c&&A.length===0&&s.current&&s.current.focus()},[c,A.length]),y.useEffect(()=>{!I&&A.length>0&&s.current&&s.current.focus()},[I,A.length]);const j=y.useCallback(()=>{r.trim()&&(O(r),i(""))},[r,O]),B=y.useCallback(ee=>{ee.key==="Enter"&&!ee.shiftKey&&(ee.preventDefault(),j())},[j]),G=y.useCallback(()=>{_(),M()},[_,M]);return c&&A.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(D_,{open:f,onOpenChange:m,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSave:S,onClear:G,showClearButton:!0,buttonLabel:"Change API Key"})}),d.jsx(lSe,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:I,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:B,onSubmit:ee=>{ee.preventDefault(),j()},onConfigDialogOpenChange:m})]}):d.jsxs("div",{className:"flex flex-col h-full relative",children:[d.jsx(iSe,{llmConfig:c,hasMessages:A.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSaveConfig:S,onClearConfig:G}),d.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?d.jsx(Vke,{messages:A,isLoading:I,serverId:e.url,readResource:a,tools:e.tools}):d.jsx(cSe,{onConfigureClick:()=>m(!0)})}),c&&d.jsx(oSe,{inputValue:r,isConnected:t,isLoading:I,textareaRef:s,onInputChange:i,onKeyDown:B,onSendMessage:j})]})}const O0=y.createContext(null);O0.displayName="PanelGroupContext";const qn={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"},CD=10,Ul=y.useLayoutEffect,O2=kd.useId,Zke=typeof O2=="function"?O2:()=>null;let Yke=0;function RD(e=null){const t=Zke(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+Yke++),e??n.current}function $Y({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:f,onExpand:m,onResize:h,order:g,style:v,tagName:E="div",...x}){const w=y.useContext(O0);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:S,expandPanel:_,getPanelSize:k,getPanelStyle:N,groupId:C,isPanelCollapsed:A,reevaluatePanelConstraints:I,registerPanel:O,resizePanel:M,unregisterPanel:j}=w,B=RD(s),G=y.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:a,defaultSize:r,maxSize:c,minSize:u},id:B,idIsFromProps:s!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),Ul(()=>{const{callbacks:te,constraints:ae}=G.current,V={...ae};G.current.id=B,G.current.idIsFromProps=s!==void 0,G.current.order=g,te.onCollapse=f,te.onExpand=m,te.onResize=h,ae.collapsedSize=n,ae.collapsible=a,ae.defaultSize=r,ae.maxSize=c,ae.minSize=u,(V.collapsedSize!==ae.collapsedSize||V.collapsible!==ae.collapsible||V.maxSize!==ae.maxSize||V.minSize!==ae.minSize)&&I(G.current,V)}),Ul(()=>{const te=G.current;return O(te),()=>{j(te)}},[g,B,O,j]),y.useImperativeHandle(i,()=>({collapse:()=>{S(G.current)},expand:te=>{_(G.current,te)},getId(){return B},getSize(){return k(G.current)},isCollapsed(){return A(G.current)},isExpanded(){return!A(G.current)},resize:te=>{M(G.current,te)}}),[S,_,k,A,B,M]);const ee=N(G.current,r);return y.createElement(E,{...x,children:e,className:t,id:B,style:{...ee,...v},[qn.groupId]:C,[qn.panel]:"",[qn.panelCollapsible]:a||void 0,[qn.panelId]:B,[qn.panelSize]:parseFloat(""+ee.flexGrow).toFixed(1)})}const MY=y.forwardRef((e,t)=>y.createElement($Y,{...e,forwardedRef:t}));$Y.displayName="Panel";MY.displayName="forwardRef(Panel)";let lk=null,ev=-1,Ns=null;function qke(e,t,n){const a=(t&BY)!==0,r=(t&HY)!==0,i=(t&VY)!==0,s=(t&GY)!==0;if(t){if(a)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Xke(){Ns!==null&&(document.head.removeChild(Ns),lk=null,Ns=null,ev=-1)}function iE(e,t,n){var a,r;const i=qke(e,t);if(lk!==i){if(lk=i,Ns===null&&(Ns=document.createElement("style"),document.head.appendChild(Ns)),ev>=0){var s;(s=Ns.sheet)===null||s===void 0||s.removeRule(ev)}ev=(a=(r=Ns.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function PY(e){return e.type==="keydown"}function zY(e){return e.type.startsWith("pointer")}function UY(e){return e.type.startsWith("mouse")}function D0(e){if(zY(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(UY(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Jke(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Qke(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 eTe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:L2(e),b:L2(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;$t(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:j2(D2(n.a)),b:j2(D2(n.b))};if(r.a===r.b){const i=a.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let c=i.length;for(;c--;){const u=i[c];if(u===s.a)return 1;if(u===s.b)return-1}}return Math.sign(r.a-r.b)}const tTe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function nTe(e){var t;const n=getComputedStyle((t=FY(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function rTe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||nTe(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"||tTe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function D2(e){let t=e.length;for(;t--;){const n=e[t];if($t(n,"Missing node"),rTe(n))return n}return null}function j2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function L2(e){const t=[];for(;e;)t.push(e),e=FY(e);return t}function FY(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const BY=1,HY=2,VY=4,GY=8,aTe=Jke()==="coarse";let wi=[],Au=!1,Cs=new Map,j0=new Map;const lm=new Set;function iTe(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=Cs.get(s))!==null&&i!==void 0?i:0;return Cs.set(s,u+1),lm.add(c),ty(),function(){var m;j0.delete(e),lm.delete(c);const h=(m=Cs.get(s))!==null&&m!==void 0?m:1;if(Cs.set(s,h-1),ty(),h===1&&Cs.delete(s),wi.includes(c)){const g=wi.indexOf(c);g>=0&&wi.splice(g,1),L0(),r("up",!0,null)}}}function oTe(e){const{target:t}=e,{x:n,y:a}=D0(e);Au=!0,AD({target:t,x:n,y:a}),ty(),wi.length>0&&(ny("down",e),L0(),e.preventDefault(),WY(t)||e.stopImmediatePropagation())}function oE(e){const{x:t,y:n}=D0(e);if(Au&&e.type!=="pointerleave"&&e.buttons===0&&(Au=!1,ny("up",e)),!Au){const{target:a}=e;AD({target:a,x:t,y:n})}ny("move",e),L0(),wi.length>0&&e.preventDefault()}function sE(e){const{target:t}=e,{x:n,y:a}=D0(e);j0.clear(),Au=!1,wi.length>0&&(e.preventDefault(),WY(t)||e.stopImmediatePropagation()),ny("up",e),AD({target:t,x:n,y:a}),L0(),ty()}function WY(e){let t=e;for(;t;){if(t.hasAttribute(qn.resizeHandle))return!0;t=t.parentElement}return!1}function AD({target:e,x:t,y:n}){wi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),lm.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:f,right:m,top:h}=c,g=aTe?s.coarse:s.fine;if(t>=f-g&&t<=m+g&&n>=h-g&&n<=u+g){if(a!==null&&document.contains(a)&&i!==a&&!i.contains(a)&&!a.contains(i)&&eTe(a,i)>0){let E=a,x=!1;for(;E&&!E.contains(i);){if(Qke(E.getBoundingClientRect(),c)){x=!0;break}E=E.parentElement}if(x)return}wi.push(r)}})}function lE(e,t){j0.set(e,t)}function L0(){let e=!1,t=!1;wi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;j0.forEach(a=>{n|=a}),e&&t?iE("intersection",n):e?iE("horizontal",n):t?iE("vertical",n):Xke()}let cE;function ty(){var e;(e=cE)===null||e===void 0||e.abort(),cE=new AbortController;const t={capture:!0,signal:cE.signal};lm.size&&(Au?(wi.length>0&&Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",sE,t),r.addEventListener("pointerleave",oE,t),r.addEventListener("pointermove",oE,t))}),Cs.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",sE,t),r.addEventListener("pointercancel",sE,t)})):Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",oTe,t),r.addEventListener("pointermove",oE,t))}))}function ny(e,t){lm.forEach(n=>{const{setResizeHandlerState:a}=n,r=wi.includes(n);a(e,r,t)})}function sTe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function $t(e,t){if(!e)throw console.error(t),Error(t)}function ec(e,t,n=CD){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Ro(e,t,n=CD){return ec(e,t,n)===0}function Da(e,t,n){return ec(e,t,n)===0}function lTe(e,t,n){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++){const r=e[a],i=t[a];if(!Da(r,i,n))return!1}return!0}function wu({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];$t(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(ec(n,c)<0)if(i){const u=(r+c)/2;ec(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(CD)),n}function cp({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Da(e,0))return t;const s=[...t],[c,u]=a;$t(c!=null,"Invalid first pivot index"),$t(u!=null,"Invalid second pivot index");let f=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];$t(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if($t(w!=null,`Previous layout not found for panel index ${h}`),Da(w,v)){const S=x-w;ec(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const h=e<0?c:u,g=n[h];$t(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if($t(w!=null,`Previous layout not found for panel index ${h}`),Da(w,x)){const S=w-v;ec(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const x=t[g];$t(x!=null,`Previous layout not found for panel index ${g}`);const S=wu({panelConstraints:n,panelIndex:g,size:100})-x;if(v+=S,g+=h,g<0||g>=n.length)break}const E=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-E:E}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(f),E=t[g];$t(E!=null,`Previous layout not found for panel index ${g}`);const x=E-v,w=wu({panelConstraints:n,panelIndex:g,size:x});if(!Da(E,w)&&(f+=E-w,s[g]=w,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(lTe(r,s))return r;{const h=e<0?u:c,g=t[h];$t(g!=null,`Previous layout not found for panel index ${h}`);const v=g+f,E=wu({panelConstraints:n,panelIndex:h,size:v});if(s[h]=E,!Da(E,v)){let x=v-E,S=e<0?u:c;for(;S>=0&&S<n.length;){const _=s[S];$t(_!=null,`Previous layout not found for panel index ${S}`);const k=_+x,N=wu({panelConstraints:n,panelIndex:S,size:k});if(Da(_,N)||(x-=N-_,s[S]=N),Da(x,0))break;e>0?S--:S++}}}const m=s.reduce((h,g)=>g+h,0);return Da(m,100)?s:r}function cTe({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];$t(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:E=100,minSize:x=0}=v;g===c?(a=x,r=E):(i+=x,s+=E)});const u=Math.min(r,100-i),f=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:f,valueNow:m}}function cm(e,t=document){return Array.from(t.querySelectorAll(`[${qn.resizeHandleId}][data-panel-group-id="${e}"]`))}function KY(e,t,n=document){const r=cm(e,n).findIndex(i=>i.getAttribute(qn.resizeHandleId)===t);return r??null}function ZY(e,t,n){const a=KY(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function uTe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function YY(e,t=document){if(uTe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function $0(e,t=document){const n=t.querySelector(`[${qn.resizeHandleId}="${e}"]`);return n||null}function dTe(e,t,n,a=document){var r,i,s,c;const u=$0(t,a),f=cm(e,a),m=u?f.indexOf(u):-1,h=(r=(i=n[m])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,g=(s=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[h,g]}function fTe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){y.useRef({didWarnAboutMissingResizeHandle:!1}),Ul(()=>{if(!i)return;const c=cm(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:f,valueMin:m,valueNow:h}=cTe({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];$t(v,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",v.id),g.setAttribute("aria-valuemax",""+Math.round(f)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{c.forEach((u,f)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,a,r,i]),y.useEffect(()=>{if(!i)return;const c=t.current;$t(c,"Eager values not found");const{panelDataArray:u}=c,f=YY(n,i);$t(f!=null,`No group found for id "${n}"`);const m=cm(n,i);$t(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(qn.resizeHandleId);$t(v,"Resize handle element has no handle id attribute");const[E,x]=dTe(n,v,u,i);if(E==null||x==null)return()=>{};const w=S=>{if(!S.defaultPrevented)switch(S.key){case"Enter":{S.preventDefault();const _=u.findIndex(k=>k.id===E);if(_>=0){const k=u[_];$t(k,`No panel data found for index ${_}`);const N=a[_],{collapsedSize:C=0,collapsible:A,minSize:I=0}=k.constraints;if(N!=null&&A){const O=cp({delta:Da(N,C)?I-C:C-N,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:ZY(n,v,i),prevLayout:a,trigger:"keyboard"});a!==O&&s(O)}}break}}};return g.addEventListener("keydown",w),()=>{g.removeEventListener("keydown",w)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,a,r,s])}function $2(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 qY(e,t){const n=e==="horizontal",{x:a,y:r}=D0(t);return n?a:r}function pTe(e,t,n,a,r){const i=n==="horizontal",s=$0(t,r);$t(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(qn.groupId);$t(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const f=qY(n,e),m=YY(c,r);$t(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(f-u)/g*100}function mTe(e,t,n,a,r,i){if(PY(e)){const s=n==="horizontal";let c=0;e.shiftKey?c=100:r!=null?c=r:c=10;let u=0;switch(e.key){case"ArrowDown":u=s?0:c;break;case"ArrowLeft":u=s?-c:0;break;case"ArrowRight":u=s?c:0;break;case"ArrowUp":u=s?0:-c;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return a==null?0:pTe(e,t,n,a,i)}function hTe({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let a=0,r=100;for(let i=0;i<e.length;i++){const s=n[i];$t(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;c!=null&&(a++,t[i]=c,r-=c)}for(let i=0;i<e.length;i++){const s=n[i];$t(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;if(c!=null)continue;const u=e.length-a,f=r/u;a++,t[i]=f,r-=f}return t}function Jc(e,t,n){t.forEach((a,r)=>{const i=e[r];$t(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:f=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:E}=s;E&&E(a,h),m&&(g||v)&&(v&&(h==null||Ro(h,f))&&!Ro(a,f)&&v(),g&&(h==null||!Ro(h,f))&&Ro(a,f)&&g())}})}function Tb(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 gTe({defaultSize:e,dragState:t,layout:n,panelData:a,panelIndex:r,precision:i=3}){const s=n[r];let c;return s==null?c=e!=null?e.toFixed(i):"1":a.length===1?c="1":c=s.toFixed(i),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function bTe(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function M2(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 XY(e){return`react-resizable-panels:${e}`}function JY(e){return e.map(t=>{const{constraints:n,id:a,idIsFromProps:r,order:i}=t;return r?a:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function QY(e,t){try{const n=XY(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function vTe(e,t,n){var a,r;const i=(a=QY(e,n))!==null&&a!==void 0?a:{},s=JY(t);return(r=i[s])!==null&&r!==void 0?r:null}function yTe(e,t,n,a,r){var i;const s=XY(e),c=JY(t),u=(i=QY(e,r))!==null&&i!==void 0?i:{};u[c]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{r.setItem(s,JSON.stringify(u))}catch(f){console.error(f)}}function P2({layout:e,panelConstraints:t}){const n=[...e],a=n.reduce((i,s)=>i+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Da(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];$t(s!=null,`No layout data found for index ${i}`);const c=100/a*s;n[i]=c}let r=0;for(let i=0;i<t.length;i++){const s=n[i];$t(s!=null,`No layout data found for index ${i}`);const c=wu({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Da(r,0))for(let i=0;i<t.length;i++){const s=n[i];$t(s!=null,`No layout data found for index ${i}`);const c=s+r,u=wu({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Da(r,0)))break}return n}const wTe=100,up={getItem:e=>(M2(up),up.getItem(e)),setItem:(e,t)=>{M2(up),up.setItem(e,t)}},z2={};function eq({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=up,style:f,tagName:m="div",...h}){const g=RD(i),v=y.useRef(null),[E,x]=y.useState(null),[w,S]=y.useState([]),_=sTe(),k=y.useRef({}),N=y.useRef(new Map),C=y.useRef(0),A=y.useRef({autoSaveId:e,direction:a,dragState:E,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),I=y.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});y.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),y.useImperativeHandle(r,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:U}=I.current;return U},setLayout:U=>{const{onLayout:L}=A.current,{layout:$,panelDataArray:W}=I.current,K=P2({layout:U,panelConstraints:W.map(Y=>Y.constraints)});$2($,K)||(S(K),I.current.layout=K,L&&L(K),Jc(W,K,k.current))}}),[]),Ul(()=>{A.current.autoSaveId=e,A.current.direction=a,A.current.dragState=E,A.current.id=g,A.current.onLayout=s,A.current.storage=u}),fTe({committedValuesRef:A,eagerValuesRef:I,groupId:g,layout:w,panelDataArray:I.current.panelDataArray,setLayout:S,panelGroupElement:v.current}),y.useEffect(()=>{const{panelDataArray:U}=I.current;if(e){if(w.length===0||w.length!==U.length)return;let L=z2[e];L==null&&(L=bTe(yTe,wTe),z2[e]=L);const $=[...U],W=new Map(N.current);L(e,$,W,w,u)}},[e,w,u]),y.useEffect(()=>{});const O=y.useCallback(U=>{const{onLayout:L}=A.current,{layout:$,panelDataArray:W}=I.current;if(U.constraints.collapsible){const K=W.map(X=>X.constraints),{collapsedSize:Y=0,panelSize:se,pivotIndices:oe}=kl(W,U,$);if($t(se!=null,`Panel size not found for panel "${U.id}"`),!Ro(se,Y)){N.current.set(U.id,se);const J=su(W,U)===W.length-1?se-Y:Y-se,le=cp({delta:J,initialLayout:$,panelConstraints:K,pivotIndices:oe,prevLayout:$,trigger:"imperative-api"});Tb($,le)||(S(le),I.current.layout=le,L&&L(le),Jc(W,le,k.current))}}},[]),M=y.useCallback((U,L)=>{const{onLayout:$}=A.current,{layout:W,panelDataArray:K}=I.current;if(U.constraints.collapsible){const Y=K.map(pe=>pe.constraints),{collapsedSize:se=0,panelSize:oe=0,minSize:X=0,pivotIndices:J}=kl(K,U,W),le=L??X;if(Ro(oe,se)){const pe=N.current.get(U.id),me=pe!=null&&pe>=le?pe:le,ze=su(K,U)===K.length-1?oe-me:me-oe,ue=cp({delta:ze,initialLayout:W,panelConstraints:Y,pivotIndices:J,prevLayout:W,trigger:"imperative-api"});Tb(W,ue)||(S(ue),I.current.layout=ue,$&&$(ue),Jc(K,ue,k.current))}}},[]),j=y.useCallback(U=>{const{layout:L,panelDataArray:$}=I.current,{panelSize:W}=kl($,U,L);return $t(W!=null,`Panel size not found for panel "${U.id}"`),W},[]),B=y.useCallback((U,L)=>{const{panelDataArray:$}=I.current,W=su($,U);return gTe({defaultSize:L,dragState:E,layout:w,panelData:$,panelIndex:W})},[E,w]),G=y.useCallback(U=>{const{layout:L,panelDataArray:$}=I.current,{collapsedSize:W=0,collapsible:K,panelSize:Y}=kl($,U,L);return $t(Y!=null,`Panel size not found for panel "${U.id}"`),K===!0&&Ro(Y,W)},[]),ee=y.useCallback(U=>{const{layout:L,panelDataArray:$}=I.current,{collapsedSize:W=0,collapsible:K,panelSize:Y}=kl($,U,L);return $t(Y!=null,`Panel size not found for panel "${U.id}"`),!K||ec(Y,W)>0},[]),te=y.useCallback(U=>{const{panelDataArray:L}=I.current;L.push(U),L.sort(($,W)=>{const K=$.order,Y=W.order;return K==null&&Y==null?0:K==null?-1:Y==null?1:K-Y}),I.current.panelDataArrayChanged=!0,_()},[_]);Ul(()=>{if(I.current.panelDataArrayChanged){I.current.panelDataArrayChanged=!1;const{autoSaveId:U,onLayout:L,storage:$}=A.current,{layout:W,panelDataArray:K}=I.current;let Y=null;if(U){const oe=vTe(U,K,$);oe&&(N.current=new Map(Object.entries(oe.expandToSizes)),Y=oe.layout)}Y==null&&(Y=hTe({panelDataArray:K}));const se=P2({layout:Y,panelConstraints:K.map(oe=>oe.constraints)});$2(W,se)||(S(se),I.current.layout=se,L&&L(se),Jc(K,se,k.current))}}),Ul(()=>{const U=I.current;return()=>{U.layout=[]}},[]);const ae=y.useCallback(U=>{let L=!1;const $=v.current;return $&&window.getComputedStyle($,null).getPropertyValue("direction")==="rtl"&&(L=!0),function(K){K.preventDefault();const Y=v.current;if(!Y)return()=>null;const{direction:se,dragState:oe,id:X,keyboardResizeBy:J,onLayout:le}=A.current,{layout:pe,panelDataArray:me}=I.current,{initialLayout:_e}=oe??{},ze=ZY(X,U,Y);let ue=mTe(K,U,se,oe,J,Y);const Pe=se==="horizontal";Pe&&L&&(ue=-ue);const Ye=me.map(He=>He.constraints),fe=cp({delta:ue,initialLayout:_e??pe,panelConstraints:Ye,pivotIndices:ze,prevLayout:pe,trigger:PY(K)?"keyboard":"mouse-or-touch"}),De=!Tb(pe,fe);(zY(K)||UY(K))&&C.current!=ue&&(C.current=ue,!De&&ue!==0?Pe?lE(U,ue<0?BY:HY):lE(U,ue<0?VY:GY):lE(U,0)),De&&(S(fe),I.current.layout=fe,le&&le(fe),Jc(me,fe,k.current))}},[]),V=y.useCallback((U,L)=>{const{onLayout:$}=A.current,{layout:W,panelDataArray:K}=I.current,Y=K.map(pe=>pe.constraints),{panelSize:se,pivotIndices:oe}=kl(K,U,W);$t(se!=null,`Panel size not found for panel "${U.id}"`);const J=su(K,U)===K.length-1?se-L:L-se,le=cp({delta:J,initialLayout:W,panelConstraints:Y,pivotIndices:oe,prevLayout:W,trigger:"imperative-api"});Tb(W,le)||(S(le),I.current.layout=le,$&&$(le),Jc(K,le,k.current))},[]),q=y.useCallback((U,L)=>{const{layout:$,panelDataArray:W}=I.current,{collapsedSize:K=0,collapsible:Y}=L,{collapsedSize:se=0,collapsible:oe,maxSize:X=100,minSize:J=0}=U.constraints,{panelSize:le}=kl(W,U,$);le!=null&&(Y&&oe&&Ro(le,K)?Ro(K,se)||V(U,se):le<J?V(U,J):le>X&&V(U,X))},[V]),H=y.useCallback((U,L)=>{const{direction:$}=A.current,{layout:W}=I.current;if(!v.current)return;const K=$0(U,v.current);$t(K,`Drag handle element not found for id "${U}"`);const Y=qY($,L);x({dragHandleId:U,dragHandleRect:K.getBoundingClientRect(),initialCursorPosition:Y,initialLayout:W})},[]),ie=y.useCallback(()=>{x(null)},[]),re=y.useCallback(U=>{const{panelDataArray:L}=I.current,$=su(L,U);$>=0&&(L.splice($,1),delete k.current[U.id],I.current.panelDataArrayChanged=!0,_())},[_]),P=y.useMemo(()=>({collapsePanel:O,direction:a,dragState:E,expandPanel:M,getPanelSize:j,getPanelStyle:B,groupId:g,isPanelCollapsed:G,isPanelExpanded:ee,reevaluatePanelConstraints:q,registerPanel:te,registerResizeHandle:ae,resizePanel:V,startDragging:H,stopDragging:ie,unregisterPanel:re,panelGroupElement:v.current}),[O,E,a,M,j,B,g,G,ee,q,te,ae,V,H,ie,re]),F={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return y.createElement(O0.Provider,{value:P},y.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...F,...f},[qn.group]:"",[qn.groupDirection]:a,[qn.groupId]:g}))}const tq=y.forwardRef((e,t)=>y.createElement(eq,{...e,forwardedRef:t}));eq.displayName="PanelGroup";tq.displayName="forwardRef(PanelGroup)";function su(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function kl(e,t,n){const a=su(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function xTe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){y.useEffect(()=>{if(e||n==null||a==null)return;const r=$0(t,a);if(r==null)return;const i=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const c=r.getAttribute(qn.groupId);$t(c,`No group element found for id "${c}"`);const u=cm(c,a),f=KY(c,t,a);$t(f!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?f>0?f-1:u.length-1:f+1<u.length?f+1:0;u[m].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[a,e,t,n])}function nq({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:f,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...E}){var x,w;const S=y.useRef(null),_=y.useRef({onClick:s,onDragging:c,onPointerDown:f,onPointerUp:m});y.useEffect(()=>{_.current.onClick=s,_.current.onDragging=c,_.current.onPointerDown=f,_.current.onPointerUp=m});const k=y.useContext(O0);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:N,groupId:C,registerResizeHandle:A,startDragging:I,stopDragging:O,panelGroupElement:M}=k,j=RD(r),[B,G]=y.useState("inactive"),[ee,te]=y.useState(!1),[ae,V]=y.useState(null),q=y.useRef({state:B});Ul(()=>{q.current.state=B}),y.useEffect(()=>{if(n)V(null);else{const P=A(j);V(()=>P)}},[n,j,A]);const H=(x=a?.coarse)!==null&&x!==void 0?x:15,ie=(w=a?.fine)!==null&&w!==void 0?w:5;y.useEffect(()=>{if(n||ae==null)return;const P=S.current;$t(P,"Element ref not attached");let F=!1;return iTe(j,P,N,{coarse:H,fine:ie},(L,$,W)=>{if(!$){G("inactive");return}switch(L){case"down":{G("drag"),F=!1,$t(W,'Expected event to be defined for "down" action'),I(j,W);const{onDragging:K,onPointerDown:Y}=_.current;K?.(!0),Y?.();break}case"move":{const{state:K}=q.current;F=!0,K!=="drag"&&G("hover"),$t(W,'Expected event to be defined for "move" action'),ae(W);break}case"up":{G("hover"),O();const{onClick:K,onDragging:Y,onPointerUp:se}=_.current;Y?.(!1),se?.(),F||K?.();break}}})},[H,N,n,ie,A,j,ae,I,O]),xTe({disabled:n,handleId:j,resizeHandler:ae,panelGroupElement:M});const re={touchAction:"none",userSelect:"none"};return y.createElement(v,{...E,children:e,className:t,id:r,onBlur:()=>{te(!1),i?.()},onFocus:()=>{te(!0),u?.()},ref:S,role:"separator",style:{...re,...h},tabIndex:g,[qn.groupDirection]:N,[qn.groupId]:C,[qn.resizeHandle]:"",[qn.resizeHandleActive]:B==="drag"?"pointer":ee?"keyboard":void 0,[qn.resizeHandleEnabled]:!n,[qn.resizeHandleId]:j,[qn.resizeHandleState]:B})}nq.displayName="PanelResizeHandle";function sa({className:e,...t}){return d.jsx(tq,{"data-slot":"resizable-panel-group",className:Me("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function In({...e}){return d.jsx(MY,{"data-slot":"resizable-panel",...e})}function xi({withHandle:e,className:t,...n}){return d.jsx(nq,{"data-slot":"resizable-handle",className:Me("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(hhe,{className:"size-2.5"})})})}function th({className:e,...t}){return d.jsx("kbd",{"data-slot":"kbd",className:Me("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 STe({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,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(Tn,{ref:u,placeholder:"Search notifications...",value:t,onChange:f=>i(f.target.value),onBlur:s,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(hr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(Pd,{className:"h-4 w-4"})})}),d.jsxs(It,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(th,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(Po,{className:"h-4 w-4"})})}),d.jsx(It,{side:"bottom",children:"Clear all"})]})})]})}function tl({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return d.jsx("button",{id:e,type:"button",onClick:c,className:Me("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:[a&&d.jsx("div",{className:"flex-shrink-0 mt-1",children:d.jsx("div",{className:Me("p-2.5 rounded-full transition-colors",t?"bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600"),children:a})}),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:Me("font-medium truncate font-mono text-sm"),children:r})}),i&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function ETe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Md,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>d.jsx(tl,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=r(s.timestamp),f=s.params&&Object.keys(s.params).length>0?Object.keys(s.params).length:0,m=f>0?` | ${f} param${f>1?"s":""}`:"";return u+m})(),onClick:()=>n(s)},s.id))})}function _Te({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){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(Fp,{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(iC,{className:"h-4 w-4 mr-1"}):d.jsx(GG,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,children:s?d.jsx(mr,{className:"h-4 w-4"}):d.jsx(er,{className:"h-4 w-4"})}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,children:d.jsx(Mm,{className:"h-4 w-4"})}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:i,children:d.jsx(Hp,{className:"h-4 w-4"})}),c&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,children:d.jsx(no,{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(Qn,{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(aC,{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 ry(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<60?"just now":r<60?`${r}m ago`:i<24?`${i}h ago`:s<7?`${s}d ago`:new Date(e).toLocaleDateString()}function kTe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,E]=y.useState(!0),[x,w]=y.useState(!1),[S,_]=y.useState(!0),[k,N]=y.useState(!1),C=y.useRef(null),A=y.useRef(null),I=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const q=C.current;if(!q)return;const H=()=>{q.scrollTop>0&&(O.current=!0,E(!1))};return q.addEventListener("scroll",H),()=>q.removeEventListener("scroll",H)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const M=y.useCallback(()=>{f.trim()||w(!1)},[f]),j=y.useMemo(()=>{if(!f.trim())return e;const q=f.toLowerCase();return e.filter(H=>H.method.toLowerCase().includes(q)||JSON.stringify(H.params||{}).toLowerCase().includes(q))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const q=H=>{const ie=H.target;if(ie.tagName==="INPUT"||ie.tagName==="TEXTAREA"||ie.contentEditable==="true"||H.metaKey||H.ctrlKey||H.altKey)return;const P=j;if(H.key==="ArrowDown")H.preventDefault(),g(F=>{const U=F+1;return U>=P.length?0:U});else if(H.key==="ArrowUp")H.preventDefault(),g(F=>{const U=F-1;return U<0?P.length-1:U});else if(H.key==="Enter"&&h>=0){H.preventDefault();const F=j[h];F&&B(F)}};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[h,j]),y.useEffect(()=>{if(h>=0){const q=`notification-${j[h]?.id}`,H=document.getElementById(q);H&&H.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,j]);const B=y.useCallback(q=>{u(q)},[]),G=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),ee=y.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)),N(!0),setTimeout(()=>N(!1),2e3)}catch(q){console.error("[NotificationsTab] Failed to copy notification:",q)}},[c]),te=y.useCallback(()=>{if(c)try{const q=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),H=URL.createObjectURL(q),ie=document.createElement("a");ie.href=H,ie.download=`notification-${Date.now()}.json`,document.body.appendChild(ie),ie.click(),document.body.removeChild(ie),URL.revokeObjectURL(H)}catch(q){console.error("[NotificationsTab] Failed to download notification:",q)}},[c]),ae=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(q){console.error("[NotificationsTab] Failed to toggle fullscreen:",q)}},[]),V=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:ry}:null;return s?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(In,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(In,{defaultSize:75,minSize:30,children:[d.jsx(STe,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:j.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onClearAll:G,searchInputRef:I}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(ETe,{notifications:j,selectedNotification:c,onNotificationSelect:B,focusedIndex:h,formatRelativeTime:ry,listRef:C})})]})})}),d.jsx(xi,{}),d.jsx(In,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(_Te,{notification:V,previewMode:S,onTogglePreview:()=>_(!S),onCopy:ee,onDownload:te,onFullscreen:ae,onClose:()=>u(null),isCopied:k})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(aC,{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 rq({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:f="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,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(Tn,{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?a:r}),w&&d.jsxs(d.Fragment,{children:[d.jsx(hr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:d.jsx(Pd,{className:"h-4 w-4"})})}),d.jsxs(It,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(th,{children:"F"})]})]})]})]})}),d.jsxs(Le,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[w?d.jsx(c,{}):d.jsx(u,{}),d.jsx("span",{className:"hidden sm:inline",children:w?r:a}),w&&s>0&&d.jsx(hr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function U2({prompts:e,selectedPrompt:t,onPromptSelect:n,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(Vp,{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((r,i)=>d.jsx(tl,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:d.jsx(Vp,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&d.jsxs(hr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[r.arguments.length," args"]}),onClick:()=>n(r)},r.name))})}function F2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:f}){return d.jsx(rq,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:Vp,secondaryIcon:Fp,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:f})}function B2({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,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(Fp,{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((i,s)=>d.jsx(tl,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:d.jsx(Fp,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function TTe({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.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 i=s=>{const c=s.name,u=t[c],f=typeof u=="string"?u:JSON.stringify(u);return s.type==="boolean"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.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:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),d.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Tn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Jl,{id:c,value:f,onChange:m=>{try{const h=JSON.parse(m.target.value);n(c,h)}catch{n(c,m.target.value)}},placeholder:s.description||`Enter ${c} as JSON`,className:"font-mono text-sm min-h-[100px]"}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Tn,{id:c,value:f,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return d.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function H2({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return y.useEffect(()=>{const c=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&a&&(u.preventDefault(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,a,i]),e?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:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?d.jsxs(d.Fragment,{children:[d.jsx(ki,{className:"mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):d.jsxs(d.Fragment,{children:[d.jsx(XG,{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:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[d.jsx(lC,{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(TTe,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):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 NTe(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function CTe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function RTe(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 ATe({message:e,index:t}){const[n,a]=y.useState(!1),r=async()=>{const s=RTe(e.content);await navigator.clipboard.writeText(s),a(!0),setTimeout(()=>a(!1),2e3)},i=()=>{const s=e.content;return typeof s=="string"?d.jsx(Xb,{content:s}):s.type==="text"&&s.text?d.jsx(Xb,{content:s.text}):s.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: ",s.mimeType||"unknown type"]}),s.data&&d.jsx("img",{src:`data:${s.mimeType};base64,${s.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):s.type==="resource"&&s.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:s.resource.uri})]}),s.resource.text&&d.jsx("div",{className:"mt-2",children:d.jsx(Xb,{content:s.resource.text})})]}):d.jsx("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:d.jsx("code",{children:JSON.stringify(s,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(hr,{variant:NTe(e.role),children:CTe(e.role)}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-6 px-2",title:"Copy message content",children:n?d.jsx(mr,{className:"h-3.5 w-3.5"}):d.jsx(er,{className:"h-3.5 w-3.5"})})]}),d.jsx("div",{className:"px-4 py-3",children:i()})]})}function ITe(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<10?"now":a<60?`${a}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${s}d ago`}function OTe(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 V2({results:e,copiedResult:t,previewMode:n=!0,onCopy:a,onDelete:r,onFullscreen:i,onTogglePreview:s,onMaximize:c,isMaximized:u=!1}){const[f,m]=y.useState(0),[h,g]=y.useState(""),[v,E]=y.useState(!0),x=e[0],w=x?e.filter(C=>C.promptName===x.promptName):[],S=w[f]||w[0],_=e.findIndex(C=>C===S);if(y.useEffect(()=>{w.length>0&&f>=w.length&&m(0)},[w.length,f]),y.useEffect(()=>{const C=()=>{S&&g(ITe(S.timestamp))};C();const A=setInterval(C,1e3);return()=>clearInterval(A)},[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(Md,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const k=S.error||OTe(S.result),N="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(Gp,{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"]})]}),N&&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 ${v?"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 ${v?"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(Bp,{className:"h-3 w-3 text-gray-400"}),d.jsxs(Gi,{value:f.toString(),onValueChange:C=>m(parseInt(C)),children:[d.jsx(Ki,{className:"h-7 w-[120px] text-xs",children:d.jsx(Wi,{})}),d.jsx(Zi,{children:w.map((C,A)=>d.jsx(Er,{value:A.toString(),children:A===0?"Latest":`${A+1} call ago`},A))})]})]}),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:()=>a(_,S.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?d.jsx(mr,{className:"h-4 w-4"}):d.jsx(er,{className:"h-4 w-4"})}),r&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>r(_),className:"h-7 w-7 p-0",title:"Delete result",children:d.jsx(Po,{className:"h-4 w-4"})}),i&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>i(_),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:d.jsx(Hp,{className:"h-4 w-4"})}),c&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0 hidden sm:flex",title:u?"Restore":"Maximize",children:u?d.jsx(qG,{className:"h-4 w-4"}):d.jsx(Hp,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:k?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:k})]}):v&&N?d.jsx("div",{className:"space-y-3",children:S.result.messages.map((C,A)=>d.jsx(ATe,{message:C,index:A},A))}):d.jsx(Qn,{data:S.result,filename:`prompt-result-${S.promptName}-${Date.now()}.json`})})]})})})}function ID({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=y.useState([]),i=y.useRef(null),[s,c]=y.useState(new Set),[u]=y.useState(""),f=v=>{c(E=>{const x=new Set(E);return x.has(v)?x.delete(v):x.add(v),x})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const E=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});E.ok||console.warn("[RPC Logger] Failed to clear server buffer:",E.status)}catch(v){console.warn("[RPC Logger] Error clearing server buffer:",v)}},h=y.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);y.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),y.useEffect(()=>{t?.(a.length)},[a.length,t]),y.useEffect(()=>{let v=null;try{const E=new URLSearchParams;E.set("replay","50"),E.set("_t",Date.now().toString()),e&&e.length>0&&E.set("serverIds",e.join(","));const x=`/inspector/api/rpc/stream?${E.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",x),v=new globalThis.EventSource(x),v.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},v.onmessage=w=>{try{const S=JSON.parse(w.data);if(!S||S.type!=="rpc")return;const{serverId:_,direction:k,message:N,timestamp:C}=S,A=N,I=typeof A?.method=="string"?A.method:A?.result!==void 0?"result":A?.error!==void 0?"error":"unknown",O={id:`${C??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof _=="string"?_:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:I,timestamp:C??new Date().toISOString(),payload:N};console.log("[RPC Logger] Received RPC event:",{method:I,direction:k,serverId:_}),r(M=>{const j=[O,...M].slice(0,1e3);return t?.(j.length),j})}catch(S){console.error("[RPC Logger] Error parsing SSE message:",S)}},v.onerror=w=>{console.error("[RPC Logger] SSE connection error:",w);try{v?.close()}catch{}}}catch(E){console.error("[RPC Logger] Failed to create SSE connection:",E)}return()=>{try{v?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=y.useMemo(()=>{let v=a;if(e&&e.length>0){const E=new Set(e);v=v.filter(x=>E.has(x.serverId))}if(u.trim()){const E=u.toLowerCase();v=v.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 v=[...v].sort((E,x)=>new Date(x.timestamp).getTime()-new Date(E.timestamp).getTime()),v},[a,u,e]);return d.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:d.jsx("div",{ref:i,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(v=>{const E=s.has(v.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(v.id),children:[d.jsx("div",{className:"flex-shrink-0",children:E?d.jsx(qs,{className:"h-3 w-3 text-muted-foreground transition-transform"}):d.jsx(WG,{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(v.timestamp).toLocaleTimeString()}),d.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${v.direction==="RECEIVE"?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"bg-green-500/10 text-green-600 dark:text-green-400"}`,title:v.direction==="RECEIVE"?"Incoming":"Outgoing",children:v.direction==="RECEIVE"?d.jsx(kme,{className:"h-3 w-3"}):d.jsx(Nme,{className:"h-3 w-3"})}),d.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.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(Qn,{data:v.payload})})})})]},v.id)})})})}const G2="mcp-inspector-saved-prompts";function aq({ref:e,prompts:t,callPrompt:n,serverId:a,isConnected:r}){const[i,s]=y.useState(null),[c,u]=y.useState(null),{selectedPromptName:f,setSelectedPromptName:m}=oc(),[h,g]=y.useState({}),[v,E]=y.useState([]),[x,w]=y.useState(!1),[S,_]=y.useState(null),[k,N]=y.useState(""),[C,A]=y.useState("prompts"),[I,O]=y.useState([]),[M,j]=y.useState(!1),[B,G]=y.useState(""),[ee,te]=y.useState(!1),[ae,V]=y.useState(-1),q=y.useRef(null),[H,ie]=y.useState(!1),[re,P]=y.useState("list"),[F,U]=y.useState(0),[L,$]=y.useState(!0),[W,K]=y.useState(!1),Y=y.useRef(null),se=y.useRef(null),oe=y.useRef(null),X=y.useRef(null);y.useEffect(()=>{const Ne=()=>{ie(window.innerWidth<1024)};return Ne(),window.addEventListener("resize",Ne),()=>window.removeEventListener("resize",Ne)},[]),y.useEffect(()=>{P(i?"detail":"list")},[i]),y.useEffect(()=>{H&&v.length>0&&!x&&P("response")},[v,x,H]),y.useImperativeHandle(e,()=>({focusSearch:()=>{te(!0),setTimeout(()=>{q.current&&q.current.focus()},0)},blurSearch:()=>{N(""),te(!1),q.current&&q.current.blur()}})),y.useEffect(()=>{try{const Ne=localStorage.getItem(G2);if(Ne){const Ae=JSON.parse(Ne);O(Ae)}}catch(Ne){console.error("[PromptsTab] Failed to load saved prompts:",Ne)}},[]);const J=y.useCallback(Ne=>{try{localStorage.setItem(G2,JSON.stringify(Ne))}catch(Ae){console.error("[PromptsTab] Failed to save prompts:",Ae)}},[]);y.useEffect(()=>{ee&&q.current&&q.current.focus()},[ee]);const le=y.useCallback(()=>{k.trim()||te(!1)},[k]),pe=y.useMemo(()=>{if(!k.trim())return t;const Ne=k.toLowerCase();return t.filter(Ae=>Ae.name.toLowerCase().includes(Ne)||Ae.description?.toLowerCase().includes(Ne))},[t,k]),me=y.useCallback(Ne=>{s(Ne);const Ae={};Ne.arguments&&Ne.arguments.forEach(We=>{We.default!==void 0?Ae[We.name]=We.default:We.type==="string"?Ae[We.name]="":We.type==="number"?Ae[We.name]=0:We.type==="boolean"?Ae[We.name]=!1:We.type==="array"?Ae[We.name]=[]:We.type==="object"&&(Ae[We.name]={})}),g(Ae)},[]),_e=y.useCallback(Ne=>{const Ae=t.find(We=>We.name===Ne.promptName);Ae&&(s(Ae),g(Ne.args),u(Ne))},[t]);y.useEffect(()=>{V(-1)},[k,C]),y.useEffect(()=>{const Ne=Ae=>{const We=Ae.target;if(We.tagName==="INPUT"||We.tagName==="TEXTAREA"||We.contentEditable==="true"||Ae.metaKey||Ae.ctrlKey||Ae.altKey)return;const at=C==="prompts"?pe:I;if(Ae.key==="ArrowDown")Ae.preventDefault(),V(yt=>{const xn=yt+1;return xn>=at.length?0:xn});else if(Ae.key==="ArrowUp")Ae.preventDefault(),V(yt=>{const xn=yt-1;return xn<0?at.length-1:xn});else if(Ae.key==="Enter"&&ae>=0)if(Ae.preventDefault(),C==="prompts"){const yt=pe[ae];yt&&me(yt)}else{const yt=I[ae];yt&&_e(yt)}};return document.addEventListener("keydown",Ne),()=>document.removeEventListener("keydown",Ne)},[ae,pe,I,C,me,_e]),y.useEffect(()=>{if(ae>=0){const Ne=C==="prompts"?`prompt-${pe[ae]?.name}`:`saved-prompt-${I[ae]?.id}`,Ae=document.getElementById(Ne);Ae&&Ae.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ae,pe,I,C]),y.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:f,promptsCount:t.length,currentSelectedPrompt:i?.name}),f&&t.length>0){const Ne=t.find(Ae=>Ae.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!Ne,promptName:Ne?.name,shouldSelect:Ne&&i?.name!==Ne.name}),Ne&&i?.name!==Ne.name){console.warn("[PromptsTab] Selecting prompt:",Ne.name),m(null);const Ae=setTimeout(()=>{me(Ne);const We=document.getElementById(`prompt-${Ne.name}`);We&&(console.warn("[PromptsTab] Scrolling to prompt element"),We.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(Ae)}}},[f,t,i,me,m]);const ze=y.useCallback((Ne,Ae)=>{g(We=>({...We,[Ne]:Ae}))},[]),ue=y.useCallback(async()=>{if(!i||x)return;w(!0);const Ne=Date.now();try{const Ae=await n(i.name,h),We=Date.now()-Ne;_r.getInstance().capture(new iU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),E(at=>[{promptName:i.name,args:h,result:Ae,timestamp:Ne,duration:We},...at])}catch(Ae){_r.getInstance().capture(new iU({promptName:i.name,serverId:a,success:!1,error:Ae instanceof Error?Ae.message:"Unknown error"})).catch(()=>{});const ft={promptName:i.name,args:h,result:null,error:Ae instanceof Error?Ae.message:String(Ae),timestamp:Ne,duration:Date.now()-Ne};E(at=>[ft,...at])}finally{w(!1)}},[i,h,x,n,a]),Pe=y.useCallback(async(Ne,Ae)=>{try{await navigator.clipboard.writeText(JSON.stringify(Ae,null,2)),_(Ne),setTimeout(()=>_(null),2e3)}catch(We){console.error("[PromptsTab] Failed to copy result:",We)}},[]),Ye=y.useCallback(Ne=>{E(Ae=>Ae.filter((We,ft)=>ft!==Ne))},[]),fe=y.useCallback(Ne=>{if(H)P("response");else{const Ae=v[Ne];if(Ae){const We=window.open("","_blank","width=800,height=600");if(We){const ft=Ae.result;We.document.write(`
|
|
1672
1672
|
<html>
|
|
1673
1673
|
<head>
|
|
1674
1674
|
<title>${Ae.promptName} Result</title>
|
|
@@ -1698,4 +1698,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1698
1698
|
<pre>${JSON.stringify(Ue.result,null,2)}</pre>
|
|
1699
1699
|
</body>
|
|
1700
1700
|
</html>
|
|
1701
|
-
`),Se.document.close())}},[E]),xn=y.useCallback(()=>{K?(me.current&&me.current.expand(),_e.current&&_e.current.expand(),Y(!1)):(me.current&&me.current.collapse(),_e.current&&_e.current.collapse(),Y(!0))},[K]),pt=y.useCallback(()=>{s&&(ae(""),ee(!0))},[s]),Gn=y.useCallback(()=>{if(!s)return;const Ve={id:`${Date.now()}-${Math.random()}`,name:te.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};Ye([...j,Ve]),_r.getInstance().capture(new hme({toolName:s.name,serverId:r})).catch(()=>{}),ee(!1),ae("")},[s,te,g,j,Ye,r]),hn=y.useCallback(Ve=>{Ye(j.filter(Ue=>Ue.id!==Ve)),u?.id===Ve&&f(null)},[j,Ye,u]);return U?d.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[$!=="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:()=>{$==="response"?W("detail"):(c(null),W("list"))},className:"p-0 h-8 w-8",children:d.jsx(a0,{className:"h-4 w-4"})}),d.jsxs("div",{className:"flex items-center text-sm font-medium",children:[d.jsx("button",{onClick:()=>{c(null),W("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),$==="detail"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("button",{onClick:()=>{W("response")},className:$==="detail"?"text-foreground hover:underline":$==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),$==="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(d0,{initial:!1,mode:"popLayout",children:[$==="list"&&d.jsxs(xa.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(nF,{activeTab:O,isSearchExpanded:H,searchQuery:A,filteredToolsCount:fe.length,savedRequestsCount:j.length,onSearchExpand:()=>ie(!0),onSearchChange:I,onSearchBlur:Ee,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:F}),O==="tools"?d.jsx(tF,{tools:fe,selectedTool:s,onToolSelect:De,focusedIndex:re}):d.jsx(Y2,{savedRequests:j,selectedRequest:u,onLoadRequest:He,onDeleteRequest:hn,focusedIndex:re})]},"list"),$==="detail"&&d.jsx(xa.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(J2,{selectedTool:s,toolArgs:g,isExecuting:w,isConnected:i,onArgChange:Ne,onExecute:Ae,onSave:pt})},"detail"),$==="response"&&d.jsx(xa.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(eF,{results:at,copiedResult:_,previewMode:V,serverId:r,readResource:a,onCopy:We,onDelete:ft,onFullscreen:yt,onTogglePreview:()=>q(!V)})},"response")]})}),d.jsx(q2,{isOpen:G,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Gn,onCancel:()=>ee(!1)})]}):d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(In,{ref:me,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:d.jsxs(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[d.jsx(In,{defaultSize:75,minSize:30,children:d.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[d.jsx(nF,{activeTab:O,isSearchExpanded:H,searchQuery:A,filteredToolsCount:fe.length,savedRequestsCount:j.length,onSearchExpand:()=>ie(!0),onSearchChange:I,onSearchBlur:Ee,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:F}),O==="tools"?d.jsx(tF,{tools:fe,selectedTool:s,onToolSelect:De,focusedIndex:re}):d.jsx(Y2,{savedRequests:j,selectedRequest:u,onLoadRequest:He,onDeleteRequest:hn,focusedIndex:re})]})}),d.jsx(xi,{withHandle:!0}),d.jsxs(In,{ref:ue,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,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:Ve=>{Ve.preventDefault(),Ve.stopPropagation(),X?(ue.current?.resize(25),J(!1)):(ue.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"}),se>0&&d.jsx(hr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:se}),se>0&&!X&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:Ve=>{Ve.preventDefault(),Ve.stopPropagation(),Pe.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:d.jsx(Po,{className:"h-3.5 w-3.5"})})]}),d.jsx(qs,{className:`h-4 w-4 text-muted-foreground transition-transform ${X?"":"rotate-180"}`})]}),d.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${X?"hidden":""}`,children:d.jsx(ID,{serverIds:[r],onCountChange:oe,onClearRef:Pe})})]})]})}),d.jsx(xi,{withHandle:!0}),d.jsx(In,{defaultSize:67,children:d.jsxs(sa,{direction:"vertical",children:[d.jsx(In,{ref:_e,defaultSize:40,collapsible:!0,children:d.jsx(J2,{selectedTool:s,toolArgs:g,isExecuting:w,isConnected:i,onArgChange:Ne,onExecute:Ae,onSave:pt,onCancel:()=>{N&&N.abort()}})}),d.jsx(xi,{withHandle:!0}),d.jsx(In,{ref:ze,defaultSize:60,children:d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(eF,{results:at,copiedResult:_,previewMode:V,serverId:r,readResource:a,onCopy:We,onDelete:ft,onFullscreen:yt,onTogglePreview:()=>q(!V),onMaximize:xn,isMaximized:K})})})]})}),d.jsx(q2,{isOpen:G,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Gn,onCancel:()=>ee(!1)})]})}lq.displayName="ToolsTab";function FTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,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(Tn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>i(f.target.value),onBlur:s,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(hr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(Pd,{className:"h-4 w-4"})})}),d.jsxs(It,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(th,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(Po,{className:"h-4 w-4"})})}),d.jsx(It,{side:"bottom",children:"Reject all"})]})})]})}function BTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Md,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.params?.messages?.length||0,f=s.request.params?.maxTokens;return d.jsx(tl,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=r(s.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),f&&h.push(`max ${f} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function HTe({llmConfig:e}){const t=y.useRef(null);return{generateResponse:y.useCallback(async({request:a})=>{if(!e)throw new Error("LLM config is not available");const r=a.params||{},i=r.maxTokens,s=r.temperature;r.modelPreferences;const c=r.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!r,messagesCount:c.length,messages:c,params:r}),c.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:f,AIMessage:m}=await Mr(async()=>{const{HumanMessage:E,AIMessage:x}=await import("./index-Bfe1ynAS.js");return{HumanMessage:E,AIMessage:x}},__vite__mapDeps([1,2]));for(const E of c){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(i!==void 0&&(x.maxTokens=i),s!==void 0?x.temperature=s:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:w}=await Mr(async()=>{const{ChatOpenAI:S}=await import("./index-CSZqqrHs.js");return{ChatOpenAI:S}},__vite__mapDeps([0,1,2,3,4,5,6]));E=new w(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:w}=await Mr(async()=>{const{ChatAnthropic:S}=await import("./index-BSuQO5pd.js");return{ChatAnthropic:S}},__vite__mapDeps([7,3,2,4,1,6]));E=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await Mr(async()=>{const{ChatGoogleGenerativeAI:S}=await import("./index-BOIA9kd1.js");return{ChatGoogleGenerativeAI:S}},__vite__mapDeps([8,3,2,4,1,5]));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 VTe({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:f,llmConfig:m}){const[h,g]=y.useState("manual"),[v,E]=y.useState("stub-model"),[x,w]=y.useState("endTurn"),[S,_]=y.useState("assistant"),[k,N]=y.useState("text"),[C,A]=y.useState("positive"),[I,O]=y.useState(""),[M,j]=y.useState("image/png"),[B,G]=y.useState(!1),[ee,te]=y.useState(null),{generateResponse:ae,isAvailable:V}=HTe({llmConfig:m});y.useEffect(()=>{e&&(E("stub-model"),w("endTurn"),_("assistant"),N("text"),A("positive"),O(""),j("image/png"),te(null))},[e?.id]);const q=async()=>{if(!(!e||!V)){G(!0),te(null);try{const P=await ae({request:e.request});E(P.model||m?.model||"stub-model"),w(P.stopReason||"endTurn"),_(P.role||"assistant");const F=Array.isArray(P.content)?P.content[0]:P.content;F.type==="text"?(N("text"),A(F.text||"")):F.type==="image"&&(N("image"),O(F.data||""),j(F.mimeType||"image/png"))}catch(P){const F=P instanceof Error?P.message:"Failed to generate response";te(F),ct.error("LLM Generation Failed",{description:F})}finally{G(!1)}}},H=y.useMemo(()=>{const P={model:v,stopReason:x,role:S,content:{type:k}};return k==="text"?P.content.text=C:k==="image"&&(P.content.data=I,P.content.mimeType=M),P},[v,x,S,k,C,I,M]),ie=()=>{if(!e)return;const P=bN.safeParse(H);if(!P.success){ct.error("Invalid response",{description:`Validation failed: ${P.error.message}`});return}t(e.id,P.data),a(),Mr(()=>Promise.resolve().then(()=>kd),void 0).then(F=>{const U=ct(F.createElement("div",{className:"space-y-3"},F.createElement("div",null,F.createElement("strong",null,"Sampling Response Sent"),F.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),F.createElement("div",{className:"flex gap-2"},F.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const L=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(L),ct.dismiss(U)}},"View Tool Result"))),{duration:5e3})})},re=()=>{e&&(n(e.id,"User rejected sampling request"),a())};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(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?d.jsx(mr,{className:"h-4 w-4 text-green-600"}):d.jsx(er,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Copy request"})]}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(Mm,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Download request"})]}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(sC,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Fullscreen"})]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(no,{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(Qn,{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(Xt,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),d.jsxs(Gi,{value:h,onValueChange:P=>g(P),children:[d.jsx(Ki,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:d.jsx(Wi,{})}),d.jsxs(Zi,{children:[d.jsx(Er,{value:"manual",children:"Manual"}),d.jsx(Er,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&d.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[V?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Le,{onClick:q,disabled:B,size:"sm",className:"flex items-center gap-2",children:B?d.jsxs(d.Fragment,{children:[d.jsx(Fs,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):d.jsxs(d.Fragment,{children:[d.jsx(Vhe,{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."}),ee&&d.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:ee})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`model-${e.id}`,children:"Model"}),d.jsx(Tn,{id:`model-${e.id}`,value:v,onChange:P=>E(P.target.value),placeholder:"stub-model",disabled:h==="llm"&&B})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),d.jsx(Tn,{id:`stopReason-${e.id}`,value:x,onChange:P=>w(P.target.value),placeholder:"endTurn",disabled:h==="llm"&&B})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`role-${e.id}`,children:"Role"}),d.jsxs(Gi,{value:S,onValueChange:P=>_(P),disabled:h==="llm"&&B,children:[d.jsx(Ki,{id:`role-${e.id}`,children:d.jsx(Wi,{})}),d.jsxs(Zi,{children:[d.jsx(Er,{value:"assistant",children:"assistant"}),d.jsx(Er,{value:"user",children:"user"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),d.jsxs(Gi,{value:k,onValueChange:P=>N(P),disabled:h==="llm"&&B,children:[d.jsx(Ki,{id:`contentType-${e.id}`,children:d.jsx(Wi,{})}),d.jsxs(Zi,{children:[d.jsx(Er,{value:"text",children:"text"}),d.jsx(Er,{value:"image",children:"image"})]})]})]}),k==="text"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`text-${e.id}`,children:"Text Content"}),d.jsx(Jl,{id:`text-${e.id}`,value:C,onChange:P=>A(P.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&B})]}),k==="image"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),d.jsx(Jl,{id:`imageData-${e.id}`,value:I,onChange:P=>O(P.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&B})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),d.jsx(Tn,{id:`mimeType-${e.id}`,value:M,onChange:P=>j(P.target.value),placeholder:"image/png",disabled:h==="llm"&&B})]})]})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Le,{onClick:ie,className:"flex-1",disabled:h==="llm"&&B,children:"Approve"}),d.jsx(Le,{onClick:re,variant:"outline",className:"flex-1",disabled:h==="llm"&&B,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"})})}function GTe({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=oc(),{llmConfig:u}=LY({mcpServerUrl:i}),[f,m]=y.useState(null),[h,g]=y.useState(""),[v,E]=y.useState(-1),[x,w]=y.useState(!0),[S,_]=y.useState(!1),[k,N]=y.useState(!0),[C,A]=y.useState(!1),I=y.useRef(null),O=y.useRef(null),M=y.useRef(null),j=y.useRef(!1);y.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:s,pendingRequestsCount:e.length,currentSelectedId:f?.id}),s&&e.length>0){const H=e.find(ie=>ie.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!H,H?.id),H&&(console.log("[SamplingTab] Auto-selecting request:",H.id),c(null),m(H),setTimeout(()=>{const ie=document.getElementById(`sampling-request-${H.id}`);console.log("[SamplingTab] Scrolling to element:",!!ie),ie&&ie.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),y.useEffect(()=>{const H=ie=>{const P=ie.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",P);const F=e.find(U=>U.id===P);F&&(console.log("[SamplingTab] Selecting request from event:",P),m(F),setTimeout(()=>{const U=document.getElementById(`sampling-request-${P}`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",H),()=>window.removeEventListener("navigate-to-sampling",H)},[e]),y.useEffect(()=>{x&&e.length>0&&I.current&&!j.current&&(I.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const H=I.current;if(!H)return;const ie=()=>{H.scrollTop>0&&(j.current=!0,w(!1))};return H.addEventListener("scroll",ie),()=>H.removeEventListener("scroll",ie)},[]),y.useEffect(()=>{e.length===0&&(j.current=!1,w(!0))},[e.length]),y.useEffect(()=>{S&&M.current&&M.current.focus()},[S]);const B=y.useCallback(()=>{h.trim()||_(!1)},[h]),G=y.useMemo(()=>{if(!h.trim())return e;const H=h.toLowerCase();return e.filter(ie=>ie.serverName.toLowerCase().includes(H)||JSON.stringify(ie.request||{}).toLowerCase().includes(H))},[e,h]);y.useEffect(()=>{E(-1)},[h]),y.useEffect(()=>{const H=ie=>{const re=ie.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||ie.metaKey||ie.ctrlKey||ie.altKey)return;const F=G;if(ie.key==="ArrowDown")ie.preventDefault(),E(U=>{const L=U+1;return L>=F.length?0:L});else if(ie.key==="ArrowUp")ie.preventDefault(),E(U=>{const L=U-1;return L<0?F.length-1:L});else if(ie.key==="Enter"&&v>=0){ie.preventDefault();const U=G[v];U&&ee(U)}};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[v,G]),y.useEffect(()=>{if(v>=0){const H=`sampling-request-${G[v]?.id}`,ie=document.getElementById(H);ie&&ie.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,G]);const ee=y.useCallback(H=>{m(H)},[]),te=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(H=>{n(H.id,"User rejected all requests")}),m(null))},[e,n]),ae=y.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)),A(!0),setTimeout(()=>A(!1),2e3)}catch(H){console.error("[SamplingTab] Failed to copy request:",H)}},[f]),V=y.useCallback(()=>{if(f)try{const H=new globalThis.Blob([JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)],{type:"application/json"}),ie=URL.createObjectURL(H),re=document.createElement("a");re.href=ie,re.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(ie)}catch(H){console.error("[SamplingTab] Failed to download request:",H)}},[f]),q=y.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(H){console.error("[SamplingTab] Failed to toggle fullscreen:",H)}},[]);return r?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(In,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(In,{defaultSize:75,minSize:30,children:[d.jsx(FTe,{isSearchExpanded:S,searchQuery:h,filteredRequestsCount:G.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:B,onRejectAll:te,searchInputRef:M}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(BTe,{requests:G,selectedRequest:f,onRequestSelect:ee,focusedIndex:v,formatRelativeTime:ry,listRef:I})})]})})}),d.jsx(xi,{}),d.jsx(In,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(VTe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>N(!k),isCopied:C,onCopy:ae,onDownload:V,onFullscreen:q,llmConfig:u})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZG,{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 WTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onCancelAll:c,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(Tn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>i(f.target.value),onBlur:s,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(hr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(Pd,{className:"h-4 w-4"})})}),d.jsxs(It,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(th,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(no,{className:"h-4 w-4"})})}),d.jsx(It,{side:"bottom",children:"Cancel all"})]})})]})}function KTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Md,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.mode||"form",f=u==="form"&&"requestedSchema"in s.request&&s.request.requestedSchema;return d.jsx(tl,{id:`elicitation-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,d.jsx(hr,{variant:"outline",className:u==="url"?"bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50":"bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50",children:u})]}),description:(()=>{const m=r(s.timestamp),h=[];f&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function ZTe({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:f}){const[m,h]=y.useState({}),[g,v]=y.useState(!1),E=e?.request.mode||"form",x=E==="form",w=E==="url";y.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const I=e.request.requestedSchema,O={};if(I?.type==="object"&&I.properties)for(const[M,j]of Object.entries(I.properties)){const B=j;B.default!==void 0?O[M]=B.default:B.type==="boolean"?O[M]=!1:B.type==="number"||B.type==="integer"?O[M]=0:O[M]=""}h(O)}v(!1)},[e?.id,x]);const S=(I,O)=>{h(M=>({...M,[I]:O}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const I=e.request.requestedSchema;if(I?.required){const O=I.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(O.length>0){ct.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"});a(),Mr(()=>Promise.resolve().then(()=>kd),void 0).then(I=>{const O=ct(I.createElement("div",{className:"space-y-3"},I.createElement("div",null,I.createElement("strong",null,"Elicitation Response Sent"),I.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),I.createElement("div",{className:"flex gap-2"},I.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),ct.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),a())},N=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},C=()=>{e&&w&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},A=y.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const I=e.request.requestedSchema;if(!I||I.type!=="object"||!I.properties)return d.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=I.properties,M=I.required||[];return d.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([j,B])=>{const G=B,ee=M.includes(j),te=G.type||"string",ae=G.title||j,V=G.description;return d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:`field-${j}`,children:[ae,ee&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),V&&d.jsx("p",{className:"text-xs text-muted-foreground",children:V}),te==="boolean"?d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(om,{id:`field-${j}`,checked:m[j]||!1,onCheckedChange:q=>S(j,q)}),d.jsx(Xt,{htmlFor:`field-${j}`,className:"text-sm font-normal cursor-pointer",children:G.title||j})]}):te==="number"||te==="integer"?d.jsx(Tn,{id:`field-${j}`,type:"number",value:m[j]||"",onChange:q=>S(j,te==="integer"?parseInt(q.target.value,10):parseFloat(q.target.value)),placeholder:G.default?.toString()||""}):G.enum?d.jsxs("select",{id:`field-${j}`,value:m[j]||"",onChange:q=>S(j,q.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..."}),G.enum.map(q=>d.jsx("option",{value:q,children:q},q))]}):te==="string"&&(G.format==="textarea"||G.maxLength>100)?d.jsx(Jl,{id:`field-${j}`,value:m[j]||"",onChange:q=>S(j,q.target.value),placeholder:G.default||"",rows:4}):d.jsx(Tn,{id:`field-${j}`,type:"text",value:m[j]||"",onChange:q=>S(j,q.target.value),placeholder:G.default||""})]},j)})})},[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(hr,{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(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?d.jsx(mr,{className:"h-4 w-4 text-green-600"}):d.jsx(er,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Copy request"})]}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(Mm,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Download request"})]}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(sC,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Fullscreen"})]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(no,{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:C,className:"flex items-center gap-2",children:[d.jsx(t_,{className:"h-4 w-4"}),"Open URL"]})]}),d.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[d.jsx(om,{id:"url-completed",checked:g,onCheckedChange:I=>v(!!I)}),d.jsx(Xt,{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"}),A]}),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(Qn,{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:k,variant:"outline",className:"flex-1",children:"Decline"}),d.jsx(Le,{onClick:N,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:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=oc(),[c,u]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,E]=y.useState(!0),[x,w]=y.useState(!1),[S,_]=y.useState(!0),[k,N]=y.useState(!1),C=y.useRef(null),A=y.useRef(null),I=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:c?.id}),i&&e.length>0){const V=e.find(q=>q.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!V,V?.id),V&&(console.log("[ElicitationTab] Auto-selecting request:",V.id),s(null),u(V),setTimeout(()=>{const q=document.getElementById(`elicitation-request-${V.id}`);console.log("[ElicitationTab] Scrolling to element:",!!q),q&&q.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,s]),y.useEffect(()=>{const V=q=>{const ie=q.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",ie);const re=e.find(P=>P.id===ie);re&&(console.log("[ElicitationTab] Selecting request from event:",ie),u(re),setTimeout(()=>{const P=document.getElementById(`elicitation-request-${ie}`);P&&P.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",V),()=>window.removeEventListener("navigate-to-elicitation",V)},[e]),y.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const V=C.current;if(!V)return;const q=()=>{V.scrollTop>0&&(O.current=!0,E(!1))};return V.addEventListener("scroll",q),()=>V.removeEventListener("scroll",q)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const M=y.useCallback(()=>{f.trim()||w(!1)},[f]),j=y.useMemo(()=>{if(!f.trim())return e;const V=f.toLowerCase();return e.filter(q=>q.serverName.toLowerCase().includes(V)||q.request.message.toLowerCase().includes(V)||JSON.stringify(q.request||{}).toLowerCase().includes(V))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const V=q=>{const H=q.target;if(H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.contentEditable==="true"||q.metaKey||q.ctrlKey||q.altKey)return;const re=j;if(q.key==="ArrowDown")q.preventDefault(),g(P=>{const F=P+1;return F>=re.length?0:F});else if(q.key==="ArrowUp")q.preventDefault(),g(P=>{const F=P-1;return F<0?re.length-1:F});else if(q.key==="Enter"&&h>=0){q.preventDefault();const P=j[h];P&&B(P)}};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[h,j]),y.useEffect(()=>{if(h>=0){const V=`elicitation-request-${j[h]?.id}`,q=document.getElementById(V);q&&q.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,j]);const B=y.useCallback(V=>{u(V)},[]),G=y.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(V=>{n(V.id,"User cancelled all requests")}),u(null))},[e,n]),ee=y.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)),N(!0),setTimeout(()=>N(!1),2e3)}catch(V){console.error("[ElicitationTab] Failed to copy request:",V)}},[c]),te=y.useCallback(()=>{if(c)try{const V=new globalThis.Blob([JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)],{type:"application/json"}),q=URL.createObjectURL(V),H=document.createElement("a");H.href=q,H.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(H),H.click(),document.body.removeChild(H),URL.revokeObjectURL(q)}catch(V){console.error("[ElicitationTab] Failed to download request:",V)}},[c]),ae=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(V){console.error("[ElicitationTab] Failed to toggle fullscreen:",V)}},[]);return r?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(In,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(In,{defaultSize:75,minSize:30,children:[d.jsx(WTe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:j.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:G,searchInputRef:I}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(KTe,{requests:j,selectedRequest:c,onRequestSelect:B,focusedIndex:h,formatRelativeTime:ry,listRef:C})})]})})}),d.jsx(xi,{}),d.jsx(In,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(ZTe,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:S,onTogglePreview:()=>_(!S),isCopied:k,onCopy:ee,onDownload:te,onFullscreen:ae})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(QG,{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 qTe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:d.jsx(lq,{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(aq,{ref:a,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(oq,{ref:r,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(Kke,{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(GTe,{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(kTe,{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:i})]}):d.jsx(d.Fragment,{children:i})}function aF({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 cq=y.createContext(void 0);function uq(){const e=y.use(cq);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const dq=y.createContext(void 0);function XTe(){return y.use(dq)}function ck({ref:e,children:t,defaultValue:n,value:a,onValueChange:r,className:i,collapsed:s,onCollapsedChange:c,...u}){const[f,m]=y.useState(n||""),h=a!==void 0,g=s!==void 0,[v,E]=y.useState(!1),x=y.useCallback(k=>{h||m(k),r?.(k)},[h,r]),w=h?a:f,S=g?s:v,_=y.useCallback(k=>{g||E(k),c?.(k)},[g,c]);return d.jsx(cq,{value:{activeValue:w,handleValueChange:x,collapsed:S,handleCollapsedChange:_},children:d.jsx("div",{ref:e,className:Me("flex flex-col gap-2",i),...u,children:t})})}ck.displayName="Tabs";function uk({ref:e,children:t,className:n,variant:a="default",collapsible:r=!1,...i}){const{activeValue:s,collapsed:c,handleCollapsedChange:u}=uq(),[f,m]=y.useState({width:0,left:0}),h=y.useRef(null),g=y.useRef(null),v=y.useRef(null),E=y.useCallback(()=>{const S=h.current;if(!S)return;const _=S.querySelector("div:first-child");if(!_)return;const k=_.querySelector(`button[data-tab-value="${s}"]`);if(k&&s){const N=_.getBoundingClientRect(),C=k.getBoundingClientRect();m({width:C.width,left:C.left-N.left})}else m({width:0,left:0})},[s]),x=y.useCallback(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(E,16)},[E]);y.useEffect(()=>{const S=setTimeout(E,10);return()=>clearTimeout(S)},[E,c]),y.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(N=>{g.current&&g.current.observe(N)}),()=>{g.current&&g.current.disconnect(),v.current&&clearTimeout(v.current)}},[x]),y.useEffect(()=>{const S=()=>{x()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[x]);const w=y.useRef(null);return y.useEffect(()=>{w.current&&(w.current.style.width=`${f.width}px`,w.current.style.left=`${f.left}px`)},[f]),d.jsx(dq,{value:{variant:a,collapsed:c,handleCollapsedChange:u},children:d.jsx("div",{ref:h,className:Me("relative flex items-center bg-none gap-1",a==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",a==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...i,children:d.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,d.jsx("span",{ref:w,className:Me("absolute transition-all duration-500 ease-in-out z-0",a==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",a==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}uk.displayName="TabsList";const JTe=({children:e,title:t,collapsed:n})=>!t||!n?e:d.jsx(nC,{children:d.jsxs(Rt,{children:[d.jsx(At,{children:e}),d.jsx(It,{children:t})]})}),dk=y.forwardRef(({children:e,value:t,className:n,disabled:a,icon:r,title:i,...s},c)=>{const{activeValue:u,handleValueChange:f,collapsed:m}=uq(),g=XTe()?.variant||"default",v=u===t,E=m&&i?i:void 0;return d.jsx(JTe,{title:i,collapsed:m,children:d.jsxs("button",{ref:c,disabled:a,onClick:()=>f(t),"data-tab-value":t,"data-tab-active":v,role:"tab","aria-selected":v?"true":"false",title:E,className:Me("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",g==="default"&&"py-2.5",g==="default"&&"rounded-md px-4",g==="underline"&&"px-6 py-3 border-b-2 border-transparent",v&&"text-foreground",!v&&"text-muted-foreground hover:text-foreground",n),...s,children:[r&&d.jsx(r,{className:Me("h-4 w-4 transition-all duration-500 ease-in-out",!m&&"mr-2",m&&"mr-0!")}),d.jsx("span",{className:Me("transition-all duration-500 ease-in-out overflow-hidden",m?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});dk.displayName="TabsTrigger";function iF({serverUrl:e,serverName:t,headers:n,className:a}){const[r,i]=y.useState(!1),[s,c]=y.useState(null),[u,f]=y.useState(!1),m=()=>{try{const _=iy(e,t,n);window.location.href=_,ct.success("Opening in Cursor...")}catch(_){console.error("Failed to generate Cursor deep link:",_),ct.error("Failed to open in Cursor")}},h=()=>{try{const _=oy(e,t,n);window.location.href=_,ct.success("Opening in VS Code...")}catch(_){console.error("Failed to generate VS Code deep link:",_),ct.error("Failed to open in VS Code")}},g=()=>{try{sy(e,t,n),ct.success("Downloaded .mcpb file")}catch(_){console.error("Failed to download .mcpb file:",_),ct.error("Failed to download configuration file")}},v=()=>{c("claude-code"),i(!0)},E=()=>{c("gemini-cli"),i(!0)},x=()=>{c("codex-cli"),i(!0)},w=async _=>{try{await navigator.clipboard.writeText(_),f(!0),ct.success("Copied to clipboard"),setTimeout(()=>f(!1),2e3)}catch(k){console.error("Failed to copy:",k),ct.error("Failed to copy to clipboard")}},S=()=>{if(s==="claude-code"){const{command:_,envVars:k}=ly(e,t,n),N=kp(k);return d.jsxs(d.Fragment,{children:[d.jsxs(js,{children:[d.jsx(Ls,{children:"Add to Claude Code"}),d.jsx(Ub,{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:()=>w(_),children:u?d.jsx(mr,{className:"size-3.5 text-green-600"}):d.jsx(er,{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:_})})]}),N&&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:N})})]}),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(s==="gemini-cli"){const{command:_,envVars:k}=cy(e,t,n),N=kp(k);return d.jsxs(d.Fragment,{children:[d.jsxs(js,{children:[d.jsx(Ls,{children:"Add to Gemini CLI"}),d.jsx(Ub,{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"})]}),N&&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:N?"3.":"2."}),d.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),N&&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:N})})]}),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:()=>w(_),children:u?d.jsx(mr,{className:"size-3.5 text-green-600"}):d.jsx(er,{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:_})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Gemini CLI to load the new configuration."})]})]})}if(s==="codex-cli"){const{config:_,envVars:k}=uy(e,t,n);return d.jsxs(d.Fragment,{children:[d.jsxs(js,{children:[d.jsx(Ls,{children:"Add to Codex CLI"}),d.jsxs(Ub,{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:()=>w(_),children:u?d.jsx(mr,{className:"size-3.5 text-green-600"}):d.jsx(er,{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:_})})]}),k.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};return d.jsxs(d.Fragment,{children:[d.jsxs(Av,{children:[d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Iv,{asChild:!0,children: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 ${a||""}`,"aria-label":"Add to Client",children:[d.jsx("span",{className:"hidden sm:inline ml-2",children:"Add to Client"}),d.jsx(qs,{className:"size-3 ml-1"})]})})}),d.jsx(It,{children:d.jsx("p",{children:"Add to Client"})})]}),d.jsxs(zp,{align:"end",className:"w-48",children:[d.jsxs(ia,{onClick:m,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",{children:"Cursor"})]}),d.jsxs(ia,{onClick:v,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",{children:"Claude Code"})]}),d.jsxs(ia,{onClick:g,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",{children:"Claude Desktop"})]}),d.jsxs(ia,{onClick:h,className:"flex items-center gap-2",children:[d.jsx(FK,{className:"h-4 w-4"}),d.jsx("span",{children:"VS Code"})]}),d.jsxs(ia,{onClick:E,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",{children:"Gemini CLI"})]}),d.jsxs(ia,{onClick:x,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",{children:"Codex CLI"})]})]})]}),d.jsx(ku,{open:r,onOpenChange:i,children:d.jsx(Tu,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:S()})})]})}function oF({className:e}){const{theme:t,setTheme:n}=A0(),a=y.useRef(null),[r,i]=y.useState(!1);y.useEffect(()=>{i(!0)},[]);const s=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?d.jsx(uU,{className:"size-4"}):t==="light"?d.jsx(Yhe,{className:"size-5"}):d.jsx(Che,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",f=async()=>{if(!a.current)return;const m=s();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{Od.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:E}=a.current.getBoundingClientRect(),x=h+E/2,w=g+v/2,S=window.innerWidth-g,_=window.innerHeight-h,k=Math.hypot(Math.max(g,S),Math.max(h,_));document.documentElement.animate({clipPath:[`circle(0px at ${w}px ${x}px)`,`circle(${k}px at ${w}px ${x}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?d.jsx("button",{ref:a,onClick:f,className:Me(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):d.jsx("button",{ref:a,className:Me(e),"aria-label":"Toggle theme",children:d.jsx(uU,{className:"size-4"})})}function sF({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[a,r]=y.useState(!1),i=.2,s=.7,c=.6,u=4,f=i+s+c,m=0,h=i/f,g=(i+s)/f,v=1;return d.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Me("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[d.jsx("div",{className:"relative",children:d.jsxs(xa.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:Me("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[d.jsxs(xa.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:f,times:[m,h,g,v],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(QTe,{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z",times:{T0:m,T1:h,T2:g,T3:v},total:f}),d.jsx(lF,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f}),d.jsx(lF,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f})]})]})}),t==="expanded"&&d.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",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 QTe({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return d.jsx(xa.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[a,r,i,s],ease:"easeInOut"}}}})}function lF({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return d.jsx(xa.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:r,times:[i,s,c,u],ease:"easeInOut"}}}})}function fq({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:f}=A0(),m=f==="dark"?"#000000":"#ffffff",h=f==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=i||h;return d.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":r,"--speed":a,"--cut":n,"--bg":v},className:Me("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",f==="dark"?"border-black/10 text-black":"border-white/10 text-white",s),ref:e,...u,children:[d.jsx("div",{className:Me("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:d.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [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))]"})})}),c,d.jsx("div",{className:Me("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",f==="dark"?"shadow-[inset_0_-8px_10px_#0000001f] group-hover:shadow-[inset_0_-6px_10px_#0000003f] group-active:shadow-[inset_0_-10px_10px_#0000003f]":"shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]")}),d.jsx("div",{className:Me("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}fq.displayName="ShimmerButton";function cF({status:e}){const t=i=>{switch(i){case"ready":return{color:"bg-emerald-500",ringColor:"ring-emerald-500",tooltip:"Connected"};case"failed":return{color:"bg-red-500",ringColor:"ring-red-500",tooltip:"Failed"};default:return{color:"bg-yellow-500",ringColor:"ring-yellow-500",tooltip:i}}},{color:n,ringColor:a,tooltip:r}=t(e);return d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),d.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),d.jsx(It,{children:d.jsx("p",{children:r})})]})}function uF({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=Rd(),s=c=>{const u=e.find(f=>f.id===c);if(!u||u.state!=="ready"){ct.error("Server is not connected and cannot be inspected");return}n(c)};return r?d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("div",{className:"relative",children:d.jsxs(Av,{children:[d.jsx(Iv,{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(Dl,{serverUrl:t.url,serverName:t.name,size:"md"}):d.jsx(zhe,{className:"h-5 w-5"}),d.jsx(qs,{className:"h-4 w-4"})]})}),d.jsxs(zp,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(JE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),d.jsx(rp,{}),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(c=>d.jsxs(ia,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[d.jsx(Dl,{serverUrl:c.url,serverName:c.name,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:c.name}),d.jsx(cF,{status:c.state})]}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:d.jsx(_u,{className:"h-3 w-3"})})]},c.id)),d.jsx(rp,{}),d.jsx(ia,{onClick:()=>i("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("div",{className:"relative",children:d.jsxs(Av,{children:[d.jsx(Iv,{asChild:!0,children:d.jsxs(fq,{className:Me("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-10"),children:[t&&d.jsx(Dl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&d.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx("button",{onClick:c=>{c.stopPropagation()},className:"w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors",title:"Click to copy error message","aria-label":"Copy error message to clipboard"})}),d.jsx(It,{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(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx("button",{type:"button",onClick:()=>{a(t.id)},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"Edit connection settings",children:d.jsx(_u,{className:"h-4 w-4"})})}),d.jsx(It,{children:d.jsx("p",{children:"Edit connection settings"})})]}),d.jsxs(zp,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(JE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),d.jsx(rp,{}),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(c=>d.jsxs(ia,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[d.jsx(Dl,{serverUrl:c.url,serverName:c.name,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:c.name}),d.jsx(cF,{status:c.state})]}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:d.jsx(_u,{className:"h-3 w-3"})})]},c.id)),d.jsx(rp,{}),d.jsx(ia,{onClick:()=>i("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const dF=[{id:"tools",label:"Tools",icon:Kl},{id:"prompts",label:"Prompts",icon:Vp},{id:"resources",label:"Resources",icon:dhe},{id:"sampling",label:"Sampling",icon:ZG},{id:"elicitation",label:"Elicitation",icon:QG},{id:"notifications",label:"Notifications",icon:aC},{id:"chat",label:"Chat",icon:Ehe}];function fF(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 eNe({collapsed:e,onToggle:t}){return d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx("button",{onClick:t,className:Me("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(WG,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):d.jsx(a0,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),d.jsx(It,{children:d.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function tNe({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s,embedded:c=!1}){const{tunnelUrl:u}=oc(),f=t&&u,[m,h]=y.useState(!1),[g,v]=y.useState(!0),E=async()=>{if(u)try{await navigator.clipboard.writeText(`${u}/mcp`),h(!0),ct.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{ct.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:[!c&&d.jsx("div",{className:"flex-1 flex justify-start",children:d.jsx(uF,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),!c&&d.jsx("div",{className:"flex-shrink-0 flex justify-center",children:d.jsx("div",{className:"scale-150",children:d.jsx(sF,{state:"collapsed"})})}),!c&&d.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[t&&d.jsx(iF,{serverUrl:u?`${u}/mcp`:t.url,serverName:t.name,headers:t.customHeaders,className:"p-2"}),d.jsxs(Rt,{children:[d.jsx(At,{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(aF,{className:"h-4 w-4"})})})}),d.jsx(It,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(oF,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&d.jsx("div",{className:"w-full",children:d.jsx(ck,{value:n,onValueChange:x=>r(x),collapsed:g,onCollapsedChange:v,children:d.jsx(uk,{className:"w-full justify-center",children:dF.map(x=>{const w=fF(x.id,t);return d.jsxs(dk,{value:x.id,icon:x.icon,className:Me("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",g&&"pl-2"),children:[w>0&&d.jsx("span",{className:Me(n===x.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:w}),d.jsx("span",{className:"sr-only",children:x.label})]},x.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:[!c&&d.jsx(uF,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ck,{value:n,onValueChange:x=>r(x),collapsed:g,onCollapsedChange:v,children:d.jsx(uk,{className:"overflow-x-auto",collapsible:!0,children:dF.map(x=>{const w=fF(x.id,t),S=w>0?`${x.label} (${w})`:x.label;return d.jsx(dk,{value:x.id,icon:x.icon,className:Me("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",g&&"pl-4"),title:S,children:d.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[x.label,w>0&&d.jsx("span",{className:Me(n===x.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:w})]})})})})}),d.jsx(eNe,{collapsed:g,onToggle:()=>v(!g)})]}),f&&d.jsxs(iZ,{children:[d.jsx(oZ,{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(Gp,{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(QC,{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(Gp,{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:E,children:m?d.jsx(mr,{className:"size-3.5 text-green-600"}):d.jsx(er,{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"})]})]})]})]})})]})]}),!c&&d.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[t&&d.jsx(iF,{serverUrl:u?`${u}/mcp`:t.url,serverName:t.name,headers:t.customHeaders}),d.jsxs(Rt,{children:[d.jsx(At,{children:d.jsx(oF,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),d.jsx(It,{children:d.jsx("p",{children:"Toggle theme"})})]}),d.jsxs(Rt,{children:[d.jsx(At,{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:i,children:[d.jsx(Zme,{className:"size-4"}),d.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),d.jsx(It,{children:d.jsx("p",{children:"Command Palette"})})]}),d.jsxs(Rt,{children:[d.jsx(At,{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(aF,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),d.jsx(It,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(sF,{state:"expanded"})]})]})]})}function nNe({children:e}){const t=Rd(),n=Ho(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=rC(),{selectedServerId:u,setSelectedServerId:f,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v,tunnelUrl:E,isEmbedded:x,embeddedConfig:w,setEmbeddedMode:S}=oc(),[_,k]=y.useState(!1),[N,C]=y.useState(null),A=fxe();y.useEffect(()=>{const F=new URLSearchParams(n.search),U=F.get("embedded")==="true",L=F.get("embeddedConfig");if(U){let $={};if(L)try{$=JSON.parse(L)}catch(W){console.error("Failed to parse embeddedConfig:",W)}S(!0,$)}},[]),y.useEffect(()=>{const U=new URLSearchParams(n.search).get("tunnelUrl");v(U)},[n.search,v]),y.useEffect(()=>{const F=$=>{const K=$.detail.requestId;u&&g(u,"sampling",K)},U=$=>{const K=$.detail.requestId;u&&g(u,"elicitation",K)},L=$=>{const K=$.detail.toolName;u&&K?g(u,"tools",K):u&&h("tools")};return window.addEventListener("navigate-to-sampling",F),window.addEventListener("navigate-to-elicitation",U),window.addEventListener("navigate-to-tool-result",L),()=>{window.removeEventListener("navigate-to-sampling",F),window.removeEventListener("navigate-to-elicitation",U),window.removeEventListener("navigate-to-tool-result",L)}},[u,h,g]);const I=y.useRef(null),O=y.useRef(null),M=y.useRef(null),{isAutoConnecting:j}=dxe({connections:a,addConnection:r,removeConnection:i,configLoaded:c,embedded:x}),B=y.useCallback(F=>{_r.getInstance().capture(new mme({trigger:F})).catch(()=>{}),k(!0)},[]),G=F=>{const U=a.find(K=>K.id===F);if(!U||U.state!=="ready"){ct.error("Server is not connected and cannot be inspected");return}f(F);const $=new URLSearchParams(n.search).get("tunnelUrl"),W=$?`/?server=${encodeURIComponent(F)}&tunnelUrl=${encodeURIComponent($)}`:`/?server=${encodeURIComponent(F)}`;t(W)},ee=y.useCallback(F=>{C(F)},[]),te=y.useCallback(F=>{N&&(F.url!==N?(i(N),r(F.url,F.name,F.proxyConfig,F.transportType)):s(N,{name:F.name,proxyConfig:F.proxyConfig,transportType:F.transportType}),C(null),ct.success("Connection settings updated"))},[N,i,r,s]),ae=(F,U,L)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:F,itemName:U,serverId:L}),L){const $=a.find(se=>se.id===L);if(console.warn("[Layout] Server lookup:",{serverId:L,serverFound:!!$,serverState:$?.state}),!$||$.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),ct.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:L,tab:F,itemName:U}),g(L,F,U);const K=new URLSearchParams(n.search).get("tunnelUrl"),Y=K?`/?server=${encodeURIComponent(L)}&tunnelUrl=${encodeURIComponent(K)}`:`/?server=${encodeURIComponent(L)}`;console.warn("[Layout] Navigating to:",Y),t(Y)}else console.warn("[Layout] No serverId, just updating tab to:",F),h(F)},V=a.find(F=>F.id===u),q=V?V.tools.map(F=>({...F,_serverId:V.id})):a.flatMap(F=>F.state==="ready"?F.tools.map(U=>({...U,_serverId:F.id,_serverName:F.name})):[]),H=V?V.prompts.map(F=>({...F,_serverId:V.id})):a.flatMap(F=>F.state==="ready"?F.prompts.map(U=>({...U,_serverId:F.id,_serverName:F.name})):[]),ie=V?V.resources.map(F=>({...F,_serverId:V.id})):a.flatMap(F=>F.state==="ready"?F.resources.map(U=>({...U,_serverId:F.id,_serverName:F.name})):[]);if(y.useEffect(()=>{const U=new URLSearchParams(n.search).get("server"),L=U?decodeURIComponent(U):null;L!==u&&f(L)},[n.search,u,f]),y.useEffect(()=>{const U=new URLSearchParams(n.search).get("server");if(!U)return;const L=decodeURIComponent(U),$=a.find(W=>W.id===L);if(!$){const W=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(W)}if($.state==="failed"){const W=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(W)}},[n.search,t,a]),OK({onCommandPalette:()=>B("keyboard"),onToolsTab:()=>{V&&h("tools")},onPromptsTab:()=>{V&&h("prompts")},onResourcesTab:()=>{V&&h("resources")},onChatTab:()=>{V&&h("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{m==="tools"&&I.current?I.current.focusSearch():m==="prompts"&&O.current?O.current.focusSearch():m==="resources"&&M.current&&M.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&I.current?I.current.blurSearch():m==="prompts"&&O.current?O.current.blurSearch():m==="resources"&&M.current&&M.current.blurSearch()}}),j)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(ki,{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 re=x?{backgroundColor:w.backgroundColor||"#f3f3f3",padding:w.padding||"0.5rem"}:{},P=x?"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(nC,{children:d.jsxs("div",{className:P,style:re,children:[d.jsx(tNe,{connections:a,selectedServer:V,activeTab:m,onServerSelect:G,onTabChange:h,onCommandPaletteOpen:()=>B("button"),onOpenConnectionOptions:ee,embedded:x}),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(qTe,{selectedServer:V,activeTab:m,toolsSearchRef:I,promptsSearchRef:O,resourcesSearchRef:M,children:e})}),d.jsx(zxe,{isOpen:_,onOpenChange:k,tools:q,prompts:H,resources:ie,savedRequests:A,connections:a,selectedServer:V,tunnelUrl:E,onNavigate:ae,onServerSelect:G}),d.jsx(Z7,{connection:N&&a.find(F=>F.id===N)||null,open:N!==null,onOpenChange:F=>{F||C(null)},onConnect:te})]})})}function rNe(){const[e,t]=y.useState("processing"),[n,a]=y.useState("");return y.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),TN().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(r=>{console.error("[OAuthCallback] Authorization failed:",r),t("error"),a(r instanceof Error?r.message:String(r))})},[]),e==="processing"?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(Fs,{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 aNe=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,f=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(E=>{let x=E==="class",w=x&&i?r.map(S=>i[S]||S):r;x?(u.classList.remove(...w),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(E,v)}),h(v)}function h(v){c&&f.includes(v)&&(u.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(a)m(a);else try{let v=localStorage.getItem(t)||n,E=s&&v==="system"?g():v;m(E)}catch{}},iNe=y.createContext(void 0),oNe={setTheme:e=>{},themes:[]},sNe=()=>{var e;return(e=y.useContext(iNe))!=null?e:oNe};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:a,enableColorScheme:r,defaultTheme:i,value:s,themes:c,nonce:u,scriptProps:f})=>{let m=JSON.stringify([n,t,i,e,c,s,a,r]).slice(1,-1);return y.createElement("script",{...f,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${aNe.toString()})(${m})`}})});function lNe({...e}){const{theme:t="system"}=sNe();return d.jsx(e7,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function cNe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true";return d.jsx(N_e,{children:d.jsx(vme,{embedded:t,children:d.jsxs(uxe,{children:[d.jsx(gle,{basename:"/inspector",children:d.jsxs(Kse,{children:[d.jsx(BE,{path:"/oauth/callback",element:d.jsx(rNe,{})}),d.jsx(BE,{path:"/",element:d.jsx(nNe,{children:d.jsx(cxe,{})})})]})}),d.jsx(lNe,{position:"top-center"})]})})})}const pF=new URLSearchParams(window.location.search);if(pF.has("code")||pF.has("error"))try{TN()}catch(e){console.error("[inspector] OAuth callback error:",e)}const mF=document.getElementById("root");mF?tse.createRoot(mF).render(d.jsx(cNe,{})):console.error("[inspector] Root element not found");export{LB as $,UF as A,je as B,Mr as C,$e as D,Ml as E,lv as F,joe as G,jb as H,Moe as I,Poe as J,CF as K,NJ as L,Ooe as M,pk as N,TN as O,FJ as P,Q as R,Ui as T,CJ as V,Gne as Z,Cy as _,kd as a,sd as b,VT as c,Pne as d,kne as e,ld as f,ay as g,X5 as h,fE as i,KT as j,vi as k,Rb as l,pE as m,sv as n,Jf as o,XF as p,ni as q,y as r,Rp as s,lu as t,od as u,K6 as v,W6 as w,jB as x,HF as y,QB as z};
|
|
1701
|
+
`),Se.document.close())}},[E]),xn=y.useCallback(()=>{K?(me.current&&me.current.expand(),_e.current&&_e.current.expand(),Y(!1)):(me.current&&me.current.collapse(),_e.current&&_e.current.collapse(),Y(!0))},[K]),pt=y.useCallback(()=>{s&&(ae(""),ee(!0))},[s]),Gn=y.useCallback(()=>{if(!s)return;const Ve={id:`${Date.now()}-${Math.random()}`,name:te.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};Ye([...j,Ve]),_r.getInstance().capture(new hme({toolName:s.name,serverId:r})).catch(()=>{}),ee(!1),ae("")},[s,te,g,j,Ye,r]),hn=y.useCallback(Ve=>{Ye(j.filter(Ue=>Ue.id!==Ve)),u?.id===Ve&&f(null)},[j,Ye,u]);return U?d.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[$!=="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:()=>{$==="response"?W("detail"):(c(null),W("list"))},className:"p-0 h-8 w-8",children:d.jsx(a0,{className:"h-4 w-4"})}),d.jsxs("div",{className:"flex items-center text-sm font-medium",children:[d.jsx("button",{onClick:()=>{c(null),W("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),$==="detail"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("button",{onClick:()=>{W("response")},className:$==="detail"?"text-foreground hover:underline":$==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),$==="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(d0,{initial:!1,mode:"popLayout",children:[$==="list"&&d.jsxs(xa.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(nF,{activeTab:O,isSearchExpanded:H,searchQuery:A,filteredToolsCount:fe.length,savedRequestsCount:j.length,onSearchExpand:()=>ie(!0),onSearchChange:I,onSearchBlur:Ee,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:F}),O==="tools"?d.jsx(tF,{tools:fe,selectedTool:s,onToolSelect:De,focusedIndex:re}):d.jsx(Y2,{savedRequests:j,selectedRequest:u,onLoadRequest:He,onDeleteRequest:hn,focusedIndex:re})]},"list"),$==="detail"&&d.jsx(xa.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(J2,{selectedTool:s,toolArgs:g,isExecuting:w,isConnected:i,onArgChange:Ne,onExecute:Ae,onSave:pt})},"detail"),$==="response"&&d.jsx(xa.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(eF,{results:at,copiedResult:_,previewMode:V,serverId:r,readResource:a,onCopy:We,onDelete:ft,onFullscreen:yt,onTogglePreview:()=>q(!V)})},"response")]})}),d.jsx(q2,{isOpen:G,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Gn,onCancel:()=>ee(!1)})]}):d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(In,{ref:me,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:d.jsxs(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[d.jsx(In,{defaultSize:75,minSize:30,children:d.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[d.jsx(nF,{activeTab:O,isSearchExpanded:H,searchQuery:A,filteredToolsCount:fe.length,savedRequestsCount:j.length,onSearchExpand:()=>ie(!0),onSearchChange:I,onSearchBlur:Ee,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:F}),O==="tools"?d.jsx(tF,{tools:fe,selectedTool:s,onToolSelect:De,focusedIndex:re}):d.jsx(Y2,{savedRequests:j,selectedRequest:u,onLoadRequest:He,onDeleteRequest:hn,focusedIndex:re})]})}),d.jsx(xi,{withHandle:!0}),d.jsxs(In,{ref:ue,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,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:Ve=>{Ve.preventDefault(),Ve.stopPropagation(),X?(ue.current?.resize(25),J(!1)):(ue.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"}),se>0&&d.jsx(hr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:se}),se>0&&!X&&d.jsx(Le,{variant:"ghost",size:"sm",onClick:Ve=>{Ve.preventDefault(),Ve.stopPropagation(),Pe.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:d.jsx(Po,{className:"h-3.5 w-3.5"})})]}),d.jsx(qs,{className:`h-4 w-4 text-muted-foreground transition-transform ${X?"":"rotate-180"}`})]}),d.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${X?"hidden":""}`,children:d.jsx(ID,{serverIds:[r],onCountChange:oe,onClearRef:Pe})})]})]})}),d.jsx(xi,{withHandle:!0}),d.jsx(In,{defaultSize:67,children:d.jsxs(sa,{direction:"vertical",children:[d.jsx(In,{ref:_e,defaultSize:40,collapsible:!0,children:d.jsx(J2,{selectedTool:s,toolArgs:g,isExecuting:w,isConnected:i,onArgChange:Ne,onExecute:Ae,onSave:pt,onCancel:()=>{N&&N.abort()}})}),d.jsx(xi,{withHandle:!0}),d.jsx(In,{ref:ze,defaultSize:60,children:d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(eF,{results:at,copiedResult:_,previewMode:V,serverId:r,readResource:a,onCopy:We,onDelete:ft,onFullscreen:yt,onTogglePreview:()=>q(!V),onMaximize:xn,isMaximized:K})})})]})}),d.jsx(q2,{isOpen:G,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Gn,onCancel:()=>ee(!1)})]})}lq.displayName="ToolsTab";function FTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,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(Tn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>i(f.target.value),onBlur:s,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(hr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(Pd,{className:"h-4 w-4"})})}),d.jsxs(It,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(th,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(Po,{className:"h-4 w-4"})})}),d.jsx(It,{side:"bottom",children:"Reject all"})]})})]})}function BTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Md,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.params?.messages?.length||0,f=s.request.params?.maxTokens;return d.jsx(tl,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=r(s.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),f&&h.push(`max ${f} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function HTe({llmConfig:e}){const t=y.useRef(null);return{generateResponse:y.useCallback(async({request:a})=>{if(!e)throw new Error("LLM config is not available");const r=a.params||{},i=r.maxTokens,s=r.temperature;r.modelPreferences;const c=r.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!r,messagesCount:c.length,messages:c,params:r}),c.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:f,AIMessage:m}=await Mr(async()=>{const{HumanMessage:E,AIMessage:x}=await import("./index-C2UfjD9L.js");return{HumanMessage:E,AIMessage:x}},__vite__mapDeps([1,2]));for(const E of c){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(i!==void 0&&(x.maxTokens=i),s!==void 0?x.temperature=s:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:w}=await Mr(async()=>{const{ChatOpenAI:S}=await import("./index-C69r9Nt9.js");return{ChatOpenAI:S}},__vite__mapDeps([0,1,2,3,4,5,6]));E=new w(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:w}=await Mr(async()=>{const{ChatAnthropic:S}=await import("./index-DXrgZUfu.js");return{ChatAnthropic:S}},__vite__mapDeps([7,3,2,4,1,6]));E=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await Mr(async()=>{const{ChatGoogleGenerativeAI:S}=await import("./index-Apq2pBJl.js");return{ChatGoogleGenerativeAI:S}},__vite__mapDeps([8,3,2,4,1,5]));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 VTe({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:f,llmConfig:m}){const[h,g]=y.useState("manual"),[v,E]=y.useState("stub-model"),[x,w]=y.useState("endTurn"),[S,_]=y.useState("assistant"),[k,N]=y.useState("text"),[C,A]=y.useState("positive"),[I,O]=y.useState(""),[M,j]=y.useState("image/png"),[B,G]=y.useState(!1),[ee,te]=y.useState(null),{generateResponse:ae,isAvailable:V}=HTe({llmConfig:m});y.useEffect(()=>{e&&(E("stub-model"),w("endTurn"),_("assistant"),N("text"),A("positive"),O(""),j("image/png"),te(null))},[e?.id]);const q=async()=>{if(!(!e||!V)){G(!0),te(null);try{const P=await ae({request:e.request});E(P.model||m?.model||"stub-model"),w(P.stopReason||"endTurn"),_(P.role||"assistant");const F=Array.isArray(P.content)?P.content[0]:P.content;F.type==="text"?(N("text"),A(F.text||"")):F.type==="image"&&(N("image"),O(F.data||""),j(F.mimeType||"image/png"))}catch(P){const F=P instanceof Error?P.message:"Failed to generate response";te(F),ct.error("LLM Generation Failed",{description:F})}finally{G(!1)}}},H=y.useMemo(()=>{const P={model:v,stopReason:x,role:S,content:{type:k}};return k==="text"?P.content.text=C:k==="image"&&(P.content.data=I,P.content.mimeType=M),P},[v,x,S,k,C,I,M]),ie=()=>{if(!e)return;const P=bN.safeParse(H);if(!P.success){ct.error("Invalid response",{description:`Validation failed: ${P.error.message}`});return}t(e.id,P.data),a(),Mr(()=>Promise.resolve().then(()=>kd),void 0).then(F=>{const U=ct(F.createElement("div",{className:"space-y-3"},F.createElement("div",null,F.createElement("strong",null,"Sampling Response Sent"),F.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),F.createElement("div",{className:"flex gap-2"},F.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const L=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(L),ct.dismiss(U)}},"View Tool Result"))),{duration:5e3})})},re=()=>{e&&(n(e.id,"User rejected sampling request"),a())};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(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?d.jsx(mr,{className:"h-4 w-4 text-green-600"}):d.jsx(er,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Copy request"})]}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(Mm,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Download request"})]}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(sC,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Fullscreen"})]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(no,{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(Qn,{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(Xt,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),d.jsxs(Gi,{value:h,onValueChange:P=>g(P),children:[d.jsx(Ki,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:d.jsx(Wi,{})}),d.jsxs(Zi,{children:[d.jsx(Er,{value:"manual",children:"Manual"}),d.jsx(Er,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&d.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[V?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Le,{onClick:q,disabled:B,size:"sm",className:"flex items-center gap-2",children:B?d.jsxs(d.Fragment,{children:[d.jsx(Fs,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):d.jsxs(d.Fragment,{children:[d.jsx(Vhe,{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."}),ee&&d.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:ee})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`model-${e.id}`,children:"Model"}),d.jsx(Tn,{id:`model-${e.id}`,value:v,onChange:P=>E(P.target.value),placeholder:"stub-model",disabled:h==="llm"&&B})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),d.jsx(Tn,{id:`stopReason-${e.id}`,value:x,onChange:P=>w(P.target.value),placeholder:"endTurn",disabled:h==="llm"&&B})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`role-${e.id}`,children:"Role"}),d.jsxs(Gi,{value:S,onValueChange:P=>_(P),disabled:h==="llm"&&B,children:[d.jsx(Ki,{id:`role-${e.id}`,children:d.jsx(Wi,{})}),d.jsxs(Zi,{children:[d.jsx(Er,{value:"assistant",children:"assistant"}),d.jsx(Er,{value:"user",children:"user"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),d.jsxs(Gi,{value:k,onValueChange:P=>N(P),disabled:h==="llm"&&B,children:[d.jsx(Ki,{id:`contentType-${e.id}`,children:d.jsx(Wi,{})}),d.jsxs(Zi,{children:[d.jsx(Er,{value:"text",children:"text"}),d.jsx(Er,{value:"image",children:"image"})]})]})]}),k==="text"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`text-${e.id}`,children:"Text Content"}),d.jsx(Jl,{id:`text-${e.id}`,value:C,onChange:P=>A(P.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&B})]}),k==="image"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),d.jsx(Jl,{id:`imageData-${e.id}`,value:I,onChange:P=>O(P.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&B})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Xt,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),d.jsx(Tn,{id:`mimeType-${e.id}`,value:M,onChange:P=>j(P.target.value),placeholder:"image/png",disabled:h==="llm"&&B})]})]})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Le,{onClick:ie,className:"flex-1",disabled:h==="llm"&&B,children:"Approve"}),d.jsx(Le,{onClick:re,variant:"outline",className:"flex-1",disabled:h==="llm"&&B,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"})})}function GTe({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=oc(),{llmConfig:u}=LY({mcpServerUrl:i}),[f,m]=y.useState(null),[h,g]=y.useState(""),[v,E]=y.useState(-1),[x,w]=y.useState(!0),[S,_]=y.useState(!1),[k,N]=y.useState(!0),[C,A]=y.useState(!1),I=y.useRef(null),O=y.useRef(null),M=y.useRef(null),j=y.useRef(!1);y.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:s,pendingRequestsCount:e.length,currentSelectedId:f?.id}),s&&e.length>0){const H=e.find(ie=>ie.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!H,H?.id),H&&(console.log("[SamplingTab] Auto-selecting request:",H.id),c(null),m(H),setTimeout(()=>{const ie=document.getElementById(`sampling-request-${H.id}`);console.log("[SamplingTab] Scrolling to element:",!!ie),ie&&ie.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),y.useEffect(()=>{const H=ie=>{const P=ie.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",P);const F=e.find(U=>U.id===P);F&&(console.log("[SamplingTab] Selecting request from event:",P),m(F),setTimeout(()=>{const U=document.getElementById(`sampling-request-${P}`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",H),()=>window.removeEventListener("navigate-to-sampling",H)},[e]),y.useEffect(()=>{x&&e.length>0&&I.current&&!j.current&&(I.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const H=I.current;if(!H)return;const ie=()=>{H.scrollTop>0&&(j.current=!0,w(!1))};return H.addEventListener("scroll",ie),()=>H.removeEventListener("scroll",ie)},[]),y.useEffect(()=>{e.length===0&&(j.current=!1,w(!0))},[e.length]),y.useEffect(()=>{S&&M.current&&M.current.focus()},[S]);const B=y.useCallback(()=>{h.trim()||_(!1)},[h]),G=y.useMemo(()=>{if(!h.trim())return e;const H=h.toLowerCase();return e.filter(ie=>ie.serverName.toLowerCase().includes(H)||JSON.stringify(ie.request||{}).toLowerCase().includes(H))},[e,h]);y.useEffect(()=>{E(-1)},[h]),y.useEffect(()=>{const H=ie=>{const re=ie.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||ie.metaKey||ie.ctrlKey||ie.altKey)return;const F=G;if(ie.key==="ArrowDown")ie.preventDefault(),E(U=>{const L=U+1;return L>=F.length?0:L});else if(ie.key==="ArrowUp")ie.preventDefault(),E(U=>{const L=U-1;return L<0?F.length-1:L});else if(ie.key==="Enter"&&v>=0){ie.preventDefault();const U=G[v];U&&ee(U)}};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[v,G]),y.useEffect(()=>{if(v>=0){const H=`sampling-request-${G[v]?.id}`,ie=document.getElementById(H);ie&&ie.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,G]);const ee=y.useCallback(H=>{m(H)},[]),te=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(H=>{n(H.id,"User rejected all requests")}),m(null))},[e,n]),ae=y.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)),A(!0),setTimeout(()=>A(!1),2e3)}catch(H){console.error("[SamplingTab] Failed to copy request:",H)}},[f]),V=y.useCallback(()=>{if(f)try{const H=new globalThis.Blob([JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)],{type:"application/json"}),ie=URL.createObjectURL(H),re=document.createElement("a");re.href=ie,re.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(ie)}catch(H){console.error("[SamplingTab] Failed to download request:",H)}},[f]),q=y.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(H){console.error("[SamplingTab] Failed to toggle fullscreen:",H)}},[]);return r?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(In,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(In,{defaultSize:75,minSize:30,children:[d.jsx(FTe,{isSearchExpanded:S,searchQuery:h,filteredRequestsCount:G.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:B,onRejectAll:te,searchInputRef:M}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(BTe,{requests:G,selectedRequest:f,onRequestSelect:ee,focusedIndex:v,formatRelativeTime:ry,listRef:I})})]})})}),d.jsx(xi,{}),d.jsx(In,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(VTe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>N(!k),isCopied:C,onCopy:ae,onDownload:V,onFullscreen:q,llmConfig:u})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZG,{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 WTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onCancelAll:c,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(Tn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>i(f.target.value),onBlur:s,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(hr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(Pd,{className:"h-4 w-4"})})}),d.jsxs(It,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(th,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(no,{className:"h-4 w-4"})})}),d.jsx(It,{side:"bottom",children:"Cancel all"})]})})]})}function KTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Md,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.mode||"form",f=u==="form"&&"requestedSchema"in s.request&&s.request.requestedSchema;return d.jsx(tl,{id:`elicitation-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,d.jsx(hr,{variant:"outline",className:u==="url"?"bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50":"bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50",children:u})]}),description:(()=>{const m=r(s.timestamp),h=[];f&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function ZTe({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:f}){const[m,h]=y.useState({}),[g,v]=y.useState(!1),E=e?.request.mode||"form",x=E==="form",w=E==="url";y.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const I=e.request.requestedSchema,O={};if(I?.type==="object"&&I.properties)for(const[M,j]of Object.entries(I.properties)){const B=j;B.default!==void 0?O[M]=B.default:B.type==="boolean"?O[M]=!1:B.type==="number"||B.type==="integer"?O[M]=0:O[M]=""}h(O)}v(!1)},[e?.id,x]);const S=(I,O)=>{h(M=>({...M,[I]:O}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const I=e.request.requestedSchema;if(I?.required){const O=I.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(O.length>0){ct.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"});a(),Mr(()=>Promise.resolve().then(()=>kd),void 0).then(I=>{const O=ct(I.createElement("div",{className:"space-y-3"},I.createElement("div",null,I.createElement("strong",null,"Elicitation Response Sent"),I.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),I.createElement("div",{className:"flex gap-2"},I.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),ct.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),a())},N=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},C=()=>{e&&w&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},A=y.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const I=e.request.requestedSchema;if(!I||I.type!=="object"||!I.properties)return d.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=I.properties,M=I.required||[];return d.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([j,B])=>{const G=B,ee=M.includes(j),te=G.type||"string",ae=G.title||j,V=G.description;return d.jsxs("div",{className:"space-y-2",children:[d.jsxs(Xt,{htmlFor:`field-${j}`,children:[ae,ee&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),V&&d.jsx("p",{className:"text-xs text-muted-foreground",children:V}),te==="boolean"?d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(om,{id:`field-${j}`,checked:m[j]||!1,onCheckedChange:q=>S(j,q)}),d.jsx(Xt,{htmlFor:`field-${j}`,className:"text-sm font-normal cursor-pointer",children:G.title||j})]}):te==="number"||te==="integer"?d.jsx(Tn,{id:`field-${j}`,type:"number",value:m[j]||"",onChange:q=>S(j,te==="integer"?parseInt(q.target.value,10):parseFloat(q.target.value)),placeholder:G.default?.toString()||""}):G.enum?d.jsxs("select",{id:`field-${j}`,value:m[j]||"",onChange:q=>S(j,q.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..."}),G.enum.map(q=>d.jsx("option",{value:q,children:q},q))]}):te==="string"&&(G.format==="textarea"||G.maxLength>100)?d.jsx(Jl,{id:`field-${j}`,value:m[j]||"",onChange:q=>S(j,q.target.value),placeholder:G.default||"",rows:4}):d.jsx(Tn,{id:`field-${j}`,type:"text",value:m[j]||"",onChange:q=>S(j,q.target.value),placeholder:G.default||""})]},j)})})},[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(hr,{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(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?d.jsx(mr,{className:"h-4 w-4 text-green-600"}):d.jsx(er,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Copy request"})]}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(Mm,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Download request"})]}),d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(sC,{className:"h-4 w-4"})})}),d.jsx(It,{children:"Fullscreen"})]}),d.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(no,{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:C,className:"flex items-center gap-2",children:[d.jsx(t_,{className:"h-4 w-4"}),"Open URL"]})]}),d.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[d.jsx(om,{id:"url-completed",checked:g,onCheckedChange:I=>v(!!I)}),d.jsx(Xt,{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"}),A]}),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(Qn,{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:k,variant:"outline",className:"flex-1",children:"Decline"}),d.jsx(Le,{onClick:N,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:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=oc(),[c,u]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,E]=y.useState(!0),[x,w]=y.useState(!1),[S,_]=y.useState(!0),[k,N]=y.useState(!1),C=y.useRef(null),A=y.useRef(null),I=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:c?.id}),i&&e.length>0){const V=e.find(q=>q.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!V,V?.id),V&&(console.log("[ElicitationTab] Auto-selecting request:",V.id),s(null),u(V),setTimeout(()=>{const q=document.getElementById(`elicitation-request-${V.id}`);console.log("[ElicitationTab] Scrolling to element:",!!q),q&&q.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,s]),y.useEffect(()=>{const V=q=>{const ie=q.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",ie);const re=e.find(P=>P.id===ie);re&&(console.log("[ElicitationTab] Selecting request from event:",ie),u(re),setTimeout(()=>{const P=document.getElementById(`elicitation-request-${ie}`);P&&P.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",V),()=>window.removeEventListener("navigate-to-elicitation",V)},[e]),y.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const V=C.current;if(!V)return;const q=()=>{V.scrollTop>0&&(O.current=!0,E(!1))};return V.addEventListener("scroll",q),()=>V.removeEventListener("scroll",q)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const M=y.useCallback(()=>{f.trim()||w(!1)},[f]),j=y.useMemo(()=>{if(!f.trim())return e;const V=f.toLowerCase();return e.filter(q=>q.serverName.toLowerCase().includes(V)||q.request.message.toLowerCase().includes(V)||JSON.stringify(q.request||{}).toLowerCase().includes(V))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const V=q=>{const H=q.target;if(H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.contentEditable==="true"||q.metaKey||q.ctrlKey||q.altKey)return;const re=j;if(q.key==="ArrowDown")q.preventDefault(),g(P=>{const F=P+1;return F>=re.length?0:F});else if(q.key==="ArrowUp")q.preventDefault(),g(P=>{const F=P-1;return F<0?re.length-1:F});else if(q.key==="Enter"&&h>=0){q.preventDefault();const P=j[h];P&&B(P)}};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[h,j]),y.useEffect(()=>{if(h>=0){const V=`elicitation-request-${j[h]?.id}`,q=document.getElementById(V);q&&q.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,j]);const B=y.useCallback(V=>{u(V)},[]),G=y.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(V=>{n(V.id,"User cancelled all requests")}),u(null))},[e,n]),ee=y.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)),N(!0),setTimeout(()=>N(!1),2e3)}catch(V){console.error("[ElicitationTab] Failed to copy request:",V)}},[c]),te=y.useCallback(()=>{if(c)try{const V=new globalThis.Blob([JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)],{type:"application/json"}),q=URL.createObjectURL(V),H=document.createElement("a");H.href=q,H.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(H),H.click(),document.body.removeChild(H),URL.revokeObjectURL(q)}catch(V){console.error("[ElicitationTab] Failed to download request:",V)}},[c]),ae=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(V){console.error("[ElicitationTab] Failed to toggle fullscreen:",V)}},[]);return r?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(In,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(In,{defaultSize:75,minSize:30,children:[d.jsx(WTe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:j.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:G,searchInputRef:I}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(KTe,{requests:j,selectedRequest:c,onRequestSelect:B,focusedIndex:h,formatRelativeTime:ry,listRef:C})})]})})}),d.jsx(xi,{}),d.jsx(In,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(ZTe,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:S,onTogglePreview:()=>_(!S),isCopied:k,onCopy:ee,onDownload:te,onFullscreen:ae})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(QG,{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 qTe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:d.jsx(lq,{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(aq,{ref:a,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(oq,{ref:r,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(Kke,{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(GTe,{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(kTe,{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:i})]}):d.jsx(d.Fragment,{children:i})}function aF({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 cq=y.createContext(void 0);function uq(){const e=y.use(cq);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const dq=y.createContext(void 0);function XTe(){return y.use(dq)}function ck({ref:e,children:t,defaultValue:n,value:a,onValueChange:r,className:i,collapsed:s,onCollapsedChange:c,...u}){const[f,m]=y.useState(n||""),h=a!==void 0,g=s!==void 0,[v,E]=y.useState(!1),x=y.useCallback(k=>{h||m(k),r?.(k)},[h,r]),w=h?a:f,S=g?s:v,_=y.useCallback(k=>{g||E(k),c?.(k)},[g,c]);return d.jsx(cq,{value:{activeValue:w,handleValueChange:x,collapsed:S,handleCollapsedChange:_},children:d.jsx("div",{ref:e,className:Me("flex flex-col gap-2",i),...u,children:t})})}ck.displayName="Tabs";function uk({ref:e,children:t,className:n,variant:a="default",collapsible:r=!1,...i}){const{activeValue:s,collapsed:c,handleCollapsedChange:u}=uq(),[f,m]=y.useState({width:0,left:0}),h=y.useRef(null),g=y.useRef(null),v=y.useRef(null),E=y.useCallback(()=>{const S=h.current;if(!S)return;const _=S.querySelector("div:first-child");if(!_)return;const k=_.querySelector(`button[data-tab-value="${s}"]`);if(k&&s){const N=_.getBoundingClientRect(),C=k.getBoundingClientRect();m({width:C.width,left:C.left-N.left})}else m({width:0,left:0})},[s]),x=y.useCallback(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(E,16)},[E]);y.useEffect(()=>{const S=setTimeout(E,10);return()=>clearTimeout(S)},[E,c]),y.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(N=>{g.current&&g.current.observe(N)}),()=>{g.current&&g.current.disconnect(),v.current&&clearTimeout(v.current)}},[x]),y.useEffect(()=>{const S=()=>{x()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[x]);const w=y.useRef(null);return y.useEffect(()=>{w.current&&(w.current.style.width=`${f.width}px`,w.current.style.left=`${f.left}px`)},[f]),d.jsx(dq,{value:{variant:a,collapsed:c,handleCollapsedChange:u},children:d.jsx("div",{ref:h,className:Me("relative flex items-center bg-none gap-1",a==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",a==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...i,children:d.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,d.jsx("span",{ref:w,className:Me("absolute transition-all duration-500 ease-in-out z-0",a==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",a==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}uk.displayName="TabsList";const JTe=({children:e,title:t,collapsed:n})=>!t||!n?e:d.jsx(nC,{children:d.jsxs(Rt,{children:[d.jsx(At,{children:e}),d.jsx(It,{children:t})]})}),dk=y.forwardRef(({children:e,value:t,className:n,disabled:a,icon:r,title:i,...s},c)=>{const{activeValue:u,handleValueChange:f,collapsed:m}=uq(),g=XTe()?.variant||"default",v=u===t,E=m&&i?i:void 0;return d.jsx(JTe,{title:i,collapsed:m,children:d.jsxs("button",{ref:c,disabled:a,onClick:()=>f(t),"data-tab-value":t,"data-tab-active":v,role:"tab","aria-selected":v?"true":"false",title:E,className:Me("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",g==="default"&&"py-2.5",g==="default"&&"rounded-md px-4",g==="underline"&&"px-6 py-3 border-b-2 border-transparent",v&&"text-foreground",!v&&"text-muted-foreground hover:text-foreground",n),...s,children:[r&&d.jsx(r,{className:Me("h-4 w-4 transition-all duration-500 ease-in-out",!m&&"mr-2",m&&"mr-0!")}),d.jsx("span",{className:Me("transition-all duration-500 ease-in-out overflow-hidden",m?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});dk.displayName="TabsTrigger";function iF({serverUrl:e,serverName:t,headers:n,className:a}){const[r,i]=y.useState(!1),[s,c]=y.useState(null),[u,f]=y.useState(!1),m=()=>{try{const _=iy(e,t,n);window.location.href=_,ct.success("Opening in Cursor...")}catch(_){console.error("Failed to generate Cursor deep link:",_),ct.error("Failed to open in Cursor")}},h=()=>{try{const _=oy(e,t,n);window.location.href=_,ct.success("Opening in VS Code...")}catch(_){console.error("Failed to generate VS Code deep link:",_),ct.error("Failed to open in VS Code")}},g=()=>{try{sy(e,t,n),ct.success("Downloaded .mcpb file")}catch(_){console.error("Failed to download .mcpb file:",_),ct.error("Failed to download configuration file")}},v=()=>{c("claude-code"),i(!0)},E=()=>{c("gemini-cli"),i(!0)},x=()=>{c("codex-cli"),i(!0)},w=async _=>{try{await navigator.clipboard.writeText(_),f(!0),ct.success("Copied to clipboard"),setTimeout(()=>f(!1),2e3)}catch(k){console.error("Failed to copy:",k),ct.error("Failed to copy to clipboard")}},S=()=>{if(s==="claude-code"){const{command:_,envVars:k}=ly(e,t,n),N=kp(k);return d.jsxs(d.Fragment,{children:[d.jsxs(js,{children:[d.jsx(Ls,{children:"Add to Claude Code"}),d.jsx(Ub,{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:()=>w(_),children:u?d.jsx(mr,{className:"size-3.5 text-green-600"}):d.jsx(er,{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:_})})]}),N&&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:N})})]}),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(s==="gemini-cli"){const{command:_,envVars:k}=cy(e,t,n),N=kp(k);return d.jsxs(d.Fragment,{children:[d.jsxs(js,{children:[d.jsx(Ls,{children:"Add to Gemini CLI"}),d.jsx(Ub,{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"})]}),N&&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:N?"3.":"2."}),d.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),N&&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:N})})]}),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:()=>w(_),children:u?d.jsx(mr,{className:"size-3.5 text-green-600"}):d.jsx(er,{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:_})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Gemini CLI to load the new configuration."})]})]})}if(s==="codex-cli"){const{config:_,envVars:k}=uy(e,t,n);return d.jsxs(d.Fragment,{children:[d.jsxs(js,{children:[d.jsx(Ls,{children:"Add to Codex CLI"}),d.jsxs(Ub,{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:()=>w(_),children:u?d.jsx(mr,{className:"size-3.5 text-green-600"}):d.jsx(er,{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:_})})]}),k.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};return d.jsxs(d.Fragment,{children:[d.jsxs(Av,{children:[d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx(Iv,{asChild:!0,children: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 ${a||""}`,"aria-label":"Add to Client",children:[d.jsx("span",{className:"hidden sm:inline ml-2",children:"Add to Client"}),d.jsx(qs,{className:"size-3 ml-1"})]})})}),d.jsx(It,{children:d.jsx("p",{children:"Add to Client"})})]}),d.jsxs(zp,{align:"end",className:"w-48",children:[d.jsxs(ia,{onClick:m,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",{children:"Cursor"})]}),d.jsxs(ia,{onClick:v,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",{children:"Claude Code"})]}),d.jsxs(ia,{onClick:g,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",{children:"Claude Desktop"})]}),d.jsxs(ia,{onClick:h,className:"flex items-center gap-2",children:[d.jsx(FK,{className:"h-4 w-4"}),d.jsx("span",{children:"VS Code"})]}),d.jsxs(ia,{onClick:E,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",{children:"Gemini CLI"})]}),d.jsxs(ia,{onClick:x,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",{children:"Codex CLI"})]})]})]}),d.jsx(ku,{open:r,onOpenChange:i,children:d.jsx(Tu,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:S()})})]})}function oF({className:e}){const{theme:t,setTheme:n}=A0(),a=y.useRef(null),[r,i]=y.useState(!1);y.useEffect(()=>{i(!0)},[]);const s=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?d.jsx(uU,{className:"size-4"}):t==="light"?d.jsx(Yhe,{className:"size-5"}):d.jsx(Che,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",f=async()=>{if(!a.current)return;const m=s();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{Od.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:E}=a.current.getBoundingClientRect(),x=h+E/2,w=g+v/2,S=window.innerWidth-g,_=window.innerHeight-h,k=Math.hypot(Math.max(g,S),Math.max(h,_));document.documentElement.animate({clipPath:[`circle(0px at ${w}px ${x}px)`,`circle(${k}px at ${w}px ${x}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?d.jsx("button",{ref:a,onClick:f,className:Me(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):d.jsx("button",{ref:a,className:Me(e),"aria-label":"Toggle theme",children:d.jsx(uU,{className:"size-4"})})}function sF({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[a,r]=y.useState(!1),i=.2,s=.7,c=.6,u=4,f=i+s+c,m=0,h=i/f,g=(i+s)/f,v=1;return d.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Me("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[d.jsx("div",{className:"relative",children:d.jsxs(xa.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:Me("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[d.jsxs(xa.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:f,times:[m,h,g,v],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(QTe,{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z",times:{T0:m,T1:h,T2:g,T3:v},total:f}),d.jsx(lF,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f}),d.jsx(lF,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f})]})]})}),t==="expanded"&&d.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",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 QTe({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return d.jsx(xa.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[a,r,i,s],ease:"easeInOut"}}}})}function lF({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return d.jsx(xa.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:r,times:[i,s,c,u],ease:"easeInOut"}}}})}function fq({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:f}=A0(),m=f==="dark"?"#000000":"#ffffff",h=f==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=i||h;return d.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":r,"--speed":a,"--cut":n,"--bg":v},className:Me("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",f==="dark"?"border-black/10 text-black":"border-white/10 text-white",s),ref:e,...u,children:[d.jsx("div",{className:Me("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:d.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [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))]"})})}),c,d.jsx("div",{className:Me("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",f==="dark"?"shadow-[inset_0_-8px_10px_#0000001f] group-hover:shadow-[inset_0_-6px_10px_#0000003f] group-active:shadow-[inset_0_-10px_10px_#0000003f]":"shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]")}),d.jsx("div",{className:Me("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}fq.displayName="ShimmerButton";function cF({status:e}){const t=i=>{switch(i){case"ready":return{color:"bg-emerald-500",ringColor:"ring-emerald-500",tooltip:"Connected"};case"failed":return{color:"bg-red-500",ringColor:"ring-red-500",tooltip:"Failed"};default:return{color:"bg-yellow-500",ringColor:"ring-yellow-500",tooltip:i}}},{color:n,ringColor:a,tooltip:r}=t(e);return d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),d.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),d.jsx(It,{children:d.jsx("p",{children:r})})]})}function uF({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=Rd(),s=c=>{const u=e.find(f=>f.id===c);if(!u||u.state!=="ready"){ct.error("Server is not connected and cannot be inspected");return}n(c)};return r?d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("div",{className:"relative",children:d.jsxs(Av,{children:[d.jsx(Iv,{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(Dl,{serverUrl:t.url,serverName:t.name,size:"md"}):d.jsx(zhe,{className:"h-5 w-5"}),d.jsx(qs,{className:"h-4 w-4"})]})}),d.jsxs(zp,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(JE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),d.jsx(rp,{}),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(c=>d.jsxs(ia,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[d.jsx(Dl,{serverUrl:c.url,serverName:c.name,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:c.name}),d.jsx(cF,{status:c.state})]}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:d.jsx(_u,{className:"h-3 w-3"})})]},c.id)),d.jsx(rp,{}),d.jsx(ia,{onClick:()=>i("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("div",{className:"relative",children:d.jsxs(Av,{children:[d.jsx(Iv,{asChild:!0,children:d.jsxs(fq,{className:Me("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-10"),children:[t&&d.jsx(Dl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&d.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx("button",{onClick:c=>{c.stopPropagation()},className:"w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors",title:"Click to copy error message","aria-label":"Copy error message to clipboard"})}),d.jsx(It,{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(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx("button",{type:"button",onClick:()=>{a(t.id)},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"Edit connection settings",children:d.jsx(_u,{className:"h-4 w-4"})})}),d.jsx(It,{children:d.jsx("p",{children:"Edit connection settings"})})]}),d.jsxs(zp,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(JE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),d.jsx(rp,{}),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(c=>d.jsxs(ia,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[d.jsx(Dl,{serverUrl:c.url,serverName:c.name,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:c.name}),d.jsx(cF,{status:c.state})]}),d.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:d.jsx(_u,{className:"h-3 w-3"})})]},c.id)),d.jsx(rp,{}),d.jsx(ia,{onClick:()=>i("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const dF=[{id:"tools",label:"Tools",icon:Kl},{id:"prompts",label:"Prompts",icon:Vp},{id:"resources",label:"Resources",icon:dhe},{id:"sampling",label:"Sampling",icon:ZG},{id:"elicitation",label:"Elicitation",icon:QG},{id:"notifications",label:"Notifications",icon:aC},{id:"chat",label:"Chat",icon:Ehe}];function fF(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 eNe({collapsed:e,onToggle:t}){return d.jsxs(Rt,{children:[d.jsx(At,{asChild:!0,children:d.jsx("button",{onClick:t,className:Me("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(WG,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):d.jsx(a0,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),d.jsx(It,{children:d.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function tNe({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s,embedded:c=!1}){const{tunnelUrl:u}=oc(),f=t&&u,[m,h]=y.useState(!1),[g,v]=y.useState(!0),E=async()=>{if(u)try{await navigator.clipboard.writeText(`${u}/mcp`),h(!0),ct.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{ct.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:[!c&&d.jsx("div",{className:"flex-1 flex justify-start",children:d.jsx(uF,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),!c&&d.jsx("div",{className:"flex-shrink-0 flex justify-center",children:d.jsx("div",{className:"scale-150",children:d.jsx(sF,{state:"collapsed"})})}),!c&&d.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[t&&d.jsx(iF,{serverUrl:u?`${u}/mcp`:t.url,serverName:t.name,headers:t.customHeaders,className:"p-2"}),d.jsxs(Rt,{children:[d.jsx(At,{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(aF,{className:"h-4 w-4"})})})}),d.jsx(It,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(oF,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&d.jsx("div",{className:"w-full",children:d.jsx(ck,{value:n,onValueChange:x=>r(x),collapsed:g,onCollapsedChange:v,children:d.jsx(uk,{className:"w-full justify-center",children:dF.map(x=>{const w=fF(x.id,t);return d.jsxs(dk,{value:x.id,icon:x.icon,className:Me("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",g&&"pl-2"),children:[w>0&&d.jsx("span",{className:Me(n===x.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:w}),d.jsx("span",{className:"sr-only",children:x.label})]},x.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:[!c&&d.jsx(uF,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ck,{value:n,onValueChange:x=>r(x),collapsed:g,onCollapsedChange:v,children:d.jsx(uk,{className:"overflow-x-auto",collapsible:!0,children:dF.map(x=>{const w=fF(x.id,t),S=w>0?`${x.label} (${w})`:x.label;return d.jsx(dk,{value:x.id,icon:x.icon,className:Me("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",g&&"pl-4"),title:S,children:d.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[x.label,w>0&&d.jsx("span",{className:Me(n===x.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:w})]})})})})}),d.jsx(eNe,{collapsed:g,onToggle:()=>v(!g)})]}),f&&d.jsxs(iZ,{children:[d.jsx(oZ,{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(Gp,{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(QC,{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(Gp,{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:E,children:m?d.jsx(mr,{className:"size-3.5 text-green-600"}):d.jsx(er,{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"})]})]})]})]})})]})]}),!c&&d.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[t&&d.jsx(iF,{serverUrl:u?`${u}/mcp`:t.url,serverName:t.name,headers:t.customHeaders}),d.jsxs(Rt,{children:[d.jsx(At,{children:d.jsx(oF,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),d.jsx(It,{children:d.jsx("p",{children:"Toggle theme"})})]}),d.jsxs(Rt,{children:[d.jsx(At,{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:i,children:[d.jsx(Zme,{className:"size-4"}),d.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),d.jsx(It,{children:d.jsx("p",{children:"Command Palette"})})]}),d.jsxs(Rt,{children:[d.jsx(At,{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(aF,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),d.jsx(It,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(sF,{state:"expanded"})]})]})]})}function nNe({children:e}){const t=Rd(),n=Ho(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=rC(),{selectedServerId:u,setSelectedServerId:f,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v,tunnelUrl:E,isEmbedded:x,embeddedConfig:w,setEmbeddedMode:S}=oc(),[_,k]=y.useState(!1),[N,C]=y.useState(null),A=fxe();y.useEffect(()=>{const F=new URLSearchParams(n.search),U=F.get("embedded")==="true",L=F.get("embeddedConfig");if(U){let $={};if(L)try{$=JSON.parse(L)}catch(W){console.error("Failed to parse embeddedConfig:",W)}S(!0,$)}},[]),y.useEffect(()=>{const U=new URLSearchParams(n.search).get("tunnelUrl");v(U)},[n.search,v]),y.useEffect(()=>{const F=$=>{const K=$.detail.requestId;u&&g(u,"sampling",K)},U=$=>{const K=$.detail.requestId;u&&g(u,"elicitation",K)},L=$=>{const K=$.detail.toolName;u&&K?g(u,"tools",K):u&&h("tools")};return window.addEventListener("navigate-to-sampling",F),window.addEventListener("navigate-to-elicitation",U),window.addEventListener("navigate-to-tool-result",L),()=>{window.removeEventListener("navigate-to-sampling",F),window.removeEventListener("navigate-to-elicitation",U),window.removeEventListener("navigate-to-tool-result",L)}},[u,h,g]);const I=y.useRef(null),O=y.useRef(null),M=y.useRef(null),{isAutoConnecting:j}=dxe({connections:a,addConnection:r,removeConnection:i,configLoaded:c,embedded:x}),B=y.useCallback(F=>{_r.getInstance().capture(new mme({trigger:F})).catch(()=>{}),k(!0)},[]),G=F=>{const U=a.find(K=>K.id===F);if(!U||U.state!=="ready"){ct.error("Server is not connected and cannot be inspected");return}f(F);const $=new URLSearchParams(n.search).get("tunnelUrl"),W=$?`/?server=${encodeURIComponent(F)}&tunnelUrl=${encodeURIComponent($)}`:`/?server=${encodeURIComponent(F)}`;t(W)},ee=y.useCallback(F=>{C(F)},[]),te=y.useCallback(F=>{N&&(F.url!==N?(i(N),r(F.url,F.name,F.proxyConfig,F.transportType)):s(N,{name:F.name,proxyConfig:F.proxyConfig,transportType:F.transportType}),C(null),ct.success("Connection settings updated"))},[N,i,r,s]),ae=(F,U,L)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:F,itemName:U,serverId:L}),L){const $=a.find(se=>se.id===L);if(console.warn("[Layout] Server lookup:",{serverId:L,serverFound:!!$,serverState:$?.state}),!$||$.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),ct.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:L,tab:F,itemName:U}),g(L,F,U);const K=new URLSearchParams(n.search).get("tunnelUrl"),Y=K?`/?server=${encodeURIComponent(L)}&tunnelUrl=${encodeURIComponent(K)}`:`/?server=${encodeURIComponent(L)}`;console.warn("[Layout] Navigating to:",Y),t(Y)}else console.warn("[Layout] No serverId, just updating tab to:",F),h(F)},V=a.find(F=>F.id===u),q=V?V.tools.map(F=>({...F,_serverId:V.id})):a.flatMap(F=>F.state==="ready"?F.tools.map(U=>({...U,_serverId:F.id,_serverName:F.name})):[]),H=V?V.prompts.map(F=>({...F,_serverId:V.id})):a.flatMap(F=>F.state==="ready"?F.prompts.map(U=>({...U,_serverId:F.id,_serverName:F.name})):[]),ie=V?V.resources.map(F=>({...F,_serverId:V.id})):a.flatMap(F=>F.state==="ready"?F.resources.map(U=>({...U,_serverId:F.id,_serverName:F.name})):[]);if(y.useEffect(()=>{const U=new URLSearchParams(n.search).get("server"),L=U?decodeURIComponent(U):null;L!==u&&f(L)},[n.search,u,f]),y.useEffect(()=>{const U=new URLSearchParams(n.search).get("server");if(!U)return;const L=decodeURIComponent(U),$=a.find(W=>W.id===L);if(!$){const W=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(W)}if($.state==="failed"){const W=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(W)}},[n.search,t,a]),OK({onCommandPalette:()=>B("keyboard"),onToolsTab:()=>{V&&h("tools")},onPromptsTab:()=>{V&&h("prompts")},onResourcesTab:()=>{V&&h("resources")},onChatTab:()=>{V&&h("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{m==="tools"&&I.current?I.current.focusSearch():m==="prompts"&&O.current?O.current.focusSearch():m==="resources"&&M.current&&M.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&I.current?I.current.blurSearch():m==="prompts"&&O.current?O.current.blurSearch():m==="resources"&&M.current&&M.current.blurSearch()}}),j)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(ki,{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 re=x?{backgroundColor:w.backgroundColor||"#f3f3f3",padding:w.padding||"0.5rem"}:{},P=x?"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(nC,{children:d.jsxs("div",{className:P,style:re,children:[d.jsx(tNe,{connections:a,selectedServer:V,activeTab:m,onServerSelect:G,onTabChange:h,onCommandPaletteOpen:()=>B("button"),onOpenConnectionOptions:ee,embedded:x}),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(qTe,{selectedServer:V,activeTab:m,toolsSearchRef:I,promptsSearchRef:O,resourcesSearchRef:M,children:e})}),d.jsx(zxe,{isOpen:_,onOpenChange:k,tools:q,prompts:H,resources:ie,savedRequests:A,connections:a,selectedServer:V,tunnelUrl:E,onNavigate:ae,onServerSelect:G}),d.jsx(Z7,{connection:N&&a.find(F=>F.id===N)||null,open:N!==null,onOpenChange:F=>{F||C(null)},onConnect:te})]})})}function rNe(){const[e,t]=y.useState("processing"),[n,a]=y.useState("");return y.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),TN().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(r=>{console.error("[OAuthCallback] Authorization failed:",r),t("error"),a(r instanceof Error?r.message:String(r))})},[]),e==="processing"?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(Fs,{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 aNe=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,f=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(E=>{let x=E==="class",w=x&&i?r.map(S=>i[S]||S):r;x?(u.classList.remove(...w),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(E,v)}),h(v)}function h(v){c&&f.includes(v)&&(u.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(a)m(a);else try{let v=localStorage.getItem(t)||n,E=s&&v==="system"?g():v;m(E)}catch{}},iNe=y.createContext(void 0),oNe={setTheme:e=>{},themes:[]},sNe=()=>{var e;return(e=y.useContext(iNe))!=null?e:oNe};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:a,enableColorScheme:r,defaultTheme:i,value:s,themes:c,nonce:u,scriptProps:f})=>{let m=JSON.stringify([n,t,i,e,c,s,a,r]).slice(1,-1);return y.createElement("script",{...f,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${aNe.toString()})(${m})`}})});function lNe({...e}){const{theme:t="system"}=sNe();return d.jsx(e7,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function cNe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true";return d.jsx(N_e,{children:d.jsx(vme,{embedded:t,children:d.jsxs(uxe,{children:[d.jsx(gle,{basename:"/inspector",children:d.jsxs(Kse,{children:[d.jsx(BE,{path:"/oauth/callback",element:d.jsx(rNe,{})}),d.jsx(BE,{path:"/",element:d.jsx(nNe,{children:d.jsx(cxe,{})})})]})}),d.jsx(lNe,{position:"top-center"})]})})})}const pF=new URLSearchParams(window.location.search);if(pF.has("code")||pF.has("error"))try{TN()}catch(e){console.error("[inspector] OAuth callback error:",e)}const mF=document.getElementById("root");mF?tse.createRoot(mF).render(d.jsx(cNe,{})):console.error("[inspector] Root element not found");export{LB as $,UF as A,je as B,Mr as C,$e as D,Ml as E,lv as F,joe as G,jb as H,Moe as I,Poe as J,CF as K,NJ as L,Ooe as M,pk as N,TN as O,FJ as P,Q as R,Ui as T,CJ as V,Gne as Z,Cy as _,kd as a,sd as b,VT as c,Pne as d,kne as e,ld as f,ay as g,X5 as h,fE as i,KT as j,vi as k,Rb as l,pE as m,sv as n,Jf as o,XF as p,ni as q,y as r,Rp as s,lu as t,od as u,K6 as v,W6 as w,jB as x,HF as y,QB as z};
|