scordi-extension 1.17.13 → 1.17.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.
@@ -1,7 +1,7 @@
1
- "use strict";var zn=Object.defineProperty;var Hn=(t,e,r)=>e in t?zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var le=(t,e,r)=>Hn(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var be;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{const i={};for(const o of n)i[o]=o;return i},t.getValidEnumValues=n=>{const i=t.objectKeys(n).filter(u=>typeof n[n[u]]!="number"),o={};for(const u of i)o[u]=n[u];return t.objectValues(o)},t.objectValues=n=>t.objectKeys(n).map(function(i){return n[i]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&i.push(o);return i},t.find=(n,i)=>{for(const o of n)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,i=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=a,t.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(be||(be={}));var Ir;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ir||(Ir={}));const W=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xt=t=>{switch(typeof t){case"undefined":return W.undefined;case"string":return W.string;case"number":return Number.isNaN(t)?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(t)?W.array:t===null?W.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?W.promise:typeof Map<"u"&&t instanceof Map?W.map:typeof Set<"u"&&t instanceof Set?W.set:typeof Date<"u"&&t 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"]),qn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class ot 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 r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(i){return i.message},a={_errors:[]},n=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)a._errors.push(r(o));else{let u=a,v=0;for(;v<o.path.length;){const k=o.path[v];v===o.path.length-1?(u[k]=u[k]||{_errors:[]},u[k]._errors.push(r(o))):u[k]=u[k]||{_errors:[]},u=u[k],v++}}};return n(this),a}static assert(e){if(!(e instanceof ot))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=r=>r.message){const r={},a=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];r[i]=r[i]||[],r[i].push(e(n))}else a.push(e(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}}ot.create=t=>new ot(t);const Gt=(t,e)=>{let r;switch(t.code){case P.invalid_type:t.received===W.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case P.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,be.jsonStringifyReplacer)}`;break;case P.unrecognized_keys:r=`Unrecognized key(s) in object: ${be.joinValues(t.keys,", ")}`;break;case P.invalid_union:r="Invalid input";break;case P.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${be.joinValues(t.options)}`;break;case P.invalid_enum_value:r=`Invalid enum value. Expected ${be.joinValues(t.options)}, received '${t.received}'`;break;case P.invalid_arguments:r="Invalid function arguments";break;case P.invalid_return_type:r="Invalid function return type";break;case P.invalid_date:r="Invalid date";break;case P.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:be.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case P.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case P.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case P.custom:r="Invalid input";break;case P.invalid_intersection_types:r="Intersection results could not be merged";break;case P.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case P.not_finite:r="Number must be finite";break;default:r=e.defaultError,be.assertNever(t)}return{message:r}};let Dn=Gt;function Gn(t){Dn=t}function xr(){return Dn}const Er=t=>{const{data:e,path:r,errorMaps:a,issueData:n}=t,i=[...r,...n.path||[]],o={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let u="";const v=a.filter(k=>!!k).slice().reverse();for(const k of v)u=k(o,{data:e,defaultError:u}).message;return{...n,path:i,message:u}},Yn=[];function L(t,e){const r=xr(),a=Er({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Gt?void 0:Gt].filter(n=>!!n)});t.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,r){const a=[];for(const n of r){if(n.status==="aborted")return te;n.status==="dirty"&&e.dirty(),a.push(n.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,r){const a=[];for(const n of r){const i=await n.key,o=await n.value;a.push({key:i,value:o})}return Ke.mergeObjectSync(e,a)}static mergeObjectSync(e,r){const a={};for(const n of r){const{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return te;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(a[i.value]=o.value)}return{status:e.value,value:a}}}const te=Object.freeze({status:"aborted"}),Ht=t=>({status:"dirty",value:t}),Xe=t=>({status:"valid",value:t}),jr=t=>t.status==="aborted",Fr=t=>t.status==="dirty",Ft=t=>t.status==="valid",tr=t=>typeof Promise<"u"&&t instanceof Promise;var Y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class vt{constructor(e,r,a,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=a,this._key=n}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 yn=(t,e)=>{if(Ft(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new ot(t.common.issues);return this._error=r,this._error}}};function oe(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:a,description:n}=t;if(e&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(o,u)=>{const{message:v}=t;return o.code==="invalid_enum_value"?{message:v??u.defaultError}:typeof u.data>"u"?{message:v??a??u.defaultError}:o.code!=="invalid_type"?{message:u.defaultError}:{message:v??r??u.defaultError}},description:n}}class ue{get description(){return this._def.description}_getType(e){return xt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:xt(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:xt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(tr(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const a=this.safeParse(e,r);if(a.success)return a.data;throw a.error}safeParse(e,r){const a={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xt(e)},n=this._parseSync({data:e,path:a.path,parent:a});return yn(a,n)}"~validate"(e){var a,n;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xt(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return Ft(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(n=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&n.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>Ft(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const a=await this.safeParseAsync(e,r);if(a.success)return a.data;throw a.error}async safeParseAsync(e,r){const a={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:xt(e)},n=this._parse({data:e,path:a.path,parent:a}),i=await(tr(n)?n:Promise.resolve(n));return yn(a,i)}refine(e,r){const a=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,i)=>{const o=e(n),u=()=>i.addIssue({code:P.custom,...a(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(v=>v?!0:(u(),!1)):o?!0:(u(),!1)})}refinement(e,r){return this._refinement((a,n)=>e(a)?!0:(n.addIssue(typeof r=="function"?r(a,n):r),!1))}_refinement(e){return new mt({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:r=>this["~validate"](r)}}optional(){return yt.create(this,this._def)}nullable(){return Nt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pt.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 mt({...oe(this._def),schema:this,typeName:ne.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new fr({...oe(this._def),innerType:this,defaultValue:r,typeName:ne.ZodDefault})}brand(){return new $r({typeName:ne.ZodBranded,type:this,...oe(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new dr({...oe(this._def),innerType:this,catchValue:r,typeName:ne.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return mr.create(this,e)}readonly(){return hr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Kn=/^c[^\s-]{8,}$/i,Jn=/^[0-9a-z]+$/,Xn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Qn=/^[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,ea=/^[a-z0-9_-]{21}$/i,ta=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ra=/^[-+]?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)?)??$/,na=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,aa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Nr;const sa=/^(?:(?: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])$/,ia=/^(?:(?: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])$/,oa=/^(([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]))$/,ca=/^(([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])$/,la=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ua=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,On="((\\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])))",fa=new RegExp(`^${On}$`);function Cn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function da(t){return new RegExp(`^${Cn(t)}$`)}function Pn(t){let e=`${On}T${Cn(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function ha(t,e){return!!((e==="v4"||!e)&&sa.test(t)||(e==="v6"||!e)&&oa.test(t))}function pa(t,e){if(!ta.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function ma(t,e){return!!((e==="v4"||!e)&&ia.test(t)||(e==="v6"||!e)&&ca.test(t))}class ht extends ue{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==W.string){const i=this._getOrReturnCtx(e);return L(i,{code:P.invalid_type,expected:W.string,received:i.parsedType}),te}const a=new Ke;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),L(n,{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&&(n=this._getOrReturnCtx(e,n),L(n,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,u=e.data.length<i.value;(o||u)&&(n=this._getOrReturnCtx(e,n),o?L(n,{code:P.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):u&&L(n,{code:P.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")na.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"email",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Nr||(Nr=new RegExp(aa,"u")),Nr.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"emoji",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Qn.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"uuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")ea.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"nanoid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")Kn.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"cuid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Jn.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"cuid2",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Xn.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"ulid",code:P.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),L(n,{validation:"url",code:P.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{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)||(n=this._getOrReturnCtx(e,n),L(n,{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)||(n=this._getOrReturnCtx(e,n),L(n,{code:P.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),L(n,{code:P.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?Pn(i).test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:P.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?fa.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:P.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?da(i).test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:P.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?ra.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"duration",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?ha(e.data,i.version)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"ip",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?pa(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"jwt",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?ma(e.data,i.version)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"cidr",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?la.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"base64",code:P.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?ua.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"base64url",code:P.invalid_string,message:i.message}),a.dirty()):be.assertNever(i);return{status:a.value,value:e.data}}_regex(e,r,a){return this.refinement(n=>e.test(n),{validation:r,code:P.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ht({...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,r){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Y.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Y.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Y.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Y.errToObj(r)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new ht({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ht({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ht({...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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}ht.create=t=>new ht({checks:[],typeName:ne.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...oe(t)});function ga(t,e){const r=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,n=r>a?r:a,i=Number.parseInt(t.toFixed(n).replace(".","")),o=Number.parseInt(e.toFixed(n).replace(".",""));return i%o/10**n}class Ot extends ue{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 L(i,{code:P.invalid_type,expected:W.number,received:i.parsedType}),te}let a;const n=new Ke;for(const i of this._def.checks)i.kind==="int"?be.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),L(a,{code:P.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),L(a,{code:P.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),L(a,{code:P.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?ga(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),L(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),L(a,{code:P.not_finite,message:i.message}),n.dirty()):be.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Y.toString(r))}setLimit(e,r,a,n){return new Ot({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:Y.toString(n)}]})}_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,r){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.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,r=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Ot.create=t=>new Ot({checks:[],typeName:ne.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...oe(t)});class Ct extends ue{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 n=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),L(a,{code:P.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),L(a,{code:P.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),L(a,{code:P.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):be.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return L(r,{code:P.invalid_type,expected:W.bigint,received:r.parsedType}),te}gte(e,r){return this.setLimit("min",e,!0,Y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Y.toString(r))}setLimit(e,r,a,n){return new Ct({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:Y.toString(n)}]})}_addCheck(e){return new Ct({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Ct.create=t=>new Ct({checks:[],typeName:ne.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...oe(t)});class rr extends ue{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==W.boolean){const a=this._getOrReturnCtx(e);return L(a,{code:P.invalid_type,expected:W.boolean,received:a.parsedType}),te}return Xe(e.data)}}rr.create=t=>new rr({typeName:ne.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...oe(t)});class Bt extends ue{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==W.date){const i=this._getOrReturnCtx(e);return L(i,{code:P.invalid_type,expected:W.date,received:i.parsedType}),te}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return L(i,{code:P.invalid_date}),te}const a=new Ke;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),L(n,{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&&(n=this._getOrReturnCtx(e,n),L(n,{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,r){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Bt.create=t=>new Bt({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:ne.ZodDate,...oe(t)});class Ar extends ue{_parse(e){if(this._getType(e)!==W.symbol){const a=this._getOrReturnCtx(e);return L(a,{code:P.invalid_type,expected:W.symbol,received:a.parsedType}),te}return Xe(e.data)}}Ar.create=t=>new Ar({typeName:ne.ZodSymbol,...oe(t)});class nr extends ue{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return L(a,{code:P.invalid_type,expected:W.undefined,received:a.parsedType}),te}return Xe(e.data)}}nr.create=t=>new nr({typeName:ne.ZodUndefined,...oe(t)});class ar extends ue{_parse(e){if(this._getType(e)!==W.null){const a=this._getOrReturnCtx(e);return L(a,{code:P.invalid_type,expected:W.null,received:a.parsedType}),te}return Xe(e.data)}}ar.create=t=>new ar({typeName:ne.ZodNull,...oe(t)});class Yt extends ue{constructor(){super(...arguments),this._any=!0}_parse(e){return Xe(e.data)}}Yt.create=t=>new Yt({typeName:ne.ZodAny,...oe(t)});class jt extends ue{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Xe(e.data)}}jt.create=t=>new jt({typeName:ne.ZodUnknown,...oe(t)});class Et extends ue{_parse(e){const r=this._getOrReturnCtx(e);return L(r,{code:P.invalid_type,expected:W.never,received:r.parsedType}),te}}Et.create=t=>new Et({typeName:ne.ZodNever,...oe(t)});class Tr extends ue{_parse(e){if(this._getType(e)!==W.undefined){const a=this._getOrReturnCtx(e);return L(a,{code:P.invalid_type,expected:W.void,received:a.parsedType}),te}return Xe(e.data)}}Tr.create=t=>new Tr({typeName:ne.ZodVoid,...oe(t)});class pt extends ue{_parse(e){const{ctx:r,status:a}=this._processInputParams(e),n=this._def;if(r.parsedType!==W.array)return L(r,{code:P.invalid_type,expected:W.array,received:r.parsedType}),te;if(n.exactLength!==null){const o=r.data.length>n.exactLength.value,u=r.data.length<n.exactLength.value;(o||u)&&(L(r,{code:o?P.too_big:P.too_small,minimum:u?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(L(r,{code:P.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(L(r,{code:P.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((o,u)=>n.type._parseAsync(new vt(r,o,r.path,u)))).then(o=>Ke.mergeArray(a,o));const i=[...r.data].map((o,u)=>n.type._parseSync(new vt(r,o,r.path,u)));return Ke.mergeArray(a,i)}get element(){return this._def.type}min(e,r){return new pt({...this._def,minLength:{value:e,message:Y.toString(r)}})}max(e,r){return new pt({...this._def,maxLength:{value:e,message:Y.toString(r)}})}length(e,r){return new pt({...this._def,exactLength:{value:e,message:Y.toString(r)}})}nonempty(e){return this.min(1,e)}}pt.create=(t,e)=>new pt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ne.ZodArray,...oe(e)});function zt(t){if(t instanceof je){const e={};for(const r in t.shape){const a=t.shape[r];e[r]=yt.create(zt(a))}return new je({...t._def,shape:()=>e})}else return t instanceof pt?new pt({...t._def,type:zt(t.element)}):t instanceof yt?yt.create(zt(t.unwrap())):t instanceof Nt?Nt.create(zt(t.unwrap())):t instanceof bt?bt.create(t.items.map(e=>zt(e))):t}class je extends ue{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(),r=be.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==W.object){const k=this._getOrReturnCtx(e);return L(k,{code:P.invalid_type,expected:W.object,received:k.parsedType}),te}const{status:a,ctx:n}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),u=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const k in n.data)o.includes(k)||u.push(k);const v=[];for(const k of o){const C=i[k],D=n.data[k];v.push({key:{status:"valid",value:k},value:C._parse(new vt(n,D,n.path,k)),alwaysSet:k in n.data})}if(this._def.catchall instanceof Et){const k=this._def.unknownKeys;if(k==="passthrough")for(const C of u)v.push({key:{status:"valid",value:C},value:{status:"valid",value:n.data[C]}});else if(k==="strict")u.length>0&&(L(n,{code:P.unrecognized_keys,keys:u}),a.dirty());else if(k!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const k=this._def.catchall;for(const C of u){const D=n.data[C];v.push({key:{status:"valid",value:C},value:k._parse(new vt(n,D,n.path,C)),alwaysSet:C in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const k=[];for(const C of v){const D=await C.key,x=await C.value;k.push({key:D,value:x,alwaysSet:C.alwaysSet})}return k}).then(k=>Ke.mergeObjectSync(a,k)):Ke.mergeObjectSync(a,v)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,a)=>{var i,o;const n=((o=(i=this._def).errorMap)==null?void 0:o.call(i,r,a).message)??a.defaultError;return r.code==="unrecognized_keys"?{message:Y.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new je({...this._def,unknownKeys:"strip"})}passthrough(){return new je({...this._def,unknownKeys:"passthrough"})}extend(e){return new je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ne.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new je({...this._def,catchall:e})}pick(e){const r={};for(const a of be.objectKeys(e))e[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new je({...this._def,shape:()=>r})}omit(e){const r={};for(const a of be.objectKeys(this.shape))e[a]||(r[a]=this.shape[a]);return new je({...this._def,shape:()=>r})}deepPartial(){return zt(this)}partial(e){const r={};for(const a of be.objectKeys(this.shape)){const n=this.shape[a];e&&!e[a]?r[a]=n:r[a]=n.optional()}return new je({...this._def,shape:()=>r})}required(e){const r={};for(const a of be.objectKeys(this.shape))if(e&&!e[a])r[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof yt;)i=i._def.innerType;r[a]=i}return new je({...this._def,shape:()=>r})}keyof(){return Nn(be.objectKeys(this.shape))}}je.create=(t,e)=>new je({shape:()=>t,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});je.strictCreate=(t,e)=>new je({shape:()=>t,unknownKeys:"strict",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});je.lazycreate=(t,e)=>new je({shape:t,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});class sr extends ue{_parse(e){const{ctx:r}=this._processInputParams(e),a=this._def.options;function n(i){for(const u of i)if(u.result.status==="valid")return u.result;for(const u of i)if(u.result.status==="dirty")return r.common.issues.push(...u.ctx.common.issues),u.result;const o=i.map(u=>new ot(u.ctx.common.issues));return L(r,{code:P.invalid_union,unionErrors:o}),te}if(r.common.async)return Promise.all(a.map(async i=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let i;const o=[];for(const v of a){const k={...r,common:{...r.common,issues:[]},parent:null},C=v._parseSync({data:r.data,path:r.path,parent:k});if(C.status==="valid")return C;C.status==="dirty"&&!i&&(i={result:C,ctx:k}),k.common.issues.length&&o.push(k.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const u=o.map(v=>new ot(v));return L(r,{code:P.invalid_union,unionErrors:u}),te}}get options(){return this._def.options}}sr.create=(t,e)=>new sr({options:t,typeName:ne.ZodUnion,...oe(e)});const _t=t=>t instanceof cr?_t(t.schema):t instanceof mt?_t(t.innerType()):t instanceof lr?[t.value]:t instanceof Pt?t.options:t instanceof ur?be.objectValues(t.enum):t instanceof fr?_t(t._def.innerType):t instanceof nr?[void 0]:t instanceof ar?[null]:t instanceof yt?[void 0,..._t(t.unwrap())]:t instanceof Nt?[null,..._t(t.unwrap())]:t instanceof $r||t instanceof hr?_t(t.unwrap()):t instanceof dr?_t(t._def.innerType):[];class Or extends ue{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.object)return L(r,{code:P.invalid_type,expected:W.object,received:r.parsedType}),te;const a=this.discriminator,n=r.data[a],i=this.optionsMap.get(n);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(L(r,{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,r,a){const n=new Map;for(const i of r){const o=_t(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const u of o){if(n.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);n.set(u,i)}}return new Or({typeName:ne.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...oe(a)})}}function Br(t,e){const r=xt(t),a=xt(e);if(t===e)return{valid:!0,data:t};if(r===W.object&&a===W.object){const n=be.objectKeys(e),i=be.objectKeys(t).filter(u=>n.indexOf(u)!==-1),o={...t,...e};for(const u of i){const v=Br(t[u],e[u]);if(!v.valid)return{valid:!1};o[u]=v.data}return{valid:!0,data:o}}else if(r===W.array&&a===W.array){if(t.length!==e.length)return{valid:!1};const n=[];for(let i=0;i<t.length;i++){const o=t[i],u=e[i],v=Br(o,u);if(!v.valid)return{valid:!1};n.push(v.data)}return{valid:!0,data:n}}else return r===W.date&&a===W.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ir extends ue{_parse(e){const{status:r,ctx:a}=this._processInputParams(e),n=(i,o)=>{if(jr(i)||jr(o))return te;const u=Br(i.value,o.value);return u.valid?((Fr(i)||Fr(o))&&r.dirty(),{status:r.value,value:u.data}):(L(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,o])=>n(i,o)):n(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=(t,e,r)=>new ir({left:t,right:e,typeName:ne.ZodIntersection,...oe(r)});class bt extends ue{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.array)return L(a,{code:P.invalid_type,expected:W.array,received:a.parsedType}),te;if(a.data.length<this._def.items.length)return L(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&&(L(a,{code:P.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...a.data].map((o,u)=>{const v=this._def.items[u]||this._def.rest;return v?v._parse(new vt(a,o,a.path,u)):null}).filter(o=>!!o);return a.common.async?Promise.all(i).then(o=>Ke.mergeArray(r,o)):Ke.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new bt({...this._def,rest:e})}}bt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bt({items:t,typeName:ne.ZodTuple,rest:null,...oe(e)})};class or extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.object)return L(a,{code:P.invalid_type,expected:W.object,received:a.parsedType}),te;const n=[],i=this._def.keyType,o=this._def.valueType;for(const u in a.data)n.push({key:i._parse(new vt(a,u,a.path,u)),value:o._parse(new vt(a,a.data[u],a.path,u)),alwaysSet:u in a.data});return a.common.async?Ke.mergeObjectAsync(r,n):Ke.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,a){return r instanceof ue?new or({keyType:e,valueType:r,typeName:ne.ZodRecord,...oe(a)}):new or({keyType:ht.create(),valueType:e,typeName:ne.ZodRecord,...oe(r)})}}class Sr extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.map)return L(a,{code:P.invalid_type,expected:W.map,received:a.parsedType}),te;const n=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([u,v],k)=>({key:n._parse(new vt(a,u,a.path,[k,"key"])),value:i._parse(new vt(a,v,a.path,[k,"value"]))}));if(a.common.async){const u=new Map;return Promise.resolve().then(async()=>{for(const v of o){const k=await v.key,C=await v.value;if(k.status==="aborted"||C.status==="aborted")return te;(k.status==="dirty"||C.status==="dirty")&&r.dirty(),u.set(k.value,C.value)}return{status:r.value,value:u}})}else{const u=new Map;for(const v of o){const k=v.key,C=v.value;if(k.status==="aborted"||C.status==="aborted")return te;(k.status==="dirty"||C.status==="dirty")&&r.dirty(),u.set(k.value,C.value)}return{status:r.value,value:u}}}}Sr.create=(t,e,r)=>new Sr({valueType:e,keyType:t,typeName:ne.ZodMap,...oe(r)});class Lt extends ue{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.set)return L(a,{code:P.invalid_type,expected:W.set,received:a.parsedType}),te;const n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(L(a,{code:P.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(L(a,{code:P.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());const i=this._def.valueType;function o(v){const k=new Set;for(const C of v){if(C.status==="aborted")return te;C.status==="dirty"&&r.dirty(),k.add(C.value)}return{status:r.value,value:k}}const u=[...a.data.values()].map((v,k)=>i._parse(new vt(a,v,a.path,k)));return a.common.async?Promise.all(u).then(v=>o(v)):o(u)}min(e,r){return new Lt({...this._def,minSize:{value:e,message:Y.toString(r)}})}max(e,r){return new Lt({...this._def,maxSize:{value:e,message:Y.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Lt.create=(t,e)=>new Lt({valueType:t,minSize:null,maxSize:null,typeName:ne.ZodSet,...oe(e)});class qt extends ue{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.function)return L(r,{code:P.invalid_type,expected:W.function,received:r.parsedType}),te;function a(u,v){return Er({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xr(),Gt].filter(k=>!!k),issueData:{code:P.invalid_arguments,argumentsError:v}})}function n(u,v){return Er({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xr(),Gt].filter(k=>!!k),issueData:{code:P.invalid_return_type,returnTypeError:v}})}const i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Kt){const u=this;return Xe(async function(...v){const k=new ot([]),C=await u._def.args.parseAsync(v,i).catch(T=>{throw k.addIssue(a(v,T)),k}),D=await Reflect.apply(o,this,C);return await u._def.returns._def.type.parseAsync(D,i).catch(T=>{throw k.addIssue(n(D,T)),k})})}else{const u=this;return Xe(function(...v){const k=u._def.args.safeParse(v,i);if(!k.success)throw new ot([a(v,k.error)]);const C=Reflect.apply(o,this,k.data),D=u._def.returns.safeParse(C,i);if(!D.success)throw new ot([n(C,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new qt({...this._def,args:bt.create(e).rest(jt.create())})}returns(e){return new qt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,a){return new qt({args:e||bt.create([]).rest(jt.create()),returns:r||jt.create(),typeName:ne.ZodFunction,...oe(a)})}}class cr extends ue{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}cr.create=(t,e)=>new cr({getter:t,typeName:ne.ZodLazy,...oe(e)});class lr extends ue{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return L(r,{received:r.data,code:P.invalid_literal,expected:this._def.value}),te}return{status:"valid",value:e.data}}get value(){return this._def.value}}lr.create=(t,e)=>new lr({value:t,typeName:ne.ZodLiteral,...oe(e)});function Nn(t,e){return new Pt({values:t,typeName:ne.ZodEnum,...oe(e)})}class Pt extends ue{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),a=this._def.values;return L(r,{expected:be.joinValues(a),received:r.parsedType,code:P.invalid_type}),te}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),a=this._def.values;return L(r,{received:r.data,code:P.invalid_enum_value,options:a}),te}return Xe(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Pt.create(e,{...this._def,...r})}exclude(e,r=this._def){return Pt.create(this.options.filter(a=>!e.includes(a)),{...this._def,...r})}}Pt.create=Nn;class ur extends ue{_parse(e){const r=be.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==W.string&&a.parsedType!==W.number){const n=be.objectValues(r);return L(a,{expected:be.joinValues(n),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 n=be.objectValues(r);return L(a,{received:a.data,code:P.invalid_enum_value,options:n}),te}return Xe(e.data)}get enum(){return this._def.values}}ur.create=(t,e)=>new ur({values:t,typeName:ne.ZodNativeEnum,...oe(e)});class Kt extends ue{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==W.promise&&r.common.async===!1)return L(r,{code:P.invalid_type,expected:W.promise,received:r.parsedType}),te;const a=r.parsedType===W.promise?r.data:Promise.resolve(r.data);return Xe(a.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Kt.create=(t,e)=>new Kt({type:t,typeName:ne.ZodPromise,...oe(e)});class mt extends ue{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:r,ctx:a}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:o=>{L(a,o),o.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){const o=n.transform(a.data,i);if(a.common.async)return Promise.resolve(o).then(async u=>{if(r.value==="aborted")return te;const v=await this._def.schema._parseAsync({data:u,path:a.path,parent:a});return v.status==="aborted"?te:v.status==="dirty"||r.value==="dirty"?Ht(v.value):v});{if(r.value==="aborted")return te;const u=this._def.schema._parseSync({data:o,path:a.path,parent:a});return u.status==="aborted"?te:u.status==="dirty"||r.value==="dirty"?Ht(u.value):u}}if(n.type==="refinement"){const o=u=>{const v=n.refinement(u,i);if(a.common.async)return Promise.resolve(v);if(v instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u};if(a.common.async===!1){const u=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return u.status==="aborted"?te:(u.status==="dirty"&&r.dirty(),o(u.value),{status:r.value,value:u.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(u=>u.status==="aborted"?te:(u.status==="dirty"&&r.dirty(),o(u.value).then(()=>({status:r.value,value:u.value}))))}if(n.type==="transform")if(a.common.async===!1){const o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Ft(o))return te;const u=n.transform(o.value,i);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:u}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>Ft(o)?Promise.resolve(n.transform(o.value,i)).then(u=>({status:r.value,value:u})):te);be.assertNever(n)}}mt.create=(t,e,r)=>new mt({schema:t,typeName:ne.ZodEffects,effect:e,...oe(r)});mt.createWithPreprocess=(t,e,r)=>new mt({schema:e,effect:{type:"preprocess",transform:t},typeName:ne.ZodEffects,...oe(r)});class yt extends ue{_parse(e){return this._getType(e)===W.undefined?Xe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}yt.create=(t,e)=>new yt({innerType:t,typeName:ne.ZodOptional,...oe(e)});class Nt extends ue{_parse(e){return this._getType(e)===W.null?Xe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Nt.create=(t,e)=>new Nt({innerType:t,typeName:ne.ZodNullable,...oe(e)});class fr extends ue{_parse(e){const{ctx:r}=this._processInputParams(e);let a=r.data;return r.parsedType===W.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}fr.create=(t,e)=>new fr({innerType:t,typeName:ne.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...oe(e)});class dr extends ue{_parse(e){const{ctx:r}=this._processInputParams(e),a={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return tr(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ot(a.common.issues)},input:a.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ot(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}dr.create=(t,e)=>new dr({innerType:t,typeName:ne.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...oe(e)});class Dr extends ue{_parse(e){if(this._getType(e)!==W.nan){const a=this._getOrReturnCtx(e);return L(a,{code:P.invalid_type,expected:W.nan,received:a.parsedType}),te}return{status:"valid",value:e.data}}}Dr.create=t=>new Dr({typeName:ne.ZodNaN,...oe(t)});const ya=Symbol("zod_brand");class $r extends ue{_parse(e){const{ctx:r}=this._processInputParams(e),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}}class mr extends ue{_parse(e){const{status:r,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"?(r.dirty(),Ht(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?te:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(e,r){return new mr({in:e,out:r,typeName:ne.ZodPipeline})}}class hr extends ue{_parse(e){const r=this._def.innerType._parse(e),a=n=>(Ft(n)&&(n.value=Object.freeze(n.value)),n);return tr(r)?r.then(n=>a(n)):a(r)}unwrap(){return this._def.innerType}}hr.create=(t,e)=>new hr({innerType:t,typeName:ne.ZodReadonly,...oe(e)});function vn(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Rn(t,e={},r){return t?Yt.create().superRefine((a,n)=>{const i=t(a);if(i instanceof Promise)return i.then(o=>{if(!o){const u=vn(e,a),v=u.fatal??r??!0;n.addIssue({code:"custom",...u,fatal:v})}});if(!i){const o=vn(e,a),u=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:u})}}):Yt.create()}const va={object:je.lazycreate};var ne;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ne||(ne={}));const ba=(t,e={message:`Input not instance of ${t.name}`})=>Rn(r=>r instanceof t,e),Ce=ht.create,$t=Ot.create,wa=Dr.create,ka=Ct.create,Rt=rr.create,_a=Bt.create,xa=Ar.create,Ea=nr.create,Aa=ar.create,Ta=Yt.create,Sa=jt.create,Da=Et.create,Oa=Tr.create,Ca=pt.create,At=je.create,Pa=je.strictCreate,Na=sr.create,Ra=Or.create,Ma=ir.create,Ia=bt.create,ja=or.create,Fa=Sr.create,Ba=Lt.create,La=qt.create,$a=cr.create,Ua=lr.create,Ur=Pt.create,Zr=ur.create,Za=Kt.create,bn=mt.create,Wa=yt.create,Va=Nt.create,za=mt.createWithPreprocess,Ha=mr.create,qa=()=>Ce().optional(),Ga=()=>$t().optional(),Ya=()=>Rt().optional(),pr={string:(t=>ht.create({...t,coerce:!0})),number:(t=>Ot.create({...t,coerce:!0})),boolean:(t=>rr.create({...t,coerce:!0})),bigint:(t=>Ct.create({...t,coerce:!0})),date:(t=>Bt.create({...t,coerce:!0}))},Ka=te,b=Object.freeze(Object.defineProperty({__proto__:null,BRAND:ya,DIRTY:Ht,EMPTY_PATH:Yn,INVALID:te,NEVER:Ka,OK:Xe,ParseStatus:Ke,Schema:ue,ZodAny:Yt,ZodArray:pt,ZodBigInt:Ct,ZodBoolean:rr,ZodBranded:$r,ZodCatch:dr,ZodDate:Bt,ZodDefault:fr,ZodDiscriminatedUnion:Or,ZodEffects:mt,ZodEnum:Pt,ZodError:ot,get ZodFirstPartyTypeKind(){return ne},ZodFunction:qt,ZodIntersection:ir,ZodIssueCode:P,ZodLazy:cr,ZodLiteral:lr,ZodMap:Sr,ZodNaN:Dr,ZodNativeEnum:ur,ZodNever:Et,ZodNull:ar,ZodNullable:Nt,ZodNumber:Ot,ZodObject:je,ZodOptional:yt,ZodParsedType:W,ZodPipeline:mr,ZodPromise:Kt,ZodReadonly:hr,ZodRecord:or,ZodSchema:ue,ZodSet:Lt,ZodString:ht,ZodSymbol:Ar,ZodTransformer:mt,ZodTuple:bt,ZodType:ue,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:jt,ZodVoid:Tr,addIssueToContext:L,any:Ta,array:Ca,bigint:ka,boolean:Rt,coerce:pr,custom:Rn,date:_a,datetimeRegex:Pn,defaultErrorMap:Gt,discriminatedUnion:Ra,effect:bn,enum:Ur,function:La,getErrorMap:xr,getParsedType:xt,instanceof:ba,intersection:Ma,isAborted:jr,isAsync:tr,isDirty:Fr,isValid:Ft,late:va,lazy:$a,literal:Ua,makeIssue:Er,map:Fa,nan:wa,nativeEnum:Zr,never:Da,null:Aa,nullable:Va,number:$t,object:At,get objectUtil(){return Ir},oboolean:Ya,onumber:Ga,optional:Wa,ostring:qa,pipeline:Ha,preprocess:za,promise:Za,quotelessJson:qn,record:ja,set:Ba,setErrorMap:Gn,strictObject:Pa,string:Ce,symbol:xa,transformer:bn,tuple:Ia,undefined:Ea,union:Na,unknown:Sa,get util(){return be},void:Oa},Symbol.toStringTag,{value:"Module"})),tt=At({name:Ce(),selector:Ce(),findBy:Ur(["cssSelector","xpath"]),option:At({waitForSelector:Rt().optional(),waitSelectorTimeout:$t().optional(),multiple:Rt().optional()})}),Ja=b.object({type:b.literal("object"),shape:b.record(b.string(),b.any())}),Xa=b.object({type:b.literal("array"),items:b.any()}),Qa=b.discriminatedUnion("type",[Ja,Xa]),Wr=b.object({name:b.literal("ai-parse-data"),sourceData:b.any().optional(),schemaDefinition:Qa,prompt:b.string().optional(),model:b.string().optional(),apiKey:b.string().min(1,"AI API key is required"),provider:b.enum(["openai","anthropic"])});function es(t){return Wr.parse(t)}async function ts(t){try{const{sourceData:e,schemaDefinition:r,prompt:a,model:n,apiKey:i,provider:o}=t;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 u=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:r,prompt:a,model:n,apiKey:i,provider:o}});if(u.$isError)throw new Error(u.message||"AI parsing failed");return{data:u.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function rs(t){return{type:"object",shape:t}}function ns(t){return{type:"array",items:t}}const as={string:t=>({type:"string",...t}),number:t=>({type:"number",...t}),boolean:t=>({type:"boolean",...t}),array:(t,e)=>({type:"array",items:t,...e}),object:(t,e)=>({type:"object",shape:t,...e}),currency:t=>({type:"currency",shape:In,description:(t==null?void 0:t.description)||"Currency information with code, symbol, format, amount, and text",optional:t==null?void 0:t.optional})};class Cr{async waitForElement(e,r,a){return new Promise(n=>{const i=Date.now(),o=async()=>{const u=await this.find(e,r);if(u&&(!Array.isArray(u)||u.length>0)){n(u);return}if(Date.now()-i>=a){n(null);return}setTimeout(o,100)};o()})}}class ss extends Cr{async find(e,r=document){const{selector:a,option:n}=e,{multiple:i=!1}=n||{};try{const o=this.processCustomPseudoSelectors(a,r);return i?Array.from(r.querySelectorAll(o)):r.querySelector(o)}catch(o){return console.error("CSS Selector error:",o),null}}processCustomPseudoSelectors(e,r){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,o)=>`[data-contains="${o}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,o)=>`[data-equal="${o}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const n=((i=a.textContent)==null?void 0:i.trim())||"";if(n){a.setAttribute("data-contains",n);const u=Array.from(a.childNodes).filter(v=>v.nodeType===Node.TEXT_NODE).map(v=>{var k;return((k=v.textContent)==null?void 0:k.trim())||""}).join(" ").trim();(u&&u===n||a.children.length===0&&n)&&a.setAttribute("data-equal",n)}})}}class is extends Cr{async find(e,r=document){const{selector:a,option:n}=e,{multiple:i=!1}=n||{};if(!a||a.trim()==="")return null;const o=a.split("|>").map(k=>k.trim());if(o.length!==2)return null;const u=o[0],v=o[1];if(!u||!v)return null;try{const k=r.querySelector(u);if(!k||!k.contentDocument)return null;const C=k.contentDocument;return i?Array.from(C.querySelectorAll(v)):C.querySelector(v)}catch(k){return console.error("Iframe Selector error:",k),null}}}class os extends Cr{async find(e,r=document){const{selector:a,option:n}=e,{multiple:i=!1}=n||{};if(!a||a.trim()==="")return null;const o=a.split(">>").map(v=>v.trim());let u=r;try{for(let v=0;v<o.length;v++){const k=o[v],C=v===o.length-1;if(!k)return null;if(C&&i)return Array.from(u.querySelectorAll(k));const D=u.querySelector(k);if(!D)return null;if(C)return D;if(D.shadowRoot)u=D.shadowRoot;else return null}}catch(v){return console.error("Shadow DOM Selector error:",v),null}return null}}class cs extends Cr{async find(e,r=document){const{selector:a,option:n}=e,{multiple:i=!1}=n||{};try{const o=r.evaluate(a,r,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const u=[];for(let v=0;v<o.snapshotLength;v++){const k=o.snapshotItem(v);k&&k.nodeType===Node.ELEMENT_NODE&&u.push(k)}return Promise.resolve(u.length>0?u:null)}else{const u=o.singleNodeValue;return u&&u.nodeType===Node.ELEMENT_NODE?u:null}}catch(o){return console.error("XPath error:",o),null}}}class ls{static generate(e){const r=["data-testid","aria-label","title","alt","role"];for(const i of r){const o=e.getAttribute(i);if(o&&!this.isDynamicValue(o))return`[${i}="${CSS.escape(o)}"]`}const a=e.tagName.toLowerCase(),n=e.parentElement;if(n){const i=Array.from(n.children),o=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${o})`}if(n){const i=this.generateParentSelector(n);if(i)return`${i} > ${a}:nth-child(${Array.from(n.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const r=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const o=e.getAttribute(i);if(o&&!this.isDynamicValue(o))return`[${i}="${CSS.escape(o)}"]`}const n=e.parentElement;if(n){const i=Array.from(n.children),o=i.indexOf(e)+1;if(i.length>1)return`${r}:nth-child(${o})`}return r}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 rt(t,e=document){const{selector:r,findBy:a="cssSelector",option:n}=t,{waitForSelector:i=!1,waitSelectorTimeout:o=5e3}=n||{},u=us(r,a);return i?u.waitForElement(t,e,o):u.find(t,e)}function us(t,e){return e==="xpath"?new cs:t.includes(">>")?new os:t.includes("|>")?new is:new ss}const Vr=tt.extend({name:b.literal("get-text"),includeTags:b.boolean().optional(),useTextContent:b.boolean().optional(),regex:b.string().optional(),prefixText:b.string().optional(),suffixText:b.string().optional(),filterEmpty:b.boolean().optional(),scrollToCollect:b.boolean().optional(),scrollDistance:b.number().optional(),scrollWaitMs:b.number().optional(),maxScrollAttempts:b.number().optional()});function fs(t){return Vr.parse(t)}async function ds(t){try{const{selector:e="",includeTags:r=!1,useTextContent:a=!1,regex:n,prefixText:i="",suffixText:o="",findBy:u="cssSelector",option:v,filterEmpty:k=!0,scrollToCollect:C=!1,scrollDistance:D=500,scrollWaitMs:x=300,maxScrollAttempts:T=100}=t;if(!e)throw new Error("Selector is required for get-text block");if(C&&(v!=null&&v.multiple))return await hs({selector:e,findBy:u,option:v,includeTags:r,useTextContent:a,regex:n,prefixText:i,suffixText:o,filterEmpty:k,scrollDistance:D,scrollWaitMs:x,maxScrollAttempts:T});const I=await rt({selector:e,findBy:u,option:v});if(!I)return{data:""};const ae=Mn(r,a,n,i,o);if(Array.isArray(I)){const Q=I.map(ae);return{data:k?Q.filter(q=>q.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 hs(t){const{selector:e,findBy:r,option:a,includeTags:n,useTextContent:i,regex:o,prefixText:u,suffixText:v,filterEmpty:k,scrollDistance:C,scrollWaitMs:D,maxScrollAttempts:x}=t,T=Mn(n,i,o,u,v),I=new Set;let ae=0,Q=0;const pe=5;for(;ae<x;){const q=await rt({selector:e,findBy:r,option:a});if(q&&Array.isArray(q)){const U=I.size;if(q.forEach($=>{const V=T($);(!k||V.trim()!=="")&&I.add(V)}),I.size===U){if(Q++,Q>=pe)break}else Q=0}const R=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:C,behavior:"auto"}),await new Promise(U=>setTimeout(U,D)),(window.pageYOffset||document.documentElement.scrollTop)===R)break;ae++}return{data:Array.from(I)}}function Mn(t,e,r,a="",n=""){return i=>{let o="";if(t?o=i.innerHTML:o=e?i.textContent||"":i.innerText||"",r){const u=new RegExp(r,"g"),v=o.match(u);o=v?v.join(" "):""}return o.trim()&&(o=a+o.trim()+n),o}}const zr=tt.extend({name:b.literal("attribute-value"),attributeName:b.string()});function ps(t){return zr.parse(t)}async function ms(t){try{const{selector:e="",attributeName:r,findBy:a="cssSelector",option:n}=t;if(!e)throw new Error("Selector is required for attribute-value block");if(!r)throw new Error("Attribute name is required for attribute-value block");const i=await rt({selector:e,findBy:a,option:n});return i?{data:Array.isArray(i)?i.map(u=>u.getAttribute(r)).filter(u=>u!==null):i.getAttribute(r)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const Hr=tt.extend({name:b.literal("get-value-form"),type:b.enum(["text-field","select","checkbox"]).optional()});function gs(t){return Hr.parse(t)}async function ys(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for get-value-form block");const n=await rt({selector:e,findBy:a,option:t.option});if(!n)throw new Error("Form element not found");return{data:vs(n,r)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function vs(t,e){switch(e){case"text-field":if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)return t.value;break;case"select":if(t instanceof HTMLSelectElement)return t.value;break;case"checkbox":if(t instanceof HTMLInputElement&&t.type==="checkbox")return t.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const qr=tt.extend({name:b.literal("set-value-form"),setValue:b.string(),type:b.enum(["text-field","select","checkbox"]).optional()});function bs(t){return qr.parse(t)}async function ws(t){try{const{selector:e="",setValue:r,type:a="text-field",findBy:n="cssSelector"}=t;if(!e)throw new Error("Selector is required for set-value-form block");const i=await rt({selector:e,findBy:n,option:t.option});if(!i)throw new Error("Form element not found");return ks(i,r,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 ks(t,e,r){switch(r){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.value=e,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=e==="true"||e==="checked",t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${r}`)}}const Gr=tt.extend({name:b.literal("clear-value-form"),type:b.enum(["text-field","select","checkbox"]).optional()});function _s(t){return Gr.parse(t)}async function xs(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for clear-value-form block");const n=await rt({selector:e,findBy:a,option:t.option});if(!n)throw new Error("Form element not found");return Es(n,r),{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 Es(t,e){switch(e){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.selectedIndex=0,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=!1,t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Yr=tt.extend({name:b.literal("set-contenteditable"),setValue:b.string()});function As(t){return Yr.parse(t)}async function Ts(t){try{const{selector:e="",setValue:r,findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for set-contenteditable block");const n=await rt({selector:e,findBy:a,option:t.option});if(!n)throw new Error("Contenteditable element not found");if(!Ss(n))throw new Error("Target element is not contenteditable");return Ds(n,r),{data:"Contenteditable element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-contenteditable handler",data:null}}}function Ss(t){return t.isContentEditable||t.getAttribute("contenteditable")==="true"}function Ds(t,e){t.textContent=e,t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,data:e,inputType:"insertText"})),t.dispatchEvent(new Event("change",{bubbles:!0}))}const Kr=tt.extend({name:b.literal("element-exists")});function Os(t){return Kr.parse(t)}async function Cs(t){try{const{selector:e="",findBy:r="cssSelector",option:a}=t;if(!e)throw new Error("Selector is required for element-exists block");return{data:await rt({selector:e,findBy:r,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Jr=tt.extend({name:b.literal("event-click"),textFilter:b.object({text:b.union([b.string(),b.array(b.string())]),mode:b.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function Ps(t){return Jr.parse(t)}async function Ns(t){try{const{selector:e="",findBy:r="cssSelector",option:a,textFilter:n}=t;if(!e)throw new Error("Selector is required for event-click block");const i=await rt({selector:e,findBy:r,option:a});if(!i)throw new Error("Element not found for clicking");let o;if(Array.isArray(i))if(n){const u=Rs(i,n.text,n.mode);if(!u){const v=Array.isArray(n.text)?n.text.join(", "):n.text;throw new Error(`No element found with text filter: "${v}" (mode: ${n.mode})`)}o=u}else o=i[0];else o=i;return await Is(o),{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 Rs(t,e,r){for(const a of t){const n=Ms(a),i=Array.isArray(e)?e:[e];for(const o of i){let u=!1;switch(r){case"exact":u=n===o;break;case"contains":u=n.includes(o);break;case"startsWith":u=n.startsWith(o);break;case"endsWith":u=n.endsWith(o);break;case"regex":try{u=new RegExp(o).test(n)}catch{console.warn("Invalid regex pattern:",o);continue}break}if(u)return a}}return null}function Ms(t){if(t.innerText)return t.innerText.trim();if(t.textContent)return t.textContent.trim();if(t instanceof HTMLInputElement&&t.value)return t.value.trim();const e=t.getAttribute("placeholder");if(e)return e.trim();const r=t.getAttribute("title");if(r)return r.trim();const a=t.getAttribute("aria-label");return a?a.trim():""}function wn(t){const e=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,button:0}),r=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,view:window,button:0}),a=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window,button:0});t.dispatchEvent(e),t.dispatchEvent(r),t.dispatchEvent(a)}async function Is(t){t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(n=>setTimeout(n,50)),t.focus&&t.focus();const e=t.getBoundingClientRect(),r=e.left+e.width/2,a=e.top+e.height/2;try{const n=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:r,y:a}});if(n&&!n.$isError)console.log("[EventClick] CDP click successful:",n),wn(t);else throw new Error((n==null?void 0:n.message)||"CDP click failed")}catch(n){console.error("[EventClick] CDP click failed, falling back to native MouseEvent dispatch:",n),wn(t)}await new Promise(n=>setTimeout(n,50))}const Xr=b.object({name:b.literal("keypress"),key:b.string(),code:b.string().optional(),keyCode:b.number().optional(),modifiers:b.array(b.enum(["Alt","Control","Meta","Shift"])).optional()});function js(t){return Xr.parse(t)}async function Fs(t){try{const{key:e,code:r,keyCode:a,modifiers:n=[]}=t;return await Bs(e,r,a,n),{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 Bs(t,e,r,a=[]){try{const n=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:t,code:e||t,keyCode:r||Rr(t),modifiers:a}});if(n&&!n.$isError)console.log("[Keypress] CDP keypress successful:",n);else throw new Error((n==null?void 0:n.message)||"CDP keypress failed")}catch(n){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",n);const i=new KeyboardEvent("keydown",{key:t,code:e||t,keyCode:r||Rr(t),bubbles:!0,cancelable:!0,...kn(a)}),o=new KeyboardEvent("keyup",{key:t,code:e||t,keyCode:r||Rr(t),bubbles:!0,cancelable:!0,...kn(a)});document.dispatchEvent(i),await new Promise(u=>setTimeout(u,10)),document.dispatchEvent(o)}await new Promise(n=>setTimeout(n,50))}function Rr(t){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[t]||0}function kn(t){return{altKey:t.includes("Alt"),ctrlKey:t.includes("Control"),metaKey:t.includes("Meta"),shiftKey:t.includes("Shift")}}const Qr=b.object({name:b.literal("wait"),duration:b.number().min(0)});function Ls(t){return Qr.parse(t)}async function $s(t){try{const{duration:e}=t;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(r=>setTimeout(r,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 en=b.object({name:b.literal("wait-for-condition"),conditions:b.object({urlPattern:b.string().optional(),elementExists:b.object({selector:b.string(),findBy:b.enum(["cssSelector","xpath"])}).optional(),cookieExists:b.string().optional(),storageKey:b.object({type:b.enum(["localStorage","sessionStorage"]),key:b.string()}).optional(),userConfirmation:b.boolean().optional(),message:b.string().optional(),buttonText:b.string().optional()}).refine(t=>t.urlPattern!==void 0||t.elementExists!==void 0||t.cookieExists!==void 0||t.storageKey!==void 0||t.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:b.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:b.number().min(100).optional(),timeoutMs:b.number().min(1e3).optional(),position:b.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Us(t){return en.parse(t)}async function Zs(t){try{const{conditions:e,mode:r="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:n=3e5,position:i="bottom-right"}=t;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",r,"Timeout:",n);const o=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),u=e.userConfirmation===!0;let v=null,k=null;(r==="manual"||r==="auto-or-manual")&&u&&(v=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 C=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 T=null;if(x==="cssSelector"?T=document.querySelector(D):x==="xpath"&&(T=document.evaluate(D,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),T)return{success:!0,reason:"elementExists",message:`Element found: ${D}`}}if(e.cookieExists&&document.cookie.split(";").some(T=>{const[I]=T.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,T=!1;const I=()=>{x&&(clearInterval(x),x=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},ae=pe=>{T||(T=!0,I(),console.log("[WaitForCondition] Resolved with:",pe),D({data:pe}))},Q=setTimeout(()=>{ae({success:!1,reason:"timeout",message:`Timeout after ${n}ms`})},n);(r==="auto"||r==="auto-or-manual")&&o&&(x=setInterval(async()=>{const pe=await C();pe&&(clearTimeout(Q),ae(pe))},a)),(r==="manual"||r==="auto-or-manual")&&v&&v.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 tn=b.object({name:b.literal("navigate"),url:b.string().url("Valid URL is required"),waitForLoad:b.boolean().optional(),timeout:b.number().min(0).optional()});function Ws(t){return tn.parse(t)}async function Vs(t){try{const{url:e,waitForLoad:r=!0,timeout:a=3e4}=t;return console.log(`[Navigate] Navigating to: ${e}`),r?new Promise((n,i)=>{const o=setTimeout(()=>{i(new Error(`Navigation timeout after ${a}ms`))},a),u=()=>{clearTimeout(o),window.removeEventListener("load",u),console.log(`[Navigate] Page loaded: ${e}`),n({data:!0})};document.readyState==="complete"?(clearTimeout(o),console.log(`[Navigate] Page already loaded: ${e}`),n({data:!0})):window.addEventListener("load",u),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 rn=tt.extend({name:b.literal("save-assets")});function zs(t){return rn.parse(t)}async function Hs(t){try{const{selector:e="img, audio, video, source",findBy:r="cssSelector",option:a}=t,n=await rt({selector:e,findBy:r,option:a});if(!n||!Array.isArray(n))return{data:[]};const i=[];return n.forEach(o=>{let u="";(o instanceof HTMLImageElement||o instanceof HTMLAudioElement||o instanceof HTMLVideoElement||o instanceof HTMLSourceElement)&&(u=o.src),u&&!i.includes(u)&&i.push(u)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class qs{static generate(e){var n;const r=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const o=Array.from(((n=a.parentElement)==null?void 0:n.children)||[]).filter(v=>v.tagName===a.tagName);if(o.length>1){const v=o.indexOf(a)+1;i+=`[${v}]`}const u=this.getStableAttributes(a);u.length>0&&(i+=`[@${u.join(" and @")}]`),r.unshift(i),a=a.parentElement}return"/"+r.join("/")}static getStableAttributes(e){const r=[],a=["data-testid","aria-label","title","alt","role"];for(const n of a){const i=e.getAttribute(n);i&&!this.isDynamicValue(i)&&r.push(`${n}="${i}"`)}return r}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 nn=tt.extend({name:b.literal("get-element-data"),includeText:b.boolean().optional(),includeTags:b.boolean().optional(),useTextContent:b.boolean().optional(),regex:b.string().optional(),prefixText:b.string().optional(),suffixText:b.string().optional(),attributes:b.array(b.string()).optional(),includeSelector:b.boolean().optional(),includeXPath:b.boolean().optional()});function Gs(t){return nn.parse(t)}async function Ys(t){try{const{selector:e="",includeText:r=!0,includeTags:a=!1,useTextContent:n=!1,regex:i,prefixText:o="",suffixText:u="",attributes:v=[],includeSelector:k=!1,includeXPath:C=!1,findBy:D="cssSelector",option:x}=t;if(!e)throw new Error("Selector is required for get-element-data block");if(!r&&v.length===0)throw new Error("Either includeText must be true or attributes must be provided");const T=await rt({selector:e,findBy:D,option:x});if(!T)return{data:Array.isArray(T)?[]:{}};const I=Ks(r,a,n,i,o,u,v,k,C);return Array.isArray(T)?{data:T.map(I)}:{data:I(T)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function Ks(t,e,r,a,n="",i="",o=[],u=!1,v=!1){return k=>{const C={};if(t){let D="";if(e?D=k.innerHTML:D=r?k.textContent||"":k.innerText||"",a){const x=new RegExp(a,"g"),T=D.match(x);D=T?T.join(" "):""}D.trim()&&(D=n+D.trim()+i),C.text=D}return o.length>0&&(C.attributes={},o.forEach(D=>{let x=k.getAttribute(D);if(x===null){const T=k.querySelector(`[${D}]`);T&&(x=T.getAttribute(D))}C.attributes[D]=x})),u&&(C.selector=ls.generate(k)),v&&(C.xpath=qs.generate(k)),C}}const an=tt.extend({name:b.literal("scroll"),scrollType:b.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:b.number().optional(),behavior:b.enum(["auto","smooth"]).optional(),maxScrolls:b.number().optional(),waitAfterScroll:b.number().optional()});function Js(t){return an.parse(t)}async function Xs(t){try{const{selector:e="",scrollType:r="toBottom",distance:a=500,behavior:n="smooth",maxScrolls:i=50,waitAfterScroll:o=300,findBy:u="cssSelector",option:v}=t;switch(r){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Qs(e,u,v,n);case"toBottom":return await ei(n,o);case"byDistance":return await ti(a,n);case"untilLoaded":return await ri(i,a,n,o);default:throw new Error(`Unknown scroll type: ${r}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Qs(t,e,r,a){const n=await rt({selector:t,findBy:e,option:r});return n?((Array.isArray(n)?n[0]:n).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function ei(t,e){let r=document.body.scrollHeight,a=0;const n=50;for(;a<n;){window.scrollTo({top:document.body.scrollHeight,behavior:t}),await new Promise(o=>setTimeout(o,e));const i=document.body.scrollHeight;if(i===r)break;r=i,a++}return{data:!0}}async function ti(t,e){return window.scrollBy({top:t,behavior:e}),{data:!0}}async function ri(t,e,r,a){let n=0,i=document.body.scrollHeight;for(;n<t;){window.scrollBy({top:e,behavior:r}),await new Promise(k=>setTimeout(k,a));const o=document.body.scrollHeight,u=window.pageYOffset||document.documentElement.scrollTop,v=window.innerHeight;if(u+v>=o-10&&o===i)break;i=o,n++}return{data:!0}}const sn=b.object({name:b.literal("fetch-api"),url:b.string(),method:b.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:b.record(b.string(),b.string()).optional(),body:b.record(b.string(),b.any()).optional(),timeout:b.number().min(0).optional(),parseJson:b.boolean().optional(),returnHeaders:b.boolean().optional()});function ni(t){return sn.parse(t)}async function ai(t){try{console.log("[FetchApiBlock] Sending API request to background:",t.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:t.url,method:t.method||"GET",headers:t.headers||{},body:t.body,timeout:t.timeout||3e4,parseJson:t.parseJson??!0,returnHeaders:t.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 _n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function si(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function _r(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Mr={exports:{}},xn;function ii(){return xn||(xn=1,(function(t,e){(function(r){t.exports=r()})(function(){return(function(){function r(a,n,i){function o(k,C){if(!n[k]){if(!a[k]){var D=typeof _r=="function"&&_r;if(!C&&D)return D(k,!0);if(u)return u(k,!0);var x=new Error("Cannot find module '"+k+"'");throw x.code="MODULE_NOT_FOUND",x}var T=n[k]={exports:{}};a[k][0].call(T.exports,function(I){var ae=a[k][1][I];return o(ae||I)},T,T.exports,r,a,n,i)}return n[k].exports}for(var u=typeof _r=="function"&&_r,v=0;v<i.length;v++)o(i[v]);return o}return r})()({1:[function(r,a,n){const i=r("./utils"),o=(function(){const u=i.stringToArray,v=["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"],C=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],D=["Thousand","Million","Billion","Trillion"];function x(w,S){var _=function(B,j,O){var F="";if(B<=19)F=(j?" and ":"")+(O?k[B]:v[B]);else if(B<100){const ye=Math.floor(B/10),we=B%10;F=(j?" and ":"")+C[ye-2],we>0?F+="-"+_(we,!1,O):O&&(F=F.substring(0,F.length-1)+"ieth")}else if(B<1e3){const ye=Math.floor(B/100),we=B%100;F=(j?", ":"")+v[ye]+" Hundred",we>0?F+=_(we,!0,O):O&&(F+="th")}else{var J=Math.floor(Math.log10(B)/3);J>D.length&&(J=D.length);const ye=Math.pow(10,J*3),we=Math.floor(B/ye),K=B-we*ye;F=(j?", ":"")+_(we,!1,!1)+" "+D[J-1],K>0?F+=_(K,!0,O):O&&(F+="th")}return F},N=_(w,!1,S);return N}const T={};v.forEach(function(w,S){T[w.toLowerCase()]=S}),k.forEach(function(w,S){T[w.toLowerCase()]=S}),C.forEach(function(w,S){const _=w.toLowerCase();T[_]=(S+2)*10,T[_.substring(0,w.length-1)+"ieth"]=T[_]}),T.hundredth=100,D.forEach(function(w,S){const _=w.toLowerCase(),N=Math.pow(10,(S+1)*3);T[_]=N,T[_+"th"]=N});function I(w){const _=w.split(/,\s|\sand\s|[\s\\-]/).map(j=>T[j]);let N=[0];return _.forEach(j=>{if(j<100){let O=N.pop();O>=1e3&&(N.push(O),O=0),N.push(O+j)}else N.push(N.pop()*j)}),N.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(w){for(var S=0;S<ae.length;S++){const _=ae[S];if(w>=_[0])return _[1]+pe(w-_[0])}return""}function q(w){for(var S=0,_=1,N=w.length-1;N>=0;N--){const B=w[N],j=Q[B];j<_?S-=j:(_=j,S+=j)}return S}function R(w,S){for(var _=[],N=S.charCodeAt(0);w>0;)_.unshift(String.fromCharCode((w-1)%26+N)),w=Math.floor((w-1)/26);return _.join("")}function se(w,S){for(var _=S.charCodeAt(0),N=0,B=0;B<w.length;B++)N+=(w.charCodeAt(w.length-B-1)-_+1)*Math.pow(26,B);return N}function U(w,S){if(typeof w>"u")return;w=Math.floor(w);const _=_e(S);return V(w,_)}const A={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},$={UPPER:"upper",LOWER:"lower",TITLE:"title"};function V(w,S){let _;const N=w<0;switch(w=Math.abs(w),S.primary){case A.LETTERS:_=R(w,S.case===$.UPPER?"A":"a");break;case A.ROMAN:_=pe(w),S.case===$.UPPER&&(_=_.toUpperCase());break;case A.WORDS:_=x(w,S.ordinal),S.case===$.UPPER?_=_.toUpperCase():S.case===$.LOWER&&(_=_.toLowerCase());break;case A.DECIMAL:_=""+w;var B=S.mandatoryDigits-_.length;if(B>0){var j=new Array(B+1).join("0");_=j+_}if(S.zeroCode!==48&&(_=u(_).map(ye=>String.fromCodePoint(ye.codePointAt(0)+S.zeroCode-48)).join("")),S.regular){const ye=Math.floor((_.length-1)/S.groupingSeparators.position);for(let we=ye;we>0;we--){const K=_.length-we*S.groupingSeparators.position;_=_.substr(0,K)+S.groupingSeparators.character+_.substr(K)}}else S.groupingSeparators.reverse().forEach(ye=>{const we=_.length-ye.position;_=_.substr(0,we)+ye.character+_.substr(we)});if(S.ordinal){var O={1:"st",2:"nd",3:"rd"},F=_[_.length-1],J=O[F];(!J||_.length>1&&_[_.length-2]==="1")&&(J="th"),_=_+J}break;case A.SEQUENCE:throw{code:"D3130",value:S.token}}return N&&(_="-"+_),_}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 _e(w){const S={type:"integer",primary:A.DECIMAL,case:$.LOWER,ordinal:!1};let _,N;const B=w.lastIndexOf(";");switch(B===-1?_=w:(_=w.substring(0,B),N=w.substring(B+1),N[0]==="o"&&(S.ordinal=!0)),_){case"A":S.case=$.UPPER;case"a":S.primary=A.LETTERS;break;case"I":S.case=$.UPPER;case"i":S.primary=A.ROMAN;break;case"W":S.case=$.UPPER,S.primary=A.WORDS;break;case"Ww":S.case=$.TITLE,S.primary=A.WORDS;break;case"w":S.primary=A.WORDS;break;default:{let j=null,O=0,F=0,J=[],ye=0;if(u(_).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++,ye++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}ee||(K===35?(ye++,F++):J.push({position:ye,character:String.fromCodePoint(K)}))}),O>0){S.primary=A.DECIMAL,S.zeroCode=j,S.mandatoryDigits=O,S.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),lt=function($e,qe){return qe===0?$e:lt(qe,$e%qe)},He=Ze.reduce(lt);for(let $e=1;$e<=Ze.length;$e++)if(Ze.indexOf($e*He)===-1)return 0;return He}(J);ee>0?(S.regular=!0,S.groupingSeparators={position:ee,character:J[0].character}):(S.regular=!1,S.groupingSeparators=J)}else S.primary=A.SEQUENCE,S.token=_}}return S}const Ae={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 Te(w){var S=[];const _={type:"datetime",parts:S},N=function(ee,me){if(me>ee){let G=w.substring(ee,me);G=G.split("]]").join("]"),S.push({type:"literal",value:G})}};for(var B=0,j=0;j<w.length;){if(w.charAt(j)==="["){if(w.charAt(j+1)==="["){N(B,j),S.push({type:"literal",value:"["}),j+=2,B=j;continue}if(N(B,j),B=j,j=w.indexOf("]",B),j===-1)throw{code:"D3135"};let ee=w.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,lt;const He=function(qe){if(!(typeof qe>"u"||qe==="*"))return parseInt(qe)};G===-1?Ze=me:(Ze=me.substring(0,G),lt=me.substring(G+1));const $e={min:He(Ze),max:He(lt)};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 ye=J.charAt(J.length-1);"atco".indexOf(ye)!==-1?(O.presentation2=ye,ye==="o"&&(O.ordinal=!0),O.presentation1=J.substring(0,J.length-1)):O.presentation1=J}else O.presentation1=Ae[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=_e(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=S[S.length-1];me&&me.integerFormat&&(me.integerFormat.parseWidth=me.integerFormat.mandatoryDigits)}(O.component==="Z"||O.component==="z")&&(O.integerFormat=_e(O.presentation1)),S.push(O),B=j+1}j++}return N(B,j),_}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Me=["January","February","March","April","May","June","July","August","September","October","November","December"],nt=1e3*60*60*24,xe=function(w){const S=Date.UTC(w.year,w.month);var _=new Date(S).getUTCDay();return _===0&&(_=7),_>4?S+(8-_)*nt:S-(_-1)*nt},fe=function(w,S){return{year:w,month:S,nextMonth:function(){return S===11?fe(w+1,0):fe(w,S+1)},previousMonth:function(){return S===0?fe(w-1,11):fe(w,S-1)},nextYear:function(){return fe(w+1,S)},previousYear:function(){return fe(w-1,S)}}},at=function(w,S){return(S-w)/(nt*7)+1},ie=(w,S)=>{let _;switch(S){case"Y":_=w.getUTCFullYear();break;case"M":_=w.getUTCMonth()+1;break;case"D":_=w.getUTCDate();break;case"d":{const N=Date.UTC(w.getUTCFullYear(),w.getUTCMonth(),w.getUTCDate()),B=Date.UTC(w.getUTCFullYear(),0);_=(N-B)/nt+1;break}case"F":_=w.getUTCDay(),_===0&&(_=7);break;case"W":{const N=fe(w.getUTCFullYear(),0),B=xe(N),j=Date.UTC(N.year,w.getUTCMonth(),w.getUTCDate());let O=at(B,j);if(O>52){const F=xe(N.nextYear());j>=F&&(O=1)}else if(O<1){const F=xe(N.previousYear());O=at(F,j)}_=Math.floor(O);break}case"w":{const N=fe(w.getUTCFullYear(),w.getUTCMonth()),B=xe(N),j=Date.UTC(N.year,N.month,w.getUTCDate());let O=at(B,j);if(O>4){const F=xe(N.nextMonth());j>=F&&(O=1)}else if(O<1){const F=xe(N.previousMonth());O=at(F,j)}_=Math.floor(O);break}case"X":{const N=fe(w.getUTCFullYear(),0),B=xe(N),j=xe(N.nextYear()),O=w.getTime();O<B?_=N.year-1:O>=j?_=N.year+1:_=N.year;break}case"x":{const N=fe(w.getUTCFullYear(),w.getUTCMonth()),B=xe(N),j=N.nextMonth(),O=xe(j),F=w.getTime();F<B?_=N.previousMonth().month+1:F>=O?_=j.month+1:_=N.month+1;break}case"H":_=w.getUTCHours();break;case"h":_=w.getUTCHours(),_=_%12,_===0&&(_=12);break;case"P":_=w.getUTCHours()>=12?"pm":"am";break;case"m":_=w.getUTCMinutes();break;case"s":_=w.getUTCSeconds();break;case"f":_=w.getUTCMilliseconds();break;case"Z":case"z":break;case"C":_="ISO";break;case"E":_="ISO";break}return _};let Be=null;function ct(w,S,_){var N=0,B=0;if(typeof _<"u"){const we=parseInt(_);N=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=Me[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=V(ee,K.integerFormat);else if(K.component==="f")ee=V(ee,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const me=N*100+B;if(K.integerFormat.regular)ee=V(me,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)ee=V(N,K.integerFormat),B!==0&&(ee+=":"+U(B,"00"));else if(G===3||G===4)ee=V(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 S>"u"?(Be===null&&(Be=Te("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),O=Be):O=Te(S);const F=(60*N+B)*60*1e3,J=new Date(w+F);let ye="";return O.parts.forEach(function(we){we.type==="literal"?ye+=we.value:ye+=j(J,we)}),ye}function d(w){var S={};if(w.type==="datetime")S.type="datetime",S.parts=w.parts.map(function(_){var N={};if(_.type==="literal")N.regex=_.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(_.component==="Z"||_.component==="z"){let j;Array.isArray(_.integerFormat.groupingSeparators)||(j=_.integerFormat.groupingSeparators),N.regex="",_.component==="z"&&(N.regex="GMT"),N.regex+="[-+][0-9]+",j&&(N.regex+=j.character+"[0-9]+"),N.parse=function(O){_.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(_.integerFormat)N=d(_.integerFormat);else{N.regex="[a-zA-Z]+";var B={};if(_.component==="M"||_.component==="x")Me.forEach(function(j,O){_.width&&_.width.max?B[j.substring(0,_.width.max)]=O+1:B[j]=O+1});else if(_.component==="F")ve.forEach(function(j,O){O>0&&(_.width&&_.width.max?B[j.substring(0,_.width.max)]=O:B[j]=O)});else if(_.component==="P")B={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:_.component};N.parse=function(j){return B[j]}}return N.component=_.component,N});else{S.type="integer";const _=w.case===$.UPPER;switch(w.primary){case A.LETTERS:S.regex=_?"[A-Z]+":"[a-z]+",S.parse=function(N){return se(N,_?"A":"a")};break;case A.ROMAN:S.regex=_?"[MDCLXVI]+":"[mdclxvi]+",S.parse=function(N){return q(_?N:N.toUpperCase())};break;case A.WORDS:S.regex="(?:"+Object.keys(T).concat("and","[\\-, ]").join("|")+")+",S.parse=function(N){return I(N.toLowerCase())};break;case A.DECIMAL:S.regex="[0-9]",w.parseWidth?S.regex+=`{${w.parseWidth}}`:S.regex+="+",w.ordinal&&(S.regex+="(?:th|st|nd|rd)"),S.parse=function(N){let B=N;return w.ordinal&&(B=N.substring(0,N.length-2)),w.regular?B=B.split(",").join(""):w.groupingSeparators.forEach(j=>{B=B.split(j.character).join("")}),w.zeroCode!==48&&(B=B.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-w.zeroCode+48)).join("")),parseInt(B)};break;case A.SEQUENCE:throw{code:"D3130",value:w.token}}}return S}function m(w,S){if(typeof w>"u")return;const _=_e(S);return d(_).parse(w)}function z(w,S){const _=Te(S),N=d(_),B="^"+N.parts.map(J=>"("+J.regex+")").join("")+"$";var O=new RegExp(B,"i").exec(w);if(O!==null){const G={};for(let De=1;De<O.length;De++){const l=N.parts[De-1];l.parse&&(G[l.component]=l.parse(O[De]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ze=0;const lt=De=>{Ze<<=1,Ze+=De?1:0},He=De=>!(~De&Ze)&&!!(De&Ze);"YXMxWwdD".split("").forEach(De=>lt(G[De]));const qe=!He(161)&&He(130),wt=He(84),Tt=!wt&&He(72);Ze=0,"PHhmsf".split("").forEach(De=>lt(G[De]));const St=!He(23)&&He(47),Jt=(qe?"YD":wt?"XxwF":Tt?"XWF":"YMD")+(St?"Phmsf":"Hmsf"),ft=this.environment.timestamp;let Ut=!1,gt=!1;if(Jt.split("").forEach(De=>{if(typeof G[De]>"u")Ut?(G[De]="MDd".indexOf(De)!==-1?1:0,gt=!0):G[De]=ie(ft,De);else if(Ut=!0,gt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,qe){const De=Date.UTC(G.Y,0),l=(G.d-1)*1e3*60*60*24,h=new Date(De+l);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(wt)throw{code:"D3136"};if(Tt)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(w,S){if(!(typeof w>"u"))if(typeof S>"u"){if(!de.test(w))throw{stack:new Error().stack,code:"D3110",value:w};return Date.parse(w)}else return z.call(this,w,S)}function Ee(w,S,_){if(!(typeof w>"u"))return ct.call(this,w,S,_)}return{formatInteger:U,parseInteger:m,fromMillis:Ee,toMillis:Pe}})();a.exports=o},{"./utils":6}],2:[function(r,a,n){(function(i){(function(){var o=r("./utils");const u=(()=>{var v=o.isNumeric,k=o.isArrayOfStrings,C=o.isArrayOfNumbers,D=o.createSequence,x=o.isSequence,T=o.isFunction,I=o.isLambda,ae=o.isPromise,Q=o.getFunctionArity,pe=o.isDeepEqual,q=o.stringToArray;function R(s){if(!(typeof s>"u")){var c=0;return s.forEach(function(f){c+=f}),c}}function se(s){return typeof s>"u"?0:s.length}function U(s){if(!(typeof s>"u"||s.length===0))return Math.max.apply(Math,s)}function A(s){if(!(typeof s>"u"||s.length===0))return Math.min.apply(Math,s)}function $(s){if(!(typeof s>"u"||s.length===0)){var c=0;return s.forEach(function(f){c+=f}),c/s.length}}function V(s,c=!1){if(!(typeof s>"u")){var f;if(typeof s=="string")f=s;else if(T(s))f="";else{if(typeof s=="number"&&!isFinite(s))throw{code:"D3001",value:s,stack:new Error().stack};var y=c?2:0;Array.isArray(s)&&s.outerWrapper&&(s=s[0]),f=JSON.stringify(s,function(p,E){return typeof E<"u"&&E!==null&&E.toPrecision&&v(E)?Number(E.toPrecision(15)):E&&T(E)?"":E},y)}return f}}function he(s,c,f){if(!(typeof s>"u")){var y=q(s),p=y.length;if(p+c<0&&(c=0),typeof f<"u"){if(f<=0)return"";var E=c>=0?c+f:p+c+f;return y.slice(c,E).join("")}return y.slice(c).join("")}}function _e(s,c){if(!(typeof s>"u")){var f=s.indexOf(c);return f>-1?s.substr(0,f):s}}function Ae(s,c){if(!(typeof s>"u")){var f=s.indexOf(c);return f>-1?s.substr(f+c.length):s}}function Te(s){if(!(typeof s>"u"))return s.toLowerCase()}function ve(s){if(!(typeof s>"u"))return s.toUpperCase()}function Me(s){if(!(typeof s>"u"))return q(s).length}function nt(s){if(!(typeof s>"u")){var c=s.replace(/[ \t\n\r]+/gm," ");return c.charAt(0)===" "&&(c=c.substring(1)),c.charAt(c.length-1)===" "&&(c=c.substring(0,c.length-1)),c}}function xe(s,c,f){if(!(typeof s>"u")){(typeof f>"u"||f.length===0)&&(f=" ");var y;c=Math.trunc(c);var p=Math.abs(c)-Me(s);if(p>0){var E=new Array(p+1).join(f);f.length>1&&(E=he(E,0,p)),c>0?y=s+E:y=E+s}else y=s;return y}}async function fe(s,c){var f=s.apply(this,[c]);if(ae(f)&&(f=await f),f&&!(typeof f.start=="number"||f.end==="number"||Array.isArray(f.groups)||T(f.next)))throw{code:"T1010",stack:new Error().stack};return f}async function at(s,c){if(!(typeof s>"u")){var f;if(typeof c=="string")f=s.indexOf(c)!==-1;else{var y=await fe(c,s);f=typeof y<"u"}return f}}async function ie(s,c,f){if(!(typeof s>"u")){if(f<0)throw{stack:new Error().stack,value:f,code:"D3040",index:3};var y=D();if(typeof f>"u"||f>0){var p=0,E=await fe(c,s);if(typeof E<"u")for(;typeof E<"u"&&(typeof f>"u"||p<f);)y.push({match:E.match,index:E.start,groups:E.groups}),E=await fe(E.next),p++}return y}}async function Be(s,c,f,y){if(!(typeof s>"u")){var p=this;if(c==="")throw{code:"D3010",stack:new Error().stack,value:c,index:2};if(y<0)throw{code:"D3011",stack:new Error().stack,value:y,index:4};var E;typeof f=="string"?E=function(Se){for(var We="",ke=0,Fe=f.indexOf("$",ke);Fe!==-1&&ke<f.length;){We+=f.substring(ke,Fe),ke=Fe+1;var ut=f.charAt(ke);if(ut==="$")We+="$",ke++;else if(ut==="0")We+=Se.match,ke++;else{var Ve;if(Se.groups.length===0?Ve=1:Ve=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,Fe=parseInt(f.substring(ke,ke+Ve),10),Ve>1&&Fe>Se.groups.length&&(Fe=parseInt(f.substring(ke,ke+Ve-1),10)),isNaN(Fe))We+="$";else{if(Se.groups.length>0){var Zt=Se.groups[Fe-1];typeof Zt<"u"&&(We+=Zt)}ke+=Fe.toString().length}}Fe=f.indexOf("$",ke)}return We+=f.substring(ke),We}:E=f;var M="",H=0;if(typeof y>"u"||y>0){var X=0;if(typeof c=="string"){for(var Oe=s.indexOf(c,H);Oe!==-1&&(typeof y>"u"||X<y);)M+=s.substring(H,Oe),M+=f,H=Oe+c.length,X++,Oe=s.indexOf(c,H);M+=s.substring(H)}else{var ge=await fe(c,s);if(typeof ge<"u"){for(;typeof ge<"u"&&(typeof y>"u"||X<y);){M+=s.substring(H,ge.start);var Ne=E.apply(p,[ge]);if(ae(Ne)&&(Ne=await Ne),typeof Ne=="string")M+=Ne;else throw{code:"D3012",stack:new Error().stack,value:Ne};H=ge.start+ge.match.length,X++,ge=await fe(ge.next)}M+=s.substring(H)}else M=s}}else M=s;return M}}function ct(s){if(!(typeof s>"u")){var c=typeof window<"u"?window.btoa:function(f){return new i.Buffer.from(f,"binary").toString("base64")};return c(s)}}function d(s){if(!(typeof s>"u")){var c=typeof window<"u"?window.atob:function(f){return new i.Buffer.from(f,"base64").toString("binary")};return c(s)}}function m(s){if(!(typeof s>"u")){var c;try{c=encodeURIComponent(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"encodeUrlComponent"}}return c}}function z(s){if(!(typeof s>"u")){var c;try{c=encodeURI(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"encodeUrl"}}return c}}function de(s){if(!(typeof s>"u")){var c;try{c=decodeURIComponent(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"decodeUrlComponent"}}return c}}function Pe(s){if(!(typeof s>"u")){var c;try{c=decodeURI(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"decodeUrl"}}return c}}async function Ee(s,c,f){if(!(typeof s>"u")){if(f<0)throw{code:"D3020",stack:new Error().stack,value:f,index:3};var y=[];if(typeof f>"u"||f>0)if(typeof c=="string")y=s.split(c,f);else{var p=0,E=await fe(c,s);if(typeof E<"u"){for(var M=0;typeof E<"u"&&(typeof f>"u"||p<f);)y.push(s.substring(M,E.start)),M=E.end,E=await fe(E.next),p++;(typeof f>"u"||p<f)&&y.push(s.substring(M))}else y.push(s)}return y}}function w(s,c){if(!(typeof s>"u"))return typeof c>"u"&&(c=""),s.join(c)}function S(s,c,f){if(!(typeof s>"u")){var y={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},p=y;typeof f<"u"&&Object.keys(f).forEach(function(re){p[re]=f[re]});for(var E=[],M=p["zero-digit"].charCodeAt(0),H=M;H<M+10;H++)E.push(String.fromCharCode(H));var X=E.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),Oe=c.split(p["pattern-separator"]);if(Oe.length>2)throw{code:"D3080",stack:new Error().stack};var ge=function(re){var Ie=(function(){for(var Ue,it=0;it<re.length;it++)if(Ue=re.charAt(it),X.indexOf(Ue)!==-1&&Ue!==p["exponent-separator"])return re.substring(0,it)})(),Ye=(function(){for(var Ue,it=re.length-1;it>=0;it--)if(Ue=re.charAt(it),X.indexOf(Ue)!==-1&&Ue!==p["exponent-separator"])return re.substring(it+1)})(),Re=re.substring(Ie.length,re.length-Ye.length),Qe,Dt,et,It,st=re.indexOf(p["exponent-separator"],Ie.length);st===-1||st>re.length-Ye.length?(Qe=Re,Dt=void 0):(Qe=Re.substring(0,st),Dt=Re.substring(st+1));var dt=Qe.indexOf(p["decimal-separator"]);return dt===-1?(et=Qe,It=Ye):(et=Qe.substring(0,dt),It=Qe.substring(dt+1)),{prefix:Ie,suffix:Ye,activePart:Re,mantissaPart:Qe,exponentPart:Dt,integerPart:et,fractionalPart:It,subpicture:re}},Ne=function(re){var Ie,Ye,Re=re.subpicture,Qe=Re.indexOf(p["decimal-separator"]);Qe!==Re.lastIndexOf(p["decimal-separator"])&&(Ie="D3081"),Re.indexOf(p.percent)!==Re.lastIndexOf(p.percent)&&(Ie="D3082"),Re.indexOf(p["per-mille"])!==Re.lastIndexOf(p["per-mille"])&&(Ie="D3083"),Re.indexOf(p.percent)!==-1&&Re.indexOf(p["per-mille"])!==-1&&(Ie="D3084");var Dt=!1;for(Ye=0;Ye<re.mantissaPart.length;Ye++){var et=re.mantissaPart.charAt(Ye);if(E.indexOf(et)!==-1||et===p.digit){Dt=!0;break}}Dt||(Ie="D3085");var It=re.activePart.split("").map(function(Ue){return X.indexOf(Ue)===-1?"p":"a"}).join("");It.indexOf("p")!==-1&&(Ie="D3086"),Qe!==-1?(Re.charAt(Qe-1)===p["grouping-separator"]||Re.charAt(Qe+1)===p["grouping-separator"])&&(Ie="D3087"):re.integerPart.charAt(re.integerPart.length-1)===p["grouping-separator"]&&(Ie="D3088"),Re.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Ie="D3089");var st=re.integerPart.indexOf(p.digit);st!==-1&&re.integerPart.substring(0,st).split("").filter(function(Ue){return E.indexOf(Ue)>-1}).length>0&&(Ie="D3090"),st=re.fractionalPart.lastIndexOf(p.digit),st!==-1&&re.fractionalPart.substring(st).split("").filter(function(Ue){return E.indexOf(Ue)>-1}).length>0&&(Ie="D3091");var dt=typeof re.exponentPart=="string";if(dt&&re.exponentPart.length>0&&(Re.indexOf(p.percent)!==-1||Re.indexOf(p["per-mille"])!==-1)&&(Ie="D3092"),dt&&(re.exponentPart.length===0||re.exponentPart.split("").filter(function(Ue){return E.indexOf(Ue)===-1}).length>0)&&(Ie="D3093"),Ie)throw{code:Ie,stack:new Error().stack}},Se=function(re){var Ie=function(ze,wr){for(var er=[],kt=ze.indexOf(p["grouping-separator"]);kt!==-1;){var kr=(wr?ze.substring(0,kt):ze.substring(kt)).split("").filter(function(Vt){return E.indexOf(Vt)!==-1||Vt===p.digit}).length;er.push(kr),kt=re.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Ie(re.integerPart),Re=function(ze){if(ze.length===0)return 0;for(var wr=function(kr,Vt){return Vt===0?kr:wr(Vt,kr%Vt)},er=ze.reduce(wr),kt=1;kt<=ze.length;kt++)if(ze.indexOf(kt*er)===-1)return 0;return er},Qe=Re(Ye),Dt=Ie(re.fractionalPart,!0),et=re.integerPart.split("").filter(function(ze){return E.indexOf(ze)!==-1}).length,It=et,st=re.fractionalPart.split(""),dt=st.filter(function(ze){return E.indexOf(ze)!==-1}).length,Ue=st.filter(function(ze){return E.indexOf(ze)!==-1||ze===p.digit}).length,it=typeof re.exponentPart=="string";et===0&&Ue===0&&(it?(dt=1,Ue=1):et=1),it&&et===0&&re.integerPart.indexOf(p.digit)!==-1&&(et=1),et===0&&dt===0&&(dt=1);var gn=0;return it&&(gn=re.exponentPart.split("").filter(function(ze){return E.indexOf(ze)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Qe,minimumIntegerPartSize:et,scalingFactor:It,prefix:re.prefix,fractionalPartGroupingPositions:Dt,minimumFactionalPartSize:dt,maximumFactionalPartSize:Ue,minimumExponentSize:gn,suffix:re.suffix,picture:re.subpicture}},We=Oe.map(ge);We.forEach(Ne);var ke=We.map(Se),Fe=p["minus-sign"],ut=p["zero-digit"],Ve=p["decimal-separator"],Zt=p["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=Fe+ke[1].prefix);var Le;s>=0?Le=ke[0]:Le=ke[1];var Xt;Le.picture.indexOf(p.percent)!==-1?Xt=s*100:Le.picture.indexOf(p["per-mille"])!==-1?Xt=s*1e3:Xt=s;var Mt,Wt;if(Le.minimumExponentSize===0)Mt=Xt;else{var Un=Math.pow(10,Le.scalingFactor),Zn=Math.pow(10,Le.scalingFactor-1);for(Mt=Xt,Wt=0;Mt<Zn;)Mt*=10,Wt-=1;for(;Mt>Un;)Mt/=10,Wt+=1}var Wn=F(Mt,Le.maximumFactionalPartSize),pn=function(re,Ie){var Ye=Math.abs(re).toFixed(Ie);return ut!=="0"&&(Ye=Ye.split("").map(function(Re){return Re>="0"&&Re<="9"?E[Re.charCodeAt(0)-48]:Re}).join("")),Ye},ce=pn(Wn,Le.maximumFactionalPartSize),Ge=ce.indexOf(".");for(Ge===-1?ce=ce+Ve:ce=ce.replace(".",Ve);ce.charAt(0)===ut;)ce=ce.substring(1);for(;ce.charAt(ce.length-1)===ut;)ce=ce.substring(0,ce.length-1);Ge=ce.indexOf(Ve);var Qt=Le.minimumIntegerPartSize-Ge,mn=Le.minimumFactionalPartSize-(ce.length-Ge-1);if(ce=(Qt>0?new Array(Qt+1).join(ut):"")+ce,ce=ce+(mn>0?new Array(mn+1).join(ut):""),Ge=ce.indexOf(Ve),Le.regularGrouping>0)for(var Vn=Math.floor((Ge-1)/Le.regularGrouping),vr=1;vr<=Vn;vr++)ce=[ce.slice(0,Ge-vr*Le.regularGrouping),Zt,ce.slice(Ge-vr*Le.regularGrouping)].join("");else Le.integerPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,Ge-re),Zt,ce.slice(Ge-re)].join(""),Ge++});if(Ge=ce.indexOf(Ve),Le.fractionalPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,re+Ge+1),Zt,ce.slice(re+Ge+1)].join("")}),Ge=ce.indexOf(Ve),(Le.picture.indexOf(Ve)===-1||Ge===ce.length-1)&&(ce=ce.substring(0,ce.length-1)),typeof Wt<"u"){var br=pn(Wt,0);Qt=Le.minimumExponentSize-br.length,Qt>0&&(br=new Array(Qt+1).join(ut)+br),ce=ce+p["exponent-separator"]+(Wt<0?Fe:"")+br}return ce=Le.prefix+ce+Le.suffix,ce}}function _(s,c){if(!(typeof s>"u")){if(s=F(s),typeof c>"u"?c=10:c=F(c),c<2||c>36)throw{code:"D3100",stack:new Error().stack,value:c};var f=s.toString(c);return f}}function N(s){var c;if(!(typeof s>"u")){if(typeof s=="number")c=s;else if(typeof s=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(s)&&!isNaN(parseFloat(s))&&isFinite(s))c=parseFloat(s);else if(typeof s=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(s))c=Number(s);else if(s===!0)c=1;else if(s===!1)c=0;else throw{code:"D3030",value:s,stack:new Error().stack,index:1};return c}}function B(s){var c;if(!(typeof s>"u"))return c=Math.abs(s),c}function j(s){var c;if(!(typeof s>"u"))return c=Math.floor(s),c}function O(s){var c;if(!(typeof s>"u"))return c=Math.ceil(s),c}function F(s,c){var f;if(!(typeof s>"u")){if(c){var y=s.toString().split("e");s=+(y[0]+"e"+(y[1]?+y[1]+c:c))}f=Math.round(s);var p=f-s;return Math.abs(p)===.5&&Math.abs(f%2)===1&&(f=f-1),c&&(y=f.toString().split("e"),f=+(y[0]+"e"+(y[1]?+y[1]-c:-c))),Object.is(f,-0)&&(f=0),f}}function J(s){var c;if(!(typeof s>"u")){if(s<0)throw{stack:new Error().stack,code:"D3060",index:1,value:s};return c=Math.sqrt(s),c}}function ye(s,c){var f;if(!(typeof s>"u")){if(f=Math.pow(s,c),!isFinite(f))throw{stack:new Error().stack,code:"D3061",index:1,value:s,exp:c};return f}}function we(){return Math.random()}function K(s){if(!(typeof s>"u")){var c=!1;if(Array.isArray(s)){if(s.length===1)c=K(s[0]);else if(s.length>1){var f=s.filter(function(y){return K(y)});c=f.length>0}}else typeof s=="string"?s.length>0&&(c=!0):v(s)?s!==0&&(c=!0):s!==null&&typeof s=="object"&&!T(s)?Object.keys(s).length>0&&(c=!0):typeof s=="boolean"&&s===!0&&(c=!0);return c}}function ee(s){if(!(typeof s>"u"))return!K(s)}function me(s,c,f,y){var p=[c],E=Q(s);return E>=2&&p.push(f),E>=3&&p.push(y),p}async function G(s,c){if(!(typeof s>"u")){for(var f=D(),y=0;y<s.length;y++){var p=me(c,s[y],y,s),E=await c.apply(this,p);typeof E<"u"&&f.push(E)}return f}}async function Ze(s,c){if(!(typeof s>"u")){for(var f=D(),y=0;y<s.length;y++){var p=s[y],E=me(c,p,y,s),M=await c.apply(this,E);K(M)&&f.push(p)}return f}}async function lt(s,c){if(!(typeof s>"u")){for(var f=!1,y,p=0;p<s.length;p++){var E=s[p],M=!0;if(typeof c<"u"){var H=me(c,E,p,s),X=await c.apply(this,H);M=K(X)}if(M)if(!f)y=E,f=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!f)throw{stack:new Error().stack,code:"D3139"};return y}}function He(){for(var s=[],c=Array.prototype.slice.call(arguments),f=Math.min.apply(Math,c.map(function(E){return Array.isArray(E)?E.length:0})),y=0;y<f;y++){var p=c.map(E=>E[y]);s.push(p)}return s}async function $e(s,c,f){if(!(typeof s>"u")){var y,p=Q(c);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var E;for(typeof f>"u"&&s.length>0?(y=s[0],E=1):(y=f,E=0);E<s.length;){var M=[y,s[E]];p>=3&&M.push(E),p>=4&&M.push(s),y=await c.apply(this,M),E++}return y}}function qe(s){var c=D();if(Array.isArray(s)){var f={};s.forEach(function(y){var p=qe(y);p.forEach(function(E){f[E]=!0})}),c=qe(f)}else s!==null&&typeof s=="object"&&!T(s)&&Object.keys(s).forEach(y=>c.push(y));return c}function wt(s,c){var f;if(Array.isArray(s)){f=D();for(var y=0;y<s.length;y++){var p=wt(s[y],c);typeof p<"u"&&(Array.isArray(p)?p.forEach(E=>f.push(E)):f.push(p))}}else s!==null&&typeof s=="object"&&!T(s)&&(f=s[c]);return f}function Tt(s,c){return typeof s>"u"?c:typeof c>"u"?s:(Array.isArray(s)||(s=D(s)),Array.isArray(c)||(c=[c]),s.concat(c))}function gr(s){return!(typeof s>"u")}function St(s){var c=D();if(Array.isArray(s))s.forEach(function(p){c=Tt(c,St(p))});else if(s!==null&&typeof s=="object"&&!I(s))for(var f in s){var y={};y[f]=s[f],c.push(y)}else c=s;return c}function Z(s){if(!(typeof s>"u")){var c={};return s.forEach(function(f){for(var y in f)c[y]=f[y]}),c}}function yr(s){if(!(typeof s>"u")){if(s.length<=1)return s;for(var c=s.length,f=new Array(c),y=0;y<c;y++)f[c-y-1]=s[y];return f}}async function Jt(s,c){var f=D();for(var y in s){var p=me(c,s[y],y,s),E=await c.apply(this,p);typeof E<"u"&&f.push(E)}return f}function ft(s){throw{code:"D3137",stack:new Error().stack,message:s||"$error() function evaluated"}}function Ut(s,c){if(!s)throw{code:"D3141",stack:new Error().stack,message:c||"$assert() statement failed"}}function gt(s){if(s!==void 0)return s===null?"null":v(s)?"number":typeof s=="string"?"string":typeof s=="boolean"?"boolean":Array.isArray(s)?"array":T(s)?"function":"object"}async function De(s,c){if(!(typeof s>"u")){if(s.length<=1)return s;var f;if(typeof c>"u"){if(!C(s)&&!k(s))throw{stack:new Error().stack,code:"D3070",index:1};f=async function(M,H){return M>H}}else f=c;var y=async function(M,H){var X=async function(ge,Ne,Se){Ne.length===0?Array.prototype.push.apply(ge,Se):Se.length===0?Array.prototype.push.apply(ge,Ne):await f(Ne[0],Se[0])?(ge.push(Se[0]),await X(ge,Ne,Se.slice(1))):(ge.push(Ne[0]),await X(ge,Ne.slice(1),Se))},Oe=[];return await X(Oe,M,H),Oe},p=async function(M){if(!Array.isArray(M)||M.length<=1)return M;var H=Math.floor(M.length/2),X=M.slice(0,H),Oe=M.slice(H);return X=await p(X),Oe=await p(Oe),await y(X,Oe)},E=await p(s);return E}}function l(s){if(!(typeof s>"u")){if(s.length<=1)return s;for(var c=new Array(s.length),f=0;f<s.length;f++){var y=Math.floor(Math.random()*(f+1));f!==y&&(c[f]=c[y]),c[y]=s[f]}return c}}function h(s){if(!(typeof s>"u")){if(!Array.isArray(s)||s.length<=1)return s;for(var c=x(s)?D():[],f=0;f<s.length;f++){for(var y=s[f],p=!1,E=0;E<c.length;E++)if(pe(y,c[E])){p=!0;break}p||c.push(y)}return c}}async function g(s,c){var f={};for(var y in s){var p=s[y],E=me(c,p,y,s),M=await c.apply(this,E);K(M)&&(f[y]=p)}return Object.keys(f).length===0&&(f=void 0),f}return{sum:R,count:se,max:U,min:A,average:$,string:V,substring:he,substringBefore:_e,substringAfter:Ae,lowercase:Te,uppercase:ve,length:Me,trim:nt,pad:xe,match:ie,contains:at,replace:Be,split:Ee,join:w,formatNumber:S,formatBase:_,number:N,floor:j,ceil:O,round:F,abs:B,sqrt:J,power:ye,random:we,boolean:K,not:ee,map:G,zip:He,filter:Ze,single:lt,foldLeft:$e,sift:g,keys:qe,lookup:wt,append:Tt,exists:gr,spread:St,merge:Z,reverse:yr,each:Jt,error:ft,assert:Ut,type:gt,sort:De,shuffle:l,distinct:h,base64encode:ct,base64decode:d,encodeUrlComponent:m,encodeUrl:z,decodeUrlComponent:de,decodeUrl:Pe}})();a.exports=u}).call(this)}).call(this,typeof _n<"u"?_n:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(r,a,n){var i=r("./datetime"),o=r("./functions"),u=r("./utils"),v=r("./parser"),k=r("./signature"),C=(function(){var D=u.isNumeric,x=u.isArrayOfStrings,T=u.isArrayOfNumbers,I=u.createSequence,ae=u.isSequence,Q=u.isFunction,pe=u.isLambda,q=u.isIterable,R=u.isPromise,se=u.getFunctionArity,U=u.isDeepEqual,A=ft(null);async function $(l,h,g){var s,c=g.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(c&&await c(l,h,g),l.type){case"path":s=await V(l,h,g);break;case"binary":s=await Me(l,h,g);break;case"unary":s=await nt(l,h,g);break;case"name":s=xe(l,h);break;case"string":case"number":case"value":s=fe(l);break;case"wildcard":s=at(l,h);break;case"descendant":s=Be(l,h);break;case"parent":s=g.lookup(l.slot.label);break;case"condition":s=await j(l,h,g);break;case"block":s=await O(l,h,g);break;case"bind":s=await B(l,h,g);break;case"regex":s=F(l);break;case"function":s=await me(l,h,g);break;case"variable":s=J(l,h,g);break;case"lambda":s=lt(l,h,g);break;case"partial":s=await He(l,h,g);break;case"apply":s=await ee(l,h,g);break;case"transform":s=we(l,h,g);break}if(Object.prototype.hasOwnProperty.call(l,"predicate"))for(var f=0;f<l.predicate.length;f++)s=await ve(l.predicate[f].expr,s,g);l.type!=="path"&&Object.prototype.hasOwnProperty.call(l,"group")&&(s=await S(l.group,s,g));var y=g.lookup(Symbol.for("jsonata.__evaluate_exit"));return y&&await y(l,h,g,s),s&&ae(s)&&!s.tupleStream&&(l.keepArray&&(s.keepSingleton=!0),s.length===0?s=void 0:s.length===1&&(s=s.keepSingleton?s:s[0])),s}async function V(l,h,g){var s;Array.isArray(h)&&l.steps[0].type!=="variable"?s=h:s=I(h);for(var c,f=!1,y=void 0,p=0;p<l.steps.length;p++){var E=l.steps[p];if(E.tuple&&(f=!0),p===0&&E.consarray?c=await $(E,s,g):f?y=await Te(E,s,y,g):c=await _e(E,s,g,p===l.steps.length-1),!f&&(typeof c>"u"||c.length===0))break;typeof E.focus>"u"&&(s=c)}if(f)if(l.tuple)c=y;else for(c=I(),p=0;p<y.length;p++)c.push(y[p]["@"]);return l.keepSingletonArray&&(Array.isArray(c)&&c.cons&&!c.sequence&&(c=I(c)),c.keepSingleton=!0),l.hasOwnProperty("group")&&(c=await S(l.group,f?y:c,g)),c}function he(l,h){var g=ft(l);for(const s in h)g.bind(s,h[s]);return g}async function _e(l,h,g,s){var c;if(l.type==="sort")return c=await ye(l,h,g),l.stages&&(c=await Ae(l.stages,c,g)),c;c=I();for(var f=0;f<h.length;f++){var y=await $(l,h[f],g);if(l.stages)for(var p=0;p<l.stages.length;p++)y=await ve(l.stages[p].expr,y,g);typeof y<"u"&&c.push(y)}var E=I();return s&&c.length===1&&Array.isArray(c[0])&&!ae(c[0])?E=c[0]:c.forEach(function(M){!Array.isArray(M)||M.cons?E.push(M):M.forEach(H=>E.push(H))}),E}async function Ae(l,h,g){for(var s=h,c=0;c<l.length;c++){var f=l[c];switch(f.type){case"filter":s=await ve(f.expr,s,g);break;case"index":for(var y=0;y<s.length;y++){var p=s[y];p[f.value]=y}break}}return s}async function Te(l,h,g,s){var c;if(l.type==="sort"){if(g)c=await ye(l,g,s);else{var f=await ye(l,h,s);c=I(),c.tupleStream=!0;for(var y=0;y<f.length;y++){var p={"@":f[y]};p[l.index]=y,c.push(p)}}return l.stages&&(c=await Ae(l.stages,c,s)),c}c=I(),c.tupleStream=!0;var E=s;g===void 0&&(g=h.map(Oe=>({"@":Oe})));for(var M=0;M<g.length;M++){E=he(s,g[M]);var H=await $(l,g[M]["@"],E);if(typeof H<"u"){Array.isArray(H)||(H=[H]);for(var X=0;X<H.length;X++)p={},Object.assign(p,g[M]),H.tupleStream?Object.assign(p,H[X]):(l.focus?(p[l.focus]=H[X],p["@"]=g[M]["@"]):p["@"]=H[X],l.index&&(p[l.index]=X),l.ancestor&&(p[l.ancestor.label]=g[M]["@"])),c.push(p)}}return l.stages&&(c=await Ae(l.stages,c,s)),c}async function ve(l,h,g){var s=I();if(h&&h.tupleStream&&(s.tupleStream=!0),Array.isArray(h)||(h=I(h)),l.type==="number"){var c=Math.floor(l.value);c<0&&(c=h.length+c);var f=await h[c];typeof f<"u"&&(Array.isArray(f)?s=f:s.push(f))}else for(c=0;c<h.length;c++){var f=h[c],y=f,p=g;h.tupleStream&&(y=f["@"],p=he(g,f));var E=await $(l,y,p);D(E)&&(E=[E]),T(E)?E.forEach(function(H){var X=Math.floor(H);X<0&&(X=h.length+X),X===c&&s.push(f)}):o.boolean(E)&&s.push(f)}return s}async function Me(l,h,g){var s,c=await $(l.lhs,h,g),f=l.value,y=async()=>await $(l.rhs,h,g);if(f==="and"||f==="or")try{return await Pe(c,y,f)}catch(E){throw E.position=l.position,E.token=f,E}var p=await y();try{switch(f){case"+":case"-":case"*":case"/":case"%":s=d(c,p,f);break;case"=":case"!=":s=m(c,p,f);break;case"<":case"<=":case">":case">=":s=z(c,p,f);break;case"&":s=w(c,p);break;case"..":s=N(c,p);break;case"in":s=de(c,p);break}}catch(E){throw E.position=l.position,E.token=f,E}return s}async function nt(l,h,g){var s;switch(l.value){case"-":if(s=await $(l.expression,h,g),typeof s>"u")s=void 0;else if(D(s))s=-s;else throw{code:"D1002",stack:new Error().stack,position:l.position,token:l.value,value:s};break;case"[":s=[];let y=await Promise.all(l.expressions.map(async(p,E)=>(g.isParallelCall=E>0,[p,await $(p,h,g)])));for(let p of y){var[c,f]=p;typeof f<"u"&&(c.value==="["?s.push(f):s=o.append(s,f))}l.consarray&&Object.defineProperty(s,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":s=await S(l,h,g);break}return s}function xe(l,h,g){return o.lookup(h,l.value)}function fe(l){return l.value}function at(l,h){var g=I();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(s){var c=h[s];Array.isArray(c)?(c=ie(c),g=o.append(g,c)):g.push(c)}),g}function ie(l,h){return typeof h>"u"&&(h=[]),Array.isArray(l)?l.forEach(function(g){ie(g,h)}):h.push(l),h}function Be(l,h){var g,s=I();return typeof h<"u"&&(ct(h,s),s.length===1?g=s[0]:g=s),g}function ct(l,h){Array.isArray(l)||h.push(l),Array.isArray(l)?l.forEach(function(g){ct(g,h)}):l!==null&&typeof l=="object"&&Object.keys(l).forEach(function(g){ct(l[g],h)})}function d(l,h,g){var s;if(typeof l<"u"&&!D(l))throw{code:"T2001",stack:new Error().stack,value:l};if(typeof h<"u"&&!D(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof l>"u"||typeof h>"u")return s;switch(g){case"+":s=l+h;break;case"-":s=l-h;break;case"*":s=l*h;break;case"/":s=l/h;break;case"%":s=l%h;break}return s}function m(l,h,g){var s,c=typeof l,f=typeof h;if(c==="undefined"||f==="undefined")return!1;switch(g){case"=":s=U(l,h);break;case"!=":s=!U(l,h);break}return s}function z(l,h,g){var s,c=typeof l,f=typeof h,y=c==="undefined"||c==="string"||c==="number",p=f==="undefined"||f==="string"||f==="number";if(!y||!p)throw{code:"T2010",stack:new Error().stack,value:c==="string"||c==="number"?h:l};if(!(c==="undefined"||f==="undefined")){if(c!==f)throw{code:"T2009",stack:new Error().stack,value:l,value2:h};switch(g){case"<":s=l<h;break;case"<=":s=l<=h;break;case">":s=l>h;break;case">=":s=l>=h;break}return s}}function de(l,h){var g=!1;if(typeof l>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var s=0;s<h.length;s++)if(h[s]===l){g=!0;break}return g}async function Pe(l,h,g){var s,c=Ee(l);switch(g){case"and":s=c&&Ee(await h());break;case"or":s=c||Ee(await h());break}return s}function Ee(l){var h=o.boolean(l);return typeof h>"u"?!1:h}function w(l,h){var g,s="",c="";return typeof l<"u"&&(s=o.string(l)),typeof h<"u"&&(c=o.string(h)),g=s.concat(c),g}async function S(l,h,g){var s={},c={},f=!!(h&&h.tupleStream);Array.isArray(h)||(h=I(h)),h.length===0&&h.push(void 0);for(var y=0;y<h.length;y++)for(var p=h[y],E=f?he(g,p):g,M=0;M<l.lhs.length;M++){var H=l.lhs[M],X=await $(H[0],f?p["@"]:p,E);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:l.position,value:X};if(X!==void 0){var Oe={data:p,exprIndex:M};if(c.hasOwnProperty(X)){if(c[X].exprIndex!==M)throw{code:"D1009",stack:new Error().stack,position:l.position,value:X};c[X].data=o.append(c[X].data,p)}else c[X]=Oe}}let ge=await Promise.all(Object.keys(c).map(async(Se,We)=>{let ke=c[Se];var Fe=ke.data,ut=g;if(f){var Ve=_(ke.data);Fe=Ve["@"],delete Ve["@"],ut=he(g,Ve)}return g.isParallelCall=We>0,[Se,await $(l.lhs[ke.exprIndex][1],Fe,ut)]}));for(let Se of ge){var[X,Ne]=await Se;typeof Ne<"u"&&(s[X]=Ne)}return s}function _(l){if(!Array.isArray(l))return l;var h={};Object.assign(h,l[0]);for(var g=1;g<l.length;g++)for(const s in l[g])h[s]=o.append(h[s],l[g][s]);return h}function N(l,h){var g;if(typeof l<"u"&&!Number.isInteger(l))throw{code:"T2003",stack:new Error().stack,value:l};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof l>"u"||typeof h>"u"||l>h)return g;var s=h-l+1;if(s>1e7)throw{code:"D2014",stack:new Error().stack,value:s};g=new Array(s);for(var c=l,f=0;c<=h;c++,f++)g[f]=c;return g.sequence=!0,g}async function B(l,h,g){var s=await $(l.rhs,h,g);return g.bind(l.lhs.value,s),s}async function j(l,h,g){var s,c=await $(l.condition,h,g);return o.boolean(c)?s=await $(l.then,h,g):typeof l.else<"u"&&(s=await $(l.else,h,g)),s}async function O(l,h,g){for(var s,c=ft(g),f=0;f<l.expressions.length;f++)s=await $(l.expressions[f],h,c);return s}function F(l){var h=new De.RegexEngine(l.value),g=function(s,c){var f;h.lastIndex=c||0;var y=h.exec(s);if(y!==null){if(f={match:y[0],start:y.index,end:y.index+y[0].length,groups:[]},y.length>1)for(var p=1;p<y.length;p++)f.groups.push(y[p]);f.next=function(){if(!(h.lastIndex>=s.length)){var E=g(s,h.lastIndex);if(E&&E.match==="")throw{code:"D1004",stack:new Error().stack,position:l.position,value:l.value.source};return E}}}return f};return g}function J(l,h,g){var s;return l.value===""?s=h&&h.outerWrapper?h[0]:h:s=g.lookup(l.value),s}async function ye(l,h,g){var s,c=h,f=!!h.tupleStream,y=async function(E,M){for(var H=0,X=0;H===0&&X<l.terms.length;X++){var Oe=l.terms[X],ge=E,Ne=g;f&&(ge=E["@"],Ne=he(g,E));var Se=await $(Oe.expression,ge,Ne);ge=M,Ne=g,f&&(ge=M["@"],Ne=he(g,M));var We=await $(Oe.expression,ge,Ne),ke=typeof Se,Fe=typeof We;if(ke==="undefined"){H=Fe==="undefined"?0:1;continue}if(Fe==="undefined"){H=-1;continue}if(!(ke==="string"||ke==="number")||!(Fe==="string"||Fe==="number"))throw{code:"T2008",stack:new Error().stack,position:l.position,value:ke==="string"||ke==="number"?We:Se};if(ke!==Fe)throw{code:"T2007",stack:new Error().stack,position:l.position,value:Se,value2:We};Se!==We&&(Se<We?H=-1:H=1,Oe.descending===!0&&(H=-H))}return H===1},p={environment:g,input:h};return s=await o.sort.apply(p,[c,y]),s}function we(l,h,g){var s=async function(c){if(!(typeof c>"u")){var f=g.lookup("clone");if(!Q(f))throw{code:"T2013",stack:new Error().stack,position:l.position};var y=await G(f,[c],null,g),p=await $(l.pattern,y,g);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var E=0;E<p.length;E++){var M=p[E];if(M&&(M.isPrototypeOf(y)||M instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:l.position};var H=await $(l.update,M,g),X=typeof H;if(X!=="undefined"){if(X!=="object"||H===null||Array.isArray(H))throw{code:"T2011",stack:new Error().stack,position:l.update.position,value:H};for(var Oe in H)M[Oe]=H[Oe]}if(typeof l.delete<"u"){var ge=await $(l.delete,M,g);if(typeof ge<"u"){var Ne=ge;if(Array.isArray(ge)||(ge=[ge]),!x(ge))throw{code:"T2012",stack:new Error().stack,position:l.delete.position,value:Ne};for(var Se=0;Se<ge.length;Se++)typeof M=="object"&&M!==null&&delete M[ge[Se]]}}}}return y}};return Z(s,"<(oa):o>")}var K=v("function($f, $g) { function($x){ $g($f($x)) } }");async function ee(l,h,g){var s,c=await $(l.lhs,h,g);if(l.rhs.type==="function")s=await me(l.rhs,h,g,{context:c});else{var f=await $(l.rhs,h,g);if(!Q(f))throw{code:"T2006",stack:new Error().stack,position:l.position,value:f};if(Q(c)){var y=await $(K,null,g);s=await G(y,[c,f],null,g)}else s=await G(f,[c],null,g)}return s}async function me(l,h,g,s){var c,f=await $(l.procedure,h,g);if(typeof f>"u"&&l.procedure.type==="path"&&g.lookup(l.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:l.position,token:l.procedure.steps[0].value};var y=[];typeof s<"u"&&y.push(s.context);for(var p=0;p<l.arguments.length;p++){const M=await $(l.arguments[p],h,g);if(Q(M)){const H=async function(...X){return await G(M,X,null,g)};H.arity=se(M),y.push(H)}else y.push(M)}var E=l.procedure.type==="path"?l.procedure.steps[0].value:l.procedure.value;try{typeof f=="object"&&(f.token=E,f.position=l.position),c=await G(f,y,h,g)}catch(M){throw M.position||(M.position=l.position),M.token||(M.token=E),M}return c}async function G(l,h,g,s){var c;for(c=await Ze(l,h,g,s);pe(c)&&c.thunk===!0;){var f=await $(c.body.procedure,c.input,c.environment);c.body.procedure.type==="variable"&&(f.token=c.body.procedure.value),f.position=c.body.procedure.position;for(var y=[],p=0;p<c.body.arguments.length;p++)y.push(await $(c.body.arguments[p],c.input,c.environment));c=await Ze(f,y,g,s)}return c}async function Ze(l,h,g,s){var c;try{var f=h;if(l&&(f=$e(l.signature,h,g)),pe(l))c=await qe(l,f);else if(l&&l._jsonata_function===!0){var y={environment:s,input:g};c=l.implementation.apply(y,f),q(c)&&(c=c.next().value),R(c)&&(c=await c)}else if(typeof l=="function")c=l.apply(g,f),R(c)&&(c=await c);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw l&&(typeof p.token>"u"&&typeof l.token<"u"&&(p.token=l.token),p.position=l.position||p.position),p}return c}function lt(l,h,g){var s={_jsonata_lambda:!0,input:h,environment:g,arguments:l.arguments,signature:l.signature,body:l.body};return l.thunk===!0&&(s.thunk=!0),s.apply=async function(c,f){return await G(s,f,h,c?c.environment:g)},s}async function He(l,h,g){for(var s,c=[],f=0;f<l.arguments.length;f++){var y=l.arguments[f];y.type==="operator"&&y.value==="?"?c.push(y):c.push(await $(y,h,g))}var p=await $(l.procedure,h,g);if(typeof p>"u"&&l.procedure.type==="path"&&g.lookup(l.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:l.position,token:l.procedure.steps[0].value};if(pe(p))s=wt(p,c);else if(p&&p._jsonata_function===!0)s=Tt(p.implementation,c);else if(typeof p=="function")s=Tt(p,c);else throw{code:"T1008",stack:new Error().stack,position:l.position,token:l.procedure.type==="path"?l.procedure.steps[0].value:l.procedure.value};return s}function $e(l,h,g){if(typeof l>"u")return h;var s=l.validate(h,g);return s}async function qe(l,h){var g,s=ft(l.environment);return l.arguments.forEach(function(c,f){s.bind(c.value,h[f])}),typeof l.body=="function"?g=await gr(l.body,s):g=await $(l.body,l.input,s),g}function wt(l,h){var g=ft(l.environment),s=[];l.arguments.forEach(function(f,y){var p=h[y];p&&p.type==="operator"&&p.value==="?"?s.push(f):g.bind(f.value,p)});var c={_jsonata_lambda:!0,input:l.input,environment:g,arguments:s,body:l.body};return c}function Tt(l,h){var g=St(l);g=g.map(function(y){return"$"+y.trim()});var s="function("+g.join(", ")+"){ _ }",c=v(s);c.body=l;var f=wt(c,h);return f}async function gr(l,h){var g=St(l),s=g.map(function(y){return h.lookup(y.trim())}),c={environment:h},f=l.apply(c,s);return R(f)&&(f=await f),f}function St(l){var h=l.toString(),g=/\(([^)]*)\)/.exec(h)[1],s=g.split(",");return s}function Z(l,h){var g={_jsonata_function:!0,implementation:l};return typeof h<"u"&&(g.signature=k(h)),g}async function yr(l,h){if(!(typeof l>"u")){var g=this.input;typeof h<"u"&&(g=h,Array.isArray(g)&&!ae(g)&&(g=I(g),g.outerWrapper=!0));try{var s=v(l,!1)}catch(f){throw gt(f),{stack:new Error().stack,code:"D3120",value:f.message,error:f}}try{var c=await $(s,g,this.environment)}catch(f){throw gt(f),{stack:new Error().stack,code:"D3121",value:f.message,error:f}}return c}}function Jt(l){if(!(typeof l>"u"))return JSON.parse(o.string(l))}function ft(l){var h={};const g={bind:function(c,f){h[c]=f},lookup:function(c){var f;return h.hasOwnProperty(c)?f=h[c]:l&&(f=l.lookup(c)),f},timestamp:l?l.timestamp:null,async:l?l.async:!1,isParallelCall:l?l.isParallelCall:!1,global:l?l.global:{ancestry:[null]}};if(l){var s=l.lookup(Symbol.for("jsonata.__createFrame_push"));s&&s(l,g)}return g}A.bind("sum",Z(o.sum,"<a<n>:n>")),A.bind("count",Z(o.count,"<a:n>")),A.bind("max",Z(o.max,"<a<n>:n>")),A.bind("min",Z(o.min,"<a<n>:n>")),A.bind("average",Z(o.average,"<a<n>:n>")),A.bind("string",Z(o.string,"<x-b?:s>")),A.bind("substring",Z(o.substring,"<s-nn?:s>")),A.bind("substringBefore",Z(o.substringBefore,"<s-s:s>")),A.bind("substringAfter",Z(o.substringAfter,"<s-s:s>")),A.bind("lowercase",Z(o.lowercase,"<s-:s>")),A.bind("uppercase",Z(o.uppercase,"<s-:s>")),A.bind("length",Z(o.length,"<s-:n>")),A.bind("trim",Z(o.trim,"<s-:s>")),A.bind("pad",Z(o.pad,"<s-ns?:s>")),A.bind("match",Z(o.match,"<s-f<s:o>n?:a<o>>")),A.bind("contains",Z(o.contains,"<s-(sf):b>")),A.bind("replace",Z(o.replace,"<s-(sf)(sf)n?:s>")),A.bind("split",Z(o.split,"<s-(sf)n?:a<s>>")),A.bind("join",Z(o.join,"<a<s>s?:s>")),A.bind("formatNumber",Z(o.formatNumber,"<n-so?:s>")),A.bind("formatBase",Z(o.formatBase,"<n-n?:s>")),A.bind("formatInteger",Z(i.formatInteger,"<n-s:s>")),A.bind("parseInteger",Z(i.parseInteger,"<s-s:n>")),A.bind("number",Z(o.number,"<(nsb)-:n>")),A.bind("floor",Z(o.floor,"<n-:n>")),A.bind("ceil",Z(o.ceil,"<n-:n>")),A.bind("round",Z(o.round,"<n-n?:n>")),A.bind("abs",Z(o.abs,"<n-:n>")),A.bind("sqrt",Z(o.sqrt,"<n-:n>")),A.bind("power",Z(o.power,"<n-n:n>")),A.bind("random",Z(o.random,"<:n>")),A.bind("boolean",Z(o.boolean,"<x-:b>")),A.bind("not",Z(o.not,"<x-:b>")),A.bind("map",Z(o.map,"<af>")),A.bind("zip",Z(o.zip,"<a+>")),A.bind("filter",Z(o.filter,"<af>")),A.bind("single",Z(o.single,"<af?>")),A.bind("reduce",Z(o.foldLeft,"<afj?:j>")),A.bind("sift",Z(o.sift,"<o-f?:o>")),A.bind("keys",Z(o.keys,"<x-:a<s>>")),A.bind("lookup",Z(o.lookup,"<x-s:x>")),A.bind("append",Z(o.append,"<xx:a>")),A.bind("exists",Z(o.exists,"<x:b>")),A.bind("spread",Z(o.spread,"<x-:a<o>>")),A.bind("merge",Z(o.merge,"<a<o>:o>")),A.bind("reverse",Z(o.reverse,"<a:a>")),A.bind("each",Z(o.each,"<o-f:a>")),A.bind("error",Z(o.error,"<s?:x>")),A.bind("assert",Z(o.assert,"<bs?:x>")),A.bind("type",Z(o.type,"<x:s>")),A.bind("sort",Z(o.sort,"<af?:a>")),A.bind("shuffle",Z(o.shuffle,"<a:a>")),A.bind("distinct",Z(o.distinct,"<x:x>")),A.bind("base64encode",Z(o.base64encode,"<s-:s>")),A.bind("base64decode",Z(o.base64decode,"<s-:s>")),A.bind("encodeUrlComponent",Z(o.encodeUrlComponent,"<s-:s>")),A.bind("encodeUrl",Z(o.encodeUrl,"<s-:s>")),A.bind("decodeUrlComponent",Z(o.decodeUrlComponent,"<s-:s>")),A.bind("decodeUrl",Z(o.decodeUrl,"<s-:s>")),A.bind("eval",Z(yr,"<sx?:x>")),A.bind("toMillis",Z(i.toMillis,"<s-s?:n>")),A.bind("fromMillis",Z(i.fromMillis,"<n-s?s?:s>")),A.bind("clone",Z(Jt,"<(oa)-:o>"));var Ut={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function gt(l){var h=Ut[l.code];if(typeof h<"u"){var g=h.replace(/\{\{\{([^}]+)}}}/g,function(){return l[arguments[1]]});g=g.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(l[arguments[1]])}),l.message=g}}function De(l,h){var g,s;try{g=v(l,h&&h.recover),s=g.errors,delete g.errors}catch(y){throw gt(y),y}var c=ft(A),f=new Date;return c.bind("now",Z(function(y,p){return i.fromMillis(f.getTime(),y,p)},"<s?s?:s>")),c.bind("millis",Z(function(){return f.getTime()},"<:n>")),h&&h.RegexEngine?De.RegexEngine=h.RegexEngine:De.RegexEngine=RegExp,{evaluate:async function(y,p,E){if(typeof s<"u"){var M={code:"S0500",position:0};throw gt(M),M}if(typeof p<"u"){var H;H=ft(c);for(var X in p)H.bind(X,p[X])}else H=c;H.bind("$",y),f=new Date,H.timestamp=f,Array.isArray(y)&&!ae(y)&&(y=I(y),y.outerWrapper=!0);var Oe;try{return Oe=await $(g,y,H),typeof E=="function"&&E(null,Oe),Oe}catch(ge){throw gt(ge),ge}},assign:function(y,p){c.bind(y,p)},registerFunction:function(y,p,E){var M=Z(p,E);c.bind(y,M)},ast:function(){return g},errors:function(){return s}}}return De.parser=v,De})();a.exports=C},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(r,a,n){var i=r("./signature");const o=(()=>{var u={".":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},v={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
- `,r:"\r",t:" "},k=function(D){var x=0,T=D.length,I=function(pe,q){var R={type:pe,value:q,position:x};return R},ae=function(){for(var pe=x,q=0,R,se,U=function($){if(D.charAt($)==="/"&&q===0){for(var V=0;D.charAt($-(V+1))==="\\";)V++;if(V%2===0)return!0}return!1};x<T;){var A=D.charAt(x);if(U(x)){if(R=D.substring(pe,x),R==="")throw{code:"S0301",stack:new Error().stack,position:x};for(x++,A=D.charAt(x),pe=x;A==="i"||A==="m";)x++,A=D.charAt(x);return se=D.substring(pe,x)+"g",new RegExp(R,se)}(A==="("||A==="["||A==="{")&&D.charAt(x-1)!=="\\"&&q++,(A===")"||A==="]"||A==="}")&&D.charAt(x-1)!=="\\"&&q--,x++}throw{code:"S0302",stack:new Error().stack,position:x}},Q=function(pe){if(x>=T)return null;for(var q=D.charAt(x);x<T&&`
3
- \r\v`.indexOf(q)>-1;)x++,q=D.charAt(x);if(q==="/"&&D.charAt(x+1)==="*"){var R=x;for(x+=2,q=D.charAt(x);!(q==="*"&&D.charAt(x+1)==="/");)if(q=D.charAt(++x),x>=T)throw{code:"S0106",stack:new Error().stack,position:R};return x+=2,q=D.charAt(x),Q(pe)}if(pe!==!0&&q==="/")return x++,I("regex",ae());if(q==="."&&D.charAt(x+1)===".")return x+=2,I("operator","..");if(q===":"&&D.charAt(x+1)==="=")return x+=2,I("operator",":=");if(q==="!"&&D.charAt(x+1)==="=")return x+=2,I("operator","!=");if(q===">"&&D.charAt(x+1)==="=")return x+=2,I("operator",">=");if(q==="<"&&D.charAt(x+1)==="=")return x+=2,I("operator","<=");if(q==="*"&&D.charAt(x+1)==="*")return x+=2,I("operator","**");if(q==="~"&&D.charAt(x+1)===">")return x+=2,I("operator","~>");if(q==="?"&&D.charAt(x+1)===":")return x+=2,I("operator","?:");if(q==="?"&&D.charAt(x+1)==="?")return x+=2,I("operator","??");if(Object.prototype.hasOwnProperty.call(u,q))return x++,I("operator",q);if(q==='"'||q==="'"){var se=q;x++;for(var U="";x<T;){if(q=D.charAt(x),q==="\\")if(x++,q=D.charAt(x),Object.prototype.hasOwnProperty.call(v,q))U+=v[q];else if(q==="u"){var A=D.substr(x+1,4);if(/^[0-9a-fA-F]+$/.test(A)){var $=parseInt(A,16);U+=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:q};else{if(q===se)return x++,I("string",U);U+=q}x++}throw{code:"S0101",stack:new Error().stack,position:x}}var V=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,he=V.exec(D.substring(x));if(he!==null){var _e=parseFloat(he[0]);if(!isNaN(_e)&&isFinite(_e))return x+=he[0].length,I("number",_e);throw{code:"S0102",stack:new Error().stack,position:x,token:he[0]}}var Ae;if(q==="`"){x++;var Te=D.indexOf("`",x);if(Te!==-1)return Ae=D.substring(x,Te),x=Te+1,I("name",Ae);throw x=T,{code:"S0105",stack:new Error().stack,position:x}}for(var ve=x,Me;;)if(Me=D.charAt(ve),ve===T||`
4
- \r\v`.indexOf(Me)>-1||Object.prototype.hasOwnProperty.call(u,Me)){if(D.charAt(x)==="$")return Ae=D.substring(x+1,ve),x=ve,I("variable",Ae);switch(Ae=D.substring(x,ve),x=ve,Ae){case"or":case"in":case"and":return I("operator",Ae);case"true":return I("value",!0);case"false":return I("value",!1);case"null":return I("value",null);default:return x===T&&Ae===""?null:I("name",Ae)}}else ve++};return Q},C=function(D,x){var T,I,ae={},Q=[],pe=function(){var d=[];T.id!=="(end)"&&d.push({type:T.type,value:T.value,position:T.position});for(var m=I();m!==null;)d.push(m),m=I();return d},q={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(x)return d.remaining=pe(),d.type="error",Q.push(d),d;throw d.stack=new Error().stack,d}},R=function(d,m){var z=ae[d];return m=m||0,z?m>=z.lbp&&(z.lbp=m):(z=Object.create(q),z.id=z.value=d,z.lbp=m,ae[d]=z),z},se=function(d){if(x){d.remaining=pe(),Q.push(d);var m=ae["(error)"];return T=Object.create(m),T.error=d,T.type="(error)",T}else throw d.stack=new Error().stack,d},U=function(d,m){if(d&&T.id!==d){var z;T.id==="(end)"?z="S0203":z="S0202";var de={code:z,position:T.position,token:T.value,value:d};return se(de)}var Pe=I(m);if(Pe===null)return T=ae["(end)"],T.position=D.length,T;var Ee=Pe.value,w=Pe.type,S;switch(w){case"name":case"variable":S=ae["(name)"];break;case"operator":if(S=ae[Ee],!S)return se({code:"S0204",stack:new Error().stack,position:Pe.position,token:Ee});break;case"string":case"number":case"value":S=ae["(literal)"];break;case"regex":w="regex",S=ae["(regex)"];break;default:return se({code:"S0205",stack:new Error().stack,position:Pe.position,token:Ee})}return T=Object.create(S),T.value=Ee,T.type=w,T.position=Pe.position,T},A=function(d){var m,z=T;for(U(null,!0),m=z.nud();d<T.lbp;)z=T,U(),m=z.led(m);return m},$=function(d){var m=R(d,0);m.nud=function(){return this}},V=function(d,m,z){var de=m||u[d],Pe=R(d,de);return Pe.led=z||function(Ee){return this.lhs=Ee,this.rhs=A(de),this.type="binary",this},Pe},he=function(d,m,z){var de=R(d,m);return de.led=z,de},_e=function(d,m){var z=R(d);return z.nud=m||function(){return this.expression=A(70),this.type="unary",this},z};$("(end)"),$("(name)"),$("(literal)"),$("(regex)"),R(":"),R(";"),R(","),R(")"),R("]"),R("}"),R(".."),V("."),V("+"),V("-"),V("*"),V("/"),V("%"),V("="),V("<"),V(">"),V("!="),V("<="),V(">="),V("&"),V("and"),V("or"),V("in"),$("and"),$("or"),$("in"),_e("-"),V("~>"),V("??",u["??"],function(d){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[d]},this.then=d,this.else=A(0),this}),he("(error)",10,function(d){return this.lhs=d,this.error=T.error,this.remaining=pe(),this.type="error",this}),_e("*",function(){return this.type="wildcard",this}),_e("**",function(){return this.type="descendant",this}),_e("%",function(){return this.type="parent",this}),V("(",u["("],function(d){if(this.procedure=d,this.type="function",this.arguments=[],T.id!==")")for(;T.type==="operator"&&T.id==="?"?(this.type="partial",this.arguments.push(T),U("?")):this.arguments.push(A(0)),T.id===",";)U(",");if(U(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(Ee,w){if(Ee.type!=="variable")return se({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:w+1})}),this.type="lambda",T.id==="<"){for(var m=T.position,z=1,de="<";z>0&&T.id!=="{"&&T.id!=="(end)";){var Pe=U();Pe.id===">"?z--:Pe.id==="<"&&z++,de+=Pe.value}U(">");try{this.signature=i(de)}catch(Ee){return Ee.position=m+Ee.offset,se(Ee)}}U("{"),this.body=A(0),U("}")}return this}),_e("(",function(){for(var d=[];T.id!==")"&&(d.push(A(0)),T.id===";");)U(";");return U(")",!0),this.type="block",this.expressions=d,this}),_e("[",function(){var d=[];if(T.id!=="]")for(;;){var m=A(0);if(T.id===".."){var z={type:"binary",value:"..",position:T.position,lhs:m};U(".."),z.rhs=A(0),m=z}if(d.push(m),T.id!==",")break;U(",")}return U("]",!0),this.expressions=d,this.type="unary",this}),V("[",u["["],function(d){if(T.id==="]"){for(var m=d;m&&m.type==="binary"&&m.value==="[";)m=m.lhs;return m.keepArray=!0,U("]"),d}else return this.lhs=d,this.rhs=A(u["]"]),this.type="binary",U("]",!0),this}),V("^",u["^"],function(d){U("(");for(var m=[];;){var z={descending:!1};if(T.id==="<"?U("<"):T.id===">"&&(z.descending=!0,U(">")),z.expression=A(0),m.push(z),T.id!==",")break;U(",")}return U(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Ae=function(d){var m=[];if(T.id!=="}")for(;;){var z=A(0);U(":");var de=A(0);if(m.push([z,de]),T.id!==",")break;U(",")}return U("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};_e("{",Ae),V("{",u["{"],Ae),he(":=",u[":="],function(d){return d.type!=="variable"?se({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=A(u[":="]-1),this.type="binary",this)}),V("@",u["@"],function(d){return this.lhs=d,this.rhs=A(u["@"]),this.rhs.type!=="variable"?se({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),V("#",u["#"],function(d){return this.lhs=d,this.rhs=A(u["#"]),this.rhs.type!=="variable"?se({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),V("?",u["?"],function(d){return this.type="condition",this.condition=d,this.then=A(0),T.id===":"&&(U(":"),this.else=A(0)),this}),V("?:",u["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=A(0),this}),_e("|",function(){return this.type="transform",this.pattern=A(0),U("|"),this.update=A(0),T.id===","&&(U(","),this.delete=A(0)),U("|"),this});var Te=function(d){var m;if(d.type==="function"&&!d.predicate){var z={type:"lambda",thunk:!0,arguments:[],position:d.position};z.body=d,m=z}else if(d.type==="condition")d.then=Te(d.then),typeof d.else<"u"&&(d.else=Te(d.else)),m=d;else if(d.type==="block"){var de=d.expressions.length;de>0&&(d.expressions[de-1]=Te(d.expressions[de-1])),m=d}else m=d;return m},ve=0,Me=0,nt=[],xe=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(nt[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=xe(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var z=d.steps.length-1;for(m=xe(d.steps[z--],m);m.level>0&&z>=0;)m=xe(d.steps[z--],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 z=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&z.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=z:Array.prototype.push.apply(d.seekingParent,z)}},at=function(d){var m=d.steps.length-1,z=d.steps[m],de=typeof z.seekingParent<"u"?z.seekingParent:[];z.type==="parent"&&de.push(z.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 w=d.steps[m--];m>=0&&w.focus&&d.steps[m].focus;)w=d.steps[m--];Ee=xe(w,Ee)}}},ie=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var z=ie(d.lhs);z.type==="path"?m=z:m={type:"path",steps:[z]},z.type==="parent"&&(m.seekingParent=[z.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),at(m);break;case"[":m=ie(d.lhs);var w=m,S="predicate";if(m.type==="path"&&(w=m.steps[m.steps.length-1],S="stages"),typeof w.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof w[S]>"u"&&(w[S]=[]);var _=ie(d.rhs);typeof _.seekingParent<"u"&&(_.seekingParent.forEach(F=>{F.level===1?xe(w,F):F.level--}),fe(w,_)),w[S].push({type:"filter",expr:_,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 N={type:"sort",position:d.position};N.terms=d.rhs.map(function(F){var J=ie(F.expression);return fe(N,J),{descending:F.descending,expression:J}}),m.steps.push(N),at(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),w=m,m.type==="path"&&(w=m.steps[m.steps.length-1]),typeof w.stages<"u"||typeof w.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:d.position};if(w.type==="sort")throw{code:"S0216",stack:new Error().stack,position:d.position};d.keepArray&&(w.keepArray=!0),w.focus=d.rhs.value,w.tuple=!0;break;case"#":m=ie(d.lhs),w=m,m.type==="path"?w=m.steps[m.steps.length-1]:(m={type:"path",steps:[m]},typeof w.predicate<"u"&&(w.stages=w.predicate,delete w.predicate)),typeof w.stages>"u"?w.index=d.rhs.value:w.stages.push({type:"index",value:d.rhs.value,position:d.position}),w.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 ye=ie(F[1]);return fe(m,ye),[J,ye]}):(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=Te(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:Me++}},nt.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),U();var Be=A(0);if(T.id!=="(end)"){var ct={code:"S0201",position:T.position,token:T.value};se(ct)}if(Be=ie(Be),Be.type==="parent"||typeof Be.seekingParent<"u")throw{code:"S0217",token:Be.type,position:Be.position};return Q.length>0&&(Be.errors=Q),Be};return C})();a.exports=o},{"./signature":5}],5:[function(r,a,n){var i=r("./utils");const o=(()=>{var u={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function v(k){for(var C=1,D=[],x={},T=x;C<k.length;){var I=k.charAt(C);if(I===":")break;var ae=function(){D.push(x),T=x,x={}},Q=function(V,he,_e,Ae){for(var Te=1,ve=he;ve<V.length;)if(ve++,I=V.charAt(ve),I===Ae){if(Te--,Te===0)break}else I===_e&&Te++;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"-":T.context=!0,T.contextRegex=new RegExp(T.regex),T.regex+="?";break;case"?":case"+":T.regex+=I;break;case"(":var pe=Q(k,C,"(",")"),q=k.substring(C+1,pe);if(q.indexOf("<")===-1)x.regex="["+q+"m]";else throw{code:"S0402",stack:new Error().stack,value:q,offset:C};x.type="("+q+")",C=pe,ae();break;case"<":if(T.type==="a"||T.type==="f"){var R=Q(k,C,"<",">");T.subtype=k.substring(C+1,R),C=R}else throw{code:"S0401",stack:new Error().stack,value:T.type,offset:C};break}C++}var se="^"+D.map(function(V){return"("+V.regex+")"}).join("")+"$",U=new RegExp(se),A=function(V){var he;if(i.isFunction(V))he="f";else{var _e=typeof V;switch(_e){case"string":he="s";break;case"number":he="n";break;case"boolean":he="b";break;case"object":V===null?he="l":Array.isArray(V)?he="a":he="o";break;case"undefined":default:he="m"}}return he},$=function(V,he){for(var _e="^",Ae=0,Te=0;Te<D.length;Te++){_e+=D[Te].regex;var ve=he.match(_e);if(ve===null)throw{code:"T0410",stack:new Error().stack,value:V[Ae],index:Ae+1};Ae=ve[0].length}throw{code:"T0410",stack:new Error().stack,value:V[Ae],index:Ae+1}};return{definition:k,validate:function(V,he){var _e="";V.forEach(function(Me){_e+=A(Me)});var Ae=U.exec(_e);if(Ae){var Te=[],ve=0;return D.forEach(function(Me,nt){var xe=V[ve],fe=Ae[nt+1];if(fe==="")if(Me.context&&Me.contextRegex){var at=A(he);if(Me.contextRegex.test(at))Te.push(he);else throw{code:"T0411",stack:new Error().stack,value:he,index:ve+1}}else Te.push(xe),ve++;else fe.split("").forEach(function(ie){if(Me.type==="a"){if(ie==="m")xe=void 0;else{xe=V[ve];var Be=!0;if(typeof Me.subtype<"u"){if(ie!=="a"&&fe!==Me.subtype)Be=!1;else if(ie==="a"&&xe.length>0){var ct=A(xe[0]);if(ct!==Me.subtype.charAt(0))Be=!1;else{var d=xe.filter(function(m){return A(m)!==ct});Be=d.length===0}}}if(!Be)throw{code:"T0412",stack:new Error().stack,value:xe,index:ve+1,type:u[Me.subtype]};ie!=="a"&&(xe=[xe])}Te.push(xe),ve++}else Te.push(xe),ve++})}),Te}$(V,_e)}}}return v})();a.exports=o},{"./utils":6}],6:[function(r,a,n){const i=(()=>{function o(R){var se=!1;if(typeof R=="number"&&(se=!isNaN(R),se&&!isFinite(R)))throw{code:"D1001",value:R,stack:new Error().stack};return se}function u(R){var se=!1;return Array.isArray(R)&&(se=R.filter(function(U){return typeof U!="string"}).length===0),se}function v(R){var se=!1;return Array.isArray(R)&&(se=R.filter(function(U){return!o(U)}).length===0),se}function k(){var R=[];return R.sequence=!0,arguments.length===1&&R.push(arguments[0]),R}function C(R){return R.sequence===!0&&Array.isArray(R)}function D(R){return R&&(R._jsonata_function===!0||R._jsonata_lambda===!0)||typeof R=="function"}function x(R){var se=typeof R.arity=="number"?R.arity:typeof R.implementation=="function"?R.implementation.length:typeof R.length=="number"?R.length:R.arguments.length;return se}function T(R){return R&&R._jsonata_lambda===!0}var I=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function ae(R){return typeof R=="object"&&R!==null&&I in R&&"next"in R&&typeof R.next=="function"}function Q(R,se){if(R===se)return!0;if(typeof R=="object"&&typeof se=="object"&&R!==null&&se!==null){if(Array.isArray(R)&&Array.isArray(se)){if(R.length!==se.length)return!1;for(var U=0;U<R.length;U++)if(!Q(R[U],se[U]))return!1;return!0}var A=Object.getOwnPropertyNames(R),$=Object.getOwnPropertyNames(se);if(A.length!==$.length)return!1;for(A=A.sort(),$=$.sort(),U=0;U<A.length;U++)if(A[U]!==$[U])return!1;for(U=0;U<A.length;U++){var V=A[U];if(!Q(R[V],se[V]))return!1}return!0}return!1}function pe(R){return typeof R=="object"&&R!==null&&"then"in R&&typeof R.then=="function"}function q(R){var se=[];for(let U of R)se.push(U);return se}return{isNumeric:o,isArrayOfStrings:u,isArrayOfNumbers:v,createSequence:k,isSequence:C,isFunction:D,isLambda:T,isIterable:ae,getFunctionArity:x,isDeepEqual:Q,stringToArray:q,isPromise:pe}})();a.exports=i},{}]},{},[3])(3)})})(Mr)),Mr.exports}var oi=ii();const ci=si(oi),on=b.object({name:b.literal("transform-data"),sourceData:b.any().optional(),expression:b.string().min(1,"JSONata expression is required")});function li(t){return on.parse(t)}async function ui(t){try{const{sourceData:e,expression:r}=t,a=e??{};let n;try{n=ci(r)}catch(o){throw new Error(`Invalid JSONata expression: ${o instanceof Error?o.message:"Unknown error"}`)}let i;try{i=await n.evaluate(a)}catch(o){throw console.error("JSONata evaluation failed:",o),new Error(`JSONata evaluation failed: ${o instanceof Error?o.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 cn=b.object({name:b.literal("export-data"),data:b.any(),format:b.enum(["json","csv","xlsx"]),filename:b.string().optional(),csvOptions:b.object({delimiter:b.string().optional(),includeHeaders:b.boolean().optional()}).optional()});function fi(t){return cn.parse(t)}async function di(t){try{const{data:e,format:r,filename:a,csvOptions:n}=t;console.log("[ExportDataBlock] Sending export request to background:",r);const i=await chrome.runtime.sendMessage({type:"EXPORT_DATA",data:{data:e,format:r,filename:a,csvOptions:n}});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 ln=b.object({name:b.literal("network-catch"),urlPattern:b.string().optional(),method:b.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),status:b.union([b.number(),b.object({min:b.number().optional(),max:b.number().optional()})]).optional(),mimeType:b.string().optional(),requestBodyPattern:b.union([b.string(),b.record(b.any())]).optional(),waitForRequest:b.boolean().optional(),waitTimeout:b.number().min(0).optional(),returnAll:b.boolean().optional(),includeHeaders:b.boolean().optional()});function hi(t){return ln.parse(t)}async function pi(t){try{console.log("[NetworkCatchBlock] Fetching network requests with pattern:",t.urlPattern);const e=await chrome.runtime.sendMessage({type:"NETWORK_CATCH",data:{urlPattern:t.urlPattern,method:t.method,status:t.status,mimeType:t.mimeType,requestBodyPattern:t.requestBodyPattern,waitForRequest:t.waitForRequest||!1,waitTimeout:t.waitTimeout||5e3,returnAll:t.returnAll||!1,includeHeaders:t.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 un=tt.extend({name:b.literal("mark-border"),borderStyle:b.object({color:b.string().optional(),width:b.number().optional(),style:b.enum(["solid","dashed","dotted","double"]).optional(),animated:b.boolean().optional()}).optional(),textFilter:b.object({text:b.union([b.string(),b.array(b.string())]),mode:b.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function mi(t){return un.parse(t)}async function gi(t){try{const{selector:e="",findBy:r="cssSelector",option:a,borderStyle:n,textFilter:i}=t;if(!e)throw new Error("Selector is required for mark-border block");const o=await rt({selector:e,findBy:r,option:a});if(!o)throw new Error("Element not found for marking border");let u;if(Array.isArray(o))if(i){const x=yi(o,i.text,i.mode);if(!x){const T=Array.isArray(i.text)?i.text.join(", "):i.text;throw new Error(`No element found with text filter: "${T}" (mode: ${i.mode})`)}u=[x]}else u=o;else u=[o];const v=(n==null?void 0:n.color)||"#9b59b6",k=(n==null?void 0:n.width)||3,C=(n==null?void 0:n.style)||"solid",D=(n==null?void 0:n.animated)!==!1;for(const x of u)bi(x,v,k,C,D);return{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in mark-border handler",data:!1}}}function yi(t,e,r){for(const a of t){const n=vi(a),i=Array.isArray(e)?e:[e];for(const o of i){let u=!1;switch(r){case"exact":u=n===o;break;case"contains":u=n.includes(o);break;case"startsWith":u=n.startsWith(o);break;case"endsWith":u=n.endsWith(o);break;case"regex":try{u=new RegExp(o).test(n)}catch{console.warn("Invalid regex pattern:",o);continue}break}if(u)return a}}return null}function vi(t){if(t.innerText)return t.innerText.trim();if(t.textContent)return t.textContent.trim();if(t instanceof HTMLInputElement&&t.value)return t.value.trim();const e=t.getAttribute("placeholder");if(e)return e.trim();const r=t.getAttribute("title");if(r)return r.trim();const a=t.getAttribute("aria-label");return a?a.trim():""}function bi(t,e,r,a,n=!0){t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});const i=t.style.border,o=t.style.outline,u=t.style.zIndex,v=t.style.position,k=t.style.animation;if(n&&!document.getElementById("mark-border-animation-style")){const C=document.createElement("style");C.id="mark-border-animation-style",C.textContent=`
1
+ "use strict";var zn=Object.defineProperty;var Hn=(t,e,r)=>e in t?zn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var le=(t,e,r)=>Hn(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var be;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{const i={};for(const o of n)i[o]=o;return i},t.getValidEnumValues=n=>{const i=t.objectKeys(n).filter(u=>typeof n[n[u]]!="number"),o={};for(const u of i)o[u]=n[u];return t.objectValues(o)},t.objectValues=n=>t.objectKeys(n).map(function(i){return n[i]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&i.push(o);return i},t.find=(n,i)=>{for(const o of n)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,i=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=a,t.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(be||(be={}));var Ir;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ir||(Ir={}));const Z=be.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_t=t=>{switch(typeof t){case"undefined":return Z.undefined;case"string":return Z.string;case"number":return Number.isNaN(t)?Z.nan:Z.number;case"boolean":return Z.boolean;case"function":return Z.function;case"bigint":return Z.bigint;case"symbol":return Z.symbol;case"object":return Array.isArray(t)?Z.array:t===null?Z.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Z.promise:typeof Map<"u"&&t instanceof Map?Z.map:typeof Set<"u"&&t instanceof Set?Z.set:typeof Date<"u"&&t instanceof Date?Z.date:Z.object;default:return Z.unknown}},C=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"]),qn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class ot 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 r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(i){return i.message},a={_errors:[]},n=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)a._errors.push(r(o));else{let u=a,v=0;for(;v<o.path.length;){const k=o.path[v];v===o.path.length-1?(u[k]=u[k]||{_errors:[]},u[k]._errors.push(r(o))):u[k]=u[k]||{_errors:[]},u=u[k],v++}}};return n(this),a}static assert(e){if(!(e instanceof ot))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=r=>r.message){const r={},a=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];r[i]=r[i]||[],r[i].push(e(n))}else a.push(e(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}}ot.create=t=>new ot(t);const Gt=(t,e)=>{let r;switch(t.code){case C.invalid_type:t.received===Z.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case C.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,be.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:r=`Unrecognized key(s) in object: ${be.joinValues(t.keys,", ")}`;break;case C.invalid_union:r="Invalid input";break;case C.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${be.joinValues(t.options)}`;break;case C.invalid_enum_value:r=`Invalid enum value. Expected ${be.joinValues(t.options)}, received '${t.received}'`;break;case C.invalid_arguments:r="Invalid function arguments";break;case C.invalid_return_type:r="Invalid function return type";break;case C.invalid_date:r="Invalid date";break;case C.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:be.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case C.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case C.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case C.custom:r="Invalid input";break;case C.invalid_intersection_types:r="Intersection results could not be merged";break;case C.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case C.not_finite:r="Number must be finite";break;default:r=e.defaultError,be.assertNever(t)}return{message:r}};let Dn=Gt;function Gn(t){Dn=t}function _r(){return Dn}const Er=t=>{const{data:e,path:r,errorMaps:a,issueData:n}=t,i=[...r,...n.path||[]],o={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let u="";const v=a.filter(k=>!!k).slice().reverse();for(const k of v)u=k(o,{data:e,defaultError:u}).message;return{...n,path:i,message:u}},Yn=[];function L(t,e){const r=_r(),a=Er({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Gt?void 0:Gt].filter(n=>!!n)});t.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,r){const a=[];for(const n of r){if(n.status==="aborted")return te;n.status==="dirty"&&e.dirty(),a.push(n.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,r){const a=[];for(const n of r){const i=await n.key,o=await n.value;a.push({key:i,value:o})}return Ke.mergeObjectSync(e,a)}static mergeObjectSync(e,r){const a={};for(const n of r){const{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return te;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(a[i.value]=o.value)}return{status:e.value,value:a}}}const te=Object.freeze({status:"aborted"}),Ht=t=>({status:"dirty",value:t}),Xe=t=>({status:"valid",value:t}),jr=t=>t.status==="aborted",Fr=t=>t.status==="dirty",Ft=t=>t.status==="valid",tr=t=>typeof Promise<"u"&&t instanceof Promise;var Y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class vt{constructor(e,r,a,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=a,this._key=n}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 yn=(t,e)=>{if(Ft(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new ot(t.common.issues);return this._error=r,this._error}}};function oe(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:a,description:n}=t;if(e&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(o,u)=>{const{message:v}=t;return o.code==="invalid_enum_value"?{message:v??u.defaultError}:typeof u.data>"u"?{message:v??a??u.defaultError}:o.code!=="invalid_type"?{message:u.defaultError}:{message:v??r??u.defaultError}},description:n}}class ue{get description(){return this._def.description}_getType(e){return _t(e.data)}_getOrReturnCtx(e,r){return r||{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 r=this._parse(e);if(tr(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const a=this.safeParse(e,r);if(a.success)return a.data;throw a.error}safeParse(e,r){const a={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},n=this._parseSync({data:e,path:a.path,parent:a});return yn(a,n)}"~validate"(e){var a,n;const r={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:r});return Ft(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(n=(a=i==null?void 0:i.message)==null?void 0:a.toLowerCase())!=null&&n.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>Ft(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const a=await this.safeParseAsync(e,r);if(a.success)return a.data;throw a.error}async safeParseAsync(e,r){const a={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_t(e)},n=this._parse({data:e,path:a.path,parent:a}),i=await(tr(n)?n:Promise.resolve(n));return yn(a,i)}refine(e,r){const a=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,i)=>{const o=e(n),u=()=>i.addIssue({code:C.custom,...a(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(v=>v?!0:(u(),!1)):o?!0:(u(),!1)})}refinement(e,r){return this._refinement((a,n)=>e(a)?!0:(n.addIssue(typeof r=="function"?r(a,n):r),!1))}_refinement(e){return new mt({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:r=>this["~validate"](r)}}optional(){return yt.create(this,this._def)}nullable(){return Nt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pt.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 mt({...oe(this._def),schema:this,typeName:ne.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new fr({...oe(this._def),innerType:this,defaultValue:r,typeName:ne.ZodDefault})}brand(){return new $r({typeName:ne.ZodBranded,type:this,...oe(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new dr({...oe(this._def),innerType:this,catchValue:r,typeName:ne.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return mr.create(this,e)}readonly(){return hr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Kn=/^c[^\s-]{8,}$/i,Jn=/^[0-9a-z]+$/,Xn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Qn=/^[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,ea=/^[a-z0-9_-]{21}$/i,ta=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ra=/^[-+]?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)?)??$/,na=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,aa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Nr;const sa=/^(?:(?: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])$/,ia=/^(?:(?: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])$/,oa=/^(([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]))$/,ca=/^(([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])$/,la=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ua=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Pn="((\\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])))",fa=new RegExp(`^${Pn}$`);function On(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function da(t){return new RegExp(`^${On(t)}$`)}function Cn(t){let e=`${Pn}T${On(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function ha(t,e){return!!((e==="v4"||!e)&&sa.test(t)||(e==="v6"||!e)&&oa.test(t))}function pa(t,e){if(!ta.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function ma(t,e){return!!((e==="v4"||!e)&&ia.test(t)||(e==="v6"||!e)&&ca.test(t))}class ht extends ue{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Z.string){const i=this._getOrReturnCtx(e);return L(i,{code:C.invalid_type,expected:Z.string,received:i.parsedType}),te}const a=new Ke;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:C.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&&(n=this._getOrReturnCtx(e,n),L(n,{code:C.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,u=e.data.length<i.value;(o||u)&&(n=this._getOrReturnCtx(e,n),o?L(n,{code:C.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):u&&L(n,{code:C.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")na.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"email",code:C.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")Nr||(Nr=new RegExp(aa,"u")),Nr.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"emoji",code:C.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")Qn.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"uuid",code:C.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")ea.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"nanoid",code:C.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")Kn.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"cuid",code:C.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")Jn.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"cuid2",code:C.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")Xn.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"ulid",code:C.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),L(n,{validation:"url",code:C.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"regex",code:C.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)||(n=this._getOrReturnCtx(e,n),L(n,{code:C.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)||(n=this._getOrReturnCtx(e,n),L(n,{code:C.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),L(n,{code:C.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?Cn(i).test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:C.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?fa.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:C.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?da(i).test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:C.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?ra.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"duration",code:C.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?ha(e.data,i.version)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"ip",code:C.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?pa(e.data,i.alg)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"jwt",code:C.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?ma(e.data,i.version)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"cidr",code:C.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?la.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"base64",code:C.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?ua.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:"base64url",code:C.invalid_string,message:i.message}),a.dirty()):be.assertNever(i);return{status:a.value,value:e.data}}_regex(e,r,a){return this.refinement(n=>e.test(n),{validation:r,code:C.invalid_string,...Y.errToObj(a)})}_addCheck(e){return new ht({...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,r){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Y.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Y.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Y.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Y.errToObj(r)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new ht({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ht({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ht({...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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}ht.create=t=>new ht({checks:[],typeName:ne.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...oe(t)});function ga(t,e){const r=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,n=r>a?r:a,i=Number.parseInt(t.toFixed(n).replace(".","")),o=Number.parseInt(e.toFixed(n).replace(".",""));return i%o/10**n}class Pt extends ue{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)!==Z.number){const i=this._getOrReturnCtx(e);return L(i,{code:C.invalid_type,expected:Z.number,received:i.parsedType}),te}let a;const n=new Ke;for(const i of this._def.checks)i.kind==="int"?be.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),L(a,{code:C.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(a=this._getOrReturnCtx(e,a),L(a,{code:C.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),L(a,{code:C.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?ga(e.data,i.value)!==0&&(a=this._getOrReturnCtx(e,a),L(a,{code:C.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),L(a,{code:C.not_finite,message:i.message}),n.dirty()):be.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Y.toString(r))}setLimit(e,r,a,n){return new Pt({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:Y.toString(n)}]})}_addCheck(e){return new Pt({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.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,r=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Pt.create=t=>new Pt({checks:[],typeName:ne.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...oe(t)});class Ot extends ue{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)!==Z.bigint)return this._getInvalidInput(e);let a;const n=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),L(a,{code:C.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(a=this._getOrReturnCtx(e,a),L(a,{code:C.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),L(a,{code:C.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):be.assertNever(i);return{status:n.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return L(r,{code:C.invalid_type,expected:Z.bigint,received:r.parsedType}),te}gte(e,r){return this.setLimit("min",e,!0,Y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Y.toString(r))}setLimit(e,r,a,n){return new Ot({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:Y.toString(n)}]})}_addCheck(e){return new Ot({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Ot.create=t=>new Ot({checks:[],typeName:ne.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...oe(t)});class rr extends ue{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Z.boolean){const a=this._getOrReturnCtx(e);return L(a,{code:C.invalid_type,expected:Z.boolean,received:a.parsedType}),te}return Xe(e.data)}}rr.create=t=>new rr({typeName:ne.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...oe(t)});class Bt extends ue{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Z.date){const i=this._getOrReturnCtx(e);return L(i,{code:C.invalid_type,expected:Z.date,received:i.parsedType}),te}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return L(i,{code:C.invalid_date}),te}const a=new Ke;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:C.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:C.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,r){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Bt.create=t=>new Bt({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:ne.ZodDate,...oe(t)});class Ar extends ue{_parse(e){if(this._getType(e)!==Z.symbol){const a=this._getOrReturnCtx(e);return L(a,{code:C.invalid_type,expected:Z.symbol,received:a.parsedType}),te}return Xe(e.data)}}Ar.create=t=>new Ar({typeName:ne.ZodSymbol,...oe(t)});class nr extends ue{_parse(e){if(this._getType(e)!==Z.undefined){const a=this._getOrReturnCtx(e);return L(a,{code:C.invalid_type,expected:Z.undefined,received:a.parsedType}),te}return Xe(e.data)}}nr.create=t=>new nr({typeName:ne.ZodUndefined,...oe(t)});class ar extends ue{_parse(e){if(this._getType(e)!==Z.null){const a=this._getOrReturnCtx(e);return L(a,{code:C.invalid_type,expected:Z.null,received:a.parsedType}),te}return Xe(e.data)}}ar.create=t=>new ar({typeName:ne.ZodNull,...oe(t)});class Yt extends ue{constructor(){super(...arguments),this._any=!0}_parse(e){return Xe(e.data)}}Yt.create=t=>new Yt({typeName:ne.ZodAny,...oe(t)});class jt extends ue{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Xe(e.data)}}jt.create=t=>new jt({typeName:ne.ZodUnknown,...oe(t)});class Et extends ue{_parse(e){const r=this._getOrReturnCtx(e);return L(r,{code:C.invalid_type,expected:Z.never,received:r.parsedType}),te}}Et.create=t=>new Et({typeName:ne.ZodNever,...oe(t)});class Tr extends ue{_parse(e){if(this._getType(e)!==Z.undefined){const a=this._getOrReturnCtx(e);return L(a,{code:C.invalid_type,expected:Z.void,received:a.parsedType}),te}return Xe(e.data)}}Tr.create=t=>new Tr({typeName:ne.ZodVoid,...oe(t)});class pt extends ue{_parse(e){const{ctx:r,status:a}=this._processInputParams(e),n=this._def;if(r.parsedType!==Z.array)return L(r,{code:C.invalid_type,expected:Z.array,received:r.parsedType}),te;if(n.exactLength!==null){const o=r.data.length>n.exactLength.value,u=r.data.length<n.exactLength.value;(o||u)&&(L(r,{code:o?C.too_big:C.too_small,minimum:u?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(L(r,{code:C.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(L(r,{code:C.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((o,u)=>n.type._parseAsync(new vt(r,o,r.path,u)))).then(o=>Ke.mergeArray(a,o));const i=[...r.data].map((o,u)=>n.type._parseSync(new vt(r,o,r.path,u)));return Ke.mergeArray(a,i)}get element(){return this._def.type}min(e,r){return new pt({...this._def,minLength:{value:e,message:Y.toString(r)}})}max(e,r){return new pt({...this._def,maxLength:{value:e,message:Y.toString(r)}})}length(e,r){return new pt({...this._def,exactLength:{value:e,message:Y.toString(r)}})}nonempty(e){return this.min(1,e)}}pt.create=(t,e)=>new pt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ne.ZodArray,...oe(e)});function zt(t){if(t instanceof je){const e={};for(const r in t.shape){const a=t.shape[r];e[r]=yt.create(zt(a))}return new je({...t._def,shape:()=>e})}else return t instanceof pt?new pt({...t._def,type:zt(t.element)}):t instanceof yt?yt.create(zt(t.unwrap())):t instanceof Nt?Nt.create(zt(t.unwrap())):t instanceof bt?bt.create(t.items.map(e=>zt(e))):t}class je extends ue{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(),r=be.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Z.object){const k=this._getOrReturnCtx(e);return L(k,{code:C.invalid_type,expected:Z.object,received:k.parsedType}),te}const{status:a,ctx:n}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),u=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const k in n.data)o.includes(k)||u.push(k);const v=[];for(const k of o){const O=i[k],D=n.data[k];v.push({key:{status:"valid",value:k},value:O._parse(new vt(n,D,n.path,k)),alwaysSet:k in n.data})}if(this._def.catchall instanceof Et){const k=this._def.unknownKeys;if(k==="passthrough")for(const O of u)v.push({key:{status:"valid",value:O},value:{status:"valid",value:n.data[O]}});else if(k==="strict")u.length>0&&(L(n,{code:C.unrecognized_keys,keys:u}),a.dirty());else if(k!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const k=this._def.catchall;for(const O of u){const D=n.data[O];v.push({key:{status:"valid",value:O},value:k._parse(new vt(n,D,n.path,O)),alwaysSet:O in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const k=[];for(const O of v){const D=await O.key,_=await O.value;k.push({key:D,value:_,alwaysSet:O.alwaysSet})}return k}).then(k=>Ke.mergeObjectSync(a,k)):Ke.mergeObjectSync(a,v)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new je({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,a)=>{var i,o;const n=((o=(i=this._def).errorMap)==null?void 0:o.call(i,r,a).message)??a.defaultError;return r.code==="unrecognized_keys"?{message:Y.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new je({...this._def,unknownKeys:"strip"})}passthrough(){return new je({...this._def,unknownKeys:"passthrough"})}extend(e){return new je({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new je({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ne.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new je({...this._def,catchall:e})}pick(e){const r={};for(const a of be.objectKeys(e))e[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new je({...this._def,shape:()=>r})}omit(e){const r={};for(const a of be.objectKeys(this.shape))e[a]||(r[a]=this.shape[a]);return new je({...this._def,shape:()=>r})}deepPartial(){return zt(this)}partial(e){const r={};for(const a of be.objectKeys(this.shape)){const n=this.shape[a];e&&!e[a]?r[a]=n:r[a]=n.optional()}return new je({...this._def,shape:()=>r})}required(e){const r={};for(const a of be.objectKeys(this.shape))if(e&&!e[a])r[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof yt;)i=i._def.innerType;r[a]=i}return new je({...this._def,shape:()=>r})}keyof(){return Nn(be.objectKeys(this.shape))}}je.create=(t,e)=>new je({shape:()=>t,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});je.strictCreate=(t,e)=>new je({shape:()=>t,unknownKeys:"strict",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});je.lazycreate=(t,e)=>new je({shape:t,unknownKeys:"strip",catchall:Et.create(),typeName:ne.ZodObject,...oe(e)});class sr extends ue{_parse(e){const{ctx:r}=this._processInputParams(e),a=this._def.options;function n(i){for(const u of i)if(u.result.status==="valid")return u.result;for(const u of i)if(u.result.status==="dirty")return r.common.issues.push(...u.ctx.common.issues),u.result;const o=i.map(u=>new ot(u.ctx.common.issues));return L(r,{code:C.invalid_union,unionErrors:o}),te}if(r.common.async)return Promise.all(a.map(async i=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let i;const o=[];for(const v of a){const k={...r,common:{...r.common,issues:[]},parent:null},O=v._parseSync({data:r.data,path:r.path,parent:k});if(O.status==="valid")return O;O.status==="dirty"&&!i&&(i={result:O,ctx:k}),k.common.issues.length&&o.push(k.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const u=o.map(v=>new ot(v));return L(r,{code:C.invalid_union,unionErrors:u}),te}}get options(){return this._def.options}}sr.create=(t,e)=>new sr({options:t,typeName:ne.ZodUnion,...oe(e)});const xt=t=>t instanceof cr?xt(t.schema):t instanceof mt?xt(t.innerType()):t instanceof lr?[t.value]:t instanceof Ct?t.options:t instanceof ur?be.objectValues(t.enum):t instanceof fr?xt(t._def.innerType):t instanceof nr?[void 0]:t instanceof ar?[null]:t instanceof yt?[void 0,...xt(t.unwrap())]:t instanceof Nt?[null,...xt(t.unwrap())]:t instanceof $r||t instanceof hr?xt(t.unwrap()):t instanceof dr?xt(t._def.innerType):[];class Pr extends ue{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Z.object)return L(r,{code:C.invalid_type,expected:Z.object,received:r.parsedType}),te;const a=this.discriminator,n=r.data[a],i=this.optionsMap.get(n);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(L(r,{code:C.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,r,a){const n=new Map;for(const i of r){const o=xt(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const u of o){if(n.has(u))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(u)}`);n.set(u,i)}}return new Pr({typeName:ne.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...oe(a)})}}function Br(t,e){const r=_t(t),a=_t(e);if(t===e)return{valid:!0,data:t};if(r===Z.object&&a===Z.object){const n=be.objectKeys(e),i=be.objectKeys(t).filter(u=>n.indexOf(u)!==-1),o={...t,...e};for(const u of i){const v=Br(t[u],e[u]);if(!v.valid)return{valid:!1};o[u]=v.data}return{valid:!0,data:o}}else if(r===Z.array&&a===Z.array){if(t.length!==e.length)return{valid:!1};const n=[];for(let i=0;i<t.length;i++){const o=t[i],u=e[i],v=Br(o,u);if(!v.valid)return{valid:!1};n.push(v.data)}return{valid:!0,data:n}}else return r===Z.date&&a===Z.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ir extends ue{_parse(e){const{status:r,ctx:a}=this._processInputParams(e),n=(i,o)=>{if(jr(i)||jr(o))return te;const u=Br(i.value,o.value);return u.valid?((Fr(i)||Fr(o))&&r.dirty(),{status:r.value,value:u.data}):(L(a,{code:C.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,o])=>n(i,o)):n(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=(t,e,r)=>new ir({left:t,right:e,typeName:ne.ZodIntersection,...oe(r)});class bt extends ue{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==Z.array)return L(a,{code:C.invalid_type,expected:Z.array,received:a.parsedType}),te;if(a.data.length<this._def.items.length)return L(a,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),te;!this._def.rest&&a.data.length>this._def.items.length&&(L(a,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...a.data].map((o,u)=>{const v=this._def.items[u]||this._def.rest;return v?v._parse(new vt(a,o,a.path,u)):null}).filter(o=>!!o);return a.common.async?Promise.all(i).then(o=>Ke.mergeArray(r,o)):Ke.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new bt({...this._def,rest:e})}}bt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new bt({items:t,typeName:ne.ZodTuple,rest:null,...oe(e)})};class or extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==Z.object)return L(a,{code:C.invalid_type,expected:Z.object,received:a.parsedType}),te;const n=[],i=this._def.keyType,o=this._def.valueType;for(const u in a.data)n.push({key:i._parse(new vt(a,u,a.path,u)),value:o._parse(new vt(a,a.data[u],a.path,u)),alwaysSet:u in a.data});return a.common.async?Ke.mergeObjectAsync(r,n):Ke.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,a){return r instanceof ue?new or({keyType:e,valueType:r,typeName:ne.ZodRecord,...oe(a)}):new or({keyType:ht.create(),valueType:e,typeName:ne.ZodRecord,...oe(r)})}}class Sr extends ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==Z.map)return L(a,{code:C.invalid_type,expected:Z.map,received:a.parsedType}),te;const n=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([u,v],k)=>({key:n._parse(new vt(a,u,a.path,[k,"key"])),value:i._parse(new vt(a,v,a.path,[k,"value"]))}));if(a.common.async){const u=new Map;return Promise.resolve().then(async()=>{for(const v of o){const k=await v.key,O=await v.value;if(k.status==="aborted"||O.status==="aborted")return te;(k.status==="dirty"||O.status==="dirty")&&r.dirty(),u.set(k.value,O.value)}return{status:r.value,value:u}})}else{const u=new Map;for(const v of o){const k=v.key,O=v.value;if(k.status==="aborted"||O.status==="aborted")return te;(k.status==="dirty"||O.status==="dirty")&&r.dirty(),u.set(k.value,O.value)}return{status:r.value,value:u}}}}Sr.create=(t,e,r)=>new Sr({valueType:e,keyType:t,typeName:ne.ZodMap,...oe(r)});class Lt extends ue{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==Z.set)return L(a,{code:C.invalid_type,expected:Z.set,received:a.parsedType}),te;const n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(L(a,{code:C.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(L(a,{code:C.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());const i=this._def.valueType;function o(v){const k=new Set;for(const O of v){if(O.status==="aborted")return te;O.status==="dirty"&&r.dirty(),k.add(O.value)}return{status:r.value,value:k}}const u=[...a.data.values()].map((v,k)=>i._parse(new vt(a,v,a.path,k)));return a.common.async?Promise.all(u).then(v=>o(v)):o(u)}min(e,r){return new Lt({...this._def,minSize:{value:e,message:Y.toString(r)}})}max(e,r){return new Lt({...this._def,maxSize:{value:e,message:Y.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Lt.create=(t,e)=>new Lt({valueType:t,minSize:null,maxSize:null,typeName:ne.ZodSet,...oe(e)});class qt extends ue{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Z.function)return L(r,{code:C.invalid_type,expected:Z.function,received:r.parsedType}),te;function a(u,v){return Er({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_r(),Gt].filter(k=>!!k),issueData:{code:C.invalid_arguments,argumentsError:v}})}function n(u,v){return Er({data:u,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_r(),Gt].filter(k=>!!k),issueData:{code:C.invalid_return_type,returnTypeError:v}})}const i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Kt){const u=this;return Xe(async function(...v){const k=new ot([]),O=await u._def.args.parseAsync(v,i).catch(T=>{throw k.addIssue(a(v,T)),k}),D=await Reflect.apply(o,this,O);return await u._def.returns._def.type.parseAsync(D,i).catch(T=>{throw k.addIssue(n(D,T)),k})})}else{const u=this;return Xe(function(...v){const k=u._def.args.safeParse(v,i);if(!k.success)throw new ot([a(v,k.error)]);const O=Reflect.apply(o,this,k.data),D=u._def.returns.safeParse(O,i);if(!D.success)throw new ot([n(O,D.error)]);return D.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new qt({...this._def,args:bt.create(e).rest(jt.create())})}returns(e){return new qt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,a){return new qt({args:e||bt.create([]).rest(jt.create()),returns:r||jt.create(),typeName:ne.ZodFunction,...oe(a)})}}class cr extends ue{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}cr.create=(t,e)=>new cr({getter:t,typeName:ne.ZodLazy,...oe(e)});class lr extends ue{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return L(r,{received:r.data,code:C.invalid_literal,expected:this._def.value}),te}return{status:"valid",value:e.data}}get value(){return this._def.value}}lr.create=(t,e)=>new lr({value:t,typeName:ne.ZodLiteral,...oe(e)});function Nn(t,e){return new Ct({values:t,typeName:ne.ZodEnum,...oe(e)})}class Ct extends ue{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),a=this._def.values;return L(r,{expected:be.joinValues(a),received:r.parsedType,code:C.invalid_type}),te}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),a=this._def.values;return L(r,{received:r.data,code:C.invalid_enum_value,options:a}),te}return Xe(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Ct.create(e,{...this._def,...r})}exclude(e,r=this._def){return Ct.create(this.options.filter(a=>!e.includes(a)),{...this._def,...r})}}Ct.create=Nn;class ur extends ue{_parse(e){const r=be.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==Z.string&&a.parsedType!==Z.number){const n=be.objectValues(r);return L(a,{expected:be.joinValues(n),received:a.parsedType,code:C.invalid_type}),te}if(this._cache||(this._cache=new Set(be.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=be.objectValues(r);return L(a,{received:a.data,code:C.invalid_enum_value,options:n}),te}return Xe(e.data)}get enum(){return this._def.values}}ur.create=(t,e)=>new ur({values:t,typeName:ne.ZodNativeEnum,...oe(e)});class Kt extends ue{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Z.promise&&r.common.async===!1)return L(r,{code:C.invalid_type,expected:Z.promise,received:r.parsedType}),te;const a=r.parsedType===Z.promise?r.data:Promise.resolve(r.data);return Xe(a.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Kt.create=(t,e)=>new Kt({type:t,typeName:ne.ZodPromise,...oe(e)});class mt extends ue{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:r,ctx:a}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:o=>{L(a,o),o.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){const o=n.transform(a.data,i);if(a.common.async)return Promise.resolve(o).then(async u=>{if(r.value==="aborted")return te;const v=await this._def.schema._parseAsync({data:u,path:a.path,parent:a});return v.status==="aborted"?te:v.status==="dirty"||r.value==="dirty"?Ht(v.value):v});{if(r.value==="aborted")return te;const u=this._def.schema._parseSync({data:o,path:a.path,parent:a});return u.status==="aborted"?te:u.status==="dirty"||r.value==="dirty"?Ht(u.value):u}}if(n.type==="refinement"){const o=u=>{const v=n.refinement(u,i);if(a.common.async)return Promise.resolve(v);if(v instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return u};if(a.common.async===!1){const u=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return u.status==="aborted"?te:(u.status==="dirty"&&r.dirty(),o(u.value),{status:r.value,value:u.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(u=>u.status==="aborted"?te:(u.status==="dirty"&&r.dirty(),o(u.value).then(()=>({status:r.value,value:u.value}))))}if(n.type==="transform")if(a.common.async===!1){const o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Ft(o))return te;const u=n.transform(o.value,i);if(u instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:u}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>Ft(o)?Promise.resolve(n.transform(o.value,i)).then(u=>({status:r.value,value:u})):te);be.assertNever(n)}}mt.create=(t,e,r)=>new mt({schema:t,typeName:ne.ZodEffects,effect:e,...oe(r)});mt.createWithPreprocess=(t,e,r)=>new mt({schema:e,effect:{type:"preprocess",transform:t},typeName:ne.ZodEffects,...oe(r)});class yt extends ue{_parse(e){return this._getType(e)===Z.undefined?Xe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}yt.create=(t,e)=>new yt({innerType:t,typeName:ne.ZodOptional,...oe(e)});class Nt extends ue{_parse(e){return this._getType(e)===Z.null?Xe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Nt.create=(t,e)=>new Nt({innerType:t,typeName:ne.ZodNullable,...oe(e)});class fr extends ue{_parse(e){const{ctx:r}=this._processInputParams(e);let a=r.data;return r.parsedType===Z.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}fr.create=(t,e)=>new fr({innerType:t,typeName:ne.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...oe(e)});class dr extends ue{_parse(e){const{ctx:r}=this._processInputParams(e),a={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return tr(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ot(a.common.issues)},input:a.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new ot(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}dr.create=(t,e)=>new dr({innerType:t,typeName:ne.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...oe(e)});class Dr extends ue{_parse(e){if(this._getType(e)!==Z.nan){const a=this._getOrReturnCtx(e);return L(a,{code:C.invalid_type,expected:Z.nan,received:a.parsedType}),te}return{status:"valid",value:e.data}}}Dr.create=t=>new Dr({typeName:ne.ZodNaN,...oe(t)});const ya=Symbol("zod_brand");class $r extends ue{_parse(e){const{ctx:r}=this._processInputParams(e),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}}class mr extends ue{_parse(e){const{status:r,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"?(r.dirty(),Ht(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{const n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?te:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(e,r){return new mr({in:e,out:r,typeName:ne.ZodPipeline})}}class hr extends ue{_parse(e){const r=this._def.innerType._parse(e),a=n=>(Ft(n)&&(n.value=Object.freeze(n.value)),n);return tr(r)?r.then(n=>a(n)):a(r)}unwrap(){return this._def.innerType}}hr.create=(t,e)=>new hr({innerType:t,typeName:ne.ZodReadonly,...oe(e)});function vn(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Rn(t,e={},r){return t?Yt.create().superRefine((a,n)=>{const i=t(a);if(i instanceof Promise)return i.then(o=>{if(!o){const u=vn(e,a),v=u.fatal??r??!0;n.addIssue({code:"custom",...u,fatal:v})}});if(!i){const o=vn(e,a),u=o.fatal??r??!0;n.addIssue({code:"custom",...o,fatal:u})}}):Yt.create()}const va={object:je.lazycreate};var ne;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ne||(ne={}));const ba=(t,e={message:`Input not instance of ${t.name}`})=>Rn(r=>r instanceof t,e),Oe=ht.create,$t=Pt.create,wa=Dr.create,ka=Ot.create,Rt=rr.create,xa=Bt.create,_a=Ar.create,Ea=nr.create,Aa=ar.create,Ta=Yt.create,Sa=jt.create,Da=Et.create,Pa=Tr.create,Oa=pt.create,At=je.create,Ca=je.strictCreate,Na=sr.create,Ra=Pr.create,Ma=ir.create,Ia=bt.create,ja=or.create,Fa=Sr.create,Ba=Lt.create,La=qt.create,$a=cr.create,Ua=lr.create,Ur=Ct.create,Vr=ur.create,Va=Kt.create,bn=mt.create,Za=yt.create,Wa=Nt.create,za=mt.createWithPreprocess,Ha=mr.create,qa=()=>Oe().optional(),Ga=()=>$t().optional(),Ya=()=>Rt().optional(),pr={string:(t=>ht.create({...t,coerce:!0})),number:(t=>Pt.create({...t,coerce:!0})),boolean:(t=>rr.create({...t,coerce:!0})),bigint:(t=>Ot.create({...t,coerce:!0})),date:(t=>Bt.create({...t,coerce:!0}))},Ka=te,b=Object.freeze(Object.defineProperty({__proto__:null,BRAND:ya,DIRTY:Ht,EMPTY_PATH:Yn,INVALID:te,NEVER:Ka,OK:Xe,ParseStatus:Ke,Schema:ue,ZodAny:Yt,ZodArray:pt,ZodBigInt:Ot,ZodBoolean:rr,ZodBranded:$r,ZodCatch:dr,ZodDate:Bt,ZodDefault:fr,ZodDiscriminatedUnion:Pr,ZodEffects:mt,ZodEnum:Ct,ZodError:ot,get ZodFirstPartyTypeKind(){return ne},ZodFunction:qt,ZodIntersection:ir,ZodIssueCode:C,ZodLazy:cr,ZodLiteral:lr,ZodMap:Sr,ZodNaN:Dr,ZodNativeEnum:ur,ZodNever:Et,ZodNull:ar,ZodNullable:Nt,ZodNumber:Pt,ZodObject:je,ZodOptional:yt,ZodParsedType:Z,ZodPipeline:mr,ZodPromise:Kt,ZodReadonly:hr,ZodRecord:or,ZodSchema:ue,ZodSet:Lt,ZodString:ht,ZodSymbol:Ar,ZodTransformer:mt,ZodTuple:bt,ZodType:ue,ZodUndefined:nr,ZodUnion:sr,ZodUnknown:jt,ZodVoid:Tr,addIssueToContext:L,any:Ta,array:Oa,bigint:ka,boolean:Rt,coerce:pr,custom:Rn,date:xa,datetimeRegex:Cn,defaultErrorMap:Gt,discriminatedUnion:Ra,effect:bn,enum:Ur,function:La,getErrorMap:_r,getParsedType:_t,instanceof:ba,intersection:Ma,isAborted:jr,isAsync:tr,isDirty:Fr,isValid:Ft,late:va,lazy:$a,literal:Ua,makeIssue:Er,map:Fa,nan:wa,nativeEnum:Vr,never:Da,null:Aa,nullable:Wa,number:$t,object:At,get objectUtil(){return Ir},oboolean:Ya,onumber:Ga,optional:Za,ostring:qa,pipeline:Ha,preprocess:za,promise:Va,quotelessJson:qn,record:ja,set:Ba,setErrorMap:Gn,strictObject:Ca,string:Oe,symbol:_a,transformer:bn,tuple:Ia,undefined:Ea,union:Na,unknown:Sa,get util(){return be},void:Pa},Symbol.toStringTag,{value:"Module"})),tt=At({name:Oe(),selector:Oe(),findBy:Ur(["cssSelector","xpath"]),option:At({waitForSelector:Rt().optional(),waitSelectorTimeout:$t().optional(),multiple:Rt().optional()})}),Ja=b.object({type:b.literal("object"),shape:b.record(b.string(),b.any())}),Xa=b.object({type:b.literal("array"),items:b.any()}),Qa=b.discriminatedUnion("type",[Ja,Xa]),Zr=b.object({name:b.literal("ai-parse-data"),sourceData:b.any().optional(),schemaDefinition:Qa,prompt:b.string().optional(),model:b.string().optional(),apiKey:b.string().min(1,"AI API key is required"),provider:b.enum(["openai","anthropic"])});function es(t){return Zr.parse(t)}async function ts(t){try{const{sourceData:e,schemaDefinition:r,prompt:a,model:n,apiKey:i,provider:o}=t;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 u=await chrome.runtime.sendMessage({type:"AI_PARSE_DATA",data:{sourceData:e,schemaDefinition:r,prompt:a,model:n,apiKey:i,provider:o}});if(u.$isError)throw new Error(u.message||"AI parsing failed");return{data:u.data}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in ai-parse-data handler",data:null}}}function rs(t){return{type:"object",shape:t}}function ns(t){return{type:"array",items:t}}const as={string:t=>({type:"string",...t}),number:t=>({type:"number",...t}),boolean:t=>({type:"boolean",...t}),array:(t,e)=>({type:"array",items:t,...e}),object:(t,e)=>({type:"object",shape:t,...e}),currency:t=>({type:"currency",shape:In,description:(t==null?void 0:t.description)||"Currency information with code, symbol, format, amount, and text",optional:t==null?void 0:t.optional})};class Or{async waitForElement(e,r,a){return new Promise(n=>{const i=Date.now(),o=async()=>{const u=await this.find(e,r);if(u&&(!Array.isArray(u)||u.length>0)){n(u);return}if(Date.now()-i>=a){n(null);return}setTimeout(o,100)};o()})}}class ss extends Or{async find(e,r=document){const{selector:a,option:n}=e,{multiple:i=!1}=n||{};try{const o=this.processCustomPseudoSelectors(a,r);return i?Array.from(r.querySelectorAll(o)):r.querySelector(o)}catch(o){return console.error("CSS Selector error:",o),null}}processCustomPseudoSelectors(e,r){return/:contains\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:contains\(['"]([^'"]*)['"]\)/g,(i,o)=>`[data-contains="${o}"]`)):/:equal\(['"]([^'"]*)['"]\)/g.test(e)?(this.markElementsWithText(r),e.replace(/:equal\(['"]([^'"]*)['"]\)/g,(i,o)=>`[data-equal="${o}"]`)):e}markElementsWithText(e){e.querySelectorAll("*").forEach(a=>{var i;const n=((i=a.textContent)==null?void 0:i.trim())||"";if(n){a.setAttribute("data-contains",n);const u=Array.from(a.childNodes).filter(v=>v.nodeType===Node.TEXT_NODE).map(v=>{var k;return((k=v.textContent)==null?void 0:k.trim())||""}).join(" ").trim();(u&&u===n||a.children.length===0&&n)&&a.setAttribute("data-equal",n)}})}}class is extends Or{async find(e,r=document){const{selector:a,option:n}=e,{multiple:i=!1}=n||{};if(!a||a.trim()==="")return null;const o=a.split("|>").map(k=>k.trim());if(o.length!==2)return null;const u=o[0],v=o[1];if(!u||!v)return null;try{const k=r.querySelector(u);if(!k||!k.contentDocument)return null;const O=k.contentDocument;return i?Array.from(O.querySelectorAll(v)):O.querySelector(v)}catch(k){return console.error("Iframe Selector error:",k),null}}}class os extends Or{async find(e,r=document){const{selector:a,option:n}=e,{multiple:i=!1}=n||{};if(!a||a.trim()==="")return null;const o=a.split(">>").map(v=>v.trim());let u=r;try{for(let v=0;v<o.length;v++){const k=o[v],O=v===o.length-1;if(!k)return null;if(O&&i)return Array.from(u.querySelectorAll(k));const D=u.querySelector(k);if(!D)return null;if(O)return D;if(D.shadowRoot)u=D.shadowRoot;else return null}}catch(v){return console.error("Shadow DOM Selector error:",v),null}return null}}class cs extends Or{async find(e,r=document){const{selector:a,option:n}=e,{multiple:i=!1}=n||{};try{const o=r.evaluate(a,r,null,i?XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(i){const u=[];for(let v=0;v<o.snapshotLength;v++){const k=o.snapshotItem(v);k&&k.nodeType===Node.ELEMENT_NODE&&u.push(k)}return Promise.resolve(u.length>0?u:null)}else{const u=o.singleNodeValue;return u&&u.nodeType===Node.ELEMENT_NODE?u:null}}catch(o){return console.error("XPath error:",o),null}}}class ls{static generate(e){const r=["data-testid","aria-label","title","alt","role"];for(const i of r){const o=e.getAttribute(i);if(o&&!this.isDynamicValue(o))return`[${i}="${CSS.escape(o)}"]`}const a=e.tagName.toLowerCase(),n=e.parentElement;if(n){const i=Array.from(n.children),o=i.indexOf(e)+1;if(i.length>1)return`${a}:nth-child(${o})`}if(n){const i=this.generateParentSelector(n);if(i)return`${i} > ${a}:nth-child(${Array.from(n.children).indexOf(e)+1})`}return a}static generateParentSelector(e){const r=e.tagName.toLowerCase(),a=["data-testid","aria-label","title","alt","role"];for(const i of a){const o=e.getAttribute(i);if(o&&!this.isDynamicValue(o))return`[${i}="${CSS.escape(o)}"]`}const n=e.parentElement;if(n){const i=Array.from(n.children),o=i.indexOf(e)+1;if(i.length>1)return`${r}:nth-child(${o})`}return r}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 rt(t,e=document){const{selector:r,findBy:a="cssSelector",option:n}=t,{waitForSelector:i=!1,waitSelectorTimeout:o=5e3}=n||{},u=us(r,a);return i?u.waitForElement(t,e,o):u.find(t,e)}function us(t,e){return e==="xpath"?new cs:t.includes(">>")?new os:t.includes("|>")?new is:new ss}const Wr=tt.extend({name:b.literal("get-text"),includeTags:b.boolean().optional(),useTextContent:b.boolean().optional(),regex:b.string().optional(),prefixText:b.string().optional(),suffixText:b.string().optional(),filterEmpty:b.boolean().optional(),scrollToCollect:b.boolean().optional(),scrollDistance:b.number().optional(),scrollWaitMs:b.number().optional(),maxScrollAttempts:b.number().optional()});function fs(t){return Wr.parse(t)}async function ds(t){try{const{selector:e="",includeTags:r=!1,useTextContent:a=!1,regex:n,prefixText:i="",suffixText:o="",findBy:u="cssSelector",option:v,filterEmpty:k=!0,scrollToCollect:O=!1,scrollDistance:D=500,scrollWaitMs:_=300,maxScrollAttempts:T=100}=t;if(!e)throw new Error("Selector is required for get-text block");if(O&&(v!=null&&v.multiple))return await hs({selector:e,findBy:u,option:v,includeTags:r,useTextContent:a,regex:n,prefixText:i,suffixText:o,filterEmpty:k,scrollDistance:D,scrollWaitMs:_,maxScrollAttempts:T});const I=await rt({selector:e,findBy:u,option:v});if(!I)return{data:""};const ae=Mn(r,a,n,i,o);if(Array.isArray(I)){const Q=I.map(ae);return{data:k?Q.filter(q=>q.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 hs(t){const{selector:e,findBy:r,option:a,includeTags:n,useTextContent:i,regex:o,prefixText:u,suffixText:v,filterEmpty:k,scrollDistance:O,scrollWaitMs:D,maxScrollAttempts:_}=t,T=Mn(n,i,o,u,v),I=new Set;let ae=0,Q=0;const pe=5;for(;ae<_;){const q=await rt({selector:e,findBy:r,option:a});if(q&&Array.isArray(q)){const U=I.size;if(q.forEach($=>{const W=T($);(!k||W.trim()!=="")&&I.add(W)}),I.size===U){if(Q++,Q>=pe)break}else Q=0}const R=window.pageYOffset||document.documentElement.scrollTop;if(window.scrollBy({top:O,behavior:"auto"}),await new Promise(U=>setTimeout(U,D)),(window.pageYOffset||document.documentElement.scrollTop)===R)break;ae++}return{data:Array.from(I)}}function Mn(t,e,r,a="",n=""){return i=>{let o="";if(t?o=i.innerHTML:o=e?i.textContent||"":i.innerText||"",r){const u=new RegExp(r,"g"),v=o.match(u);o=v?v.join(" "):""}return o.trim()&&(o=a+o.trim()+n),o}}const zr=tt.extend({name:b.literal("attribute-value"),attributeName:b.string()});function ps(t){return zr.parse(t)}async function ms(t){try{const{selector:e="",attributeName:r,findBy:a="cssSelector",option:n}=t;if(!e)throw new Error("Selector is required for attribute-value block");if(!r)throw new Error("Attribute name is required for attribute-value block");const i=await rt({selector:e,findBy:a,option:n});return i?{data:Array.isArray(i)?i.map(u=>u.getAttribute(r)).filter(u=>u!==null):i.getAttribute(r)}:{data:null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in attribute-value handler",data:null}}}const Hr=tt.extend({name:b.literal("get-value-form"),type:b.enum(["text-field","select","checkbox"]).optional()});function gs(t){return Hr.parse(t)}async function ys(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for get-value-form block");const n=await rt({selector:e,findBy:a,option:t.option});if(!n)throw new Error("Form element not found");return{data:vs(n,r)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-value-form handler",data:null}}}function vs(t,e){switch(e){case"text-field":if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)return t.value;break;case"select":if(t instanceof HTMLSelectElement)return t.value;break;case"checkbox":if(t instanceof HTMLInputElement&&t.type==="checkbox")return t.checked;break;default:throw new Error(`Unsupported form element type: ${e}`)}throw new Error(`Invalid element type for ${e}`)}const qr=tt.extend({name:b.literal("set-value-form"),setValue:b.string(),type:b.enum(["text-field","select","checkbox"]).optional()});function bs(t){return qr.parse(t)}async function ws(t){try{const{selector:e="",setValue:r,type:a="text-field",findBy:n="cssSelector"}=t;if(!e)throw new Error("Selector is required for set-value-form block");const i=await rt({selector:e,findBy:n,option:t.option});if(!i)throw new Error("Form element not found");return ks(i,r,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 ks(t,e,r){switch(r){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.value=e,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=e==="true"||e==="checked",t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${r}`)}}const Gr=tt.extend({name:b.literal("clear-value-form"),type:b.enum(["text-field","select","checkbox"]).optional()});function xs(t){return Gr.parse(t)}async function _s(t){try{const{selector:e="",type:r="text-field",findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for clear-value-form block");const n=await rt({selector:e,findBy:a,option:t.option});if(!n)throw new Error("Form element not found");return Es(n,r),{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 Es(t,e){switch(e){case"text-field":(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"select":t instanceof HTMLSelectElement&&(t.selectedIndex=0,t.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":t instanceof HTMLInputElement&&t.type==="checkbox"&&(t.checked=!1,t.dispatchEvent(new Event("change",{bubbles:!0})));break;default:throw new Error(`Unsupported form element type: ${e}`)}}const Yr=tt.extend({name:b.literal("set-contenteditable"),setValue:b.string()});function As(t){return Yr.parse(t)}async function Ts(t){try{const{selector:e="",setValue:r,findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for set-contenteditable block");const n=await rt({selector:e,findBy:a,option:t.option});if(!n)throw new Error("Contenteditable element not found");if(!Ss(n))throw new Error("Target element is not contenteditable");return Ds(n,r),{data:"Contenteditable element updated successfully"}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in set-contenteditable handler",data:null}}}function Ss(t){return t.isContentEditable||t.getAttribute("contenteditable")==="true"}function Ds(t,e){t.textContent=e,t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,data:e,inputType:"insertText"})),t.dispatchEvent(new Event("change",{bubbles:!0}))}const Kr=tt.extend({name:b.literal("element-exists")});function Ps(t){return Kr.parse(t)}async function Os(t){try{const{selector:e="",findBy:r="cssSelector",option:a}=t;if(!e)throw new Error("Selector is required for element-exists block");return{data:await rt({selector:e,findBy:r,option:a})!==null}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in element-exists handler",data:null}}}const Jr=tt.extend({name:b.literal("event-click"),textFilter:b.object({text:b.union([b.string(),b.array(b.string())]),mode:b.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function Cs(t){return Jr.parse(t)}async function Ns(t){try{const{selector:e="",findBy:r="cssSelector",option:a,textFilter:n}=t;if(!e)throw new Error("Selector is required for event-click block");const i=await rt({selector:e,findBy:r,option:a});if(!i)throw new Error("Element not found for clicking");let o;if(Array.isArray(i))if(n){const u=Rs(i,n.text,n.mode);if(!u){const v=Array.isArray(n.text)?n.text.join(", "):n.text;throw new Error(`No element found with text filter: "${v}" (mode: ${n.mode})`)}o=u}else o=i[0];else o=i;return await Is(o),{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 Rs(t,e,r){for(const a of t){const n=Ms(a),i=Array.isArray(e)?e:[e];for(const o of i){let u=!1;switch(r){case"exact":u=n===o;break;case"contains":u=n.includes(o);break;case"startsWith":u=n.startsWith(o);break;case"endsWith":u=n.endsWith(o);break;case"regex":try{u=new RegExp(o).test(n)}catch{console.warn("Invalid regex pattern:",o);continue}break}if(u)return a}}return null}function Ms(t){if(t.innerText)return t.innerText.trim();if(t.textContent)return t.textContent.trim();if(t instanceof HTMLInputElement&&t.value)return t.value.trim();const e=t.getAttribute("placeholder");if(e)return e.trim();const r=t.getAttribute("title");if(r)return r.trim();const a=t.getAttribute("aria-label");return a?a.trim():""}function wn(t){const e=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window,button:0}),r=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,view:window,button:0}),a=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window,button:0});t.dispatchEvent(e),t.dispatchEvent(r),t.dispatchEvent(a)}async function Is(t){t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(n=>setTimeout(n,50)),t.focus&&t.focus();const e=t.getBoundingClientRect(),r=e.left+e.width/2,a=e.top+e.height/2;try{const n=await chrome.runtime.sendMessage({type:"CDP_CLICK",data:{x:r,y:a}});if(n&&!n.$isError)console.log("[EventClick] CDP click successful:",n),wn(t);else throw new Error((n==null?void 0:n.message)||"CDP click failed")}catch(n){console.error("[EventClick] CDP click failed, falling back to native MouseEvent dispatch:",n),wn(t)}await new Promise(n=>setTimeout(n,50))}const Xr=b.object({name:b.literal("keypress"),key:b.string(),code:b.string().optional(),keyCode:b.number().optional(),modifiers:b.array(b.enum(["Alt","Control","Meta","Shift"])).optional()});function js(t){return Xr.parse(t)}async function Fs(t){try{const{key:e,code:r,keyCode:a,modifiers:n=[]}=t;return await Bs(e,r,a,n),{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 Bs(t,e,r,a=[]){try{const n=await chrome.runtime.sendMessage({type:"CDP_KEYPRESS",data:{key:t,code:e||t,keyCode:r||Rr(t),modifiers:a}});if(n&&!n.$isError)console.log("[Keypress] CDP keypress successful:",n);else throw new Error((n==null?void 0:n.message)||"CDP keypress failed")}catch(n){console.error("[Keypress] CDP keypress failed, falling back to native dispatch:",n);const i=new KeyboardEvent("keydown",{key:t,code:e||t,keyCode:r||Rr(t),bubbles:!0,cancelable:!0,...kn(a)}),o=new KeyboardEvent("keyup",{key:t,code:e||t,keyCode:r||Rr(t),bubbles:!0,cancelable:!0,...kn(a)});document.dispatchEvent(i),await new Promise(u=>setTimeout(u,10)),document.dispatchEvent(o)}await new Promise(n=>setTimeout(n,50))}function Rr(t){return{Escape:27,Enter:13,Tab:9,Backspace:8,Delete:46,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Space:32," ":32}[t]||0}function kn(t){return{altKey:t.includes("Alt"),ctrlKey:t.includes("Control"),metaKey:t.includes("Meta"),shiftKey:t.includes("Shift")}}const Qr=b.object({name:b.literal("wait"),duration:b.number().min(0)});function Ls(t){return Qr.parse(t)}async function $s(t){try{const{duration:e}=t;return console.log(`[Wait] Waiting for ${e}ms...`),await new Promise(r=>setTimeout(r,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 en=b.object({name:b.literal("wait-for-condition"),conditions:b.object({urlPattern:b.string().optional(),elementExists:b.object({selector:b.string(),findBy:b.enum(["cssSelector","xpath"])}).optional(),cookieExists:b.string().optional(),storageKey:b.object({type:b.enum(["localStorage","sessionStorage"]),key:b.string()}).optional(),userConfirmation:b.boolean().optional(),message:b.string().optional(),buttonText:b.string().optional()}).refine(t=>t.urlPattern!==void 0||t.elementExists!==void 0||t.cookieExists!==void 0||t.storageKey!==void 0||t.userConfirmation===!0,{message:"At least one condition must be specified"}),mode:b.enum(["auto","manual","auto-or-manual"]).optional(),pollingIntervalMs:b.number().min(100).optional(),timeoutMs:b.number().min(1e3).optional(),position:b.enum(["top-left","top-right","bottom-left","bottom-right"]).optional()});function Us(t){return en.parse(t)}async function Vs(t){try{const{conditions:e,mode:r="auto-or-manual",pollingIntervalMs:a=1e3,timeoutMs:n=3e5,position:i="bottom-right"}=t;console.log("[WaitForCondition] Starting wait with conditions:",e),console.log("[WaitForCondition] Mode:",r,"Timeout:",n);const o=!!(e.urlPattern||e.elementExists||e.cookieExists||e.storageKey),u=e.userConfirmation===!0;let v=null,k=null;(r==="manual"||r==="auto-or-manual")&&u&&(v=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 O=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:_}=e.elementExists;let T=null;if(_==="cssSelector"?T=document.querySelector(D):_==="xpath"&&(T=document.evaluate(D,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue),T)return{success:!0,reason:"elementExists",message:`Element found: ${D}`}}if(e.cookieExists&&document.cookie.split(";").some(T=>{const[I]=T.trim().split("=");return I===e.cookieExists}))return{success:!0,reason:"cookieExists",message:`Cookie found: ${e.cookieExists}`};if(e.storageKey){const{type:D,key:_}=e.storageKey;if((D==="localStorage"?window.localStorage:window.sessionStorage).getItem(_)!==null)return{success:!0,reason:"storageKey",message:`Storage key found: ${D}.${_}`}}return null};return new Promise(D=>{let _=null,T=!1;const I=()=>{_&&(clearInterval(_),_=null),window.dispatchEvent(new CustomEvent("8g-hide-confirmation-ui"))},ae=pe=>{T||(T=!0,I(),console.log("[WaitForCondition] Resolved with:",pe),D({data:pe}))},Q=setTimeout(()=>{ae({success:!1,reason:"timeout",message:`Timeout after ${n}ms`})},n);(r==="auto"||r==="auto-or-manual")&&o&&(_=setInterval(async()=>{const pe=await O();pe&&(clearTimeout(Q),ae(pe))},a)),(r==="manual"||r==="auto-or-manual")&&v&&v.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 tn=b.object({name:b.literal("navigate"),url:b.string().url("Valid URL is required"),waitForLoad:b.boolean().optional(),timeout:b.number().min(0).optional()});function Zs(t){return tn.parse(t)}async function Ws(t){try{const{url:e,waitForLoad:r=!0,timeout:a=3e4}=t;return console.log(`[Navigate] Navigating to: ${e}`),r?new Promise((n,i)=>{const o=setTimeout(()=>{i(new Error(`Navigation timeout after ${a}ms`))},a),u=()=>{clearTimeout(o),window.removeEventListener("load",u),console.log(`[Navigate] Page loaded: ${e}`),n({data:!0})};document.readyState==="complete"?(clearTimeout(o),console.log(`[Navigate] Page already loaded: ${e}`),n({data:!0})):window.addEventListener("load",u),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 rn=tt.extend({name:b.literal("save-assets")});function zs(t){return rn.parse(t)}async function Hs(t){try{const{selector:e="img, audio, video, source",findBy:r="cssSelector",option:a}=t,n=await rt({selector:e,findBy:r,option:a});if(!n||!Array.isArray(n))return{data:[]};const i=[];return n.forEach(o=>{let u="";(o instanceof HTMLImageElement||o instanceof HTMLAudioElement||o instanceof HTMLVideoElement||o instanceof HTMLSourceElement)&&(u=o.src),u&&!i.includes(u)&&i.push(u)}),{data:i}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in save-assets handler",data:null}}}class qs{static generate(e){var n;const r=[];let a=e;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let i=a.tagName.toLowerCase();const o=Array.from(((n=a.parentElement)==null?void 0:n.children)||[]).filter(v=>v.tagName===a.tagName);if(o.length>1){const v=o.indexOf(a)+1;i+=`[${v}]`}const u=this.getStableAttributes(a);u.length>0&&(i+=`[@${u.join(" and @")}]`),r.unshift(i),a=a.parentElement}return"/"+r.join("/")}static getStableAttributes(e){const r=[],a=["data-testid","aria-label","title","alt","role"];for(const n of a){const i=e.getAttribute(n);i&&!this.isDynamicValue(i)&&r.push(`${n}="${i}"`)}return r}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 nn=tt.extend({name:b.literal("get-element-data"),includeText:b.boolean().optional(),includeTags:b.boolean().optional(),useTextContent:b.boolean().optional(),regex:b.string().optional(),prefixText:b.string().optional(),suffixText:b.string().optional(),attributes:b.array(b.string()).optional(),includeSelector:b.boolean().optional(),includeXPath:b.boolean().optional()});function Gs(t){return nn.parse(t)}async function Ys(t){try{const{selector:e="",includeText:r=!0,includeTags:a=!1,useTextContent:n=!1,regex:i,prefixText:o="",suffixText:u="",attributes:v=[],includeSelector:k=!1,includeXPath:O=!1,findBy:D="cssSelector",option:_}=t;if(!e)throw new Error("Selector is required for get-element-data block");if(!r&&v.length===0)throw new Error("Either includeText must be true or attributes must be provided");const T=await rt({selector:e,findBy:D,option:_});if(!T)return{data:Array.isArray(T)?[]:{}};const I=Ks(r,a,n,i,o,u,v,k,O);return Array.isArray(T)?{data:T.map(I)}:{data:I(T)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in get-element-data handler",data:{}}}}function Ks(t,e,r,a,n="",i="",o=[],u=!1,v=!1){return k=>{const O={};if(t){let D="";if(e?D=k.innerHTML:D=r?k.textContent||"":k.innerText||"",a){const _=new RegExp(a,"g"),T=D.match(_);D=T?T.join(" "):""}D.trim()&&(D=n+D.trim()+i),O.text=D}return o.length>0&&(O.attributes={},o.forEach(D=>{let _=k.getAttribute(D);if(_===null){const T=k.querySelector(`[${D}]`);T&&(_=T.getAttribute(D))}O.attributes[D]=_})),u&&(O.selector=ls.generate(k)),v&&(O.xpath=qs.generate(k)),O}}const an=tt.extend({name:b.literal("scroll"),scrollType:b.enum(["toElement","toBottom","byDistance","untilLoaded"]).optional(),distance:b.number().optional(),behavior:b.enum(["auto","smooth"]).optional(),maxScrolls:b.number().optional(),waitAfterScroll:b.number().optional()});function Js(t){return an.parse(t)}async function Xs(t){try{const{selector:e="",scrollType:r="toBottom",distance:a=500,behavior:n="smooth",maxScrolls:i=50,waitAfterScroll:o=300,findBy:u="cssSelector",option:v}=t;switch(r){case"toElement":if(!e)throw new Error("Selector is required for toElement scroll type");return await Qs(e,u,v,n);case"toBottom":return await ei(n,o);case"byDistance":return await ti(a,n);case"untilLoaded":return await ri(i,a,n,o);default:throw new Error(`Unknown scroll type: ${r}`)}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in scroll handler",data:!1}}}async function Qs(t,e,r,a){const n=await rt({selector:t,findBy:e,option:r});return n?((Array.isArray(n)?n[0]:n).scrollIntoView({behavior:a,block:"center"}),{data:!0}):{hasError:!0,message:"Element not found for scrolling",data:!1}}async function ei(t,e){let r=document.body.scrollHeight,a=0;const n=50;for(;a<n;){window.scrollTo({top:document.body.scrollHeight,behavior:t}),await new Promise(o=>setTimeout(o,e));const i=document.body.scrollHeight;if(i===r)break;r=i,a++}return{data:!0}}async function ti(t,e){return window.scrollBy({top:t,behavior:e}),{data:!0}}async function ri(t,e,r,a){let n=0,i=document.body.scrollHeight;for(;n<t;){window.scrollBy({top:e,behavior:r}),await new Promise(k=>setTimeout(k,a));const o=document.body.scrollHeight,u=window.pageYOffset||document.documentElement.scrollTop,v=window.innerHeight;if(u+v>=o-10&&o===i)break;i=o,n++}return{data:!0}}const sn=b.object({name:b.literal("fetch-api"),url:b.string(),method:b.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),headers:b.record(b.string(),b.string()).optional(),body:b.record(b.string(),b.any()).optional(),timeout:b.number().min(0).optional(),parseJson:b.boolean().optional(),returnHeaders:b.boolean().optional()});function ni(t){return sn.parse(t)}async function ai(t){try{console.log("[FetchApiBlock] Sending API request to background:",t.url);const e=await chrome.runtime.sendMessage({type:"FETCH_API",data:{url:t.url,method:t.method||"GET",headers:t.headers||{},body:t.body,timeout:t.timeout||3e4,parseJson:t.parseJson??!0,returnHeaders:t.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 xn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function si(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function xr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Mr={exports:{}},_n;function ii(){return _n||(_n=1,(function(t,e){(function(r){t.exports=r()})(function(){return(function(){function r(a,n,i){function o(k,O){if(!n[k]){if(!a[k]){var D=typeof xr=="function"&&xr;if(!O&&D)return D(k,!0);if(u)return u(k,!0);var _=new Error("Cannot find module '"+k+"'");throw _.code="MODULE_NOT_FOUND",_}var T=n[k]={exports:{}};a[k][0].call(T.exports,function(I){var ae=a[k][1][I];return o(ae||I)},T,T.exports,r,a,n,i)}return n[k].exports}for(var u=typeof xr=="function"&&xr,v=0;v<i.length;v++)o(i[v]);return o}return r})()({1:[function(r,a,n){const i=r("./utils"),o=(function(){const u=i.stringToArray,v=["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"],O=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],D=["Thousand","Million","Billion","Trillion"];function _(w,S){var x=function(B,j,P){var F="";if(B<=19)F=(j?" and ":"")+(P?k[B]:v[B]);else if(B<100){const ye=Math.floor(B/10),we=B%10;F=(j?" and ":"")+O[ye-2],we>0?F+="-"+x(we,!1,P):P&&(F=F.substring(0,F.length-1)+"ieth")}else if(B<1e3){const ye=Math.floor(B/100),we=B%100;F=(j?", ":"")+v[ye]+" Hundred",we>0?F+=x(we,!0,P):P&&(F+="th")}else{var J=Math.floor(Math.log10(B)/3);J>D.length&&(J=D.length);const ye=Math.pow(10,J*3),we=Math.floor(B/ye),K=B-we*ye;F=(j?", ":"")+x(we,!1,!1)+" "+D[J-1],K>0?F+=x(K,!0,P):P&&(F+="th")}return F},N=x(w,!1,S);return N}const T={};v.forEach(function(w,S){T[w.toLowerCase()]=S}),k.forEach(function(w,S){T[w.toLowerCase()]=S}),O.forEach(function(w,S){const x=w.toLowerCase();T[x]=(S+2)*10,T[x.substring(0,w.length-1)+"ieth"]=T[x]}),T.hundredth=100,D.forEach(function(w,S){const x=w.toLowerCase(),N=Math.pow(10,(S+1)*3);T[x]=N,T[x+"th"]=N});function I(w){const x=w.split(/,\s|\sand\s|[\s\\-]/).map(j=>T[j]);let N=[0];return x.forEach(j=>{if(j<100){let P=N.pop();P>=1e3&&(N.push(P),P=0),N.push(P+j)}else N.push(N.pop()*j)}),N.reduce((j,P)=>j+P,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(w){for(var S=0;S<ae.length;S++){const x=ae[S];if(w>=x[0])return x[1]+pe(w-x[0])}return""}function q(w){for(var S=0,x=1,N=w.length-1;N>=0;N--){const B=w[N],j=Q[B];j<x?S-=j:(x=j,S+=j)}return S}function R(w,S){for(var x=[],N=S.charCodeAt(0);w>0;)x.unshift(String.fromCharCode((w-1)%26+N)),w=Math.floor((w-1)/26);return x.join("")}function se(w,S){for(var x=S.charCodeAt(0),N=0,B=0;B<w.length;B++)N+=(w.charCodeAt(w.length-B-1)-x+1)*Math.pow(26,B);return N}function U(w,S){if(typeof w>"u")return;w=Math.floor(w);const x=xe(S);return W(w,x)}const A={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},$={UPPER:"upper",LOWER:"lower",TITLE:"title"};function W(w,S){let x;const N=w<0;switch(w=Math.abs(w),S.primary){case A.LETTERS:x=R(w,S.case===$.UPPER?"A":"a");break;case A.ROMAN:x=pe(w),S.case===$.UPPER&&(x=x.toUpperCase());break;case A.WORDS:x=_(w,S.ordinal),S.case===$.UPPER?x=x.toUpperCase():S.case===$.LOWER&&(x=x.toLowerCase());break;case A.DECIMAL:x=""+w;var B=S.mandatoryDigits-x.length;if(B>0){var j=new Array(B+1).join("0");x=j+x}if(S.zeroCode!==48&&(x=u(x).map(ye=>String.fromCodePoint(ye.codePointAt(0)+S.zeroCode-48)).join("")),S.regular){const ye=Math.floor((x.length-1)/S.groupingSeparators.position);for(let we=ye;we>0;we--){const K=x.length-we*S.groupingSeparators.position;x=x.substr(0,K)+S.groupingSeparators.character+x.substr(K)}}else S.groupingSeparators.reverse().forEach(ye=>{const we=x.length-ye.position;x=x.substr(0,we)+ye.character+x.substr(we)});if(S.ordinal){var P={1:"st",2:"nd",3:"rd"},F=x[x.length-1],J=P[F];(!J||x.length>1&&x[x.length-2]==="1")&&(J="th"),x=x+J}break;case A.SEQUENCE:throw{code:"D3130",value:S.token}}return N&&(x="-"+x),x}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(w){const S={type:"integer",primary:A.DECIMAL,case:$.LOWER,ordinal:!1};let x,N;const B=w.lastIndexOf(";");switch(B===-1?x=w:(x=w.substring(0,B),N=w.substring(B+1),N[0]==="o"&&(S.ordinal=!0)),x){case"A":S.case=$.UPPER;case"a":S.primary=A.LETTERS;break;case"I":S.case=$.UPPER;case"i":S.primary=A.ROMAN;break;case"W":S.case=$.UPPER,S.primary=A.WORDS;break;case"Ww":S.case=$.TITLE,S.primary=A.WORDS;break;case"w":S.primary=A.WORDS;break;default:{let j=null,P=0,F=0,J=[],ye=0;if(u(x).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,P++,ye++,j===null)j=G;else if(G!==j)throw{code:"D3131"};break}}ee||(K===35?(ye++,F++):J.push({position:ye,character:String.fromCodePoint(K)}))}),P>0){S.primary=A.DECIMAL,S.zeroCode=j,S.mandatoryDigits=P,S.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 Ve=me.map($e=>$e.position),lt=function($e,qe){return qe===0?$e:lt(qe,$e%qe)},He=Ve.reduce(lt);for(let $e=1;$e<=Ve.length;$e++)if(Ve.indexOf($e*He)===-1)return 0;return He}(J);ee>0?(S.regular=!0,S.groupingSeparators={position:ee,character:J[0].character}):(S.regular=!1,S.groupingSeparators=J)}else S.primary=A.SEQUENCE,S.token=x}}return S}const Ae={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 Te(w){var S=[];const x={type:"datetime",parts:S},N=function(ee,me){if(me>ee){let G=w.substring(ee,me);G=G.split("]]").join("]"),S.push({type:"literal",value:G})}};for(var B=0,j=0;j<w.length;){if(w.charAt(j)==="["){if(w.charAt(j+1)==="["){N(B,j),S.push({type:"literal",value:"["}),j+=2,B=j;continue}if(N(B,j),B=j,j=w.indexOf("]",B),j===-1)throw{code:"D3135"};let ee=w.substring(B+1,j);ee=ee.split(/\s+/).join("");var P={type:"marker",component:ee.charAt(0)},F=ee.lastIndexOf(","),J;if(F!==-1){const me=ee.substring(F+1),G=me.indexOf("-");let Ve,lt;const He=function(qe){if(!(typeof qe>"u"||qe==="*"))return parseInt(qe)};G===-1?Ve=me:(Ve=me.substring(0,G),lt=me.substring(G+1));const $e={min:He(Ve),max:He(lt)};P.width=$e,J=ee.substring(1,F)}else J=ee.substring(1);if(J.length===1)P.presentation1=J;else if(J.length>1){var ye=J.charAt(J.length-1);"atco".indexOf(ye)!==-1?(P.presentation2=ye,ye==="o"&&(P.ordinal=!0),P.presentation1=J.substring(0,J.length-1)):P.presentation1=J}else P.presentation1=Ae[P.component];if(typeof P.presentation1>"u")throw{code:"D3132",value:P.component};if(P.presentation1[0]==="n")P.names=$.LOWER;else if(P.presentation1[0]==="N")P.presentation1[1]==="n"?P.names=$.TITLE:P.names=$.UPPER;else if("YMDdFWwXxHhmsf".indexOf(P.component)!==-1){var we=P.presentation1;if(P.presentation2&&(we+=";"+P.presentation2),P.integerFormat=xe(we),P.width&&P.width.min!==void 0&&P.integerFormat.mandatoryDigits<P.width.min&&(P.integerFormat.mandatoryDigits=P.width.min),P.component==="Y")if(P.n=-1,P.width&&P.width.max!==void 0)P.n=P.width.max,P.integerFormat.mandatoryDigits=P.n;else{var K=P.integerFormat.mandatoryDigits+P.integerFormat.optionalDigits;K>=2&&(P.n=K)}const me=S[S.length-1];me&&me.integerFormat&&(me.integerFormat.parseWidth=me.integerFormat.mandatoryDigits)}(P.component==="Z"||P.component==="z")&&(P.integerFormat=xe(P.presentation1)),S.push(P),B=j+1}j++}return N(B,j),x}const ve=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],Me=["January","February","March","April","May","June","July","August","September","October","November","December"],nt=1e3*60*60*24,_e=function(w){const S=Date.UTC(w.year,w.month);var x=new Date(S).getUTCDay();return x===0&&(x=7),x>4?S+(8-x)*nt:S-(x-1)*nt},fe=function(w,S){return{year:w,month:S,nextMonth:function(){return S===11?fe(w+1,0):fe(w,S+1)},previousMonth:function(){return S===0?fe(w-1,11):fe(w,S-1)},nextYear:function(){return fe(w+1,S)},previousYear:function(){return fe(w-1,S)}}},at=function(w,S){return(S-w)/(nt*7)+1},ie=(w,S)=>{let x;switch(S){case"Y":x=w.getUTCFullYear();break;case"M":x=w.getUTCMonth()+1;break;case"D":x=w.getUTCDate();break;case"d":{const N=Date.UTC(w.getUTCFullYear(),w.getUTCMonth(),w.getUTCDate()),B=Date.UTC(w.getUTCFullYear(),0);x=(N-B)/nt+1;break}case"F":x=w.getUTCDay(),x===0&&(x=7);break;case"W":{const N=fe(w.getUTCFullYear(),0),B=_e(N),j=Date.UTC(N.year,w.getUTCMonth(),w.getUTCDate());let P=at(B,j);if(P>52){const F=_e(N.nextYear());j>=F&&(P=1)}else if(P<1){const F=_e(N.previousYear());P=at(F,j)}x=Math.floor(P);break}case"w":{const N=fe(w.getUTCFullYear(),w.getUTCMonth()),B=_e(N),j=Date.UTC(N.year,N.month,w.getUTCDate());let P=at(B,j);if(P>4){const F=_e(N.nextMonth());j>=F&&(P=1)}else if(P<1){const F=_e(N.previousMonth());P=at(F,j)}x=Math.floor(P);break}case"X":{const N=fe(w.getUTCFullYear(),0),B=_e(N),j=_e(N.nextYear()),P=w.getTime();P<B?x=N.year-1:P>=j?x=N.year+1:x=N.year;break}case"x":{const N=fe(w.getUTCFullYear(),w.getUTCMonth()),B=_e(N),j=N.nextMonth(),P=_e(j),F=w.getTime();F<B?x=N.previousMonth().month+1:F>=P?x=j.month+1:x=N.month+1;break}case"H":x=w.getUTCHours();break;case"h":x=w.getUTCHours(),x=x%12,x===0&&(x=12);break;case"P":x=w.getUTCHours()>=12?"pm":"am";break;case"m":x=w.getUTCMinutes();break;case"s":x=w.getUTCSeconds();break;case"f":x=w.getUTCMilliseconds();break;case"Z":case"z":break;case"C":x="ISO";break;case"E":x="ISO";break}return x};let Be=null;function ct(w,S,x){var N=0,B=0;if(typeof x<"u"){const we=parseInt(x);N=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=Me[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=W(ee,K.integerFormat);else if(K.component==="f")ee=W(ee,K.integerFormat);else if(K.component==="Z"||K.component==="z"){const me=N*100+B;if(K.integerFormat.regular)ee=W(me,K.integerFormat);else{const G=K.integerFormat.mandatoryDigits;if(G===1||G===2)ee=W(N,K.integerFormat),B!==0&&(ee+=":"+U(B,"00"));else if(G===3||G===4)ee=W(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 P;typeof S>"u"?(Be===null&&(Be=Te("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),P=Be):P=Te(S);const F=(60*N+B)*60*1e3,J=new Date(w+F);let ye="";return P.parts.forEach(function(we){we.type==="literal"?ye+=we.value:ye+=j(J,we)}),ye}function d(w){var S={};if(w.type==="datetime")S.type="datetime",S.parts=w.parts.map(function(x){var N={};if(x.type==="literal")N.regex=x.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if(x.component==="Z"||x.component==="z"){let j;Array.isArray(x.integerFormat.groupingSeparators)||(j=x.integerFormat.groupingSeparators),N.regex="",x.component==="z"&&(N.regex="GMT"),N.regex+="[-+][0-9]+",j&&(N.regex+=j.character+"[0-9]+"),N.parse=function(P){x.component==="z"&&(P=P.substring(3));let F=0,J=0;return j?(F=Number.parseInt(P.substring(0,P.indexOf(j.character))),J=Number.parseInt(P.substring(P.indexOf(j.character)+1))):P.length-1<=2?F=Number.parseInt(P):(F=Number.parseInt(P.substring(0,3)),J=Number.parseInt(P.substring(3))),F*60+J}}else if(x.integerFormat)N=d(x.integerFormat);else{N.regex="[a-zA-Z]+";var B={};if(x.component==="M"||x.component==="x")Me.forEach(function(j,P){x.width&&x.width.max?B[j.substring(0,x.width.max)]=P+1:B[j]=P+1});else if(x.component==="F")ve.forEach(function(j,P){P>0&&(x.width&&x.width.max?B[j.substring(0,x.width.max)]=P:B[j]=P)});else if(x.component==="P")B={am:0,AM:0,pm:1,PM:1};else throw{code:"D3133",value:x.component};N.parse=function(j){return B[j]}}return N.component=x.component,N});else{S.type="integer";const x=w.case===$.UPPER;switch(w.primary){case A.LETTERS:S.regex=x?"[A-Z]+":"[a-z]+",S.parse=function(N){return se(N,x?"A":"a")};break;case A.ROMAN:S.regex=x?"[MDCLXVI]+":"[mdclxvi]+",S.parse=function(N){return q(x?N:N.toUpperCase())};break;case A.WORDS:S.regex="(?:"+Object.keys(T).concat("and","[\\-, ]").join("|")+")+",S.parse=function(N){return I(N.toLowerCase())};break;case A.DECIMAL:S.regex="[0-9]",w.parseWidth?S.regex+=`{${w.parseWidth}}`:S.regex+="+",w.ordinal&&(S.regex+="(?:th|st|nd|rd)"),S.parse=function(N){let B=N;return w.ordinal&&(B=N.substring(0,N.length-2)),w.regular?B=B.split(",").join(""):w.groupingSeparators.forEach(j=>{B=B.split(j.character).join("")}),w.zeroCode!==48&&(B=B.split("").map(j=>String.fromCodePoint(j.codePointAt(0)-w.zeroCode+48)).join("")),parseInt(B)};break;case A.SEQUENCE:throw{code:"D3130",value:w.token}}}return S}function m(w,S){if(typeof w>"u")return;const x=xe(S);return d(x).parse(w)}function z(w,S){const x=Te(S),N=d(x),B="^"+N.parts.map(J=>"("+J.regex+")").join("")+"$";var P=new RegExp(B,"i").exec(w);if(P!==null){const G={};for(let De=1;De<P.length;De++){const l=N.parts[De-1];l.parse&&(G[l.component]=l.parse(P[De]))}if(Object.getOwnPropertyNames(G).length===0)return;let Ve=0;const lt=De=>{Ve<<=1,Ve+=De?1:0},He=De=>!(~De&Ve)&&!!(De&Ve);"YXMxWwdD".split("").forEach(De=>lt(G[De]));const qe=!He(161)&&He(130),wt=He(84),Tt=!wt&&He(72);Ve=0,"PHhmsf".split("").forEach(De=>lt(G[De]));const St=!He(23)&&He(47),Jt=(qe?"YD":wt?"XxwF":Tt?"XWF":"YMD")+(St?"Phmsf":"Hmsf"),ft=this.environment.timestamp;let Ut=!1,gt=!1;if(Jt.split("").forEach(De=>{if(typeof G[De]>"u")Ut?(G[De]="MDd".indexOf(De)!==-1?1:0,gt=!0):G[De]=ie(ft,De);else if(Ut=!0,gt)throw{code:"D3136"}}),G.M>0?G.M-=1:G.M=0,qe){const De=Date.UTC(G.Y,0),l=(G.d-1)*1e3*60*60*24,h=new Date(De+l);G.M=h.getUTCMonth(),G.D=h.getUTCDate()}if(wt)throw{code:"D3136"};if(Tt)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 Ce(w,S){if(!(typeof w>"u"))if(typeof S>"u"){if(!de.test(w))throw{stack:new Error().stack,code:"D3110",value:w};return Date.parse(w)}else return z.call(this,w,S)}function Ee(w,S,x){if(!(typeof w>"u"))return ct.call(this,w,S,x)}return{formatInteger:U,parseInteger:m,fromMillis:Ee,toMillis:Ce}})();a.exports=o},{"./utils":6}],2:[function(r,a,n){(function(i){(function(){var o=r("./utils");const u=(()=>{var v=o.isNumeric,k=o.isArrayOfStrings,O=o.isArrayOfNumbers,D=o.createSequence,_=o.isSequence,T=o.isFunction,I=o.isLambda,ae=o.isPromise,Q=o.getFunctionArity,pe=o.isDeepEqual,q=o.stringToArray;function R(s){if(!(typeof s>"u")){var c=0;return s.forEach(function(f){c+=f}),c}}function se(s){return typeof s>"u"?0:s.length}function U(s){if(!(typeof s>"u"||s.length===0))return Math.max.apply(Math,s)}function A(s){if(!(typeof s>"u"||s.length===0))return Math.min.apply(Math,s)}function $(s){if(!(typeof s>"u"||s.length===0)){var c=0;return s.forEach(function(f){c+=f}),c/s.length}}function W(s,c=!1){if(!(typeof s>"u")){var f;if(typeof s=="string")f=s;else if(T(s))f="";else{if(typeof s=="number"&&!isFinite(s))throw{code:"D3001",value:s,stack:new Error().stack};var y=c?2:0;Array.isArray(s)&&s.outerWrapper&&(s=s[0]),f=JSON.stringify(s,function(p,E){return typeof E<"u"&&E!==null&&E.toPrecision&&v(E)?Number(E.toPrecision(15)):E&&T(E)?"":E},y)}return f}}function he(s,c,f){if(!(typeof s>"u")){var y=q(s),p=y.length;if(p+c<0&&(c=0),typeof f<"u"){if(f<=0)return"";var E=c>=0?c+f:p+c+f;return y.slice(c,E).join("")}return y.slice(c).join("")}}function xe(s,c){if(!(typeof s>"u")){var f=s.indexOf(c);return f>-1?s.substr(0,f):s}}function Ae(s,c){if(!(typeof s>"u")){var f=s.indexOf(c);return f>-1?s.substr(f+c.length):s}}function Te(s){if(!(typeof s>"u"))return s.toLowerCase()}function ve(s){if(!(typeof s>"u"))return s.toUpperCase()}function Me(s){if(!(typeof s>"u"))return q(s).length}function nt(s){if(!(typeof s>"u")){var c=s.replace(/[ \t\n\r]+/gm," ");return c.charAt(0)===" "&&(c=c.substring(1)),c.charAt(c.length-1)===" "&&(c=c.substring(0,c.length-1)),c}}function _e(s,c,f){if(!(typeof s>"u")){(typeof f>"u"||f.length===0)&&(f=" ");var y;c=Math.trunc(c);var p=Math.abs(c)-Me(s);if(p>0){var E=new Array(p+1).join(f);f.length>1&&(E=he(E,0,p)),c>0?y=s+E:y=E+s}else y=s;return y}}async function fe(s,c){var f=s.apply(this,[c]);if(ae(f)&&(f=await f),f&&!(typeof f.start=="number"||f.end==="number"||Array.isArray(f.groups)||T(f.next)))throw{code:"T1010",stack:new Error().stack};return f}async function at(s,c){if(!(typeof s>"u")){var f;if(typeof c=="string")f=s.indexOf(c)!==-1;else{var y=await fe(c,s);f=typeof y<"u"}return f}}async function ie(s,c,f){if(!(typeof s>"u")){if(f<0)throw{stack:new Error().stack,value:f,code:"D3040",index:3};var y=D();if(typeof f>"u"||f>0){var p=0,E=await fe(c,s);if(typeof E<"u")for(;typeof E<"u"&&(typeof f>"u"||p<f);)y.push({match:E.match,index:E.start,groups:E.groups}),E=await fe(E.next),p++}return y}}async function Be(s,c,f,y){if(!(typeof s>"u")){var p=this;if(c==="")throw{code:"D3010",stack:new Error().stack,value:c,index:2};if(y<0)throw{code:"D3011",stack:new Error().stack,value:y,index:4};var E;typeof f=="string"?E=function(Se){for(var Ze="",ke=0,Fe=f.indexOf("$",ke);Fe!==-1&&ke<f.length;){Ze+=f.substring(ke,Fe),ke=Fe+1;var ut=f.charAt(ke);if(ut==="$")Ze+="$",ke++;else if(ut==="0")Ze+=Se.match,ke++;else{var We;if(Se.groups.length===0?We=1:We=Math.floor(Math.log(Se.groups.length)*Math.LOG10E)+1,Fe=parseInt(f.substring(ke,ke+We),10),We>1&&Fe>Se.groups.length&&(Fe=parseInt(f.substring(ke,ke+We-1),10)),isNaN(Fe))Ze+="$";else{if(Se.groups.length>0){var Vt=Se.groups[Fe-1];typeof Vt<"u"&&(Ze+=Vt)}ke+=Fe.toString().length}}Fe=f.indexOf("$",ke)}return Ze+=f.substring(ke),Ze}:E=f;var M="",H=0;if(typeof y>"u"||y>0){var X=0;if(typeof c=="string"){for(var Pe=s.indexOf(c,H);Pe!==-1&&(typeof y>"u"||X<y);)M+=s.substring(H,Pe),M+=f,H=Pe+c.length,X++,Pe=s.indexOf(c,H);M+=s.substring(H)}else{var ge=await fe(c,s);if(typeof ge<"u"){for(;typeof ge<"u"&&(typeof y>"u"||X<y);){M+=s.substring(H,ge.start);var Ne=E.apply(p,[ge]);if(ae(Ne)&&(Ne=await Ne),typeof Ne=="string")M+=Ne;else throw{code:"D3012",stack:new Error().stack,value:Ne};H=ge.start+ge.match.length,X++,ge=await fe(ge.next)}M+=s.substring(H)}else M=s}}else M=s;return M}}function ct(s){if(!(typeof s>"u")){var c=typeof window<"u"?window.btoa:function(f){return new i.Buffer.from(f,"binary").toString("base64")};return c(s)}}function d(s){if(!(typeof s>"u")){var c=typeof window<"u"?window.atob:function(f){return new i.Buffer.from(f,"base64").toString("binary")};return c(s)}}function m(s){if(!(typeof s>"u")){var c;try{c=encodeURIComponent(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"encodeUrlComponent"}}return c}}function z(s){if(!(typeof s>"u")){var c;try{c=encodeURI(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"encodeUrl"}}return c}}function de(s){if(!(typeof s>"u")){var c;try{c=decodeURIComponent(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"decodeUrlComponent"}}return c}}function Ce(s){if(!(typeof s>"u")){var c;try{c=decodeURI(s)}catch{throw{code:"D3140",stack:new Error().stack,value:s,functionName:"decodeUrl"}}return c}}async function Ee(s,c,f){if(!(typeof s>"u")){if(f<0)throw{code:"D3020",stack:new Error().stack,value:f,index:3};var y=[];if(typeof f>"u"||f>0)if(typeof c=="string")y=s.split(c,f);else{var p=0,E=await fe(c,s);if(typeof E<"u"){for(var M=0;typeof E<"u"&&(typeof f>"u"||p<f);)y.push(s.substring(M,E.start)),M=E.end,E=await fe(E.next),p++;(typeof f>"u"||p<f)&&y.push(s.substring(M))}else y.push(s)}return y}}function w(s,c){if(!(typeof s>"u"))return typeof c>"u"&&(c=""),s.join(c)}function S(s,c,f){if(!(typeof s>"u")){var y={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"},p=y;typeof f<"u"&&Object.keys(f).forEach(function(re){p[re]=f[re]});for(var E=[],M=p["zero-digit"].charCodeAt(0),H=M;H<M+10;H++)E.push(String.fromCharCode(H));var X=E.concat([p["decimal-separator"],p["exponent-separator"],p["grouping-separator"],p.digit,p["pattern-separator"]]),Pe=c.split(p["pattern-separator"]);if(Pe.length>2)throw{code:"D3080",stack:new Error().stack};var ge=function(re){var Ie=(function(){for(var Ue,it=0;it<re.length;it++)if(Ue=re.charAt(it),X.indexOf(Ue)!==-1&&Ue!==p["exponent-separator"])return re.substring(0,it)})(),Ye=(function(){for(var Ue,it=re.length-1;it>=0;it--)if(Ue=re.charAt(it),X.indexOf(Ue)!==-1&&Ue!==p["exponent-separator"])return re.substring(it+1)})(),Re=re.substring(Ie.length,re.length-Ye.length),Qe,Dt,et,It,st=re.indexOf(p["exponent-separator"],Ie.length);st===-1||st>re.length-Ye.length?(Qe=Re,Dt=void 0):(Qe=Re.substring(0,st),Dt=Re.substring(st+1));var dt=Qe.indexOf(p["decimal-separator"]);return dt===-1?(et=Qe,It=Ye):(et=Qe.substring(0,dt),It=Qe.substring(dt+1)),{prefix:Ie,suffix:Ye,activePart:Re,mantissaPart:Qe,exponentPart:Dt,integerPart:et,fractionalPart:It,subpicture:re}},Ne=function(re){var Ie,Ye,Re=re.subpicture,Qe=Re.indexOf(p["decimal-separator"]);Qe!==Re.lastIndexOf(p["decimal-separator"])&&(Ie="D3081"),Re.indexOf(p.percent)!==Re.lastIndexOf(p.percent)&&(Ie="D3082"),Re.indexOf(p["per-mille"])!==Re.lastIndexOf(p["per-mille"])&&(Ie="D3083"),Re.indexOf(p.percent)!==-1&&Re.indexOf(p["per-mille"])!==-1&&(Ie="D3084");var Dt=!1;for(Ye=0;Ye<re.mantissaPart.length;Ye++){var et=re.mantissaPart.charAt(Ye);if(E.indexOf(et)!==-1||et===p.digit){Dt=!0;break}}Dt||(Ie="D3085");var It=re.activePart.split("").map(function(Ue){return X.indexOf(Ue)===-1?"p":"a"}).join("");It.indexOf("p")!==-1&&(Ie="D3086"),Qe!==-1?(Re.charAt(Qe-1)===p["grouping-separator"]||Re.charAt(Qe+1)===p["grouping-separator"])&&(Ie="D3087"):re.integerPart.charAt(re.integerPart.length-1)===p["grouping-separator"]&&(Ie="D3088"),Re.indexOf(p["grouping-separator"]+p["grouping-separator"])!==-1&&(Ie="D3089");var st=re.integerPart.indexOf(p.digit);st!==-1&&re.integerPart.substring(0,st).split("").filter(function(Ue){return E.indexOf(Ue)>-1}).length>0&&(Ie="D3090"),st=re.fractionalPart.lastIndexOf(p.digit),st!==-1&&re.fractionalPart.substring(st).split("").filter(function(Ue){return E.indexOf(Ue)>-1}).length>0&&(Ie="D3091");var dt=typeof re.exponentPart=="string";if(dt&&re.exponentPart.length>0&&(Re.indexOf(p.percent)!==-1||Re.indexOf(p["per-mille"])!==-1)&&(Ie="D3092"),dt&&(re.exponentPart.length===0||re.exponentPart.split("").filter(function(Ue){return E.indexOf(Ue)===-1}).length>0)&&(Ie="D3093"),Ie)throw{code:Ie,stack:new Error().stack}},Se=function(re){var Ie=function(ze,wr){for(var er=[],kt=ze.indexOf(p["grouping-separator"]);kt!==-1;){var kr=(wr?ze.substring(0,kt):ze.substring(kt)).split("").filter(function(Wt){return E.indexOf(Wt)!==-1||Wt===p.digit}).length;er.push(kr),kt=re.integerPart.indexOf(p["grouping-separator"],kt+1)}return er},Ye=Ie(re.integerPart),Re=function(ze){if(ze.length===0)return 0;for(var wr=function(kr,Wt){return Wt===0?kr:wr(Wt,kr%Wt)},er=ze.reduce(wr),kt=1;kt<=ze.length;kt++)if(ze.indexOf(kt*er)===-1)return 0;return er},Qe=Re(Ye),Dt=Ie(re.fractionalPart,!0),et=re.integerPart.split("").filter(function(ze){return E.indexOf(ze)!==-1}).length,It=et,st=re.fractionalPart.split(""),dt=st.filter(function(ze){return E.indexOf(ze)!==-1}).length,Ue=st.filter(function(ze){return E.indexOf(ze)!==-1||ze===p.digit}).length,it=typeof re.exponentPart=="string";et===0&&Ue===0&&(it?(dt=1,Ue=1):et=1),it&&et===0&&re.integerPart.indexOf(p.digit)!==-1&&(et=1),et===0&&dt===0&&(dt=1);var gn=0;return it&&(gn=re.exponentPart.split("").filter(function(ze){return E.indexOf(ze)!==-1}).length),{integerPartGroupingPositions:Ye,regularGrouping:Qe,minimumIntegerPartSize:et,scalingFactor:It,prefix:re.prefix,fractionalPartGroupingPositions:Dt,minimumFactionalPartSize:dt,maximumFactionalPartSize:Ue,minimumExponentSize:gn,suffix:re.suffix,picture:re.subpicture}},Ze=Pe.map(ge);Ze.forEach(Ne);var ke=Ze.map(Se),Fe=p["minus-sign"],ut=p["zero-digit"],We=p["decimal-separator"],Vt=p["grouping-separator"];ke.length===1&&(ke.push(JSON.parse(JSON.stringify(ke[0]))),ke[1].prefix=Fe+ke[1].prefix);var Le;s>=0?Le=ke[0]:Le=ke[1];var Xt;Le.picture.indexOf(p.percent)!==-1?Xt=s*100:Le.picture.indexOf(p["per-mille"])!==-1?Xt=s*1e3:Xt=s;var Mt,Zt;if(Le.minimumExponentSize===0)Mt=Xt;else{var Un=Math.pow(10,Le.scalingFactor),Vn=Math.pow(10,Le.scalingFactor-1);for(Mt=Xt,Zt=0;Mt<Vn;)Mt*=10,Zt-=1;for(;Mt>Un;)Mt/=10,Zt+=1}var Zn=F(Mt,Le.maximumFactionalPartSize),pn=function(re,Ie){var Ye=Math.abs(re).toFixed(Ie);return ut!=="0"&&(Ye=Ye.split("").map(function(Re){return Re>="0"&&Re<="9"?E[Re.charCodeAt(0)-48]:Re}).join("")),Ye},ce=pn(Zn,Le.maximumFactionalPartSize),Ge=ce.indexOf(".");for(Ge===-1?ce=ce+We:ce=ce.replace(".",We);ce.charAt(0)===ut;)ce=ce.substring(1);for(;ce.charAt(ce.length-1)===ut;)ce=ce.substring(0,ce.length-1);Ge=ce.indexOf(We);var Qt=Le.minimumIntegerPartSize-Ge,mn=Le.minimumFactionalPartSize-(ce.length-Ge-1);if(ce=(Qt>0?new Array(Qt+1).join(ut):"")+ce,ce=ce+(mn>0?new Array(mn+1).join(ut):""),Ge=ce.indexOf(We),Le.regularGrouping>0)for(var Wn=Math.floor((Ge-1)/Le.regularGrouping),vr=1;vr<=Wn;vr++)ce=[ce.slice(0,Ge-vr*Le.regularGrouping),Vt,ce.slice(Ge-vr*Le.regularGrouping)].join("");else Le.integerPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,Ge-re),Vt,ce.slice(Ge-re)].join(""),Ge++});if(Ge=ce.indexOf(We),Le.fractionalPartGroupingPositions.forEach(function(re){ce=[ce.slice(0,re+Ge+1),Vt,ce.slice(re+Ge+1)].join("")}),Ge=ce.indexOf(We),(Le.picture.indexOf(We)===-1||Ge===ce.length-1)&&(ce=ce.substring(0,ce.length-1)),typeof Zt<"u"){var br=pn(Zt,0);Qt=Le.minimumExponentSize-br.length,Qt>0&&(br=new Array(Qt+1).join(ut)+br),ce=ce+p["exponent-separator"]+(Zt<0?Fe:"")+br}return ce=Le.prefix+ce+Le.suffix,ce}}function x(s,c){if(!(typeof s>"u")){if(s=F(s),typeof c>"u"?c=10:c=F(c),c<2||c>36)throw{code:"D3100",stack:new Error().stack,value:c};var f=s.toString(c);return f}}function N(s){var c;if(!(typeof s>"u")){if(typeof s=="number")c=s;else if(typeof s=="string"&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(s)&&!isNaN(parseFloat(s))&&isFinite(s))c=parseFloat(s);else if(typeof s=="string"&&/^(0[xX][0-9A-Fa-f]+)|(0[oO][0-7]+)|(0[bB][0-1]+)$/.test(s))c=Number(s);else if(s===!0)c=1;else if(s===!1)c=0;else throw{code:"D3030",value:s,stack:new Error().stack,index:1};return c}}function B(s){var c;if(!(typeof s>"u"))return c=Math.abs(s),c}function j(s){var c;if(!(typeof s>"u"))return c=Math.floor(s),c}function P(s){var c;if(!(typeof s>"u"))return c=Math.ceil(s),c}function F(s,c){var f;if(!(typeof s>"u")){if(c){var y=s.toString().split("e");s=+(y[0]+"e"+(y[1]?+y[1]+c:c))}f=Math.round(s);var p=f-s;return Math.abs(p)===.5&&Math.abs(f%2)===1&&(f=f-1),c&&(y=f.toString().split("e"),f=+(y[0]+"e"+(y[1]?+y[1]-c:-c))),Object.is(f,-0)&&(f=0),f}}function J(s){var c;if(!(typeof s>"u")){if(s<0)throw{stack:new Error().stack,code:"D3060",index:1,value:s};return c=Math.sqrt(s),c}}function ye(s,c){var f;if(!(typeof s>"u")){if(f=Math.pow(s,c),!isFinite(f))throw{stack:new Error().stack,code:"D3061",index:1,value:s,exp:c};return f}}function we(){return Math.random()}function K(s){if(!(typeof s>"u")){var c=!1;if(Array.isArray(s)){if(s.length===1)c=K(s[0]);else if(s.length>1){var f=s.filter(function(y){return K(y)});c=f.length>0}}else typeof s=="string"?s.length>0&&(c=!0):v(s)?s!==0&&(c=!0):s!==null&&typeof s=="object"&&!T(s)?Object.keys(s).length>0&&(c=!0):typeof s=="boolean"&&s===!0&&(c=!0);return c}}function ee(s){if(!(typeof s>"u"))return!K(s)}function me(s,c,f,y){var p=[c],E=Q(s);return E>=2&&p.push(f),E>=3&&p.push(y),p}async function G(s,c){if(!(typeof s>"u")){for(var f=D(),y=0;y<s.length;y++){var p=me(c,s[y],y,s),E=await c.apply(this,p);typeof E<"u"&&f.push(E)}return f}}async function Ve(s,c){if(!(typeof s>"u")){for(var f=D(),y=0;y<s.length;y++){var p=s[y],E=me(c,p,y,s),M=await c.apply(this,E);K(M)&&f.push(p)}return f}}async function lt(s,c){if(!(typeof s>"u")){for(var f=!1,y,p=0;p<s.length;p++){var E=s[p],M=!0;if(typeof c<"u"){var H=me(c,E,p,s),X=await c.apply(this,H);M=K(X)}if(M)if(!f)y=E,f=!0;else throw{stack:new Error().stack,code:"D3138",index:p}}if(!f)throw{stack:new Error().stack,code:"D3139"};return y}}function He(){for(var s=[],c=Array.prototype.slice.call(arguments),f=Math.min.apply(Math,c.map(function(E){return Array.isArray(E)?E.length:0})),y=0;y<f;y++){var p=c.map(E=>E[y]);s.push(p)}return s}async function $e(s,c,f){if(!(typeof s>"u")){var y,p=Q(c);if(p<2)throw{stack:new Error().stack,code:"D3050",index:1};var E;for(typeof f>"u"&&s.length>0?(y=s[0],E=1):(y=f,E=0);E<s.length;){var M=[y,s[E]];p>=3&&M.push(E),p>=4&&M.push(s),y=await c.apply(this,M),E++}return y}}function qe(s){var c=D();if(Array.isArray(s)){var f={};s.forEach(function(y){var p=qe(y);p.forEach(function(E){f[E]=!0})}),c=qe(f)}else s!==null&&typeof s=="object"&&!T(s)&&Object.keys(s).forEach(y=>c.push(y));return c}function wt(s,c){var f;if(Array.isArray(s)){f=D();for(var y=0;y<s.length;y++){var p=wt(s[y],c);typeof p<"u"&&(Array.isArray(p)?p.forEach(E=>f.push(E)):f.push(p))}}else s!==null&&typeof s=="object"&&!T(s)&&(f=s[c]);return f}function Tt(s,c){return typeof s>"u"?c:typeof c>"u"?s:(Array.isArray(s)||(s=D(s)),Array.isArray(c)||(c=[c]),s.concat(c))}function gr(s){return!(typeof s>"u")}function St(s){var c=D();if(Array.isArray(s))s.forEach(function(p){c=Tt(c,St(p))});else if(s!==null&&typeof s=="object"&&!I(s))for(var f in s){var y={};y[f]=s[f],c.push(y)}else c=s;return c}function V(s){if(!(typeof s>"u")){var c={};return s.forEach(function(f){for(var y in f)c[y]=f[y]}),c}}function yr(s){if(!(typeof s>"u")){if(s.length<=1)return s;for(var c=s.length,f=new Array(c),y=0;y<c;y++)f[c-y-1]=s[y];return f}}async function Jt(s,c){var f=D();for(var y in s){var p=me(c,s[y],y,s),E=await c.apply(this,p);typeof E<"u"&&f.push(E)}return f}function ft(s){throw{code:"D3137",stack:new Error().stack,message:s||"$error() function evaluated"}}function Ut(s,c){if(!s)throw{code:"D3141",stack:new Error().stack,message:c||"$assert() statement failed"}}function gt(s){if(s!==void 0)return s===null?"null":v(s)?"number":typeof s=="string"?"string":typeof s=="boolean"?"boolean":Array.isArray(s)?"array":T(s)?"function":"object"}async function De(s,c){if(!(typeof s>"u")){if(s.length<=1)return s;var f;if(typeof c>"u"){if(!O(s)&&!k(s))throw{stack:new Error().stack,code:"D3070",index:1};f=async function(M,H){return M>H}}else f=c;var y=async function(M,H){var X=async function(ge,Ne,Se){Ne.length===0?Array.prototype.push.apply(ge,Se):Se.length===0?Array.prototype.push.apply(ge,Ne):await f(Ne[0],Se[0])?(ge.push(Se[0]),await X(ge,Ne,Se.slice(1))):(ge.push(Ne[0]),await X(ge,Ne.slice(1),Se))},Pe=[];return await X(Pe,M,H),Pe},p=async function(M){if(!Array.isArray(M)||M.length<=1)return M;var H=Math.floor(M.length/2),X=M.slice(0,H),Pe=M.slice(H);return X=await p(X),Pe=await p(Pe),await y(X,Pe)},E=await p(s);return E}}function l(s){if(!(typeof s>"u")){if(s.length<=1)return s;for(var c=new Array(s.length),f=0;f<s.length;f++){var y=Math.floor(Math.random()*(f+1));f!==y&&(c[f]=c[y]),c[y]=s[f]}return c}}function h(s){if(!(typeof s>"u")){if(!Array.isArray(s)||s.length<=1)return s;for(var c=_(s)?D():[],f=0;f<s.length;f++){for(var y=s[f],p=!1,E=0;E<c.length;E++)if(pe(y,c[E])){p=!0;break}p||c.push(y)}return c}}async function g(s,c){var f={};for(var y in s){var p=s[y],E=me(c,p,y,s),M=await c.apply(this,E);K(M)&&(f[y]=p)}return Object.keys(f).length===0&&(f=void 0),f}return{sum:R,count:se,max:U,min:A,average:$,string:W,substring:he,substringBefore:xe,substringAfter:Ae,lowercase:Te,uppercase:ve,length:Me,trim:nt,pad:_e,match:ie,contains:at,replace:Be,split:Ee,join:w,formatNumber:S,formatBase:x,number:N,floor:j,ceil:P,round:F,abs:B,sqrt:J,power:ye,random:we,boolean:K,not:ee,map:G,zip:He,filter:Ve,single:lt,foldLeft:$e,sift:g,keys:qe,lookup:wt,append:Tt,exists:gr,spread:St,merge:V,reverse:yr,each:Jt,error:ft,assert:Ut,type:gt,sort:De,shuffle:l,distinct:h,base64encode:ct,base64decode:d,encodeUrlComponent:m,encodeUrl:z,decodeUrlComponent:de,decodeUrl:Ce}})();a.exports=u}).call(this)}).call(this,typeof xn<"u"?xn:typeof self<"u"?self:typeof window<"u"?window:{})},{"./utils":6}],3:[function(r,a,n){var i=r("./datetime"),o=r("./functions"),u=r("./utils"),v=r("./parser"),k=r("./signature"),O=(function(){var D=u.isNumeric,_=u.isArrayOfStrings,T=u.isArrayOfNumbers,I=u.createSequence,ae=u.isSequence,Q=u.isFunction,pe=u.isLambda,q=u.isIterable,R=u.isPromise,se=u.getFunctionArity,U=u.isDeepEqual,A=ft(null);async function $(l,h,g){var s,c=g.lookup(Symbol.for("jsonata.__evaluate_entry"));switch(c&&await c(l,h,g),l.type){case"path":s=await W(l,h,g);break;case"binary":s=await Me(l,h,g);break;case"unary":s=await nt(l,h,g);break;case"name":s=_e(l,h);break;case"string":case"number":case"value":s=fe(l);break;case"wildcard":s=at(l,h);break;case"descendant":s=Be(l,h);break;case"parent":s=g.lookup(l.slot.label);break;case"condition":s=await j(l,h,g);break;case"block":s=await P(l,h,g);break;case"bind":s=await B(l,h,g);break;case"regex":s=F(l);break;case"function":s=await me(l,h,g);break;case"variable":s=J(l,h,g);break;case"lambda":s=lt(l,h,g);break;case"partial":s=await He(l,h,g);break;case"apply":s=await ee(l,h,g);break;case"transform":s=we(l,h,g);break}if(Object.prototype.hasOwnProperty.call(l,"predicate"))for(var f=0;f<l.predicate.length;f++)s=await ve(l.predicate[f].expr,s,g);l.type!=="path"&&Object.prototype.hasOwnProperty.call(l,"group")&&(s=await S(l.group,s,g));var y=g.lookup(Symbol.for("jsonata.__evaluate_exit"));return y&&await y(l,h,g,s),s&&ae(s)&&!s.tupleStream&&(l.keepArray&&(s.keepSingleton=!0),s.length===0?s=void 0:s.length===1&&(s=s.keepSingleton?s:s[0])),s}async function W(l,h,g){var s;Array.isArray(h)&&l.steps[0].type!=="variable"?s=h:s=I(h);for(var c,f=!1,y=void 0,p=0;p<l.steps.length;p++){var E=l.steps[p];if(E.tuple&&(f=!0),p===0&&E.consarray?c=await $(E,s,g):f?y=await Te(E,s,y,g):c=await xe(E,s,g,p===l.steps.length-1),!f&&(typeof c>"u"||c.length===0))break;typeof E.focus>"u"&&(s=c)}if(f)if(l.tuple)c=y;else for(c=I(),p=0;p<y.length;p++)c.push(y[p]["@"]);return l.keepSingletonArray&&(Array.isArray(c)&&c.cons&&!c.sequence&&(c=I(c)),c.keepSingleton=!0),l.hasOwnProperty("group")&&(c=await S(l.group,f?y:c,g)),c}function he(l,h){var g=ft(l);for(const s in h)g.bind(s,h[s]);return g}async function xe(l,h,g,s){var c;if(l.type==="sort")return c=await ye(l,h,g),l.stages&&(c=await Ae(l.stages,c,g)),c;c=I();for(var f=0;f<h.length;f++){var y=await $(l,h[f],g);if(l.stages)for(var p=0;p<l.stages.length;p++)y=await ve(l.stages[p].expr,y,g);typeof y<"u"&&c.push(y)}var E=I();return s&&c.length===1&&Array.isArray(c[0])&&!ae(c[0])?E=c[0]:c.forEach(function(M){!Array.isArray(M)||M.cons?E.push(M):M.forEach(H=>E.push(H))}),E}async function Ae(l,h,g){for(var s=h,c=0;c<l.length;c++){var f=l[c];switch(f.type){case"filter":s=await ve(f.expr,s,g);break;case"index":for(var y=0;y<s.length;y++){var p=s[y];p[f.value]=y}break}}return s}async function Te(l,h,g,s){var c;if(l.type==="sort"){if(g)c=await ye(l,g,s);else{var f=await ye(l,h,s);c=I(),c.tupleStream=!0;for(var y=0;y<f.length;y++){var p={"@":f[y]};p[l.index]=y,c.push(p)}}return l.stages&&(c=await Ae(l.stages,c,s)),c}c=I(),c.tupleStream=!0;var E=s;g===void 0&&(g=h.map(Pe=>({"@":Pe})));for(var M=0;M<g.length;M++){E=he(s,g[M]);var H=await $(l,g[M]["@"],E);if(typeof H<"u"){Array.isArray(H)||(H=[H]);for(var X=0;X<H.length;X++)p={},Object.assign(p,g[M]),H.tupleStream?Object.assign(p,H[X]):(l.focus?(p[l.focus]=H[X],p["@"]=g[M]["@"]):p["@"]=H[X],l.index&&(p[l.index]=X),l.ancestor&&(p[l.ancestor.label]=g[M]["@"])),c.push(p)}}return l.stages&&(c=await Ae(l.stages,c,s)),c}async function ve(l,h,g){var s=I();if(h&&h.tupleStream&&(s.tupleStream=!0),Array.isArray(h)||(h=I(h)),l.type==="number"){var c=Math.floor(l.value);c<0&&(c=h.length+c);var f=await h[c];typeof f<"u"&&(Array.isArray(f)?s=f:s.push(f))}else for(c=0;c<h.length;c++){var f=h[c],y=f,p=g;h.tupleStream&&(y=f["@"],p=he(g,f));var E=await $(l,y,p);D(E)&&(E=[E]),T(E)?E.forEach(function(H){var X=Math.floor(H);X<0&&(X=h.length+X),X===c&&s.push(f)}):o.boolean(E)&&s.push(f)}return s}async function Me(l,h,g){var s,c=await $(l.lhs,h,g),f=l.value,y=async()=>await $(l.rhs,h,g);if(f==="and"||f==="or")try{return await Ce(c,y,f)}catch(E){throw E.position=l.position,E.token=f,E}var p=await y();try{switch(f){case"+":case"-":case"*":case"/":case"%":s=d(c,p,f);break;case"=":case"!=":s=m(c,p,f);break;case"<":case"<=":case">":case">=":s=z(c,p,f);break;case"&":s=w(c,p);break;case"..":s=N(c,p);break;case"in":s=de(c,p);break}}catch(E){throw E.position=l.position,E.token=f,E}return s}async function nt(l,h,g){var s;switch(l.value){case"-":if(s=await $(l.expression,h,g),typeof s>"u")s=void 0;else if(D(s))s=-s;else throw{code:"D1002",stack:new Error().stack,position:l.position,token:l.value,value:s};break;case"[":s=[];let y=await Promise.all(l.expressions.map(async(p,E)=>(g.isParallelCall=E>0,[p,await $(p,h,g)])));for(let p of y){var[c,f]=p;typeof f<"u"&&(c.value==="["?s.push(f):s=o.append(s,f))}l.consarray&&Object.defineProperty(s,"cons",{enumerable:!1,configurable:!1,value:!0});break;case"{":s=await S(l,h,g);break}return s}function _e(l,h,g){return o.lookup(h,l.value)}function fe(l){return l.value}function at(l,h){var g=I();return Array.isArray(h)&&h.outerWrapper&&h.length>0&&(h=h[0]),h!==null&&typeof h=="object"&&Object.keys(h).forEach(function(s){var c=h[s];Array.isArray(c)?(c=ie(c),g=o.append(g,c)):g.push(c)}),g}function ie(l,h){return typeof h>"u"&&(h=[]),Array.isArray(l)?l.forEach(function(g){ie(g,h)}):h.push(l),h}function Be(l,h){var g,s=I();return typeof h<"u"&&(ct(h,s),s.length===1?g=s[0]:g=s),g}function ct(l,h){Array.isArray(l)||h.push(l),Array.isArray(l)?l.forEach(function(g){ct(g,h)}):l!==null&&typeof l=="object"&&Object.keys(l).forEach(function(g){ct(l[g],h)})}function d(l,h,g){var s;if(typeof l<"u"&&!D(l))throw{code:"T2001",stack:new Error().stack,value:l};if(typeof h<"u"&&!D(h))throw{code:"T2002",stack:new Error().stack,value:h};if(typeof l>"u"||typeof h>"u")return s;switch(g){case"+":s=l+h;break;case"-":s=l-h;break;case"*":s=l*h;break;case"/":s=l/h;break;case"%":s=l%h;break}return s}function m(l,h,g){var s,c=typeof l,f=typeof h;if(c==="undefined"||f==="undefined")return!1;switch(g){case"=":s=U(l,h);break;case"!=":s=!U(l,h);break}return s}function z(l,h,g){var s,c=typeof l,f=typeof h,y=c==="undefined"||c==="string"||c==="number",p=f==="undefined"||f==="string"||f==="number";if(!y||!p)throw{code:"T2010",stack:new Error().stack,value:c==="string"||c==="number"?h:l};if(!(c==="undefined"||f==="undefined")){if(c!==f)throw{code:"T2009",stack:new Error().stack,value:l,value2:h};switch(g){case"<":s=l<h;break;case"<=":s=l<=h;break;case">":s=l>h;break;case">=":s=l>=h;break}return s}}function de(l,h){var g=!1;if(typeof l>"u"||typeof h>"u")return!1;Array.isArray(h)||(h=[h]);for(var s=0;s<h.length;s++)if(h[s]===l){g=!0;break}return g}async function Ce(l,h,g){var s,c=Ee(l);switch(g){case"and":s=c&&Ee(await h());break;case"or":s=c||Ee(await h());break}return s}function Ee(l){var h=o.boolean(l);return typeof h>"u"?!1:h}function w(l,h){var g,s="",c="";return typeof l<"u"&&(s=o.string(l)),typeof h<"u"&&(c=o.string(h)),g=s.concat(c),g}async function S(l,h,g){var s={},c={},f=!!(h&&h.tupleStream);Array.isArray(h)||(h=I(h)),h.length===0&&h.push(void 0);for(var y=0;y<h.length;y++)for(var p=h[y],E=f?he(g,p):g,M=0;M<l.lhs.length;M++){var H=l.lhs[M],X=await $(H[0],f?p["@"]:p,E);if(typeof X!="string"&&X!==void 0)throw{code:"T1003",stack:new Error().stack,position:l.position,value:X};if(X!==void 0){var Pe={data:p,exprIndex:M};if(c.hasOwnProperty(X)){if(c[X].exprIndex!==M)throw{code:"D1009",stack:new Error().stack,position:l.position,value:X};c[X].data=o.append(c[X].data,p)}else c[X]=Pe}}let ge=await Promise.all(Object.keys(c).map(async(Se,Ze)=>{let ke=c[Se];var Fe=ke.data,ut=g;if(f){var We=x(ke.data);Fe=We["@"],delete We["@"],ut=he(g,We)}return g.isParallelCall=Ze>0,[Se,await $(l.lhs[ke.exprIndex][1],Fe,ut)]}));for(let Se of ge){var[X,Ne]=await Se;typeof Ne<"u"&&(s[X]=Ne)}return s}function x(l){if(!Array.isArray(l))return l;var h={};Object.assign(h,l[0]);for(var g=1;g<l.length;g++)for(const s in l[g])h[s]=o.append(h[s],l[g][s]);return h}function N(l,h){var g;if(typeof l<"u"&&!Number.isInteger(l))throw{code:"T2003",stack:new Error().stack,value:l};if(typeof h<"u"&&!Number.isInteger(h))throw{code:"T2004",stack:new Error().stack,value:h};if(typeof l>"u"||typeof h>"u"||l>h)return g;var s=h-l+1;if(s>1e7)throw{code:"D2014",stack:new Error().stack,value:s};g=new Array(s);for(var c=l,f=0;c<=h;c++,f++)g[f]=c;return g.sequence=!0,g}async function B(l,h,g){var s=await $(l.rhs,h,g);return g.bind(l.lhs.value,s),s}async function j(l,h,g){var s,c=await $(l.condition,h,g);return o.boolean(c)?s=await $(l.then,h,g):typeof l.else<"u"&&(s=await $(l.else,h,g)),s}async function P(l,h,g){for(var s,c=ft(g),f=0;f<l.expressions.length;f++)s=await $(l.expressions[f],h,c);return s}function F(l){var h=new De.RegexEngine(l.value),g=function(s,c){var f;h.lastIndex=c||0;var y=h.exec(s);if(y!==null){if(f={match:y[0],start:y.index,end:y.index+y[0].length,groups:[]},y.length>1)for(var p=1;p<y.length;p++)f.groups.push(y[p]);f.next=function(){if(!(h.lastIndex>=s.length)){var E=g(s,h.lastIndex);if(E&&E.match==="")throw{code:"D1004",stack:new Error().stack,position:l.position,value:l.value.source};return E}}}return f};return g}function J(l,h,g){var s;return l.value===""?s=h&&h.outerWrapper?h[0]:h:s=g.lookup(l.value),s}async function ye(l,h,g){var s,c=h,f=!!h.tupleStream,y=async function(E,M){for(var H=0,X=0;H===0&&X<l.terms.length;X++){var Pe=l.terms[X],ge=E,Ne=g;f&&(ge=E["@"],Ne=he(g,E));var Se=await $(Pe.expression,ge,Ne);ge=M,Ne=g,f&&(ge=M["@"],Ne=he(g,M));var Ze=await $(Pe.expression,ge,Ne),ke=typeof Se,Fe=typeof Ze;if(ke==="undefined"){H=Fe==="undefined"?0:1;continue}if(Fe==="undefined"){H=-1;continue}if(!(ke==="string"||ke==="number")||!(Fe==="string"||Fe==="number"))throw{code:"T2008",stack:new Error().stack,position:l.position,value:ke==="string"||ke==="number"?Ze:Se};if(ke!==Fe)throw{code:"T2007",stack:new Error().stack,position:l.position,value:Se,value2:Ze};Se!==Ze&&(Se<Ze?H=-1:H=1,Pe.descending===!0&&(H=-H))}return H===1},p={environment:g,input:h};return s=await o.sort.apply(p,[c,y]),s}function we(l,h,g){var s=async function(c){if(!(typeof c>"u")){var f=g.lookup("clone");if(!Q(f))throw{code:"T2013",stack:new Error().stack,position:l.position};var y=await G(f,[c],null,g),p=await $(l.pattern,y,g);if(typeof p<"u"){Array.isArray(p)||(p=[p]);for(var E=0;E<p.length;E++){var M=p[E];if(M&&(M.isPrototypeOf(y)||M instanceof Object.constructor))throw{code:"D1010",stack:new Error().stack,position:l.position};var H=await $(l.update,M,g),X=typeof H;if(X!=="undefined"){if(X!=="object"||H===null||Array.isArray(H))throw{code:"T2011",stack:new Error().stack,position:l.update.position,value:H};for(var Pe in H)M[Pe]=H[Pe]}if(typeof l.delete<"u"){var ge=await $(l.delete,M,g);if(typeof ge<"u"){var Ne=ge;if(Array.isArray(ge)||(ge=[ge]),!_(ge))throw{code:"T2012",stack:new Error().stack,position:l.delete.position,value:Ne};for(var Se=0;Se<ge.length;Se++)typeof M=="object"&&M!==null&&delete M[ge[Se]]}}}}return y}};return V(s,"<(oa):o>")}var K=v("function($f, $g) { function($x){ $g($f($x)) } }");async function ee(l,h,g){var s,c=await $(l.lhs,h,g);if(l.rhs.type==="function")s=await me(l.rhs,h,g,{context:c});else{var f=await $(l.rhs,h,g);if(!Q(f))throw{code:"T2006",stack:new Error().stack,position:l.position,value:f};if(Q(c)){var y=await $(K,null,g);s=await G(y,[c,f],null,g)}else s=await G(f,[c],null,g)}return s}async function me(l,h,g,s){var c,f=await $(l.procedure,h,g);if(typeof f>"u"&&l.procedure.type==="path"&&g.lookup(l.procedure.steps[0].value))throw{code:"T1005",stack:new Error().stack,position:l.position,token:l.procedure.steps[0].value};var y=[];typeof s<"u"&&y.push(s.context);for(var p=0;p<l.arguments.length;p++){const M=await $(l.arguments[p],h,g);if(Q(M)){const H=async function(...X){return await G(M,X,null,g)};H.arity=se(M),y.push(H)}else y.push(M)}var E=l.procedure.type==="path"?l.procedure.steps[0].value:l.procedure.value;try{typeof f=="object"&&(f.token=E,f.position=l.position),c=await G(f,y,h,g)}catch(M){throw M.position||(M.position=l.position),M.token||(M.token=E),M}return c}async function G(l,h,g,s){var c;for(c=await Ve(l,h,g,s);pe(c)&&c.thunk===!0;){var f=await $(c.body.procedure,c.input,c.environment);c.body.procedure.type==="variable"&&(f.token=c.body.procedure.value),f.position=c.body.procedure.position;for(var y=[],p=0;p<c.body.arguments.length;p++)y.push(await $(c.body.arguments[p],c.input,c.environment));c=await Ve(f,y,g,s)}return c}async function Ve(l,h,g,s){var c;try{var f=h;if(l&&(f=$e(l.signature,h,g)),pe(l))c=await qe(l,f);else if(l&&l._jsonata_function===!0){var y={environment:s,input:g};c=l.implementation.apply(y,f),q(c)&&(c=c.next().value),R(c)&&(c=await c)}else if(typeof l=="function")c=l.apply(g,f),R(c)&&(c=await c);else throw{code:"T1006",stack:new Error().stack}}catch(p){throw l&&(typeof p.token>"u"&&typeof l.token<"u"&&(p.token=l.token),p.position=l.position||p.position),p}return c}function lt(l,h,g){var s={_jsonata_lambda:!0,input:h,environment:g,arguments:l.arguments,signature:l.signature,body:l.body};return l.thunk===!0&&(s.thunk=!0),s.apply=async function(c,f){return await G(s,f,h,c?c.environment:g)},s}async function He(l,h,g){for(var s,c=[],f=0;f<l.arguments.length;f++){var y=l.arguments[f];y.type==="operator"&&y.value==="?"?c.push(y):c.push(await $(y,h,g))}var p=await $(l.procedure,h,g);if(typeof p>"u"&&l.procedure.type==="path"&&g.lookup(l.procedure.steps[0].value))throw{code:"T1007",stack:new Error().stack,position:l.position,token:l.procedure.steps[0].value};if(pe(p))s=wt(p,c);else if(p&&p._jsonata_function===!0)s=Tt(p.implementation,c);else if(typeof p=="function")s=Tt(p,c);else throw{code:"T1008",stack:new Error().stack,position:l.position,token:l.procedure.type==="path"?l.procedure.steps[0].value:l.procedure.value};return s}function $e(l,h,g){if(typeof l>"u")return h;var s=l.validate(h,g);return s}async function qe(l,h){var g,s=ft(l.environment);return l.arguments.forEach(function(c,f){s.bind(c.value,h[f])}),typeof l.body=="function"?g=await gr(l.body,s):g=await $(l.body,l.input,s),g}function wt(l,h){var g=ft(l.environment),s=[];l.arguments.forEach(function(f,y){var p=h[y];p&&p.type==="operator"&&p.value==="?"?s.push(f):g.bind(f.value,p)});var c={_jsonata_lambda:!0,input:l.input,environment:g,arguments:s,body:l.body};return c}function Tt(l,h){var g=St(l);g=g.map(function(y){return"$"+y.trim()});var s="function("+g.join(", ")+"){ _ }",c=v(s);c.body=l;var f=wt(c,h);return f}async function gr(l,h){var g=St(l),s=g.map(function(y){return h.lookup(y.trim())}),c={environment:h},f=l.apply(c,s);return R(f)&&(f=await f),f}function St(l){var h=l.toString(),g=/\(([^)]*)\)/.exec(h)[1],s=g.split(",");return s}function V(l,h){var g={_jsonata_function:!0,implementation:l};return typeof h<"u"&&(g.signature=k(h)),g}async function yr(l,h){if(!(typeof l>"u")){var g=this.input;typeof h<"u"&&(g=h,Array.isArray(g)&&!ae(g)&&(g=I(g),g.outerWrapper=!0));try{var s=v(l,!1)}catch(f){throw gt(f),{stack:new Error().stack,code:"D3120",value:f.message,error:f}}try{var c=await $(s,g,this.environment)}catch(f){throw gt(f),{stack:new Error().stack,code:"D3121",value:f.message,error:f}}return c}}function Jt(l){if(!(typeof l>"u"))return JSON.parse(o.string(l))}function ft(l){var h={};const g={bind:function(c,f){h[c]=f},lookup:function(c){var f;return h.hasOwnProperty(c)?f=h[c]:l&&(f=l.lookup(c)),f},timestamp:l?l.timestamp:null,async:l?l.async:!1,isParallelCall:l?l.isParallelCall:!1,global:l?l.global:{ancestry:[null]}};if(l){var s=l.lookup(Symbol.for("jsonata.__createFrame_push"));s&&s(l,g)}return g}A.bind("sum",V(o.sum,"<a<n>:n>")),A.bind("count",V(o.count,"<a:n>")),A.bind("max",V(o.max,"<a<n>:n>")),A.bind("min",V(o.min,"<a<n>:n>")),A.bind("average",V(o.average,"<a<n>:n>")),A.bind("string",V(o.string,"<x-b?:s>")),A.bind("substring",V(o.substring,"<s-nn?:s>")),A.bind("substringBefore",V(o.substringBefore,"<s-s:s>")),A.bind("substringAfter",V(o.substringAfter,"<s-s:s>")),A.bind("lowercase",V(o.lowercase,"<s-:s>")),A.bind("uppercase",V(o.uppercase,"<s-:s>")),A.bind("length",V(o.length,"<s-:n>")),A.bind("trim",V(o.trim,"<s-:s>")),A.bind("pad",V(o.pad,"<s-ns?:s>")),A.bind("match",V(o.match,"<s-f<s:o>n?:a<o>>")),A.bind("contains",V(o.contains,"<s-(sf):b>")),A.bind("replace",V(o.replace,"<s-(sf)(sf)n?:s>")),A.bind("split",V(o.split,"<s-(sf)n?:a<s>>")),A.bind("join",V(o.join,"<a<s>s?:s>")),A.bind("formatNumber",V(o.formatNumber,"<n-so?:s>")),A.bind("formatBase",V(o.formatBase,"<n-n?:s>")),A.bind("formatInteger",V(i.formatInteger,"<n-s:s>")),A.bind("parseInteger",V(i.parseInteger,"<s-s:n>")),A.bind("number",V(o.number,"<(nsb)-:n>")),A.bind("floor",V(o.floor,"<n-:n>")),A.bind("ceil",V(o.ceil,"<n-:n>")),A.bind("round",V(o.round,"<n-n?:n>")),A.bind("abs",V(o.abs,"<n-:n>")),A.bind("sqrt",V(o.sqrt,"<n-:n>")),A.bind("power",V(o.power,"<n-n:n>")),A.bind("random",V(o.random,"<:n>")),A.bind("boolean",V(o.boolean,"<x-:b>")),A.bind("not",V(o.not,"<x-:b>")),A.bind("map",V(o.map,"<af>")),A.bind("zip",V(o.zip,"<a+>")),A.bind("filter",V(o.filter,"<af>")),A.bind("single",V(o.single,"<af?>")),A.bind("reduce",V(o.foldLeft,"<afj?:j>")),A.bind("sift",V(o.sift,"<o-f?:o>")),A.bind("keys",V(o.keys,"<x-:a<s>>")),A.bind("lookup",V(o.lookup,"<x-s:x>")),A.bind("append",V(o.append,"<xx:a>")),A.bind("exists",V(o.exists,"<x:b>")),A.bind("spread",V(o.spread,"<x-:a<o>>")),A.bind("merge",V(o.merge,"<a<o>:o>")),A.bind("reverse",V(o.reverse,"<a:a>")),A.bind("each",V(o.each,"<o-f:a>")),A.bind("error",V(o.error,"<s?:x>")),A.bind("assert",V(o.assert,"<bs?:x>")),A.bind("type",V(o.type,"<x:s>")),A.bind("sort",V(o.sort,"<af?:a>")),A.bind("shuffle",V(o.shuffle,"<a:a>")),A.bind("distinct",V(o.distinct,"<x:x>")),A.bind("base64encode",V(o.base64encode,"<s-:s>")),A.bind("base64decode",V(o.base64decode,"<s-:s>")),A.bind("encodeUrlComponent",V(o.encodeUrlComponent,"<s-:s>")),A.bind("encodeUrl",V(o.encodeUrl,"<s-:s>")),A.bind("decodeUrlComponent",V(o.decodeUrlComponent,"<s-:s>")),A.bind("decodeUrl",V(o.decodeUrl,"<s-:s>")),A.bind("eval",V(yr,"<sx?:x>")),A.bind("toMillis",V(i.toMillis,"<s-s?:n>")),A.bind("fromMillis",V(i.fromMillis,"<n-s?s?:s>")),A.bind("clone",V(Jt,"<(oa)-:o>"));var Ut={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function gt(l){var h=Ut[l.code];if(typeof h<"u"){var g=h.replace(/\{\{\{([^}]+)}}}/g,function(){return l[arguments[1]]});g=g.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(l[arguments[1]])}),l.message=g}}function De(l,h){var g,s;try{g=v(l,h&&h.recover),s=g.errors,delete g.errors}catch(y){throw gt(y),y}var c=ft(A),f=new Date;return c.bind("now",V(function(y,p){return i.fromMillis(f.getTime(),y,p)},"<s?s?:s>")),c.bind("millis",V(function(){return f.getTime()},"<:n>")),h&&h.RegexEngine?De.RegexEngine=h.RegexEngine:De.RegexEngine=RegExp,{evaluate:async function(y,p,E){if(typeof s<"u"){var M={code:"S0500",position:0};throw gt(M),M}if(typeof p<"u"){var H;H=ft(c);for(var X in p)H.bind(X,p[X])}else H=c;H.bind("$",y),f=new Date,H.timestamp=f,Array.isArray(y)&&!ae(y)&&(y=I(y),y.outerWrapper=!0);var Pe;try{return Pe=await $(g,y,H),typeof E=="function"&&E(null,Pe),Pe}catch(ge){throw gt(ge),ge}},assign:function(y,p){c.bind(y,p)},registerFunction:function(y,p,E){var M=V(p,E);c.bind(y,M)},ast:function(){return g},errors:function(){return s}}}return De.parser=v,De})();a.exports=O},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(r,a,n){var i=r("./signature");const o=(()=>{var u={".":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},v={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
+ `,r:"\r",t:" "},k=function(D){var _=0,T=D.length,I=function(pe,q){var R={type:pe,value:q,position:_};return R},ae=function(){for(var pe=_,q=0,R,se,U=function($){if(D.charAt($)==="/"&&q===0){for(var W=0;D.charAt($-(W+1))==="\\";)W++;if(W%2===0)return!0}return!1};_<T;){var A=D.charAt(_);if(U(_)){if(R=D.substring(pe,_),R==="")throw{code:"S0301",stack:new Error().stack,position:_};for(_++,A=D.charAt(_),pe=_;A==="i"||A==="m";)_++,A=D.charAt(_);return se=D.substring(pe,_)+"g",new RegExp(R,se)}(A==="("||A==="["||A==="{")&&D.charAt(_-1)!=="\\"&&q++,(A===")"||A==="]"||A==="}")&&D.charAt(_-1)!=="\\"&&q--,_++}throw{code:"S0302",stack:new Error().stack,position:_}},Q=function(pe){if(_>=T)return null;for(var q=D.charAt(_);_<T&&`
3
+ \r\v`.indexOf(q)>-1;)_++,q=D.charAt(_);if(q==="/"&&D.charAt(_+1)==="*"){var R=_;for(_+=2,q=D.charAt(_);!(q==="*"&&D.charAt(_+1)==="/");)if(q=D.charAt(++_),_>=T)throw{code:"S0106",stack:new Error().stack,position:R};return _+=2,q=D.charAt(_),Q(pe)}if(pe!==!0&&q==="/")return _++,I("regex",ae());if(q==="."&&D.charAt(_+1)===".")return _+=2,I("operator","..");if(q===":"&&D.charAt(_+1)==="=")return _+=2,I("operator",":=");if(q==="!"&&D.charAt(_+1)==="=")return _+=2,I("operator","!=");if(q===">"&&D.charAt(_+1)==="=")return _+=2,I("operator",">=");if(q==="<"&&D.charAt(_+1)==="=")return _+=2,I("operator","<=");if(q==="*"&&D.charAt(_+1)==="*")return _+=2,I("operator","**");if(q==="~"&&D.charAt(_+1)===">")return _+=2,I("operator","~>");if(q==="?"&&D.charAt(_+1)===":")return _+=2,I("operator","?:");if(q==="?"&&D.charAt(_+1)==="?")return _+=2,I("operator","??");if(Object.prototype.hasOwnProperty.call(u,q))return _++,I("operator",q);if(q==='"'||q==="'"){var se=q;_++;for(var U="";_<T;){if(q=D.charAt(_),q==="\\")if(_++,q=D.charAt(_),Object.prototype.hasOwnProperty.call(v,q))U+=v[q];else if(q==="u"){var A=D.substr(_+1,4);if(/^[0-9a-fA-F]+$/.test(A)){var $=parseInt(A,16);U+=String.fromCharCode($),_+=4}else throw{code:"S0104",stack:new Error().stack,position:_}}else throw{code:"S0103",stack:new Error().stack,position:_,token:q};else{if(q===se)return _++,I("string",U);U+=q}_++}throw{code:"S0101",stack:new Error().stack,position:_}}var W=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/,he=W.exec(D.substring(_));if(he!==null){var xe=parseFloat(he[0]);if(!isNaN(xe)&&isFinite(xe))return _+=he[0].length,I("number",xe);throw{code:"S0102",stack:new Error().stack,position:_,token:he[0]}}var Ae;if(q==="`"){_++;var Te=D.indexOf("`",_);if(Te!==-1)return Ae=D.substring(_,Te),_=Te+1,I("name",Ae);throw _=T,{code:"S0105",stack:new Error().stack,position:_}}for(var ve=_,Me;;)if(Me=D.charAt(ve),ve===T||`
4
+ \r\v`.indexOf(Me)>-1||Object.prototype.hasOwnProperty.call(u,Me)){if(D.charAt(_)==="$")return Ae=D.substring(_+1,ve),_=ve,I("variable",Ae);switch(Ae=D.substring(_,ve),_=ve,Ae){case"or":case"in":case"and":return I("operator",Ae);case"true":return I("value",!0);case"false":return I("value",!1);case"null":return I("value",null);default:return _===T&&Ae===""?null:I("name",Ae)}}else ve++};return Q},O=function(D,_){var T,I,ae={},Q=[],pe=function(){var d=[];T.id!=="(end)"&&d.push({type:T.type,value:T.value,position:T.position});for(var m=I();m!==null;)d.push(m),m=I();return d},q={nud:function(){var d={code:"S0211",token:this.value,position:this.position};if(_)return d.remaining=pe(),d.type="error",Q.push(d),d;throw d.stack=new Error().stack,d}},R=function(d,m){var z=ae[d];return m=m||0,z?m>=z.lbp&&(z.lbp=m):(z=Object.create(q),z.id=z.value=d,z.lbp=m,ae[d]=z),z},se=function(d){if(_){d.remaining=pe(),Q.push(d);var m=ae["(error)"];return T=Object.create(m),T.error=d,T.type="(error)",T}else throw d.stack=new Error().stack,d},U=function(d,m){if(d&&T.id!==d){var z;T.id==="(end)"?z="S0203":z="S0202";var de={code:z,position:T.position,token:T.value,value:d};return se(de)}var Ce=I(m);if(Ce===null)return T=ae["(end)"],T.position=D.length,T;var Ee=Ce.value,w=Ce.type,S;switch(w){case"name":case"variable":S=ae["(name)"];break;case"operator":if(S=ae[Ee],!S)return se({code:"S0204",stack:new Error().stack,position:Ce.position,token:Ee});break;case"string":case"number":case"value":S=ae["(literal)"];break;case"regex":w="regex",S=ae["(regex)"];break;default:return se({code:"S0205",stack:new Error().stack,position:Ce.position,token:Ee})}return T=Object.create(S),T.value=Ee,T.type=w,T.position=Ce.position,T},A=function(d){var m,z=T;for(U(null,!0),m=z.nud();d<T.lbp;)z=T,U(),m=z.led(m);return m},$=function(d){var m=R(d,0);m.nud=function(){return this}},W=function(d,m,z){var de=m||u[d],Ce=R(d,de);return Ce.led=z||function(Ee){return this.lhs=Ee,this.rhs=A(de),this.type="binary",this},Ce},he=function(d,m,z){var de=R(d,m);return de.led=z,de},xe=function(d,m){var z=R(d);return z.nud=m||function(){return this.expression=A(70),this.type="unary",this},z};$("(end)"),$("(name)"),$("(literal)"),$("(regex)"),R(":"),R(";"),R(","),R(")"),R("]"),R("}"),R(".."),W("."),W("+"),W("-"),W("*"),W("/"),W("%"),W("="),W("<"),W(">"),W("!="),W("<="),W(">="),W("&"),W("and"),W("or"),W("in"),$("and"),$("or"),$("in"),xe("-"),W("~>"),W("??",u["??"],function(d){return this.type="condition",this.condition={type:"function",value:"(",procedure:{type:"variable",value:"exists"},arguments:[d]},this.then=d,this.else=A(0),this}),he("(error)",10,function(d){return this.lhs=d,this.error=T.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}),W("(",u["("],function(d){if(this.procedure=d,this.type="function",this.arguments=[],T.id!==")")for(;T.type==="operator"&&T.id==="?"?(this.type="partial",this.arguments.push(T),U("?")):this.arguments.push(A(0)),T.id===",";)U(",");if(U(")",!0),d.type==="name"&&(d.value==="function"||d.value==="λ")){if(this.arguments.forEach(function(Ee,w){if(Ee.type!=="variable")return se({code:"S0208",stack:new Error().stack,position:Ee.position,token:Ee.value,value:w+1})}),this.type="lambda",T.id==="<"){for(var m=T.position,z=1,de="<";z>0&&T.id!=="{"&&T.id!=="(end)";){var Ce=U();Ce.id===">"?z--:Ce.id==="<"&&z++,de+=Ce.value}U(">");try{this.signature=i(de)}catch(Ee){return Ee.position=m+Ee.offset,se(Ee)}}U("{"),this.body=A(0),U("}")}return this}),xe("(",function(){for(var d=[];T.id!==")"&&(d.push(A(0)),T.id===";");)U(";");return U(")",!0),this.type="block",this.expressions=d,this}),xe("[",function(){var d=[];if(T.id!=="]")for(;;){var m=A(0);if(T.id===".."){var z={type:"binary",value:"..",position:T.position,lhs:m};U(".."),z.rhs=A(0),m=z}if(d.push(m),T.id!==",")break;U(",")}return U("]",!0),this.expressions=d,this.type="unary",this}),W("[",u["["],function(d){if(T.id==="]"){for(var m=d;m&&m.type==="binary"&&m.value==="[";)m=m.lhs;return m.keepArray=!0,U("]"),d}else return this.lhs=d,this.rhs=A(u["]"]),this.type="binary",U("]",!0),this}),W("^",u["^"],function(d){U("(");for(var m=[];;){var z={descending:!1};if(T.id==="<"?U("<"):T.id===">"&&(z.descending=!0,U(">")),z.expression=A(0),m.push(z),T.id!==",")break;U(",")}return U(")"),this.lhs=d,this.rhs=m,this.type="binary",this});var Ae=function(d){var m=[];if(T.id!=="}")for(;;){var z=A(0);U(":");var de=A(0);if(m.push([z,de]),T.id!==",")break;U(",")}return U("}",!0),typeof d>"u"?(this.lhs=m,this.type="unary"):(this.lhs=d,this.rhs=m,this.type="binary"),this};xe("{",Ae),W("{",u["{"],Ae),he(":=",u[":="],function(d){return d.type!=="variable"?se({code:"S0212",stack:new Error().stack,position:d.position,token:d.value}):(this.lhs=d,this.rhs=A(u[":="]-1),this.type="binary",this)}),W("@",u["@"],function(d){return this.lhs=d,this.rhs=A(u["@"]),this.rhs.type!=="variable"?se({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),W("#",u["#"],function(d){return this.lhs=d,this.rhs=A(u["#"]),this.rhs.type!=="variable"?se({code:"S0214",stack:new Error().stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),W("?",u["?"],function(d){return this.type="condition",this.condition=d,this.then=A(0),T.id===":"&&(U(":"),this.else=A(0)),this}),W("?:",u["?:"],function(d){return this.type="condition",this.condition=d,this.then=d,this.else=A(0),this}),xe("|",function(){return this.type="transform",this.pattern=A(0),U("|"),this.update=A(0),T.id===","&&(U(","),this.delete=A(0)),U("|"),this});var Te=function(d){var m;if(d.type==="function"&&!d.predicate){var z={type:"lambda",thunk:!0,arguments:[],position:d.position};z.body=d,m=z}else if(d.type==="condition")d.then=Te(d.then),typeof d.else<"u"&&(d.else=Te(d.else)),m=d;else if(d.type==="block"){var de=d.expressions.length;de>0&&(d.expressions[de-1]=Te(d.expressions[de-1])),m=d}else m=d;return m},ve=0,Me=0,nt=[],_e=function(d,m){switch(d.type){case"name":case"wildcard":m.level--,m.level===0&&(typeof d.ancestor>"u"||(nt[m.index].slot.label=d.ancestor.label),d.ancestor=m,d.tuple=!0);break;case"parent":m.level++;break;case"block":d.expressions.length>0&&(d.tuple=!0,m=_e(d.expressions[d.expressions.length-1],m));break;case"path":d.tuple=!0;var z=d.steps.length-1;for(m=_e(d.steps[z--],m);m.level>0&&z>=0;)m=_e(d.steps[z--],m);break;default:throw{code:"S0217",token:d.type,position:d.position}}return m},fe=function(d,m){if(typeof m.seekingParent<"u"||m.type==="parent"){var z=typeof m.seekingParent<"u"?m.seekingParent:[];m.type==="parent"&&z.push(m.slot),typeof d.seekingParent>"u"?d.seekingParent=z:Array.prototype.push.apply(d.seekingParent,z)}},at=function(d){var m=d.steps.length-1,z=d.steps[m],de=typeof z.seekingParent<"u"?z.seekingParent:[];z.type==="parent"&&de.push(z.slot);for(var Ce=0;Ce<de.length;Ce++){var Ee=de[Ce];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 w=d.steps[m--];m>=0&&w.focus&&d.steps[m].focus;)w=d.steps[m--];Ee=_e(w,Ee)}}},ie=function(d){var m;switch(d.type){case"binary":switch(d.value){case".":var z=ie(d.lhs);z.type==="path"?m=z:m={type:"path",steps:[z]},z.type==="parent"&&(m.seekingParent=[z.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 Ce=m.steps[0];Ce.type==="unary"&&Ce.value==="["&&(Ce.consarray=!0);var Ee=m.steps[m.steps.length-1];Ee.type==="unary"&&Ee.value==="["&&(Ee.consarray=!0),at(m);break;case"[":m=ie(d.lhs);var w=m,S="predicate";if(m.type==="path"&&(w=m.steps[m.steps.length-1],S="stages"),typeof w.group<"u")throw{code:"S0209",stack:new Error().stack,position:d.position};typeof w[S]>"u"&&(w[S]=[]);var x=ie(d.rhs);typeof x.seekingParent<"u"&&(x.seekingParent.forEach(F=>{F.level===1?_e(w,F):F.level--}),fe(w,x)),w[S].push({type:"filter",expr:x,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 N={type:"sort",position:d.position};N.terms=d.rhs.map(function(F){var J=ie(F.expression);return fe(N,J),{descending:F.descending,expression:J}}),m.steps.push(N),at(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),w=m,m.type==="path"&&(w=m.steps[m.steps.length-1]),typeof w.stages<"u"||typeof w.predicate<"u")throw{code:"S0215",stack:new Error().stack,position:d.position};if(w.type==="sort")throw{code:"S0216",stack:new Error().stack,position:d.position};d.keepArray&&(w.keepArray=!0),w.focus=d.rhs.value,w.tuple=!0;break;case"#":m=ie(d.lhs),w=m,m.type==="path"?w=m.steps[m.steps.length-1]:(m={type:"path",steps:[m]},typeof w.predicate<"u"&&(w.stages=w.predicate,delete w.predicate)),typeof w.stages>"u"?w.index=d.rhs.value:w.stages.push({type:"index",value:d.rhs.value,position:d.position}),w.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 ye=ie(F[1]);return fe(m,ye),[J,ye]}):(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=Te(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:Me++}},nt.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 P={code:j,position:d.position,token:d.value};if(_)return Q.push(P),{type:"error",error:P};throw P.stack=new Error().stack,P}return d.keepArray&&(m.keepArray=!0),m};I=k(D),U();var Be=A(0);if(T.id!=="(end)"){var ct={code:"S0201",position:T.position,token:T.value};se(ct)}if(Be=ie(Be),Be.type==="parent"||typeof Be.seekingParent<"u")throw{code:"S0217",token:Be.type,position:Be.position};return Q.length>0&&(Be.errors=Q),Be};return O})();a.exports=o},{"./signature":5}],5:[function(r,a,n){var i=r("./utils");const o=(()=>{var u={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function v(k){for(var O=1,D=[],_={},T=_;O<k.length;){var I=k.charAt(O);if(I===":")break;var ae=function(){D.push(_),T=_,_={}},Q=function(W,he,xe,Ae){for(var Te=1,ve=he;ve<W.length;)if(ve++,I=W.charAt(ve),I===Ae){if(Te--,Te===0)break}else I===xe&&Te++;return ve};switch(I){case"s":case"n":case"b":case"l":case"o":_.regex="["+I+"m]",_.type=I,ae();break;case"a":_.regex="[asnblfom]",_.type=I,_.array=!0,ae();break;case"f":_.regex="f",_.type=I,ae();break;case"j":_.regex="[asnblom]",_.type=I,ae();break;case"x":_.regex="[asnblfom]",_.type=I,ae();break;case"-":T.context=!0,T.contextRegex=new RegExp(T.regex),T.regex+="?";break;case"?":case"+":T.regex+=I;break;case"(":var pe=Q(k,O,"(",")"),q=k.substring(O+1,pe);if(q.indexOf("<")===-1)_.regex="["+q+"m]";else throw{code:"S0402",stack:new Error().stack,value:q,offset:O};_.type="("+q+")",O=pe,ae();break;case"<":if(T.type==="a"||T.type==="f"){var R=Q(k,O,"<",">");T.subtype=k.substring(O+1,R),O=R}else throw{code:"S0401",stack:new Error().stack,value:T.type,offset:O};break}O++}var se="^"+D.map(function(W){return"("+W.regex+")"}).join("")+"$",U=new RegExp(se),A=function(W){var he;if(i.isFunction(W))he="f";else{var xe=typeof W;switch(xe){case"string":he="s";break;case"number":he="n";break;case"boolean":he="b";break;case"object":W===null?he="l":Array.isArray(W)?he="a":he="o";break;case"undefined":default:he="m"}}return he},$=function(W,he){for(var xe="^",Ae=0,Te=0;Te<D.length;Te++){xe+=D[Te].regex;var ve=he.match(xe);if(ve===null)throw{code:"T0410",stack:new Error().stack,value:W[Ae],index:Ae+1};Ae=ve[0].length}throw{code:"T0410",stack:new Error().stack,value:W[Ae],index:Ae+1}};return{definition:k,validate:function(W,he){var xe="";W.forEach(function(Me){xe+=A(Me)});var Ae=U.exec(xe);if(Ae){var Te=[],ve=0;return D.forEach(function(Me,nt){var _e=W[ve],fe=Ae[nt+1];if(fe==="")if(Me.context&&Me.contextRegex){var at=A(he);if(Me.contextRegex.test(at))Te.push(he);else throw{code:"T0411",stack:new Error().stack,value:he,index:ve+1}}else Te.push(_e),ve++;else fe.split("").forEach(function(ie){if(Me.type==="a"){if(ie==="m")_e=void 0;else{_e=W[ve];var Be=!0;if(typeof Me.subtype<"u"){if(ie!=="a"&&fe!==Me.subtype)Be=!1;else if(ie==="a"&&_e.length>0){var ct=A(_e[0]);if(ct!==Me.subtype.charAt(0))Be=!1;else{var d=_e.filter(function(m){return A(m)!==ct});Be=d.length===0}}}if(!Be)throw{code:"T0412",stack:new Error().stack,value:_e,index:ve+1,type:u[Me.subtype]};ie!=="a"&&(_e=[_e])}Te.push(_e),ve++}else Te.push(_e),ve++})}),Te}$(W,xe)}}}return v})();a.exports=o},{"./utils":6}],6:[function(r,a,n){const i=(()=>{function o(R){var se=!1;if(typeof R=="number"&&(se=!isNaN(R),se&&!isFinite(R)))throw{code:"D1001",value:R,stack:new Error().stack};return se}function u(R){var se=!1;return Array.isArray(R)&&(se=R.filter(function(U){return typeof U!="string"}).length===0),se}function v(R){var se=!1;return Array.isArray(R)&&(se=R.filter(function(U){return!o(U)}).length===0),se}function k(){var R=[];return R.sequence=!0,arguments.length===1&&R.push(arguments[0]),R}function O(R){return R.sequence===!0&&Array.isArray(R)}function D(R){return R&&(R._jsonata_function===!0||R._jsonata_lambda===!0)||typeof R=="function"}function _(R){var se=typeof R.arity=="number"?R.arity:typeof R.implementation=="function"?R.implementation.length:typeof R.length=="number"?R.length:R.arguments.length;return se}function T(R){return R&&R._jsonata_lambda===!0}var I=(typeof Symbol=="function"?Symbol:{}).iterator||"@@iterator";function ae(R){return typeof R=="object"&&R!==null&&I in R&&"next"in R&&typeof R.next=="function"}function Q(R,se){if(R===se)return!0;if(typeof R=="object"&&typeof se=="object"&&R!==null&&se!==null){if(Array.isArray(R)&&Array.isArray(se)){if(R.length!==se.length)return!1;for(var U=0;U<R.length;U++)if(!Q(R[U],se[U]))return!1;return!0}var A=Object.getOwnPropertyNames(R),$=Object.getOwnPropertyNames(se);if(A.length!==$.length)return!1;for(A=A.sort(),$=$.sort(),U=0;U<A.length;U++)if(A[U]!==$[U])return!1;for(U=0;U<A.length;U++){var W=A[U];if(!Q(R[W],se[W]))return!1}return!0}return!1}function pe(R){return typeof R=="object"&&R!==null&&"then"in R&&typeof R.then=="function"}function q(R){var se=[];for(let U of R)se.push(U);return se}return{isNumeric:o,isArrayOfStrings:u,isArrayOfNumbers:v,createSequence:k,isSequence:O,isFunction:D,isLambda:T,isIterable:ae,getFunctionArity:_,isDeepEqual:Q,stringToArray:q,isPromise:pe}})();a.exports=i},{}]},{},[3])(3)})})(Mr)),Mr.exports}var oi=ii();const ci=si(oi),on=b.object({name:b.literal("transform-data"),sourceData:b.any().optional(),expression:b.string().min(1,"JSONata expression is required")});function li(t){return on.parse(t)}async function ui(t){try{const{sourceData:e,expression:r}=t,a=e??{};let n;try{n=ci(r)}catch(o){throw new Error(`Invalid JSONata expression: ${o instanceof Error?o.message:"Unknown error"}`)}let i;try{i=await n.evaluate(a)}catch(o){throw console.error("JSONata evaluation failed:",o),new Error(`JSONata evaluation failed: ${o instanceof Error?o.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 cn=b.object({name:b.literal("export-data"),data:b.any(),format:b.enum(["json","csv","xlsx"]),filename:b.string().optional(),csvOptions:b.object({delimiter:b.string().optional(),includeHeaders:b.boolean().optional()}).optional()});function fi(t){return cn.parse(t)}async function di(t){try{const{data:e,format:r,filename:a,csvOptions:n}=t;console.log("[ExportDataBlock] Sending export request to background:",r);const i=await chrome.runtime.sendMessage({type:"EXPORT_DATA",data:{data:e,format:r,filename:a,csvOptions:n}});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 ln=b.object({name:b.literal("network-catch"),urlPattern:b.string().optional(),method:b.enum(["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"]).optional(),status:b.union([b.number(),b.object({min:b.number().optional(),max:b.number().optional()})]).optional(),mimeType:b.string().optional(),requestBodyPattern:b.union([b.string(),b.record(b.any())]).optional(),waitForRequest:b.boolean().optional(),waitTimeout:b.number().min(0).optional(),returnAll:b.boolean().optional(),includeHeaders:b.boolean().optional()});function hi(t){return ln.parse(t)}async function pi(t){try{console.log("[NetworkCatchBlock] Fetching network requests with pattern:",t.urlPattern);const e=await chrome.runtime.sendMessage({type:"NETWORK_CATCH",data:{urlPattern:t.urlPattern,method:t.method,status:t.status,mimeType:t.mimeType,requestBodyPattern:t.requestBodyPattern,waitForRequest:t.waitForRequest||!1,waitTimeout:t.waitTimeout||5e3,returnAll:t.returnAll||!1,includeHeaders:t.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 un=tt.extend({name:b.literal("mark-border"),borderStyle:b.object({color:b.string().optional(),width:b.number().optional(),style:b.enum(["solid","dashed","dotted","double"]).optional(),animated:b.boolean().optional()}).optional(),textFilter:b.object({text:b.union([b.string(),b.array(b.string())]),mode:b.enum(["exact","contains","startsWith","endsWith","regex"])}).optional()});function mi(t){return un.parse(t)}async function gi(t){try{const{selector:e="",findBy:r="cssSelector",option:a,borderStyle:n,textFilter:i}=t;if(!e)throw new Error("Selector is required for mark-border block");const o=await rt({selector:e,findBy:r,option:a});if(!o)throw new Error("Element not found for marking border");let u;if(Array.isArray(o))if(i){const _=yi(o,i.text,i.mode);if(!_){const T=Array.isArray(i.text)?i.text.join(", "):i.text;throw new Error(`No element found with text filter: "${T}" (mode: ${i.mode})`)}u=[_]}else u=o;else u=[o];const v=(n==null?void 0:n.color)||"#9b59b6",k=(n==null?void 0:n.width)||3,O=(n==null?void 0:n.style)||"solid",D=(n==null?void 0:n.animated)!==!1;for(const _ of u)bi(_,v,k,O,D);return{data:!0}}catch(e){return console.log(e),{hasError:!0,message:e instanceof Error?e.message:"Unknown error in mark-border handler",data:!1}}}function yi(t,e,r){for(const a of t){const n=vi(a),i=Array.isArray(e)?e:[e];for(const o of i){let u=!1;switch(r){case"exact":u=n===o;break;case"contains":u=n.includes(o);break;case"startsWith":u=n.startsWith(o);break;case"endsWith":u=n.endsWith(o);break;case"regex":try{u=new RegExp(o).test(n)}catch{console.warn("Invalid regex pattern:",o);continue}break}if(u)return a}}return null}function vi(t){if(t.innerText)return t.innerText.trim();if(t.textContent)return t.textContent.trim();if(t instanceof HTMLInputElement&&t.value)return t.value.trim();const e=t.getAttribute("placeholder");if(e)return e.trim();const r=t.getAttribute("title");if(r)return r.trim();const a=t.getAttribute("aria-label");return a?a.trim():""}function bi(t,e,r,a,n=!0){t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});const i=t.style.border,o=t.style.outline,u=t.style.zIndex,v=t.style.position,k=t.style.animation;if(n&&!document.getElementById("mark-border-animation-style")){const O=document.createElement("style");O.id="mark-border-animation-style",O.textContent=`
5
5
  @keyframes mark-border-blink {
6
6
  0%, 100% {
7
7
  border-color: ${e};
@@ -13,4 +13,4 @@
13
13
  [data-mark-border-animated="true"] {
14
14
  animation: mark-border-blink 1s ease-in-out infinite;
15
15
  }
16
- `,document.head.appendChild(C)}t.style.border=`${r}px ${a} ${e}`,t.style.outline="none",t.style.zIndex=u||"999999",(!v||v==="static")&&(t.style.position="relative"),n&&t.setAttribute("data-mark-border-animated","true"),t.setAttribute("data-mark-border-original-border",i),t.setAttribute("data-mark-border-original-outline",o),t.setAttribute("data-mark-border-original-z-index",u),t.setAttribute("data-mark-border-original-position",v),t.setAttribute("data-mark-border-original-animation",k),t.setAttribute("data-mark-border-applied","true")}function wi(){if(typeof document<"u"&&document.documentElement){const t=document.documentElement.getAttribute("lang");if(t)return En(t)}return typeof navigator<"u"&&navigator.language?En(navigator.language):"en"}function En(t){if(!t)return"en";const r=t.toLowerCase().split("-")[0];return["ko","en"].includes(r)?r:"en"}const ki={"slack.roles.workspace_primary_owner":"Workspace Primary Owner","slack.roles.workspace_owners":"Workspace Owners","slack.roles.workspace_admins":"Workspace Admins","slack.roles.full_members":"Full members","slack.roles.multi_channel_guests":"Multi-Channel Guests","slack.roles.single_channel_guests":"Single-Channel Guests","slack.roles.channel_managers":"Channel Managers","slack.roles.invited_members":"Invited members","slack.roles.org_primary_owner":"Org Primary Owner","slack.roles.org_owners":"Org Owners","slack.roles.org_admins":"Org Admins","slack.roles.analytics_admin":"Analytics Admin","slack.roles.audit_logs_admin":"Audit Logs Admin","slack.roles.channels_admin":"Channels Admin","slack.roles.content_admin":"Content Admin","slack.roles.customization_manager":"Customization Manager","slack.roles.dlp_admin":"DLP Admin","slack.roles.export_admin":"Export Admin","slack.roles.integrations_admin":"Integrations Admin","slack.roles.legal_holds_admin":"Legal Holds Admin","slack.roles.message_activity_manager":"Message Activity Manager","slack.roles.roles_admin":"Roles Admin","slack.roles.sales_admin":"Sales Admin","slack.roles.salesforce_admin":"Salesforce Admin","slack.roles.security_admin":"Security Admin","slack.roles.template_admin":"Template Admin","slack.roles.users_admin":"Users Admin","slack.roles.workflow_admin":"Workflow Admin"},_i={"slack.roles.workspace_primary_owner":"워크스페이스 주 소유자","slack.roles.workspace_owners":"워크스페이스 소유자","slack.roles.workspace_admins":"워크스페이스 관리자","slack.roles.full_members":"전체 멤버","slack.roles.multi_channel_guests":"멀티 채널 게스트","slack.roles.single_channel_guests":"단일 채널 게스트","slack.roles.channel_managers":"채널 매니저","slack.roles.invited_members":"초대된 멤버","slack.roles.org_primary_owner":"조직 주 소유자","slack.roles.org_owners":"조직 소유자","slack.roles.org_admins":"조직 관리자","slack.roles.analytics_admin":"분석 관리자","slack.roles.audit_logs_admin":"감사 로그 관리자","slack.roles.channels_admin":"채널 관리자","slack.roles.content_admin":"콘텐츠 관리자","slack.roles.customization_manager":"사용자 맞춤 관리자","slack.roles.dlp_admin":"DLP 관리자","slack.roles.export_admin":"내보내기 관리자","slack.roles.integrations_admin":"통합 관리자","slack.roles.legal_holds_admin":"법적 자료 관리자","slack.roles.message_activity_manager":"메시지 활동 관리자","slack.roles.roles_admin":"역할 관리자","slack.roles.sales_admin":"영업 관리자","slack.roles.salesforce_admin":"Salesforce 관리자","slack.roles.security_admin":"보안 관리자","slack.roles.template_admin":"템플릿 관리자","slack.roles.users_admin":"사용자 관리자","slack.roles.workflow_admin":"워크플로 관리자"},An={en:ki,ko:_i};function xi(t){const e=Ai(t);return An[e]||An.en}function Ei(t,e){return xi(e)[t]}function Ai(t){if(!t)return"en";const r=t.toLowerCase().split("-")[0];return["ko","en"].includes(r)?r:"en"}function Tn(t,e,r){if(!t||typeof t!="string")return t;const a=`${e}.`;let n;t.startsWith(a)?n=t:n=`${e}.${t}`;const i=Ei(n,r);return i!==void 0?i:t}function Sn(t,e,r){const a={...t};for(const[n,i]of Object.entries(e))if(n in a&&a[n]!==null&&a[n]!==void 0){const o=a[n];typeof o=="string"?a[n]=Tn(o,i.translationKey,r):Array.isArray(o)&&(a[n]=o.map(u=>typeof u=="string"?Tn(u,i.translationKey,r):u))}return a}const Ti=b.union([b.string(),b.object({translationKey:b.string()})]),fn=b.object({name:b.literal("apply-locale"),sourceData:b.any().optional(),locale:b.string().optional(),mappings:b.record(b.string(),Ti)});function Si(t){return fn.parse(t)}async function Di(t){try{const{sourceData:e,locale:r,mappings:a}=t,n=e??{},i=r||wi(),o={};for(const[u,v]of Object.entries(a))typeof v=="string"?o[u]={translationKey:v}:o[u]=v;if(Array.isArray(n))return{data:n.map(v=>typeof v=="object"&&v!==null&&!Array.isArray(v)?Sn(v,o,i):v)};if(typeof n=="object"&&n!==null&&!Array.isArray(n))return{data:Sn(n,o,i)};throw new Error("sourceData must be an object or an array of objects")}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in apply-locale handler",data:null}}}const dn=tt.extend({name:b.literal("paste-value"),value:b.string()});function Oi(t){return dn.parse(t)}async function Ci(t){try{const{selector:e="",value:r,findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for paste-value block");if(r==null)throw new Error("Value is required for paste-value block");const n=await rt({selector:e,findBy:a,option:t.option});if(!n)throw new Error("Element not found for pasting value");const i=Array.isArray(n)?n[0]:n;if(!i)throw new Error("Target element not found");return await Pi(i,r),{data:!0}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in paste-value handler",data:!1}}}async function Pi(t,e){if(t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(r=>setTimeout(r,50)),t.focus&&t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){t.select();const r=t.selectionStart||0,a=t.selectionEnd||0,n=t.value,i=n.substring(0,r)+e+n.substring(a);t.value=i;const o=r+e.length;t.setSelectionRange(o,o);const u=new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});u.clipboardData&&u.clipboardData.setData("text/plain",e),t.dispatchEvent(u),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}else if(t.isContentEditable){const r=window.getSelection();if(r&&r.rangeCount>0){const n=r.getRangeAt(0);n.deleteContents(),n.insertNode(document.createTextNode(e)),n.collapse(!1),r.removeAllRanges(),r.addRange(n)}else t.textContent=e;const a=new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});a.clipboardData&&a.clipboardData.setData("text/plain",e),t.dispatchEvent(a),t.dispatchEvent(new Event("input",{bubbles:!0}))}else console.log("element is other",t),"value"in t&&typeof t.value=="string"?(t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))):(t.textContent=e,t.dispatchEvent(new Event("input",{bubbles:!0})));await new Promise(r=>setTimeout(r,50))}const Ni={"get-text":Vr,"attribute-value":zr,"get-value-form":Hr,"set-value-form":qr,"set-contenteditable":Yr,"clear-value-form":Gr,"element-exists":Kr,"event-click":Jr,keypress:Xr,wait:Qr,"wait-for-condition":en,navigate:tn,"save-assets":rn,"get-element-data":nn,scroll:an,"ai-parse-data":Wr,"fetch-api":sn,"transform-data":on,"export-data":cn,"network-catch":ln,"mark-border":un,"apply-locale":fn,"paste-value":dn};class Ri{static async executeBlock(e){try{switch(e.name){case"get-text":{const r=fs(e);return await ds(r)}case"attribute-value":{const r=ps(e);return await ms(r)}case"get-value-form":{const r=gs(e);return await ys(r)}case"set-value-form":{const r=bs(e);return await ws(r)}case"set-contenteditable":{const r=As(e);return await Ts(r)}case"clear-value-form":{const r=_s(e);return await xs(r)}case"element-exists":{const r=Os(e);return await Cs(r)}case"event-click":{const r=Ps(e);return await Ns(r)}case"keypress":{const r=js(e);return await Fs(r)}case"wait":{const r=Ls(e);return await $s(r)}case"wait-for-condition":{const r=Us(e);return await Zs(r)}case"navigate":{const r=Ws(e);return await Vs(r)}case"save-assets":{const r=zs(e);return await Hs(r)}case"get-element-data":{const r=Gs(e);return await Ys(r)}case"scroll":{const r=Js(e);return await Xs(r)}case"ai-parse-data":{const r=es(e);return await ts(r)}case"fetch-api":{const r=ni(e);return await ai(r)}case"transform-data":{const r=li(e);return await ui(r)}case"export-data":{const r=fi(e);return await di(r)}case"network-catch":{const r=hi(e);return await pi(r)}case"mark-border":{const r=mi(e);return await gi(r)}case"apply-locale":{const r=Si(e);return await Di(r)}case"paste-value":{const r=Oi(e);return await Ci(r)}default:return{hasError:!0,message:`Unknown block type: ${e.name}`,data:null}}}catch(r){return{hasError:!0,message:r instanceof Error?r.message:"Unknown error in block execution",data:null}}}}class Mi{constructor(){le(this,"expr");le(this,"json")}}class Ii{constructor(){le(this,"template");le(this,"valueFrom");le(this,"default")}}class ji{constructor(){le(this,"id");le(this,"title");le(this,"when");le(this,"block");le(this,"repeat");le(this,"next");le(this,"onSuccess");le(this,"onFailure");le(this,"switch");le(this,"timeoutMs");le(this,"retry");le(this,"delayAfterMs")}}class Fi{constructor(){le(this,"version");le(this,"id");le(this,"title");le(this,"description");le(this,"start");le(this,"steps");le(this,"vars");le(this,"defaultDelayMs")}}class Bi{constructor(){le(this,"stepId");le(this,"skipped");le(this,"success");le(this,"message");le(this,"result");le(this,"startedAt");le(this,"finishedAt");le(this,"attempts")}}class Li{constructor(){le(this,"success");le(this,"steps");le(this,"context");le(this,"targetUrl");le(this,"timestamp");le(this,"error")}}var Pr=(t=>(t.USD="USD",t.KRW="KRW",t.EUR="EUR",t.GBP="GBP",t.CAD="CAD",t.CNY="CNY",t.JPY="JPY",t.VND="VND",t.ARS="ARS",t.INR="INR",t.TWD="TWD",t.AUD="AUD",t.HKD="HKD",t.IDR="IDR",t.MXN="MXN",t.NZD="NZD",t.SGD="SGD",t.CHF="CHF",t.THB="THB",t.BRL="BRL",t.TRY="TRY",t.RUB="RUB",t.NOK="NOK",t.DKK="DKK",t.SEK="SEK",t.ILS="ILS",t.ZAR="ZAR",t.PLN="PLN",t.PHP="PHP",t.CZK="CZK",t.CLP="CLP",t.COP="COP",t.EGP="EGP",t.MYR="MYR",t.HUF="HUF",t.AED="AED",t.SAR="SAR",t.RON="RON",t.BGN="BGN",t))(Pr||{});const In={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 Je extends Error{constructor(e,r,a){super(e),this.code=r,this.details=a,this.name="EightGError"}static extensionNotInstalled(){return new Je("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new Je(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new Je(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(e=6e5){const r=Math.floor(e/1e3);return new Je(`Request timeout - Extension did not respond within ${r} seconds`,"REQUEST_TIMEOUT")}}function $i(t){return t&&t.type==="8G_EXTENSION_RESPONSE"}const jn=At({id:Ce(),slug:Ce(),name:Ce(),image:Ce(),memberCount:$t(),isAdmin:Rt().nullable().optional()}),Fn=At({slug:Ce(),displayName:Ce(),profileImageUrl:Ce(),description:Ce(),publicEmail:Ce(),billingEmail:Ce(),orgPageUrl:Ce()});var hn=(t=>(t.monthly="MONTHLY",t.yearly="YEARLY",t))(hn||{});const Lr=At({code:Zr(Pr),symbol:Ce(),format:Ce(),amount:$t(),text:Ce().optional()}),Bn=At({planName:Ce(),currentCycleBillAmount:Lr,nextPaymentDue:Ce(),cycleTerm:Zr(hn).nullable(),isFreeTier:Rt(),isPerUser:Rt(),paidMemberCount:$t(),usedMemberCount:$t(),unitPrice:Lr.nullable(),cardNumber:Ce(),cardName:Ce()}),Ln=At({uid:Ce(),issuedDate:pr.date(),paidDate:pr.date().nullable().optional(),paymentMethod:Ce(),amount:Lr,isSuccessfulPaid:Rt(),receiptUrl:Ce()}),$n=At({name:Ce(),email:Ce().email(),profileImageUrl:Ce(),role:Ce(),subscriptionSeatStatus:Ur(["NONE","FREE","PAID","QUIT"]).nullable().optional(),startedAt:pr.date().nullable().optional(),deletedAt:pr.date().nullable().optional()});class Ui{constructor(){}async checkExtension(){return new Promise((e,r)=>{const a=setTimeout(()=>{r(Je.extensionNotInstalled())},5e3),n=i=>{$i(i.data)&&(clearTimeout(a),window.removeEventListener("message",n),e(i.data))};window.addEventListener("message",n),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((r,a)=>{const n=`8g_wf_${Date.now()}_${Math.random()}`,i=e.timeoutMs??6e5,o=setTimeout(()=>{a(Je.requestTimeout(i))},i),u=v=>{var k,C,D,x,T,I,ae;if(((k=v.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&v.data.requestId===n){clearTimeout(o),window.removeEventListener("message",u);const Q=v.data,pe=((C=Q==null?void 0:Q.result)==null?void 0:C.steps)??((x=(D=Q==null?void 0:Q.result)==null?void 0:D.result)==null?void 0:x.steps)??[],q=((T=Q==null?void 0:Q.result)==null?void 0:T.context)??((ae=(I=Q==null?void 0:Q.result)==null?void 0:I.result)==null?void 0:ae.context)??{steps:{},vars:{}};r({success:Q.success,steps:pe,context:q,error:Q.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",u),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:n,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}async getWorkspaces(e){var i,o;const r=await this.collectWorkflow(e);if(!r.success)throw new Je("Failed to get workspaces","GET_WORKSPACES_FAILED");const a=(o=(i=r.steps[r.steps.length-1])==null?void 0:i.result)==null?void 0:o.data;if(!a||!Array.isArray(a))return{...r,data:[],isSuccess:!1};const n=[];for(const u of a){const v=jn.safeParse(u);v.success?n.push(v.data):console.warn("Invalid workspace data:",u,v.error)}return{...r,data:n,isSuccess:!0}}async getWorkspaceDetail(e,r,a){var u,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const n=await this.collectWorkflow(a);if(!n.success)throw new Je("Failed to get workspaces","GET_WORKSPACES_FAILED");const i=(v=(u=n.steps[n.steps.length-1])==null?void 0:u.result)==null?void 0:v.data;if(!i)return{...n};const o=Fn.safeParse(i);if(o.success){const k=o.data;return{...n,data:k}}else return console.warn("Invalid workspace detail data:",i,o.error),{...n,data:void 0}}async getWorkspaceBilling(e,r,a){var u,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const n=await this.collectWorkflow(a);if(!n.success)throw new Je("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const i=(v=(u=n.steps[n.steps.length-1])==null?void 0:u.result)==null?void 0:v.data;if(!i)return{...n};const o=Bn.safeParse(i);if(o.success){const k=o.data;return{...n,data:k}}else return console.warn("Invalid workspace billing data:",i,o.error),{...n,data:void 0}}async getWorkspaceBillingHistories(e,r,a){var u,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const n=await this.collectWorkflow(a);if(!n.success)throw new Je("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const i=(v=(u=n.steps[n.steps.length-1])==null?void 0:u.result)==null?void 0:v.data;if(!i||!Array.isArray(i))return{...n,data:[]};const o=[];for(const k of i){const C=Ln.safeParse(k);C.success?o.push(C.data):console.warn("Invalid workspace billing history data:",k,C.error)}return{...n,data:o}}async getWorkspaceMembers(e,r,a){var u,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const n=await this.collectWorkflow(a);if(!n.success)throw new Je("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const i=(v=(u=n.steps[n.steps.length-1])==null?void 0:u.result)==null?void 0:v.data;if(!i||!Array.isArray(i))return{...n,data:[]};const o=[];for(const k of i){const C=$n.safeParse(k);C.success?o.push(C.data):console.warn("Invalid workspace member data:",k,C.error)}return{...n,data:o}}async addMembers(e,r,a,n){n.workflow.vars={...n.workflow.vars,workspaceKey:e,slug:r,emails:a};const i=await this.collectWorkflow(n);if(!i.success)throw new Je("Failed to add sheets","ADD_SHEETS_FAILED");return{...i}}async deleteMembers(e,r,a,n){n.workflow.vars={...n.workflow.vars,workspaceKey:e,slug:r,emails:a};const i=await this.collectWorkflow(n);if(!i.success)throw new Je("Failed to delete members","DELETE_MEMBERS_FAILED");return{...i}}static getFromContext(e,r){const a=r.split(".");let n=e;for(const i of a){if(n==null)return;n=n[i]}return n}static getStepResult(e,r){return e.steps[r]}static getStepData(e,r){var a,n;return(n=(a=e.steps[r])==null?void 0:a.result)==null?void 0:n.data}static getVar(e,r){return e.vars[r]}}exports.AiParseDataBlockSchema=Wr;exports.AllBlockSchemas=Ni;exports.ApplyLocaleBlockSchema=fn;exports.BaseBlockSchema=tt;exports.BillingCycleTerm=hn;exports.Binding=Ii;exports.BlockHandler=Ri;exports.ClearValueFormsBlockSchema=Gr;exports.CollectWorkflowResult=Li;exports.Condition=Mi;exports.CurrencyCode=Pr;exports.CurrencyInfoSchema=In;exports.EightGClient=Ui;exports.EightGError=Je;exports.ElementExistsBlockSchema=Kr;exports.EventClickBlockSchema=Jr;exports.ExportDataBlockSchema=cn;exports.FetchApiBlockSchema=sn;exports.GetAttributeValueBlockSchema=zr;exports.GetElementDataBlockSchema=nn;exports.GetTextBlockSchema=Vr;exports.GetValueFormsBlockSchema=Hr;exports.KeypressBlockSchema=Xr;exports.MarkBorderBlockSchema=un;exports.NavigateBlockSchema=tn;exports.NetworkCatchBlockSchema=ln;exports.PasteValueBlockSchema=dn;exports.SaveAssetsBlockSchema=rn;exports.Schema=as;exports.ScrollBlockSchema=an;exports.SetContentEditableBlockSchema=Yr;exports.SetValueFormsBlockSchema=qr;exports.TransformDataBlockSchema=on;exports.WaitBlockSchema=Qr;exports.WaitForConditionBlockSchema=en;exports.Workflow=Fi;exports.WorkflowStep=ji;exports.WorkflowStepRunResult=Bi;exports.WorkspaceBillingHistorySchema=Ln;exports.WorkspaceBillingSchema=Bn;exports.WorkspaceDetailItemSchema=Fn;exports.WorkspaceItemSchema=jn;exports.WorkspaceMemberSchema=$n;exports.createArraySchema=ns;exports.createSchema=rs;
16
+ `,document.head.appendChild(O)}t.style.border=`${r}px ${a} ${e}`,t.style.outline="none",t.style.zIndex=u||"999999",(!v||v==="static")&&(t.style.position="relative"),n&&t.setAttribute("data-mark-border-animated","true"),t.setAttribute("data-mark-border-original-border",i),t.setAttribute("data-mark-border-original-outline",o),t.setAttribute("data-mark-border-original-z-index",u),t.setAttribute("data-mark-border-original-position",v),t.setAttribute("data-mark-border-original-animation",k),t.setAttribute("data-mark-border-applied","true")}function wi(){if(typeof document<"u"&&document.documentElement){const t=document.documentElement.getAttribute("lang");if(t)return En(t)}return typeof navigator<"u"&&navigator.language?En(navigator.language):"en"}function En(t){if(!t)return"en";const r=t.toLowerCase().split("-")[0];return["ko","en"].includes(r)?r:"en"}const ki={"slack.roles.workspace_primary_owner":"Workspace Primary Owner","slack.roles.workspace_owners":"Workspace Owners","slack.roles.workspace_admins":"Workspace Admins","slack.roles.full_members":"Full members","slack.roles.multi_channel_guests":"Multi-Channel Guests","slack.roles.single_channel_guests":"Single-Channel Guests","slack.roles.channel_managers":"Channel Managers","slack.roles.invited_members":"Invited members","slack.roles.org_primary_owner":"Org Primary Owner","slack.roles.org_owners":"Org Owners","slack.roles.org_admins":"Org Admins","slack.roles.analytics_admin":"Analytics Admin","slack.roles.audit_logs_admin":"Audit Logs Admin","slack.roles.channels_admin":"Channels Admin","slack.roles.content_admin":"Content Admin","slack.roles.customization_manager":"Customization Manager","slack.roles.dlp_admin":"DLP Admin","slack.roles.export_admin":"Export Admin","slack.roles.integrations_admin":"Integrations Admin","slack.roles.legal_holds_admin":"Legal Holds Admin","slack.roles.message_activity_manager":"Message Activity Manager","slack.roles.roles_admin":"Roles Admin","slack.roles.sales_admin":"Sales Admin","slack.roles.salesforce_admin":"Salesforce Admin","slack.roles.security_admin":"Security Admin","slack.roles.template_admin":"Template Admin","slack.roles.users_admin":"Users Admin","slack.roles.workflow_admin":"Workflow Admin"},xi={"slack.roles.workspace_primary_owner":"워크스페이스 주 소유자","slack.roles.workspace_owners":"워크스페이스 소유자","slack.roles.workspace_admins":"워크스페이스 관리자","slack.roles.full_members":"전체 멤버","slack.roles.multi_channel_guests":"멀티 채널 게스트","slack.roles.single_channel_guests":"단일 채널 게스트","slack.roles.channel_managers":"채널 매니저","slack.roles.invited_members":"초대된 멤버","slack.roles.org_primary_owner":"조직 주 소유자","slack.roles.org_owners":"조직 소유자","slack.roles.org_admins":"조직 관리자","slack.roles.analytics_admin":"분석 관리자","slack.roles.audit_logs_admin":"감사 로그 관리자","slack.roles.channels_admin":"채널 관리자","slack.roles.content_admin":"콘텐츠 관리자","slack.roles.customization_manager":"사용자 맞춤 관리자","slack.roles.dlp_admin":"DLP 관리자","slack.roles.export_admin":"내보내기 관리자","slack.roles.integrations_admin":"통합 관리자","slack.roles.legal_holds_admin":"법적 자료 관리자","slack.roles.message_activity_manager":"메시지 활동 관리자","slack.roles.roles_admin":"역할 관리자","slack.roles.sales_admin":"영업 관리자","slack.roles.salesforce_admin":"Salesforce 관리자","slack.roles.security_admin":"보안 관리자","slack.roles.template_admin":"템플릿 관리자","slack.roles.users_admin":"사용자 관리자","slack.roles.workflow_admin":"워크플로 관리자"},An={en:ki,ko:xi};function _i(t){const e=Ai(t);return An[e]||An.en}function Ei(t,e){return _i(e)[t]}function Ai(t){if(!t)return"en";const r=t.toLowerCase().split("-")[0];return["ko","en"].includes(r)?r:"en"}function Tn(t,e,r){if(!t||typeof t!="string")return t;const a=`${e}.`;let n;t.startsWith(a)?n=t:n=`${e}.${t}`;const i=Ei(n,r);return i!==void 0?i:t}function Sn(t,e,r){const a={...t};for(const[n,i]of Object.entries(e))if(n in a&&a[n]!==null&&a[n]!==void 0){const o=a[n];typeof o=="string"?a[n]=Tn(o,i.translationKey,r):Array.isArray(o)&&(a[n]=o.map(u=>typeof u=="string"?Tn(u,i.translationKey,r):u))}return a}const Ti=b.union([b.string(),b.object({translationKey:b.string()})]),fn=b.object({name:b.literal("apply-locale"),sourceData:b.any().optional(),locale:b.string().optional(),mappings:b.record(b.string(),Ti)});function Si(t){return fn.parse(t)}async function Di(t){try{const{sourceData:e,locale:r,mappings:a}=t,n=e??{},i=r||wi(),o={};for(const[u,v]of Object.entries(a))typeof v=="string"?o[u]={translationKey:v}:o[u]=v;if(Array.isArray(n))return{data:n.map(v=>typeof v=="object"&&v!==null&&!Array.isArray(v)?Sn(v,o,i):v)};if(typeof n=="object"&&n!==null&&!Array.isArray(n))return{data:Sn(n,o,i)};throw new Error("sourceData must be an object or an array of objects")}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in apply-locale handler",data:null}}}const dn=tt.extend({name:b.literal("paste-value"),value:b.string()});function Pi(t){return dn.parse(t)}async function Oi(t){try{const{selector:e="",value:r,findBy:a="cssSelector"}=t;if(!e)throw new Error("Selector is required for paste-value block");if(r==null)throw new Error("Value is required for paste-value block");const n=await rt({selector:e,findBy:a,option:t.option});if(!n)throw new Error("Element not found for pasting value");const i=Array.isArray(n)?n[0]:n;if(!i)throw new Error("Target element not found");return await Ci(i,r),{data:!0}}catch(e){return{hasError:!0,message:e instanceof Error?e.message:"Unknown error in paste-value handler",data:!1}}}async function Ci(t,e){if(console.log("[PasteValue] === 시작 ==="),console.log("[PasteValue] 붙여넣을 값:",e),console.log("[PasteValue] 요소 타입:",t.constructor.name),console.log("[PasteValue] 요소:",t),console.log("[PasteValue] 1. 스크롤 시작"),t.scrollIntoView({behavior:"instant",block:"center",inline:"center"}),await new Promise(r=>setTimeout(r,50)),console.log("[PasteValue] 1. 스크롤 완료"),console.log("[PasteValue] 2. 포커스 설정"),t.focus&&t.focus(),console.log("[PasteValue] 2. 포커스 완료"),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){console.log("[PasteValue] 3. Input/Textarea 요소 처리 시작");const r=t.value;console.log("[PasteValue] 3-1. 기존 값:",r),console.log("[PasteValue] 3-1. 기존 값 길이:",r.length),t.select();const a=t.selectionStart||0,n=t.selectionEnd||0;console.log("[PasteValue] 3-2. 선택 범위: start=",a,"end=",n);const i=t.value,o=i.substring(0,a)+e+i.substring(n);console.log("[PasteValue] 3-3. 새 값 계산:",o),console.log("[PasteValue] 3-3. 새 값 길이:",o.length),console.log("[PasteValue] 3-4. 값 설정 전 - element.value:",t.value),t.value=o,console.log("[PasteValue] 3-4. 값 설정 후 - element.value:",t.value),console.log("[PasteValue] 3-4. 값 설정 후 - element.value 길이:",t.value.length);const u=a+e.length;t.setSelectionRange(u,u),console.log("[PasteValue] 3-5. 커서 위치 설정:",u),console.log("[PasteValue] 3-6. paste 이벤트 생성 시작");const v=new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});v.clipboardData&&(v.clipboardData.setData("text/plain",e),console.log("[PasteValue] 3-6. clipboardData 설정 완료:",v.clipboardData.getData("text/plain"))),console.log("[PasteValue] 3-7. paste 이벤트 발생 전 - element.value:",t.value);const k=t.dispatchEvent(v);console.log("[PasteValue] 3-7. paste 이벤트 발생 후 - dispatched:",k),console.log("[PasteValue] 3-7. paste 이벤트 발생 후 - element.value:",t.value),console.log("[PasteValue] 3-7. paste 이벤트 발생 후 - element.value 길이:",t.value.length)}else if(t.isContentEditable){console.log("[PasteValue] 3. ContentEditable 요소 처리 시작");const r=t.textContent||t.innerText;console.log("[PasteValue] 3-1. 기존 내용:",r);const a=window.getSelection();if(a&&a.rangeCount>0){console.log("[PasteValue] 3-2. 선택 범위가 있음");const i=a.getRangeAt(0);i.deleteContents(),i.insertNode(document.createTextNode(e)),i.collapse(!1),a.removeAllRanges(),a.addRange(i),console.log("[PasteValue] 3-2. 값 삽입 후 내용:",t.textContent||t.innerText)}else console.log("[PasteValue] 3-2. 선택 범위 없음, 전체 교체"),t.textContent=e,console.log("[PasteValue] 3-2. 값 설정 후 내용:",t.textContent);console.log("[PasteValue] 3-3. paste 이벤트 생성");const n=new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});n.clipboardData&&n.clipboardData.setData("text/plain",e),console.log("[PasteValue] 3-4. paste 이벤트 발생 전 내용:",t.textContent||t.innerText),t.dispatchEvent(n),console.log("[PasteValue] 3-4. paste 이벤트 발생 후 내용:",t.textContent||t.innerText)}else if(console.log("[PasteValue] 3. 일반 요소 처리 시작"),console.log("[PasteValue] 3-1. 요소:",t),"value"in t&&typeof t.value=="string"){const r=t.value;console.log("[PasteValue] 3-2. value 속성 있음, 기존 값:",r),t.value=e,console.log("[PasteValue] 3-2. 값 설정 후:",t.value)}else{const r=t.textContent;console.log("[PasteValue] 3-2. textContent 사용, 기존 내용:",r),t.textContent=e,console.log("[PasteValue] 3-2. 값 설정 후:",t.textContent)}console.log("[PasteValue] 4. 최종 대기 시작"),await new Promise(r=>setTimeout(r,50)),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?(console.log("[PasteValue] === 완료 === 최종 element.value:",t.value),console.log("[PasteValue] === 완료 === 최종 element.value 길이:",t.value.length)):t.isContentEditable?console.log("[PasteValue] === 완료 === 최종 내용:",t.textContent||t.innerText):"value"in t?console.log("[PasteValue] === 완료 === 최종 value:",t.value):console.log("[PasteValue] === 완료 === 최종 textContent:",t.textContent)}const Ni={"get-text":Wr,"attribute-value":zr,"get-value-form":Hr,"set-value-form":qr,"set-contenteditable":Yr,"clear-value-form":Gr,"element-exists":Kr,"event-click":Jr,keypress:Xr,wait:Qr,"wait-for-condition":en,navigate:tn,"save-assets":rn,"get-element-data":nn,scroll:an,"ai-parse-data":Zr,"fetch-api":sn,"transform-data":on,"export-data":cn,"network-catch":ln,"mark-border":un,"apply-locale":fn,"paste-value":dn};class Ri{static async executeBlock(e){try{switch(e.name){case"get-text":{const r=fs(e);return await ds(r)}case"attribute-value":{const r=ps(e);return await ms(r)}case"get-value-form":{const r=gs(e);return await ys(r)}case"set-value-form":{const r=bs(e);return await ws(r)}case"set-contenteditable":{const r=As(e);return await Ts(r)}case"clear-value-form":{const r=xs(e);return await _s(r)}case"element-exists":{const r=Ps(e);return await Os(r)}case"event-click":{const r=Cs(e);return await Ns(r)}case"keypress":{const r=js(e);return await Fs(r)}case"wait":{const r=Ls(e);return await $s(r)}case"wait-for-condition":{const r=Us(e);return await Vs(r)}case"navigate":{const r=Zs(e);return await Ws(r)}case"save-assets":{const r=zs(e);return await Hs(r)}case"get-element-data":{const r=Gs(e);return await Ys(r)}case"scroll":{const r=Js(e);return await Xs(r)}case"ai-parse-data":{const r=es(e);return await ts(r)}case"fetch-api":{const r=ni(e);return await ai(r)}case"transform-data":{const r=li(e);return await ui(r)}case"export-data":{const r=fi(e);return await di(r)}case"network-catch":{const r=hi(e);return await pi(r)}case"mark-border":{const r=mi(e);return await gi(r)}case"apply-locale":{const r=Si(e);return await Di(r)}case"paste-value":{const r=Pi(e);return await Oi(r)}default:return{hasError:!0,message:`Unknown block type: ${e.name}`,data:null}}}catch(r){return{hasError:!0,message:r instanceof Error?r.message:"Unknown error in block execution",data:null}}}}class Mi{constructor(){le(this,"expr");le(this,"json")}}class Ii{constructor(){le(this,"template");le(this,"valueFrom");le(this,"default")}}class ji{constructor(){le(this,"id");le(this,"title");le(this,"when");le(this,"block");le(this,"repeat");le(this,"next");le(this,"onSuccess");le(this,"onFailure");le(this,"switch");le(this,"timeoutMs");le(this,"retry");le(this,"delayAfterMs")}}class Fi{constructor(){le(this,"version");le(this,"id");le(this,"title");le(this,"description");le(this,"start");le(this,"steps");le(this,"vars");le(this,"defaultDelayMs")}}class Bi{constructor(){le(this,"stepId");le(this,"skipped");le(this,"success");le(this,"message");le(this,"result");le(this,"startedAt");le(this,"finishedAt");le(this,"attempts")}}class Li{constructor(){le(this,"success");le(this,"steps");le(this,"context");le(this,"targetUrl");le(this,"timestamp");le(this,"error")}}var Cr=(t=>(t.USD="USD",t.KRW="KRW",t.EUR="EUR",t.GBP="GBP",t.CAD="CAD",t.CNY="CNY",t.JPY="JPY",t.VND="VND",t.ARS="ARS",t.INR="INR",t.TWD="TWD",t.AUD="AUD",t.HKD="HKD",t.IDR="IDR",t.MXN="MXN",t.NZD="NZD",t.SGD="SGD",t.CHF="CHF",t.THB="THB",t.BRL="BRL",t.TRY="TRY",t.RUB="RUB",t.NOK="NOK",t.DKK="DKK",t.SEK="SEK",t.ILS="ILS",t.ZAR="ZAR",t.PLN="PLN",t.PHP="PHP",t.CZK="CZK",t.CLP="CLP",t.COP="COP",t.EGP="EGP",t.MYR="MYR",t.HUF="HUF",t.AED="AED",t.SAR="SAR",t.RON="RON",t.BGN="BGN",t))(Cr||{});const In={code:{type:"string",enum:Object.values(Cr),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 Je extends Error{constructor(e,r,a){super(e),this.code=r,this.details=a,this.name="EightGError"}static extensionNotInstalled(){return new Je("8G Extension is not installed or not responding","EXTENSION_NOT_FOUND")}static invalidRequest(e){return new Je(`Invalid request: ${e}`,"INVALID_REQUEST")}static collectionFailed(e){return new Je(`Data collection failed: ${e}`,"COLLECTION_FAILED")}static requestTimeout(e=6e5){const r=Math.floor(e/1e3);return new Je(`Request timeout - Extension did not respond within ${r} seconds`,"REQUEST_TIMEOUT")}}function $i(t){return t&&t.type==="8G_EXTENSION_RESPONSE"}const jn=At({id:Oe(),slug:Oe(),name:Oe(),image:Oe(),memberCount:$t(),isAdmin:Rt().nullable().optional()}),Fn=At({slug:Oe(),displayName:Oe(),profileImageUrl:Oe(),description:Oe(),publicEmail:Oe(),billingEmail:Oe(),orgPageUrl:Oe()});var hn=(t=>(t.monthly="MONTHLY",t.yearly="YEARLY",t))(hn||{});const Lr=At({code:Vr(Cr),symbol:Oe(),format:Oe(),amount:$t(),text:Oe().optional()}),Bn=At({planName:Oe(),currentCycleBillAmount:Lr,nextPaymentDue:Oe(),cycleTerm:Vr(hn).nullable(),isFreeTier:Rt(),isPerUser:Rt(),paidMemberCount:$t(),usedMemberCount:$t(),unitPrice:Lr.nullable(),cardNumber:Oe(),cardName:Oe()}),Ln=At({uid:Oe(),issuedDate:pr.date(),paidDate:pr.date().nullable().optional(),paymentMethod:Oe(),amount:Lr,isSuccessfulPaid:Rt(),receiptUrl:Oe()}),$n=At({name:Oe(),email:Oe().email(),profileImageUrl:Oe(),role:Oe(),subscriptionSeatStatus:Ur(["NONE","FREE","PAID","QUIT"]).nullable().optional(),startedAt:pr.date().nullable().optional(),deletedAt:pr.date().nullable().optional()});class Ui{constructor(){}async checkExtension(){return new Promise((e,r)=>{const a=setTimeout(()=>{r(Je.extensionNotInstalled())},5e3),n=i=>{$i(i.data)&&(clearTimeout(a),window.removeEventListener("message",n),e(i.data))};window.addEventListener("message",n),window.postMessage({type:"8G_EXTENSION_CHECK"},"*")})}async collectWorkflow(e){return new Promise((r,a)=>{const n=`8g_wf_${Date.now()}_${Math.random()}`,i=e.timeoutMs??6e5,o=setTimeout(()=>{a(Je.requestTimeout(i))},i),u=v=>{var k,O,D,_,T,I,ae;if(((k=v.data)==null?void 0:k.type)==="8G_COLLECT_RESPONSE"&&v.data.requestId===n){clearTimeout(o),window.removeEventListener("message",u);const Q=v.data,pe=((O=Q==null?void 0:Q.result)==null?void 0:O.steps)??((_=(D=Q==null?void 0:Q.result)==null?void 0:D.result)==null?void 0:_.steps)??[],q=((T=Q==null?void 0:Q.result)==null?void 0:T.context)??((ae=(I=Q==null?void 0:Q.result)==null?void 0:I.result)==null?void 0:ae.context)??{steps:{},vars:{}};r({success:Q.success,steps:pe,context:q,error:Q.success?void 0:"Workflow failed",timestamp:new Date().toISOString(),targetUrl:e.targetUrl})}};window.addEventListener("message",u),window.postMessage({type:"8G_COLLECT_WORKFLOW",requestId:n,targetUrl:e.targetUrl,workflow:e.workflow,closeTabAfterCollection:e.closeTabAfterCollection!==!1,activateTab:e.activateTab===!0},"*")})}async getWorkspaces(e){var i,o;const r=await this.collectWorkflow(e);if(!r.success)throw new Je("Failed to get workspaces","GET_WORKSPACES_FAILED");const a=(o=(i=r.steps[r.steps.length-1])==null?void 0:i.result)==null?void 0:o.data;if(!a||!Array.isArray(a))return{...r,data:[],isSuccess:!1};const n=[];for(const u of a){const v=jn.safeParse(u);v.success?n.push(v.data):console.warn("Invalid workspace data:",u,v.error)}return{...r,data:n,isSuccess:!0}}async getWorkspaceDetail(e,r,a){var u,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const n=await this.collectWorkflow(a);if(!n.success)throw new Je("Failed to get workspaces","GET_WORKSPACES_FAILED");const i=(v=(u=n.steps[n.steps.length-1])==null?void 0:u.result)==null?void 0:v.data;if(!i)return{...n};const o=Fn.safeParse(i);if(o.success){const k=o.data;return{...n,data:k}}else return console.warn("Invalid workspace detail data:",i,o.error),{...n,data:void 0}}async getWorkspaceBilling(e,r,a){var u,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const n=await this.collectWorkflow(a);if(!n.success)throw new Je("Failed to get workspace plan and cycle","GET_WORKSPACE_PLAN_AND_CYCLE_FAILED");const i=(v=(u=n.steps[n.steps.length-1])==null?void 0:u.result)==null?void 0:v.data;if(!i)return{...n};const o=Bn.safeParse(i);if(o.success){const k=o.data;return{...n,data:k}}else return console.warn("Invalid workspace billing data:",i,o.error),{...n,data:void 0}}async getWorkspaceBillingHistories(e,r,a){var u,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const n=await this.collectWorkflow(a);if(!n.success)throw new Je("Failed to get workspace billing histories","GET_WORKSPACE_BILLING_HISTORIES_FAILED");const i=(v=(u=n.steps[n.steps.length-1])==null?void 0:u.result)==null?void 0:v.data;if(!i||!Array.isArray(i))return{...n,data:[]};const o=[];for(const k of i){const O=Ln.safeParse(k);O.success?o.push(O.data):console.warn("Invalid workspace billing history data:",k,O.error)}return{...n,data:o}}async getWorkspaceMembers(e,r,a){var u,v;a.workflow.vars={...a.workflow.vars,workspaceKey:e,slug:r};const n=await this.collectWorkflow(a);if(!n.success)throw new Je("Failed to get workspace members","GET_WORKSPACE_MEMBERS_FAILED");const i=(v=(u=n.steps[n.steps.length-1])==null?void 0:u.result)==null?void 0:v.data;if(!i||!Array.isArray(i))return{...n,data:[]};const o=[];for(const k of i){const O=$n.safeParse(k);O.success?o.push(O.data):console.warn("Invalid workspace member data:",k,O.error)}return{...n,data:o}}async addMembers(e,r,a,n){n.workflow.vars={...n.workflow.vars,workspaceKey:e,slug:r,emails:a};const i=await this.collectWorkflow(n);if(!i.success)throw new Je("Failed to add sheets","ADD_SHEETS_FAILED");return{...i}}async deleteMembers(e,r,a,n){n.workflow.vars={...n.workflow.vars,workspaceKey:e,slug:r,emails:a};const i=await this.collectWorkflow(n);if(!i.success)throw new Je("Failed to delete members","DELETE_MEMBERS_FAILED");return{...i}}static getFromContext(e,r){const a=r.split(".");let n=e;for(const i of a){if(n==null)return;n=n[i]}return n}static getStepResult(e,r){return e.steps[r]}static getStepData(e,r){var a,n;return(n=(a=e.steps[r])==null?void 0:a.result)==null?void 0:n.data}static getVar(e,r){return e.vars[r]}}exports.AiParseDataBlockSchema=Zr;exports.AllBlockSchemas=Ni;exports.ApplyLocaleBlockSchema=fn;exports.BaseBlockSchema=tt;exports.BillingCycleTerm=hn;exports.Binding=Ii;exports.BlockHandler=Ri;exports.ClearValueFormsBlockSchema=Gr;exports.CollectWorkflowResult=Li;exports.Condition=Mi;exports.CurrencyCode=Cr;exports.CurrencyInfoSchema=In;exports.EightGClient=Ui;exports.EightGError=Je;exports.ElementExistsBlockSchema=Kr;exports.EventClickBlockSchema=Jr;exports.ExportDataBlockSchema=cn;exports.FetchApiBlockSchema=sn;exports.GetAttributeValueBlockSchema=zr;exports.GetElementDataBlockSchema=nn;exports.GetTextBlockSchema=Wr;exports.GetValueFormsBlockSchema=Hr;exports.KeypressBlockSchema=Xr;exports.MarkBorderBlockSchema=un;exports.NavigateBlockSchema=tn;exports.NetworkCatchBlockSchema=ln;exports.PasteValueBlockSchema=dn;exports.SaveAssetsBlockSchema=rn;exports.Schema=as;exports.ScrollBlockSchema=an;exports.SetContentEditableBlockSchema=Yr;exports.SetValueFormsBlockSchema=qr;exports.TransformDataBlockSchema=on;exports.WaitBlockSchema=Qr;exports.WaitForConditionBlockSchema=en;exports.Workflow=Fi;exports.WorkflowStep=ji;exports.WorkflowStepRunResult=Bi;exports.WorkspaceBillingHistorySchema=Ln;exports.WorkspaceBillingSchema=Bn;exports.WorkspaceDetailItemSchema=Fn;exports.WorkspaceItemSchema=jn;exports.WorkspaceMemberSchema=$n;exports.createArraySchema=ns;exports.createSchema=rs;