/*
 * Copyright 2024 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

(()=>{let e;(l=p||(p={})).Call="call",l.Reply="reply",l.Syn="syn",l.SynAck="synAck",l.Ack="ack",(u=h||(h={})).Fulfilled="fulfilled",u.Rejected="rejected",(c=m||(m={})).ConnectionDestroyed="ConnectionDestroyed",c.ConnectionTimeout="ConnectionTimeout",c.NoIframeSrc="NoIframeSrc",(f||(f={})).DataCloneError="DataCloneError",(v||(v={})).Message="message";var t,r,a,n,i,s,o,d,l,u,c,p,h,m,f,v,g,y,_,E,b,k,x,w,T,N,C,O;let R=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let S=0;let I=e=>e?e.split("."):[],Z=(e,t,r)=>{let a=I(t);return a.reduce(((e,t,n)=>(void 0===e[t]&&(e[t]={}),n===a.length-1&&(e[t]=r),e[t])),e),e},A=(e,t)=>{let r={};return Object.keys(e).forEach((a=>{let n=e[a],i=((e,t)=>{let r=I(t||"");return r.push(e),(e=>e.join("."))(r)})(a,t);"object"==typeof n&&Object.assign(r,A(n,i)),"function"==typeof n&&(r[i]=n)})),r};var P=(e,t,r,a,n)=>{let{localName:i,local:s,remote:o,originForSending:d,originForReceiving:l}=t,u=!1;n(`${i}: Connecting call sender`);let c=e=>(...t)=>{let r;n(`${i}: Sending ${e}() call`);try{o.closed&&(r=!0)}catch(e){r=!0}if(r&&a(),u){let t=Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=m.ConnectionDestroyed,t}return new Promise(((r,a)=>{let u=++S,c=t=>{if(t.source!==o||t.data.penpal!==p.Reply||t.data.id!==u)return;if("*"!==l&&t.origin!==l)return void n(`${i} received message from origin ${t.origin} which did not match expected origin ${l}`);let d=t.data;n(`${i}: Received ${e}() reply`),s.removeEventListener(v.Message,c);let m=d.returnValue;d.returnValueIsError&&(m=(e=>{let t=Error();return Object.keys(e).forEach((r=>t[r]=e[r])),t})(m)),(d.resolution===h.Fulfilled?r:a)(m)};s.addEventListener(v.Message,c);let m={penpal:p.Call,id:u,methodName:e,args:t};o.postMessage(m,d)}))};return Object.assign(e,(e=>{let t={};for(let r in e)Z(t,r,e[r]);return t})(r.reduce(((e,t)=>(e[t]=c(t),e)),{}))),()=>{u=!0}},$=(e,t,r,a)=>{let{destroy:n,onDestroy:i}=r;return r=>{if(!(e instanceof RegExp?e.test(r.origin):"*"===e||e===r.origin))return void a(`Child: Handshake - Received SYN-ACK from origin ${r.origin} which did not match expected origin ${e}`);a("Child: Handshake - Received SYN-ACK, responding with ACK");let s="null"===r.origin?"*":r.origin,o={penpal:p.Ack,methodNames:Object.keys(t)};window.parent.postMessage(o,s);let d={localName:"Child",local:window,remote:window.parent,originForSending:s,originForReceiving:r.origin};i(((e,t,r)=>{let{localName:a,local:n,remote:i,originForSending:s,originForReceiving:o}=e,d=!1,l=e=>{if(e.source!==i||e.data.penpal!==p.Call)return;if("*"!==o&&e.origin!==o)return void r(`${a} received message from origin ${e.origin} which did not match expected origin ${o}`);let{methodName:n,args:l,id:u}=e.data;r(`${a}: Received ${n}() call`);let c=e=>t=>{if(r(`${a}: Sending ${n}() reply`),d)return void r(`${a}: Unable to send ${n}() reply due to destroyed connection`);let o={penpal:p.Reply,id:u,resolution:e,returnValue:t};e===h.Rejected&&t instanceof Error&&(o.returnValue=R(t),o.returnValueIsError=!0);try{i.postMessage(o,s)}catch(e){if(e.name===f.DataCloneError){let t={penpal:p.Reply,id:u,resolution:h.Rejected,returnValue:R(e),returnValueIsError:!0};i.postMessage(t,s)}throw e}};new Promise((e=>e(t[n].apply(t,l)))).then(c(h.Fulfilled),c(h.Rejected))};return n.addEventListener(v.Message,l),()=>{d=!0,n.removeEventListener(v.Message,l)}})(d,t,a));let l={};return i(P(l,d,r.data.methodNames,n,a)),l}};var j=(e={})=>{let{parentOrigin:t="*",methods:r={},timeout:a,debug:n=!1}=e,i=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(n),s=((e,t)=>{let r=[],a=!1;return{destroy(n){a||(a=!0,t(`${e}: Destroying connection`),r.forEach((e=>{e(n)})))},onDestroy(e){a?e():r.push(e)}}})("Child",i),{destroy:o,onDestroy:d}=s,l=$(t,A(r),s,i),u=()=>{i("Child: Handshake - Sending SYN");let e={penpal:p.Syn};window.parent.postMessage(e,t instanceof RegExp?"*":t)};return{promise:new Promise(((e,t)=>{let r=((e,t)=>{let r;return void 0!==e&&(r=window.setTimeout((()=>{let r=Error(`Connection timed out after ${e}ms`);r.code=m.ConnectionTimeout,t(r)}),e)),()=>{clearTimeout(r)}})(a,o),n=t=>{if((()=>{try{clearTimeout()}catch(e){return!1}return!0})()&&t.source===parent&&t.data&&t.data.penpal===p.SynAck){let a=l(t);a&&(window.removeEventListener(v.Message,n),r(),e(a))}};window.addEventListener(v.Message,n),u(),d((e=>{window.removeEventListener(v.Message,n),e&&t(e)}))})),destroy(){o()}}};(t=g||(g={})).DRAFT="draft",t.PUBLISHED="published",t.UNPUBLISHED="unpublished",t.MODIFIED="modified",t.UNKNOWN="unknown",(r=y||(y={})).PAGE="page",r.CONTENT_FRAGMENT="content-fragment",r.EXPERIENCE_FRAGMENT="experience-fragment",r.ASSET="asset",r.TEMPLATE="template",r.POLICIES="policies",r.PRODUCT="product",r.CATALOG="catalog",r.TAG="tag",r.OTHERS="others";let M=Object.freeze({UUID:"id",RESOURCE:"resource",TYPE:"type",PROP:"prop",PARENTID:"parentid",BEHAVIOR:"behavior",LABEL:"label",MODEL:"model",FILTER:"filter"});(a=_||(_={})).EDIT="edit",a.PREVIEW="preview",(n=E||(E={})).TEXT="text",n.MEDIA="media",n.RICHTEXT="richtext",n.REFERENCE="reference",n.CONTAINER="container",n.COMPONENT="component",(i=b||(b={})).TEXT="text",i.MEDIA="media",i.RICHTEXT="richtext",i.REFERENCE="reference",i.CONTAINER="container",i.COMPONENT="component",Object.freeze({BLOCKS:"blocks",FORMAT:"format",ALIGNMENT:"alignment",INDENTATION:"indentation",SR_SCRIPT:"sr_script",LIST:"list",INSERT:"insert",ADVANCED:"advanced",EXTENSIONS:"extensions",EDITOR:"editor"}),(s=k||(k={})).assertEqual=e=>e,s.assertIs=function(e){},s.assertNever=function(e){throw Error()},s.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},s.getValidEnumValues=e=>{let t=s.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),r={};for(let a of t)r[a]=e[a];return s.objectValues(r)},s.objectValues=e=>s.objectKeys(e).map((function(t){return e[t]})),s.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},s.find=(e,t)=>{for(let r of e)if(t(r))return r},s.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,s.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},s.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(x||(x={})).mergeShapes=(e,t)=>({...e,...t});let L=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=e=>{switch(typeof e){case"undefined":return L.undefined;case"string":return L.string;case"number":return isNaN(e)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":return Array.isArray(e)?L.array:null===e?L.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?L.promise:"undefined"!=typeof Map&&e instanceof Map?L.map:"undefined"!=typeof Set&&e instanceof Set?L.set:"undefined"!=typeof Date&&e instanceof Date?L.date:L.object;default:return L.unknown}},U=k.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"]);class V extends Error{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}get errors(){return this.issues}format(e){let t=e||function(e){return e.message},r={_errors:[]},a=e=>{for(let n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)r._errors.push(t(n));else{let e=r,a=0;for(;a<n.path.length;){let r=n.path[a];a===n.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(n))):e[r]=e[r]||{_errors:[]},e=e[r],a++}}};return a(this),r}static assert(e){if(!(e instanceof V))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}V.create=e=>new V(e);let F=(e,t)=>{let r;switch(e.code){case U.invalid_type:r=e.received===L.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case U.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,k.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(e.keys,", ")}`;break;case U.invalid_union:r="Invalid input";break;case U.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(e.options)}`;break;case U.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(e.options)}, received '${e.received}'`;break;case U.invalid_arguments:r="Invalid function arguments";break;case U.invalid_return_type:r="Invalid function return type";break;case U.invalid_date:r="Invalid date";break;case U.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:k.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case U.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`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 U.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case U.custom:r="Invalid input";break;case U.invalid_intersection_types:r="Intersection results could not be merged";break;case U.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case U.not_finite:r="Number must be finite";break;default:r=t.defaultError,k.assertNever(e)}return{message:r}},z=F;function K(){return z}let q=e=>{let{data:t,path:r,errorMaps:a,issueData:n}=e,i=[...r,...n.path||[]],s={...n,path:i};if(void 0!==n.message)return{...n,path:i,message:n.message};let o="";for(let e of a.filter((e=>!!e)).slice().reverse())o=e(s,{data:t,defaultError:o}).message;return{...n,path:i,message:o}};function B(e,t){let r=K(),a=q({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===F?void 0:F].filter((e=>!!e))});e.common.issues.push(a)}class W{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let a of t){if("aborted"===a.status)return H;"dirty"===a.status&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,a=await e.value;r.push({key:t,value:a})}return W.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let a of t){let{key:t,value:n}=a;if("aborted"===t.status||"aborted"===n.status)return H;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==n.value||a.alwaysSet)&&(r[t.value]=n.value)}return{status:e.value,value:r}}}let H=Object.freeze({status:"aborted"}),Y=e=>({status:"dirty",value:e}),X=e=>({status:"valid",value:e}),G=e=>"aborted"===e.status,J=e=>"dirty"===e.status,Q=e=>"valid"===e.status,ee=e=>"undefined"!=typeof Promise&&e instanceof Promise;function te(e,t,r,a){if("a"===r&&!a)throw TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?a:"a"===r?a.call(e):a?a.value:t.get(e)}function re(e,t,r,a,n){if("m"===a)throw TypeError("Private method is not writable");if("a"===a&&!n)throw TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,r):n?n.value=r:t.set(e,r),r}"function"==typeof SuppressedError&&SuppressedError,(o=w||(w={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},o.toString=e=>"string"==typeof e?e:null==e?void 0:e.message;class ae{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}let ne=(e,t)=>{if(Q(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 V(e.common.issues);return this._error=t,this._error}}};function ie(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:n}=e;if(t&&(r||a))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:n}:{errorMap:(t,n)=>{var i,s;let{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:n.defaultError}:void 0===n.data?{message:null!==(i=null!=o?o:a)&&void 0!==i?i:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(s=null!=o?o:r)&&void 0!==s?s:n.defaultError}},description:n}}class se{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)}get description(){return this._def.description}_getType(e){return D(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new W,ctx:{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ee(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;let a={common:{issues:[],async:null!==(r=null==t?void 0:t.async)&&void 0!==r&&r,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},n=this._parseSync({data:e,path:a.path,parent:a});return ne(a,n)}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},a=this._parse({data:e,path:r.path,parent:r});return ne(r,await(ee(a)?a:Promise.resolve(a)))}refine(e,t){let r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{let n=e(t),i=()=>a.addIssue({code:U.custom,...r(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(i(),!1))):!!n||(i(),!1)}))}refinement(e,t){return this._refinement(((r,a)=>!!e(r)||(a.addIssue("function"==typeof t?t(r,a):t),!1)))}_refinement(e){return new Xe({schema:this,typeName:C.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Ge.create(this,this._def)}nullable(){return Je.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ae.create(this,this._def)}promise(){return Ye.create(this,this._def)}or(e){return $e.create([this,e],this._def)}and(e){return Le.create(this,e,this._def)}transform(e){return new Xe({...ie(this._def),schema:this,typeName:C.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new Qe({...ie(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:C.ZodDefault})}brand(){return new at({typeName:C.ZodBranded,type:this,...ie(this._def)})}catch(e){return new et({...ie(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:C.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return nt.create(this,e)}readonly(){return it.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let oe=/^c[^\s-]{8,}$/i,de=/^[0-9a-z]+$/,le=/^[0-9A-HJKMNP-TV-Z]{26}$/,ue=/^[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,pe=/^[-+]?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)?)??$/,he=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,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])$/,fe=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ve=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ge="((\\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])))",ye=RegExp(`^${ge}$`);function _e(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function Ee(e){let t=`${ge}T${_e(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)}class be extends se{_parse(t){var r,a;let n;if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==L.string){let e=this._getOrReturnCtx(t);return B(e,{code:U.invalid_type,expected:L.string,received:e.parsedType}),H}let i=new W;for(let s of this._def.checks)if("min"===s.kind)t.data.length<s.value&&(B(n=this._getOrReturnCtx(t,n),{code:U.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if("max"===s.kind)t.data.length>s.value&&(B(n=this._getOrReturnCtx(t,n),{code:U.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if("length"===s.kind){let e=t.data.length>s.value,r=t.data.length<s.value;(e||r)&&(n=this._getOrReturnCtx(t,n),e?B(n,{code:U.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):r&&B(n,{code:U.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),i.dirty())}else if("email"===s.kind)he.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"email",code:U.invalid_string,message:s.message}),i.dirty());else if("emoji"===s.kind)e||(e=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),e.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"emoji",code:U.invalid_string,message:s.message}),i.dirty());else if("uuid"===s.kind)ue.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"uuid",code:U.invalid_string,message:s.message}),i.dirty());else if("nanoid"===s.kind)ce.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"nanoid",code:U.invalid_string,message:s.message}),i.dirty());else if("cuid"===s.kind)oe.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"cuid",code:U.invalid_string,message:s.message}),i.dirty());else if("cuid2"===s.kind)de.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"cuid2",code:U.invalid_string,message:s.message}),i.dirty());else if("ulid"===s.kind)le.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"ulid",code:U.invalid_string,message:s.message}),i.dirty());else if("url"===s.kind)try{new URL(t.data)}catch(e){B(n=this._getOrReturnCtx(t,n),{validation:"url",code:U.invalid_string,message:s.message}),i.dirty()}else"regex"===s.kind?(s.regex.lastIndex=0,s.regex.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"regex",code:U.invalid_string,message:s.message}),i.dirty())):"trim"===s.kind?t.data=t.data.trim():"includes"===s.kind?t.data.includes(s.value,s.position)||(B(n=this._getOrReturnCtx(t,n),{code:U.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),i.dirty()):"toLowerCase"===s.kind?t.data=t.data.toLowerCase():"toUpperCase"===s.kind?t.data=t.data.toUpperCase():"startsWith"===s.kind?t.data.startsWith(s.value)||(B(n=this._getOrReturnCtx(t,n),{code:U.invalid_string,validation:{startsWith:s.value},message:s.message}),i.dirty()):"endsWith"===s.kind?t.data.endsWith(s.value)||(B(n=this._getOrReturnCtx(t,n),{code:U.invalid_string,validation:{endsWith:s.value},message:s.message}),i.dirty()):"datetime"===s.kind?Ee(s).test(t.data)||(B(n=this._getOrReturnCtx(t,n),{code:U.invalid_string,validation:"datetime",message:s.message}),i.dirty()):"date"===s.kind?ye.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{code:U.invalid_string,validation:"date",message:s.message}),i.dirty()):"time"===s.kind?RegExp(`^${_e(s)}$`).test(t.data)||(B(n=this._getOrReturnCtx(t,n),{code:U.invalid_string,validation:"time",message:s.message}),i.dirty()):"duration"===s.kind?pe.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"duration",code:U.invalid_string,message:s.message}),i.dirty()):"ip"===s.kind?(r=t.data,("v4"===(a=s.version)||!a)&&me.test(r)||("v6"===a||!a)&&fe.test(r)||(B(n=this._getOrReturnCtx(t,n),{validation:"ip",code:U.invalid_string,message:s.message}),i.dirty())):"base64"===s.kind?ve.test(t.data)||(B(n=this._getOrReturnCtx(t,n),{validation:"base64",code:U.invalid_string,message:s.message}),i.dirty()):k.assertNever(s);return{status:i.value,value:t.data}}_regex(e,t,r){return this.refinement((t=>e.test(t)),{validation:t,code:U.invalid_string,...w.errToObj(r)})}_addCheck(e){return new be({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var t,r;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(r=null==e?void 0:e.local)&&void 0!==r&&r,...w.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...w.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...w.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new be({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new be({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new be({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}be.create=e=>{var t;return new be({checks:[],typeName:C.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...ie(e)})};class ke extends se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==L.number){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.number,received:t.parsedType}),H}let r=new W;for(let a of this._def.checks)"int"===a.kind?k.isInteger(e.data)||(B(t=this._getOrReturnCtx(e,t),{code:U.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):"min"===a.kind?(a.inclusive?e.data<a.value:e.data<=a.value)&&(B(t=this._getOrReturnCtx(e,t),{code:U.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):"max"===a.kind?(a.inclusive?e.data>a.value:e.data>=a.value)&&(B(t=this._getOrReturnCtx(e,t),{code:U.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):"multipleOf"===a.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=r>a?r:a;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}(e.data,a.value)&&(B(t=this._getOrReturnCtx(e,t),{code:U.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):"finite"===a.kind?Number.isFinite(e.data)||(B(t=this._getOrReturnCtx(e,t),{code:U.not_finite,message:a.message}),r.dirty()):k.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,a){return new ke({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(a)}]})}_addCheck(e){return new ke({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&k.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(let r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ke.create=e=>new ke({checks:[],typeName:C.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...ie(e)});class xe extends se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==L.bigint){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.bigint,received:t.parsedType}),H}let r=new W;for(let a of this._def.checks)"min"===a.kind?(a.inclusive?e.data<a.value:e.data<=a.value)&&(B(t=this._getOrReturnCtx(e,t),{code:U.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):"max"===a.kind?(a.inclusive?e.data>a.value:e.data>=a.value)&&(B(t=this._getOrReturnCtx(e,t),{code:U.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):"multipleOf"===a.kind?e.data%a.value!==BigInt(0)&&(B(t=this._getOrReturnCtx(e,t),{code:U.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):k.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,r,a){return new xe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:w.toString(a)}]})}_addCheck(e){return new xe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}xe.create=e=>{var t;return new xe({checks:[],typeName:C.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...ie(e)})};class we extends se{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==L.boolean){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.boolean,received:t.parsedType}),H}return X(e.data)}}we.create=e=>new we({typeName:C.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...ie(e)});class Te extends se{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==L.date){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.date,received:t.parsedType}),H}if(isNaN(e.data.getTime()))return B(this._getOrReturnCtx(e),{code:U.invalid_date}),H;let r=new W;for(let a of this._def.checks)"min"===a.kind?e.data.getTime()<a.value&&(B(t=this._getOrReturnCtx(e,t),{code:U.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):"max"===a.kind?e.data.getTime()>a.value&&(B(t=this._getOrReturnCtx(e,t),{code:U.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):k.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Te({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Te.create=e=>new Te({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:C.ZodDate,...ie(e)});class Ne extends se{_parse(e){if(this._getType(e)!==L.symbol){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.symbol,received:t.parsedType}),H}return X(e.data)}}Ne.create=e=>new Ne({typeName:C.ZodSymbol,...ie(e)});class Ce extends se{_parse(e){if(this._getType(e)!==L.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.undefined,received:t.parsedType}),H}return X(e.data)}}Ce.create=e=>new Ce({typeName:C.ZodUndefined,...ie(e)});class Oe extends se{_parse(e){if(this._getType(e)!==L.null){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.null,received:t.parsedType}),H}return X(e.data)}}Oe.create=e=>new Oe({typeName:C.ZodNull,...ie(e)});class Re extends se{constructor(){super(...arguments),this._any=!0}_parse(e){return X(e.data)}}Re.create=e=>new Re({typeName:C.ZodAny,...ie(e)});class Se extends se{constructor(){super(...arguments),this._unknown=!0}_parse(e){return X(e.data)}}Se.create=e=>new Se({typeName:C.ZodUnknown,...ie(e)});class Ie extends se{_parse(e){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.never,received:t.parsedType}),H}}Ie.create=e=>new Ie({typeName:C.ZodNever,...ie(e)});class Ze extends se{_parse(e){if(this._getType(e)!==L.undefined){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.void,received:t.parsedType}),H}return X(e.data)}}Ze.create=e=>new Ze({typeName:C.ZodVoid,...ie(e)});class Ae extends se{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==L.array)return B(t,{code:U.invalid_type,expected:L.array,received:t.parsedType}),H;if(null!==a.exactLength){let e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(B(t,{code:e?U.too_big:U.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(B(t,{code:U.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(B(t,{code:U.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map(((e,r)=>a.type._parseAsync(new ae(t,e,t.path,r))))).then((e=>W.mergeArray(r,e)));let n=[...t.data].map(((e,r)=>a.type._parseSync(new ae(t,e,t.path,r))));return W.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new Ae({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new Ae({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new Ae({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}Ae.create=(e,t)=>new Ae({type:e,minLength:null,maxLength:null,exactLength:null,typeName:C.ZodArray,...ie(t)});class Pe extends se{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==L.object){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.object,received:t.parsedType}),H}let{status:t,ctx:r}=this._processInputParams(e),{shape:a,keys:n}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ie&&"strip"===this._def.unknownKeys))for(let e in r.data)n.includes(e)||i.push(e);let s=[];for(let e of n){let t=a[e],n=r.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new ae(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof Ie){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of i)s.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)i.length>0&&(B(r,{code:U.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of i){let a=r.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new ae(r,a,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then((async()=>{let e=[];for(let t of s){let r=await t.key,a=await t.value;e.push({key:r,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>W.mergeObjectSync(t,e))):W.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new Pe({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{var a,n,i,s;let o=null!==(i=null===(n=(a=this._def).errorMap)||void 0===n?void 0:n.call(a,t,r).message)&&void 0!==i?i:r.defaultError;return"unrecognized_keys"===t.code?{message:null!==(s=w.errToObj(e).message)&&void 0!==s?s:o}:{message:o}}}:{}})}strip(){return new Pe({...this._def,unknownKeys:"strip"})}passthrough(){return new Pe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Pe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Pe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:C.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Pe({...this._def,catchall:e})}pick(e){let t={};return k.objectKeys(e).forEach((r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])})),new Pe({...this._def,shape:()=>t})}omit(e){let t={};return k.objectKeys(this.shape).forEach((r=>{e[r]||(t[r]=this.shape[r])})),new Pe({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof Pe){let r={};for(let a in t.shape){let n=t.shape[a];r[a]=Ge.create(e(n))}return new Pe({...t._def,shape:()=>r})}return t instanceof Ae?new Ae({...t._def,type:e(t.element)}):t instanceof Ge?Ge.create(e(t.unwrap())):t instanceof Je?Je.create(e(t.unwrap())):t instanceof De?De.create(t.items.map((t=>e(t)))):t}(this)}partial(e){let t={};return k.objectKeys(this.shape).forEach((r=>{let a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()})),new Pe({...this._def,shape:()=>t})}required(e){let t={};return k.objectKeys(this.shape).forEach((r=>{if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof Ge;)e=e._def.innerType;t[r]=e}})),new Pe({...this._def,shape:()=>t})}keyof(){return Be(k.objectKeys(this.shape))}}Pe.create=(e,t)=>new Pe({shape:()=>e,unknownKeys:"strip",catchall:Ie.create(),typeName:C.ZodObject,...ie(t)}),Pe.strictCreate=(e,t)=>new Pe({shape:()=>e,unknownKeys:"strict",catchall:Ie.create(),typeName:C.ZodObject,...ie(t)}),Pe.lazycreate=(e,t)=>new Pe({shape:e,unknownKeys:"strip",catchall:Ie.create(),typeName:C.ZodObject,...ie(t)});class $e extends se{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map((async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}}))).then((function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map((e=>new V(e.ctx.common.issues)));return B(t,{code:U.invalid_union,unionErrors:r}),H}));{let e,a=[];for(let n of r){let r={...t,common:{...t.common,issues:[]},parent:null},i=n._parseSync({data:t.data,path:t.path,parent:r});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:r}),r.common.issues.length&&a.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let n=a.map((e=>new V(e)));return B(t,{code:U.invalid_union,unionErrors:n}),H}}get options(){return this._def.options}}$e.create=(e,t)=>new $e({options:e,typeName:C.ZodUnion,...ie(t)});let je=e=>e instanceof Ke?je(e.schema):e instanceof Xe?je(e.innerType()):e instanceof qe?[e.value]:e instanceof We?e.options:e instanceof He?k.objectValues(e.enum):e instanceof Qe?je(e._def.innerType):e instanceof Ce?[void 0]:e instanceof Oe?[null]:e instanceof Ge?[void 0,...je(e.unwrap())]:e instanceof Je?[null,...je(e.unwrap())]:e instanceof at||e instanceof it?je(e.unwrap()):e instanceof et?je(e._def.innerType):[];class Me extends se{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.object)return B(t,{code:U.invalid_type,expected:L.object,received:t.parsedType}),H;let r=this.discriminator,a=t.data[r],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(B(t,{code:U.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),H)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let a=new Map;for(let r of t){let t=je(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let n of t){if(a.has(n))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,r)}}return new Me({typeName:C.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...ie(r)})}}class Le extends se{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=(e,a)=>{if(G(e)||G(a))return H;let n=function e(t,r){let a=D(t),n=D(r);if(t===r)return{valid:!0,data:t};if(a===L.object&&n===L.object){let a=k.objectKeys(r),n=k.objectKeys(t).filter((e=>-1!==a.indexOf(e))),i={...t,...r};for(let a of n){let n=e(t[a],r[a]);if(!n.valid)return{valid:!1};i[a]=n.data}return{valid:!0,data:i}}if(a===L.array&&n===L.array){if(t.length!==r.length)return{valid:!1};let a=[];for(let n=0;n<t.length;n++){let i=e(t[n],r[n]);if(!i.valid)return{valid:!1};a.push(i.data)}return{valid:!0,data:a}}return a===L.date&&n===L.date&&+t==+r?{valid:!0,data:t}:{valid:!1}}(e.value,a.value);return n.valid?((J(e)||J(a))&&t.dirty(),{status:t.value,value:n.data}):(B(r,{code:U.invalid_intersection_types}),H)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Le.create=(e,t,r)=>new Le({left:e,right:t,typeName:C.ZodIntersection,...ie(r)});class De extends se{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==L.array)return B(r,{code:U.invalid_type,expected:L.array,received:r.parsedType}),H;if(r.data.length<this._def.items.length)return B(r,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),H;!this._def.rest&&r.data.length>this._def.items.length&&(B(r,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...r.data].map(((e,t)=>{let a=this._def.items[t]||this._def.rest;return a?a._parse(new ae(r,e,r.path,t)):null})).filter((e=>!!e));return r.common.async?Promise.all(a).then((e=>W.mergeArray(t,e))):W.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new De({...this._def,rest:e})}}De.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new De({items:e,typeName:C.ZodTuple,rest:null,...ie(t)})};class Ue extends se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==L.object)return B(r,{code:U.invalid_type,expected:L.object,received:r.parsedType}),H;let a=[],n=this._def.keyType,i=this._def.valueType;for(let e in r.data)a.push({key:n._parse(new ae(r,e,r.path,e)),value:i._parse(new ae(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?W.mergeObjectAsync(t,a):W.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return new Ue(t instanceof se?{keyType:e,valueType:t,typeName:C.ZodRecord,...ie(r)}:{keyType:be.create(),valueType:e,typeName:C.ZodRecord,...ie(t)})}}class Ve extends se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==L.map)return B(r,{code:U.invalid_type,expected:L.map,received:r.parsedType}),H;let a=this._def.keyType,n=this._def.valueType,i=[...r.data.entries()].map((([e,t],i)=>({key:a._parse(new ae(r,e,r.path,[i,"key"])),value:n._parse(new ae(r,t,r.path,[i,"value"]))})));if(r.common.async){let e=new Map;return Promise.resolve().then((async()=>{for(let r of i){let a=await r.key,n=await r.value;if("aborted"===a.status||"aborted"===n.status)return H;("dirty"===a.status||"dirty"===n.status)&&t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}))}{let e=new Map;for(let r of i){let a=r.key,n=r.value;if("aborted"===a.status||"aborted"===n.status)return H;("dirty"===a.status||"dirty"===n.status)&&t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}Ve.create=(e,t,r)=>new Ve({valueType:t,keyType:e,typeName:C.ZodMap,...ie(r)});class Fe extends se{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==L.set)return B(r,{code:U.invalid_type,expected:L.set,received:r.parsedType}),H;let a=this._def;null!==a.minSize&&r.data.size<a.minSize.value&&(B(r,{code:U.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&r.data.size>a.maxSize.value&&(B(r,{code:U.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());let n=this._def.valueType;function i(e){let r=new Set;for(let a of e){if("aborted"===a.status)return H;"dirty"===a.status&&t.dirty(),r.add(a.value)}return{status:t.value,value:r}}let s=[...r.data.values()].map(((e,t)=>n._parse(new ae(r,e,r.path,t))));return r.common.async?Promise.all(s).then((e=>i(e))):i(s)}min(e,t){return new Fe({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new Fe({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Fe.create=(e,t)=>new Fe({valueType:e,minSize:null,maxSize:null,typeName:C.ZodSet,...ie(t)});class ze extends se{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.function)return B(t,{code:U.invalid_type,expected:L.function,received:t.parsedType}),H;function r(e,r){return q({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,K(),F].filter((e=>!!e)),issueData:{code:U.invalid_arguments,argumentsError:r}})}function a(e,r){return q({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,K(),F].filter((e=>!!e)),issueData:{code:U.invalid_return_type,returnTypeError:r}})}let n={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ye){let e=this;return X((async function(...t){let s=new V([]),o=await e._def.args.parseAsync(t,n).catch((e=>{throw s.addIssue(r(t,e)),s})),d=await Reflect.apply(i,this,o);return await e._def.returns._def.type.parseAsync(d,n).catch((e=>{throw s.addIssue(a(d,e)),s}))}))}{let e=this;return X((function(...t){let s=e._def.args.safeParse(t,n);if(!s.success)throw new V([r(t,s.error)]);let o=Reflect.apply(i,this,s.data),d=e._def.returns.safeParse(o,n);if(!d.success)throw new V([a(o,d.error)]);return d.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ze({...this._def,args:De.create(e).rest(Se.create())})}returns(e){return new ze({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new ze({args:e||De.create([]).rest(Se.create()),returns:t||Se.create(),typeName:C.ZodFunction,...ie(r)})}}class Ke extends se{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})}}Ke.create=(e,t)=>new Ke({getter:e,typeName:C.ZodLazy,...ie(t)});class qe extends se{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:U.invalid_literal,expected:this._def.value}),H}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Be(e,t){return new We({values:e,typeName:C.ZodEnum,...ie(t)})}qe.create=(e,t)=>new qe({value:e,typeName:C.ZodLiteral,...ie(t)});class We extends se{constructor(){super(...arguments),T.set(this,void 0)}_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return B(t,{expected:k.joinValues(r),received:t.parsedType,code:U.invalid_type}),H}if(te(this,T,"f")||re(this,T,new Set(this._def.values),"f"),!te(this,T,"f").has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return B(t,{received:t.data,code:U.invalid_enum_value,options:r}),H}return X(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(e,t=this._def){return We.create(e,{...this._def,...t})}exclude(e,t=this._def){return We.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}T=new WeakMap,We.create=Be;class He extends se{constructor(){super(...arguments),N.set(this,void 0)}_parse(e){let t=k.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==L.string&&r.parsedType!==L.number){let e=k.objectValues(t);return B(r,{expected:k.joinValues(e),received:r.parsedType,code:U.invalid_type}),H}if(te(this,N,"f")||re(this,N,new Set(k.getValidEnumValues(this._def.values)),"f"),!te(this,N,"f").has(e.data)){let e=k.objectValues(t);return B(r,{received:r.data,code:U.invalid_enum_value,options:e}),H}return X(e.data)}get enum(){return this._def.values}}N=new WeakMap,He.create=(e,t)=>new He({values:e,typeName:C.ZodNativeEnum,...ie(t)});class Ye extends se{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==L.promise&&!1===t.common.async?(B(t,{code:U.invalid_type,expected:L.promise,received:t.parsedType}),H):X((t.parsedType===L.promise?t.data:Promise.resolve(t.data)).then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}Ye.create=(e,t)=>new Ye({type:e,typeName:C.ZodPromise,...ie(t)});class Xe extends se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===C.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:e=>{B(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===a.type){let e=a.transform(r.data,n);if(r.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return H;let a=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===a.status?H:"dirty"===a.status||"dirty"===t.value?Y(a.value):a}));{if("aborted"===t.value)return H;let a=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===a.status?H:"dirty"===a.status||"dirty"===t.value?Y(a.value):a}}if("refinement"===a.type){let e=e=>{let t=a.refinement(e,n);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(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((r=>"aborted"===r.status?H:("dirty"===r.status&&t.dirty(),e(r.value).then((()=>({status:t.value,value:r.value}))))));{let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===a.status?H:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}}if("transform"===a.type){if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then((e=>Q(e)?Promise.resolve(a.transform(e.value,n)).then((e=>({status:t.value,value:e}))):e));{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Q(e))return e;let i=a.transform(e.value,n);if(i instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}}k.assertNever(a)}}Xe.create=(e,t,r)=>new Xe({schema:e,typeName:C.ZodEffects,effect:t,...ie(r)}),Xe.createWithPreprocess=(e,t,r)=>new Xe({schema:t,effect:{type:"preprocess",transform:e},typeName:C.ZodEffects,...ie(r)});class Ge extends se{_parse(e){return this._getType(e)===L.undefined?X(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ge.create=(e,t)=>new Ge({innerType:e,typeName:C.ZodOptional,...ie(t)});class Je extends se{_parse(e){return this._getType(e)===L.null?X(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Je.create=(e,t)=>new Je({innerType:e,typeName:C.ZodNullable,...ie(t)});class Qe extends se{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===L.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Qe.create=(e,t)=>new Qe({innerType:e,typeName:C.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...ie(t)});class et extends se{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ee(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new V(r.common.issues)},input:r.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new V(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}et.create=(e,t)=>new et({innerType:e,typeName:C.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...ie(t)});class tt extends se{_parse(e){if(this._getType(e)!==L.nan){let t=this._getOrReturnCtx(e);return B(t,{code:U.invalid_type,expected:L.nan,received:t.parsedType}),H}return{status:"valid",value:e.data}}}tt.create=e=>new tt({typeName:C.ZodNaN,...ie(e)});let rt=Symbol("zod_brand");class at extends se{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class nt extends se{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?H:"dirty"===e.status?(t.dirty(),Y(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?H:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new nt({in:e,out:t,typeName:C.ZodPipeline})}}class it extends se{_parse(e){let t=this._def.innerType._parse(e),r=e=>(Q(e)&&(e.value=Object.freeze(e.value)),e);return ee(t)?t.then((e=>r(e))):r(t)}unwrap(){return this._def.innerType}}function st(e,t={},r){return e?Re.create().superRefine(((a,n)=>{var i,s;if(!e(a)){let e="function"==typeof t?t(a):"string"==typeof t?{message:t}:t,o=null===(s=null!==(i=e.fatal)&&void 0!==i?i:r)||void 0===s||s,d="string"==typeof e?{message:e}:e;n.addIssue({code:"custom",...d,fatal:o})}})):Re.create()}it.create=(e,t)=>new it({innerType:e,typeName:C.ZodReadonly,...ie(t)});let ot={object:Pe.lazycreate};(d=C||(C={})).ZodString="ZodString",d.ZodNumber="ZodNumber",d.ZodNaN="ZodNaN",d.ZodBigInt="ZodBigInt",d.ZodBoolean="ZodBoolean",d.ZodDate="ZodDate",d.ZodSymbol="ZodSymbol",d.ZodUndefined="ZodUndefined",d.ZodNull="ZodNull",d.ZodAny="ZodAny",d.ZodUnknown="ZodUnknown",d.ZodNever="ZodNever",d.ZodVoid="ZodVoid",d.ZodArray="ZodArray",d.ZodObject="ZodObject",d.ZodUnion="ZodUnion",d.ZodDiscriminatedUnion="ZodDiscriminatedUnion",d.ZodIntersection="ZodIntersection",d.ZodTuple="ZodTuple",d.ZodRecord="ZodRecord",d.ZodMap="ZodMap",d.ZodSet="ZodSet",d.ZodFunction="ZodFunction",d.ZodLazy="ZodLazy",d.ZodLiteral="ZodLiteral",d.ZodEnum="ZodEnum",d.ZodEffects="ZodEffects",d.ZodNativeEnum="ZodNativeEnum",d.ZodOptional="ZodOptional",d.ZodNullable="ZodNullable",d.ZodDefault="ZodDefault",d.ZodCatch="ZodCatch",d.ZodPromise="ZodPromise",d.ZodBranded="ZodBranded",d.ZodPipeline="ZodPipeline",d.ZodReadonly="ZodReadonly";let dt=be.create,lt=ke.create,ut=tt.create,ct=xe.create,pt=we.create,ht=Te.create,mt=Ne.create,ft=Ce.create,vt=Oe.create,gt=Re.create,yt=Se.create,_t=Ie.create,Et=Ze.create,bt=Ae.create,kt=Pe.create,xt=Pe.strictCreate,wt=$e.create,Tt=Me.create,Nt=Le.create,Ct=De.create,Ot=Ue.create,Rt=Ve.create,St=Fe.create,It=ze.create,Zt=Ke.create,At=qe.create,Pt=We.create,$t=He.create,jt=Ye.create,Mt=Xe.create,Lt=Ge.create,Dt=Je.create,Ut=Xe.createWithPreprocess,Vt=nt.create;var Ft=Object.freeze({__proto__:null,defaultErrorMap:F,setErrorMap:function(e){z=e},getErrorMap:K,makeIssue:q,EMPTY_PATH:[],addIssueToContext:B,ParseStatus:W,INVALID:H,DIRTY:Y,OK:X,isAborted:G,isDirty:J,isValid:Q,isAsync:ee,get util(){return k},get objectUtil(){return x},ZodParsedType:L,getParsedType:D,ZodType:se,datetimeRegex:Ee,ZodString:be,ZodNumber:ke,ZodBigInt:xe,ZodBoolean:we,ZodDate:Te,ZodSymbol:Ne,ZodUndefined:Ce,ZodNull:Oe,ZodAny:Re,ZodUnknown:Se,ZodNever:Ie,ZodVoid:Ze,ZodArray:Ae,ZodObject:Pe,ZodUnion:$e,ZodDiscriminatedUnion:Me,ZodIntersection:Le,ZodTuple:De,ZodRecord:Ue,ZodMap:Ve,ZodSet:Fe,ZodFunction:ze,ZodLazy:Ke,ZodLiteral:qe,ZodEnum:We,ZodNativeEnum:He,ZodPromise:Ye,ZodEffects:Xe,ZodTransformer:Xe,ZodOptional:Ge,ZodNullable:Je,ZodDefault:Qe,ZodCatch:et,ZodNaN:tt,BRAND:rt,ZodBranded:at,ZodPipeline:nt,ZodReadonly:it,custom:st,Schema:se,ZodSchema:se,late:ot,get ZodFirstPartyTypeKind(){return C},coerce:{string:e=>be.create({...e,coerce:!0}),number:e=>ke.create({...e,coerce:!0}),boolean:e=>we.create({...e,coerce:!0}),bigint:e=>xe.create({...e,coerce:!0}),date:e=>Te.create({...e,coerce:!0})},any:gt,array:bt,bigint:ct,boolean:pt,date:ht,discriminatedUnion:Tt,effect:Mt,enum:Pt,function:It,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>st((t=>t instanceof e),t),intersection:Nt,lazy:Zt,literal:At,map:Rt,nan:ut,nativeEnum:$t,never:_t,null:vt,nullable:Dt,number:lt,object:kt,oboolean:()=>pt().optional(),onumber:()=>lt().optional(),optional:Lt,ostring:()=>dt().optional(),pipeline:Vt,preprocess:Ut,promise:jt,record:Ot,set:St,strictObject:xt,string:dt,symbol:mt,transformer:Mt,tuple:Ct,undefined:ft,union:wt,unknown:yt,void:Et,NEVER:H,ZodIssueCode:U,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:V});let zt=Ft.enum(["0","1","2","3","4","5","6","7","8","9"]),Kt=Ft.enum(["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]),qt=Ft.enum(["minus","equal","bracketleft","bracketright","backslash","semicolon","quote","comma","period","slash","backquote","enter","escape","backspace","tab","insert","home","end","pageup","pagedown","delete","arrowup","arrowdown","arrowleft","arrowright"]);Ft.union([zt,Kt,qt]);let Bt=Ft.enum(["shift+ctrl+","shift+alt+","shift+cmd+","ctrl+alt+","ctrl+cmd+","alt+cmd+","shift+ctrl+alt+","shift+ctrl+cmd+","shift+alt+cmd+","ctrl+alt+cmd+","shift+ctrl+alt+cmd+","shift+","ctrl+","alt+","cmd+",""]),Wt="urn:adobe:aue:",Ht=`meta[name^='${Wt}']`,Yt=`meta[name='${Wt}config:namespace']`,Xt=(M.TYPE,{URN_PREFIX:Wt,META_SELECTOR:Ht,META_NAMESPACE:Yt,USER_INPUT_RELAY_MESSAGE:"REMOTE_APP_USER_INPUT",DEFAULT_PREFIX:"data-aue-",COMPONENT_ITEM_TYPE:"component",RTE_URL:"https://exc-unifiedcontent.experience.adobe.net/solutions/CQ-aem-headless-rte/assets/tinymce-684/js/tinymce/tinymce.min.js",EVENT_APP_INITIALIZED:"aue:initialized",EVENT_UI_SELECT:"aue:ui-select",EVENT_UI_PREVIEW:"aue:ui-preview",EVENT_UI_EDIT:"aue:ui-edit",EVENT_CONTENT_MOVE:"aue:content-move",EVENT_CONTENT_ADD:"aue:content-add",EVENT_CONTENT_COPY:"aue:content-copy",EVENT_CONTENT_PATCH:"aue:content-patch",EVENT_CONTENT_REMOVE:"aue:content-remove"});Bt.options,zt.options,Kt.options,qt.options;var Gt;function Jt(e,t,r){function a(){var l=Date.now()-o;l<t&&l>=0?n=setTimeout(a,t-l):(n=null,r||(d=e.apply(s,i),s=i=null))}null==t&&(t=100);var n,i,s,o,d,l=function(){s=this,i=arguments,o=Date.now();var l=r&&!n;return n||(n=setTimeout(a,t)),l&&(d=e.apply(s,i),s=i=null),d};return l.clear=function(){n&&(clearTimeout(n),n=null)},l.flush=function(){n&&(d=e.apply(s,i),s=i=null,clearTimeout(n),n=null)},l}Jt.debounce=Jt,Gt=Jt;let Qt={element:window.document},er=(e=Xt.DEFAULT_PREFIX)=>{let t={};for(let r in M)t[r]=`${e}${M[r]}`;return t},tr=(e,t)=>{var r;if(!(e&&e instanceof HTMLElement&&t))return"";let a="";return t===b.TEXT?a=e.textContent||e.innerText:t===b.RICHTEXT?a=e.innerHTML:t===b.MEDIA&&(a=null!==(r=e.getAttribute("src"))&&void 0!==r?r:""),a},rr="OverlayBlockingElement",ar=()=>{nr(),(()=>{let e=document.createElement("div");e.id=rr,e.style.cssText="\n    position: fixed;\n    top: 0;\n    left: 0;\n    width: 100%;\n    height: 100%;\n    z-index: 2147483647;",document.body.appendChild(e)})()},nr=()=>{let e=document.getElementById(rr);e&&e.remove()},ir=({element:e,callback:t})=>{let r=new MutationObserver(t);return r.observe(e,{attributes:!0,characterData:!0,childList:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),r.disconnect};var sr=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;let or=[];for(let e=0;e<256;++e)or.push((e+256).toString(16).slice(1));function dr(e,t){return e<<t|e>>>32-t}let lr=function(){function e(e,t,r,a){var n;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}(e)),"string"==typeof t&&(t=function(e){let t;if("string"!=typeof e||!sr.test(e))throw TypeError("Invalid UUID");let r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r}(t)),16!==(null===(n=t)||void 0===n?void 0:n.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let i=new Uint8Array(16+e.length);if(i.set(t),i.set(e,t.length),(i=function(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){let t=unescape(encodeURIComponent(e));e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);let a=Math.ceil((e.length/4+2)/16),n=Array(a);for(let t=0;t<a;++t){let r=new Uint32Array(16);for(let a=0;a<16;++a)r[a]=e[64*t+4*a]<<24|e[64*t+4*a+1]<<16|e[64*t+4*a+2]<<8|e[64*t+4*a+3];n[t]=r}n[a-1][14]=8*(e.length-1)/4294967296,n[a-1][14]=Math.floor(n[a-1][14]),n[a-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<a;++e){let a=new Uint32Array(80);for(let t=0;t<16;++t)a[t]=n[e][t];for(let e=16;e<80;++e)a[e]=dr(a[e-3]^a[e-8]^a[e-14]^a[e-16],1);let i=r[0],s=r[1],o=r[2],d=r[3],l=r[4];for(let e=0;e<80;++e){let r=Math.floor(e/20),n=dr(i,5)+function(e,t,r,a){switch(e){case 0:return t&r^~t&a;case 1:case 3:return t^r^a;case 2:return t&r^t&a^r&a}}(r,s,o,d)+l+t[r]+a[e]>>>0;l=d,d=o,o=dr(s,30)>>>0,s=i,i=n}r[0]=r[0]+i>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+o>>>0,r[3]=r[3]+d>>>0,r[4]=r[4]+l>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]}(i))[6]=15&i[6]|80,i[8]=63&i[8]|128,r){a=a||0;for(let e=0;e<16;++e)r[a+e]=i[e];return r}return function(e,t=0){return or[e[t+0]]+or[e[t+1]]+or[e[t+2]]+or[e[t+3]]+"-"+or[e[t+4]]+or[e[t+5]]+"-"+or[e[t+6]]+or[e[t+7]]+"-"+or[e[t+8]]+or[e[t+9]]+"-"+or[e[t+10]]+or[e[t+11]]+or[e[t+12]]+or[e[t+13]]+or[e[t+14]]+or[e[t+15]]}(i)}try{e.name="v5"}catch(e){}return e.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",e.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",e}(),ur=(e,t,{resource:r,prop:a})=>{var n,i;let s=[r,a].filter((e=>!!e)).join("_"),o=lr(s,lr.URL),d=t.get(o);return(null===(i=null===(n=null==d?void 0:d.copyInfo)||void 0===n?void 0:n.copies)||void 0===i?void 0:i.length)&&document.querySelectorAll(d.selector).forEach(((t,r)=>{t===e&&(o=lr(`${s}_${r}`,lr.URL))})),o},cr=({editor:e})=>{let t=window.document.head,r=RegExp(`^${Xt.URN_PREFIX}`);(e=>{document.querySelectorAll(Xt.META_SELECTOR).forEach((({name:t,content:r})=>{var a;return null===(a=e.setUrnMapping)||void 0===a?void 0:a.call(e,{name:t,value:r})}))})(e),ir({element:t,callback:(0,Gt.debounce)((t=>{t.forEach((t=>{var a;if(t.addedNodes.length>0&&"META"===t.addedNodes[0].nodeName){let n=t.addedNodes[0],i=n.name;if(!(null==i?void 0:i.match(r)))return;null===(a=e.setUrnMapping)||void 0===a||a.call(e,{name:i,value:n.content})}}))}),150)})},pr=er(),hr=new Map,mr=(e,{resource:t,type:r,prop:a})=>{let n,i="";t?(n=((e,t,r)=>{var a,n,i;let s=null===(a=e.parentElement)||void 0===a?void 0:a.closest(`[${r.TYPE}="${b.CONTAINER}"]:is([${r.RESOURCE}],[${r.PROP}]`);if(!s)return;let o=s.getAttribute(r.RESOURCE),d=s.getAttribute(r.PROP);if(o)return{parentResource:o,parentid:ur(s,t,{resource:o,prop:d})};let l=null!==(i=null===(n=s.closest(`[${r.RESOURCE}]`))||void 0===n?void 0:n.getAttribute(r.RESOURCE))&&void 0!==i?i:"";return d?{parentResource:l,parentid:ur(s,t,{resource:l,prop:d})}:void 0})(e,hr,pr),i=`[${pr.RESOURCE}="${t}"]`):(n=((e,t,r)=>{let a=e.closest(`[${r.RESOURCE}]`),n=(null==a?void 0:a.getAttribute(r.RESOURCE))||"",i=(null==a?void 0:a.getAttribute(r.PROP))||"";return{parentResource:n,parentid:ur(a,t,{resource:n,prop:i})}})(e,hr,pr),i=`[${pr.RESOURCE}="${n.parentResource}"] ${e.tagName.toLocaleLowerCase()}[${pr.TYPE}="${r}"]`),a&&(i+=`[${pr.PROP}="${a}"]`);let s=r===Xt.COMPONENT_ITEM_TYPE||e.getAttribute(pr.BEHAVIOR)===Xt.COMPONENT_ITEM_TYPE;return{...n,selector:i,isComponent:s}},fr=e=>{let t=e.filter((e=>!!e)).join("_"),r=lr(t,lr.URL),a=hr.get(r);return a?((e,t)=>{var r,a;let n=null!==(a=null===(r=e.copyInfo)||void 0===r?void 0:r.copies)&&void 0!==a?a:[],i=n.length+1,s=lr(`${t}_${i}`,lr.URL);return n.push(s),hr.set(e.id,{...e,copyInfo:{copies:n}}),{id:s,copyInfo:{copyIndex:i,originalId:e.id}}})(a,t):{id:r}},vr=e=>{let{scrollLeft:t,scrollTop:r}=e.documentElement,a=e.querySelectorAll(`[${pr.RESOURCE}],[${pr.PROP}]`)||[];return hr.clear(),a.forEach((e=>{let t=(e=>{let t=e.getAttribute(null==pr?void 0:pr.TYPE),r=e.getAttribute(pr.RESOURCE),a=e.getAttribute(pr.PROP);if(!r&&!a)return;let n=e.getAttribute(pr.MODEL)||"",{parentid:i="",parentResource:s,selector:o,isComponent:d}=mr(e,{resource:r,type:t,prop:a}),{id:l,copyInfo:u}=fr([r||s,a]);return{id:l,type:t||"",resource:r||"",prop:a||"",model:n,rect:e.getBoundingClientRect(),label:e.getAttribute(pr.LABEL)||"",parentid:i,selector:o,isComponent:d,filter:e.getAttribute(pr.FILTER)||"",content:tr(e,t),copyInfo:u}})(e);if(t){let e=hr.get(t.id);if(hr.set(t.id,{...t,children:(null==e?void 0:e.children)||[]}),t.parentid&&t.id!==t.parentid){let e=hr.get(t.parentid);e?e.children.push(t.id):hr.set(t.parentid,{children:[t.id]})}}})),{editables:hr,offset:{x:t,y:r},selected:{}}},gr={viewport:{width:0,height:0},frame:{width:0,height:0},scroll:{x:0,y:0}},yr=({editor:e})=>{null==e||e.updateFrameDetails({details:gr})},_r=({target:e})=>{let t=e.documentElement;gr.scroll.x=t.scrollLeft,gr.scroll.y=t.scrollTop},Er=({target:e})=>{let t=Math.max(e.document.documentElement.clientWidth||0,e.innerWidth||0),r=Math.max(e.document.documentElement.clientHeight||0,e.innerHeight||0),{width:a,height:n}=e.document.documentElement.getBoundingClientRect();gr.viewport={width:t,height:r},gr.frame={width:Math.ceil(a),height:Math.ceil(n)}},br={edit:"adobe-ue-edit",preview:"adobe-ue-preview"},kr="application/vnd.adobe.aue.";O=function(e){return function(t,r,a){var n=a.subscribe;return a.subscribe=function(e,t,r){var i=e;if(t){var s=(null==r?void 0:r.equalityFn)||Object.is,o=e(a.getState());i=function(r){var a=e(r);if(!s(o,a)){var n=o;t(o=a,n)}},null!=r&&r.fireImmediately&&t(o,o)}return n(i)},e(t,r,a)}};var xr={},wr=function(e){var t,r=new Set,a=function(e,a){var n="function"==typeof e?e(t):e;if(!Object.is(n,t)){var i=t;t=(null!=a?a:"object"!=typeof n||null===n)?n:Object.assign({},t,n),r.forEach((function(e){return e(t,i)}))}},n=function(){return t},i={setState:a,getState:n,getInitialState:function(){return s},subscribe:function(e){return r.add(e),function(){return r.delete(e)}},destroy:function(){r.clear()}},s=t=e(a,n,i);return i},Tr=function(e){return e?wr(e):wr},Nr=function(e){return Tr(e)};xr.createStore=Tr,xr.default=Nr,(xr=Nr).createStore=Tr,xr.default=xr;let Cr=({set:e},t)=>{e((e=>({...e,editor:t})))},Or=({set:e},{mode:t})=>{e((e=>{let r=t===_.EDIT||t===_.PREVIEW;return{...e,mode:t,isInEditor:r}}))},Rr=({set:e},t)=>{e((e=>({...e,prefix:t})))},Sr=(0,xr.createStore)(O(((e,t)=>({mode:_.PREVIEW,isInEditor:!1,prefix:null,editor:null,setMode:Or.bind(null,{get:t,set:e}),setPrefix:Rr.bind(null,{get:t,set:e}),setEditor:Cr.bind(null,{get:t,set:e})})))),Ir=e=>e.preventDefault(),Zr=()=>{var e;null===(e=window.navigation)||void 0===e||e.removeEventListener("navigate",Ir)},Ar=({editable:e,config:t},r=0)=>{var a;if(!window.tinymce)return void(r<3&&setTimeout((()=>Ar({editable:e,config:t},r+1)),100));nr(),null==t||delete t.selector;let n=null===(a=e.copyInfo)||void 0===a?void 0:a.copyIndex,i=n?document.querySelectorAll(e.selector)[n]:document.querySelector(e.selector);if(!t.toolbar){let e=null==i?void 0:i.tagName;e&&["a","div"].includes(e.toLowerCase())&&Object.assign(t,{forced_root_block:e})}window.tinymce.init({...t,target:i,setup:t=>{t.on("init",(()=>{window.tinymce.activeEditor.focus(!1),(()=>{var e;null===(e=window.navigation)||void 0===e||e.addEventListener("navigate",Ir)})()})),t.on("keyup",(e=>"Escape"===e.key&&e.target.blur())),t.on("blur",(r=>{((e,t)=>{var r;let{editor:a}=Sr.getState(),{bodyElement:n,startContent:i}=e.target,s=window.tinymce.activeEditor.getContent();null==a||a.closeRTE({editable:t,isModified:i!==s,newContent:{html:s,text:null!==(r=n.textContent)&&void 0!==r?r:""}})})(r,e),((e,t)=>{e.preventDefault(),e.stopImmediatePropagation(),t.remove(),Zr(),ar()})(r,t)}))}})},Pr=(e,t,r,a)=>{var n,i;let s,o=new CustomEvent(e,{bubbles:!0,detail:r});if(t){let e=null===(n=null==a?void 0:a.copyInfo)||void 0===n?void 0:n.copyIndex;s=e?document.querySelectorAll(t)[e]:document.querySelector(t)}return null===(i=null!=s?s:document.body)||void 0===i||i.dispatchEvent(o),!!s},$r=({selector:e,classNames:t,operation:r="toggle"})=>{let a=document.querySelector(e);if(a)for(let e of t)a.classList[r](e)},jr=({container:e,beforeSelector:t,refresh:r,element:a,attributes:n})=>{a&&e?(n&&Object.entries(n).forEach((([e,t])=>{a.setAttribute(e,t)})),((e,t,r)=>{r?document.querySelector(r).before(e):t.appendChild(e)})(a,e,t)):r&&window.location.reload()},Mr=()=>{document.addEventListener(Xt.EVENT_CONTENT_MOVE,(e=>{let{prefix:t}=Sr.getState(),{component:r,before:a,from:n,to:i}=e.detail,s=e.target,o=`[${t}${M.RESOURCE}="${r}"]`,d=document.querySelector(o),l=d.getAttribute(`${t}${M.RESOURCE}`),u={};if(n!==i&&(null==l?void 0:l.includes(n))){let e=null==l?void 0:l.replace(n,"");Object.assign(u,{[`${t}${M.RESOURCE}`]:`${i}${e}`})}jr({container:s,element:d,beforeSelector:a?`[${t}${M.RESOURCE}="${a}"]`:void 0,attributes:u})})),document.addEventListener(Xt.EVENT_UI_SELECT,(e=>{let t=e.target;t&&e.detail.selected&&(t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView({block:"nearest"}))})),document.addEventListener(Xt.EVENT_CONTENT_PATCH,(e=>{var t;let{prefix:r}=Sr.getState(),{request:a,patch:n}=null==e?void 0:e.detail,i=document.querySelector(`[${r}${M.RESOURCE}="${null===(t=null==a?void 0:a.target)||void 0===t?void 0:t.resource}"]`),s=null==i?void 0:i.getAttribute(`${r}${M.PROP}`);if(i&&n.name&&s!==n.name&&(i=i.querySelector(`[${r}${M.PROP}='${n.name}']`)),!i)return void window.location.reload();let o=i.getAttribute(`${r}${M.TYPE}`);o===b.MEDIA?i.src=n.value:o===b.TEXT||o===b.RICHTEXT?i.innerHTML=n.value:window.location.reload()})),document.addEventListener(Xt.EVENT_CONTENT_REMOVE,(e=>{var t;let r=null===(t=null==e?void 0:e.detail)||void 0===t?void 0:t.resource;if(!r)return;let{prefix:a}=Sr.getState(),n=document.querySelector(`[${a}${M.RESOURCE}="${r}"]`);n&&n.remove()})),document.addEventListener(Xt.EVENT_CONTENT_ADD,(()=>{window.location.reload()})),document.addEventListener(Xt.EVENT_UI_EDIT,(()=>{Lr(_.EDIT)})),document.addEventListener(Xt.EVENT_UI_PREVIEW,(()=>{Lr(_.PREVIEW)})),document.addEventListener(Xt.EVENT_CONTENT_COPY,(e=>{var t;let{source:r,target:a,response:n}=null==e?void 0:e.detail,i=e.target;if(!r||!a||!i)return;let{prefix:s}=Sr.getState(),o=i.cloneNode(!0);o.setAttribute(`${s}${M.RESOURCE}`,null==n?void 0:n.resource),o.setAttribute(`${s}${M.LABEL}`,null!==(t=a.newName)&&void 0!==t?t:""),r.container===a.container&&jr({container:i.parentElement,element:o,beforeSelector:a.before?`[${s}${M.RESOURCE}="${a.before}"]`:void 0})}))},Lr=e=>{let{mode:t,setMode:r}=Sr.getState();$r({selector:"html",classNames:[br[e]],operation:"add"}),t!==e&&($r({selector:"html",classNames:[br[t]],operation:"remove"}),r({mode:e}))},Dr={updateAppMode:Lr,getDocumentProperties:e=>e.reduce(((e,t)=>{var r;return{...e,[t]:null!==(r=document[t])&&void 0!==r?r:null}}),{}),getDefinitions:async()=>{let e={},t=document.querySelectorAll(`script[type^="${kr}"]`);return await Promise.all([...t].map((async({type:t,src:r,innerText:a})=>{let n=t.replace(kr,"").replace("+json",""),i=a?(e=>{try{return JSON.parse(e)}catch(e){return console.log("Cors parseDefinitions",e),null}})(a):await(async e=>{try{return await fetch(e).then((e=>e.json()))}catch(e){return console.log("Cors fetchDefinitions",e),null}})(r);e[n]=i}))),e},triggerEvent:Pr,openRTE:Ar};(async()=>{let e=j({methods:Dr}),t=await e.promise;Sr.getState().setEditor(t),Mr();let r=(()=>{let e=document.querySelector(Xt.META_NAMESPACE);return(null==e?void 0:e.content)?`data-${e.content}-`:Xt.DEFAULT_PREFIX})();Sr.getState().setPrefix(r),(()=>{let e=document.createElement("script");e.id="tiny-mce-script",e.src=Xt.RTE_URL,document.body.appendChild(e)})(),Pr(Xt.EVENT_APP_INITIALIZED),(({editor:e,prefix:t})=>{let r=Qt.element;t&&t!==Xt.DEFAULT_PREFIX&&Object.assign(pr,er(t));let a=(0,Gt.debounce)((()=>{let t=vr(r);e.repaintEditables({editables:t})}),150);a(),window.removeEventListener("resize",a),window.addEventListener("resize",a),ir({element:r,callback:a})})({editor:t,prefix:r}),(({editor:e})=>{let t=window;t.document.addEventListener("scroll",(0,Gt.debounce)((({target:t})=>{_r({target:t}),yr({editor:e})}),150)),t.addEventListener("resize",(0,Gt.debounce)((({target:t})=>{Er({target:t}),yr({editor:e})}),150)),t.addEventListener("orientationchange",(0,Gt.debounce)((({target:r})=>{_r({target:t.document}),Er({target:r}),yr({editor:e})}),150));let r=new ResizeObserver((0,Gt.debounce)((()=>{Er({target:t}),yr({editor:e})}),150));r.observe(t.document.documentElement),r.observe(t.document.body),requestAnimationFrame((()=>{_r({target:t.document}),Er({target:t}),yr({editor:e})}))})({editor:t}),(({editor:e})=>{cr({editor:e})})({editor:t}),(({editor:e})=>{document.addEventListener("click",(t=>(({event:e,editor:t})=>{let r=e.target.closest("A");r&&(e.preventDefault(),t.navigateTo({href:r.href}))})({event:t,editor:e})),{capture:!0})})({editor:t}),window.addEventListener("keydown",(({type:e,key:t,code:r,altKey:a,metaKey:n,shiftKey:i,ctrlKey:s})=>{parent.postMessage({type:Xt.USER_INPUT_RELAY_MESSAGE,value:{type:e,key:t,code:r,altKey:a,metaKey:n,shiftKey:i,ctrlKey:s}},"*")})),(e=>{Sr.subscribe((e=>[e.mode]),(([t],[r])=>{t&&t!==r&&e(t)}))})((e=>{var t;let r={[_.PREVIEW]:nr,[_.EDIT]:ar};null===(t=r[e])||void 0===t||t.call(r)})),t.trackCorsVersion({version:"2.3.7"})})()})();