scordi-extension 1.15.13 → 1.15.15
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/NetworkCatchBlock.d.ts +78 -0
- package/dist/blocks/NetworkCatchBlock.d.ts.map +1 -0
- package/dist/blocks/TransformDataBlock.d.ts.map +1 -1
- package/dist/blocks/index.d.ts +50 -0
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/sdk/index.cjs +4 -4
- package/dist/sdk/index.js +945 -889
- package/dist/src/blocks/NetworkCatchBlock.ts.js +56 -0
- package/dist/src/blocks/TransformDataBlock.ts.js +1 -0
- package/dist/src/blocks/index.ts.js +9 -1
- package/dist/src/types/internal-messages.ts.js +3 -0
- package/dist/types/internal-messages.d.ts +19 -1
- package/dist/types/internal-messages.d.ts.map +1 -1
- package/dist/vendor/vite-client.js +1 -1
- package/package.json +1 -1
package/dist/sdk/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Mn=Object.defineProperty;var In=(r,e,t)=>e in r?Mn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ue=(r,e,t)=>In(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"]),jn=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 Gt=(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 vn=Gt;function Fn(r){vn=r}function xr(){return vn}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}},Bn=[];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===Gt?void 0:Gt].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 te;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 te;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 te=Object.freeze({status:"aborted"}),qt=r=>({status:"dirty",value:r}),Je=r=>({status:"valid",value:r}),Ir=r=>r.status==="aborted",jr=r=>r.status==="dirty",Ft=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 dn=(r,e)=>{if(Ft(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 oe(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 le{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 dn(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 Ft(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=>Ft(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 dn(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:ne.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 Nt.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({...oe(this._def),schema:this,typeName:ne.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new fr({...oe(this._def),innerType:this,defaultValue:t,typeName:ne.ZodDefault})}brand(){return new $r({typeName:ne.ZodBranded,type:this,...oe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new dr({...oe(this._def),innerType:this,catchValue:t,typeName:ne.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 Un=/^c[^\s-]{8,}$/i,$n=/^[0-9a-z]+$/,Ln=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Zn=/^[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,Wn=/^[a-z0-9_-]{21}$/i,zn=/^[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)?)??$/,qn=/^(?!\.)(?!.*\.\.)([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 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])$/,Yn=/^(?:(?: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]))$/,Jn=/^(([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])$/,Xn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Qn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bn="((\\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])))",ea=new RegExp(`^${bn}$`);function wn(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 ta(r){return new RegExp(`^${wn(r)}$`)}function kn(r){let e=`${bn}T${wn(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 ra(r,e){return!!((e==="v4"||!e)&&Gn.test(r)||(e==="v6"||!e)&&Kn.test(r))}function na(r,e){if(!zn.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 aa(r,e){return!!((e==="v4"||!e)&&Yn.test(r)||(e==="v6"||!e)&&Jn.test(r))}class ft extends le{_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}),te}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")qn.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")Zn.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")Wn.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")Un.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")$n.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")Ln.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"?kn(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"?ea.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?ta(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"?ra(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"?na(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"?aa(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"?Xn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?Qn.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:ne.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...oe(r)});function sa(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 Ot extends le{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}),te}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"?sa(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 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]})}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)}}Ot.create=r=>new Ot({checks:[],typeName:ne.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...oe(r)});class Pt extends le{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}),te}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 Pt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Pt({...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}}Pt.create=r=>new Pt({checks:[],typeName:ne.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...oe(r)});class rr extends le{_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}),te}return Je(e.data)}}rr.create=r=>new rr({typeName:ne.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...oe(r)});class Bt extends le{_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}),te}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_date}),te}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 Bt({...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}}Bt.create=r=>new Bt({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ne.ZodDate,...oe(r)});class Er extends le{_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}),te}return Je(e.data)}}Er.create=r=>new Er({typeName:ne.ZodSymbol,...oe(r)});class nr extends le{_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}),te}return Je(e.data)}}nr.create=r=>new nr({typeName:ne.ZodUndefined,...oe(r)});class ar extends le{_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}),te}return Je(e.data)}}ar.create=r=>new ar({typeName:ne.ZodNull,...oe(r)});class Yt extends le{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Yt.create=r=>new Yt({typeName:ne.ZodAny,...oe(r)});class jt extends le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}jt.create=r=>new jt({typeName:ne.ZodUnknown,...oe(r)});class Et extends le{_parse(e){const t=this._getOrReturnCtx(e);return U(t,{code:P.invalid_type,expected:W.never,received:t.parsedType}),te}}Et.create=r=>new Et({typeName:ne.ZodNever,...oe(r)});class Tr extends le{_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}),te}return Je(e.data)}}Tr.create=r=>new Tr({typeName:ne.ZodVoid,...oe(r)});class dt extends le{_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}),te;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:ne.ZodArray,...oe(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 Nt?Nt.create(Vt(r.unwrap())):r instanceof bt?bt.create(r.items.map(e=>Vt(e))):r}class Ie extends le{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}),te}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:ne.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 xn(be.objectKeys(this.shape))}}Ie.create=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});Ie.strictCreate=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strict",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});Ie.lazycreate=(r,e)=>new Ie({shape:r,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});class sr extends le{_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}),te}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}),te}}get options(){return this._def.options}}sr.create=(r,e)=>new sr({options:r,typeName:ne.ZodUnion,...oe(e)});const xt=r=>r instanceof cr?xt(r.schema):r instanceof ht?xt(r.innerType()):r instanceof ur?[r.value]:r instanceof Ct?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 Nt?[null,...xt(r.unwrap())]:r instanceof $r||r instanceof hr?xt(r.unwrap()):r instanceof dr?xt(r._def.innerType):[];class Dr extends le{_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}),te;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]}),te)}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:ne.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...oe(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 le{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(Ir(i)||Ir(c))return te;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}),te)};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:ne.ZodIntersection,...oe(t)});class bt extends le{_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}),te;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"}),te;!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:ne.ZodTuple,rest:null,...oe(e)})};class or extends le{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}),te;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 le?new or({keyType:e,valueType:t,typeName:ne.ZodRecord,...oe(a)}):new or({keyType:ft.create(),valueType:e,typeName:ne.ZodRecord,...oe(t)})}}class Ar extends le{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}),te;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 te;(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 te;(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:ne.ZodMap,...oe(t)});class Ut extends le{_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}),te;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 te;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 Ut({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new Ut({...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)}}Ut.create=(r,e)=>new Ut({valueType:r,minSize:null,maxSize:null,typeName:ne.ZodSet,...oe(e)});class Ht extends le{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}),te;function a(f,b){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),Gt].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(),Gt].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(A=>{throw k.addIssue(a(b,A)),k}),S=await Reflect.apply(c,this,M);return await f._def.returns._def.type.parseAsync(S,i).catch(A=>{throw k.addIssue(s(S,A)),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(jt.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(jt.create()),returns:t||jt.create(),typeName:ne.ZodFunction,...oe(a)})}}class cr extends le{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:ne.ZodLazy,...oe(e)});class ur extends le{_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}),te}return{status:"valid",value:e.data}}get value(){return this._def.value}}ur.create=(r,e)=>new ur({value:r,typeName:ne.ZodLiteral,...oe(e)});function xn(r,e){return new Ct({values:r,typeName:ne.ZodEnum,...oe(e)})}class Ct extends le{_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}),te}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}),te}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 Ct.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ct.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Ct.create=xn;class lr extends le{_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}),te}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}),te}return Je(e.data)}get enum(){return this._def.values}}lr.create=(r,e)=>new lr({values:r,typeName:ne.ZodNativeEnum,...oe(e)});class Kt extends le{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}),te;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:ne.ZodPromise,...oe(e)});class ht extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ne.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 te;const b=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return b.status==="aborted"?te:b.status==="dirty"||t.value==="dirty"?qt(b.value):b});{if(t.value==="aborted")return te;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?te:f.status==="dirty"||t.value==="dirty"?qt(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"?te:(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"?te:(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(!Ft(c))return te;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=>Ft(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:t.value,value:f})):te);be.assertNever(s)}}ht.create=(r,e,t)=>new ht({schema:r,typeName:ne.ZodEffects,effect:e,...oe(t)});ht.createWithPreprocess=(r,e,t)=>new ht({schema:e,effect:{type:"preprocess",transform:r},typeName:ne.ZodEffects,...oe(t)});class gt extends le{_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:ne.ZodOptional,...oe(e)});class Nt extends le{_parse(e){return this._getType(e)===W.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Nt.create=(r,e)=>new Nt({innerType:r,typeName:ne.ZodNullable,...oe(e)});class fr extends le{_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:ne.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...oe(e)});class dr extends le{_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:ne.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...oe(e)});class Sr extends le{_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}),te}return{status:"valid",value:e.data}}}Sr.create=r=>new Sr({typeName:ne.ZodNaN,...oe(r)});const ia=Symbol("zod_brand");class $r extends le{_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 le{_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"?te:i.status==="dirty"?(t.dirty(),qt(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"?te: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:ne.ZodPipeline})}}class hr extends le{_parse(e){const t=this._def.innerType._parse(e),a=s=>(Ft(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:ne.ZodReadonly,...oe(e)});function hn(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function _n(r,e={},t){return r?Yt.create().superRefine((a,s)=>{const i=r(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=hn(e,a),b=f.fatal??t??!0;s.addIssue({code:"custom",...f,fatal:b})}});if(!i){const c=hn(e,a),f=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:f})}}):Yt.create()}const oa={object:Ie.lazycreate};var ne;(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"})(ne||(ne={}));const ca=(r,e={message:`Input not instance of ${r.name}`})=>_n(t=>t instanceof r,e),Ue=ft.create,$t=Ot.create,ua=Sr.create,la=Pt.create,Tt=rr.create,fa=Bt.create,da=Er.create,ha=nr.create,pa=ar.create,ma=Yt.create,ya=jt.create,ga=Et.create,va=Tr.create,ba=dt.create,Rt=Ie.create,wa=Ie.strictCreate,ka=sr.create,xa=Dr.create,_a=ir.create,Ea=bt.create,Ta=or.create,Aa=Ar.create,Sa=Ut.create,Da=Ht.create,Oa=cr.create,Pa=ur.create,Lr=Ct.create,Zr=lr.create,Ca=Kt.create,pn=ht.create,Na=gt.create,Ra=Nt.create,Ma=ht.createWithPreprocess,Ia=pr.create,ja=()=>Ue().optional(),Fa=()=>$t().optional(),Ba=()=>Tt().optional(),Br={string:(r=>ft.create({...r,coerce:!0})),number:(r=>Ot.create({...r,coerce:!0})),boolean:(r=>rr.create({...r,coerce:!0})),bigint:(r=>Pt.create({...r,coerce:!0})),date:(r=>Bt.create({...r,coerce:!0}))},Ua=te,D=Object.freeze(Object.defineProperty({__proto__:null,BRAND:ia,DIRTY:qt,EMPTY_PATH:Bn,INVALID:te,NEVER:Ua,OK:Je,ParseStatus:Ke,Schema:le,ZodAny:Yt,ZodArray:dt,ZodBigInt:Pt,ZodBoolean:rr,ZodBranded:$r,ZodCatch:dr,ZodDate:Bt,ZodDefault:fr,ZodDiscriminatedUnion:Dr,ZodEffects:ht,ZodEnum:Ct,ZodError:at,get ZodFirstPartyTypeKind(){return ne},ZodFunction:Ht,ZodIntersection:ir,ZodIssueCode:P,ZodLazy:cr,ZodLiteral:ur,ZodMap:Ar,ZodNaN:Sr,ZodNativeEnum:lr,ZodNever:Et,ZodNull:ar,ZodNullable:Nt,ZodNumber:Ot,ZodObject:Ie,ZodOptional:gt,ZodParsedType:W,ZodPipeline:pr,ZodPromise:Kt,ZodReadonly:hr,ZodRecord:or,ZodSchema:le,ZodSet:Ut,ZodString:ft,ZodSymbol:Er,ZodTransformer:ht,ZodTuple:bt,ZodType:le,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:jt,ZodVoid:Tr,addIssueToContext:U,any:ma,array:ba,bigint:la,boolean:Tt,coerce:Br,custom:_n,date:fa,datetimeRegex:kn,defaultErrorMap:Gt,discriminatedUnion:xa,effect:pn,enum:Lr,function:Da,getErrorMap:xr,getParsedType:_t,instanceof:ca,intersection:_a,isAborted:Ir,isAsync:tr,isDirty:jr,isValid:Ft,late:oa,lazy:Oa,literal:Pa,makeIssue:_r,map:Aa,nan:ua,nativeEnum:Zr,never:ga,null:pa,nullable:Ra,number:$t,object:Rt,get objectUtil(){return Mr},oboolean:Ba,onumber:Fa,optional:Na,ostring:ja,pipeline:Ia,preprocess:Ma,promise:Ca,quotelessJson:jn,record:Ta,set:Sa,setErrorMap:Fn,strictObject:wa,string:Ue,symbol:da,transformer:pn,tuple:Ea,undefined:ha,union:ka,unknown:ya,get util(){return be},void:va},Symbol.toStringTag,{value:"Module"})),pt=Rt({name:Ue(),selector:Ue(),findBy:Lr(["cssSelector","xpath"]),option:Rt({waitForSelector:Tt().optional(),waitSelectorTimeout:$t().optional(),multiple:Tt().optional()})}),$a=D.object({type:D.literal("object"),shape:D.record(D.string(),D.any())}),La=D.object({type:D.literal("array"),items:D.any()}),Za=D.discriminatedUnion("type",[$a,La]),Wr=D.object({name:D.literal("ai-parse-data"),sourceData:D.any().optional(),schemaDefinition:Za,prompt:D.string().optional(),model:D.string().optional(),apiKey:D.string().min(1,"AI API key is required"),provider:D.enum(["openai","anthropic"])});function Wa(r){return Wr.parse(r)}async function za(r){try{const{sourceData:e,schemaDefinition:t,prompt:a,model:s,apiKey:i,provider:c}=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 f=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:t,prompt:a,model:s,apiKey:i,provider:c}});if(f.$isError)throw new Error(f.message||"AI parsing failed");return{data:f.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 qa(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}),currency:r=>({type:"currency",shape:Tn,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 Ga 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 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(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 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 Ja 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 Xa{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=Qa(t,a);return i?f.waitForElement(r,e,c):f.find(r,e)}function Qa(r,e){return e==="xpath"?new Ja:r.includes(">>")?new Ka:r.includes("|>")?new Ya:new Ga}const zr=pt.extend({name:D.literal("get-text"),includeTags:D.boolean().optional(),useTextContent:D.boolean().optional(),regex:D.string().optional(),prefixText:D.string().optional(),suffixText:D.string().optional(),filterEmpty:D.boolean().optional(),scrollToCollect:D.boolean().optional(),scrollDistance:D.number().optional(),scrollWaitMs:D.number().optional(),maxScrollAttempts:D.number().optional()});function es(r){return zr.parse(r)}async function ts(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:A=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(M&&(b!=null&&b.multiple))return await rs({selector:e,findBy:f,option:b,includeTags:t,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:k,scrollDistance:S,scrollWaitMs:x,maxScrollAttempts:A});const I=await mt({selector:e,findBy:f,option:b});if(!I)return{data:""};const ae=En(t,a,s,i,c);if(Array.isArray(I)){const Q=I.map(ae);return{data:k?Q.filter(H=>H.trim()!==""):Q}}else return{data:ae(I)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function rs(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,A=En(s,i,c,f,b),I=new Set;let ae=0,Q=0;const pe=5;for(;ae<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=A($);(!k||z.trim()!=="")&&I.add(z)}),I.size===L){if(Q++,Q>=pe)break}else Q=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;ae++}return{data:Array.from(I)}}function En(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 Vr=pt.extend({name:D.literal("attribute-value"),attributeName:D.string()});function ns(r){return Vr.parse(r)}async function as(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 qr=pt.extend({name:D.literal("get-value-form"),type:D.enum(["text-field","select","checkbox"]).optional()});function ss(r){return qr.parse(r)}async function is(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:os(s,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function os(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 Hr=pt.extend({name:D.literal("set-value-form"),setValue:D.string(),type:D.enum(["text-field","select","checkbox"]).optional()});function cs(r){return Hr.parse(r)}async function us(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 ls(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 ls(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 Gr=pt.extend({name:D.literal("clear-value-form"),type:D.enum(["text-field","select","checkbox"]).optional()});function fs(r){return Gr.parse(r)}async function ds(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 hs(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 hs(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 Yr=pt.extend({name:D.literal("element-exists")});function ps(r){return Yr.parse(r)}async function ms(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 Kr=pt.extend({name:D.literal("event-click"),textFilter:D.object({text:D.union([D.string(),D.array(D.string())]),mode:D.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function ys(r){return Kr.parse(r)}async function gs(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=vs(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 ws(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 vs(r,e,t){for(const a of r){const s=bs(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 bs(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 ws(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 Jr=D.object({name:D.literal("keypress"),key:D.string(),code:D.string().optional(),keyCode:D.number().optional(),modifiers:D.array(D.enum(["Alt","Control","Meta","Shift"])).optional()});function ks(r){return Jr.parse(r)}async function xs(r){try{const{key:e,code:t,keyCode:a,modifiers:s=[]}=r;return await _s(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 _s(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,...mn(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...mn(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 mn(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Xr=D.object({name:D.literal("wait"),duration:D.number().min(0)});function Es(r){return Xr.parse(r)}async function Ts(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 Qr=D.object({name:D.literal("wait-for-condition"),conditions:D.object({urlPattern:D.string().optional(),elementExists:D.object({selector:D.string(),findBy:D.enum(["cssSelector","xpath"])}).optional(),cookieExists:D.string().optional(),storageKey:D.object({type:D.enum(["localStorage","sessionStorage"]),key:D.string()}).optional(),userConfirmation:D.boolean().optional(),message:D.string().optional(),buttonText:D.string().optional()}).refine(r=>r.urlPattern!==void 0||r.elementExists!==void 0||r.cookieExists!==void 0||r.storageKey!==void 0||r.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:D.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:D.number().min(100).optional(),timeoutMs:D.number().min(1e3).optional(),position:D.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function As(r){return Qr.parse(r)}async function Ss(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 A=null;if(x==="cssSelector"?A=document.querySelector(S):x==="xpath"&&(A=document.evaluate(S,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),A)return{success:!0,reason:"elementExists",message:`Element found: ${S}`}}if(e.cookieExists&&document.cookie.split(";").some(A=>{const[I]=A.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,A=!1;const I=()=>{x&&(clearInterval(x),x=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},ae=pe=>{A||(A=!0,I(),console.log("[WaitForCondition] Resolved with:",pe),S({data:pe}))},Q=setTimeout(()=>{ae({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(t==="auto"||t==="auto-or-manual")&&c&&(x=setInterval(async()=>{const pe=await M();pe&&(clearTimeout(Q),ae(pe))},a)),(t==="manual"||t==="auto-or-manual")&&b&&b.then(()=>{clearTimeout(Q),ae({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 en=D.object({name:D.literal("navigate"),url:D.string().url("Valid URL is required"),waitForLoad:D.boolean().optional(),timeout:D.number().min(0).optional()});function Ds(r){return en.parse(r)}async function Os(r){try{const{url:e,waitForLoad:t=!0,timeout:a=3e4}=r;return console.log(`[Navigate] Navigating to: ${e}`),t?new Promise((s,i)=>{const c=setTimeout(()=>{i(new Error(`Navigation timeout after ${a}ms`))},a),f=()=>{clearTimeout(c),window.removeEventListener("load",f),console.log(`[Navigate] Page loaded: ${e}`),s({data:!0})};document.readyState==="complete"?(clearTimeout(c),console.log(`[Navigate] Page already loaded: ${e}`),s({data:!0})):window.addEventListener("load",f),window.location.href=e}):(window.location.href=e,console.log(`[Navigate] Navigation initiated (no wait): ${e}`),{data:!0})}catch(e){return console.error("[Navigate] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in navigate handler",data:!1}}}const tn=pt.extend({name:D.literal("save-assets")});function Ps(r){return tn.parse(r)}async function Cs(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 Ns{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 rn=pt.extend({name:D.literal("get-element-data"),includeText:D.boolean().optional(),includeTags:D.boolean().optional(),useTextContent:D.boolean().optional(),regex:D.string().optional(),prefixText:D.string().optional(),suffixText:D.string().optional(),attributes:D.array(D.string()).optional(),includeSelector:D.boolean().optional(),includeXPath:D.boolean().optional()});function Rs(r){return rn.parse(r)}async function Ms(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 A=await mt({selector:e,findBy:S,option:x});if(!A)return{data:Array.isArray(A)?[]:{}};const I=Is(t,a,s,i,c,f,b,k,M);return Array.isArray(A)?{data:A.map(I)}:{data:I(A)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function Is(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"),A=S.match(x);S=A?A.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 A=k.querySelector(`[${S}]`);A&&(x=A.getAttribute(S))}M.attributes[S]=x})),f&&(M.selector=Xa.generate(k)),b&&(M.xpath=Ns.generate(k)),M}}const nn=pt.extend({name:D.literal("scroll"),scrollType:D.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:D.number().optional(),behavior:D.enum(["auto","smooth"]).optional(),maxScrolls:D.number().optional(),waitAfterScroll:D.number().optional()});function js(r){return nn.parse(r)}async function Fs(r){try{const{selector:e="",scrollType:t="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:b}=r;switch(t){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Bs(e,f,b,s);case"toBottom":return await Us(s,c);case"byDistance":return await $s(a,s);case"untilLoaded":return await Ls(i,a,s,c);default:throw new Error(`Unknown scroll type: ${t}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Bs(r,e,t,a){const s=await mt({selector:r,findBy:e,option:t});return s?((Array.isArray(s)?s[0]:s).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function Us(r,e){let t=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:r}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===t)break;t=i,a++}return{data:!0}}async function $s(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function Ls(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 an=D.object({name:D.literal("fetch-api"),url:D.string(),method:D.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:D.record(D.string(),D.string()).optional(),body:D.record(D.string(),D.any()).optional(),timeout:D.number().min(0).optional(),parseJson:D.boolean().optional(),returnHeaders:D.boolean().optional()});function Zs(r){return an.parse(r)}async function Ws(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 yn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zs(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:{}},gn;function Vs(){return gn||(gn=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 A=s[k]={exports:{}};a[k][0].call(A.exports,function(I){var ae=a[k][1][I];return c(ae||I)},A,A.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,T){var w=function(B,j,O){var F="";if(B<=19)F=(j?" and ":"")+(O?k[B]:b[B]);else if(B<100){const ge=Math.floor(B/10),we=B%10;F=(j?" and ":"")+M[ge-2],we>0?F+="-"+w(we,!1,O):O&&(F=F.substring(0,F.length-1)+"ieth")}else if(B<1e3){const ge=Math.floor(B/100),we=B%100;F=(j?", ":"")+b[ge]+" Hundred",we>0?F+=w(we,!0,O):O&&(F+="th")}else{var J=Math.floor(Math.log10(B)/3);J>S.length&&(J=S.length);const ge=Math.pow(10,J*3),we=Math.floor(B/ge),K=B-we*ge;F=(j?", ":"")+w(we,!1,!1)+" "+S[J-1],K>0?F+=w(K,!0,O):O&&(F+="th")}return F},C=w(v,!1,T);return C}const A={};b.forEach(function(v,T){A[v.toLowerCase()]=T}),k.forEach(function(v,T){A[v.toLowerCase()]=T}),M.forEach(function(v,T){const w=v.toLowerCase();A[w]=(T+2)*10,A[w.substring(0,v.length-1)+"ieth"]=A[w]}),A.hundredth=100,S.forEach(function(v,T){const w=v.toLowerCase(),C=Math.pow(10,(T+1)*3);A[w]=C,A[w+"th"]=C});function I(v){const w=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>A[j]);let C=[0];return w.forEach(j=>{if(j<100){let O=C.pop();O>=1e3&&(C.push(O),O=0),C.push(O+j)}else C.push(C.pop()*j)}),C.reduce((j,O)=>j+O,0)}const ae=[[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"]],Q={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function pe(v){for(var T=0;T<ae.length;T++){const w=ae[T];if(v>=w[0])return w[1]+pe(v-w[0])}return""}function H(v){for(var T=0,w=1,C=v.length-1;C>=0;C--){const B=v[C],j=Q[B];j<w?T-=j:(w=j,T+=j)}return T}function N(v,T){for(var w=[],C=T.charCodeAt(0);v>0;)w.unshift(String.fromCharCode((v-1)%26+C)),v=Math.floor((v-1)/26);return w.join("")}function se(v,T){for(var w=T.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,T){if(typeof v>"u")return;v=Math.floor(v);const w=xe(T);return z(v,w)}const E={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},$={UPPER:"upper",LOWER:"lower",TITLE:"title"};function z(v,T){let w;const C=v<0;switch(v=Math.abs(v),T.primary){case E.LETTERS:w=N(v,T.case===$.UPPER?"A":"a");break;case E.ROMAN:w=pe(v),T.case===$.UPPER&&(w=w.toUpperCase());break;case E.WORDS:w=x(v,T.ordinal),T.case===$.UPPER?w=w.toUpperCase():T.case===$.LOWER&&(w=w.toLowerCase());break;case E.DECIMAL:w=""+v;var B=T.mandatoryDigits-w.length;if(B>0){var j=new Array(B+1).join("0");w=j+w}if(T.zeroCode!==48&&(w=f(w).map(ge=>String.fromCodePoint(ge.codePointAt(0)+T.zeroCode-48)).join("")),T.regular){const ge=Math.floor((w.length-1)/T.groupingSeparators.position);for(let we=ge;we>0;we--){const K=w.length-we*T.groupingSeparators.position;w=w.substr(0,K)+T.groupingSeparators.character+w.substr(K)}}else T.groupingSeparators.reverse().forEach(ge=>{const we=w.length-ge.position;w=w.substr(0,we)+ge.character+w.substr(we)});if(T.ordinal){var O={1:"st",2:"nd",3:"rd"},F=w[w.length-1],J=O[F];(!J||w.length>1&&w[w.length-2]==="1")&&(J="th"),w=w+J}break;case E.SEQUENCE:throw{code:"D3130",value:T.token}}return C&&(w="-"+w),w}const he=[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 T={type:"integer",primary:E.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"&&(T.ordinal=!0)),w){case"A":T.case=$.UPPER;case"a":T.primary=E.LETTERS;break;case"I":T.case=$.UPPER;case"i":T.primary=E.ROMAN;break;case"W":T.case=$.UPPER,T.primary=E.WORDS;break;case"Ww":T.case=$.TITLE,T.primary=E.WORDS;break;case"w":T.primary=E.WORDS;break;default:{let j=null,O=0,F=0,J=[],ge=0;if(f(w).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let ee=!1;for(let me=0;me<he.length;me++){const G=he[me];if(K>=G&&K<=G+9){if(ee=!0,O++,ge++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}ee||(K===35?(ge++,F++):J.push({position:ge,character:String.fromCodePoint(K)}))}),O>0){T.primary=E.DECIMAL,T.zeroCode=j,T.mandatoryDigits=O,T.optionalDigits=F;const ee=function(me){if(me.length===0)return 0;const G=me[0].character;for(let $e=1;$e<me.length;$e++)if(me[$e].character!==G)return 0;const Ze=me.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);ee>0?(T.regular=!0,T.groupingSeparators={position:ee,character:J[0].character}):(T.regular=!1,T.groupingSeparators=J)}else T.primary=E.SEQUENCE,T.token=w}}return T}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 T=[];const w={type:"datetime",parts:T},C=function(ee,me){if(me>ee){let G=v.substring(ee,me);G=G.split("]]").join("]"),T.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),T.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 ee=v.substring(B+1,j);ee=ee.split(/\s+/).join("");var O={type:"marker",component:ee.charAt(0)},F=ee.lastIndexOf(","),J;if(F!==-1){const me=ee.substring(F+1),G=me.indexOf("-");let Ze,it;const qe=function(He){if(!(typeof He>"u"||He==="*"))return parseInt(He)};G===-1?Ze=me:(Ze=me.substring(0,G),it=me.substring(G+1));const $e={min:qe(Ze),max:qe(it)};O.width=$e,J=ee.substring(1,F)}else J=ee.substring(1);if(J.length===1)O.presentation1=J;else if(J.length>1){var ge=J.charAt(J.length-1);"atco".indexOf(ge)!==-1?(O.presentation2=ge,ge==="o"&&(O.ordinal=!0),O.presentation1=J.substring(0,J.length-1)):O.presentation1=J}else O.presentation1=Te[O.component];if(typeof O.presentation1>"u")throw{code:"D3132",value:O.component};if(O.presentation1[0]==="n")O.names=$.LOWER;else if(O.presentation1[0]==="N")O.presentation1[1]==="n"?O.names=$.TITLE:O.names=$.UPPER;else if("YMDdFWwXxHhmsf".indexOf(O.component)!==-1){var we=O.presentation1;if(O.presentation2&&(we+=";"+O.presentation2),O.integerFormat=xe(we),O.width&&O.width.min!==void 0&&O.integerFormat.mandatoryDigits<O.width.min&&(O.integerFormat.mandatoryDigits=O.width.min),O.component==="Y")if(O.n=-1,O.width&&O.width.max!==void 0)O.n=O.width.max,O.integerFormat.mandatoryDigits=O.n;else{var K=O.integerFormat.mandatoryDigits+O.integerFormat.optionalDigits;K>=2&&(O.n=K)}const me=T[T.length-1];me&&me.integerFormat&&(me.integerFormat.parseWidth=me.integerFormat.mandatoryDigits)}(O.component==="Z"||O.component==="z")&&(O.integerFormat=xe(O.presentation1)),T.push(O),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 T=Date.UTC(v.year,v.month);var w=new Date(T).getUTCDay();return w===0&&(w=7),w>4?T+(8-w)*et:T-(w-1)*et},fe=function(v,T){return{year:v,month:T,nextMonth:function(){return T===11?fe(v+1,0):fe(v,T+1)},previousMonth:function(){return T===0?fe(v-1,11):fe(v,T-1)},nextYear:function(){return fe(v+1,T)},previousYear:function(){return fe(v-1,T)}}},tt=function(v,T){return(T-v)/(et*7)+1},ie=(v,T)=>{let w;switch(T){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=fe(v.getUTCFullYear(),0),B=_e(C),j=Date.UTC(C.year,v.getUTCMonth(),v.getUTCDate());let O=tt(B,j);if(O>52){const F=_e(C.nextYear());j>=F&&(O=1)}else if(O<1){const F=_e(C.previousYear());O=tt(F,j)}w=Math.floor(O);break}case"w":{const C=fe(v.getUTCFullYear(),v.getUTCMonth()),B=_e(C),j=Date.UTC(C.year,C.month,v.getUTCDate());let O=tt(B,j);if(O>4){const F=_e(C.nextMonth());j>=F&&(O=1)}else if(O<1){const F=_e(C.previousMonth());O=tt(F,j)}w=Math.floor(O);break}case"X":{const C=fe(v.getUTCFullYear(),0),B=_e(C),j=_e(C.nextYear()),O=v.getTime();O<B?w=C.year-1:O>=j?w=C.year+1:w=C.year;break}case"x":{const C=fe(v.getUTCFullYear(),v.getUTCMonth()),B=_e(C),j=C.nextMonth(),O=_e(j),F=v.getTime();F<B?w=C.previousMonth().month+1:F>=O?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,T,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 ee=ie(we,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(ee=ee%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")ee=Re[ee-1];else if(K.component==="F")ee=ve[ee];else throw{code:"D3133",value:K.component};K.names===$.UPPER?ee=ee.toUpperCase():K.names===$.LOWER&&(ee=ee.toLowerCase()),K.width&&ee.length>K.width.max&&(ee=ee.substring(0,K.width.max))}else ee=z(ee,K.integerFormat);else if(K.component==="f")ee=z(ee,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const me=C*100+B;if(K.integerFormat.regular)ee=z(me,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)ee=z(C,K.integerFormat),B!==0&&(ee+=":"+L(B,"00"));else if(G===3||G===4)ee=z(me,K.integerFormat);else throw{code:"D3134",value:G}}me>=0&&(ee="+"+ee),K.component==="z"&&(ee="GMT"+ee),me===0&&K.presentation2==="t"&&(ee="Z")}else K.component==="P"&&K.names===$.UPPER&&(ee=ee.toUpperCase());return ee};let O;typeof T>"u"?(Fe===null&&(Fe=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),O=Fe):O=Ae(T);const F=(60*C+B)*60*1e3,J=new Date(v+F);let ge="";return O.parts.forEach(function(we){we.type==="literal"?ge+=we.value:ge+=j(J,we)}),ge}function d(v){var T={};if(v.type==="datetime")T.type="datetime",T.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(O){w.component==="z"&&(O=O.substring(3));let F=0,J=0;return j?(F=Number.parseInt(O.substring(0,O.indexOf(j.character))),J=Number.parseInt(O.substring(O.indexOf(j.character)+1))):O.length-1<=2?F=Number.parseInt(O):(F=Number.parseInt(O.substring(0,3)),J=Number.parseInt(O.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,O){w.width&&w.width.max?B[j.substring(0,w.width.max)]=O+1:B[j]=O+1});else if(w.component==="F")ve.forEach(function(j,O){O>0&&(w.width&&w.width.max?B[j.substring(0,w.width.max)]=O:B[j]=O)});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{T.type="integer";const w=v.case===$.UPPER;switch(v.primary){case E.LETTERS:T.regex=w?"[A-Z]+":"[a-z]+",T.parse=function(C){return se(C,w?"A":"a")};break;case E.ROMAN:T.regex=w?"[MDCLXVI]+":"[mdclxvi]+",T.parse=function(C){return H(w?C:C.toUpperCase())};break;case E.WORDS:T.regex="(?:"+Object.keys(A).concat("and","[\\-, ]").join("|")+")+",T.parse=function(C){return I(C.toLowerCase())};break;case E.DECIMAL:T.regex="[0-9]",v.parseWidth?T.regex+=`{${v.parseWidth}}`:T.regex+="+",v.ordinal&&(T.regex+="(?:th|st|nd|rd)"),T.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 E.SEQUENCE:throw{code:"D3130",value:v.token}}}return T}function m(v,T){if(typeof v>"u")return;const w=xe(T);return d(w).parse(v)}function V(v,T){const w=Ae(T),C=d(w),B="^"+C.parts.map(J=>"("+J.regex+")").join("")+"$";var O=new RegExp(B,"i").exec(v);if(O!==null){const G={};for(let De=1;De<O.length;De++){const u=C.parts[De-1];u.parse&&(G[u.component]=u.parse(O[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),At=!wt&&qe(72);Ze=0,"PHhmsf".split("").forEach(De=>it(G[De]));const St=!qe(23)&&qe(47),Jt=(He?"YD":wt?"XxwF":At?"XWF":"YMD")+(St?"Phmsf":"Hmsf"),ut=this.environment.timestamp;let Lt=!1,yt=!1;if(Jt.split("").forEach(De=>{if(typeof G[De]>"u")Lt?(G[De]="MDd".indexOf(De)!==-1?1:0,yt=!0):G[De]=ie(ut,De);else if(Lt=!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(At)throw{code:"D3136"};St&&(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 de=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,T){if(!(typeof v>"u"))if(typeof T>"u"){if(!de.test(v))throw{stack:new Error().stack,code:"D3110",value:v};return Date.parse(v)}else return V.call(this,v,T)}function Ee(v,T,w){if(!(typeof v>"u"))return st.call(this,v,T,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,A=c.isFunction,I=c.isLambda,ae=c.isPromise,Q=c.getFunctionArity,pe=c.isDeepEqual,H=c.stringToArray;function N(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function se(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 E(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(A(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)):_&&A(_)?"":_},g)}return l}}function he(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&&(_=he(_,0,p)),o>0?g=n+_:g=_+n}else g=n;return g}}async function fe(n,o){var l=n.apply(this,[o]);if(ae(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||A(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 fe(o,n);l=typeof g<"u"}return l}}async function ie(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 fe(o,n);if(typeof _<"u")for(;typeof _<"u"&&(typeof l>"u"||p<l);)g.push({match:_.match,index:_.start,groups:_.groups}),_=await fe(_.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 Zt=Se.groups[je-1];typeof Zt<"u"&&(We+=Zt)}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 ye=await fe(o,n);if(typeof ye<"u"){for(;typeof ye<"u"&&(typeof g>"u"||X<g);){R+=n.substring(q,ye.start);var Ce=_.apply(p,[ye]);if(ae(Ce)&&(Ce=await Ce),typeof Ce=="string")R+=Ce;else throw{code:"D3012",stack:new Error().stack,value:Ce};q=ye.start+ye.match.length,X++,ye=await fe(ye.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 de(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 fe(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 fe(_.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 T(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(re){p[re]=l[re]});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 ye=function(re){var Me=(function(){for(var Le,nt=0;nt<re.length;nt++)if(Le=re.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return re.substring(0,nt)})(),Ye=(function(){for(var Le,nt=re.length-1;nt>=0;nt--)if(Le=re.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return re.substring(nt+1)})(),Ne=re.substring(Me.length,re.length-Ye.length),Xe,Dt,Qe,It,rt=re.indexOf(p["exponent-separator"],Me.length);rt===-1||rt>re.length-Ye.length?(Xe=Ne,Dt=void 0):(Xe=Ne.substring(0,rt),Dt=Ne.substring(rt+1));var lt=Xe.indexOf(p["decimal-separator"]);return lt===-1?(Qe=Xe,It=Ye):(Qe=Xe.substring(0,lt),It=Xe.substring(lt+1)),{prefix:Me,suffix:Ye,activePart:Ne,mantissaPart:Xe,exponentPart:Dt,integerPart:Qe,fractionalPart:It,subpicture:re}},Ce=function(re){var Me,Ye,Ne=re.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 Dt=!1;for(Ye=0;Ye<re.mantissaPart.length;Ye++){var Qe=re.mantissaPart.charAt(Ye);if(_.indexOf(Qe)!==-1||Qe===p.digit){Dt=!0;break}}Dt||(Me="D3085");var It=re.activePart.split("").map(function(Le){return X.indexOf(Le)===-1?"p":"a"}).join("");It.indexOf("p")!==-1&&(Me="D3086"),Xe!==-1?(Ne.charAt(Xe-1)===p["grouping-separator"]||Ne.charAt(Xe+1)===p["grouping-separator"])&&(Me="D3087"):re.integerPart.charAt(re.integerPart.length-1)===p["grouping-separator"]&&(Me="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Me="D3089");var rt=re.integerPart.indexOf(p.digit);rt!==-1&&re.integerPart.substring(0,rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3090"),rt=re.fractionalPart.lastIndexOf(p.digit),rt!==-1&&re.fractionalPart.substring(rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3091");var lt=typeof re.exponentPart=="string";if(lt&&re.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Me="D3092"),lt&&(re.exponentPart.length===0||re.exponentPart.split("").filter(function(Le){return _.indexOf(Le)===-1}).length>0)&&(Me="D3093"),Me)throw{code:Me,stack:new Error().stack}},Se=function(re){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(zt){return _.indexOf(zt)!==-1||zt===p.digit}).length;er.push(wr),kt=re.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Me(re.integerPart),Ne=function(Ve){if(Ve.length===0)return 0;for(var br=function(wr,zt){return zt===0?wr:br(zt,wr%zt)},er=Ve.reduce(br),kt=1;kt<=Ve.length;kt++)if(Ve.indexOf(kt*er)===-1)return 0;return er},Xe=Ne(Ye),Dt=Me(re.fractionalPart,!0),Qe=re.integerPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length,It=Qe,rt=re.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 re.exponentPart=="string";Qe===0&&Le===0&&(nt?(lt=1,Le=1):Qe=1),nt&&Qe===0&&re.integerPart.indexOf(p.digit)!==-1&&(Qe=1),Qe===0&<===0&&(lt=1);var fn=0;return nt&&(fn=re.exponentPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:It,prefix:re.prefix,fractionalPartGroupingPositions:Dt,minimumFactionalPartSize:lt,maximumFactionalPartSize:Le,minimumExponentSize:fn,suffix:re.suffix,picture:re.subpicture}},We=Oe.map(ye);We.forEach(Ce);var ke=We.map(Se),je=p["minus-sign"],ot=p["zero-digit"],ze=p["decimal-separator"],Zt=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 Mt,Wt;if(Be.minimumExponentSize===0)Mt=Xt;else{var Pn=Math.pow(10,Be.scalingFactor),Cn=Math.pow(10,Be.scalingFactor-1);for(Mt=Xt,Wt=0;Mt<Cn;)Mt*=10,Wt-=1;for(;Mt>Pn;)Mt/=10,Wt+=1}var Nn=F(Mt,Be.maximumFactionalPartSize),un=function(re,Me){var Ye=Math.abs(re).toFixed(Me);return ot!=="0"&&(Ye=Ye.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?_[Ne.charCodeAt(0)-48]:Ne}).join("")),Ye},ce=un(Nn,Be.maximumFactionalPartSize),Ge=ce.indexOf(".");for(Ge===-1?ce=ce+ze:ce=ce.replace(".",ze);ce.charAt(0)===ot;)ce=ce.substring(1);for(;ce.charAt(ce.length-1)===ot;)ce=ce.substring(0,ce.length-1);Ge=ce.indexOf(ze);var Qt=Be.minimumIntegerPartSize-Ge,ln=Be.minimumFactionalPartSize-(ce.length-Ge-1);if(ce=(Qt>0?new Array(Qt+1).join(ot):"")+ce,ce=ce+(ln>0?new Array(ln+1).join(ot):""),Ge=ce.indexOf(ze),Be.regularGrouping>0)for(var Rn=Math.floor((Ge-1)/Be.regularGrouping),gr=1;gr<=Rn;gr++)ce=[ce.slice(0,Ge-gr*Be.regularGrouping),Zt,ce.slice(Ge-gr*Be.regularGrouping)].join("");else Be.integerPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,Ge-re),Zt,ce.slice(Ge-re)].join(""),Ge++});if(Ge=ce.indexOf(ze),Be.fractionalPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,re+Ge+1),Zt,ce.slice(re+Ge+1)].join("")}),Ge=ce.indexOf(ze),(Be.picture.indexOf(ze)===-1||Ge===ce.length-1)&&(ce=ce.substring(0,ce.length-1)),typeof Wt<"u"){var vr=un(Wt,0);Qt=Be.minimumExponentSize-vr.length,Qt>0&&(vr=new Array(Qt+1).join(ot)+vr),ce=ce+p["exponent-separator"]+(Wt<0?je:"")+vr}return ce=Be.prefix+ce+Be.suffix,ce}}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 O(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 ge(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"&&!A(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function ee(n){if(!(typeof n>"u"))return!K(n)}function me(n,o,l,g){var p=[o],_=Q(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=me(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],_=me(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=me(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=Q(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"&&!A(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"&&!A(n)&&(l=n[o]);return l}function At(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 St(n){var o=S();if(Array.isArray(n))n.forEach(function(p){o=At(o,St(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=me(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 Lt(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":A(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(ye,Ce,Se){Ce.length===0?Array.prototype.push.apply(ye,Se):Se.length===0?Array.prototype.push.apply(ye,Ce):await l(Ce[0],Se[0])?(ye.push(Se[0]),await X(ye,Ce,Se.slice(1))):(ye.push(Ce[0]),await X(ye,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(pe(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],_=me(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:se,max:L,min:E,average:$,string:z,substring:he,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Re,trim:et,pad:_e,match:ie,contains:tt,replace:Fe,split:Ee,join:v,formatNumber:T,formatBase:w,number:C,floor:j,ceil:O,round:F,abs:B,sqrt:J,power:ge,random:we,boolean:K,not:ee,map:G,zip:qe,filter:Ze,single:it,foldLeft:$e,sift:y,keys:He,lookup:wt,append:At,exists:mr,spread:St,merge:Z,reverse:yr,each:Jt,error:ut,assert:Lt,type:yt,sort:De,shuffle:u,distinct:h,base64encode:st,base64decode:d,encodeUrlComponent:m,encodeUrl:V,decodeUrlComponent:de,decodeUrl:Pe}})();a.exports=f}).call(this)}).call(this,typeof yn<"u"?yn: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,A=f.isArrayOfNumbers,I=f.createSequence,ae=f.isSequence,Q=f.isFunction,pe=f.isLambda,H=f.isIterable,N=f.isPromise,se=f.getFunctionArity,L=f.isDeepEqual,E=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=fe(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 O(u,h,y);break;case"bind":n=await B(u,h,y);break;case"regex":n=F(u);break;case"function":n=await me(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 ee(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 T(u.group,n,y));var g=y.lookup(Symbol.for("jsonata.__evaluate_exit"));return g&&await g(u,h,y,n),n&&ae(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 T(u.group,l?g:o,y)),o}function he(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 ge(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])&&!ae(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 ge(u,y,n);else{var l=await ge(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++){_=he(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=he(y,l));var _=await $(u,g,p);S(_)&&(_=[_]),A(_)?_.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=de(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 T(u,h,y);break}return n}function _e(u,h,y){return c.lookup(h,u.value)}function fe(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=ie(o),y=c.append(y,o)):y.push(o)}),y}function ie(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ie(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 de(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 T(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?he(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 ye=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=he(y,ze)}return y.isParallelCall=We>0,[Se,await $(u.lhs[ke.exprIndex][1],je,ot)]}));for(let Se of ye){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 O(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 ge(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],ye=_,Ce=y;l&&(ye=_["@"],Ce=he(y,_));var Se=await $(Oe.expression,ye,Ce);ye=R,Ce=y,l&&(ye=R["@"],Ce=he(y,R));var We=await $(Oe.expression,ye,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(!Q(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 ye=await $(u.delete,R,y);if(typeof ye<"u"){var Ce=ye;if(Array.isArray(ye)||(ye=[ye]),!x(ye))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Ce};for(var Se=0;Se<ye.length;Se++)typeof R=="object"&&R!==null&&delete R[ye[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var K=b("function($f, $g) { function($x){ $g($f($x)) } }");async function ee(u,h,y){var n,o=await $(u.lhs,h,y);if(u.rhs.type==="function")n=await me(u.rhs,h,y,{context:o});else{var l=await $(u.rhs,h,y);if(!Q(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(Q(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 me(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(Q(R)){const q=async function(...X){return await G(R,X,null,y)};q.arity=se(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);pe(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)),pe(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(pe(p))n=wt(p,o);else if(p&&p._jsonata_function===!0)n=At(p.implementation,o);else if(typeof p=="function")n=At(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 At(u,h){var y=St(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=St(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 St(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)&&!ae(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}E.bind("sum",Z(c.sum,"<a<n>:n>")),E.bind("count",Z(c.count,"<a:n>")),E.bind("max",Z(c.max,"<a<n>:n>")),E.bind("min",Z(c.min,"<a<n>:n>")),E.bind("average",Z(c.average,"<a<n>:n>")),E.bind("string",Z(c.string,"<x-b?:s>")),E.bind("substring",Z(c.substring,"<s-nn?:s>")),E.bind("substringBefore",Z(c.substringBefore,"<s-s:s>")),E.bind("substringAfter",Z(c.substringAfter,"<s-s:s>")),E.bind("lowercase",Z(c.lowercase,"<s-:s>")),E.bind("uppercase",Z(c.uppercase,"<s-:s>")),E.bind("length",Z(c.length,"<s-:n>")),E.bind("trim",Z(c.trim,"<s-:s>")),E.bind("pad",Z(c.pad,"<s-ns?:s>")),E.bind("match",Z(c.match,"<s-f<s:o>n?:a<o>>")),E.bind("contains",Z(c.contains,"<s-(sf):b>")),E.bind("replace",Z(c.replace,"<s-(sf)(sf)n?:s>")),E.bind("split",Z(c.split,"<s-(sf)n?:a<s>>")),E.bind("join",Z(c.join,"<a<s>s?:s>")),E.bind("formatNumber",Z(c.formatNumber,"<n-so?:s>")),E.bind("formatBase",Z(c.formatBase,"<n-n?:s>")),E.bind("formatInteger",Z(i.formatInteger,"<n-s:s>")),E.bind("parseInteger",Z(i.parseInteger,"<s-s:n>")),E.bind("number",Z(c.number,"<(nsb)-:n>")),E.bind("floor",Z(c.floor,"<n-:n>")),E.bind("ceil",Z(c.ceil,"<n-:n>")),E.bind("round",Z(c.round,"<n-n?:n>")),E.bind("abs",Z(c.abs,"<n-:n>")),E.bind("sqrt",Z(c.sqrt,"<n-:n>")),E.bind("power",Z(c.power,"<n-n:n>")),E.bind("random",Z(c.random,"<:n>")),E.bind("boolean",Z(c.boolean,"<x-:b>")),E.bind("not",Z(c.not,"<x-:b>")),E.bind("map",Z(c.map,"<af>")),E.bind("zip",Z(c.zip,"<a+>")),E.bind("filter",Z(c.filter,"<af>")),E.bind("single",Z(c.single,"<af?>")),E.bind("reduce",Z(c.foldLeft,"<afj?:j>")),E.bind("sift",Z(c.sift,"<o-f?:o>")),E.bind("keys",Z(c.keys,"<x-:a<s>>")),E.bind("lookup",Z(c.lookup,"<x-s:x>")),E.bind("append",Z(c.append,"<xx:a>")),E.bind("exists",Z(c.exists,"<x:b>")),E.bind("spread",Z(c.spread,"<x-:a<o>>")),E.bind("merge",Z(c.merge,"<a<o>:o>")),E.bind("reverse",Z(c.reverse,"<a:a>")),E.bind("each",Z(c.each,"<o-f:a>")),E.bind("error",Z(c.error,"<s?:x>")),E.bind("assert",Z(c.assert,"<bs?:x>")),E.bind("type",Z(c.type,"<x:s>")),E.bind("sort",Z(c.sort,"<af?:a>")),E.bind("shuffle",Z(c.shuffle,"<a:a>")),E.bind("distinct",Z(c.distinct,"<x:x>")),E.bind("base64encode",Z(c.base64encode,"<s-:s>")),E.bind("base64decode",Z(c.base64decode,"<s-:s>")),E.bind("encodeUrlComponent",Z(c.encodeUrlComponent,"<s-:s>")),E.bind("encodeUrl",Z(c.encodeUrl,"<s-:s>")),E.bind("decodeUrlComponent",Z(c.decodeUrlComponent,"<s-:s>")),E.bind("decodeUrl",Z(c.decodeUrl,"<s-:s>")),E.bind("eval",Z(yr,"<sx?:x>")),E.bind("toMillis",Z(i.toMillis,"<s-s?:n>")),E.bind("fromMillis",Z(i.fromMillis,"<n-s?s?:s>")),E.bind("clone",Z(Jt,"<(oa)-:o>"));var Lt={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=Lt[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(E),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)&&!ae(g)&&(g=I(g),g.outerWrapper=!0);var Oe;try{return Oe=await $(y,g,q),typeof _=="function"&&_(null,Oe),Oe}catch(ye){throw yt(ye),ye}},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(
|
|
3
|
-
\r\v`.indexOf(H)>-1;)x++,H=
|
|
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===A&&Te===""?null:I("name",Te)}}else ve++};return Q},M=function(S,x){var A,I,ae={},Q=[],pe=function(){var d=[];A.id!=="(end)"&&d.push({type:A.type,value:A.value,position:A.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=pe(),d.type="error",Q.push(d),d;throw d.stack=new Error().stack,d}},N=function(d,m){var V=ae[d];return m=m||0,V?m>=V.lbp&&(V.lbp=m):(V=Object.create(H),V.id=V.value=d,V.lbp=m,ae[d]=V),V},se=function(d){if(x){d.remaining=pe(),Q.push(d);var m=ae["(error)"];return A=Object.create(m),A.error=d,A.type="(error)",A}else throw d.stack=new Error().stack,d},L=function(d,m){if(d&&A.id!==d){var V;A.id==="(end)"?V="S0203":V="S0202";var de={code:V,position:A.position,token:A.value,value:d};return se(de)}var Pe=I(m);if(Pe===null)return A=ae["(end)"],A.position=S.length,A;var Ee=Pe.value,v=Pe.type,T;switch(v){case"name":case"variable":T=ae["(name)"];break;case"operator":if(T=ae[Ee],!T)return se({code:"S0204",stack:new Error().stack,position:Pe.position,token:Ee});break;case"string":case"number":case"value":T=ae["(literal)"];break;case"regex":v="regex",T=ae["(regex)"];break;default:return se({code:"S0205",stack:new Error().stack,position:Pe.position,token:Ee})}return A=Object.create(T),A.value=Ee,A.type=v,A.position=Pe.position,A},E=function(d){var m,V=A;for(L(null,!0),m=V.nud();d<A.lbp;)V=A,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 de=m||f[d],Pe=N(d,de);return Pe.led=V||function(Ee){return this.lhs=Ee,this.rhs=E(de),this.type="binary",this},Pe},he=function(d,m,V){var de=N(d,m);return de.led=V,de},xe=function(d,m){var V=N(d);return V.nud=m||function(){return this.expression=E(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=E(0),this}),he("(error)",10,function(d){return this.lhs=d,this.error=A.error,this.remaining=pe(),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=[],A.id!==")")for(;A.type==="operator"&&A.id==="?"?(this.type="partial",this.arguments.push(A),L("?")):this.arguments.push(E(0)),A.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 se({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:v+1})}),this.type="lambda",A.id==="<"){for(var m=A.position,V=1,de="<";V>0&&A.id!=="{"&&A.id!=="(end)";){var Pe=L();Pe.id===">"?V--:Pe.id==="<"&&V++,de+=Pe.value}L(">");try{this.signature=i(de)}catch(Ee){return Ee.position=m+Ee.offset,se(Ee)}}L("{"),this.body=E(0),L("}")}return this}),xe("(",function(){for(var d=[];A.id!==")"&&(d.push(E(0)),A.id===";");)L(";");return L(")",!0),this.type="block",this.expressions=d,this}),xe("[",function(){var d=[];if(A.id!=="]")for(;;){var m=E(0);if(A.id===".."){var V={type:"binary",value:"..",position:A.position,lhs:m};L(".."),V.rhs=E(0),m=V}if(d.push(m),A.id!==",")break;L(",")}return L("]",!0),this.expressions=d,this.type="unary",this}),z("[",f["["],function(d){if(A.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=E(f["]"]),this.type="binary",L("]",!0),this}),z("^",f["^"],function(d){L("(");for(var m=[];;){var V={descending:!1};if(A.id==="<"?L("<"):A.id===">"&&(V.descending=!0,L(">")),V.expression=E(0),m.push(V),A.id!==",")break;L(",")}return L(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Te=function(d){var m=[];if(A.id!=="}")for(;;){var V=E(0);L(":");var de=E(0);if(m.push([V,de]),A.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),he(":=",f[":="],function(d){return d.type!=="variable"?se({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=E(f[":="]-1),this.type="binary",this)}),z("@",f["@"],function(d){return this.lhs=d,this.rhs=E(f["@"]),this.rhs.type!=="variable"?se({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=E(f["#"]),this.rhs.type!=="variable"?se({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=E(0),A.id===":"&&(L(":"),this.else=E(0)),this}),z("?:",f["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=E(0),this}),xe("|",function(){return this.type="transform",this.pattern=E(0),L("|"),this.update=E(0),A.id===","&&(L(","),this.delete=E(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 de=d.expressions.length;de>0&&(d.expressions[de-1]=Ae(d.expressions[de-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},fe=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],de=typeof V.seekingParent<"u"?V.seekingParent:[];V.type==="parent"&&de.push(V.slot);for(var Pe=0;Pe<de.length;Pe++){var Ee=de[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)}}},ie=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var V=ie(d.lhs);V.type==="path"?m=V:m={type:"path",steps:[V]},V.type==="parent"&&(m.seekingParent=[V.slot]);var de=ie(d.rhs);de.type==="function"&&de.procedure.type==="path"&&de.procedure.steps.length===1&&de.procedure.steps[0].type==="name"&&m.steps[m.steps.length-1].type==="function"&&(m.steps[m.steps.length-1].nextFunction=de.procedure.steps[0].value),de.type==="path"?Array.prototype.push.apply(m.steps,de.steps):(typeof de.predicate<"u"&&(de.stages=de.predicate,delete de.predicate),m.steps.push(de)),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=ie(d.lhs);var v=m,T="predicate";if(m.type==="path"&&(v=m.steps[m.steps.length-1],T="stages"),typeof v.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof v[T]>"u"&&(v[T]=[]);var w=ie(d.rhs);typeof w.seekingParent<"u"&&(w.seekingParent.forEach(F=>{F.level===1?_e(v,F):F.level--}),fe(v,w)),v[T].push({type:"filter",expr:w,position:d.position});break;case"{":if(m=ie(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[ie(F[0]),ie(F[1])]}),position:d.position};break;case"^":m=ie(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=ie(F.expression);return fe(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=ie(d.lhs),m.rhs=ie(d.rhs),fe(m,m.rhs);break;case"@":if(m=ie(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=ie(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=ie(d.lhs),m.rhs=ie(d.rhs),m.keepArray=m.lhs.keepArray||m.rhs.keepArray;break;default:m={type:d.type,value:d.value,position:d.position},m.lhs=ie(d.lhs),m.rhs=ie(d.rhs),fe(m,m.lhs),fe(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=ie(F);return fe(m,J),J}):d.value==="{"?m.lhs=d.lhs.map(function(F){var J=ie(F[0]);fe(m,J);var ge=ie(F[1]);return fe(m,ge),[J,ge]}):(m.expression=ie(d.expression),d.value==="-"&&m.expression.type==="number"?(m=m.expression,m.value=-m.value):fe(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=ie(F);return fe(m,J),J}),m.procedure=ie(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var B=ie(d.body);m.body=Ae(B);break;case"condition":m={type:d.type,position:d.position},m.condition=ie(d.condition),fe(m,m.condition),m.then=ie(d.then),fe(m,m.then),typeof d.else<"u"&&(m.else=ie(d.else),fe(m,m.else));break;case"transform":m={type:d.type,position:d.position},m.pattern=ie(d.pattern),m.update=ie(d.update),typeof d.delete<"u"&&(m.delete=ie(d.delete));break;case"block":m={type:d.type,position:d.position},m.expressions=d.expressions.map(function(F){var J=ie(F);return fe(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=ie(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=ie(d.lhs));break;default:var j="S0206";d.id==="(end)"&&(j="S0207");var O={code:j,position:d.position,token:d.value};if(x)return Q.push(O),{type:"error",error:O};throw O.stack=new Error().stack,O}return d.keepArray&&(m.keepArray=!0),m};I=k(S),L();var Fe=E(0);if(A.id!=="(end)"){var st={code:"S0201",position:A.position,token:A.value};se(st)}if(Fe=ie(Fe),Fe.type==="parent"||typeof Fe.seekingParent<"u")throw{code:"S0217",token:Fe.type,position:Fe.position};return Q.length>0&&(Fe.errors=Q),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={},A=x;M<k.length;){var I=k.charAt(M);if(I===":")break;var ae=function(){S.push(x),A=x,x={}},Q=function(z,he,xe,Te){for(var Ae=1,ve=he;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,ae();break;case"a":x.regex="[asnblfom]",x.type=I,x.array=!0,ae();break;case"f":x.regex="f",x.type=I,ae();break;case"j":x.regex="[asnblom]",x.type=I,ae();break;case"x":x.regex="[asnblfom]",x.type=I,ae();break;case"-":A.context=!0,A.contextRegex=new RegExp(A.regex),A.regex+="?";break;case"?":case"+":A.regex+=I;break;case"(":var pe=Q(k,M,"(",")"),H=k.substring(M+1,pe);if(H.indexOf("<")===-1)x.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:M};x.type="("+H+")",M=pe,ae();break;case"<":if(A.type==="a"||A.type==="f"){var N=Q(k,M,"<",">");A.subtype=k.substring(M+1,N),M=N}else throw{code:"S0401",stack:new Error().stack,value:A.type,offset:M};break}M++}var se="^"+S.map(function(z){return"("+z.regex+")"}).join("")+"$",L=new RegExp(se),E=function(z){var he;if(i.isFunction(z))he="f";else{var xe=typeof z;switch(xe){case"string":he="s";break;case"number":he="n";break;case"boolean":he="b";break;case"object":z===null?he="l":Array.isArray(z)?he="a":he="o";break;case"undefined":default:he="m"}}return he},$=function(z,he){for(var xe="^",Te=0,Ae=0;Ae<S.length;Ae++){xe+=S[Ae].regex;var ve=he.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,he){var xe="";z.forEach(function(Re){xe+=E(Re)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return S.forEach(function(Re,et){var _e=z[ve],fe=Te[et+1];if(fe==="")if(Re.context&&Re.contextRegex){var tt=E(he);if(Re.contextRegex.test(tt))Ae.push(he);else throw{code:"T0411",stack:new Error().stack,value:he,index:ve+1}}else Ae.push(_e),ve++;else fe.split("").forEach(function(ie){if(Re.type==="a"){if(ie==="m")_e=void 0;else{_e=z[ve];var Fe=!0;if(typeof Re.subtype<"u"){if(ie!=="a"&&fe!==Re.subtype)Fe=!1;else if(ie==="a"&&_e.length>0){var st=E(_e[0]);if(st!==Re.subtype.charAt(0))Fe=!1;else{var d=_e.filter(function(m){return E(m)!==st});Fe=d.length===0}}}if(!Fe)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:f[Re.subtype]};ie!=="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 se=!1;if(typeof N=="number"&&(se=!isNaN(N),se&&!isFinite(N)))throw{code:"D1001",value:N,stack:new Error().stack};return se}function f(N){var se=!1;return Array.isArray(N)&&(se=N.filter(function(L){return typeof L!="string"}).length===0),se}function b(N){var se=!1;return Array.isArray(N)&&(se=N.filter(function(L){return!c(L)}).length===0),se}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 se=typeof N.arity=="number"?N.arity:typeof N.implementation=="function"?N.implementation.length:typeof N.length=="number"?N.length:N.arguments.length;return se}function A(N){return N&&N._jsonata_lambda===!0}var I=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function ae(N){return typeof N=="object"&&N!==null&&I in N&&"next"in N&&typeof N.next=="function"}function Q(N,se){if(N===se)return!0;if(typeof N=="object"&&typeof se=="object"&&N!==null&&se!==null){if(Array.isArray(N)&&Array.isArray(se)){if(N.length!==se.length)return!1;for(var L=0;L<N.length;L++)if(!Q(N[L],se[L]))return!1;return!0}var E=Object.getOwnPropertyNames(N),$=Object.getOwnPropertyNames(se);if(E.length!==$.length)return!1;for(E=E.sort(),$=$.sort(),L=0;L<E.length;L++)if(E[L]!==$[L])return!1;for(L=0;L<E.length;L++){var z=E[L];if(!Q(N[z],se[z]))return!1}return!0}return!1}function pe(N){return typeof N=="object"&&N!==null&&"then"in N&&typeof N.then=="function"}function H(N){var se=[];for(let L of N)se.push(L);return se}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:b,createSequence:k,isSequence:M,isFunction:S,isLambda:A,isIterable:ae,getFunctionArity:x,isDeepEqual:Q,stringToArray:H,isPromise:pe}})();a.exports=i},{}]},{},[3])(3)})})(Rr)),Rr.exports}var qs=Vs();const Hs=zs(qs),sn=D.object({name:D.literal("transform-data"),sourceData:D.any().optional(),expression:D.string().min(1,"JSONata expression is required")});function Gs(r){return sn.parse(r)}async function Ys(r){try{const{sourceData:e,expression:t}=r,a=e??{};let s;try{s=Hs(t)}catch(c){throw new Error(`Invalid JSONata expression: ${c instanceof Error?c.message:"Unknown error"}`)}let i;try{i=await s.evaluate(a)}catch(c){throw new Error(`JSONata evaluation failed: ${c instanceof Error?c.message:"Unknown error"}`)}return{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in transform-data handler",data:null}}}const on=D.object({name:D.literal("export-data"),data:D.any(),format:D.enum(["json","csv","xlsx"]),filename:D.string().optional(),csvOptions:D.object({delimiter:D.string().optional(),includeHeaders:D.boolean().optional()}).optional()});function Ks(r){return on.parse(r)}async function Js(r){try{const{data:e,format:t,filename:a,csvOptions:s}=r;console.log("[ExportDataBlock] Sending export request to background:",t);const i=await chrome.runtime.sendMessage({type:"EXPORT_DATA",data:{data:e,format:t,filename:a,csvOptions:s}});return i.$isError?{hasError:!0,message:i.message||"Export failed",data:void 0}:(console.log("[ExportDataBlock] Export successful:",i.data.filename),{data:i.data})}catch(e){return console.error("[ExportDataBlock] Export error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in export-data handler",data:void 0}}}const Xs={"get-text":zr,"attribute-value":Vr,"get-value-form":qr,"set-value-form":Hr,"clear-value-form":Gr,"element-exists":Yr,"event-click":Kr,keypress:Jr,wait:Xr,"wait-for-condition":Qr,navigate:en,"save-assets":tn,"get-element-data":rn,scroll:nn,"ai-parse-data":Wr,"fetch-api":an,"transform-data":sn,"export-data":on};class Qs{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=es(e);return await ts(t)}case"attribute-value":{const t=ns(e);return await as(t)}case"get-value-form":{const t=ss(e);return await is(t)}case"set-value-form":{const t=cs(e);return await us(t)}case"clear-value-form":{const t=fs(e);return await ds(t)}case"element-exists":{const t=ps(e);return await ms(t)}case"event-click":{const t=ys(e);return await gs(t)}case"keypress":{const t=ks(e);return await xs(t)}case"wait":{const t=Es(e);return await Ts(t)}case"wait-for-condition":{const t=As(e);return await Ss(t)}case"navigate":{const t=Ds(e);return await Os(t)}case"save-assets":{const t=Ps(e);return await Cs(t)}case"get-element-data":{const t=Rs(e);return await Ms(t)}case"scroll":{const t=js(e);return await Fs(t)}case"ai-parse-data":{const t=Wa(e);return await za(t)}case"fetch-api":{const t=Zs(e);return await Ws(t)}case"transform-data":{const t=Gs(e);return await Ys(t)}case"export-data":{const t=Ks(e);return await Js(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 ei{constructor(){ue(this,"expr");ue(this,"json")}}class ti{constructor(){ue(this,"template");ue(this,"valueFrom");ue(this,"default")}}class ri{constructor(){ue(this,"id");ue(this,"title");ue(this,"when");ue(this,"block");ue(this,"repeat");ue(this,"next");ue(this,"onSuccess");ue(this,"onFailure");ue(this,"switch");ue(this,"timeoutMs");ue(this,"retry");ue(this,"delayAfterMs")}}class ni{constructor(){ue(this,"version");ue(this,"id");ue(this,"title");ue(this,"description");ue(this,"start");ue(this,"steps");ue(this,"vars");ue(this,"defaultDelayMs")}}class ai{constructor(){ue(this,"stepId");ue(this,"skipped");ue(this,"success");ue(this,"message");ue(this,"result");ue(this,"startedAt");ue(this,"finishedAt");ue(this,"attempts")}}class si{constructor(){ue(this,"success");ue(this,"steps");ue(this,"context");ue(this,"targetUrl");ue(this,"timestamp");ue(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 Tn={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 ii(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}const An=Rt({id:Ue(),name:Ue(),image:Ue(),memberCount:$t(),isAdmin:Tt().nullable().optional()});var cn=(r=>(r.monthly="MONTHLY",r.yearly="YEARLY",r))(cn||{});const Ur=Rt({code:Zr(Pr),symbol:Ue(),format:Ue(),amount:$t(),text:Ue().optional()}),Sn=Rt({planName:Ue(),currentCycleBillAmount:Ur,nextPaymentDue:Ue(),cycleTerm:Zr(cn).nullable(),isFreeTier:Tt(),isPerUser:Tt(),paidMemberCount:$t(),usedMemberCount:$t(),unitPrice:Ur.nullable(),cardNumber:Ue(),cardName:Ue()}),Dn=Rt({uid:Ue(),issuedDate:Br.date(),paidDate:Br.date().nullable().optional(),paymentMethod:Ue(),amount:Ur,isSuccessfulPaid:Tt(),receiptUrl:Ue()}),On=Rt({name:Ue(),email:Ue().email(),profileImageUrl:Ue(),role:Ue(),isPaid:Tt().nullable().optional(),subscriptionSeatStatus:Lr(["FREE","PAID"]).nullable().optional()});class oi{constructor(){}async checkExtension(){return new Promise((e,t)=>{const a=setTimeout(()=>{t(ct.extensionNotInstalled())},5e3),s=i=>{ii(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,A,I,ae;if(((k=b.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&b.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const Q=b.data,pe=((M=Q==null?void 0:Q.result)==null?void 0:M.steps)??((x=(S=Q==null?void 0:Q.result)==null?void 0:S.result)==null?void 0:x.steps)??[],H=((A=Q==null?void 0:Q.result)==null?void 0:A.context)??((ae=(I=Q==null?void 0:Q.result)==null?void 0:I.result)==null?void 0:ae.context)??{steps:{},vars:{}};t({success:Q.success,steps:pe,context:H,error:Q.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=An.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=Sn.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=Dn.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=On.safeParse(b);k.success?i.push(k.data):console.warn("Invalid workspace member data:",b,k.error)}return{...a,data:i}}static getFromContext(e,t){const a=t.split(".");let s=e;for(const i of a){if(s==null)return;s=s[i]}return s}static getStepResult(e,t){return e.steps[t]}static getStepData(e,t){var a,s;return(s=(a=e.steps[t])==null?void 0:a.result)==null?void 0:s.data}static getVar(e,t){return e.vars[t]}}exports.AiParseDataBlockSchema=Wr;exports.AllBlockSchemas=Xs;exports.BaseBlockSchema=pt;exports.BillingCycleTerm=cn;exports.Binding=ti;exports.BlockHandler=Qs;exports.ClearValueFormsBlockSchema=Gr;exports.CollectWorkflowResult=si;exports.Condition=ei;exports.CurrencyCode=Pr;exports.CurrencyInfoSchema=Tn;exports.EightGClient=oi;exports.EightGError=ct;exports.ElementExistsBlockSchema=Yr;exports.EventClickBlockSchema=Kr;exports.ExportDataBlockSchema=on;exports.FetchApiBlockSchema=an;exports.GetAttributeValueBlockSchema=Vr;exports.GetElementDataBlockSchema=rn;exports.GetTextBlockSchema=zr;exports.GetValueFormsBlockSchema=qr;exports.KeypressBlockSchema=Jr;exports.NavigateBlockSchema=en;exports.SaveAssetsBlockSchema=tn;exports.Schema=Ha;exports.ScrollBlockSchema=nn;exports.SetValueFormsBlockSchema=Hr;exports.TransformDataBlockSchema=sn;exports.WaitBlockSchema=Xr;exports.WaitForConditionBlockSchema=Qr;exports.Workflow=ni;exports.WorkflowStep=ri;exports.WorkflowStepRunResult=ai;exports.WorkspaceBillingHistorySchema=Dn;exports.WorkspaceBillingSchema=Sn;exports.WorkspaceItemSchema=An;exports.WorkspaceMemberSchema=On;exports.createArraySchema=qa;exports.createSchema=Va;
|
|
1
|
+
"use strict";var In=Object.defineProperty;var jn=(r,e,t)=>e in r?In(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ue=(r,e,t)=>jn(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var we;(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})(we||(we={}));var Mr;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Mr||(Mr={}));const W=we.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=we.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"]),Fn=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,w=0;for(;w<c.path.length;){const k=c.path[w];w===c.path.length-1?(f[k]=f[k]||{_errors:[]},f[k]._errors.push(t(c))):f[k]=f[k]||{_errors:[]},f=f[k],w++}}};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,we.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 Gt=(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,we.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:t=`Unrecognized key(s) in object: ${we.joinValues(r.keys,", ")}`;break;case P.invalid_union:t="Invalid input";break;case P.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${we.joinValues(r.options)}`;break;case P.invalid_enum_value:t=`Invalid enum value. Expected ${we.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}"`:we.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,we.assertNever(r)}return{message:t}};let wn=Gt;function Bn(r){wn=r}function xr(){return wn}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 w=a.filter(k=>!!k).slice().reverse();for(const k of w)f=k(c,{data:e,defaultError:f}).message;return{...s,path:i,message:f}},Un=[];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===Gt?void 0:Gt].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 te;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 te;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 te=Object.freeze({status:"aborted"}),qt=r=>({status:"dirty",value:r}),Je=r=>({status:"valid",value:r}),Ir=r=>r.status==="aborted",jr=r=>r.status==="dirty",Ft=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 hn=(r,e)=>{if(Ft(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 oe(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:w}=r;return c.code==="invalid_enum_value"?{message:w??f.defaultError}:typeof f.data>"u"?{message:w??a??f.defaultError}:c.code!=="invalid_type"?{message:f.defaultError}:{message:w??t??f.defaultError}},description:s}}class le{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 hn(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 Ft(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=>Ft(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 hn(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(w=>w?!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:ne.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 Nt.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({...oe(this._def),schema:this,typeName:ne.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new fr({...oe(this._def),innerType:this,defaultValue:t,typeName:ne.ZodDefault})}brand(){return new $r({typeName:ne.ZodBranded,type:this,...oe(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new dr({...oe(this._def),innerType:this,catchValue:t,typeName:ne.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pr.create(this,e)}readonly(){return hr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $n=/^c[^\s-]{8,}$/i,Ln=/^[0-9a-z]+$/,Zn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Wn=/^[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,Vn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,qn=/^[-+]?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)?)??$/,Hn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Cr;const Yn=/^(?:(?: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])$/,Kn=/^(?:(?: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])$/,Jn=/^(([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]))$/,Xn=/^(([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])$/,Qn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ea=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bn="((\\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])))",ta=new RegExp(`^${bn}$`);function kn(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 ra(r){return new RegExp(`^${kn(r)}$`)}function xn(r){let e=`${bn}T${kn(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 na(r,e){return!!((e==="v4"||!e)&&Yn.test(r)||(e==="v6"||!e)&&Jn.test(r))}function aa(r,e){if(!Vn.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 sa(r,e){return!!((e==="v4"||!e)&&Kn.test(r)||(e==="v6"||!e)&&Xn.test(r))}class ft extends le{_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}),te}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")Hn.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(Gn,"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")Wn.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")$n.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")Ln.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")Zn.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"?xn(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"?ta.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{code:P.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?ra(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"?qn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"duration",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?na(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"?aa(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"?sa(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"?Qn.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?ea.test(e.data)||(s=this._getOrReturnCtx(e,s),U(s,{validation:"base64url",code:P.invalid_string,message:i.message}),a.dirty()):we.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:ne.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...oe(r)});function ia(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 Ot extends le{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}),te}let a;const s=new Ke;for(const i of this._def.checks)i.kind==="int"?we.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"?ia(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()):we.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 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]})}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"&&we.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)}}Ot.create=r=>new Ot({checks:[],typeName:ne.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...oe(r)});class Pt extends le{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()):we.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}),te}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 Pt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Y.toString(s)}]})}_addCheck(e){return new Pt({...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}}Pt.create=r=>new Pt({checks:[],typeName:ne.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...oe(r)});class rr extends le{_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}),te}return Je(e.data)}}rr.create=r=>new rr({typeName:ne.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...oe(r)});class Bt extends le{_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}),te}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return U(i,{code:P.invalid_date}),te}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()):we.assertNever(i);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Bt({...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}}Bt.create=r=>new Bt({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ne.ZodDate,...oe(r)});class Er extends le{_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}),te}return Je(e.data)}}Er.create=r=>new Er({typeName:ne.ZodSymbol,...oe(r)});class nr extends le{_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}),te}return Je(e.data)}}nr.create=r=>new nr({typeName:ne.ZodUndefined,...oe(r)});class ar extends le{_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}),te}return Je(e.data)}}ar.create=r=>new ar({typeName:ne.ZodNull,...oe(r)});class Yt extends le{constructor(){super(...arguments),this._any=!0}_parse(e){return Je(e.data)}}Yt.create=r=>new Yt({typeName:ne.ZodAny,...oe(r)});class jt extends le{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Je(e.data)}}jt.create=r=>new jt({typeName:ne.ZodUnknown,...oe(r)});class Et extends le{_parse(e){const t=this._getOrReturnCtx(e);return U(t,{code:P.invalid_type,expected:W.never,received:t.parsedType}),te}}Et.create=r=>new Et({typeName:ne.ZodNever,...oe(r)});class Tr extends le{_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}),te}return Je(e.data)}}Tr.create=r=>new Tr({typeName:ne.ZodVoid,...oe(r)});class dt extends le{_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}),te;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:ne.ZodArray,...oe(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 Nt?Nt.create(Vt(r.unwrap())):r instanceof wt?wt.create(r.items.map(e=>Vt(e))):r}class Ie extends le{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=we.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}),te}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 w=[];for(const k of c){const M=i[k],D=s.data[k];w.push({key:{status:"valid",value:k},value:M._parse(new vt(s,D,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)w.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 D=s.data[M];w.push({key:{status:"valid",value:M},value:k._parse(new vt(s,D,s.path,M)),alwaysSet:M in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const k=[];for(const M of w){const D=await M.key,x=await M.value;k.push({key:D,value:x,alwaysSet:M.alwaysSet})}return k}).then(k=>Ke.mergeObjectSync(a,k)):Ke.mergeObjectSync(a,w)}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:ne.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 we.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 we.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 we.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 we.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 _n(we.objectKeys(this.shape))}}Ie.create=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});Ie.strictCreate=(r,e)=>new Ie({shape:()=>r,unknownKeys:"strict",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});Ie.lazycreate=(r,e)=>new Ie({shape:r,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});class sr extends le{_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}),te}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 w of a){const k={...t,common:{...t.common,issues:[]},parent:null},M=w._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(w=>new at(w));return U(t,{code:P.invalid_union,unionErrors:f}),te}}get options(){return this._def.options}}sr.create=(r,e)=>new sr({options:r,typeName:ne.ZodUnion,...oe(e)});const xt=r=>r instanceof cr?xt(r.schema):r instanceof ht?xt(r.innerType()):r instanceof ur?[r.value]:r instanceof Ct?r.options:r instanceof lr?we.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 Nt?[null,...xt(r.unwrap())]:r instanceof $r||r instanceof hr?xt(r.unwrap()):r instanceof dr?xt(r._def.innerType):[];class Dr extends le{_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}),te;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]}),te)}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:ne.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...oe(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=we.objectKeys(e),i=we.objectKeys(r).filter(f=>s.indexOf(f)!==-1),c={...r,...e};for(const f of i){const w=Fr(r[f],e[f]);if(!w.valid)return{valid:!1};c[f]=w.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],w=Fr(c,f);if(!w.valid)return{valid:!1};s.push(w.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 le{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=(i,c)=>{if(Ir(i)||Ir(c))return te;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}),te)};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:ne.ZodIntersection,...oe(t)});class wt extends le{_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}),te;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"}),te;!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 w=this._def.items[f]||this._def.rest;return w?w._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 wt({...this._def,rest:e})}}wt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new wt({items:r,typeName:ne.ZodTuple,rest:null,...oe(e)})};class or extends le{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}),te;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 le?new or({keyType:e,valueType:t,typeName:ne.ZodRecord,...oe(a)}):new or({keyType:ft.create(),valueType:e,typeName:ne.ZodRecord,...oe(t)})}}class Ar extends le{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}),te;const s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([f,w],k)=>({key:s._parse(new vt(a,f,a.path,[k,"key"])),value:i._parse(new vt(a,w,a.path,[k,"value"]))}));if(a.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const w of c){const k=await w.key,M=await w.value;if(k.status==="aborted"||M.status==="aborted")return te;(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 w of c){const k=w.key,M=w.value;if(k.status==="aborted"||M.status==="aborted")return te;(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:ne.ZodMap,...oe(t)});class Ut extends le{_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}),te;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(w){const k=new Set;for(const M of w){if(M.status==="aborted")return te;M.status==="dirty"&&t.dirty(),k.add(M.value)}return{status:t.value,value:k}}const f=[...a.data.values()].map((w,k)=>i._parse(new vt(a,w,a.path,k)));return a.common.async?Promise.all(f).then(w=>c(w)):c(f)}min(e,t){return new Ut({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new Ut({...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)}}Ut.create=(r,e)=>new Ut({valueType:r,minSize:null,maxSize:null,typeName:ne.ZodSet,...oe(e)});class Ht extends le{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}),te;function a(f,w){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),Gt].filter(k=>!!k),issueData:{code:P.invalid_arguments,argumentsError:w}})}function s(f,w){return _r({data:f,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xr(),Gt].filter(k=>!!k),issueData:{code:P.invalid_return_type,returnTypeError:w}})}const i={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof Kt){const f=this;return Je(async function(...w){const k=new at([]),M=await f._def.args.parseAsync(w,i).catch(S=>{throw k.addIssue(a(w,S)),k}),D=await Reflect.apply(c,this,M);return await f._def.returns._def.type.parseAsync(D,i).catch(S=>{throw k.addIssue(s(D,S)),k})})}else{const f=this;return Je(function(...w){const k=f._def.args.safeParse(w,i);if(!k.success)throw new at([a(w,k.error)]);const M=Reflect.apply(c,this,k.data),D=f._def.returns.safeParse(M,i);if(!D.success)throw new at([s(M,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ht({...this._def,args:wt.create(e).rest(jt.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||wt.create([]).rest(jt.create()),returns:t||jt.create(),typeName:ne.ZodFunction,...oe(a)})}}class cr extends le{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:ne.ZodLazy,...oe(e)});class ur extends le{_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}),te}return{status:"valid",value:e.data}}get value(){return this._def.value}}ur.create=(r,e)=>new ur({value:r,typeName:ne.ZodLiteral,...oe(e)});function _n(r,e){return new Ct({values:r,typeName:ne.ZodEnum,...oe(e)})}class Ct extends le{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return U(t,{expected:we.joinValues(a),received:t.parsedType,code:P.invalid_type}),te}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}),te}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 Ct.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ct.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Ct.create=_n;class lr extends le{_parse(e){const t=we.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==W.string&&a.parsedType!==W.number){const s=we.objectValues(t);return U(a,{expected:we.joinValues(s),received:a.parsedType,code:P.invalid_type}),te}if(this._cache||(this._cache=new Set(we.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=we.objectValues(t);return U(a,{received:a.data,code:P.invalid_enum_value,options:s}),te}return Je(e.data)}get enum(){return this._def.values}}lr.create=(r,e)=>new lr({values:r,typeName:ne.ZodNativeEnum,...oe(e)});class Kt extends le{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}),te;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:ne.ZodPromise,...oe(e)});class ht extends le{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ne.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 te;const w=await this._def.schema._parseAsync({data:f,path:a.path,parent:a});return w.status==="aborted"?te:w.status==="dirty"||t.value==="dirty"?qt(w.value):w});{if(t.value==="aborted")return te;const f=this._def.schema._parseSync({data:c,path:a.path,parent:a});return f.status==="aborted"?te:f.status==="dirty"||t.value==="dirty"?qt(f.value):f}}if(s.type==="refinement"){const c=f=>{const w=s.refinement(f,i);if(a.common.async)return Promise.resolve(w);if(w 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"?te:(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"?te:(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(!Ft(c))return te;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=>Ft(c)?Promise.resolve(s.transform(c.value,i)).then(f=>({status:t.value,value:f})):te);we.assertNever(s)}}ht.create=(r,e,t)=>new ht({schema:r,typeName:ne.ZodEffects,effect:e,...oe(t)});ht.createWithPreprocess=(r,e,t)=>new ht({schema:e,effect:{type:"preprocess",transform:r},typeName:ne.ZodEffects,...oe(t)});class gt extends le{_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:ne.ZodOptional,...oe(e)});class Nt extends le{_parse(e){return this._getType(e)===W.null?Je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Nt.create=(r,e)=>new Nt({innerType:r,typeName:ne.ZodNullable,...oe(e)});class fr extends le{_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:ne.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...oe(e)});class dr extends le{_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:ne.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...oe(e)});class Sr extends le{_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}),te}return{status:"valid",value:e.data}}}Sr.create=r=>new Sr({typeName:ne.ZodNaN,...oe(r)});const oa=Symbol("zod_brand");class $r extends le{_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 le{_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"?te:i.status==="dirty"?(t.dirty(),qt(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"?te: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:ne.ZodPipeline})}}class hr extends le{_parse(e){const t=this._def.innerType._parse(e),a=s=>(Ft(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:ne.ZodReadonly,...oe(e)});function pn(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function En(r,e={},t){return r?Yt.create().superRefine((a,s)=>{const i=r(a);if(i instanceof Promise)return i.then(c=>{if(!c){const f=pn(e,a),w=f.fatal??t??!0;s.addIssue({code:"custom",...f,fatal:w})}});if(!i){const c=pn(e,a),f=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:f})}}):Yt.create()}const ca={object:Ie.lazycreate};var ne;(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"})(ne||(ne={}));const ua=(r,e={message:`Input not instance of ${r.name}`})=>En(t=>t instanceof r,e),Ue=ft.create,$t=Ot.create,la=Sr.create,fa=Pt.create,Tt=rr.create,da=Bt.create,ha=Er.create,pa=nr.create,ma=ar.create,ya=Yt.create,ga=jt.create,va=Et.create,wa=Tr.create,ba=dt.create,Rt=Ie.create,ka=Ie.strictCreate,xa=sr.create,_a=Dr.create,Ea=ir.create,Ta=wt.create,Aa=or.create,Sa=Ar.create,Da=Ut.create,Oa=Ht.create,Pa=cr.create,Ca=ur.create,Lr=Ct.create,Zr=lr.create,Na=Kt.create,mn=ht.create,Ra=gt.create,Ma=Nt.create,Ia=ht.createWithPreprocess,ja=pr.create,Fa=()=>Ue().optional(),Ba=()=>$t().optional(),Ua=()=>Tt().optional(),Br={string:(r=>ft.create({...r,coerce:!0})),number:(r=>Ot.create({...r,coerce:!0})),boolean:(r=>rr.create({...r,coerce:!0})),bigint:(r=>Pt.create({...r,coerce:!0})),date:(r=>Bt.create({...r,coerce:!0}))},$a=te,T=Object.freeze(Object.defineProperty({__proto__:null,BRAND:oa,DIRTY:qt,EMPTY_PATH:Un,INVALID:te,NEVER:$a,OK:Je,ParseStatus:Ke,Schema:le,ZodAny:Yt,ZodArray:dt,ZodBigInt:Pt,ZodBoolean:rr,ZodBranded:$r,ZodCatch:dr,ZodDate:Bt,ZodDefault:fr,ZodDiscriminatedUnion:Dr,ZodEffects:ht,ZodEnum:Ct,ZodError:at,get ZodFirstPartyTypeKind(){return ne},ZodFunction:Ht,ZodIntersection:ir,ZodIssueCode:P,ZodLazy:cr,ZodLiteral:ur,ZodMap:Ar,ZodNaN:Sr,ZodNativeEnum:lr,ZodNever:Et,ZodNull:ar,ZodNullable:Nt,ZodNumber:Ot,ZodObject:Ie,ZodOptional:gt,ZodParsedType:W,ZodPipeline:pr,ZodPromise:Kt,ZodReadonly:hr,ZodRecord:or,ZodSchema:le,ZodSet:Ut,ZodString:ft,ZodSymbol:Er,ZodTransformer:ht,ZodTuple:wt,ZodType:le,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:jt,ZodVoid:Tr,addIssueToContext:U,any:ya,array:ba,bigint:fa,boolean:Tt,coerce:Br,custom:En,date:da,datetimeRegex:xn,defaultErrorMap:Gt,discriminatedUnion:_a,effect:mn,enum:Lr,function:Oa,getErrorMap:xr,getParsedType:_t,instanceof:ua,intersection:Ea,isAborted:Ir,isAsync:tr,isDirty:jr,isValid:Ft,late:ca,lazy:Pa,literal:Ca,makeIssue:_r,map:Sa,nan:la,nativeEnum:Zr,never:va,null:ma,nullable:Ma,number:$t,object:Rt,get objectUtil(){return Mr},oboolean:Ua,onumber:Ba,optional:Ra,ostring:Fa,pipeline:ja,preprocess:Ia,promise:Na,quotelessJson:Fn,record:Aa,set:Da,setErrorMap:Bn,strictObject:ka,string:Ue,symbol:ha,transformer:mn,tuple:Ta,undefined:pa,union:xa,unknown:ga,get util(){return we},void:wa},Symbol.toStringTag,{value:"Module"})),pt=Rt({name:Ue(),selector:Ue(),findBy:Lr(["cssSelector","xpath"]),option:Rt({waitForSelector:Tt().optional(),waitSelectorTimeout:$t().optional(),multiple:Tt().optional()})}),La=T.object({type:T.literal("object"),shape:T.record(T.string(),T.any())}),Za=T.object({type:T.literal("array"),items:T.any()}),Wa=T.discriminatedUnion("type",[La,Za]),Wr=T.object({name:T.literal("ai-parse-data"),sourceData:T.any().optional(),schemaDefinition:Wa,prompt:T.string().optional(),model:T.string().optional(),apiKey:T.string().min(1,"AI API key is required"),provider:T.enum(["openai","anthropic"])});function za(r){return Wr.parse(r)}async function Va(r){try{const{sourceData:e,schemaDefinition:t,prompt:a,model:s,apiKey:i,provider:c}=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 f=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:t,prompt:a,model:s,apiKey:i,provider:c}});if(f.$isError)throw new Error(f.message||"AI parsing failed");return{data:f.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function qa(r){return{type:"object",shape:r}}function Ha(r){return{type:"array",items:r}}const Ga={string:r=>({type:"string",...r}),number:r=>({type:"number",...r}),boolean:r=>({type:"boolean",...r}),array:(r,e)=>({type:"array",items:r,...e}),object:(r,e)=>({type:"object",shape:r,...e}),currency:r=>({type:"currency",shape:An,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 Ya extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=this.processCustomPseudoSelectors(a,t);return i?Array.from(t.querySelectorAll(c)):t.querySelector(c)}catch(c){return console.error("CSS Selector error:",c),null}}processCustomPseudoSelectors(e,t){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-contains="${c}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(t),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,c)=>`[data-equal="${c}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const s=((i=a.textContent)==null?void 0:i.trim())||"";if(s){a.setAttribute("data-contains",s);const f=Array.from(a.childNodes).filter(w=>w.nodeType===Node.TEXT_NODE).map(w=>{var k;return((k=w.textContent)==null?void 0:k.trim())||""}).join(" ").trim();(f&&f===s||a.children.length===0&&s)&&a.setAttribute("data-equal",s)}})}}class Ka extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split("|>").map(k=>k.trim());if(c.length!==2)return null;const f=c[0],w=c[1];if(!f||!w)return null;try{const k=t.querySelector(f);if(!k||!k.contentDocument)return null;const M=k.contentDocument;return i?Array.from(M.querySelectorAll(w)):M.querySelector(w)}catch(k){return console.error("Iframe Selector error:",k),null}}}class Ja extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};if(!a||a.trim()==="")return null;const c=a.split(">>").map(w=>w.trim());let f=t;try{for(let w=0;w<c.length;w++){const k=c[w],M=w===c.length-1;if(!k)return null;if(M&&i)return Array.from(f.querySelectorAll(k));const D=f.querySelector(k);if(!D)return null;if(M)return D;if(D.shadowRoot)f=D.shadowRoot;else return null}}catch(w){return console.error("Shadow DOM Selector error:",w),null}return null}}class Xa extends Or{async find(e,t=document){const{selector:a,option:s}=e,{multiple:i=!1}=s||{};try{const c=t.evaluate(a,t,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const f=[];for(let w=0;w<c.snapshotLength;w++){const k=c.snapshotItem(w);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 Qa{static generate(e){const t=["data-testid","aria-label","title","alt","role"];for(const i of t){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const a=e.tagName.toLowerCase(),s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${c})`}if(s){const i=this.generateParentSelector(s);if(i)return`${i} > ${a}:nth-child(${Array.from(s.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const t=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const c=e.getAttribute(i);if(c&&!this.isDynamicValue(c))return`[${i}="${CSS.escape(c)}"]`}const s=e.parentElement;if(s){const i=Array.from(s.children),c=i.indexOf(e)+1;if(i.length>1)return`${t}:nth-child(${c})`}return t}static isDynamicValue(e){return[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^\d{13}$/,/^[a-zA-Z0-9]{16,}$/,/^[a-zA-Z0-9]+-\d+$/].some(a=>a.test(e))}}async function mt(r,e=document){const{selector:t,findBy:a="cssSelector",option:s}=r,{waitForSelector:i=!1,waitSelectorTimeout:c=5e3}=s||{},f=es(t,a);return i?f.waitForElement(r,e,c):f.find(r,e)}function es(r,e){return e==="xpath"?new Xa:r.includes(">>")?new Ja:r.includes("|>")?new Ka:new Ya}const zr=pt.extend({name:T.literal("get-text"),includeTags:T.boolean().optional(),useTextContent:T.boolean().optional(),regex:T.string().optional(),prefixText:T.string().optional(),suffixText:T.string().optional(),filterEmpty:T.boolean().optional(),scrollToCollect:T.boolean().optional(),scrollDistance:T.number().optional(),scrollWaitMs:T.number().optional(),maxScrollAttempts:T.number().optional()});function ts(r){return zr.parse(r)}async function rs(r){try{const{selector:e="",includeTags:t=!1,useTextContent:a=!1,regex:s,prefixText:i="",suffixText:c="",findBy:f="cssSelector",option:w,filterEmpty:k=!0,scrollToCollect:M=!1,scrollDistance:D=500,scrollWaitMs:x=300,maxScrollAttempts:S=100}=r;if(!e)throw new Error("Selector is required for get-text block");if(M&&(w!=null&&w.multiple))return await ns({selector:e,findBy:f,option:w,includeTags:t,useTextContent:a,regex:s,prefixText:i,suffixText:c,filterEmpty:k,scrollDistance:D,scrollWaitMs:x,maxScrollAttempts:S});const I=await mt({selector:e,findBy:f,option:w});if(!I)return{data:""};const ae=Tn(t,a,s,i,c);if(Array.isArray(I)){const Q=I.map(ae);return{data:k?Q.filter(H=>H.trim()!==""):Q}}else return{data:ae(I)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-text handler",data:""}}}async function ns(r){const{selector:e,findBy:t,option:a,includeTags:s,useTextContent:i,regex:c,prefixText:f,suffixText:w,filterEmpty:k,scrollDistance:M,scrollWaitMs:D,maxScrollAttempts:x}=r,S=Tn(s,i,c,f,w),I=new Set;let ae=0,Q=0;const pe=5;for(;ae<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=S($);(!k||z.trim()!=="")&&I.add(z)}),I.size===L){if(Q++,Q>=pe)break}else Q=0}const N=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:M,behavior:"auto"}),await new Promise(L=>setTimeout(L,D)),(window.pageYOffset||document.documentElement.scrollTop)===N)break;ae++}return{data:Array.from(I)}}function Tn(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"),w=c.match(f);c=w?w.join(" "):""}return c.trim()&&(c=a+c.trim()+s),c}}const Vr=pt.extend({name:T.literal("attribute-value"),attributeName:T.string()});function as(r){return Vr.parse(r)}async function ss(r){try{const{selector:e="",attributeName:t,findBy:a="cssSelector",option:s}=r;if(!e)throw new Error("Selector is required for attribute-value block");if(!t)throw new Error("Attribute name is required for attribute-value block");const i=await mt({selector:e,findBy:a,option:s});return i?{data:Array.isArray(i)?i.map(f=>f.getAttribute(t)).filter(f=>f!==null):i.getAttribute(t)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const qr=pt.extend({name:T.literal("get-value-form"),type:T.enum(["text-field","select","checkbox"]).optional()});function is(r){return qr.parse(r)}async function os(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for get-value-form block");const s=await mt({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return{data:cs(s,t)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function cs(r,e){switch(e){case"text-field":if(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)return r.value;break;case"select":if(r instanceof HTMLSelectElement)return r.value;break;case"checkbox":if(r instanceof HTMLInputElement&&r.type==="checkbox")return r.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const Hr=pt.extend({name:T.literal("set-value-form"),setValue:T.string(),type:T.enum(["text-field","select","checkbox"]).optional()});function us(r){return Hr.parse(r)}async function ls(r){try{const{selector:e="",setValue:t,type:a="text-field",findBy:s="cssSelector"}=r;if(!e)throw new Error("Selector is required for set-value-form block");const i=await mt({selector:e,findBy:s,option:r.option});if(!i)throw new Error("Form element not found");return fs(i,t,a),{data:"Form element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-value-form handler",data:null}}}function fs(r,e,t){switch(t){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value=e,r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.value=e,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=e==="true"||e==="checked",r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${t}`)}}const Gr=pt.extend({name:T.literal("clear-value-form"),type:T.enum(["text-field","select","checkbox"]).optional()});function ds(r){return Gr.parse(r)}async function hs(r){try{const{selector:e="",type:t="text-field",findBy:a="cssSelector"}=r;if(!e)throw new Error("Selector is required for clear-value-form block");const s=await mt({selector:e,findBy:a,option:r.option});if(!s)throw new Error("Form element not found");return ps(s,t),{data:"Form element cleared successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in clear-value-form handler",data:null}}}function ps(r,e){switch(e){case"text-field":(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)&&(r.value="",r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":r instanceof HTMLSelectElement&&(r.selectedIndex=0,r.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":r instanceof HTMLInputElement&&r.type==="checkbox"&&(r.checked=!1,r.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Yr=pt.extend({name:T.literal("element-exists")});function ms(r){return Yr.parse(r)}async function ys(r){try{const{selector:e="",findBy:t="cssSelector",option:a}=r;if(!e)throw new Error("Selector is required for element-exists block");return{data:await mt({selector:e,findBy:t,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Kr=pt.extend({name:T.literal("event-click"),textFilter:T.object({text:T.union([T.string(),T.array(T.string())]),mode:T.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function gs(r){return Kr.parse(r)}async function vs(r){try{const{selector:e="",findBy:t="cssSelector",option:a,textFilter:s}=r;if(!e)throw new Error("Selector is required for event-click block");const i=await mt({selector:e,findBy:t,option:a});if(!i)throw new Error("Element not found for clicking");let c;if(Array.isArray(i))if(s){const f=ws(i,s.text,s.mode);if(!f){const w=Array.isArray(s.text)?s.text.join(", "):s.text;throw new Error(`No element found with text filter: "${w}" (mode: ${s.mode})`)}c=f}else c=i[0];else c=i;return await ks(c),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in event-click handler",data:!1}}}function ws(r,e,t){for(const a of r){const s=bs(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 bs(r){if(r.innerText)return r.innerText.trim();if(r.textContent)return r.textContent.trim();if(r instanceof HTMLInputElement&&r.value)return r.value.trim();const e=r.getAttribute("placeholder");if(e)return e.trim();const t=r.getAttribute("title");if(t)return t.trim();const a=r.getAttribute("aria-label");return a?a.trim():""}async function ks(r){r.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(s=>setTimeout(s,50)),r.focus&&r.focus();const e=r.getBoundingClientRect(),t=e.left+e.width/2,a=e.top+e.height/2;try{const s=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:t,y:a}});if(s&&!s.$isError)console.log("[EventClick] CDP click successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP click failed")}catch(s){console.error("[EventClick] CDP click failed, falling back to native click:",s),r.click&&r.click()}await new Promise(s=>setTimeout(s,50))}const Jr=T.object({name:T.literal("keypress"),key:T.string(),code:T.string().optional(),keyCode:T.number().optional(),modifiers:T.array(T.enum(["Alt","Control","Meta","Shift"])).optional()});function xs(r){return Jr.parse(r)}async function _s(r){try{const{key:e,code:t,keyCode:a,modifiers:s=[]}=r;return await Es(e,t,a,s),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in keypress handler",data:!1}}}async function Es(r,e,t,a=[]){try{const s=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:r,code:e||r,keyCode:t||Nr(r),modifiers:a}});if(s&&!s.$isError)console.log("[Keypress] CDP keypress successful:",s);else throw new Error((s==null?void 0:s.message)||"CDP keypress failed")}catch(s){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",s);const i=new KeyboardEvent("keydown",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...yn(a)}),c=new KeyboardEvent("keyup",{key:r,code:e||r,keyCode:t||Nr(r),bubbles:!0,cancelable:!0,...yn(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 yn(r){return{altKey:r.includes("Alt"),ctrlKey:r.includes("Control"),metaKey:r.includes("Meta"),shiftKey:r.includes("Shift")}}const Xr=T.object({name:T.literal("wait"),duration:T.number().min(0)});function Ts(r){return Xr.parse(r)}async function As(r){try{const{duration:e}=r;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(t=>setTimeout(t,e)),console.log(`[Wait] Wait completed after ${e}ms`),{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in wait handler",data:!1}}}const Qr=T.object({name:T.literal("wait-for-condition"),conditions:T.object({urlPattern:T.string().optional(),elementExists:T.object({selector:T.string(),findBy:T.enum(["cssSelector","xpath"])}).optional(),cookieExists:T.string().optional(),storageKey:T.object({type:T.enum(["localStorage","sessionStorage"]),key:T.string()}).optional(),userConfirmation:T.boolean().optional(),message:T.string().optional(),buttonText:T.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:T.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:T.number().min(100).optional(),timeoutMs:T.number().min(1e3).optional(),position:T.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Ss(r){return Qr.parse(r)}async function Ds(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 w=null,k=null;(t==="manual"||t==="auto-or-manual")&&f&&(w=new Promise(D=>{k=D}),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(D){console.warn("[WaitForCondition] Invalid URL pattern:",D)}if(e.elementExists){const{selector:D,findBy:x}=e.elementExists;let S=null;if(x==="cssSelector"?S=document.querySelector(D):x==="xpath"&&(S=document.evaluate(D,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),S)return{success:!0,reason:"elementExists",message:`Element found: ${D}`}}if(e.cookieExists&&document.cookie.split(";").some(S=>{const[I]=S.trim().split("=");return I===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:D,key:x}=e.storageKey;if((D==="localStorage"?window.localStorage:window.sessionStorage).getItem(x)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${D}.${x}`}}return null};return new Promise(D=>{let x=null,S=!1;const I=()=>{x&&(clearInterval(x),x=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},ae=pe=>{S||(S=!0,I(),console.log("[WaitForCondition] Resolved with:",pe),D({data:pe}))},Q=setTimeout(()=>{ae({success:!1,reason:"timeout",message:`Timeout after ${s}ms`})},s);(t==="auto"||t==="auto-or-manual")&&c&&(x=setInterval(async()=>{const pe=await M();pe&&(clearTimeout(Q),ae(pe))},a)),(t==="manual"||t==="auto-or-manual")&&w&&w.then(()=>{clearTimeout(Q),ae({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 en=T.object({name:T.literal("navigate"),url:T.string().url("Valid URL is required"),waitForLoad:T.boolean().optional(),timeout:T.number().min(0).optional()});function Os(r){return en.parse(r)}async function Ps(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 tn=pt.extend({name:T.literal("save-assets")});function Cs(r){return tn.parse(r)}async function Ns(r){try{const{selector:e="img, audio, video, source",findBy:t="cssSelector",option:a}=r,s=await mt({selector:e,findBy:t,option:a});if(!s||!Array.isArray(s))return{data:[]};const i=[];return s.forEach(c=>{let f="";(c instanceof HTMLImageElement||c instanceof HTMLAudioElement||c instanceof HTMLVideoElement||c instanceof HTMLSourceElement)&&(f=c.src),f&&!i.includes(f)&&i.push(f)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class Rs{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(w=>w.tagName===a.tagName);if(c.length>1){const w=c.indexOf(a)+1;i+=`[${w}]`}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 rn=pt.extend({name:T.literal("get-element-data"),includeText:T.boolean().optional(),includeTags:T.boolean().optional(),useTextContent:T.boolean().optional(),regex:T.string().optional(),prefixText:T.string().optional(),suffixText:T.string().optional(),attributes:T.array(T.string()).optional(),includeSelector:T.boolean().optional(),includeXPath:T.boolean().optional()});function Ms(r){return rn.parse(r)}async function Is(r){try{const{selector:e="",includeText:t=!0,includeTags:a=!1,useTextContent:s=!1,regex:i,prefixText:c="",suffixText:f="",attributes:w=[],includeSelector:k=!1,includeXPath:M=!1,findBy:D="cssSelector",option:x}=r;if(!e)throw new Error("Selector is required for get-element-data block");if(!t&&w.length===0)throw new Error("Either includeText must be true or attributes must be provided");const S=await mt({selector:e,findBy:D,option:x});if(!S)return{data:Array.isArray(S)?[]:{}};const I=js(t,a,s,i,c,f,w,k,M);return Array.isArray(S)?{data:S.map(I)}:{data:I(S)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function js(r,e,t,a,s="",i="",c=[],f=!1,w=!1){return k=>{const M={};if(r){let D="";if(e?D=k.innerHTML:D=t?k.textContent||"":k.innerText||"",a){const x=new RegExp(a,"g"),S=D.match(x);D=S?S.join(" "):""}D.trim()&&(D=s+D.trim()+i),M.text=D}return c.length>0&&(M.attributes={},c.forEach(D=>{let x=k.getAttribute(D);if(x===null){const S=k.querySelector(`[${D}]`);S&&(x=S.getAttribute(D))}M.attributes[D]=x})),f&&(M.selector=Qa.generate(k)),w&&(M.xpath=Rs.generate(k)),M}}const nn=pt.extend({name:T.literal("scroll"),scrollType:T.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:T.number().optional(),behavior:T.enum(["auto","smooth"]).optional(),maxScrolls:T.number().optional(),waitAfterScroll:T.number().optional()});function Fs(r){return nn.parse(r)}async function Bs(r){try{const{selector:e="",scrollType:t="toBottom",distance:a=500,behavior:s="smooth",maxScrolls:i=50,waitAfterScroll:c=300,findBy:f="cssSelector",option:w}=r;switch(t){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Us(e,f,w,s);case"toBottom":return await $s(s,c);case"byDistance":return await Ls(a,s);case"untilLoaded":return await Zs(i,a,s,c);default:throw new Error(`Unknown scroll type: ${t}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Us(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 $s(r,e){let t=document.body.scrollHeight,a=0;const s=50;for(;a<s;){window.scrollTo({top:document.body.scrollHeight,behavior:r}),await new Promise(c=>setTimeout(c,e));const i=document.body.scrollHeight;if(i===t)break;t=i,a++}return{data:!0}}async function Ls(r,e){return window.scrollBy({top:r,behavior:e}),{data:!0}}async function Zs(r,e,t,a){let s=0,i=document.body.scrollHeight;for(;s<r;){window.scrollBy({top:e,behavior:t}),await new Promise(k=>setTimeout(k,a));const c=document.body.scrollHeight,f=window.pageYOffset||document.documentElement.scrollTop,w=window.innerHeight;if(f+w>=c-10&&c===i)break;i=c,s++}return{data:!0}}const an=T.object({name:T.literal("fetch-api"),url:T.string(),method:T.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:T.record(T.string(),T.string()).optional(),body:T.record(T.string(),T.any()).optional(),timeout:T.number().min(0).optional(),parseJson:T.boolean().optional(),returnHeaders:T.boolean().optional()});function Ws(r){return an.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 gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function kr(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Rr={exports:{}},vn;function qs(){return vn||(vn=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 D=typeof kr=="function"&&kr;if(!M&&D)return D(k,!0);if(f)return f(k,!0);var x=new Error("Cannot find module '"+k+"'");throw x.code="MODULE_NOT_FOUND",x}var S=s[k]={exports:{}};a[k][0].call(S.exports,function(I){var ae=a[k][1][I];return c(ae||I)},S,S.exports,t,a,s,i)}return s[k].exports}for(var f=typeof kr=="function"&&kr,w=0;w<i.length;w++)c(i[w]);return c}return t})()({1:[function(t,a,s){const i=t("./utils"),c=(function(){const f=i.stringToArray,w=["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"],D=["Thousand","Million","Billion","Trillion"];function x(v,A){var b=function(B,j,O){var F="";if(B<=19)F=(j?" and ":"")+(O?k[B]:w[B]);else if(B<100){const ge=Math.floor(B/10),be=B%10;F=(j?" and ":"")+M[ge-2],be>0?F+="-"+b(be,!1,O):O&&(F=F.substring(0,F.length-1)+"ieth")}else if(B<1e3){const ge=Math.floor(B/100),be=B%100;F=(j?", ":"")+w[ge]+" Hundred",be>0?F+=b(be,!0,O):O&&(F+="th")}else{var J=Math.floor(Math.log10(B)/3);J>D.length&&(J=D.length);const ge=Math.pow(10,J*3),be=Math.floor(B/ge),K=B-be*ge;F=(j?", ":"")+b(be,!1,!1)+" "+D[J-1],K>0?F+=b(K,!0,O):O&&(F+="th")}return F},C=b(v,!1,A);return C}const S={};w.forEach(function(v,A){S[v.toLowerCase()]=A}),k.forEach(function(v,A){S[v.toLowerCase()]=A}),M.forEach(function(v,A){const b=v.toLowerCase();S[b]=(A+2)*10,S[b.substring(0,v.length-1)+"ieth"]=S[b]}),S.hundredth=100,D.forEach(function(v,A){const b=v.toLowerCase(),C=Math.pow(10,(A+1)*3);S[b]=C,S[b+"th"]=C});function I(v){const b=v.split(/,\s|\sand\s|[\s\\-]/).map(j=>S[j]);let C=[0];return b.forEach(j=>{if(j<100){let O=C.pop();O>=1e3&&(C.push(O),O=0),C.push(O+j)}else C.push(C.pop()*j)}),C.reduce((j,O)=>j+O,0)}const ae=[[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"]],Q={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function pe(v){for(var A=0;A<ae.length;A++){const b=ae[A];if(v>=b[0])return b[1]+pe(v-b[0])}return""}function H(v){for(var A=0,b=1,C=v.length-1;C>=0;C--){const B=v[C],j=Q[B];j<b?A-=j:(b=j,A+=j)}return A}function N(v,A){for(var b=[],C=A.charCodeAt(0);v>0;)b.unshift(String.fromCharCode((v-1)%26+C)),v=Math.floor((v-1)/26);return b.join("")}function se(v,A){for(var b=A.charCodeAt(0),C=0,B=0;B<v.length;B++)C+=(v.charCodeAt(v.length-B-1)-b+1)*Math.pow(26,B);return C}function L(v,A){if(typeof v>"u")return;v=Math.floor(v);const b=xe(A);return z(v,b)}const E={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},$={UPPER:"upper",LOWER:"lower",TITLE:"title"};function z(v,A){let b;const C=v<0;switch(v=Math.abs(v),A.primary){case E.LETTERS:b=N(v,A.case===$.UPPER?"A":"a");break;case E.ROMAN:b=pe(v),A.case===$.UPPER&&(b=b.toUpperCase());break;case E.WORDS:b=x(v,A.ordinal),A.case===$.UPPER?b=b.toUpperCase():A.case===$.LOWER&&(b=b.toLowerCase());break;case E.DECIMAL:b=""+v;var B=A.mandatoryDigits-b.length;if(B>0){var j=new Array(B+1).join("0");b=j+b}if(A.zeroCode!==48&&(b=f(b).map(ge=>String.fromCodePoint(ge.codePointAt(0)+A.zeroCode-48)).join("")),A.regular){const ge=Math.floor((b.length-1)/A.groupingSeparators.position);for(let be=ge;be>0;be--){const K=b.length-be*A.groupingSeparators.position;b=b.substr(0,K)+A.groupingSeparators.character+b.substr(K)}}else A.groupingSeparators.reverse().forEach(ge=>{const be=b.length-ge.position;b=b.substr(0,be)+ge.character+b.substr(be)});if(A.ordinal){var O={1:"st",2:"nd",3:"rd"},F=b[b.length-1],J=O[F];(!J||b.length>1&&b[b.length-2]==="1")&&(J="th"),b=b+J}break;case E.SEQUENCE:throw{code:"D3130",value:A.token}}return C&&(b="-"+b),b}const he=[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:E.DECIMAL,case:$.LOWER,ordinal:!1};let b,C;const B=v.lastIndexOf(";");switch(B===-1?b=v:(b=v.substring(0,B),C=v.substring(B+1),C[0]==="o"&&(A.ordinal=!0)),b){case"A":A.case=$.UPPER;case"a":A.primary=E.LETTERS;break;case"I":A.case=$.UPPER;case"i":A.primary=E.ROMAN;break;case"W":A.case=$.UPPER,A.primary=E.WORDS;break;case"Ww":A.case=$.TITLE,A.primary=E.WORDS;break;case"w":A.primary=E.WORDS;break;default:{let j=null,O=0,F=0,J=[],ge=0;if(f(b).map(K=>K.codePointAt(0)).reverse().forEach(K=>{let ee=!1;for(let me=0;me<he.length;me++){const G=he[me];if(K>=G&&K<=G+9){if(ee=!0,O++,ge++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}ee||(K===35?(ge++,F++):J.push({position:ge,character:String.fromCodePoint(K)}))}),O>0){A.primary=E.DECIMAL,A.zeroCode=j,A.mandatoryDigits=O,A.optionalDigits=F;const ee=function(me){if(me.length===0)return 0;const G=me[0].character;for(let $e=1;$e<me.length;$e++)if(me[$e].character!==G)return 0;const Ze=me.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);ee>0?(A.regular=!0,A.groupingSeparators={position:ee,character:J[0].character}):(A.regular=!1,A.groupingSeparators=J)}else A.primary=E.SEQUENCE,A.token=b}}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 b={type:"datetime",parts:A},C=function(ee,me){if(me>ee){let G=v.substring(ee,me);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 ee=v.substring(B+1,j);ee=ee.split(/\s+/).join("");var O={type:"marker",component:ee.charAt(0)},F=ee.lastIndexOf(","),J;if(F!==-1){const me=ee.substring(F+1),G=me.indexOf("-");let Ze,it;const qe=function(He){if(!(typeof He>"u"||He==="*"))return parseInt(He)};G===-1?Ze=me:(Ze=me.substring(0,G),it=me.substring(G+1));const $e={min:qe(Ze),max:qe(it)};O.width=$e,J=ee.substring(1,F)}else J=ee.substring(1);if(J.length===1)O.presentation1=J;else if(J.length>1){var ge=J.charAt(J.length-1);"atco".indexOf(ge)!==-1?(O.presentation2=ge,ge==="o"&&(O.ordinal=!0),O.presentation1=J.substring(0,J.length-1)):O.presentation1=J}else O.presentation1=Te[O.component];if(typeof O.presentation1>"u")throw{code:"D3132",value:O.component};if(O.presentation1[0]==="n")O.names=$.LOWER;else if(O.presentation1[0]==="N")O.presentation1[1]==="n"?O.names=$.TITLE:O.names=$.UPPER;else if("YMDdFWwXxHhmsf".indexOf(O.component)!==-1){var be=O.presentation1;if(O.presentation2&&(be+=";"+O.presentation2),O.integerFormat=xe(be),O.width&&O.width.min!==void 0&&O.integerFormat.mandatoryDigits<O.width.min&&(O.integerFormat.mandatoryDigits=O.width.min),O.component==="Y")if(O.n=-1,O.width&&O.width.max!==void 0)O.n=O.width.max,O.integerFormat.mandatoryDigits=O.n;else{var K=O.integerFormat.mandatoryDigits+O.integerFormat.optionalDigits;K>=2&&(O.n=K)}const me=A[A.length-1];me&&me.integerFormat&&(me.integerFormat.parseWidth=me.integerFormat.mandatoryDigits)}(O.component==="Z"||O.component==="z")&&(O.integerFormat=xe(O.presentation1)),A.push(O),B=j+1}j++}return C(B,j),b}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 b=new Date(A).getUTCDay();return b===0&&(b=7),b>4?A+(8-b)*et:A-(b-1)*et},fe=function(v,A){return{year:v,month:A,nextMonth:function(){return A===11?fe(v+1,0):fe(v,A+1)},previousMonth:function(){return A===0?fe(v-1,11):fe(v,A-1)},nextYear:function(){return fe(v+1,A)},previousYear:function(){return fe(v-1,A)}}},tt=function(v,A){return(A-v)/(et*7)+1},ie=(v,A)=>{let b;switch(A){case"Y":b=v.getUTCFullYear();break;case"M":b=v.getUTCMonth()+1;break;case"D":b=v.getUTCDate();break;case"d":{const C=Date.UTC(v.getUTCFullYear(),v.getUTCMonth(),v.getUTCDate()),B=Date.UTC(v.getUTCFullYear(),0);b=(C-B)/et+1;break}case"F":b=v.getUTCDay(),b===0&&(b=7);break;case"W":{const C=fe(v.getUTCFullYear(),0),B=_e(C),j=Date.UTC(C.year,v.getUTCMonth(),v.getUTCDate());let O=tt(B,j);if(O>52){const F=_e(C.nextYear());j>=F&&(O=1)}else if(O<1){const F=_e(C.previousYear());O=tt(F,j)}b=Math.floor(O);break}case"w":{const C=fe(v.getUTCFullYear(),v.getUTCMonth()),B=_e(C),j=Date.UTC(C.year,C.month,v.getUTCDate());let O=tt(B,j);if(O>4){const F=_e(C.nextMonth());j>=F&&(O=1)}else if(O<1){const F=_e(C.previousMonth());O=tt(F,j)}b=Math.floor(O);break}case"X":{const C=fe(v.getUTCFullYear(),0),B=_e(C),j=_e(C.nextYear()),O=v.getTime();O<B?b=C.year-1:O>=j?b=C.year+1:b=C.year;break}case"x":{const C=fe(v.getUTCFullYear(),v.getUTCMonth()),B=_e(C),j=C.nextMonth(),O=_e(j),F=v.getTime();F<B?b=C.previousMonth().month+1:F>=O?b=j.month+1:b=C.month+1;break}case"H":b=v.getUTCHours();break;case"h":b=v.getUTCHours(),b=b%12,b===0&&(b=12);break;case"P":b=v.getUTCHours()>=12?"pm":"am";break;case"m":b=v.getUTCMinutes();break;case"s":b=v.getUTCSeconds();break;case"f":b=v.getUTCMilliseconds();break;case"Z":case"z":break;case"C":b="ISO";break;case"E":b="ISO";break}return b};let Fe=null;function st(v,A,b){var C=0,B=0;if(typeof b<"u"){const be=parseInt(b);C=Math.floor(be/100),B=be%100}var j=function(be,K){var ee=ie(be,K.component);if("YMDdFWwXxHhms".indexOf(K.component)!==-1)if(K.component==="Y"&&K.n!==-1&&(ee=ee%Math.pow(10,K.n)),K.names){if(K.component==="M"||K.component==="x")ee=Re[ee-1];else if(K.component==="F")ee=ve[ee];else throw{code:"D3133",value:K.component};K.names===$.UPPER?ee=ee.toUpperCase():K.names===$.LOWER&&(ee=ee.toLowerCase()),K.width&&ee.length>K.width.max&&(ee=ee.substring(0,K.width.max))}else ee=z(ee,K.integerFormat);else if(K.component==="f")ee=z(ee,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const me=C*100+B;if(K.integerFormat.regular)ee=z(me,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)ee=z(C,K.integerFormat),B!==0&&(ee+=":"+L(B,"00"));else if(G===3||G===4)ee=z(me,K.integerFormat);else throw{code:"D3134",value:G}}me>=0&&(ee="+"+ee),K.component==="z"&&(ee="GMT"+ee),me===0&&K.presentation2==="t"&&(ee="Z")}else K.component==="P"&&K.names===$.UPPER&&(ee=ee.toUpperCase());return ee};let O;typeof A>"u"?(Fe===null&&(Fe=Ae("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),O=Fe):O=Ae(A);const F=(60*C+B)*60*1e3,J=new Date(v+F);let ge="";return O.parts.forEach(function(be){be.type==="literal"?ge+=be.value:ge+=j(J,be)}),ge}function d(v){var A={};if(v.type==="datetime")A.type="datetime",A.parts=v.parts.map(function(b){var C={};if(b.type==="literal")C.regex=b.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(b.component==="Z"||b.component==="z"){let j;Array.isArray(b.integerFormat.groupingSeparators)||(j=b.integerFormat.groupingSeparators),C.regex="",b.component==="z"&&(C.regex="GMT"),C.regex+="[-+][0-9]+",j&&(C.regex+=j.character+"[0-9]+"),C.parse=function(O){b.component==="z"&&(O=O.substring(3));let F=0,J=0;return j?(F=Number.parseInt(O.substring(0,O.indexOf(j.character))),J=Number.parseInt(O.substring(O.indexOf(j.character)+1))):O.length-1<=2?F=Number.parseInt(O):(F=Number.parseInt(O.substring(0,3)),J=Number.parseInt(O.substring(3))),F*60+J}}else if(b.integerFormat)C=d(b.integerFormat);else{C.regex="[a-zA-Z]+";var B={};if(b.component==="M"||b.component==="x")Re.forEach(function(j,O){b.width&&b.width.max?B[j.substring(0,b.width.max)]=O+1:B[j]=O+1});else if(b.component==="F")ve.forEach(function(j,O){O>0&&(b.width&&b.width.max?B[j.substring(0,b.width.max)]=O:B[j]=O)});else if(b.component==="P")B={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:b.component};C.parse=function(j){return B[j]}}return C.component=b.component,C});else{A.type="integer";const b=v.case===$.UPPER;switch(v.primary){case E.LETTERS:A.regex=b?"[A-Z]+":"[a-z]+",A.parse=function(C){return se(C,b?"A":"a")};break;case E.ROMAN:A.regex=b?"[MDCLXVI]+":"[mdclxvi]+",A.parse=function(C){return H(b?C:C.toUpperCase())};break;case E.WORDS:A.regex="(?:"+Object.keys(S).concat("and","[\\-, ]").join("|")+")+",A.parse=function(C){return I(C.toLowerCase())};break;case E.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 E.SEQUENCE:throw{code:"D3130",value:v.token}}}return A}function m(v,A){if(typeof v>"u")return;const b=xe(A);return d(b).parse(v)}function V(v,A){const b=Ae(A),C=d(b),B="^"+C.parts.map(J=>"("+J.regex+")").join("")+"$";var O=new RegExp(B,"i").exec(v);if(O!==null){const G={};for(let De=1;De<O.length;De++){const u=C.parts[De-1];u.parse&&(G[u.component]=u.parse(O[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),bt=qe(84),At=!bt&&qe(72);Ze=0,"PHhmsf".split("").forEach(De=>it(G[De]));const St=!qe(23)&&qe(47),Jt=(He?"YD":bt?"XxwF":At?"XWF":"YMD")+(St?"Phmsf":"Hmsf"),ut=this.environment.timestamp;let Lt=!1,yt=!1;if(Jt.split("").forEach(De=>{if(typeof G[De]>"u")Lt?(G[De]="MDd".indexOf(De)!==-1?1:0,yt=!0):G[De]=ie(ut,De);else if(Lt=!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(bt)throw{code:"D3136"};if(At)throw{code:"D3136"};St&&(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 de=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(!de.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,b){if(!(typeof v>"u"))return st.call(this,v,A,b)}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 w=c.isNumeric,k=c.isArrayOfStrings,M=c.isArrayOfNumbers,D=c.createSequence,x=c.isSequence,S=c.isFunction,I=c.isLambda,ae=c.isPromise,Q=c.getFunctionArity,pe=c.isDeepEqual,H=c.stringToArray;function N(n){if(!(typeof n>"u")){var o=0;return n.forEach(function(l){o+=l}),o}}function se(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 E(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(S(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&&w(_)?Number(_.toPrecision(15)):_&&S(_)?"":_},g)}return l}}function he(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&&(_=he(_,0,p)),o>0?g=n+_:g=_+n}else g=n;return g}}async function fe(n,o){var l=n.apply(this,[o]);if(ae(l)&&(l=await l),l&&!(typeof l.start=="number"||l.end==="number"||Array.isArray(l.groups)||S(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 fe(o,n);l=typeof g<"u"}return l}}async function ie(n,o,l){if(!(typeof n>"u")){if(l<0)throw{stack:new Error().stack,value:l,code:"D3040",index:3};var g=D();if(typeof l>"u"||l>0){var p=0,_=await fe(o,n);if(typeof _<"u")for(;typeof _<"u"&&(typeof l>"u"||p<l);)g.push({match:_.match,index:_.start,groups:_.groups}),_=await fe(_.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 Zt=Se.groups[je-1];typeof Zt<"u"&&(We+=Zt)}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 ye=await fe(o,n);if(typeof ye<"u"){for(;typeof ye<"u"&&(typeof g>"u"||X<g);){R+=n.substring(q,ye.start);var Ce=_.apply(p,[ye]);if(ae(Ce)&&(Ce=await Ce),typeof Ce=="string")R+=Ce;else throw{code:"D3012",stack:new Error().stack,value:Ce};q=ye.start+ye.match.length,X++,ye=await fe(ye.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 de(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 fe(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 fe(_.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(re){p[re]=l[re]});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 ye=function(re){var Me=(function(){for(var Le,nt=0;nt<re.length;nt++)if(Le=re.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return re.substring(0,nt)})(),Ye=(function(){for(var Le,nt=re.length-1;nt>=0;nt--)if(Le=re.charAt(nt),X.indexOf(Le)!==-1&&Le!==p["exponent-separator"])return re.substring(nt+1)})(),Ne=re.substring(Me.length,re.length-Ye.length),Xe,Dt,Qe,It,rt=re.indexOf(p["exponent-separator"],Me.length);rt===-1||rt>re.length-Ye.length?(Xe=Ne,Dt=void 0):(Xe=Ne.substring(0,rt),Dt=Ne.substring(rt+1));var lt=Xe.indexOf(p["decimal-separator"]);return lt===-1?(Qe=Xe,It=Ye):(Qe=Xe.substring(0,lt),It=Xe.substring(lt+1)),{prefix:Me,suffix:Ye,activePart:Ne,mantissaPart:Xe,exponentPart:Dt,integerPart:Qe,fractionalPart:It,subpicture:re}},Ce=function(re){var Me,Ye,Ne=re.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 Dt=!1;for(Ye=0;Ye<re.mantissaPart.length;Ye++){var Qe=re.mantissaPart.charAt(Ye);if(_.indexOf(Qe)!==-1||Qe===p.digit){Dt=!0;break}}Dt||(Me="D3085");var It=re.activePart.split("").map(function(Le){return X.indexOf(Le)===-1?"p":"a"}).join("");It.indexOf("p")!==-1&&(Me="D3086"),Xe!==-1?(Ne.charAt(Xe-1)===p["grouping-separator"]||Ne.charAt(Xe+1)===p["grouping-separator"])&&(Me="D3087"):re.integerPart.charAt(re.integerPart.length-1)===p["grouping-separator"]&&(Me="D3088"),Ne.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Me="D3089");var rt=re.integerPart.indexOf(p.digit);rt!==-1&&re.integerPart.substring(0,rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3090"),rt=re.fractionalPart.lastIndexOf(p.digit),rt!==-1&&re.fractionalPart.substring(rt).split("").filter(function(Le){return _.indexOf(Le)>-1}).length>0&&(Me="D3091");var lt=typeof re.exponentPart=="string";if(lt&&re.exponentPart.length>0&&(Ne.indexOf(p.percent)!==-1||Ne.indexOf(p["per-mille"])!==-1)&&(Me="D3092"),lt&&(re.exponentPart.length===0||re.exponentPart.split("").filter(function(Le){return _.indexOf(Le)===-1}).length>0)&&(Me="D3093"),Me)throw{code:Me,stack:new Error().stack}},Se=function(re){var Me=function(Ve,wr){for(var er=[],kt=Ve.indexOf(p["grouping-separator"]);kt!==-1;){var br=(wr?Ve.substring(0,kt):Ve.substring(kt)).split("").filter(function(zt){return _.indexOf(zt)!==-1||zt===p.digit}).length;er.push(br),kt=re.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Me(re.integerPart),Ne=function(Ve){if(Ve.length===0)return 0;for(var wr=function(br,zt){return zt===0?br:wr(zt,br%zt)},er=Ve.reduce(wr),kt=1;kt<=Ve.length;kt++)if(Ve.indexOf(kt*er)===-1)return 0;return er},Xe=Ne(Ye),Dt=Me(re.fractionalPart,!0),Qe=re.integerPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length,It=Qe,rt=re.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 re.exponentPart=="string";Qe===0&&Le===0&&(nt?(lt=1,Le=1):Qe=1),nt&&Qe===0&&re.integerPart.indexOf(p.digit)!==-1&&(Qe=1),Qe===0&<===0&&(lt=1);var dn=0;return nt&&(dn=re.exponentPart.split("").filter(function(Ve){return _.indexOf(Ve)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Xe,minimumIntegerPartSize:Qe,scalingFactor:It,prefix:re.prefix,fractionalPartGroupingPositions:Dt,minimumFactionalPartSize:lt,maximumFactionalPartSize:Le,minimumExponentSize:dn,suffix:re.suffix,picture:re.subpicture}},We=Oe.map(ye);We.forEach(Ce);var ke=We.map(Se),je=p["minus-sign"],ot=p["zero-digit"],ze=p["decimal-separator"],Zt=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 Mt,Wt;if(Be.minimumExponentSize===0)Mt=Xt;else{var Cn=Math.pow(10,Be.scalingFactor),Nn=Math.pow(10,Be.scalingFactor-1);for(Mt=Xt,Wt=0;Mt<Nn;)Mt*=10,Wt-=1;for(;Mt>Cn;)Mt/=10,Wt+=1}var Rn=F(Mt,Be.maximumFactionalPartSize),ln=function(re,Me){var Ye=Math.abs(re).toFixed(Me);return ot!=="0"&&(Ye=Ye.split("").map(function(Ne){return Ne>="0"&&Ne<="9"?_[Ne.charCodeAt(0)-48]:Ne}).join("")),Ye},ce=ln(Rn,Be.maximumFactionalPartSize),Ge=ce.indexOf(".");for(Ge===-1?ce=ce+ze:ce=ce.replace(".",ze);ce.charAt(0)===ot;)ce=ce.substring(1);for(;ce.charAt(ce.length-1)===ot;)ce=ce.substring(0,ce.length-1);Ge=ce.indexOf(ze);var Qt=Be.minimumIntegerPartSize-Ge,fn=Be.minimumFactionalPartSize-(ce.length-Ge-1);if(ce=(Qt>0?new Array(Qt+1).join(ot):"")+ce,ce=ce+(fn>0?new Array(fn+1).join(ot):""),Ge=ce.indexOf(ze),Be.regularGrouping>0)for(var Mn=Math.floor((Ge-1)/Be.regularGrouping),gr=1;gr<=Mn;gr++)ce=[ce.slice(0,Ge-gr*Be.regularGrouping),Zt,ce.slice(Ge-gr*Be.regularGrouping)].join("");else Be.integerPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,Ge-re),Zt,ce.slice(Ge-re)].join(""),Ge++});if(Ge=ce.indexOf(ze),Be.fractionalPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,re+Ge+1),Zt,ce.slice(re+Ge+1)].join("")}),Ge=ce.indexOf(ze),(Be.picture.indexOf(ze)===-1||Ge===ce.length-1)&&(ce=ce.substring(0,ce.length-1)),typeof Wt<"u"){var vr=ln(Wt,0);Qt=Be.minimumExponentSize-vr.length,Qt>0&&(vr=new Array(Qt+1).join(ot)+vr),ce=ce+p["exponent-separator"]+(Wt<0?je:"")+vr}return ce=Be.prefix+ce+Be.suffix,ce}}function b(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 O(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 ge(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 be(){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):w(n)?n!==0&&(o=!0):n!==null&&typeof n=="object"&&!S(n)?Object.keys(n).length>0&&(o=!0):typeof n=="boolean"&&n===!0&&(o=!0);return o}}function ee(n){if(!(typeof n>"u"))return!K(n)}function me(n,o,l,g){var p=[o],_=Q(n);return _>=2&&p.push(l),_>=3&&p.push(g),p}async function G(n,o){if(!(typeof n>"u")){for(var l=D(),g=0;g<n.length;g++){var p=me(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=D(),g=0;g<n.length;g++){var p=n[g],_=me(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=me(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=Q(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=D();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"&&!S(n)&&Object.keys(n).forEach(g=>o.push(g));return o}function bt(n,o){var l;if(Array.isArray(n)){l=D();for(var g=0;g<n.length;g++){var p=bt(n[g],o);typeof p<"u"&&(Array.isArray(p)?p.forEach(_=>l.push(_)):l.push(p))}}else n!==null&&typeof n=="object"&&!S(n)&&(l=n[o]);return l}function At(n,o){return typeof n>"u"?o:typeof o>"u"?n:(Array.isArray(n)||(n=D(n)),Array.isArray(o)||(o=[o]),n.concat(o))}function mr(n){return!(typeof n>"u")}function St(n){var o=D();if(Array.isArray(n))n.forEach(function(p){o=At(o,St(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=D();for(var g in n){var p=me(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 Lt(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":w(n)?"number":typeof n=="string"?"string":typeof n=="boolean"?"boolean":Array.isArray(n)?"array":S(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(ye,Ce,Se){Ce.length===0?Array.prototype.push.apply(ye,Se):Se.length===0?Array.prototype.push.apply(ye,Ce):await l(Ce[0],Se[0])?(ye.push(Se[0]),await X(ye,Ce,Se.slice(1))):(ye.push(Ce[0]),await X(ye,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)?D():[],l=0;l<n.length;l++){for(var g=n[l],p=!1,_=0;_<o.length;_++)if(pe(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],_=me(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:se,max:L,min:E,average:$,string:z,substring:he,substringBefore:xe,substringAfter:Te,lowercase:Ae,uppercase:ve,length:Re,trim:et,pad:_e,match:ie,contains:tt,replace:Fe,split:Ee,join:v,formatNumber:A,formatBase:b,number:C,floor:j,ceil:O,round:F,abs:B,sqrt:J,power:ge,random:be,boolean:K,not:ee,map:G,zip:qe,filter:Ze,single:it,foldLeft:$e,sift:y,keys:He,lookup:bt,append:At,exists:mr,spread:St,merge:Z,reverse:yr,each:Jt,error:ut,assert:Lt,type:yt,sort:De,shuffle:u,distinct:h,base64encode:st,base64decode:d,encodeUrlComponent:m,encodeUrl:V,decodeUrlComponent:de,decodeUrl:Pe}})();a.exports=f}).call(this)}).call(this,typeof gn<"u"?gn: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"),w=t("./parser"),k=t("./signature"),M=(function(){var D=f.isNumeric,x=f.isArrayOfStrings,S=f.isArrayOfNumbers,I=f.createSequence,ae=f.isSequence,Q=f.isFunction,pe=f.isLambda,H=f.isIterable,N=f.isPromise,se=f.getFunctionArity,L=f.isDeepEqual,E=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=fe(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 O(u,h,y);break;case"bind":n=await B(u,h,y);break;case"regex":n=F(u);break;case"function":n=await me(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 ee(u,h,y);break;case"transform":n=be(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&&ae(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 he(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 ge(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])&&!ae(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 ge(u,y,n);else{var l=await ge(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++){_=he(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=he(y,l));var _=await $(u,g,p);D(_)&&(_=[_]),S(_)?_.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=de(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(D(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 fe(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=ie(o),y=c.append(y,o)):y.push(o)}),y}function ie(u,h){return typeof h>"u"&&(h=[]),Array.isArray(u)?u.forEach(function(y){ie(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"&&!D(u))throw{code:"T2001",stack:new Error().stack,value:u};if(typeof h<"u"&&!D(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 de(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?he(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 ye=await Promise.all(Object.keys(o).map(async(Se,We)=>{let ke=o[Se];var je=ke.data,ot=y;if(l){var ze=b(ke.data);je=ze["@"],delete ze["@"],ot=he(y,ze)}return y.isParallelCall=We>0,[Se,await $(u.lhs[ke.exprIndex][1],je,ot)]}));for(let Se of ye){var[X,Ce]=await Se;typeof Ce<"u"&&(n[X]=Ce)}return n}function b(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 O(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 ge(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],ye=_,Ce=y;l&&(ye=_["@"],Ce=he(y,_));var Se=await $(Oe.expression,ye,Ce);ye=R,Ce=y,l&&(ye=R["@"],Ce=he(y,R));var We=await $(Oe.expression,ye,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 be(u,h,y){var n=async function(o){if(!(typeof o>"u")){var l=y.lookup("clone");if(!Q(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 ye=await $(u.delete,R,y);if(typeof ye<"u"){var Ce=ye;if(Array.isArray(ye)||(ye=[ye]),!x(ye))throw{code:"T2012",stack:new Error().stack,position:u.delete.position,value:Ce};for(var Se=0;Se<ye.length;Se++)typeof R=="object"&&R!==null&&delete R[ye[Se]]}}}}return g}};return Z(n,"<(oa):o>")}var K=w("function($f, $g) { function($x){ $g($f($x)) } }");async function ee(u,h,y){var n,o=await $(u.lhs,h,y);if(u.rhs.type==="function")n=await me(u.rhs,h,y,{context:o});else{var l=await $(u.rhs,h,y);if(!Q(l))throw{code:"T2006",stack:new Error().stack,position:u.position,value:l};if(Q(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 me(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(Q(R)){const q=async function(...X){return await G(R,X,null,y)};q.arity=se(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);pe(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)),pe(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(pe(p))n=bt(p,o);else if(p&&p._jsonata_function===!0)n=At(p.implementation,o);else if(typeof p=="function")n=At(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 bt(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 At(u,h){var y=St(u);y=y.map(function(g){return"$"+g.trim()});var n="function("+y.join(", ")+"){ _ }",o=w(n);o.body=u;var l=bt(o,h);return l}async function mr(u,h){var y=St(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 St(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)&&!ae(y)&&(y=I(y),y.outerWrapper=!0));try{var n=w(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}E.bind("sum",Z(c.sum,"<a<n>:n>")),E.bind("count",Z(c.count,"<a:n>")),E.bind("max",Z(c.max,"<a<n>:n>")),E.bind("min",Z(c.min,"<a<n>:n>")),E.bind("average",Z(c.average,"<a<n>:n>")),E.bind("string",Z(c.string,"<x-b?:s>")),E.bind("substring",Z(c.substring,"<s-nn?:s>")),E.bind("substringBefore",Z(c.substringBefore,"<s-s:s>")),E.bind("substringAfter",Z(c.substringAfter,"<s-s:s>")),E.bind("lowercase",Z(c.lowercase,"<s-:s>")),E.bind("uppercase",Z(c.uppercase,"<s-:s>")),E.bind("length",Z(c.length,"<s-:n>")),E.bind("trim",Z(c.trim,"<s-:s>")),E.bind("pad",Z(c.pad,"<s-ns?:s>")),E.bind("match",Z(c.match,"<s-f<s:o>n?:a<o>>")),E.bind("contains",Z(c.contains,"<s-(sf):b>")),E.bind("replace",Z(c.replace,"<s-(sf)(sf)n?:s>")),E.bind("split",Z(c.split,"<s-(sf)n?:a<s>>")),E.bind("join",Z(c.join,"<a<s>s?:s>")),E.bind("formatNumber",Z(c.formatNumber,"<n-so?:s>")),E.bind("formatBase",Z(c.formatBase,"<n-n?:s>")),E.bind("formatInteger",Z(i.formatInteger,"<n-s:s>")),E.bind("parseInteger",Z(i.parseInteger,"<s-s:n>")),E.bind("number",Z(c.number,"<(nsb)-:n>")),E.bind("floor",Z(c.floor,"<n-:n>")),E.bind("ceil",Z(c.ceil,"<n-:n>")),E.bind("round",Z(c.round,"<n-n?:n>")),E.bind("abs",Z(c.abs,"<n-:n>")),E.bind("sqrt",Z(c.sqrt,"<n-:n>")),E.bind("power",Z(c.power,"<n-n:n>")),E.bind("random",Z(c.random,"<:n>")),E.bind("boolean",Z(c.boolean,"<x-:b>")),E.bind("not",Z(c.not,"<x-:b>")),E.bind("map",Z(c.map,"<af>")),E.bind("zip",Z(c.zip,"<a+>")),E.bind("filter",Z(c.filter,"<af>")),E.bind("single",Z(c.single,"<af?>")),E.bind("reduce",Z(c.foldLeft,"<afj?:j>")),E.bind("sift",Z(c.sift,"<o-f?:o>")),E.bind("keys",Z(c.keys,"<x-:a<s>>")),E.bind("lookup",Z(c.lookup,"<x-s:x>")),E.bind("append",Z(c.append,"<xx:a>")),E.bind("exists",Z(c.exists,"<x:b>")),E.bind("spread",Z(c.spread,"<x-:a<o>>")),E.bind("merge",Z(c.merge,"<a<o>:o>")),E.bind("reverse",Z(c.reverse,"<a:a>")),E.bind("each",Z(c.each,"<o-f:a>")),E.bind("error",Z(c.error,"<s?:x>")),E.bind("assert",Z(c.assert,"<bs?:x>")),E.bind("type",Z(c.type,"<x:s>")),E.bind("sort",Z(c.sort,"<af?:a>")),E.bind("shuffle",Z(c.shuffle,"<a:a>")),E.bind("distinct",Z(c.distinct,"<x:x>")),E.bind("base64encode",Z(c.base64encode,"<s-:s>")),E.bind("base64decode",Z(c.base64decode,"<s-:s>")),E.bind("encodeUrlComponent",Z(c.encodeUrlComponent,"<s-:s>")),E.bind("encodeUrl",Z(c.encodeUrl,"<s-:s>")),E.bind("decodeUrlComponent",Z(c.decodeUrlComponent,"<s-:s>")),E.bind("decodeUrl",Z(c.decodeUrl,"<s-:s>")),E.bind("eval",Z(yr,"<sx?:x>")),E.bind("toMillis",Z(i.toMillis,"<s-s?:n>")),E.bind("fromMillis",Z(i.fromMillis,"<n-s?s?:s>")),E.bind("clone",Z(Jt,"<(oa)-:o>"));var Lt={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=Lt[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=w(u,h&&h.recover),n=y.errors,delete y.errors}catch(g){throw yt(g),g}var o=ut(E),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)&&!ae(g)&&(g=I(g),g.outerWrapper=!0);var Oe;try{return Oe=await $(y,g,q),typeof _=="function"&&_(null,Oe),Oe}catch(ye){throw yt(ye),ye}},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=w,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},w={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" "},k=function(D){var x=0,S=D.length,I=function(pe,H){var N={type:pe,value:H,position:x};return N},ae=function(){for(var pe=x,H=0,N,se,L=function($){if(D.charAt($)==="/"&&H===0){for(var z=0;D.charAt($-(z+1))==="\\";)z++;if(z%2===0)return!0}return!1};x<S;){var E=D.charAt(x);if(L(x)){if(N=D.substring(pe,x),N==="")throw{code:"S0301",stack:new Error().stack,position:x};for(x++,E=D.charAt(x),pe=x;E==="i"||E==="m";)x++,E=D.charAt(x);return se=D.substring(pe,x)+"g",new RegExp(N,se)}(E==="("||E==="["||E==="{")&&D.charAt(x-1)!=="\\"&&H++,(E===")"||E==="]"||E==="}")&&D.charAt(x-1)!=="\\"&&H--,x++}throw{code:"S0302",stack:new Error().stack,position:x}},Q=function(pe){if(x>=S)return null;for(var H=D.charAt(x);x<S&&`
|
|
3
|
+
\r\v`.indexOf(H)>-1;)x++,H=D.charAt(x);if(H==="/"&&D.charAt(x+1)==="*"){var N=x;for(x+=2,H=D.charAt(x);!(H==="*"&&D.charAt(x+1)==="/");)if(H=D.charAt(++x),x>=S)throw{code:"S0106",stack:new Error().stack,position:N};return x+=2,H=D.charAt(x),Q(pe)}if(pe!==!0&&H==="/")return x++,I("regex",ae());if(H==="."&&D.charAt(x+1)===".")return x+=2,I("operator","..");if(H===":"&&D.charAt(x+1)==="=")return x+=2,I("operator",":=");if(H==="!"&&D.charAt(x+1)==="=")return x+=2,I("operator","!=");if(H===">"&&D.charAt(x+1)==="=")return x+=2,I("operator",">=");if(H==="<"&&D.charAt(x+1)==="=")return x+=2,I("operator","<=");if(H==="*"&&D.charAt(x+1)==="*")return x+=2,I("operator","**");if(H==="~"&&D.charAt(x+1)===">")return x+=2,I("operator","~>");if(H==="?"&&D.charAt(x+1)===":")return x+=2,I("operator","?:");if(H==="?"&&D.charAt(x+1)==="?")return x+=2,I("operator","??");if(Object.prototype.hasOwnProperty.call(f,H))return x++,I("operator",H);if(H==='"'||H==="'"){var se=H;x++;for(var L="";x<S;){if(H=D.charAt(x),H==="\\")if(x++,H=D.charAt(x),Object.prototype.hasOwnProperty.call(w,H))L+=w[H];else if(H==="u"){var E=D.substr(x+1,4);if(/^[0-9a-fA-F]+$/.test(E)){var $=parseInt(E,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===se)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]+)?/,he=z.exec(D.substring(x));if(he!==null){var xe=parseFloat(he[0]);if(!isNaN(xe)&&isFinite(xe))return x+=he[0].length,I("number",xe);throw{code:"S0102",stack:new Error().stack,position:x,token:he[0]}}var Te;if(H==="`"){x++;var Ae=D.indexOf("`",x);if(Ae!==-1)return Te=D.substring(x,Ae),x=Ae+1,I("name",Te);throw x=S,{code:"S0105",stack:new Error().stack,position:x}}for(var ve=x,Re;;)if(Re=D.charAt(ve),ve===S||`
|
|
4
|
+
\r\v`.indexOf(Re)>-1||Object.prototype.hasOwnProperty.call(f,Re)){if(D.charAt(x)==="$")return Te=D.substring(x+1,ve),x=ve,I("variable",Te);switch(Te=D.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===S&&Te===""?null:I("name",Te)}}else ve++};return Q},M=function(D,x){var S,I,ae={},Q=[],pe=function(){var d=[];S.id!=="(end)"&&d.push({type:S.type,value:S.value,position:S.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=pe(),d.type="error",Q.push(d),d;throw d.stack=new Error().stack,d}},N=function(d,m){var V=ae[d];return m=m||0,V?m>=V.lbp&&(V.lbp=m):(V=Object.create(H),V.id=V.value=d,V.lbp=m,ae[d]=V),V},se=function(d){if(x){d.remaining=pe(),Q.push(d);var m=ae["(error)"];return S=Object.create(m),S.error=d,S.type="(error)",S}else throw d.stack=new Error().stack,d},L=function(d,m){if(d&&S.id!==d){var V;S.id==="(end)"?V="S0203":V="S0202";var de={code:V,position:S.position,token:S.value,value:d};return se(de)}var Pe=I(m);if(Pe===null)return S=ae["(end)"],S.position=D.length,S;var Ee=Pe.value,v=Pe.type,A;switch(v){case"name":case"variable":A=ae["(name)"];break;case"operator":if(A=ae[Ee],!A)return se({code:"S0204",stack:new Error().stack,position:Pe.position,token:Ee});break;case"string":case"number":case"value":A=ae["(literal)"];break;case"regex":v="regex",A=ae["(regex)"];break;default:return se({code:"S0205",stack:new Error().stack,position:Pe.position,token:Ee})}return S=Object.create(A),S.value=Ee,S.type=v,S.position=Pe.position,S},E=function(d){var m,V=S;for(L(null,!0),m=V.nud();d<S.lbp;)V=S,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 de=m||f[d],Pe=N(d,de);return Pe.led=V||function(Ee){return this.lhs=Ee,this.rhs=E(de),this.type="binary",this},Pe},he=function(d,m,V){var de=N(d,m);return de.led=V,de},xe=function(d,m){var V=N(d);return V.nud=m||function(){return this.expression=E(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=E(0),this}),he("(error)",10,function(d){return this.lhs=d,this.error=S.error,this.remaining=pe(),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=[],S.id!==")")for(;S.type==="operator"&&S.id==="?"?(this.type="partial",this.arguments.push(S),L("?")):this.arguments.push(E(0)),S.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 se({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:v+1})}),this.type="lambda",S.id==="<"){for(var m=S.position,V=1,de="<";V>0&&S.id!=="{"&&S.id!=="(end)";){var Pe=L();Pe.id===">"?V--:Pe.id==="<"&&V++,de+=Pe.value}L(">");try{this.signature=i(de)}catch(Ee){return Ee.position=m+Ee.offset,se(Ee)}}L("{"),this.body=E(0),L("}")}return this}),xe("(",function(){for(var d=[];S.id!==")"&&(d.push(E(0)),S.id===";");)L(";");return L(")",!0),this.type="block",this.expressions=d,this}),xe("[",function(){var d=[];if(S.id!=="]")for(;;){var m=E(0);if(S.id===".."){var V={type:"binary",value:"..",position:S.position,lhs:m};L(".."),V.rhs=E(0),m=V}if(d.push(m),S.id!==",")break;L(",")}return L("]",!0),this.expressions=d,this.type="unary",this}),z("[",f["["],function(d){if(S.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=E(f["]"]),this.type="binary",L("]",!0),this}),z("^",f["^"],function(d){L("(");for(var m=[];;){var V={descending:!1};if(S.id==="<"?L("<"):S.id===">"&&(V.descending=!0,L(">")),V.expression=E(0),m.push(V),S.id!==",")break;L(",")}return L(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Te=function(d){var m=[];if(S.id!=="}")for(;;){var V=E(0);L(":");var de=E(0);if(m.push([V,de]),S.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),he(":=",f[":="],function(d){return d.type!=="variable"?se({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=E(f[":="]-1),this.type="binary",this)}),z("@",f["@"],function(d){return this.lhs=d,this.rhs=E(f["@"]),this.rhs.type!=="variable"?se({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=E(f["#"]),this.rhs.type!=="variable"?se({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=E(0),S.id===":"&&(L(":"),this.else=E(0)),this}),z("?:",f["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=E(0),this}),xe("|",function(){return this.type="transform",this.pattern=E(0),L("|"),this.update=E(0),S.id===","&&(L(","),this.delete=E(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 de=d.expressions.length;de>0&&(d.expressions[de-1]=Ae(d.expressions[de-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},fe=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],de=typeof V.seekingParent<"u"?V.seekingParent:[];V.type==="parent"&&de.push(V.slot);for(var Pe=0;Pe<de.length;Pe++){var Ee=de[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)}}},ie=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var V=ie(d.lhs);V.type==="path"?m=V:m={type:"path",steps:[V]},V.type==="parent"&&(m.seekingParent=[V.slot]);var de=ie(d.rhs);de.type==="function"&&de.procedure.type==="path"&&de.procedure.steps.length===1&&de.procedure.steps[0].type==="name"&&m.steps[m.steps.length-1].type==="function"&&(m.steps[m.steps.length-1].nextFunction=de.procedure.steps[0].value),de.type==="path"?Array.prototype.push.apply(m.steps,de.steps):(typeof de.predicate<"u"&&(de.stages=de.predicate,delete de.predicate),m.steps.push(de)),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=ie(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 b=ie(d.rhs);typeof b.seekingParent<"u"&&(b.seekingParent.forEach(F=>{F.level===1?_e(v,F):F.level--}),fe(v,b)),v[A].push({type:"filter",expr:b,position:d.position});break;case"{":if(m=ie(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[ie(F[0]),ie(F[1])]}),position:d.position};break;case"^":m=ie(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=ie(F.expression);return fe(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=ie(d.lhs),m.rhs=ie(d.rhs),fe(m,m.rhs);break;case"@":if(m=ie(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=ie(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=ie(d.lhs),m.rhs=ie(d.rhs),m.keepArray=m.lhs.keepArray||m.rhs.keepArray;break;default:m={type:d.type,value:d.value,position:d.position},m.lhs=ie(d.lhs),m.rhs=ie(d.rhs),fe(m,m.lhs),fe(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=ie(F);return fe(m,J),J}):d.value==="{"?m.lhs=d.lhs.map(function(F){var J=ie(F[0]);fe(m,J);var ge=ie(F[1]);return fe(m,ge),[J,ge]}):(m.expression=ie(d.expression),d.value==="-"&&m.expression.type==="number"?(m=m.expression,m.value=-m.value):fe(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=ie(F);return fe(m,J),J}),m.procedure=ie(d.procedure);break;case"lambda":m={type:d.type,arguments:d.arguments,signature:d.signature,position:d.position};var B=ie(d.body);m.body=Ae(B);break;case"condition":m={type:d.type,position:d.position},m.condition=ie(d.condition),fe(m,m.condition),m.then=ie(d.then),fe(m,m.then),typeof d.else<"u"&&(m.else=ie(d.else),fe(m,m.else));break;case"transform":m={type:d.type,position:d.position},m.pattern=ie(d.pattern),m.update=ie(d.update),typeof d.delete<"u"&&(m.delete=ie(d.delete));break;case"block":m={type:d.type,position:d.position},m.expressions=d.expressions.map(function(F){var J=ie(F);return fe(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=ie(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=ie(d.lhs));break;default:var j="S0206";d.id==="(end)"&&(j="S0207");var O={code:j,position:d.position,token:d.value};if(x)return Q.push(O),{type:"error",error:O};throw O.stack=new Error().stack,O}return d.keepArray&&(m.keepArray=!0),m};I=k(D),L();var Fe=E(0);if(S.id!=="(end)"){var st={code:"S0201",position:S.position,token:S.value};se(st)}if(Fe=ie(Fe),Fe.type==="parent"||typeof Fe.seekingParent<"u")throw{code:"S0217",token:Fe.type,position:Fe.position};return Q.length>0&&(Fe.errors=Q),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 w(k){for(var M=1,D=[],x={},S=x;M<k.length;){var I=k.charAt(M);if(I===":")break;var ae=function(){D.push(x),S=x,x={}},Q=function(z,he,xe,Te){for(var Ae=1,ve=he;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,ae();break;case"a":x.regex="[asnblfom]",x.type=I,x.array=!0,ae();break;case"f":x.regex="f",x.type=I,ae();break;case"j":x.regex="[asnblom]",x.type=I,ae();break;case"x":x.regex="[asnblfom]",x.type=I,ae();break;case"-":S.context=!0,S.contextRegex=new RegExp(S.regex),S.regex+="?";break;case"?":case"+":S.regex+=I;break;case"(":var pe=Q(k,M,"(",")"),H=k.substring(M+1,pe);if(H.indexOf("<")===-1)x.regex="["+H+"m]";else throw{code:"S0402",stack:new Error().stack,value:H,offset:M};x.type="("+H+")",M=pe,ae();break;case"<":if(S.type==="a"||S.type==="f"){var N=Q(k,M,"<",">");S.subtype=k.substring(M+1,N),M=N}else throw{code:"S0401",stack:new Error().stack,value:S.type,offset:M};break}M++}var se="^"+D.map(function(z){return"("+z.regex+")"}).join("")+"$",L=new RegExp(se),E=function(z){var he;if(i.isFunction(z))he="f";else{var xe=typeof z;switch(xe){case"string":he="s";break;case"number":he="n";break;case"boolean":he="b";break;case"object":z===null?he="l":Array.isArray(z)?he="a":he="o";break;case"undefined":default:he="m"}}return he},$=function(z,he){for(var xe="^",Te=0,Ae=0;Ae<D.length;Ae++){xe+=D[Ae].regex;var ve=he.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,he){var xe="";z.forEach(function(Re){xe+=E(Re)});var Te=L.exec(xe);if(Te){var Ae=[],ve=0;return D.forEach(function(Re,et){var _e=z[ve],fe=Te[et+1];if(fe==="")if(Re.context&&Re.contextRegex){var tt=E(he);if(Re.contextRegex.test(tt))Ae.push(he);else throw{code:"T0411",stack:new Error().stack,value:he,index:ve+1}}else Ae.push(_e),ve++;else fe.split("").forEach(function(ie){if(Re.type==="a"){if(ie==="m")_e=void 0;else{_e=z[ve];var Fe=!0;if(typeof Re.subtype<"u"){if(ie!=="a"&&fe!==Re.subtype)Fe=!1;else if(ie==="a"&&_e.length>0){var st=E(_e[0]);if(st!==Re.subtype.charAt(0))Fe=!1;else{var d=_e.filter(function(m){return E(m)!==st});Fe=d.length===0}}}if(!Fe)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:f[Re.subtype]};ie!=="a"&&(_e=[_e])}Ae.push(_e),ve++}else Ae.push(_e),ve++})}),Ae}$(z,xe)}}}return w})();a.exports=c},{"./utils":6}],6:[function(t,a,s){const i=(()=>{function c(N){var se=!1;if(typeof N=="number"&&(se=!isNaN(N),se&&!isFinite(N)))throw{code:"D1001",value:N,stack:new Error().stack};return se}function f(N){var se=!1;return Array.isArray(N)&&(se=N.filter(function(L){return typeof L!="string"}).length===0),se}function w(N){var se=!1;return Array.isArray(N)&&(se=N.filter(function(L){return!c(L)}).length===0),se}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 D(N){return N&&(N._jsonata_function===!0||N._jsonata_lambda===!0)||typeof N=="function"}function x(N){var se=typeof N.arity=="number"?N.arity:typeof N.implementation=="function"?N.implementation.length:typeof N.length=="number"?N.length:N.arguments.length;return se}function S(N){return N&&N._jsonata_lambda===!0}var I=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function ae(N){return typeof N=="object"&&N!==null&&I in N&&"next"in N&&typeof N.next=="function"}function Q(N,se){if(N===se)return!0;if(typeof N=="object"&&typeof se=="object"&&N!==null&&se!==null){if(Array.isArray(N)&&Array.isArray(se)){if(N.length!==se.length)return!1;for(var L=0;L<N.length;L++)if(!Q(N[L],se[L]))return!1;return!0}var E=Object.getOwnPropertyNames(N),$=Object.getOwnPropertyNames(se);if(E.length!==$.length)return!1;for(E=E.sort(),$=$.sort(),L=0;L<E.length;L++)if(E[L]!==$[L])return!1;for(L=0;L<E.length;L++){var z=E[L];if(!Q(N[z],se[z]))return!1}return!0}return!1}function pe(N){return typeof N=="object"&&N!==null&&"then"in N&&typeof N.then=="function"}function H(N){var se=[];for(let L of N)se.push(L);return se}return{isNumeric:c,isArrayOfStrings:f,isArrayOfNumbers:w,createSequence:k,isSequence:M,isFunction:D,isLambda:S,isIterable:ae,getFunctionArity:x,isDeepEqual:Q,stringToArray:H,isPromise:pe}})();a.exports=i},{}]},{},[3])(3)})})(Rr)),Rr.exports}var Hs=qs();const Gs=Vs(Hs),sn=T.object({name:T.literal("transform-data"),sourceData:T.any().optional(),expression:T.string().min(1,"JSONata expression is required")});function Ys(r){return sn.parse(r)}async function Ks(r){try{const{sourceData:e,expression:t}=r,a=e??{};let s;try{s=Gs(t)}catch(c){throw new Error(`Invalid JSONata expression: ${c instanceof Error?c.message:"Unknown error"}`)}let i;try{i=await s.evaluate(a)}catch(c){throw console.error("JSONata evaluation failed:",c),new Error(`JSONata evaluation failed: ${c instanceof Error?c.message:"Unknown error"}`)}return{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in transform-data handler",data:null}}}const on=T.object({name:T.literal("export-data"),data:T.any(),format:T.enum(["json","csv","xlsx"]),filename:T.string().optional(),csvOptions:T.object({delimiter:T.string().optional(),includeHeaders:T.boolean().optional()}).optional()});function Js(r){return on.parse(r)}async function Xs(r){try{const{data:e,format:t,filename:a,csvOptions:s}=r;console.log("[ExportDataBlock] Sending export request to background:",t);const i=await chrome.runtime.sendMessage({type:"EXPORT_DATA",data:{data:e,format:t,filename:a,csvOptions:s}});return i.$isError?{hasError:!0,message:i.message||"Export failed",data:void 0}:(console.log("[ExportDataBlock] Export successful:",i.data.filename),{data:i.data})}catch(e){return console.error("[ExportDataBlock] Export error:",e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in export-data handler",data:void 0}}}const cn=T.object({name:T.literal("network-catch"),urlPattern:T.string().optional(),method:T.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),status:T.union([T.number(),T.object({min:T.number().optional(),max:T.number().optional()})]).optional(),mimeType:T.string().optional(),waitForRequest:T.boolean().optional(),waitTimeout:T.number().min(0).optional(),returnAll:T.boolean().optional(),includeHeaders:T.boolean().optional()});function Qs(r){return cn.parse(r)}async function ei(r){try{console.log("[NetworkCatchBlock] Fetching network requests with pattern:",r.urlPattern);const e=await chrome.runtime.sendMessage({type:"NETWORK_CATCH",data:{urlPattern:r.urlPattern,method:r.method,status:r.status,mimeType:r.mimeType,waitForRequest:r.waitForRequest||!1,waitTimeout:r.waitTimeout||5e3,returnAll:r.returnAll||!1,includeHeaders:r.includeHeaders||!1}});return e.$isError?{hasError:!0,message:e.message||"Failed to fetch network data",data:void 0}:(console.log("[NetworkCatchBlock] Retrieved network data:",e.data),{data:e.data})}catch(e){return console.error("[NetworkCatchBlock] Error:",e),{hasError:!0,message:e instanceof Error?e.message:"Failed to fetch network data"}}}const ti={"get-text":zr,"attribute-value":Vr,"get-value-form":qr,"set-value-form":Hr,"clear-value-form":Gr,"element-exists":Yr,"event-click":Kr,keypress:Jr,wait:Xr,"wait-for-condition":Qr,navigate:en,"save-assets":tn,"get-element-data":rn,scroll:nn,"ai-parse-data":Wr,"fetch-api":an,"transform-data":sn,"export-data":on,"network-catch":cn};class ri{static async executeBlock(e){try{switch(e.name){case"get-text":{const t=ts(e);return await rs(t)}case"attribute-value":{const t=as(e);return await ss(t)}case"get-value-form":{const t=is(e);return await os(t)}case"set-value-form":{const t=us(e);return await ls(t)}case"clear-value-form":{const t=ds(e);return await hs(t)}case"element-exists":{const t=ms(e);return await ys(t)}case"event-click":{const t=gs(e);return await vs(t)}case"keypress":{const t=xs(e);return await _s(t)}case"wait":{const t=Ts(e);return await As(t)}case"wait-for-condition":{const t=Ss(e);return await Ds(t)}case"navigate":{const t=Os(e);return await Ps(t)}case"save-assets":{const t=Cs(e);return await Ns(t)}case"get-element-data":{const t=Ms(e);return await Is(t)}case"scroll":{const t=Fs(e);return await Bs(t)}case"ai-parse-data":{const t=za(e);return await Va(t)}case"fetch-api":{const t=Ws(e);return await zs(t)}case"transform-data":{const t=Ys(e);return await Ks(t)}case"export-data":{const t=Js(e);return await Xs(t)}case"network-catch":{const t=Qs(e);return await ei(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 ni{constructor(){ue(this,"expr");ue(this,"json")}}class ai{constructor(){ue(this,"template");ue(this,"valueFrom");ue(this,"default")}}class si{constructor(){ue(this,"id");ue(this,"title");ue(this,"when");ue(this,"block");ue(this,"repeat");ue(this,"next");ue(this,"onSuccess");ue(this,"onFailure");ue(this,"switch");ue(this,"timeoutMs");ue(this,"retry");ue(this,"delayAfterMs")}}class ii{constructor(){ue(this,"version");ue(this,"id");ue(this,"title");ue(this,"description");ue(this,"start");ue(this,"steps");ue(this,"vars");ue(this,"defaultDelayMs")}}class oi{constructor(){ue(this,"stepId");ue(this,"skipped");ue(this,"success");ue(this,"message");ue(this,"result");ue(this,"startedAt");ue(this,"finishedAt");ue(this,"attempts")}}class ci{constructor(){ue(this,"success");ue(this,"steps");ue(this,"context");ue(this,"targetUrl");ue(this,"timestamp");ue(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 An={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 ui(r){return r&&r.type==="8G_EXTENSION_RESPONSE"}const Sn=Rt({id:Ue(),name:Ue(),image:Ue(),memberCount:$t(),isAdmin:Tt().nullable().optional()});var un=(r=>(r.monthly="MONTHLY",r.yearly="YEARLY",r))(un||{});const Ur=Rt({code:Zr(Pr),symbol:Ue(),format:Ue(),amount:$t(),text:Ue().optional()}),Dn=Rt({planName:Ue(),currentCycleBillAmount:Ur,nextPaymentDue:Ue(),cycleTerm:Zr(un).nullable(),isFreeTier:Tt(),isPerUser:Tt(),paidMemberCount:$t(),usedMemberCount:$t(),unitPrice:Ur.nullable(),cardNumber:Ue(),cardName:Ue()}),On=Rt({uid:Ue(),issuedDate:Br.date(),paidDate:Br.date().nullable().optional(),paymentMethod:Ue(),amount:Ur,isSuccessfulPaid:Tt(),receiptUrl:Ue()}),Pn=Rt({name:Ue(),email:Ue().email(),profileImageUrl:Ue(),role:Ue(),isPaid:Tt().nullable().optional(),subscriptionSeatStatus:Lr(["FREE","PAID"]).nullable().optional()});class li{constructor(){}async checkExtension(){return new Promise((e,t)=>{const a=setTimeout(()=>{t(ct.extensionNotInstalled())},5e3),s=i=>{ui(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=w=>{var k,M,D,x,S,I,ae;if(((k=w.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&w.data.requestId===s){clearTimeout(c),window.removeEventListener("message",f);const Q=w.data,pe=((M=Q==null?void 0:Q.result)==null?void 0:M.steps)??((x=(D=Q==null?void 0:Q.result)==null?void 0:D.result)==null?void 0:x.steps)??[],H=((S=Q==null?void 0:Q.result)==null?void 0:S.context)??((ae=(I=Q==null?void 0:Q.result)==null?void 0:I.result)==null?void 0:ae.context)??{steps:{},vars:{}};t({success:Q.success,steps:pe,context:H,error:Q.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 w=Sn.safeParse(f);w.success?s.push(w.data):console.warn("Invalid workspace data:",f,w.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=Dn.safeParse(s);if(i.success){const w=i.data;return{...a,...w}}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 w of s){const k=On.safeParse(w);k.success?i.push(k.data):console.warn("Invalid workspace billing history data:",w,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 w of s){const k=Pn.safeParse(w);k.success?i.push(k.data):console.warn("Invalid workspace member data:",w,k.error)}return{...a,data:i}}static getFromContext(e,t){const a=t.split(".");let s=e;for(const i of a){if(s==null)return;s=s[i]}return s}static getStepResult(e,t){return e.steps[t]}static getStepData(e,t){var a,s;return(s=(a=e.steps[t])==null?void 0:a.result)==null?void 0:s.data}static getVar(e,t){return e.vars[t]}}exports.AiParseDataBlockSchema=Wr;exports.AllBlockSchemas=ti;exports.BaseBlockSchema=pt;exports.BillingCycleTerm=un;exports.Binding=ai;exports.BlockHandler=ri;exports.ClearValueFormsBlockSchema=Gr;exports.CollectWorkflowResult=ci;exports.Condition=ni;exports.CurrencyCode=Pr;exports.CurrencyInfoSchema=An;exports.EightGClient=li;exports.EightGError=ct;exports.ElementExistsBlockSchema=Yr;exports.EventClickBlockSchema=Kr;exports.ExportDataBlockSchema=on;exports.FetchApiBlockSchema=an;exports.GetAttributeValueBlockSchema=Vr;exports.GetElementDataBlockSchema=rn;exports.GetTextBlockSchema=zr;exports.GetValueFormsBlockSchema=qr;exports.KeypressBlockSchema=Jr;exports.NavigateBlockSchema=en;exports.NetworkCatchBlockSchema=cn;exports.SaveAssetsBlockSchema=tn;exports.Schema=Ga;exports.ScrollBlockSchema=nn;exports.SetValueFormsBlockSchema=Hr;exports.TransformDataBlockSchema=sn;exports.WaitBlockSchema=Xr;exports.WaitForConditionBlockSchema=Qr;exports.Workflow=ii;exports.WorkflowStep=si;exports.WorkflowStepRunResult=oi;exports.WorkspaceBillingHistorySchema=On;exports.WorkspaceBillingSchema=Dn;exports.WorkspaceItemSchema=Sn;exports.WorkspaceMemberSchema=Pn;exports.createArraySchema=Ha;exports.createSchema=qa;
|