scordi-extension 1.15.1 → 1.15.2

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.
@@ -1,4 +1,4 @@
1
- "use strict";var Nn=Object.defineProperty;var Mn=(r,e,t)=>e in r?Nn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fe=(r,e,t)=>Mn(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class ct extends Error{constructor(e,t,a){super(e),this.code=t,this.details=a,this.name="EightGError"}static extensionNotInstalled(){return new ct("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new ct(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new ct(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(e=6e5){const t=Math.floor(e/1e3);return new ct(`Request timeout - Extension did not respond within ${t} seconds`,"REQUEST_TIMEOUT")}}function Rn(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}var be;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const c of s)i[c]=c;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(f=>typeof s[s[f]]!="number"),c={};for(const f of i)c[f]=s[f];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&i.push(c);return i},r.find=(s,i)=>{for(const c of s)if(i(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,i=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(i)}r.joinValues=a,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(be||(be={}));var Rr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Rr||(Rr={}));const W=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_t=r=>{switch(typeof r){case"undefined":return W.undefined;case"string":return W.string;case"number":return Number.isNaN(r)?W.nan:W.number;case"boolean":return W.boolean;case"function":return W.function;case"bigint":return W.bigint;case"symbol":return W.symbol;case"object":return Array.isArray(r)?W.array:r===null?W.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?W.promise:typeof Map<"u"&&r instanceof Map?W.map:typeof Set<"u"&&r instanceof Set?W.set:typeof Date<"u"&&r instanceof Date?W.date:W.object;default:return W.unknown}},O=be.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"]),In=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class at extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},a={_errors:[]},s=i=>{for(const c of i.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(t(c));else{let f=a,b=0;for(;b<c.path.length;){const _=c.path[b];b===c.path.length-1?(f[_]=f[_]||{_errors:[]},f[_]._errors.push(t(c))):f[_]=f[_]||{_errors:[]},f=f[_],b++}}};return s(this),a}static assert(e){if(!(e instanceof at))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},a=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];t[i]=t[i]||[],t[i].push(e(s))}else a.push(e(s));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}at.create=r=>new at(r);const Ht=(r,e)=>{let t;switch(r.code){case O.invalid_type:r.received===W.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case O.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,be.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:t=`Unrecognized key(s) in object: ${be.joinValues(r.keys,", ")}`;break;case O.invalid_union:t="Invalid input";break;case O.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${be.joinValues(r.options)}`;break;case O.invalid_enum_value:t=`Invalid enum value. Expected ${be.joinValues(r.options)}, received '${r.received}'`;break;case O.invalid_arguments:t="Invalid function arguments";break;case O.invalid_return_type:t="Invalid function return type";break;case O.invalid_date:t="Invalid date";break;case O.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case O.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case O.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case O.custom:t="Invalid input";break;case O.invalid_intersection_types:t="Intersection results could not be merged";break;case O.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case O.not_finite:t="Number must be finite";break;default:t=e.defaultError,be.assertNever(r)}return{message:t}};let pn=Ht;function jn(r){pn=r}function xr(){return pn}const _r=r=>{const{data:e,path:t,errorMaps:a,issueData:s}=r,i=[...t,...s.path||[]],c={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let f="";const b=a.filter(_=>!!_).slice().reverse();for(const _ of b)f=_(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},Fn=[];function B(r,e){const t=xr(),a=_r({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ht?void 0:Ht].filter(s=>!!s)});r.common.issues.push(a)}class Ke{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const s of t){if(s.status==="aborted")return ee;s.status==="dirty"&&e.dirty(),a.push(s.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const s of t){const i=await s.key,c=await s.value;a.push({key:i,value:c})}return Ke.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const s of t){const{key:i,value:c}=s;if(i.status==="aborted"||c.status==="aborted")return ee;i.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[i.value]=c.value)}return{status:e.value,value:a}}}const ee=Object.freeze({status:"aborted"}),Vt=r=>({status:"dirty",value:r}),Je=r=>({status:"valid",value:r}),Ir=r=>r.status==="aborted",jr=r=>r.status==="dirty",jt=r=>r.status==="valid",tr=r=>typeof Promise<"u"&&r instanceof Promise;var Y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class vt{constructor(e,t,a,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=s}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 cn=(r,e)=>{if(jt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new at(r.common.issues);return this._error=t,this._error}}};function ie(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:a,description:s}=r;if(e&&(t||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,f)=>{const{message:b}=r;return c.code==="invalid_enum_value"?{message:b??f.defaultError}:typeof f.data>"u"?{message:b??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:b??t??f.defaultError}},description:s}}class ce{get description(){return this._def.description}_getType(e){return _t(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:_t(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ke,ctx:{common:e.parent.common,data:e.data,parsedType:_t(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(tr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){const a={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},s=this._parseSync({data:e,path:a.path,parent:a});return cn(a,s)}"~validate"(e){var a,s;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return jt(i)?{value:i.value}:{issues:t.common.issues}}catch(i){(s=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>jt(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},s=this._parse({data:e,path:a.path,parent:a}),i=await(tr(s)?s:Promise.resolve(s));return cn(a,i)}refine(e,t){const a=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const c=e(s),f=()=>i.addIssue({code:O.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(b=>b?!0:(f(),!1)):c?!0:(f(),!1)})}refinement(e,t){return this._refinement((a,s)=>e(a)?!0:(s.addIssue(typeof t=="function"?t(a,s):t),!1))}_refinement(e){return new ht({schema:this,typeName:re.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:t=>this["~validate"](t)}}optional(){return gt.create(this,this._def)}nullable(){return Pt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this)}promise(){return Yt.create(this,this._def)}or(e){return sr.create([this,e],this._def)}and(e){return ir.create(this,e,this._def)}transform(e){return new ht({...ie(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new fr({...ie(this._def),innerType:this,defaultValue:t,typeName:re.ZodDefault})}brand(){return new Br({typeName:re.ZodBranded,type:this,...ie(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new dr({...ie(this._def),innerType:this,catchValue:t,typeName:re.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pr.create(this,e)}readonly(){return hr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $n=/^c[^\s-]{8,}$/i,Bn=/^[0-9a-z]+$/,Un=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ln=/^[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,Zn=/^[a-z0-9_-]{21}$/i,Wn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zn=/^[-+]?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)?)??$/,Vn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pr;const Hn=/^(?:(?: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])$/,Gn=/^(?:(?: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])$/,Yn=/^(([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]))$/,Kn=/^(([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])$/,Jn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mn="((\\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])))",Qn=new RegExp(`^${mn}$`);function yn(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function ea(r){return new RegExp(`^${yn(r)}$`)}function gn(r){let e=`${mn}T${yn(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ta(r,e){return!!((e==="v4"||!e)&&Hn.test(r)||(e==="v6"||!e)&&Yn.test(r))}function ra(r,e){if(!Wn.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const a=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function na(r,e){return!!((e==="v4"||!e)&&Gn.test(r)||(e==="v6"||!e)&&Kn.test(r))}class ft extends ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==W.string){const i=this._getOrReturnCtx(e);return B(i,{code:O.invalid_type,expected:W.string,received:i.parsedType}),ee}const a=new Ke;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const c=e.data.length>i.value,f=e.data.length<i.value;(c||f)&&(s=this._getOrReturnCtx(e,s),c?B(s,{code:O.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&B(s,{code:O.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"email",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Pr||(Pr=new RegExp(qn,"u")),Pr.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"emoji",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"uuid",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"nanoid",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")$n.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid2",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Un.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ulid",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),B(s,{validation:"url",code:O.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"regex",code:O.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?gn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?Qn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?ea(i).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?zn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"duration",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?ta(e.data,i.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ip",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?ra(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"jwt",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?na(e.data,i.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cidr",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?Jn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"base64",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?Xn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"base64url",code:O.invalid_string,message:i.message}),a.dirty()):be.assertNever(i);return{status:a.value,value:e.data}}_regex(e,t,a){return this.refinement(s=>e.test(s),{validation:t,code:O.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ft({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Y.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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...Y.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Y.errToObj(t)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new ft({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ft({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ft.create=r=>new ft({checks:[],typeName:re.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});function aa(r,e){const t=(r.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,s=t>a?t:a,i=Number.parseInt(r.toFixed(s).replace(".","")),c=Number.parseInt(e.toFixed(s).replace(".",""));return i%c/10**s}class Ct extends ce{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)!==W.number){const i=this._getOrReturnCtx(e);return B(i,{code:O.invalid_type,expected:W.number,received:i.parsedType}),ee}let a;const s=new Ke;for(const i of this._def.checks)i.kind==="int"?be.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),B(a,{code:O.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?aa(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_finite,message:i.message}),s.dirty()):be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,a,s){return new Ct({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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"&&be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(t===null||a.value>t)&&(t=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ct.create=r=>new Ct({checks:[],typeName:re.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Dt extends ce{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)!==W.bigint)return this._getInvalidInput(e);let a;const s=new Ke;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):be.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return B(t,{code:O.invalid_type,expected:W.bigint,received:t.parsedType}),ee}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,a,s){return new Dt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Dt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Dt.create=r=>new Dt({checks:[],typeName:re.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});class rr extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==W.boolean){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.boolean,received:a.parsedType}),ee}return Je(e.data)}}rr.create=r=>new rr({typeName:re.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Ft extends ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==W.date){const i=this._getOrReturnCtx(e);return B(i,{code:O.invalid_type,expected:W.date,received:i.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return B(i,{code:O.invalid_date}),ee}const a=new Ke;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):be.assertNever(i);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ft({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ft.create=r=>new Ft({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:re.ZodDate,...ie(r)});class Er extends ce{_parse(e){if(this._getType(e)!==W.symbol){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.symbol,received:a.parsedType}),ee}return Je(e.data)}}Er.create=r=>new Er({typeName:re.ZodSymbol,...ie(r)});class nr extends ce{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.undefined,received:a.parsedType}),ee}return Je(e.data)}}nr.create=r=>new nr({typeName:re.ZodUndefined,...ie(r)});class ar extends ce{_parse(e){if(this._getType(e)!==W.null){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.null,received:a.parsedType}),ee}return Je(e.data)}}ar.create=r=>new ar({typeName:re.ZodNull,...ie(r)});class Gt extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Gt.create=r=>new Gt({typeName:re.ZodAny,...ie(r)});class It extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}It.create=r=>new It({typeName:re.ZodUnknown,...ie(r)});class Et extends ce{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:O.invalid_type,expected:W.never,received:t.parsedType}),ee}}Et.create=r=>new Et({typeName:re.ZodNever,...ie(r)});class Tr extends ce{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.void,received:a.parsedType}),ee}return Je(e.data)}}Tr.create=r=>new Tr({typeName:re.ZodVoid,...ie(r)});class dt extends ce{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),s=this._def;if(t.parsedType!==W.array)return B(t,{code:O.invalid_type,expected:W.array,received:t.parsedType}),ee;if(s.exactLength!==null){const c=t.data.length>s.exactLength.value,f=t.data.length<s.exactLength.value;(c||f)&&(B(t,{code:c?O.too_big:O.too_small,minimum:f?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(B(t,{code:O.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(B(t,{code:O.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((c,f)=>s.type._parseAsync(new vt(t,c,t.path,f)))).then(c=>Ke.mergeArray(a,c));const i=[...t.data].map((c,f)=>s.type._parseSync(new vt(t,c,t.path,f)));return Ke.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new dt({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new dt({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new dt({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}dt.create=(r,e)=>new dt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...ie(e)});function zt(r){if(r instanceof Ie){const e={};for(const t in r.shape){const a=r.shape[t];e[t]=gt.create(zt(a))}return new Ie({...r._def,shape:()=>e})}else return r instanceof dt?new dt({...r._def,type:zt(r.element)}):r instanceof gt?gt.create(zt(r.unwrap())):r instanceof Pt?Pt.create(zt(r.unwrap())):r instanceof bt?bt.create(r.items.map(e=>zt(e))):r}class Ie extends ce{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(),t=be.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==W.object){const _=this._getOrReturnCtx(e);return B(_,{code:O.invalid_type,expected:W.object,received:_.parsedType}),ee}const{status:a,ctx:s}=this._processInputParams(e),{shape:i,keys:c}=this._getCached(),f=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const _ in s.data)c.includes(_)||f.push(_);const b=[];for(const _ of c){const R=i[_],S=s.data[_];b.push({key:{status:"valid",value:_},value:R._parse(new vt(s,S,s.path,_)),alwaysSet:_ in s.data})}if(this._def.catchall instanceof Et){const _=this._def.unknownKeys;if(_==="passthrough")for(const R of f)b.push({key:{status:"valid",value:R},value:{status:"valid",value:s.data[R]}});else if(_==="strict")f.length>0&&(B(s,{code:O.unrecognized_keys,keys:f}),a.dirty());else if(_!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const _=this._def.catchall;for(const R of f){const S=s.data[R];b.push({key:{status:"valid",value:R},value:_._parse(new vt(s,S,s.path,R)),alwaysSet:R in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const _=[];for(const R of b){const S=await R.key,k=await R.value;_.push({key:S,value:k,alwaysSet:R.alwaysSet})}return _}).then(_=>Ke.mergeObjectSync(a,_)):Ke.mergeObjectSync(a,b)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new Ie({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,a)=>{var i,c;const s=((c=(i=this._def).errorMap)==null?void 0:c.call(i,t,a).message)??a.defaultError;return t.code==="unrecognized_keys"?{message:Y.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Ie({...this._def,unknownKeys:"strip"})}passthrough(){return new Ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:re.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ie({...this._def,catchall:e})}pick(e){const t={};for(const a of be.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new Ie({...this._def,shape:()=>t})}omit(e){const t={};for(const a of be.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new Ie({...this._def,shape:()=>t})}deepPartial(){return zt(this)}partial(e){const t={};for(const a of be.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?t[a]=s:t[a]=s.optional()}return new Ie({...this._def,shape:()=>t})}required(e){const t={};for(const a of be.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof gt;)i=i._def.innerType;t[a]=i}return new Ie({...this._def,shape:()=>t})}keyof(){return vn(be.objectKeys(this.shape))}}Ie.create=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strip",catchall:Et.create(),typeName:re.ZodObject,...ie(e)});Ie.strictCreate=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strict",catchall:Et.create(),typeName:re.ZodObject,...ie(e)});Ie.lazycreate=(r,e)=>new Ie({shape:r,unknownKeys:"strip",catchall:Et.create(),typeName:re.ZodObject,...ie(e)});class sr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;function s(i){for(const f of i)if(f.result.status==="valid")return f.result;for(const f of i)if(f.result.status==="dirty")return t.common.issues.push(...f.ctx.common.issues),f.result;const c=i.map(f=>new at(f.ctx.common.issues));return B(t,{code:O.invalid_union,unionErrors:c}),ee}if(t.common.async)return Promise.all(a.map(async i=>{const c={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(s);{let i;const c=[];for(const b of a){const _={...t,common:{...t.common,issues:[]},parent:null},R=b._parseSync({data:t.data,path:t.path,parent:_});if(R.status==="valid")return R;R.status==="dirty"&&!i&&(i={result:R,ctx:_}),_.common.issues.length&&c.push(_.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(b=>new at(b));return B(t,{code:O.invalid_union,unionErrors:f}),ee}}get options(){return this._def.options}}sr.create=(r,e)=>new sr({options:r,typeName:re.ZodUnion,...ie(e)});const xt=r=>r instanceof cr?xt(r.schema):r instanceof ht?xt(r.innerType()):r instanceof ur?[r.value]:r instanceof Ot?r.options:r instanceof lr?be.objectValues(r.enum):r instanceof fr?xt(r._def.innerType):r instanceof nr?[void 0]:r instanceof ar?[null]:r instanceof gt?[void 0,...xt(r.unwrap())]:r instanceof Pt?[null,...xt(r.unwrap())]:r instanceof Br||r instanceof hr?xt(r.unwrap()):r instanceof dr?xt(r._def.innerType):[];class Dr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.object)return B(t,{code:O.invalid_type,expected:W.object,received:t.parsedType}),ee;const a=this.discriminator,s=t.data[a],i=this.optionsMap.get(s);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}):(B(t,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const s=new Map;for(const i of t){const c=xt(i.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const f of c){if(s.has(f))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(f)}`);s.set(f,i)}}return new Dr({typeName:re.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ie(a)})}}function Fr(r,e){const t=_t(r),a=_t(e);if(r===e)return{valid:!0,data:r};if(t===W.object&&a===W.object){const s=be.objectKeys(e),i=be.objectKeys(r).filter(f=>s.indexOf(f)!==-1),c={...r,...e};for(const f of i){const b=Fr(r[f],e[f]);if(!b.valid)return{valid:!1};c[f]=b.data}return{valid:!0,data:c}}else if(t===W.array&&a===W.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const c=r[i],f=e[i],b=Fr(c,f);if(!b.valid)return{valid:!1};s.push(b.data)}return{valid:!0,data:s}}else return t===W.date&&a===W.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ir extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(Ir(i)||Ir(c))return ee;const f=Fr(i.value,c.value);return f.valid?((jr(i)||jr(c))&&t.dirty(),{status:t.value,value:f.data}):(B(a,{code:O.invalid_intersection_types}),ee)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,c])=>s(i,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}ir.create=(r,e,t)=>new ir({left:r,right:e,typeName:re.ZodIntersection,...ie(t)});class bt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.array)return B(a,{code:O.invalid_type,expected:W.array,received:a.parsedType}),ee;if(a.data.length<this._def.items.length)return B(a,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&a.data.length>this._def.items.length&&(B(a,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...a.data].map((c,f)=>{const b=this._def.items[f]||this._def.rest;return b?b._parse(new vt(a,c,a.path,f)):null}).filter(c=>!!c);return a.common.async?Promise.all(i).then(c=>Ke.mergeArray(t,c)):Ke.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new bt({...this._def,rest:e})}}bt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bt({items:r,typeName:re.ZodTuple,rest:null,...ie(e)})};class or extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.object)return B(a,{code:O.invalid_type,expected:W.object,received:a.parsedType}),ee;const s=[],i=this._def.keyType,c=this._def.valueType;for(const f in a.data)s.push({key:i._parse(new vt(a,f,a.path,f)),value:c._parse(new vt(a,a.data[f],a.path,f)),alwaysSet:f in a.data});return a.common.async?Ke.mergeObjectAsync(t,s):Ke.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,a){return t instanceof ce?new or({keyType:e,valueType:t,typeName:re.ZodRecord,...ie(a)}):new or({keyType:ft.create(),valueType:e,typeName:re.ZodRecord,...ie(t)})}}class Ar extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.map)return B(a,{code:O.invalid_type,expected:W.map,received:a.parsedType}),ee;const s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([f,b],_)=>({key:s._parse(new vt(a,f,a.path,[_,"key"])),value:i._parse(new vt(a,b,a.path,[_,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const b of c){const _=await b.key,R=await b.value;if(_.status==="aborted"||R.status==="aborted")return ee;(_.status==="dirty"||R.status==="dirty")&&t.dirty(),f.set(_.value,R.value)}return{status:t.value,value:f}})}else{const f=new Map;for(const b of c){const _=b.key,R=b.value;if(_.status==="aborted"||R.status==="aborted")return ee;(_.status==="dirty"||R.status==="dirty")&&t.dirty(),f.set(_.value,R.value)}return{status:t.value,value:f}}}}Ar.create=(r,e,t)=>new Ar({valueType:e,keyType:r,typeName:re.ZodMap,...ie(t)});class $t extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.set)return B(a,{code:O.invalid_type,expected:W.set,received:a.parsedType}),ee;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(B(a,{code:O.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(B(a,{code:O.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function c(b){const _=new Set;for(const R of b){if(R.status==="aborted")return ee;R.status==="dirty"&&t.dirty(),_.add(R.value)}return{status:t.value,value:_}}const f=[...a.data.values()].map((b,_)=>i._parse(new vt(a,b,a.path,_)));return a.common.async?Promise.all(f).then(b=>c(b)):c(f)}min(e,t){return new $t({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new $t({...this._def,maxSize:{value:e,message:Y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}$t.create=(r,e)=>new $t({valueType:r,minSize:null,maxSize:null,typeName:re.ZodSet,...ie(e)});class qt extends ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.function)return B(t,{code:O.invalid_type,expected:W.function,received:t.parsedType}),ee;function a(f,b){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),Ht].filter(_=>!!_),issueData:{code:O.invalid_arguments,argumentsError:b}})}function s(f,b){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),Ht].filter(_=>!!_),issueData:{code:O.invalid_return_type,returnTypeError:b}})}const i={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof Yt){const f=this;return Je(async function(...b){const _=new at([]),R=await f._def.args.parseAsync(b,i).catch(E=>{throw _.addIssue(a(b,E)),_}),S=await Reflect.apply(c,this,R);return await f._def.returns._def.type.parseAsync(S,i).catch(E=>{throw _.addIssue(s(S,E)),_})})}else{const f=this;return Je(function(...b){const _=f._def.args.safeParse(b,i);if(!_.success)throw new at([a(b,_.error)]);const R=Reflect.apply(c,this,_.data),S=f._def.returns.safeParse(R,i);if(!S.success)throw new at([s(R,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new qt({...this._def,args:bt.create(e).rest(It.create())})}returns(e){return new qt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new qt({args:e||bt.create([]).rest(It.create()),returns:t||It.create(),typeName:re.ZodFunction,...ie(a)})}}class cr extends ce{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}cr.create=(r,e)=>new cr({getter:r,typeName:re.ZodLazy,...ie(e)});class ur extends ce{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:O.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:e.data}}get value(){return this._def.value}}ur.create=(r,e)=>new ur({value:r,typeName:re.ZodLiteral,...ie(e)});function vn(r,e){return new Ot({values:r,typeName:re.ZodEnum,...ie(e)})}class Ot extends ce{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return B(t,{expected:be.joinValues(a),received:t.parsedType,code:O.invalid_type}),ee}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return B(t,{received:t.data,code:O.invalid_enum_value,options:a}),ee}return Je(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ot.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ot.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Ot.create=vn;class lr extends ce{_parse(e){const t=be.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==W.string&&a.parsedType!==W.number){const s=be.objectValues(t);return B(a,{expected:be.joinValues(s),received:a.parsedType,code:O.invalid_type}),ee}if(this._cache||(this._cache=new Set(be.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=be.objectValues(t);return B(a,{received:a.data,code:O.invalid_enum_value,options:s}),ee}return Je(e.data)}get enum(){return this._def.values}}lr.create=(r,e)=>new lr({values:r,typeName:re.ZodNativeEnum,...ie(e)});class Yt extends ce{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.promise&&t.common.async===!1)return B(t,{code:O.invalid_type,expected:W.promise,received:t.parsedType}),ee;const a=t.parsedType===W.promise?t.data:Promise.resolve(t.data);return Je(a.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Yt.create=(r,e)=>new Yt({type:r,typeName:re.ZodPromise,...ie(e)});class ht extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===re.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:c=>{B(a,c),c.fatal?t.abort():t.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const c=s.transform(a.data,i);if(a.common.async)return Promise.resolve(c).then(async f=>{if(t.value==="aborted")return ee;const b=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return b.status==="aborted"?ee:b.status==="dirty"||t.value==="dirty"?Vt(b.value):b});{if(t.value==="aborted")return ee;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?ee:f.status==="dirty"||t.value==="dirty"?Vt(f.value):f}}if(s.type==="refinement"){const c=f=>{const b=s.refinement(f,i);if(a.common.async)return Promise.resolve(b);if(b instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(a.common.async===!1){const f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return f.status==="aborted"?ee:(f.status==="dirty"&&t.dirty(),c(f.value),{status:t.value,value:f.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(f=>f.status==="aborted"?ee:(f.status==="dirty"&&t.dirty(),c(f.value).then(()=>({status:t.value,value:f.value}))))}if(s.type==="transform")if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!jt(c))return ee;const f=s.transform(c.value,i);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:f}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>jt(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:t.value,value:f})):ee);be.assertNever(s)}}ht.create=(r,e,t)=>new ht({schema:r,typeName:re.ZodEffects,effect:e,...ie(t)});ht.createWithPreprocess=(r,e,t)=>new ht({schema:e,effect:{type:"preprocess",transform:r},typeName:re.ZodEffects,...ie(t)});class gt extends ce{_parse(e){return this._getType(e)===W.undefined?Je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}gt.create=(r,e)=>new gt({innerType:r,typeName:re.ZodOptional,...ie(e)});class Pt extends ce{_parse(e){return this._getType(e)===W.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pt.create=(r,e)=>new Pt({innerType:r,typeName:re.ZodNullable,...ie(e)});class fr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===W.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}fr.create=(r,e)=>new fr({innerType:r,typeName:re.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class dr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return tr(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new at(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new at(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}dr.create=(r,e)=>new dr({innerType:r,typeName:re.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class Sr extends ce{_parse(e){if(this._getType(e)!==W.nan){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.nan,received:a.parsedType}),ee}return{status:"valid",value:e.data}}}Sr.create=r=>new Sr({typeName:re.ZodNaN,...ie(r)});const sa=Symbol("zod_brand");class Br extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class pr extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?ee:i.status==="dirty"?(t.dirty(),Vt(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?ee:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(e,t){return new pr({in:e,out:t,typeName:re.ZodPipeline})}}class hr extends ce{_parse(e){const t=this._def.innerType._parse(e),a=s=>(jt(s)&&(s.value=Object.freeze(s.value)),s);return tr(t)?t.then(s=>a(s)):a(t)}unwrap(){return this._def.innerType}}hr.create=(r,e)=>new hr({innerType:r,typeName:re.ZodReadonly,...ie(e)});function un(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function bn(r,e={},t){return r?Gt.create().superRefine((a,s)=>{const i=r(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=un(e,a),b=f.fatal??t??!0;s.addIssue({code:"custom",...f,fatal:b})}});if(!i){const c=un(e,a),f=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:f})}}):Gt.create()}const ia={object:Ie.lazycreate};var re;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(re||(re={}));const oa=(r,e={message:`Input not instance of ${r.name}`})=>bn(t=>t instanceof r,e),Be=ft.create,Kt=Ct.create,ca=Sr.create,ua=Dt.create,Bt=rr.create,la=Ft.create,fa=Er.create,da=nr.create,ha=ar.create,pa=Gt.create,ma=It.create,ya=Et.create,ga=Tr.create,va=dt.create,Nt=Ie.create,ba=Ie.strictCreate,wa=sr.create,ka=Dr.create,xa=ir.create,_a=bt.create,Ea=or.create,Ta=Ar.create,Aa=$t.create,Sa=qt.create,Ca=cr.create,Da=ur.create,wn=Ot.create,kn=lr.create,Oa=Yt.create,ln=ht.create,Pa=gt.create,Na=Pt.create,Ma=ht.createWithPreprocess,Ra=pr.create,Ia=()=>Be().optional(),ja=()=>Kt().optional(),Fa=()=>Bt().optional(),$r={string:(r=>ft.create({...r,coerce:!0})),number:(r=>Ct.create({...r,coerce:!0})),boolean:(r=>rr.create({...r,coerce:!0})),bigint:(r=>Dt.create({...r,coerce:!0})),date:(r=>Ft.create({...r,coerce:!0}))},$a=ee,D=Object.freeze(Object.defineProperty({__proto__:null,BRAND:sa,DIRTY:Vt,EMPTY_PATH:Fn,INVALID:ee,NEVER:$a,OK:Je,ParseStatus:Ke,Schema:ce,ZodAny:Gt,ZodArray:dt,ZodBigInt:Dt,ZodBoolean:rr,ZodBranded:Br,ZodCatch:dr,ZodDate:Ft,ZodDefault:fr,ZodDiscriminatedUnion:Dr,ZodEffects:ht,ZodEnum:Ot,ZodError:at,get ZodFirstPartyTypeKind(){return re},ZodFunction:qt,ZodIntersection:ir,ZodIssueCode:O,ZodLazy:cr,ZodLiteral:ur,ZodMap:Ar,ZodNaN:Sr,ZodNativeEnum:lr,ZodNever:Et,ZodNull:ar,ZodNullable:Pt,ZodNumber:Ct,ZodObject:Ie,ZodOptional:gt,ZodParsedType:W,ZodPipeline:pr,ZodPromise:Yt,ZodReadonly:hr,ZodRecord:or,ZodSchema:ce,ZodSet:$t,ZodString:ft,ZodSymbol:Er,ZodTransformer:ht,ZodTuple:bt,ZodType:ce,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:It,ZodVoid:Tr,addIssueToContext:B,any:pa,array:va,bigint:ua,boolean:Bt,coerce:$r,custom:bn,date:la,datetimeRegex:gn,defaultErrorMap:Ht,discriminatedUnion:ka,effect:ln,enum:wn,function:Sa,getErrorMap:xr,getParsedType:_t,instanceof:oa,intersection:xa,isAborted:Ir,isAsync:tr,isDirty:jr,isValid:jt,late:ia,lazy:Ca,literal:Da,makeIssue:_r,map:Ta,nan:ca,nativeEnum:kn,never:ya,null:ha,nullable:Na,number:Kt,object:Nt,get objectUtil(){return Rr},oboolean:Fa,onumber:ja,optional:Pa,ostring:Ia,pipeline:Ra,preprocess:Ma,promise:Oa,quotelessJson:In,record:Ea,set:Aa,setErrorMap:jn,strictObject:ba,string:Be,symbol:fa,transformer:ln,tuple:_a,undefined:da,union:wa,unknown:ma,get util(){return be},void:ga},Symbol.toStringTag,{value:"Module"})),xn=Nt({name:Be(),key:Be(),image:Be()});var Ur=(r=>(r.monthly="MONTHLY",r.yearly="YEARLY",r))(Ur||{});const Cr=Nt({text:Be(),code:Be(),symbol:Be(),format:Be(),amount:Kt()});var _n=(r=>(r.USD="USD",r.KRW="KRW",r))(_n||{});const Ba={en:{code:"USD",symbol:"$"},ko:{code:"KRW",symbol:"₩"}},En=Nt({planName:Be(),currentCycleBillAmount:Cr,nextPaymentDue:Be(),cycleTerm:kn(Ur).nullable(),isFreeTier:Bt(),isPerUser:Bt(),paidMemberCount:Kt(),usedMemberCount:Kt(),unitPrice:Cr.nullable()}),Tn=Nt({uid:Be(),issuedDate:$r.date(),paidDate:$r.date().nullable().optional(),paymentMethod:Be(),amount:Cr,isSuccessfulPaid:Bt(),receiptUrl:Be()}),An=Nt({name:Be(),email:Be().email(),profileImageUrl:Be(),role:Be()});class Ua{constructor(){}async checkExtension(){return new Promise((e,t)=>{const a=setTimeout(()=>{t(ct.extensionNotInstalled())},5e3),s=i=>{Rn(i.data)&&(clearTimeout(a),window.removeEventListener("message",s),e(i.data))};window.addEventListener("message",s),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((t,a)=>{const s=`8g_wf_${Date.now()}_${Math.random()}`,i=e.timeoutMs??6e5,c=setTimeout(()=>{a(ct.requestTimeout(i))},i),f=b=>{var _,R,S,k;if(((_=b.data)==null?void 0:_.type)==="8G_COLLECT_RESPONSE"&&b.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const E=b.data,I=((R=E==null?void 0:E.result)==null?void 0:R.steps)??((k=(S=E==null?void 0:E.result)==null?void 0:S.result)==null?void 0:k.steps)??[];t({success:E.success,steps:I,error:E.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",f),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:s,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}async getWorkspaces(e){var i,c;const t=await this.collectWorkflow(e);if(!t.success)throw new ct("Failed to get workspaces","GET_WORKSPACES_FAILED");const a=(c=(i=t.steps[t.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a||!Array.isArray(a))return{data:[],isSuccess:!1};const s=[];for(const f of a){const b=xn.safeParse(f);b.success?s.push(b.data):console.warn("Invalid workspace data:",f,b.error)}return{data:s,isSuccess:!0}}async getWorkspacePlanAndCycle(e){var i,c;const t=await this.collectWorkflow(e);if(!t.success)throw new ct("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const a=(c=(i=t.steps[t.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a)return null;const s=En.safeParse(a);return s.success?s.data:(console.warn("Invalid workspace billing data:",a,s.error),null)}async getWorkspaceBillingHistories(e){var i,c;const t=await this.collectWorkflow(e);if(!t.success)throw new ct("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const a=(c=(i=t.steps[t.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a||!Array.isArray(a))return[];const s=[];for(const f of a){const b=Tn.safeParse(f);b.success?s.push(b.data):console.warn("Invalid workspace billing history data:",f,b.error)}return s}async getWorkspaceMembers(e){var i,c;const t=await this.collectWorkflow(e);if(!t.success)throw new ct("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const a=(c=(i=t.steps[t.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a||!Array.isArray(a))return[];const s=[];for(const f of a){const b=An.safeParse(f);b.success?s.push(b.data):console.warn("Invalid workspace member data:",f,b.error)}return s}}const pt=Nt({name:Be(),selector:Be(),findBy:wn(["cssSelector","xpath"]),option:Nt({waitForSelector:Bt().optional(),waitSelectorTimeout:Kt().optional(),multiple:Bt().optional()})}),La=D.object({type:D.literal("object"),shape:D.record(D.string(),D.any())}),Za=D.object({type:D.literal("array"),items:D.any()}),Wa=D.discriminatedUnion("type",[La,Za]),Lr=D.object({name:D.literal("ai-parse-data"),sourceData:D.any().optional(),schemaDefinition:Wa,prompt:D.string().optional(),model:D.string().optional(),apiKey:D.string().min(1,"OpenAI API key is required")});function za(r){return Lr.parse(r)}async function Va(r){try{const{sourceData:e,schemaDefinition:t,prompt:a,model:s="gpt-4o-mini",apiKey:i}=r;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!i||i.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const c=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:t,prompt:a,model:s,apiKey:i}});if(c.$isError)throw new Error(c.message||"AI parsing failed");return{data:c.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function qa(r){return{type:"object",shape:r}}function Ha(r){return{type:"array",items:r}}const Ga={string:r=>({type:"string",...r}),number:r=>({type:"number",...r}),boolean:r=>({type:"boolean",...r}),array:(r,e)=>({type:"array",items:r,...e}),object:(r,e)=>({type:"object",shape:r,...e})};class Or{async waitForElement(e,t,a){return new Promise(s=>{const i=Date.now(),c=async()=>{const f=await this.find(e,t);if(f&&(!Array.isArray(f)||f.length>0)){s(f);return}if(Date.now()-i>=a){s(null);return}setTimeout(c,100)};c()})}}class Ya extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=this.processCustomPseudoSelectors(a,t);return i?Array.from(t.querySelectorAll(c)):t.querySelector(c)}catch(c){return console.error("CSS Selector error:",c),null}}processCustomPseudoSelectors(e,t){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const s=((i=a.textContent)==null?void 0:i.trim())||"";if(s){a.setAttribute("data-contains",s);const f=Array.from(a.childNodes).filter(b=>b.nodeType===Node.TEXT_NODE).map(b=>{var _;return((_=b.textContent)==null?void 0:_.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class Ka extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(_=>_.trim());if(c.length!==2)return null;const f=c[0],b=c[1];if(!f||!b)return null;try{const _=t.querySelector(f);if(!_||!_.contentDocument)return null;const R=_.contentDocument;return i?Array.from(R.querySelectorAll(b)):R.querySelector(b)}catch(_){return console.error("Iframe Selector error:",_),null}}}class Ja extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(b=>b.trim());let f=t;try{for(let b=0;b<c.length;b++){const _=c[b],R=b===c.length-1;if(!_)return null;if(R&&i)return Array.from(f.querySelectorAll(_));const S=f.querySelector(_);if(!S)return null;if(R)return S;if(S.shadowRoot)f=S.shadowRoot;else return null}}catch(b){return console.error("Shadow DOM Selector error:",b),null}return null}}class Xa extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=t.evaluate(a,t,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const f=[];for(let b=0;b<c.snapshotLength;b++){const _=c.snapshotItem(b);_&&_.nodeType===Node.ELEMENT_NODE&&f.push(_)}return Promise.resolve(f.length>0?f:null)}else{const f=c.singleNodeValue;return f&&f.nodeType===Node.ELEMENT_NODE?f:null}}catch(c){return console.error("XPath error:",c),null}}}class Qa{static generate(e){const t=["data-testid","aria-label","title","alt","role"];for(const i of t){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${c})`}if(s){const i=this.generateParentSelector(s);if(i)return`${i} > ${a}:nth-child(${Array.from(s.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const t=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${t}:nth-child(${c})`}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(a=>a.test(e))}}async function mt(r,e=document){const{selector:t,findBy:a="cssSelector",option:s}=r,{waitForSelector:i=!1,waitSelectorTimeout:c=5e3}=s||{},f=es(t,a);return i?f.waitForElement(r,e,c):f.find(r,e)}function es(r,e){return e==="xpath"?new Xa:r.includes(">>")?new Ja:r.includes("|>")?new Ka:new Ya}const Zr=pt.extend({name:D.literal("get-text"),includeTags:D.boolean().optional(),useTextContent:D.boolean().optional(),regex:D.string().optional(),prefixText:D.string().optional(),suffixText:D.string().optional(),filterEmpty:D.boolean().optional(),scrollToCollect:D.boolean().optional(),scrollDistance:D.number().optional(),scrollWaitMs:D.number().optional(),maxScrollAttempts:D.number().optional()});function ts(r){return Zr.parse(r)}async function rs(r){try{const{selector:e="",includeTags:t=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:b,filterEmpty:_=!0,scrollToCollect:R=!1,scrollDistance:S=500,scrollWaitMs:k=300,maxScrollAttempts:E=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(R&&(b!=null&&b.multiple))return await ns({selector:e,findBy:f,option:b,includeTags:t,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:_,scrollDistance:S,scrollWaitMs:k,maxScrollAttempts:E});const I=await mt({selector:e,findBy:f,option:b});if(!I)return{data:""};const se=Sn(t,a,s,i,c);if(Array.isArray(I)){const me=I.map(se);return{data:_?me.filter(H=>H.trim()!==""):me}}else return{data:se(I)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function ns(r){const{selector:e,findBy:t,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:b,filterEmpty:_,scrollDistance:R,scrollWaitMs:S,maxScrollAttempts:k}=r,E=Sn(s,i,c,f,b),I=new Set;let se=0,me=0;const ge=5;for(;se<k;){const H=await mt({selector:e,findBy:t,option:a});if(H&&Array.isArray(H)){const L=I.size;if(H.forEach(U=>{const z=E(U);(!_||z.trim()!=="")&&I.add(z)}),I.size===L){if(me++,me>=ge)break}else me=0}const N=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:R,behavior:"auto"}),await new Promise(L=>setTimeout(L,S)),(window.pageYOffset||document.documentElement.scrollTop)===N)break;se++}return{data:Array.from(I)}}function Sn(r,e,t,a="",s=""){return i=>{let c="";if(r?c=i.innerHTML:c=e?i.textContent||"":i.innerText||"",t){const f=new RegExp(t,"g"),b=c.match(f);c=b?b.join(" "):""}return c.trim()&&(c=a+c.trim()+s),c}}const Wr=pt.extend({name:D.literal("attribute-value"),attributeName:D.string()});function as(r){return Wr.parse(r)}async function ss(r){try{const{selector:e="",attributeName:t,findBy:a="cssSelector",option:s}=r;if(!e)throw new Error("Selector is required for attribute-value block");if(!t)throw new Error("Attribute name is required for attribute-value block");const i=await mt({selector:e,findBy:a,option:s});return i?{data:Array.isArray(i)?i.map(f=>f.getAttribute(t)).filter(f=>f!==null):i.getAttribute(t)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const zr=pt.extend({name:D.literal("get-value-form"),type:D.enum(["text-field","select","checkbox"]).optional()});function is(r){return zr.parse(r)}async function os(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for get-value-form block");const s=await mt({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return{data:cs(s,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function cs(r,e){switch(e){case"text-field":if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)return r.value;break;case"select":if(r instanceof HTMLSelectElement)return r.value;break;case"checkbox":if(r instanceof HTMLInputElement&&r.type==="checkbox")return r.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const Vr=pt.extend({name:D.literal("set-value-form"),setValue:D.string(),type:D.enum(["text-field","select","checkbox"]).optional()});function us(r){return Vr.parse(r)}async function ls(r){try{const{selector:e="",setValue:t,type:a="text-field",findBy:s="cssSelector"}=r;if(!e)throw new Error("Selector is required for set-value-form block");const i=await mt({selector:e,findBy:s,option:r.option});if(!i)throw new Error("Form element not found");return fs(i,t,a),{data:"Form element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-value-form handler",data:null}}}function fs(r,e,t){switch(t){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value=e,r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.value=e,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=e==="true"||e==="checked",r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${t}`)}}const qr=pt.extend({name:D.literal("clear-value-form"),type:D.enum(["text-field","select","checkbox"]).optional()});function ds(r){return qr.parse(r)}async function hs(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for clear-value-form block");const s=await mt({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return ps(s,t),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function ps(r,e){switch(e){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="",r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.selectedIndex=0,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=!1,r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Hr=pt.extend({name:D.literal("element-exists")});function ms(r){return Hr.parse(r)}async function ys(r){try{const{selector:e="",findBy:t="cssSelector",option:a}=r;if(!e)throw new Error("Selector is required for element-exists block");return{data:await mt({selector:e,findBy:t,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Gr=pt.extend({name:D.literal("event-click"),textFilter:D.object({text:D.union([D.string(),D.array(D.string())]),mode:D.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function gs(r){return Gr.parse(r)}async function vs(r){try{const{selector:e="",findBy:t="cssSelector",option:a,textFilter:s}=r;if(!e)throw new Error("Selector is required for event-click block");const i=await mt({selector:e,findBy:t,option:a});if(!i)throw new Error("Element not found for clicking");let c;if(Array.isArray(i))if(s){const f=bs(i,s.text,s.mode);if(!f){const b=Array.isArray(s.text)?s.text.join(", "):s.text;throw new Error(`No element found with text filter: "${b}" (mode: ${s.mode})`)}c=f}else c=i[0];else c=i;return await ks(c),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in event-click handler",data:!1}}}function bs(r,e,t){for(const a of r){const s=ws(a),i=Array.isArray(e)?e:[e];for(const c of i){let f=!1;switch(t){case"exact":f=s===c;break;case"contains":f=s.includes(c);break;case"startsWith":f=s.startsWith(c);break;case"endsWith":f=s.endsWith(c);break;case"regex":try{f=new RegExp(c).test(s)}catch{console.warn("Invalid regex pattern:",c);continue}break}if(f)return a}}return null}function ws(r){if(r.innerText)return r.innerText.trim();if(r.textContent)return r.textContent.trim();if(r instanceof HTMLInputElement&&r.value)return r.value.trim();const e=r.getAttribute("placeholder");if(e)return e.trim();const t=r.getAttribute("title");if(t)return t.trim();const a=r.getAttribute("aria-label");return a?a.trim():""}async function ks(r){r.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(s=>setTimeout(s,50)),r.focus&&r.focus();const e=r.getBoundingClientRect(),t=e.left+e.width/2,a=e.top+e.height/2;try{const s=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:t,y:a}});if(s&&!s.$isError)console.log("[EventClick] CDP click successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP click failed")}catch(s){console.error("[EventClick] CDP click failed, falling back to native click:",s),r.click&&r.click()}await new Promise(s=>setTimeout(s,50))}const Yr=D.object({name:D.literal("keypress"),key:D.string(),code:D.string().optional(),keyCode:D.number().optional(),modifiers:D.array(D.enum(["Alt","Control","Meta","Shift"])).optional()});function xs(r){return Yr.parse(r)}async function _s(r){try{const{key:e,code:t,keyCode:a,modifiers:s=[]}=r;return await Es(e,t,a,s),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in keypress handler",data:!1}}}async function Es(r,e,t,a=[]){try{const s=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:r,code:e||r,keyCode:t||Nr(r),modifiers:a}});if(s&&!s.$isError)console.log("[Keypress] CDP keypress successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP keypress failed")}catch(s){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",s);const i=new KeyboardEvent("keydown",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...fn(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...fn(a)});document.dispatchEvent(i),await new Promise(f=>setTimeout(f,10)),document.dispatchEvent(c)}await new Promise(s=>setTimeout(s,50))}function Nr(r){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[r]||0}function fn(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Kr=D.object({name:D.literal("wait"),duration:D.number().min(0)});function Ts(r){return Kr.parse(r)}async function As(r){try{const{duration:e}=r;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(t=>setTimeout(t,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Jr=D.object({name:D.literal("wait-for-condition"),conditions:D.object({urlPattern:D.string().optional(),elementExists:D.object({selector:D.string(),findBy:D.enum(["cssSelector","xpath"])}).optional(),cookieExists:D.string().optional(),storageKey:D.object({type:D.enum(["localStorage","sessionStorage"]),key:D.string()}).optional(),userConfirmation:D.boolean().optional(),message:D.string().optional(),buttonText:D.string().optional()}).refine(r=>r.urlPattern!==void 0||r.elementExists!==void 0||r.cookieExists!==void 0||r.storageKey!==void 0||r.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:D.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:D.number().min(100).optional(),timeoutMs:D.number().min(1e3).optional(),position:D.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Ss(r){return Jr.parse(r)}async function Cs(r){try{const{conditions:e,mode:t="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:s=3e5,position:i="bottom-right"}=r;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",t,"Timeout:",s);const c=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),f=e.userConfirmation===!0;let b=null,_=null;(t==="manual"||t==="auto-or-manual")&&f&&(b=new Promise(S=>{_=S}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:_}})));const R=async()=>{if(e.urlPattern)try{if(new RegExp(e.urlPattern).test(window.location.href))return{success:!0,reason:"urlPattern",message:`URL matches pattern: ${e.urlPattern}`}}catch(S){console.warn("[WaitForCondition] Invalid URL pattern:",S)}if(e.elementExists){const{selector:S,findBy:k}=e.elementExists;let E=null;if(k==="cssSelector"?E=document.querySelector(S):k==="xpath"&&(E=document.evaluate(S,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),E)return{success:!0,reason:"elementExists",message:`Element found: ${S}`}}if(e.cookieExists&&document.cookie.split(";").some(E=>{const[I]=E.trim().split("=");return I===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:S,key:k}=e.storageKey;if((S==="localStorage"?window.localStorage:window.sessionStorage).getItem(k)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${S}.${k}`}}return null};return new Promise(S=>{let k=null,E=!1;const I=()=>{k&&(clearInterval(k),k=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},se=ge=>{E||(E=!0,I(),console.log("[WaitForCondition] Resolved with:",ge),S({data:ge}))},me=setTimeout(()=>{se({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(t==="auto"||t==="auto-or-manual")&&c&&(k=setInterval(async()=>{const ge=await R();ge&&(clearTimeout(me),se(ge))},a)),(t==="manual"||t==="auto-or-manual")&&b&&b.then(()=>{clearTimeout(me),se({success:!0,reason:"userConfirmation",message:"User confirmed completion"})})})}catch(e){return console.error("[WaitForCondition] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait-for-condition handler",data:{success:!1,message:e instanceof Error?e.message:"Unknown error"}}}}const Xr=D.object({name:D.literal("navigate"),url:D.string().url("Valid URL is required"),waitForLoad:D.boolean().optional(),timeout:D.number().min(0).optional()});function Ds(r){return Xr.parse(r)}async function Os(r){try{const{url:e,waitForLoad:t=!0,timeout:a=3e4}=r;return console.log(`[Navigate] Navigating to: ${e}`),t?new Promise((s,i)=>{const c=setTimeout(()=>{i(new Error(`Navigation timeout after ${a}ms`))},a),f=()=>{clearTimeout(c),window.removeEventListener("load",f),console.log(`[Navigate] Page loaded: ${e}`),s({data:!0})};document.readyState==="complete"?(clearTimeout(c),console.log(`[Navigate] Page already loaded: ${e}`),s({data:!0})):window.addEventListener("load",f),window.location.href=e}):(window.location.href=e,console.log(`[Navigate] Navigation initiated (no wait): ${e}`),{data:!0})}catch(e){return console.error("[Navigate] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in navigate handler",data:!1}}}const Qr=pt.extend({name:D.literal("save-assets")});function Ps(r){return Qr.parse(r)}async function Ns(r){try{const{selector:e="img, audio, video, source",findBy:t="cssSelector",option:a}=r,s=await mt({selector:e,findBy:t,option:a});if(!s||!Array.isArray(s))return{data:[]};const i=[];return s.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!i.includes(f)&&i.push(f)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class Ms{static generate(e){var s;const t=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const c=Array.from(((s=a.parentElement)==null?void 0:s.children)||[]).filter(b=>b.tagName===a.tagName);if(c.length>1){const b=c.indexOf(a)+1;i+=`[${b}]`}const f=this.getStableAttributes(a);f.length>0&&(i+=`[@${f.join(" and @")}]`),t.unshift(i),a=a.parentElement}return"/"+t.join("/")}static getStableAttributes(e){const t=[],a=["data-testid","aria-label","title","alt","role"];for(const s of a){const i=e.getAttribute(s);i&&!this.isDynamicValue(i)&&t.push(`${s}="${i}"`)}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/,/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/].some(a=>a.test(e))}}const en=pt.extend({name:D.literal("get-element-data"),includeText:D.boolean().optional(),includeTags:D.boolean().optional(),useTextContent:D.boolean().optional(),regex:D.string().optional(),prefixText:D.string().optional(),suffixText:D.string().optional(),attributes:D.array(D.string()).optional(),includeSelector:D.boolean().optional(),includeXPath:D.boolean().optional()});function Rs(r){return en.parse(r)}async function Is(r){try{const{selector:e="",includeText:t=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:b=[],includeSelector:_=!1,includeXPath:R=!1,findBy:S="cssSelector",option:k}=r;if(!e)throw new Error("Selector is required for get-element-data block");if(!t&&b.length===0)throw new Error("Either includeText must be true or attributes must be provided");const E=await mt({selector:e,findBy:S,option:k});if(!E)return{data:Array.isArray(E)?[]:{}};const I=js(t,a,s,i,c,f,b,_,R);return Array.isArray(E)?{data:E.map(I)}:{data:I(E)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function js(r,e,t,a,s="",i="",c=[],f=!1,b=!1){return _=>{const R={};if(r){let S="";if(e?S=_.innerHTML:S=t?_.textContent||"":_.innerText||"",a){const k=new RegExp(a,"g"),E=S.match(k);S=E?E.join(" "):""}S.trim()&&(S=s+S.trim()+i),R.text=S}return c.length>0&&(R.attributes={},c.forEach(S=>{let k=_.getAttribute(S);if(k===null){const E=_.querySelector(`[${S}]`);E&&(k=E.getAttribute(S))}R.attributes[S]=k})),f&&(R.selector=Qa.generate(_)),b&&(R.xpath=Ms.generate(_)),R}}const tn=pt.extend({name:D.literal("scroll"),scrollType:D.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:D.number().optional(),behavior:D.enum(["auto","smooth"]).optional(),maxScrolls:D.number().optional(),waitAfterScroll:D.number().optional()});function Fs(r){return tn.parse(r)}async function $s(r){try{const{selector:e="",scrollType:t="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:b}=r;switch(t){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Bs(e,f,b,s);case"toBottom":return await Us(s,c);case"byDistance":return await Ls(a,s);case"untilLoaded":return await Zs(i,a,s,c);default:throw new Error(`Unknown scroll type: ${t}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Bs(r,e,t,a){const s=await mt({selector:r,findBy:e,option:t});return s?((Array.isArray(s)?s[0]:s).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Us(r,e){let t=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:r}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===t)break;t=i,a++}return{data:!0}}async function Ls(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function Zs(r,e,t,a){let s=0,i=document.body.scrollHeight;for(;s<r;){window.scrollBy({top:e,behavior:t}),await new Promise(_=>setTimeout(_,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,b=window.innerHeight;if(f+b>=c-10&&c===i)break;i=c,s++}return{data:!0}}const rn=D.object({name:D.literal("fetch-api"),url:D.string(),method:D.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:D.record(D.string(),D.string()).optional(),body:D.record(D.string(),D.any()).optional(),timeout:D.number().min(0).optional(),parseJson:D.boolean().optional(),returnHeaders:D.boolean().optional()});function Ws(r){return rn.parse(r)}async function zs(r){try{console.log("[FetchApiBlock] Sending API request to background:",r.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:r.url,method:r.method||"GET",headers:r.headers||{},body:r.body,timeout:r.timeout||3e4,parseJson:r.parseJson??!0,returnHeaders:r.returnHeaders??!1}});return e.$isError?{hasError:!0,message:e.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:e.data})}catch(e){return console.error("[FetchApiBlock] API request error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in API request",data:void 0}}}var dn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function kr(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Mr={exports:{}},hn;function qs(){return hn||(hn=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function(){function t(a,s,i){function c(_,R){if(!s[_]){if(!a[_]){var S=typeof kr=="function"&&kr;if(!R&&S)return S(_,!0);if(f)return f(_,!0);var k=new Error("Cannot find module '"+_+"'");throw k.code="MODULE_NOT_FOUND",k}var E=s[_]={exports:{}};a[_][0].call(E.exports,function(I){var se=a[_][1][I];return c(se||I)},E,E.exports,t,a,s,i)}return s[_].exports}for(var f=typeof kr=="function"&&kr,b=0;b<i.length;b++)c(i[b]);return c}return t})()({1:[function(t,a,s){const i=t("./utils"),c=(function(){const f=i.stringToArray,b=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],_=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],R=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function k(v,A){var w=function($,j,C){var F="";if($<=19)F=(j?" and ":"")+(C?_[$]:b[$]);else if($<100){const ye=Math.floor($/10),we=$%10;F=(j?" and ":"")+R[ye-2],we>0?F+="-"+w(we,!1,C):C&&(F=F.substring(0,F.length-1)+"ieth")}else if($<1e3){const ye=Math.floor($/100),we=$%100;F=(j?", ":"")+b[ye]+" Hundred",we>0?F+=w(we,!0,C):C&&(F+="th")}else{var J=Math.floor(Math.log10($)/3);J>S.length&&(J=S.length);const ye=Math.pow(10,J*3),we=Math.floor($/ye),K=$-we*ye;F=(j?", ":"")+w(we,!1,!1)+" "+S[J-1],K>0?F+=w(K,!0,C):C&&(F+="th")}return F},P=w(v,!1,A);return P}const E={};b.forEach(function(v,A){E[v.toLowerCase()]=A}),_.forEach(function(v,A){E[v.toLowerCase()]=A}),R.forEach(function(v,A){const w=v.toLowerCase();E[w]=(A+2)*10,E[w.substring(0,v.length-1)+"ieth"]=E[w]}),E.hundredth=100,S.forEach(function(v,A){const w=v.toLowerCase(),P=Math.pow(10,(A+1)*3);E[w]=P,E[w+"th"]=P});function I(v){const w=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>E[j]);let P=[0];return w.forEach(j=>{if(j<100){let C=P.pop();C>=1e3&&(P.push(C),C=0),P.push(C+j)}else P.push(P.pop()*j)}),P.reduce((j,C)=>j+C,0)}const se=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],me={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function ge(v){for(var A=0;A<se.length;A++){const w=se[A];if(v>=w[0])return w[1]+ge(v-w[0])}return""}function H(v){for(var A=0,w=1,P=v.length-1;P>=0;P--){const $=v[P],j=me[$];j<w?A-=j:(w=j,A+=j)}return A}function N(v,A){for(var w=[],P=A.charCodeAt(0);v>0;)w.unshift(String.fromCharCode((v-1)%26+P)),v=Math.floor((v-1)/26);return w.join("")}function ne(v,A){for(var w=A.charCodeAt(0),P=0,$=0;$<v.length;$++)P+=(v.charCodeAt(v.length-$-1)-w+1)*Math.pow(26,$);return P}function L(v,A){if(typeof v>"u")return;v=Math.floor(v);const w=xe(A);return z(v,w)}const T={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},U={UPPER:"upper",LOWER:"lower",TITLE:"title"};function z(v,A){let w;const P=v<0;switch(v=Math.abs(v),A.primary){case T.LETTERS:w=N(v,A.case===U.UPPER?"A":"a");break;case T.ROMAN:w=ge(v),A.case===U.UPPER&&(w=w.toUpperCase());break;case T.WORDS:w=k(v,A.ordinal),A.case===U.UPPER?w=w.toUpperCase():A.case===U.LOWER&&(w=w.toLowerCase());break;case T.DECIMAL:w=""+v;var $=A.mandatoryDigits-w.length;if($>0){var j=new Array($+1).join("0");w=j+w}if(A.zeroCode!==48&&(w=f(w).map(ye=>String.fromCodePoint(ye.codePointAt(0)+A.zeroCode-48)).join("")),A.regular){const ye=Math.floor((w.length-1)/A.groupingSeparators.position);for(let we=ye;we>0;we--){const K=w.length-we*A.groupingSeparators.position;w=w.substr(0,K)+A.groupingSeparators.character+w.substr(K)}}else A.groupingSeparators.reverse().forEach(ye=>{const we=w.length-ye.position;w=w.substr(0,we)+ye.character+w.substr(we)});if(A.ordinal){var C={1:"st",2:"nd",3:"rd"},F=w[w.length-1],J=C[F];(!J||w.length>1&&w[w.length-2]==="1")&&(J="th"),w=w+J}break;case T.SEQUENCE:throw{code:"D3130",value:A.token}}return P&&(w="-"+w),w}const de=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function xe(v){const A={type:"integer",primary:T.DECIMAL,case:U.LOWER,ordinal:!1};let w,P;const $=v.lastIndexOf(";");switch($===-1?w=v:(w=v.substring(0,$),P=v.substring($+1),P[0]==="o"&&(A.ordinal=!0)),w){case"A":A.case=U.UPPER;case"a":A.primary=T.LETTERS;break;case"I":A.case=U.UPPER;case"i":A.primary=T.ROMAN;break;case"W":A.case=U.UPPER,A.primary=T.WORDS;break;case"Ww":A.case=U.TITLE,A.primary=T.WORDS;break;case"w":A.primary=T.WORDS;break;default:{let j=null,C=0,F=0,J=[],ye=0;if(f(w).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let Q=!1;for(let he=0;he<de.length;he++){const G=de[he];if(K>=G&&K<=G+9){if(Q=!0,C++,ye++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}Q||(K===35?(ye++,F++):J.push({position:ye,character:String.fromCodePoint(K)}))}),C>0){A.primary=T.DECIMAL,A.zeroCode=j,A.mandatoryDigits=C,A.optionalDigits=F;const Q=function(he){if(he.length===0)return 0;const G=he[0].character;for(let Ue=1;Ue<he.length;Ue++)if(he[Ue].character!==G)return 0;const Ze=he.map(Ue=>Ue.position),it=function(Ue,He){return He===0?Ue:it(He,Ue%He)},qe=Ze.reduce(it);for(let Ue=1;Ue<=Ze.length;Ue++)if(Ze.indexOf(Ue*qe)===-1)return 0;return qe}(J);Q>0?(A.regular=!0,A.groupingSeparators={position:Q,character:J[0].character}):(A.regular=!1,A.groupingSeparators=J)}else A.primary=T.SEQUENCE,A.token=w}}return A}const Te={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function Ae(v){var A=[];const w={type:"datetime",parts:A},P=function(Q,he){if(he>Q){let G=v.substring(Q,he);G=G.split("]]").join("]"),A.push({type:"literal",value:G})}};for(var $=0,j=0;j<v.length;){if(v.charAt(j)==="["){if(v.charAt(j+1)==="["){P($,j),A.push({type:"literal",value:"["}),j+=2,$=j;continue}if(P($,j),$=j,j=v.indexOf("]",$),j===-1)throw{code:"D3135"};let Q=v.substring($+1,j);Q=Q.split(/\s+/).join("");var C={type:"marker",component:Q.charAt(0)},F=Q.lastIndexOf(","),J;if(F!==-1){const he=Q.substring(F+1),G=he.indexOf("-");let Ze,it;const qe=function(He){if(!(typeof He>"u"||He==="*"))return parseInt(He)};G===-1?Ze=he:(Ze=he.substring(0,G),it=he.substring(G+1));const Ue={min:qe(Ze),max:qe(it)};C.width=Ue,J=Q.substring(1,F)}else J=Q.substring(1);if(J.length===1)C.presentation1=J;else if(J.length>1){var ye=J.charAt(J.length-1);"atco".indexOf(ye)!==-1?(C.presentation2=ye,ye==="o"&&(C.ordinal=!0),C.presentation1=J.substring(0,J.length-1)):C.presentation1=J}else C.presentation1=Te[C.component];if(typeof C.presentation1>"u")throw{code:"D3132",value:C.component};if(C.presentation1[0]==="n")C.names=U.LOWER;else if(C.presentation1[0]==="N")C.presentation1[1]==="n"?C.names=U.TITLE:C.names=U.UPPER;else if("YMDdFWwXxHhmsf".indexOf(C.component)!==-1){var we=C.presentation1;if(C.presentation2&&(we+=";"+C.presentation2),C.integerFormat=xe(we),C.width&&C.width.min!==void 0&&C.integerFormat.mandatoryDigits<C.width.min&&(C.integerFormat.mandatoryDigits=C.width.min),C.component==="Y")if(C.n=-1,C.width&&C.width.max!==void 0)C.n=C.width.max,C.integerFormat.mandatoryDigits=C.n;else{var K=C.integerFormat.mandatoryDigits+C.integerFormat.optionalDigits;K>=2&&(C.n=K)}const he=A[A.length-1];he&&he.integerFormat&&(he.integerFormat.parseWidth=he.integerFormat.mandatoryDigits)}(C.component==="Z"||C.component==="z")&&(C.integerFormat=xe(C.presentation1)),A.push(C),$=j+1}j++}return P($,j),w}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Me=["January","February","March","April","May","June","July","August","September","October","November","December"],et=1e3*60*60*24,_e=function(v){const A=Date.UTC(v.year,v.month);var w=new Date(A).getUTCDay();return w===0&&(w=7),w>4?A+(8-w)*et:A-(w-1)*et},ue=function(v,A){return{year:v,month:A,nextMonth:function(){return A===11?ue(v+1,0):ue(v,A+1)},previousMonth:function(){return A===0?ue(v-1,11):ue(v,A-1)},nextYear:function(){return ue(v+1,A)},previousYear:function(){return ue(v-1,A)}}},tt=function(v,A){return(A-v)/(et*7)+1},ae=(v,A)=>{let w;switch(A){case"Y":w=v.getUTCFullYear();break;case"M":w=v.getUTCMonth()+1;break;case"D":w=v.getUTCDate();break;case"d":{const P=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),$=Date.UTC(v.getUTCFullYear(),0);w=(P-$)/et+1;break}case"F":w=v.getUTCDay(),w===0&&(w=7);break;case"W":{const P=ue(v.getUTCFullYear(),0),$=_e(P),j=Date.UTC(P.year,v.getUTCMonth(),v.getUTCDate());let C=tt($,j);if(C>52){const F=_e(P.nextYear());j>=F&&(C=1)}else if(C<1){const F=_e(P.previousYear());C=tt(F,j)}w=Math.floor(C);break}case"w":{const P=ue(v.getUTCFullYear(),v.getUTCMonth()),$=_e(P),j=Date.UTC(P.year,P.month,v.getUTCDate());let C=tt($,j);if(C>4){const F=_e(P.nextMonth());j>=F&&(C=1)}else if(C<1){const F=_e(P.previousMonth());C=tt(F,j)}w=Math.floor(C);break}case"X":{const P=ue(v.getUTCFullYear(),0),$=_e(P),j=_e(P.nextYear()),C=v.getTime();C<$?w=P.year-1:C>=j?w=P.year+1:w=P.year;break}case"x":{const P=ue(v.getUTCFullYear(),v.getUTCMonth()),$=_e(P),j=P.nextMonth(),C=_e(j),F=v.getTime();F<$?w=P.previousMonth().month+1:F>=C?w=j.month+1:w=P.month+1;break}case"H":w=v.getUTCHours();break;case"h":w=v.getUTCHours(),w=w%12,w===0&&(w=12);break;case"P":w=v.getUTCHours()>=12?"pm":"am";break;case"m":w=v.getUTCMinutes();break;case"s":w=v.getUTCSeconds();break;case"f":w=v.getUTCMilliseconds();break;case"Z":case"z":break;case"C":w="ISO";break;case"E":w="ISO";break}return w};let Fe=null;function st(v,A,w){var P=0,$=0;if(typeof w<"u"){const we=parseInt(w);P=Math.floor(we/100),$=we%100}var j=function(we,K){var Q=ae(we,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(Q=Q%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")Q=Me[Q-1];else if(K.component==="F")Q=ve[Q];else throw{code:"D3133",value:K.component};K.names===U.UPPER?Q=Q.toUpperCase():K.names===U.LOWER&&(Q=Q.toLowerCase()),K.width&&Q.length>K.width.max&&(Q=Q.substring(0,K.width.max))}else Q=z(Q,K.integerFormat);else if(K.component==="f")Q=z(Q,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const he=P*100+$;if(K.integerFormat.regular)Q=z(he,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)Q=z(P,K.integerFormat),$!==0&&(Q+=":"+L($,"00"));else if(G===3||G===4)Q=z(he,K.integerFormat);else throw{code:"D3134",value:G}}he>=0&&(Q="+"+Q),K.component==="z"&&(Q="GMT"+Q),he===0&&K.presentation2==="t"&&(Q="Z")}else K.component==="P"&&K.names===U.UPPER&&(Q=Q.toUpperCase());return Q};let C;typeof A>"u"?(Fe===null&&(Fe=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),C=Fe):C=Ae(A);const F=(60*P+$)*60*1e3,J=new Date(v+F);let ye="";return C.parts.forEach(function(we){we.type==="literal"?ye+=we.value:ye+=j(J,we)}),ye}function d(v){var A={};if(v.type==="datetime")A.type="datetime",A.parts=v.parts.map(function(w){var P={};if(w.type==="literal")P.regex=w.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(w.component==="Z"||w.component==="z"){let j;Array.isArray(w.integerFormat.groupingSeparators)||(j=w.integerFormat.groupingSeparators),P.regex="",w.component==="z"&&(P.regex="GMT"),P.regex+="[-+][0-9]+",j&&(P.regex+=j.character+"[0-9]+"),P.parse=function(C){w.component==="z"&&(C=C.substring(3));let F=0,J=0;return j?(F=Number.parseInt(C.substring(0,C.indexOf(j.character))),J=Number.parseInt(C.substring(C.indexOf(j.character)+1))):C.length-1<=2?F=Number.parseInt(C):(F=Number.parseInt(C.substring(0,3)),J=Number.parseInt(C.substring(3))),F*60+J}}else if(w.integerFormat)P=d(w.integerFormat);else{P.regex="[a-zA-Z]+";var $={};if(w.component==="M"||w.component==="x")Me.forEach(function(j,C){w.width&&w.width.max?$[j.substring(0,w.width.max)]=C+1:$[j]=C+1});else if(w.component==="F")ve.forEach(function(j,C){C>0&&(w.width&&w.width.max?$[j.substring(0,w.width.max)]=C:$[j]=C)});else if(w.component==="P")$={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:w.component};P.parse=function(j){return $[j]}}return P.component=w.component,P});else{A.type="integer";const w=v.case===U.UPPER;switch(v.primary){case T.LETTERS:A.regex=w?"[A-Z]+":"[a-z]+",A.parse=function(P){return ne(P,w?"A":"a")};break;case T.ROMAN:A.regex=w?"[MDCLXVI]+":"[mdclxvi]+",A.parse=function(P){return H(w?P:P.toUpperCase())};break;case T.WORDS:A.regex="(?:"+Object.keys(E).concat("and","[\\-, ]").join("|")+")+",A.parse=function(P){return I(P.toLowerCase())};break;case T.DECIMAL:A.regex="[0-9]",v.parseWidth?A.regex+=`{${v.parseWidth}}`:A.regex+="+",v.ordinal&&(A.regex+="(?:th|st|nd|rd)"),A.parse=function(P){let $=P;return v.ordinal&&($=P.substring(0,P.length-2)),v.regular?$=$.split(",").join(""):v.groupingSeparators.forEach(j=>{$=$.split(j.character).join("")}),v.zeroCode!==48&&($=$.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-v.zeroCode+48)).join("")),parseInt($)};break;case T.SEQUENCE:throw{code:"D3130",value:v.token}}}return A}function m(v,A){if(typeof v>"u")return;const w=xe(A);return d(w).parse(v)}function V(v,A){const w=Ae(A),P=d(w),$="^"+P.parts.map(J=>"("+J.regex+")").join("")+"$";var C=new RegExp($,"i").exec(v);if(C!==null){const G={};for(let Ce=1;Ce<C.length;Ce++){const u=P.parts[Ce-1];u.parse&&(G[u.component]=u.parse(C[Ce]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ze=0;const it=Ce=>{Ze<<=1,Ze+=Ce?1:0},qe=Ce=>!(~Ce&Ze)&&!!(Ce&Ze);"YXMxWwdD".split("").forEach(Ce=>it(G[Ce]));const He=!qe(161)&&qe(130),wt=qe(84),Tt=!wt&&qe(72);Ze=0,"PHhmsf".split("").forEach(Ce=>it(G[Ce]));const At=!qe(23)&&qe(47),Jt=(He?"YD":wt?"XxwF":Tt?"XWF":"YMD")+(At?"Phmsf":"Hmsf"),ut=this.environment.timestamp;let Ut=!1,yt=!1;if(Jt.split("").forEach(Ce=>{if(typeof G[Ce]>"u")Ut?(G[Ce]="MDd".indexOf(Ce)!==-1?1:0,yt=!0):G[Ce]=ae(ut,Ce);else if(Ut=!0,yt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,He){const Ce=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(Ce+u);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(wt)throw{code:"D3136"};if(Tt)throw{code:"D3136"};At&&(G.H=G.h===12?0:G.h,G.P===1&&(G.H+=12));var F=Date.UTC(G.Y,G.M,G.D,G.H,G.m,G.s,G.f);return(G.Z||G.z)&&(F-=(G.Z||G.z)*60*1e3),F}}var le=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function Oe(v,A){if(!(typeof v>"u"))if(typeof A>"u"){if(!le.test(v))throw{stack:new Error().stack,code:"D3110",value:v};return Date.parse(v)}else return V.call(this,v,A)}function Ee(v,A,w){if(!(typeof v>"u"))return st.call(this,v,A,w)}return{formatInteger:L,parseInteger:m,fromMillis:Ee,toMillis:Oe}})();a.exports=c},{"./utils":6}],2:[function(t,a,s){(function(i){(function(){var c=t("./utils");const f=(()=>{var b=c.isNumeric,_=c.isArrayOfStrings,R=c.isArrayOfNumbers,S=c.createSequence,k=c.isSequence,E=c.isFunction,I=c.isLambda,se=c.isPromise,me=c.getFunctionArity,ge=c.isDeepEqual,H=c.stringToArray;function N(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function ne(n){return typeof n>"u"?0:n.length}function L(n){if(!(typeof n>"u"||n.length===0))return Math.max.apply(Math,n)}function T(n){if(!(typeof n>"u"||n.length===0))return Math.min.apply(Math,n)}function U(n){if(!(typeof n>"u"||n.length===0)){var o=0;return n.forEach(function(l){o+=l}),o/n.length}}function z(n,o=!1){if(!(typeof n>"u")){var l;if(typeof n=="string")l=n;else if(E(n))l="";else{if(typeof n=="number"&&!isFinite(n))throw{code:"D3001",value:n,stack:new Error().stack};var g=o?2:0;Array.isArray(n)&&n.outerWrapper&&(n=n[0]),l=JSON.stringify(n,function(p,x){return typeof x<"u"&&x!==null&&x.toPrecision&&b(x)?Number(x.toPrecision(15)):x&&E(x)?"":x},g)}return l}}function de(n,o,l){if(!(typeof n>"u")){var g=H(n),p=g.length;if(p+o<0&&(o=0),typeof l<"u"){if(l<=0)return"";var x=o>=0?o+l:p+o+l;return g.slice(o,x).join("")}return g.slice(o).join("")}}function xe(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(0,l):n}}function Te(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(l+o.length):n}}function Ae(n){if(!(typeof n>"u"))return n.toLowerCase()}function ve(n){if(!(typeof n>"u"))return n.toUpperCase()}function Me(n){if(!(typeof n>"u"))return H(n).length}function et(n){if(!(typeof n>"u")){var o=n.replace(/[ \t\n\r]+/gm," ");return o.charAt(0)===" "&&(o=o.substring(1)),o.charAt(o.length-1)===" "&&(o=o.substring(0,o.length-1)),o}}function _e(n,o,l){if(!(typeof n>"u")){(typeof l>"u"||l.length===0)&&(l=" ");var g;o=Math.trunc(o);var p=Math.abs(o)-Me(n);if(p>0){var x=new Array(p+1).join(l);l.length>1&&(x=de(x,0,p)),o>0?g=n+x:g=x+n}else g=n;return g}}async function ue(n,o){var l=n.apply(this,[o]);if(se(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||E(l.next)))throw{code:"T1010",stack:new Error().stack};return l}async function tt(n,o){if(!(typeof n>"u")){var l;if(typeof o=="string")l=n.indexOf(o)!==-1;else{var g=await ue(o,n);l=typeof g<"u"}return l}}async function ae(n,o,l){if(!(typeof n>"u")){if(l<0)throw{stack:new Error().stack,value:l,code:"D3040",index:3};var g=S();if(typeof l>"u"||l>0){var p=0,x=await ue(o,n);if(typeof x<"u")for(;typeof x<"u"&&(typeof l>"u"||p<l);)g.push({match:x.match,index:x.start,groups:x.groups}),x=await ue(x.next),p++}return g}}async function Fe(n,o,l,g){if(!(typeof n>"u")){var p=this;if(o==="")throw{code:"D3010",stack:new Error().stack,value:o,index:2};if(g<0)throw{code:"D3011",stack:new Error().stack,value:g,index:4};var x;typeof l=="string"?x=function(Se){for(var We="",ke=0,je=l.indexOf("$",ke);je!==-1&&ke<l.length;){We+=l.substring(ke,je),ke=je+1;var ot=l.charAt(ke);if(ot==="$")We+="$",ke++;else if(ot==="0")We+=Se.match,ke++;else{var ze;if(Se.groups.length===0?ze=1:ze=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,je=parseInt(l.substring(ke,ke+ze),10),ze>1&&je>Se.groups.length&&(je=parseInt(l.substring(ke,ke+ze-1),10)),isNaN(je))We+="$";else{if(Se.groups.length>0){var Lt=Se.groups[je-1];typeof Lt<"u"&&(We+=Lt)}ke+=je.toString().length}}je=l.indexOf("$",ke)}return We+=l.substring(ke),We}:x=l;var M="",q=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var De=n.indexOf(o,q);De!==-1&&(typeof g>"u"||X<g);)M+=n.substring(q,De),M+=l,q=De+o.length,X++,De=n.indexOf(o,q);M+=n.substring(q)}else{var pe=await ue(o,n);if(typeof pe<"u"){for(;typeof pe<"u"&&(typeof g>"u"||X<g);){M+=n.substring(q,pe.start);var Pe=x.apply(p,[pe]);if(se(Pe)&&(Pe=await Pe),typeof Pe=="string")M+=Pe;else throw{code:"D3012",stack:new Error().stack,value:Pe};q=pe.start+pe.match.length,X++,pe=await ue(pe.next)}M+=n.substring(q)}else M=n}}else M=n;return M}}function st(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.btoa:function(l){return new i.Buffer.from(l,"binary").toString("base64")};return o(n)}}function d(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.atob:function(l){return new i.Buffer.from(l,"base64").toString("binary")};return o(n)}}function m(n){if(!(typeof n>"u")){var o;try{o=encodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrlComponent"}}return o}}function V(n){if(!(typeof n>"u")){var o;try{o=encodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrl"}}return o}}function le(n){if(!(typeof n>"u")){var o;try{o=decodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrlComponent"}}return o}}function Oe(n){if(!(typeof n>"u")){var o;try{o=decodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrl"}}return o}}async function Ee(n,o,l){if(!(typeof n>"u")){if(l<0)throw{code:"D3020",stack:new Error().stack,value:l,index:3};var g=[];if(typeof l>"u"||l>0)if(typeof o=="string")g=n.split(o,l);else{var p=0,x=await ue(o,n);if(typeof x<"u"){for(var M=0;typeof x<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(M,x.start)),M=x.end,x=await ue(x.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(M))}else g.push(n)}return g}}function v(n,o){if(!(typeof n>"u"))return typeof o>"u"&&(o=""),n.join(o)}function A(n,o,l){if(!(typeof n>"u")){var g={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},p=g;typeof l<"u"&&Object.keys(l).forEach(function(te){p[te]=l[te]});for(var x=[],M=p["zero-digit"].charCodeAt(0),q=M;q<M+10;q++)x.push(String.fromCharCode(q));var X=x.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),De=o.split(p["pattern-separator"]);if(De.length>2)throw{code:"D3080",stack:new Error().stack};var pe=function(te){var Re=(function(){for(var Le,nt=0;nt<te.length;nt++)if(Le=te.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return te.substring(0,nt)})(),Ye=(function(){for(var Le,nt=te.length-1;nt>=0;nt--)if(Le=te.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return te.substring(nt+1)})(),Ne=te.substring(Re.length,te.length-Ye.length),Xe,St,Qe,Rt,rt=te.indexOf(p["exponent-separator"],Re.length);rt===-1||rt>te.length-Ye.length?(Xe=Ne,St=void 0):(Xe=Ne.substring(0,rt),St=Ne.substring(rt+1));var lt=Xe.indexOf(p["decimal-separator"]);return lt===-1?(Qe=Xe,Rt=Ye):(Qe=Xe.substring(0,lt),Rt=Xe.substring(lt+1)),{prefix:Re,suffix:Ye,activePart:Ne,mantissaPart:Xe,exponentPart:St,integerPart:Qe,fractionalPart:Rt,subpicture:te}},Pe=function(te){var Re,Ye,Ne=te.subpicture,Xe=Ne.indexOf(p["decimal-separator"]);Xe!==Ne.lastIndexOf(p["decimal-separator"])&&(Re="D3081"),Ne.indexOf(p.percent)!==Ne.lastIndexOf(p.percent)&&(Re="D3082"),Ne.indexOf(p["per-mille"])!==Ne.lastIndexOf(p["per-mille"])&&(Re="D3083"),Ne.indexOf(p.percent)!==-1&&Ne.indexOf(p["per-mille"])!==-1&&(Re="D3084");var St=!1;for(Ye=0;Ye<te.mantissaPart.length;Ye++){var Qe=te.mantissaPart.charAt(Ye);if(x.indexOf(Qe)!==-1||Qe===p.digit){St=!0;break}}St||(Re="D3085");var Rt=te.activePart.split("").map(function(Le){return X.indexOf(Le)===-1?"p":"a"}).join("");Rt.indexOf("p")!==-1&&(Re="D3086"),Xe!==-1?(Ne.charAt(Xe-1)===p["grouping-separator"]||Ne.charAt(Xe+1)===p["grouping-separator"])&&(Re="D3087"):te.integerPart.charAt(te.integerPart.length-1)===p["grouping-separator"]&&(Re="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Re="D3089");var rt=te.integerPart.indexOf(p.digit);rt!==-1&&te.integerPart.substring(0,rt).split("").filter(function(Le){return x.indexOf(Le)>-1}).length>0&&(Re="D3090"),rt=te.fractionalPart.lastIndexOf(p.digit),rt!==-1&&te.fractionalPart.substring(rt).split("").filter(function(Le){return x.indexOf(Le)>-1}).length>0&&(Re="D3091");var lt=typeof te.exponentPart=="string";if(lt&&te.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Re="D3092"),lt&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function(Le){return x.indexOf(Le)===-1}).length>0)&&(Re="D3093"),Re)throw{code:Re,stack:new Error().stack}},Se=function(te){var Re=function(Ve,br){for(var er=[],kt=Ve.indexOf(p["grouping-separator"]);kt!==-1;){var wr=(br?Ve.substring(0,kt):Ve.substring(kt)).split("").filter(function(Wt){return x.indexOf(Wt)!==-1||Wt===p.digit}).length;er.push(wr),kt=te.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Re(te.integerPart),Ne=function(Ve){if(Ve.length===0)return 0;for(var br=function(wr,Wt){return Wt===0?wr:br(Wt,wr%Wt)},er=Ve.reduce(br),kt=1;kt<=Ve.length;kt++)if(Ve.indexOf(kt*er)===-1)return 0;return er},Xe=Ne(Ye),St=Re(te.fractionalPart,!0),Qe=te.integerPart.split("").filter(function(Ve){return x.indexOf(Ve)!==-1}).length,Rt=Qe,rt=te.fractionalPart.split(""),lt=rt.filter(function(Ve){return x.indexOf(Ve)!==-1}).length,Le=rt.filter(function(Ve){return x.indexOf(Ve)!==-1||Ve===p.digit}).length,nt=typeof te.exponentPart=="string";Qe===0&&Le===0&&(nt?(lt=1,Le=1):Qe=1),nt&&Qe===0&&te.integerPart.indexOf(p.digit)!==-1&&(Qe=1),Qe===0&&lt===0&&(lt=1);var on=0;return nt&&(on=te.exponentPart.split("").filter(function(Ve){return x.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:Rt,prefix:te.prefix,fractionalPartGroupingPositions:St,minimumFactionalPartSize:lt,maximumFactionalPartSize:Le,minimumExponentSize:on,suffix:te.suffix,picture:te.subpicture}},We=De.map(pe);We.forEach(Pe);var ke=We.map(Se),je=p["minus-sign"],ot=p["zero-digit"],ze=p["decimal-separator"],Lt=p["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=je+ke[1].prefix);var $e;n>=0?$e=ke[0]:$e=ke[1];var Xt;$e.picture.indexOf(p.percent)!==-1?Xt=n*100:$e.picture.indexOf(p["per-mille"])!==-1?Xt=n*1e3:Xt=n;var Mt,Zt;if($e.minimumExponentSize===0)Mt=Xt;else{var Cn=Math.pow(10,$e.scalingFactor),Dn=Math.pow(10,$e.scalingFactor-1);for(Mt=Xt,Zt=0;Mt<Dn;)Mt*=10,Zt-=1;for(;Mt>Cn;)Mt/=10,Zt+=1}var On=F(Mt,$e.maximumFactionalPartSize),an=function(te,Re){var Ye=Math.abs(te).toFixed(Re);return ot!=="0"&&(Ye=Ye.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?x[Ne.charCodeAt(0)-48]:Ne}).join("")),Ye},oe=an(On,$e.maximumFactionalPartSize),Ge=oe.indexOf(".");for(Ge===-1?oe=oe+ze:oe=oe.replace(".",ze);oe.charAt(0)===ot;)oe=oe.substring(1);for(;oe.charAt(oe.length-1)===ot;)oe=oe.substring(0,oe.length-1);Ge=oe.indexOf(ze);var Qt=$e.minimumIntegerPartSize-Ge,sn=$e.minimumFactionalPartSize-(oe.length-Ge-1);if(oe=(Qt>0?new Array(Qt+1).join(ot):"")+oe,oe=oe+(sn>0?new Array(sn+1).join(ot):""),Ge=oe.indexOf(ze),$e.regularGrouping>0)for(var Pn=Math.floor((Ge-1)/$e.regularGrouping),gr=1;gr<=Pn;gr++)oe=[oe.slice(0,Ge-gr*$e.regularGrouping),Lt,oe.slice(Ge-gr*$e.regularGrouping)].join("");else $e.integerPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,Ge-te),Lt,oe.slice(Ge-te)].join(""),Ge++});if(Ge=oe.indexOf(ze),$e.fractionalPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,te+Ge+1),Lt,oe.slice(te+Ge+1)].join("")}),Ge=oe.indexOf(ze),($e.picture.indexOf(ze)===-1||Ge===oe.length-1)&&(oe=oe.substring(0,oe.length-1)),typeof Zt<"u"){var vr=an(Zt,0);Qt=$e.minimumExponentSize-vr.length,Qt>0&&(vr=new Array(Qt+1).join(ot)+vr),oe=oe+p["exponent-separator"]+(Zt<0?je:"")+vr}return oe=$e.prefix+oe+$e.suffix,oe}}function w(n,o){if(!(typeof n>"u")){if(n=F(n),typeof o>"u"?o=10:o=F(o),o<2||o>36)throw{code:"D3100",stack:new Error().stack,value:o};var l=n.toString(o);return l}}function P(n){var o;if(!(typeof n>"u")){if(typeof n=="number")o=n;else if(typeof n=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(n)&&!isNaN(parseFloat(n))&&isFinite(n))o=parseFloat(n);else if(typeof n=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(n))o=Number(n);else if(n===!0)o=1;else if(n===!1)o=0;else throw{code:"D3030",value:n,stack:new Error().stack,index:1};return o}}function $(n){var o;if(!(typeof n>"u"))return o=Math.abs(n),o}function j(n){var o;if(!(typeof n>"u"))return o=Math.floor(n),o}function C(n){var o;if(!(typeof n>"u"))return o=Math.ceil(n),o}function F(n,o){var l;if(!(typeof n>"u")){if(o){var g=n.toString().split("e");n=+(g[0]+"e"+(g[1]?+g[1]+o:o))}l=Math.round(n);var p=l-n;return Math.abs(p)===.5&&Math.abs(l%2)===1&&(l=l-1),o&&(g=l.toString().split("e"),l=+(g[0]+"e"+(g[1]?+g[1]-o:-o))),Object.is(l,-0)&&(l=0),l}}function J(n){var o;if(!(typeof n>"u")){if(n<0)throw{stack:new Error().stack,code:"D3060",index:1,value:n};return o=Math.sqrt(n),o}}function ye(n,o){var l;if(!(typeof n>"u")){if(l=Math.pow(n,o),!isFinite(l))throw{stack:new Error().stack,code:"D3061",index:1,value:n,exp:o};return l}}function we(){return Math.random()}function K(n){if(!(typeof n>"u")){var o=!1;if(Array.isArray(n)){if(n.length===1)o=K(n[0]);else if(n.length>1){var l=n.filter(function(g){return K(g)});o=l.length>0}}else typeof n=="string"?n.length>0&&(o=!0):b(n)?n!==0&&(o=!0):n!==null&&typeof n=="object"&&!E(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function Q(n){if(!(typeof n>"u"))return!K(n)}function he(n,o,l,g){var p=[o],x=me(n);return x>=2&&p.push(l),x>=3&&p.push(g),p}async function G(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=he(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}}async function Ze(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=n[g],x=he(o,p,g,n),M=await o.apply(this,x);K(M)&&l.push(p)}return l}}async function it(n,o){if(!(typeof n>"u")){for(var l=!1,g,p=0;p<n.length;p++){var x=n[p],M=!0;if(typeof o<"u"){var q=he(o,x,p,n),X=await o.apply(this,q);M=K(X)}if(M)if(!l)g=x,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function qe(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(x){return Array.isArray(x)?x.length:0})),g=0;g<l;g++){var p=o.map(x=>x[g]);n.push(p)}return n}async function Ue(n,o,l){if(!(typeof n>"u")){var g,p=me(o);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var x;for(typeof l>"u"&&n.length>0?(g=n[0],x=1):(g=l,x=0);x<n.length;){var M=[g,n[x]];p>=3&&M.push(x),p>=4&&M.push(n),g=await o.apply(this,M),x++}return g}}function He(n){var o=S();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=He(g);p.forEach(function(x){l[x]=!0})}),o=He(l)}else n!==null&&typeof n=="object"&&!E(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function wt(n,o){var l;if(Array.isArray(n)){l=S();for(var g=0;g<n.length;g++){var p=wt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(x=>l.push(x)):l.push(p))}}else n!==null&&typeof n=="object"&&!E(n)&&(l=n[o]);return l}function Tt(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=S(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function mr(n){return!(typeof n>"u")}function At(n){var o=S();if(Array.isArray(n))n.forEach(function(p){o=Tt(o,At(p))});else if(n!==null&&typeof n=="object"&&!I(n))for(var l in n){var g={};g[l]=n[l],o.push(g)}else o=n;return o}function Z(n){if(!(typeof n>"u")){var o={};return n.forEach(function(l){for(var g in l)o[g]=l[g]}),o}}function yr(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=n.length,l=new Array(o),g=0;g<o;g++)l[o-g-1]=n[g];return l}}async function Jt(n,o){var l=S();for(var g in n){var p=he(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}function ut(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function Ut(n,o){if(!n)throw{code:"D3141",stack:new Error().stack,message:o||"$assert() statement failed"}}function yt(n){if(n!==void 0)return n===null?"null":b(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":E(n)?"function":"object"}async function Ce(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!R(n)&&!_(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(M,q){return M>q}}else l=o;var g=async function(M,q){var X=async function(pe,Pe,Se){Pe.length===0?Array.prototype.push.apply(pe,Se):Se.length===0?Array.prototype.push.apply(pe,Pe):await l(Pe[0],Se[0])?(pe.push(Se[0]),await X(pe,Pe,Se.slice(1))):(pe.push(Pe[0]),await X(pe,Pe.slice(1),Se))},De=[];return await X(De,M,q),De},p=async function(M){if(!Array.isArray(M)||M.length<=1)return M;var q=Math.floor(M.length/2),X=M.slice(0,q),De=M.slice(q);return X=await p(X),De=await p(De),await g(X,De)},x=await p(n);return x}}function u(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=new Array(n.length),l=0;l<n.length;l++){var g=Math.floor(Math.random()*(l+1));l!==g&&(o[l]=o[g]),o[g]=n[l]}return o}}function h(n){if(!(typeof n>"u")){if(!Array.isArray(n)||n.length<=1)return n;for(var o=k(n)?S():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,x=0;x<o.length;x++)if(ge(g,o[x])){p=!0;break}p||o.push(g)}return o}}async function y(n,o){var l={};for(var g in n){var p=n[g],x=he(o,p,g,n),M=await o.apply(this,x);K(M)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:N,count:ne,max:L,min:T,average:U,string:z,substring:de,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Me,trim:et,pad:_e,match:ae,contains:tt,replace:Fe,split:Ee,join:v,formatNumber:A,formatBase:w,number:P,floor:j,ceil:C,round:F,abs:$,sqrt:J,power:ye,random:we,boolean:K,not:Q,map:G,zip:qe,filter:Ze,single:it,foldLeft:Ue,sift:y,keys:He,lookup:wt,append:Tt,exists:mr,spread:At,merge:Z,reverse:yr,each:Jt,error:ut,assert:Ut,type:yt,sort:Ce,shuffle:u,distinct:h,base64encode:st,base64decode:d,encodeUrlComponent:m,encodeUrl:V,decodeUrlComponent:le,decodeUrl:Oe}})();a.exports=f}).call(this)}).call(this,typeof dn<"u"?dn:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(t,a,s){var i=t("./datetime"),c=t("./functions"),f=t("./utils"),b=t("./parser"),_=t("./signature"),R=(function(){var S=f.isNumeric,k=f.isArrayOfStrings,E=f.isArrayOfNumbers,I=f.createSequence,se=f.isSequence,me=f.isFunction,ge=f.isLambda,H=f.isIterable,N=f.isPromise,ne=f.getFunctionArity,L=f.isDeepEqual,T=ut(null);async function U(u,h,y){var n,o=y.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(o&&await o(u,h,y),u.type){case"path":n=await z(u,h,y);break;case"binary":n=await Me(u,h,y);break;case"unary":n=await et(u,h,y);break;case"name":n=_e(u,h);break;case"string":case"number":case"value":n=ue(u);break;case"wildcard":n=tt(u,h);break;case"descendant":n=Fe(u,h);break;case"parent":n=y.lookup(u.slot.label);break;case"condition":n=await j(u,h,y);break;case"block":n=await C(u,h,y);break;case"bind":n=await $(u,h,y);break;case"regex":n=F(u);break;case"function":n=await he(u,h,y);break;case"variable":n=J(u,h,y);break;case"lambda":n=it(u,h,y);break;case"partial":n=await qe(u,h,y);break;case"apply":n=await Q(u,h,y);break;case"transform":n=we(u,h,y);break}if(Object.prototype.hasOwnProperty.call(u,"predicate"))for(var l=0;l<u.predicate.length;l++)n=await ve(u.predicate[l].expr,n,y);u.type!=="path"&&Object.prototype.hasOwnProperty.call(u,"group")&&(n=await A(u.group,n,y));var g=y.lookup(Symbol.for("jsonata.__evaluate_exit"));return g&&await g(u,h,y,n),n&&se(n)&&!n.tupleStream&&(u.keepArray&&(n.keepSingleton=!0),n.length===0?n=void 0:n.length===1&&(n=n.keepSingleton?n:n[0])),n}async function z(u,h,y){var n;Array.isArray(h)&&u.steps[0].type!=="variable"?n=h:n=I(h);for(var o,l=!1,g=void 0,p=0;p<u.steps.length;p++){var x=u.steps[p];if(x.tuple&&(l=!0),p===0&&x.consarray?o=await U(x,n,y):l?g=await Ae(x,n,g,y):o=await xe(x,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof x.focus>"u"&&(n=o)}if(l)if(u.tuple)o=g;else for(o=I(),p=0;p<g.length;p++)o.push(g[p]["@"]);return u.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=I(o)),o.keepSingleton=!0),u.hasOwnProperty("group")&&(o=await A(u.group,l?g:o,y)),o}function de(u,h){var y=ut(u);for(const n in h)y.bind(n,h[n]);return y}async function xe(u,h,y,n){var o;if(u.type==="sort")return o=await ye(u,h,y),u.stages&&(o=await Te(u.stages,o,y)),o;o=I();for(var l=0;l<h.length;l++){var g=await U(u,h[l],y);if(u.stages)for(var p=0;p<u.stages.length;p++)g=await ve(u.stages[p].expr,g,y);typeof g<"u"&&o.push(g)}var x=I();return n&&o.length===1&&Array.isArray(o[0])&&!se(o[0])?x=o[0]:o.forEach(function(M){!Array.isArray(M)||M.cons?x.push(M):M.forEach(q=>x.push(q))}),x}async function Te(u,h,y){for(var n=h,o=0;o<u.length;o++){var l=u[o];switch(l.type){case"filter":n=await ve(l.expr,n,y);break;case"index":for(var g=0;g<n.length;g++){var p=n[g];p[l.value]=g}break}}return n}async function Ae(u,h,y,n){var o;if(u.type==="sort"){if(y)o=await ye(u,y,n);else{var l=await ye(u,h,n);o=I(),o.tupleStream=!0;for(var g=0;g<l.length;g++){var p={"@":l[g]};p[u.index]=g,o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}o=I(),o.tupleStream=!0;var x=n;y===void 0&&(y=h.map(De=>({"@":De})));for(var M=0;M<y.length;M++){x=de(n,y[M]);var q=await U(u,y[M]["@"],x);if(typeof q<"u"){Array.isArray(q)||(q=[q]);for(var X=0;X<q.length;X++)p={},Object.assign(p,y[M]),q.tupleStream?Object.assign(p,q[X]):(u.focus?(p[u.focus]=q[X],p["@"]=y[M]["@"]):p["@"]=q[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[M]["@"])),o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}async function ve(u,h,y){var n=I();if(h&&h.tupleStream&&(n.tupleStream=!0),Array.isArray(h)||(h=I(h)),u.type==="number"){var o=Math.floor(u.value);o<0&&(o=h.length+o);var l=await h[o];typeof l<"u"&&(Array.isArray(l)?n=l:n.push(l))}else for(o=0;o<h.length;o++){var l=h[o],g=l,p=y;h.tupleStream&&(g=l["@"],p=de(y,l));var x=await U(u,g,p);S(x)&&(x=[x]),E(x)?x.forEach(function(q){var X=Math.floor(q);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(x)&&n.push(l)}return n}async function Me(u,h,y){var n,o=await U(u.lhs,h,y),l=u.value,g=async()=>await U(u.rhs,h,y);if(l==="and"||l==="or")try{return await Oe(o,g,l)}catch(x){throw x.position=u.position,x.token=l,x}var p=await g();try{switch(l){case"+":case"-":case"*":case"/":case"%":n=d(o,p,l);break;case"=":case"!=":n=m(o,p,l);break;case"<":case"<=":case">":case">=":n=V(o,p,l);break;case"&":n=v(o,p);break;case"..":n=P(o,p);break;case"in":n=le(o,p);break}}catch(x){throw x.position=u.position,x.token=l,x}return n}async function et(u,h,y){var n;switch(u.value){case"-":if(n=await U(u.expression,h,y),typeof n>"u")n=void 0;else if(S(n))n=-n;else throw{code:"D1002",stack:new Error().stack,position:u.position,token:u.value,value:n};break;case"[":n=[];let g=await Promise.all(u.expressions.map(async(p,x)=>(y.isParallelCall=x>0,[p,await U(p,h,y)])));for(let p of g){var[o,l]=p;typeof l<"u"&&(o.value==="["?n.push(l):n=c.append(n,l))}u.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":n=await A(u,h,y);break}return n}function _e(u,h,y){return c.lookup(h,u.value)}function ue(u){return u.value}function tt(u,h){var y=I();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(n){var o=h[n];Array.isArray(o)?(o=ae(o),y=c.append(y,o)):y.push(o)}),y}function ae(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ae(y,h)}):h.push(u),h}function Fe(u,h){var y,n=I();return typeof h<"u"&&(st(h,n),n.length===1?y=n[0]:y=n),y}function st(u,h){Array.isArray(u)||h.push(u),Array.isArray(u)?u.forEach(function(y){st(y,h)}):u!==null&&typeof u=="object"&&Object.keys(u).forEach(function(y){st(u[y],h)})}function d(u,h,y){var n;if(typeof u<"u"&&!S(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!S(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u")return n;switch(y){case"+":n=u+h;break;case"-":n=u-h;break;case"*":n=u*h;break;case"/":n=u/h;break;case"%":n=u%h;break}return n}function m(u,h,y){var n,o=typeof u,l=typeof h;if(o==="undefined"||l==="undefined")return!1;switch(y){case"=":n=L(u,h);break;case"!=":n=!L(u,h);break}return n}function V(u,h,y){var n,o=typeof u,l=typeof h,g=o==="undefined"||o==="string"||o==="number",p=l==="undefined"||l==="string"||l==="number";if(!g||!p)throw{code:"T2010",stack:new Error().stack,value:o==="string"||o==="number"?h:u};if(!(o==="undefined"||l==="undefined")){if(o!==l)throw{code:"T2009",stack:new Error().stack,value:u,value2:h};switch(y){case"<":n=u<h;break;case"<=":n=u<=h;break;case">":n=u>h;break;case">=":n=u>=h;break}return n}}function le(u,h){var y=!1;if(typeof u>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var n=0;n<h.length;n++)if(h[n]===u){y=!0;break}return y}async function Oe(u,h,y){var n,o=Ee(u);switch(y){case"and":n=o&&Ee(await h());break;case"or":n=o||Ee(await h());break}return n}function Ee(u){var h=c.boolean(u);return typeof h>"u"?!1:h}function v(u,h){var y,n="",o="";return typeof u<"u"&&(n=c.string(u)),typeof h<"u"&&(o=c.string(h)),y=n.concat(o),y}async function A(u,h,y){var n={},o={},l=!!(h&&h.tupleStream);Array.isArray(h)||(h=I(h)),h.length===0&&h.push(void 0);for(var g=0;g<h.length;g++)for(var p=h[g],x=l?de(y,p):y,M=0;M<u.lhs.length;M++){var q=u.lhs[M],X=await U(q[0],l?p["@"]:p,x);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var De={data:p,exprIndex:M};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==M)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=De}}let pe=await Promise.all(Object.keys(o).map(async(Se,We)=>{let ke=o[Se];var je=ke.data,ot=y;if(l){var ze=w(ke.data);je=ze["@"],delete ze["@"],ot=de(y,ze)}return y.isParallelCall=We>0,[Se,await U(u.lhs[ke.exprIndex][1],je,ot)]}));for(let Se of pe){var[X,Pe]=await Se;typeof Pe<"u"&&(n[X]=Pe)}return n}function w(u){if(!Array.isArray(u))return u;var h={};Object.assign(h,u[0]);for(var y=1;y<u.length;y++)for(const n in u[y])h[n]=c.append(h[n],u[y][n]);return h}function P(u,h){var y;if(typeof u<"u"&&!Number.isInteger(u))throw{code:"T2003",stack:new Error().stack,value:u};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u"||u>h)return y;var n=h-u+1;if(n>1e7)throw{code:"D2014",stack:new Error().stack,value:n};y=new Array(n);for(var o=u,l=0;o<=h;o++,l++)y[l]=o;return y.sequence=!0,y}async function $(u,h,y){var n=await U(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await U(u.condition,h,y);return c.boolean(o)?n=await U(u.then,h,y):typeof u.else<"u"&&(n=await U(u.else,h,y)),n}async function C(u,h,y){for(var n,o=ut(y),l=0;l<u.expressions.length;l++)n=await U(u.expressions[l],h,o);return n}function F(u){var h=new Ce.RegexEngine(u.value),y=function(n,o){var l;h.lastIndex=o||0;var g=h.exec(n);if(g!==null){if(l={match:g[0],start:g.index,end:g.index+g[0].length,groups:[]},g.length>1)for(var p=1;p<g.length;p++)l.groups.push(g[p]);l.next=function(){if(!(h.lastIndex>=n.length)){var x=y(n,h.lastIndex);if(x&&x.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return x}}}return l};return y}function J(u,h,y){var n;return u.value===""?n=h&&h.outerWrapper?h[0]:h:n=y.lookup(u.value),n}async function ye(u,h,y){var n,o=h,l=!!h.tupleStream,g=async function(x,M){for(var q=0,X=0;q===0&&X<u.terms.length;X++){var De=u.terms[X],pe=x,Pe=y;l&&(pe=x["@"],Pe=de(y,x));var Se=await U(De.expression,pe,Pe);pe=M,Pe=y,l&&(pe=M["@"],Pe=de(y,M));var We=await U(De.expression,pe,Pe),ke=typeof Se,je=typeof We;if(ke==="undefined"){q=je==="undefined"?0:1;continue}if(je==="undefined"){q=-1;continue}if(!(ke==="string"||ke==="number")||!(je==="string"||je==="number"))throw{code:"T2008",stack:new Error().stack,position:u.position,value:ke==="string"||ke==="number"?We:Se};if(ke!==je)throw{code:"T2007",stack:new Error().stack,position:u.position,value:Se,value2:We};Se!==We&&(Se<We?q=-1:q=1,De.descending===!0&&(q=-q))}return q===1},p={environment:y,input:h};return n=await c.sort.apply(p,[o,g]),n}function we(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!me(l))throw{code:"T2013",stack:new Error().stack,position:u.position};var g=await G(l,[o],null,y),p=await U(u.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var x=0;x<p.length;x++){var M=p[x];if(M&&(M.isPrototypeOf(g)||M instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var q=await U(u.update,M,y),X=typeof q;if(X!=="undefined"){if(X!=="object"||q===null||Array.isArray(q))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:q};for(var De in q)M[De]=q[De]}if(typeof u.delete<"u"){var pe=await U(u.delete,M,y);if(typeof pe<"u"){var Pe=pe;if(Array.isArray(pe)||(pe=[pe]),!k(pe))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Pe};for(var Se=0;Se<pe.length;Se++)typeof M=="object"&&M!==null&&delete M[pe[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var K=b("function($f, $g) { function($x){ $g($f($x)) } }");async function Q(u,h,y){var n,o=await U(u.lhs,h,y);if(u.rhs.type==="function")n=await he(u.rhs,h,y,{context:o});else{var l=await U(u.rhs,h,y);if(!me(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(me(o)){var g=await U(K,null,y);n=await G(g,[o,l],null,y)}else n=await G(l,[o],null,y)}return n}async function he(u,h,y,n){var o,l=await U(u.procedure,h,y);if(typeof l>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};var g=[];typeof n<"u"&&g.push(n.context);for(var p=0;p<u.arguments.length;p++){const M=await U(u.arguments[p],h,y);if(me(M)){const q=async function(...X){return await G(M,X,null,y)};q.arity=ne(M),g.push(q)}else g.push(M)}var x=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=x,l.position=u.position),o=await G(l,g,h,y)}catch(M){throw M.position||(M.position=u.position),M.token||(M.token=x),M}return o}async function G(u,h,y,n){var o;for(o=await Ze(u,h,y,n);ge(o)&&o.thunk===!0;){var l=await U(o.body.procedure,o.input,o.environment);o.body.procedure.type==="variable"&&(l.token=o.body.procedure.value),l.position=o.body.procedure.position;for(var g=[],p=0;p<o.body.arguments.length;p++)g.push(await U(o.body.arguments[p],o.input,o.environment));o=await Ze(l,g,y,n)}return o}async function Ze(u,h,y,n){var o;try{var l=h;if(u&&(l=Ue(u.signature,h,y)),ge(u))o=await He(u,l);else if(u&&u._jsonata_function===!0){var g={environment:n,input:y};o=u.implementation.apply(g,l),H(o)&&(o=o.next().value),N(o)&&(o=await o)}else if(typeof u=="function")o=u.apply(y,l),N(o)&&(o=await o);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw u&&(typeof p.token>"u"&&typeof u.token<"u"&&(p.token=u.token),p.position=u.position||p.position),p}return o}function it(u,h,y){var n={_jsonata_lambda:!0,input:h,environment:y,arguments:u.arguments,signature:u.signature,body:u.body};return u.thunk===!0&&(n.thunk=!0),n.apply=async function(o,l){return await G(n,l,h,o?o.environment:y)},n}async function qe(u,h,y){for(var n,o=[],l=0;l<u.arguments.length;l++){var g=u.arguments[l];g.type==="operator"&&g.value==="?"?o.push(g):o.push(await U(g,h,y))}var p=await U(u.procedure,h,y);if(typeof p>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};if(ge(p))n=wt(p,o);else if(p&&p._jsonata_function===!0)n=Tt(p.implementation,o);else if(typeof p=="function")n=Tt(p,o);else throw{code:"T1008",stack:new Error().stack,position:u.position,token:u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value};return n}function Ue(u,h,y){if(typeof u>"u")return h;var n=u.validate(h,y);return n}async function He(u,h){var y,n=ut(u.environment);return u.arguments.forEach(function(o,l){n.bind(o.value,h[l])}),typeof u.body=="function"?y=await mr(u.body,n):y=await U(u.body,u.input,n),y}function wt(u,h){var y=ut(u.environment),n=[];u.arguments.forEach(function(l,g){var p=h[g];p&&p.type==="operator"&&p.value==="?"?n.push(l):y.bind(l.value,p)});var o={_jsonata_lambda:!0,input:u.input,environment:y,arguments:n,body:u.body};return o}function Tt(u,h){var y=At(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=b(n);o.body=u;var l=wt(o,h);return l}async function mr(u,h){var y=At(u),n=y.map(function(g){return h.lookup(g.trim())}),o={environment:h},l=u.apply(o,n);return N(l)&&(l=await l),l}function At(u){var h=u.toString(),y=/\(([^)]*)\)/.exec(h)[1],n=y.split(",");return n}function Z(u,h){var y={_jsonata_function:!0,implementation:u};return typeof h<"u"&&(y.signature=_(h)),y}async function yr(u,h){if(!(typeof u>"u")){var y=this.input;typeof h<"u"&&(y=h,Array.isArray(y)&&!se(y)&&(y=I(y),y.outerWrapper=!0));try{var n=b(u,!1)}catch(l){throw yt(l),{stack:new Error().stack,code:"D3120",value:l.message,error:l}}try{var o=await U(n,y,this.environment)}catch(l){throw yt(l),{stack:new Error().stack,code:"D3121",value:l.message,error:l}}return o}}function Jt(u){if(!(typeof u>"u"))return JSON.parse(c.string(u))}function ut(u){var h={};const y={bind:function(o,l){h[o]=l},lookup:function(o){var l;return h.hasOwnProperty(o)?l=h[o]:u&&(l=u.lookup(o)),l},timestamp:u?u.timestamp:null,async:u?u.async:!1,isParallelCall:u?u.isParallelCall:!1,global:u?u.global:{ancestry:[null]}};if(u){var n=u.lookup(Symbol.for("jsonata.__createFrame_push"));n&&n(u,y)}return y}T.bind("sum",Z(c.sum,"<a<n>:n>")),T.bind("count",Z(c.count,"<a:n>")),T.bind("max",Z(c.max,"<a<n>:n>")),T.bind("min",Z(c.min,"<a<n>:n>")),T.bind("average",Z(c.average,"<a<n>:n>")),T.bind("string",Z(c.string,"<x-b?:s>")),T.bind("substring",Z(c.substring,"<s-nn?:s>")),T.bind("substringBefore",Z(c.substringBefore,"<s-s:s>")),T.bind("substringAfter",Z(c.substringAfter,"<s-s:s>")),T.bind("lowercase",Z(c.lowercase,"<s-:s>")),T.bind("uppercase",Z(c.uppercase,"<s-:s>")),T.bind("length",Z(c.length,"<s-:n>")),T.bind("trim",Z(c.trim,"<s-:s>")),T.bind("pad",Z(c.pad,"<s-ns?:s>")),T.bind("match",Z(c.match,"<s-f<s:o>n?:a<o>>")),T.bind("contains",Z(c.contains,"<s-(sf):b>")),T.bind("replace",Z(c.replace,"<s-(sf)(sf)n?:s>")),T.bind("split",Z(c.split,"<s-(sf)n?:a<s>>")),T.bind("join",Z(c.join,"<a<s>s?:s>")),T.bind("formatNumber",Z(c.formatNumber,"<n-so?:s>")),T.bind("formatBase",Z(c.formatBase,"<n-n?:s>")),T.bind("formatInteger",Z(i.formatInteger,"<n-s:s>")),T.bind("parseInteger",Z(i.parseInteger,"<s-s:n>")),T.bind("number",Z(c.number,"<(nsb)-:n>")),T.bind("floor",Z(c.floor,"<n-:n>")),T.bind("ceil",Z(c.ceil,"<n-:n>")),T.bind("round",Z(c.round,"<n-n?:n>")),T.bind("abs",Z(c.abs,"<n-:n>")),T.bind("sqrt",Z(c.sqrt,"<n-:n>")),T.bind("power",Z(c.power,"<n-n:n>")),T.bind("random",Z(c.random,"<:n>")),T.bind("boolean",Z(c.boolean,"<x-:b>")),T.bind("not",Z(c.not,"<x-:b>")),T.bind("map",Z(c.map,"<af>")),T.bind("zip",Z(c.zip,"<a+>")),T.bind("filter",Z(c.filter,"<af>")),T.bind("single",Z(c.single,"<af?>")),T.bind("reduce",Z(c.foldLeft,"<afj?:j>")),T.bind("sift",Z(c.sift,"<o-f?:o>")),T.bind("keys",Z(c.keys,"<x-:a<s>>")),T.bind("lookup",Z(c.lookup,"<x-s:x>")),T.bind("append",Z(c.append,"<xx:a>")),T.bind("exists",Z(c.exists,"<x:b>")),T.bind("spread",Z(c.spread,"<x-:a<o>>")),T.bind("merge",Z(c.merge,"<a<o>:o>")),T.bind("reverse",Z(c.reverse,"<a:a>")),T.bind("each",Z(c.each,"<o-f:a>")),T.bind("error",Z(c.error,"<s?:x>")),T.bind("assert",Z(c.assert,"<bs?:x>")),T.bind("type",Z(c.type,"<x:s>")),T.bind("sort",Z(c.sort,"<af?:a>")),T.bind("shuffle",Z(c.shuffle,"<a:a>")),T.bind("distinct",Z(c.distinct,"<x:x>")),T.bind("base64encode",Z(c.base64encode,"<s-:s>")),T.bind("base64decode",Z(c.base64decode,"<s-:s>")),T.bind("encodeUrlComponent",Z(c.encodeUrlComponent,"<s-:s>")),T.bind("encodeUrl",Z(c.encodeUrl,"<s-:s>")),T.bind("decodeUrlComponent",Z(c.decodeUrlComponent,"<s-:s>")),T.bind("decodeUrl",Z(c.decodeUrl,"<s-:s>")),T.bind("eval",Z(yr,"<sx?:x>")),T.bind("toMillis",Z(i.toMillis,"<s-s?:n>")),T.bind("fromMillis",Z(i.fromMillis,"<n-s?s?:s>")),T.bind("clone",Z(Jt,"<(oa)-:o>"));var Ut={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function yt(u){var h=Ut[u.code];if(typeof h<"u"){var y=h.replace(/\{\{\{([^}]+)}}}/g,function(){return u[arguments[1]]});y=y.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(u[arguments[1]])}),u.message=y}}function Ce(u,h){var y,n;try{y=b(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw yt(g),g}var o=ut(T),l=new Date;return o.bind("now",Z(function(g,p){return i.fromMillis(l.getTime(),g,p)},"<s?s?:s>")),o.bind("millis",Z(function(){return l.getTime()},"<:n>")),h&&h.RegexEngine?Ce.RegexEngine=h.RegexEngine:Ce.RegexEngine=RegExp,{evaluate:async function(g,p,x){if(typeof n<"u"){var M={code:"S0500",position:0};throw yt(M),M}if(typeof p<"u"){var q;q=ut(o);for(var X in p)q.bind(X,p[X])}else q=o;q.bind("$",g),l=new Date,q.timestamp=l,Array.isArray(g)&&!se(g)&&(g=I(g),g.outerWrapper=!0);var De;try{return De=await U(y,g,q),typeof x=="function"&&x(null,De),De}catch(pe){throw yt(pe),pe}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,x){var M=Z(p,x);o.bind(g,M)},ast:function(){return y},errors:function(){return n}}}return Ce.parser=b,Ce})();a.exports=R},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,a,s){var i=t("./signature");const c=(()=>{var f={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},b={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
1
+ "use strict";var Nn=Object.defineProperty;var Mn=(r,e,t)=>e in r?Nn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var fe=(r,e,t)=>Mn(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class ct extends Error{constructor(e,t,a){super(e),this.code=t,this.details=a,this.name="EightGError"}static extensionNotInstalled(){return new ct("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new ct(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new ct(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(e=6e5){const t=Math.floor(e/1e3);return new ct(`Request timeout - Extension did not respond within ${t} seconds`,"REQUEST_TIMEOUT")}}function Rn(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}var be;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const i={};for(const c of s)i[c]=c;return i},r.getValidEnumValues=s=>{const i=r.objectKeys(s).filter(f=>typeof s[s[f]]!="number"),c={};for(const f of i)c[f]=s[f];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const c in s)Object.prototype.hasOwnProperty.call(s,c)&&i.push(c);return i},r.find=(s,i)=>{for(const c of s)if(i(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,i=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(i)}r.joinValues=a,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(be||(be={}));var Rr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Rr||(Rr={}));const W=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_t=r=>{switch(typeof r){case"undefined":return W.undefined;case"string":return W.string;case"number":return Number.isNaN(r)?W.nan:W.number;case"boolean":return W.boolean;case"function":return W.function;case"bigint":return W.bigint;case"symbol":return W.symbol;case"object":return Array.isArray(r)?W.array:r===null?W.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?W.promise:typeof Map<"u"&&r instanceof Map?W.map:typeof Set<"u"&&r instanceof Set?W.set:typeof Date<"u"&&r instanceof Date?W.date:W.object;default:return W.unknown}},O=be.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"]),In=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class at extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(i){return i.message},a={_errors:[]},s=i=>{for(const c of i.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(t(c));else{let f=a,b=0;for(;b<c.path.length;){const _=c.path[b];b===c.path.length-1?(f[_]=f[_]||{_errors:[]},f[_]._errors.push(t(c))):f[_]=f[_]||{_errors:[]},f=f[_],b++}}};return s(this),a}static assert(e){if(!(e instanceof at))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,be.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},a=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];t[i]=t[i]||[],t[i].push(e(s))}else a.push(e(s));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}at.create=r=>new at(r);const Ht=(r,e)=>{let t;switch(r.code){case O.invalid_type:r.received===W.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case O.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,be.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:t=`Unrecognized key(s) in object: ${be.joinValues(r.keys,", ")}`;break;case O.invalid_union:t="Invalid input";break;case O.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${be.joinValues(r.options)}`;break;case O.invalid_enum_value:t=`Invalid enum value. Expected ${be.joinValues(r.options)}, received '${r.received}'`;break;case O.invalid_arguments:t="Invalid function arguments";break;case O.invalid_return_type:t="Invalid function return type";break;case O.invalid_date:t="Invalid date";break;case O.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:be.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case O.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case O.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case O.custom:t="Invalid input";break;case O.invalid_intersection_types:t="Intersection results could not be merged";break;case O.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case O.not_finite:t="Number must be finite";break;default:t=e.defaultError,be.assertNever(r)}return{message:t}};let pn=Ht;function jn(r){pn=r}function xr(){return pn}const _r=r=>{const{data:e,path:t,errorMaps:a,issueData:s}=r,i=[...t,...s.path||[]],c={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let f="";const b=a.filter(_=>!!_).slice().reverse();for(const _ of b)f=_(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},Fn=[];function B(r,e){const t=xr(),a=_r({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Ht?void 0:Ht].filter(s=>!!s)});r.common.issues.push(a)}class Ke{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const s of t){if(s.status==="aborted")return ee;s.status==="dirty"&&e.dirty(),a.push(s.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const s of t){const i=await s.key,c=await s.value;a.push({key:i,value:c})}return Ke.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const s of t){const{key:i,value:c}=s;if(i.status==="aborted"||c.status==="aborted")return ee;i.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[i.value]=c.value)}return{status:e.value,value:a}}}const ee=Object.freeze({status:"aborted"}),Vt=r=>({status:"dirty",value:r}),Je=r=>({status:"valid",value:r}),Ir=r=>r.status==="aborted",jr=r=>r.status==="dirty",jt=r=>r.status==="valid",tr=r=>typeof Promise<"u"&&r instanceof Promise;var Y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class vt{constructor(e,t,a,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=s}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 cn=(r,e)=>{if(jt(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new at(r.common.issues);return this._error=t,this._error}}};function ie(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:a,description:s}=r;if(e&&(t||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,f)=>{const{message:b}=r;return c.code==="invalid_enum_value"?{message:b??f.defaultError}:typeof f.data>"u"?{message:b??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:b??t??f.defaultError}},description:s}}class ce{get description(){return this._def.description}_getType(e){return _t(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:_t(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ke,ctx:{common:e.parent.common,data:e.data,parsedType:_t(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(tr(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){const a={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},s=this._parseSync({data:e,path:a.path,parent:a});return cn(a,s)}"~validate"(e){var a,s;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:t});return jt(i)?{value:i.value}:{issues:t.common.issues}}catch(i){(s=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(i=>jt(i)?{value:i.value}:{issues:t.common.issues})}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},s=this._parse({data:e,path:a.path,parent:a}),i=await(tr(s)?s:Promise.resolve(s));return cn(a,i)}refine(e,t){const a=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,i)=>{const c=e(s),f=()=>i.addIssue({code:O.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(b=>b?!0:(f(),!1)):c?!0:(f(),!1)})}refinement(e,t){return this._refinement((a,s)=>e(a)?!0:(s.addIssue(typeof t=="function"?t(a,s):t),!1))}_refinement(e){return new ht({schema:this,typeName:re.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:t=>this["~validate"](t)}}optional(){return gt.create(this,this._def)}nullable(){return Pt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this)}promise(){return Yt.create(this,this._def)}or(e){return sr.create([this,e],this._def)}and(e){return ir.create(this,e,this._def)}transform(e){return new ht({...ie(this._def),schema:this,typeName:re.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new fr({...ie(this._def),innerType:this,defaultValue:t,typeName:re.ZodDefault})}brand(){return new Br({typeName:re.ZodBranded,type:this,...ie(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new dr({...ie(this._def),innerType:this,catchValue:t,typeName:re.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pr.create(this,e)}readonly(){return hr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $n=/^c[^\s-]{8,}$/i,Bn=/^[0-9a-z]+$/,Un=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ln=/^[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,Zn=/^[a-z0-9_-]{21}$/i,Wn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zn=/^[-+]?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)?)??$/,Vn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pr;const Hn=/^(?:(?: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])$/,Gn=/^(?:(?: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])$/,Yn=/^(([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]))$/,Kn=/^(([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])$/,Jn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mn="((\\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])))",Qn=new RegExp(`^${mn}$`);function yn(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function ea(r){return new RegExp(`^${yn(r)}$`)}function gn(r){let e=`${mn}T${yn(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ta(r,e){return!!((e==="v4"||!e)&&Hn.test(r)||(e==="v6"||!e)&&Yn.test(r))}function ra(r,e){if(!Wn.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const a=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function na(r,e){return!!((e==="v4"||!e)&&Gn.test(r)||(e==="v6"||!e)&&Kn.test(r))}class ft extends ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==W.string){const i=this._getOrReturnCtx(e);return B(i,{code:O.invalid_type,expected:W.string,received:i.parsedType}),ee}const a=new Ke;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const c=e.data.length>i.value,f=e.data.length<i.value;(c||f)&&(s=this._getOrReturnCtx(e,s),c?B(s,{code:O.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&B(s,{code:O.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"email",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Pr||(Pr=new RegExp(qn,"u")),Pr.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"emoji",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"uuid",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"nanoid",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")$n.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid2",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Un.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ulid",code:O.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),B(s,{validation:"url",code:O.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"regex",code:O.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?gn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?Qn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?ea(i).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:O.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?zn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"duration",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?ta(e.data,i.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ip",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?ra(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"jwt",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?na(e.data,i.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cidr",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?Jn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"base64",code:O.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?Xn.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"base64url",code:O.invalid_string,message:i.message}),a.dirty()):be.assertNever(i);return{status:a.value,value:e.data}}_regex(e,t,a){return this.refinement(s=>e.test(s),{validation:t,code:O.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ft({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Y.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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...Y.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Y.errToObj(t)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new ft({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ft({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ft.create=r=>new ft({checks:[],typeName:re.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});function aa(r,e){const t=(r.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,s=t>a?t:a,i=Number.parseInt(r.toFixed(s).replace(".","")),c=Number.parseInt(e.toFixed(s).replace(".",""));return i%c/10**s}class Ct extends ce{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)!==W.number){const i=this._getOrReturnCtx(e);return B(i,{code:O.invalid_type,expected:W.number,received:i.parsedType}),ee}let a;const s=new Ke;for(const i of this._def.checks)i.kind==="int"?be.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),B(a,{code:O.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?aa(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_finite,message:i.message}),s.dirty()):be.assertNever(i);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,a,s){return new Ct({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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"&&be.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(t===null||a.value>t)&&(t=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Ct.create=r=>new Ct({checks:[],typeName:re.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Dt extends ce{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)!==W.bigint)return this._getInvalidInput(e);let a;const s=new Ke;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),B(a,{code:O.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):be.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return B(t,{code:O.invalid_type,expected:W.bigint,received:t.parsedType}),ee}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,a,s){return new Dt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Dt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Dt.create=r=>new Dt({checks:[],typeName:re.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...ie(r)});class rr extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==W.boolean){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.boolean,received:a.parsedType}),ee}return Je(e.data)}}rr.create=r=>new rr({typeName:re.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Ft extends ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==W.date){const i=this._getOrReturnCtx(e);return B(i,{code:O.invalid_type,expected:W.date,received:i.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return B(i,{code:O.invalid_date}),ee}const a=new Ke;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:O.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):be.assertNever(i);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ft({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ft.create=r=>new Ft({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:re.ZodDate,...ie(r)});class Er extends ce{_parse(e){if(this._getType(e)!==W.symbol){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.symbol,received:a.parsedType}),ee}return Je(e.data)}}Er.create=r=>new Er({typeName:re.ZodSymbol,...ie(r)});class nr extends ce{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.undefined,received:a.parsedType}),ee}return Je(e.data)}}nr.create=r=>new nr({typeName:re.ZodUndefined,...ie(r)});class ar extends ce{_parse(e){if(this._getType(e)!==W.null){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.null,received:a.parsedType}),ee}return Je(e.data)}}ar.create=r=>new ar({typeName:re.ZodNull,...ie(r)});class Gt extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Gt.create=r=>new Gt({typeName:re.ZodAny,...ie(r)});class It extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}It.create=r=>new It({typeName:re.ZodUnknown,...ie(r)});class Et extends ce{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:O.invalid_type,expected:W.never,received:t.parsedType}),ee}}Et.create=r=>new Et({typeName:re.ZodNever,...ie(r)});class Tr extends ce{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.void,received:a.parsedType}),ee}return Je(e.data)}}Tr.create=r=>new Tr({typeName:re.ZodVoid,...ie(r)});class dt extends ce{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),s=this._def;if(t.parsedType!==W.array)return B(t,{code:O.invalid_type,expected:W.array,received:t.parsedType}),ee;if(s.exactLength!==null){const c=t.data.length>s.exactLength.value,f=t.data.length<s.exactLength.value;(c||f)&&(B(t,{code:c?O.too_big:O.too_small,minimum:f?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(B(t,{code:O.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(B(t,{code:O.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((c,f)=>s.type._parseAsync(new vt(t,c,t.path,f)))).then(c=>Ke.mergeArray(a,c));const i=[...t.data].map((c,f)=>s.type._parseSync(new vt(t,c,t.path,f)));return Ke.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new dt({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new dt({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new dt({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}dt.create=(r,e)=>new dt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:re.ZodArray,...ie(e)});function zt(r){if(r instanceof Ie){const e={};for(const t in r.shape){const a=r.shape[t];e[t]=gt.create(zt(a))}return new Ie({...r._def,shape:()=>e})}else return r instanceof dt?new dt({...r._def,type:zt(r.element)}):r instanceof gt?gt.create(zt(r.unwrap())):r instanceof Pt?Pt.create(zt(r.unwrap())):r instanceof bt?bt.create(r.items.map(e=>zt(e))):r}class Ie extends ce{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(),t=be.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==W.object){const _=this._getOrReturnCtx(e);return B(_,{code:O.invalid_type,expected:W.object,received:_.parsedType}),ee}const{status:a,ctx:s}=this._processInputParams(e),{shape:i,keys:c}=this._getCached(),f=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const _ in s.data)c.includes(_)||f.push(_);const b=[];for(const _ of c){const R=i[_],S=s.data[_];b.push({key:{status:"valid",value:_},value:R._parse(new vt(s,S,s.path,_)),alwaysSet:_ in s.data})}if(this._def.catchall instanceof Et){const _=this._def.unknownKeys;if(_==="passthrough")for(const R of f)b.push({key:{status:"valid",value:R},value:{status:"valid",value:s.data[R]}});else if(_==="strict")f.length>0&&(B(s,{code:O.unrecognized_keys,keys:f}),a.dirty());else if(_!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const _=this._def.catchall;for(const R of f){const S=s.data[R];b.push({key:{status:"valid",value:R},value:_._parse(new vt(s,S,s.path,R)),alwaysSet:R in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const _=[];for(const R of b){const S=await R.key,k=await R.value;_.push({key:S,value:k,alwaysSet:R.alwaysSet})}return _}).then(_=>Ke.mergeObjectSync(a,_)):Ke.mergeObjectSync(a,b)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new Ie({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,a)=>{var i,c;const s=((c=(i=this._def).errorMap)==null?void 0:c.call(i,t,a).message)??a.defaultError;return t.code==="unrecognized_keys"?{message:Y.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Ie({...this._def,unknownKeys:"strip"})}passthrough(){return new Ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:re.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ie({...this._def,catchall:e})}pick(e){const t={};for(const a of be.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new Ie({...this._def,shape:()=>t})}omit(e){const t={};for(const a of be.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new Ie({...this._def,shape:()=>t})}deepPartial(){return zt(this)}partial(e){const t={};for(const a of be.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?t[a]=s:t[a]=s.optional()}return new Ie({...this._def,shape:()=>t})}required(e){const t={};for(const a of be.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof gt;)i=i._def.innerType;t[a]=i}return new Ie({...this._def,shape:()=>t})}keyof(){return vn(be.objectKeys(this.shape))}}Ie.create=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strip",catchall:Et.create(),typeName:re.ZodObject,...ie(e)});Ie.strictCreate=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strict",catchall:Et.create(),typeName:re.ZodObject,...ie(e)});Ie.lazycreate=(r,e)=>new Ie({shape:r,unknownKeys:"strip",catchall:Et.create(),typeName:re.ZodObject,...ie(e)});class sr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;function s(i){for(const f of i)if(f.result.status==="valid")return f.result;for(const f of i)if(f.result.status==="dirty")return t.common.issues.push(...f.ctx.common.issues),f.result;const c=i.map(f=>new at(f.ctx.common.issues));return B(t,{code:O.invalid_union,unionErrors:c}),ee}if(t.common.async)return Promise.all(a.map(async i=>{const c={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(s);{let i;const c=[];for(const b of a){const _={...t,common:{...t.common,issues:[]},parent:null},R=b._parseSync({data:t.data,path:t.path,parent:_});if(R.status==="valid")return R;R.status==="dirty"&&!i&&(i={result:R,ctx:_}),_.common.issues.length&&c.push(_.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(b=>new at(b));return B(t,{code:O.invalid_union,unionErrors:f}),ee}}get options(){return this._def.options}}sr.create=(r,e)=>new sr({options:r,typeName:re.ZodUnion,...ie(e)});const xt=r=>r instanceof cr?xt(r.schema):r instanceof ht?xt(r.innerType()):r instanceof ur?[r.value]:r instanceof Ot?r.options:r instanceof lr?be.objectValues(r.enum):r instanceof fr?xt(r._def.innerType):r instanceof nr?[void 0]:r instanceof ar?[null]:r instanceof gt?[void 0,...xt(r.unwrap())]:r instanceof Pt?[null,...xt(r.unwrap())]:r instanceof Br||r instanceof hr?xt(r.unwrap()):r instanceof dr?xt(r._def.innerType):[];class Dr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.object)return B(t,{code:O.invalid_type,expected:W.object,received:t.parsedType}),ee;const a=this.discriminator,s=t.data[a],i=this.optionsMap.get(s);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}):(B(t,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const s=new Map;for(const i of t){const c=xt(i.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const f of c){if(s.has(f))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(f)}`);s.set(f,i)}}return new Dr({typeName:re.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ie(a)})}}function Fr(r,e){const t=_t(r),a=_t(e);if(r===e)return{valid:!0,data:r};if(t===W.object&&a===W.object){const s=be.objectKeys(e),i=be.objectKeys(r).filter(f=>s.indexOf(f)!==-1),c={...r,...e};for(const f of i){const b=Fr(r[f],e[f]);if(!b.valid)return{valid:!1};c[f]=b.data}return{valid:!0,data:c}}else if(t===W.array&&a===W.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<r.length;i++){const c=r[i],f=e[i],b=Fr(c,f);if(!b.valid)return{valid:!1};s.push(b.data)}return{valid:!0,data:s}}else return t===W.date&&a===W.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ir extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(Ir(i)||Ir(c))return ee;const f=Fr(i.value,c.value);return f.valid?((jr(i)||jr(c))&&t.dirty(),{status:t.value,value:f.data}):(B(a,{code:O.invalid_intersection_types}),ee)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,c])=>s(i,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}ir.create=(r,e,t)=>new ir({left:r,right:e,typeName:re.ZodIntersection,...ie(t)});class bt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.array)return B(a,{code:O.invalid_type,expected:W.array,received:a.parsedType}),ee;if(a.data.length<this._def.items.length)return B(a,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&a.data.length>this._def.items.length&&(B(a,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...a.data].map((c,f)=>{const b=this._def.items[f]||this._def.rest;return b?b._parse(new vt(a,c,a.path,f)):null}).filter(c=>!!c);return a.common.async?Promise.all(i).then(c=>Ke.mergeArray(t,c)):Ke.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new bt({...this._def,rest:e})}}bt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bt({items:r,typeName:re.ZodTuple,rest:null,...ie(e)})};class or extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.object)return B(a,{code:O.invalid_type,expected:W.object,received:a.parsedType}),ee;const s=[],i=this._def.keyType,c=this._def.valueType;for(const f in a.data)s.push({key:i._parse(new vt(a,f,a.path,f)),value:c._parse(new vt(a,a.data[f],a.path,f)),alwaysSet:f in a.data});return a.common.async?Ke.mergeObjectAsync(t,s):Ke.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,a){return t instanceof ce?new or({keyType:e,valueType:t,typeName:re.ZodRecord,...ie(a)}):new or({keyType:ft.create(),valueType:e,typeName:re.ZodRecord,...ie(t)})}}class Ar extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.map)return B(a,{code:O.invalid_type,expected:W.map,received:a.parsedType}),ee;const s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([f,b],_)=>({key:s._parse(new vt(a,f,a.path,[_,"key"])),value:i._parse(new vt(a,b,a.path,[_,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const b of c){const _=await b.key,R=await b.value;if(_.status==="aborted"||R.status==="aborted")return ee;(_.status==="dirty"||R.status==="dirty")&&t.dirty(),f.set(_.value,R.value)}return{status:t.value,value:f}})}else{const f=new Map;for(const b of c){const _=b.key,R=b.value;if(_.status==="aborted"||R.status==="aborted")return ee;(_.status==="dirty"||R.status==="dirty")&&t.dirty(),f.set(_.value,R.value)}return{status:t.value,value:f}}}}Ar.create=(r,e,t)=>new Ar({valueType:e,keyType:r,typeName:re.ZodMap,...ie(t)});class $t extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.set)return B(a,{code:O.invalid_type,expected:W.set,received:a.parsedType}),ee;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(B(a,{code:O.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(B(a,{code:O.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const i=this._def.valueType;function c(b){const _=new Set;for(const R of b){if(R.status==="aborted")return ee;R.status==="dirty"&&t.dirty(),_.add(R.value)}return{status:t.value,value:_}}const f=[...a.data.values()].map((b,_)=>i._parse(new vt(a,b,a.path,_)));return a.common.async?Promise.all(f).then(b=>c(b)):c(f)}min(e,t){return new $t({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new $t({...this._def,maxSize:{value:e,message:Y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}$t.create=(r,e)=>new $t({valueType:r,minSize:null,maxSize:null,typeName:re.ZodSet,...ie(e)});class qt extends ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.function)return B(t,{code:O.invalid_type,expected:W.function,received:t.parsedType}),ee;function a(f,b){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),Ht].filter(_=>!!_),issueData:{code:O.invalid_arguments,argumentsError:b}})}function s(f,b){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),Ht].filter(_=>!!_),issueData:{code:O.invalid_return_type,returnTypeError:b}})}const i={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof Yt){const f=this;return Je(async function(...b){const _=new at([]),R=await f._def.args.parseAsync(b,i).catch(E=>{throw _.addIssue(a(b,E)),_}),S=await Reflect.apply(c,this,R);return await f._def.returns._def.type.parseAsync(S,i).catch(E=>{throw _.addIssue(s(S,E)),_})})}else{const f=this;return Je(function(...b){const _=f._def.args.safeParse(b,i);if(!_.success)throw new at([a(b,_.error)]);const R=Reflect.apply(c,this,_.data),S=f._def.returns.safeParse(R,i);if(!S.success)throw new at([s(R,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new qt({...this._def,args:bt.create(e).rest(It.create())})}returns(e){return new qt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new qt({args:e||bt.create([]).rest(It.create()),returns:t||It.create(),typeName:re.ZodFunction,...ie(a)})}}class cr extends ce{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}cr.create=(r,e)=>new cr({getter:r,typeName:re.ZodLazy,...ie(e)});class ur extends ce{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:O.invalid_literal,expected:this._def.value}),ee}return{status:"valid",value:e.data}}get value(){return this._def.value}}ur.create=(r,e)=>new ur({value:r,typeName:re.ZodLiteral,...ie(e)});function vn(r,e){return new Ot({values:r,typeName:re.ZodEnum,...ie(e)})}class Ot extends ce{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return B(t,{expected:be.joinValues(a),received:t.parsedType,code:O.invalid_type}),ee}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return B(t,{received:t.data,code:O.invalid_enum_value,options:a}),ee}return Je(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ot.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ot.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Ot.create=vn;class lr extends ce{_parse(e){const t=be.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==W.string&&a.parsedType!==W.number){const s=be.objectValues(t);return B(a,{expected:be.joinValues(s),received:a.parsedType,code:O.invalid_type}),ee}if(this._cache||(this._cache=new Set(be.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=be.objectValues(t);return B(a,{received:a.data,code:O.invalid_enum_value,options:s}),ee}return Je(e.data)}get enum(){return this._def.values}}lr.create=(r,e)=>new lr({values:r,typeName:re.ZodNativeEnum,...ie(e)});class Yt extends ce{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.promise&&t.common.async===!1)return B(t,{code:O.invalid_type,expected:W.promise,received:t.parsedType}),ee;const a=t.parsedType===W.promise?t.data:Promise.resolve(t.data);return Je(a.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Yt.create=(r,e)=>new Yt({type:r,typeName:re.ZodPromise,...ie(e)});class ht extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===re.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:c=>{B(a,c),c.fatal?t.abort():t.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const c=s.transform(a.data,i);if(a.common.async)return Promise.resolve(c).then(async f=>{if(t.value==="aborted")return ee;const b=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return b.status==="aborted"?ee:b.status==="dirty"||t.value==="dirty"?Vt(b.value):b});{if(t.value==="aborted")return ee;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?ee:f.status==="dirty"||t.value==="dirty"?Vt(f.value):f}}if(s.type==="refinement"){const c=f=>{const b=s.refinement(f,i);if(a.common.async)return Promise.resolve(b);if(b instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(a.common.async===!1){const f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return f.status==="aborted"?ee:(f.status==="dirty"&&t.dirty(),c(f.value),{status:t.value,value:f.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(f=>f.status==="aborted"?ee:(f.status==="dirty"&&t.dirty(),c(f.value).then(()=>({status:t.value,value:f.value}))))}if(s.type==="transform")if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!jt(c))return ee;const f=s.transform(c.value,i);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:f}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>jt(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:t.value,value:f})):ee);be.assertNever(s)}}ht.create=(r,e,t)=>new ht({schema:r,typeName:re.ZodEffects,effect:e,...ie(t)});ht.createWithPreprocess=(r,e,t)=>new ht({schema:e,effect:{type:"preprocess",transform:r},typeName:re.ZodEffects,...ie(t)});class gt extends ce{_parse(e){return this._getType(e)===W.undefined?Je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}gt.create=(r,e)=>new gt({innerType:r,typeName:re.ZodOptional,...ie(e)});class Pt extends ce{_parse(e){return this._getType(e)===W.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pt.create=(r,e)=>new Pt({innerType:r,typeName:re.ZodNullable,...ie(e)});class fr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===W.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}fr.create=(r,e)=>new fr({innerType:r,typeName:re.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});class dr extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return tr(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new at(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new at(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}dr.create=(r,e)=>new dr({innerType:r,typeName:re.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});class Sr extends ce{_parse(e){if(this._getType(e)!==W.nan){const a=this._getOrReturnCtx(e);return B(a,{code:O.invalid_type,expected:W.nan,received:a.parsedType}),ee}return{status:"valid",value:e.data}}}Sr.create=r=>new Sr({typeName:re.ZodNaN,...ie(r)});const sa=Symbol("zod_brand");class Br extends ce{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class pr extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?ee:i.status==="dirty"?(t.dirty(),Vt(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?ee:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(e,t){return new pr({in:e,out:t,typeName:re.ZodPipeline})}}class hr extends ce{_parse(e){const t=this._def.innerType._parse(e),a=s=>(jt(s)&&(s.value=Object.freeze(s.value)),s);return tr(t)?t.then(s=>a(s)):a(t)}unwrap(){return this._def.innerType}}hr.create=(r,e)=>new hr({innerType:r,typeName:re.ZodReadonly,...ie(e)});function un(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function bn(r,e={},t){return r?Gt.create().superRefine((a,s)=>{const i=r(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=un(e,a),b=f.fatal??t??!0;s.addIssue({code:"custom",...f,fatal:b})}});if(!i){const c=un(e,a),f=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:f})}}):Gt.create()}const ia={object:Ie.lazycreate};var re;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(re||(re={}));const oa=(r,e={message:`Input not instance of ${r.name}`})=>bn(t=>t instanceof r,e),Be=ft.create,Kt=Ct.create,ca=Sr.create,ua=Dt.create,Bt=rr.create,la=Ft.create,fa=Er.create,da=nr.create,ha=ar.create,pa=Gt.create,ma=It.create,ya=Et.create,ga=Tr.create,va=dt.create,Nt=Ie.create,ba=Ie.strictCreate,wa=sr.create,ka=Dr.create,xa=ir.create,_a=bt.create,Ea=or.create,Ta=Ar.create,Aa=$t.create,Sa=qt.create,Ca=cr.create,Da=ur.create,wn=Ot.create,kn=lr.create,Oa=Yt.create,ln=ht.create,Pa=gt.create,Na=Pt.create,Ma=ht.createWithPreprocess,Ra=pr.create,Ia=()=>Be().optional(),ja=()=>Kt().optional(),Fa=()=>Bt().optional(),$r={string:(r=>ft.create({...r,coerce:!0})),number:(r=>Ct.create({...r,coerce:!0})),boolean:(r=>rr.create({...r,coerce:!0})),bigint:(r=>Dt.create({...r,coerce:!0})),date:(r=>Ft.create({...r,coerce:!0}))},$a=ee,D=Object.freeze(Object.defineProperty({__proto__:null,BRAND:sa,DIRTY:Vt,EMPTY_PATH:Fn,INVALID:ee,NEVER:$a,OK:Je,ParseStatus:Ke,Schema:ce,ZodAny:Gt,ZodArray:dt,ZodBigInt:Dt,ZodBoolean:rr,ZodBranded:Br,ZodCatch:dr,ZodDate:Ft,ZodDefault:fr,ZodDiscriminatedUnion:Dr,ZodEffects:ht,ZodEnum:Ot,ZodError:at,get ZodFirstPartyTypeKind(){return re},ZodFunction:qt,ZodIntersection:ir,ZodIssueCode:O,ZodLazy:cr,ZodLiteral:ur,ZodMap:Ar,ZodNaN:Sr,ZodNativeEnum:lr,ZodNever:Et,ZodNull:ar,ZodNullable:Pt,ZodNumber:Ct,ZodObject:Ie,ZodOptional:gt,ZodParsedType:W,ZodPipeline:pr,ZodPromise:Yt,ZodReadonly:hr,ZodRecord:or,ZodSchema:ce,ZodSet:$t,ZodString:ft,ZodSymbol:Er,ZodTransformer:ht,ZodTuple:bt,ZodType:ce,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:It,ZodVoid:Tr,addIssueToContext:B,any:pa,array:va,bigint:ua,boolean:Bt,coerce:$r,custom:bn,date:la,datetimeRegex:gn,defaultErrorMap:Ht,discriminatedUnion:ka,effect:ln,enum:wn,function:Sa,getErrorMap:xr,getParsedType:_t,instanceof:oa,intersection:xa,isAborted:Ir,isAsync:tr,isDirty:jr,isValid:jt,late:ia,lazy:Ca,literal:Da,makeIssue:_r,map:Ta,nan:ca,nativeEnum:kn,never:ya,null:ha,nullable:Na,number:Kt,object:Nt,get objectUtil(){return Rr},oboolean:Fa,onumber:ja,optional:Pa,ostring:Ia,pipeline:Ra,preprocess:Ma,promise:Oa,quotelessJson:In,record:Ea,set:Aa,setErrorMap:jn,strictObject:ba,string:Be,symbol:fa,transformer:ln,tuple:_a,undefined:da,union:wa,unknown:ma,get util(){return be},void:ga},Symbol.toStringTag,{value:"Module"})),xn=Nt({name:Be(),key:Be(),image:Be()});var Ur=(r=>(r.monthly="MONTHLY",r.yearly="YEARLY",r))(Ur||{});const Cr=Nt({text:Be(),code:Be(),symbol:Be(),format:Be(),amount:Kt()});var _n=(r=>(r.USD="USD",r.KRW="KRW",r))(_n||{});const Ba={en:{code:"USD",symbol:"$"},ko:{code:"KRW",symbol:"₩"}},En=Nt({planName:Be(),currentCycleBillAmount:Cr,nextPaymentDue:Be(),cycleTerm:kn(Ur).nullable(),isFreeTier:Bt(),isPerUser:Bt(),paidMemberCount:Kt(),usedMemberCount:Kt(),unitPrice:Cr.nullable()}),Tn=Nt({uid:Be(),issuedDate:$r.date(),paidDate:$r.date().nullable().optional(),paymentMethod:Be(),amount:Cr,isSuccessfulPaid:Bt(),receiptUrl:Be()}),An=Nt({name:Be(),email:Be().email(),profileImageUrl:Be(),role:Be()});class Ua{constructor(){}async checkExtension(){return new Promise((e,t)=>{const a=setTimeout(()=>{t(ct.extensionNotInstalled())},5e3),s=i=>{Rn(i.data)&&(clearTimeout(a),window.removeEventListener("message",s),e(i.data))};window.addEventListener("message",s),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((t,a)=>{const s=`8g_wf_${Date.now()}_${Math.random()}`,i=e.timeoutMs??6e5,c=setTimeout(()=>{a(ct.requestTimeout(i))},i),f=b=>{var _,R,S,k;if(((_=b.data)==null?void 0:_.type)==="8G_COLLECT_RESPONSE"&&b.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const E=b.data,I=((R=E==null?void 0:E.result)==null?void 0:R.steps)??((k=(S=E==null?void 0:E.result)==null?void 0:S.result)==null?void 0:k.steps)??[];t({success:E.success,steps:I,error:E.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",f),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:s,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}async getWorkspaces(e){var i,c;const t=await this.collectWorkflow(e);if(!t.success)throw new ct("Failed to get workspaces","GET_WORKSPACES_FAILED");const a=(c=(i=t.steps[t.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a||!Array.isArray(a))return{rawData:t,data:[],isSuccess:!1};const s=[];for(const f of a){const b=xn.safeParse(f);b.success?s.push(b.data):console.warn("Invalid workspace data:",f,b.error)}return{rawData:t,data:s,isSuccess:!0}}async getWorkspacePlanAndCycle(e){var i,c;const t=await this.collectWorkflow(e);if(!t.success)throw new ct("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const a=(c=(i=t.steps[t.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a)return{rawData:t};const s=En.safeParse(a);if(s.success){const f=s.data;return{rawData:t,...f}}else return console.warn("Invalid workspace billing data:",a,s.error),{rawData:t}}async getWorkspaceBillingHistories(e){var i,c;const t=await this.collectWorkflow(e);if(!t.success)throw new ct("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const a=(c=(i=t.steps[t.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a||!Array.isArray(a))return{rawData:t,data:[]};const s=[];for(const f of a){const b=Tn.safeParse(f);b.success?s.push(b.data):console.warn("Invalid workspace billing history data:",f,b.error)}return{rawData:t,data:s}}async getWorkspaceMembers(e){var i,c;const t=await this.collectWorkflow(e);if(!t.success)throw new ct("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const a=(c=(i=t.steps[t.steps.length-1])==null?void 0:i.result)==null?void 0:c.data;if(!a||!Array.isArray(a))return{rawData:t,data:[]};const s=[];for(const f of a){const b=An.safeParse(f);b.success?s.push(b.data):console.warn("Invalid workspace member data:",f,b.error)}return{rawData:t,data:s}}}const pt=Nt({name:Be(),selector:Be(),findBy:wn(["cssSelector","xpath"]),option:Nt({waitForSelector:Bt().optional(),waitSelectorTimeout:Kt().optional(),multiple:Bt().optional()})}),La=D.object({type:D.literal("object"),shape:D.record(D.string(),D.any())}),Za=D.object({type:D.literal("array"),items:D.any()}),Wa=D.discriminatedUnion("type",[La,Za]),Lr=D.object({name:D.literal("ai-parse-data"),sourceData:D.any().optional(),schemaDefinition:Wa,prompt:D.string().optional(),model:D.string().optional(),apiKey:D.string().min(1,"OpenAI API key is required")});function za(r){return Lr.parse(r)}async function Va(r){try{const{sourceData:e,schemaDefinition:t,prompt:a,model:s="gpt-4o-mini",apiKey:i}=r;if(e==null)throw new Error("sourceData is required for ai-parse-data block");if(!i||i.trim()==="")throw new Error("apiKey is required for ai-parse-data block");const c=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:t,prompt:a,model:s,apiKey:i}});if(c.$isError)throw new Error(c.message||"AI parsing failed");return{data:c.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function qa(r){return{type:"object",shape:r}}function Ha(r){return{type:"array",items:r}}const Ga={string:r=>({type:"string",...r}),number:r=>({type:"number",...r}),boolean:r=>({type:"boolean",...r}),array:(r,e)=>({type:"array",items:r,...e}),object:(r,e)=>({type:"object",shape:r,...e})};class Or{async waitForElement(e,t,a){return new Promise(s=>{const i=Date.now(),c=async()=>{const f=await this.find(e,t);if(f&&(!Array.isArray(f)||f.length>0)){s(f);return}if(Date.now()-i>=a){s(null);return}setTimeout(c,100)};c()})}}class Ya extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=this.processCustomPseudoSelectors(a,t);return i?Array.from(t.querySelectorAll(c)):t.querySelector(c)}catch(c){return console.error("CSS Selector error:",c),null}}processCustomPseudoSelectors(e,t){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const s=((i=a.textContent)==null?void 0:i.trim())||"";if(s){a.setAttribute("data-contains",s);const f=Array.from(a.childNodes).filter(b=>b.nodeType===Node.TEXT_NODE).map(b=>{var _;return((_=b.textContent)==null?void 0:_.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class Ka extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(_=>_.trim());if(c.length!==2)return null;const f=c[0],b=c[1];if(!f||!b)return null;try{const _=t.querySelector(f);if(!_||!_.contentDocument)return null;const R=_.contentDocument;return i?Array.from(R.querySelectorAll(b)):R.querySelector(b)}catch(_){return console.error("Iframe Selector error:",_),null}}}class Ja extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(b=>b.trim());let f=t;try{for(let b=0;b<c.length;b++){const _=c[b],R=b===c.length-1;if(!_)return null;if(R&&i)return Array.from(f.querySelectorAll(_));const S=f.querySelector(_);if(!S)return null;if(R)return S;if(S.shadowRoot)f=S.shadowRoot;else return null}}catch(b){return console.error("Shadow DOM Selector error:",b),null}return null}}class Xa extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=t.evaluate(a,t,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const f=[];for(let b=0;b<c.snapshotLength;b++){const _=c.snapshotItem(b);_&&_.nodeType===Node.ELEMENT_NODE&&f.push(_)}return Promise.resolve(f.length>0?f:null)}else{const f=c.singleNodeValue;return f&&f.nodeType===Node.ELEMENT_NODE?f:null}}catch(c){return console.error("XPath error:",c),null}}}class Qa{static generate(e){const t=["data-testid","aria-label","title","alt","role"];for(const i of t){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${c})`}if(s){const i=this.generateParentSelector(s);if(i)return`${i} > ${a}:nth-child(${Array.from(s.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const t=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${t}:nth-child(${c})`}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(a=>a.test(e))}}async function mt(r,e=document){const{selector:t,findBy:a="cssSelector",option:s}=r,{waitForSelector:i=!1,waitSelectorTimeout:c=5e3}=s||{},f=es(t,a);return i?f.waitForElement(r,e,c):f.find(r,e)}function es(r,e){return e==="xpath"?new Xa:r.includes(">>")?new Ja:r.includes("|>")?new Ka:new Ya}const Zr=pt.extend({name:D.literal("get-text"),includeTags:D.boolean().optional(),useTextContent:D.boolean().optional(),regex:D.string().optional(),prefixText:D.string().optional(),suffixText:D.string().optional(),filterEmpty:D.boolean().optional(),scrollToCollect:D.boolean().optional(),scrollDistance:D.number().optional(),scrollWaitMs:D.number().optional(),maxScrollAttempts:D.number().optional()});function ts(r){return Zr.parse(r)}async function rs(r){try{const{selector:e="",includeTags:t=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:b,filterEmpty:_=!0,scrollToCollect:R=!1,scrollDistance:S=500,scrollWaitMs:k=300,maxScrollAttempts:E=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(R&&(b!=null&&b.multiple))return await ns({selector:e,findBy:f,option:b,includeTags:t,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:_,scrollDistance:S,scrollWaitMs:k,maxScrollAttempts:E});const I=await mt({selector:e,findBy:f,option:b});if(!I)return{data:""};const se=Sn(t,a,s,i,c);if(Array.isArray(I)){const me=I.map(se);return{data:_?me.filter(H=>H.trim()!==""):me}}else return{data:se(I)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function ns(r){const{selector:e,findBy:t,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:b,filterEmpty:_,scrollDistance:R,scrollWaitMs:S,maxScrollAttempts:k}=r,E=Sn(s,i,c,f,b),I=new Set;let se=0,me=0;const ge=5;for(;se<k;){const H=await mt({selector:e,findBy:t,option:a});if(H&&Array.isArray(H)){const L=I.size;if(H.forEach(U=>{const z=E(U);(!_||z.trim()!=="")&&I.add(z)}),I.size===L){if(me++,me>=ge)break}else me=0}const N=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:R,behavior:"auto"}),await new Promise(L=>setTimeout(L,S)),(window.pageYOffset||document.documentElement.scrollTop)===N)break;se++}return{data:Array.from(I)}}function Sn(r,e,t,a="",s=""){return i=>{let c="";if(r?c=i.innerHTML:c=e?i.textContent||"":i.innerText||"",t){const f=new RegExp(t,"g"),b=c.match(f);c=b?b.join(" "):""}return c.trim()&&(c=a+c.trim()+s),c}}const Wr=pt.extend({name:D.literal("attribute-value"),attributeName:D.string()});function as(r){return Wr.parse(r)}async function ss(r){try{const{selector:e="",attributeName:t,findBy:a="cssSelector",option:s}=r;if(!e)throw new Error("Selector is required for attribute-value block");if(!t)throw new Error("Attribute name is required for attribute-value block");const i=await mt({selector:e,findBy:a,option:s});return i?{data:Array.isArray(i)?i.map(f=>f.getAttribute(t)).filter(f=>f!==null):i.getAttribute(t)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const zr=pt.extend({name:D.literal("get-value-form"),type:D.enum(["text-field","select","checkbox"]).optional()});function is(r){return zr.parse(r)}async function os(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for get-value-form block");const s=await mt({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return{data:cs(s,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function cs(r,e){switch(e){case"text-field":if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)return r.value;break;case"select":if(r instanceof HTMLSelectElement)return r.value;break;case"checkbox":if(r instanceof HTMLInputElement&&r.type==="checkbox")return r.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const Vr=pt.extend({name:D.literal("set-value-form"),setValue:D.string(),type:D.enum(["text-field","select","checkbox"]).optional()});function us(r){return Vr.parse(r)}async function ls(r){try{const{selector:e="",setValue:t,type:a="text-field",findBy:s="cssSelector"}=r;if(!e)throw new Error("Selector is required for set-value-form block");const i=await mt({selector:e,findBy:s,option:r.option});if(!i)throw new Error("Form element not found");return fs(i,t,a),{data:"Form element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-value-form handler",data:null}}}function fs(r,e,t){switch(t){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value=e,r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.value=e,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=e==="true"||e==="checked",r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${t}`)}}const qr=pt.extend({name:D.literal("clear-value-form"),type:D.enum(["text-field","select","checkbox"]).optional()});function ds(r){return qr.parse(r)}async function hs(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for clear-value-form block");const s=await mt({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return ps(s,t),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function ps(r,e){switch(e){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="",r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.selectedIndex=0,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=!1,r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Hr=pt.extend({name:D.literal("element-exists")});function ms(r){return Hr.parse(r)}async function ys(r){try{const{selector:e="",findBy:t="cssSelector",option:a}=r;if(!e)throw new Error("Selector is required for element-exists block");return{data:await mt({selector:e,findBy:t,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Gr=pt.extend({name:D.literal("event-click"),textFilter:D.object({text:D.union([D.string(),D.array(D.string())]),mode:D.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function gs(r){return Gr.parse(r)}async function vs(r){try{const{selector:e="",findBy:t="cssSelector",option:a,textFilter:s}=r;if(!e)throw new Error("Selector is required for event-click block");const i=await mt({selector:e,findBy:t,option:a});if(!i)throw new Error("Element not found for clicking");let c;if(Array.isArray(i))if(s){const f=bs(i,s.text,s.mode);if(!f){const b=Array.isArray(s.text)?s.text.join(", "):s.text;throw new Error(`No element found with text filter: "${b}" (mode: ${s.mode})`)}c=f}else c=i[0];else c=i;return await ks(c),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in event-click handler",data:!1}}}function bs(r,e,t){for(const a of r){const s=ws(a),i=Array.isArray(e)?e:[e];for(const c of i){let f=!1;switch(t){case"exact":f=s===c;break;case"contains":f=s.includes(c);break;case"startsWith":f=s.startsWith(c);break;case"endsWith":f=s.endsWith(c);break;case"regex":try{f=new RegExp(c).test(s)}catch{console.warn("Invalid regex pattern:",c);continue}break}if(f)return a}}return null}function ws(r){if(r.innerText)return r.innerText.trim();if(r.textContent)return r.textContent.trim();if(r instanceof HTMLInputElement&&r.value)return r.value.trim();const e=r.getAttribute("placeholder");if(e)return e.trim();const t=r.getAttribute("title");if(t)return t.trim();const a=r.getAttribute("aria-label");return a?a.trim():""}async function ks(r){r.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(s=>setTimeout(s,50)),r.focus&&r.focus();const e=r.getBoundingClientRect(),t=e.left+e.width/2,a=e.top+e.height/2;try{const s=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:t,y:a}});if(s&&!s.$isError)console.log("[EventClick] CDP click successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP click failed")}catch(s){console.error("[EventClick] CDP click failed, falling back to native click:",s),r.click&&r.click()}await new Promise(s=>setTimeout(s,50))}const Yr=D.object({name:D.literal("keypress"),key:D.string(),code:D.string().optional(),keyCode:D.number().optional(),modifiers:D.array(D.enum(["Alt","Control","Meta","Shift"])).optional()});function xs(r){return Yr.parse(r)}async function _s(r){try{const{key:e,code:t,keyCode:a,modifiers:s=[]}=r;return await Es(e,t,a,s),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in keypress handler",data:!1}}}async function Es(r,e,t,a=[]){try{const s=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:r,code:e||r,keyCode:t||Nr(r),modifiers:a}});if(s&&!s.$isError)console.log("[Keypress] CDP keypress successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP keypress failed")}catch(s){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",s);const i=new KeyboardEvent("keydown",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...fn(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...fn(a)});document.dispatchEvent(i),await new Promise(f=>setTimeout(f,10)),document.dispatchEvent(c)}await new Promise(s=>setTimeout(s,50))}function Nr(r){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[r]||0}function fn(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Kr=D.object({name:D.literal("wait"),duration:D.number().min(0)});function Ts(r){return Kr.parse(r)}async function As(r){try{const{duration:e}=r;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(t=>setTimeout(t,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Jr=D.object({name:D.literal("wait-for-condition"),conditions:D.object({urlPattern:D.string().optional(),elementExists:D.object({selector:D.string(),findBy:D.enum(["cssSelector","xpath"])}).optional(),cookieExists:D.string().optional(),storageKey:D.object({type:D.enum(["localStorage","sessionStorage"]),key:D.string()}).optional(),userConfirmation:D.boolean().optional(),message:D.string().optional(),buttonText:D.string().optional()}).refine(r=>r.urlPattern!==void 0||r.elementExists!==void 0||r.cookieExists!==void 0||r.storageKey!==void 0||r.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:D.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:D.number().min(100).optional(),timeoutMs:D.number().min(1e3).optional(),position:D.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Ss(r){return Jr.parse(r)}async function Cs(r){try{const{conditions:e,mode:t="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:s=3e5,position:i="bottom-right"}=r;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",t,"Timeout:",s);const c=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),f=e.userConfirmation===!0;let b=null,_=null;(t==="manual"||t==="auto-or-manual")&&f&&(b=new Promise(S=>{_=S}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:_}})));const R=async()=>{if(e.urlPattern)try{if(new RegExp(e.urlPattern).test(window.location.href))return{success:!0,reason:"urlPattern",message:`URL matches pattern: ${e.urlPattern}`}}catch(S){console.warn("[WaitForCondition] Invalid URL pattern:",S)}if(e.elementExists){const{selector:S,findBy:k}=e.elementExists;let E=null;if(k==="cssSelector"?E=document.querySelector(S):k==="xpath"&&(E=document.evaluate(S,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),E)return{success:!0,reason:"elementExists",message:`Element found: ${S}`}}if(e.cookieExists&&document.cookie.split(";").some(E=>{const[I]=E.trim().split("=");return I===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:S,key:k}=e.storageKey;if((S==="localStorage"?window.localStorage:window.sessionStorage).getItem(k)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${S}.${k}`}}return null};return new Promise(S=>{let k=null,E=!1;const I=()=>{k&&(clearInterval(k),k=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},se=ge=>{E||(E=!0,I(),console.log("[WaitForCondition] Resolved with:",ge),S({data:ge}))},me=setTimeout(()=>{se({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(t==="auto"||t==="auto-or-manual")&&c&&(k=setInterval(async()=>{const ge=await R();ge&&(clearTimeout(me),se(ge))},a)),(t==="manual"||t==="auto-or-manual")&&b&&b.then(()=>{clearTimeout(me),se({success:!0,reason:"userConfirmation",message:"User confirmed completion"})})})}catch(e){return console.error("[WaitForCondition] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait-for-condition handler",data:{success:!1,message:e instanceof Error?e.message:"Unknown error"}}}}const Xr=D.object({name:D.literal("navigate"),url:D.string().url("Valid URL is required"),waitForLoad:D.boolean().optional(),timeout:D.number().min(0).optional()});function Ds(r){return Xr.parse(r)}async function Os(r){try{const{url:e,waitForLoad:t=!0,timeout:a=3e4}=r;return console.log(`[Navigate] Navigating to: ${e}`),t?new Promise((s,i)=>{const c=setTimeout(()=>{i(new Error(`Navigation timeout after ${a}ms`))},a),f=()=>{clearTimeout(c),window.removeEventListener("load",f),console.log(`[Navigate] Page loaded: ${e}`),s({data:!0})};document.readyState==="complete"?(clearTimeout(c),console.log(`[Navigate] Page already loaded: ${e}`),s({data:!0})):window.addEventListener("load",f),window.location.href=e}):(window.location.href=e,console.log(`[Navigate] Navigation initiated (no wait): ${e}`),{data:!0})}catch(e){return console.error("[Navigate] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in navigate handler",data:!1}}}const Qr=pt.extend({name:D.literal("save-assets")});function Ps(r){return Qr.parse(r)}async function Ns(r){try{const{selector:e="img, audio, video, source",findBy:t="cssSelector",option:a}=r,s=await mt({selector:e,findBy:t,option:a});if(!s||!Array.isArray(s))return{data:[]};const i=[];return s.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!i.includes(f)&&i.push(f)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class Ms{static generate(e){var s;const t=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const c=Array.from(((s=a.parentElement)==null?void 0:s.children)||[]).filter(b=>b.tagName===a.tagName);if(c.length>1){const b=c.indexOf(a)+1;i+=`[${b}]`}const f=this.getStableAttributes(a);f.length>0&&(i+=`[@${f.join(" and @")}]`),t.unshift(i),a=a.parentElement}return"/"+t.join("/")}static getStableAttributes(e){const t=[],a=["data-testid","aria-label","title","alt","role"];for(const s of a){const i=e.getAttribute(s);i&&!this.isDynamicValue(i)&&t.push(`${s}="${i}"`)}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/,/^[a-zA-Z0-9]+_[a-zA-Z0-9]+$/].some(a=>a.test(e))}}const en=pt.extend({name:D.literal("get-element-data"),includeText:D.boolean().optional(),includeTags:D.boolean().optional(),useTextContent:D.boolean().optional(),regex:D.string().optional(),prefixText:D.string().optional(),suffixText:D.string().optional(),attributes:D.array(D.string()).optional(),includeSelector:D.boolean().optional(),includeXPath:D.boolean().optional()});function Rs(r){return en.parse(r)}async function Is(r){try{const{selector:e="",includeText:t=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:b=[],includeSelector:_=!1,includeXPath:R=!1,findBy:S="cssSelector",option:k}=r;if(!e)throw new Error("Selector is required for get-element-data block");if(!t&&b.length===0)throw new Error("Either includeText must be true or attributes must be provided");const E=await mt({selector:e,findBy:S,option:k});if(!E)return{data:Array.isArray(E)?[]:{}};const I=js(t,a,s,i,c,f,b,_,R);return Array.isArray(E)?{data:E.map(I)}:{data:I(E)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function js(r,e,t,a,s="",i="",c=[],f=!1,b=!1){return _=>{const R={};if(r){let S="";if(e?S=_.innerHTML:S=t?_.textContent||"":_.innerText||"",a){const k=new RegExp(a,"g"),E=S.match(k);S=E?E.join(" "):""}S.trim()&&(S=s+S.trim()+i),R.text=S}return c.length>0&&(R.attributes={},c.forEach(S=>{let k=_.getAttribute(S);if(k===null){const E=_.querySelector(`[${S}]`);E&&(k=E.getAttribute(S))}R.attributes[S]=k})),f&&(R.selector=Qa.generate(_)),b&&(R.xpath=Ms.generate(_)),R}}const tn=pt.extend({name:D.literal("scroll"),scrollType:D.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:D.number().optional(),behavior:D.enum(["auto","smooth"]).optional(),maxScrolls:D.number().optional(),waitAfterScroll:D.number().optional()});function Fs(r){return tn.parse(r)}async function $s(r){try{const{selector:e="",scrollType:t="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:b}=r;switch(t){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Bs(e,f,b,s);case"toBottom":return await Us(s,c);case"byDistance":return await Ls(a,s);case"untilLoaded":return await Zs(i,a,s,c);default:throw new Error(`Unknown scroll type: ${t}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Bs(r,e,t,a){const s=await mt({selector:r,findBy:e,option:t});return s?((Array.isArray(s)?s[0]:s).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Us(r,e){let t=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:r}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===t)break;t=i,a++}return{data:!0}}async function Ls(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function Zs(r,e,t,a){let s=0,i=document.body.scrollHeight;for(;s<r;){window.scrollBy({top:e,behavior:t}),await new Promise(_=>setTimeout(_,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,b=window.innerHeight;if(f+b>=c-10&&c===i)break;i=c,s++}return{data:!0}}const rn=D.object({name:D.literal("fetch-api"),url:D.string(),method:D.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:D.record(D.string(),D.string()).optional(),body:D.record(D.string(),D.any()).optional(),timeout:D.number().min(0).optional(),parseJson:D.boolean().optional(),returnHeaders:D.boolean().optional()});function Ws(r){return rn.parse(r)}async function zs(r){try{console.log("[FetchApiBlock] Sending API request to background:",r.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:r.url,method:r.method||"GET",headers:r.headers||{},body:r.body,timeout:r.timeout||3e4,parseJson:r.parseJson??!0,returnHeaders:r.returnHeaders??!1}});return e.$isError?{hasError:!0,message:e.message||"API request failed",data:void 0}:(console.log("[FetchApiBlock] API request successful"),{data:e.data})}catch(e){return console.error("[FetchApiBlock] API request error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in API request",data:void 0}}}var dn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function kr(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Mr={exports:{}},hn;function qs(){return hn||(hn=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function(){function t(a,s,i){function c(_,R){if(!s[_]){if(!a[_]){var S=typeof kr=="function"&&kr;if(!R&&S)return S(_,!0);if(f)return f(_,!0);var k=new Error("Cannot find module '"+_+"'");throw k.code="MODULE_NOT_FOUND",k}var E=s[_]={exports:{}};a[_][0].call(E.exports,function(I){var se=a[_][1][I];return c(se||I)},E,E.exports,t,a,s,i)}return s[_].exports}for(var f=typeof kr=="function"&&kr,b=0;b<i.length;b++)c(i[b]);return c}return t})()({1:[function(t,a,s){const i=t("./utils"),c=(function(){const f=i.stringToArray,b=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],_=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],R=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function k(v,A){var w=function($,j,C){var F="";if($<=19)F=(j?" and ":"")+(C?_[$]:b[$]);else if($<100){const ye=Math.floor($/10),we=$%10;F=(j?" and ":"")+R[ye-2],we>0?F+="-"+w(we,!1,C):C&&(F=F.substring(0,F.length-1)+"ieth")}else if($<1e3){const ye=Math.floor($/100),we=$%100;F=(j?", ":"")+b[ye]+" Hundred",we>0?F+=w(we,!0,C):C&&(F+="th")}else{var J=Math.floor(Math.log10($)/3);J>S.length&&(J=S.length);const ye=Math.pow(10,J*3),we=Math.floor($/ye),K=$-we*ye;F=(j?", ":"")+w(we,!1,!1)+" "+S[J-1],K>0?F+=w(K,!0,C):C&&(F+="th")}return F},P=w(v,!1,A);return P}const E={};b.forEach(function(v,A){E[v.toLowerCase()]=A}),_.forEach(function(v,A){E[v.toLowerCase()]=A}),R.forEach(function(v,A){const w=v.toLowerCase();E[w]=(A+2)*10,E[w.substring(0,v.length-1)+"ieth"]=E[w]}),E.hundredth=100,S.forEach(function(v,A){const w=v.toLowerCase(),P=Math.pow(10,(A+1)*3);E[w]=P,E[w+"th"]=P});function I(v){const w=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>E[j]);let P=[0];return w.forEach(j=>{if(j<100){let C=P.pop();C>=1e3&&(P.push(C),C=0),P.push(C+j)}else P.push(P.pop()*j)}),P.reduce((j,C)=>j+C,0)}const se=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],me={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function ge(v){for(var A=0;A<se.length;A++){const w=se[A];if(v>=w[0])return w[1]+ge(v-w[0])}return""}function H(v){for(var A=0,w=1,P=v.length-1;P>=0;P--){const $=v[P],j=me[$];j<w?A-=j:(w=j,A+=j)}return A}function N(v,A){for(var w=[],P=A.charCodeAt(0);v>0;)w.unshift(String.fromCharCode((v-1)%26+P)),v=Math.floor((v-1)/26);return w.join("")}function ne(v,A){for(var w=A.charCodeAt(0),P=0,$=0;$<v.length;$++)P+=(v.charCodeAt(v.length-$-1)-w+1)*Math.pow(26,$);return P}function L(v,A){if(typeof v>"u")return;v=Math.floor(v);const w=xe(A);return z(v,w)}const T={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},U={UPPER:"upper",LOWER:"lower",TITLE:"title"};function z(v,A){let w;const P=v<0;switch(v=Math.abs(v),A.primary){case T.LETTERS:w=N(v,A.case===U.UPPER?"A":"a");break;case T.ROMAN:w=ge(v),A.case===U.UPPER&&(w=w.toUpperCase());break;case T.WORDS:w=k(v,A.ordinal),A.case===U.UPPER?w=w.toUpperCase():A.case===U.LOWER&&(w=w.toLowerCase());break;case T.DECIMAL:w=""+v;var $=A.mandatoryDigits-w.length;if($>0){var j=new Array($+1).join("0");w=j+w}if(A.zeroCode!==48&&(w=f(w).map(ye=>String.fromCodePoint(ye.codePointAt(0)+A.zeroCode-48)).join("")),A.regular){const ye=Math.floor((w.length-1)/A.groupingSeparators.position);for(let we=ye;we>0;we--){const K=w.length-we*A.groupingSeparators.position;w=w.substr(0,K)+A.groupingSeparators.character+w.substr(K)}}else A.groupingSeparators.reverse().forEach(ye=>{const we=w.length-ye.position;w=w.substr(0,we)+ye.character+w.substr(we)});if(A.ordinal){var C={1:"st",2:"nd",3:"rd"},F=w[w.length-1],J=C[F];(!J||w.length>1&&w[w.length-2]==="1")&&(J="th"),w=w+J}break;case T.SEQUENCE:throw{code:"D3130",value:A.token}}return P&&(w="-"+w),w}const de=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function xe(v){const A={type:"integer",primary:T.DECIMAL,case:U.LOWER,ordinal:!1};let w,P;const $=v.lastIndexOf(";");switch($===-1?w=v:(w=v.substring(0,$),P=v.substring($+1),P[0]==="o"&&(A.ordinal=!0)),w){case"A":A.case=U.UPPER;case"a":A.primary=T.LETTERS;break;case"I":A.case=U.UPPER;case"i":A.primary=T.ROMAN;break;case"W":A.case=U.UPPER,A.primary=T.WORDS;break;case"Ww":A.case=U.TITLE,A.primary=T.WORDS;break;case"w":A.primary=T.WORDS;break;default:{let j=null,C=0,F=0,J=[],ye=0;if(f(w).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let Q=!1;for(let he=0;he<de.length;he++){const G=de[he];if(K>=G&&K<=G+9){if(Q=!0,C++,ye++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}Q||(K===35?(ye++,F++):J.push({position:ye,character:String.fromCodePoint(K)}))}),C>0){A.primary=T.DECIMAL,A.zeroCode=j,A.mandatoryDigits=C,A.optionalDigits=F;const Q=function(he){if(he.length===0)return 0;const G=he[0].character;for(let Ue=1;Ue<he.length;Ue++)if(he[Ue].character!==G)return 0;const Ze=he.map(Ue=>Ue.position),it=function(Ue,He){return He===0?Ue:it(He,Ue%He)},qe=Ze.reduce(it);for(let Ue=1;Ue<=Ze.length;Ue++)if(Ze.indexOf(Ue*qe)===-1)return 0;return qe}(J);Q>0?(A.regular=!0,A.groupingSeparators={position:Q,character:J[0].character}):(A.regular=!1,A.groupingSeparators=J)}else A.primary=T.SEQUENCE,A.token=w}}return A}const Te={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function Ae(v){var A=[];const w={type:"datetime",parts:A},P=function(Q,he){if(he>Q){let G=v.substring(Q,he);G=G.split("]]").join("]"),A.push({type:"literal",value:G})}};for(var $=0,j=0;j<v.length;){if(v.charAt(j)==="["){if(v.charAt(j+1)==="["){P($,j),A.push({type:"literal",value:"["}),j+=2,$=j;continue}if(P($,j),$=j,j=v.indexOf("]",$),j===-1)throw{code:"D3135"};let Q=v.substring($+1,j);Q=Q.split(/\s+/).join("");var C={type:"marker",component:Q.charAt(0)},F=Q.lastIndexOf(","),J;if(F!==-1){const he=Q.substring(F+1),G=he.indexOf("-");let Ze,it;const qe=function(He){if(!(typeof He>"u"||He==="*"))return parseInt(He)};G===-1?Ze=he:(Ze=he.substring(0,G),it=he.substring(G+1));const Ue={min:qe(Ze),max:qe(it)};C.width=Ue,J=Q.substring(1,F)}else J=Q.substring(1);if(J.length===1)C.presentation1=J;else if(J.length>1){var ye=J.charAt(J.length-1);"atco".indexOf(ye)!==-1?(C.presentation2=ye,ye==="o"&&(C.ordinal=!0),C.presentation1=J.substring(0,J.length-1)):C.presentation1=J}else C.presentation1=Te[C.component];if(typeof C.presentation1>"u")throw{code:"D3132",value:C.component};if(C.presentation1[0]==="n")C.names=U.LOWER;else if(C.presentation1[0]==="N")C.presentation1[1]==="n"?C.names=U.TITLE:C.names=U.UPPER;else if("YMDdFWwXxHhmsf".indexOf(C.component)!==-1){var we=C.presentation1;if(C.presentation2&&(we+=";"+C.presentation2),C.integerFormat=xe(we),C.width&&C.width.min!==void 0&&C.integerFormat.mandatoryDigits<C.width.min&&(C.integerFormat.mandatoryDigits=C.width.min),C.component==="Y")if(C.n=-1,C.width&&C.width.max!==void 0)C.n=C.width.max,C.integerFormat.mandatoryDigits=C.n;else{var K=C.integerFormat.mandatoryDigits+C.integerFormat.optionalDigits;K>=2&&(C.n=K)}const he=A[A.length-1];he&&he.integerFormat&&(he.integerFormat.parseWidth=he.integerFormat.mandatoryDigits)}(C.component==="Z"||C.component==="z")&&(C.integerFormat=xe(C.presentation1)),A.push(C),$=j+1}j++}return P($,j),w}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Me=["January","February","March","April","May","June","July","August","September","October","November","December"],et=1e3*60*60*24,_e=function(v){const A=Date.UTC(v.year,v.month);var w=new Date(A).getUTCDay();return w===0&&(w=7),w>4?A+(8-w)*et:A-(w-1)*et},ue=function(v,A){return{year:v,month:A,nextMonth:function(){return A===11?ue(v+1,0):ue(v,A+1)},previousMonth:function(){return A===0?ue(v-1,11):ue(v,A-1)},nextYear:function(){return ue(v+1,A)},previousYear:function(){return ue(v-1,A)}}},tt=function(v,A){return(A-v)/(et*7)+1},ae=(v,A)=>{let w;switch(A){case"Y":w=v.getUTCFullYear();break;case"M":w=v.getUTCMonth()+1;break;case"D":w=v.getUTCDate();break;case"d":{const P=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),$=Date.UTC(v.getUTCFullYear(),0);w=(P-$)/et+1;break}case"F":w=v.getUTCDay(),w===0&&(w=7);break;case"W":{const P=ue(v.getUTCFullYear(),0),$=_e(P),j=Date.UTC(P.year,v.getUTCMonth(),v.getUTCDate());let C=tt($,j);if(C>52){const F=_e(P.nextYear());j>=F&&(C=1)}else if(C<1){const F=_e(P.previousYear());C=tt(F,j)}w=Math.floor(C);break}case"w":{const P=ue(v.getUTCFullYear(),v.getUTCMonth()),$=_e(P),j=Date.UTC(P.year,P.month,v.getUTCDate());let C=tt($,j);if(C>4){const F=_e(P.nextMonth());j>=F&&(C=1)}else if(C<1){const F=_e(P.previousMonth());C=tt(F,j)}w=Math.floor(C);break}case"X":{const P=ue(v.getUTCFullYear(),0),$=_e(P),j=_e(P.nextYear()),C=v.getTime();C<$?w=P.year-1:C>=j?w=P.year+1:w=P.year;break}case"x":{const P=ue(v.getUTCFullYear(),v.getUTCMonth()),$=_e(P),j=P.nextMonth(),C=_e(j),F=v.getTime();F<$?w=P.previousMonth().month+1:F>=C?w=j.month+1:w=P.month+1;break}case"H":w=v.getUTCHours();break;case"h":w=v.getUTCHours(),w=w%12,w===0&&(w=12);break;case"P":w=v.getUTCHours()>=12?"pm":"am";break;case"m":w=v.getUTCMinutes();break;case"s":w=v.getUTCSeconds();break;case"f":w=v.getUTCMilliseconds();break;case"Z":case"z":break;case"C":w="ISO";break;case"E":w="ISO";break}return w};let Fe=null;function st(v,A,w){var P=0,$=0;if(typeof w<"u"){const we=parseInt(w);P=Math.floor(we/100),$=we%100}var j=function(we,K){var Q=ae(we,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(Q=Q%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")Q=Me[Q-1];else if(K.component==="F")Q=ve[Q];else throw{code:"D3133",value:K.component};K.names===U.UPPER?Q=Q.toUpperCase():K.names===U.LOWER&&(Q=Q.toLowerCase()),K.width&&Q.length>K.width.max&&(Q=Q.substring(0,K.width.max))}else Q=z(Q,K.integerFormat);else if(K.component==="f")Q=z(Q,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const he=P*100+$;if(K.integerFormat.regular)Q=z(he,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)Q=z(P,K.integerFormat),$!==0&&(Q+=":"+L($,"00"));else if(G===3||G===4)Q=z(he,K.integerFormat);else throw{code:"D3134",value:G}}he>=0&&(Q="+"+Q),K.component==="z"&&(Q="GMT"+Q),he===0&&K.presentation2==="t"&&(Q="Z")}else K.component==="P"&&K.names===U.UPPER&&(Q=Q.toUpperCase());return Q};let C;typeof A>"u"?(Fe===null&&(Fe=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),C=Fe):C=Ae(A);const F=(60*P+$)*60*1e3,J=new Date(v+F);let ye="";return C.parts.forEach(function(we){we.type==="literal"?ye+=we.value:ye+=j(J,we)}),ye}function d(v){var A={};if(v.type==="datetime")A.type="datetime",A.parts=v.parts.map(function(w){var P={};if(w.type==="literal")P.regex=w.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(w.component==="Z"||w.component==="z"){let j;Array.isArray(w.integerFormat.groupingSeparators)||(j=w.integerFormat.groupingSeparators),P.regex="",w.component==="z"&&(P.regex="GMT"),P.regex+="[-+][0-9]+",j&&(P.regex+=j.character+"[0-9]+"),P.parse=function(C){w.component==="z"&&(C=C.substring(3));let F=0,J=0;return j?(F=Number.parseInt(C.substring(0,C.indexOf(j.character))),J=Number.parseInt(C.substring(C.indexOf(j.character)+1))):C.length-1<=2?F=Number.parseInt(C):(F=Number.parseInt(C.substring(0,3)),J=Number.parseInt(C.substring(3))),F*60+J}}else if(w.integerFormat)P=d(w.integerFormat);else{P.regex="[a-zA-Z]+";var $={};if(w.component==="M"||w.component==="x")Me.forEach(function(j,C){w.width&&w.width.max?$[j.substring(0,w.width.max)]=C+1:$[j]=C+1});else if(w.component==="F")ve.forEach(function(j,C){C>0&&(w.width&&w.width.max?$[j.substring(0,w.width.max)]=C:$[j]=C)});else if(w.component==="P")$={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:w.component};P.parse=function(j){return $[j]}}return P.component=w.component,P});else{A.type="integer";const w=v.case===U.UPPER;switch(v.primary){case T.LETTERS:A.regex=w?"[A-Z]+":"[a-z]+",A.parse=function(P){return ne(P,w?"A":"a")};break;case T.ROMAN:A.regex=w?"[MDCLXVI]+":"[mdclxvi]+",A.parse=function(P){return H(w?P:P.toUpperCase())};break;case T.WORDS:A.regex="(?:"+Object.keys(E).concat("and","[\\-, ]").join("|")+")+",A.parse=function(P){return I(P.toLowerCase())};break;case T.DECIMAL:A.regex="[0-9]",v.parseWidth?A.regex+=`{${v.parseWidth}}`:A.regex+="+",v.ordinal&&(A.regex+="(?:th|st|nd|rd)"),A.parse=function(P){let $=P;return v.ordinal&&($=P.substring(0,P.length-2)),v.regular?$=$.split(",").join(""):v.groupingSeparators.forEach(j=>{$=$.split(j.character).join("")}),v.zeroCode!==48&&($=$.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-v.zeroCode+48)).join("")),parseInt($)};break;case T.SEQUENCE:throw{code:"D3130",value:v.token}}}return A}function m(v,A){if(typeof v>"u")return;const w=xe(A);return d(w).parse(v)}function V(v,A){const w=Ae(A),P=d(w),$="^"+P.parts.map(J=>"("+J.regex+")").join("")+"$";var C=new RegExp($,"i").exec(v);if(C!==null){const G={};for(let Ce=1;Ce<C.length;Ce++){const u=P.parts[Ce-1];u.parse&&(G[u.component]=u.parse(C[Ce]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ze=0;const it=Ce=>{Ze<<=1,Ze+=Ce?1:0},qe=Ce=>!(~Ce&Ze)&&!!(Ce&Ze);"YXMxWwdD".split("").forEach(Ce=>it(G[Ce]));const He=!qe(161)&&qe(130),wt=qe(84),Tt=!wt&&qe(72);Ze=0,"PHhmsf".split("").forEach(Ce=>it(G[Ce]));const At=!qe(23)&&qe(47),Jt=(He?"YD":wt?"XxwF":Tt?"XWF":"YMD")+(At?"Phmsf":"Hmsf"),ut=this.environment.timestamp;let Ut=!1,yt=!1;if(Jt.split("").forEach(Ce=>{if(typeof G[Ce]>"u")Ut?(G[Ce]="MDd".indexOf(Ce)!==-1?1:0,yt=!0):G[Ce]=ae(ut,Ce);else if(Ut=!0,yt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,He){const Ce=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(Ce+u);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(wt)throw{code:"D3136"};if(Tt)throw{code:"D3136"};At&&(G.H=G.h===12?0:G.h,G.P===1&&(G.H+=12));var F=Date.UTC(G.Y,G.M,G.D,G.H,G.m,G.s,G.f);return(G.Z||G.z)&&(F-=(G.Z||G.z)*60*1e3),F}}var le=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function Oe(v,A){if(!(typeof v>"u"))if(typeof A>"u"){if(!le.test(v))throw{stack:new Error().stack,code:"D3110",value:v};return Date.parse(v)}else return V.call(this,v,A)}function Ee(v,A,w){if(!(typeof v>"u"))return st.call(this,v,A,w)}return{formatInteger:L,parseInteger:m,fromMillis:Ee,toMillis:Oe}})();a.exports=c},{"./utils":6}],2:[function(t,a,s){(function(i){(function(){var c=t("./utils");const f=(()=>{var b=c.isNumeric,_=c.isArrayOfStrings,R=c.isArrayOfNumbers,S=c.createSequence,k=c.isSequence,E=c.isFunction,I=c.isLambda,se=c.isPromise,me=c.getFunctionArity,ge=c.isDeepEqual,H=c.stringToArray;function N(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function ne(n){return typeof n>"u"?0:n.length}function L(n){if(!(typeof n>"u"||n.length===0))return Math.max.apply(Math,n)}function T(n){if(!(typeof n>"u"||n.length===0))return Math.min.apply(Math,n)}function U(n){if(!(typeof n>"u"||n.length===0)){var o=0;return n.forEach(function(l){o+=l}),o/n.length}}function z(n,o=!1){if(!(typeof n>"u")){var l;if(typeof n=="string")l=n;else if(E(n))l="";else{if(typeof n=="number"&&!isFinite(n))throw{code:"D3001",value:n,stack:new Error().stack};var g=o?2:0;Array.isArray(n)&&n.outerWrapper&&(n=n[0]),l=JSON.stringify(n,function(p,x){return typeof x<"u"&&x!==null&&x.toPrecision&&b(x)?Number(x.toPrecision(15)):x&&E(x)?"":x},g)}return l}}function de(n,o,l){if(!(typeof n>"u")){var g=H(n),p=g.length;if(p+o<0&&(o=0),typeof l<"u"){if(l<=0)return"";var x=o>=0?o+l:p+o+l;return g.slice(o,x).join("")}return g.slice(o).join("")}}function xe(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(0,l):n}}function Te(n,o){if(!(typeof n>"u")){var l=n.indexOf(o);return l>-1?n.substr(l+o.length):n}}function Ae(n){if(!(typeof n>"u"))return n.toLowerCase()}function ve(n){if(!(typeof n>"u"))return n.toUpperCase()}function Me(n){if(!(typeof n>"u"))return H(n).length}function et(n){if(!(typeof n>"u")){var o=n.replace(/[ \t\n\r]+/gm," ");return o.charAt(0)===" "&&(o=o.substring(1)),o.charAt(o.length-1)===" "&&(o=o.substring(0,o.length-1)),o}}function _e(n,o,l){if(!(typeof n>"u")){(typeof l>"u"||l.length===0)&&(l=" ");var g;o=Math.trunc(o);var p=Math.abs(o)-Me(n);if(p>0){var x=new Array(p+1).join(l);l.length>1&&(x=de(x,0,p)),o>0?g=n+x:g=x+n}else g=n;return g}}async function ue(n,o){var l=n.apply(this,[o]);if(se(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||E(l.next)))throw{code:"T1010",stack:new Error().stack};return l}async function tt(n,o){if(!(typeof n>"u")){var l;if(typeof o=="string")l=n.indexOf(o)!==-1;else{var g=await ue(o,n);l=typeof g<"u"}return l}}async function ae(n,o,l){if(!(typeof n>"u")){if(l<0)throw{stack:new Error().stack,value:l,code:"D3040",index:3};var g=S();if(typeof l>"u"||l>0){var p=0,x=await ue(o,n);if(typeof x<"u")for(;typeof x<"u"&&(typeof l>"u"||p<l);)g.push({match:x.match,index:x.start,groups:x.groups}),x=await ue(x.next),p++}return g}}async function Fe(n,o,l,g){if(!(typeof n>"u")){var p=this;if(o==="")throw{code:"D3010",stack:new Error().stack,value:o,index:2};if(g<0)throw{code:"D3011",stack:new Error().stack,value:g,index:4};var x;typeof l=="string"?x=function(Se){for(var We="",ke=0,je=l.indexOf("$",ke);je!==-1&&ke<l.length;){We+=l.substring(ke,je),ke=je+1;var ot=l.charAt(ke);if(ot==="$")We+="$",ke++;else if(ot==="0")We+=Se.match,ke++;else{var ze;if(Se.groups.length===0?ze=1:ze=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,je=parseInt(l.substring(ke,ke+ze),10),ze>1&&je>Se.groups.length&&(je=parseInt(l.substring(ke,ke+ze-1),10)),isNaN(je))We+="$";else{if(Se.groups.length>0){var Lt=Se.groups[je-1];typeof Lt<"u"&&(We+=Lt)}ke+=je.toString().length}}je=l.indexOf("$",ke)}return We+=l.substring(ke),We}:x=l;var M="",q=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var De=n.indexOf(o,q);De!==-1&&(typeof g>"u"||X<g);)M+=n.substring(q,De),M+=l,q=De+o.length,X++,De=n.indexOf(o,q);M+=n.substring(q)}else{var pe=await ue(o,n);if(typeof pe<"u"){for(;typeof pe<"u"&&(typeof g>"u"||X<g);){M+=n.substring(q,pe.start);var Pe=x.apply(p,[pe]);if(se(Pe)&&(Pe=await Pe),typeof Pe=="string")M+=Pe;else throw{code:"D3012",stack:new Error().stack,value:Pe};q=pe.start+pe.match.length,X++,pe=await ue(pe.next)}M+=n.substring(q)}else M=n}}else M=n;return M}}function st(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.btoa:function(l){return new i.Buffer.from(l,"binary").toString("base64")};return o(n)}}function d(n){if(!(typeof n>"u")){var o=typeof window<"u"?window.atob:function(l){return new i.Buffer.from(l,"base64").toString("binary")};return o(n)}}function m(n){if(!(typeof n>"u")){var o;try{o=encodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrlComponent"}}return o}}function V(n){if(!(typeof n>"u")){var o;try{o=encodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"encodeUrl"}}return o}}function le(n){if(!(typeof n>"u")){var o;try{o=decodeURIComponent(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrlComponent"}}return o}}function Oe(n){if(!(typeof n>"u")){var o;try{o=decodeURI(n)}catch{throw{code:"D3140",stack:new Error().stack,value:n,functionName:"decodeUrl"}}return o}}async function Ee(n,o,l){if(!(typeof n>"u")){if(l<0)throw{code:"D3020",stack:new Error().stack,value:l,index:3};var g=[];if(typeof l>"u"||l>0)if(typeof o=="string")g=n.split(o,l);else{var p=0,x=await ue(o,n);if(typeof x<"u"){for(var M=0;typeof x<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(M,x.start)),M=x.end,x=await ue(x.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(M))}else g.push(n)}return g}}function v(n,o){if(!(typeof n>"u"))return typeof o>"u"&&(o=""),n.join(o)}function A(n,o,l){if(!(typeof n>"u")){var g={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},p=g;typeof l<"u"&&Object.keys(l).forEach(function(te){p[te]=l[te]});for(var x=[],M=p["zero-digit"].charCodeAt(0),q=M;q<M+10;q++)x.push(String.fromCharCode(q));var X=x.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),De=o.split(p["pattern-separator"]);if(De.length>2)throw{code:"D3080",stack:new Error().stack};var pe=function(te){var Re=(function(){for(var Le,nt=0;nt<te.length;nt++)if(Le=te.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return te.substring(0,nt)})(),Ye=(function(){for(var Le,nt=te.length-1;nt>=0;nt--)if(Le=te.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return te.substring(nt+1)})(),Ne=te.substring(Re.length,te.length-Ye.length),Xe,St,Qe,Rt,rt=te.indexOf(p["exponent-separator"],Re.length);rt===-1||rt>te.length-Ye.length?(Xe=Ne,St=void 0):(Xe=Ne.substring(0,rt),St=Ne.substring(rt+1));var lt=Xe.indexOf(p["decimal-separator"]);return lt===-1?(Qe=Xe,Rt=Ye):(Qe=Xe.substring(0,lt),Rt=Xe.substring(lt+1)),{prefix:Re,suffix:Ye,activePart:Ne,mantissaPart:Xe,exponentPart:St,integerPart:Qe,fractionalPart:Rt,subpicture:te}},Pe=function(te){var Re,Ye,Ne=te.subpicture,Xe=Ne.indexOf(p["decimal-separator"]);Xe!==Ne.lastIndexOf(p["decimal-separator"])&&(Re="D3081"),Ne.indexOf(p.percent)!==Ne.lastIndexOf(p.percent)&&(Re="D3082"),Ne.indexOf(p["per-mille"])!==Ne.lastIndexOf(p["per-mille"])&&(Re="D3083"),Ne.indexOf(p.percent)!==-1&&Ne.indexOf(p["per-mille"])!==-1&&(Re="D3084");var St=!1;for(Ye=0;Ye<te.mantissaPart.length;Ye++){var Qe=te.mantissaPart.charAt(Ye);if(x.indexOf(Qe)!==-1||Qe===p.digit){St=!0;break}}St||(Re="D3085");var Rt=te.activePart.split("").map(function(Le){return X.indexOf(Le)===-1?"p":"a"}).join("");Rt.indexOf("p")!==-1&&(Re="D3086"),Xe!==-1?(Ne.charAt(Xe-1)===p["grouping-separator"]||Ne.charAt(Xe+1)===p["grouping-separator"])&&(Re="D3087"):te.integerPart.charAt(te.integerPart.length-1)===p["grouping-separator"]&&(Re="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Re="D3089");var rt=te.integerPart.indexOf(p.digit);rt!==-1&&te.integerPart.substring(0,rt).split("").filter(function(Le){return x.indexOf(Le)>-1}).length>0&&(Re="D3090"),rt=te.fractionalPart.lastIndexOf(p.digit),rt!==-1&&te.fractionalPart.substring(rt).split("").filter(function(Le){return x.indexOf(Le)>-1}).length>0&&(Re="D3091");var lt=typeof te.exponentPart=="string";if(lt&&te.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Re="D3092"),lt&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function(Le){return x.indexOf(Le)===-1}).length>0)&&(Re="D3093"),Re)throw{code:Re,stack:new Error().stack}},Se=function(te){var Re=function(Ve,br){for(var er=[],kt=Ve.indexOf(p["grouping-separator"]);kt!==-1;){var wr=(br?Ve.substring(0,kt):Ve.substring(kt)).split("").filter(function(Wt){return x.indexOf(Wt)!==-1||Wt===p.digit}).length;er.push(wr),kt=te.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Re(te.integerPart),Ne=function(Ve){if(Ve.length===0)return 0;for(var br=function(wr,Wt){return Wt===0?wr:br(Wt,wr%Wt)},er=Ve.reduce(br),kt=1;kt<=Ve.length;kt++)if(Ve.indexOf(kt*er)===-1)return 0;return er},Xe=Ne(Ye),St=Re(te.fractionalPart,!0),Qe=te.integerPart.split("").filter(function(Ve){return x.indexOf(Ve)!==-1}).length,Rt=Qe,rt=te.fractionalPart.split(""),lt=rt.filter(function(Ve){return x.indexOf(Ve)!==-1}).length,Le=rt.filter(function(Ve){return x.indexOf(Ve)!==-1||Ve===p.digit}).length,nt=typeof te.exponentPart=="string";Qe===0&&Le===0&&(nt?(lt=1,Le=1):Qe=1),nt&&Qe===0&&te.integerPart.indexOf(p.digit)!==-1&&(Qe=1),Qe===0&&lt===0&&(lt=1);var on=0;return nt&&(on=te.exponentPart.split("").filter(function(Ve){return x.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:Rt,prefix:te.prefix,fractionalPartGroupingPositions:St,minimumFactionalPartSize:lt,maximumFactionalPartSize:Le,minimumExponentSize:on,suffix:te.suffix,picture:te.subpicture}},We=De.map(pe);We.forEach(Pe);var ke=We.map(Se),je=p["minus-sign"],ot=p["zero-digit"],ze=p["decimal-separator"],Lt=p["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=je+ke[1].prefix);var $e;n>=0?$e=ke[0]:$e=ke[1];var Xt;$e.picture.indexOf(p.percent)!==-1?Xt=n*100:$e.picture.indexOf(p["per-mille"])!==-1?Xt=n*1e3:Xt=n;var Mt,Zt;if($e.minimumExponentSize===0)Mt=Xt;else{var Cn=Math.pow(10,$e.scalingFactor),Dn=Math.pow(10,$e.scalingFactor-1);for(Mt=Xt,Zt=0;Mt<Dn;)Mt*=10,Zt-=1;for(;Mt>Cn;)Mt/=10,Zt+=1}var On=F(Mt,$e.maximumFactionalPartSize),an=function(te,Re){var Ye=Math.abs(te).toFixed(Re);return ot!=="0"&&(Ye=Ye.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?x[Ne.charCodeAt(0)-48]:Ne}).join("")),Ye},oe=an(On,$e.maximumFactionalPartSize),Ge=oe.indexOf(".");for(Ge===-1?oe=oe+ze:oe=oe.replace(".",ze);oe.charAt(0)===ot;)oe=oe.substring(1);for(;oe.charAt(oe.length-1)===ot;)oe=oe.substring(0,oe.length-1);Ge=oe.indexOf(ze);var Qt=$e.minimumIntegerPartSize-Ge,sn=$e.minimumFactionalPartSize-(oe.length-Ge-1);if(oe=(Qt>0?new Array(Qt+1).join(ot):"")+oe,oe=oe+(sn>0?new Array(sn+1).join(ot):""),Ge=oe.indexOf(ze),$e.regularGrouping>0)for(var Pn=Math.floor((Ge-1)/$e.regularGrouping),gr=1;gr<=Pn;gr++)oe=[oe.slice(0,Ge-gr*$e.regularGrouping),Lt,oe.slice(Ge-gr*$e.regularGrouping)].join("");else $e.integerPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,Ge-te),Lt,oe.slice(Ge-te)].join(""),Ge++});if(Ge=oe.indexOf(ze),$e.fractionalPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,te+Ge+1),Lt,oe.slice(te+Ge+1)].join("")}),Ge=oe.indexOf(ze),($e.picture.indexOf(ze)===-1||Ge===oe.length-1)&&(oe=oe.substring(0,oe.length-1)),typeof Zt<"u"){var vr=an(Zt,0);Qt=$e.minimumExponentSize-vr.length,Qt>0&&(vr=new Array(Qt+1).join(ot)+vr),oe=oe+p["exponent-separator"]+(Zt<0?je:"")+vr}return oe=$e.prefix+oe+$e.suffix,oe}}function w(n,o){if(!(typeof n>"u")){if(n=F(n),typeof o>"u"?o=10:o=F(o),o<2||o>36)throw{code:"D3100",stack:new Error().stack,value:o};var l=n.toString(o);return l}}function P(n){var o;if(!(typeof n>"u")){if(typeof n=="number")o=n;else if(typeof n=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(n)&&!isNaN(parseFloat(n))&&isFinite(n))o=parseFloat(n);else if(typeof n=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(n))o=Number(n);else if(n===!0)o=1;else if(n===!1)o=0;else throw{code:"D3030",value:n,stack:new Error().stack,index:1};return o}}function $(n){var o;if(!(typeof n>"u"))return o=Math.abs(n),o}function j(n){var o;if(!(typeof n>"u"))return o=Math.floor(n),o}function C(n){var o;if(!(typeof n>"u"))return o=Math.ceil(n),o}function F(n,o){var l;if(!(typeof n>"u")){if(o){var g=n.toString().split("e");n=+(g[0]+"e"+(g[1]?+g[1]+o:o))}l=Math.round(n);var p=l-n;return Math.abs(p)===.5&&Math.abs(l%2)===1&&(l=l-1),o&&(g=l.toString().split("e"),l=+(g[0]+"e"+(g[1]?+g[1]-o:-o))),Object.is(l,-0)&&(l=0),l}}function J(n){var o;if(!(typeof n>"u")){if(n<0)throw{stack:new Error().stack,code:"D3060",index:1,value:n};return o=Math.sqrt(n),o}}function ye(n,o){var l;if(!(typeof n>"u")){if(l=Math.pow(n,o),!isFinite(l))throw{stack:new Error().stack,code:"D3061",index:1,value:n,exp:o};return l}}function we(){return Math.random()}function K(n){if(!(typeof n>"u")){var o=!1;if(Array.isArray(n)){if(n.length===1)o=K(n[0]);else if(n.length>1){var l=n.filter(function(g){return K(g)});o=l.length>0}}else typeof n=="string"?n.length>0&&(o=!0):b(n)?n!==0&&(o=!0):n!==null&&typeof n=="object"&&!E(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function Q(n){if(!(typeof n>"u"))return!K(n)}function he(n,o,l,g){var p=[o],x=me(n);return x>=2&&p.push(l),x>=3&&p.push(g),p}async function G(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=he(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}}async function Ze(n,o){if(!(typeof n>"u")){for(var l=S(),g=0;g<n.length;g++){var p=n[g],x=he(o,p,g,n),M=await o.apply(this,x);K(M)&&l.push(p)}return l}}async function it(n,o){if(!(typeof n>"u")){for(var l=!1,g,p=0;p<n.length;p++){var x=n[p],M=!0;if(typeof o<"u"){var q=he(o,x,p,n),X=await o.apply(this,q);M=K(X)}if(M)if(!l)g=x,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function qe(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(x){return Array.isArray(x)?x.length:0})),g=0;g<l;g++){var p=o.map(x=>x[g]);n.push(p)}return n}async function Ue(n,o,l){if(!(typeof n>"u")){var g,p=me(o);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var x;for(typeof l>"u"&&n.length>0?(g=n[0],x=1):(g=l,x=0);x<n.length;){var M=[g,n[x]];p>=3&&M.push(x),p>=4&&M.push(n),g=await o.apply(this,M),x++}return g}}function He(n){var o=S();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=He(g);p.forEach(function(x){l[x]=!0})}),o=He(l)}else n!==null&&typeof n=="object"&&!E(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function wt(n,o){var l;if(Array.isArray(n)){l=S();for(var g=0;g<n.length;g++){var p=wt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(x=>l.push(x)):l.push(p))}}else n!==null&&typeof n=="object"&&!E(n)&&(l=n[o]);return l}function Tt(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=S(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function mr(n){return!(typeof n>"u")}function At(n){var o=S();if(Array.isArray(n))n.forEach(function(p){o=Tt(o,At(p))});else if(n!==null&&typeof n=="object"&&!I(n))for(var l in n){var g={};g[l]=n[l],o.push(g)}else o=n;return o}function Z(n){if(!(typeof n>"u")){var o={};return n.forEach(function(l){for(var g in l)o[g]=l[g]}),o}}function yr(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=n.length,l=new Array(o),g=0;g<o;g++)l[o-g-1]=n[g];return l}}async function Jt(n,o){var l=S();for(var g in n){var p=he(o,n[g],g,n),x=await o.apply(this,p);typeof x<"u"&&l.push(x)}return l}function ut(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function Ut(n,o){if(!n)throw{code:"D3141",stack:new Error().stack,message:o||"$assert() statement failed"}}function yt(n){if(n!==void 0)return n===null?"null":b(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":E(n)?"function":"object"}async function Ce(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!R(n)&&!_(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(M,q){return M>q}}else l=o;var g=async function(M,q){var X=async function(pe,Pe,Se){Pe.length===0?Array.prototype.push.apply(pe,Se):Se.length===0?Array.prototype.push.apply(pe,Pe):await l(Pe[0],Se[0])?(pe.push(Se[0]),await X(pe,Pe,Se.slice(1))):(pe.push(Pe[0]),await X(pe,Pe.slice(1),Se))},De=[];return await X(De,M,q),De},p=async function(M){if(!Array.isArray(M)||M.length<=1)return M;var q=Math.floor(M.length/2),X=M.slice(0,q),De=M.slice(q);return X=await p(X),De=await p(De),await g(X,De)},x=await p(n);return x}}function u(n){if(!(typeof n>"u")){if(n.length<=1)return n;for(var o=new Array(n.length),l=0;l<n.length;l++){var g=Math.floor(Math.random()*(l+1));l!==g&&(o[l]=o[g]),o[g]=n[l]}return o}}function h(n){if(!(typeof n>"u")){if(!Array.isArray(n)||n.length<=1)return n;for(var o=k(n)?S():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,x=0;x<o.length;x++)if(ge(g,o[x])){p=!0;break}p||o.push(g)}return o}}async function y(n,o){var l={};for(var g in n){var p=n[g],x=he(o,p,g,n),M=await o.apply(this,x);K(M)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:N,count:ne,max:L,min:T,average:U,string:z,substring:de,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Me,trim:et,pad:_e,match:ae,contains:tt,replace:Fe,split:Ee,join:v,formatNumber:A,formatBase:w,number:P,floor:j,ceil:C,round:F,abs:$,sqrt:J,power:ye,random:we,boolean:K,not:Q,map:G,zip:qe,filter:Ze,single:it,foldLeft:Ue,sift:y,keys:He,lookup:wt,append:Tt,exists:mr,spread:At,merge:Z,reverse:yr,each:Jt,error:ut,assert:Ut,type:yt,sort:Ce,shuffle:u,distinct:h,base64encode:st,base64decode:d,encodeUrlComponent:m,encodeUrl:V,decodeUrlComponent:le,decodeUrl:Oe}})();a.exports=f}).call(this)}).call(this,typeof dn<"u"?dn:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(t,a,s){var i=t("./datetime"),c=t("./functions"),f=t("./utils"),b=t("./parser"),_=t("./signature"),R=(function(){var S=f.isNumeric,k=f.isArrayOfStrings,E=f.isArrayOfNumbers,I=f.createSequence,se=f.isSequence,me=f.isFunction,ge=f.isLambda,H=f.isIterable,N=f.isPromise,ne=f.getFunctionArity,L=f.isDeepEqual,T=ut(null);async function U(u,h,y){var n,o=y.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(o&&await o(u,h,y),u.type){case"path":n=await z(u,h,y);break;case"binary":n=await Me(u,h,y);break;case"unary":n=await et(u,h,y);break;case"name":n=_e(u,h);break;case"string":case"number":case"value":n=ue(u);break;case"wildcard":n=tt(u,h);break;case"descendant":n=Fe(u,h);break;case"parent":n=y.lookup(u.slot.label);break;case"condition":n=await j(u,h,y);break;case"block":n=await C(u,h,y);break;case"bind":n=await $(u,h,y);break;case"regex":n=F(u);break;case"function":n=await he(u,h,y);break;case"variable":n=J(u,h,y);break;case"lambda":n=it(u,h,y);break;case"partial":n=await qe(u,h,y);break;case"apply":n=await Q(u,h,y);break;case"transform":n=we(u,h,y);break}if(Object.prototype.hasOwnProperty.call(u,"predicate"))for(var l=0;l<u.predicate.length;l++)n=await ve(u.predicate[l].expr,n,y);u.type!=="path"&&Object.prototype.hasOwnProperty.call(u,"group")&&(n=await A(u.group,n,y));var g=y.lookup(Symbol.for("jsonata.__evaluate_exit"));return g&&await g(u,h,y,n),n&&se(n)&&!n.tupleStream&&(u.keepArray&&(n.keepSingleton=!0),n.length===0?n=void 0:n.length===1&&(n=n.keepSingleton?n:n[0])),n}async function z(u,h,y){var n;Array.isArray(h)&&u.steps[0].type!=="variable"?n=h:n=I(h);for(var o,l=!1,g=void 0,p=0;p<u.steps.length;p++){var x=u.steps[p];if(x.tuple&&(l=!0),p===0&&x.consarray?o=await U(x,n,y):l?g=await Ae(x,n,g,y):o=await xe(x,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof x.focus>"u"&&(n=o)}if(l)if(u.tuple)o=g;else for(o=I(),p=0;p<g.length;p++)o.push(g[p]["@"]);return u.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=I(o)),o.keepSingleton=!0),u.hasOwnProperty("group")&&(o=await A(u.group,l?g:o,y)),o}function de(u,h){var y=ut(u);for(const n in h)y.bind(n,h[n]);return y}async function xe(u,h,y,n){var o;if(u.type==="sort")return o=await ye(u,h,y),u.stages&&(o=await Te(u.stages,o,y)),o;o=I();for(var l=0;l<h.length;l++){var g=await U(u,h[l],y);if(u.stages)for(var p=0;p<u.stages.length;p++)g=await ve(u.stages[p].expr,g,y);typeof g<"u"&&o.push(g)}var x=I();return n&&o.length===1&&Array.isArray(o[0])&&!se(o[0])?x=o[0]:o.forEach(function(M){!Array.isArray(M)||M.cons?x.push(M):M.forEach(q=>x.push(q))}),x}async function Te(u,h,y){for(var n=h,o=0;o<u.length;o++){var l=u[o];switch(l.type){case"filter":n=await ve(l.expr,n,y);break;case"index":for(var g=0;g<n.length;g++){var p=n[g];p[l.value]=g}break}}return n}async function Ae(u,h,y,n){var o;if(u.type==="sort"){if(y)o=await ye(u,y,n);else{var l=await ye(u,h,n);o=I(),o.tupleStream=!0;for(var g=0;g<l.length;g++){var p={"@":l[g]};p[u.index]=g,o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}o=I(),o.tupleStream=!0;var x=n;y===void 0&&(y=h.map(De=>({"@":De})));for(var M=0;M<y.length;M++){x=de(n,y[M]);var q=await U(u,y[M]["@"],x);if(typeof q<"u"){Array.isArray(q)||(q=[q]);for(var X=0;X<q.length;X++)p={},Object.assign(p,y[M]),q.tupleStream?Object.assign(p,q[X]):(u.focus?(p[u.focus]=q[X],p["@"]=y[M]["@"]):p["@"]=q[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[M]["@"])),o.push(p)}}return u.stages&&(o=await Te(u.stages,o,n)),o}async function ve(u,h,y){var n=I();if(h&&h.tupleStream&&(n.tupleStream=!0),Array.isArray(h)||(h=I(h)),u.type==="number"){var o=Math.floor(u.value);o<0&&(o=h.length+o);var l=await h[o];typeof l<"u"&&(Array.isArray(l)?n=l:n.push(l))}else for(o=0;o<h.length;o++){var l=h[o],g=l,p=y;h.tupleStream&&(g=l["@"],p=de(y,l));var x=await U(u,g,p);S(x)&&(x=[x]),E(x)?x.forEach(function(q){var X=Math.floor(q);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(x)&&n.push(l)}return n}async function Me(u,h,y){var n,o=await U(u.lhs,h,y),l=u.value,g=async()=>await U(u.rhs,h,y);if(l==="and"||l==="or")try{return await Oe(o,g,l)}catch(x){throw x.position=u.position,x.token=l,x}var p=await g();try{switch(l){case"+":case"-":case"*":case"/":case"%":n=d(o,p,l);break;case"=":case"!=":n=m(o,p,l);break;case"<":case"<=":case">":case">=":n=V(o,p,l);break;case"&":n=v(o,p);break;case"..":n=P(o,p);break;case"in":n=le(o,p);break}}catch(x){throw x.position=u.position,x.token=l,x}return n}async function et(u,h,y){var n;switch(u.value){case"-":if(n=await U(u.expression,h,y),typeof n>"u")n=void 0;else if(S(n))n=-n;else throw{code:"D1002",stack:new Error().stack,position:u.position,token:u.value,value:n};break;case"[":n=[];let g=await Promise.all(u.expressions.map(async(p,x)=>(y.isParallelCall=x>0,[p,await U(p,h,y)])));for(let p of g){var[o,l]=p;typeof l<"u"&&(o.value==="["?n.push(l):n=c.append(n,l))}u.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":n=await A(u,h,y);break}return n}function _e(u,h,y){return c.lookup(h,u.value)}function ue(u){return u.value}function tt(u,h){var y=I();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(n){var o=h[n];Array.isArray(o)?(o=ae(o),y=c.append(y,o)):y.push(o)}),y}function ae(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ae(y,h)}):h.push(u),h}function Fe(u,h){var y,n=I();return typeof h<"u"&&(st(h,n),n.length===1?y=n[0]:y=n),y}function st(u,h){Array.isArray(u)||h.push(u),Array.isArray(u)?u.forEach(function(y){st(y,h)}):u!==null&&typeof u=="object"&&Object.keys(u).forEach(function(y){st(u[y],h)})}function d(u,h,y){var n;if(typeof u<"u"&&!S(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!S(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u")return n;switch(y){case"+":n=u+h;break;case"-":n=u-h;break;case"*":n=u*h;break;case"/":n=u/h;break;case"%":n=u%h;break}return n}function m(u,h,y){var n,o=typeof u,l=typeof h;if(o==="undefined"||l==="undefined")return!1;switch(y){case"=":n=L(u,h);break;case"!=":n=!L(u,h);break}return n}function V(u,h,y){var n,o=typeof u,l=typeof h,g=o==="undefined"||o==="string"||o==="number",p=l==="undefined"||l==="string"||l==="number";if(!g||!p)throw{code:"T2010",stack:new Error().stack,value:o==="string"||o==="number"?h:u};if(!(o==="undefined"||l==="undefined")){if(o!==l)throw{code:"T2009",stack:new Error().stack,value:u,value2:h};switch(y){case"<":n=u<h;break;case"<=":n=u<=h;break;case">":n=u>h;break;case">=":n=u>=h;break}return n}}function le(u,h){var y=!1;if(typeof u>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var n=0;n<h.length;n++)if(h[n]===u){y=!0;break}return y}async function Oe(u,h,y){var n,o=Ee(u);switch(y){case"and":n=o&&Ee(await h());break;case"or":n=o||Ee(await h());break}return n}function Ee(u){var h=c.boolean(u);return typeof h>"u"?!1:h}function v(u,h){var y,n="",o="";return typeof u<"u"&&(n=c.string(u)),typeof h<"u"&&(o=c.string(h)),y=n.concat(o),y}async function A(u,h,y){var n={},o={},l=!!(h&&h.tupleStream);Array.isArray(h)||(h=I(h)),h.length===0&&h.push(void 0);for(var g=0;g<h.length;g++)for(var p=h[g],x=l?de(y,p):y,M=0;M<u.lhs.length;M++){var q=u.lhs[M],X=await U(q[0],l?p["@"]:p,x);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var De={data:p,exprIndex:M};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==M)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=De}}let pe=await Promise.all(Object.keys(o).map(async(Se,We)=>{let ke=o[Se];var je=ke.data,ot=y;if(l){var ze=w(ke.data);je=ze["@"],delete ze["@"],ot=de(y,ze)}return y.isParallelCall=We>0,[Se,await U(u.lhs[ke.exprIndex][1],je,ot)]}));for(let Se of pe){var[X,Pe]=await Se;typeof Pe<"u"&&(n[X]=Pe)}return n}function w(u){if(!Array.isArray(u))return u;var h={};Object.assign(h,u[0]);for(var y=1;y<u.length;y++)for(const n in u[y])h[n]=c.append(h[n],u[y][n]);return h}function P(u,h){var y;if(typeof u<"u"&&!Number.isInteger(u))throw{code:"T2003",stack:new Error().stack,value:u};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof u>"u"||typeof h>"u"||u>h)return y;var n=h-u+1;if(n>1e7)throw{code:"D2014",stack:new Error().stack,value:n};y=new Array(n);for(var o=u,l=0;o<=h;o++,l++)y[l]=o;return y.sequence=!0,y}async function $(u,h,y){var n=await U(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await U(u.condition,h,y);return c.boolean(o)?n=await U(u.then,h,y):typeof u.else<"u"&&(n=await U(u.else,h,y)),n}async function C(u,h,y){for(var n,o=ut(y),l=0;l<u.expressions.length;l++)n=await U(u.expressions[l],h,o);return n}function F(u){var h=new Ce.RegexEngine(u.value),y=function(n,o){var l;h.lastIndex=o||0;var g=h.exec(n);if(g!==null){if(l={match:g[0],start:g.index,end:g.index+g[0].length,groups:[]},g.length>1)for(var p=1;p<g.length;p++)l.groups.push(g[p]);l.next=function(){if(!(h.lastIndex>=n.length)){var x=y(n,h.lastIndex);if(x&&x.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return x}}}return l};return y}function J(u,h,y){var n;return u.value===""?n=h&&h.outerWrapper?h[0]:h:n=y.lookup(u.value),n}async function ye(u,h,y){var n,o=h,l=!!h.tupleStream,g=async function(x,M){for(var q=0,X=0;q===0&&X<u.terms.length;X++){var De=u.terms[X],pe=x,Pe=y;l&&(pe=x["@"],Pe=de(y,x));var Se=await U(De.expression,pe,Pe);pe=M,Pe=y,l&&(pe=M["@"],Pe=de(y,M));var We=await U(De.expression,pe,Pe),ke=typeof Se,je=typeof We;if(ke==="undefined"){q=je==="undefined"?0:1;continue}if(je==="undefined"){q=-1;continue}if(!(ke==="string"||ke==="number")||!(je==="string"||je==="number"))throw{code:"T2008",stack:new Error().stack,position:u.position,value:ke==="string"||ke==="number"?We:Se};if(ke!==je)throw{code:"T2007",stack:new Error().stack,position:u.position,value:Se,value2:We};Se!==We&&(Se<We?q=-1:q=1,De.descending===!0&&(q=-q))}return q===1},p={environment:y,input:h};return n=await c.sort.apply(p,[o,g]),n}function we(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!me(l))throw{code:"T2013",stack:new Error().stack,position:u.position};var g=await G(l,[o],null,y),p=await U(u.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var x=0;x<p.length;x++){var M=p[x];if(M&&(M.isPrototypeOf(g)||M instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var q=await U(u.update,M,y),X=typeof q;if(X!=="undefined"){if(X!=="object"||q===null||Array.isArray(q))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:q};for(var De in q)M[De]=q[De]}if(typeof u.delete<"u"){var pe=await U(u.delete,M,y);if(typeof pe<"u"){var Pe=pe;if(Array.isArray(pe)||(pe=[pe]),!k(pe))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Pe};for(var Se=0;Se<pe.length;Se++)typeof M=="object"&&M!==null&&delete M[pe[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var K=b("function($f, $g) { function($x){ $g($f($x)) } }");async function Q(u,h,y){var n,o=await U(u.lhs,h,y);if(u.rhs.type==="function")n=await he(u.rhs,h,y,{context:o});else{var l=await U(u.rhs,h,y);if(!me(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(me(o)){var g=await U(K,null,y);n=await G(g,[o,l],null,y)}else n=await G(l,[o],null,y)}return n}async function he(u,h,y,n){var o,l=await U(u.procedure,h,y);if(typeof l>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};var g=[];typeof n<"u"&&g.push(n.context);for(var p=0;p<u.arguments.length;p++){const M=await U(u.arguments[p],h,y);if(me(M)){const q=async function(...X){return await G(M,X,null,y)};q.arity=ne(M),g.push(q)}else g.push(M)}var x=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=x,l.position=u.position),o=await G(l,g,h,y)}catch(M){throw M.position||(M.position=u.position),M.token||(M.token=x),M}return o}async function G(u,h,y,n){var o;for(o=await Ze(u,h,y,n);ge(o)&&o.thunk===!0;){var l=await U(o.body.procedure,o.input,o.environment);o.body.procedure.type==="variable"&&(l.token=o.body.procedure.value),l.position=o.body.procedure.position;for(var g=[],p=0;p<o.body.arguments.length;p++)g.push(await U(o.body.arguments[p],o.input,o.environment));o=await Ze(l,g,y,n)}return o}async function Ze(u,h,y,n){var o;try{var l=h;if(u&&(l=Ue(u.signature,h,y)),ge(u))o=await He(u,l);else if(u&&u._jsonata_function===!0){var g={environment:n,input:y};o=u.implementation.apply(g,l),H(o)&&(o=o.next().value),N(o)&&(o=await o)}else if(typeof u=="function")o=u.apply(y,l),N(o)&&(o=await o);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw u&&(typeof p.token>"u"&&typeof u.token<"u"&&(p.token=u.token),p.position=u.position||p.position),p}return o}function it(u,h,y){var n={_jsonata_lambda:!0,input:h,environment:y,arguments:u.arguments,signature:u.signature,body:u.body};return u.thunk===!0&&(n.thunk=!0),n.apply=async function(o,l){return await G(n,l,h,o?o.environment:y)},n}async function qe(u,h,y){for(var n,o=[],l=0;l<u.arguments.length;l++){var g=u.arguments[l];g.type==="operator"&&g.value==="?"?o.push(g):o.push(await U(g,h,y))}var p=await U(u.procedure,h,y);if(typeof p>"u"&&u.procedure.type==="path"&&y.lookup(u.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:u.position,token:u.procedure.steps[0].value};if(ge(p))n=wt(p,o);else if(p&&p._jsonata_function===!0)n=Tt(p.implementation,o);else if(typeof p=="function")n=Tt(p,o);else throw{code:"T1008",stack:new Error().stack,position:u.position,token:u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value};return n}function Ue(u,h,y){if(typeof u>"u")return h;var n=u.validate(h,y);return n}async function He(u,h){var y,n=ut(u.environment);return u.arguments.forEach(function(o,l){n.bind(o.value,h[l])}),typeof u.body=="function"?y=await mr(u.body,n):y=await U(u.body,u.input,n),y}function wt(u,h){var y=ut(u.environment),n=[];u.arguments.forEach(function(l,g){var p=h[g];p&&p.type==="operator"&&p.value==="?"?n.push(l):y.bind(l.value,p)});var o={_jsonata_lambda:!0,input:u.input,environment:y,arguments:n,body:u.body};return o}function Tt(u,h){var y=At(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=b(n);o.body=u;var l=wt(o,h);return l}async function mr(u,h){var y=At(u),n=y.map(function(g){return h.lookup(g.trim())}),o={environment:h},l=u.apply(o,n);return N(l)&&(l=await l),l}function At(u){var h=u.toString(),y=/\(([^)]*)\)/.exec(h)[1],n=y.split(",");return n}function Z(u,h){var y={_jsonata_function:!0,implementation:u};return typeof h<"u"&&(y.signature=_(h)),y}async function yr(u,h){if(!(typeof u>"u")){var y=this.input;typeof h<"u"&&(y=h,Array.isArray(y)&&!se(y)&&(y=I(y),y.outerWrapper=!0));try{var n=b(u,!1)}catch(l){throw yt(l),{stack:new Error().stack,code:"D3120",value:l.message,error:l}}try{var o=await U(n,y,this.environment)}catch(l){throw yt(l),{stack:new Error().stack,code:"D3121",value:l.message,error:l}}return o}}function Jt(u){if(!(typeof u>"u"))return JSON.parse(c.string(u))}function ut(u){var h={};const y={bind:function(o,l){h[o]=l},lookup:function(o){var l;return h.hasOwnProperty(o)?l=h[o]:u&&(l=u.lookup(o)),l},timestamp:u?u.timestamp:null,async:u?u.async:!1,isParallelCall:u?u.isParallelCall:!1,global:u?u.global:{ancestry:[null]}};if(u){var n=u.lookup(Symbol.for("jsonata.__createFrame_push"));n&&n(u,y)}return y}T.bind("sum",Z(c.sum,"<a<n>:n>")),T.bind("count",Z(c.count,"<a:n>")),T.bind("max",Z(c.max,"<a<n>:n>")),T.bind("min",Z(c.min,"<a<n>:n>")),T.bind("average",Z(c.average,"<a<n>:n>")),T.bind("string",Z(c.string,"<x-b?:s>")),T.bind("substring",Z(c.substring,"<s-nn?:s>")),T.bind("substringBefore",Z(c.substringBefore,"<s-s:s>")),T.bind("substringAfter",Z(c.substringAfter,"<s-s:s>")),T.bind("lowercase",Z(c.lowercase,"<s-:s>")),T.bind("uppercase",Z(c.uppercase,"<s-:s>")),T.bind("length",Z(c.length,"<s-:n>")),T.bind("trim",Z(c.trim,"<s-:s>")),T.bind("pad",Z(c.pad,"<s-ns?:s>")),T.bind("match",Z(c.match,"<s-f<s:o>n?:a<o>>")),T.bind("contains",Z(c.contains,"<s-(sf):b>")),T.bind("replace",Z(c.replace,"<s-(sf)(sf)n?:s>")),T.bind("split",Z(c.split,"<s-(sf)n?:a<s>>")),T.bind("join",Z(c.join,"<a<s>s?:s>")),T.bind("formatNumber",Z(c.formatNumber,"<n-so?:s>")),T.bind("formatBase",Z(c.formatBase,"<n-n?:s>")),T.bind("formatInteger",Z(i.formatInteger,"<n-s:s>")),T.bind("parseInteger",Z(i.parseInteger,"<s-s:n>")),T.bind("number",Z(c.number,"<(nsb)-:n>")),T.bind("floor",Z(c.floor,"<n-:n>")),T.bind("ceil",Z(c.ceil,"<n-:n>")),T.bind("round",Z(c.round,"<n-n?:n>")),T.bind("abs",Z(c.abs,"<n-:n>")),T.bind("sqrt",Z(c.sqrt,"<n-:n>")),T.bind("power",Z(c.power,"<n-n:n>")),T.bind("random",Z(c.random,"<:n>")),T.bind("boolean",Z(c.boolean,"<x-:b>")),T.bind("not",Z(c.not,"<x-:b>")),T.bind("map",Z(c.map,"<af>")),T.bind("zip",Z(c.zip,"<a+>")),T.bind("filter",Z(c.filter,"<af>")),T.bind("single",Z(c.single,"<af?>")),T.bind("reduce",Z(c.foldLeft,"<afj?:j>")),T.bind("sift",Z(c.sift,"<o-f?:o>")),T.bind("keys",Z(c.keys,"<x-:a<s>>")),T.bind("lookup",Z(c.lookup,"<x-s:x>")),T.bind("append",Z(c.append,"<xx:a>")),T.bind("exists",Z(c.exists,"<x:b>")),T.bind("spread",Z(c.spread,"<x-:a<o>>")),T.bind("merge",Z(c.merge,"<a<o>:o>")),T.bind("reverse",Z(c.reverse,"<a:a>")),T.bind("each",Z(c.each,"<o-f:a>")),T.bind("error",Z(c.error,"<s?:x>")),T.bind("assert",Z(c.assert,"<bs?:x>")),T.bind("type",Z(c.type,"<x:s>")),T.bind("sort",Z(c.sort,"<af?:a>")),T.bind("shuffle",Z(c.shuffle,"<a:a>")),T.bind("distinct",Z(c.distinct,"<x:x>")),T.bind("base64encode",Z(c.base64encode,"<s-:s>")),T.bind("base64decode",Z(c.base64decode,"<s-:s>")),T.bind("encodeUrlComponent",Z(c.encodeUrlComponent,"<s-:s>")),T.bind("encodeUrl",Z(c.encodeUrl,"<s-:s>")),T.bind("decodeUrlComponent",Z(c.decodeUrlComponent,"<s-:s>")),T.bind("decodeUrl",Z(c.decodeUrl,"<s-:s>")),T.bind("eval",Z(yr,"<sx?:x>")),T.bind("toMillis",Z(i.toMillis,"<s-s?:n>")),T.bind("fromMillis",Z(i.fromMillis,"<n-s?s?:s>")),T.bind("clone",Z(Jt,"<(oa)-:o>"));var Ut={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function yt(u){var h=Ut[u.code];if(typeof h<"u"){var y=h.replace(/\{\{\{([^}]+)}}}/g,function(){return u[arguments[1]]});y=y.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(u[arguments[1]])}),u.message=y}}function Ce(u,h){var y,n;try{y=b(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw yt(g),g}var o=ut(T),l=new Date;return o.bind("now",Z(function(g,p){return i.fromMillis(l.getTime(),g,p)},"<s?s?:s>")),o.bind("millis",Z(function(){return l.getTime()},"<:n>")),h&&h.RegexEngine?Ce.RegexEngine=h.RegexEngine:Ce.RegexEngine=RegExp,{evaluate:async function(g,p,x){if(typeof n<"u"){var M={code:"S0500",position:0};throw yt(M),M}if(typeof p<"u"){var q;q=ut(o);for(var X in p)q.bind(X,p[X])}else q=o;q.bind("$",g),l=new Date,q.timestamp=l,Array.isArray(g)&&!se(g)&&(g=I(g),g.outerWrapper=!0);var De;try{return De=await U(y,g,q),typeof x=="function"&&x(null,De),De}catch(pe){throw yt(pe),pe}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,x){var M=Z(p,x);o.bind(g,M)},ast:function(){return y},errors:function(){return n}}}return Ce.parser=b,Ce})();a.exports=R},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,a,s){var i=t("./signature");const c=(()=>{var f={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,"?:":40,"??":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},b={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
2
  `,r:"\r",t:" "},_=function(S){var k=0,E=S.length,I=function(ge,H){var N={type:ge,value:H,position:k};return N},se=function(){for(var ge=k,H=0,N,ne,L=function(U){if(S.charAt(U)==="/"&&H===0){for(var z=0;S.charAt(U-(z+1))==="\\";)z++;if(z%2===0)return!0}return!1};k<E;){var T=S.charAt(k);if(L(k)){if(N=S.substring(ge,k),N==="")throw{code:"S0301",stack:new Error().stack,position:k};for(k++,T=S.charAt(k),ge=k;T==="i"||T==="m";)k++,T=S.charAt(k);return ne=S.substring(ge,k)+"g",new RegExp(N,ne)}(T==="("||T==="["||T==="{")&&S.charAt(k-1)!=="\\"&&H++,(T===")"||T==="]"||T==="}")&&S.charAt(k-1)!=="\\"&&H--,k++}throw{code:"S0302",stack:new Error().stack,position:k}},me=function(ge){if(k>=E)return null;for(var H=S.charAt(k);k<E&&`
3
3
  \r\v`.indexOf(H)>-1;)k++,H=S.charAt(k);if(H==="/"&&S.charAt(k+1)==="*"){var N=k;for(k+=2,H=S.charAt(k);!(H==="*"&&S.charAt(k+1)==="/");)if(H=S.charAt(++k),k>=E)throw{code:"S0106",stack:new Error().stack,position:N};return k+=2,H=S.charAt(k),me(ge)}if(ge!==!0&&H==="/")return k++,I("regex",se());if(H==="."&&S.charAt(k+1)===".")return k+=2,I("operator","..");if(H===":"&&S.charAt(k+1)==="=")return k+=2,I("operator",":=");if(H==="!"&&S.charAt(k+1)==="=")return k+=2,I("operator","!=");if(H===">"&&S.charAt(k+1)==="=")return k+=2,I("operator",">=");if(H==="<"&&S.charAt(k+1)==="=")return k+=2,I("operator","<=");if(H==="*"&&S.charAt(k+1)==="*")return k+=2,I("operator","**");if(H==="~"&&S.charAt(k+1)===">")return k+=2,I("operator","~>");if(H==="?"&&S.charAt(k+1)===":")return k+=2,I("operator","?:");if(H==="?"&&S.charAt(k+1)==="?")return k+=2,I("operator","??");if(Object.prototype.hasOwnProperty.call(f,H))return k++,I("operator",H);if(H==='"'||H==="'"){var ne=H;k++;for(var L="";k<E;){if(H=S.charAt(k),H==="\\")if(k++,H=S.charAt(k),Object.prototype.hasOwnProperty.call(b,H))L+=b[H];else if(H==="u"){var T=S.substr(k+1,4);if(/^[0-9a-fA-F]+$/.test(T)){var U=parseInt(T,16);L+=String.fromCharCode(U),k+=4}else throw{code:"S0104",stack:new Error().stack,position:k}}else throw{code:"S0103",stack:new Error().stack,position:k,token:H};else{if(H===ne)return k++,I("string",L);L+=H}k++}throw{code:"S0101",stack:new Error().stack,position:k}}var z=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,de=z.exec(S.substring(k));if(de!==null){var xe=parseFloat(de[0]);if(!isNaN(xe)&&isFinite(xe))return k+=de[0].length,I("number",xe);throw{code:"S0102",stack:new Error().stack,position:k,token:de[0]}}var Te;if(H==="`"){k++;var Ae=S.indexOf("`",k);if(Ae!==-1)return Te=S.substring(k,Ae),k=Ae+1,I("name",Te);throw k=E,{code:"S0105",stack:new Error().stack,position:k}}for(var ve=k,Me;;)if(Me=S.charAt(ve),ve===E||`
4
4
  \r\v`.indexOf(Me)>-1||Object.prototype.hasOwnProperty.call(f,Me)){if(S.charAt(k)==="$")return Te=S.substring(k+1,ve),k=ve,I("variable",Te);switch(Te=S.substring(k,ve),k=ve,Te){case"or":case"in":case"and":return I("operator",Te);case"true":return I("value",!0);case"false":return I("value",!1);case"null":return I("value",null);default:return k===E&&Te===""?null:I("name",Te)}}else ve++};return me},R=function(S,k){var E,I,se={},me=[],ge=function(){var d=[];E.id!=="(end)"&&d.push({type:E.type,value:E.value,position:E.position});for(var m=I();m!==null;)d.push(m),m=I();return d},H={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(k)return d.remaining=ge(),d.type="error",me.push(d),d;throw d.stack=new Error().stack,d}},N=function(d,m){var V=se[d];return m=m||0,V?m>=V.lbp&&(V.lbp=m):(V=Object.create(H),V.id=V.value=d,V.lbp=m,se[d]=V),V},ne=function(d){if(k){d.remaining=ge(),me.push(d);var m=se["(error)"];return E=Object.create(m),E.error=d,E.type="(error)",E}else throw d.stack=new Error().stack,d},L=function(d,m){if(d&&E.id!==d){var V;E.id==="(end)"?V="S0203":V="S0202";var le={code:V,position:E.position,token:E.value,value:d};return ne(le)}var Oe=I(m);if(Oe===null)return E=se["(end)"],E.position=S.length,E;var Ee=Oe.value,v=Oe.type,A;switch(v){case"name":case"variable":A=se["(name)"];break;case"operator":if(A=se[Ee],!A)return ne({code:"S0204",stack:new Error().stack,position:Oe.position,token:Ee});break;case"string":case"number":case"value":A=se["(literal)"];break;case"regex":v="regex",A=se["(regex)"];break;default:return ne({code:"S0205",stack:new Error().stack,position:Oe.position,token:Ee})}return E=Object.create(A),E.value=Ee,E.type=v,E.position=Oe.position,E},T=function(d){var m,V=E;for(L(null,!0),m=V.nud();d<E.lbp;)V=E,L(),m=V.led(m);return m},U=function(d){var m=N(d,0);m.nud=function(){return this}},z=function(d,m,V){var le=m||f[d],Oe=N(d,le);return Oe.led=V||function(Ee){return this.lhs=Ee,this.rhs=T(le),this.type="binary",this},Oe},de=function(d,m,V){var le=N(d,m);return le.led=V,le},xe=function(d,m){var V=N(d);return V.nud=m||function(){return this.expression=T(70),this.type="unary",this},V};U("(end)"),U("(name)"),U("(literal)"),U("(regex)"),N(":"),N(";"),N(","),N(")"),N("]"),N("}"),N(".."),z("."),z("+"),z("-"),z("*"),z("/"),z("%"),z("="),z("<"),z(">"),z("!="),z("<="),z(">="),z("&"),z("and"),z("or"),z("in"),U("and"),U("or"),U("in"),xe("-"),z("~>"),z("??",f["??"],function(d){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[d]},this.then=d,this.else=T(0),this}),de("(error)",10,function(d){return this.lhs=d,this.error=E.error,this.remaining=ge(),this.type="error",this}),xe("*",function(){return this.type="wildcard",this}),xe("**",function(){return this.type="descendant",this}),xe("%",function(){return this.type="parent",this}),z("(",f["("],function(d){if(this.procedure=d,this.type="function",this.arguments=[],E.id!==")")for(;E.type==="operator"&&E.id==="?"?(this.type="partial",this.arguments.push(E),L("?")):this.arguments.push(T(0)),E.id===",";)L(",");if(L(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(Ee,v){if(Ee.type!=="variable")return ne({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:v+1})}),this.type="lambda",E.id==="<"){for(var m=E.position,V=1,le="<";V>0&&E.id!=="{"&&E.id!=="(end)";){var Oe=L();Oe.id===">"?V--:Oe.id==="<"&&V++,le+=Oe.value}L(">");try{this.signature=i(le)}catch(Ee){return Ee.position=m+Ee.offset,ne(Ee)}}L("{"),this.body=T(0),L("}")}return this}),xe("(",function(){for(var d=[];E.id!==")"&&(d.push(T(0)),E.id===";");)L(";");return L(")",!0),this.type="block",this.expressions=d,this}),xe("[",function(){var d=[];if(E.id!=="]")for(;;){var m=T(0);if(E.id===".."){var V={type:"binary",value:"..",position:E.position,lhs:m};L(".."),V.rhs=T(0),m=V}if(d.push(m),E.id!==",")break;L(",")}return L("]",!0),this.expressions=d,this.type="unary",this}),z("[",f["["],function(d){if(E.id==="]"){for(var m=d;m&&m.type==="binary"&&m.value==="[";)m=m.lhs;return m.keepArray=!0,L("]"),d}else return this.lhs=d,this.rhs=T(f["]"]),this.type="binary",L("]",!0),this}),z("^",f["^"],function(d){L("(");for(var m=[];;){var V={descending:!1};if(E.id==="<"?L("<"):E.id===">"&&(V.descending=!0,L(">")),V.expression=T(0),m.push(V),E.id!==",")break;L(",")}return L(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Te=function(d){var m=[];if(E.id!=="}")for(;;){var V=T(0);L(":");var le=T(0);if(m.push([V,le]),E.id!==",")break;L(",")}return L("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};xe("{",Te),z("{",f["{"],Te),de(":=",f[":="],function(d){return d.type!=="variable"?ne({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=T(f[":="]-1),this.type="binary",this)}),z("@",f["@"],function(d){return this.lhs=d,this.rhs=T(f["@"]),this.rhs.type!=="variable"?ne({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),z("#",f["#"],function(d){return this.lhs=d,this.rhs=T(f["#"]),this.rhs.type!=="variable"?ne({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),z("?",f["?"],function(d){return this.type="condition",this.condition=d,this.then=T(0),E.id===":"&&(L(":"),this.else=T(0)),this}),z("?:",f["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=T(0),this}),xe("|",function(){return this.type="transform",this.pattern=T(0),L("|"),this.update=T(0),E.id===","&&(L(","),this.delete=T(0)),L("|"),this});var Ae=function(d){var m;if(d.type==="function"&&!d.predicate){var V={type:"lambda",thunk:!0,arguments:[],position:d.position};V.body=d,m=V}else if(d.type==="condition")d.then=Ae(d.then),typeof d.else<"u"&&(d.else=Ae(d.else)),m=d;else if(d.type==="block"){var le=d.expressions.length;le>0&&(d.expressions[le-1]=Ae(d.expressions[le-1])),m=d}else m=d;return m},ve=0,Me=0,et=[],_e=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(et[m.index].slot.label=d.ancestor.label),d.ancestor=m,d.tuple=!0);break;case"parent":m.level++;break;case"block":d.expressions.length>0&&(d.tuple=!0,m=_e(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var V=d.steps.length-1;for(m=_e(d.steps[V--],m);m.level>0&&V>=0;)m=_e(d.steps[V--],m);break;default:throw{code:"S0217",token:d.type,position:d.position}}return m},ue=function(d,m){if(typeof m.seekingParent<"u"||m.type==="parent"){var V=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&V.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=V:Array.prototype.push.apply(d.seekingParent,V)}},tt=function(d){var m=d.steps.length-1,V=d.steps[m],le=typeof V.seekingParent<"u"?V.seekingParent:[];V.type==="parent"&&le.push(V.slot);for(var Oe=0;Oe<le.length;Oe++){var Ee=le[Oe];for(m=d.steps.length-2;Ee.level>0;){if(m<0){typeof d.seekingParent>"u"?d.seekingParent=[Ee]:d.seekingParent.push(Ee);break}for(var v=d.steps[m--];m>=0&&v.focus&&d.steps[m].focus;)v=d.steps[m--];Ee=_e(v,Ee)}}},ae=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var V=ae(d.lhs);V.type==="path"?m=V:m={type:"path",steps:[V]},V.type==="parent"&&(m.seekingParent=[V.slot]);var le=ae(d.rhs);le.type==="function"&&le.procedure.type==="path"&&le.procedure.steps.length===1&&le.procedure.steps[0].type==="name"&&m.steps[m.steps.length-1].type==="function"&&(m.steps[m.steps.length-1].nextFunction=le.procedure.steps[0].value),le.type==="path"?Array.prototype.push.apply(m.steps,le.steps):(typeof le.predicate<"u"&&(le.stages=le.predicate,delete le.predicate),m.steps.push(le)),m.steps.filter(function(F){if(F.type==="number"||F.type==="value")throw{code:"S0213",stack:new Error().stack,position:F.position,value:F.value};return F.type==="string"}).forEach(function(F){F.type="name"}),m.steps.filter(function(F){return F.keepArray===!0}).length>0&&(m.keepSingletonArray=!0);var Oe=m.steps[0];Oe.type==="unary"&&Oe.value==="["&&(Oe.consarray=!0);var Ee=m.steps[m.steps.length-1];Ee.type==="unary"&&Ee.value==="["&&(Ee.consarray=!0),tt(m);break;case"[":m=ae(d.lhs);var v=m,A="predicate";if(m.type==="path"&&(v=m.steps[m.steps.length-1],A="stages"),typeof v.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof v[A]>"u"&&(v[A]=[]);var w=ae(d.rhs);typeof w.seekingParent<"u"&&(w.seekingParent.forEach(F=>{F.level===1?_e(v,F):F.level--}),ue(v,w)),v[A].push({type:"filter",expr:w,position:d.position});break;case"{":if(m=ae(d.lhs),typeof m.group<"u")throw{code:"S0210",stack:new Error().stack,position:d.position};m.group={lhs:d.rhs.map(function(F){return[ae(F[0]),ae(F[1])]}),position:d.position};break;case"^":m=ae(d.lhs),m.type!=="path"&&(m={type:"path",steps:[m]});var P={type:"sort",position:d.position};P.terms=d.rhs.map(function(F){var J=ae(F.expression);return ue(P,J),{descending:F.descending,expression:J}}),m.steps.push(P),tt(m);break;case":=":m={type:"bind",value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),ue(m,m.rhs);break;case"@":if(m=ae(d.lhs),v=m,m.type==="path"&&(v=m.steps[m.steps.length-1]),typeof v.stages<"u"||typeof v.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:d.position};if(v.type==="sort")throw{code:"S0216",stack:new Error().stack,position:d.position};d.keepArray&&(v.keepArray=!0),v.focus=d.rhs.value,v.tuple=!0;break;case"#":m=ae(d.lhs),v=m,m.type==="path"?v=m.steps[m.steps.length-1]:(m={type:"path",steps:[m]},typeof v.predicate<"u"&&(v.stages=v.predicate,delete v.predicate)),typeof v.stages>"u"?v.index=d.rhs.value:v.stages.push({type:"index",value:d.rhs.value,position:d.position}),v.tuple=!0;break;case"~>":m={type:"apply",value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),m.keepArray=m.lhs.keepArray||m.rhs.keepArray;break;default:m={type:d.type,value:d.value,position:d.position},m.lhs=ae(d.lhs),m.rhs=ae(d.rhs),ue(m,m.lhs),ue(m,m.rhs)}break;case"unary":m={type:d.type,value:d.value,position:d.position},d.value==="["?m.expressions=d.expressions.map(function(F){var J=ae(F);return ue(m,J),J}):d.value==="{"?m.lhs=d.lhs.map(function(F){var J=ae(F[0]);ue(m,J);var ye=ae(F[1]);return ue(m,ye),[J,ye]}):(m.expression=ae(d.expression),d.value==="-"&&m.expression.type==="number"?(m=m.expression,m.value=-m.value):ue(m,m.expression));break;case"function":case"partial":m={type:d.type,name:d.name,value:d.value,position:d.position},m.arguments=d.arguments.map(function(F){var J=ae(F);return ue(m,J),J}),m.procedure=ae(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var $=ae(d.body);m.body=Ae($);break;case"condition":m={type:d.type,position:d.position},m.condition=ae(d.condition),ue(m,m.condition),m.then=ae(d.then),ue(m,m.then),typeof d.else<"u"&&(m.else=ae(d.else),ue(m,m.else));break;case"transform":m={type:d.type,position:d.position},m.pattern=ae(d.pattern),m.update=ae(d.update),typeof d.delete<"u"&&(m.delete=ae(d.delete));break;case"block":m={type:d.type,position:d.position},m.expressions=d.expressions.map(function(F){var J=ae(F);return ue(m,J),(J.consarray||J.type==="path"&&J.steps[0].consarray)&&(m.consarray=!0),J});break;case"name":m={type:"path",steps:[d]},d.keepArray&&(m.keepSingletonArray=!0);break;case"parent":m={type:"parent",slot:{label:"!"+ve++,level:1,index:Me++}},et.push(m);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":m=d;break;case"operator":if(d.value==="and"||d.value==="or"||d.value==="in")d.type="name",m=ae(d);else if(d.value==="?")m=d;else throw{code:"S0201",stack:new Error().stack,position:d.position,token:d.value};break;case"error":m=d,d.lhs&&(m=ae(d.lhs));break;default:var j="S0206";d.id==="(end)"&&(j="S0207");var C={code:j,position:d.position,token:d.value};if(k)return me.push(C),{type:"error",error:C};throw C.stack=new Error().stack,C}return d.keepArray&&(m.keepArray=!0),m};I=_(S),L();var Fe=T(0);if(E.id!=="(end)"){var st={code:"S0201",position:E.position,token:E.value};ne(st)}if(Fe=ae(Fe),Fe.type==="parent"||typeof Fe.seekingParent<"u")throw{code:"S0217",token:Fe.type,position:Fe.position};return me.length>0&&(Fe.errors=me),Fe};return R})();a.exports=c},{"./signature":5}],5:[function(t,a,s){var i=t("./utils");const c=(()=>{var f={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function b(_){for(var R=1,S=[],k={},E=k;R<_.length;){var I=_.charAt(R);if(I===":")break;var se=function(){S.push(k),E=k,k={}},me=function(z,de,xe,Te){for(var Ae=1,ve=de;ve<z.length;)if(ve++,I=z.charAt(ve),I===Te){if(Ae--,Ae===0)break}else I===xe&&Ae++;return ve};switch(I){case"s":case"n":case"b":case"l":case"o":k.regex="["+I+"m]",k.type=I,se();break;case"a":k.regex="[asnblfom]",k.type=I,k.array=!0,se();break;case"f":k.regex="f",k.type=I,se();break;case"j":k.regex="[asnblom]",k.type=I,se();break;case"x":k.regex="[asnblfom]",k.type=I,se();break;case"-":E.context=!0,E.contextRegex=new RegExp(E.regex),E.regex+="?";break;case"?":case"+":E.regex+=I;break;case"(":var ge=me(_,R,"(",")"),H=_.substring(R+1,ge);if(H.indexOf("<")===-1)k.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:R};k.type="("+H+")",R=ge,se();break;case"<":if(E.type==="a"||E.type==="f"){var N=me(_,R,"<",">");E.subtype=_.substring(R+1,N),R=N}else throw{code:"S0401",stack:new Error().stack,value:E.type,offset:R};break}R++}var ne="^"+S.map(function(z){return"("+z.regex+")"}).join("")+"$",L=new RegExp(ne),T=function(z){var de;if(i.isFunction(z))de="f";else{var xe=typeof z;switch(xe){case"string":de="s";break;case"number":de="n";break;case"boolean":de="b";break;case"object":z===null?de="l":Array.isArray(z)?de="a":de="o";break;case"undefined":default:de="m"}}return de},U=function(z,de){for(var xe="^",Te=0,Ae=0;Ae<S.length;Ae++){xe+=S[Ae].regex;var ve=de.match(xe);if(ve===null)throw{code:"T0410",stack:new Error().stack,value:z[Te],index:Te+1};Te=ve[0].length}throw{code:"T0410",stack:new Error().stack,value:z[Te],index:Te+1}};return{definition:_,validate:function(z,de){var xe="";z.forEach(function(Me){xe+=T(Me)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return S.forEach(function(Me,et){var _e=z[ve],ue=Te[et+1];if(ue==="")if(Me.context&&Me.contextRegex){var tt=T(de);if(Me.contextRegex.test(tt))Ae.push(de);else throw{code:"T0411",stack:new Error().stack,value:de,index:ve+1}}else Ae.push(_e),ve++;else ue.split("").forEach(function(ae){if(Me.type==="a"){if(ae==="m")_e=void 0;else{_e=z[ve];var Fe=!0;if(typeof Me.subtype<"u"){if(ae!=="a"&&ue!==Me.subtype)Fe=!1;else if(ae==="a"&&_e.length>0){var st=T(_e[0]);if(st!==Me.subtype.charAt(0))Fe=!1;else{var d=_e.filter(function(m){return T(m)!==st});Fe=d.length===0}}}if(!Fe)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:f[Me.subtype]};ae!=="a"&&(_e=[_e])}Ae.push(_e),ve++}else Ae.push(_e),ve++})}),Ae}U(z,xe)}}}return b})();a.exports=c},{"./utils":6}],6:[function(t,a,s){const i=(()=>{function c(N){var ne=!1;if(typeof N=="number"&&(ne=!isNaN(N),ne&&!isFinite(N)))throw{code:"D1001",value:N,stack:new Error().stack};return ne}function f(N){var ne=!1;return Array.isArray(N)&&(ne=N.filter(function(L){return typeof L!="string"}).length===0),ne}function b(N){var ne=!1;return Array.isArray(N)&&(ne=N.filter(function(L){return!c(L)}).length===0),ne}function _(){var N=[];return N.sequence=!0,arguments.length===1&&N.push(arguments[0]),N}function R(N){return N.sequence===!0&&Array.isArray(N)}function S(N){return N&&(N._jsonata_function===!0||N._jsonata_lambda===!0)||typeof N=="function"}function k(N){var ne=typeof N.arity=="number"?N.arity:typeof N.implementation=="function"?N.implementation.length:typeof N.length=="number"?N.length:N.arguments.length;return ne}function E(N){return N&&N._jsonata_lambda===!0}var I=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function se(N){return typeof N=="object"&&N!==null&&I in N&&"next"in N&&typeof N.next=="function"}function me(N,ne){if(N===ne)return!0;if(typeof N=="object"&&typeof ne=="object"&&N!==null&&ne!==null){if(Array.isArray(N)&&Array.isArray(ne)){if(N.length!==ne.length)return!1;for(var L=0;L<N.length;L++)if(!me(N[L],ne[L]))return!1;return!0}var T=Object.getOwnPropertyNames(N),U=Object.getOwnPropertyNames(ne);if(T.length!==U.length)return!1;for(T=T.sort(),U=U.sort(),L=0;L<T.length;L++)if(T[L]!==U[L])return!1;for(L=0;L<T.length;L++){var z=T[L];if(!me(N[z],ne[z]))return!1}return!0}return!1}function ge(N){return typeof N=="object"&&N!==null&&"then"in N&&typeof N.then=="function"}function H(N){var ne=[];for(let L of N)ne.push(L);return ne}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:b,createSequence:_,isSequence:R,isFunction:S,isLambda:E,isIterable:se,getFunctionArity:k,isDeepEqual:me,stringToArray:H,isPromise:ge}})();a.exports=i},{}]},{},[3])(3)})})(Mr)),Mr.exports}var Hs=qs();const Gs=Vs(Hs),nn=D.object({name:D.literal("data-extract"),code:D.string(),inputData:D.any().optional()});function Ys(r){return nn.parse(r)}async function Ks(r){try{console.log("[DataExtractBlock] Executing JSONata query:",r.code);const t=await Gs(r.code).evaluate(r.inputData);return console.log("[DataExtractBlock] Data extraction successful"),{data:t}}catch(e){return console.error("[DataExtractBlock] Data extraction error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in data extraction",data:void 0}}}const Js={"get-text":Zr,"attribute-value":Wr,"get-value-form":zr,"set-value-form":Vr,"clear-value-form":qr,"element-exists":Hr,"event-click":Gr,keypress:Yr,wait:Kr,"wait-for-condition":Jr,navigate:Xr,"save-assets":Qr,"get-element-data":en,scroll:tn,"ai-parse-data":Lr,"fetch-api":rn,"data-extract":nn};class Xs{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=ts(e);return await rs(t)}case"attribute-value":{const t=as(e);return await ss(t)}case"get-value-form":{const t=is(e);return await os(t)}case"set-value-form":{const t=us(e);return await ls(t)}case"clear-value-form":{const t=ds(e);return await hs(t)}case"element-exists":{const t=ms(e);return await ys(t)}case"event-click":{const t=gs(e);return await vs(t)}case"keypress":{const t=xs(e);return await _s(t)}case"wait":{const t=Ts(e);return await As(t)}case"wait-for-condition":{const t=Ss(e);return await Cs(t)}case"navigate":{const t=Ds(e);return await Os(t)}case"save-assets":{const t=Ps(e);return await Ns(t)}case"get-element-data":{const t=Rs(e);return await Is(t)}case"scroll":{const t=Fs(e);return await $s(t)}case"ai-parse-data":{const t=za(e);return await Va(t)}case"fetch-api":{const t=Ws(e);return await zs(t)}case"data-extract":{const t=Ys(e);return await Ks(t)}default:return{hasError:!0,message:`Unknown block type: ${e.name}`,data:null}}}catch(t){return{hasError:!0,message:t instanceof Error?t.message:"Unknown error in block execution",data:null}}}}class Qs{constructor(){fe(this,"expr");fe(this,"json")}}class ei{constructor(){fe(this,"template");fe(this,"valueFrom");fe(this,"default")}}class ti{constructor(){fe(this,"id");fe(this,"title");fe(this,"when");fe(this,"block");fe(this,"repeat");fe(this,"next");fe(this,"onSuccess");fe(this,"onFailure");fe(this,"switch");fe(this,"timeoutMs");fe(this,"retry");fe(this,"delayAfterMs")}}class ri{constructor(){fe(this,"version");fe(this,"id");fe(this,"title");fe(this,"description");fe(this,"start");fe(this,"steps");fe(this,"vars");fe(this,"defaultDelayMs")}}class ni{constructor(){fe(this,"stepId");fe(this,"skipped");fe(this,"success");fe(this,"message");fe(this,"result");fe(this,"startedAt");fe(this,"finishedAt");fe(this,"attempts")}}class ai{constructor(){fe(this,"success");fe(this,"steps");fe(this,"targetUrl");fe(this,"timestamp");fe(this,"error")}}exports.AiParseDataBlockSchema=Lr;exports.AllBlockSchemas=Js;exports.BaseBlockSchema=pt;exports.BillingCycleTerm=Ur;exports.Binding=ei;exports.BlockHandler=Xs;exports.ClearValueFormsBlockSchema=qr;exports.CollectWorkflowResult=ai;exports.Condition=Qs;exports.Currency=_n;exports.CurrencySchema=Cr;exports.CurrencyValues=Ba;exports.DataExtractBlockSchema=nn;exports.EightGClient=Ua;exports.EightGError=ct;exports.ElementExistsBlockSchema=Hr;exports.EventClickBlockSchema=Gr;exports.FetchApiBlockSchema=rn;exports.GetAttributeValueBlockSchema=Wr;exports.GetElementDataBlockSchema=en;exports.GetTextBlockSchema=Zr;exports.GetValueFormsBlockSchema=zr;exports.KeypressBlockSchema=Yr;exports.NavigateBlockSchema=Xr;exports.SaveAssetsBlockSchema=Qr;exports.Schema=Ga;exports.ScrollBlockSchema=tn;exports.SetValueFormsBlockSchema=Vr;exports.WaitBlockSchema=Kr;exports.WaitForConditionBlockSchema=Jr;exports.Workflow=ri;exports.WorkflowStep=ti;exports.WorkflowStepRunResult=ni;exports.WorkspaceBillingHistorySchema=Tn;exports.WorkspaceBillingSchema=En;exports.WorkspaceItemSchema=xn;exports.WorkspaceMemberSchema=An;exports.createArraySchema=Ha;exports.createSchema=qa;