@resconet/qp-bridge 1.5.0-alpha.12 → 1.5.0-alpha.14

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/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Se={exports:{}},Ve;function os(){if(Ve)return Se.exports;Ve=1;var t=Se.exports={},e,s;function n(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?e=setTimeout:e=n}catch{e=n}try{typeof clearTimeout=="function"?s=clearTimeout:s=a}catch{s=a}})();function r(w){if(e===setTimeout)return setTimeout(w,0);if((e===n||!e)&&setTimeout)return e=setTimeout,setTimeout(w,0);try{return e(w,0)}catch{try{return e.call(null,w,0)}catch{return e.call(this,w,0)}}}function i(w){if(s===clearTimeout)return clearTimeout(w);if((s===a||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(w);try{return s(w)}catch{try{return s.call(null,w)}catch{return s.call(this,w)}}}var o=[],d=!1,l,v=-1;function N(){!d||!l||(d=!1,l.length?o=l.concat(o):v=-1,o.length&&O())}function O(){if(!d){var w=r(N);d=!0;for(var E=o.length;E;){for(l=o,o=[];++v<E;)l&&l[v].run();v=-1,E=o.length}l=null,d=!1,i(w)}}t.nextTick=function(w){var E=new Array(arguments.length-1);if(arguments.length>1)for(var H=1;H<arguments.length;H++)E[H-1]=arguments[H];o.push(new Be(w,E)),o.length===1&&!d&&r(O)};function Be(w,E){this.fun=w,this.array=E}Be.prototype.run=function(){this.fun.apply(null,this.array)},t.title="browser",t.browser=!0,t.env={},t.argv=[],t.version="",t.versions={};function Z(){}return t.on=Z,t.addListener=Z,t.once=Z,t.off=Z,t.removeListener=Z,t.removeAllListeners=Z,t.emit=Z,t.prependListener=Z,t.prependOnceListener=Z,t.listeners=function(w){return[]},t.binding=function(w){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(w){throw new Error("process.chdir is not supported")},t.umask=function(){return 0},Se.exports}var cs=os();const R=[];for(let t=0;t<256;++t)R.push((t+256).toString(16).slice(1));function us(t,e=0){return(R[t[e+0]]+R[t[e+1]]+R[t[e+2]]+R[t[e+3]]+"-"+R[t[e+4]]+R[t[e+5]]+"-"+R[t[e+6]]+R[t[e+7]]+"-"+R[t[e+8]]+R[t[e+9]]+"-"+R[t[e+10]]+R[t[e+11]]+R[t[e+12]]+R[t[e+13]]+R[t[e+14]]+R[t[e+15]]).toLowerCase()}const ds=new Uint8Array(16);function ls(){return crypto.getRandomValues(ds)}function Ke(t,e,s){return crypto.randomUUID?crypto.randomUUID():fs(t)}function fs(t,e,s){t=t||{};const n=t.random??t.rng?.()??ls();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,us(n)}var x;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function s(a){throw new Error}t.assertNever=s,t.arrayToEnum=a=>{const r={};for(const i of a)r[i]=i;return r},t.getValidEnumValues=a=>{const r=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of r)i[o]=a[o];return t.objectValues(i)},t.objectValues=a=>t.objectKeys(a).map(function(r){return a[r]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const r=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&r.push(i);return r},t.find=(a,r)=>{for(const i of a)if(r(i))return i},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,r=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(r)}t.joinValues=n,t.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(x||(x={}));var Ue;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(Ue||(Ue={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Q=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},c=x.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 L extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}format(e){const s=e||function(r){return r.message},n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)n._errors.push(s(i));else{let o=n,d=0;for(;d<i.path.length;){const l=i.path[d];d===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(s(i))):o[l]=o[l]||{_errors:[]},o=o[l],d++}}};return a(this),n}static assert(e){if(!(e instanceof L))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=s=>s.message){const s={},n=[];for(const a of this.issues)if(a.path.length>0){const r=a.path[0];s[r]=s[r]||[],s[r].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}L.create=t=>new L(t);const Me=(t,e)=>{let s;switch(t.code){case c.invalid_type:t.received===f.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case c.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:s=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case c.invalid_union:s="Invalid input";break;case c.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case c.invalid_enum_value:s=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case c.invalid_arguments:s="Invalid function arguments";break;case c.invalid_return_type:s="Invalid function return type";break;case c.invalid_date:s="Invalid date";break;case c.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:x.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case c.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case c.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case c.custom:s="Invalid input";break;case c.invalid_intersection_types:s="Intersection results could not be merged";break;case c.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case c.not_finite:s="Number must be finite";break;default:s=e.defaultError,x.assertNever(t)}return{message:s}};let hs=Me;function ms(){return hs}const ps=t=>{const{data:e,path:s,errorMaps:n,issueData:a}=t,r=[...s,...a.path||[]],i={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let o="";const d=n.filter(l=>!!l).slice().reverse();for(const l of d)o=l(i,{data:e,defaultError:o}).message;return{...a,path:r,message:o}};function u(t,e){const s=ms(),n=ps({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s,s===Me?void 0:Me].filter(a=>!!a)});t.common.issues.push(n)}class M{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const a of s){if(a.status==="aborted")return m;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const a of s){const r=await a.key,i=await a.value;n.push({key:r,value:i})}return M.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const a of s){const{key:r,value:i}=a;if(r.status==="aborted"||i.status==="aborted")return m;r.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(n[r.value]=i.value)}return{status:e.value,value:n}}}const m=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),De=t=>t.status==="aborted",ze=t=>t.status==="dirty",Y=t=>t.status==="valid",ce=t=>typeof Promise<"u"&&t instanceof Promise;var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));class A{constructor(e,s,n,a){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Fe=(t,e)=>{if(Y(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new L(t.common.issues);return this._error=s,this._error}}};function y(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:a}=t;if(e&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:d}=t;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:d??s??o.defaultError}},description:a}}class _{get description(){return this._def.description}_getType(e){return Q(e.data)}_getOrReturnCtx(e,s){return s||{common:e.parent.common,data:e.data,parsedType:Q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new M,ctx:{common:e.parent.common,data:e.data,parsedType:Q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const s=this._parse(e);if(ce(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){const n={common:{issues:[],async:s?.async??!1,contextualErrorMap:s?.errorMap},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Q(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Fe(n,a)}"~validate"(e){const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Q(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:s});return Y(n)?{value:n.value}:{issues:s.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(n=>Y(n)?{value:n.value}:{issues:s.common.issues})}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s?.errorMap,async:!0},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Q(e)},a=this._parse({data:e,path:n.path,parent:n}),r=await(ce(a)?a:Promise.resolve(a));return Fe(n,r)}refine(e,s){const n=a=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(a):s;return this._refinement((a,r)=>{const i=e(a),o=()=>r.addIssue({code:c.custom,...n(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,s){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof s=="function"?s(n,a):s),!1))}_refinement(e){return new F({schema:this,typeName:p.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:s=>this["~validate"](s)}}optional(){return G.create(this,this._def)}nullable(){return W.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return pe.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new F({...y(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new ge({...y(this._def),innerType:this,defaultValue:s,typeName:p.ZodDefault})}brand(){return new nt({typeName:p.ZodBranded,type:this,...y(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new ye({...y(this._def),innerType:this,catchValue:s,typeName:p.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return Ze.create(this,e)}readonly(){return ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const gs=/^c[^\s-]{8,}$/i,ys=/^[0-9a-z]+$/,vs=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_s=/^[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,xs=/^[a-z0-9_-]{21}$/i,bs=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ws=/^[-+]?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)?)??$/,ks=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ss="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Re;const Rs=/^(?:(?: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])$/,Ms=/^(?:(?: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])$/,Ts=/^(([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]))$/,Cs=/^(([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])$/,Is=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Es=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,et="((\\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])))",qs=new RegExp(`^${et}$`);function tt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const s=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${s}`}function As(t){return new RegExp(`^${tt(t)}$`)}function Ns(t){let e=`${et}T${tt(t)}`;const s=[];return s.push(t.local?"Z?":"Z"),t.offset&&s.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${s.join("|")})`,new RegExp(`^${e}$`)}function Os(t,e){return!!((e==="v4"||!e)&&Rs.test(t)||(e==="v6"||!e)&&Ts.test(t))}function Zs(t,e){if(!bs.test(t))return!1;try{const[s]=t.split(".");if(!s)return!1;const n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function js(t,e){return!!((e==="v4"||!e)&&Ms.test(t)||(e==="v6"||!e)&&Cs.test(t))}class P extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.string,received:r.parsedType}),m}const n=new M;let a;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.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&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,o=e.data.length<r.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?u(a,{code:c.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&u(a,{code:c.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind==="email")ks.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"email",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="emoji")Re||(Re=new RegExp(Ss,"u")),Re.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"emoji",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="uuid")_s.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"uuid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="nanoid")xs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"nanoid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid")gs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid2")ys.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid2",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="ulid")vs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ulid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),u(a,{validation:"url",code:c.invalid_string,message:r.message}),n.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"regex",code:c.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)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.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)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind==="datetime"?Ns(r).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"datetime",message:r.message}),n.dirty()):r.kind==="date"?qs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"date",message:r.message}),n.dirty()):r.kind==="time"?As(r).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"time",message:r.message}),n.dirty()):r.kind==="duration"?ws.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"duration",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="ip"?Os(e.data,r.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ip",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="jwt"?Zs(e.data,r.alg)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"jwt",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="cidr"?js(e.data,r.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cidr",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="base64"?Is.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="base64url"?Es.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64url",code:c.invalid_string,message:r.message}),n.dirty()):x.assertNever(r);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(a=>e.test(a),{validation:s,code:c.invalid_string,...h.errToObj(n)})}_addCheck(e){return new P({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.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:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.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:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,s){return this._addCheck({kind:"regex",regex:e,...h.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s?.position,...h.errToObj(s?.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...h.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...h.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...h.errToObj(s)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new P({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new P({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new P({...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(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}P.create=t=>new P({checks:[],typeName:p.ZodString,coerce:t?.coerce??!1,...y(t)});function Ps(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=s>n?s:n,r=Number.parseInt(t.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return r%i/10**a}class X extends _{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)!==f.number){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.number,received:r.parsedType}),m}let n;const a=new M;for(const r of this._def.checks)r.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?Ps(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_finite,message:r.message}),a.dirty()):x.assertNever(r);return{status:a.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,a){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(a)}]})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}X.create=t=>new X({checks:[],typeName:p.ZodNumber,coerce:t?.coerce||!1,...y(t)});class ie extends _{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)!==f.bigint)return this._getInvalidInput(e);let n;const a=new M;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):x.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:f.bigint,received:s.parsedType}),m}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,a){return new ie({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(a)}]})}_addCheck(e){return new ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}ie.create=t=>new ie({checks:[],typeName:p.ZodBigInt,coerce:t?.coerce??!1,...y(t)});class Te extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.boolean,received:n.parsedType}),m}return C(e.data)}}Te.create=t=>new Te({typeName:p.ZodBoolean,coerce:t?.coerce||!1,...y(t)});class ue extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.date,received:r.parsedType}),m}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_date}),m}const n=new M;let a;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()):x.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}ue.create=t=>new ue({checks:[],coerce:t?.coerce||!1,typeName:p.ZodDate,...y(t)});class We extends _{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.symbol,received:n.parsedType}),m}return C(e.data)}}We.create=t=>new We({typeName:p.ZodSymbol,...y(t)});class Ce extends _{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.undefined,received:n.parsedType}),m}return C(e.data)}}Ce.create=t=>new Ce({typeName:p.ZodUndefined,...y(t)});class Ie extends _{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.null,received:n.parsedType}),m}return C(e.data)}}Ie.create=t=>new Ie({typeName:p.ZodNull,...y(t)});class He extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}He.create=t=>new He({typeName:p.ZodAny,...y(t)});class Ee extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}Ee.create=t=>new Ee({typeName:p.ZodUnknown,...y(t)});class B extends _{_parse(e){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:f.never,received:s.parsedType}),m}}B.create=t=>new B({typeName:p.ZodNever,...y(t)});class Je extends _{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.void,received:n.parsedType}),m}return C(e.data)}}Je.create=t=>new Je({typeName:p.ZodVoid,...y(t)});class q extends _{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),a=this._def;if(s.parsedType!==f.array)return u(s,{code:c.invalid_type,expected:f.array,received:s.parsedType}),m;if(a.exactLength!==null){const i=s.data.length>a.exactLength.value,o=s.data.length<a.exactLength.value;(i||o)&&(u(s,{code:i?c.too_big:c.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&s.data.length<a.minLength.value&&(u(s,{code:c.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&s.data.length>a.maxLength.value&&(u(s,{code:c.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((i,o)=>a.type._parseAsync(new A(s,i,s.path,o)))).then(i=>M.mergeArray(n,i));const r=[...s.data].map((i,o)=>a.type._parseSync(new A(s,i,s.path,o)));return M.mergeArray(n,r)}get element(){return this._def.type}min(e,s){return new q({...this._def,minLength:{value:e,message:h.toString(s)}})}max(e,s){return new q({...this._def,maxLength:{value:e,message:h.toString(s)}})}length(e,s){return new q({...this._def,exactLength:{value:e,message:h.toString(s)}})}nonempty(e){return this.min(1,e)}}q.create=(t,e)=>new q({type:t,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...y(e)});function J(t){if(t instanceof S){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=G.create(J(n))}return new S({...t._def,shape:()=>e})}else return t instanceof q?new q({...t._def,type:J(t.element)}):t instanceof G?G.create(J(t.unwrap())):t instanceof W?W.create(J(t.unwrap())):t instanceof D?D.create(t.items.map(e=>J(e))):t}class S extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),s=x.objectKeys(e);return this._cached={shape:e,keys:s},this._cached}_parse(e){if(this._getType(e)!==f.object){const l=this._getOrReturnCtx(e);return u(l,{code:c.invalid_type,expected:f.object,received:l.parsedType}),m}const{status:n,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(const l in a.data)i.includes(l)||o.push(l);const d=[];for(const l of i){const v=r[l],N=a.data[l];d.push({key:{status:"valid",value:l},value:v._parse(new A(a,N,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof B){const l=this._def.unknownKeys;if(l==="passthrough")for(const v of o)d.push({key:{status:"valid",value:v},value:{status:"valid",value:a.data[v]}});else if(l==="strict")o.length>0&&(u(a,{code:c.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const v of o){const N=a.data[v];d.push({key:{status:"valid",value:v},value:l._parse(new A(a,N,a.path,v)),alwaysSet:v in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const v of d){const N=await v.key,O=await v.value;l.push({key:N,value:O,alwaysSet:v.alwaysSet})}return l}).then(l=>M.mergeObjectSync(n,l)):M.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new S({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{const a=this._def.errorMap?.(s,n).message??n.defaultError;return s.code==="unrecognized_keys"?{message:h.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new S({...this._def,unknownKeys:"strip"})}passthrough(){return new S({...this._def,unknownKeys:"passthrough"})}extend(e){return new S({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new S({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new S({...this._def,catchall:e})}pick(e){const s={};for(const n of x.objectKeys(e))e[n]&&this.shape[n]&&(s[n]=this.shape[n]);return new S({...this._def,shape:()=>s})}omit(e){const s={};for(const n of x.objectKeys(this.shape))e[n]||(s[n]=this.shape[n]);return new S({...this._def,shape:()=>s})}deepPartial(){return J(this)}partial(e){const s={};for(const n of x.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?s[n]=a:s[n]=a.optional()}return new S({...this._def,shape:()=>s})}required(e){const s={};for(const n of x.objectKeys(this.shape))if(e&&!e[n])s[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof G;)r=r._def.innerType;s[n]=r}return new S({...this._def,shape:()=>s})}keyof(){return st(x.objectKeys(this.shape))}}S.create=(t,e)=>new S({shape:()=>t,unknownKeys:"strip",catchall:B.create(),typeName:p.ZodObject,...y(e)});S.strictCreate=(t,e)=>new S({shape:()=>t,unknownKeys:"strict",catchall:B.create(),typeName:p.ZodObject,...y(e)});S.lazycreate=(t,e)=>new S({shape:t,unknownKeys:"strip",catchall:B.create(),typeName:p.ZodObject,...y(e)});class de extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n=this._def.options;function a(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return s.common.issues.push(...o.ctx.common.issues),o.result;const i=r.map(o=>new L(o.ctx.common.issues));return u(s,{code:c.invalid_union,unionErrors:i}),m}if(s.common.async)return Promise.all(n.map(async r=>{const i={...s,common:{...s.common,issues:[]},parent:null};return{result:await r._parseAsync({data:s.data,path:s.path,parent:i}),ctx:i}})).then(a);{let r;const i=[];for(const d of n){const l={...s,common:{...s.common,issues:[]},parent:null},v=d._parseSync({data:s.data,path:s.path,parent:l});if(v.status==="valid")return v;v.status==="dirty"&&!r&&(r={result:v,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(r)return s.common.issues.push(...r.ctx.common.issues),r.result;const o=i.map(d=>new L(d));return u(s,{code:c.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}de.create=(t,e)=>new de({options:t,typeName:p.ZodUnion,...y(e)});const j=t=>t instanceof he?j(t.schema):t instanceof F?j(t.innerType()):t instanceof me?[t.value]:t instanceof z?t.options:t instanceof Ae?x.objectValues(t.enum):t instanceof ge?j(t._def.innerType):t instanceof Ce?[void 0]:t instanceof Ie?[null]:t instanceof G?[void 0,...j(t.unwrap())]:t instanceof W?[null,...j(t.unwrap())]:t instanceof nt||t instanceof ve?j(t.unwrap()):t instanceof ye?j(t._def.innerType):[];class Oe extends _{_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return u(s,{code:c.invalid_type,expected:f.object,received:s.parsedType}),m;const n=this.discriminator,a=s.data[n],r=this.optionsMap.get(a);return r?s.common.async?r._parseAsync({data:s.data,path:s.path,parent:s}):r._parseSync({data:s.data,path:s.path,parent:s}):(u(s,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,s,n){const a=new Map;for(const r of s){const i=j(r.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,r)}}return new Oe({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:s,optionsMap:a,...y(n)})}}function qe(t,e){const s=Q(t),n=Q(e);if(t===e)return{valid:!0,data:t};if(s===f.object&&n===f.object){const a=x.objectKeys(e),r=x.objectKeys(t).filter(o=>a.indexOf(o)!==-1),i={...t,...e};for(const o of r){const d=qe(t[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(s===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let r=0;r<t.length;r++){const i=t[r],o=e[r],d=qe(i,o);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return s===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class le extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),a=(r,i)=>{if(De(r)||De(i))return m;const o=qe(r.value,i.value);return o.valid?((ze(r)||ze(i))&&s.dirty(),{status:s.value,value:o.data}):(u(n,{code:c.invalid_intersection_types}),m)};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(([r,i])=>a(r,i)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}le.create=(t,e,s)=>new le({left:t,right:e,typeName:p.ZodIntersection,...y(s)});class D extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return u(n,{code:c.invalid_type,expected:f.array,received:n.parsedType}),m;if(n.data.length<this._def.items.length)return u(n,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&n.data.length>this._def.items.length&&(u(n,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const r=[...n.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new A(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(r).then(i=>M.mergeArray(s,i)):M.mergeArray(s,r)}get items(){return this._def.items}rest(e){return new D({...this._def,rest:e})}}D.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new D({items:t,typeName:p.ZodTuple,rest:null,...y(e)})};class fe extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return u(n,{code:c.invalid_type,expected:f.object,received:n.parsedType}),m;const a=[],r=this._def.keyType,i=this._def.valueType;for(const o in n.data)a.push({key:r._parse(new A(n,o,n.path,o)),value:i._parse(new A(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?M.mergeObjectAsync(s,a):M.mergeObjectSync(s,a)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof _?new fe({keyType:e,valueType:s,typeName:p.ZodRecord,...y(n)}):new fe({keyType:P.create(),valueType:e,typeName:p.ZodRecord,...y(s)})}}class Ye extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return u(n,{code:c.invalid_type,expected:f.map,received:n.parsedType}),m;const a=this._def.keyType,r=this._def.valueType,i=[...n.data.entries()].map(([o,d],l)=>({key:a._parse(new A(n,o,n.path,[l,"key"])),value:r._parse(new A(n,d,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const l=await d.key,v=await d.value;if(l.status==="aborted"||v.status==="aborted")return m;(l.status==="dirty"||v.status==="dirty")&&s.dirty(),o.set(l.value,v.value)}return{status:s.value,value:o}})}else{const o=new Map;for(const d of i){const l=d.key,v=d.value;if(l.status==="aborted"||v.status==="aborted")return m;(l.status==="dirty"||v.status==="dirty")&&s.dirty(),o.set(l.value,v.value)}return{status:s.value,value:o}}}}Ye.create=(t,e,s)=>new Ye({valueType:e,keyType:t,typeName:p.ZodMap,...y(s)});class oe extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return u(n,{code:c.invalid_type,expected:f.set,received:n.parsedType}),m;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(u(n,{code:c.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),s.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(u(n,{code:c.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),s.dirty());const r=this._def.valueType;function i(d){const l=new Set;for(const v of d){if(v.status==="aborted")return m;v.status==="dirty"&&s.dirty(),l.add(v.value)}return{status:s.value,value:l}}const o=[...n.data.values()].map((d,l)=>r._parse(new A(n,d,n.path,l)));return n.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,s){return new oe({...this._def,minSize:{value:e,message:h.toString(s)}})}max(e,s){return new oe({...this._def,maxSize:{value:e,message:h.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}oe.create=(t,e)=>new oe({valueType:t,minSize:null,maxSize:null,typeName:p.ZodSet,...y(e)});class he extends _{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}he.create=(t,e)=>new he({getter:t,typeName:p.ZodLazy,...y(e)});class me extends _{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return u(s,{received:s.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}me.create=(t,e)=>new me({value:t,typeName:p.ZodLiteral,...y(e)});function st(t,e){return new z({values:t,typeName:p.ZodEnum,...y(e)})}class z extends _{_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return u(s,{expected:x.joinValues(n),received:s.parsedType,code:c.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const s=this._getOrReturnCtx(e),n=this._def.values;return u(s,{received:s.data,code:c.invalid_enum_value,options:n}),m}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e,s=this._def){return z.create(e,{...this._def,...s})}exclude(e,s=this._def){return z.create(this.options.filter(n=>!e.includes(n)),{...this._def,...s})}}z.create=st;class Ae extends _{_parse(e){const s=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const a=x.objectValues(s);return u(n,{expected:x.joinValues(a),received:n.parsedType,code:c.invalid_type}),m}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=x.objectValues(s);return u(n,{received:n.data,code:c.invalid_enum_value,options:a}),m}return C(e.data)}get enum(){return this._def.values}}Ae.create=(t,e)=>new Ae({values:t,typeName:p.ZodNativeEnum,...y(e)});class pe extends _{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.promise&&s.common.async===!1)return u(s,{code:c.invalid_type,expected:f.promise,received:s.parsedType}),m;const n=s.parsedType===f.promise?s.data:Promise.resolve(s.data);return C(n.then(a=>this._def.type.parseAsync(a,{path:s.path,errorMap:s.common.contextualErrorMap})))}}pe.create=(t,e)=>new pe({type:t,typeName:p.ZodPromise,...y(e)});class F extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),a=this._def.effect||null,r={addIssue:i=>{u(n,i),i.fatal?s.abort():s.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){const i=a.transform(n.data,r);if(n.common.async)return Promise.resolve(i).then(async o=>{if(s.value==="aborted")return m;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?m:d.status==="dirty"||s.value==="dirty"?te(d.value):d});{if(s.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?m:o.status==="dirty"||s.value==="dirty"?te(o.value):o}}if(a.type==="refinement"){const i=o=>{const d=a.refinement(o,r);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?m:(o.status==="dirty"&&s.dirty(),i(o.value),{status:s.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&s.dirty(),i(o.value).then(()=>({status:s.value,value:o.value}))))}if(a.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Y(i))return m;const o=a.transform(i.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Y(i)?Promise.resolve(a.transform(i.value,r)).then(o=>({status:s.value,value:o})):m);x.assertNever(a)}}F.create=(t,e,s)=>new F({schema:t,typeName:p.ZodEffects,effect:e,...y(s)});F.createWithPreprocess=(t,e,s)=>new F({schema:e,effect:{type:"preprocess",transform:t},typeName:p.ZodEffects,...y(s)});class G extends _{_parse(e){return this._getType(e)===f.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(t,e)=>new G({innerType:t,typeName:p.ZodOptional,...y(e)});class W extends _{_parse(e){return this._getType(e)===f.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}W.create=(t,e)=>new W({innerType:t,typeName:p.ZodNullable,...y(e)});class ge extends _{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}ge.create=(t,e)=>new ge({innerType:t,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class ye extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ce(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ye.create=(t,e)=>new ye({innerType:t,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class Xe extends _{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.nan,received:n.parsedType}),m}return{status:"valid",value:e.data}}}Xe.create=t=>new Xe({typeName:p.ZodNaN,...y(t)});class nt extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class Ze extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?m:r.status==="dirty"?(s.dirty(),te(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?m:a.status==="dirty"?(s.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,s){return new Ze({in:e,out:s,typeName:p.ZodPipeline})}}class ve extends _{_parse(e){const s=this._def.innerType._parse(e),n=a=>(Y(a)&&(a.value=Object.freeze(a.value)),a);return ce(s)?s.then(a=>n(a)):n(s)}unwrap(){return this._def.innerType}}ve.create=(t,e)=>new ve({innerType:t,typeName:p.ZodReadonly,...y(e)});var p;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(p||(p={}));const g=P.create,je=X.create,I=Te.create,xe=Ee.create;B.create;const be=q.create,$=S.create,Gs=de.create,Ls=Oe.create;le.create;D.create;const $s=fe.create,Pe=he.create,b=me.create,Qs=z.create;pe.create;G.create;W.create;const at=3,V=$({type:b("qp-bridge"),id:g().optional(),instanceId:g().optional()}),k=V.extend({featureVersion:je().optional()}),rt=V.extend({status:b("answerChanged"),question:g(),answer:xe()}),it=V.extend({action:b("commandExecuted"),commandName:g()}),ot=V.extend({action:b("questionnaireLoaded")}),U=V.extend({status:b("success")}),ct=V.extend({status:b("error"),message:g()}),ut=Qs(["imageMedia","shortText","longText","url","email","wholeNumber","decimalNumber","date","dateTime","singleSelect","multiSelect","optionSet","rating","yesNo","signature","lookup"]),we=$({type:ut,semanticColor:g().optional(),label:g().optional(),description:g().optional(),disabled:I(),required:I(),hidden:I(),errorMessage:g().optional(),answer:xe().optional()}),dt=we.partial(),lt=we.extend({itemType:b("question"),name:g()}),ft=$({id:g().uuid(),name:g(),mimeType:g(),blobUrl:g()}),ke=$s(xe()),Ge=$({label:g(),hidden:I(),collapsed:I()}),Le=Ge.partial(),ht=Ls("type",[$({itemType:b("staticComponent"),type:b("staticDescription"),name:g(),hidden:I().optional(),content:g()}),$({itemType:b("staticComponent"),type:b("button"),name:g(),hidden:I().optional(),clickText:g(),disabled:I().optional(),semanticColor:g().optional(),commandName:g().optional(),commandLabel:g().optional()})]),Bs=Le.extend({itemType:b("group"),name:g()}),Vs=$({itemType:b("repeatableGroup"),name:g(),label:g().optional(),hidden:I().optional()}),$e=Pe(()=>Gs([lt,Qe,mt,ht])),Qe=Pe(()=>Bs.extend({items:be($e)})),mt=Pe(()=>Vs.extend({groups:be(Qe)})),Us=$({entityName:g(),id:g(),name:g()}),pt=$({isNew:I(),id:g().uuid(),name:g(),label:g(),description:g().optional(),regarding:Us.optional(),items:be($e)}),gt=k.extend({action:b("getQuestion"),question:g()}),yt=U.extend({question:we}),vt=k.extend({action:b("setQuestion"),question:g(),questionData:dt}),_t=k.extend({action:b("getGroup"),group:g()}),xt=U.extend({group:Ge}),bt=k.extend({action:b("getQuestionnaire")}),wt=U.extend({questionnaire:pt}),kt=U.extend({canSave:I()}),St=k.extend({action:b("canSave")}),Rt=k.extend({action:b("postSave"),answerId:g()}),Mt=k.extend({action:b("setGroup"),group:g(),groupData:Le}),Tt=k.extend({action:b("setAnswer"),question:g(),answer:xe()}),Ct=k.extend({action:b("busyIndicatorStart")}),It=k.extend({action:b("busyIndicatorEnd")}),Et=k.extend({action:b("saveQuestionnaire")}),qt=k.extend({action:b("completeAndCloseQuestionnaire")}),At=k.extend({action:b("executeCustomCommand"),commandName:g()}),Nt=k.extend({action:b("fetchEntities"),fetchXml:g()}),Ot=U.extend({entities:be(ke)}),Zt=k.extend({action:b("getEntityById"),entityName:g(),entityId:g()}),jt=U.extend({entity:ke}),Pt=k.extend({action:b("saveEntity"),entity:ke}),Gt=k.extend({action:b("repeatGroup"),parentGroupName:g(),groupIndex:je()}),Lt=k.extend({action:b("addNewGroup"),groupName:g()}),$t=k.extend({action:b("deleteGroup"),parentGroupName:g(),groupIndex:je()});function Ds(t){return ft.safeParse(t).success}function Qt(t){return rt.safeParse(t).success}function Bt(t){return it.safeParse(t).success}function Vt(t){return ot.safeParse(t).success}function _e(t){return V.safeParse(t).success}function zs(t){return k.safeParse(t).success}function Ut(t){return U.safeParse(t).success}function Dt(t){return ct.safeParse(t).success}function Fs(t){return gt.safeParse(t).success}function zt(t){return yt.safeParse(t).success}function Ws(t){return Tt.safeParse(t).success}function Hs(t){return vt.safeParse(t).success}function Js(t){return Mt.safeParse(t).success}function Ys(t){return _t.safeParse(t).success}function Xs(t){return bt.safeParse(t).success}function Ft(t){return xt.safeParse(t).success}function Wt(t){return wt.safeParse(t).success}function Ks(t){return kt.safeParse(t).success}function Ht(t){return St.safeParse(t).success}function Jt(t){return Rt.safeParse(t).success}function Yt(t){return Ct.safeParse(t).success}function Xt(t){return It.safeParse(t).success}function en(t){return Et.safeParse(t).success}function tn(t){return qt.safeParse(t).success}function sn(t){return At.safeParse(t).success}function nn(t){return Yt(t)||Xt(t)}function Kt(t,e,s){return!_e(t)||t.id!==e||s!==void 0&&t.instanceId!==s||!("status"in t)}function an(t){return Nt.safeParse(t).success}function es(t){return Ot.safeParse(t).success}function rn(t){return Zt.safeParse(t).success}function ts(t){return jt.safeParse(t).success}function on(t){return Pt.safeParse(t).success}function cn(t){return Gt.safeParse(t).success}function un(t){return Lt.safeParse(t).success}function dn(t){return $t.safeParse(t).success}function K(t){if(t?.instanceId!=null)return t.instanceId;const e=globalThis.__RESCO_QP_BRIDGE_INSTANCE_ID;return typeof e=="string"?e:void 0}function ss(t){if(t instanceof File||t instanceof Blob)return URL.createObjectURL(t);if(typeof t=="string"){if(/^data:/.test(t)){const r=t.match(/^data:([^;]+);base64,(.*)$/);if(r){const i=r[1],o=r[2],d=atob(o),l=new ArrayBuffer(d.length),v=new Uint8Array(l);for(let O=0;O<d.length;O++)v[O]=d.charCodeAt(O);const N=new Blob([l],{type:i});return URL.createObjectURL(N)}throw new Error("Invalid data URL format. Only base64 data URLs are supported.")}const e=atob(t),s=new ArrayBuffer(e.length),n=new Uint8Array(s);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);const a=new Blob([s]);return URL.createObjectURL(a)}if(t instanceof ArrayBuffer){const e=new Blob([t]);return URL.createObjectURL(e)}throw new Error("Unsupported content type for blobUrl")}function ln(t,e,s,n){return{id:n??Ke(),name:t,mimeType:e,blobUrl:ss(s)}}function fn(t,e){let s=t.blobUrl;return e.content!==void 0&&(s=ss(e.content)),{...t,...e,blobUrl:s}}cs.env?.NODE_ENV!=="test"&&ns();function ns(){window.addEventListener("message",is)}function hn(){window.removeEventListener("message",is)}async function mn(t){return await $n({type:"qp-bridge",action:"getQuestionnaire"},t)}function as(t,e){Ne(t.items,[],e)}function rs(t){const e=[];return as(t,s=>e.push(s)),e}function pn(t){return rs(t).filter(gn)}function gn(t){return t.itemType==="question"}function Ne(t,e,s){for(const n of t)switch(s(n,e),n.itemType){case"question":case"staticComponent":break;case"group":Ne(n.items,[...e,n],s);break;case"repeatableGroup":Ne(n.groups,[...e,n],s);break;default:return n}}async function yn(t,e,s){await T({type:"qp-bridge",action:"setAnswer",question:t,answer:e},s)}async function vn(t,e){return await Gn({type:"qp-bridge",action:"getQuestion",question:t},e)}async function _n(t,e,s){await T({type:"qp-bridge",action:"setQuestion",question:t,questionData:e},s)}async function xn(t,e){return await Ln({type:"qp-bridge",action:"getGroup",group:t},e)}async function bn(t,e,s){await T({type:"qp-bridge",action:"setGroup",group:t,groupData:e},s)}function wn(t,e){const s=K(e),n=a=>{Qt(a.data)&&a.data.instanceId===s&&t(a.data.question,a.data.answer)};return window.addEventListener("message",n),{cancelSubscription:()=>{window.removeEventListener("message",n)}}}async function kn(t,e){await T({type:"qp-bridge",action:"busyIndicatorStart"},e);try{return await t()}finally{await T({type:"qp-bridge",action:"busyIndicatorEnd"},e)}}async function Sn(t){await T({type:"qp-bridge",action:"saveQuestionnaire"},t)}async function Rn(t){await T({type:"qp-bridge",action:"completeAndCloseQuestionnaire"},t)}async function Mn(t,e){await T({type:"qp-bridge",action:"executeCustomCommand",commandName:t},e)}const se=[],ne=[],ae=[],re=[];function Tn(t,e){const s=K(e);return re.some(n=>n.handler===t&&n.instanceId===s)||re.push({handler:t,instanceId:s}),{cancelSubscription:()=>{const n=re.findIndex(a=>a.handler===t&&a.instanceId===s);n!==-1&&re.splice(n,1)}}}function Cn(t,e){const s=K(e);return ae.some(n=>n.handler===t&&n.instanceId===s)||ae.push({handler:t,instanceId:s}),{cancelSubscription:()=>{const n=ae.findIndex(a=>a.handler===t&&a.instanceId===s);n!==-1&&ae.splice(n,1)}}}function In(t,e){const s=K(e);return se.some(n=>n.validator===t&&n.instanceId===s)||se.push({validator:t,instanceId:s}),{cancelSubscription:()=>{const n=se.findIndex(a=>a.validator===t&&a.instanceId===s);n!==-1&&se.splice(n,1)}}}function En(t,e){const s=K(e);return ne.some(n=>n.handler===t&&n.instanceId===s)||ne.push({handler:t,instanceId:s}),{cancelSubscription:()=>{const n=ne.findIndex(a=>a.handler===t&&a.instanceId===s);n!==-1&&ne.splice(n,1)}}}async function is(t){try{if(Bt(t.data)&&ae.filter(e=>e.instanceId===t.data.instanceId).forEach(e=>e.handler(t.data.commandName)),Vt(t.data)&&re.filter(e=>e.instanceId===t.data.instanceId).forEach(e=>e.handler()),Ht(t.data)){const e=se.filter(a=>a.instanceId===t.data.instanceId),s=await Promise.all(e.map(a=>a.validator())),n={type:"qp-bridge",status:"success",id:t.data.id,instanceId:t.data.instanceId,canSave:s.every(a=>a)};window.parent.postMessage(n,"*")}if(Jt(t.data)){const e=ne.filter(n=>n.instanceId===t.data.instanceId);await Promise.all(e.map(n=>n.handler(t.data.answerId)));const s={type:"qp-bridge",status:"success",id:t.data.id,instanceId:t.data.instanceId};window.parent.postMessage(s,"*")}}catch(e){const s={type:"qp-bridge",status:"error",id:_e(t.data)?t.data.id:void 0,instanceId:_e(t.data)?t.data.instanceId:void 0,message:e instanceof Error?e.message:"Unknown error"};window.parent.postMessage(s,"*")}}async function qn(t,e){return await Qn({type:"qp-bridge",action:"fetchEntities",fetchXml:t},e)}async function An(t,e,s){return await Bn({type:"qp-bridge",action:"getEntityById",entityName:t,entityId:e},s)}function Nn(){return{isNew:!0}}async function On(t,e){await T({type:"qp-bridge",action:"saveEntity",entity:t},e)}async function Zn(t,e,s){await T({type:"qp-bridge",action:"repeatGroup",parentGroupName:t,groupIndex:e},s)}async function jn(t,e){await T({type:"qp-bridge",action:"addNewGroup",groupName:t},e)}async function Pn(t,e,s){await T({type:"qp-bridge",action:"deleteGroup",parentGroupName:t,groupIndex:e},s)}async function ee(t,e,s){return new Promise((n,a)=>{const r=Ke(),i=K(s),o=d=>{if(Kt(d.data,r,i))return;const l=e(d.data);l.success?n(l.data):Dt(d.data)?a(new Error(d.data.message)):a(new Error("Unknown message received")),window.removeEventListener("message",o)};window.addEventListener("message",o),window.parent.postMessage({...t,id:r,instanceId:i,featureVersion:at},"*")})}async function Gn(t,e){return ee(t,s=>zt(s)?{success:!0,data:s.question}:{success:!1},e)}async function Ln(t,e){return ee(t,s=>Ft(s)?{success:!0,data:s.group}:{success:!1},e)}async function $n(t,e){return ee(t,s=>Wt(s)?{success:!0,data:s.questionnaire}:{success:!1},e)}function T(t,e){return ee(t,s=>Ut(s)?{success:!0,data:void 0}:{success:!1},e)}async function Qn(t,e){return ee(t,s=>es(s)?{success:!0,data:s.entities}:{success:!1},e)}async function Bn(t,e){return ee(t,s=>ts(s)?{success:!0,data:s.entity}:{success:!1},e)}exports.QP_BRIDGE_FEATURE_VERSION=at;exports.addNewGroup=jn;exports.addNewGroupRequestMessageSchema=Lt;exports.busyIndicatorEndRequestMessageSchema=It;exports.busyIndicatorStartRequestMessageSchema=Ct;exports.canSaveRequestMessageSchema=St;exports.canSaveSuccessResponseMessageSchema=kt;exports.commandExecutedMessageSchema=it;exports.completeAndCloseQuestionnaire=Rn;exports.completeAndCloseQuestionnaireRequestMessageSchema=qt;exports.createMediaItem=ln;exports.createNewEntity=Nn;exports.deleteGroup=Pn;exports.deleteGroupRequestMessageSchema=$t;exports.entitySchema=ke;exports.executeCustomCommand=Mn;exports.executeCustomCommandRequestMessageSchema=At;exports.fetchEntities=qn;exports.fetchEntitiesRequestMessageSchema=Nt;exports.fetchEntitiesSuccessResponseMessageSchema=Ot;exports.flattenQuestionnaireItems=rs;exports.flattenQuestions=pn;exports.getEntityById=An;exports.getEntityByIdRequestMessageSchema=Zt;exports.getEntityByIdSuccessResponseMessageSchema=jt;exports.getGroup=xn;exports.getGroupRequestMessageSchema=_t;exports.getGroupSuccessResponseMessageSchema=xt;exports.getQuestion=vn;exports.getQuestionRequestMessageSchema=gt;exports.getQuestionSuccessResponseMessageSchema=yt;exports.getQuestionnaire=mn;exports.getQuestionnaireRequestMessageSchema=bt;exports.getQuestionnaireSuccessResponseMessageSchema=wt;exports.groupOptionalScheme=Le;exports.groupSchema=Ge;exports.initOnSaveMessageHandler=ns;exports.isAddNewGroupRequestMessage=un;exports.isBusyIndicatorEndRequestMessage=Xt;exports.isBusyIndicatorStartRequestMessage=Yt;exports.isCanSaveRequestMessage=Ht;exports.isCanSaveSuccessResponseMessage=Ks;exports.isCommandExecutedMessage=Bt;exports.isCompleteAndCloseQuestionnaireRequestMessage=tn;exports.isDeleteGroupRequestMessage=dn;exports.isErrorMessage=Dt;exports.isExecuteCustomCommandRequestMessage=sn;exports.isFetchEntitiesRequestMessage=an;exports.isFetchEntitiesSuccessResponseMessage=es;exports.isGetEntityByIdRequestMessage=rn;exports.isGetEntityByIdSuccessResponseMessage=ts;exports.isGetGroupRequestMessage=Ys;exports.isGetGroupSuccessResponseMessage=Ft;exports.isGetQuestionRequestMessage=Fs;exports.isGetQuestionSuccessResponseMessage=zt;exports.isGetQuestionnaireRequestMessage=Xs;exports.isGetQuestionnaireSuccessResponseMessage=Wt;exports.isMediaItem=Ds;exports.isNotRelevantMessage=Kt;exports.isOnAnswerChangeMessage=Qt;exports.isPostSaveRequestMessage=Jt;exports.isQpBridgeMessage=_e;exports.isQpBridgeRequestMessage=zs;exports.isQuestionnaireLoadedMessage=Vt;exports.isRepeatGroupRequestMessage=cn;exports.isSaveEntityRequestMessage=on;exports.isSaveQuestionnaireRequestMessage=en;exports.isSetAnswerRequestMessage=Ws;exports.isSetGroupRequestMessage=Js;exports.isSetQuestionRequestMessage=Hs;exports.isSuccessMessage=Ut;exports.isWithBusyIndicatorRequestMessage=nn;exports.mediaItemSchema=ft;exports.onAnswerChange=wn;exports.onAnswerChangeMessageSchema=rt;exports.onCommandExecuted=Cn;exports.onPostSave=En;exports.onQuestionnaireLoaded=Tn;exports.onSave=In;exports.postSaveRequestMessageSchema=Rt;exports.qpBridgeBaseMessageSchema=V;exports.qpBridgeRequestMessageSchema=k;exports.questionOptionalScheme=dt;exports.questionSchema=we;exports.questionTypeSchema=ut;exports.questionnaireGroupSchema=Qe;exports.questionnaireItemSchema=$e;exports.questionnaireLoadedMessageSchema=ot;exports.questionnaireQuestionSchema=lt;exports.questionnaireRepeatableGroupSchema=mt;exports.questionnaireSchema=pt;exports.questionnaireStaticComponentSchema=ht;exports.removeOnSaveMessageHandler=hn;exports.repeatGroup=Zn;exports.repeatGroupRequestMessageSchema=Gt;exports.responseErrorMessageSchema=ct;exports.responseSuccessMessageSchema=U;exports.saveEntity=On;exports.saveEntityRequestMessageSchema=Pt;exports.saveQuestionnaire=Sn;exports.saveQuestionnaireRequestMessageSchema=Et;exports.setAnswer=yn;exports.setAnswerRequestMessageSchema=Tt;exports.setGroup=bn;exports.setGroupRequestMessageSchema=Mt;exports.setQuestion=_n;exports.setQuestionRequestMessageSchema=vt;exports.traverseQuestionnaireItems=as;exports.updateMediaItem=fn;exports.withBusyIndicator=kn;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=((e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports))(((e,t)=>{var n=t.exports={},r,i;function a(){throw Error(`setTimeout has not been defined`)}function o(){throw Error(`clearTimeout has not been defined`)}(function(){try{r=typeof setTimeout==`function`?setTimeout:a}catch{r=a}try{i=typeof clearTimeout==`function`?clearTimeout:o}catch{i=o}})();function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch{try{return r.call(null,e,0)}catch{return r.call(this,e,0)}}}function c(e){if(i===clearTimeout)return clearTimeout(e);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{return i(e)}catch{try{return i.call(null,e)}catch{return i.call(this,e)}}}var l=[],u=!1,d,f=-1;function p(){!u||!d||(u=!1,d.length?l=d.concat(l):f=-1,l.length&&ee())}function ee(){if(!u){var e=s(p);u=!0;for(var t=l.length;t;){for(d=l,l=[];++f<t;)d&&d[f].run();f=-1,t=l.length}d=null,u=!1,c(e)}}n.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new m(e,t)),l.length===1&&!u&&s(ee)};function m(e,t){this.fun=e,this.array=t}m.prototype.run=function(){this.fun.apply(null,this.array)},n.title=`browser`,n.browser=!0,n.env={},n.argv=[],n.version=``,n.versions={};function h(){}n.on=h,n.addListener=h,n.once=h,n.off=h,n.removeListener=h,n.removeAllListeners=h,n.emit=h,n.prependListener=h,n.prependOnceListener=h,n.listeners=function(e){return[]},n.binding=function(e){throw Error(`process.binding is not supported`)},n.cwd=function(){return`/`},n.chdir=function(e){throw Error(`process.chdir is not supported`)},n.umask=function(){return 0}})),t=[];for(let e=0;e<256;++e)t.push((e+256).toString(16).slice(1));function n(e,n=0){return(t[e[n+0]]+t[e[n+1]]+t[e[n+2]]+t[e[n+3]]+`-`+t[e[n+4]]+t[e[n+5]]+`-`+t[e[n+6]]+t[e[n+7]]+`-`+t[e[n+8]]+t[e[n+9]]+`-`+t[e[n+10]]+t[e[n+11]]+t[e[n+12]]+t[e[n+13]]+t[e[n+14]]+t[e[n+15]]).toLowerCase()}var r=new Uint8Array(16);function i(){return crypto.getRandomValues(r)}function a(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():o(e,t,n)}function o(e,t,r){e||={};let a=e.random??e.rng?.()??i();if(a.length<16)throw Error(`Random bytes length must be >= 16`);if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,t){if(r||=0,r<0||r+16>t.length)throw RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=a[e];return t}return n(a)}var s;(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})(s||={});var c;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(c||={});var l=s.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),u=e=>{switch(typeof e){case`undefined`:return l.undefined;case`string`:return l.string;case`number`:return Number.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:e===null?l.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?l.promise:typeof Map<`u`&&e instanceof Map?l.map:typeof Set<`u`&&e instanceof Set?l.set:typeof Date<`u`&&e instanceof Date?l.date:l.object;default:return l.unknown}},d=s.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`]),f=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,s.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()}};f.create=e=>new f(e);var p=(e,t)=>{let n;switch(e.code){case d.invalid_type:n=e.received===l.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,s.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${s.joinValues(e.keys,`, `)}`;break;case d.invalid_union:n=`Invalid input`;break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${s.joinValues(e.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${s.joinValues(e.options)}, received '${e.received}'`;break;case d.invalid_arguments:n=`Invalid function arguments`;break;case d.invalid_return_type:n=`Invalid function return type`;break;case d.invalid_date:n=`Invalid date`;break;case d.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:s.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case d.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case d.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case d.custom:n=`Invalid input`;break;case d.invalid_intersection_types:n=`Intersection results could not be merged`;break;case d.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case d.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,s.assertNever(e)}return{message:n}},ee=p;function m(){return ee}var h=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 g(e,t){let n=m(),r=h({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===p?void 0:p].filter(e=>!!e)});e.common.issues.push(r)}var _=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 v;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 v;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}}},v=Object.freeze({status:`aborted`}),te=e=>({status:`dirty`,value:e}),y=e=>({status:`valid`,value:e}),ne=e=>e.status===`aborted`,re=e=>e.status===`dirty`,b=e=>e.status===`valid`,ie=e=>typeof Promise<`u`&&e instanceof Promise,x;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(x||={});var S=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}},ae=(e,t)=>{if(b(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 f(e.common.issues);return this._error=t,this._error}}};function C(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var w=class{get description(){return this._def.description}_getType(e){return u(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:u(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new _,ctx:{common:e.parent.common,data:e.data,parsedType:u(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ie(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:u(e)};return ae(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:u(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return b(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=>b(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:u(e)},r=this._parse({data:e,path:n.path,parent:n});return ae(n,await(ie(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:d.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new P({schema:this,typeName:R.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 F.create(this,this._def)}nullable(){return I.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return D.create(this)}promise(){return N.create(this,this._def)}or(e){return Ve.create([this,e],this._def)}and(e){return j.create(this,e,this._def)}transform(e){return new P({...C(this._def),schema:this,typeName:R.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new L({...C(this._def),innerType:this,defaultValue:t,typeName:R.ZodDefault})}brand(){return new tt({typeName:R.ZodBranded,type:this,...C(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new $e({...C(this._def),innerType:this,catchValue:t,typeName:R.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return nt.create(this,e)}readonly(){return rt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},oe=/^c[^\s-]{8,}$/i,se=/^[0-9a-z]+$/,ce=/^[0-9A-HJKMNP-TV-Z]{26}$/i,le=/^[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,ue=/^[a-z0-9_-]{21}$/i,de=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,fe=/^[-+]?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)?)??$/,pe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,me=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,he,ge=/^(?:(?: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])$/,_e=/^(?:(?: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])$/,ve=/^(([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]))$/,ye=/^(([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])$/,be=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Se=`((\\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])))`,Ce=RegExp(`^${Se}$`);function we(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 Te(e){return RegExp(`^${we(e)}$`)}function Ee(e){let t=`${Se}T${we(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function De(e,t){return!!((t===`v4`||!t)&&ge.test(e)||(t===`v6`||!t)&&ve.test(e))}function Oe(e,t){if(!de.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 ke(e,t){return!!((t===`v4`||!t)&&_e.test(e)||(t===`v6`||!t)&&ye.test(e))}var Ae=class e extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==l.string){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.string,received:t.parsedType}),v}let t=new _,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:d.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:d.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?g(n,{code:d.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&g(n,{code:d.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)pe.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`email`,code:d.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)he||=new RegExp(me,`u`),he.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`emoji`,code:d.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)le.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`uuid`,code:d.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)ue.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`nanoid`,code:d.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)oe.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`cuid`,code:d.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)se.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`cuid2`,code:d.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)ce.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`ulid`,code:d.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),g(n,{validation:`url`,code:d.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`regex`,code:d.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),g(n,{code:d.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),g(n,{code:d.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),g(n,{code:d.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Ee(r).test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:d.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Ce.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:d.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Te(r).test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:d.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?fe.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`duration`,code:d.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?De(e.data,r.version)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`ip`,code:d.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Oe(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`jwt`,code:d.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?ke(e.data,r.version)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`cidr`,code:d.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?be.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`base64`,code:d.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?xe.test(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{validation:`base64url`,code:d.invalid_string,message:r.message}),t.dirty()):s.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:d.invalid_string,...x.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...x.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...x.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...x.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...x.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...x.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...x.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...x.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...x.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...x.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...x.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...x.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...x.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,...x.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,...x.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...x.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...x.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...x.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...x.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...x.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...x.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...x.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...x.errToObj(t)})}nonempty(e){return this.min(1,x.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}};Ae.create=e=>new Ae({checks:[],typeName:R.ZodString,coerce:e?.coerce??!1,...C(e)});function je(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 Me=class e extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==l.number){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.number,received:t.parsedType}),v}let t,n=new _;for(let r of this._def.checks)r.kind===`int`?s.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:d.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:d.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:d.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?je(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),g(t,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),g(t,{code:d.not_finite,message:r.message}),n.dirty()):s.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,x.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,x.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,x.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,x.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:x.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:x.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:x.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:x.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:x.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:x.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`&&s.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)}};Me.create=e=>new Me({checks:[],typeName:R.ZodNumber,coerce:e?.coerce||!1,...C(e)});var Ne=class e extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==l.bigint)return this._getInvalidInput(e);let t,n=new _;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:d.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),g(t,{code:d.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),g(t,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):s.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit(`min`,e,!0,x.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,x.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,x.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,x.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:x.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:x.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:x.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}};Ne.create=e=>new Ne({checks:[],typeName:R.ZodBigInt,coerce:e?.coerce??!1,...C(e)});var Pe=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==l.boolean){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.boolean,received:t.parsedType}),v}return y(e.data)}};Pe.create=e=>new Pe({typeName:R.ZodBoolean,coerce:e?.coerce||!1,...C(e)});var Fe=class e extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==l.date){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.date,received:t.parsedType}),v}if(Number.isNaN(e.data.getTime()))return g(this._getOrReturnCtx(e),{code:d.invalid_date}),v;let t=new _,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:d.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),g(n,{code:d.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):s.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:x.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:x.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)}};Fe.create=e=>new Fe({checks:[],coerce:e?.coerce||!1,typeName:R.ZodDate,...C(e)});var Ie=class extends w{_parse(e){if(this._getType(e)!==l.symbol){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.symbol,received:t.parsedType}),v}return y(e.data)}};Ie.create=e=>new Ie({typeName:R.ZodSymbol,...C(e)});var Le=class extends w{_parse(e){if(this._getType(e)!==l.undefined){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.undefined,received:t.parsedType}),v}return y(e.data)}};Le.create=e=>new Le({typeName:R.ZodUndefined,...C(e)});var Re=class extends w{_parse(e){if(this._getType(e)!==l.null){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.null,received:t.parsedType}),v}return y(e.data)}};Re.create=e=>new Re({typeName:R.ZodNull,...C(e)});var ze=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return y(e.data)}};ze.create=e=>new ze({typeName:R.ZodAny,...C(e)});var T=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return y(e.data)}};T.create=e=>new T({typeName:R.ZodUnknown,...C(e)});var E=class extends w{_parse(e){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.never,received:t.parsedType}),v}};E.create=e=>new E({typeName:R.ZodNever,...C(e)});var Be=class extends w{_parse(e){if(this._getType(e)!==l.undefined){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.void,received:t.parsedType}),v}return y(e.data)}};Be.create=e=>new Be({typeName:R.ZodVoid,...C(e)});var D=class e extends w{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==l.array)return g(t,{code:d.invalid_type,expected:l.array,received:t.parsedType}),v;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(g(t,{code:e?d.too_big:d.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(g(t,{code:d.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(g(t,{code:d.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new S(t,e,t.path,n)))).then(e=>_.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new S(t,e,t.path,n)));return _.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:x.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:x.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:x.toString(n)}})}nonempty(e){return this.min(1,e)}};D.create=(e,t)=>new D({type:e,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...C(t)});function O(e){if(e instanceof k){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=F.create(O(r))}return new k({...e._def,shape:()=>t})}else if(e instanceof D)return new D({...e._def,type:O(e.element)});else if(e instanceof F)return F.create(O(e.unwrap()));else if(e instanceof I)return I.create(O(e.unwrap()));else if(e instanceof M)return M.create(e.items.map(e=>O(e)));else return e}var k=class e extends w{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=s.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==l.object){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.object,received:t.parsedType}),v}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof E&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new S(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof E){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(g(n,{code:d.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new S(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>_.mergeObjectSync(t,e)):_.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return x.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:x.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:R.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of s.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of s.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return O(this)}partial(t){let n={};for(let e of s.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of s.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof F;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Xe(s.objectKeys(this.shape))}};k.create=(e,t)=>new k({shape:()=>e,unknownKeys:`strip`,catchall:E.create(),typeName:R.ZodObject,...C(t)}),k.strictCreate=(e,t)=>new k({shape:()=>e,unknownKeys:`strict`,catchall:E.create(),typeName:R.ZodObject,...C(t)}),k.lazycreate=(e,t)=>new k({shape:e,unknownKeys:`strip`,catchall:E.create(),typeName:R.ZodObject,...C(t)});var Ve=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new f(e.ctx.common.issues));return g(t,{code:d.invalid_union,unionErrors:n}),v}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 f(e));return g(t,{code:d.invalid_union,unionErrors:i}),v}}get options(){return this._def.options}};Ve.create=(e,t)=>new Ve({options:e,typeName:R.ZodUnion,...C(t)});var A=e=>e instanceof Je?A(e.schema):e instanceof P?A(e.innerType()):e instanceof Ye?[e.value]:e instanceof Ze?e.options:e instanceof Qe?s.objectValues(e.enum):e instanceof L?A(e._def.innerType):e instanceof Le?[void 0]:e instanceof Re?[null]:e instanceof F?[void 0,...A(e.unwrap())]:e instanceof I?[null,...A(e.unwrap())]:e instanceof tt||e instanceof rt?A(e.unwrap()):e instanceof $e?A(e._def.innerType):[],He=class e extends w{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.object)return g(t,{code:d.invalid_type,expected:l.object,received:t.parsedType}),v;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(g(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}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:R.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...C(r)})}};function Ue(e,t){let n=u(e),r=u(t);if(e===t)return{valid:!0,data:e};if(n===l.object&&r===l.object){let n=s.objectKeys(t),r=s.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ue(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===l.array&&r===l.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ue(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===l.date&&r===l.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var j=class extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(ne(e)||ne(r))return v;let i=Ue(e.value,r.value);return i.valid?((re(e)||re(r))&&t.dirty(),{status:t.value,value:i.data}):(g(n,{code:d.invalid_intersection_types}),v)};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:R.ZodIntersection,...C(n)});var M=class e extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==l.array)return g(n,{code:d.invalid_type,expected:l.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return g(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),v;!this._def.rest&&n.data.length>this._def.items.length&&(g(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new S(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>_.mergeArray(t,e)):_.mergeArray(t,r)}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:R.ZodTuple,rest:null,...C(t)})};var We=class e extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==l.object)return g(n,{code:d.invalid_type,expected:l.object,received:n.parsedType}),v;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new S(n,e,n.path,e)),value:a._parse(new S(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?_.mergeObjectAsync(t,r):_.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof w?new e({keyType:t,valueType:n,typeName:R.ZodRecord,...C(r)}):new e({keyType:Ae.create(),valueType:t,typeName:R.ZodRecord,...C(n)})}},Ge=class extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==l.map)return g(n,{code:d.invalid_type,expected:l.map,received:n.parsedType}),v;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new S(n,e,n.path,[a,`key`])),value:i._parse(new S(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return v;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return v;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Ge.create=(e,t,n)=>new Ge({valueType:t,keyType:e,typeName:R.ZodMap,...C(n)});var Ke=class e extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==l.set)return g(n,{code:d.invalid_type,expected:l.set,received:n.parsedType}),v;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(g(n,{code:d.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(g(n,{code:d.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return v;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new S(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:x.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:x.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ke.create=(e,t)=>new Ke({valueType:e,minSize:null,maxSize:null,typeName:R.ZodSet,...C(t)});var qe=class e extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.function)return g(t,{code:d.invalid_type,expected:l.function,received:t.parsedType}),v;function n(e,n){return h({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,m(),p].filter(e=>!!e),issueData:{code:d.invalid_arguments,argumentsError:n}})}function r(e,n){return h({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,m(),p].filter(e=>!!e),issueData:{code:d.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof N){let e=this;return y(async function(...t){let o=new f([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return y(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new f([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new f([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:M.create(t).rest(T.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(T.create()),returns:n||T.create(),typeName:R.ZodFunction,...C(r)})}},Je=class extends w{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Je.create=(e,t)=>new Je({getter:e,typeName:R.ZodLazy,...C(t)});var Ye=class extends w{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return g(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Ye.create=(e,t)=>new Ye({value:e,typeName:R.ZodLiteral,...C(t)});function Xe(e,t){return new Ze({values:e,typeName:R.ZodEnum,...C(t)})}var Ze=class e extends w{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return g(t,{expected:s.joinValues(n),received:t.parsedType,code:d.invalid_type}),v}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return g(t,{received:t.data,code:d.invalid_enum_value,options:n}),v}return y(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})}};Ze.create=Xe;var Qe=class extends w{_parse(e){let t=s.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==l.string&&n.parsedType!==l.number){let e=s.objectValues(t);return g(n,{expected:s.joinValues(e),received:n.parsedType,code:d.invalid_type}),v}if(this._cache||=new Set(s.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=s.objectValues(t);return g(n,{received:n.data,code:d.invalid_enum_value,options:e}),v}return y(e.data)}get enum(){return this._def.values}};Qe.create=(e,t)=>new Qe({values:e,typeName:R.ZodNativeEnum,...C(t)});var N=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==l.promise&&t.common.async===!1?(g(t,{code:d.invalid_type,expected:l.promise,received:t.parsedType}),v):y((t.parsedType===l.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};N.create=(e,t)=>new N({type:e,typeName:R.ZodPromise,...C(t)});var P=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{g(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return v;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?v:r.status===`dirty`||t.value===`dirty`?te(r.value):r});{if(t.value===`aborted`)return v;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?v:r.status===`dirty`||t.value===`dirty`?te(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?v:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?v:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!b(e))return v;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>b(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):v);s.assertNever(r)}};P.create=(e,t,n)=>new P({schema:e,typeName:R.ZodEffects,effect:t,...C(n)}),P.createWithPreprocess=(e,t,n)=>new P({schema:t,effect:{type:`preprocess`,transform:e},typeName:R.ZodEffects,...C(n)});var F=class extends w{_parse(e){return this._getType(e)===l.undefined?y(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(e,t)=>new F({innerType:e,typeName:R.ZodOptional,...C(t)});var I=class extends w{_parse(e){return this._getType(e)===l.null?y(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};I.create=(e,t)=>new I({innerType:e,typeName:R.ZodNullable,...C(t)});var L=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===l.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};L.create=(e,t)=>new L({innerType:e,typeName:R.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...C(t)});var $e=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ie(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new f(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new f(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};$e.create=(e,t)=>new $e({innerType:e,typeName:R.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...C(t)});var et=class extends w{_parse(e){if(this._getType(e)!==l.nan){let t=this._getOrReturnCtx(e);return g(t,{code:d.invalid_type,expected:l.nan,received:t.parsedType}),v}return{status:`valid`,value:e.data}}};et.create=e=>new et({typeName:R.ZodNaN,...C(e)});var tt=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},nt=class e extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?v:e.status===`dirty`?(t.dirty(),te(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?v: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:R.ZodPipeline})}},rt=class extends w{_parse(e){let t=this._def.innerType._parse(e),n=e=>(b(e)&&(e.value=Object.freeze(e.value)),e);return ie(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};rt.create=(e,t)=>new rt({innerType:e,typeName:R.ZodReadonly,...C(t)}),k.lazycreate;var R;(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`})(R||={});var z=Ae.create,it=Me.create;et.create,Ne.create;var B=Pe.create;Fe.create,Ie.create,Le.create,Re.create,ze.create;var at=T.create;E.create,Be.create;var V=D.create,H=k.create;k.strictCreate;var ot=Ve.create,st=He.create;j.create,M.create;var ct=We.create;Ge.create,Ke.create,qe.create;var lt=Je.create,U=Ye.create,ut=Ze.create;Qe.create,N.create,P.create,F.create,I.create,P.createWithPreprocess,nt.create;var dt=e(),ft=3,W=H({type:U(`qp-bridge`),id:z().optional(),instanceId:z().optional()}),G=W.extend({featureVersion:it().optional()}),pt=W.extend({status:U(`answerChanged`),question:z(),answer:at()}),mt=W.extend({action:U(`commandExecuted`),commandName:z()}),ht=W.extend({action:U(`questionnaireLoaded`)}),K=W.extend({status:U(`success`)}),gt=W.extend({status:U(`error`),message:z()}),_t=ut([`imageMedia`,`shortText`,`longText`,`url`,`email`,`wholeNumber`,`decimalNumber`,`date`,`dateTime`,`singleSelect`,`multiSelect`,`optionSet`,`rating`,`yesNo`,`signature`,`lookup`]),vt=H({type:_t,semanticColor:z().optional(),label:z().optional(),description:z().optional(),disabled:B(),required:B(),hidden:B(),errorMessage:z().optional(),answer:at().optional()}),yt=vt.partial(),bt=vt.extend({itemType:U(`question`),name:z()}),xt=H({id:z().uuid(),name:z(),mimeType:z(),blobUrl:z()}),St=ct(at()),Ct=H({label:z(),hidden:B(),collapsed:B()}),wt=Ct.partial(),Tt=st(`type`,[H({itemType:U(`staticComponent`),type:U(`staticDescription`),name:z(),hidden:B().optional(),content:z()}),H({itemType:U(`staticComponent`),type:U(`button`),name:z(),hidden:B().optional(),label:z(),disabled:B().optional(),semanticColor:z().optional(),commandName:z().optional(),commandLabel:z().optional()})]),Et=wt.extend({itemType:U(`group`),name:z()}),Dt=H({itemType:U(`repeatableGroup`),name:z(),label:z().optional(),hidden:B().optional()}),Ot=lt(()=>ot([bt,kt,At,Tt])),kt=lt(()=>Et.extend({items:V(Ot)})),At=lt(()=>Dt.extend({groups:V(kt)})),jt=H({entityName:z(),id:z(),name:z()}),Mt=H({isNew:B(),id:z().uuid(),name:z(),label:z(),description:z().optional(),regarding:jt.optional(),items:V(Ot)}),Nt=G.extend({action:U(`getQuestion`),question:z()}),Pt=K.extend({question:vt}),Ft=G.extend({action:U(`setQuestion`),question:z(),questionData:yt}),It=G.extend({action:U(`getGroup`),group:z()}),Lt=K.extend({group:Ct}),Rt=G.extend({action:U(`getQuestionnaire`)}),zt=K.extend({questionnaire:Mt}),Bt=K.extend({canSave:B()}),Vt=G.extend({action:U(`canSave`)}),Ht=G.extend({action:U(`postSave`),answerId:z()}),Ut=G.extend({action:U(`setGroup`),group:z(),groupData:wt}),Wt=G.extend({action:U(`setAnswer`),question:z(),answer:at()}),Gt=G.extend({action:U(`busyIndicatorStart`)}),Kt=G.extend({action:U(`busyIndicatorEnd`)}),qt=G.extend({action:U(`saveQuestionnaire`)}),Jt=G.extend({action:U(`completeAndCloseQuestionnaire`)}),Yt=G.extend({action:U(`executeCustomCommand`),commandName:z()}),Xt=G.extend({action:U(`fetchEntities`),fetchXml:z()}),Zt=K.extend({entities:V(St)}),Qt=G.extend({action:U(`getEntityById`),entityName:z(),entityId:z()}),$t=K.extend({entity:St}),en=G.extend({action:U(`saveEntity`),entity:St}),tn=G.extend({action:U(`repeatGroup`),parentGroupName:z(),groupIndex:it()}),nn=G.extend({action:U(`addNewGroup`),groupName:z()}),rn=G.extend({action:U(`deleteGroup`),parentGroupName:z(),groupIndex:it()});function an(e){return xt.safeParse(e).success}function on(e){return pt.safeParse(e).success}function sn(e){return mt.safeParse(e).success}function cn(e){return ht.safeParse(e).success}function ln(e){return W.safeParse(e).success}function un(e){return G.safeParse(e).success}function dn(e){return K.safeParse(e).success}function fn(e){return gt.safeParse(e).success}function pn(e){return Nt.safeParse(e).success}function mn(e){return Pt.safeParse(e).success}function hn(e){return Wt.safeParse(e).success}function gn(e){return Ft.safeParse(e).success}function _n(e){return Ut.safeParse(e).success}function vn(e){return It.safeParse(e).success}function yn(e){return Rt.safeParse(e).success}function bn(e){return Lt.safeParse(e).success}function xn(e){return zt.safeParse(e).success}function Sn(e){return Bt.safeParse(e).success}function Cn(e){return Vt.safeParse(e).success}function wn(e){return Ht.safeParse(e).success}function Tn(e){return Gt.safeParse(e).success}function En(e){return Kt.safeParse(e).success}function Dn(e){return qt.safeParse(e).success}function On(e){return Jt.safeParse(e).success}function kn(e){return Yt.safeParse(e).success}function An(e){return Tn(e)||En(e)}function jn(e,t,n){return!ln(e)||e.id!==t||n!==void 0&&e.instanceId!==n||!(`status`in e)}function Mn(e){return Xt.safeParse(e).success}function Nn(e){return Zt.safeParse(e).success}function Pn(e){return Qt.safeParse(e).success}function Fn(e){return $t.safeParse(e).success}function In(e){return en.safeParse(e).success}function Ln(e){return tn.safeParse(e).success}function Rn(e){return nn.safeParse(e).success}function zn(e){return rn.safeParse(e).success}function q(e){if(e?.instanceId!=null)return e.instanceId;let t=globalThis.__RESCO_QP_BRIDGE_INSTANCE_ID;return typeof t==`string`?t:void 0}function Bn(e){if(e instanceof File||e instanceof Blob)return URL.createObjectURL(e);if(typeof e==`string`){if(/^data:/.test(e)){let t=e.match(/^data:([^;]+);base64,(.*)$/);if(t){let e=t[1],n=t[2],r=atob(n),i=new ArrayBuffer(r.length),a=new Uint8Array(i);for(let e=0;e<r.length;e++)a[e]=r.charCodeAt(e);let o=new Blob([i],{type:e});return URL.createObjectURL(o)}throw Error(`Invalid data URL format. Only base64 data URLs are supported.`)}let t=atob(e),n=new ArrayBuffer(t.length),r=new Uint8Array(n);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);let i=new Blob([n]);return URL.createObjectURL(i)}if(e instanceof ArrayBuffer){let t=new Blob([e]);return URL.createObjectURL(t)}throw Error(`Unsupported content type for blobUrl`)}function Vn(e,t,n,r){return{id:r??a(),name:e,mimeType:t,blobUrl:Bn(n)}}function Hn(e,t){let n=e.blobUrl;return t.content!==void 0&&(n=Bn(t.content)),{...e,...t,blobUrl:n}}dt.env?.NODE_ENV!==`test`&&Un();function Un(){window.addEventListener(`message`,dr)}function Wn(){window.removeEventListener(`message`,dr)}async function Gn(e){return await xr({type:`qp-bridge`,action:`getQuestionnaire`},e)}function Kn(e,t){Xn(e.items,[],t)}function qn(e){let t=[];return Kn(e,e=>t.push(e)),t}function Jn(e){return qn(e).filter(Yn)}function Yn(e){return e.itemType===`question`}function Xn(e,t,n){for(let r of e)switch(n(r,t),r.itemType){case`question`:case`staticComponent`:break;case`group`:Xn(r.items,[...t,r],n);break;case`repeatableGroup`:Xn(r.groups,[...t,r],n);break;default:return r}}async function Zn(e,t,n){await $({type:`qp-bridge`,action:`setAnswer`,question:e,answer:t},n)}async function Qn(e,t){return await yr({type:`qp-bridge`,action:`getQuestion`,question:e},t)}async function $n(e,t,n){await $({type:`qp-bridge`,action:`setQuestion`,question:e,questionData:t},n)}async function er(e,t){return await br({type:`qp-bridge`,action:`getGroup`,group:e},t)}async function tr(e,t,n){await $({type:`qp-bridge`,action:`setGroup`,group:e,groupData:t},n)}function nr(e,t){let n=q(t),r=t=>{on(t.data)&&t.data.instanceId===n&&e(t.data.question,t.data.answer)};return window.addEventListener(`message`,r),{cancelSubscription:()=>{window.removeEventListener(`message`,r)}}}async function rr(e,t){await $({type:`qp-bridge`,action:`busyIndicatorStart`},t);try{return await e()}finally{await $({type:`qp-bridge`,action:`busyIndicatorEnd`},t)}}async function ir(e){await $({type:`qp-bridge`,action:`saveQuestionnaire`},e)}async function ar(e){await $({type:`qp-bridge`,action:`completeAndCloseQuestionnaire`},e)}async function or(e,t){await $({type:`qp-bridge`,action:`executeCustomCommand`,commandName:e},t)}var J=[],Y=[],X=[],Z=[];function sr(e,t){let n=q(t);return Z.some(t=>t.handler===e&&t.instanceId===n)||Z.push({handler:e,instanceId:n}),{cancelSubscription:()=>{let t=Z.findIndex(t=>t.handler===e&&t.instanceId===n);t!==-1&&Z.splice(t,1)}}}function cr(e,t){let n=q(t);return X.some(t=>t.handler===e&&t.instanceId===n)||X.push({handler:e,instanceId:n}),{cancelSubscription:()=>{let t=X.findIndex(t=>t.handler===e&&t.instanceId===n);t!==-1&&X.splice(t,1)}}}function lr(e,t){let n=q(t);return J.some(t=>t.validator===e&&t.instanceId===n)||J.push({validator:e,instanceId:n}),{cancelSubscription:()=>{let t=J.findIndex(t=>t.validator===e&&t.instanceId===n);t!==-1&&J.splice(t,1)}}}function ur(e,t){let n=q(t);return Y.some(t=>t.handler===e&&t.instanceId===n)||Y.push({handler:e,instanceId:n}),{cancelSubscription:()=>{let t=Y.findIndex(t=>t.handler===e&&t.instanceId===n);t!==-1&&Y.splice(t,1)}}}async function dr(e){try{if(sn(e.data)&&X.filter(t=>t.instanceId===e.data.instanceId).forEach(t=>t.handler(e.data.commandName)),cn(e.data)&&Z.filter(t=>t.instanceId===e.data.instanceId).forEach(e=>e.handler()),Cn(e.data)){let t=J.filter(t=>t.instanceId===e.data.instanceId),n=await Promise.all(t.map(e=>e.validator())),r={type:`qp-bridge`,status:`success`,id:e.data.id,instanceId:e.data.instanceId,canSave:n.every(e=>e)};window.parent.postMessage(r,`*`)}if(wn(e.data)){let t=Y.filter(t=>t.instanceId===e.data.instanceId);await Promise.all(t.map(t=>t.handler(e.data.answerId)));let n={type:`qp-bridge`,status:`success`,id:e.data.id,instanceId:e.data.instanceId};window.parent.postMessage(n,`*`)}}catch(t){let n={type:`qp-bridge`,status:`error`,id:ln(e.data)?e.data.id:void 0,instanceId:ln(e.data)?e.data.instanceId:void 0,message:t instanceof Error?t.message:`Unknown error`};window.parent.postMessage(n,`*`)}}async function fr(e,t){return await Sr({type:`qp-bridge`,action:`fetchEntities`,fetchXml:e},t)}async function pr(e,t,n){return await Cr({type:`qp-bridge`,action:`getEntityById`,entityName:e,entityId:t},n)}function mr(){return{isNew:!0}}async function hr(e,t){await $({type:`qp-bridge`,action:`saveEntity`,entity:e},t)}async function gr(e,t,n){await $({type:`qp-bridge`,action:`repeatGroup`,parentGroupName:e,groupIndex:t},n)}async function _r(e,t){await $({type:`qp-bridge`,action:`addNewGroup`,groupName:e},t)}async function vr(e,t,n){await $({type:`qp-bridge`,action:`deleteGroup`,parentGroupName:e,groupIndex:t},n)}async function Q(e,t,n){return new Promise((r,i)=>{let o=a(),s=q(n),c=e=>{if(jn(e.data,o,s))return;let n=t(e.data);n.success?r(n.data):fn(e.data)?i(Error(e.data.message)):i(Error(`Unknown message received`)),window.removeEventListener(`message`,c)};window.addEventListener(`message`,c),window.parent.postMessage({...e,id:o,instanceId:s,featureVersion:3},`*`)})}async function yr(e,t){return Q(e,e=>mn(e)?{success:!0,data:e.question}:{success:!1},t)}async function br(e,t){return Q(e,e=>bn(e)?{success:!0,data:e.group}:{success:!1},t)}async function xr(e,t){return Q(e,e=>xn(e)?{success:!0,data:e.questionnaire}:{success:!1},t)}function $(e,t){return Q(e,e=>dn(e)?{success:!0,data:void 0}:{success:!1},t)}async function Sr(e,t){return Q(e,e=>Nn(e)?{success:!0,data:e.entities}:{success:!1},t)}async function Cr(e,t){return Q(e,e=>Fn(e)?{success:!0,data:e.entity}:{success:!1},t)}exports.QP_BRIDGE_FEATURE_VERSION=ft,exports.addNewGroup=_r,exports.addNewGroupRequestMessageSchema=nn,exports.busyIndicatorEndRequestMessageSchema=Kt,exports.busyIndicatorStartRequestMessageSchema=Gt,exports.canSaveRequestMessageSchema=Vt,exports.canSaveSuccessResponseMessageSchema=Bt,exports.commandExecutedMessageSchema=mt,exports.completeAndCloseQuestionnaire=ar,exports.completeAndCloseQuestionnaireRequestMessageSchema=Jt,exports.createMediaItem=Vn,exports.createNewEntity=mr,exports.deleteGroup=vr,exports.deleteGroupRequestMessageSchema=rn,exports.entitySchema=St,exports.executeCustomCommand=or,exports.executeCustomCommandRequestMessageSchema=Yt,exports.fetchEntities=fr,exports.fetchEntitiesRequestMessageSchema=Xt,exports.fetchEntitiesSuccessResponseMessageSchema=Zt,exports.flattenQuestionnaireItems=qn,exports.flattenQuestions=Jn,exports.getEntityById=pr,exports.getEntityByIdRequestMessageSchema=Qt,exports.getEntityByIdSuccessResponseMessageSchema=$t,exports.getGroup=er,exports.getGroupRequestMessageSchema=It,exports.getGroupSuccessResponseMessageSchema=Lt,exports.getQuestion=Qn,exports.getQuestionRequestMessageSchema=Nt,exports.getQuestionSuccessResponseMessageSchema=Pt,exports.getQuestionnaire=Gn,exports.getQuestionnaireRequestMessageSchema=Rt,exports.getQuestionnaireSuccessResponseMessageSchema=zt,exports.groupOptionalScheme=wt,exports.groupSchema=Ct,exports.initOnSaveMessageHandler=Un,exports.isAddNewGroupRequestMessage=Rn,exports.isBusyIndicatorEndRequestMessage=En,exports.isBusyIndicatorStartRequestMessage=Tn,exports.isCanSaveRequestMessage=Cn,exports.isCanSaveSuccessResponseMessage=Sn,exports.isCommandExecutedMessage=sn,exports.isCompleteAndCloseQuestionnaireRequestMessage=On,exports.isDeleteGroupRequestMessage=zn,exports.isErrorMessage=fn,exports.isExecuteCustomCommandRequestMessage=kn,exports.isFetchEntitiesRequestMessage=Mn,exports.isFetchEntitiesSuccessResponseMessage=Nn,exports.isGetEntityByIdRequestMessage=Pn,exports.isGetEntityByIdSuccessResponseMessage=Fn,exports.isGetGroupRequestMessage=vn,exports.isGetGroupSuccessResponseMessage=bn,exports.isGetQuestionRequestMessage=pn,exports.isGetQuestionSuccessResponseMessage=mn,exports.isGetQuestionnaireRequestMessage=yn,exports.isGetQuestionnaireSuccessResponseMessage=xn,exports.isMediaItem=an,exports.isNotRelevantMessage=jn,exports.isOnAnswerChangeMessage=on,exports.isPostSaveRequestMessage=wn,exports.isQpBridgeMessage=ln,exports.isQpBridgeRequestMessage=un,exports.isQuestionnaireLoadedMessage=cn,exports.isRepeatGroupRequestMessage=Ln,exports.isSaveEntityRequestMessage=In,exports.isSaveQuestionnaireRequestMessage=Dn,exports.isSetAnswerRequestMessage=hn,exports.isSetGroupRequestMessage=_n,exports.isSetQuestionRequestMessage=gn,exports.isSuccessMessage=dn,exports.isWithBusyIndicatorRequestMessage=An,exports.mediaItemSchema=xt,exports.onAnswerChange=nr,exports.onAnswerChangeMessageSchema=pt,exports.onCommandExecuted=cr,exports.onPostSave=ur,exports.onQuestionnaireLoaded=sr,exports.onSave=lr,exports.postSaveRequestMessageSchema=Ht,exports.qpBridgeBaseMessageSchema=W,exports.qpBridgeRequestMessageSchema=G,exports.questionOptionalScheme=yt,exports.questionSchema=vt,exports.questionTypeSchema=_t,exports.questionnaireGroupSchema=kt,exports.questionnaireItemSchema=Ot,exports.questionnaireLoadedMessageSchema=ht,exports.questionnaireQuestionSchema=bt,exports.questionnaireRepeatableGroupSchema=At,exports.questionnaireSchema=Mt,exports.questionnaireStaticComponentSchema=Tt,exports.removeOnSaveMessageHandler=Wn,exports.repeatGroup=gr,exports.repeatGroupRequestMessageSchema=tn,exports.responseErrorMessageSchema=gt,exports.responseSuccessMessageSchema=K,exports.saveEntity=hr,exports.saveEntityRequestMessageSchema=en,exports.saveQuestionnaire=ir,exports.saveQuestionnaireRequestMessageSchema=qt,exports.setAnswer=Zn,exports.setAnswerRequestMessageSchema=Wt,exports.setGroup=tr,exports.setGroupRequestMessageSchema=Ut,exports.setQuestion=$n,exports.setQuestionRequestMessageSchema=Ft,exports.traverseQuestionnaireItems=Kn,exports.updateMediaItem=Hn,exports.withBusyIndicator=rr;