@video-lab/embed-helper 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -2
- package/dist/index.iife.js +1 -1
- package/dist/index.mjs +9 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -122,13 +122,20 @@ function createEmbedListener(options = {}) {
|
|
|
122
122
|
}
|
|
123
123
|
//#endregion
|
|
124
124
|
//#region src/page-fullscreen.ts
|
|
125
|
+
let sessionCounter = 0;
|
|
126
|
+
function createSessionId() {
|
|
127
|
+
const uuid = globalThis.crypto?.randomUUID?.();
|
|
128
|
+
if (uuid) return uuid;
|
|
129
|
+
sessionCounter += 1;
|
|
130
|
+
return `page-fullscreen-${Date.now().toString(36)}-${sessionCounter.toString(36)}`;
|
|
131
|
+
}
|
|
125
132
|
/** 只控制网页全屏,不暴露其他播放器命令。销毁时恢复宿主布局。 */
|
|
126
133
|
function createPageFullscreenController(options) {
|
|
127
134
|
if (new URL(options.origin).origin !== options.origin || options.origin === "null") throw new Error("网页全屏要求精确 origin");
|
|
128
135
|
const { iframe, origin, adapter } = options;
|
|
129
136
|
const target = iframe.ownerDocument.defaultView;
|
|
130
137
|
if (!target) throw new Error("iframe 尚无宿主窗口");
|
|
131
|
-
let session =
|
|
138
|
+
let session = createSessionId();
|
|
132
139
|
let instance = "";
|
|
133
140
|
let revision = 0;
|
|
134
141
|
let active = false;
|
|
@@ -271,7 +278,7 @@ function createPageFullscreenController(options) {
|
|
|
271
278
|
if (event.key === "Escape" && active) setPageFullscreen(false).catch(() => {});
|
|
272
279
|
}
|
|
273
280
|
function reload() {
|
|
274
|
-
session =
|
|
281
|
+
session = createSessionId();
|
|
275
282
|
clearWaiting(/* @__PURE__ */ new Error("iframe 已重新加载"));
|
|
276
283
|
instance = "";
|
|
277
284
|
active = false;
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var SentinelEmbed=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t;(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})(t||={});var n;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(n||={});let r=t.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),i=e=>{switch(typeof e){case`undefined`:return r.undefined;case`string`:return r.string;case`number`:return Number.isNaN(e)?r.nan:r.number;case`boolean`:return r.boolean;case`function`:return r.function;case`bigint`:return r.bigint;case`symbol`:return r.symbol;case`object`:return Array.isArray(e)?r.array:e===null?r.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?r.promise:typeof Map<`u`&&e instanceof Map?r.map:typeof Set<`u`&&e instanceof Set?r.set:typeof Date<`u`&&e instanceof Date?r.date:r.object;default:return r.unknown}},a=t.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 o=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,t.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()}};o.create=e=>new o(e);let s=(e,n)=>{let i;switch(e.code){case a.invalid_type:i=e.received===r.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case a.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(e.expected,t.jsonStringifyReplacer)}`;break;case a.unrecognized_keys:i=`Unrecognized key(s) in object: ${t.joinValues(e.keys,`, `)}`;break;case a.invalid_union:i=`Invalid input`;break;case a.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${t.joinValues(e.options)}`;break;case a.invalid_enum_value:i=`Invalid enum value. Expected ${t.joinValues(e.options)}, received '${e.received}'`;break;case a.invalid_arguments:i=`Invalid function arguments`;break;case a.invalid_return_type:i=`Invalid function return type`;break;case a.invalid_date:i=`Invalid date`;break;case a.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(i=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(i=`${i} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?i=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?i=`Invalid input: must end with "${e.validation.endsWith}"`:t.assertNever(e.validation):i=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case a.too_small:i=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 a.too_big:i=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 a.custom:i=`Invalid input`;break;case a.invalid_intersection_types:i=`Intersection results could not be merged`;break;case a.not_multiple_of:i=`Number must be a multiple of ${e.multipleOf}`;break;case a.not_finite:i=`Number must be finite`;break;default:i=n.defaultError,t.assertNever(e)}return{message:i}},c=s;function l(){return c}let u=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 d(e,t){let n=l(),r=u({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===s?void 0:s].filter(e=>!!e)});e.common.issues.push(r)}var f=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 p;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 p;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}}};let p=Object.freeze({status:`aborted`}),m=e=>({status:`dirty`,value:e}),h=e=>({status:`valid`,value:e}),g=e=>e.status===`aborted`,_=e=>e.status===`dirty`,v=e=>e.status===`valid`,y=e=>typeof Promise<`u`&&e instanceof Promise;var b;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(b||={});var x=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}};let S=(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(){if(this._error)return this._error;let t=new o(e.common.issues);return this._error=t,this._error}}};function C(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 w=class{get description(){return this._def.description}_getType(e){return i(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new f,ctx:{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(y(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:i(e)},r=this._parseSync({data:e,path:n.path,parent:n});return S(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(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:i(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(y(r)?r:Promise.resolve(r));return S(n,a)}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),o=()=>r.addIssue({code:a.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(o(),!1)):i?!0:(o(),!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 L({schema:this,typeName:V.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 R.create(this,this._def)}nullable(){return z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return k.create(this)}promise(){return I.create(this,this._def)}or(e){return M.create([this,e],this._def)}and(e){return P.create(this,e,this._def)}transform(e){return new L({...C(this._def),schema:this,typeName:V.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Ue({...C(this._def),innerType:this,defaultValue:t,typeName:V.ZodDefault})}brand(){return new Ke({typeName:V.ZodBranded,type:this,...C(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new We({...C(this._def),innerType:this,catchValue:t,typeName:V.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return qe.create(this,e)}readonly(){return B.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let ee=/^c[^\s-]{8,}$/i,te=/^[0-9a-z]+$/,ne=/^[0-9A-HJKMNP-TV-Z]{26}$/i,re=/^[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,ie=/^[a-z0-9_-]{21}$/i,ae=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,oe=/^[-+]?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)?)??$/,se=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ce,le=/^(?:(?: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])$/,ue=/^(?:(?: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])$/,de=/^(([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]))$/,fe=/^(([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])$/,pe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,me=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,he=`((\\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])))`,ge=RegExp(`^${he}$`);function _e(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 ve(e){return RegExp(`^${_e(e)}$`)}function ye(e){let t=`${he}T${_e(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function be(e,t){return!!((t===`v4`||!t)&&le.test(e)||(t===`v6`||!t)&&de.test(e))}function xe(e,t){if(!ae.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 Se(e,t){return!!((t===`v4`||!t)&&ue.test(e)||(t===`v6`||!t)&&fe.test(e))}var Ce=class e extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==r.string){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.string,received:t.parsedType}),p}let n=new f,i;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind===`max`)e.data.length>r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind===`length`){let t=e.data.length>r.value,o=e.data.length<r.value;(t||o)&&(i=this._getOrReturnCtx(e,i),t?d(i,{code:a.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):o&&d(i,{code:a.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind===`email`)se.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`email`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`emoji`)ce||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),ce.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`emoji`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`uuid`)re.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`uuid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`nanoid`)ie.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`nanoid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`cuid`)ee.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cuid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`cuid2`)te.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cuid2`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`ulid`)ne.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`ulid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),d(i,{validation:`url`,code:a.invalid_string,message:r.message}),n.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`regex`,code:a.invalid_string,message:r.message}),n.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.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)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind===`datetime`?ye(r).test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`datetime`,message:r.message}),n.dirty()):r.kind===`date`?ge.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`date`,message:r.message}),n.dirty()):r.kind===`time`?ve(r).test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`time`,message:r.message}),n.dirty()):r.kind===`duration`?oe.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`duration`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`ip`?be(e.data,r.version)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`ip`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`jwt`?xe(e.data,r.alg)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`jwt`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`cidr`?Se(e.data,r.version)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cidr`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`base64`?pe.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`base64`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`base64url`?me.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`base64url`,code:a.invalid_string,message:r.message}),n.dirty()):t.assertNever(r);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:a.invalid_string,...b.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...b.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...b.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...b.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...b.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...b.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...b.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...b.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...b.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...b.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...b.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...b.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,...b.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,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...b.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...b.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.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}};Ce.create=e=>new Ce({checks:[],typeName:V.ZodString,coerce:e?.coerce??!1,...C(e)});function we(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Te=class e extends w{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)!==r.number){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.number,received:t.parsedType}),p}let n,i=new f;for(let r of this._def.checks)r.kind===`int`?t.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:a.invalid_type,expected:`integer`,received:`float`,message:r.message}),i.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind===`multipleOf`?we(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_finite,message:r.message}),i.dirty()):t.assertNever(r);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,b.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,b.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,b.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,b.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:b.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:b.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:b.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:b.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:b.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`&&t.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)}};Te.create=e=>new Te({checks:[],typeName:V.ZodNumber,coerce:e?.coerce||!1,...C(e)});var Ee=class e extends w{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)!==r.bigint)return this._getInvalidInput(e);let n,i=new f;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):t.assertNever(r);return{status:i.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.bigint,received:t.parsedType}),p}gte(e,t){return this.setLimit(`min`,e,!0,b.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,b.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,b.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,b.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:b.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:b.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:b.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}};Ee.create=e=>new Ee({checks:[],typeName:V.ZodBigInt,coerce:e?.coerce??!1,...C(e)});var De=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==r.boolean){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.boolean,received:t.parsedType}),p}return h(e.data)}};De.create=e=>new De({typeName:V.ZodBoolean,coerce:e?.coerce||!1,...C(e)});var Oe=class e extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==r.date){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.date,received:t.parsedType}),p}if(Number.isNaN(e.data.getTime()))return d(this._getOrReturnCtx(e),{code:a.invalid_date}),p;let n=new f,i;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),n.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),n.dirty()):t.assertNever(r);return{status:n.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:b.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:b.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)}};Oe.create=e=>new Oe({checks:[],coerce:e?.coerce||!1,typeName:V.ZodDate,...C(e)});var ke=class extends w{_parse(e){if(this._getType(e)!==r.symbol){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.symbol,received:t.parsedType}),p}return h(e.data)}};ke.create=e=>new ke({typeName:V.ZodSymbol,...C(e)});var T=class extends w{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.undefined,received:t.parsedType}),p}return h(e.data)}};T.create=e=>new T({typeName:V.ZodUndefined,...C(e)});var E=class extends w{_parse(e){if(this._getType(e)!==r.null){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.null,received:t.parsedType}),p}return h(e.data)}};E.create=e=>new E({typeName:V.ZodNull,...C(e)});var Ae=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return h(e.data)}};Ae.create=e=>new Ae({typeName:V.ZodAny,...C(e)});var D=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return h(e.data)}};D.create=e=>new D({typeName:V.ZodUnknown,...C(e)});var O=class extends w{_parse(e){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.never,received:t.parsedType}),p}};O.create=e=>new O({typeName:V.ZodNever,...C(e)});var je=class extends w{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.void,received:t.parsedType}),p}return h(e.data)}};je.create=e=>new je({typeName:V.ZodVoid,...C(e)});var k=class e extends w{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==r.array)return d(t,{code:a.invalid_type,expected:r.array,received:t.parsedType}),p;if(i.exactLength!==null){let e=t.data.length>i.exactLength.value,r=t.data.length<i.exactLength.value;(e||r)&&(d(t,{code:e?a.too_big:a.too_small,minimum:r?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(d(t,{code:a.too_small,minimum:i.minLength.value,type:`array`,inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(d(t,{code:a.too_big,maximum:i.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>i.type._parseAsync(new x(t,e,t.path,n)))).then(e=>f.mergeArray(n,e));let o=[...t.data].map((e,n)=>i.type._parseSync(new x(t,e,t.path,n)));return f.mergeArray(n,o)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:b.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:b.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};k.create=(e,t)=>new k({type:e,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...C(t)});function A(e){if(e instanceof j){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=R.create(A(r))}return new j({...e._def,shape:()=>t})}else if(e instanceof k)return new k({...e._def,type:A(e.element)});else if(e instanceof R)return R.create(A(e.unwrap()));else if(e instanceof z)return z.create(A(e.unwrap()));else if(e instanceof F)return F.create(e.items.map(e=>A(e)));else return e}var j=class e extends w{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(),n=t.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==r.object){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.object,received:t.parsedType}),p}let{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof O&&this._def.unknownKeys===`strip`))for(let e in n.data)o.includes(e)||s.push(e);let c=[];for(let e of o){let t=i[e],r=n.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new x(n,r,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof O){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)s.length>0&&(d(n,{code:a.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let r=n.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new x(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>f.mergeObjectSync(t,e)):f.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(t){return b.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:b.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:V.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(n){let r={};for(let e of t.objectKeys(n))n[e]&&this.shape[e]&&(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}omit(n){let r={};for(let e of t.objectKeys(this.shape))n[e]||(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}deepPartial(){return A(this)}partial(n){let r={};for(let e of t.objectKeys(this.shape)){let t=this.shape[e];n&&!n[e]?r[e]=t:r[e]=t.optional()}return new e({...this._def,shape:()=>r})}required(n){let r={};for(let e of t.objectKeys(this.shape))if(n&&!n[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof R;)t=t._def.innerType;r[e]=t}return new e({...this._def,shape:()=>r})}keyof(){return Be(t.objectKeys(this.shape))}};j.create=(e,t)=>new j({shape:()=>e,unknownKeys:`strip`,catchall:O.create(),typeName:V.ZodObject,...C(t)}),j.strictCreate=(e,t)=>new j({shape:()=>e,unknownKeys:`strict`,catchall:O.create(),typeName:V.ZodObject,...C(t)}),j.lazycreate=(e,t)=>new j({shape:e,unknownKeys:`strip`,catchall:O.create(),typeName:V.ZodObject,...C(t)});var M=class extends w{_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 o(e.ctx.common.issues));return d(t,{code:a.invalid_union,unionErrors:n}),p}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 o(e));return d(t,{code:a.invalid_union,unionErrors:i}),p}}get options(){return this._def.options}};M.create=(e,t)=>new M({options:e,typeName:V.ZodUnion,...C(t)});let N=e=>e instanceof Re?N(e.schema):e instanceof L?N(e.innerType()):e instanceof ze?[e.value]:e instanceof Ve?e.options:e instanceof He?t.objectValues(e.enum):e instanceof Ue?N(e._def.innerType):e instanceof T?[void 0]:e instanceof E?[null]:e instanceof R?[void 0,...N(e.unwrap())]:e instanceof z?[null,...N(e.unwrap())]:e instanceof Ke||e instanceof B?N(e.unwrap()):e instanceof We?N(e._def.innerType):[];var Me=class e extends w{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return d(t,{code:a.invalid_type,expected:r.object,received:t.parsedType}),p;let n=this.discriminator,i=t.data[n],o=this.optionsMap.get(i);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(d(t,{code:a.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),p)}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=N(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:V.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...C(r)})}};function Ne(e,n){let a=i(e),o=i(n);if(e===n)return{valid:!0,data:e};if(a===r.object&&o===r.object){let r=t.objectKeys(n),i=t.objectKeys(e).filter(e=>r.indexOf(e)!==-1),a={...e,...n};for(let t of i){let r=Ne(e[t],n[t]);if(!r.valid)return{valid:!1};a[t]=r.data}return{valid:!0,data:a}}else if(a===r.array&&o===r.array){if(e.length!==n.length)return{valid:!1};let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=n[r],o=Ne(i,a);if(!o.valid)return{valid:!1};t.push(o.data)}return{valid:!0,data:t}}else if(a===r.date&&o===r.date&&+e==+n)return{valid:!0,data:e};else return{valid:!1}}var P=class extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(g(e)||g(r))return p;let i=Ne(e.value,r.value);return i.valid?((_(e)||_(r))&&t.dirty(),{status:t.value,value:i.data}):(d(n,{code:a.invalid_intersection_types}),p)};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}))}};P.create=(e,t,n)=>new P({left:e,right:t,typeName:V.ZodIntersection,...C(n)});var F=class e extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==r.array)return d(n,{code:a.invalid_type,expected:r.array,received:n.parsedType}),p;if(n.data.length<this._def.items.length)return d(n,{code:a.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),p;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:a.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let i=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new x(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(i).then(e=>f.mergeArray(t,e)):f.mergeArray(t,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};F.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new F({items:e,typeName:V.ZodTuple,rest:null,...C(t)})};var Pe=class e extends w{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!==r.object)return d(n,{code:a.invalid_type,expected:r.object,received:n.parsedType}),p;let i=[],o=this._def.keyType,s=this._def.valueType;for(let e in n.data)i.push({key:o._parse(new x(n,e,n.path,e)),value:s._parse(new x(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?f.mergeObjectAsync(t,i):f.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof w?new e({keyType:t,valueType:n,typeName:V.ZodRecord,...C(r)}):new e({keyType:Ce.create(),valueType:t,typeName:V.ZodRecord,...C(n)})}},Fe=class extends w{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!==r.map)return d(n,{code:a.invalid_type,expected:r.map,received:n.parsedType}),p;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([e,t],r)=>({key:i._parse(new x(n,e,n.path,[r,`key`])),value:o._parse(new x(n,t,n.path,[r,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return p;(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 s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return p;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Fe.create=(e,t,n)=>new Fe({valueType:t,keyType:e,typeName:V.ZodMap,...C(n)});var Ie=class e extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==r.set)return d(n,{code:a.invalid_type,expected:r.set,received:n.parsedType}),p;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(d(n,{code:a.too_small,minimum:i.minSize.value,type:`set`,inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(d(n,{code:a.too_big,maximum:i.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let o=this._def.valueType;function s(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return p;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...n.data.values()].map((e,t)=>o._parse(new x(n,e,n.path,t)));return n.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:b.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:b.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ie.create=(e,t)=>new Ie({valueType:e,minSize:null,maxSize:null,typeName:V.ZodSet,...C(t)});var Le=class e extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.function)return d(t,{code:a.invalid_type,expected:r.function,received:t.parsedType}),p;function n(e,n){return u({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l(),s].filter(e=>!!e),issueData:{code:a.invalid_arguments,argumentsError:n}})}function i(e,n){return u({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l(),s].filter(e=>!!e),issueData:{code:a.invalid_return_type,returnTypeError:n}})}let c={errorMap:t.common.contextualErrorMap},f=t.data;if(this._def.returns instanceof I){let e=this;return h(async function(...t){let r=new o([]),a=await e._def.args.parseAsync(t,c).catch(e=>{throw r.addIssue(n(t,e)),r}),s=await Reflect.apply(f,this,a);return await e._def.returns._def.type.parseAsync(s,c).catch(e=>{throw r.addIssue(i(s,e)),r})})}else{let e=this;return h(function(...t){let r=e._def.args.safeParse(t,c);if(!r.success)throw new o([n(t,r.error)]);let a=Reflect.apply(f,this,r.data),s=e._def.returns.safeParse(a,c);if(!s.success)throw new o([i(a,s.error)]);return s.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:F.create(t).rest(D.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||F.create([]).rest(D.create()),returns:n||D.create(),typeName:V.ZodFunction,...C(r)})}},Re=class extends w{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})}};Re.create=(e,t)=>new Re({getter:e,typeName:V.ZodLazy,...C(t)});var ze=class extends w{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return d(t,{received:t.data,code:a.invalid_literal,expected:this._def.value}),p}return{status:`valid`,value:e.data}}get value(){return this._def.value}};ze.create=(e,t)=>new ze({value:e,typeName:V.ZodLiteral,...C(t)});function Be(e,t){return new Ve({values:e,typeName:V.ZodEnum,...C(t)})}var Ve=class e extends w{_parse(e){if(typeof e.data!=`string`){let n=this._getOrReturnCtx(e),r=this._def.values;return d(n,{expected:t.joinValues(r),received:n.parsedType,code:a.invalid_type}),p}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return d(t,{received:t.data,code:a.invalid_enum_value,options:n}),p}return h(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})}};Ve.create=Be;var He=class extends w{_parse(e){let n=t.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==r.string&&i.parsedType!==r.number){let e=t.objectValues(n);return d(i,{expected:t.joinValues(e),received:i.parsedType,code:a.invalid_type}),p}if(this._cache||=new Set(t.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=t.objectValues(n);return d(i,{received:i.data,code:a.invalid_enum_value,options:e}),p}return h(e.data)}get enum(){return this._def.values}};He.create=(e,t)=>new He({values:e,typeName:V.ZodNativeEnum,...C(t)});var I=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==r.promise&&t.common.async===!1?(d(t,{code:a.invalid_type,expected:r.promise,received:t.parsedType}),p):h((t.parsedType===r.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};I.create=(e,t)=>new I({type:e,typeName:V.ZodPromise,...C(t)});var L=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:e=>{d(r,e),e.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(n.value===`aborted`)return p;let t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return t.status===`aborted`?p:t.status===`dirty`||n.value===`dirty`?m(t.value):t});{if(n.value===`aborted`)return p;let t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return t.status===`aborted`?p:t.status===`dirty`||n.value===`dirty`?m(t.value):t}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.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(r.common.async===!1){let t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return t.status===`aborted`?p:(t.status===`dirty`&&n.dirty(),e(t.value),{status:n.value,value:t.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>t.status===`aborted`?p:(t.status===`dirty`&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if(i.type===`transform`)if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!v(e))return p;let t=i.transform(e.value,a);if(t instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:n.value,value:t}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>v(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):p);t.assertNever(i)}};L.create=(e,t,n)=>new L({schema:e,typeName:V.ZodEffects,effect:t,...C(n)}),L.createWithPreprocess=(e,t,n)=>new L({schema:t,effect:{type:`preprocess`,transform:e},typeName:V.ZodEffects,...C(n)});var R=class extends w{_parse(e){return this._getType(e)===r.undefined?h(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};R.create=(e,t)=>new R({innerType:e,typeName:V.ZodOptional,...C(t)});var z=class extends w{_parse(e){return this._getType(e)===r.null?h(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};z.create=(e,t)=>new z({innerType:e,typeName:V.ZodNullable,...C(t)});var Ue=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===r.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ue.create=(e,t)=>new Ue({innerType:e,typeName:V.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...C(t)});var We=class extends w{_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 y(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};We.create=(e,t)=>new We({innerType:e,typeName:V.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...C(t)});var Ge=class extends w{_parse(e){if(this._getType(e)!==r.nan){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.nan,received:t.parsedType}),p}return{status:`valid`,value:e.data}}};Ge.create=e=>new Ge({typeName:V.ZodNaN,...C(e)});var Ke=class extends w{_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}},qe=class e extends w{_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`?p:e.status===`dirty`?(t.dirty(),m(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`?p: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:V.ZodPipeline})}},B=class extends w{_parse(e){let t=this._def.innerType._parse(e),n=e=>(v(e)&&(e.value=Object.freeze(e.value)),e);return y(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};B.create=(e,t)=>new B({innerType:e,typeName:V.ZodReadonly,...C(t)}),j.lazycreate;var V;(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`})(V||={});let H=Ce.create,U=Te.create;Ge.create,Ee.create;let W=De.create;Oe.create,ke.create;let Je=T.create,Ye=E.create;Ae.create,D.create,O.create,je.create;let G=k.create,K=j.create;j.strictCreate;let q=M.create,J=Me.create;P.create,F.create;let Xe=Pe.create;Fe.create,Ie.create,Le.create,Re.create;let Y=ze.create,X=Ve.create;He.create,I.create,L.create,R.create,z.create,L.createWithPreprocess,qe.create;let Ze=X([`mp4`,`hls`,`flv`,`auto`]),Qe=X([`mp4`,`hls`,`flv`]),$e=q([H(),K({url:H(),loading:X([`eager`,`lazy`]).default(`lazy`).optional(),fit:X([`cover`,`contain`,`fill`]).default(`cover`).optional()})]),et=q([H(),K({url:H(),fit:X([`cover`,`contain`,`fill`]).optional(),closable:W().optional()})]),tt=J(`mode`,[K({mode:Y(`url`),url:H(),locale:H(),label:H(),isDefault:W().optional()}),K({mode:Y(`content`),content:H(),locale:H(),label:H(),isDefault:W().optional()})]),nt=K({lowLatencyMode:W().optional()}),rt=K({title:H().optional(),description:H().optional(),duration:U().optional()}),it=K({url:H(),type:Qe}),at={live:W().optional(),hls:nt.optional(),subtitles:G(tt).optional(),metadata:rt.optional()},ot=K({url:H(),type:Ze.optional(),...at}),st=K({sources:G(it).min(1),...at}),ct=q([H(),st,ot]),lt=q([H(),K({locale:H(),fallbackLocales:G(H()).optional(),messages:Xe(H(),Xe(H(),H())).optional()})]),ut=K({id:H(),text:H(),type:X([`scroll`,`top`,`bottom`]).optional(),color:H().optional(),start:U().nonnegative().optional()}),dt=K({enabled:W(),mode:X([`preload`,`streaming`]).optional(),items:G(ut).optional(),display:K({area:X([`top`,`half`,`full`]).optional(),opacity:U().min(0).max(1).optional(),speed:U().min(.5).max(2).optional(),fontSize:U().min(12).max(48).optional(),maxLines:U().int().positive().optional()}).optional()}).superRefine((e,t)=>{e.items&&e.items.length>0&&e.mode!==`preload`&&t.addIssue({code:`custom`,path:[`items`],message:`danmaku.items 只在 mode: 'preload' 下有效。当前 mode 是 ${e.mode??`streaming`}(默认)—— 渲染引擎在直播模式下会忽略每条的 start,整包会一股脑全飘出来。要么设 mode: "preload",要么改用 pushDanmaku 逐条推。`}),e.display?.maxLines!==void 0&&e.display.area&&e.display.area!==`full`&&t.addIssue({code:`custom`,path:[`display`,`maxLines`],message:`danmaku.display.maxLines 与 area: '${e.display.area}' 不能同时用 —— 渲染引擎里两者互斥(给了轨道条数,区域比例就失效),同传只会有一个生效。要限制条数就去掉 area(或用 area: 'full'),要限制区域就去掉 maxLines。`})}),ft=X([`homepage-preview`]),pt=K({play:W().optional(),progress:W().optional(),time:W().optional(),volume:W().optional(),playbackRate:W().optional(),fullscreen:W().optional(),cssFullscreen:W().optional(),pip:W().optional()}).strict();K({source:ct,preset:ft.optional(),autoplay:W().optional(),muted:W().optional(),loop:W().optional(),playbackRate:U().min(.25).max(4).optional(),volume:U().min(0).max(1).optional(),playsinline:W().optional(),preload:X([`none`,`metadata`,`auto`]).optional(),startTime:U().min(0).optional(),controls:W().optional(),showErrorOverlay:W().optional(),showLoadingOverlay:W().optional(),controlVisibility:pt.optional(),interactive:W().optional(),poster:$e.optional(),pauseImage:et.optional(),locale:lt.optional(),danmaku:dt.optional(),debug:W().optional()});let mt=X([`manifest`,`media`,`network`,`auth`,`env`,`autoplay`]),ht=X([`E_MANIFEST_PARSE`,`E_MEDIA_DECODE`,`E_MEDIA_ABORTED`,`E_MEDIA_NOT_SUPPORTED`,`E_SUBTITLE_LOAD_FAILED`,`E_AUTOPLAY_BLOCKED`,`E_NETWORK`,`E_NETWORK_TIMEOUT`,`E_AUTH_EXPIRED`,`E_ENV_CSP_BLOCKED`,`E_METHOD_NOT_SUPPORTED`,`E_DANMAKU_SEND_FAILED`,`E_INTERNAL`,`E_UNKNOWN`,`E_PLAYER_DESTROYED`,`E_HANDSHAKE_TIMEOUT`,`E_HANDSHAKE_VERSION_MISMATCH`,`E_LOAD_FAILED`,`E_FRAME_CRASHED`]),gt=X([`W_BROWSER_INCOMPATIBLE`,`W_VERSION_MISMATCH`,`W_EVENT_REJECTED`]),_t=K({name:H(),message:H(),code:U().optional(),status:U().optional()}).catchall(q([H(),U(),W()])),vt=K({code:ht,message:H(),retryable:W(),category:mt,cause:_t.optional()}),yt=K({fvt:U()}),bt=K({durationMs:U(),droppedFrames:U(),totalFrames:U()}),xt=[`switch_play_pause`,`switch_fullscreen`,`switch_cssfullscreen`,`switch_css_fullscreen`,`change_definition`,`change_rate`,`change_volume`,`change_muted`,`change_pip`,`seek`,`rotate`,`shot`,`download`,`switch_danmu`,`error_retry`],St=K({action:X(xt),source:H(),from:q([H(),U(),W()]).nullable(),to:q([H(),U(),W()]).nullable()});new Set(xt);let Z={channel:Y(`video-lab:page-fullscreen`),version:Y(1),session:H().min(1)},Ct=J(`type`,[K({...Z,type:Y(`hello`)}),K({...Z,type:Y(`ready`),instance:H().min(1)}),K({...Z,type:Y(`request`),instance:H().min(1),id:U().int().positive(),active:W()}),K({...Z,type:Y(`state`),instance:H().min(1),revision:U().int().nonnegative(),active:W()}),K({...Z,type:Y(`ack`),instance:H().min(1),revision:U().int().nonnegative()}),K({...Z,type:Y(`disconnect`)})]);K({available:W(),active:W()});let wt=K({active:W()}),Tt=X([`native`,`hls.js`,`flv.js`]),Et=X([`live`,`vod`]),Dt=K({platform:X([`ios`,`android`,`desktop`,`unknown`]),browser:X([`webkit`,`gecko`,`chromium`,`embedded`,`unknown`]),mse:X([`standard`,`managed`,`unavailable`])}),Ot=K({sessionId:H(),candidateTypes:G(Qe).min(1),streamKind:Et,runtime:Dt}),kt=J(`outcome`,[Ot.extend({outcome:Y(`selected`),mediaType:Qe,kernel:Tt,reason:X([`required_hls`,`live_preference`,`vod_preference`,`native_mp4_fallback`])}).strict(),Ot.extend({outcome:Y(`unsupported`),mediaType:Ye(),kernel:Ye(),reason:Y(`no_supported_candidate`),errorCode:Y(`E_MEDIA_NOT_SUPPORTED`)}).strict()]),At=K({sessionId:H(),kernel:Tt,mediaType:Qe.optional(),streamKind:Et.optional(),runtime:Dt.optional(),position:U(),qualityLevel:U().nullable(),srcOrigin:H(),srcPath:H()});X([`detected`,`backoff`,`attempting`,`validating`,`recovered`,`failed`,`cancelled`]);let jt=X([`reconnect`,`media_recovery`,`visibility_reload`]),Mt=X([`error`,`manual`,`visibility`,`stall`,`startup_timeout`]),Q={sessionId:H().min(1),recoveryId:U().int().positive(),strategy:jt,trigger:Mt,attempt:U().int().nonnegative(),maxAttempts:U().int().positive(),elapsedMs:U().finite().nonnegative(),reason:ht.optional()},Nt={...Q,attempt:U().int().positive()},Pt=J(`phase`,[K({...Q,phase:Y(`detected`)}).strict(),K({...Q,phase:Y(`backoff`)}).strict(),K({...Nt,phase:Y(`attempting`)}).strict(),K({...Nt,phase:Y(`validating`)}).strict(),K({...Nt,phase:Y(`recovered`),validatedBy:Y(`playing_position_advance`)}).strict(),K({...Q,phase:Y(`failed`),outcome:X([`timeout`,`attempts_exhausted`])}).strict(),K({...Q,phase:Y(`cancelled`),outcome:X([`source_changed`,`destroyed`,`superseded`,`user_paused`,`natural_recovery`])}).strict()]).refine(e=>e.attempt<=e.maxAttempts,{message:`attempt exceeds episode budget`,path:[`attempt`]}),Ft=K({level:U(),label:H().optional(),height:U().optional(),bitrate:U().optional()}),It=K({id:U(),locale:H(),label:H()}),Lt=X([`ok`,`initializing`,`buffering`,`stalled`,`reconnecting`,`autoplay_blocked`,`error`,`frame_disconnected`,`degraded`]),Rt=J(`event`,[K({event:Y(`pagefullscreenchange`),payload:wt}),K({event:Y(`sourceroute`),payload:kt}),K({event:Y(`ready`),payload:K({duration:U(),quality:G(Ft),subtitles:G(It).optional()})}),K({event:Y(`play`),payload:K({})}),K({event:Y(`pause`),payload:K({})}),K({event:Y(`ended`),payload:K({})}),K({event:Y(`timeupdate`),payload:K({time:U(),duration:U()})}),K({event:Y(`volumechange`),payload:K({volume:U(),muted:W()})}),K({event:Y(`seeking`),payload:K({time:U()})}),K({event:Y(`seeked`),payload:K({time:U()})}),K({event:Y(`waiting`),payload:K({})}),K({event:Y(`playing`),payload:K({})}),K({event:Y(`qualitychange`),payload:K({level:U(),auto:W()})}),K({event:Y(`subtitlechange`),payload:K({id:U().nullable()})}),K({event:Y(`error`),payload:vt}),K({event:Y(`autoplayblocked`),payload:K({})}),K({event:Y(`recovery`),payload:Pt}),K({event:Y(`compatwarning`),payload:K({code:gt,message:H(),ua:H(),hostVersion:H().optional(),iframeVersion:H().optional(),rejectedEvent:H().optional()})}),K({event:Y(`stalled`),payload:K({phase:X([`start`,`end`]),position:U(),durationMs:U().optional(),kind:X([`playback`,`firstframe`,`seek`]).optional()})}),K({event:Y(`playablechange`),payload:K({playable:W(),reason:Lt,recoverable:W(),action:X([`retry`,`play`,`replace-source`,`recreate-frame`,`none`]).optional()})}),K({event:Y(`kernelhealth`),payload:K({degraded:W(),reason:X([`network`,`media`,`other`]),count:U(),durationMs:U(),detail:H()})}),K({event:Y(`audiohealth`),payload:K({degraded:W(),reason:Y(`audio_data_gap`),durationMs:U()})}),K({event:Y(`bufferhealth`),payload:K({draining:W(),marginSec:U()})}),K({event:Y(`contextchange`),payload:At}),K({event:Y(`firstframe`),payload:yt}),K({event:Y(`framefreeze`),payload:bt}),K({event:Y(`useraction`),payload:St})]);function zt(e,t){return{event:`compatwarning`,payload:{code:`W_EVENT_REJECTED`,message:`收到一条过不了契约校验的事件(${e??`(未知)`}),已丢弃。最常见的成因是 iframe 比宿主新 —— 先看两端契约版本差多少,再怀疑 iframe 有 bug。`,ua:t,...e===void 0?{}:{rejectedEvent:e}}}}K({event:Rt,producerSessionId:H().min(1),deliveryId:H().min(1),occurredAtMs:U().finite(),sequence:U().int().positive()});let Bt=J(`method`,[K({method:Y(`play`),params:K({}).optional()}),K({method:Y(`pause`),params:K({}).optional()}),K({method:Y(`seek`),params:K({time:U(),type:X([`exact`,`keyframe`]).optional()})}),K({method:Y(`setVolume`),params:K({volume:U().min(0).max(1)})}),K({method:Y(`setMuted`),params:K({muted:W()})}),K({method:Y(`setPlaybackRate`),params:K({rate:U().min(.25).max(4)})}),K({method:Y(`setQuality`),params:K({level:q([U(),Y(`auto`)])})}),K({method:Y(`setSubtitle`),params:K({id:q([U(),Y(`off`)])})}),K({method:Y(`setLocale`),params:K({locale:lt})}),K({method:Y(`load`),params:K({source:ct})}),K({method:Y(`retry`),params:K({}).strict().optional()}),K({method:Y(`pushDanmaku`),params:K({item:ut})}),K({method:Y(`setDanmakuEnabled`),params:K({enabled:W()})}),K({method:Y(`clearDanmaku`),params:K({}).optional()}),K({method:Y(`destroy`),params:K({}).optional()}),K({method:Y(`enterFullscreen`),params:K({}).optional()}),K({method:Y(`exitFullscreen`),params:K({}).optional()})]);X([`command`,`event`,`response`,`error`]);let Vt={version:H(),id:H(),timestamp:U()};function $(e,t){return K({...Vt,type:Y(e),payload:t})}let Ht=q([$(`command`,Bt),q([$(`event`,Rt).extend({producerSessionId:Je().optional(),sequence:Je().optional()}),$(`event`,Rt).extend({producerSessionId:H().min(1),sequence:U().int().positive()})]),$(`response`,K({})),$(`error`,vt)]);function Ut(e){return e||(typeof window<`u`?window:null)}function Wt(e={}){let t=Ut(e.target),n=e.iframe,r=e.origin==null?null:new Set(Array.isArray(e.origin)?e.origin:[e.origin]),i=new Set;function a(e){let t=e;if(typeof t!=`object`||!t||t.type!==`event`)return;let n=t.payload?.event,r=typeof n==`string`?n:`(未知)`;i.has(r)||(i.add(r),o(zt(typeof n==`string`?n:void 0,typeof navigator>`u`?``:navigator.userAgent)))}function o(e){let{event:t,payload:n}=e;for(let e of c)try{e({event:t,payload:n})}catch{}let r=s.get(t);if(r)for(let e of r)try{e(n)}catch(e){console.warn(`[SentinelEmbed] 事件处理器抛错:`,e)}}let s=new Map,c=new Set,l=new Set,u=e=>{let t=e;if(r&&!r.has(t.origin)||n&&t.source!==n.contentWindow)return;let i=Ht.safeParse(t.data);if(!i.success){a(t.data);return}if(i.data.type===`event`&&(o(i.data.payload),i.data.producerSessionId!==void 0&&i.data.sequence!==void 0)){let e={event:i.data.payload,producerSessionId:i.data.producerSessionId,deliveryId:i.data.id,occurredAtMs:i.data.timestamp,sequence:i.data.sequence};for(let t of l)try{t(e)}catch{}}};t?.addEventListener(`message`,u);let d=(e,t)=>{s.get(e)?.delete(t)};return{on:(e,t)=>{let n=s.get(e);return n||(n=new Set,s.set(e,n)),n.add(t),()=>d(e,t)},onAny:e=>(c.add(e),()=>c.delete(e)),onDelivered:e=>(l.add(e),()=>l.delete(e)),off:d,destroy:()=>{t?.removeEventListener(`message`,u),s.clear(),c.clear(),l.clear()}}}function Gt(e){if(new URL(e.origin).origin!==e.origin||e.origin===`null`)throw Error(`网页全屏要求精确 origin`);let{iframe:t,origin:n,adapter:r}=e,i=t.ownerDocument.defaultView;if(!i)throw Error(`iframe 尚无宿主窗口`);let a=crypto.randomUUID(),o=``,s=0,c=!1,l=!1,u=Date.now(),d=0,f=Promise.resolve(),p;function m(e){let r=t.contentWindow;if(r){try{if(r.location.href===`about:blank`)return}catch(e){if(!(e instanceof DOMException)||e.name!==`SecurityError`)throw e}r.postMessage(e,n)}}function h(){o&&m({channel:`video-lab:page-fullscreen`,version:1,type:`state`,session:a,instance:o,revision:s,active:c})}function g(){m({channel:`video-lab:page-fullscreen`,version:1,type:`hello`,session:a}),p&&h()}function _(e){if(!p)return;let t=p;p=void 0,clearTimeout(t.timer),e?t.reject(e):t.resolve()}function v(){l||(l=!0,clearInterval(C),i?.removeEventListener(`message`,b),i?.removeEventListener(`keydown`,x),t.removeEventListener(`load`,S),m({channel:`video-lab:page-fullscreen`,version:1,type:`disconnect`,session:a}),_(Error(`网页全屏连接已销毁`)),c=!1,r.dispose())}function y(t){let n=a,i=f.then(async()=>{if(l||!o||n!==a)throw Error(`iframe 尚未确认网页全屏支持`);let i=o,u,d=Promise.resolve().then(()=>r.setActive(t)).then(()=>{if(l||n!==a||o!==i)throw r.dispose(),Error(`网页全屏请求已失效`)});try{await Promise.race([d,new Promise((e,t)=>{u=setTimeout(()=>{v(),t(Error(`宿主布局超时`))},1e4)})]),c=t,s+=1,await new Promise((e,t)=>{p={revision:s,resolve:e,reject:t,timer:setTimeout(()=>{v()},1e4)},h()}),e.onChange?.({active:c})}catch(e){throw c=!1,r.dispose(),l||(s+=1,h()),e}finally{clearTimeout(u)}});return f=i.catch(()=>{}),i}function b(e){if(l||e.source!==t.contentWindow||e.origin!==n)return;let i=Ct.safeParse(e.data);if(!i.success||i.data.session!==a)return;let f=i.data;if(f.type===`ready`){if(o&&o!==f.instance)return;u=Date.now(),o!==f.instance&&(_(Error(`iframe 已重新加载`)),c&&r.dispose(),c=!1,o=f.instance,s=0,d=0,h())}else if(f.type===`ack`&&f.instance===o&&f.revision===p?.revision)_();else if(f.type===`request`&&f.instance===o){if(f.id<=d){h();return}d=f.id,y(f.active).catch(()=>{})}}function x(e){e.key===`Escape`&&c&&y(!1).catch(()=>{})}function S(){a=crypto.randomUUID(),_(Error(`iframe 已重新加载`)),o=``,c=!1,r.dispose(),g()}i.addEventListener(`message`,b),i.addEventListener(`keydown`,x),t.addEventListener(`load`,S);let C=setInterval(()=>{o&&Date.now()-u>5e3?v():g()},1e3);return g(),{setPageFullscreen:y,destroy:v}}let Kt=null;function qt(){return Kt||=Wt(),Kt}function Jt(e,t){return qt().on(e,t)}function Yt(e){return qt().onAny(e)}function Xt(e){return qt().onDelivered(e)}function Zt(e,t){qt().off(e,t)}function Qt(){Kt?.destroy(),Kt=null}return e.createEmbedListener=Wt,e.createPageFullscreenController=Gt,e.destroy=Qt,e.off=Zt,e.on=Jt,e.onAny=Yt,e.onDelivered=Xt,e})({});
|
|
1
|
+
var SentinelEmbed=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t;(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})(t||={});var n;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(n||={});let r=t.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),i=e=>{switch(typeof e){case`undefined`:return r.undefined;case`string`:return r.string;case`number`:return Number.isNaN(e)?r.nan:r.number;case`boolean`:return r.boolean;case`function`:return r.function;case`bigint`:return r.bigint;case`symbol`:return r.symbol;case`object`:return Array.isArray(e)?r.array:e===null?r.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?r.promise:typeof Map<`u`&&e instanceof Map?r.map:typeof Set<`u`&&e instanceof Set?r.set:typeof Date<`u`&&e instanceof Date?r.date:r.object;default:return r.unknown}},a=t.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 o=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,t.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()}};o.create=e=>new o(e);let s=(e,n)=>{let i;switch(e.code){case a.invalid_type:i=e.received===r.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case a.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(e.expected,t.jsonStringifyReplacer)}`;break;case a.unrecognized_keys:i=`Unrecognized key(s) in object: ${t.joinValues(e.keys,`, `)}`;break;case a.invalid_union:i=`Invalid input`;break;case a.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${t.joinValues(e.options)}`;break;case a.invalid_enum_value:i=`Invalid enum value. Expected ${t.joinValues(e.options)}, received '${e.received}'`;break;case a.invalid_arguments:i=`Invalid function arguments`;break;case a.invalid_return_type:i=`Invalid function return type`;break;case a.invalid_date:i=`Invalid date`;break;case a.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(i=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(i=`${i} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?i=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?i=`Invalid input: must end with "${e.validation.endsWith}"`:t.assertNever(e.validation):i=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case a.too_small:i=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 a.too_big:i=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 a.custom:i=`Invalid input`;break;case a.invalid_intersection_types:i=`Intersection results could not be merged`;break;case a.not_multiple_of:i=`Number must be a multiple of ${e.multipleOf}`;break;case a.not_finite:i=`Number must be finite`;break;default:i=n.defaultError,t.assertNever(e)}return{message:i}},c=s;function l(){return c}let u=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 d(e,t){let n=l(),r=u({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===s?void 0:s].filter(e=>!!e)});e.common.issues.push(r)}var f=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 p;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 p;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}}};let p=Object.freeze({status:`aborted`}),m=e=>({status:`dirty`,value:e}),h=e=>({status:`valid`,value:e}),g=e=>e.status===`aborted`,_=e=>e.status===`dirty`,v=e=>e.status===`valid`,y=e=>typeof Promise<`u`&&e instanceof Promise;var b;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(b||={});var x=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}};let S=(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(){if(this._error)return this._error;let t=new o(e.common.issues);return this._error=t,this._error}}};function C(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 w=class{get description(){return this._def.description}_getType(e){return i(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new f,ctx:{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(y(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:i(e)},r=this._parseSync({data:e,path:n.path,parent:n});return S(n,r)}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(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:i(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(y(r)?r:Promise.resolve(r));return S(n,a)}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),o=()=>r.addIssue({code:a.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(o(),!1)):i?!0:(o(),!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 L({schema:this,typeName:V.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 R.create(this,this._def)}nullable(){return z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return k.create(this)}promise(){return I.create(this,this._def)}or(e){return M.create([this,e],this._def)}and(e){return P.create(this,e,this._def)}transform(e){return new L({...C(this._def),schema:this,typeName:V.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Ue({...C(this._def),innerType:this,defaultValue:t,typeName:V.ZodDefault})}brand(){return new Ke({typeName:V.ZodBranded,type:this,...C(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new We({...C(this._def),innerType:this,catchValue:t,typeName:V.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return qe.create(this,e)}readonly(){return B.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let ee=/^c[^\s-]{8,}$/i,te=/^[0-9a-z]+$/,ne=/^[0-9A-HJKMNP-TV-Z]{26}$/i,re=/^[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,ie=/^[a-z0-9_-]{21}$/i,ae=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,oe=/^[-+]?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)?)??$/,se=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ce,le=/^(?:(?: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])$/,ue=/^(?:(?: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])$/,de=/^(([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]))$/,fe=/^(([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])$/,pe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,me=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,he=`((\\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])))`,ge=RegExp(`^${he}$`);function _e(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 ve(e){return RegExp(`^${_e(e)}$`)}function ye(e){let t=`${he}T${_e(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function be(e,t){return!!((t===`v4`||!t)&&le.test(e)||(t===`v6`||!t)&&de.test(e))}function xe(e,t){if(!ae.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 Se(e,t){return!!((t===`v4`||!t)&&ue.test(e)||(t===`v6`||!t)&&fe.test(e))}var Ce=class e extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==r.string){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.string,received:t.parsedType}),p}let n=new f,i;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind===`max`)e.data.length>r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind===`length`){let t=e.data.length>r.value,o=e.data.length<r.value;(t||o)&&(i=this._getOrReturnCtx(e,i),t?d(i,{code:a.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):o&&d(i,{code:a.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind===`email`)se.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`email`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`emoji`)ce||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),ce.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`emoji`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`uuid`)re.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`uuid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`nanoid`)ie.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`nanoid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`cuid`)ee.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cuid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`cuid2`)te.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cuid2`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`ulid`)ne.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`ulid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),d(i,{validation:`url`,code:a.invalid_string,message:r.message}),n.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`regex`,code:a.invalid_string,message:r.message}),n.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.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)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind===`datetime`?ye(r).test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`datetime`,message:r.message}),n.dirty()):r.kind===`date`?ge.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`date`,message:r.message}),n.dirty()):r.kind===`time`?ve(r).test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`time`,message:r.message}),n.dirty()):r.kind===`duration`?oe.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`duration`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`ip`?be(e.data,r.version)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`ip`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`jwt`?xe(e.data,r.alg)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`jwt`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`cidr`?Se(e.data,r.version)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cidr`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`base64`?pe.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`base64`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`base64url`?me.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`base64url`,code:a.invalid_string,message:r.message}),n.dirty()):t.assertNever(r);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:a.invalid_string,...b.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...b.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...b.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...b.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...b.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...b.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...b.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...b.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...b.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...b.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...b.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...b.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,...b.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,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...b.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...b.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...b.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...b.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...b.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...b.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...b.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...b.errToObj(t)})}nonempty(e){return this.min(1,b.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}};Ce.create=e=>new Ce({checks:[],typeName:V.ZodString,coerce:e?.coerce??!1,...C(e)});function we(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Te=class e extends w{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)!==r.number){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.number,received:t.parsedType}),p}let n,i=new f;for(let r of this._def.checks)r.kind===`int`?t.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:a.invalid_type,expected:`integer`,received:`float`,message:r.message}),i.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind===`multipleOf`?we(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_finite,message:r.message}),i.dirty()):t.assertNever(r);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,b.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,b.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,b.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,b.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:b.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:b.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:b.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:b.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:b.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:b.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`&&t.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)}};Te.create=e=>new Te({checks:[],typeName:V.ZodNumber,coerce:e?.coerce||!1,...C(e)});var Ee=class e extends w{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)!==r.bigint)return this._getInvalidInput(e);let n,i=new f;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):t.assertNever(r);return{status:i.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.bigint,received:t.parsedType}),p}gte(e,t){return this.setLimit(`min`,e,!0,b.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,b.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,b.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,b.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:b.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:b.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:b.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}};Ee.create=e=>new Ee({checks:[],typeName:V.ZodBigInt,coerce:e?.coerce??!1,...C(e)});var De=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==r.boolean){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.boolean,received:t.parsedType}),p}return h(e.data)}};De.create=e=>new De({typeName:V.ZodBoolean,coerce:e?.coerce||!1,...C(e)});var Oe=class e extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==r.date){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.date,received:t.parsedType}),p}if(Number.isNaN(e.data.getTime()))return d(this._getOrReturnCtx(e),{code:a.invalid_date}),p;let n=new f,i;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),n.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),n.dirty()):t.assertNever(r);return{status:n.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:b.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:b.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)}};Oe.create=e=>new Oe({checks:[],coerce:e?.coerce||!1,typeName:V.ZodDate,...C(e)});var ke=class extends w{_parse(e){if(this._getType(e)!==r.symbol){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.symbol,received:t.parsedType}),p}return h(e.data)}};ke.create=e=>new ke({typeName:V.ZodSymbol,...C(e)});var T=class extends w{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.undefined,received:t.parsedType}),p}return h(e.data)}};T.create=e=>new T({typeName:V.ZodUndefined,...C(e)});var E=class extends w{_parse(e){if(this._getType(e)!==r.null){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.null,received:t.parsedType}),p}return h(e.data)}};E.create=e=>new E({typeName:V.ZodNull,...C(e)});var Ae=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return h(e.data)}};Ae.create=e=>new Ae({typeName:V.ZodAny,...C(e)});var D=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return h(e.data)}};D.create=e=>new D({typeName:V.ZodUnknown,...C(e)});var O=class extends w{_parse(e){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.never,received:t.parsedType}),p}};O.create=e=>new O({typeName:V.ZodNever,...C(e)});var je=class extends w{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.void,received:t.parsedType}),p}return h(e.data)}};je.create=e=>new je({typeName:V.ZodVoid,...C(e)});var k=class e extends w{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==r.array)return d(t,{code:a.invalid_type,expected:r.array,received:t.parsedType}),p;if(i.exactLength!==null){let e=t.data.length>i.exactLength.value,r=t.data.length<i.exactLength.value;(e||r)&&(d(t,{code:e?a.too_big:a.too_small,minimum:r?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(d(t,{code:a.too_small,minimum:i.minLength.value,type:`array`,inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(d(t,{code:a.too_big,maximum:i.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>i.type._parseAsync(new x(t,e,t.path,n)))).then(e=>f.mergeArray(n,e));let o=[...t.data].map((e,n)=>i.type._parseSync(new x(t,e,t.path,n)));return f.mergeArray(n,o)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:b.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:b.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};k.create=(e,t)=>new k({type:e,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...C(t)});function A(e){if(e instanceof j){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=R.create(A(r))}return new j({...e._def,shape:()=>t})}else if(e instanceof k)return new k({...e._def,type:A(e.element)});else if(e instanceof R)return R.create(A(e.unwrap()));else if(e instanceof z)return z.create(A(e.unwrap()));else if(e instanceof F)return F.create(e.items.map(e=>A(e)));else return e}var j=class e extends w{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(),n=t.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==r.object){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.object,received:t.parsedType}),p}let{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof O&&this._def.unknownKeys===`strip`))for(let e in n.data)o.includes(e)||s.push(e);let c=[];for(let e of o){let t=i[e],r=n.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new x(n,r,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof O){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)s.length>0&&(d(n,{code:a.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let r=n.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new x(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>f.mergeObjectSync(t,e)):f.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(t){return b.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:b.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:V.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(n){let r={};for(let e of t.objectKeys(n))n[e]&&this.shape[e]&&(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}omit(n){let r={};for(let e of t.objectKeys(this.shape))n[e]||(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}deepPartial(){return A(this)}partial(n){let r={};for(let e of t.objectKeys(this.shape)){let t=this.shape[e];n&&!n[e]?r[e]=t:r[e]=t.optional()}return new e({...this._def,shape:()=>r})}required(n){let r={};for(let e of t.objectKeys(this.shape))if(n&&!n[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof R;)t=t._def.innerType;r[e]=t}return new e({...this._def,shape:()=>r})}keyof(){return Be(t.objectKeys(this.shape))}};j.create=(e,t)=>new j({shape:()=>e,unknownKeys:`strip`,catchall:O.create(),typeName:V.ZodObject,...C(t)}),j.strictCreate=(e,t)=>new j({shape:()=>e,unknownKeys:`strict`,catchall:O.create(),typeName:V.ZodObject,...C(t)}),j.lazycreate=(e,t)=>new j({shape:e,unknownKeys:`strip`,catchall:O.create(),typeName:V.ZodObject,...C(t)});var M=class extends w{_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 o(e.ctx.common.issues));return d(t,{code:a.invalid_union,unionErrors:n}),p}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 o(e));return d(t,{code:a.invalid_union,unionErrors:i}),p}}get options(){return this._def.options}};M.create=(e,t)=>new M({options:e,typeName:V.ZodUnion,...C(t)});let N=e=>e instanceof Re?N(e.schema):e instanceof L?N(e.innerType()):e instanceof ze?[e.value]:e instanceof Ve?e.options:e instanceof He?t.objectValues(e.enum):e instanceof Ue?N(e._def.innerType):e instanceof T?[void 0]:e instanceof E?[null]:e instanceof R?[void 0,...N(e.unwrap())]:e instanceof z?[null,...N(e.unwrap())]:e instanceof Ke||e instanceof B?N(e.unwrap()):e instanceof We?N(e._def.innerType):[];var Me=class e extends w{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return d(t,{code:a.invalid_type,expected:r.object,received:t.parsedType}),p;let n=this.discriminator,i=t.data[n],o=this.optionsMap.get(i);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(d(t,{code:a.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),p)}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=N(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:V.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...C(r)})}};function Ne(e,n){let a=i(e),o=i(n);if(e===n)return{valid:!0,data:e};if(a===r.object&&o===r.object){let r=t.objectKeys(n),i=t.objectKeys(e).filter(e=>r.indexOf(e)!==-1),a={...e,...n};for(let t of i){let r=Ne(e[t],n[t]);if(!r.valid)return{valid:!1};a[t]=r.data}return{valid:!0,data:a}}else if(a===r.array&&o===r.array){if(e.length!==n.length)return{valid:!1};let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=n[r],o=Ne(i,a);if(!o.valid)return{valid:!1};t.push(o.data)}return{valid:!0,data:t}}else if(a===r.date&&o===r.date&&+e==+n)return{valid:!0,data:e};else return{valid:!1}}var P=class extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(g(e)||g(r))return p;let i=Ne(e.value,r.value);return i.valid?((_(e)||_(r))&&t.dirty(),{status:t.value,value:i.data}):(d(n,{code:a.invalid_intersection_types}),p)};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}))}};P.create=(e,t,n)=>new P({left:e,right:t,typeName:V.ZodIntersection,...C(n)});var F=class e extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==r.array)return d(n,{code:a.invalid_type,expected:r.array,received:n.parsedType}),p;if(n.data.length<this._def.items.length)return d(n,{code:a.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),p;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:a.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let i=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new x(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(i).then(e=>f.mergeArray(t,e)):f.mergeArray(t,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};F.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new F({items:e,typeName:V.ZodTuple,rest:null,...C(t)})};var Pe=class e extends w{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!==r.object)return d(n,{code:a.invalid_type,expected:r.object,received:n.parsedType}),p;let i=[],o=this._def.keyType,s=this._def.valueType;for(let e in n.data)i.push({key:o._parse(new x(n,e,n.path,e)),value:s._parse(new x(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?f.mergeObjectAsync(t,i):f.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof w?new e({keyType:t,valueType:n,typeName:V.ZodRecord,...C(r)}):new e({keyType:Ce.create(),valueType:t,typeName:V.ZodRecord,...C(n)})}},Fe=class extends w{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!==r.map)return d(n,{code:a.invalid_type,expected:r.map,received:n.parsedType}),p;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([e,t],r)=>({key:i._parse(new x(n,e,n.path,[r,`key`])),value:o._parse(new x(n,t,n.path,[r,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return p;(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 s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return p;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Fe.create=(e,t,n)=>new Fe({valueType:t,keyType:e,typeName:V.ZodMap,...C(n)});var Ie=class e extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==r.set)return d(n,{code:a.invalid_type,expected:r.set,received:n.parsedType}),p;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(d(n,{code:a.too_small,minimum:i.minSize.value,type:`set`,inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(d(n,{code:a.too_big,maximum:i.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let o=this._def.valueType;function s(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return p;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...n.data.values()].map((e,t)=>o._parse(new x(n,e,n.path,t)));return n.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:b.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:b.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ie.create=(e,t)=>new Ie({valueType:e,minSize:null,maxSize:null,typeName:V.ZodSet,...C(t)});var Le=class e extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.function)return d(t,{code:a.invalid_type,expected:r.function,received:t.parsedType}),p;function n(e,n){return u({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l(),s].filter(e=>!!e),issueData:{code:a.invalid_arguments,argumentsError:n}})}function i(e,n){return u({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l(),s].filter(e=>!!e),issueData:{code:a.invalid_return_type,returnTypeError:n}})}let c={errorMap:t.common.contextualErrorMap},f=t.data;if(this._def.returns instanceof I){let e=this;return h(async function(...t){let r=new o([]),a=await e._def.args.parseAsync(t,c).catch(e=>{throw r.addIssue(n(t,e)),r}),s=await Reflect.apply(f,this,a);return await e._def.returns._def.type.parseAsync(s,c).catch(e=>{throw r.addIssue(i(s,e)),r})})}else{let e=this;return h(function(...t){let r=e._def.args.safeParse(t,c);if(!r.success)throw new o([n(t,r.error)]);let a=Reflect.apply(f,this,r.data),s=e._def.returns.safeParse(a,c);if(!s.success)throw new o([i(a,s.error)]);return s.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:F.create(t).rest(D.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||F.create([]).rest(D.create()),returns:n||D.create(),typeName:V.ZodFunction,...C(r)})}},Re=class extends w{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})}};Re.create=(e,t)=>new Re({getter:e,typeName:V.ZodLazy,...C(t)});var ze=class extends w{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return d(t,{received:t.data,code:a.invalid_literal,expected:this._def.value}),p}return{status:`valid`,value:e.data}}get value(){return this._def.value}};ze.create=(e,t)=>new ze({value:e,typeName:V.ZodLiteral,...C(t)});function Be(e,t){return new Ve({values:e,typeName:V.ZodEnum,...C(t)})}var Ve=class e extends w{_parse(e){if(typeof e.data!=`string`){let n=this._getOrReturnCtx(e),r=this._def.values;return d(n,{expected:t.joinValues(r),received:n.parsedType,code:a.invalid_type}),p}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return d(t,{received:t.data,code:a.invalid_enum_value,options:n}),p}return h(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})}};Ve.create=Be;var He=class extends w{_parse(e){let n=t.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==r.string&&i.parsedType!==r.number){let e=t.objectValues(n);return d(i,{expected:t.joinValues(e),received:i.parsedType,code:a.invalid_type}),p}if(this._cache||=new Set(t.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=t.objectValues(n);return d(i,{received:i.data,code:a.invalid_enum_value,options:e}),p}return h(e.data)}get enum(){return this._def.values}};He.create=(e,t)=>new He({values:e,typeName:V.ZodNativeEnum,...C(t)});var I=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==r.promise&&t.common.async===!1?(d(t,{code:a.invalid_type,expected:r.promise,received:t.parsedType}),p):h((t.parsedType===r.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};I.create=(e,t)=>new I({type:e,typeName:V.ZodPromise,...C(t)});var L=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:e=>{d(r,e),e.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(n.value===`aborted`)return p;let t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return t.status===`aborted`?p:t.status===`dirty`||n.value===`dirty`?m(t.value):t});{if(n.value===`aborted`)return p;let t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return t.status===`aborted`?p:t.status===`dirty`||n.value===`dirty`?m(t.value):t}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.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(r.common.async===!1){let t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return t.status===`aborted`?p:(t.status===`dirty`&&n.dirty(),e(t.value),{status:n.value,value:t.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>t.status===`aborted`?p:(t.status===`dirty`&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if(i.type===`transform`)if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!v(e))return p;let t=i.transform(e.value,a);if(t instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:n.value,value:t}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>v(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):p);t.assertNever(i)}};L.create=(e,t,n)=>new L({schema:e,typeName:V.ZodEffects,effect:t,...C(n)}),L.createWithPreprocess=(e,t,n)=>new L({schema:t,effect:{type:`preprocess`,transform:e},typeName:V.ZodEffects,...C(n)});var R=class extends w{_parse(e){return this._getType(e)===r.undefined?h(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};R.create=(e,t)=>new R({innerType:e,typeName:V.ZodOptional,...C(t)});var z=class extends w{_parse(e){return this._getType(e)===r.null?h(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};z.create=(e,t)=>new z({innerType:e,typeName:V.ZodNullable,...C(t)});var Ue=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===r.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ue.create=(e,t)=>new Ue({innerType:e,typeName:V.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...C(t)});var We=class extends w{_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 y(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};We.create=(e,t)=>new We({innerType:e,typeName:V.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...C(t)});var Ge=class extends w{_parse(e){if(this._getType(e)!==r.nan){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.nan,received:t.parsedType}),p}return{status:`valid`,value:e.data}}};Ge.create=e=>new Ge({typeName:V.ZodNaN,...C(e)});var Ke=class extends w{_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}},qe=class e extends w{_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`?p:e.status===`dirty`?(t.dirty(),m(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`?p: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:V.ZodPipeline})}},B=class extends w{_parse(e){let t=this._def.innerType._parse(e),n=e=>(v(e)&&(e.value=Object.freeze(e.value)),e);return y(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};B.create=(e,t)=>new B({innerType:e,typeName:V.ZodReadonly,...C(t)}),j.lazycreate;var V;(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`})(V||={});let H=Ce.create,U=Te.create;Ge.create,Ee.create;let W=De.create;Oe.create,ke.create;let Je=T.create,Ye=E.create;Ae.create,D.create,O.create,je.create;let G=k.create,K=j.create;j.strictCreate;let q=M.create,J=Me.create;P.create,F.create;let Xe=Pe.create;Fe.create,Ie.create,Le.create,Re.create;let Y=ze.create,X=Ve.create;He.create,I.create,L.create,R.create,z.create,L.createWithPreprocess,qe.create;let Ze=X([`mp4`,`hls`,`flv`,`auto`]),Qe=X([`mp4`,`hls`,`flv`]),$e=q([H(),K({url:H(),loading:X([`eager`,`lazy`]).default(`lazy`).optional(),fit:X([`cover`,`contain`,`fill`]).default(`cover`).optional()})]),et=q([H(),K({url:H(),fit:X([`cover`,`contain`,`fill`]).optional(),closable:W().optional()})]),tt=J(`mode`,[K({mode:Y(`url`),url:H(),locale:H(),label:H(),isDefault:W().optional()}),K({mode:Y(`content`),content:H(),locale:H(),label:H(),isDefault:W().optional()})]),nt=K({lowLatencyMode:W().optional()}),rt=K({title:H().optional(),description:H().optional(),duration:U().optional()}),it=K({url:H(),type:Qe}),at={live:W().optional(),hls:nt.optional(),subtitles:G(tt).optional(),metadata:rt.optional()},ot=K({url:H(),type:Ze.optional(),...at}),st=K({sources:G(it).min(1),...at}),ct=q([H(),st,ot]),lt=q([H(),K({locale:H(),fallbackLocales:G(H()).optional(),messages:Xe(H(),Xe(H(),H())).optional()})]),ut=K({id:H(),text:H(),type:X([`scroll`,`top`,`bottom`]).optional(),color:H().optional(),start:U().nonnegative().optional()}),dt=K({enabled:W(),mode:X([`preload`,`streaming`]).optional(),items:G(ut).optional(),display:K({area:X([`top`,`half`,`full`]).optional(),opacity:U().min(0).max(1).optional(),speed:U().min(.5).max(2).optional(),fontSize:U().min(12).max(48).optional(),maxLines:U().int().positive().optional()}).optional()}).superRefine((e,t)=>{e.items&&e.items.length>0&&e.mode!==`preload`&&t.addIssue({code:`custom`,path:[`items`],message:`danmaku.items 只在 mode: 'preload' 下有效。当前 mode 是 ${e.mode??`streaming`}(默认)—— 渲染引擎在直播模式下会忽略每条的 start,整包会一股脑全飘出来。要么设 mode: "preload",要么改用 pushDanmaku 逐条推。`}),e.display?.maxLines!==void 0&&e.display.area&&e.display.area!==`full`&&t.addIssue({code:`custom`,path:[`display`,`maxLines`],message:`danmaku.display.maxLines 与 area: '${e.display.area}' 不能同时用 —— 渲染引擎里两者互斥(给了轨道条数,区域比例就失效),同传只会有一个生效。要限制条数就去掉 area(或用 area: 'full'),要限制区域就去掉 maxLines。`})}),ft=X([`homepage-preview`]),pt=K({play:W().optional(),progress:W().optional(),time:W().optional(),volume:W().optional(),playbackRate:W().optional(),fullscreen:W().optional(),cssFullscreen:W().optional(),pip:W().optional()}).strict();K({source:ct,preset:ft.optional(),autoplay:W().optional(),muted:W().optional(),loop:W().optional(),playbackRate:U().min(.25).max(4).optional(),volume:U().min(0).max(1).optional(),playsinline:W().optional(),preload:X([`none`,`metadata`,`auto`]).optional(),startTime:U().min(0).optional(),controls:W().optional(),showErrorOverlay:W().optional(),showLoadingOverlay:W().optional(),controlVisibility:pt.optional(),interactive:W().optional(),poster:$e.optional(),pauseImage:et.optional(),locale:lt.optional(),danmaku:dt.optional(),debug:W().optional()});let mt=X([`manifest`,`media`,`network`,`auth`,`env`,`autoplay`]),ht=X([`E_MANIFEST_PARSE`,`E_MEDIA_DECODE`,`E_MEDIA_ABORTED`,`E_MEDIA_NOT_SUPPORTED`,`E_SUBTITLE_LOAD_FAILED`,`E_AUTOPLAY_BLOCKED`,`E_NETWORK`,`E_NETWORK_TIMEOUT`,`E_AUTH_EXPIRED`,`E_ENV_CSP_BLOCKED`,`E_METHOD_NOT_SUPPORTED`,`E_DANMAKU_SEND_FAILED`,`E_INTERNAL`,`E_UNKNOWN`,`E_PLAYER_DESTROYED`,`E_HANDSHAKE_TIMEOUT`,`E_HANDSHAKE_VERSION_MISMATCH`,`E_LOAD_FAILED`,`E_FRAME_CRASHED`]),gt=X([`W_BROWSER_INCOMPATIBLE`,`W_VERSION_MISMATCH`,`W_EVENT_REJECTED`]),_t=K({name:H(),message:H(),code:U().optional(),status:U().optional()}).catchall(q([H(),U(),W()])),vt=K({code:ht,message:H(),retryable:W(),category:mt,cause:_t.optional()}),yt=K({fvt:U()}),bt=K({durationMs:U(),droppedFrames:U(),totalFrames:U()}),xt=[`switch_play_pause`,`switch_fullscreen`,`switch_cssfullscreen`,`switch_css_fullscreen`,`change_definition`,`change_rate`,`change_volume`,`change_muted`,`change_pip`,`seek`,`rotate`,`shot`,`download`,`switch_danmu`,`error_retry`],St=K({action:X(xt),source:H(),from:q([H(),U(),W()]).nullable(),to:q([H(),U(),W()]).nullable()});new Set(xt);let Z={channel:Y(`video-lab:page-fullscreen`),version:Y(1),session:H().min(1)},Ct=J(`type`,[K({...Z,type:Y(`hello`)}),K({...Z,type:Y(`ready`),instance:H().min(1)}),K({...Z,type:Y(`request`),instance:H().min(1),id:U().int().positive(),active:W()}),K({...Z,type:Y(`state`),instance:H().min(1),revision:U().int().nonnegative(),active:W()}),K({...Z,type:Y(`ack`),instance:H().min(1),revision:U().int().nonnegative()}),K({...Z,type:Y(`disconnect`)})]);K({available:W(),active:W()});let wt=K({active:W()}),Tt=X([`native`,`hls.js`,`flv.js`]),Et=X([`live`,`vod`]),Dt=K({platform:X([`ios`,`android`,`desktop`,`unknown`]),browser:X([`webkit`,`gecko`,`chromium`,`embedded`,`unknown`]),mse:X([`standard`,`managed`,`unavailable`])}),Ot=K({sessionId:H(),candidateTypes:G(Qe).min(1),streamKind:Et,runtime:Dt}),kt=J(`outcome`,[Ot.extend({outcome:Y(`selected`),mediaType:Qe,kernel:Tt,reason:X([`required_hls`,`live_preference`,`vod_preference`,`native_mp4_fallback`])}).strict(),Ot.extend({outcome:Y(`unsupported`),mediaType:Ye(),kernel:Ye(),reason:Y(`no_supported_candidate`),errorCode:Y(`E_MEDIA_NOT_SUPPORTED`)}).strict()]),At=K({sessionId:H(),kernel:Tt,mediaType:Qe.optional(),streamKind:Et.optional(),runtime:Dt.optional(),position:U(),qualityLevel:U().nullable(),srcOrigin:H(),srcPath:H()});X([`detected`,`backoff`,`attempting`,`validating`,`recovered`,`failed`,`cancelled`]);let jt=X([`reconnect`,`media_recovery`,`visibility_reload`]),Mt=X([`error`,`manual`,`visibility`,`stall`,`startup_timeout`]),Q={sessionId:H().min(1),recoveryId:U().int().positive(),strategy:jt,trigger:Mt,attempt:U().int().nonnegative(),maxAttempts:U().int().positive(),elapsedMs:U().finite().nonnegative(),reason:ht.optional()},Nt={...Q,attempt:U().int().positive()},Pt=J(`phase`,[K({...Q,phase:Y(`detected`)}).strict(),K({...Q,phase:Y(`backoff`)}).strict(),K({...Nt,phase:Y(`attempting`)}).strict(),K({...Nt,phase:Y(`validating`)}).strict(),K({...Nt,phase:Y(`recovered`),validatedBy:Y(`playing_position_advance`)}).strict(),K({...Q,phase:Y(`failed`),outcome:X([`timeout`,`attempts_exhausted`])}).strict(),K({...Q,phase:Y(`cancelled`),outcome:X([`source_changed`,`destroyed`,`superseded`,`user_paused`,`natural_recovery`])}).strict()]).refine(e=>e.attempt<=e.maxAttempts,{message:`attempt exceeds episode budget`,path:[`attempt`]}),Ft=K({level:U(),label:H().optional(),height:U().optional(),bitrate:U().optional()}),It=K({id:U(),locale:H(),label:H()}),Lt=X([`ok`,`initializing`,`buffering`,`stalled`,`reconnecting`,`autoplay_blocked`,`error`,`frame_disconnected`,`degraded`]),Rt=J(`event`,[K({event:Y(`pagefullscreenchange`),payload:wt}),K({event:Y(`sourceroute`),payload:kt}),K({event:Y(`ready`),payload:K({duration:U(),quality:G(Ft),subtitles:G(It).optional()})}),K({event:Y(`play`),payload:K({})}),K({event:Y(`pause`),payload:K({})}),K({event:Y(`ended`),payload:K({})}),K({event:Y(`timeupdate`),payload:K({time:U(),duration:U()})}),K({event:Y(`volumechange`),payload:K({volume:U(),muted:W()})}),K({event:Y(`seeking`),payload:K({time:U()})}),K({event:Y(`seeked`),payload:K({time:U()})}),K({event:Y(`waiting`),payload:K({})}),K({event:Y(`playing`),payload:K({})}),K({event:Y(`qualitychange`),payload:K({level:U(),auto:W()})}),K({event:Y(`subtitlechange`),payload:K({id:U().nullable()})}),K({event:Y(`error`),payload:vt}),K({event:Y(`autoplayblocked`),payload:K({})}),K({event:Y(`recovery`),payload:Pt}),K({event:Y(`compatwarning`),payload:K({code:gt,message:H(),ua:H(),hostVersion:H().optional(),iframeVersion:H().optional(),rejectedEvent:H().optional()})}),K({event:Y(`stalled`),payload:K({phase:X([`start`,`end`]),position:U(),durationMs:U().optional(),kind:X([`playback`,`firstframe`,`seek`]).optional()})}),K({event:Y(`playablechange`),payload:K({playable:W(),reason:Lt,recoverable:W(),action:X([`retry`,`play`,`replace-source`,`recreate-frame`,`none`]).optional()})}),K({event:Y(`kernelhealth`),payload:K({degraded:W(),reason:X([`network`,`media`,`other`]),count:U(),durationMs:U(),detail:H()})}),K({event:Y(`audiohealth`),payload:K({degraded:W(),reason:Y(`audio_data_gap`),durationMs:U()})}),K({event:Y(`bufferhealth`),payload:K({draining:W(),marginSec:U()})}),K({event:Y(`contextchange`),payload:At}),K({event:Y(`firstframe`),payload:yt}),K({event:Y(`framefreeze`),payload:bt}),K({event:Y(`useraction`),payload:St})]);function zt(e,t){return{event:`compatwarning`,payload:{code:`W_EVENT_REJECTED`,message:`收到一条过不了契约校验的事件(${e??`(未知)`}),已丢弃。最常见的成因是 iframe 比宿主新 —— 先看两端契约版本差多少,再怀疑 iframe 有 bug。`,ua:t,...e===void 0?{}:{rejectedEvent:e}}}}K({event:Rt,producerSessionId:H().min(1),deliveryId:H().min(1),occurredAtMs:U().finite(),sequence:U().int().positive()});let Bt=J(`method`,[K({method:Y(`play`),params:K({}).optional()}),K({method:Y(`pause`),params:K({}).optional()}),K({method:Y(`seek`),params:K({time:U(),type:X([`exact`,`keyframe`]).optional()})}),K({method:Y(`setVolume`),params:K({volume:U().min(0).max(1)})}),K({method:Y(`setMuted`),params:K({muted:W()})}),K({method:Y(`setPlaybackRate`),params:K({rate:U().min(.25).max(4)})}),K({method:Y(`setQuality`),params:K({level:q([U(),Y(`auto`)])})}),K({method:Y(`setSubtitle`),params:K({id:q([U(),Y(`off`)])})}),K({method:Y(`setLocale`),params:K({locale:lt})}),K({method:Y(`load`),params:K({source:ct})}),K({method:Y(`retry`),params:K({}).strict().optional()}),K({method:Y(`pushDanmaku`),params:K({item:ut})}),K({method:Y(`setDanmakuEnabled`),params:K({enabled:W()})}),K({method:Y(`clearDanmaku`),params:K({}).optional()}),K({method:Y(`destroy`),params:K({}).optional()}),K({method:Y(`enterFullscreen`),params:K({}).optional()}),K({method:Y(`exitFullscreen`),params:K({}).optional()})]);X([`command`,`event`,`response`,`error`]);let Vt={version:H(),id:H(),timestamp:U()};function $(e,t){return K({...Vt,type:Y(e),payload:t})}let Ht=q([$(`command`,Bt),q([$(`event`,Rt).extend({producerSessionId:Je().optional(),sequence:Je().optional()}),$(`event`,Rt).extend({producerSessionId:H().min(1),sequence:U().int().positive()})]),$(`response`,K({})),$(`error`,vt)]);function Ut(e){return e||(typeof window<`u`?window:null)}function Wt(e={}){let t=Ut(e.target),n=e.iframe,r=e.origin==null?null:new Set(Array.isArray(e.origin)?e.origin:[e.origin]),i=new Set;function a(e){let t=e;if(typeof t!=`object`||!t||t.type!==`event`)return;let n=t.payload?.event,r=typeof n==`string`?n:`(未知)`;i.has(r)||(i.add(r),o(zt(typeof n==`string`?n:void 0,typeof navigator>`u`?``:navigator.userAgent)))}function o(e){let{event:t,payload:n}=e;for(let e of c)try{e({event:t,payload:n})}catch{}let r=s.get(t);if(r)for(let e of r)try{e(n)}catch(e){console.warn(`[SentinelEmbed] 事件处理器抛错:`,e)}}let s=new Map,c=new Set,l=new Set,u=e=>{let t=e;if(r&&!r.has(t.origin)||n&&t.source!==n.contentWindow)return;let i=Ht.safeParse(t.data);if(!i.success){a(t.data);return}if(i.data.type===`event`&&(o(i.data.payload),i.data.producerSessionId!==void 0&&i.data.sequence!==void 0)){let e={event:i.data.payload,producerSessionId:i.data.producerSessionId,deliveryId:i.data.id,occurredAtMs:i.data.timestamp,sequence:i.data.sequence};for(let t of l)try{t(e)}catch{}}};t?.addEventListener(`message`,u);let d=(e,t)=>{s.get(e)?.delete(t)};return{on:(e,t)=>{let n=s.get(e);return n||(n=new Set,s.set(e,n)),n.add(t),()=>d(e,t)},onAny:e=>(c.add(e),()=>c.delete(e)),onDelivered:e=>(l.add(e),()=>l.delete(e)),off:d,destroy:()=>{t?.removeEventListener(`message`,u),s.clear(),c.clear(),l.clear()}}}let Gt=0;function Kt(){return globalThis.crypto?.randomUUID?.()||(Gt+=1,`page-fullscreen-${Date.now().toString(36)}-${Gt.toString(36)}`)}function qt(e){if(new URL(e.origin).origin!==e.origin||e.origin===`null`)throw Error(`网页全屏要求精确 origin`);let{iframe:t,origin:n,adapter:r}=e,i=t.ownerDocument.defaultView;if(!i)throw Error(`iframe 尚无宿主窗口`);let a=Kt(),o=``,s=0,c=!1,l=!1,u=Date.now(),d=0,f=Promise.resolve(),p;function m(e){let r=t.contentWindow;if(r){try{if(r.location.href===`about:blank`)return}catch(e){if(!(e instanceof DOMException)||e.name!==`SecurityError`)throw e}r.postMessage(e,n)}}function h(){o&&m({channel:`video-lab:page-fullscreen`,version:1,type:`state`,session:a,instance:o,revision:s,active:c})}function g(){m({channel:`video-lab:page-fullscreen`,version:1,type:`hello`,session:a}),p&&h()}function _(e){if(!p)return;let t=p;p=void 0,clearTimeout(t.timer),e?t.reject(e):t.resolve()}function v(){l||(l=!0,clearInterval(C),i?.removeEventListener(`message`,b),i?.removeEventListener(`keydown`,x),t.removeEventListener(`load`,S),m({channel:`video-lab:page-fullscreen`,version:1,type:`disconnect`,session:a}),_(Error(`网页全屏连接已销毁`)),c=!1,r.dispose())}function y(t){let n=a,i=f.then(async()=>{if(l||!o||n!==a)throw Error(`iframe 尚未确认网页全屏支持`);let i=o,u,d=Promise.resolve().then(()=>r.setActive(t)).then(()=>{if(l||n!==a||o!==i)throw r.dispose(),Error(`网页全屏请求已失效`)});try{await Promise.race([d,new Promise((e,t)=>{u=setTimeout(()=>{v(),t(Error(`宿主布局超时`))},1e4)})]),c=t,s+=1,await new Promise((e,t)=>{p={revision:s,resolve:e,reject:t,timer:setTimeout(()=>{v()},1e4)},h()}),e.onChange?.({active:c})}catch(e){throw c=!1,r.dispose(),l||(s+=1,h()),e}finally{clearTimeout(u)}});return f=i.catch(()=>{}),i}function b(e){if(l||e.source!==t.contentWindow||e.origin!==n)return;let i=Ct.safeParse(e.data);if(!i.success||i.data.session!==a)return;let f=i.data;if(f.type===`ready`){if(o&&o!==f.instance)return;u=Date.now(),o!==f.instance&&(_(Error(`iframe 已重新加载`)),c&&r.dispose(),c=!1,o=f.instance,s=0,d=0,h())}else if(f.type===`ack`&&f.instance===o&&f.revision===p?.revision)_();else if(f.type===`request`&&f.instance===o){if(f.id<=d){h();return}d=f.id,y(f.active).catch(()=>{})}}function x(e){e.key===`Escape`&&c&&y(!1).catch(()=>{})}function S(){a=Kt(),_(Error(`iframe 已重新加载`)),o=``,c=!1,r.dispose(),g()}i.addEventListener(`message`,b),i.addEventListener(`keydown`,x),t.addEventListener(`load`,S);let C=setInterval(()=>{o&&Date.now()-u>5e3?v():g()},1e3);return g(),{setPageFullscreen:y,destroy:v}}let Jt=null;function Yt(){return Jt||=Wt(),Jt}function Xt(e,t){return Yt().on(e,t)}function Zt(e){return Yt().onAny(e)}function Qt(e){return Yt().onDelivered(e)}function $t(e,t){Yt().off(e,t)}function en(){Jt?.destroy(),Jt=null}return e.createEmbedListener=Wt,e.createPageFullscreenController=qt,e.destroy=en,e.off=$t,e.on=Xt,e.onAny=Zt,e.onDelivered=Qt,e})({});
|
package/dist/index.mjs
CHANGED
|
@@ -121,13 +121,20 @@ function createEmbedListener(options = {}) {
|
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/page-fullscreen.ts
|
|
124
|
+
let sessionCounter = 0;
|
|
125
|
+
function createSessionId() {
|
|
126
|
+
const uuid = globalThis.crypto?.randomUUID?.();
|
|
127
|
+
if (uuid) return uuid;
|
|
128
|
+
sessionCounter += 1;
|
|
129
|
+
return `page-fullscreen-${Date.now().toString(36)}-${sessionCounter.toString(36)}`;
|
|
130
|
+
}
|
|
124
131
|
/** 只控制网页全屏,不暴露其他播放器命令。销毁时恢复宿主布局。 */
|
|
125
132
|
function createPageFullscreenController(options) {
|
|
126
133
|
if (new URL(options.origin).origin !== options.origin || options.origin === "null") throw new Error("网页全屏要求精确 origin");
|
|
127
134
|
const { iframe, origin, adapter } = options;
|
|
128
135
|
const target = iframe.ownerDocument.defaultView;
|
|
129
136
|
if (!target) throw new Error("iframe 尚无宿主窗口");
|
|
130
|
-
let session =
|
|
137
|
+
let session = createSessionId();
|
|
131
138
|
let instance = "";
|
|
132
139
|
let revision = 0;
|
|
133
140
|
let active = false;
|
|
@@ -270,7 +277,7 @@ function createPageFullscreenController(options) {
|
|
|
270
277
|
if (event.key === "Escape" && active) setPageFullscreen(false).catch(() => {});
|
|
271
278
|
}
|
|
272
279
|
function reload() {
|
|
273
|
-
session =
|
|
280
|
+
session = createSessionId();
|
|
274
281
|
clearWaiting(/* @__PURE__ */ new Error("iframe 已重新加载"));
|
|
275
282
|
instance = "";
|
|
276
283
|
active = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@video-lab/embed-helper",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@video-lab/protocol": "3.0.
|
|
34
|
+
"@video-lab/protocol": "3.0.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"tsdown": "^0.22.9",
|