@mcp-use/inspector 0.13.0-canary.10 → 0.13.0-canary.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{browser-CQhvXRgA.js → browser-C4F-osqk.js} +4 -4
- package/dist/client/assets/{display-A5IEINAP-BsKaiMOX.js → display-A5IEINAP-H3Q2-YX2.js} +2 -2
- package/dist/client/assets/{embeddings-DpSXEv5n.js → embeddings-7yD5FP5W.js} +1 -1
- package/dist/client/assets/{index-CyHacqJj.js → index-BCGobKCz.js} +1 -1
- package/dist/client/assets/{index-1oOUdn3H.js → index-BKkxSJZC.js} +1 -1
- package/dist/client/assets/{index-CyjpFzxN.js → index-BVRlDOe5.js} +1 -1
- package/dist/client/assets/{index-B4gW2Mq2.js → index-Baw2JzBf.js} +1 -1
- package/dist/client/assets/{index-B0cN6CyQ.js → index-Bdz9XpGY.js} +1 -1
- package/dist/client/assets/{index-DdjBoJpx.js → index-CVHM2qPt.js} +1 -1
- package/dist/client/assets/{index-BYYChQ84.js → index-CcXsZ4ms.js} +6 -6
- package/dist/client/assets/{index-BW8kJiKz.js → index-Cfg3RZ-z.js} +1 -1
- package/dist/client/assets/{index-DkySmQtm.js → index-DxljWnJH.js} +1 -1
- package/dist/client/assets/langfuse-74RGPTAH-CzkBGeHI.js +1 -0
- package/dist/client/assets/{path-DYKDF_ga.js → path-BzkNY3AW.js} +1 -1
- package/dist/client/assets/{winston-j3ELiB8E.js → winston-mndsjLRM.js} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +2 -2
- package/dist/client/assets/langfuse-74RGPTAH-DyVjdY8Y.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-
|
|
2
|
-
var tee=Object.defineProperty;var nee=(e,t,n)=>t in e?tee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ip=(e,t,n)=>nee(e,typeof t!="symbol"?t+"":t,n);function ree(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();function Ay(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function AAe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var a=!1;try{a=this instanceof r}catch{}return a?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}),n}var gx={exports:{}},op={};var kP;function aee(){if(kP)return op;kP=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,i){var o=null;if(i!==void 0&&(o=""+i),a.key!==void 0&&(o=""+a.key),"key"in a){i={};for(var l in a)l!=="key"&&(i[l]=a[l])}else i=a;return a=i.ref,{$$typeof:e,type:r,key:o,ref:a!==void 0?a:null,props:i}}return op.Fragment=t,op.jsx=n,op.jsxs=n,op}var TP;function iee(){return TP||(TP=1,gx.exports=aee()),gx.exports}var f=iee();const oee="modulepreload",see=function(e){return"/inspector/"+e},NP={},pr=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(d){return Promise.all(d.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");a=u(n.map(d=>{if(d=see(d),d in NP)return;NP[d]=!0;const p=d.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":oee,p||(g.as="script"),g.crossOrigin="",g.href=d,l&&g.setAttribute("nonce",l),document.head.appendChild(g),p)return new Promise((b,v)=>{g.addEventListener("load",b),g.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return a.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};var lee=Object.defineProperty,Ye=(e,t)=>lee(e,"name",{value:t,configurable:!0}),Us=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),vu={};async function K3(){if(typeof process<"u")try{const e=await pr(()=>import("fs"),[]),t=await pr(()=>import("./path-MNZaYwxc.js").then(n=>n.p),[]);return{fs:e.default,path:t.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}Ye(K3,"getNodeModules");var Na=null;function Z3(){if(typeof Us<"u")try{Na=Us("winston")}catch{}}Ye(Z3,"loadWinstonSync");async function Y3(){return Na||(Na=await pr(()=>import("./winston-j3ELiB8E.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),Na}Ye(Y3,"getWinston");var BE="mcp-use";function wv(){try{return typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")||typeof globalThis.EdgeRuntime<"u"||typeof globalThis.Deno<"u"?!1:typeof process<"u"&&!0&&typeof __dirname<"u"}catch{return!1}}Ye(wv,"isNodeJSEnvironment");var nd,cee=(nd=class{_level;name;constructor(t=BE,n="info"){this.name=t,this._level=n}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],r=n.indexOf(this._level);return n.indexOf(t)<=r}formatMessage(t,n){return`${new Date().toLocaleTimeString("en-US",{hour12:!1})} [${this.name}] ${t}: ${n}`}error(t){this.shouldLog("error")&&console.error(this.formatMessage("error",t))}warn(t){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t))}info(t){this.shouldLog("info")&&console.info(this.formatMessage("info",t))}debug(t){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t))}http(t){this.shouldLog("http")&&console.log(this.formatMessage("http",t))}verbose(t){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t))}silly(t){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t))}get level(){return this._level}set level(t){this._level=t}},Ye(nd,"SimpleConsoleLogger"),nd);function Kb(e){switch((typeof process<"u"&&vu?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}Ye(Kb,"resolveLevel");var zo,q3=(zo=class{static get(t=BE){if(!wv()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&vu?.DEBUG||void 0;this.simpleInstances[t]=new cee(t,Kb(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!Na)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:r}=Na,{combine:a,timestamp:i,label:o,colorize:l,splat:u}=r;this.instances[t]=n({level:Kb(vu.DEBUG),format:a(l(),u(),o({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[new Na.transports.Console]})}return this.instances[t]}static getFormatter(){if(!Na)throw new Error("Winston not loaded");const{format:t}=Na,{printf:n}=t,r=n(({level:o,message:l,label:u,timestamp:d})=>`${d} [${u}] ${o}: ${l}`),a=n(({level:o,message:l,label:u,timestamp:d})=>`${d} [${u}] ${o.toUpperCase()}: ${l}`),i=n(({level:o,message:l,label:u,timestamp:d})=>`${d} [${u}] ${o.toUpperCase()}: ${l}`);switch(this.currentFormat){case"minimal":return r;case"detailed":return a;case"emoji":return i;default:return r}}static async configure(t={}){const{level:n,console:r=!0,file:a,format:i="minimal"}=t,o=typeof process<"u"&&vu?.DEBUG||void 0,l=n??Kb(o);if(this.currentFormat=i,!wv()){Object.values(this.simpleInstances).forEach(S=>{S.level=l});return}if(await Y3(),!Na)throw new Error("Failed to load winston");const u=this.get();u.level=l;const d=u;if(d.clear(),r&&d.add(new Na.transports.Console),a){const{fs:S,path:_}=await K3();if(S&&_){const E=_.dirname(_.resolve(a));S.existsSync(E)||S.mkdirSync(E,{recursive:!0}),d.add(new Na.transports.File({filename:a}))}}const{format:p}=Na,{combine:h,timestamp:g,label:b,colorize:v,splat:x}=p;Object.values(this.instances).forEach(S=>{S&&"format"in S&&(S.level=l,S.format=h(v(),x(),b({label:BE}),g({format:"HH:mm:ss"}),this.getFormatter()))})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.simpleInstances).forEach(r=>{r.level=n}),Object.values(this.instances).forEach(r=>{r&&(r.level=n)}),typeof process<"u"&&vu&&(vu.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},Ye(zo,"Logger"),ip(zo,"instances",{}),ip(zo,"simpleInstances",{}),ip(zo,"currentFormat","minimal"),zo);wv()&&(Z3(),Na&&q3.configure());var Ce=q3.get(),Zb={},X3=typeof globalThis.Deno<"u";function uee(e){return X3?globalThis.Deno.env.get(e):Zb[e]}Ye(uee,"getEnv");function dee(){return X3?globalThis.Deno.cwd():process.cwd()}Ye(dee,"getCwd");function bp(){return globalThis.crypto.randomUUID()}Ye(bp,"generateUUID");var fee="1.11.0-canary.10";function Sv(){return fee}Ye(Sv,"getPackageVersion");var rd,Vi=(rd=class{},Ye(rd,"BaseTelemetryEvent"),rd),ad,pee=(ad=class extends Vi{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}}},Ye(ad,"MCPAgentExecutionEvent"),ad);function J3(e,t){const n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),a=Array.from(e.registrations.resources.values()),i=Array.from(e.registrations.resourceTemplates.values()),o=a.map(p=>({name:p.config.name,title:p.config.title??null,description:p.config.description??null,uri:p.config.uri??null,mime_type:p.config.mimeType??null})),l=o.filter(p=>p.mime_type==="text/html+skybridge"),u=o.filter(p=>p.mime_type==="text/uri-list"||p.mime_type==="text/html"),d=o.filter(p=>p.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(p=>({name:p.config.name,title:p.config.title??null,description:p.config.description??null,input_schema:p.config.schema?JSON.stringify(p.config.schema):null,output_schema:p.config.outputSchema?JSON.stringify(p.config.outputSchema):null})):null,resources:o.length>0?o:null,prompts:r.length>0?r.map(p=>({name:p.config.name,title:p.config.title??null,description:p.config.description??null,args:p.config.args?JSON.stringify(p.config.args):null})):null,templates:i.length>0?i.map(p=>({name:p.config.name,title:p.config.title??null,description:p.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:l.length>0?l:null,appsSdkResourcesNumber:l.length,mcpUiResources:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:d.length>0?d:null,mcpAppsResourcesNumber:d.length}}Ye(J3,"createServerRunEventData");var id,mee=(id=class extends Vi{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}}},Ye(id,"ServerRunEvent"),id),od,hee=(od=class extends Vi{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}}},Ye(od,"ServerInitializeEvent"),od),sd,gee=(sd=class extends Vi{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}}},Ye(sd,"ServerToolCallEvent"),sd),ld,bee=(ld=class extends Vi{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}}},Ye(ld,"ServerResourceCallEvent"),ld),cd,vee=(cd=class extends Vi{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}}},Ye(cd,"ServerPromptCallEvent"),cd),ud,yee=(ud=class extends Vi{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}}},Ye(ud,"ServerContextEvent"),ud),dd,wee=(dd=class extends Vi{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}}},Ye(dd,"MCPClientInitEvent"),dd),fd,See=(fd=class extends Vi{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}}},Ye(fd,"ConnectorInitEvent"),fd),pd,xee=(pd=class extends Vi{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,r=n.url;return{server_name:t,server_url_domain:r?this._extractHostname(r):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},Ye(pd,"ClientAddServerEvent"),pd),md,Eee=(md=class extends Vi{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},Ye(md,"ClientRemoveServerEvent"),md);function Q3(e){return e._llm_type||e.constructor.name.toLowerCase()}Ye(Q3,"getModelProvider");function eB(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}Ye(eB,"getModelName");function _ee(e){return[Q3(e),eB(e)]}Ye(_ee,"extractModelInfo");var RP="mcp_use_user_id";function tB(){try{return typeof globalThis.Bun<"u"?"bun":typeof globalThis.Deno<"u"?"deno":typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")?"cloudflare-workers":typeof globalThis.EdgeRuntime<"u"?"edge":typeof window<"u"&&typeof document<"u"?"browser":typeof process<"u"&&typeof process.versions?.node<"u"?"node":"unknown"}catch{return"unknown"}}Ye(tB,"detectRuntimeEnvironment");function nB(e){switch(e){case"node":case"bun":return"filesystem";case"browser":try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only";case"deno":return"session-only";default:return"session-only"}}Ye(nB,"getStorageCapability");var bx=null;function rB(){return bx===null&&(bx=tB()),bx}Ye(rB,"getRuntimeEnvironment");var hd,kee=(hd=class{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout),a=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(r),!a.ok)throw new Error(`HTTP error! status: ${a.status}`)}catch(n){Ce.debug(`Failed to send Scarf event: ${n}`)}}},Ye(hd,"ScarfEventLogger"),hd),Oi,aB=(Oi=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";SCARF_GATEWAY_URL="https://mcpuse.gateway.scarf.sh/events-ts";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogNodeClient=null;_posthogBrowserClient=null;_posthogLoading=null;_scarfClient=null;_runtimeEnvironment;_storageCapability;_source;_userIdPath=null;_versionDownloadPath=null;constructor(){this._runtimeEnvironment=rB(),this._storageCapability=nB(this._runtimeEnvironment),this._source=typeof process<"u"&&Zb?.MCP_USE_TELEMETRY_SOURCE||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";if(t)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,Ce.debug("Telemetry disabled via environment/localStorage");else if(!n)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,Ce.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`);else{Ce.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."),this._posthogLoading=this._initPostHog();try{this._scarfClient=new kee(this.SCARF_GATEWAY_URL,3e3)}catch(r){Ce.warn(`Failed to initialize Scarf telemetry: ${r}`),this._scarfClient=null}}}_checkTelemetryDisabled(){return typeof process<"u"&&Zb?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()==="false"||typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHog(){this._runtimeEnvironment==="browser"?await this._initPostHogBrowser():await this._initPostHogNode()}async _initPostHogBrowser(){try{const t=await pr(()=>import("./module-DXhXtM9n.js"),[]),n=t.default||t.posthog;if(!n||typeof n.init!="function")throw new Error("posthog-js module did not export expected interface");n.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:Ye(()=>{Ce.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=n}catch(t){Ce.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}async _initPostHogNode(){try{const{PostHog:t}=await pr(async()=>{const{PostHog:a}=await import("./posthog-node-CuYhrq1Q.js");return{PostHog:a}},[]),n=["cloudflare-workers","edge","deno"].includes(this._runtimeEnvironment),r={host:this.HOST,disableGeoip:!1};n&&(r.flushAt=1,r.flushInterval=0),this._posthogNodeClient=new t(this.PROJECT_API_KEY,r),Ce.debug("PostHog Node.js client initialized")}catch(t){Ce.warn(`Failed to initialize PostHog Node.js telemetry: ${t}`),this._posthogNodeClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return Oi.instance||(Oi.instance=new Oi),Oi.instance}setSource(t){this._source=t,Ce.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogNodeClient!==null||this._posthogBrowserClient!==null||this._scarfClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"filesystem":this._currUserId=this._getUserIdFromFilesystem();break;case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:this._currUserId=`session-${bp()}`,Ce.debug(`Using session-based user ID (${this._runtimeEnvironment} environment)`);break}this._storageCapability==="filesystem"&&this._currUserId&&this._trackPackageDownloadInternal(this._currUserId,{triggered_by:"user_id_property"}).catch(t=>Ce.debug(`Failed to track package download: ${t}`))}catch(t){Ce.debug(`Failed to get/create user ID: ${t}`),this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromFilesystem(){const t=Us("fs"),n=Us("os"),r=Us("path");if(this._userIdPath||(this._userIdPath=r.join(this._getCacheHome(n,r),"mcp_use_3","telemetry_user_id")),!t.existsSync(this._userIdPath)){Ce.debug(`Creating user ID path: ${this._userIdPath}`),t.mkdirSync(r.dirname(this._userIdPath),{recursive:!0});const i=bp();return t.writeFileSync(this._userIdPath,i),Ce.debug(`User ID path created: ${this._userIdPath}`),i}return t.readFileSync(this._userIdPath,"utf-8").trim()}_getUserIdFromLocalStorage(){try{let t=localStorage.getItem(RP);return t||(t=bp(),localStorage.setItem(RP,t),Ce.debug("Created new browser user ID")),t}catch(t){return Ce.debug(`localStorage access failed: ${t}`),`session-${bp()}`}}_getCacheHome(t,n){const r=Zb.XDG_CACHE_HOME;if(r&&n.isAbsolute(r))return r;const a=t.homedir();return n.join(a,".cache")}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogNodeClient&&!this._posthogBrowserClient&&!this._scarfClient)return;const n={...t.properties};if(n.mcp_use_version=Sv(),n.language="typescript",n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogNodeClient)try{Ce.debug(`CAPTURE: PostHog Node Event ${t.name}`),this._posthogNodeClient.capture({distinctId:this.userId,event:t.name,properties:n})}catch(r){Ce.debug(`Failed to track PostHog Node event ${t.name}: ${r}`)}if(this._posthogBrowserClient)try{Ce.debug(`CAPTURE: PostHog Browser Event ${t.name}`),this._posthogBrowserClient.capture(t.name,{...n,distinct_id:this.userId})}catch(r){Ce.debug(`Failed to track PostHog Browser event ${t.name}: ${r}`)}if(this._scarfClient)try{const r={...n,user_id:this.userId,event:t.name};await this._scarfClient.logEvent(r)}catch(r){Ce.debug(`Failed to track Scarf event ${t.name}: ${r}`)}}async trackPackageDownload(t){return this._trackPackageDownloadInternal(this.userId,t)}async _trackPackageDownloadInternal(t,n){if(this._scarfClient&&this._storageCapability==="filesystem")try{const r=Us("fs"),a=Us("path"),i=Us("os");this._versionDownloadPath||(this._versionDownloadPath=a.join(this._getCacheHome(i,a),"mcp_use","download_version"));const o=Sv();let l=!1,u=!1;if(!r.existsSync(this._versionDownloadPath))l=!0,u=!0,r.mkdirSync(a.dirname(this._versionDownloadPath),{recursive:!0}),r.writeFileSync(this._versionDownloadPath,o);else{const d=r.readFileSync(this._versionDownloadPath,"utf-8").trim();o>d&&(l=!0,u=!1,r.writeFileSync(this._versionDownloadPath,o))}if(l){Ce.debug(`Tracking package download event with properties: ${JSON.stringify(n)}`);const d={...n||{}};d.mcp_use_version=o,d.user_id=t,d.event="package_download",d.first_download=u,d.language="typescript",d.source=this._source,d.runtime=this._runtimeEnvironment,await this._scarfClient.logEvent(d)}}catch(r){Ce.debug(`Failed to track Scarf package_download event: ${r}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new pee(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const r=J3(t,n),a=new mee(r);await this.capture(a)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new hee(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new gee(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new bee(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new vee(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new yee(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new wee(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new See(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const r=new xee({serverName:t,serverConfig:n});await this.capture(r)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new Eee({serverName:t});await this.capture(n)}async trackUseMcpConnection(t){this.isEnabled&&await this.capture({name:"usemcp_connection",properties:{url_domain:new URL(t.url).hostname,transport_type:t.transportType,success:t.success,error_type:t.errorType??null,connection_time_ms:t.connectionTimeMs??null,has_oauth:t.hasOAuth,has_sampling:t.hasSampling,has_elicitation:t.hasElicitation}})}async trackUseMcpToolCall(t){this.isEnabled&&await this.capture({name:"usemcp_tool_call",properties:{tool_name:t.toolName,success:t.success,error_type:t.errorType??null,execution_time_ms:t.executionTimeMs??null}})}async trackUseMcpResourceRead(t){this.isEnabled&&await this.capture({name:"usemcp_resource_read",properties:{resource_uri_scheme:t.resourceUri.split(":")[0],success:t.success,error_type:t.errorType??null}})}identify(t,n){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(t,n)}catch(r){Ce.debug(`Failed to identify user: ${r}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){Ce.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){if(this._posthogNodeClient)try{this._posthogNodeClient.flush(),Ce.debug("PostHog client telemetry queue flushed")}catch(t){Ce.debug(`Failed to flush PostHog client: ${t}`)}}shutdown(){if(this._posthogNodeClient)try{this._posthogNodeClient.shutdown(),Ce.debug("PostHog client shutdown successfully")}catch(t){Ce.debug(`Error shutting down PostHog client: ${t}`)}}},Ye(Oi,"Telemetry"),ip(Oi,"instance",null),Oi),Qi=aB;function Tee(e){Qi.getInstance().setSource(e)}Ye(Tee,"setTelemetrySource");const iB=Object.freeze({status:"aborted"});function be(e,t,n){function r(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,u);const d=o.prototype,p=Object.keys(d);for(let h=0;h<p.length;h++){const g=p[h];g in l||(l[g]=d[g].bind(l))}}const a=n?.Parent??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var u;const d=n?.Parent?new i:this;r(d,l),(u=d._zod).deferred??(u.deferred=[]);for(const p of d._zod.deferred)p();return d}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}const oB=Symbol("zod_brand");class Jl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Iy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const xv={};function ha(e){return e&&Object.assign(xv,e),xv}function Nee(e){return e}function Ree(e){return e}function Cee(e){}function Aee(e){throw new Error}function Iee(e){}function iT(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function We(e,t="|"){return e.map(n=>jt(n)).join(t)}function Ev(e,t){return typeof t=="bigint"?t.toString():t}function Am(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function vc(e){return e==null}function Oy(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function sB(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let a=(r.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(r)){const u=r.match(/\d?e-(\d?)/);u?.[1]&&(a=Number.parseInt(u[1]))}const i=n>a?n:a,o=Number.parseInt(e.toFixed(i).replace(".","")),l=Number.parseInt(t.toFixed(i).replace(".",""));return o%l/10**i}const CP=Symbol("evaluating");function cn(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==CP)return r===void 0&&(r=CP,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Oee(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function il(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function rs(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Dee(e){return rs(e._zod.def)}function Lee(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function jee(e){const t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{const a={};for(let i=0;i<t.length;i++)a[t[i]]=r[i];return a})}function $ee(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function HE(e){return JSON.stringify(e)}function lB(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const oT="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _d(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const cB=Am(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ac(e){if(_d(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(_d(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Dy(e){return ac(e)?{...e}:Array.isArray(e)?[...e]:e}function Mee(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const Pee=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}`)}},_v=new Set(["string","number","symbol"]),uB=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Yo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Me(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 Uee(e){let t;return new Proxy({},{get(n,r,a){return t??(t=e()),Reflect.get(t,r,a)},set(n,r,a,i){return t??(t=e()),Reflect.set(t,r,a,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,a){return t??(t=e()),Reflect.defineProperty(t,r,a)}})}function jt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function dB(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const fB={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]},pB={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function mB(e,t){const n=e._zod.def,r=rs(e._zod.def,{get shape(){const a={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(a[i]=n.shape[i])}return il(this,"shape",a),a},checks:[]});return vi(e,r)}function hB(e,t){const n=e._zod.def,r=rs(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete a[i]}return il(this,"shape",a),a},checks:[]});return vi(e,r)}function gB(e,t){if(!ac(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const a=rs(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return il(this,"shape",i),i},checks:[]});return vi(e,a)}function bB(e,t){if(!ac(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return il(this,"shape",r),r},checks:e._zod.def.checks};return vi(e,n)}function vB(e,t){const n=rs(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return il(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return vi(e,n)}function yB(e,t,n){const r=rs(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in a))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=e?new e({type:"optional",innerType:a[o]}):a[o])}else for(const o in a)i[o]=e?new e({type:"optional",innerType:a[o]}):a[o];return il(this,"shape",i),i},checks:[]});return vi(t,r)}function wB(e,t,n){const r=rs(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return il(this,"shape",i),i},checks:[]});return vi(t,r)}function Gl(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 Di(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function vp(e){return typeof e=="string"?e:e?.message}function Pi(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const a=vp(e.inst?._zod.def?.error?.(e))??vp(t?.error?.(e))??vp(n.customError?.(e))??vp(n.localeError?.(e))??"Invalid input";r.message=a}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ly(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function jy(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function kd(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function zee(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function SB(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function xB(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Fee(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return SB(t+n)}function Bee(e){return xB(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Hee(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 r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function Vee(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class Gee{constructor(...t){}}const EB=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:pB,Class:Gee,NUMBER_FORMAT_RANGES:fB,aborted:Gl,allowsEval:cB,assert:Iee,assertEqual:Nee,assertIs:Cee,assertNever:Aee,assertNotEqual:Ree,assignProp:il,base64ToUint8Array:SB,base64urlToUint8Array:Fee,cached:Am,captureStackTrace:oT,cleanEnum:zee,cleanRegex:Oy,clone:vi,cloneDef:Dee,createTransparentProxy:Uee,defineLazy:cn,esc:HE,escapeRegex:Yo,extend:gB,finalizeIssue:Pi,floatSafeRemainder:sB,getElementAtPath:Lee,getEnumValues:iT,getLengthableOrigin:jy,getParsedType:Pee,getSizableOrigin:Ly,hexToUint8Array:Hee,isObject:_d,isPlainObject:ac,issue:kd,joinValues:We,jsonStringifyReplacer:Ev,merge:vB,mergeDefs:rs,normalizeParams:Me,nullish:vc,numKeys:Mee,objectClone:Oee,omit:hB,optionalKeys:dB,partial:yB,pick:mB,prefixIssues:Di,primitiveTypes:uB,promiseAllObject:jee,propertyKeyTypes:_v,randomString:$ee,required:wB,safeExtend:bB,shallowClone:Dy,slugify:lB,stringifyPrimitive:jt,uint8ArrayToBase64:xB,uint8ArrayToBase64url:Bee,uint8ArrayToHex:Vee,unwrapMessage:vp},Symbol.toStringTag,{value:"Module"})),_B=(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,Ev,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},sT=be("$ZodError",_B),Ka=be("$ZodError",_B,{Parent:Error});function lT(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function cT(e,t=n=>n.message){const n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>r({issues:o}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let o=n,l=0;for(;l<i.path.length;){const u=i.path[l];l===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],l++}}};return r(e),n}function kB(e,t=n=>n.message){const n={errors:[]},r=(a,i=[])=>{var o,l;for(const u of a.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(d=>r({issues:d},u.path));else if(u.code==="invalid_key")r({issues:u.issues},u.path);else if(u.code==="invalid_element")r({issues:u.issues},u.path);else{const d=[...i,...u.path];if(d.length===0){n.errors.push(t(u));continue}let p=n,h=0;for(;h<d.length;){const g=d[h],b=h===d.length-1;typeof g=="string"?(p.properties??(p.properties={}),(o=p.properties)[g]??(o[g]={errors:[]}),p=p.properties[g]):(p.items??(p.items=[]),(l=p.items)[g]??(l[g]={errors:[]}),p=p.items[g]),b&&p.errors.push(t(u)),h++}}};return r(e),n}function TB(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function NB(e){const t=[],n=[...e.issues].sort((r,a)=>(r.path??[]).length-(a.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${TB(r.path)}`);return t.join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-mndsjLRM.js","assets/util-t-trnxQI.js","assets/index-DRz5BQNA.js","assets/path-BzkNY3AW.js","assets/path-MNZaYwxc.js","assets/index-BVRlDOe5.js","assets/index-BCGobKCz.js","assets/index-Baw2JzBf.js","assets/index-DxljWnJH.js","assets/embeddings-7yD5FP5W.js","assets/index-BKkxSJZC.js","assets/index-CVHM2qPt.js","assets/browser-C4F-osqk.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var tee=Object.defineProperty;var nee=(e,t,n)=>t in e?tee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ip=(e,t,n)=>nee(e,typeof t!="symbol"?t+"":t,n);function ree(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=n(a);fetch(a.href,i)}})();function Ay(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function AAe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var a=!1;try{a=this instanceof r}catch{}return a?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}),n}var gx={exports:{}},op={};var kP;function aee(){if(kP)return op;kP=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,i){var o=null;if(i!==void 0&&(o=""+i),a.key!==void 0&&(o=""+a.key),"key"in a){i={};for(var l in a)l!=="key"&&(i[l]=a[l])}else i=a;return a=i.ref,{$$typeof:e,type:r,key:o,ref:a!==void 0?a:null,props:i}}return op.Fragment=t,op.jsx=n,op.jsxs=n,op}var TP;function iee(){return TP||(TP=1,gx.exports=aee()),gx.exports}var f=iee();const oee="modulepreload",see=function(e){return"/inspector/"+e},NP={},pr=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(d){return Promise.all(d.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");a=u(n.map(d=>{if(d=see(d),d in NP)return;NP[d]=!0;const p=d.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":oee,p||(g.as="script"),g.crossOrigin="",g.href=d,l&&g.setAttribute("nonce",l),document.head.appendChild(g),p)return new Promise((b,v)=>{g.addEventListener("load",b),g.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${d}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return a.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};var lee=Object.defineProperty,Ye=(e,t)=>lee(e,"name",{value:t,configurable:!0}),Us=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),vu={};async function K3(){if(typeof process<"u")try{const e=await pr(()=>import("fs"),[]),t=await pr(()=>import("./path-MNZaYwxc.js").then(n=>n.p),[]);return{fs:e.default,path:t.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}Ye(K3,"getNodeModules");var Na=null;function Z3(){if(typeof Us<"u")try{Na=Us("winston")}catch{}}Ye(Z3,"loadWinstonSync");async function Y3(){return Na||(Na=await pr(()=>import("./winston-mndsjLRM.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),Na}Ye(Y3,"getWinston");var BE="mcp-use";function wv(){try{return typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")||typeof globalThis.EdgeRuntime<"u"||typeof globalThis.Deno<"u"?!1:typeof process<"u"&&!0&&typeof __dirname<"u"}catch{return!1}}Ye(wv,"isNodeJSEnvironment");var nd,cee=(nd=class{_level;name;constructor(t=BE,n="info"){this.name=t,this._level=n}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],r=n.indexOf(this._level);return n.indexOf(t)<=r}formatMessage(t,n){return`${new Date().toLocaleTimeString("en-US",{hour12:!1})} [${this.name}] ${t}: ${n}`}error(t){this.shouldLog("error")&&console.error(this.formatMessage("error",t))}warn(t){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t))}info(t){this.shouldLog("info")&&console.info(this.formatMessage("info",t))}debug(t){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t))}http(t){this.shouldLog("http")&&console.log(this.formatMessage("http",t))}verbose(t){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t))}silly(t){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t))}get level(){return this._level}set level(t){this._level=t}},Ye(nd,"SimpleConsoleLogger"),nd);function Kb(e){switch((typeof process<"u"&&vu?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}Ye(Kb,"resolveLevel");var zo,q3=(zo=class{static get(t=BE){if(!wv()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&vu?.DEBUG||void 0;this.simpleInstances[t]=new cee(t,Kb(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!Na)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:r}=Na,{combine:a,timestamp:i,label:o,colorize:l,splat:u}=r;this.instances[t]=n({level:Kb(vu.DEBUG),format:a(l(),u(),o({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[new Na.transports.Console]})}return this.instances[t]}static getFormatter(){if(!Na)throw new Error("Winston not loaded");const{format:t}=Na,{printf:n}=t,r=n(({level:o,message:l,label:u,timestamp:d})=>`${d} [${u}] ${o}: ${l}`),a=n(({level:o,message:l,label:u,timestamp:d})=>`${d} [${u}] ${o.toUpperCase()}: ${l}`),i=n(({level:o,message:l,label:u,timestamp:d})=>`${d} [${u}] ${o.toUpperCase()}: ${l}`);switch(this.currentFormat){case"minimal":return r;case"detailed":return a;case"emoji":return i;default:return r}}static async configure(t={}){const{level:n,console:r=!0,file:a,format:i="minimal"}=t,o=typeof process<"u"&&vu?.DEBUG||void 0,l=n??Kb(o);if(this.currentFormat=i,!wv()){Object.values(this.simpleInstances).forEach(S=>{S.level=l});return}if(await Y3(),!Na)throw new Error("Failed to load winston");const u=this.get();u.level=l;const d=u;if(d.clear(),r&&d.add(new Na.transports.Console),a){const{fs:S,path:_}=await K3();if(S&&_){const E=_.dirname(_.resolve(a));S.existsSync(E)||S.mkdirSync(E,{recursive:!0}),d.add(new Na.transports.File({filename:a}))}}const{format:p}=Na,{combine:h,timestamp:g,label:b,colorize:v,splat:x}=p;Object.values(this.instances).forEach(S=>{S&&"format"in S&&(S.level=l,S.format=h(v(),x(),b({label:BE}),g({format:"HH:mm:ss"}),this.getFormatter()))})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.simpleInstances).forEach(r=>{r.level=n}),Object.values(this.instances).forEach(r=>{r&&(r.level=n)}),typeof process<"u"&&vu&&(vu.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},Ye(zo,"Logger"),ip(zo,"instances",{}),ip(zo,"simpleInstances",{}),ip(zo,"currentFormat","minimal"),zo);wv()&&(Z3(),Na&&q3.configure());var Ce=q3.get(),Zb={},X3=typeof globalThis.Deno<"u";function uee(e){return X3?globalThis.Deno.env.get(e):Zb[e]}Ye(uee,"getEnv");function dee(){return X3?globalThis.Deno.cwd():process.cwd()}Ye(dee,"getCwd");function bp(){return globalThis.crypto.randomUUID()}Ye(bp,"generateUUID");var fee="1.11.0-canary.11";function Sv(){return fee}Ye(Sv,"getPackageVersion");var rd,Vi=(rd=class{},Ye(rd,"BaseTelemetryEvent"),rd),ad,pee=(ad=class extends Vi{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}}},Ye(ad,"MCPAgentExecutionEvent"),ad);function J3(e,t){const n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),a=Array.from(e.registrations.resources.values()),i=Array.from(e.registrations.resourceTemplates.values()),o=a.map(p=>({name:p.config.name,title:p.config.title??null,description:p.config.description??null,uri:p.config.uri??null,mime_type:p.config.mimeType??null})),l=o.filter(p=>p.mime_type==="text/html+skybridge"),u=o.filter(p=>p.mime_type==="text/uri-list"||p.mime_type==="text/html"),d=o.filter(p=>p.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(p=>({name:p.config.name,title:p.config.title??null,description:p.config.description??null,input_schema:p.config.schema?JSON.stringify(p.config.schema):null,output_schema:p.config.outputSchema?JSON.stringify(p.config.outputSchema):null})):null,resources:o.length>0?o:null,prompts:r.length>0?r.map(p=>({name:p.config.name,title:p.config.title??null,description:p.config.description??null,args:p.config.args?JSON.stringify(p.config.args):null})):null,templates:i.length>0?i.map(p=>({name:p.config.name,title:p.config.title??null,description:p.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:l.length>0?l:null,appsSdkResourcesNumber:l.length,mcpUiResources:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:d.length>0?d:null,mcpAppsResourcesNumber:d.length}}Ye(J3,"createServerRunEventData");var id,mee=(id=class extends Vi{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}}},Ye(id,"ServerRunEvent"),id),od,hee=(od=class extends Vi{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}}},Ye(od,"ServerInitializeEvent"),od),sd,gee=(sd=class extends Vi{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}}},Ye(sd,"ServerToolCallEvent"),sd),ld,bee=(ld=class extends Vi{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}}},Ye(ld,"ServerResourceCallEvent"),ld),cd,vee=(cd=class extends Vi{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}}},Ye(cd,"ServerPromptCallEvent"),cd),ud,yee=(ud=class extends Vi{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}}},Ye(ud,"ServerContextEvent"),ud),dd,wee=(dd=class extends Vi{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}}},Ye(dd,"MCPClientInitEvent"),dd),fd,See=(fd=class extends Vi{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}}},Ye(fd,"ConnectorInitEvent"),fd),pd,xee=(pd=class extends Vi{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,r=n.url;return{server_name:t,server_url_domain:r?this._extractHostname(r):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},Ye(pd,"ClientAddServerEvent"),pd),md,Eee=(md=class extends Vi{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},Ye(md,"ClientRemoveServerEvent"),md);function Q3(e){return e._llm_type||e.constructor.name.toLowerCase()}Ye(Q3,"getModelProvider");function eB(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}Ye(eB,"getModelName");function _ee(e){return[Q3(e),eB(e)]}Ye(_ee,"extractModelInfo");var RP="mcp_use_user_id";function tB(){try{return typeof globalThis.Bun<"u"?"bun":typeof globalThis.Deno<"u"?"deno":typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")?"cloudflare-workers":typeof globalThis.EdgeRuntime<"u"?"edge":typeof window<"u"&&typeof document<"u"?"browser":typeof process<"u"&&typeof process.versions?.node<"u"?"node":"unknown"}catch{return"unknown"}}Ye(tB,"detectRuntimeEnvironment");function nB(e){switch(e){case"node":case"bun":return"filesystem";case"browser":try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only";case"deno":return"session-only";default:return"session-only"}}Ye(nB,"getStorageCapability");var bx=null;function rB(){return bx===null&&(bx=tB()),bx}Ye(rB,"getRuntimeEnvironment");var hd,kee=(hd=class{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout),a=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(r),!a.ok)throw new Error(`HTTP error! status: ${a.status}`)}catch(n){Ce.debug(`Failed to send Scarf event: ${n}`)}}},Ye(hd,"ScarfEventLogger"),hd),Oi,aB=(Oi=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";SCARF_GATEWAY_URL="https://mcpuse.gateway.scarf.sh/events-ts";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogNodeClient=null;_posthogBrowserClient=null;_posthogLoading=null;_scarfClient=null;_runtimeEnvironment;_storageCapability;_source;_userIdPath=null;_versionDownloadPath=null;constructor(){this._runtimeEnvironment=rB(),this._storageCapability=nB(this._runtimeEnvironment),this._source=typeof process<"u"&&Zb?.MCP_USE_TELEMETRY_SOURCE||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";if(t)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,Ce.debug("Telemetry disabled via environment/localStorage");else if(!n)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,Ce.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`);else{Ce.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."),this._posthogLoading=this._initPostHog();try{this._scarfClient=new kee(this.SCARF_GATEWAY_URL,3e3)}catch(r){Ce.warn(`Failed to initialize Scarf telemetry: ${r}`),this._scarfClient=null}}}_checkTelemetryDisabled(){return typeof process<"u"&&Zb?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()==="false"||typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHog(){this._runtimeEnvironment==="browser"?await this._initPostHogBrowser():await this._initPostHogNode()}async _initPostHogBrowser(){try{const t=await pr(()=>import("./module-DXhXtM9n.js"),[]),n=t.default||t.posthog;if(!n||typeof n.init!="function")throw new Error("posthog-js module did not export expected interface");n.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:Ye(()=>{Ce.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=n}catch(t){Ce.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}async _initPostHogNode(){try{const{PostHog:t}=await pr(async()=>{const{PostHog:a}=await import("./posthog-node-CuYhrq1Q.js");return{PostHog:a}},[]),n=["cloudflare-workers","edge","deno"].includes(this._runtimeEnvironment),r={host:this.HOST,disableGeoip:!1};n&&(r.flushAt=1,r.flushInterval=0),this._posthogNodeClient=new t(this.PROJECT_API_KEY,r),Ce.debug("PostHog Node.js client initialized")}catch(t){Ce.warn(`Failed to initialize PostHog Node.js telemetry: ${t}`),this._posthogNodeClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return Oi.instance||(Oi.instance=new Oi),Oi.instance}setSource(t){this._source=t,Ce.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogNodeClient!==null||this._posthogBrowserClient!==null||this._scarfClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"filesystem":this._currUserId=this._getUserIdFromFilesystem();break;case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:this._currUserId=`session-${bp()}`,Ce.debug(`Using session-based user ID (${this._runtimeEnvironment} environment)`);break}this._storageCapability==="filesystem"&&this._currUserId&&this._trackPackageDownloadInternal(this._currUserId,{triggered_by:"user_id_property"}).catch(t=>Ce.debug(`Failed to track package download: ${t}`))}catch(t){Ce.debug(`Failed to get/create user ID: ${t}`),this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromFilesystem(){const t=Us("fs"),n=Us("os"),r=Us("path");if(this._userIdPath||(this._userIdPath=r.join(this._getCacheHome(n,r),"mcp_use_3","telemetry_user_id")),!t.existsSync(this._userIdPath)){Ce.debug(`Creating user ID path: ${this._userIdPath}`),t.mkdirSync(r.dirname(this._userIdPath),{recursive:!0});const i=bp();return t.writeFileSync(this._userIdPath,i),Ce.debug(`User ID path created: ${this._userIdPath}`),i}return t.readFileSync(this._userIdPath,"utf-8").trim()}_getUserIdFromLocalStorage(){try{let t=localStorage.getItem(RP);return t||(t=bp(),localStorage.setItem(RP,t),Ce.debug("Created new browser user ID")),t}catch(t){return Ce.debug(`localStorage access failed: ${t}`),`session-${bp()}`}}_getCacheHome(t,n){const r=Zb.XDG_CACHE_HOME;if(r&&n.isAbsolute(r))return r;const a=t.homedir();return n.join(a,".cache")}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogNodeClient&&!this._posthogBrowserClient&&!this._scarfClient)return;const n={...t.properties};if(n.mcp_use_version=Sv(),n.language="typescript",n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogNodeClient)try{Ce.debug(`CAPTURE: PostHog Node Event ${t.name}`),this._posthogNodeClient.capture({distinctId:this.userId,event:t.name,properties:n})}catch(r){Ce.debug(`Failed to track PostHog Node event ${t.name}: ${r}`)}if(this._posthogBrowserClient)try{Ce.debug(`CAPTURE: PostHog Browser Event ${t.name}`),this._posthogBrowserClient.capture(t.name,{...n,distinct_id:this.userId})}catch(r){Ce.debug(`Failed to track PostHog Browser event ${t.name}: ${r}`)}if(this._scarfClient)try{const r={...n,user_id:this.userId,event:t.name};await this._scarfClient.logEvent(r)}catch(r){Ce.debug(`Failed to track Scarf event ${t.name}: ${r}`)}}async trackPackageDownload(t){return this._trackPackageDownloadInternal(this.userId,t)}async _trackPackageDownloadInternal(t,n){if(this._scarfClient&&this._storageCapability==="filesystem")try{const r=Us("fs"),a=Us("path"),i=Us("os");this._versionDownloadPath||(this._versionDownloadPath=a.join(this._getCacheHome(i,a),"mcp_use","download_version"));const o=Sv();let l=!1,u=!1;if(!r.existsSync(this._versionDownloadPath))l=!0,u=!0,r.mkdirSync(a.dirname(this._versionDownloadPath),{recursive:!0}),r.writeFileSync(this._versionDownloadPath,o);else{const d=r.readFileSync(this._versionDownloadPath,"utf-8").trim();o>d&&(l=!0,u=!1,r.writeFileSync(this._versionDownloadPath,o))}if(l){Ce.debug(`Tracking package download event with properties: ${JSON.stringify(n)}`);const d={...n||{}};d.mcp_use_version=o,d.user_id=t,d.event="package_download",d.first_download=u,d.language="typescript",d.source=this._source,d.runtime=this._runtimeEnvironment,await this._scarfClient.logEvent(d)}}catch(r){Ce.debug(`Failed to track Scarf package_download event: ${r}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new pee(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const r=J3(t,n),a=new mee(r);await this.capture(a)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new hee(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new gee(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new bee(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new vee(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new yee(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new wee(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new See(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const r=new xee({serverName:t,serverConfig:n});await this.capture(r)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new Eee({serverName:t});await this.capture(n)}async trackUseMcpConnection(t){this.isEnabled&&await this.capture({name:"usemcp_connection",properties:{url_domain:new URL(t.url).hostname,transport_type:t.transportType,success:t.success,error_type:t.errorType??null,connection_time_ms:t.connectionTimeMs??null,has_oauth:t.hasOAuth,has_sampling:t.hasSampling,has_elicitation:t.hasElicitation}})}async trackUseMcpToolCall(t){this.isEnabled&&await this.capture({name:"usemcp_tool_call",properties:{tool_name:t.toolName,success:t.success,error_type:t.errorType??null,execution_time_ms:t.executionTimeMs??null}})}async trackUseMcpResourceRead(t){this.isEnabled&&await this.capture({name:"usemcp_resource_read",properties:{resource_uri_scheme:t.resourceUri.split(":")[0],success:t.success,error_type:t.errorType??null}})}identify(t,n){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(t,n)}catch(r){Ce.debug(`Failed to identify user: ${r}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){Ce.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){if(this._posthogNodeClient)try{this._posthogNodeClient.flush(),Ce.debug("PostHog client telemetry queue flushed")}catch(t){Ce.debug(`Failed to flush PostHog client: ${t}`)}}shutdown(){if(this._posthogNodeClient)try{this._posthogNodeClient.shutdown(),Ce.debug("PostHog client shutdown successfully")}catch(t){Ce.debug(`Error shutting down PostHog client: ${t}`)}}},Ye(Oi,"Telemetry"),ip(Oi,"instance",null),Oi),Qi=aB;function Tee(e){Qi.getInstance().setSource(e)}Ye(Tee,"setTelemetrySource");const iB=Object.freeze({status:"aborted"});function be(e,t,n){function r(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,u);const d=o.prototype,p=Object.keys(d);for(let h=0;h<p.length;h++){const g=p[h];g in l||(l[g]=d[g].bind(l))}}const a=n?.Parent??Object;class i extends a{}Object.defineProperty(i,"name",{value:e});function o(l){var u;const d=n?.Parent?new i:this;r(d,l),(u=d._zod).deferred??(u.deferred=[]);for(const p of d._zod.deferred)p();return d}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}const oB=Symbol("zod_brand");class Jl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Iy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const xv={};function ha(e){return e&&Object.assign(xv,e),xv}function Nee(e){return e}function Ree(e){return e}function Cee(e){}function Aee(e){throw new Error}function Iee(e){}function iT(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function We(e,t="|"){return e.map(n=>jt(n)).join(t)}function Ev(e,t){return typeof t=="bigint"?t.toString():t}function Am(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function vc(e){return e==null}function Oy(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function sB(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let a=(r.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(r)){const u=r.match(/\d?e-(\d?)/);u?.[1]&&(a=Number.parseInt(u[1]))}const i=n>a?n:a,o=Number.parseInt(e.toFixed(i).replace(".","")),l=Number.parseInt(t.toFixed(i).replace(".",""));return o%l/10**i}const CP=Symbol("evaluating");function cn(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==CP)return r===void 0&&(r=CP,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Oee(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function il(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function rs(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Dee(e){return rs(e._zod.def)}function Lee(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function jee(e){const t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{const a={};for(let i=0;i<t.length;i++)a[t[i]]=r[i];return a})}function $ee(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function HE(e){return JSON.stringify(e)}function lB(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const oT="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _d(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const cB=Am(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ac(e){if(_d(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(_d(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Dy(e){return ac(e)?{...e}:Array.isArray(e)?[...e]:e}function Mee(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const Pee=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}`)}},_v=new Set(["string","number","symbol"]),uB=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Yo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Me(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 Uee(e){let t;return new Proxy({},{get(n,r,a){return t??(t=e()),Reflect.get(t,r,a)},set(n,r,a,i){return t??(t=e()),Reflect.set(t,r,a,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,a){return t??(t=e()),Reflect.defineProperty(t,r,a)}})}function jt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function dB(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const fB={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]},pB={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function mB(e,t){const n=e._zod.def,r=rs(e._zod.def,{get shape(){const a={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(a[i]=n.shape[i])}return il(this,"shape",a),a},checks:[]});return vi(e,r)}function hB(e,t){const n=e._zod.def,r=rs(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete a[i]}return il(this,"shape",a),a},checks:[]});return vi(e,r)}function gB(e,t){if(!ac(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const a=rs(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return il(this,"shape",i),i},checks:[]});return vi(e,a)}function bB(e,t){if(!ac(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return il(this,"shape",r),r},checks:e._zod.def.checks};return vi(e,n)}function vB(e,t){const n=rs(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return il(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return vi(e,n)}function yB(e,t,n){const r=rs(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in a))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=e?new e({type:"optional",innerType:a[o]}):a[o])}else for(const o in a)i[o]=e?new e({type:"optional",innerType:a[o]}):a[o];return il(this,"shape",i),i},checks:[]});return vi(t,r)}function wB(e,t,n){const r=rs(t._zod.def,{get shape(){const a=t._zod.def.shape,i={...a};if(n)for(const o in n){if(!(o in i))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(i[o]=new e({type:"nonoptional",innerType:a[o]}))}else for(const o in a)i[o]=new e({type:"nonoptional",innerType:a[o]});return il(this,"shape",i),i},checks:[]});return vi(t,r)}function Gl(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 Di(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function vp(e){return typeof e=="string"?e:e?.message}function Pi(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const a=vp(e.inst?._zod.def?.error?.(e))??vp(t?.error?.(e))??vp(n.customError?.(e))??vp(n.localeError?.(e))??"Invalid input";r.message=a}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ly(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function jy(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function kd(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function zee(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function SB(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function xB(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Fee(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return SB(t+n)}function Bee(e){return xB(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Hee(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 r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function Vee(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class Gee{constructor(...t){}}const EB=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:pB,Class:Gee,NUMBER_FORMAT_RANGES:fB,aborted:Gl,allowsEval:cB,assert:Iee,assertEqual:Nee,assertIs:Cee,assertNever:Aee,assertNotEqual:Ree,assignProp:il,base64ToUint8Array:SB,base64urlToUint8Array:Fee,cached:Am,captureStackTrace:oT,cleanEnum:zee,cleanRegex:Oy,clone:vi,cloneDef:Dee,createTransparentProxy:Uee,defineLazy:cn,esc:HE,escapeRegex:Yo,extend:gB,finalizeIssue:Pi,floatSafeRemainder:sB,getElementAtPath:Lee,getEnumValues:iT,getLengthableOrigin:jy,getParsedType:Pee,getSizableOrigin:Ly,hexToUint8Array:Hee,isObject:_d,isPlainObject:ac,issue:kd,joinValues:We,jsonStringifyReplacer:Ev,merge:vB,mergeDefs:rs,normalizeParams:Me,nullish:vc,numKeys:Mee,objectClone:Oee,omit:hB,optionalKeys:dB,partial:yB,pick:mB,prefixIssues:Di,primitiveTypes:uB,promiseAllObject:jee,propertyKeyTypes:_v,randomString:$ee,required:wB,safeExtend:bB,shallowClone:Dy,slugify:lB,stringifyPrimitive:jt,uint8ArrayToBase64:xB,uint8ArrayToBase64url:Bee,uint8ArrayToHex:Vee,unwrapMessage:vp},Symbol.toStringTag,{value:"Module"})),_B=(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,Ev,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},sT=be("$ZodError",_B),Ka=be("$ZodError",_B,{Parent:Error});function lT(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function cT(e,t=n=>n.message){const n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(o=>r({issues:o}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let o=n,l=0;for(;l<i.path.length;){const u=i.path[l];l===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],l++}}};return r(e),n}function kB(e,t=n=>n.message){const n={errors:[]},r=(a,i=[])=>{var o,l;for(const u of a.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(d=>r({issues:d},u.path));else if(u.code==="invalid_key")r({issues:u.issues},u.path);else if(u.code==="invalid_element")r({issues:u.issues},u.path);else{const d=[...i,...u.path];if(d.length===0){n.errors.push(t(u));continue}let p=n,h=0;for(;h<d.length;){const g=d[h],b=h===d.length-1;typeof g=="string"?(p.properties??(p.properties={}),(o=p.properties)[g]??(o[g]={errors:[]}),p=p.properties[g]):(p.items??(p.items=[]),(l=p.items)[g]??(l[g]={errors:[]}),p=p.items[g]),b&&p.errors.push(t(u)),h++}}};return r(e),n}function TB(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function NB(e){const t=[],n=[...e.issues].sort((r,a)=>(r.path??[]).length-(a.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${TB(r.path)}`);return t.join(`
|
|
3
3
|
`)}const Im=e=>(t,n,r,a)=>{const i=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Jl;if(o.issues.length){const l=new(a?.Err??e)(o.issues.map(u=>Pi(u,i,ha())));throw oT(l,a?.callee),l}return o.value},VE=Im(Ka),Om=e=>async(t,n,r,a)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new(a?.Err??e)(o.issues.map(u=>Pi(u,i,ha())));throw oT(l,a?.callee),l}return o.value},GE=Om(Ka),Dm=e=>(t,n,r)=>{const a=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Jl;return i.issues.length?{success:!1,error:new(e??sT)(i.issues.map(o=>Pi(o,a,ha())))}:{success:!0,data:i.value}},uT=Dm(Ka),Lm=e=>async(t,n,r)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},a);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(o=>Pi(o,a,ha())))}:{success:!0,data:i.value}},RB=Lm(Ka),dT=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Im(e)(t,n,a)},Wee=dT(Ka),fT=e=>(t,n,r)=>Im(e)(t,n,r),Kee=fT(Ka),pT=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Om(e)(t,n,a)},Zee=pT(Ka),mT=e=>async(t,n,r)=>Om(e)(t,n,r),Yee=mT(Ka),hT=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Dm(e)(t,n,a)},qee=hT(Ka),gT=e=>(t,n,r)=>Dm(e)(t,n,r),Xee=gT(Ka),bT=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Lm(e)(t,n,a)},Jee=bT(Ka),vT=e=>async(t,n,r)=>Lm(e)(t,n,r),Qee=vT(Ka),CB=/^[cC][^\s-]{8,}$/,AB=/^[0-9a-z]+$/,IB=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,OB=/^[0-9a-vA-V]{20}$/,DB=/^[A-Za-z0-9]{27}$/,LB=/^[a-zA-Z0-9_-]{21}$/,jB=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ete=/^[-+]?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)?)??$/,$B=/^([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)$/,tte=Td(4),nte=Td(6),rte=Td(7),MB=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ate=/^[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])?)*$/,ite=/^(([^<>()\[\]\\.,;:\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,}))$/,PB=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,ote=PB,ste=/^[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])?)*$/,lte="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function UB(){return new RegExp(lte,"u")}const zB=/^(?:(?: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])$/,FB=/^(([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}|:))$/,BB=e=>{const t=Yo(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},HB=/^((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])$/,VB=/^(([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])$/,GB=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yT=/^[A-Za-z0-9_-]*$/,WB=/^(?=.{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])?)*\.?$/,KB=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,ZB=/^\+(?:[0-9]){6,14}[0-9]$/,YB="(?:(?:\\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])))",qB=new RegExp(`^${YB}$`);function XB(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 JB(e){return new RegExp(`^${XB(e)}$`)}function QB(e){const t=XB({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${YB}T(?:${r})$`)}const e6=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},t6=/^-?\d+n?$/,n6=/^-?\d+$/,r6=/^-?\d+(?:\.\d+)?/,a6=/^(?:true|false)$/i,i6=/^null$/i,o6=/^undefined$/i,s6=/^[^A-Z]*$/,l6=/^[^a-z]*$/,c6=/^[0-9a-fA-F]*$/;function jm(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function $m(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const cte=/^[0-9a-fA-F]{32}$/,ute=jm(22,"=="),dte=$m(22),fte=/^[0-9a-fA-F]{40}$/,pte=jm(27,"="),mte=$m(27),hte=/^[0-9a-fA-F]{64}$/,gte=jm(43,"="),bte=$m(43),vte=/^[0-9a-fA-F]{96}$/,yte=jm(64,""),wte=$m(64),Ste=/^[0-9a-fA-F]{128}$/,xte=jm(86,"=="),Ete=$m(86),wT=Object.freeze(Object.defineProperty({__proto__:null,base64:GB,base64url:yT,bigint:t6,boolean:a6,browserEmail:ste,cidrv4:HB,cidrv6:VB,cuid:CB,cuid2:AB,date:qB,datetime:QB,domain:KB,duration:jB,e164:ZB,email:MB,emoji:UB,extendedDuration:ete,guid:$B,hex:c6,hostname:WB,html5Email:ate,idnEmail:ote,integer:n6,ipv4:zB,ipv6:FB,ksuid:DB,lowercase:s6,mac:BB,md5_base64:ute,md5_base64url:dte,md5_hex:cte,nanoid:LB,null:i6,number:r6,rfc5322Email:ite,sha1_base64:pte,sha1_base64url:mte,sha1_hex:fte,sha256_base64:gte,sha256_base64url:bte,sha256_hex:hte,sha384_base64:yte,sha384_base64url:wte,sha384_hex:vte,sha512_base64:xte,sha512_base64url:Ete,sha512_hex:Ste,string:e6,time:JB,ulid:IB,undefined:o6,unicodeEmail:PB,uppercase:l6,uuid:Td,uuid4:tte,uuid6:nte,uuid7:rte,xid:OB},Symbol.toStringTag,{value:"Module"})),tr=be("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),u6={number:"number",bigint:"bigint",object:"date"},ST=be("$ZodCheckLessThan",(e,t)=>{tr.init(e,t);const n=u6[typeof t.value];e._zod.onattach.push(r=>{const a=r._zod.bag,i=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xT=be("$ZodCheckGreaterThan",(e,t)=>{tr.init(e,t);const n=u6[typeof t.value];e._zod.onattach.push(r=>{const a=r._zod.bag,i=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),d6=be("$ZodCheckMultipleOf",(e,t)=>{tr.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):sB(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})}}),f6=be("$ZodCheckNumberFormat",(e,t)=>{tr.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[a,i]=fB[t.format];e._zod.onattach.push(o=>{const l=o._zod.bag;l.format=t.format,l.minimum=a,l.maximum=i,n&&(l.pattern=n6)}),e._zod.check=o=>{const l=o.value;if(n){if(!Number.isInteger(l)){o.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?o.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):o.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}l<a&&o.issues.push({origin:"number",input:l,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),l>i&&o.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inst:e})}}),p6=be("$ZodCheckBigIntFormat",(e,t)=>{tr.init(e,t);const[n,r]=pB[t.format];e._zod.onattach.push(a=>{const i=a._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=a=>{const i=a.value;i<n&&a.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>r&&a.issues.push({origin:"bigint",input:i,code:"too_big",maximum:r,inst:e})}}),m6=be("$ZodCheckMaxSize",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!vc(a)&&a.size!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;a.size<=t.maximum||r.issues.push({origin:Ly(a),code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),h6=be("$ZodCheckMinSize",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!vc(a)&&a.size!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;a.size>=t.minimum||r.issues.push({origin:Ly(a),code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),g6=be("$ZodCheckSizeEquals",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!vc(a)&&a.size!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.size,a.maximum=t.size,a.size=t.size}),e._zod.check=r=>{const a=r.value,i=a.size;if(i===t.size)return;const o=i>t.size;r.issues.push({origin:Ly(a),...o?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),b6=be("$ZodCheckMaxLength",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!vc(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;if(a.length<=t.maximum)return;const o=jy(a);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),v6=be("$ZodCheckMinLength",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!vc(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;if(a.length>=t.minimum)return;const o=jy(a);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),y6=be("$ZodCheckLengthEquals",(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!vc(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=r=>{const a=r.value,i=a.length;if(i===t.length)return;const o=jy(a),l=i>t.length;r.issues.push({origin:o,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Mm=be("$ZodCheckStringFormat",(e,t)=>{var n,r;tr.init(e,t),e._zod.onattach.push(a=>{const i=a._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=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),w6=be("$ZodCheckRegex",(e,t)=>{Mm.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})}}),S6=be("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=s6),Mm.init(e,t)}),x6=be("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=l6),Mm.init(e,t)}),E6=be("$ZodCheckIncludes",(e,t)=>{tr.init(e,t);const n=Yo(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),_6=be("$ZodCheckStartsWith",(e,t)=>{tr.init(e,t);const n=new RegExp(`^${Yo(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),k6=be("$ZodCheckEndsWith",(e,t)=>{tr.init(e,t);const n=new RegExp(`.*${Yo(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function AP(e,t,n){e.issues.length&&t.issues.push(...Di(n,e.issues))}const T6=be("$ZodCheckProperty",(e,t)=>{tr.init(e,t),e._zod.check=n=>{const r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(a=>AP(a,n,t.property));AP(r,n,t.property)}}),N6=be("$ZodCheckMimeType",(e,t)=>{tr.init(e,t);const n=new Set(t.mime);e._zod.onattach.push(r=>{r._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),R6=be("$ZodCheckOverwrite",(e,t)=>{tr.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class C6{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
4
4
|
`).filter(o=>o),a=Math.min(...r.map(o=>o.length-o.trimStart().length)),i=r.map(o=>o.slice(a)).map(o=>" ".repeat(this.indent*2)+o);for(const o of i)this.content.push(o)}compile(){const t=Function,n=this?.args,a=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,a.join(`
|
|
5
5
|
`))}}const A6={major:4,minor:1,patch:13},Ft=be("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=A6;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const a of r)for(const i of a._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const a=(o,l,u)=>{let d=Gl(o),p;for(const h of l){if(h._zod.def.when){if(!h._zod.def.when(o))continue}else if(d)continue;const g=o.issues.length,b=h._zod.check(o);if(b instanceof Promise&&u?.async===!1)throw new Jl;if(p||b instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await b,o.issues.length!==g&&(d||(d=Gl(o,g)))});else{if(o.issues.length===g)continue;d||(d=Gl(o,g))}}return p?p.then(()=>o):o},i=(o,l,u)=>{if(Gl(o))return o.aborted=!0,o;const d=a(l,r,u);if(d instanceof Promise){if(u.async===!1)throw new Jl;return d.then(p=>e._zod.parse(p,u))}return e._zod.parse(d,u)};e._zod.run=(o,l)=>{if(l.skipChecks)return e._zod.parse(o,l);if(l.direction==="backward"){const d=e._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(p=>i(p,o,l)):i(d,o,l)}const u=e._zod.parse(o,l);if(u instanceof Promise){if(l.async===!1)throw new Jl;return u.then(d=>a(d,r,l))}return a(u,r,l)}}e["~standard"]={validate:a=>{try{const i=uT(e,a);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return RB(e,a).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}}),Pm=be("$ZodString",(e,t)=>{Ft.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??e6(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Hn=be("$ZodStringFormat",(e,t)=>{Mm.init(e,t),Pm.init(e,t)}),I6=be("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=$B),Hn.init(e,t)}),O6=be("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Td(r))}else t.pattern??(t.pattern=Td());Hn.init(e,t)}),D6=be("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=MB),Hn.init(e,t)}),L6=be("$ZodURL",(e,t)=>{Hn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),a=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),j6=be("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=UB()),Hn.init(e,t)}),$6=be("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=LB),Hn.init(e,t)}),M6=be("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=CB),Hn.init(e,t)}),P6=be("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=AB),Hn.init(e,t)}),U6=be("$ZodULID",(e,t)=>{t.pattern??(t.pattern=IB),Hn.init(e,t)}),z6=be("$ZodXID",(e,t)=>{t.pattern??(t.pattern=OB),Hn.init(e,t)}),F6=be("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=DB),Hn.init(e,t)}),B6=be("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=QB(t)),Hn.init(e,t)}),H6=be("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=qB),Hn.init(e,t)}),V6=be("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=JB(t)),Hn.init(e,t)}),G6=be("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=jB),Hn.init(e,t)}),W6=be("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=zB),Hn.init(e,t),e._zod.bag.format="ipv4"}),K6=be("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=FB),Hn.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})}}}),Z6=be("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=BB(t.delimiter)),Hn.init(e,t),e._zod.bag.format="mac"}),Y6=be("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=HB),Hn.init(e,t)}),q6=be("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=VB),Hn.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[a,i]=r;if(!i)throw new Error;const o=Number(i);if(`${o}`!==i)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${a}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function ET(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const X6=be("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=GB),Hn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ET(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function J6(e){if(!yT.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ET(n)}const Q6=be("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=yT),Hn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{J6(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),e5=be("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ZB),Hn.init(e,t)});function t5(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const a=JSON.parse(atob(r));return!("typ"in a&&a?.typ!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const n5=be("$ZodJWT",(e,t)=>{Hn.init(e,t),e._zod.check=n=>{t5(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),r5=be("$ZodCustomStringFormat",(e,t)=>{Hn.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})}}),_T=be("$ZodNumber",(e,t)=>{Ft.init(e,t),e._zod.pattern=e._zod.bag.pattern??r6,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const a=n.value;if(typeof a=="number"&&!Number.isNaN(a)&&Number.isFinite(a))return n;const i=typeof a=="number"?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:a,inst:e,...i?{received:i}:{}}),n}}),a5=be("$ZodNumberFormat",(e,t)=>{f6.init(e,t),_T.init(e,t)}),kT=be("$ZodBoolean",(e,t)=>{Ft.init(e,t),e._zod.pattern=a6,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),TT=be("$ZodBigInt",(e,t)=>{Ft.init(e,t),e._zod.pattern=t6,e._zod.parse=(n,r)=>{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}}),i5=be("$ZodBigIntFormat",(e,t)=>{p6.init(e,t),TT.init(e,t)}),o5=be("$ZodSymbol",(e,t)=>{Ft.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;return typeof a=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:a,inst:e}),n}}),s5=be("$ZodUndefined",(e,t)=>{Ft.init(e,t),e._zod.pattern=o6,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,r)=>{const a=n.value;return typeof a>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:a,inst:e}),n}}),l5=be("$ZodNull",(e,t)=>{Ft.init(e,t),e._zod.pattern=i6,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const a=n.value;return a===null||n.issues.push({expected:"null",code:"invalid_type",input:a,inst:e}),n}}),c5=be("$ZodAny",(e,t)=>{Ft.init(e,t),e._zod.parse=n=>n}),u5=be("$ZodUnknown",(e,t)=>{Ft.init(e,t),e._zod.parse=n=>n}),d5=be("$ZodNever",(e,t)=>{Ft.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),f5=be("$ZodVoid",(e,t)=>{Ft.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;return typeof a>"u"||n.issues.push({expected:"void",code:"invalid_type",input:a,inst:e}),n}}),p5=be("$ZodDate",(e,t)=>{Ft.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const a=n.value,i=a instanceof Date;return i&&!Number.isNaN(a.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:a,...i?{received:"Invalid Date"}:{},inst:e}),n}});function IP(e,t,n){e.issues.length&&t.issues.push(...Di(n,e.issues)),t.value[n]=e.value}const m5=be("$ZodArray",(e,t)=>{Ft.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.value=Array(a.length);const i=[];for(let o=0;o<a.length;o++){const l=a[o],u=t.element._zod.run({value:l,issues:[]},r);u instanceof Promise?i.push(u.then(d=>IP(d,n,o))):IP(u,n,o)}return i.length?Promise.all(i).then(()=>n):n}});function kv(e,t,n,r){e.issues.length&&t.issues.push(...Di(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function h5(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=dB(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function g5(e,t,n,r,a,i){const o=[],l=a.keySet,u=a.catchall._zod,d=u.def.type;for(const p in t){if(l.has(p))continue;if(d==="never"){o.push(p);continue}const h=u.run({value:t[p],issues:[]},r);h instanceof Promise?e.push(h.then(g=>kv(g,n,p,t))):kv(h,n,p,t)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const b5=be("$ZodObject",(e,t)=>{if(Ft.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...l};return Object.defineProperty(t,"shape",{value:u}),u}})}const r=Am(()=>h5(t));cn(e._zod,"propValues",()=>{const l=t.shape,u={};for(const d in l){const p=l[d]._zod;if(p.values){u[d]??(u[d]=new Set);for(const h of p.values)u[d].add(h)}}return u});const a=_d,i=t.catchall;let o;e._zod.parse=(l,u)=>{o??(o=r.value);const d=l.value;if(!a(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};const p=[],h=o.shape;for(const g of o.keys){const v=h[g]._zod.run({value:d[g],issues:[]},u);v instanceof Promise?p.push(v.then(x=>kv(x,l,g,d))):kv(v,l,g,d)}return i?g5(p,d,l,u,r.value,e):p.length?Promise.all(p).then(()=>l):l}}),v5=be("$ZodObjectJIT",(e,t)=>{b5.init(e,t);const n=e._zod.parse,r=Am(()=>h5(t)),a=g=>{const b=new C6(["shape","payload","ctx"]),v=r.value,x=k=>{const C=HE(k);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};b.write("const input = payload.value;");const S=Object.create(null);let _=0;for(const k of v.keys)S[k]=`key_${_++}`;b.write("const newResult = {};");for(const k of v.keys){const C=S[k],R=HE(k);b.write(`const ${C} = ${x(k)};`),b.write(`
|
|
@@ -32,7 +32,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
32
32
|
`;break;case"id":l=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?r(parseInt(S,10)):n(new hz(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:_}));break;default:n(new hz(`Unknown field "${x.length>20?`${x.slice(0,20)}…`:x}"`,{type:"unknown-field",field:x,value:S,line:_}));break}}function b(){u.length>0&&t({id:l,event:d||void 0,data:u.endsWith(`
|
|
33
33
|
`)?u.slice(0,-1):u}),l=void 0,u="",d=""}function v(x={}){i&&x.consume&&h(i),o=!0,l=void 0,u="",d="",i=""}return{feed:p,reset:v}}function Tle(e){const t=[];let n="",r=0;for(;r<e.length;){const a=e.indexOf("\r",r),i=e.indexOf(`
|
|
34
34
|
`,r);let o=-1;if(a!==-1&&i!==-1?o=Math.min(a,i):a!==-1?a===e.length-1?o=-1:o=a:i!==-1&&(o=i),o===-1){n=e.slice(r);break}else{const l=e.slice(r,o);t.push(l),r=o+1,e[r-1]==="\r"&&e[r]===`
|
|
35
|
-
`&&r++}}return[t,n]}class Nle extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let a;super({start(i){a=B9({onEvent:o=>{i.enqueue(o)},onError(o){t==="terminate"?i.error(o):typeof t=="function"&&t(o)},onRetry:n,onComment:r})},transform(i){a.feed(i)}})}}const Rle={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class zl extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class Cle{constructor(t,n){var r;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=R9(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(r=n?.reconnectionOptions)!==null&&r!==void 0?r:Rle}async _authThenStart(){var t;if(!this._authProvider)throw new di("No auth provider");let n;try{n=await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw(t=this.onerror)===null||t===void 0||t.call(this,r),r}if(n!=="AUTHORIZED")throw new di;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const n={};if(this._authProvider){const a=await this._authProvider.tokens();a&&(n.Authorization=`Bearer ${a.access_token}`)}this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const r=jv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...r})}async _startOrAuthSse(t){var n,r,a,i;const{resumptionToken:o}=t;try{const l=await this._commonHeaders();l.set("Accept","text/event-stream"),o&&l.set("last-event-id",o);const u=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,{method:"GET",headers:l,signal:(r=this._abortController)===null||r===void 0?void 0:r.signal});if(!u.ok){if(await((a=u.body)===null||a===void 0?void 0:a.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new zl(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(l){throw(i=this.onerror)===null||i===void 0||i.call(this,l),l}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(r,t),a)}_scheduleReconnection(t,n=0){var r;const a=this._reconnectionOptions.maxRetries;if(n>=a){(r=this.onerror)===null||r===void 0||r.call(this,new Error(`Maximum reconnection attempts (${a}) exceeded.`));return}const i=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(o=>{var l;(l=this.onerror)===null||l===void 0||l.call(this,new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(t,n+1)})},i)}_handleSseStream(t,n,r){if(!t)return;const{onresumptiontoken:a,replayMessageId:i}=n;let o,l=!1,u=!1;(async()=>{var p,h,g,b;try{const v=t.pipeThrough(new TextDecoderStream).pipeThrough(new Nle({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:E}=await v.read();if(E)break;if(_.id&&(o=_.id,l=!0,a?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const k=Yb.parse(JSON.parse(_.data));wp(k)&&(u=!0,i!==void 0&&(k.id=i)),(p=this.onmessage)===null||p===void 0||p.call(this,k)}catch(k){(h=this.onerror)===null||h===void 0||h.call(this,k)}}(r||l)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:o,onresumptiontoken:a,replayMessageId:i},0)}catch(v){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${v}`)),(r||l)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:o,onresumptiontoken:a,replayMessageId:i},0)}catch(_){(b=this.onerror)===null||b===void 0||b.call(this,new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new di("No auth provider");if(await Ho(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new di("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 r,a,i,o,l,u,d;try{const{resumptionToken:p,onresumptiontoken:h}=n||{};if(p){this._startOrAuthSse({resumptionToken:p,replayMessageId:XE(t)?t.id:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const b={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(t),signal:(r=this._abortController)===null||r===void 0?void 0:r.signal},v=await((a=this._fetch)!==null&&a!==void 0?a:fetch)(this._url,b),x=v.headers.get("mcp-session-id");if(x&&(this._sessionId=x),!v.ok){const k=await v.text().catch(()=>null);if(v.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new zl(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:C,scope:R}=rm(v);if(this._resourceMetadataUrl=C,this._scope=R,await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new di;return this._hasCompletedAuthFlow=!0,this.send(t)}if(v.status===403&&this._authProvider){const{resourceMetadataUrl:C,scope:R,error:A}=rm(v);if(A==="insufficient_scope"){const N=v.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===N)throw new zl(403,"Server returned 403 after trying upscoping");if(R&&(this._scope=R),C&&(this._resourceMetadataUrl=C),this._lastUpscopingHeader=N??void 0,await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new di;return this.send(t)}}throw new zl(v.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,v.status===202){await((i=v.body)===null||i===void 0?void 0:i.cancel()),yie(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const _=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,E=v.headers.get("content-type");if(_)if(E?.includes("text/event-stream"))this._handleSseStream(v.body,{onresumptiontoken:h},!1);else if(E?.includes("application/json")){const k=await v.json(),C=Array.isArray(k)?k.map(R=>Yb.parse(R)):[Yb.parse(k)];for(const R of C)(o=this.onmessage)===null||o===void 0||o.call(this,R)}else throw await((l=v.body)===null||l===void 0?void 0:l.cancel()),new zl(-1,`Unexpected content type: ${E}`);else await((u=v.body)===null||u===void 0?void 0:u.cancel())}catch(p){throw(d=this.onerror)===null||d===void 0||d.call(this,p),p}}get sessionId(){return this._sessionId}async terminateSession(){var t,n,r,a;if(this._sessionId)try{const i=await this._commonHeaders(),o={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},l=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,o);if(await((r=l.body)===null||r===void 0?void 0:r.cancel()),!l.ok&&l.status!==405)throw new zl(l.status,`Failed to terminate session: ${l.statusText}`);this._sessionId=void 0}catch(i){throw(a=this.onerror)===null||a===void 0||a.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 gz extends Event{constructor(t,n){var r,a;super(t),this.code=(r=n?.code)!=null?r:void 0,this.message=(a=n?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(bz(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(bz(this),n)}}function Ale(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function u_(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(u_).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${u_(e.cause)}`:e.message:`${e}`}function bz(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var H9=e=>{throw TypeError(e)},mR=(e,t,n)=>t.has(e)||H9("Cannot "+n),ln=(e,t,n)=>(mR(e,t,"read from private field"),n?n.call(e):t.get(e)),kr=(e,t,n)=>t.has(e)?H9("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Jn=(e,t,n,r)=>(mR(e,t,"write to private field"),t.set(e,n),n),Mo=(e,t,n)=>(mR(e,t,"access private method"),n),Ca,Bl,yu,Xb,zv,Lp,Au,jp,Bs,wu,Hu,Su,Sp,Ni,d_,f_,p_,vz,m_,h_,xp,g_,b_;class Jb extends EventTarget{constructor(t,n){var r,a;super(),kr(this,Ni),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,kr(this,Ca),kr(this,Bl),kr(this,yu),kr(this,Xb),kr(this,zv),kr(this,Lp),kr(this,Au),kr(this,jp,null),kr(this,Bs),kr(this,wu),kr(this,Hu,null),kr(this,Su,null),kr(this,Sp,null),kr(this,f_,async i=>{var o;ln(this,wu).reset();const{body:l,redirected:u,status:d,headers:p}=i;if(d===204){Mo(this,Ni,xp).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?Jn(this,yu,new URL(i.url)):Jn(this,yu,void 0),d!==200){Mo(this,Ni,xp).call(this,`Non-200 status code (${d})`,d);return}if(!(p.get("content-type")||"").startsWith("text/event-stream")){Mo(this,Ni,xp).call(this,'Invalid content type, expected "text/event-stream"',d);return}if(ln(this,Ca)===this.CLOSED)return;Jn(this,Ca,this.OPEN);const h=new Event("open");if((o=ln(this,Sp))==null||o.call(this,h),this.dispatchEvent(h),typeof l!="object"||!l||!("getReader"in l)){Mo(this,Ni,xp).call(this,"Invalid response body, expected a web ReadableStream",d),this.close();return}const g=new TextDecoder,b=l.getReader();let v=!0;do{const{done:x,value:S}=await b.read();S&&ln(this,wu).feed(g.decode(S,{stream:!x})),x&&(v=!1,ln(this,wu).reset(),Mo(this,Ni,g_).call(this))}while(v)}),kr(this,p_,i=>{Jn(this,Bs,void 0),!(i.name==="AbortError"||i.type==="aborted")&&Mo(this,Ni,g_).call(this,u_(i))}),kr(this,m_,i=>{typeof i.id=="string"&&Jn(this,jp,i.id);const o=new MessageEvent(i.event||"message",{data:i.data,origin:ln(this,yu)?ln(this,yu).origin:ln(this,Bl).origin,lastEventId:i.id||""});ln(this,Su)&&(!i.event||i.event==="message")&&ln(this,Su).call(this,o),this.dispatchEvent(o)}),kr(this,h_,i=>{Jn(this,Lp,i)}),kr(this,b_,()=>{Jn(this,Au,void 0),ln(this,Ca)===this.CONNECTING&&Mo(this,Ni,d_).call(this)});try{if(t instanceof URL)Jn(this,Bl,t);else if(typeof t=="string")Jn(this,Bl,new URL(t,Ile()));else throw new Error("Invalid URL")}catch{throw Ale("An invalid or illegal string was specified")}Jn(this,wu,B9({onEvent:ln(this,m_),onRetry:ln(this,h_)})),Jn(this,Ca,this.CONNECTING),Jn(this,Lp,3e3),Jn(this,zv,(r=n?.fetch)!=null?r:globalThis.fetch),Jn(this,Xb,(a=n?.withCredentials)!=null?a:!1),Mo(this,Ni,d_).call(this)}get readyState(){return ln(this,Ca)}get url(){return ln(this,Bl).href}get withCredentials(){return ln(this,Xb)}get onerror(){return ln(this,Hu)}set onerror(t){Jn(this,Hu,t)}get onmessage(){return ln(this,Su)}set onmessage(t){Jn(this,Su,t)}get onopen(){return ln(this,Sp)}set onopen(t){Jn(this,Sp,t)}addEventListener(t,n,r){const a=n;super.addEventListener(t,a,r)}removeEventListener(t,n,r){const a=n;super.removeEventListener(t,a,r)}close(){ln(this,Au)&&clearTimeout(ln(this,Au)),ln(this,Ca)!==this.CLOSED&&(ln(this,Bs)&&ln(this,Bs).abort(),Jn(this,Ca,this.CLOSED),Jn(this,Bs,void 0))}}Ca=new WeakMap,Bl=new WeakMap,yu=new WeakMap,Xb=new WeakMap,zv=new WeakMap,Lp=new WeakMap,Au=new WeakMap,jp=new WeakMap,Bs=new WeakMap,wu=new WeakMap,Hu=new WeakMap,Su=new WeakMap,Sp=new WeakMap,Ni=new WeakSet,d_=function(){Jn(this,Ca,this.CONNECTING),Jn(this,Bs,new AbortController),ln(this,zv)(ln(this,Bl),Mo(this,Ni,vz).call(this)).then(ln(this,f_)).catch(ln(this,p_))},f_=new WeakMap,p_=new WeakMap,vz=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...ln(this,jp)?{"Last-Event-ID":ln(this,jp)}:void 0},cache:"no-store",signal:(e=ln(this,Bs))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},m_=new WeakMap,h_=new WeakMap,xp=function(e,t){var n;ln(this,Ca)!==this.CLOSED&&Jn(this,Ca,this.CLOSED);const r=new gz("error",{code:t,message:e});(n=ln(this,Hu))==null||n.call(this,r),this.dispatchEvent(r)},g_=function(e,t){var n;if(ln(this,Ca)===this.CLOSED)return;Jn(this,Ca,this.CONNECTING);const r=new gz("error",{code:t,message:e});(n=ln(this,Hu))==null||n.call(this,r),this.dispatchEvent(r),Jn(this,Au,setTimeout(ln(this,b_),ln(this,Lp)))},b_=new WeakMap,Jb.CONNECTING=0,Jb.OPEN=1,Jb.CLOSED=2;function Ile(){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 Ole extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class Dle{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=R9(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new di("No auth provider");let n;try{n=await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw(t=this.onerror)===null||t===void 0||t.call(this,r),r}if(n!=="AUTHORIZED")throw new di;return await this._startOrAuth()}async _commonHeaders(){var t;const n={};if(this._authProvider){const a=await this._authProvider.tokens();a&&(n.Authorization=`Bearer ${a.access_token}`)}this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const r=jv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...r})}_startOrAuth(){var t,n,r;const a=(r=(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&&r!==void 0?r:fetch;return new Promise((i,o)=>{this._eventSource=new Jb(this._url.href,{...this._eventSourceInit,fetch:async(l,u)=>{const d=await this._commonHeaders();d.set("Accept","text/event-stream");const p=await a(l,{...u,headers:d});if(p.status===401&&p.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=rm(p);this._resourceMetadataUrl=h,this._scope=g}return p}}),this._abortController=new AbortController,this._eventSource.onerror=l=>{var u;if(l.code===401&&this._authProvider){this._authThenStart().then(i,o);return}const d=new Ole(l.code,l.message,l);o(d),(u=this.onerror)===null||u===void 0||u.call(this,d)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",l=>{var u;const d=l;try{if(this._endpoint=new URL(d.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(p){o(p),(u=this.onerror)===null||u===void 0||u.call(this,p),this.close();return}i()}),this._eventSource.onmessage=l=>{var u,d;const p=l;let h;try{h=Yb.parse(JSON.parse(p.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(d=this.onmessage)===null||d===void 0||d.call(this,h)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new di("No auth provider");if(await Ho(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new di("Failed to authorize")}async close(){var t,n,r;(t=this._abortController)===null||t===void 0||t.abort(),(n=this._eventSource)===null||n===void 0||n.close(),(r=this.onclose)===null||r===void 0||r.call(this)}async send(t){var n,r,a,i;if(!this._endpoint)throw new Error("Not connected");try{const o=await this._commonHeaders();o.set("content-type","application/json");const l={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},u=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._endpoint,l);if(!u.ok){const d=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:p,scope:h}=rm(u);if(this._resourceMetadataUrl=p,this._scope=h,await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new di;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${d}`)}await((a=u.body)===null||a===void 0?void 0:a.cancel())}catch(o){throw(i=this.onerror)===null||i===void 0||i.call(this,o),o}}setProtocolVersion(t){this._protocolVersion=t}}var bd,Lle=(bd=class{connector;autoConnect;constructor(t,n=!0){this.connector=t,this.autoConnect=n}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(t,n){t==="notification"&&this.connector.onNotification(n)}async setRoots(t){return this.connector.setRoots(t)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(t){return this.connector.listTools(t)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(t,n={},r){return this.connector.callTool(t,n,r)}async listResources(t,n){return this.connector.listResources(t,n)}async listAllResources(t){return this.connector.listAllResources(t)}async listResourceTemplates(t){return this.connector.listResourceTemplates(t)}async readResource(t,n){return this.connector.readResource(t,n)}async subscribeToResource(t,n){return this.connector.subscribeToResource(t,n)}async unsubscribeFromResource(t,n){return this.connector.unsubscribeFromResource(t,n)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(t,n){return this.connector.getPrompt(t,n)}async request(t,n=null,r){return this.connector.request(t,n,r)}},Ye(bd,"MCPSession"),bd),vd,jle=(vd=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,Qi.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Qi.getInstance().trackClientRemoveServer(t))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(t){return this.config.mcpServers?.[t]}getConfig(){return this.config??{}}async createSession(t,n=!0){const r=this.config.mcpServers??{};if(Object.keys(r).length===0&&Ce.warn("No MCP servers defined in config"),!r[t])throw new Error(`Server '${t}' not found in config`);const a=this.createConnectorFromConfig(r[t]),i=new Lle(a);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&&Ce.warn("No MCP servers defined in config");for(const r of Object.keys(n))await this.createSession(r,t);return this.sessions}getSession(t){const n=this.sessions[t];return n||null}requireSession(t){const n=this.sessions[t];if(!n)throw new Error(`Session '${t}' not found. Available sessions: ${this.activeSessions.join(", ")||"none"}`);return n}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){Ce.warn(`No session exists for server ${t}, nothing to close`);return}try{Ce.debug(`Closing session for server ${t}`),await n.disconnect()}catch(r){Ce.error(`Error closing session for server '${t}': ${r}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(r=>r!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const r of t)try{Ce.debug(`Closing session for server ${r}`),await this.closeSession(r)}catch(a){const i=`Failed to close session for server '${r}': ${a}`;Ce.error(i),n.push(i)}n.length?Ce.error(`Encountered ${n.length} errors while closing sessions`):Ce.debug("All sessions closed successfully")}},Ye(vd,"BaseMCPClient"),vd),yd,$le=(yd=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),Ce.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){Ce.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?Ce.debug(`${this.constructor.name} task aborted successfully`):Ce.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,Ce.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(){Ce.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),Ce.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,Ce.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){Ce.warn(`Error closing connection in ${this.constructor.name}: ${t}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((t,n)=>{if(!this._abortController)return;const r=this._abortController.signal;if(r.aborted){t();return}const a=Ye(()=>{r.removeEventListener("abort",a),t()},"onAbort");r.addEventListener("abort",a)})}},Ye(yd,"ConnectionManager"),yd),wd,Mle=(wd=class extends $le{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 Dle(this.url,this.opts),n=t.send.bind(t);return t.send=async r=>{const a=Ye(async i=>{if(Array.isArray(i))for(const o of i)await n(o);else await n(i)},"sendMessage");try{await a(r)}catch(i){if(i?.code===404&&t.sessionId&&!this.reinitializing){Ce.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),Ce.info("[SSE] Re-initialization successful, retrying request"),await a(r)}finally{this.reinitializing=!1}}else throw i}},this._transport=t,Ce.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){Ce.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){Ce.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},Ye(wd,"SseConnectionManager"),wd),Sd,Ple=(Sd=class extends joe{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;transportType=null;streamableTransport=null;constructor(t,n={}){super(n),this.baseUrl=t.replace(/\/$/,""),this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.timeout=n.timeout??3e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1}async connect(){if(this.connected){Ce.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){Ce.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}Ce.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{Ce.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),Ce.info("✅ Successfully connected via streamable HTTP")}catch(n){let r="Unknown error",a=!1;if(n instanceof zl){const i=n;a=i.code===401,i.code===400&&i.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Ce.warn(`⚠️ ${r}`)):i.code===404||i.code===405?(r=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,Ce.debug(r)):(r=`Server returned ${i.code}: ${i.message}`,Ce.debug(r))}else if(n instanceof Error){const i=n.toString(),o=n.message||"";a=i.includes("401")||o.includes("Unauthorized"),i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||o.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Ce.warn(`⚠️ ${r}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(r="Server doesn't support streamable HTTP (405/404)",Ce.debug(r)):(r=`Streamable HTTP failed: ${n.message}`,Ce.debug(r))}if(a){Ce.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}Ce.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if(Ce.error("Failed to connect with both transports:"),Ce.error(` Streamable HTTP: ${r}`),Ce.error(` SSE: ${i}`),await this.cleanupResources(),i?.message?.includes("401")||i?.message?.includes("Unauthorized")){const l=new Error("Authentication required");throw l.code=401,l}throw new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(t){try{const n=new Cle(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let r=n;if(this.opts.wrapTransport){const i=this.baseUrl;r=this.opts.wrapTransport(r,i)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};Ce.debug("Creating Client with capabilities:",JSON.stringify(a.capabilities,null,2)),this.client=new dz(this.clientInfo,a),this.setupRootsHandler(),Ce.debug("Roots handler registered before connect");try{await this.client.connect(r,{timeout:Math.min(this.timeout,3e3)});const i=n.sessionId;i?Ce.debug(`Session ID obtained: ${i}`):Ce.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(i){if(i instanceof Error){const o=i.message||i.toString();if(o.includes("Missing session ID")||o.includes("Bad Request: Missing session ID")||o.includes("Mcp-Session-Id header is required")){const l=new Error(`Session ID error: ${o}. The SDK should automatically extract session ID from initialize response.`);throw l.cause=i,l}}throw i}this.streamableTransport=n,this.connectionManager={stop:Ye(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){Ce.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(),Ce.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 Mle(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const a=this.baseUrl;n=this.opts.wrapTransport(n,a)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};Ce.debug("Creating Client with capabilities (SSE):",JSON.stringify(r.capabilities,null,2)),this.client=new dz(this.clientInfo,r),this.setupRootsHandler(),Ce.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),Ce.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}},Ye(Sd,"HttpConnector"),Sd),rc,Ule=(rc=class extends jle{static getPackageVersion(){return Sv()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Qi.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>Ce.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new rc(t)}createConnectorFromConfig(t){const{url:n,headers:r,authToken:a,authProvider:i,wrapTransport:o,clientOptions:l,samplingCallback:u,elicitationCallback:d}=t;if(!n)throw new Error("Server URL is required");const p={headers:r,authToken:a,authProvider:i,wrapTransport:o,clientOptions:l,samplingCallback:u,elicitationCallback:d};return l?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(l,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new Ple(n,p)}},Ye(rc,"BrowserMCPClient"),rc);function Iu(e){const t=Ye(()=>{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(V9).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}Ye(Iu,"sanitizeUrl");function V9([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}Ye(V9,"sanitizeParam");var xd,Qb=(xd=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=Iu(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 Iu(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(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,r),localStorage.removeItem(t);return}}async saveClientInformation(t){const n=this.getKey("client_info");localStorage.setItem(n,JSON.stringify(t))}async tokens(){const t=this.getKey("tokens"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,r),localStorage.removeItem(t);return}}async saveTokens(t){const n=this.getKey("tokens");localStorage.setItem(n,JSON.stringify(t)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(t){const n=this.getKey("code_verifier");localStorage.setItem(n,t)}async codeVerifier(){const t=this.getKey("code_verifier"),n=localStorage.getItem(t);if(!n)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${t}. Auth flow likely corrupted or timed out.`);return n}async prepareAuthorizationUrl(t){const n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,a={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:this.useRedirectFlow&&typeof window<"u"?window.location.href:void 0};localStorage.setItem(r,JSON.stringify(a)),t.searchParams.set("state",n);const i=t.toString(),o=Iu(i);return localStorage.setItem(this.getKey("last_auth_url"),o),o}async redirectToAuthorization(t){const n=await this.prepareAuthorizationUrl(t);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=n;return}const r="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const a=window.open(n,`mcp_auth_${this.serverUrlHash}`,r);this.onPopupWindow&&this.onPopupWindow(n,r,a),!a||a.closed||typeof a.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(a.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(a){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,a)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?Iu(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,r=[];let a=0;for(let o=0;o<localStorage.length;o++){const l=localStorage.key(o);if(l){if(l.startsWith(t))r.push(l);else if(l.startsWith(n))try{const u=localStorage.getItem(l);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&r.push(l)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${l} during clearStorage:`,u)}}}return[...new Set(r)].forEach(o=>{localStorage.removeItem(o),a++}),a}hashString(t){let n=0;for(let r=0;r<t.length;r++){const a=t.charCodeAt(r);n=(n<<5)-n+a,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},Ye(xd,"BrowserOAuthClientProvider"),xd);async function hR(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),r=e.get("error"),a=e.get("error_description"),i="[mcp-callback]";console.log(`${i} Handling callback...`,{code:t,state:n,error:r,errorDescription:a});let o=null,l=null;const u=n?`mcp:auth:state_${n}`:null;try{if(r)throw new Error(`OAuth error: ${r} - ${a||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!u)throw new Error("State parameter not found or invalid in callback query parameters.");const d=localStorage.getItem(u);if(!d)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{l=JSON.parse(d)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!l.expiry||l.expiry<Date.now())throw localStorage.removeItem(u),new Error("OAuth state has expired. Please try initiating authentication again.");if(!l.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:p,...h}=l.providerOptions;console.log(`${i} Re-instantiating provider for server: ${p}`),o=new Qb(p,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(p).origin,b=await Ho(o,{serverUrl:g,authorizationCode:t});if(b==="AUTHORIZED")if(console.log(`${i} Authorization successful via SDK auth().`),l.flowType==="redirect"&&l.returnUrl)console.log(`${i} Redirect flow complete. Returning to: ${l.returnUrl}`),localStorage.removeItem(u),window.location.href=l.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),S=x.length>0&&x[x.length-1]==="callback"?"/"+x.slice(0,-2).join("/"):"/";window.location.href=S||"/"}else throw console.warn(`${i} SDK auth() returned unexpected status: ${b}`),new Error(`Unexpected result from authentication library: ${b}`)}catch(d){console.error(`${i} Error during OAuth callback handling:`,d);const p=d instanceof Error?d.message:String(d);window.opener&&!window.opener.closed&&window.opener.postMessage({type:"mcp_auth_callback",success:!1,error:p},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 b=document.createElement("p");b.style.color="red",b.style.backgroundColor="#ffebeb",b.style.border="1px solid red",b.style.padding="10px",b.style.borderRadius="4px",b.textContent=p,h.appendChild(b);const v=document.createElement("p");v.textContent="You can close this window or ";const x=document.createElement("a");if(x.href="#",x.textContent="click here to close",x.onclick=S=>(S.preventDefault(),window.close(),!1),v.appendChild(x),v.appendChild(document.createTextNode(".")),h.appendChild(v),d instanceof Error&&d.stack){const S=document.createElement("pre");S.style.fontSize="0.8em",S.style.color="#555",S.style.marginTop="20px",S.style.whiteSpace="pre-wrap",S.textContent=d.stack,h.appendChild(S)}document.body.appendChild(h)}catch(h){console.error(`${i} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),o&&(localStorage.removeItem(o.getKey("code_verifier")),localStorage.removeItem(o.getKey("last_auth_url")))}}Ye(hR,"onMcpAuthorization");var jx={exports:{}},zt={};var yz;function zle(){if(yz)return zt;yz=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function b(L){return L===null||typeof L!="object"?null:(L=g&&L[g]||L["@@iterator"],typeof L=="function"?L:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,S={};function _(L,V,F){this.props=L,this.context=V,this.refs=S,this.updater=F||v}_.prototype.isReactComponent={},_.prototype.setState=function(L,V){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,V,"setState")},_.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function E(){}E.prototype=_.prototype;function k(L,V,F){this.props=L,this.context=V,this.refs=S,this.updater=F||v}var C=k.prototype=new E;C.constructor=k,x(C,_.prototype),C.isPureReactComponent=!0;var R=Array.isArray;function A(){}var N={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function $(L,V,F){var j=F.ref;return{$$typeof:e,type:L,key:V,ref:j!==void 0?j:null,props:F}}function M(L,V){return $(L.type,V,L.props)}function z(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function W(L){var V={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(F){return V[F]})}var J=/\/+/g;function X(L,V){return typeof L=="object"&&L!==null&&L.key!=null?W(""+L.key):V.toString(36)}function re(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(A,A):(L.status="pending",L.then(function(V){L.status==="pending"&&(L.status="fulfilled",L.value=V)},function(V){L.status==="pending"&&(L.status="rejected",L.reason=V)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function H(L,V,F,j,P){var B=typeof L;(B==="undefined"||B==="boolean")&&(L=null);var K=!1;if(L===null)K=!0;else switch(B){case"bigint":case"string":case"number":K=!0;break;case"object":switch(L.$$typeof){case e:case t:K=!0;break;case p:return K=L._init,H(K(L._payload),V,F,j,P)}}if(K)return P=P(L),K=j===""?"."+X(L,0):j,R(P)?(F="",K!=null&&(F=K.replace(J,"$&/")+"/"),H(P,V,F,"",function(ue){return ue})):P!=null&&(z(P)&&(P=M(P,F+(P.key==null||L&&L.key===P.key?"":(""+P.key).replace(J,"$&/")+"/")+K)),V.push(P)),1;K=0;var ee=j===""?".":j+":";if(R(L))for(var ie=0;ie<L.length;ie++)j=L[ie],B=ee+X(j,ie),K+=H(j,V,F,B,P);else if(ie=b(L),typeof ie=="function")for(L=ie.call(L),ie=0;!(j=L.next()).done;)j=j.value,B=ee+X(j,ie++),K+=H(j,V,F,B,P);else if(B==="object"){if(typeof L.then=="function")return H(re(L),V,F,j,P);throw V=String(L),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return K}function Z(L,V,F){if(L==null)return L;var j=[],P=0;return H(L,j,"","",function(B){return V.call(F,B,P++)}),j}function G(L){if(L._status===-1){var V=L._result;V=V(),V.then(function(F){(L._status===0||L._status===-1)&&(L._status=1,L._result=F)},function(F){(L._status===0||L._status===-1)&&(L._status=2,L._result=F)}),L._status===-1&&(L._status=0,L._result=V)}if(L._status===1)return L._result.default;throw L._result}var ae=typeof reportError=="function"?reportError:function(L){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof L=="object"&&L!==null&&typeof L.message=="string"?String(L.message):String(L),error:L});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",L);return}console.error(L)},ne={map:Z,forEach:function(L,V,F){Z(L,function(){V.apply(this,arguments)},F)},count:function(L){var V=0;return Z(L,function(){V++}),V},toArray:function(L){return Z(L,function(V){return V})||[]},only:function(L){if(!z(L))throw Error("React.Children.only expected to receive a single React element child.");return L}};return zt.Activity=h,zt.Children=ne,zt.Component=_,zt.Fragment=n,zt.Profiler=a,zt.PureComponent=k,zt.StrictMode=r,zt.Suspense=u,zt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,zt.__COMPILER_RUNTIME={__proto__:null,c:function(L){return N.H.useMemoCache(L)}},zt.cache=function(L){return function(){return L.apply(null,arguments)}},zt.cacheSignal=function(){return null},zt.cloneElement=function(L,V,F){if(L==null)throw Error("The argument must be a React element, but you passed "+L+".");var j=x({},L.props),P=L.key;if(V!=null)for(B in V.key!==void 0&&(P=""+V.key),V)!O.call(V,B)||B==="key"||B==="__self"||B==="__source"||B==="ref"&&V.ref===void 0||(j[B]=V[B]);var B=arguments.length-2;if(B===1)j.children=F;else if(1<B){for(var K=Array(B),ee=0;ee<B;ee++)K[ee]=arguments[ee+2];j.children=K}return $(L.type,P,j)},zt.createContext=function(L){return L={$$typeof:o,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null},L.Provider=L,L.Consumer={$$typeof:i,_context:L},L},zt.createElement=function(L,V,F){var j,P={},B=null;if(V!=null)for(j in V.key!==void 0&&(B=""+V.key),V)O.call(V,j)&&j!=="key"&&j!=="__self"&&j!=="__source"&&(P[j]=V[j]);var K=arguments.length-2;if(K===1)P.children=F;else if(1<K){for(var ee=Array(K),ie=0;ie<K;ie++)ee[ie]=arguments[ie+2];P.children=ee}if(L&&L.defaultProps)for(j in K=L.defaultProps,K)P[j]===void 0&&(P[j]=K[j]);return $(L,B,P)},zt.createRef=function(){return{current:null}},zt.forwardRef=function(L){return{$$typeof:l,render:L}},zt.isValidElement=z,zt.lazy=function(L){return{$$typeof:p,_payload:{_status:-1,_result:L},_init:G}},zt.memo=function(L,V){return{$$typeof:d,type:L,compare:V===void 0?null:V}},zt.startTransition=function(L){var V=N.T,F={};N.T=F;try{var j=L(),P=N.S;P!==null&&P(F,j),typeof j=="object"&&j!==null&&typeof j.then=="function"&&j.then(A,ae)}catch(B){ae(B)}finally{V!==null&&F.types!==null&&(V.types=F.types),N.T=V}},zt.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},zt.use=function(L){return N.H.use(L)},zt.useActionState=function(L,V,F){return N.H.useActionState(L,V,F)},zt.useCallback=function(L,V){return N.H.useCallback(L,V)},zt.useContext=function(L){return N.H.useContext(L)},zt.useDebugValue=function(){},zt.useDeferredValue=function(L,V){return N.H.useDeferredValue(L,V)},zt.useEffect=function(L,V){return N.H.useEffect(L,V)},zt.useEffectEvent=function(L){return N.H.useEffectEvent(L)},zt.useId=function(){return N.H.useId()},zt.useImperativeHandle=function(L,V,F){return N.H.useImperativeHandle(L,V,F)},zt.useInsertionEffect=function(L,V){return N.H.useInsertionEffect(L,V)},zt.useLayoutEffect=function(L,V){return N.H.useLayoutEffect(L,V)},zt.useMemo=function(L,V){return N.H.useMemo(L,V)},zt.useOptimistic=function(L,V){return N.H.useOptimistic(L,V)},zt.useReducer=function(L,V,F){return N.H.useReducer(L,V,F)},zt.useRef=function(L){return N.H.useRef(L)},zt.useState=function(L){return N.H.useState(L)},zt.useSyncExternalStore=function(L,V,F){return N.H.useSyncExternalStore(L,V,F)},zt.useTransition=function(){return N.H.useTransition()},zt.version="19.2.0",zt}var wz;function gR(){return wz||(wz=1,jx.exports=zle()),jx.exports}var y=gR();const de=Ay(y),Gd=ree({__proto__:null,default:de},[y]);function v_(e,t){if(!e)throw new Error(t)}Ye(v_,"assert");var Sz=3e3,Fle=5e3;function bR(e){const{url:t,enabled:n=!0,clientName:r,clientUri:a,callbackUrl:i=typeof window<"u"?Iu(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:o="mcp:auth",clientConfig:l={},customHeaders:u={},debug:d=!1,autoRetry:p=!1,autoReconnect:h=Sz,transportType:g="auto",preventAutoAuth:b=!1,useRedirectFlow:v=!1,onPopupWindow:x,timeout:S=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:C,onElicitation:R}=e,[A,N]=y.useState("discovering"),[O,$]=y.useState([]),[M,z]=y.useState([]),[W,J]=y.useState([]),[X,re]=y.useState([]),[H,Z]=y.useState(),[G,ae]=y.useState(),[ne,L]=y.useState(void 0),[V,F]=y.useState([]),[j,P]=y.useState(void 0),B=y.useRef(null),K=y.useRef(null),ee=y.useRef(!1),ie=y.useRef(!0),ue=y.useRef(0),Q=y.useRef(null),q=y.useRef(A),le=y.useRef(h),ve=y.useRef(null);y.useEffect(()=>{q.current=A,le.current=h},[A,h]);const oe=y.useCallback((He,Be,...Te)=>{const Pe=Te.length>0?`${Be} ${Te.map(Ve=>JSON.stringify(Ve)).join(" ")}`:Be;console[He](`[useMcp] ${Pe}`),ie.current&&F(Ve=>[...Ve.slice(-100),{level:He,message:Pe,timestamp:Date.now()}])},[]),Ae=y.useCallback(async(He=!1)=>{if(He||oe("info","Disconnecting..."),ee.current=!1,Q.current&&clearTimeout(Q.current),Q.current=null,B.current)try{const Be="inspector-server",Te=B.current.getSession(Be);Te&&Te._healthCheckCleanup&&(Te._healthCheckCleanup(),Te._healthCheckCleanup=null),await B.current.closeSession(Be)}catch(Be){He||oe("warn","Error closing session:",Be)}B.current=null,ie.current&&!He&&(N("discovering"),$([]),z([]),J([]),re([]),L(void 0),P(void 0))},[oe]),Je=y.useCallback((He,Be)=>{if(oe("error",He,Be??""),ie.current){N("failed"),L(He);const Te=K.current?.getLastAttemptedAuthUrl();Te&&(P(Te),oe("info","Manual authentication URL may be available.",Te))}ee.current=!1,t&&Qi.getInstance().trackUseMcpConnection({url:t,transportType:g,success:!1,errorType:Be?.name||"UnknownError",hasOAuth:!!K.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{})},[oe,t,g,C,R]),ke=y.useCallback(async()=>{if(!n||!t){oe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(ee.current){oe("debug","Connection attempt already in progress.");return}if(!ie.current){oe("debug","Connect called after unmount, aborting.");return}ee.current=!0,ue.current+=1,L(void 0),P(void 0),ve.current=null,N("discovering"),oe("info",`Connecting attempt #${ue.current} to ${t}...`),K.current||(K.current=new Qb(t,{storageKeyPrefix:o,clientName:r,clientUri:a,callbackUrl:i,preventAutoAuth:b,useRedirectFlow:v,onPopupWindow:x}),oe("debug","BrowserOAuthClientProvider initialized in connect.")),B.current||(B.current=new Ule,oe("debug","BrowserMCPClient initialized in connect."));const He=Ye(async(Te,Pe=!1)=>{oe("info",`Attempting connection with transport: ${Te}`);try{const Ve="inspector-server",Qe={url:t,transport:Te==="sse"?"http":Te};if(u&&Object.keys(u).length>0&&(Qe.headers=u),K.current){const it=await K.current.tokens();it?.access_token&&(Qe.headers={...Qe.headers,Authorization:`Bearer ${it.access_token}`})}B.current.addServer(Ve,{...Qe,authProvider:K.current,clientOptions:l,samplingCallback:C,elicitationCallback:R,wrapTransport:E?it=>(console.log("[useMcp] Applying transport wrapper for server:",Ve,"url:",t),E(it,t)):void 0});const ot=await B.current.createSession(Ve,!1);ot.on("notification",it=>{k?.(it),it.method==="notifications/tools/list_changed"?(oe("info","Tools list changed, auto-refreshing..."),gt().catch(kt=>oe("warn","Auto-refresh tools failed:",kt))):it.method==="notifications/resources/list_changed"?(oe("info","Resources list changed, auto-refreshing..."),wt().catch(kt=>oe("warn","Auto-refresh resources failed:",kt))):it.method==="notifications/prompts/list_changed"&&(oe("info","Prompts list changed, auto-refreshing..."),Tt().catch(kt=>oe("warn","Auto-refresh prompts failed:",kt)))}),await ot.initialize(),oe("info","✅ Successfully connected to MCP server"),oe("info","Server info:",ot.connector.serverInfo),oe("info","Server capabilities:",ot.connector.serverCapabilities),console.log("[useMcp] Server info:",ot.connector.serverInfo),console.log("[useMcp] Server capabilities:",ot.connector.serverCapabilities),N("ready"),ve.current=Te;const $t=Ye(()=>{let it=null,kt=Date.now();const Mt=1e4,nr=3e4;return it=setInterval(Ye(async()=>{if(!ie.current||q.current!=="ready"){it&&(clearInterval(it),it=null);return}try{await ot.connector.listTools(),kt=Date.now()}catch{const se=Date.now()-kt;se>nr&&(oe("warn",`Connection appears to be broken (no response for ${Math.round(se/1e3)}s), attempting to reconnect...`),it&&(clearInterval(it),it=null),le.current&&ie.current&&(N("discovering"),oe("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{ie.current&&q.current==="discovering"&&ke()},typeof le.current=="number"?le.current:Sz)))}},"checkConnectionHealth"),Mt),()=>{it&&(clearInterval(it),it=null)}},"setupConnectionMonitoring");if(h){const it=$t();ot._healthCheckCleanup=it}Qi.getInstance().trackUseMcpConnection({url:t,transportType:Te,success:!0,hasOAuth:!!K.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{}),$(ot.connector.tools||[]);const Rt=await ot.connector.listAllResources();z(Rt.resources||[]);const Xt=await ot.connector.listPrompts();re(Xt.prompts||[]);const un=ot.connector.serverInfo,at=ot.connector.serverCapabilities;return un&&(console.log("[useMcp] Server info:",un),Z(un)),at&&(console.log("[useMcp] Server capabilities:",at),ae(at)),"success"}catch(Ve){const Qe=Ve,ot=Qe?.message||String(Ve);if(Qe.code===401||ot.includes("401")||ot.includes("Unauthorized")){if(K.current){oe("info","Authentication required. OAuth provider available.");try{const{auth:$t}=await pr(async()=>{const{auth:Xt}=await Promise.resolve().then(()=>mz);return{auth:Xt}},void 0),Rt=new URL(t).origin;$t(K.current,{serverUrl:Rt}).catch(()=>{}),setTimeout(()=>{if(ie.current){const Xt=K.current?.getLastAttemptedAuthUrl();Xt?(P(Xt),oe("info","Manual authentication URL available:",Xt)):oe("warn","Could not generate authentication URL")}},100)}catch($t){oe("warn","Error generating auth URL:",$t)}return ie.current&&N("pending_auth"),ee.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(Je("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Je("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Je(ot,Qe instanceof Error?Qe:new Error(String(Qe))),"failed"}},"tryConnectWithTransport");let Be="failed";if(g==="sse")oe("debug","Using SSE-only transport mode"),Be=await He("sse");else if(g==="http")oe("debug","Using HTTP-only transport mode"),Be=await He("http");else{oe("debug","Using auto transport mode (HTTP with SSE fallback)");const Te=await He("http");Te==="fallback"&&ie.current&&q.current!=="authenticating"?(oe("info","HTTP failed, attempting SSE fallback..."),Be=await He("sse")):Be=Te}(Be==="success"||Be==="failed"||Be==="auth_redirect")&&(ee.current=!1),oe("debug",`Connection sequence finished with status: ${Be}`)},[oe,Je,Ae,t,o,r,a,i,l.name,l.version,u,g,b,v,x,n,S,_]),Re=y.useCallback(async(He,Be,Te)=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot call tool "${He}".`);oe("info",`Calling tool: ${He}`,Be);const Pe=Date.now();try{const Qe=B.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const ot=await Qe.connector.callTool(He,Be||{},Te);return oe("info",`Tool "${He}" call successful:`,ot),Qi.getInstance().trackUseMcpToolCall({toolName:He,success:!0,executionTimeMs:Date.now()-Pe}).catch(()=>{}),ot}catch(Ve){throw oe("error",`Tool "${He}" call failed:`,Ve),Qi.getInstance().trackUseMcpToolCall({toolName:He,success:!1,errorType:Ve instanceof Error?Ve.name:"UnknownError",executionTimeMs:Date.now()-Pe}).catch(()=>{}),Ve}},[A]),Ze=y.useCallback(()=>{q.current==="failed"?(oe("info","Retry requested..."),ke()):oe("warn",`Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`)},[oe,ke]),me=y.useCallback(async()=>{oe("info","Manual authentication requested...");const He=q.current;if(He==="failed")oe("info","Attempting to reconnect and authenticate via retry..."),Ze();else if(He==="pending_auth"){oe("info","Proceeding with authentication from pending state...");try{v_(K.current,"Auth Provider not available for manual auth"),v_(t,"Server URL is required for authentication"),oe("info","Clearing all OAuth state and initiating fresh flow...");const Be=`${o}:${K.current.serverUrlHash}`;Object.keys(localStorage).forEach(Qe=>{Qe.startsWith(Be)&&(oe("debug",`Removing stale OAuth key: ${Qe}`),localStorage.removeItem(Qe)),Qe.startsWith(`${o}:state_`)&&(oe("debug",`Removing orphaned state: ${Qe}`),localStorage.removeItem(Qe))}),N("authenticating");const Te=new Qb(t,{storageKeyPrefix:o,clientName:r,clientUri:a,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:v,onPopupWindow:x});K.current=Te,oe("info","Triggering fresh OAuth authorization...");const{auth:Pe}=await pr(async()=>{const{auth:Qe}=await Promise.resolve().then(()=>mz);return{auth:Qe}},void 0),Ve=new URL(t).origin;Pe(Te,{serverUrl:Ve}).catch(Qe=>{oe("info","OAuth flow initiated:",Qe instanceof Error?Qe.message:"Redirecting...")})}catch(Be){if(!ie.current)return;N("pending_auth"),oe("error",`Manual authentication failed: ${Be instanceof Error?Be.message:String(Be)}`)}}else if(He==="authenticating"){oe("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Be=K.current?.getLastAttemptedAuthUrl();Be&&!j&&(P(Be),oe("info","Manual authentication URL retrieved:",Be))}else oe("info",`Client not in a state requiring manual authentication trigger (state: ${He}). If needed, try disconnecting and reconnecting.`)},[oe,Ze,j,t,v,x,o,r,a,i]),Le=y.useCallback(()=>{if(K.current){const He=K.current.clearStorage();oe("info",`Cleared ${He} item(s) from localStorage for ${t}.`),P(void 0),Ae()}else oe("warn","Auth provider not initialized, cannot clear storage.")},[t,oe,Ae]),Ke=y.useCallback(async()=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list resources.`);oe("info","Listing resources");try{const Be=B.current.getSession("inspector-server");if(!Be)throw new Error("No active session found");const Te=await Be.connector.listAllResources();z(Te.resources||[]),oe("info","Resources listed successfully")}catch(He){throw oe("error","List resources failed:",He),He}},[A]),_e=y.useCallback(async He=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot read resource.`);oe("info",`Reading resource: ${He}`);try{const Te=B.current.getSession("inspector-server");if(!Te)throw new Error("No active session found");const Pe=await Te.connector.readResource(He);return oe("info","Resource read successful:",Pe),Qi.getInstance().trackUseMcpResourceRead({resourceUri:He,success:!0}).catch(()=>{}),Pe}catch(Be){throw oe("error","Resource read failed:",Be),Qi.getInstance().trackUseMcpResourceRead({resourceUri:He,success:!1,errorType:Be instanceof Error?Be.name:"UnknownError"}).catch(()=>{}),Be}},[A]),vt=y.useCallback(async()=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list prompts.`);oe("info","Listing prompts");try{const Be=B.current.getSession("inspector-server");if(!Be)throw new Error("No active session found");const Te=await Be.connector.listPrompts();re(Te.prompts||[]),oe("info","Prompts listed successfully")}catch(He){throw oe("error","List prompts failed:",He),He}},[A]),gt=y.useCallback(async()=>{if(q.current!=="ready"||!B.current){oe("debug","Cannot refresh tools - client not ready");return}oe("debug","Refreshing tools list");try{const Be=B.current.getSession("inspector-server");if(!Be){oe("warn","No active session found for tools refresh");return}const Te=await Be.connector.listTools();$(Te||[]),oe("info","Tools list refreshed successfully")}catch(He){oe("warn","Failed to refresh tools:",He)}},[oe]),wt=y.useCallback(async()=>{if(q.current!=="ready"||!B.current){oe("debug","Cannot refresh resources - client not ready");return}oe("debug","Refreshing resources list");try{const Be=B.current.getSession("inspector-server");if(!Be){oe("warn","No active session found for resources refresh");return}const Te=await Be.connector.listAllResources();z(Te.resources||[]),oe("info","Resources list refreshed successfully")}catch(He){oe("warn","Failed to refresh resources:",He)}},[oe]),Tt=y.useCallback(async()=>{if(q.current!=="ready"||!B.current){oe("debug","Cannot refresh prompts - client not ready");return}oe("debug","Refreshing prompts list");try{const Be=B.current.getSession("inspector-server");if(!Be){oe("warn","No active session found for prompts refresh");return}const Te=await Be.connector.listPrompts();re(Te.prompts||[]),oe("info","Prompts list refreshed successfully")}catch(He){oe("warn","Failed to refresh prompts:",He)}},[oe]),At=y.useCallback(async()=>{oe("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([gt(),wt(),Tt()])},[gt,wt,Tt,oe]),Cn=y.useCallback(async(He,Be)=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot get prompt.`);oe("info",`Getting prompt: ${He}`,Be);try{const Pe=B.current.getSession("inspector-server");if(!Pe)throw new Error("No active session found");const Ve=await Pe.connector.getPrompt(He,Be||{});return oe("info",`Prompt "${He}" retrieved successfully:`,Ve),Ve}catch(Te){throw oe("error",`Prompt "${He}" retrieval failed:`,Te),Te}},[A]),mr=y.useRef(ke),Ut=y.useRef(Je);return y.useEffect(()=>{mr.current=ke,Ut.current=Je}),y.useEffect(()=>{const He=Ye(Be=>{Be.origin===window.location.origin&&Be.data?.type==="mcp_auth_callback"&&(oe("info","Received auth callback message.",Be.data),Q.current&&clearTimeout(Q.current),Q.current=null,Be.data.success?(oe("info","Authentication successful via popup. Reconnecting client..."),ee.current&&oe("debug","Connection attempt already in progress, resetting flag to allow reconnection."),ee.current=!1,setTimeout(()=>{ie.current&&(oe("debug","Initiating reconnection after successful auth callback."),mr.current())},100)):Ut.current(`Authentication failed in callback: ${Be.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",He),oe("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",He),oe("debug","Auth callback message listener removed."),Q.current&&clearTimeout(Q.current)}},[oe]),y.useEffect(()=>(ie.current=!0,!n||!t?(oe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),N("discovering"),()=>{ie.current=!1}):(oe("debug","useMcp mounted, initiating connection."),ue.current=0,(!K.current||K.current.serverUrl!==t)&&(K.current=new Qb(t,{storageKeyPrefix:o,clientName:r,clientUri:a,callbackUrl:i,preventAutoAuth:b,useRedirectFlow:v,onPopupWindow:x}),oe("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),ke(),()=>{ie.current=!1,oe("debug","useMcp unmounting, disconnecting."),Ae(!0)})),[t,n,o,i,r,a,l.name,l.version,v]),y.useEffect(()=>{let He=null;if(A==="failed"&&p&&ue.current>0){const Be=typeof p=="number"?p:Fle;oe("info",`Connection failed, auto-retrying in ${Be}ms...`),He=setTimeout(()=>{ie.current&&q.current==="failed"&&Ze()},Be)}return()=>{He&&clearTimeout(He)}},[A,p,Ze,oe]),{state:A,tools:O,resources:M,resourceTemplates:W,prompts:X,serverInfo:H,capabilities:G,error:ne,log:V,authUrl:j,client:B.current,callTool:Re,readResource:_e,listResources:Ke,listPrompts:vt,getPrompt:Cn,refreshTools:gt,refreshResources:wt,refreshPrompts:Tt,refreshAll:At,retry:Ze,disconnect:Ae,authenticate:me,clearStorage:Le}}Ye(bR,"useMcp");var Ed,Ble=(Ed=class extends de.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?de.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"},de.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),de.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},Ye(Ed,"ErrorBoundary"),Ed),$p="openai:set_globals";function Ti(e){return y.useSyncExternalStore(t=>{const n=Ye(r=>{r.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener($p,n),()=>{typeof window<"u"&&window.removeEventListener($p,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}Ye(Ti,"useOpenAiGlobal");function Wd(e){const[t,n]=y.useState(()=>typeof window<"u"&&!!window.openai);y.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const M=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(M))},100),z=Ye(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(M))},"handleSetGlobals");typeof window<"u"&&window.addEventListener($p,z);const W=setTimeout(()=>{clearInterval(M),typeof window<"u"&&window.removeEventListener($p,z)},5e3);return()=>{clearInterval(M),clearTimeout(W),typeof window<"u"&&window.removeEventListener($p,z)}},[]);const r=y.useMemo(()=>t?"openai":"mcp-ui",[t]),a=typeof window<"u"?window.location.search:"",i=y.useMemo(()=>{const M=new URLSearchParams(a);return M.has("mcpUseParams")?JSON.parse(M.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[a]),o=r==="openai"?Ti("toolInput"):i.toolInput,l=r==="openai"?Ti("toolOutput"):i.toolOutput,u=Ti("toolResponseMetadata"),d=y.useMemo(()=>{if(u&&typeof u=="object"){const M=u["mcp-use/props"];if(M)return M}return e||{}},[u,e]),p=Ti("widgetState"),h=Ti("theme"),g=Ti("displayMode"),b=Ti("safeArea"),v=Ti("maxHeight"),x=Ti("userAgent"),S=Ti("locale"),_=y.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[E,k]=y.useState(null);y.useEffect(()=>{p!==void 0&&k(p)},[p]);const C=y.useCallback(async(M,z)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(M,z)},[]),R=y.useCallback(async M=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:M})},[]),A=y.useCallback(M=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:M})},[]),N=y.useCallback(async M=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:M})},[]),O=y.useCallback(async M=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const W=typeof M=="function"?M(p!==void 0?p:E):M;return k(W),window.openai.setWidgetState(W)},[p,E]),$=y.useMemo(()=>r==="openai"&&u===null,[r,u]);return{props:d,toolInput:o||{},output:l??null,metadata:u??null,state:E,setState:O,theme:h||"light",displayMode:g||"inline",safeArea:b||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:v||600,userAgent:x||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:S||"en",mcp_url:_,callTool:C,sendFollowUpMessage:R,openExternal:A,requestDisplayMode:N,isAvailable:t,isPending:$}}Ye(Wd,"useWidget");function Hle(e){const{props:t}=Wd(e);return t}Ye(Hle,"useWidgetProps");function Vle(){const{theme:e}=Wd();return e}Ye(Vle,"useWidgetTheme");function Gle(e){const{state:t,setState:n}=Wd();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Ye(Gle,"useWidgetState");var xz=Ye(({children:e})=>{const{theme:t,isAvailable:n}=Wd();console.log("theme",t);const[r,a]=y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");y.useEffect(()=>{if(typeof window>"u")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),l=Ye(u=>{a(u.matches?"dark":"light")},"handleChange");return o.addEventListener("change",l),()=>o.removeEventListener("change",l)},[]);const i=n?t:r;return y.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),de.createElement(de.Fragment,null,e)},"ThemeProvider");function G9({children:e,className:t="",position:n="top-right",attachTo:r,showLabels:a=!0,debugger:i=!1,viewControls:o=!1}){const{props:l,output:u,metadata:d,state:p,theme:h,displayMode:g,safeArea:b,maxHeight:v,userAgent:x,locale:S,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:C,requestDisplayMode:R,setState:A}=Wd(),[N,O]=y.useState(!1),[$,M]=y.useState(!1),z=y.useRef(null),W=y.useRef(null),[J,X]=y.useState([]),[re,H]=y.useState(""),[Z,G]=y.useState("get-my-city"),[ae,ne]=y.useState("{}"),[L,V]=y.useState("Test follow-up message"),[F,j]=y.useState("https://docs.mcp-use.com"),P=g==="fullscreen"&&_,B=g==="pip"&&_,K=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const _e=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const vt=Object.keys(window.openai);X(vt)}catch{X([])}else X([])},100);return()=>{clearTimeout(_e)}},[]);const ee=h==="dark",ie=Ye(()=>{const _e=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",N?"opacity-100":"opacity-0",N?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[..._e,"top-4","left-4"];case"top-center":return[..._e,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[..._e,"top-4","right-4"];case"center-left":return[..._e,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[..._e,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[..._e,"bottom-4","left-4"];case"bottom-center":return[..._e,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[..._e,"bottom-4","right-4"];default:return[..._e,"top-4","right-4"]}},"getPositionClasses"),ue=Ye(()=>{const vt=b?.insets?.top?Math.max(16,b.insets.top+8):16,gt=b?.insets?.right?Math.max(16,b.insets.right+8):16,wt=b?.insets?.bottom?Math.max(16,b.insets.bottom+8):16,Tt=b?.insets?.left?Math.max(16,b.insets.left+8):16,At={};switch(n){case"top-left":At.top=`${vt}px`,At.left=`${Tt}px`;break;case"top-center":At.top=`${vt}px`;break;case"top-right":At.top=`${vt}px`,At.right=`${gt}px`;break;case"center-left":At.left=`${Tt}px`;break;case"center-right":At.right=`${gt}px`;break;case"bottom-left":At.bottom=`${wt}px`,At.left=`${Tt}px`;break;case"bottom-center":At.bottom=`${wt}px`;break;case"bottom-right":At.bottom=`${wt}px`,At.right=`${gt}px`;break;default:At.top=`${vt}px`,At.right=`${gt}px`;break}return At},"getPositionOffsetStyles");y.useEffect(()=>{if(!r)return;const _e=Ye(()=>O(!0),"handleMouseEnter"),vt=Ye(()=>O(!1),"handleMouseLeave");return r.addEventListener("mouseenter",_e),r.addEventListener("mouseleave",vt),()=>{r.removeEventListener("mouseenter",_e),r.removeEventListener("mouseleave",vt)}},[r]),y.useEffect(()=>{if(!$)return;const _e=Ye(vt=>{W.current&&!W.current.contains(vt.target)&&M(!1)},"handleClickOutside");return document.addEventListener("mousedown",_e),()=>{document.removeEventListener("mousedown",_e)}},[$]),y.useEffect(()=>($?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[$]);const Q=Ye(()=>{M(!$)},"handleToggleOverlay"),q=Ye(async()=>{try{H("Calling tool...");const _e=ae.trim()?JSON.parse(ae):{},vt=await E(Z,_e);H(`Success: ${JSON.stringify(vt,null,2)}`)}catch(_e){H(`Error: ${_e.message}`)}},"handleCallTool"),le=Ye(async()=>{try{H("Sending follow-up message..."),await k(L),H("Follow-up message sent successfully")}catch(_e){H(`Error: ${_e.message}`)}},"handleSendFollowUpMessage"),ve=Ye(()=>{try{C(F),H(`Opened external link: ${F}`)}catch(_e){H(`Error: ${_e.message}`)}},"handleOpenExternal"),oe=Ye(async _e=>{try{H(`Requesting display mode: ${_e}...`);const vt=await R(_e);H(`Display mode granted: ${vt.mode}`)}catch(vt){H(`Error: ${vt.message}`)}},"handleRequestDisplayMode"),Ae=Ye(async()=>{try{const _e=p?{...p,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};H("Setting state..."),await A(_e),H(`State updated: ${JSON.stringify(_e,null,2)}`)}catch(_e){H(`Error: ${_e.message}`)}},"handleSetState"),Je=Ye(async()=>{try{await R("fullscreen")}catch(_e){console.error("Failed to go fullscreen:",_e)}},"handleFullscreen"),ke=Ye(async()=>{try{await R("pip")}catch(_e){console.error("Failed to go pip:",_e)}},"handlePip"),Re=Ye(()=>{const _e=["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[..._e,"top-full","right-0","mt-2"];case"top-left":return[..._e,"top-full","left-0","mt-2"];case"top-center":return[..._e,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[..._e,"bottom-full","right-0","mb-2"];case"bottom-left":return[..._e,"bottom-full","left-0","mb-2"];case"bottom-center":return[..._e,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[..._e,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[..._e,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[..._e,"top-full","right-0","mt-2"]}},"getTooltipClasses"),Ze=Ye(({onClick:_e,label:vt,children:gt})=>{const[wt,Tt]=y.useState(!1),At=Re();return de.createElement("button",{className:`p-2 ${ee?"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 ${ee?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Tt(!0),onMouseLeave:()=>Tt(!1),onClick:_e,"aria-label":vt},de.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"},gt),a&&de.createElement("span",{className:`${At.join(" ")} ${wt?"opacity-100":"opacity-0"}`},vt))},"IconButton"),me=Ye(_e=>{if(_e===null)return"null";if(_e===void 0)return"undefined";if(typeof _e=="object")try{return JSON.stringify(_e,null,2)}catch{return String(_e)}return String(_e)},"formatValue"),Le=Ye(_e=>_e?`${_e.device?.type||"unknown"}`:"N/A","formatUserAgent"),Ke=Ye(_e=>{if(!_e?.insets)return"N/A";const{top:vt,bottom:gt,left:wt,right:Tt}=_e.insets;return`T:${vt} B:${gt} L:${wt} R:${Tt}`},"formatSafeArea");return de.createElement(de.Fragment,null,de.createElement("div",{ref:z,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&O(!0),onMouseLeave:()=>!r&&O(!1)},de.createElement("div",{className:ie().join(" "),style:ue()},!K&&de.createElement(de.Fragment,null,!P&&!B&&de.createElement(de.Fragment,null,(o===!0||o==="fullscreen")&&de.createElement(Ze,{onClick:Je,label:"Fullscreen"},de.createElement("path",{d:"M15 3h6v6"}),de.createElement("path",{d:"m21 3-7 7"}),de.createElement("path",{d:"m3 21 7-7"}),de.createElement("path",{d:"M9 21H3v-6"})),(o===!0||o==="pip")&&de.createElement(Ze,{onClick:ke,label:"Picture in Picture"},de.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),de.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&de.createElement(Ze,{onClick:Q,label:"Debug Info"},de.createElement("path",{d:"M12 20v-9"}),de.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),de.createElement("path",{d:"M14.12 3.88 16 2"}),de.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),de.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),de.createElement("path",{d:"M22 13h-4"}),de.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),de.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),de.createElement("path",{d:"M6 13H2"}),de.createElement("path",{d:"m8 2 1.88 1.88"}),de.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),$&&i&&de.createElement("div",{ref:W,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:_e=>{_e.target===W.current&&M(!1)}},de.createElement("button",{onClick:()=>M(!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"},"×"),de.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},de.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),de.createElement("table",{className:"w-full border-collapse border-spacing-0"},de.createElement("tbody",null,de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),de.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},me(l))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),de.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},me(u))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),de.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},me(d))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),de.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},me(p))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),de.createElement("td",{className:"p-2"},h)),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),de.createElement("td",{className:"p-2"},g)),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),de.createElement("td",{className:"p-2"},S)),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),de.createElement("td",{className:"p-2"},v,"px")),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),de.createElement("td",{className:"p-2"},Le(x))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),de.createElement("td",{className:"p-2"},Ke(b))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),de.createElement("td",{className:"p-2"},_?"Yes":"No")),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),de.createElement("td",{className:"p-2"},J.length>0?J.join(", "):"N/A")))),de.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),de.createElement("div",{className:"flex flex-col gap-3"},de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("input",{type:"text",value:Z,onChange:_e=>G(_e.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]"}),de.createElement("input",{type:"text",value:ae,onChange:_e=>ne(_e.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"}),de.createElement("button",{onClick:q,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("input",{type:"text",value:L,onChange:_e=>V(_e.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"}),de.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")),de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("input",{type:"text",value:F,onChange:_e=>j(_e.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"}),de.createElement("button",{onClick:ve,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),de.createElement("button",{onClick:()=>oe("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"),de.createElement("button",{onClick:()=>oe("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"),de.createElement("button",{onClick:()=>oe("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")),de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("button",{onClick:Ae,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Set State (Add Timestamp)")),re&&de.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"},de.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),re,de.createElement("button",{onClick:()=>H(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}Ye(G9,"WidgetControls");function W9(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Ye(W9,"getBasename");var Wle=150,Kle=5;function Zle({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!1}){const a=W9(),i=y.useRef(null),o=y.useRef(0),l=y.useRef(null),u=y.useRef(!1),[d,p]=y.useState(null),[h,g]=y.useState(null),[b,v]=y.useState(!0);y.useEffect(()=>{let E=!0;return(async()=>{try{const k=await pr(()=>import("./index-BW8kJiKz.js"),[]);E&&(p(()=>k.BrowserRouter),v(!1))}catch{E&&(g(new Error(`❌ react-router not installed!
|
|
35
|
+
`&&r++}}return[t,n]}class Nle extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let a;super({start(i){a=B9({onEvent:o=>{i.enqueue(o)},onError(o){t==="terminate"?i.error(o):typeof t=="function"&&t(o)},onRetry:n,onComment:r})},transform(i){a.feed(i)}})}}const Rle={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class zl extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class Cle{constructor(t,n){var r;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=R9(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(r=n?.reconnectionOptions)!==null&&r!==void 0?r:Rle}async _authThenStart(){var t;if(!this._authProvider)throw new di("No auth provider");let n;try{n=await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw(t=this.onerror)===null||t===void 0||t.call(this,r),r}if(n!=="AUTHORIZED")throw new di;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const n={};if(this._authProvider){const a=await this._authProvider.tokens();a&&(n.Authorization=`Bearer ${a.access_token}`)}this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const r=jv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...r})}async _startOrAuthSse(t){var n,r,a,i;const{resumptionToken:o}=t;try{const l=await this._commonHeaders();l.set("Accept","text/event-stream"),o&&l.set("last-event-id",o);const u=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,{method:"GET",headers:l,signal:(r=this._abortController)===null||r===void 0?void 0:r.signal});if(!u.ok){if(await((a=u.body)===null||a===void 0?void 0:a.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new zl(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(l){throw(i=this.onerror)===null||i===void 0||i.call(this,l),l}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(r,t),a)}_scheduleReconnection(t,n=0){var r;const a=this._reconnectionOptions.maxRetries;if(n>=a){(r=this.onerror)===null||r===void 0||r.call(this,new Error(`Maximum reconnection attempts (${a}) exceeded.`));return}const i=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(o=>{var l;(l=this.onerror)===null||l===void 0||l.call(this,new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(t,n+1)})},i)}_handleSseStream(t,n,r){if(!t)return;const{onresumptiontoken:a,replayMessageId:i}=n;let o,l=!1,u=!1;(async()=>{var p,h,g,b;try{const v=t.pipeThrough(new TextDecoderStream).pipeThrough(new Nle({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:E}=await v.read();if(E)break;if(_.id&&(o=_.id,l=!0,a?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const k=Yb.parse(JSON.parse(_.data));wp(k)&&(u=!0,i!==void 0&&(k.id=i)),(p=this.onmessage)===null||p===void 0||p.call(this,k)}catch(k){(h=this.onerror)===null||h===void 0||h.call(this,k)}}(r||l)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:o,onresumptiontoken:a,replayMessageId:i},0)}catch(v){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${v}`)),(r||l)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:o,onresumptiontoken:a,replayMessageId:i},0)}catch(_){(b=this.onerror)===null||b===void 0||b.call(this,new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new di("No auth provider");if(await Ho(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new di("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 r,a,i,o,l,u,d;try{const{resumptionToken:p,onresumptiontoken:h}=n||{};if(p){this._startOrAuthSse({resumptionToken:p,replayMessageId:XE(t)?t.id:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const b={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(t),signal:(r=this._abortController)===null||r===void 0?void 0:r.signal},v=await((a=this._fetch)!==null&&a!==void 0?a:fetch)(this._url,b),x=v.headers.get("mcp-session-id");if(x&&(this._sessionId=x),!v.ok){const k=await v.text().catch(()=>null);if(v.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new zl(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:C,scope:R}=rm(v);if(this._resourceMetadataUrl=C,this._scope=R,await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new di;return this._hasCompletedAuthFlow=!0,this.send(t)}if(v.status===403&&this._authProvider){const{resourceMetadataUrl:C,scope:R,error:A}=rm(v);if(A==="insufficient_scope"){const N=v.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===N)throw new zl(403,"Server returned 403 after trying upscoping");if(R&&(this._scope=R),C&&(this._resourceMetadataUrl=C),this._lastUpscopingHeader=N??void 0,await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new di;return this.send(t)}}throw new zl(v.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,v.status===202){await((i=v.body)===null||i===void 0?void 0:i.cancel()),yie(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const _=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,E=v.headers.get("content-type");if(_)if(E?.includes("text/event-stream"))this._handleSseStream(v.body,{onresumptiontoken:h},!1);else if(E?.includes("application/json")){const k=await v.json(),C=Array.isArray(k)?k.map(R=>Yb.parse(R)):[Yb.parse(k)];for(const R of C)(o=this.onmessage)===null||o===void 0||o.call(this,R)}else throw await((l=v.body)===null||l===void 0?void 0:l.cancel()),new zl(-1,`Unexpected content type: ${E}`);else await((u=v.body)===null||u===void 0?void 0:u.cancel())}catch(p){throw(d=this.onerror)===null||d===void 0||d.call(this,p),p}}get sessionId(){return this._sessionId}async terminateSession(){var t,n,r,a;if(this._sessionId)try{const i=await this._commonHeaders(),o={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},l=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,o);if(await((r=l.body)===null||r===void 0?void 0:r.cancel()),!l.ok&&l.status!==405)throw new zl(l.status,`Failed to terminate session: ${l.statusText}`);this._sessionId=void 0}catch(i){throw(a=this.onerror)===null||a===void 0||a.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 gz extends Event{constructor(t,n){var r,a;super(t),this.code=(r=n?.code)!=null?r:void 0,this.message=(a=n?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(bz(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(bz(this),n)}}function Ale(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function u_(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(u_).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${u_(e.cause)}`:e.message:`${e}`}function bz(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var H9=e=>{throw TypeError(e)},mR=(e,t,n)=>t.has(e)||H9("Cannot "+n),ln=(e,t,n)=>(mR(e,t,"read from private field"),n?n.call(e):t.get(e)),kr=(e,t,n)=>t.has(e)?H9("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Jn=(e,t,n,r)=>(mR(e,t,"write to private field"),t.set(e,n),n),Mo=(e,t,n)=>(mR(e,t,"access private method"),n),Ca,Bl,yu,Xb,zv,Lp,Au,jp,Bs,wu,Hu,Su,Sp,Ni,d_,f_,p_,vz,m_,h_,xp,g_,b_;class Jb extends EventTarget{constructor(t,n){var r,a;super(),kr(this,Ni),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,kr(this,Ca),kr(this,Bl),kr(this,yu),kr(this,Xb),kr(this,zv),kr(this,Lp),kr(this,Au),kr(this,jp,null),kr(this,Bs),kr(this,wu),kr(this,Hu,null),kr(this,Su,null),kr(this,Sp,null),kr(this,f_,async i=>{var o;ln(this,wu).reset();const{body:l,redirected:u,status:d,headers:p}=i;if(d===204){Mo(this,Ni,xp).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?Jn(this,yu,new URL(i.url)):Jn(this,yu,void 0),d!==200){Mo(this,Ni,xp).call(this,`Non-200 status code (${d})`,d);return}if(!(p.get("content-type")||"").startsWith("text/event-stream")){Mo(this,Ni,xp).call(this,'Invalid content type, expected "text/event-stream"',d);return}if(ln(this,Ca)===this.CLOSED)return;Jn(this,Ca,this.OPEN);const h=new Event("open");if((o=ln(this,Sp))==null||o.call(this,h),this.dispatchEvent(h),typeof l!="object"||!l||!("getReader"in l)){Mo(this,Ni,xp).call(this,"Invalid response body, expected a web ReadableStream",d),this.close();return}const g=new TextDecoder,b=l.getReader();let v=!0;do{const{done:x,value:S}=await b.read();S&&ln(this,wu).feed(g.decode(S,{stream:!x})),x&&(v=!1,ln(this,wu).reset(),Mo(this,Ni,g_).call(this))}while(v)}),kr(this,p_,i=>{Jn(this,Bs,void 0),!(i.name==="AbortError"||i.type==="aborted")&&Mo(this,Ni,g_).call(this,u_(i))}),kr(this,m_,i=>{typeof i.id=="string"&&Jn(this,jp,i.id);const o=new MessageEvent(i.event||"message",{data:i.data,origin:ln(this,yu)?ln(this,yu).origin:ln(this,Bl).origin,lastEventId:i.id||""});ln(this,Su)&&(!i.event||i.event==="message")&&ln(this,Su).call(this,o),this.dispatchEvent(o)}),kr(this,h_,i=>{Jn(this,Lp,i)}),kr(this,b_,()=>{Jn(this,Au,void 0),ln(this,Ca)===this.CONNECTING&&Mo(this,Ni,d_).call(this)});try{if(t instanceof URL)Jn(this,Bl,t);else if(typeof t=="string")Jn(this,Bl,new URL(t,Ile()));else throw new Error("Invalid URL")}catch{throw Ale("An invalid or illegal string was specified")}Jn(this,wu,B9({onEvent:ln(this,m_),onRetry:ln(this,h_)})),Jn(this,Ca,this.CONNECTING),Jn(this,Lp,3e3),Jn(this,zv,(r=n?.fetch)!=null?r:globalThis.fetch),Jn(this,Xb,(a=n?.withCredentials)!=null?a:!1),Mo(this,Ni,d_).call(this)}get readyState(){return ln(this,Ca)}get url(){return ln(this,Bl).href}get withCredentials(){return ln(this,Xb)}get onerror(){return ln(this,Hu)}set onerror(t){Jn(this,Hu,t)}get onmessage(){return ln(this,Su)}set onmessage(t){Jn(this,Su,t)}get onopen(){return ln(this,Sp)}set onopen(t){Jn(this,Sp,t)}addEventListener(t,n,r){const a=n;super.addEventListener(t,a,r)}removeEventListener(t,n,r){const a=n;super.removeEventListener(t,a,r)}close(){ln(this,Au)&&clearTimeout(ln(this,Au)),ln(this,Ca)!==this.CLOSED&&(ln(this,Bs)&&ln(this,Bs).abort(),Jn(this,Ca,this.CLOSED),Jn(this,Bs,void 0))}}Ca=new WeakMap,Bl=new WeakMap,yu=new WeakMap,Xb=new WeakMap,zv=new WeakMap,Lp=new WeakMap,Au=new WeakMap,jp=new WeakMap,Bs=new WeakMap,wu=new WeakMap,Hu=new WeakMap,Su=new WeakMap,Sp=new WeakMap,Ni=new WeakSet,d_=function(){Jn(this,Ca,this.CONNECTING),Jn(this,Bs,new AbortController),ln(this,zv)(ln(this,Bl),Mo(this,Ni,vz).call(this)).then(ln(this,f_)).catch(ln(this,p_))},f_=new WeakMap,p_=new WeakMap,vz=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...ln(this,jp)?{"Last-Event-ID":ln(this,jp)}:void 0},cache:"no-store",signal:(e=ln(this,Bs))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},m_=new WeakMap,h_=new WeakMap,xp=function(e,t){var n;ln(this,Ca)!==this.CLOSED&&Jn(this,Ca,this.CLOSED);const r=new gz("error",{code:t,message:e});(n=ln(this,Hu))==null||n.call(this,r),this.dispatchEvent(r)},g_=function(e,t){var n;if(ln(this,Ca)===this.CLOSED)return;Jn(this,Ca,this.CONNECTING);const r=new gz("error",{code:t,message:e});(n=ln(this,Hu))==null||n.call(this,r),this.dispatchEvent(r),Jn(this,Au,setTimeout(ln(this,b_),ln(this,Lp)))},b_=new WeakMap,Jb.CONNECTING=0,Jb.OPEN=1,Jb.CLOSED=2;function Ile(){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 Ole extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class Dle{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=R9(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new di("No auth provider");let n;try{n=await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw(t=this.onerror)===null||t===void 0||t.call(this,r),r}if(n!=="AUTHORIZED")throw new di;return await this._startOrAuth()}async _commonHeaders(){var t;const n={};if(this._authProvider){const a=await this._authProvider.tokens();a&&(n.Authorization=`Bearer ${a.access_token}`)}this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const r=jv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...r})}_startOrAuth(){var t,n,r;const a=(r=(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&&r!==void 0?r:fetch;return new Promise((i,o)=>{this._eventSource=new Jb(this._url.href,{...this._eventSourceInit,fetch:async(l,u)=>{const d=await this._commonHeaders();d.set("Accept","text/event-stream");const p=await a(l,{...u,headers:d});if(p.status===401&&p.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=rm(p);this._resourceMetadataUrl=h,this._scope=g}return p}}),this._abortController=new AbortController,this._eventSource.onerror=l=>{var u;if(l.code===401&&this._authProvider){this._authThenStart().then(i,o);return}const d=new Ole(l.code,l.message,l);o(d),(u=this.onerror)===null||u===void 0||u.call(this,d)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",l=>{var u;const d=l;try{if(this._endpoint=new URL(d.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(p){o(p),(u=this.onerror)===null||u===void 0||u.call(this,p),this.close();return}i()}),this._eventSource.onmessage=l=>{var u,d;const p=l;let h;try{h=Yb.parse(JSON.parse(p.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(d=this.onmessage)===null||d===void 0||d.call(this,h)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new di("No auth provider");if(await Ho(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new di("Failed to authorize")}async close(){var t,n,r;(t=this._abortController)===null||t===void 0||t.abort(),(n=this._eventSource)===null||n===void 0||n.close(),(r=this.onclose)===null||r===void 0||r.call(this)}async send(t){var n,r,a,i;if(!this._endpoint)throw new Error("Not connected");try{const o=await this._commonHeaders();o.set("content-type","application/json");const l={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},u=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._endpoint,l);if(!u.ok){const d=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:p,scope:h}=rm(u);if(this._resourceMetadataUrl=p,this._scope=h,await Ho(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new di;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${d}`)}await((a=u.body)===null||a===void 0?void 0:a.cancel())}catch(o){throw(i=this.onerror)===null||i===void 0||i.call(this,o),o}}setProtocolVersion(t){this._protocolVersion=t}}var bd,Lle=(bd=class{connector;autoConnect;constructor(t,n=!0){this.connector=t,this.autoConnect=n}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(t,n){t==="notification"&&this.connector.onNotification(n)}async setRoots(t){return this.connector.setRoots(t)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(t){return this.connector.listTools(t)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(t,n={},r){return this.connector.callTool(t,n,r)}async listResources(t,n){return this.connector.listResources(t,n)}async listAllResources(t){return this.connector.listAllResources(t)}async listResourceTemplates(t){return this.connector.listResourceTemplates(t)}async readResource(t,n){return this.connector.readResource(t,n)}async subscribeToResource(t,n){return this.connector.subscribeToResource(t,n)}async unsubscribeFromResource(t,n){return this.connector.unsubscribeFromResource(t,n)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(t,n){return this.connector.getPrompt(t,n)}async request(t,n=null,r){return this.connector.request(t,n,r)}},Ye(bd,"MCPSession"),bd),vd,jle=(vd=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,Qi.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Qi.getInstance().trackClientRemoveServer(t))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(t){return this.config.mcpServers?.[t]}getConfig(){return this.config??{}}async createSession(t,n=!0){const r=this.config.mcpServers??{};if(Object.keys(r).length===0&&Ce.warn("No MCP servers defined in config"),!r[t])throw new Error(`Server '${t}' not found in config`);const a=this.createConnectorFromConfig(r[t]),i=new Lle(a);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&&Ce.warn("No MCP servers defined in config");for(const r of Object.keys(n))await this.createSession(r,t);return this.sessions}getSession(t){const n=this.sessions[t];return n||null}requireSession(t){const n=this.sessions[t];if(!n)throw new Error(`Session '${t}' not found. Available sessions: ${this.activeSessions.join(", ")||"none"}`);return n}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){Ce.warn(`No session exists for server ${t}, nothing to close`);return}try{Ce.debug(`Closing session for server ${t}`),await n.disconnect()}catch(r){Ce.error(`Error closing session for server '${t}': ${r}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(r=>r!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const r of t)try{Ce.debug(`Closing session for server ${r}`),await this.closeSession(r)}catch(a){const i=`Failed to close session for server '${r}': ${a}`;Ce.error(i),n.push(i)}n.length?Ce.error(`Encountered ${n.length} errors while closing sessions`):Ce.debug("All sessions closed successfully")}},Ye(vd,"BaseMCPClient"),vd),yd,$le=(yd=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),Ce.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){Ce.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?Ce.debug(`${this.constructor.name} task aborted successfully`):Ce.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,Ce.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(){Ce.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),Ce.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,Ce.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){Ce.warn(`Error closing connection in ${this.constructor.name}: ${t}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((t,n)=>{if(!this._abortController)return;const r=this._abortController.signal;if(r.aborted){t();return}const a=Ye(()=>{r.removeEventListener("abort",a),t()},"onAbort");r.addEventListener("abort",a)})}},Ye(yd,"ConnectionManager"),yd),wd,Mle=(wd=class extends $le{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 Dle(this.url,this.opts),n=t.send.bind(t);return t.send=async r=>{const a=Ye(async i=>{if(Array.isArray(i))for(const o of i)await n(o);else await n(i)},"sendMessage");try{await a(r)}catch(i){if(i?.code===404&&t.sessionId&&!this.reinitializing){Ce.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),Ce.info("[SSE] Re-initialization successful, retrying request"),await a(r)}finally{this.reinitializing=!1}}else throw i}},this._transport=t,Ce.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){Ce.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){Ce.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},Ye(wd,"SseConnectionManager"),wd),Sd,Ple=(Sd=class extends joe{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;transportType=null;streamableTransport=null;constructor(t,n={}){super(n),this.baseUrl=t.replace(/\/$/,""),this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.timeout=n.timeout??3e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1}async connect(){if(this.connected){Ce.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){Ce.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}Ce.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{Ce.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),Ce.info("✅ Successfully connected via streamable HTTP")}catch(n){let r="Unknown error",a=!1;if(n instanceof zl){const i=n;a=i.code===401,i.code===400&&i.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Ce.warn(`⚠️ ${r}`)):i.code===404||i.code===405?(r=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,Ce.debug(r)):(r=`Server returned ${i.code}: ${i.message}`,Ce.debug(r))}else if(n instanceof Error){const i=n.toString(),o=n.message||"";a=i.includes("401")||o.includes("Unauthorized"),i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||o.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Ce.warn(`⚠️ ${r}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(r="Server doesn't support streamable HTTP (405/404)",Ce.debug(r)):(r=`Streamable HTTP failed: ${n.message}`,Ce.debug(r))}if(a){Ce.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}Ce.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if(Ce.error("Failed to connect with both transports:"),Ce.error(` Streamable HTTP: ${r}`),Ce.error(` SSE: ${i}`),await this.cleanupResources(),i?.message?.includes("401")||i?.message?.includes("Unauthorized")){const l=new Error("Authentication required");throw l.code=401,l}throw new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(t){try{const n=new Cle(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let r=n;if(this.opts.wrapTransport){const i=this.baseUrl;r=this.opts.wrapTransport(r,i)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};Ce.debug("Creating Client with capabilities:",JSON.stringify(a.capabilities,null,2)),this.client=new dz(this.clientInfo,a),this.setupRootsHandler(),Ce.debug("Roots handler registered before connect");try{await this.client.connect(r,{timeout:Math.min(this.timeout,3e3)});const i=n.sessionId;i?Ce.debug(`Session ID obtained: ${i}`):Ce.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(i){if(i instanceof Error){const o=i.message||i.toString();if(o.includes("Missing session ID")||o.includes("Bad Request: Missing session ID")||o.includes("Mcp-Session-Id header is required")){const l=new Error(`Session ID error: ${o}. The SDK should automatically extract session ID from initialize response.`);throw l.cause=i,l}}throw i}this.streamableTransport=n,this.connectionManager={stop:Ye(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){Ce.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(),Ce.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 Mle(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const a=this.baseUrl;n=this.opts.wrapTransport(n,a)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};Ce.debug("Creating Client with capabilities (SSE):",JSON.stringify(r.capabilities,null,2)),this.client=new dz(this.clientInfo,r),this.setupRootsHandler(),Ce.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),Ce.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}},Ye(Sd,"HttpConnector"),Sd),rc,Ule=(rc=class extends jle{static getPackageVersion(){return Sv()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Qi.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>Ce.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new rc(t)}createConnectorFromConfig(t){const{url:n,headers:r,authToken:a,authProvider:i,wrapTransport:o,clientOptions:l,samplingCallback:u,elicitationCallback:d}=t;if(!n)throw new Error("Server URL is required");const p={headers:r,authToken:a,authProvider:i,wrapTransport:o,clientOptions:l,samplingCallback:u,elicitationCallback:d};return l?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(l,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new Ple(n,p)}},Ye(rc,"BrowserMCPClient"),rc);function Iu(e){const t=Ye(()=>{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(V9).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}Ye(Iu,"sanitizeUrl");function V9([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}Ye(V9,"sanitizeParam");var xd,Qb=(xd=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=Iu(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 Iu(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(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,r),localStorage.removeItem(t);return}}async saveClientInformation(t){const n=this.getKey("client_info");localStorage.setItem(n,JSON.stringify(t))}async tokens(){const t=this.getKey("tokens"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,r),localStorage.removeItem(t);return}}async saveTokens(t){const n=this.getKey("tokens");localStorage.setItem(n,JSON.stringify(t)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(t){const n=this.getKey("code_verifier");localStorage.setItem(n,t)}async codeVerifier(){const t=this.getKey("code_verifier"),n=localStorage.getItem(t);if(!n)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${t}. Auth flow likely corrupted or timed out.`);return n}async prepareAuthorizationUrl(t){const n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,a={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:this.useRedirectFlow&&typeof window<"u"?window.location.href:void 0};localStorage.setItem(r,JSON.stringify(a)),t.searchParams.set("state",n);const i=t.toString(),o=Iu(i);return localStorage.setItem(this.getKey("last_auth_url"),o),o}async redirectToAuthorization(t){const n=await this.prepareAuthorizationUrl(t);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=n;return}const r="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const a=window.open(n,`mcp_auth_${this.serverUrlHash}`,r);this.onPopupWindow&&this.onPopupWindow(n,r,a),!a||a.closed||typeof a.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(a.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(a){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,a)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?Iu(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,r=[];let a=0;for(let o=0;o<localStorage.length;o++){const l=localStorage.key(o);if(l){if(l.startsWith(t))r.push(l);else if(l.startsWith(n))try{const u=localStorage.getItem(l);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&r.push(l)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${l} during clearStorage:`,u)}}}return[...new Set(r)].forEach(o=>{localStorage.removeItem(o),a++}),a}hashString(t){let n=0;for(let r=0;r<t.length;r++){const a=t.charCodeAt(r);n=(n<<5)-n+a,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},Ye(xd,"BrowserOAuthClientProvider"),xd);async function hR(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),r=e.get("error"),a=e.get("error_description"),i="[mcp-callback]";console.log(`${i} Handling callback...`,{code:t,state:n,error:r,errorDescription:a});let o=null,l=null;const u=n?`mcp:auth:state_${n}`:null;try{if(r)throw new Error(`OAuth error: ${r} - ${a||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!u)throw new Error("State parameter not found or invalid in callback query parameters.");const d=localStorage.getItem(u);if(!d)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{l=JSON.parse(d)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!l.expiry||l.expiry<Date.now())throw localStorage.removeItem(u),new Error("OAuth state has expired. Please try initiating authentication again.");if(!l.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:p,...h}=l.providerOptions;console.log(`${i} Re-instantiating provider for server: ${p}`),o=new Qb(p,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(p).origin,b=await Ho(o,{serverUrl:g,authorizationCode:t});if(b==="AUTHORIZED")if(console.log(`${i} Authorization successful via SDK auth().`),l.flowType==="redirect"&&l.returnUrl)console.log(`${i} Redirect flow complete. Returning to: ${l.returnUrl}`),localStorage.removeItem(u),window.location.href=l.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),S=x.length>0&&x[x.length-1]==="callback"?"/"+x.slice(0,-2).join("/"):"/";window.location.href=S||"/"}else throw console.warn(`${i} SDK auth() returned unexpected status: ${b}`),new Error(`Unexpected result from authentication library: ${b}`)}catch(d){console.error(`${i} Error during OAuth callback handling:`,d);const p=d instanceof Error?d.message:String(d);window.opener&&!window.opener.closed&&window.opener.postMessage({type:"mcp_auth_callback",success:!1,error:p},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 b=document.createElement("p");b.style.color="red",b.style.backgroundColor="#ffebeb",b.style.border="1px solid red",b.style.padding="10px",b.style.borderRadius="4px",b.textContent=p,h.appendChild(b);const v=document.createElement("p");v.textContent="You can close this window or ";const x=document.createElement("a");if(x.href="#",x.textContent="click here to close",x.onclick=S=>(S.preventDefault(),window.close(),!1),v.appendChild(x),v.appendChild(document.createTextNode(".")),h.appendChild(v),d instanceof Error&&d.stack){const S=document.createElement("pre");S.style.fontSize="0.8em",S.style.color="#555",S.style.marginTop="20px",S.style.whiteSpace="pre-wrap",S.textContent=d.stack,h.appendChild(S)}document.body.appendChild(h)}catch(h){console.error(`${i} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),o&&(localStorage.removeItem(o.getKey("code_verifier")),localStorage.removeItem(o.getKey("last_auth_url")))}}Ye(hR,"onMcpAuthorization");var jx={exports:{}},zt={};var yz;function zle(){if(yz)return zt;yz=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function b(L){return L===null||typeof L!="object"?null:(L=g&&L[g]||L["@@iterator"],typeof L=="function"?L:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,S={};function _(L,V,F){this.props=L,this.context=V,this.refs=S,this.updater=F||v}_.prototype.isReactComponent={},_.prototype.setState=function(L,V){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,V,"setState")},_.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function E(){}E.prototype=_.prototype;function k(L,V,F){this.props=L,this.context=V,this.refs=S,this.updater=F||v}var C=k.prototype=new E;C.constructor=k,x(C,_.prototype),C.isPureReactComponent=!0;var R=Array.isArray;function A(){}var N={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function $(L,V,F){var j=F.ref;return{$$typeof:e,type:L,key:V,ref:j!==void 0?j:null,props:F}}function M(L,V){return $(L.type,V,L.props)}function z(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function W(L){var V={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(F){return V[F]})}var J=/\/+/g;function X(L,V){return typeof L=="object"&&L!==null&&L.key!=null?W(""+L.key):V.toString(36)}function re(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(A,A):(L.status="pending",L.then(function(V){L.status==="pending"&&(L.status="fulfilled",L.value=V)},function(V){L.status==="pending"&&(L.status="rejected",L.reason=V)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function H(L,V,F,j,P){var B=typeof L;(B==="undefined"||B==="boolean")&&(L=null);var K=!1;if(L===null)K=!0;else switch(B){case"bigint":case"string":case"number":K=!0;break;case"object":switch(L.$$typeof){case e:case t:K=!0;break;case p:return K=L._init,H(K(L._payload),V,F,j,P)}}if(K)return P=P(L),K=j===""?"."+X(L,0):j,R(P)?(F="",K!=null&&(F=K.replace(J,"$&/")+"/"),H(P,V,F,"",function(ue){return ue})):P!=null&&(z(P)&&(P=M(P,F+(P.key==null||L&&L.key===P.key?"":(""+P.key).replace(J,"$&/")+"/")+K)),V.push(P)),1;K=0;var ee=j===""?".":j+":";if(R(L))for(var ie=0;ie<L.length;ie++)j=L[ie],B=ee+X(j,ie),K+=H(j,V,F,B,P);else if(ie=b(L),typeof ie=="function")for(L=ie.call(L),ie=0;!(j=L.next()).done;)j=j.value,B=ee+X(j,ie++),K+=H(j,V,F,B,P);else if(B==="object"){if(typeof L.then=="function")return H(re(L),V,F,j,P);throw V=String(L),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return K}function Z(L,V,F){if(L==null)return L;var j=[],P=0;return H(L,j,"","",function(B){return V.call(F,B,P++)}),j}function G(L){if(L._status===-1){var V=L._result;V=V(),V.then(function(F){(L._status===0||L._status===-1)&&(L._status=1,L._result=F)},function(F){(L._status===0||L._status===-1)&&(L._status=2,L._result=F)}),L._status===-1&&(L._status=0,L._result=V)}if(L._status===1)return L._result.default;throw L._result}var ae=typeof reportError=="function"?reportError:function(L){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof L=="object"&&L!==null&&typeof L.message=="string"?String(L.message):String(L),error:L});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",L);return}console.error(L)},ne={map:Z,forEach:function(L,V,F){Z(L,function(){V.apply(this,arguments)},F)},count:function(L){var V=0;return Z(L,function(){V++}),V},toArray:function(L){return Z(L,function(V){return V})||[]},only:function(L){if(!z(L))throw Error("React.Children.only expected to receive a single React element child.");return L}};return zt.Activity=h,zt.Children=ne,zt.Component=_,zt.Fragment=n,zt.Profiler=a,zt.PureComponent=k,zt.StrictMode=r,zt.Suspense=u,zt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=N,zt.__COMPILER_RUNTIME={__proto__:null,c:function(L){return N.H.useMemoCache(L)}},zt.cache=function(L){return function(){return L.apply(null,arguments)}},zt.cacheSignal=function(){return null},zt.cloneElement=function(L,V,F){if(L==null)throw Error("The argument must be a React element, but you passed "+L+".");var j=x({},L.props),P=L.key;if(V!=null)for(B in V.key!==void 0&&(P=""+V.key),V)!O.call(V,B)||B==="key"||B==="__self"||B==="__source"||B==="ref"&&V.ref===void 0||(j[B]=V[B]);var B=arguments.length-2;if(B===1)j.children=F;else if(1<B){for(var K=Array(B),ee=0;ee<B;ee++)K[ee]=arguments[ee+2];j.children=K}return $(L.type,P,j)},zt.createContext=function(L){return L={$$typeof:o,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null},L.Provider=L,L.Consumer={$$typeof:i,_context:L},L},zt.createElement=function(L,V,F){var j,P={},B=null;if(V!=null)for(j in V.key!==void 0&&(B=""+V.key),V)O.call(V,j)&&j!=="key"&&j!=="__self"&&j!=="__source"&&(P[j]=V[j]);var K=arguments.length-2;if(K===1)P.children=F;else if(1<K){for(var ee=Array(K),ie=0;ie<K;ie++)ee[ie]=arguments[ie+2];P.children=ee}if(L&&L.defaultProps)for(j in K=L.defaultProps,K)P[j]===void 0&&(P[j]=K[j]);return $(L,B,P)},zt.createRef=function(){return{current:null}},zt.forwardRef=function(L){return{$$typeof:l,render:L}},zt.isValidElement=z,zt.lazy=function(L){return{$$typeof:p,_payload:{_status:-1,_result:L},_init:G}},zt.memo=function(L,V){return{$$typeof:d,type:L,compare:V===void 0?null:V}},zt.startTransition=function(L){var V=N.T,F={};N.T=F;try{var j=L(),P=N.S;P!==null&&P(F,j),typeof j=="object"&&j!==null&&typeof j.then=="function"&&j.then(A,ae)}catch(B){ae(B)}finally{V!==null&&F.types!==null&&(V.types=F.types),N.T=V}},zt.unstable_useCacheRefresh=function(){return N.H.useCacheRefresh()},zt.use=function(L){return N.H.use(L)},zt.useActionState=function(L,V,F){return N.H.useActionState(L,V,F)},zt.useCallback=function(L,V){return N.H.useCallback(L,V)},zt.useContext=function(L){return N.H.useContext(L)},zt.useDebugValue=function(){},zt.useDeferredValue=function(L,V){return N.H.useDeferredValue(L,V)},zt.useEffect=function(L,V){return N.H.useEffect(L,V)},zt.useEffectEvent=function(L){return N.H.useEffectEvent(L)},zt.useId=function(){return N.H.useId()},zt.useImperativeHandle=function(L,V,F){return N.H.useImperativeHandle(L,V,F)},zt.useInsertionEffect=function(L,V){return N.H.useInsertionEffect(L,V)},zt.useLayoutEffect=function(L,V){return N.H.useLayoutEffect(L,V)},zt.useMemo=function(L,V){return N.H.useMemo(L,V)},zt.useOptimistic=function(L,V){return N.H.useOptimistic(L,V)},zt.useReducer=function(L,V,F){return N.H.useReducer(L,V,F)},zt.useRef=function(L){return N.H.useRef(L)},zt.useState=function(L){return N.H.useState(L)},zt.useSyncExternalStore=function(L,V,F){return N.H.useSyncExternalStore(L,V,F)},zt.useTransition=function(){return N.H.useTransition()},zt.version="19.2.0",zt}var wz;function gR(){return wz||(wz=1,jx.exports=zle()),jx.exports}var y=gR();const de=Ay(y),Gd=ree({__proto__:null,default:de},[y]);function v_(e,t){if(!e)throw new Error(t)}Ye(v_,"assert");var Sz=3e3,Fle=5e3;function bR(e){const{url:t,enabled:n=!0,clientName:r,clientUri:a,callbackUrl:i=typeof window<"u"?Iu(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:o="mcp:auth",clientConfig:l={},customHeaders:u={},debug:d=!1,autoRetry:p=!1,autoReconnect:h=Sz,transportType:g="auto",preventAutoAuth:b=!1,useRedirectFlow:v=!1,onPopupWindow:x,timeout:S=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:C,onElicitation:R}=e,[A,N]=y.useState("discovering"),[O,$]=y.useState([]),[M,z]=y.useState([]),[W,J]=y.useState([]),[X,re]=y.useState([]),[H,Z]=y.useState(),[G,ae]=y.useState(),[ne,L]=y.useState(void 0),[V,F]=y.useState([]),[j,P]=y.useState(void 0),B=y.useRef(null),K=y.useRef(null),ee=y.useRef(!1),ie=y.useRef(!0),ue=y.useRef(0),Q=y.useRef(null),q=y.useRef(A),le=y.useRef(h),ve=y.useRef(null);y.useEffect(()=>{q.current=A,le.current=h},[A,h]);const oe=y.useCallback((He,Be,...Te)=>{const Pe=Te.length>0?`${Be} ${Te.map(Ve=>JSON.stringify(Ve)).join(" ")}`:Be;console[He](`[useMcp] ${Pe}`),ie.current&&F(Ve=>[...Ve.slice(-100),{level:He,message:Pe,timestamp:Date.now()}])},[]),Ae=y.useCallback(async(He=!1)=>{if(He||oe("info","Disconnecting..."),ee.current=!1,Q.current&&clearTimeout(Q.current),Q.current=null,B.current)try{const Be="inspector-server",Te=B.current.getSession(Be);Te&&Te._healthCheckCleanup&&(Te._healthCheckCleanup(),Te._healthCheckCleanup=null),await B.current.closeSession(Be)}catch(Be){He||oe("warn","Error closing session:",Be)}B.current=null,ie.current&&!He&&(N("discovering"),$([]),z([]),J([]),re([]),L(void 0),P(void 0))},[oe]),Je=y.useCallback((He,Be)=>{if(oe("error",He,Be??""),ie.current){N("failed"),L(He);const Te=K.current?.getLastAttemptedAuthUrl();Te&&(P(Te),oe("info","Manual authentication URL may be available.",Te))}ee.current=!1,t&&Qi.getInstance().trackUseMcpConnection({url:t,transportType:g,success:!1,errorType:Be?.name||"UnknownError",hasOAuth:!!K.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{})},[oe,t,g,C,R]),ke=y.useCallback(async()=>{if(!n||!t){oe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(ee.current){oe("debug","Connection attempt already in progress.");return}if(!ie.current){oe("debug","Connect called after unmount, aborting.");return}ee.current=!0,ue.current+=1,L(void 0),P(void 0),ve.current=null,N("discovering"),oe("info",`Connecting attempt #${ue.current} to ${t}...`),K.current||(K.current=new Qb(t,{storageKeyPrefix:o,clientName:r,clientUri:a,callbackUrl:i,preventAutoAuth:b,useRedirectFlow:v,onPopupWindow:x}),oe("debug","BrowserOAuthClientProvider initialized in connect.")),B.current||(B.current=new Ule,oe("debug","BrowserMCPClient initialized in connect."));const He=Ye(async(Te,Pe=!1)=>{oe("info",`Attempting connection with transport: ${Te}`);try{const Ve="inspector-server",Qe={url:t,transport:Te==="sse"?"http":Te};if(u&&Object.keys(u).length>0&&(Qe.headers=u),K.current){const it=await K.current.tokens();it?.access_token&&(Qe.headers={...Qe.headers,Authorization:`Bearer ${it.access_token}`})}B.current.addServer(Ve,{...Qe,authProvider:K.current,clientOptions:l,samplingCallback:C,elicitationCallback:R,wrapTransport:E?it=>(console.log("[useMcp] Applying transport wrapper for server:",Ve,"url:",t),E(it,t)):void 0});const ot=await B.current.createSession(Ve,!1);ot.on("notification",it=>{k?.(it),it.method==="notifications/tools/list_changed"?(oe("info","Tools list changed, auto-refreshing..."),gt().catch(kt=>oe("warn","Auto-refresh tools failed:",kt))):it.method==="notifications/resources/list_changed"?(oe("info","Resources list changed, auto-refreshing..."),wt().catch(kt=>oe("warn","Auto-refresh resources failed:",kt))):it.method==="notifications/prompts/list_changed"&&(oe("info","Prompts list changed, auto-refreshing..."),Tt().catch(kt=>oe("warn","Auto-refresh prompts failed:",kt)))}),await ot.initialize(),oe("info","✅ Successfully connected to MCP server"),oe("info","Server info:",ot.connector.serverInfo),oe("info","Server capabilities:",ot.connector.serverCapabilities),console.log("[useMcp] Server info:",ot.connector.serverInfo),console.log("[useMcp] Server capabilities:",ot.connector.serverCapabilities),N("ready"),ve.current=Te;const $t=Ye(()=>{let it=null,kt=Date.now();const Mt=1e4,nr=3e4;return it=setInterval(Ye(async()=>{if(!ie.current||q.current!=="ready"){it&&(clearInterval(it),it=null);return}try{await ot.connector.listTools(),kt=Date.now()}catch{const se=Date.now()-kt;se>nr&&(oe("warn",`Connection appears to be broken (no response for ${Math.round(se/1e3)}s), attempting to reconnect...`),it&&(clearInterval(it),it=null),le.current&&ie.current&&(N("discovering"),oe("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{ie.current&&q.current==="discovering"&&ke()},typeof le.current=="number"?le.current:Sz)))}},"checkConnectionHealth"),Mt),()=>{it&&(clearInterval(it),it=null)}},"setupConnectionMonitoring");if(h){const it=$t();ot._healthCheckCleanup=it}Qi.getInstance().trackUseMcpConnection({url:t,transportType:Te,success:!0,hasOAuth:!!K.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{}),$(ot.connector.tools||[]);const Rt=await ot.connector.listAllResources();z(Rt.resources||[]);const Xt=await ot.connector.listPrompts();re(Xt.prompts||[]);const un=ot.connector.serverInfo,at=ot.connector.serverCapabilities;return un&&(console.log("[useMcp] Server info:",un),Z(un)),at&&(console.log("[useMcp] Server capabilities:",at),ae(at)),"success"}catch(Ve){const Qe=Ve,ot=Qe?.message||String(Ve);if(Qe.code===401||ot.includes("401")||ot.includes("Unauthorized")){if(K.current){oe("info","Authentication required. OAuth provider available.");try{const{auth:$t}=await pr(async()=>{const{auth:Xt}=await Promise.resolve().then(()=>mz);return{auth:Xt}},void 0),Rt=new URL(t).origin;$t(K.current,{serverUrl:Rt}).catch(()=>{}),setTimeout(()=>{if(ie.current){const Xt=K.current?.getLastAttemptedAuthUrl();Xt?(P(Xt),oe("info","Manual authentication URL available:",Xt)):oe("warn","Could not generate authentication URL")}},100)}catch($t){oe("warn","Error generating auth URL:",$t)}return ie.current&&N("pending_auth"),ee.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(Je("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Je("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Je(ot,Qe instanceof Error?Qe:new Error(String(Qe))),"failed"}},"tryConnectWithTransport");let Be="failed";if(g==="sse")oe("debug","Using SSE-only transport mode"),Be=await He("sse");else if(g==="http")oe("debug","Using HTTP-only transport mode"),Be=await He("http");else{oe("debug","Using auto transport mode (HTTP with SSE fallback)");const Te=await He("http");Te==="fallback"&&ie.current&&q.current!=="authenticating"?(oe("info","HTTP failed, attempting SSE fallback..."),Be=await He("sse")):Be=Te}(Be==="success"||Be==="failed"||Be==="auth_redirect")&&(ee.current=!1),oe("debug",`Connection sequence finished with status: ${Be}`)},[oe,Je,Ae,t,o,r,a,i,l.name,l.version,u,g,b,v,x,n,S,_]),Re=y.useCallback(async(He,Be,Te)=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot call tool "${He}".`);oe("info",`Calling tool: ${He}`,Be);const Pe=Date.now();try{const Qe=B.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const ot=await Qe.connector.callTool(He,Be||{},Te);return oe("info",`Tool "${He}" call successful:`,ot),Qi.getInstance().trackUseMcpToolCall({toolName:He,success:!0,executionTimeMs:Date.now()-Pe}).catch(()=>{}),ot}catch(Ve){throw oe("error",`Tool "${He}" call failed:`,Ve),Qi.getInstance().trackUseMcpToolCall({toolName:He,success:!1,errorType:Ve instanceof Error?Ve.name:"UnknownError",executionTimeMs:Date.now()-Pe}).catch(()=>{}),Ve}},[A]),Ze=y.useCallback(()=>{q.current==="failed"?(oe("info","Retry requested..."),ke()):oe("warn",`Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`)},[oe,ke]),me=y.useCallback(async()=>{oe("info","Manual authentication requested...");const He=q.current;if(He==="failed")oe("info","Attempting to reconnect and authenticate via retry..."),Ze();else if(He==="pending_auth"){oe("info","Proceeding with authentication from pending state...");try{v_(K.current,"Auth Provider not available for manual auth"),v_(t,"Server URL is required for authentication"),oe("info","Clearing all OAuth state and initiating fresh flow...");const Be=`${o}:${K.current.serverUrlHash}`;Object.keys(localStorage).forEach(Qe=>{Qe.startsWith(Be)&&(oe("debug",`Removing stale OAuth key: ${Qe}`),localStorage.removeItem(Qe)),Qe.startsWith(`${o}:state_`)&&(oe("debug",`Removing orphaned state: ${Qe}`),localStorage.removeItem(Qe))}),N("authenticating");const Te=new Qb(t,{storageKeyPrefix:o,clientName:r,clientUri:a,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:v,onPopupWindow:x});K.current=Te,oe("info","Triggering fresh OAuth authorization...");const{auth:Pe}=await pr(async()=>{const{auth:Qe}=await Promise.resolve().then(()=>mz);return{auth:Qe}},void 0),Ve=new URL(t).origin;Pe(Te,{serverUrl:Ve}).catch(Qe=>{oe("info","OAuth flow initiated:",Qe instanceof Error?Qe.message:"Redirecting...")})}catch(Be){if(!ie.current)return;N("pending_auth"),oe("error",`Manual authentication failed: ${Be instanceof Error?Be.message:String(Be)}`)}}else if(He==="authenticating"){oe("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Be=K.current?.getLastAttemptedAuthUrl();Be&&!j&&(P(Be),oe("info","Manual authentication URL retrieved:",Be))}else oe("info",`Client not in a state requiring manual authentication trigger (state: ${He}). If needed, try disconnecting and reconnecting.`)},[oe,Ze,j,t,v,x,o,r,a,i]),Le=y.useCallback(()=>{if(K.current){const He=K.current.clearStorage();oe("info",`Cleared ${He} item(s) from localStorage for ${t}.`),P(void 0),Ae()}else oe("warn","Auth provider not initialized, cannot clear storage.")},[t,oe,Ae]),Ke=y.useCallback(async()=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list resources.`);oe("info","Listing resources");try{const Be=B.current.getSession("inspector-server");if(!Be)throw new Error("No active session found");const Te=await Be.connector.listAllResources();z(Te.resources||[]),oe("info","Resources listed successfully")}catch(He){throw oe("error","List resources failed:",He),He}},[A]),_e=y.useCallback(async He=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot read resource.`);oe("info",`Reading resource: ${He}`);try{const Te=B.current.getSession("inspector-server");if(!Te)throw new Error("No active session found");const Pe=await Te.connector.readResource(He);return oe("info","Resource read successful:",Pe),Qi.getInstance().trackUseMcpResourceRead({resourceUri:He,success:!0}).catch(()=>{}),Pe}catch(Be){throw oe("error","Resource read failed:",Be),Qi.getInstance().trackUseMcpResourceRead({resourceUri:He,success:!1,errorType:Be instanceof Error?Be.name:"UnknownError"}).catch(()=>{}),Be}},[A]),vt=y.useCallback(async()=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list prompts.`);oe("info","Listing prompts");try{const Be=B.current.getSession("inspector-server");if(!Be)throw new Error("No active session found");const Te=await Be.connector.listPrompts();re(Te.prompts||[]),oe("info","Prompts listed successfully")}catch(He){throw oe("error","List prompts failed:",He),He}},[A]),gt=y.useCallback(async()=>{if(q.current!=="ready"||!B.current){oe("debug","Cannot refresh tools - client not ready");return}oe("debug","Refreshing tools list");try{const Be=B.current.getSession("inspector-server");if(!Be){oe("warn","No active session found for tools refresh");return}const Te=await Be.connector.listTools();$(Te||[]),oe("info","Tools list refreshed successfully")}catch(He){oe("warn","Failed to refresh tools:",He)}},[oe]),wt=y.useCallback(async()=>{if(q.current!=="ready"||!B.current){oe("debug","Cannot refresh resources - client not ready");return}oe("debug","Refreshing resources list");try{const Be=B.current.getSession("inspector-server");if(!Be){oe("warn","No active session found for resources refresh");return}const Te=await Be.connector.listAllResources();z(Te.resources||[]),oe("info","Resources list refreshed successfully")}catch(He){oe("warn","Failed to refresh resources:",He)}},[oe]),Tt=y.useCallback(async()=>{if(q.current!=="ready"||!B.current){oe("debug","Cannot refresh prompts - client not ready");return}oe("debug","Refreshing prompts list");try{const Be=B.current.getSession("inspector-server");if(!Be){oe("warn","No active session found for prompts refresh");return}const Te=await Be.connector.listPrompts();re(Te.prompts||[]),oe("info","Prompts list refreshed successfully")}catch(He){oe("warn","Failed to refresh prompts:",He)}},[oe]),At=y.useCallback(async()=>{oe("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([gt(),wt(),Tt()])},[gt,wt,Tt,oe]),Cn=y.useCallback(async(He,Be)=>{if(q.current!=="ready"||!B.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot get prompt.`);oe("info",`Getting prompt: ${He}`,Be);try{const Pe=B.current.getSession("inspector-server");if(!Pe)throw new Error("No active session found");const Ve=await Pe.connector.getPrompt(He,Be||{});return oe("info",`Prompt "${He}" retrieved successfully:`,Ve),Ve}catch(Te){throw oe("error",`Prompt "${He}" retrieval failed:`,Te),Te}},[A]),mr=y.useRef(ke),Ut=y.useRef(Je);return y.useEffect(()=>{mr.current=ke,Ut.current=Je}),y.useEffect(()=>{const He=Ye(Be=>{Be.origin===window.location.origin&&Be.data?.type==="mcp_auth_callback"&&(oe("info","Received auth callback message.",Be.data),Q.current&&clearTimeout(Q.current),Q.current=null,Be.data.success?(oe("info","Authentication successful via popup. Reconnecting client..."),ee.current&&oe("debug","Connection attempt already in progress, resetting flag to allow reconnection."),ee.current=!1,setTimeout(()=>{ie.current&&(oe("debug","Initiating reconnection after successful auth callback."),mr.current())},100)):Ut.current(`Authentication failed in callback: ${Be.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",He),oe("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",He),oe("debug","Auth callback message listener removed."),Q.current&&clearTimeout(Q.current)}},[oe]),y.useEffect(()=>(ie.current=!0,!n||!t?(oe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),N("discovering"),()=>{ie.current=!1}):(oe("debug","useMcp mounted, initiating connection."),ue.current=0,(!K.current||K.current.serverUrl!==t)&&(K.current=new Qb(t,{storageKeyPrefix:o,clientName:r,clientUri:a,callbackUrl:i,preventAutoAuth:b,useRedirectFlow:v,onPopupWindow:x}),oe("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),ke(),()=>{ie.current=!1,oe("debug","useMcp unmounting, disconnecting."),Ae(!0)})),[t,n,o,i,r,a,l.name,l.version,v]),y.useEffect(()=>{let He=null;if(A==="failed"&&p&&ue.current>0){const Be=typeof p=="number"?p:Fle;oe("info",`Connection failed, auto-retrying in ${Be}ms...`),He=setTimeout(()=>{ie.current&&q.current==="failed"&&Ze()},Be)}return()=>{He&&clearTimeout(He)}},[A,p,Ze,oe]),{state:A,tools:O,resources:M,resourceTemplates:W,prompts:X,serverInfo:H,capabilities:G,error:ne,log:V,authUrl:j,client:B.current,callTool:Re,readResource:_e,listResources:Ke,listPrompts:vt,getPrompt:Cn,refreshTools:gt,refreshResources:wt,refreshPrompts:Tt,refreshAll:At,retry:Ze,disconnect:Ae,authenticate:me,clearStorage:Le}}Ye(bR,"useMcp");var Ed,Ble=(Ed=class extends de.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?de.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"},de.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),de.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},Ye(Ed,"ErrorBoundary"),Ed),$p="openai:set_globals";function Ti(e){return y.useSyncExternalStore(t=>{const n=Ye(r=>{r.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener($p,n),()=>{typeof window<"u"&&window.removeEventListener($p,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}Ye(Ti,"useOpenAiGlobal");function Wd(e){const[t,n]=y.useState(()=>typeof window<"u"&&!!window.openai);y.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const M=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(M))},100),z=Ye(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(M))},"handleSetGlobals");typeof window<"u"&&window.addEventListener($p,z);const W=setTimeout(()=>{clearInterval(M),typeof window<"u"&&window.removeEventListener($p,z)},5e3);return()=>{clearInterval(M),clearTimeout(W),typeof window<"u"&&window.removeEventListener($p,z)}},[]);const r=y.useMemo(()=>t?"openai":"mcp-ui",[t]),a=typeof window<"u"?window.location.search:"",i=y.useMemo(()=>{const M=new URLSearchParams(a);return M.has("mcpUseParams")?JSON.parse(M.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[a]),o=r==="openai"?Ti("toolInput"):i.toolInput,l=r==="openai"?Ti("toolOutput"):i.toolOutput,u=Ti("toolResponseMetadata"),d=y.useMemo(()=>{if(u&&typeof u=="object"){const M=u["mcp-use/props"];if(M)return M}return e||{}},[u,e]),p=Ti("widgetState"),h=Ti("theme"),g=Ti("displayMode"),b=Ti("safeArea"),v=Ti("maxHeight"),x=Ti("userAgent"),S=Ti("locale"),_=y.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[E,k]=y.useState(null);y.useEffect(()=>{p!==void 0&&k(p)},[p]);const C=y.useCallback(async(M,z)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(M,z)},[]),R=y.useCallback(async M=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:M})},[]),A=y.useCallback(M=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:M})},[]),N=y.useCallback(async M=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:M})},[]),O=y.useCallback(async M=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const W=typeof M=="function"?M(p!==void 0?p:E):M;return k(W),window.openai.setWidgetState(W)},[p,E]),$=y.useMemo(()=>r==="openai"&&u===null,[r,u]);return{props:d,toolInput:o||{},output:l??null,metadata:u??null,state:E,setState:O,theme:h||"light",displayMode:g||"inline",safeArea:b||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:v||600,userAgent:x||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:S||"en",mcp_url:_,callTool:C,sendFollowUpMessage:R,openExternal:A,requestDisplayMode:N,isAvailable:t,isPending:$}}Ye(Wd,"useWidget");function Hle(e){const{props:t}=Wd(e);return t}Ye(Hle,"useWidgetProps");function Vle(){const{theme:e}=Wd();return e}Ye(Vle,"useWidgetTheme");function Gle(e){const{state:t,setState:n}=Wd();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Ye(Gle,"useWidgetState");var xz=Ye(({children:e})=>{const{theme:t,isAvailable:n}=Wd();console.log("theme",t);const[r,a]=y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");y.useEffect(()=>{if(typeof window>"u")return;const o=window.matchMedia("(prefers-color-scheme: dark)"),l=Ye(u=>{a(u.matches?"dark":"light")},"handleChange");return o.addEventListener("change",l),()=>o.removeEventListener("change",l)},[]);const i=n?t:r;return y.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),de.createElement(de.Fragment,null,e)},"ThemeProvider");function G9({children:e,className:t="",position:n="top-right",attachTo:r,showLabels:a=!0,debugger:i=!1,viewControls:o=!1}){const{props:l,output:u,metadata:d,state:p,theme:h,displayMode:g,safeArea:b,maxHeight:v,userAgent:x,locale:S,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:C,requestDisplayMode:R,setState:A}=Wd(),[N,O]=y.useState(!1),[$,M]=y.useState(!1),z=y.useRef(null),W=y.useRef(null),[J,X]=y.useState([]),[re,H]=y.useState(""),[Z,G]=y.useState("get-my-city"),[ae,ne]=y.useState("{}"),[L,V]=y.useState("Test follow-up message"),[F,j]=y.useState("https://docs.mcp-use.com"),P=g==="fullscreen"&&_,B=g==="pip"&&_,K=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const _e=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const vt=Object.keys(window.openai);X(vt)}catch{X([])}else X([])},100);return()=>{clearTimeout(_e)}},[]);const ee=h==="dark",ie=Ye(()=>{const _e=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",N?"opacity-100":"opacity-0",N?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[..._e,"top-4","left-4"];case"top-center":return[..._e,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[..._e,"top-4","right-4"];case"center-left":return[..._e,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[..._e,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[..._e,"bottom-4","left-4"];case"bottom-center":return[..._e,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[..._e,"bottom-4","right-4"];default:return[..._e,"top-4","right-4"]}},"getPositionClasses"),ue=Ye(()=>{const vt=b?.insets?.top?Math.max(16,b.insets.top+8):16,gt=b?.insets?.right?Math.max(16,b.insets.right+8):16,wt=b?.insets?.bottom?Math.max(16,b.insets.bottom+8):16,Tt=b?.insets?.left?Math.max(16,b.insets.left+8):16,At={};switch(n){case"top-left":At.top=`${vt}px`,At.left=`${Tt}px`;break;case"top-center":At.top=`${vt}px`;break;case"top-right":At.top=`${vt}px`,At.right=`${gt}px`;break;case"center-left":At.left=`${Tt}px`;break;case"center-right":At.right=`${gt}px`;break;case"bottom-left":At.bottom=`${wt}px`,At.left=`${Tt}px`;break;case"bottom-center":At.bottom=`${wt}px`;break;case"bottom-right":At.bottom=`${wt}px`,At.right=`${gt}px`;break;default:At.top=`${vt}px`,At.right=`${gt}px`;break}return At},"getPositionOffsetStyles");y.useEffect(()=>{if(!r)return;const _e=Ye(()=>O(!0),"handleMouseEnter"),vt=Ye(()=>O(!1),"handleMouseLeave");return r.addEventListener("mouseenter",_e),r.addEventListener("mouseleave",vt),()=>{r.removeEventListener("mouseenter",_e),r.removeEventListener("mouseleave",vt)}},[r]),y.useEffect(()=>{if(!$)return;const _e=Ye(vt=>{W.current&&!W.current.contains(vt.target)&&M(!1)},"handleClickOutside");return document.addEventListener("mousedown",_e),()=>{document.removeEventListener("mousedown",_e)}},[$]),y.useEffect(()=>($?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[$]);const Q=Ye(()=>{M(!$)},"handleToggleOverlay"),q=Ye(async()=>{try{H("Calling tool...");const _e=ae.trim()?JSON.parse(ae):{},vt=await E(Z,_e);H(`Success: ${JSON.stringify(vt,null,2)}`)}catch(_e){H(`Error: ${_e.message}`)}},"handleCallTool"),le=Ye(async()=>{try{H("Sending follow-up message..."),await k(L),H("Follow-up message sent successfully")}catch(_e){H(`Error: ${_e.message}`)}},"handleSendFollowUpMessage"),ve=Ye(()=>{try{C(F),H(`Opened external link: ${F}`)}catch(_e){H(`Error: ${_e.message}`)}},"handleOpenExternal"),oe=Ye(async _e=>{try{H(`Requesting display mode: ${_e}...`);const vt=await R(_e);H(`Display mode granted: ${vt.mode}`)}catch(vt){H(`Error: ${vt.message}`)}},"handleRequestDisplayMode"),Ae=Ye(async()=>{try{const _e=p?{...p,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};H("Setting state..."),await A(_e),H(`State updated: ${JSON.stringify(_e,null,2)}`)}catch(_e){H(`Error: ${_e.message}`)}},"handleSetState"),Je=Ye(async()=>{try{await R("fullscreen")}catch(_e){console.error("Failed to go fullscreen:",_e)}},"handleFullscreen"),ke=Ye(async()=>{try{await R("pip")}catch(_e){console.error("Failed to go pip:",_e)}},"handlePip"),Re=Ye(()=>{const _e=["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[..._e,"top-full","right-0","mt-2"];case"top-left":return[..._e,"top-full","left-0","mt-2"];case"top-center":return[..._e,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[..._e,"bottom-full","right-0","mb-2"];case"bottom-left":return[..._e,"bottom-full","left-0","mb-2"];case"bottom-center":return[..._e,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[..._e,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[..._e,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[..._e,"top-full","right-0","mt-2"]}},"getTooltipClasses"),Ze=Ye(({onClick:_e,label:vt,children:gt})=>{const[wt,Tt]=y.useState(!1),At=Re();return de.createElement("button",{className:`p-2 ${ee?"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 ${ee?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Tt(!0),onMouseLeave:()=>Tt(!1),onClick:_e,"aria-label":vt},de.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"},gt),a&&de.createElement("span",{className:`${At.join(" ")} ${wt?"opacity-100":"opacity-0"}`},vt))},"IconButton"),me=Ye(_e=>{if(_e===null)return"null";if(_e===void 0)return"undefined";if(typeof _e=="object")try{return JSON.stringify(_e,null,2)}catch{return String(_e)}return String(_e)},"formatValue"),Le=Ye(_e=>_e?`${_e.device?.type||"unknown"}`:"N/A","formatUserAgent"),Ke=Ye(_e=>{if(!_e?.insets)return"N/A";const{top:vt,bottom:gt,left:wt,right:Tt}=_e.insets;return`T:${vt} B:${gt} L:${wt} R:${Tt}`},"formatSafeArea");return de.createElement(de.Fragment,null,de.createElement("div",{ref:z,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&O(!0),onMouseLeave:()=>!r&&O(!1)},de.createElement("div",{className:ie().join(" "),style:ue()},!K&&de.createElement(de.Fragment,null,!P&&!B&&de.createElement(de.Fragment,null,(o===!0||o==="fullscreen")&&de.createElement(Ze,{onClick:Je,label:"Fullscreen"},de.createElement("path",{d:"M15 3h6v6"}),de.createElement("path",{d:"m21 3-7 7"}),de.createElement("path",{d:"m3 21 7-7"}),de.createElement("path",{d:"M9 21H3v-6"})),(o===!0||o==="pip")&&de.createElement(Ze,{onClick:ke,label:"Picture in Picture"},de.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),de.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&de.createElement(Ze,{onClick:Q,label:"Debug Info"},de.createElement("path",{d:"M12 20v-9"}),de.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),de.createElement("path",{d:"M14.12 3.88 16 2"}),de.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),de.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),de.createElement("path",{d:"M22 13h-4"}),de.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),de.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),de.createElement("path",{d:"M6 13H2"}),de.createElement("path",{d:"m8 2 1.88 1.88"}),de.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),$&&i&&de.createElement("div",{ref:W,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:_e=>{_e.target===W.current&&M(!1)}},de.createElement("button",{onClick:()=>M(!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"},"×"),de.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},de.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),de.createElement("table",{className:"w-full border-collapse border-spacing-0"},de.createElement("tbody",null,de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),de.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},me(l))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),de.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},me(u))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),de.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},me(d))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),de.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},me(p))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),de.createElement("td",{className:"p-2"},h)),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),de.createElement("td",{className:"p-2"},g)),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),de.createElement("td",{className:"p-2"},S)),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),de.createElement("td",{className:"p-2"},v,"px")),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),de.createElement("td",{className:"p-2"},Le(x))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),de.createElement("td",{className:"p-2"},Ke(b))),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),de.createElement("td",{className:"p-2"},_?"Yes":"No")),de.createElement("tr",{className:"border-b border-gray-700"},de.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),de.createElement("td",{className:"p-2"},J.length>0?J.join(", "):"N/A")))),de.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),de.createElement("div",{className:"flex flex-col gap-3"},de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("input",{type:"text",value:Z,onChange:_e=>G(_e.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]"}),de.createElement("input",{type:"text",value:ae,onChange:_e=>ne(_e.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"}),de.createElement("button",{onClick:q,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("input",{type:"text",value:L,onChange:_e=>V(_e.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"}),de.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")),de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("input",{type:"text",value:F,onChange:_e=>j(_e.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"}),de.createElement("button",{onClick:ve,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),de.createElement("button",{onClick:()=>oe("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"),de.createElement("button",{onClick:()=>oe("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"),de.createElement("button",{onClick:()=>oe("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")),de.createElement("div",{className:"flex gap-2 items-center"},de.createElement("button",{onClick:Ae,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Set State (Add Timestamp)")),re&&de.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"},de.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),re,de.createElement("button",{onClick:()=>H(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}Ye(G9,"WidgetControls");function W9(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Ye(W9,"getBasename");var Wle=150,Kle=5;function Zle({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!1}){const a=W9(),i=y.useRef(null),o=y.useRef(0),l=y.useRef(null),u=y.useRef(!1),[d,p]=y.useState(null),[h,g]=y.useState(null),[b,v]=y.useState(!0);y.useEffect(()=>{let E=!0;return(async()=>{try{const k=await pr(()=>import("./index-Cfg3RZ-z.js"),[]);E&&(p(()=>k.BrowserRouter),v(!1))}catch{E&&(g(new Error(`❌ react-router not installed!
|
|
36
36
|
|
|
37
37
|
To use MCP widgets with McpUseProvider, you need to install:
|
|
38
38
|
|
|
@@ -121,7 +121,7 @@ import(${JSON.stringify(t.entry.module)});`:" ";return y.createElement(y.Fragmen
|
|
|
121
121
|
`)},I4=function(){var e=parseInt(document.body.getAttribute(Yu)||"0",10);return isFinite(e)?e:0},whe=function(){y.useEffect(function(){return document.body.setAttribute(Yu,(I4()+1).toString()),function(){var e=I4()-1;e<=0?document.body.removeAttribute(Yu):document.body.setAttribute(Yu,e.toString())}},[])},She=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;whe();var i=y.useMemo(function(){return bhe(a)},[a]);return y.createElement(vhe,{styles:yhe(i,!t,a,n?"":"!important")})},B_=!1;if(typeof window<"u")try{var Ab=Object.defineProperty({},"passive",{get:function(){return B_=!0,!0}});window.addEventListener("test",Ab,Ab),window.removeEventListener("test",Ab,Ab)}catch{B_=!1}var mu=B_?{passive:!1}:!1,xhe=function(e){return e.tagName==="TEXTAREA"},wW=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!xhe(e)&&n[t]==="visible")},Ehe=function(e){return wW(e,"overflowY")},_he=function(e){return wW(e,"overflowX")},O4=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=SW(e,r);if(a){var i=xW(e,r),o=i[1],l=i[2];if(o>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},khe=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},The=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},SW=function(e,t){return e==="v"?Ehe(t):_he(t)},xW=function(e,t){return e==="v"?khe(t):The(t)},Nhe=function(e,t){return e==="h"&&t==="rtl"?-1:1},Rhe=function(e,t,n,r,a){var i=Nhe(e,window.getComputedStyle(t).direction),o=i*r,l=n.target,u=t.contains(l),d=!1,p=o>0,h=0,g=0;do{if(!l)break;var b=xW(e,l),v=b[0],x=b[1],S=b[2],_=x-S-i*v;(v||_)&&SW(e,l)&&(h+=_,g+=v);var E=l.parentNode;l=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(p&&Math.abs(h)<1||!p&&Math.abs(g)<1)&&(d=!0),d},Ib=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},D4=function(e){return[e.deltaX,e.deltaY]},L4=function(e){return e&&"current"in e?e.current:e},Che=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Ahe=function(e){return`
|
|
122
122
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
123
123
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
124
|
-
`)},Ihe=0,hu=[];function Ohe(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),a=y.useState(Ihe++)[0],i=y.useState(yW)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var x=Qme([e.lockRef.current],(e.shards||[]).map(L4),!0).filter(Boolean);return x.forEach(function(S){return S.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),x.forEach(function(S){return S.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=y.useCallback(function(x,S){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!o.current.allowPinchZoom;var _=Ib(x),E=n.current,k="deltaX"in x?x.deltaX:E[0]-_[0],C="deltaY"in x?x.deltaY:E[1]-_[1],R,A=x.target,N=Math.abs(k)>Math.abs(C)?"h":"v";if("touches"in x&&N==="h"&&A.type==="range")return!1;var O=O4(N,A);if(!O)return!0;if(O?R=N:(R=N==="v"?"h":"v",O=O4(N,A)),!O)return!1;if(!r.current&&"changedTouches"in x&&(k||C)&&(r.current=R),!R)return!0;var $=r.current||R;return Rhe($,S,x,$==="h"?k:C)},[]),u=y.useCallback(function(x){var S=x;if(!(!hu.length||hu[hu.length-1]!==i)){var _="deltaY"in S?D4(S):Ib(S),E=t.current.filter(function(R){return R.name===S.type&&(R.target===S.target||S.target===R.shadowParent)&&Che(R.delta,_)})[0];if(E&&E.should){S.cancelable&&S.preventDefault();return}if(!E){var k=(o.current.shards||[]).map(L4).filter(Boolean).filter(function(R){return R.contains(S.target)}),C=k.length>0?l(S,k[0]):!o.current.noIsolation;C&&S.cancelable&&S.preventDefault()}}},[]),d=y.useCallback(function(x,S,_,E){var k={name:x,delta:S,target:_,should:E,shadowParent:Dhe(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(C){return C!==k})},1)},[]),p=y.useCallback(function(x){n.current=Ib(x),r.current=void 0},[]),h=y.useCallback(function(x){d(x.type,D4(x),x.target,l(x,e.lockRef.current))},[]),g=y.useCallback(function(x){d(x.type,Ib(x),x.target,l(x,e.lockRef.current))},[]);y.useEffect(function(){return hu.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,mu),document.addEventListener("touchmove",u,mu),document.addEventListener("touchstart",p,mu),function(){hu=hu.filter(function(x){return x!==i}),document.removeEventListener("wheel",u,mu),document.removeEventListener("touchmove",u,mu),document.removeEventListener("touchstart",p,mu)}},[]);var b=e.removeScrollBar,v=e.inert;return y.createElement(y.Fragment,null,v?y.createElement(i,{styles:Ahe(a)}):null,b?y.createElement(She,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Dhe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lhe=lhe(vW,Ohe);var Jm=y.forwardRef(function(e,t){return y.createElement(Sw,eo({},e,{ref:t,sideCar:Lhe}))});Jm.classNames=Sw.classNames;var H_=["Enter"," "],jhe=["ArrowDown","PageUp","Home"],EW=["ArrowUp","PageDown","End"],$he=[...jhe,...EW],Mhe={ltr:[...H_,"ArrowRight"],rtl:[...H_,"ArrowLeft"]},Phe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Qm="Menu",[cm,Uhe,zhe]=VR(Qm),[xc,_W]=Wi(Qm,[zhe,ul,uW]),xw=ul(),kW=uW(),[Fhe,Ec]=xc(Qm),[Bhe,eh]=xc(Qm),TW=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:i,modal:o=!0}=e,l=xw(t),[u,d]=y.useState(null),p=y.useRef(!1),h=co(i),g=GR(a);return y.useEffect(()=>{const b=()=>{p.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>p.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),f.jsx(bw,{...l,children:f.jsx(Fhe,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:f.jsx(Bhe,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:p,dir:g,modal:o,children:r})})})};TW.displayName=Qm;var Hhe="MenuAnchor",tC=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=xw(n);return f.jsx(qm,{...a,...r,ref:t})});tC.displayName=Hhe;var nC="MenuPortal",[Vhe,NW]=xc(nC,{forceMount:void 0}),RW=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,i=Ec(nC,t);return f.jsx(Vhe,{scope:t,forceMount:n,children:f.jsx(Xa,{present:n||i.open,children:f.jsx(nf,{asChild:!0,container:a,children:r})})})};RW.displayName=nC;var gi="MenuContent",[Ghe,rC]=xc(gi),CW=y.forwardRef((e,t)=>{const n=NW(gi,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,i=Ec(gi,e.__scopeMenu),o=eh(gi,e.__scopeMenu);return f.jsx(cm.Provider,{scope:e.__scopeMenu,children:f.jsx(Xa,{present:r||i.open,children:f.jsx(cm.Slot,{scope:e.__scopeMenu,children:o.modal?f.jsx(Whe,{...a,ref:t}):f.jsx(Khe,{...a,ref:t})})})})}),Whe=y.forwardRef((e,t)=>{const n=Ec(gi,e.__scopeMenu),r=y.useRef(null),a=yn(t,r);return y.useEffect(()=>{const i=r.current;if(i)return ww(i)},[]),f.jsx(aC,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:rt(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Khe=y.forwardRef((e,t)=>{const n=Ec(gi,e.__scopeMenu);return f.jsx(aC,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Zhe=lc("MenuContent.ScrollLock"),aC=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:g,onDismiss:b,disableOutsideScroll:v,...x}=e,S=Ec(gi,n),_=eh(gi,n),E=xw(n),k=kW(n),C=Uhe(n),[R,A]=y.useState(null),N=y.useRef(null),O=yn(t,N,S.onContentChange),$=y.useRef(0),M=y.useRef(""),z=y.useRef(0),W=y.useRef(null),J=y.useRef("right"),X=y.useRef(0),re=v?Jm:y.Fragment,H=v?{as:Zhe,allowPinchZoom:!0}:void 0,Z=ae=>{const ne=M.current+ae,L=C().filter(K=>!K.disabled),V=document.activeElement,F=L.find(K=>K.ref.current===V)?.textValue,j=L.map(K=>K.textValue),P=oge(j,ne,F),B=L.find(K=>K.textValue===P)?.ref.current;(function K(ee){M.current=ee,window.clearTimeout($.current),ee!==""&&($.current=window.setTimeout(()=>K(""),1e3))})(ne),B&&setTimeout(()=>B.focus())};y.useEffect(()=>()=>window.clearTimeout($.current),[]),fw();const G=y.useCallback(ae=>J.current===W.current?.side&&lge(ae,W.current?.area),[]);return f.jsx(Ghe,{scope:n,searchRef:M,onItemEnter:y.useCallback(ae=>{G(ae)&&ae.preventDefault()},[G]),onItemLeave:y.useCallback(ae=>{G(ae)||(N.current?.focus(),A(null))},[G]),onTriggerLeave:y.useCallback(ae=>{G(ae)&&ae.preventDefault()},[G]),pointerGraceTimerRef:z,onPointerGraceIntentChange:y.useCallback(ae=>{W.current=ae},[]),children:f.jsx(re,{...H,children:f.jsx(Zm,{asChild:!0,trapped:a,onMountAutoFocus:rt(i,ae=>{ae.preventDefault(),N.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:f.jsx(Qd,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:g,onDismiss:b,children:f.jsx(Zme,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:R,onCurrentTabStopIdChange:A,onEntryFocus:rt(u,ae=>{_.isUsingKeyboardRef.current||ae.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(vw,{role:"menu","aria-orientation":"vertical","data-state":GW(S.open),"data-radix-menu-content":"",dir:_.dir,...E,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:rt(x.onKeyDown,ae=>{const L=ae.target.closest("[data-radix-menu-content]")===ae.currentTarget,V=ae.ctrlKey||ae.altKey||ae.metaKey,F=ae.key.length===1;L&&(ae.key==="Tab"&&ae.preventDefault(),!V&&F&&Z(ae.key));const j=N.current;if(ae.target!==j||!$he.includes(ae.key))return;ae.preventDefault();const B=C().filter(K=>!K.disabled).map(K=>K.ref.current);EW.includes(ae.key)&&B.reverse(),age(B)}),onBlur:rt(e.onBlur,ae=>{ae.currentTarget.contains(ae.target)||(window.clearTimeout($.current),M.current="")}),onPointerMove:rt(e.onPointerMove,um(ae=>{const ne=ae.target,L=X.current!==ae.clientX;if(ae.currentTarget.contains(ne)&&L){const V=ae.clientX>X.current?"right":"left";J.current=V,X.current=ae.clientX}}))})})})})})})});CW.displayName=gi;var Yhe="MenuGroup",iC=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f.jsx(Gt.div,{role:"group",...r,ref:t})});iC.displayName=Yhe;var qhe="MenuLabel",AW=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f.jsx(Gt.div,{...r,ref:t})});AW.displayName=qhe;var Xv="MenuItem",j4="menu.itemSelect",Ew=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,i=y.useRef(null),o=eh(Xv,e.__scopeMenu),l=rC(Xv,e.__scopeMenu),u=yn(t,i),d=y.useRef(!1),p=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(j4,{bubbles:!0,cancelable:!0});h.addEventListener(j4,b=>r?.(b),{once:!0}),PG(h,g),g.defaultPrevented?d.current=!1:o.onClose()}};return f.jsx(IW,{...a,ref:u,disabled:n,onClick:rt(e.onClick,p),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:rt(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:rt(e.onKeyDown,h=>{const g=l.searchRef.current!=="";n||g&&h.key===" "||H_.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Ew.displayName=Xv;var IW=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...i}=e,o=rC(Xv,n),l=kW(n),u=y.useRef(null),d=yn(t,u),[p,h]=y.useState(!1),[g,b]=y.useState("");return y.useEffect(()=>{const v=u.current;v&&b((v.textContent??"").trim())},[i.children]),f.jsx(cm.ItemSlot,{scope:n,disabled:r,textValue:a??g,children:f.jsx(Yme,{asChild:!0,...l,focusable:!r,children:f.jsx(Gt.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:d,onPointerMove:rt(e.onPointerMove,um(v=>{r?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:rt(e.onPointerLeave,um(v=>o.onItemLeave(v))),onFocus:rt(e.onFocus,()=>h(!0)),onBlur:rt(e.onBlur,()=>h(!1))})})})}),Xhe="MenuCheckboxItem",OW=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return f.jsx(MW,{scope:e.__scopeMenu,checked:n,children:f.jsx(Ew,{role:"menuitemcheckbox","aria-checked":Jv(n)?"mixed":n,...a,ref:t,"data-state":sC(n),onSelect:rt(a.onSelect,()=>r?.(Jv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});OW.displayName=Xhe;var DW="MenuRadioGroup",[Jhe,Qhe]=xc(DW,{value:void 0,onValueChange:()=>{}}),LW=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,i=co(r);return f.jsx(Jhe,{scope:e.__scopeMenu,value:n,onValueChange:i,children:f.jsx(iC,{...a,ref:t})})});LW.displayName=DW;var jW="MenuRadioItem",$W=y.forwardRef((e,t)=>{const{value:n,...r}=e,a=Qhe(jW,e.__scopeMenu),i=n===a.value;return f.jsx(MW,{scope:e.__scopeMenu,checked:i,children:f.jsx(Ew,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":sC(i),onSelect:rt(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});$W.displayName=jW;var oC="MenuItemIndicator",[MW,ege]=xc(oC,{checked:!1}),PW=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,i=ege(oC,n);return f.jsx(Xa,{present:r||Jv(i.checked)||i.checked===!0,children:f.jsx(Gt.span,{...a,ref:t,"data-state":sC(i.checked)})})});PW.displayName=oC;var tge="MenuSeparator",UW=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f.jsx(Gt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});UW.displayName=tge;var nge="MenuArrow",zW=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=xw(n);return f.jsx(yw,{...a,...r,ref:t})});zW.displayName=nge;var rge="MenuSub",[_Ie,FW]=xc(rge),kp="MenuSubTrigger",BW=y.forwardRef((e,t)=>{const n=Ec(kp,e.__scopeMenu),r=eh(kp,e.__scopeMenu),a=FW(kp,e.__scopeMenu),i=rC(kp,e.__scopeMenu),o=y.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=i,d={__scopeMenu:e.__scopeMenu},p=y.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return y.useEffect(()=>p,[p]),y.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),u(null)}},[l,u]),f.jsx(tC,{asChild:!0,...d,children:f.jsx(IW,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":GW(n.open),...e,ref:lo(t,a.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:rt(e.onPointerMove,um(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:rt(e.onPointerLeave,um(h=>{p();const g=n.content?.getBoundingClientRect();if(g){const b=n.content?.dataset.side,v=b==="right",x=v?-5:5,S=g[v?"left":"right"],_=g[v?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:S,y:g.top},{x:_,y:g.top},{x:_,y:g.bottom},{x:S,y:g.bottom}],side:b}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:rt(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||Mhe[r.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});BW.displayName=kp;var HW="MenuSubContent",VW=y.forwardRef((e,t)=>{const n=NW(gi,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,i=Ec(gi,e.__scopeMenu),o=eh(gi,e.__scopeMenu),l=FW(HW,e.__scopeMenu),u=y.useRef(null),d=yn(t,u);return f.jsx(cm.Provider,{scope:e.__scopeMenu,children:f.jsx(Xa,{present:r||i.open,children:f.jsx(cm.Slot,{scope:e.__scopeMenu,children:f.jsx(aC,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{o.isUsingKeyboardRef.current&&u.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:rt(e.onFocusOutside,p=>{p.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:rt(e.onEscapeKeyDown,p=>{o.onClose(),p.preventDefault()}),onKeyDown:rt(e.onKeyDown,p=>{const h=p.currentTarget.contains(p.target),g=Phe[o.dir].includes(p.key);h&&g&&(i.onOpenChange(!1),l.trigger?.focus(),p.preventDefault())})})})})})});VW.displayName=HW;function GW(e){return e?"open":"closed"}function Jv(e){return e==="indeterminate"}function sC(e){return Jv(e)?"indeterminate":e?"checked":"unchecked"}function age(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ige(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function oge(e,t,n){const a=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=ige(e,Math.max(i,0));a.length===1&&(o=o.filter(d=>d!==n));const u=o.find(d=>d.toLowerCase().startsWith(a.toLowerCase()));return u!==n?u:void 0}function sge(e,t){const{x:n,y:r}=e;let a=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const l=t[i],u=t[o],d=l.x,p=l.y,h=u.x,g=u.y;p>r!=g>r&&n<(h-d)*(r-p)/(g-p)+d&&(a=!a)}return a}function lge(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return sge(n,t)}function um(e){return t=>t.pointerType==="mouse"?e(t):void 0}var cge=TW,uge=tC,dge=RW,fge=CW,pge=iC,mge=AW,hge=Ew,gge=OW,bge=LW,vge=$W,yge=PW,wge=UW,Sge=zW,xge=BW,Ege=VW,_w="DropdownMenu",[_ge]=Wi(_w,[_W]),wa=_W(),[kge,WW]=_ge(_w),KW=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,u=wa(t),d=y.useRef(null),[p,h]=Xo({prop:a,defaultProp:i??!1,onChange:o,caller:_w});return f.jsx(kge,{scope:t,triggerId:Kr(),triggerRef:d,contentId:Kr(),open:p,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:l,children:f.jsx(cge,{...u,open:p,onOpenChange:h,dir:r,modal:l,children:n})})};KW.displayName=_w;var ZW="DropdownMenuTrigger",YW=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,i=WW(ZW,n),o=wa(n);return f.jsx(uge,{asChild:!0,...o,children:f.jsx(Gt.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":r?"":void 0,disabled:r,...a,ref:lo(t,i.triggerRef),onPointerDown:rt(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:rt(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});YW.displayName=ZW;var Tge="DropdownMenuPortal",qW=e=>{const{__scopeDropdownMenu:t,...n}=e,r=wa(t);return f.jsx(dge,{...r,...n})};qW.displayName=Tge;var XW="DropdownMenuContent",JW=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=WW(XW,n),i=wa(n),o=y.useRef(!1);return f.jsx(fge,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:t,onCloseAutoFocus:rt(e.onCloseAutoFocus,l=>{o.current||a.triggerRef.current?.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:rt(e.onInteractOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,p=u.button===2||d;(!a.modal||p)&&(o.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)"}})});JW.displayName=XW;var Nge="DropdownMenuGroup",Rge=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(pge,{...a,...r,ref:t})});Rge.displayName=Nge;var Cge="DropdownMenuLabel",QW=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(mge,{...a,...r,ref:t})});QW.displayName=Cge;var Age="DropdownMenuItem",e7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(hge,{...a,...r,ref:t})});e7.displayName=Age;var Ige="DropdownMenuCheckboxItem",t7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(gge,{...a,...r,ref:t})});t7.displayName=Ige;var Oge="DropdownMenuRadioGroup",Dge=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(bge,{...a,...r,ref:t})});Dge.displayName=Oge;var Lge="DropdownMenuRadioItem",n7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(vge,{...a,...r,ref:t})});n7.displayName=Lge;var jge="DropdownMenuItemIndicator",$ge=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(yge,{...a,...r,ref:t})});$ge.displayName=jge;var Mge="DropdownMenuSeparator",r7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(wge,{...a,...r,ref:t})});r7.displayName=Mge;var Pge="DropdownMenuArrow",Uge=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(Sge,{...a,...r,ref:t})});Uge.displayName=Pge;var zge="DropdownMenuSubTrigger",a7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(xge,{...a,...r,ref:t})});a7.displayName=zge;var Fge="DropdownMenuSubContent",i7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(Ege,{...a,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});i7.displayName=Fge;var Bge=KW,Hge=YW,Vge=qW,o7=JW,s7=QW,l7=e7,Gge=t7,Wge=n7,c7=r7,Kge=a7,Zge=i7;const V_=Bge,G_=Hge;Kge.displayName;Zge.displayName;function Qv({ref:e,className:t,sideOffset:n=4,...r}){return f.jsx(Vge,{children:f.jsx(o7,{ref:e,sideOffset:n,className:Ue("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})})}Qv.displayName=o7.displayName;function Vo({ref:e,className:t,inset:n,...r}){return f.jsx(l7,{ref:e,className:Ue("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...r})}Vo.displayName=l7.displayName;Gge.displayName;Wge.displayName;function W_({ref:e,className:t,inset:n,...r}){return f.jsx(s7,{ref:e,className:Ue("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...r})}W_.displayName=s7.displayName;function Tp({ref:e,className:t,...n}){return f.jsx(c7,{ref:e,className:Ue("-mx-1 my-1 h-px bg-muted",t),...n})}Tp.displayName=c7.displayName;var Yge=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],os=Yge.reduce((e,t)=>{const n=yG(`Primitive.${t}`),r=y.forwardRef((a,i)=>{const{asChild:o,...l}=a,u=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),qge="Label",u7=y.forwardRef((e,t)=>f.jsx(os.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));u7.displayName=qge;var Xge=u7;function pn({className:e,...t}){return f.jsx(Xge,{"data-slot":"label",className:Ue("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 rf({message:e,className:t="",vertical:n,noBorder:r}){return f.jsx("div",{className:Ue(`mt-2 rounded-md p-6 ${t}`,!r&&"border"),children:f.jsxs("p",{className:Ue("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[f.jsx("svg",{width:"40",height:"40",viewBox:"0 0 273 273",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:f.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:f.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[f.jsx("path",{d:"M49.953025,-2.10854389 C63.26892,-2.21867124 76.6185256,2.70621155 86.9019463,12.6653164 L86.9019463,12.6653164 L87.505627,13.2592944 C97.5154947,23.2654892 102.640454,36.3074513 102.880738,49.4222247 C103.08932,77.4533067 113.877287,105.391753 135.242867,126.757333 C156.613383,148.127849 184.559216,158.914875 212.568138,159.119313 L212.568138,159.119313 L213.212264,159.134159 C225.843948,159.517566 238.363557,164.434972 248.121998,173.886137 L248.121998,173.886137 L248.725621,174.480088 C258.982114,184.732164 264.11035,198.171134 264.11035,211.6101 C264.11035,225.04592 258.984514,238.481745 248.732867,248.732867 C238.592792,258.872942 225.336706,263.997882 212.046872,264.107794 C198.731075,264.21792 185.381569,259.293085 175.098248,249.334078 L175.098248,249.334078 L174.494602,248.740134 C163.75802,238.008189 158.640853,223.784027 159.143413,209.719372 C158.258245,182.640933 147.489786,155.83332 126.828333,135.171867 C106.351297,114.694831 79.8363505,103.934873 53.0237258,102.891841 L53.0237258,102.891841 L52.2811438,102.865674 C38.4791718,103.347421 24.5325234,98.4328111 13.8776628,88.1140866 L13.8776628,88.1140866 L13.2739843,87.5201168 C3.12895117,77.3789607 -1.9984796,64.1195994 -2.10841888,50.8264755 C-2.21854669,37.5105567 2.70635908,24.1609269 12.6655135,13.8774565 L12.6655135,13.8774565 L13.2594878,13.2737797 C23.4005926,3.12880025 36.659927,-1.99860507 49.953025,-2.10854389 Z"}),f.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),f.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function d7({className:e,color:t,children:n,grayscaled:r=!1}){const a=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return r?0:.2},[t,r]),i=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return r?.3:.4},[t,r]),o=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]),l=y.useMemo(()=>t||`oklch(${Math.min(i,1)} ${a} ${o})`,[o,a,i]),u=y.useMemo(()=>`oklch(${Math.min(i*2,1)} ${a} ${o})`,[o,a,i,t]),d=y.useMemo(()=>Math.floor(Math.random()*360),[o]),p=y.useMemo(()=>"1000%",[]);return f.jsx("section",{className:Ue("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:f.jsxs("div",{className:"isolate relative w-full h-full",children:[f.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${d}deg, ${l}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${p})`}}),n&&f.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function lC(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 kw="Switch",[Jge]=Wi(kw),[Qge,ebe]=Jge(kw),f7=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:l,value:u="on",onCheckedChange:d,form:p,...h}=e,[g,b]=y.useState(null),v=yn(t,k=>b(k)),x=y.useRef(!1),S=g?p||!!g.closest("form"):!0,[_,E]=Xo({prop:a,defaultProp:i??!1,onChange:d,caller:kw});return f.jsxs(Qge,{scope:n,checked:_,disabled:l,children:[f.jsx(Gt.button,{type:"button",role:"switch","aria-checked":_,"aria-required":o,"data-state":g7(_),"data-disabled":l?"":void 0,disabled:l,value:u,...h,ref:v,onClick:rt(e.onClick,k=>{E(C=>!C),S&&(x.current=k.isPropagationStopped(),x.current||k.stopPropagation())})}),S&&f.jsx(h7,{control:g,bubbles:!x.current,name:r,value:u,checked:_,required:o,disabled:l,form:p,style:{transform:"translateX(-100%)"}})]})});f7.displayName=kw;var p7="SwitchThumb",m7=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=ebe(p7,n);return f.jsx(Gt.span,{"data-state":g7(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});m7.displayName=p7;var tbe="SwitchBubbleInput",h7=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},i)=>{const o=y.useRef(null),l=yn(o,i),u=lC(n),d=JR(t);return y.useEffect(()=>{const p=o.current;if(!p)return;const h=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&b){const v=new Event("click",{bubbles:r});b.call(p,n),p.dispatchEvent(v)}},[u,n,r]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:l,style:{...a.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});h7.displayName=tbe;function g7(e){return e?"checked":"unchecked"}var b7=f7,nbe=m7;function Tw({ref:e,className:t,...n}){return f.jsx(b7,{className:Ue("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:f.jsx(nbe,{className:Ue("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")})})}Tw.displayName=b7.displayName;var v7=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"}),rbe="VisuallyHidden",y7=y.forwardRef((e,t)=>f.jsx(Gt.span,{...e,ref:t,style:{...v7,...e.style}}));y7.displayName=rbe;var abe=y7,[Nw]=Wi("Tooltip",[ul]),Rw=ul(),w7="TooltipProvider",ibe=700,K_="tooltip.open",[obe,cC]=Nw(w7),S7=e=>{const{__scopeTooltip:t,delayDuration:n=ibe,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:i}=e,o=y.useRef(!0),l=y.useRef(!1),u=y.useRef(0);return y.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),f.jsx(obe,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(u.current),o.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:y.useCallback(d=>{l.current=d},[]),disableHoverableContent:a,children:i})};S7.displayName=w7;var dm="Tooltip",[sbe,th]=Nw(dm),x7=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:l}=e,u=cC(dm,e.__scopeTooltip),d=Rw(t),[p,h]=y.useState(null),g=Kr(),b=y.useRef(0),v=o??u.disableHoverableContent,x=l??u.delayDuration,S=y.useRef(!1),[_,E]=Xo({prop:r,defaultProp:a??!1,onChange:N=>{N?(u.onOpen(),document.dispatchEvent(new CustomEvent(K_))):u.onClose(),i?.(N)},caller:dm}),k=y.useMemo(()=>_?S.current?"delayed-open":"instant-open":"closed",[_]),C=y.useCallback(()=>{window.clearTimeout(b.current),b.current=0,S.current=!1,E(!0)},[E]),R=y.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),A=y.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{S.current=!0,E(!0),b.current=0},x)},[x,E]);return y.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),f.jsx(bw,{...d,children:f.jsx(sbe,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:p,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{u.isOpenDelayedRef.current?A():C()},[u.isOpenDelayedRef,A,C]),onTriggerLeave:y.useCallback(()=>{v?R():(window.clearTimeout(b.current),b.current=0)},[R,v]),onOpen:C,onClose:R,disableHoverableContent:v,children:n})})};x7.displayName=dm;var Z_="TooltipTrigger",E7=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=th(Z_,n),i=cC(Z_,n),o=Rw(n),l=y.useRef(null),u=yn(t,l,a.onTriggerChange),d=y.useRef(!1),p=y.useRef(!1),h=y.useCallback(()=>d.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),f.jsx(qm,{asChild:!0,...o,children:f.jsx(Gt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:u,onPointerMove:rt(e.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:rt(e.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:rt(e.onPointerDown,()=>{a.open&&a.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:rt(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:rt(e.onBlur,a.onClose),onClick:rt(e.onClick,a.onClose)})})});E7.displayName=Z_;var uC="TooltipPortal",[lbe,cbe]=Nw(uC,{forceMount:void 0}),_7=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:a}=e,i=th(uC,t);return f.jsx(lbe,{scope:t,forceMount:n,children:f.jsx(Xa,{present:n||i.open,children:f.jsx(nf,{asChild:!0,container:a,children:r})})})};_7.displayName=uC;var Dd="TooltipContent",k7=y.forwardRef((e,t)=>{const n=cbe(Dd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...i}=e,o=th(Dd,e.__scopeTooltip);return f.jsx(Xa,{present:r||o.open,children:o.disableHoverableContent?f.jsx(T7,{side:a,...i,ref:t}):f.jsx(ube,{side:a,...i,ref:t})})}),ube=y.forwardRef((e,t)=>{const n=th(Dd,e.__scopeTooltip),r=cC(Dd,e.__scopeTooltip),a=y.useRef(null),i=yn(t,a),[o,l]=y.useState(null),{trigger:u,onClose:d}=n,p=a.current,{onPointerInTransitChange:h}=r,g=y.useCallback(()=>{l(null),h(!1)},[h]),b=y.useCallback((v,x)=>{const S=v.currentTarget,_={x:v.clientX,y:v.clientY},E=mbe(_,S.getBoundingClientRect()),k=hbe(_,E),C=gbe(x.getBoundingClientRect()),R=vbe([...k,...C]);l(R),h(!0)},[h]);return y.useEffect(()=>()=>g(),[g]),y.useEffect(()=>{if(u&&p){const v=S=>b(S,p),x=S=>b(S,u);return u.addEventListener("pointerleave",v),p.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",v),p.removeEventListener("pointerleave",x)}}},[u,p,b,g]),y.useEffect(()=>{if(o){const v=x=>{const S=x.target,_={x:x.clientX,y:x.clientY},E=u?.contains(S)||p?.contains(S),k=!bbe(_,o);E?g():k&&(g(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,p,o,d,g]),f.jsx(T7,{...e,ref:i})}),[dbe,fbe]=Nw(dm,{isInside:!1}),pbe=Kfe("TooltipContent"),T7=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...l}=e,u=th(Dd,n),d=Rw(n),{onClose:p}=u;return y.useEffect(()=>(document.addEventListener(K_,p),()=>document.removeEventListener(K_,p)),[p]),y.useEffect(()=>{if(u.trigger){const h=g=>{g.target?.contains(u.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,p]),f.jsx(Qd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:f.jsxs(vw,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[f.jsx(pbe,{children:r}),f.jsx(dbe,{scope:n,isInside:!0,children:f.jsx(abe,{id:u.contentId,role:"tooltip",children:a||r})})]})})});k7.displayName=Dd;var N7="TooltipArrow",R7=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=Rw(n);return fbe(N7,n).isInside?null:f.jsx(yw,{...a,...r,ref:t})});R7.displayName=N7;function mbe(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,a,i)){case i:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function hbe(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function gbe(e){const{top:t,right:n,bottom:r,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:r},{x:a,y:r}]}function bbe(e,t){const{x:n,y:r}=e;let a=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const l=t[i],u=t[o],d=l.x,p=l.y,h=u.x,g=u.y;p>r!=g>r&&n<(h-d)*(r-p)/(g-p)+d&&(a=!a)}return a}function vbe(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),ybe(t)}function ybe(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const a=e[r];for(;t.length>=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const a=e[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))n.pop();else break}n.push(a)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var wbe=S7,Sbe=x7,xbe=E7,Ebe=_7,_be=k7,kbe=R7;function dC({delayDuration:e=0,...t}){return f.jsx(wbe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Zt({...e}){return f.jsx(dC,{children:f.jsx(Sbe,{"data-slot":"tooltip",...e})})}function Yt({...e}){return f.jsx(xbe,{"data-slot":"tooltip-trigger",...e})}function qt({className:e,sideOffset:t=0,children:n,...r}){return f.jsx(Ebe,{children:f.jsxs(_be,{"data-slot":"tooltip-content",sideOffset:t,className:Ue("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,f.jsx(kbe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class Tbe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class $4{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 M4{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class P4{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class U4{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 Nbe{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 Rbe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class Cbe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class Abe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function iE(){try{return"0.13.0-canary.10"}catch{return"0.0.0"}}var Ibe={};function oE(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class z4{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout),a=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(r),!a.ok)throw new Error(`HTTP error! status: ${a.status}`)}catch{}}}function Ds(e){return`mcp_inspector_telemetry_${e}`}class Or{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=oE(),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 z4(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new z4(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(Ds("disabled"))==="true"||typeof process<"u"&&Ibe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(Ds("source")):null}static getInstance(){return Or.instance||(Or.instance=new Or),Or.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(Ds("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!oE())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(Ds("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(Ds("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=typeof window<"u"&&window.crypto&&window.crypto.getRandomValues?window.crypto:typeof crypto<"u"&&crypto.getRandomValues?crypto:void 0;if(t&&t.getRandomValues){const n=new Uint8Array(16);t.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("");return r.slice(0,8)+"-"+r.slice(8,12)+"-"+r.slice(12,16)+"-"+r.slice(16,20)+"-"+r.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&3|8).toString(16)})}async capture(t){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{const n={event:t.name,user_id:this.userId,properties:{...t.properties,mcp_use_version:iE(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=iE(),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&&oE())try{const n=iE();let r=!1,a=!1;const i=localStorage.getItem(Ds("download_version"));if(i?n>i&&(r=!0,a=!1,localStorage.setItem(Ds("download_version"),n)):(r=!0,a=!0,localStorage.setItem(Ds("download_version"),n)),r){const o={...t||{}};o.mcp_use_version=n,o.user_id=this.userId,o.event="package_download",o.first_download=a,o.language="typescript",o.source=this._source,o.package="inspector",await this._scarfClient.logEvent(o)}}catch{}}async trackInspectorOpen(t){const n=new Tbe(t);await this.capture(n)}}const Obe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function Dbe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:a}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Sampling Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),n()},children:"View Details"}),f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),r(Obe)},children:"Approve"}),f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),a()},children:"Deny"})]})]})}function Lbe({requestId:e,serverName:t,mode:n,message:r,url:a,onViewDetails:i,onOpenUrl:o,onCancel:l}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Elicitation Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",r]}),n==="url"&&a&&f.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:a})]}),f.jsxs("div",{className:"flex gap-2 flex-wrap",children:[f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),i()},children:"View Details"}),n==="url"&&o&&f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),o()},children:"Open URL"}),f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),l()},children:"Cancel"})]})]})}const Ob=()=>{},Db=()=>{},Lb=()=>{},jb=()=>{},C7=y.createContext(null);function fC(){const e=y.use(C7);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function jbe({url:e,name:t,proxyConfig:n,transportType:r,connectionId:a,onUpdate:i,onRemove:o}){const l=typeof window<"u"?new URL("/inspector/oauth/callback",window.location.origin).toString():"/inspector/oauth/callback";let u=e,d={};if(n?.proxyAddress){const j=new URL(n.proxyAddress),P=new URL(e);u=`${j.origin}${j.pathname}${P.pathname}${P.search}`,d["X-Target-URL"]=e}n?.customHeaders&&(d={...d,...n.customHeaders});const[p,h]=y.useState([]),g=y.useRef(0),[b,v]=y.useState([]),x=y.useRef(0),S=y.useMemo(()=>p.map(j=>({id:j.id,request:j.request,timestamp:j.timestamp,serverName:j.serverName})),[p]),_=y.useMemo(()=>b.map(j=>({id:j.id,request:j.request,timestamp:j.timestamp,serverName:j.serverName})),[b]),E=y.useRef(null),[k,C]=y.useState(!1),R=y.useRef(!1);y.useEffect(()=>{typeof window<"u"&&!R.current&&(R.current=!0,pr(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(j=>{E.current=j.wrapTransportForLogging,C(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(j=>{console.error("[McpContext] Failed to load transport wrapper:",j)}))},[]);const A=y.useMemo(()=>{if(!(!k||!E.current))return(j,P)=>{const B=a;return console.log("[McpContext] Applying transport wrapper, serverId:",B,"from connector:",P),E.current(j,B)}},[k,a]),N=`mcp-inspector-notifications-${a}`,O=500,[$,M]=y.useState([]);y.useEffect(()=>{try{const j=localStorage.getItem(N);if(j){const P=JSON.parse(j);Array.isArray(P)&&M(P)}}catch(j){console.error("Failed to load notifications from localStorage:",j)}},[N]),y.useEffect(()=>{try{localStorage.setItem(N,JSON.stringify($))}catch(j){console.error("Failed to save notifications to localStorage:",j)}},[$,N]);const z=y.useCallback(j=>{M(P=>P.map(B=>B.id===j?{...B,read:!0}:B))},[]),W=y.useCallback(()=>{M(j=>j.map(P=>({...P,read:!0})))},[]),J=y.useCallback(()=>{M([])},[]),X=y.useCallback(j=>{M(P=>{const B=[j,...P];return B.length>O?B.slice(0,O):B})},[]),re=y.useCallback((j,P)=>{h(B=>{const K=B.find(ee=>ee.id===j);return K?(K.resolve(P),B.filter(ee=>ee.id!==j)):B})},[]),H=y.useCallback((j,P)=>{h(B=>{const K=B.find(ee=>ee.id===j);return K?(K.reject(new Error(P||"User rejected sampling request")),B.filter(ee=>ee.id!==j)):B})},[]),Z=y.useCallback((j,P)=>{v(B=>{const K=B.find(ee=>ee.id===j);return K?(K.resolve(P),B.filter(ee=>ee.id!==j)):B})},[]),G=y.useCallback((j,P)=>{v(B=>{const K=B.find(ee=>ee.id===j);return K?(K.reject(new Error(P||"User rejected elicitation request")),B.filter(ee=>ee.id!==j)):B})},[]),ae=y.useCallback(async j=>new Promise((P,B)=>{const K=`sampling-${g.current++}`,ee={id:K,request:{params:j},timestamp:Date.now(),serverName:t,resolve:P,reject:B};h(ie=>[...ie,ee]),typeof window<"u"&&pr(async()=>{const{toast:ie}=await Promise.resolve().then(()=>K4);return{toast:ie}},void 0).then(({toast:ie})=>{const ue=ie(f.jsx(Dbe,{requestId:K,serverName:t,onViewDetails:()=>{const Q=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:K}});window.dispatchEvent(Q),ie.dismiss(ue)},onApprove:Q=>{h(q=>{const le=q.find(ve=>ve.id===K);return le?(le.resolve(Q),ie.success("Sampling request approved"),q.filter(ve=>ve.id!==K)):q}),ie.dismiss(ue)},onDeny:()=>{h(Q=>{const q=Q.find(le=>le.id===K);return q?(q.reject(new Error("User denied sampling request from toast")),ie.error("Sampling request denied"),Q.filter(le=>le.id!==K)):Q}),ie.dismiss(ue)}}),{duration:5e3})})}),[t]),ne=y.useCallback(async j=>new Promise((P,B)=>{const K=`elicitation-${x.current++}`,ee={id:K,request:j,timestamp:Date.now(),serverName:t,resolve:P,reject:B};v(ie=>[...ie,ee]),typeof window<"u"&&pr(async()=>{const{toast:ie}=await Promise.resolve().then(()=>K4);return{toast:ie}},void 0).then(({toast:ie})=>{const ue=ie(f.jsx(Lbe,{requestId:K,serverName:t,mode:j.mode||"form",message:j.message,url:j.mode==="url"?j.url:void 0,onViewDetails:()=>{const Q=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:K}});window.dispatchEvent(Q),ie.dismiss(ue)},onOpenUrl:j.mode==="url"?()=>{window.open(j.url,"_blank"),ie.dismiss(ue)}:void 0,onCancel:()=>{v(Q=>{const q=Q.find(le=>le.id===K);return q?(q.reject(new Error("User cancelled elicitation request from toast")),ie.error("Elicitation request cancelled"),Q.filter(le=>le.id!==K)):Q}),ie.dismiss(ue)}}),{duration:5e3})})}),[t]),L=bR({url:u,callbackUrl:l,customHeaders:Object.keys(d).length>0?d:void 0,transportType:r||"http",preventAutoAuth:!0,useRedirectFlow:!0,enabled:k,wrapTransport:A,onNotification:j=>{X({id:globalThis.crypto.randomUUID(),method:j.method,params:j.params,timestamp:Date.now(),read:!1})},samplingCallback:ae,onElicitation:ne}),V=y.useRef(i),F=y.useRef(null);return y.useEffect(()=>{V.current=i},[i]),y.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{L.state==="ready"&&L.serverInfo&&console.log("[McpContext] Server info available:",L.serverInfo);const j=$.filter(K=>!K.read).length,P={id:a,url:e,name:L.serverInfo?.name||t,state:L.state,tools:L.tools,resources:L.resources,prompts:L.prompts,error:L.error??null,authUrl:L.authUrl??null,customHeaders:d,transportType:r,proxyConfig:n,serverInfo:L.serverInfo,capabilities:L.capabilities,notifications:$,unreadNotificationCount:j,markNotificationRead:z,markAllNotificationsRead:W,clearNotifications:J,pendingSamplingRequests:S,approveSampling:re,rejectSampling:H,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:L.callTool,readResource:L.readResource,listPrompts:L.listPrompts,getPrompt:L.getPrompt,authenticate:L.authenticate,retry:L.retry,clearStorage:L.clearStorage,disconnect:L.disconnect,client:L.client},B=F.current;(!B||B.state!==P.state||B.error!==P.error||B.authUrl!==P.authUrl||B.name!==P.name||B.tools.length!==P.tools.length||B.resources.length!==P.resources.length||B.prompts.length!==P.prompts.length||B.serverInfo!==P.serverInfo||B.capabilities!==P.capabilities||B.notifications.length!==P.notifications.length||B.unreadNotificationCount!==P.unreadNotificationCount||B.pendingSamplingRequests.length!==P.pendingSamplingRequests.length||B.pendingElicitationRequests.length!==P.pendingElicitationRequests.length||!B.client)&&(F.current=P,V.current(P))});else{const j=$.filter(K=>!K.read).length,P={id:a,url:e,name:L.serverInfo?.name||t,state:L.state,tools:L.tools,resources:L.resources,prompts:L.prompts,error:L.error??null,authUrl:L.authUrl??null,customHeaders:d,transportType:r,proxyConfig:n,serverInfo:L.serverInfo,capabilities:L.capabilities,notifications:$,unreadNotificationCount:j,markNotificationRead:z,markAllNotificationsRead:W,clearNotifications:J,pendingSamplingRequests:S,approveSampling:re,rejectSampling:H,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:L.callTool,readResource:L.readResource,listPrompts:L.listPrompts,getPrompt:L.getPrompt,authenticate:L.authenticate,retry:L.retry,clearStorage:L.clearStorage,disconnect:L.disconnect,client:L.client},B=F.current;(!B||B.state!==P.state||B.error!==P.error||B.authUrl!==P.authUrl||B.name!==P.name||B.tools.length!==P.tools.length||B.resources.length!==P.resources.length||B.prompts.length!==P.prompts.length||B.serverInfo!==P.serverInfo||B.capabilities!==P.capabilities||B.notifications.length!==P.notifications.length||B.unreadNotificationCount!==P.unreadNotificationCount||B.pendingSamplingRequests.length!==P.pendingSamplingRequests.length||B.pendingElicitationRequests.length!==P.pendingElicitationRequests.length||!B.client)&&(F.current=P,V.current(P))}},[e,t,r,n,d,a,L.state,L.tools,L.resources,L.prompts,L.error,L.authUrl,L.serverInfo,L.capabilities,L.client,$,z,W,J,L.callTool,L.readResource,L.listPrompts,L.getPrompt,L.authenticate,L.retry,L.clearStorage,p,re,H,_,Z,G]),null}function $be({children:e}){const[t,n]=y.useState([]),[r,a]=y.useState(!1),[i,o]=y.useState(!0),[l,u]=y.useState([]);y.useEffect(()=>{try{const S=localStorage.getItem("mcp-inspector-connections");if(S){const E=JSON.parse(S);Array.isArray(E)&&(u(E),n(E.map(k=>({id:k.id||k.url,url:k.url,name:k.name||"MCP Server",state:"discovering",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k.proxyConfig?.customHeaders,transportType:k.transportType,proxyConfig:k.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Ob,rejectSampling:Db,pendingElicitationRequests:[],approveElicitation:Lb,rejectElicitation:jb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&o(_==="true")}catch(S){console.error("Failed to load connections from localStorage:",S)}finally{a(!0)}},[]),y.useEffect(()=>{r&&localStorage.setItem("mcp-inspector-connections",JSON.stringify(l))},[l,r]),y.useEffect(()=>{r&&localStorage.setItem("mcp-inspector-auto-connect",String(i))},[i,r]);const d=y.useCallback((S,_,E,k)=>{const C=l.find(N=>N.url===S),R=t.find(N=>N.url===S);if(C&&R){if(JSON.stringify(C.proxyConfig)!==JSON.stringify(E)&&E){u(O=>O.filter($=>$.url!==S)),n(O=>O.filter($=>$.url!==S)),setTimeout(()=>{const O={id:S,url:S,name:_||C.name||"MCP Server",proxyConfig:E,transportType:k||C.transportType};u($=>[...$,O]),n($=>[...$,{id:S,url:S,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||C.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Ob,rejectSampling:Db,pendingElicitationRequests:[],approveElicitation:Lb,rejectElicitation:jb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!R){(E||k)&&u(N=>N.map(O=>O.url===S?{...O,proxyConfig:E||O.proxyConfig,transportType:k||O.transportType,name:_||O.name}:O)),n(N=>[...N,{id:C.id||S,url:S,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||C.proxyConfig?.customHeaders,transportType:k||C.transportType,proxyConfig:E||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Ob,rejectSampling:Db,pendingElicitationRequests:[],approveElicitation:Lb,rejectElicitation:jb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const A={id:S,url:S,name:_||"MCP Server",proxyConfig:E,transportType:k};u(N=>[...N,A]),n(N=>[...N,{id:S,url:S,name:_||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Ob,rejectSampling:Db,pendingElicitationRequests:[],approveElicitation:Lb,rejectElicitation:jb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[l,t]),p=y.useCallback(S=>{const _=t.find(k=>k.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())),u(k=>k.filter(C=>C.id!==S)),n(k=>k.filter(C=>C.id!==S));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const C=JSON.parse(E).filter(R=>(R.id||R.url)!==S);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(k){console.error("Failed to update localStorage on remove:",k)}Or.getInstance().capture(new Rbe({serverId:S}))},[t]),h=y.useCallback((S,_)=>{u(E=>E.map(k=>k.id===S||k.url===S?{...k,..._}:k)),n(E=>E.map(k=>k.id===S?{...k,..._}:k))},[]),g=y.useCallback(S=>{n(_=>{const E=_.findIndex(R=>R.id===S.id);if(E===-1)return _;const k=_[E];if(k.state===S.state&&k.tools===S.tools&&k.resources===S.resources&&k.prompts===S.prompts&&k.error===S.error&&k.serverInfo===S.serverInfo&&k.client===S.client&&k.notifications===S.notifications&&k.unreadNotificationCount===S.unreadNotificationCount&&k.pendingSamplingRequests.length===S.pendingSamplingRequests.length&&k.pendingElicitationRequests.length===S.pendingElicitationRequests.length)return _;const C=[..._];return C[E]=S,C})},[]),b=y.useCallback(S=>{console.log("Connect requested for:",S)},[]),v=y.useCallback(S=>{console.log("Disconnect requested for:",S)},[]),x=y.useMemo(()=>({connections:t,addConnection:d,removeConnection:p,updateConnectionConfig:h,autoConnect:i,setAutoConnect:o,connectServer:b,disconnectServer:v,configLoaded:r}),[t,d,p,h,i,b,v,r]);return f.jsxs(C7.Provider,{value:x,children:[e,r&&i&&l.map(S=>{const _=`${S.id||S.url}-${S.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",S.proxyConfig),f.jsx(jbe,{url:S.url,name:S.name,proxyConfig:S.proxyConfig,transportType:S.transportType,connectionId:S.id||S.url,onUpdate:g,onRemove:()=>p(S.id||S.url)},_)})]})}const Mbe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pbe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),F4=e=>{const t=Pbe(e);return t.charAt(0).toUpperCase()+t.slice(1)},A7=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Ube=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var zbe={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 Fbe=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:o,...l},u)=>y.createElement("svg",{ref:u,...zbe,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:A7("lucide",a),...!i&&!Ube(l)&&{"aria-hidden":"true"},...l},[...o.map(([d,p])=>y.createElement(d,p)),...Array.isArray(i)?i:[i]]));const pt=(e,t)=>{const n=y.forwardRef(({className:r,...a},i)=>y.createElement(Fbe,{ref:i,iconNode:t,className:A7(`lucide-${Mbe(F4(e))}`,`lucide-${e}`,r),...a}));return n.displayName=F4(e),n};const Bbe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Hbe=pt("arrow-down-to-line",Bbe);const Vbe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Gbe=pt("arrow-up-from-line",Vbe);const Wbe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Kbe=pt("arrow-up",Wbe);const Zbe=[["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"}]],pC=pt("bell",Zbe);const Ybe=[["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"}]],I7=pt("brush",Ybe);const qbe=[["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"}]],Xbe=pt("bug",qbe);const Jbe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ba=pt("check",Jbe);const Qbe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],_c=pt("chevron-down",Qbe);const eve=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],O7=pt("chevron-right",eve);const tve=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Cw=pt("chevron-left",tve);const nve=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],rve=pt("chevron-up",nve);const ave=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],ive=pt("chevrons-up-down",ave);const ove=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],B4=pt("circle-minus",ove);const sve=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ld=pt("clock",sve);const lve=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],mC=pt("code",lve);const cve=[["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"}]],uve=pt("cog",cve);const dve=[["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"}]],fve=pt("command",dve);const pve=[["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"}]],Zr=pt("copy",pve);const mve=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Aw=pt("database",mve);const hve=[["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"}]],nh=pt("download",hve);const gve=[["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"}]],bve=pt("ellipsis-vertical",gve);const vve=[["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"}]],Y_=pt("external-link",vve);const yve=[["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"}]],D7=pt("eye-off",yve);const wve=[["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"}]],q_=pt("eye",wve);const Sve=[["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"}]],xve=pt("file-code",Sve);const Eve=[["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"}]],_ve=pt("file-image",Eve);const kve=[["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"}]],hC=pt("file-text",kve);const Tve=[["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"}]],Nve=pt("file",Tve);const Rve=[["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"}]],Cve=pt("folder-open",Rve);const Ave=[["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"}]],Ive=pt("globe",Ave);const Ove=[["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"}]],Dve=pt("grip-vertical",Ove);const Lve=[["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"}]],L7=pt("hash",Lve);const jve=[["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"}]],ey=pt("history",jve);const $ve=[["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"}]],j7=pt("key",$ve);const Mve=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],el=pt("loader-circle",Mve);const Pve=[["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"}]],gC=pt("maximize-2",Pve);const Uve=[["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"}]],bC=pt("maximize",Uve);const zve=[["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"}]],Fve=pt("message-circle",zve);const Bve=[["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"}]],fm=pt("message-square",Bve);const Hve=[["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"}]],Vve=pt("minimize",Hve);const Gve=[["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"}]],H4=pt("monitor",Gve);const Wve=[["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"}]],Kve=pt("moon",Wve);const Zve=[["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"}]],Yve=pt("picture-in-picture",Zve);const qve=[["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"}]],$7=pt("play",qve);const Xve=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],M7=pt("plus",Xve);const Jve=[["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"}]],V4=pt("rotate-ccw",Jve);const Qve=[["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"}]],vC=pt("save",Qve);const eye=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],af=pt("search",eye);const tye=[["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"}]],nye=pt("send",tye);const rye=[["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"}]],aye=pt("server",rye);const iye=[["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"}]],qu=pt("settings",iye);const oye=[["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"}]],sye=pt("shield",oye);const lye=[["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"}]],cye=pt("sparkles",lye);const uye=[["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"}]],P7=pt("square-check-big",uye);const dye=[["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"}]],fye=pt("square-pen",dye);const pye=[["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"}]],mye=pt("sun-dim",pye);const hye=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],sE=pt("terminal",hye);const gye=[["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"}]],tl=pt("trash-2",gye);const bye=[["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"}]],vye=pt("trash",bye);const yye=[["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"}]],uc=pt("wrench",yye);const wye=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],po=pt("x",wye);const Sye=[["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"}]],pm=pt("zap",Sye);function xye(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 Eye=e=>{switch(e){case"success":return Tye;case"info":return Rye;case"warning":return Nye;case"error":return Cye;default:return null}},_ye=Array(12).fill(0),kye=({visible:e,className:t})=>de.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},de.createElement("div",{className:"sonner-spinner"},_ye.map((n,r)=>de.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),Tye=de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},de.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"})),Nye=de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},de.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"})),Rye=de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},de.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"})),Cye=de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},de.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"})),Aye=de.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"},de.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),de.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Iye=()=>{const[e,t]=de.useState(document.hidden);return de.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let X_=1;class Oye{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:r,...a}=t,i=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:X_++,o=this.toasts.find(u=>u.id===i),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),o?this.toasts=this.toasts.map(u=>u.id===i?(this.publish({...u,...t,id:i,title:r}),{...u,...t,id:i,dismissible:l,title:r}):u):this.addToast({title:r,...a,dismissible:l,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(r=>r({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 r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const a=Promise.resolve(t instanceof Function?t():t);let i=r!==void 0,o;const l=a.then(async d=>{if(o=["resolve",d],de.isValidElement(d))i=!1,this.create({id:r,type:"default",message:d});else if(Lye(d)&&!d.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,v=typeof h=="object"&&!de.isValidElement(h)?h:{message:h};this.create({id:r,type:"error",description:g,...v})}else if(d instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,v=typeof h=="object"&&!de.isValidElement(h)?h:{message:h};this.create({id:r,type:"error",description:g,...v})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,v=typeof h=="object"&&!de.isValidElement(h)?h:{message:h};this.create({id:r,type:"success",description:g,...v})}}).catch(async d=>{if(o=["reject",d],n.error!==void 0){i=!1;const p=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,b=typeof p=="object"&&!de.isValidElement(p)?p:{message:p};this.create({id:r,type:"error",description:h,...b})}}).finally(()=>{i&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((d,p)=>l.then(()=>o[0]==="reject"?p(o[1]):d(o[1])).catch(p));return typeof r!="string"&&typeof r!="number"?{unwrap:u}:Object.assign(r,{unwrap:u})},this.custom=(t,n)=>{const r=n?.id||X_++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Ra=new Oye,Dye=(e,t)=>{const n=t?.id||X_++;return Ra.addToast({title:e,...t,id:n}),n},Lye=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jye=Dye,$ye=()=>Ra.toasts,Mye=()=>Ra.getActiveToasts(),vn=Object.assign(jye,{success:Ra.success,info:Ra.info,warning:Ra.warning,error:Ra.error,custom:Ra.custom,message:Ra.message,promise:Ra.promise,dismiss:Ra.dismiss,loading:Ra.loading},{getHistory:$ye,getToasts:Mye});xye("[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 $b(e){return e.label!==void 0}const Pye=3,Uye="24px",zye="16px",G4=4e3,Fye=356,Bye=14,Hye=45,Vye=200;function Ji(...e){return e.filter(Boolean).join(" ")}function Gye(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const Wye=e=>{var t,n,r,a,i,o,l,u,d;const{invert:p,toast:h,unstyled:g,interacting:b,setHeights:v,visibleToasts:x,heights:S,index:_,toasts:E,expanded:k,removeToast:C,defaultRichColors:R,closeButton:A,style:N,cancelButtonStyle:O,actionButtonStyle:$,className:M="",descriptionClassName:z="",duration:W,position:J,gap:X,expandByDefault:re,classNames:H,icons:Z,closeButtonAriaLabel:G="Close toast"}=e,[ae,ne]=de.useState(null),[L,V]=de.useState(null),[F,j]=de.useState(!1),[P,B]=de.useState(!1),[K,ee]=de.useState(!1),[ie,ue]=de.useState(!1),[Q,q]=de.useState(!1),[le,ve]=de.useState(0),[oe,Ae]=de.useState(0),Je=de.useRef(h.duration||W||G4),ke=de.useRef(null),Re=de.useRef(null),Ze=_===0,me=_+1<=x,Le=h.type,Ke=h.dismissible!==!1,_e=h.className||"",vt=h.descriptionClassName||"",gt=de.useMemo(()=>S.findIndex(at=>at.toastId===h.id)||0,[S,h.id]),wt=de.useMemo(()=>{var at;return(at=h.closeButton)!=null?at:A},[h.closeButton,A]),Tt=de.useMemo(()=>h.duration||W||G4,[h.duration,W]),At=de.useRef(0),Cn=de.useRef(0),mr=de.useRef(0),Ut=de.useRef(null),[He,Be]=J.split("-"),Te=de.useMemo(()=>S.reduce((at,it,kt)=>kt>=gt?at:at+it.height,0),[S,gt]),Pe=Iye(),Ve=h.invert||p,Qe=Le==="loading";Cn.current=de.useMemo(()=>gt*X+Te,[gt,Te]),de.useEffect(()=>{Je.current=Tt},[Tt]),de.useEffect(()=>{j(!0)},[]),de.useEffect(()=>{const at=Re.current;if(at){const it=at.getBoundingClientRect().height;return Ae(it),v(kt=>[{toastId:h.id,height:it,position:h.position},...kt]),()=>v(kt=>kt.filter(Mt=>Mt.toastId!==h.id))}},[v,h.id]),de.useLayoutEffect(()=>{if(!F)return;const at=Re.current,it=at.style.height;at.style.height="auto";const kt=at.getBoundingClientRect().height;at.style.height=it,Ae(kt),v(Mt=>Mt.find(En=>En.toastId===h.id)?Mt.map(En=>En.toastId===h.id?{...En,height:kt}:En):[{toastId:h.id,height:kt,position:h.position},...Mt])},[F,h.title,h.description,v,h.id,h.jsx,h.action,h.cancel]);const ot=de.useCallback(()=>{B(!0),ve(Cn.current),v(at=>at.filter(it=>it.toastId!==h.id)),setTimeout(()=>{C(h)},Vye)},[h,C,v,Cn]);de.useEffect(()=>{if(h.promise&&Le==="loading"||h.duration===1/0||h.type==="loading")return;let at;return k||b||Pe?(()=>{if(mr.current<At.current){const Mt=new Date().getTime()-At.current;Je.current=Je.current-Mt}mr.current=new Date().getTime()})():(()=>{Je.current!==1/0&&(At.current=new Date().getTime(),at=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),ot()},Je.current))})(),()=>clearTimeout(at)},[k,b,h,Le,Pe,ot]),de.useEffect(()=>{h.delete&&(ot(),h.onDismiss==null||h.onDismiss.call(h,h))},[ot,h.delete]);function $t(){var at;if(Z?.loading){var it;return de.createElement("div",{className:Ji(H?.loader,h==null||(it=h.classNames)==null?void 0:it.loader,"sonner-loader"),"data-visible":Le==="loading"},Z.loading)}return de.createElement(kye,{className:Ji(H?.loader,h==null||(at=h.classNames)==null?void 0:at.loader),visible:Le==="loading"})}const Rt=h.icon||Z?.[Le]||Eye(Le);var Xt,un;return de.createElement("li",{tabIndex:0,ref:Re,className:Ji(M,_e,H?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,H?.default,H?.[Le],h==null||(n=h.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(Xt=h.richColors)!=null?Xt:R,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":F,"data-promise":!!h.promise,"data-swiped":Q,"data-removed":P,"data-visible":me,"data-y-position":He,"data-x-position":Be,"data-index":_,"data-front":Ze,"data-swiping":K,"data-dismissible":Ke,"data-type":Le,"data-invert":Ve,"data-swipe-out":ie,"data-swipe-direction":L,"data-expanded":!!(k||re&&F),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${P?le:Cn.current}px`,"--initial-height":re?"auto":`${oe}px`,...N,...h.style},onDragEnd:()=>{ee(!1),ne(null),Ut.current=null},onPointerDown:at=>{at.button!==2&&(Qe||!Ke||(ke.current=new Date,ve(Cn.current),at.target.setPointerCapture(at.pointerId),at.target.tagName!=="BUTTON"&&(ee(!0),Ut.current={x:at.clientX,y:at.clientY})))},onPointerUp:()=>{var at,it,kt;if(ie||!Ke)return;Ut.current=null;const Mt=Number(((at=Re.current)==null?void 0:at.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),nr=Number(((it=Re.current)==null?void 0:it.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),En=new Date().getTime()-((kt=ke.current)==null?void 0:kt.getTime()),qn=ae==="x"?Mt:nr,se=Math.abs(qn)/En;if(Math.abs(qn)>=Hye||se>.11){ve(Cn.current),h.onDismiss==null||h.onDismiss.call(h,h),V(ae==="x"?Mt>0?"right":"left":nr>0?"down":"up"),ot(),ue(!0);return}else{var pe,ge;(pe=Re.current)==null||pe.style.setProperty("--swipe-amount-x","0px"),(ge=Re.current)==null||ge.style.setProperty("--swipe-amount-y","0px")}q(!1),ee(!1),ne(null)},onPointerMove:at=>{var it,kt,Mt;if(!Ut.current||!Ke||((it=window.getSelection())==null?void 0:it.toString().length)>0)return;const En=at.clientY-Ut.current.y,qn=at.clientX-Ut.current.x;var se;const pe=(se=e.swipeDirections)!=null?se:Gye(J);!ae&&(Math.abs(qn)>1||Math.abs(En)>1)&&ne(Math.abs(qn)>Math.abs(En)?"x":"y");let ge={x:0,y:0};const $e=De=>1/(1.5+Math.abs(De)/20);if(ae==="y"){if(pe.includes("top")||pe.includes("bottom"))if(pe.includes("top")&&En<0||pe.includes("bottom")&&En>0)ge.y=En;else{const De=En*$e(En);ge.y=Math.abs(De)<Math.abs(En)?De:En}}else if(ae==="x"&&(pe.includes("left")||pe.includes("right")))if(pe.includes("left")&&qn<0||pe.includes("right")&&qn>0)ge.x=qn;else{const De=qn*$e(qn);ge.x=Math.abs(De)<Math.abs(qn)?De:qn}(Math.abs(ge.x)>0||Math.abs(ge.y)>0)&&q(!0),(kt=Re.current)==null||kt.style.setProperty("--swipe-amount-x",`${ge.x}px`),(Mt=Re.current)==null||Mt.style.setProperty("--swipe-amount-y",`${ge.y}px`)}},wt&&!h.jsx&&Le!=="loading"?de.createElement("button",{"aria-label":G,"data-disabled":Qe,"data-close-button":!0,onClick:Qe||!Ke?()=>{}:()=>{ot(),h.onDismiss==null||h.onDismiss.call(h,h)},className:Ji(H?.closeButton,h==null||(r=h.classNames)==null?void 0:r.closeButton)},(un=Z?.close)!=null?un:Aye):null,(Le||h.icon||h.promise)&&h.icon!==null&&(Z?.[Le]!==null||h.icon)?de.createElement("div",{"data-icon":"",className:Ji(H?.icon,h==null||(a=h.classNames)==null?void 0:a.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||$t():null,h.type!=="loading"?Rt:null):null,de.createElement("div",{"data-content":"",className:Ji(H?.content,h==null||(i=h.classNames)==null?void 0:i.content)},de.createElement("div",{"data-title":"",className:Ji(H?.title,h==null||(o=h.classNames)==null?void 0:o.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?de.createElement("div",{"data-description":"",className:Ji(z,vt,H?.description,h==null||(l=h.classNames)==null?void 0:l.description)},typeof h.description=="function"?h.description():h.description):null),de.isValidElement(h.cancel)?h.cancel:h.cancel&&$b(h.cancel)?de.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:at=>{$b(h.cancel)&&Ke&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,at),ot())},className:Ji(H?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,de.isValidElement(h.action)?h.action:h.action&&$b(h.action)?de.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||$,onClick:at=>{$b(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,at),!at.defaultPrevented&&ot())},className:Ji(H?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function W4(){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 Kye(e,t){const n={};return[e,t].forEach((r,a)=>{const i=a===1,o=i?"--mobile-offset":"--offset",l=i?zye:Uye;function u(d){["top","right","bottom","left"].forEach(p=>{n[`${o}-${p}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?u(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${o}-${d}`]=l:n[`${o}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):u(l)}),n}const U7=de.forwardRef(function(t,n){const{id:r,invert:a,position:i="bottom-right",hotkey:o=["altKey","KeyT"],expand:l,closeButton:u,className:d,offset:p,mobileOffset:h,theme:g="light",richColors:b,duration:v,style:x,visibleToasts:S=Pye,toastOptions:_,dir:E=W4(),gap:k=Bye,icons:C,containerAriaLabel:R="Notifications"}=t,[A,N]=de.useState([]),O=de.useMemo(()=>r?A.filter(F=>F.toasterId===r):A.filter(F=>!F.toasterId),[A,r]),$=de.useMemo(()=>Array.from(new Set([i].concat(O.filter(F=>F.position).map(F=>F.position)))),[O,i]),[M,z]=de.useState([]),[W,J]=de.useState(!1),[X,re]=de.useState(!1),[H,Z]=de.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=de.useRef(null),ae=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),ne=de.useRef(null),L=de.useRef(!1),V=de.useCallback(F=>{N(j=>{var P;return(P=j.find(B=>B.id===F.id))!=null&&P.delete||Ra.dismiss(F.id),j.filter(({id:B})=>B!==F.id)})},[]);return de.useEffect(()=>Ra.subscribe(F=>{if(F.dismiss){requestAnimationFrame(()=>{N(j=>j.map(P=>P.id===F.id?{...P,delete:!0}:P))});return}setTimeout(()=>{$G.flushSync(()=>{N(j=>{const P=j.findIndex(B=>B.id===F.id);return P!==-1?[...j.slice(0,P),{...j[P],...F},...j.slice(P+1)]:[F,...j]})})})}),[A]),de.useEffect(()=>{if(g!=="system"){Z(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;const F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:j})=>{Z(j?"dark":"light")})}catch{F.addListener(({matches:P})=>{try{Z(P?"dark":"light")}catch(B){console.error(B)}})}},[g]),de.useEffect(()=>{A.length<=1&&J(!1)},[A]),de.useEffect(()=>{const F=j=>{var P;if(o.every(ee=>j[ee]||j.code===ee)){var K;J(!0),(K=G.current)==null||K.focus()}j.code==="Escape"&&(document.activeElement===G.current||(P=G.current)!=null&&P.contains(document.activeElement))&&J(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[o]),de.useEffect(()=>{if(G.current)return()=>{ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null,L.current=!1)}},[G.current]),de.createElement("section",{ref:n,"aria-label":`${R} ${ae}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},$.map((F,j)=>{var P;const[B,K]=F.split("-");return O.length?de.createElement("ol",{key:F,dir:E==="auto"?W4():E,tabIndex:-1,ref:G,className:d,"data-sonner-toaster":!0,"data-sonner-theme":H,"data-y-position":B,"data-x-position":K,style:{"--front-toast-height":`${((P=M[0])==null?void 0:P.height)||0}px`,"--width":`${Fye}px`,"--gap":`${k}px`,...x,...Kye(p,h)},onBlur:ee=>{L.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(L.current=!1,ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||L.current||(L.current=!0,ne.current=ee.relatedTarget)},onMouseEnter:()=>J(!0),onMouseMove:()=>J(!0),onMouseLeave:()=>{X||J(!1)},onDragEnd:()=>J(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||re(!0)},onPointerUp:()=>re(!1)},O.filter(ee=>!ee.position&&j===0||ee.position===F).map((ee,ie)=>{var ue,Q;return de.createElement(Wye,{key:ee.id,icons:C,index:ie,toast:ee,defaultRichColors:b,duration:(ue=_?.duration)!=null?ue:v,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:a,visibleToasts:S,closeButton:(Q=_?.closeButton)!=null?Q:u,interacting:X,position:F,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:V,toasts:O.filter(q=>q.position==ee.position),heights:M.filter(q=>q.position==ee.position),setHeights:z,expandByDefault:l,gap:k,expanded:W,swipeDirections:t.swipeDirections})})):null}))}),K4=Object.freeze(Object.defineProperty({__proto__:null,Toaster:U7,toast:vn},Symbol.toStringTag,{value:"Module"}));var Iw="Dialog",[z7]=Wi(Iw),[Zye,Ki]=z7(Iw),F7=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=y.useRef(null),u=y.useRef(null),[d,p]=Xo({prop:r,defaultProp:a??!1,onChange:i,caller:Iw});return f.jsx(Zye,{scope:t,triggerRef:l,contentRef:u,contentId:Kr(),titleId:Kr(),descriptionId:Kr(),open:d,onOpenChange:p,onOpenToggle:y.useCallback(()=>p(h=>!h),[p]),modal:o,children:n})};F7.displayName=Iw;var B7="DialogTrigger",H7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(B7,n),i=yn(t,a.triggerRef);return f.jsx(Gt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":SC(a.open),...r,ref:i,onClick:rt(e.onClick,a.onOpenToggle)})});H7.displayName=B7;var yC="DialogPortal",[Yye,V7]=z7(yC,{forceMount:void 0}),G7=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,i=Ki(yC,t);return f.jsx(Yye,{scope:t,forceMount:n,children:y.Children.map(r,o=>f.jsx(Xa,{present:n||i.open,children:f.jsx(nf,{asChild:!0,container:a,children:o})}))})};G7.displayName=yC;var ty="DialogOverlay",W7=y.forwardRef((e,t)=>{const n=V7(ty,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,i=Ki(ty,e.__scopeDialog);return i.modal?f.jsx(Xa,{present:r||i.open,children:f.jsx(Xye,{...a,ref:t})}):null});W7.displayName=ty;var qye=lc("DialogOverlay.RemoveScroll"),Xye=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(ty,n);return f.jsx(Jm,{as:qye,allowPinchZoom:!0,shards:[a.contentRef],children:f.jsx(Gt.div,{"data-state":SC(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),dc="DialogContent",K7=y.forwardRef((e,t)=>{const n=V7(dc,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,i=Ki(dc,e.__scopeDialog);return f.jsx(Xa,{present:r||i.open,children:i.modal?f.jsx(Jye,{...a,ref:t}):f.jsx(Qye,{...a,ref:t})})});K7.displayName=dc;var Jye=y.forwardRef((e,t)=>{const n=Ki(dc,e.__scopeDialog),r=y.useRef(null),a=yn(t,n.contentRef,r);return y.useEffect(()=>{const i=r.current;if(i)return ww(i)},[]),f.jsx(Z7,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:rt(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:rt(e.onPointerDownOutside,i=>{const o=i.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&i.preventDefault()}),onFocusOutside:rt(e.onFocusOutside,i=>i.preventDefault())})}),Qye=y.forwardRef((e,t)=>{const n=Ki(dc,e.__scopeDialog),r=y.useRef(!1),a=y.useRef(!1);return f.jsx(Z7,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;n.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Z7=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=Ki(dc,n),u=y.useRef(null),d=yn(t,u);return fw(),f.jsxs(f.Fragment,{children:[f.jsx(Zm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:f.jsx(Qd,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":SC(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(ewe,{titleId:l.titleId}),f.jsx(nwe,{contentRef:u,descriptionId:l.descriptionId})]})]})}),wC="DialogTitle",Y7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(wC,n);return f.jsx(Gt.h2,{id:a.titleId,...r,ref:t})});Y7.displayName=wC;var q7="DialogDescription",X7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(q7,n);return f.jsx(Gt.p,{id:a.descriptionId,...r,ref:t})});X7.displayName=q7;var J7="DialogClose",Q7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(J7,n);return f.jsx(Gt.button,{type:"button",...r,ref:t,onClick:rt(e.onClick,()=>a.onOpenChange(!1))})});Q7.displayName=J7;function SC(e){return e?"open":"closed"}var eK="DialogTitleWarning",[kIe,tK]=Ffe(eK,{contentName:dc,titleName:wC,docsSlug:"dialog"}),ewe=({titleId:e})=>{const t=tK(eK),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
124
|
+
`)},Ihe=0,hu=[];function Ohe(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),a=y.useState(Ihe++)[0],i=y.useState(yW)[0],o=y.useRef(e);y.useEffect(function(){o.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var x=Qme([e.lockRef.current],(e.shards||[]).map(L4),!0).filter(Boolean);return x.forEach(function(S){return S.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),x.forEach(function(S){return S.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=y.useCallback(function(x,S){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!o.current.allowPinchZoom;var _=Ib(x),E=n.current,k="deltaX"in x?x.deltaX:E[0]-_[0],C="deltaY"in x?x.deltaY:E[1]-_[1],R,A=x.target,N=Math.abs(k)>Math.abs(C)?"h":"v";if("touches"in x&&N==="h"&&A.type==="range")return!1;var O=O4(N,A);if(!O)return!0;if(O?R=N:(R=N==="v"?"h":"v",O=O4(N,A)),!O)return!1;if(!r.current&&"changedTouches"in x&&(k||C)&&(r.current=R),!R)return!0;var $=r.current||R;return Rhe($,S,x,$==="h"?k:C)},[]),u=y.useCallback(function(x){var S=x;if(!(!hu.length||hu[hu.length-1]!==i)){var _="deltaY"in S?D4(S):Ib(S),E=t.current.filter(function(R){return R.name===S.type&&(R.target===S.target||S.target===R.shadowParent)&&Che(R.delta,_)})[0];if(E&&E.should){S.cancelable&&S.preventDefault();return}if(!E){var k=(o.current.shards||[]).map(L4).filter(Boolean).filter(function(R){return R.contains(S.target)}),C=k.length>0?l(S,k[0]):!o.current.noIsolation;C&&S.cancelable&&S.preventDefault()}}},[]),d=y.useCallback(function(x,S,_,E){var k={name:x,delta:S,target:_,should:E,shadowParent:Dhe(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(C){return C!==k})},1)},[]),p=y.useCallback(function(x){n.current=Ib(x),r.current=void 0},[]),h=y.useCallback(function(x){d(x.type,D4(x),x.target,l(x,e.lockRef.current))},[]),g=y.useCallback(function(x){d(x.type,Ib(x),x.target,l(x,e.lockRef.current))},[]);y.useEffect(function(){return hu.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,mu),document.addEventListener("touchmove",u,mu),document.addEventListener("touchstart",p,mu),function(){hu=hu.filter(function(x){return x!==i}),document.removeEventListener("wheel",u,mu),document.removeEventListener("touchmove",u,mu),document.removeEventListener("touchstart",p,mu)}},[]);var b=e.removeScrollBar,v=e.inert;return y.createElement(y.Fragment,null,v?y.createElement(i,{styles:Ahe(a)}):null,b?y.createElement(She,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Dhe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Lhe=lhe(vW,Ohe);var Jm=y.forwardRef(function(e,t){return y.createElement(Sw,eo({},e,{ref:t,sideCar:Lhe}))});Jm.classNames=Sw.classNames;var H_=["Enter"," "],jhe=["ArrowDown","PageUp","Home"],EW=["ArrowUp","PageDown","End"],$he=[...jhe,...EW],Mhe={ltr:[...H_,"ArrowRight"],rtl:[...H_,"ArrowLeft"]},Phe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Qm="Menu",[cm,Uhe,zhe]=VR(Qm),[xc,_W]=Wi(Qm,[zhe,ul,uW]),xw=ul(),kW=uW(),[Fhe,Ec]=xc(Qm),[Bhe,eh]=xc(Qm),TW=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:i,modal:o=!0}=e,l=xw(t),[u,d]=y.useState(null),p=y.useRef(!1),h=co(i),g=GR(a);return y.useEffect(()=>{const b=()=>{p.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>p.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),f.jsx(bw,{...l,children:f.jsx(Fhe,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:f.jsx(Bhe,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:p,dir:g,modal:o,children:r})})})};TW.displayName=Qm;var Hhe="MenuAnchor",tC=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=xw(n);return f.jsx(qm,{...a,...r,ref:t})});tC.displayName=Hhe;var nC="MenuPortal",[Vhe,NW]=xc(nC,{forceMount:void 0}),RW=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,i=Ec(nC,t);return f.jsx(Vhe,{scope:t,forceMount:n,children:f.jsx(Xa,{present:n||i.open,children:f.jsx(nf,{asChild:!0,container:a,children:r})})})};RW.displayName=nC;var gi="MenuContent",[Ghe,rC]=xc(gi),CW=y.forwardRef((e,t)=>{const n=NW(gi,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,i=Ec(gi,e.__scopeMenu),o=eh(gi,e.__scopeMenu);return f.jsx(cm.Provider,{scope:e.__scopeMenu,children:f.jsx(Xa,{present:r||i.open,children:f.jsx(cm.Slot,{scope:e.__scopeMenu,children:o.modal?f.jsx(Whe,{...a,ref:t}):f.jsx(Khe,{...a,ref:t})})})})}),Whe=y.forwardRef((e,t)=>{const n=Ec(gi,e.__scopeMenu),r=y.useRef(null),a=yn(t,r);return y.useEffect(()=>{const i=r.current;if(i)return ww(i)},[]),f.jsx(aC,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:rt(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Khe=y.forwardRef((e,t)=>{const n=Ec(gi,e.__scopeMenu);return f.jsx(aC,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Zhe=lc("MenuContent.ScrollLock"),aC=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:g,onDismiss:b,disableOutsideScroll:v,...x}=e,S=Ec(gi,n),_=eh(gi,n),E=xw(n),k=kW(n),C=Uhe(n),[R,A]=y.useState(null),N=y.useRef(null),O=yn(t,N,S.onContentChange),$=y.useRef(0),M=y.useRef(""),z=y.useRef(0),W=y.useRef(null),J=y.useRef("right"),X=y.useRef(0),re=v?Jm:y.Fragment,H=v?{as:Zhe,allowPinchZoom:!0}:void 0,Z=ae=>{const ne=M.current+ae,L=C().filter(K=>!K.disabled),V=document.activeElement,F=L.find(K=>K.ref.current===V)?.textValue,j=L.map(K=>K.textValue),P=oge(j,ne,F),B=L.find(K=>K.textValue===P)?.ref.current;(function K(ee){M.current=ee,window.clearTimeout($.current),ee!==""&&($.current=window.setTimeout(()=>K(""),1e3))})(ne),B&&setTimeout(()=>B.focus())};y.useEffect(()=>()=>window.clearTimeout($.current),[]),fw();const G=y.useCallback(ae=>J.current===W.current?.side&&lge(ae,W.current?.area),[]);return f.jsx(Ghe,{scope:n,searchRef:M,onItemEnter:y.useCallback(ae=>{G(ae)&&ae.preventDefault()},[G]),onItemLeave:y.useCallback(ae=>{G(ae)||(N.current?.focus(),A(null))},[G]),onTriggerLeave:y.useCallback(ae=>{G(ae)&&ae.preventDefault()},[G]),pointerGraceTimerRef:z,onPointerGraceIntentChange:y.useCallback(ae=>{W.current=ae},[]),children:f.jsx(re,{...H,children:f.jsx(Zm,{asChild:!0,trapped:a,onMountAutoFocus:rt(i,ae=>{ae.preventDefault(),N.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:f.jsx(Qd,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:p,onFocusOutside:h,onInteractOutside:g,onDismiss:b,children:f.jsx(Zme,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:R,onCurrentTabStopIdChange:A,onEntryFocus:rt(u,ae=>{_.isUsingKeyboardRef.current||ae.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(vw,{role:"menu","aria-orientation":"vertical","data-state":GW(S.open),"data-radix-menu-content":"",dir:_.dir,...E,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:rt(x.onKeyDown,ae=>{const L=ae.target.closest("[data-radix-menu-content]")===ae.currentTarget,V=ae.ctrlKey||ae.altKey||ae.metaKey,F=ae.key.length===1;L&&(ae.key==="Tab"&&ae.preventDefault(),!V&&F&&Z(ae.key));const j=N.current;if(ae.target!==j||!$he.includes(ae.key))return;ae.preventDefault();const B=C().filter(K=>!K.disabled).map(K=>K.ref.current);EW.includes(ae.key)&&B.reverse(),age(B)}),onBlur:rt(e.onBlur,ae=>{ae.currentTarget.contains(ae.target)||(window.clearTimeout($.current),M.current="")}),onPointerMove:rt(e.onPointerMove,um(ae=>{const ne=ae.target,L=X.current!==ae.clientX;if(ae.currentTarget.contains(ne)&&L){const V=ae.clientX>X.current?"right":"left";J.current=V,X.current=ae.clientX}}))})})})})})})});CW.displayName=gi;var Yhe="MenuGroup",iC=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f.jsx(Gt.div,{role:"group",...r,ref:t})});iC.displayName=Yhe;var qhe="MenuLabel",AW=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f.jsx(Gt.div,{...r,ref:t})});AW.displayName=qhe;var Xv="MenuItem",j4="menu.itemSelect",Ew=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,i=y.useRef(null),o=eh(Xv,e.__scopeMenu),l=rC(Xv,e.__scopeMenu),u=yn(t,i),d=y.useRef(!1),p=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(j4,{bubbles:!0,cancelable:!0});h.addEventListener(j4,b=>r?.(b),{once:!0}),PG(h,g),g.defaultPrevented?d.current=!1:o.onClose()}};return f.jsx(IW,{...a,ref:u,disabled:n,onClick:rt(e.onClick,p),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:rt(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:rt(e.onKeyDown,h=>{const g=l.searchRef.current!=="";n||g&&h.key===" "||H_.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Ew.displayName=Xv;var IW=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...i}=e,o=rC(Xv,n),l=kW(n),u=y.useRef(null),d=yn(t,u),[p,h]=y.useState(!1),[g,b]=y.useState("");return y.useEffect(()=>{const v=u.current;v&&b((v.textContent??"").trim())},[i.children]),f.jsx(cm.ItemSlot,{scope:n,disabled:r,textValue:a??g,children:f.jsx(Yme,{asChild:!0,...l,focusable:!r,children:f.jsx(Gt.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:d,onPointerMove:rt(e.onPointerMove,um(v=>{r?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:rt(e.onPointerLeave,um(v=>o.onItemLeave(v))),onFocus:rt(e.onFocus,()=>h(!0)),onBlur:rt(e.onBlur,()=>h(!1))})})})}),Xhe="MenuCheckboxItem",OW=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return f.jsx(MW,{scope:e.__scopeMenu,checked:n,children:f.jsx(Ew,{role:"menuitemcheckbox","aria-checked":Jv(n)?"mixed":n,...a,ref:t,"data-state":sC(n),onSelect:rt(a.onSelect,()=>r?.(Jv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});OW.displayName=Xhe;var DW="MenuRadioGroup",[Jhe,Qhe]=xc(DW,{value:void 0,onValueChange:()=>{}}),LW=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,i=co(r);return f.jsx(Jhe,{scope:e.__scopeMenu,value:n,onValueChange:i,children:f.jsx(iC,{...a,ref:t})})});LW.displayName=DW;var jW="MenuRadioItem",$W=y.forwardRef((e,t)=>{const{value:n,...r}=e,a=Qhe(jW,e.__scopeMenu),i=n===a.value;return f.jsx(MW,{scope:e.__scopeMenu,checked:i,children:f.jsx(Ew,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":sC(i),onSelect:rt(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});$W.displayName=jW;var oC="MenuItemIndicator",[MW,ege]=xc(oC,{checked:!1}),PW=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,i=ege(oC,n);return f.jsx(Xa,{present:r||Jv(i.checked)||i.checked===!0,children:f.jsx(Gt.span,{...a,ref:t,"data-state":sC(i.checked)})})});PW.displayName=oC;var tge="MenuSeparator",UW=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return f.jsx(Gt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});UW.displayName=tge;var nge="MenuArrow",zW=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=xw(n);return f.jsx(yw,{...a,...r,ref:t})});zW.displayName=nge;var rge="MenuSub",[_Ie,FW]=xc(rge),kp="MenuSubTrigger",BW=y.forwardRef((e,t)=>{const n=Ec(kp,e.__scopeMenu),r=eh(kp,e.__scopeMenu),a=FW(kp,e.__scopeMenu),i=rC(kp,e.__scopeMenu),o=y.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=i,d={__scopeMenu:e.__scopeMenu},p=y.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return y.useEffect(()=>p,[p]),y.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),u(null)}},[l,u]),f.jsx(tC,{asChild:!0,...d,children:f.jsx(IW,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":GW(n.open),...e,ref:lo(t,a.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:rt(e.onPointerMove,um(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),p()},100))})),onPointerLeave:rt(e.onPointerLeave,um(h=>{p();const g=n.content?.getBoundingClientRect();if(g){const b=n.content?.dataset.side,v=b==="right",x=v?-5:5,S=g[v?"left":"right"],_=g[v?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:S,y:g.top},{x:_,y:g.top},{x:_,y:g.bottom},{x:S,y:g.bottom}],side:b}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:rt(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||Mhe[r.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});BW.displayName=kp;var HW="MenuSubContent",VW=y.forwardRef((e,t)=>{const n=NW(gi,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,i=Ec(gi,e.__scopeMenu),o=eh(gi,e.__scopeMenu),l=FW(HW,e.__scopeMenu),u=y.useRef(null),d=yn(t,u);return f.jsx(cm.Provider,{scope:e.__scopeMenu,children:f.jsx(Xa,{present:r||i.open,children:f.jsx(cm.Slot,{scope:e.__scopeMenu,children:f.jsx(aC,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{o.isUsingKeyboardRef.current&&u.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:rt(e.onFocusOutside,p=>{p.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:rt(e.onEscapeKeyDown,p=>{o.onClose(),p.preventDefault()}),onKeyDown:rt(e.onKeyDown,p=>{const h=p.currentTarget.contains(p.target),g=Phe[o.dir].includes(p.key);h&&g&&(i.onOpenChange(!1),l.trigger?.focus(),p.preventDefault())})})})})})});VW.displayName=HW;function GW(e){return e?"open":"closed"}function Jv(e){return e==="indeterminate"}function sC(e){return Jv(e)?"indeterminate":e?"checked":"unchecked"}function age(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ige(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function oge(e,t,n){const a=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=ige(e,Math.max(i,0));a.length===1&&(o=o.filter(d=>d!==n));const u=o.find(d=>d.toLowerCase().startsWith(a.toLowerCase()));return u!==n?u:void 0}function sge(e,t){const{x:n,y:r}=e;let a=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const l=t[i],u=t[o],d=l.x,p=l.y,h=u.x,g=u.y;p>r!=g>r&&n<(h-d)*(r-p)/(g-p)+d&&(a=!a)}return a}function lge(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return sge(n,t)}function um(e){return t=>t.pointerType==="mouse"?e(t):void 0}var cge=TW,uge=tC,dge=RW,fge=CW,pge=iC,mge=AW,hge=Ew,gge=OW,bge=LW,vge=$W,yge=PW,wge=UW,Sge=zW,xge=BW,Ege=VW,_w="DropdownMenu",[_ge]=Wi(_w,[_W]),wa=_W(),[kge,WW]=_ge(_w),KW=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,u=wa(t),d=y.useRef(null),[p,h]=Xo({prop:a,defaultProp:i??!1,onChange:o,caller:_w});return f.jsx(kge,{scope:t,triggerId:Kr(),triggerRef:d,contentId:Kr(),open:p,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:l,children:f.jsx(cge,{...u,open:p,onOpenChange:h,dir:r,modal:l,children:n})})};KW.displayName=_w;var ZW="DropdownMenuTrigger",YW=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,i=WW(ZW,n),o=wa(n);return f.jsx(uge,{asChild:!0,...o,children:f.jsx(Gt.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":r?"":void 0,disabled:r,...a,ref:lo(t,i.triggerRef),onPointerDown:rt(e.onPointerDown,l=>{!r&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:rt(e.onKeyDown,l=>{r||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});YW.displayName=ZW;var Tge="DropdownMenuPortal",qW=e=>{const{__scopeDropdownMenu:t,...n}=e,r=wa(t);return f.jsx(dge,{...r,...n})};qW.displayName=Tge;var XW="DropdownMenuContent",JW=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=WW(XW,n),i=wa(n),o=y.useRef(!1);return f.jsx(fge,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:t,onCloseAutoFocus:rt(e.onCloseAutoFocus,l=>{o.current||a.triggerRef.current?.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:rt(e.onInteractOutside,l=>{const u=l.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,p=u.button===2||d;(!a.modal||p)&&(o.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)"}})});JW.displayName=XW;var Nge="DropdownMenuGroup",Rge=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(pge,{...a,...r,ref:t})});Rge.displayName=Nge;var Cge="DropdownMenuLabel",QW=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(mge,{...a,...r,ref:t})});QW.displayName=Cge;var Age="DropdownMenuItem",e7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(hge,{...a,...r,ref:t})});e7.displayName=Age;var Ige="DropdownMenuCheckboxItem",t7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(gge,{...a,...r,ref:t})});t7.displayName=Ige;var Oge="DropdownMenuRadioGroup",Dge=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(bge,{...a,...r,ref:t})});Dge.displayName=Oge;var Lge="DropdownMenuRadioItem",n7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(vge,{...a,...r,ref:t})});n7.displayName=Lge;var jge="DropdownMenuItemIndicator",$ge=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(yge,{...a,...r,ref:t})});$ge.displayName=jge;var Mge="DropdownMenuSeparator",r7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(wge,{...a,...r,ref:t})});r7.displayName=Mge;var Pge="DropdownMenuArrow",Uge=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(Sge,{...a,...r,ref:t})});Uge.displayName=Pge;var zge="DropdownMenuSubTrigger",a7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(xge,{...a,...r,ref:t})});a7.displayName=zge;var Fge="DropdownMenuSubContent",i7=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=wa(n);return f.jsx(Ege,{...a,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});i7.displayName=Fge;var Bge=KW,Hge=YW,Vge=qW,o7=JW,s7=QW,l7=e7,Gge=t7,Wge=n7,c7=r7,Kge=a7,Zge=i7;const V_=Bge,G_=Hge;Kge.displayName;Zge.displayName;function Qv({ref:e,className:t,sideOffset:n=4,...r}){return f.jsx(Vge,{children:f.jsx(o7,{ref:e,sideOffset:n,className:Ue("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})})}Qv.displayName=o7.displayName;function Vo({ref:e,className:t,inset:n,...r}){return f.jsx(l7,{ref:e,className:Ue("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...r})}Vo.displayName=l7.displayName;Gge.displayName;Wge.displayName;function W_({ref:e,className:t,inset:n,...r}){return f.jsx(s7,{ref:e,className:Ue("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...r})}W_.displayName=s7.displayName;function Tp({ref:e,className:t,...n}){return f.jsx(c7,{ref:e,className:Ue("-mx-1 my-1 h-px bg-muted",t),...n})}Tp.displayName=c7.displayName;var Yge=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],os=Yge.reduce((e,t)=>{const n=yG(`Primitive.${t}`),r=y.forwardRef((a,i)=>{const{asChild:o,...l}=a,u=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),qge="Label",u7=y.forwardRef((e,t)=>f.jsx(os.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));u7.displayName=qge;var Xge=u7;function pn({className:e,...t}){return f.jsx(Xge,{"data-slot":"label",className:Ue("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 rf({message:e,className:t="",vertical:n,noBorder:r}){return f.jsx("div",{className:Ue(`mt-2 rounded-md p-6 ${t}`,!r&&"border"),children:f.jsxs("p",{className:Ue("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[f.jsx("svg",{width:"40",height:"40",viewBox:"0 0 273 273",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:f.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:f.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[f.jsx("path",{d:"M49.953025,-2.10854389 C63.26892,-2.21867124 76.6185256,2.70621155 86.9019463,12.6653164 L86.9019463,12.6653164 L87.505627,13.2592944 C97.5154947,23.2654892 102.640454,36.3074513 102.880738,49.4222247 C103.08932,77.4533067 113.877287,105.391753 135.242867,126.757333 C156.613383,148.127849 184.559216,158.914875 212.568138,159.119313 L212.568138,159.119313 L213.212264,159.134159 C225.843948,159.517566 238.363557,164.434972 248.121998,173.886137 L248.121998,173.886137 L248.725621,174.480088 C258.982114,184.732164 264.11035,198.171134 264.11035,211.6101 C264.11035,225.04592 258.984514,238.481745 248.732867,248.732867 C238.592792,258.872942 225.336706,263.997882 212.046872,264.107794 C198.731075,264.21792 185.381569,259.293085 175.098248,249.334078 L175.098248,249.334078 L174.494602,248.740134 C163.75802,238.008189 158.640853,223.784027 159.143413,209.719372 C158.258245,182.640933 147.489786,155.83332 126.828333,135.171867 C106.351297,114.694831 79.8363505,103.934873 53.0237258,102.891841 L53.0237258,102.891841 L52.2811438,102.865674 C38.4791718,103.347421 24.5325234,98.4328111 13.8776628,88.1140866 L13.8776628,88.1140866 L13.2739843,87.5201168 C3.12895117,77.3789607 -1.9984796,64.1195994 -2.10841888,50.8264755 C-2.21854669,37.5105567 2.70635908,24.1609269 12.6655135,13.8774565 L12.6655135,13.8774565 L13.2594878,13.2737797 C23.4005926,3.12880025 36.659927,-1.99860507 49.953025,-2.10854389 Z"}),f.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),f.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function d7({className:e,color:t,children:n,grayscaled:r=!1}){const a=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return r?0:.2},[t,r]),i=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return r?.3:.4},[t,r]),o=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]),l=y.useMemo(()=>t||`oklch(${Math.min(i,1)} ${a} ${o})`,[o,a,i]),u=y.useMemo(()=>`oklch(${Math.min(i*2,1)} ${a} ${o})`,[o,a,i,t]),d=y.useMemo(()=>Math.floor(Math.random()*360),[o]),p=y.useMemo(()=>"1000%",[]);return f.jsx("section",{className:Ue("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:f.jsxs("div",{className:"isolate relative w-full h-full",children:[f.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${d}deg, ${l}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${p})`}}),n&&f.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function lC(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 kw="Switch",[Jge]=Wi(kw),[Qge,ebe]=Jge(kw),f7=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:l,value:u="on",onCheckedChange:d,form:p,...h}=e,[g,b]=y.useState(null),v=yn(t,k=>b(k)),x=y.useRef(!1),S=g?p||!!g.closest("form"):!0,[_,E]=Xo({prop:a,defaultProp:i??!1,onChange:d,caller:kw});return f.jsxs(Qge,{scope:n,checked:_,disabled:l,children:[f.jsx(Gt.button,{type:"button",role:"switch","aria-checked":_,"aria-required":o,"data-state":g7(_),"data-disabled":l?"":void 0,disabled:l,value:u,...h,ref:v,onClick:rt(e.onClick,k=>{E(C=>!C),S&&(x.current=k.isPropagationStopped(),x.current||k.stopPropagation())})}),S&&f.jsx(h7,{control:g,bubbles:!x.current,name:r,value:u,checked:_,required:o,disabled:l,form:p,style:{transform:"translateX(-100%)"}})]})});f7.displayName=kw;var p7="SwitchThumb",m7=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=ebe(p7,n);return f.jsx(Gt.span,{"data-state":g7(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});m7.displayName=p7;var tbe="SwitchBubbleInput",h7=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},i)=>{const o=y.useRef(null),l=yn(o,i),u=lC(n),d=JR(t);return y.useEffect(()=>{const p=o.current;if(!p)return;const h=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&b){const v=new Event("click",{bubbles:r});b.call(p,n),p.dispatchEvent(v)}},[u,n,r]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:l,style:{...a.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});h7.displayName=tbe;function g7(e){return e?"checked":"unchecked"}var b7=f7,nbe=m7;function Tw({ref:e,className:t,...n}){return f.jsx(b7,{className:Ue("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:f.jsx(nbe,{className:Ue("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")})})}Tw.displayName=b7.displayName;var v7=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"}),rbe="VisuallyHidden",y7=y.forwardRef((e,t)=>f.jsx(Gt.span,{...e,ref:t,style:{...v7,...e.style}}));y7.displayName=rbe;var abe=y7,[Nw]=Wi("Tooltip",[ul]),Rw=ul(),w7="TooltipProvider",ibe=700,K_="tooltip.open",[obe,cC]=Nw(w7),S7=e=>{const{__scopeTooltip:t,delayDuration:n=ibe,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:i}=e,o=y.useRef(!0),l=y.useRef(!1),u=y.useRef(0);return y.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),f.jsx(obe,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(u.current),o.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:y.useCallback(d=>{l.current=d},[]),disableHoverableContent:a,children:i})};S7.displayName=w7;var dm="Tooltip",[sbe,th]=Nw(dm),x7=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:l}=e,u=cC(dm,e.__scopeTooltip),d=Rw(t),[p,h]=y.useState(null),g=Kr(),b=y.useRef(0),v=o??u.disableHoverableContent,x=l??u.delayDuration,S=y.useRef(!1),[_,E]=Xo({prop:r,defaultProp:a??!1,onChange:N=>{N?(u.onOpen(),document.dispatchEvent(new CustomEvent(K_))):u.onClose(),i?.(N)},caller:dm}),k=y.useMemo(()=>_?S.current?"delayed-open":"instant-open":"closed",[_]),C=y.useCallback(()=>{window.clearTimeout(b.current),b.current=0,S.current=!1,E(!0)},[E]),R=y.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),A=y.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{S.current=!0,E(!0),b.current=0},x)},[x,E]);return y.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),f.jsx(bw,{...d,children:f.jsx(sbe,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:p,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{u.isOpenDelayedRef.current?A():C()},[u.isOpenDelayedRef,A,C]),onTriggerLeave:y.useCallback(()=>{v?R():(window.clearTimeout(b.current),b.current=0)},[R,v]),onOpen:C,onClose:R,disableHoverableContent:v,children:n})})};x7.displayName=dm;var Z_="TooltipTrigger",E7=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=th(Z_,n),i=cC(Z_,n),o=Rw(n),l=y.useRef(null),u=yn(t,l,a.onTriggerChange),d=y.useRef(!1),p=y.useRef(!1),h=y.useCallback(()=>d.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),f.jsx(qm,{asChild:!0,...o,children:f.jsx(Gt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:u,onPointerMove:rt(e.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:rt(e.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:rt(e.onPointerDown,()=>{a.open&&a.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:rt(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:rt(e.onBlur,a.onClose),onClick:rt(e.onClick,a.onClose)})})});E7.displayName=Z_;var uC="TooltipPortal",[lbe,cbe]=Nw(uC,{forceMount:void 0}),_7=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:a}=e,i=th(uC,t);return f.jsx(lbe,{scope:t,forceMount:n,children:f.jsx(Xa,{present:n||i.open,children:f.jsx(nf,{asChild:!0,container:a,children:r})})})};_7.displayName=uC;var Dd="TooltipContent",k7=y.forwardRef((e,t)=>{const n=cbe(Dd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...i}=e,o=th(Dd,e.__scopeTooltip);return f.jsx(Xa,{present:r||o.open,children:o.disableHoverableContent?f.jsx(T7,{side:a,...i,ref:t}):f.jsx(ube,{side:a,...i,ref:t})})}),ube=y.forwardRef((e,t)=>{const n=th(Dd,e.__scopeTooltip),r=cC(Dd,e.__scopeTooltip),a=y.useRef(null),i=yn(t,a),[o,l]=y.useState(null),{trigger:u,onClose:d}=n,p=a.current,{onPointerInTransitChange:h}=r,g=y.useCallback(()=>{l(null),h(!1)},[h]),b=y.useCallback((v,x)=>{const S=v.currentTarget,_={x:v.clientX,y:v.clientY},E=mbe(_,S.getBoundingClientRect()),k=hbe(_,E),C=gbe(x.getBoundingClientRect()),R=vbe([...k,...C]);l(R),h(!0)},[h]);return y.useEffect(()=>()=>g(),[g]),y.useEffect(()=>{if(u&&p){const v=S=>b(S,p),x=S=>b(S,u);return u.addEventListener("pointerleave",v),p.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",v),p.removeEventListener("pointerleave",x)}}},[u,p,b,g]),y.useEffect(()=>{if(o){const v=x=>{const S=x.target,_={x:x.clientX,y:x.clientY},E=u?.contains(S)||p?.contains(S),k=!bbe(_,o);E?g():k&&(g(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,p,o,d,g]),f.jsx(T7,{...e,ref:i})}),[dbe,fbe]=Nw(dm,{isInside:!1}),pbe=Kfe("TooltipContent"),T7=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...l}=e,u=th(Dd,n),d=Rw(n),{onClose:p}=u;return y.useEffect(()=>(document.addEventListener(K_,p),()=>document.removeEventListener(K_,p)),[p]),y.useEffect(()=>{if(u.trigger){const h=g=>{g.target?.contains(u.trigger)&&p()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,p]),f.jsx(Qd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:p,children:f.jsxs(vw,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[f.jsx(pbe,{children:r}),f.jsx(dbe,{scope:n,isInside:!0,children:f.jsx(abe,{id:u.contentId,role:"tooltip",children:a||r})})]})})});k7.displayName=Dd;var N7="TooltipArrow",R7=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=Rw(n);return fbe(N7,n).isInside?null:f.jsx(yw,{...a,...r,ref:t})});R7.displayName=N7;function mbe(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,a,i)){case i:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function hbe(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function gbe(e){const{top:t,right:n,bottom:r,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:r},{x:a,y:r}]}function bbe(e,t){const{x:n,y:r}=e;let a=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const l=t[i],u=t[o],d=l.x,p=l.y,h=u.x,g=u.y;p>r!=g>r&&n<(h-d)*(r-p)/(g-p)+d&&(a=!a)}return a}function vbe(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),ybe(t)}function ybe(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const a=e[r];for(;t.length>=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const a=e[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))n.pop();else break}n.push(a)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var wbe=S7,Sbe=x7,xbe=E7,Ebe=_7,_be=k7,kbe=R7;function dC({delayDuration:e=0,...t}){return f.jsx(wbe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Zt({...e}){return f.jsx(dC,{children:f.jsx(Sbe,{"data-slot":"tooltip",...e})})}function Yt({...e}){return f.jsx(xbe,{"data-slot":"tooltip-trigger",...e})}function qt({className:e,sideOffset:t=0,children:n,...r}){return f.jsx(Ebe,{children:f.jsxs(_be,{"data-slot":"tooltip-content",sideOffset:t,className:Ue("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,f.jsx(kbe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class Tbe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class $4{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 M4{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class P4{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class U4{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 Nbe{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 Rbe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class Cbe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class Abe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function iE(){try{return"0.13.0-canary.11"}catch{return"0.0.0"}}var Ibe={};function oE(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class z4{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout),a=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(r),!a.ok)throw new Error(`HTTP error! status: ${a.status}`)}catch{}}}function Ds(e){return`mcp_inspector_telemetry_${e}`}class Or{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=oE(),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 z4(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new z4(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(Ds("disabled"))==="true"||typeof process<"u"&&Ibe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(Ds("source")):null}static getInstance(){return Or.instance||(Or.instance=new Or),Or.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(Ds("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!oE())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(Ds("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(Ds("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=typeof window<"u"&&window.crypto&&window.crypto.getRandomValues?window.crypto:typeof crypto<"u"&&crypto.getRandomValues?crypto:void 0;if(t&&t.getRandomValues){const n=new Uint8Array(16);t.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("");return r.slice(0,8)+"-"+r.slice(8,12)+"-"+r.slice(12,16)+"-"+r.slice(16,20)+"-"+r.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&3|8).toString(16)})}async capture(t){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{const n={event:t.name,user_id:this.userId,properties:{...t.properties,mcp_use_version:iE(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=iE(),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&&oE())try{const n=iE();let r=!1,a=!1;const i=localStorage.getItem(Ds("download_version"));if(i?n>i&&(r=!0,a=!1,localStorage.setItem(Ds("download_version"),n)):(r=!0,a=!0,localStorage.setItem(Ds("download_version"),n)),r){const o={...t||{}};o.mcp_use_version=n,o.user_id=this.userId,o.event="package_download",o.first_download=a,o.language="typescript",o.source=this._source,o.package="inspector",await this._scarfClient.logEvent(o)}}catch{}}async trackInspectorOpen(t){const n=new Tbe(t);await this.capture(n)}}const Obe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function Dbe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:a}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Sampling Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),n()},children:"View Details"}),f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),r(Obe)},children:"Approve"}),f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),a()},children:"Deny"})]})]})}function Lbe({requestId:e,serverName:t,mode:n,message:r,url:a,onViewDetails:i,onOpenUrl:o,onCancel:l}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Elicitation Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",r]}),n==="url"&&a&&f.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:a})]}),f.jsxs("div",{className:"flex gap-2 flex-wrap",children:[f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),i()},children:"View Details"}),n==="url"&&o&&f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),o()},children:"Open URL"}),f.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),l()},children:"Cancel"})]})]})}const Ob=()=>{},Db=()=>{},Lb=()=>{},jb=()=>{},C7=y.createContext(null);function fC(){const e=y.use(C7);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function jbe({url:e,name:t,proxyConfig:n,transportType:r,connectionId:a,onUpdate:i,onRemove:o}){const l=typeof window<"u"?new URL("/inspector/oauth/callback",window.location.origin).toString():"/inspector/oauth/callback";let u=e,d={};if(n?.proxyAddress){const j=new URL(n.proxyAddress),P=new URL(e);u=`${j.origin}${j.pathname}${P.pathname}${P.search}`,d["X-Target-URL"]=e}n?.customHeaders&&(d={...d,...n.customHeaders});const[p,h]=y.useState([]),g=y.useRef(0),[b,v]=y.useState([]),x=y.useRef(0),S=y.useMemo(()=>p.map(j=>({id:j.id,request:j.request,timestamp:j.timestamp,serverName:j.serverName})),[p]),_=y.useMemo(()=>b.map(j=>({id:j.id,request:j.request,timestamp:j.timestamp,serverName:j.serverName})),[b]),E=y.useRef(null),[k,C]=y.useState(!1),R=y.useRef(!1);y.useEffect(()=>{typeof window<"u"&&!R.current&&(R.current=!0,pr(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(j=>{E.current=j.wrapTransportForLogging,C(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(j=>{console.error("[McpContext] Failed to load transport wrapper:",j)}))},[]);const A=y.useMemo(()=>{if(!(!k||!E.current))return(j,P)=>{const B=a;return console.log("[McpContext] Applying transport wrapper, serverId:",B,"from connector:",P),E.current(j,B)}},[k,a]),N=`mcp-inspector-notifications-${a}`,O=500,[$,M]=y.useState([]);y.useEffect(()=>{try{const j=localStorage.getItem(N);if(j){const P=JSON.parse(j);Array.isArray(P)&&M(P)}}catch(j){console.error("Failed to load notifications from localStorage:",j)}},[N]),y.useEffect(()=>{try{localStorage.setItem(N,JSON.stringify($))}catch(j){console.error("Failed to save notifications to localStorage:",j)}},[$,N]);const z=y.useCallback(j=>{M(P=>P.map(B=>B.id===j?{...B,read:!0}:B))},[]),W=y.useCallback(()=>{M(j=>j.map(P=>({...P,read:!0})))},[]),J=y.useCallback(()=>{M([])},[]),X=y.useCallback(j=>{M(P=>{const B=[j,...P];return B.length>O?B.slice(0,O):B})},[]),re=y.useCallback((j,P)=>{h(B=>{const K=B.find(ee=>ee.id===j);return K?(K.resolve(P),B.filter(ee=>ee.id!==j)):B})},[]),H=y.useCallback((j,P)=>{h(B=>{const K=B.find(ee=>ee.id===j);return K?(K.reject(new Error(P||"User rejected sampling request")),B.filter(ee=>ee.id!==j)):B})},[]),Z=y.useCallback((j,P)=>{v(B=>{const K=B.find(ee=>ee.id===j);return K?(K.resolve(P),B.filter(ee=>ee.id!==j)):B})},[]),G=y.useCallback((j,P)=>{v(B=>{const K=B.find(ee=>ee.id===j);return K?(K.reject(new Error(P||"User rejected elicitation request")),B.filter(ee=>ee.id!==j)):B})},[]),ae=y.useCallback(async j=>new Promise((P,B)=>{const K=`sampling-${g.current++}`,ee={id:K,request:{params:j},timestamp:Date.now(),serverName:t,resolve:P,reject:B};h(ie=>[...ie,ee]),typeof window<"u"&&pr(async()=>{const{toast:ie}=await Promise.resolve().then(()=>K4);return{toast:ie}},void 0).then(({toast:ie})=>{const ue=ie(f.jsx(Dbe,{requestId:K,serverName:t,onViewDetails:()=>{const Q=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:K}});window.dispatchEvent(Q),ie.dismiss(ue)},onApprove:Q=>{h(q=>{const le=q.find(ve=>ve.id===K);return le?(le.resolve(Q),ie.success("Sampling request approved"),q.filter(ve=>ve.id!==K)):q}),ie.dismiss(ue)},onDeny:()=>{h(Q=>{const q=Q.find(le=>le.id===K);return q?(q.reject(new Error("User denied sampling request from toast")),ie.error("Sampling request denied"),Q.filter(le=>le.id!==K)):Q}),ie.dismiss(ue)}}),{duration:5e3})})}),[t]),ne=y.useCallback(async j=>new Promise((P,B)=>{const K=`elicitation-${x.current++}`,ee={id:K,request:j,timestamp:Date.now(),serverName:t,resolve:P,reject:B};v(ie=>[...ie,ee]),typeof window<"u"&&pr(async()=>{const{toast:ie}=await Promise.resolve().then(()=>K4);return{toast:ie}},void 0).then(({toast:ie})=>{const ue=ie(f.jsx(Lbe,{requestId:K,serverName:t,mode:j.mode||"form",message:j.message,url:j.mode==="url"?j.url:void 0,onViewDetails:()=>{const Q=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:K}});window.dispatchEvent(Q),ie.dismiss(ue)},onOpenUrl:j.mode==="url"?()=>{window.open(j.url,"_blank"),ie.dismiss(ue)}:void 0,onCancel:()=>{v(Q=>{const q=Q.find(le=>le.id===K);return q?(q.reject(new Error("User cancelled elicitation request from toast")),ie.error("Elicitation request cancelled"),Q.filter(le=>le.id!==K)):Q}),ie.dismiss(ue)}}),{duration:5e3})})}),[t]),L=bR({url:u,callbackUrl:l,customHeaders:Object.keys(d).length>0?d:void 0,transportType:r||"http",preventAutoAuth:!0,useRedirectFlow:!0,enabled:k,wrapTransport:A,onNotification:j=>{X({id:globalThis.crypto.randomUUID(),method:j.method,params:j.params,timestamp:Date.now(),read:!1})},samplingCallback:ae,onElicitation:ne}),V=y.useRef(i),F=y.useRef(null);return y.useEffect(()=>{V.current=i},[i]),y.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{L.state==="ready"&&L.serverInfo&&console.log("[McpContext] Server info available:",L.serverInfo);const j=$.filter(K=>!K.read).length,P={id:a,url:e,name:L.serverInfo?.name||t,state:L.state,tools:L.tools,resources:L.resources,prompts:L.prompts,error:L.error??null,authUrl:L.authUrl??null,customHeaders:d,transportType:r,proxyConfig:n,serverInfo:L.serverInfo,capabilities:L.capabilities,notifications:$,unreadNotificationCount:j,markNotificationRead:z,markAllNotificationsRead:W,clearNotifications:J,pendingSamplingRequests:S,approveSampling:re,rejectSampling:H,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:L.callTool,readResource:L.readResource,listPrompts:L.listPrompts,getPrompt:L.getPrompt,authenticate:L.authenticate,retry:L.retry,clearStorage:L.clearStorage,disconnect:L.disconnect,client:L.client},B=F.current;(!B||B.state!==P.state||B.error!==P.error||B.authUrl!==P.authUrl||B.name!==P.name||B.tools.length!==P.tools.length||B.resources.length!==P.resources.length||B.prompts.length!==P.prompts.length||B.serverInfo!==P.serverInfo||B.capabilities!==P.capabilities||B.notifications.length!==P.notifications.length||B.unreadNotificationCount!==P.unreadNotificationCount||B.pendingSamplingRequests.length!==P.pendingSamplingRequests.length||B.pendingElicitationRequests.length!==P.pendingElicitationRequests.length||!B.client)&&(F.current=P,V.current(P))});else{const j=$.filter(K=>!K.read).length,P={id:a,url:e,name:L.serverInfo?.name||t,state:L.state,tools:L.tools,resources:L.resources,prompts:L.prompts,error:L.error??null,authUrl:L.authUrl??null,customHeaders:d,transportType:r,proxyConfig:n,serverInfo:L.serverInfo,capabilities:L.capabilities,notifications:$,unreadNotificationCount:j,markNotificationRead:z,markAllNotificationsRead:W,clearNotifications:J,pendingSamplingRequests:S,approveSampling:re,rejectSampling:H,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:L.callTool,readResource:L.readResource,listPrompts:L.listPrompts,getPrompt:L.getPrompt,authenticate:L.authenticate,retry:L.retry,clearStorage:L.clearStorage,disconnect:L.disconnect,client:L.client},B=F.current;(!B||B.state!==P.state||B.error!==P.error||B.authUrl!==P.authUrl||B.name!==P.name||B.tools.length!==P.tools.length||B.resources.length!==P.resources.length||B.prompts.length!==P.prompts.length||B.serverInfo!==P.serverInfo||B.capabilities!==P.capabilities||B.notifications.length!==P.notifications.length||B.unreadNotificationCount!==P.unreadNotificationCount||B.pendingSamplingRequests.length!==P.pendingSamplingRequests.length||B.pendingElicitationRequests.length!==P.pendingElicitationRequests.length||!B.client)&&(F.current=P,V.current(P))}},[e,t,r,n,d,a,L.state,L.tools,L.resources,L.prompts,L.error,L.authUrl,L.serverInfo,L.capabilities,L.client,$,z,W,J,L.callTool,L.readResource,L.listPrompts,L.getPrompt,L.authenticate,L.retry,L.clearStorage,p,re,H,_,Z,G]),null}function $be({children:e}){const[t,n]=y.useState([]),[r,a]=y.useState(!1),[i,o]=y.useState(!0),[l,u]=y.useState([]);y.useEffect(()=>{try{const S=localStorage.getItem("mcp-inspector-connections");if(S){const E=JSON.parse(S);Array.isArray(E)&&(u(E),n(E.map(k=>({id:k.id||k.url,url:k.url,name:k.name||"MCP Server",state:"discovering",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k.proxyConfig?.customHeaders,transportType:k.transportType,proxyConfig:k.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Ob,rejectSampling:Db,pendingElicitationRequests:[],approveElicitation:Lb,rejectElicitation:jb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&o(_==="true")}catch(S){console.error("Failed to load connections from localStorage:",S)}finally{a(!0)}},[]),y.useEffect(()=>{r&&localStorage.setItem("mcp-inspector-connections",JSON.stringify(l))},[l,r]),y.useEffect(()=>{r&&localStorage.setItem("mcp-inspector-auto-connect",String(i))},[i,r]);const d=y.useCallback((S,_,E,k)=>{const C=l.find(N=>N.url===S),R=t.find(N=>N.url===S);if(C&&R){if(JSON.stringify(C.proxyConfig)!==JSON.stringify(E)&&E){u(O=>O.filter($=>$.url!==S)),n(O=>O.filter($=>$.url!==S)),setTimeout(()=>{const O={id:S,url:S,name:_||C.name||"MCP Server",proxyConfig:E,transportType:k||C.transportType};u($=>[...$,O]),n($=>[...$,{id:S,url:S,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||C.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Ob,rejectSampling:Db,pendingElicitationRequests:[],approveElicitation:Lb,rejectElicitation:jb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!R){(E||k)&&u(N=>N.map(O=>O.url===S?{...O,proxyConfig:E||O.proxyConfig,transportType:k||O.transportType,name:_||O.name}:O)),n(N=>[...N,{id:C.id||S,url:S,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||C.proxyConfig?.customHeaders,transportType:k||C.transportType,proxyConfig:E||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Ob,rejectSampling:Db,pendingElicitationRequests:[],approveElicitation:Lb,rejectElicitation:jb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const A={id:S,url:S,name:_||"MCP Server",proxyConfig:E,transportType:k};u(N=>[...N,A]),n(N=>[...N,{id:S,url:S,name:_||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Ob,rejectSampling:Db,pendingElicitationRequests:[],approveElicitation:Lb,rejectElicitation:jb,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[l,t]),p=y.useCallback(S=>{const _=t.find(k=>k.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())),u(k=>k.filter(C=>C.id!==S)),n(k=>k.filter(C=>C.id!==S));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const C=JSON.parse(E).filter(R=>(R.id||R.url)!==S);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(k){console.error("Failed to update localStorage on remove:",k)}Or.getInstance().capture(new Rbe({serverId:S}))},[t]),h=y.useCallback((S,_)=>{u(E=>E.map(k=>k.id===S||k.url===S?{...k,..._}:k)),n(E=>E.map(k=>k.id===S?{...k,..._}:k))},[]),g=y.useCallback(S=>{n(_=>{const E=_.findIndex(R=>R.id===S.id);if(E===-1)return _;const k=_[E];if(k.state===S.state&&k.tools===S.tools&&k.resources===S.resources&&k.prompts===S.prompts&&k.error===S.error&&k.serverInfo===S.serverInfo&&k.client===S.client&&k.notifications===S.notifications&&k.unreadNotificationCount===S.unreadNotificationCount&&k.pendingSamplingRequests.length===S.pendingSamplingRequests.length&&k.pendingElicitationRequests.length===S.pendingElicitationRequests.length)return _;const C=[..._];return C[E]=S,C})},[]),b=y.useCallback(S=>{console.log("Connect requested for:",S)},[]),v=y.useCallback(S=>{console.log("Disconnect requested for:",S)},[]),x=y.useMemo(()=>({connections:t,addConnection:d,removeConnection:p,updateConnectionConfig:h,autoConnect:i,setAutoConnect:o,connectServer:b,disconnectServer:v,configLoaded:r}),[t,d,p,h,i,b,v,r]);return f.jsxs(C7.Provider,{value:x,children:[e,r&&i&&l.map(S=>{const _=`${S.id||S.url}-${S.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",S.proxyConfig),f.jsx(jbe,{url:S.url,name:S.name,proxyConfig:S.proxyConfig,transportType:S.transportType,connectionId:S.id||S.url,onUpdate:g,onRemove:()=>p(S.id||S.url)},_)})]})}const Mbe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pbe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),F4=e=>{const t=Pbe(e);return t.charAt(0).toUpperCase()+t.slice(1)},A7=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Ube=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var zbe={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 Fbe=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:o,...l},u)=>y.createElement("svg",{ref:u,...zbe,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:A7("lucide",a),...!i&&!Ube(l)&&{"aria-hidden":"true"},...l},[...o.map(([d,p])=>y.createElement(d,p)),...Array.isArray(i)?i:[i]]));const pt=(e,t)=>{const n=y.forwardRef(({className:r,...a},i)=>y.createElement(Fbe,{ref:i,iconNode:t,className:A7(`lucide-${Mbe(F4(e))}`,`lucide-${e}`,r),...a}));return n.displayName=F4(e),n};const Bbe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Hbe=pt("arrow-down-to-line",Bbe);const Vbe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Gbe=pt("arrow-up-from-line",Vbe);const Wbe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Kbe=pt("arrow-up",Wbe);const Zbe=[["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"}]],pC=pt("bell",Zbe);const Ybe=[["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"}]],I7=pt("brush",Ybe);const qbe=[["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"}]],Xbe=pt("bug",qbe);const Jbe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ba=pt("check",Jbe);const Qbe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],_c=pt("chevron-down",Qbe);const eve=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],O7=pt("chevron-right",eve);const tve=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Cw=pt("chevron-left",tve);const nve=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],rve=pt("chevron-up",nve);const ave=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],ive=pt("chevrons-up-down",ave);const ove=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],B4=pt("circle-minus",ove);const sve=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ld=pt("clock",sve);const lve=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],mC=pt("code",lve);const cve=[["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"}]],uve=pt("cog",cve);const dve=[["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"}]],fve=pt("command",dve);const pve=[["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"}]],Zr=pt("copy",pve);const mve=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Aw=pt("database",mve);const hve=[["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"}]],nh=pt("download",hve);const gve=[["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"}]],bve=pt("ellipsis-vertical",gve);const vve=[["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"}]],Y_=pt("external-link",vve);const yve=[["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"}]],D7=pt("eye-off",yve);const wve=[["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"}]],q_=pt("eye",wve);const Sve=[["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"}]],xve=pt("file-code",Sve);const Eve=[["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"}]],_ve=pt("file-image",Eve);const kve=[["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"}]],hC=pt("file-text",kve);const Tve=[["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"}]],Nve=pt("file",Tve);const Rve=[["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"}]],Cve=pt("folder-open",Rve);const Ave=[["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"}]],Ive=pt("globe",Ave);const Ove=[["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"}]],Dve=pt("grip-vertical",Ove);const Lve=[["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"}]],L7=pt("hash",Lve);const jve=[["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"}]],ey=pt("history",jve);const $ve=[["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"}]],j7=pt("key",$ve);const Mve=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],el=pt("loader-circle",Mve);const Pve=[["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"}]],gC=pt("maximize-2",Pve);const Uve=[["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"}]],bC=pt("maximize",Uve);const zve=[["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"}]],Fve=pt("message-circle",zve);const Bve=[["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"}]],fm=pt("message-square",Bve);const Hve=[["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"}]],Vve=pt("minimize",Hve);const Gve=[["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"}]],H4=pt("monitor",Gve);const Wve=[["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"}]],Kve=pt("moon",Wve);const Zve=[["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"}]],Yve=pt("picture-in-picture",Zve);const qve=[["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"}]],$7=pt("play",qve);const Xve=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],M7=pt("plus",Xve);const Jve=[["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"}]],V4=pt("rotate-ccw",Jve);const Qve=[["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"}]],vC=pt("save",Qve);const eye=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],af=pt("search",eye);const tye=[["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"}]],nye=pt("send",tye);const rye=[["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"}]],aye=pt("server",rye);const iye=[["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"}]],qu=pt("settings",iye);const oye=[["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"}]],sye=pt("shield",oye);const lye=[["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"}]],cye=pt("sparkles",lye);const uye=[["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"}]],P7=pt("square-check-big",uye);const dye=[["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"}]],fye=pt("square-pen",dye);const pye=[["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"}]],mye=pt("sun-dim",pye);const hye=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],sE=pt("terminal",hye);const gye=[["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"}]],tl=pt("trash-2",gye);const bye=[["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"}]],vye=pt("trash",bye);const yye=[["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"}]],uc=pt("wrench",yye);const wye=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],po=pt("x",wye);const Sye=[["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"}]],pm=pt("zap",Sye);function xye(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 Eye=e=>{switch(e){case"success":return Tye;case"info":return Rye;case"warning":return Nye;case"error":return Cye;default:return null}},_ye=Array(12).fill(0),kye=({visible:e,className:t})=>de.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},de.createElement("div",{className:"sonner-spinner"},_ye.map((n,r)=>de.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),Tye=de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},de.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"})),Nye=de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},de.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"})),Rye=de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},de.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"})),Cye=de.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},de.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"})),Aye=de.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"},de.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),de.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Iye=()=>{const[e,t]=de.useState(document.hidden);return de.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let X_=1;class Oye{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:r,...a}=t,i=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:X_++,o=this.toasts.find(u=>u.id===i),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),o?this.toasts=this.toasts.map(u=>u.id===i?(this.publish({...u,...t,id:i,title:r}),{...u,...t,id:i,dismissible:l,title:r}):u):this.addToast({title:r,...a,dismissible:l,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(r=>r({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 r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const a=Promise.resolve(t instanceof Function?t():t);let i=r!==void 0,o;const l=a.then(async d=>{if(o=["resolve",d],de.isValidElement(d))i=!1,this.create({id:r,type:"default",message:d});else if(Lye(d)&&!d.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,v=typeof h=="object"&&!de.isValidElement(h)?h:{message:h};this.create({id:r,type:"error",description:g,...v})}else if(d instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,v=typeof h=="object"&&!de.isValidElement(h)?h:{message:h};this.create({id:r,type:"error",description:g,...v})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,v=typeof h=="object"&&!de.isValidElement(h)?h:{message:h};this.create({id:r,type:"success",description:g,...v})}}).catch(async d=>{if(o=["reject",d],n.error!==void 0){i=!1;const p=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,b=typeof p=="object"&&!de.isValidElement(p)?p:{message:p};this.create({id:r,type:"error",description:h,...b})}}).finally(()=>{i&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((d,p)=>l.then(()=>o[0]==="reject"?p(o[1]):d(o[1])).catch(p));return typeof r!="string"&&typeof r!="number"?{unwrap:u}:Object.assign(r,{unwrap:u})},this.custom=(t,n)=>{const r=n?.id||X_++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Ra=new Oye,Dye=(e,t)=>{const n=t?.id||X_++;return Ra.addToast({title:e,...t,id:n}),n},Lye=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jye=Dye,$ye=()=>Ra.toasts,Mye=()=>Ra.getActiveToasts(),vn=Object.assign(jye,{success:Ra.success,info:Ra.info,warning:Ra.warning,error:Ra.error,custom:Ra.custom,message:Ra.message,promise:Ra.promise,dismiss:Ra.dismiss,loading:Ra.loading},{getHistory:$ye,getToasts:Mye});xye("[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 $b(e){return e.label!==void 0}const Pye=3,Uye="24px",zye="16px",G4=4e3,Fye=356,Bye=14,Hye=45,Vye=200;function Ji(...e){return e.filter(Boolean).join(" ")}function Gye(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const Wye=e=>{var t,n,r,a,i,o,l,u,d;const{invert:p,toast:h,unstyled:g,interacting:b,setHeights:v,visibleToasts:x,heights:S,index:_,toasts:E,expanded:k,removeToast:C,defaultRichColors:R,closeButton:A,style:N,cancelButtonStyle:O,actionButtonStyle:$,className:M="",descriptionClassName:z="",duration:W,position:J,gap:X,expandByDefault:re,classNames:H,icons:Z,closeButtonAriaLabel:G="Close toast"}=e,[ae,ne]=de.useState(null),[L,V]=de.useState(null),[F,j]=de.useState(!1),[P,B]=de.useState(!1),[K,ee]=de.useState(!1),[ie,ue]=de.useState(!1),[Q,q]=de.useState(!1),[le,ve]=de.useState(0),[oe,Ae]=de.useState(0),Je=de.useRef(h.duration||W||G4),ke=de.useRef(null),Re=de.useRef(null),Ze=_===0,me=_+1<=x,Le=h.type,Ke=h.dismissible!==!1,_e=h.className||"",vt=h.descriptionClassName||"",gt=de.useMemo(()=>S.findIndex(at=>at.toastId===h.id)||0,[S,h.id]),wt=de.useMemo(()=>{var at;return(at=h.closeButton)!=null?at:A},[h.closeButton,A]),Tt=de.useMemo(()=>h.duration||W||G4,[h.duration,W]),At=de.useRef(0),Cn=de.useRef(0),mr=de.useRef(0),Ut=de.useRef(null),[He,Be]=J.split("-"),Te=de.useMemo(()=>S.reduce((at,it,kt)=>kt>=gt?at:at+it.height,0),[S,gt]),Pe=Iye(),Ve=h.invert||p,Qe=Le==="loading";Cn.current=de.useMemo(()=>gt*X+Te,[gt,Te]),de.useEffect(()=>{Je.current=Tt},[Tt]),de.useEffect(()=>{j(!0)},[]),de.useEffect(()=>{const at=Re.current;if(at){const it=at.getBoundingClientRect().height;return Ae(it),v(kt=>[{toastId:h.id,height:it,position:h.position},...kt]),()=>v(kt=>kt.filter(Mt=>Mt.toastId!==h.id))}},[v,h.id]),de.useLayoutEffect(()=>{if(!F)return;const at=Re.current,it=at.style.height;at.style.height="auto";const kt=at.getBoundingClientRect().height;at.style.height=it,Ae(kt),v(Mt=>Mt.find(En=>En.toastId===h.id)?Mt.map(En=>En.toastId===h.id?{...En,height:kt}:En):[{toastId:h.id,height:kt,position:h.position},...Mt])},[F,h.title,h.description,v,h.id,h.jsx,h.action,h.cancel]);const ot=de.useCallback(()=>{B(!0),ve(Cn.current),v(at=>at.filter(it=>it.toastId!==h.id)),setTimeout(()=>{C(h)},Vye)},[h,C,v,Cn]);de.useEffect(()=>{if(h.promise&&Le==="loading"||h.duration===1/0||h.type==="loading")return;let at;return k||b||Pe?(()=>{if(mr.current<At.current){const Mt=new Date().getTime()-At.current;Je.current=Je.current-Mt}mr.current=new Date().getTime()})():(()=>{Je.current!==1/0&&(At.current=new Date().getTime(),at=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),ot()},Je.current))})(),()=>clearTimeout(at)},[k,b,h,Le,Pe,ot]),de.useEffect(()=>{h.delete&&(ot(),h.onDismiss==null||h.onDismiss.call(h,h))},[ot,h.delete]);function $t(){var at;if(Z?.loading){var it;return de.createElement("div",{className:Ji(H?.loader,h==null||(it=h.classNames)==null?void 0:it.loader,"sonner-loader"),"data-visible":Le==="loading"},Z.loading)}return de.createElement(kye,{className:Ji(H?.loader,h==null||(at=h.classNames)==null?void 0:at.loader),visible:Le==="loading"})}const Rt=h.icon||Z?.[Le]||Eye(Le);var Xt,un;return de.createElement("li",{tabIndex:0,ref:Re,className:Ji(M,_e,H?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,H?.default,H?.[Le],h==null||(n=h.classNames)==null?void 0:n[Le]),"data-sonner-toast":"","data-rich-colors":(Xt=h.richColors)!=null?Xt:R,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":F,"data-promise":!!h.promise,"data-swiped":Q,"data-removed":P,"data-visible":me,"data-y-position":He,"data-x-position":Be,"data-index":_,"data-front":Ze,"data-swiping":K,"data-dismissible":Ke,"data-type":Le,"data-invert":Ve,"data-swipe-out":ie,"data-swipe-direction":L,"data-expanded":!!(k||re&&F),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${P?le:Cn.current}px`,"--initial-height":re?"auto":`${oe}px`,...N,...h.style},onDragEnd:()=>{ee(!1),ne(null),Ut.current=null},onPointerDown:at=>{at.button!==2&&(Qe||!Ke||(ke.current=new Date,ve(Cn.current),at.target.setPointerCapture(at.pointerId),at.target.tagName!=="BUTTON"&&(ee(!0),Ut.current={x:at.clientX,y:at.clientY})))},onPointerUp:()=>{var at,it,kt;if(ie||!Ke)return;Ut.current=null;const Mt=Number(((at=Re.current)==null?void 0:at.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),nr=Number(((it=Re.current)==null?void 0:it.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),En=new Date().getTime()-((kt=ke.current)==null?void 0:kt.getTime()),qn=ae==="x"?Mt:nr,se=Math.abs(qn)/En;if(Math.abs(qn)>=Hye||se>.11){ve(Cn.current),h.onDismiss==null||h.onDismiss.call(h,h),V(ae==="x"?Mt>0?"right":"left":nr>0?"down":"up"),ot(),ue(!0);return}else{var pe,ge;(pe=Re.current)==null||pe.style.setProperty("--swipe-amount-x","0px"),(ge=Re.current)==null||ge.style.setProperty("--swipe-amount-y","0px")}q(!1),ee(!1),ne(null)},onPointerMove:at=>{var it,kt,Mt;if(!Ut.current||!Ke||((it=window.getSelection())==null?void 0:it.toString().length)>0)return;const En=at.clientY-Ut.current.y,qn=at.clientX-Ut.current.x;var se;const pe=(se=e.swipeDirections)!=null?se:Gye(J);!ae&&(Math.abs(qn)>1||Math.abs(En)>1)&&ne(Math.abs(qn)>Math.abs(En)?"x":"y");let ge={x:0,y:0};const $e=De=>1/(1.5+Math.abs(De)/20);if(ae==="y"){if(pe.includes("top")||pe.includes("bottom"))if(pe.includes("top")&&En<0||pe.includes("bottom")&&En>0)ge.y=En;else{const De=En*$e(En);ge.y=Math.abs(De)<Math.abs(En)?De:En}}else if(ae==="x"&&(pe.includes("left")||pe.includes("right")))if(pe.includes("left")&&qn<0||pe.includes("right")&&qn>0)ge.x=qn;else{const De=qn*$e(qn);ge.x=Math.abs(De)<Math.abs(qn)?De:qn}(Math.abs(ge.x)>0||Math.abs(ge.y)>0)&&q(!0),(kt=Re.current)==null||kt.style.setProperty("--swipe-amount-x",`${ge.x}px`),(Mt=Re.current)==null||Mt.style.setProperty("--swipe-amount-y",`${ge.y}px`)}},wt&&!h.jsx&&Le!=="loading"?de.createElement("button",{"aria-label":G,"data-disabled":Qe,"data-close-button":!0,onClick:Qe||!Ke?()=>{}:()=>{ot(),h.onDismiss==null||h.onDismiss.call(h,h)},className:Ji(H?.closeButton,h==null||(r=h.classNames)==null?void 0:r.closeButton)},(un=Z?.close)!=null?un:Aye):null,(Le||h.icon||h.promise)&&h.icon!==null&&(Z?.[Le]!==null||h.icon)?de.createElement("div",{"data-icon":"",className:Ji(H?.icon,h==null||(a=h.classNames)==null?void 0:a.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||$t():null,h.type!=="loading"?Rt:null):null,de.createElement("div",{"data-content":"",className:Ji(H?.content,h==null||(i=h.classNames)==null?void 0:i.content)},de.createElement("div",{"data-title":"",className:Ji(H?.title,h==null||(o=h.classNames)==null?void 0:o.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?de.createElement("div",{"data-description":"",className:Ji(z,vt,H?.description,h==null||(l=h.classNames)==null?void 0:l.description)},typeof h.description=="function"?h.description():h.description):null),de.isValidElement(h.cancel)?h.cancel:h.cancel&&$b(h.cancel)?de.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:at=>{$b(h.cancel)&&Ke&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,at),ot())},className:Ji(H?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,de.isValidElement(h.action)?h.action:h.action&&$b(h.action)?de.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||$,onClick:at=>{$b(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,at),!at.defaultPrevented&&ot())},className:Ji(H?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function W4(){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 Kye(e,t){const n={};return[e,t].forEach((r,a)=>{const i=a===1,o=i?"--mobile-offset":"--offset",l=i?zye:Uye;function u(d){["top","right","bottom","left"].forEach(p=>{n[`${o}-${p}`]=typeof d=="number"?`${d}px`:d})}typeof r=="number"||typeof r=="string"?u(r):typeof r=="object"?["top","right","bottom","left"].forEach(d=>{r[d]===void 0?n[`${o}-${d}`]=l:n[`${o}-${d}`]=typeof r[d]=="number"?`${r[d]}px`:r[d]}):u(l)}),n}const U7=de.forwardRef(function(t,n){const{id:r,invert:a,position:i="bottom-right",hotkey:o=["altKey","KeyT"],expand:l,closeButton:u,className:d,offset:p,mobileOffset:h,theme:g="light",richColors:b,duration:v,style:x,visibleToasts:S=Pye,toastOptions:_,dir:E=W4(),gap:k=Bye,icons:C,containerAriaLabel:R="Notifications"}=t,[A,N]=de.useState([]),O=de.useMemo(()=>r?A.filter(F=>F.toasterId===r):A.filter(F=>!F.toasterId),[A,r]),$=de.useMemo(()=>Array.from(new Set([i].concat(O.filter(F=>F.position).map(F=>F.position)))),[O,i]),[M,z]=de.useState([]),[W,J]=de.useState(!1),[X,re]=de.useState(!1),[H,Z]=de.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=de.useRef(null),ae=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),ne=de.useRef(null),L=de.useRef(!1),V=de.useCallback(F=>{N(j=>{var P;return(P=j.find(B=>B.id===F.id))!=null&&P.delete||Ra.dismiss(F.id),j.filter(({id:B})=>B!==F.id)})},[]);return de.useEffect(()=>Ra.subscribe(F=>{if(F.dismiss){requestAnimationFrame(()=>{N(j=>j.map(P=>P.id===F.id?{...P,delete:!0}:P))});return}setTimeout(()=>{$G.flushSync(()=>{N(j=>{const P=j.findIndex(B=>B.id===F.id);return P!==-1?[...j.slice(0,P),{...j[P],...F},...j.slice(P+1)]:[F,...j]})})})}),[A]),de.useEffect(()=>{if(g!=="system"){Z(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;const F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:j})=>{Z(j?"dark":"light")})}catch{F.addListener(({matches:P})=>{try{Z(P?"dark":"light")}catch(B){console.error(B)}})}},[g]),de.useEffect(()=>{A.length<=1&&J(!1)},[A]),de.useEffect(()=>{const F=j=>{var P;if(o.every(ee=>j[ee]||j.code===ee)){var K;J(!0),(K=G.current)==null||K.focus()}j.code==="Escape"&&(document.activeElement===G.current||(P=G.current)!=null&&P.contains(document.activeElement))&&J(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[o]),de.useEffect(()=>{if(G.current)return()=>{ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null,L.current=!1)}},[G.current]),de.createElement("section",{ref:n,"aria-label":`${R} ${ae}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},$.map((F,j)=>{var P;const[B,K]=F.split("-");return O.length?de.createElement("ol",{key:F,dir:E==="auto"?W4():E,tabIndex:-1,ref:G,className:d,"data-sonner-toaster":!0,"data-sonner-theme":H,"data-y-position":B,"data-x-position":K,style:{"--front-toast-height":`${((P=M[0])==null?void 0:P.height)||0}px`,"--width":`${Fye}px`,"--gap":`${k}px`,...x,...Kye(p,h)},onBlur:ee=>{L.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(L.current=!1,ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||L.current||(L.current=!0,ne.current=ee.relatedTarget)},onMouseEnter:()=>J(!0),onMouseMove:()=>J(!0),onMouseLeave:()=>{X||J(!1)},onDragEnd:()=>J(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||re(!0)},onPointerUp:()=>re(!1)},O.filter(ee=>!ee.position&&j===0||ee.position===F).map((ee,ie)=>{var ue,Q;return de.createElement(Wye,{key:ee.id,icons:C,index:ie,toast:ee,defaultRichColors:b,duration:(ue=_?.duration)!=null?ue:v,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:a,visibleToasts:S,closeButton:(Q=_?.closeButton)!=null?Q:u,interacting:X,position:F,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:V,toasts:O.filter(q=>q.position==ee.position),heights:M.filter(q=>q.position==ee.position),setHeights:z,expandByDefault:l,gap:k,expanded:W,swipeDirections:t.swipeDirections})})):null}))}),K4=Object.freeze(Object.defineProperty({__proto__:null,Toaster:U7,toast:vn},Symbol.toStringTag,{value:"Module"}));var Iw="Dialog",[z7]=Wi(Iw),[Zye,Ki]=z7(Iw),F7=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=y.useRef(null),u=y.useRef(null),[d,p]=Xo({prop:r,defaultProp:a??!1,onChange:i,caller:Iw});return f.jsx(Zye,{scope:t,triggerRef:l,contentRef:u,contentId:Kr(),titleId:Kr(),descriptionId:Kr(),open:d,onOpenChange:p,onOpenToggle:y.useCallback(()=>p(h=>!h),[p]),modal:o,children:n})};F7.displayName=Iw;var B7="DialogTrigger",H7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(B7,n),i=yn(t,a.triggerRef);return f.jsx(Gt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":SC(a.open),...r,ref:i,onClick:rt(e.onClick,a.onOpenToggle)})});H7.displayName=B7;var yC="DialogPortal",[Yye,V7]=z7(yC,{forceMount:void 0}),G7=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,i=Ki(yC,t);return f.jsx(Yye,{scope:t,forceMount:n,children:y.Children.map(r,o=>f.jsx(Xa,{present:n||i.open,children:f.jsx(nf,{asChild:!0,container:a,children:o})}))})};G7.displayName=yC;var ty="DialogOverlay",W7=y.forwardRef((e,t)=>{const n=V7(ty,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,i=Ki(ty,e.__scopeDialog);return i.modal?f.jsx(Xa,{present:r||i.open,children:f.jsx(Xye,{...a,ref:t})}):null});W7.displayName=ty;var qye=lc("DialogOverlay.RemoveScroll"),Xye=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(ty,n);return f.jsx(Jm,{as:qye,allowPinchZoom:!0,shards:[a.contentRef],children:f.jsx(Gt.div,{"data-state":SC(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),dc="DialogContent",K7=y.forwardRef((e,t)=>{const n=V7(dc,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,i=Ki(dc,e.__scopeDialog);return f.jsx(Xa,{present:r||i.open,children:i.modal?f.jsx(Jye,{...a,ref:t}):f.jsx(Qye,{...a,ref:t})})});K7.displayName=dc;var Jye=y.forwardRef((e,t)=>{const n=Ki(dc,e.__scopeDialog),r=y.useRef(null),a=yn(t,n.contentRef,r);return y.useEffect(()=>{const i=r.current;if(i)return ww(i)},[]),f.jsx(Z7,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:rt(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:rt(e.onPointerDownOutside,i=>{const o=i.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&i.preventDefault()}),onFocusOutside:rt(e.onFocusOutside,i=>i.preventDefault())})}),Qye=y.forwardRef((e,t)=>{const n=Ki(dc,e.__scopeDialog),r=y.useRef(!1),a=y.useRef(!1);return f.jsx(Z7,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;n.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Z7=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=Ki(dc,n),u=y.useRef(null),d=yn(t,u);return fw(),f.jsxs(f.Fragment,{children:[f.jsx(Zm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:f.jsx(Qd,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":SC(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(ewe,{titleId:l.titleId}),f.jsx(nwe,{contentRef:u,descriptionId:l.descriptionId})]})]})}),wC="DialogTitle",Y7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(wC,n);return f.jsx(Gt.h2,{id:a.titleId,...r,ref:t})});Y7.displayName=wC;var q7="DialogDescription",X7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(q7,n);return f.jsx(Gt.p,{id:a.descriptionId,...r,ref:t})});X7.displayName=q7;var J7="DialogClose",Q7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ki(J7,n);return f.jsx(Gt.button,{type:"button",...r,ref:t,onClick:rt(e.onClick,()=>a.onOpenChange(!1))})});Q7.displayName=J7;function SC(e){return e?"open":"closed"}var eK="DialogTitleWarning",[kIe,tK]=Ffe(eK,{contentName:dc,titleName:wC,docsSlug:"dialog"}),ewe=({titleId:e})=>{const t=tK(eK),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
125
125
|
|
|
126
126
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
127
127
|
|
|
@@ -1688,7 +1688,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1688
1688
|
<\/script>
|
|
1689
1689
|
</body>
|
|
1690
1690
|
</html>`,oX=1,n3=2,sX=3,r3=4,lX=5,a3=Symbol.for("quilt.threads.serialize"),KRe=Symbol.for("quilt.threads.transferable");class ZRe extends AbortController{constructor(...t){super();const n=t.find(r=>r.aborted);if(n)this.abort(n.reason);else{const r=i=>this.abort(i.target.reason),a={signal:this.signal};for(const i of t)i.addEventListener("abort",r,a)}}}class i3 extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let YRe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function cX(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let r=0;r<e;r++)t+=YRe[63&n[r]];return t}var Ap,Tu,Ip,bv,Jk,uX;class qRe{constructor(){Ii(this,Jk),Ii(this,Ap,new Map),Ii(this,Tu,new Map),Ii(this,Ip,new Map),Ii(this,bv,new WeakMap)}get(t){return Qn(this,Tu).get(t)}release(t){const n=Qn(this,Tu).get(t);return n&&(Qn(this,Tu).delete(t),Qn(this,Ap).delete(n)),!!n}serialize(t){let n=Qn(this,Ap).get(t);return n==null&&(n=cX(),Qn(this,Ap).set(t,n),Qn(this,Tu).set(n,t)),n}deserialize(t,n){var r,a;let i=(r=Qn(this,Ip).get(t))==null?void 0:r.deref();return i||(i=(...o)=>{if(!Qn(this,Ip).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((l,u,d)=>{n.messages.send([sX,l,t,u],d)},o)},(a=Hr(this,Jk,uX).call(this,n))==null||a.register(i,t),Qn(this,Ip).set(t,new WeakRef(i)),i)}}Ap=new WeakMap,Tu=new WeakMap,Ip=new WeakMap,bv=new WeakMap,Jk=new WeakSet,uX=function(e){let t=Qn(this,bv).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([lX,n])}),Qn(this,bv).set(e,t)),t};function XRe(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function o3(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const $E="_@f",s3="_@i";var Xp,Jp,ui,vv,Ms;class JRe{constructor(t){Ii(this,ui),Ii(this,Xp),Ii(this,Jp),qk(this,Xp,t?.serialize),qk(this,Jp,t?.deserialize)}serialize(t,n,r){return Hr(this,ui,vv).call(this,t,n,r)}deserialize(t,n){return Hr(this,ui,Ms).call(this,t,n)}}Xp=new WeakMap,Jp=new WeakMap,ui=new WeakSet,vv=function(e,t,n,r=new Map,a=!1){if(e==null)return e;if(r.has(e))return r.get(e);if(r.set(e,void 0),typeof e=="object"){if(Qn(this,Xp)&&!a){const l=Qn(this,Xp).call(this,e,u=>Hr(this,ui,vv).call(this,u,t,n,r,!0),t,n);if(l!==void 0)return r.set(e,l),l}if(e[KRe])return n?.push(e),r.set(e,e),e;const i=l=>Hr(this,ui,vv).call(this,l,t,n,r);if(typeof e[a3]=="function"){const l=e[a3]({serialize:i});return r.set(e,l),l}if(Array.isArray(e)){const l=e.map(u=>i(u));return r.set(e,l),l}if(e instanceof Map){const l=[...e.entries()].map(([d,p])=>[i(d),i(p)]),u=new Map(l);return r.set(e,u),u}if(e instanceof Set){const l=[...e].map(d=>i(d)),u=new Set(l);return r.set(e,u),u}const o=XRe(e);if(o3(e)||o){const l={};for(const u of Object.keys(e))l[u]=i(e[u]);return o&&(l.next??(l.next=i(e.next.bind(e))),l.return??(l.return=i(e.return.bind(e))),l.throw??(l.throw=i(e.throw.bind(e))),l[s3]=!0),r.set(e,l),l}}if(typeof e=="function"){const i=t.functions.serialize(e,t,n),o={[$E]:i};return r.set(e,o),o}return r.set(e,e),e},Ms=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if(Qn(this,Jp)&&!n){const a=Qn(this,Jp).call(this,e,i=>Hr(this,ui,Ms).call(this,i,t,!0),t);if(a!==void 0)return a}if(e==null)return e;if(Array.isArray(e))return e.map(a=>Hr(this,ui,Ms).call(this,a,t));if(e instanceof Map)return new Map([...e].map(([a,i])=>[Hr(this,ui,Ms).call(this,a,t),Hr(this,ui,Ms).call(this,i,t)]));if(e instanceof Set)return new Set([...e].map(a=>Hr(this,ui,Ms).call(this,a,t)));if($E in e)return t.functions.deserialize(e[$E],t);if(!o3(e))return e;const r={};for(const a of Object.keys(e))a===s3?r[Symbol.asyncIterator]=()=>r:r[a]=Hr(this,ui,Ms).call(this,e[a],t);return r}return e};var Nu,Xl,Ps,Qk,dX,eT,fX;class QRe{constructor(t,{imports:n,exports:r,functions:a=new qRe,serialization:i=new JRe,signal:o}={}){Ii(this,Ps),Ii(this,Nu),Ii(this,Xl,new Map);var l,u,d,p;this.messages=t,qk(this,Nu,o?new ZRe(o):new AbortController),this.exports=r??{},this.imports=eCe(Hr(this,Ps,dX).bind(this),n),this.functions=a,this.serialization=i,(u=(l=this.functions).start)==null||u.call(l,this),(p=(d=this.serialization).start)==null||p.call(d,this),this.signal.addEventListener("abort",()=>{for(const h of Qn(this,Xl).keys())Hr(this,Ps,eT).call(this,h,void 0,new i3);Qn(this,Xl).clear()},{once:!0}),t.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case oX:{const[,b,v,x]=g,S=this.exports[v]??(()=>{throw new Error(`No '${v}' method is exported from this thread`)});await Hr(this,Ps,Qk).call(this,S,x,(_,E,k)=>{this.messages.send([n3,b,_,E],k)});break}case sX:{const[,b,v,x]=g,S=this.functions.get(v,this)??tCe;await Hr(this,Ps,Qk).call(this,S,x,(_,E,k)=>{this.messages.send([r3,b,_,E],k)});break}case n3:case r3:{Hr(this,Ps,eT).call(this,...g.slice(1));break}case lX:{const b=g[1];this.functions.release(b,this);break}}},{signal:this.signal})}get signal(){return Qn(this,Nu).signal}get closed(){return Qn(this,Nu).signal.aborted}close(){Qn(this,Nu).abort()}call(t,n){if(this.closed)return Promise.reject(new i3);const r=[],a=this.serialization.serialize(n,this,r),i=cX(),o=Hr(this,Ps,fX).call(this,i);return t(i,a,r),o}}Nu=new WeakMap,Xl=new WeakMap,Ps=new WeakSet,Qk=async function(e,t,n){try{const r=this.functions.call?await this.functions.call(e,t,this):await e(...this.serialization.deserialize(t,this)),a=[],i=this.serialization.serialize(r,this,a);n(i,void 0,a)}catch(r){n(void 0,this.serialization.serialize(r,this))}},dX=function(e){return(...t)=>{try{if(typeof e!="string"&&typeof e!="number")throw new Error(`Can’t call a symbol method on a thread: ${e.toString()}`);return this.call((n,r,a)=>{this.messages.send([oX,n,e,r],a)},t)}catch(n){return Promise.reject(n)}}},eT=function(...e){const t=e[0],n=Qn(this,Xl).get(t);n&&(n(...e),Qn(this,Xl).delete(t))},fX=function(e){const t=new Promise((n,r)=>{Qn(this,Xl).set(e,(a,i,o)=>{o==null?n(this.serialization.deserialize(i,this)):r(this.serialization.deserialize(o,this))})});return Object.defineProperty(t,Symbol.asyncIterator,{async*value(){const n=await t;Object.defineProperty(n,Symbol.asyncIterator,{value:()=>n}),yield*n}}),t};function eCe(e,t){let n;if(t==null){if(typeof Proxy!="function")throw new Error("You must pass an array of callable methods in environments without Proxies.");const r=new Map;n=new Proxy({},{get(a,i){if(r.has(i))return r.get(i);const o=e(i);return r.set(i,o),o}})}else{n={};for(const r of t)Object.defineProperty(n,r,{value:e(r),writable:!1,configurable:!0,enumerable:!0})}return n}function tCe(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const nCe="quilt.threads.ping",l3="quilt.threads.pong";function rCe(e,{targetOrigin:t="*"}={}){let n=!1;const r=function(i,o){e.postMessage(i,t,o)},a=new Promise(i=>{const o=new AbortController;globalThis.window.addEventListener("message",l=>{l.source===e&&l.data===l3&&(n=!0,o.abort(),i())},{signal:o.signal}),o.signal.addEventListener("abort",()=>i(),{once:!0}),r(nCe)});return{send(i,o){return n?r(i,o):a.then(()=>{if(n)return r(i,o)})},listen(i,{signal:o}){self.addEventListener("message",l=>{l.source===e&&l.data!==l3&&i(l.data)},{signal:o})}}}class aCe extends QRe{constructor(t,{targetOrigin:n="*",...r}={}){super(rCe(t.contentWindow,{targetOrigin:n}),r),this.iframe=t}}const pX=de.forwardRef(({content:e,children:t,...n},r)=>f.jsx("span",{ref:r,...n,children:e||t}));pX.displayName="UIText";const mX=de.forwardRef(({label:e,onPress:t,onClick:n,children:r,...a},i)=>f.jsx("button",{ref:i,onClick:o=>{t&&t(),n&&n(o)},style:{padding:"8px 16px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},...a,children:e||r}));mX.displayName="UIButton";const hX=de.forwardRef(({direction:e="vertical",spacing:t="8",align:n="stretch",justify:r="flex-start",children:a,...i},o)=>f.jsx("div",{ref:o,style:{display:"flex",flexDirection:e==="horizontal"?"row":"column",gap:`${t}px`,alignItems:n,justifyContent:r},...i,children:a}));hX.displayName="UIStack";const gX=de.forwardRef(({src:e,alt:t,width:n,height:r,children:a,...i},o)=>f.jsx("img",{ref:o,src:e,alt:t,width:n,height:r,style:{maxWidth:"100%",height:"auto",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)"},...i}));gX.displayName="UIImage";const ML={name:"basic",elements:[{tagName:"ui-text",component:pX,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:mX,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:hX,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:gX,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},iCe=({receiver:e})=>{const t=y.useRef(null);return y.useEffect(()=>{if(t.current)return e.connect(t.current),()=>{e.disconnect()}},[e]),f.jsx("div",{ref:t,"data-testid":"standard-dom-renderer-container"})},oCe=({resource:e,library:t,remoteElements:n=[],onUIAction:r})=>{const a=y.useRef(null),i=y.useRef(null),[o,l]=y.useState(null),u=y.useMemo(()=>(e.mimeType||"").includes("framework=react")?"react":"webcomponents",[e.mimeType]),d=`${t?.name}-${u}`,{receiver:p,components:h}=y.useMemo(()=>{switch(u){case"react":{const b=new MRe,v=t||ML,x=new Map;return v&&v.elements.forEach(S=>{const _=HRe(S.component);x.set(S.tagName,_)}),{receiver:b,components:x}}case"webcomponents":default:return{receiver:new PRe,components:null}}},[e,t,n]);y.useEffect(()=>{function b(v){var x;if(a.current&&v.source===a.current.contentWindow){const S=v.data;if(!S)return;(x=r?.(S))==null||x.catch(_=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",_)})}}return window.addEventListener("message",b),()=>window.removeEventListener("message",b)},[r]),y.useEffect(()=>{const b=i.current;return i.current=null,()=>{b?.close()}},[d]);const g=()=>{const b=a.current;if(!b||i.current)return;const v=new aCe(b);i.current=v;const{code:x,error:S}=RRe(e);if(S){l(S);return}if(x&&p!=null&&p.connection){const _={code:x,remoteElements:n,useReactRenderer:u==="react",componentLibrary:t?.name};v.imports.render(_,p.connection).catch(E=>console.error("Error calling remote render:",E))}};return o?f.jsx("p",{className:"text-red-500",children:o}):f.jsxs(f.Fragment,{children:[f.jsx("iframe",{ref:a,srcDoc:WRe,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},d),u==="react"&&h?f.jsx(GRe,{receiver:p,components:h}):f.jsx(iCe,{receiver:p})]})};function sCe(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 PL=e=>{const{resource:t,onUIAction:n,supportedContentTypes:r,htmlProps:a,remoteDomProps:i}=e,o=sCe(t);if(r&&o&&!r.includes(o))return f.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",o,"."]});switch(o){case"rawHtml":case"externalUrl":return f.jsx(eX,{resource:t,onUIAction:n,...a});case"remoteDom":return f.jsx(oCe,{resource:t,onUIAction:n,library:i?.library||ML,...i});default:return f.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};PL.displayName="UIResourceRenderer";const lCe={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},cCe={tagName:"ui-text",remoteAttributes:["content"]},uCe={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},dCe={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},fCe=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://")?f.jsx("div",{className:"my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card",children:f.jsx(PL,{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 c3({toolName:e,toolArgs:t,result:n,serverId:r,readResource:a,toolMeta:i}){const[o,l]=y.useState(null);y.useEffect(()=>{console.log("[ToolResultRenderer] Rendering:",{toolName:e,hasToolMeta:!!i,outputTemplate:i?.["openai/outputTemplate"],hasResult:!!n,hasServerId:!!r,hasReadResource:!!a})},[e,i,n,r,a]);const u=y.useMemo(()=>{if(typeof n=="string")try{return JSON.parse(n)}catch(b){return console.error("[ToolResultRenderer] Failed to parse result:",b),n}return n},[n]),d=y.useMemo(()=>!!i?.["openai/outputTemplate"],[i]),p=y.useMemo(()=>!!(u?.content&&Array.isArray(u.content)&&u.content.some(b=>b.type==="resource"&&b.resource?.uri?.startsWith("ui://")&&b.resource?.mimeType==="text/html+skybridge")),[u]),h=y.useMemo(()=>p&&u.content.find(v=>v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType==="text/html+skybridge")?.resource||null,[p,u]);if(y.useEffect(()=>{if(h){l(h);return}if(d&&i&&a){const b=i["openai/outputTemplate"];console.log("[ToolResultRenderer] Fetching resource for Apps SDK tool:",b),a(b).then(v=>{console.log("[ToolResultRenderer] Resource fetched:",v),v?.contents&&Array.isArray(v.contents)&&v.contents.length>0?l(v.contents[0]):console.warn("[ToolResultRenderer] No contents in fetched resource:",v)}).catch(v=>{console.error("[ToolResultRenderer] Failed to fetch resource:",v)})}},[h,d,i,a]),(d||p)&&o&&r&&a)return f.jsx(OL,{componentUrl:o.uri,toolName:e,toolArgs:t,toolResult:u,serverId:r,readResource:a,noWrapper:!0,className:"my-4",showConsole:!1});if((d||p)&&!o)return f.jsx("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:f.jsx(Fi,{className:"size-5"})});if(d&&(!r||!a))return console.error("[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:",{toolName:e,hasServerId:!!r,hasReadResource:!!a}),f.jsx("div",{className:"my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg",children:f.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:"Cannot render widget: Missing required props (serverId or readResource)"})});const g=[];if(u?.content&&Array.isArray(u.content))for(const b of u.content)b.type==="resource"&&b.resource?.uri?.startsWith("ui://")&&b.resource?.mimeType!=="text/html+skybridge"&&g.push(b.resource);return g.length>0?f.jsx(f.Fragment,{children:g.map(b=>f.jsx(fCe,{resource:b},`${e}-mcp-ui-${b.uri}`))}):(console.log("[ToolResultRenderer] Not rendering (no UI resources found):",{toolName:e,isAppsSdkTool:d,hasAppsSdkComponent:p,hasResourceData:!!o,contentLength:u?.content?.length}),null)}function pCe({content:e,timestamp:t}){return!e||e.length===0?null:f.jsx("div",{className:"flex items-start gap-3 justify-end group/user-message",children:f.jsxs("div",{className:"flex-1 min-w-0 flex flex-col items-end",children:[f.jsx("div",{className:"bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words",children:f.jsx("p",{className:"text-base leading-7 font-sans text-start break-words",children:e})}),t&&f.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:new Date(t).toLocaleTimeString()})]})})}const mCe=y.memo(({messages:e,isLoading:t,serverId:n,readResource:r,tools:a})=>{const i=y.useRef(null),o=d=>a?.find(h=>h.name===d)?._meta;y.useEffect(()=>{e.length>0&&i.current&&i.current.scrollIntoView({behavior:t?"auto":"smooth",block:"start"})},[e.length,t]);const l=t&&(()=>{if(e.length===0)return!0;const d=e[e.length-1];if(d.role==="user")return!0;if(d.role==="assistant"){const p=typeof d.content=="string"?d.content:Array.isArray(d.content)?d.content.map(g=>typeof g=="string"?g:g.text||JSON.stringify(g)).join(""):JSON.stringify(d.content);return!(p&&p.trim().length>0)}return!1})(),u=d=>{if(!t)return!1;const p=e[e.length-1];return d.id===p.id&&p.role==="assistant"};return f.jsxs("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(d=>{const p=typeof d.content=="string"?d.content:Array.isArray(d.content)?d.content.map(h=>typeof h=="string"?h:h.text||JSON.stringify(h)).join(""):JSON.stringify(d.content);return d.role==="user"?f.jsx(pCe,{content:p,timestamp:d.timestamp},d.id):d.role==="assistant"?f.jsx("div",{className:"space-y-4",children:d.parts&&d.parts.length>0?d.parts.map((h,g)=>{const b=h.type==="text"?`${d.id}-text-${g}-${h.text?.slice(0,20)}`:`${d.id}-tool-${h.toolInvocation?.toolName}-${g}`;return h.type==="text"?f.jsx(WF,{content:h.text||"",timestamp:g===d.parts.length-1?d.timestamp:void 0,_isStreaming:u(d)},b):h.type==="tool-invocation"&&h.toolInvocation?f.jsxs("div",{children:[f.jsx(KF,{toolName:h.toolInvocation.toolName,args:h.toolInvocation.args,result:h.toolInvocation.result,state:h.toolInvocation.result?"result":"call"}),h.toolInvocation.result&&f.jsx(c3,{toolName:h.toolInvocation.toolName,toolArgs:h.toolInvocation.args,result:h.toolInvocation.result,serverId:n,readResource:r,toolMeta:o(h.toolInvocation.toolName)})]},b):null}):f.jsxs(f.Fragment,{children:[f.jsx(WF,{content:p,timestamp:d.timestamp,_isStreaming:u(d)}),d.toolCalls&&d.toolCalls.length>0&&f.jsx("div",{className:"space-y-2",children:d.toolCalls.map(h=>{const g=`${d.id}-${h.toolName}-${JSON.stringify(h.args).slice(0,50)}`;return f.jsxs("div",{children:[f.jsx(KF,{toolName:h.toolName,args:h.args,result:h.result,state:h.result?"result":"call"}),h.result&&f.jsx(c3,{toolName:h.toolName,toolArgs:h.args,result:h.result,serverId:n,readResource:r,toolMeta:o(h.toolName)})]},g)})})]})},d.id):null}),l&&f.jsx("div",{className:"flex items-start gap-3",children:f.jsx("div",{className:"flex-1",children:f.jsx("div",{className:"rounded-lg p-4 max-w-fit",children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("span",{className:"text-sm",children:f.jsx(Oke,{duration:2,spread:1,children:"Thinking..."})})})})})}),f.jsx("div",{ref:i})]})});function bX(e){let t=0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t=(t<<5)-t+r,t=t&t}return Math.abs(t).toString(16)}function hCe({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:r}){const[a,i]=y.useState([]),[o,l]=y.useState(!1),u=y.useCallback(async p=>{if(!p.trim()||!t||!r)return;const h={id:`user-${Date.now()}`,role:"user",content:p.trim(),timestamp:Date.now()};i(g=>[...g,h]),l(!0);try{let g=n;if(n?.type==="oauth")try{const C="mcp:auth",R=bX(e),A=`${C}_${R}_tokens`,N=localStorage.getItem(A);if(N){const O=JSON.parse(N);g={...n,oauthTokens:O}}else console.warn("No OAuth tokens found in localStorage for key:",A)}catch(C){console.warn("Failed to retrieve OAuth tokens:",C)}const b=await fetch("/inspector/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServerUrl:e,llmConfig:t,authConfig:g,messages:[...a,h].map(C=>({role:C.role,content:C.content}))})});if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);const v=`assistant-${Date.now()}`;let x="";const S=[];i(C=>[...C,{id:v,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);const _=b.body?.getReader(),E=new TextDecoder;if(!_)throw new Error("No response body");let k="";for(;;){const{done:C,value:R}=await _.read();if(C)break;k+=E.decode(R,{stream:!0});const A=k.split(`
|
|
1691
|
-
`);k=A.pop()||"";for(const N of A)if(N.trim()&&N.startsWith("data: "))try{const O=JSON.parse(N.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 $=S[S.length-1];$&&$.type==="text"?$.text=x:S.push({type:"text",text:x}),console.log("[Parts after text]",S.length,"parts, text length:",x.length),i(M=>M.map(z=>z.id===v?{...z,parts:[...S]}:z))}else if(O.type==="tool-call")x&&(x=""),S.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",S.length,"parts, tool:",O.toolName),i($=>$.map(M=>M.id===v?{...M,parts:[...S]}:M));else if(O.type==="tool-result"){const $=S.find(M=>M.type==="tool-invocation"&&M.toolInvocation?.toolName===O.toolName&&!M.toolInvocation?.result);$&&$.toolInvocation?($.toolInvocation.result=O.result,$.toolInvocation.state="result",console.log("[Parts after tool-result]",S.length,"parts, updated:",O.toolName),i(M=>M.map(z=>z.id===v?{...z,parts:[...S]}:z))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",S.length),i($=>$.map(M=>M.id===v?{...M,parts:[...S],content:""}:M));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,N)}}}catch(g){let b="Unknown error occurred";if(g instanceof Error){b=g.message;const x=g;x.status&&(b=`HTTP ${x.status}: ${b}`),(x.code===401||b.includes("401")||b.includes("Unauthorized"))&&(b="Authentication failed (401). Check your Authorization header in the connection settings.")}const v={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${b}`,timestamp:Date.now()};i(x=>[...x,v])}finally{l(!1)}},[t,r,e,a,n]),d=y.useCallback(()=>{i([])},[]);return{messages:a,isLoading:o,sendMessage:u,clearMessages:d}}function gCe({connection:e,llmConfig:t,isConnected:n,readResource:r}){const[a,i]=y.useState([]),[o,l]=y.useState(!1),u=y.useRef(null),d=y.useRef(null),p=y.useRef(null),h=y.useCallback(async b=>{if(!b.trim()||!t||!n)return;const v={id:`user-${Date.now()}`,role:"user",content:b.trim(),timestamp:Date.now()};i(_=>[..._,v]),l(!0),u.current=new AbortController;const x=Date.now();let S=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(C=>[...C,{id:_,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]),!p.current||p.current.provider!==t.provider||p.current.model!==t.model||p.current.apiKey!==t.apiKey){let C;if(t.provider==="openai"){const{ChatOpenAI:R}=await pr(async()=>{const{ChatOpenAI:A}=await import("./index-CyjpFzxN.js");return{ChatOpenAI:A}},__vite__mapDeps([5,6,7,2,8,9]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:R}=await pr(async()=>{const{ChatAnthropic:A}=await import("./index-1oOUdn3H.js");return{ChatAnthropic:A}},__vite__mapDeps([10,7,6,2]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:R}=await pr(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-DdjBoJpx.js");return{ChatGoogleGenerativeAI:A}},__vite__mapDeps([11,7,6,2,9]));C=new R({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);p.current={instance:C,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==p.current.instance){const{MCPAgent:C}=await pr(async()=>{const{MCPAgent:R}=await import("./browser-CQhvXRgA.js").then(A=>A.b);return{MCPAgent:R}},__vite__mapDeps([12,4,3,8,6,7,2,9]));d.current=new C({llm:p.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await d.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",d.current.conversationHistory?.length);for await(const C of d.current.streamEvents(b,10,!1,void 0)){if(u.current?.signal.aborted)break;if(C.event==="on_chat_model_stream"&&C.data?.chunk?.text){const R=C.data.chunk.text;if(typeof R=="string"&&R.length>0){E+=R;const A=k[k.length-1];A&&A.type==="text"?A.text=E:k.push({type:"text",text:E}),i(N=>N.map(O=>O.id===_?{...O,parts:[...k]}:O))}}else if(C.event==="on_tool_start"){E&&(E="");let R={};C.data?.input?R=C.data.input:C.data?.tool_input?R=C.data.tool_input:C.data&&(R=C.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:C.name,eventData:C.data,extractedArgs:R}),S++,k.push({type:"tool-invocation",toolInvocation:{toolName:C.name||"unknown",args:R,state:"pending"}}),i(A=>A.map(N=>N.id===_?{...N,parts:[...k]}:N))}else if(C.event==="on_tool_end"){const R=k.find(A=>A.type==="tool-invocation"&&A.toolInvocation?.toolName===C.name&&!A.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:C.name,hasToolPart:!!R,output:C.data?.output}),R&&R.toolInvocation){let A=C.data?.output;if(A?.kwargs?.content&&typeof A.kwargs.content=="string")try{A=JSON.parse(A.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),A=A.kwargs.content}else if(A?.content&&typeof A.content=="string")try{A=JSON.parse(A.content)}catch{A=A.content}R.toolInvocation.result=A,R.toolInvocation.state="result";const N=A?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:C.name,hasMeta:!!A?._meta,hasStructuredContent:!!A?.structuredContent,appsSdkUri:N}),N&&typeof N=="string"&&r){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",N);try{const O=await r(N);console.log("[useChatMessagesClientSide] Resource fetched:",O);const $=A?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const M=O.contents.map(W=>({type:"resource",resource:W}));console.log("[useChatMessagesClientSide] Created MCP resources:",M);const z={...A,content:[...A.content||[],...M],structuredContent:$};R.toolInvocation.result=z,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($=>$.id===_?{...$,parts:[...k]}:$))}}}i(C=>C.map(R=>R.id===_?{...R,parts:[...k],content:""}:R)),t&&Or.getInstance().capture(new U4({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:S,success:!0,executionMode:"client-side",duration:Date.now()-x})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const C=_;C.status&&(E=`HTTP ${C.status}: ${E}`),(C.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&Or.getInstance().capture(new U4({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:S,success:!1,executionMode:"client-side",duration:Date.now()-x,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(C=>[...C,k])}finally{l(!1),u.current=null}},[e,t,n,a,r]),g=y.useCallback(()=>{i([]),d.current&&d.current.clearConversationHistory()},[]);return{messages:a,isLoading:o,sendMessage:h,clearMessages:g}}const u3={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function vX({mcpServerUrl:e}){const[t,n]=y.useState(null),[r,a]=y.useState(null),[i,o]=y.useState(!1),[l,u]=y.useState("openai"),[d,p]=y.useState(""),[h,g]=y.useState(u3.openai),b=y.useCallback(()=>{const $=localStorage.getItem("mcp-inspector-api-keys");if($)try{return JSON.parse($)}catch(M){return console.error("Failed to load API keys:",M),{}}return{}},[]),v=y.useCallback($=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify($))},[]),[x,S]=y.useState("none"),[_,E]=y.useState(""),[k,C]=y.useState(""),[R,A]=y.useState("");y.useEffect(()=>{const $=localStorage.getItem("mcp-inspector-llm-config"),M=b();if($)try{const z=JSON.parse($);n(z),u(z.provider),p(M[z.provider]||z.apiKey||""),g(z.model)}catch(z){console.error("Failed to load LLM config:",z)}},[b]),y.useEffect(()=>{const $=localStorage.getItem("mcp-inspector-auth-config");if($)try{const M=JSON.parse($);a(M),S(M.type),M.username&&E(M.username),M.password&&C(M.password),M.token&&A(M.token)}catch(M){console.error("Failed to load auth config:",M)}else try{const M="mcp:auth",z=bX(e),W=`${M}_${z}_tokens`;localStorage.getItem(W)&&(a({type:"oauth"}),S("oauth"))}catch(M){console.error("Failed to check for OAuth tokens:",M)}},[e]),y.useEffect(()=>{g(u3[l]);const $=b();p($[l]||"")},[l,b]);const N=y.useCallback(()=>{if(!d.trim())return;const $=b();$[l]=d,v($);const M={provider:l,apiKey:d,model:h},z={type:x,...x==="basic"&&{username:_.trim(),password:k.trim()},...x==="bearer"&&{token:R.trim()}};n(M),a(z),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(M)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(z)),o(!1)},[l,d,h,x,_,k,R,b,v]),O=y.useCallback(()=>{n(null),a(null);const $=b();delete $[l],v($),p(""),E(""),C(""),A(""),S("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[l,b,v]);return{llmConfig:t,authConfig:r,configDialogOpen:i,setConfigDialogOpen:o,tempProvider:l,setTempProvider:u,tempApiKey:d,setTempApiKey:p,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:N,clearConfig:O}}function bCe({connection:e,isConnected:t,useClientSide:n=!0,readResource:r}){const[a,i]=y.useState(""),o=y.useRef(null),{llmConfig:l,authConfig:u,configDialogOpen:d,setConfigDialogOpen:p,tempProvider:h,setTempProvider:g,tempApiKey:b,setTempApiKey:v,tempModel:x,setTempModel:S,saveLLMConfig:_,clearConfig:E}=vX({mcpServerUrl:e.url}),k={connection:e,llmConfig:l,isConnected:t,readResource:r},C=hCe({mcpServerUrl:e.url,llmConfig:l,authConfig:u,isConnected:t}),R=gCe(k),{messages:A,isLoading:N,sendMessage:O,clearMessages:$}=n?R:C;gY({onNewChat:$}),y.useEffect(()=>{l&&A.length===0&&o.current&&o.current.focus()},[l,A.length]),y.useEffect(()=>{!N&&A.length>0&&o.current&&o.current.focus()},[N,A.length]);const M=y.useCallback(()=>{a.trim()&&(O(a),i(""))},[a,O]),z=y.useCallback(J=>{J.key==="Enter"&&!J.shiftKey&&(J.preventDefault(),M())},[M]),W=y.useCallback(()=>{E(),$()},[E,$]);return l&&A.length===0?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"absolute top-4 right-4 z-10",children:f.jsx(Tk,{open:d,onOpenChange:p,tempProvider:h,tempModel:x,tempApiKey:b,onProviderChange:g,onModelChange:S,onApiKeyChange:v,onSave:_,onClear:W,showClearButton:!0,buttonLabel:"Change API Key"})}),f.jsx(Ake,{mcpServerUrl:e.url,inputValue:a,isConnected:t,isLoading:N,textareaRef:o,llmConfig:l,onInputChange:i,onKeyDown:z,onSubmit:J=>{J.preventDefault(),M()},onConfigDialogOpenChange:p})]}):f.jsxs("div",{className:"flex flex-col h-full relative",children:[f.jsx(Nke,{llmConfig:l,hasMessages:A.length>0,configDialogOpen:d,onConfigDialogOpenChange:p,onClearChat:$,tempProvider:h,tempModel:x,tempApiKey:b,onProviderChange:g,onModelChange:S,onApiKeyChange:v,onSaveConfig:_,onClearConfig:W}),f.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:l?f.jsx(mCe,{messages:A,isLoading:N,serverId:e.url,readResource:r,tools:e.tools}):f.jsx(Ike,{onConfigureClick:()=>p(!0)})}),l&&f.jsx(Rke,{inputValue:a,isConnected:t,isLoading:N,textareaRef:o,onInputChange:i,onKeyDown:z,onSendMessage:M})]})}const a0=y.createContext(null);a0.displayName="PanelGroupContext";const lr={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"},UL=10,nc=y.useLayoutEffect,d3=Gd.useId,vCe=typeof d3=="function"?d3:()=>null;let yCe=0;function zL(e=null){const t=vCe(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+yCe++),e??n.current}function yX({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:a,forwardedRef:i,id:o,maxSize:l,minSize:u,onCollapse:d,onExpand:p,onResize:h,order:g,style:b,tagName:v="div",...x}){const S=y.useContext(a0);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:C,groupId:R,isPanelCollapsed:A,reevaluatePanelConstraints:N,registerPanel:O,resizePanel:$,unregisterPanel:M}=S,z=zL(o),W=y.useRef({callbacks:{onCollapse:d,onExpand:p,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:a,maxSize:l,minSize:u},id:z,idIsFromProps:o!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),nc(()=>{const{callbacks:X,constraints:re}=W.current,H={...re};W.current.id=z,W.current.idIsFromProps=o!==void 0,W.current.order=g,X.onCollapse=d,X.onExpand=p,X.onResize=h,re.collapsedSize=n,re.collapsible=r,re.defaultSize=a,re.maxSize=l,re.minSize=u,(H.collapsedSize!==re.collapsedSize||H.collapsible!==re.collapsible||H.maxSize!==re.maxSize||H.minSize!==re.minSize)&&N(W.current,H)}),nc(()=>{const X=W.current;return O(X),()=>{M(X)}},[g,z,O,M]),y.useImperativeHandle(i,()=>({collapse:()=>{_(W.current)},expand:X=>{E(W.current,X)},getId(){return z},getSize(){return k(W.current)},isCollapsed(){return A(W.current)},isExpanded(){return!A(W.current)},resize:X=>{$(W.current,X)}}),[_,E,k,A,z,$]);const J=C(W.current,a);return y.createElement(v,{...x,children:e,className:t,id:z,style:{...J,...b},[lr.groupId]:R,[lr.panel]:"",[lr.panelCollapsible]:r||void 0,[lr.panelId]:z,[lr.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const wX=y.forwardRef((e,t)=>y.createElement(yX,{...e,forwardedRef:t}));yX.displayName="Panel";wX.displayName="forwardRef(Panel)";let tT=null,yv=-1,Hs=null;function wCe(e,t,n){const r=(t&kX)!==0,a=(t&TX)!==0,i=(t&NX)!==0,o=(t&RX)!==0;if(t){if(r)return i?"se-resize":o?"ne-resize":"e-resize";if(a)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function SCe(){Hs!==null&&(document.head.removeChild(Hs),tT=null,Hs=null,yv=-1)}function ME(e,t,n){var r,a;const i=wCe(e,t);if(tT!==i){if(tT=i,Hs===null&&(Hs=document.createElement("style"),document.head.appendChild(Hs)),yv>=0){var o;(o=Hs.sheet)===null||o===void 0||o.removeRule(yv)}yv=(r=(a=Hs.sheet)===null||a===void 0?void 0:a.insertRule(`*{cursor: ${i} !important;}`))!==null&&r!==void 0?r:-1}}function SX(e){return e.type==="keydown"}function xX(e){return e.type.startsWith("pointer")}function EX(e){return e.type.startsWith("mouse")}function i0(e){if(xX(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(EX(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function xCe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function ECe(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 _Ce(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:m3(e),b:m3(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Jt(r,"Stacking order can only be calculated for elements with a common ancestor");const a={a:p3(f3(n.a)),b:p3(f3(n.b))};if(a.a===a.b){const i=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let l=i.length;for(;l--;){const u=i[l];if(u===o.a)return 1;if(u===o.b)return-1}}return Math.sign(a.a-a.b)}const kCe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function TCe(e){var t;const n=getComputedStyle((t=_X(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function NCe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||TCe(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"||kCe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function f3(e){let t=e.length;for(;t--;){const n=e[t];if(Jt(n,"Missing node"),NCe(n))return n}return null}function p3(e){return e&&Number(getComputedStyle(e).zIndex)||0}function m3(e){const t=[];for(;e;)t.push(e),e=_X(e);return t}function _X(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const kX=1,TX=2,NX=4,RX=8,RCe=xCe()==="coarse";let $i=[],ed=!1,Vs=new Map,o0=new Map;const Rm=new Set;function CCe(e,t,n,r,a){var i;const{ownerDocument:o}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:a},u=(i=Vs.get(o))!==null&&i!==void 0?i:0;return Vs.set(o,u+1),Rm.add(l),Ny(),function(){var p;o0.delete(e),Rm.delete(l);const h=(p=Vs.get(o))!==null&&p!==void 0?p:1;if(Vs.set(o,h-1),Ny(),h===1&&Vs.delete(o),$i.includes(l)){const g=$i.indexOf(l);g>=0&&$i.splice(g,1),s0(),a("up",!0,null)}}}function ACe(e){const{target:t}=e,{x:n,y:r}=i0(e);ed=!0,FL({target:t,x:n,y:r}),Ny(),$i.length>0&&(Ry("down",e),s0(),e.preventDefault(),CX(t)||e.stopImmediatePropagation())}function PE(e){const{x:t,y:n}=i0(e);if(ed&&e.type!=="pointerleave"&&e.buttons===0&&(ed=!1,Ry("up",e)),!ed){const{target:r}=e;FL({target:r,x:t,y:n})}Ry("move",e),s0(),$i.length>0&&e.preventDefault()}function UE(e){const{target:t}=e,{x:n,y:r}=i0(e);o0.clear(),ed=!1,$i.length>0&&(e.preventDefault(),CX(t)||e.stopImmediatePropagation()),Ry("up",e),FL({target:t,x:n,y:r}),s0(),Ny()}function CX(e){let t=e;for(;t;){if(t.hasAttribute(lr.resizeHandle))return!0;t=t.parentElement}return!1}function FL({target:e,x:t,y:n}){$i.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Rm.forEach(a=>{const{element:i,hitAreaMargins:o}=a,l=i.getBoundingClientRect(),{bottom:u,left:d,right:p,top:h}=l,g=RCe?o.coarse:o.fine;if(t>=d-g&&t<=p+g&&n>=h-g&&n<=u+g){if(r!==null&&document.contains(r)&&i!==r&&!i.contains(r)&&!r.contains(i)&&_Ce(r,i)>0){let v=r,x=!1;for(;v&&!v.contains(i);){if(ECe(v.getBoundingClientRect(),l)){x=!0;break}v=v.parentElement}if(x)return}$i.push(a)}})}function zE(e,t){o0.set(e,t)}function s0(){let e=!1,t=!1;$i.forEach(r=>{const{direction:a}=r;a==="horizontal"?e=!0:t=!0});let n=0;o0.forEach(r=>{n|=r}),e&&t?ME("intersection",n):e?ME("horizontal",n):t?ME("vertical",n):SCe()}let FE;function Ny(){var e;(e=FE)===null||e===void 0||e.abort(),FE=new AbortController;const t={capture:!0,signal:FE.signal};Rm.size&&(ed?($i.length>0&&Vs.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("contextmenu",UE,t),a.addEventListener("pointerleave",PE,t),a.addEventListener("pointermove",PE,t))}),Vs.forEach((n,r)=>{const{body:a}=r;a.addEventListener("pointerup",UE,t),a.addEventListener("pointercancel",UE,t)})):Vs.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("pointerdown",ACe,t),a.addEventListener("pointermove",PE,t))}))}function Ry(e,t){Rm.forEach(n=>{const{setResizeHandlerState:r}=n,a=$i.includes(n);r(e,a,t)})}function ICe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function Jt(e,t){if(!e)throw console.error(t),Error(t)}function bc(e,t,n=UL){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Fo(e,t,n=UL){return bc(e,t,n)===0}function Ha(e,t,n){return bc(e,t,n)===0}function OCe(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const a=e[r],i=t[r];if(!Ha(a,i,n))return!1}return!0}function Bu({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Jt(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:i,maxSize:o=100,minSize:l=0}=r;if(bc(n,l)<0)if(i){const u=(a+l)/2;bc(n,u)<0?n=a:n=l}else n=l;return n=Math.min(o,n),n=parseFloat(n.toFixed(UL)),n}function Op({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:i}){if(Ha(e,0))return t;const o=[...t],[l,u]=r;Jt(l!=null,"Invalid first pivot index"),Jt(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:l,g=n[h];Jt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:b=0,collapsible:v,minSize:x=0}=g;if(v){const S=t[h];if(Jt(S!=null,`Previous layout not found for panel index ${h}`),Ha(S,b)){const _=x-S;bc(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?l:u,g=n[h];Jt(g,`No panel constraints found for index ${h}`);const{collapsedSize:b=0,collapsible:v,minSize:x=0}=g;if(v){const S=t[h];if(Jt(S!=null,`Previous layout not found for panel index ${h}`),Ha(S,x)){const _=S-b;bc(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:l,b=0;for(;;){const x=t[g];Jt(x!=null,`Previous layout not found for panel index ${g}`);const _=Bu({panelConstraints:n,panelIndex:g,size:100})-x;if(b+=_,g+=h,g<0||g>=n.length)break}const v=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-v:v}{let g=e<0?l:u;for(;g>=0&&g<n.length;){const b=Math.abs(e)-Math.abs(d),v=t[g];Jt(v!=null,`Previous layout not found for panel index ${g}`);const x=v-b,S=Bu({panelConstraints:n,panelIndex:g,size:x});if(!Ha(v,S)&&(d+=v-S,o[g]=S,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(OCe(a,o))return a;{const h=e<0?u:l,g=t[h];Jt(g!=null,`Previous layout not found for panel index ${h}`);const b=g+d,v=Bu({panelConstraints:n,panelIndex:h,size:b});if(o[h]=v,!Ha(v,b)){let x=b-v,_=e<0?u:l;for(;_>=0&&_<n.length;){const E=o[_];Jt(E!=null,`Previous layout not found for panel index ${_}`);const k=E+x,C=Bu({panelConstraints:n,panelIndex:_,size:k});if(Ha(E,C)||(x-=C-E,o[_]=C),Ha(x,0))break;e>0?_--:_++}}}const p=o.reduce((h,g)=>g+h,0);return Ha(p,100)?o:a}function DCe({layout:e,panelsArray:t,pivotIndices:n}){let r=0,a=100,i=0,o=0;const l=n[0];Jt(l!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:b}=h,{maxSize:v=100,minSize:x=0}=b;g===l?(r=x,a=v):(i+=x,o+=v)});const u=Math.min(a,100-i),d=Math.max(r,100-o),p=e[l];return{valueMax:u,valueMin:d,valueNow:p}}function Cm(e,t=document){return Array.from(t.querySelectorAll(`[${lr.resizeHandleId}][data-panel-group-id="${e}"]`))}function AX(e,t,n=document){const a=Cm(e,n).findIndex(i=>i.getAttribute(lr.resizeHandleId)===t);return a??null}function IX(e,t,n){const r=AX(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function LCe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function OX(e,t=document){if(LCe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function l0(e,t=document){const n=t.querySelector(`[${lr.resizeHandleId}="${e}"]`);return n||null}function jCe(e,t,n,r=document){var a,i,o,l;const u=l0(t,r),d=Cm(e,r),p=u?d.indexOf(u):-1,h=(a=(i=n[p])===null||i===void 0?void 0:i.id)!==null&&a!==void 0?a:null,g=(o=(l=n[p+1])===null||l===void 0?void 0:l.id)!==null&&o!==void 0?o:null;return[h,g]}function $Ce({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:a,panelGroupElement:i,setLayout:o}){y.useRef({didWarnAboutMissingResizeHandle:!1}),nc(()=>{if(!i)return;const l=Cm(n,i);for(let u=0;u<a.length-1;u++){const{valueMax:d,valueMin:p,valueNow:h}=DCe({layout:r,panelsArray:a,pivotIndices:[u,u+1]}),g=l[u];if(g!=null){const b=a[u];Jt(b,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",b.id),g.setAttribute("aria-valuemax",""+Math.round(d)),g.setAttribute("aria-valuemin",""+Math.round(p)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{l.forEach((u,d)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,r,a,i]),y.useEffect(()=>{if(!i)return;const l=t.current;Jt(l,"Eager values not found");const{panelDataArray:u}=l,d=OX(n,i);Jt(d!=null,`No group found for id "${n}"`);const p=Cm(n,i);Jt(p,`No resize handles found for group id "${n}"`);const h=p.map(g=>{const b=g.getAttribute(lr.resizeHandleId);Jt(b,"Resize handle element has no handle id attribute");const[v,x]=jCe(n,b,u,i);if(v==null||x==null)return()=>{};const S=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===v);if(E>=0){const k=u[E];Jt(k,`No panel data found for index ${E}`);const C=r[E],{collapsedSize:R=0,collapsible:A,minSize:N=0}=k.constraints;if(C!=null&&A){const O=Op({delta:Ha(C,R)?N-R:R-C,initialLayout:r,panelConstraints:u.map($=>$.constraints),pivotIndices:IX(n,b,i),prevLayout:r,trigger:"keyboard"});r!==O&&o(O)}}break}}};return g.addEventListener("keydown",S),()=>{g.removeEventListener("keydown",S)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,r,a,o])}function h3(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 DX(e,t){const n=e==="horizontal",{x:r,y:a}=i0(t);return n?r:a}function MCe(e,t,n,r,a){const i=n==="horizontal",o=l0(t,a);Jt(o,`No resize handle element found for id "${t}"`);const l=o.getAttribute(lr.groupId);Jt(l,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=r;const d=DX(n,e),p=OX(l,a);Jt(p,`No group element found for id "${l}"`);const h=p.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function PCe(e,t,n,r,a,i){if(SX(e)){const o=n==="horizontal";let l=0;e.shiftKey?l=100:a!=null?l=a:l=10;let u=0;switch(e.key){case"ArrowDown":u=o?0:l;break;case"ArrowLeft":u=o?-l:0;break;case"ArrowRight":u=o?l:0;break;case"ArrowUp":u=o?0:-l;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return r==null?0:MCe(e,t,n,r,i)}function UCe({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let r=0,a=100;for(let i=0;i<e.length;i++){const o=n[i];Jt(o,`Panel constraints not found for index ${i}`);const{defaultSize:l}=o;l!=null&&(r++,t[i]=l,a-=l)}for(let i=0;i<e.length;i++){const o=n[i];Jt(o,`Panel constraints not found for index ${i}`);const{defaultSize:l}=o;if(l!=null)continue;const u=e.length-r,d=a/u;r++,t[i]=d,a-=d}return t}function bu(e,t,n){t.forEach((r,a)=>{const i=e[a];Jt(i,`Panel data not found for index ${a}`);const{callbacks:o,constraints:l,id:u}=i,{collapsedSize:d=0,collapsible:p}=l,h=n[u];if(h==null||r!==h){n[u]=r;const{onCollapse:g,onExpand:b,onResize:v}=o;v&&v(r,h),p&&(g||b)&&(b&&(h==null||Fo(h,d))&&!Fo(r,d)&&b(),g&&(h==null||!Fo(h,d))&&Fo(r,d)&&g())}})}function Wb(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 zCe({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:a,precision:i=3}){const o=n[a];let l;return o==null?l=e!=null?e.toFixed(i):"1":r.length===1?l="1":l=o.toFixed(i),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function FCe(e,t=10){let n=null;return(...a)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...a)},t)}}function g3(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 LX(e){return`react-resizable-panels:${e}`}function jX(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:a,order:i}=t;return a?r:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function $X(e,t){try{const n=LX(e),r=t.getItem(n);if(r){const a=JSON.parse(r);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function BCe(e,t,n){var r,a;const i=(r=$X(e,n))!==null&&r!==void 0?r:{},o=jX(t);return(a=i[o])!==null&&a!==void 0?a:null}function HCe(e,t,n,r,a){var i;const o=LX(e),l=jX(t),u=(i=$X(e,a))!==null&&i!==void 0?i:{};u[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{a.setItem(o,JSON.stringify(u))}catch(d){console.error(d)}}function b3({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((i,o)=>i+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Ha(r,100)&&n.length>0)for(let i=0;i<t.length;i++){const o=n[i];Jt(o!=null,`No layout data found for index ${i}`);const l=100/r*o;n[i]=l}let a=0;for(let i=0;i<t.length;i++){const o=n[i];Jt(o!=null,`No layout data found for index ${i}`);const l=Bu({panelConstraints:t,panelIndex:i,size:o});o!=l&&(a+=o-l,n[i]=l)}if(!Ha(a,0))for(let i=0;i<t.length;i++){const o=n[i];Jt(o!=null,`No layout data found for index ${i}`);const l=o+a,u=Bu({panelConstraints:t,panelIndex:i,size:l});if(o!==u&&(a-=u-o,n[i]=u,Ha(a,0)))break}return n}const VCe=100,Dp={getItem:e=>(g3(Dp),Dp.getItem(e)),setItem:(e,t)=>{g3(Dp),Dp.setItem(e,t)}},v3={};function MX({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:a,id:i=null,onLayout:o=null,keyboardResizeBy:l=null,storage:u=Dp,style:d,tagName:p="div",...h}){const g=zL(i),b=y.useRef(null),[v,x]=y.useState(null),[S,_]=y.useState([]),E=ICe(),k=y.useRef({}),C=y.useRef(new Map),R=y.useRef(0),A=y.useRef({autoSaveId:e,direction:r,dragState:v,id:g,keyboardResizeBy:l,onLayout:o,storage:u}),N=y.useRef({layout:S,panelDataArray:[],panelDataArrayChanged:!1});y.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),y.useImperativeHandle(a,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:F}=N.current;return F},setLayout:F=>{const{onLayout:j}=A.current,{layout:P,panelDataArray:B}=N.current,K=b3({layout:F,panelConstraints:B.map(ee=>ee.constraints)});h3(P,K)||(_(K),N.current.layout=K,j&&j(K),bu(B,K,k.current))}}),[]),nc(()=>{A.current.autoSaveId=e,A.current.direction=r,A.current.dragState=v,A.current.id=g,A.current.onLayout=o,A.current.storage=u}),$Ce({committedValuesRef:A,eagerValuesRef:N,groupId:g,layout:S,panelDataArray:N.current.panelDataArray,setLayout:_,panelGroupElement:b.current}),y.useEffect(()=>{const{panelDataArray:F}=N.current;if(e){if(S.length===0||S.length!==F.length)return;let j=v3[e];j==null&&(j=FCe(HCe,VCe),v3[e]=j);const P=[...F],B=new Map(C.current);j(e,P,B,S,u)}},[e,S,u]),y.useEffect(()=>{});const O=y.useCallback(F=>{const{onLayout:j}=A.current,{layout:P,panelDataArray:B}=N.current;if(F.constraints.collapsible){const K=B.map(Q=>Q.constraints),{collapsedSize:ee=0,panelSize:ie,pivotIndices:ue}=Ul(B,F,P);if(Jt(ie!=null,`Panel size not found for panel "${F.id}"`),!Fo(ie,ee)){C.current.set(F.id,ie);const q=Ru(B,F)===B.length-1?ie-ee:ee-ie,le=Op({delta:q,initialLayout:P,panelConstraints:K,pivotIndices:ue,prevLayout:P,trigger:"imperative-api"});Wb(P,le)||(_(le),N.current.layout=le,j&&j(le),bu(B,le,k.current))}}},[]),$=y.useCallback((F,j)=>{const{onLayout:P}=A.current,{layout:B,panelDataArray:K}=N.current;if(F.constraints.collapsible){const ee=K.map(ve=>ve.constraints),{collapsedSize:ie=0,panelSize:ue=0,minSize:Q=0,pivotIndices:q}=Ul(K,F,B),le=j??Q;if(Fo(ue,ie)){const ve=C.current.get(F.id),oe=ve!=null&&ve>=le?ve:le,Je=Ru(K,F)===K.length-1?ue-oe:oe-ue,ke=Op({delta:Je,initialLayout:B,panelConstraints:ee,pivotIndices:q,prevLayout:B,trigger:"imperative-api"});Wb(B,ke)||(_(ke),N.current.layout=ke,P&&P(ke),bu(K,ke,k.current))}}},[]),M=y.useCallback(F=>{const{layout:j,panelDataArray:P}=N.current,{panelSize:B}=Ul(P,F,j);return Jt(B!=null,`Panel size not found for panel "${F.id}"`),B},[]),z=y.useCallback((F,j)=>{const{panelDataArray:P}=N.current,B=Ru(P,F);return zCe({defaultSize:j,dragState:v,layout:S,panelData:P,panelIndex:B})},[v,S]),W=y.useCallback(F=>{const{layout:j,panelDataArray:P}=N.current,{collapsedSize:B=0,collapsible:K,panelSize:ee}=Ul(P,F,j);return Jt(ee!=null,`Panel size not found for panel "${F.id}"`),K===!0&&Fo(ee,B)},[]),J=y.useCallback(F=>{const{layout:j,panelDataArray:P}=N.current,{collapsedSize:B=0,collapsible:K,panelSize:ee}=Ul(P,F,j);return Jt(ee!=null,`Panel size not found for panel "${F.id}"`),!K||bc(ee,B)>0},[]),X=y.useCallback(F=>{const{panelDataArray:j}=N.current;j.push(F),j.sort((P,B)=>{const K=P.order,ee=B.order;return K==null&&ee==null?0:K==null?-1:ee==null?1:K-ee}),N.current.panelDataArrayChanged=!0,E()},[E]);nc(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:F,onLayout:j,storage:P}=A.current,{layout:B,panelDataArray:K}=N.current;let ee=null;if(F){const ue=BCe(F,K,P);ue&&(C.current=new Map(Object.entries(ue.expandToSizes)),ee=ue.layout)}ee==null&&(ee=UCe({panelDataArray:K}));const ie=b3({layout:ee,panelConstraints:K.map(ue=>ue.constraints)});h3(B,ie)||(_(ie),N.current.layout=ie,j&&j(ie),bu(K,ie,k.current))}}),nc(()=>{const F=N.current;return()=>{F.layout=[]}},[]);const re=y.useCallback(F=>{let j=!1;const P=b.current;return P&&window.getComputedStyle(P,null).getPropertyValue("direction")==="rtl"&&(j=!0),function(K){K.preventDefault();const ee=b.current;if(!ee)return()=>null;const{direction:ie,dragState:ue,id:Q,keyboardResizeBy:q,onLayout:le}=A.current,{layout:ve,panelDataArray:oe}=N.current,{initialLayout:Ae}=ue??{},Je=IX(Q,F,ee);let ke=PCe(K,F,ie,ue,q,ee);const Re=ie==="horizontal";Re&&j&&(ke=-ke);const Ze=oe.map(Ke=>Ke.constraints),me=Op({delta:ke,initialLayout:Ae??ve,panelConstraints:Ze,pivotIndices:Je,prevLayout:ve,trigger:SX(K)?"keyboard":"mouse-or-touch"}),Le=!Wb(ve,me);(xX(K)||EX(K))&&R.current!=ke&&(R.current=ke,!Le&&ke!==0?Re?zE(F,ke<0?kX:TX):zE(F,ke<0?NX:RX):zE(F,0)),Le&&(_(me),N.current.layout=me,le&&le(me),bu(oe,me,k.current))}},[]),H=y.useCallback((F,j)=>{const{onLayout:P}=A.current,{layout:B,panelDataArray:K}=N.current,ee=K.map(ve=>ve.constraints),{panelSize:ie,pivotIndices:ue}=Ul(K,F,B);Jt(ie!=null,`Panel size not found for panel "${F.id}"`);const q=Ru(K,F)===K.length-1?ie-j:j-ie,le=Op({delta:q,initialLayout:B,panelConstraints:ee,pivotIndices:ue,prevLayout:B,trigger:"imperative-api"});Wb(B,le)||(_(le),N.current.layout=le,P&&P(le),bu(K,le,k.current))},[]),Z=y.useCallback((F,j)=>{const{layout:P,panelDataArray:B}=N.current,{collapsedSize:K=0,collapsible:ee}=j,{collapsedSize:ie=0,collapsible:ue,maxSize:Q=100,minSize:q=0}=F.constraints,{panelSize:le}=Ul(B,F,P);le!=null&&(ee&&ue&&Fo(le,K)?Fo(K,ie)||H(F,ie):le<q?H(F,q):le>Q&&H(F,Q))},[H]),G=y.useCallback((F,j)=>{const{direction:P}=A.current,{layout:B}=N.current;if(!b.current)return;const K=l0(F,b.current);Jt(K,`Drag handle element not found for id "${F}"`);const ee=DX(P,j);x({dragHandleId:F,dragHandleRect:K.getBoundingClientRect(),initialCursorPosition:ee,initialLayout:B})},[]),ae=y.useCallback(()=>{x(null)},[]),ne=y.useCallback(F=>{const{panelDataArray:j}=N.current,P=Ru(j,F);P>=0&&(j.splice(P,1),delete k.current[F.id],N.current.panelDataArrayChanged=!0,E())},[E]),L=y.useMemo(()=>({collapsePanel:O,direction:r,dragState:v,expandPanel:$,getPanelSize:M,getPanelStyle:z,groupId:g,isPanelCollapsed:W,isPanelExpanded:J,reevaluatePanelConstraints:Z,registerPanel:X,registerResizeHandle:re,resizePanel:H,startDragging:G,stopDragging:ae,unregisterPanel:ne,panelGroupElement:b.current}),[O,v,r,$,M,z,g,W,J,Z,X,re,H,G,ae,ne]),V={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return y.createElement(a0.Provider,{value:L},y.createElement(p,{...h,children:t,className:n,id:i,ref:b,style:{...V,...d},[lr.group]:"",[lr.groupDirection]:r,[lr.groupId]:g}))}const PX=y.forwardRef((e,t)=>y.createElement(MX,{...e,forwardedRef:t}));MX.displayName="PanelGroup";PX.displayName="forwardRef(PanelGroup)";function Ru(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Ul(e,t,n){const r=Ru(e,t),i=r===e.length-1?[r-1,r]:[r,r+1],o=n[r];return{...t.constraints,panelSize:o,pivotIndices:i}}function GCe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){y.useEffect(()=>{if(e||n==null||r==null)return;const a=l0(t,r);if(a==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const l=a.getAttribute(lr.groupId);Jt(l,`No group element found for id "${l}"`);const u=Cm(l,r),d=AX(l,t,r);Jt(d!==null,`No resize element found for id "${t}"`);const p=o.shiftKey?d>0?d-1:u.length-1:d+1<u.length?d+1:0;u[p].focus();break}}};return a.addEventListener("keydown",i),()=>{a.removeEventListener("keydown",i)}},[r,e,t,n])}function UX({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:a,onBlur:i,onClick:o,onDragging:l,onFocus:u,onPointerDown:d,onPointerUp:p,style:h={},tabIndex:g=0,tagName:b="div",...v}){var x,S;const _=y.useRef(null),E=y.useRef({onClick:o,onDragging:l,onPointerDown:d,onPointerUp:p});y.useEffect(()=>{E.current.onClick=o,E.current.onDragging=l,E.current.onPointerDown=d,E.current.onPointerUp=p});const k=y.useContext(a0);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:R,registerResizeHandle:A,startDragging:N,stopDragging:O,panelGroupElement:$}=k,M=zL(a),[z,W]=y.useState("inactive"),[J,X]=y.useState(!1),[re,H]=y.useState(null),Z=y.useRef({state:z});nc(()=>{Z.current.state=z}),y.useEffect(()=>{if(n)H(null);else{const L=A(M);H(()=>L)}},[n,M,A]);const G=(x=r?.coarse)!==null&&x!==void 0?x:15,ae=(S=r?.fine)!==null&&S!==void 0?S:5;y.useEffect(()=>{if(n||re==null)return;const L=_.current;Jt(L,"Element ref not attached");let V=!1;return CCe(M,L,C,{coarse:G,fine:ae},(j,P,B)=>{if(!P){W("inactive");return}switch(j){case"down":{W("drag"),V=!1,Jt(B,'Expected event to be defined for "down" action'),N(M,B);const{onDragging:K,onPointerDown:ee}=E.current;K?.(!0),ee?.();break}case"move":{const{state:K}=Z.current;V=!0,K!=="drag"&&W("hover"),Jt(B,'Expected event to be defined for "move" action'),re(B);break}case"up":{W("hover"),O();const{onClick:K,onDragging:ee,onPointerUp:ie}=E.current;ee?.(!1),ie?.(),V||K?.();break}}})},[G,C,n,ae,A,M,re,N,O]),GCe({disabled:n,handleId:M,resizeHandler:re,panelGroupElement:$});const ne={touchAction:"none",userSelect:"none"};return y.createElement(b,{...v,children:e,className:t,id:a,onBlur:()=>{X(!1),i?.()},onFocus:()=>{X(!0),u?.()},ref:_,role:"separator",style:{...ne,...h},tabIndex:g,[lr.groupDirection]:C,[lr.groupId]:R,[lr.resizeHandle]:"",[lr.resizeHandleActive]:z==="drag"?"pointer":J?"keyboard":void 0,[lr.resizeHandleEnabled]:!n,[lr.resizeHandleId]:M,[lr.resizeHandleState]:z})}UX.displayName="PanelResizeHandle";function ma({className:e,...t}){return f.jsx(PX,{"data-slot":"resizable-panel-group",className:Ue("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Gn({...e}){return f.jsx(wX,{"data-slot":"resizable-panel",...e})}function Mi({withHandle:e,className:t,...n}){return f.jsx(UX,{"data-slot":"resizable-handle",className:Ue("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&f.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:f.jsx(Dve,{className:"size-2.5"})})})}function yh({className:e,...t}){return f.jsx("kbd",{"data-slot":"kbd",className:Ue("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 WCe({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:a,onSearchChange:i,onSearchBlur:o,onClearAll:l,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(Bn,{ref:u,placeholder:"Search notifications...",value:t,onChange:d=>i(d.target.value),onBlur:o,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:f.jsx(tl,{className:"h-4 w-4"})})}),f.jsx(qt,{side:"bottom",children:"Clear all"})]})})]})}function hl({id:e,isSelected:t,isFocused:n,icon:r,title:a,description:i,metadata:o,onClick:l,className:u}){return f.jsx("button",{id:e,type:"button",onClick:l,className:Ue("w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group",t&&"bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500",n&&"ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset",u),children:f.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[r&&f.jsx("div",{className:"flex-shrink-0 mt-1",children:f.jsx("div",{className:Ue("p-2.5 rounded-full transition-colors",t?"bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600"),children:r})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"flex items-center gap-2 mb-1",children:f.jsx("h3",{className:Ue("font-medium truncate font-mono text-sm"),children:a})}),i&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function KCe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((o,l)=>f.jsx(hl,{id:`notification-${o.id}`,isSelected:t?.id===o.id,isFocused:r===l,title:f.jsxs("span",{className:"flex items-center gap-3",children:[o.method,!o.read&&f.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=a(o.timestamp),d=o.params&&Object.keys(o.params).length>0?Object.keys(o.params).length:0,p=d>0?` | ${d} param${d>1?"s":""}`:"";return u+p})(),onClick:()=>n(o)},o.id))})}function ZCe({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:a,onFullscreen:i,isCopied:o=!1,onClose:l}){return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ld,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Fe,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?f.jsx(mC,{className:"h-4 w-4 mr-1"}):f.jsx(I7,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:r,children:o?f.jsx(ba,{className:"h-4 w-4"}):f.jsx(Zr,{className:"h-4 w-4"})}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:a,children:f.jsx(nh,{className:"h-4 w-4"})}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:i,children:f.jsx(bC,{className:"h-4 w-4"})}),l&&f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,children:f.jsx(po,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(pC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function Cy(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),i=Math.floor(a/60),o=Math.floor(i/24);return r<60?"just now":a<60?`${a}m ago`:i<24?`${i}h ago`:o<7?`${o}d ago`:new Date(e).toLocaleDateString()}function YCe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:a,serverId:i,isConnected:o}){const[l,u]=y.useState(null),[d,p]=y.useState(""),[h,g]=y.useState(-1),[b,v]=y.useState(!0),[x,S]=y.useState(!1),[_,E]=y.useState(!0),[k,C]=y.useState(!1),R=y.useRef(null),A=y.useRef(null),N=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{b&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,b]),y.useEffect(()=>{const Z=R.current;if(!Z)return;const G=()=>{Z.scrollTop>0&&(O.current=!0,v(!1))};return Z.addEventListener("scroll",G),()=>Z.removeEventListener("scroll",G)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,v(!0))},[e.length]),y.useEffect(()=>{l&&!l.read&&n(l.id)},[l,n]),y.useEffect(()=>{x&&N.current&&N.current.focus()},[x]);const $=y.useCallback(()=>{d.trim()||S(!1)},[d]),M=y.useMemo(()=>{if(!d.trim())return e;const Z=d.toLowerCase();return e.filter(G=>G.method.toLowerCase().includes(Z)||JSON.stringify(G.params||{}).toLowerCase().includes(Z))},[e,d]);y.useEffect(()=>{g(-1)},[d]),y.useEffect(()=>{const Z=G=>{const ae=G.target;if(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.contentEditable==="true"||G.metaKey||G.ctrlKey||G.altKey)return;const L=M;if(G.key==="ArrowDown")G.preventDefault(),g(V=>{const F=V+1;return F>=L.length?0:F});else if(G.key==="ArrowUp")G.preventDefault(),g(V=>{const F=V-1;return F<0?L.length-1:F});else if(G.key==="Enter"&&h>=0){G.preventDefault();const V=M[h];V&&z(V)}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[h,M]),y.useEffect(()=>{if(h>=0){const Z=`notification-${M[h]?.id}`,G=document.getElementById(Z);G&&G.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,M]);const z=y.useCallback(Z=>{u(Z)},[]),W=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(a(),u(null))},[a]),J=y.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(JSON.stringify({method:l.method,timestamp:l.timestamp,read:l.read,params:l.params},null,2)),C(!0),setTimeout(()=>C(!1),2e3)}catch(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[l]),X=y.useCallback(()=>{if(l)try{const Z=new globalThis.Blob([JSON.stringify({method:l.method,timestamp:l.timestamp,read:l.read,params:l.params},null,2)],{type:"application/json"}),G=URL.createObjectURL(Z),ae=document.createElement("a");ae.href=G,ae.download=`notification-${Date.now()}.json`,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae),URL.revokeObjectURL(G)}catch(Z){console.error("[NotificationsTab] Failed to download notification:",Z)}},[l]),re=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(Z){console.error("[NotificationsTab] Failed to toggle fullscreen:",Z)}},[]),H=l?{method:l.method,params:l.params,timestamp:l.timestamp,read:l.read,formatRelativeTime:Cy}:null;return o?f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:40,minSize:30,children:f.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Gn,{defaultSize:75,minSize:30,children:[f.jsx(WCe,{isSearchExpanded:x,searchQuery:d,filteredNotificationsCount:M.length,notificationsCount:e.length,onSearchExpand:()=>S(!0),onSearchChange:p,onSearchBlur:$,onClearAll:W,searchInputRef:N}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(KCe,{notifications:M,selectedNotification:l,onNotificationSelect:z,focusedIndex:h,formatRelativeTime:Cy,listRef:R})})]})})}),f.jsx(Mi,{}),f.jsx(Gn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(ZCe,{notification:H,previewMode:_,onTogglePreview:()=>E(!_),onCopy:J,onDownload:X,onFullscreen:re,onClose:()=>u(null),isCopied:k})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(pC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function zX({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:a,primaryCount:i,secondaryCount:o,secondaryIcon:l,primaryIcon:u,searchPlaceholder:d="Search...",onSearchExpand:p,onSearchChange:h,onSearchBlur:g,onTabSwitch:b,searchInputRef:v,primaryTabName:x}){const S=e===x;return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?f.jsx(Bn,{ref:v,placeholder:d,value:n,onChange:_=>h(_.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:S?r:a}),S&&f.jsxs(f.Fragment,{children:[f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:p,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})]})}),f.jsxs(Fe,{variant:"ghost",size:"sm",onClick:b,className:"gap-2 flex-shrink-0",children:[S?f.jsx(l,{}):f.jsx(u,{}),f.jsx("span",{className:"hidden sm:inline",children:S?a:r}),S&&o>0&&f.jsx(Lr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:o})]})]})}function y3({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(fm,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((a,i)=>f.jsx(hl,{id:`prompt-${a.name}`,isSelected:t?.name===a.name,isFocused:r===i,icon:f.jsx(fm,{className:"h-4 w-4"}),title:a.name,description:a.description,metadata:a.arguments&&a.arguments.length>0&&f.jsxs(Lr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[a.arguments.length," args"]}),onClick:()=>n(a)},a.name))})}function w3({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:a,onSearchExpand:i,onSearchChange:o,onSearchBlur:l,onTabSwitch:u,searchInputRef:d}){return f.jsx(zX,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:r,secondaryCount:a,primaryIcon:fm,secondaryIcon:Ld,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:o,onSearchBlur:l,onTabSwitch:u,searchInputRef:d})}function S3({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Ld,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),f.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,o)=>f.jsx(hl,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:a===o,icon:f.jsx(Ld,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function qCe({selectedPrompt:e,promptArgs:t,onArgChange:n}){const r=e?.arguments||[];if(!(r.length>0))return f.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const i=o=>{const l=o.name,u=t[l],d=typeof u=="string"?u:JSON.stringify(u);return o.type==="boolean"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:l,className:"text-sm font-medium",children:[l,o.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx("input",{id:l,type:"checkbox",checked:!!u,onChange:p=>n(l,p.target.checked),className:"rounded","aria-label":`Toggle ${l}`}),f.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:o.description})]})]},l):o.type==="number"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:l,className:"text-sm font-medium",children:[l,o.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(Bn,{id:l,type:"number",value:Number(u)||0,onChange:p=>n(l,Number(p.target.value)),placeholder:o.description||`Enter ${l}`}),o.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:o.description})]},l):o.type==="array"||o.type==="object"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:l,className:"text-sm font-medium",children:[l,o.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(hc,{id:l,value:d,onChange:p=>{try{const h=JSON.parse(p.target.value);n(l,h)}catch{n(l,p.target.value)}},placeholder:o.description||`Enter ${l} as JSON`,className:"font-mono text-sm min-h-[100px]"}),o.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:o.description})]},l):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:l,className:"text-sm font-medium",children:[l,o.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(Bn,{id:l,value:d,onChange:p=>n(l,p.target.value),placeholder:o.description||`Enter ${l}`}),o.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:o.description})]},l)};return f.jsx("div",{className:"space-y-4",children:r.map(o=>i(o))})}function x3({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:a,onExecute:i,onSave:o}){return y.useEffect(()=>{const l=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&r&&(u.preventDefault(),i())};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,n,r,i]),e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsx(Fe,{onClick:i,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Fi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx($7,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"}),f.jsx("span",{className:"hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2",children:"⌘↵"})]})}),f.jsxs(Fe,{variant:"outline",onClick:o,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(vC,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(qCe,{selectedPrompt:e,promptArgs:t,onArgChange:a})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),f.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a prompt from the list to view its details and execute it"})]})}function XCe(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 E3({results:e,copiedResult:t,onCopy:n}){return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:e.length>0?f.jsx("div",{className:"space-y-4 flex-1 h-full",children:e.map((r,a)=>{const i=r.error||XCe(r.result);return f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ld,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(r.timestamp).toLocaleTimeString()})]}),r.duration!==void 0&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(pm,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[r.duration,"ms"]})]}),f.jsx("div",{className:"flex gap-2 ml-auto",children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>n(a,r.result),className:"h-6 px-2",children:t===a?f.jsx(ba,{className:"h-4 w-4"}):f.jsx(Zr,{className:"h-4 w-4"})})})]}),i?f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:i})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:r.result,filename:`prompt-result-${r.promptName}-${Date.now()}.json`})})]},a)})}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function BL({serverIds:e,onCountChange:t,onClearRef:n}={}){const[r,a]=y.useState([]),i=y.useRef(null),[o,l]=y.useState(new Set),[u]=y.useState(""),d=b=>{l(v=>{const x=new Set(v);return x.has(b)?x.delete(b):x.add(b),x})},p=async()=>{a([]),l(new Set),t?.(0);try{const b=new URLSearchParams;e&&e.length>0&&b.set("serverIds",e.join(","));const v=await fetch(`/inspector/api/rpc/log?${b.toString()}`,{method:"DELETE"});v.ok||console.warn("[RPC Logger] Failed to clear server buffer:",v.status)}catch(b){console.warn("[RPC Logger] Error clearing server buffer:",b)}},h=y.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);y.useEffect(()=>(n&&(n.current=p),()=>{n&&(n.current=null)}),[n,p]),y.useEffect(()=>{t?.(r.length)},[r.length,t]),y.useEffect(()=>{let b=null;try{const v=new URLSearchParams;v.set("replay","3"),v.set("_t",Date.now().toString()),e&&e.length>0&&v.set("serverIds",e.join(","));const x=`/inspector/api/rpc/stream?${v.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",x),b=new globalThis.EventSource(x),b.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},b.onmessage=S=>{try{const _=JSON.parse(S.data);if(!_||_.type!=="rpc")return;const{serverId:E,direction:k,message:C,timestamp:R}=_,A=C,N=typeof A?.method=="string"?A.method:A?.result!==void 0?"result":A?.error!==void 0?"error":"unknown",O={id:`${R??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:N,timestamp:R??new Date().toISOString(),payload:C};console.log("[RPC Logger] Received RPC event:",{method:N,direction:k,serverId:E}),a($=>{const M=[O,...$].slice(0,1e3);return t?.(M.length),M})}catch(_){console.error("[RPC Logger] Error parsing SSE message:",_)}},b.onerror=S=>{console.error("[RPC Logger] SSE connection error:",S);try{b?.close()}catch{}}}catch(v){console.error("[RPC Logger] Failed to create SSE connection:",v)}return()=>{try{b?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=y.useMemo(()=>{let b=r;if(e&&e.length>0){const v=new Set(e);b=b.filter(x=>v.has(x.serverId))}if(u.trim()){const v=u.toLowerCase();b=b.filter(x=>x.serverId.toLowerCase().includes(v)||x.method.toLowerCase().includes(v)||x.direction.toLowerCase().includes(v)||JSON.stringify(x.payload).toLowerCase().includes(v))}return b},[r,u,e]);return f.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:f.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?f.jsxs("div",{className:"text-center py-8",children:[f.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),f.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(b=>{const v=o.has(b.id);return f.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[f.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(b.id),children:[f.jsx("div",{className:"flex-shrink-0",children:v?f.jsx(_c,{className:"h-3 w-3 text-muted-foreground transition-transform"}):f.jsx(O7,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),f.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[f.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(b.timestamp).toLocaleTimeString()}),f.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${b.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:b.direction==="RECEIVE"?"Incoming":"Outgoing",children:b.direction==="RECEIVE"?f.jsx(Hbe,{className:"h-3 w-3"}):f.jsx(Gbe,{className:"h-3 w-3"})}),f.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:b.method})]})]}),v&&f.jsx("div",{className:"border-t bg-muted/20",children:f.jsx("div",{className:"p-3",children:f.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:f.jsx(fr,{data:b.payload})})})})]},b.id)})})})}const _3="mcp-inspector-saved-prompts";function FX({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:a}){const[i,o]=y.useState(null),[l,u]=y.useState(null),{selectedPromptName:d,setSelectedPromptName:p}=kc(),[h,g]=y.useState({}),[b,v]=y.useState([]),[x,S]=y.useState(!1),[_,E]=y.useState(null),[k,C]=y.useState(""),[R,A]=y.useState("prompts"),[N,O]=y.useState([]),[$,M]=y.useState(!1),[z,W]=y.useState(""),[J,X]=y.useState(!1),[re,H]=y.useState(-1),Z=y.useRef(null),[G,ae]=y.useState(!1),[ne,L]=y.useState("list"),[V,F]=y.useState(0),[j,P]=y.useState(!0),B=y.useRef(null),K=y.useRef(null);y.useEffect(()=>{const ke=()=>{ae(window.innerWidth<1024)};return ke(),window.addEventListener("resize",ke),()=>window.removeEventListener("resize",ke)},[]),y.useEffect(()=>{L(i?"detail":"list")},[i]),y.useEffect(()=>{G&&b.length>0&&!x&&L("response")},[b,x,G]),y.useImperativeHandle(e,()=>({focusSearch:()=>{X(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{C(""),X(!1),Z.current&&Z.current.blur()}})),y.useEffect(()=>{try{const ke=localStorage.getItem(_3);if(ke){const Re=JSON.parse(ke);O(Re)}}catch(ke){console.error("[PromptsTab] Failed to load saved prompts:",ke)}},[]);const ee=y.useCallback(ke=>{try{localStorage.setItem(_3,JSON.stringify(ke))}catch(Re){console.error("[PromptsTab] Failed to save prompts:",Re)}},[]);y.useEffect(()=>{J&&Z.current&&Z.current.focus()},[J]);const ie=y.useCallback(()=>{k.trim()||X(!1)},[k]),ue=y.useMemo(()=>{if(!k.trim())return t;const ke=k.toLowerCase();return t.filter(Re=>Re.name.toLowerCase().includes(ke)||Re.description?.toLowerCase().includes(ke))},[t,k]),Q=y.useCallback(ke=>{o(ke);const Re={};ke.arguments&&ke.arguments.forEach(Ze=>{Ze.default!==void 0?Re[Ze.name]=Ze.default:Ze.type==="string"?Re[Ze.name]="":Ze.type==="number"?Re[Ze.name]=0:Ze.type==="boolean"?Re[Ze.name]=!1:Ze.type==="array"?Re[Ze.name]=[]:Ze.type==="object"&&(Re[Ze.name]={})}),g(Re)},[]),q=y.useCallback(ke=>{const Re=t.find(Ze=>Ze.name===ke.promptName);Re&&(o(Re),g(ke.args),u(ke))},[t]);y.useEffect(()=>{H(-1)},[k,R]),y.useEffect(()=>{const ke=Re=>{const Ze=Re.target;if(Ze.tagName==="INPUT"||Ze.tagName==="TEXTAREA"||Ze.contentEditable==="true"||Re.metaKey||Re.ctrlKey||Re.altKey)return;const Le=R==="prompts"?ue:N;if(Re.key==="ArrowDown")Re.preventDefault(),H(Ke=>{const _e=Ke+1;return _e>=Le.length?0:_e});else if(Re.key==="ArrowUp")Re.preventDefault(),H(Ke=>{const _e=Ke-1;return _e<0?Le.length-1:_e});else if(Re.key==="Enter"&&re>=0)if(Re.preventDefault(),R==="prompts"){const Ke=ue[re];Ke&&Q(Ke)}else{const Ke=N[re];Ke&&q(Ke)}};return document.addEventListener("keydown",ke),()=>document.removeEventListener("keydown",ke)},[re,ue,N,R,Q,q]),y.useEffect(()=>{if(re>=0){const ke=R==="prompts"?`prompt-${ue[re]?.name}`:`saved-prompt-${N[re]?.id}`,Re=document.getElementById(ke);Re&&Re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[re,ue,N,R]),y.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:d,promptsCount:t.length,currentSelectedPrompt:i?.name}),d&&t.length>0){const ke=t.find(Re=>Re.name===d);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:d,promptFound:!!ke,promptName:ke?.name,shouldSelect:ke&&i?.name!==ke.name}),ke&&i?.name!==ke.name){console.warn("[PromptsTab] Selecting prompt:",ke.name),p(null);const Re=setTimeout(()=>{Q(ke);const Ze=document.getElementById(`prompt-${ke.name}`);Ze&&(console.warn("[PromptsTab] Scrolling to prompt element"),Ze.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(Re)}}},[d,t,i,Q,p]);const le=y.useCallback((ke,Re)=>{g(Ze=>({...Ze,[ke]:Re}))},[]),ve=y.useCallback(async()=>{if(!i||x)return;S(!0);const ke=Date.now();try{const Re=await n(i.name,h),Ze=Date.now()-ke;Or.getInstance().capture(new P4({promptName:i.name,serverId:r,success:!0})).catch(()=>{}),v(Le=>[{promptName:i.name,args:h,result:Re,timestamp:ke,duration:Ze},...Le])}catch(Re){Or.getInstance().capture(new P4({promptName:i.name,serverId:r,success:!1,error:Re instanceof Error?Re.message:"Unknown error"})).catch(()=>{});const me={promptName:i.name,args:h,result:null,error:Re instanceof Error?Re.message:String(Re),timestamp:ke,duration:Date.now()-ke};v(Le=>[me,...Le])}finally{S(!1)}},[i,h,x,n,r]),oe=y.useCallback(async(ke,Re)=>{try{await navigator.clipboard.writeText(JSON.stringify(Re,null,2)),E(ke),setTimeout(()=>E(null),2e3)}catch(Ze){console.error("[PromptsTab] Failed to copy result:",Ze)}},[]),Ae=y.useCallback(()=>{i&&(W(""),M(!0))},[i]),Je=y.useCallback(ke=>{ee(N.filter(Re=>Re.id!==ke)),l?.id===ke&&u(null)},[N,ee,l]);return G?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[ne!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>{ne==="response"?L("detail"):(o(null),L("list"))},className:"p-0 h-8 w-8",children:f.jsx(Cw,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{o(null),L("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),ne!=="list"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{ne==="response"&&L("detail")},className:ne==="detail"?"text-foreground hover:underline":ne==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),ne==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($w,{initial:!1,mode:"popLayout",children:[ne==="list"&&f.jsxs(Ia.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[f.jsx(w3,{activeTab:R,isSearchExpanded:J,searchQuery:k,filteredPromptsCount:ue.length,savedPromptsCount:N.length,onSearchExpand:()=>X(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>A(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(y3,{prompts:ue,selectedPrompt:i,onPromptSelect:Q,focusedIndex:re}):f.jsx(S3,{savedPrompts:N,selectedPrompt:l,onLoadPrompt:q,onDeletePrompt:Je,focusedIndex:re})]},"list"),ne==="detail"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:f.jsx(x3,{selectedPrompt:i,promptArgs:h,isExecuting:x,isConnected:a,onArgChange:le,onExecute:ve,onSave:Ae})},"detail"),ne==="response"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:f.jsx(E3,{results:b,copiedResult:_,onCopy:oe})},"response")]})})]}):f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:33,className:"flex flex-col h-full relative",children:f.jsxs(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Gn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(w3,{activeTab:R,isSearchExpanded:J,searchQuery:k,filteredPromptsCount:ue.length,savedPromptsCount:N.length,onSearchExpand:()=>X(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>A(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(y3,{prompts:ue,selectedPrompt:i,onPromptSelect:Q,focusedIndex:re}):f.jsx(S3,{savedPrompts:N,selectedPrompt:l,onLoadPrompt:q,onDeletePrompt:Je,focusedIndex:re})]})}),f.jsx(Mi,{withHandle:!0}),f.jsxs(Gn,{ref:B,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>P(!0),onExpand:()=>P(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:ke=>{ke.preventDefault(),ke.stopPropagation(),j?(B.current?.resize(25),P(!1)):(B.current?.resize(5),P(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),V>0&&f.jsx(Lr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:V}),V>0&&!j&&f.jsx(Fe,{variant:"ghost",size:"sm",onClick:ke=>{ke.preventDefault(),ke.stopPropagation(),K.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(tl,{className:"h-3.5 w-3.5"})})]}),f.jsx(_c,{className:`h-4 w-4 text-muted-foreground transition-transform ${j?"rotate-180":""}`})]}),!j&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(BL,{serverIds:[r],onCountChange:F,onClearRef:K})})]})]})}),f.jsx(Mi,{withHandle:!0}),f.jsx(Gn,{defaultSize:67,children:f.jsxs(ma,{direction:"vertical",children:[f.jsx(Gn,{defaultSize:40,children:f.jsx(x3,{selectedPrompt:i,promptArgs:h,isExecuting:x,isConnected:a,onArgChange:le,onExecute:ve,onSave:Ae})}),f.jsx(Mi,{withHandle:!0}),f.jsx(Gn,{defaultSize:50,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(E3,{results:b,copiedResult:_,onCopy:oe})})})]})})]})}FX.displayName="PromptsTab";function td(e){if(!e?.mimeType)return!1;const t=e.mimeType.toLowerCase();return t==="text/html"||t==="text/html+skybridge"||t==="text/uri-list"||t.startsWith("application/vnd.mcp-ui.remote-dom")}function JCe(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function BX({resource:e,onUIAction:t,className:n}){const r=async i=>t?.(i),a=JCe(e);return f.jsx("div",{className:n,children:f.jsx(PL,{resource:a,onUIAction:r,htmlProps:{autoResizeIframe:{width:!0,height:!0},style:{width:"100%",minHeight:"200px"},sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},remoteDomProps:{remoteElements:[cCe,lCe,uCe,dCe],library:ML}})})}function QCe(e){if("error"in e&&e.error)return e.error;if(!("isError"in e&&e.isError))return null;if("contents"in e&&Array.isArray(e.contents)){const t=e.contents.filter(n=>"text"in n).map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1691
|
+
`);k=A.pop()||"";for(const N of A)if(N.trim()&&N.startsWith("data: "))try{const O=JSON.parse(N.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 $=S[S.length-1];$&&$.type==="text"?$.text=x:S.push({type:"text",text:x}),console.log("[Parts after text]",S.length,"parts, text length:",x.length),i(M=>M.map(z=>z.id===v?{...z,parts:[...S]}:z))}else if(O.type==="tool-call")x&&(x=""),S.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",S.length,"parts, tool:",O.toolName),i($=>$.map(M=>M.id===v?{...M,parts:[...S]}:M));else if(O.type==="tool-result"){const $=S.find(M=>M.type==="tool-invocation"&&M.toolInvocation?.toolName===O.toolName&&!M.toolInvocation?.result);$&&$.toolInvocation?($.toolInvocation.result=O.result,$.toolInvocation.state="result",console.log("[Parts after tool-result]",S.length,"parts, updated:",O.toolName),i(M=>M.map(z=>z.id===v?{...z,parts:[...S]}:z))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",S.length),i($=>$.map(M=>M.id===v?{...M,parts:[...S],content:""}:M));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,N)}}}catch(g){let b="Unknown error occurred";if(g instanceof Error){b=g.message;const x=g;x.status&&(b=`HTTP ${x.status}: ${b}`),(x.code===401||b.includes("401")||b.includes("Unauthorized"))&&(b="Authentication failed (401). Check your Authorization header in the connection settings.")}const v={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${b}`,timestamp:Date.now()};i(x=>[...x,v])}finally{l(!1)}},[t,r,e,a,n]),d=y.useCallback(()=>{i([])},[]);return{messages:a,isLoading:o,sendMessage:u,clearMessages:d}}function gCe({connection:e,llmConfig:t,isConnected:n,readResource:r}){const[a,i]=y.useState([]),[o,l]=y.useState(!1),u=y.useRef(null),d=y.useRef(null),p=y.useRef(null),h=y.useCallback(async b=>{if(!b.trim()||!t||!n)return;const v={id:`user-${Date.now()}`,role:"user",content:b.trim(),timestamp:Date.now()};i(_=>[..._,v]),l(!0),u.current=new AbortController;const x=Date.now();let S=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(C=>[...C,{id:_,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]),!p.current||p.current.provider!==t.provider||p.current.model!==t.model||p.current.apiKey!==t.apiKey){let C;if(t.provider==="openai"){const{ChatOpenAI:R}=await pr(async()=>{const{ChatOpenAI:A}=await import("./index-BVRlDOe5.js");return{ChatOpenAI:A}},__vite__mapDeps([5,6,7,2,8,9]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:R}=await pr(async()=>{const{ChatAnthropic:A}=await import("./index-BKkxSJZC.js");return{ChatAnthropic:A}},__vite__mapDeps([10,7,6,2]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:R}=await pr(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-CVHM2qPt.js");return{ChatGoogleGenerativeAI:A}},__vite__mapDeps([11,7,6,2,9]));C=new R({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);p.current={instance:C,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==p.current.instance){const{MCPAgent:C}=await pr(async()=>{const{MCPAgent:R}=await import("./browser-C4F-osqk.js").then(A=>A.b);return{MCPAgent:R}},__vite__mapDeps([12,4,3,8,6,7,2,9]));d.current=new C({llm:p.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await d.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",d.current.conversationHistory?.length);for await(const C of d.current.streamEvents(b,10,!1,void 0)){if(u.current?.signal.aborted)break;if(C.event==="on_chat_model_stream"&&C.data?.chunk?.text){const R=C.data.chunk.text;if(typeof R=="string"&&R.length>0){E+=R;const A=k[k.length-1];A&&A.type==="text"?A.text=E:k.push({type:"text",text:E}),i(N=>N.map(O=>O.id===_?{...O,parts:[...k]}:O))}}else if(C.event==="on_tool_start"){E&&(E="");let R={};C.data?.input?R=C.data.input:C.data?.tool_input?R=C.data.tool_input:C.data&&(R=C.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:C.name,eventData:C.data,extractedArgs:R}),S++,k.push({type:"tool-invocation",toolInvocation:{toolName:C.name||"unknown",args:R,state:"pending"}}),i(A=>A.map(N=>N.id===_?{...N,parts:[...k]}:N))}else if(C.event==="on_tool_end"){const R=k.find(A=>A.type==="tool-invocation"&&A.toolInvocation?.toolName===C.name&&!A.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:C.name,hasToolPart:!!R,output:C.data?.output}),R&&R.toolInvocation){let A=C.data?.output;if(A?.kwargs?.content&&typeof A.kwargs.content=="string")try{A=JSON.parse(A.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),A=A.kwargs.content}else if(A?.content&&typeof A.content=="string")try{A=JSON.parse(A.content)}catch{A=A.content}R.toolInvocation.result=A,R.toolInvocation.state="result";const N=A?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:C.name,hasMeta:!!A?._meta,hasStructuredContent:!!A?.structuredContent,appsSdkUri:N}),N&&typeof N=="string"&&r){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",N);try{const O=await r(N);console.log("[useChatMessagesClientSide] Resource fetched:",O);const $=A?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const M=O.contents.map(W=>({type:"resource",resource:W}));console.log("[useChatMessagesClientSide] Created MCP resources:",M);const z={...A,content:[...A.content||[],...M],structuredContent:$};R.toolInvocation.result=z,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($=>$.id===_?{...$,parts:[...k]}:$))}}}i(C=>C.map(R=>R.id===_?{...R,parts:[...k],content:""}:R)),t&&Or.getInstance().capture(new U4({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:S,success:!0,executionMode:"client-side",duration:Date.now()-x})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const C=_;C.status&&(E=`HTTP ${C.status}: ${E}`),(C.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&Or.getInstance().capture(new U4({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:S,success:!1,executionMode:"client-side",duration:Date.now()-x,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(C=>[...C,k])}finally{l(!1),u.current=null}},[e,t,n,a,r]),g=y.useCallback(()=>{i([]),d.current&&d.current.clearConversationHistory()},[]);return{messages:a,isLoading:o,sendMessage:h,clearMessages:g}}const u3={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function vX({mcpServerUrl:e}){const[t,n]=y.useState(null),[r,a]=y.useState(null),[i,o]=y.useState(!1),[l,u]=y.useState("openai"),[d,p]=y.useState(""),[h,g]=y.useState(u3.openai),b=y.useCallback(()=>{const $=localStorage.getItem("mcp-inspector-api-keys");if($)try{return JSON.parse($)}catch(M){return console.error("Failed to load API keys:",M),{}}return{}},[]),v=y.useCallback($=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify($))},[]),[x,S]=y.useState("none"),[_,E]=y.useState(""),[k,C]=y.useState(""),[R,A]=y.useState("");y.useEffect(()=>{const $=localStorage.getItem("mcp-inspector-llm-config"),M=b();if($)try{const z=JSON.parse($);n(z),u(z.provider),p(M[z.provider]||z.apiKey||""),g(z.model)}catch(z){console.error("Failed to load LLM config:",z)}},[b]),y.useEffect(()=>{const $=localStorage.getItem("mcp-inspector-auth-config");if($)try{const M=JSON.parse($);a(M),S(M.type),M.username&&E(M.username),M.password&&C(M.password),M.token&&A(M.token)}catch(M){console.error("Failed to load auth config:",M)}else try{const M="mcp:auth",z=bX(e),W=`${M}_${z}_tokens`;localStorage.getItem(W)&&(a({type:"oauth"}),S("oauth"))}catch(M){console.error("Failed to check for OAuth tokens:",M)}},[e]),y.useEffect(()=>{g(u3[l]);const $=b();p($[l]||"")},[l,b]);const N=y.useCallback(()=>{if(!d.trim())return;const $=b();$[l]=d,v($);const M={provider:l,apiKey:d,model:h},z={type:x,...x==="basic"&&{username:_.trim(),password:k.trim()},...x==="bearer"&&{token:R.trim()}};n(M),a(z),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(M)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(z)),o(!1)},[l,d,h,x,_,k,R,b,v]),O=y.useCallback(()=>{n(null),a(null);const $=b();delete $[l],v($),p(""),E(""),C(""),A(""),S("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[l,b,v]);return{llmConfig:t,authConfig:r,configDialogOpen:i,setConfigDialogOpen:o,tempProvider:l,setTempProvider:u,tempApiKey:d,setTempApiKey:p,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:N,clearConfig:O}}function bCe({connection:e,isConnected:t,useClientSide:n=!0,readResource:r}){const[a,i]=y.useState(""),o=y.useRef(null),{llmConfig:l,authConfig:u,configDialogOpen:d,setConfigDialogOpen:p,tempProvider:h,setTempProvider:g,tempApiKey:b,setTempApiKey:v,tempModel:x,setTempModel:S,saveLLMConfig:_,clearConfig:E}=vX({mcpServerUrl:e.url}),k={connection:e,llmConfig:l,isConnected:t,readResource:r},C=hCe({mcpServerUrl:e.url,llmConfig:l,authConfig:u,isConnected:t}),R=gCe(k),{messages:A,isLoading:N,sendMessage:O,clearMessages:$}=n?R:C;gY({onNewChat:$}),y.useEffect(()=>{l&&A.length===0&&o.current&&o.current.focus()},[l,A.length]),y.useEffect(()=>{!N&&A.length>0&&o.current&&o.current.focus()},[N,A.length]);const M=y.useCallback(()=>{a.trim()&&(O(a),i(""))},[a,O]),z=y.useCallback(J=>{J.key==="Enter"&&!J.shiftKey&&(J.preventDefault(),M())},[M]),W=y.useCallback(()=>{E(),$()},[E,$]);return l&&A.length===0?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"absolute top-4 right-4 z-10",children:f.jsx(Tk,{open:d,onOpenChange:p,tempProvider:h,tempModel:x,tempApiKey:b,onProviderChange:g,onModelChange:S,onApiKeyChange:v,onSave:_,onClear:W,showClearButton:!0,buttonLabel:"Change API Key"})}),f.jsx(Ake,{mcpServerUrl:e.url,inputValue:a,isConnected:t,isLoading:N,textareaRef:o,llmConfig:l,onInputChange:i,onKeyDown:z,onSubmit:J=>{J.preventDefault(),M()},onConfigDialogOpenChange:p})]}):f.jsxs("div",{className:"flex flex-col h-full relative",children:[f.jsx(Nke,{llmConfig:l,hasMessages:A.length>0,configDialogOpen:d,onConfigDialogOpenChange:p,onClearChat:$,tempProvider:h,tempModel:x,tempApiKey:b,onProviderChange:g,onModelChange:S,onApiKeyChange:v,onSaveConfig:_,onClearConfig:W}),f.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:l?f.jsx(mCe,{messages:A,isLoading:N,serverId:e.url,readResource:r,tools:e.tools}):f.jsx(Ike,{onConfigureClick:()=>p(!0)})}),l&&f.jsx(Rke,{inputValue:a,isConnected:t,isLoading:N,textareaRef:o,onInputChange:i,onKeyDown:z,onSendMessage:M})]})}const a0=y.createContext(null);a0.displayName="PanelGroupContext";const lr={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"},UL=10,nc=y.useLayoutEffect,d3=Gd.useId,vCe=typeof d3=="function"?d3:()=>null;let yCe=0;function zL(e=null){const t=vCe(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+yCe++),e??n.current}function yX({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:a,forwardedRef:i,id:o,maxSize:l,minSize:u,onCollapse:d,onExpand:p,onResize:h,order:g,style:b,tagName:v="div",...x}){const S=y.useContext(a0);if(S===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:C,groupId:R,isPanelCollapsed:A,reevaluatePanelConstraints:N,registerPanel:O,resizePanel:$,unregisterPanel:M}=S,z=zL(o),W=y.useRef({callbacks:{onCollapse:d,onExpand:p,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:a,maxSize:l,minSize:u},id:z,idIsFromProps:o!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),nc(()=>{const{callbacks:X,constraints:re}=W.current,H={...re};W.current.id=z,W.current.idIsFromProps=o!==void 0,W.current.order=g,X.onCollapse=d,X.onExpand=p,X.onResize=h,re.collapsedSize=n,re.collapsible=r,re.defaultSize=a,re.maxSize=l,re.minSize=u,(H.collapsedSize!==re.collapsedSize||H.collapsible!==re.collapsible||H.maxSize!==re.maxSize||H.minSize!==re.minSize)&&N(W.current,H)}),nc(()=>{const X=W.current;return O(X),()=>{M(X)}},[g,z,O,M]),y.useImperativeHandle(i,()=>({collapse:()=>{_(W.current)},expand:X=>{E(W.current,X)},getId(){return z},getSize(){return k(W.current)},isCollapsed(){return A(W.current)},isExpanded(){return!A(W.current)},resize:X=>{$(W.current,X)}}),[_,E,k,A,z,$]);const J=C(W.current,a);return y.createElement(v,{...x,children:e,className:t,id:z,style:{...J,...b},[lr.groupId]:R,[lr.panel]:"",[lr.panelCollapsible]:r||void 0,[lr.panelId]:z,[lr.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const wX=y.forwardRef((e,t)=>y.createElement(yX,{...e,forwardedRef:t}));yX.displayName="Panel";wX.displayName="forwardRef(Panel)";let tT=null,yv=-1,Hs=null;function wCe(e,t,n){const r=(t&kX)!==0,a=(t&TX)!==0,i=(t&NX)!==0,o=(t&RX)!==0;if(t){if(r)return i?"se-resize":o?"ne-resize":"e-resize";if(a)return i?"sw-resize":o?"nw-resize":"w-resize";if(i)return"s-resize";if(o)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function SCe(){Hs!==null&&(document.head.removeChild(Hs),tT=null,Hs=null,yv=-1)}function ME(e,t,n){var r,a;const i=wCe(e,t);if(tT!==i){if(tT=i,Hs===null&&(Hs=document.createElement("style"),document.head.appendChild(Hs)),yv>=0){var o;(o=Hs.sheet)===null||o===void 0||o.removeRule(yv)}yv=(r=(a=Hs.sheet)===null||a===void 0?void 0:a.insertRule(`*{cursor: ${i} !important;}`))!==null&&r!==void 0?r:-1}}function SX(e){return e.type==="keydown"}function xX(e){return e.type.startsWith("pointer")}function EX(e){return e.type.startsWith("mouse")}function i0(e){if(xX(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(EX(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function xCe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function ECe(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 _Ce(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:m3(e),b:m3(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Jt(r,"Stacking order can only be calculated for elements with a common ancestor");const a={a:p3(f3(n.a)),b:p3(f3(n.b))};if(a.a===a.b){const i=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let l=i.length;for(;l--;){const u=i[l];if(u===o.a)return 1;if(u===o.b)return-1}}return Math.sign(a.a-a.b)}const kCe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function TCe(e){var t;const n=getComputedStyle((t=_X(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function NCe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||TCe(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"||kCe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function f3(e){let t=e.length;for(;t--;){const n=e[t];if(Jt(n,"Missing node"),NCe(n))return n}return null}function p3(e){return e&&Number(getComputedStyle(e).zIndex)||0}function m3(e){const t=[];for(;e;)t.push(e),e=_X(e);return t}function _X(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const kX=1,TX=2,NX=4,RX=8,RCe=xCe()==="coarse";let $i=[],ed=!1,Vs=new Map,o0=new Map;const Rm=new Set;function CCe(e,t,n,r,a){var i;const{ownerDocument:o}=t,l={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:a},u=(i=Vs.get(o))!==null&&i!==void 0?i:0;return Vs.set(o,u+1),Rm.add(l),Ny(),function(){var p;o0.delete(e),Rm.delete(l);const h=(p=Vs.get(o))!==null&&p!==void 0?p:1;if(Vs.set(o,h-1),Ny(),h===1&&Vs.delete(o),$i.includes(l)){const g=$i.indexOf(l);g>=0&&$i.splice(g,1),s0(),a("up",!0,null)}}}function ACe(e){const{target:t}=e,{x:n,y:r}=i0(e);ed=!0,FL({target:t,x:n,y:r}),Ny(),$i.length>0&&(Ry("down",e),s0(),e.preventDefault(),CX(t)||e.stopImmediatePropagation())}function PE(e){const{x:t,y:n}=i0(e);if(ed&&e.type!=="pointerleave"&&e.buttons===0&&(ed=!1,Ry("up",e)),!ed){const{target:r}=e;FL({target:r,x:t,y:n})}Ry("move",e),s0(),$i.length>0&&e.preventDefault()}function UE(e){const{target:t}=e,{x:n,y:r}=i0(e);o0.clear(),ed=!1,$i.length>0&&(e.preventDefault(),CX(t)||e.stopImmediatePropagation()),Ry("up",e),FL({target:t,x:n,y:r}),s0(),Ny()}function CX(e){let t=e;for(;t;){if(t.hasAttribute(lr.resizeHandle))return!0;t=t.parentElement}return!1}function FL({target:e,x:t,y:n}){$i.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Rm.forEach(a=>{const{element:i,hitAreaMargins:o}=a,l=i.getBoundingClientRect(),{bottom:u,left:d,right:p,top:h}=l,g=RCe?o.coarse:o.fine;if(t>=d-g&&t<=p+g&&n>=h-g&&n<=u+g){if(r!==null&&document.contains(r)&&i!==r&&!i.contains(r)&&!r.contains(i)&&_Ce(r,i)>0){let v=r,x=!1;for(;v&&!v.contains(i);){if(ECe(v.getBoundingClientRect(),l)){x=!0;break}v=v.parentElement}if(x)return}$i.push(a)}})}function zE(e,t){o0.set(e,t)}function s0(){let e=!1,t=!1;$i.forEach(r=>{const{direction:a}=r;a==="horizontal"?e=!0:t=!0});let n=0;o0.forEach(r=>{n|=r}),e&&t?ME("intersection",n):e?ME("horizontal",n):t?ME("vertical",n):SCe()}let FE;function Ny(){var e;(e=FE)===null||e===void 0||e.abort(),FE=new AbortController;const t={capture:!0,signal:FE.signal};Rm.size&&(ed?($i.length>0&&Vs.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("contextmenu",UE,t),a.addEventListener("pointerleave",PE,t),a.addEventListener("pointermove",PE,t))}),Vs.forEach((n,r)=>{const{body:a}=r;a.addEventListener("pointerup",UE,t),a.addEventListener("pointercancel",UE,t)})):Vs.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("pointerdown",ACe,t),a.addEventListener("pointermove",PE,t))}))}function Ry(e,t){Rm.forEach(n=>{const{setResizeHandlerState:r}=n,a=$i.includes(n);r(e,a,t)})}function ICe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function Jt(e,t){if(!e)throw console.error(t),Error(t)}function bc(e,t,n=UL){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Fo(e,t,n=UL){return bc(e,t,n)===0}function Ha(e,t,n){return bc(e,t,n)===0}function OCe(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const a=e[r],i=t[r];if(!Ha(a,i,n))return!1}return!0}function Bu({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Jt(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:i,maxSize:o=100,minSize:l=0}=r;if(bc(n,l)<0)if(i){const u=(a+l)/2;bc(n,u)<0?n=a:n=l}else n=l;return n=Math.min(o,n),n=parseFloat(n.toFixed(UL)),n}function Op({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:i}){if(Ha(e,0))return t;const o=[...t],[l,u]=r;Jt(l!=null,"Invalid first pivot index"),Jt(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:l,g=n[h];Jt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:b=0,collapsible:v,minSize:x=0}=g;if(v){const S=t[h];if(Jt(S!=null,`Previous layout not found for panel index ${h}`),Ha(S,b)){const _=x-S;bc(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?l:u,g=n[h];Jt(g,`No panel constraints found for index ${h}`);const{collapsedSize:b=0,collapsible:v,minSize:x=0}=g;if(v){const S=t[h];if(Jt(S!=null,`Previous layout not found for panel index ${h}`),Ha(S,x)){const _=S-b;bc(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:l,b=0;for(;;){const x=t[g];Jt(x!=null,`Previous layout not found for panel index ${g}`);const _=Bu({panelConstraints:n,panelIndex:g,size:100})-x;if(b+=_,g+=h,g<0||g>=n.length)break}const v=Math.min(Math.abs(e),Math.abs(b));e=e<0?0-v:v}{let g=e<0?l:u;for(;g>=0&&g<n.length;){const b=Math.abs(e)-Math.abs(d),v=t[g];Jt(v!=null,`Previous layout not found for panel index ${g}`);const x=v-b,S=Bu({panelConstraints:n,panelIndex:g,size:x});if(!Ha(v,S)&&(d+=v-S,o[g]=S,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(OCe(a,o))return a;{const h=e<0?u:l,g=t[h];Jt(g!=null,`Previous layout not found for panel index ${h}`);const b=g+d,v=Bu({panelConstraints:n,panelIndex:h,size:b});if(o[h]=v,!Ha(v,b)){let x=b-v,_=e<0?u:l;for(;_>=0&&_<n.length;){const E=o[_];Jt(E!=null,`Previous layout not found for panel index ${_}`);const k=E+x,C=Bu({panelConstraints:n,panelIndex:_,size:k});if(Ha(E,C)||(x-=C-E,o[_]=C),Ha(x,0))break;e>0?_--:_++}}}const p=o.reduce((h,g)=>g+h,0);return Ha(p,100)?o:a}function DCe({layout:e,panelsArray:t,pivotIndices:n}){let r=0,a=100,i=0,o=0;const l=n[0];Jt(l!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:b}=h,{maxSize:v=100,minSize:x=0}=b;g===l?(r=x,a=v):(i+=x,o+=v)});const u=Math.min(a,100-i),d=Math.max(r,100-o),p=e[l];return{valueMax:u,valueMin:d,valueNow:p}}function Cm(e,t=document){return Array.from(t.querySelectorAll(`[${lr.resizeHandleId}][data-panel-group-id="${e}"]`))}function AX(e,t,n=document){const a=Cm(e,n).findIndex(i=>i.getAttribute(lr.resizeHandleId)===t);return a??null}function IX(e,t,n){const r=AX(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function LCe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function OX(e,t=document){if(LCe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function l0(e,t=document){const n=t.querySelector(`[${lr.resizeHandleId}="${e}"]`);return n||null}function jCe(e,t,n,r=document){var a,i,o,l;const u=l0(t,r),d=Cm(e,r),p=u?d.indexOf(u):-1,h=(a=(i=n[p])===null||i===void 0?void 0:i.id)!==null&&a!==void 0?a:null,g=(o=(l=n[p+1])===null||l===void 0?void 0:l.id)!==null&&o!==void 0?o:null;return[h,g]}function $Ce({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:a,panelGroupElement:i,setLayout:o}){y.useRef({didWarnAboutMissingResizeHandle:!1}),nc(()=>{if(!i)return;const l=Cm(n,i);for(let u=0;u<a.length-1;u++){const{valueMax:d,valueMin:p,valueNow:h}=DCe({layout:r,panelsArray:a,pivotIndices:[u,u+1]}),g=l[u];if(g!=null){const b=a[u];Jt(b,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",b.id),g.setAttribute("aria-valuemax",""+Math.round(d)),g.setAttribute("aria-valuemin",""+Math.round(p)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{l.forEach((u,d)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,r,a,i]),y.useEffect(()=>{if(!i)return;const l=t.current;Jt(l,"Eager values not found");const{panelDataArray:u}=l,d=OX(n,i);Jt(d!=null,`No group found for id "${n}"`);const p=Cm(n,i);Jt(p,`No resize handles found for group id "${n}"`);const h=p.map(g=>{const b=g.getAttribute(lr.resizeHandleId);Jt(b,"Resize handle element has no handle id attribute");const[v,x]=jCe(n,b,u,i);if(v==null||x==null)return()=>{};const S=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===v);if(E>=0){const k=u[E];Jt(k,`No panel data found for index ${E}`);const C=r[E],{collapsedSize:R=0,collapsible:A,minSize:N=0}=k.constraints;if(C!=null&&A){const O=Op({delta:Ha(C,R)?N-R:R-C,initialLayout:r,panelConstraints:u.map($=>$.constraints),pivotIndices:IX(n,b,i),prevLayout:r,trigger:"keyboard"});r!==O&&o(O)}}break}}};return g.addEventListener("keydown",S),()=>{g.removeEventListener("keydown",S)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,r,a,o])}function h3(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 DX(e,t){const n=e==="horizontal",{x:r,y:a}=i0(t);return n?r:a}function MCe(e,t,n,r,a){const i=n==="horizontal",o=l0(t,a);Jt(o,`No resize handle element found for id "${t}"`);const l=o.getAttribute(lr.groupId);Jt(l,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=r;const d=DX(n,e),p=OX(l,a);Jt(p,`No group element found for id "${l}"`);const h=p.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function PCe(e,t,n,r,a,i){if(SX(e)){const o=n==="horizontal";let l=0;e.shiftKey?l=100:a!=null?l=a:l=10;let u=0;switch(e.key){case"ArrowDown":u=o?0:l;break;case"ArrowLeft":u=o?-l:0;break;case"ArrowRight":u=o?l:0;break;case"ArrowUp":u=o?0:-l;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return r==null?0:MCe(e,t,n,r,i)}function UCe({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let r=0,a=100;for(let i=0;i<e.length;i++){const o=n[i];Jt(o,`Panel constraints not found for index ${i}`);const{defaultSize:l}=o;l!=null&&(r++,t[i]=l,a-=l)}for(let i=0;i<e.length;i++){const o=n[i];Jt(o,`Panel constraints not found for index ${i}`);const{defaultSize:l}=o;if(l!=null)continue;const u=e.length-r,d=a/u;r++,t[i]=d,a-=d}return t}function bu(e,t,n){t.forEach((r,a)=>{const i=e[a];Jt(i,`Panel data not found for index ${a}`);const{callbacks:o,constraints:l,id:u}=i,{collapsedSize:d=0,collapsible:p}=l,h=n[u];if(h==null||r!==h){n[u]=r;const{onCollapse:g,onExpand:b,onResize:v}=o;v&&v(r,h),p&&(g||b)&&(b&&(h==null||Fo(h,d))&&!Fo(r,d)&&b(),g&&(h==null||!Fo(h,d))&&Fo(r,d)&&g())}})}function Wb(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 zCe({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:a,precision:i=3}){const o=n[a];let l;return o==null?l=e!=null?e.toFixed(i):"1":r.length===1?l="1":l=o.toFixed(i),{flexBasis:0,flexGrow:l,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function FCe(e,t=10){let n=null;return(...a)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...a)},t)}}function g3(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 LX(e){return`react-resizable-panels:${e}`}function jX(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:a,order:i}=t;return a?r:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function $X(e,t){try{const n=LX(e),r=t.getItem(n);if(r){const a=JSON.parse(r);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function BCe(e,t,n){var r,a;const i=(r=$X(e,n))!==null&&r!==void 0?r:{},o=jX(t);return(a=i[o])!==null&&a!==void 0?a:null}function HCe(e,t,n,r,a){var i;const o=LX(e),l=jX(t),u=(i=$X(e,a))!==null&&i!==void 0?i:{};u[l]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{a.setItem(o,JSON.stringify(u))}catch(d){console.error(d)}}function b3({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((i,o)=>i+o,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Ha(r,100)&&n.length>0)for(let i=0;i<t.length;i++){const o=n[i];Jt(o!=null,`No layout data found for index ${i}`);const l=100/r*o;n[i]=l}let a=0;for(let i=0;i<t.length;i++){const o=n[i];Jt(o!=null,`No layout data found for index ${i}`);const l=Bu({panelConstraints:t,panelIndex:i,size:o});o!=l&&(a+=o-l,n[i]=l)}if(!Ha(a,0))for(let i=0;i<t.length;i++){const o=n[i];Jt(o!=null,`No layout data found for index ${i}`);const l=o+a,u=Bu({panelConstraints:t,panelIndex:i,size:l});if(o!==u&&(a-=u-o,n[i]=u,Ha(a,0)))break}return n}const VCe=100,Dp={getItem:e=>(g3(Dp),Dp.getItem(e)),setItem:(e,t)=>{g3(Dp),Dp.setItem(e,t)}},v3={};function MX({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:a,id:i=null,onLayout:o=null,keyboardResizeBy:l=null,storage:u=Dp,style:d,tagName:p="div",...h}){const g=zL(i),b=y.useRef(null),[v,x]=y.useState(null),[S,_]=y.useState([]),E=ICe(),k=y.useRef({}),C=y.useRef(new Map),R=y.useRef(0),A=y.useRef({autoSaveId:e,direction:r,dragState:v,id:g,keyboardResizeBy:l,onLayout:o,storage:u}),N=y.useRef({layout:S,panelDataArray:[],panelDataArrayChanged:!1});y.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),y.useImperativeHandle(a,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:F}=N.current;return F},setLayout:F=>{const{onLayout:j}=A.current,{layout:P,panelDataArray:B}=N.current,K=b3({layout:F,panelConstraints:B.map(ee=>ee.constraints)});h3(P,K)||(_(K),N.current.layout=K,j&&j(K),bu(B,K,k.current))}}),[]),nc(()=>{A.current.autoSaveId=e,A.current.direction=r,A.current.dragState=v,A.current.id=g,A.current.onLayout=o,A.current.storage=u}),$Ce({committedValuesRef:A,eagerValuesRef:N,groupId:g,layout:S,panelDataArray:N.current.panelDataArray,setLayout:_,panelGroupElement:b.current}),y.useEffect(()=>{const{panelDataArray:F}=N.current;if(e){if(S.length===0||S.length!==F.length)return;let j=v3[e];j==null&&(j=FCe(HCe,VCe),v3[e]=j);const P=[...F],B=new Map(C.current);j(e,P,B,S,u)}},[e,S,u]),y.useEffect(()=>{});const O=y.useCallback(F=>{const{onLayout:j}=A.current,{layout:P,panelDataArray:B}=N.current;if(F.constraints.collapsible){const K=B.map(Q=>Q.constraints),{collapsedSize:ee=0,panelSize:ie,pivotIndices:ue}=Ul(B,F,P);if(Jt(ie!=null,`Panel size not found for panel "${F.id}"`),!Fo(ie,ee)){C.current.set(F.id,ie);const q=Ru(B,F)===B.length-1?ie-ee:ee-ie,le=Op({delta:q,initialLayout:P,panelConstraints:K,pivotIndices:ue,prevLayout:P,trigger:"imperative-api"});Wb(P,le)||(_(le),N.current.layout=le,j&&j(le),bu(B,le,k.current))}}},[]),$=y.useCallback((F,j)=>{const{onLayout:P}=A.current,{layout:B,panelDataArray:K}=N.current;if(F.constraints.collapsible){const ee=K.map(ve=>ve.constraints),{collapsedSize:ie=0,panelSize:ue=0,minSize:Q=0,pivotIndices:q}=Ul(K,F,B),le=j??Q;if(Fo(ue,ie)){const ve=C.current.get(F.id),oe=ve!=null&&ve>=le?ve:le,Je=Ru(K,F)===K.length-1?ue-oe:oe-ue,ke=Op({delta:Je,initialLayout:B,panelConstraints:ee,pivotIndices:q,prevLayout:B,trigger:"imperative-api"});Wb(B,ke)||(_(ke),N.current.layout=ke,P&&P(ke),bu(K,ke,k.current))}}},[]),M=y.useCallback(F=>{const{layout:j,panelDataArray:P}=N.current,{panelSize:B}=Ul(P,F,j);return Jt(B!=null,`Panel size not found for panel "${F.id}"`),B},[]),z=y.useCallback((F,j)=>{const{panelDataArray:P}=N.current,B=Ru(P,F);return zCe({defaultSize:j,dragState:v,layout:S,panelData:P,panelIndex:B})},[v,S]),W=y.useCallback(F=>{const{layout:j,panelDataArray:P}=N.current,{collapsedSize:B=0,collapsible:K,panelSize:ee}=Ul(P,F,j);return Jt(ee!=null,`Panel size not found for panel "${F.id}"`),K===!0&&Fo(ee,B)},[]),J=y.useCallback(F=>{const{layout:j,panelDataArray:P}=N.current,{collapsedSize:B=0,collapsible:K,panelSize:ee}=Ul(P,F,j);return Jt(ee!=null,`Panel size not found for panel "${F.id}"`),!K||bc(ee,B)>0},[]),X=y.useCallback(F=>{const{panelDataArray:j}=N.current;j.push(F),j.sort((P,B)=>{const K=P.order,ee=B.order;return K==null&&ee==null?0:K==null?-1:ee==null?1:K-ee}),N.current.panelDataArrayChanged=!0,E()},[E]);nc(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:F,onLayout:j,storage:P}=A.current,{layout:B,panelDataArray:K}=N.current;let ee=null;if(F){const ue=BCe(F,K,P);ue&&(C.current=new Map(Object.entries(ue.expandToSizes)),ee=ue.layout)}ee==null&&(ee=UCe({panelDataArray:K}));const ie=b3({layout:ee,panelConstraints:K.map(ue=>ue.constraints)});h3(B,ie)||(_(ie),N.current.layout=ie,j&&j(ie),bu(K,ie,k.current))}}),nc(()=>{const F=N.current;return()=>{F.layout=[]}},[]);const re=y.useCallback(F=>{let j=!1;const P=b.current;return P&&window.getComputedStyle(P,null).getPropertyValue("direction")==="rtl"&&(j=!0),function(K){K.preventDefault();const ee=b.current;if(!ee)return()=>null;const{direction:ie,dragState:ue,id:Q,keyboardResizeBy:q,onLayout:le}=A.current,{layout:ve,panelDataArray:oe}=N.current,{initialLayout:Ae}=ue??{},Je=IX(Q,F,ee);let ke=PCe(K,F,ie,ue,q,ee);const Re=ie==="horizontal";Re&&j&&(ke=-ke);const Ze=oe.map(Ke=>Ke.constraints),me=Op({delta:ke,initialLayout:Ae??ve,panelConstraints:Ze,pivotIndices:Je,prevLayout:ve,trigger:SX(K)?"keyboard":"mouse-or-touch"}),Le=!Wb(ve,me);(xX(K)||EX(K))&&R.current!=ke&&(R.current=ke,!Le&&ke!==0?Re?zE(F,ke<0?kX:TX):zE(F,ke<0?NX:RX):zE(F,0)),Le&&(_(me),N.current.layout=me,le&&le(me),bu(oe,me,k.current))}},[]),H=y.useCallback((F,j)=>{const{onLayout:P}=A.current,{layout:B,panelDataArray:K}=N.current,ee=K.map(ve=>ve.constraints),{panelSize:ie,pivotIndices:ue}=Ul(K,F,B);Jt(ie!=null,`Panel size not found for panel "${F.id}"`);const q=Ru(K,F)===K.length-1?ie-j:j-ie,le=Op({delta:q,initialLayout:B,panelConstraints:ee,pivotIndices:ue,prevLayout:B,trigger:"imperative-api"});Wb(B,le)||(_(le),N.current.layout=le,P&&P(le),bu(K,le,k.current))},[]),Z=y.useCallback((F,j)=>{const{layout:P,panelDataArray:B}=N.current,{collapsedSize:K=0,collapsible:ee}=j,{collapsedSize:ie=0,collapsible:ue,maxSize:Q=100,minSize:q=0}=F.constraints,{panelSize:le}=Ul(B,F,P);le!=null&&(ee&&ue&&Fo(le,K)?Fo(K,ie)||H(F,ie):le<q?H(F,q):le>Q&&H(F,Q))},[H]),G=y.useCallback((F,j)=>{const{direction:P}=A.current,{layout:B}=N.current;if(!b.current)return;const K=l0(F,b.current);Jt(K,`Drag handle element not found for id "${F}"`);const ee=DX(P,j);x({dragHandleId:F,dragHandleRect:K.getBoundingClientRect(),initialCursorPosition:ee,initialLayout:B})},[]),ae=y.useCallback(()=>{x(null)},[]),ne=y.useCallback(F=>{const{panelDataArray:j}=N.current,P=Ru(j,F);P>=0&&(j.splice(P,1),delete k.current[F.id],N.current.panelDataArrayChanged=!0,E())},[E]),L=y.useMemo(()=>({collapsePanel:O,direction:r,dragState:v,expandPanel:$,getPanelSize:M,getPanelStyle:z,groupId:g,isPanelCollapsed:W,isPanelExpanded:J,reevaluatePanelConstraints:Z,registerPanel:X,registerResizeHandle:re,resizePanel:H,startDragging:G,stopDragging:ae,unregisterPanel:ne,panelGroupElement:b.current}),[O,v,r,$,M,z,g,W,J,Z,X,re,H,G,ae,ne]),V={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return y.createElement(a0.Provider,{value:L},y.createElement(p,{...h,children:t,className:n,id:i,ref:b,style:{...V,...d},[lr.group]:"",[lr.groupDirection]:r,[lr.groupId]:g}))}const PX=y.forwardRef((e,t)=>y.createElement(MX,{...e,forwardedRef:t}));MX.displayName="PanelGroup";PX.displayName="forwardRef(PanelGroup)";function Ru(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Ul(e,t,n){const r=Ru(e,t),i=r===e.length-1?[r-1,r]:[r,r+1],o=n[r];return{...t.constraints,panelSize:o,pivotIndices:i}}function GCe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){y.useEffect(()=>{if(e||n==null||r==null)return;const a=l0(t,r);if(a==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const l=a.getAttribute(lr.groupId);Jt(l,`No group element found for id "${l}"`);const u=Cm(l,r),d=AX(l,t,r);Jt(d!==null,`No resize element found for id "${t}"`);const p=o.shiftKey?d>0?d-1:u.length-1:d+1<u.length?d+1:0;u[p].focus();break}}};return a.addEventListener("keydown",i),()=>{a.removeEventListener("keydown",i)}},[r,e,t,n])}function UX({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:a,onBlur:i,onClick:o,onDragging:l,onFocus:u,onPointerDown:d,onPointerUp:p,style:h={},tabIndex:g=0,tagName:b="div",...v}){var x,S;const _=y.useRef(null),E=y.useRef({onClick:o,onDragging:l,onPointerDown:d,onPointerUp:p});y.useEffect(()=>{E.current.onClick=o,E.current.onDragging=l,E.current.onPointerDown=d,E.current.onPointerUp=p});const k=y.useContext(a0);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:R,registerResizeHandle:A,startDragging:N,stopDragging:O,panelGroupElement:$}=k,M=zL(a),[z,W]=y.useState("inactive"),[J,X]=y.useState(!1),[re,H]=y.useState(null),Z=y.useRef({state:z});nc(()=>{Z.current.state=z}),y.useEffect(()=>{if(n)H(null);else{const L=A(M);H(()=>L)}},[n,M,A]);const G=(x=r?.coarse)!==null&&x!==void 0?x:15,ae=(S=r?.fine)!==null&&S!==void 0?S:5;y.useEffect(()=>{if(n||re==null)return;const L=_.current;Jt(L,"Element ref not attached");let V=!1;return CCe(M,L,C,{coarse:G,fine:ae},(j,P,B)=>{if(!P){W("inactive");return}switch(j){case"down":{W("drag"),V=!1,Jt(B,'Expected event to be defined for "down" action'),N(M,B);const{onDragging:K,onPointerDown:ee}=E.current;K?.(!0),ee?.();break}case"move":{const{state:K}=Z.current;V=!0,K!=="drag"&&W("hover"),Jt(B,'Expected event to be defined for "move" action'),re(B);break}case"up":{W("hover"),O();const{onClick:K,onDragging:ee,onPointerUp:ie}=E.current;ee?.(!1),ie?.(),V||K?.();break}}})},[G,C,n,ae,A,M,re,N,O]),GCe({disabled:n,handleId:M,resizeHandler:re,panelGroupElement:$});const ne={touchAction:"none",userSelect:"none"};return y.createElement(b,{...v,children:e,className:t,id:a,onBlur:()=>{X(!1),i?.()},onFocus:()=>{X(!0),u?.()},ref:_,role:"separator",style:{...ne,...h},tabIndex:g,[lr.groupDirection]:C,[lr.groupId]:R,[lr.resizeHandle]:"",[lr.resizeHandleActive]:z==="drag"?"pointer":J?"keyboard":void 0,[lr.resizeHandleEnabled]:!n,[lr.resizeHandleId]:M,[lr.resizeHandleState]:z})}UX.displayName="PanelResizeHandle";function ma({className:e,...t}){return f.jsx(PX,{"data-slot":"resizable-panel-group",className:Ue("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Gn({...e}){return f.jsx(wX,{"data-slot":"resizable-panel",...e})}function Mi({withHandle:e,className:t,...n}){return f.jsx(UX,{"data-slot":"resizable-handle",className:Ue("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&f.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:f.jsx(Dve,{className:"size-2.5"})})})}function yh({className:e,...t}){return f.jsx("kbd",{"data-slot":"kbd",className:Ue("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 WCe({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:a,onSearchChange:i,onSearchBlur:o,onClearAll:l,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(Bn,{ref:u,placeholder:"Search notifications...",value:t,onChange:d=>i(d.target.value),onBlur:o,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:f.jsx(tl,{className:"h-4 w-4"})})}),f.jsx(qt,{side:"bottom",children:"Clear all"})]})})]})}function hl({id:e,isSelected:t,isFocused:n,icon:r,title:a,description:i,metadata:o,onClick:l,className:u}){return f.jsx("button",{id:e,type:"button",onClick:l,className:Ue("w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group",t&&"bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500",n&&"ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset",u),children:f.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[r&&f.jsx("div",{className:"flex-shrink-0 mt-1",children:f.jsx("div",{className:Ue("p-2.5 rounded-full transition-colors",t?"bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600"),children:r})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"flex items-center gap-2 mb-1",children:f.jsx("h3",{className:Ue("font-medium truncate font-mono text-sm"),children:a})}),i&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function KCe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((o,l)=>f.jsx(hl,{id:`notification-${o.id}`,isSelected:t?.id===o.id,isFocused:r===l,title:f.jsxs("span",{className:"flex items-center gap-3",children:[o.method,!o.read&&f.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=a(o.timestamp),d=o.params&&Object.keys(o.params).length>0?Object.keys(o.params).length:0,p=d>0?` | ${d} param${d>1?"s":""}`:"";return u+p})(),onClick:()=>n(o)},o.id))})}function ZCe({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:a,onFullscreen:i,isCopied:o=!1,onClose:l}){return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ld,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Fe,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?f.jsx(mC,{className:"h-4 w-4 mr-1"}):f.jsx(I7,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:r,children:o?f.jsx(ba,{className:"h-4 w-4"}):f.jsx(Zr,{className:"h-4 w-4"})}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:a,children:f.jsx(nh,{className:"h-4 w-4"})}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:i,children:f.jsx(bC,{className:"h-4 w-4"})}),l&&f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,children:f.jsx(po,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(pC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function Cy(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),i=Math.floor(a/60),o=Math.floor(i/24);return r<60?"just now":a<60?`${a}m ago`:i<24?`${i}h ago`:o<7?`${o}d ago`:new Date(e).toLocaleDateString()}function YCe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:a,serverId:i,isConnected:o}){const[l,u]=y.useState(null),[d,p]=y.useState(""),[h,g]=y.useState(-1),[b,v]=y.useState(!0),[x,S]=y.useState(!1),[_,E]=y.useState(!0),[k,C]=y.useState(!1),R=y.useRef(null),A=y.useRef(null),N=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{b&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,b]),y.useEffect(()=>{const Z=R.current;if(!Z)return;const G=()=>{Z.scrollTop>0&&(O.current=!0,v(!1))};return Z.addEventListener("scroll",G),()=>Z.removeEventListener("scroll",G)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,v(!0))},[e.length]),y.useEffect(()=>{l&&!l.read&&n(l.id)},[l,n]),y.useEffect(()=>{x&&N.current&&N.current.focus()},[x]);const $=y.useCallback(()=>{d.trim()||S(!1)},[d]),M=y.useMemo(()=>{if(!d.trim())return e;const Z=d.toLowerCase();return e.filter(G=>G.method.toLowerCase().includes(Z)||JSON.stringify(G.params||{}).toLowerCase().includes(Z))},[e,d]);y.useEffect(()=>{g(-1)},[d]),y.useEffect(()=>{const Z=G=>{const ae=G.target;if(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.contentEditable==="true"||G.metaKey||G.ctrlKey||G.altKey)return;const L=M;if(G.key==="ArrowDown")G.preventDefault(),g(V=>{const F=V+1;return F>=L.length?0:F});else if(G.key==="ArrowUp")G.preventDefault(),g(V=>{const F=V-1;return F<0?L.length-1:F});else if(G.key==="Enter"&&h>=0){G.preventDefault();const V=M[h];V&&z(V)}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[h,M]),y.useEffect(()=>{if(h>=0){const Z=`notification-${M[h]?.id}`,G=document.getElementById(Z);G&&G.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,M]);const z=y.useCallback(Z=>{u(Z)},[]),W=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(a(),u(null))},[a]),J=y.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(JSON.stringify({method:l.method,timestamp:l.timestamp,read:l.read,params:l.params},null,2)),C(!0),setTimeout(()=>C(!1),2e3)}catch(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[l]),X=y.useCallback(()=>{if(l)try{const Z=new globalThis.Blob([JSON.stringify({method:l.method,timestamp:l.timestamp,read:l.read,params:l.params},null,2)],{type:"application/json"}),G=URL.createObjectURL(Z),ae=document.createElement("a");ae.href=G,ae.download=`notification-${Date.now()}.json`,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae),URL.revokeObjectURL(G)}catch(Z){console.error("[NotificationsTab] Failed to download notification:",Z)}},[l]),re=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(Z){console.error("[NotificationsTab] Failed to toggle fullscreen:",Z)}},[]),H=l?{method:l.method,params:l.params,timestamp:l.timestamp,read:l.read,formatRelativeTime:Cy}:null;return o?f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:40,minSize:30,children:f.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Gn,{defaultSize:75,minSize:30,children:[f.jsx(WCe,{isSearchExpanded:x,searchQuery:d,filteredNotificationsCount:M.length,notificationsCount:e.length,onSearchExpand:()=>S(!0),onSearchChange:p,onSearchBlur:$,onClearAll:W,searchInputRef:N}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(KCe,{notifications:M,selectedNotification:l,onNotificationSelect:z,focusedIndex:h,formatRelativeTime:Cy,listRef:R})})]})})}),f.jsx(Mi,{}),f.jsx(Gn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(ZCe,{notification:H,previewMode:_,onTogglePreview:()=>E(!_),onCopy:J,onDownload:X,onFullscreen:re,onClose:()=>u(null),isCopied:k})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(pC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function zX({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:a,primaryCount:i,secondaryCount:o,secondaryIcon:l,primaryIcon:u,searchPlaceholder:d="Search...",onSearchExpand:p,onSearchChange:h,onSearchBlur:g,onTabSwitch:b,searchInputRef:v,primaryTabName:x}){const S=e===x;return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?f.jsx(Bn,{ref:v,placeholder:d,value:n,onChange:_=>h(_.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:S?r:a}),S&&f.jsxs(f.Fragment,{children:[f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:p,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})]})}),f.jsxs(Fe,{variant:"ghost",size:"sm",onClick:b,className:"gap-2 flex-shrink-0",children:[S?f.jsx(l,{}):f.jsx(u,{}),f.jsx("span",{className:"hidden sm:inline",children:S?a:r}),S&&o>0&&f.jsx(Lr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:o})]})]})}function y3({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(fm,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((a,i)=>f.jsx(hl,{id:`prompt-${a.name}`,isSelected:t?.name===a.name,isFocused:r===i,icon:f.jsx(fm,{className:"h-4 w-4"}),title:a.name,description:a.description,metadata:a.arguments&&a.arguments.length>0&&f.jsxs(Lr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[a.arguments.length," args"]}),onClick:()=>n(a)},a.name))})}function w3({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:a,onSearchExpand:i,onSearchChange:o,onSearchBlur:l,onTabSwitch:u,searchInputRef:d}){return f.jsx(zX,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:r,secondaryCount:a,primaryIcon:fm,secondaryIcon:Ld,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:o,onSearchBlur:l,onTabSwitch:u,searchInputRef:d})}function S3({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Ld,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),f.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,o)=>f.jsx(hl,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:a===o,icon:f.jsx(Ld,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function qCe({selectedPrompt:e,promptArgs:t,onArgChange:n}){const r=e?.arguments||[];if(!(r.length>0))return f.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const i=o=>{const l=o.name,u=t[l],d=typeof u=="string"?u:JSON.stringify(u);return o.type==="boolean"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:l,className:"text-sm font-medium",children:[l,o.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx("input",{id:l,type:"checkbox",checked:!!u,onChange:p=>n(l,p.target.checked),className:"rounded","aria-label":`Toggle ${l}`}),f.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:o.description})]})]},l):o.type==="number"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:l,className:"text-sm font-medium",children:[l,o.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(Bn,{id:l,type:"number",value:Number(u)||0,onChange:p=>n(l,Number(p.target.value)),placeholder:o.description||`Enter ${l}`}),o.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:o.description})]},l):o.type==="array"||o.type==="object"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:l,className:"text-sm font-medium",children:[l,o.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(hc,{id:l,value:d,onChange:p=>{try{const h=JSON.parse(p.target.value);n(l,h)}catch{n(l,p.target.value)}},placeholder:o.description||`Enter ${l} as JSON`,className:"font-mono text-sm min-h-[100px]"}),o.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:o.description})]},l):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:l,className:"text-sm font-medium",children:[l,o.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(Bn,{id:l,value:d,onChange:p=>n(l,p.target.value),placeholder:o.description||`Enter ${l}`}),o.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:o.description})]},l)};return f.jsx("div",{className:"space-y-4",children:r.map(o=>i(o))})}function x3({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:a,onExecute:i,onSave:o}){return y.useEffect(()=>{const l=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&r&&(u.preventDefault(),i())};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[e,n,r,i]),e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsx(Fe,{onClick:i,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Fi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx($7,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"}),f.jsx("span",{className:"hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2",children:"⌘↵"})]})}),f.jsxs(Fe,{variant:"outline",onClick:o,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(vC,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(qCe,{selectedPrompt:e,promptArgs:t,onArgChange:a})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),f.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a prompt from the list to view its details and execute it"})]})}function XCe(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 E3({results:e,copiedResult:t,onCopy:n}){return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:e.length>0?f.jsx("div",{className:"space-y-4 flex-1 h-full",children:e.map((r,a)=>{const i=r.error||XCe(r.result);return f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ld,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(r.timestamp).toLocaleTimeString()})]}),r.duration!==void 0&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(pm,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[r.duration,"ms"]})]}),f.jsx("div",{className:"flex gap-2 ml-auto",children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>n(a,r.result),className:"h-6 px-2",children:t===a?f.jsx(ba,{className:"h-4 w-4"}):f.jsx(Zr,{className:"h-4 w-4"})})})]}),i?f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:i})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:r.result,filename:`prompt-result-${r.promptName}-${Date.now()}.json`})})]},a)})}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function BL({serverIds:e,onCountChange:t,onClearRef:n}={}){const[r,a]=y.useState([]),i=y.useRef(null),[o,l]=y.useState(new Set),[u]=y.useState(""),d=b=>{l(v=>{const x=new Set(v);return x.has(b)?x.delete(b):x.add(b),x})},p=async()=>{a([]),l(new Set),t?.(0);try{const b=new URLSearchParams;e&&e.length>0&&b.set("serverIds",e.join(","));const v=await fetch(`/inspector/api/rpc/log?${b.toString()}`,{method:"DELETE"});v.ok||console.warn("[RPC Logger] Failed to clear server buffer:",v.status)}catch(b){console.warn("[RPC Logger] Error clearing server buffer:",b)}},h=y.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);y.useEffect(()=>(n&&(n.current=p),()=>{n&&(n.current=null)}),[n,p]),y.useEffect(()=>{t?.(r.length)},[r.length,t]),y.useEffect(()=>{let b=null;try{const v=new URLSearchParams;v.set("replay","3"),v.set("_t",Date.now().toString()),e&&e.length>0&&v.set("serverIds",e.join(","));const x=`/inspector/api/rpc/stream?${v.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",x),b=new globalThis.EventSource(x),b.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},b.onmessage=S=>{try{const _=JSON.parse(S.data);if(!_||_.type!=="rpc")return;const{serverId:E,direction:k,message:C,timestamp:R}=_,A=C,N=typeof A?.method=="string"?A.method:A?.result!==void 0?"result":A?.error!==void 0?"error":"unknown",O={id:`${R??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:N,timestamp:R??new Date().toISOString(),payload:C};console.log("[RPC Logger] Received RPC event:",{method:N,direction:k,serverId:E}),a($=>{const M=[O,...$].slice(0,1e3);return t?.(M.length),M})}catch(_){console.error("[RPC Logger] Error parsing SSE message:",_)}},b.onerror=S=>{console.error("[RPC Logger] SSE connection error:",S);try{b?.close()}catch{}}}catch(v){console.error("[RPC Logger] Failed to create SSE connection:",v)}return()=>{try{b?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=y.useMemo(()=>{let b=r;if(e&&e.length>0){const v=new Set(e);b=b.filter(x=>v.has(x.serverId))}if(u.trim()){const v=u.toLowerCase();b=b.filter(x=>x.serverId.toLowerCase().includes(v)||x.method.toLowerCase().includes(v)||x.direction.toLowerCase().includes(v)||JSON.stringify(x.payload).toLowerCase().includes(v))}return b},[r,u,e]);return f.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:f.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?f.jsxs("div",{className:"text-center py-8",children:[f.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),f.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(b=>{const v=o.has(b.id);return f.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[f.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(b.id),children:[f.jsx("div",{className:"flex-shrink-0",children:v?f.jsx(_c,{className:"h-3 w-3 text-muted-foreground transition-transform"}):f.jsx(O7,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),f.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[f.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(b.timestamp).toLocaleTimeString()}),f.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${b.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:b.direction==="RECEIVE"?"Incoming":"Outgoing",children:b.direction==="RECEIVE"?f.jsx(Hbe,{className:"h-3 w-3"}):f.jsx(Gbe,{className:"h-3 w-3"})}),f.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:b.method})]})]}),v&&f.jsx("div",{className:"border-t bg-muted/20",children:f.jsx("div",{className:"p-3",children:f.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:f.jsx(fr,{data:b.payload})})})})]},b.id)})})})}const _3="mcp-inspector-saved-prompts";function FX({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:a}){const[i,o]=y.useState(null),[l,u]=y.useState(null),{selectedPromptName:d,setSelectedPromptName:p}=kc(),[h,g]=y.useState({}),[b,v]=y.useState([]),[x,S]=y.useState(!1),[_,E]=y.useState(null),[k,C]=y.useState(""),[R,A]=y.useState("prompts"),[N,O]=y.useState([]),[$,M]=y.useState(!1),[z,W]=y.useState(""),[J,X]=y.useState(!1),[re,H]=y.useState(-1),Z=y.useRef(null),[G,ae]=y.useState(!1),[ne,L]=y.useState("list"),[V,F]=y.useState(0),[j,P]=y.useState(!0),B=y.useRef(null),K=y.useRef(null);y.useEffect(()=>{const ke=()=>{ae(window.innerWidth<1024)};return ke(),window.addEventListener("resize",ke),()=>window.removeEventListener("resize",ke)},[]),y.useEffect(()=>{L(i?"detail":"list")},[i]),y.useEffect(()=>{G&&b.length>0&&!x&&L("response")},[b,x,G]),y.useImperativeHandle(e,()=>({focusSearch:()=>{X(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{C(""),X(!1),Z.current&&Z.current.blur()}})),y.useEffect(()=>{try{const ke=localStorage.getItem(_3);if(ke){const Re=JSON.parse(ke);O(Re)}}catch(ke){console.error("[PromptsTab] Failed to load saved prompts:",ke)}},[]);const ee=y.useCallback(ke=>{try{localStorage.setItem(_3,JSON.stringify(ke))}catch(Re){console.error("[PromptsTab] Failed to save prompts:",Re)}},[]);y.useEffect(()=>{J&&Z.current&&Z.current.focus()},[J]);const ie=y.useCallback(()=>{k.trim()||X(!1)},[k]),ue=y.useMemo(()=>{if(!k.trim())return t;const ke=k.toLowerCase();return t.filter(Re=>Re.name.toLowerCase().includes(ke)||Re.description?.toLowerCase().includes(ke))},[t,k]),Q=y.useCallback(ke=>{o(ke);const Re={};ke.arguments&&ke.arguments.forEach(Ze=>{Ze.default!==void 0?Re[Ze.name]=Ze.default:Ze.type==="string"?Re[Ze.name]="":Ze.type==="number"?Re[Ze.name]=0:Ze.type==="boolean"?Re[Ze.name]=!1:Ze.type==="array"?Re[Ze.name]=[]:Ze.type==="object"&&(Re[Ze.name]={})}),g(Re)},[]),q=y.useCallback(ke=>{const Re=t.find(Ze=>Ze.name===ke.promptName);Re&&(o(Re),g(ke.args),u(ke))},[t]);y.useEffect(()=>{H(-1)},[k,R]),y.useEffect(()=>{const ke=Re=>{const Ze=Re.target;if(Ze.tagName==="INPUT"||Ze.tagName==="TEXTAREA"||Ze.contentEditable==="true"||Re.metaKey||Re.ctrlKey||Re.altKey)return;const Le=R==="prompts"?ue:N;if(Re.key==="ArrowDown")Re.preventDefault(),H(Ke=>{const _e=Ke+1;return _e>=Le.length?0:_e});else if(Re.key==="ArrowUp")Re.preventDefault(),H(Ke=>{const _e=Ke-1;return _e<0?Le.length-1:_e});else if(Re.key==="Enter"&&re>=0)if(Re.preventDefault(),R==="prompts"){const Ke=ue[re];Ke&&Q(Ke)}else{const Ke=N[re];Ke&&q(Ke)}};return document.addEventListener("keydown",ke),()=>document.removeEventListener("keydown",ke)},[re,ue,N,R,Q,q]),y.useEffect(()=>{if(re>=0){const ke=R==="prompts"?`prompt-${ue[re]?.name}`:`saved-prompt-${N[re]?.id}`,Re=document.getElementById(ke);Re&&Re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[re,ue,N,R]),y.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:d,promptsCount:t.length,currentSelectedPrompt:i?.name}),d&&t.length>0){const ke=t.find(Re=>Re.name===d);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:d,promptFound:!!ke,promptName:ke?.name,shouldSelect:ke&&i?.name!==ke.name}),ke&&i?.name!==ke.name){console.warn("[PromptsTab] Selecting prompt:",ke.name),p(null);const Re=setTimeout(()=>{Q(ke);const Ze=document.getElementById(`prompt-${ke.name}`);Ze&&(console.warn("[PromptsTab] Scrolling to prompt element"),Ze.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(Re)}}},[d,t,i,Q,p]);const le=y.useCallback((ke,Re)=>{g(Ze=>({...Ze,[ke]:Re}))},[]),ve=y.useCallback(async()=>{if(!i||x)return;S(!0);const ke=Date.now();try{const Re=await n(i.name,h),Ze=Date.now()-ke;Or.getInstance().capture(new P4({promptName:i.name,serverId:r,success:!0})).catch(()=>{}),v(Le=>[{promptName:i.name,args:h,result:Re,timestamp:ke,duration:Ze},...Le])}catch(Re){Or.getInstance().capture(new P4({promptName:i.name,serverId:r,success:!1,error:Re instanceof Error?Re.message:"Unknown error"})).catch(()=>{});const me={promptName:i.name,args:h,result:null,error:Re instanceof Error?Re.message:String(Re),timestamp:ke,duration:Date.now()-ke};v(Le=>[me,...Le])}finally{S(!1)}},[i,h,x,n,r]),oe=y.useCallback(async(ke,Re)=>{try{await navigator.clipboard.writeText(JSON.stringify(Re,null,2)),E(ke),setTimeout(()=>E(null),2e3)}catch(Ze){console.error("[PromptsTab] Failed to copy result:",Ze)}},[]),Ae=y.useCallback(()=>{i&&(W(""),M(!0))},[i]),Je=y.useCallback(ke=>{ee(N.filter(Re=>Re.id!==ke)),l?.id===ke&&u(null)},[N,ee,l]);return G?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[ne!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>{ne==="response"?L("detail"):(o(null),L("list"))},className:"p-0 h-8 w-8",children:f.jsx(Cw,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{o(null),L("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),ne!=="list"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{ne==="response"&&L("detail")},className:ne==="detail"?"text-foreground hover:underline":ne==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),ne==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($w,{initial:!1,mode:"popLayout",children:[ne==="list"&&f.jsxs(Ia.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[f.jsx(w3,{activeTab:R,isSearchExpanded:J,searchQuery:k,filteredPromptsCount:ue.length,savedPromptsCount:N.length,onSearchExpand:()=>X(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>A(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(y3,{prompts:ue,selectedPrompt:i,onPromptSelect:Q,focusedIndex:re}):f.jsx(S3,{savedPrompts:N,selectedPrompt:l,onLoadPrompt:q,onDeletePrompt:Je,focusedIndex:re})]},"list"),ne==="detail"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:f.jsx(x3,{selectedPrompt:i,promptArgs:h,isExecuting:x,isConnected:a,onArgChange:le,onExecute:ve,onSave:Ae})},"detail"),ne==="response"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:f.jsx(E3,{results:b,copiedResult:_,onCopy:oe})},"response")]})})]}):f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:33,className:"flex flex-col h-full relative",children:f.jsxs(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Gn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(w3,{activeTab:R,isSearchExpanded:J,searchQuery:k,filteredPromptsCount:ue.length,savedPromptsCount:N.length,onSearchExpand:()=>X(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>A(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(y3,{prompts:ue,selectedPrompt:i,onPromptSelect:Q,focusedIndex:re}):f.jsx(S3,{savedPrompts:N,selectedPrompt:l,onLoadPrompt:q,onDeletePrompt:Je,focusedIndex:re})]})}),f.jsx(Mi,{withHandle:!0}),f.jsxs(Gn,{ref:B,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>P(!0),onExpand:()=>P(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:ke=>{ke.preventDefault(),ke.stopPropagation(),j?(B.current?.resize(25),P(!1)):(B.current?.resize(5),P(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),V>0&&f.jsx(Lr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:V}),V>0&&!j&&f.jsx(Fe,{variant:"ghost",size:"sm",onClick:ke=>{ke.preventDefault(),ke.stopPropagation(),K.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(tl,{className:"h-3.5 w-3.5"})})]}),f.jsx(_c,{className:`h-4 w-4 text-muted-foreground transition-transform ${j?"rotate-180":""}`})]}),!j&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(BL,{serverIds:[r],onCountChange:F,onClearRef:K})})]})]})}),f.jsx(Mi,{withHandle:!0}),f.jsx(Gn,{defaultSize:67,children:f.jsxs(ma,{direction:"vertical",children:[f.jsx(Gn,{defaultSize:40,children:f.jsx(x3,{selectedPrompt:i,promptArgs:h,isExecuting:x,isConnected:a,onArgChange:le,onExecute:ve,onSave:Ae})}),f.jsx(Mi,{withHandle:!0}),f.jsx(Gn,{defaultSize:50,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(E3,{results:b,copiedResult:_,onCopy:oe})})})]})})]})}FX.displayName="PromptsTab";function td(e){if(!e?.mimeType)return!1;const t=e.mimeType.toLowerCase();return t==="text/html"||t==="text/html+skybridge"||t==="text/uri-list"||t.startsWith("application/vnd.mcp-ui.remote-dom")}function JCe(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function BX({resource:e,onUIAction:t,className:n}){const r=async i=>t?.(i),a=JCe(e);return f.jsx("div",{className:n,children:f.jsx(PL,{resource:a,onUIAction:r,htmlProps:{autoResizeIframe:{width:!0,height:!0},style:{width:"100%",minHeight:"200px"},sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},remoteDomProps:{remoteElements:[cCe,lCe,uCe,dCe],library:ML}})})}function QCe(e){if("error"in e&&e.error)return e.error;if(!("isError"in e&&e.isError))return null;if("contents"in e&&Array.isArray(e.contents)){const t=e.contents.filter(n=>"text"in n).map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1692
1692
|
`)}return"An error occurred"}function k3({result:e,isLoading:t,previewMode:n,serverId:r,readResource:a,onTogglePreview:i,onCopy:o,onDownload:l,onFullscreen:u,isCopied:d=!1}){let p=[],h;if(e?.resourceAnnotations&&(p=Object.keys(e.resourceAnnotations).filter(S=>S.startsWith("openai/")),h=e.resourceAnnotations["openai/outputTemplate"]),e?.result?.contents?.[0]?._meta){const S=e.result.contents[0]._meta,_=Object.keys(S).filter(E=>E.startsWith("openai/"));_.length>0&&(p=[...p,..._]),!h&&S["openai/outputTemplate"]&&(h=S["openai/outputTemplate"]),!h&&e.uri&&e.uri.startsWith("ui://widget/")&&(h=e.uri)}const g=!!(p.length>0&&h&&typeof h=="string"&&r&&a);if(t)return f.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:f.jsx(Fi,{className:"size-5"})});if(!e)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a resource to view its contents"}),f.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a resource from the list to see its data"})]});const b=e.error||QCe(e.result);if(b)return f.jsx("div",{className:"p-4",children:f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:b})]})});const v=e?.result?.contents&&Array.isArray(e.result.contents)&&e.result.contents.some(S=>S.mimeType&&td(S)),x=v?e.result.contents.filter(S=>S.mimeType&&td(S)):[];return f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Ld,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{const S=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return S!==void 0?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(pm,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[S,"ms"]})]}):null})(),v&&f.jsx(Lr,{variant:"outline",className:"text-xs bg-purple-50 dark:bg-purple-900/20 border-none border-purple-200 dark:border-purple-800/50 text-purple-600 dark:text-purple-400",children:"MCP UI"}),g&&f.jsx(Lr,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-900/20 border-none border-blue-200 dark:border-blue-800/50 text-blue-600 dark:text-blue-400",children:"OpenAI Widget"})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[(v||g)&&f.jsxs(Fe,{variant:"ghost",size:"sm",onClick:i,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?f.jsx(mC,{className:"h-4 w-4 mr-1"}):f.jsx(I7,{className:"h-4 w-4 mr-1"}),n?"JSON":g?"Component":"Preview"]}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:o,children:d?f.jsx(ba,{className:"h-4 w-4"}):f.jsx(Zr,{className:"h-4 w-4"})}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,children:f.jsx(nh,{className:"h-4 w-4"})}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:u,children:f.jsx(bC,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:g&&r&&a&&h?n?f.jsx("div",{className:"flex-1 h-full",children:f.jsx(OL,{componentUrl:h,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:r,readResource:a,className:"w-full h-full relative flex p-4"})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})}):v?n?f.jsxs("div",{className:"space-y-0 h-full",children:[x.map((S,_)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx("div",{className:"w-full h-full",children:f.jsx(BX,{resource:S,className:"w-full h-full"})})},`mcp-ui-${S.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result.contents&&Array.isArray(e.result.contents)){const S=e.result.contents.filter(_=>!(_.mimeType&&td(_)));if(S.length>0)return f.jsx("div",{className:"px-4",children:f.jsx(fr,{data:S,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-non-ui-${Date.now()}.json`})})}return null})()]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-mcp-ui-${Date.now()}.json`})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]})}function eAe(e,t){if(!e&&!t)return f.jsx(Nve,{className:"h-5 w-5"});const n=(e||t||"").toLowerCase();return n.includes("image")?f.jsx(_ve,{className:"h-5 w-5"}):n.includes("json")||n.includes("javascript")||n.includes("typescript")?f.jsx(xve,{className:"h-5 w-5"}):n.includes("html")||n.includes("xml")?f.jsx(Ive,{className:"h-5 w-5"}):n.includes("database")||n.includes("sql")?f.jsx(Aw,{className:"h-5 w-5"}):f.jsx(hC,{className:"h-5 w-5"})}function T3({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:r}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Aw,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No resources available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((a,i)=>{const o=eAe(a.mimeType,a.uri),l=[a.description,a.mimeType&&f.jsx("span",{className:"font-mono",children:a.mimeType},"mime")].filter(Boolean);return f.jsx(hl,{id:`resource-${a.uri}`,isSelected:t?.uri===a.uri,isFocused:r===i,icon:o,title:a.name,description:l.length>0?f.jsxs("span",{className:"flex flex-col gap-1",children:[a.description&&f.jsx("span",{children:a.description}),a.mimeType&&f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-500 font-mono",children:a.mimeType})]}):void 0,onClick:()=>n(a)},a.uri)})})}function N3({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:r,onSearchChange:a,onSearchBlur:i,searchInputRef:o}){return f.jsx("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(Bn,{ref:o,placeholder:"Search resources...",value:t,onChange:l=>a(l.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Resources"}),f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})})})}function HX({ref:e,resources:t,readResource:n,serverId:r,isConnected:a}){const[i,o]=y.useState(null),{selectedResourceUri:l,setSelectedResourceUri:u}=kc(),[d,p]=y.useState(null),[h,g]=y.useState(!1),[b,v]=y.useState(""),[x]=y.useState("resources"),[S,_]=y.useState(!0),[E,k]=y.useState(!1),[C,R]=y.useState(-1),[A,N]=y.useState(!1),O=y.useRef(null),$=y.useRef(null),[M,z]=y.useState(!1),[W,J]=y.useState("list"),[X,re]=y.useState(0),[H,Z]=y.useState(!0),G=y.useRef(null),ae=y.useRef(null);y.useEffect(()=>{const B=()=>{z(window.innerWidth<1024)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),y.useEffect(()=>{J(i?"detail":"list")},[i]),y.useImperativeHandle(e,()=>({focusSearch:()=>{k(!0),setTimeout(()=>{O.current&&O.current.focus()},0)},blurSearch:()=>{v(""),k(!1),O.current&&O.current.blur()}})),y.useEffect(()=>{E&&O.current&&O.current.focus()},[E]);const ne=y.useCallback(()=>{b.trim()||k(!1)},[b]),L=y.useMemo(()=>{if(!b)return t;const B=b.toLowerCase();return t.filter(K=>K.name.toLowerCase().includes(B)||K.description?.toLowerCase().includes(B)||K.uri.toLowerCase().includes(B))},[t,b]),V=y.useCallback(async B=>{if(o(B),a){g(!0);const K=Date.now();try{const ee=await n(B.uri);Or.getInstance().capture(new M4({resourceUri:B.uri,serverId:r,success:!0})).catch(()=>{}),p({uri:B.uri,result:ee,timestamp:K,resourceAnnotations:B.annotations})}catch(ee){Or.getInstance().capture(new M4({resourceUri:B.uri,serverId:r,success:!1,error:ee instanceof Error?ee.message:"Unknown error"})).catch(()=>{}),p({uri:B.uri,result:null,error:ee instanceof Error?ee.message:"Unknown error",timestamp:K,resourceAnnotations:B.annotations})}finally{g(!1)}}},[n,r,a]);y.useEffect(()=>{R(-1)},[b,x]),y.useEffect(()=>{const B=K=>{const ee=K.target;if(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.contentEditable==="true"||K.metaKey||K.ctrlKey||K.altKey)return;const ue=L;if(K.key==="ArrowDown")K.preventDefault(),R(Q=>{const q=Q+1;return q>=ue.length?0:q});else if(K.key==="ArrowUp")K.preventDefault(),R(Q=>{const q=Q-1;return q<0?ue.length-1:q});else if(K.key==="Enter"&&C>=0){K.preventDefault();const Q=L[C];Q&&V(Q)}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[C,L,V]),y.useEffect(()=>{if(C>=0){const B=`resource-${L[C]?.uri}`,K=document.getElementById(B);K&&K.scrollIntoView({behavior:"smooth",block:"nearest"})}},[C,L]),y.useEffect(()=>{if(l&&t.length>0){const B=t.find(K=>K.uri===l);B&&i?.uri!==B.uri&&(u(null),setTimeout(()=>{V(B);const K=document.getElementById(`resource-${B.uri}`);K&&K.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[l,t,i,V,u]);const F=y.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify(d.result,null,2)),N(!0),setTimeout(()=>N(!1),2e3)}catch(B){console.error("[ResourcesTab] Failed to copy result:",B)}},[d]),j=y.useCallback(()=>{if(d)try{const B=new globalThis.Blob([JSON.stringify(d.result,null,2)],{type:"application/json"}),K=URL.createObjectURL(B),ee=document.createElement("a");ee.href=K,ee.download=`resource-${Date.now()}.json`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(K)}catch(B){console.error("[ResourcesTab] Failed to download result:",B)}},[d]),P=y.useCallback(async()=>{if($.current)try{document.fullscreenElement?await document.exitFullscreen():await $.current.requestFullscreen()}catch(B){console.error("[ResourcesTab] Failed to toggle fullscreen:",B)}},[]);return M?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[W!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>{o(null),J("list")},className:"p-0 h-8 w-8",children:f.jsx(Cw,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{o(null),J("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Resources"}),W==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Content"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($w,{initial:!1,mode:"popLayout",children:[W==="list"&&f.jsxs(Ia.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[f.jsx(N3,{activeTab:x,isSearchExpanded:E,searchQuery:b,filteredResourcesCount:L.length,onSearchExpand:()=>k(!0),onSearchChange:v,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(T3,{resources:L,selectedResource:i,onResourceSelect:V,focusedIndex:C})})]},"list"),W==="detail"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-white dark:bg-zinc-900 z-10",children:f.jsx("div",{ref:$,className:"h-full",children:f.jsx(k3,{result:d,isLoading:h,previewMode:S,serverId:r,readResource:n,onTogglePreview:()=>_(!S),onCopy:F,onDownload:j,onFullscreen:P,isCopied:A})})},"detail")]})})]}):f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:25,children:f.jsxs(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Gn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(N3,{activeTab:x,isSearchExpanded:E,searchQuery:b,filteredResourcesCount:L.length,onSearchExpand:()=>k(!0),onSearchChange:v,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx(T3,{resources:L,selectedResource:i,onResourceSelect:V,focusedIndex:C})]})}),f.jsx(Mi,{withHandle:!0}),f.jsxs(Gn,{ref:G,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>Z(!0),onExpand:()=>Z(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:B=>{B.preventDefault(),B.stopPropagation(),H?(G.current?.resize(25),Z(!1)):(G.current?.resize(5),Z(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),X>0&&f.jsx(Lr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:X}),X>0&&!H&&f.jsx(Fe,{variant:"ghost",size:"sm",onClick:B=>{B.preventDefault(),B.stopPropagation(),ae.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(tl,{className:"h-3.5 w-3.5"})})]}),f.jsx(_c,{className:`h-4 w-4 text-muted-foreground transition-transform ${H?"":"rotate-180"}`})]}),!H&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(BL,{serverIds:[r],onCountChange:re,onClearRef:ae})})]})]})}),f.jsx(Mi,{}),f.jsx(Gn,{defaultSize:50,children:f.jsx(ma,{direction:"vertical",children:f.jsx(Gn,{defaultSize:70,children:f.jsx("div",{ref:$,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(k3,{result:d,isLoading:h,previewMode:S,serverId:r,readResource:n,onTogglePreview:()=>_(!S),onCopy:F,onDownload:j,onFullscreen:P,isCopied:A})})})})})]})}HX.displayName="ResourcesTab";function R3({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:r,focusedIndex:a}){if(e.length===0)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Aw,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),f.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Execute a tool and click Save to store requests"})]});const i=(o,l)=>{o.stopPropagation(),l()};return f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((o,l)=>f.jsxs("div",{className:"relative group",children:[f.jsx(hl,{id:`saved-${o.id}`,isSelected:t?.id===o.id,isFocused:a===l,icon:f.jsx(ey,{className:"h-4 w-4"}),title:o.name,description:o.toolName,metadata:f.jsx("div",{className:"flex flex-col gap-1",children:f.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(o.savedAt).toLocaleString()})}),onClick:()=>n(o)}),f.jsx("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"secondary",size:"sm",onClick:u=>i(u,()=>r(o.id)),className:"h-8 w-8 p-0",children:f.jsx(tl,{className:"h-4 w-4"})})}),f.jsx(qt,{children:f.jsx("p",{children:"Delete saved request"})})]})})]},o.id))})}function C3({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:r,onSave:a,onCancel:i}){return e?f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:f.jsxs("div",{className:"bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700",onClick:o=>o.stopPropagation(),children:[f.jsx("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx(pn,{htmlFor:"request-name",children:"Request Name (optional)"}),f.jsx(Bn,{id:"request-name",value:t,onChange:o=>r(o.target.value),placeholder:n,className:"mt-2",onKeyDown:o=>{o.key==="Enter"&&a()},autoFocus:!0})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Fe,{variant:"outline",onClick:i,children:"Cancel"}),f.jsxs(Fe,{onClick:a,children:[f.jsx(vC,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}function VX(e,t){if(!e?.$ref)return e;const n=e.$ref;if(n.startsWith("#/")){const r=n.substring(2).split("/");let a=t;for(const i of r)if(a&&typeof a=="object"&&i in a)a=a[i];else return console.warn(`Could not resolve $ref: ${n}`),e;return a}return e}function tAe(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.find(r=>r.type!=="null");if(n)return{...VX(n,t),nullable:!0}}return e}function nAe(e){return Array.isArray(e.enum)?e.enum:null}function A3({selectedTool:e,toolArgs:t,onArgChange:n}){const r=e?.inputSchema?.properties||{},a=e?.inputSchema?.required||[];return Object.keys(r).length>0?f.jsx("div",{className:"space-y-4",children:Object.entries(r).map(([o,l])=>{const u=e?.inputSchema||{};let d=tAe(l,u);d=VX(d,u);const p=nAe(d),h=d.type==="string"&&p!==null,g=d;g.required=a.includes(o);const b=t[o];let v="";return b!=null&&(typeof b=="string"?v=b:typeof b=="object"&&b!==null?v=JSON.stringify(b,null,2):v=String(b)),g.type==="object"||g.type==="array"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:o,className:"text-sm font-medium",children:[o,g?.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(hc,{id:o,value:v,onChange:S=>n(o,S.target.value),placeholder:g?.description||`Enter ${o}`,className:"min-h-[100px]"}),g?.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},o):h&&p?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:o,className:"text-sm font-medium",children:[o,g.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs(Go,{value:String(t[o]||""),onValueChange:S=>n(o,S),children:[f.jsx(Ko,{id:o,className:"w-full",children:f.jsx(Wo,{placeholder:g.description||"Select an option"})}),f.jsx(Zo,{children:p.map((S,_)=>f.jsx(Gr,{value:S,children:g.enumNames?.[_]||S},S))})]}),g.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},o):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:o,className:"text-sm font-medium",children:[o,g?.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(Bn,{id:o,value:v,onChange:S=>n(o,S.target.value),placeholder:g?.description||`Enter ${o}`}),g?.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},o)})}):f.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No parameters required"})}function I3({selectedTool:e,toolArgs:t,isExecuting:n,isConnected:r,onArgChange:a,onExecute:i,onSave:o,onCancel:l}){const[u,d]=y.useState(!1),[p,h]=y.useState(()=>{if(typeof window<"u"){const x=localStorage.getItem("mcp-inspector-show-tool-metadata");return x?JSON.parse(x):!1}return!1}),[g,b]=y.useState(!1);y.useEffect(()=>{typeof window<"u"&&localStorage.setItem("mcp-inspector-show-tool-metadata",JSON.stringify(p))},[p]);const v=()=>{if(!e)return;const x={name:e.name,description:e.description||"",_meta:e._meta};navigator.clipboard.writeText(JSON.stringify(x,null,2)),b(!0),setTimeout(()=>b(!1),2e3)};return y.useEffect(()=>{const x=S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&e&&!n&&r&&(S.preventDefault(),i()),S.key==="Escape"&&n&&l&&(S.preventDefault(),l())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[e,n,r,i,l]),e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsxs(Fe,{variant:p?"default":"outline",onClick:()=>h(!p),disabled:n,size:"sm",className:"lg:size-default gap-2",title:"Toggle tool metadata",children:[f.jsx(mC,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Metadata"})]})}),f.jsx(qt,{children:f.jsx("p",{children:"Show tool definition metadata"})})]}),f.jsxs(Fe,{variant:"outline",onClick:o,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(vC,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),n&&l?f.jsxs(Zt,{open:u?void 0:!1,children:[f.jsx(Yt,{asChild:!0,children:f.jsx("div",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:"relative",children:f.jsx(Fe,{onClick:l,variant:u?"destructive":"default",size:"sm",className:"lg:size-default gap-2 transition-all",children:u?f.jsxs(f.Fragment,{children:[f.jsx(po,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Cancel"}),f.jsx("span",{className:"hidden sm:inline text-[12px] border border-current p-1 rounded-full ml-2",children:"Esc"})]}):f.jsxs(f.Fragment,{children:[f.jsx(Fi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]})})})}),f.jsx(qt,{children:f.jsx("p",{children:"Hover to cancel (or press Esc)"})})]}):f.jsx(Fe,{onClick:i,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Fi,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx($7,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"}),f.jsx("span",{className:"hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2",children:"⌘↵"})]})})]})]}),e.description&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),p?f.jsxs("div",{className:"flex-1 overflow-hidden flex gap-4 px-3 sm:px-6 pb-4",children:[f.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:f.jsx(A3,{selectedTool:e,toolArgs:t,onArgChange:a})}),f.jsxs("div",{className:"w-2/5 flex flex-col bg-zinc-50 dark:bg-zinc-900/50 rounded border border-zinc-200 dark:border-zinc-800 overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-zinc-200 dark:border-zinc-800 flex-shrink-0",children:[f.jsx("h4",{className:"text-sm font-medium",children:"Tool Definition"}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:v,className:"h-7 w-7 p-0",title:"Copy metadata",children:g?f.jsx(ba,{className:"h-3.5 w-3.5 text-green-600"}):f.jsx(Zr,{className:"h-3.5 w-3.5"})})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:f.jsx("pre",{className:"text-xs font-mono text-zinc-700 dark:text-zinc-300 whitespace-pre-wrap break-words",children:JSON.stringify({name:e.name,description:e.description||"(no description)",_meta:e._meta||null},null,2)})})]})]}):f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(A3,{selectedTool:e,toolArgs:t,onArgChange:a})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),f.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a tool from the list to view its details and execute it"})]})}function O3(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),i=Math.floor(a/60),o=Math.floor(i/24);return r<10?"now":r<60?`${r}s ago`:a<60?`${a}m ago`:i<24?`${i}h ago`:`${o}d ago`}function rAe(e){if(!e?.isError)return null;if(e.content&&Array.isArray(e.content)){const t=e.content.filter(n=>n.type==="text").map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1693
1693
|
`)}return"An error occurred"}function aAe(e){try{return JSON.parse(e),!0}catch{return!1}}function iAe({content:e}){return!Array.isArray(e)||e.length===0?f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):f.jsx("div",{className:"space-y-4",children:e.map((t,n)=>{if(t.type==="text"){const r=t.text||"";if(aAe(r))try{const a=JSON.parse(r);return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content (JSON)"}),f.jsx(fr,{data:a,filename:`content-${n}.json`})]},n)}catch{}return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content"}),f.jsx("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words",children:r})]},n)}if(t.type==="image")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[f.jsx("img",{src:`data:${t.mimeType||"image/png"};base64,${t.data}`,alt:"Result",className:"max-w-full rounded"}),t.annotations&&f.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.jsx(fr,{data:t.annotations,filename:`image-annotations-${n}.json`})})]})]},n);if(t.type==="audio")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[f.jsx("audio",{controls:!0,src:`data:${t.mimeType||"audio/wav"};base64,${t.data}`,className:"w-full"}),t.annotations&&f.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.jsx(fr,{data:t.annotations,filename:`audio-annotations-${n}.json`})})]})]},n);if(t.type==="resource_link")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"font-mono text-sm break-all",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",t.uri]}),t.name&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",t.name]}),t.description&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",t.description]}),t.mimeType&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",t.mimeType]}),t.annotations&&f.jsxs("div",{className:"mt-2",children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),f.jsx(fr,{data:t.annotations,filename:`resource-link-annotations-${n}.json`})]})]})]},n);if(t.type==="resource"){const r=t.resource||{};return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"font-mono text-sm break-all",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",r.uri]}),r.mimeType&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",r.mimeType]}),r.text&&f.jsxs("div",{children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),f.jsx("div",{className:"bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:r.text})]}),r.blob&&f.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",r.blob.length||0," bytes]"]}),r.annotations&&f.jsxs("div",{className:"mt-2",children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),f.jsx(fr,{data:r.annotations,filename:`resource-annotations-${n}.json`})]})]})]},n)}return f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",t.type||"N/A"]}),f.jsx(fr,{data:t,filename:`content-${n}.json`})]},n)})})}function D3({results:e,copiedResult:t,previewMode:n,serverId:r,readResource:a,onCopy:i,onTogglePreview:o,onMaximize:l,isMaximized:u=!1}){const[d,p]=y.useState(0),[h,g]=y.useState(""),[b,v]=y.useState(!0),x=e[0],S=x?e.filter(X=>X.toolName===x.toolName):[],_=S[d]||S[0],E=e.findIndex(X=>X===_);y.useEffect(()=>{S.length>0&&d>=S.length&&p(0)},[S.length,d]),y.useEffect(()=>{const X=()=>{_&&g(O3(_.timestamp))};X();const re=setInterval(X,1e3);return()=>clearInterval(re)},[_]);const k=y.useMemo(()=>_?.args,[_?.timestamp,d]),C=y.useMemo(()=>_?.result,[_?.timestamp,d]),R=y.useCallback(X=>a(X),[a]);if(e.length===0)return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const A=_.toolMeta?.["openai/outputTemplate"],N=!!(A&&typeof A=="string"&&_.appsSdkResource),O=A,$=_.result?.content||[],M=$.filter(X=>X.type==="resource"&&td(X.resource)),z=M.length>0,W=!!($&&$.length>0||_.result?.structuredContent),J=!z&&!N&&W;return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:`flex items-center gap-2 px-4 pt-2 ${z||N||J?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[f.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),_.duration!==void 0&&f.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[f.jsx(pm,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[_.duration,"ms"]})]}),N&&f.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",O||"No URI"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>o(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Component"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>o(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw JSON"})]})]}),z&&!N&&f.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",M[0]?.resource?.uri||"No URI"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>o(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Preview"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>o(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"JSON"})]})]}),J&&f.jsxs("div",{className:"flex items-center gap-2 sm:ml-4",children:[f.jsx("button",{onClick:()=>v(!0),className:`text-xs font-medium ${b?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>v(!1),className:`text-xs font-medium ${b?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(N||z)&&l&&f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,title:u?"Restore":"Maximize",children:u?f.jsx(Vve,{className:"h-4 w-4"}):f.jsx(bC,{className:"h-4 w-4"})}),S.length>1&&f.jsxs(Go,{value:d.toString(),onValueChange:X=>p(parseInt(X)),children:[f.jsx(Ko,{size:"sm",className:"w-[140px] h-8 text-xs",children:f.jsx(Wo,{children:f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(ey,{className:"h-3 w-3"}),f.jsx("span",{children:h})]})})}),f.jsx(Zo,{children:S.map((X,re)=>f.jsx(Gr,{value:re.toString(),children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(ey,{className:"h-3 w-3"}),f.jsx("span",{children:O3(X.timestamp)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",new Date(X.timestamp).toLocaleTimeString(),")"]})]})},re))})]}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>i(E,_.result),children:t===E?f.jsx(ba,{className:"h-4 w-4"}):f.jsx(Zr,{className:"h-4 w-4"})})]})]}),(()=>{const X=_.error||rAe(_.result);return X?f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:X})]}):(()=>{if(N){const re=_.appsSdkResource;return re.isLoading?f.jsx(f.Fragment,{}):re.error?f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Resource Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:re.error})]}):n?f.jsx("div",{className:"flex-1",children:f.jsx(OL,{componentUrl:O,toolName:_.toolName,toolArgs:k,toolResult:C,serverId:r,readResource:R,className:"w-full h-full relative p-4"})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})}if(z)return n?f.jsxs("div",{className:"space-y-0 h-full",children:[M.map((re,H)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx(BX,{resource:re.resource,onUIAction:Z=>{},className:"w-full h-full relative"})},H)),$.filter(re=>!(re.type==="resource"&&td(re.resource))).length>0&&f.jsx("div",{className:"px-4",children:f.jsx(fr,{data:$.filter(re=>!(re.type==="resource"&&td(re.resource))),filename:`tool-result-${_.toolName}-non-ui-${Date.now()}.json`})})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:_.result,filename:`tool-result-${_.toolName}-mcp-ui-${Date.now()}.json`})});if(J&&b){const re=_.result?.structuredContent;return f.jsxs("div",{className:"px-4 pt-4 space-y-4",children:[re&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),f.jsx(fr,{data:re,filename:`structured-content-${_.toolName}-${Date.now()}.json`})]}),$&&$.length>0&&f.jsx(iAe,{content:$}),!re&&(!$||$.length===0)&&f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content to display"})]})}return f.jsx("div",{className:"px-4 pt-4",children:f.jsx(fr,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})})()})()]})})})}function L3({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:r}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(uc,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((a,i)=>f.jsx(hl,{id:`tool-${a.name}`,isSelected:t?.name===a.name,isFocused:r===i,icon:f.jsx(uc,{className:"h-4 w-4"}),title:a.name,description:a.description,metadata:a.inputSchema?.properties&&f.jsxs(Lr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[Object.keys(a.inputSchema.properties).length," params"]}),onClick:()=>n(a)},a.name))})}function j3({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:r,savedRequestsCount:a,onSearchExpand:i,onSearchChange:o,onSearchBlur:l,onTabSwitch:u,searchInputRef:d}){return f.jsx(zX,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:r,secondaryCount:a,primaryIcon:uc,secondaryIcon:Aw,searchPlaceholder:"Search tools...",onSearchExpand:i,onSearchChange:o,onSearchBlur:l,onTabSwitch:u,searchInputRef:d})}const $3="mcp-inspector-saved-requests";function GX({ref:e,tools:t,callTool:n,readResource:r,serverId:a,isConnected:i}){const[o,l]=y.useState(null),[u,d]=y.useState(null),{selectedToolName:p,setSelectedToolName:h}=kc(),[g,b]=y.useState({}),[v,x]=y.useState([]),[S,_]=y.useState(!1),[E,k]=y.useState(null),[C,R]=y.useState(null),[A,N]=y.useState(""),[O,$]=y.useState("tools"),[M,z]=y.useState([]),[W,J]=y.useState(!1),[X,re]=y.useState(""),[H,Z]=y.useState(!0),[G,ae]=y.useState(!1),[ne,L]=y.useState(-1),V=y.useRef(null),[F,j]=y.useState(!1),[P,B]=y.useState("list"),[K,ee]=y.useState(!1),[ie,ue]=y.useState(0),[Q,q]=y.useState(!0),[le,ve]=y.useState(void 0),oe=y.useRef(null),Ae=y.useRef(null),Je=y.useRef(null),ke=y.useRef(null),Re=y.useRef(null);y.useEffect(()=>{const Te=()=>{j(window.innerWidth<1024)};return Te(),window.addEventListener("resize",Te),()=>window.removeEventListener("resize",Te)},[]),y.useEffect(()=>{B(o?"detail":"list")},[o]),y.useEffect(()=>{F&&v.length>0&&!S&&B("response")},[v,S,F]),y.useImperativeHandle(e,()=>({focusSearch:()=>{ae(!0),setTimeout(()=>{V.current&&V.current.focus()},0)},blurSearch:()=>{N(""),ae(!1),V.current&&V.current.blur()}})),y.useEffect(()=>{try{const Te=localStorage.getItem($3);Te&&z(JSON.parse(Te))}catch(Te){console.error("[ToolsTab] Failed to load saved requests:",Te)}},[]);const Ze=y.useCallback(Te=>{try{localStorage.setItem($3,JSON.stringify(Te)),z(Te)}catch(Pe){console.error("[ToolsTab] Failed to save requests:",Pe)}},[]),me=y.useMemo(()=>{if(!A.trim())return t;const Te=A.toLowerCase();return t.filter(Pe=>Pe.name.toLowerCase().includes(Te)||Pe.description?.toLowerCase().includes(Te))},[t,A]),Le=y.useCallback(Te=>{l(Te);const Pe={};Te.inputSchema?.properties&&Object.entries(Te.inputSchema.properties).forEach(([Ve,Qe])=>{const ot=Qe;ot.default!==void 0?Pe[Ve]=ot.default:ot.type==="string"?Pe[Ve]="":ot.type==="number"?Pe[Ve]=0:ot.type==="boolean"?Pe[Ve]=!1:ot.type==="array"?Pe[Ve]="[]":ot.type==="object"&&(Pe[Ve]="{}")}),b(Pe)},[]),Ke=y.useCallback(Te=>{const Pe=t.find(Ve=>Ve.name===Te.toolName);Pe&&(l(Pe),b(Te.args),d(Te))},[t]);y.useEffect(()=>{G&&V.current&&V.current.focus()},[G]);const _e=y.useCallback(()=>{A.trim()||ae(!1)},[A]);y.useEffect(()=>{O!=="tools"&&ae(!1)},[O]),y.useEffect(()=>{L(-1)},[A,O]),y.useEffect(()=>{const Te=Pe=>{const Ve=Pe.target;if(Ve.tagName==="INPUT"||Ve.tagName==="TEXTAREA"||Ve.contentEditable==="true"||Pe.metaKey||Pe.ctrlKey||Pe.altKey)return;const ot=O==="tools"?me:M;if(Pe.key==="ArrowDown")Pe.preventDefault(),L($t=>{const Rt=$t+1;return Rt>=ot.length?0:Rt});else if(Pe.key==="ArrowUp")Pe.preventDefault(),L($t=>{const Rt=$t-1;return Rt<0?ot.length-1:Rt});else if(Pe.key==="Enter"&&ne>=0)if(Pe.preventDefault(),O==="tools"){const $t=me[ne];$t&&Le($t)}else{const $t=M[ne];$t&&Ke($t)}};return document.addEventListener("keydown",Te),()=>document.removeEventListener("keydown",Te)},[ne,me,M,O,Le,Ke]),y.useEffect(()=>{if(ne>=0){const Te=O==="tools"?`tool-${me[ne]?.name}`:`saved-${M[ne]?.id}`,Pe=document.getElementById(Te);Pe&&Pe.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,me,M,O]),y.useEffect(()=>{if(p&&t.length>0){const Te=t.find(Pe=>Pe.name===p);if(Te&&o?.name!==Te.name){h(null);const Pe=setTimeout(()=>{Le(Te);const Ve=document.getElementById(`tool-${Te.name}`);Ve&&Ve.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout(Pe)}}},[p,t,o,Le,h]);const vt=y.useCallback((Te,Pe)=>{b(Ve=>{const Qe={...Ve};if(o?.inputSchema?.properties?.[Te]){const $t=o.inputSchema.properties[Te].type;if($t==="object"||$t==="array")Qe[Te]=Pe;else if($t==="string")Qe[Te]=Pe;else try{Qe[Te]=JSON.parse(Pe)}catch{Qe[Te]=Pe}}else Qe[Te]=Pe;return Qe})},[o]),gt=y.useCallback(async()=>{if(!o||S)return;const Te=new AbortController;R(Te),_(!0);const Pe=Date.now();try{const Ve={...g};o.inputSchema?.properties&&Object.entries(o.inputSchema.properties).forEach(([at,it])=>{const Mt=it.type,nr=Ve[at];if((Mt==="object"||Mt==="array")&&typeof nr=="string")try{Ve[at]=JSON.parse(nr)}catch{}});const Qe=await n(o.name,Ve,{timeout:6e5,resetTimeoutOnProgress:!0,signal:Te.signal}),ot=Date.now()-Pe;Or.getInstance().capture(new $4({toolName:o.name,serverId:a,success:!0,duration:ot})).catch(()=>{});const Rt=o?._meta||o?.metadata,Xt=Rt?.["openai/outputTemplate"];let un;if(Xt&&typeof Xt=="string"){const at={toolName:o.name,args:g,result:Qe,timestamp:Pe,duration:ot,toolMeta:Rt,appsSdkResource:{uri:Xt,resourceData:null,isLoading:!0}};x([at]);try{const it=await r(Xt);let kt=null;if(Qe?.structuredContent)kt=Qe.structuredContent;else if(Array.isArray(Qe)&&Qe[0]){const Mt=Qe[0];Mt.output?.value?.structuredContent?kt=Mt.output.value.structuredContent:Mt.structuredContent?kt=Mt.structuredContent:Mt.output?.value&&(kt=Mt.output.value)}kt||(kt=Qe),un={uri:Xt,resourceData:{...it,structuredContent:kt},isLoading:!1}}catch(it){un={uri:Xt,resourceData:null,isLoading:!1,error:it instanceof Error?it.message:String(it)}}x(it=>it.map((kt,Mt)=>Mt===0?{...kt,appsSdkResource:un}:kt))}else x(at=>[{toolName:o.name,args:g,result:Qe,timestamp:Pe,duration:ot,toolMeta:Rt},...at])}catch(Ve){const Qe=Date.now()-Pe;Or.getInstance().capture(new $4({toolName:o.name,serverId:a,success:!1,duration:Qe,error:Ve instanceof Error?Ve.message:String(Ve)})).catch(()=>{});const $t=o?._meta||o?.metadata,Rt={toolName:o.name,args:g,result:null,error:Ve instanceof Error?Ve.message:String(Ve),timestamp:Pe,duration:Qe,toolMeta:$t},Xt=$t?.["openai/outputTemplate"];x(Xt?[Rt]:un=>[Rt,...un])}finally{_(!1)}},[o,g,S,n,r,a]),wt=y.useCallback(async(Te,Pe)=>{try{await navigator.clipboard.writeText(JSON.stringify(Pe,null,2)),k(Te),setTimeout(()=>k(null),2e3)}catch(Ve){console.error("[ToolsTab] Failed to copy result:",Ve)}},[]),Tt=y.useCallback(Te=>{x(Pe=>Pe.filter((Ve,Qe)=>Qe!==Te))},[]),At=y.useMemo(()=>o?v.filter(Te=>Te.toolName===o.name):[],[v,o]),Cn=y.useCallback(Te=>{const Pe=At[Te];if(Pe){const Ve=window.open("","_blank","width=800,height=600");Ve&&(Ve.document.write(`
|
|
1694
1694
|
<html>
|
|
@@ -1704,4 +1704,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1704
1704
|
<pre>${JSON.stringify(Pe.result,null,2)}</pre>
|
|
1705
1705
|
</body>
|
|
1706
1706
|
</html>
|
|
1707
|
-
`),Ve.document.close())}},[v]),mr=y.useCallback(()=>{K?(oe.current&&oe.current.expand(),Ae.current&&Ae.current.expand(),ee(!1)):(oe.current&&oe.current.collapse(),Ae.current&&Ae.current.collapse(),ee(!0))},[K]),Ut=y.useCallback(()=>{o&&(re(""),J(!0))},[o]),He=y.useCallback(()=>{if(!o)return;const Te={id:`${Date.now()}-${Math.random()}`,name:X.trim()||`${o.name} - ${new Date().toLocaleString()}`,toolName:o.name,args:g,savedAt:Date.now(),serverId:o._serverId,serverName:o._serverName};Ze([...M,Te]),Or.getInstance().capture(new Abe({toolName:o.name,serverId:a})).catch(()=>{}),J(!1),re("")},[o,X,g,M,Ze,a]),Be=y.useCallback(Te=>{Ze(M.filter(Pe=>Pe.id!==Te)),u?.id===Te&&d(null)},[M,Ze,u]);return F?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[P!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>{P==="response"?B("detail"):(l(null),B("list"))},className:"p-0 h-8 w-8",children:f.jsx(Cw,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{l(null),B("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),P==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{B("response")},className:P==="detail"?"text-foreground hover:underline":P==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),P==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($w,{initial:!1,mode:"popLayout",children:[P==="list"&&f.jsxs(Ia.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[f.jsx(j3,{activeTab:O,isSearchExpanded:G,searchQuery:A,filteredToolsCount:me.length,savedRequestsCount:M.length,onSearchExpand:()=>ae(!0),onSearchChange:N,onSearchBlur:_e,onTabSwitch:()=>$(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(L3,{tools:me,selectedTool:o,onToolSelect:Le,focusedIndex:ne}):f.jsx(R3,{savedRequests:M,selectedRequest:u,onLoadRequest:Ke,onDeleteRequest:Be,focusedIndex:ne})]},"list"),P==="detail"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:f.jsx(I3,{selectedTool:o,toolArgs:g,isExecuting:S,isConnected:i,onArgChange:vt,onExecute:gt,onSave:Ut})},"detail"),P==="response"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:f.jsx(D3,{results:At,copiedResult:E,previewMode:H,serverId:a,readResource:r,onCopy:wt,onDelete:Tt,onFullscreen:Cn,onTogglePreview:()=>Z(!H)})},"response")]})}),f.jsx(C3,{isOpen:W,requestName:X,defaultPlaceholder:`${o?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:re,onSave:He,onCancel:()=>J(!1)})]}):f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{ref:oe,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:f.jsxs(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Gn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(j3,{activeTab:O,isSearchExpanded:G,searchQuery:A,filteredToolsCount:me.length,savedRequestsCount:M.length,onSearchExpand:()=>ae(!0),onSearchChange:N,onSearchBlur:_e,onTabSwitch:()=>$(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(L3,{tools:me,selectedTool:o,onToolSelect:Le,focusedIndex:ne}):f.jsx(R3,{savedRequests:M,selectedRequest:u,onLoadRequest:Ke,onDeleteRequest:Be,focusedIndex:ne})]})}),f.jsx(Mi,{withHandle:!0}),f.jsxs(Gn,{ref:ke,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>{q(!0)},onExpand:()=>{q(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Te=>{Te.preventDefault(),Te.stopPropagation(),Q?(ke.current?.resize(25),q(!1)):(ke.current?.resize(5),q(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),ie>0&&f.jsx(Lr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:ie}),ie>0&&!Q&&f.jsx(Fe,{variant:"ghost",size:"sm",onClick:Te=>{Te.preventDefault(),Te.stopPropagation(),Re.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(tl,{className:"h-3.5 w-3.5"})})]}),f.jsx(_c,{className:`h-4 w-4 text-muted-foreground transition-transform ${Q?"":"rotate-180"}`})]}),!Q&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(BL,{serverIds:[a],onCountChange:ue,onClearRef:Re})})]})]})}),f.jsx(Mi,{withHandle:!0}),f.jsx(Gn,{defaultSize:67,children:f.jsxs(ma,{direction:"vertical",children:[f.jsx(Gn,{ref:Ae,defaultSize:40,collapsible:!0,children:f.jsx(I3,{selectedTool:o,toolArgs:g,isExecuting:S,isConnected:i,onArgChange:vt,onExecute:gt,onSave:Ut,onCancel:()=>{C&&C.abort()}})}),f.jsx(Mi,{withHandle:!0}),f.jsx(Gn,{ref:Je,defaultSize:60,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(D3,{results:At,copiedResult:E,previewMode:H,serverId:a,readResource:r,onCopy:wt,onDelete:Tt,onFullscreen:Cn,onTogglePreview:()=>Z(!H),onMaximize:mr,isMaximized:K})})})]})}),f.jsx(C3,{isOpen:W,requestName:X,defaultPlaceholder:`${o?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:re,onSave:He,onCancel:()=>J(!1)})]})}GX.displayName="ToolsTab";function oAe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:i,onSearchBlur:o,onRejectAll:l,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(Bn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:o,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:f.jsx(tl,{className:"h-4 w-4"})})}),f.jsx(qt,{side:"bottom",children:"Reject all"})]})})]})}function sAe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((o,l)=>{const u=o.request.params?.messages?.length||0,d=o.request.params?.maxTokens;return f.jsx(hl,{id:`sampling-request-${o.id}`,isSelected:t?.id===o.id,isFocused:r===l,title:f.jsxs("span",{className:"flex items-center gap-3",children:[o.serverName,f.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const p=a(o.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),d&&h.push(`max ${d} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return p+g})(),onClick:()=>n(o)},o.id)})})}function lAe({llmConfig:e}){const t=y.useRef(null);return{generateResponse:y.useCallback(async({request:r})=>{if(!e)throw new Error("LLM config is not available");const a=r.params||{},i=a.maxTokens,o=a.temperature;a.modelPreferences;const l=a.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!a,messagesCount:l.length,messages:l,params:a}),l.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:d,AIMessage:p}=await pr(async()=>{const{HumanMessage:v,AIMessage:x}=await import("./index-CyHacqJj.js").then(S=>S.bD);return{HumanMessage:v,AIMessage:x}},[]);for(const v of l){if(!v||!v.role){console.warn("Skipping invalid message:",v);continue}const x=Array.isArray(v.content)?v.content[0]:v.content;if(!x){console.warn("Skipping message with no content:",v);continue}x.type==="text"&&x.text?v.role==="user"?u.push(new d(x.text)):v.role==="assistant"&&u.push(new p(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 v;const x={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(x.maxTokens=i),o!==void 0?x.temperature=o:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:S}=await pr(async()=>{const{ChatOpenAI:_}=await import("./index-CyjpFzxN.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,2,8,9]));v=new S(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:S}=await pr(async()=>{const{ChatAnthropic:_}=await import("./index-1oOUdn3H.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,2]));v=new S(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:S}=await pr(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-DdjBoJpx.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,2,9]));v=new S(x)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:v,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 cAe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:i,isCopied:o,onCopy:l,onDownload:u,onFullscreen:d,llmConfig:p}){const[h,g]=y.useState("manual"),[b,v]=y.useState("stub-model"),[x,S]=y.useState("endTurn"),[_,E]=y.useState("assistant"),[k,C]=y.useState("text"),[R,A]=y.useState("positive"),[N,O]=y.useState(""),[$,M]=y.useState("image/png"),[z,W]=y.useState(!1),[J,X]=y.useState(null),{generateResponse:re,isAvailable:H}=lAe({llmConfig:p});y.useEffect(()=>{e&&(v("stub-model"),S("endTurn"),E("assistant"),C("text"),A("positive"),O(""),M("image/png"),X(null))},[e?.id]);const Z=async()=>{if(!(!e||!H)){W(!0),X(null);try{const L=await re({request:e.request});v(L.model||p?.model||"stub-model"),S(L.stopReason||"endTurn"),E(L.role||"assistant");const V=Array.isArray(L.content)?L.content[0]:L.content;V.type==="text"?(C("text"),A(V.text||"")):V.type==="image"&&(C("image"),O(V.data||""),M(V.mimeType||"image/png"))}catch(L){const V=L instanceof Error?L.message:"Failed to generate response";X(V),vn.error("LLM Generation Failed",{description:V})}finally{W(!1)}}},G=y.useMemo(()=>{const L={model:b,stopReason:x,role:_,content:{type:k}};return k==="text"?L.content.text=R:k==="image"&&(L.content.data=N,L.content.mimeType=$),L},[b,x,_,k,R,N,$]),ae=()=>{if(!e)return;const L=oR.safeParse(G);if(!L.success){vn.error("Invalid response",{description:`Validation failed: ${L.error.message}`});return}t(e.id,L.data),r(),pr(()=>Promise.resolve().then(()=>Gd),void 0).then(V=>{const F=vn(V.createElement("div",{className:"space-y-3"},V.createElement("div",null,V.createElement("strong",null,"Sampling Response Sent"),V.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),V.createElement("div",{className:"flex gap-2"},V.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const j=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(j),vn.dismiss(F)}},"View Tool Result"))),{duration:5e3})})},ne=()=>{e&&(n(e.id,"User rejected sampling request"),r())};return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0",children:o?f.jsx(ba,{className:"h-4 w-4 text-green-600"}):f.jsx(Zr,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Copy request"})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(nh,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Download request"})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(gC,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Fullscreen"})]}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(po,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(fr,{data:e.request})})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(pn,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),f.jsxs(Go,{value:h,onValueChange:L=>g(L),children:[f.jsx(Ko,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:f.jsx(Wo,{})}),f.jsxs(Zo,{children:[f.jsx(Gr,{value:"manual",children:"Manual"}),f.jsx(Gr,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&f.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[H?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Fe,{onClick:Z,disabled:z,size:"sm",className:"flex items-center gap-2",children:z?f.jsxs(f.Fragment,{children:[f.jsx(el,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):f.jsxs(f.Fragment,{children:[f.jsx(cye,{className:"h-4 w-4"}),"Generate with LLM"]})}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",p?.provider," (",p?.model,")"]})]}):f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),J&&f.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:J})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`model-${e.id}`,children:"Model"}),f.jsx(Bn,{id:`model-${e.id}`,value:b,onChange:L=>v(L.target.value),placeholder:"stub-model",disabled:h==="llm"&&z})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),f.jsx(Bn,{id:`stopReason-${e.id}`,value:x,onChange:L=>S(L.target.value),placeholder:"endTurn",disabled:h==="llm"&&z})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`role-${e.id}`,children:"Role"}),f.jsxs(Go,{value:_,onValueChange:L=>E(L),disabled:h==="llm"&&z,children:[f.jsx(Ko,{id:`role-${e.id}`,children:f.jsx(Wo,{})}),f.jsxs(Zo,{children:[f.jsx(Gr,{value:"assistant",children:"assistant"}),f.jsx(Gr,{value:"user",children:"user"})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),f.jsxs(Go,{value:k,onValueChange:L=>C(L),disabled:h==="llm"&&z,children:[f.jsx(Ko,{id:`contentType-${e.id}`,children:f.jsx(Wo,{})}),f.jsxs(Zo,{children:[f.jsx(Gr,{value:"text",children:"text"}),f.jsx(Gr,{value:"image",children:"image"})]})]})]}),k==="text"&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`text-${e.id}`,children:"Text Content"}),f.jsx(hc,{id:`text-${e.id}`,value:R,onChange:L=>A(L.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&z})]}),k==="image"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),f.jsx(hc,{id:`imageData-${e.id}`,value:N,onChange:L=>O(L.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&z})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),f.jsx(Bn,{id:`mimeType-${e.id}`,value:$,onChange:L=>M(L.target.value),placeholder:"image/png",disabled:h==="llm"&&z})]})]})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(Fe,{onClick:ae,className:"flex-1",disabled:h==="llm"&&z,children:"Approve"}),f.jsx(Fe,{onClick:ne,variant:"outline",className:"flex-1",disabled:h==="llm"&&z,children:"Reject"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}function uAe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:a,mcpServerUrl:i}){const{selectedSamplingRequestId:o,setSelectedSamplingRequestId:l}=kc(),{llmConfig:u}=vX({mcpServerUrl:i}),[d,p]=y.useState(null),[h,g]=y.useState(""),[b,v]=y.useState(-1),[x,S]=y.useState(!0),[_,E]=y.useState(!1),[k,C]=y.useState(!0),[R,A]=y.useState(!1),N=y.useRef(null),O=y.useRef(null),$=y.useRef(null),M=y.useRef(!1);y.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:o,pendingRequestsCount:e.length,currentSelectedId:d?.id}),o&&e.length>0){const G=e.find(ae=>ae.id===o);console.log("[SamplingTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[SamplingTab] Auto-selecting request:",G.id),l(null),p(G),setTimeout(()=>{const ae=document.getElementById(`sampling-request-${G.id}`);console.log("[SamplingTab] Scrolling to element:",!!ae),ae&&ae.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[o,e,l]),y.useEffect(()=>{const G=ae=>{const L=ae.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",L);const V=e.find(F=>F.id===L);V&&(console.log("[SamplingTab] Selecting request from event:",L),p(V),setTimeout(()=>{const F=document.getElementById(`sampling-request-${L}`);F&&F.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",G),()=>window.removeEventListener("navigate-to-sampling",G)},[e]),y.useEffect(()=>{x&&e.length>0&&N.current&&!M.current&&(N.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const G=N.current;if(!G)return;const ae=()=>{G.scrollTop>0&&(M.current=!0,S(!1))};return G.addEventListener("scroll",ae),()=>G.removeEventListener("scroll",ae)},[]),y.useEffect(()=>{e.length===0&&(M.current=!1,S(!0))},[e.length]),y.useEffect(()=>{_&&$.current&&$.current.focus()},[_]);const z=y.useCallback(()=>{h.trim()||E(!1)},[h]),W=y.useMemo(()=>{if(!h.trim())return e;const G=h.toLowerCase();return e.filter(ae=>ae.serverName.toLowerCase().includes(G)||JSON.stringify(ae.request||{}).toLowerCase().includes(G))},[e,h]);y.useEffect(()=>{v(-1)},[h]),y.useEffect(()=>{const G=ae=>{const ne=ae.target;if(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.contentEditable==="true"||ae.metaKey||ae.ctrlKey||ae.altKey)return;const V=W;if(ae.key==="ArrowDown")ae.preventDefault(),v(F=>{const j=F+1;return j>=V.length?0:j});else if(ae.key==="ArrowUp")ae.preventDefault(),v(F=>{const j=F-1;return j<0?V.length-1:j});else if(ae.key==="Enter"&&b>=0){ae.preventDefault();const F=W[b];F&&J(F)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[b,W]),y.useEffect(()=>{if(b>=0){const G=`sampling-request-${W[b]?.id}`,ae=document.getElementById(G);ae&&ae.scrollIntoView({behavior:"smooth",block:"nearest"})}},[b,W]);const J=y.useCallback(G=>{p(G)},[]),X=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(G=>{n(G.id,"User rejected all requests")}),p(null))},[e,n]),re=y.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(G){console.error("[SamplingTab] Failed to copy request:",G)}},[d]),H=y.useCallback(()=>{if(d)try{const G=new globalThis.Blob([JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)],{type:"application/json"}),ae=URL.createObjectURL(G),ne=document.createElement("a");ne.href=ae,ne.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(ae)}catch(G){console.error("[SamplingTab] Failed to download request:",G)}},[d]),Z=y.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(G){console.error("[SamplingTab] Failed to toggle fullscreen:",G)}},[]);return a?f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:40,minSize:30,children:f.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Gn,{defaultSize:75,minSize:30,children:[f.jsx(oAe,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:W.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:z,onRejectAll:X,searchInputRef:$}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(sAe,{requests:W,selectedRequest:d,onRequestSelect:J,focusedIndex:b,formatRelativeTime:Cy,listRef:N})})]})})}),f.jsx(Mi,{}),f.jsx(Gn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(cAe,{request:d,onApprove:t,onReject:n,onClose:()=>p(null),previewMode:k,onTogglePreview:()=>C(!k),isCopied:R,onCopy:re,onDownload:H,onFullscreen:Z,llmConfig:u})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(L7,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function dAe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:i,onSearchBlur:o,onCancelAll:l,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(Bn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:o,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:f.jsx(po,{className:"h-4 w-4"})})}),f.jsx(qt,{side:"bottom",children:"Cancel all"})]})})]})}function fAe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((o,l)=>{const u=o.request.mode||"form",d=u==="form"&&"requestedSchema"in o.request&&o.request.requestedSchema;return f.jsx(hl,{id:`elicitation-request-${o.id}`,isSelected:t?.id===o.id,isFocused:r===l,title:f.jsxs("span",{className:"flex items-center gap-3",children:[o.serverName,f.jsx(Lr,{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 p=a(o.timestamp),h=[];d&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return p+g})(),onClick:()=>n(o)},o.id)})})}function pAe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:i,isCopied:o,onCopy:l,onDownload:u,onFullscreen:d}){const[p,h]=y.useState({}),[g,b]=y.useState(!1),v=e?.request.mode||"form",x=v==="form",S=v==="url";y.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const N=e.request.requestedSchema,O={};if(N?.type==="object"&&N.properties)for(const[$,M]of Object.entries(N.properties)){const z=M;z.default!==void 0?O[$]=z.default:z.type==="boolean"?O[$]=!1:z.type==="number"||z.type==="integer"?O[$]=0:O[$]=""}h(O)}b(!1)},[e?.id,x]);const _=(N,O)=>{h($=>({...$,[N]:O}))},E=()=>{if(e){if(x){if("requestedSchema"in e.request){const N=e.request.requestedSchema;if(N?.required){const O=N.required.filter($=>p[$]===void 0||p[$]===""||p[$]===null);if(O.length>0){vn.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:p})}else S&&t(e.id,{action:"accept"});r(),pr(()=>Promise.resolve().then(()=>Gd),void 0).then(N=>{const O=vn(N.createElement("div",{className:"space-y-3"},N.createElement("div",null,N.createElement("strong",null,"Elicitation Response Sent"),N.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),N.createElement("div",{className:"flex gap-2"},N.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 $=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent($),vn.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),r())},C=()=>{e&&(n(e.id,"User cancelled elicitation request"),r())},R=()=>{e&&S&&"url"in e.request&&(window.open(e.request.url,"_blank"),b(!0))},A=y.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const N=e.request.requestedSchema;if(!N||N.type!=="object"||!N.properties)return f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=N.properties,$=N.required||[];return f.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([M,z])=>{const W=z,J=$.includes(M),X=W.type||"string",re=W.title||M,H=W.description;return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:`field-${M}`,children:[re,J&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),H&&f.jsx("p",{className:"text-xs text-muted-foreground",children:H}),X==="boolean"?f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(Tm,{id:`field-${M}`,checked:p[M]||!1,onCheckedChange:Z=>_(M,Z)}),f.jsx(pn,{htmlFor:`field-${M}`,className:"text-sm font-normal cursor-pointer",children:W.title||M})]}):X==="number"||X==="integer"?f.jsx(Bn,{id:`field-${M}`,type:"number",value:p[M]||"",onChange:Z=>_(M,X==="integer"?parseInt(Z.target.value,10):parseFloat(Z.target.value)),placeholder:W.default?.toString()||""}):W.enum?f.jsxs("select",{id:`field-${M}`,value:p[M]||"",onChange:Z=>_(M,Z.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:[f.jsx("option",{value:"",children:"Select..."}),W.enum.map(Z=>f.jsx("option",{value:Z,children:Z},Z))]}):X==="string"&&(W.format==="textarea"||W.maxLength>100)?f.jsx(hc,{id:`field-${M}`,value:p[M]||"",onChange:Z=>_(M,Z.target.value),placeholder:W.default||"",rows:4}):f.jsx(Bn,{id:`field-${M}`,type:"text",value:p[M]||"",onChange:Z=>_(M,Z.target.value),placeholder:W.default||""})]},M)})})},[e,p,x]);return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx(Lr,{variant:"outline",className:S?"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:v}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0",children:o?f.jsx(ba,{className:"h-4 w-4 text-green-600"}):f.jsx(Zr,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Copy request"})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(nh,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Download request"})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(gC,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Fullscreen"})]}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(po,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),f.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),S&&"url"in e.request&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),f.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[f.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),f.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[f.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),f.jsxs(Fe,{size:"sm",variant:"outline",onClick:R,className:"flex items-center gap-2",children:[f.jsx(Y_,{className:"h-4 w-4"}),"Open URL"]})]}),f.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[f.jsx(Tm,{id:"url-completed",checked:g,onCheckedChange:N=>b(!!N)}),f.jsx(pn,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),x&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),A]}),x&&"requestedSchema"in e.request&&e.request.requestedSchema&&f.jsxs("details",{className:"space-y-2",children:[f.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(fr,{data:e.request.requestedSchema})})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(Fe,{onClick:E,className:"flex-1",children:"Accept"}),f.jsx(Fe,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),f.jsx(Fe,{onClick:C,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function mAe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:a}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:o}=kc(),[l,u]=y.useState(null),[d,p]=y.useState(""),[h,g]=y.useState(-1),[b,v]=y.useState(!0),[x,S]=y.useState(!1),[_,E]=y.useState(!0),[k,C]=y.useState(!1),R=y.useRef(null),A=y.useRef(null),N=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:l?.id}),i&&e.length>0){const H=e.find(Z=>Z.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!H,H?.id),H&&(console.log("[ElicitationTab] Auto-selecting request:",H.id),o(null),u(H),setTimeout(()=>{const Z=document.getElementById(`elicitation-request-${H.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Z),Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,o]),y.useEffect(()=>{const H=Z=>{const ae=Z.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",ae);const ne=e.find(L=>L.id===ae);ne&&(console.log("[ElicitationTab] Selecting request from event:",ae),u(ne),setTimeout(()=>{const L=document.getElementById(`elicitation-request-${ae}`);L&&L.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",H),()=>window.removeEventListener("navigate-to-elicitation",H)},[e]),y.useEffect(()=>{b&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,b]),y.useEffect(()=>{const H=R.current;if(!H)return;const Z=()=>{H.scrollTop>0&&(O.current=!0,v(!1))};return H.addEventListener("scroll",Z),()=>H.removeEventListener("scroll",Z)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,v(!0))},[e.length]),y.useEffect(()=>{x&&N.current&&N.current.focus()},[x]);const $=y.useCallback(()=>{d.trim()||S(!1)},[d]),M=y.useMemo(()=>{if(!d.trim())return e;const H=d.toLowerCase();return e.filter(Z=>Z.serverName.toLowerCase().includes(H)||Z.request.message.toLowerCase().includes(H)||JSON.stringify(Z.request||{}).toLowerCase().includes(H))},[e,d]);y.useEffect(()=>{g(-1)},[d]),y.useEffect(()=>{const H=Z=>{const G=Z.target;if(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const ne=M;if(Z.key==="ArrowDown")Z.preventDefault(),g(L=>{const V=L+1;return V>=ne.length?0:V});else if(Z.key==="ArrowUp")Z.preventDefault(),g(L=>{const V=L-1;return V<0?ne.length-1:V});else if(Z.key==="Enter"&&h>=0){Z.preventDefault();const L=M[h];L&&z(L)}};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[h,M]),y.useEffect(()=>{if(h>=0){const H=`elicitation-request-${M[h]?.id}`,Z=document.getElementById(H);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,M]);const z=y.useCallback(H=>{u(H)},[]),W=y.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(H=>{n(H.id,"User cancelled all requests")}),u(null))},[e,n]),J=y.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),C(!0),setTimeout(()=>C(!1),2e3)}catch(H){console.error("[ElicitationTab] Failed to copy request:",H)}},[l]),X=y.useCallback(()=>{if(l)try{const H=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:"application/json"}),Z=URL.createObjectURL(H),G=document.createElement("a");G.href=Z,G.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(Z)}catch(H){console.error("[ElicitationTab] Failed to download request:",H)}},[l]),re=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(H){console.error("[ElicitationTab] Failed to toggle fullscreen:",H)}},[]);return a?f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:40,minSize:30,children:f.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Gn,{defaultSize:75,minSize:30,children:[f.jsx(dAe,{isSearchExpanded:x,searchQuery:d,filteredRequestsCount:M.length,requestsCount:e.length,onSearchExpand:()=>S(!0),onSearchChange:p,onSearchBlur:$,onCancelAll:W,searchInputRef:N}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(fAe,{requests:M,selectedRequest:l,onRequestSelect:z,focusedIndex:h,formatRelativeTime:Cy,listRef:R})})]})})}),f.jsx(Mi,{}),f.jsx(Gn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(pAe,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:_,onTogglePreview:()=>E(!_),isCopied:k,onCopy:J,onDownload:X,onFullscreen:re})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(P7,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function hAe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:a,children:i}){return e?f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:f.jsx(GX,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:f.jsx(FX,{ref:r,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:f.jsx(HX,{ref:a,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:f.jsx(bCe,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),f.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:f.jsx(uAe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),f.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:f.jsx(mAe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:f.jsx(YCe,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state==="ready"})}),t!=="tools"&&t!=="prompts"&&t!=="resources"&&t!=="chat"&&t!=="sampling"&&t!=="elicitation"&&t!=="notifications"&&f.jsx(f.Fragment,{children:i})]}):f.jsx(f.Fragment,{children:i})}function M3({className:e}){return f.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentcolor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[f.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),f.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const WX=y.createContext(void 0);function KX(){const e=y.use(WX);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const ZX=y.createContext(void 0);function gAe(){return y.use(ZX)}function nT({ref:e,children:t,defaultValue:n,value:r,onValueChange:a,className:i,collapsed:o,onCollapsedChange:l,...u}){const[d,p]=y.useState(n||""),h=r!==void 0,g=o!==void 0,[b,v]=y.useState(!1),x=y.useCallback(k=>{h||p(k),a?.(k)},[h,a]),S=h?r:d,_=g?o:b,E=y.useCallback(k=>{g||v(k),l?.(k)},[g,l]);return f.jsx(WX,{value:{activeValue:S,handleValueChange:x,collapsed:_,handleCollapsedChange:E},children:f.jsx("div",{ref:e,className:Ue("flex flex-col gap-2",i),...u,children:t})})}nT.displayName="Tabs";function rT({ref:e,children:t,className:n,variant:r="default",collapsible:a=!1,...i}){const{activeValue:o,collapsed:l,handleCollapsedChange:u}=KX(),[d,p]=y.useState({width:0,left:0}),h=y.useRef(null),g=y.useRef(null),b=y.useRef(null),v=y.useCallback(()=>{const _=h.current;if(!_)return;const E=_.querySelector("div:first-child");if(!E)return;const k=E.querySelector(`button[data-tab-value="${o}"]`);if(k&&o){const C=E.getBoundingClientRect(),R=k.getBoundingClientRect();p({width:R.width,left:R.left-C.left})}else p({width:0,left:0})},[o]),x=y.useCallback(()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(v,16)},[v]);y.useEffect(()=>{const _=setTimeout(v,10);return()=>clearTimeout(_)},[v,l]),y.useEffect(()=>{const _=h.current;if(!_)return;g.current=new ResizeObserver(()=>{x()}),g.current.observe(_);const E=_.querySelector("div:first-child");return E&&E.querySelectorAll("button[data-tab-value]").forEach(C=>{g.current&&g.current.observe(C)}),()=>{g.current&&g.current.disconnect(),b.current&&clearTimeout(b.current)}},[x]),y.useEffect(()=>{const _=()=>{x()};return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[x]);const S=y.useRef(null);return y.useEffect(()=>{S.current&&(S.current.style.width=`${d.width}px`,S.current.style.left=`${d.left}px`)},[d]),f.jsx(ZX,{value:{variant:r,collapsed:l,handleCollapsedChange:u},children:f.jsx("div",{ref:h,className:Ue("relative flex items-center bg-none gap-1",r==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",r==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...i,children:f.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,f.jsx("span",{ref:S,className:Ue("absolute transition-all duration-500 ease-in-out z-0",r==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",r==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}rT.displayName="TabsList";const bAe=({children:e,title:t,collapsed:n})=>!t||!n?e:f.jsx(dC,{children:f.jsxs(Zt,{children:[f.jsx(Yt,{children:e}),f.jsx(qt,{children:t})]})}),aT=y.forwardRef(({children:e,value:t,className:n,disabled:r,icon:a,title:i,...o},l)=>{const{activeValue:u,handleValueChange:d,collapsed:p}=KX(),g=gAe()?.variant||"default",b=u===t,v=p&&i?i:void 0;return f.jsx(bAe,{title:i,collapsed:p,children:f.jsxs("button",{ref:l,disabled:r,onClick:()=>d(t),"data-tab-value":t,"data-tab-active":b,role:"tab","aria-selected":b?"true":"false",title:v,className:Ue("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",b&&"text-foreground",!b&&"text-muted-foreground hover:text-foreground",n),...o,children:[a&&f.jsx(a,{className:Ue("h-4 w-4 transition-all duration-500 ease-in-out",!p&&"mr-2",p&&"mr-0!")}),f.jsx("span",{className:Ue("transition-all duration-500 ease-in-out overflow-hidden",p?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});aT.displayName="TabsTrigger";function P3({className:e}){const{theme:t,setTheme:n}=n0(),r=y.useRef(null),[a,i]=y.useState(!1);y.useEffect(()=>{i(!0)},[]);const o=()=>t==="system"?"light":t==="light"?"dark":"system",l=()=>t==="system"?f.jsx(H4,{className:"size-4"}):t==="light"?f.jsx(mye,{className:"size-5"}):f.jsx(Kve,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",d=async()=>{if(!r.current)return;const p=o();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{Jd.flushSync(()=>{n(p)})}).ready;const{top:h,left:g,width:b,height:v}=r.current.getBoundingClientRect(),x=h+v/2,S=g+b/2,_=window.innerWidth-g,E=window.innerHeight-h,k=Math.hypot(Math.max(g,_),Math.max(h,E));document.documentElement.animate({clipPath:[`circle(0px at ${S}px ${x}px)`,`circle(${k}px at ${S}px ${x}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(p)};return a?f.jsx("button",{ref:r,onClick:d,className:Ue(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:l()}):f.jsx("button",{ref:r,className:Ue(e),"aria-label":"Toggle theme",children:f.jsx(H4,{className:"size-4"})})}function U3({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[r,a]=y.useState(!1),i=.2,o=.7,l=.6,u=4,d=i+o+l,p=0,h=i/d,g=(i+o)/d,b=1;return f.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Ue("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[f.jsx("div",{className:"relative",children:f.jsxs(Ia.svg,{viewBox:"0 0 303 303",initial:"rest",animate:r?"hover":"rest",className:Ue("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[f.jsxs(Ia.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:d,times:[p,h,g,b],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx("path",{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z"}),f.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),f.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),f.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx(vAe,{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:p,T1:h,T2:g,T3:b},total:d}),f.jsx(z3,{cx:70.3,cy:232.3,r:50,times:{T0:p,T1:h,T2:g,T3:b},total:d}),f.jsx(z3,{cx:232.3,cy:70.3,r:50,times:{T0:p,T1:h,T2:g,T3:b},total:d})]})]})}),t==="expanded"&&f.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",children:[f.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),f.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function vAe({d:e,times:t,total:n}){const{T0:r,T1:a,T2:i,T3:o}=t;return f.jsx(Ia.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,a,i,o],ease:"easeInOut"}}}})}function z3({cx:e,cy:t,r:n,times:r,total:a}){const{T0:i,T1:o,T2:l,T3:u}=r;return f.jsx(Ia.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:a,times:[i,o,l,u],ease:"easeInOut"}}}})}function YX({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:r="3s",borderRadius:a="100px",background:i,className:o,children:l,...u}){const{resolvedTheme:d}=n0(),p=d==="dark"?"#000000":"#ffffff",h=d==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||p,b=i||h;return f.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":a,"--speed":r,"--cut":n,"--bg":b},className:Ue("group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]","transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",d==="dark"?"border-black/10 text-black":"border-white/10 text-white",o),ref:e,...u,children:[f.jsx("div",{className:Ue("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:f.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:f.jsx("div",{className:"animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]"})})}),l,f.jsx("div",{className:Ue("absolute inset-0 size-full","rounded-2xl px-4 py-1.5 text-sm font-medium","transform-gpu transition-all duration-300 ease-in-out",d==="dark"?"shadow-[inset_0_-8px_10px_#0000001f] group-hover:shadow-[inset_0_-6px_10px_#0000003f] group-active:shadow-[inset_0_-10px_10px_#0000003f]":"shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]")}),f.jsx("div",{className:Ue("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}YX.displayName="ShimmerButton";function F3({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:r,tooltip:a}=t(e);return f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:`absolute w-2 h-2 rounded-full ${r} animate-ping`}),f.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),f.jsx(qt,{children:f.jsx("p",{children:a})})]})}function B3({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:r,mobileMode:a=!1}){const i=cl(),o=l=>{const u=e.find(d=>d.id===l);if(!u||u.state!=="ready"){vn.error("Server is not connected and cannot be inspected");return}n(l)};return a?f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(V_,{children:[f.jsx(G_,{asChild:!0,children:f.jsxs(Fe,{variant:"ghost",className:"h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5",children:[t?f.jsx(Yl,{serverUrl:t.url,serverName:t.name,size:"md"}):f.jsx(aye,{className:"h-5 w-5"}),f.jsx(_c,{className:"h-4 w-4"})]})}),f.jsxs(Qv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(W_,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Tp,{}),e.length===0?f.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(l=>f.jsxs(Vo,{onClick:()=>o(l.id),className:"flex items-center gap-3",children:[f.jsx(Yl,{serverUrl:l.url,serverName:l.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:l.name}),f.jsx(F3,{status:l.state})]}),f.jsx(Fe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),r(l.id)},children:f.jsx(qu,{className:"h-3 w-3"})})]},l.id)),f.jsx(Tp,{}),f.jsx(Vo,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(V_,{children:[f.jsx(G_,{asChild:!0,children:f.jsxs(YX,{className:Ue("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-10"),children:[t&&f.jsx(Yl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&f.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx("button",{onClick:l=>{l.stopPropagation()},className:"w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors",title:"Click to copy error message","aria-label":"Copy error message to clipboard"})}),f.jsx(qt,{children:f.jsx("p",{className:"max-w-xs",children:t.error})})]}):f.jsx("div",{className:`w-2 h-2 rounded-full ${t.state==="ready"?"bg-emerald-600 animate-status-pulse":t.state==="failed"?"bg-rose-600 animate-status-pulse-red":"bg-yellow-500 animate-status-pulse-yellow"}`})})]})]})}),t&&f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx("button",{type:"button",onClick:()=>{r(t.id)},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"Edit connection settings",children:f.jsx(qu,{className:"h-4 w-4"})})}),f.jsx(qt,{children:f.jsx("p",{children:"Edit connection settings"})})]}),f.jsxs(Qv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(W_,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Tp,{}),e.length===0?f.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(l=>f.jsxs(Vo,{onClick:()=>o(l.id),className:"flex items-center gap-3",children:[f.jsx(Yl,{serverUrl:l.url,serverName:l.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:l.name}),f.jsx(F3,{status:l.state})]}),f.jsx(Fe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),r(l.id)},children:f.jsx(qu,{className:"h-3 w-3"})})]},l.id)),f.jsx(Tp,{}),f.jsx(Vo,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const H3=[{id:"tools",label:"Tools",icon:uc},{id:"prompts",label:"Prompts",icon:fm},{id:"resources",label:"Resources",icon:Cve},{id:"sampling",label:"Sampling",icon:L7},{id:"elicitation",label:"Elicitation",icon:P7},{id:"notifications",label:"Notifications",icon:pC},{id:"chat",label:"Chat",icon:Fve}];function V3(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 yAe({collapsed:e,onToggle:t}){return f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx("button",{onClick:t,className:Ue("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?f.jsx(O7,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):f.jsx(Cw,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),f.jsx(qt,{children:f.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function wAe({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:a,onCommandPaletteOpen:i,onOpenConnectionOptions:o}){const{tunnelUrl:l}=kc(),u=t&&l,[d,p]=y.useState(!1),[h,g]=y.useState(!1),b=async()=>{if(l)try{await navigator.clipboard.writeText(`${l}/mcp`),p(!0),vn.success("Tunnel URL copied to clipboard"),setTimeout(()=>p(!1),2e3)}catch{vn.error("Failed to copy URL")}};return f.jsxs("header",{className:"w-full mx-auto",children:[f.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center justify-between w-full",children:[f.jsx("div",{className:"flex-1 flex justify-start",children:f.jsx(B3,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:o,mobileMode:!0})}),f.jsx("div",{className:"flex-shrink-0 flex justify-center",children:f.jsx("div",{className:"scale-150",children:f.jsx(U3,{state:"collapsed"})})}),f.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:f.jsx(M3,{className:"h-4 w-4"})})})}),f.jsx(qt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(P3,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&f.jsx("div",{className:"w-full",children:f.jsx(nT,{value:n,onValueChange:v=>a(v),collapsed:h,onCollapsedChange:g,children:f.jsx(rT,{className:"w-full justify-center",children:H3.map(v=>{const x=V3(v.id,t);return f.jsxs(aT,{value:v.id,icon:v.icon,className:Ue("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",h&&"pl-2"),children:[x>0&&f.jsx("span",{className:Ue(n===v.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:x}),f.jsx("span",{className:"sr-only",children:v.label})]},v.id)})})})})]}),f.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[f.jsx(B3,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:o}),t&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(nT,{value:n,onValueChange:v=>a(v),collapsed:h,onCollapsedChange:g,children:f.jsx(rT,{className:"overflow-x-auto",collapsible:!0,children:H3.map(v=>{const x=V3(v.id,t),S=x>0?`${v.label} (${x})`:v.label;return f.jsx(aT,{value:v.id,icon:v.icon,className:Ue("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",h&&"pl-4"),title:S,children:f.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[v.label,x>0&&f.jsx("span",{className:Ue(n===v.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:x})]})})})})}),f.jsx(yAe,{collapsed:h,onToggle:()=>g(!h)})]}),u&&f.jsxs(BY,{children:[f.jsx(HY,{asChild:!0,children:f.jsxs("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-500/10 to-pink-500/10 dark:from-purple-500/20 dark:to-pink-500/20 border border-purple-500/30 dark:border-purple-500/40 rounded-full hover:from-purple-500/20 hover:to-pink-500/20 dark:hover:from-purple-500/30 dark:hover:to-pink-500/30 transition-colors cursor-pointer",children:[f.jsx(pm,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),f.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),f.jsx(uA,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[f.jsx(pm,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),f.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[f.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[l,"/mcp"]}),f.jsx(Fe,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:b,children:d?f.jsx(ba,{className:"size-3.5 text-green-600"}):f.jsx(Zr,{className:"size-3.5"})})]})]}),f.jsxs("div",{children:[f.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),f.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"1."}),f.jsxs("span",{children:["Enable"," ",f.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"2."}),f.jsxs("span",{children:["In"," ",f.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",f.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"3."}),f.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),f.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{children:f.jsx(P3,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),f.jsx(qt,{children:f.jsx("p",{children:"Toggle theme"})})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsxs(Fe,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[f.jsx(fve,{className:"size-4"}),f.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),f.jsx(qt,{children:f.jsx("p",{children:"Command Palette"})})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[f.jsx(M3,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),f.jsx(qt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(U3,{state:"expanded"})]})]})]})}function SAe({children:e}){const t=cl(),n=ya(),{connections:r,addConnection:a,removeConnection:i,updateConnectionConfig:o,configLoaded:l}=fC(),{selectedServerId:u,setSelectedServerId:d,activeTab:p,setActiveTab:h,navigateToItem:g,setTunnelUrl:b}=kc(),[v,x]=y.useState(!1),[S,_]=y.useState(null),E=L_e();y.useEffect(()=>{const Z=new URLSearchParams(n.search).get("tunnelUrl");b(Z)},[n.search,b]),y.useEffect(()=>{const H=ae=>{const L=ae.detail.requestId;u&&g(u,"sampling",L)},Z=ae=>{const L=ae.detail.requestId;u&&g(u,"elicitation",L)},G=ae=>{const L=ae.detail.toolName;u&&L?g(u,"tools",L):u&&h("tools")};return window.addEventListener("navigate-to-sampling",H),window.addEventListener("navigate-to-elicitation",Z),window.addEventListener("navigate-to-tool-result",G),()=>{window.removeEventListener("navigate-to-sampling",H),window.removeEventListener("navigate-to-elicitation",Z),window.removeEventListener("navigate-to-tool-result",G)}},[u,h,g]);const k=y.useRef(null),C=y.useRef(null),R=y.useRef(null),{isAutoConnecting:A}=D_e({connections:r,addConnection:a,removeConnection:i,configLoaded:l}),N=y.useCallback(H=>{Or.getInstance().capture(new Cbe({trigger:H})).catch(()=>{}),x(!0)},[]),O=H=>{const Z=r.find(L=>L.id===H);if(!Z||Z.state!=="ready"){vn.error("Server is not connected and cannot be inspected");return}d(H);const ae=new URLSearchParams(n.search).get("tunnelUrl"),ne=ae?`/?server=${encodeURIComponent(H)}&tunnelUrl=${encodeURIComponent(ae)}`:`/?server=${encodeURIComponent(H)}`;t(ne)},$=y.useCallback(H=>{_(H)},[]),M=y.useCallback(H=>{S&&(H.url!==S?(i(S),a(H.url,H.name,H.proxyConfig,H.transportType)):o(S,{name:H.name,proxyConfig:H.proxyConfig,transportType:H.transportType}),_(null),vn.success("Connection settings updated"))},[S,i,a,o]),z=(H,Z,G)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:H,itemName:Z,serverId:G}),G){const ae=r.find(F=>F.id===G);if(console.warn("[Layout] Server lookup:",{serverId:G,serverFound:!!ae,serverState:ae?.state}),!ae||ae.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),vn.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:G,tab:H,itemName:Z}),g(G,H,Z);const L=new URLSearchParams(n.search).get("tunnelUrl"),V=L?`/?server=${encodeURIComponent(G)}&tunnelUrl=${encodeURIComponent(L)}`:`/?server=${encodeURIComponent(G)}`;console.warn("[Layout] Navigating to:",V),t(V)}else console.warn("[Layout] No serverId, just updating tab to:",H),h(H)},W=r.find(H=>H.id===u),J=W?W.tools.map(H=>({...H,_serverId:W.id})):r.flatMap(H=>H.state==="ready"?H.tools.map(Z=>({...Z,_serverId:H.id,_serverName:H.name})):[]),X=W?W.prompts.map(H=>({...H,_serverId:W.id})):r.flatMap(H=>H.state==="ready"?H.prompts.map(Z=>({...Z,_serverId:H.id,_serverName:H.name})):[]),re=W?W.resources.map(H=>({...H,_serverId:W.id})):r.flatMap(H=>H.state==="ready"?H.resources.map(Z=>({...Z,_serverId:H.id,_serverName:H.name})):[]);return y.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server"),G=Z?decodeURIComponent(Z):null;G!==u&&d(G)},[n.search,u,d]),y.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server");if(!Z)return;const G=decodeURIComponent(Z),ae=r.find(ne=>ne.id===G);if(!ae){const ne=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(ne)}if(ae.state==="failed"){const ne=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(ne)}},[n.search,t,r]),gY({onCommandPalette:()=>N("keyboard"),onToolsTab:()=>{W&&h("tools")},onPromptsTab:()=>{W&&h("prompts")},onResourcesTab:()=>{W&&h("resources")},onChatTab:()=>{W&&h("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{p==="tools"&&k.current?k.current.focusSearch():p==="prompts"&&C.current?C.current.focusSearch():p==="resources"&&R.current&&R.current.focusSearch()},onBlurSearch:()=>{p==="tools"&&k.current?k.current.blurSearch():p==="prompts"&&C.current?C.current.blurSearch():p==="resources"&&R.current&&R.current.blurSearch()}}),A?f.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Fi,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})}):f.jsx(dC,{children:f.jsxs("div",{className:"h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-2 py-2 sm:px-4 sm:py-4 gap-2 sm:gap-4",children:[f.jsx(wAe,{connections:r,selectedServer:W,activeTab:p,onServerSelect:O,onTabChange:h,onCommandPaletteOpen:()=>N("button"),onOpenConnectionOptions:$}),f.jsx("main",{className:"flex-1 w-full mx-auto bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 p-0 overflow-auto",children:f.jsx(hAe,{selectedServer:W,activeTab:p,toolsSearchRef:k,promptsSearchRef:C,resourcesSearchRef:R,children:e})}),f.jsx(ske,{isOpen:v,onOpenChange:x,tools:J,prompts:X,resources:re,savedRequests:E,connections:r,onNavigate:z,onServerSelect:O}),f.jsx(DK,{connection:S&&r.find(H=>H.id===S)||null,open:S!==null,onOpenChange:H=>{H||_(null)},onConnect:M})]})})}function xAe(){const[e,t]=y.useState("processing"),[n,r]=y.useState("");return y.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),hR().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(a=>{console.error("[OAuthCallback] Authorization failed:",a),t("error"),r(a instanceof Error?a.message:String(a))})},[]),e==="processing"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(el,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),f.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var EAe=(e,t,n,r,a,i,o,l)=>{let u=document.documentElement,d=["light","dark"];function p(b){(Array.isArray(e)?e:[e]).forEach(v=>{let x=v==="class",S=x&&i?a.map(_=>i[_]||_):a;x?(u.classList.remove(...S),u.classList.add(i&&i[b]?i[b]:b)):u.setAttribute(v,b)}),h(b)}function h(b){l&&d.includes(b)&&(u.style.colorScheme=b)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)p(r);else try{let b=localStorage.getItem(t)||n,v=o&&b==="system"?g():b;p(v)}catch{}},_Ae=y.createContext(void 0),kAe={setTheme:e=>{},themes:[]},TAe=()=>{var e;return(e=y.useContext(_Ae))!=null?e:kAe};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:a,defaultTheme:i,value:o,themes:l,nonce:u,scriptProps:d})=>{let p=JSON.stringify([n,t,i,e,l,o,r,a]).slice(1,-1);return y.createElement("script",{...d,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${EAe.toString()})(${p})`}})});function NAe({...e}){const{theme:t="system"}=TAe();return f.jsx(U7,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function RAe(){return f.jsx(qNe,{children:f.jsx($be,{children:f.jsxs(O_e,{children:[f.jsx(Nde,{basename:"/inspector",children:f.jsxs(wue,{children:[f.jsx(T_,{path:"/oauth/callback",element:f.jsx(xAe,{})}),f.jsx(T_,{path:"/",element:f.jsx(SAe,{children:f.jsx(I_e,{})})})]})}),f.jsx(NAe,{position:"top-center"})]})})})}const G3=new URLSearchParams(window.location.search);if(G3.has("code")||G3.has("error"))try{hR()}catch(e){console.error("[inspector] OAuth callback error:",e)}const W3=document.getElementById("root");W3?tce.createRoot(W3).render(f.jsx(RAe,{})):console.error("[inspector] Root element not found");export{dG as $,O_ as A,DAe as B,LAe as C,vR as D,so as E,uw as F,ga as G,hde as H,Yz as I,Ql as J,Zce as K,Jr as L,Mce as M,Hue as N,ZAe as O,aIe as P,Y8 as Q,dIe as R,SIe as S,YAe as T,Nde as U,fG as V,mIe as W,Hl as X,yR as Y,ev as Z,Ye as _,pr as a,AR as a$,cIe as a0,WAe as a1,uIe as a2,Cde as a3,KAe as a4,ace as a5,oG as a6,T_ as a7,Sc as a8,wue as a9,IAe as aA,pIe as aB,aa as aC,Bv as aD,qAe as aE,N_ as aF,xIe as aG,Rce as aH,OAe as aI,am as aJ,wi as aK,XAe as aL,Ece as aM,Rde as aN,yIe as aO,HAe as aP,IR as aQ,BAe as aR,pue as aS,vIe as aT,hue as aU,gIe as aV,bIe as aW,Lde as aX,nue as aY,wc as aZ,Ide as a_,Ede as aa,Ade as ab,wIe as ac,$Ae as ad,as as ae,ll as af,sw as ag,Kd as ah,Ya as ai,qa as aj,ow as ak,JAe as al,nIe as am,eIe as an,q9 as ao,PR as ap,oIe as aq,wR as ar,sIe as as,iIe as at,DR as au,St as av,Km as aw,lIe as ax,jde as ay,fIe as az,EIe as b,ya as b0,PAe as b1,CR as b2,cl as b3,fue as b4,MAe as b5,aue as b6,UAe as b7,kR as b8,Wm as b9,iV as bA,Gy as bB,uV as bC,Qt as bD,AT as bE,aB as bF,_ee as bG,Qb as bH,q3 as bI,Ule as bJ,fee as bK,hR as bL,Tee as bM,Li as bN,GE as bO,vi as bP,SH as bQ,d5 as bR,R5 as bS,gB as bT,yB as bU,wH as bV,u5 as bW,zAe as ba,FAe as bb,iue as bc,hIe as bd,mG as be,Mde as bf,Ay as bg,zH as bh,VE as bi,joe as bj,Yb as bk,jle as bl,Sv as bm,Qi as bn,Ce as bo,Lle as bp,Ple as bq,dz as br,Us as bs,$le as bt,kae as bu,ZE as bv,Sae as bw,Yae as bx,$N as by,oV as bz,lde as c,Vue as d,de as e,Ou as f,AAe as g,sc as h,VAe as i,GAe as j,eue as k,Bue as l,Ai as m,hi as n,$ce as o,NB as p,jAe as q,y as r,dde as s,rIe as t,OR as u,tIe as v,k_ as w,QAe as x,Gd as y,Que as z};
|
|
1707
|
+
`),Ve.document.close())}},[v]),mr=y.useCallback(()=>{K?(oe.current&&oe.current.expand(),Ae.current&&Ae.current.expand(),ee(!1)):(oe.current&&oe.current.collapse(),Ae.current&&Ae.current.collapse(),ee(!0))},[K]),Ut=y.useCallback(()=>{o&&(re(""),J(!0))},[o]),He=y.useCallback(()=>{if(!o)return;const Te={id:`${Date.now()}-${Math.random()}`,name:X.trim()||`${o.name} - ${new Date().toLocaleString()}`,toolName:o.name,args:g,savedAt:Date.now(),serverId:o._serverId,serverName:o._serverName};Ze([...M,Te]),Or.getInstance().capture(new Abe({toolName:o.name,serverId:a})).catch(()=>{}),J(!1),re("")},[o,X,g,M,Ze,a]),Be=y.useCallback(Te=>{Ze(M.filter(Pe=>Pe.id!==Te)),u?.id===Te&&d(null)},[M,Ze,u]);return F?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[P!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Fe,{variant:"ghost",size:"sm",onClick:()=>{P==="response"?B("detail"):(l(null),B("list"))},className:"p-0 h-8 w-8",children:f.jsx(Cw,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{l(null),B("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),P==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{B("response")},className:P==="detail"?"text-foreground hover:underline":P==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),P==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($w,{initial:!1,mode:"popLayout",children:[P==="list"&&f.jsxs(Ia.div,{initial:{x:"-100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 flex flex-col bg-background z-0",children:[f.jsx(j3,{activeTab:O,isSearchExpanded:G,searchQuery:A,filteredToolsCount:me.length,savedRequestsCount:M.length,onSearchExpand:()=>ae(!0),onSearchChange:N,onSearchBlur:_e,onTabSwitch:()=>$(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(L3,{tools:me,selectedTool:o,onToolSelect:Le,focusedIndex:ne}):f.jsx(R3,{savedRequests:M,selectedRequest:u,onLoadRequest:Ke,onDeleteRequest:Be,focusedIndex:ne})]},"list"),P==="detail"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"-100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-10",children:f.jsx(I3,{selectedTool:o,toolArgs:g,isExecuting:S,isConnected:i,onArgChange:vt,onExecute:gt,onSave:Ut})},"detail"),P==="response"&&f.jsx(Ia.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-background z-20",children:f.jsx(D3,{results:At,copiedResult:E,previewMode:H,serverId:a,readResource:r,onCopy:wt,onDelete:Tt,onFullscreen:Cn,onTogglePreview:()=>Z(!H)})},"response")]})}),f.jsx(C3,{isOpen:W,requestName:X,defaultPlaceholder:`${o?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:re,onSave:He,onCancel:()=>J(!1)})]}):f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{ref:oe,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:f.jsxs(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Gn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(j3,{activeTab:O,isSearchExpanded:G,searchQuery:A,filteredToolsCount:me.length,savedRequestsCount:M.length,onSearchExpand:()=>ae(!0),onSearchChange:N,onSearchBlur:_e,onTabSwitch:()=>$(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(L3,{tools:me,selectedTool:o,onToolSelect:Le,focusedIndex:ne}):f.jsx(R3,{savedRequests:M,selectedRequest:u,onLoadRequest:Ke,onDeleteRequest:Be,focusedIndex:ne})]})}),f.jsx(Mi,{withHandle:!0}),f.jsxs(Gn,{ref:ke,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>{q(!0)},onExpand:()=>{q(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Te=>{Te.preventDefault(),Te.stopPropagation(),Q?(ke.current?.resize(25),q(!1)):(ke.current?.resize(5),q(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),ie>0&&f.jsx(Lr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:ie}),ie>0&&!Q&&f.jsx(Fe,{variant:"ghost",size:"sm",onClick:Te=>{Te.preventDefault(),Te.stopPropagation(),Re.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx(tl,{className:"h-3.5 w-3.5"})})]}),f.jsx(_c,{className:`h-4 w-4 text-muted-foreground transition-transform ${Q?"":"rotate-180"}`})]}),!Q&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(BL,{serverIds:[a],onCountChange:ue,onClearRef:Re})})]})]})}),f.jsx(Mi,{withHandle:!0}),f.jsx(Gn,{defaultSize:67,children:f.jsxs(ma,{direction:"vertical",children:[f.jsx(Gn,{ref:Ae,defaultSize:40,collapsible:!0,children:f.jsx(I3,{selectedTool:o,toolArgs:g,isExecuting:S,isConnected:i,onArgChange:vt,onExecute:gt,onSave:Ut,onCancel:()=>{C&&C.abort()}})}),f.jsx(Mi,{withHandle:!0}),f.jsx(Gn,{ref:Je,defaultSize:60,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(D3,{results:At,copiedResult:E,previewMode:H,serverId:a,readResource:r,onCopy:wt,onDelete:Tt,onFullscreen:Cn,onTogglePreview:()=>Z(!H),onMaximize:mr,isMaximized:K})})})]})}),f.jsx(C3,{isOpen:W,requestName:X,defaultPlaceholder:`${o?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:re,onSave:He,onCancel:()=>J(!1)})]})}GX.displayName="ToolsTab";function oAe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:i,onSearchBlur:o,onRejectAll:l,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(Bn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:o,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:f.jsx(tl,{className:"h-4 w-4"})})}),f.jsx(qt,{side:"bottom",children:"Reject all"})]})})]})}function sAe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((o,l)=>{const u=o.request.params?.messages?.length||0,d=o.request.params?.maxTokens;return f.jsx(hl,{id:`sampling-request-${o.id}`,isSelected:t?.id===o.id,isFocused:r===l,title:f.jsxs("span",{className:"flex items-center gap-3",children:[o.serverName,f.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const p=a(o.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),d&&h.push(`max ${d} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return p+g})(),onClick:()=>n(o)},o.id)})})}function lAe({llmConfig:e}){const t=y.useRef(null);return{generateResponse:y.useCallback(async({request:r})=>{if(!e)throw new Error("LLM config is not available");const a=r.params||{},i=a.maxTokens,o=a.temperature;a.modelPreferences;const l=a.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!a,messagesCount:l.length,messages:l,params:a}),l.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:d,AIMessage:p}=await pr(async()=>{const{HumanMessage:v,AIMessage:x}=await import("./index-BCGobKCz.js").then(S=>S.bD);return{HumanMessage:v,AIMessage:x}},[]);for(const v of l){if(!v||!v.role){console.warn("Skipping invalid message:",v);continue}const x=Array.isArray(v.content)?v.content[0]:v.content;if(!x){console.warn("Skipping message with no content:",v);continue}x.type==="text"&&x.text?v.role==="user"?u.push(new d(x.text)):v.role==="assistant"&&u.push(new p(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 v;const x={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(x.maxTokens=i),o!==void 0?x.temperature=o:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:S}=await pr(async()=>{const{ChatOpenAI:_}=await import("./index-BVRlDOe5.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,2,8,9]));v=new S(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:S}=await pr(async()=>{const{ChatAnthropic:_}=await import("./index-BKkxSJZC.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,2]));v=new S(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:S}=await pr(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-CVHM2qPt.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,2,9]));v=new S(x)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:v,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 cAe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:i,isCopied:o,onCopy:l,onDownload:u,onFullscreen:d,llmConfig:p}){const[h,g]=y.useState("manual"),[b,v]=y.useState("stub-model"),[x,S]=y.useState("endTurn"),[_,E]=y.useState("assistant"),[k,C]=y.useState("text"),[R,A]=y.useState("positive"),[N,O]=y.useState(""),[$,M]=y.useState("image/png"),[z,W]=y.useState(!1),[J,X]=y.useState(null),{generateResponse:re,isAvailable:H}=lAe({llmConfig:p});y.useEffect(()=>{e&&(v("stub-model"),S("endTurn"),E("assistant"),C("text"),A("positive"),O(""),M("image/png"),X(null))},[e?.id]);const Z=async()=>{if(!(!e||!H)){W(!0),X(null);try{const L=await re({request:e.request});v(L.model||p?.model||"stub-model"),S(L.stopReason||"endTurn"),E(L.role||"assistant");const V=Array.isArray(L.content)?L.content[0]:L.content;V.type==="text"?(C("text"),A(V.text||"")):V.type==="image"&&(C("image"),O(V.data||""),M(V.mimeType||"image/png"))}catch(L){const V=L instanceof Error?L.message:"Failed to generate response";X(V),vn.error("LLM Generation Failed",{description:V})}finally{W(!1)}}},G=y.useMemo(()=>{const L={model:b,stopReason:x,role:_,content:{type:k}};return k==="text"?L.content.text=R:k==="image"&&(L.content.data=N,L.content.mimeType=$),L},[b,x,_,k,R,N,$]),ae=()=>{if(!e)return;const L=oR.safeParse(G);if(!L.success){vn.error("Invalid response",{description:`Validation failed: ${L.error.message}`});return}t(e.id,L.data),r(),pr(()=>Promise.resolve().then(()=>Gd),void 0).then(V=>{const F=vn(V.createElement("div",{className:"space-y-3"},V.createElement("div",null,V.createElement("strong",null,"Sampling Response Sent"),V.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),V.createElement("div",{className:"flex gap-2"},V.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const j=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(j),vn.dismiss(F)}},"View Tool Result"))),{duration:5e3})})},ne=()=>{e&&(n(e.id,"User rejected sampling request"),r())};return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0",children:o?f.jsx(ba,{className:"h-4 w-4 text-green-600"}):f.jsx(Zr,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Copy request"})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(nh,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Download request"})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(gC,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Fullscreen"})]}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(po,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(fr,{data:e.request})})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(pn,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),f.jsxs(Go,{value:h,onValueChange:L=>g(L),children:[f.jsx(Ko,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:f.jsx(Wo,{})}),f.jsxs(Zo,{children:[f.jsx(Gr,{value:"manual",children:"Manual"}),f.jsx(Gr,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&f.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[H?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Fe,{onClick:Z,disabled:z,size:"sm",className:"flex items-center gap-2",children:z?f.jsxs(f.Fragment,{children:[f.jsx(el,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):f.jsxs(f.Fragment,{children:[f.jsx(cye,{className:"h-4 w-4"}),"Generate with LLM"]})}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",p?.provider," (",p?.model,")"]})]}):f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),J&&f.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:J})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`model-${e.id}`,children:"Model"}),f.jsx(Bn,{id:`model-${e.id}`,value:b,onChange:L=>v(L.target.value),placeholder:"stub-model",disabled:h==="llm"&&z})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),f.jsx(Bn,{id:`stopReason-${e.id}`,value:x,onChange:L=>S(L.target.value),placeholder:"endTurn",disabled:h==="llm"&&z})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`role-${e.id}`,children:"Role"}),f.jsxs(Go,{value:_,onValueChange:L=>E(L),disabled:h==="llm"&&z,children:[f.jsx(Ko,{id:`role-${e.id}`,children:f.jsx(Wo,{})}),f.jsxs(Zo,{children:[f.jsx(Gr,{value:"assistant",children:"assistant"}),f.jsx(Gr,{value:"user",children:"user"})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),f.jsxs(Go,{value:k,onValueChange:L=>C(L),disabled:h==="llm"&&z,children:[f.jsx(Ko,{id:`contentType-${e.id}`,children:f.jsx(Wo,{})}),f.jsxs(Zo,{children:[f.jsx(Gr,{value:"text",children:"text"}),f.jsx(Gr,{value:"image",children:"image"})]})]})]}),k==="text"&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`text-${e.id}`,children:"Text Content"}),f.jsx(hc,{id:`text-${e.id}`,value:R,onChange:L=>A(L.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&z})]}),k==="image"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),f.jsx(hc,{id:`imageData-${e.id}`,value:N,onChange:L=>O(L.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&z})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(pn,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),f.jsx(Bn,{id:`mimeType-${e.id}`,value:$,onChange:L=>M(L.target.value),placeholder:"image/png",disabled:h==="llm"&&z})]})]})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(Fe,{onClick:ae,className:"flex-1",disabled:h==="llm"&&z,children:"Approve"}),f.jsx(Fe,{onClick:ne,variant:"outline",className:"flex-1",disabled:h==="llm"&&z,children:"Reject"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}function uAe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:a,mcpServerUrl:i}){const{selectedSamplingRequestId:o,setSelectedSamplingRequestId:l}=kc(),{llmConfig:u}=vX({mcpServerUrl:i}),[d,p]=y.useState(null),[h,g]=y.useState(""),[b,v]=y.useState(-1),[x,S]=y.useState(!0),[_,E]=y.useState(!1),[k,C]=y.useState(!0),[R,A]=y.useState(!1),N=y.useRef(null),O=y.useRef(null),$=y.useRef(null),M=y.useRef(!1);y.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:o,pendingRequestsCount:e.length,currentSelectedId:d?.id}),o&&e.length>0){const G=e.find(ae=>ae.id===o);console.log("[SamplingTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[SamplingTab] Auto-selecting request:",G.id),l(null),p(G),setTimeout(()=>{const ae=document.getElementById(`sampling-request-${G.id}`);console.log("[SamplingTab] Scrolling to element:",!!ae),ae&&ae.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[o,e,l]),y.useEffect(()=>{const G=ae=>{const L=ae.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",L);const V=e.find(F=>F.id===L);V&&(console.log("[SamplingTab] Selecting request from event:",L),p(V),setTimeout(()=>{const F=document.getElementById(`sampling-request-${L}`);F&&F.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",G),()=>window.removeEventListener("navigate-to-sampling",G)},[e]),y.useEffect(()=>{x&&e.length>0&&N.current&&!M.current&&(N.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const G=N.current;if(!G)return;const ae=()=>{G.scrollTop>0&&(M.current=!0,S(!1))};return G.addEventListener("scroll",ae),()=>G.removeEventListener("scroll",ae)},[]),y.useEffect(()=>{e.length===0&&(M.current=!1,S(!0))},[e.length]),y.useEffect(()=>{_&&$.current&&$.current.focus()},[_]);const z=y.useCallback(()=>{h.trim()||E(!1)},[h]),W=y.useMemo(()=>{if(!h.trim())return e;const G=h.toLowerCase();return e.filter(ae=>ae.serverName.toLowerCase().includes(G)||JSON.stringify(ae.request||{}).toLowerCase().includes(G))},[e,h]);y.useEffect(()=>{v(-1)},[h]),y.useEffect(()=>{const G=ae=>{const ne=ae.target;if(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.contentEditable==="true"||ae.metaKey||ae.ctrlKey||ae.altKey)return;const V=W;if(ae.key==="ArrowDown")ae.preventDefault(),v(F=>{const j=F+1;return j>=V.length?0:j});else if(ae.key==="ArrowUp")ae.preventDefault(),v(F=>{const j=F-1;return j<0?V.length-1:j});else if(ae.key==="Enter"&&b>=0){ae.preventDefault();const F=W[b];F&&J(F)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[b,W]),y.useEffect(()=>{if(b>=0){const G=`sampling-request-${W[b]?.id}`,ae=document.getElementById(G);ae&&ae.scrollIntoView({behavior:"smooth",block:"nearest"})}},[b,W]);const J=y.useCallback(G=>{p(G)},[]),X=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(G=>{n(G.id,"User rejected all requests")}),p(null))},[e,n]),re=y.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(G){console.error("[SamplingTab] Failed to copy request:",G)}},[d]),H=y.useCallback(()=>{if(d)try{const G=new globalThis.Blob([JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)],{type:"application/json"}),ae=URL.createObjectURL(G),ne=document.createElement("a");ne.href=ae,ne.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(ae)}catch(G){console.error("[SamplingTab] Failed to download request:",G)}},[d]),Z=y.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(G){console.error("[SamplingTab] Failed to toggle fullscreen:",G)}},[]);return a?f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:40,minSize:30,children:f.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Gn,{defaultSize:75,minSize:30,children:[f.jsx(oAe,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:W.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:z,onRejectAll:X,searchInputRef:$}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(sAe,{requests:W,selectedRequest:d,onRequestSelect:J,focusedIndex:b,formatRelativeTime:Cy,listRef:N})})]})})}),f.jsx(Mi,{}),f.jsx(Gn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(cAe,{request:d,onApprove:t,onReject:n,onClose:()=>p(null),previewMode:k,onTogglePreview:()=>C(!k),isCopied:R,onCopy:re,onDownload:H,onFullscreen:Z,llmConfig:u})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(L7,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function dAe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:i,onSearchBlur:o,onCancelAll:l,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(Bn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:o,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),f.jsx(Lr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(af,{className:"h-4 w-4"})})}),f.jsxs(qt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(yh,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,disabled:r===0,className:"h-8 w-8 p-0",children:f.jsx(po,{className:"h-4 w-4"})})}),f.jsx(qt,{side:"bottom",children:"Cancel all"})]})})]})}function fAe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(rf,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((o,l)=>{const u=o.request.mode||"form",d=u==="form"&&"requestedSchema"in o.request&&o.request.requestedSchema;return f.jsx(hl,{id:`elicitation-request-${o.id}`,isSelected:t?.id===o.id,isFocused:r===l,title:f.jsxs("span",{className:"flex items-center gap-3",children:[o.serverName,f.jsx(Lr,{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 p=a(o.timestamp),h=[];d&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return p+g})(),onClick:()=>n(o)},o.id)})})}function pAe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:i,isCopied:o,onCopy:l,onDownload:u,onFullscreen:d}){const[p,h]=y.useState({}),[g,b]=y.useState(!1),v=e?.request.mode||"form",x=v==="form",S=v==="url";y.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const N=e.request.requestedSchema,O={};if(N?.type==="object"&&N.properties)for(const[$,M]of Object.entries(N.properties)){const z=M;z.default!==void 0?O[$]=z.default:z.type==="boolean"?O[$]=!1:z.type==="number"||z.type==="integer"?O[$]=0:O[$]=""}h(O)}b(!1)},[e?.id,x]);const _=(N,O)=>{h($=>({...$,[N]:O}))},E=()=>{if(e){if(x){if("requestedSchema"in e.request){const N=e.request.requestedSchema;if(N?.required){const O=N.required.filter($=>p[$]===void 0||p[$]===""||p[$]===null);if(O.length>0){vn.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:p})}else S&&t(e.id,{action:"accept"});r(),pr(()=>Promise.resolve().then(()=>Gd),void 0).then(N=>{const O=vn(N.createElement("div",{className:"space-y-3"},N.createElement("div",null,N.createElement("strong",null,"Elicitation Response Sent"),N.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),N.createElement("div",{className:"flex gap-2"},N.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 $=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent($),vn.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),r())},C=()=>{e&&(n(e.id,"User cancelled elicitation request"),r())},R=()=>{e&&S&&"url"in e.request&&(window.open(e.request.url,"_blank"),b(!0))},A=y.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const N=e.request.requestedSchema;if(!N||N.type!=="object"||!N.properties)return f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=N.properties,$=N.required||[];return f.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([M,z])=>{const W=z,J=$.includes(M),X=W.type||"string",re=W.title||M,H=W.description;return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(pn,{htmlFor:`field-${M}`,children:[re,J&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),H&&f.jsx("p",{className:"text-xs text-muted-foreground",children:H}),X==="boolean"?f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(Tm,{id:`field-${M}`,checked:p[M]||!1,onCheckedChange:Z=>_(M,Z)}),f.jsx(pn,{htmlFor:`field-${M}`,className:"text-sm font-normal cursor-pointer",children:W.title||M})]}):X==="number"||X==="integer"?f.jsx(Bn,{id:`field-${M}`,type:"number",value:p[M]||"",onChange:Z=>_(M,X==="integer"?parseInt(Z.target.value,10):parseFloat(Z.target.value)),placeholder:W.default?.toString()||""}):W.enum?f.jsxs("select",{id:`field-${M}`,value:p[M]||"",onChange:Z=>_(M,Z.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:[f.jsx("option",{value:"",children:"Select..."}),W.enum.map(Z=>f.jsx("option",{value:Z,children:Z},Z))]}):X==="string"&&(W.format==="textarea"||W.maxLength>100)?f.jsx(hc,{id:`field-${M}`,value:p[M]||"",onChange:Z=>_(M,Z.target.value),placeholder:W.default||"",rows:4}):f.jsx(Bn,{id:`field-${M}`,type:"text",value:p[M]||"",onChange:Z=>_(M,Z.target.value),placeholder:W.default||""})]},M)})})},[e,p,x]);return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx(Lr,{variant:"outline",className:S?"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:v}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:l,className:"h-8 w-8 p-0",children:o?f.jsx(ba,{className:"h-4 w-4 text-green-600"}):f.jsx(Zr,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Copy request"})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(nh,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Download request"})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(gC,{className:"h-4 w-4"})})}),f.jsx(qt,{children:"Fullscreen"})]}),f.jsx(Fe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(po,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),f.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),S&&"url"in e.request&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),f.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[f.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),f.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[f.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),f.jsxs(Fe,{size:"sm",variant:"outline",onClick:R,className:"flex items-center gap-2",children:[f.jsx(Y_,{className:"h-4 w-4"}),"Open URL"]})]}),f.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[f.jsx(Tm,{id:"url-completed",checked:g,onCheckedChange:N=>b(!!N)}),f.jsx(pn,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),x&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),A]}),x&&"requestedSchema"in e.request&&e.request.requestedSchema&&f.jsxs("details",{className:"space-y-2",children:[f.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(fr,{data:e.request.requestedSchema})})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(Fe,{onClick:E,className:"flex-1",children:"Accept"}),f.jsx(Fe,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),f.jsx(Fe,{onClick:C,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function mAe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:a}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:o}=kc(),[l,u]=y.useState(null),[d,p]=y.useState(""),[h,g]=y.useState(-1),[b,v]=y.useState(!0),[x,S]=y.useState(!1),[_,E]=y.useState(!0),[k,C]=y.useState(!1),R=y.useRef(null),A=y.useRef(null),N=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:l?.id}),i&&e.length>0){const H=e.find(Z=>Z.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!H,H?.id),H&&(console.log("[ElicitationTab] Auto-selecting request:",H.id),o(null),u(H),setTimeout(()=>{const Z=document.getElementById(`elicitation-request-${H.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Z),Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,o]),y.useEffect(()=>{const H=Z=>{const ae=Z.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",ae);const ne=e.find(L=>L.id===ae);ne&&(console.log("[ElicitationTab] Selecting request from event:",ae),u(ne),setTimeout(()=>{const L=document.getElementById(`elicitation-request-${ae}`);L&&L.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",H),()=>window.removeEventListener("navigate-to-elicitation",H)},[e]),y.useEffect(()=>{b&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,b]),y.useEffect(()=>{const H=R.current;if(!H)return;const Z=()=>{H.scrollTop>0&&(O.current=!0,v(!1))};return H.addEventListener("scroll",Z),()=>H.removeEventListener("scroll",Z)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,v(!0))},[e.length]),y.useEffect(()=>{x&&N.current&&N.current.focus()},[x]);const $=y.useCallback(()=>{d.trim()||S(!1)},[d]),M=y.useMemo(()=>{if(!d.trim())return e;const H=d.toLowerCase();return e.filter(Z=>Z.serverName.toLowerCase().includes(H)||Z.request.message.toLowerCase().includes(H)||JSON.stringify(Z.request||{}).toLowerCase().includes(H))},[e,d]);y.useEffect(()=>{g(-1)},[d]),y.useEffect(()=>{const H=Z=>{const G=Z.target;if(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const ne=M;if(Z.key==="ArrowDown")Z.preventDefault(),g(L=>{const V=L+1;return V>=ne.length?0:V});else if(Z.key==="ArrowUp")Z.preventDefault(),g(L=>{const V=L-1;return V<0?ne.length-1:V});else if(Z.key==="Enter"&&h>=0){Z.preventDefault();const L=M[h];L&&z(L)}};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[h,M]),y.useEffect(()=>{if(h>=0){const H=`elicitation-request-${M[h]?.id}`,Z=document.getElementById(H);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,M]);const z=y.useCallback(H=>{u(H)},[]),W=y.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(H=>{n(H.id,"User cancelled all requests")}),u(null))},[e,n]),J=y.useCallback(async()=>{if(l)try{await navigator.clipboard.writeText(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),C(!0),setTimeout(()=>C(!1),2e3)}catch(H){console.error("[ElicitationTab] Failed to copy request:",H)}},[l]),X=y.useCallback(()=>{if(l)try{const H=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:"application/json"}),Z=URL.createObjectURL(H),G=document.createElement("a");G.href=Z,G.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(Z)}catch(H){console.error("[ElicitationTab] Failed to download request:",H)}},[l]),re=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(H){console.error("[ElicitationTab] Failed to toggle fullscreen:",H)}},[]);return a?f.jsxs(ma,{direction:"horizontal",className:"h-full",children:[f.jsx(Gn,{defaultSize:40,minSize:30,children:f.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Gn,{defaultSize:75,minSize:30,children:[f.jsx(dAe,{isSearchExpanded:x,searchQuery:d,filteredRequestsCount:M.length,requestsCount:e.length,onSearchExpand:()=>S(!0),onSearchChange:p,onSearchBlur:$,onCancelAll:W,searchInputRef:N}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(fAe,{requests:M,selectedRequest:l,onRequestSelect:z,focusedIndex:h,formatRelativeTime:Cy,listRef:R})})]})})}),f.jsx(Mi,{}),f.jsx(Gn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(pAe,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:_,onTogglePreview:()=>E(!_),isCopied:k,onCopy:J,onDownload:X,onFullscreen:re})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(P7,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function hAe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:a,children:i}){return e?f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:f.jsx(GX,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:f.jsx(FX,{ref:r,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:f.jsx(HX,{ref:a,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:f.jsx(bCe,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),f.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:f.jsx(uAe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),f.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:f.jsx(mAe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:f.jsx(YCe,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state==="ready"})}),t!=="tools"&&t!=="prompts"&&t!=="resources"&&t!=="chat"&&t!=="sampling"&&t!=="elicitation"&&t!=="notifications"&&f.jsx(f.Fragment,{children:i})]}):f.jsx(f.Fragment,{children:i})}function M3({className:e}){return f.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentcolor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[f.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),f.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const WX=y.createContext(void 0);function KX(){const e=y.use(WX);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const ZX=y.createContext(void 0);function gAe(){return y.use(ZX)}function nT({ref:e,children:t,defaultValue:n,value:r,onValueChange:a,className:i,collapsed:o,onCollapsedChange:l,...u}){const[d,p]=y.useState(n||""),h=r!==void 0,g=o!==void 0,[b,v]=y.useState(!1),x=y.useCallback(k=>{h||p(k),a?.(k)},[h,a]),S=h?r:d,_=g?o:b,E=y.useCallback(k=>{g||v(k),l?.(k)},[g,l]);return f.jsx(WX,{value:{activeValue:S,handleValueChange:x,collapsed:_,handleCollapsedChange:E},children:f.jsx("div",{ref:e,className:Ue("flex flex-col gap-2",i),...u,children:t})})}nT.displayName="Tabs";function rT({ref:e,children:t,className:n,variant:r="default",collapsible:a=!1,...i}){const{activeValue:o,collapsed:l,handleCollapsedChange:u}=KX(),[d,p]=y.useState({width:0,left:0}),h=y.useRef(null),g=y.useRef(null),b=y.useRef(null),v=y.useCallback(()=>{const _=h.current;if(!_)return;const E=_.querySelector("div:first-child");if(!E)return;const k=E.querySelector(`button[data-tab-value="${o}"]`);if(k&&o){const C=E.getBoundingClientRect(),R=k.getBoundingClientRect();p({width:R.width,left:R.left-C.left})}else p({width:0,left:0})},[o]),x=y.useCallback(()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(v,16)},[v]);y.useEffect(()=>{const _=setTimeout(v,10);return()=>clearTimeout(_)},[v,l]),y.useEffect(()=>{const _=h.current;if(!_)return;g.current=new ResizeObserver(()=>{x()}),g.current.observe(_);const E=_.querySelector("div:first-child");return E&&E.querySelectorAll("button[data-tab-value]").forEach(C=>{g.current&&g.current.observe(C)}),()=>{g.current&&g.current.disconnect(),b.current&&clearTimeout(b.current)}},[x]),y.useEffect(()=>{const _=()=>{x()};return window.addEventListener("resize",_),()=>window.removeEventListener("resize",_)},[x]);const S=y.useRef(null);return y.useEffect(()=>{S.current&&(S.current.style.width=`${d.width}px`,S.current.style.left=`${d.left}px`)},[d]),f.jsx(ZX,{value:{variant:r,collapsed:l,handleCollapsedChange:u},children:f.jsx("div",{ref:h,className:Ue("relative flex items-center bg-none gap-1",r==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",r==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...i,children:f.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,f.jsx("span",{ref:S,className:Ue("absolute transition-all duration-500 ease-in-out z-0",r==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",r==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}rT.displayName="TabsList";const bAe=({children:e,title:t,collapsed:n})=>!t||!n?e:f.jsx(dC,{children:f.jsxs(Zt,{children:[f.jsx(Yt,{children:e}),f.jsx(qt,{children:t})]})}),aT=y.forwardRef(({children:e,value:t,className:n,disabled:r,icon:a,title:i,...o},l)=>{const{activeValue:u,handleValueChange:d,collapsed:p}=KX(),g=gAe()?.variant||"default",b=u===t,v=p&&i?i:void 0;return f.jsx(bAe,{title:i,collapsed:p,children:f.jsxs("button",{ref:l,disabled:r,onClick:()=>d(t),"data-tab-value":t,"data-tab-active":b,role:"tab","aria-selected":b?"true":"false",title:v,className:Ue("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",b&&"text-foreground",!b&&"text-muted-foreground hover:text-foreground",n),...o,children:[a&&f.jsx(a,{className:Ue("h-4 w-4 transition-all duration-500 ease-in-out",!p&&"mr-2",p&&"mr-0!")}),f.jsx("span",{className:Ue("transition-all duration-500 ease-in-out overflow-hidden",p?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});aT.displayName="TabsTrigger";function P3({className:e}){const{theme:t,setTheme:n}=n0(),r=y.useRef(null),[a,i]=y.useState(!1);y.useEffect(()=>{i(!0)},[]);const o=()=>t==="system"?"light":t==="light"?"dark":"system",l=()=>t==="system"?f.jsx(H4,{className:"size-4"}):t==="light"?f.jsx(mye,{className:"size-5"}):f.jsx(Kve,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",d=async()=>{if(!r.current)return;const p=o();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{Jd.flushSync(()=>{n(p)})}).ready;const{top:h,left:g,width:b,height:v}=r.current.getBoundingClientRect(),x=h+v/2,S=g+b/2,_=window.innerWidth-g,E=window.innerHeight-h,k=Math.hypot(Math.max(g,_),Math.max(h,E));document.documentElement.animate({clipPath:[`circle(0px at ${S}px ${x}px)`,`circle(${k}px at ${S}px ${x}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(p)};return a?f.jsx("button",{ref:r,onClick:d,className:Ue(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:l()}):f.jsx("button",{ref:r,className:Ue(e),"aria-label":"Toggle theme",children:f.jsx(H4,{className:"size-4"})})}function U3({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[r,a]=y.useState(!1),i=.2,o=.7,l=.6,u=4,d=i+o+l,p=0,h=i/d,g=(i+o)/d,b=1;return f.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Ue("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[f.jsx("div",{className:"relative",children:f.jsxs(Ia.svg,{viewBox:"0 0 303 303",initial:"rest",animate:r?"hover":"rest",className:Ue("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[f.jsxs(Ia.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:d,times:[p,h,g,b],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx("path",{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z"}),f.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),f.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),f.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx(vAe,{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:p,T1:h,T2:g,T3:b},total:d}),f.jsx(z3,{cx:70.3,cy:232.3,r:50,times:{T0:p,T1:h,T2:g,T3:b},total:d}),f.jsx(z3,{cx:232.3,cy:70.3,r:50,times:{T0:p,T1:h,T2:g,T3:b},total:d})]})]})}),t==="expanded"&&f.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",children:[f.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),f.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function vAe({d:e,times:t,total:n}){const{T0:r,T1:a,T2:i,T3:o}=t;return f.jsx(Ia.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,a,i,o],ease:"easeInOut"}}}})}function z3({cx:e,cy:t,r:n,times:r,total:a}){const{T0:i,T1:o,T2:l,T3:u}=r;return f.jsx(Ia.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:a,times:[i,o,l,u],ease:"easeInOut"}}}})}function YX({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:r="3s",borderRadius:a="100px",background:i,className:o,children:l,...u}){const{resolvedTheme:d}=n0(),p=d==="dark"?"#000000":"#ffffff",h=d==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||p,b=i||h;return f.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":a,"--speed":r,"--cut":n,"--bg":b},className:Ue("group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]","transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",d==="dark"?"border-black/10 text-black":"border-white/10 text-white",o),ref:e,...u,children:[f.jsx("div",{className:Ue("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:f.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:f.jsx("div",{className:"animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]"})})}),l,f.jsx("div",{className:Ue("absolute inset-0 size-full","rounded-2xl px-4 py-1.5 text-sm font-medium","transform-gpu transition-all duration-300 ease-in-out",d==="dark"?"shadow-[inset_0_-8px_10px_#0000001f] group-hover:shadow-[inset_0_-6px_10px_#0000003f] group-active:shadow-[inset_0_-10px_10px_#0000003f]":"shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]")}),f.jsx("div",{className:Ue("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}YX.displayName="ShimmerButton";function F3({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:r,tooltip:a}=t(e);return f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:`absolute w-2 h-2 rounded-full ${r} animate-ping`}),f.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),f.jsx(qt,{children:f.jsx("p",{children:a})})]})}function B3({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:r,mobileMode:a=!1}){const i=cl(),o=l=>{const u=e.find(d=>d.id===l);if(!u||u.state!=="ready"){vn.error("Server is not connected and cannot be inspected");return}n(l)};return a?f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(V_,{children:[f.jsx(G_,{asChild:!0,children:f.jsxs(Fe,{variant:"ghost",className:"h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5",children:[t?f.jsx(Yl,{serverUrl:t.url,serverName:t.name,size:"md"}):f.jsx(aye,{className:"h-5 w-5"}),f.jsx(_c,{className:"h-4 w-4"})]})}),f.jsxs(Qv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(W_,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Tp,{}),e.length===0?f.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(l=>f.jsxs(Vo,{onClick:()=>o(l.id),className:"flex items-center gap-3",children:[f.jsx(Yl,{serverUrl:l.url,serverName:l.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:l.name}),f.jsx(F3,{status:l.state})]}),f.jsx(Fe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),r(l.id)},children:f.jsx(qu,{className:"h-3 w-3"})})]},l.id)),f.jsx(Tp,{}),f.jsx(Vo,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(V_,{children:[f.jsx(G_,{asChild:!0,children:f.jsxs(YX,{className:Ue("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-10"),children:[t&&f.jsx(Yl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&f.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx("button",{onClick:l=>{l.stopPropagation()},className:"w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors",title:"Click to copy error message","aria-label":"Copy error message to clipboard"})}),f.jsx(qt,{children:f.jsx("p",{className:"max-w-xs",children:t.error})})]}):f.jsx("div",{className:`w-2 h-2 rounded-full ${t.state==="ready"?"bg-emerald-600 animate-status-pulse":t.state==="failed"?"bg-rose-600 animate-status-pulse-red":"bg-yellow-500 animate-status-pulse-yellow"}`})})]})]})}),t&&f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx("button",{type:"button",onClick:()=>{r(t.id)},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"Edit connection settings",children:f.jsx(qu,{className:"h-4 w-4"})})}),f.jsx(qt,{children:f.jsx("p",{children:"Edit connection settings"})})]}),f.jsxs(Qv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(W_,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Tp,{}),e.length===0?f.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(l=>f.jsxs(Vo,{onClick:()=>o(l.id),className:"flex items-center gap-3",children:[f.jsx(Yl,{serverUrl:l.url,serverName:l.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:l.name}),f.jsx(F3,{status:l.state})]}),f.jsx(Fe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),r(l.id)},children:f.jsx(qu,{className:"h-3 w-3"})})]},l.id)),f.jsx(Tp,{}),f.jsx(Vo,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const H3=[{id:"tools",label:"Tools",icon:uc},{id:"prompts",label:"Prompts",icon:fm},{id:"resources",label:"Resources",icon:Cve},{id:"sampling",label:"Sampling",icon:L7},{id:"elicitation",label:"Elicitation",icon:P7},{id:"notifications",label:"Notifications",icon:pC},{id:"chat",label:"Chat",icon:Fve}];function V3(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 yAe({collapsed:e,onToggle:t}){return f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx("button",{onClick:t,className:Ue("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?f.jsx(O7,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):f.jsx(Cw,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),f.jsx(qt,{children:f.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function wAe({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:a,onCommandPaletteOpen:i,onOpenConnectionOptions:o}){const{tunnelUrl:l}=kc(),u=t&&l,[d,p]=y.useState(!1),[h,g]=y.useState(!1),b=async()=>{if(l)try{await navigator.clipboard.writeText(`${l}/mcp`),p(!0),vn.success("Tunnel URL copied to clipboard"),setTimeout(()=>p(!1),2e3)}catch{vn.error("Failed to copy URL")}};return f.jsxs("header",{className:"w-full mx-auto",children:[f.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center justify-between w-full",children:[f.jsx("div",{className:"flex-1 flex justify-start",children:f.jsx(B3,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:o,mobileMode:!0})}),f.jsx("div",{className:"flex-shrink-0 flex justify-center",children:f.jsx("div",{className:"scale-150",children:f.jsx(U3,{state:"collapsed"})})}),f.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:f.jsx(M3,{className:"h-4 w-4"})})})}),f.jsx(qt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(P3,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&f.jsx("div",{className:"w-full",children:f.jsx(nT,{value:n,onValueChange:v=>a(v),collapsed:h,onCollapsedChange:g,children:f.jsx(rT,{className:"w-full justify-center",children:H3.map(v=>{const x=V3(v.id,t);return f.jsxs(aT,{value:v.id,icon:v.icon,className:Ue("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",h&&"pl-2"),children:[x>0&&f.jsx("span",{className:Ue(n===v.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:x}),f.jsx("span",{className:"sr-only",children:v.label})]},v.id)})})})})]}),f.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[f.jsx(B3,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:o}),t&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(nT,{value:n,onValueChange:v=>a(v),collapsed:h,onCollapsedChange:g,children:f.jsx(rT,{className:"overflow-x-auto",collapsible:!0,children:H3.map(v=>{const x=V3(v.id,t),S=x>0?`${v.label} (${x})`:v.label;return f.jsx(aT,{value:v.id,icon:v.icon,className:Ue("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",h&&"pl-4"),title:S,children:f.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[v.label,x>0&&f.jsx("span",{className:Ue(n===v.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:x})]})})})})}),f.jsx(yAe,{collapsed:h,onToggle:()=>g(!h)})]}),u&&f.jsxs(BY,{children:[f.jsx(HY,{asChild:!0,children:f.jsxs("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-500/10 to-pink-500/10 dark:from-purple-500/20 dark:to-pink-500/20 border border-purple-500/30 dark:border-purple-500/40 rounded-full hover:from-purple-500/20 hover:to-pink-500/20 dark:hover:from-purple-500/30 dark:hover:to-pink-500/30 transition-colors cursor-pointer",children:[f.jsx(pm,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),f.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),f.jsx(uA,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[f.jsx(pm,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),f.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[f.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[l,"/mcp"]}),f.jsx(Fe,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:b,children:d?f.jsx(ba,{className:"size-3.5 text-green-600"}):f.jsx(Zr,{className:"size-3.5"})})]})]}),f.jsxs("div",{children:[f.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),f.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"1."}),f.jsxs("span",{children:["Enable"," ",f.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"2."}),f.jsxs("span",{children:["In"," ",f.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",f.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"3."}),f.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),f.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[f.jsxs(Zt,{children:[f.jsx(Yt,{children:f.jsx(P3,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),f.jsx(qt,{children:f.jsx("p",{children:"Toggle theme"})})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsxs(Fe,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[f.jsx(fve,{className:"size-4"}),f.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),f.jsx(qt,{children:f.jsx("p",{children:"Command Palette"})})]}),f.jsxs(Zt,{children:[f.jsx(Yt,{asChild:!0,children:f.jsx(Fe,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[f.jsx(M3,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),f.jsx(qt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(U3,{state:"expanded"})]})]})]})}function SAe({children:e}){const t=cl(),n=ya(),{connections:r,addConnection:a,removeConnection:i,updateConnectionConfig:o,configLoaded:l}=fC(),{selectedServerId:u,setSelectedServerId:d,activeTab:p,setActiveTab:h,navigateToItem:g,setTunnelUrl:b}=kc(),[v,x]=y.useState(!1),[S,_]=y.useState(null),E=L_e();y.useEffect(()=>{const Z=new URLSearchParams(n.search).get("tunnelUrl");b(Z)},[n.search,b]),y.useEffect(()=>{const H=ae=>{const L=ae.detail.requestId;u&&g(u,"sampling",L)},Z=ae=>{const L=ae.detail.requestId;u&&g(u,"elicitation",L)},G=ae=>{const L=ae.detail.toolName;u&&L?g(u,"tools",L):u&&h("tools")};return window.addEventListener("navigate-to-sampling",H),window.addEventListener("navigate-to-elicitation",Z),window.addEventListener("navigate-to-tool-result",G),()=>{window.removeEventListener("navigate-to-sampling",H),window.removeEventListener("navigate-to-elicitation",Z),window.removeEventListener("navigate-to-tool-result",G)}},[u,h,g]);const k=y.useRef(null),C=y.useRef(null),R=y.useRef(null),{isAutoConnecting:A}=D_e({connections:r,addConnection:a,removeConnection:i,configLoaded:l}),N=y.useCallback(H=>{Or.getInstance().capture(new Cbe({trigger:H})).catch(()=>{}),x(!0)},[]),O=H=>{const Z=r.find(L=>L.id===H);if(!Z||Z.state!=="ready"){vn.error("Server is not connected and cannot be inspected");return}d(H);const ae=new URLSearchParams(n.search).get("tunnelUrl"),ne=ae?`/?server=${encodeURIComponent(H)}&tunnelUrl=${encodeURIComponent(ae)}`:`/?server=${encodeURIComponent(H)}`;t(ne)},$=y.useCallback(H=>{_(H)},[]),M=y.useCallback(H=>{S&&(H.url!==S?(i(S),a(H.url,H.name,H.proxyConfig,H.transportType)):o(S,{name:H.name,proxyConfig:H.proxyConfig,transportType:H.transportType}),_(null),vn.success("Connection settings updated"))},[S,i,a,o]),z=(H,Z,G)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:H,itemName:Z,serverId:G}),G){const ae=r.find(F=>F.id===G);if(console.warn("[Layout] Server lookup:",{serverId:G,serverFound:!!ae,serverState:ae?.state}),!ae||ae.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),vn.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:G,tab:H,itemName:Z}),g(G,H,Z);const L=new URLSearchParams(n.search).get("tunnelUrl"),V=L?`/?server=${encodeURIComponent(G)}&tunnelUrl=${encodeURIComponent(L)}`:`/?server=${encodeURIComponent(G)}`;console.warn("[Layout] Navigating to:",V),t(V)}else console.warn("[Layout] No serverId, just updating tab to:",H),h(H)},W=r.find(H=>H.id===u),J=W?W.tools.map(H=>({...H,_serverId:W.id})):r.flatMap(H=>H.state==="ready"?H.tools.map(Z=>({...Z,_serverId:H.id,_serverName:H.name})):[]),X=W?W.prompts.map(H=>({...H,_serverId:W.id})):r.flatMap(H=>H.state==="ready"?H.prompts.map(Z=>({...Z,_serverId:H.id,_serverName:H.name})):[]),re=W?W.resources.map(H=>({...H,_serverId:W.id})):r.flatMap(H=>H.state==="ready"?H.resources.map(Z=>({...Z,_serverId:H.id,_serverName:H.name})):[]);return y.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server"),G=Z?decodeURIComponent(Z):null;G!==u&&d(G)},[n.search,u,d]),y.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server");if(!Z)return;const G=decodeURIComponent(Z),ae=r.find(ne=>ne.id===G);if(!ae){const ne=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(ne)}if(ae.state==="failed"){const ne=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(ne)}},[n.search,t,r]),gY({onCommandPalette:()=>N("keyboard"),onToolsTab:()=>{W&&h("tools")},onPromptsTab:()=>{W&&h("prompts")},onResourcesTab:()=>{W&&h("resources")},onChatTab:()=>{W&&h("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{p==="tools"&&k.current?k.current.focusSearch():p==="prompts"&&C.current?C.current.focusSearch():p==="resources"&&R.current&&R.current.focusSearch()},onBlurSearch:()=>{p==="tools"&&k.current?k.current.blurSearch():p==="prompts"&&C.current?C.current.blurSearch():p==="resources"&&R.current&&R.current.blurSearch()}}),A?f.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Fi,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})}):f.jsx(dC,{children:f.jsxs("div",{className:"h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-2 py-2 sm:px-4 sm:py-4 gap-2 sm:gap-4",children:[f.jsx(wAe,{connections:r,selectedServer:W,activeTab:p,onServerSelect:O,onTabChange:h,onCommandPaletteOpen:()=>N("button"),onOpenConnectionOptions:$}),f.jsx("main",{className:"flex-1 w-full mx-auto bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 p-0 overflow-auto",children:f.jsx(hAe,{selectedServer:W,activeTab:p,toolsSearchRef:k,promptsSearchRef:C,resourcesSearchRef:R,children:e})}),f.jsx(ske,{isOpen:v,onOpenChange:x,tools:J,prompts:X,resources:re,savedRequests:E,connections:r,onNavigate:z,onServerSelect:O}),f.jsx(DK,{connection:S&&r.find(H=>H.id===S)||null,open:S!==null,onOpenChange:H=>{H||_(null)},onConnect:M})]})})}function xAe(){const[e,t]=y.useState("processing"),[n,r]=y.useState("");return y.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),hR().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(a=>{console.error("[OAuthCallback] Authorization failed:",a),t("error"),r(a instanceof Error?a.message:String(a))})},[]),e==="processing"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(el,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),f.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var EAe=(e,t,n,r,a,i,o,l)=>{let u=document.documentElement,d=["light","dark"];function p(b){(Array.isArray(e)?e:[e]).forEach(v=>{let x=v==="class",S=x&&i?a.map(_=>i[_]||_):a;x?(u.classList.remove(...S),u.classList.add(i&&i[b]?i[b]:b)):u.setAttribute(v,b)}),h(b)}function h(b){l&&d.includes(b)&&(u.style.colorScheme=b)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)p(r);else try{let b=localStorage.getItem(t)||n,v=o&&b==="system"?g():b;p(v)}catch{}},_Ae=y.createContext(void 0),kAe={setTheme:e=>{},themes:[]},TAe=()=>{var e;return(e=y.useContext(_Ae))!=null?e:kAe};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:a,defaultTheme:i,value:o,themes:l,nonce:u,scriptProps:d})=>{let p=JSON.stringify([n,t,i,e,l,o,r,a]).slice(1,-1);return y.createElement("script",{...d,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${EAe.toString()})(${p})`}})});function NAe({...e}){const{theme:t="system"}=TAe();return f.jsx(U7,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function RAe(){return f.jsx(qNe,{children:f.jsx($be,{children:f.jsxs(O_e,{children:[f.jsx(Nde,{basename:"/inspector",children:f.jsxs(wue,{children:[f.jsx(T_,{path:"/oauth/callback",element:f.jsx(xAe,{})}),f.jsx(T_,{path:"/",element:f.jsx(SAe,{children:f.jsx(I_e,{})})})]})}),f.jsx(NAe,{position:"top-center"})]})})})}const G3=new URLSearchParams(window.location.search);if(G3.has("code")||G3.has("error"))try{hR()}catch(e){console.error("[inspector] OAuth callback error:",e)}const W3=document.getElementById("root");W3?tce.createRoot(W3).render(f.jsx(RAe,{})):console.error("[inspector] Root element not found");export{dG as $,O_ as A,DAe as B,LAe as C,vR as D,so as E,uw as F,ga as G,hde as H,Yz as I,Ql as J,Zce as K,Jr as L,Mce as M,Hue as N,ZAe as O,aIe as P,Y8 as Q,dIe as R,SIe as S,YAe as T,Nde as U,fG as V,mIe as W,Hl as X,yR as Y,ev as Z,Ye as _,pr as a,AR as a$,cIe as a0,WAe as a1,uIe as a2,Cde as a3,KAe as a4,ace as a5,oG as a6,T_ as a7,Sc as a8,wue as a9,IAe as aA,pIe as aB,aa as aC,Bv as aD,qAe as aE,N_ as aF,xIe as aG,Rce as aH,OAe as aI,am as aJ,wi as aK,XAe as aL,Ece as aM,Rde as aN,yIe as aO,HAe as aP,IR as aQ,BAe as aR,pue as aS,vIe as aT,hue as aU,gIe as aV,bIe as aW,Lde as aX,nue as aY,wc as aZ,Ide as a_,Ede as aa,Ade as ab,wIe as ac,$Ae as ad,as as ae,ll as af,sw as ag,Kd as ah,Ya as ai,qa as aj,ow as ak,JAe as al,nIe as am,eIe as an,q9 as ao,PR as ap,oIe as aq,wR as ar,sIe as as,iIe as at,DR as au,St as av,Km as aw,lIe as ax,jde as ay,fIe as az,EIe as b,ya as b0,PAe as b1,CR as b2,cl as b3,fue as b4,MAe as b5,aue as b6,UAe as b7,kR as b8,Wm as b9,iV as bA,Gy as bB,uV as bC,Qt as bD,AT as bE,aB as bF,_ee as bG,Qb as bH,q3 as bI,Ule as bJ,fee as bK,hR as bL,Tee as bM,Li as bN,GE as bO,vi as bP,SH as bQ,d5 as bR,R5 as bS,gB as bT,yB as bU,wH as bV,u5 as bW,zAe as ba,FAe as bb,iue as bc,hIe as bd,mG as be,Mde as bf,Ay as bg,zH as bh,VE as bi,joe as bj,Yb as bk,jle as bl,Sv as bm,Qi as bn,Ce as bo,Lle as bp,Ple as bq,dz as br,Us as bs,$le as bt,kae as bu,ZE as bv,Sae as bw,Yae as bx,$N as by,oV as bz,lde as c,Vue as d,de as e,Ou as f,AAe as g,sc as h,VAe as i,GAe as j,eue as k,Bue as l,Ai as m,hi as n,$ce as o,NB as p,jAe as q,y as r,dde as s,rIe as t,OR as u,tIe as v,k_ as w,QAe as x,Gd as y,Que as z};
|