@onyxsecurity/mcp-gateway 1.0.57 → 1.0.58
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/bin/mcp-gateway.js +1 -1
- package/dist/index.js +1 -1
- package/dist/main-DrICeKMT.js +141 -0
- package/dist/main-DrICeKMT.js.map +1 -0
- package/dist/{normalizeUrl-S0KWkvwy.js → normalizeUrl-HKa4cuMt.js} +2 -2
- package/dist/{normalizeUrl-S0KWkvwy.js.map → normalizeUrl-HKa4cuMt.js.map} +1 -1
- package/package.json +1 -1
- package/dist/main-BWU2iaVZ.js +0 -141
- package/dist/main-BWU2iaVZ.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-CrDKVgUD.js";import{randomUUID as r}from"crypto";import{AsyncLocalStorage as i}from"node:async_hooks";import{randomUUID as a}from"node:crypto";import{chownSync as o,existsSync as s,mkdirSync as c,readFileSync as l}from"node:fs";import{join as u,sep as d}from"node:path";import f from"winston";import p from"winston-daily-rotate-file";import m from"env-var";import{arch as h,homedir as g,hostname as _,platform as v,userInfo as y}from"node:os";import"dotenv/config";import{chown as b}from"node:fs/promises";import x from"ps-list";import{deflateSync as S}from"node:zlib";import{URL as C}from"url";import w from"node:http";import T from"node:process";var E=class{events=new Map;async replayEventsAfter(e,{send:t}){if(!e||!this.events.has(e))return``;let n=this.getStreamIdFromEventId(e);if(!n)return``;let r=!1,i=[...this.events.entries()].sort((e,t)=>e[0].localeCompare(t[0]));for(let[a,{message:o,streamId:s}]of i){if(s!==n)continue;if(a===e){r=!0;continue}r&&await t(a,o)}return n}async storeEvent(e,t){let n=this.generateEventId(e);return this.events.set(n,{message:t,streamId:e}),n}generateEventId(e){return`${e}_${Date.now()}_${Math.random().toString(36).substring(2,10)}`}getStreamIdFromEventId(e){let t=e.split(`_`);return t.length>0?t[0]:``}},D;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(D||={});var O;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(O||={});const k=D.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),A=e=>{switch(typeof e){case`undefined`:return k.undefined;case`string`:return k.string;case`number`:return Number.isNaN(e)?k.nan:k.number;case`boolean`:return k.boolean;case`function`:return k.function;case`bigint`:return k.bigint;case`symbol`:return k.symbol;case`object`:return Array.isArray(e)?k.array:e===null?k.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?k.promise:typeof Map<`u`&&e instanceof Map?k.map:typeof Set<`u`&&e instanceof Set?k.set:typeof Date<`u`&&e instanceof Date?k.date:k.object;default:return k.unknown}},j=D.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]);var M=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,D.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};M.create=e=>new M(e);var N=(e,t)=>{let n;switch(e.code){case j.invalid_type:n=e.received===k.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case j.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,D.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:n=`Unrecognized key(s) in object: ${D.joinValues(e.keys,`, `)}`;break;case j.invalid_union:n=`Invalid input`;break;case j.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${D.joinValues(e.options)}`;break;case j.invalid_enum_value:n=`Invalid enum value. Expected ${D.joinValues(e.options)}, received '${e.received}'`;break;case j.invalid_arguments:n=`Invalid function arguments`;break;case j.invalid_return_type:n=`Invalid function return type`;break;case j.invalid_date:n=`Invalid date`;break;case j.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:D.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case j.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case j.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case j.custom:n=`Invalid input`;break;case j.invalid_intersection_types:n=`Intersection results could not be merged`;break;case j.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case j.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,D.assertNever(e)}return{message:n}};let P=N;function F(){return P}const ee=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function I(e,t){let n=F(),r=ee({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===N?void 0:N].filter(e=>!!e)});e.common.issues.push(r)}var L=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return R;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return R;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const R=Object.freeze({status:`aborted`}),te=e=>({status:`dirty`,value:e}),z=e=>({status:`valid`,value:e}),B=e=>e.status===`aborted`,ne=e=>e.status===`dirty`,V=e=>e.status===`valid`,H=e=>typeof Promise<`u`&&e instanceof Promise;var U;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(U||={});var re=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const ie=(e,t)=>{if(V(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new M(e.common.issues),this._error}}};function W(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var G=class{get description(){return this._def.description}_getType(e){return A(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:A(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new L,ctx:{common:e.parent.common,data:e.data,parsedType:A(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(H(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},r=this._parseSync({data:e,path:n.path,parent:n});return ie(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return V(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>V(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(H(r)?r:Promise.resolve(r));return ie(n,i)}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:j.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new ot({schema:this,typeName:K.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return st.create(this,this._def)}nullable(){return ct.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ve.create(this)}promise(){return at.create(this,this._def)}or(e){return We.create([this,e],this._def)}and(e){return Je.create(this,e,this._def)}transform(e){return new ot({...W(this._def),schema:this,typeName:K.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new lt({...W(this._def),innerType:this,defaultValue:t,typeName:K.ZodDefault})}brand(){return new ft({typeName:K.ZodBranded,type:this,...W(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ut({...W(this._def),innerType:this,catchValue:t,typeName:K.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pt.create(this,e)}readonly(){return mt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const ae=/^c[^\s-]{8,}$/i,oe=/^[0-9a-z]+$/,se=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ce=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,le=/^[a-z0-9_-]{21}$/i,ue=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,de=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,fe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let pe;const me=/^(?:(?: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])$/,he=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ge=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,_e=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ve=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ye=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,be=`((\\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])))`,xe=RegExp(`^${be}$`);function Se(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Ce(e){return RegExp(`^${Se(e)}$`)}function we(e){let t=`${be}T${Se(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Te(e,t){return!!((t===`v4`||!t)&&me.test(e)||(t===`v6`||!t)&&ge.test(e))}function Ee(e,t){if(!ue.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function De(e,t){return!!((t===`v4`||!t)&&he.test(e)||(t===`v6`||!t)&&_e.test(e))}var Oe=class e extends G{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==k.string){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.string,received:t.parsedType}),R}let t=new L,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),I(n,{code:j.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),I(n,{code:j.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?I(n,{code:j.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&I(n,{code:j.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)fe.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`email`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)pe||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),pe.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`emoji`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)ce.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`uuid`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)le.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`nanoid`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)ae.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`cuid`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)oe.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`cuid2`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)se.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`ulid`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),I(n,{validation:`url`,code:j.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`regex`,code:j.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?we(r).test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?xe.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Ce(r).test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?de.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`duration`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Te(e.data,r.version)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`ip`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Ee(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`jwt`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?De(e.data,r.version)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`cidr`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?ve.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`base64`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?ye.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`base64url`,code:j.invalid_string,message:r.message}),t.dirty()):D.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:j.invalid_string,...U.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...U.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...U.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...U.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...U.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...U.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...U.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...U.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...U.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...U.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...U.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...U.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...U.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...U.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...U.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...U.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...U.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...U.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...U.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...U.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...U.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...U.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...U.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...U.errToObj(t)})}nonempty(e){return this.min(1,U.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Oe.create=e=>new Oe({checks:[],typeName:K.ZodString,coerce:e?.coerce??!1,...W(e)});function ke(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(`.`,``)),o=Number.parseInt(t.toFixed(i).replace(`.`,``));return a%o/10**i}var Ae=class e extends G{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==k.number){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.number,received:t.parsedType}),R}let t,n=new L;for(let r of this._def.checks)r.kind===`int`?D.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),I(t,{code:j.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?ke(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),I(t,{code:j.not_finite,message:r.message}),n.dirty()):D.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,U.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,U.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,U.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,U.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:U.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:U.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:U.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:U.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:U.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:U.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:U.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:U.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:U.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:U.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&D.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Ae.create=e=>new Ae({checks:[],typeName:K.ZodNumber,coerce:e?.coerce||!1,...W(e)});var je=class e extends G{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==k.bigint)return this._getInvalidInput(e);let t,n=new L;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):D.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.bigint,received:t.parsedType}),R}gte(e,t){return this.setLimit(`min`,e,!0,U.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,U.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,U.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,U.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:U.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:U.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:U.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:U.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:U.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:U.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};je.create=e=>new je({checks:[],typeName:K.ZodBigInt,coerce:e?.coerce??!1,...W(e)});var Me=class extends G{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==k.boolean){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.boolean,received:t.parsedType}),R}return z(e.data)}};Me.create=e=>new Me({typeName:K.ZodBoolean,coerce:e?.coerce||!1,...W(e)});var Ne=class e extends G{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==k.date){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.date,received:t.parsedType}),R}if(Number.isNaN(e.data.getTime())){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_date}),R}let t=new L,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),I(n,{code:j.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),I(n,{code:j.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):D.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:U.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:U.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Ne.create=e=>new Ne({checks:[],coerce:e?.coerce||!1,typeName:K.ZodDate,...W(e)});var Pe=class extends G{_parse(e){if(this._getType(e)!==k.symbol){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.symbol,received:t.parsedType}),R}return z(e.data)}};Pe.create=e=>new Pe({typeName:K.ZodSymbol,...W(e)});var Fe=class extends G{_parse(e){if(this._getType(e)!==k.undefined){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.undefined,received:t.parsedType}),R}return z(e.data)}};Fe.create=e=>new Fe({typeName:K.ZodUndefined,...W(e)});var Ie=class extends G{_parse(e){if(this._getType(e)!==k.null){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.null,received:t.parsedType}),R}return z(e.data)}};Ie.create=e=>new Ie({typeName:K.ZodNull,...W(e)});var Le=class extends G{constructor(){super(...arguments),this._any=!0}_parse(e){return z(e.data)}};Le.create=e=>new Le({typeName:K.ZodAny,...W(e)});var Re=class extends G{constructor(){super(...arguments),this._unknown=!0}_parse(e){return z(e.data)}};Re.create=e=>new Re({typeName:K.ZodUnknown,...W(e)});var ze=class extends G{_parse(e){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.never,received:t.parsedType}),R}};ze.create=e=>new ze({typeName:K.ZodNever,...W(e)});var Be=class extends G{_parse(e){if(this._getType(e)!==k.undefined){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.void,received:t.parsedType}),R}return z(e.data)}};Be.create=e=>new Be({typeName:K.ZodVoid,...W(e)});var Ve=class e extends G{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==k.array)return I(t,{code:j.invalid_type,expected:k.array,received:t.parsedType}),R;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(I(t,{code:e?j.too_big:j.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(I(t,{code:j.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(I(t,{code:j.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new re(t,e,t.path,n)))).then(e=>L.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new re(t,e,t.path,n)));return L.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:U.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:U.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:U.toString(n)}})}nonempty(e){return this.min(1,e)}};Ve.create=(e,t)=>new Ve({type:e,minLength:null,maxLength:null,exactLength:null,typeName:K.ZodArray,...W(t)});function He(e){if(e instanceof Ue){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=st.create(He(r))}return new Ue({...e._def,shape:()=>t})}else if(e instanceof Ve)return new Ve({...e._def,type:He(e.element)});else if(e instanceof st)return st.create(He(e.unwrap()));else if(e instanceof ct)return ct.create(He(e.unwrap()));else if(e instanceof Ye)return Ye.create(e.items.map(e=>He(e)));else return e}var Ue=class e extends G{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=D.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==k.object){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.object,received:t.parsedType}),R}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ze&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new re(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ze){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(I(n,{code:j.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new re(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>L.mergeObjectSync(t,e)):L.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return U.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:U.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:K.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of D.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of D.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return He(this)}partial(t){let n={};for(let e of D.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of D.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof st;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return nt(D.objectKeys(this.shape))}};Ue.create=(e,t)=>new Ue({shape:()=>e,unknownKeys:`strip`,catchall:ze.create(),typeName:K.ZodObject,...W(t)}),Ue.strictCreate=(e,t)=>new Ue({shape:()=>e,unknownKeys:`strict`,catchall:ze.create(),typeName:K.ZodObject,...W(t)}),Ue.lazycreate=(e,t)=>new Ue({shape:e,unknownKeys:`strip`,catchall:ze.create(),typeName:K.ZodObject,...W(t)});var We=class extends G{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new M(e.ctx.common.issues));return I(t,{code:j.invalid_union,unionErrors:n}),R}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new M(e));return I(t,{code:j.invalid_union,unionErrors:i}),R}}get options(){return this._def.options}};We.create=(e,t)=>new We({options:e,typeName:K.ZodUnion,...W(t)});const Ge=e=>e instanceof et?Ge(e.schema):e instanceof ot?Ge(e.innerType()):e instanceof tt?[e.value]:e instanceof rt?e.options:e instanceof it?D.objectValues(e.enum):e instanceof lt?Ge(e._def.innerType):e instanceof Fe?[void 0]:e instanceof Ie?[null]:e instanceof st?[void 0,...Ge(e.unwrap())]:e instanceof ct?[null,...Ge(e.unwrap())]:e instanceof ft||e instanceof mt?Ge(e.unwrap()):e instanceof ut?Ge(e._def.innerType):[];var Ke=class e extends G{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.object)return I(t,{code:j.invalid_type,expected:k.object,received:t.parsedType}),R;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(I(t,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),R)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ge(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:K.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...W(r)})}};function qe(e,t){let n=A(e),r=A(t);if(e===t)return{valid:!0,data:e};if(n===k.object&&r===k.object){let n=D.objectKeys(t),r=D.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=qe(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===k.array&&r===k.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=qe(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===k.date&&r===k.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Je=class extends G{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(B(e)||B(r))return R;let i=qe(e.value,r.value);return i.valid?((ne(e)||ne(r))&&t.dirty(),{status:t.value,value:i.data}):(I(n,{code:j.invalid_intersection_types}),R)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Je.create=(e,t,n)=>new Je({left:e,right:t,typeName:K.ZodIntersection,...W(n)});var Ye=class e extends G{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.array)return I(n,{code:j.invalid_type,expected:k.array,received:n.parsedType}),R;if(n.data.length<this._def.items.length)return I(n,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),R;!this._def.rest&&n.data.length>this._def.items.length&&(I(n,{code:j.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new re(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>L.mergeArray(t,e)):L.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ye.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ye({items:e,typeName:K.ZodTuple,rest:null,...W(t)})};var Xe=class e extends G{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.object)return I(n,{code:j.invalid_type,expected:k.object,received:n.parsedType}),R;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new re(n,e,n.path,e)),value:a._parse(new re(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?L.mergeObjectAsync(t,r):L.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof G?new e({keyType:t,valueType:n,typeName:K.ZodRecord,...W(r)}):new e({keyType:Oe.create(),valueType:t,typeName:K.ZodRecord,...W(n)})}},Ze=class extends G{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.map)return I(n,{code:j.invalid_type,expected:k.map,received:n.parsedType}),R;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new re(n,e,n.path,[a,`key`])),value:i._parse(new re(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return R;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return R;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Ze.create=(e,t,n)=>new Ze({valueType:t,keyType:e,typeName:K.ZodMap,...W(n)});var Qe=class e extends G{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.set)return I(n,{code:j.invalid_type,expected:k.set,received:n.parsedType}),R;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(I(n,{code:j.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(I(n,{code:j.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return R;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new re(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:U.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:U.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Qe.create=(e,t)=>new Qe({valueType:e,minSize:null,maxSize:null,typeName:K.ZodSet,...W(t)});var $e=class e extends G{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.function)return I(t,{code:j.invalid_type,expected:k.function,received:t.parsedType}),R;function n(e,n){return ee({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,F(),N].filter(e=>!!e),issueData:{code:j.invalid_arguments,argumentsError:n}})}function r(e,n){return ee({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,F(),N].filter(e=>!!e),issueData:{code:j.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof at){let e=this;return z(async function(...t){let o=new M([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return z(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new M([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new M([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ye.create(t).rest(Re.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ye.create([]).rest(Re.create()),returns:n||Re.create(),typeName:K.ZodFunction,...W(r)})}},et=class extends G{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};et.create=(e,t)=>new et({getter:e,typeName:K.ZodLazy,...W(t)});var tt=class extends G{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return I(t,{received:t.data,code:j.invalid_literal,expected:this._def.value}),R}return{status:`valid`,value:e.data}}get value(){return this._def.value}};tt.create=(e,t)=>new tt({value:e,typeName:K.ZodLiteral,...W(t)});function nt(e,t){return new rt({values:e,typeName:K.ZodEnum,...W(t)})}var rt=class e extends G{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return I(t,{expected:D.joinValues(n),received:t.parsedType,code:j.invalid_type}),R}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return I(t,{received:t.data,code:j.invalid_enum_value,options:n}),R}return z(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};rt.create=nt;var it=class extends G{_parse(e){let t=D.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==k.string&&n.parsedType!==k.number){let e=D.objectValues(t);return I(n,{expected:D.joinValues(e),received:n.parsedType,code:j.invalid_type}),R}if(this._cache||=new Set(D.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=D.objectValues(t);return I(n,{received:n.data,code:j.invalid_enum_value,options:e}),R}return z(e.data)}get enum(){return this._def.values}};it.create=(e,t)=>new it({values:e,typeName:K.ZodNativeEnum,...W(t)});var at=class extends G{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.promise&&t.common.async===!1)return I(t,{code:j.invalid_type,expected:k.promise,received:t.parsedType}),R;let n=t.parsedType===k.promise?t.data:Promise.resolve(t.data);return z(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};at.create=(e,t)=>new at({type:e,typeName:K.ZodPromise,...W(t)});var ot=class extends G{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===K.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{I(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return R;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?R:r.status===`dirty`||t.value===`dirty`?te(r.value):r});{if(t.value===`aborted`)return R;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?R:r.status===`dirty`||t.value===`dirty`?te(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?R:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?R:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!V(e))return R;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>V(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):R);D.assertNever(r)}};ot.create=(e,t,n)=>new ot({schema:e,typeName:K.ZodEffects,effect:t,...W(n)}),ot.createWithPreprocess=(e,t,n)=>new ot({schema:t,effect:{type:`preprocess`,transform:e},typeName:K.ZodEffects,...W(n)});var st=class extends G{_parse(e){return this._getType(e)===k.undefined?z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};st.create=(e,t)=>new st({innerType:e,typeName:K.ZodOptional,...W(t)});var ct=class extends G{_parse(e){return this._getType(e)===k.null?z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ct.create=(e,t)=>new ct({innerType:e,typeName:K.ZodNullable,...W(t)});var lt=class extends G{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===k.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};lt.create=(e,t)=>new lt({innerType:e,typeName:K.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...W(t)});var ut=class extends G{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return H(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ut.create=(e,t)=>new ut({innerType:e,typeName:K.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...W(t)});var dt=class extends G{_parse(e){if(this._getType(e)!==k.nan){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.nan,received:t.parsedType}),R}return{status:`valid`,value:e.data}}};dt.create=e=>new dt({typeName:K.ZodNaN,...W(e)});var ft=class extends G{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},pt=class e extends G{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?R:e.status===`dirty`?(t.dirty(),te(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?R:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:K.ZodPipeline})}},mt=class extends G{_parse(e){let t=this._def.innerType._parse(e),n=e=>(V(e)&&(e.value=Object.freeze(e.value)),e);return H(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};mt.create=(e,t)=>new mt({innerType:e,typeName:K.ZodReadonly,...W(t)}),Ue.lazycreate;var K;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(K||={});const q=Oe.create,ht=Ae.create;dt.create,je.create;const gt=Me.create;Ne.create,Pe.create,Fe.create,Ie.create;const _t=Le.create,vt=Re.create;ze.create,Be.create;const J=Ve.create,Y=Ue.create;Ue.strictCreate;const yt=We.create,bt=Ke.create;Je.create,Ye.create;const xt=Xe.create;Ze.create,Qe.create,$e.create,et.create;const X=tt.create,St=rt.create;it.create,at.create,ot.create;const Z=st.create;ct.create,ot.createWithPreprocess,pt.create;const Ct=R,wt=`2025-06-18`,Tt=[wt,`2025-03-26`,`2024-11-05`,`2024-10-07`],Et=yt([q(),ht().int()]),Dt=q(),Ot=Y({progressToken:Z(Et)}).passthrough(),kt=Y({_meta:Z(Ot)}).passthrough(),At=Y({method:q(),params:Z(kt)}),jt=Y({_meta:Z(Y({}).passthrough())}).passthrough(),Mt=Y({method:q(),params:Z(jt)}),Nt=Y({_meta:Z(Y({}).passthrough())}).passthrough(),Pt=yt([q(),ht().int()]),Ft=Y({jsonrpc:X(`2.0`),id:Pt}).merge(At).strict(),It=e=>Ft.safeParse(e).success,Lt=Y({jsonrpc:X(`2.0`)}).merge(Mt).strict(),Rt=e=>Lt.safeParse(e).success,zt=Y({jsonrpc:X(`2.0`),id:Pt,result:Nt}).strict(),Bt=e=>zt.safeParse(e).success;var Vt;(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`})(Vt||={});const Ht=Y({jsonrpc:X(`2.0`),id:Pt,error:Y({code:ht().int(),message:q(),data:Z(vt())})}).strict(),Ut=e=>Ht.safeParse(e).success,Wt=yt([Ft,Lt,zt,Ht]),Gt=Nt.strict(),Kt=Mt.extend({method:X(`notifications/cancelled`),params:jt.extend({requestId:Pt,reason:q().optional()})}),qt=Y({src:q(),mimeType:Z(q()),sizes:Z(q())}).passthrough(),Jt=Y({name:q(),title:Z(q())}).passthrough(),Yt=Jt.extend({version:q(),websiteUrl:Z(q()),icons:Z(J(qt))}),Xt=Y({experimental:Z(Y({}).passthrough()),sampling:Z(Y({}).passthrough()),elicitation:Z(Y({}).passthrough()),roots:Z(Y({listChanged:Z(gt())}).passthrough())}).passthrough(),Zt=At.extend({method:X(`initialize`),params:kt.extend({protocolVersion:q(),capabilities:Xt,clientInfo:Yt})}),Qt=e=>Zt.safeParse(e).success,$t=Y({experimental:Z(Y({}).passthrough()),logging:Z(Y({}).passthrough()),completions:Z(Y({}).passthrough()),prompts:Z(Y({listChanged:Z(gt())}).passthrough()),resources:Z(Y({subscribe:Z(gt()),listChanged:Z(gt())}).passthrough()),tools:Z(Y({listChanged:Z(gt())}).passthrough())}).passthrough(),en=Nt.extend({protocolVersion:q(),capabilities:$t,serverInfo:Yt,instructions:Z(q())}),tn=Mt.extend({method:X(`notifications/initialized`)}),nn=e=>tn.safeParse(e).success,rn=At.extend({method:X(`ping`)}),an=Y({progress:ht(),total:Z(ht()),message:Z(q())}).passthrough(),on=Mt.extend({method:X(`notifications/progress`),params:jt.merge(an).extend({progressToken:Et})}),sn=At.extend({params:kt.extend({cursor:Z(Dt)}).optional()}),cn=Nt.extend({nextCursor:Z(Dt)}),ln=Y({uri:q(),mimeType:Z(q()),_meta:Z(Y({}).passthrough())}).passthrough(),un=ln.extend({text:q()}),dn=q().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),fn=ln.extend({blob:dn}),pn=Jt.extend({uri:q(),description:Z(q()),mimeType:Z(q()),icons:Z(J(qt)),_meta:Z(Y({}).passthrough())}),mn=Jt.extend({uriTemplate:q(),description:Z(q()),mimeType:Z(q()),_meta:Z(Y({}).passthrough())}),hn=sn.extend({method:X(`resources/list`)}),gn=cn.extend({resources:J(pn)}),_n=sn.extend({method:X(`resources/templates/list`)}),vn=cn.extend({resourceTemplates:J(mn)}),yn=At.extend({method:X(`resources/read`),params:kt.extend({uri:q()})}),bn=Nt.extend({contents:J(yt([un,fn]))}),xn=Mt.extend({method:X(`notifications/resources/list_changed`)}),Sn=At.extend({method:X(`resources/subscribe`),params:kt.extend({uri:q()})}),Cn=At.extend({method:X(`resources/unsubscribe`),params:kt.extend({uri:q()})}),wn=Mt.extend({method:X(`notifications/resources/updated`),params:jt.extend({uri:q()})}),Tn=Y({name:q(),description:Z(q()),required:Z(gt())}).passthrough(),En=Jt.extend({description:Z(q()),arguments:Z(J(Tn)),icons:Z(J(qt)),_meta:Z(Y({}).passthrough())}),Dn=sn.extend({method:X(`prompts/list`)}),On=cn.extend({prompts:J(En)}),kn=At.extend({method:X(`prompts/get`),params:kt.extend({name:q(),arguments:Z(xt(q()))})}),An=Y({type:X(`text`),text:q(),_meta:Z(Y({}).passthrough())}).passthrough(),jn=Y({type:X(`image`),data:dn,mimeType:q(),_meta:Z(Y({}).passthrough())}).passthrough(),Mn=Y({type:X(`audio`),data:dn,mimeType:q(),_meta:Z(Y({}).passthrough())}).passthrough(),Nn=Y({type:X(`resource`),resource:yt([un,fn]),_meta:Z(Y({}).passthrough())}).passthrough(),Pn=pn.extend({type:X(`resource_link`)}),Fn=yt([An,jn,Mn,Pn,Nn]),In=Y({role:St([`user`,`assistant`]),content:Fn}).passthrough(),Ln=Nt.extend({description:Z(q()),messages:J(In)}),Rn=Mt.extend({method:X(`notifications/prompts/list_changed`)}),zn=Y({title:Z(q()),readOnlyHint:Z(gt()),destructiveHint:Z(gt()),idempotentHint:Z(gt()),openWorldHint:Z(gt())}).passthrough(),Bn=Jt.extend({description:Z(q()),inputSchema:Y({type:X(`object`),properties:Z(Y({}).passthrough()),required:Z(J(q()))}).passthrough(),outputSchema:Z(Y({type:X(`object`),properties:Z(Y({}).passthrough()),required:Z(J(q()))}).passthrough()),annotations:Z(zn),icons:Z(J(qt)),_meta:Z(Y({}).passthrough())}),Vn=sn.extend({method:X(`tools/list`)}),Hn=cn.extend({tools:J(Bn)}),Un=Nt.extend({content:J(Fn).default([]),structuredContent:Y({}).passthrough().optional(),isError:Z(gt())});Un.or(Nt.extend({toolResult:vt()}));const Wn=At.extend({method:X(`tools/call`),params:kt.extend({name:q(),arguments:Z(xt(vt()))})}),Gn=Mt.extend({method:X(`notifications/tools/list_changed`)}),Kn=St([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),qn=At.extend({method:X(`logging/setLevel`),params:kt.extend({level:Kn})}),Jn=Mt.extend({method:X(`notifications/message`),params:jt.extend({level:Kn,logger:Z(q()),data:vt()})}),Yn=Y({name:q().optional()}).passthrough(),Xn=Y({hints:Z(J(Yn)),costPriority:Z(ht().min(0).max(1)),speedPriority:Z(ht().min(0).max(1)),intelligencePriority:Z(ht().min(0).max(1))}).passthrough(),Zn=Y({role:St([`user`,`assistant`]),content:yt([An,jn,Mn])}).passthrough(),Qn=At.extend({method:X(`sampling/createMessage`),params:kt.extend({messages:J(Zn),systemPrompt:Z(q()),includeContext:Z(St([`none`,`thisServer`,`allServers`])),temperature:Z(ht()),maxTokens:ht().int(),stopSequences:Z(J(q())),metadata:Z(Y({}).passthrough()),modelPreferences:Z(Xn)})}),$n=Nt.extend({model:q(),stopReason:Z(St([`endTurn`,`stopSequence`,`maxTokens`]).or(q())),role:St([`user`,`assistant`]),content:bt(`type`,[An,jn,Mn])}),er=Y({type:X(`boolean`),title:Z(q()),description:Z(q()),default:Z(gt())}).passthrough(),tr=Y({type:X(`string`),title:Z(q()),description:Z(q()),minLength:Z(ht()),maxLength:Z(ht()),format:Z(St([`email`,`uri`,`date`,`date-time`]))}).passthrough(),nr=Y({type:St([`number`,`integer`]),title:Z(q()),description:Z(q()),minimum:Z(ht()),maximum:Z(ht())}).passthrough(),rr=Y({type:X(`string`),title:Z(q()),description:Z(q()),enum:J(q()),enumNames:Z(J(q()))}).passthrough(),ir=yt([er,tr,nr,rr]),ar=At.extend({method:X(`elicitation/create`),params:kt.extend({message:q(),requestedSchema:Y({type:X(`object`),properties:xt(q(),ir),required:Z(J(q()))}).passthrough()})}),or=Nt.extend({action:St([`accept`,`decline`,`cancel`]),content:Z(xt(q(),vt()))}),sr=Y({type:X(`ref/resource`),uri:q()}).passthrough(),cr=Y({type:X(`ref/prompt`),name:q()}).passthrough(),lr=At.extend({method:X(`completion/complete`),params:kt.extend({ref:yt([cr,sr]),argument:Y({name:q(),value:q()}).passthrough(),context:Z(Y({arguments:Z(xt(q(),q()))}))})}),ur=Nt.extend({completion:Y({values:J(q()).max(100),total:Z(ht().int()),hasMore:Z(gt())}).passthrough()}),dr=Y({uri:q().startsWith(`file://`),name:Z(q()),_meta:Z(Y({}).passthrough())}).passthrough(),fr=At.extend({method:X(`roots/list`)}),pr=Nt.extend({roots:J(dr)}),mr=Mt.extend({method:X(`notifications/roots/list_changed`)});yt([rn,Zt,lr,qn,kn,Dn,hn,_n,yn,Sn,Cn,Wn,Vn]),yt([Kt,on,tn,mr]),yt([Gt,$n,or,pr]),yt([rn,Qn,ar,fr]),yt([Kt,on,Jn,wn,xn,Gn,Rn]),yt([Gt,en,ur,Ln,On,gn,vn,bn,Un,Hn]);var hr=class extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}},gr=class extends Error{extra;tags;constructor(e,t,n={},r={}){super(t),this.name=e,this.tags=n,this.extra=r}},_r=class extends gr{constructor(e,t=`access_denied`,n={}){super(`AccessControlBlockError`,e,{feature:`access_control`,module:`security`,operation:`block`},{reason:t,...n}),this.reason=t}},vr=class extends gr{constructor(e,t,n={}){super(`ConfigurationError`,e,{feature:`configuration`,module:`cli`,operation:`validate`},{configKey:t,...n})}},yr=class extends gr{constructor(e,t,n,r={}){super(`ProxyConnectionError`,e,{feature:`connection`,module:`proxy`,operation:`connect`,transport:n||`unknown`},{url:t?(()=>{try{return new URL(t).origin}catch{return t}})():void 0,...r})}};const br={APP_VERSION:`1.0.57`,NODE_ENV:`development`,OAUTH_PROVIDERS:[{authorizationEndpoint:`https://github.com/login/oauth/authorize`,clientId:`Ov23liDj6mzRyvM5n0yG`,id:`github`,name:`GitHub`,tokenEndpoint:`https://github.com/login/oauth/access_token`,urlPatterns:[`github.com`,`api.github.com`,`githubcopilot.com`,`api.githubcopilot.com`],clientSecret:`d467125f345a6edd5de0254a5a9b6bdde26fdd86`,scopes:[`read:user`,`repo`,`gist`,`notifications`,`project`,`public_repo`,`read:gpg_key`,`read:org`,`repo:status`,`repo_deployment`,`user`,`user:email`,`user:follow`],usePkce:!0,tokenEndpointAuthMethod:`client_secret_post`}]},xr=m.get,Sr=br.APP_VERSION,Cr=e=>{let t={};if(e){let n=e.split(`,`);for(let e of n){let[n,...r]=e.split(`:`);n&&r.length>0&&(t[n.trim()]=r.join(`:`).trim())}}return t},wr=e=>{try{let t=new URL(e),n=t.pathname.split(`/`).filter(Boolean)[0]===`ingest`?`/ingest`:``;return`${t.protocol}//${t.host}${n}/endpoint-logs`}catch{return null}},Tr=e=>{try{let t=new URL(e),n=`/guard/evaluate/v1`;return t.pathname.includes(n)?(t.pathname=t.pathname.replace(n,`/access-control/authorize`),t.toString()):(console.warn(`[mcp-gateway] Warning: SCANNER_URL does not contain expected path "${n}". Access control URL derivation skipped. Current path: "${t.pathname}". Please set MCP_GATEWAY_ACCESS_CONTROL_URL explicitly.`),null)}catch(e){return console.warn(`[mcp-gateway] Warning: Failed to parse SCANNER_URL as valid URL: ${e instanceof Error?e.message:String(e)}. Please set MCP_GATEWAY_ACCESS_CONTROL_URL explicitly.`),null}},Er=r(),Dr=xr(`NODE_ENV`).default(br.NODE_ENV||`development`).asEnum([`development`,`production`,`staging`,`test`]),Or=xr(`DEBUG`).default(`false`).asBool()||xr(`MCP_GATEWAY_DEBUG`).default(`false`).asBool(),kr=xr(`MCP_GATEWAY_SCANNER_URL`).default(``).asString()||null,Ar=xr(`MCP_GATEWAY_SCANNER_API_KEY`).default(``).asString()||void 0,jr=xr(`MCP_GATEWAY_MIRROR_URL`).default(``).asString()||null,Mr=(()=>{let e=xr(`MCP_GATEWAY_SCANNER_HEADERS`).required(!1).asString();return e?Cr(e):{}})(),Nr=xr(`MCP_GATEWAY_SCANNER_TIMEOUT_MS`).default(`20000`).asIntPositive(),Pr=xr(`MCP_GATEWAY_SCANNER_FAIL_OPEN`).default(`true`).asBool(),Fr=xr(`MCP_GATEWAY_COMMAND`).default(`mcp-gateway`).asString(),Ir=xr(`CLIENT_APP_NAME`).default(``).asString(),Lr=xr(`MCP_GATEWAY_LOG_DIR`).default(u(g(),`.onyx`,`mcp-gateway`,`logs`)).asString(),Rr=xr(`MCP_GATEWAY_OAUTH_DIR`).default(u(g(),`.onyx`,`mcp-gateway`,`oauth`)).asString(),zr=(()=>xr(`MCP_GATEWAY_ACCESS_CONTROL_URL`).default(``).asString()||(kr?Tr(kr):null))(),Br=(()=>{let e=xr(`MCP_GATEWAY_ACCESS_CONTROL_HEADERS`).required(!1).asString();return e?Cr(e):{}})(),Vr=xr(`MCP_GATEWAY_ACCESS_CONTROL_TIMEOUT_MS`).default(`3000`).asIntPositive(),Hr=xr(`MCP_GATEWAY_LOG_INGEST_ENABLED`).default(`true`).asBool(),Ur=xr(`MCP_GATEWAY_LOG_INGEST_TIMEOUT_MS`).default(`5000`).asIntPositive(),Wr=(()=>xr(`MCP_GATEWAY_LOG_INGEST_URL`).default(``).asString()||(jr?wr(jr):kr?wr(kr):null))(),Gr={accessControl:{enabled:!!(zr&&Ar),headers:Br,timeoutMs:Vr,url:zr},appVersion:Sr,clientAppName:Ir,debug:Or,environment:Dr,logDir:Lr,logIngest:{apiKey:Ar,enabled:Hr&&!!(Wr&&Ar),timeoutMs:Ur,url:Wr},oauthDir:Rr,proxyCommand:Fr,scanner:{apiKey:Ar,enabled:!!kr,failOpen:Pr,headers:Mr,timeoutMs:Nr,url:kr}};async function Kr(e){let t=Yr();if(!t)return;let n=Jr(e);if(!n){await b(e,t.uid,t.gid);return}for(let e of n)await b(e,t.uid,t.gid)}function qr(e){let t=Yr();if(!t)return;let n=Jr(e);if(!n){o(e,t.uid,t.gid);return}for(let e of n)o(e,t.uid,t.gid)}function Jr(e){if(!e.startsWith(d))return;let t=e.split(d),n=t.indexOf(`.onyx`);if(n===-1)return;let r=[];for(let e=n;e<t.length;e++)r.push(t.slice(0,e+1).join(d));return r}function Yr(){if(typeof process.getuid!=`function`||process.getuid()!==0)return;let e=process.env.SUDO_UID,t=process.env.SUDO_GID;if(!e||!t)return;let n=parseInt(e,10),r=parseInt(t,10);if(!(isNaN(n)||isNaN(r)))return{gid:r,uid:n}}var Xr=e(((exports,n)=>{n.exports=t(`util`).deprecate})),Zr=e(((exports,n)=>{n.exports=t(`stream`)})),Qr=e(((exports,t)=>{function n(e,t){var n=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(o,this,e)):process.nextTick(o,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted?process.nextTick(i,n):(n._writableState.errorEmitted=!0,process.nextTick(r,n,e)):process.nextTick(r,n,e):t?(process.nextTick(i,n),t(e)):process.nextTick(i,n)}),this)}function r(e,t){o(e,t),i(e)}function i(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit(`close`)}function a(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function o(e,t){e.emit(`error`,t)}function s(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit(`error`,t)}t.exports={destroy:n,undestroy:a,errorOrDestroy:s}})),$r=e(((exports,t)=>{let n={};function r(e,t,r){r||=Error;function i(e,n,r){return typeof t==`string`?t:t(e,n,r)}class a extends r{constructor(e,t,n){super(i(e,t,n))}}a.prototype.name=r.name,a.prototype.code=e,n[e]=a}function i(e,t){if(Array.isArray(e)){let n=e.length;return e=e.map(e=>String(e)),n>2?`one of ${t} ${e.slice(0,n-1).join(`, `)}, or `+e[n-1]:n===2?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}else return`of ${t} ${String(e)}`}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function o(e,t,n){return(n===void 0||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function s(e,t,n){return typeof n!=`number`&&(n=0),n+t.length>e.length?!1:e.indexOf(t,n)!==-1}r(`ERR_INVALID_OPT_VALUE`,function(e,t){return`The value "`+t+`" is invalid for option "`+e+`"`},TypeError),r(`ERR_INVALID_ARG_TYPE`,function(e,t,n){let r;typeof t==`string`&&a(t,`not `)?(r=`must not be`,t=t.replace(/^not /,``)):r=`must be`;let c;if(o(e,` argument`))c=`The ${e} ${r} ${i(t,`type`)}`;else{let n=s(e,`.`)?`property`:`argument`;c=`The "${e}" ${n} ${r} ${i(t,`type`)}`}return c+=`. Received type ${typeof n}`,c},TypeError),r(`ERR_STREAM_PUSH_AFTER_EOF`,`stream.push() after EOF`),r(`ERR_METHOD_NOT_IMPLEMENTED`,function(e){return`The `+e+` method is not implemented`}),r(`ERR_STREAM_PREMATURE_CLOSE`,`Premature close`),r(`ERR_STREAM_DESTROYED`,function(e){return`Cannot call `+e+` after a stream was destroyed`}),r(`ERR_MULTIPLE_CALLBACK`,`Callback called multiple times`),r(`ERR_STREAM_CANNOT_PIPE`,`Cannot pipe, not readable`),r(`ERR_STREAM_WRITE_AFTER_END`,`write after end`),r(`ERR_STREAM_NULL_VALUES`,`May not write null values to stream`,TypeError),r(`ERR_UNKNOWN_ENCODING`,function(e){return`Unknown encoding: `+e},TypeError),r(`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,`stream.unshift() after end event`),t.exports.codes=n})),ei=e(((exports,t)=>{var n=$r().codes.ERR_INVALID_OPT_VALUE;function r(e,t,n){return e.highWaterMark==null?t?e[n]:null:e.highWaterMark}function i(e,t,i,a){var o=r(t,a,i);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0)throw new n(a?i:`highWaterMark`,o);return Math.floor(o)}return e.objectMode?16:16*1024}t.exports={getHighWaterMark:i}})),ti=e(((exports,t)=>{typeof Object.create==`function`?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}})),ni=e(((exports,n)=>{try{var r=t(`util`);if(typeof r.inherits!=`function`)throw``;n.exports=r.inherits}catch{n.exports=ti()}})),ri=e(((exports,n)=>{function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?r(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return t=l(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function l(e){var t=u(e,`string`);return typeof t==`symbol`?t:String(t)}function u(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var d=t(`buffer`),f=d.Buffer,p=t(`util`),m=p.inspect,h=m&&m.custom||`inspect`;function g(e,t,n){f.prototype.copy.call(e,t,n)}n.exports=function(){function e(){o(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:`push`,value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:`unshift`,value:function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length}},{key:`shift`,value:function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:`clear`,value:function(){this.head=this.tail=null,this.length=0}},{key:`join`,value:function(e){if(this.length===0)return``;for(var t=this.head,n=``+t.data;t=t.next;)n+=e+t.data;return n}},{key:`concat`,value:function(e){if(this.length===0)return f.alloc(0);for(var t=f.allocUnsafe(e>>>0),n=this.head,r=0;n;)g(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:`consume`,value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:`first`,value:function(){return this.head.data}},{key:`_getString`,value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,a=e>i.length?i.length:e;if(a===i.length?r+=i:r+=i.slice(0,e),e-=a,e===0){a===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(a));break}++n}return this.length-=n,r}},{key:`_getBuffer`,value:function(e){var t=f.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),e-=a,e===0){a===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(a));break}++r}return this.length-=r,t}},{key:h,value:function(e,t){return m(this,i(i({},t),{},{depth:0,customInspect:!1}))}}]),e}()})),ii=e(((exports,n)=>{
|
|
1
|
+
import{__commonJSMin as e,__require as t,__toESM as n}from"./chunk-CrDKVgUD.js";import{randomUUID as r}from"crypto";import{AsyncLocalStorage as i}from"node:async_hooks";import{randomUUID as a}from"node:crypto";import{chownSync as o,existsSync as s,mkdirSync as c,readFileSync as l}from"node:fs";import{join as u,sep as d}from"node:path";import f from"winston";import p from"winston-daily-rotate-file";import m from"env-var";import{arch as h,homedir as g,hostname as _,platform as v,userInfo as y}from"node:os";import"dotenv/config";import{chown as b}from"node:fs/promises";import x from"ps-list";import{deflateSync as S}from"node:zlib";import{URL as C}from"url";import w from"node:http";import T from"node:process";var E=class{events=new Map;async replayEventsAfter(e,{send:t}){if(!e||!this.events.has(e))return``;let n=this.getStreamIdFromEventId(e);if(!n)return``;let r=!1,i=[...this.events.entries()].sort((e,t)=>e[0].localeCompare(t[0]));for(let[a,{message:o,streamId:s}]of i){if(s!==n)continue;if(a===e){r=!0;continue}r&&await t(a,o)}return n}async storeEvent(e,t){let n=this.generateEventId(e);return this.events.set(n,{message:t,streamId:e}),n}generateEventId(e){return`${e}_${Date.now()}_${Math.random().toString(36).substring(2,10)}`}getStreamIdFromEventId(e){let t=e.split(`_`);return t.length>0?t[0]:``}},D;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(D||={});var O;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(O||={});const k=D.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),A=e=>{switch(typeof e){case`undefined`:return k.undefined;case`string`:return k.string;case`number`:return Number.isNaN(e)?k.nan:k.number;case`boolean`:return k.boolean;case`function`:return k.function;case`bigint`:return k.bigint;case`symbol`:return k.symbol;case`object`:return Array.isArray(e)?k.array:e===null?k.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?k.promise:typeof Map<`u`&&e instanceof Map?k.map:typeof Set<`u`&&e instanceof Set?k.set:typeof Date<`u`&&e instanceof Date?k.date:k.object;default:return k.unknown}},j=D.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]);var M=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,D.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};M.create=e=>new M(e);var N=(e,t)=>{let n;switch(e.code){case j.invalid_type:n=e.received===k.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case j.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,D.jsonStringifyReplacer)}`;break;case j.unrecognized_keys:n=`Unrecognized key(s) in object: ${D.joinValues(e.keys,`, `)}`;break;case j.invalid_union:n=`Invalid input`;break;case j.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${D.joinValues(e.options)}`;break;case j.invalid_enum_value:n=`Invalid enum value. Expected ${D.joinValues(e.options)}, received '${e.received}'`;break;case j.invalid_arguments:n=`Invalid function arguments`;break;case j.invalid_return_type:n=`Invalid function return type`;break;case j.invalid_date:n=`Invalid date`;break;case j.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:D.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case j.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case j.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case j.custom:n=`Invalid input`;break;case j.invalid_intersection_types:n=`Intersection results could not be merged`;break;case j.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case j.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,D.assertNever(e)}return{message:n}};let P=N;function F(){return P}const ee=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function I(e,t){let n=F(),r=ee({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===N?void 0:N].filter(e=>!!e)});e.common.issues.push(r)}var L=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return R;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return R;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};const R=Object.freeze({status:`aborted`}),te=e=>({status:`dirty`,value:e}),z=e=>({status:`valid`,value:e}),B=e=>e.status===`aborted`,ne=e=>e.status===`dirty`,V=e=>e.status===`valid`,H=e=>typeof Promise<`u`&&e instanceof Promise;var U;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(U||={});var re=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const ie=(e,t)=>{if(V(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new M(e.common.issues),this._error}}};function W(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var G=class{get description(){return this._def.description}_getType(e){return A(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:A(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new L,ctx:{common:e.parent.common,data:e.data,parsedType:A(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(H(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},r=this._parseSync({data:e,path:n.path,parent:n});return ie(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return V(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>V(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:A(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(H(r)?r:Promise.resolve(r));return ie(n,i)}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:j.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new ot({schema:this,typeName:K.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return st.create(this,this._def)}nullable(){return ct.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ve.create(this)}promise(){return at.create(this,this._def)}or(e){return We.create([this,e],this._def)}and(e){return Je.create(this,e,this._def)}transform(e){return new ot({...W(this._def),schema:this,typeName:K.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new lt({...W(this._def),innerType:this,defaultValue:t,typeName:K.ZodDefault})}brand(){return new ft({typeName:K.ZodBranded,type:this,...W(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ut({...W(this._def),innerType:this,catchValue:t,typeName:K.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pt.create(this,e)}readonly(){return mt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const ae=/^c[^\s-]{8,}$/i,oe=/^[0-9a-z]+$/,se=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ce=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,le=/^[a-z0-9_-]{21}$/i,ue=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,de=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,fe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let pe;const me=/^(?:(?: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])$/,he=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ge=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,_e=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ve=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ye=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,be=`((\\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])))`,xe=RegExp(`^${be}$`);function Se(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Ce(e){return RegExp(`^${Se(e)}$`)}function we(e){let t=`${be}T${Se(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Te(e,t){return!!((t===`v4`||!t)&&me.test(e)||(t===`v6`||!t)&&ge.test(e))}function Ee(e,t){if(!ue.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function De(e,t){return!!((t===`v4`||!t)&&he.test(e)||(t===`v6`||!t)&&_e.test(e))}var Oe=class e extends G{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==k.string){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.string,received:t.parsedType}),R}let t=new L,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),I(n,{code:j.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),I(n,{code:j.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?I(n,{code:j.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&I(n,{code:j.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)fe.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`email`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)pe||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),pe.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`emoji`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)ce.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`uuid`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)le.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`nanoid`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)ae.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`cuid`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)oe.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`cuid2`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)se.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`ulid`,code:j.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),I(n,{validation:`url`,code:j.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`regex`,code:j.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?we(r).test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?xe.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Ce(r).test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{code:j.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?de.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`duration`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Te(e.data,r.version)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`ip`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Ee(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`jwt`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?De(e.data,r.version)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`cidr`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?ve.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`base64`,code:j.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?ye.test(e.data)||(n=this._getOrReturnCtx(e,n),I(n,{validation:`base64url`,code:j.invalid_string,message:r.message}),t.dirty()):D.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:j.invalid_string,...U.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...U.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...U.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...U.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...U.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...U.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...U.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...U.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...U.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...U.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...U.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...U.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...U.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...U.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...U.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...U.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...U.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...U.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...U.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...U.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...U.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...U.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...U.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...U.errToObj(t)})}nonempty(e){return this.min(1,U.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Oe.create=e=>new Oe({checks:[],typeName:K.ZodString,coerce:e?.coerce??!1,...W(e)});function ke(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(`.`,``)),o=Number.parseInt(t.toFixed(i).replace(`.`,``));return a%o/10**i}var Ae=class e extends G{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==k.number){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.number,received:t.parsedType}),R}let t,n=new L;for(let r of this._def.checks)r.kind===`int`?D.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),I(t,{code:j.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?ke(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),I(t,{code:j.not_finite,message:r.message}),n.dirty()):D.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,U.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,U.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,U.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,U.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:U.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:U.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:U.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:U.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:U.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:U.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:U.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:U.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:U.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:U.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&D.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Ae.create=e=>new Ae({checks:[],typeName:K.ZodNumber,coerce:e?.coerce||!1,...W(e)});var je=class e extends G{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==k.bigint)return this._getInvalidInput(e);let t,n=new L;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),I(t,{code:j.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):D.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.bigint,received:t.parsedType}),R}gte(e,t){return this.setLimit(`min`,e,!0,U.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,U.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,U.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,U.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:U.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:U.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:U.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:U.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:U.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:U.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};je.create=e=>new je({checks:[],typeName:K.ZodBigInt,coerce:e?.coerce??!1,...W(e)});var Me=class extends G{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==k.boolean){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.boolean,received:t.parsedType}),R}return z(e.data)}};Me.create=e=>new Me({typeName:K.ZodBoolean,coerce:e?.coerce||!1,...W(e)});var Ne=class e extends G{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==k.date){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.date,received:t.parsedType}),R}if(Number.isNaN(e.data.getTime())){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_date}),R}let t=new L,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),I(n,{code:j.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),I(n,{code:j.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):D.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:U.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:U.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Ne.create=e=>new Ne({checks:[],coerce:e?.coerce||!1,typeName:K.ZodDate,...W(e)});var Pe=class extends G{_parse(e){if(this._getType(e)!==k.symbol){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.symbol,received:t.parsedType}),R}return z(e.data)}};Pe.create=e=>new Pe({typeName:K.ZodSymbol,...W(e)});var Fe=class extends G{_parse(e){if(this._getType(e)!==k.undefined){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.undefined,received:t.parsedType}),R}return z(e.data)}};Fe.create=e=>new Fe({typeName:K.ZodUndefined,...W(e)});var Ie=class extends G{_parse(e){if(this._getType(e)!==k.null){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.null,received:t.parsedType}),R}return z(e.data)}};Ie.create=e=>new Ie({typeName:K.ZodNull,...W(e)});var Le=class extends G{constructor(){super(...arguments),this._any=!0}_parse(e){return z(e.data)}};Le.create=e=>new Le({typeName:K.ZodAny,...W(e)});var Re=class extends G{constructor(){super(...arguments),this._unknown=!0}_parse(e){return z(e.data)}};Re.create=e=>new Re({typeName:K.ZodUnknown,...W(e)});var ze=class extends G{_parse(e){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.never,received:t.parsedType}),R}};ze.create=e=>new ze({typeName:K.ZodNever,...W(e)});var Be=class extends G{_parse(e){if(this._getType(e)!==k.undefined){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.void,received:t.parsedType}),R}return z(e.data)}};Be.create=e=>new Be({typeName:K.ZodVoid,...W(e)});var Ve=class e extends G{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==k.array)return I(t,{code:j.invalid_type,expected:k.array,received:t.parsedType}),R;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(I(t,{code:e?j.too_big:j.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(I(t,{code:j.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(I(t,{code:j.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new re(t,e,t.path,n)))).then(e=>L.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new re(t,e,t.path,n)));return L.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:U.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:U.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:U.toString(n)}})}nonempty(e){return this.min(1,e)}};Ve.create=(e,t)=>new Ve({type:e,minLength:null,maxLength:null,exactLength:null,typeName:K.ZodArray,...W(t)});function He(e){if(e instanceof Ue){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=st.create(He(r))}return new Ue({...e._def,shape:()=>t})}else if(e instanceof Ve)return new Ve({...e._def,type:He(e.element)});else if(e instanceof st)return st.create(He(e.unwrap()));else if(e instanceof ct)return ct.create(He(e.unwrap()));else if(e instanceof Ye)return Ye.create(e.items.map(e=>He(e)));else return e}var Ue=class e extends G{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=D.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==k.object){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.object,received:t.parsedType}),R}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ze&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new re(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ze){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(I(n,{code:j.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new re(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>L.mergeObjectSync(t,e)):L.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return U.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:U.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:K.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of D.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of D.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return He(this)}partial(t){let n={};for(let e of D.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of D.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof st;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return nt(D.objectKeys(this.shape))}};Ue.create=(e,t)=>new Ue({shape:()=>e,unknownKeys:`strip`,catchall:ze.create(),typeName:K.ZodObject,...W(t)}),Ue.strictCreate=(e,t)=>new Ue({shape:()=>e,unknownKeys:`strict`,catchall:ze.create(),typeName:K.ZodObject,...W(t)}),Ue.lazycreate=(e,t)=>new Ue({shape:e,unknownKeys:`strip`,catchall:ze.create(),typeName:K.ZodObject,...W(t)});var We=class extends G{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new M(e.ctx.common.issues));return I(t,{code:j.invalid_union,unionErrors:n}),R}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new M(e));return I(t,{code:j.invalid_union,unionErrors:i}),R}}get options(){return this._def.options}};We.create=(e,t)=>new We({options:e,typeName:K.ZodUnion,...W(t)});const Ge=e=>e instanceof et?Ge(e.schema):e instanceof ot?Ge(e.innerType()):e instanceof tt?[e.value]:e instanceof rt?e.options:e instanceof it?D.objectValues(e.enum):e instanceof lt?Ge(e._def.innerType):e instanceof Fe?[void 0]:e instanceof Ie?[null]:e instanceof st?[void 0,...Ge(e.unwrap())]:e instanceof ct?[null,...Ge(e.unwrap())]:e instanceof ft||e instanceof mt?Ge(e.unwrap()):e instanceof ut?Ge(e._def.innerType):[];var Ke=class e extends G{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.object)return I(t,{code:j.invalid_type,expected:k.object,received:t.parsedType}),R;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(I(t,{code:j.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),R)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ge(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:K.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...W(r)})}};function qe(e,t){let n=A(e),r=A(t);if(e===t)return{valid:!0,data:e};if(n===k.object&&r===k.object){let n=D.objectKeys(t),r=D.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=qe(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===k.array&&r===k.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=qe(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===k.date&&r===k.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Je=class extends G{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(B(e)||B(r))return R;let i=qe(e.value,r.value);return i.valid?((ne(e)||ne(r))&&t.dirty(),{status:t.value,value:i.data}):(I(n,{code:j.invalid_intersection_types}),R)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Je.create=(e,t,n)=>new Je({left:e,right:t,typeName:K.ZodIntersection,...W(n)});var Ye=class e extends G{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.array)return I(n,{code:j.invalid_type,expected:k.array,received:n.parsedType}),R;if(n.data.length<this._def.items.length)return I(n,{code:j.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),R;!this._def.rest&&n.data.length>this._def.items.length&&(I(n,{code:j.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new re(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>L.mergeArray(t,e)):L.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ye.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ye({items:e,typeName:K.ZodTuple,rest:null,...W(t)})};var Xe=class e extends G{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.object)return I(n,{code:j.invalid_type,expected:k.object,received:n.parsedType}),R;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new re(n,e,n.path,e)),value:a._parse(new re(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?L.mergeObjectAsync(t,r):L.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof G?new e({keyType:t,valueType:n,typeName:K.ZodRecord,...W(r)}):new e({keyType:Oe.create(),valueType:t,typeName:K.ZodRecord,...W(n)})}},Ze=class extends G{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.map)return I(n,{code:j.invalid_type,expected:k.map,received:n.parsedType}),R;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new re(n,e,n.path,[a,`key`])),value:i._parse(new re(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return R;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return R;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Ze.create=(e,t,n)=>new Ze({valueType:t,keyType:e,typeName:K.ZodMap,...W(n)});var Qe=class e extends G{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==k.set)return I(n,{code:j.invalid_type,expected:k.set,received:n.parsedType}),R;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(I(n,{code:j.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(I(n,{code:j.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return R;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new re(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:U.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:U.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Qe.create=(e,t)=>new Qe({valueType:e,minSize:null,maxSize:null,typeName:K.ZodSet,...W(t)});var $e=class e extends G{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.function)return I(t,{code:j.invalid_type,expected:k.function,received:t.parsedType}),R;function n(e,n){return ee({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,F(),N].filter(e=>!!e),issueData:{code:j.invalid_arguments,argumentsError:n}})}function r(e,n){return ee({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,F(),N].filter(e=>!!e),issueData:{code:j.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof at){let e=this;return z(async function(...t){let o=new M([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return z(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new M([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new M([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ye.create(t).rest(Re.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ye.create([]).rest(Re.create()),returns:n||Re.create(),typeName:K.ZodFunction,...W(r)})}},et=class extends G{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};et.create=(e,t)=>new et({getter:e,typeName:K.ZodLazy,...W(t)});var tt=class extends G{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return I(t,{received:t.data,code:j.invalid_literal,expected:this._def.value}),R}return{status:`valid`,value:e.data}}get value(){return this._def.value}};tt.create=(e,t)=>new tt({value:e,typeName:K.ZodLiteral,...W(t)});function nt(e,t){return new rt({values:e,typeName:K.ZodEnum,...W(t)})}var rt=class e extends G{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return I(t,{expected:D.joinValues(n),received:t.parsedType,code:j.invalid_type}),R}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return I(t,{received:t.data,code:j.invalid_enum_value,options:n}),R}return z(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};rt.create=nt;var it=class extends G{_parse(e){let t=D.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==k.string&&n.parsedType!==k.number){let e=D.objectValues(t);return I(n,{expected:D.joinValues(e),received:n.parsedType,code:j.invalid_type}),R}if(this._cache||=new Set(D.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=D.objectValues(t);return I(n,{received:n.data,code:j.invalid_enum_value,options:e}),R}return z(e.data)}get enum(){return this._def.values}};it.create=(e,t)=>new it({values:e,typeName:K.ZodNativeEnum,...W(t)});var at=class extends G{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.promise&&t.common.async===!1)return I(t,{code:j.invalid_type,expected:k.promise,received:t.parsedType}),R;let n=t.parsedType===k.promise?t.data:Promise.resolve(t.data);return z(n.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};at.create=(e,t)=>new at({type:e,typeName:K.ZodPromise,...W(t)});var ot=class extends G{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===K.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{I(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return R;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?R:r.status===`dirty`||t.value===`dirty`?te(r.value):r});{if(t.value===`aborted`)return R;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?R:r.status===`dirty`||t.value===`dirty`?te(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?R:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?R:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!V(e))return R;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>V(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):R);D.assertNever(r)}};ot.create=(e,t,n)=>new ot({schema:e,typeName:K.ZodEffects,effect:t,...W(n)}),ot.createWithPreprocess=(e,t,n)=>new ot({schema:t,effect:{type:`preprocess`,transform:e},typeName:K.ZodEffects,...W(n)});var st=class extends G{_parse(e){return this._getType(e)===k.undefined?z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};st.create=(e,t)=>new st({innerType:e,typeName:K.ZodOptional,...W(t)});var ct=class extends G{_parse(e){return this._getType(e)===k.null?z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ct.create=(e,t)=>new ct({innerType:e,typeName:K.ZodNullable,...W(t)});var lt=class extends G{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===k.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};lt.create=(e,t)=>new lt({innerType:e,typeName:K.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...W(t)});var ut=class extends G{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return H(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ut.create=(e,t)=>new ut({innerType:e,typeName:K.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...W(t)});var dt=class extends G{_parse(e){if(this._getType(e)!==k.nan){let t=this._getOrReturnCtx(e);return I(t,{code:j.invalid_type,expected:k.nan,received:t.parsedType}),R}return{status:`valid`,value:e.data}}};dt.create=e=>new dt({typeName:K.ZodNaN,...W(e)});var ft=class extends G{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},pt=class e extends G{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?R:e.status===`dirty`?(t.dirty(),te(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?R:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:K.ZodPipeline})}},mt=class extends G{_parse(e){let t=this._def.innerType._parse(e),n=e=>(V(e)&&(e.value=Object.freeze(e.value)),e);return H(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};mt.create=(e,t)=>new mt({innerType:e,typeName:K.ZodReadonly,...W(t)}),Ue.lazycreate;var K;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(K||={});const q=Oe.create,ht=Ae.create;dt.create,je.create;const gt=Me.create;Ne.create,Pe.create,Fe.create,Ie.create;const _t=Le.create,vt=Re.create;ze.create,Be.create;const J=Ve.create,Y=Ue.create;Ue.strictCreate;const yt=We.create,bt=Ke.create;Je.create,Ye.create;const xt=Xe.create;Ze.create,Qe.create,$e.create,et.create;const X=tt.create,St=rt.create;it.create,at.create,ot.create;const Z=st.create;ct.create,ot.createWithPreprocess,pt.create;const Ct=R,wt=`2025-06-18`,Tt=[wt,`2025-03-26`,`2024-11-05`,`2024-10-07`],Et=yt([q(),ht().int()]),Dt=q(),Ot=Y({progressToken:Z(Et)}).passthrough(),kt=Y({_meta:Z(Ot)}).passthrough(),At=Y({method:q(),params:Z(kt)}),jt=Y({_meta:Z(Y({}).passthrough())}).passthrough(),Mt=Y({method:q(),params:Z(jt)}),Nt=Y({_meta:Z(Y({}).passthrough())}).passthrough(),Pt=yt([q(),ht().int()]),Ft=Y({jsonrpc:X(`2.0`),id:Pt}).merge(At).strict(),It=e=>Ft.safeParse(e).success,Lt=Y({jsonrpc:X(`2.0`)}).merge(Mt).strict(),Rt=e=>Lt.safeParse(e).success,zt=Y({jsonrpc:X(`2.0`),id:Pt,result:Nt}).strict(),Bt=e=>zt.safeParse(e).success;var Vt;(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`})(Vt||={});const Ht=Y({jsonrpc:X(`2.0`),id:Pt,error:Y({code:ht().int(),message:q(),data:Z(vt())})}).strict(),Ut=e=>Ht.safeParse(e).success,Wt=yt([Ft,Lt,zt,Ht]),Gt=Nt.strict(),Kt=Mt.extend({method:X(`notifications/cancelled`),params:jt.extend({requestId:Pt,reason:q().optional()})}),qt=Y({src:q(),mimeType:Z(q()),sizes:Z(q())}).passthrough(),Jt=Y({name:q(),title:Z(q())}).passthrough(),Yt=Jt.extend({version:q(),websiteUrl:Z(q()),icons:Z(J(qt))}),Xt=Y({experimental:Z(Y({}).passthrough()),sampling:Z(Y({}).passthrough()),elicitation:Z(Y({}).passthrough()),roots:Z(Y({listChanged:Z(gt())}).passthrough())}).passthrough(),Zt=At.extend({method:X(`initialize`),params:kt.extend({protocolVersion:q(),capabilities:Xt,clientInfo:Yt})}),Qt=e=>Zt.safeParse(e).success,$t=Y({experimental:Z(Y({}).passthrough()),logging:Z(Y({}).passthrough()),completions:Z(Y({}).passthrough()),prompts:Z(Y({listChanged:Z(gt())}).passthrough()),resources:Z(Y({subscribe:Z(gt()),listChanged:Z(gt())}).passthrough()),tools:Z(Y({listChanged:Z(gt())}).passthrough())}).passthrough(),en=Nt.extend({protocolVersion:q(),capabilities:$t,serverInfo:Yt,instructions:Z(q())}),tn=Mt.extend({method:X(`notifications/initialized`)}),nn=e=>tn.safeParse(e).success,rn=At.extend({method:X(`ping`)}),an=Y({progress:ht(),total:Z(ht()),message:Z(q())}).passthrough(),on=Mt.extend({method:X(`notifications/progress`),params:jt.merge(an).extend({progressToken:Et})}),sn=At.extend({params:kt.extend({cursor:Z(Dt)}).optional()}),cn=Nt.extend({nextCursor:Z(Dt)}),ln=Y({uri:q(),mimeType:Z(q()),_meta:Z(Y({}).passthrough())}).passthrough(),un=ln.extend({text:q()}),dn=q().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),fn=ln.extend({blob:dn}),pn=Jt.extend({uri:q(),description:Z(q()),mimeType:Z(q()),icons:Z(J(qt)),_meta:Z(Y({}).passthrough())}),mn=Jt.extend({uriTemplate:q(),description:Z(q()),mimeType:Z(q()),_meta:Z(Y({}).passthrough())}),hn=sn.extend({method:X(`resources/list`)}),gn=cn.extend({resources:J(pn)}),_n=sn.extend({method:X(`resources/templates/list`)}),vn=cn.extend({resourceTemplates:J(mn)}),yn=At.extend({method:X(`resources/read`),params:kt.extend({uri:q()})}),bn=Nt.extend({contents:J(yt([un,fn]))}),xn=Mt.extend({method:X(`notifications/resources/list_changed`)}),Sn=At.extend({method:X(`resources/subscribe`),params:kt.extend({uri:q()})}),Cn=At.extend({method:X(`resources/unsubscribe`),params:kt.extend({uri:q()})}),wn=Mt.extend({method:X(`notifications/resources/updated`),params:jt.extend({uri:q()})}),Tn=Y({name:q(),description:Z(q()),required:Z(gt())}).passthrough(),En=Jt.extend({description:Z(q()),arguments:Z(J(Tn)),icons:Z(J(qt)),_meta:Z(Y({}).passthrough())}),Dn=sn.extend({method:X(`prompts/list`)}),On=cn.extend({prompts:J(En)}),kn=At.extend({method:X(`prompts/get`),params:kt.extend({name:q(),arguments:Z(xt(q()))})}),An=Y({type:X(`text`),text:q(),_meta:Z(Y({}).passthrough())}).passthrough(),jn=Y({type:X(`image`),data:dn,mimeType:q(),_meta:Z(Y({}).passthrough())}).passthrough(),Mn=Y({type:X(`audio`),data:dn,mimeType:q(),_meta:Z(Y({}).passthrough())}).passthrough(),Nn=Y({type:X(`resource`),resource:yt([un,fn]),_meta:Z(Y({}).passthrough())}).passthrough(),Pn=pn.extend({type:X(`resource_link`)}),Fn=yt([An,jn,Mn,Pn,Nn]),In=Y({role:St([`user`,`assistant`]),content:Fn}).passthrough(),Ln=Nt.extend({description:Z(q()),messages:J(In)}),Rn=Mt.extend({method:X(`notifications/prompts/list_changed`)}),zn=Y({title:Z(q()),readOnlyHint:Z(gt()),destructiveHint:Z(gt()),idempotentHint:Z(gt()),openWorldHint:Z(gt())}).passthrough(),Bn=Jt.extend({description:Z(q()),inputSchema:Y({type:X(`object`),properties:Z(Y({}).passthrough()),required:Z(J(q()))}).passthrough(),outputSchema:Z(Y({type:X(`object`),properties:Z(Y({}).passthrough()),required:Z(J(q()))}).passthrough()),annotations:Z(zn),icons:Z(J(qt)),_meta:Z(Y({}).passthrough())}),Vn=sn.extend({method:X(`tools/list`)}),Hn=cn.extend({tools:J(Bn)}),Un=Nt.extend({content:J(Fn).default([]),structuredContent:Y({}).passthrough().optional(),isError:Z(gt())});Un.or(Nt.extend({toolResult:vt()}));const Wn=At.extend({method:X(`tools/call`),params:kt.extend({name:q(),arguments:Z(xt(vt()))})}),Gn=Mt.extend({method:X(`notifications/tools/list_changed`)}),Kn=St([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),qn=At.extend({method:X(`logging/setLevel`),params:kt.extend({level:Kn})}),Jn=Mt.extend({method:X(`notifications/message`),params:jt.extend({level:Kn,logger:Z(q()),data:vt()})}),Yn=Y({name:q().optional()}).passthrough(),Xn=Y({hints:Z(J(Yn)),costPriority:Z(ht().min(0).max(1)),speedPriority:Z(ht().min(0).max(1)),intelligencePriority:Z(ht().min(0).max(1))}).passthrough(),Zn=Y({role:St([`user`,`assistant`]),content:yt([An,jn,Mn])}).passthrough(),Qn=At.extend({method:X(`sampling/createMessage`),params:kt.extend({messages:J(Zn),systemPrompt:Z(q()),includeContext:Z(St([`none`,`thisServer`,`allServers`])),temperature:Z(ht()),maxTokens:ht().int(),stopSequences:Z(J(q())),metadata:Z(Y({}).passthrough()),modelPreferences:Z(Xn)})}),$n=Nt.extend({model:q(),stopReason:Z(St([`endTurn`,`stopSequence`,`maxTokens`]).or(q())),role:St([`user`,`assistant`]),content:bt(`type`,[An,jn,Mn])}),er=Y({type:X(`boolean`),title:Z(q()),description:Z(q()),default:Z(gt())}).passthrough(),tr=Y({type:X(`string`),title:Z(q()),description:Z(q()),minLength:Z(ht()),maxLength:Z(ht()),format:Z(St([`email`,`uri`,`date`,`date-time`]))}).passthrough(),nr=Y({type:St([`number`,`integer`]),title:Z(q()),description:Z(q()),minimum:Z(ht()),maximum:Z(ht())}).passthrough(),rr=Y({type:X(`string`),title:Z(q()),description:Z(q()),enum:J(q()),enumNames:Z(J(q()))}).passthrough(),ir=yt([er,tr,nr,rr]),ar=At.extend({method:X(`elicitation/create`),params:kt.extend({message:q(),requestedSchema:Y({type:X(`object`),properties:xt(q(),ir),required:Z(J(q()))}).passthrough()})}),or=Nt.extend({action:St([`accept`,`decline`,`cancel`]),content:Z(xt(q(),vt()))}),sr=Y({type:X(`ref/resource`),uri:q()}).passthrough(),cr=Y({type:X(`ref/prompt`),name:q()}).passthrough(),lr=At.extend({method:X(`completion/complete`),params:kt.extend({ref:yt([cr,sr]),argument:Y({name:q(),value:q()}).passthrough(),context:Z(Y({arguments:Z(xt(q(),q()))}))})}),ur=Nt.extend({completion:Y({values:J(q()).max(100),total:Z(ht().int()),hasMore:Z(gt())}).passthrough()}),dr=Y({uri:q().startsWith(`file://`),name:Z(q()),_meta:Z(Y({}).passthrough())}).passthrough(),fr=At.extend({method:X(`roots/list`)}),pr=Nt.extend({roots:J(dr)}),mr=Mt.extend({method:X(`notifications/roots/list_changed`)});yt([rn,Zt,lr,qn,kn,Dn,hn,_n,yn,Sn,Cn,Wn,Vn]),yt([Kt,on,tn,mr]),yt([Gt,$n,or,pr]),yt([rn,Qn,ar,fr]),yt([Kt,on,Jn,wn,xn,Gn,Rn]),yt([Gt,en,ur,Ln,On,gn,vn,bn,Un,Hn]);var hr=class extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}},gr=class extends Error{extra;tags;constructor(e,t,n={},r={}){super(t),this.name=e,this.tags=n,this.extra=r}},_r=class extends gr{constructor(e,t=`access_denied`,n={}){super(`AccessControlBlockError`,e,{feature:`access_control`,module:`security`,operation:`block`},{reason:t,...n}),this.reason=t}},vr=class extends gr{constructor(e,t,n={}){super(`ConfigurationError`,e,{feature:`configuration`,module:`cli`,operation:`validate`},{configKey:t,...n})}},yr=class extends gr{constructor(e,t,n,r={}){super(`ProxyConnectionError`,e,{feature:`connection`,module:`proxy`,operation:`connect`,transport:n||`unknown`},{url:t?(()=>{try{return new URL(t).origin}catch{return t}})():void 0,...r})}};const br={APP_VERSION:`1.0.58`,NODE_ENV:`development`,OAUTH_PROVIDERS:[{authorizationEndpoint:`https://github.com/login/oauth/authorize`,clientId:`Ov23liDj6mzRyvM5n0yG`,id:`github`,name:`GitHub`,tokenEndpoint:`https://github.com/login/oauth/access_token`,urlPatterns:[`github.com`,`api.github.com`,`githubcopilot.com`,`api.githubcopilot.com`],clientSecret:`d467125f345a6edd5de0254a5a9b6bdde26fdd86`,scopes:[`read:user`,`repo`,`gist`,`notifications`,`project`,`public_repo`,`read:gpg_key`,`read:org`,`repo:status`,`repo_deployment`,`user`,`user:email`,`user:follow`],usePkce:!0,tokenEndpointAuthMethod:`client_secret_post`}]},xr=m.get,Sr=br.APP_VERSION,Cr=e=>{let t={};if(e){let n=e.split(`,`);for(let e of n){let[n,...r]=e.split(`:`);n&&r.length>0&&(t[n.trim()]=r.join(`:`).trim())}}return t},wr=e=>{try{let t=new URL(e),n=t.pathname.split(`/`).filter(Boolean)[0]===`ingest`?`/ingest`:``;return`${t.protocol}//${t.host}${n}/endpoint-logs`}catch{return null}},Tr=e=>{try{let t=new URL(e),n=`/guard/evaluate/v1`;return t.pathname.includes(n)?(t.pathname=t.pathname.replace(n,`/access-control/authorize`),t.toString()):(console.warn(`[mcp-gateway] Warning: SCANNER_URL does not contain expected path "${n}". Access control URL derivation skipped. Current path: "${t.pathname}". Please set MCP_GATEWAY_ACCESS_CONTROL_URL explicitly.`),null)}catch(e){return console.warn(`[mcp-gateway] Warning: Failed to parse SCANNER_URL as valid URL: ${e instanceof Error?e.message:String(e)}. Please set MCP_GATEWAY_ACCESS_CONTROL_URL explicitly.`),null}},Er=r(),Dr=xr(`NODE_ENV`).default(br.NODE_ENV||`development`).asEnum([`development`,`production`,`staging`,`test`]),Or=xr(`DEBUG`).default(`false`).asBool()||xr(`MCP_GATEWAY_DEBUG`).default(`false`).asBool(),kr=xr(`MCP_GATEWAY_SCANNER_URL`).default(``).asString()||null,Ar=xr(`MCP_GATEWAY_SCANNER_API_KEY`).default(``).asString()||void 0,jr=xr(`MCP_GATEWAY_MIRROR_URL`).default(``).asString()||null,Mr=(()=>{let e=xr(`MCP_GATEWAY_SCANNER_HEADERS`).required(!1).asString();return e?Cr(e):{}})(),Nr=xr(`MCP_GATEWAY_SCANNER_TIMEOUT_MS`).default(`20000`).asIntPositive(),Pr=xr(`MCP_GATEWAY_SCANNER_FAIL_OPEN`).default(`true`).asBool(),Fr=xr(`MCP_GATEWAY_COMMAND`).default(`mcp-gateway`).asString(),Ir=xr(`CLIENT_APP_NAME`).default(``).asString(),Lr=xr(`MCP_GATEWAY_LOG_DIR`).default(u(g(),`.onyx`,`mcp-gateway`,`logs`)).asString(),Rr=xr(`MCP_GATEWAY_OAUTH_DIR`).default(u(g(),`.onyx`,`mcp-gateway`,`oauth`)).asString(),zr=(()=>xr(`MCP_GATEWAY_ACCESS_CONTROL_URL`).default(``).asString()||(kr?Tr(kr):null))(),Br=(()=>{let e=xr(`MCP_GATEWAY_ACCESS_CONTROL_HEADERS`).required(!1).asString();return e?Cr(e):{}})(),Vr=xr(`MCP_GATEWAY_ACCESS_CONTROL_TIMEOUT_MS`).default(`3000`).asIntPositive(),Hr=xr(`MCP_GATEWAY_LOG_INGEST_ENABLED`).default(`true`).asBool(),Ur=xr(`MCP_GATEWAY_LOG_INGEST_TIMEOUT_MS`).default(`5000`).asIntPositive(),Wr=(()=>xr(`MCP_GATEWAY_LOG_INGEST_URL`).default(``).asString()||(jr?wr(jr):kr?wr(kr):null))(),Gr={accessControl:{enabled:!!(zr&&Ar),headers:Br,timeoutMs:Vr,url:zr},appVersion:Sr,clientAppName:Ir,debug:Or,environment:Dr,logDir:Lr,logIngest:{apiKey:Ar,enabled:Hr&&!!(Wr&&Ar),timeoutMs:Ur,url:Wr},oauthDir:Rr,proxyCommand:Fr,scanner:{apiKey:Ar,enabled:!!kr,failOpen:Pr,headers:Mr,timeoutMs:Nr,url:kr}};async function Kr(e){let t=Yr();if(!t)return;let n=Jr(e);if(!n){await b(e,t.uid,t.gid);return}for(let e of n)await b(e,t.uid,t.gid)}function qr(e){let t=Yr();if(!t)return;let n=Jr(e);if(!n){o(e,t.uid,t.gid);return}for(let e of n)o(e,t.uid,t.gid)}function Jr(e){if(!e.startsWith(d))return;let t=e.split(d),n=t.indexOf(`.onyx`);if(n===-1)return;let r=[];for(let e=n;e<t.length;e++)r.push(t.slice(0,e+1).join(d));return r}function Yr(){if(typeof process.getuid!=`function`||process.getuid()!==0)return;let e=process.env.SUDO_UID,t=process.env.SUDO_GID;if(!e||!t)return;let n=parseInt(e,10),r=parseInt(t,10);if(!(isNaN(n)||isNaN(r)))return{gid:r,uid:n}}var Xr=e(((exports,n)=>{n.exports=t(`util`).deprecate})),Zr=e(((exports,n)=>{n.exports=t(`stream`)})),Qr=e(((exports,t)=>{function n(e,t){var n=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(o,this,e)):process.nextTick(o,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted?process.nextTick(i,n):(n._writableState.errorEmitted=!0,process.nextTick(r,n,e)):process.nextTick(r,n,e):t?(process.nextTick(i,n),t(e)):process.nextTick(i,n)}),this)}function r(e,t){o(e,t),i(e)}function i(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit(`close`)}function a(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function o(e,t){e.emit(`error`,t)}function s(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit(`error`,t)}t.exports={destroy:n,undestroy:a,errorOrDestroy:s}})),$r=e(((exports,t)=>{let n={};function r(e,t,r){r||=Error;function i(e,n,r){return typeof t==`string`?t:t(e,n,r)}class a extends r{constructor(e,t,n){super(i(e,t,n))}}a.prototype.name=r.name,a.prototype.code=e,n[e]=a}function i(e,t){if(Array.isArray(e)){let n=e.length;return e=e.map(e=>String(e)),n>2?`one of ${t} ${e.slice(0,n-1).join(`, `)}, or `+e[n-1]:n===2?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}else return`of ${t} ${String(e)}`}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function o(e,t,n){return(n===void 0||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function s(e,t,n){return typeof n!=`number`&&(n=0),n+t.length>e.length?!1:e.indexOf(t,n)!==-1}r(`ERR_INVALID_OPT_VALUE`,function(e,t){return`The value "`+t+`" is invalid for option "`+e+`"`},TypeError),r(`ERR_INVALID_ARG_TYPE`,function(e,t,n){let r;typeof t==`string`&&a(t,`not `)?(r=`must not be`,t=t.replace(/^not /,``)):r=`must be`;let c;if(o(e,` argument`))c=`The ${e} ${r} ${i(t,`type`)}`;else{let n=s(e,`.`)?`property`:`argument`;c=`The "${e}" ${n} ${r} ${i(t,`type`)}`}return c+=`. Received type ${typeof n}`,c},TypeError),r(`ERR_STREAM_PUSH_AFTER_EOF`,`stream.push() after EOF`),r(`ERR_METHOD_NOT_IMPLEMENTED`,function(e){return`The `+e+` method is not implemented`}),r(`ERR_STREAM_PREMATURE_CLOSE`,`Premature close`),r(`ERR_STREAM_DESTROYED`,function(e){return`Cannot call `+e+` after a stream was destroyed`}),r(`ERR_MULTIPLE_CALLBACK`,`Callback called multiple times`),r(`ERR_STREAM_CANNOT_PIPE`,`Cannot pipe, not readable`),r(`ERR_STREAM_WRITE_AFTER_END`,`write after end`),r(`ERR_STREAM_NULL_VALUES`,`May not write null values to stream`,TypeError),r(`ERR_UNKNOWN_ENCODING`,function(e){return`Unknown encoding: `+e},TypeError),r(`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,`stream.unshift() after end event`),t.exports.codes=n})),ei=e(((exports,t)=>{var n=$r().codes.ERR_INVALID_OPT_VALUE;function r(e,t,n){return e.highWaterMark==null?t?e[n]:null:e.highWaterMark}function i(e,t,i,a){var o=r(t,a,i);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0)throw new n(a?i:`highWaterMark`,o);return Math.floor(o)}return e.objectMode?16:16*1024}t.exports={getHighWaterMark:i}})),ti=e(((exports,t)=>{typeof Object.create==`function`?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}})),ni=e(((exports,n)=>{try{var r=t(`util`);if(typeof r.inherits!=`function`)throw``;n.exports=r.inherits}catch{n.exports=ti()}})),ri=e(((exports,n)=>{function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?r(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return t=l(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,`prototype`,{writable:!1}),e}function l(e){var t=u(e,`string`);return typeof t==`symbol`?t:String(t)}function u(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var d=t(`buffer`),f=d.Buffer,p=t(`util`),m=p.inspect,h=m&&m.custom||`inspect`;function g(e,t,n){f.prototype.copy.call(e,t,n)}n.exports=function(){function e(){o(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:`push`,value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:`unshift`,value:function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length}},{key:`shift`,value:function(){if(this.length!==0){var e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:`clear`,value:function(){this.head=this.tail=null,this.length=0}},{key:`join`,value:function(e){if(this.length===0)return``;for(var t=this.head,n=``+t.data;t=t.next;)n+=e+t.data;return n}},{key:`concat`,value:function(e){if(this.length===0)return f.alloc(0);for(var t=f.allocUnsafe(e>>>0),n=this.head,r=0;n;)g(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:`consume`,value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:`first`,value:function(){return this.head.data}},{key:`_getString`,value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,a=e>i.length?i.length:e;if(a===i.length?r+=i:r+=i.slice(0,e),e-=a,e===0){a===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(a));break}++n}return this.length-=n,r}},{key:`_getBuffer`,value:function(e){var t=f.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),e-=a,e===0){a===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(a));break}++r}return this.length-=r,t}},{key:h,value:function(e,t){return m(this,i(i({},t),{},{depth:0,customInspect:!1}))}}]),e}()})),ii=e(((exports,n)=>{
|
|
2
2
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
3
|
var r=t(`buffer`),i=r.Buffer;function a(e,t){for(var n in e)t[n]=e[n]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?n.exports=r:(a(r,exports),exports.Buffer=o);function o(e,t,n){return i(e,t,n)}o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return i(e,t,n)},o.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var r=i(e);return t===void 0?r.fill(0):typeof n==`string`?r.fill(t,n):r.fill(t),r},o.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return i(e)},o.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r.SlowBuffer(e)}})),ai=e((exports=>{var t=ii().Buffer,n=t.isEncoding||function(e){switch(e=``+e,e&&e.toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:case`raw`:return!0;default:return!1}};function r(e){if(!e)return`utf8`;for(var t;;)switch(e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:if(t)return;e=(``+e).toLowerCase(),t=!0}}function i(e){var i=r(e);if(typeof i!=`string`&&(t.isEncoding===n||!n(e)))throw Error(`Unknown encoding: `+e);return i||e}exports.StringDecoder=a;function a(e){this.encoding=i(e);var n;switch(this.encoding){case`utf16le`:this.text=f,this.end=p,n=4;break;case`utf8`:this.fillLast=l,n=4;break;case`base64`:this.text=m,this.end=h,n=3;break;default:this.write=g,this.end=_;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(n)}a.prototype.write=function(e){if(e.length===0)return``;var t,n;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return``;n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||``},a.prototype.end=d,a.prototype.text=u,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e,t,n){var r=t.length-1;if(r<n)return 0;var i=o(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function c(e,t,n){if((t[0]&192)!=128)return e.lastNeed=0,`�`;if(e.lastNeed>1&&t.length>1){if((t[1]&192)!=128)return e.lastNeed=1,`�`;if(e.lastNeed>2&&t.length>2&&(t[2]&192)!=128)return e.lastNeed=2,`�`}}function l(e){var t=this.lastTotal-this.lastNeed,n=c(this,e,t);if(n!==void 0)return n;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function u(e,t){var n=s(this,e,t);if(!this.lastNeed)return e.toString(`utf8`,t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString(`utf8`,t,r)}function d(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+`�`:t}function f(e,t){if((e.length-t)%2==0){var n=e.toString(`utf16le`,t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString(`utf16le`,t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):``;if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString(`utf16le`,0,n)}return t}function m(e,t){var n=(e.length-t)%3;return n===0?e.toString(`base64`,t):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString(`base64`,t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+this.lastChar.toString(`base64`,0,3-this.lastNeed):t}function g(e){return e.toString(this.encoding)}function _(e){return e&&e.length?this.write(e):``}})),oi=e(((exports,t)=>{var n=$r().codes.ERR_STREAM_PREMATURE_CLOSE;function r(e){var t=!1;return function(){if(!t){t=!0;var n=[...arguments];e.apply(this,n)}}}function i(){}function a(e){return e.setHeader&&typeof e.abort==`function`}function o(e,t,s){if(typeof t==`function`)return o(e,null,t);t||={},s=r(s||i);var c=t.readable||t.readable!==!1&&e.readable,l=t.writable||t.writable!==!1&&e.writable,u=function(){e.writable||f()},d=e._writableState&&e._writableState.finished,f=function(){l=!1,d=!0,c||s.call(e)},p=e._readableState&&e._readableState.endEmitted,m=function(){c=!1,p=!0,l||s.call(e)},h=function(t){s.call(e,t)},g=function(){var t;if(c&&!p)return(!e._readableState||!e._readableState.ended)&&(t=new n),s.call(e,t);if(l&&!d)return(!e._writableState||!e._writableState.ended)&&(t=new n),s.call(e,t)},_=function(){e.req.on(`finish`,f)};return a(e)?(e.on(`complete`,f),e.on(`abort`,g),e.req?_():e.on(`request`,_)):l&&!e._writableState&&(e.on(`end`,u),e.on(`close`,u)),e.on(`end`,m),e.on(`finish`,f),t.error!==!1&&e.on(`error`,h),e.on(`close`,g),function(){e.removeListener(`complete`,f),e.removeListener(`abort`,g),e.removeListener(`request`,_),e.req&&e.req.removeListener(`finish`,f),e.removeListener(`end`,u),e.removeListener(`close`,u),e.removeListener(`finish`,f),e.removeListener(`end`,m),e.removeListener(`error`,h),e.removeListener(`close`,g)}}t.exports=o})),si=e(((exports,t)=>{var n;function r(e,t,n){return t=i(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){var t=a(e,`string`);return typeof t==`symbol`?t:String(t)}function a(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var o=oi(),s=Symbol(`lastResolve`),c=Symbol(`lastReject`),l=Symbol(`error`),u=Symbol(`ended`),d=Symbol(`lastPromise`),f=Symbol(`handlePromise`),p=Symbol(`stream`);function m(e,t){return{value:e,done:t}}function h(e){var t=e[s];if(t!==null){var n=e[p].read();n!==null&&(e[d]=null,e[s]=null,e[c]=null,t(m(n,!1)))}}function g(e){process.nextTick(h,e)}function _(e,t){return function(n,r){e.then(function(){if(t[u]){n(m(void 0,!0));return}t[f](n,r)},r)}}var v=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((n={get stream(){return this[p]},next:function(){var e=this,t=this[l];if(t!==null)return Promise.reject(t);if(this[u])return Promise.resolve(m(void 0,!0));if(this[p].destroyed)return new Promise(function(t,n){process.nextTick(function(){e[l]?n(e[l]):t(m(void 0,!0))})});var n=this[d],r;if(n)r=new Promise(_(n,this));else{var i=this[p].read();if(i!==null)return Promise.resolve(m(i,!1));r=new Promise(this[f])}return this[d]=r,r}},r(n,Symbol.asyncIterator,function(){return this}),r(n,`return`,function(){var e=this;return new Promise(function(t,n){e[p].destroy(null,function(e){if(e){n(e);return}t(m(void 0,!0))})})}),n),v);t.exports=function(e){var t,n=Object.create(y,(t={},r(t,p,{value:e,writable:!0}),r(t,s,{value:null,writable:!0}),r(t,c,{value:null,writable:!0}),r(t,l,{value:null,writable:!0}),r(t,u,{value:e._readableState.endEmitted,writable:!0}),r(t,f,{value:function(e,t){var r=n[p].read();r?(n[d]=null,n[s]=null,n[c]=null,e(m(r,!1))):(n[s]=e,n[c]=t)},writable:!0}),t));return n[d]=null,o(e,function(e){if(e&&e.code!==`ERR_STREAM_PREMATURE_CLOSE`){var t=n[c];t!==null&&(n[d]=null,n[s]=null,n[c]=null,t(e)),n[l]=e;return}var r=n[s];r!==null&&(n[d]=null,n[s]=null,n[c]=null,r(m(void 0,!0))),n[u]=!0}),e.on(`readable`,g.bind(null,n)),n}})),ci=e(((exports,t)=>{function n(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,c,`next`,e)}function c(e){n(o,i,a,s,c,`throw`,e)}s(void 0)})}}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,n){return t=s(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){var t=c(e,`string`);return typeof t==`symbol`?t:String(t)}function c(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var l=$r().codes.ERR_INVALID_ARG_TYPE;function u(e,t,n){var i;if(t&&typeof t.next==`function`)i=t;else if(t&&t[Symbol.asyncIterator])i=t[Symbol.asyncIterator]();else if(t&&t[Symbol.iterator])i=t[Symbol.iterator]();else throw new l(`iterable`,[`Iterable`],t);var o=new e(a({objectMode:!0},n)),s=!1;o._read=function(){s||(s=!0,c())};function c(){return u.apply(this,arguments)}function u(){return u=r(function*(){try{var e=yield i.next(),t=e.value;e.done?o.push(null):o.push(yield t)?c():s=!1}catch(e){o.destroy(e)}}),u.apply(this,arguments)}return o}t.exports=u})),li=e(((exports,n)=>{n.exports=O;var r;O.ReadableState=D,t(`events`).EventEmitter;var i=function(e,t){return e.listeners(t).length},a=Zr(),o=t(`buffer`).Buffer,s=(typeof global<`u`?global:typeof window<`u`?window:typeof self<`u`?self:{}).Uint8Array||function(){};function c(e){return o.from(e)}function l(e){return o.isBuffer(e)||e instanceof s}var u=t(`util`),d=u&&u.debuglog?u.debuglog(`stream`):function(){},f=ri(),p=Qr(),m=ei(),h=m.getHighWaterMark,g=$r().codes,_=g.ERR_INVALID_ARG_TYPE,v=g.ERR_STREAM_PUSH_AFTER_EOF,y=g.ERR_METHOD_NOT_IMPLEMENTED,b=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,x,S,C;ni()(O,a);var w=p.errorOrDestroy,T=[`error`,`close`,`destroy`,`pause`,`resume`];function E(e,t,n){if(typeof e.prependListener==`function`)return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function D(e,t,n){r||=ui(),e||={},typeof n!=`boolean`&&(n=t instanceof r),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=h(this,e,`readableHighWaterMark`,n),this.buffer=new f,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||`utf8`,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(x||=ai().StringDecoder,this.decoder=new x(e.encoding),this.encoding=e.encoding)}function O(e){if(r||=ui(),!(this instanceof O))return new O(e);var t=this instanceof r;this._readableState=new D(e,this,t),this.readable=!0,e&&(typeof e.read==`function`&&(this._read=e.read),typeof e.destroy==`function`&&(this._destroy=e.destroy)),a.call(this)}Object.defineProperty(O.prototype,`destroyed`,{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),O.prototype.destroy=p.destroy,O.prototype._undestroy=p.undestroy,O.prototype._destroy=function(e,t){t(e)},O.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:typeof e==`string`&&(t||=n.defaultEncoding,t!==n.encoding&&(e=o.from(e,t),t=``),r=!0),k(this,e,t,!1,r)},O.prototype.unshift=function(e){return k(this,e,null,!0,!1)};function k(e,t,n,r,i){d(`readableAddChunk`,t);var a=e._readableState;if(t===null)a.reading=!1,F(e,a);else{var s;if(i||(s=j(a,t)),s)w(e,s);else if(a.objectMode||t&&t.length>0)if(typeof t!=`string`&&!a.objectMode&&Object.getPrototypeOf(t)!==o.prototype&&(t=c(t)),r)a.endEmitted?w(e,new b):A(e,a,t,!0);else if(a.ended)w(e,new v);else if(a.destroyed)return!1;else a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||t.length!==0?A(e,a,t,!1):L(e,a)):A(e,a,t,!1);else r||(a.reading=!1,L(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function A(e,t,n,r){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit(`data`,n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&ee(e)),L(e,t)}function j(e,t){var n;return!l(t)&&typeof t!=`string`&&t!==void 0&&!e.objectMode&&(n=new _(`chunk`,[`string`,`Buffer`,`Uint8Array`],t)),n}O.prototype.isPaused=function(){return this._readableState.flowing===!1},O.prototype.setEncoding=function(e){x||=ai().StringDecoder;var t=new x(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r=``;n!==null;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),r!==``&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var M=1073741824;function N(e){return e>=M?e=M:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function P(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=N(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}O.prototype.read=function(e){d(`read`,e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark===0?t.length>0:t.length>=t.highWaterMark)||t.ended))return d(`read: emitReadable`,t.length,t.ended),t.length===0&&t.ended?re(this):ee(this),null;if(e=P(e,t),e===0&&t.ended)return t.length===0&&re(this),null;var r=t.needReadable;d(`need readable`,r),(t.length===0||t.length-e<t.highWaterMark)&&(r=!0,d(`length less than watermark`,r)),t.ended||t.reading?(r=!1,d(`reading or ended`,r)):r&&(d(`do read`),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=P(n,t)));var i=e>0?U(e,t):null;return i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&re(this)),i!==null&&this.emit(`data`,i),i};function F(e,t){if(d(`onEofChunk`),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?ee(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,I(e)))}}function ee(e){var t=e._readableState;d(`emitReadable`,t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(d(`emitReadable`,t.flowing),t.emittedReadable=!0,process.nextTick(I,e))}function I(e){var t=e._readableState;d(`emitReadable_`,t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit(`readable`),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,H(e)}function L(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(R,e,t))}function R(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var n=t.length;if(d(`maybeReadMore read 0`),e.read(0),n===t.length)break}t.readingMore=!1}O.prototype._read=function(e){w(this,new y(`_read()`))},O.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e);break}r.pipesCount+=1,d(`pipe count=%d opts=%j`,r.pipesCount,t);var a=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr?s:g;r.endEmitted?process.nextTick(a):n.once(`end`,a),e.on(`unpipe`,o);function o(e,t){d(`onunpipe`),e===n&&t&&t.hasUnpiped===!1&&(t.hasUnpiped=!0,u())}function s(){d(`onend`),e.end()}var c=te(n);e.on(`drain`,c);var l=!1;function u(){d(`cleanup`),e.removeListener(`close`,m),e.removeListener(`finish`,h),e.removeListener(`drain`,c),e.removeListener(`error`,p),e.removeListener(`unpipe`,o),n.removeListener(`end`,s),n.removeListener(`end`,g),n.removeListener(`data`,f),l=!0,r.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}n.on(`data`,f);function f(t){d(`ondata`);var i=e.write(t);d(`dest.write`,i),i===!1&&((r.pipesCount===1&&r.pipes===e||r.pipesCount>1&&W(r.pipes,e)!==-1)&&!l&&(d(`false write response, pause`,r.awaitDrain),r.awaitDrain++),n.pause())}function p(t){d(`onerror`,t),g(),e.removeListener(`error`,p),i(e,`error`)===0&&w(e,t)}E(e,`error`,p);function m(){e.removeListener(`finish`,h),g()}e.once(`close`,m);function h(){d(`onfinish`),e.removeListener(`close`,m),g()}e.once(`finish`,h);function g(){d(`unpipe`),n.unpipe(e)}return e.emit(`pipe`,n),r.flowing||(d(`pipe resume`),n.resume()),e};function te(e){return function(){var t=e._readableState;d(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&i(e,`data`)&&(t.flowing=!0,H(e))}}O.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||=t.pipes,t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit(`unpipe`,this,n),this);if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<i;a++)r[a].emit(`unpipe`,this,{hasUnpiped:!1});return this}var o=W(t.pipes,e);return o===-1?this:(t.pipes.splice(o,1),--t.pipesCount,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit(`unpipe`,this,n),this)},O.prototype.on=function(e,t){var n=a.prototype.on.call(this,e,t),r=this._readableState;return e===`data`?(r.readableListening=this.listenerCount(`readable`)>0,r.flowing!==!1&&this.resume()):e===`readable`&&!r.endEmitted&&!r.readableListening&&(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,d(`on readable`,r.length,r.reading),r.length?ee(this):r.reading||process.nextTick(B,this)),n},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(e,t){var n=a.prototype.removeListener.call(this,e,t);return e===`readable`&&process.nextTick(z,this),n},O.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&process.nextTick(z,this),t};function z(e){var t=e._readableState;t.readableListening=e.listenerCount(`readable`)>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount(`data`)>0&&e.resume()}function B(e){d(`readable nexttick read 0`),e.read(0)}O.prototype.resume=function(){var e=this._readableState;return e.flowing||(d(`resume`),e.flowing=!e.readableListening,ne(this,e)),e.paused=!1,this};function ne(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(V,e,t))}function V(e,t){d(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),H(e),t.flowing&&!t.reading&&e.read(0)}O.prototype.pause=function(){return d(`call pause flowing=%j`,this._readableState.flowing),this._readableState.flowing!==!1&&(d(`pause`),this._readableState.flowing=!1,this.emit(`pause`)),this._readableState.paused=!0,this};function H(e){var t=e._readableState;for(d(`flow`,t.flowing);t.flowing&&e.read()!==null;);}O.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on(`end`,function(){if(d(`wrapped end`),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on(`data`,function(i){d(`wrapped data`),n.decoder&&(i=n.decoder.write(i)),!(n.objectMode&&i==null)&&(!n.objectMode&&(!i||!i.length)||t.push(i)||(r=!0,e.pause()))}),e)this[i]===void 0&&typeof e[i]==`function`&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var a=0;a<T.length;a++)e.on(T[a],this.emit.bind(this,T[a]));return this._read=function(t){d(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(O.prototype[Symbol.asyncIterator]=function(){return S===void 0&&(S=si()),S(this)}),Object.defineProperty(O.prototype,`readableHighWaterMark`,{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(O.prototype,`readableBuffer`,{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(O.prototype,`readableFlowing`,{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),O._fromList=U,Object.defineProperty(O.prototype,`readableLength`,{enumerable:!1,get:function(){return this._readableState.length}});function U(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(``):t.buffer.length===1?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n}function re(e){var t=e._readableState;d(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(ie,t,e))}function ie(e,t){if(d(`endReadableNT`,e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit(`end`),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}typeof Symbol==`function`&&(O.from=function(e,t){return C===void 0&&(C=ci()),C(O,e,t)});function W(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),ui=e(((exports,t)=>{var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=c;var r=li(),i=di();ni()(c,r);for(var a=n(i.prototype),o=0;o<a.length;o++){var s=a[o];c.prototype[s]||(c.prototype[s]=i.prototype[s])}function c(e){if(!(this instanceof c))return new c(e);r.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once(`end`,l)))}Object.defineProperty(c.prototype,`writableHighWaterMark`,{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,`writableBuffer`,{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,`writableLength`,{enumerable:!1,get:function(){return this._writableState.length}});function l(){this._writableState.ended||process.nextTick(u,this)}function u(e){e.end()}Object.defineProperty(c.prototype,`destroyed`,{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}})})),di=e(((exports,n)=>{n.exports=D;function r(e){var t=this;this.next=null,this.entry=null,this.finish=function(){V(t,e)}}var i;D.WritableState=T;var a={deprecate:Xr()},o=Zr(),s=t(`buffer`).Buffer,c=(typeof global<`u`?global:typeof window<`u`?window:typeof self<`u`?self:{}).Uint8Array||function(){};function l(e){return s.from(e)}function u(e){return s.isBuffer(e)||e instanceof c}var d=Qr(),f=ei(),p=f.getHighWaterMark,m=$r().codes,h=m.ERR_INVALID_ARG_TYPE,g=m.ERR_METHOD_NOT_IMPLEMENTED,_=m.ERR_MULTIPLE_CALLBACK,v=m.ERR_STREAM_CANNOT_PIPE,y=m.ERR_STREAM_DESTROYED,b=m.ERR_STREAM_NULL_VALUES,x=m.ERR_STREAM_WRITE_AFTER_END,S=m.ERR_UNKNOWN_ENCODING,C=d.errorOrDestroy;ni()(D,o);function w(){}function T(e,t,n){i||=ui(),e||={},typeof n!=`boolean`&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=p(this,e,`writableHighWaterMark`,n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1,this.decodeStrings=e.decodeStrings!==!1,this.defaultEncoding=e.defaultEncoding||`utf8`,this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){F(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new r(this)}T.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},(function(){try{Object.defineProperty(T.prototype,`buffer`,{get:a.deprecate(function(){return this.getBuffer()},`_writableState.buffer is deprecated. Use _writableState.getBuffer instead.`,`DEP0003`)})}catch{}})();var E;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(E=Function.prototype[Symbol.hasInstance],Object.defineProperty(D,Symbol.hasInstance,{value:function(e){return E.call(this,e)?!0:this===D?e&&e._writableState instanceof T:!1}})):E=function(e){return e instanceof this};function D(e){i||=ui();var t=this instanceof i;if(!t&&!E.call(D,this))return new D(e);this._writableState=new T(e,this,t),this.writable=!0,e&&(typeof e.write==`function`&&(this._write=e.write),typeof e.writev==`function`&&(this._writev=e.writev),typeof e.destroy==`function`&&(this._destroy=e.destroy),typeof e.final==`function`&&(this._final=e.final)),o.call(this)}D.prototype.pipe=function(){C(this,new v)};function O(e,t){var n=new x;C(e,n),process.nextTick(t,n)}function k(e,t,n,r){var i;return n===null?i=new b:typeof n!=`string`&&!t.objectMode&&(i=new h(`chunk`,[`string`,`Buffer`],n)),i?(C(e,i),process.nextTick(r,i),!1):!0}D.prototype.write=function(e,t,n){var r=this._writableState,i=!1,a=!r.objectMode&&u(e);return a&&!s.isBuffer(e)&&(e=l(e)),typeof t==`function`&&(n=t,t=null),a?t=`buffer`:t||=r.defaultEncoding,typeof n!=`function`&&(n=w),r.ending?O(this,n):(a||k(this,r,e,n))&&(r.pendingcb++,i=j(this,r,a,e,t,n)),i},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&L(this,e))},D.prototype.setDefaultEncoding=function(e){if(typeof e==`string`&&(e=e.toLowerCase()),!([`hex`,`utf8`,`utf-8`,`ascii`,`binary`,`base64`,`ucs2`,`ucs-2`,`utf16le`,`utf-16le`,`raw`].indexOf((e+``).toLowerCase())>-1))throw new S(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(D.prototype,`writableBuffer`,{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function A(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=s.from(t,n)),t}Object.defineProperty(D.prototype,`writableHighWaterMark`,{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function j(e,t,n,r,i,a){if(!n){var o=A(t,r,i);r!==o&&(n=!0,i=`buffer`,r=o)}var s=t.objectMode?1:r.length;t.length+=s;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:a,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else M(e,t,!1,s,r,i,a);return c}function M(e,t,n,r,i,a,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new y(`write`)):n?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function N(e,t,n,r,i){--t.pendingcb,n?(process.nextTick(i,r),process.nextTick(B,e,t),e._writableState.errorEmitted=!0,C(e,r)):(i(r),e._writableState.errorEmitted=!0,C(e,r),B(e,t))}function P(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function F(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(typeof i!=`function`)throw new _;if(P(n),t)N(e,n,r,t,i);else{var a=R(n)||e.destroyed;!a&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&L(e,n),r?process.nextTick(ee,e,n,a,i):ee(e,n,a,i)}}function ee(e,t,n,r){n||I(e,t),t.pendingcb--,r(),B(e,t)}function I(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function L(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,a=Array(i),o=t.corkedRequestsFree;o.entry=n;for(var s=0,c=!0;n;)a[s]=n,n.isBuf||(c=!1),n=n.next,s+=1;a.allBuffers=c,M(e,t,!0,t.length,a,``,o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new r(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,d=n.callback,f=t.objectMode?1:l.length;if(M(e,t,!1,f,l,u,d),n=n.next,t.bufferedRequestCount--,t.writing)break}n===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}D.prototype._write=function(e,t,n){n(new g(`_write()`))},D.prototype._writev=null,D.prototype.end=function(e,t,n){var r=this._writableState;return typeof e==`function`?(n=e,e=null,t=null):typeof t==`function`&&(n=t,t=null),e!=null&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||ne(this,r,n),this},Object.defineProperty(D.prototype,`writableLength`,{enumerable:!1,get:function(){return this._writableState.length}});function R(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function te(e,t){e._final(function(n){t.pendingcb--,n&&C(e,n),t.prefinished=!0,e.emit(`prefinish`),B(e,t)})}function z(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,process.nextTick(te,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function B(e,t){var n=R(t);if(n&&(z(e,t),t.pendingcb===0&&(t.finished=!0,e.emit(`finish`),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function ne(e,t,n){t.ending=!0,B(e,t),n&&(t.finished?process.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function V(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}Object.defineProperty(D.prototype,`destroyed`,{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),D.prototype.destroy=d.destroy,D.prototype._undestroy=d.undestroy,D.prototype._destroy=function(e,t){t(e)}})),fi=e((exports=>{exports.levels={error:0,warn:1,help:2,data:3,info:4,debug:5,prompt:6,verbose:7,input:8,silly:9},exports.colors={error:`red`,warn:`yellow`,help:`cyan`,data:`grey`,info:`green`,debug:`blue`,prompt:`grey`,verbose:`cyan`,input:`grey`,silly:`magenta`}})),pi=e((exports=>{exports.levels={error:0,warn:1,info:2,http:3,verbose:4,debug:5,silly:6},exports.colors={error:`red`,warn:`yellow`,info:`green`,http:`green`,verbose:`cyan`,debug:`blue`,silly:`magenta`}})),mi=e((exports=>{exports.levels={emerg:0,alert:1,crit:2,error:3,warning:4,notice:5,info:6,debug:7},exports.colors={emerg:`red`,alert:`yellow`,crit:`red`,error:`red`,warning:`red`,notice:`yellow`,info:`green`,debug:`blue`}})),hi=e((exports=>{Object.defineProperty(exports,`cli`,{value:fi()}),Object.defineProperty(exports,`npm`,{value:pi()}),Object.defineProperty(exports,`syslog`,{value:mi()})})),gi=e((exports=>{Object.defineProperty(exports,`LEVEL`,{value:Symbol.for(`level`)}),Object.defineProperty(exports,`MESSAGE`,{value:Symbol.for(`message`)}),Object.defineProperty(exports,`SPLAT`,{value:Symbol.for(`splat`)}),Object.defineProperty(exports,`configs`,{value:hi()})})),_i=e(((exports,n)=>{let r=t(`util`),i=di(),{LEVEL:a}=gi(),o=n.exports=function(e={}){i.call(this,{objectMode:!0,highWaterMark:e.highWaterMark}),this.format=e.format,this.level=e.level,this.handleExceptions=e.handleExceptions,this.handleRejections=e.handleRejections,this.silent=e.silent,e.log&&(this.log=e.log),e.logv&&(this.logv=e.logv),e.close&&(this.close=e.close),this.once(`pipe`,e=>{this.levels=e.levels,this.parent=e}),this.once(`unpipe`,e=>{e===this.parent&&(this.parent=null,this.close&&this.close())})};r.inherits(o,i),o.prototype._write=function(e,t,n){if(this.silent||e.exception===!0&&!this.handleExceptions)return n(null);let r=this.level||this.parent&&this.parent.level;if(!r||this.levels[r]>=this.levels[e[a]]){if(e&&!this.format)return this.log(e,n);let t,r;try{r=this.format.transform(Object.assign({},e),this.format.options)}catch(e){t=e}if(t||!r){if(n(),t)throw t;return}return this.log(r,n)}return this._writableState.sync=!1,n(null)},o.prototype._writev=function(e,t){if(this.logv){let n=e.filter(this._accept,this);return n.length?this.logv(n,t):t(null)}for(let n=0;n<e.length;n++){if(!this._accept(e[n]))continue;if(e[n].chunk&&!this.format){this.log(e[n].chunk,e[n].callback);continue}let r,i;try{i=this.format.transform(Object.assign({},e[n].chunk),this.format.options)}catch(e){r=e}if(r||!i){if(e[n].callback(),r)throw t(null),r}else this.log(i,e[n].callback)}return t(null)},o.prototype._accept=function(e){let t=e.chunk;if(this.silent)return!1;let n=this.level||this.parent&&this.parent.level;return!!((t.exception===!0||!n||this.levels[n]>=this.levels[t[a]])&&(this.handleExceptions||t.exception!==!0))},o.prototype._nop=function(){}})),vi=e(((exports,n)=>{let r=t(`util`),{LEVEL:i}=gi(),a=_i(),o=n.exports=function(e={}){if(a.call(this,e),!e.transport||typeof e.transport.log!=`function`)throw Error(`Invalid transport, must be an object with a log method.`);this.transport=e.transport,this.level=this.level||e.transport.level,this.handleExceptions=this.handleExceptions||e.transport.handleExceptions,this._deprecated();function t(e){this.emit(`error`,e,this.transport)}this.transport.__winstonError||(this.transport.__winstonError=t.bind(this),this.transport.on(`error`,this.transport.__winstonError))};r.inherits(o,a),o.prototype._write=function(e,t,n){if(this.silent||e.exception===!0&&!this.handleExceptions)return n(null);(!this.level||this.levels[this.level]>=this.levels[e[i]])&&this.transport.log(e[i],e.message,e,this._nop),n(null)},o.prototype._writev=function(e,t){for(let t=0;t<e.length;t++)this._accept(e[t])&&(this.transport.log(e[t].chunk[i],e[t].chunk.message,e[t].chunk,this._nop),e[t].callback());return t(null)},o.prototype._deprecated=function(){console.error([`${this.transport.name} is a legacy winston transport. Consider upgrading: `,`- Upgrade docs: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md`].join(`
|
|
4
4
|
`))},o.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener(`error`,this.transport.__winstonError),this.transport.__winstonError=null)}})),yi=n(e(((exports,t)=>{t.exports=_i(),t.exports.LegacyTransportStream=vi()}))(),1);const bi=new Set([`apikey`,`auth`,`credential`,`key`,`password`,`secret`,`token`]);var xi=class extends yi.default{apiKey;extraAttributes;httpTimeout;ingestUrl;pendingRequests=new Set;constructor(e){super({}),this.apiKey=e.apiKey,this.ingestUrl=e.ingestUrl,this.httpTimeout=e.httpTimeout??5e3;let t=_()||`unknown`;this.extraAttributes={arch:h(),hostname:t,instance:`mcp-gateway-${t}`,os:v(),source:`onyx-mcp-gateway`,version:Gr.appVersion,workload:`mcp-gateway`}}async flush(e=5e3){let t=Array.from(this.pendingRequests);t.length!==0&&await Promise.race([Promise.all(t),new Promise(t=>setTimeout(t,e))])}log(e,t){setImmediate(()=>this.emit(`logged`,e));let n=this.enrichEntry(e),r=this.sendEntry(n);this.pendingRequests.add(r),r.finally(()=>this.pendingRequests.delete(r)),t()}enrichEntry(e){let t={...this.extraAttributes,level:(e.level||`info`).toUpperCase(),message:e.message||``,timestamp:e.timestamp||new Date().toISOString()};for(let[n,r]of Object.entries(e)){if([`level`,`message`,`timestamp`].includes(n))continue;bi.has(n.toLowerCase())?t[n]=`[REDACTED]`:t[n]=Ci(r)}return t}async sendEntry(e){let t=new AbortController,n=setTimeout(()=>t.abort(),this.httpTimeout);try{let n=Si(e);await(await fetch(this.ingestUrl,{body:n,headers:{apikey:this.apiKey,"Content-Type":`application/json`,"x-source-type":`endpoint-logs`},method:`POST`,signal:t.signal})).text()}catch{}finally{clearTimeout(n)}}};function Si(e){try{return JSON.stringify(e)}catch(t){let n={_serializationError:!0,level:`ERROR`,message:`[Log entry could not be serialized]`,originalError:t instanceof Error?t.message:String(t),timestamp:new Date().toISOString()};if(e&&typeof e==`object`)for(let t of[`level`,`message`,`timestamp`,`source`,`workload`]){let r=e[t];typeof r==`string`&&(n[t]=r)}return JSON.stringify(n)}}function Ci(e,t=0,n=new WeakSet){if(t>10)return`[max depth exceeded]`;if(e==null)return e;let r=typeof e;if(r===`string`||r===`number`||r===`boolean`)return r===`number`&&(Number.isNaN(e)||!Number.isFinite(e))?String(e):e;if(r===`function`)return`[Function: ${e.name||`anonymous`}]`;if(r===`symbol`)return`[Symbol: ${e.description||``}]`;if(r===`bigint`)return String(e);if(r===`object`){if(n.has(e))return`[Circular]`;if(n.add(e),e instanceof Date)return e.toISOString();if(e instanceof Error)return{message:e.message,name:e.name,stack:e.stack};if(e instanceof RegExp)return e.toString();if(e instanceof Map){let r={};for(let[i,a]of e){let e=typeof i==`string`?i:String(i);r[e]=Ci(a,t+1,n)}return r}if(e instanceof Set)return Array.from(e).map(e=>Ci(e,t+1,n));if(Array.isArray(e))return e.map(e=>Ci(e,t+1,n));if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return`[Binary Data]`;let r={},i;try{i=Object.keys(e)}catch{return`[Object with inaccessible keys]`}for(let a of i){if(bi.has(a.toLowerCase())){r[a]=`[REDACTED]`;continue}try{let i=e[a];r[a]=Ci(i,t+1,n)}catch{r[a]=`[Unserializable]`}}return r}return`[Unknown Type]`}const wi=a(),Ti=new i;function Ei(e,t){return Ti.run({traceId:e},t)}let Di=wi;function Oi(e){let t=e?.traceparent;if(t){let e=t.split(`-`);if(e.length>=2&&e[1])return e[1]}}function ki(){return Ti.getStore()?.traceId??Di}function Ai(e){Di=e}const ji=Gr.logDir,Mi=Gr.debug?`debug`:`info`;let Ni=!1;try{s(ji)||c(ji,{recursive:!0}),Ni=!0;try{qr(ji)}catch{}}catch(e){let t=e instanceof Error?e.message:String(e),n=t.includes(`EACCES`)||t.includes(`permission denied`);console.error(`[mcp-gateway] WARNING: Failed to create log directory: ${ji}`),console.error(`[mcp-gateway] Error: ${t}`),n&&(console.error(`[mcp-gateway] This appears to be a permission issue. Possible solutions:`),console.error(`[mcp-gateway] 1. Fix directory permissions: sudo chown -R $USER ~/.onyx`),console.error(`[mcp-gateway] 2. Use a different log directory: export MCP_GATEWAY_LOG_DIR=/tmp/mcp-gateway-logs`)),console.error(`[mcp-gateway] File logging will be disabled. The gateway will continue to function.`)}const Pi=f.format.combine(f.format.timestamp(),f.format.errors({stack:!0}),f.format.json());let Fi=null;const Ii=[];if(Ni){let e=new p({datePattern:`YYYY-MM-DD`,filename:u(ji,`mcp-gateway-%DATE%.log`),format:Pi,handleExceptions:!1,handleRejections:!1,level:Mi,maxFiles:10,maxSize:`10m`});Ii.push(e)}let Li=null;const Ri=Gr.logIngest.enabled&&Gr.logIngest.url&&Gr.logIngest.apiKey;Ri&&(Li=new xi({apiKey:Gr.logIngest.apiKey,httpTimeout:Gr.logIngest.timeoutMs,ingestUrl:Gr.logIngest.url}),Ii.push(Li));const zi=f.format(e=>(e.traceId=ki(),e)),Bi=f.createLogger({defaultMeta:{service:`mcp-gateway`,version:Gr.appVersion},format:f.format.combine(zi(),f.format.errors({stack:!0})),level:Mi,transports:Ii}),Vi=e=>{let[t,...n]=e;if(typeof t!=`string`)return{message:String(t??``),meta:void 0,sessionData:Fi||void 0};if(n.length>0&&n[0]&&typeof n[0]==`object`&&`proxyType`in n[0]){let e=n[0],r=n[1];return{message:t,meta:r,sessionData:e}}let r=n[0];return{message:t,meta:r,sessionData:Fi||void 0}},Q={debug:(...e)=>{let{message:t,meta:n,sessionData:r}=Vi(e);Bi.debug(t,{sessionData:r,...n})},error:(...e)=>{let{message:t,meta:n,sessionData:r}=Vi(e);Bi.error(t,{sessionData:r,...n})},getSessionData:()=>Fi,getTraceId:()=>ki(),info:(...e)=>{let{message:t,meta:n,sessionData:r}=Vi(e);Bi.info(t,{sessionData:r,...n})},setSessionData:e=>{Fi=e,Q.debug(`Session data set for logger`,e)},setTraceId:e=>{Ai(e),Q.debug(`Trace ID updated for logger`,{traceId:e})},warn:(...e)=>{let{message:t,meta:n,sessionData:r}=Vi(e);Bi.warn(t,{sessionData:r,...n})}},Hi=async e=>{Li&&await Li.flush(e)};Q.info(`MCP Gateway logger initialized`,{debug:Gr.debug,fileLoggingEnabled:Ni,ingestLoggingEnabled:Ri,logDir:ji,logLevel:Mi});const Ui=Gr.clientAppName;let Wi=null;const Gi=async()=>(Wi||=await import(`systeminformation`),Wi);function Ki(e){return typeof e==`string`&&e!==``&&e.includes(`@`)}function qi(){try{let e=Zi();if(!s(e))return null;let t=l(e,`utf-8`),n=!1;for(let e of t.split(`
|
|
@@ -30,4 +30,4 @@ return fn.apply(this, arguments)
|
|
|
30
30
|
`&&r++}}return[t,n]}var us=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(ps(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(ps(this),t)}};function ds(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function fs(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(fs).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${fs(e.cause)}`:e.message:`${e}`}function ps(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var ms=e=>{throw TypeError(e)},hs=(e,t,n)=>t.has(e)||ms(`Cannot `+n),$=(e,t,n)=>(hs(e,t,`read from private field`),n?n.call(e):t.get(e)),gs=(e,t,n)=>t.has(e)?ms(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),_s=(e,t,n,r)=>(hs(e,t,`write to private field`),t.set(e,n),n),vs=(e,t,n)=>(hs(e,t,`access private method`),n),ys,bs,xs,Ss,Cs,ws,Ts,Es,Ds,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs=class extends EventTarget{constructor(e,t){super(),gs(this,Ms),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,gs(this,ys),gs(this,bs),gs(this,xs),gs(this,Ss),gs(this,Cs),gs(this,ws),gs(this,Ts),gs(this,Es,null),gs(this,Ds),gs(this,Os),gs(this,ks,null),gs(this,As,null),gs(this,js,null),gs(this,Ps,async e=>{var t;$(this,Os).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){vs(this,Ms,zs).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?_s(this,xs,new URL(e.url)):_s(this,xs,void 0),i!==200){vs(this,Ms,zs).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){vs(this,Ms,zs).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if($(this,ys)===this.CLOSED)return;_s(this,ys,this.OPEN);let o=new Event(`open`);if((t=$(this,js))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){vs(this,Ms,zs).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&$(this,Os).feed(s.decode(t,{stream:!e})),e&&(l=!1,$(this,Os).reset(),vs(this,Ms,Bs).call(this))}while(l)}),gs(this,Fs,e=>{_s(this,Ds,void 0),!(e.name===`AbortError`||e.type===`aborted`)&&vs(this,Ms,Bs).call(this,fs(e))}),gs(this,Ls,e=>{typeof e.id==`string`&&_s(this,Es,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:$(this,xs)?$(this,xs).origin:$(this,bs).origin,lastEventId:e.id||``});$(this,As)&&(!e.event||e.event===`message`)&&$(this,As).call(this,t),this.dispatchEvent(t)}),gs(this,Rs,e=>{_s(this,ws,e)}),gs(this,Vs,()=>{_s(this,Ts,void 0),$(this,ys)===this.CONNECTING&&vs(this,Ms,Ns).call(this)});try{if(e instanceof URL)_s(this,bs,e);else if(typeof e==`string`)_s(this,bs,new URL(e,Us()));else throw Error(`Invalid URL`)}catch{throw ds(`An invalid or illegal string was specified`)}_s(this,Os,cs({onEvent:$(this,Ls),onRetry:$(this,Rs)})),_s(this,ys,this.CONNECTING),_s(this,ws,3e3),_s(this,Cs,t?.fetch??globalThis.fetch),_s(this,Ss,t?.withCredentials??!1),vs(this,Ms,Ns).call(this)}get readyState(){return $(this,ys)}get url(){return $(this,bs).href}get withCredentials(){return $(this,Ss)}get onerror(){return $(this,ks)}set onerror(e){_s(this,ks,e)}get onmessage(){return $(this,As)}set onmessage(e){_s(this,As,e)}get onopen(){return $(this,js)}set onopen(e){_s(this,js,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){$(this,Ts)&&clearTimeout($(this,Ts)),$(this,ys)!==this.CLOSED&&($(this,Ds)&&$(this,Ds).abort(),_s(this,ys,this.CLOSED),_s(this,Ds,void 0))}};ys=new WeakMap,bs=new WeakMap,xs=new WeakMap,Ss=new WeakMap,Cs=new WeakMap,ws=new WeakMap,Ts=new WeakMap,Es=new WeakMap,Ds=new WeakMap,Os=new WeakMap,ks=new WeakMap,As=new WeakMap,js=new WeakMap,Ms=new WeakSet,Ns=function(){_s(this,ys,this.CONNECTING),_s(this,Ds,new AbortController),$(this,Cs)($(this,bs),vs(this,Ms,Is).call(this)).then($(this,Ps)).catch($(this,Fs))},Ps=new WeakMap,Fs=new WeakMap,Is=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...$(this,Es)?{"Last-Event-ID":$(this,Es)}:void 0},cache:`no-store`,signal:$(this,Ds)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},Ls=new WeakMap,Rs=new WeakMap,zs=function(e,t){var n;$(this,ys)!==this.CLOSED&&_s(this,ys,this.CLOSED);let r=new us(`error`,{code:t,message:e});(n=$(this,ks))==null||n.call(this,r),this.dispatchEvent(r)},Bs=function(e,t){var n;if($(this,ys)===this.CLOSED)return;_s(this,ys,this.CONNECTING);let r=new us(`error`,{code:t,message:e});(n=$(this,ks))==null||n.call(this,r),this.dispatchEvent(r),_s(this,Ts,setTimeout($(this,Vs),$(this,ws)))},Vs=new WeakMap,Hs.CONNECTING=0,Hs.OPEN=1,Hs.CLOSED=2;function Us(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}let Ws;Ws=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function Gs(e){return(await Ws).getRandomValues(new Uint8Array(e))}async function Ks(e){let t=``,n=await Gs(e);for(let r=0;r<e;r++){let e=n[r]%66;t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e]}return t}async function qs(e){return await Ks(e)}async function Js(e){let t=await(await Ws).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Ys(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await qs(e),n=await Js(t);return{code_verifier:t,code_challenge:n}}const Xs=q().url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:j.custom,message:`URL must be parseable`,fatal:!0}),Ct}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Zs=Y({resource:q().url(),authorization_servers:J(Xs).optional(),jwks_uri:q().url().optional(),scopes_supported:J(q()).optional(),bearer_methods_supported:J(q()).optional(),resource_signing_alg_values_supported:J(q()).optional(),resource_name:q().optional(),resource_documentation:q().optional(),resource_policy_uri:q().url().optional(),resource_tos_uri:q().url().optional(),tls_client_certificate_bound_access_tokens:gt().optional(),authorization_details_types_supported:J(q()).optional(),dpop_signing_alg_values_supported:J(q()).optional(),dpop_bound_access_tokens_required:gt().optional()}).passthrough(),Qs=Y({issuer:q(),authorization_endpoint:Xs,token_endpoint:Xs,registration_endpoint:Xs.optional(),scopes_supported:J(q()).optional(),response_types_supported:J(q()),response_modes_supported:J(q()).optional(),grant_types_supported:J(q()).optional(),token_endpoint_auth_methods_supported:J(q()).optional(),token_endpoint_auth_signing_alg_values_supported:J(q()).optional(),service_documentation:Xs.optional(),revocation_endpoint:Xs.optional(),revocation_endpoint_auth_methods_supported:J(q()).optional(),revocation_endpoint_auth_signing_alg_values_supported:J(q()).optional(),introspection_endpoint:q().optional(),introspection_endpoint_auth_methods_supported:J(q()).optional(),introspection_endpoint_auth_signing_alg_values_supported:J(q()).optional(),code_challenge_methods_supported:J(q()).optional()}).passthrough(),$s=Y({issuer:q(),authorization_endpoint:Xs,token_endpoint:Xs,userinfo_endpoint:Xs.optional(),jwks_uri:Xs,registration_endpoint:Xs.optional(),scopes_supported:J(q()).optional(),response_types_supported:J(q()),response_modes_supported:J(q()).optional(),grant_types_supported:J(q()).optional(),acr_values_supported:J(q()).optional(),subject_types_supported:J(q()),id_token_signing_alg_values_supported:J(q()),id_token_encryption_alg_values_supported:J(q()).optional(),id_token_encryption_enc_values_supported:J(q()).optional(),userinfo_signing_alg_values_supported:J(q()).optional(),userinfo_encryption_alg_values_supported:J(q()).optional(),userinfo_encryption_enc_values_supported:J(q()).optional(),request_object_signing_alg_values_supported:J(q()).optional(),request_object_encryption_alg_values_supported:J(q()).optional(),request_object_encryption_enc_values_supported:J(q()).optional(),token_endpoint_auth_methods_supported:J(q()).optional(),token_endpoint_auth_signing_alg_values_supported:J(q()).optional(),display_values_supported:J(q()).optional(),claim_types_supported:J(q()).optional(),claims_supported:J(q()).optional(),service_documentation:q().optional(),claims_locales_supported:J(q()).optional(),ui_locales_supported:J(q()).optional(),claims_parameter_supported:gt().optional(),request_parameter_supported:gt().optional(),request_uri_parameter_supported:gt().optional(),require_request_uri_registration:gt().optional(),op_policy_uri:Xs.optional(),op_tos_uri:Xs.optional()}).passthrough().merge(Qs.pick({code_challenge_methods_supported:!0})),ec=Y({access_token:q(),id_token:q().optional(),token_type:q(),expires_in:ht().optional(),scope:q().optional(),refresh_token:q().optional()}).strip(),tc=Y({error:q(),error_description:q().optional(),error_uri:q().optional()}),nc=Y({redirect_uris:J(Xs),token_endpoint_auth_method:q().optional(),grant_types:J(q()).optional(),response_types:J(q()).optional(),client_name:q().optional(),client_uri:Xs.optional(),logo_uri:Xs.optional(),scope:q().optional(),contacts:J(q()).optional(),tos_uri:Xs.optional(),policy_uri:q().optional(),jwks_uri:Xs.optional(),jwks:_t().optional(),software_id:q().optional(),software_version:q().optional(),software_statement:q().optional()}).strip(),rc=Y({client_id:q(),client_secret:q().optional(),client_id_issued_at:ht().optional(),client_secret_expires_at:ht().optional()}).strip(),ic=nc.merge(rc);Y({error:q(),error_description:q().optional()}).strip(),Y({token:q(),token_type_hint:q().optional()}).strip();function ac(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function oc({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var sc=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},cc=class extends sc{};cc.errorCode=`invalid_request`;var lc=class extends sc{};lc.errorCode=`invalid_client`;var uc=class extends sc{};uc.errorCode=`invalid_grant`;var dc=class extends sc{};dc.errorCode=`unauthorized_client`;var fc=class extends sc{};fc.errorCode=`unsupported_grant_type`;var pc=class extends sc{};pc.errorCode=`invalid_scope`;var mc=class extends sc{};mc.errorCode=`access_denied`;var hc=class extends sc{};hc.errorCode=`server_error`;var gc=class extends sc{};gc.errorCode=`temporarily_unavailable`;var _c=class extends sc{};_c.errorCode=`unsupported_response_type`;var vc=class extends sc{};vc.errorCode=`unsupported_token_type`;var yc=class extends sc{};yc.errorCode=`invalid_token`;var bc=class extends sc{};bc.errorCode=`method_not_allowed`;var xc=class extends sc{};xc.errorCode=`too_many_requests`;var Sc=class extends sc{};Sc.errorCode=`invalid_client_metadata`;var Cc=class extends sc{};Cc.errorCode=`insufficient_scope`;const wc={[cc.errorCode]:cc,[lc.errorCode]:lc,[uc.errorCode]:uc,[dc.errorCode]:dc,[fc.errorCode]:fc,[pc.errorCode]:pc,[mc.errorCode]:mc,[hc.errorCode]:hc,[gc.errorCode]:gc,[_c.errorCode]:_c,[vc.errorCode]:vc,[yc.errorCode]:yc,[bc.errorCode]:bc,[xc.errorCode]:xc,[Sc.errorCode]:Sc,[Cc.errorCode]:Cc};var Tc=class extends Error{constructor(e){super(e??`Unauthorized`)}};function Ec(e,t){let n=e.client_secret!==void 0;return t.length===0?n?`client_secret_post`:`none`:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function Dc(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:Oc(i,a,n);return;case`client_secret_post`:kc(i,a,r);return;case`none`:Ac(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function Oc(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function kc(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function Ac(e,t){t.set(`client_id`,e)}async function jc(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=tc.parse(JSON.parse(n));return new(wc[e]||hc)(t||``,r)}catch(e){let r=`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`;return new hc(r)}}async function Mc(e,t){try{return await Nc(e,t)}catch(n){if(n instanceof lc||n instanceof dc)return await e.invalidateCredentials?.call(e,`all`),await Nc(e,t);if(n instanceof uc)return await e.invalidateCredentials?.call(e,`tokens`),await Nc(e,t);throw n}}async function Nc(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o,s;try{o=await Ic(t,{resourceMetadataUrl:i},a),o.authorization_servers&&o.authorization_servers.length>0&&(s=o.authorization_servers[0])}catch{}s||=t;let c=await Pc(t,e,o),l=await Uc(s,{fetchFn:a}),u=await Promise.resolve(e.clientInformation());if(!u){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await qc(s,{metadata:l,clientMetadata:e.clientMetadata,fetchFn:a});await e.saveClientInformation(t),u=t}if(n!==void 0){let t=await e.codeVerifier(),r=await Gc(s,{metadata:l,clientInformation:u,authorizationCode:n,codeVerifier:t,redirectUri:e.redirectUrl,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(r),`AUTHORIZED`}let d=await e.tokens();if(d?.refresh_token)try{let t=await Kc(s,{metadata:l,clientInformation:u,refreshToken:d.refresh_token,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof sc)||e instanceof hc))throw e}let f=e.state?await e.state():void 0,{authorizationUrl:p,codeVerifier:m}=await Wc(s,{metadata:l,clientInformation:u,state:f,redirectUrl:e.redirectUrl,scope:r||e.clientMetadata.scope,resource:c});return await e.saveCodeVerifier(m),await e.redirectToAuthorization(p),`REDIRECT`}async function Pc(e,t,n){let r=ac(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!oc({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function Fc(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return;let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return;let i=/resource_metadata="([^"]*)"/.exec(t);if(i)try{return new URL(i[1])}catch{return}}async function Ic(e,t,n=fetch){let r=await Vc(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return Zs.parse(await r.json())}async function Lc(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?Lc(e,void 0,n):void 0;throw r}}function Rc(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function zc(e,t,n=fetch){return await Lc(e,{"MCP-Protocol-Version":t},n)}function Bc(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function Vc(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??wt,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=Rc(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await zc(o,a,n);if(!r?.metadataUrl&&Bc(s,i.pathname)){let e=new URL(`/.well-known/${t}`,i);s=await zc(e,a,n)}return s}function Hc(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function Uc(e,{fetchFn:t=fetch,protocolVersion:n=wt}={}){let r={"MCP-Protocol-Version":n},i=Hc(e);for(let{url:e,type:n}of i){let i=await Lc(e,r,t);if(!i)continue;if(!i.ok){if(i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}if(n===`oauth`)return Qs.parse(await i.json());{let t=$s.parse(await i.json());if(!t.code_challenge_methods_supported?.includes(`S256`))throw Error(`Incompatible OIDC provider at ${e}: does not support S256 code challenge method required by MCP specification`);return t}}}async function Wc(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s=`code`,c=`S256`,l;if(t){if(l=new URL(t.authorization_endpoint),!t.response_types_supported.includes(s))throw Error(`Incompatible auth server: does not support response type ${s}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(c))throw Error(`Incompatible auth server: does not support code challenge method ${c}`)}else l=new URL(`/authorize`,e);let u=await Ys(),d=u.code_verifier,f=u.code_challenge;return l.searchParams.set(`response_type`,s),l.searchParams.set(`client_id`,n.client_id),l.searchParams.set(`code_challenge`,f),l.searchParams.set(`code_challenge_method`,c),l.searchParams.set(`redirect_uri`,String(r)),a&&l.searchParams.set(`state`,a),i&&l.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&l.searchParams.append(`prompt`,`consent`),o&&l.searchParams.set(`resource`,o.href),{authorizationUrl:l,codeVerifier:d}}async function Gc(e,{metadata:t,clientInformation:n,authorizationCode:r,codeVerifier:i,redirectUri:a,resource:o,addClientAuthentication:s,fetchFn:c}){let l=`authorization_code`,u=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e);if(t?.grant_types_supported&&!t.grant_types_supported.includes(l))throw Error(`Incompatible auth server: does not support grant type ${l}`);let d=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`}),f=new URLSearchParams({grant_type:l,code:r,code_verifier:i,redirect_uri:String(a)});if(s)s(d,f,e,t);else{let e=t?.token_endpoint_auth_methods_supported??[],r=Ec(n,e);Dc(r,n,d,f)}o&&f.set(`resource`,o.href);let p=await(c??fetch)(u,{method:`POST`,headers:d,body:f});if(!p.ok)throw await jc(p);return ec.parse(await p.json())}async function Kc(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){let s=`refresh_token`,c;if(t){if(c=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(s))throw Error(`Incompatible auth server: does not support grant type ${s}`)}else c=new URL(`/token`,e);let l=new Headers({"Content-Type":`application/x-www-form-urlencoded`}),u=new URLSearchParams({grant_type:s,refresh_token:r});if(a)a(l,u,e,t);else{let e=t?.token_endpoint_auth_methods_supported??[],r=Ec(n,e);Dc(r,n,l,u)}i&&u.set(`resource`,i.href);let d=await(o??fetch)(c,{method:`POST`,headers:l,body:u});if(!d.ok)throw await jc(d);return ec.parse({refresh_token:r,...await d.json()})}async function qc(e,{metadata:t,clientMetadata:n,fetchFn:r}){let i;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);i=new URL(t.registration_endpoint)}else i=new URL(`/register`,e);let a=await(r??fetch)(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!a.ok)throw await jc(a);return ic.parse(await a.json())}var Jc=class extends Error{constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n}},Yc=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch}async _authThenStart(){var e;if(!this._authProvider)throw new Tc(`No auth provider`);let t;try{t=await Mc(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch})}catch(t){throw(e=this.onerror)==null||e.call(this,t),t}if(t!==`AUTHORIZED`)throw new Tc;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}return this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion),new Headers({...e,...this._requestInit?.headers})}_startOrAuth(){let e=(this===null||this===void 0?void 0:this._eventSourceInit)?.fetch??this._fetch??fetch;return new Promise((t,n)=>{this._eventSource=new Hs(this._url.href,{...this._eventSourceInit,fetch:async(t,n)=>{let r=await this._commonHeaders();r.set(`Accept`,`text/event-stream`);let i=await e(t,{...n,headers:r});return i.status===401&&i.headers.has(`www-authenticate`)&&(this._resourceMetadataUrl=Fc(i)),i}}),this._abortController=new AbortController,this._eventSource.onerror=e=>{var r;if(e.code===401&&this._authProvider){this._authThenStart().then(t,n);return}let i=new Jc(e.code,e.message,e);n(i),(r=this.onerror)==null||r.call(this,i)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener(`endpoint`,e=>{var r;let i=e;try{if(this._endpoint=new URL(i.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){n(e),(r=this.onerror)==null||r.call(this,e),this.close();return}t()}),this._eventSource.onmessage=e=>{var t,n;let r=e,i;try{i=Wt.parse(JSON.parse(r.data))}catch(e){(t=this.onerror)==null||t.call(this,e);return}(n=this.onmessage)==null||n.call(this,i)}})}async start(){if(this._eventSource)throw Error(`SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new Tc(`No auth provider`);if(await Mc(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch})!==`AUTHORIZED`)throw new Tc(`Failed to authorize`)}async close(){var e,t,n;(e=this._abortController)==null||e.abort(),(t=this._eventSource)==null||t.close(),(n=this.onclose)==null||n.call(this)}async send(e){var t;if(!this._endpoint)throw Error(`Not connected`);try{let t=await this._commonHeaders();t.set(`content-type`,`application/json`);let n={...this._requestInit,method:`POST`,headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._endpoint,n);if(!r.ok){if(r.status===401&&this._authProvider){if(this._resourceMetadataUrl=Fc(r),await Mc(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch})!==`AUTHORIZED`)throw new Tc;return this.send(e)}let t=await r.text().catch(()=>null);throw Error(`Error POSTing to endpoint (HTTP ${r.status}): ${t}`)}}catch(e){throw(t=this.onerror)==null||t.call(this,e),e}}setProtocolVersion(e){this._protocolVersion=e}},Xc=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=cs({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};const Zc={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};var Qc=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},$c=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??Zc}async _authThenStart(){var e;if(!this._authProvider)throw new Tc(`No auth provider`);let t;try{t=await Mc(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch})}catch(t){throw(e=this.onerror)==null||e.call(this,t),t}if(t!==`AUTHORIZED`)throw new Tc;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let 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);let t=this._normalizeHeaders(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){var t;let{resumptionToken:n}=e;try{let t=await this._commonHeaders();t.set(`Accept`,`text/event-stream`),n&&t.set(`last-event-id`,n);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:t,signal:this._abortController?.signal});if(!r.ok){if(r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new Qc(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw(t=this.onerror)==null||t.call(this,e),e}}_getNextReconnectionDelay(e){let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_normalizeHeaders(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}_scheduleReconnection(e,t=0){var n;let r=this._reconnectionOptions.maxRetries;if(r>0&&t>=r){(n=this.onerror)==null||n.call(this,Error(`Maximum reconnection attempts (${r}) exceeded.`));return}let i=this._getNextReconnectionDelay(t);setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{var r;(r=this.onerror)==null||r.call(this,Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},i)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a;(async()=>{var t,o,s,c;try{let n=e.pipeThrough(new TextDecoderStream).pipeThrough(new Xc).getReader();for(;;){let{value:e,done:s}=await n.read();if(s)break;if(e.id&&(a=e.id,r?.(e.id)),!e.event||e.event===`message`)try{let n=Wt.parse(JSON.parse(e.data));i!==void 0&&Bt(n)&&(n.id=i),(t=this.onmessage)==null||t.call(this,n)}catch(e){(o=this.onerror)==null||o.call(this,e)}}}catch(e){if((s=this.onerror)==null||s.call(this,Error(`SSE stream disconnected: ${e}`)),n&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){(c=this.onerror)==null||c.call(this,Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw 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 Tc(`No auth provider`);if(await Mc(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch})!==`AUTHORIZED`)throw new Tc(`Failed to authorize`)}async close(){var e,t;(e=this._abortController)==null||e.abort(),(t=this.onclose)==null||t.call(this)}async send(e,t){var n,r;try{let{resumptionToken:r,onresumptiontoken:i}=t||{};if(r){this._startOrAuthSse({resumptionToken:r,replayMessageId:It(e)?e.id:void 0}).catch(e=>this.onerror?.call(this,e));return}let a=await this._commonHeaders();a.set(`content-type`,`application/json`),a.set(`accept`,`application/json, text/event-stream`);let o={...this._requestInit,method:`POST`,headers:a,body:JSON.stringify(e),signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,o),c=s.headers.get(`mcp-session-id`);if(c&&(this._sessionId=c),!s.ok){if(s.status===401&&this._authProvider){if(this._resourceMetadataUrl=Fc(s),await Mc(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch})!==`AUTHORIZED`)throw new Tc;return this.send(e)}let t=await s.text().catch(()=>null);throw Error(`Error POSTing to endpoint (HTTP ${s.status}): ${t}`)}if(s.status===202){nn(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.call(this,e));return}let l=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,u=s.headers.get(`content-type`);if(l)if(u?.includes(`text/event-stream`))this._handleSseStream(s.body,{onresumptiontoken:i},!1);else if(u?.includes(`application/json`)){let e=await s.json(),t=Array.isArray(e)?e.map(e=>Wt.parse(e)):[Wt.parse(e)];for(let e of t)(n=this.onmessage)==null||n.call(this,e)}else throw new Qc(-1,`Unexpected content type: ${u}`)}catch(e){throw(r=this.onerror)==null||r.call(this,e),e}}get sessionId(){return this._sessionId}async terminateSession(){var e;if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(!n.ok&&n.status!==405)throw new Qc(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(t){throw(e=this.onerror)==null||e.call(this,t),t}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}},el=n(ts(),1),tl=class extends so{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Kn.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this.setRequestHandler(Zt,e=>this._oninitialize(e)),this.setNotificationHandler(tn,()=>this.oninitialized?.call(this)),this._capabilities.logging&&this.setRequestHandler(qn,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=Kn.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=co(this._capabilities,e)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Server does not support sampling (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`ping`:case`initialize`:break}}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Tt.includes(t)?t:wt,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},Gt)}async createMessage(e,t){return this.request({method:`sampling/createMessage`,params:e},$n,t)}async elicitInput(e,t){let n=await this.request({method:`elicitation/create`,params:e},or,t);if(n.action===`accept`&&n.content)try{let t=new el.default,r=t.compile(e.requestedSchema);if(!r(n.content))throw new hr(Vt.InvalidParams,`Elicitation response content does not match requested schema: ${t.errorsText(r.errors)}`)}catch(e){throw e instanceof hr?e:new hr(Vt.InternalError,`Error validating elicitation response: ${e}`)}return n}async listRoots(e,t){return this.request({method:`roots/list`,params:e},pr,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}},nl=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
31
31
|
`);if(e===-1)return null;let t=this._buffer.toString(`utf8`,0,e).replace(/\r$/,``);return this._buffer=this._buffer.subarray(e+1),rl(t)}clear(){this._buffer=void 0}};function rl(e){return Wt.parse(JSON.parse(e))}function il(e){return JSON.stringify(e)+`
|
|
32
32
|
`}var al=class{constructor(e=T.stdin,t=T.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new nl,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{var t;(t=this.onerror)==null||t.call(this,e)}}async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror)}processReadBuffer(){for(var e,t;;)try{let t=this._readBuffer.readMessage();if(t===null)break;(e=this.onmessage)==null||e.call(this,t)}catch(e){(t=this.onerror)==null||t.call(this,e)}}async close(){var e;this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),(e=this.onclose)==null||e.call(this)}send(e){return new Promise(t=>{let n=il(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};function ol(e){let t=typeof e==`string`?new URL(e):new URL(e.toString());return t.pathname.length>1&&t.pathname.endsWith(`/`)&&(t.pathname=t.pathname.slice(0,-1)),t.toString()}export{_r as AccessControlBlockError,br as BUILD_TIME_CONFIG,rs as Client,vr as ConfigurationError,E as InMemoryEventStore,yr as ProxyConnectionError,nl as ReadBuffer,Yc as SSEClientTransport,tl as Server,al as StdioServerTransport,$c as StreamableHTTPClientTransport,Tc as UnauthorizedError,Kr as chownToRealUser,aa as compressClientInfo,Gr as config,cs as createParser,Uc as discoverAuthorizationServerMetadata,Ic as discoverOAuthProtectedResourceMetadata,Gc as exchangeAuthorization,Oi as extractTraceIdFromHeaders,Hi as flushLogs,ia as getSessionData,ca as initializeTrafficMirror,da as logRequestCounts,Q as logger,ol as normalizeUrl,ma as proxyServer,Kc as refreshAuthorization,qc as registerClient,il as serializeMessage,Wc as startAuthorization,oo as startHTTPServer};
|
|
33
|
-
//# sourceMappingURL=normalizeUrl-
|
|
33
|
+
//# sourceMappingURL=normalizeUrl-HKa4cuMt.js.map
|