scordi-extension 1.15.5 → 1.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks/AiParseDataBlock.d.ts +14 -2
- package/dist/blocks/AiParseDataBlock.d.ts.map +1 -1
- package/dist/sdk/EightGClient.d.ts +6 -72
- package/dist/sdk/EightGClient.d.ts.map +1 -1
- package/dist/sdk/index.cjs +4 -4
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +609 -807
- package/dist/sdk/types.d.ts +31 -23
- package/dist/sdk/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/sdk/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Rn=Object.defineProperty;var Mn=(r,e,t)=>e in r?Rn(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"});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 Mr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Mr||(Mr={}));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}},P=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 k=c.path[b];b===c.path.length-1?(f[k]=f[k]||{_errors:[]},f[k]._errors.push(t(c))):f[k]=f[k]||{_errors:[]},f=f[k],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 qt=(r,e)=>{let t;switch(r.code){case P.invalid_type:r.received===W.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case P.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,be.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:t=`Unrecognized key(s) in object: ${be.joinValues(r.keys,", ")}`;break;case P.invalid_union:t="Invalid input";break;case P.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${be.joinValues(r.options)}`;break;case P.invalid_enum_value:t=`Invalid enum value. Expected ${be.joinValues(r.options)}, received '${r.received}'`;break;case P.invalid_arguments:t="Invalid function arguments";break;case P.invalid_return_type:t="Invalid function return type";break;case P.invalid_date:t="Invalid date";break;case P.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 P.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 P.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 P.custom:t="Invalid input";break;case P.invalid_intersection_types:t="Intersection results could not be merged";break;case P.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case P.not_finite:t="Number must be finite";break;default:t=e.defaultError,be.assertNever(r)}return{message:t}};let yn=qt;function jn(r){yn=r}function xr(){return yn}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(k=>!!k).slice().reverse();for(const k of b)f=k(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},Fn=[];function U(r,e){const t=xr(),a=_r({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===qt?void 0:qt].filter(s=>!!s)});r.common.issues.push(a)}class Ye{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 Ye.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"}),zt=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 K;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(K||(K={}));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 ln=(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 Ye,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 ln(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 ln(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:P.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 Ct.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this)}promise(){return Kt.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 Ur({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 Bn=/^c[^\s-]{8,}$/i,Un=/^[0-9a-z]+$/,$n=/^[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-_]*$/,Vn=/^[-+]?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)?)??$/,zn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Cr;const qn=/^(?:(?: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])$/,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]))$/,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]))\/(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}(=)?))?$/,gn="((\\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(`^${gn}$`);function vn(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(`^${vn(r)}$`)}function bn(r){let e=`${gn}T${vn(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)&&qn.test(r)||(e==="v6"||!e)&&Kn.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)&&Yn.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 U(i,{code:P.invalid_type,expected:W.string,received:i.parsedType}),ee}const a=new Ye;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.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),U(s,{code:P.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?U(s,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&U(s,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"email",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Cr||(Cr=new RegExp(Hn,"u")),Cr.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"emoji",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"uuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"nanoid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Un.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid2",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")$n.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ulid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),U(s,{validation:"url",code:P.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),U(s,{validation:"regex",code:P.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),U(s,{code:P.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),U(s,{code:P.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?bn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?Qn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?ea(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?Vn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"duration",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?ta(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ip",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?ra(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"jwt",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?na(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cidr",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?Jn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?Xn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64url",code:P.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:P.invalid_string,...K.errToObj(a)})}_addCheck(e){return new ft({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...K.errToObj(e)})}url(e){return this._addCheck({kind:"url",...K.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...K.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...K.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...K.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...K.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...K.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...K.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...K.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...K.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...K.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...K.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...K.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,...K.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,...K.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...K.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...K.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...K.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...K.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...K.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...K.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...K.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...K.errToObj(t)})}nonempty(e){return this.min(1,K.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 Dt 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 U(i,{code:P.invalid_type,expected:W.number,received:i.parsedType}),ee}let a;const s=new Ye;for(const i of this._def.checks)i.kind==="int"?be.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.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),U(a,{code:P.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),U(a,{code:P.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),U(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.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,K.toString(t))}gt(e,t){return this.setLimit("min",e,!1,K.toString(t))}lte(e,t){return this.setLimit("max",e,!0,K.toString(t))}lt(e,t){return this.setLimit("max",e,!1,K.toString(t))}setLimit(e,t,a,s){return new Dt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:K.toString(s)}]})}_addCheck(e){return new Dt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:K.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:K.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:K.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.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)}}Dt.create=r=>new Dt({checks:[],typeName:re.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Ot 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 Ye;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),U(a,{code:P.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),U(a,{code:P.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),U(a,{code:P.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 U(t,{code:P.invalid_type,expected:W.bigint,received:t.parsedType}),ee}gte(e,t){return this.setLimit("min",e,!0,K.toString(t))}gt(e,t){return this.setLimit("min",e,!1,K.toString(t))}lte(e,t){return this.setLimit("max",e,!0,K.toString(t))}lt(e,t){return this.setLimit("max",e,!1,K.toString(t))}setLimit(e,t,a,s){return new Ot({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:K.toString(s)}]})}_addCheck(e){return new Ot({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:K.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}}Ot.create=r=>new Ot({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 U(a,{code:P.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 U(i,{code:P.invalid_type,expected:W.date,received:i.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_date}),ee}const a=new Ye;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),U(s,{code:P.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),U(s,{code:P.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:K.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:K.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 U(a,{code:P.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 U(a,{code:P.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 U(a,{code:P.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 U(t,{code:P.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 U(a,{code:P.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 U(t,{code:P.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)&&(U(t,{code:c?P.too_big:P.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&&(U(t,{code:P.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&&(U(t,{code:P.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=>Ye.mergeArray(a,c));const i=[...t.data].map((c,f)=>s.type._parseSync(new vt(t,c,t.path,f)));return Ye.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new dt({...this._def,minLength:{value:e,message:K.toString(t)}})}max(e,t){return new dt({...this._def,maxLength:{value:e,message:K.toString(t)}})}length(e,t){return new dt({...this._def,exactLength:{value:e,message:K.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 Vt(r){if(r instanceof Ie){const e={};for(const t in r.shape){const a=r.shape[t];e[t]=gt.create(Vt(a))}return new Ie({...r._def,shape:()=>e})}else return r instanceof dt?new dt({...r._def,type:Vt(r.element)}):r instanceof gt?gt.create(Vt(r.unwrap())):r instanceof Ct?Ct.create(Vt(r.unwrap())):r instanceof bt?bt.create(r.items.map(e=>Vt(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 k=this._getOrReturnCtx(e);return U(k,{code:P.invalid_type,expected:W.object,received:k.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 k in s.data)c.includes(k)||f.push(k);const b=[];for(const k of c){const M=i[k],S=s.data[k];b.push({key:{status:"valid",value:k},value:M._parse(new vt(s,S,s.path,k)),alwaysSet:k in s.data})}if(this._def.catchall instanceof Et){const k=this._def.unknownKeys;if(k==="passthrough")for(const M of f)b.push({key:{status:"valid",value:M},value:{status:"valid",value:s.data[M]}});else if(k==="strict")f.length>0&&(U(s,{code:P.unrecognized_keys,keys:f}),a.dirty());else if(k!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const k=this._def.catchall;for(const M of f){const S=s.data[M];b.push({key:{status:"valid",value:M},value:k._parse(new vt(s,S,s.path,M)),alwaysSet:M in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const k=[];for(const M of b){const S=await M.key,x=await M.value;k.push({key:S,value:x,alwaysSet:M.alwaysSet})}return k}).then(k=>Ye.mergeObjectSync(a,k)):Ye.mergeObjectSync(a,b)}get shape(){return this._def.shape()}strict(e){return K.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:K.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 Vt(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 wn(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 U(t,{code:P.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 k={...t,common:{...t.common,issues:[]},parent:null},M=b._parseSync({data:t.data,path:t.path,parent:k});if(M.status==="valid")return M;M.status==="dirty"&&!i&&(i={result:M,ctx:k}),k.common.issues.length&&c.push(k.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(b=>new at(b));return U(t,{code:P.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 Pt?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 Ct?[null,...xt(r.unwrap())]:r instanceof Ur||r instanceof hr?xt(r.unwrap()):r instanceof dr?xt(r._def.innerType):[];class Or extends ce{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.object)return U(t,{code:P.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}):(U(t,{code:P.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 Or({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}):(U(a,{code:P.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 U(a,{code:P.invalid_type,expected:W.array,received:a.parsedType}),ee;if(a.data.length<this._def.items.length)return U(a,{code:P.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&a.data.length>this._def.items.length&&(U(a,{code:P.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=>Ye.mergeArray(t,c)):Ye.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 U(a,{code:P.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?Ye.mergeObjectAsync(t,s):Ye.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 U(a,{code:P.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],k)=>({key:s._parse(new vt(a,f,a.path,[k,"key"])),value:i._parse(new vt(a,b,a.path,[k,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const b of c){const k=await b.key,M=await b.value;if(k.status==="aborted"||M.status==="aborted")return ee;(k.status==="dirty"||M.status==="dirty")&&t.dirty(),f.set(k.value,M.value)}return{status:t.value,value:f}})}else{const f=new Map;for(const b of c){const k=b.key,M=b.value;if(k.status==="aborted"||M.status==="aborted")return ee;(k.status==="dirty"||M.status==="dirty")&&t.dirty(),f.set(k.value,M.value)}return{status:t.value,value:f}}}}Ar.create=(r,e,t)=>new Ar({valueType:e,keyType:r,typeName:re.ZodMap,...ie(t)});class Bt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.set)return U(a,{code:P.invalid_type,expected:W.set,received:a.parsedType}),ee;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(U(a,{code:P.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&&(U(a,{code:P.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 k=new Set;for(const M of b){if(M.status==="aborted")return ee;M.status==="dirty"&&t.dirty(),k.add(M.value)}return{status:t.value,value:k}}const f=[...a.data.values()].map((b,k)=>i._parse(new vt(a,b,a.path,k)));return a.common.async?Promise.all(f).then(b=>c(b)):c(f)}min(e,t){return new Bt({...this._def,minSize:{value:e,message:K.toString(t)}})}max(e,t){return new Bt({...this._def,maxSize:{value:e,message:K.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Bt.create=(r,e)=>new Bt({valueType:r,minSize:null,maxSize:null,typeName:re.ZodSet,...ie(e)});class Ht extends ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.function)return U(t,{code:P.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(),qt].filter(k=>!!k),issueData:{code:P.invalid_arguments,argumentsError:b}})}function s(f,b){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),qt].filter(k=>!!k),issueData:{code:P.invalid_return_type,returnTypeError:b}})}const i={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof Kt){const f=this;return Je(async function(...b){const k=new at([]),M=await f._def.args.parseAsync(b,i).catch(E=>{throw k.addIssue(a(b,E)),k}),S=await Reflect.apply(c,this,M);return await f._def.returns._def.type.parseAsync(S,i).catch(E=>{throw k.addIssue(s(S,E)),k})})}else{const f=this;return Je(function(...b){const k=f._def.args.safeParse(b,i);if(!k.success)throw new at([a(b,k.error)]);const M=Reflect.apply(c,this,k.data),S=f._def.returns.safeParse(M,i);if(!S.success)throw new at([s(M,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ht({...this._def,args:bt.create(e).rest(It.create())})}returns(e){return new Ht({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new Ht({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 U(t,{received:t.data,code:P.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 wn(r,e){return new Pt({values:r,typeName:re.ZodEnum,...ie(e)})}class Pt extends ce{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return U(t,{expected:be.joinValues(a),received:t.parsedType,code:P.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 U(t,{received:t.data,code:P.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 Pt.create(e,{...this._def,...t})}exclude(e,t=this._def){return Pt.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Pt.create=wn;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 U(a,{expected:be.joinValues(s),received:a.parsedType,code:P.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 U(a,{received:a.data,code:P.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 Kt 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 U(t,{code:P.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})))}}Kt.create=(r,e)=>new Kt({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=>{U(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"?zt(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"?zt(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 Ct extends ce{_parse(e){return this._getType(e)===W.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ct.create=(r,e)=>new Ct({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 U(a,{code:P.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 Ur 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(),zt(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 fn(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function kn(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=fn(e,a),b=f.fatal??t??!0;s.addIssue({code:"custom",...f,fatal:b})}});if(!i){const c=fn(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}`})=>kn(t=>t instanceof r,e),Fe=ft.create,Yt=Dt.create,ca=Sr.create,ua=Ot.create,Ut=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=Or.create,xa=ir.create,_a=bt.create,Ea=or.create,Ta=Ar.create,Aa=Bt.create,Sa=Ht.create,Da=cr.create,Oa=ur.create,xn=Pt.create,$r=lr.create,Pa=Kt.create,dn=ht.create,Ca=gt.create,Na=Ct.create,Ra=ht.createWithPreprocess,Ma=pr.create,Ia=()=>Fe().optional(),ja=()=>Yt().optional(),Fa=()=>Ut().optional(),Br={string:(r=>ft.create({...r,coerce:!0})),number:(r=>Dt.create({...r,coerce:!0})),boolean:(r=>rr.create({...r,coerce:!0})),bigint:(r=>Ot.create({...r,coerce:!0})),date:(r=>Ft.create({...r,coerce:!0}))},Ba=ee,O=Object.freeze(Object.defineProperty({__proto__:null,BRAND:sa,DIRTY:zt,EMPTY_PATH:Fn,INVALID:ee,NEVER:Ba,OK:Je,ParseStatus:Ye,Schema:ce,ZodAny:Gt,ZodArray:dt,ZodBigInt:Ot,ZodBoolean:rr,ZodBranded:Ur,ZodCatch:dr,ZodDate:Ft,ZodDefault:fr,ZodDiscriminatedUnion:Or,ZodEffects:ht,ZodEnum:Pt,ZodError:at,get ZodFirstPartyTypeKind(){return re},ZodFunction:Ht,ZodIntersection:ir,ZodIssueCode:P,ZodLazy:cr,ZodLiteral:ur,ZodMap:Ar,ZodNaN:Sr,ZodNativeEnum:lr,ZodNever:Et,ZodNull:ar,ZodNullable:Ct,ZodNumber:Dt,ZodObject:Ie,ZodOptional:gt,ZodParsedType:W,ZodPipeline:pr,ZodPromise:Kt,ZodReadonly:hr,ZodRecord:or,ZodSchema:ce,ZodSet:Bt,ZodString:ft,ZodSymbol:Er,ZodTransformer:ht,ZodTuple:bt,ZodType:ce,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:It,ZodVoid:Tr,addIssueToContext:U,any:pa,array:va,bigint:ua,boolean:Ut,coerce:Br,custom:kn,date:la,datetimeRegex:bn,defaultErrorMap:qt,discriminatedUnion:ka,effect:dn,enum:xn,function:Sa,getErrorMap:xr,getParsedType:_t,instanceof:oa,intersection:xa,isAborted:Ir,isAsync:tr,isDirty:jr,isValid:jt,late:ia,lazy:Da,literal:Oa,makeIssue:_r,map:Ta,nan:ca,nativeEnum:$r,never:ya,null:ha,nullable:Na,number:Yt,object:Nt,get objectUtil(){return Mr},oboolean:Fa,onumber:ja,optional:Ca,ostring:Ia,pipeline:Ma,preprocess:Ra,promise:Pa,quotelessJson:In,record:Ea,set:Aa,setErrorMap:jn,strictObject:ba,string:Fe,symbol:fa,transformer:dn,tuple:_a,undefined:da,union:wa,unknown:ma,get util(){return be},void:ga},Symbol.toStringTag,{value:"Module"})),pt=Nt({name:Fe(),selector:Fe(),findBy:xn(["cssSelector","xpath"]),option:Nt({waitForSelector:Ut().optional(),waitSelectorTimeout:Yt().optional(),multiple:Ut().optional()})}),Ua=O.object({type:O.literal("object"),shape:O.record(O.string(),O.any())}),$a=O.object({type:O.literal("array"),items:O.any()}),La=O.discriminatedUnion("type",[Ua,$a]),Lr=O.object({name:O.literal("ai-parse-data"),sourceData:O.any().optional(),schemaDefinition:La,prompt:O.string().optional(),model:O.string().optional(),apiKey:O.string().min(1,"OpenAI API key is required")});function Za(r){return Lr.parse(r)}async function Wa(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 Va(r){return{type:"object",shape:r}}function za(r){return{type:"array",items:r}}const Ha={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 Pr{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 qa extends Pr{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 k;return((k=b.textContent)==null?void 0:k.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class Ga extends Pr{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(k=>k.trim());if(c.length!==2)return null;const f=c[0],b=c[1];if(!f||!b)return null;try{const k=t.querySelector(f);if(!k||!k.contentDocument)return null;const M=k.contentDocument;return i?Array.from(M.querySelectorAll(b)):M.querySelector(b)}catch(k){return console.error("Iframe Selector error:",k),null}}}class Ka extends Pr{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 k=c[b],M=b===c.length-1;if(!k)return null;if(M&&i)return Array.from(f.querySelectorAll(k));const S=f.querySelector(k);if(!S)return null;if(M)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 Ya extends Pr{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 k=c.snapshotItem(b);k&&k.nodeType===Node.ELEMENT_NODE&&f.push(k)}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 Ja{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=Xa(t,a);return i?f.waitForElement(r,e,c):f.find(r,e)}function Xa(r,e){return e==="xpath"?new Ya:r.includes(">>")?new Ka:r.includes("|>")?new Ga:new qa}const Zr=pt.extend({name:O.literal("get-text"),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),filterEmpty:O.boolean().optional(),scrollToCollect:O.boolean().optional(),scrollDistance:O.number().optional(),scrollWaitMs:O.number().optional(),maxScrollAttempts:O.number().optional()});function Qa(r){return Zr.parse(r)}async function es(r){try{const{selector:e="",includeTags:t=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:b,filterEmpty:k=!0,scrollToCollect:M=!1,scrollDistance:S=500,scrollWaitMs:x=300,maxScrollAttempts:E=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(M&&(b!=null&&b.multiple))return await ts({selector:e,findBy:f,option:b,includeTags:t,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:k,scrollDistance:S,scrollWaitMs:x,maxScrollAttempts:E});const I=await mt({selector:e,findBy:f,option:b});if(!I)return{data:""};const se=_n(t,a,s,i,c);if(Array.isArray(I)){const me=I.map(se);return{data:k?me.filter(q=>q.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 ts(r){const{selector:e,findBy:t,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:b,filterEmpty:k,scrollDistance:M,scrollWaitMs:S,maxScrollAttempts:x}=r,E=_n(s,i,c,f,b),I=new Set;let se=0,me=0;const ge=5;for(;se<x;){const q=await mt({selector:e,findBy:t,option:a});if(q&&Array.isArray(q)){const L=I.size;if(q.forEach($=>{const V=E($);(!k||V.trim()!=="")&&I.add(V)}),I.size===L){if(me++,me>=ge)break}else me=0}const N=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:M,behavior:"auto"}),await new Promise(L=>setTimeout(L,S)),(window.pageYOffset||document.documentElement.scrollTop)===N)break;se++}return{data:Array.from(I)}}function _n(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:O.literal("attribute-value"),attributeName:O.string()});function rs(r){return Wr.parse(r)}async function ns(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 Vr=pt.extend({name:O.literal("get-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function as(r){return Vr.parse(r)}async function ss(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:is(s,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function is(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 zr=pt.extend({name:O.literal("set-value-form"),setValue:O.string(),type:O.enum(["text-field","select","checkbox"]).optional()});function os(r){return zr.parse(r)}async function cs(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 us(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 us(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 Hr=pt.extend({name:O.literal("clear-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function ls(r){return Hr.parse(r)}async function fs(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 ds(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 ds(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 qr=pt.extend({name:O.literal("element-exists")});function hs(r){return qr.parse(r)}async function ps(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:O.literal("event-click"),textFilter:O.object({text:O.union([O.string(),O.array(O.string())]),mode:O.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function ms(r){return Gr.parse(r)}async function ys(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=gs(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 bs(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 gs(r,e,t){for(const a of r){const s=vs(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 vs(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 bs(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 Kr=O.object({name:O.literal("keypress"),key:O.string(),code:O.string().optional(),keyCode:O.number().optional(),modifiers:O.array(O.enum(["Alt","Control","Meta","Shift"])).optional()});function ws(r){return Kr.parse(r)}async function ks(r){try{const{key:e,code:t,keyCode:a,modifiers:s=[]}=r;return await xs(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 xs(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,...hn(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...hn(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 hn(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Yr=O.object({name:O.literal("wait"),duration:O.number().min(0)});function _s(r){return Yr.parse(r)}async function Es(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=O.object({name:O.literal("wait-for-condition"),conditions:O.object({urlPattern:O.string().optional(),elementExists:O.object({selector:O.string(),findBy:O.enum(["cssSelector","xpath"])}).optional(),cookieExists:O.string().optional(),storageKey:O.object({type:O.enum(["localStorage","sessionStorage"]),key:O.string()}).optional(),userConfirmation:O.boolean().optional(),message:O.string().optional(),buttonText:O.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:O.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:O.number().min(100).optional(),timeoutMs:O.number().min(1e3).optional(),position:O.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Ts(r){return Jr.parse(r)}async function As(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,k=null;(t==="manual"||t==="auto-or-manual")&&f&&(b=new Promise(S=>{k=S}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:k}})));const M=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:x}=e.elementExists;let E=null;if(x==="cssSelector"?E=document.querySelector(S):x==="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:x}=e.storageKey;if((S==="localStorage"?window.localStorage:window.sessionStorage).getItem(x)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${S}.${x}`}}return null};return new Promise(S=>{let x=null,E=!1;const I=()=>{x&&(clearInterval(x),x=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&&(x=setInterval(async()=>{const ge=await M();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=O.object({name:O.literal("navigate"),url:O.string().url("Valid URL is required"),waitForLoad:O.boolean().optional(),timeout:O.number().min(0).optional()});function Ss(r){return Xr.parse(r)}async function Ds(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:O.literal("save-assets")});function Os(r){return Qr.parse(r)}async function Ps(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 Cs{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:O.literal("get-element-data"),includeText:O.boolean().optional(),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),attributes:O.array(O.string()).optional(),includeSelector:O.boolean().optional(),includeXPath:O.boolean().optional()});function Ns(r){return en.parse(r)}async function Rs(r){try{const{selector:e="",includeText:t=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:b=[],includeSelector:k=!1,includeXPath:M=!1,findBy:S="cssSelector",option:x}=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:x});if(!E)return{data:Array.isArray(E)?[]:{}};const I=Ms(t,a,s,i,c,f,b,k,M);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 Ms(r,e,t,a,s="",i="",c=[],f=!1,b=!1){return k=>{const M={};if(r){let S="";if(e?S=k.innerHTML:S=t?k.textContent||"":k.innerText||"",a){const x=new RegExp(a,"g"),E=S.match(x);S=E?E.join(" "):""}S.trim()&&(S=s+S.trim()+i),M.text=S}return c.length>0&&(M.attributes={},c.forEach(S=>{let x=k.getAttribute(S);if(x===null){const E=k.querySelector(`[${S}]`);E&&(x=E.getAttribute(S))}M.attributes[S]=x})),f&&(M.selector=Ja.generate(k)),b&&(M.xpath=Cs.generate(k)),M}}const tn=pt.extend({name:O.literal("scroll"),scrollType:O.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:O.number().optional(),behavior:O.enum(["auto","smooth"]).optional(),maxScrolls:O.number().optional(),waitAfterScroll:O.number().optional()});function Is(r){return tn.parse(r)}async function js(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 Fs(e,f,b,s);case"toBottom":return await Bs(s,c);case"byDistance":return await Us(a,s);case"untilLoaded":return await $s(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 Fs(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 Bs(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 Us(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function $s(r,e,t,a){let s=0,i=document.body.scrollHeight;for(;s<r;){window.scrollBy({top:e,behavior:t}),await new Promise(k=>setTimeout(k,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=O.object({name:O.literal("fetch-api"),url:O.string(),method:O.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:O.record(O.string(),O.string()).optional(),body:O.record(O.string(),O.any()).optional(),timeout:O.number().min(0).optional(),parseJson:O.boolean().optional(),returnHeaders:O.boolean().optional()});function Ls(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 pn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ws(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 Rr={exports:{}},mn;function Vs(){return mn||(mn=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function(){function t(a,s,i){function c(k,M){if(!s[k]){if(!a[k]){var S=typeof kr=="function"&&kr;if(!M&&S)return S(k,!0);if(f)return f(k,!0);var x=new Error("Cannot find module '"+k+"'");throw x.code="MODULE_NOT_FOUND",x}var E=s[k]={exports:{}};a[k][0].call(E.exports,function(I){var se=a[k][1][I];return c(se||I)},E,E.exports,t,a,s,i)}return s[k].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"],k=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],M=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function x(v,A){var w=function(B,j,D){var F="";if(B<=19)F=(j?" and ":"")+(D?k[B]:b[B]);else if(B<100){const ye=Math.floor(B/10),we=B%10;F=(j?" and ":"")+M[ye-2],we>0?F+="-"+w(we,!1,D):D&&(F=F.substring(0,F.length-1)+"ieth")}else if(B<1e3){const ye=Math.floor(B/100),we=B%100;F=(j?", ":"")+b[ye]+" Hundred",we>0?F+=w(we,!0,D):D&&(F+="th")}else{var J=Math.floor(Math.log10(B)/3);J>S.length&&(J=S.length);const ye=Math.pow(10,J*3),we=Math.floor(B/ye),Y=B-we*ye;F=(j?", ":"")+w(we,!1,!1)+" "+S[J-1],Y>0?F+=w(Y,!0,D):D&&(F+="th")}return F},C=w(v,!1,A);return C}const E={};b.forEach(function(v,A){E[v.toLowerCase()]=A}),k.forEach(function(v,A){E[v.toLowerCase()]=A}),M.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(),C=Math.pow(10,(A+1)*3);E[w]=C,E[w+"th"]=C});function I(v){const w=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>E[j]);let C=[0];return w.forEach(j=>{if(j<100){let D=C.pop();D>=1e3&&(C.push(D),D=0),C.push(D+j)}else C.push(C.pop()*j)}),C.reduce((j,D)=>j+D,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 q(v){for(var A=0,w=1,C=v.length-1;C>=0;C--){const B=v[C],j=me[B];j<w?A-=j:(w=j,A+=j)}return A}function N(v,A){for(var w=[],C=A.charCodeAt(0);v>0;)w.unshift(String.fromCharCode((v-1)%26+C)),v=Math.floor((v-1)/26);return w.join("")}function ne(v,A){for(var w=A.charCodeAt(0),C=0,B=0;B<v.length;B++)C+=(v.charCodeAt(v.length-B-1)-w+1)*Math.pow(26,B);return C}function L(v,A){if(typeof v>"u")return;v=Math.floor(v);const w=xe(A);return V(v,w)}const T={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},$={UPPER:"upper",LOWER:"lower",TITLE:"title"};function V(v,A){let w;const C=v<0;switch(v=Math.abs(v),A.primary){case T.LETTERS:w=N(v,A.case===$.UPPER?"A":"a");break;case T.ROMAN:w=ge(v),A.case===$.UPPER&&(w=w.toUpperCase());break;case T.WORDS:w=x(v,A.ordinal),A.case===$.UPPER?w=w.toUpperCase():A.case===$.LOWER&&(w=w.toLowerCase());break;case T.DECIMAL:w=""+v;var B=A.mandatoryDigits-w.length;if(B>0){var j=new Array(B+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 Y=w.length-we*A.groupingSeparators.position;w=w.substr(0,Y)+A.groupingSeparators.character+w.substr(Y)}}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 D={1:"st",2:"nd",3:"rd"},F=w[w.length-1],J=D[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 C&&(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:$.LOWER,ordinal:!1};let w,C;const B=v.lastIndexOf(";");switch(B===-1?w=v:(w=v.substring(0,B),C=v.substring(B+1),C[0]==="o"&&(A.ordinal=!0)),w){case"A":A.case=$.UPPER;case"a":A.primary=T.LETTERS;break;case"I":A.case=$.UPPER;case"i":A.primary=T.ROMAN;break;case"W":A.case=$.UPPER,A.primary=T.WORDS;break;case"Ww":A.case=$.TITLE,A.primary=T.WORDS;break;case"w":A.primary=T.WORDS;break;default:{let j=null,D=0,F=0,J=[],ye=0;if(f(w).map(Y=>Y.codePointAt(0)).reverse().forEach(Y=>{let Q=!1;for(let he=0;he<de.length;he++){const G=de[he];if(Y>=G&&Y<=G+9){if(Q=!0,D++,ye++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}Q||(Y===35?(ye++,F++):J.push({position:ye,character:String.fromCodePoint(Y)}))}),D>0){A.primary=T.DECIMAL,A.zeroCode=j,A.mandatoryDigits=D,A.optionalDigits=F;const Q=function(he){if(he.length===0)return 0;const G=he[0].character;for(let $e=1;$e<he.length;$e++)if(he[$e].character!==G)return 0;const Ze=he.map($e=>$e.position),it=function($e,qe){return qe===0?$e:it(qe,$e%qe)},He=Ze.reduce(it);for(let $e=1;$e<=Ze.length;$e++)if(Ze.indexOf($e*He)===-1)return 0;return He}(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},C=function(Q,he){if(he>Q){let G=v.substring(Q,he);G=G.split("]]").join("]"),A.push({type:"literal",value:G})}};for(var B=0,j=0;j<v.length;){if(v.charAt(j)==="["){if(v.charAt(j+1)==="["){C(B,j),A.push({type:"literal",value:"["}),j+=2,B=j;continue}if(C(B,j),B=j,j=v.indexOf("]",B),j===-1)throw{code:"D3135"};let Q=v.substring(B+1,j);Q=Q.split(/\s+/).join("");var D={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 He=function(qe){if(!(typeof qe>"u"||qe==="*"))return parseInt(qe)};G===-1?Ze=he:(Ze=he.substring(0,G),it=he.substring(G+1));const $e={min:He(Ze),max:He(it)};D.width=$e,J=Q.substring(1,F)}else J=Q.substring(1);if(J.length===1)D.presentation1=J;else if(J.length>1){var ye=J.charAt(J.length-1);"atco".indexOf(ye)!==-1?(D.presentation2=ye,ye==="o"&&(D.ordinal=!0),D.presentation1=J.substring(0,J.length-1)):D.presentation1=J}else D.presentation1=Te[D.component];if(typeof D.presentation1>"u")throw{code:"D3132",value:D.component};if(D.presentation1[0]==="n")D.names=$.LOWER;else if(D.presentation1[0]==="N")D.presentation1[1]==="n"?D.names=$.TITLE:D.names=$.UPPER;else if("YMDdFWwXxHhmsf".indexOf(D.component)!==-1){var we=D.presentation1;if(D.presentation2&&(we+=";"+D.presentation2),D.integerFormat=xe(we),D.width&&D.width.min!==void 0&&D.integerFormat.mandatoryDigits<D.width.min&&(D.integerFormat.mandatoryDigits=D.width.min),D.component==="Y")if(D.n=-1,D.width&&D.width.max!==void 0)D.n=D.width.max,D.integerFormat.mandatoryDigits=D.n;else{var Y=D.integerFormat.mandatoryDigits+D.integerFormat.optionalDigits;Y>=2&&(D.n=Y)}const he=A[A.length-1];he&&he.integerFormat&&(he.integerFormat.parseWidth=he.integerFormat.mandatoryDigits)}(D.component==="Z"||D.component==="z")&&(D.integerFormat=xe(D.presentation1)),A.push(D),B=j+1}j++}return C(B,j),w}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Re=["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 C=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),B=Date.UTC(v.getUTCFullYear(),0);w=(C-B)/et+1;break}case"F":w=v.getUTCDay(),w===0&&(w=7);break;case"W":{const C=ue(v.getUTCFullYear(),0),B=_e(C),j=Date.UTC(C.year,v.getUTCMonth(),v.getUTCDate());let D=tt(B,j);if(D>52){const F=_e(C.nextYear());j>=F&&(D=1)}else if(D<1){const F=_e(C.previousYear());D=tt(F,j)}w=Math.floor(D);break}case"w":{const C=ue(v.getUTCFullYear(),v.getUTCMonth()),B=_e(C),j=Date.UTC(C.year,C.month,v.getUTCDate());let D=tt(B,j);if(D>4){const F=_e(C.nextMonth());j>=F&&(D=1)}else if(D<1){const F=_e(C.previousMonth());D=tt(F,j)}w=Math.floor(D);break}case"X":{const C=ue(v.getUTCFullYear(),0),B=_e(C),j=_e(C.nextYear()),D=v.getTime();D<B?w=C.year-1:D>=j?w=C.year+1:w=C.year;break}case"x":{const C=ue(v.getUTCFullYear(),v.getUTCMonth()),B=_e(C),j=C.nextMonth(),D=_e(j),F=v.getTime();F<B?w=C.previousMonth().month+1:F>=D?w=j.month+1:w=C.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 Be=null;function st(v,A,w){var C=0,B=0;if(typeof w<"u"){const we=parseInt(w);C=Math.floor(we/100),B=we%100}var j=function(we,Y){var Q=ae(we,Y.component);if("YMDdFWwXxHhms".indexOf(Y.component)!==-1)if(Y.component==="Y"&&Y.n!==-1&&(Q=Q%Math.pow(10,Y.n)),Y.names){if(Y.component==="M"||Y.component==="x")Q=Re[Q-1];else if(Y.component==="F")Q=ve[Q];else throw{code:"D3133",value:Y.component};Y.names===$.UPPER?Q=Q.toUpperCase():Y.names===$.LOWER&&(Q=Q.toLowerCase()),Y.width&&Q.length>Y.width.max&&(Q=Q.substring(0,Y.width.max))}else Q=V(Q,Y.integerFormat);else if(Y.component==="f")Q=V(Q,Y.integerFormat);else if(Y.component==="Z"||Y.component==="z"){const he=C*100+B;if(Y.integerFormat.regular)Q=V(he,Y.integerFormat);else{const G=Y.integerFormat.mandatoryDigits;if(G===1||G===2)Q=V(C,Y.integerFormat),B!==0&&(Q+=":"+L(B,"00"));else if(G===3||G===4)Q=V(he,Y.integerFormat);else throw{code:"D3134",value:G}}he>=0&&(Q="+"+Q),Y.component==="z"&&(Q="GMT"+Q),he===0&&Y.presentation2==="t"&&(Q="Z")}else Y.component==="P"&&Y.names===$.UPPER&&(Q=Q.toUpperCase());return Q};let D;typeof A>"u"?(Be===null&&(Be=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),D=Be):D=Ae(A);const F=(60*C+B)*60*1e3,J=new Date(v+F);let ye="";return D.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 C={};if(w.type==="literal")C.regex=w.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(w.component==="Z"||w.component==="z"){let j;Array.isArray(w.integerFormat.groupingSeparators)||(j=w.integerFormat.groupingSeparators),C.regex="",w.component==="z"&&(C.regex="GMT"),C.regex+="[-+][0-9]+",j&&(C.regex+=j.character+"[0-9]+"),C.parse=function(D){w.component==="z"&&(D=D.substring(3));let F=0,J=0;return j?(F=Number.parseInt(D.substring(0,D.indexOf(j.character))),J=Number.parseInt(D.substring(D.indexOf(j.character)+1))):D.length-1<=2?F=Number.parseInt(D):(F=Number.parseInt(D.substring(0,3)),J=Number.parseInt(D.substring(3))),F*60+J}}else if(w.integerFormat)C=d(w.integerFormat);else{C.regex="[a-zA-Z]+";var B={};if(w.component==="M"||w.component==="x")Re.forEach(function(j,D){w.width&&w.width.max?B[j.substring(0,w.width.max)]=D+1:B[j]=D+1});else if(w.component==="F")ve.forEach(function(j,D){D>0&&(w.width&&w.width.max?B[j.substring(0,w.width.max)]=D:B[j]=D)});else if(w.component==="P")B={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:w.component};C.parse=function(j){return B[j]}}return C.component=w.component,C});else{A.type="integer";const w=v.case===$.UPPER;switch(v.primary){case T.LETTERS:A.regex=w?"[A-Z]+":"[a-z]+",A.parse=function(C){return ne(C,w?"A":"a")};break;case T.ROMAN:A.regex=w?"[MDCLXVI]+":"[mdclxvi]+",A.parse=function(C){return q(w?C:C.toUpperCase())};break;case T.WORDS:A.regex="(?:"+Object.keys(E).concat("and","[\\-, ]").join("|")+")+",A.parse=function(C){return I(C.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(C){let B=C;return v.ordinal&&(B=C.substring(0,C.length-2)),v.regular?B=B.split(",").join(""):v.groupingSeparators.forEach(j=>{B=B.split(j.character).join("")}),v.zeroCode!==48&&(B=B.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-v.zeroCode+48)).join("")),parseInt(B)};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 z(v,A){const w=Ae(A),C=d(w),B="^"+C.parts.map(J=>"("+J.regex+")").join("")+"$";var D=new RegExp(B,"i").exec(v);if(D!==null){const G={};for(let De=1;De<D.length;De++){const u=C.parts[De-1];u.parse&&(G[u.component]=u.parse(D[De]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ze=0;const it=De=>{Ze<<=1,Ze+=De?1:0},He=De=>!(~De&Ze)&&!!(De&Ze);"YXMxWwdD".split("").forEach(De=>it(G[De]));const qe=!He(161)&&He(130),wt=He(84),Tt=!wt&&He(72);Ze=0,"PHhmsf".split("").forEach(De=>it(G[De]));const At=!He(23)&&He(47),Jt=(qe?"YD":wt?"XxwF":Tt?"XWF":"YMD")+(At?"Phmsf":"Hmsf"),ut=this.environment.timestamp;let $t=!1,yt=!1;if(Jt.split("").forEach(De=>{if(typeof G[De]>"u")$t?(G[De]="MDd".indexOf(De)!==-1?1:0,yt=!0):G[De]=ae(ut,De);else if($t=!0,yt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,qe){const De=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(De+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 Pe(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 z.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:Pe}})();a.exports=c},{"./utils":6}],2:[function(t,a,s){(function(i){(function(){var c=t("./utils");const f=(()=>{var b=c.isNumeric,k=c.isArrayOfStrings,M=c.isArrayOfNumbers,S=c.createSequence,x=c.isSequence,E=c.isFunction,I=c.isLambda,se=c.isPromise,me=c.getFunctionArity,ge=c.isDeepEqual,q=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 $(n){if(!(typeof n>"u"||n.length===0)){var o=0;return n.forEach(function(l){o+=l}),o/n.length}}function V(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,_){return typeof _<"u"&&_!==null&&_.toPrecision&&b(_)?Number(_.toPrecision(15)):_&&E(_)?"":_},g)}return l}}function de(n,o,l){if(!(typeof n>"u")){var g=q(n),p=g.length;if(p+o<0&&(o=0),typeof l<"u"){if(l<=0)return"";var _=o>=0?o+l:p+o+l;return g.slice(o,_).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 Re(n){if(!(typeof n>"u"))return q(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)-Re(n);if(p>0){var _=new Array(p+1).join(l);l.length>1&&(_=de(_,0,p)),o>0?g=n+_:g=_+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,_=await ue(o,n);if(typeof _<"u")for(;typeof _<"u"&&(typeof l>"u"||p<l);)g.push({match:_.match,index:_.start,groups:_.groups}),_=await ue(_.next),p++}return g}}async function Be(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 _;typeof l=="string"?_=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 Ve;if(Se.groups.length===0?Ve=1:Ve=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,je=parseInt(l.substring(ke,ke+Ve),10),Ve>1&&je>Se.groups.length&&(je=parseInt(l.substring(ke,ke+Ve-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}:_=l;var R="",H=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var Oe=n.indexOf(o,H);Oe!==-1&&(typeof g>"u"||X<g);)R+=n.substring(H,Oe),R+=l,H=Oe+o.length,X++,Oe=n.indexOf(o,H);R+=n.substring(H)}else{var pe=await ue(o,n);if(typeof pe<"u"){for(;typeof pe<"u"&&(typeof g>"u"||X<g);){R+=n.substring(H,pe.start);var Ce=_.apply(p,[pe]);if(se(Ce)&&(Ce=await Ce),typeof Ce=="string")R+=Ce;else throw{code:"D3012",stack:new Error().stack,value:Ce};H=pe.start+pe.match.length,X++,pe=await ue(pe.next)}R+=n.substring(H)}else R=n}}else R=n;return R}}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 z(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 Pe(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,_=await ue(o,n);if(typeof _<"u"){for(var R=0;typeof _<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(R,_.start)),R=_.end,_=await ue(_.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(R))}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 _=[],R=p["zero-digit"].charCodeAt(0),H=R;H<R+10;H++)_.push(String.fromCharCode(H));var X=_.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),Oe=o.split(p["pattern-separator"]);if(Oe.length>2)throw{code:"D3080",stack:new Error().stack};var pe=function(te){var Me=(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)})(),Ke=(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(Me.length,te.length-Ke.length),Xe,St,Qe,Mt,rt=te.indexOf(p["exponent-separator"],Me.length);rt===-1||rt>te.length-Ke.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,Mt=Ke):(Qe=Xe.substring(0,lt),Mt=Xe.substring(lt+1)),{prefix:Me,suffix:Ke,activePart:Ne,mantissaPart:Xe,exponentPart:St,integerPart:Qe,fractionalPart:Mt,subpicture:te}},Ce=function(te){var Me,Ke,Ne=te.subpicture,Xe=Ne.indexOf(p["decimal-separator"]);Xe!==Ne.lastIndexOf(p["decimal-separator"])&&(Me="D3081"),Ne.indexOf(p.percent)!==Ne.lastIndexOf(p.percent)&&(Me="D3082"),Ne.indexOf(p["per-mille"])!==Ne.lastIndexOf(p["per-mille"])&&(Me="D3083"),Ne.indexOf(p.percent)!==-1&&Ne.indexOf(p["per-mille"])!==-1&&(Me="D3084");var St=!1;for(Ke=0;Ke<te.mantissaPart.length;Ke++){var Qe=te.mantissaPart.charAt(Ke);if(_.indexOf(Qe)!==-1||Qe===p.digit){St=!0;break}}St||(Me="D3085");var Mt=te.activePart.split("").map(function(Le){return X.indexOf(Le)===-1?"p":"a"}).join("");Mt.indexOf("p")!==-1&&(Me="D3086"),Xe!==-1?(Ne.charAt(Xe-1)===p["grouping-separator"]||Ne.charAt(Xe+1)===p["grouping-separator"])&&(Me="D3087"):te.integerPart.charAt(te.integerPart.length-1)===p["grouping-separator"]&&(Me="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Me="D3089");var rt=te.integerPart.indexOf(p.digit);rt!==-1&&te.integerPart.substring(0,rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3090"),rt=te.fractionalPart.lastIndexOf(p.digit),rt!==-1&&te.fractionalPart.substring(rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3091");var lt=typeof te.exponentPart=="string";if(lt&&te.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Me="D3092"),lt&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function(Le){return _.indexOf(Le)===-1}).length>0)&&(Me="D3093"),Me)throw{code:Me,stack:new Error().stack}},Se=function(te){var Me=function(ze,br){for(var er=[],kt=ze.indexOf(p["grouping-separator"]);kt!==-1;){var wr=(br?ze.substring(0,kt):ze.substring(kt)).split("").filter(function(Wt){return _.indexOf(Wt)!==-1||Wt===p.digit}).length;er.push(wr),kt=te.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ke=Me(te.integerPart),Ne=function(ze){if(ze.length===0)return 0;for(var br=function(wr,Wt){return Wt===0?wr:br(Wt,wr%Wt)},er=ze.reduce(br),kt=1;kt<=ze.length;kt++)if(ze.indexOf(kt*er)===-1)return 0;return er},Xe=Ne(Ke),St=Me(te.fractionalPart,!0),Qe=te.integerPart.split("").filter(function(ze){return _.indexOf(ze)!==-1}).length,Mt=Qe,rt=te.fractionalPart.split(""),lt=rt.filter(function(ze){return _.indexOf(ze)!==-1}).length,Le=rt.filter(function(ze){return _.indexOf(ze)!==-1||ze===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&<===0&&(lt=1);var un=0;return nt&&(un=te.exponentPart.split("").filter(function(ze){return _.indexOf(ze)!==-1}).length),{integerPartGroupingPositions:Ke,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:Mt,prefix:te.prefix,fractionalPartGroupingPositions:St,minimumFactionalPartSize:lt,maximumFactionalPartSize:Le,minimumExponentSize:un,suffix:te.suffix,picture:te.subpicture}},We=Oe.map(pe);We.forEach(Ce);var ke=We.map(Se),je=p["minus-sign"],ot=p["zero-digit"],Ve=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 Ue;n>=0?Ue=ke[0]:Ue=ke[1];var Xt;Ue.picture.indexOf(p.percent)!==-1?Xt=n*100:Ue.picture.indexOf(p["per-mille"])!==-1?Xt=n*1e3:Xt=n;var Rt,Zt;if(Ue.minimumExponentSize===0)Rt=Xt;else{var On=Math.pow(10,Ue.scalingFactor),Pn=Math.pow(10,Ue.scalingFactor-1);for(Rt=Xt,Zt=0;Rt<Pn;)Rt*=10,Zt-=1;for(;Rt>On;)Rt/=10,Zt+=1}var Cn=F(Rt,Ue.maximumFactionalPartSize),on=function(te,Me){var Ke=Math.abs(te).toFixed(Me);return ot!=="0"&&(Ke=Ke.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?_[Ne.charCodeAt(0)-48]:Ne}).join("")),Ke},oe=on(Cn,Ue.maximumFactionalPartSize),Ge=oe.indexOf(".");for(Ge===-1?oe=oe+Ve:oe=oe.replace(".",Ve);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(Ve);var Qt=Ue.minimumIntegerPartSize-Ge,cn=Ue.minimumFactionalPartSize-(oe.length-Ge-1);if(oe=(Qt>0?new Array(Qt+1).join(ot):"")+oe,oe=oe+(cn>0?new Array(cn+1).join(ot):""),Ge=oe.indexOf(Ve),Ue.regularGrouping>0)for(var Nn=Math.floor((Ge-1)/Ue.regularGrouping),gr=1;gr<=Nn;gr++)oe=[oe.slice(0,Ge-gr*Ue.regularGrouping),Lt,oe.slice(Ge-gr*Ue.regularGrouping)].join("");else Ue.integerPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,Ge-te),Lt,oe.slice(Ge-te)].join(""),Ge++});if(Ge=oe.indexOf(Ve),Ue.fractionalPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,te+Ge+1),Lt,oe.slice(te+Ge+1)].join("")}),Ge=oe.indexOf(Ve),(Ue.picture.indexOf(Ve)===-1||Ge===oe.length-1)&&(oe=oe.substring(0,oe.length-1)),typeof Zt<"u"){var vr=on(Zt,0);Qt=Ue.minimumExponentSize-vr.length,Qt>0&&(vr=new Array(Qt+1).join(ot)+vr),oe=oe+p["exponent-separator"]+(Zt<0?je:"")+vr}return oe=Ue.prefix+oe+Ue.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 C(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 B(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 D(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 Y(n){if(!(typeof n>"u")){var o=!1;if(Array.isArray(n)){if(n.length===1)o=Y(n[0]);else if(n.length>1){var l=n.filter(function(g){return Y(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!Y(n)}function he(n,o,l,g){var p=[o],_=me(n);return _>=2&&p.push(l),_>=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),_=await o.apply(this,p);typeof _<"u"&&l.push(_)}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],_=he(o,p,g,n),R=await o.apply(this,_);Y(R)&&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 _=n[p],R=!0;if(typeof o<"u"){var H=he(o,_,p,n),X=await o.apply(this,H);R=Y(X)}if(R)if(!l)g=_,l=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!l)throw{stack:new Error().stack,code:"D3139"};return g}}function He(){for(var n=[],o=Array.prototype.slice.call(arguments),l=Math.min.apply(Math,o.map(function(_){return Array.isArray(_)?_.length:0})),g=0;g<l;g++){var p=o.map(_=>_[g]);n.push(p)}return n}async function $e(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 _;for(typeof l>"u"&&n.length>0?(g=n[0],_=1):(g=l,_=0);_<n.length;){var R=[g,n[_]];p>=3&&R.push(_),p>=4&&R.push(n),g=await o.apply(this,R),_++}return g}}function qe(n){var o=S();if(Array.isArray(n)){var l={};n.forEach(function(g){var p=qe(g);p.forEach(function(_){l[_]=!0})}),o=qe(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(_=>l.push(_)):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),_=await o.apply(this,p);typeof _<"u"&&l.push(_)}return l}function ut(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function $t(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 De(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!M(n)&&!k(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(R,H){return R>H}}else l=o;var g=async function(R,H){var X=async function(pe,Ce,Se){Ce.length===0?Array.prototype.push.apply(pe,Se):Se.length===0?Array.prototype.push.apply(pe,Ce):await l(Ce[0],Se[0])?(pe.push(Se[0]),await X(pe,Ce,Se.slice(1))):(pe.push(Ce[0]),await X(pe,Ce.slice(1),Se))},Oe=[];return await X(Oe,R,H),Oe},p=async function(R){if(!Array.isArray(R)||R.length<=1)return R;var H=Math.floor(R.length/2),X=R.slice(0,H),Oe=R.slice(H);return X=await p(X),Oe=await p(Oe),await g(X,Oe)},_=await p(n);return _}}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=x(n)?S():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,_=0;_<o.length;_++)if(ge(g,o[_])){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],_=he(o,p,g,n),R=await o.apply(this,_);Y(R)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:N,count:ne,max:L,min:T,average:$,string:V,substring:de,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Re,trim:et,pad:_e,match:ae,contains:tt,replace:Be,split:Ee,join:v,formatNumber:A,formatBase:w,number:C,floor:j,ceil:D,round:F,abs:B,sqrt:J,power:ye,random:we,boolean:Y,not:Q,map:G,zip:He,filter:Ze,single:it,foldLeft:$e,sift:y,keys:qe,lookup:wt,append:Tt,exists:mr,spread:At,merge:Z,reverse:yr,each:Jt,error:ut,assert:$t,type:yt,sort:De,shuffle:u,distinct:h,base64encode:st,base64decode:d,encodeUrlComponent:m,encodeUrl:z,decodeUrlComponent:le,decodeUrl:Pe}})();a.exports=f}).call(this)}).call(this,typeof pn<"u"?pn: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"),k=t("./signature"),M=(function(){var S=f.isNumeric,x=f.isArrayOfStrings,E=f.isArrayOfNumbers,I=f.createSequence,se=f.isSequence,me=f.isFunction,ge=f.isLambda,q=f.isIterable,N=f.isPromise,ne=f.getFunctionArity,L=f.isDeepEqual,T=ut(null);async function $(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 V(u,h,y);break;case"binary":n=await Re(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=Be(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 D(u,h,y);break;case"bind":n=await B(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 He(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 V(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 _=u.steps[p];if(_.tuple&&(l=!0),p===0&&_.consarray?o=await $(_,n,y):l?g=await Ae(_,n,g,y):o=await xe(_,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof _.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,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 _=I();return n&&o.length===1&&Array.isArray(o[0])&&!se(o[0])?_=o[0]:o.forEach(function(R){!Array.isArray(R)||R.cons?_.push(R):R.forEach(H=>_.push(H))}),_}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 _=n;y===void 0&&(y=h.map(Oe=>({"@":Oe})));for(var R=0;R<y.length;R++){_=de(n,y[R]);var H=await $(u,y[R]["@"],_);if(typeof H<"u"){Array.isArray(H)||(H=[H]);for(var X=0;X<H.length;X++)p={},Object.assign(p,y[R]),H.tupleStream?Object.assign(p,H[X]):(u.focus?(p[u.focus]=H[X],p["@"]=y[R]["@"]):p["@"]=H[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[R]["@"])),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 _=await $(u,g,p);S(_)&&(_=[_]),E(_)?_.forEach(function(H){var X=Math.floor(H);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(_)&&n.push(l)}return n}async function Re(u,h,y){var n,o=await $(u.lhs,h,y),l=u.value,g=async()=>await $(u.rhs,h,y);if(l==="and"||l==="or")try{return await Pe(o,g,l)}catch(_){throw _.position=u.position,_.token=l,_}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=z(o,p,l);break;case"&":n=v(o,p);break;case"..":n=C(o,p);break;case"in":n=le(o,p);break}}catch(_){throw _.position=u.position,_.token=l,_}return n}async function et(u,h,y){var n;switch(u.value){case"-":if(n=await $(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,_)=>(y.isParallelCall=_>0,[p,await $(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 Be(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 z(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 Pe(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],_=l?de(y,p):y,R=0;R<u.lhs.length;R++){var H=u.lhs[R],X=await $(H[0],l?p["@"]:p,_);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var Oe={data:p,exprIndex:R};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==R)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=Oe}}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 Ve=w(ke.data);je=Ve["@"],delete Ve["@"],ot=de(y,Ve)}return y.isParallelCall=We>0,[Se,await $(u.lhs[ke.exprIndex][1],je,ot)]}));for(let Se of pe){var[X,Ce]=await Se;typeof Ce<"u"&&(n[X]=Ce)}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 C(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 B(u,h,y){var n=await $(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await $(u.condition,h,y);return c.boolean(o)?n=await $(u.then,h,y):typeof u.else<"u"&&(n=await $(u.else,h,y)),n}async function D(u,h,y){for(var n,o=ut(y),l=0;l<u.expressions.length;l++)n=await $(u.expressions[l],h,o);return n}function F(u){var h=new De.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 _=y(n,h.lastIndex);if(_&&_.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return _}}}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(_,R){for(var H=0,X=0;H===0&&X<u.terms.length;X++){var Oe=u.terms[X],pe=_,Ce=y;l&&(pe=_["@"],Ce=de(y,_));var Se=await $(Oe.expression,pe,Ce);pe=R,Ce=y,l&&(pe=R["@"],Ce=de(y,R));var We=await $(Oe.expression,pe,Ce),ke=typeof Se,je=typeof We;if(ke==="undefined"){H=je==="undefined"?0:1;continue}if(je==="undefined"){H=-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?H=-1:H=1,Oe.descending===!0&&(H=-H))}return H===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.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var _=0;_<p.length;_++){var R=p[_];if(R&&(R.isPrototypeOf(g)||R instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var H=await $(u.update,R,y),X=typeof H;if(X!=="undefined"){if(X!=="object"||H===null||Array.isArray(H))throw{code:"T2011",stack:new Error().stack,position:u.update.position,value:H};for(var Oe in H)R[Oe]=H[Oe]}if(typeof u.delete<"u"){var pe=await $(u.delete,R,y);if(typeof pe<"u"){var Ce=pe;if(Array.isArray(pe)||(pe=[pe]),!x(pe))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Ce};for(var Se=0;Se<pe.length;Se++)typeof R=="object"&&R!==null&&delete R[pe[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var Y=b("function($f, $g) { function($x){ $g($f($x)) } }");async function Q(u,h,y){var n,o=await $(u.lhs,h,y);if(u.rhs.type==="function")n=await he(u.rhs,h,y,{context:o});else{var l=await $(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 $(Y,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.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 R=await $(u.arguments[p],h,y);if(me(R)){const H=async function(...X){return await G(R,X,null,y)};H.arity=ne(R),g.push(H)}else g.push(R)}var _=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=_,l.position=u.position),o=await G(l,g,h,y)}catch(R){throw R.position||(R.position=u.position),R.token||(R.token=_),R}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 $(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 $(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=$e(u.signature,h,y)),ge(u))o=await qe(u,l);else if(u&&u._jsonata_function===!0){var g={environment:n,input:y};o=u.implementation.apply(g,l),q(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 He(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 $(g,h,y))}var p=await $(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 $e(u,h,y){if(typeof u>"u")return h;var n=u.validate(h,y);return n}async function qe(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.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=k(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 $(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 $t={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=$t[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 De(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?De.RegexEngine=h.RegexEngine:De.RegexEngine=RegExp,{evaluate:async function(g,p,_){if(typeof n<"u"){var R={code:"S0500",position:0};throw yt(R),R}if(typeof p<"u"){var H;H=ut(o);for(var X in p)H.bind(X,p[X])}else H=o;H.bind("$",g),l=new Date,H.timestamp=l,Array.isArray(g)&&!se(g)&&(g=I(g),g.outerWrapper=!0);var Oe;try{return Oe=await $(y,g,H),typeof _=="function"&&_(null,Oe),Oe}catch(pe){throw yt(pe),pe}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,_){var R=Z(p,_);o.bind(g,R)},ast:function(){return y},errors:function(){return n}}}return De.parser=b,De})();a.exports=M},{"./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
|
-
`,r:"\r",t:" "},k=function(S){var x=0,E=S.length,I=function(ge,
|
|
3
|
-
\r\v`.indexOf(
|
|
4
|
-
\r\v`.indexOf(Re)>-1||Object.prototype.hasOwnProperty.call(f,Re)){if(S.charAt(x)==="$")return Te=S.substring(x+1,ve),x=ve,I("variable",Te);switch(Te=S.substring(x,ve),x=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 x===E&&Te===""?null:I("name",Te)}}else ve++};return me},M=function(S,x){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},q={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(x)return d.remaining=ge(),d.type="error",me.push(d),d;throw d.stack=new Error().stack,d}},N=function(d,m){var z=se[d];return m=m||0,z?m>=z.lbp&&(z.lbp=m):(z=Object.create(q),z.id=z.value=d,z.lbp=m,se[d]=z),z},ne=function(d){if(x){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 z;E.id==="(end)"?z="S0203":z="S0202";var le={code:z,position:E.position,token:E.value,value:d};return ne(le)}var Pe=I(m);if(Pe===null)return E=se["(end)"],E.position=S.length,E;var Ee=Pe.value,v=Pe.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:Pe.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:Pe.position,token:Ee})}return E=Object.create(A),E.value=Ee,E.type=v,E.position=Pe.position,E},T=function(d){var m,z=E;for(L(null,!0),m=z.nud();d<E.lbp;)z=E,L(),m=z.led(m);return m},$=function(d){var m=N(d,0);m.nud=function(){return this}},V=function(d,m,z){var le=m||f[d],Pe=N(d,le);return Pe.led=z||function(Ee){return this.lhs=Ee,this.rhs=T(le),this.type="binary",this},Pe},de=function(d,m,z){var le=N(d,m);return le.led=z,le},xe=function(d,m){var z=N(d);return z.nud=m||function(){return this.expression=T(70),this.type="unary",this},z};$("(end)"),$("(name)"),$("(literal)"),$("(regex)"),N(":"),N(";"),N(","),N(")"),N("]"),N("}"),N(".."),V("."),V("+"),V("-"),V("*"),V("/"),V("%"),V("="),V("<"),V(">"),V("!="),V("<="),V(">="),V("&"),V("and"),V("or"),V("in"),$("and"),$("or"),$("in"),xe("-"),V("~>"),V("??",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}),V("(",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,z=1,le="<";z>0&&E.id!=="{"&&E.id!=="(end)";){var Pe=L();Pe.id===">"?z--:Pe.id==="<"&&z++,le+=Pe.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 z={type:"binary",value:"..",position:E.position,lhs:m};L(".."),z.rhs=T(0),m=z}if(d.push(m),E.id!==",")break;L(",")}return L("]",!0),this.expressions=d,this.type="unary",this}),V("[",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}),V("^",f["^"],function(d){L("(");for(var m=[];;){var z={descending:!1};if(E.id==="<"?L("<"):E.id===">"&&(z.descending=!0,L(">")),z.expression=T(0),m.push(z),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 z=T(0);L(":");var le=T(0);if(m.push([z,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),V("{",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)}),V("@",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)}),V("#",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)}),V("?",f["?"],function(d){return this.type="condition",this.condition=d,this.then=T(0),E.id===":"&&(L(":"),this.else=T(0)),this}),V("?:",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 z={type:"lambda",thunk:!0,arguments:[],position:d.position};z.body=d,m=z}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,Re=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 z=d.steps.length-1;for(m=_e(d.steps[z--],m);m.level>0&&z>=0;)m=_e(d.steps[z--],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 z=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&z.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=z:Array.prototype.push.apply(d.seekingParent,z)}},tt=function(d){var m=d.steps.length-1,z=d.steps[m],le=typeof z.seekingParent<"u"?z.seekingParent:[];z.type==="parent"&&le.push(z.slot);for(var Pe=0;Pe<le.length;Pe++){var Ee=le[Pe];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 z=ae(d.lhs);z.type==="path"?m=z:m={type:"path",steps:[z]},z.type==="parent"&&(m.seekingParent=[z.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 Pe=m.steps[0];Pe.type==="unary"&&Pe.value==="["&&(Pe.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 C={type:"sort",position:d.position};C.terms=d.rhs.map(function(F){var J=ae(F.expression);return ue(C,J),{descending:F.descending,expression:J}}),m.steps.push(C),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 B=ae(d.body);m.body=Ae(B);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:Re++}},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 D={code:j,position:d.position,token:d.value};if(x)return me.push(D),{type:"error",error:D};throw D.stack=new Error().stack,D}return d.keepArray&&(m.keepArray=!0),m};I=k(S),L();var Be=T(0);if(E.id!=="(end)"){var st={code:"S0201",position:E.position,token:E.value};ne(st)}if(Be=ae(Be),Be.type==="parent"||typeof Be.seekingParent<"u")throw{code:"S0217",token:Be.type,position:Be.position};return me.length>0&&(Be.errors=me),Be};return M})();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(k){for(var M=1,S=[],x={},E=x;M<k.length;){var I=k.charAt(M);if(I===":")break;var se=function(){S.push(x),E=x,x={}},me=function(V,de,xe,Te){for(var Ae=1,ve=de;ve<V.length;)if(ve++,I=V.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":x.regex="["+I+"m]",x.type=I,se();break;case"a":x.regex="[asnblfom]",x.type=I,x.array=!0,se();break;case"f":x.regex="f",x.type=I,se();break;case"j":x.regex="[asnblom]",x.type=I,se();break;case"x":x.regex="[asnblfom]",x.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(k,M,"(",")"),q=k.substring(M+1,ge);if(q.indexOf("<")===-1)x.regex="["+q+"m]";else throw{code:"S0402",stack:new Error().stack,value:q,offset:M};x.type="("+q+")",M=ge,se();break;case"<":if(E.type==="a"||E.type==="f"){var N=me(k,M,"<",">");E.subtype=k.substring(M+1,N),M=N}else throw{code:"S0401",stack:new Error().stack,value:E.type,offset:M};break}M++}var ne="^"+S.map(function(V){return"("+V.regex+")"}).join("")+"$",L=new RegExp(ne),T=function(V){var de;if(i.isFunction(V))de="f";else{var xe=typeof V;switch(xe){case"string":de="s";break;case"number":de="n";break;case"boolean":de="b";break;case"object":V===null?de="l":Array.isArray(V)?de="a":de="o";break;case"undefined":default:de="m"}}return de},$=function(V,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:V[Te],index:Te+1};Te=ve[0].length}throw{code:"T0410",stack:new Error().stack,value:V[Te],index:Te+1}};return{definition:k,validate:function(V,de){var xe="";V.forEach(function(Re){xe+=T(Re)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return S.forEach(function(Re,et){var _e=V[ve],ue=Te[et+1];if(ue==="")if(Re.context&&Re.contextRegex){var tt=T(de);if(Re.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(Re.type==="a"){if(ae==="m")_e=void 0;else{_e=V[ve];var Be=!0;if(typeof Re.subtype<"u"){if(ae!=="a"&&ue!==Re.subtype)Be=!1;else if(ae==="a"&&_e.length>0){var st=T(_e[0]);if(st!==Re.subtype.charAt(0))Be=!1;else{var d=_e.filter(function(m){return T(m)!==st});Be=d.length===0}}}if(!Be)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:f[Re.subtype]};ae!=="a"&&(_e=[_e])}Ae.push(_e),ve++}else Ae.push(_e),ve++})}),Ae}$(V,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 k(){var N=[];return N.sequence=!0,arguments.length===1&&N.push(arguments[0]),N}function M(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 x(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),$=Object.getOwnPropertyNames(ne);if(T.length!==$.length)return!1;for(T=T.sort(),$=$.sort(),L=0;L<T.length;L++)if(T[L]!==$[L])return!1;for(L=0;L<T.length;L++){var V=T[L];if(!me(N[V],ne[V]))return!1}return!0}return!1}function ge(N){return typeof N=="object"&&N!==null&&"then"in N&&typeof N.then=="function"}function q(N){var ne=[];for(let L of N)ne.push(L);return ne}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:b,createSequence:k,isSequence:M,isFunction:S,isLambda:E,isIterable:se,getFunctionArity:x,isDeepEqual:me,stringToArray:q,isPromise:ge}})();a.exports=i},{}]},{},[3])(3)})})(Rr)),Rr.exports}var zs=Vs();const Hs=Ws(zs),nn=O.object({name:O.literal("data-extract"),code:O.string(),inputData:O.any().optional()});function qs(r){return nn.parse(r)}async function Gs(r){try{console.log("[DataExtractBlock] Executing JSONata query:",r.code);const t=await Hs(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 Ks={"get-text":Zr,"attribute-value":Wr,"get-value-form":Vr,"set-value-form":zr,"clear-value-form":Hr,"element-exists":qr,"event-click":Gr,keypress:Kr,wait:Yr,"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 Ys{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=Qa(e);return await es(t)}case"attribute-value":{const t=rs(e);return await ns(t)}case"get-value-form":{const t=as(e);return await ss(t)}case"set-value-form":{const t=os(e);return await cs(t)}case"clear-value-form":{const t=ls(e);return await fs(t)}case"element-exists":{const t=hs(e);return await ps(t)}case"event-click":{const t=ms(e);return await ys(t)}case"keypress":{const t=ws(e);return await ks(t)}case"wait":{const t=_s(e);return await Es(t)}case"wait-for-condition":{const t=Ts(e);return await As(t)}case"navigate":{const t=Ss(e);return await Ds(t)}case"save-assets":{const t=Os(e);return await Ps(t)}case"get-element-data":{const t=Ns(e);return await Rs(t)}case"scroll":{const t=Is(e);return await js(t)}case"ai-parse-data":{const t=Za(e);return await Wa(t)}case"fetch-api":{const t=Ls(e);return await Zs(t)}case"data-extract":{const t=qs(e);return await Gs(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 Js{constructor(){fe(this,"expr");fe(this,"json")}}class Xs{constructor(){fe(this,"template");fe(this,"valueFrom");fe(this,"default")}}class Qs{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 ei{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 ti{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 ri{constructor(){fe(this,"success");fe(this,"steps");fe(this,"targetUrl");fe(this,"timestamp");fe(this,"error")}}var an=(r=>(r.USD="USD",r.KRW="KRW",r.EUR="EUR",r.GBP="GBP",r.CAD="CAD",r.CNY="CNY",r.JPY="JPY",r.VND="VND",r.ARS="ARS",r.INR="INR",r.TWD="TWD",r.AUD="AUD",r.HKD="HKD",r.IDR="IDR",r.MXN="MXN",r.NZD="NZD",r.SGD="SGD",r.CHF="CHF",r.THB="THB",r.BRL="BRL",r.TRY="TRY",r.RUB="RUB",r.NOK="NOK",r.DKK="DKK",r.SEK="SEK",r.ILS="ILS",r.ZAR="ZAR",r.PLN="PLN",r.PHP="PHP",r.CZK="CZK",r.CLP="CLP",r.COP="COP",r.EGP="EGP",r.MYR="MYR",r.HUF="HUF",r.AED="AED",r.SAR="SAR",r.RON="RON",r.BGN="BGN",r))(an||{});const ni={USD:{code:"USD",symbol:"$",format:"%s%u",desc:"United States Dollar"},EUR:{code:"EUR",symbol:"€",format:"%s%u",desc:"Euro (European Union)"},KRW:{code:"KRW",symbol:"₩",local:"원",format:"%s%u",desc:"South Korean Won"},GBP:{code:"GBP",symbol:"£",format:"%s%u",desc:"British Pound Sterling"},CAD:{code:"CAD",symbol:"$",format:"%s%u",desc:"Canadian Dollar"},CNY:{code:"CNY",symbol:"¥",local:"元",format:"%s%u",desc:"Chinese Yuan"},JPY:{code:"JPY",symbol:"¥",local:"円",format:"%s%u",desc:"Japanese Yen"},VND:{code:"VND",symbol:"₫",format:"%s%u",desc:"Vietnamese Dong"},ARS:{code:"ARS",symbol:"$",format:"%s%u",desc:"Argentine Peso"},INR:{code:"INR",symbol:"₹",format:"%s%u",desc:"Indian Rupee"},TWD:{code:"TWD",symbol:"NT$",format:"%s%u",desc:"New Taiwan Dollar"},AUD:{code:"AUD",symbol:"$",format:"%s%u",desc:"Australian Dollar"},HKD:{code:"HKD",symbol:"$",format:"%s%u",desc:"Hong Kong Dollar"},IDR:{code:"IDR",symbol:"Rp",format:"%s%u",desc:"Indonesian Rupiah"},MXN:{code:"MXN",symbol:"$",format:"%s%u",desc:"Mexican Peso"},NZD:{code:"NZD",symbol:"$",format:"%s%u",desc:"New Zealand Dollar"},SGD:{code:"SGD",symbol:"$",format:"%s%u",desc:"Singapore Dollar"},CHF:{code:"CHF",symbol:"₣",format:"%s%u",desc:"Swiss Franc"},THB:{code:"THB",symbol:"฿",format:"%s%u",desc:"Thai Baht"},BRL:{code:"BRL",symbol:"R$",format:"%s%u",desc:"Brazilian Real"},TRY:{code:"TRY",symbol:"₺",abbreviation:"TL",format:"%s%u",desc:"Turkish Lira"},RUB:{code:"RUB",symbol:"₽",format:"%s%u",desc:"Russian Ruble"},NOK:{code:"NOK",symbol:"kr",format:"%s%u",desc:"Norwegian Krone"},DKK:{code:"DKK",symbol:"kr",format:"%s%u",desc:"Danish Krone"},SEK:{code:"SEK",symbol:"kr",format:"%s%u",desc:"Swedish Krona"},ILS:{code:"ILS",symbol:"₪",format:"%s%u",desc:"Israeli New Shekel"},ZAR:{code:"ZAR",symbol:"R",format:"%s%u",desc:"South African Rand"},PLN:{code:"PLN",symbol:"zł",format:"%s%u",desc:"Polish Zloty"},PHP:{code:"PHP",symbol:"₱",format:"%s%u",desc:"Philippine Peso"},CZK:{code:"CZK",symbol:"Kč",format:"%s%u",desc:"Czech Koruna"},CLP:{code:"CLP",symbol:"$",format:"%s%u",desc:"Chilean Peso"},COP:{code:"COP",symbol:"$",format:"%s%u",desc:"Colombian Peso"},EGP:{code:"EGP",symbol:"E£",format:"%s%u",desc:"Egyptian Pound"},MYR:{code:"MYR",symbol:"RM",local:"令吉",format:"%s%u",desc:"Malaysian Ringgit"},HUF:{code:"HUF",symbol:"Ft",format:"%s%u",desc:"Hungarian Forint"},AED:{code:"AED",symbol:"د.إ",format:"%s%u",desc:"United Arab Emirates Dirham"},SAR:{code:"SAR",symbol:"﷼",format:"%s%u",desc:"Saudi Riyal"},RON:{code:"RON",symbol:"L",local:"lei",format:"%s%u",desc:"Romanian Leu"},BGN:{code:"BGN",symbol:"лв",format:"%s%u",desc:"Bulgarian Lev"}},ai={code:"USD",symbol:"$",format:"%u%n"};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 si(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}const En=Nt({name:Fe(),key:Fe(),image:Fe()});var sn=(r=>(r.monthly="MONTHLY",r.yearly="YEARLY",r))(sn||{});const Dr=Nt({code:$r(an),symbol:Fe(),local:Fe().optional(),abbreviation:Fe().optional(),format:Fe(),desc:Fe(),amount:Yt(),text:Fe().optional()});var Tn=(r=>(r.USD="USD",r.KRW="KRW",r))(Tn||{});const ii={en:{code:"USD",symbol:"$"},ko:{code:"KRW",symbol:"₩"}},An=Nt({planName:Fe(),currentCycleBillAmount:Dr,nextPaymentDue:Fe(),cycleTerm:$r(sn).nullable(),isFreeTier:Ut(),isPerUser:Ut(),paidMemberCount:Yt(),usedMemberCount:Yt(),unitPrice:Dr.nullable()}),Sn=Nt({uid:Fe(),issuedDate:Br.date(),paidDate:Br.date().nullable().optional(),paymentMethod:Fe(),amount:Dr,isSuccessfulPaid:Ut(),receiptUrl:Fe()}),Dn=Nt({name:Fe(),email:Fe().email(),profileImageUrl:Fe(),role:Fe()});class oi{constructor(){}async checkExtension(){return new Promise((e,t)=>{const a=setTimeout(()=>{t(ct.extensionNotInstalled())},5e3),s=i=>{si(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 k,M,S,x;if(((k=b.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&b.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const E=b.data,I=((M=E==null?void 0:E.result)==null?void 0:M.steps)??((x=(S=E==null?void 0:E.result)==null?void 0:S.result)==null?void 0:x.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{...t,data:[],isSuccess:!1};const s=[];for(const f of a){const b=En.safeParse(f);b.success?s.push(b.data):console.warn("Invalid workspace data:",f,b.error)}return{...t,data:s,isSuccess:!0}}async getWorkspacePlanAndCycle(e,t){var c,f;t.workflow.vars={...t.workflow.vars,workspaceKey:e};const a=await this.collectWorkflow(t);if(!a.success)throw new ct("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const s=(f=(c=a.steps[a.steps.length-1])==null?void 0:c.result)==null?void 0:f.data;if(!s)return{...a};const i=An.safeParse(s);if(i.success){const b=i.data;return{...a,...b}}else return console.warn("Invalid workspace billing data:",s,i.error),{...a}}async getWorkspaceBillingHistories(e,t){var c,f;t.workflow.vars={...t.workflow.vars,workspaceKey:e};const a=await this.collectWorkflow(t);if(!a.success)throw new ct("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const s=(f=(c=a.steps[a.steps.length-1])==null?void 0:c.result)==null?void 0:f.data;if(!s||!Array.isArray(s))return{...a,data:[]};const i=[];for(const b of s){const k=Sn.safeParse(b);k.success?i.push(k.data):console.warn("Invalid workspace billing history data:",b,k.error)}return{...a,data:i}}async getWorkspaceMembers(e,t){var c,f;t.workflow.vars={...t.workflow.vars,workspaceKey:e};const a=await this.collectWorkflow(t);if(!a.success)throw new ct("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const s=(f=(c=a.steps[a.steps.length-1])==null?void 0:c.result)==null?void 0:f.data;if(!s||!Array.isArray(s))return{...a,data:[]};const i=[];for(const b of s){const k=Dn.safeParse(b);k.success?i.push(k.data):console.warn("Invalid workspace member data:",b,k.error)}return{...a,data:i}}}exports.AiParseDataBlockSchema=Lr;exports.AllBlockSchemas=Ks;exports.BaseBlockSchema=pt;exports.BillingCycleTerm=sn;exports.Binding=Xs;exports.BlockHandler=Ys;exports.ClearValueFormsBlockSchema=Hr;exports.CollectWorkflowResult=ri;exports.Condition=Js;exports.Currency=Tn;exports.CurrencyAmountSchema=Dr;exports.CurrencyCode=an;exports.CurrencyList=ni;exports.CurrencyValues=ii;exports.DataExtractBlockSchema=nn;exports.DefaultCurrency=ai;exports.EightGClient=oi;exports.EightGError=ct;exports.ElementExistsBlockSchema=qr;exports.EventClickBlockSchema=Gr;exports.FetchApiBlockSchema=rn;exports.GetAttributeValueBlockSchema=Wr;exports.GetElementDataBlockSchema=en;exports.GetTextBlockSchema=Zr;exports.GetValueFormsBlockSchema=Vr;exports.KeypressBlockSchema=Kr;exports.NavigateBlockSchema=Xr;exports.SaveAssetsBlockSchema=Qr;exports.Schema=Ha;exports.ScrollBlockSchema=tn;exports.SetValueFormsBlockSchema=zr;exports.WaitBlockSchema=Yr;exports.WaitForConditionBlockSchema=Jr;exports.Workflow=ei;exports.WorkflowStep=Qs;exports.WorkflowStepRunResult=ti;exports.WorkspaceBillingHistorySchema=Sn;exports.WorkspaceBillingSchema=An;exports.WorkspaceItemSchema=En;exports.WorkspaceMemberSchema=Dn;exports.createArraySchema=za;exports.createSchema=Va;
|
|
1
|
+
"use strict";var Rn=Object.defineProperty;var Mn=(r,e,t)=>e in r?Rn(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"});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 Mr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Mr||(Mr={}));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}},P=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 k=c.path[b];b===c.path.length-1?(f[k]=f[k]||{_errors:[]},f[k]._errors.push(t(c))):f[k]=f[k]||{_errors:[]},f=f[k],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 P.invalid_type:r.received===W.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case P.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,be.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:t=`Unrecognized key(s) in object: ${be.joinValues(r.keys,", ")}`;break;case P.invalid_union:t="Invalid input";break;case P.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${be.joinValues(r.options)}`;break;case P.invalid_enum_value:t=`Invalid enum value. Expected ${be.joinValues(r.options)}, received '${r.received}'`;break;case P.invalid_arguments:t="Invalid function arguments";break;case P.invalid_return_type:t="Invalid function return type";break;case P.invalid_date:t="Invalid date";break;case P.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 P.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 P.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 P.custom:t="Invalid input";break;case P.invalid_intersection_types:t="Intersection results could not be merged";break;case P.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case P.not_finite:t="Number must be finite";break;default:t=e.defaultError,be.assertNever(r)}return{message:t}};let yn=Ht;function jn(r){yn=r}function xr(){return yn}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(k=>!!k).slice().reverse();for(const k of b)f=k(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},Fn=[];function U(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 ln=(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 ln(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 ln(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:P.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 Ct.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 $r({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 Bn=/^c[^\s-]{8,}$/i,Un=/^[0-9a-z]+$/,$n=/^[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 Cr;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}(=)?))?$/,gn="((\\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(`^${gn}$`);function vn(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(`^${vn(r)}$`)}function bn(r){let e=`${gn}T${vn(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 U(i,{code:P.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),U(s,{code:P.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),U(s,{code:P.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?U(s,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):f&&U(s,{code:P.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),U(s,{validation:"email",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Cr||(Cr=new RegExp(qn,"u")),Cr.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"emoji",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"uuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"nanoid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Un.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cuid2",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")$n.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ulid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),U(s,{validation:"url",code:P.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),U(s,{validation:"regex",code:P.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),U(s,{code:P.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),U(s,{code:P.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?bn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?Qn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?ea(i).test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?zn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"duration",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?ta(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"ip",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?ra(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"jwt",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?na(e.data,i.version)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"cidr",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?Jn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?Xn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64url",code:P.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:P.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 Dt 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 U(i,{code:P.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),U(a,{code:P.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),U(a,{code:P.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),U(a,{code:P.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),U(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),U(a,{code:P.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 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]})}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)}}Dt.create=r=>new Dt({checks:[],typeName:re.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ie(r)});class Ot 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),U(a,{code:P.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),U(a,{code:P.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),U(a,{code:P.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 U(t,{code:P.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 Ot({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Ot({...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}}Ot.create=r=>new Ot({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 U(a,{code:P.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 U(i,{code:P.invalid_type,expected:W.date,received:i.parsedType}),ee}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:P.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),U(s,{code:P.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),U(s,{code:P.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 U(a,{code:P.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 U(a,{code:P.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 U(a,{code:P.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 U(t,{code:P.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 U(a,{code:P.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 U(t,{code:P.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)&&(U(t,{code:c?P.too_big:P.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&&(U(t,{code:P.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&&(U(t,{code:P.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 Ct?Ct.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 k=this._getOrReturnCtx(e);return U(k,{code:P.invalid_type,expected:W.object,received:k.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 k in s.data)c.includes(k)||f.push(k);const b=[];for(const k of c){const M=i[k],S=s.data[k];b.push({key:{status:"valid",value:k},value:M._parse(new vt(s,S,s.path,k)),alwaysSet:k in s.data})}if(this._def.catchall instanceof Et){const k=this._def.unknownKeys;if(k==="passthrough")for(const M of f)b.push({key:{status:"valid",value:M},value:{status:"valid",value:s.data[M]}});else if(k==="strict")f.length>0&&(U(s,{code:P.unrecognized_keys,keys:f}),a.dirty());else if(k!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const k=this._def.catchall;for(const M of f){const S=s.data[M];b.push({key:{status:"valid",value:M},value:k._parse(new vt(s,S,s.path,M)),alwaysSet:M in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const k=[];for(const M of b){const S=await M.key,x=await M.value;k.push({key:S,value:x,alwaysSet:M.alwaysSet})}return k}).then(k=>Ke.mergeObjectSync(a,k)):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 wn(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 U(t,{code:P.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 k={...t,common:{...t.common,issues:[]},parent:null},M=b._parseSync({data:t.data,path:t.path,parent:k});if(M.status==="valid")return M;M.status==="dirty"&&!i&&(i={result:M,ctx:k}),k.common.issues.length&&c.push(k.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const f=c.map(b=>new at(b));return U(t,{code:P.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 Pt?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 Ct?[null,...xt(r.unwrap())]:r instanceof $r||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 U(t,{code:P.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}):(U(t,{code:P.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}):(U(a,{code:P.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 U(a,{code:P.invalid_type,expected:W.array,received:a.parsedType}),ee;if(a.data.length<this._def.items.length)return U(a,{code:P.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ee;!this._def.rest&&a.data.length>this._def.items.length&&(U(a,{code:P.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 U(a,{code:P.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 U(a,{code:P.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],k)=>({key:s._parse(new vt(a,f,a.path,[k,"key"])),value:i._parse(new vt(a,b,a.path,[k,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const b of c){const k=await b.key,M=await b.value;if(k.status==="aborted"||M.status==="aborted")return ee;(k.status==="dirty"||M.status==="dirty")&&t.dirty(),f.set(k.value,M.value)}return{status:t.value,value:f}})}else{const f=new Map;for(const b of c){const k=b.key,M=b.value;if(k.status==="aborted"||M.status==="aborted")return ee;(k.status==="dirty"||M.status==="dirty")&&t.dirty(),f.set(k.value,M.value)}return{status:t.value,value:f}}}}Ar.create=(r,e,t)=>new Ar({valueType:e,keyType:r,typeName:re.ZodMap,...ie(t)});class Bt extends ce{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.set)return U(a,{code:P.invalid_type,expected:W.set,received:a.parsedType}),ee;const s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(U(a,{code:P.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&&(U(a,{code:P.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 k=new Set;for(const M of b){if(M.status==="aborted")return ee;M.status==="dirty"&&t.dirty(),k.add(M.value)}return{status:t.value,value:k}}const f=[...a.data.values()].map((b,k)=>i._parse(new vt(a,b,a.path,k)));return a.common.async?Promise.all(f).then(b=>c(b)):c(f)}min(e,t){return new Bt({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new Bt({...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)}}Bt.create=(r,e)=>new Bt({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 U(t,{code:P.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(k=>!!k),issueData:{code:P.invalid_arguments,argumentsError:b}})}function s(f,b){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),Ht].filter(k=>!!k),issueData:{code:P.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 k=new at([]),M=await f._def.args.parseAsync(b,i).catch(E=>{throw k.addIssue(a(b,E)),k}),S=await Reflect.apply(c,this,M);return await f._def.returns._def.type.parseAsync(S,i).catch(E=>{throw k.addIssue(s(S,E)),k})})}else{const f=this;return Je(function(...b){const k=f._def.args.safeParse(b,i);if(!k.success)throw new at([a(b,k.error)]);const M=Reflect.apply(c,this,k.data),S=f._def.returns.safeParse(M,i);if(!S.success)throw new at([s(M,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 U(t,{received:t.data,code:P.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 wn(r,e){return new Pt({values:r,typeName:re.ZodEnum,...ie(e)})}class Pt extends ce{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return U(t,{expected:be.joinValues(a),received:t.parsedType,code:P.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 U(t,{received:t.data,code:P.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 Pt.create(e,{...this._def,...t})}exclude(e,t=this._def){return Pt.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Pt.create=wn;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 U(a,{expected:be.joinValues(s),received:a.parsedType,code:P.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 U(a,{received:a.data,code:P.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 U(t,{code:P.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=>{U(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 Ct extends ce{_parse(e){return this._getType(e)===W.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ct.create=(r,e)=>new Ct({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 U(a,{code:P.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 $r 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 fn(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function kn(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=fn(e,a),b=f.fatal??t??!0;s.addIssue({code:"custom",...f,fatal:b})}});if(!i){const c=fn(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}`})=>kn(t=>t instanceof r,e),Ue=ft.create,Kt=Dt.create,ca=Sr.create,ua=Ot.create,Ut=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=Bt.create,Sa=qt.create,Da=cr.create,Oa=ur.create,xn=Pt.create,Lr=lr.create,Pa=Yt.create,dn=ht.create,Ca=gt.create,Na=Ct.create,Ra=ht.createWithPreprocess,Ma=pr.create,Ia=()=>Ue().optional(),ja=()=>Kt().optional(),Fa=()=>Ut().optional(),Br={string:(r=>ft.create({...r,coerce:!0})),number:(r=>Dt.create({...r,coerce:!0})),boolean:(r=>rr.create({...r,coerce:!0})),bigint:(r=>Ot.create({...r,coerce:!0})),date:(r=>Ft.create({...r,coerce:!0}))},Ba=ee,O=Object.freeze(Object.defineProperty({__proto__:null,BRAND:sa,DIRTY:Vt,EMPTY_PATH:Fn,INVALID:ee,NEVER:Ba,OK:Je,ParseStatus:Ke,Schema:ce,ZodAny:Gt,ZodArray:dt,ZodBigInt:Ot,ZodBoolean:rr,ZodBranded:$r,ZodCatch:dr,ZodDate:Ft,ZodDefault:fr,ZodDiscriminatedUnion:Dr,ZodEffects:ht,ZodEnum:Pt,ZodError:at,get ZodFirstPartyTypeKind(){return re},ZodFunction:qt,ZodIntersection:ir,ZodIssueCode:P,ZodLazy:cr,ZodLiteral:ur,ZodMap:Ar,ZodNaN:Sr,ZodNativeEnum:lr,ZodNever:Et,ZodNull:ar,ZodNullable:Ct,ZodNumber:Dt,ZodObject:Ie,ZodOptional:gt,ZodParsedType:W,ZodPipeline:pr,ZodPromise:Yt,ZodReadonly:hr,ZodRecord:or,ZodSchema:ce,ZodSet:Bt,ZodString:ft,ZodSymbol:Er,ZodTransformer:ht,ZodTuple:bt,ZodType:ce,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:It,ZodVoid:Tr,addIssueToContext:U,any:pa,array:va,bigint:ua,boolean:Ut,coerce:Br,custom:kn,date:la,datetimeRegex:bn,defaultErrorMap:Ht,discriminatedUnion:ka,effect:dn,enum:xn,function:Sa,getErrorMap:xr,getParsedType:_t,instanceof:oa,intersection:xa,isAborted:Ir,isAsync:tr,isDirty:jr,isValid:jt,late:ia,lazy:Da,literal:Oa,makeIssue:_r,map:Ta,nan:ca,nativeEnum:Lr,never:ya,null:ha,nullable:Na,number:Kt,object:Nt,get objectUtil(){return Mr},oboolean:Fa,onumber:ja,optional:Ca,ostring:Ia,pipeline:Ma,preprocess:Ra,promise:Pa,quotelessJson:In,record:Ea,set:Aa,setErrorMap:jn,strictObject:ba,string:Ue,symbol:fa,transformer:dn,tuple:_a,undefined:da,union:wa,unknown:ma,get util(){return be},void:ga},Symbol.toStringTag,{value:"Module"})),pt=Nt({name:Ue(),selector:Ue(),findBy:xn(["cssSelector","xpath"]),option:Nt({waitForSelector:Ut().optional(),waitSelectorTimeout:Kt().optional(),multiple:Ut().optional()})}),Ua=O.object({type:O.literal("object"),shape:O.record(O.string(),O.any())}),$a=O.object({type:O.literal("array"),items:O.any()}),La=O.discriminatedUnion("type",[Ua,$a]),Zr=O.object({name:O.literal("ai-parse-data"),sourceData:O.any().optional(),schemaDefinition:La,prompt:O.string().optional(),model:O.string().optional(),apiKey:O.string().min(1,"OpenAI API key is required")});function Za(r){return Zr.parse(r)}async function Wa(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 za(r){return{type:"object",shape:r}}function Va(r){return{type:"array",items:r}}const qa={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}),currency:r=>({type:"currency",shape:En,description:(r==null?void 0:r.description)||"Currency information with code, symbol, format, amount, and text",optional:r==null?void 0:r.optional})};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 Ha 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 k;return((k=b.textContent)==null?void 0:k.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class Ga 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(k=>k.trim());if(c.length!==2)return null;const f=c[0],b=c[1];if(!f||!b)return null;try{const k=t.querySelector(f);if(!k||!k.contentDocument)return null;const M=k.contentDocument;return i?Array.from(M.querySelectorAll(b)):M.querySelector(b)}catch(k){return console.error("Iframe Selector error:",k),null}}}class Ya 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 k=c[b],M=b===c.length-1;if(!k)return null;if(M&&i)return Array.from(f.querySelectorAll(k));const S=f.querySelector(k);if(!S)return null;if(M)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 Ka 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 k=c.snapshotItem(b);k&&k.nodeType===Node.ELEMENT_NODE&&f.push(k)}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 Ja{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=Xa(t,a);return i?f.waitForElement(r,e,c):f.find(r,e)}function Xa(r,e){return e==="xpath"?new Ka:r.includes(">>")?new Ya:r.includes("|>")?new Ga:new Ha}const Wr=pt.extend({name:O.literal("get-text"),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),filterEmpty:O.boolean().optional(),scrollToCollect:O.boolean().optional(),scrollDistance:O.number().optional(),scrollWaitMs:O.number().optional(),maxScrollAttempts:O.number().optional()});function Qa(r){return Wr.parse(r)}async function es(r){try{const{selector:e="",includeTags:t=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:b,filterEmpty:k=!0,scrollToCollect:M=!1,scrollDistance:S=500,scrollWaitMs:x=300,maxScrollAttempts:E=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(M&&(b!=null&&b.multiple))return await ts({selector:e,findBy:f,option:b,includeTags:t,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:k,scrollDistance:S,scrollWaitMs:x,maxScrollAttempts:E});const I=await mt({selector:e,findBy:f,option:b});if(!I)return{data:""};const se=_n(t,a,s,i,c);if(Array.isArray(I)){const me=I.map(se);return{data:k?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 ts(r){const{selector:e,findBy:t,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:b,filterEmpty:k,scrollDistance:M,scrollWaitMs:S,maxScrollAttempts:x}=r,E=_n(s,i,c,f,b),I=new Set;let se=0,me=0;const ge=5;for(;se<x;){const H=await mt({selector:e,findBy:t,option:a});if(H&&Array.isArray(H)){const L=I.size;if(H.forEach($=>{const z=E($);(!k||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:M,behavior:"auto"}),await new Promise(L=>setTimeout(L,S)),(window.pageYOffset||document.documentElement.scrollTop)===N)break;se++}return{data:Array.from(I)}}function _n(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 zr=pt.extend({name:O.literal("attribute-value"),attributeName:O.string()});function rs(r){return zr.parse(r)}async function ns(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 Vr=pt.extend({name:O.literal("get-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function as(r){return Vr.parse(r)}async function ss(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:is(s,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function is(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 qr=pt.extend({name:O.literal("set-value-form"),setValue:O.string(),type:O.enum(["text-field","select","checkbox"]).optional()});function os(r){return qr.parse(r)}async function cs(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 us(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 us(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 Hr=pt.extend({name:O.literal("clear-value-form"),type:O.enum(["text-field","select","checkbox"]).optional()});function ls(r){return Hr.parse(r)}async function fs(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 ds(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 ds(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 Gr=pt.extend({name:O.literal("element-exists")});function hs(r){return Gr.parse(r)}async function ps(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 Yr=pt.extend({name:O.literal("event-click"),textFilter:O.object({text:O.union([O.string(),O.array(O.string())]),mode:O.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function ms(r){return Yr.parse(r)}async function ys(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=gs(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 bs(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 gs(r,e,t){for(const a of r){const s=vs(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 vs(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 bs(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 Kr=O.object({name:O.literal("keypress"),key:O.string(),code:O.string().optional(),keyCode:O.number().optional(),modifiers:O.array(O.enum(["Alt","Control","Meta","Shift"])).optional()});function ws(r){return Kr.parse(r)}async function ks(r){try{const{key:e,code:t,keyCode:a,modifiers:s=[]}=r;return await xs(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 xs(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,...hn(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...hn(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 hn(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Jr=O.object({name:O.literal("wait"),duration:O.number().min(0)});function _s(r){return Jr.parse(r)}async function Es(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 Xr=O.object({name:O.literal("wait-for-condition"),conditions:O.object({urlPattern:O.string().optional(),elementExists:O.object({selector:O.string(),findBy:O.enum(["cssSelector","xpath"])}).optional(),cookieExists:O.string().optional(),storageKey:O.object({type:O.enum(["localStorage","sessionStorage"]),key:O.string()}).optional(),userConfirmation:O.boolean().optional(),message:O.string().optional(),buttonText:O.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:O.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:O.number().min(100).optional(),timeoutMs:O.number().min(1e3).optional(),position:O.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Ts(r){return Xr.parse(r)}async function As(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,k=null;(t==="manual"||t==="auto-or-manual")&&f&&(b=new Promise(S=>{k=S}),window.dispatchEvent(new CustomEvent("8g-show-confirmation-ui",{detail:{message:e.message||"작업을 완료하셨나요?",buttonText:e.buttonText||"완료",position:i,onConfirm:k}})));const M=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:x}=e.elementExists;let E=null;if(x==="cssSelector"?E=document.querySelector(S):x==="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:x}=e.storageKey;if((S==="localStorage"?window.localStorage:window.sessionStorage).getItem(x)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${S}.${x}`}}return null};return new Promise(S=>{let x=null,E=!1;const I=()=>{x&&(clearInterval(x),x=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&&(x=setInterval(async()=>{const ge=await M();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 Qr=O.object({name:O.literal("navigate"),url:O.string().url("Valid URL is required"),waitForLoad:O.boolean().optional(),timeout:O.number().min(0).optional()});function Ss(r){return Qr.parse(r)}async function Ds(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 en=pt.extend({name:O.literal("save-assets")});function Os(r){return en.parse(r)}async function Ps(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 Cs{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 tn=pt.extend({name:O.literal("get-element-data"),includeText:O.boolean().optional(),includeTags:O.boolean().optional(),useTextContent:O.boolean().optional(),regex:O.string().optional(),prefixText:O.string().optional(),suffixText:O.string().optional(),attributes:O.array(O.string()).optional(),includeSelector:O.boolean().optional(),includeXPath:O.boolean().optional()});function Ns(r){return tn.parse(r)}async function Rs(r){try{const{selector:e="",includeText:t=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:b=[],includeSelector:k=!1,includeXPath:M=!1,findBy:S="cssSelector",option:x}=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:x});if(!E)return{data:Array.isArray(E)?[]:{}};const I=Ms(t,a,s,i,c,f,b,k,M);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 Ms(r,e,t,a,s="",i="",c=[],f=!1,b=!1){return k=>{const M={};if(r){let S="";if(e?S=k.innerHTML:S=t?k.textContent||"":k.innerText||"",a){const x=new RegExp(a,"g"),E=S.match(x);S=E?E.join(" "):""}S.trim()&&(S=s+S.trim()+i),M.text=S}return c.length>0&&(M.attributes={},c.forEach(S=>{let x=k.getAttribute(S);if(x===null){const E=k.querySelector(`[${S}]`);E&&(x=E.getAttribute(S))}M.attributes[S]=x})),f&&(M.selector=Ja.generate(k)),b&&(M.xpath=Cs.generate(k)),M}}const rn=pt.extend({name:O.literal("scroll"),scrollType:O.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:O.number().optional(),behavior:O.enum(["auto","smooth"]).optional(),maxScrolls:O.number().optional(),waitAfterScroll:O.number().optional()});function Is(r){return rn.parse(r)}async function js(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 Fs(e,f,b,s);case"toBottom":return await Bs(s,c);case"byDistance":return await Us(a,s);case"untilLoaded":return await $s(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 Fs(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 Bs(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 Us(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function $s(r,e,t,a){let s=0,i=document.body.scrollHeight;for(;s<r;){window.scrollBy({top:e,behavior:t}),await new Promise(k=>setTimeout(k,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 nn=O.object({name:O.literal("fetch-api"),url:O.string(),method:O.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:O.record(O.string(),O.string()).optional(),body:O.record(O.string(),O.any()).optional(),timeout:O.number().min(0).optional(),parseJson:O.boolean().optional(),returnHeaders:O.boolean().optional()});function Ls(r){return nn.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 pn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ws(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 Rr={exports:{}},mn;function zs(){return mn||(mn=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function(){function t(a,s,i){function c(k,M){if(!s[k]){if(!a[k]){var S=typeof kr=="function"&&kr;if(!M&&S)return S(k,!0);if(f)return f(k,!0);var x=new Error("Cannot find module '"+k+"'");throw x.code="MODULE_NOT_FOUND",x}var E=s[k]={exports:{}};a[k][0].call(E.exports,function(I){var se=a[k][1][I];return c(se||I)},E,E.exports,t,a,s,i)}return s[k].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"],k=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],M=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],S=["Thousand","Million","Billion","Trillion"];function x(v,A){var w=function(B,j,D){var F="";if(B<=19)F=(j?" and ":"")+(D?k[B]:b[B]);else if(B<100){const ye=Math.floor(B/10),we=B%10;F=(j?" and ":"")+M[ye-2],we>0?F+="-"+w(we,!1,D):D&&(F=F.substring(0,F.length-1)+"ieth")}else if(B<1e3){const ye=Math.floor(B/100),we=B%100;F=(j?", ":"")+b[ye]+" Hundred",we>0?F+=w(we,!0,D):D&&(F+="th")}else{var J=Math.floor(Math.log10(B)/3);J>S.length&&(J=S.length);const ye=Math.pow(10,J*3),we=Math.floor(B/ye),K=B-we*ye;F=(j?", ":"")+w(we,!1,!1)+" "+S[J-1],K>0?F+=w(K,!0,D):D&&(F+="th")}return F},C=w(v,!1,A);return C}const E={};b.forEach(function(v,A){E[v.toLowerCase()]=A}),k.forEach(function(v,A){E[v.toLowerCase()]=A}),M.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(),C=Math.pow(10,(A+1)*3);E[w]=C,E[w+"th"]=C});function I(v){const w=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>E[j]);let C=[0];return w.forEach(j=>{if(j<100){let D=C.pop();D>=1e3&&(C.push(D),D=0),C.push(D+j)}else C.push(C.pop()*j)}),C.reduce((j,D)=>j+D,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,C=v.length-1;C>=0;C--){const B=v[C],j=me[B];j<w?A-=j:(w=j,A+=j)}return A}function N(v,A){for(var w=[],C=A.charCodeAt(0);v>0;)w.unshift(String.fromCharCode((v-1)%26+C)),v=Math.floor((v-1)/26);return w.join("")}function ne(v,A){for(var w=A.charCodeAt(0),C=0,B=0;B<v.length;B++)C+=(v.charCodeAt(v.length-B-1)-w+1)*Math.pow(26,B);return C}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"},$={UPPER:"upper",LOWER:"lower",TITLE:"title"};function z(v,A){let w;const C=v<0;switch(v=Math.abs(v),A.primary){case T.LETTERS:w=N(v,A.case===$.UPPER?"A":"a");break;case T.ROMAN:w=ge(v),A.case===$.UPPER&&(w=w.toUpperCase());break;case T.WORDS:w=x(v,A.ordinal),A.case===$.UPPER?w=w.toUpperCase():A.case===$.LOWER&&(w=w.toLowerCase());break;case T.DECIMAL:w=""+v;var B=A.mandatoryDigits-w.length;if(B>0){var j=new Array(B+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 D={1:"st",2:"nd",3:"rd"},F=w[w.length-1],J=D[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 C&&(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:$.LOWER,ordinal:!1};let w,C;const B=v.lastIndexOf(";");switch(B===-1?w=v:(w=v.substring(0,B),C=v.substring(B+1),C[0]==="o"&&(A.ordinal=!0)),w){case"A":A.case=$.UPPER;case"a":A.primary=T.LETTERS;break;case"I":A.case=$.UPPER;case"i":A.primary=T.ROMAN;break;case"W":A.case=$.UPPER,A.primary=T.WORDS;break;case"Ww":A.case=$.TITLE,A.primary=T.WORDS;break;case"w":A.primary=T.WORDS;break;default:{let j=null,D=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,D++,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)}))}),D>0){A.primary=T.DECIMAL,A.zeroCode=j,A.mandatoryDigits=D,A.optionalDigits=F;const Q=function(he){if(he.length===0)return 0;const G=he[0].character;for(let $e=1;$e<he.length;$e++)if(he[$e].character!==G)return 0;const Ze=he.map($e=>$e.position),it=function($e,He){return He===0?$e:it(He,$e%He)},qe=Ze.reduce(it);for(let $e=1;$e<=Ze.length;$e++)if(Ze.indexOf($e*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},C=function(Q,he){if(he>Q){let G=v.substring(Q,he);G=G.split("]]").join("]"),A.push({type:"literal",value:G})}};for(var B=0,j=0;j<v.length;){if(v.charAt(j)==="["){if(v.charAt(j+1)==="["){C(B,j),A.push({type:"literal",value:"["}),j+=2,B=j;continue}if(C(B,j),B=j,j=v.indexOf("]",B),j===-1)throw{code:"D3135"};let Q=v.substring(B+1,j);Q=Q.split(/\s+/).join("");var D={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 $e={min:qe(Ze),max:qe(it)};D.width=$e,J=Q.substring(1,F)}else J=Q.substring(1);if(J.length===1)D.presentation1=J;else if(J.length>1){var ye=J.charAt(J.length-1);"atco".indexOf(ye)!==-1?(D.presentation2=ye,ye==="o"&&(D.ordinal=!0),D.presentation1=J.substring(0,J.length-1)):D.presentation1=J}else D.presentation1=Te[D.component];if(typeof D.presentation1>"u")throw{code:"D3132",value:D.component};if(D.presentation1[0]==="n")D.names=$.LOWER;else if(D.presentation1[0]==="N")D.presentation1[1]==="n"?D.names=$.TITLE:D.names=$.UPPER;else if("YMDdFWwXxHhmsf".indexOf(D.component)!==-1){var we=D.presentation1;if(D.presentation2&&(we+=";"+D.presentation2),D.integerFormat=xe(we),D.width&&D.width.min!==void 0&&D.integerFormat.mandatoryDigits<D.width.min&&(D.integerFormat.mandatoryDigits=D.width.min),D.component==="Y")if(D.n=-1,D.width&&D.width.max!==void 0)D.n=D.width.max,D.integerFormat.mandatoryDigits=D.n;else{var K=D.integerFormat.mandatoryDigits+D.integerFormat.optionalDigits;K>=2&&(D.n=K)}const he=A[A.length-1];he&&he.integerFormat&&(he.integerFormat.parseWidth=he.integerFormat.mandatoryDigits)}(D.component==="Z"||D.component==="z")&&(D.integerFormat=xe(D.presentation1)),A.push(D),B=j+1}j++}return C(B,j),w}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Re=["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 C=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),B=Date.UTC(v.getUTCFullYear(),0);w=(C-B)/et+1;break}case"F":w=v.getUTCDay(),w===0&&(w=7);break;case"W":{const C=ue(v.getUTCFullYear(),0),B=_e(C),j=Date.UTC(C.year,v.getUTCMonth(),v.getUTCDate());let D=tt(B,j);if(D>52){const F=_e(C.nextYear());j>=F&&(D=1)}else if(D<1){const F=_e(C.previousYear());D=tt(F,j)}w=Math.floor(D);break}case"w":{const C=ue(v.getUTCFullYear(),v.getUTCMonth()),B=_e(C),j=Date.UTC(C.year,C.month,v.getUTCDate());let D=tt(B,j);if(D>4){const F=_e(C.nextMonth());j>=F&&(D=1)}else if(D<1){const F=_e(C.previousMonth());D=tt(F,j)}w=Math.floor(D);break}case"X":{const C=ue(v.getUTCFullYear(),0),B=_e(C),j=_e(C.nextYear()),D=v.getTime();D<B?w=C.year-1:D>=j?w=C.year+1:w=C.year;break}case"x":{const C=ue(v.getUTCFullYear(),v.getUTCMonth()),B=_e(C),j=C.nextMonth(),D=_e(j),F=v.getTime();F<B?w=C.previousMonth().month+1:F>=D?w=j.month+1:w=C.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 C=0,B=0;if(typeof w<"u"){const we=parseInt(w);C=Math.floor(we/100),B=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=Re[Q-1];else if(K.component==="F")Q=ve[Q];else throw{code:"D3133",value:K.component};K.names===$.UPPER?Q=Q.toUpperCase():K.names===$.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=C*100+B;if(K.integerFormat.regular)Q=z(he,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)Q=z(C,K.integerFormat),B!==0&&(Q+=":"+L(B,"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===$.UPPER&&(Q=Q.toUpperCase());return Q};let D;typeof A>"u"?(Fe===null&&(Fe=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),D=Fe):D=Ae(A);const F=(60*C+B)*60*1e3,J=new Date(v+F);let ye="";return D.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 C={};if(w.type==="literal")C.regex=w.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(w.component==="Z"||w.component==="z"){let j;Array.isArray(w.integerFormat.groupingSeparators)||(j=w.integerFormat.groupingSeparators),C.regex="",w.component==="z"&&(C.regex="GMT"),C.regex+="[-+][0-9]+",j&&(C.regex+=j.character+"[0-9]+"),C.parse=function(D){w.component==="z"&&(D=D.substring(3));let F=0,J=0;return j?(F=Number.parseInt(D.substring(0,D.indexOf(j.character))),J=Number.parseInt(D.substring(D.indexOf(j.character)+1))):D.length-1<=2?F=Number.parseInt(D):(F=Number.parseInt(D.substring(0,3)),J=Number.parseInt(D.substring(3))),F*60+J}}else if(w.integerFormat)C=d(w.integerFormat);else{C.regex="[a-zA-Z]+";var B={};if(w.component==="M"||w.component==="x")Re.forEach(function(j,D){w.width&&w.width.max?B[j.substring(0,w.width.max)]=D+1:B[j]=D+1});else if(w.component==="F")ve.forEach(function(j,D){D>0&&(w.width&&w.width.max?B[j.substring(0,w.width.max)]=D:B[j]=D)});else if(w.component==="P")B={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:w.component};C.parse=function(j){return B[j]}}return C.component=w.component,C});else{A.type="integer";const w=v.case===$.UPPER;switch(v.primary){case T.LETTERS:A.regex=w?"[A-Z]+":"[a-z]+",A.parse=function(C){return ne(C,w?"A":"a")};break;case T.ROMAN:A.regex=w?"[MDCLXVI]+":"[mdclxvi]+",A.parse=function(C){return H(w?C:C.toUpperCase())};break;case T.WORDS:A.regex="(?:"+Object.keys(E).concat("and","[\\-, ]").join("|")+")+",A.parse=function(C){return I(C.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(C){let B=C;return v.ordinal&&(B=C.substring(0,C.length-2)),v.regular?B=B.split(",").join(""):v.groupingSeparators.forEach(j=>{B=B.split(j.character).join("")}),v.zeroCode!==48&&(B=B.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-v.zeroCode+48)).join("")),parseInt(B)};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),C=d(w),B="^"+C.parts.map(J=>"("+J.regex+")").join("")+"$";var D=new RegExp(B,"i").exec(v);if(D!==null){const G={};for(let De=1;De<D.length;De++){const u=C.parts[De-1];u.parse&&(G[u.component]=u.parse(D[De]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ze=0;const it=De=>{Ze<<=1,Ze+=De?1:0},qe=De=>!(~De&Ze)&&!!(De&Ze);"YXMxWwdD".split("").forEach(De=>it(G[De]));const He=!qe(161)&&qe(130),wt=qe(84),Tt=!wt&&qe(72);Ze=0,"PHhmsf".split("").forEach(De=>it(G[De]));const At=!qe(23)&&qe(47),Jt=(He?"YD":wt?"XxwF":Tt?"XWF":"YMD")+(At?"Phmsf":"Hmsf"),ut=this.environment.timestamp;let $t=!1,yt=!1;if(Jt.split("").forEach(De=>{if(typeof G[De]>"u")$t?(G[De]="MDd".indexOf(De)!==-1?1:0,yt=!0):G[De]=ae(ut,De);else if($t=!0,yt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,He){const De=Date.UTC(G.Y,0),u=(G.d-1)*1e3*60*60*24,h=new Date(De+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 Pe(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:Pe}})();a.exports=c},{"./utils":6}],2:[function(t,a,s){(function(i){(function(){var c=t("./utils");const f=(()=>{var b=c.isNumeric,k=c.isArrayOfStrings,M=c.isArrayOfNumbers,S=c.createSequence,x=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 $(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,_){return typeof _<"u"&&_!==null&&_.toPrecision&&b(_)?Number(_.toPrecision(15)):_&&E(_)?"":_},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 _=o>=0?o+l:p+o+l;return g.slice(o,_).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 Re(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)-Re(n);if(p>0){var _=new Array(p+1).join(l);l.length>1&&(_=de(_,0,p)),o>0?g=n+_:g=_+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,_=await ue(o,n);if(typeof _<"u")for(;typeof _<"u"&&(typeof l>"u"||p<l);)g.push({match:_.match,index:_.start,groups:_.groups}),_=await ue(_.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 _;typeof l=="string"?_=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}:_=l;var R="",q=0;if(typeof g>"u"||g>0){var X=0;if(typeof o=="string"){for(var Oe=n.indexOf(o,q);Oe!==-1&&(typeof g>"u"||X<g);)R+=n.substring(q,Oe),R+=l,q=Oe+o.length,X++,Oe=n.indexOf(o,q);R+=n.substring(q)}else{var pe=await ue(o,n);if(typeof pe<"u"){for(;typeof pe<"u"&&(typeof g>"u"||X<g);){R+=n.substring(q,pe.start);var Ce=_.apply(p,[pe]);if(se(Ce)&&(Ce=await Ce),typeof Ce=="string")R+=Ce;else throw{code:"D3012",stack:new Error().stack,value:Ce};q=pe.start+pe.match.length,X++,pe=await ue(pe.next)}R+=n.substring(q)}else R=n}}else R=n;return R}}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 Pe(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,_=await ue(o,n);if(typeof _<"u"){for(var R=0;typeof _<"u"&&(typeof l>"u"||p<l);)g.push(n.substring(R,_.start)),R=_.end,_=await ue(_.next),p++;(typeof l>"u"||p<l)&&g.push(n.substring(R))}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 _=[],R=p["zero-digit"].charCodeAt(0),q=R;q<R+10;q++)_.push(String.fromCharCode(q));var X=_.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),Oe=o.split(p["pattern-separator"]);if(Oe.length>2)throw{code:"D3080",stack:new Error().stack};var pe=function(te){var Me=(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(Me.length,te.length-Ye.length),Xe,St,Qe,Mt,rt=te.indexOf(p["exponent-separator"],Me.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,Mt=Ye):(Qe=Xe.substring(0,lt),Mt=Xe.substring(lt+1)),{prefix:Me,suffix:Ye,activePart:Ne,mantissaPart:Xe,exponentPart:St,integerPart:Qe,fractionalPart:Mt,subpicture:te}},Ce=function(te){var Me,Ye,Ne=te.subpicture,Xe=Ne.indexOf(p["decimal-separator"]);Xe!==Ne.lastIndexOf(p["decimal-separator"])&&(Me="D3081"),Ne.indexOf(p.percent)!==Ne.lastIndexOf(p.percent)&&(Me="D3082"),Ne.indexOf(p["per-mille"])!==Ne.lastIndexOf(p["per-mille"])&&(Me="D3083"),Ne.indexOf(p.percent)!==-1&&Ne.indexOf(p["per-mille"])!==-1&&(Me="D3084");var St=!1;for(Ye=0;Ye<te.mantissaPart.length;Ye++){var Qe=te.mantissaPart.charAt(Ye);if(_.indexOf(Qe)!==-1||Qe===p.digit){St=!0;break}}St||(Me="D3085");var Mt=te.activePart.split("").map(function(Le){return X.indexOf(Le)===-1?"p":"a"}).join("");Mt.indexOf("p")!==-1&&(Me="D3086"),Xe!==-1?(Ne.charAt(Xe-1)===p["grouping-separator"]||Ne.charAt(Xe+1)===p["grouping-separator"])&&(Me="D3087"):te.integerPart.charAt(te.integerPart.length-1)===p["grouping-separator"]&&(Me="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Me="D3089");var rt=te.integerPart.indexOf(p.digit);rt!==-1&&te.integerPart.substring(0,rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3090"),rt=te.fractionalPart.lastIndexOf(p.digit),rt!==-1&&te.fractionalPart.substring(rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3091");var lt=typeof te.exponentPart=="string";if(lt&&te.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Me="D3092"),lt&&(te.exponentPart.length===0||te.exponentPart.split("").filter(function(Le){return _.indexOf(Le)===-1}).length>0)&&(Me="D3093"),Me)throw{code:Me,stack:new Error().stack}},Se=function(te){var Me=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 _.indexOf(Wt)!==-1||Wt===p.digit}).length;er.push(wr),kt=te.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Me(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=Me(te.fractionalPart,!0),Qe=te.integerPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length,Mt=Qe,rt=te.fractionalPart.split(""),lt=rt.filter(function(Ve){return _.indexOf(Ve)!==-1}).length,Le=rt.filter(function(Ve){return _.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&<===0&&(lt=1);var un=0;return nt&&(un=te.exponentPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:Mt,prefix:te.prefix,fractionalPartGroupingPositions:St,minimumFactionalPartSize:lt,maximumFactionalPartSize:Le,minimumExponentSize:un,suffix:te.suffix,picture:te.subpicture}},We=Oe.map(pe);We.forEach(Ce);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 Be;n>=0?Be=ke[0]:Be=ke[1];var Xt;Be.picture.indexOf(p.percent)!==-1?Xt=n*100:Be.picture.indexOf(p["per-mille"])!==-1?Xt=n*1e3:Xt=n;var Rt,Zt;if(Be.minimumExponentSize===0)Rt=Xt;else{var On=Math.pow(10,Be.scalingFactor),Pn=Math.pow(10,Be.scalingFactor-1);for(Rt=Xt,Zt=0;Rt<Pn;)Rt*=10,Zt-=1;for(;Rt>On;)Rt/=10,Zt+=1}var Cn=F(Rt,Be.maximumFactionalPartSize),on=function(te,Me){var Ye=Math.abs(te).toFixed(Me);return ot!=="0"&&(Ye=Ye.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?_[Ne.charCodeAt(0)-48]:Ne}).join("")),Ye},oe=on(Cn,Be.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=Be.minimumIntegerPartSize-Ge,cn=Be.minimumFactionalPartSize-(oe.length-Ge-1);if(oe=(Qt>0?new Array(Qt+1).join(ot):"")+oe,oe=oe+(cn>0?new Array(cn+1).join(ot):""),Ge=oe.indexOf(ze),Be.regularGrouping>0)for(var Nn=Math.floor((Ge-1)/Be.regularGrouping),gr=1;gr<=Nn;gr++)oe=[oe.slice(0,Ge-gr*Be.regularGrouping),Lt,oe.slice(Ge-gr*Be.regularGrouping)].join("");else Be.integerPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,Ge-te),Lt,oe.slice(Ge-te)].join(""),Ge++});if(Ge=oe.indexOf(ze),Be.fractionalPartGroupingPositions.forEach(function(te){oe=[oe.slice(0,te+Ge+1),Lt,oe.slice(te+Ge+1)].join("")}),Ge=oe.indexOf(ze),(Be.picture.indexOf(ze)===-1||Ge===oe.length-1)&&(oe=oe.substring(0,oe.length-1)),typeof Zt<"u"){var vr=on(Zt,0);Qt=Be.minimumExponentSize-vr.length,Qt>0&&(vr=new Array(Qt+1).join(ot)+vr),oe=oe+p["exponent-separator"]+(Zt<0?je:"")+vr}return oe=Be.prefix+oe+Be.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 C(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 B(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 D(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],_=me(n);return _>=2&&p.push(l),_>=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),_=await o.apply(this,p);typeof _<"u"&&l.push(_)}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],_=he(o,p,g,n),R=await o.apply(this,_);K(R)&&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 _=n[p],R=!0;if(typeof o<"u"){var q=he(o,_,p,n),X=await o.apply(this,q);R=K(X)}if(R)if(!l)g=_,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(_){return Array.isArray(_)?_.length:0})),g=0;g<l;g++){var p=o.map(_=>_[g]);n.push(p)}return n}async function $e(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 _;for(typeof l>"u"&&n.length>0?(g=n[0],_=1):(g=l,_=0);_<n.length;){var R=[g,n[_]];p>=3&&R.push(_),p>=4&&R.push(n),g=await o.apply(this,R),_++}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(_){l[_]=!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(_=>l.push(_)):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),_=await o.apply(this,p);typeof _<"u"&&l.push(_)}return l}function ut(n){throw{code:"D3137",stack:new Error().stack,message:n||"$error() function evaluated"}}function $t(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 De(n,o){if(!(typeof n>"u")){if(n.length<=1)return n;var l;if(typeof o>"u"){if(!M(n)&&!k(n))throw{stack:new Error().stack,code:"D3070",index:1};l=async function(R,q){return R>q}}else l=o;var g=async function(R,q){var X=async function(pe,Ce,Se){Ce.length===0?Array.prototype.push.apply(pe,Se):Se.length===0?Array.prototype.push.apply(pe,Ce):await l(Ce[0],Se[0])?(pe.push(Se[0]),await X(pe,Ce,Se.slice(1))):(pe.push(Ce[0]),await X(pe,Ce.slice(1),Se))},Oe=[];return await X(Oe,R,q),Oe},p=async function(R){if(!Array.isArray(R)||R.length<=1)return R;var q=Math.floor(R.length/2),X=R.slice(0,q),Oe=R.slice(q);return X=await p(X),Oe=await p(Oe),await g(X,Oe)},_=await p(n);return _}}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=x(n)?S():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,_=0;_<o.length;_++)if(ge(g,o[_])){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],_=he(o,p,g,n),R=await o.apply(this,_);K(R)&&(l[g]=p)}return Object.keys(l).length===0&&(l=void 0),l}return{sum:N,count:ne,max:L,min:T,average:$,string:z,substring:de,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Re,trim:et,pad:_e,match:ae,contains:tt,replace:Fe,split:Ee,join:v,formatNumber:A,formatBase:w,number:C,floor:j,ceil:D,round:F,abs:B,sqrt:J,power:ye,random:we,boolean:K,not:Q,map:G,zip:qe,filter:Ze,single:it,foldLeft:$e,sift:y,keys:He,lookup:wt,append:Tt,exists:mr,spread:At,merge:Z,reverse:yr,each:Jt,error:ut,assert:$t,type:yt,sort:De,shuffle:u,distinct:h,base64encode:st,base64decode:d,encodeUrlComponent:m,encodeUrl:V,decodeUrlComponent:le,decodeUrl:Pe}})();a.exports=f}).call(this)}).call(this,typeof pn<"u"?pn: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"),k=t("./signature"),M=(function(){var S=f.isNumeric,x=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,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 Re(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 D(u,h,y);break;case"bind":n=await B(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 _=u.steps[p];if(_.tuple&&(l=!0),p===0&&_.consarray?o=await $(_,n,y):l?g=await Ae(_,n,g,y):o=await xe(_,n,y,p===u.steps.length-1),!l&&(typeof o>"u"||o.length===0))break;typeof _.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,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 _=I();return n&&o.length===1&&Array.isArray(o[0])&&!se(o[0])?_=o[0]:o.forEach(function(R){!Array.isArray(R)||R.cons?_.push(R):R.forEach(q=>_.push(q))}),_}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 _=n;y===void 0&&(y=h.map(Oe=>({"@":Oe})));for(var R=0;R<y.length;R++){_=de(n,y[R]);var q=await $(u,y[R]["@"],_);if(typeof q<"u"){Array.isArray(q)||(q=[q]);for(var X=0;X<q.length;X++)p={},Object.assign(p,y[R]),q.tupleStream?Object.assign(p,q[X]):(u.focus?(p[u.focus]=q[X],p["@"]=y[R]["@"]):p["@"]=q[X],u.index&&(p[u.index]=X),u.ancestor&&(p[u.ancestor.label]=y[R]["@"])),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 _=await $(u,g,p);S(_)&&(_=[_]),E(_)?_.forEach(function(q){var X=Math.floor(q);X<0&&(X=h.length+X),X===o&&n.push(l)}):c.boolean(_)&&n.push(l)}return n}async function Re(u,h,y){var n,o=await $(u.lhs,h,y),l=u.value,g=async()=>await $(u.rhs,h,y);if(l==="and"||l==="or")try{return await Pe(o,g,l)}catch(_){throw _.position=u.position,_.token=l,_}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=C(o,p);break;case"in":n=le(o,p);break}}catch(_){throw _.position=u.position,_.token=l,_}return n}async function et(u,h,y){var n;switch(u.value){case"-":if(n=await $(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,_)=>(y.isParallelCall=_>0,[p,await $(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 Pe(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],_=l?de(y,p):y,R=0;R<u.lhs.length;R++){var q=u.lhs[R],X=await $(q[0],l?p["@"]:p,_);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:u.position,value:X};if(X!==void 0){var Oe={data:p,exprIndex:R};if(o.hasOwnProperty(X)){if(o[X].exprIndex!==R)throw{code:"D1009",stack:new Error().stack,position:u.position,value:X};o[X].data=c.append(o[X].data,p)}else o[X]=Oe}}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.lhs[ke.exprIndex][1],je,ot)]}));for(let Se of pe){var[X,Ce]=await Se;typeof Ce<"u"&&(n[X]=Ce)}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 C(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 B(u,h,y){var n=await $(u.rhs,h,y);return y.bind(u.lhs.value,n),n}async function j(u,h,y){var n,o=await $(u.condition,h,y);return c.boolean(o)?n=await $(u.then,h,y):typeof u.else<"u"&&(n=await $(u.else,h,y)),n}async function D(u,h,y){for(var n,o=ut(y),l=0;l<u.expressions.length;l++)n=await $(u.expressions[l],h,o);return n}function F(u){var h=new De.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 _=y(n,h.lastIndex);if(_&&_.match==="")throw{code:"D1004",stack:new Error().stack,position:u.position,value:u.value.source};return _}}}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(_,R){for(var q=0,X=0;q===0&&X<u.terms.length;X++){var Oe=u.terms[X],pe=_,Ce=y;l&&(pe=_["@"],Ce=de(y,_));var Se=await $(Oe.expression,pe,Ce);pe=R,Ce=y,l&&(pe=R["@"],Ce=de(y,R));var We=await $(Oe.expression,pe,Ce),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,Oe.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.pattern,g,y);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var _=0;_<p.length;_++){var R=p[_];if(R&&(R.isPrototypeOf(g)||R instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:u.position};var q=await $(u.update,R,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 Oe in q)R[Oe]=q[Oe]}if(typeof u.delete<"u"){var pe=await $(u.delete,R,y);if(typeof pe<"u"){var Ce=pe;if(Array.isArray(pe)||(pe=[pe]),!x(pe))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Ce};for(var Se=0;Se<pe.length;Se++)typeof R=="object"&&R!==null&&delete R[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.lhs,h,y);if(u.rhs.type==="function")n=await he(u.rhs,h,y,{context:o});else{var l=await $(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 $(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.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 R=await $(u.arguments[p],h,y);if(me(R)){const q=async function(...X){return await G(R,X,null,y)};q.arity=ne(R),g.push(q)}else g.push(R)}var _=u.procedure.type==="path"?u.procedure.steps[0].value:u.procedure.value;try{typeof l=="object"&&(l.token=_,l.position=u.position),o=await G(l,g,h,y)}catch(R){throw R.position||(R.position=u.position),R.token||(R.token=_),R}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 $(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 $(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=$e(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 $(g,h,y))}var p=await $(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 $e(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.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=k(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 $(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 $t={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=$t[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 De(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?De.RegexEngine=h.RegexEngine:De.RegexEngine=RegExp,{evaluate:async function(g,p,_){if(typeof n<"u"){var R={code:"S0500",position:0};throw yt(R),R}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 Oe;try{return Oe=await $(y,g,q),typeof _=="function"&&_(null,Oe),Oe}catch(pe){throw yt(pe),pe}},assign:function(g,p){o.bind(g,p)},registerFunction:function(g,p,_){var R=Z(p,_);o.bind(g,R)},ast:function(){return y},errors:function(){return n}}}return De.parser=b,De})();a.exports=M},{"./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
|
+
`,r:"\r",t:" "},k=function(S){var x=0,E=S.length,I=function(ge,H){var N={type:ge,value:H,position:x};return N},se=function(){for(var ge=x,H=0,N,ne,L=function($){if(S.charAt($)==="/"&&H===0){for(var z=0;S.charAt($-(z+1))==="\\";)z++;if(z%2===0)return!0}return!1};x<E;){var T=S.charAt(x);if(L(x)){if(N=S.substring(ge,x),N==="")throw{code:"S0301",stack:new Error().stack,position:x};for(x++,T=S.charAt(x),ge=x;T==="i"||T==="m";)x++,T=S.charAt(x);return ne=S.substring(ge,x)+"g",new RegExp(N,ne)}(T==="("||T==="["||T==="{")&&S.charAt(x-1)!=="\\"&&H++,(T===")"||T==="]"||T==="}")&&S.charAt(x-1)!=="\\"&&H--,x++}throw{code:"S0302",stack:new Error().stack,position:x}},me=function(ge){if(x>=E)return null;for(var H=S.charAt(x);x<E&&`
|
|
3
|
+
\r\v`.indexOf(H)>-1;)x++,H=S.charAt(x);if(H==="/"&&S.charAt(x+1)==="*"){var N=x;for(x+=2,H=S.charAt(x);!(H==="*"&&S.charAt(x+1)==="/");)if(H=S.charAt(++x),x>=E)throw{code:"S0106",stack:new Error().stack,position:N};return x+=2,H=S.charAt(x),me(ge)}if(ge!==!0&&H==="/")return x++,I("regex",se());if(H==="."&&S.charAt(x+1)===".")return x+=2,I("operator","..");if(H===":"&&S.charAt(x+1)==="=")return x+=2,I("operator",":=");if(H==="!"&&S.charAt(x+1)==="=")return x+=2,I("operator","!=");if(H===">"&&S.charAt(x+1)==="=")return x+=2,I("operator",">=");if(H==="<"&&S.charAt(x+1)==="=")return x+=2,I("operator","<=");if(H==="*"&&S.charAt(x+1)==="*")return x+=2,I("operator","**");if(H==="~"&&S.charAt(x+1)===">")return x+=2,I("operator","~>");if(H==="?"&&S.charAt(x+1)===":")return x+=2,I("operator","?:");if(H==="?"&&S.charAt(x+1)==="?")return x+=2,I("operator","??");if(Object.prototype.hasOwnProperty.call(f,H))return x++,I("operator",H);if(H==='"'||H==="'"){var ne=H;x++;for(var L="";x<E;){if(H=S.charAt(x),H==="\\")if(x++,H=S.charAt(x),Object.prototype.hasOwnProperty.call(b,H))L+=b[H];else if(H==="u"){var T=S.substr(x+1,4);if(/^[0-9a-fA-F]+$/.test(T)){var $=parseInt(T,16);L+=String.fromCharCode($),x+=4}else throw{code:"S0104",stack:new Error().stack,position:x}}else throw{code:"S0103",stack:new Error().stack,position:x,token:H};else{if(H===ne)return x++,I("string",L);L+=H}x++}throw{code:"S0101",stack:new Error().stack,position:x}}var z=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,de=z.exec(S.substring(x));if(de!==null){var xe=parseFloat(de[0]);if(!isNaN(xe)&&isFinite(xe))return x+=de[0].length,I("number",xe);throw{code:"S0102",stack:new Error().stack,position:x,token:de[0]}}var Te;if(H==="`"){x++;var Ae=S.indexOf("`",x);if(Ae!==-1)return Te=S.substring(x,Ae),x=Ae+1,I("name",Te);throw x=E,{code:"S0105",stack:new Error().stack,position:x}}for(var ve=x,Re;;)if(Re=S.charAt(ve),ve===E||`
|
|
4
|
+
\r\v`.indexOf(Re)>-1||Object.prototype.hasOwnProperty.call(f,Re)){if(S.charAt(x)==="$")return Te=S.substring(x+1,ve),x=ve,I("variable",Te);switch(Te=S.substring(x,ve),x=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 x===E&&Te===""?null:I("name",Te)}}else ve++};return me},M=function(S,x){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(x)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(x){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 Pe=I(m);if(Pe===null)return E=se["(end)"],E.position=S.length,E;var Ee=Pe.value,v=Pe.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:Pe.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:Pe.position,token:Ee})}return E=Object.create(A),E.value=Ee,E.type=v,E.position=Pe.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},$=function(d){var m=N(d,0);m.nud=function(){return this}},z=function(d,m,V){var le=m||f[d],Pe=N(d,le);return Pe.led=V||function(Ee){return this.lhs=Ee,this.rhs=T(le),this.type="binary",this},Pe},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};$("(end)"),$("(name)"),$("(literal)"),$("(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"),$("and"),$("or"),$("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 Pe=L();Pe.id===">"?V--:Pe.id==="<"&&V++,le+=Pe.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,Re=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 Pe=0;Pe<le.length;Pe++){var Ee=le[Pe];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 Pe=m.steps[0];Pe.type==="unary"&&Pe.value==="["&&(Pe.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 C={type:"sort",position:d.position};C.terms=d.rhs.map(function(F){var J=ae(F.expression);return ue(C,J),{descending:F.descending,expression:J}}),m.steps.push(C),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 B=ae(d.body);m.body=Ae(B);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:Re++}},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 D={code:j,position:d.position,token:d.value};if(x)return me.push(D),{type:"error",error:D};throw D.stack=new Error().stack,D}return d.keepArray&&(m.keepArray=!0),m};I=k(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 M})();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(k){for(var M=1,S=[],x={},E=x;M<k.length;){var I=k.charAt(M);if(I===":")break;var se=function(){S.push(x),E=x,x={}},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":x.regex="["+I+"m]",x.type=I,se();break;case"a":x.regex="[asnblfom]",x.type=I,x.array=!0,se();break;case"f":x.regex="f",x.type=I,se();break;case"j":x.regex="[asnblom]",x.type=I,se();break;case"x":x.regex="[asnblfom]",x.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(k,M,"(",")"),H=k.substring(M+1,ge);if(H.indexOf("<")===-1)x.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:M};x.type="("+H+")",M=ge,se();break;case"<":if(E.type==="a"||E.type==="f"){var N=me(k,M,"<",">");E.subtype=k.substring(M+1,N),M=N}else throw{code:"S0401",stack:new Error().stack,value:E.type,offset:M};break}M++}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},$=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:k,validate:function(z,de){var xe="";z.forEach(function(Re){xe+=T(Re)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return S.forEach(function(Re,et){var _e=z[ve],ue=Te[et+1];if(ue==="")if(Re.context&&Re.contextRegex){var tt=T(de);if(Re.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(Re.type==="a"){if(ae==="m")_e=void 0;else{_e=z[ve];var Fe=!0;if(typeof Re.subtype<"u"){if(ae!=="a"&&ue!==Re.subtype)Fe=!1;else if(ae==="a"&&_e.length>0){var st=T(_e[0]);if(st!==Re.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[Re.subtype]};ae!=="a"&&(_e=[_e])}Ae.push(_e),ve++}else Ae.push(_e),ve++})}),Ae}$(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 k(){var N=[];return N.sequence=!0,arguments.length===1&&N.push(arguments[0]),N}function M(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 x(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),$=Object.getOwnPropertyNames(ne);if(T.length!==$.length)return!1;for(T=T.sort(),$=$.sort(),L=0;L<T.length;L++)if(T[L]!==$[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:k,isSequence:M,isFunction:S,isLambda:E,isIterable:se,getFunctionArity:x,isDeepEqual:me,stringToArray:H,isPromise:ge}})();a.exports=i},{}]},{},[3])(3)})})(Rr)),Rr.exports}var Vs=zs();const qs=Ws(Vs),an=O.object({name:O.literal("data-extract"),code:O.string(),inputData:O.any().optional()});function Hs(r){return an.parse(r)}async function Gs(r){try{console.log("[DataExtractBlock] Executing JSONata query:",r.code);const t=await qs(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 Ys={"get-text":Wr,"attribute-value":zr,"get-value-form":Vr,"set-value-form":qr,"clear-value-form":Hr,"element-exists":Gr,"event-click":Yr,keypress:Kr,wait:Jr,"wait-for-condition":Xr,navigate:Qr,"save-assets":en,"get-element-data":tn,scroll:rn,"ai-parse-data":Zr,"fetch-api":nn,"data-extract":an};class Ks{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=Qa(e);return await es(t)}case"attribute-value":{const t=rs(e);return await ns(t)}case"get-value-form":{const t=as(e);return await ss(t)}case"set-value-form":{const t=os(e);return await cs(t)}case"clear-value-form":{const t=ls(e);return await fs(t)}case"element-exists":{const t=hs(e);return await ps(t)}case"event-click":{const t=ms(e);return await ys(t)}case"keypress":{const t=ws(e);return await ks(t)}case"wait":{const t=_s(e);return await Es(t)}case"wait-for-condition":{const t=Ts(e);return await As(t)}case"navigate":{const t=Ss(e);return await Ds(t)}case"save-assets":{const t=Os(e);return await Ps(t)}case"get-element-data":{const t=Ns(e);return await Rs(t)}case"scroll":{const t=Is(e);return await js(t)}case"ai-parse-data":{const t=Za(e);return await Wa(t)}case"fetch-api":{const t=Ls(e);return await Zs(t)}case"data-extract":{const t=Hs(e);return await Gs(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 Js{constructor(){fe(this,"expr");fe(this,"json")}}class Xs{constructor(){fe(this,"template");fe(this,"valueFrom");fe(this,"default")}}class Qs{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 ei{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 ti{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 ri{constructor(){fe(this,"success");fe(this,"steps");fe(this,"targetUrl");fe(this,"timestamp");fe(this,"error")}}var Pr=(r=>(r.USD="USD",r.KRW="KRW",r.EUR="EUR",r.GBP="GBP",r.CAD="CAD",r.CNY="CNY",r.JPY="JPY",r.VND="VND",r.ARS="ARS",r.INR="INR",r.TWD="TWD",r.AUD="AUD",r.HKD="HKD",r.IDR="IDR",r.MXN="MXN",r.NZD="NZD",r.SGD="SGD",r.CHF="CHF",r.THB="THB",r.BRL="BRL",r.TRY="TRY",r.RUB="RUB",r.NOK="NOK",r.DKK="DKK",r.SEK="SEK",r.ILS="ILS",r.ZAR="ZAR",r.PLN="PLN",r.PHP="PHP",r.CZK="CZK",r.CLP="CLP",r.COP="COP",r.EGP="EGP",r.MYR="MYR",r.HUF="HUF",r.AED="AED",r.SAR="SAR",r.RON="RON",r.BGN="BGN",r))(Pr||{});const En={code:{type:"string",enum:Object.values(Pr),description:"Currency code"},symbol:{type:"string",enum:["$","₩","€","£","¥","₫","₹","NT$","Rp","₣","฿","R$","₺","₽","kr","₪","R","zł","₱","Kč","E£","RM","Ft","د.إ","﷼","L","лв"],description:"Currency symbol"},format:{type:"string",enum:["%s%u","%s%n","%u%s","%n%s","%s %u","%s %n","%u %s","%n %s"],description:"Display format (%s: symbol, %u/%n: amount)"},amount:{type:"number",description:"Actual amount value"},text:{type:"string",description:"Formatted display text (e.g., US$57.75)"}};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 ni(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}const Tn=Nt({name:Ue(),key:Ue(),image:Ue()});var sn=(r=>(r.monthly="MONTHLY",r.yearly="YEARLY",r))(sn||{});const Ur=Nt({code:Lr(Pr),symbol:Ue(),format:Ue(),amount:Kt(),text:Ue().optional()}),An=Nt({planName:Ue(),currentCycleBillAmount:Ur,nextPaymentDue:Ue(),cycleTerm:Lr(sn).nullable(),isFreeTier:Ut(),isPerUser:Ut(),paidMemberCount:Kt(),usedMemberCount:Kt(),unitPrice:Ur.nullable(),cardNumber:Ue(),cardName:Ue()}),Sn=Nt({uid:Ue(),issuedDate:Br.date(),paidDate:Br.date().nullable().optional(),paymentMethod:Ue(),amount:Ur,isSuccessfulPaid:Ut(),receiptUrl:Ue()}),Dn=Nt({name:Ue(),email:Ue().email(),profileImageUrl:Ue(),role:Ue()});class ai{constructor(){}async checkExtension(){return new Promise((e,t)=>{const a=setTimeout(()=>{t(ct.extensionNotInstalled())},5e3),s=i=>{ni(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 k,M,S,x;if(((k=b.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&b.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const E=b.data,I=((M=E==null?void 0:E.result)==null?void 0:M.steps)??((x=(S=E==null?void 0:E.result)==null?void 0:S.result)==null?void 0:x.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{...t,data:[],isSuccess:!1};const s=[];for(const f of a){const b=Tn.safeParse(f);b.success?s.push(b.data):console.warn("Invalid workspace data:",f,b.error)}return{...t,data:s,isSuccess:!0}}async getWorkspacePlanAndCycle(e,t){var c,f;t.workflow.vars={...t.workflow.vars,workspaceKey:e};const a=await this.collectWorkflow(t);if(!a.success)throw new ct("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const s=(f=(c=a.steps[a.steps.length-1])==null?void 0:c.result)==null?void 0:f.data;if(!s)return{...a};const i=An.safeParse(s);if(i.success){const b=i.data;return{...a,...b}}else return console.warn("Invalid workspace billing data:",s,i.error),{...a}}async getWorkspaceBillingHistories(e,t){var c,f;t.workflow.vars={...t.workflow.vars,workspaceKey:e};const a=await this.collectWorkflow(t);if(!a.success)throw new ct("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const s=(f=(c=a.steps[a.steps.length-1])==null?void 0:c.result)==null?void 0:f.data;if(!s||!Array.isArray(s))return{...a,data:[]};const i=[];for(const b of s){const k=Sn.safeParse(b);k.success?i.push(k.data):console.warn("Invalid workspace billing history data:",b,k.error)}return{...a,data:i}}async getWorkspaceMembers(e,t){var c,f;t.workflow.vars={...t.workflow.vars,workspaceKey:e};const a=await this.collectWorkflow(t);if(!a.success)throw new ct("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const s=(f=(c=a.steps[a.steps.length-1])==null?void 0:c.result)==null?void 0:f.data;if(!s||!Array.isArray(s))return{...a,data:[]};const i=[];for(const b of s){const k=Dn.safeParse(b);k.success?i.push(k.data):console.warn("Invalid workspace member data:",b,k.error)}return{...a,data:i}}}exports.AiParseDataBlockSchema=Zr;exports.AllBlockSchemas=Ys;exports.BaseBlockSchema=pt;exports.BillingCycleTerm=sn;exports.Binding=Xs;exports.BlockHandler=Ks;exports.ClearValueFormsBlockSchema=Hr;exports.CollectWorkflowResult=ri;exports.Condition=Js;exports.CurrencyCode=Pr;exports.CurrencyInfoSchema=En;exports.DataExtractBlockSchema=an;exports.EightGClient=ai;exports.EightGError=ct;exports.ElementExistsBlockSchema=Gr;exports.EventClickBlockSchema=Yr;exports.FetchApiBlockSchema=nn;exports.GetAttributeValueBlockSchema=zr;exports.GetElementDataBlockSchema=tn;exports.GetTextBlockSchema=Wr;exports.GetValueFormsBlockSchema=Vr;exports.KeypressBlockSchema=Kr;exports.NavigateBlockSchema=Qr;exports.SaveAssetsBlockSchema=en;exports.Schema=qa;exports.ScrollBlockSchema=rn;exports.SetValueFormsBlockSchema=qr;exports.WaitBlockSchema=Jr;exports.WaitForConditionBlockSchema=Xr;exports.Workflow=ei;exports.WorkflowStep=Qs;exports.WorkflowStepRunResult=ti;exports.WorkspaceBillingHistorySchema=Sn;exports.WorkspaceBillingSchema=An;exports.WorkspaceItemSchema=Tn;exports.WorkspaceMemberSchema=Dn;exports.createArraySchema=Va;exports.createSchema=za;
|