@video-lab/embed-helper 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/index.iife.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @video-lab/embed-helper
|
|
2
2
|
|
|
3
|
-
Video Lab Player
|
|
3
|
+
Video Lab Player 的静态 iframe 宿主侧事件监听器。
|
|
4
4
|
|
|
5
5
|
给 CMS / Markdown / 论坛 / 邮件模板这类「只能嵌一个 URL、跑不了 npm 包」的场景用:让宿主页面能订阅 iframe 里播放器广播出来的契约事件。
|
|
6
6
|
|
|
@@ -10,21 +10,21 @@ Video Lab Player 的**静态 iframe 场景 host 侧辅助(L7)**。
|
|
|
10
10
|
|
|
11
11
|
### 1. `<script>` 标签(无构建工具)
|
|
12
12
|
|
|
13
|
-
`helper.js` 和 iframe
|
|
13
|
+
`helper.js` 和 iframe 地址位于同一部署版本目录。以下的 `player.example.com` 与版本号仅为占位符,实际地址由内部部署配置提供:
|
|
14
14
|
|
|
15
15
|
```html
|
|
16
16
|
<iframe id="article-player"></iframe>
|
|
17
|
-
<script src="https://player.example.
|
|
17
|
+
<script src="https://player.example.com/v1.0.0/helper.js"></script>
|
|
18
18
|
<script>
|
|
19
19
|
const iframe = document.getElementById('article-player')
|
|
20
20
|
if (!(iframe instanceof HTMLIFrameElement)) throw new Error('iframe 未找到')
|
|
21
21
|
const player = SentinelEmbed.createEmbedListener({
|
|
22
|
-
origin: 'https://player.example.
|
|
22
|
+
origin: 'https://player.example.com',
|
|
23
23
|
iframe,
|
|
24
24
|
})
|
|
25
25
|
player.on('ended', () => { location.href = nextUrl })
|
|
26
26
|
// 订阅完成后再开始加载,静态事件不回放。
|
|
27
|
-
iframe.src = 'https://player.example.
|
|
27
|
+
iframe.src = 'https://player.example.com/v1.0.0/?src=...&autoplay=1'
|
|
28
28
|
</script>
|
|
29
29
|
```
|
|
30
30
|
|
|
@@ -43,8 +43,8 @@ declare function track(name: string, payload: unknown): void
|
|
|
43
43
|
import { createEmbedListener } from '@video-lab/embed-helper'
|
|
44
44
|
|
|
45
45
|
const player = createEmbedListener({
|
|
46
|
-
//
|
|
47
|
-
origin: 'https://player.example.
|
|
46
|
+
// 传入内部部署的播放器 origin,过滤不受信任的消息来源。
|
|
47
|
+
origin: 'https://player.example.com',
|
|
48
48
|
// 同 origin 多 iframe 时绑定这一张;source 只做实例归属,不替代 origin / schema 校验。
|
|
49
49
|
iframe,
|
|
50
50
|
})
|
|
@@ -92,6 +92,6 @@ player.destroy()
|
|
|
92
92
|
|
|
93
93
|
## 相关
|
|
94
94
|
|
|
95
|
-
- 静态 iframe URL
|
|
95
|
+
- 静态 iframe 的实际地址与 URL 参数由内部部署配置决定;请向项目维护团队获取接入信息。
|
|
96
96
|
|
|
97
97
|
MIT
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var SentinelEmbed=(function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function n(e){return e||(typeof window<`u`?window:null)}function r(e={}){let r=n(e.target),i=e.iframe,a=e.origin==null?null:new Set(Array.isArray(e.origin)?e.origin:[e.origin]),o=new Set;function s(e){let n=e;if(typeof n!=`object`||!n||n.type!==`event`)return;let r=n.payload?.event,i=typeof r==`string`?r:`(未知)`;o.has(i)||(o.add(i),c((0,t.makeEventRejectedWarning)(typeof r==`string`?r:void 0,typeof navigator>`u`?``:navigator.userAgent)))}function c(e){let{event:t,payload:n}=e;for(let e of u)try{e({event:t,payload:n})}catch{}let r=l.get(t);if(r)for(let e of r)try{e(n)}catch(e){console.warn(`[SentinelEmbed] 事件处理器抛错:`,e)}}let l=new Map,u=new Set,d=e=>{let n=e;if(a&&!a.has(n.origin)||i&&n.source!==i.contentWindow)return;let r=t.EnvelopeSchema.safeParse(n.data);if(!r.success){s(n.data);return}r.data.type===`event`&&c(r.data.payload)};r?.addEventListener(`message`,d);let f=(e,t)=>{l.get(e)?.delete(t)};return{on:(e,t)=>{let n=l.get(e);return n||(n=new Set,l.set(e,n)),n.add(t),()=>f(e,t)},onAny:e=>(u.add(e),()=>u.delete(e)),off:f,destroy:()=>{r?.removeEventListener(`message`,d),l.clear(),u.clear()}}}let i=null;function a(){return i||=r(),i}function o(e,t){return a().on(e,t)}function s(e){return a().onAny(e)}function c(e,t){a().off(e,t)}function l(){i?.destroy(),i=null}return e.createEmbedListener=r,e.destroy=l,e.off=c,e.on=o,e.onAny=s,e})({},_video_lab_protocol);
|
|
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`}),ee=e=>({status:`dirty`,value:e}),m=e=>({status:`valid`,value:e}),te=e=>e.status===`aborted`,ne=e=>e.status===`dirty`,h=e=>e.status===`valid`,g=e=>typeof Promise<`u`&&e instanceof Promise;var _;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(_||={});var v=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 re=(e,t)=>{if(h(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 y(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 b=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(g(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 re(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 h(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=>h(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(g(r)?r:Promise.resolve(r));return re(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 R({schema:this,typeName:U.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 z.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return E.create(this)}promise(){return L.create(this,this._def)}or(e){return k.create([this,e],this._def)}and(e){return j.create(this,e,this._def)}transform(e){return new R({...y(this._def),schema:this,typeName:U.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new V({...y(this._def),innerType:this,defaultValue:t,typeName:U.ZodDefault})}brand(){return new Ue({typeName:U.ZodBranded,type:this,...y(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new H({...y(this._def),innerType:this,catchValue:t,typeName:U.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return We.create(this,e)}readonly(){return Ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let ie=/^c[^\s-]{8,}$/i,ae=/^[0-9a-z]+$/,oe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,se=/^[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,ce=/^[a-z0-9_-]{21}$/i,le=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ue=/^[-+]?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)?)??$/,de=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,fe,pe=/^(?:(?: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])$/,me=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,he=/^(([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]))$/,ge=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_e=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ve=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ye=`((\\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])))`,be=RegExp(`^${ye}$`);function xe(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 Se(e){return RegExp(`^${xe(e)}$`)}function Ce(e){let t=`${ye}T${xe(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function we(e,t){return!!((t===`v4`||!t)&&pe.test(e)||(t===`v6`||!t)&&he.test(e))}function Te(e,t){if(!le.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 Ee(e,t){return!!((t===`v4`||!t)&&me.test(e)||(t===`v6`||!t)&&ge.test(e))}var x=class e extends b{_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`)de.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`)fe||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),fe.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`)se.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`)ce.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`)ie.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`)ae.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`)oe.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`?Ce(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`?be.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`date`,message:r.message}),n.dirty()):r.kind===`time`?Se(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`?ue.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`duration`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`ip`?we(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`?Te(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`?Ee(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`?_e.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`base64`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`base64url`?ve.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,..._.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,..._.errToObj(e)})}url(e){return this._addCheck({kind:`url`,..._.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,..._.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,..._.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,..._.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,..._.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,..._.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,..._.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,..._.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,..._.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,..._.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,..._.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,..._.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,..._.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,..._.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.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}};x.create=e=>new x({checks:[],typeName:U.ZodString,coerce:e?.coerce??!1,...y(e)});function De(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 Oe=class e extends b{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`?De(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,_.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,_.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,_.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,_.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:_.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:_.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:_.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:_.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:_.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)}};Oe.create=e=>new Oe({checks:[],typeName:U.ZodNumber,coerce:e?.coerce||!1,...y(e)});var ke=class e extends b{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,_.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,_.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,_.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,_.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:_.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:_.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:_.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}};ke.create=e=>new ke({checks:[],typeName:U.ZodBigInt,coerce:e?.coerce??!1,...y(e)});var Ae=class extends b{_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 m(e.data)}};Ae.create=e=>new Ae({typeName:U.ZodBoolean,coerce:e?.coerce||!1,...y(e)});var je=class e extends b{_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:_.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:_.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)}};je.create=e=>new je({checks:[],coerce:e?.coerce||!1,typeName:U.ZodDate,...y(e)});var Me=class extends b{_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 m(e.data)}};Me.create=e=>new Me({typeName:U.ZodSymbol,...y(e)});var S=class extends b{_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 m(e.data)}};S.create=e=>new S({typeName:U.ZodUndefined,...y(e)});var C=class extends b{_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 m(e.data)}};C.create=e=>new C({typeName:U.ZodNull,...y(e)});var Ne=class extends b{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}};Ne.create=e=>new Ne({typeName:U.ZodAny,...y(e)});var w=class extends b{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}};w.create=e=>new w({typeName:U.ZodUnknown,...y(e)});var T=class extends b{_parse(e){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.never,received:t.parsedType}),p}};T.create=e=>new T({typeName:U.ZodNever,...y(e)});var Pe=class extends b{_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 m(e.data)}};Pe.create=e=>new Pe({typeName:U.ZodVoid,...y(e)});var E=class e extends b{_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 v(t,e,t.path,n)))).then(e=>f.mergeArray(n,e));let o=[...t.data].map((e,n)=>i.type._parseSync(new v(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:_.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:_.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:_.toString(n)}})}nonempty(e){return this.min(1,e)}};E.create=(e,t)=>new E({type:e,minLength:null,maxLength:null,exactLength:null,typeName:U.ZodArray,...y(t)});function D(e){if(e instanceof O){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=z.create(D(r))}return new O({...e._def,shape:()=>t})}else if(e instanceof E)return new E({...e._def,type:D(e.element)});else if(e instanceof z)return z.create(D(e.unwrap()));else if(e instanceof B)return B.create(D(e.unwrap()));else if(e instanceof M)return M.create(e.items.map(e=>D(e)));else return e}var O=class e extends b{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 T&&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 v(n,r,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof T){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 v(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 _.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:_.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:U.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 D(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 z;)t=t._def.innerType;r[e]=t}return new e({...this._def,shape:()=>r})}keyof(){return Ve(t.objectKeys(this.shape))}};O.create=(e,t)=>new O({shape:()=>e,unknownKeys:`strip`,catchall:T.create(),typeName:U.ZodObject,...y(t)}),O.strictCreate=(e,t)=>new O({shape:()=>e,unknownKeys:`strict`,catchall:T.create(),typeName:U.ZodObject,...y(t)}),O.lazycreate=(e,t)=>new O({shape:e,unknownKeys:`strip`,catchall:T.create(),typeName:U.ZodObject,...y(t)});var k=class extends b{_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}};k.create=(e,t)=>new k({options:e,typeName:U.ZodUnion,...y(t)});let A=e=>e instanceof N?A(e.schema):e instanceof R?A(e.innerType()):e instanceof P?[e.value]:e instanceof F?e.options:e instanceof I?t.objectValues(e.enum):e instanceof V?A(e._def.innerType):e instanceof S?[void 0]:e instanceof C?[null]:e instanceof z?[void 0,...A(e.unwrap())]:e instanceof B?[null,...A(e.unwrap())]:e instanceof Ue||e instanceof Ge?A(e.unwrap()):e instanceof H?A(e._def.innerType):[];var Fe=class e extends b{_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=A(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:U.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...y(r)})}};function Ie(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=Ie(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=Ie(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 j=class extends b{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(te(e)||te(r))return p;let i=Ie(e.value,r.value);return i.valid?((ne(e)||ne(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}))}};j.create=(e,t,n)=>new j({left:e,right:t,typeName:U.ZodIntersection,...y(n)});var M=class e extends b{_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 v(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})}};M.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new M({items:e,typeName:U.ZodTuple,rest:null,...y(t)})};var Le=class e extends b{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 v(n,e,n.path,e)),value:s._parse(new v(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 b?new e({keyType:t,valueType:n,typeName:U.ZodRecord,...y(r)}):new e({keyType:x.create(),valueType:t,typeName:U.ZodRecord,...y(n)})}},Re=class extends b{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 v(n,e,n.path,[r,`key`])),value:o._parse(new v(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}}}};Re.create=(e,t,n)=>new Re({valueType:t,keyType:e,typeName:U.ZodMap,...y(n)});var ze=class e extends b{_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 v(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:_.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:_.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ze.create=(e,t)=>new ze({valueType:e,minSize:null,maxSize:null,typeName:U.ZodSet,...y(t)});var Be=class e extends b{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 L){let e=this;return m(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 m(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:M.create(t).rest(w.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||M.create([]).rest(w.create()),returns:n||w.create(),typeName:U.ZodFunction,...y(r)})}},N=class extends b{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})}};N.create=(e,t)=>new N({getter:e,typeName:U.ZodLazy,...y(t)});var P=class extends b{_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}};P.create=(e,t)=>new P({value:e,typeName:U.ZodLiteral,...y(t)});function Ve(e,t){return new F({values:e,typeName:U.ZodEnum,...y(t)})}var F=class e extends b{_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 m(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})}};F.create=Ve;var I=class extends b{_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 m(e.data)}get enum(){return this._def.values}};I.create=(e,t)=>new I({values:e,typeName:U.ZodNativeEnum,...y(t)});var L=class extends b{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):m((t.parsedType===r.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};L.create=(e,t)=>new L({type:e,typeName:U.ZodPromise,...y(t)});var R=class extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===U.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`?ee(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`?ee(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(!h(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=>h(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):p);t.assertNever(i)}};R.create=(e,t,n)=>new R({schema:e,typeName:U.ZodEffects,effect:t,...y(n)}),R.createWithPreprocess=(e,t,n)=>new R({schema:t,effect:{type:`preprocess`,transform:e},typeName:U.ZodEffects,...y(n)});var z=class extends b{_parse(e){return this._getType(e)===r.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};z.create=(e,t)=>new z({innerType:e,typeName:U.ZodOptional,...y(t)});var B=class extends b{_parse(e){return this._getType(e)===r.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(e,t)=>new B({innerType:e,typeName:U.ZodNullable,...y(t)});var V=class extends b{_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}};V.create=(e,t)=>new V({innerType:e,typeName:U.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...y(t)});var H=class extends b{_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 g(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}};H.create=(e,t)=>new H({innerType:e,typeName:U.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...y(t)});var He=class extends b{_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}}};He.create=e=>new He({typeName:U.ZodNaN,...y(e)});var Ue=class extends b{_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}},We=class e extends b{_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(),ee(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:U.ZodPipeline})}},Ge=class extends b{_parse(e){let t=this._def.innerType._parse(e),n=e=>(h(e)&&(e.value=Object.freeze(e.value)),e);return g(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Ge.create=(e,t)=>new Ge({innerType:e,typeName:U.ZodReadonly,...y(t)}),O.lazycreate;var U;(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`})(U||={});let W=x.create,G=Oe.create;He.create,ke.create;let K=Ae.create;je.create,Me.create,S.create;let Ke=C.create;Ne.create,w.create,T.create,Pe.create;let q=E.create,J=O.create;O.strictCreate;let Y=k.create,X=Fe.create;j.create,M.create;let qe=Le.create;Re.create,ze.create,Be.create,N.create;let Z=P.create,Q=F.create;I.create,L.create,R.create,z.create,B.create,R.createWithPreprocess,We.create;let Je=Q([`mp4`,`hls`,`flv`,`auto`]),Ye=Q([`mp4`,`hls`,`flv`]),Xe=Y([W(),J({url:W(),loading:Q([`eager`,`lazy`]).default(`lazy`).optional(),fit:Q([`cover`,`contain`,`fill`]).default(`cover`).optional()})]),Ze=Y([W(),J({url:W(),fit:Q([`cover`,`contain`,`fill`]).optional(),closable:K().optional()})]),Qe=X(`mode`,[J({mode:Z(`url`),url:W(),locale:W(),label:W(),isDefault:K().optional()}),J({mode:Z(`content`),content:W(),locale:W(),label:W(),isDefault:K().optional()})]),$e=J({lowLatencyMode:K().optional()}),et=J({title:W().optional(),description:W().optional(),duration:G().optional()}),tt=J({url:W(),type:Ye}),nt={live:K().optional(),hls:$e.optional(),subtitles:q(Qe).optional(),metadata:et.optional()},rt=J({url:W(),type:Je.optional(),...nt}),it=J({sources:q(tt).min(1),...nt}),at=Y([W(),it,rt]),ot=Y([W(),J({locale:W(),fallbackLocales:q(W()).optional(),messages:qe(W(),qe(W(),W())).optional()})]),st=J({id:W(),text:W(),type:Q([`scroll`,`top`,`bottom`]).optional(),color:W().optional(),start:G().nonnegative().optional()}),ct=J({enabled:K(),mode:Q([`preload`,`streaming`]).optional(),items:q(st).optional(),display:J({area:Q([`top`,`half`,`full`]).optional(),opacity:G().min(0).max(1).optional(),speed:G().min(.5).max(2).optional(),fontSize:G().min(12).max(48).optional(),maxLines:G().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。`})});J({source:at,preset:Q([`homepage-preview`]).optional(),autoplay:K().optional(),muted:K().optional(),loop:K().optional(),playbackRate:G().min(.25).max(4).optional(),volume:G().min(0).max(1).optional(),playsinline:K().optional(),preload:Q([`none`,`metadata`,`auto`]).optional(),startTime:G().min(0).optional(),controls:K().optional(),interactive:K().optional(),poster:Xe.optional(),pauseImage:Ze.optional(),locale:ot.optional(),danmaku:ct.optional(),debug:K().optional()});let lt=Q([`manifest`,`media`,`network`,`auth`,`env`,`autoplay`]),ut=Q([`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`]),dt=Q([`W_BROWSER_INCOMPATIBLE`,`W_VERSION_MISMATCH`,`W_EVENT_REJECTED`]),ft=J({name:W(),message:W(),code:G().optional(),status:G().optional()}).catchall(Y([W(),G(),K()])),pt=J({code:ut,message:W(),retryable:K(),category:lt,cause:ft.optional()}),mt=J({fvt:G()}),ht=J({durationMs:G(),droppedFrames:G(),totalFrames:G()}),gt=[`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`],_t=J({action:Q(gt),source:W(),from:Y([W(),G(),K()]).nullable(),to:Y([W(),G(),K()]).nullable()});new Set(gt);let vt=Q([`native`,`hls.js`,`flv.js`]),yt=Q([`live`,`vod`]),bt=J({platform:Q([`ios`,`android`,`desktop`,`unknown`]),browser:Q([`webkit`,`gecko`,`chromium`,`embedded`,`unknown`]),mse:Q([`standard`,`managed`,`unavailable`])}),xt=J({sessionId:W(),candidateTypes:q(Ye).min(1),streamKind:yt,runtime:bt}),St=X(`outcome`,[xt.extend({outcome:Z(`selected`),mediaType:Ye,kernel:vt,reason:Q([`required_hls`,`live_preference`,`vod_preference`,`native_mp4_fallback`])}).strict(),xt.extend({outcome:Z(`unsupported`),mediaType:Ke(),kernel:Ke(),reason:Z(`no_supported_candidate`),errorCode:Z(`E_MEDIA_NOT_SUPPORTED`)}).strict()]),Ct=J({sessionId:W(),kernel:vt,mediaType:Ye.optional(),streamKind:yt.optional(),runtime:bt.optional(),position:G(),qualityLevel:G().nullable(),srcOrigin:W(),srcPath:W()}),wt=J({level:G(),label:W().optional(),height:G().optional(),bitrate:G().optional()}),Tt=J({id:G(),locale:W(),label:W()}),Et=Q([`ok`,`initializing`,`buffering`,`stalled`,`reconnecting`,`autoplay_blocked`,`error`,`frame_disconnected`,`degraded`]);Q([`detected`,`attempting`,`validating`,`recovered`,`failed`,`cancelled`]);let Dt=Q([`reconnect`,`media_recovery`,`visibility_reload`]),Ot=Q([`error`,`manual`,`visibility`]),$={recoveryId:G().int().positive(),strategy:Dt,trigger:Ot,attempt:G().int().positive(),maxAttempts:G().int().positive(),reason:ut.optional()},kt=X(`phase`,[J({...$,phase:Z(`detected`)}).strict(),J({...$,phase:Z(`attempting`)}).strict(),J({...$,phase:Z(`validating`)}).strict(),J({...$,phase:Z(`recovered`),validatedBy:Z(`playing_position_advance`)}).strict(),J({...$,phase:Z(`failed`),outcome:Q([`timeout`,`attempts_exhausted`])}).strict(),J({...$,phase:Z(`cancelled`),outcome:Q([`source_changed`,`destroyed`,`superseded`])}).strict()]),At=X(`event`,[J({event:Z(`sourceroute`),payload:St}),J({event:Z(`ready`),payload:J({duration:G(),quality:q(wt),subtitles:q(Tt).optional()})}),J({event:Z(`play`),payload:J({})}),J({event:Z(`pause`),payload:J({})}),J({event:Z(`ended`),payload:J({})}),J({event:Z(`timeupdate`),payload:J({time:G(),duration:G()})}),J({event:Z(`volumechange`),payload:J({volume:G(),muted:K()})}),J({event:Z(`seeking`),payload:J({time:G()})}),J({event:Z(`seeked`),payload:J({time:G()})}),J({event:Z(`waiting`),payload:J({})}),J({event:Z(`playing`),payload:J({})}),J({event:Z(`qualitychange`),payload:J({level:G(),auto:K()})}),J({event:Z(`subtitlechange`),payload:J({id:G().nullable()})}),J({event:Z(`error`),payload:pt}),J({event:Z(`autoplayblocked`),payload:J({})}),J({event:Z(`reconnectstart`),payload:J({attempt:G(),maxAttempts:G(),reason:ut.optional(),nextDelayMs:G().optional()})}),J({event:Z(`reconnectsuccess`),payload:J({attempts:G()})}),J({event:Z(`reconnectfailed`),payload:J({attempts:G(),reason:ut.optional()})}),J({event:Z(`recovery`),payload:kt}),J({event:Z(`compatwarning`),payload:J({code:dt,message:W(),ua:W(),hostVersion:W().optional(),iframeVersion:W().optional(),rejectedEvent:W().optional()})}),J({event:Z(`stalled`),payload:J({phase:Q([`start`,`end`]),position:G(),durationMs:G().optional(),kind:Q([`playback`,`firstframe`,`seek`]).optional()})}),J({event:Z(`playablechange`),payload:J({playable:K(),reason:Et,recoverable:K()})}),J({event:Z(`kernelhealth`),payload:J({degraded:K(),reason:Q([`network`,`media`,`other`]),count:G(),durationMs:G(),detail:W()})}),J({event:Z(`audiohealth`),payload:J({degraded:K(),reason:Z(`audio_data_gap`),durationMs:G()})}),J({event:Z(`bufferhealth`),payload:J({draining:K(),marginSec:G()})}),J({event:Z(`contextchange`),payload:Ct}),J({event:Z(`firstframe`),payload:mt}),J({event:Z(`framefreeze`),payload:ht}),J({event:Z(`useraction`),payload:_t})]);function jt(e,t){return{event:`compatwarning`,payload:{code:`W_EVENT_REJECTED`,message:`收到一条过不了契约校验的事件(${e??`(未知)`}),已丢弃。最常见的成因是 iframe 比宿主新 —— 先看两端契约版本差多少,再怀疑 iframe 有 bug。`,ua:t,...e===void 0?{}:{rejectedEvent:e}}}}let Mt=X(`method`,[J({method:Z(`play`),params:J({}).optional()}),J({method:Z(`pause`),params:J({}).optional()}),J({method:Z(`seek`),params:J({time:G(),type:Q([`exact`,`keyframe`]).optional()})}),J({method:Z(`setVolume`),params:J({volume:G().min(0).max(1)})}),J({method:Z(`setMuted`),params:J({muted:K()})}),J({method:Z(`setPlaybackRate`),params:J({rate:G().min(.25).max(4)})}),J({method:Z(`setQuality`),params:J({level:Y([G(),Z(`auto`)])})}),J({method:Z(`setSubtitle`),params:J({id:Y([G(),Z(`off`)])})}),J({method:Z(`setLocale`),params:J({locale:ot})}),J({method:Z(`load`),params:J({source:at})}),J({method:Z(`reconnect`),params:J({resetCounter:K().optional()}).optional()}),J({method:Z(`pushDanmaku`),params:J({item:st})}),J({method:Z(`setDanmakuEnabled`),params:J({enabled:K()})}),J({method:Z(`clearDanmaku`),params:J({}).optional()}),J({method:Z(`destroy`),params:J({}).optional()}),J({method:Z(`enterFullscreen`),params:J({}).optional()}),J({method:Z(`exitFullscreen`),params:J({}).optional()})]);Q([`command`,`event`,`response`,`error`]);let Nt={version:W(),id:W(),timestamp:G()};function Pt(e,t){return J({...Nt,type:Z(e),payload:t})}let Ft=X(`type`,[Pt(`command`,Mt),Pt(`event`,At),Pt(`response`,J({})),Pt(`error`,pt)]);function It(e){return e||(typeof window<`u`?window:null)}function Lt(e={}){let t=It(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(jt(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=e=>{let t=e;if(r&&!r.has(t.origin)||n&&t.source!==n.contentWindow)return;let i=Ft.safeParse(t.data);if(!i.success){a(t.data);return}i.data.type===`event`&&o(i.data.payload)};t?.addEventListener(`message`,l);let u=(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),()=>u(e,t)},onAny:e=>(c.add(e),()=>c.delete(e)),off:u,destroy:()=>{t?.removeEventListener(`message`,l),s.clear(),c.clear()}}}let Rt=null;function zt(){return Rt||=Lt(),Rt}function Bt(e,t){return zt().on(e,t)}function Vt(e){return zt().onAny(e)}function Ht(e,t){zt().off(e,t)}function Ut(){Rt?.destroy(),Rt=null}return e.createEmbedListener=Lt,e.destroy=Ut,e.off=Ht,e.on=Bt,e.onAny=Vt,e})({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@video-lab/embed-helper",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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": "
|
|
34
|
+
"@video-lab/protocol": "2.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"tsdown": "^0.22.9",
|