@barndoor-ai/sdk 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,13 +1,13 @@
1
- import e from"os";import t,{dirname as r,join as n}from"path";import o from"fs/promises";import{jwtVerify as s,createRemoteJWKSet as a}from"jose";import i from"crypto";import c from"http";import u,{fileURLToPath as l}from"url";import{spawn as d}from"child_process";import h from"readline";import p from"pkce-challenge";import{readFileSync as f}from"fs";class m extends Error{constructor(e){super(e),this.name="BarndoorError"}}class y extends m{constructor(e,t=null){super(e),this.name="AuthenticationError",this.errorCode=t}}class g extends y{constructor(e,t=null){let r=e;r+=t?` ${t}`:" Run 'barndoor-login' to authenticate.",super(r),this.name="TokenError",this.helpText=t}}class v extends g{}class _ extends g{}class w extends m{constructor(e,t){let r;const n=t.toString().toLowerCase();r=n.includes("timeout")?`Connection to ${e} timed out. Please check your internet connection and try again.`:n.includes("connection refused")?`Could not connect to ${e}. The service may be unavailable.`:n.includes("name resolution")||n.includes("getaddrinfo")?`Could not resolve hostname for ${e}. Please check the URL and your DNS settings.`:`Failed to connect to ${e}. Please check your internet connection.`,super(r),this.url=e,this.originalError=t}}class $ extends m{constructor(e,t,r=null){super($._createUserFriendlyMessage(e,t,r)),this.name="HTTPError",this.statusCode=e,this.responseBody=r}static _createUserFriendlyMessage(e,t,r){const n=`Request failed (HTTP ${e})`;return 400===e?`${n}: Invalid request. Please check your input parameters.`:401===e?`${n}: Authentication failed. Please check your token or re-authenticate.`:403===e?`${n}: Access denied. You don't have permission for this operation.`:404===e?`${n}: Resource not found. Please check the server ID or URL.`:429===e?`${n}: Rate limit exceeded. Please wait before making more requests.`:e>=500&&e<600?`${n}: Server error. Please try again later or contact support.`:`${n}: ${t}`}}class b extends m{constructor(e,t=null){let r=`Server '${e}' not found`;r+=t?`. Available servers: ${t.join(", ")}`:". Use listServers() to see available servers.",super(r),this.serverIdentifier=e,this.availableServers=t}}let k=class extends y{};class E extends m{}class P extends m{}class S{constructor(e=30,t=10){this.read=1e3*e,this.connect=1e3*t}}class T{constructor(e=new S,t=3){this.timeoutConfig=e,this.maxRetries=t,this.closed=!1}async request(e,t,r={}){if(this.closed)throw new Error("HTTP client has been closed");const{headers:n={},json:o,params:s,...a}=r,i=this._buildUrl(t,s),c={method:e.toUpperCase(),headers:{"Content-Type":"application/json","User-Agent":"barndoor-js-sdk/0.1.0",...n},...a};let u;o&&(c.body=JSON.stringify(o));for(let t=0;t<=this.maxRetries;t++){const r=new AbortController,n=this.timeoutConfig.connect+this.timeoutConfig.read,o=setTimeout(()=>r.abort(),n),s={...c,signal:r.signal};try{const e=await globalThis.fetch(i,s);if(clearTimeout(o),!e.ok){let t="";try{const r=e;"function"==typeof r.text?t=await r.text():"function"==typeof r.json&&(t=JSON.stringify(await r.json()))}catch{}throw new $(e.status,e.statusText,t)}let t="";const r=e,n=r&&r.headers;let a;return n&&("function"==typeof n.get?t=n.get("content-type")||n.get("Content-Type")||"":"object"==typeof n&&(t=n["content-type"]||n["Content-Type"]||"")),a=t.includes("application/json")||!t&&"function"==typeof r.json?await e.json():t.includes("text/")||!t&&"function"==typeof r.text?await e.text():"function"==typeof r.arrayBuffer?await e.arrayBuffer():e,a}catch(r){if(clearTimeout(o),r instanceof Error&&"AbortError"===r.name){const e=this.timeoutConfig.connect+this.timeoutConfig.read;u=new P(`Request to ${i} timed out after ${e}ms`)}else if(r instanceof $){if(r.statusCode>=400&&r.statusCode<500)throw r;if(!(r.statusCode>=500&&r.statusCode<600))throw r;{const t=e.toUpperCase();if(!("GET"===t||"HEAD"===t||"OPTIONS"===t))throw r;u=r}}else u=r instanceof Error&&"TypeError"===r.name&&r.message.includes("fetch")?new w(i,r):r instanceof Error?r:new Error(String(r));if(t===this.maxRetries)break;const n=Math.min(1e3*Math.pow(2,t),1e4);await this._sleep(n)}}throw u||(u=new Error(`Request to ${i} failed after ${this.maxRetries+1} attempts with no specific error`)),u}_buildUrl(e,t){if(!t||0===Object.keys(t).length)return e;const r=new URL(e);return Object.entries(t).forEach(([e,t])=>{null!=t&&r.searchParams.append(e,String(t))}),r.toString()}_sleep(e){return new Promise(t=>setTimeout(t,e))}async close(){this.closed=!0}async aclose(){await this.close()}}class I{constructor(e){if(this.id=e.id,this.name=e.name,this.slug=e.slug,this.provider=e.provider??null,this.connection_status=e.connection_status,!(this.id&&this.name&&this.slug&&this.connection_status))throw new Error("ServerSummary missing required fields")}static fromApiResponse(e){return new I(e)}}class x extends I{constructor(e){super(e),this.url=e.url??null}static fromApiResponse(e){return new x(e)}}class N{constructor(e){if(this.agent_token=e.agent_token,this.expires_in=e.expires_in,!this.agent_token||"number"!=typeof this.expires_in)throw new Error("AgentToken missing required fields")}static fromApiResponse(e){return new N(e)}}const C={production:{issuer:"https://auth.barndoor.ai/realms/barndoor",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.platform.barndoor.ai"},uat:{issuer:"https://auth.barndooruat.com/realms/barndoor",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.trial.barndooruat.com"},dev:{issuer:"https://auth.barndoordev.com/realms/barndoor",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.platform.barndoordev.com"},"enterprise-production":{issuer:"https://auth.barndoor.ai",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.mcp.barndoor.ai"},"enterprise-uat":{issuer:"https://auth.barndooruat.com",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.mcp.barndooruat.com"},"enterprise-dev":{issuer:"https://auth.barndoordev.com",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.mcp.barndoordev.com"},localdev:{issuer:"http://localhost:8080/realms/barndoor",audience:"https://barndoor.ai/",baseUrl:"http://localhost:8000"}},j="undefined"!=typeof window&&void 0!==window.document,R="undefined"==typeof window&&"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;function O(e,t=""){return R?process.env[e]??t:j&&window.ENV?window.ENV[e]??t:t}class z{constructor(e={}){const t=e.environment??(O("MODE")||O("BARNDOOR_ENV")||"production");this.environment={production:"production",prod:"production",uat:"uat",dev:"dev",development:"dev","enterprise-production":"enterprise-production","enterprise-prod":"enterprise-production","enterprise-uat":"enterprise-uat","enterprise-dev":"enterprise-dev",enterprise:"enterprise-production",localdev:"localdev",local:"localdev"}[t.toLowerCase()]??"production";const r=C[this.environment]??C.production,n=O("AUTH_URL"),o=e.authDomain??O("AUTH_DOMAIN");e.authIssuer?this.authIssuer=e.authIssuer:this.authIssuer=n||(o?o.startsWith("http")?o:`https://${o}`:r.issuer),this.clientId=e.clientId??(O("AGENT_CLIENT_ID")||O("AUTH_CLIENT_ID")||""),this.clientSecret=e.clientSecret??(O("AGENT_CLIENT_SECRET")||O("AUTH_CLIENT_SECRET")||""),this.apiAudience=e.apiAudience??(O("API_AUDIENCE")||r.audience),this.promptForLogin=e.promptForLogin??!1,this.skipLoginLocal=e.skipLoginLocal??!1,this.baseUrl=e.baseUrl??(O("BARNDOOR_API")||O("BARNDOOR_URL")||r.baseUrl)}get authDomain(){let e=this.authIssuer;return e.startsWith("https://")?e=e.slice(8):e.startsWith("http://")&&(e=e.slice(7)),e}static getStaticConfig(){return new z}static getDynamicConfig(e,t={}){const{requireOrganization:r=!0,fallbackOrganizationId:n}=t,o=new z,s=A(e);if(s.hasOrganization){const e=String(s.organizationId??"").trim().toLowerCase();if(!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(e))throw new E("Invalid organization subdomain format from token");return o.baseUrl=o.baseUrl.replace("{org_slug}",e),o}if(n)return o.baseUrl=o.baseUrl.replace("{org_slug}",n),o;if(r){const e=s.error||"No organization information found in token";throw new E(`Failed to extract organization ID from token: ${e}. This token may be for a personal account or may be missing organization claims. Consider using getStaticConfig() for organization-independent operations or provide a fallbackOrganizationId in the options.`)}return o}validate(){if(!this.authIssuer||""===this.authIssuer.trim())throw new E("authIssuer is required");if(!this.apiAudience||""===this.apiAudience.trim())throw new E("apiAudience is required");if(!this.baseUrl||""===this.baseUrl.trim())throw new E("baseUrl is required")}}function A(e){try{const t=e.split(".");if(3!==t.length)return{hasOrganization:!1,error:"Invalid JWT format - expected 3 parts separated by dots"};let r,n;try{r=JSON.parse(function(e){if("undefined"!=typeof globalThis&&globalThis.atob)return globalThis.atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");throw new Error("No base64 decode function available")}(t[1].replace(/-/g,"+").replace(/_/g,"/")))}catch(e){return{hasOrganization:!1,error:"Failed to parse JWT payload - token may be corrupted"}}if(r.user&&"object"==typeof r.user&&(n=r.user.organization_name??r.user.organization_slug),!n){const e=r["https://barndoor.ai/organization_slug"],t=r.organization_slug,o=r.organization_name,s=r.org_slug;n=("string"==typeof o?o:void 0)??("string"==typeof e?e:void 0)??("string"==typeof t?t:void 0)??("string"==typeof s?s:void 0)}return n&&"string"==typeof n&&""!==n.trim()?{organizationId:n.trim(),hasOrganization:!0}:{hasOrganization:!1,error:"No organization information found in token. This token may be for a personal account or may be missing organization claims."}}catch(e){return{hasOrganization:!1,error:`Failed to decode JWT token: ${e instanceof Error?e.message:String(e)}`}}}function M(){return z.getStaticConfig()}function D(e,t){return z.getDynamicConfig(e,t)}function U(e){return A(e)}function q(e){return A(e).hasOrganization}let V={debug:(e,...t)=>{"undefined"!=typeof console&&console.debug&&console.debug(e,...t)},info:(e,...t)=>{"undefined"!=typeof console&&console.info&&console.info(e,...t)},warn:(e,...t)=>{"undefined"!=typeof console&&console.warn&&console.warn(e,...t)},error:(e,...t)=>{"undefined"!=typeof console&&console.error&&console.error(e,...t)}};function F(e){V=e}function L(){return V}function K(e){return{debug:(t,...r)=>{V.debug(`[${e}] ${t}`,...r)},info:(t,...r)=>{V.info(`[${e}] ${t}`,...r)},warn:(t,...r)=>{V.warn(`[${e}] ${t}`,...r)},error:(t,...r)=>{V.error(`[${e}] ${t}`,...r)}}}function H(e,...t){V.debug(e,...t)}function Z(e,...t){V.info(e,...t)}function G(e,...t){V.warn(e,...t)}function B(e,...t){V.error(e,...t)}const J=K("token"),W=new Map;async function Q(e){if(W.has(e))return W.get(e);const t=e.replace(/\/$/,""),r=`${t}/.well-known/openid-configuration`;try{const t=new AbortController,n=setTimeout(()=>t.abort(),5e3);try{const n=await fetch(r,{signal:t.signal});if(!n.ok)throw new Error(`HTTP ${n.status}`);const o=await n.json();return W.set(e,o),J.debug(`OIDC discovery successful for ${e}`),o}finally{clearTimeout(n)}}catch(r){return J.warn(`OIDC discovery failed for ${e}:`,r),t.includes("/realms/")?{issuer:t,token_endpoint:`${t}/protocol/openid-connect/token`,authorization_endpoint:`${t}/protocol/openid-connect/auth`,userinfo_endpoint:`${t}/protocol/openid-connect/userinfo`,jwks_uri:`${t}/protocol/openid-connect/certs`}:{issuer:t,token_endpoint:`${t}/oauth/token`,authorization_endpoint:`${t}/authorize`,userinfo_endpoint:`${t}/userinfo`,jwks_uri:`${t}/.well-known/jwks.json`}}}function Y(){W.clear()}function X(e){console.warn("setTokenLogger is deprecated. Use setLogger from the main logging module instead.")}function ee(e){try{const t=e.split(".");if(3!==t.length)return null;const r=JSON.parse(function(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");if(R)return Buffer.from(t,"base64").toString("utf8");if("undefined"!=typeof globalThis&&globalThis.atob)return globalThis.atob(t);throw new Error("No base64 decode function available")}(t[1]));return r}catch(e){return null}}function te(e,t){return"undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?e:Promise.race([e,new Promise((e,r)=>{setTimeout(()=>r(new Error("Request timeout")),t)})])}var re;!function(e){e.VALID="valid",e.EXPIRED="expired",e.INVALID="invalid"}(re||(re={}));const ne=new Map;class oe{constructor(e){this.lockAcquired=!1,this.lockFile=`${e}.lock`}async acquire(e=5e3){if(!R)return;const t=Date.now();for(;Date.now()-t<e;)try{return await o.writeFile(this.lockFile,process.pid.toString(),{flag:"wx"}),void(this.lockAcquired=!0)}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"EEXIST"!==e.code)throw new g(`Failed to acquire file lock: ${e}`);try{const e=await o.readFile(this.lockFile,"utf8"),t=parseInt(e.trim(),10);try{process.kill(t,0),await new Promise(e=>setTimeout(e,100));continue}catch(e){if(e&&"object"==typeof e&&"code"in e){const t=e;if("EPERM"===t.code){await new Promise(e=>setTimeout(e,100));continue}if("ESRCH"===t.code){await o.unlink(this.lockFile).catch(()=>{});continue}}await o.unlink(this.lockFile).catch(()=>{});continue}}catch{await o.unlink(this.lockFile).catch(()=>{});continue}}throw new g("Failed to acquire file lock: timeout")}async release(){if(R&&this.lockAcquired)try{await o.unlink(this.lockFile),this.lockAcquired=!1}catch(e){console.debug("Failed to release file lock:",e)}}}class se{}class ae extends se{constructor(){super(),this.storageKey="barndoor_token"}async loadToken(){try{const e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):null}catch(e){return J.warn("Failed to load token from localStorage:",e),null}}async saveToken(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e))}catch(e){const t=e instanceof Error?e.message:String(e);throw new g(`Failed to save token: ${t}`)}}async clearToken(){try{localStorage.removeItem(this.storageKey)}catch(e){J.warn("Failed to clear token from localStorage:",e)}}}class ie extends se{constructor(){super(),this.tokenFile=this._getTokenFilePath()}_getTokenFilePath(){if(R)return t.join(e.homedir(),".barndoor","token.json");throw new Error("NodeTokenStorage can only be used in Node.js environment")}async loadToken(){if(!R)throw new Error("NodeTokenStorage can only be used in Node.js environment");const e=new oe(this.tokenFile);try{await e.acquire();const t=await o.readFile(this.tokenFile,"utf8");return JSON.parse(t)}catch(e){return e&&"object"==typeof e&&"code"in e&&"ENOENT"===e.code||J.warn("Failed to load token from file:",e),null}finally{await e.release()}}async saveToken(e){if(!R)throw new Error("NodeTokenStorage can only be used in Node.js environment");const r=new oe(this.tokenFile);try{await r.acquire(),await o.mkdir(t.dirname(this.tokenFile),{recursive:!0}),await o.writeFile(this.tokenFile,JSON.stringify(e,null,2)),await o.chmod(this.tokenFile,384),J.debug("Token saved to storage")}catch(e){const t=e instanceof Error?e.message:String(e);throw new g(`Failed to save token: ${t}`)}finally{await r.release()}}async clearToken(){if(!R)throw new Error("NodeTokenStorage can only be used in Node.js environment");try{await o.unlink(this.tokenFile)}catch(e){e&&"object"==typeof e&&"code"in e&&"ENOENT"!==e.code&&J.warn("Failed to clear token file:",e)}}}function ce(){if(j)return new ae;if(R)return new ie;throw new Error("Unsupported environment for token storage")}async function ue(e,t,r){try{const n=await async function(e){if(ne.has(e))return ne.get(e);try{const t=(await Q(e)).jwks_uri;if(!t)throw J.debug(`No jwks_uri in OIDC config for ${e}`),new Error("No jwks_uri available");const r=a(new URL(t));return ne.set(e,r),r}catch(t){throw J.debug(`Failed to get JWKS for ${e}:`,t),t}}(t),o=`${t.replace(/\/$/,"")}/`;return await s(e,n,{issuer:o,audience:r}),J.debug("Token verified locally using JWKS"),re.VALID}catch(e){return e&&"object"==typeof e&&"code"in e&&"ERR_JWT_EXPIRED"===e.code?(J.debug("Token expired (verified locally)"),re.EXPIRED):(J.debug("JWT verification failed:",e),re.INVALID)}}class le{constructor(){this._locked=!1,this._waitQueue=[]}async acquire(){return new Promise(e=>{this._locked?this._waitQueue.push(e):(this._locked=!0,e())})}release(){if(this._waitQueue.length>0){const e=this._waitQueue.shift();e&&e()}else this._locked=!1}async withLock(e){await this.acquire();try{return await e()}finally{this.release()}}}class de{constructor(e){this._refreshMutex=new le,this.storage=ce()}async getValidToken(){return this._refreshMutex.withLock(async()=>{const e=await this.storage.loadToken();if(!e)throw new g("No token found. Please authenticate.");try{if(this._shouldRefreshToken(e)&&e.refresh_token){J.debug("Proactively refreshing token before expiration");const t=await this._refreshToken(e),r={...e,...t};return await this.storage.saveToken(r),r.access_token}const t=await this._validateOrRefresh(e);return await this.storage.saveToken(t),t.access_token}catch(e){throw J.error("Token validation/refresh failed:",e),new v("Token expired and refresh failed. Please re-authenticate.")}})}_shouldRefreshToken(e){const t=ee(e.access_token);if(!t?.exp)return!0;const r=Math.floor(Date.now()/1e3);return t.exp-r<300}async _validateOrRefresh(e){const t=e.access_token,r=M(),n=await ue(t,r.authIssuer,r.apiAudience);if(n===re.VALID)return J.debug("Token validated locally"),e;if(n===re.INVALID&&(J.debug("Local validation failed, trying remote"),await this._isTokenValidRemote(t)))return J.debug("Token validated remotely"),e;if(J.info("Token invalid or expired, attempting refresh"),e.refresh_token){const t=await this._refreshToken(e);return{...e,...t}}throw new v("Token expired and no refresh token available")}async _isTokenValidRemote(e){try{const t=M(),r=(await Q(t.authIssuer)).userinfo_endpoint,n=fetch(r,{headers:{Authorization:`Bearer ${e}`},..."undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?{signal:AbortSignal.timeout(5e3)}:{}});return(await te(n,5e3)).ok}catch(e){return J.debug("Remote token validation failed:",e),!1}}async _refreshToken(e){const t=e.refresh_token;if(!t)throw new g("No refresh token available");const r=M();if(j&&r.clientSecret)throw new g("Refresh flow requires a confidential client; run interactive login again.");const n=(await Q(r.authIssuer)).token_endpoint,o=new URLSearchParams({grant_type:"refresh_token",client_id:r.clientId,refresh_token:t});r.clientSecret&&!j&&o.set("client_secret",r.clientSecret);try{const e=fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString(),..."undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?{signal:AbortSignal.timeout(15e3)}:{}}),t=await te(e,15e3);if(400===t.status){let e="Invalid refresh token";try{e=(await t.json()).error_description||e}catch{}throw J.warn(`Refresh token invalid: ${e}`),new v(`Refresh token expired or invalid: ${e}`)}if(429===t.status)throw J.warn("Rate limited during token refresh"),new g("Rate limited during token refresh. Please try again later.");if(t.status>=500)throw J.warn(`Auth server error during refresh: ${t.status}`),new g(`Auth server temporarily unavailable (HTTP ${t.status})`);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);return await t.json()}catch(e){if(e instanceof g||e instanceof v)throw e;if(e&&"object"==typeof e&&"name"in e){if("TimeoutError"===e.name||"AbortError"===e.name)throw J.warn("Timeout during token refresh"),new g("Token refresh timed out. Please check your connection.");if("TypeError"===e.name&&"message"in e&&"string"==typeof e.message&&e.message.includes("fetch"))throw J.warn(`Network error during token refresh: ${e.message}`),new g("Network error during token refresh. Please check your connection.")}J.error("Unexpected error during token refresh:",e);const t=e instanceof Error?e.message:String(e);throw new g(`Token refresh failed: ${t}`)}}}async function he(){try{const e=ce(),t=await e.loadToken();return t?.access_token??null}catch(e){return null}}async function pe(e){const t=ce();let r;r="string"==typeof e?{access_token:e}:e,await t.saveToken(r)}async function fe(){const e=ce();await e.clearToken()}async function me(e){try{const e=ce(),t=await e.loadToken();if(!t?.access_token)return!1;const r=M(),n=(await Q(r.authIssuer)).userinfo_endpoint,o=fetch(n,{headers:{Authorization:`Bearer ${t.access_token}`},..."undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?{signal:AbortSignal.timeout(1e4)}:{}});return(await te(o,1e4)).ok}catch(e){return!1}}async function ye(e){try{const t=new de(e||"");return await t.getValidToken(),!0}catch(e){return J.warn("Token validation/refresh failed:",e),!1}}async function ge(e,t){try{const t=M(),r=await ue(e,t.authIssuer,t.apiAudience);if(r===re.VALID)return{valid:!0};if(r===re.INVALID)try{const r=(await Q(t.authIssuer)).userinfo_endpoint,n=fetch(r,{headers:{Authorization:`Bearer ${e}`},..."undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?{signal:AbortSignal.timeout(5e3)}:{}});return{valid:(await te(n,5e3)).ok}}catch(e){return J.warn("Remote token validation failed:",e),{valid:!1}}return{valid:!1}}catch(e){return J.warn("Token validation failed:",e),{valid:!1}}}class ve{constructor(){this._codeVerifier=null,this._currentState=null,this._logger=K("pkce")}async buildAuthorizationUrl({domain:e,clientId:t,redirectUri:r,audience:n,scope:o="openid profile email",issuer:s}){this._codeVerifier=_e(32);const a=we(await async function(e){const t=(new TextEncoder).encode(e);if(j&&window.crypto&&window.crypto.subtle){const e=await window.crypto.subtle.digest("SHA-256",t);return new Uint8Array(e)}if(R){const t=i.createHash("sha256").update(e).digest();return new Uint8Array(t)}throw new Error("SHA256 not available in this environment")}(this._codeVerifier));this._currentState=_e(16);const c=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:r,scope:o,audience:n,state:this._currentState,code_challenge:a,code_challenge_method:"S256"});let u;if(s){u=(await Q(s)).authorization_endpoint}else{if(!e)throw new k("Either issuer or domain must be provided");u=`https://${e}/authorize`}return`${u}?${c.toString()}`}async exchangeCodeForToken({domain:e,clientId:t,code:r,redirectUri:n,clientSecret:o,issuer:s}){const a=new URLSearchParams({grant_type:"authorization_code",client_id:t,code:r,redirect_uri:n});if(o&&a.set("client_secret",o),this._codeVerifier&&a.set("code_verifier",this._codeVerifier),!o&&!this._codeVerifier)throw new k("Either client_secret or PKCE verifier must be provided");let i;if(s){i=(await Q(s)).token_endpoint}else{if(!e)throw new k("Either issuer or domain must be provided");i=`https://${e}/oauth/token`}try{const e=await fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(!e.ok){const t=await e.json().catch(()=>({}));throw this._logger.error("Token endpoint response:",t),new k(`Token exchange failed: ${t.error??t.error_description??e.statusText}`)}const t=await e.json();return this.clearState(),t}catch(e){if(e instanceof k)throw e;const t=e instanceof Error?e.message:String(e);throw new k(`Token exchange failed: ${t}`)}}validateState(e){return Boolean(this._currentState&&e===this._currentState)}clearState(){this._codeVerifier=null,this._currentState=null}getState(){return this._codeVerifier&&this._currentState?{codeVerifier:this._codeVerifier,codeChallenge:"",state:this._currentState,timestamp:Date.now()}:null}}function _e(e){const t=new Uint8Array(e);if(j&&window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(t);else{if(!R)throw new Error("Secure random generator not available for PKCE.");i.randomFillSync(t)}return we(t)}function we(e){const t=function(e){if("undefined"!=typeof globalThis&&globalThis.btoa)return globalThis.btoa(String.fromCharCode(...e));if("undefined"!=typeof Buffer)return Buffer.from(e).toString("base64");throw new Error("No base64 encode function available")}(e);return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $e(e=52765){if(!R)throw new Error("Local callback server is only available in Node.js environment");const t=K("pkce"),r="undefined"!=typeof process&&process.env&&process.env.BARNDOOR_REDIRECT_HOST||"127.0.0.1",n=r.startsWith("http")?`${r}:${e}/cb`:`http://${r}:${e}/cb`,o=new Promise((r,o)=>{const s=c.createServer((e,n)=>{t.debug(`Callback server received request: ${e.method} ${e.url}`);const a=u.parse(e.url??"",!0);if(t.debug(`Parsed URL - pathname: ${a.pathname}, query:`,a.query),"/cb"===a.pathname){const{code:i,state:c,error:u,error_description:l}=a.query;t.debug(`Callback params - code: ${!!i}, state: ${!!c}, error: ${u}`),n.writeHead(200,{"Content-Type":"text/html"}),u?(t.error(`OAuth error: ${u} - ${l}`),n.end("\n <html>\n <body>\n <h1>Authentication Failed</h1>\n <p>Error: Authentication error occurred.</p>\n <p>Description: Please return to the application for details.</p>\n <p>You can close this window.</p>\n </body>\n </html>\n "),s.close(),o(new k(`OAuth error: ${u} - ${l}`))):i?(t.info("OAuth callback received successfully, closing server"),n.end("\n <html>\n <body>\n <h1>Authentication Successful</h1>\n <p>You can close this window and return to your application.</p>\n <script>\n console.log('Authentication callback received. You can close this window.');\n setTimeout(() => window.close(), 1000);\n <\/script>\n </body>\n </html>\n "),s.close(),r([i,c])):(t.warn("No authorization code received in callback"),t.warn(`Full URL: ${e.url}`),t.warn("Query params:",a.query),n.end(`\n <html>\n <body>\n <h1>Authentication Failed</h1>\n <p>No authorization code received.</p>\n <p>Full URL: ${e.url}</p>\n <p>You can close this window.</p>\n </body>\n </html>\n `),s.close(),o(new k("No authorization code received")))}else t.debug(`404 for path: ${a.pathname}`),n.writeHead(404,{"Content-Type":"text/plain"}),n.end("Not found")});s.listen(e,"0.0.0.0",()=>{console.log(`OAuth callback server listening on ${n}`)}),s.on("error",e=>{o(new k(`Failed to start callback server: ${e.message}`))}),s.on("connection",e=>{t.debug(`New connection from ${e.remoteAddress}:${e.remotePort}`)})});return[n,o]}const be=K("client-credentials");async function ke(e){const{timeoutMs:t=15e3}=e,{tokenEndpoint:r,body:n}=await async function(e){const{clientId:t,clientSecret:r,audience:n,issuer:o,domain:s}=e;let a;if(o)a=(await Q(o)).token_endpoint;else{if(!s)throw new k("Either 'issuer' or 'domain' must be provided");a=`https://${s}/oauth/token`}return{tokenEndpoint:a,body:new URLSearchParams({grant_type:"client_credentials",client_id:t,client_secret:r,audience:n})}}(e),o=new AbortController,s=setTimeout(()=>o.abort(),t);try{const e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString(),signal:o.signal});if(!e.ok){const t=await e.json().catch(()=>({}));throw be.error("Client-credentials token endpoint error:",t),new k(`Client-credentials grant failed: ${t.error_description??t.error??e.statusText}`)}const t=await e.json();if(!t.access_token)throw new k("Client-credentials grant: response missing access_token");return t.access_token}catch(e){if(e instanceof k)throw e;if(e instanceof Error&&"AbortError"===e.name)throw new k(`Client-credentials grant timed out after ${t}ms`);const r=e instanceof Error?e.message:String(e);throw new k(`Client-credentials grant failed: ${r}`)}finally{clearTimeout(s)}}class Ee{constructor(e,t={}){this._credentials=null,this._logger=K("client");const{token:r,timeout:n=30,maxRetries:o=3}=t;this.base=this._validateUrl(e,"API base URL").replace(/\/$/,"");const s=Object.prototype.hasOwnProperty.call(t,"token");if(this._token=s?this._validateToken(r):null,"number"!=typeof n||n<=0)throw new E("timeout must be a positive number");if(!Number.isInteger(o)||o<0)throw new E("maxRetries must be a non-negative integer");const a=new S(n,n/3);this._http=new T(a,o),this._tokenValidated=!1,this._closed=!1,this._logger.info(`Initialized BarndoorSDK for ${this.base}`)}static async fromClientCredentials(e,t){const{timeout:r,maxRetries:n,...o}=t,s={token:await ke(o)};void 0!==r&&(s.timeout=r),void 0!==n&&(s.maxRetries=n);const a=new Ee(e,s);return a._credentials={...o},a._tokenValidated=!0,a}get token(){if(!this._token)throw new Error("No token available. Call authenticate() first or provide token in constructor.");return this._token}async authenticate(e){this._token=this._validateToken(e),this._tokenValidated=!1,await this.ensureValidToken(),this._logger.info("Authentication successful")}_validateUrl(e,t){if(!e||"string"!=typeof e)throw new E(`${t} must be a non-empty string`);try{return new URL(e),e}catch(e){throw new E(`${t} must be a valid URL`)}}_validateToken(e){if(!e||"string"!=typeof e)throw new g("Token must be a non-empty string");if(3!==e.split(".").length)throw new g("Token must be a valid JWT");return e}_ensureNotClosed(){if(this._closed)throw new Error("SDK has been closed. Create a new instance or use as context manager.")}async _req(e,t,r={}){this._ensureNotClosed(),await this.ensureValidToken(),await this._maybeRefreshM2MToken();const n=`${this.base}${t}`,o=()=>{const e={...r.headers??{}};return e.Authorization=`Bearer ${this.token}`,{...r,headers:e}};try{return await this._http.request(e,n,o())}catch(t){if(t instanceof $&&401===t.statusCode&&null!==this._credentials)return this._logger.info("M2M token rejected (401); refreshing and retrying once"),await this._refreshM2MToken(),await this._http.request(e,n,o());throw t}}async _maybeRefreshM2MToken(){null!==this._credentials&&function(e,t){const r=e.split(".");if(3!==r.length)return!0;const n=r[1];if(!n)return!0;let o;try{const e=n.replace(/-/g,"+").replace(/_/g,"/"),t="undefined"!=typeof Buffer?Buffer.from(e,"base64").toString("utf8"):globalThis.atob(e);o=JSON.parse(t)}catch{return!0}const s=o.exp;return"number"!=typeof s||s-Date.now()/1e3<=t}(this.token,60)&&(this._logger.debug("M2M token near expiry; refreshing"),await this._refreshM2MToken())}async _refreshM2MToken(){if(null===this._credentials)throw new Error("_refreshM2MToken() called on an SDK not created via BarndoorSDK.fromClientCredentials()");this._token=await ke(this._credentials),this._tokenValidated=!0}async validateCachedToken(){if(!this.token)return!1;try{const e=M(),t=(await Q(e.authIssuer)).userinfo_endpoint,r=new AbortController,n=setTimeout(()=>r.abort(),1e4);try{const e=(await fetch(t,{headers:{Authorization:`Bearer ${this.token}`},signal:r.signal})).ok;return e&&(this._tokenValidated=!0),e}finally{clearTimeout(n)}}catch(e){return!1}}async ensureValidToken(){if(!this._token)throw new Error("No token available. Call authenticate() first or provide token in constructor.");if(this._tokenValidated)return;const e=(R?process.env.BARNDOOR_ENV:"")??"";if(["test","ci"].includes(e.toLowerCase()))return void(this._tokenValidated=!0);if(!await this.validateCachedToken())throw new g("Token validation failed. Please re-authenticate.");this._tokenValidated=!0}async listServers(){this._logger.debug("Fetching server list");try{const e=[];let t=1;for(;null!==t;){const r=1===t?"/api/servers":`/api/servers?page=${t}`,n=await this._req("GET",r),o=n.data.map(e=>I.fromApiResponse(e));e.push(...o),t=n.pagination.next_page}return this._logger.info(`Retrieved ${e.length} servers total`),e}catch(e){throw this._logger.error("Failed to list servers:",e),e}}async getServer(e){const t=this._validateServerId(e);this._logger.info(`Fetching server details for ${t}`);const r=this._isUuid(t)?`/api/servers/${t}`:`/api/servers/by-slug/${t}`,n=await this._req("GET",r);return x.fromApiResponse(n)}async initiateConnection(e,t){const r=this._validateServerId(e);let n;t&&(n=this._validateUrl(t,"Return URL")),this._logger.info(`Initiating connection for server ${r}`);const o=n?{return_url:n}:void 0;try{const e=this._isUuid(r)?`/api/servers/${r}/connect`:`/api/servers/by-slug/${r}/connect`;return await this._req("POST",e,{params:o,json:{}})}catch(e){if(e instanceof $&&500===e.statusCode&&e.responseBody?.includes("OAuth server configuration not found"))throw new Error("Server is missing OAuth configuration. Ask an admin to configure credentials before initiating a connection.");throw e}}async getConnectionStatus(e){const t=this._validateServerId(e);this._logger.info(`Checking connection status for server ${t}`);const r=this._isUuid(t)?`/api/servers/${t}/connection`:`/api/servers/by-slug/${t}/connection`;return(await this._req("GET",r)).status}async disconnectServer(e){const t=this._validateServerId(e);this._logger.info(`Disconnecting from server ${t}`);try{const e=this._isUuid(t)?`/api/servers/${t}/connection`:`/api/servers/by-slug/${t}/connection`;await this._req("DELETE",e),this._logger.info(`Successfully disconnected from server ${t}`)}catch(e){if(e instanceof $&&404===e.statusCode)throw new Error(`Connection not found for server ${t}. Server may not be connected.`);throw e}}_validateServerId(e){if(!e||"string"!=typeof e)throw new Error("Server ID must be a non-empty string");if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)&&!/^[a-z0-9-]+$/.test(e))throw new Error("Server ID must be a valid UUID or slug (lowercase letters, numbers, and hyphens only)");return e}_isUuid(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async listPolicies(e=1,t=10,r={}){if(!Number.isInteger(e)||e<1)throw new Error("Page must be a positive integer");if(!Number.isInteger(t)||t<1||t>1e3)throw new Error("Limit must be a positive integer between 1 and 1000");this._logger.debug(`Listing policies (page=${e}, limit=${t})`);const n={page:e,limit:t,...r};return this._req("GET","/api/v2/policies",{params:n})}async getPolicy(e){if(!e||"string"!=typeof e)throw new Error("Policy ID must be a non-empty string");if(!this._isUuid(e))throw new Error("Policy ID must be a valid UUID");return this._logger.debug(`Fetching policy details for ${e}`),this._req("GET",`/api/v2/policies/${e}`)}async createPolicy(e){if(!e||"object"!=typeof e)throw new Error("Policy data must be a non-empty object");return this._logger.debug("Creating new policy"),this._req("POST","/api/v2/policies",{json:e})}async updatePolicy(e,t){if(!e||"string"!=typeof e)throw new Error("Policy ID must be a non-empty string");if(!this._isUuid(e))throw new Error("Policy ID must be a valid UUID");if(!t||"object"!=typeof t)throw new Error("Policy data must be a non-empty object");return this._logger.debug(`Updating policy ${e}`),this._req("PATCH",`/api/v2/policies/${e}`,{json:t})}async clonePolicy(e,t){if(!e||"string"!=typeof e)throw new Error("Policy ID must be a non-empty string");if(!this._isUuid(e))throw new Error("Policy ID must be a valid UUID");if(!t||"string"!=typeof t)throw new Error("New name must be a non-empty string");return this._logger.debug(`Cloning policy ${e} with new name: ${t}`),this._req("POST",`/api/v2/policies/${e}/clone`,{json:{name:t}})}async validatePolicy(e){if(!e||"object"!=typeof e)throw new Error("Validation data must be a non-empty object");return this._logger.debug("Validating policy configuration"),this._req("POST","/api/v2/policies/validate",{json:e})}async getPolicySummary(){return this._logger.debug("Fetching policy summary"),this._req("GET","/api/v2/policies/summary")}async getPolicyFilterDefinitions(){return this._logger.debug("Fetching policy filter definitions"),this._req("GET","/api/v2/policies/filter-definitions")}async close(){this._closed||(await this._http.close(),this._closed=!0)}async aclose(){await this.close()}async ensureServerConnected(t,r={}){const{pollSeconds:n=60}=r;if(!R)throw new Error("ensureServerConnected requires Node.js environment for browser opening");let o;try{o=await this.getServer(t)}catch(e){if(e instanceof $&&404===e.statusCode)throw new b(t);throw e}if("connected"===o.connection_status)return;const s=o.slug||t,a=(await this.initiateConnection(s)).auth_url;if(!a)throw new Error("Registry did not return auth_url");const i=e.platform();let c;try{c=new URL(a)}catch{throw new Error("Invalid auth_url returned by server")}if("https:"!==c.protocol&&("http:"!==c.protocol||"localhost"!==c.hostname&&"127.0.0.1"!==c.hostname))throw new Error("Auth URL must use HTTPS (http allowed only for localhost)");try{"darwin"===i?d("open",[a],{detached:!0,stdio:"ignore"}).unref():"win32"===i?d("powershell",["-NoProfile","Start-Process",a],{detached:!0,stdio:"ignore"}).unref():d("xdg-open",[a],{detached:!0,stdio:"ignore"}).unref()}catch(e){this._logger.warn("Failed to open browser",e)}for(let e=0;e<n;e++){if("connected"===await this.getConnectionStatus(s))return;await new Promise(e=>setTimeout(e,1e3))}throw new Error("OAuth connection was not completed in time")}}const Pe=Object.freeze({status:"aborted"});function Se(e,t,r){function n(r,n){var o;Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(o=r._zod).traits??(o.traits=new Set),r._zod.traits.add(e),t(r,n);for(const e in a.prototype)e in r||Object.defineProperty(r,e,{value:a.prototype[e].bind(r)});r._zod.constr=a,r._zod.def=n}const o=r?.Parent??Object;class s extends o{}function a(e){var t;const o=r?.Parent?new s:this;n(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class Te extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ie={};function xe(e){return e&&Object.assign(Ie,e),Ie}function Ne(e,t){return"bigint"==typeof t?t.toString():t}function Ce(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function je(e){return null==e}function Re(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Oe(e,t,r){Object.defineProperty(e,t,{get(){{const n=r();return e[t]=n,n}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function ze(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ae(e){return JSON.stringify(e)}const Me=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function De(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Ue=Ce(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function qe(e){if(!1===De(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!1!==De(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}const Ve=new Set(["string","number","symbol"]);function Fe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Le(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function Ke(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const He={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ze(e,t=0){for(let r=t;r<e.issues.length;r++)if(!0!==e.issues[r]?.continue)return!0;return!1}function Ge(e,t){return t.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function Be(e){return"string"==typeof e?e:e?.message}function Je(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const o=Be(e.inst?._zod.def?.error?.(e))??Be(t?.error?.(e))??Be(r.customError?.(e))??Be(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function We(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function Qe(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}const Ye=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,Ne,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Xe=Se("$ZodError",Ye),et=Se("$ZodError",Ye,{Parent:Error});const tt=e=>(t,r,n,o)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Te;if(a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>Je(e,s,xe())));throw Me(t,o?.callee),t}return a.value},rt=e=>async(t,r,n,o)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>Je(e,s,xe())));throw Me(t,o?.callee),t}return a.value},nt=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Te;return s.issues.length?{success:!1,error:new(e??Xe)(s.issues.map(e=>Je(e,o,xe())))}:{success:!0,data:s.value}},ot=nt(et),st=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>Je(e,o,xe())))}:{success:!0,data:s.value}},at=st(et),it=/^[cC][^\s-]{8,}$/,ct=/^[0-9a-z]+$/,ut=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,lt=/^[0-9a-vA-V]{20}$/,dt=/^[A-Za-z0-9]{27}$/,ht=/^[a-zA-Z0-9_-]{21}$/,pt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ft=/^([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})$/,mt=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)$/,yt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const gt=/^(?:(?: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])$/,vt=/^(([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})$/,_t=/^((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])$/,wt=/^(([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])$/,$t=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bt=/^[A-Za-z0-9_-]*$/,kt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Et=/^\+(?:[0-9]){6,14}[0-9]$/,Pt="(?:(?:\\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])))",St=new RegExp(`^${Pt}$`);function Tt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const It=/^\d+$/,xt=/^-?\d+(?:\.\d+)?/i,Nt=/true|false/i,Ct=/null/i,jt=/^[^A-Z]*$/,Rt=/^[^a-z]*$/,Ot=Se("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),zt={number:"number",bigint:"bigint",object:"date"},At=Se("$ZodCheckLessThan",(e,t)=>{Ot.init(e,t);const r=zt[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Mt=Se("$ZodCheckGreaterThan",(e,t)=>{Ot.init(e,t);const r=zt[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dt=Se("$ZodCheckMultipleOf",(e,t)=>{Ot.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===function(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n;return Number.parseInt(e.toFixed(o).replace(".",""))%Number.parseInt(t.toFixed(o).replace(".",""))/10**o}(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Ut=Se("$ZodCheckNumberFormat",(e,t)=>{Ot.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,s]=He[t.format];e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,n.minimum=o,n.maximum=s,r&&(n.pattern=It)}),e._zod.check=a=>{const i=a.value;if(r){if(!Number.isInteger(i))return void a.issues.push({expected:n,format:t.format,code:"invalid_type",input:i,inst:e});if(!Number.isSafeInteger(i))return void(i>0?a.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):a.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}))}i<o&&a.issues.push({origin:"number",input:i,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),i>s&&a.issues.push({origin:"number",input:i,code:"too_big",maximum:s,inst:e})}}),qt=Se("$ZodCheckMaxLength",(e,t)=>{var r;Ot.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!je(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const n=r.value;if(n.length<=t.maximum)return;const o=We(n);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Vt=Se("$ZodCheckMinLength",(e,t)=>{var r;Ot.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!je(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const n=r.value;if(n.length>=t.minimum)return;const o=We(n);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ft=Se("$ZodCheckLengthEquals",(e,t)=>{var r;Ot.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!je(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{const n=r.value,o=n.length;if(o===t.length)return;const s=We(n),a=o>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Lt=Se("$ZodCheckStringFormat",(e,t)=>{var r,n;Ot.init(e,t),e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Kt=Se("$ZodCheckRegex",(e,t)=>{Lt.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ht=Se("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=jt),Lt.init(e,t)}),Zt=Se("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Rt),Lt.init(e,t)}),Gt=Se("$ZodCheckIncludes",(e,t)=>{Ot.init(e,t);const r=Fe(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Bt=Se("$ZodCheckStartsWith",(e,t)=>{Ot.init(e,t);const r=new RegExp(`^${Fe(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),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})}}),Jt=Se("$ZodCheckEndsWith",(e,t)=>{Ot.init(e,t);const r=new RegExp(`.*${Fe(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),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})}}),Wt=Se("$ZodCheckOverwrite",(e,t)=>{Ot.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Qt{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length)),n=t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e);for(const e of n)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Yt={major:4,minor:0,patch:0},Xt=Se("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Yt;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let n,o=Ze(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===r?.async)throw new Te;if(n||a instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await a;e.issues.length!==t&&(o||(o=Ze(e,t)))});else{if(e.issues.length===t)continue;o||(o=Ze(e,t))}}return n?n.then(()=>e):e};e._zod.run=(r,o)=>{const s=e._zod.parse(r,o);if(s instanceof Promise){if(!1===o.async)throw new Te;return s.then(e=>t(e,n,o))}return t(s,n,o)}}e["~standard"]={validate:t=>{try{const r=ot(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return at(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),er=Se("$ZodString",(e,t)=>{var r;Xt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(r=e._zod.bag,new RegExp(`^${r?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tr=Se("$ZodStringFormat",(e,t)=>{Lt.init(e,t),er.init(e,t)}),rr=Se("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ft),tr.init(e,t)}),nr=Se("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mt(e))}else t.pattern??(t.pattern=mt());tr.init(e,t)}),or=Se("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=yt),tr.init(e,t)}),sr=Se("$ZodURL",(e,t)=>{tr.init(e,t),e._zod.check=r=>{try{const n=r.value,o=new URL(n),s=o.href;return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:kt.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),void(!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s)}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ar=Se("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),tr.init(e,t)}),ir=Se("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ht),tr.init(e,t)}),cr=Se("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=it),tr.init(e,t)}),ur=Se("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ct),tr.init(e,t)}),lr=Se("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ut),tr.init(e,t)}),dr=Se("$ZodXID",(e,t)=>{t.pattern??(t.pattern=lt),tr.init(e,t)}),hr=Se("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=dt),tr.init(e,t)}),pr=Se("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=Tt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Pt}T(?:${n})$`)}(t)),tr.init(e,t)}),fr=Se("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=St),tr.init(e,t)}),mr=Se("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Tt(t)}$`)),tr.init(e,t)}),yr=Se("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pt),tr.init(e,t)}),gr=Se("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=gt),tr.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),vr=Se("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=vt),tr.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),_r=Se("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=_t),tr.init(e,t)}),wr=Se("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=wt),tr.init(e,t),e._zod.check=r=>{const[n,o]=r.value.split("/");try{if(!o)throw new Error;const e=Number(o);if(`${e}`!==o)throw new Error;if(e<0||e>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function $r(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const br=Se("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$t),tr.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{$r(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});const kr=Se("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=bt),tr.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{(function(e){if(!bt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return $r(t.padEnd(4*Math.ceil(t.length/4),"="))})(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Er=Se("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Et),tr.init(e,t)});const Pr=Se("$ZodJWT",(e,t)=>{tr.init(e,t),e._zod.check=r=>{(function(e,t=null){try{const r=e.split(".");if(3!==r.length)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Sr=Se("$ZodNumber",(e,t)=>{Xt.init(e,t),e._zod.pattern=e._zod.bag.pattern??xt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}const o=r.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return r;const s="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Tr=Se("$ZodNumber",(e,t)=>{Ut.init(e,t),Sr.init(e,t)}),Ir=Se("$ZodBoolean",(e,t)=>{Xt.init(e,t),e._zod.pattern=Nt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(e){}const o=r.value;return"boolean"==typeof o||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),xr=Se("$ZodNull",(e,t)=>{Xt.init(e,t),e._zod.pattern=Ct,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{const n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),Nr=Se("$ZodAny",(e,t)=>{Xt.init(e,t),e._zod.parse=e=>e}),Cr=Se("$ZodUnknown",(e,t)=>{Xt.init(e,t),e._zod.parse=e=>e}),jr=Se("$ZodNever",(e,t)=>{Xt.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Rr(e,t,r){e.issues.length&&t.issues.push(...Ge(r,e.issues)),t.value[r]=e.value}const Or=Se("$ZodArray",(e,t)=>{Xt.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const s=[];for(let e=0;e<o.length;e++){const a=o[e],i=t.element._zod.run({value:a,issues:[]},n);i instanceof Promise?s.push(i.then(t=>Rr(t,r,e))):Rr(i,r,e)}return s.length?Promise.all(s).then(()=>r):r}});function zr(e,t,r){e.issues.length&&t.issues.push(...Ge(r,e.issues)),t.value[r]=e.value}function Ar(e,t,r,n){e.issues.length?void 0===n[r]?t.value[r]=r in n?void 0:e.value:t.issues.push(...Ge(r,e.issues)):void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const Mr=Se("$ZodObject",(e,t)=>{Xt.init(e,t);const r=Ce(()=>{const e=Object.keys(t.shape);for(const r of e)if(!(t.shape[r]instanceof Xt))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const r=(n=t.shape,Object.keys(n).filter(e=>"optional"===n[e]._zod.optin&&"optional"===n[e]._zod.optout));var n;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}});Oe(e._zod,"propValues",()=>{const e=t.shape,r={};for(const t in e){const n=e[t]._zod;if(n.values){r[t]??(r[t]=new Set);for(const e of n.values)r[t].add(e)}}return r});let n;const o=De,s=!Ie.jitless,a=s&&Ue.value,i=t.catchall;let c;e._zod.parse=(u,l)=>{c??(c=r.value);const d=u.value;if(!o(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;const h=[];if(s&&a&&!1===l?.async&&!0!==l.jitless)n||(n=(e=>{const t=new Qt(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Ae(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=Object.create(null);let a=0;for(const e of n.keys)s[e]="key_"+a++;t.write("const newResult = {}");for(const e of n.keys)if(n.optionalKeys.has(e)){const r=s[e];t.write(`const ${r} = ${o(e)};`);const n=Ae(e);t.write(`\n if (${r}.issues.length) {\n if (input[${n}] === undefined) {\n if (${n} in input) {\n newResult[${n}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${r}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${n}, ...iss.path] : [${n}],\n }))\n );\n }\n } else if (${r}.value === undefined) {\n if (${n} in input) newResult[${n}] = undefined;\n } else {\n newResult[${n}] = ${r}.value;\n }\n `)}else{const r=s[e];t.write(`const ${r} = ${o(e)};`),t.write(`\n if (${r}.issues.length) payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${Ae(e)}, ...iss.path] : [${Ae(e)}]\n })));`),t.write(`newResult[${Ae(e)}] = ${r}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const i=t.compile();return(t,r)=>i(e,t,r)})(t.shape)),u=n(u,l);else{u.value={};const e=c.shape;for(const t of c.keys){const r=e[t],n=r._zod.run({value:d[t],issues:[]},l),o="optional"===r._zod.optin&&"optional"===r._zod.optout;n instanceof Promise?h.push(n.then(e=>o?Ar(e,u,t,d):zr(e,u,t))):o?Ar(n,u,t,d):zr(n,u,t)}}if(!i)return h.length?Promise.all(h).then(()=>u):u;const p=[],f=c.keySet,m=i._zod,y=m.def.type;for(const e of Object.keys(d)){if(f.has(e))continue;if("never"===y){p.push(e);continue}const t=m.run({value:d[e],issues:[]},l);t instanceof Promise?h.push(t.then(t=>zr(t,u,e))):zr(t,u,e)}return p.length&&u.issues.push({code:"unrecognized_keys",keys:p,input:d,inst:e}),h.length?Promise.all(h).then(()=>u):u}});function Dr(e,t,r,n){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>Je(e,n,xe())))}),t}const Ur=Se("$ZodUnion",(e,t)=>{Xt.init(e,t),Oe(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Oe(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Oe(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Oe(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>Re(e.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let o=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},n);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>Dr(t,r,e,n)):Dr(s,r,e,n)}}),qr=Se("$ZodDiscriminatedUnion",(e,t)=>{Ur.init(e,t);const r=e._zod.parse;Oe(e._zod,"propValues",()=>{const e={};for(const r of t.options){const n=r._zod.propValues;if(!n||0===Object.keys(n).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const[t,r]of Object.entries(n)){e[t]||(e[t]=new Set);for(const n of r)e[t].add(n)}}return e});const n=Ce(()=>{const e=t.options,r=new Map;for(const n of e){const e=n._zod.propValues[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const t of e){if(r.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,n)}}return r});e._zod.parse=(o,s)=>{const a=o.value;if(!De(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const i=n.value.get(a?.[t.discriminator]);return i?i._zod.run(o,s):t.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),o)}}),Vr=Se("$ZodIntersection",(e,t)=>{Xt.init(e,t),e._zod.parse=(e,r)=>{const n=e.value,o=t.left._zod.run({value:n,issues:[]},r),s=t.right._zod.run({value:n,issues:[]},r);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([t,r])=>Lr(e,t,r)):Lr(e,o,s)}});function Fr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(qe(e)&&qe(t)){const r=Object.keys(t),n=Object.keys(e).filter(e=>-1!==r.indexOf(e)),o={...e,...t};for(const r of n){const n=Fr(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};o[r]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=Fr(e[n],t[n]);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Lr(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Ze(e))return e;const n=Fr(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const Kr=Se("$ZodRecord",(e,t)=>{Xt.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!qe(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const s=[];if(t.keyType._zod.values){const a=t.keyType._zod.values;r.value={};for(const e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const a=t.valueType._zod.run({value:o[e],issues:[]},n);a instanceof Promise?s.push(a.then(t=>{t.issues.length&&r.issues.push(...Ge(e,t.issues)),r.value[e]=t.value})):(a.issues.length&&r.issues.push(...Ge(e,a.issues)),r.value[e]=a.value)}let i;for(const e in o)a.has(e)||(i=i??[],i.push(e));i&&i.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:i})}else{r.value={};for(const a of Reflect.ownKeys(o)){if("__proto__"===a)continue;const i=t.keyType._zod.run({value:a,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(i.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:i.issues.map(e=>Je(e,n,xe())),input:a,path:[a],inst:e}),r.value[i.value]=i.value;continue}const c=t.valueType._zod.run({value:o[a],issues:[]},n);c instanceof Promise?s.push(c.then(e=>{e.issues.length&&r.issues.push(...Ge(a,e.issues)),r.value[i.value]=e.value})):(c.issues.length&&r.issues.push(...Ge(a,c.issues)),r.value[i.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}}),Hr=Se("$ZodEnum",(e,t)=>{Xt.init(e,t);const r=function(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(e=>Ve.has(typeof e)).map(e=>"string"==typeof e?Fe(e):e.toString()).join("|")})$`),e._zod.parse=(t,n)=>{const o=t.value;return e._zod.values.has(o)||t.issues.push({code:"invalid_value",values:r,input:o,inst:e}),t}}),Zr=Se("$ZodLiteral",(e,t)=>{Xt.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?Fe(e):e?e.toString():String(e)).join("|")})$`),e._zod.parse=(r,n)=>{const o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),Gr=Se("$ZodTransform",(e,t)=>{Xt.init(e,t),e._zod.parse=(e,r)=>{const n=t.transform(e.value,e);if(r.async){return(n instanceof Promise?n:Promise.resolve(n)).then(t=>(e.value=t,e))}if(n instanceof Promise)throw new Te;return e.value=n,e}}),Br=Se("$ZodOptional",(e,t)=>{Xt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Oe(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Re(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>"optional"===t.innerType._zod.optin?t.innerType._zod.run(e,r):void 0===e.value?e:t.innerType._zod.run(e,r)}),Jr=Se("$ZodNullable",(e,t)=>{Xt.init(e,t),Oe(e._zod,"optin",()=>t.innerType._zod.optin),Oe(e._zod,"optout",()=>t.innerType._zod.optout),Oe(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Re(e.source)}|null)$`):void 0}),Oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),Wr=Se("$ZodDefault",(e,t)=>{Xt.init(e,t),e._zod.optin="optional",Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>Qr(e,t)):Qr(n,t)}});function Qr(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Yr=Se("$ZodPrefault",(e,t)=>{Xt.init(e,t),e._zod.optin="optional",Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),Xr=Se("$ZodNonOptional",(e,t)=>{Xt.init(e,t),Oe(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(t=>en(t,e)):en(o,e)}});function en(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const tn=Se("$ZodCatch",(e,t)=>{Xt.init(e,t),e._zod.optin="optional",Oe(e._zod,"optout",()=>t.innerType._zod.optout),Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>Je(e,r,xe()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>Je(e,r,xe()))},input:e.value}),e.issues=[]),e)}}),rn=Se("$ZodPipe",(e,t)=>{Xt.init(e,t),Oe(e._zod,"values",()=>t.in._zod.values),Oe(e._zod,"optin",()=>t.in._zod.optin),Oe(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(e,r)=>{const n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>nn(e,t,r)):nn(n,t,r)}});function nn(e,t,r){return Ze(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const on=Se("$ZodReadonly",(e,t)=>{Xt.init(e,t),Oe(e._zod,"propValues",()=>t.innerType._zod.propValues),Oe(e._zod,"values",()=>t.innerType._zod.values),Oe(e._zod,"optin",()=>t.innerType._zod.optin),Oe(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,r)=>{const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(sn):sn(n)}});function sn(e){return e.value=Object.freeze(e.value),e}const an=Se("$ZodCustom",(e,t)=>{Ot.init(e,t),Xt.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(t=>cn(t,r,n,e));cn(o,r,n,e)}});function cn(e,t,r,n){if(!e){const e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(Qe(e))}}class un{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const r=t[0];if(this._map.set(e,r),r&&"object"==typeof r&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};return delete r.id,{...r,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function ln(){return new un}const dn=ln();function hn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ke(t)})}function pn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ke(t)})}function fn(e,t){return new At({check:"less_than",...Ke(t),value:e,inclusive:!1})}function mn(e,t){return new At({check:"less_than",...Ke(t),value:e,inclusive:!0})}function yn(e,t){return new Mt({check:"greater_than",...Ke(t),value:e,inclusive:!1})}function gn(e,t){return new Mt({check:"greater_than",...Ke(t),value:e,inclusive:!0})}function vn(e,t){return new Dt({check:"multiple_of",...Ke(t),value:e})}function _n(e,t){return new qt({check:"max_length",...Ke(t),maximum:e})}function wn(e,t){return new Vt({check:"min_length",...Ke(t),minimum:e})}function $n(e,t){return new Ft({check:"length_equals",...Ke(t),length:e})}function bn(e){return new Wt({check:"overwrite",tx:e})}function kn(e){return!!e._zod}function En(e,t){if(kn(e)){return ot(e,t)}return e.safeParse(t)}function Pn(e){if(!e)return;let t;if(kn(e)){const r=e;t=r._zod?.def?.shape}else{t=e.shape}if(t){if("function"==typeof t)try{return t()}catch{return}return t}}const Sn=Se("ZodISODateTime",(e,t)=>{pr.init(e,t),Ln.init(e,t)});function Tn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ke(t)})}(Sn,e)}const In=Se("ZodISODate",(e,t)=>{fr.init(e,t),Ln.init(e,t)});function xn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Ke(t)})}(In,e)}const Nn=Se("ZodISOTime",(e,t)=>{mr.init(e,t),Ln.init(e,t)});function Cn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ke(t)})}(Nn,e)}const jn=Se("ZodISODuration",(e,t)=>{yr.init(e,t),Ln.init(e,t)});function Rn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ke(t)})}(jn,e)}const On=Se("ZodError",(e,t)=>{Xe.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t){const r=t||function(e){return e.message},n={_errors:[]},o=e=>{for(const t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>o({issues:e}));else if("invalid_key"===t.code)o({issues:t.issues});else if("invalid_element"===t.code)o({issues:t.issues});else if(0===t.path.length)n._errors.push(r(t));else{let e=n,o=0;for(;o<t.path.length;){const n=t.path[o];o===t.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(r(t))):e[n]=e[n]||{_errors:[]},e=e[n],o++}}};return o(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),zn=tt(On),An=rt(On),Mn=nt(On),Dn=st(On),Un=Se("ZodType",(e,t)=>(Xt.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,r)=>Le(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>zn(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Mn(e,t,r),e.parseAsync=async(t,r)=>An(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Dn(e,t,r),e.spa=e.safeParseAsync,e.refine=(t,r)=>e.check(function(e,t={}){return function(e,t,r){return new e({type:"custom",check:"custom",fn:t,...Ke(r)})}(Xo,e,t)}(t,r)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new Ot({check:"custom"});return t._zod.check=e,t}(r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(Qe(e,r.value,t._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(Qe(n))}},e(r.value,r)));return t}(t)),e.overwrite=t=>e.check(bn(t)),e.optional=()=>Lo(e),e.nullable=()=>Ho(e),e.nullish=()=>Lo(Ho(e)),e.nonoptional=t=>function(e,t){return new Bo({type:"nonoptional",innerType:e,...Ke(t)})}(e,t),e.array=()=>Eo(e),e.or=t=>xo([e,t]),e.and=t=>Ro(e,t),e.transform=t=>Qo(e,Vo(t)),e.default=t=>{return r=t,new Zo({type:"default",innerType:e,get defaultValue(){return"function"==typeof r?r():r}});var r},e.prefault=t=>{return r=t,new Go({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof r?r():r}});var r},e.catch=t=>{return new Jo({type:"catch",innerType:e,catchValue:"function"==typeof(r=t)?r:()=>r});var r},e.pipe=t=>Qo(e,t),e.readonly=()=>new Yo({type:"readonly",innerType:e}),e.describe=t=>{const r=e.clone();return dn.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>dn.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return dn.get(e);const r=e.clone();return dn.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),qn=Se("_ZodString",(e,t)=>{er.init(e,t),Un.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new Kt({check:"string_format",format:"regex",...Ke(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Gt({check:"string_format",format:"includes",...Ke(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Bt({check:"string_format",format:"starts_with",...Ke(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Jt({check:"string_format",format:"ends_with",...Ke(t),suffix:e})}(...t)),e.min=(...t)=>e.check(wn(...t)),e.max=(...t)=>e.check(_n(...t)),e.length=(...t)=>e.check($n(...t)),e.nonempty=(...t)=>e.check(wn(1,...t)),e.lowercase=t=>e.check(function(e){return new Ht({check:"string_format",format:"lowercase",...Ke(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Zt({check:"string_format",format:"uppercase",...Ke(e)})}(t)),e.trim=()=>e.check(bn(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return bn(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(bn(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(bn(e=>e.toUpperCase()))}),Vn=Se("ZodString",(e,t)=>{er.init(e,t),qn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ke(t)})}(Kn,t)),e.url=t=>e.check(pn(Gn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ke(t)})}(co,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ke(t)})}(Bn,t)),e.guid=t=>e.check(hn(Hn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ke(t)})}(Zn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ke(t)})}(Zn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ke(t)})}(Zn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ke(t)})}(Zn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ke(t)})}(Jn,t)),e.guid=t=>e.check(hn(Hn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ke(t)})}(Wn,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ke(t)})}(Qn,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ke(t)})}(Yn,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ke(t)})}(so,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ke(t)})}(ao,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ke(t)})}(Xn,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ke(t)})}(eo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ke(t)})}(to,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ke(t)})}(ro,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ke(t)})}(no,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ke(t)})}(oo,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ke(t)})}(io,t)),e.datetime=t=>e.check(Tn(t)),e.date=t=>e.check(xn(t)),e.time=t=>e.check(Cn(t)),e.duration=t=>e.check(Rn(t))});function Fn(e){return function(e,t){return new e({type:"string",...Ke(t)})}(Vn,e)}const Ln=Se("ZodStringFormat",(e,t)=>{tr.init(e,t),qn.init(e,t)}),Kn=Se("ZodEmail",(e,t)=>{or.init(e,t),Ln.init(e,t)}),Hn=Se("ZodGUID",(e,t)=>{rr.init(e,t),Ln.init(e,t)}),Zn=Se("ZodUUID",(e,t)=>{nr.init(e,t),Ln.init(e,t)}),Gn=Se("ZodURL",(e,t)=>{sr.init(e,t),Ln.init(e,t)});const Bn=Se("ZodEmoji",(e,t)=>{ar.init(e,t),Ln.init(e,t)}),Jn=Se("ZodNanoID",(e,t)=>{ir.init(e,t),Ln.init(e,t)}),Wn=Se("ZodCUID",(e,t)=>{cr.init(e,t),Ln.init(e,t)}),Qn=Se("ZodCUID2",(e,t)=>{ur.init(e,t),Ln.init(e,t)}),Yn=Se("ZodULID",(e,t)=>{lr.init(e,t),Ln.init(e,t)}),Xn=Se("ZodXID",(e,t)=>{dr.init(e,t),Ln.init(e,t)}),eo=Se("ZodKSUID",(e,t)=>{hr.init(e,t),Ln.init(e,t)}),to=Se("ZodIPv4",(e,t)=>{gr.init(e,t),Ln.init(e,t)}),ro=Se("ZodIPv6",(e,t)=>{vr.init(e,t),Ln.init(e,t)}),no=Se("ZodCIDRv4",(e,t)=>{_r.init(e,t),Ln.init(e,t)}),oo=Se("ZodCIDRv6",(e,t)=>{wr.init(e,t),Ln.init(e,t)}),so=Se("ZodBase64",(e,t)=>{br.init(e,t),Ln.init(e,t)}),ao=Se("ZodBase64URL",(e,t)=>{kr.init(e,t),Ln.init(e,t)}),io=Se("ZodE164",(e,t)=>{Er.init(e,t),Ln.init(e,t)}),co=Se("ZodJWT",(e,t)=>{Pr.init(e,t),Ln.init(e,t)}),uo=Se("ZodNumber",(e,t)=>{Sr.init(e,t),Un.init(e,t),e.gt=(t,r)=>e.check(yn(t,r)),e.gte=(t,r)=>e.check(gn(t,r)),e.min=(t,r)=>e.check(gn(t,r)),e.lt=(t,r)=>e.check(fn(t,r)),e.lte=(t,r)=>e.check(mn(t,r)),e.max=(t,r)=>e.check(mn(t,r)),e.int=t=>e.check(po(t)),e.safe=t=>e.check(po(t)),e.positive=t=>e.check(yn(0,t)),e.nonnegative=t=>e.check(gn(0,t)),e.negative=t=>e.check(fn(0,t)),e.nonpositive=t=>e.check(mn(0,t)),e.multipleOf=(t,r)=>e.check(vn(t,r)),e.step=(t,r)=>e.check(vn(t,r)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function lo(e){return function(e,t){return new e({type:"number",checks:[],...Ke(t)})}(uo,e)}const ho=Se("ZodNumberFormat",(e,t)=>{Tr.init(e,t),uo.init(e,t)});function po(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ke(t)})}(ho,e)}const fo=Se("ZodBoolean",(e,t)=>{Ir.init(e,t),Un.init(e,t)});function mo(e){return function(e,t){return new e({type:"boolean",...Ke(t)})}(fo,e)}const yo=Se("ZodNull",(e,t)=>{xr.init(e,t),Un.init(e,t)});function go(e){return function(e,t){return new e({type:"null",...Ke(t)})}(yo,e)}const vo=Se("ZodAny",(e,t)=>{Nr.init(e,t),Un.init(e,t)});const _o=Se("ZodUnknown",(e,t)=>{Cr.init(e,t),Un.init(e,t)});function wo(){return new _o({type:"unknown"})}const $o=Se("ZodNever",(e,t)=>{jr.init(e,t),Un.init(e,t)});function bo(e){return function(e,t){return new e({type:"never",...Ke(t)})}($o,e)}const ko=Se("ZodArray",(e,t)=>{Or.init(e,t),Un.init(e,t),e.element=t.element,e.min=(t,r)=>e.check(wn(t,r)),e.nonempty=t=>e.check(wn(1,t)),e.max=(t,r)=>e.check(_n(t,r)),e.length=(t,r)=>e.check($n(t,r)),e.unwrap=()=>e.element});function Eo(e,t){return function(e,t,r){return new e({type:"array",element:t,...Ke(r)})}(ko,e,t)}const Po=Se("ZodObject",(e,t)=>{Mr.init(e,t),Un.init(e,t),Oe(e,"shape",()=>t.shape),e.keyof=()=>Mo(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:wo()}),e.loose=()=>e.clone({...e._zod.def,catchall:wo()}),e.strict=()=>e.clone({...e._zod.def,catchall:bo()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!qe(t))throw new Error("Invalid input to extend: expected a plain object");const r={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return ze(this,"shape",r),r},checks:[]};return Le(e,r)}(e,t),e.merge=t=>{return n=t,Le(r=e,{...r._zod.def,get shape(){const e={...r._zod.def.shape,...n._zod.def.shape};return ze(this,"shape",e),e},catchall:n._zod.def.catchall,checks:[]});var r,n},e.pick=t=>function(e,t){const r={},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(r[e]=n.shape[e])}return Le(e,{...e._zod.def,shape:r,checks:[]})}(e,t),e.omit=t=>function(e,t){const r={...e._zod.def.shape},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Le(e,{...e._zod.def,shape:r,checks:[]})}(e,t),e.partial=(...t)=>function(e,t,r){const n=t._zod.def.shape,o={...n};if(r)for(const t in r){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(o[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)o[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return Le(t,{...t._zod.def,shape:o,checks:[]})}(Fo,e,t[0]),e.required=(...t)=>function(e,t,r){const n=t._zod.def.shape,o={...n};if(r)for(const t in r){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(o[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(const t in n)o[t]=new e({type:"nonoptional",innerType:n[t]});return Le(t,{...t._zod.def,shape:o,checks:[]})}(Bo,e,t[0])});function So(e,t){const r={type:"object",get shape(){return ze(this,"shape",{...e}),this.shape},...Ke(t)};return new Po(r)}function To(e,t){return new Po({type:"object",get shape(){return ze(this,"shape",{...e}),this.shape},catchall:wo(),...Ke(t)})}const Io=Se("ZodUnion",(e,t)=>{Ur.init(e,t),Un.init(e,t),e.options=t.options});function xo(e,t){return new Io({type:"union",options:e,...Ke(t)})}const No=Se("ZodDiscriminatedUnion",(e,t)=>{Io.init(e,t),qr.init(e,t)});function Co(e,t,r){return new No({type:"union",options:t,discriminator:e,...Ke(r)})}const jo=Se("ZodIntersection",(e,t)=>{Vr.init(e,t),Un.init(e,t)});function Ro(e,t){return new jo({type:"intersection",left:e,right:t})}const Oo=Se("ZodRecord",(e,t)=>{Kr.init(e,t),Un.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function zo(e,t,r){return new Oo({type:"record",keyType:e,valueType:t,...Ke(r)})}const Ao=Se("ZodEnum",(e,t)=>{Hr.init(e,t),Un.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const o={};for(const n of e){if(!r.has(n))throw new Error(`Key ${n} not found in enum`);o[n]=t.entries[n]}return new Ao({...t,checks:[],...Ke(n),entries:o})},e.exclude=(e,n)=>{const o={...t.entries};for(const t of e){if(!r.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new Ao({...t,checks:[],...Ke(n),entries:o})}});function Mo(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ao({type:"enum",entries:r,...Ke(t)})}const Do=Se("ZodLiteral",(e,t)=>{Zr.init(e,t),Un.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Uo(e,t){return new Do({type:"literal",values:Array.isArray(e)?e:[e],...Ke(t)})}const qo=Se("ZodTransform",(e,t)=>{Gr.init(e,t),Un.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=n=>{if("string"==typeof n)r.issues.push(Qe(n,r.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),t.continue??(t.continue=!0),r.issues.push(Qe(t))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(e=>(r.value=e,r)):(r.value=o,r)}});function Vo(e){return new qo({type:"transform",transform:e})}const Fo=Se("ZodOptional",(e,t)=>{Br.init(e,t),Un.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Lo(e){return new Fo({type:"optional",innerType:e})}const Ko=Se("ZodNullable",(e,t)=>{Jr.init(e,t),Un.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ho(e){return new Ko({type:"nullable",innerType:e})}const Zo=Se("ZodDefault",(e,t)=>{Wr.init(e,t),Un.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const Go=Se("ZodPrefault",(e,t)=>{Yr.init(e,t),Un.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Bo=Se("ZodNonOptional",(e,t)=>{Xr.init(e,t),Un.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Jo=Se("ZodCatch",(e,t)=>{tn.init(e,t),Un.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Wo=Se("ZodPipe",(e,t)=>{rn.init(e,t),Un.init(e,t),e.in=t.in,e.out=t.out});function Qo(e,t){return new Wo({type:"pipe",in:e,out:t})}const Yo=Se("ZodReadonly",(e,t)=>{on.init(e,t),Un.init(e,t)});const Xo=Se("ZodCustom",(e,t)=>{an.init(e,t),Un.init(e,t)});function es(e,t){return Qo(Vo(e),t)}const ts="custom";const rs="2025-11-25",ns=[rs,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],os="io.modelcontextprotocol/related-task",ss="2.0",as=function(e,t,r){const n=Ke(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}(Xo,(e=>null!==e&&("object"==typeof e||"function"==typeof e))??(()=>!0),is);var is;const cs=xo([Fn(),lo().int()]),us=Fn();To({ttl:xo([lo(),go()]).optional(),pollInterval:lo().optional()});const ls=So({ttl:lo().optional()}),ds=So({taskId:Fn()}),hs=To({progressToken:cs.optional(),[os]:ds.optional()}),ps=So({_meta:hs.optional()}),fs=ps.extend({task:ls.optional()}),ms=So({method:Fn(),params:ps.loose().optional()}),ys=So({_meta:hs.optional()}),gs=So({method:Fn(),params:ys.loose().optional()}),vs=To({_meta:hs.optional()}),_s=xo([Fn(),lo().int()]),ws=So({jsonrpc:Uo(ss),id:_s,...ms.shape}).strict(),$s=e=>ws.safeParse(e).success,bs=So({jsonrpc:Uo(ss),...gs.shape}).strict(),ks=So({jsonrpc:Uo(ss),id:_s,result:vs}).strict(),Es=e=>ks.safeParse(e).success;var Ps;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"}(Ps||(Ps={}));const Ss=So({jsonrpc:Uo(ss),id:_s.optional(),error:So({code:lo().int(),message:Fn(),data:wo().optional()})}).strict(),Ts=xo([ws,bs,ks,Ss]);xo([ks,Ss]);const Is=vs.strict(),xs=ys.extend({requestId:_s.optional(),reason:Fn().optional()}),Ns=gs.extend({method:Uo("notifications/cancelled"),params:xs}),Cs=So({src:Fn(),mimeType:Fn().optional(),sizes:Eo(Fn()).optional(),theme:Mo(["light","dark"]).optional()}),js=So({icons:Eo(Cs).optional()}),Rs=So({name:Fn(),title:Fn().optional()}),Os=Rs.extend({...Rs.shape,...js.shape,version:Fn(),websiteUrl:Fn().optional(),description:Fn().optional()}),zs=Ro(So({applyDefaults:mo().optional()}),zo(Fn(),wo())),As=es(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,Ro(So({form:zs.optional(),url:as.optional()}),zo(Fn(),wo()).optional())),Ms=To({list:as.optional(),cancel:as.optional(),requests:To({sampling:To({createMessage:as.optional()}).optional(),elicitation:To({create:as.optional()}).optional()}).optional()}),Ds=To({list:as.optional(),cancel:as.optional(),requests:To({tools:To({call:as.optional()}).optional()}).optional()}),Us=So({experimental:zo(Fn(),as).optional(),sampling:So({context:as.optional(),tools:as.optional()}).optional(),elicitation:As.optional(),roots:So({listChanged:mo().optional()}).optional(),tasks:Ms.optional()}),qs=ps.extend({protocolVersion:Fn(),capabilities:Us,clientInfo:Os}),Vs=ms.extend({method:Uo("initialize"),params:qs}),Fs=So({experimental:zo(Fn(),as).optional(),logging:as.optional(),completions:as.optional(),prompts:So({listChanged:mo().optional()}).optional(),resources:So({subscribe:mo().optional(),listChanged:mo().optional()}).optional(),tools:So({listChanged:mo().optional()}).optional(),tasks:Ds.optional()}),Ls=vs.extend({protocolVersion:Fn(),capabilities:Fs,serverInfo:Os,instructions:Fn().optional()}),Ks=gs.extend({method:Uo("notifications/initialized"),params:ys.optional()}),Hs=ms.extend({method:Uo("ping"),params:ps.optional()}),Zs=So({progress:lo(),total:Lo(lo()),message:Lo(Fn())}),Gs=So({...ys.shape,...Zs.shape,progressToken:cs}),Bs=gs.extend({method:Uo("notifications/progress"),params:Gs}),Js=ps.extend({cursor:us.optional()}),Ws=ms.extend({params:Js.optional()}),Qs=vs.extend({nextCursor:us.optional()}),Ys=Mo(["working","input_required","completed","failed","cancelled"]),Xs=So({taskId:Fn(),status:Ys,ttl:xo([lo(),go()]),createdAt:Fn(),lastUpdatedAt:Fn(),pollInterval:Lo(lo()),statusMessage:Lo(Fn())}),ea=vs.extend({task:Xs}),ta=ys.merge(Xs),ra=gs.extend({method:Uo("notifications/tasks/status"),params:ta}),na=ms.extend({method:Uo("tasks/get"),params:ps.extend({taskId:Fn()})}),oa=vs.merge(Xs),sa=ms.extend({method:Uo("tasks/result"),params:ps.extend({taskId:Fn()})});vs.loose();const aa=Ws.extend({method:Uo("tasks/list")}),ia=Qs.extend({tasks:Eo(Xs)}),ca=ms.extend({method:Uo("tasks/cancel"),params:ps.extend({taskId:Fn()})}),ua=vs.merge(Xs),la=So({uri:Fn(),mimeType:Lo(Fn()),_meta:zo(Fn(),wo()).optional()}),da=la.extend({text:Fn()}),ha=Fn().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),pa=la.extend({blob:ha}),fa=Mo(["user","assistant"]),ma=So({audience:Eo(fa).optional(),priority:lo().min(0).max(1).optional(),lastModified:Tn({offset:!0}).optional()}),ya=So({...Rs.shape,...js.shape,uri:Fn(),description:Lo(Fn()),mimeType:Lo(Fn()),annotations:ma.optional(),_meta:Lo(To({}))}),ga=So({...Rs.shape,...js.shape,uriTemplate:Fn(),description:Lo(Fn()),mimeType:Lo(Fn()),annotations:ma.optional(),_meta:Lo(To({}))}),va=Ws.extend({method:Uo("resources/list")}),_a=Qs.extend({resources:Eo(ya)}),wa=Ws.extend({method:Uo("resources/templates/list")}),$a=Qs.extend({resourceTemplates:Eo(ga)}),ba=ps.extend({uri:Fn()}),ka=ba,Ea=ms.extend({method:Uo("resources/read"),params:ka}),Pa=vs.extend({contents:Eo(xo([da,pa]))}),Sa=gs.extend({method:Uo("notifications/resources/list_changed"),params:ys.optional()}),Ta=ba,Ia=ms.extend({method:Uo("resources/subscribe"),params:Ta}),xa=ba,Na=ms.extend({method:Uo("resources/unsubscribe"),params:xa}),Ca=ys.extend({uri:Fn()}),ja=gs.extend({method:Uo("notifications/resources/updated"),params:Ca}),Ra=So({name:Fn(),description:Lo(Fn()),required:Lo(mo())}),Oa=So({...Rs.shape,...js.shape,description:Lo(Fn()),arguments:Lo(Eo(Ra)),_meta:Lo(To({}))}),za=Ws.extend({method:Uo("prompts/list")}),Aa=Qs.extend({prompts:Eo(Oa)}),Ma=ps.extend({name:Fn(),arguments:zo(Fn(),Fn()).optional()}),Da=ms.extend({method:Uo("prompts/get"),params:Ma}),Ua=So({type:Uo("text"),text:Fn(),annotations:ma.optional(),_meta:zo(Fn(),wo()).optional()}),qa=So({type:Uo("image"),data:ha,mimeType:Fn(),annotations:ma.optional(),_meta:zo(Fn(),wo()).optional()}),Va=So({type:Uo("audio"),data:ha,mimeType:Fn(),annotations:ma.optional(),_meta:zo(Fn(),wo()).optional()}),Fa=So({type:Uo("tool_use"),name:Fn(),id:Fn(),input:zo(Fn(),wo()),_meta:zo(Fn(),wo()).optional()}),La=So({type:Uo("resource"),resource:xo([da,pa]),annotations:ma.optional(),_meta:zo(Fn(),wo()).optional()}),Ka=xo([Ua,qa,Va,ya.extend({type:Uo("resource_link")}),La]),Ha=So({role:fa,content:Ka}),Za=vs.extend({description:Fn().optional(),messages:Eo(Ha)}),Ga=gs.extend({method:Uo("notifications/prompts/list_changed"),params:ys.optional()}),Ba=So({title:Fn().optional(),readOnlyHint:mo().optional(),destructiveHint:mo().optional(),idempotentHint:mo().optional(),openWorldHint:mo().optional()}),Ja=So({taskSupport:Mo(["required","optional","forbidden"]).optional()}),Wa=So({...Rs.shape,...js.shape,description:Fn().optional(),inputSchema:So({type:Uo("object"),properties:zo(Fn(),as).optional(),required:Eo(Fn()).optional()}).catchall(wo()),outputSchema:So({type:Uo("object"),properties:zo(Fn(),as).optional(),required:Eo(Fn()).optional()}).catchall(wo()).optional(),annotations:Ba.optional(),execution:Ja.optional(),_meta:zo(Fn(),wo()).optional()}),Qa=Ws.extend({method:Uo("tools/list")}),Ya=Qs.extend({tools:Eo(Wa)}),Xa=vs.extend({content:Eo(Ka).default([]),structuredContent:zo(Fn(),wo()).optional(),isError:mo().optional()});Xa.or(vs.extend({toolResult:wo()}));const ei=fs.extend({name:Fn(),arguments:zo(Fn(),wo()).optional()}),ti=ms.extend({method:Uo("tools/call"),params:ei}),ri=gs.extend({method:Uo("notifications/tools/list_changed"),params:ys.optional()}),ni=So({autoRefresh:mo().default(!0),debounceMs:lo().int().nonnegative().default(300)}),oi=Mo(["debug","info","notice","warning","error","critical","alert","emergency"]),si=ps.extend({level:oi}),ai=ms.extend({method:Uo("logging/setLevel"),params:si}),ii=ys.extend({level:oi,logger:Fn().optional(),data:wo()}),ci=gs.extend({method:Uo("notifications/message"),params:ii}),ui=So({name:Fn().optional()}),li=So({hints:Eo(ui).optional(),costPriority:lo().min(0).max(1).optional(),speedPriority:lo().min(0).max(1).optional(),intelligencePriority:lo().min(0).max(1).optional()}),di=So({mode:Mo(["auto","required","none"]).optional()}),hi=So({type:Uo("tool_result"),toolUseId:Fn().describe("The unique identifier for the corresponding tool call."),content:Eo(Ka).default([]),structuredContent:So({}).loose().optional(),isError:mo().optional(),_meta:zo(Fn(),wo()).optional()}),pi=Co("type",[Ua,qa,Va]),fi=Co("type",[Ua,qa,Va,Fa,hi]),mi=So({role:fa,content:xo([fi,Eo(fi)]),_meta:zo(Fn(),wo()).optional()}),yi=fs.extend({messages:Eo(mi),modelPreferences:li.optional(),systemPrompt:Fn().optional(),includeContext:Mo(["none","thisServer","allServers"]).optional(),temperature:lo().optional(),maxTokens:lo().int(),stopSequences:Eo(Fn()).optional(),metadata:as.optional(),tools:Eo(Wa).optional(),toolChoice:di.optional()}),gi=ms.extend({method:Uo("sampling/createMessage"),params:yi}),vi=vs.extend({model:Fn(),stopReason:Lo(Mo(["endTurn","stopSequence","maxTokens"]).or(Fn())),role:fa,content:pi}),_i=vs.extend({model:Fn(),stopReason:Lo(Mo(["endTurn","stopSequence","maxTokens","toolUse"]).or(Fn())),role:fa,content:xo([fi,Eo(fi)])}),wi=So({type:Uo("boolean"),title:Fn().optional(),description:Fn().optional(),default:mo().optional()}),$i=So({type:Uo("string"),title:Fn().optional(),description:Fn().optional(),minLength:lo().optional(),maxLength:lo().optional(),format:Mo(["email","uri","date","date-time"]).optional(),default:Fn().optional()}),bi=So({type:Mo(["number","integer"]),title:Fn().optional(),description:Fn().optional(),minimum:lo().optional(),maximum:lo().optional(),default:lo().optional()}),ki=So({type:Uo("string"),title:Fn().optional(),description:Fn().optional(),enum:Eo(Fn()),default:Fn().optional()}),Ei=So({type:Uo("string"),title:Fn().optional(),description:Fn().optional(),oneOf:Eo(So({const:Fn(),title:Fn()})),default:Fn().optional()}),Pi=So({type:Uo("string"),title:Fn().optional(),description:Fn().optional(),enum:Eo(Fn()),enumNames:Eo(Fn()).optional(),default:Fn().optional()}),Si=xo([ki,Ei]),Ti=xo([So({type:Uo("array"),title:Fn().optional(),description:Fn().optional(),minItems:lo().optional(),maxItems:lo().optional(),items:So({type:Uo("string"),enum:Eo(Fn())}),default:Eo(Fn()).optional()}),So({type:Uo("array"),title:Fn().optional(),description:Fn().optional(),minItems:lo().optional(),maxItems:lo().optional(),items:So({anyOf:Eo(So({const:Fn(),title:Fn()}))}),default:Eo(Fn()).optional()})]),Ii=xo([Pi,Si,Ti]),xi=xo([Ii,wi,$i,bi]),Ni=xo([fs.extend({mode:Uo("form").optional(),message:Fn(),requestedSchema:So({type:Uo("object"),properties:zo(Fn(),xi),required:Eo(Fn()).optional()})}),fs.extend({mode:Uo("url"),message:Fn(),elicitationId:Fn(),url:Fn().url()})]),Ci=ms.extend({method:Uo("elicitation/create"),params:Ni}),ji=ys.extend({elicitationId:Fn()}),Ri=gs.extend({method:Uo("notifications/elicitation/complete"),params:ji}),Oi=vs.extend({action:Mo(["accept","decline","cancel"]),content:es(e=>null===e?void 0:e,zo(Fn(),xo([Fn(),lo(),mo(),Eo(Fn())])).optional())}),zi=So({type:Uo("ref/resource"),uri:Fn()}),Ai=So({type:Uo("ref/prompt"),name:Fn()}),Mi=ps.extend({ref:xo([Ai,zi]),argument:So({name:Fn(),value:Fn()}),context:So({arguments:zo(Fn(),Fn()).optional()}).optional()}),Di=ms.extend({method:Uo("completion/complete"),params:Mi}),Ui=vs.extend({completion:To({values:Eo(Fn()).max(100),total:Lo(lo().int()),hasMore:Lo(mo())})}),qi=So({uri:Fn().startsWith("file://"),name:Fn().optional(),_meta:zo(Fn(),wo()).optional()}),Vi=ms.extend({method:Uo("roots/list"),params:ps.optional()}),Fi=vs.extend({roots:Eo(qi)}),Li=gs.extend({method:Uo("notifications/roots/list_changed"),params:ys.optional()});xo([Hs,Vs,Di,ai,Da,za,va,wa,Ea,Ia,Na,ti,Qa,na,sa,aa,ca]),xo([Ns,Bs,Ks,Li,ra]),xo([Is,vi,_i,Oi,Fi,oa,ia,ea]),xo([Hs,gi,Ci,Vi,na,sa,aa,ca]),xo([Ns,Bs,ci,ja,Sa,ri,Ga,ra,Ri]),xo([Is,Ls,Ui,Za,Aa,_a,$a,Pa,Xa,Ya,oa,ia,ea]);class Ki extends Error{constructor(e,t,r){super(`MCP error ${e}: ${t}`),this.code=e,this.data=r,this.name="McpError"}static fromError(e,t,r){if(e===Ps.UrlElicitationRequired&&r){const e=r;if(e.elicitations)return new Hi(e.elicitations,t)}return new Ki(e,t,r)}}class Hi extends Ki{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Ps.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}function Zi(e){return"completed"===e||"failed"===e||"cancelled"===e}function Gi(e){const t=Pn(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=function(e){if(kn(e)){const t=e,r=t._zod?.def;if(r){if(void 0!==r.value)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}}const t=e._def;if(t){if(void 0!==t.value)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const r=e.value;if(void 0!==r)return r}(r);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function Bi(e,t){const r=En(e,t);if(!r.success)throw r.error;return r.data}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");class Ji{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ns,e=>{this._oncancel(e)}),this.setNotificationHandler(Bs,e=>{this._onprogress(e)}),this.setRequestHandler(Hs,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(na,async(e,t)=>{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new Ki(Ps.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(sa,async(e,t)=>{const r=async()=>{const n=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(n,t.sessionId);){if("response"===e.type||"error"===e.type){const t=e.message,r=t.id,n=this._requestResolvers.get(r);if(n)if(this._requestResolvers.delete(r),"response"===e.type)n(t);else{const e=t;n(new Ki(e.error.code,e.error.message,e.error.data))}else{const t="response"===e.type?"Response":"Error";this._onerror(new Error(`${t} handler missing for request ${r}`))}continue}await(this._transport?.send(e.message,{relatedRequestId:t.requestId}))}}const o=await this._taskStore.getTask(n,t.sessionId);if(!o)throw new Ki(Ps.InvalidParams,`Task not found: ${n}`);if(!Zi(o.status))return await this._waitForTaskUpdate(n,t.signal),await r();if(Zi(o.status)){const e=await this._taskStore.getTaskResult(n,t.sessionId);return this._clearTaskQueue(n),{...e,_meta:{...e._meta,[os]:{taskId:n}}}}return await r()};return await r()}),this.setRequestHandler(aa,async(e,t)=>{try{const{tasks:r,nextCursor:n}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:r,nextCursor:n,_meta:{}}}catch(e){throw new Ki(Ps.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(ca,async(e,t)=>{try{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new Ki(Ps.InvalidParams,`Task not found: ${e.params.taskId}`);if(Zi(r.status))throw new Ki(Ps.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new Ki(Ps.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof Ki)throw e;throw new Ki(Ps.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;const t=this._requestHandlerAbortControllers.get(e.params.requestId);t?.abort(e.params.reason)}_setupTimeout(e,t,r,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:n})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),Ki.fromError(Ps.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=e=>{r?.(e),this._onerror(e)};const n=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{var r;n?.(e,t),Es(e)||(r=e,Ss.safeParse(r).success)?this._onresponse(e):$s(e)?this._onrequest(e,t):(e=>bs.safeParse(e).success)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();const t=Ki.fromError(Ps.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of e.values())r(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;void 0!==t&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){const r=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,n=this._transport,o=e.params?._meta?.[os]?.taskId;if(void 0===r){const t={jsonrpc:"2.0",id:e.id,error:{code:Ps.MethodNotFound,message:"Method not found"}};return void(o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:t,timestamp:Date.now()},n?.sessionId).catch(e=>this._onerror(new Error(`Failed to enqueue error response: ${e}`))):n?.send(t).catch(e=>this._onerror(new Error(`Failed to send an error response: ${e}`))))}const s=new AbortController;this._requestHandlerAbortControllers.set(e.id,s);const a=(i=e.params,fs.safeParse(i).success?e.params.task:void 0);var i;const c=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,u={signal:s.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(s.signal.aborted)return;const r={relatedRequestId:e.id};o&&(r.relatedTask={taskId:o}),await this.notification(t,r)},sendRequest:async(t,r,n)=>{if(s.signal.aborted)throw new Ki(Ps.ConnectionClosed,"Request was cancelled");const a={...n,relatedRequestId:e.id};o&&!a.relatedTask&&(a.relatedTask={taskId:o});const i=a.relatedTask?.taskId??o;return i&&c&&await c.updateTaskStatus(i,"input_required"),await this.request(t,r,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>r(e,u)).then(async t=>{if(s.signal.aborted)return;const r={result:t,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))},async t=>{if(s.signal.aborted)return;const r={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:Ps.InternalError,message:t.message??"Internal error",...void 0!==t.data&&{data:t.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))}).catch(e=>this._onerror(new Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...r}=e.params,n=Number(t),o=this._progressHandlers.get(n);if(!o)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const s=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(e){return this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),void s(e)}o(r)}_onresponse(e){const t=Number(e.id),r=this._requestResolvers.get(t);if(r){if(this._requestResolvers.delete(t),Es(e))r(e);else{r(new Ki(e.error.code,e.error.message,e.error.data))}return}const n=this._responseHandlers.get(t);if(void 0===n)return void this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));this._responseHandlers.delete(t),this._cleanupTimeout(t);let o=!1;if(Es(e)&&e.result&&"object"==typeof e.result){const r=e.result;if(r.task&&"object"==typeof r.task){const e=r.task;"string"==typeof e.taskId&&(o=!0,this._taskProgressTokens.set(e.taskId,t))}}if(o||this._progressHandlers.delete(t),Es(e))n(e);else{n(Ki.fromError(e.error.code,e.error.message,e.error.data))}}get transport(){return this._transport}async close(){await(this._transport?.close())}async*requestStream(e,t,r){const{task:n}=r??{};if(!n){try{const n=await this.request(e,t,r);yield{type:"result",result:n}}catch(e){yield{type:"error",error:e instanceof Ki?e:new Ki(Ps.InternalError,String(e))}}return}let o;try{const n=await this.request(e,ea,r);if(!n.task)throw new Ki(Ps.InternalError,"Task creation did not return a task");for(o=n.task.taskId,yield{type:"taskCreated",task:n.task};;){const e=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:e},Zi(e.status)){if("completed"===e.status){const e=await this.getTaskResult({taskId:o},t,r);yield{type:"result",result:e}}else"failed"===e.status?yield{type:"error",error:new Ki(Ps.InternalError,`Task ${o} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new Ki(Ps.InternalError,`Task ${o} was cancelled`)});return}if("input_required"===e.status){const e=await this.getTaskResult({taskId:o},t,r);return void(yield{type:"result",result:e})}const n=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,n)),r?.signal?.throwIfAborted()}}catch(e){yield{type:"error",error:e instanceof Ki?e:new Ki(Ps.InternalError,String(e))}}}request(e,t,r){const{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:i}=r??{};return new Promise((c,u)=>{const l=e=>{u(e)};if(!this._transport)return void l(new Error("Not connected"));if(!0===this._options?.enforceStrictCapabilities)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(e){return void l(e)}r?.signal?.throwIfAborted();const d=this._requestMessageId++,h={...e,jsonrpc:"2.0",id:d};r?.onprogress&&(this._progressHandlers.set(d,r.onprogress),h.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),a&&(h.params={...h.params,task:a}),i&&(h.params={...h.params,_meta:{...h.params?._meta||{},[os]:i}});const p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:d,reason:String(e)}},{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)));const t=e instanceof Ki?e:new Ki(Ps.RequestTimeout,String(e));u(t)};this._responseHandlers.set(d,e=>{if(!r?.signal?.aborted){if(e instanceof Error)return u(e);try{const r=En(t,e.result);r.success?c(r.data):u(r.error)}catch(e){u(e)}}}),r?.signal?.addEventListener("abort",()=>{p(r?.signal?.reason)});const f=r?.timeout??6e4;this._setupTimeout(d,f,r?.maxTotalTimeout,()=>p(Ki.fromError(Ps.RequestTimeout,"Request timed out",{timeout:f})),r?.resetTimeoutOnProgress??!1);const m=i?.taskId;if(m){const e=e=>{const t=this._responseHandlers.get(d);t?t(e):this._onerror(new Error(`Response handler missing for side-channeled request ${d}`))};this._requestResolvers.set(d,e),this._enqueueTaskMessage(m,{type:"request",message:h,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),u(e)})}else this._transport.send(h,{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(e=>{this._cleanupTimeout(d),u(e)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},oa,t)}async getTaskResult(e,t,r){return this.request({method:"tasks/result",params:e},t,r)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},ia,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},ua,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const r=t?.relatedTask?.taskId;if(r){const n={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[os]:t.relatedTask}}};return void await this._enqueueTaskMessage(r,{type:"notification",message:n,timestamp:Date.now()})}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let r={...e,jsonrpc:"2.0"};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[os]:t.relatedTask}}}),this._transport?.send(r,t).catch(e=>this._onerror(e))})}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[os]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const r=Gi(e);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(r,n)=>{const o=Bi(e,r);return Promise.resolve(t(o,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const r=Gi(e);this._notificationHandlers.set(r,r=>{const n=Bi(e,r);return Promise.resolve(t(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);void 0!==t&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,r,n)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(e,t);for(const t of r)if("request"===t.type&&$s(t.message)){const r=t.message.id,n=this._requestResolvers.get(r);n?(n(new Ki(Ps.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(r)):this._onerror(new Error(`Resolver missing for request ${r} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let r=this._options?.defaultTaskPollInterval??1e3;try{const t=await(this._taskStore?.getTask(e));t?.pollInterval&&(r=t.pollInterval)}catch{}return new Promise((e,n)=>{if(t.aborted)return void n(new Ki(Ps.InvalidRequest,"Request cancelled"));const o=setTimeout(e,r);t.addEventListener("abort",()=>{clearTimeout(o),n(new Ki(Ps.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await r.createTask(n,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{const n=await r.getTask(e,t);if(!n)throw new Ki(Ps.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(e,n,o)=>{await r.storeTaskResult(e,n,o,t);const s=await r.getTask(e,t);if(s){const t=ra.parse({method:"notifications/tasks/status",params:s});await this.notification(t),Zi(s.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>r.getTaskResult(e,t),updateTaskStatus:async(e,n,o)=>{const s=await r.getTask(e,t);if(!s)throw new Ki(Ps.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Zi(s.status))throw new Ki(Ps.InvalidParams,`Cannot update task "${e}" from terminal status "${s.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(e,n,o,t);const a=await r.getTask(e,t);if(a){const t=ra.parse({method:"notifications/tasks/status",params:a});await this.notification(t),Zi(a.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>r.listTasks(e,t)}}}function Wi(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Qi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Yi,Xi={exports:{}},ec={},tc={},rc={},nc={},oc={},sc={};function ac(){return Yi||(Yi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function o(e,...t){const r=[e[0]];let o=0;for(;o<t.length;)i(r,t[o]),r.push(e[++o]);return new n(r)}e._Code=n,e.nil=new n(""),e._=o;const s=new n("+");function a(e,...t){const r=[u(e[0])];let o=0;for(;o<t.length;)r.push(s),i(r,t[o]),r.push(s,u(e[++o]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===s){const r=c(e[t-1],e[t+1]);if(void 0!==r){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}(r),new n(r)}function i(e,t){var o;t instanceof n?e.push(...t._items):t instanceof r?e.push(t):e.push("number"==typeof(o=t)||"boolean"==typeof o||null===o?o:u(Array.isArray(o)?o.join(","):o))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof r||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof r?void 0:`"${e}${t.slice(1)}`}function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=a,e.addCodeArg=i,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:a`${e}${t}`},e.stringify=function(e){return new n(u(e))},e.safeStringify=u,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):o`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(e){return new n(e.toString())}}(sc)),sc}var ic,cc,uc={};function lc(){return ic||(ic=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=ac();class r extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var n;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class o{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,r;if((null===(r=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===r?void 0:r.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}e.Scope=o;class s extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=t._`.${new t.Name(r)}[${n}]`}}e.ValueScopeName=s;const a=t._`\n`;e.ValueScope=class extends o{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?a:t.nil}}get(){return this._scope}name(e){return new s(e,this._newName(e))}value(e,t){var r;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const n=this.toName(e),{prefix:o}=n,s=null!==(r=t.key)&&void 0!==r?r:t.ref;let a=this._values[o];if(a){const e=a.get(s);if(e)return e}else a=this._values[o]=new Map;a.set(s,n);const i=this._scope[o]||(this._scope[o]=[]),c=i.length;return i[c]=t.ref,n.setValue(t,{property:o,itemIndex:c}),n}getValue(e,t){const r=this._values[e];if(r)return r.get(t)}scopeRefs(e,r=this._values){return this._reduceValues(r,r=>{if(void 0===r.scopePath)throw new Error(`CodeGen: name "${r}" has no value`);return t._`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,r)}_reduceValues(o,s,a={},i){let c=t.nil;for(const u in o){const l=o[u];if(!l)continue;const d=a[u]=a[u]||new Map;l.forEach(o=>{if(d.has(o))return;d.set(o,n.Started);let a=s(o);if(a){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${o} = ${a};${this.opts._n}`}else{if(!(a=null==i?void 0:i(o)))throw new r(o);c=t._`${c}${a}${this.opts._n}`}d.set(o,n.Completed)})}return c}}}(uc)),uc}function dc(){return cc||(cc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=ac(),r=lc();var n=ac();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var o=lc();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class s{optimizeNodes(){return this}optimizeNames(e,t){return this}}class a extends s{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r}render({es5:e,_n:t}){const n=e?r.varKinds.var:this.varKind,o=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=x(this.rhs,e,t)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends s{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof t.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=x(this.rhs,e,r),this}get names(){return I(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}}class c extends i{constructor(e,t,r,n){super(e,r,n),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class u extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class l extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class d extends s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class h extends s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=x(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class p extends s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:r}=this;let n=r.length;for(;n--;){const o=r[n];o.optimizeNames(e,t)||(N(e,o.names),r.splice(n,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>T(e,t.names),{})}}class f extends p{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends p{}class y extends f{}y.kind="else";class g extends f{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new y(e):e}return t?!1===e?t instanceof g?t:t.nodes:this.nodes.length?this:new g(C(e),t instanceof g?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=x(this.condition,e,t),this}get names(){const e=super.names;return I(e,this.condition),this.else&&T(e,this.else.names),e}}g.kind="if";class v extends f{}v.kind="for";class _ extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=x(this.iteration,e,t),this}get names(){return T(super.names,this.iteration.names)}}class w extends v{constructor(e,t,r,n){super(),this.varKind=e,this.name=t,this.from=r,this.to=n}render(e){const t=e.es5?r.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${t} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){const e=I(super.names,this.from);return I(e,this.to)}}class $ extends v{constructor(e,t,r,n){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=x(this.iterable,e,t),this}get names(){return T(super.names,this.iterable.names)}}class b extends f{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}b.kind="func";class k extends p{render(e){return"return "+super.render(e)}}k.kind="return";class E extends f{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var r,n;return super.optimizeNames(e,t),null===(r=this.catch)||void 0===r||r.optimizeNames(e,t),null===(n=this.finally)||void 0===n||n.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&T(e,this.catch.names),this.finally&&T(e,this.finally.names),e}}class P extends f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}P.kind="catch";class S extends f{render(e){return"finally"+super.render(e)}}S.kind="finally";function T(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function I(e,r){return r instanceof t._CodeOrName?T(e,r.names):e}function x(e,r,n){return e instanceof t.Name?s(e):(o=e)instanceof t._Code&&o._items.some(e=>e instanceof t.Name&&1===r[e.str]&&void 0!==n[e.str])?new t._Code(e._items.reduce((e,r)=>(r instanceof t.Name&&(r=s(r)),r instanceof t._Code?e.push(...r._items):e.push(r),e),[])):e;var o;function s(e){const t=n[e.str];return void 0===t||1!==r[e.str]?e:(delete r[e.str],t)}}function N(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function C(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:t._`!${z(e)}`}e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new r.Scope({parent:e}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const r=this._extScope.value(e,t);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,n){const o=this._scope.toName(t);return void 0!==r&&n&&(this._constants[o.str]=r),this._leafNode(new a(e,o,r)),o}const(e,t,n){return this._def(r.varKinds.const,e,t,n)}let(e,t,n){return this._def(r.varKinds.let,e,t,n)}var(e,t,n){return this._def(r.varKinds.var,e,t,n)}assign(e,t,r){return this._leafNode(new i(e,t,r))}add(t,r){return this._leafNode(new c(t,e.operators.ADD,r))}code(e){return"function"==typeof e?e():e!==t.nil&&this._leafNode(new h(e)),this}object(...e){const r=["{"];for(const[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,t.addCodeArg)(r,o));return r.push("}"),new t._Code(r)}if(e,t,r){if(this._blockNode(new g(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new g(e))}else(){return this._elseNode(new y)}endIf(){return this._endBlockNode(g,y)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new _(e),t)}forRange(e,t,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.let)){const a=this._scope.toName(e);return this._for(new w(s,a,t,n),()=>o(a))}forOf(e,n,o,s=r.varKinds.const){const a=this._scope.toName(e);if(this.opts.es5){const e=n instanceof t.Name?n:this.var("_arr",n);return this.forRange("_i",0,t._`${e}.length`,r=>{this.var(a,t._`${e}[${r}]`),o(a)})}return this._for(new $("of",s,a,n),()=>o(a))}forIn(e,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,t._`Object.keys(${n})`,o);const a=this._scope.toName(e);return this._for(new $("in",s,a,n),()=>o(a))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new u(e))}break(e){return this._leafNode(new l(e))}return(e){const t=new k;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(k)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new E;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new P(e),t(e)}return r&&(this._currNode=n.finally=new S,this.code(r)),this._endBlockNode(P,S)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-t;if(r<0||void 0!==e&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,r=t.nil,n,o){return this._blockNode(new b(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(b)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},e.not=C;const j=O(e.operators.AND);e.and=function(...e){return e.reduce(j)};const R=O(e.operators.OR);function O(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${z(r)} ${e} ${z(n)}`}function z(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(R)}}(oc)),oc}var hc={};Object.defineProperty(hc,"__esModule",{value:!0}),hc.checkStrictMode=hc.getErrorPath=hc.Type=hc.useFunc=hc.setEvaluated=hc.evaluatedPropsToName=hc.mergeEvaluated=hc.eachItem=hc.unescapeJsonPointer=hc.escapeJsonPointer=hc.escapeFragment=hc.unescapeFragment=hc.schemaRefOrVal=hc.schemaHasRulesButRef=hc.schemaHasRules=hc.checkUnknownRules=hc.alwaysValidSchema=hc.toHash=void 0;const pc=dc(),fc=ac();function mc(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema)return;if("boolean"==typeof t)return;const o=n.RULES.keywords;for(const r in t)o[r]||Ec(e,`unknown keyword: "${r}"`)}function yc(e,t){if("boolean"==typeof e)return!e;for(const r in e)if(t[r])return!0;return!1}function gc(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function vc(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function _c({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,a,i)=>{const c=void 0===a?s:a instanceof pc.Name?(s instanceof pc.Name?e(o,s,a):t(o,s,a),a):s instanceof pc.Name?(t(o,a,s),s):r(s,a);return i!==pc.Name||c instanceof pc.Name?c:n(o,c)}}function wc(e,t){if(!0===t)return e.var("props",!0);const r=e.var("props",pc._`{}`);return void 0!==t&&$c(e,r,t),r}function $c(e,t,r){Object.keys(r).forEach(r=>e.assign(pc._`${t}${(0,pc.getProperty)(r)}`,!0))}hc.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},hc.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(mc(e,t),!yc(t,e.self.RULES.all))},hc.checkUnknownRules=mc,hc.schemaHasRules=yc,hc.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const r in e)if("$ref"!==r&&t.all[r])return!0;return!1},hc.schemaRefOrVal=function({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if("number"==typeof r||"boolean"==typeof r)return r;if("string"==typeof r)return pc._`${r}`}return pc._`${e}${t}${(0,pc.getProperty)(n)}`},hc.unescapeFragment=function(e){return vc(decodeURIComponent(e))},hc.escapeFragment=function(e){return encodeURIComponent(gc(e))},hc.escapeJsonPointer=gc,hc.unescapeJsonPointer=vc,hc.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},hc.mergeEvaluated={props:_c({mergeNames:(e,t,r)=>e.if(pc._`${r} !== true && ${t} !== undefined`,()=>{e.if(pc._`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,pc._`${r} || {}`).code(pc._`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if(pc._`${r} !== true`,()=>{!0===t?e.assign(r,!0):(e.assign(r,pc._`${r} || {}`),$c(e,r,t))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:wc}),items:_c({mergeNames:(e,t,r)=>e.if(pc._`${r} !== true && ${t} !== undefined`,()=>e.assign(r,pc._`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if(pc._`${r} !== true`,()=>e.assign(r,!0===t||pc._`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},hc.evaluatedPropsToName=wc,hc.setEvaluated=$c;const bc={};var kc;function Ec(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,!0===r)throw new Error(t);e.self.logger.warn(t)}}hc.useFunc=function(e,t){return e.scopeValue("func",{ref:t,code:bc[t.code]||(bc[t.code]=new fc._Code(t.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(kc||(hc.Type=kc={})),hc.getErrorPath=function(e,t,r){if(e instanceof pc.Name){const n=t===kc.Num;return r?n?pc._`"[" + ${e} + "]"`:pc._`"['" + ${e} + "']"`:n?pc._`"/" + ${e}`:pc._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,pc.getProperty)(e).toString():"/"+gc(e)},hc.checkStrictMode=Ec;var Pc,Sc,Tc,Ic={};function xc(){if(Pc)return Ic;Pc=1,Object.defineProperty(Ic,"__esModule",{value:!0});const e=dc(),t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return Ic.default=t,Ic}function Nc(){return Sc||(Sc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=dc(),r=hc,n=xc();function o(e,r){const o=e.const("err",r);e.if(t._`${n.default.vErrors} === null`,()=>e.assign(n.default.vErrors,t._`[${o}]`),t._`${n.default.vErrors}.push(${o})`),e.code(t._`${n.default.errors}++`)}function s(e,r){const{gen:n,validateName:o,schemaEnv:s}=e;s.$async?n.throw(t._`new ${e.ValidationError}(${r})`):(n.assign(t._`${o}.errors`,r),n.return(!1))}e.keywordError={message:({keyword:e})=>t.str`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:r})=>r?t.str`"${e}" keyword must be ${r} ($data)`:t.str`"${e}" keyword is invalid ($data)`},e.reportError=function(r,n=e.keywordError,a,c){const{it:u}=r,{gen:l,compositeRule:d,allErrors:h}=u,p=i(r,n,a);(null!=c?c:d||h)?o(l,p):s(u,t._`[${p}]`)},e.reportExtraError=function(t,r=e.keywordError,a){const{it:c}=t,{gen:u,compositeRule:l,allErrors:d}=c;o(u,i(t,r,a)),l||d||s(c,n.default.vErrors)},e.resetErrorsCount=function(e,r){e.assign(n.default.errors,r),e.if(t._`${n.default.vErrors} !== null`,()=>e.if(r,()=>e.assign(t._`${n.default.vErrors}.length`,r),()=>e.assign(n.default.vErrors,null)))},e.extendErrors=function({gen:e,keyword:r,schemaValue:o,data:s,errsCount:a,it:i}){if(void 0===a)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",a,n.default.errors,a=>{e.const(c,t._`${n.default.vErrors}[${a}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,i.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${i.errSchemaPath}/${r}`),i.opts.verbose&&(e.assign(t._`${c}.schema`,o),e.assign(t._`${c}.data`,s))})};const a={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function i(e,r,o){const{createErrors:s}=e.it;return!1===s?t._`{}`:function(e,r,o={}){const{gen:s,it:i}=e,l=[c(i,o),u(e,o)];return function(e,{params:r,message:o},s){const{keyword:i,data:c,schemaValue:u,it:l}=e,{opts:d,propertyName:h,topSchemaRef:p,schemaPath:f}=l;s.push([a.keyword,i],[a.params,"function"==typeof r?r(e):r||t._`{}`]),d.messages&&s.push([a.message,"function"==typeof o?o(e):o]);d.verbose&&s.push([a.schema,u],[a.parentSchema,t._`${p}${f}`],[n.default.data,c]);h&&s.push([a.propertyName,h])}(e,r,l),s.object(...l)}(e,r,o)}function c({errorPath:e},{instancePath:o}){const s=o?t.str`${e}${(0,r.getErrorPath)(o,r.Type.Str)}`:e;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,s)]}function u({keyword:e,it:{errSchemaPath:n}},{schemaPath:o,parentSchema:s}){let i=s?n:t.str`${n}/${e}`;return o&&(i=t.str`${i}${(0,r.getErrorPath)(o,r.Type.Str)}`),[a.schemaPath,i]}}(nc)),nc}var Cc={},jc={};Object.defineProperty(jc,"__esModule",{value:!0}),jc.getRules=jc.isJSONType=void 0;const Rc=new Set(["string","number","integer","boolean","null","object","array"]);jc.isJSONType=function(e){return"string"==typeof e&&Rc.has(e)},jc.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}};var Oc,zc={};function Ac(){if(Oc)return zc;function e(e,r){return r.rules.some(r=>t(e,r))}function t(e,t){var r;return void 0!==e[t.keyword]||(null===(r=t.definition.implements)||void 0===r?void 0:r.some(t=>void 0!==e[t]))}return Oc=1,Object.defineProperty(zc,"__esModule",{value:!0}),zc.shouldUseRule=zc.shouldUseGroup=zc.schemaHasRulesForType=void 0,zc.schemaHasRulesForType=function({schema:t,self:r},n){const o=r.RULES.types[n];return o&&!0!==o&&e(t,o)},zc.shouldUseGroup=e,zc.shouldUseRule=t,zc}Object.defineProperty(Cc,"__esModule",{value:!0}),Cc.reportTypeError=Cc.checkDataTypes=Cc.checkDataType=Cc.coerceAndCheckDataType=Cc.getJSONTypes=Cc.getSchemaTypes=Cc.DataType=void 0;const Mc=jc,Dc=Ac(),Uc=Nc(),qc=dc(),Vc=hc;var Fc;function Lc(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(Mc.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(Fc||(Cc.DataType=Fc={})),Cc.getSchemaTypes=function(e){const t=Lc(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},Cc.getJSONTypes=Lc,Cc.coerceAndCheckDataType=function(e,t){const{gen:r,data:n,opts:o}=e,s=function(e,t){return t?e.filter(e=>Kc.has(e)||"array"===t&&"array"===e):[]}(t,o.coerceTypes),a=t.length>0&&!(0===s.length&&1===t.length&&(0,Dc.schemaHasRulesForType)(e,t[0]));if(a){const a=Zc(t,n,o.strictNumbers,Fc.Wrong);r.if(a,()=>{s.length?function(e,t,r){const{gen:n,data:o,opts:s}=e,a=n.let("dataType",qc._`typeof ${o}`),i=n.let("coerced",qc._`undefined`);"array"===s.coerceTypes&&n.if(qc._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,qc._`${o}[0]`).assign(a,qc._`typeof ${o}`).if(Zc(t,o,s.strictNumbers),()=>n.assign(i,o)));n.if(qc._`${i} !== undefined`);for(const e of r)(Kc.has(e)||"array"===e&&"array"===s.coerceTypes)&&c(e);function c(e){switch(e){case"string":return void n.elseIf(qc._`${a} == "number" || ${a} == "boolean"`).assign(i,qc._`"" + ${o}`).elseIf(qc._`${o} === null`).assign(i,qc._`""`);case"number":return void n.elseIf(qc._`${a} == "boolean" || ${o} === null
1
+ import e from"os";import t,{dirname as r,join as n}from"path";import o from"fs/promises";import{jwtVerify as s,createRemoteJWKSet as a}from"jose";import i from"crypto";import c from"http";import l,{fileURLToPath as u}from"url";import{spawn as d}from"child_process";import h from"readline";import p from"pkce-challenge";import{readFileSync as f}from"fs";class m extends Error{constructor(e){super(e),this.name="BarndoorError"}}class y extends m{constructor(e,t=null){super(e),this.name="AuthenticationError",this.errorCode=t}}class g extends y{constructor(e,t=null){let r=e;r+=t?` ${t}`:" Run 'barndoor-login' to authenticate.",super(r),this.name="TokenError",this.helpText=t}}class v extends g{}class _ extends g{}class w extends m{constructor(e,t){let r;const n=t.toString().toLowerCase();r=n.includes("timeout")?`Connection to ${e} timed out. Please check your internet connection and try again.`:n.includes("connection refused")?`Could not connect to ${e}. The service may be unavailable.`:n.includes("name resolution")||n.includes("getaddrinfo")?`Could not resolve hostname for ${e}. Please check the URL and your DNS settings.`:`Failed to connect to ${e}. Please check your internet connection.`,super(r),this.url=e,this.originalError=t}}class $ extends m{constructor(e,t,r=null){super($._createUserFriendlyMessage(e,t,r)),this.name="HTTPError",this.statusCode=e,this.responseBody=r}static _createUserFriendlyMessage(e,t,r){const n=`Request failed (HTTP ${e})`;return 400===e?`${n}: Invalid request. Please check your input parameters.`:401===e?`${n}: Authentication failed. Please check your token or re-authenticate.`:403===e?`${n}: Access denied. You don't have permission for this operation.`:404===e?`${n}: Resource not found. Please check the server ID or URL.`:429===e?`${n}: Rate limit exceeded. Please wait before making more requests.`:e>=500&&e<600?`${n}: Server error. Please try again later or contact support.`:`${n}: ${t}`}}class b extends m{constructor(e,t=null){let r=`Server '${e}' not found`;r+=t?`. Available servers: ${t.join(", ")}`:". Use listServers() to see available servers.",super(r),this.serverIdentifier=e,this.availableServers=t}}let k=class extends y{};class E extends m{}class P extends m{}class S{constructor(e=30,t=10){this.read=1e3*e,this.connect=1e3*t}}class T{constructor(e=new S,t=3){this.timeoutConfig=e,this.maxRetries=t,this.closed=!1}async request(e,t,r={}){if(this.closed)throw new Error("HTTP client has been closed");const{headers:n={},json:o,params:s,...a}=r,i=this._buildUrl(t,s),c={method:e.toUpperCase(),headers:{"Content-Type":"application/json","User-Agent":"barndoor-js-sdk/0.1.0",...n},...a};let l;o&&(c.body=JSON.stringify(o));for(let t=0;t<=this.maxRetries;t++){const r=new AbortController,n=this.timeoutConfig.connect+this.timeoutConfig.read,o=setTimeout(()=>r.abort(),n),s={...c,signal:r.signal};try{const e=await globalThis.fetch(i,s);if(clearTimeout(o),!e.ok){let t="";try{const r=e;"function"==typeof r.text?t=await r.text():"function"==typeof r.json&&(t=JSON.stringify(await r.json()))}catch{}throw new $(e.status,e.statusText,t)}if(204===e.status||205===e.status||304===e.status)return null;let t="";const r=e,n=r&&r.headers;let a;return n&&("function"==typeof n.get?t=n.get("content-type")||n.get("Content-Type")||"":"object"==typeof n&&(t=n["content-type"]||n["Content-Type"]||"")),a=t.includes("application/json")||!t&&"function"==typeof r.json?await e.json():t.includes("text/")||!t&&"function"==typeof r.text?await e.text():"function"==typeof r.arrayBuffer?await e.arrayBuffer():e,a}catch(r){if(clearTimeout(o),r instanceof Error&&"AbortError"===r.name){const e=this.timeoutConfig.connect+this.timeoutConfig.read;l=new P(`Request to ${i} timed out after ${e}ms`)}else if(r instanceof $){if(r.statusCode>=400&&r.statusCode<500)throw r;if(!(r.statusCode>=500&&r.statusCode<600))throw r;{const t=e.toUpperCase();if(!("GET"===t||"HEAD"===t||"OPTIONS"===t))throw r;l=r}}else l=r instanceof Error&&"TypeError"===r.name&&r.message.includes("fetch")?new w(i,r):r instanceof Error?r:new Error(String(r));if(t===this.maxRetries)break;const n=Math.min(1e3*Math.pow(2,t),1e4);await this._sleep(n)}}throw l||(l=new Error(`Request to ${i} failed after ${this.maxRetries+1} attempts with no specific error`)),l}_buildUrl(e,t){if(!t||0===Object.keys(t).length)return e;const r=new URL(e);return Object.entries(t).forEach(([e,t])=>{null!=t&&r.searchParams.append(e,String(t))}),r.toString()}_sleep(e){return new Promise(t=>setTimeout(t,e))}async close(){this.closed=!0}async aclose(){await this.close()}}class I{constructor(e){if(this.id=e.id,this.name=e.name,this.slug=e.slug,this.provider=e.provider??null,this.connection_status=e.connection_status,!(this.id&&this.name&&this.slug&&this.connection_status))throw new Error("ServerSummary missing required fields")}static fromApiResponse(e){return new I(e)}}class x extends I{constructor(e){super(e),this.url=e.url??null}static fromApiResponse(e){return new x(e)}}class N{constructor(e){if(this.agent_token=e.agent_token,this.expires_in=e.expires_in,!this.agent_token||"number"!=typeof this.expires_in)throw new Error("AgentToken missing required fields")}static fromApiResponse(e){return new N(e)}}const C={production:{issuer:"https://auth.barndoor.ai/realms/barndoor",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.platform.barndoor.ai"},uat:{issuer:"https://auth.barndooruat.com/realms/barndoor",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.trial.barndooruat.com"},dev:{issuer:"https://auth.barndoordev.com/realms/barndoor",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.platform.barndoordev.com"},"enterprise-production":{issuer:"https://auth.barndoor.ai",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.mcp.barndoor.ai"},"enterprise-uat":{issuer:"https://auth.barndooruat.com",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.mcp.barndooruat.com"},"enterprise-dev":{issuer:"https://auth.barndoordev.com",audience:"https://barndoor.ai/",baseUrl:"https://{org_slug}.mcp.barndoordev.com"},localdev:{issuer:"http://localhost:8080/realms/barndoor",audience:"https://barndoor.ai/",baseUrl:"http://localhost:8000"}},j="undefined"!=typeof window&&void 0!==window.document,R="undefined"==typeof window&&"undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node;function O(e,t=""){return R?process.env[e]??t:j&&window.ENV?window.ENV[e]??t:t}class z{constructor(e={}){const t=e.environment??(O("MODE")||O("BARNDOOR_ENV")||"production");this.environment={production:"production",prod:"production",uat:"uat",dev:"dev",development:"dev","enterprise-production":"enterprise-production","enterprise-prod":"enterprise-production","enterprise-uat":"enterprise-uat","enterprise-dev":"enterprise-dev",enterprise:"enterprise-production",localdev:"localdev",local:"localdev"}[t.toLowerCase()]??"production";const r=C[this.environment]??C.production,n=O("AUTH_URL"),o=e.authDomain??O("AUTH_DOMAIN");e.authIssuer?this.authIssuer=e.authIssuer:this.authIssuer=n||(o?o.startsWith("http")?o:`https://${o}`:r.issuer),this.clientId=e.clientId??(O("AGENT_CLIENT_ID")||O("AUTH_CLIENT_ID")||""),this.clientSecret=e.clientSecret??(O("AGENT_CLIENT_SECRET")||O("AUTH_CLIENT_SECRET")||""),this.apiAudience=e.apiAudience??(O("API_AUDIENCE")||r.audience),this.promptForLogin=e.promptForLogin??!1,this.skipLoginLocal=e.skipLoginLocal??!1,this.baseUrl=e.baseUrl??(O("BARNDOOR_API")||O("BARNDOOR_URL")||r.baseUrl)}get authDomain(){let e=this.authIssuer;return e.startsWith("https://")?e=e.slice(8):e.startsWith("http://")&&(e=e.slice(7)),e}static getStaticConfig(){return new z}static getDynamicConfig(e,t={}){const{requireOrganization:r=!0,fallbackOrganizationId:n}=t,o=new z,s=A(e);if(s.hasOrganization){const e=String(s.organizationId??"").trim().toLowerCase();if(!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(e))throw new E("Invalid organization subdomain format from token");return o.baseUrl=o.baseUrl.replace("{org_slug}",e),o}if(n)return o.baseUrl=o.baseUrl.replace("{org_slug}",n),o;if(r){const e=s.error||"No organization information found in token";throw new E(`Failed to extract organization ID from token: ${e}. This token may be for a personal account or may be missing organization claims. Consider using getStaticConfig() for organization-independent operations or provide a fallbackOrganizationId in the options.`)}return o}validate(){if(!this.authIssuer||""===this.authIssuer.trim())throw new E("authIssuer is required");if(!this.apiAudience||""===this.apiAudience.trim())throw new E("apiAudience is required");if(!this.baseUrl||""===this.baseUrl.trim())throw new E("baseUrl is required")}}function A(e){try{const t=e.split(".");if(3!==t.length)return{hasOrganization:!1,error:"Invalid JWT format - expected 3 parts separated by dots"};let r,n;try{r=JSON.parse(function(e){if("undefined"!=typeof globalThis&&globalThis.atob)return globalThis.atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");throw new Error("No base64 decode function available")}(t[1].replace(/-/g,"+").replace(/_/g,"/")))}catch(e){return{hasOrganization:!1,error:"Failed to parse JWT payload - token may be corrupted"}}if(r.user&&"object"==typeof r.user&&(n=r.user.organization_name??r.user.organization_slug),!n){const e=r["https://barndoor.ai/organization_slug"],t=r.organization_slug,o=r.organization_name,s=r.org_slug;n=("string"==typeof o?o:void 0)??("string"==typeof e?e:void 0)??("string"==typeof t?t:void 0)??("string"==typeof s?s:void 0)}return n&&"string"==typeof n&&""!==n.trim()?{organizationId:n.trim(),hasOrganization:!0}:{hasOrganization:!1,error:"No organization information found in token. This token may be for a personal account or may be missing organization claims."}}catch(e){return{hasOrganization:!1,error:`Failed to decode JWT token: ${e instanceof Error?e.message:String(e)}`}}}function M(){return z.getStaticConfig()}function U(e,t){return z.getDynamicConfig(e,t)}function D(e){return A(e)}function q(e){return A(e).hasOrganization}let V={debug:(e,...t)=>{"undefined"!=typeof console&&console.debug&&console.debug(e,...t)},info:(e,...t)=>{"undefined"!=typeof console&&console.info&&console.info(e,...t)},warn:(e,...t)=>{"undefined"!=typeof console&&console.warn&&console.warn(e,...t)},error:(e,...t)=>{"undefined"!=typeof console&&console.error&&console.error(e,...t)}};function F(e){V=e}function L(){return V}function H(e){return{debug:(t,...r)=>{V.debug(`[${e}] ${t}`,...r)},info:(t,...r)=>{V.info(`[${e}] ${t}`,...r)},warn:(t,...r)=>{V.warn(`[${e}] ${t}`,...r)},error:(t,...r)=>{V.error(`[${e}] ${t}`,...r)}}}function K(e,...t){V.debug(e,...t)}function Z(e,...t){V.info(e,...t)}function G(e,...t){V.warn(e,...t)}function B(e,...t){V.error(e,...t)}const J=H("token"),W=new Map;async function Q(e){if(W.has(e))return W.get(e);const t=e.replace(/\/$/,""),r=`${t}/.well-known/openid-configuration`;try{const t=new AbortController,n=setTimeout(()=>t.abort(),5e3);try{const n=await fetch(r,{signal:t.signal});if(!n.ok)throw new Error(`HTTP ${n.status}`);const o=await n.json();return W.set(e,o),J.debug(`OIDC discovery successful for ${e}`),o}finally{clearTimeout(n)}}catch(r){return J.warn(`OIDC discovery failed for ${e}:`,r),t.includes("/realms/")?{issuer:t,token_endpoint:`${t}/protocol/openid-connect/token`,authorization_endpoint:`${t}/protocol/openid-connect/auth`,userinfo_endpoint:`${t}/protocol/openid-connect/userinfo`,jwks_uri:`${t}/protocol/openid-connect/certs`}:{issuer:t,token_endpoint:`${t}/oauth/token`,authorization_endpoint:`${t}/authorize`,userinfo_endpoint:`${t}/userinfo`,jwks_uri:`${t}/.well-known/jwks.json`}}}function Y(){W.clear()}function X(e){console.warn("setTokenLogger is deprecated. Use setLogger from the main logging module instead.")}function ee(e){try{const t=e.split(".");if(3!==t.length)return null;const r=JSON.parse(function(e){const t=e.replace(/-/g,"+").replace(/_/g,"/");if(R)return Buffer.from(t,"base64").toString("utf8");if("undefined"!=typeof globalThis&&globalThis.atob)return globalThis.atob(t);throw new Error("No base64 decode function available")}(t[1]));return r}catch(e){return null}}function te(e,t){return"undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?e:Promise.race([e,new Promise((e,r)=>{setTimeout(()=>r(new Error("Request timeout")),t)})])}var re;!function(e){e.VALID="valid",e.EXPIRED="expired",e.INVALID="invalid"}(re||(re={}));const ne=new Map;class oe{constructor(e){this.lockAcquired=!1,this.lockFile=`${e}.lock`}async acquire(e=5e3){if(!R)return;const t=Date.now();for(;Date.now()-t<e;)try{return await o.writeFile(this.lockFile,process.pid.toString(),{flag:"wx"}),void(this.lockAcquired=!0)}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"EEXIST"!==e.code)throw new g(`Failed to acquire file lock: ${e}`);try{const e=await o.readFile(this.lockFile,"utf8"),t=parseInt(e.trim(),10);try{process.kill(t,0),await new Promise(e=>setTimeout(e,100));continue}catch(e){if(e&&"object"==typeof e&&"code"in e){const t=e;if("EPERM"===t.code){await new Promise(e=>setTimeout(e,100));continue}if("ESRCH"===t.code){await o.unlink(this.lockFile).catch(()=>{});continue}}await o.unlink(this.lockFile).catch(()=>{});continue}}catch{await o.unlink(this.lockFile).catch(()=>{});continue}}throw new g("Failed to acquire file lock: timeout")}async release(){if(R&&this.lockAcquired)try{await o.unlink(this.lockFile),this.lockAcquired=!1}catch(e){console.debug("Failed to release file lock:",e)}}}class se{}class ae extends se{constructor(){super(),this.storageKey="barndoor_token"}async loadToken(){try{const e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):null}catch(e){return J.warn("Failed to load token from localStorage:",e),null}}async saveToken(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e))}catch(e){const t=e instanceof Error?e.message:String(e);throw new g(`Failed to save token: ${t}`)}}async clearToken(){try{localStorage.removeItem(this.storageKey)}catch(e){J.warn("Failed to clear token from localStorage:",e)}}}class ie extends se{constructor(){super(),this.tokenFile=this._getTokenFilePath()}_getTokenFilePath(){if(R)return t.join(e.homedir(),".barndoor","token.json");throw new Error("NodeTokenStorage can only be used in Node.js environment")}async loadToken(){if(!R)throw new Error("NodeTokenStorage can only be used in Node.js environment");const e=new oe(this.tokenFile);try{await e.acquire();const t=await o.readFile(this.tokenFile,"utf8");return JSON.parse(t)}catch(e){return e&&"object"==typeof e&&"code"in e&&"ENOENT"===e.code||J.warn("Failed to load token from file:",e),null}finally{await e.release()}}async saveToken(e){if(!R)throw new Error("NodeTokenStorage can only be used in Node.js environment");const r=new oe(this.tokenFile);try{await r.acquire(),await o.mkdir(t.dirname(this.tokenFile),{recursive:!0}),await o.writeFile(this.tokenFile,JSON.stringify(e,null,2)),await o.chmod(this.tokenFile,384),J.debug("Token saved to storage")}catch(e){const t=e instanceof Error?e.message:String(e);throw new g(`Failed to save token: ${t}`)}finally{await r.release()}}async clearToken(){if(!R)throw new Error("NodeTokenStorage can only be used in Node.js environment");try{await o.unlink(this.tokenFile)}catch(e){e&&"object"==typeof e&&"code"in e&&"ENOENT"!==e.code&&J.warn("Failed to clear token file:",e)}}}function ce(){if(j)return new ae;if(R)return new ie;throw new Error("Unsupported environment for token storage")}async function le(e,t,r){try{const n=await async function(e){if(ne.has(e))return ne.get(e);try{const t=(await Q(e)).jwks_uri;if(!t)throw J.debug(`No jwks_uri in OIDC config for ${e}`),new Error("No jwks_uri available");const r=a(new URL(t));return ne.set(e,r),r}catch(t){throw J.debug(`Failed to get JWKS for ${e}:`,t),t}}(t),o=`${t.replace(/\/$/,"")}/`;return await s(e,n,{issuer:o,audience:r}),J.debug("Token verified locally using JWKS"),re.VALID}catch(e){return e&&"object"==typeof e&&"code"in e&&"ERR_JWT_EXPIRED"===e.code?(J.debug("Token expired (verified locally)"),re.EXPIRED):(J.debug("JWT verification failed:",e),re.INVALID)}}class ue{constructor(){this._locked=!1,this._waitQueue=[]}async acquire(){return new Promise(e=>{this._locked?this._waitQueue.push(e):(this._locked=!0,e())})}release(){if(this._waitQueue.length>0){const e=this._waitQueue.shift();e&&e()}else this._locked=!1}async withLock(e){await this.acquire();try{return await e()}finally{this.release()}}}class de{constructor(e){this._refreshMutex=new ue,this.storage=ce()}async getValidToken(){return this._refreshMutex.withLock(async()=>{const e=await this.storage.loadToken();if(!e)throw new g("No token found. Please authenticate.");try{if(this._shouldRefreshToken(e)&&e.refresh_token){J.debug("Proactively refreshing token before expiration");const t=await this._refreshToken(e),r={...e,...t};return await this.storage.saveToken(r),r.access_token}const t=await this._validateOrRefresh(e);return await this.storage.saveToken(t),t.access_token}catch(e){throw J.error("Token validation/refresh failed:",e),new v("Token expired and refresh failed. Please re-authenticate.")}})}_shouldRefreshToken(e){const t=ee(e.access_token);if(!t?.exp)return!0;const r=Math.floor(Date.now()/1e3);return t.exp-r<300}async _validateOrRefresh(e){const t=e.access_token,r=M(),n=await le(t,r.authIssuer,r.apiAudience);if(n===re.VALID)return J.debug("Token validated locally"),e;if(n===re.INVALID&&(J.debug("Local validation failed, trying remote"),await this._isTokenValidRemote(t)))return J.debug("Token validated remotely"),e;if(J.info("Token invalid or expired, attempting refresh"),e.refresh_token){const t=await this._refreshToken(e);return{...e,...t}}throw new v("Token expired and no refresh token available")}async _isTokenValidRemote(e){try{const t=M(),r=(await Q(t.authIssuer)).userinfo_endpoint,n=fetch(r,{headers:{Authorization:`Bearer ${e}`},..."undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?{signal:AbortSignal.timeout(5e3)}:{}});return(await te(n,5e3)).ok}catch(e){return J.debug("Remote token validation failed:",e),!1}}async _refreshToken(e){const t=e.refresh_token;if(!t)throw new g("No refresh token available");const r=M();if(j&&r.clientSecret)throw new g("Refresh flow requires a confidential client; run interactive login again.");const n=(await Q(r.authIssuer)).token_endpoint,o=new URLSearchParams({grant_type:"refresh_token",client_id:r.clientId,refresh_token:t});r.clientSecret&&!j&&o.set("client_secret",r.clientSecret);try{const e=fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString(),..."undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?{signal:AbortSignal.timeout(15e3)}:{}}),t=await te(e,15e3);if(400===t.status){let e="Invalid refresh token";try{e=(await t.json()).error_description||e}catch{}throw J.warn(`Refresh token invalid: ${e}`),new v(`Refresh token expired or invalid: ${e}`)}if(429===t.status)throw J.warn("Rate limited during token refresh"),new g("Rate limited during token refresh. Please try again later.");if(t.status>=500)throw J.warn(`Auth server error during refresh: ${t.status}`),new g(`Auth server temporarily unavailable (HTTP ${t.status})`);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);return await t.json()}catch(e){if(e instanceof g||e instanceof v)throw e;if(e&&"object"==typeof e&&"name"in e){if("TimeoutError"===e.name||"AbortError"===e.name)throw J.warn("Timeout during token refresh"),new g("Token refresh timed out. Please check your connection.");if("TypeError"===e.name&&"message"in e&&"string"==typeof e.message&&e.message.includes("fetch"))throw J.warn(`Network error during token refresh: ${e.message}`),new g("Network error during token refresh. Please check your connection.")}J.error("Unexpected error during token refresh:",e);const t=e instanceof Error?e.message:String(e);throw new g(`Token refresh failed: ${t}`)}}}async function he(){try{const e=ce(),t=await e.loadToken();return t?.access_token??null}catch(e){return null}}async function pe(e){const t=ce();let r;r="string"==typeof e?{access_token:e}:e,await t.saveToken(r)}async function fe(){const e=ce();await e.clearToken()}async function me(e){try{const e=ce(),t=await e.loadToken();if(!t?.access_token)return!1;const r=M(),n=(await Q(r.authIssuer)).userinfo_endpoint,o=fetch(n,{headers:{Authorization:`Bearer ${t.access_token}`},..."undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?{signal:AbortSignal.timeout(1e4)}:{}});return(await te(o,1e4)).ok}catch(e){return!1}}async function ye(e){try{const t=new de(e||"");return await t.getValidToken(),!0}catch(e){return J.warn("Token validation/refresh failed:",e),!1}}async function ge(e,t){try{const t=M(),r=await le(e,t.authIssuer,t.apiAudience);if(r===re.VALID)return{valid:!0};if(r===re.INVALID)try{const r=(await Q(t.authIssuer)).userinfo_endpoint,n=fetch(r,{headers:{Authorization:`Bearer ${e}`},..."undefined"!=typeof AbortSignal&&"timeout"in AbortSignal?{signal:AbortSignal.timeout(5e3)}:{}});return{valid:(await te(n,5e3)).ok}}catch(e){return J.warn("Remote token validation failed:",e),{valid:!1}}return{valid:!1}}catch(e){return J.warn("Token validation failed:",e),{valid:!1}}}class ve{constructor(){this._codeVerifier=null,this._currentState=null,this._logger=H("pkce")}async buildAuthorizationUrl({domain:e,clientId:t,redirectUri:r,audience:n,scope:o="openid profile email",issuer:s}){this._codeVerifier=_e(32);const a=we(await async function(e){const t=(new TextEncoder).encode(e);if(j&&window.crypto&&window.crypto.subtle){const e=await window.crypto.subtle.digest("SHA-256",t);return new Uint8Array(e)}if(R){const t=i.createHash("sha256").update(e).digest();return new Uint8Array(t)}throw new Error("SHA256 not available in this environment")}(this._codeVerifier));this._currentState=_e(16);const c=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:r,scope:o,audience:n,state:this._currentState,code_challenge:a,code_challenge_method:"S256"});let l;if(s){l=(await Q(s)).authorization_endpoint}else{if(!e)throw new k("Either issuer or domain must be provided");l=`https://${e}/authorize`}return`${l}?${c.toString()}`}async exchangeCodeForToken({domain:e,clientId:t,code:r,redirectUri:n,clientSecret:o,issuer:s}){const a=new URLSearchParams({grant_type:"authorization_code",client_id:t,code:r,redirect_uri:n});if(o&&a.set("client_secret",o),this._codeVerifier&&a.set("code_verifier",this._codeVerifier),!o&&!this._codeVerifier)throw new k("Either client_secret or PKCE verifier must be provided");let i;if(s){i=(await Q(s)).token_endpoint}else{if(!e)throw new k("Either issuer or domain must be provided");i=`https://${e}/oauth/token`}try{const e=await fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()});if(!e.ok){const t=await e.json().catch(()=>({}));throw this._logger.error("Token endpoint response:",t),new k(`Token exchange failed: ${t.error??t.error_description??e.statusText}`)}const t=await e.json();return this.clearState(),t}catch(e){if(e instanceof k)throw e;const t=e instanceof Error?e.message:String(e);throw new k(`Token exchange failed: ${t}`)}}validateState(e){return Boolean(this._currentState&&e===this._currentState)}clearState(){this._codeVerifier=null,this._currentState=null}getState(){return this._codeVerifier&&this._currentState?{codeVerifier:this._codeVerifier,codeChallenge:"",state:this._currentState,timestamp:Date.now()}:null}}function _e(e){const t=new Uint8Array(e);if(j&&window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(t);else{if(!R)throw new Error("Secure random generator not available for PKCE.");i.randomFillSync(t)}return we(t)}function we(e){const t=function(e){if("undefined"!=typeof globalThis&&globalThis.btoa)return globalThis.btoa(String.fromCharCode(...e));if("undefined"!=typeof Buffer)return Buffer.from(e).toString("base64");throw new Error("No base64 encode function available")}(e);return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $e(e=52765){if(!R)throw new Error("Local callback server is only available in Node.js environment");const t=H("pkce"),r="undefined"!=typeof process&&process.env&&process.env.BARNDOOR_REDIRECT_HOST||"127.0.0.1",n=r.startsWith("http")?`${r}:${e}/cb`:`http://${r}:${e}/cb`,o=new Promise((r,o)=>{const s=c.createServer((e,n)=>{t.debug(`Callback server received request: ${e.method} ${e.url}`);const a=l.parse(e.url??"",!0);if(t.debug(`Parsed URL - pathname: ${a.pathname}, query:`,a.query),"/cb"===a.pathname){const{code:i,state:c,error:l,error_description:u}=a.query;t.debug(`Callback params - code: ${!!i}, state: ${!!c}, error: ${l}`),n.writeHead(200,{"Content-Type":"text/html"}),l?(t.error(`OAuth error: ${l} - ${u}`),n.end("\n <html>\n <body>\n <h1>Authentication Failed</h1>\n <p>Error: Authentication error occurred.</p>\n <p>Description: Please return to the application for details.</p>\n <p>You can close this window.</p>\n </body>\n </html>\n "),s.close(),o(new k(`OAuth error: ${l} - ${u}`))):i?(t.info("OAuth callback received successfully, closing server"),n.end("\n <html>\n <body>\n <h1>Authentication Successful</h1>\n <p>You can close this window and return to your application.</p>\n <script>\n console.log('Authentication callback received. You can close this window.');\n setTimeout(() => window.close(), 1000);\n <\/script>\n </body>\n </html>\n "),s.close(),r([i,c])):(t.warn("No authorization code received in callback"),t.warn(`Full URL: ${e.url}`),t.warn("Query params:",a.query),n.end(`\n <html>\n <body>\n <h1>Authentication Failed</h1>\n <p>No authorization code received.</p>\n <p>Full URL: ${e.url}</p>\n <p>You can close this window.</p>\n </body>\n </html>\n `),s.close(),o(new k("No authorization code received")))}else t.debug(`404 for path: ${a.pathname}`),n.writeHead(404,{"Content-Type":"text/plain"}),n.end("Not found")});s.listen(e,"0.0.0.0",()=>{console.log(`OAuth callback server listening on ${n}`)}),s.on("error",e=>{o(new k(`Failed to start callback server: ${e.message}`))}),s.on("connection",e=>{t.debug(`New connection from ${e.remoteAddress}:${e.remotePort}`)})});return[n,o]}const be=H("client-credentials");async function ke(e){const{timeoutMs:t=15e3}=e,{tokenEndpoint:r,body:n}=await async function(e){const{clientId:t,clientSecret:r,audience:n,issuer:o,domain:s}=e;let a;if(o)a=(await Q(o)).token_endpoint;else{if(!s)throw new k("Either 'issuer' or 'domain' must be provided");a=`https://${s}/oauth/token`}return{tokenEndpoint:a,body:new URLSearchParams({grant_type:"client_credentials",client_id:t,client_secret:r,audience:n})}}(e),o=new AbortController,s=setTimeout(()=>o.abort(),t);try{const e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString(),signal:o.signal});if(!e.ok){const t=await e.json().catch(()=>({}));throw be.error("Client-credentials token endpoint error:",t),new k(`Client-credentials grant failed: ${t.error_description??t.error??e.statusText}`)}const t=await e.json();if(!t.access_token)throw new k("Client-credentials grant: response missing access_token");return t.access_token}catch(e){if(e instanceof k)throw e;if(e instanceof Error&&"AbortError"===e.name)throw new k(`Client-credentials grant timed out after ${t}ms`);const r=e instanceof Error?e.message:String(e);throw new k(`Client-credentials grant failed: ${r}`)}finally{clearTimeout(s)}}class Ee{constructor(e,t={}){this._credentials=null,this._logger=H("client");const{token:r,timeout:n=30,maxRetries:o=3}=t;this.base=this._validateUrl(e,"API base URL").replace(/\/$/,"");const s=Object.prototype.hasOwnProperty.call(t,"token");if(this._token=s?this._validateToken(r):null,"number"!=typeof n||n<=0)throw new E("timeout must be a positive number");if(!Number.isInteger(o)||o<0)throw new E("maxRetries must be a non-negative integer");const a=new S(n,n/3);this._http=new T(a,o),this._tokenValidated=!1,this._closed=!1,this._logger.info(`Initialized BarndoorSDK for ${this.base}`)}static async fromClientCredentials(e,t){const{timeout:r,maxRetries:n,...o}=t,s={token:await ke(o)};void 0!==r&&(s.timeout=r),void 0!==n&&(s.maxRetries=n);const a=new Ee(e,s);return a._credentials={...o},a._tokenValidated=!0,a}get token(){if(!this._token)throw new Error("No token available. Call authenticate() first or provide token in constructor.");return this._token}async authenticate(e){this._token=this._validateToken(e),this._tokenValidated=!1,await this.ensureValidToken(),this._logger.info("Authentication successful")}_validateUrl(e,t){if(!e||"string"!=typeof e)throw new E(`${t} must be a non-empty string`);try{return new URL(e),e}catch(e){throw new E(`${t} must be a valid URL`)}}_validateToken(e){if(!e||"string"!=typeof e)throw new g("Token must be a non-empty string");if(3!==e.split(".").length)throw new g("Token must be a valid JWT");return e}_ensureNotClosed(){if(this._closed)throw new Error("SDK has been closed. Create a new instance or use as context manager.")}async _req(e,t,r={}){this._ensureNotClosed(),await this.ensureValidToken(),await this._maybeRefreshM2MToken();const n=`${this.base}${t}`,o=()=>{const e={...r.headers??{}};return e.Authorization=`Bearer ${this.token}`,{...r,headers:e}};try{return await this._http.request(e,n,o())}catch(t){if(t instanceof $&&401===t.statusCode&&null!==this._credentials)return this._logger.info("M2M token rejected (401); refreshing and retrying once"),await this._refreshM2MToken(),await this._http.request(e,n,o());throw t}}async _maybeRefreshM2MToken(){null!==this._credentials&&function(e,t){const r=e.split(".");if(3!==r.length)return!0;const n=r[1];if(!n)return!0;let o;try{const e=n.replace(/-/g,"+").replace(/_/g,"/"),t="undefined"!=typeof Buffer?Buffer.from(e,"base64").toString("utf8"):globalThis.atob(e);o=JSON.parse(t)}catch{return!0}const s=o.exp;return"number"!=typeof s||s-Date.now()/1e3<=t}(this.token,60)&&(this._logger.debug("M2M token near expiry; refreshing"),await this._refreshM2MToken())}async _refreshM2MToken(){if(null===this._credentials)throw new Error("_refreshM2MToken() called on an SDK not created via BarndoorSDK.fromClientCredentials()");this._token=await ke(this._credentials),this._tokenValidated=!0}async validateCachedToken(){if(!this.token)return!1;try{const e=M(),t=(await Q(e.authIssuer)).userinfo_endpoint,r=new AbortController,n=setTimeout(()=>r.abort(),1e4);try{const e=(await fetch(t,{headers:{Authorization:`Bearer ${this.token}`},signal:r.signal})).ok;return e&&(this._tokenValidated=!0),e}finally{clearTimeout(n)}}catch(e){return!1}}async ensureValidToken(){if(!this._token)throw new Error("No token available. Call authenticate() first or provide token in constructor.");if(this._tokenValidated)return;const e=(R?process.env.BARNDOOR_ENV:"")??"";if(["test","ci"].includes(e.toLowerCase()))return void(this._tokenValidated=!0);if(!await this.validateCachedToken())throw new g("Token validation failed. Please re-authenticate.");this._tokenValidated=!0}async listServers(){this._logger.debug("Fetching server list");try{const e=[];let t=1;for(;null!==t;){const r=1===t?"/api/servers":`/api/servers?page=${t}`,n=await this._req("GET",r),o=n.data.map(e=>I.fromApiResponse(e));e.push(...o),t=n.pagination.next_page}return this._logger.info(`Retrieved ${e.length} servers total`),e}catch(e){throw this._logger.error("Failed to list servers:",e),e}}async getServer(e){const t=this._validateServerId(e);this._logger.info(`Fetching server details for ${t}`);const r=this._isUuid(t)?`/api/servers/${t}`:`/api/servers/by-slug/${t}`,n=await this._req("GET",r);return x.fromApiResponse(n)}async initiateConnection(e,t){const r=this._validateServerId(e);let n;t&&(n=this._validateUrl(t,"Return URL")),this._logger.info(`Initiating connection for server ${r}`);const o=n?{return_url:n}:void 0;try{const e=this._isUuid(r)?`/api/servers/${r}/connect`:`/api/servers/by-slug/${r}/connect`;return await this._req("POST",e,{params:o,json:{}})}catch(e){if(e instanceof $&&500===e.statusCode&&e.responseBody?.includes("OAuth server configuration not found"))throw new Error("Server is missing OAuth configuration. Ask an admin to configure credentials before initiating a connection.");throw e}}async getConnectionStatus(e){const t=this._validateServerId(e);this._logger.info(`Checking connection status for server ${t}`);const r=this._isUuid(t)?`/api/servers/${t}/connection`:`/api/servers/by-slug/${t}/connection`;return(await this._req("GET",r)).status}async disconnectServer(e){const t=this._validateServerId(e);this._logger.info(`Disconnecting from server ${t}`);try{const e=this._isUuid(t)?`/api/servers/${t}/connection`:`/api/servers/by-slug/${t}/connection`;await this._req("DELETE",e),this._logger.info(`Successfully disconnected from server ${t}`)}catch(e){if(e instanceof $&&404===e.statusCode)throw new Error(`Connection not found for server ${t}. Server may not be connected.`);throw e}}async getChannelOptions(){return this._logger.debug("Fetching notification channel options"),await this._req("GET",`${Ee.CHANNELS_PATH}/options`)}async listChannels(){this._logger.debug("Listing organization notification channels");const e=await this._req("GET",Ee.CHANNELS_PATH);return e?.data??[]}async listUserChannels(){this._logger.debug("Listing caller's personal notification channels");const e=await this._req("GET",`${Ee.CHANNELS_PATH}/user`);return e?.data??[]}async upsertChannel(e){if(!e||"object"!=typeof e)throw new Error("Channel input must be a non-empty object");if(!e.type||"string"!=typeof e.type)throw new Error("Channel type must be a non-empty string");const t={type:e.type,enabled:e.enabled??!0};void 0!==e.channelId&&(t.id=this._requireChannelId(e.channelId));const r=[["email_address",e.emailAddress],["url",e.url],["label",e.label],["slack_channel_id",e.slackChannelId],["teams_workflow_url",e.teamsWorkflowUrl]];for(const[e,n]of r)void 0!==n&&(t[e]=n);return t.subscriptions=(e.subscriptions??[]).map(e=>({alert_type:e})),this._logger.info(`Upserting notification channel (type=${e.type})`),await this._req("PUT",Ee.CHANNELS_PATH,{json:t})}async deleteChannel(e){const t=this._requireChannelId(e);this._logger.info(`Deleting notification channel ${t}`),await this._req("DELETE",`${Ee.CHANNELS_PATH}/${t}`)}async regenerateChannelSecret(e){const t=this._requireChannelId(e);return this._logger.info(`Rotating signing secret for notification channel ${t}`),await this._req("POST",`${Ee.CHANNELS_PATH}/${t}/regenerate-secret`)}async testChannel(e){const t=this._requireChannelId(e);return this._logger.debug(`Testing notification channel ${t}`),await this._req("POST",`${Ee.CHANNELS_PATH}/${t}/test`)}_requireChannelId(e){if(!e||"string"!=typeof e)throw new Error("Channel ID must be a non-empty string");const t=e.trim();if(!t)throw new Error("Channel ID cannot be empty or whitespace");return t}_validateServerId(e){if(!e||"string"!=typeof e)throw new Error("Server ID must be a non-empty string");if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)&&!/^[a-z0-9-]+$/.test(e))throw new Error("Server ID must be a valid UUID or slug (lowercase letters, numbers, and hyphens only)");return e}_isUuid(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}async listPolicies(e=1,t=10,r={}){if(!Number.isInteger(e)||e<1)throw new Error("Page must be a positive integer");if(!Number.isInteger(t)||t<1||t>1e3)throw new Error("Limit must be a positive integer between 1 and 1000");this._logger.debug(`Listing policies (page=${e}, limit=${t})`);const n={page:e,limit:t,...r};return this._req("GET","/api/v2/policies",{params:n})}async getPolicy(e){if(!e||"string"!=typeof e)throw new Error("Policy ID must be a non-empty string");if(!this._isUuid(e))throw new Error("Policy ID must be a valid UUID");return this._logger.debug(`Fetching policy details for ${e}`),this._req("GET",`/api/v2/policies/${e}`)}async createPolicy(e){if(!e||"object"!=typeof e)throw new Error("Policy data must be a non-empty object");return this._logger.debug("Creating new policy"),this._req("POST","/api/v2/policies",{json:e})}async updatePolicy(e,t){if(!e||"string"!=typeof e)throw new Error("Policy ID must be a non-empty string");if(!this._isUuid(e))throw new Error("Policy ID must be a valid UUID");if(!t||"object"!=typeof t)throw new Error("Policy data must be a non-empty object");return this._logger.debug(`Updating policy ${e}`),this._req("PATCH",`/api/v2/policies/${e}`,{json:t})}async clonePolicy(e,t){if(!e||"string"!=typeof e)throw new Error("Policy ID must be a non-empty string");if(!this._isUuid(e))throw new Error("Policy ID must be a valid UUID");if(!t||"string"!=typeof t)throw new Error("New name must be a non-empty string");return this._logger.debug(`Cloning policy ${e} with new name: ${t}`),this._req("POST",`/api/v2/policies/${e}/clone`,{json:{name:t}})}async validatePolicy(e){if(!e||"object"!=typeof e)throw new Error("Validation data must be a non-empty object");return this._logger.debug("Validating policy configuration"),this._req("POST","/api/v2/policies/validate",{json:e})}async getPolicySummary(){return this._logger.debug("Fetching policy summary"),this._req("GET","/api/v2/policies/summary")}async getPolicyFilterDefinitions(){return this._logger.debug("Fetching policy filter definitions"),this._req("GET","/api/v2/policies/filter-definitions")}async close(){this._closed||(await this._http.close(),this._closed=!0)}async aclose(){await this.close()}async ensureServerConnected(t,r={}){const{pollSeconds:n=60}=r;if(!R)throw new Error("ensureServerConnected requires Node.js environment for browser opening");let o;try{o=await this.getServer(t)}catch(e){if(e instanceof $&&404===e.statusCode)throw new b(t);throw e}if("connected"===o.connection_status)return;const s=o.slug||t,a=(await this.initiateConnection(s)).auth_url;if(!a)throw new Error("Registry did not return auth_url");const i=e.platform();let c;try{c=new URL(a)}catch{throw new Error("Invalid auth_url returned by server")}if("https:"!==c.protocol&&("http:"!==c.protocol||"localhost"!==c.hostname&&"127.0.0.1"!==c.hostname))throw new Error("Auth URL must use HTTPS (http allowed only for localhost)");try{"darwin"===i?d("open",[a],{detached:!0,stdio:"ignore"}).unref():"win32"===i?d("powershell",["-NoProfile","Start-Process",a],{detached:!0,stdio:"ignore"}).unref():d("xdg-open",[a],{detached:!0,stdio:"ignore"}).unref()}catch(e){this._logger.warn("Failed to open browser",e)}for(let e=0;e<n;e++){if("connected"===await this.getConnectionStatus(s))return;await new Promise(e=>setTimeout(e,1e3))}throw new Error("OAuth connection was not completed in time")}}Ee.CHANNELS_PATH="/api/notification/public/v1/channels";const Pe=Object.freeze({status:"aborted"});function Se(e,t,r){function n(r,n){var o;Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(o=r._zod).traits??(o.traits=new Set),r._zod.traits.add(e),t(r,n);for(const e in a.prototype)e in r||Object.defineProperty(r,e,{value:a.prototype[e].bind(r)});r._zod.constr=a,r._zod.def=n}const o=r?.Parent??Object;class s extends o{}function a(e){var t;const o=r?.Parent?new s:this;n(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class Te extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Ie={};function xe(e){return e&&Object.assign(Ie,e),Ie}function Ne(e,t){return"bigint"==typeof t?t.toString():t}function Ce(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function je(e){return null==e}function Re(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Oe(e,t,r){Object.defineProperty(e,t,{get(){{const n=r();return e[t]=n,n}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function ze(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ae(e){return JSON.stringify(e)}const Me=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Ue(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const De=Ce(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function qe(e){if(!1===Ue(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!1!==Ue(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}const Ve=new Set(["string","number","symbol"]);function Fe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Le(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function He(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const Ke={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ze(e,t=0){for(let r=t;r<e.issues.length;r++)if(!0!==e.issues[r]?.continue)return!0;return!1}function Ge(e,t){return t.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function Be(e){return"string"==typeof e?e:e?.message}function Je(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const o=Be(e.inst?._zod.def?.error?.(e))??Be(t?.error?.(e))??Be(r.customError?.(e))??Be(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function We(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function Qe(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}const Ye=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,Ne,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Xe=Se("$ZodError",Ye),et=Se("$ZodError",Ye,{Parent:Error});const tt=e=>(t,r,n,o)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Te;if(a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>Je(e,s,xe())));throw Me(t,o?.callee),t}return a.value},rt=e=>async(t,r,n,o)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>Je(e,s,xe())));throw Me(t,o?.callee),t}return a.value},nt=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Te;return s.issues.length?{success:!1,error:new(e??Xe)(s.issues.map(e=>Je(e,o,xe())))}:{success:!0,data:s.value}},ot=nt(et),st=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>Je(e,o,xe())))}:{success:!0,data:s.value}},at=st(et),it=/^[cC][^\s-]{8,}$/,ct=/^[0-9a-z]+$/,lt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ut=/^[0-9a-vA-V]{20}$/,dt=/^[A-Za-z0-9]{27}$/,ht=/^[a-zA-Z0-9_-]{21}$/,pt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ft=/^([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})$/,mt=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)$/,yt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const gt=/^(?:(?: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])$/,vt=/^(([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})$/,_t=/^((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])$/,wt=/^(([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])$/,$t=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bt=/^[A-Za-z0-9_-]*$/,kt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Et=/^\+(?:[0-9]){6,14}[0-9]$/,Pt="(?:(?:\\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])))",St=new RegExp(`^${Pt}$`);function Tt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const It=/^\d+$/,xt=/^-?\d+(?:\.\d+)?/i,Nt=/true|false/i,Ct=/null/i,jt=/^[^A-Z]*$/,Rt=/^[^a-z]*$/,Ot=Se("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),zt={number:"number",bigint:"bigint",object:"date"},At=Se("$ZodCheckLessThan",(e,t)=>{Ot.init(e,t);const r=zt[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Mt=Se("$ZodCheckGreaterThan",(e,t)=>{Ot.init(e,t);const r=zt[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ut=Se("$ZodCheckMultipleOf",(e,t)=>{Ot.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===function(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n;return Number.parseInt(e.toFixed(o).replace(".",""))%Number.parseInt(t.toFixed(o).replace(".",""))/10**o}(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Dt=Se("$ZodCheckNumberFormat",(e,t)=>{Ot.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Ke[t.format];e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,n.minimum=o,n.maximum=s,r&&(n.pattern=It)}),e._zod.check=a=>{const i=a.value;if(r){if(!Number.isInteger(i))return void a.issues.push({expected:n,format:t.format,code:"invalid_type",input:i,inst:e});if(!Number.isSafeInteger(i))return void(i>0?a.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):a.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}))}i<o&&a.issues.push({origin:"number",input:i,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),i>s&&a.issues.push({origin:"number",input:i,code:"too_big",maximum:s,inst:e})}}),qt=Se("$ZodCheckMaxLength",(e,t)=>{var r;Ot.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!je(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const n=r.value;if(n.length<=t.maximum)return;const o=We(n);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Vt=Se("$ZodCheckMinLength",(e,t)=>{var r;Ot.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!je(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const n=r.value;if(n.length>=t.minimum)return;const o=We(n);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ft=Se("$ZodCheckLengthEquals",(e,t)=>{var r;Ot.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!je(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{const n=r.value,o=n.length;if(o===t.length)return;const s=We(n),a=o>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Lt=Se("$ZodCheckStringFormat",(e,t)=>{var r,n;Ot.init(e,t),e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Ht=Se("$ZodCheckRegex",(e,t)=>{Lt.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Kt=Se("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=jt),Lt.init(e,t)}),Zt=Se("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Rt),Lt.init(e,t)}),Gt=Se("$ZodCheckIncludes",(e,t)=>{Ot.init(e,t);const r=Fe(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Bt=Se("$ZodCheckStartsWith",(e,t)=>{Ot.init(e,t);const r=new RegExp(`^${Fe(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),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})}}),Jt=Se("$ZodCheckEndsWith",(e,t)=>{Ot.init(e,t);const r=new RegExp(`.*${Fe(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),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})}}),Wt=Se("$ZodCheckOverwrite",(e,t)=>{Ot.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Qt{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length)),n=t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e);for(const e of n)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Yt={major:4,minor:0,patch:0},Xt=Se("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Yt;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let n,o=Ze(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===r?.async)throw new Te;if(n||a instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await a;e.issues.length!==t&&(o||(o=Ze(e,t)))});else{if(e.issues.length===t)continue;o||(o=Ze(e,t))}}return n?n.then(()=>e):e};e._zod.run=(r,o)=>{const s=e._zod.parse(r,o);if(s instanceof Promise){if(!1===o.async)throw new Te;return s.then(e=>t(e,n,o))}return t(s,n,o)}}e["~standard"]={validate:t=>{try{const r=ot(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return at(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),er=Se("$ZodString",(e,t)=>{var r;Xt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(r=e._zod.bag,new RegExp(`^${r?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),tr=Se("$ZodStringFormat",(e,t)=>{Lt.init(e,t),er.init(e,t)}),rr=Se("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ft),tr.init(e,t)}),nr=Se("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mt(e))}else t.pattern??(t.pattern=mt());tr.init(e,t)}),or=Se("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=yt),tr.init(e,t)}),sr=Se("$ZodURL",(e,t)=>{tr.init(e,t),e._zod.check=r=>{try{const n=r.value,o=new URL(n),s=o.href;return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:kt.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),void(!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s)}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ar=Se("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),tr.init(e,t)}),ir=Se("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ht),tr.init(e,t)}),cr=Se("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=it),tr.init(e,t)}),lr=Se("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ct),tr.init(e,t)}),ur=Se("$ZodULID",(e,t)=>{t.pattern??(t.pattern=lt),tr.init(e,t)}),dr=Se("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ut),tr.init(e,t)}),hr=Se("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=dt),tr.init(e,t)}),pr=Se("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=Tt({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Pt}T(?:${n})$`)}(t)),tr.init(e,t)}),fr=Se("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=St),tr.init(e,t)}),mr=Se("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Tt(t)}$`)),tr.init(e,t)}),yr=Se("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pt),tr.init(e,t)}),gr=Se("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=gt),tr.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),vr=Se("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=vt),tr.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),_r=Se("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=_t),tr.init(e,t)}),wr=Se("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=wt),tr.init(e,t),e._zod.check=r=>{const[n,o]=r.value.split("/");try{if(!o)throw new Error;const e=Number(o);if(`${e}`!==o)throw new Error;if(e<0||e>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function $r(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const br=Se("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=$t),tr.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{$r(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});const kr=Se("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=bt),tr.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{(function(e){if(!bt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return $r(t.padEnd(4*Math.ceil(t.length/4),"="))})(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Er=Se("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Et),tr.init(e,t)});const Pr=Se("$ZodJWT",(e,t)=>{tr.init(e,t),e._zod.check=r=>{(function(e,t=null){try{const r=e.split(".");if(3!==r.length)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Sr=Se("$ZodNumber",(e,t)=>{Xt.init(e,t),e._zod.pattern=e._zod.bag.pattern??xt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}const o=r.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return r;const s="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Tr=Se("$ZodNumber",(e,t)=>{Dt.init(e,t),Sr.init(e,t)}),Ir=Se("$ZodBoolean",(e,t)=>{Xt.init(e,t),e._zod.pattern=Nt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(e){}const o=r.value;return"boolean"==typeof o||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),xr=Se("$ZodNull",(e,t)=>{Xt.init(e,t),e._zod.pattern=Ct,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{const n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),Nr=Se("$ZodAny",(e,t)=>{Xt.init(e,t),e._zod.parse=e=>e}),Cr=Se("$ZodUnknown",(e,t)=>{Xt.init(e,t),e._zod.parse=e=>e}),jr=Se("$ZodNever",(e,t)=>{Xt.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Rr(e,t,r){e.issues.length&&t.issues.push(...Ge(r,e.issues)),t.value[r]=e.value}const Or=Se("$ZodArray",(e,t)=>{Xt.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const s=[];for(let e=0;e<o.length;e++){const a=o[e],i=t.element._zod.run({value:a,issues:[]},n);i instanceof Promise?s.push(i.then(t=>Rr(t,r,e))):Rr(i,r,e)}return s.length?Promise.all(s).then(()=>r):r}});function zr(e,t,r){e.issues.length&&t.issues.push(...Ge(r,e.issues)),t.value[r]=e.value}function Ar(e,t,r,n){e.issues.length?void 0===n[r]?t.value[r]=r in n?void 0:e.value:t.issues.push(...Ge(r,e.issues)):void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const Mr=Se("$ZodObject",(e,t)=>{Xt.init(e,t);const r=Ce(()=>{const e=Object.keys(t.shape);for(const r of e)if(!(t.shape[r]instanceof Xt))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const r=(n=t.shape,Object.keys(n).filter(e=>"optional"===n[e]._zod.optin&&"optional"===n[e]._zod.optout));var n;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}});Oe(e._zod,"propValues",()=>{const e=t.shape,r={};for(const t in e){const n=e[t]._zod;if(n.values){r[t]??(r[t]=new Set);for(const e of n.values)r[t].add(e)}}return r});let n;const o=Ue,s=!Ie.jitless,a=s&&De.value,i=t.catchall;let c;e._zod.parse=(l,u)=>{c??(c=r.value);const d=l.value;if(!o(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;const h=[];if(s&&a&&!1===u?.async&&!0!==u.jitless)n||(n=(e=>{const t=new Qt(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Ae(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=Object.create(null);let a=0;for(const e of n.keys)s[e]="key_"+a++;t.write("const newResult = {}");for(const e of n.keys)if(n.optionalKeys.has(e)){const r=s[e];t.write(`const ${r} = ${o(e)};`);const n=Ae(e);t.write(`\n if (${r}.issues.length) {\n if (input[${n}] === undefined) {\n if (${n} in input) {\n newResult[${n}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${r}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${n}, ...iss.path] : [${n}],\n }))\n );\n }\n } else if (${r}.value === undefined) {\n if (${n} in input) newResult[${n}] = undefined;\n } else {\n newResult[${n}] = ${r}.value;\n }\n `)}else{const r=s[e];t.write(`const ${r} = ${o(e)};`),t.write(`\n if (${r}.issues.length) payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${Ae(e)}, ...iss.path] : [${Ae(e)}]\n })));`),t.write(`newResult[${Ae(e)}] = ${r}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const i=t.compile();return(t,r)=>i(e,t,r)})(t.shape)),l=n(l,u);else{l.value={};const e=c.shape;for(const t of c.keys){const r=e[t],n=r._zod.run({value:d[t],issues:[]},u),o="optional"===r._zod.optin&&"optional"===r._zod.optout;n instanceof Promise?h.push(n.then(e=>o?Ar(e,l,t,d):zr(e,l,t))):o?Ar(n,l,t,d):zr(n,l,t)}}if(!i)return h.length?Promise.all(h).then(()=>l):l;const p=[],f=c.keySet,m=i._zod,y=m.def.type;for(const e of Object.keys(d)){if(f.has(e))continue;if("never"===y){p.push(e);continue}const t=m.run({value:d[e],issues:[]},u);t instanceof Promise?h.push(t.then(t=>zr(t,l,e))):zr(t,l,e)}return p.length&&l.issues.push({code:"unrecognized_keys",keys:p,input:d,inst:e}),h.length?Promise.all(h).then(()=>l):l}});function Ur(e,t,r,n){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>Je(e,n,xe())))}),t}const Dr=Se("$ZodUnion",(e,t)=>{Xt.init(e,t),Oe(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Oe(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Oe(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Oe(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>Re(e.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let o=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},n);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>Ur(t,r,e,n)):Ur(s,r,e,n)}}),qr=Se("$ZodDiscriminatedUnion",(e,t)=>{Dr.init(e,t);const r=e._zod.parse;Oe(e._zod,"propValues",()=>{const e={};for(const r of t.options){const n=r._zod.propValues;if(!n||0===Object.keys(n).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const[t,r]of Object.entries(n)){e[t]||(e[t]=new Set);for(const n of r)e[t].add(n)}}return e});const n=Ce(()=>{const e=t.options,r=new Map;for(const n of e){const e=n._zod.propValues[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const t of e){if(r.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,n)}}return r});e._zod.parse=(o,s)=>{const a=o.value;if(!Ue(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const i=n.value.get(a?.[t.discriminator]);return i?i._zod.run(o,s):t.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),o)}}),Vr=Se("$ZodIntersection",(e,t)=>{Xt.init(e,t),e._zod.parse=(e,r)=>{const n=e.value,o=t.left._zod.run({value:n,issues:[]},r),s=t.right._zod.run({value:n,issues:[]},r);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([t,r])=>Lr(e,t,r)):Lr(e,o,s)}});function Fr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(qe(e)&&qe(t)){const r=Object.keys(t),n=Object.keys(e).filter(e=>-1!==r.indexOf(e)),o={...e,...t};for(const r of n){const n=Fr(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};o[r]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const o=Fr(e[n],t[n]);if(!o.valid)return{valid:!1,mergeErrorPath:[n,...o.mergeErrorPath]};r.push(o.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Lr(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Ze(e))return e;const n=Fr(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const Hr=Se("$ZodRecord",(e,t)=>{Xt.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!qe(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const s=[];if(t.keyType._zod.values){const a=t.keyType._zod.values;r.value={};for(const e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const a=t.valueType._zod.run({value:o[e],issues:[]},n);a instanceof Promise?s.push(a.then(t=>{t.issues.length&&r.issues.push(...Ge(e,t.issues)),r.value[e]=t.value})):(a.issues.length&&r.issues.push(...Ge(e,a.issues)),r.value[e]=a.value)}let i;for(const e in o)a.has(e)||(i=i??[],i.push(e));i&&i.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:i})}else{r.value={};for(const a of Reflect.ownKeys(o)){if("__proto__"===a)continue;const i=t.keyType._zod.run({value:a,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(i.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:i.issues.map(e=>Je(e,n,xe())),input:a,path:[a],inst:e}),r.value[i.value]=i.value;continue}const c=t.valueType._zod.run({value:o[a],issues:[]},n);c instanceof Promise?s.push(c.then(e=>{e.issues.length&&r.issues.push(...Ge(a,e.issues)),r.value[i.value]=e.value})):(c.issues.length&&r.issues.push(...Ge(a,c.issues)),r.value[i.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}}),Kr=Se("$ZodEnum",(e,t)=>{Xt.init(e,t);const r=function(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(e=>Ve.has(typeof e)).map(e=>"string"==typeof e?Fe(e):e.toString()).join("|")})$`),e._zod.parse=(t,n)=>{const o=t.value;return e._zod.values.has(o)||t.issues.push({code:"invalid_value",values:r,input:o,inst:e}),t}}),Zr=Se("$ZodLiteral",(e,t)=>{Xt.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?Fe(e):e?e.toString():String(e)).join("|")})$`),e._zod.parse=(r,n)=>{const o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),Gr=Se("$ZodTransform",(e,t)=>{Xt.init(e,t),e._zod.parse=(e,r)=>{const n=t.transform(e.value,e);if(r.async){return(n instanceof Promise?n:Promise.resolve(n)).then(t=>(e.value=t,e))}if(n instanceof Promise)throw new Te;return e.value=n,e}}),Br=Se("$ZodOptional",(e,t)=>{Xt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Oe(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Re(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>"optional"===t.innerType._zod.optin?t.innerType._zod.run(e,r):void 0===e.value?e:t.innerType._zod.run(e,r)}),Jr=Se("$ZodNullable",(e,t)=>{Xt.init(e,t),Oe(e._zod,"optin",()=>t.innerType._zod.optin),Oe(e._zod,"optout",()=>t.innerType._zod.optout),Oe(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Re(e.source)}|null)$`):void 0}),Oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),Wr=Se("$ZodDefault",(e,t)=>{Xt.init(e,t),e._zod.optin="optional",Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>Qr(e,t)):Qr(n,t)}});function Qr(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Yr=Se("$ZodPrefault",(e,t)=>{Xt.init(e,t),e._zod.optin="optional",Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),Xr=Se("$ZodNonOptional",(e,t)=>{Xt.init(e,t),Oe(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(t=>en(t,e)):en(o,e)}});function en(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const tn=Se("$ZodCatch",(e,t)=>{Xt.init(e,t),e._zod.optin="optional",Oe(e._zod,"optout",()=>t.innerType._zod.optout),Oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>Je(e,r,xe()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>Je(e,r,xe()))},input:e.value}),e.issues=[]),e)}}),rn=Se("$ZodPipe",(e,t)=>{Xt.init(e,t),Oe(e._zod,"values",()=>t.in._zod.values),Oe(e._zod,"optin",()=>t.in._zod.optin),Oe(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(e,r)=>{const n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>nn(e,t,r)):nn(n,t,r)}});function nn(e,t,r){return Ze(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const on=Se("$ZodReadonly",(e,t)=>{Xt.init(e,t),Oe(e._zod,"propValues",()=>t.innerType._zod.propValues),Oe(e._zod,"values",()=>t.innerType._zod.values),Oe(e._zod,"optin",()=>t.innerType._zod.optin),Oe(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,r)=>{const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(sn):sn(n)}});function sn(e){return e.value=Object.freeze(e.value),e}const an=Se("$ZodCustom",(e,t)=>{Ot.init(e,t),Xt.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(t=>cn(t,r,n,e));cn(o,r,n,e)}});function cn(e,t,r,n){if(!e){const e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(Qe(e))}}class ln{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const r=t[0];if(this._map.set(e,r),r&&"object"==typeof r&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};return delete r.id,{...r,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function un(){return new ln}const dn=un();function hn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...He(t)})}function pn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...He(t)})}function fn(e,t){return new At({check:"less_than",...He(t),value:e,inclusive:!1})}function mn(e,t){return new At({check:"less_than",...He(t),value:e,inclusive:!0})}function yn(e,t){return new Mt({check:"greater_than",...He(t),value:e,inclusive:!1})}function gn(e,t){return new Mt({check:"greater_than",...He(t),value:e,inclusive:!0})}function vn(e,t){return new Ut({check:"multiple_of",...He(t),value:e})}function _n(e,t){return new qt({check:"max_length",...He(t),maximum:e})}function wn(e,t){return new Vt({check:"min_length",...He(t),minimum:e})}function $n(e,t){return new Ft({check:"length_equals",...He(t),length:e})}function bn(e){return new Wt({check:"overwrite",tx:e})}function kn(e){return!!e._zod}function En(e,t){if(kn(e)){return ot(e,t)}return e.safeParse(t)}function Pn(e){if(!e)return;let t;if(kn(e)){const r=e;t=r._zod?.def?.shape}else{t=e.shape}if(t){if("function"==typeof t)try{return t()}catch{return}return t}}const Sn=Se("ZodISODateTime",(e,t)=>{pr.init(e,t),Ln.init(e,t)});function Tn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...He(t)})}(Sn,e)}const In=Se("ZodISODate",(e,t)=>{fr.init(e,t),Ln.init(e,t)});function xn(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...He(t)})}(In,e)}const Nn=Se("ZodISOTime",(e,t)=>{mr.init(e,t),Ln.init(e,t)});function Cn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...He(t)})}(Nn,e)}const jn=Se("ZodISODuration",(e,t)=>{yr.init(e,t),Ln.init(e,t)});function Rn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...He(t)})}(jn,e)}const On=Se("ZodError",(e,t)=>{Xe.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t){const r=t||function(e){return e.message},n={_errors:[]},o=e=>{for(const t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>o({issues:e}));else if("invalid_key"===t.code)o({issues:t.issues});else if("invalid_element"===t.code)o({issues:t.issues});else if(0===t.path.length)n._errors.push(r(t));else{let e=n,o=0;for(;o<t.path.length;){const n=t.path[o];o===t.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(r(t))):e[n]=e[n]||{_errors:[]},e=e[n],o++}}};return o(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),zn=tt(On),An=rt(On),Mn=nt(On),Un=st(On),Dn=Se("ZodType",(e,t)=>(Xt.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,r)=>Le(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>zn(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Mn(e,t,r),e.parseAsync=async(t,r)=>An(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Un(e,t,r),e.spa=e.safeParseAsync,e.refine=(t,r)=>e.check(function(e,t={}){return function(e,t,r){return new e({type:"custom",check:"custom",fn:t,...He(r)})}(Xo,e,t)}(t,r)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new Ot({check:"custom"});return t._zod.check=e,t}(r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(Qe(e,r.value,t._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(Qe(n))}},e(r.value,r)));return t}(t)),e.overwrite=t=>e.check(bn(t)),e.optional=()=>Lo(e),e.nullable=()=>Ko(e),e.nullish=()=>Lo(Ko(e)),e.nonoptional=t=>function(e,t){return new Bo({type:"nonoptional",innerType:e,...He(t)})}(e,t),e.array=()=>Eo(e),e.or=t=>xo([e,t]),e.and=t=>Ro(e,t),e.transform=t=>Qo(e,Vo(t)),e.default=t=>{return r=t,new Zo({type:"default",innerType:e,get defaultValue(){return"function"==typeof r?r():r}});var r},e.prefault=t=>{return r=t,new Go({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof r?r():r}});var r},e.catch=t=>{return new Jo({type:"catch",innerType:e,catchValue:"function"==typeof(r=t)?r:()=>r});var r},e.pipe=t=>Qo(e,t),e.readonly=()=>new Yo({type:"readonly",innerType:e}),e.describe=t=>{const r=e.clone();return dn.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>dn.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return dn.get(e);const r=e.clone();return dn.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),qn=Se("_ZodString",(e,t)=>{er.init(e,t),Dn.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new Ht({check:"string_format",format:"regex",...He(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Gt({check:"string_format",format:"includes",...He(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Bt({check:"string_format",format:"starts_with",...He(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Jt({check:"string_format",format:"ends_with",...He(t),suffix:e})}(...t)),e.min=(...t)=>e.check(wn(...t)),e.max=(...t)=>e.check(_n(...t)),e.length=(...t)=>e.check($n(...t)),e.nonempty=(...t)=>e.check(wn(1,...t)),e.lowercase=t=>e.check(function(e){return new Kt({check:"string_format",format:"lowercase",...He(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Zt({check:"string_format",format:"uppercase",...He(e)})}(t)),e.trim=()=>e.check(bn(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return bn(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(bn(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(bn(e=>e.toUpperCase()))}),Vn=Se("ZodString",(e,t)=>{er.init(e,t),qn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...He(t)})}(Hn,t)),e.url=t=>e.check(pn(Gn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...He(t)})}(co,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...He(t)})}(Bn,t)),e.guid=t=>e.check(hn(Kn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...He(t)})}(Zn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...He(t)})}(Zn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...He(t)})}(Zn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...He(t)})}(Zn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...He(t)})}(Jn,t)),e.guid=t=>e.check(hn(Kn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...He(t)})}(Wn,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...He(t)})}(Qn,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...He(t)})}(Yn,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...He(t)})}(so,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...He(t)})}(ao,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...He(t)})}(Xn,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...He(t)})}(eo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...He(t)})}(to,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...He(t)})}(ro,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...He(t)})}(no,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...He(t)})}(oo,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...He(t)})}(io,t)),e.datetime=t=>e.check(Tn(t)),e.date=t=>e.check(xn(t)),e.time=t=>e.check(Cn(t)),e.duration=t=>e.check(Rn(t))});function Fn(e){return function(e,t){return new e({type:"string",...He(t)})}(Vn,e)}const Ln=Se("ZodStringFormat",(e,t)=>{tr.init(e,t),qn.init(e,t)}),Hn=Se("ZodEmail",(e,t)=>{or.init(e,t),Ln.init(e,t)}),Kn=Se("ZodGUID",(e,t)=>{rr.init(e,t),Ln.init(e,t)}),Zn=Se("ZodUUID",(e,t)=>{nr.init(e,t),Ln.init(e,t)}),Gn=Se("ZodURL",(e,t)=>{sr.init(e,t),Ln.init(e,t)});const Bn=Se("ZodEmoji",(e,t)=>{ar.init(e,t),Ln.init(e,t)}),Jn=Se("ZodNanoID",(e,t)=>{ir.init(e,t),Ln.init(e,t)}),Wn=Se("ZodCUID",(e,t)=>{cr.init(e,t),Ln.init(e,t)}),Qn=Se("ZodCUID2",(e,t)=>{lr.init(e,t),Ln.init(e,t)}),Yn=Se("ZodULID",(e,t)=>{ur.init(e,t),Ln.init(e,t)}),Xn=Se("ZodXID",(e,t)=>{dr.init(e,t),Ln.init(e,t)}),eo=Se("ZodKSUID",(e,t)=>{hr.init(e,t),Ln.init(e,t)}),to=Se("ZodIPv4",(e,t)=>{gr.init(e,t),Ln.init(e,t)}),ro=Se("ZodIPv6",(e,t)=>{vr.init(e,t),Ln.init(e,t)}),no=Se("ZodCIDRv4",(e,t)=>{_r.init(e,t),Ln.init(e,t)}),oo=Se("ZodCIDRv6",(e,t)=>{wr.init(e,t),Ln.init(e,t)}),so=Se("ZodBase64",(e,t)=>{br.init(e,t),Ln.init(e,t)}),ao=Se("ZodBase64URL",(e,t)=>{kr.init(e,t),Ln.init(e,t)}),io=Se("ZodE164",(e,t)=>{Er.init(e,t),Ln.init(e,t)}),co=Se("ZodJWT",(e,t)=>{Pr.init(e,t),Ln.init(e,t)}),lo=Se("ZodNumber",(e,t)=>{Sr.init(e,t),Dn.init(e,t),e.gt=(t,r)=>e.check(yn(t,r)),e.gte=(t,r)=>e.check(gn(t,r)),e.min=(t,r)=>e.check(gn(t,r)),e.lt=(t,r)=>e.check(fn(t,r)),e.lte=(t,r)=>e.check(mn(t,r)),e.max=(t,r)=>e.check(mn(t,r)),e.int=t=>e.check(po(t)),e.safe=t=>e.check(po(t)),e.positive=t=>e.check(yn(0,t)),e.nonnegative=t=>e.check(gn(0,t)),e.negative=t=>e.check(fn(0,t)),e.nonpositive=t=>e.check(mn(0,t)),e.multipleOf=(t,r)=>e.check(vn(t,r)),e.step=(t,r)=>e.check(vn(t,r)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function uo(e){return function(e,t){return new e({type:"number",checks:[],...He(t)})}(lo,e)}const ho=Se("ZodNumberFormat",(e,t)=>{Tr.init(e,t),lo.init(e,t)});function po(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...He(t)})}(ho,e)}const fo=Se("ZodBoolean",(e,t)=>{Ir.init(e,t),Dn.init(e,t)});function mo(e){return function(e,t){return new e({type:"boolean",...He(t)})}(fo,e)}const yo=Se("ZodNull",(e,t)=>{xr.init(e,t),Dn.init(e,t)});function go(e){return function(e,t){return new e({type:"null",...He(t)})}(yo,e)}const vo=Se("ZodAny",(e,t)=>{Nr.init(e,t),Dn.init(e,t)});const _o=Se("ZodUnknown",(e,t)=>{Cr.init(e,t),Dn.init(e,t)});function wo(){return new _o({type:"unknown"})}const $o=Se("ZodNever",(e,t)=>{jr.init(e,t),Dn.init(e,t)});function bo(e){return function(e,t){return new e({type:"never",...He(t)})}($o,e)}const ko=Se("ZodArray",(e,t)=>{Or.init(e,t),Dn.init(e,t),e.element=t.element,e.min=(t,r)=>e.check(wn(t,r)),e.nonempty=t=>e.check(wn(1,t)),e.max=(t,r)=>e.check(_n(t,r)),e.length=(t,r)=>e.check($n(t,r)),e.unwrap=()=>e.element});function Eo(e,t){return function(e,t,r){return new e({type:"array",element:t,...He(r)})}(ko,e,t)}const Po=Se("ZodObject",(e,t)=>{Mr.init(e,t),Dn.init(e,t),Oe(e,"shape",()=>t.shape),e.keyof=()=>Mo(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:wo()}),e.loose=()=>e.clone({...e._zod.def,catchall:wo()}),e.strict=()=>e.clone({...e._zod.def,catchall:bo()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!qe(t))throw new Error("Invalid input to extend: expected a plain object");const r={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return ze(this,"shape",r),r},checks:[]};return Le(e,r)}(e,t),e.merge=t=>{return n=t,Le(r=e,{...r._zod.def,get shape(){const e={...r._zod.def.shape,...n._zod.def.shape};return ze(this,"shape",e),e},catchall:n._zod.def.catchall,checks:[]});var r,n},e.pick=t=>function(e,t){const r={},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(r[e]=n.shape[e])}return Le(e,{...e._zod.def,shape:r,checks:[]})}(e,t),e.omit=t=>function(e,t){const r={...e._zod.def.shape},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Le(e,{...e._zod.def,shape:r,checks:[]})}(e,t),e.partial=(...t)=>function(e,t,r){const n=t._zod.def.shape,o={...n};if(r)for(const t in r){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(o[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)o[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return Le(t,{...t._zod.def,shape:o,checks:[]})}(Fo,e,t[0]),e.required=(...t)=>function(e,t,r){const n=t._zod.def.shape,o={...n};if(r)for(const t in r){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(o[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(const t in n)o[t]=new e({type:"nonoptional",innerType:n[t]});return Le(t,{...t._zod.def,shape:o,checks:[]})}(Bo,e,t[0])});function So(e,t){const r={type:"object",get shape(){return ze(this,"shape",{...e}),this.shape},...He(t)};return new Po(r)}function To(e,t){return new Po({type:"object",get shape(){return ze(this,"shape",{...e}),this.shape},catchall:wo(),...He(t)})}const Io=Se("ZodUnion",(e,t)=>{Dr.init(e,t),Dn.init(e,t),e.options=t.options});function xo(e,t){return new Io({type:"union",options:e,...He(t)})}const No=Se("ZodDiscriminatedUnion",(e,t)=>{Io.init(e,t),qr.init(e,t)});function Co(e,t,r){return new No({type:"union",options:t,discriminator:e,...He(r)})}const jo=Se("ZodIntersection",(e,t)=>{Vr.init(e,t),Dn.init(e,t)});function Ro(e,t){return new jo({type:"intersection",left:e,right:t})}const Oo=Se("ZodRecord",(e,t)=>{Hr.init(e,t),Dn.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function zo(e,t,r){return new Oo({type:"record",keyType:e,valueType:t,...He(r)})}const Ao=Se("ZodEnum",(e,t)=>{Kr.init(e,t),Dn.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const o={};for(const n of e){if(!r.has(n))throw new Error(`Key ${n} not found in enum`);o[n]=t.entries[n]}return new Ao({...t,checks:[],...He(n),entries:o})},e.exclude=(e,n)=>{const o={...t.entries};for(const t of e){if(!r.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new Ao({...t,checks:[],...He(n),entries:o})}});function Mo(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ao({type:"enum",entries:r,...He(t)})}const Uo=Se("ZodLiteral",(e,t)=>{Zr.init(e,t),Dn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Do(e,t){return new Uo({type:"literal",values:Array.isArray(e)?e:[e],...He(t)})}const qo=Se("ZodTransform",(e,t)=>{Gr.init(e,t),Dn.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=n=>{if("string"==typeof n)r.issues.push(Qe(n,r.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),t.continue??(t.continue=!0),r.issues.push(Qe(t))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(e=>(r.value=e,r)):(r.value=o,r)}});function Vo(e){return new qo({type:"transform",transform:e})}const Fo=Se("ZodOptional",(e,t)=>{Br.init(e,t),Dn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Lo(e){return new Fo({type:"optional",innerType:e})}const Ho=Se("ZodNullable",(e,t)=>{Jr.init(e,t),Dn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ko(e){return new Ho({type:"nullable",innerType:e})}const Zo=Se("ZodDefault",(e,t)=>{Wr.init(e,t),Dn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const Go=Se("ZodPrefault",(e,t)=>{Yr.init(e,t),Dn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Bo=Se("ZodNonOptional",(e,t)=>{Xr.init(e,t),Dn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Jo=Se("ZodCatch",(e,t)=>{tn.init(e,t),Dn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Wo=Se("ZodPipe",(e,t)=>{rn.init(e,t),Dn.init(e,t),e.in=t.in,e.out=t.out});function Qo(e,t){return new Wo({type:"pipe",in:e,out:t})}const Yo=Se("ZodReadonly",(e,t)=>{on.init(e,t),Dn.init(e,t)});const Xo=Se("ZodCustom",(e,t)=>{an.init(e,t),Dn.init(e,t)});function es(e,t){return Qo(Vo(e),t)}const ts="custom";const rs="2025-11-25",ns=[rs,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],os="io.modelcontextprotocol/related-task",ss="2.0",as=function(e,t,r){const n=He(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}(Xo,(e=>null!==e&&("object"==typeof e||"function"==typeof e))??(()=>!0),is);var is;const cs=xo([Fn(),uo().int()]),ls=Fn();To({ttl:xo([uo(),go()]).optional(),pollInterval:uo().optional()});const us=So({ttl:uo().optional()}),ds=So({taskId:Fn()}),hs=To({progressToken:cs.optional(),[os]:ds.optional()}),ps=So({_meta:hs.optional()}),fs=ps.extend({task:us.optional()}),ms=So({method:Fn(),params:ps.loose().optional()}),ys=So({_meta:hs.optional()}),gs=So({method:Fn(),params:ys.loose().optional()}),vs=To({_meta:hs.optional()}),_s=xo([Fn(),uo().int()]),ws=So({jsonrpc:Do(ss),id:_s,...ms.shape}).strict(),$s=e=>ws.safeParse(e).success,bs=So({jsonrpc:Do(ss),...gs.shape}).strict(),ks=So({jsonrpc:Do(ss),id:_s,result:vs}).strict(),Es=e=>ks.safeParse(e).success;var Ps;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"}(Ps||(Ps={}));const Ss=So({jsonrpc:Do(ss),id:_s.optional(),error:So({code:uo().int(),message:Fn(),data:wo().optional()})}).strict(),Ts=xo([ws,bs,ks,Ss]);xo([ks,Ss]);const Is=vs.strict(),xs=ys.extend({requestId:_s.optional(),reason:Fn().optional()}),Ns=gs.extend({method:Do("notifications/cancelled"),params:xs}),Cs=So({src:Fn(),mimeType:Fn().optional(),sizes:Eo(Fn()).optional(),theme:Mo(["light","dark"]).optional()}),js=So({icons:Eo(Cs).optional()}),Rs=So({name:Fn(),title:Fn().optional()}),Os=Rs.extend({...Rs.shape,...js.shape,version:Fn(),websiteUrl:Fn().optional(),description:Fn().optional()}),zs=Ro(So({applyDefaults:mo().optional()}),zo(Fn(),wo())),As=es(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,Ro(So({form:zs.optional(),url:as.optional()}),zo(Fn(),wo()).optional())),Ms=To({list:as.optional(),cancel:as.optional(),requests:To({sampling:To({createMessage:as.optional()}).optional(),elicitation:To({create:as.optional()}).optional()}).optional()}),Us=To({list:as.optional(),cancel:as.optional(),requests:To({tools:To({call:as.optional()}).optional()}).optional()}),Ds=So({experimental:zo(Fn(),as).optional(),sampling:So({context:as.optional(),tools:as.optional()}).optional(),elicitation:As.optional(),roots:So({listChanged:mo().optional()}).optional(),tasks:Ms.optional()}),qs=ps.extend({protocolVersion:Fn(),capabilities:Ds,clientInfo:Os}),Vs=ms.extend({method:Do("initialize"),params:qs}),Fs=So({experimental:zo(Fn(),as).optional(),logging:as.optional(),completions:as.optional(),prompts:So({listChanged:mo().optional()}).optional(),resources:So({subscribe:mo().optional(),listChanged:mo().optional()}).optional(),tools:So({listChanged:mo().optional()}).optional(),tasks:Us.optional()}),Ls=vs.extend({protocolVersion:Fn(),capabilities:Fs,serverInfo:Os,instructions:Fn().optional()}),Hs=gs.extend({method:Do("notifications/initialized"),params:ys.optional()}),Ks=ms.extend({method:Do("ping"),params:ps.optional()}),Zs=So({progress:uo(),total:Lo(uo()),message:Lo(Fn())}),Gs=So({...ys.shape,...Zs.shape,progressToken:cs}),Bs=gs.extend({method:Do("notifications/progress"),params:Gs}),Js=ps.extend({cursor:ls.optional()}),Ws=ms.extend({params:Js.optional()}),Qs=vs.extend({nextCursor:ls.optional()}),Ys=Mo(["working","input_required","completed","failed","cancelled"]),Xs=So({taskId:Fn(),status:Ys,ttl:xo([uo(),go()]),createdAt:Fn(),lastUpdatedAt:Fn(),pollInterval:Lo(uo()),statusMessage:Lo(Fn())}),ea=vs.extend({task:Xs}),ta=ys.merge(Xs),ra=gs.extend({method:Do("notifications/tasks/status"),params:ta}),na=ms.extend({method:Do("tasks/get"),params:ps.extend({taskId:Fn()})}),oa=vs.merge(Xs),sa=ms.extend({method:Do("tasks/result"),params:ps.extend({taskId:Fn()})});vs.loose();const aa=Ws.extend({method:Do("tasks/list")}),ia=Qs.extend({tasks:Eo(Xs)}),ca=ms.extend({method:Do("tasks/cancel"),params:ps.extend({taskId:Fn()})}),la=vs.merge(Xs),ua=So({uri:Fn(),mimeType:Lo(Fn()),_meta:zo(Fn(),wo()).optional()}),da=ua.extend({text:Fn()}),ha=Fn().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),pa=ua.extend({blob:ha}),fa=Mo(["user","assistant"]),ma=So({audience:Eo(fa).optional(),priority:uo().min(0).max(1).optional(),lastModified:Tn({offset:!0}).optional()}),ya=So({...Rs.shape,...js.shape,uri:Fn(),description:Lo(Fn()),mimeType:Lo(Fn()),annotations:ma.optional(),_meta:Lo(To({}))}),ga=So({...Rs.shape,...js.shape,uriTemplate:Fn(),description:Lo(Fn()),mimeType:Lo(Fn()),annotations:ma.optional(),_meta:Lo(To({}))}),va=Ws.extend({method:Do("resources/list")}),_a=Qs.extend({resources:Eo(ya)}),wa=Ws.extend({method:Do("resources/templates/list")}),$a=Qs.extend({resourceTemplates:Eo(ga)}),ba=ps.extend({uri:Fn()}),ka=ba,Ea=ms.extend({method:Do("resources/read"),params:ka}),Pa=vs.extend({contents:Eo(xo([da,pa]))}),Sa=gs.extend({method:Do("notifications/resources/list_changed"),params:ys.optional()}),Ta=ba,Ia=ms.extend({method:Do("resources/subscribe"),params:Ta}),xa=ba,Na=ms.extend({method:Do("resources/unsubscribe"),params:xa}),Ca=ys.extend({uri:Fn()}),ja=gs.extend({method:Do("notifications/resources/updated"),params:Ca}),Ra=So({name:Fn(),description:Lo(Fn()),required:Lo(mo())}),Oa=So({...Rs.shape,...js.shape,description:Lo(Fn()),arguments:Lo(Eo(Ra)),_meta:Lo(To({}))}),za=Ws.extend({method:Do("prompts/list")}),Aa=Qs.extend({prompts:Eo(Oa)}),Ma=ps.extend({name:Fn(),arguments:zo(Fn(),Fn()).optional()}),Ua=ms.extend({method:Do("prompts/get"),params:Ma}),Da=So({type:Do("text"),text:Fn(),annotations:ma.optional(),_meta:zo(Fn(),wo()).optional()}),qa=So({type:Do("image"),data:ha,mimeType:Fn(),annotations:ma.optional(),_meta:zo(Fn(),wo()).optional()}),Va=So({type:Do("audio"),data:ha,mimeType:Fn(),annotations:ma.optional(),_meta:zo(Fn(),wo()).optional()}),Fa=So({type:Do("tool_use"),name:Fn(),id:Fn(),input:zo(Fn(),wo()),_meta:zo(Fn(),wo()).optional()}),La=So({type:Do("resource"),resource:xo([da,pa]),annotations:ma.optional(),_meta:zo(Fn(),wo()).optional()}),Ha=xo([Da,qa,Va,ya.extend({type:Do("resource_link")}),La]),Ka=So({role:fa,content:Ha}),Za=vs.extend({description:Fn().optional(),messages:Eo(Ka)}),Ga=gs.extend({method:Do("notifications/prompts/list_changed"),params:ys.optional()}),Ba=So({title:Fn().optional(),readOnlyHint:mo().optional(),destructiveHint:mo().optional(),idempotentHint:mo().optional(),openWorldHint:mo().optional()}),Ja=So({taskSupport:Mo(["required","optional","forbidden"]).optional()}),Wa=So({...Rs.shape,...js.shape,description:Fn().optional(),inputSchema:So({type:Do("object"),properties:zo(Fn(),as).optional(),required:Eo(Fn()).optional()}).catchall(wo()),outputSchema:So({type:Do("object"),properties:zo(Fn(),as).optional(),required:Eo(Fn()).optional()}).catchall(wo()).optional(),annotations:Ba.optional(),execution:Ja.optional(),_meta:zo(Fn(),wo()).optional()}),Qa=Ws.extend({method:Do("tools/list")}),Ya=Qs.extend({tools:Eo(Wa)}),Xa=vs.extend({content:Eo(Ha).default([]),structuredContent:zo(Fn(),wo()).optional(),isError:mo().optional()});Xa.or(vs.extend({toolResult:wo()}));const ei=fs.extend({name:Fn(),arguments:zo(Fn(),wo()).optional()}),ti=ms.extend({method:Do("tools/call"),params:ei}),ri=gs.extend({method:Do("notifications/tools/list_changed"),params:ys.optional()}),ni=So({autoRefresh:mo().default(!0),debounceMs:uo().int().nonnegative().default(300)}),oi=Mo(["debug","info","notice","warning","error","critical","alert","emergency"]),si=ps.extend({level:oi}),ai=ms.extend({method:Do("logging/setLevel"),params:si}),ii=ys.extend({level:oi,logger:Fn().optional(),data:wo()}),ci=gs.extend({method:Do("notifications/message"),params:ii}),li=So({name:Fn().optional()}),ui=So({hints:Eo(li).optional(),costPriority:uo().min(0).max(1).optional(),speedPriority:uo().min(0).max(1).optional(),intelligencePriority:uo().min(0).max(1).optional()}),di=So({mode:Mo(["auto","required","none"]).optional()}),hi=So({type:Do("tool_result"),toolUseId:Fn().describe("The unique identifier for the corresponding tool call."),content:Eo(Ha).default([]),structuredContent:So({}).loose().optional(),isError:mo().optional(),_meta:zo(Fn(),wo()).optional()}),pi=Co("type",[Da,qa,Va]),fi=Co("type",[Da,qa,Va,Fa,hi]),mi=So({role:fa,content:xo([fi,Eo(fi)]),_meta:zo(Fn(),wo()).optional()}),yi=fs.extend({messages:Eo(mi),modelPreferences:ui.optional(),systemPrompt:Fn().optional(),includeContext:Mo(["none","thisServer","allServers"]).optional(),temperature:uo().optional(),maxTokens:uo().int(),stopSequences:Eo(Fn()).optional(),metadata:as.optional(),tools:Eo(Wa).optional(),toolChoice:di.optional()}),gi=ms.extend({method:Do("sampling/createMessage"),params:yi}),vi=vs.extend({model:Fn(),stopReason:Lo(Mo(["endTurn","stopSequence","maxTokens"]).or(Fn())),role:fa,content:pi}),_i=vs.extend({model:Fn(),stopReason:Lo(Mo(["endTurn","stopSequence","maxTokens","toolUse"]).or(Fn())),role:fa,content:xo([fi,Eo(fi)])}),wi=So({type:Do("boolean"),title:Fn().optional(),description:Fn().optional(),default:mo().optional()}),$i=So({type:Do("string"),title:Fn().optional(),description:Fn().optional(),minLength:uo().optional(),maxLength:uo().optional(),format:Mo(["email","uri","date","date-time"]).optional(),default:Fn().optional()}),bi=So({type:Mo(["number","integer"]),title:Fn().optional(),description:Fn().optional(),minimum:uo().optional(),maximum:uo().optional(),default:uo().optional()}),ki=So({type:Do("string"),title:Fn().optional(),description:Fn().optional(),enum:Eo(Fn()),default:Fn().optional()}),Ei=So({type:Do("string"),title:Fn().optional(),description:Fn().optional(),oneOf:Eo(So({const:Fn(),title:Fn()})),default:Fn().optional()}),Pi=So({type:Do("string"),title:Fn().optional(),description:Fn().optional(),enum:Eo(Fn()),enumNames:Eo(Fn()).optional(),default:Fn().optional()}),Si=xo([ki,Ei]),Ti=xo([So({type:Do("array"),title:Fn().optional(),description:Fn().optional(),minItems:uo().optional(),maxItems:uo().optional(),items:So({type:Do("string"),enum:Eo(Fn())}),default:Eo(Fn()).optional()}),So({type:Do("array"),title:Fn().optional(),description:Fn().optional(),minItems:uo().optional(),maxItems:uo().optional(),items:So({anyOf:Eo(So({const:Fn(),title:Fn()}))}),default:Eo(Fn()).optional()})]),Ii=xo([Pi,Si,Ti]),xi=xo([Ii,wi,$i,bi]),Ni=xo([fs.extend({mode:Do("form").optional(),message:Fn(),requestedSchema:So({type:Do("object"),properties:zo(Fn(),xi),required:Eo(Fn()).optional()})}),fs.extend({mode:Do("url"),message:Fn(),elicitationId:Fn(),url:Fn().url()})]),Ci=ms.extend({method:Do("elicitation/create"),params:Ni}),ji=ys.extend({elicitationId:Fn()}),Ri=gs.extend({method:Do("notifications/elicitation/complete"),params:ji}),Oi=vs.extend({action:Mo(["accept","decline","cancel"]),content:es(e=>null===e?void 0:e,zo(Fn(),xo([Fn(),uo(),mo(),Eo(Fn())])).optional())}),zi=So({type:Do("ref/resource"),uri:Fn()}),Ai=So({type:Do("ref/prompt"),name:Fn()}),Mi=ps.extend({ref:xo([Ai,zi]),argument:So({name:Fn(),value:Fn()}),context:So({arguments:zo(Fn(),Fn()).optional()}).optional()}),Ui=ms.extend({method:Do("completion/complete"),params:Mi}),Di=vs.extend({completion:To({values:Eo(Fn()).max(100),total:Lo(uo().int()),hasMore:Lo(mo())})}),qi=So({uri:Fn().startsWith("file://"),name:Fn().optional(),_meta:zo(Fn(),wo()).optional()}),Vi=ms.extend({method:Do("roots/list"),params:ps.optional()}),Fi=vs.extend({roots:Eo(qi)}),Li=gs.extend({method:Do("notifications/roots/list_changed"),params:ys.optional()});xo([Ks,Vs,Ui,ai,Ua,za,va,wa,Ea,Ia,Na,ti,Qa,na,sa,aa,ca]),xo([Ns,Bs,Hs,Li,ra]),xo([Is,vi,_i,Oi,Fi,oa,ia,ea]),xo([Ks,gi,Ci,Vi,na,sa,aa,ca]),xo([Ns,Bs,ci,ja,Sa,ri,Ga,ra,Ri]),xo([Is,Ls,Di,Za,Aa,_a,$a,Pa,Xa,Ya,oa,ia,ea]);class Hi extends Error{constructor(e,t,r){super(`MCP error ${e}: ${t}`),this.code=e,this.data=r,this.name="McpError"}static fromError(e,t,r){if(e===Ps.UrlElicitationRequired&&r){const e=r;if(e.elicitations)return new Ki(e.elicitations,t)}return new Hi(e,t,r)}}class Ki extends Hi{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Ps.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}function Zi(e){return"completed"===e||"failed"===e||"cancelled"===e}function Gi(e){const t=Pn(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=function(e){if(kn(e)){const t=e,r=t._zod?.def;if(r){if(void 0!==r.value)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}}const t=e._def;if(t){if(void 0!==t.value)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const r=e.value;if(void 0!==r)return r}(r);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function Bi(e,t){const r=En(e,t);if(!r.success)throw r.error;return r.data}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");class Ji{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ns,e=>{this._oncancel(e)}),this.setNotificationHandler(Bs,e=>{this._onprogress(e)}),this.setRequestHandler(Ks,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(na,async(e,t)=>{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new Hi(Ps.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(sa,async(e,t)=>{const r=async()=>{const n=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(n,t.sessionId);){if("response"===e.type||"error"===e.type){const t=e.message,r=t.id,n=this._requestResolvers.get(r);if(n)if(this._requestResolvers.delete(r),"response"===e.type)n(t);else{const e=t;n(new Hi(e.error.code,e.error.message,e.error.data))}else{const t="response"===e.type?"Response":"Error";this._onerror(new Error(`${t} handler missing for request ${r}`))}continue}await(this._transport?.send(e.message,{relatedRequestId:t.requestId}))}}const o=await this._taskStore.getTask(n,t.sessionId);if(!o)throw new Hi(Ps.InvalidParams,`Task not found: ${n}`);if(!Zi(o.status))return await this._waitForTaskUpdate(n,t.signal),await r();if(Zi(o.status)){const e=await this._taskStore.getTaskResult(n,t.sessionId);return this._clearTaskQueue(n),{...e,_meta:{...e._meta,[os]:{taskId:n}}}}return await r()};return await r()}),this.setRequestHandler(aa,async(e,t)=>{try{const{tasks:r,nextCursor:n}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:r,nextCursor:n,_meta:{}}}catch(e){throw new Hi(Ps.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(ca,async(e,t)=>{try{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new Hi(Ps.InvalidParams,`Task not found: ${e.params.taskId}`);if(Zi(r.status))throw new Hi(Ps.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new Hi(Ps.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof Hi)throw e;throw new Hi(Ps.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;const t=this._requestHandlerAbortControllers.get(e.params.requestId);t?.abort(e.params.reason)}_setupTimeout(e,t,r,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:n})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),Hi.fromError(Ps.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=e=>{r?.(e),this._onerror(e)};const n=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{var r;n?.(e,t),Es(e)||(r=e,Ss.safeParse(r).success)?this._onresponse(e):$s(e)?this._onrequest(e,t):(e=>bs.safeParse(e).success)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();const t=Hi.fromError(Ps.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of e.values())r(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;void 0!==t&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){const r=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,n=this._transport,o=e.params?._meta?.[os]?.taskId;if(void 0===r){const t={jsonrpc:"2.0",id:e.id,error:{code:Ps.MethodNotFound,message:"Method not found"}};return void(o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:t,timestamp:Date.now()},n?.sessionId).catch(e=>this._onerror(new Error(`Failed to enqueue error response: ${e}`))):n?.send(t).catch(e=>this._onerror(new Error(`Failed to send an error response: ${e}`))))}const s=new AbortController;this._requestHandlerAbortControllers.set(e.id,s);const a=(i=e.params,fs.safeParse(i).success?e.params.task:void 0);var i;const c=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,l={signal:s.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(s.signal.aborted)return;const r={relatedRequestId:e.id};o&&(r.relatedTask={taskId:o}),await this.notification(t,r)},sendRequest:async(t,r,n)=>{if(s.signal.aborted)throw new Hi(Ps.ConnectionClosed,"Request was cancelled");const a={...n,relatedRequestId:e.id};o&&!a.relatedTask&&(a.relatedTask={taskId:o});const i=a.relatedTask?.taskId??o;return i&&c&&await c.updateTaskStatus(i,"input_required"),await this.request(t,r,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>r(e,l)).then(async t=>{if(s.signal.aborted)return;const r={result:t,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))},async t=>{if(s.signal.aborted)return;const r={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:Ps.InternalError,message:t.message??"Internal error",...void 0!==t.data&&{data:t.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))}).catch(e=>this._onerror(new Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...r}=e.params,n=Number(t),o=this._progressHandlers.get(n);if(!o)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const s=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(e){return this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),void s(e)}o(r)}_onresponse(e){const t=Number(e.id),r=this._requestResolvers.get(t);if(r){if(this._requestResolvers.delete(t),Es(e))r(e);else{r(new Hi(e.error.code,e.error.message,e.error.data))}return}const n=this._responseHandlers.get(t);if(void 0===n)return void this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));this._responseHandlers.delete(t),this._cleanupTimeout(t);let o=!1;if(Es(e)&&e.result&&"object"==typeof e.result){const r=e.result;if(r.task&&"object"==typeof r.task){const e=r.task;"string"==typeof e.taskId&&(o=!0,this._taskProgressTokens.set(e.taskId,t))}}if(o||this._progressHandlers.delete(t),Es(e))n(e);else{n(Hi.fromError(e.error.code,e.error.message,e.error.data))}}get transport(){return this._transport}async close(){await(this._transport?.close())}async*requestStream(e,t,r){const{task:n}=r??{};if(!n){try{const n=await this.request(e,t,r);yield{type:"result",result:n}}catch(e){yield{type:"error",error:e instanceof Hi?e:new Hi(Ps.InternalError,String(e))}}return}let o;try{const n=await this.request(e,ea,r);if(!n.task)throw new Hi(Ps.InternalError,"Task creation did not return a task");for(o=n.task.taskId,yield{type:"taskCreated",task:n.task};;){const e=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:e},Zi(e.status)){if("completed"===e.status){const e=await this.getTaskResult({taskId:o},t,r);yield{type:"result",result:e}}else"failed"===e.status?yield{type:"error",error:new Hi(Ps.InternalError,`Task ${o} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new Hi(Ps.InternalError,`Task ${o} was cancelled`)});return}if("input_required"===e.status){const e=await this.getTaskResult({taskId:o},t,r);return void(yield{type:"result",result:e})}const n=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,n)),r?.signal?.throwIfAborted()}}catch(e){yield{type:"error",error:e instanceof Hi?e:new Hi(Ps.InternalError,String(e))}}}request(e,t,r){const{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:i}=r??{};return new Promise((c,l)=>{const u=e=>{l(e)};if(!this._transport)return void u(new Error("Not connected"));if(!0===this._options?.enforceStrictCapabilities)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(e){return void u(e)}r?.signal?.throwIfAborted();const d=this._requestMessageId++,h={...e,jsonrpc:"2.0",id:d};r?.onprogress&&(this._progressHandlers.set(d,r.onprogress),h.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),a&&(h.params={...h.params,task:a}),i&&(h.params={...h.params,_meta:{...h.params?._meta||{},[os]:i}});const p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:d,reason:String(e)}},{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)));const t=e instanceof Hi?e:new Hi(Ps.RequestTimeout,String(e));l(t)};this._responseHandlers.set(d,e=>{if(!r?.signal?.aborted){if(e instanceof Error)return l(e);try{const r=En(t,e.result);r.success?c(r.data):l(r.error)}catch(e){l(e)}}}),r?.signal?.addEventListener("abort",()=>{p(r?.signal?.reason)});const f=r?.timeout??6e4;this._setupTimeout(d,f,r?.maxTotalTimeout,()=>p(Hi.fromError(Ps.RequestTimeout,"Request timed out",{timeout:f})),r?.resetTimeoutOnProgress??!1);const m=i?.taskId;if(m){const e=e=>{const t=this._responseHandlers.get(d);t?t(e):this._onerror(new Error(`Response handler missing for side-channeled request ${d}`))};this._requestResolvers.set(d,e),this._enqueueTaskMessage(m,{type:"request",message:h,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})}else this._transport.send(h,{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},oa,t)}async getTaskResult(e,t,r){return this.request({method:"tasks/result",params:e},t,r)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},ia,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},la,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const r=t?.relatedTask?.taskId;if(r){const n={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[os]:t.relatedTask}}};return void await this._enqueueTaskMessage(r,{type:"notification",message:n,timestamp:Date.now()})}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let r={...e,jsonrpc:"2.0"};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[os]:t.relatedTask}}}),this._transport?.send(r,t).catch(e=>this._onerror(e))})}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[os]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const r=Gi(e);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(r,n)=>{const o=Bi(e,r);return Promise.resolve(t(o,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const r=Gi(e);this._notificationHandlers.set(r,r=>{const n=Bi(e,r);return Promise.resolve(t(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);void 0!==t&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,r,n)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(e,t);for(const t of r)if("request"===t.type&&$s(t.message)){const r=t.message.id,n=this._requestResolvers.get(r);n?(n(new Hi(Ps.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(r)):this._onerror(new Error(`Resolver missing for request ${r} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let r=this._options?.defaultTaskPollInterval??1e3;try{const t=await(this._taskStore?.getTask(e));t?.pollInterval&&(r=t.pollInterval)}catch{}return new Promise((e,n)=>{if(t.aborted)return void n(new Hi(Ps.InvalidRequest,"Request cancelled"));const o=setTimeout(e,r);t.addEventListener("abort",()=>{clearTimeout(o),n(new Hi(Ps.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await r.createTask(n,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{const n=await r.getTask(e,t);if(!n)throw new Hi(Ps.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(e,n,o)=>{await r.storeTaskResult(e,n,o,t);const s=await r.getTask(e,t);if(s){const t=ra.parse({method:"notifications/tasks/status",params:s});await this.notification(t),Zi(s.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>r.getTaskResult(e,t),updateTaskStatus:async(e,n,o)=>{const s=await r.getTask(e,t);if(!s)throw new Hi(Ps.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Zi(s.status))throw new Hi(Ps.InvalidParams,`Cannot update task "${e}" from terminal status "${s.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(e,n,o,t);const a=await r.getTask(e,t);if(a){const t=ra.parse({method:"notifications/tasks/status",params:a});await this.notification(t),Zi(a.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>r.listTasks(e,t)}}}function Wi(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Qi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Yi,Xi={exports:{}},ec={},tc={},rc={},nc={},oc={},sc={};function ac(){return Yi||(Yi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function o(e,...t){const r=[e[0]];let o=0;for(;o<t.length;)i(r,t[o]),r.push(e[++o]);return new n(r)}e._Code=n,e.nil=new n(""),e._=o;const s=new n("+");function a(e,...t){const r=[l(e[0])];let o=0;for(;o<t.length;)r.push(s),i(r,t[o]),r.push(s,l(e[++o]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===s){const r=c(e[t-1],e[t+1]);if(void 0!==r){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}(r),new n(r)}function i(e,t){var o;t instanceof n?e.push(...t._items):t instanceof r?e.push(t):e.push("number"==typeof(o=t)||"boolean"==typeof o||null===o?o:l(Array.isArray(o)?o.join(","):o))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof r||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof r?void 0:`"${e}${t.slice(1)}`}function l(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=a,e.addCodeArg=i,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:a`${e}${t}`},e.stringify=function(e){return new n(l(e))},e.safeStringify=l,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):o`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(e){return new n(e.toString())}}(sc)),sc}var ic,cc,lc={};function uc(){return ic||(ic=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=ac();class r extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var n;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class o{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,r;if((null===(r=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===r?void 0:r.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}e.Scope=o;class s extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=t._`.${new t.Name(r)}[${n}]`}}e.ValueScopeName=s;const a=t._`\n`;e.ValueScope=class extends o{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?a:t.nil}}get(){return this._scope}name(e){return new s(e,this._newName(e))}value(e,t){var r;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const n=this.toName(e),{prefix:o}=n,s=null!==(r=t.key)&&void 0!==r?r:t.ref;let a=this._values[o];if(a){const e=a.get(s);if(e)return e}else a=this._values[o]=new Map;a.set(s,n);const i=this._scope[o]||(this._scope[o]=[]),c=i.length;return i[c]=t.ref,n.setValue(t,{property:o,itemIndex:c}),n}getValue(e,t){const r=this._values[e];if(r)return r.get(t)}scopeRefs(e,r=this._values){return this._reduceValues(r,r=>{if(void 0===r.scopePath)throw new Error(`CodeGen: name "${r}" has no value`);return t._`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,r)}_reduceValues(o,s,a={},i){let c=t.nil;for(const l in o){const u=o[l];if(!u)continue;const d=a[l]=a[l]||new Map;u.forEach(o=>{if(d.has(o))return;d.set(o,n.Started);let a=s(o);if(a){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${o} = ${a};${this.opts._n}`}else{if(!(a=null==i?void 0:i(o)))throw new r(o);c=t._`${c}${a}${this.opts._n}`}d.set(o,n.Completed)})}return c}}}(lc)),lc}function dc(){return cc||(cc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=ac(),r=uc();var n=ac();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var o=uc();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class s{optimizeNodes(){return this}optimizeNames(e,t){return this}}class a extends s{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r}render({es5:e,_n:t}){const n=e?r.varKinds.var:this.varKind,o=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=x(this.rhs,e,t)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends s{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof t.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=x(this.rhs,e,r),this}get names(){return I(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}}class c extends i{constructor(e,t,r,n){super(e,r,n),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class l extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class u extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class d extends s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class h extends s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=x(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class p extends s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:r}=this;let n=r.length;for(;n--;){const o=r[n];o.optimizeNames(e,t)||(N(e,o.names),r.splice(n,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>T(e,t.names),{})}}class f extends p{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends p{}class y extends f{}y.kind="else";class g extends f{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new y(e):e}return t?!1===e?t instanceof g?t:t.nodes:this.nodes.length?this:new g(C(e),t instanceof g?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=x(this.condition,e,t),this}get names(){const e=super.names;return I(e,this.condition),this.else&&T(e,this.else.names),e}}g.kind="if";class v extends f{}v.kind="for";class _ extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=x(this.iteration,e,t),this}get names(){return T(super.names,this.iteration.names)}}class w extends v{constructor(e,t,r,n){super(),this.varKind=e,this.name=t,this.from=r,this.to=n}render(e){const t=e.es5?r.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${t} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){const e=I(super.names,this.from);return I(e,this.to)}}class $ extends v{constructor(e,t,r,n){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=x(this.iterable,e,t),this}get names(){return T(super.names,this.iterable.names)}}class b extends f{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}b.kind="func";class k extends p{render(e){return"return "+super.render(e)}}k.kind="return";class E extends f{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var r,n;return super.optimizeNames(e,t),null===(r=this.catch)||void 0===r||r.optimizeNames(e,t),null===(n=this.finally)||void 0===n||n.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&T(e,this.catch.names),this.finally&&T(e,this.finally.names),e}}class P extends f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}P.kind="catch";class S extends f{render(e){return"finally"+super.render(e)}}S.kind="finally";function T(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function I(e,r){return r instanceof t._CodeOrName?T(e,r.names):e}function x(e,r,n){return e instanceof t.Name?s(e):(o=e)instanceof t._Code&&o._items.some(e=>e instanceof t.Name&&1===r[e.str]&&void 0!==n[e.str])?new t._Code(e._items.reduce((e,r)=>(r instanceof t.Name&&(r=s(r)),r instanceof t._Code?e.push(...r._items):e.push(r),e),[])):e;var o;function s(e){const t=n[e.str];return void 0===t||1!==r[e.str]?e:(delete r[e.str],t)}}function N(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function C(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:t._`!${z(e)}`}e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new r.Scope({parent:e}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const r=this._extScope.value(e,t);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,n){const o=this._scope.toName(t);return void 0!==r&&n&&(this._constants[o.str]=r),this._leafNode(new a(e,o,r)),o}const(e,t,n){return this._def(r.varKinds.const,e,t,n)}let(e,t,n){return this._def(r.varKinds.let,e,t,n)}var(e,t,n){return this._def(r.varKinds.var,e,t,n)}assign(e,t,r){return this._leafNode(new i(e,t,r))}add(t,r){return this._leafNode(new c(t,e.operators.ADD,r))}code(e){return"function"==typeof e?e():e!==t.nil&&this._leafNode(new h(e)),this}object(...e){const r=["{"];for(const[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,t.addCodeArg)(r,o));return r.push("}"),new t._Code(r)}if(e,t,r){if(this._blockNode(new g(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new g(e))}else(){return this._elseNode(new y)}endIf(){return this._endBlockNode(g,y)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new _(e),t)}forRange(e,t,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.let)){const a=this._scope.toName(e);return this._for(new w(s,a,t,n),()=>o(a))}forOf(e,n,o,s=r.varKinds.const){const a=this._scope.toName(e);if(this.opts.es5){const e=n instanceof t.Name?n:this.var("_arr",n);return this.forRange("_i",0,t._`${e}.length`,r=>{this.var(a,t._`${e}[${r}]`),o(a)})}return this._for(new $("of",s,a,n),()=>o(a))}forIn(e,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,t._`Object.keys(${n})`,o);const a=this._scope.toName(e);return this._for(new $("in",s,a,n),()=>o(a))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){const t=new k;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(k)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new E;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new P(e),t(e)}return r&&(this._currNode=n.finally=new S,this.code(r)),this._endBlockNode(P,S)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-t;if(r<0||void 0!==e&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,r=t.nil,n,o){return this._blockNode(new b(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(b)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},e.not=C;const j=O(e.operators.AND);e.and=function(...e){return e.reduce(j)};const R=O(e.operators.OR);function O(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${z(r)} ${e} ${z(n)}`}function z(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(R)}}(oc)),oc}var hc={};Object.defineProperty(hc,"__esModule",{value:!0}),hc.checkStrictMode=hc.getErrorPath=hc.Type=hc.useFunc=hc.setEvaluated=hc.evaluatedPropsToName=hc.mergeEvaluated=hc.eachItem=hc.unescapeJsonPointer=hc.escapeJsonPointer=hc.escapeFragment=hc.unescapeFragment=hc.schemaRefOrVal=hc.schemaHasRulesButRef=hc.schemaHasRules=hc.checkUnknownRules=hc.alwaysValidSchema=hc.toHash=void 0;const pc=dc(),fc=ac();function mc(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema)return;if("boolean"==typeof t)return;const o=n.RULES.keywords;for(const r in t)o[r]||Ec(e,`unknown keyword: "${r}"`)}function yc(e,t){if("boolean"==typeof e)return!e;for(const r in e)if(t[r])return!0;return!1}function gc(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function vc(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function _c({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,a,i)=>{const c=void 0===a?s:a instanceof pc.Name?(s instanceof pc.Name?e(o,s,a):t(o,s,a),a):s instanceof pc.Name?(t(o,a,s),s):r(s,a);return i!==pc.Name||c instanceof pc.Name?c:n(o,c)}}function wc(e,t){if(!0===t)return e.var("props",!0);const r=e.var("props",pc._`{}`);return void 0!==t&&$c(e,r,t),r}function $c(e,t,r){Object.keys(r).forEach(r=>e.assign(pc._`${t}${(0,pc.getProperty)(r)}`,!0))}hc.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},hc.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(mc(e,t),!yc(t,e.self.RULES.all))},hc.checkUnknownRules=mc,hc.schemaHasRules=yc,hc.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const r in e)if("$ref"!==r&&t.all[r])return!0;return!1},hc.schemaRefOrVal=function({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if("number"==typeof r||"boolean"==typeof r)return r;if("string"==typeof r)return pc._`${r}`}return pc._`${e}${t}${(0,pc.getProperty)(n)}`},hc.unescapeFragment=function(e){return vc(decodeURIComponent(e))},hc.escapeFragment=function(e){return encodeURIComponent(gc(e))},hc.escapeJsonPointer=gc,hc.unescapeJsonPointer=vc,hc.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},hc.mergeEvaluated={props:_c({mergeNames:(e,t,r)=>e.if(pc._`${r} !== true && ${t} !== undefined`,()=>{e.if(pc._`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,pc._`${r} || {}`).code(pc._`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if(pc._`${r} !== true`,()=>{!0===t?e.assign(r,!0):(e.assign(r,pc._`${r} || {}`),$c(e,r,t))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:wc}),items:_c({mergeNames:(e,t,r)=>e.if(pc._`${r} !== true && ${t} !== undefined`,()=>e.assign(r,pc._`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if(pc._`${r} !== true`,()=>e.assign(r,!0===t||pc._`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},hc.evaluatedPropsToName=wc,hc.setEvaluated=$c;const bc={};var kc;function Ec(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,!0===r)throw new Error(t);e.self.logger.warn(t)}}hc.useFunc=function(e,t){return e.scopeValue("func",{ref:t,code:bc[t.code]||(bc[t.code]=new fc._Code(t.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(kc||(hc.Type=kc={})),hc.getErrorPath=function(e,t,r){if(e instanceof pc.Name){const n=t===kc.Num;return r?n?pc._`"[" + ${e} + "]"`:pc._`"['" + ${e} + "']"`:n?pc._`"/" + ${e}`:pc._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,pc.getProperty)(e).toString():"/"+gc(e)},hc.checkStrictMode=Ec;var Pc,Sc,Tc,Ic={};function xc(){if(Pc)return Ic;Pc=1,Object.defineProperty(Ic,"__esModule",{value:!0});const e=dc(),t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return Ic.default=t,Ic}function Nc(){return Sc||(Sc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=dc(),r=hc,n=xc();function o(e,r){const o=e.const("err",r);e.if(t._`${n.default.vErrors} === null`,()=>e.assign(n.default.vErrors,t._`[${o}]`),t._`${n.default.vErrors}.push(${o})`),e.code(t._`${n.default.errors}++`)}function s(e,r){const{gen:n,validateName:o,schemaEnv:s}=e;s.$async?n.throw(t._`new ${e.ValidationError}(${r})`):(n.assign(t._`${o}.errors`,r),n.return(!1))}e.keywordError={message:({keyword:e})=>t.str`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:r})=>r?t.str`"${e}" keyword must be ${r} ($data)`:t.str`"${e}" keyword is invalid ($data)`},e.reportError=function(r,n=e.keywordError,a,c){const{it:l}=r,{gen:u,compositeRule:d,allErrors:h}=l,p=i(r,n,a);(null!=c?c:d||h)?o(u,p):s(l,t._`[${p}]`)},e.reportExtraError=function(t,r=e.keywordError,a){const{it:c}=t,{gen:l,compositeRule:u,allErrors:d}=c;o(l,i(t,r,a)),u||d||s(c,n.default.vErrors)},e.resetErrorsCount=function(e,r){e.assign(n.default.errors,r),e.if(t._`${n.default.vErrors} !== null`,()=>e.if(r,()=>e.assign(t._`${n.default.vErrors}.length`,r),()=>e.assign(n.default.vErrors,null)))},e.extendErrors=function({gen:e,keyword:r,schemaValue:o,data:s,errsCount:a,it:i}){if(void 0===a)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",a,n.default.errors,a=>{e.const(c,t._`${n.default.vErrors}[${a}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,i.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${i.errSchemaPath}/${r}`),i.opts.verbose&&(e.assign(t._`${c}.schema`,o),e.assign(t._`${c}.data`,s))})};const a={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function i(e,r,o){const{createErrors:s}=e.it;return!1===s?t._`{}`:function(e,r,o={}){const{gen:s,it:i}=e,u=[c(i,o),l(e,o)];return function(e,{params:r,message:o},s){const{keyword:i,data:c,schemaValue:l,it:u}=e,{opts:d,propertyName:h,topSchemaRef:p,schemaPath:f}=u;s.push([a.keyword,i],[a.params,"function"==typeof r?r(e):r||t._`{}`]),d.messages&&s.push([a.message,"function"==typeof o?o(e):o]);d.verbose&&s.push([a.schema,l],[a.parentSchema,t._`${p}${f}`],[n.default.data,c]);h&&s.push([a.propertyName,h])}(e,r,u),s.object(...u)}(e,r,o)}function c({errorPath:e},{instancePath:o}){const s=o?t.str`${e}${(0,r.getErrorPath)(o,r.Type.Str)}`:e;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,s)]}function l({keyword:e,it:{errSchemaPath:n}},{schemaPath:o,parentSchema:s}){let i=s?n:t.str`${n}/${e}`;return o&&(i=t.str`${i}${(0,r.getErrorPath)(o,r.Type.Str)}`),[a.schemaPath,i]}}(nc)),nc}var Cc={},jc={};Object.defineProperty(jc,"__esModule",{value:!0}),jc.getRules=jc.isJSONType=void 0;const Rc=new Set(["string","number","integer","boolean","null","object","array"]);jc.isJSONType=function(e){return"string"==typeof e&&Rc.has(e)},jc.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}};var Oc,zc={};function Ac(){if(Oc)return zc;function e(e,r){return r.rules.some(r=>t(e,r))}function t(e,t){var r;return void 0!==e[t.keyword]||(null===(r=t.definition.implements)||void 0===r?void 0:r.some(t=>void 0!==e[t]))}return Oc=1,Object.defineProperty(zc,"__esModule",{value:!0}),zc.shouldUseRule=zc.shouldUseGroup=zc.schemaHasRulesForType=void 0,zc.schemaHasRulesForType=function({schema:t,self:r},n){const o=r.RULES.types[n];return o&&!0!==o&&e(t,o)},zc.shouldUseGroup=e,zc.shouldUseRule=t,zc}Object.defineProperty(Cc,"__esModule",{value:!0}),Cc.reportTypeError=Cc.checkDataTypes=Cc.checkDataType=Cc.coerceAndCheckDataType=Cc.getJSONTypes=Cc.getSchemaTypes=Cc.DataType=void 0;const Mc=jc,Uc=Ac(),Dc=Nc(),qc=dc(),Vc=hc;var Fc;function Lc(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(Mc.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(Fc||(Cc.DataType=Fc={})),Cc.getSchemaTypes=function(e){const t=Lc(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},Cc.getJSONTypes=Lc,Cc.coerceAndCheckDataType=function(e,t){const{gen:r,data:n,opts:o}=e,s=function(e,t){return t?e.filter(e=>Hc.has(e)||"array"===t&&"array"===e):[]}(t,o.coerceTypes),a=t.length>0&&!(0===s.length&&1===t.length&&(0,Uc.schemaHasRulesForType)(e,t[0]));if(a){const a=Zc(t,n,o.strictNumbers,Fc.Wrong);r.if(a,()=>{s.length?function(e,t,r){const{gen:n,data:o,opts:s}=e,a=n.let("dataType",qc._`typeof ${o}`),i=n.let("coerced",qc._`undefined`);"array"===s.coerceTypes&&n.if(qc._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,qc._`${o}[0]`).assign(a,qc._`typeof ${o}`).if(Zc(t,o,s.strictNumbers),()=>n.assign(i,o)));n.if(qc._`${i} !== undefined`);for(const e of r)(Hc.has(e)||"array"===e&&"array"===s.coerceTypes)&&c(e);function c(e){switch(e){case"string":return void n.elseIf(qc._`${a} == "number" || ${a} == "boolean"`).assign(i,qc._`"" + ${o}`).elseIf(qc._`${o} === null`).assign(i,qc._`""`);case"number":return void n.elseIf(qc._`${a} == "boolean" || ${o} === null
2
2
  || (${a} == "string" && ${o} && ${o} == +${o})`).assign(i,qc._`+${o}`);case"integer":return void n.elseIf(qc._`${a} === "boolean" || ${o} === null
3
3
  || (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(i,qc._`+${o}`);case"boolean":return void n.elseIf(qc._`${o} === "false" || ${o} === 0 || ${o} === null`).assign(i,!1).elseIf(qc._`${o} === "true" || ${o} === 1`).assign(i,!0);case"null":return n.elseIf(qc._`${o} === "" || ${o} === 0 || ${o} === false`),void n.assign(i,null);case"array":n.elseIf(qc._`${a} === "string" || ${a} === "number"
4
- || ${a} === "boolean" || ${o} === null`).assign(i,qc._`[${o}]`)}}n.else(),Bc(e),n.endIf(),n.if(qc._`${i} !== undefined`,()=>{n.assign(o,i),function({gen:e,parentData:t,parentDataProperty:r},n){e.if(qc._`${t} !== undefined`,()=>e.assign(qc._`${t}[${r}]`,n))}(e,i)})}(e,t,s):Bc(e)})}return a};const Kc=new Set(["string","number","integer","boolean","null"]);function Hc(e,t,r,n=Fc.Correct){const o=n===Fc.Correct?qc.operators.EQ:qc.operators.NEQ;let s;switch(e){case"null":return qc._`${t} ${o} null`;case"array":s=qc._`Array.isArray(${t})`;break;case"object":s=qc._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=a(qc._`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=a();break;default:return qc._`typeof ${t} ${o} ${e}`}return n===Fc.Correct?s:(0,qc.not)(s);function a(e=qc.nil){return(0,qc.and)(qc._`typeof ${t} == "number"`,e,r?qc._`isFinite(${t})`:qc.nil)}}function Zc(e,t,r,n){if(1===e.length)return Hc(e[0],t,r,n);let o;const s=(0,Vc.toHash)(e);if(s.array&&s.object){const e=qc._`typeof ${t} != "object"`;o=s.null?e:qc._`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=qc.nil;s.number&&delete s.integer;for(const e in s)o=(0,qc.and)(o,Hc(e,t,r,n));return o}Cc.checkDataType=Hc,Cc.checkDataTypes=Zc;const Gc={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?qc._`{type: ${e}}`:qc._`{type: ${t}}`};function Bc(e){const t=function(e){const{gen:t,data:r,schema:n}=e,o=(0,Vc.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}(e);(0,Uc.reportError)(t,Gc)}Cc.reportTypeError=Bc;var Jc,Wc={};var Qc,Yc,Xc={},eu={};function tu(){if(Qc)return eu;Qc=1,Object.defineProperty(eu,"__esModule",{value:!0}),eu.validateUnion=eu.validateArray=eu.usePattern=eu.callValidateCode=eu.schemaProperties=eu.allSchemaProperties=eu.noPropertyInData=eu.propertyInData=eu.isOwnProperty=eu.hasPropFunc=eu.reportMissingProp=eu.checkMissingProp=eu.checkReportMissingProp=void 0;const e=dc(),t=hc,r=xc(),n=hc;function o(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:e._`Object.prototype.hasOwnProperty`})}function s(t,r,n){return e._`${o(t)}.call(${r}, ${n})`}function a(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} === undefined`;return o?(0,e.or)(a,(0,e.not)(s(t,r,n))):a}function i(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}eu.checkReportMissingProp=function(t,r){const{gen:n,data:o,it:s}=t;n.if(a(n,o,r,s.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},eu.checkMissingProp=function({gen:t,data:r,it:{opts:n}},o,s){return(0,e.or)(...o.map(o=>(0,e.and)(a(t,r,o,n.ownProperties),e._`${s} = ${o}`)))},eu.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},eu.hasPropFunc=o,eu.isOwnProperty=s,eu.propertyInData=function(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return o?e._`${a} && ${s(t,r,n)}`:a},eu.noPropertyInData=a,eu.allSchemaProperties=i,eu.schemaProperties=function(e,r){return i(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},eu.callValidateCode=function({schemaCode:t,data:n,it:{gen:o,topSchemaRef:s,schemaPath:a,errorPath:i},it:c},u,l,d){const h=d?e._`${t}, ${n}, ${s}${a}`:n,p=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,i)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const f=e._`${h}, ${o.object(...p)}`;return l!==e.nil?e._`${u}.call(${l}, ${f})`:e._`${u}(${f})`};const c=e._`new RegExp`;return eu.usePattern=function({gen:t,it:{opts:r}},o){const s=r.unicodeRegExp?"u":"",{regExp:a}=r.code,i=a(o,s);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:e._`${"new RegExp"===a.code?c:(0,n.useFunc)(t,a)}(${o}, ${s})`})},eu.validateArray=function(r){const{gen:n,data:o,keyword:s,it:a}=r,i=n.name("valid");if(a.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(i,!0),c(()=>n.break()),i;function c(a){const c=n.const("len",e._`${o}.length`);n.forRange("i",0,c,o=>{r.subschema({keyword:s,dataProp:o,dataPropType:t.Type.Num},i),n.if((0,e.not)(i),a)})}},eu.validateUnion=function(r){const{gen:n,schema:o,keyword:s,it:a}=r;if(!Array.isArray(o))throw new Error("ajv implementation error");if(o.some(e=>(0,t.alwaysValidSchema)(a,e))&&!a.opts.unevaluated)return;const i=n.let("valid",!1),c=n.name("_valid");n.block(()=>o.forEach((t,o)=>{const a=r.subschema({keyword:s,schemaProp:o,compositeRule:!0},c);n.assign(i,e._`${i} || ${c}`);r.mergeValidEvaluated(a,c)||n.if((0,e.not)(i))})),r.result(i,()=>r.reset(),()=>r.error(!0))},eu}function ru(){if(Yc)return Xc;Yc=1,Object.defineProperty(Xc,"__esModule",{value:!0}),Xc.validateKeywordUsage=Xc.validSchemaType=Xc.funcKeywordCode=Xc.macroKeywordCode=void 0;const e=dc(),t=xc(),r=tu(),n=Nc();function o(t){const{gen:r,data:n,it:o}=t;r.if(o.parentData,()=>r.assign(n,e._`${o.parentData}[${o.parentDataProperty}]`))}function s(t,r,n){if(void 0===n)throw new Error(`keyword "${r}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,e.stringify)(n)})}return Xc.macroKeywordCode=function(t,r){const{gen:n,keyword:o,schema:a,parentSchema:i,it:c}=t,u=r.macro.call(c.self,a,i,c),l=s(n,o,u);!1!==c.opts.validateSchema&&c.self.validateSchema(u,!0);const d=n.name("valid");t.subschema({schema:u,schemaPath:e.nil,errSchemaPath:`${c.errSchemaPath}/${o}`,topSchemaRef:l,compositeRule:!0},d),t.pass(d,()=>t.error(!0))},Xc.funcKeywordCode=function(a,i){var c;const{gen:u,keyword:l,schema:d,parentSchema:h,$data:p,it:f}=a;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(f,i);const m=!p&&i.compile?i.compile.call(f.self,d,h,f):i.validate,y=s(u,l,m),g=u.let("valid");function v(n=(i.async?e._`await `:e.nil)){const o=f.opts.passContext?t.default.this:t.default.self,s=!("compile"in i&&!p||!1===i.schema);u.assign(g,e._`${n}${(0,r.callValidateCode)(a,y,o,s)}`,i.modifying)}function _(t){var r;u.if((0,e.not)(null!==(r=i.valid)&&void 0!==r?r:g),t)}a.block$data(g,function(){if(!1===i.errors)v(),i.modifying&&o(a),_(()=>a.error());else{const r=i.async?function(){const t=u.let("ruleErrs",null);return u.try(()=>v(e._`await `),r=>u.assign(g,!1).if(e._`${r} instanceof ${f.ValidationError}`,()=>u.assign(t,e._`${r}.errors`),()=>u.throw(r))),t}():function(){const t=e._`${y}.errors`;return u.assign(t,null),v(e.nil),t}();i.modifying&&o(a),_(()=>function(r,o){const{gen:s}=r;s.if(e._`Array.isArray(${o})`,()=>{s.assign(t.default.vErrors,e._`${t.default.vErrors} === null ? ${o} : ${t.default.vErrors}.concat(${o})`).assign(t.default.errors,e._`${t.default.vErrors}.length`),(0,n.extendErrors)(r)},()=>r.error())}(a,r))}}),a.ok(null!==(c=i.valid)&&void 0!==c?c:g)},Xc.validSchemaType=function(e,t,r=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||r&&void 0===e)},Xc.validateKeywordUsage=function({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");const a=o.dependencies;if(null==a?void 0:a.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${s}: ${a.join(",")}`);if(o.validateSchema){if(!o.validateSchema(e[s])){const e=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);r.logger.error(e)}}},Xc}var nu,ou={};var su={},au=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!==o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(s=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;0!==o--;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r},iu={exports:{}},cu=iu.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),uu(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function uu(e,t,r,n,o,s,a,i,c,u){if(n&&"object"==typeof n&&!Array.isArray(n)){for(var l in t(n,o,s,a,i,c,u),n){var d=n[l];if(Array.isArray(d)){if(l in cu.arrayKeywords)for(var h=0;h<d.length;h++)uu(e,t,r,d[h],o+"/"+l+"/"+h,s,o,l,n,h)}else if(l in cu.propsKeywords){if(d&&"object"==typeof d)for(var p in d)uu(e,t,r,d[p],o+"/"+l+"/"+lu(p),s,o,l,n,p)}else(l in cu.keywords||e.allKeys&&!(l in cu.skipKeywords))&&uu(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,a,i,c,u)}}function lu(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}cu.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},cu.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},cu.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},cu.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};var du=iu.exports;Object.defineProperty(su,"__esModule",{value:!0}),su.getSchemaRefs=su.resolveUrl=su.normalizeId=su._getFullPath=su.getFullPath=su.inlineRef=void 0;const hu=hc,pu=au,fu=du,mu=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);su.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!gu(e):!!t&&vu(e)<=t)};const yu=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function gu(e){for(const t in e){if(yu.has(t))return!0;const r=e[t];if(Array.isArray(r)&&r.some(gu))return!0;if("object"==typeof r&&gu(r))return!0}return!1}function vu(e){let t=0;for(const r in e){if("$ref"===r)return 1/0;if(t++,!mu.has(r)&&("object"==typeof e[r]&&(0,hu.eachItem)(e[r],e=>t+=vu(e)),t===1/0))return 1/0}return t}function _u(e,t="",r){!1!==r&&(t=bu(t));const n=e.parse(t);return wu(e,n)}function wu(e,t){return e.serialize(t).split("#")[0]+"#"}su.getFullPath=_u,su._getFullPath=wu;const $u=/#\/?$/;function bu(e){return e?e.replace($u,""):""}su.normalizeId=bu,su.resolveUrl=function(e,t,r){return r=bu(r),e.resolve(t,r)};const ku=/^[a-z_][-a-z0-9._]*$/i;var Eu;function Pu(){if(Eu)return tc;Eu=1,Object.defineProperty(tc,"__esModule",{value:!0}),tc.getData=tc.KeywordCxt=tc.validateFunctionCode=void 0;const e=function(){if(Tc)return rc;Tc=1,Object.defineProperty(rc,"__esModule",{value:!0}),rc.boolOrEmptySchema=rc.topBoolOrEmptySchema=void 0;const e=Nc(),t=dc(),r=xc(),n={message:"boolean schema is false"};function o(t,r){const{gen:o,data:s}=t,a={gen:o,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(a,n,void 0,r)}return rc.topBoolOrEmptySchema=function(e){const{gen:n,schema:s,validateName:a}=e;!1===s?o(e,!1):"object"==typeof s&&!0===s.$async?n.return(r.default.data):(n.assign(t._`${a}.errors`,null),n.return(!0))},rc.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),o(e)):r.var(t,!0)},rc}(),t=Cc,r=Ac(),n=Cc,o=function(){if(Jc)return Wc;Jc=1,Object.defineProperty(Wc,"__esModule",{value:!0}),Wc.assignDefaults=void 0;const e=dc(),t=hc;function r(r,n,o){const{gen:s,compositeRule:a,data:i,opts:c}=r;if(void 0===o)return;const u=e._`${i}${(0,e.getProperty)(n)}`;if(a)return void(0,t.checkStrictMode)(r,`default is ignored for: ${u}`);let l=e._`${u} === undefined`;"empty"===c.useDefaults&&(l=e._`${l} || ${u} === null || ${u} === ""`),s.if(l,e._`${u} = ${(0,e.stringify)(o)}`)}return Wc.assignDefaults=function(e,t){const{properties:n,items:o}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(o)&&o.forEach((t,n)=>r(e,n,t.default))},Wc}(),s=ru(),a=function(){if(nu)return ou;nu=1,Object.defineProperty(ou,"__esModule",{value:!0}),ou.extendSubschemaMode=ou.extendSubschemaData=ou.getSubschema=void 0;const e=dc(),t=hc;return ou.getSubschema=function(r,{keyword:n,schemaProp:o,schema:s,schemaPath:a,errSchemaPath:i,topSchemaRef:c}){if(void 0!==n&&void 0!==s)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==n){const s=r.schema[n];return void 0===o?{schema:s,schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}`,errSchemaPath:`${r.errSchemaPath}/${n}`}:{schema:s[o],schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}${(0,e.getProperty)(o)}`,errSchemaPath:`${r.errSchemaPath}/${n}/${(0,t.escapeFragment)(o)}`}}if(void 0!==s){if(void 0===a||void 0===i||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:a,topSchemaRef:c,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')},ou.extendSubschemaData=function(r,n,{dataProp:o,dataPropType:s,data:a,dataTypes:i,propertyName:c}){if(void 0!==a&&void 0!==o)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:u}=n;if(void 0!==o){const{errorPath:a,dataPathArr:i,opts:c}=n;l(u.let("data",e._`${n.data}${(0,e.getProperty)(o)}`,!0)),r.errorPath=e.str`${a}${(0,t.getErrorPath)(o,s,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${o}`,r.dataPathArr=[...i,r.parentDataProperty]}function l(e){r.data=e,r.dataLevel=n.dataLevel+1,r.dataTypes=[],n.definedProperties=new Set,r.parentData=n.data,r.dataNames=[...n.dataNames,e]}void 0!==a&&(l(a instanceof e.Name?a:u.let("data",a,!0)),void 0!==c&&(r.propertyName=c)),i&&(r.dataTypes=i)},ou.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){void 0!==n&&(e.compositeRule=n),void 0!==o&&(e.createErrors=o),void 0!==s&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r},ou}(),i=dc(),c=xc(),u=su,l=hc,d=Nc();function h({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,i._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(i._`"use strict"; ${p(r,o)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,i._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,i._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,i._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,i._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,i._`""`),e.var(c.default.parentData,i._`undefined`),e.var(c.default.parentDataProperty,i._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`{}`)})}(e,o),e.code(s)}):e.func(t,i._`${c.default.data}, ${function(e){return i._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?i._`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}(o)}`,n.$async,()=>e.code(p(r,o)).code(s))}function p(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?i._`/*# sourceURL=${r} */`:i.nil}function f(t,r){y(t)&&(g(t),m(t))?function(e,t){const{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&_(e);(function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))})(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const s=n.const("_errs",c.default.errors);v(e,s),n.var(t,i._`${s} === ${c.default.errors}`)}(t,r):(0,e.boolOrEmptySchema)(t,r)}function m({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function y(e){return"boolean"!=typeof e.schema}function g(e){(0,l.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(e)}function v(e,r){if(e.opts.jtd)return w(e,[],!1,r);const n=(0,t.getSchemaTypes)(e.schema);w(e,n,!(0,t.coerceAndCheckDataType)(e,n),r)}function _({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){const s=r.$comment;if(!0===o.$comment)e.code(i._`${c.default.self}.logger.log(${s})`);else if("function"==typeof o.$comment){const r=i.str`${n}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(i._`${c.default.self}.opts.$comment(${s}, ${r}, ${o}.schema)`)}}function w(e,t,o,s){const{gen:a,schema:u,data:d,allErrors:h,opts:p,self:f}=e,{RULES:m}=f;function y(l){(0,r.shouldUseGroup)(u,l)&&(l.type?(a.if((0,n.checkDataType)(l.type,d,p.strictNumbers)),$(e,l),1===t.length&&t[0]===l.type&&o&&(a.else(),(0,n.reportTypeError)(e)),a.endIf()):$(e,l),h||a.if(i._`${c.default.errors} === ${s||0}`))}!u.$ref||!p.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(u,m)?(p.jtd||function(e,t){if(e.schemaEnv.meta||!e.opts.strictTypes)return;(function(e,t){if(!t.length)return;if(!e.dataTypes.length)return void(e.dataTypes=t);t.forEach(t=>{k(e.dataTypes,t)||E(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const r=[];for(const n of e.dataTypes)k(t,n)?r.push(n):t.includes("integer")&&"number"===n&&r.push("integer");e.dataTypes=r}(e,t)})(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&E(e,"use allowUnionTypes to allow union type keyword")}(e,t);!function(e,t){const n=e.self.RULES.all;for(const o in n){const s=n[o];if("object"==typeof s&&(0,r.shouldUseRule)(e.schema,s)){const{type:r}=s.definition;r.length&&!r.some(e=>b(t,e))&&E(e,`missing type "${r.join(",")}" for keyword "${o}"`)}}}(e,e.dataTypes)}(e,t),a.block(()=>{for(const e of m.rules)y(e);y(m.post)})):a.block(()=>S(e,"$ref",m.all.$ref.definition))}function $(e,t){const{gen:n,schema:s,opts:{useDefaults:a}}=e;a&&(0,o.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(s,n)&&S(e,n.keyword,n.definition,t.type)})}function b(e,t){return e.includes(t)||"number"===t&&e.includes("integer")}function k(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function E(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,l.checkStrictMode)(e,t,e.opts.strictTypes)}tc.validateFunctionCode=function(t){y(t)&&(g(t),m(t))?function(e){const{schema:t,opts:r,gen:n}=e;h(e,()=>{r.$comment&&t.$comment&&_(e),function(e){const{schema:t,opts:r}=e;void 0!==t.default&&r.useDefaults&&r.strictSchema&&(0,l.checkStrictMode)(e,"default is ignored in the schema root")}(e),n.let(c.default.vErrors,null),n.let(c.default.errors,0),r.unevaluated&&function(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",i._`${r}.evaluated`),t.if(i._`${e.evaluated}.dynamicProps`,()=>t.assign(i._`${e.evaluated}.props`,i._`undefined`)),t.if(i._`${e.evaluated}.dynamicItems`,()=>t.assign(i._`${e.evaluated}.items`,i._`undefined`))}(e),v(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if(i._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(i._`new ${o}(${c.default.vErrors})`)):(t.assign(i._`${n}.errors`,c.default.vErrors),s.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof i.Name&&e.assign(i._`${t}.props`,r);n instanceof i.Name&&e.assign(i._`${t}.items`,n)}(e),t.return(i._`${c.default.errors} === 0`))}(e)})}(t):h(t,()=>(0,e.topBoolOrEmptySchema)(t))};class P{constructor(e,t,r){if((0,s.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,l.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",x(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,s.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",c.default.errors))}result(e,t,r){this.failResult((0,i.not)(e),t,r)}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,i.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(i._`${t} !== undefined && (${(0,i.or)(this.invalid$data(),e)})`)}error(e,t,r){if(t)return this.setParams(t),this._error(e,r),void this.setParams({});this._error(e,r)}_error(e,t){(e?d.reportExtraError:d.reportError)(this,this.def.error,t)}$dataError(){(0,d.reportError)(this,this.def.$dataError||d.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,d.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,r=i.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=i.nil,t=i.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:o,def:s}=this;r.if((0,i.or)(i._`${n} === undefined`,t)),e!==i.nil&&r.assign(e,!0),(o.length||s.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==i.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:o,it:s}=this;return(0,i.or)(function(){if(r.length){if(!(t instanceof i.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return i._`${(0,n.checkDataTypes)(e,t,s.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}(),function(){if(o.validateSchema){const r=e.scopeValue("validate$data",{ref:o.validateSchema});return i._`!${r}(${t})`}return i.nil}())}subschema(e,t){const r=(0,a.getSubschema)(this.it,e);(0,a.extendSubschemaData)(r,this.it,e),(0,a.extendSubschemaMode)(r,e);const n={...this.it,...r,items:void 0,props:void 0};return f(n,t),n}mergeEvaluated(e,t){const{it:r,gen:n}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==e.props&&(r.props=l.mergeEvaluated.props(n,e.props,r.props,t)),!0!==r.items&&void 0!==e.items&&(r.items=l.mergeEvaluated.items(n,e.items,r.items,t)))}mergeValidEvaluated(e,t){const{it:r,gen:n}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return n.if(t,()=>this.mergeEvaluated(e,i.Name)),!0}}function S(e,t,r,n){const o=new P(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,s.funcKeywordCode)(o,r):"macro"in r?(0,s.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,s.funcKeywordCode)(o,r)}tc.KeywordCxt=P;const T=/^\/(?:[^~]|~0|~1)*$/,I=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(""===e)return c.default.rootData;if("/"===e[0]){if(!T.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=c.default.rootData}else{const a=I.exec(e);if(!a)throw new Error(`Invalid JSON-pointer: ${e}`);const i=+a[1];if(o=a[2],"#"===o){if(i>=t)throw new Error(d("property/index",i));return n[t-i]}if(i>t)throw new Error(d("data",i));if(s=r[t-i],!o)return s}let a=s;const u=o.split("/");for(const e of u)e&&(s=i._`${s}${(0,i.getProperty)((0,l.unescapeJsonPointer)(e))}`,a=i._`${a} && ${s}`);return a;function d(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return tc.getData=x,tc}su.getSchemaRefs=function(e,t){if("boolean"==typeof e)return{};const{schemaId:r,uriResolver:n}=this.opts,o=bu(e[r]||t),s={"":o},a=_u(n,o,!1),i={},c=new Set;return fu(e,{allKeys:!0},(e,t,n,o)=>{if(void 0===o)return;const d=a+t;let h=s[o];function p(t){const r=this.opts.uriResolver.resolve;if(t=bu(h?r(h,t):t),c.has(t))throw l(t);c.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?u(e,n.schema,t):t!==bu(d)&&("#"===t[0]?(u(e,i[t],t),i[t]=e):this.refs[t]=d),t}function f(e){if("string"==typeof e){if(!ku.test(e))throw new Error(`invalid anchor "${e}"`);p.call(this,`#${e}`)}}"string"==typeof e[r]&&(h=p.call(this,e[r])),f.call(this,e.$anchor),f.call(this,e.$dynamicAnchor),s[t]=h}),i;function u(e,t,r){if(void 0!==t&&!pu(e,t))throw l(r)}function l(e){return new Error(`reference "${e}" resolves to more than one schema`)}};var Su,Tu={};function Iu(){if(Su)return Tu;Su=1,Object.defineProperty(Tu,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return Tu.default=e,Tu}var xu,Nu={};function Cu(){if(xu)return Nu;xu=1,Object.defineProperty(Nu,"__esModule",{value:!0});const e=su;class t extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,e.resolveUrl)(t,r,n),this.missingSchema=(0,e.normalizeId)((0,e.getFullPath)(t,this.missingRef))}}return Nu.default=t,Nu}var ju={};Object.defineProperty(ju,"__esModule",{value:!0}),ju.resolveSchema=ju.getCompilingSchema=ju.resolveRef=ju.compileSchema=ju.SchemaEnv=void 0;const Ru=dc(),Ou=Iu(),zu=xc(),Au=su,Mu=hc,Du=Pu();let Uu=class{constructor(e){var t;let r;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,Au.normalizeId)(null==r?void 0:r[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==r?void 0:r.$async,this.refs={}}};function qu(e){const t=Fu.call(this,e);if(t)return t;const r=(0,Au.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,a=new Ru.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s});let i;e.$async&&(i=a.scopeValue("Error",{ref:Ou.default,code:Ru._`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const u={gen:a,allErrors:this.opts.allErrors,data:zu.default.data,parentData:zu.default.parentData,parentDataProperty:zu.default.parentDataProperty,dataNames:[zu.default.data],dataPathArr:[Ru.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,Ru.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Ru.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:Ru._`""`,opts:this.opts,self:this};let l;try{this._compilations.add(e),(0,Du.validateFunctionCode)(u),a.optimize(this.opts.code.optimize);const t=a.toString();l=`${a.scopeRefs(zu.default.scope)}return ${t}`,this.opts.code.process&&(l=this.opts.code.process(l,e));const r=new Function(`${zu.default.self}`,`${zu.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:r}),r.errors=null,r.schema=e.schema,r.schemaEnv=e,e.$async&&(r.$async=!0),!0===this.opts.code.source&&(r.source={validateName:c,validateCode:t,scopeValues:a._values}),this.opts.unevaluated){const{props:e,items:t}=u;r.evaluated={props:e instanceof Ru.Name?void 0:e,items:t instanceof Ru.Name?void 0:t,dynamicProps:e instanceof Ru.Name,dynamicItems:t instanceof Ru.Name},r.source&&(r.source.evaluated=(0,Ru.stringify)(r.evaluated))}return e.validate=r,e}catch(t){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),t}finally{this._compilations.delete(e)}}function Vu(e){return(0,Au.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:qu.call(this,e)}function Fu(e){for(const t of this._compilations)if(Lu(t,e))return t}function Lu(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Ku(e,t){let r;for(;"string"==typeof(r=this.refs[t]);)t=r;return r||this.schemas[t]||Hu.call(this,e,t)}function Hu(e,t){const r=this.opts.uriResolver.parse(t),n=(0,Au._getFullPath)(this.opts.uriResolver,r);let o=(0,Au.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Gu.call(this,r,e);const s=(0,Au.normalizeId)(n),a=this.refs[s]||this.schemas[s];if("string"==typeof a){const t=Hu.call(this,e,a);if("object"!=typeof(null==t?void 0:t.schema))return;return Gu.call(this,r,t)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||qu.call(this,a),s===(0,Au.normalizeId)(t)){const{schema:t}=a,{schemaId:r}=this.opts,n=t[r];return n&&(o=(0,Au.resolveUrl)(this.opts.uriResolver,o,n)),new Uu({schema:t,schemaId:r,root:e,baseId:o})}return Gu.call(this,r,a)}}ju.SchemaEnv=Uu,ju.compileSchema=qu,ju.resolveRef=function(e,t,r){var n;r=(0,Au.resolveUrl)(this.opts.uriResolver,t,r);const o=e.refs[r];if(o)return o;let s=Ku.call(this,e,r);if(void 0===s){const o=null===(n=e.localRefs)||void 0===n?void 0:n[r],{schemaId:a}=this.opts;o&&(s=new Uu({schema:o,schemaId:a,root:e,baseId:t}))}return void 0!==s?e.refs[r]=Vu.call(this,s):void 0},ju.getCompilingSchema=Fu,ju.resolveSchema=Hu;const Zu=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Gu(e,{baseId:t,schema:r,root:n}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const n of e.fragment.slice(1).split("/")){if("boolean"==typeof r)return;const e=r[(0,Mu.unescapeFragment)(n)];if(void 0===e)return;const o="object"==typeof(r=e)&&r[this.opts.schemaId];!Zu.has(n)&&o&&(t=(0,Au.resolveUrl)(this.opts.uriResolver,t,o))}let s;if("boolean"!=typeof r&&r.$ref&&!(0,Mu.schemaHasRulesButRef)(r,this.RULES)){const e=(0,Au.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Hu.call(this,n,e)}const{schemaId:a}=this.opts;return s=s||new Uu({schema:r,schemaId:a,root:n,baseId:t}),s.schema!==s.root.schema?s:void 0}var Bu={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},Ju={},Wu={exports:{}};const Qu=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Yu=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function Xu(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),48!==r){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}function el(e){return e.length=0,!0}function tl(e,t,r){if(e.length){const n=Xu(e);if(""===n)return r.error=!0,!1;t.push(n),e.length=0}return!0}function rl(e){if(function(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}(e,":")<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const r={error:!1,address:"",zone:""},n=[],o=[];let s=!1,a=!1,i=tl;for(let c=0;c<e.length;c++){const u=e[c];if("["!==u&&"]"!==u)if(":"!==u)if("%"===u){if(!i(o,n,r))break;i=el}else o.push(u);else{if(!0===s&&(a=!0),!i(o,n,r))break;if(++t>7){r.error=!0;break}c>0&&":"===e[c-1]&&(s=!0),n.push(":")}}return o.length&&(i===el?r.zone=o.join(""):a?n.push(o.join("")):n.push(Xu(o))),r.address=n.join(""),r}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,r=t.address;return t.zone&&(e+="%"+t.zone,r+="%25"+t.zone),{host:e,isIPV6:!0,escapedHost:r}}}var nl={nonSimpleDomain:RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u),recomposeAuthority:function(e){const t=[];if(void 0!==e.userinfo&&(t.push(e.userinfo),t.push("@")),void 0!==e.host){let r=unescape(e.host);if(!Yu(r)){const t=rl(r);r=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}t.push(r)}return"number"!=typeof e.port&&"string"!=typeof e.port||(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0},normalizeComponentEncoding:function(e,t){const r=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=r(e.scheme)),void 0!==e.userinfo&&(e.userinfo=r(e.userinfo)),void 0!==e.host&&(e.host=r(e.host)),void 0!==e.path&&(e.path=r(e.path)),void 0!==e.query&&(e.query=r(e.query)),void 0!==e.fragment&&(e.fragment=r(e.fragment)),e},removeDotSegments:function(e){let t=e;const r=[];let n=-1,o=0;for(;o=t.length;){if(1===o){if("."===t)break;if("/"===t){r.push("/");break}r.push(t);break}if(2===o){if("."===t[0]){if("."===t[1])break;if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&("."===t[1]||"/"===t[1])){r.push("/");break}}else if(3===o&&"/.."===t){0!==r.length&&r.pop(),r.push("/");break}if("."===t[0]){if("."===t[1]){if("/"===t[2]){t=t.slice(3);continue}}else if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&"."===t[1]){if("/"===t[2]){t=t.slice(2);continue}if("."===t[2]&&"/"===t[3]){t=t.slice(3),0!==r.length&&r.pop();continue}}if(-1===(n=t.indexOf("/",1))){r.push(t);break}r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")},isIPv4:Yu,isUUID:Qu,normalizeIPv6:rl,stringArrayToHexStripped:Xu};const{isUUID:ol}=nl,sl=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,al=["http","https","ws","wss","urn","urn:uuid"];function il(e){return!0===e.secure||!1!==e.secure&&(!!e.scheme&&!(3!==e.scheme.length||"w"!==e.scheme[0]&&"W"!==e.scheme[0]||"s"!==e.scheme[1]&&"S"!==e.scheme[1]||"s"!==e.scheme[2]&&"S"!==e.scheme[2]))}function cl(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function ul(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const ll={scheme:"http",domainHost:!0,parse:cl,serialize:ul},dl={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=il(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(il(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,r]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}},hl={http:ll,https:{scheme:"https",domainHost:ll.domainHost,parse:cl,serialize:ul},ws:dl,wss:{scheme:"wss",domainHost:dl.domainHost,parse:dl.parse,serialize:dl.serialize},urn:{scheme:"urn",parse:function(e,t){if(!e.path)return e.error="URN can not be parsed",e;const r=e.path.match(sl);if(r){const n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];const o=pl(`${n}:${t.nid||e.nid}`);e.path=void 0,o&&(e=o.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){if(void 0===e.nid)throw new Error("URN without nid cannot be serialized");const r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=pl(`${r}:${t.nid||n}`);o&&(e=o.serialize(e,t));const s=e,a=e.nss;return s.path=`${n||t.nid}:${a}`,t.skipEscape=!0,s},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(e,t){const r=e;return r.uuid=r.nss,r.nss=void 0,t.tolerant||r.uuid&&ol(r.uuid)||(r.error=r.error||"UUID is not valid."),r},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};function pl(e){return e&&(hl[e]||hl[e.toLowerCase()])||void 0}Object.setPrototypeOf(hl,null);var fl={wsIsSecure:il,SCHEMES:hl,isValidSchemeName:function(e){return-1!==al.indexOf(e)},getSchemeHandler:pl};const{normalizeIPv6:ml,removeDotSegments:yl,recomposeAuthority:gl,normalizeComponentEncoding:vl,isIPv4:_l,nonSimpleDomain:wl}=nl,{SCHEMES:$l,getSchemeHandler:bl}=fl;function kl(e,t,r,n){const o={};return n||(e=Sl(El(e,r),r),t=Sl(El(t,r),r)),!(r=r||{}).tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=yl(t.path||""),o.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=yl(t.path||""),o.query=t.query):(t.path?("/"===t.path[0]?o.path=yl(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path:o.path="/"+t.path,o.path=yl(o.path)),o.query=t.query):(o.path=e.path,void 0!==t.query?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function El(e,t){const r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[],s=bl(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),void 0!==r.path&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),void 0!==r.scheme&&(r.path=r.path.split("%3A").join(":")))),"suffix"!==n.reference&&r.scheme&&o.push(r.scheme,":");const a=gl(r);if(void 0!==a&&("suffix"!==n.reference&&o.push("//"),o.push(a),r.path&&"/"!==r.path[0]&&o.push("/")),void 0!==r.path){let e=r.path;n.absolutePath||s&&s.absolutePath||(e=yl(e)),void 0===a&&"/"===e[0]&&"/"===e[1]&&(e="/%2F"+e.slice(2)),o.push(e)}return void 0!==r.query&&o.push("?",r.query),void 0!==r.fragment&&o.push("#",r.fragment),o.join("")}const Pl=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Sl(e,t){const r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let o=!1;"suffix"===r.reference&&(e=r.scheme?r.scheme+":"+e:"//"+e);const s=e.match(Pl);if(s){if(n.scheme=s[1],n.userinfo=s[3],n.host=s[4],n.port=parseInt(s[5],10),n.path=s[6]||"",n.query=s[7],n.fragment=s[8],isNaN(n.port)&&(n.port=s[5]),n.host){if(!1===_l(n.host)){const e=ml(n.host);n.host=e.host.toLowerCase(),o=e.isIPV6}else o=!0}void 0!==n.scheme||void 0!==n.userinfo||void 0!==n.host||void 0!==n.port||void 0!==n.query||n.path?void 0===n.scheme?n.reference="relative":void 0===n.fragment?n.reference="absolute":n.reference="uri":n.reference="same-document",r.reference&&"suffix"!==r.reference&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");const t=bl(r.scheme||n.scheme);if(!(r.unicodeSupport||t&&t.unicodeSupport)&&n.host&&(r.domainHost||t&&t.domainHost)&&!1===o&&wl(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(e){n.error=n.error||"Host's domain name can not be converted to ASCII: "+e}(!t||t&&!t.skipNormalize)&&(-1!==e.indexOf("%")&&(void 0!==n.scheme&&(n.scheme=unescape(n.scheme)),void 0!==n.host&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),t&&t.parse&&t.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}const Tl={SCHEMES:$l,normalize:function(e,t){return"string"==typeof e?e=El(Sl(e,t),t):"object"==typeof e&&(e=Sl(El(e,t),t)),e},resolve:function(e,t,r){const n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=kl(Sl(e,n),Sl(t,n),n,!0);return n.skipEscape=!0,El(o,n)},resolveComponent:kl,equal:function(e,t,r){return"string"==typeof e?(e=unescape(e),e=El(vl(Sl(e,r),!0),{...r,skipEscape:!0})):"object"==typeof e&&(e=El(vl(e,!0),{...r,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=El(vl(Sl(t,r),!0),{...r,skipEscape:!0})):"object"==typeof t&&(t=El(vl(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:El,parse:Sl};Wu.exports=Tl,Wu.exports.default=Tl,Wu.exports.fastUri=Tl;var Il=Wu.exports;Object.defineProperty(Ju,"__esModule",{value:!0});const xl=Il;xl.code='require("ajv/dist/runtime/uri").default',Ju.default=xl,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Pu();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=dc();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Iu(),o=Cu(),s=jc,a=ju,i=dc(),c=su,u=Cc,l=hc,d=Bu,h=Ju,p=(e,t)=>new RegExp(e,t);p.code="new RegExp";const f=["removeAdditional","useDefaults","coerceTypes"],m=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),y={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},g={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function v(e){var t,r,n,o,s,a,i,c,u,l,d,f,m,y,g,v,_,w,$,b,k,E,P,S,T;const I=e.strict,x=null===(t=e.code)||void 0===t?void 0:t.optimize,N=!0===x||void 0===x?1:x||0,C=null!==(n=null===(r=e.code)||void 0===r?void 0:r.regExp)&&void 0!==n?n:p,j=null!==(o=e.uriResolver)&&void 0!==o?o:h.default;return{strictSchema:null===(a=null!==(s=e.strictSchema)&&void 0!==s?s:I)||void 0===a||a,strictNumbers:null===(c=null!==(i=e.strictNumbers)&&void 0!==i?i:I)||void 0===c||c,strictTypes:null!==(l=null!==(u=e.strictTypes)&&void 0!==u?u:I)&&void 0!==l?l:"log",strictTuples:null!==(f=null!==(d=e.strictTuples)&&void 0!==d?d:I)&&void 0!==f?f:"log",strictRequired:null!==(y=null!==(m=e.strictRequired)&&void 0!==m?m:I)&&void 0!==y&&y,code:e.code?{...e.code,optimize:N,regExp:C}:{optimize:N,regExp:C},loopRequired:null!==(g=e.loopRequired)&&void 0!==g?g:200,loopEnum:null!==(v=e.loopEnum)&&void 0!==v?v:200,meta:null===(_=e.meta)||void 0===_||_,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===($=e.inlineRefs)||void 0===$||$,schemaId:null!==(b=e.schemaId)&&void 0!==b?b:"$id",addUsedSchema:null===(k=e.addUsedSchema)||void 0===k||k,validateSchema:null===(E=e.validateSchema)||void 0===E||E,validateFormats:null===(P=e.validateFormats)||void 0===P||P,unicodeRegExp:null===(S=e.unicodeRegExp)||void 0===S||S,int32range:null===(T=e.int32range)||void 0===T||T,uriResolver:j}}class _{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};const{es5:t,lines:r}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:m,es5:t,lines:r}),this.logger=function(e){if(!1===e)return S;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,s.getRules)(),w.call(this,y,e,"NOT SUPPORTED"),w.call(this,g,e,"DEPRECATED","warn"),this._metaOpts=P.call(this),e.formats&&k.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),b.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:r}=this.opts;let n=d;"id"===r&&(n={...d},n.id=n.$id,delete n.$id),t&&e&&this.addMetaSchema(n,n[r],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let r;if("string"==typeof e){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);const n=r(t);return"$async"in r||(this.errors=r.errors),n}compile(e,t){const r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return n.call(this,e,t);async function n(e,t){await s.call(this,e.$schema);const r=this._addSchema(e,t);return r.validate||a.call(this,r)}async function s(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function a(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof o.default))throw t;return i.call(this,t),await c.call(this,t.missingSchema),a.call(this,e)}}function i({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){const r=await u.call(this,e);this.refs[e]||await s.call(this,r.$schema),this.refs[e]||this.addSchema(r,e,t)}async function u(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=r(e))}finally{delete this._loading[e]}}}addSchema(e,t,r,n=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,r,n);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,n,!0),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,!0,r),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let r;if(r=e.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const n=this.validate(r,e);if(!n&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return n}getSchema(e){let t;for(;"string"==typeof(t=$.call(this,e));)e=t;if(void 0===t){const{schemaId:r}=this.opts,n=new a.SchemaEnv({schema:{},schemaId:r});if(t=a.resolveSchema.call(this,n,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=$.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0,c.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if("string"==typeof e)r=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(r=(t=e).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(I.call(this,r,t),!t)return(0,l.eachItem)(r,e=>x.call(this,e)),this;C.call(this,t);const n={...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)};return(0,l.eachItem)(r,0===n.type.length?e=>x.call(this,e,n):e=>n.type.forEach(t=>x.call(this,e,n,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const r of t.rules){const t=r.rules.findIndex(t=>t.keyword===e);t>=0&&r.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return e&&0!==e.length?e.map(e=>`${r}${e.instancePath} ${e.message}`).reduce((e,r)=>e+t+r):"No errors"}$dataMetaSchema(e,t){const r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const n of t){const t=n.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in r){const t=r[e];if("object"!=typeof t)continue;const{$data:n}=t.definition,s=o[e];n&&s&&(o[e]=R(s))}}return e}_removeAllSchemas(e,t){for(const r in e){const n=e[r];t&&!t.test(r)||("string"==typeof n?delete e[r]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[r]))}}_addSchema(e,t,r,n=this.opts.validateSchema,o=this.opts.addUsedSchema){let s;const{schemaId:i}=this.opts;if("object"==typeof e)s=e[i];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let u=this._cache.get(e);if(void 0!==u)return u;r=(0,c.normalizeId)(s||r);const l=c.getSchemaRefs.call(this,e,r);return u=new a.SchemaEnv({schema:e,schemaId:i,meta:t,baseId:r,localRefs:l}),this._cache.set(u.schema,u),o&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=u),n&&this.validateSchema(e,!0),u}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):a.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,e)}finally{this.opts=t}}}function w(e,t,r,n="error"){for(const o in e){const s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function $(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function b(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function k(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}}function P(){const e={...this.opts};for(const t of f)delete e[t];return e}_.ValidationError=n.default,_.MissingRefError=o.default,e.default=_;const S={log(){},warn(){},error(){}};const T=/^[a-z_$][a-z0-9_$:-]*$/i;function I(e,t){const{RULES:r}=this;if((0,l.eachItem)(e,e=>{if(r.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!T.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function x(e,t,r){var n;const o=null==t?void 0:t.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:s}=this;let a=o?s.post:s.rules.find(({type:e})=>e===r);if(a||(a={type:r,rules:[]},s.rules.push(a)),s.keywords[e]=!0,!t)return;const i={keyword:e,definition:{...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)}};t.before?N.call(this,a,i,t.before):a.rules.push(i),s.all[e]=i,null===(n=t.implements)||void 0===n||n.forEach(e=>this.addKeyword(e))}function N(e,t,r){const n=e.rules.findIndex(e=>e.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function C(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=R(t)),e.validateSchema=this.compile(t,!0))}const j={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function R(e){return{anyOf:[e,j]}}}(ec);var Nl={},Cl={},jl={};Object.defineProperty(jl,"__esModule",{value:!0});const Rl={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};jl.default=Rl;var Ol={};Object.defineProperty(Ol,"__esModule",{value:!0}),Ol.callRef=Ol.getValidate=void 0;const zl=Cu(),Al=tu(),Ml=dc(),Dl=xc(),Ul=ju,ql=hc,Vl={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:a,opts:i,self:c}=n,{root:u}=s;if(("#"===r||"#/"===r)&&o===u.baseId)return function(){if(s===u)return Ll(e,a,s,s.$async);const r=t.scopeValue("root",{ref:u});return Ll(e,Ml._`${r}.validate`,u,u.$async)}();const l=Ul.resolveRef.call(c,u,o,r);if(void 0===l)throw new zl.default(n.opts.uriResolver,o,r);return l instanceof Ul.SchemaEnv?function(t){const r=Fl(e,t);Ll(e,r,t,t.$async)}(l):function(n){const o=t.scopeValue("schema",!0===i.code.source?{ref:n,code:(0,Ml.stringify)(n)}:{ref:n}),s=t.name("valid"),a=e.subschema({schema:n,dataTypes:[],schemaPath:Ml.nil,topSchemaRef:o,errSchemaPath:r},s);e.mergeEvaluated(a),e.ok(s)}(l)}};function Fl(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):Ml._`${r.scopeValue("wrapper",{ref:t})}.validate`}function Ll(e,t,r,n){const{gen:o,it:s}=e,{allErrors:a,schemaEnv:i,opts:c}=s,u=c.passContext?Dl.default.this:Ml.nil;function l(e){const t=Ml._`${e}.errors`;o.assign(Dl.default.vErrors,Ml._`${Dl.default.vErrors} === null ? ${t} : ${Dl.default.vErrors}.concat(${t})`),o.assign(Dl.default.errors,Ml._`${Dl.default.vErrors}.length`)}function d(e){var t;if(!s.opts.unevaluated)return;const n=null===(t=null==r?void 0:r.validate)||void 0===t?void 0:t.evaluated;if(!0!==s.props)if(n&&!n.dynamicProps)void 0!==n.props&&(s.props=ql.mergeEvaluated.props(o,n.props,s.props));else{const t=o.var("props",Ml._`${e}.evaluated.props`);s.props=ql.mergeEvaluated.props(o,t,s.props,Ml.Name)}if(!0!==s.items)if(n&&!n.dynamicItems)void 0!==n.items&&(s.items=ql.mergeEvaluated.items(o,n.items,s.items));else{const t=o.var("items",Ml._`${e}.evaluated.items`);s.items=ql.mergeEvaluated.items(o,t,s.items,Ml.Name)}}n?function(){if(!i.$async)throw new Error("async schema referenced by sync schema");const r=o.let("valid");o.try(()=>{o.code(Ml._`await ${(0,Al.callValidateCode)(e,t,u)}`),d(t),a||o.assign(r,!0)},e=>{o.if(Ml._`!(${e} instanceof ${s.ValidationError})`,()=>o.throw(e)),l(e),a||o.assign(r,!1)}),e.ok(r)}():e.result((0,Al.callValidateCode)(e,t,u),()=>d(t),()=>l(t))}Ol.getValidate=Fl,Ol.callRef=Ll,Ol.default=Vl,Object.defineProperty(Cl,"__esModule",{value:!0});const Kl=Ol,Hl=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",jl.default,Kl.default];Cl.default=Hl;var Zl={},Gl={};Object.defineProperty(Gl,"__esModule",{value:!0});const Bl=dc(),Jl=Bl.operators,Wl={maximum:{okStr:"<=",ok:Jl.LTE,fail:Jl.GT},minimum:{okStr:">=",ok:Jl.GTE,fail:Jl.LT},exclusiveMaximum:{okStr:"<",ok:Jl.LT,fail:Jl.GTE},exclusiveMinimum:{okStr:">",ok:Jl.GT,fail:Jl.LTE}},Ql={message:({keyword:e,schemaCode:t})=>Bl.str`must be ${Wl[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>Bl._`{comparison: ${Wl[e].okStr}, limit: ${t}}`},Yl={keyword:Object.keys(Wl),type:"number",schemaType:"number",$data:!0,error:Ql,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data(Bl._`${r} ${Wl[t].fail} ${n} || isNaN(${r})`)}};Gl.default=Yl;var Xl={};Object.defineProperty(Xl,"__esModule",{value:!0});const ed=dc(),td={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>ed.str`must be multiple of ${e}`,params:({schemaCode:e})=>ed._`{multipleOf: ${e}}`},code(e){const{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,a=t.let("res"),i=s?ed._`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:ed._`${a} !== parseInt(${a})`;e.fail$data(ed._`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Xl.default=td;var rd={},nd={};function od(e){const t=e.length;let r,n=0,o=0;for(;o<t;)n++,r=e.charCodeAt(o++),r>=55296&&r<=56319&&o<t&&(r=e.charCodeAt(o),56320==(64512&r)&&o++);return n}Object.defineProperty(nd,"__esModule",{value:!0}),nd.default=od,od.code='require("ajv/dist/runtime/ucs2length").default',Object.defineProperty(rd,"__esModule",{value:!0});const sd=dc(),ad=hc,id=nd,cd={message({keyword:e,schemaCode:t}){const r="maxLength"===e?"more":"fewer";return sd.str`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>sd._`{limit: ${e}}`},ud={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:cd,code(e){const{keyword:t,data:r,schemaCode:n,it:o}=e,s="maxLength"===t?sd.operators.GT:sd.operators.LT,a=!1===o.opts.unicode?sd._`${r}.length`:sd._`${(0,ad.useFunc)(e.gen,id.default)}(${r})`;e.fail$data(sd._`${a} ${s} ${n}`)}};rd.default=ud;var ld={};Object.defineProperty(ld,"__esModule",{value:!0});const dd=tu(),hd=hc,pd=dc(),fd={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>pd.str`must match pattern "${e}"`,params:({schemaCode:e})=>pd._`{pattern: ${e}}`},code(e){const{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:n}=a.opts.code,o="new RegExp"===n.code?pd._`new RegExp`:(0,hd.useFunc)(t,n),c=t.let("valid");t.try(()=>t.assign(c,pd._`${o}(${s}, ${i}).test(${r})`),()=>t.assign(c,!1)),e.fail$data(pd._`!${c}`)}else{const t=(0,dd.usePattern)(e,o);e.fail$data(pd._`!${t}.test(${r})`)}}};ld.default=fd;var md={};Object.defineProperty(md,"__esModule",{value:!0});const yd=dc(),gd={message({keyword:e,schemaCode:t}){const r="maxProperties"===e?"more":"fewer";return yd.str`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>yd._`{limit: ${e}}`},vd={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:gd,code(e){const{keyword:t,data:r,schemaCode:n}=e,o="maxProperties"===t?yd.operators.GT:yd.operators.LT;e.fail$data(yd._`Object.keys(${r}).length ${o} ${n}`)}};md.default=vd;var _d={};Object.defineProperty(_d,"__esModule",{value:!0});const wd=tu(),$d=dc(),bd=hc,kd={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>$d.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>$d._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:a}=e,{opts:i}=a;if(!s&&0===r.length)return;const c=r.length>=i.loopRequired;if(a.allErrors?function(){if(c||s)e.block$data($d.nil,u);else for(const t of r)(0,wd.checkReportMissingProp)(e,t)}():function(){const a=t.let("missing");if(c||s){const r=t.let("valid",!0);e.block$data(r,()=>function(r,s){e.setParams({missingProperty:r}),t.forOf(r,n,()=>{t.assign(s,(0,wd.propertyInData)(t,o,r,i.ownProperties)),t.if((0,$d.not)(s),()=>{e.error(),t.break()})},$d.nil)}(a,r)),e.ok(r)}else t.if((0,wd.checkMissingProp)(e,r,a)),(0,wd.reportMissingProp)(e,a),t.else()}(),i.strictRequired){const t=e.parentSchema.properties,{definedProperties:n}=e.it;for(const e of r)if(void 0===(null==t?void 0:t[e])&&!n.has(e)){const t=`required property "${e}" is not defined at "${a.schemaEnv.baseId+a.errSchemaPath}" (strictRequired)`;(0,bd.checkStrictMode)(a,t,a.opts.strictRequired)}}function u(){t.forOf("prop",n,r=>{e.setParams({missingProperty:r}),t.if((0,wd.noPropertyInData)(t,o,r,i.ownProperties),()=>e.error())})}}};_d.default=kd;var Ed={};Object.defineProperty(Ed,"__esModule",{value:!0});const Pd=dc(),Sd={message({keyword:e,schemaCode:t}){const r="maxItems"===e?"more":"fewer";return Pd.str`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>Pd._`{limit: ${e}}`},Td={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Sd,code(e){const{keyword:t,data:r,schemaCode:n}=e,o="maxItems"===t?Pd.operators.GT:Pd.operators.LT;e.fail$data(Pd._`${r}.length ${o} ${n}`)}};Ed.default=Td;var Id={},xd={};Object.defineProperty(xd,"__esModule",{value:!0});const Nd=au;Nd.code='require("ajv/dist/runtime/equal").default',xd.default=Nd,Object.defineProperty(Id,"__esModule",{value:!0});const Cd=Cc,jd=dc(),Rd=hc,Od=xd,zd={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>jd.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>jd._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:a,it:i}=e;if(!n&&!o)return;const c=t.let("valid"),u=s.items?(0,Cd.getSchemaTypes)(s.items):[];function l(n,o){const s=t.name("item"),a=(0,Cd.checkDataTypes)(u,s,i.opts.strictNumbers,Cd.DataType.Wrong),l=t.const("indices",jd._`{}`);t.for(jd._`;${n}--;`,()=>{t.let(s,jd._`${r}[${n}]`),t.if(a,jd._`continue`),u.length>1&&t.if(jd._`typeof ${s} == "string"`,jd._`${s} += "_"`),t.if(jd._`typeof ${l}[${s}] == "number"`,()=>{t.assign(o,jd._`${l}[${s}]`),e.error(),t.assign(c,!1).break()}).code(jd._`${l}[${s}] = ${n}`)})}function d(n,o){const s=(0,Rd.useFunc)(t,Od.default),a=t.name("outer");t.label(a).for(jd._`;${n}--;`,()=>t.for(jd._`${o} = ${n}; ${o}--;`,()=>t.if(jd._`${s}(${r}[${n}], ${r}[${o}])`,()=>{e.error(),t.assign(c,!1).break(a)})))}e.block$data(c,function(){const n=t.let("i",jd._`${r}.length`),o=t.let("j");e.setParams({i:n,j:o}),t.assign(c,!0),t.if(jd._`${n} > 1`,()=>(u.length>0&&!u.some(e=>"object"===e||"array"===e)?l:d)(n,o))},jd._`${a} === false`),e.ok(c)}};Id.default=zd;var Ad={};Object.defineProperty(Ad,"__esModule",{value:!0});const Md=dc(),Dd=hc,Ud=xd,qd={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>Md._`{allowedValue: ${e}}`},code(e){const{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&"object"==typeof s?e.fail$data(Md._`!${(0,Dd.useFunc)(t,Ud.default)}(${r}, ${o})`):e.fail(Md._`${s} !== ${r}`)}};Ad.default=qd;var Vd={};Object.defineProperty(Vd,"__esModule",{value:!0});const Fd=dc(),Ld=hc,Kd=xd,Hd={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>Fd._`{allowedValues: ${e}}`},code(e){const{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e;if(!n&&0===o.length)throw new Error("enum must have non-empty array");const i=o.length>=a.opts.loopEnum;let c;const u=()=>null!=c?c:c=(0,Ld.useFunc)(t,Kd.default);let l;if(i||n)l=t.let("valid"),e.block$data(l,function(){t.assign(l,!1),t.forOf("v",s,e=>t.if(Fd._`${u()}(${r}, ${e})`,()=>t.assign(l,!0).break()))});else{if(!Array.isArray(o))throw new Error("ajv implementation error");const e=t.const("vSchema",s);l=(0,Fd.or)(...o.map((t,n)=>function(e,t){const n=o[t];return"object"==typeof n&&null!==n?Fd._`${u()}(${r}, ${e}[${t}])`:Fd._`${r} === ${n}`}(e,n)))}e.pass(l)}};Vd.default=Hd,Object.defineProperty(Zl,"__esModule",{value:!0});const Zd=Xl,Gd=rd,Bd=ld,Jd=md,Wd=_d,Qd=Ed,Yd=Id,Xd=Ad,eh=Vd,th=[Gl.default,Zd.default,Gd.default,Bd.default,Jd.default,Wd.default,Qd.default,Yd.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Xd.default,eh.default];Zl.default=th;var rh={},nh={};Object.defineProperty(nh,"__esModule",{value:!0}),nh.validateAdditionalItems=void 0;const oh=dc(),sh=hc,ah={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>oh.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>oh._`{limit: ${e}}`},code(e){const{parentSchema:t,it:r}=e,{items:n}=t;Array.isArray(n)?ih(e,n):(0,sh.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas')}};function ih(e,t){const{gen:r,schema:n,data:o,keyword:s,it:a}=e;a.items=!0;const i=r.const("len",oh._`${o}.length`);if(!1===n)e.setParams({len:t.length}),e.pass(oh._`${i} <= ${t.length}`);else if("object"==typeof n&&!(0,sh.alwaysValidSchema)(a,n)){const n=r.var("valid",oh._`${i} <= ${t.length}`);r.if((0,oh.not)(n),()=>function(n){r.forRange("i",t.length,i,t=>{e.subschema({keyword:s,dataProp:t,dataPropType:sh.Type.Num},n),a.allErrors||r.if((0,oh.not)(n),()=>r.break())})}(n)),e.ok(n)}}nh.validateAdditionalItems=ih,nh.default=ah;var ch={},uh={};Object.defineProperty(uh,"__esModule",{value:!0}),uh.validateTuple=void 0;const lh=dc(),dh=hc,hh=tu(),ph={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return fh(e,"additionalItems",t);r.items=!0,(0,dh.alwaysValidSchema)(r,t)||e.ok((0,hh.validateArray)(e))}};function fh(e,t,r=e.schema){const{gen:n,parentSchema:o,data:s,keyword:a,it:i}=e;!function(e){const{opts:n,errSchemaPath:o}=i,s=r.length,c=s===e.minItems&&(s===e.maxItems||!1===e[t]);if(n.strictTuples&&!c){const e=`"${a}" is ${s}-tuple, but minItems or maxItems/${t} are not specified or different at path "${o}"`;(0,dh.checkStrictMode)(i,e,n.strictTuples)}}(o),i.opts.unevaluated&&r.length&&!0!==i.items&&(i.items=dh.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),u=n.const("len",lh._`${s}.length`);r.forEach((t,r)=>{(0,dh.alwaysValidSchema)(i,t)||(n.if(lh._`${u} > ${r}`,()=>e.subschema({keyword:a,schemaProp:r,dataProp:r},c)),e.ok(c))})}uh.validateTuple=fh,uh.default=ph,Object.defineProperty(ch,"__esModule",{value:!0});const mh=uh,yh={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,mh.validateTuple)(e,"items")};ch.default=yh;var gh={};Object.defineProperty(gh,"__esModule",{value:!0});const vh=dc(),_h=hc,wh=tu(),$h=nh,bh={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>vh.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>vh._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,(0,_h.alwaysValidSchema)(n,t)||(o?(0,$h.validateAdditionalItems)(e,o):e.ok((0,wh.validateArray)(e)))}};gh.default=bh;var kh={};Object.defineProperty(kh,"__esModule",{value:!0});const Eh=dc(),Ph=hc,Sh={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>void 0===t?Eh.str`must contain at least ${e} valid item(s)`:Eh.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>void 0===t?Eh._`{minContains: ${e}}`:Eh._`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;let a,i;const{minContains:c,maxContains:u}=n;s.opts.next?(a=void 0===c?1:c,i=u):a=1;const l=t.const("len",Eh._`${o}.length`);if(e.setParams({min:a,max:i}),void 0===i&&0===a)return void(0,Ph.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==i&&a>i)return(0,Ph.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),void e.fail();if((0,Ph.alwaysValidSchema)(s,r)){let t=Eh._`${l} >= ${a}`;return void 0!==i&&(t=Eh._`${t} && ${l} <= ${i}`),void e.pass(t)}s.items=!0;const d=t.name("valid");function h(){const e=t.name("_valid"),r=t.let("count",0);p(e,()=>t.if(e,()=>function(e){t.code(Eh._`${e}++`),void 0===i?t.if(Eh._`${e} >= ${a}`,()=>t.assign(d,!0).break()):(t.if(Eh._`${e} > ${i}`,()=>t.assign(d,!1).break()),1===a?t.assign(d,!0):t.if(Eh._`${e} >= ${a}`,()=>t.assign(d,!0)))}(r)))}function p(r,n){t.forRange("i",0,l,t=>{e.subschema({keyword:"contains",dataProp:t,dataPropType:Ph.Type.Num,compositeRule:!0},r),n()})}void 0===i&&1===a?p(d,()=>t.if(d,()=>t.break())):0===a?(t.let(d,!0),void 0!==i&&t.if(Eh._`${o}.length > 0`,h)):(t.let(d,!1),h()),e.result(d,()=>e.reset())}};kh.default=Sh;var Th={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=dc(),r=hc,n=tu();e.error={message:({params:{property:e,depsCount:r,deps:n}})=>{const o=1===r?"property":"properties";return t.str`must have ${o} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:r,deps:n,missingProperty:o}})=>t._`{property: ${e},
4
+ || ${a} === "boolean" || ${o} === null`).assign(i,qc._`[${o}]`)}}n.else(),Bc(e),n.endIf(),n.if(qc._`${i} !== undefined`,()=>{n.assign(o,i),function({gen:e,parentData:t,parentDataProperty:r},n){e.if(qc._`${t} !== undefined`,()=>e.assign(qc._`${t}[${r}]`,n))}(e,i)})}(e,t,s):Bc(e)})}return a};const Hc=new Set(["string","number","integer","boolean","null"]);function Kc(e,t,r,n=Fc.Correct){const o=n===Fc.Correct?qc.operators.EQ:qc.operators.NEQ;let s;switch(e){case"null":return qc._`${t} ${o} null`;case"array":s=qc._`Array.isArray(${t})`;break;case"object":s=qc._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=a(qc._`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=a();break;default:return qc._`typeof ${t} ${o} ${e}`}return n===Fc.Correct?s:(0,qc.not)(s);function a(e=qc.nil){return(0,qc.and)(qc._`typeof ${t} == "number"`,e,r?qc._`isFinite(${t})`:qc.nil)}}function Zc(e,t,r,n){if(1===e.length)return Kc(e[0],t,r,n);let o;const s=(0,Vc.toHash)(e);if(s.array&&s.object){const e=qc._`typeof ${t} != "object"`;o=s.null?e:qc._`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=qc.nil;s.number&&delete s.integer;for(const e in s)o=(0,qc.and)(o,Kc(e,t,r,n));return o}Cc.checkDataType=Kc,Cc.checkDataTypes=Zc;const Gc={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?qc._`{type: ${e}}`:qc._`{type: ${t}}`};function Bc(e){const t=function(e){const{gen:t,data:r,schema:n}=e,o=(0,Vc.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}(e);(0,Dc.reportError)(t,Gc)}Cc.reportTypeError=Bc;var Jc,Wc={};var Qc,Yc,Xc={},el={};function tl(){if(Qc)return el;Qc=1,Object.defineProperty(el,"__esModule",{value:!0}),el.validateUnion=el.validateArray=el.usePattern=el.callValidateCode=el.schemaProperties=el.allSchemaProperties=el.noPropertyInData=el.propertyInData=el.isOwnProperty=el.hasPropFunc=el.reportMissingProp=el.checkMissingProp=el.checkReportMissingProp=void 0;const e=dc(),t=hc,r=xc(),n=hc;function o(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:e._`Object.prototype.hasOwnProperty`})}function s(t,r,n){return e._`${o(t)}.call(${r}, ${n})`}function a(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} === undefined`;return o?(0,e.or)(a,(0,e.not)(s(t,r,n))):a}function i(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}el.checkReportMissingProp=function(t,r){const{gen:n,data:o,it:s}=t;n.if(a(n,o,r,s.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},el.checkMissingProp=function({gen:t,data:r,it:{opts:n}},o,s){return(0,e.or)(...o.map(o=>(0,e.and)(a(t,r,o,n.ownProperties),e._`${s} = ${o}`)))},el.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},el.hasPropFunc=o,el.isOwnProperty=s,el.propertyInData=function(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return o?e._`${a} && ${s(t,r,n)}`:a},el.noPropertyInData=a,el.allSchemaProperties=i,el.schemaProperties=function(e,r){return i(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},el.callValidateCode=function({schemaCode:t,data:n,it:{gen:o,topSchemaRef:s,schemaPath:a,errorPath:i},it:c},l,u,d){const h=d?e._`${t}, ${n}, ${s}${a}`:n,p=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,i)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const f=e._`${h}, ${o.object(...p)}`;return u!==e.nil?e._`${l}.call(${u}, ${f})`:e._`${l}(${f})`};const c=e._`new RegExp`;return el.usePattern=function({gen:t,it:{opts:r}},o){const s=r.unicodeRegExp?"u":"",{regExp:a}=r.code,i=a(o,s);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:e._`${"new RegExp"===a.code?c:(0,n.useFunc)(t,a)}(${o}, ${s})`})},el.validateArray=function(r){const{gen:n,data:o,keyword:s,it:a}=r,i=n.name("valid");if(a.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(i,!0),c(()=>n.break()),i;function c(a){const c=n.const("len",e._`${o}.length`);n.forRange("i",0,c,o=>{r.subschema({keyword:s,dataProp:o,dataPropType:t.Type.Num},i),n.if((0,e.not)(i),a)})}},el.validateUnion=function(r){const{gen:n,schema:o,keyword:s,it:a}=r;if(!Array.isArray(o))throw new Error("ajv implementation error");if(o.some(e=>(0,t.alwaysValidSchema)(a,e))&&!a.opts.unevaluated)return;const i=n.let("valid",!1),c=n.name("_valid");n.block(()=>o.forEach((t,o)=>{const a=r.subschema({keyword:s,schemaProp:o,compositeRule:!0},c);n.assign(i,e._`${i} || ${c}`);r.mergeValidEvaluated(a,c)||n.if((0,e.not)(i))})),r.result(i,()=>r.reset(),()=>r.error(!0))},el}function rl(){if(Yc)return Xc;Yc=1,Object.defineProperty(Xc,"__esModule",{value:!0}),Xc.validateKeywordUsage=Xc.validSchemaType=Xc.funcKeywordCode=Xc.macroKeywordCode=void 0;const e=dc(),t=xc(),r=tl(),n=Nc();function o(t){const{gen:r,data:n,it:o}=t;r.if(o.parentData,()=>r.assign(n,e._`${o.parentData}[${o.parentDataProperty}]`))}function s(t,r,n){if(void 0===n)throw new Error(`keyword "${r}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,e.stringify)(n)})}return Xc.macroKeywordCode=function(t,r){const{gen:n,keyword:o,schema:a,parentSchema:i,it:c}=t,l=r.macro.call(c.self,a,i,c),u=s(n,o,l);!1!==c.opts.validateSchema&&c.self.validateSchema(l,!0);const d=n.name("valid");t.subschema({schema:l,schemaPath:e.nil,errSchemaPath:`${c.errSchemaPath}/${o}`,topSchemaRef:u,compositeRule:!0},d),t.pass(d,()=>t.error(!0))},Xc.funcKeywordCode=function(a,i){var c;const{gen:l,keyword:u,schema:d,parentSchema:h,$data:p,it:f}=a;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(f,i);const m=!p&&i.compile?i.compile.call(f.self,d,h,f):i.validate,y=s(l,u,m),g=l.let("valid");function v(n=(i.async?e._`await `:e.nil)){const o=f.opts.passContext?t.default.this:t.default.self,s=!("compile"in i&&!p||!1===i.schema);l.assign(g,e._`${n}${(0,r.callValidateCode)(a,y,o,s)}`,i.modifying)}function _(t){var r;l.if((0,e.not)(null!==(r=i.valid)&&void 0!==r?r:g),t)}a.block$data(g,function(){if(!1===i.errors)v(),i.modifying&&o(a),_(()=>a.error());else{const r=i.async?function(){const t=l.let("ruleErrs",null);return l.try(()=>v(e._`await `),r=>l.assign(g,!1).if(e._`${r} instanceof ${f.ValidationError}`,()=>l.assign(t,e._`${r}.errors`),()=>l.throw(r))),t}():function(){const t=e._`${y}.errors`;return l.assign(t,null),v(e.nil),t}();i.modifying&&o(a),_(()=>function(r,o){const{gen:s}=r;s.if(e._`Array.isArray(${o})`,()=>{s.assign(t.default.vErrors,e._`${t.default.vErrors} === null ? ${o} : ${t.default.vErrors}.concat(${o})`).assign(t.default.errors,e._`${t.default.vErrors}.length`),(0,n.extendErrors)(r)},()=>r.error())}(a,r))}}),a.ok(null!==(c=i.valid)&&void 0!==c?c:g)},Xc.validSchemaType=function(e,t,r=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||r&&void 0===e)},Xc.validateKeywordUsage=function({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");const a=o.dependencies;if(null==a?void 0:a.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${s}: ${a.join(",")}`);if(o.validateSchema){if(!o.validateSchema(e[s])){const e=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);r.logger.error(e)}}},Xc}var nl,ol={};var sl={},al=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!==o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(s=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;0!==o--;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r},il={exports:{}},cl=il.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),ll(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function ll(e,t,r,n,o,s,a,i,c,l){if(n&&"object"==typeof n&&!Array.isArray(n)){for(var u in t(n,o,s,a,i,c,l),n){var d=n[u];if(Array.isArray(d)){if(u in cl.arrayKeywords)for(var h=0;h<d.length;h++)ll(e,t,r,d[h],o+"/"+u+"/"+h,s,o,u,n,h)}else if(u in cl.propsKeywords){if(d&&"object"==typeof d)for(var p in d)ll(e,t,r,d[p],o+"/"+u+"/"+ul(p),s,o,u,n,p)}else(u in cl.keywords||e.allKeys&&!(u in cl.skipKeywords))&&ll(e,t,r,d,o+"/"+u,s,o,u,n)}r(n,o,s,a,i,c,l)}}function ul(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}cl.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},cl.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},cl.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},cl.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};var dl=il.exports;Object.defineProperty(sl,"__esModule",{value:!0}),sl.getSchemaRefs=sl.resolveUrl=sl.normalizeId=sl._getFullPath=sl.getFullPath=sl.inlineRef=void 0;const hl=hc,pl=al,fl=dl,ml=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);sl.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!gl(e):!!t&&vl(e)<=t)};const yl=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function gl(e){for(const t in e){if(yl.has(t))return!0;const r=e[t];if(Array.isArray(r)&&r.some(gl))return!0;if("object"==typeof r&&gl(r))return!0}return!1}function vl(e){let t=0;for(const r in e){if("$ref"===r)return 1/0;if(t++,!ml.has(r)&&("object"==typeof e[r]&&(0,hl.eachItem)(e[r],e=>t+=vl(e)),t===1/0))return 1/0}return t}function _l(e,t="",r){!1!==r&&(t=bl(t));const n=e.parse(t);return wl(e,n)}function wl(e,t){return e.serialize(t).split("#")[0]+"#"}sl.getFullPath=_l,sl._getFullPath=wl;const $l=/#\/?$/;function bl(e){return e?e.replace($l,""):""}sl.normalizeId=bl,sl.resolveUrl=function(e,t,r){return r=bl(r),e.resolve(t,r)};const kl=/^[a-z_][-a-z0-9._]*$/i;var El;function Pl(){if(El)return tc;El=1,Object.defineProperty(tc,"__esModule",{value:!0}),tc.getData=tc.KeywordCxt=tc.validateFunctionCode=void 0;const e=function(){if(Tc)return rc;Tc=1,Object.defineProperty(rc,"__esModule",{value:!0}),rc.boolOrEmptySchema=rc.topBoolOrEmptySchema=void 0;const e=Nc(),t=dc(),r=xc(),n={message:"boolean schema is false"};function o(t,r){const{gen:o,data:s}=t,a={gen:o,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(a,n,void 0,r)}return rc.topBoolOrEmptySchema=function(e){const{gen:n,schema:s,validateName:a}=e;!1===s?o(e,!1):"object"==typeof s&&!0===s.$async?n.return(r.default.data):(n.assign(t._`${a}.errors`,null),n.return(!0))},rc.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),o(e)):r.var(t,!0)},rc}(),t=Cc,r=Ac(),n=Cc,o=function(){if(Jc)return Wc;Jc=1,Object.defineProperty(Wc,"__esModule",{value:!0}),Wc.assignDefaults=void 0;const e=dc(),t=hc;function r(r,n,o){const{gen:s,compositeRule:a,data:i,opts:c}=r;if(void 0===o)return;const l=e._`${i}${(0,e.getProperty)(n)}`;if(a)return void(0,t.checkStrictMode)(r,`default is ignored for: ${l}`);let u=e._`${l} === undefined`;"empty"===c.useDefaults&&(u=e._`${u} || ${l} === null || ${l} === ""`),s.if(u,e._`${l} = ${(0,e.stringify)(o)}`)}return Wc.assignDefaults=function(e,t){const{properties:n,items:o}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(o)&&o.forEach((t,n)=>r(e,n,t.default))},Wc}(),s=rl(),a=function(){if(nl)return ol;nl=1,Object.defineProperty(ol,"__esModule",{value:!0}),ol.extendSubschemaMode=ol.extendSubschemaData=ol.getSubschema=void 0;const e=dc(),t=hc;return ol.getSubschema=function(r,{keyword:n,schemaProp:o,schema:s,schemaPath:a,errSchemaPath:i,topSchemaRef:c}){if(void 0!==n&&void 0!==s)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==n){const s=r.schema[n];return void 0===o?{schema:s,schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}`,errSchemaPath:`${r.errSchemaPath}/${n}`}:{schema:s[o],schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}${(0,e.getProperty)(o)}`,errSchemaPath:`${r.errSchemaPath}/${n}/${(0,t.escapeFragment)(o)}`}}if(void 0!==s){if(void 0===a||void 0===i||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:a,topSchemaRef:c,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')},ol.extendSubschemaData=function(r,n,{dataProp:o,dataPropType:s,data:a,dataTypes:i,propertyName:c}){if(void 0!==a&&void 0!==o)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:l}=n;if(void 0!==o){const{errorPath:a,dataPathArr:i,opts:c}=n;u(l.let("data",e._`${n.data}${(0,e.getProperty)(o)}`,!0)),r.errorPath=e.str`${a}${(0,t.getErrorPath)(o,s,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${o}`,r.dataPathArr=[...i,r.parentDataProperty]}function u(e){r.data=e,r.dataLevel=n.dataLevel+1,r.dataTypes=[],n.definedProperties=new Set,r.parentData=n.data,r.dataNames=[...n.dataNames,e]}void 0!==a&&(u(a instanceof e.Name?a:l.let("data",a,!0)),void 0!==c&&(r.propertyName=c)),i&&(r.dataTypes=i)},ol.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){void 0!==n&&(e.compositeRule=n),void 0!==o&&(e.createErrors=o),void 0!==s&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r},ol}(),i=dc(),c=xc(),l=sl,u=hc,d=Nc();function h({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,i._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(i._`"use strict"; ${p(r,o)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,i._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,i._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,i._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,i._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,i._`""`),e.var(c.default.parentData,i._`undefined`),e.var(c.default.parentDataProperty,i._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`{}`)})}(e,o),e.code(s)}):e.func(t,i._`${c.default.data}, ${function(e){return i._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?i._`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}(o)}`,n.$async,()=>e.code(p(r,o)).code(s))}function p(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?i._`/*# sourceURL=${r} */`:i.nil}function f(t,r){y(t)&&(g(t),m(t))?function(e,t){const{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&_(e);(function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,l.resolveUrl)(e.opts.uriResolver,e.baseId,t))})(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const s=n.const("_errs",c.default.errors);v(e,s),n.var(t,i._`${s} === ${c.default.errors}`)}(t,r):(0,e.boolOrEmptySchema)(t,r)}function m({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function y(e){return"boolean"!=typeof e.schema}function g(e){(0,u.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(e)}function v(e,r){if(e.opts.jtd)return w(e,[],!1,r);const n=(0,t.getSchemaTypes)(e.schema);w(e,n,!(0,t.coerceAndCheckDataType)(e,n),r)}function _({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){const s=r.$comment;if(!0===o.$comment)e.code(i._`${c.default.self}.logger.log(${s})`);else if("function"==typeof o.$comment){const r=i.str`${n}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(i._`${c.default.self}.opts.$comment(${s}, ${r}, ${o}.schema)`)}}function w(e,t,o,s){const{gen:a,schema:l,data:d,allErrors:h,opts:p,self:f}=e,{RULES:m}=f;function y(u){(0,r.shouldUseGroup)(l,u)&&(u.type?(a.if((0,n.checkDataType)(u.type,d,p.strictNumbers)),$(e,u),1===t.length&&t[0]===u.type&&o&&(a.else(),(0,n.reportTypeError)(e)),a.endIf()):$(e,u),h||a.if(i._`${c.default.errors} === ${s||0}`))}!l.$ref||!p.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(l,m)?(p.jtd||function(e,t){if(e.schemaEnv.meta||!e.opts.strictTypes)return;(function(e,t){if(!t.length)return;if(!e.dataTypes.length)return void(e.dataTypes=t);t.forEach(t=>{k(e.dataTypes,t)||E(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const r=[];for(const n of e.dataTypes)k(t,n)?r.push(n):t.includes("integer")&&"number"===n&&r.push("integer");e.dataTypes=r}(e,t)})(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&E(e,"use allowUnionTypes to allow union type keyword")}(e,t);!function(e,t){const n=e.self.RULES.all;for(const o in n){const s=n[o];if("object"==typeof s&&(0,r.shouldUseRule)(e.schema,s)){const{type:r}=s.definition;r.length&&!r.some(e=>b(t,e))&&E(e,`missing type "${r.join(",")}" for keyword "${o}"`)}}}(e,e.dataTypes)}(e,t),a.block(()=>{for(const e of m.rules)y(e);y(m.post)})):a.block(()=>S(e,"$ref",m.all.$ref.definition))}function $(e,t){const{gen:n,schema:s,opts:{useDefaults:a}}=e;a&&(0,o.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(s,n)&&S(e,n.keyword,n.definition,t.type)})}function b(e,t){return e.includes(t)||"number"===t&&e.includes("integer")}function k(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function E(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,u.checkStrictMode)(e,t,e.opts.strictTypes)}tc.validateFunctionCode=function(t){y(t)&&(g(t),m(t))?function(e){const{schema:t,opts:r,gen:n}=e;h(e,()=>{r.$comment&&t.$comment&&_(e),function(e){const{schema:t,opts:r}=e;void 0!==t.default&&r.useDefaults&&r.strictSchema&&(0,u.checkStrictMode)(e,"default is ignored in the schema root")}(e),n.let(c.default.vErrors,null),n.let(c.default.errors,0),r.unevaluated&&function(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",i._`${r}.evaluated`),t.if(i._`${e.evaluated}.dynamicProps`,()=>t.assign(i._`${e.evaluated}.props`,i._`undefined`)),t.if(i._`${e.evaluated}.dynamicItems`,()=>t.assign(i._`${e.evaluated}.items`,i._`undefined`))}(e),v(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if(i._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(i._`new ${o}(${c.default.vErrors})`)):(t.assign(i._`${n}.errors`,c.default.vErrors),s.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof i.Name&&e.assign(i._`${t}.props`,r);n instanceof i.Name&&e.assign(i._`${t}.items`,n)}(e),t.return(i._`${c.default.errors} === 0`))}(e)})}(t):h(t,()=>(0,e.topBoolOrEmptySchema)(t))};class P{constructor(e,t,r){if((0,s.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,u.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",x(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,s.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",c.default.errors))}result(e,t,r){this.failResult((0,i.not)(e),t,r)}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,i.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(i._`${t} !== undefined && (${(0,i.or)(this.invalid$data(),e)})`)}error(e,t,r){if(t)return this.setParams(t),this._error(e,r),void this.setParams({});this._error(e,r)}_error(e,t){(e?d.reportExtraError:d.reportError)(this,this.def.error,t)}$dataError(){(0,d.reportError)(this,this.def.$dataError||d.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,d.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,r=i.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=i.nil,t=i.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:o,def:s}=this;r.if((0,i.or)(i._`${n} === undefined`,t)),e!==i.nil&&r.assign(e,!0),(o.length||s.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==i.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:o,it:s}=this;return(0,i.or)(function(){if(r.length){if(!(t instanceof i.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return i._`${(0,n.checkDataTypes)(e,t,s.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}(),function(){if(o.validateSchema){const r=e.scopeValue("validate$data",{ref:o.validateSchema});return i._`!${r}(${t})`}return i.nil}())}subschema(e,t){const r=(0,a.getSubschema)(this.it,e);(0,a.extendSubschemaData)(r,this.it,e),(0,a.extendSubschemaMode)(r,e);const n={...this.it,...r,items:void 0,props:void 0};return f(n,t),n}mergeEvaluated(e,t){const{it:r,gen:n}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==e.props&&(r.props=u.mergeEvaluated.props(n,e.props,r.props,t)),!0!==r.items&&void 0!==e.items&&(r.items=u.mergeEvaluated.items(n,e.items,r.items,t)))}mergeValidEvaluated(e,t){const{it:r,gen:n}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return n.if(t,()=>this.mergeEvaluated(e,i.Name)),!0}}function S(e,t,r,n){const o=new P(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,s.funcKeywordCode)(o,r):"macro"in r?(0,s.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,s.funcKeywordCode)(o,r)}tc.KeywordCxt=P;const T=/^\/(?:[^~]|~0|~1)*$/,I=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(""===e)return c.default.rootData;if("/"===e[0]){if(!T.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=c.default.rootData}else{const a=I.exec(e);if(!a)throw new Error(`Invalid JSON-pointer: ${e}`);const i=+a[1];if(o=a[2],"#"===o){if(i>=t)throw new Error(d("property/index",i));return n[t-i]}if(i>t)throw new Error(d("data",i));if(s=r[t-i],!o)return s}let a=s;const l=o.split("/");for(const e of l)e&&(s=i._`${s}${(0,i.getProperty)((0,u.unescapeJsonPointer)(e))}`,a=i._`${a} && ${s}`);return a;function d(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return tc.getData=x,tc}sl.getSchemaRefs=function(e,t){if("boolean"==typeof e)return{};const{schemaId:r,uriResolver:n}=this.opts,o=bl(e[r]||t),s={"":o},a=_l(n,o,!1),i={},c=new Set;return fl(e,{allKeys:!0},(e,t,n,o)=>{if(void 0===o)return;const d=a+t;let h=s[o];function p(t){const r=this.opts.uriResolver.resolve;if(t=bl(h?r(h,t):t),c.has(t))throw u(t);c.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?l(e,n.schema,t):t!==bl(d)&&("#"===t[0]?(l(e,i[t],t),i[t]=e):this.refs[t]=d),t}function f(e){if("string"==typeof e){if(!kl.test(e))throw new Error(`invalid anchor "${e}"`);p.call(this,`#${e}`)}}"string"==typeof e[r]&&(h=p.call(this,e[r])),f.call(this,e.$anchor),f.call(this,e.$dynamicAnchor),s[t]=h}),i;function l(e,t,r){if(void 0!==t&&!pl(e,t))throw u(r)}function u(e){return new Error(`reference "${e}" resolves to more than one schema`)}};var Sl,Tl={};function Il(){if(Sl)return Tl;Sl=1,Object.defineProperty(Tl,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return Tl.default=e,Tl}var xl,Nl={};function Cl(){if(xl)return Nl;xl=1,Object.defineProperty(Nl,"__esModule",{value:!0});const e=sl;class t extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,e.resolveUrl)(t,r,n),this.missingSchema=(0,e.normalizeId)((0,e.getFullPath)(t,this.missingRef))}}return Nl.default=t,Nl}var jl={};Object.defineProperty(jl,"__esModule",{value:!0}),jl.resolveSchema=jl.getCompilingSchema=jl.resolveRef=jl.compileSchema=jl.SchemaEnv=void 0;const Rl=dc(),Ol=Il(),zl=xc(),Al=sl,Ml=hc,Ul=Pl();let Dl=class{constructor(e){var t;let r;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,Al.normalizeId)(null==r?void 0:r[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==r?void 0:r.$async,this.refs={}}};function ql(e){const t=Fl.call(this,e);if(t)return t;const r=(0,Al.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,a=new Rl.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s});let i;e.$async&&(i=a.scopeValue("Error",{ref:Ol.default,code:Rl._`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:zl.default.data,parentData:zl.default.parentData,parentDataProperty:zl.default.parentDataProperty,dataNames:[zl.default.data],dataPathArr:[Rl.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,Rl.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Rl.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:Rl._`""`,opts:this.opts,self:this};let u;try{this._compilations.add(e),(0,Ul.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const t=a.toString();u=`${a.scopeRefs(zl.default.scope)}return ${t}`,this.opts.code.process&&(u=this.opts.code.process(u,e));const r=new Function(`${zl.default.self}`,`${zl.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:r}),r.errors=null,r.schema=e.schema,r.schemaEnv=e,e.$async&&(r.$async=!0),!0===this.opts.code.source&&(r.source={validateName:c,validateCode:t,scopeValues:a._values}),this.opts.unevaluated){const{props:e,items:t}=l;r.evaluated={props:e instanceof Rl.Name?void 0:e,items:t instanceof Rl.Name?void 0:t,dynamicProps:e instanceof Rl.Name,dynamicItems:t instanceof Rl.Name},r.source&&(r.source.evaluated=(0,Rl.stringify)(r.evaluated))}return e.validate=r,e}catch(t){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),t}finally{this._compilations.delete(e)}}function Vl(e){return(0,Al.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ql.call(this,e)}function Fl(e){for(const t of this._compilations)if(Ll(t,e))return t}function Ll(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Hl(e,t){let r;for(;"string"==typeof(r=this.refs[t]);)t=r;return r||this.schemas[t]||Kl.call(this,e,t)}function Kl(e,t){const r=this.opts.uriResolver.parse(t),n=(0,Al._getFullPath)(this.opts.uriResolver,r);let o=(0,Al.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Gl.call(this,r,e);const s=(0,Al.normalizeId)(n),a=this.refs[s]||this.schemas[s];if("string"==typeof a){const t=Kl.call(this,e,a);if("object"!=typeof(null==t?void 0:t.schema))return;return Gl.call(this,r,t)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||ql.call(this,a),s===(0,Al.normalizeId)(t)){const{schema:t}=a,{schemaId:r}=this.opts,n=t[r];return n&&(o=(0,Al.resolveUrl)(this.opts.uriResolver,o,n)),new Dl({schema:t,schemaId:r,root:e,baseId:o})}return Gl.call(this,r,a)}}jl.SchemaEnv=Dl,jl.compileSchema=ql,jl.resolveRef=function(e,t,r){var n;r=(0,Al.resolveUrl)(this.opts.uriResolver,t,r);const o=e.refs[r];if(o)return o;let s=Hl.call(this,e,r);if(void 0===s){const o=null===(n=e.localRefs)||void 0===n?void 0:n[r],{schemaId:a}=this.opts;o&&(s=new Dl({schema:o,schemaId:a,root:e,baseId:t}))}return void 0!==s?e.refs[r]=Vl.call(this,s):void 0},jl.getCompilingSchema=Fl,jl.resolveSchema=Kl;const Zl=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Gl(e,{baseId:t,schema:r,root:n}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const n of e.fragment.slice(1).split("/")){if("boolean"==typeof r)return;const e=r[(0,Ml.unescapeFragment)(n)];if(void 0===e)return;const o="object"==typeof(r=e)&&r[this.opts.schemaId];!Zl.has(n)&&o&&(t=(0,Al.resolveUrl)(this.opts.uriResolver,t,o))}let s;if("boolean"!=typeof r&&r.$ref&&!(0,Ml.schemaHasRulesButRef)(r,this.RULES)){const e=(0,Al.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Kl.call(this,n,e)}const{schemaId:a}=this.opts;return s=s||new Dl({schema:r,schemaId:a,root:n,baseId:t}),s.schema!==s.root.schema?s:void 0}var Bl={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},Jl={},Wl={exports:{}};const Ql=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Yl=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),Xl=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),eu=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),tu=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function ru(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),48!==r){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}const nu=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ou(e){return e.length=0,!0}function su(e,t,r){if(e.length){const n=ru(e);if(""===n)return r.error=!0,!1;t.push(n),e.length=0}return!0}function au(e){if(function(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}(e,":")<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const r={error:!1,address:"",zone:""},n=[],o=[];let s=!1,a=!1,i=su;for(let c=0;c<e.length;c++){const l=e[c];if("["!==l&&"]"!==l)if(":"!==l)if("%"===l){if(!i(o,n,r))break;i=ou}else o.push(l);else{if(!0===s&&(a=!0),!i(o,n,r))break;if(++t>7){r.error=!0;break}c>0&&":"===e[c-1]&&(s=!0),n.push(":")}}return o.length&&(i===ou?r.zone=o.join(""):a?n.push(o.join("")):n.push(ru(o))),r.address=n.join(""),r}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,r=t.address;return t.zone&&(e+="%"+t.zone,r+="%25"+t.zone),{host:e,isIPV6:!0,escapedHost:r}}}const iu={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},cu=/[@/?#:]/g,lu=/[@/?#]/g;function uu(e,t){const r=t?lu:cu;return r.lastIndex=0,e.replace(r,e=>iu[e])}var du={nonSimpleDomain:nu,recomposeAuthority:function(e){const t=[];if(void 0!==e.userinfo&&(t.push(e.userinfo),t.push("@")),void 0!==e.host){let r=unescape(e.host);if(!Yl(r)){const e=au(r);r=!0===e.isIPV6?`[${e.escapedHost}]`:uu(r,!1)}t.push(r)}return"number"!=typeof e.port&&"string"!=typeof e.port||(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0},reescapeHostDelimiters:uu,normalizePercentEncoding:function(e,t=!1){if(-1===e.indexOf("%"))return e;let r="";for(let n=0;n<e.length;n++){if("%"===e[n]&&n+2<e.length){const o=e.slice(n+1,n+3);if(Xl(o)){const e=o.toUpperCase(),s=String.fromCharCode(parseInt(e,16));t&&eu(s)?r+=s:r+="%"+e,n+=2;continue}}r+=e[n]}return r},normalizePathEncoding:function(e){let t="";for(let r=0;r<e.length;r++){if("%"===e[r]&&r+2<e.length){const n=e.slice(r+1,r+3);if(Xl(n)){const e=n.toUpperCase(),o=String.fromCharCode(parseInt(e,16));"."!==o&&eu(o)?t+=o:t+="%"+e,r+=2;continue}}tu(e[r])?t+=e[r]:t+=escape(e[r])}return t},escapePreservingEscapes:function(e){let t="";for(let r=0;r<e.length;r++){if("%"===e[r]&&r+2<e.length){const n=e.slice(r+1,r+3);if(Xl(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t},removeDotSegments:function(e){let t=e;const r=[];let n=-1,o=0;for(;o=t.length;){if(1===o){if("."===t)break;if("/"===t){r.push("/");break}r.push(t);break}if(2===o){if("."===t[0]){if("."===t[1])break;if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&("."===t[1]||"/"===t[1])){r.push("/");break}}else if(3===o&&"/.."===t){0!==r.length&&r.pop(),r.push("/");break}if("."===t[0]){if("."===t[1]){if("/"===t[2]){t=t.slice(3);continue}}else if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&"."===t[1]){if("/"===t[2]){t=t.slice(2);continue}if("."===t[2]&&"/"===t[3]){t=t.slice(3),0!==r.length&&r.pop();continue}}if(-1===(n=t.indexOf("/",1))){r.push(t);break}r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")},isIPv4:Yl,isUUID:Ql,normalizeIPv6:au,stringArrayToHexStripped:ru};const{isUUID:hu}=du,pu=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,fu=["http","https","ws","wss","urn","urn:uuid"];function mu(e){return!0===e.secure||!1!==e.secure&&(!!e.scheme&&!(3!==e.scheme.length||"w"!==e.scheme[0]&&"W"!==e.scheme[0]||"s"!==e.scheme[1]&&"S"!==e.scheme[1]||"s"!==e.scheme[2]&&"S"!==e.scheme[2]))}function yu(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function gu(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const vu={scheme:"http",domainHost:!0,parse:yu,serialize:gu},_u={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=mu(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(mu(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,r]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}},wu={http:vu,https:{scheme:"https",domainHost:vu.domainHost,parse:yu,serialize:gu},ws:_u,wss:{scheme:"wss",domainHost:_u.domainHost,parse:_u.parse,serialize:_u.serialize},urn:{scheme:"urn",parse:function(e,t){if(!e.path)return e.error="URN can not be parsed",e;const r=e.path.match(pu);if(r){const n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];const o=$u(`${n}:${t.nid||e.nid}`);e.path=void 0,o&&(e=o.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){if(void 0===e.nid)throw new Error("URN without nid cannot be serialized");const r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=$u(`${r}:${t.nid||n}`);o&&(e=o.serialize(e,t));const s=e,a=e.nss;return s.path=`${n||t.nid}:${a}`,t.skipEscape=!0,s},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(e,t){const r=e;return r.uuid=r.nss,r.nss=void 0,t.tolerant||r.uuid&&hu(r.uuid)||(r.error=r.error||"UUID is not valid."),r},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};function $u(e){return e&&(wu[e]||wu[e.toLowerCase()])||void 0}Object.setPrototypeOf(wu,null);var bu={wsIsSecure:mu,SCHEMES:wu,isValidSchemeName:function(e){return-1!==fu.indexOf(e)},getSchemeHandler:$u};const{normalizeIPv6:ku,removeDotSegments:Eu,recomposeAuthority:Pu,normalizePercentEncoding:Su,normalizePathEncoding:Tu,escapePreservingEscapes:Iu,reescapeHostDelimiters:xu,isIPv4:Nu,nonSimpleDomain:Cu}=du,{SCHEMES:ju,getSchemeHandler:Ru}=bu;function Ou(e,t,r,n){const o={};return n||(e=qu(zu(e,r),r),t=qu(zu(t,r),r)),!(r=r||{}).tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=Eu(t.path||""),o.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=Eu(t.path||""),o.query=t.query):(t.path?("/"===t.path[0]?o.path=Eu(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path:o.path="/"+t.path,o.path=Eu(o.path)),o.query=t.query):(o.path=e.path,void 0!==t.query?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function zu(e,t){const r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[],s=Ru(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),void 0!==r.path&&(n.skipEscape?r.path=Su(r.path):(r.path=Iu(r.path),void 0!==r.scheme&&(r.path=r.path.split("%3A").join(":")))),"suffix"!==n.reference&&r.scheme&&o.push(r.scheme,":");const a=Pu(r);if(void 0!==a&&("suffix"!==n.reference&&o.push("//"),o.push(a),r.path&&"/"!==r.path[0]&&o.push("/")),void 0!==r.path){let e=r.path;n.absolutePath||s&&s.absolutePath||(e=Eu(e)),void 0===a&&"/"===e[0]&&"/"===e[1]&&(e="/%2F"+e.slice(2)),o.push(e)}return void 0!==r.query&&o.push("?",r.query),void 0!==r.fragment&&o.push("#",r.fragment),o.join("")}const Au=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,Mu=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,Uu=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function Du(e,t){const r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let o=!1,s=!1;"suffix"===r.reference&&(e=r.scheme?r.scheme+":"+e:"//"+e);const a=e.match(Mu);null!==a&&-1!==a[1].indexOf("\\")&&(n.error="URI authority must not contain a literal backslash.",o=!0);const i=e.match(Uu);if(null!==i){const e=i[1],t=e.replace(/[\t\n\r]/g,"");t.length>=2&&("//"!==t.slice(0,2)?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):e.length!==t.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}const c=e.match(Au);if(c){n.scheme=c[1],n.userinfo=c[3],n.host=c[4],n.port=parseInt(c[5],10),n.path=c[6]||"",n.query=c[7],n.fragment=c[8],isNaN(n.port)&&(n.port=c[5]);const t=function(e,t){return void 0!==t[2]&&e.path&&"/"!==e.path[0]?'URI path must start with "/" when authority is present.':"number"==typeof e.port&&(e.port<0||e.port>65535)?"URI port is malformed.":void 0}(n,c);if(void 0!==t&&(n.error=n.error||t,o=!0),n.host){if(!1===Nu(n.host)){const e=ku(n.host);n.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0}void 0!==n.scheme||void 0!==n.userinfo||void 0!==n.host||void 0!==n.port||void 0!==n.query||n.path?void 0===n.scheme?n.reference="relative":void 0===n.fragment?n.reference="absolute":n.reference="uri":n.reference="same-document",r.reference&&"suffix"!==r.reference&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");const a=Ru(r.scheme||n.scheme);if(!(r.unicodeSupport||a&&a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&!1===s&&Cu(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(e){n.error=n.error||"Host's domain name can not be converted to ASCII: "+e}if((!a||a&&!a.skipNormalize)&&(-1!==e.indexOf("%")&&(void 0!==n.scheme&&(n.scheme=unescape(n.scheme)),void 0!==n.host&&(n.host=xu(unescape(n.host),s))),n.path&&(n.path=Tu(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}a&&a.parse&&a.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function qu(e,t){return Du(e,t).parsed}function Vu(e,t){const{parsed:r,malformedAuthorityOrPort:n}=Du(e,t);return{normalized:n?e:zu(r,t),malformedAuthorityOrPort:n}}function Fu(e,t){if("string"==typeof e){const{normalized:r,malformedAuthorityOrPort:n}=Vu(e,t);return n?void 0:r}if("object"==typeof e)return zu(e,t)}const Lu={SCHEMES:ju,normalize:function(e,t){return"string"==typeof e?e=function(e,t){return Vu(e,t).normalized}(e,t):"object"==typeof e&&(e=qu(zu(e,t),t)),e},resolve:function(e,t,r){const n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s}=Du(e,n),{parsed:a,malformedAuthorityOrPort:i}=Du(t,n);if(s||i)throw new Error(o.error||a.error||"URI is malformed.");const c=Ou(o,a,n,!0);return n.skipEscape=!0,zu(c,n)},resolveComponent:Ou,equal:function(e,t,r){const n=Fu(e,r),o=Fu(t,r);return void 0!==n&&void 0!==o&&n.toLowerCase()===o.toLowerCase()},serialize:zu,parse:qu};Wl.exports=Lu,Wl.exports.default=Lu,Wl.exports.fastUri=Lu;var Hu=Wl.exports;Object.defineProperty(Jl,"__esModule",{value:!0});const Ku=Hu;Ku.code='require("ajv/dist/runtime/uri").default',Jl.default=Ku,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Pl();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=dc();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Il(),o=Cl(),s=jc,a=jl,i=dc(),c=sl,l=Cc,u=hc,d=Bl,h=Jl,p=(e,t)=>new RegExp(e,t);p.code="new RegExp";const f=["removeAdditional","useDefaults","coerceTypes"],m=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),y={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},g={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function v(e){var t,r,n,o,s,a,i,c,l,u,d,f,m,y,g,v,_,w,$,b,k,E,P,S,T;const I=e.strict,x=null===(t=e.code)||void 0===t?void 0:t.optimize,N=!0===x||void 0===x?1:x||0,C=null!==(n=null===(r=e.code)||void 0===r?void 0:r.regExp)&&void 0!==n?n:p,j=null!==(o=e.uriResolver)&&void 0!==o?o:h.default;return{strictSchema:null===(a=null!==(s=e.strictSchema)&&void 0!==s?s:I)||void 0===a||a,strictNumbers:null===(c=null!==(i=e.strictNumbers)&&void 0!==i?i:I)||void 0===c||c,strictTypes:null!==(u=null!==(l=e.strictTypes)&&void 0!==l?l:I)&&void 0!==u?u:"log",strictTuples:null!==(f=null!==(d=e.strictTuples)&&void 0!==d?d:I)&&void 0!==f?f:"log",strictRequired:null!==(y=null!==(m=e.strictRequired)&&void 0!==m?m:I)&&void 0!==y&&y,code:e.code?{...e.code,optimize:N,regExp:C}:{optimize:N,regExp:C},loopRequired:null!==(g=e.loopRequired)&&void 0!==g?g:200,loopEnum:null!==(v=e.loopEnum)&&void 0!==v?v:200,meta:null===(_=e.meta)||void 0===_||_,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===($=e.inlineRefs)||void 0===$||$,schemaId:null!==(b=e.schemaId)&&void 0!==b?b:"$id",addUsedSchema:null===(k=e.addUsedSchema)||void 0===k||k,validateSchema:null===(E=e.validateSchema)||void 0===E||E,validateFormats:null===(P=e.validateFormats)||void 0===P||P,unicodeRegExp:null===(S=e.unicodeRegExp)||void 0===S||S,int32range:null===(T=e.int32range)||void 0===T||T,uriResolver:j}}class _{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};const{es5:t,lines:r}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:m,es5:t,lines:r}),this.logger=function(e){if(!1===e)return S;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,s.getRules)(),w.call(this,y,e,"NOT SUPPORTED"),w.call(this,g,e,"DEPRECATED","warn"),this._metaOpts=P.call(this),e.formats&&k.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),b.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:r}=this.opts;let n=d;"id"===r&&(n={...d},n.id=n.$id,delete n.$id),t&&e&&this.addMetaSchema(n,n[r],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let r;if("string"==typeof e){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);const n=r(t);return"$async"in r||(this.errors=r.errors),n}compile(e,t){const r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return n.call(this,e,t);async function n(e,t){await s.call(this,e.$schema);const r=this._addSchema(e,t);return r.validate||a.call(this,r)}async function s(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function a(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof o.default))throw t;return i.call(this,t),await c.call(this,t.missingSchema),a.call(this,e)}}function i({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){const r=await l.call(this,e);this.refs[e]||await s.call(this,r.$schema),this.refs[e]||this.addSchema(r,e,t)}async function l(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=r(e))}finally{delete this._loading[e]}}}addSchema(e,t,r,n=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,r,n);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,n,!0),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,!0,r),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let r;if(r=e.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const n=this.validate(r,e);if(!n&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return n}getSchema(e){let t;for(;"string"==typeof(t=$.call(this,e));)e=t;if(void 0===t){const{schemaId:r}=this.opts,n=new a.SchemaEnv({schema:{},schemaId:r});if(t=a.resolveSchema.call(this,n,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=$.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0,c.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if("string"==typeof e)r=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(r=(t=e).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(I.call(this,r,t),!t)return(0,u.eachItem)(r,e=>x.call(this,e)),this;C.call(this,t);const n={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(r,0===n.type.length?e=>x.call(this,e,n):e=>n.type.forEach(t=>x.call(this,e,n,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const r of t.rules){const t=r.rules.findIndex(t=>t.keyword===e);t>=0&&r.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return e&&0!==e.length?e.map(e=>`${r}${e.instancePath} ${e.message}`).reduce((e,r)=>e+t+r):"No errors"}$dataMetaSchema(e,t){const r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const n of t){const t=n.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in r){const t=r[e];if("object"!=typeof t)continue;const{$data:n}=t.definition,s=o[e];n&&s&&(o[e]=R(s))}}return e}_removeAllSchemas(e,t){for(const r in e){const n=e[r];t&&!t.test(r)||("string"==typeof n?delete e[r]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[r]))}}_addSchema(e,t,r,n=this.opts.validateSchema,o=this.opts.addUsedSchema){let s;const{schemaId:i}=this.opts;if("object"==typeof e)s=e[i];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let l=this._cache.get(e);if(void 0!==l)return l;r=(0,c.normalizeId)(s||r);const u=c.getSchemaRefs.call(this,e,r);return l=new a.SchemaEnv({schema:e,schemaId:i,meta:t,baseId:r,localRefs:u}),this._cache.set(l.schema,l),o&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=l),n&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):a.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,e)}finally{this.opts=t}}}function w(e,t,r,n="error"){for(const o in e){const s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function $(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function b(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function k(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}}function P(){const e={...this.opts};for(const t of f)delete e[t];return e}_.ValidationError=n.default,_.MissingRefError=o.default,e.default=_;const S={log(){},warn(){},error(){}};const T=/^[a-z_$][a-z0-9_$:-]*$/i;function I(e,t){const{RULES:r}=this;if((0,u.eachItem)(e,e=>{if(r.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!T.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function x(e,t,r){var n;const o=null==t?void 0:t.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:s}=this;let a=o?s.post:s.rules.find(({type:e})=>e===r);if(a||(a={type:r,rules:[]},s.rules.push(a)),s.keywords[e]=!0,!t)return;const i={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?N.call(this,a,i,t.before):a.rules.push(i),s.all[e]=i,null===(n=t.implements)||void 0===n||n.forEach(e=>this.addKeyword(e))}function N(e,t,r){const n=e.rules.findIndex(e=>e.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function C(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=R(t)),e.validateSchema=this.compile(t,!0))}const j={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function R(e){return{anyOf:[e,j]}}}(ec);var Zu={},Gu={},Bu={};Object.defineProperty(Bu,"__esModule",{value:!0});const Ju={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Bu.default=Ju;var Wu={};Object.defineProperty(Wu,"__esModule",{value:!0}),Wu.callRef=Wu.getValidate=void 0;const Qu=Cl(),Yu=tl(),Xu=dc(),ed=xc(),td=jl,rd=hc,nd={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:a,opts:i,self:c}=n,{root:l}=s;if(("#"===r||"#/"===r)&&o===l.baseId)return function(){if(s===l)return sd(e,a,s,s.$async);const r=t.scopeValue("root",{ref:l});return sd(e,Xu._`${r}.validate`,l,l.$async)}();const u=td.resolveRef.call(c,l,o,r);if(void 0===u)throw new Qu.default(n.opts.uriResolver,o,r);return u instanceof td.SchemaEnv?function(t){const r=od(e,t);sd(e,r,t,t.$async)}(u):function(n){const o=t.scopeValue("schema",!0===i.code.source?{ref:n,code:(0,Xu.stringify)(n)}:{ref:n}),s=t.name("valid"),a=e.subschema({schema:n,dataTypes:[],schemaPath:Xu.nil,topSchemaRef:o,errSchemaPath:r},s);e.mergeEvaluated(a),e.ok(s)}(u)}};function od(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):Xu._`${r.scopeValue("wrapper",{ref:t})}.validate`}function sd(e,t,r,n){const{gen:o,it:s}=e,{allErrors:a,schemaEnv:i,opts:c}=s,l=c.passContext?ed.default.this:Xu.nil;function u(e){const t=Xu._`${e}.errors`;o.assign(ed.default.vErrors,Xu._`${ed.default.vErrors} === null ? ${t} : ${ed.default.vErrors}.concat(${t})`),o.assign(ed.default.errors,Xu._`${ed.default.vErrors}.length`)}function d(e){var t;if(!s.opts.unevaluated)return;const n=null===(t=null==r?void 0:r.validate)||void 0===t?void 0:t.evaluated;if(!0!==s.props)if(n&&!n.dynamicProps)void 0!==n.props&&(s.props=rd.mergeEvaluated.props(o,n.props,s.props));else{const t=o.var("props",Xu._`${e}.evaluated.props`);s.props=rd.mergeEvaluated.props(o,t,s.props,Xu.Name)}if(!0!==s.items)if(n&&!n.dynamicItems)void 0!==n.items&&(s.items=rd.mergeEvaluated.items(o,n.items,s.items));else{const t=o.var("items",Xu._`${e}.evaluated.items`);s.items=rd.mergeEvaluated.items(o,t,s.items,Xu.Name)}}n?function(){if(!i.$async)throw new Error("async schema referenced by sync schema");const r=o.let("valid");o.try(()=>{o.code(Xu._`await ${(0,Yu.callValidateCode)(e,t,l)}`),d(t),a||o.assign(r,!0)},e=>{o.if(Xu._`!(${e} instanceof ${s.ValidationError})`,()=>o.throw(e)),u(e),a||o.assign(r,!1)}),e.ok(r)}():e.result((0,Yu.callValidateCode)(e,t,l),()=>d(t),()=>u(t))}Wu.getValidate=od,Wu.callRef=sd,Wu.default=nd,Object.defineProperty(Gu,"__esModule",{value:!0});const ad=Wu,id=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Bu.default,ad.default];Gu.default=id;var cd={},ld={};Object.defineProperty(ld,"__esModule",{value:!0});const ud=dc(),dd=ud.operators,hd={maximum:{okStr:"<=",ok:dd.LTE,fail:dd.GT},minimum:{okStr:">=",ok:dd.GTE,fail:dd.LT},exclusiveMaximum:{okStr:"<",ok:dd.LT,fail:dd.GTE},exclusiveMinimum:{okStr:">",ok:dd.GT,fail:dd.LTE}},pd={message:({keyword:e,schemaCode:t})=>ud.str`must be ${hd[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>ud._`{comparison: ${hd[e].okStr}, limit: ${t}}`},fd={keyword:Object.keys(hd),type:"number",schemaType:"number",$data:!0,error:pd,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data(ud._`${r} ${hd[t].fail} ${n} || isNaN(${r})`)}};ld.default=fd;var md={};Object.defineProperty(md,"__esModule",{value:!0});const yd=dc(),gd={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>yd.str`must be multiple of ${e}`,params:({schemaCode:e})=>yd._`{multipleOf: ${e}}`},code(e){const{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,a=t.let("res"),i=s?yd._`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:yd._`${a} !== parseInt(${a})`;e.fail$data(yd._`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};md.default=gd;var vd={},_d={};function wd(e){const t=e.length;let r,n=0,o=0;for(;o<t;)n++,r=e.charCodeAt(o++),r>=55296&&r<=56319&&o<t&&(r=e.charCodeAt(o),56320==(64512&r)&&o++);return n}Object.defineProperty(_d,"__esModule",{value:!0}),_d.default=wd,wd.code='require("ajv/dist/runtime/ucs2length").default',Object.defineProperty(vd,"__esModule",{value:!0});const $d=dc(),bd=hc,kd=_d,Ed={message({keyword:e,schemaCode:t}){const r="maxLength"===e?"more":"fewer";return $d.str`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>$d._`{limit: ${e}}`},Pd={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Ed,code(e){const{keyword:t,data:r,schemaCode:n,it:o}=e,s="maxLength"===t?$d.operators.GT:$d.operators.LT,a=!1===o.opts.unicode?$d._`${r}.length`:$d._`${(0,bd.useFunc)(e.gen,kd.default)}(${r})`;e.fail$data($d._`${a} ${s} ${n}`)}};vd.default=Pd;var Sd={};Object.defineProperty(Sd,"__esModule",{value:!0});const Td=tl(),Id=hc,xd=dc(),Nd={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>xd.str`must match pattern "${e}"`,params:({schemaCode:e})=>xd._`{pattern: ${e}}`},code(e){const{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:n}=a.opts.code,o="new RegExp"===n.code?xd._`new RegExp`:(0,Id.useFunc)(t,n),c=t.let("valid");t.try(()=>t.assign(c,xd._`${o}(${s}, ${i}).test(${r})`),()=>t.assign(c,!1)),e.fail$data(xd._`!${c}`)}else{const t=(0,Td.usePattern)(e,o);e.fail$data(xd._`!${t}.test(${r})`)}}};Sd.default=Nd;var Cd={};Object.defineProperty(Cd,"__esModule",{value:!0});const jd=dc(),Rd={message({keyword:e,schemaCode:t}){const r="maxProperties"===e?"more":"fewer";return jd.str`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>jd._`{limit: ${e}}`},Od={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Rd,code(e){const{keyword:t,data:r,schemaCode:n}=e,o="maxProperties"===t?jd.operators.GT:jd.operators.LT;e.fail$data(jd._`Object.keys(${r}).length ${o} ${n}`)}};Cd.default=Od;var zd={};Object.defineProperty(zd,"__esModule",{value:!0});const Ad=tl(),Md=dc(),Ud=hc,Dd={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>Md.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>Md._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:a}=e,{opts:i}=a;if(!s&&0===r.length)return;const c=r.length>=i.loopRequired;if(a.allErrors?function(){if(c||s)e.block$data(Md.nil,l);else for(const t of r)(0,Ad.checkReportMissingProp)(e,t)}():function(){const a=t.let("missing");if(c||s){const r=t.let("valid",!0);e.block$data(r,()=>function(r,s){e.setParams({missingProperty:r}),t.forOf(r,n,()=>{t.assign(s,(0,Ad.propertyInData)(t,o,r,i.ownProperties)),t.if((0,Md.not)(s),()=>{e.error(),t.break()})},Md.nil)}(a,r)),e.ok(r)}else t.if((0,Ad.checkMissingProp)(e,r,a)),(0,Ad.reportMissingProp)(e,a),t.else()}(),i.strictRequired){const t=e.parentSchema.properties,{definedProperties:n}=e.it;for(const e of r)if(void 0===(null==t?void 0:t[e])&&!n.has(e)){const t=`required property "${e}" is not defined at "${a.schemaEnv.baseId+a.errSchemaPath}" (strictRequired)`;(0,Ud.checkStrictMode)(a,t,a.opts.strictRequired)}}function l(){t.forOf("prop",n,r=>{e.setParams({missingProperty:r}),t.if((0,Ad.noPropertyInData)(t,o,r,i.ownProperties),()=>e.error())})}}};zd.default=Dd;var qd={};Object.defineProperty(qd,"__esModule",{value:!0});const Vd=dc(),Fd={message({keyword:e,schemaCode:t}){const r="maxItems"===e?"more":"fewer";return Vd.str`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>Vd._`{limit: ${e}}`},Ld={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Fd,code(e){const{keyword:t,data:r,schemaCode:n}=e,o="maxItems"===t?Vd.operators.GT:Vd.operators.LT;e.fail$data(Vd._`${r}.length ${o} ${n}`)}};qd.default=Ld;var Hd={},Kd={};Object.defineProperty(Kd,"__esModule",{value:!0});const Zd=al;Zd.code='require("ajv/dist/runtime/equal").default',Kd.default=Zd,Object.defineProperty(Hd,"__esModule",{value:!0});const Gd=Cc,Bd=dc(),Jd=hc,Wd=Kd,Qd={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>Bd.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>Bd._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:a,it:i}=e;if(!n&&!o)return;const c=t.let("valid"),l=s.items?(0,Gd.getSchemaTypes)(s.items):[];function u(n,o){const s=t.name("item"),a=(0,Gd.checkDataTypes)(l,s,i.opts.strictNumbers,Gd.DataType.Wrong),u=t.const("indices",Bd._`{}`);t.for(Bd._`;${n}--;`,()=>{t.let(s,Bd._`${r}[${n}]`),t.if(a,Bd._`continue`),l.length>1&&t.if(Bd._`typeof ${s} == "string"`,Bd._`${s} += "_"`),t.if(Bd._`typeof ${u}[${s}] == "number"`,()=>{t.assign(o,Bd._`${u}[${s}]`),e.error(),t.assign(c,!1).break()}).code(Bd._`${u}[${s}] = ${n}`)})}function d(n,o){const s=(0,Jd.useFunc)(t,Wd.default),a=t.name("outer");t.label(a).for(Bd._`;${n}--;`,()=>t.for(Bd._`${o} = ${n}; ${o}--;`,()=>t.if(Bd._`${s}(${r}[${n}], ${r}[${o}])`,()=>{e.error(),t.assign(c,!1).break(a)})))}e.block$data(c,function(){const n=t.let("i",Bd._`${r}.length`),o=t.let("j");e.setParams({i:n,j:o}),t.assign(c,!0),t.if(Bd._`${n} > 1`,()=>(l.length>0&&!l.some(e=>"object"===e||"array"===e)?u:d)(n,o))},Bd._`${a} === false`),e.ok(c)}};Hd.default=Qd;var Yd={};Object.defineProperty(Yd,"__esModule",{value:!0});const Xd=dc(),eh=hc,th=Kd,rh={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>Xd._`{allowedValue: ${e}}`},code(e){const{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&"object"==typeof s?e.fail$data(Xd._`!${(0,eh.useFunc)(t,th.default)}(${r}, ${o})`):e.fail(Xd._`${s} !== ${r}`)}};Yd.default=rh;var nh={};Object.defineProperty(nh,"__esModule",{value:!0});const oh=dc(),sh=hc,ah=Kd,ih={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>oh._`{allowedValues: ${e}}`},code(e){const{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e;if(!n&&0===o.length)throw new Error("enum must have non-empty array");const i=o.length>=a.opts.loopEnum;let c;const l=()=>null!=c?c:c=(0,sh.useFunc)(t,ah.default);let u;if(i||n)u=t.let("valid"),e.block$data(u,function(){t.assign(u,!1),t.forOf("v",s,e=>t.if(oh._`${l()}(${r}, ${e})`,()=>t.assign(u,!0).break()))});else{if(!Array.isArray(o))throw new Error("ajv implementation error");const e=t.const("vSchema",s);u=(0,oh.or)(...o.map((t,n)=>function(e,t){const n=o[t];return"object"==typeof n&&null!==n?oh._`${l()}(${r}, ${e}[${t}])`:oh._`${r} === ${n}`}(e,n)))}e.pass(u)}};nh.default=ih,Object.defineProperty(cd,"__esModule",{value:!0});const ch=md,lh=vd,uh=Sd,dh=Cd,hh=zd,ph=qd,fh=Hd,mh=Yd,yh=nh,gh=[ld.default,ch.default,lh.default,uh.default,dh.default,hh.default,ph.default,fh.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},mh.default,yh.default];cd.default=gh;var vh={},_h={};Object.defineProperty(_h,"__esModule",{value:!0}),_h.validateAdditionalItems=void 0;const wh=dc(),$h=hc,bh={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>wh.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>wh._`{limit: ${e}}`},code(e){const{parentSchema:t,it:r}=e,{items:n}=t;Array.isArray(n)?kh(e,n):(0,$h.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas')}};function kh(e,t){const{gen:r,schema:n,data:o,keyword:s,it:a}=e;a.items=!0;const i=r.const("len",wh._`${o}.length`);if(!1===n)e.setParams({len:t.length}),e.pass(wh._`${i} <= ${t.length}`);else if("object"==typeof n&&!(0,$h.alwaysValidSchema)(a,n)){const n=r.var("valid",wh._`${i} <= ${t.length}`);r.if((0,wh.not)(n),()=>function(n){r.forRange("i",t.length,i,t=>{e.subschema({keyword:s,dataProp:t,dataPropType:$h.Type.Num},n),a.allErrors||r.if((0,wh.not)(n),()=>r.break())})}(n)),e.ok(n)}}_h.validateAdditionalItems=kh,_h.default=bh;var Eh={},Ph={};Object.defineProperty(Ph,"__esModule",{value:!0}),Ph.validateTuple=void 0;const Sh=dc(),Th=hc,Ih=tl(),xh={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Nh(e,"additionalItems",t);r.items=!0,(0,Th.alwaysValidSchema)(r,t)||e.ok((0,Ih.validateArray)(e))}};function Nh(e,t,r=e.schema){const{gen:n,parentSchema:o,data:s,keyword:a,it:i}=e;!function(e){const{opts:n,errSchemaPath:o}=i,s=r.length,c=s===e.minItems&&(s===e.maxItems||!1===e[t]);if(n.strictTuples&&!c){const e=`"${a}" is ${s}-tuple, but minItems or maxItems/${t} are not specified or different at path "${o}"`;(0,Th.checkStrictMode)(i,e,n.strictTuples)}}(o),i.opts.unevaluated&&r.length&&!0!==i.items&&(i.items=Th.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",Sh._`${s}.length`);r.forEach((t,r)=>{(0,Th.alwaysValidSchema)(i,t)||(n.if(Sh._`${l} > ${r}`,()=>e.subschema({keyword:a,schemaProp:r,dataProp:r},c)),e.ok(c))})}Ph.validateTuple=Nh,Ph.default=xh,Object.defineProperty(Eh,"__esModule",{value:!0});const Ch=Ph,jh={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Ch.validateTuple)(e,"items")};Eh.default=jh;var Rh={};Object.defineProperty(Rh,"__esModule",{value:!0});const Oh=dc(),zh=hc,Ah=tl(),Mh=_h,Uh={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>Oh.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>Oh._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,(0,zh.alwaysValidSchema)(n,t)||(o?(0,Mh.validateAdditionalItems)(e,o):e.ok((0,Ah.validateArray)(e)))}};Rh.default=Uh;var Dh={};Object.defineProperty(Dh,"__esModule",{value:!0});const qh=dc(),Vh=hc,Fh={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>void 0===t?qh.str`must contain at least ${e} valid item(s)`:qh.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>void 0===t?qh._`{minContains: ${e}}`:qh._`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;let a,i;const{minContains:c,maxContains:l}=n;s.opts.next?(a=void 0===c?1:c,i=l):a=1;const u=t.const("len",qh._`${o}.length`);if(e.setParams({min:a,max:i}),void 0===i&&0===a)return void(0,Vh.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==i&&a>i)return(0,Vh.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),void e.fail();if((0,Vh.alwaysValidSchema)(s,r)){let t=qh._`${u} >= ${a}`;return void 0!==i&&(t=qh._`${t} && ${u} <= ${i}`),void e.pass(t)}s.items=!0;const d=t.name("valid");function h(){const e=t.name("_valid"),r=t.let("count",0);p(e,()=>t.if(e,()=>function(e){t.code(qh._`${e}++`),void 0===i?t.if(qh._`${e} >= ${a}`,()=>t.assign(d,!0).break()):(t.if(qh._`${e} > ${i}`,()=>t.assign(d,!1).break()),1===a?t.assign(d,!0):t.if(qh._`${e} >= ${a}`,()=>t.assign(d,!0)))}(r)))}function p(r,n){t.forRange("i",0,u,t=>{e.subschema({keyword:"contains",dataProp:t,dataPropType:Vh.Type.Num,compositeRule:!0},r),n()})}void 0===i&&1===a?p(d,()=>t.if(d,()=>t.break())):0===a?(t.let(d,!0),void 0!==i&&t.if(qh._`${o}.length > 0`,h)):(t.let(d,!1),h()),e.result(d,()=>e.reset())}};Dh.default=Fh;var Lh={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=dc(),r=hc,n=tl();e.error={message:({params:{property:e,depsCount:r,deps:n}})=>{const o=1===r?"property":"properties";return t.str`must have ${o} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:r,deps:n,missingProperty:o}})=>t._`{property: ${e},
5
5
  missingProperty: ${o},
6
6
  depsCount: ${r},
7
- deps: ${n}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(e){const[t,r]=function({schema:e}){const t={},r={};for(const n in e){if("__proto__"===n)continue;(Array.isArray(e[n])?t:r)[n]=e[n]}return[t,r]}(e);s(e,t),a(e,r)}};function s(e,r=e.schema){const{gen:o,data:s,it:a}=e;if(0===Object.keys(r).length)return;const i=o.let("missing");for(const c in r){const u=r[c];if(0===u.length)continue;const l=(0,n.propertyInData)(o,s,c,a.opts.ownProperties);e.setParams({property:c,depsCount:u.length,deps:u.join(", ")}),a.allErrors?o.if(l,()=>{for(const t of u)(0,n.checkReportMissingProp)(e,t)}):(o.if(t._`${l} && (${(0,n.checkMissingProp)(e,u,i)})`),(0,n.reportMissingProp)(e,i),o.else())}}function a(e,t=e.schema){const{gen:o,data:s,keyword:a,it:i}=e,c=o.name("valid");for(const u in t)(0,r.alwaysValidSchema)(i,t[u])||(o.if((0,n.propertyInData)(o,s,u,i.opts.ownProperties),()=>{const t=e.subschema({keyword:a,schemaProp:u},c);e.mergeValidEvaluated(t,c)},()=>o.var(c,!0)),e.ok(c))}e.validatePropertyDeps=s,e.validateSchemaDeps=a,e.default=o}(Th);var Ih={};Object.defineProperty(Ih,"__esModule",{value:!0});const xh=dc(),Nh=hc,Ch={message:"property name must be valid",params:({params:e})=>xh._`{propertyName: ${e.propertyName}}`},jh={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Ch,code(e){const{gen:t,schema:r,data:n,it:o}=e;if((0,Nh.alwaysValidSchema)(o,r))return;const s=t.name("valid");t.forIn("key",n,r=>{e.setParams({propertyName:r}),e.subschema({keyword:"propertyNames",data:r,dataTypes:["string"],propertyName:r,compositeRule:!0},s),t.if((0,xh.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Ih.default=jh;var Rh={};Object.defineProperty(Rh,"__esModule",{value:!0});const Oh=tu(),zh=dc(),Ah=xc(),Mh=hc,Dh={message:"must NOT have additional properties",params:({params:e})=>zh._`{additionalProperty: ${e.additionalProperty}}`},Uh={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Dh,code(e){const{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:a}=e;if(!s)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,"all"!==c.removeAdditional&&(0,Mh.alwaysValidSchema)(a,r))return;const u=(0,Oh.allSchemaProperties)(n.properties),l=(0,Oh.allSchemaProperties)(n.patternProperties);function d(e){t.code(zh._`delete ${o}[${e}]`)}function h(n){if("all"===c.removeAdditional||c.removeAdditional&&!1===r)d(n);else{if(!1===r)return e.setParams({additionalProperty:n}),e.error(),void(i||t.break());if("object"==typeof r&&!(0,Mh.alwaysValidSchema)(a,r)){const r=t.name("valid");"failing"===c.removeAdditional?(p(n,r,!1),t.if((0,zh.not)(r),()=>{e.reset(),d(n)})):(p(n,r),i||t.if((0,zh.not)(r),()=>t.break()))}}}function p(t,r,n){const o={keyword:"additionalProperties",dataProp:t,dataPropType:Mh.Type.Str};!1===n&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(o,r)}t.forIn("key",o,r=>{u.length||l.length?t.if(function(r){let o;if(u.length>8){const e=(0,Mh.schemaRefOrVal)(a,n.properties,"properties");o=(0,Oh.isOwnProperty)(t,e,r)}else o=u.length?(0,zh.or)(...u.map(e=>zh._`${r} === ${e}`)):zh.nil;return l.length&&(o=(0,zh.or)(o,...l.map(t=>zh._`${(0,Oh.usePattern)(e,t)}.test(${r})`))),(0,zh.not)(o)}(r),()=>h(r)):h(r)}),e.ok(zh._`${s} === ${Ah.default.errors}`)}};Rh.default=Uh;var qh={};Object.defineProperty(qh,"__esModule",{value:!0});const Vh=Pu(),Fh=tu(),Lh=hc,Kh=Rh,Hh={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;"all"===s.opts.removeAdditional&&void 0===n.additionalProperties&&Kh.default.code(new Vh.KeywordCxt(s,Kh.default,"additionalProperties"));const a=(0,Fh.allSchemaProperties)(r);for(const e of a)s.definedProperties.add(e);s.opts.unevaluated&&a.length&&!0!==s.props&&(s.props=Lh.mergeEvaluated.props(t,(0,Lh.toHash)(a),s.props));const i=a.filter(e=>!(0,Lh.alwaysValidSchema)(s,r[e]));if(0===i.length)return;const c=t.name("valid");for(const r of i)u(r)?l(r):(t.if((0,Fh.propertyInData)(t,o,r,s.opts.ownProperties)),l(r),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(r),e.ok(c);function u(e){return s.opts.useDefaults&&!s.compositeRule&&void 0!==r[e].default}function l(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},c)}}};qh.default=Hh;var Zh={};Object.defineProperty(Zh,"__esModule",{value:!0});const Gh=tu(),Bh=dc(),Jh=hc,Wh=hc,Qh={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:a}=s,i=(0,Gh.allSchemaProperties)(r),c=i.filter(e=>(0,Jh.alwaysValidSchema)(s,r[e]));if(0===i.length||c.length===i.length&&(!s.opts.unevaluated||!0===s.props))return;const u=a.strictSchema&&!a.allowMatchingProperties&&o.properties,l=t.name("valid");!0===s.props||s.props instanceof Bh.Name||(s.props=(0,Wh.evaluatedPropsToName)(t,s.props));const{props:d}=s;function h(e){for(const t in u)new RegExp(e).test(t)&&(0,Jh.checkStrictMode)(s,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function p(r){t.forIn("key",n,n=>{t.if(Bh._`${(0,Gh.usePattern)(e,r)}.test(${n})`,()=>{const o=c.includes(r);o||e.subschema({keyword:"patternProperties",schemaProp:r,dataProp:n,dataPropType:Wh.Type.Str},l),s.opts.unevaluated&&!0!==d?t.assign(Bh._`${d}[${n}]`,!0):o||s.allErrors||t.if((0,Bh.not)(l),()=>t.break())})})}!function(){for(const e of i)u&&h(e),s.allErrors?p(e):(t.var(l,!0),p(e),t.if(l))}()}};Zh.default=Qh;var Yh={};Object.defineProperty(Yh,"__esModule",{value:!0});const Xh=hc,ep={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,Xh.alwaysValidSchema)(n,r))return void e.fail();const o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Yh.default=ep;var tp={};Object.defineProperty(tp,"__esModule",{value:!0});const rp={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:tu().validateUnion,error:{message:"must match a schema in anyOf"}};tp.default=rp;var np={};Object.defineProperty(np,"__esModule",{value:!0});const op=dc(),sp=hc,ap={message:"must match exactly one schema in oneOf",params:({params:e})=>op._`{passingSchemas: ${e.passing}}`},ip={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:ap,code(e){const{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;const s=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(function(){s.forEach((r,n)=>{let s;(0,sp.alwaysValidSchema)(o,r)?t.var(c,!0):s=e.subschema({keyword:"oneOf",schemaProp:n,compositeRule:!0},c),n>0&&t.if(op._`${c} && ${a}`).assign(a,!1).assign(i,op._`[${i}, ${n}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,n),s&&e.mergeEvaluated(s,op.Name)})})}),e.result(a,()=>e.reset(),()=>e.error(!0))}};np.default=ip;var cp={};Object.defineProperty(cp,"__esModule",{value:!0});const up=hc,lp={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const o=t.name("valid");r.forEach((t,r)=>{if((0,up.alwaysValidSchema)(n,t))return;const s=e.subschema({keyword:"allOf",schemaProp:r},o);e.ok(o),e.mergeEvaluated(s)})}};cp.default=lp;var dp={};Object.defineProperty(dp,"__esModule",{value:!0});const hp=dc(),pp=hc,fp={message:({params:e})=>hp.str`must match "${e.ifClause}" schema`,params:({params:e})=>hp._`{failingKeyword: ${e.ifClause}}`},mp={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:fp,code(e){const{gen:t,parentSchema:r,it:n}=e;void 0===r.then&&void 0===r.else&&(0,pp.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const o=yp(n,"then"),s=yp(n,"else");if(!o&&!s)return;const a=t.let("valid",!0),i=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(t)}(),e.reset(),o&&s){const r=t.let("ifClause");e.setParams({ifClause:r}),t.if(i,c("then",r),c("else",r))}else o?t.if(i,c("then")):t.if((0,hp.not)(i),c("else"));function c(r,n){return()=>{const o=e.subschema({keyword:r},i);t.assign(a,i),e.mergeValidEvaluated(o,a),n?t.assign(n,hp._`${r}`):e.setParams({ifClause:r})}}e.pass(a,()=>e.error(!0))}};function yp(e,t){const r=e.schema[t];return void 0!==r&&!(0,pp.alwaysValidSchema)(e,r)}dp.default=mp;var gp={};Object.defineProperty(gp,"__esModule",{value:!0});const vp=hc,_p={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){void 0===t.if&&(0,vp.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};gp.default=_p,Object.defineProperty(rh,"__esModule",{value:!0});const wp=nh,$p=ch,bp=uh,kp=gh,Ep=kh,Pp=Th,Sp=Ih,Tp=Rh,Ip=qh,xp=Zh,Np=Yh,Cp=tp,jp=np,Rp=cp,Op=dp,zp=gp;rh.default=function(e=!1){const t=[Np.default,Cp.default,jp.default,Rp.default,Op.default,zp.default,Sp.default,Tp.default,Pp.default,Ip.default,xp.default];return e?t.push($p.default,kp.default):t.push(wp.default,bp.default),t.push(Ep.default),t};var Ap={},Mp={};Object.defineProperty(Mp,"__esModule",{value:!0});const Dp=dc(),Up={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>Dp.str`must match format "${e}"`,params:({schemaCode:e})=>Dp._`{format: ${e}}`},code(e,t){const{gen:r,data:n,$data:o,schema:s,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=i;c.validateFormats&&(o?function(){const o=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),s=r.const("fDef",Dp._`${o}[${a}]`),i=r.let("fType"),u=r.let("format");r.if(Dp._`typeof ${s} == "object" && !(${s} instanceof RegExp)`,()=>r.assign(i,Dp._`${s}.type || "string"`).assign(u,Dp._`${s}.validate`),()=>r.assign(i,Dp._`"string"`).assign(u,s)),e.fail$data((0,Dp.or)(!1===c.strictSchema?Dp.nil:Dp._`${a} && !${u}`,function(){const e=l.$async?Dp._`(${s}.async ? await ${u}(${n}) : ${u}(${n}))`:Dp._`${u}(${n})`,r=Dp._`(typeof ${u} == "function" ? ${e} : ${u}.test(${n}))`;return Dp._`${u} && ${u} !== true && ${i} === ${t} && !${r}`}()))}():function(){const o=d.formats[s];if(!o)return void function(){if(!1===c.strictSchema)return void d.logger.warn(e());throw new Error(e());function e(){return`unknown format "${s}" ignored in schema at path "${u}"`}}();if(!0===o)return;const[a,i,h]=function(e){const t=e instanceof RegExp?(0,Dp.regexpCode)(e):c.code.formats?Dp._`${c.code.formats}${(0,Dp.getProperty)(s)}`:void 0,n=r.scopeValue("formats",{key:s,ref:e,code:t});if("object"==typeof e&&!(e instanceof RegExp))return[e.type||"string",e.validate,Dp._`${n}.validate`];return["string",e,n]}(o);a===t&&e.pass(function(){if("object"==typeof o&&!(o instanceof RegExp)&&o.async){if(!l.$async)throw new Error("async format in sync schema");return Dp._`await ${h}(${n})`}return"function"==typeof i?Dp._`${h}(${n})`:Dp._`${h}.test(${n})`}())}())}};Mp.default=Up,Object.defineProperty(Ap,"__esModule",{value:!0});const qp=[Mp.default];Ap.default=qp;var Vp={};Object.defineProperty(Vp,"__esModule",{value:!0}),Vp.contentVocabulary=Vp.metadataVocabulary=void 0,Vp.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Vp.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"],Object.defineProperty(Nl,"__esModule",{value:!0});const Fp=Zl,Lp=rh,Kp=Ap,Hp=Vp,Zp=[Cl.default,Fp.default,(0,Lp.default)(),Kp.default,Hp.metadataVocabulary,Hp.contentVocabulary];Nl.default=Zp;var Gp,Bp={},Jp={};Object.defineProperty(Jp,"__esModule",{value:!0}),Jp.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(Gp||(Jp.DiscrError=Gp={})),Object.defineProperty(Bp,"__esModule",{value:!0});const Wp=dc(),Qp=Jp,Yp=ju,Xp=Cu(),ef=hc,tf={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===Qp.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>Wp._`{error: ${e}, tag: ${r}, tagValue: ${t}}`},code(e){const{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:a}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if("string"!=typeof i)throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),u=t.const("tag",Wp._`${r}${(0,Wp.getProperty)(i)}`);function l(r){const n=t.name("valid"),o=e.subschema({keyword:"oneOf",schemaProp:r},n);return e.mergeEvaluated(o,Wp.Name),n}t.if(Wp._`typeof ${u} == "string"`,()=>function(){const r=function(){var e;const t={},r=c(o);let n=!0;for(let t=0;t<a.length;t++){let o=a[t];if((null==o?void 0:o.$ref)&&!(0,ef.schemaHasRulesButRef)(o,s.self.RULES)){const e=o.$ref;if(o=Yp.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,e),o instanceof Yp.SchemaEnv&&(o=o.schema),void 0===o)throw new Xp.default(s.opts.uriResolver,s.baseId,e)}const l=null===(e=null==o?void 0:o.properties)||void 0===e?void 0:e[i];if("object"!=typeof l)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);n=n&&(r||c(o)),u(l,t)}if(!n)throw new Error(`discriminator: "${i}" must be required`);return t;function c({required:e}){return Array.isArray(e)&&e.includes(i)}function u(e,t){if(e.const)l(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`);for(const r of e.enum)l(r,t)}}function l(e,r){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${i}" values must be unique strings`);t[e]=r}}();t.if(!1);for(const e in r)t.elseIf(Wp._`${u} === ${e}`),t.assign(c,l(r[e]));t.else(),e.error(!1,{discrError:Qp.DiscrError.Mapping,tag:u,tagName:i}),t.endIf()}(),()=>e.error(!1,{discrError:Qp.DiscrError.Tag,tag:u,tagName:i})),e.ok(c)}};Bp.default=tf;var rf={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const r=ec,n=Nl,o=Bp,s=rf,a=["/properties"],i="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(o.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(e,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var u=Pu();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var l=dc();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var d=Iu();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var h=Cu();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return h.default}})}(Xi,Xi.exports);var nf=Qi(Xi.exports),of={exports:{}},sf={};!function(e){function t(e,t){return{validate:e,compare:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0,e.fullFormats={date:t(o,s),time:t(i(!0),c),"date-time":t(d(!0),h),"iso-time":t(i(),u),"iso-date-time":t(d(),p),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(e){return f.test(e)&&m.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:function(e){if(w.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}},uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:function(e){return y.lastIndex=0,y.test(e)},int32:{type:"number",validate:function(e){return Number.isInteger(e)&&e<=v&&e>=g}},int64:{type:"number",validate:function(e){return Number.isInteger(e)}},float:{type:"number",validate:_},double:{type:"number",validate:_},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,s),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,h),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,p),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);const r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(e){const t=r.exec(e);if(!t)return!1;const o=+t[1],s=+t[2],a=+t[3];return s>=1&&s<=12&&a>=1&&a<=(2===s&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(o)?29:n[s])}function s(e,t){if(e&&t)return e>t?1:e<t?-1:0}const a=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function i(e){return function(t){const r=a.exec(t);if(!r)return!1;const n=+r[1],o=+r[2],s=+r[3],i=r[4],c="-"===r[5]?-1:1,u=+(r[6]||0),l=+(r[7]||0);if(u>23||l>59||e&&!i)return!1;if(n<=23&&o<=59&&s<60)return!0;const d=o-l*c,h=n-u*c-(d<0?1:0);return(23===h||-1===h)&&(59===d||-1===d)&&s<61}}function c(e,t){if(!e||!t)return;const r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();return r&&n?r-n:void 0}function u(e,t){if(!e||!t)return;const r=a.exec(e),n=a.exec(t);return r&&n?(e=r[1]+r[2]+r[3])>(t=n[1]+n[2]+n[3])?1:e<t?-1:0:void 0}const l=/t|\s/i;function d(e){const t=i(e);return function(e){const r=e.split(l);return 2===r.length&&o(r[0])&&t(r[1])}}function h(e,t){if(!e||!t)return;const r=new Date(e).valueOf(),n=new Date(t).valueOf();return r&&n?r-n:void 0}function p(e,t){if(!e||!t)return;const[r,n]=e.split(l),[o,a]=t.split(l),i=s(r,o);return void 0!==i?i||c(n,a):void 0}const f=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;const y=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;const g=-(2**31),v=2**31-1;function _(){return!0}const w=/[^\\]\\Z/}(sf);var af={},cf={exports:{}},uf={},lf={},df={},hf={},pf={},ff={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function o(e,...t){const r=[e[0]];let o=0;for(;o<t.length;)i(r,t[o]),r.push(e[++o]);return new n(r)}e._Code=n,e.nil=new n(""),e._=o;const s=new n("+");function a(e,...t){const r=[u(e[0])];let o=0;for(;o<t.length;)r.push(s),i(r,t[o]),r.push(s,u(e[++o]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===s){const r=c(e[t-1],e[t+1]);if(void 0!==r){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}(r),new n(r)}function i(e,t){var o;t instanceof n?e.push(...t._items):t instanceof r?e.push(t):e.push("number"==typeof(o=t)||"boolean"==typeof o||null===o?o:u(Array.isArray(o)?o.join(","):o))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof r||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof r?void 0:`"${e}${t.slice(1)}`}function u(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=a,e.addCodeArg=i,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:a`${e}${t}`},e.stringify=function(e){return new n(u(e))},e.safeStringify=u,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):o`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(e){return new n(e.toString())}}(ff);var mf={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=ff;class r extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var n;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class o{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,r;if((null===(r=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===r?void 0:r.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}e.Scope=o;class s extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=t._`.${new t.Name(r)}[${n}]`}}e.ValueScopeName=s;const a=t._`\n`;e.ValueScope=class extends o{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?a:t.nil}}get(){return this._scope}name(e){return new s(e,this._newName(e))}value(e,t){var r;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const n=this.toName(e),{prefix:o}=n,s=null!==(r=t.key)&&void 0!==r?r:t.ref;let a=this._values[o];if(a){const e=a.get(s);if(e)return e}else a=this._values[o]=new Map;a.set(s,n);const i=this._scope[o]||(this._scope[o]=[]),c=i.length;return i[c]=t.ref,n.setValue(t,{property:o,itemIndex:c}),n}getValue(e,t){const r=this._values[e];if(r)return r.get(t)}scopeRefs(e,r=this._values){return this._reduceValues(r,r=>{if(void 0===r.scopePath)throw new Error(`CodeGen: name "${r}" has no value`);return t._`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,r)}_reduceValues(o,s,a={},i){let c=t.nil;for(const u in o){const l=o[u];if(!l)continue;const d=a[u]=a[u]||new Map;l.forEach(o=>{if(d.has(o))return;d.set(o,n.Started);let a=s(o);if(a){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${o} = ${a};${this.opts._n}`}else{if(!(a=null==i?void 0:i(o)))throw new r(o);c=t._`${c}${a}${this.opts._n}`}d.set(o,n.Completed)})}return c}}}(mf),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=ff,r=mf;var n=ff;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var o=mf;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class s{optimizeNodes(){return this}optimizeNames(e,t){return this}}class a extends s{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r}render({es5:e,_n:t}){const n=e?r.varKinds.var:this.varKind,o=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=x(this.rhs,e,t)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends s{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof t.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=x(this.rhs,e,r),this}get names(){return I(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}}class c extends i{constructor(e,t,r,n){super(e,r,n),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class u extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class l extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class d extends s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class h extends s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=x(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class p extends s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:r}=this;let n=r.length;for(;n--;){const o=r[n];o.optimizeNames(e,t)||(N(e,o.names),r.splice(n,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>T(e,t.names),{})}}class f extends p{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends p{}class y extends f{}y.kind="else";class g extends f{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new y(e):e}return t?!1===e?t instanceof g?t:t.nodes:this.nodes.length?this:new g(C(e),t instanceof g?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=x(this.condition,e,t),this}get names(){const e=super.names;return I(e,this.condition),this.else&&T(e,this.else.names),e}}g.kind="if";class v extends f{}v.kind="for";class _ extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=x(this.iteration,e,t),this}get names(){return T(super.names,this.iteration.names)}}class w extends v{constructor(e,t,r,n){super(),this.varKind=e,this.name=t,this.from=r,this.to=n}render(e){const t=e.es5?r.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${t} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){const e=I(super.names,this.from);return I(e,this.to)}}class $ extends v{constructor(e,t,r,n){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=x(this.iterable,e,t),this}get names(){return T(super.names,this.iterable.names)}}class b extends f{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}b.kind="func";class k extends p{render(e){return"return "+super.render(e)}}k.kind="return";class E extends f{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var r,n;return super.optimizeNames(e,t),null===(r=this.catch)||void 0===r||r.optimizeNames(e,t),null===(n=this.finally)||void 0===n||n.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&T(e,this.catch.names),this.finally&&T(e,this.finally.names),e}}class P extends f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}P.kind="catch";class S extends f{render(e){return"finally"+super.render(e)}}S.kind="finally";function T(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function I(e,r){return r instanceof t._CodeOrName?T(e,r.names):e}function x(e,r,n){return e instanceof t.Name?s(e):(o=e)instanceof t._Code&&o._items.some(e=>e instanceof t.Name&&1===r[e.str]&&void 0!==n[e.str])?new t._Code(e._items.reduce((e,r)=>(r instanceof t.Name&&(r=s(r)),r instanceof t._Code?e.push(...r._items):e.push(r),e),[])):e;var o;function s(e){const t=n[e.str];return void 0===t||1!==r[e.str]?e:(delete r[e.str],t)}}function N(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function C(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:t._`!${z(e)}`}e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new r.Scope({parent:e}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const r=this._extScope.value(e,t);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,n){const o=this._scope.toName(t);return void 0!==r&&n&&(this._constants[o.str]=r),this._leafNode(new a(e,o,r)),o}const(e,t,n){return this._def(r.varKinds.const,e,t,n)}let(e,t,n){return this._def(r.varKinds.let,e,t,n)}var(e,t,n){return this._def(r.varKinds.var,e,t,n)}assign(e,t,r){return this._leafNode(new i(e,t,r))}add(t,r){return this._leafNode(new c(t,e.operators.ADD,r))}code(e){return"function"==typeof e?e():e!==t.nil&&this._leafNode(new h(e)),this}object(...e){const r=["{"];for(const[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,t.addCodeArg)(r,o));return r.push("}"),new t._Code(r)}if(e,t,r){if(this._blockNode(new g(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new g(e))}else(){return this._elseNode(new y)}endIf(){return this._endBlockNode(g,y)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new _(e),t)}forRange(e,t,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.let)){const a=this._scope.toName(e);return this._for(new w(s,a,t,n),()=>o(a))}forOf(e,n,o,s=r.varKinds.const){const a=this._scope.toName(e);if(this.opts.es5){const e=n instanceof t.Name?n:this.var("_arr",n);return this.forRange("_i",0,t._`${e}.length`,r=>{this.var(a,t._`${e}[${r}]`),o(a)})}return this._for(new $("of",s,a,n),()=>o(a))}forIn(e,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,t._`Object.keys(${n})`,o);const a=this._scope.toName(e);return this._for(new $("in",s,a,n),()=>o(a))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new u(e))}break(e){return this._leafNode(new l(e))}return(e){const t=new k;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(k)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new E;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new P(e),t(e)}return r&&(this._currNode=n.finally=new S,this.code(r)),this._endBlockNode(P,S)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-t;if(r<0||void 0!==e&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,r=t.nil,n,o){return this._blockNode(new b(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(b)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},e.not=C;const j=O(e.operators.AND);e.and=function(...e){return e.reduce(j)};const R=O(e.operators.OR);function O(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${z(r)} ${e} ${z(n)}`}function z(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(R)}}(pf);var yf={};Object.defineProperty(yf,"__esModule",{value:!0}),yf.checkStrictMode=yf.getErrorPath=yf.Type=yf.useFunc=yf.setEvaluated=yf.evaluatedPropsToName=yf.mergeEvaluated=yf.eachItem=yf.unescapeJsonPointer=yf.escapeJsonPointer=yf.escapeFragment=yf.unescapeFragment=yf.schemaRefOrVal=yf.schemaHasRulesButRef=yf.schemaHasRules=yf.checkUnknownRules=yf.alwaysValidSchema=yf.toHash=void 0;const gf=pf,vf=ff;function _f(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema)return;if("boolean"==typeof t)return;const o=n.RULES.keywords;for(const r in t)o[r]||If(e,`unknown keyword: "${r}"`)}function wf(e,t){if("boolean"==typeof e)return!e;for(const r in e)if(t[r])return!0;return!1}function $f(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function bf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function kf({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,a,i)=>{const c=void 0===a?s:a instanceof gf.Name?(s instanceof gf.Name?e(o,s,a):t(o,s,a),a):s instanceof gf.Name?(t(o,a,s),s):r(s,a);return i!==gf.Name||c instanceof gf.Name?c:n(o,c)}}function Ef(e,t){if(!0===t)return e.var("props",!0);const r=e.var("props",gf._`{}`);return void 0!==t&&Pf(e,r,t),r}function Pf(e,t,r){Object.keys(r).forEach(r=>e.assign(gf._`${t}${(0,gf.getProperty)(r)}`,!0))}yf.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},yf.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(_f(e,t),!wf(t,e.self.RULES.all))},yf.checkUnknownRules=_f,yf.schemaHasRules=wf,yf.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const r in e)if("$ref"!==r&&t.all[r])return!0;return!1},yf.schemaRefOrVal=function({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if("number"==typeof r||"boolean"==typeof r)return r;if("string"==typeof r)return gf._`${r}`}return gf._`${e}${t}${(0,gf.getProperty)(n)}`},yf.unescapeFragment=function(e){return bf(decodeURIComponent(e))},yf.escapeFragment=function(e){return encodeURIComponent($f(e))},yf.escapeJsonPointer=$f,yf.unescapeJsonPointer=bf,yf.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},yf.mergeEvaluated={props:kf({mergeNames:(e,t,r)=>e.if(gf._`${r} !== true && ${t} !== undefined`,()=>{e.if(gf._`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,gf._`${r} || {}`).code(gf._`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if(gf._`${r} !== true`,()=>{!0===t?e.assign(r,!0):(e.assign(r,gf._`${r} || {}`),Pf(e,r,t))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:Ef}),items:kf({mergeNames:(e,t,r)=>e.if(gf._`${r} !== true && ${t} !== undefined`,()=>e.assign(r,gf._`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if(gf._`${r} !== true`,()=>e.assign(r,!0===t||gf._`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},yf.evaluatedPropsToName=Ef,yf.setEvaluated=Pf;const Sf={};var Tf;function If(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,!0===r)throw new Error(t);e.self.logger.warn(t)}}yf.useFunc=function(e,t){return e.scopeValue("func",{ref:t,code:Sf[t.code]||(Sf[t.code]=new vf._Code(t.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(Tf||(yf.Type=Tf={})),yf.getErrorPath=function(e,t,r){if(e instanceof gf.Name){const n=t===Tf.Num;return r?n?gf._`"[" + ${e} + "]"`:gf._`"['" + ${e} + "']"`:n?gf._`"/" + ${e}`:gf._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,gf.getProperty)(e).toString():"/"+$f(e)},yf.checkStrictMode=If;var xf,Nf,Cf,jf={};function Rf(){if(xf)return jf;xf=1,Object.defineProperty(jf,"__esModule",{value:!0});const e=pf,t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return jf.default=t,jf}function Of(){return Nf||(Nf=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=pf,r=yf,n=Rf();function o(e,r){const o=e.const("err",r);e.if(t._`${n.default.vErrors} === null`,()=>e.assign(n.default.vErrors,t._`[${o}]`),t._`${n.default.vErrors}.push(${o})`),e.code(t._`${n.default.errors}++`)}function s(e,r){const{gen:n,validateName:o,schemaEnv:s}=e;s.$async?n.throw(t._`new ${e.ValidationError}(${r})`):(n.assign(t._`${o}.errors`,r),n.return(!1))}e.keywordError={message:({keyword:e})=>t.str`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:r})=>r?t.str`"${e}" keyword must be ${r} ($data)`:t.str`"${e}" keyword is invalid ($data)`},e.reportError=function(r,n=e.keywordError,a,c){const{it:u}=r,{gen:l,compositeRule:d,allErrors:h}=u,p=i(r,n,a);(null!=c?c:d||h)?o(l,p):s(u,t._`[${p}]`)},e.reportExtraError=function(t,r=e.keywordError,a){const{it:c}=t,{gen:u,compositeRule:l,allErrors:d}=c;o(u,i(t,r,a)),l||d||s(c,n.default.vErrors)},e.resetErrorsCount=function(e,r){e.assign(n.default.errors,r),e.if(t._`${n.default.vErrors} !== null`,()=>e.if(r,()=>e.assign(t._`${n.default.vErrors}.length`,r),()=>e.assign(n.default.vErrors,null)))},e.extendErrors=function({gen:e,keyword:r,schemaValue:o,data:s,errsCount:a,it:i}){if(void 0===a)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",a,n.default.errors,a=>{e.const(c,t._`${n.default.vErrors}[${a}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,i.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${i.errSchemaPath}/${r}`),i.opts.verbose&&(e.assign(t._`${c}.schema`,o),e.assign(t._`${c}.data`,s))})};const a={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function i(e,r,o){const{createErrors:s}=e.it;return!1===s?t._`{}`:function(e,r,o={}){const{gen:s,it:i}=e,l=[c(i,o),u(e,o)];return function(e,{params:r,message:o},s){const{keyword:i,data:c,schemaValue:u,it:l}=e,{opts:d,propertyName:h,topSchemaRef:p,schemaPath:f}=l;s.push([a.keyword,i],[a.params,"function"==typeof r?r(e):r||t._`{}`]),d.messages&&s.push([a.message,"function"==typeof o?o(e):o]);d.verbose&&s.push([a.schema,u],[a.parentSchema,t._`${p}${f}`],[n.default.data,c]);h&&s.push([a.propertyName,h])}(e,r,l),s.object(...l)}(e,r,o)}function c({errorPath:e},{instancePath:o}){const s=o?t.str`${e}${(0,r.getErrorPath)(o,r.Type.Str)}`:e;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,s)]}function u({keyword:e,it:{errSchemaPath:n}},{schemaPath:o,parentSchema:s}){let i=s?n:t.str`${n}/${e}`;return o&&(i=t.str`${i}${(0,r.getErrorPath)(o,r.Type.Str)}`),[a.schemaPath,i]}}(hf)),hf}var zf={},Af={};Object.defineProperty(Af,"__esModule",{value:!0}),Af.getRules=Af.isJSONType=void 0;const Mf=new Set(["string","number","integer","boolean","null","object","array"]);Af.isJSONType=function(e){return"string"==typeof e&&Mf.has(e)},Af.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}};var Df,Uf={};function qf(){if(Df)return Uf;function e(e,r){return r.rules.some(r=>t(e,r))}function t(e,t){var r;return void 0!==e[t.keyword]||(null===(r=t.definition.implements)||void 0===r?void 0:r.some(t=>void 0!==e[t]))}return Df=1,Object.defineProperty(Uf,"__esModule",{value:!0}),Uf.shouldUseRule=Uf.shouldUseGroup=Uf.schemaHasRulesForType=void 0,Uf.schemaHasRulesForType=function({schema:t,self:r},n){const o=r.RULES.types[n];return o&&!0!==o&&e(t,o)},Uf.shouldUseGroup=e,Uf.shouldUseRule=t,Uf}Object.defineProperty(zf,"__esModule",{value:!0}),zf.reportTypeError=zf.checkDataTypes=zf.checkDataType=zf.coerceAndCheckDataType=zf.getJSONTypes=zf.getSchemaTypes=zf.DataType=void 0;const Vf=Af,Ff=qf(),Lf=Of(),Kf=pf,Hf=yf;var Zf;function Gf(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(Vf.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(Zf||(zf.DataType=Zf={})),zf.getSchemaTypes=function(e){const t=Gf(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},zf.getJSONTypes=Gf,zf.coerceAndCheckDataType=function(e,t){const{gen:r,data:n,opts:o}=e,s=function(e,t){return t?e.filter(e=>Bf.has(e)||"array"===t&&"array"===e):[]}(t,o.coerceTypes),a=t.length>0&&!(0===s.length&&1===t.length&&(0,Ff.schemaHasRulesForType)(e,t[0]));if(a){const a=Wf(t,n,o.strictNumbers,Zf.Wrong);r.if(a,()=>{s.length?function(e,t,r){const{gen:n,data:o,opts:s}=e,a=n.let("dataType",Kf._`typeof ${o}`),i=n.let("coerced",Kf._`undefined`);"array"===s.coerceTypes&&n.if(Kf._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,Kf._`${o}[0]`).assign(a,Kf._`typeof ${o}`).if(Wf(t,o,s.strictNumbers),()=>n.assign(i,o)));n.if(Kf._`${i} !== undefined`);for(const e of r)(Bf.has(e)||"array"===e&&"array"===s.coerceTypes)&&c(e);function c(e){switch(e){case"string":return void n.elseIf(Kf._`${a} == "number" || ${a} == "boolean"`).assign(i,Kf._`"" + ${o}`).elseIf(Kf._`${o} === null`).assign(i,Kf._`""`);case"number":return void n.elseIf(Kf._`${a} == "boolean" || ${o} === null
8
- || (${a} == "string" && ${o} && ${o} == +${o})`).assign(i,Kf._`+${o}`);case"integer":return void n.elseIf(Kf._`${a} === "boolean" || ${o} === null
9
- || (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(i,Kf._`+${o}`);case"boolean":return void n.elseIf(Kf._`${o} === "false" || ${o} === 0 || ${o} === null`).assign(i,!1).elseIf(Kf._`${o} === "true" || ${o} === 1`).assign(i,!0);case"null":return n.elseIf(Kf._`${o} === "" || ${o} === 0 || ${o} === false`),void n.assign(i,null);case"array":n.elseIf(Kf._`${a} === "string" || ${a} === "number"
10
- || ${a} === "boolean" || ${o} === null`).assign(i,Kf._`[${o}]`)}}n.else(),Yf(e),n.endIf(),n.if(Kf._`${i} !== undefined`,()=>{n.assign(o,i),function({gen:e,parentData:t,parentDataProperty:r},n){e.if(Kf._`${t} !== undefined`,()=>e.assign(Kf._`${t}[${r}]`,n))}(e,i)})}(e,t,s):Yf(e)})}return a};const Bf=new Set(["string","number","integer","boolean","null"]);function Jf(e,t,r,n=Zf.Correct){const o=n===Zf.Correct?Kf.operators.EQ:Kf.operators.NEQ;let s;switch(e){case"null":return Kf._`${t} ${o} null`;case"array":s=Kf._`Array.isArray(${t})`;break;case"object":s=Kf._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=a(Kf._`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=a();break;default:return Kf._`typeof ${t} ${o} ${e}`}return n===Zf.Correct?s:(0,Kf.not)(s);function a(e=Kf.nil){return(0,Kf.and)(Kf._`typeof ${t} == "number"`,e,r?Kf._`isFinite(${t})`:Kf.nil)}}function Wf(e,t,r,n){if(1===e.length)return Jf(e[0],t,r,n);let o;const s=(0,Hf.toHash)(e);if(s.array&&s.object){const e=Kf._`typeof ${t} != "object"`;o=s.null?e:Kf._`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=Kf.nil;s.number&&delete s.integer;for(const e in s)o=(0,Kf.and)(o,Jf(e,t,r,n));return o}zf.checkDataType=Jf,zf.checkDataTypes=Wf;const Qf={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?Kf._`{type: ${e}}`:Kf._`{type: ${t}}`};function Yf(e){const t=function(e){const{gen:t,data:r,schema:n}=e,o=(0,Hf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}(e);(0,Lf.reportError)(t,Qf)}zf.reportTypeError=Yf;var Xf,em={};var tm,rm,nm={},om={};function sm(){if(tm)return om;tm=1,Object.defineProperty(om,"__esModule",{value:!0}),om.validateUnion=om.validateArray=om.usePattern=om.callValidateCode=om.schemaProperties=om.allSchemaProperties=om.noPropertyInData=om.propertyInData=om.isOwnProperty=om.hasPropFunc=om.reportMissingProp=om.checkMissingProp=om.checkReportMissingProp=void 0;const e=pf,t=yf,r=Rf(),n=yf;function o(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:e._`Object.prototype.hasOwnProperty`})}function s(t,r,n){return e._`${o(t)}.call(${r}, ${n})`}function a(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} === undefined`;return o?(0,e.or)(a,(0,e.not)(s(t,r,n))):a}function i(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}om.checkReportMissingProp=function(t,r){const{gen:n,data:o,it:s}=t;n.if(a(n,o,r,s.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},om.checkMissingProp=function({gen:t,data:r,it:{opts:n}},o,s){return(0,e.or)(...o.map(o=>(0,e.and)(a(t,r,o,n.ownProperties),e._`${s} = ${o}`)))},om.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},om.hasPropFunc=o,om.isOwnProperty=s,om.propertyInData=function(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return o?e._`${a} && ${s(t,r,n)}`:a},om.noPropertyInData=a,om.allSchemaProperties=i,om.schemaProperties=function(e,r){return i(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},om.callValidateCode=function({schemaCode:t,data:n,it:{gen:o,topSchemaRef:s,schemaPath:a,errorPath:i},it:c},u,l,d){const h=d?e._`${t}, ${n}, ${s}${a}`:n,p=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,i)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const f=e._`${h}, ${o.object(...p)}`;return l!==e.nil?e._`${u}.call(${l}, ${f})`:e._`${u}(${f})`};const c=e._`new RegExp`;return om.usePattern=function({gen:t,it:{opts:r}},o){const s=r.unicodeRegExp?"u":"",{regExp:a}=r.code,i=a(o,s);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:e._`${"new RegExp"===a.code?c:(0,n.useFunc)(t,a)}(${o}, ${s})`})},om.validateArray=function(r){const{gen:n,data:o,keyword:s,it:a}=r,i=n.name("valid");if(a.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(i,!0),c(()=>n.break()),i;function c(a){const c=n.const("len",e._`${o}.length`);n.forRange("i",0,c,o=>{r.subschema({keyword:s,dataProp:o,dataPropType:t.Type.Num},i),n.if((0,e.not)(i),a)})}},om.validateUnion=function(r){const{gen:n,schema:o,keyword:s,it:a}=r;if(!Array.isArray(o))throw new Error("ajv implementation error");if(o.some(e=>(0,t.alwaysValidSchema)(a,e))&&!a.opts.unevaluated)return;const i=n.let("valid",!1),c=n.name("_valid");n.block(()=>o.forEach((t,o)=>{const a=r.subschema({keyword:s,schemaProp:o,compositeRule:!0},c);n.assign(i,e._`${i} || ${c}`);r.mergeValidEvaluated(a,c)||n.if((0,e.not)(i))})),r.result(i,()=>r.reset(),()=>r.error(!0))},om}function am(){if(rm)return nm;rm=1,Object.defineProperty(nm,"__esModule",{value:!0}),nm.validateKeywordUsage=nm.validSchemaType=nm.funcKeywordCode=nm.macroKeywordCode=void 0;const e=pf,t=Rf(),r=sm(),n=Of();function o(t){const{gen:r,data:n,it:o}=t;r.if(o.parentData,()=>r.assign(n,e._`${o.parentData}[${o.parentDataProperty}]`))}function s(t,r,n){if(void 0===n)throw new Error(`keyword "${r}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,e.stringify)(n)})}return nm.macroKeywordCode=function(t,r){const{gen:n,keyword:o,schema:a,parentSchema:i,it:c}=t,u=r.macro.call(c.self,a,i,c),l=s(n,o,u);!1!==c.opts.validateSchema&&c.self.validateSchema(u,!0);const d=n.name("valid");t.subschema({schema:u,schemaPath:e.nil,errSchemaPath:`${c.errSchemaPath}/${o}`,topSchemaRef:l,compositeRule:!0},d),t.pass(d,()=>t.error(!0))},nm.funcKeywordCode=function(a,i){var c;const{gen:u,keyword:l,schema:d,parentSchema:h,$data:p,it:f}=a;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(f,i);const m=!p&&i.compile?i.compile.call(f.self,d,h,f):i.validate,y=s(u,l,m),g=u.let("valid");function v(n=(i.async?e._`await `:e.nil)){const o=f.opts.passContext?t.default.this:t.default.self,s=!("compile"in i&&!p||!1===i.schema);u.assign(g,e._`${n}${(0,r.callValidateCode)(a,y,o,s)}`,i.modifying)}function _(t){var r;u.if((0,e.not)(null!==(r=i.valid)&&void 0!==r?r:g),t)}a.block$data(g,function(){if(!1===i.errors)v(),i.modifying&&o(a),_(()=>a.error());else{const r=i.async?function(){const t=u.let("ruleErrs",null);return u.try(()=>v(e._`await `),r=>u.assign(g,!1).if(e._`${r} instanceof ${f.ValidationError}`,()=>u.assign(t,e._`${r}.errors`),()=>u.throw(r))),t}():function(){const t=e._`${y}.errors`;return u.assign(t,null),v(e.nil),t}();i.modifying&&o(a),_(()=>function(r,o){const{gen:s}=r;s.if(e._`Array.isArray(${o})`,()=>{s.assign(t.default.vErrors,e._`${t.default.vErrors} === null ? ${o} : ${t.default.vErrors}.concat(${o})`).assign(t.default.errors,e._`${t.default.vErrors}.length`),(0,n.extendErrors)(r)},()=>r.error())}(a,r))}}),a.ok(null!==(c=i.valid)&&void 0!==c?c:g)},nm.validSchemaType=function(e,t,r=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||r&&void 0===e)},nm.validateKeywordUsage=function({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");const a=o.dependencies;if(null==a?void 0:a.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${s}: ${a.join(",")}`);if(o.validateSchema){if(!o.validateSchema(e[s])){const e=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);r.logger.error(e)}}},nm}var im,cm={};var um={},lm={exports:{}},dm=lm.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),hm(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function hm(e,t,r,n,o,s,a,i,c,u){if(n&&"object"==typeof n&&!Array.isArray(n)){for(var l in t(n,o,s,a,i,c,u),n){var d=n[l];if(Array.isArray(d)){if(l in dm.arrayKeywords)for(var h=0;h<d.length;h++)hm(e,t,r,d[h],o+"/"+l+"/"+h,s,o,l,n,h)}else if(l in dm.propsKeywords){if(d&&"object"==typeof d)for(var p in d)hm(e,t,r,d[p],o+"/"+l+"/"+pm(p),s,o,l,n,p)}else(l in dm.keywords||e.allKeys&&!(l in dm.skipKeywords))&&hm(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,a,i,c,u)}}function pm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}dm.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},dm.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},dm.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},dm.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};var fm=lm.exports;Object.defineProperty(um,"__esModule",{value:!0}),um.getSchemaRefs=um.resolveUrl=um.normalizeId=um._getFullPath=um.getFullPath=um.inlineRef=void 0;const mm=yf,ym=au,gm=fm,vm=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);um.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!wm(e):!!t&&$m(e)<=t)};const _m=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function wm(e){for(const t in e){if(_m.has(t))return!0;const r=e[t];if(Array.isArray(r)&&r.some(wm))return!0;if("object"==typeof r&&wm(r))return!0}return!1}function $m(e){let t=0;for(const r in e){if("$ref"===r)return 1/0;if(t++,!vm.has(r)&&("object"==typeof e[r]&&(0,mm.eachItem)(e[r],e=>t+=$m(e)),t===1/0))return 1/0}return t}function bm(e,t="",r){!1!==r&&(t=Pm(t));const n=e.parse(t);return km(e,n)}function km(e,t){return e.serialize(t).split("#")[0]+"#"}um.getFullPath=bm,um._getFullPath=km;const Em=/#\/?$/;function Pm(e){return e?e.replace(Em,""):""}um.normalizeId=Pm,um.resolveUrl=function(e,t,r){return r=Pm(r),e.resolve(t,r)};const Sm=/^[a-z_][-a-z0-9._]*$/i;var Tm;function Im(){if(Tm)return lf;Tm=1,Object.defineProperty(lf,"__esModule",{value:!0}),lf.getData=lf.KeywordCxt=lf.validateFunctionCode=void 0;const e=function(){if(Cf)return df;Cf=1,Object.defineProperty(df,"__esModule",{value:!0}),df.boolOrEmptySchema=df.topBoolOrEmptySchema=void 0;const e=Of(),t=pf,r=Rf(),n={message:"boolean schema is false"};function o(t,r){const{gen:o,data:s}=t,a={gen:o,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(a,n,void 0,r)}return df.topBoolOrEmptySchema=function(e){const{gen:n,schema:s,validateName:a}=e;!1===s?o(e,!1):"object"==typeof s&&!0===s.$async?n.return(r.default.data):(n.assign(t._`${a}.errors`,null),n.return(!0))},df.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),o(e)):r.var(t,!0)},df}(),t=zf,r=qf(),n=zf,o=function(){if(Xf)return em;Xf=1,Object.defineProperty(em,"__esModule",{value:!0}),em.assignDefaults=void 0;const e=pf,t=yf;function r(r,n,o){const{gen:s,compositeRule:a,data:i,opts:c}=r;if(void 0===o)return;const u=e._`${i}${(0,e.getProperty)(n)}`;if(a)return void(0,t.checkStrictMode)(r,`default is ignored for: ${u}`);let l=e._`${u} === undefined`;"empty"===c.useDefaults&&(l=e._`${l} || ${u} === null || ${u} === ""`),s.if(l,e._`${u} = ${(0,e.stringify)(o)}`)}return em.assignDefaults=function(e,t){const{properties:n,items:o}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(o)&&o.forEach((t,n)=>r(e,n,t.default))},em}(),s=am(),a=function(){if(im)return cm;im=1,Object.defineProperty(cm,"__esModule",{value:!0}),cm.extendSubschemaMode=cm.extendSubschemaData=cm.getSubschema=void 0;const e=pf,t=yf;return cm.getSubschema=function(r,{keyword:n,schemaProp:o,schema:s,schemaPath:a,errSchemaPath:i,topSchemaRef:c}){if(void 0!==n&&void 0!==s)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==n){const s=r.schema[n];return void 0===o?{schema:s,schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}`,errSchemaPath:`${r.errSchemaPath}/${n}`}:{schema:s[o],schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}${(0,e.getProperty)(o)}`,errSchemaPath:`${r.errSchemaPath}/${n}/${(0,t.escapeFragment)(o)}`}}if(void 0!==s){if(void 0===a||void 0===i||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:a,topSchemaRef:c,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')},cm.extendSubschemaData=function(r,n,{dataProp:o,dataPropType:s,data:a,dataTypes:i,propertyName:c}){if(void 0!==a&&void 0!==o)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:u}=n;if(void 0!==o){const{errorPath:a,dataPathArr:i,opts:c}=n;l(u.let("data",e._`${n.data}${(0,e.getProperty)(o)}`,!0)),r.errorPath=e.str`${a}${(0,t.getErrorPath)(o,s,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${o}`,r.dataPathArr=[...i,r.parentDataProperty]}function l(e){r.data=e,r.dataLevel=n.dataLevel+1,r.dataTypes=[],n.definedProperties=new Set,r.parentData=n.data,r.dataNames=[...n.dataNames,e]}void 0!==a&&(l(a instanceof e.Name?a:u.let("data",a,!0)),void 0!==c&&(r.propertyName=c)),i&&(r.dataTypes=i)},cm.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){void 0!==n&&(e.compositeRule=n),void 0!==o&&(e.createErrors=o),void 0!==s&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r},cm}(),i=pf,c=Rf(),u=um,l=yf,d=Of();function h({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,i._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(i._`"use strict"; ${p(r,o)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,i._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,i._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,i._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,i._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,i._`""`),e.var(c.default.parentData,i._`undefined`),e.var(c.default.parentDataProperty,i._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`{}`)})}(e,o),e.code(s)}):e.func(t,i._`${c.default.data}, ${function(e){return i._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?i._`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}(o)}`,n.$async,()=>e.code(p(r,o)).code(s))}function p(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?i._`/*# sourceURL=${r} */`:i.nil}function f(t,r){y(t)&&(g(t),m(t))?function(e,t){const{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&_(e);(function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))})(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const s=n.const("_errs",c.default.errors);v(e,s),n.var(t,i._`${s} === ${c.default.errors}`)}(t,r):(0,e.boolOrEmptySchema)(t,r)}function m({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function y(e){return"boolean"!=typeof e.schema}function g(e){(0,l.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(e)}function v(e,r){if(e.opts.jtd)return w(e,[],!1,r);const n=(0,t.getSchemaTypes)(e.schema);w(e,n,!(0,t.coerceAndCheckDataType)(e,n),r)}function _({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){const s=r.$comment;if(!0===o.$comment)e.code(i._`${c.default.self}.logger.log(${s})`);else if("function"==typeof o.$comment){const r=i.str`${n}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(i._`${c.default.self}.opts.$comment(${s}, ${r}, ${o}.schema)`)}}function w(e,t,o,s){const{gen:a,schema:u,data:d,allErrors:h,opts:p,self:f}=e,{RULES:m}=f;function y(l){(0,r.shouldUseGroup)(u,l)&&(l.type?(a.if((0,n.checkDataType)(l.type,d,p.strictNumbers)),$(e,l),1===t.length&&t[0]===l.type&&o&&(a.else(),(0,n.reportTypeError)(e)),a.endIf()):$(e,l),h||a.if(i._`${c.default.errors} === ${s||0}`))}!u.$ref||!p.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(u,m)?(p.jtd||function(e,t){if(e.schemaEnv.meta||!e.opts.strictTypes)return;(function(e,t){if(!t.length)return;if(!e.dataTypes.length)return void(e.dataTypes=t);t.forEach(t=>{k(e.dataTypes,t)||E(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const r=[];for(const n of e.dataTypes)k(t,n)?r.push(n):t.includes("integer")&&"number"===n&&r.push("integer");e.dataTypes=r}(e,t)})(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&E(e,"use allowUnionTypes to allow union type keyword")}(e,t);!function(e,t){const n=e.self.RULES.all;for(const o in n){const s=n[o];if("object"==typeof s&&(0,r.shouldUseRule)(e.schema,s)){const{type:r}=s.definition;r.length&&!r.some(e=>b(t,e))&&E(e,`missing type "${r.join(",")}" for keyword "${o}"`)}}}(e,e.dataTypes)}(e,t),a.block(()=>{for(const e of m.rules)y(e);y(m.post)})):a.block(()=>S(e,"$ref",m.all.$ref.definition))}function $(e,t){const{gen:n,schema:s,opts:{useDefaults:a}}=e;a&&(0,o.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(s,n)&&S(e,n.keyword,n.definition,t.type)})}function b(e,t){return e.includes(t)||"number"===t&&e.includes("integer")}function k(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function E(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,l.checkStrictMode)(e,t,e.opts.strictTypes)}lf.validateFunctionCode=function(t){y(t)&&(g(t),m(t))?function(e){const{schema:t,opts:r,gen:n}=e;h(e,()=>{r.$comment&&t.$comment&&_(e),function(e){const{schema:t,opts:r}=e;void 0!==t.default&&r.useDefaults&&r.strictSchema&&(0,l.checkStrictMode)(e,"default is ignored in the schema root")}(e),n.let(c.default.vErrors,null),n.let(c.default.errors,0),r.unevaluated&&function(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",i._`${r}.evaluated`),t.if(i._`${e.evaluated}.dynamicProps`,()=>t.assign(i._`${e.evaluated}.props`,i._`undefined`)),t.if(i._`${e.evaluated}.dynamicItems`,()=>t.assign(i._`${e.evaluated}.items`,i._`undefined`))}(e),v(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if(i._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(i._`new ${o}(${c.default.vErrors})`)):(t.assign(i._`${n}.errors`,c.default.vErrors),s.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof i.Name&&e.assign(i._`${t}.props`,r);n instanceof i.Name&&e.assign(i._`${t}.items`,n)}(e),t.return(i._`${c.default.errors} === 0`))}(e)})}(t):h(t,()=>(0,e.topBoolOrEmptySchema)(t))};class P{constructor(e,t,r){if((0,s.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,l.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",x(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,s.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",c.default.errors))}result(e,t,r){this.failResult((0,i.not)(e),t,r)}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,i.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(i._`${t} !== undefined && (${(0,i.or)(this.invalid$data(),e)})`)}error(e,t,r){if(t)return this.setParams(t),this._error(e,r),void this.setParams({});this._error(e,r)}_error(e,t){(e?d.reportExtraError:d.reportError)(this,this.def.error,t)}$dataError(){(0,d.reportError)(this,this.def.$dataError||d.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,d.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,r=i.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=i.nil,t=i.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:o,def:s}=this;r.if((0,i.or)(i._`${n} === undefined`,t)),e!==i.nil&&r.assign(e,!0),(o.length||s.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==i.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:o,it:s}=this;return(0,i.or)(function(){if(r.length){if(!(t instanceof i.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return i._`${(0,n.checkDataTypes)(e,t,s.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}(),function(){if(o.validateSchema){const r=e.scopeValue("validate$data",{ref:o.validateSchema});return i._`!${r}(${t})`}return i.nil}())}subschema(e,t){const r=(0,a.getSubschema)(this.it,e);(0,a.extendSubschemaData)(r,this.it,e),(0,a.extendSubschemaMode)(r,e);const n={...this.it,...r,items:void 0,props:void 0};return f(n,t),n}mergeEvaluated(e,t){const{it:r,gen:n}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==e.props&&(r.props=l.mergeEvaluated.props(n,e.props,r.props,t)),!0!==r.items&&void 0!==e.items&&(r.items=l.mergeEvaluated.items(n,e.items,r.items,t)))}mergeValidEvaluated(e,t){const{it:r,gen:n}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return n.if(t,()=>this.mergeEvaluated(e,i.Name)),!0}}function S(e,t,r,n){const o=new P(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,s.funcKeywordCode)(o,r):"macro"in r?(0,s.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,s.funcKeywordCode)(o,r)}lf.KeywordCxt=P;const T=/^\/(?:[^~]|~0|~1)*$/,I=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(""===e)return c.default.rootData;if("/"===e[0]){if(!T.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=c.default.rootData}else{const a=I.exec(e);if(!a)throw new Error(`Invalid JSON-pointer: ${e}`);const i=+a[1];if(o=a[2],"#"===o){if(i>=t)throw new Error(d("property/index",i));return n[t-i]}if(i>t)throw new Error(d("data",i));if(s=r[t-i],!o)return s}let a=s;const u=o.split("/");for(const e of u)e&&(s=i._`${s}${(0,i.getProperty)((0,l.unescapeJsonPointer)(e))}`,a=i._`${a} && ${s}`);return a;function d(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return lf.getData=x,lf}um.getSchemaRefs=function(e,t){if("boolean"==typeof e)return{};const{schemaId:r,uriResolver:n}=this.opts,o=Pm(e[r]||t),s={"":o},a=bm(n,o,!1),i={},c=new Set;return gm(e,{allKeys:!0},(e,t,n,o)=>{if(void 0===o)return;const d=a+t;let h=s[o];function p(t){const r=this.opts.uriResolver.resolve;if(t=Pm(h?r(h,t):t),c.has(t))throw l(t);c.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?u(e,n.schema,t):t!==Pm(d)&&("#"===t[0]?(u(e,i[t],t),i[t]=e):this.refs[t]=d),t}function f(e){if("string"==typeof e){if(!Sm.test(e))throw new Error(`invalid anchor "${e}"`);p.call(this,`#${e}`)}}"string"==typeof e[r]&&(h=p.call(this,e[r])),f.call(this,e.$anchor),f.call(this,e.$dynamicAnchor),s[t]=h}),i;function u(e,t,r){if(void 0!==t&&!ym(e,t))throw l(r)}function l(e){return new Error(`reference "${e}" resolves to more than one schema`)}};var xm,Nm={};function Cm(){if(xm)return Nm;xm=1,Object.defineProperty(Nm,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return Nm.default=e,Nm}var jm,Rm={};function Om(){if(jm)return Rm;jm=1,Object.defineProperty(Rm,"__esModule",{value:!0});const e=um;class t extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,e.resolveUrl)(t,r,n),this.missingSchema=(0,e.normalizeId)((0,e.getFullPath)(t,this.missingRef))}}return Rm.default=t,Rm}var zm={};Object.defineProperty(zm,"__esModule",{value:!0}),zm.resolveSchema=zm.getCompilingSchema=zm.resolveRef=zm.compileSchema=zm.SchemaEnv=void 0;const Am=pf,Mm=Cm(),Dm=Rf(),Um=um,qm=yf,Vm=Im();class Fm{constructor(e){var t;let r;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,Um.normalizeId)(null==r?void 0:r[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==r?void 0:r.$async,this.refs={}}}function Lm(e){const t=Hm.call(this,e);if(t)return t;const r=(0,Um.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,a=new Am.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s});let i;e.$async&&(i=a.scopeValue("Error",{ref:Mm.default,code:Am._`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const u={gen:a,allErrors:this.opts.allErrors,data:Dm.default.data,parentData:Dm.default.parentData,parentDataProperty:Dm.default.parentDataProperty,dataNames:[Dm.default.data],dataPathArr:[Am.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,Am.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Am.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:Am._`""`,opts:this.opts,self:this};let l;try{this._compilations.add(e),(0,Vm.validateFunctionCode)(u),a.optimize(this.opts.code.optimize);const t=a.toString();l=`${a.scopeRefs(Dm.default.scope)}return ${t}`,this.opts.code.process&&(l=this.opts.code.process(l,e));const r=new Function(`${Dm.default.self}`,`${Dm.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:r}),r.errors=null,r.schema=e.schema,r.schemaEnv=e,e.$async&&(r.$async=!0),!0===this.opts.code.source&&(r.source={validateName:c,validateCode:t,scopeValues:a._values}),this.opts.unevaluated){const{props:e,items:t}=u;r.evaluated={props:e instanceof Am.Name?void 0:e,items:t instanceof Am.Name?void 0:t,dynamicProps:e instanceof Am.Name,dynamicItems:t instanceof Am.Name},r.source&&(r.source.evaluated=(0,Am.stringify)(r.evaluated))}return e.validate=r,e}catch(t){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),t}finally{this._compilations.delete(e)}}function Km(e){return(0,Um.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Lm.call(this,e)}function Hm(e){for(const t of this._compilations)if(Zm(t,e))return t}function Zm(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Gm(e,t){let r;for(;"string"==typeof(r=this.refs[t]);)t=r;return r||this.schemas[t]||Bm.call(this,e,t)}function Bm(e,t){const r=this.opts.uriResolver.parse(t),n=(0,Um._getFullPath)(this.opts.uriResolver,r);let o=(0,Um.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Wm.call(this,r,e);const s=(0,Um.normalizeId)(n),a=this.refs[s]||this.schemas[s];if("string"==typeof a){const t=Bm.call(this,e,a);if("object"!=typeof(null==t?void 0:t.schema))return;return Wm.call(this,r,t)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||Lm.call(this,a),s===(0,Um.normalizeId)(t)){const{schema:t}=a,{schemaId:r}=this.opts,n=t[r];return n&&(o=(0,Um.resolveUrl)(this.opts.uriResolver,o,n)),new Fm({schema:t,schemaId:r,root:e,baseId:o})}return Wm.call(this,r,a)}}zm.SchemaEnv=Fm,zm.compileSchema=Lm,zm.resolveRef=function(e,t,r){var n;r=(0,Um.resolveUrl)(this.opts.uriResolver,t,r);const o=e.refs[r];if(o)return o;let s=Gm.call(this,e,r);if(void 0===s){const o=null===(n=e.localRefs)||void 0===n?void 0:n[r],{schemaId:a}=this.opts;o&&(s=new Fm({schema:o,schemaId:a,root:e,baseId:t}))}return void 0!==s?e.refs[r]=Km.call(this,s):void 0},zm.getCompilingSchema=Hm,zm.resolveSchema=Bm;const Jm=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Wm(e,{baseId:t,schema:r,root:n}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const n of e.fragment.slice(1).split("/")){if("boolean"==typeof r)return;const e=r[(0,qm.unescapeFragment)(n)];if(void 0===e)return;const o="object"==typeof(r=e)&&r[this.opts.schemaId];!Jm.has(n)&&o&&(t=(0,Um.resolveUrl)(this.opts.uriResolver,t,o))}let s;if("boolean"!=typeof r&&r.$ref&&!(0,qm.schemaHasRulesButRef)(r,this.RULES)){const e=(0,Um.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Bm.call(this,n,e)}const{schemaId:a}=this.opts;return s=s||new Fm({schema:r,schemaId:a,root:n,baseId:t}),s.schema!==s.root.schema?s:void 0}var Qm={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},Ym={};Object.defineProperty(Ym,"__esModule",{value:!0});const Xm=Il;Xm.code='require("ajv/dist/runtime/uri").default',Ym.default=Xm,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Im();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=pf;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Cm(),o=Om(),s=Af,a=zm,i=pf,c=um,u=zf,l=yf,d=Qm,h=Ym,p=(e,t)=>new RegExp(e,t);p.code="new RegExp";const f=["removeAdditional","useDefaults","coerceTypes"],m=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),y={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},g={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function v(e){var t,r,n,o,s,a,i,c,u,l,d,f,m,y,g,v,_,w,$,b,k,E,P,S,T;const I=e.strict,x=null===(t=e.code)||void 0===t?void 0:t.optimize,N=!0===x||void 0===x?1:x||0,C=null!==(n=null===(r=e.code)||void 0===r?void 0:r.regExp)&&void 0!==n?n:p,j=null!==(o=e.uriResolver)&&void 0!==o?o:h.default;return{strictSchema:null===(a=null!==(s=e.strictSchema)&&void 0!==s?s:I)||void 0===a||a,strictNumbers:null===(c=null!==(i=e.strictNumbers)&&void 0!==i?i:I)||void 0===c||c,strictTypes:null!==(l=null!==(u=e.strictTypes)&&void 0!==u?u:I)&&void 0!==l?l:"log",strictTuples:null!==(f=null!==(d=e.strictTuples)&&void 0!==d?d:I)&&void 0!==f?f:"log",strictRequired:null!==(y=null!==(m=e.strictRequired)&&void 0!==m?m:I)&&void 0!==y&&y,code:e.code?{...e.code,optimize:N,regExp:C}:{optimize:N,regExp:C},loopRequired:null!==(g=e.loopRequired)&&void 0!==g?g:200,loopEnum:null!==(v=e.loopEnum)&&void 0!==v?v:200,meta:null===(_=e.meta)||void 0===_||_,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===($=e.inlineRefs)||void 0===$||$,schemaId:null!==(b=e.schemaId)&&void 0!==b?b:"$id",addUsedSchema:null===(k=e.addUsedSchema)||void 0===k||k,validateSchema:null===(E=e.validateSchema)||void 0===E||E,validateFormats:null===(P=e.validateFormats)||void 0===P||P,unicodeRegExp:null===(S=e.unicodeRegExp)||void 0===S||S,int32range:null===(T=e.int32range)||void 0===T||T,uriResolver:j}}class _{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};const{es5:t,lines:r}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:m,es5:t,lines:r}),this.logger=function(e){if(!1===e)return S;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,s.getRules)(),w.call(this,y,e,"NOT SUPPORTED"),w.call(this,g,e,"DEPRECATED","warn"),this._metaOpts=P.call(this),e.formats&&k.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),b.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:r}=this.opts;let n=d;"id"===r&&(n={...d},n.id=n.$id,delete n.$id),t&&e&&this.addMetaSchema(n,n[r],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let r;if("string"==typeof e){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);const n=r(t);return"$async"in r||(this.errors=r.errors),n}compile(e,t){const r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return n.call(this,e,t);async function n(e,t){await s.call(this,e.$schema);const r=this._addSchema(e,t);return r.validate||a.call(this,r)}async function s(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function a(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof o.default))throw t;return i.call(this,t),await c.call(this,t.missingSchema),a.call(this,e)}}function i({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){const r=await u.call(this,e);this.refs[e]||await s.call(this,r.$schema),this.refs[e]||this.addSchema(r,e,t)}async function u(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=r(e))}finally{delete this._loading[e]}}}addSchema(e,t,r,n=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,r,n);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,n,!0),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,!0,r),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let r;if(r=e.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const n=this.validate(r,e);if(!n&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return n}getSchema(e){let t;for(;"string"==typeof(t=$.call(this,e));)e=t;if(void 0===t){const{schemaId:r}=this.opts,n=new a.SchemaEnv({schema:{},schemaId:r});if(t=a.resolveSchema.call(this,n,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=$.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0,c.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if("string"==typeof e)r=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(r=(t=e).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(I.call(this,r,t),!t)return(0,l.eachItem)(r,e=>x.call(this,e)),this;C.call(this,t);const n={...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)};return(0,l.eachItem)(r,0===n.type.length?e=>x.call(this,e,n):e=>n.type.forEach(t=>x.call(this,e,n,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const r of t.rules){const t=r.rules.findIndex(t=>t.keyword===e);t>=0&&r.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return e&&0!==e.length?e.map(e=>`${r}${e.instancePath} ${e.message}`).reduce((e,r)=>e+t+r):"No errors"}$dataMetaSchema(e,t){const r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const n of t){const t=n.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in r){const t=r[e];if("object"!=typeof t)continue;const{$data:n}=t.definition,s=o[e];n&&s&&(o[e]=R(s))}}return e}_removeAllSchemas(e,t){for(const r in e){const n=e[r];t&&!t.test(r)||("string"==typeof n?delete e[r]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[r]))}}_addSchema(e,t,r,n=this.opts.validateSchema,o=this.opts.addUsedSchema){let s;const{schemaId:i}=this.opts;if("object"==typeof e)s=e[i];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let u=this._cache.get(e);if(void 0!==u)return u;r=(0,c.normalizeId)(s||r);const l=c.getSchemaRefs.call(this,e,r);return u=new a.SchemaEnv({schema:e,schemaId:i,meta:t,baseId:r,localRefs:l}),this._cache.set(u.schema,u),o&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=u),n&&this.validateSchema(e,!0),u}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):a.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,e)}finally{this.opts=t}}}function w(e,t,r,n="error"){for(const o in e){const s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function $(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function b(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function k(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}}function P(){const e={...this.opts};for(const t of f)delete e[t];return e}_.ValidationError=n.default,_.MissingRefError=o.default,e.default=_;const S={log(){},warn(){},error(){}};const T=/^[a-z_$][a-z0-9_$:-]*$/i;function I(e,t){const{RULES:r}=this;if((0,l.eachItem)(e,e=>{if(r.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!T.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function x(e,t,r){var n;const o=null==t?void 0:t.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:s}=this;let a=o?s.post:s.rules.find(({type:e})=>e===r);if(a||(a={type:r,rules:[]},s.rules.push(a)),s.keywords[e]=!0,!t)return;const i={keyword:e,definition:{...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)}};t.before?N.call(this,a,i,t.before):a.rules.push(i),s.all[e]=i,null===(n=t.implements)||void 0===n||n.forEach(e=>this.addKeyword(e))}function N(e,t,r){const n=e.rules.findIndex(e=>e.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function C(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=R(t)),e.validateSchema=this.compile(t,!0))}const j={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function R(e){return{anyOf:[e,j]}}}(uf);var ey={},ty={},ry={};Object.defineProperty(ry,"__esModule",{value:!0});const ny={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ry.default=ny;var oy={};Object.defineProperty(oy,"__esModule",{value:!0}),oy.callRef=oy.getValidate=void 0;const sy=Om(),ay=sm(),iy=pf,cy=Rf(),uy=zm,ly=yf,dy={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:a,opts:i,self:c}=n,{root:u}=s;if(("#"===r||"#/"===r)&&o===u.baseId)return function(){if(s===u)return py(e,a,s,s.$async);const r=t.scopeValue("root",{ref:u});return py(e,iy._`${r}.validate`,u,u.$async)}();const l=uy.resolveRef.call(c,u,o,r);if(void 0===l)throw new sy.default(n.opts.uriResolver,o,r);return l instanceof uy.SchemaEnv?function(t){const r=hy(e,t);py(e,r,t,t.$async)}(l):function(n){const o=t.scopeValue("schema",!0===i.code.source?{ref:n,code:(0,iy.stringify)(n)}:{ref:n}),s=t.name("valid"),a=e.subschema({schema:n,dataTypes:[],schemaPath:iy.nil,topSchemaRef:o,errSchemaPath:r},s);e.mergeEvaluated(a),e.ok(s)}(l)}};function hy(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):iy._`${r.scopeValue("wrapper",{ref:t})}.validate`}function py(e,t,r,n){const{gen:o,it:s}=e,{allErrors:a,schemaEnv:i,opts:c}=s,u=c.passContext?cy.default.this:iy.nil;function l(e){const t=iy._`${e}.errors`;o.assign(cy.default.vErrors,iy._`${cy.default.vErrors} === null ? ${t} : ${cy.default.vErrors}.concat(${t})`),o.assign(cy.default.errors,iy._`${cy.default.vErrors}.length`)}function d(e){var t;if(!s.opts.unevaluated)return;const n=null===(t=null==r?void 0:r.validate)||void 0===t?void 0:t.evaluated;if(!0!==s.props)if(n&&!n.dynamicProps)void 0!==n.props&&(s.props=ly.mergeEvaluated.props(o,n.props,s.props));else{const t=o.var("props",iy._`${e}.evaluated.props`);s.props=ly.mergeEvaluated.props(o,t,s.props,iy.Name)}if(!0!==s.items)if(n&&!n.dynamicItems)void 0!==n.items&&(s.items=ly.mergeEvaluated.items(o,n.items,s.items));else{const t=o.var("items",iy._`${e}.evaluated.items`);s.items=ly.mergeEvaluated.items(o,t,s.items,iy.Name)}}n?function(){if(!i.$async)throw new Error("async schema referenced by sync schema");const r=o.let("valid");o.try(()=>{o.code(iy._`await ${(0,ay.callValidateCode)(e,t,u)}`),d(t),a||o.assign(r,!0)},e=>{o.if(iy._`!(${e} instanceof ${s.ValidationError})`,()=>o.throw(e)),l(e),a||o.assign(r,!1)}),e.ok(r)}():e.result((0,ay.callValidateCode)(e,t,u),()=>d(t),()=>l(t))}oy.getValidate=hy,oy.callRef=py,oy.default=dy,Object.defineProperty(ty,"__esModule",{value:!0});const fy=oy,my=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",ry.default,fy.default];ty.default=my;var yy={},gy={};Object.defineProperty(gy,"__esModule",{value:!0});const vy=pf,_y=vy.operators,wy={maximum:{okStr:"<=",ok:_y.LTE,fail:_y.GT},minimum:{okStr:">=",ok:_y.GTE,fail:_y.LT},exclusiveMaximum:{okStr:"<",ok:_y.LT,fail:_y.GTE},exclusiveMinimum:{okStr:">",ok:_y.GT,fail:_y.LTE}},$y={message:({keyword:e,schemaCode:t})=>vy.str`must be ${wy[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>vy._`{comparison: ${wy[e].okStr}, limit: ${t}}`},by={keyword:Object.keys(wy),type:"number",schemaType:"number",$data:!0,error:$y,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data(vy._`${r} ${wy[t].fail} ${n} || isNaN(${r})`)}};gy.default=by;var ky={};Object.defineProperty(ky,"__esModule",{value:!0});const Ey=pf,Py={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>Ey.str`must be multiple of ${e}`,params:({schemaCode:e})=>Ey._`{multipleOf: ${e}}`},code(e){const{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,a=t.let("res"),i=s?Ey._`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:Ey._`${a} !== parseInt(${a})`;e.fail$data(Ey._`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};ky.default=Py;var Sy={},Ty={};function Iy(e){const t=e.length;let r,n=0,o=0;for(;o<t;)n++,r=e.charCodeAt(o++),r>=55296&&r<=56319&&o<t&&(r=e.charCodeAt(o),56320==(64512&r)&&o++);return n}Object.defineProperty(Ty,"__esModule",{value:!0}),Ty.default=Iy,Iy.code='require("ajv/dist/runtime/ucs2length").default',Object.defineProperty(Sy,"__esModule",{value:!0});const xy=pf,Ny=yf,Cy=Ty,jy={message:({keyword:e,schemaCode:t})=>xy.str`must NOT have ${"maxLength"===e?"more":"fewer"} than ${t} characters`,params:({schemaCode:e})=>xy._`{limit: ${e}}`},Ry={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:jy,code(e){const{keyword:t,data:r,schemaCode:n,it:o}=e,s="maxLength"===t?xy.operators.GT:xy.operators.LT,a=!1===o.opts.unicode?xy._`${r}.length`:xy._`${(0,Ny.useFunc)(e.gen,Cy.default)}(${r})`;e.fail$data(xy._`${a} ${s} ${n}`)}};Sy.default=Ry;var Oy={};Object.defineProperty(Oy,"__esModule",{value:!0});const zy=sm(),Ay=yf,My=pf,Dy={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>My.str`must match pattern "${e}"`,params:({schemaCode:e})=>My._`{pattern: ${e}}`},code(e){const{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:n}=a.opts.code,o="new RegExp"===n.code?My._`new RegExp`:(0,Ay.useFunc)(t,n),c=t.let("valid");t.try(()=>t.assign(c,My._`${o}(${s}, ${i}).test(${r})`),()=>t.assign(c,!1)),e.fail$data(My._`!${c}`)}else{const t=(0,zy.usePattern)(e,o);e.fail$data(My._`!${t}.test(${r})`)}}};Oy.default=Dy;var Uy={};Object.defineProperty(Uy,"__esModule",{value:!0});const qy=pf,Vy={message:({keyword:e,schemaCode:t})=>qy.str`must NOT have ${"maxProperties"===e?"more":"fewer"} than ${t} properties`,params:({schemaCode:e})=>qy._`{limit: ${e}}`},Fy={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Vy,code(e){const{keyword:t,data:r,schemaCode:n}=e,o="maxProperties"===t?qy.operators.GT:qy.operators.LT;e.fail$data(qy._`Object.keys(${r}).length ${o} ${n}`)}};Uy.default=Fy;var Ly={};Object.defineProperty(Ly,"__esModule",{value:!0});const Ky=sm(),Hy=pf,Zy=yf,Gy={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>Hy.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>Hy._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:a}=e,{opts:i}=a;if(!s&&0===r.length)return;const c=r.length>=i.loopRequired;if(a.allErrors?function(){if(c||s)e.block$data(Hy.nil,u);else for(const t of r)(0,Ky.checkReportMissingProp)(e,t)}():function(){const a=t.let("missing");if(c||s){const r=t.let("valid",!0);e.block$data(r,()=>function(r,s){e.setParams({missingProperty:r}),t.forOf(r,n,()=>{t.assign(s,(0,Ky.propertyInData)(t,o,r,i.ownProperties)),t.if((0,Hy.not)(s),()=>{e.error(),t.break()})},Hy.nil)}(a,r)),e.ok(r)}else t.if((0,Ky.checkMissingProp)(e,r,a)),(0,Ky.reportMissingProp)(e,a),t.else()}(),i.strictRequired){const t=e.parentSchema.properties,{definedProperties:n}=e.it;for(const e of r)if(void 0===(null==t?void 0:t[e])&&!n.has(e)){const t=`required property "${e}" is not defined at "${a.schemaEnv.baseId+a.errSchemaPath}" (strictRequired)`;(0,Zy.checkStrictMode)(a,t,a.opts.strictRequired)}}function u(){t.forOf("prop",n,r=>{e.setParams({missingProperty:r}),t.if((0,Ky.noPropertyInData)(t,o,r,i.ownProperties),()=>e.error())})}}};Ly.default=Gy;var By={};Object.defineProperty(By,"__esModule",{value:!0});const Jy=pf,Wy={message:({keyword:e,schemaCode:t})=>Jy.str`must NOT have ${"maxItems"===e?"more":"fewer"} than ${t} items`,params:({schemaCode:e})=>Jy._`{limit: ${e}}`},Qy={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Wy,code(e){const{keyword:t,data:r,schemaCode:n}=e,o="maxItems"===t?Jy.operators.GT:Jy.operators.LT;e.fail$data(Jy._`${r}.length ${o} ${n}`)}};By.default=Qy;var Yy={},Xy={};Object.defineProperty(Xy,"__esModule",{value:!0});const eg=au;eg.code='require("ajv/dist/runtime/equal").default',Xy.default=eg,Object.defineProperty(Yy,"__esModule",{value:!0});const tg=zf,rg=pf,ng=yf,og=Xy,sg={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>rg.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>rg._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:a,it:i}=e;if(!n&&!o)return;const c=t.let("valid"),u=s.items?(0,tg.getSchemaTypes)(s.items):[];function l(n,o){const s=t.name("item"),a=(0,tg.checkDataTypes)(u,s,i.opts.strictNumbers,tg.DataType.Wrong),l=t.const("indices",rg._`{}`);t.for(rg._`;${n}--;`,()=>{t.let(s,rg._`${r}[${n}]`),t.if(a,rg._`continue`),u.length>1&&t.if(rg._`typeof ${s} == "string"`,rg._`${s} += "_"`),t.if(rg._`typeof ${l}[${s}] == "number"`,()=>{t.assign(o,rg._`${l}[${s}]`),e.error(),t.assign(c,!1).break()}).code(rg._`${l}[${s}] = ${n}`)})}function d(n,o){const s=(0,ng.useFunc)(t,og.default),a=t.name("outer");t.label(a).for(rg._`;${n}--;`,()=>t.for(rg._`${o} = ${n}; ${o}--;`,()=>t.if(rg._`${s}(${r}[${n}], ${r}[${o}])`,()=>{e.error(),t.assign(c,!1).break(a)})))}e.block$data(c,function(){const n=t.let("i",rg._`${r}.length`),o=t.let("j");e.setParams({i:n,j:o}),t.assign(c,!0),t.if(rg._`${n} > 1`,()=>(u.length>0&&!u.some(e=>"object"===e||"array"===e)?l:d)(n,o))},rg._`${a} === false`),e.ok(c)}};Yy.default=sg;var ag={};Object.defineProperty(ag,"__esModule",{value:!0});const ig=pf,cg=yf,ug=Xy,lg={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>ig._`{allowedValue: ${e}}`},code(e){const{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&"object"==typeof s?e.fail$data(ig._`!${(0,cg.useFunc)(t,ug.default)}(${r}, ${o})`):e.fail(ig._`${s} !== ${r}`)}};ag.default=lg;var dg={};Object.defineProperty(dg,"__esModule",{value:!0});const hg=pf,pg=yf,fg=Xy,mg={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>hg._`{allowedValues: ${e}}`},code(e){const{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e;if(!n&&0===o.length)throw new Error("enum must have non-empty array");const i=o.length>=a.opts.loopEnum;let c;const u=()=>null!=c?c:c=(0,pg.useFunc)(t,fg.default);let l;if(i||n)l=t.let("valid"),e.block$data(l,function(){t.assign(l,!1),t.forOf("v",s,e=>t.if(hg._`${u()}(${r}, ${e})`,()=>t.assign(l,!0).break()))});else{if(!Array.isArray(o))throw new Error("ajv implementation error");const e=t.const("vSchema",s);l=(0,hg.or)(...o.map((t,n)=>function(e,t){const n=o[t];return"object"==typeof n&&null!==n?hg._`${u()}(${r}, ${e}[${t}])`:hg._`${r} === ${n}`}(e,n)))}e.pass(l)}};dg.default=mg,Object.defineProperty(yy,"__esModule",{value:!0});const yg=ky,gg=Sy,vg=Oy,_g=Uy,wg=Ly,$g=By,bg=Yy,kg=ag,Eg=dg,Pg=[gy.default,yg.default,gg.default,vg.default,_g.default,wg.default,$g.default,bg.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},kg.default,Eg.default];yy.default=Pg;var Sg={},Tg={};Object.defineProperty(Tg,"__esModule",{value:!0}),Tg.validateAdditionalItems=void 0;const Ig=pf,xg=yf,Ng={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>Ig.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>Ig._`{limit: ${e}}`},code(e){const{parentSchema:t,it:r}=e,{items:n}=t;Array.isArray(n)?Cg(e,n):(0,xg.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas')}};function Cg(e,t){const{gen:r,schema:n,data:o,keyword:s,it:a}=e;a.items=!0;const i=r.const("len",Ig._`${o}.length`);if(!1===n)e.setParams({len:t.length}),e.pass(Ig._`${i} <= ${t.length}`);else if("object"==typeof n&&!(0,xg.alwaysValidSchema)(a,n)){const n=r.var("valid",Ig._`${i} <= ${t.length}`);r.if((0,Ig.not)(n),()=>function(n){r.forRange("i",t.length,i,t=>{e.subschema({keyword:s,dataProp:t,dataPropType:xg.Type.Num},n),a.allErrors||r.if((0,Ig.not)(n),()=>r.break())})}(n)),e.ok(n)}}Tg.validateAdditionalItems=Cg,Tg.default=Ng;var jg={},Rg={};Object.defineProperty(Rg,"__esModule",{value:!0}),Rg.validateTuple=void 0;const Og=pf,zg=yf,Ag=sm(),Mg={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return Dg(e,"additionalItems",t);r.items=!0,(0,zg.alwaysValidSchema)(r,t)||e.ok((0,Ag.validateArray)(e))}};function Dg(e,t,r=e.schema){const{gen:n,parentSchema:o,data:s,keyword:a,it:i}=e;!function(e){const{opts:n,errSchemaPath:o}=i,s=r.length,c=s===e.minItems&&(s===e.maxItems||!1===e[t]);if(n.strictTuples&&!c){const e=`"${a}" is ${s}-tuple, but minItems or maxItems/${t} are not specified or different at path "${o}"`;(0,zg.checkStrictMode)(i,e,n.strictTuples)}}(o),i.opts.unevaluated&&r.length&&!0!==i.items&&(i.items=zg.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),u=n.const("len",Og._`${s}.length`);r.forEach((t,r)=>{(0,zg.alwaysValidSchema)(i,t)||(n.if(Og._`${u} > ${r}`,()=>e.subschema({keyword:a,schemaProp:r,dataProp:r},c)),e.ok(c))})}Rg.validateTuple=Dg,Rg.default=Mg,Object.defineProperty(jg,"__esModule",{value:!0});const Ug=Rg,qg={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Ug.validateTuple)(e,"items")};jg.default=qg;var Vg={};Object.defineProperty(Vg,"__esModule",{value:!0});const Fg=pf,Lg=yf,Kg=sm(),Hg=Tg,Zg={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>Fg.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>Fg._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,(0,Lg.alwaysValidSchema)(n,t)||(o?(0,Hg.validateAdditionalItems)(e,o):e.ok((0,Kg.validateArray)(e)))}};Vg.default=Zg;var Gg={};Object.defineProperty(Gg,"__esModule",{value:!0});const Bg=pf,Jg=yf,Wg={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>void 0===t?Bg.str`must contain at least ${e} valid item(s)`:Bg.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>void 0===t?Bg._`{minContains: ${e}}`:Bg._`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;let a,i;const{minContains:c,maxContains:u}=n;s.opts.next?(a=void 0===c?1:c,i=u):a=1;const l=t.const("len",Bg._`${o}.length`);if(e.setParams({min:a,max:i}),void 0===i&&0===a)return void(0,Jg.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==i&&a>i)return(0,Jg.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),void e.fail();if((0,Jg.alwaysValidSchema)(s,r)){let t=Bg._`${l} >= ${a}`;return void 0!==i&&(t=Bg._`${t} && ${l} <= ${i}`),void e.pass(t)}s.items=!0;const d=t.name("valid");function h(){const e=t.name("_valid"),r=t.let("count",0);p(e,()=>t.if(e,()=>function(e){t.code(Bg._`${e}++`),void 0===i?t.if(Bg._`${e} >= ${a}`,()=>t.assign(d,!0).break()):(t.if(Bg._`${e} > ${i}`,()=>t.assign(d,!1).break()),1===a?t.assign(d,!0):t.if(Bg._`${e} >= ${a}`,()=>t.assign(d,!0)))}(r)))}function p(r,n){t.forRange("i",0,l,t=>{e.subschema({keyword:"contains",dataProp:t,dataPropType:Jg.Type.Num,compositeRule:!0},r),n()})}void 0===i&&1===a?p(d,()=>t.if(d,()=>t.break())):0===a?(t.let(d,!0),void 0!==i&&t.if(Bg._`${o}.length > 0`,h)):(t.let(d,!1),h()),e.result(d,()=>e.reset())}};Gg.default=Wg;var Qg={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=pf,r=yf,n=sm();e.error={message:({params:{property:e,depsCount:r,deps:n}})=>t.str`must have ${1===r?"property":"properties"} ${n} when property ${e} is present`,params:({params:{property:e,depsCount:r,deps:n,missingProperty:o}})=>t._`{property: ${e},
7
+ deps: ${n}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(e){const[t,r]=function({schema:e}){const t={},r={};for(const n in e){if("__proto__"===n)continue;(Array.isArray(e[n])?t:r)[n]=e[n]}return[t,r]}(e);s(e,t),a(e,r)}};function s(e,r=e.schema){const{gen:o,data:s,it:a}=e;if(0===Object.keys(r).length)return;const i=o.let("missing");for(const c in r){const l=r[c];if(0===l.length)continue;const u=(0,n.propertyInData)(o,s,c,a.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(", ")}),a.allErrors?o.if(u,()=>{for(const t of l)(0,n.checkReportMissingProp)(e,t)}):(o.if(t._`${u} && (${(0,n.checkMissingProp)(e,l,i)})`),(0,n.reportMissingProp)(e,i),o.else())}}function a(e,t=e.schema){const{gen:o,data:s,keyword:a,it:i}=e,c=o.name("valid");for(const l in t)(0,r.alwaysValidSchema)(i,t[l])||(o.if((0,n.propertyInData)(o,s,l,i.opts.ownProperties),()=>{const t=e.subschema({keyword:a,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>o.var(c,!0)),e.ok(c))}e.validatePropertyDeps=s,e.validateSchemaDeps=a,e.default=o}(Lh);var Hh={};Object.defineProperty(Hh,"__esModule",{value:!0});const Kh=dc(),Zh=hc,Gh={message:"property name must be valid",params:({params:e})=>Kh._`{propertyName: ${e.propertyName}}`},Bh={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Gh,code(e){const{gen:t,schema:r,data:n,it:o}=e;if((0,Zh.alwaysValidSchema)(o,r))return;const s=t.name("valid");t.forIn("key",n,r=>{e.setParams({propertyName:r}),e.subschema({keyword:"propertyNames",data:r,dataTypes:["string"],propertyName:r,compositeRule:!0},s),t.if((0,Kh.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Hh.default=Bh;var Jh={};Object.defineProperty(Jh,"__esModule",{value:!0});const Wh=tl(),Qh=dc(),Yh=xc(),Xh=hc,ep={message:"must NOT have additional properties",params:({params:e})=>Qh._`{additionalProperty: ${e.additionalProperty}}`},tp={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:ep,code(e){const{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:a}=e;if(!s)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,"all"!==c.removeAdditional&&(0,Xh.alwaysValidSchema)(a,r))return;const l=(0,Wh.allSchemaProperties)(n.properties),u=(0,Wh.allSchemaProperties)(n.patternProperties);function d(e){t.code(Qh._`delete ${o}[${e}]`)}function h(n){if("all"===c.removeAdditional||c.removeAdditional&&!1===r)d(n);else{if(!1===r)return e.setParams({additionalProperty:n}),e.error(),void(i||t.break());if("object"==typeof r&&!(0,Xh.alwaysValidSchema)(a,r)){const r=t.name("valid");"failing"===c.removeAdditional?(p(n,r,!1),t.if((0,Qh.not)(r),()=>{e.reset(),d(n)})):(p(n,r),i||t.if((0,Qh.not)(r),()=>t.break()))}}}function p(t,r,n){const o={keyword:"additionalProperties",dataProp:t,dataPropType:Xh.Type.Str};!1===n&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(o,r)}t.forIn("key",o,r=>{l.length||u.length?t.if(function(r){let o;if(l.length>8){const e=(0,Xh.schemaRefOrVal)(a,n.properties,"properties");o=(0,Wh.isOwnProperty)(t,e,r)}else o=l.length?(0,Qh.or)(...l.map(e=>Qh._`${r} === ${e}`)):Qh.nil;return u.length&&(o=(0,Qh.or)(o,...u.map(t=>Qh._`${(0,Wh.usePattern)(e,t)}.test(${r})`))),(0,Qh.not)(o)}(r),()=>h(r)):h(r)}),e.ok(Qh._`${s} === ${Yh.default.errors}`)}};Jh.default=tp;var rp={};Object.defineProperty(rp,"__esModule",{value:!0});const np=Pl(),op=tl(),sp=hc,ap=Jh,ip={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;"all"===s.opts.removeAdditional&&void 0===n.additionalProperties&&ap.default.code(new np.KeywordCxt(s,ap.default,"additionalProperties"));const a=(0,op.allSchemaProperties)(r);for(const e of a)s.definedProperties.add(e);s.opts.unevaluated&&a.length&&!0!==s.props&&(s.props=sp.mergeEvaluated.props(t,(0,sp.toHash)(a),s.props));const i=a.filter(e=>!(0,sp.alwaysValidSchema)(s,r[e]));if(0===i.length)return;const c=t.name("valid");for(const r of i)l(r)?u(r):(t.if((0,op.propertyInData)(t,o,r,s.opts.ownProperties)),u(r),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(r),e.ok(c);function l(e){return s.opts.useDefaults&&!s.compositeRule&&void 0!==r[e].default}function u(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},c)}}};rp.default=ip;var cp={};Object.defineProperty(cp,"__esModule",{value:!0});const lp=tl(),up=dc(),dp=hc,hp=hc,pp={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:a}=s,i=(0,lp.allSchemaProperties)(r),c=i.filter(e=>(0,dp.alwaysValidSchema)(s,r[e]));if(0===i.length||c.length===i.length&&(!s.opts.unevaluated||!0===s.props))return;const l=a.strictSchema&&!a.allowMatchingProperties&&o.properties,u=t.name("valid");!0===s.props||s.props instanceof up.Name||(s.props=(0,hp.evaluatedPropsToName)(t,s.props));const{props:d}=s;function h(e){for(const t in l)new RegExp(e).test(t)&&(0,dp.checkStrictMode)(s,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function p(r){t.forIn("key",n,n=>{t.if(up._`${(0,lp.usePattern)(e,r)}.test(${n})`,()=>{const o=c.includes(r);o||e.subschema({keyword:"patternProperties",schemaProp:r,dataProp:n,dataPropType:hp.Type.Str},u),s.opts.unevaluated&&!0!==d?t.assign(up._`${d}[${n}]`,!0):o||s.allErrors||t.if((0,up.not)(u),()=>t.break())})})}!function(){for(const e of i)l&&h(e),s.allErrors?p(e):(t.var(u,!0),p(e),t.if(u))}()}};cp.default=pp;var fp={};Object.defineProperty(fp,"__esModule",{value:!0});const mp=hc,yp={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,mp.alwaysValidSchema)(n,r))return void e.fail();const o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};fp.default=yp;var gp={};Object.defineProperty(gp,"__esModule",{value:!0});const vp={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:tl().validateUnion,error:{message:"must match a schema in anyOf"}};gp.default=vp;var _p={};Object.defineProperty(_p,"__esModule",{value:!0});const wp=dc(),$p=hc,bp={message:"must match exactly one schema in oneOf",params:({params:e})=>wp._`{passingSchemas: ${e.passing}}`},kp={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:bp,code(e){const{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;const s=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(function(){s.forEach((r,n)=>{let s;(0,$p.alwaysValidSchema)(o,r)?t.var(c,!0):s=e.subschema({keyword:"oneOf",schemaProp:n,compositeRule:!0},c),n>0&&t.if(wp._`${c} && ${a}`).assign(a,!1).assign(i,wp._`[${i}, ${n}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,n),s&&e.mergeEvaluated(s,wp.Name)})})}),e.result(a,()=>e.reset(),()=>e.error(!0))}};_p.default=kp;var Ep={};Object.defineProperty(Ep,"__esModule",{value:!0});const Pp=hc,Sp={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const o=t.name("valid");r.forEach((t,r)=>{if((0,Pp.alwaysValidSchema)(n,t))return;const s=e.subschema({keyword:"allOf",schemaProp:r},o);e.ok(o),e.mergeEvaluated(s)})}};Ep.default=Sp;var Tp={};Object.defineProperty(Tp,"__esModule",{value:!0});const Ip=dc(),xp=hc,Np={message:({params:e})=>Ip.str`must match "${e.ifClause}" schema`,params:({params:e})=>Ip._`{failingKeyword: ${e.ifClause}}`},Cp={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Np,code(e){const{gen:t,parentSchema:r,it:n}=e;void 0===r.then&&void 0===r.else&&(0,xp.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const o=jp(n,"then"),s=jp(n,"else");if(!o&&!s)return;const a=t.let("valid",!0),i=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(t)}(),e.reset(),o&&s){const r=t.let("ifClause");e.setParams({ifClause:r}),t.if(i,c("then",r),c("else",r))}else o?t.if(i,c("then")):t.if((0,Ip.not)(i),c("else"));function c(r,n){return()=>{const o=e.subschema({keyword:r},i);t.assign(a,i),e.mergeValidEvaluated(o,a),n?t.assign(n,Ip._`${r}`):e.setParams({ifClause:r})}}e.pass(a,()=>e.error(!0))}};function jp(e,t){const r=e.schema[t];return void 0!==r&&!(0,xp.alwaysValidSchema)(e,r)}Tp.default=Cp;var Rp={};Object.defineProperty(Rp,"__esModule",{value:!0});const Op=hc,zp={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){void 0===t.if&&(0,Op.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Rp.default=zp,Object.defineProperty(vh,"__esModule",{value:!0});const Ap=_h,Mp=Eh,Up=Ph,Dp=Rh,qp=Dh,Vp=Lh,Fp=Hh,Lp=Jh,Hp=rp,Kp=cp,Zp=fp,Gp=gp,Bp=_p,Jp=Ep,Wp=Tp,Qp=Rp;vh.default=function(e=!1){const t=[Zp.default,Gp.default,Bp.default,Jp.default,Wp.default,Qp.default,Fp.default,Lp.default,Vp.default,Hp.default,Kp.default];return e?t.push(Mp.default,Dp.default):t.push(Ap.default,Up.default),t.push(qp.default),t};var Yp={},Xp={};Object.defineProperty(Xp,"__esModule",{value:!0});const ef=dc(),tf={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>ef.str`must match format "${e}"`,params:({schemaCode:e})=>ef._`{format: ${e}}`},code(e,t){const{gen:r,data:n,$data:o,schema:s,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=i;c.validateFormats&&(o?function(){const o=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),s=r.const("fDef",ef._`${o}[${a}]`),i=r.let("fType"),l=r.let("format");r.if(ef._`typeof ${s} == "object" && !(${s} instanceof RegExp)`,()=>r.assign(i,ef._`${s}.type || "string"`).assign(l,ef._`${s}.validate`),()=>r.assign(i,ef._`"string"`).assign(l,s)),e.fail$data((0,ef.or)(!1===c.strictSchema?ef.nil:ef._`${a} && !${l}`,function(){const e=u.$async?ef._`(${s}.async ? await ${l}(${n}) : ${l}(${n}))`:ef._`${l}(${n})`,r=ef._`(typeof ${l} == "function" ? ${e} : ${l}.test(${n}))`;return ef._`${l} && ${l} !== true && ${i} === ${t} && !${r}`}()))}():function(){const o=d.formats[s];if(!o)return void function(){if(!1===c.strictSchema)return void d.logger.warn(e());throw new Error(e());function e(){return`unknown format "${s}" ignored in schema at path "${l}"`}}();if(!0===o)return;const[a,i,h]=function(e){const t=e instanceof RegExp?(0,ef.regexpCode)(e):c.code.formats?ef._`${c.code.formats}${(0,ef.getProperty)(s)}`:void 0,n=r.scopeValue("formats",{key:s,ref:e,code:t});if("object"==typeof e&&!(e instanceof RegExp))return[e.type||"string",e.validate,ef._`${n}.validate`];return["string",e,n]}(o);a===t&&e.pass(function(){if("object"==typeof o&&!(o instanceof RegExp)&&o.async){if(!u.$async)throw new Error("async format in sync schema");return ef._`await ${h}(${n})`}return"function"==typeof i?ef._`${h}(${n})`:ef._`${h}.test(${n})`}())}())}};Xp.default=tf,Object.defineProperty(Yp,"__esModule",{value:!0});const rf=[Xp.default];Yp.default=rf;var nf={};Object.defineProperty(nf,"__esModule",{value:!0}),nf.contentVocabulary=nf.metadataVocabulary=void 0,nf.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],nf.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"],Object.defineProperty(Zu,"__esModule",{value:!0});const of=cd,sf=vh,af=Yp,cf=nf,lf=[Gu.default,of.default,(0,sf.default)(),af.default,cf.metadataVocabulary,cf.contentVocabulary];Zu.default=lf;var uf,df={},hf={};Object.defineProperty(hf,"__esModule",{value:!0}),hf.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(uf||(hf.DiscrError=uf={})),Object.defineProperty(df,"__esModule",{value:!0});const pf=dc(),ff=hf,mf=jl,yf=Cl(),gf=hc,vf={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===ff.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>pf._`{error: ${e}, tag: ${r}, tagValue: ${t}}`},code(e){const{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:a}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if("string"!=typeof i)throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",pf._`${r}${(0,pf.getProperty)(i)}`);function u(r){const n=t.name("valid"),o=e.subschema({keyword:"oneOf",schemaProp:r},n);return e.mergeEvaluated(o,pf.Name),n}t.if(pf._`typeof ${l} == "string"`,()=>function(){const r=function(){var e;const t={},r=c(o);let n=!0;for(let t=0;t<a.length;t++){let o=a[t];if((null==o?void 0:o.$ref)&&!(0,gf.schemaHasRulesButRef)(o,s.self.RULES)){const e=o.$ref;if(o=mf.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,e),o instanceof mf.SchemaEnv&&(o=o.schema),void 0===o)throw new yf.default(s.opts.uriResolver,s.baseId,e)}const u=null===(e=null==o?void 0:o.properties)||void 0===e?void 0:e[i];if("object"!=typeof u)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);n=n&&(r||c(o)),l(u,t)}if(!n)throw new Error(`discriminator: "${i}" must be required`);return t;function c({required:e}){return Array.isArray(e)&&e.includes(i)}function l(e,t){if(e.const)u(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`);for(const r of e.enum)u(r,t)}}function u(e,r){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${i}" values must be unique strings`);t[e]=r}}();t.if(!1);for(const e in r)t.elseIf(pf._`${l} === ${e}`),t.assign(c,u(r[e]));t.else(),e.error(!1,{discrError:ff.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}(),()=>e.error(!1,{discrError:ff.DiscrError.Tag,tag:l,tagName:i})),e.ok(c)}};df.default=vf;var _f={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const r=ec,n=Zu,o=df,s=_f,a=["/properties"],i="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(o.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(e,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=Pl();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=dc();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=Il();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var h=Cl();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return h.default}})}(Xi,Xi.exports);var wf=Qi(Xi.exports),$f={exports:{}},bf={};!function(e){function t(e,t){return{validate:e,compare:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0,e.fullFormats={date:t(o,s),time:t(i(!0),c),"date-time":t(d(!0),h),"iso-time":t(i(),l),"iso-date-time":t(d(),p),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(e){return f.test(e)&&m.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:function(e){if(w.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}},uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:function(e){return y.lastIndex=0,y.test(e)},int32:{type:"number",validate:function(e){return Number.isInteger(e)&&e<=v&&e>=g}},int64:{type:"number",validate:function(e){return Number.isInteger(e)}},float:{type:"number",validate:_},double:{type:"number",validate:_},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,s),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,h),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,p),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);const r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(e){const t=r.exec(e);if(!t)return!1;const o=+t[1],s=+t[2],a=+t[3];return s>=1&&s<=12&&a>=1&&a<=(2===s&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(o)?29:n[s])}function s(e,t){if(e&&t)return e>t?1:e<t?-1:0}const a=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function i(e){return function(t){const r=a.exec(t);if(!r)return!1;const n=+r[1],o=+r[2],s=+r[3],i=r[4],c="-"===r[5]?-1:1,l=+(r[6]||0),u=+(r[7]||0);if(l>23||u>59||e&&!i)return!1;if(n<=23&&o<=59&&s<60)return!0;const d=o-u*c,h=n-l*c-(d<0?1:0);return(23===h||-1===h)&&(59===d||-1===d)&&s<61}}function c(e,t){if(!e||!t)return;const r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();return r&&n?r-n:void 0}function l(e,t){if(!e||!t)return;const r=a.exec(e),n=a.exec(t);return r&&n?(e=r[1]+r[2]+r[3])>(t=n[1]+n[2]+n[3])?1:e<t?-1:0:void 0}const u=/t|\s/i;function d(e){const t=i(e);return function(e){const r=e.split(u);return 2===r.length&&o(r[0])&&t(r[1])}}function h(e,t){if(!e||!t)return;const r=new Date(e).valueOf(),n=new Date(t).valueOf();return r&&n?r-n:void 0}function p(e,t){if(!e||!t)return;const[r,n]=e.split(u),[o,a]=t.split(u),i=s(r,o);return void 0!==i?i||c(n,a):void 0}const f=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;const y=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;const g=-(2**31),v=2**31-1;function _(){return!0}const w=/[^\\]\\Z/}(bf);var kf={},Ef={exports:{}},Pf={},Sf={},Tf={},If={},xf={},Nf={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function o(e,...t){const r=[e[0]];let o=0;for(;o<t.length;)i(r,t[o]),r.push(e[++o]);return new n(r)}e._Code=n,e.nil=new n(""),e._=o;const s=new n("+");function a(e,...t){const r=[l(e[0])];let o=0;for(;o<t.length;)r.push(s),i(r,t[o]),r.push(s,l(e[++o]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===s){const r=c(e[t-1],e[t+1]);if(void 0!==r){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}(r),new n(r)}function i(e,t){var o;t instanceof n?e.push(...t._items):t instanceof r?e.push(t):e.push("number"==typeof(o=t)||"boolean"==typeof o||null===o?o:l(Array.isArray(o)?o.join(","):o))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof r||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof r?void 0:`"${e}${t.slice(1)}`}function l(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=a,e.addCodeArg=i,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:a`${e}${t}`},e.stringify=function(e){return new n(l(e))},e.safeStringify=l,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):o`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(e){return new n(e.toString())}}(Nf);var Cf={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=Nf;class r extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var n;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class o{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,r;if((null===(r=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===r?void 0:r.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}e.Scope=o;class s extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=t._`.${new t.Name(r)}[${n}]`}}e.ValueScopeName=s;const a=t._`\n`;e.ValueScope=class extends o{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?a:t.nil}}get(){return this._scope}name(e){return new s(e,this._newName(e))}value(e,t){var r;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const n=this.toName(e),{prefix:o}=n,s=null!==(r=t.key)&&void 0!==r?r:t.ref;let a=this._values[o];if(a){const e=a.get(s);if(e)return e}else a=this._values[o]=new Map;a.set(s,n);const i=this._scope[o]||(this._scope[o]=[]),c=i.length;return i[c]=t.ref,n.setValue(t,{property:o,itemIndex:c}),n}getValue(e,t){const r=this._values[e];if(r)return r.get(t)}scopeRefs(e,r=this._values){return this._reduceValues(r,r=>{if(void 0===r.scopePath)throw new Error(`CodeGen: name "${r}" has no value`);return t._`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,r)}_reduceValues(o,s,a={},i){let c=t.nil;for(const l in o){const u=o[l];if(!u)continue;const d=a[l]=a[l]||new Map;u.forEach(o=>{if(d.has(o))return;d.set(o,n.Started);let a=s(o);if(a){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${o} = ${a};${this.opts._n}`}else{if(!(a=null==i?void 0:i(o)))throw new r(o);c=t._`${c}${a}${this.opts._n}`}d.set(o,n.Completed)})}return c}}}(Cf),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=Nf,r=Cf;var n=Nf;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var o=Cf;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class s{optimizeNodes(){return this}optimizeNames(e,t){return this}}class a extends s{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r}render({es5:e,_n:t}){const n=e?r.varKinds.var:this.varKind,o=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=x(this.rhs,e,t)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends s{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof t.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=x(this.rhs,e,r),this}get names(){return I(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}}class c extends i{constructor(e,t,r,n){super(e,r,n),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class l extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class u extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class d extends s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class h extends s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=x(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class p extends s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:r}=this;let n=r.length;for(;n--;){const o=r[n];o.optimizeNames(e,t)||(N(e,o.names),r.splice(n,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>T(e,t.names),{})}}class f extends p{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends p{}class y extends f{}y.kind="else";class g extends f{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new y(e):e}return t?!1===e?t instanceof g?t:t.nodes:this.nodes.length?this:new g(C(e),t instanceof g?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=x(this.condition,e,t),this}get names(){const e=super.names;return I(e,this.condition),this.else&&T(e,this.else.names),e}}g.kind="if";class v extends f{}v.kind="for";class _ extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=x(this.iteration,e,t),this}get names(){return T(super.names,this.iteration.names)}}class w extends v{constructor(e,t,r,n){super(),this.varKind=e,this.name=t,this.from=r,this.to=n}render(e){const t=e.es5?r.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${t} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){const e=I(super.names,this.from);return I(e,this.to)}}class $ extends v{constructor(e,t,r,n){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=x(this.iterable,e,t),this}get names(){return T(super.names,this.iterable.names)}}class b extends f{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}b.kind="func";class k extends p{render(e){return"return "+super.render(e)}}k.kind="return";class E extends f{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var r,n;return super.optimizeNames(e,t),null===(r=this.catch)||void 0===r||r.optimizeNames(e,t),null===(n=this.finally)||void 0===n||n.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&T(e,this.catch.names),this.finally&&T(e,this.finally.names),e}}class P extends f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}P.kind="catch";class S extends f{render(e){return"finally"+super.render(e)}}S.kind="finally";function T(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function I(e,r){return r instanceof t._CodeOrName?T(e,r.names):e}function x(e,r,n){return e instanceof t.Name?s(e):(o=e)instanceof t._Code&&o._items.some(e=>e instanceof t.Name&&1===r[e.str]&&void 0!==n[e.str])?new t._Code(e._items.reduce((e,r)=>(r instanceof t.Name&&(r=s(r)),r instanceof t._Code?e.push(...r._items):e.push(r),e),[])):e;var o;function s(e){const t=n[e.str];return void 0===t||1!==r[e.str]?e:(delete r[e.str],t)}}function N(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function C(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:t._`!${z(e)}`}e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new r.Scope({parent:e}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const r=this._extScope.value(e,t);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,n){const o=this._scope.toName(t);return void 0!==r&&n&&(this._constants[o.str]=r),this._leafNode(new a(e,o,r)),o}const(e,t,n){return this._def(r.varKinds.const,e,t,n)}let(e,t,n){return this._def(r.varKinds.let,e,t,n)}var(e,t,n){return this._def(r.varKinds.var,e,t,n)}assign(e,t,r){return this._leafNode(new i(e,t,r))}add(t,r){return this._leafNode(new c(t,e.operators.ADD,r))}code(e){return"function"==typeof e?e():e!==t.nil&&this._leafNode(new h(e)),this}object(...e){const r=["{"];for(const[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,t.addCodeArg)(r,o));return r.push("}"),new t._Code(r)}if(e,t,r){if(this._blockNode(new g(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new g(e))}else(){return this._elseNode(new y)}endIf(){return this._endBlockNode(g,y)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new _(e),t)}forRange(e,t,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.let)){const a=this._scope.toName(e);return this._for(new w(s,a,t,n),()=>o(a))}forOf(e,n,o,s=r.varKinds.const){const a=this._scope.toName(e);if(this.opts.es5){const e=n instanceof t.Name?n:this.var("_arr",n);return this.forRange("_i",0,t._`${e}.length`,r=>{this.var(a,t._`${e}[${r}]`),o(a)})}return this._for(new $("of",s,a,n),()=>o(a))}forIn(e,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,t._`Object.keys(${n})`,o);const a=this._scope.toName(e);return this._for(new $("in",s,a,n),()=>o(a))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){const t=new k;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(k)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new E;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new P(e),t(e)}return r&&(this._currNode=n.finally=new S,this.code(r)),this._endBlockNode(P,S)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-t;if(r<0||void 0!==e&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,r=t.nil,n,o){return this._blockNode(new b(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(b)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},e.not=C;const j=O(e.operators.AND);e.and=function(...e){return e.reduce(j)};const R=O(e.operators.OR);function O(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${z(r)} ${e} ${z(n)}`}function z(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(R)}}(xf);var jf={};Object.defineProperty(jf,"__esModule",{value:!0}),jf.checkStrictMode=jf.getErrorPath=jf.Type=jf.useFunc=jf.setEvaluated=jf.evaluatedPropsToName=jf.mergeEvaluated=jf.eachItem=jf.unescapeJsonPointer=jf.escapeJsonPointer=jf.escapeFragment=jf.unescapeFragment=jf.schemaRefOrVal=jf.schemaHasRulesButRef=jf.schemaHasRules=jf.checkUnknownRules=jf.alwaysValidSchema=jf.toHash=void 0;const Rf=xf,Of=Nf;function zf(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema)return;if("boolean"==typeof t)return;const o=n.RULES.keywords;for(const r in t)o[r]||Hf(e,`unknown keyword: "${r}"`)}function Af(e,t){if("boolean"==typeof e)return!e;for(const r in e)if(t[r])return!0;return!1}function Mf(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function Uf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Df({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,a,i)=>{const c=void 0===a?s:a instanceof Rf.Name?(s instanceof Rf.Name?e(o,s,a):t(o,s,a),a):s instanceof Rf.Name?(t(o,a,s),s):r(s,a);return i!==Rf.Name||c instanceof Rf.Name?c:n(o,c)}}function qf(e,t){if(!0===t)return e.var("props",!0);const r=e.var("props",Rf._`{}`);return void 0!==t&&Vf(e,r,t),r}function Vf(e,t,r){Object.keys(r).forEach(r=>e.assign(Rf._`${t}${(0,Rf.getProperty)(r)}`,!0))}jf.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},jf.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(zf(e,t),!Af(t,e.self.RULES.all))},jf.checkUnknownRules=zf,jf.schemaHasRules=Af,jf.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const r in e)if("$ref"!==r&&t.all[r])return!0;return!1},jf.schemaRefOrVal=function({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if("number"==typeof r||"boolean"==typeof r)return r;if("string"==typeof r)return Rf._`${r}`}return Rf._`${e}${t}${(0,Rf.getProperty)(n)}`},jf.unescapeFragment=function(e){return Uf(decodeURIComponent(e))},jf.escapeFragment=function(e){return encodeURIComponent(Mf(e))},jf.escapeJsonPointer=Mf,jf.unescapeJsonPointer=Uf,jf.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},jf.mergeEvaluated={props:Df({mergeNames:(e,t,r)=>e.if(Rf._`${r} !== true && ${t} !== undefined`,()=>{e.if(Rf._`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,Rf._`${r} || {}`).code(Rf._`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if(Rf._`${r} !== true`,()=>{!0===t?e.assign(r,!0):(e.assign(r,Rf._`${r} || {}`),Vf(e,r,t))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:qf}),items:Df({mergeNames:(e,t,r)=>e.if(Rf._`${r} !== true && ${t} !== undefined`,()=>e.assign(r,Rf._`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if(Rf._`${r} !== true`,()=>e.assign(r,!0===t||Rf._`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},jf.evaluatedPropsToName=qf,jf.setEvaluated=Vf;const Ff={};var Lf;function Hf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,!0===r)throw new Error(t);e.self.logger.warn(t)}}jf.useFunc=function(e,t){return e.scopeValue("func",{ref:t,code:Ff[t.code]||(Ff[t.code]=new Of._Code(t.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(Lf||(jf.Type=Lf={})),jf.getErrorPath=function(e,t,r){if(e instanceof Rf.Name){const n=t===Lf.Num;return r?n?Rf._`"[" + ${e} + "]"`:Rf._`"['" + ${e} + "']"`:n?Rf._`"/" + ${e}`:Rf._`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Rf.getProperty)(e).toString():"/"+Mf(e)},jf.checkStrictMode=Hf;var Kf,Zf,Gf,Bf={};function Jf(){if(Kf)return Bf;Kf=1,Object.defineProperty(Bf,"__esModule",{value:!0});const e=xf,t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return Bf.default=t,Bf}function Wf(){return Zf||(Zf=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=xf,r=jf,n=Jf();function o(e,r){const o=e.const("err",r);e.if(t._`${n.default.vErrors} === null`,()=>e.assign(n.default.vErrors,t._`[${o}]`),t._`${n.default.vErrors}.push(${o})`),e.code(t._`${n.default.errors}++`)}function s(e,r){const{gen:n,validateName:o,schemaEnv:s}=e;s.$async?n.throw(t._`new ${e.ValidationError}(${r})`):(n.assign(t._`${o}.errors`,r),n.return(!1))}e.keywordError={message:({keyword:e})=>t.str`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:r})=>r?t.str`"${e}" keyword must be ${r} ($data)`:t.str`"${e}" keyword is invalid ($data)`},e.reportError=function(r,n=e.keywordError,a,c){const{it:l}=r,{gen:u,compositeRule:d,allErrors:h}=l,p=i(r,n,a);(null!=c?c:d||h)?o(u,p):s(l,t._`[${p}]`)},e.reportExtraError=function(t,r=e.keywordError,a){const{it:c}=t,{gen:l,compositeRule:u,allErrors:d}=c;o(l,i(t,r,a)),u||d||s(c,n.default.vErrors)},e.resetErrorsCount=function(e,r){e.assign(n.default.errors,r),e.if(t._`${n.default.vErrors} !== null`,()=>e.if(r,()=>e.assign(t._`${n.default.vErrors}.length`,r),()=>e.assign(n.default.vErrors,null)))},e.extendErrors=function({gen:e,keyword:r,schemaValue:o,data:s,errsCount:a,it:i}){if(void 0===a)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",a,n.default.errors,a=>{e.const(c,t._`${n.default.vErrors}[${a}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,i.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${i.errSchemaPath}/${r}`),i.opts.verbose&&(e.assign(t._`${c}.schema`,o),e.assign(t._`${c}.data`,s))})};const a={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function i(e,r,o){const{createErrors:s}=e.it;return!1===s?t._`{}`:function(e,r,o={}){const{gen:s,it:i}=e,u=[c(i,o),l(e,o)];return function(e,{params:r,message:o},s){const{keyword:i,data:c,schemaValue:l,it:u}=e,{opts:d,propertyName:h,topSchemaRef:p,schemaPath:f}=u;s.push([a.keyword,i],[a.params,"function"==typeof r?r(e):r||t._`{}`]),d.messages&&s.push([a.message,"function"==typeof o?o(e):o]);d.verbose&&s.push([a.schema,l],[a.parentSchema,t._`${p}${f}`],[n.default.data,c]);h&&s.push([a.propertyName,h])}(e,r,u),s.object(...u)}(e,r,o)}function c({errorPath:e},{instancePath:o}){const s=o?t.str`${e}${(0,r.getErrorPath)(o,r.Type.Str)}`:e;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,s)]}function l({keyword:e,it:{errSchemaPath:n}},{schemaPath:o,parentSchema:s}){let i=s?n:t.str`${n}/${e}`;return o&&(i=t.str`${i}${(0,r.getErrorPath)(o,r.Type.Str)}`),[a.schemaPath,i]}}(If)),If}var Qf={},Yf={};Object.defineProperty(Yf,"__esModule",{value:!0}),Yf.getRules=Yf.isJSONType=void 0;const Xf=new Set(["string","number","integer","boolean","null","object","array"]);Yf.isJSONType=function(e){return"string"==typeof e&&Xf.has(e)},Yf.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}};var em,tm={};function rm(){if(em)return tm;function e(e,r){return r.rules.some(r=>t(e,r))}function t(e,t){var r;return void 0!==e[t.keyword]||(null===(r=t.definition.implements)||void 0===r?void 0:r.some(t=>void 0!==e[t]))}return em=1,Object.defineProperty(tm,"__esModule",{value:!0}),tm.shouldUseRule=tm.shouldUseGroup=tm.schemaHasRulesForType=void 0,tm.schemaHasRulesForType=function({schema:t,self:r},n){const o=r.RULES.types[n];return o&&!0!==o&&e(t,o)},tm.shouldUseGroup=e,tm.shouldUseRule=t,tm}Object.defineProperty(Qf,"__esModule",{value:!0}),Qf.reportTypeError=Qf.checkDataTypes=Qf.checkDataType=Qf.coerceAndCheckDataType=Qf.getJSONTypes=Qf.getSchemaTypes=Qf.DataType=void 0;const nm=Yf,om=rm(),sm=Wf(),am=xf,im=jf;var cm;function lm(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(nm.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(cm||(Qf.DataType=cm={})),Qf.getSchemaTypes=function(e){const t=lm(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},Qf.getJSONTypes=lm,Qf.coerceAndCheckDataType=function(e,t){const{gen:r,data:n,opts:o}=e,s=function(e,t){return t?e.filter(e=>um.has(e)||"array"===t&&"array"===e):[]}(t,o.coerceTypes),a=t.length>0&&!(0===s.length&&1===t.length&&(0,om.schemaHasRulesForType)(e,t[0]));if(a){const a=hm(t,n,o.strictNumbers,cm.Wrong);r.if(a,()=>{s.length?function(e,t,r){const{gen:n,data:o,opts:s}=e,a=n.let("dataType",am._`typeof ${o}`),i=n.let("coerced",am._`undefined`);"array"===s.coerceTypes&&n.if(am._`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,am._`${o}[0]`).assign(a,am._`typeof ${o}`).if(hm(t,o,s.strictNumbers),()=>n.assign(i,o)));n.if(am._`${i} !== undefined`);for(const e of r)(um.has(e)||"array"===e&&"array"===s.coerceTypes)&&c(e);function c(e){switch(e){case"string":return void n.elseIf(am._`${a} == "number" || ${a} == "boolean"`).assign(i,am._`"" + ${o}`).elseIf(am._`${o} === null`).assign(i,am._`""`);case"number":return void n.elseIf(am._`${a} == "boolean" || ${o} === null
8
+ || (${a} == "string" && ${o} && ${o} == +${o})`).assign(i,am._`+${o}`);case"integer":return void n.elseIf(am._`${a} === "boolean" || ${o} === null
9
+ || (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(i,am._`+${o}`);case"boolean":return void n.elseIf(am._`${o} === "false" || ${o} === 0 || ${o} === null`).assign(i,!1).elseIf(am._`${o} === "true" || ${o} === 1`).assign(i,!0);case"null":return n.elseIf(am._`${o} === "" || ${o} === 0 || ${o} === false`),void n.assign(i,null);case"array":n.elseIf(am._`${a} === "string" || ${a} === "number"
10
+ || ${a} === "boolean" || ${o} === null`).assign(i,am._`[${o}]`)}}n.else(),fm(e),n.endIf(),n.if(am._`${i} !== undefined`,()=>{n.assign(o,i),function({gen:e,parentData:t,parentDataProperty:r},n){e.if(am._`${t} !== undefined`,()=>e.assign(am._`${t}[${r}]`,n))}(e,i)})}(e,t,s):fm(e)})}return a};const um=new Set(["string","number","integer","boolean","null"]);function dm(e,t,r,n=cm.Correct){const o=n===cm.Correct?am.operators.EQ:am.operators.NEQ;let s;switch(e){case"null":return am._`${t} ${o} null`;case"array":s=am._`Array.isArray(${t})`;break;case"object":s=am._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=a(am._`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=a();break;default:return am._`typeof ${t} ${o} ${e}`}return n===cm.Correct?s:(0,am.not)(s);function a(e=am.nil){return(0,am.and)(am._`typeof ${t} == "number"`,e,r?am._`isFinite(${t})`:am.nil)}}function hm(e,t,r,n){if(1===e.length)return dm(e[0],t,r,n);let o;const s=(0,im.toHash)(e);if(s.array&&s.object){const e=am._`typeof ${t} != "object"`;o=s.null?e:am._`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=am.nil;s.number&&delete s.integer;for(const e in s)o=(0,am.and)(o,dm(e,t,r,n));return o}Qf.checkDataType=dm,Qf.checkDataTypes=hm;const pm={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?am._`{type: ${e}}`:am._`{type: ${t}}`};function fm(e){const t=function(e){const{gen:t,data:r,schema:n}=e,o=(0,im.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}(e);(0,sm.reportError)(t,pm)}Qf.reportTypeError=fm;var mm,ym={};var gm,vm,_m={},wm={};function $m(){if(gm)return wm;gm=1,Object.defineProperty(wm,"__esModule",{value:!0}),wm.validateUnion=wm.validateArray=wm.usePattern=wm.callValidateCode=wm.schemaProperties=wm.allSchemaProperties=wm.noPropertyInData=wm.propertyInData=wm.isOwnProperty=wm.hasPropFunc=wm.reportMissingProp=wm.checkMissingProp=wm.checkReportMissingProp=void 0;const e=xf,t=jf,r=Jf(),n=jf;function o(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:e._`Object.prototype.hasOwnProperty`})}function s(t,r,n){return e._`${o(t)}.call(${r}, ${n})`}function a(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} === undefined`;return o?(0,e.or)(a,(0,e.not)(s(t,r,n))):a}function i(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}wm.checkReportMissingProp=function(t,r){const{gen:n,data:o,it:s}=t;n.if(a(n,o,r,s.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},wm.checkMissingProp=function({gen:t,data:r,it:{opts:n}},o,s){return(0,e.or)(...o.map(o=>(0,e.and)(a(t,r,o,n.ownProperties),e._`${s} = ${o}`)))},wm.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},wm.hasPropFunc=o,wm.isOwnProperty=s,wm.propertyInData=function(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return o?e._`${a} && ${s(t,r,n)}`:a},wm.noPropertyInData=a,wm.allSchemaProperties=i,wm.schemaProperties=function(e,r){return i(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},wm.callValidateCode=function({schemaCode:t,data:n,it:{gen:o,topSchemaRef:s,schemaPath:a,errorPath:i},it:c},l,u,d){const h=d?e._`${t}, ${n}, ${s}${a}`:n,p=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,i)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const f=e._`${h}, ${o.object(...p)}`;return u!==e.nil?e._`${l}.call(${u}, ${f})`:e._`${l}(${f})`};const c=e._`new RegExp`;return wm.usePattern=function({gen:t,it:{opts:r}},o){const s=r.unicodeRegExp?"u":"",{regExp:a}=r.code,i=a(o,s);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:e._`${"new RegExp"===a.code?c:(0,n.useFunc)(t,a)}(${o}, ${s})`})},wm.validateArray=function(r){const{gen:n,data:o,keyword:s,it:a}=r,i=n.name("valid");if(a.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(i,!0),c(()=>n.break()),i;function c(a){const c=n.const("len",e._`${o}.length`);n.forRange("i",0,c,o=>{r.subschema({keyword:s,dataProp:o,dataPropType:t.Type.Num},i),n.if((0,e.not)(i),a)})}},wm.validateUnion=function(r){const{gen:n,schema:o,keyword:s,it:a}=r;if(!Array.isArray(o))throw new Error("ajv implementation error");if(o.some(e=>(0,t.alwaysValidSchema)(a,e))&&!a.opts.unevaluated)return;const i=n.let("valid",!1),c=n.name("_valid");n.block(()=>o.forEach((t,o)=>{const a=r.subschema({keyword:s,schemaProp:o,compositeRule:!0},c);n.assign(i,e._`${i} || ${c}`);r.mergeValidEvaluated(a,c)||n.if((0,e.not)(i))})),r.result(i,()=>r.reset(),()=>r.error(!0))},wm}function bm(){if(vm)return _m;vm=1,Object.defineProperty(_m,"__esModule",{value:!0}),_m.validateKeywordUsage=_m.validSchemaType=_m.funcKeywordCode=_m.macroKeywordCode=void 0;const e=xf,t=Jf(),r=$m(),n=Wf();function o(t){const{gen:r,data:n,it:o}=t;r.if(o.parentData,()=>r.assign(n,e._`${o.parentData}[${o.parentDataProperty}]`))}function s(t,r,n){if(void 0===n)throw new Error(`keyword "${r}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,e.stringify)(n)})}return _m.macroKeywordCode=function(t,r){const{gen:n,keyword:o,schema:a,parentSchema:i,it:c}=t,l=r.macro.call(c.self,a,i,c),u=s(n,o,l);!1!==c.opts.validateSchema&&c.self.validateSchema(l,!0);const d=n.name("valid");t.subschema({schema:l,schemaPath:e.nil,errSchemaPath:`${c.errSchemaPath}/${o}`,topSchemaRef:u,compositeRule:!0},d),t.pass(d,()=>t.error(!0))},_m.funcKeywordCode=function(a,i){var c;const{gen:l,keyword:u,schema:d,parentSchema:h,$data:p,it:f}=a;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(f,i);const m=!p&&i.compile?i.compile.call(f.self,d,h,f):i.validate,y=s(l,u,m),g=l.let("valid");function v(n=(i.async?e._`await `:e.nil)){const o=f.opts.passContext?t.default.this:t.default.self,s=!("compile"in i&&!p||!1===i.schema);l.assign(g,e._`${n}${(0,r.callValidateCode)(a,y,o,s)}`,i.modifying)}function _(t){var r;l.if((0,e.not)(null!==(r=i.valid)&&void 0!==r?r:g),t)}a.block$data(g,function(){if(!1===i.errors)v(),i.modifying&&o(a),_(()=>a.error());else{const r=i.async?function(){const t=l.let("ruleErrs",null);return l.try(()=>v(e._`await `),r=>l.assign(g,!1).if(e._`${r} instanceof ${f.ValidationError}`,()=>l.assign(t,e._`${r}.errors`),()=>l.throw(r))),t}():function(){const t=e._`${y}.errors`;return l.assign(t,null),v(e.nil),t}();i.modifying&&o(a),_(()=>function(r,o){const{gen:s}=r;s.if(e._`Array.isArray(${o})`,()=>{s.assign(t.default.vErrors,e._`${t.default.vErrors} === null ? ${o} : ${t.default.vErrors}.concat(${o})`).assign(t.default.errors,e._`${t.default.vErrors}.length`),(0,n.extendErrors)(r)},()=>r.error())}(a,r))}}),a.ok(null!==(c=i.valid)&&void 0!==c?c:g)},_m.validSchemaType=function(e,t,r=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||r&&void 0===e)},_m.validateKeywordUsage=function({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");const a=o.dependencies;if(null==a?void 0:a.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${s}: ${a.join(",")}`);if(o.validateSchema){if(!o.validateSchema(e[s])){const e=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);r.logger.error(e)}}},_m}var km,Em={};var Pm={},Sm={exports:{}},Tm=Sm.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),Im(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function Im(e,t,r,n,o,s,a,i,c,l){if(n&&"object"==typeof n&&!Array.isArray(n)){for(var u in t(n,o,s,a,i,c,l),n){var d=n[u];if(Array.isArray(d)){if(u in Tm.arrayKeywords)for(var h=0;h<d.length;h++)Im(e,t,r,d[h],o+"/"+u+"/"+h,s,o,u,n,h)}else if(u in Tm.propsKeywords){if(d&&"object"==typeof d)for(var p in d)Im(e,t,r,d[p],o+"/"+u+"/"+xm(p),s,o,u,n,p)}else(u in Tm.keywords||e.allKeys&&!(u in Tm.skipKeywords))&&Im(e,t,r,d,o+"/"+u,s,o,u,n)}r(n,o,s,a,i,c,l)}}function xm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}Tm.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},Tm.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},Tm.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},Tm.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};var Nm=Sm.exports;Object.defineProperty(Pm,"__esModule",{value:!0}),Pm.getSchemaRefs=Pm.resolveUrl=Pm.normalizeId=Pm._getFullPath=Pm.getFullPath=Pm.inlineRef=void 0;const Cm=jf,jm=al,Rm=Nm,Om=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);Pm.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!Am(e):!!t&&Mm(e)<=t)};const zm=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Am(e){for(const t in e){if(zm.has(t))return!0;const r=e[t];if(Array.isArray(r)&&r.some(Am))return!0;if("object"==typeof r&&Am(r))return!0}return!1}function Mm(e){let t=0;for(const r in e){if("$ref"===r)return 1/0;if(t++,!Om.has(r)&&("object"==typeof e[r]&&(0,Cm.eachItem)(e[r],e=>t+=Mm(e)),t===1/0))return 1/0}return t}function Um(e,t="",r){!1!==r&&(t=Vm(t));const n=e.parse(t);return Dm(e,n)}function Dm(e,t){return e.serialize(t).split("#")[0]+"#"}Pm.getFullPath=Um,Pm._getFullPath=Dm;const qm=/#\/?$/;function Vm(e){return e?e.replace(qm,""):""}Pm.normalizeId=Vm,Pm.resolveUrl=function(e,t,r){return r=Vm(r),e.resolve(t,r)};const Fm=/^[a-z_][-a-z0-9._]*$/i;var Lm;function Hm(){if(Lm)return Sf;Lm=1,Object.defineProperty(Sf,"__esModule",{value:!0}),Sf.getData=Sf.KeywordCxt=Sf.validateFunctionCode=void 0;const e=function(){if(Gf)return Tf;Gf=1,Object.defineProperty(Tf,"__esModule",{value:!0}),Tf.boolOrEmptySchema=Tf.topBoolOrEmptySchema=void 0;const e=Wf(),t=xf,r=Jf(),n={message:"boolean schema is false"};function o(t,r){const{gen:o,data:s}=t,a={gen:o,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(a,n,void 0,r)}return Tf.topBoolOrEmptySchema=function(e){const{gen:n,schema:s,validateName:a}=e;!1===s?o(e,!1):"object"==typeof s&&!0===s.$async?n.return(r.default.data):(n.assign(t._`${a}.errors`,null),n.return(!0))},Tf.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),o(e)):r.var(t,!0)},Tf}(),t=Qf,r=rm(),n=Qf,o=function(){if(mm)return ym;mm=1,Object.defineProperty(ym,"__esModule",{value:!0}),ym.assignDefaults=void 0;const e=xf,t=jf;function r(r,n,o){const{gen:s,compositeRule:a,data:i,opts:c}=r;if(void 0===o)return;const l=e._`${i}${(0,e.getProperty)(n)}`;if(a)return void(0,t.checkStrictMode)(r,`default is ignored for: ${l}`);let u=e._`${l} === undefined`;"empty"===c.useDefaults&&(u=e._`${u} || ${l} === null || ${l} === ""`),s.if(u,e._`${l} = ${(0,e.stringify)(o)}`)}return ym.assignDefaults=function(e,t){const{properties:n,items:o}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(o)&&o.forEach((t,n)=>r(e,n,t.default))},ym}(),s=bm(),a=function(){if(km)return Em;km=1,Object.defineProperty(Em,"__esModule",{value:!0}),Em.extendSubschemaMode=Em.extendSubschemaData=Em.getSubschema=void 0;const e=xf,t=jf;return Em.getSubschema=function(r,{keyword:n,schemaProp:o,schema:s,schemaPath:a,errSchemaPath:i,topSchemaRef:c}){if(void 0!==n&&void 0!==s)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==n){const s=r.schema[n];return void 0===o?{schema:s,schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}`,errSchemaPath:`${r.errSchemaPath}/${n}`}:{schema:s[o],schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}${(0,e.getProperty)(o)}`,errSchemaPath:`${r.errSchemaPath}/${n}/${(0,t.escapeFragment)(o)}`}}if(void 0!==s){if(void 0===a||void 0===i||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:a,topSchemaRef:c,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')},Em.extendSubschemaData=function(r,n,{dataProp:o,dataPropType:s,data:a,dataTypes:i,propertyName:c}){if(void 0!==a&&void 0!==o)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:l}=n;if(void 0!==o){const{errorPath:a,dataPathArr:i,opts:c}=n;u(l.let("data",e._`${n.data}${(0,e.getProperty)(o)}`,!0)),r.errorPath=e.str`${a}${(0,t.getErrorPath)(o,s,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${o}`,r.dataPathArr=[...i,r.parentDataProperty]}function u(e){r.data=e,r.dataLevel=n.dataLevel+1,r.dataTypes=[],n.definedProperties=new Set,r.parentData=n.data,r.dataNames=[...n.dataNames,e]}void 0!==a&&(u(a instanceof e.Name?a:l.let("data",a,!0)),void 0!==c&&(r.propertyName=c)),i&&(r.dataTypes=i)},Em.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){void 0!==n&&(e.compositeRule=n),void 0!==o&&(e.createErrors=o),void 0!==s&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r},Em}(),i=xf,c=Jf(),l=Pm,u=jf,d=Wf();function h({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,i._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(i._`"use strict"; ${p(r,o)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,i._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,i._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,i._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,i._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,i._`""`),e.var(c.default.parentData,i._`undefined`),e.var(c.default.parentDataProperty,i._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`{}`)})}(e,o),e.code(s)}):e.func(t,i._`${c.default.data}, ${function(e){return i._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?i._`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}(o)}`,n.$async,()=>e.code(p(r,o)).code(s))}function p(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?i._`/*# sourceURL=${r} */`:i.nil}function f(t,r){y(t)&&(g(t),m(t))?function(e,t){const{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&_(e);(function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,l.resolveUrl)(e.opts.uriResolver,e.baseId,t))})(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const s=n.const("_errs",c.default.errors);v(e,s),n.var(t,i._`${s} === ${c.default.errors}`)}(t,r):(0,e.boolOrEmptySchema)(t,r)}function m({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function y(e){return"boolean"!=typeof e.schema}function g(e){(0,u.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(e)}function v(e,r){if(e.opts.jtd)return w(e,[],!1,r);const n=(0,t.getSchemaTypes)(e.schema);w(e,n,!(0,t.coerceAndCheckDataType)(e,n),r)}function _({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){const s=r.$comment;if(!0===o.$comment)e.code(i._`${c.default.self}.logger.log(${s})`);else if("function"==typeof o.$comment){const r=i.str`${n}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(i._`${c.default.self}.opts.$comment(${s}, ${r}, ${o}.schema)`)}}function w(e,t,o,s){const{gen:a,schema:l,data:d,allErrors:h,opts:p,self:f}=e,{RULES:m}=f;function y(u){(0,r.shouldUseGroup)(l,u)&&(u.type?(a.if((0,n.checkDataType)(u.type,d,p.strictNumbers)),$(e,u),1===t.length&&t[0]===u.type&&o&&(a.else(),(0,n.reportTypeError)(e)),a.endIf()):$(e,u),h||a.if(i._`${c.default.errors} === ${s||0}`))}!l.$ref||!p.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(l,m)?(p.jtd||function(e,t){if(e.schemaEnv.meta||!e.opts.strictTypes)return;(function(e,t){if(!t.length)return;if(!e.dataTypes.length)return void(e.dataTypes=t);t.forEach(t=>{k(e.dataTypes,t)||E(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const r=[];for(const n of e.dataTypes)k(t,n)?r.push(n):t.includes("integer")&&"number"===n&&r.push("integer");e.dataTypes=r}(e,t)})(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&E(e,"use allowUnionTypes to allow union type keyword")}(e,t);!function(e,t){const n=e.self.RULES.all;for(const o in n){const s=n[o];if("object"==typeof s&&(0,r.shouldUseRule)(e.schema,s)){const{type:r}=s.definition;r.length&&!r.some(e=>b(t,e))&&E(e,`missing type "${r.join(",")}" for keyword "${o}"`)}}}(e,e.dataTypes)}(e,t),a.block(()=>{for(const e of m.rules)y(e);y(m.post)})):a.block(()=>S(e,"$ref",m.all.$ref.definition))}function $(e,t){const{gen:n,schema:s,opts:{useDefaults:a}}=e;a&&(0,o.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(s,n)&&S(e,n.keyword,n.definition,t.type)})}function b(e,t){return e.includes(t)||"number"===t&&e.includes("integer")}function k(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function E(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,u.checkStrictMode)(e,t,e.opts.strictTypes)}Sf.validateFunctionCode=function(t){y(t)&&(g(t),m(t))?function(e){const{schema:t,opts:r,gen:n}=e;h(e,()=>{r.$comment&&t.$comment&&_(e),function(e){const{schema:t,opts:r}=e;void 0!==t.default&&r.useDefaults&&r.strictSchema&&(0,u.checkStrictMode)(e,"default is ignored in the schema root")}(e),n.let(c.default.vErrors,null),n.let(c.default.errors,0),r.unevaluated&&function(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",i._`${r}.evaluated`),t.if(i._`${e.evaluated}.dynamicProps`,()=>t.assign(i._`${e.evaluated}.props`,i._`undefined`)),t.if(i._`${e.evaluated}.dynamicItems`,()=>t.assign(i._`${e.evaluated}.items`,i._`undefined`))}(e),v(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if(i._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(i._`new ${o}(${c.default.vErrors})`)):(t.assign(i._`${n}.errors`,c.default.vErrors),s.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof i.Name&&e.assign(i._`${t}.props`,r);n instanceof i.Name&&e.assign(i._`${t}.items`,n)}(e),t.return(i._`${c.default.errors} === 0`))}(e)})}(t):h(t,()=>(0,e.topBoolOrEmptySchema)(t))};class P{constructor(e,t,r){if((0,s.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,u.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",x(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,s.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",c.default.errors))}result(e,t,r){this.failResult((0,i.not)(e),t,r)}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,i.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(i._`${t} !== undefined && (${(0,i.or)(this.invalid$data(),e)})`)}error(e,t,r){if(t)return this.setParams(t),this._error(e,r),void this.setParams({});this._error(e,r)}_error(e,t){(e?d.reportExtraError:d.reportError)(this,this.def.error,t)}$dataError(){(0,d.reportError)(this,this.def.$dataError||d.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,d.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,r=i.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=i.nil,t=i.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:o,def:s}=this;r.if((0,i.or)(i._`${n} === undefined`,t)),e!==i.nil&&r.assign(e,!0),(o.length||s.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==i.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:o,it:s}=this;return(0,i.or)(function(){if(r.length){if(!(t instanceof i.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return i._`${(0,n.checkDataTypes)(e,t,s.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}(),function(){if(o.validateSchema){const r=e.scopeValue("validate$data",{ref:o.validateSchema});return i._`!${r}(${t})`}return i.nil}())}subschema(e,t){const r=(0,a.getSubschema)(this.it,e);(0,a.extendSubschemaData)(r,this.it,e),(0,a.extendSubschemaMode)(r,e);const n={...this.it,...r,items:void 0,props:void 0};return f(n,t),n}mergeEvaluated(e,t){const{it:r,gen:n}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==e.props&&(r.props=u.mergeEvaluated.props(n,e.props,r.props,t)),!0!==r.items&&void 0!==e.items&&(r.items=u.mergeEvaluated.items(n,e.items,r.items,t)))}mergeValidEvaluated(e,t){const{it:r,gen:n}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return n.if(t,()=>this.mergeEvaluated(e,i.Name)),!0}}function S(e,t,r,n){const o=new P(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,s.funcKeywordCode)(o,r):"macro"in r?(0,s.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,s.funcKeywordCode)(o,r)}Sf.KeywordCxt=P;const T=/^\/(?:[^~]|~0|~1)*$/,I=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(""===e)return c.default.rootData;if("/"===e[0]){if(!T.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=c.default.rootData}else{const a=I.exec(e);if(!a)throw new Error(`Invalid JSON-pointer: ${e}`);const i=+a[1];if(o=a[2],"#"===o){if(i>=t)throw new Error(d("property/index",i));return n[t-i]}if(i>t)throw new Error(d("data",i));if(s=r[t-i],!o)return s}let a=s;const l=o.split("/");for(const e of l)e&&(s=i._`${s}${(0,i.getProperty)((0,u.unescapeJsonPointer)(e))}`,a=i._`${a} && ${s}`);return a;function d(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return Sf.getData=x,Sf}Pm.getSchemaRefs=function(e,t){if("boolean"==typeof e)return{};const{schemaId:r,uriResolver:n}=this.opts,o=Vm(e[r]||t),s={"":o},a=Um(n,o,!1),i={},c=new Set;return Rm(e,{allKeys:!0},(e,t,n,o)=>{if(void 0===o)return;const d=a+t;let h=s[o];function p(t){const r=this.opts.uriResolver.resolve;if(t=Vm(h?r(h,t):t),c.has(t))throw u(t);c.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?l(e,n.schema,t):t!==Vm(d)&&("#"===t[0]?(l(e,i[t],t),i[t]=e):this.refs[t]=d),t}function f(e){if("string"==typeof e){if(!Fm.test(e))throw new Error(`invalid anchor "${e}"`);p.call(this,`#${e}`)}}"string"==typeof e[r]&&(h=p.call(this,e[r])),f.call(this,e.$anchor),f.call(this,e.$dynamicAnchor),s[t]=h}),i;function l(e,t,r){if(void 0!==t&&!jm(e,t))throw u(r)}function u(e){return new Error(`reference "${e}" resolves to more than one schema`)}};var Km,Zm={};function Gm(){if(Km)return Zm;Km=1,Object.defineProperty(Zm,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return Zm.default=e,Zm}var Bm,Jm={};function Wm(){if(Bm)return Jm;Bm=1,Object.defineProperty(Jm,"__esModule",{value:!0});const e=Pm;class t extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,e.resolveUrl)(t,r,n),this.missingSchema=(0,e.normalizeId)((0,e.getFullPath)(t,this.missingRef))}}return Jm.default=t,Jm}var Qm={};Object.defineProperty(Qm,"__esModule",{value:!0}),Qm.resolveSchema=Qm.getCompilingSchema=Qm.resolveRef=Qm.compileSchema=Qm.SchemaEnv=void 0;const Ym=xf,Xm=Gm(),ey=Jf(),ty=Pm,ry=jf,ny=Hm();class oy{constructor(e){var t;let r;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,ty.normalizeId)(null==r?void 0:r[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==r?void 0:r.$async,this.refs={}}}function sy(e){const t=iy.call(this,e);if(t)return t;const r=(0,ty.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,a=new Ym.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s});let i;e.$async&&(i=a.scopeValue("Error",{ref:Xm.default,code:Ym._`require("ajv/dist/runtime/validation_error").default`}));const c=a.scopeName("validate");e.validateName=c;const l={gen:a,allErrors:this.opts.allErrors,data:ey.default.data,parentData:ey.default.parentData,parentDataProperty:ey.default.parentDataProperty,dataNames:[ey.default.data],dataPathArr:[Ym.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,Ym.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:i,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Ym.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:Ym._`""`,opts:this.opts,self:this};let u;try{this._compilations.add(e),(0,ny.validateFunctionCode)(l),a.optimize(this.opts.code.optimize);const t=a.toString();u=`${a.scopeRefs(ey.default.scope)}return ${t}`,this.opts.code.process&&(u=this.opts.code.process(u,e));const r=new Function(`${ey.default.self}`,`${ey.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:r}),r.errors=null,r.schema=e.schema,r.schemaEnv=e,e.$async&&(r.$async=!0),!0===this.opts.code.source&&(r.source={validateName:c,validateCode:t,scopeValues:a._values}),this.opts.unevaluated){const{props:e,items:t}=l;r.evaluated={props:e instanceof Ym.Name?void 0:e,items:t instanceof Ym.Name?void 0:t,dynamicProps:e instanceof Ym.Name,dynamicItems:t instanceof Ym.Name},r.source&&(r.source.evaluated=(0,Ym.stringify)(r.evaluated))}return e.validate=r,e}catch(t){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),t}finally{this._compilations.delete(e)}}function ay(e){return(0,ty.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:sy.call(this,e)}function iy(e){for(const t of this._compilations)if(cy(t,e))return t}function cy(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function ly(e,t){let r;for(;"string"==typeof(r=this.refs[t]);)t=r;return r||this.schemas[t]||uy.call(this,e,t)}function uy(e,t){const r=this.opts.uriResolver.parse(t),n=(0,ty._getFullPath)(this.opts.uriResolver,r);let o=(0,ty.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return hy.call(this,r,e);const s=(0,ty.normalizeId)(n),a=this.refs[s]||this.schemas[s];if("string"==typeof a){const t=uy.call(this,e,a);if("object"!=typeof(null==t?void 0:t.schema))return;return hy.call(this,r,t)}if("object"==typeof(null==a?void 0:a.schema)){if(a.validate||sy.call(this,a),s===(0,ty.normalizeId)(t)){const{schema:t}=a,{schemaId:r}=this.opts,n=t[r];return n&&(o=(0,ty.resolveUrl)(this.opts.uriResolver,o,n)),new oy({schema:t,schemaId:r,root:e,baseId:o})}return hy.call(this,r,a)}}Qm.SchemaEnv=oy,Qm.compileSchema=sy,Qm.resolveRef=function(e,t,r){var n;r=(0,ty.resolveUrl)(this.opts.uriResolver,t,r);const o=e.refs[r];if(o)return o;let s=ly.call(this,e,r);if(void 0===s){const o=null===(n=e.localRefs)||void 0===n?void 0:n[r],{schemaId:a}=this.opts;o&&(s=new oy({schema:o,schemaId:a,root:e,baseId:t}))}return void 0!==s?e.refs[r]=ay.call(this,s):void 0},Qm.getCompilingSchema=iy,Qm.resolveSchema=uy;const dy=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function hy(e,{baseId:t,schema:r,root:n}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const n of e.fragment.slice(1).split("/")){if("boolean"==typeof r)return;const e=r[(0,ry.unescapeFragment)(n)];if(void 0===e)return;const o="object"==typeof(r=e)&&r[this.opts.schemaId];!dy.has(n)&&o&&(t=(0,ty.resolveUrl)(this.opts.uriResolver,t,o))}let s;if("boolean"!=typeof r&&r.$ref&&!(0,ry.schemaHasRulesButRef)(r,this.RULES)){const e=(0,ty.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=uy.call(this,n,e)}const{schemaId:a}=this.opts;return s=s||new oy({schema:r,schemaId:a,root:n,baseId:t}),s.schema!==s.root.schema?s:void 0}var py={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},fy={};Object.defineProperty(fy,"__esModule",{value:!0});const my=Hu;my.code='require("ajv/dist/runtime/uri").default',fy.default=my,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Hm();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=xf;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Gm(),o=Wm(),s=Yf,a=Qm,i=xf,c=Pm,l=Qf,u=jf,d=py,h=fy,p=(e,t)=>new RegExp(e,t);p.code="new RegExp";const f=["removeAdditional","useDefaults","coerceTypes"],m=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),y={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},g={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function v(e){var t,r,n,o,s,a,i,c,l,u,d,f,m,y,g,v,_,w,$,b,k,E,P,S,T;const I=e.strict,x=null===(t=e.code)||void 0===t?void 0:t.optimize,N=!0===x||void 0===x?1:x||0,C=null!==(n=null===(r=e.code)||void 0===r?void 0:r.regExp)&&void 0!==n?n:p,j=null!==(o=e.uriResolver)&&void 0!==o?o:h.default;return{strictSchema:null===(a=null!==(s=e.strictSchema)&&void 0!==s?s:I)||void 0===a||a,strictNumbers:null===(c=null!==(i=e.strictNumbers)&&void 0!==i?i:I)||void 0===c||c,strictTypes:null!==(u=null!==(l=e.strictTypes)&&void 0!==l?l:I)&&void 0!==u?u:"log",strictTuples:null!==(f=null!==(d=e.strictTuples)&&void 0!==d?d:I)&&void 0!==f?f:"log",strictRequired:null!==(y=null!==(m=e.strictRequired)&&void 0!==m?m:I)&&void 0!==y&&y,code:e.code?{...e.code,optimize:N,regExp:C}:{optimize:N,regExp:C},loopRequired:null!==(g=e.loopRequired)&&void 0!==g?g:200,loopEnum:null!==(v=e.loopEnum)&&void 0!==v?v:200,meta:null===(_=e.meta)||void 0===_||_,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===($=e.inlineRefs)||void 0===$||$,schemaId:null!==(b=e.schemaId)&&void 0!==b?b:"$id",addUsedSchema:null===(k=e.addUsedSchema)||void 0===k||k,validateSchema:null===(E=e.validateSchema)||void 0===E||E,validateFormats:null===(P=e.validateFormats)||void 0===P||P,unicodeRegExp:null===(S=e.unicodeRegExp)||void 0===S||S,int32range:null===(T=e.int32range)||void 0===T||T,uriResolver:j}}class _{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};const{es5:t,lines:r}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:m,es5:t,lines:r}),this.logger=function(e){if(!1===e)return S;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,s.getRules)(),w.call(this,y,e,"NOT SUPPORTED"),w.call(this,g,e,"DEPRECATED","warn"),this._metaOpts=P.call(this),e.formats&&k.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),b.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:r}=this.opts;let n=d;"id"===r&&(n={...d},n.id=n.$id,delete n.$id),t&&e&&this.addMetaSchema(n,n[r],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let r;if("string"==typeof e){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);const n=r(t);return"$async"in r||(this.errors=r.errors),n}compile(e,t){const r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return n.call(this,e,t);async function n(e,t){await s.call(this,e.$schema);const r=this._addSchema(e,t);return r.validate||a.call(this,r)}async function s(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function a(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof o.default))throw t;return i.call(this,t),await c.call(this,t.missingSchema),a.call(this,e)}}function i({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){const r=await l.call(this,e);this.refs[e]||await s.call(this,r.$schema),this.refs[e]||this.addSchema(r,e,t)}async function l(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=r(e))}finally{delete this._loading[e]}}}addSchema(e,t,r,n=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,r,n);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,n,!0),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,!0,r),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let r;if(r=e.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const n=this.validate(r,e);if(!n&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return n}getSchema(e){let t;for(;"string"==typeof(t=$.call(this,e));)e=t;if(void 0===t){const{schemaId:r}=this.opts,n=new a.SchemaEnv({schema:{},schemaId:r});if(t=a.resolveSchema.call(this,n,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=$.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0,c.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if("string"==typeof e)r=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(r=(t=e).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(I.call(this,r,t),!t)return(0,u.eachItem)(r,e=>x.call(this,e)),this;C.call(this,t);const n={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(r,0===n.type.length?e=>x.call(this,e,n):e=>n.type.forEach(t=>x.call(this,e,n,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const r of t.rules){const t=r.rules.findIndex(t=>t.keyword===e);t>=0&&r.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return e&&0!==e.length?e.map(e=>`${r}${e.instancePath} ${e.message}`).reduce((e,r)=>e+t+r):"No errors"}$dataMetaSchema(e,t){const r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const n of t){const t=n.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in r){const t=r[e];if("object"!=typeof t)continue;const{$data:n}=t.definition,s=o[e];n&&s&&(o[e]=R(s))}}return e}_removeAllSchemas(e,t){for(const r in e){const n=e[r];t&&!t.test(r)||("string"==typeof n?delete e[r]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[r]))}}_addSchema(e,t,r,n=this.opts.validateSchema,o=this.opts.addUsedSchema){let s;const{schemaId:i}=this.opts;if("object"==typeof e)s=e[i];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let l=this._cache.get(e);if(void 0!==l)return l;r=(0,c.normalizeId)(s||r);const u=c.getSchemaRefs.call(this,e,r);return l=new a.SchemaEnv({schema:e,schemaId:i,meta:t,baseId:r,localRefs:u}),this._cache.set(l.schema,l),o&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=l),n&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):a.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,e)}finally{this.opts=t}}}function w(e,t,r,n="error"){for(const o in e){const s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function $(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function b(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function k(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}}function P(){const e={...this.opts};for(const t of f)delete e[t];return e}_.ValidationError=n.default,_.MissingRefError=o.default,e.default=_;const S={log(){},warn(){},error(){}};const T=/^[a-z_$][a-z0-9_$:-]*$/i;function I(e,t){const{RULES:r}=this;if((0,u.eachItem)(e,e=>{if(r.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!T.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function x(e,t,r){var n;const o=null==t?void 0:t.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:s}=this;let a=o?s.post:s.rules.find(({type:e})=>e===r);if(a||(a={type:r,rules:[]},s.rules.push(a)),s.keywords[e]=!0,!t)return;const i={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?N.call(this,a,i,t.before):a.rules.push(i),s.all[e]=i,null===(n=t.implements)||void 0===n||n.forEach(e=>this.addKeyword(e))}function N(e,t,r){const n=e.rules.findIndex(e=>e.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function C(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=R(t)),e.validateSchema=this.compile(t,!0))}const j={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function R(e){return{anyOf:[e,j]}}}(Pf);var yy={},gy={},vy={};Object.defineProperty(vy,"__esModule",{value:!0});const _y={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};vy.default=_y;var wy={};Object.defineProperty(wy,"__esModule",{value:!0}),wy.callRef=wy.getValidate=void 0;const $y=Wm(),by=$m(),ky=xf,Ey=Jf(),Py=Qm,Sy=jf,Ty={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:a,opts:i,self:c}=n,{root:l}=s;if(("#"===r||"#/"===r)&&o===l.baseId)return function(){if(s===l)return xy(e,a,s,s.$async);const r=t.scopeValue("root",{ref:l});return xy(e,ky._`${r}.validate`,l,l.$async)}();const u=Py.resolveRef.call(c,l,o,r);if(void 0===u)throw new $y.default(n.opts.uriResolver,o,r);return u instanceof Py.SchemaEnv?function(t){const r=Iy(e,t);xy(e,r,t,t.$async)}(u):function(n){const o=t.scopeValue("schema",!0===i.code.source?{ref:n,code:(0,ky.stringify)(n)}:{ref:n}),s=t.name("valid"),a=e.subschema({schema:n,dataTypes:[],schemaPath:ky.nil,topSchemaRef:o,errSchemaPath:r},s);e.mergeEvaluated(a),e.ok(s)}(u)}};function Iy(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):ky._`${r.scopeValue("wrapper",{ref:t})}.validate`}function xy(e,t,r,n){const{gen:o,it:s}=e,{allErrors:a,schemaEnv:i,opts:c}=s,l=c.passContext?Ey.default.this:ky.nil;function u(e){const t=ky._`${e}.errors`;o.assign(Ey.default.vErrors,ky._`${Ey.default.vErrors} === null ? ${t} : ${Ey.default.vErrors}.concat(${t})`),o.assign(Ey.default.errors,ky._`${Ey.default.vErrors}.length`)}function d(e){var t;if(!s.opts.unevaluated)return;const n=null===(t=null==r?void 0:r.validate)||void 0===t?void 0:t.evaluated;if(!0!==s.props)if(n&&!n.dynamicProps)void 0!==n.props&&(s.props=Sy.mergeEvaluated.props(o,n.props,s.props));else{const t=o.var("props",ky._`${e}.evaluated.props`);s.props=Sy.mergeEvaluated.props(o,t,s.props,ky.Name)}if(!0!==s.items)if(n&&!n.dynamicItems)void 0!==n.items&&(s.items=Sy.mergeEvaluated.items(o,n.items,s.items));else{const t=o.var("items",ky._`${e}.evaluated.items`);s.items=Sy.mergeEvaluated.items(o,t,s.items,ky.Name)}}n?function(){if(!i.$async)throw new Error("async schema referenced by sync schema");const r=o.let("valid");o.try(()=>{o.code(ky._`await ${(0,by.callValidateCode)(e,t,l)}`),d(t),a||o.assign(r,!0)},e=>{o.if(ky._`!(${e} instanceof ${s.ValidationError})`,()=>o.throw(e)),u(e),a||o.assign(r,!1)}),e.ok(r)}():e.result((0,by.callValidateCode)(e,t,l),()=>d(t),()=>u(t))}wy.getValidate=Iy,wy.callRef=xy,wy.default=Ty,Object.defineProperty(gy,"__esModule",{value:!0});const Ny=wy,Cy=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",vy.default,Ny.default];gy.default=Cy;var jy={},Ry={};Object.defineProperty(Ry,"__esModule",{value:!0});const Oy=xf,zy=Oy.operators,Ay={maximum:{okStr:"<=",ok:zy.LTE,fail:zy.GT},minimum:{okStr:">=",ok:zy.GTE,fail:zy.LT},exclusiveMaximum:{okStr:"<",ok:zy.LT,fail:zy.GTE},exclusiveMinimum:{okStr:">",ok:zy.GT,fail:zy.LTE}},My={message:({keyword:e,schemaCode:t})=>Oy.str`must be ${Ay[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>Oy._`{comparison: ${Ay[e].okStr}, limit: ${t}}`},Uy={keyword:Object.keys(Ay),type:"number",schemaType:"number",$data:!0,error:My,code(e){const{keyword:t,data:r,schemaCode:n}=e;e.fail$data(Oy._`${r} ${Ay[t].fail} ${n} || isNaN(${r})`)}};Ry.default=Uy;var Dy={};Object.defineProperty(Dy,"__esModule",{value:!0});const qy=xf,Vy={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:e})=>qy.str`must be multiple of ${e}`,params:({schemaCode:e})=>qy._`{multipleOf: ${e}}`},code(e){const{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,a=t.let("res"),i=s?qy._`Math.abs(Math.round(${a}) - ${a}) > 1e-${s}`:qy._`${a} !== parseInt(${a})`;e.fail$data(qy._`(${n} === 0 || (${a} = ${r}/${n}, ${i}))`)}};Dy.default=Vy;var Fy={},Ly={};function Hy(e){const t=e.length;let r,n=0,o=0;for(;o<t;)n++,r=e.charCodeAt(o++),r>=55296&&r<=56319&&o<t&&(r=e.charCodeAt(o),56320==(64512&r)&&o++);return n}Object.defineProperty(Ly,"__esModule",{value:!0}),Ly.default=Hy,Hy.code='require("ajv/dist/runtime/ucs2length").default',Object.defineProperty(Fy,"__esModule",{value:!0});const Ky=xf,Zy=jf,Gy=Ly,By={message:({keyword:e,schemaCode:t})=>Ky.str`must NOT have ${"maxLength"===e?"more":"fewer"} than ${t} characters`,params:({schemaCode:e})=>Ky._`{limit: ${e}}`},Jy={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:By,code(e){const{keyword:t,data:r,schemaCode:n,it:o}=e,s="maxLength"===t?Ky.operators.GT:Ky.operators.LT,a=!1===o.opts.unicode?Ky._`${r}.length`:Ky._`${(0,Zy.useFunc)(e.gen,Gy.default)}(${r})`;e.fail$data(Ky._`${a} ${s} ${n}`)}};Fy.default=Jy;var Wy={};Object.defineProperty(Wy,"__esModule",{value:!0});const Qy=$m(),Yy=jf,Xy=xf,eg={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>Xy.str`must match pattern "${e}"`,params:({schemaCode:e})=>Xy._`{pattern: ${e}}`},code(e){const{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e,i=a.opts.unicodeRegExp?"u":"";if(n){const{regExp:n}=a.opts.code,o="new RegExp"===n.code?Xy._`new RegExp`:(0,Yy.useFunc)(t,n),c=t.let("valid");t.try(()=>t.assign(c,Xy._`${o}(${s}, ${i}).test(${r})`),()=>t.assign(c,!1)),e.fail$data(Xy._`!${c}`)}else{const t=(0,Qy.usePattern)(e,o);e.fail$data(Xy._`!${t}.test(${r})`)}}};Wy.default=eg;var tg={};Object.defineProperty(tg,"__esModule",{value:!0});const rg=xf,ng={message:({keyword:e,schemaCode:t})=>rg.str`must NOT have ${"maxProperties"===e?"more":"fewer"} than ${t} properties`,params:({schemaCode:e})=>rg._`{limit: ${e}}`},og={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:ng,code(e){const{keyword:t,data:r,schemaCode:n}=e,o="maxProperties"===t?rg.operators.GT:rg.operators.LT;e.fail$data(rg._`Object.keys(${r}).length ${o} ${n}`)}};tg.default=og;var sg={};Object.defineProperty(sg,"__esModule",{value:!0});const ag=$m(),ig=xf,cg=jf,lg={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>ig.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>ig._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:a}=e,{opts:i}=a;if(!s&&0===r.length)return;const c=r.length>=i.loopRequired;if(a.allErrors?function(){if(c||s)e.block$data(ig.nil,l);else for(const t of r)(0,ag.checkReportMissingProp)(e,t)}():function(){const a=t.let("missing");if(c||s){const r=t.let("valid",!0);e.block$data(r,()=>function(r,s){e.setParams({missingProperty:r}),t.forOf(r,n,()=>{t.assign(s,(0,ag.propertyInData)(t,o,r,i.ownProperties)),t.if((0,ig.not)(s),()=>{e.error(),t.break()})},ig.nil)}(a,r)),e.ok(r)}else t.if((0,ag.checkMissingProp)(e,r,a)),(0,ag.reportMissingProp)(e,a),t.else()}(),i.strictRequired){const t=e.parentSchema.properties,{definedProperties:n}=e.it;for(const e of r)if(void 0===(null==t?void 0:t[e])&&!n.has(e)){const t=`required property "${e}" is not defined at "${a.schemaEnv.baseId+a.errSchemaPath}" (strictRequired)`;(0,cg.checkStrictMode)(a,t,a.opts.strictRequired)}}function l(){t.forOf("prop",n,r=>{e.setParams({missingProperty:r}),t.if((0,ag.noPropertyInData)(t,o,r,i.ownProperties),()=>e.error())})}}};sg.default=lg;var ug={};Object.defineProperty(ug,"__esModule",{value:!0});const dg=xf,hg={message:({keyword:e,schemaCode:t})=>dg.str`must NOT have ${"maxItems"===e?"more":"fewer"} than ${t} items`,params:({schemaCode:e})=>dg._`{limit: ${e}}`},pg={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:hg,code(e){const{keyword:t,data:r,schemaCode:n}=e,o="maxItems"===t?dg.operators.GT:dg.operators.LT;e.fail$data(dg._`${r}.length ${o} ${n}`)}};ug.default=pg;var fg={},mg={};Object.defineProperty(mg,"__esModule",{value:!0});const yg=al;yg.code='require("ajv/dist/runtime/equal").default',mg.default=yg,Object.defineProperty(fg,"__esModule",{value:!0});const gg=Qf,vg=xf,_g=jf,wg=mg,$g={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:t}})=>vg.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>vg._`{i: ${e}, j: ${t}}`},code(e){const{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:a,it:i}=e;if(!n&&!o)return;const c=t.let("valid"),l=s.items?(0,gg.getSchemaTypes)(s.items):[];function u(n,o){const s=t.name("item"),a=(0,gg.checkDataTypes)(l,s,i.opts.strictNumbers,gg.DataType.Wrong),u=t.const("indices",vg._`{}`);t.for(vg._`;${n}--;`,()=>{t.let(s,vg._`${r}[${n}]`),t.if(a,vg._`continue`),l.length>1&&t.if(vg._`typeof ${s} == "string"`,vg._`${s} += "_"`),t.if(vg._`typeof ${u}[${s}] == "number"`,()=>{t.assign(o,vg._`${u}[${s}]`),e.error(),t.assign(c,!1).break()}).code(vg._`${u}[${s}] = ${n}`)})}function d(n,o){const s=(0,_g.useFunc)(t,wg.default),a=t.name("outer");t.label(a).for(vg._`;${n}--;`,()=>t.for(vg._`${o} = ${n}; ${o}--;`,()=>t.if(vg._`${s}(${r}[${n}], ${r}[${o}])`,()=>{e.error(),t.assign(c,!1).break(a)})))}e.block$data(c,function(){const n=t.let("i",vg._`${r}.length`),o=t.let("j");e.setParams({i:n,j:o}),t.assign(c,!0),t.if(vg._`${n} > 1`,()=>(l.length>0&&!l.some(e=>"object"===e||"array"===e)?u:d)(n,o))},vg._`${a} === false`),e.ok(c)}};fg.default=$g;var bg={};Object.defineProperty(bg,"__esModule",{value:!0});const kg=xf,Eg=jf,Pg=mg,Sg={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>kg._`{allowedValue: ${e}}`},code(e){const{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&"object"==typeof s?e.fail$data(kg._`!${(0,Eg.useFunc)(t,Pg.default)}(${r}, ${o})`):e.fail(kg._`${s} !== ${r}`)}};bg.default=Sg;var Tg={};Object.defineProperty(Tg,"__esModule",{value:!0});const Ig=xf,xg=jf,Ng=mg,Cg={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:e})=>Ig._`{allowedValues: ${e}}`},code(e){const{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:a}=e;if(!n&&0===o.length)throw new Error("enum must have non-empty array");const i=o.length>=a.opts.loopEnum;let c;const l=()=>null!=c?c:c=(0,xg.useFunc)(t,Ng.default);let u;if(i||n)u=t.let("valid"),e.block$data(u,function(){t.assign(u,!1),t.forOf("v",s,e=>t.if(Ig._`${l()}(${r}, ${e})`,()=>t.assign(u,!0).break()))});else{if(!Array.isArray(o))throw new Error("ajv implementation error");const e=t.const("vSchema",s);u=(0,Ig.or)(...o.map((t,n)=>function(e,t){const n=o[t];return"object"==typeof n&&null!==n?Ig._`${l()}(${r}, ${e}[${t}])`:Ig._`${r} === ${n}`}(e,n)))}e.pass(u)}};Tg.default=Cg,Object.defineProperty(jy,"__esModule",{value:!0});const jg=Dy,Rg=Fy,Og=Wy,zg=tg,Ag=sg,Mg=ug,Ug=fg,Dg=bg,qg=Tg,Vg=[Ry.default,jg.default,Rg.default,Og.default,zg.default,Ag.default,Mg.default,Ug.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Dg.default,qg.default];jy.default=Vg;var Fg={},Lg={};Object.defineProperty(Lg,"__esModule",{value:!0}),Lg.validateAdditionalItems=void 0;const Hg=xf,Kg=jf,Zg={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:e}})=>Hg.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>Hg._`{limit: ${e}}`},code(e){const{parentSchema:t,it:r}=e,{items:n}=t;Array.isArray(n)?Gg(e,n):(0,Kg.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas')}};function Gg(e,t){const{gen:r,schema:n,data:o,keyword:s,it:a}=e;a.items=!0;const i=r.const("len",Hg._`${o}.length`);if(!1===n)e.setParams({len:t.length}),e.pass(Hg._`${i} <= ${t.length}`);else if("object"==typeof n&&!(0,Kg.alwaysValidSchema)(a,n)){const n=r.var("valid",Hg._`${i} <= ${t.length}`);r.if((0,Hg.not)(n),()=>function(n){r.forRange("i",t.length,i,t=>{e.subschema({keyword:s,dataProp:t,dataPropType:Kg.Type.Num},n),a.allErrors||r.if((0,Hg.not)(n),()=>r.break())})}(n)),e.ok(n)}}Lg.validateAdditionalItems=Gg,Lg.default=Zg;var Bg={},Jg={};Object.defineProperty(Jg,"__esModule",{value:!0}),Jg.validateTuple=void 0;const Wg=xf,Qg=jf,Yg=$m(),Xg={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return ev(e,"additionalItems",t);r.items=!0,(0,Qg.alwaysValidSchema)(r,t)||e.ok((0,Yg.validateArray)(e))}};function ev(e,t,r=e.schema){const{gen:n,parentSchema:o,data:s,keyword:a,it:i}=e;!function(e){const{opts:n,errSchemaPath:o}=i,s=r.length,c=s===e.minItems&&(s===e.maxItems||!1===e[t]);if(n.strictTuples&&!c){const e=`"${a}" is ${s}-tuple, but minItems or maxItems/${t} are not specified or different at path "${o}"`;(0,Qg.checkStrictMode)(i,e,n.strictTuples)}}(o),i.opts.unevaluated&&r.length&&!0!==i.items&&(i.items=Qg.mergeEvaluated.items(n,r.length,i.items));const c=n.name("valid"),l=n.const("len",Wg._`${s}.length`);r.forEach((t,r)=>{(0,Qg.alwaysValidSchema)(i,t)||(n.if(Wg._`${l} > ${r}`,()=>e.subschema({keyword:a,schemaProp:r,dataProp:r},c)),e.ok(c))})}Jg.validateTuple=ev,Jg.default=Xg,Object.defineProperty(Bg,"__esModule",{value:!0});const tv=Jg,rv={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,tv.validateTuple)(e,"items")};Bg.default=rv;var nv={};Object.defineProperty(nv,"__esModule",{value:!0});const ov=xf,sv=jf,av=$m(),iv=Lg,cv={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>ov.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>ov._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,(0,sv.alwaysValidSchema)(n,t)||(o?(0,iv.validateAdditionalItems)(e,o):e.ok((0,av.validateArray)(e)))}};nv.default=cv;var lv={};Object.defineProperty(lv,"__esModule",{value:!0});const uv=xf,dv=jf,hv={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:e,max:t}})=>void 0===t?uv.str`must contain at least ${e} valid item(s)`:uv.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>void 0===t?uv._`{minContains: ${e}}`:uv._`{minContains: ${e}, maxContains: ${t}}`},code(e){const{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;let a,i;const{minContains:c,maxContains:l}=n;s.opts.next?(a=void 0===c?1:c,i=l):a=1;const u=t.const("len",uv._`${o}.length`);if(e.setParams({min:a,max:i}),void 0===i&&0===a)return void(0,dv.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==i&&a>i)return(0,dv.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),void e.fail();if((0,dv.alwaysValidSchema)(s,r)){let t=uv._`${u} >= ${a}`;return void 0!==i&&(t=uv._`${t} && ${u} <= ${i}`),void e.pass(t)}s.items=!0;const d=t.name("valid");function h(){const e=t.name("_valid"),r=t.let("count",0);p(e,()=>t.if(e,()=>function(e){t.code(uv._`${e}++`),void 0===i?t.if(uv._`${e} >= ${a}`,()=>t.assign(d,!0).break()):(t.if(uv._`${e} > ${i}`,()=>t.assign(d,!1).break()),1===a?t.assign(d,!0):t.if(uv._`${e} >= ${a}`,()=>t.assign(d,!0)))}(r)))}function p(r,n){t.forRange("i",0,u,t=>{e.subschema({keyword:"contains",dataProp:t,dataPropType:dv.Type.Num,compositeRule:!0},r),n()})}void 0===i&&1===a?p(d,()=>t.if(d,()=>t.break())):0===a?(t.let(d,!0),void 0!==i&&t.if(uv._`${o}.length > 0`,h)):(t.let(d,!1),h()),e.result(d,()=>e.reset())}};lv.default=hv;var pv={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=xf,r=jf,n=$m();e.error={message:({params:{property:e,depsCount:r,deps:n}})=>t.str`must have ${1===r?"property":"properties"} ${n} when property ${e} is present`,params:({params:{property:e,depsCount:r,deps:n,missingProperty:o}})=>t._`{property: ${e},
11
11
  missingProperty: ${o},
12
12
  depsCount: ${r},
13
- deps: ${n}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(e){const[t,r]=function({schema:e}){const t={},r={};for(const n in e){if("__proto__"===n)continue;(Array.isArray(e[n])?t:r)[n]=e[n]}return[t,r]}(e);s(e,t),a(e,r)}};function s(e,r=e.schema){const{gen:o,data:s,it:a}=e;if(0===Object.keys(r).length)return;const i=o.let("missing");for(const c in r){const u=r[c];if(0===u.length)continue;const l=(0,n.propertyInData)(o,s,c,a.opts.ownProperties);e.setParams({property:c,depsCount:u.length,deps:u.join(", ")}),a.allErrors?o.if(l,()=>{for(const t of u)(0,n.checkReportMissingProp)(e,t)}):(o.if(t._`${l} && (${(0,n.checkMissingProp)(e,u,i)})`),(0,n.reportMissingProp)(e,i),o.else())}}function a(e,t=e.schema){const{gen:o,data:s,keyword:a,it:i}=e,c=o.name("valid");for(const u in t)(0,r.alwaysValidSchema)(i,t[u])||(o.if((0,n.propertyInData)(o,s,u,i.opts.ownProperties),()=>{const t=e.subschema({keyword:a,schemaProp:u},c);e.mergeValidEvaluated(t,c)},()=>o.var(c,!0)),e.ok(c))}e.validatePropertyDeps=s,e.validateSchemaDeps=a,e.default=o}(Qg);var Yg={};Object.defineProperty(Yg,"__esModule",{value:!0});const Xg=pf,ev=yf,tv={message:"property name must be valid",params:({params:e})=>Xg._`{propertyName: ${e.propertyName}}`},rv={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:tv,code(e){const{gen:t,schema:r,data:n,it:o}=e;if((0,ev.alwaysValidSchema)(o,r))return;const s=t.name("valid");t.forIn("key",n,r=>{e.setParams({propertyName:r}),e.subschema({keyword:"propertyNames",data:r,dataTypes:["string"],propertyName:r,compositeRule:!0},s),t.if((0,Xg.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Yg.default=rv;var nv={};Object.defineProperty(nv,"__esModule",{value:!0});const ov=sm(),sv=pf,av=Rf(),iv=yf,cv={message:"must NOT have additional properties",params:({params:e})=>sv._`{additionalProperty: ${e.additionalProperty}}`},uv={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:cv,code(e){const{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:a}=e;if(!s)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,"all"!==c.removeAdditional&&(0,iv.alwaysValidSchema)(a,r))return;const u=(0,ov.allSchemaProperties)(n.properties),l=(0,ov.allSchemaProperties)(n.patternProperties);function d(e){t.code(sv._`delete ${o}[${e}]`)}function h(n){if("all"===c.removeAdditional||c.removeAdditional&&!1===r)d(n);else{if(!1===r)return e.setParams({additionalProperty:n}),e.error(),void(i||t.break());if("object"==typeof r&&!(0,iv.alwaysValidSchema)(a,r)){const r=t.name("valid");"failing"===c.removeAdditional?(p(n,r,!1),t.if((0,sv.not)(r),()=>{e.reset(),d(n)})):(p(n,r),i||t.if((0,sv.not)(r),()=>t.break()))}}}function p(t,r,n){const o={keyword:"additionalProperties",dataProp:t,dataPropType:iv.Type.Str};!1===n&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(o,r)}t.forIn("key",o,r=>{u.length||l.length?t.if(function(r){let o;if(u.length>8){const e=(0,iv.schemaRefOrVal)(a,n.properties,"properties");o=(0,ov.isOwnProperty)(t,e,r)}else o=u.length?(0,sv.or)(...u.map(e=>sv._`${r} === ${e}`)):sv.nil;return l.length&&(o=(0,sv.or)(o,...l.map(t=>sv._`${(0,ov.usePattern)(e,t)}.test(${r})`))),(0,sv.not)(o)}(r),()=>h(r)):h(r)}),e.ok(sv._`${s} === ${av.default.errors}`)}};nv.default=uv;var lv={};Object.defineProperty(lv,"__esModule",{value:!0});const dv=Im(),hv=sm(),pv=yf,fv=nv,mv={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;"all"===s.opts.removeAdditional&&void 0===n.additionalProperties&&fv.default.code(new dv.KeywordCxt(s,fv.default,"additionalProperties"));const a=(0,hv.allSchemaProperties)(r);for(const e of a)s.definedProperties.add(e);s.opts.unevaluated&&a.length&&!0!==s.props&&(s.props=pv.mergeEvaluated.props(t,(0,pv.toHash)(a),s.props));const i=a.filter(e=>!(0,pv.alwaysValidSchema)(s,r[e]));if(0===i.length)return;const c=t.name("valid");for(const r of i)u(r)?l(r):(t.if((0,hv.propertyInData)(t,o,r,s.opts.ownProperties)),l(r),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(r),e.ok(c);function u(e){return s.opts.useDefaults&&!s.compositeRule&&void 0!==r[e].default}function l(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},c)}}};lv.default=mv;var yv={};Object.defineProperty(yv,"__esModule",{value:!0});const gv=sm(),vv=pf,_v=yf,wv=yf,$v={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:a}=s,i=(0,gv.allSchemaProperties)(r),c=i.filter(e=>(0,_v.alwaysValidSchema)(s,r[e]));if(0===i.length||c.length===i.length&&(!s.opts.unevaluated||!0===s.props))return;const u=a.strictSchema&&!a.allowMatchingProperties&&o.properties,l=t.name("valid");!0===s.props||s.props instanceof vv.Name||(s.props=(0,wv.evaluatedPropsToName)(t,s.props));const{props:d}=s;function h(e){for(const t in u)new RegExp(e).test(t)&&(0,_v.checkStrictMode)(s,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function p(r){t.forIn("key",n,n=>{t.if(vv._`${(0,gv.usePattern)(e,r)}.test(${n})`,()=>{const o=c.includes(r);o||e.subschema({keyword:"patternProperties",schemaProp:r,dataProp:n,dataPropType:wv.Type.Str},l),s.opts.unevaluated&&!0!==d?t.assign(vv._`${d}[${n}]`,!0):o||s.allErrors||t.if((0,vv.not)(l),()=>t.break())})})}!function(){for(const e of i)u&&h(e),s.allErrors?p(e):(t.var(l,!0),p(e),t.if(l))}()}};yv.default=$v;var bv={};Object.defineProperty(bv,"__esModule",{value:!0});const kv=yf,Ev={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,kv.alwaysValidSchema)(n,r))return void e.fail();const o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};bv.default=Ev;var Pv={};Object.defineProperty(Pv,"__esModule",{value:!0});const Sv={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:sm().validateUnion,error:{message:"must match a schema in anyOf"}};Pv.default=Sv;var Tv={};Object.defineProperty(Tv,"__esModule",{value:!0});const Iv=pf,xv=yf,Nv={message:"must match exactly one schema in oneOf",params:({params:e})=>Iv._`{passingSchemas: ${e.passing}}`},Cv={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Nv,code(e){const{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;const s=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(function(){s.forEach((r,n)=>{let s;(0,xv.alwaysValidSchema)(o,r)?t.var(c,!0):s=e.subschema({keyword:"oneOf",schemaProp:n,compositeRule:!0},c),n>0&&t.if(Iv._`${c} && ${a}`).assign(a,!1).assign(i,Iv._`[${i}, ${n}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,n),s&&e.mergeEvaluated(s,Iv.Name)})})}),e.result(a,()=>e.reset(),()=>e.error(!0))}};Tv.default=Cv;var jv={};Object.defineProperty(jv,"__esModule",{value:!0});const Rv=yf,Ov={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const o=t.name("valid");r.forEach((t,r)=>{if((0,Rv.alwaysValidSchema)(n,t))return;const s=e.subschema({keyword:"allOf",schemaProp:r},o);e.ok(o),e.mergeEvaluated(s)})}};jv.default=Ov;var zv={};Object.defineProperty(zv,"__esModule",{value:!0});const Av=pf,Mv=yf,Dv={message:({params:e})=>Av.str`must match "${e.ifClause}" schema`,params:({params:e})=>Av._`{failingKeyword: ${e.ifClause}}`},Uv={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Dv,code(e){const{gen:t,parentSchema:r,it:n}=e;void 0===r.then&&void 0===r.else&&(0,Mv.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const o=qv(n,"then"),s=qv(n,"else");if(!o&&!s)return;const a=t.let("valid",!0),i=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(t)}(),e.reset(),o&&s){const r=t.let("ifClause");e.setParams({ifClause:r}),t.if(i,c("then",r),c("else",r))}else o?t.if(i,c("then")):t.if((0,Av.not)(i),c("else"));function c(r,n){return()=>{const o=e.subschema({keyword:r},i);t.assign(a,i),e.mergeValidEvaluated(o,a),n?t.assign(n,Av._`${r}`):e.setParams({ifClause:r})}}e.pass(a,()=>e.error(!0))}};function qv(e,t){const r=e.schema[t];return void 0!==r&&!(0,Mv.alwaysValidSchema)(e,r)}zv.default=Uv;var Vv={};Object.defineProperty(Vv,"__esModule",{value:!0});const Fv=yf,Lv={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){void 0===t.if&&(0,Fv.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Vv.default=Lv,Object.defineProperty(Sg,"__esModule",{value:!0});const Kv=Tg,Hv=jg,Zv=Rg,Gv=Vg,Bv=Gg,Jv=Qg,Wv=Yg,Qv=nv,Yv=lv,Xv=yv,e_=bv,t_=Pv,r_=Tv,n_=jv,o_=zv,s_=Vv;Sg.default=function(e=!1){const t=[e_.default,t_.default,r_.default,n_.default,o_.default,s_.default,Wv.default,Qv.default,Jv.default,Yv.default,Xv.default];return e?t.push(Hv.default,Gv.default):t.push(Kv.default,Zv.default),t.push(Bv.default),t};var a_={},i_={};Object.defineProperty(i_,"__esModule",{value:!0});const c_=pf,u_={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>c_.str`must match format "${e}"`,params:({schemaCode:e})=>c_._`{format: ${e}}`},code(e,t){const{gen:r,data:n,$data:o,schema:s,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=i;c.validateFormats&&(o?function(){const o=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),s=r.const("fDef",c_._`${o}[${a}]`),i=r.let("fType"),u=r.let("format");r.if(c_._`typeof ${s} == "object" && !(${s} instanceof RegExp)`,()=>r.assign(i,c_._`${s}.type || "string"`).assign(u,c_._`${s}.validate`),()=>r.assign(i,c_._`"string"`).assign(u,s)),e.fail$data((0,c_.or)(!1===c.strictSchema?c_.nil:c_._`${a} && !${u}`,function(){const e=l.$async?c_._`(${s}.async ? await ${u}(${n}) : ${u}(${n}))`:c_._`${u}(${n})`,r=c_._`(typeof ${u} == "function" ? ${e} : ${u}.test(${n}))`;return c_._`${u} && ${u} !== true && ${i} === ${t} && !${r}`}()))}():function(){const o=d.formats[s];if(!o)return void function(){if(!1===c.strictSchema)return void d.logger.warn(e());throw new Error(e());function e(){return`unknown format "${s}" ignored in schema at path "${u}"`}}();if(!0===o)return;const[a,i,h]=function(e){const t=e instanceof RegExp?(0,c_.regexpCode)(e):c.code.formats?c_._`${c.code.formats}${(0,c_.getProperty)(s)}`:void 0,n=r.scopeValue("formats",{key:s,ref:e,code:t});if("object"==typeof e&&!(e instanceof RegExp))return[e.type||"string",e.validate,c_._`${n}.validate`];return["string",e,n]}(o);a===t&&e.pass(function(){if("object"==typeof o&&!(o instanceof RegExp)&&o.async){if(!l.$async)throw new Error("async format in sync schema");return c_._`await ${h}(${n})`}return"function"==typeof i?c_._`${h}(${n})`:c_._`${h}.test(${n})`}())}())}};i_.default=u_,Object.defineProperty(a_,"__esModule",{value:!0});const l_=[i_.default];a_.default=l_;var d_={};Object.defineProperty(d_,"__esModule",{value:!0}),d_.contentVocabulary=d_.metadataVocabulary=void 0,d_.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],d_.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"],Object.defineProperty(ey,"__esModule",{value:!0});const h_=yy,p_=Sg,f_=a_,m_=d_,y_=[ty.default,h_.default,(0,p_.default)(),f_.default,m_.metadataVocabulary,m_.contentVocabulary];ey.default=y_;var g_,v_={},__={};Object.defineProperty(__,"__esModule",{value:!0}),__.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(g_||(__.DiscrError=g_={})),Object.defineProperty(v_,"__esModule",{value:!0});const w_=pf,$_=__,b_=zm,k_=Om(),E_=yf,P_={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===$_.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>w_._`{error: ${e}, tag: ${r}, tagValue: ${t}}`},code(e){const{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:a}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if("string"!=typeof i)throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),u=t.const("tag",w_._`${r}${(0,w_.getProperty)(i)}`);function l(r){const n=t.name("valid"),o=e.subschema({keyword:"oneOf",schemaProp:r},n);return e.mergeEvaluated(o,w_.Name),n}t.if(w_._`typeof ${u} == "string"`,()=>function(){const r=function(){var e;const t={},r=c(o);let n=!0;for(let t=0;t<a.length;t++){let o=a[t];if((null==o?void 0:o.$ref)&&!(0,E_.schemaHasRulesButRef)(o,s.self.RULES)){const e=o.$ref;if(o=b_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,e),o instanceof b_.SchemaEnv&&(o=o.schema),void 0===o)throw new k_.default(s.opts.uriResolver,s.baseId,e)}const l=null===(e=null==o?void 0:o.properties)||void 0===e?void 0:e[i];if("object"!=typeof l)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);n=n&&(r||c(o)),u(l,t)}if(!n)throw new Error(`discriminator: "${i}" must be required`);return t;function c({required:e}){return Array.isArray(e)&&e.includes(i)}function u(e,t){if(e.const)l(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`);for(const r of e.enum)l(r,t)}}function l(e,r){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${i}" values must be unique strings`);t[e]=r}}();t.if(!1);for(const e in r)t.elseIf(w_._`${u} === ${e}`),t.assign(c,l(r[e]));t.else(),e.error(!1,{discrError:$_.DiscrError.Mapping,tag:u,tagName:i}),t.endIf()}(),()=>e.error(!1,{discrError:$_.DiscrError.Tag,tag:u,tagName:i})),e.ok(c)}};v_.default=P_;var S_={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const r=uf,n=ey,o=v_,s=S_,a=["/properties"],i="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(o.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(e,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var u=Im();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var l=pf;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return l._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return l.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return l.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return l.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return l.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return l.CodeGen}});var d=Cm();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var h=Om();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return h.default}})}(cf,cf.exports);var T_=cf.exports;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=T_,r=pf,n=r.operators,o={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},s={message:({keyword:e,schemaCode:t})=>r.str`should be ${o[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>r._`{comparison: ${o[e].okStr}, limit: ${t}}`};e.formatLimitDefinition={keyword:Object.keys(o),type:"string",schemaType:"string",$data:!0,error:s,code(e){const{gen:n,data:s,schemaCode:a,keyword:i,it:c}=e,{opts:u,self:l}=c;if(!u.validateFormats)return;const d=new t.KeywordCxt(c,l.RULES.all.format.definition,"format");function h(e){return r._`${e}.compare(${s}, ${a}) ${o[i].fail} 0`}d.$data?function(){const t=n.scopeValue("formats",{ref:l.formats,code:u.code.formats}),o=n.const("fmt",r._`${t}[${d.schemaCode}]`);e.fail$data((0,r.or)(r._`typeof ${o} != "object"`,r._`${o} instanceof RegExp`,r._`typeof ${o}.compare != "function"`,h(o)))}():function(){const t=d.schema,o=l.formats[t];if(!o||!0===o)return;if("object"!=typeof o||o instanceof RegExp||"function"!=typeof o.compare)throw new Error(`"${i}": format "${t}" does not define "compare" function`);const s=n.scopeValue("formats",{key:t,ref:o,code:u.code.formats?r._`${u.code.formats}${(0,r.getProperty)(t)}`:void 0});e.fail$data(h(s))}()},dependencies:["format"]};e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)}(af),function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=sf,n=af,o=pf,s=new o.Name("fullFormats"),a=new o.Name("fastFormats"),i=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,r.fullFormats,s),e;const[o,i]="fast"===t.mode?[r.fastFormats,a]:[r.fullFormats,s];return c(e,t.formats||r.formatNames,o,i),t.keywords&&(0,n.default)(e),e};function c(e,t,r,n){var s,a;null!==(s=(a=e.opts.code).formats)&&void 0!==s||(a.formats=o._`require("ajv-formats/dist/formats").${n}`);for(const n of t)e.addFormat(n,r[n])}i.get=(e,t="full")=>{const n=("fast"===t?r.fastFormats:r.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n},e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}(of,of.exports);var I_=Qi(of.exports);class x_{constructor(e){this._ajv=e??function(){const e=new nf({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return I_(e),e}()}getValidator(e){const t="$id"in e&&"string"==typeof e.$id?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class N_{constructor(e){this._client=e}async*callToolStream(e,t=Xa,r){const n=this._client,o={...r,task:r?.task??(n.isToolTask(e.name)?{}:void 0)},s=n.requestStream({method:"tools/call",params:e},t,o),a=n.getToolOutputValidator(e.name);for await(const t of s){if("result"===t.type&&a){const r=t.result;if(!r.structuredContent&&!r.isError)return void(yield{type:"error",error:new Ki(Ps.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)});if(r.structuredContent)try{const e=a(r.structuredContent);if(!e.valid)return void(yield{type:"error",error:new Ki(Ps.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)})}catch(e){return e instanceof Ki?void(yield{type:"error",error:e}):void(yield{type:"error",error:new Ki(Ps.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)})}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,r){return this._client.getTaskResult({taskId:e},t,r)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,r){return this._client.requestStream(e,t,r)}}function C_(e,t){if(e&&null!==t&&"object"==typeof t){if("object"===e.type&&e.properties&&"object"==typeof e.properties){const r=t,n=e.properties;for(const e of Object.keys(n)){const t=n[e];void 0===r[e]&&Object.prototype.hasOwnProperty.call(t,"default")&&(r[e]=t.default),void 0!==r[e]&&C_(t,r[e])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)"boolean"!=typeof r&&C_(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)"boolean"!=typeof r&&C_(r,t)}}class j_ extends Ji{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new x_,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",ri,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Ga,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Sa,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new N_(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function(e,t){const r={...e};for(const e in t){const n=e,o=t[n];if(void 0===o)continue;const s=r[n];Wi(s)&&Wi(o)?r[n]={...s,...o}:r[n]=o}return r}(this._capabilities,e)}setRequestHandler(e,t){const r=Pn(e),n=r?.method;if(!n)throw new Error("Schema is missing a method literal");let o;if(kn(n)){const e=n,t=e._zod?.def;o=t?.value??e.value}else{const e=n,t=e._def;o=t?.value??e.value}if("string"!=typeof o)throw new Error("Schema method literal must be a string");const s=o;if("elicitation/create"===s){const r=async(e,r)=>{const n=En(Ci,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new Ki(Ps.InvalidParams,`Invalid elicitation request: ${e}`)}const{params:o}=n.data;o.mode=o.mode??"form";const{supportsFormMode:s,supportsUrlMode:a}=function(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};const t=void 0!==e.form,r=void 0!==e.url;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}(this._capabilities.elicitation);if("form"===o.mode&&!s)throw new Ki(Ps.InvalidParams,"Client does not support form-mode elicitation requests");if("url"===o.mode&&!a)throw new Ki(Ps.InvalidParams,"Client does not support URL-mode elicitation requests");const i=await Promise.resolve(t(e,r));if(o.task){const e=En(ea,i);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new Ki(Ps.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const c=En(Oi,i);if(!c.success){const e=c.error instanceof Error?c.error.message:String(c.error);throw new Ki(Ps.InvalidParams,`Invalid elicitation result: ${e}`)}const u=c.data,l="form"===o.mode?o.requestedSchema:void 0;if("form"===o.mode&&"accept"===u.action&&u.content&&l&&this._capabilities.elicitation?.form?.applyDefaults)try{C_(l,u.content)}catch{}return u};return super.setRequestHandler(e,r)}if("sampling/createMessage"===s){const r=async(e,r)=>{const n=En(gi,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new Ki(Ps.InvalidParams,`Invalid sampling request: ${e}`)}const{params:o}=n.data,s=await Promise.resolve(t(e,r));if(o.task){const e=En(ea,s);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new Ki(Ps.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const a=En(o.tools||o.toolChoice?_i:vi,s);if(!a.success){const e=a.error instanceof Error?a.error.message:String(a.error);throw new Ki(Ps.InvalidParams,`Invalid sampling result: ${e}`)}return a.data};return super.setRequestHandler(e,r)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),void 0===e.sessionId)try{const r=await this.request({method:"initialize",params:{protocolVersion:rs,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ls,t);if(void 0===r)throw new Error(`Server sent invalid initialize result: ${r}`);if(!ns.includes(r.protocolVersion))throw new Error(`Server's protocol version is not supported: ${r.protocolVersion}`);this._serverCapabilities=r.capabilities,this._serverVersion=r.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(r.protocolVersion),this._instructions=r.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if("resources/subscribe"===e&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if("notifications/roots/list_changed"===e)if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){!function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);if("tools/call"===t&&!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`)}(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`)}}(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Is,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Ui,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},Is,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Za,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},Aa,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},_a,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},$a,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Pa,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},Is,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},Is,t)}async callTool(e,t=Xa,r){if(this.isToolTaskRequired(e.name))throw new Ki(Ps.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const n=await this.request({method:"tools/call",params:e},t,r),o=this.getToolOutputValidator(e.name);if(o){if(!n.structuredContent&&!n.isError)throw new Ki(Ps.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(n.structuredContent)try{const e=o(n.structuredContent);if(!e.valid)throw new Ki(Ps.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){if(e instanceof Ki)throw e;throw new Ki(Ps.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return n}isToolTask(e){return!!this._serverCapabilities?.tasks?.requests?.tools?.call&&this._cachedKnownTaskTools.has(e)}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}const e=t.execution?.taskSupport;"required"!==e&&"optional"!==e||this._cachedKnownTaskTools.add(t.name),"required"===e&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const r=await this.request({method:"tools/list",params:e},Ya,t);return this.cacheToolMetadata(r.tools),r}_setupListChangedHandler(e,t,r,n){const o=ni.safeParse(r);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if("function"!=typeof r.onChanged)throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:s,debounceMs:a}=o.data,{onChanged:i}=r,c=async()=>{if(s)try{const e=await n();i(null,e)}catch(e){const t=e instanceof Error?e:new Error(String(e));i(t,null)}else i(null,null)};this.setNotificationHandler(t,()=>{if(a){const t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);const r=setTimeout(c,a);this._listChangedDebounceTimers.set(e,r)}else c()})}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}function R_(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}const O_=pn(Gn,z_).superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ts,message:"URL must be parseable",fatal:!0}),Pe}).refine(e=>{const t=new URL(e);return"javascript:"!==t.protocol&&"data:"!==t.protocol&&"vbscript:"!==t.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"});var z_;const A_=To({resource:Fn().url(),authorization_servers:Eo(O_).optional(),jwks_uri:Fn().url().optional(),scopes_supported:Eo(Fn()).optional(),bearer_methods_supported:Eo(Fn()).optional(),resource_signing_alg_values_supported:Eo(Fn()).optional(),resource_name:Fn().optional(),resource_documentation:Fn().optional(),resource_policy_uri:Fn().url().optional(),resource_tos_uri:Fn().url().optional(),tls_client_certificate_bound_access_tokens:mo().optional(),authorization_details_types_supported:Eo(Fn()).optional(),dpop_signing_alg_values_supported:Eo(Fn()).optional(),dpop_bound_access_tokens_required:mo().optional()}),M_=To({issuer:Fn(),authorization_endpoint:O_,token_endpoint:O_,registration_endpoint:O_.optional(),scopes_supported:Eo(Fn()).optional(),response_types_supported:Eo(Fn()),response_modes_supported:Eo(Fn()).optional(),grant_types_supported:Eo(Fn()).optional(),token_endpoint_auth_methods_supported:Eo(Fn()).optional(),token_endpoint_auth_signing_alg_values_supported:Eo(Fn()).optional(),service_documentation:O_.optional(),revocation_endpoint:O_.optional(),revocation_endpoint_auth_methods_supported:Eo(Fn()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Eo(Fn()).optional(),introspection_endpoint:Fn().optional(),introspection_endpoint_auth_methods_supported:Eo(Fn()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Eo(Fn()).optional(),code_challenge_methods_supported:Eo(Fn()).optional(),client_id_metadata_document_supported:mo().optional()}),D_=So({...To({issuer:Fn(),authorization_endpoint:O_,token_endpoint:O_,userinfo_endpoint:O_.optional(),jwks_uri:O_,registration_endpoint:O_.optional(),scopes_supported:Eo(Fn()).optional(),response_types_supported:Eo(Fn()),response_modes_supported:Eo(Fn()).optional(),grant_types_supported:Eo(Fn()).optional(),acr_values_supported:Eo(Fn()).optional(),subject_types_supported:Eo(Fn()),id_token_signing_alg_values_supported:Eo(Fn()),id_token_encryption_alg_values_supported:Eo(Fn()).optional(),id_token_encryption_enc_values_supported:Eo(Fn()).optional(),userinfo_signing_alg_values_supported:Eo(Fn()).optional(),userinfo_encryption_alg_values_supported:Eo(Fn()).optional(),userinfo_encryption_enc_values_supported:Eo(Fn()).optional(),request_object_signing_alg_values_supported:Eo(Fn()).optional(),request_object_encryption_alg_values_supported:Eo(Fn()).optional(),request_object_encryption_enc_values_supported:Eo(Fn()).optional(),token_endpoint_auth_methods_supported:Eo(Fn()).optional(),token_endpoint_auth_signing_alg_values_supported:Eo(Fn()).optional(),display_values_supported:Eo(Fn()).optional(),claim_types_supported:Eo(Fn()).optional(),claims_supported:Eo(Fn()).optional(),service_documentation:Fn().optional(),claims_locales_supported:Eo(Fn()).optional(),ui_locales_supported:Eo(Fn()).optional(),claims_parameter_supported:mo().optional(),request_parameter_supported:mo().optional(),request_uri_parameter_supported:mo().optional(),require_request_uri_registration:mo().optional(),op_policy_uri:O_.optional(),op_tos_uri:O_.optional(),client_id_metadata_document_supported:mo().optional()}).shape,...M_.pick({code_challenge_methods_supported:!0}).shape}),U_=So({access_token:Fn(),id_token:Fn().optional(),token_type:Fn(),expires_in:function(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...Ke(t)})}(uo,e)}().optional(),scope:Fn().optional(),refresh_token:Fn().optional()}).strip(),q_=So({error:Fn(),error_description:Fn().optional(),error_uri:Fn().optional()}),V_=O_.optional().or(Uo("").transform(()=>{})),F_=So({redirect_uris:Eo(O_),token_endpoint_auth_method:Fn().optional(),grant_types:Eo(Fn()).optional(),response_types:Eo(Fn()).optional(),client_name:Fn().optional(),client_uri:O_.optional(),logo_uri:V_,scope:Fn().optional(),contacts:Eo(Fn()).optional(),tos_uri:V_,policy_uri:Fn().optional(),jwks_uri:O_.optional(),jwks:new vo({type:"any"}).optional(),software_id:Fn().optional(),software_version:Fn().optional(),software_statement:Fn().optional()}).strip(),L_=So({client_id:Fn(),client_secret:Fn().optional(),client_id_issued_at:lo().optional(),client_secret_expires_at:lo().optional()}).strip(),K_=F_.merge(L_);So({error:Fn(),error_description:Fn().optional()}).strip(),So({token:Fn(),token_type_hint:Fn().optional()}).strip();class H_ extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){const e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}}class Z_ extends H_{}Z_.errorCode="invalid_request";class G_ extends H_{}G_.errorCode="invalid_client";class B_ extends H_{}B_.errorCode="invalid_grant";class J_ extends H_{}J_.errorCode="unauthorized_client";class W_ extends H_{}W_.errorCode="unsupported_grant_type";class Q_ extends H_{}Q_.errorCode="invalid_scope";class Y_ extends H_{}Y_.errorCode="access_denied";class X_ extends H_{}X_.errorCode="server_error";class ew extends H_{}ew.errorCode="temporarily_unavailable";class tw extends H_{}tw.errorCode="unsupported_response_type";class rw extends H_{}rw.errorCode="unsupported_token_type";class nw extends H_{}nw.errorCode="invalid_token";class ow extends H_{}ow.errorCode="method_not_allowed";class sw extends H_{}sw.errorCode="too_many_requests";class aw extends H_{}aw.errorCode="invalid_client_metadata";class iw extends H_{}iw.errorCode="insufficient_scope";class cw extends H_{}cw.errorCode="invalid_target";const uw={[Z_.errorCode]:Z_,[G_.errorCode]:G_,[B_.errorCode]:B_,[J_.errorCode]:J_,[W_.errorCode]:W_,[Q_.errorCode]:Q_,[Y_.errorCode]:Y_,[X_.errorCode]:X_,[ew.errorCode]:ew,[tw.errorCode]:tw,[rw.errorCode]:rw,[nw.errorCode]:nw,[ow.errorCode]:ow,[sw.errorCode]:sw,[aw.errorCode]:aw,[iw.errorCode]:iw,[cw.errorCode]:cw};class lw extends Error{constructor(e){super(e??"Unauthorized")}}const dw="code",hw="S256";function pw(e,t,r,n){const{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":return void function(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");const n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}(o,s,r);case"client_secret_post":return void function(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}(o,s,n);case"none":return void function(e,t){t.set("client_id",e)}(o,n);default:throw new Error(`Unsupported client authentication method: ${e}`)}}async function fw(e){const t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{const e=q_.parse(JSON.parse(r)),{error:t,error_description:n,error_uri:o}=e;return new(uw[t]||X_)(n||"",o)}catch(e){return new X_(`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${e}. Raw body: ${r}`)}}async function mw(e,t){try{return await yw(e,t)}catch(r){if(r instanceof G_||r instanceof J_)return await(e.invalidateCredentials?.("all")),await yw(e,t);if(r instanceof B_)return await(e.invalidateCredentials?.("tokens")),await yw(e,t);throw r}}async function yw(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let a,i;try{a=await async function(e,t,r=fetch){const n=await async function(e,t,r,n){const o=new URL(e),s=n?.protocolVersion??rs;let a;if(n?.metadataUrl)a=new URL(n.metadataUrl);else{const e=function(e,t="",r={}){t.endsWith("/")&&(t=t.slice(0,-1));return r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}(t,o.pathname);a=new URL(e,n?.metadataServerUrl??o),a.search=o.search}let i=await ww(a,s,r);if(!n?.metadataUrl&&function(e,t){return!e||e.status>=400&&e.status<500&&"/"!==t}(i,o.pathname)){const e=new URL(`/.well-known/${t}`,o);i=await ww(e,s,r)}return i}(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||404===n.status)throw await(n?.body?.cancel()),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await(n.body?.cancel()),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return A_.parse(await n.json())}(t,{resourceMetadataUrl:o},s),a.authorization_servers&&a.authorization_servers.length>0&&(i=a.authorization_servers[0])}catch{}i||(i=new URL("/",t));const c=await async function(e,t,r){const n=function(e){const t="string"==typeof e?new URL(e):new URL(e.href);return t.hash="",t}(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(!r)return;if(!function({requestedResource:e,configuredResource:t}){const r="string"==typeof e?new URL(e):new URL(e.href),n="string"==typeof t?new URL(t):new URL(t.href);if(r.origin!==n.origin)return!1;if(r.pathname.length<n.pathname.length)return!1;const o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return o.startsWith(s)}({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}(t,e,a),u=await async function(e,{fetchFn:t=fetch,protocolVersion:r=rs}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},o=function(e){const t="string"==typeof e?new URL(e):e,r="/"!==t.pathname,n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let o=t.pathname;o.endsWith("/")&&(o=o.slice(0,-1));return n.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${o}`,t.origin),type:"oidc"}),n.push({url:new URL(`${o}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}(e);for(const{url:e,type:r}of o){const o=await _w(e,n,t);if(o){if(!o.ok){if(await(o.body?.cancel()),o.status>=400&&o.status<500)continue;throw new Error(`HTTP ${o.status} trying to load ${"oauth"===r?"OAuth":"OpenID provider"} metadata from ${e}`)}return"oauth"===r?M_.parse(await o.json()):D_.parse(await o.json())}}return}(i,{fetchFn:s});let l=await Promise.resolve(e.clientInformation());if(!l){if(void 0!==r)throw new Error("Existing OAuth client information is required when exchanging an authorization code");const t=!0===u?.client_id_metadata_document_supported,n=e.clientMetadataUrl;if(n&&!function(e){if(!e)return!1;try{const t=new URL(e);return"https:"===t.protocol&&"/"!==t.pathname}catch{return!1}}(n))throw new aw(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${n}`);if(t&&n)l={client_id:n},await(e.saveClientInformation?.(l));else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const t=await async function(e,{metadata:t,clientMetadata:r,fetchFn:n}){let o;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");o=new URL(t.registration_endpoint)}else o=new URL("/register",e);const s=await(n??fetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw await fw(s);return K_.parse(await s.json())}(i,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:s});await e.saveClientInformation(t),l=t}}const d=!e.redirectUrl;if(void 0!==r||d){const t=await async function(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){const a=e.clientMetadata.scope;let i;e.prepareTokenRequest&&(i=await e.prepareTokenRequest(a));if(!i){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");i=function(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}(o,await e.codeVerifier(),e.redirectUrl)}const c=await e.clientInformation();return $w(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}(e,i,{metadata:u,resource:c,authorizationCode:r,fetchFn:s});return await e.saveTokens(t),"AUTHORIZED"}const h=await e.tokens();if(h?.refresh_token)try{const t=await async function(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:a}){const i=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await $w(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:a});return{refresh_token:n,...c}}(i,{metadata:u,clientInformation:l,refreshToken:h.refresh_token,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await e.saveTokens(t),"AUTHORIZED"}catch(e){if(e instanceof H_&&!(e instanceof X_))throw e}const f=e.state?await e.state():void 0,{authorizationUrl:m,codeVerifier:y}=await async function(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:a}){let i;if(t){if(i=new URL(t.authorization_endpoint),!t.response_types_supported.includes(dw))throw new Error(`Incompatible auth server: does not support response type ${dw}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(hw))throw new Error(`Incompatible auth server: does not support code challenge method ${hw}`)}else i=new URL("/authorize",e);const c=await p(),u=c.code_verifier,l=c.code_challenge;i.searchParams.set("response_type",dw),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",l),i.searchParams.set("code_challenge_method",hw),i.searchParams.set("redirect_uri",String(n)),s&&i.searchParams.set("state",s);o&&i.searchParams.set("scope",o);o?.includes("offline_access")&&i.searchParams.append("prompt","consent");a&&i.searchParams.set("resource",a.href);return{authorizationUrl:i,codeVerifier:u}}(i,{metadata:u,clientInformation:l,state:f,redirectUrl:e.redirectUrl,scope:n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,resource:c});return await e.saveCodeVerifier(y),await e.redirectToAuthorization(m),"REDIRECT"}function gw(e){const t=e.headers.get("WWW-Authenticate");if(!t)return{};const[r,n]=t.split(" ");if("bearer"!==r.toLowerCase()||!n)return{};const o=vw(e,"resource_metadata")||void 0;let s;if(o)try{s=new URL(o)}catch{}return{resourceMetadataUrl:s,scope:vw(e,"scope")||void 0,error:vw(e,"error")||void 0}}function vw(e,t){const r=e.headers.get("WWW-Authenticate");if(!r)return null;const n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function _w(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?_w(e,void 0,r):void 0;throw n}}async function ww(e,t,r=fetch){const n={"MCP-Protocol-Version":t};return await _w(e,n,r)}async function $w(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,resource:s,fetchFn:a}){const i=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",s.href),o)await o(c,r,i,t);else if(n){const e=function(e,t){const r=void 0!==e.client_secret;return 0===t.length?r?"client_secret_post":"none":"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&(n=e.token_endpoint_auth_method,["client_secret_basic","client_secret_post","none"].includes(n))&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none";var n}(n,t?.token_endpoint_auth_methods_supported??[]);pw(e,n,c,r)}const u=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!u.ok)throw await fw(u);return U_.parse(await u.json())}class bw extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function kw(e){}function Ew(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=kw,onError:r=kw,onRetry:n=kw,onComment:o}=e;let s,a="",i=!0,c="",u="";function l(e){if(""===e)return c.length>0&&t({id:s,event:u||void 0,data:c.endsWith("\n")?c.slice(0,-1):c}),s=void 0,c="",void(u="");if(e.startsWith(":"))return void(o&&o(e.slice(e.startsWith(": ")?2:1)));const r=e.indexOf(":");if(-1!==r){const t=e.slice(0,r),n=" "===e[r+1]?2:1;return void d(t,e.slice(r+n),e)}d(e,"",e)}function d(e,t,o){switch(e){case"event":u=t;break;case"data":c=`${c}${t}\n`;break;case"id":s=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?n(parseInt(t,10)):r(new bw(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:o}));break;default:r(new bw(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:o}))}}return{feed:function(e){const t=i?e.replace(/^\xEF\xBB\xBF/,""):e,[r,n]=function(e){const t=[];let r="",n=0;for(;n<e.length;){const o=e.indexOf("\r",n),s=e.indexOf("\n",n);let a=-1;if(-1!==o&&-1!==s?a=Math.min(o,s):-1!==o?a=o:-1!==s&&(a=s),-1===a){r=e.slice(n);break}{const r=e.slice(n,a);t.push(r),n=a+1,"\r"===e[n-1]&&"\n"===e[n]&&n++}}return[t,r]}(`${a}${t}`);for(const e of r)l(e);a=n,i=!1},reset:function(e={}){a&&e.consume&&l(a),i=!0,s=void 0,c="",u="",a=""}}}class Pw extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let n;super({start(o){n=Ew({onEvent:e=>{o.enqueue(e)},onError(t){"terminate"===e?o.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:r})},transform(e){n.feed(e)}})}}const Sw={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Tw extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class Iw{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=function(e=fetch,t){return t?async(r,n)=>{const o={...t,...n,headers:n?.headers?{...R_(t.headers),...R_(n.headers)}:t.headers};return e(r,o)}:e}(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??Sw}async _authThenStart(){if(!this._authProvider)throw new lw("No auth provider");let e;try{e=await mw(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if("AUTHORIZED"!==e)throw new lw;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=R_(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){const{resumptionToken:t}=e;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),t&&r.set("last-event-id",t);const n=await(this._fetch??fetch)(this._url,{method:"GET",headers:r,signal:this._abortController?.signal});if(!n.ok){if(await(n.body?.cancel()),401===n.status&&this._authProvider)return await this._authThenStart();if(405===n.status)return;throw new Tw(n.status,`Failed to open SSE stream: ${n.statusText}`)}this._handleSseStream(n.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(void 0!==this._serverRetryMs)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,n=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(r,e),n)}_scheduleReconnection(e,t=0){const r=this._reconnectionOptions.maxRetries;if(t>=r)return void this.onerror?.(new Error(`Maximum reconnection attempts (${r}) exceeded.`));const n=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(r=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${r instanceof Error?r.message:String(r)}`)),this._scheduleReconnection(e,t+1)})},n)}_handleSseStream(e,t,r){if(!e)return;const{onresumptiontoken:n,replayMessageId:o}=t;let s,a=!1,i=!1;(async()=>{try{const t=e.pipeThrough(new TextDecoderStream).pipeThrough(new Pw({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){const{value:e,done:r}=await t.read();if(r)break;if(e.id&&(s=e.id,a=!0,n?.(e.id)),e.data&&(!e.event||"message"===e.event))try{const t=Ts.parse(JSON.parse(e.data));Es(t)&&(i=!0,void 0!==o&&(t.id=o)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(r||a)&&!i&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:n,replayMessageId:o},0)}catch(e){this.onerror?.(new Error(`SSE stream disconnected: ${e}`));if((r||a)&&!i&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:n,replayMessageId:o},0)}catch(e){this.onerror?.(new Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}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(e){if(!this._authProvider)throw new lw("No auth provider");if("AUTHORIZED"!==await mw(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit}))throw new lw("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{const{resumptionToken:n,onresumptiontoken:o}=t||{};if(n)return void this._startOrAuthSse({resumptionToken:n,replayMessageId:$s(e)?e.id:void 0}).catch(e=>this.onerror?.(e));const s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");const a={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(e),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._url,a),c=i.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!i.ok){const t=await i.text().catch(()=>null);if(401===i.status&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Tw(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:t,scope:r}=gw(i);this._resourceMetadataUrl=t,this._scope=r;if("AUTHORIZED"!==await mw(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit}))throw new lw;return this._hasCompletedAuthFlow=!0,this.send(e)}if(403===i.status&&this._authProvider){const{resourceMetadataUrl:t,scope:r,error:n}=gw(i);if("insufficient_scope"===n){const n=i.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===n)throw new Tw(403,"Server returned 403 after trying upscoping");r&&(this._scope=r),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=n??void 0;if("AUTHORIZED"!==await mw(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch}))throw new lw;return this.send(e)}}throw new Tw(i.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,202===i.status)return await(i.body?.cancel()),r=e,void(Ks.safeParse(r).success&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e)));const u=(Array.isArray(e)?e:[e]).filter(e=>"method"in e&&"id"in e&&void 0!==e.id).length>0,l=i.headers.get("content-type");if(u)if(l?.includes("text/event-stream"))this._handleSseStream(i.body,{onresumptiontoken:o},!1);else{if(!l?.includes("application/json"))throw await(i.body?.cancel()),new Tw(-1,`Unexpected content type: ${l}`);{const e=await i.json(),t=Array.isArray(e)?e.map(e=>Ts.parse(e)):[Ts.parse(e)];for(const e of t)this.onmessage?.(e)}}else await(i.body?.cancel())}catch(e){throw this.onerror?.(e),e}var r}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._url,t);if(await(r.body?.cancel()),!r.ok&&405!==r.status)throw new Tw(r.status,`Failed to terminate session: ${r.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}}const xw=K("quickstart");async function Nw(t={}){if(!R)throw new Error("Interactive login is only available in Node.js environment");xw.info("Starting interactive login flow");const r=M();let n;n=t.authIssuer?t.authIssuer:t.authDomain?t.authDomain.startsWith("http")?t.authDomain:`https://${t.authDomain}`:r.authIssuer;const{clientId:o=r.clientId,clientSecret:s=r.clientSecret,audience:a=r.apiAudience,baseUrl:i,port:c=52765}=t;if(!o||!s)throw new Error("AGENT_CLIENT_ID / AGENT_CLIENT_SECRET not set – create a .env file or export in the shell");const u=await he();if(u)try{let e;q(u)?e=D(u):(xw.warn("Cached token has no organization information, using static config"),e=M());const t=new Ee(e.baseUrl,{token:u});return await t.validateCachedToken(),xw.info("Using cached valid token"),t}catch(e){xw.info("Cached token invalid, starting OAuth flow")}else xw.info("No cached token, starting OAuth flow");const l="undefined"!=typeof process&&!(!process.env||"1"!==process.env.BARNDOOR_MANUAL_CODE&&"true"!==process.env.BARNDOOR_MANUAL_CODE);let p,f=null;if(l){const e=process.env&&process.env.BARNDOOR_REDIRECT_HOST||"127.0.0.1";p=e.startsWith("http")?`${e}:${c}/cb`:`http://${e}:${c}/cb`}else{const e=$e(c);p=e[0],f=e[1]}const m=new ve,y=await m.buildAuthorizationUrl({clientId:o,redirectUri:p,audience:a,issuer:n});xw.info(`Auth URL: ${y}`);const g=e.platform();let v,_;try{v=new URL(y)}catch{throw new Error("Invalid auth URL")}if("https:"!==v.protocol&&("http:"!==v.protocol||"localhost"!==v.hostname&&"127.0.0.1"!==v.hostname))throw new Error("Auth URL must use HTTPS (http allowed only for localhost)");try{"darwin"===g?d("open",[y],{detached:!0,stdio:"ignore"}).unref():"win32"===g?d("powershell",["-NoProfile","Start-Process",y],{detached:!0,stdio:"ignore"}).unref():d("xdg-open",[y],{detached:!0,stdio:"ignore"}).unref(),xw.info("Please complete login in your browser…")}catch(e){xw.warn("Failed to open browser automatically. Please visit:",y)}if(l){const e=await new Promise(e=>{const t=h.createInterface({input:process.stdin,output:process.stdout});t.question("Paste the full redirected URL (or just the code= value): ",r=>{t.close(),e(r.trim())})});try{const t=new URL(e);_=t.searchParams.get("code")||e}catch{_=e}}else{const e=new Promise((e,t)=>{setTimeout(()=>{t(new Error(`OAuth callback timeout after 2 minutes. This usually means the callback URL is not registered in Auth0. Please add "${p}" to Allowed Callback URLs in your Auth0 application settings.`))},12e4)});_=(await Promise.race([f,e]))[0]}const w=await m.exchangeCodeForToken({clientId:o,clientSecret:s,code:_,redirectUri:p,issuer:n});let $;if(await pe(w),i)$=i;else if(q(w.access_token)){$=D(w.access_token).baseUrl}else xw.warn("New token has no organization information, using static config"),$=M().baseUrl;return new Ee($,{token:w.access_token})}async function Cw(e,t,r={}){const{timeout:n=90}=r;xw.info(`Ensuring ${t} server is connected`);try{await e.ensureServerConnected(t,{pollSeconds:n}),xw.info(`Server ${t} connected successfully`)}catch(e){throw e instanceof b?xw.error(`Server '${t}' not found`):xw.error(`Failed to connect to ${t}:`,e),e}}async function jw(e,t,r={}){const{serverId:n,serverSlug:o,proxyBaseUrl:s="http://proxy-ingress:8080",transport:a="streamable-http"}=r,i=n||o||t;let c;try{c=await e.getServer(i)}catch(e){if(e instanceof $&&404===e.statusCode)throw new b(i);throw e}const u=c.slug||i;let l;if(q(e.token)){l=`${D(e.token).baseUrl}/mcp/${u}`}else{xw.warn("Token has no organization information, using static config for MCP connection");l=`${M().baseUrl}/mcp/${u}`}return[{url:l,transport:a,headers:{Accept:"application/json, text/event-stream",Authorization:`Bearer ${e.token}`,"x-barndoor-session-id":Ow()}},l]}async function Rw(e,t,r={}){const[n]=await jw(e,t,r),o=n,s=new j_({name:"barndoor-js-sdk",version:"0.1.0"}),a=new Iw(new URL(o.url),{requestInit:{headers:o.headers}});return await s.connect(a),s}function Ow(){if(R&&"function"==typeof i.randomUUID)return i.randomUUID();if("undefined"!=typeof globalThis&&globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let e;if(R&&"function"==typeof i.randomBytes)e=i.randomBytes(16);else{if("undefined"==typeof globalThis||!globalThis.crypto?.getRandomValues)throw new Error("Secure random generator not available for UUID.");e=new Uint8Array(16),globalThis.crypto.getRandomValues(e)}const t=e??new Uint8Array(0);if(t.length<16)throw new Error("Secure random generator not available for UUID.");const r=t[6],n=t[8];t[6]=15&r|64,t[8]=63&n|128;const o=Array.from(t,e=>e.toString(16).padStart(2,"0")).join("");return`${o.substring(0,8)}-${o.substring(8,12)}-${o.substring(12,16)}-${o.substring(16,20)}-${o.substring(20)}`}const zw=function(){try{if("undefined"!=typeof process&&process.versions?.node){const e=l(import.meta.url),t=r(e),o=n(t,"..","package.json");return JSON.parse(f(o,"utf8")).version}return'"1.2.0"'}catch(e){return console.warn("Could not read version from package.json:",e),"0.1.0"}}();export{C as AUTH_CONFIG,N as AgentToken,y as AuthenticationError,z as BarndoorConfig,m as BarndoorError,Ee as BarndoorSDK,E as ConfigurationError,w as ConnectionError,$ as HTTPError,re as JWTVerificationResult,k as OAuthError,ve as PKCEManager,x as ServerDetail,b as ServerNotFoundError,I as ServerSummary,P as TimeoutError,g as TokenError,v as TokenExpiredError,de as TokenManager,_ as TokenValidationError,U as checkTokenOrganization,fe as clearCachedToken,Y as clearOidcConfigCache,K as createScopedLogger,H as debug,Cw as ensureServerConnected,B as error,ke as getClientCredentialsToken,D as getDynamicConfig,L as getLogger,Q as getOidcConfig,M as getStaticConfig,q as hasOrganizationInfo,Z as info,j as isBrowser,R as isNode,me as isTokenActive,ye as isTokenActiveWithRefresh,he as loadUserToken,Nw as loginInteractive,Rw as makeMcpClient,jw as makeMcpConnectionParams,pe as saveUserToken,F as setLogger,X as setTokenLogger,$e as startLocalCallbackServer,ge as validateToken,ue as verifyJWTLocal,zw as version,G as warn};
13
+ deps: ${n}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(e){const[t,r]=function({schema:e}){const t={},r={};for(const n in e){if("__proto__"===n)continue;(Array.isArray(e[n])?t:r)[n]=e[n]}return[t,r]}(e);s(e,t),a(e,r)}};function s(e,r=e.schema){const{gen:o,data:s,it:a}=e;if(0===Object.keys(r).length)return;const i=o.let("missing");for(const c in r){const l=r[c];if(0===l.length)continue;const u=(0,n.propertyInData)(o,s,c,a.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(", ")}),a.allErrors?o.if(u,()=>{for(const t of l)(0,n.checkReportMissingProp)(e,t)}):(o.if(t._`${u} && (${(0,n.checkMissingProp)(e,l,i)})`),(0,n.reportMissingProp)(e,i),o.else())}}function a(e,t=e.schema){const{gen:o,data:s,keyword:a,it:i}=e,c=o.name("valid");for(const l in t)(0,r.alwaysValidSchema)(i,t[l])||(o.if((0,n.propertyInData)(o,s,l,i.opts.ownProperties),()=>{const t=e.subschema({keyword:a,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>o.var(c,!0)),e.ok(c))}e.validatePropertyDeps=s,e.validateSchemaDeps=a,e.default=o}(pv);var fv={};Object.defineProperty(fv,"__esModule",{value:!0});const mv=xf,yv=jf,gv={message:"property name must be valid",params:({params:e})=>mv._`{propertyName: ${e.propertyName}}`},vv={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:gv,code(e){const{gen:t,schema:r,data:n,it:o}=e;if((0,yv.alwaysValidSchema)(o,r))return;const s=t.name("valid");t.forIn("key",n,r=>{e.setParams({propertyName:r}),e.subschema({keyword:"propertyNames",data:r,dataTypes:["string"],propertyName:r,compositeRule:!0},s),t.if((0,mv.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};fv.default=vv;var _v={};Object.defineProperty(_v,"__esModule",{value:!0});const wv=$m(),$v=xf,bv=Jf(),kv=jf,Ev={message:"must NOT have additional properties",params:({params:e})=>$v._`{additionalProperty: ${e.additionalProperty}}`},Pv={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Ev,code(e){const{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:a}=e;if(!s)throw new Error("ajv implementation error");const{allErrors:i,opts:c}=a;if(a.props=!0,"all"!==c.removeAdditional&&(0,kv.alwaysValidSchema)(a,r))return;const l=(0,wv.allSchemaProperties)(n.properties),u=(0,wv.allSchemaProperties)(n.patternProperties);function d(e){t.code($v._`delete ${o}[${e}]`)}function h(n){if("all"===c.removeAdditional||c.removeAdditional&&!1===r)d(n);else{if(!1===r)return e.setParams({additionalProperty:n}),e.error(),void(i||t.break());if("object"==typeof r&&!(0,kv.alwaysValidSchema)(a,r)){const r=t.name("valid");"failing"===c.removeAdditional?(p(n,r,!1),t.if((0,$v.not)(r),()=>{e.reset(),d(n)})):(p(n,r),i||t.if((0,$v.not)(r),()=>t.break()))}}}function p(t,r,n){const o={keyword:"additionalProperties",dataProp:t,dataPropType:kv.Type.Str};!1===n&&Object.assign(o,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(o,r)}t.forIn("key",o,r=>{l.length||u.length?t.if(function(r){let o;if(l.length>8){const e=(0,kv.schemaRefOrVal)(a,n.properties,"properties");o=(0,wv.isOwnProperty)(t,e,r)}else o=l.length?(0,$v.or)(...l.map(e=>$v._`${r} === ${e}`)):$v.nil;return u.length&&(o=(0,$v.or)(o,...u.map(t=>$v._`${(0,wv.usePattern)(e,t)}.test(${r})`))),(0,$v.not)(o)}(r),()=>h(r)):h(r)}),e.ok($v._`${s} === ${bv.default.errors}`)}};_v.default=Pv;var Sv={};Object.defineProperty(Sv,"__esModule",{value:!0});const Tv=Hm(),Iv=$m(),xv=jf,Nv=_v,Cv={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;"all"===s.opts.removeAdditional&&void 0===n.additionalProperties&&Nv.default.code(new Tv.KeywordCxt(s,Nv.default,"additionalProperties"));const a=(0,Iv.allSchemaProperties)(r);for(const e of a)s.definedProperties.add(e);s.opts.unevaluated&&a.length&&!0!==s.props&&(s.props=xv.mergeEvaluated.props(t,(0,xv.toHash)(a),s.props));const i=a.filter(e=>!(0,xv.alwaysValidSchema)(s,r[e]));if(0===i.length)return;const c=t.name("valid");for(const r of i)l(r)?u(r):(t.if((0,Iv.propertyInData)(t,o,r,s.opts.ownProperties)),u(r),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(r),e.ok(c);function l(e){return s.opts.useDefaults&&!s.compositeRule&&void 0!==r[e].default}function u(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},c)}}};Sv.default=Cv;var jv={};Object.defineProperty(jv,"__esModule",{value:!0});const Rv=$m(),Ov=xf,zv=jf,Av=jf,Mv={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:a}=s,i=(0,Rv.allSchemaProperties)(r),c=i.filter(e=>(0,zv.alwaysValidSchema)(s,r[e]));if(0===i.length||c.length===i.length&&(!s.opts.unevaluated||!0===s.props))return;const l=a.strictSchema&&!a.allowMatchingProperties&&o.properties,u=t.name("valid");!0===s.props||s.props instanceof Ov.Name||(s.props=(0,Av.evaluatedPropsToName)(t,s.props));const{props:d}=s;function h(e){for(const t in l)new RegExp(e).test(t)&&(0,zv.checkStrictMode)(s,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function p(r){t.forIn("key",n,n=>{t.if(Ov._`${(0,Rv.usePattern)(e,r)}.test(${n})`,()=>{const o=c.includes(r);o||e.subschema({keyword:"patternProperties",schemaProp:r,dataProp:n,dataPropType:Av.Type.Str},u),s.opts.unevaluated&&!0!==d?t.assign(Ov._`${d}[${n}]`,!0):o||s.allErrors||t.if((0,Ov.not)(u),()=>t.break())})})}!function(){for(const e of i)l&&h(e),s.allErrors?p(e):(t.var(u,!0),p(e),t.if(u))}()}};jv.default=Mv;var Uv={};Object.defineProperty(Uv,"__esModule",{value:!0});const Dv=jf,qv={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:r,it:n}=e;if((0,Dv.alwaysValidSchema)(n,r))return void e.fail();const o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Uv.default=qv;var Vv={};Object.defineProperty(Vv,"__esModule",{value:!0});const Fv={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:$m().validateUnion,error:{message:"must match a schema in anyOf"}};Vv.default=Fv;var Lv={};Object.defineProperty(Lv,"__esModule",{value:!0});const Hv=xf,Kv=jf,Zv={message:"must match exactly one schema in oneOf",params:({params:e})=>Hv._`{passingSchemas: ${e.passing}}`},Gv={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Zv,code(e){const{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;const s=r,a=t.let("valid",!1),i=t.let("passing",null),c=t.name("_valid");e.setParams({passing:i}),t.block(function(){s.forEach((r,n)=>{let s;(0,Kv.alwaysValidSchema)(o,r)?t.var(c,!0):s=e.subschema({keyword:"oneOf",schemaProp:n,compositeRule:!0},c),n>0&&t.if(Hv._`${c} && ${a}`).assign(a,!1).assign(i,Hv._`[${i}, ${n}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(i,n),s&&e.mergeEvaluated(s,Hv.Name)})})}),e.result(a,()=>e.reset(),()=>e.error(!0))}};Lv.default=Gv;var Bv={};Object.defineProperty(Bv,"__esModule",{value:!0});const Jv=jf,Wv={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const o=t.name("valid");r.forEach((t,r)=>{if((0,Jv.alwaysValidSchema)(n,t))return;const s=e.subschema({keyword:"allOf",schemaProp:r},o);e.ok(o),e.mergeEvaluated(s)})}};Bv.default=Wv;var Qv={};Object.defineProperty(Qv,"__esModule",{value:!0});const Yv=xf,Xv=jf,e_={message:({params:e})=>Yv.str`must match "${e.ifClause}" schema`,params:({params:e})=>Yv._`{failingKeyword: ${e.ifClause}}`},t_={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:e_,code(e){const{gen:t,parentSchema:r,it:n}=e;void 0===r.then&&void 0===r.else&&(0,Xv.checkStrictMode)(n,'"if" without "then" and "else" is ignored');const o=r_(n,"then"),s=r_(n,"else");if(!o&&!s)return;const a=t.let("valid",!0),i=t.name("_valid");if(function(){const t=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},i);e.mergeEvaluated(t)}(),e.reset(),o&&s){const r=t.let("ifClause");e.setParams({ifClause:r}),t.if(i,c("then",r),c("else",r))}else o?t.if(i,c("then")):t.if((0,Yv.not)(i),c("else"));function c(r,n){return()=>{const o=e.subschema({keyword:r},i);t.assign(a,i),e.mergeValidEvaluated(o,a),n?t.assign(n,Yv._`${r}`):e.setParams({ifClause:r})}}e.pass(a,()=>e.error(!0))}};function r_(e,t){const r=e.schema[t];return void 0!==r&&!(0,Xv.alwaysValidSchema)(e,r)}Qv.default=t_;var n_={};Object.defineProperty(n_,"__esModule",{value:!0});const o_=jf,s_={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){void 0===t.if&&(0,o_.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};n_.default=s_,Object.defineProperty(Fg,"__esModule",{value:!0});const a_=Lg,i_=Bg,c_=Jg,l_=nv,u_=lv,d_=pv,h_=fv,p_=_v,f_=Sv,m_=jv,y_=Uv,g_=Vv,v_=Lv,__=Bv,w_=Qv,$_=n_;Fg.default=function(e=!1){const t=[y_.default,g_.default,v_.default,__.default,w_.default,$_.default,h_.default,p_.default,d_.default,f_.default,m_.default];return e?t.push(i_.default,l_.default):t.push(a_.default,c_.default),t.push(u_.default),t};var b_={},k_={};Object.defineProperty(k_,"__esModule",{value:!0});const E_=xf,P_={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>E_.str`must match format "${e}"`,params:({schemaCode:e})=>E_._`{format: ${e}}`},code(e,t){const{gen:r,data:n,$data:o,schema:s,schemaCode:a,it:i}=e,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=i;c.validateFormats&&(o?function(){const o=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),s=r.const("fDef",E_._`${o}[${a}]`),i=r.let("fType"),l=r.let("format");r.if(E_._`typeof ${s} == "object" && !(${s} instanceof RegExp)`,()=>r.assign(i,E_._`${s}.type || "string"`).assign(l,E_._`${s}.validate`),()=>r.assign(i,E_._`"string"`).assign(l,s)),e.fail$data((0,E_.or)(!1===c.strictSchema?E_.nil:E_._`${a} && !${l}`,function(){const e=u.$async?E_._`(${s}.async ? await ${l}(${n}) : ${l}(${n}))`:E_._`${l}(${n})`,r=E_._`(typeof ${l} == "function" ? ${e} : ${l}.test(${n}))`;return E_._`${l} && ${l} !== true && ${i} === ${t} && !${r}`}()))}():function(){const o=d.formats[s];if(!o)return void function(){if(!1===c.strictSchema)return void d.logger.warn(e());throw new Error(e());function e(){return`unknown format "${s}" ignored in schema at path "${l}"`}}();if(!0===o)return;const[a,i,h]=function(e){const t=e instanceof RegExp?(0,E_.regexpCode)(e):c.code.formats?E_._`${c.code.formats}${(0,E_.getProperty)(s)}`:void 0,n=r.scopeValue("formats",{key:s,ref:e,code:t});if("object"==typeof e&&!(e instanceof RegExp))return[e.type||"string",e.validate,E_._`${n}.validate`];return["string",e,n]}(o);a===t&&e.pass(function(){if("object"==typeof o&&!(o instanceof RegExp)&&o.async){if(!u.$async)throw new Error("async format in sync schema");return E_._`await ${h}(${n})`}return"function"==typeof i?E_._`${h}(${n})`:E_._`${h}.test(${n})`}())}())}};k_.default=P_,Object.defineProperty(b_,"__esModule",{value:!0});const S_=[k_.default];b_.default=S_;var T_={};Object.defineProperty(T_,"__esModule",{value:!0}),T_.contentVocabulary=T_.metadataVocabulary=void 0,T_.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],T_.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"],Object.defineProperty(yy,"__esModule",{value:!0});const I_=jy,x_=Fg,N_=b_,C_=T_,j_=[gy.default,I_.default,(0,x_.default)(),N_.default,C_.metadataVocabulary,C_.contentVocabulary];yy.default=j_;var R_,O_={},z_={};Object.defineProperty(z_,"__esModule",{value:!0}),z_.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(R_||(z_.DiscrError=R_={})),Object.defineProperty(O_,"__esModule",{value:!0});const A_=xf,M_=z_,U_=Qm,D_=Wm(),q_=jf,V_={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:t}})=>e===M_.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>A_._`{error: ${e}, tag: ${r}, tagValue: ${t}}`},code(e){const{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:a}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");const i=n.propertyName;if("string"!=typeof i)throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",!1),l=t.const("tag",A_._`${r}${(0,A_.getProperty)(i)}`);function u(r){const n=t.name("valid"),o=e.subschema({keyword:"oneOf",schemaProp:r},n);return e.mergeEvaluated(o,A_.Name),n}t.if(A_._`typeof ${l} == "string"`,()=>function(){const r=function(){var e;const t={},r=c(o);let n=!0;for(let t=0;t<a.length;t++){let o=a[t];if((null==o?void 0:o.$ref)&&!(0,q_.schemaHasRulesButRef)(o,s.self.RULES)){const e=o.$ref;if(o=U_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,e),o instanceof U_.SchemaEnv&&(o=o.schema),void 0===o)throw new D_.default(s.opts.uriResolver,s.baseId,e)}const u=null===(e=null==o?void 0:o.properties)||void 0===e?void 0:e[i];if("object"!=typeof u)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${i}"`);n=n&&(r||c(o)),l(u,t)}if(!n)throw new Error(`discriminator: "${i}" must be required`);return t;function c({required:e}){return Array.isArray(e)&&e.includes(i)}function l(e,t){if(e.const)u(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${i}" must have "const" or "enum"`);for(const r of e.enum)u(r,t)}}function u(e,r){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${i}" values must be unique strings`);t[e]=r}}();t.if(!1);for(const e in r)t.elseIf(A_._`${l} === ${e}`),t.assign(c,u(r[e]));t.else(),e.error(!1,{discrError:M_.DiscrError.Mapping,tag:l,tagName:i}),t.endIf()}(),()=>e.error(!1,{discrError:M_.DiscrError.Tag,tag:l,tagName:i})),e.ok(c)}};O_.default=V_;var F_={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const r=Pf,n=yy,o=O_,s=F_,a=["/properties"],i="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(o.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(e,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var l=Hm();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=xf;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=Gm();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return d.default}});var h=Wm();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return h.default}})}(Ef,Ef.exports);var L_=Ef.exports;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=L_,r=xf,n=r.operators,o={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},s={message:({keyword:e,schemaCode:t})=>r.str`should be ${o[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>r._`{comparison: ${o[e].okStr}, limit: ${t}}`};e.formatLimitDefinition={keyword:Object.keys(o),type:"string",schemaType:"string",$data:!0,error:s,code(e){const{gen:n,data:s,schemaCode:a,keyword:i,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;const d=new t.KeywordCxt(c,u.RULES.all.format.definition,"format");function h(e){return r._`${e}.compare(${s}, ${a}) ${o[i].fail} 0`}d.$data?function(){const t=n.scopeValue("formats",{ref:u.formats,code:l.code.formats}),o=n.const("fmt",r._`${t}[${d.schemaCode}]`);e.fail$data((0,r.or)(r._`typeof ${o} != "object"`,r._`${o} instanceof RegExp`,r._`typeof ${o}.compare != "function"`,h(o)))}():function(){const t=d.schema,o=u.formats[t];if(!o||!0===o)return;if("object"!=typeof o||o instanceof RegExp||"function"!=typeof o.compare)throw new Error(`"${i}": format "${t}" does not define "compare" function`);const s=n.scopeValue("formats",{key:t,ref:o,code:l.code.formats?r._`${l.code.formats}${(0,r.getProperty)(t)}`:void 0});e.fail$data(h(s))}()},dependencies:["format"]};e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)}(kf),function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=bf,n=kf,o=xf,s=new o.Name("fullFormats"),a=new o.Name("fastFormats"),i=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,r.fullFormats,s),e;const[o,i]="fast"===t.mode?[r.fastFormats,a]:[r.fullFormats,s];return c(e,t.formats||r.formatNames,o,i),t.keywords&&(0,n.default)(e),e};function c(e,t,r,n){var s,a;null!==(s=(a=e.opts.code).formats)&&void 0!==s||(a.formats=o._`require("ajv-formats/dist/formats").${n}`);for(const n of t)e.addFormat(n,r[n])}i.get=(e,t="full")=>{const n=("fast"===t?r.fastFormats:r.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n},e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}($f,$f.exports);var H_=Qi($f.exports);class K_{constructor(e){this._ajv=e??function(){const e=new wf({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return H_(e),e}()}getValidator(e){const t="$id"in e&&"string"==typeof e.$id?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class Z_{constructor(e){this._client=e}async*callToolStream(e,t=Xa,r){const n=this._client,o={...r,task:r?.task??(n.isToolTask(e.name)?{}:void 0)},s=n.requestStream({method:"tools/call",params:e},t,o),a=n.getToolOutputValidator(e.name);for await(const t of s){if("result"===t.type&&a){const r=t.result;if(!r.structuredContent&&!r.isError)return void(yield{type:"error",error:new Hi(Ps.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)});if(r.structuredContent)try{const e=a(r.structuredContent);if(!e.valid)return void(yield{type:"error",error:new Hi(Ps.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)})}catch(e){return e instanceof Hi?void(yield{type:"error",error:e}):void(yield{type:"error",error:new Hi(Ps.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)})}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,r){return this._client.getTaskResult({taskId:e},t,r)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,r){return this._client.requestStream(e,t,r)}}function G_(e,t){if(e&&null!==t&&"object"==typeof t){if("object"===e.type&&e.properties&&"object"==typeof e.properties){const r=t,n=e.properties;for(const e of Object.keys(n)){const t=n[e];void 0===r[e]&&Object.prototype.hasOwnProperty.call(t,"default")&&(r[e]=t.default),void 0!==r[e]&&G_(t,r[e])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)"boolean"!=typeof r&&G_(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)"boolean"!=typeof r&&G_(r,t)}}class B_ extends Ji{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new K_,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",ri,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Ga,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Sa,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Z_(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function(e,t){const r={...e};for(const e in t){const n=e,o=t[n];if(void 0===o)continue;const s=r[n];Wi(s)&&Wi(o)?r[n]={...s,...o}:r[n]=o}return r}(this._capabilities,e)}setRequestHandler(e,t){const r=Pn(e),n=r?.method;if(!n)throw new Error("Schema is missing a method literal");let o;if(kn(n)){const e=n,t=e._zod?.def;o=t?.value??e.value}else{const e=n,t=e._def;o=t?.value??e.value}if("string"!=typeof o)throw new Error("Schema method literal must be a string");const s=o;if("elicitation/create"===s){const r=async(e,r)=>{const n=En(Ci,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new Hi(Ps.InvalidParams,`Invalid elicitation request: ${e}`)}const{params:o}=n.data;o.mode=o.mode??"form";const{supportsFormMode:s,supportsUrlMode:a}=function(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};const t=void 0!==e.form,r=void 0!==e.url;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}(this._capabilities.elicitation);if("form"===o.mode&&!s)throw new Hi(Ps.InvalidParams,"Client does not support form-mode elicitation requests");if("url"===o.mode&&!a)throw new Hi(Ps.InvalidParams,"Client does not support URL-mode elicitation requests");const i=await Promise.resolve(t(e,r));if(o.task){const e=En(ea,i);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new Hi(Ps.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const c=En(Oi,i);if(!c.success){const e=c.error instanceof Error?c.error.message:String(c.error);throw new Hi(Ps.InvalidParams,`Invalid elicitation result: ${e}`)}const l=c.data,u="form"===o.mode?o.requestedSchema:void 0;if("form"===o.mode&&"accept"===l.action&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{G_(u,l.content)}catch{}return l};return super.setRequestHandler(e,r)}if("sampling/createMessage"===s){const r=async(e,r)=>{const n=En(gi,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new Hi(Ps.InvalidParams,`Invalid sampling request: ${e}`)}const{params:o}=n.data,s=await Promise.resolve(t(e,r));if(o.task){const e=En(ea,s);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new Hi(Ps.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const a=En(o.tools||o.toolChoice?_i:vi,s);if(!a.success){const e=a.error instanceof Error?a.error.message:String(a.error);throw new Hi(Ps.InvalidParams,`Invalid sampling result: ${e}`)}return a.data};return super.setRequestHandler(e,r)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),void 0===e.sessionId)try{const r=await this.request({method:"initialize",params:{protocolVersion:rs,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ls,t);if(void 0===r)throw new Error(`Server sent invalid initialize result: ${r}`);if(!ns.includes(r.protocolVersion))throw new Error(`Server's protocol version is not supported: ${r.protocolVersion}`);this._serverCapabilities=r.capabilities,this._serverVersion=r.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(r.protocolVersion),this._instructions=r.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if("resources/subscribe"===e&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if("notifications/roots/list_changed"===e)if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){!function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);if("tools/call"===t&&!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`)}(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`)}}(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Is,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Di,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},Is,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Za,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},Aa,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},_a,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},$a,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Pa,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},Is,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},Is,t)}async callTool(e,t=Xa,r){if(this.isToolTaskRequired(e.name))throw new Hi(Ps.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const n=await this.request({method:"tools/call",params:e},t,r),o=this.getToolOutputValidator(e.name);if(o){if(!n.structuredContent&&!n.isError)throw new Hi(Ps.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(n.structuredContent)try{const e=o(n.structuredContent);if(!e.valid)throw new Hi(Ps.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){if(e instanceof Hi)throw e;throw new Hi(Ps.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return n}isToolTask(e){return!!this._serverCapabilities?.tasks?.requests?.tools?.call&&this._cachedKnownTaskTools.has(e)}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}const e=t.execution?.taskSupport;"required"!==e&&"optional"!==e||this._cachedKnownTaskTools.add(t.name),"required"===e&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const r=await this.request({method:"tools/list",params:e},Ya,t);return this.cacheToolMetadata(r.tools),r}_setupListChangedHandler(e,t,r,n){const o=ni.safeParse(r);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if("function"!=typeof r.onChanged)throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:s,debounceMs:a}=o.data,{onChanged:i}=r,c=async()=>{if(s)try{const e=await n();i(null,e)}catch(e){const t=e instanceof Error?e:new Error(String(e));i(t,null)}else i(null,null)};this.setNotificationHandler(t,()=>{if(a){const t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);const r=setTimeout(c,a);this._listChangedDebounceTimers.set(e,r)}else c()})}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}function J_(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}const W_=pn(Gn,Q_).superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ts,message:"URL must be parseable",fatal:!0}),Pe}).refine(e=>{const t=new URL(e);return"javascript:"!==t.protocol&&"data:"!==t.protocol&&"vbscript:"!==t.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"});var Q_;const Y_=To({resource:Fn().url(),authorization_servers:Eo(W_).optional(),jwks_uri:Fn().url().optional(),scopes_supported:Eo(Fn()).optional(),bearer_methods_supported:Eo(Fn()).optional(),resource_signing_alg_values_supported:Eo(Fn()).optional(),resource_name:Fn().optional(),resource_documentation:Fn().optional(),resource_policy_uri:Fn().url().optional(),resource_tos_uri:Fn().url().optional(),tls_client_certificate_bound_access_tokens:mo().optional(),authorization_details_types_supported:Eo(Fn()).optional(),dpop_signing_alg_values_supported:Eo(Fn()).optional(),dpop_bound_access_tokens_required:mo().optional()}),X_=To({issuer:Fn(),authorization_endpoint:W_,token_endpoint:W_,registration_endpoint:W_.optional(),scopes_supported:Eo(Fn()).optional(),response_types_supported:Eo(Fn()),response_modes_supported:Eo(Fn()).optional(),grant_types_supported:Eo(Fn()).optional(),token_endpoint_auth_methods_supported:Eo(Fn()).optional(),token_endpoint_auth_signing_alg_values_supported:Eo(Fn()).optional(),service_documentation:W_.optional(),revocation_endpoint:W_.optional(),revocation_endpoint_auth_methods_supported:Eo(Fn()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Eo(Fn()).optional(),introspection_endpoint:Fn().optional(),introspection_endpoint_auth_methods_supported:Eo(Fn()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Eo(Fn()).optional(),code_challenge_methods_supported:Eo(Fn()).optional(),client_id_metadata_document_supported:mo().optional()}),ew=So({...To({issuer:Fn(),authorization_endpoint:W_,token_endpoint:W_,userinfo_endpoint:W_.optional(),jwks_uri:W_,registration_endpoint:W_.optional(),scopes_supported:Eo(Fn()).optional(),response_types_supported:Eo(Fn()),response_modes_supported:Eo(Fn()).optional(),grant_types_supported:Eo(Fn()).optional(),acr_values_supported:Eo(Fn()).optional(),subject_types_supported:Eo(Fn()),id_token_signing_alg_values_supported:Eo(Fn()),id_token_encryption_alg_values_supported:Eo(Fn()).optional(),id_token_encryption_enc_values_supported:Eo(Fn()).optional(),userinfo_signing_alg_values_supported:Eo(Fn()).optional(),userinfo_encryption_alg_values_supported:Eo(Fn()).optional(),userinfo_encryption_enc_values_supported:Eo(Fn()).optional(),request_object_signing_alg_values_supported:Eo(Fn()).optional(),request_object_encryption_alg_values_supported:Eo(Fn()).optional(),request_object_encryption_enc_values_supported:Eo(Fn()).optional(),token_endpoint_auth_methods_supported:Eo(Fn()).optional(),token_endpoint_auth_signing_alg_values_supported:Eo(Fn()).optional(),display_values_supported:Eo(Fn()).optional(),claim_types_supported:Eo(Fn()).optional(),claims_supported:Eo(Fn()).optional(),service_documentation:Fn().optional(),claims_locales_supported:Eo(Fn()).optional(),ui_locales_supported:Eo(Fn()).optional(),claims_parameter_supported:mo().optional(),request_parameter_supported:mo().optional(),request_uri_parameter_supported:mo().optional(),require_request_uri_registration:mo().optional(),op_policy_uri:W_.optional(),op_tos_uri:W_.optional(),client_id_metadata_document_supported:mo().optional()}).shape,...X_.pick({code_challenge_methods_supported:!0}).shape}),tw=So({access_token:Fn(),id_token:Fn().optional(),token_type:Fn(),expires_in:function(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...He(t)})}(lo,e)}().optional(),scope:Fn().optional(),refresh_token:Fn().optional()}).strip(),rw=So({error:Fn(),error_description:Fn().optional(),error_uri:Fn().optional()}),nw=W_.optional().or(Do("").transform(()=>{})),ow=So({redirect_uris:Eo(W_),token_endpoint_auth_method:Fn().optional(),grant_types:Eo(Fn()).optional(),response_types:Eo(Fn()).optional(),client_name:Fn().optional(),client_uri:W_.optional(),logo_uri:nw,scope:Fn().optional(),contacts:Eo(Fn()).optional(),tos_uri:nw,policy_uri:Fn().optional(),jwks_uri:W_.optional(),jwks:new vo({type:"any"}).optional(),software_id:Fn().optional(),software_version:Fn().optional(),software_statement:Fn().optional()}).strip(),sw=So({client_id:Fn(),client_secret:Fn().optional(),client_id_issued_at:uo().optional(),client_secret_expires_at:uo().optional()}).strip(),aw=ow.merge(sw);So({error:Fn(),error_description:Fn().optional()}).strip(),So({token:Fn(),token_type_hint:Fn().optional()}).strip();class iw extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){const e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}}class cw extends iw{}cw.errorCode="invalid_request";class lw extends iw{}lw.errorCode="invalid_client";class uw extends iw{}uw.errorCode="invalid_grant";class dw extends iw{}dw.errorCode="unauthorized_client";class hw extends iw{}hw.errorCode="unsupported_grant_type";class pw extends iw{}pw.errorCode="invalid_scope";class fw extends iw{}fw.errorCode="access_denied";class mw extends iw{}mw.errorCode="server_error";class yw extends iw{}yw.errorCode="temporarily_unavailable";class gw extends iw{}gw.errorCode="unsupported_response_type";class vw extends iw{}vw.errorCode="unsupported_token_type";class _w extends iw{}_w.errorCode="invalid_token";class ww extends iw{}ww.errorCode="method_not_allowed";class $w extends iw{}$w.errorCode="too_many_requests";class bw extends iw{}bw.errorCode="invalid_client_metadata";class kw extends iw{}kw.errorCode="insufficient_scope";class Ew extends iw{}Ew.errorCode="invalid_target";const Pw={[cw.errorCode]:cw,[lw.errorCode]:lw,[uw.errorCode]:uw,[dw.errorCode]:dw,[hw.errorCode]:hw,[pw.errorCode]:pw,[fw.errorCode]:fw,[mw.errorCode]:mw,[yw.errorCode]:yw,[gw.errorCode]:gw,[vw.errorCode]:vw,[_w.errorCode]:_w,[ww.errorCode]:ww,[$w.errorCode]:$w,[bw.errorCode]:bw,[kw.errorCode]:kw,[Ew.errorCode]:Ew};class Sw extends Error{constructor(e){super(e??"Unauthorized")}}const Tw="code",Iw="S256";function xw(e,t,r,n){const{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":return void function(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");const n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}(o,s,r);case"client_secret_post":return void function(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}(o,s,n);case"none":return void function(e,t){t.set("client_id",e)}(o,n);default:throw new Error(`Unsupported client authentication method: ${e}`)}}async function Nw(e){const t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{const e=rw.parse(JSON.parse(r)),{error:t,error_description:n,error_uri:o}=e;return new(Pw[t]||mw)(n||"",o)}catch(e){return new mw(`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${e}. Raw body: ${r}`)}}async function Cw(e,t){try{return await jw(e,t)}catch(r){if(r instanceof lw||r instanceof dw)return await(e.invalidateCredentials?.("all")),await jw(e,t);if(r instanceof uw)return await(e.invalidateCredentials?.("tokens")),await jw(e,t);throw r}}async function jw(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let a,i;try{a=await async function(e,t,r=fetch){const n=await async function(e,t,r,n){const o=new URL(e),s=n?.protocolVersion??rs;let a;if(n?.metadataUrl)a=new URL(n.metadataUrl);else{const e=function(e,t="",r={}){t.endsWith("/")&&(t=t.slice(0,-1));return r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}(t,o.pathname);a=new URL(e,n?.metadataServerUrl??o),a.search=o.search}let i=await Aw(a,s,r);if(!n?.metadataUrl&&function(e,t){return!e||e.status>=400&&e.status<500&&"/"!==t}(i,o.pathname)){const e=new URL(`/.well-known/${t}`,o);i=await Aw(e,s,r)}return i}(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||404===n.status)throw await(n?.body?.cancel()),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await(n.body?.cancel()),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return Y_.parse(await n.json())}(t,{resourceMetadataUrl:o},s),a.authorization_servers&&a.authorization_servers.length>0&&(i=a.authorization_servers[0])}catch{}i||(i=new URL("/",t));const c=await async function(e,t,r){const n=function(e){const t="string"==typeof e?new URL(e):new URL(e.href);return t.hash="",t}(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(!r)return;if(!function({requestedResource:e,configuredResource:t}){const r="string"==typeof e?new URL(e):new URL(e.href),n="string"==typeof t?new URL(t):new URL(t.href);if(r.origin!==n.origin)return!1;if(r.pathname.length<n.pathname.length)return!1;const o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return o.startsWith(s)}({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}(t,e,a),l=await async function(e,{fetchFn:t=fetch,protocolVersion:r=rs}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},o=function(e){const t="string"==typeof e?new URL(e):e,r="/"!==t.pathname,n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let o=t.pathname;o.endsWith("/")&&(o=o.slice(0,-1));return n.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${o}`,t.origin),type:"oidc"}),n.push({url:new URL(`${o}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}(e);for(const{url:e,type:r}of o){const o=await zw(e,n,t);if(o){if(!o.ok){if(await(o.body?.cancel()),o.status>=400&&o.status<500)continue;throw new Error(`HTTP ${o.status} trying to load ${"oauth"===r?"OAuth":"OpenID provider"} metadata from ${e}`)}return"oauth"===r?X_.parse(await o.json()):ew.parse(await o.json())}}return}(i,{fetchFn:s});let u=await Promise.resolve(e.clientInformation());if(!u){if(void 0!==r)throw new Error("Existing OAuth client information is required when exchanging an authorization code");const t=!0===l?.client_id_metadata_document_supported,n=e.clientMetadataUrl;if(n&&!function(e){if(!e)return!1;try{const t=new URL(e);return"https:"===t.protocol&&"/"!==t.pathname}catch{return!1}}(n))throw new bw(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${n}`);if(t&&n)u={client_id:n},await(e.saveClientInformation?.(u));else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const t=await async function(e,{metadata:t,clientMetadata:r,fetchFn:n}){let o;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");o=new URL(t.registration_endpoint)}else o=new URL("/register",e);const s=await(n??fetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw await Nw(s);return aw.parse(await s.json())}(i,{metadata:l,clientMetadata:e.clientMetadata,fetchFn:s});await e.saveClientInformation(t),u=t}}const d=!e.redirectUrl;if(void 0!==r||d){const t=await async function(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){const a=e.clientMetadata.scope;let i;e.prepareTokenRequest&&(i=await e.prepareTokenRequest(a));if(!i){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");i=function(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}(o,await e.codeVerifier(),e.redirectUrl)}const c=await e.clientInformation();return Mw(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}(e,i,{metadata:l,resource:c,authorizationCode:r,fetchFn:s});return await e.saveTokens(t),"AUTHORIZED"}const h=await e.tokens();if(h?.refresh_token)try{const t=await async function(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:a}){const i=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await Mw(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:a});return{refresh_token:n,...c}}(i,{metadata:l,clientInformation:u,refreshToken:h.refresh_token,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await e.saveTokens(t),"AUTHORIZED"}catch(e){if(e instanceof iw&&!(e instanceof mw))throw e}const f=e.state?await e.state():void 0,{authorizationUrl:m,codeVerifier:y}=await async function(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:a}){let i;if(t){if(i=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Tw))throw new Error(`Incompatible auth server: does not support response type ${Tw}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(Iw))throw new Error(`Incompatible auth server: does not support code challenge method ${Iw}`)}else i=new URL("/authorize",e);const c=await p(),l=c.code_verifier,u=c.code_challenge;i.searchParams.set("response_type",Tw),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",u),i.searchParams.set("code_challenge_method",Iw),i.searchParams.set("redirect_uri",String(n)),s&&i.searchParams.set("state",s);o&&i.searchParams.set("scope",o);o?.includes("offline_access")&&i.searchParams.append("prompt","consent");a&&i.searchParams.set("resource",a.href);return{authorizationUrl:i,codeVerifier:l}}(i,{metadata:l,clientInformation:u,state:f,redirectUrl:e.redirectUrl,scope:n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,resource:c});return await e.saveCodeVerifier(y),await e.redirectToAuthorization(m),"REDIRECT"}function Rw(e){const t=e.headers.get("WWW-Authenticate");if(!t)return{};const[r,n]=t.split(" ");if("bearer"!==r.toLowerCase()||!n)return{};const o=Ow(e,"resource_metadata")||void 0;let s;if(o)try{s=new URL(o)}catch{}return{resourceMetadataUrl:s,scope:Ow(e,"scope")||void 0,error:Ow(e,"error")||void 0}}function Ow(e,t){const r=e.headers.get("WWW-Authenticate");if(!r)return null;const n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function zw(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?zw(e,void 0,r):void 0;throw n}}async function Aw(e,t,r=fetch){const n={"MCP-Protocol-Version":t};return await zw(e,n,r)}async function Mw(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,resource:s,fetchFn:a}){const i=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",s.href),o)await o(c,r,i,t);else if(n){const e=function(e,t){const r=void 0!==e.client_secret;return 0===t.length?r?"client_secret_post":"none":"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&(n=e.token_endpoint_auth_method,["client_secret_basic","client_secret_post","none"].includes(n))&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none";var n}(n,t?.token_endpoint_auth_methods_supported??[]);xw(e,n,c,r)}const l=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!l.ok)throw await Nw(l);return tw.parse(await l.json())}class Uw extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function Dw(e){}function qw(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Dw,onError:r=Dw,onRetry:n=Dw,onComment:o}=e;let s,a="",i=!0,c="",l="";function u(e){if(""===e)return c.length>0&&t({id:s,event:l||void 0,data:c.endsWith("\n")?c.slice(0,-1):c}),s=void 0,c="",void(l="");if(e.startsWith(":"))return void(o&&o(e.slice(e.startsWith(": ")?2:1)));const r=e.indexOf(":");if(-1!==r){const t=e.slice(0,r),n=" "===e[r+1]?2:1;return void d(t,e.slice(r+n),e)}d(e,"",e)}function d(e,t,o){switch(e){case"event":l=t;break;case"data":c=`${c}${t}\n`;break;case"id":s=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?n(parseInt(t,10)):r(new Uw(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:o}));break;default:r(new Uw(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:o}))}}return{feed:function(e){const t=i?e.replace(/^\xEF\xBB\xBF/,""):e,[r,n]=function(e){const t=[];let r="",n=0;for(;n<e.length;){const o=e.indexOf("\r",n),s=e.indexOf("\n",n);let a=-1;if(-1!==o&&-1!==s?a=Math.min(o,s):-1!==o?a=o:-1!==s&&(a=s),-1===a){r=e.slice(n);break}{const r=e.slice(n,a);t.push(r),n=a+1,"\r"===e[n-1]&&"\n"===e[n]&&n++}}return[t,r]}(`${a}${t}`);for(const e of r)u(e);a=n,i=!1},reset:function(e={}){a&&e.consume&&u(a),i=!0,s=void 0,c="",l="",a=""}}}class Vw extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let n;super({start(o){n=qw({onEvent:e=>{o.enqueue(e)},onError(t){"terminate"===e?o.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:r})},transform(e){n.feed(e)}})}}const Fw={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Lw extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class Hw{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=function(e=fetch,t){return t?async(r,n)=>{const o={...t,...n,headers:n?.headers?{...J_(t.headers),...J_(n.headers)}:t.headers};return e(r,o)}:e}(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??Fw}async _authThenStart(){if(!this._authProvider)throw new Sw("No auth provider");let e;try{e=await Cw(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if("AUTHORIZED"!==e)throw new Sw;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=J_(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){const{resumptionToken:t}=e;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),t&&r.set("last-event-id",t);const n=await(this._fetch??fetch)(this._url,{method:"GET",headers:r,signal:this._abortController?.signal});if(!n.ok){if(await(n.body?.cancel()),401===n.status&&this._authProvider)return await this._authThenStart();if(405===n.status)return;throw new Lw(n.status,`Failed to open SSE stream: ${n.statusText}`)}this._handleSseStream(n.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(void 0!==this._serverRetryMs)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,n=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(r,e),n)}_scheduleReconnection(e,t=0){const r=this._reconnectionOptions.maxRetries;if(t>=r)return void this.onerror?.(new Error(`Maximum reconnection attempts (${r}) exceeded.`));const n=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(r=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${r instanceof Error?r.message:String(r)}`)),this._scheduleReconnection(e,t+1)})},n)}_handleSseStream(e,t,r){if(!e)return;const{onresumptiontoken:n,replayMessageId:o}=t;let s,a=!1,i=!1;(async()=>{try{const t=e.pipeThrough(new TextDecoderStream).pipeThrough(new Vw({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){const{value:e,done:r}=await t.read();if(r)break;if(e.id&&(s=e.id,a=!0,n?.(e.id)),e.data&&(!e.event||"message"===e.event))try{const t=Ts.parse(JSON.parse(e.data));Es(t)&&(i=!0,void 0!==o&&(t.id=o)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(r||a)&&!i&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:n,replayMessageId:o},0)}catch(e){this.onerror?.(new Error(`SSE stream disconnected: ${e}`));if((r||a)&&!i&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:n,replayMessageId:o},0)}catch(e){this.onerror?.(new Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}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(e){if(!this._authProvider)throw new Sw("No auth provider");if("AUTHORIZED"!==await Cw(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit}))throw new Sw("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{const{resumptionToken:n,onresumptiontoken:o}=t||{};if(n)return void this._startOrAuthSse({resumptionToken:n,replayMessageId:$s(e)?e.id:void 0}).catch(e=>this.onerror?.(e));const s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");const a={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(e),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._url,a),c=i.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!i.ok){const t=await i.text().catch(()=>null);if(401===i.status&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Lw(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:t,scope:r}=Rw(i);this._resourceMetadataUrl=t,this._scope=r;if("AUTHORIZED"!==await Cw(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit}))throw new Sw;return this._hasCompletedAuthFlow=!0,this.send(e)}if(403===i.status&&this._authProvider){const{resourceMetadataUrl:t,scope:r,error:n}=Rw(i);if("insufficient_scope"===n){const n=i.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===n)throw new Lw(403,"Server returned 403 after trying upscoping");r&&(this._scope=r),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=n??void 0;if("AUTHORIZED"!==await Cw(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch}))throw new Sw;return this.send(e)}}throw new Lw(i.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,202===i.status)return await(i.body?.cancel()),r=e,void(Hs.safeParse(r).success&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e)));const l=(Array.isArray(e)?e:[e]).filter(e=>"method"in e&&"id"in e&&void 0!==e.id).length>0,u=i.headers.get("content-type");if(l)if(u?.includes("text/event-stream"))this._handleSseStream(i.body,{onresumptiontoken:o},!1);else{if(!u?.includes("application/json"))throw await(i.body?.cancel()),new Lw(-1,`Unexpected content type: ${u}`);{const e=await i.json(),t=Array.isArray(e)?e.map(e=>Ts.parse(e)):[Ts.parse(e)];for(const e of t)this.onmessage?.(e)}}else await(i.body?.cancel())}catch(e){throw this.onerror?.(e),e}var r}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._url,t);if(await(r.body?.cancel()),!r.ok&&405!==r.status)throw new Lw(r.status,`Failed to terminate session: ${r.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}}const Kw=H("quickstart");async function Zw(t={}){if(!R)throw new Error("Interactive login is only available in Node.js environment");Kw.info("Starting interactive login flow");const r=M();let n;n=t.authIssuer?t.authIssuer:t.authDomain?t.authDomain.startsWith("http")?t.authDomain:`https://${t.authDomain}`:r.authIssuer;const{clientId:o=r.clientId,clientSecret:s=r.clientSecret,audience:a=r.apiAudience,baseUrl:i,port:c=52765}=t;if(!o||!s)throw new Error("AGENT_CLIENT_ID / AGENT_CLIENT_SECRET not set – create a .env file or export in the shell");const l=await he();if(l)try{let e;q(l)?e=U(l):(Kw.warn("Cached token has no organization information, using static config"),e=M());const t=new Ee(e.baseUrl,{token:l});return await t.validateCachedToken(),Kw.info("Using cached valid token"),t}catch(e){Kw.info("Cached token invalid, starting OAuth flow")}else Kw.info("No cached token, starting OAuth flow");const u="undefined"!=typeof process&&!(!process.env||"1"!==process.env.BARNDOOR_MANUAL_CODE&&"true"!==process.env.BARNDOOR_MANUAL_CODE);let p,f=null;if(u){const e=process.env&&process.env.BARNDOOR_REDIRECT_HOST||"127.0.0.1";p=e.startsWith("http")?`${e}:${c}/cb`:`http://${e}:${c}/cb`}else{const e=$e(c);p=e[0],f=e[1]}const m=new ve,y=await m.buildAuthorizationUrl({clientId:o,redirectUri:p,audience:a,issuer:n});Kw.info(`Auth URL: ${y}`);const g=e.platform();let v,_;try{v=new URL(y)}catch{throw new Error("Invalid auth URL")}if("https:"!==v.protocol&&("http:"!==v.protocol||"localhost"!==v.hostname&&"127.0.0.1"!==v.hostname))throw new Error("Auth URL must use HTTPS (http allowed only for localhost)");try{"darwin"===g?d("open",[y],{detached:!0,stdio:"ignore"}).unref():"win32"===g?d("powershell",["-NoProfile","Start-Process",y],{detached:!0,stdio:"ignore"}).unref():d("xdg-open",[y],{detached:!0,stdio:"ignore"}).unref(),Kw.info("Please complete login in your browser…")}catch(e){Kw.warn("Failed to open browser automatically. Please visit:",y)}if(u){const e=await new Promise(e=>{const t=h.createInterface({input:process.stdin,output:process.stdout});t.question("Paste the full redirected URL (or just the code= value): ",r=>{t.close(),e(r.trim())})});try{const t=new URL(e);_=t.searchParams.get("code")||e}catch{_=e}}else{const e=new Promise((e,t)=>{setTimeout(()=>{t(new Error(`OAuth callback timeout after 2 minutes. This usually means the callback URL is not registered in Auth0. Please add "${p}" to Allowed Callback URLs in your Auth0 application settings.`))},12e4)});_=(await Promise.race([f,e]))[0]}const w=await m.exchangeCodeForToken({clientId:o,clientSecret:s,code:_,redirectUri:p,issuer:n});let $;if(await pe(w),i)$=i;else if(q(w.access_token)){$=U(w.access_token).baseUrl}else Kw.warn("New token has no organization information, using static config"),$=M().baseUrl;return new Ee($,{token:w.access_token})}async function Gw(e,t,r={}){const{timeout:n=90}=r;Kw.info(`Ensuring ${t} server is connected`);try{await e.ensureServerConnected(t,{pollSeconds:n}),Kw.info(`Server ${t} connected successfully`)}catch(e){throw e instanceof b?Kw.error(`Server '${t}' not found`):Kw.error(`Failed to connect to ${t}:`,e),e}}async function Bw(e,t,r={}){const{serverId:n,serverSlug:o,proxyBaseUrl:s="http://proxy-ingress:8080",transport:a="streamable-http"}=r,i=n||o||t;let c;try{c=await e.getServer(i)}catch(e){if(e instanceof $&&404===e.statusCode)throw new b(i);throw e}const l=c.slug||i;let u;if(q(e.token)){u=`${U(e.token).baseUrl}/mcp/${l}`}else{Kw.warn("Token has no organization information, using static config for MCP connection");u=`${M().baseUrl}/mcp/${l}`}return[{url:u,transport:a,headers:{Accept:"application/json, text/event-stream",Authorization:`Bearer ${e.token}`,"x-barndoor-session-id":Ww()}},u]}async function Jw(e,t,r={}){const[n]=await Bw(e,t,r),o=n,s=new B_({name:"barndoor-js-sdk",version:"0.1.0"}),a=new Hw(new URL(o.url),{requestInit:{headers:o.headers}});return await s.connect(a),s}function Ww(){if(R&&"function"==typeof i.randomUUID)return i.randomUUID();if("undefined"!=typeof globalThis&&globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let e;if(R&&"function"==typeof i.randomBytes)e=i.randomBytes(16);else{if("undefined"==typeof globalThis||!globalThis.crypto?.getRandomValues)throw new Error("Secure random generator not available for UUID.");e=new Uint8Array(16),globalThis.crypto.getRandomValues(e)}const t=e??new Uint8Array(0);if(t.length<16)throw new Error("Secure random generator not available for UUID.");const r=t[6],n=t[8];t[6]=15&r|64,t[8]=63&n|128;const o=Array.from(t,e=>e.toString(16).padStart(2,"0")).join("");return`${o.substring(0,8)}-${o.substring(8,12)}-${o.substring(12,16)}-${o.substring(16,20)}-${o.substring(20)}`}const Qw=function(){try{if("undefined"!=typeof process&&process.versions?.node){const e=u(import.meta.url),t=r(e),o=n(t,"..","package.json");return JSON.parse(f(o,"utf8")).version}return'"1.3.0"'}catch(e){return console.warn("Could not read version from package.json:",e),"0.1.0"}}();export{C as AUTH_CONFIG,N as AgentToken,y as AuthenticationError,z as BarndoorConfig,m as BarndoorError,Ee as BarndoorSDK,E as ConfigurationError,w as ConnectionError,$ as HTTPError,re as JWTVerificationResult,k as OAuthError,ve as PKCEManager,x as ServerDetail,b as ServerNotFoundError,I as ServerSummary,P as TimeoutError,g as TokenError,v as TokenExpiredError,de as TokenManager,_ as TokenValidationError,D as checkTokenOrganization,fe as clearCachedToken,Y as clearOidcConfigCache,H as createScopedLogger,K as debug,Gw as ensureServerConnected,B as error,ke as getClientCredentialsToken,U as getDynamicConfig,L as getLogger,Q as getOidcConfig,M as getStaticConfig,q as hasOrganizationInfo,Z as info,j as isBrowser,R as isNode,me as isTokenActive,ye as isTokenActiveWithRefresh,he as loadUserToken,Zw as loginInteractive,Jw as makeMcpClient,Bw as makeMcpConnectionParams,pe as saveUserToken,F as setLogger,X as setTokenLogger,$e as startLocalCallbackServer,ge as validateToken,le as verifyJWTLocal,Qw as version,G as warn};