@iai-lib/any-chat-widget 0.1.0-alpha.67 → 0.1.0-alpha.71

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.
@@ -40,7 +40,7 @@
40
40
  * @license
41
41
  * Copyright 2021 Google LLC
42
42
  * SPDX-License-Identifier: BSD-3-Clause
43
- */function uO(t,e,r){return t?e(t):r==null?void 0:r(t)}var pr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(pr||(pr={}));var ov;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ov||(ov={}));const mt=pr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ja=t=>{switch(typeof t){case"undefined":return mt.undefined;case"string":return mt.string;case"number":return isNaN(t)?mt.nan:mt.number;case"boolean":return mt.boolean;case"function":return mt.function;case"bigint":return mt.bigint;case"symbol":return mt.symbol;case"object":return Array.isArray(t)?mt.array:t===null?mt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?mt.promise:typeof Map<"u"&&t instanceof Map?mt.map:typeof Set<"u"&&t instanceof Set?mt.set:typeof Date<"u"&&t instanceof Date?mt.date:mt.object;default:return mt.unknown}},nt=pr.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"]),lO=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Zn extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}static assert(e){if(!(e instanceof Zn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Zn.create=t=>new Zn(t);const Yo=(t,e)=>{let r;switch(t.code){case nt.invalid_type:t.received===mt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case nt.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,pr.jsonStringifyReplacer)}`;break;case nt.unrecognized_keys:r=`Unrecognized key(s) in object: ${pr.joinValues(t.keys,", ")}`;break;case nt.invalid_union:r="Invalid input";break;case nt.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${pr.joinValues(t.options)}`;break;case nt.invalid_enum_value:r=`Invalid enum value. Expected ${pr.joinValues(t.options)}, received '${t.received}'`;break;case nt.invalid_arguments:r="Invalid function arguments";break;case nt.invalid_return_type:r="Invalid function return type";break;case nt.invalid_date:r="Invalid date";break;case nt.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}"`:pr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case nt.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==="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 nt.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 nt.custom:r="Invalid input";break;case nt.invalid_intersection_types:r="Intersection results could not be merged";break;case nt.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case nt.not_finite:r="Number must be finite";break;default:r=e.defaultError,pr.assertNever(t)}return{message:r}};let h0=Yo;function cO(t){h0=t}function Vd(){return h0}const Wd=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:o}},dO=[];function ft(t,e){const r=Vd(),n=Wd({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Yo?void 0:Yo].filter(i=>!!i)});t.common.issues.push(n)}class mn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return qt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r){const a=await i.key,s=await i.value;n.push({key:a,value:s})}return mn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return qt;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const qt=Object.freeze({status:"aborted"}),Qo=t=>({status:"dirty",value:t}),Tn=t=>({status:"valid",value:t}),uv=t=>t.status==="aborted",lv=t=>t.status==="dirty",kl=t=>t.status==="valid",Sl=t=>typeof Promise<"u"&&t instanceof Promise;function Zd(t,e,r,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function p0(t,e,r,n,i){if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}typeof SuppressedError=="function"&&SuppressedError;var Mt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Mt||(Mt={}));var $l,Tl;class zi{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const v0=(t,e)=>{if(kl(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 Zn(t.common.issues);return this._error=r,this._error}}};function rr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,o)=>{var u,l;const{message:c}=t;return s.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:(u=c??n)!==null&&u!==void 0?u:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(l=c??r)!==null&&l!==void 0?l:o.defaultError}},description:i}}class ur{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)}get description(){return this._def.description}_getType(e){return Ja(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ja(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new mn,ctx:{common:e.parent.common,data:e.data,parsedType:Ja(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Sl(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 n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ja(e)},a=this._parseSync({data:e,path:i.path,parent:i});return v0(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={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:Ja(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(Sl(i)?i:Promise.resolve(i));return v0(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:nt.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new ki({schema:this,typeName:Ft.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return qi.create(this,this._def)}nullable(){return es.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _i.create(this,this._def)}promise(){return ru.create(this,this._def)}or(e){return xl.create([this,e],this._def)}and(e){return Il.create(this,e,this._def)}transform(e){return new ki({...rr(this._def),schema:this,typeName:Ft.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Nl({...rr(this._def),innerType:this,defaultValue:r,typeName:Ft.ZodDefault})}brand(){return new fv({typeName:Ft.ZodBranded,type:this,...rr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Ll({...rr(this._def),innerType:this,catchValue:r,typeName:Ft.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Dl.create(this,e)}readonly(){return jl.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const fO=/^c[^\s-]{8,}$/i,hO=/^[0-9a-z]+$/,pO=/^[0-9A-HJKMNP-TV-Z]{26}$/,vO=/^[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,mO=/^[a-z0-9_-]{21}$/i,gO=/^[-+]?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)?)??$/,yO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let cv;const wO=/^(?:(?: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])$/,_O=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,kO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,m0="((\\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])))",SO=new RegExp(`^${m0}$`);function g0(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function $O(t){return new RegExp(`^${g0(t)}$`)}function y0(t){let e=`${m0}T${g0(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 TO(t,e){return!!((e==="v4"||!e)&&wO.test(t)||(e==="v6"||!e)&&_O.test(t))}class wi extends ur{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==mt.string){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.string,received:a.parsedType}),qt}const n=new mn;let i;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const s=e.data.length>a.value,o=e.data.length<a.value;(s||o)&&(i=this._getOrReturnCtx(e,i),s?ft(i,{code:nt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&ft(i,{code:nt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")yO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"email",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")cv||(cv=new RegExp(bO,"u")),cv.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"emoji",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")vO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"uuid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")mO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"nanoid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")fO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"cuid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")hO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"cuid2",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")pO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"ulid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),ft(i,{validation:"url",code:nt.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"regex",code:nt.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?y0(a).test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?SO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?$O(a).test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?gO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"duration",code:nt.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?TO(e.data,a.version)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"ip",code:nt.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?kO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"base64",code:nt.invalid_string,message:a.message}),n.dirty()):pr.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:nt.invalid_string,...Mt.errToObj(n)})}_addCheck(e){return new wi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Mt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Mt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Mt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Mt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Mt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Mt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Mt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Mt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Mt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Mt.errToObj(e)})}datetime(e){var r,n;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:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Mt.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,...Mt.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Mt.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Mt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Mt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Mt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Mt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Mt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Mt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Mt.errToObj(r)})}nonempty(e){return this.min(1,Mt.errToObj(e))}trim(){return new wi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wi({...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 isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}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}}wi.create=t=>{var e;return new wi({checks:[],typeName:Ft.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};function EO(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class Ya extends ur{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)!==mt.number){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.number,received:a.parsedType}),qt}let n;const i=new mn;for(const a of this._def.checks)a.kind==="int"?pr.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?EO(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_finite,message:a.message}),i.dirty()):pr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Mt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Mt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Mt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Mt.toString(r))}setLimit(e,r,n,i){return new Ya({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Mt.toString(i)}]})}_addCheck(e){return new Ya({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Mt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Mt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Mt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Mt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Mt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Mt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Mt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Mt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Mt.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"&&pr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Ya.create=t=>new Ya({checks:[],typeName:Ft.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class Qa extends ur{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==mt.bigint){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.bigint,received:a.parsedType}),qt}let n;const i=new mn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):pr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Mt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Mt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Mt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Mt.toString(r))}setLimit(e,r,n,i){return new Qa({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Mt.toString(i)}]})}_addCheck(e){return new Qa({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Mt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Mt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Mt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Mt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Mt.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}}Qa.create=t=>{var e;return new Qa({checks:[],typeName:Ft.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};class El extends ur{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==mt.boolean){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.boolean,received:n.parsedType}),qt}return Tn(e.data)}}El.create=t=>new El({typeName:Ft.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class qs extends ur{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==mt.date){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.date,received:a.parsedType}),qt}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_date}),qt}const n=new mn;let i;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):pr.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new qs({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Mt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Mt.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}}qs.create=t=>new qs({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Ft.ZodDate,...rr(t)});class Gd extends ur{_parse(e){if(this._getType(e)!==mt.symbol){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.symbol,received:n.parsedType}),qt}return Tn(e.data)}}Gd.create=t=>new Gd({typeName:Ft.ZodSymbol,...rr(t)});class Cl extends ur{_parse(e){if(this._getType(e)!==mt.undefined){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.undefined,received:n.parsedType}),qt}return Tn(e.data)}}Cl.create=t=>new Cl({typeName:Ft.ZodUndefined,...rr(t)});class Rl extends ur{_parse(e){if(this._getType(e)!==mt.null){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.null,received:n.parsedType}),qt}return Tn(e.data)}}Rl.create=t=>new Rl({typeName:Ft.ZodNull,...rr(t)});class Xo extends ur{constructor(){super(...arguments),this._any=!0}_parse(e){return Tn(e.data)}}Xo.create=t=>new Xo({typeName:Ft.ZodAny,...rr(t)});class Vs extends ur{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Tn(e.data)}}Vs.create=t=>new Vs({typeName:Ft.ZodUnknown,...rr(t)});class ma extends ur{_parse(e){const r=this._getOrReturnCtx(e);return ft(r,{code:nt.invalid_type,expected:mt.never,received:r.parsedType}),qt}}ma.create=t=>new ma({typeName:Ft.ZodNever,...rr(t)});class Kd extends ur{_parse(e){if(this._getType(e)!==mt.undefined){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.void,received:n.parsedType}),qt}return Tn(e.data)}}Kd.create=t=>new Kd({typeName:Ft.ZodVoid,...rr(t)});class _i extends ur{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==mt.array)return ft(r,{code:nt.invalid_type,expected:mt.array,received:r.parsedType}),qt;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(ft(r,{code:s?nt.too_big:nt.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(ft(r,{code:nt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(ft(r,{code:nt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new zi(r,s,r.path,o)))).then(s=>mn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new zi(r,s,r.path,o)));return mn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new _i({...this._def,minLength:{value:e,message:Mt.toString(r)}})}max(e,r){return new _i({...this._def,maxLength:{value:e,message:Mt.toString(r)}})}length(e,r){return new _i({...this._def,exactLength:{value:e,message:Mt.toString(r)}})}nonempty(e){return this.min(1,e)}}_i.create=(t,e)=>new _i({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ft.ZodArray,...rr(e)});function eu(t){if(t instanceof Wr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=qi.create(eu(n))}return new Wr({...t._def,shape:()=>e})}else return t instanceof _i?new _i({...t._def,type:eu(t.element)}):t instanceof qi?qi.create(eu(t.unwrap())):t instanceof es?es.create(eu(t.unwrap())):t instanceof Hi?Hi.create(t.items.map(e=>eu(e))):t}class Wr extends ur{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=pr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==mt.object){const l=this._getOrReturnCtx(e);return ft(l,{code:nt.invalid_type,expected:mt.object,received:l.parsedType}),qt}const{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof ma&&this._def.unknownKeys==="strip"))for(const l in i.data)s.includes(l)||o.push(l);const u=[];for(const l of s){const c=a[l],d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new zi(i,d,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof ma){const l=this._def.unknownKeys;if(l==="passthrough")for(const c of o)u.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(l==="strict")o.length>0&&(ft(i,{code:nt.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const c of o){const d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new zi(i,d,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const l=[];for(const c of u){const d=await c.key,f=await c.value;l.push({key:d,value:f,alwaysSet:c.alwaysSet})}return l}).then(l=>mn.mergeObjectSync(n,l)):mn.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Mt.errToObj,new Wr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Mt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Wr({...this._def,unknownKeys:"strip"})}passthrough(){return new Wr({...this._def,unknownKeys:"passthrough"})}extend(e){return new Wr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Wr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ft.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Wr({...this._def,catchall:e})}pick(e){const r={};return pr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Wr({...this._def,shape:()=>r})}omit(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Wr({...this._def,shape:()=>r})}deepPartial(){return eu(this)}partial(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new Wr({...this._def,shape:()=>r})}required(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof qi;)a=a._def.innerType;r[n]=a}}),new Wr({...this._def,shape:()=>r})}keyof(){return b0(pr.objectKeys(this.shape))}}Wr.create=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strip",catchall:ma.create(),typeName:Ft.ZodObject,...rr(e)}),Wr.strictCreate=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strict",catchall:ma.create(),typeName:Ft.ZodObject,...rr(e)}),Wr.lazycreate=(t,e)=>new Wr({shape:t,unknownKeys:"strip",catchall:ma.create(),typeName:Ft.ZodObject,...rr(e)});class xl extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new Zn(o.ctx.common.issues));return ft(r,{code:nt.invalid_union,unionErrors:s}),qt}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new Zn(u));return ft(r,{code:nt.invalid_union,unionErrors:o}),qt}}get options(){return this._def.options}}xl.create=(t,e)=>new xl({options:t,typeName:Ft.ZodUnion,...rr(e)});const ga=t=>t instanceof Ol?ga(t.schema):t instanceof ki?ga(t.innerType()):t instanceof Pl?[t.value]:t instanceof Xa?t.options:t instanceof Ml?pr.objectValues(t.enum):t instanceof Nl?ga(t._def.innerType):t instanceof Cl?[void 0]:t instanceof Rl?[null]:t instanceof qi?[void 0,...ga(t.unwrap())]:t instanceof es?[null,...ga(t.unwrap())]:t instanceof fv||t instanceof jl?ga(t.unwrap()):t instanceof Ll?ga(t._def.innerType):[];class Jd extends ur{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.object)return ft(r,{code:nt.invalid_type,expected:mt.object,received:r.parsedType}),qt;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(ft(r,{code:nt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),qt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=ga(a.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new Jd({typeName:Ft.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...rr(n)})}}function dv(t,e){const r=Ja(t),n=Ja(e);if(t===e)return{valid:!0,data:t};if(r===mt.object&&n===mt.object){const i=pr.objectKeys(e),a=pr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=dv(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===mt.array&&n===mt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=dv(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===mt.date&&n===mt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Il extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(uv(a)||uv(s))return qt;const o=dv(a.value,s.value);return o.valid?((lv(a)||lv(s))&&r.dirty(),{status:r.value,value:o.data}):(ft(n,{code:nt.invalid_intersection_types}),qt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Il.create=(t,e,r)=>new Il({left:t,right:e,typeName:Ft.ZodIntersection,...rr(r)});class Hi extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.array)return ft(n,{code:nt.invalid_type,expected:mt.array,received:n.parsedType}),qt;if(n.data.length<this._def.items.length)return ft(n,{code:nt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),qt;!this._def.rest&&n.data.length>this._def.items.length&&(ft(n,{code:nt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((s,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new zi(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(a).then(s=>mn.mergeArray(r,s)):mn.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Hi({...this._def,rest:e})}}Hi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Hi({items:t,typeName:Ft.ZodTuple,rest:null,...rr(e)})};class Al extends ur{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.object)return ft(n,{code:nt.invalid_type,expected:mt.object,received:n.parsedType}),qt;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new zi(n,o,n.path,o)),value:s._parse(new zi(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?mn.mergeObjectAsync(r,i):mn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ur?new Al({keyType:e,valueType:r,typeName:Ft.ZodRecord,...rr(n)}):new Al({keyType:wi.create(),valueType:e,typeName:Ft.ZodRecord,...rr(r)})}}class Yd extends ur{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.map)return ft(n,{code:nt.invalid_type,expected:mt.map,received:n.parsedType}),qt;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new zi(n,o,n.path,[l,"key"])),value:a._parse(new zi(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}Yd.create=(t,e,r)=>new Yd({valueType:e,keyType:t,typeName:Ft.ZodMap,...rr(r)});class Ws extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.set)return ft(n,{code:nt.invalid_type,expected:mt.set,received:n.parsedType}),qt;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(ft(n,{code:nt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(ft(n,{code:nt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return qt;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new zi(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new Ws({...this._def,minSize:{value:e,message:Mt.toString(r)}})}max(e,r){return new Ws({...this._def,maxSize:{value:e,message:Mt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Ws.create=(t,e)=>new Ws({valueType:t,minSize:null,maxSize:null,typeName:Ft.ZodSet,...rr(e)});class tu extends ur{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.function)return ft(r,{code:nt.invalid_type,expected:mt.function,received:r.parsedType}),qt;function n(o,u){return Wd({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Vd(),Yo].filter(l=>!!l),issueData:{code:nt.invalid_arguments,argumentsError:u}})}function i(o,u){return Wd({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Vd(),Yo].filter(l=>!!l),issueData:{code:nt.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof ru){const o=this;return Tn(async function(...u){const l=new Zn([]),c=await o._def.args.parseAsync(u,a).catch(m=>{throw l.addIssue(n(u,m)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(m=>{throw l.addIssue(i(d,m)),l})})}else{const o=this;return Tn(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Zn([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new Zn([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new tu({...this._def,args:Hi.create(e).rest(Vs.create())})}returns(e){return new tu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new tu({args:e||Hi.create([]).rest(Vs.create()),returns:r||Vs.create(),typeName:Ft.ZodFunction,...rr(n)})}}class Ol extends ur{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})}}Ol.create=(t,e)=>new Ol({getter:t,typeName:Ft.ZodLazy,...rr(e)});class Pl extends ur{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return ft(r,{received:r.data,code:nt.invalid_literal,expected:this._def.value}),qt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Pl.create=(t,e)=>new Pl({value:t,typeName:Ft.ZodLiteral,...rr(e)});function b0(t,e){return new Xa({values:t,typeName:Ft.ZodEnum,...rr(e)})}class Xa extends ur{constructor(){super(...arguments),$l.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return ft(r,{expected:pr.joinValues(n),received:r.parsedType,code:nt.invalid_type}),qt}if(Zd(this,$l)||p0(this,$l,new Set(this._def.values)),!Zd(this,$l).has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return ft(r,{received:r.data,code:nt.invalid_enum_value,options:n}),qt}return Tn(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 Xa.create(e,{...this._def,...r})}exclude(e,r=this._def){return Xa.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}$l=new WeakMap,Xa.create=b0;class Ml extends ur{constructor(){super(...arguments),Tl.set(this,void 0)}_parse(e){const r=pr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==mt.string&&n.parsedType!==mt.number){const i=pr.objectValues(r);return ft(n,{expected:pr.joinValues(i),received:n.parsedType,code:nt.invalid_type}),qt}if(Zd(this,Tl)||p0(this,Tl,new Set(pr.getValidEnumValues(this._def.values))),!Zd(this,Tl).has(e.data)){const i=pr.objectValues(r);return ft(n,{received:n.data,code:nt.invalid_enum_value,options:i}),qt}return Tn(e.data)}get enum(){return this._def.values}}Tl=new WeakMap,Ml.create=(t,e)=>new Ml({values:t,typeName:Ft.ZodNativeEnum,...rr(e)});class ru extends ur{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.promise&&r.common.async===!1)return ft(r,{code:nt.invalid_type,expected:mt.promise,received:r.parsedType}),qt;const n=r.parsedType===mt.promise?r.data:Promise.resolve(r.data);return Tn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}ru.create=(t,e)=>new ru({type:t,typeName:Ft.ZodPromise,...rr(e)});class ki extends ur{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ft.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{ft(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);if(n.common.async)return Promise.resolve(s).then(async o=>{if(r.value==="aborted")return qt;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?qt:u.status==="dirty"||r.value==="dirty"?Qo(u.value):u});{if(r.value==="aborted")return qt;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?qt:o.status==="dirty"||r.value==="dirty"?Qo(o.value):o}}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?qt:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?qt:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kl(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>kl(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);pr.assertNever(i)}}ki.create=(t,e,r)=>new ki({schema:t,typeName:Ft.ZodEffects,effect:e,...rr(r)}),ki.createWithPreprocess=(t,e,r)=>new ki({schema:e,effect:{type:"preprocess",transform:t},typeName:Ft.ZodEffects,...rr(r)});class qi extends ur{_parse(e){return this._getType(e)===mt.undefined?Tn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}qi.create=(t,e)=>new qi({innerType:t,typeName:Ft.ZodOptional,...rr(e)});class es extends ur{_parse(e){return this._getType(e)===mt.null?Tn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}es.create=(t,e)=>new es({innerType:t,typeName:Ft.ZodNullable,...rr(e)});class Nl extends ur{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===mt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Nl.create=(t,e)=>new Nl({innerType:t,typeName:Ft.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...rr(e)});class Ll extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Sl(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Zn(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ll.create=(t,e)=>new Ll({innerType:t,typeName:Ft.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...rr(e)});class Qd extends ur{_parse(e){if(this._getType(e)!==mt.nan){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.nan,received:n.parsedType}),qt}return{status:"valid",value:e.data}}}Qd.create=t=>new Qd({typeName:Ft.ZodNaN,...rr(t)});const CO=Symbol("zod_brand");class fv extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Dl extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?qt:a.status==="dirty"?(r.dirty(),Qo(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?qt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new Dl({in:e,out:r,typeName:Ft.ZodPipeline})}}class jl extends ur{_parse(e){const r=this._def.innerType._parse(e),n=i=>(kl(i)&&(i.value=Object.freeze(i.value)),i);return Sl(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}}jl.create=(t,e)=>new jl({innerType:t,typeName:Ft.ZodReadonly,...rr(e)});function w0(t,e={},r){return t?Xo.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):Xo.create()}const RO={object:Wr.lazycreate};var Ft;(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"})(Ft||(Ft={}));const xO=(t,e={message:`Input not instance of ${t.name}`})=>w0(r=>r instanceof t,e),_0=wi.create,k0=Ya.create,IO=Qd.create,AO=Qa.create,S0=El.create,OO=qs.create,PO=Gd.create,MO=Cl.create,NO=Rl.create,LO=Xo.create,DO=Vs.create,jO=ma.create,UO=Kd.create,FO=_i.create,BO=Wr.create,zO=Wr.strictCreate,HO=xl.create,qO=Jd.create,VO=Il.create,WO=Hi.create,ZO=Al.create,GO=Yd.create,KO=Ws.create,JO=tu.create,YO=Ol.create,QO=Pl.create,XO=Xa.create,eP=Ml.create,tP=ru.create,$0=ki.create,rP=qi.create,nP=es.create,iP=ki.createWithPreprocess,aP=Dl.create;var Ul=Object.freeze({__proto__:null,defaultErrorMap:Yo,setErrorMap:cO,getErrorMap:Vd,makeIssue:Wd,EMPTY_PATH:dO,addIssueToContext:ft,ParseStatus:mn,INVALID:qt,DIRTY:Qo,OK:Tn,isAborted:uv,isDirty:lv,isValid:kl,isAsync:Sl,get util(){return pr},get objectUtil(){return ov},ZodParsedType:mt,getParsedType:Ja,ZodType:ur,datetimeRegex:y0,ZodString:wi,ZodNumber:Ya,ZodBigInt:Qa,ZodBoolean:El,ZodDate:qs,ZodSymbol:Gd,ZodUndefined:Cl,ZodNull:Rl,ZodAny:Xo,ZodUnknown:Vs,ZodNever:ma,ZodVoid:Kd,ZodArray:_i,ZodObject:Wr,ZodUnion:xl,ZodDiscriminatedUnion:Jd,ZodIntersection:Il,ZodTuple:Hi,ZodRecord:Al,ZodMap:Yd,ZodSet:Ws,ZodFunction:tu,ZodLazy:Ol,ZodLiteral:Pl,ZodEnum:Xa,ZodNativeEnum:Ml,ZodPromise:ru,ZodEffects:ki,ZodTransformer:ki,ZodOptional:qi,ZodNullable:es,ZodDefault:Nl,ZodCatch:Ll,ZodNaN:Qd,BRAND:CO,ZodBranded:fv,ZodPipeline:Dl,ZodReadonly:jl,custom:w0,Schema:ur,ZodSchema:ur,late:RO,get ZodFirstPartyTypeKind(){return Ft},coerce:{string:t=>wi.create({...t,coerce:!0}),number:t=>Ya.create({...t,coerce:!0}),boolean:t=>El.create({...t,coerce:!0}),bigint:t=>Qa.create({...t,coerce:!0}),date:t=>qs.create({...t,coerce:!0})},any:LO,array:FO,bigint:AO,boolean:S0,date:OO,discriminatedUnion:qO,effect:$0,enum:XO,function:JO,instanceof:xO,intersection:VO,lazy:YO,literal:QO,map:GO,nan:IO,nativeEnum:eP,never:jO,null:NO,nullable:nP,number:k0,object:BO,oboolean:()=>S0().optional(),onumber:()=>k0().optional(),optional:rP,ostring:()=>_0().optional(),pipeline:aP,preprocess:iP,promise:tP,record:ZO,set:KO,strictObject:zO,string:_0,symbol:PO,transformer:$0,tuple:WO,undefined:MO,union:HO,unknown:DO,void:UO,NEVER:qt,ZodIssueCode:nt,quotelessJson:lO,ZodError:Zn});const T0=j2`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.static{position:static}.relative{position:relative}.my-4{margin-top:1rem;margin-bottom:1rem}.mb-4{margin-bottom:1rem}.mt-4{margin-top:1rem}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rounded{border-radius:.25rem}.border{border-width:1px}.border-red-400{--tw-border-opacity: 1;border-color:rgb(248 113 113 / var(--tw-border-opacity))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity))}.px-4{padding-left:1rem;padding-right:1rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}input{width:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-radius:.25rem;border-width:1px;padding:.5rem .75rem;line-height:1.25;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity));--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}label{margin-bottom:.5rem;display:block;font-size:.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-primary{border-radius:.25rem;padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.btn-primary:hover{opacity:.95}.btn-primary:disabled{pointer-events:none;opacity:.5}.btn-primary{background-color:var(--iai-chat-i-button-bg);color:var(--iai-chat-i-button-fg)}.btn-secondary{padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-secondary:hover{opacity:.95}.btn-secondary:disabled{pointer-events:none;opacity:.5}`;var ln=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sP(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function oP(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}(function(){function t(L,W){var ie=L.split("."),He=ce;ie[0]in He||!He.execScript||He.execScript("var "+ie[0]);for(var ct;ie.length&&(ct=ie.shift());)ie.length||W===void 0?He=He[ct]?He[ct]:He[ct]={}:He[ct]=W}function e(L,W){function ie(){}ie.prototype=W.prototype,L.M=W.prototype,L.prototype=new ie,L.prototype.constructor=L,L.N=function(He,ct,bt){for(var zt=Array(arguments.length-2),tr=2;tr<arguments.length;tr++)zt[tr-2]=arguments[tr];return W.prototype[ct].apply(He,zt)}}function r(L,W){L!=null&&this.a.apply(this,arguments)}function n(L){L.b=""}function i(L,W){L.sort(W||a)}function a(L,W){return L>W?1:L<W?-1:0}function s(L){var W,ie=[],He=0;for(W in L)ie[He++]=L[W];return ie}function o(L,W){this.b=L,this.a={};for(var ie=0;ie<W.length;ie++){var He=W[ie];this.a[He.b]=He}}function u(L){return L=s(L.a),i(L,function(W,ie){return W.b-ie.b}),L}function l(L,W){switch(this.b=L,this.g=!!W.v,this.a=W.c,this.i=W.type,this.h=!1,this.a){case be:case pt:case Ze:case Jt:case At:case Fe:case Ke:this.h=!0}this.f=W.defaultValue}function c(){this.a={},this.f=this.j().a,this.b=this.g=null}function d(L,W){for(var ie=u(L.j()),He=0;He<ie.length;He++){var ct=ie[He],bt=ct.b;if(W.a[bt]!=null){L.b&&delete L.b[ct.b];var zt=ct.a==11||ct.a==10;if(ct.g)for(var ct=f(W,bt)||[],tr=0;tr<ct.length;tr++){var Re=L,Ne=bt,pe=zt?ct[tr].clone():ct[tr];Re.a[Ne]||(Re.a[Ne]=[]),Re.a[Ne].push(pe),Re.b&&delete Re.b[Ne]}else ct=f(W,bt),zt?(zt=f(L,bt))?d(zt,ct):N(L,bt,ct.clone()):N(L,bt,ct)}}}function f(L,W){var ie=L.a[W];if(ie==null)return null;if(L.g){if(!(W in L.b)){var He=L.g,ct=L.f[W];if(ie!=null)if(ct.g){for(var bt=[],zt=0;zt<ie.length;zt++)bt[zt]=He.b(ct,ie[zt]);ie=bt}else ie=He.b(ct,ie);return L.b[W]=ie}return L.b[W]}return ie}function m(L,W,ie){var He=f(L,W);return L.f[W].g?He[ie||0]:He}function b(L,W){var ie;if(L.a[W]!=null)ie=m(L,W,void 0);else e:{if(ie=L.f[W],ie.f===void 0){var He=ie.i;if(He===Boolean)ie.f=!1;else if(He===Number)ie.f=0;else{if(He!==String){ie=new He;break e}ie.f=ie.h?"0":""}}ie=ie.f}return ie}function A(L,W){return L.f[W].g?L.a[W]!=null?L.a[W].length:0:L.a[W]!=null?1:0}function N(L,W,ie){L.a[W]=ie,L.b&&(L.b[W]=ie)}function z(L,W){var ie,He=[];for(ie in W)ie!=0&&He.push(new l(ie,W[ie]));return new o(L,He)}function X(){c.call(this)}function Ee(){c.call(this)}function Ie(){c.call(this)}function Be(){}function Oe(){}function ze(){}function V(){this.a={}}function xe(L){return L.length==0||Mr.test(L)}function _e(L,W){if(W==null)return null;W=W.toUpperCase();var ie=L.a[W];if(ie==null){if(ie=ut[W],ie==null)return null;ie=new ze().a(Ie.j(),ie),L.a[W]=ie}return ie}function se(L){return L=St[L],L==null?"ZZ":L[0]}function Te(L){this.H=RegExp(" "),this.C="",this.m=new r,this.w="",this.i=new r,this.u=new r,this.l=!0,this.A=this.o=this.F=!1,this.G=V.b(),this.s=0,this.b=new r,this.B=!1,this.h="",this.a=new r,this.f=[],this.D=L,this.J=this.g=re(this,this.D)}function re(L,W){var ie;if(W!=null&&isNaN(W)&&W.toUpperCase()in ut){if(ie=_e(L.G,W),ie==null)throw Error("Invalid region code: "+W);ie=b(ie,10)}else ie=0;return ie=_e(L.G,se(ie)),ie??Fr}function oe(L){for(var W=L.f.length,ie=0;ie<W;++ie){var He=L.f[ie],ct=b(He,1);if(L.w==ct)return!1;var bt;bt=L;var zt=He,tr=b(zt,1);if(tr.indexOf("|")!=-1)bt=!1;else{tr=tr.replace(dr,"\\d"),tr=tr.replace(fr,"\\d"),n(bt.m);var Re;Re=bt;var zt=b(zt,2),Ne="999999999999999".match(tr)[0];Ne.length<Re.a.b.length?Re="":(Re=Ne.replace(new RegExp(tr,"g"),zt),Re=Re.replace(RegExp("9","g")," ")),0<Re.length?(bt.m.a(Re),bt=!0):bt=!1}if(bt)return L.w=ct,L.B=Ot.test(m(He,4)),L.s=0,!0}return L.l=!1}function q(L,W){for(var ie=[],He=W.length-3,ct=L.f.length,bt=0;bt<ct;++bt){var zt=L.f[bt];A(zt,3)==0?ie.push(L.f[bt]):(zt=m(zt,3,Math.min(He,A(zt,3)-1)),W.search(zt)==0&&ie.push(L.f[bt]))}L.f=ie}function ne(L,W){L.i.a(W);var ie=W;if(et.test(ie)||L.i.b.length==1&&br.test(ie)){var He,ie=W;ie=="+"?(He=ie,L.u.a(ie)):(He=or[ie],L.u.a(He),L.a.a(He)),W=He}else L.l=!1,L.F=!0;if(!L.l){if(!L.F){if(Ct(L)){if(rt(L))return Se(L)}else if(0<L.h.length&&(ie=L.a.toString(),n(L.a),L.a.a(L.h),L.a.a(ie),ie=L.b.toString(),He=ie.lastIndexOf(L.h),n(L.b),L.b.a(ie.substring(0,He))),L.h!=Xe(L))return L.b.a(" "),Se(L)}return L.i.toString()}switch(L.u.b.length){case 0:case 1:case 2:return L.i.toString();case 3:if(!Ct(L))return L.h=Xe(L),ke(L);L.A=!0;default:return L.A?(rt(L)&&(L.A=!1),L.b.toString()+L.a.toString()):0<L.f.length?(ie=je(L,W),He=H(L),0<He.length?He:(q(L,L.a.toString()),oe(L)?M(L):L.l?ye(L,ie):L.i.toString())):ke(L)}}function Se(L){return L.l=!0,L.A=!1,L.f=[],L.s=0,n(L.m),L.w="",ke(L)}function H(L){for(var W=L.a.toString(),ie=L.f.length,He=0;He<ie;++He){var ct=L.f[He],bt=b(ct,1);if(new RegExp("^(?:"+bt+")$").test(W))return L.B=Ot.test(m(ct,4)),W=W.replace(new RegExp(bt,"g"),m(ct,2)),ye(L,W)}return""}function ye(L,W){var ie=L.b.b.length;return L.B&&0<ie&&L.b.toString().charAt(ie-1)!=" "?L.b+" "+W:L.b+W}function ke(L){var W=L.a.toString();if(3<=W.length){for(var ie=L.o&&L.h.length==0&&0<A(L.g,20)?f(L.g,20)||[]:f(L.g,19)||[],He=ie.length,ct=0;ct<He;++ct){var bt=ie[ct];0<L.h.length&&xe(b(bt,4))&&!m(bt,6)&&bt.a[5]==null||(L.h.length!=0||L.o||xe(b(bt,4))||m(bt,6))&&Wt.test(b(bt,2))&&L.f.push(bt)}return q(L,W),W=H(L),0<W.length?W:oe(L)?M(L):L.i.toString()}return ye(L,W)}function M(L){var W=L.a.toString(),ie=W.length;if(0<ie){for(var He="",ct=0;ct<ie;ct++)He=je(L,W.charAt(ct));return L.l?ye(L,He):L.i.toString()}return L.b.toString()}function Xe(L){var W,ie=L.a.toString(),He=0;return m(L.g,10)!=1?W=!1:(W=L.a.toString(),W=W.charAt(0)=="1"&&W.charAt(1)!="0"&&W.charAt(1)!="1"),W?(He=1,L.b.a("1").a(" "),L.o=!0):L.g.a[15]!=null&&(W=new RegExp("^(?:"+m(L.g,15)+")"),W=ie.match(W),W!=null&&W[0]!=null&&0<W[0].length&&(L.o=!0,He=W[0].length,L.b.a(ie.substring(0,He)))),n(L.a),L.a.a(ie.substring(He)),ie.substring(0,He)}function Ct(L){var W=L.u.toString(),ie=new RegExp("^(?:\\+|"+m(L.g,11)+")"),ie=W.match(ie);return ie!=null&&ie[0]!=null&&0<ie[0].length&&(L.o=!0,ie=ie[0].length,n(L.a),L.a.a(W.substring(ie)),n(L.b),L.b.a(W.substring(0,ie)),W.charAt(0)!="+"&&L.b.a(" "),!0)}function rt(L){if(L.a.b.length==0)return!1;var W,ie=new r;e:{if(W=L.a.toString(),W.length!=0&&W.charAt(0)!="0"){for(var He,ct=W.length,bt=1;3>=bt&&bt<=ct;++bt)if(He=parseInt(W.substring(0,bt),10),He in St){ie.a(W.substring(bt)),W=He;break e}}W=0}return W!=0&&(n(L.a),L.a.a(ie.toString()),ie=se(W),ie=="001"?L.g=_e(L.G,""+W):ie!=L.D&&(L.g=re(L,ie)),L.b.a(""+W).a(" "),L.h="",!0)}function je(L,W){var ie=L.m.toString();if(0<=ie.substring(L.s).search(L.H)){var He=ie.search(L.H),ie=ie.replace(L.H,W);return n(L.m),L.m.a(ie),L.s=He,ie.substring(0,L.s+1)}return L.f.length==1&&(L.l=!1),L.w="",L.i.toString()}var ce=this;r.prototype.b="",r.prototype.set=function(L){this.b=""+L},r.prototype.a=function(L,W,ie){if(this.b+=String(L),W!=null)for(var He=1;He<arguments.length;He++)this.b+=arguments[He];return this},r.prototype.toString=function(){return this.b};var Ke=1,Fe=2,be=3,pt=4,Ze=6,Jt=16,At=18;c.prototype.set=function(L,W){N(this,L.b,W)},c.prototype.clone=function(){var L=new this.constructor;return L!=this&&(L.a={},L.b&&(L.b={}),d(L,this)),L},e(X,c);var Q=null;e(Ee,c);var Ue=null;e(Ie,c);var ot=null;X.prototype.j=function(){var L=Q;return L||(Q=L=z(X,{0:{name:"NumberFormat",I:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",v:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,defaultValue:!1,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}})),L},X.j=X.prototype.j,Ee.prototype.j=function(){var L=Ue;return L||(Ue=L=z(Ee,{0:{name:"PhoneNumberDesc",I:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},9:{name:"possible_length",v:!0,c:5,type:Number},10:{name:"possible_length_local_only",v:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String}})),L},Ee.j=Ee.prototype.j,Ie.prototype.j=function(){var L=ot;return L||(ot=L=z(Ie,{0:{name:"PhoneMetadata",I:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:Ee},2:{name:"fixed_line",c:11,type:Ee},3:{name:"mobile",c:11,type:Ee},4:{name:"toll_free",c:11,type:Ee},5:{name:"premium_rate",c:11,type:Ee},6:{name:"shared_cost",c:11,type:Ee},7:{name:"personal_number",c:11,type:Ee},8:{name:"voip",c:11,type:Ee},21:{name:"pager",c:11,type:Ee},25:{name:"uan",c:11,type:Ee},27:{name:"emergency",c:11,type:Ee},28:{name:"voicemail",c:11,type:Ee},29:{name:"short_code",c:11,type:Ee},30:{name:"standard_rate",c:11,type:Ee},31:{name:"carrier_specific",c:11,type:Ee},33:{name:"sms_services",c:11,type:Ee},24:{name:"no_international_dialling",c:11,type:Ee},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1,type:Boolean},19:{name:"number_format",v:!0,c:11,type:X},20:{name:"intl_number_format",v:!0,c:11,type:X},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String},26:{name:"leading_zero_possible",c:8,defaultValue:!1,type:Boolean}})),L},Ie.j=Ie.prototype.j,Be.prototype.a=function(L){throw new L.b,Error("Unimplemented")},Be.prototype.b=function(L,W){if(L.a==11||L.a==10)return W instanceof c?W:this.a(L.i.prototype.j(),W);if(L.a==14){if(typeof W=="string"&&Pe.test(W)){var ie=Number(W);if(0<ie)return ie}return W}if(!L.h)return W;if(ie=L.i,ie===String){if(typeof W=="number")return String(W)}else if(ie===Number&&typeof W=="string"&&(W==="Infinity"||W==="-Infinity"||W==="NaN"||Pe.test(W)))return Number(W);return W};var Pe=/^-?[0-9]+$/;e(Oe,Be),Oe.prototype.a=function(L,W){var ie=new L.b;return ie.g=this,ie.a=W,ie.b={},ie},e(ze,Oe),ze.prototype.b=function(L,W){return L.a==8?!!W:Be.prototype.b.apply(this,arguments)},ze.prototype.a=function(L,W){return ze.M.a.call(this,L,W)};var St={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" ")},ut={AG:[null,[null,null,"(?:268|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"268(?:4(?:6[0-38]|84)|56[0-2])\\d{4}",null,null,null,"2684601234",null,null,null,[7]],[null,null,"268(?:464|7(?:1[3-9]|2\\d|3[246]|64|[78][0-689]))\\d{4}",null,null,null,"2684641234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"26848[01]\\d{4}",null,null,null,"2684801234",null,null,null,[7]],"AG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"26840[69]\\d{4}",null,null,null,"2684061234",null,null,null,[7]],null,"268",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AI:[null,[null,null,"(?:264|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"2644(?:6[12]|9[78])\\d{4}",null,null,null,"2644612345",null,null,null,[7]],[null,null,"264(?:235|476|5(?:3[6-9]|8[1-4])|7(?:29|72))\\d{4}",null,null,null,"2642351234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AI",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"264",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AS:[null,[null,null,"(?:[58]\\d\\d|684|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"6846(?:22|33|44|55|77|88|9[19])\\d{4}",null,null,null,"6846221234",null,null,null,[7]],[null,null,"684(?:2(?:5[2468]|72)|7(?:3[13]|70))\\d{4}",null,null,null,"6847331234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"684",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BB:[null,[null,null,"(?:246|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"246(?:2(?:2[78]|7[0-4])|4(?:1[024-6]|2\\d|3[2-9])|5(?:20|[34]\\d|54|7[1-3])|6(?:2\\d|38)|7[35]7|9(?:1[89]|63))\\d{4}",null,null,null,"2464123456",null,null,null,[7]],[null,null,"246(?:2(?:[356]\\d|4[0-57-9]|8[0-79])|45\\d|69[5-7]|8(?:[2-5]\\d|83))\\d{4}",null,null,null,"2462501234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"(?:246976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002123456",null,null,null,[7]],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"24631\\d{5}",null,null,null,"2463101234",null,null,null,[7]],"BB",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"246",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"246(?:292|367|4(?:1[7-9]|3[01]|44|67)|7(?:36|53))\\d{4}",null,null,null,"2464301234",null,null,null,[7]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BM:[null,[null,null,"(?:441|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"441(?:2(?:02|23|[3479]\\d|61)|[46]\\d\\d|5(?:4\\d|60|89)|824)\\d{4}",null,null,null,"4412345678",null,null,null,[7]],[null,null,"441(?:[37]\\d|5[0-39])\\d{5}",null,null,null,"4413701234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"441",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BS:[null,[null,null,"(?:242|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"242(?:3(?:02|[236][1-9]|4[0-24-9]|5[0-68]|7[347]|8[0-4]|9[2-467])|461|502|6(?:0[1-4]|12|2[013]|[45]0|7[67]|8[78]|9[89])|7(?:02|88))\\d{4}",null,null,null,"2423456789",null,null,null,[7]],[null,null,"242(?:3(?:5[79]|7[56]|95)|4(?:[23][1-9]|4[1-35-9]|5[1-8]|6[2-8]|7\\d|81)|5(?:2[45]|3[35]|44|5[1-46-9]|65|77)|6[34]6|7(?:27|38)|8(?:0[1-9]|1[02-9]|2\\d|[89]9))\\d{4}",null,null,null,"2423591234",null,null,null,[7]],[null,null,"(?:242300|8(?:00|33|44|55|66|77|88)[2-9]\\d\\d)\\d{4}",null,null,null,"8002123456",null,null,null,[7]],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"242",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"242225[0-46-9]\\d{3}",null,null,null,"2422250123"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],CA:[null,[null,null,"(?:[2-8]\\d|90)\\d{8}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"(?:5(?:00|2[12]|33|44|66|77|88)|622)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"600[2-9]\\d{6}",null,null,null,"6002012345"],"CA",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DM:[null,[null,null,"(?:[58]\\d\\d|767|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"767(?:2(?:55|66)|4(?:2[01]|4[0-25-9])|50[0-4]|70[1-3])\\d{4}",null,null,null,"7674201234",null,null,null,[7]],[null,null,"767(?:2(?:[2-4689]5|7[5-7])|31[5-7]|61[1-7])\\d{4}",null,null,null,"7672251234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"767",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DO:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"8(?:[04]9[2-9]\\d\\d|29(?:2(?:[0-59]\\d|6[04-9]|7[0-27]|8[0237-9])|3(?:[0-35-9]\\d|4[7-9])|[45]\\d\\d|6(?:[0-27-9]\\d|[3-5][1-9]|6[0135-8])|7(?:0[013-9]|[1-37]\\d|4[1-35689]|5[1-4689]|6[1-57-9]|8[1-79]|9[1-8])|8(?:0[146-9]|1[0-48]|[248]\\d|3[1-79]|5[01589]|6[013-68]|7[124-8]|9[0-8])|9(?:[0-24]\\d|3[02-46-9]|5[0-79]|60|7[0169]|8[57-9]|9[02-9])))\\d{4}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8[024]9[2-9]\\d{6}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DO",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"8[024]9",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GD:[null,[null,null,"(?:473|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"473(?:2(?:3[0-2]|69)|3(?:2[89]|86)|4(?:[06]8|3[5-9]|4[0-49]|5[5-79]|73|90)|63[68]|7(?:58|84)|800|938)\\d{4}",null,null,null,"4732691234",null,null,null,[7]],[null,null,"473(?:4(?:0[2-79]|1[04-9]|2[0-5]|58)|5(?:2[01]|3[3-8])|901)\\d{4}",null,null,null,"4734031234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GD",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"473",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GU:[null,[null,null,"(?:[58]\\d\\d|671|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GU",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"671",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],JM:[null,[null,null,"(?:[58]\\d\\d|658|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:658[2-9]\\d\\d|876(?:5(?:0[12]|1[0-468]|2[35]|63)|6(?:0[1-3579]|1[0237-9]|[23]\\d|40|5[06]|6[2-589]|7[05]|8[04]|9[4-9])|7(?:0[2-689]|[1-6]\\d|8[056]|9[45])|9(?:0[1-8]|1[02378]|[2-8]\\d|9[2-468])))\\d{4}",null,null,null,"8765230123",null,null,null,[7]],[null,null,"876(?:(?:2[14-9]|[348]\\d)\\d|5(?:0[3-9]|[2-57-9]\\d|6[0-24-9])|7(?:0[07]|7\\d|8[1-47-9]|9[0-36-9])|9(?:[01]9|9[0579]))\\d{4}",null,null,null,"8762101234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"JM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"658|876",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KN:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"869(?:2(?:29|36)|302|4(?:6[015-9]|70))\\d{4}",null,null,null,"8692361234",null,null,null,[7]],[null,null,"869(?:5(?:5[6-8]|6[5-7])|66\\d|76[02-7])\\d{4}",null,null,null,"8697652917",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KN",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"869",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KY:[null,[null,null,"(?:345|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"345(?:2(?:22|44)|444|6(?:23|38|40)|7(?:4[35-79]|6[6-9]|77)|8(?:00|1[45]|25|[48]8)|9(?:14|4[035-9]))\\d{4}",null,null,null,"3452221234",null,null,null,[7]],[null,null,"345(?:32[1-9]|5(?:1[67]|2[5-79]|4[6-9]|50|76)|649|9(?:1[67]|2[2-9]|3[689]))\\d{4}",null,null,null,"3453231234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"(?:345976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KY",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"345849\\d{4}",null,null,null,"3458491234"],null,"345",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],LC:[null,[null,null,"(?:[58]\\d\\d|758|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"758(?:4(?:30|5\\d|6[2-9]|8[0-2])|57[0-2]|638)\\d{4}",null,null,null,"7584305678",null,null,null,[7]],[null,null,"758(?:28[4-7]|384|4(?:6[01]|8[4-9])|5(?:1[89]|20|84)|7(?:1[2-9]|2\\d|3[01]))\\d{4}",null,null,null,"7582845678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"LC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"758",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MP:[null,[null,null,"(?:[58]\\d\\d|(?:67|90)0)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MP",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"670",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MS:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d\\d|66449)\\d{5}",null,null,null,null,null,null,[10],[7]],[null,null,"664491\\d{4}",null,null,null,"6644912345",null,null,null,[7]],[null,null,"66449[2-6]\\d{4}",null,null,null,"6644923456",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"664",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],PR:[null,[null,null,"(?:[589]\\d\\d|787)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"PR",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"787|939",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],SX:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d|7215)\\d{6}",null,null,null,null,null,null,[10],[7]],[null,null,"7215(?:4[2-8]|8[239]|9[056])\\d{4}",null,null,null,"7215425678",null,null,null,[7]],[null,null,"7215(?:1[02]|2\\d|5[034679]|8[014-8])\\d{4}",null,null,null,"7215205678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"SX",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"721",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TC:[null,[null,null,"(?:[58]\\d\\d|649|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"649(?:712|9(?:4\\d|50))\\d{4}",null,null,null,"6497121234",null,null,null,[7]],[null,null,"649(?:2(?:3[129]|4[1-7])|3(?:3[1-389]|4[1-8])|4[34][1-3])\\d{4}",null,null,null,"6492311234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"64971[01]\\d{4}",null,null,null,"6497101234",null,null,null,[7]],"TC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"649",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TT:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"868(?:2(?:01|[23]\\d)|6(?:0[7-9]|1[02-8]|2[1-9]|[3-69]\\d|7[0-79])|82[124])\\d{4}",null,null,null,"8682211234",null,null,null,[7]],[null,null,"868(?:2(?:6[6-9]|[7-9]\\d)|[37](?:0[1-9]|1[02-9]|[2-9]\\d)|4[6-9]\\d|6(?:20|78|8\\d))\\d{4}",null,null,null,"8682911234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"TT",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"868",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,"868619\\d{4}",null,null,null,"8686191234",null,null,null,[7]]],US:[null,[null,null,"[2-9]\\d{9}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"US",1,"011","1",null,null,"1",null,null,1,[[null,"(\\d{3})(\\d{4})","$1-$2",["[2-9]"]],[null,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],null,null,1]],[[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[2-9]"]]],[null,null,null,null,null,null,null,null,null,[-1]],1,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"710[2-9]\\d{6}",null,null,null,"7102123456"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VC:[null,[null,null,"(?:[58]\\d\\d|784|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"784(?:266|3(?:6[6-9]|7\\d|8[0-24-6])|4(?:38|5[0-36-8]|8[0-8])|5(?:55|7[0-2]|93)|638|784)\\d{4}",null,null,null,"7842661234",null,null,null,[7]],[null,null,"784(?:4(?:3[0-5]|5[45]|89|9[0-8])|5(?:2[6-9]|3[0-4]))\\d{4}",null,null,null,"7844301234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"784",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VG:[null,[null,null,"(?:284|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"284(?:(?:229|774|8(?:52|6[459]))\\d|4(?:22\\d|9(?:[45]\\d|6[0-5])))\\d{3}",null,null,null,"2842291234",null,null,null,[7]],[null,null,"284(?:(?:3(?:0[0-3]|4[0-7]|68|9[34])|54[0-57])\\d|4(?:(?:4[0-6]|68)\\d|9(?:6[6-9]|9\\d)))\\d{3}",null,null,null,"2843001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"284",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VI:[null,[null,null,"(?:(?:34|90)0|[58]\\d\\d)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VI",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"340",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]]};V.b=function(){return V.a?V.a:V.a=new V};var or={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"},br=RegExp("[++]+"),et=RegExp("([0-90-9٠-٩۰-۹])"),Mr=/^\(?\$1\)?$/,Fr=new Ie;N(Fr,11,"NA");var dr=/\[([^\[\]])*\]/g,fr=/\d(?=[^,}][^,}])/g,Wt=RegExp("^[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*(\\$\\d[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*)+$"),Ot=/[- ]/;Te.prototype.K=function(){this.C="",n(this.i),n(this.u),n(this.m),this.s=0,this.w="",n(this.b),this.h="",n(this.a),this.l=!0,this.A=this.o=this.F=!1,this.f=[],this.B=!1,this.g!=this.J&&(this.g=re(this,this.D))},Te.prototype.L=function(L){return this.C=ne(this,L)},t("Cleave.AsYouTypeFormatter",Te),t("Cleave.AsYouTypeFormatter.prototype.inputDigit",Te.prototype.L),t("Cleave.AsYouTypeFormatter.prototype.clear",Te.prototype.K)}).call(typeof ln=="object"&&ln?ln:window);var uP=Object.defineProperty,lP=Object.getOwnPropertyDescriptor,Xd=(t,e,r,n)=>{for(var i=n>1?void 0:n?lP(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&uP(e,r,i),i};const cP=Ul.object({firstName:Ul.string().min(1,{message:"First name is required"}),lastName:Ul.string().min(1,{message:"Last name is required"}),email:Ul.string().email({message:"Invalid email address"}),phone:Ul.string().regex(/^(1-)?\d{3}-\d{3}-\d{4}$/,{message:"Invalid phone number"}).transform(t=>t.replace(/-/g,"").replace(/^1/,""))});let nu=class extends Jo{constructor(){super(...arguments),this.params={firstName:"",lastName:"",email:"",phone:""},this.errors=[]}firstUpdated(){this.phoneCleave=new L2(this.phoneInput,{phone:!0,phoneRegionCode:"US",delimiter:"-"})}submit(t){t.preventDefault();try{this.params=cP.parse(this.params)}catch(e){this.errors=e.errors;return}this.dispatchEvent(new CustomEvent("submit",{composed:!0,detail:this.params}))}cancel(){this.dispatchEvent(new CustomEvent("cancel"))}updateField(t,e){this.params={...this.params,[t]:e}}render(){return Hd`
43
+ */function uO(t,e,r){return t?e(t):r==null?void 0:r(t)}var pr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(pr||(pr={}));var ov;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ov||(ov={}));const mt=pr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ja=t=>{switch(typeof t){case"undefined":return mt.undefined;case"string":return mt.string;case"number":return isNaN(t)?mt.nan:mt.number;case"boolean":return mt.boolean;case"function":return mt.function;case"bigint":return mt.bigint;case"symbol":return mt.symbol;case"object":return Array.isArray(t)?mt.array:t===null?mt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?mt.promise:typeof Map<"u"&&t instanceof Map?mt.map:typeof Set<"u"&&t instanceof Set?mt.set:typeof Date<"u"&&t instanceof Date?mt.date:mt.object;default:return mt.unknown}},nt=pr.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"]),lO=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Zn extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}static assert(e){if(!(e instanceof Zn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Zn.create=t=>new Zn(t);const Yo=(t,e)=>{let r;switch(t.code){case nt.invalid_type:t.received===mt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case nt.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,pr.jsonStringifyReplacer)}`;break;case nt.unrecognized_keys:r=`Unrecognized key(s) in object: ${pr.joinValues(t.keys,", ")}`;break;case nt.invalid_union:r="Invalid input";break;case nt.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${pr.joinValues(t.options)}`;break;case nt.invalid_enum_value:r=`Invalid enum value. Expected ${pr.joinValues(t.options)}, received '${t.received}'`;break;case nt.invalid_arguments:r="Invalid function arguments";break;case nt.invalid_return_type:r="Invalid function return type";break;case nt.invalid_date:r="Invalid date";break;case nt.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}"`:pr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case nt.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==="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 nt.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 nt.custom:r="Invalid input";break;case nt.invalid_intersection_types:r="Intersection results could not be merged";break;case nt.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case nt.not_finite:r="Number must be finite";break;default:r=e.defaultError,pr.assertNever(t)}return{message:r}};let h0=Yo;function cO(t){h0=t}function Vd(){return h0}const Wd=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:o}},dO=[];function ft(t,e){const r=Vd(),n=Wd({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Yo?void 0:Yo].filter(i=>!!i)});t.common.issues.push(n)}class mn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return qt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r){const a=await i.key,s=await i.value;n.push({key:a,value:s})}return mn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return qt;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const qt=Object.freeze({status:"aborted"}),Qo=t=>({status:"dirty",value:t}),Tn=t=>({status:"valid",value:t}),uv=t=>t.status==="aborted",lv=t=>t.status==="dirty",kl=t=>t.status==="valid",Sl=t=>typeof Promise<"u"&&t instanceof Promise;function Zd(t,e,r,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function p0(t,e,r,n,i){if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}typeof SuppressedError=="function"&&SuppressedError;var Mt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Mt||(Mt={}));var $l,Tl;class zi{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const v0=(t,e)=>{if(kl(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 Zn(t.common.issues);return this._error=r,this._error}}};function rr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,o)=>{var u,l;const{message:c}=t;return s.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:(u=c??n)!==null&&u!==void 0?u:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(l=c??r)!==null&&l!==void 0?l:o.defaultError}},description:i}}class ur{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)}get description(){return this._def.description}_getType(e){return Ja(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ja(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new mn,ctx:{common:e.parent.common,data:e.data,parsedType:Ja(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Sl(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 n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ja(e)},a=this._parseSync({data:e,path:i.path,parent:i});return v0(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={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:Ja(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(Sl(i)?i:Promise.resolve(i));return v0(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:nt.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new ki({schema:this,typeName:Ft.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return qi.create(this,this._def)}nullable(){return es.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _i.create(this,this._def)}promise(){return ru.create(this,this._def)}or(e){return xl.create([this,e],this._def)}and(e){return Il.create(this,e,this._def)}transform(e){return new ki({...rr(this._def),schema:this,typeName:Ft.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Nl({...rr(this._def),innerType:this,defaultValue:r,typeName:Ft.ZodDefault})}brand(){return new fv({typeName:Ft.ZodBranded,type:this,...rr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Ll({...rr(this._def),innerType:this,catchValue:r,typeName:Ft.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Dl.create(this,e)}readonly(){return jl.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const fO=/^c[^\s-]{8,}$/i,hO=/^[0-9a-z]+$/,pO=/^[0-9A-HJKMNP-TV-Z]{26}$/,vO=/^[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,mO=/^[a-z0-9_-]{21}$/i,gO=/^[-+]?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)?)??$/,yO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let cv;const wO=/^(?:(?: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])$/,_O=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,kO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,m0="((\\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])))",SO=new RegExp(`^${m0}$`);function g0(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function $O(t){return new RegExp(`^${g0(t)}$`)}function y0(t){let e=`${m0}T${g0(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 TO(t,e){return!!((e==="v4"||!e)&&wO.test(t)||(e==="v6"||!e)&&_O.test(t))}class wi extends ur{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==mt.string){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.string,received:a.parsedType}),qt}const n=new mn;let i;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const s=e.data.length>a.value,o=e.data.length<a.value;(s||o)&&(i=this._getOrReturnCtx(e,i),s?ft(i,{code:nt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&ft(i,{code:nt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")yO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"email",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")cv||(cv=new RegExp(bO,"u")),cv.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"emoji",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")vO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"uuid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")mO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"nanoid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")fO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"cuid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")hO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"cuid2",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")pO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"ulid",code:nt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),ft(i,{validation:"url",code:nt.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"regex",code:nt.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?y0(a).test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?SO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?$O(a).test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?gO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"duration",code:nt.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?TO(e.data,a.version)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"ip",code:nt.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?kO.test(e.data)||(i=this._getOrReturnCtx(e,i),ft(i,{validation:"base64",code:nt.invalid_string,message:a.message}),n.dirty()):pr.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:nt.invalid_string,...Mt.errToObj(n)})}_addCheck(e){return new wi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Mt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Mt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Mt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Mt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Mt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Mt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Mt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Mt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Mt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Mt.errToObj(e)})}datetime(e){var r,n;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:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Mt.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,...Mt.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Mt.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Mt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Mt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Mt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Mt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Mt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Mt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Mt.errToObj(r)})}nonempty(e){return this.min(1,Mt.errToObj(e))}trim(){return new wi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wi({...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 isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}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}}wi.create=t=>{var e;return new wi({checks:[],typeName:Ft.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};function EO(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class Ya extends ur{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)!==mt.number){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.number,received:a.parsedType}),qt}let n;const i=new mn;for(const a of this._def.checks)a.kind==="int"?pr.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?EO(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_finite,message:a.message}),i.dirty()):pr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Mt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Mt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Mt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Mt.toString(r))}setLimit(e,r,n,i){return new Ya({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Mt.toString(i)}]})}_addCheck(e){return new Ya({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Mt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Mt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Mt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Mt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Mt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Mt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Mt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Mt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Mt.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"&&pr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}Ya.create=t=>new Ya({checks:[],typeName:Ft.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class Qa extends ur{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==mt.bigint){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.bigint,received:a.parsedType}),qt}let n;const i=new mn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ft(n,{code:nt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):pr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Mt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Mt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Mt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Mt.toString(r))}setLimit(e,r,n,i){return new Qa({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Mt.toString(i)}]})}_addCheck(e){return new Qa({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Mt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Mt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Mt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Mt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Mt.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}}Qa.create=t=>{var e;return new Qa({checks:[],typeName:Ft.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};class El extends ur{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==mt.boolean){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.boolean,received:n.parsedType}),qt}return Tn(e.data)}}El.create=t=>new El({typeName:Ft.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class qs extends ur{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==mt.date){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_type,expected:mt.date,received:a.parsedType}),qt}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return ft(a,{code:nt.invalid_date}),qt}const n=new mn;let i;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),ft(i,{code:nt.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):pr.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new qs({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Mt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Mt.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}}qs.create=t=>new qs({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Ft.ZodDate,...rr(t)});class Gd extends ur{_parse(e){if(this._getType(e)!==mt.symbol){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.symbol,received:n.parsedType}),qt}return Tn(e.data)}}Gd.create=t=>new Gd({typeName:Ft.ZodSymbol,...rr(t)});class Cl extends ur{_parse(e){if(this._getType(e)!==mt.undefined){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.undefined,received:n.parsedType}),qt}return Tn(e.data)}}Cl.create=t=>new Cl({typeName:Ft.ZodUndefined,...rr(t)});class Rl extends ur{_parse(e){if(this._getType(e)!==mt.null){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.null,received:n.parsedType}),qt}return Tn(e.data)}}Rl.create=t=>new Rl({typeName:Ft.ZodNull,...rr(t)});class Xo extends ur{constructor(){super(...arguments),this._any=!0}_parse(e){return Tn(e.data)}}Xo.create=t=>new Xo({typeName:Ft.ZodAny,...rr(t)});class Vs extends ur{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Tn(e.data)}}Vs.create=t=>new Vs({typeName:Ft.ZodUnknown,...rr(t)});class ma extends ur{_parse(e){const r=this._getOrReturnCtx(e);return ft(r,{code:nt.invalid_type,expected:mt.never,received:r.parsedType}),qt}}ma.create=t=>new ma({typeName:Ft.ZodNever,...rr(t)});class Kd extends ur{_parse(e){if(this._getType(e)!==mt.undefined){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.void,received:n.parsedType}),qt}return Tn(e.data)}}Kd.create=t=>new Kd({typeName:Ft.ZodVoid,...rr(t)});class _i extends ur{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==mt.array)return ft(r,{code:nt.invalid_type,expected:mt.array,received:r.parsedType}),qt;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(ft(r,{code:s?nt.too_big:nt.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(ft(r,{code:nt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(ft(r,{code:nt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new zi(r,s,r.path,o)))).then(s=>mn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new zi(r,s,r.path,o)));return mn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new _i({...this._def,minLength:{value:e,message:Mt.toString(r)}})}max(e,r){return new _i({...this._def,maxLength:{value:e,message:Mt.toString(r)}})}length(e,r){return new _i({...this._def,exactLength:{value:e,message:Mt.toString(r)}})}nonempty(e){return this.min(1,e)}}_i.create=(t,e)=>new _i({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ft.ZodArray,...rr(e)});function eu(t){if(t instanceof Wr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=qi.create(eu(n))}return new Wr({...t._def,shape:()=>e})}else return t instanceof _i?new _i({...t._def,type:eu(t.element)}):t instanceof qi?qi.create(eu(t.unwrap())):t instanceof es?es.create(eu(t.unwrap())):t instanceof Hi?Hi.create(t.items.map(e=>eu(e))):t}class Wr extends ur{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=pr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==mt.object){const l=this._getOrReturnCtx(e);return ft(l,{code:nt.invalid_type,expected:mt.object,received:l.parsedType}),qt}const{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof ma&&this._def.unknownKeys==="strip"))for(const l in i.data)s.includes(l)||o.push(l);const u=[];for(const l of s){const c=a[l],d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new zi(i,d,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof ma){const l=this._def.unknownKeys;if(l==="passthrough")for(const c of o)u.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(l==="strict")o.length>0&&(ft(i,{code:nt.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const c of o){const d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new zi(i,d,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const l=[];for(const c of u){const d=await c.key,f=await c.value;l.push({key:d,value:f,alwaysSet:c.alwaysSet})}return l}).then(l=>mn.mergeObjectSync(n,l)):mn.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Mt.errToObj,new Wr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Mt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Wr({...this._def,unknownKeys:"strip"})}passthrough(){return new Wr({...this._def,unknownKeys:"passthrough"})}extend(e){return new Wr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Wr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ft.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Wr({...this._def,catchall:e})}pick(e){const r={};return pr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Wr({...this._def,shape:()=>r})}omit(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Wr({...this._def,shape:()=>r})}deepPartial(){return eu(this)}partial(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new Wr({...this._def,shape:()=>r})}required(e){const r={};return pr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof qi;)a=a._def.innerType;r[n]=a}}),new Wr({...this._def,shape:()=>r})}keyof(){return b0(pr.objectKeys(this.shape))}}Wr.create=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strip",catchall:ma.create(),typeName:Ft.ZodObject,...rr(e)}),Wr.strictCreate=(t,e)=>new Wr({shape:()=>t,unknownKeys:"strict",catchall:ma.create(),typeName:Ft.ZodObject,...rr(e)}),Wr.lazycreate=(t,e)=>new Wr({shape:t,unknownKeys:"strip",catchall:ma.create(),typeName:Ft.ZodObject,...rr(e)});class xl extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new Zn(o.ctx.common.issues));return ft(r,{code:nt.invalid_union,unionErrors:s}),qt}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new Zn(u));return ft(r,{code:nt.invalid_union,unionErrors:o}),qt}}get options(){return this._def.options}}xl.create=(t,e)=>new xl({options:t,typeName:Ft.ZodUnion,...rr(e)});const ga=t=>t instanceof Ol?ga(t.schema):t instanceof ki?ga(t.innerType()):t instanceof Pl?[t.value]:t instanceof Xa?t.options:t instanceof Ml?pr.objectValues(t.enum):t instanceof Nl?ga(t._def.innerType):t instanceof Cl?[void 0]:t instanceof Rl?[null]:t instanceof qi?[void 0,...ga(t.unwrap())]:t instanceof es?[null,...ga(t.unwrap())]:t instanceof fv||t instanceof jl?ga(t.unwrap()):t instanceof Ll?ga(t._def.innerType):[];class Jd extends ur{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.object)return ft(r,{code:nt.invalid_type,expected:mt.object,received:r.parsedType}),qt;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(ft(r,{code:nt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),qt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=ga(a.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new Jd({typeName:Ft.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...rr(n)})}}function dv(t,e){const r=Ja(t),n=Ja(e);if(t===e)return{valid:!0,data:t};if(r===mt.object&&n===mt.object){const i=pr.objectKeys(e),a=pr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=dv(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===mt.array&&n===mt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=dv(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===mt.date&&n===mt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Il extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(uv(a)||uv(s))return qt;const o=dv(a.value,s.value);return o.valid?((lv(a)||lv(s))&&r.dirty(),{status:r.value,value:o.data}):(ft(n,{code:nt.invalid_intersection_types}),qt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Il.create=(t,e,r)=>new Il({left:t,right:e,typeName:Ft.ZodIntersection,...rr(r)});class Hi extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.array)return ft(n,{code:nt.invalid_type,expected:mt.array,received:n.parsedType}),qt;if(n.data.length<this._def.items.length)return ft(n,{code:nt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),qt;!this._def.rest&&n.data.length>this._def.items.length&&(ft(n,{code:nt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((s,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new zi(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(a).then(s=>mn.mergeArray(r,s)):mn.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Hi({...this._def,rest:e})}}Hi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Hi({items:t,typeName:Ft.ZodTuple,rest:null,...rr(e)})};class Al extends ur{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.object)return ft(n,{code:nt.invalid_type,expected:mt.object,received:n.parsedType}),qt;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new zi(n,o,n.path,o)),value:s._parse(new zi(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?mn.mergeObjectAsync(r,i):mn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof ur?new Al({keyType:e,valueType:r,typeName:Ft.ZodRecord,...rr(n)}):new Al({keyType:wi.create(),valueType:e,typeName:Ft.ZodRecord,...rr(r)})}}class Yd extends ur{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.map)return ft(n,{code:nt.invalid_type,expected:mt.map,received:n.parsedType}),qt;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new zi(n,o,n.path,[l,"key"])),value:a._parse(new zi(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}Yd.create=(t,e,r)=>new Yd({valueType:e,keyType:t,typeName:Ft.ZodMap,...rr(r)});class Ws extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==mt.set)return ft(n,{code:nt.invalid_type,expected:mt.set,received:n.parsedType}),qt;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(ft(n,{code:nt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(ft(n,{code:nt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return qt;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new zi(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new Ws({...this._def,minSize:{value:e,message:Mt.toString(r)}})}max(e,r){return new Ws({...this._def,maxSize:{value:e,message:Mt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Ws.create=(t,e)=>new Ws({valueType:t,minSize:null,maxSize:null,typeName:Ft.ZodSet,...rr(e)});class tu extends ur{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.function)return ft(r,{code:nt.invalid_type,expected:mt.function,received:r.parsedType}),qt;function n(o,u){return Wd({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Vd(),Yo].filter(l=>!!l),issueData:{code:nt.invalid_arguments,argumentsError:u}})}function i(o,u){return Wd({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Vd(),Yo].filter(l=>!!l),issueData:{code:nt.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof ru){const o=this;return Tn(async function(...u){const l=new Zn([]),c=await o._def.args.parseAsync(u,a).catch(m=>{throw l.addIssue(n(u,m)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(m=>{throw l.addIssue(i(d,m)),l})})}else{const o=this;return Tn(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Zn([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new Zn([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new tu({...this._def,args:Hi.create(e).rest(Vs.create())})}returns(e){return new tu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new tu({args:e||Hi.create([]).rest(Vs.create()),returns:r||Vs.create(),typeName:Ft.ZodFunction,...rr(n)})}}class Ol extends ur{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})}}Ol.create=(t,e)=>new Ol({getter:t,typeName:Ft.ZodLazy,...rr(e)});class Pl extends ur{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return ft(r,{received:r.data,code:nt.invalid_literal,expected:this._def.value}),qt}return{status:"valid",value:e.data}}get value(){return this._def.value}}Pl.create=(t,e)=>new Pl({value:t,typeName:Ft.ZodLiteral,...rr(e)});function b0(t,e){return new Xa({values:t,typeName:Ft.ZodEnum,...rr(e)})}class Xa extends ur{constructor(){super(...arguments),$l.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return ft(r,{expected:pr.joinValues(n),received:r.parsedType,code:nt.invalid_type}),qt}if(Zd(this,$l)||p0(this,$l,new Set(this._def.values)),!Zd(this,$l).has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return ft(r,{received:r.data,code:nt.invalid_enum_value,options:n}),qt}return Tn(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 Xa.create(e,{...this._def,...r})}exclude(e,r=this._def){return Xa.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}$l=new WeakMap,Xa.create=b0;class Ml extends ur{constructor(){super(...arguments),Tl.set(this,void 0)}_parse(e){const r=pr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==mt.string&&n.parsedType!==mt.number){const i=pr.objectValues(r);return ft(n,{expected:pr.joinValues(i),received:n.parsedType,code:nt.invalid_type}),qt}if(Zd(this,Tl)||p0(this,Tl,new Set(pr.getValidEnumValues(this._def.values))),!Zd(this,Tl).has(e.data)){const i=pr.objectValues(r);return ft(n,{received:n.data,code:nt.invalid_enum_value,options:i}),qt}return Tn(e.data)}get enum(){return this._def.values}}Tl=new WeakMap,Ml.create=(t,e)=>new Ml({values:t,typeName:Ft.ZodNativeEnum,...rr(e)});class ru extends ur{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==mt.promise&&r.common.async===!1)return ft(r,{code:nt.invalid_type,expected:mt.promise,received:r.parsedType}),qt;const n=r.parsedType===mt.promise?r.data:Promise.resolve(r.data);return Tn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}ru.create=(t,e)=>new ru({type:t,typeName:Ft.ZodPromise,...rr(e)});class ki extends ur{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ft.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{ft(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);if(n.common.async)return Promise.resolve(s).then(async o=>{if(r.value==="aborted")return qt;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?qt:u.status==="dirty"||r.value==="dirty"?Qo(u.value):u});{if(r.value==="aborted")return qt;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?qt:o.status==="dirty"||r.value==="dirty"?Qo(o.value):o}}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?qt:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?qt:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kl(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>kl(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);pr.assertNever(i)}}ki.create=(t,e,r)=>new ki({schema:t,typeName:Ft.ZodEffects,effect:e,...rr(r)}),ki.createWithPreprocess=(t,e,r)=>new ki({schema:e,effect:{type:"preprocess",transform:t},typeName:Ft.ZodEffects,...rr(r)});class qi extends ur{_parse(e){return this._getType(e)===mt.undefined?Tn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}qi.create=(t,e)=>new qi({innerType:t,typeName:Ft.ZodOptional,...rr(e)});class es extends ur{_parse(e){return this._getType(e)===mt.null?Tn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}es.create=(t,e)=>new es({innerType:t,typeName:Ft.ZodNullable,...rr(e)});class Nl extends ur{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===mt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Nl.create=(t,e)=>new Nl({innerType:t,typeName:Ft.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...rr(e)});class Ll extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Sl(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Zn(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Zn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ll.create=(t,e)=>new Ll({innerType:t,typeName:Ft.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...rr(e)});class Qd extends ur{_parse(e){if(this._getType(e)!==mt.nan){const n=this._getOrReturnCtx(e);return ft(n,{code:nt.invalid_type,expected:mt.nan,received:n.parsedType}),qt}return{status:"valid",value:e.data}}}Qd.create=t=>new Qd({typeName:Ft.ZodNaN,...rr(t)});const CO=Symbol("zod_brand");class fv extends ur{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Dl extends ur{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?qt:a.status==="dirty"?(r.dirty(),Qo(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?qt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new Dl({in:e,out:r,typeName:Ft.ZodPipeline})}}class jl extends ur{_parse(e){const r=this._def.innerType._parse(e),n=i=>(kl(i)&&(i.value=Object.freeze(i.value)),i);return Sl(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}}jl.create=(t,e)=>new jl({innerType:t,typeName:Ft.ZodReadonly,...rr(e)});function w0(t,e={},r){return t?Xo.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):Xo.create()}const RO={object:Wr.lazycreate};var Ft;(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"})(Ft||(Ft={}));const xO=(t,e={message:`Input not instance of ${t.name}`})=>w0(r=>r instanceof t,e),_0=wi.create,k0=Ya.create,IO=Qd.create,AO=Qa.create,S0=El.create,OO=qs.create,PO=Gd.create,MO=Cl.create,NO=Rl.create,LO=Xo.create,DO=Vs.create,jO=ma.create,UO=Kd.create,FO=_i.create,BO=Wr.create,zO=Wr.strictCreate,HO=xl.create,qO=Jd.create,VO=Il.create,WO=Hi.create,ZO=Al.create,GO=Yd.create,KO=Ws.create,JO=tu.create,YO=Ol.create,QO=Pl.create,XO=Xa.create,eP=Ml.create,tP=ru.create,$0=ki.create,rP=qi.create,nP=es.create,iP=ki.createWithPreprocess,aP=Dl.create;var Ul=Object.freeze({__proto__:null,defaultErrorMap:Yo,setErrorMap:cO,getErrorMap:Vd,makeIssue:Wd,EMPTY_PATH:dO,addIssueToContext:ft,ParseStatus:mn,INVALID:qt,DIRTY:Qo,OK:Tn,isAborted:uv,isDirty:lv,isValid:kl,isAsync:Sl,get util(){return pr},get objectUtil(){return ov},ZodParsedType:mt,getParsedType:Ja,ZodType:ur,datetimeRegex:y0,ZodString:wi,ZodNumber:Ya,ZodBigInt:Qa,ZodBoolean:El,ZodDate:qs,ZodSymbol:Gd,ZodUndefined:Cl,ZodNull:Rl,ZodAny:Xo,ZodUnknown:Vs,ZodNever:ma,ZodVoid:Kd,ZodArray:_i,ZodObject:Wr,ZodUnion:xl,ZodDiscriminatedUnion:Jd,ZodIntersection:Il,ZodTuple:Hi,ZodRecord:Al,ZodMap:Yd,ZodSet:Ws,ZodFunction:tu,ZodLazy:Ol,ZodLiteral:Pl,ZodEnum:Xa,ZodNativeEnum:Ml,ZodPromise:ru,ZodEffects:ki,ZodTransformer:ki,ZodOptional:qi,ZodNullable:es,ZodDefault:Nl,ZodCatch:Ll,ZodNaN:Qd,BRAND:CO,ZodBranded:fv,ZodPipeline:Dl,ZodReadonly:jl,custom:w0,Schema:ur,ZodSchema:ur,late:RO,get ZodFirstPartyTypeKind(){return Ft},coerce:{string:t=>wi.create({...t,coerce:!0}),number:t=>Ya.create({...t,coerce:!0}),boolean:t=>El.create({...t,coerce:!0}),bigint:t=>Qa.create({...t,coerce:!0}),date:t=>qs.create({...t,coerce:!0})},any:LO,array:FO,bigint:AO,boolean:S0,date:OO,discriminatedUnion:qO,effect:$0,enum:XO,function:JO,instanceof:xO,intersection:VO,lazy:YO,literal:QO,map:GO,nan:IO,nativeEnum:eP,never:jO,null:NO,nullable:nP,number:k0,object:BO,oboolean:()=>S0().optional(),onumber:()=>k0().optional(),optional:rP,ostring:()=>_0().optional(),pipeline:aP,preprocess:iP,promise:tP,record:ZO,set:KO,strictObject:zO,string:_0,symbol:PO,transformer:$0,tuple:WO,undefined:MO,union:HO,unknown:DO,void:UO,NEVER:qt,ZodIssueCode:nt,quotelessJson:lO,ZodError:Zn});const T0=j2`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.static{position:static}.relative{position:relative}.my-4{margin-top:1rem;margin-bottom:1rem}.mb-4{margin-bottom:1rem}.mt-4{margin-top:1rem}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rounded{border-radius:.25rem}.border{border-width:1px}.border-red-400{--tw-border-opacity: 1;border-color:rgb(248 113 113 / var(--tw-border-opacity))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity))}.px-4{padding-left:1rem;padding-right:1rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}input{width:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-radius:.25rem;border-width:1px;padding:.5rem .75rem;line-height:1.25;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity));--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}label{margin-bottom:.5rem;display:block;font-size:.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-primary{border-radius:.25rem;padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.btn-primary:hover{opacity:.95}.btn-primary:disabled{pointer-events:none;opacity:.5}.btn-primary{background-color:var(--iai-chat-i-button-bg);color:var(--iai-chat-i-button-fg)}.btn-secondary{padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-secondary:hover{opacity:.95}.btn-secondary:disabled{pointer-events:none;opacity:.5}`;var ln=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sP(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function oP(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}(function(){function t(L,W){var ie=L.split("."),He=ce;ie[0]in He||!He.execScript||He.execScript("var "+ie[0]);for(var ct;ie.length&&(ct=ie.shift());)ie.length||W===void 0?He=He[ct]?He[ct]:He[ct]={}:He[ct]=W}function e(L,W){function ie(){}ie.prototype=W.prototype,L.M=W.prototype,L.prototype=new ie,L.prototype.constructor=L,L.N=function(He,ct,bt){for(var zt=Array(arguments.length-2),tr=2;tr<arguments.length;tr++)zt[tr-2]=arguments[tr];return W.prototype[ct].apply(He,zt)}}function r(L,W){L!=null&&this.a.apply(this,arguments)}function n(L){L.b=""}function i(L,W){L.sort(W||a)}function a(L,W){return L>W?1:L<W?-1:0}function s(L){var W,ie=[],He=0;for(W in L)ie[He++]=L[W];return ie}function o(L,W){this.b=L,this.a={};for(var ie=0;ie<W.length;ie++){var He=W[ie];this.a[He.b]=He}}function u(L){return L=s(L.a),i(L,function(W,ie){return W.b-ie.b}),L}function l(L,W){switch(this.b=L,this.g=!!W.v,this.a=W.c,this.i=W.type,this.h=!1,this.a){case be:case pt:case Ze:case Jt:case At:case Be:case Ke:this.h=!0}this.f=W.defaultValue}function c(){this.a={},this.f=this.j().a,this.b=this.g=null}function d(L,W){for(var ie=u(L.j()),He=0;He<ie.length;He++){var ct=ie[He],bt=ct.b;if(W.a[bt]!=null){L.b&&delete L.b[ct.b];var zt=ct.a==11||ct.a==10;if(ct.g)for(var ct=f(W,bt)||[],tr=0;tr<ct.length;tr++){var Re=L,Ne=bt,pe=zt?ct[tr].clone():ct[tr];Re.a[Ne]||(Re.a[Ne]=[]),Re.a[Ne].push(pe),Re.b&&delete Re.b[Ne]}else ct=f(W,bt),zt?(zt=f(L,bt))?d(zt,ct):N(L,bt,ct.clone()):N(L,bt,ct)}}}function f(L,W){var ie=L.a[W];if(ie==null)return null;if(L.g){if(!(W in L.b)){var He=L.g,ct=L.f[W];if(ie!=null)if(ct.g){for(var bt=[],zt=0;zt<ie.length;zt++)bt[zt]=He.b(ct,ie[zt]);ie=bt}else ie=He.b(ct,ie);return L.b[W]=ie}return L.b[W]}return ie}function m(L,W,ie){var He=f(L,W);return L.f[W].g?He[ie||0]:He}function b(L,W){var ie;if(L.a[W]!=null)ie=m(L,W,void 0);else e:{if(ie=L.f[W],ie.f===void 0){var He=ie.i;if(He===Boolean)ie.f=!1;else if(He===Number)ie.f=0;else{if(He!==String){ie=new He;break e}ie.f=ie.h?"0":""}}ie=ie.f}return ie}function A(L,W){return L.f[W].g?L.a[W]!=null?L.a[W].length:0:L.a[W]!=null?1:0}function N(L,W,ie){L.a[W]=ie,L.b&&(L.b[W]=ie)}function z(L,W){var ie,He=[];for(ie in W)ie!=0&&He.push(new l(ie,W[ie]));return new o(L,He)}function X(){c.call(this)}function Ee(){c.call(this)}function Ie(){c.call(this)}function Fe(){}function Oe(){}function ze(){}function V(){this.a={}}function xe(L){return L.length==0||Mr.test(L)}function _e(L,W){if(W==null)return null;W=W.toUpperCase();var ie=L.a[W];if(ie==null){if(ie=ut[W],ie==null)return null;ie=new ze().a(Ie.j(),ie),L.a[W]=ie}return ie}function se(L){return L=St[L],L==null?"ZZ":L[0]}function Te(L){this.H=RegExp(" "),this.C="",this.m=new r,this.w="",this.i=new r,this.u=new r,this.l=!0,this.A=this.o=this.F=!1,this.G=V.b(),this.s=0,this.b=new r,this.B=!1,this.h="",this.a=new r,this.f=[],this.D=L,this.J=this.g=re(this,this.D)}function re(L,W){var ie;if(W!=null&&isNaN(W)&&W.toUpperCase()in ut){if(ie=_e(L.G,W),ie==null)throw Error("Invalid region code: "+W);ie=b(ie,10)}else ie=0;return ie=_e(L.G,se(ie)),ie??Fr}function oe(L){for(var W=L.f.length,ie=0;ie<W;++ie){var He=L.f[ie],ct=b(He,1);if(L.w==ct)return!1;var bt;bt=L;var zt=He,tr=b(zt,1);if(tr.indexOf("|")!=-1)bt=!1;else{tr=tr.replace(dr,"\\d"),tr=tr.replace(fr,"\\d"),n(bt.m);var Re;Re=bt;var zt=b(zt,2),Ne="999999999999999".match(tr)[0];Ne.length<Re.a.b.length?Re="":(Re=Ne.replace(new RegExp(tr,"g"),zt),Re=Re.replace(RegExp("9","g")," ")),0<Re.length?(bt.m.a(Re),bt=!0):bt=!1}if(bt)return L.w=ct,L.B=Ot.test(m(He,4)),L.s=0,!0}return L.l=!1}function q(L,W){for(var ie=[],He=W.length-3,ct=L.f.length,bt=0;bt<ct;++bt){var zt=L.f[bt];A(zt,3)==0?ie.push(L.f[bt]):(zt=m(zt,3,Math.min(He,A(zt,3)-1)),W.search(zt)==0&&ie.push(L.f[bt]))}L.f=ie}function ne(L,W){L.i.a(W);var ie=W;if(et.test(ie)||L.i.b.length==1&&br.test(ie)){var He,ie=W;ie=="+"?(He=ie,L.u.a(ie)):(He=or[ie],L.u.a(He),L.a.a(He)),W=He}else L.l=!1,L.F=!0;if(!L.l){if(!L.F){if(Ct(L)){if(rt(L))return Se(L)}else if(0<L.h.length&&(ie=L.a.toString(),n(L.a),L.a.a(L.h),L.a.a(ie),ie=L.b.toString(),He=ie.lastIndexOf(L.h),n(L.b),L.b.a(ie.substring(0,He))),L.h!=Xe(L))return L.b.a(" "),Se(L)}return L.i.toString()}switch(L.u.b.length){case 0:case 1:case 2:return L.i.toString();case 3:if(!Ct(L))return L.h=Xe(L),ke(L);L.A=!0;default:return L.A?(rt(L)&&(L.A=!1),L.b.toString()+L.a.toString()):0<L.f.length?(ie=je(L,W),He=H(L),0<He.length?He:(q(L,L.a.toString()),oe(L)?M(L):L.l?ye(L,ie):L.i.toString())):ke(L)}}function Se(L){return L.l=!0,L.A=!1,L.f=[],L.s=0,n(L.m),L.w="",ke(L)}function H(L){for(var W=L.a.toString(),ie=L.f.length,He=0;He<ie;++He){var ct=L.f[He],bt=b(ct,1);if(new RegExp("^(?:"+bt+")$").test(W))return L.B=Ot.test(m(ct,4)),W=W.replace(new RegExp(bt,"g"),m(ct,2)),ye(L,W)}return""}function ye(L,W){var ie=L.b.b.length;return L.B&&0<ie&&L.b.toString().charAt(ie-1)!=" "?L.b+" "+W:L.b+W}function ke(L){var W=L.a.toString();if(3<=W.length){for(var ie=L.o&&L.h.length==0&&0<A(L.g,20)?f(L.g,20)||[]:f(L.g,19)||[],He=ie.length,ct=0;ct<He;++ct){var bt=ie[ct];0<L.h.length&&xe(b(bt,4))&&!m(bt,6)&&bt.a[5]==null||(L.h.length!=0||L.o||xe(b(bt,4))||m(bt,6))&&Wt.test(b(bt,2))&&L.f.push(bt)}return q(L,W),W=H(L),0<W.length?W:oe(L)?M(L):L.i.toString()}return ye(L,W)}function M(L){var W=L.a.toString(),ie=W.length;if(0<ie){for(var He="",ct=0;ct<ie;ct++)He=je(L,W.charAt(ct));return L.l?ye(L,He):L.i.toString()}return L.b.toString()}function Xe(L){var W,ie=L.a.toString(),He=0;return m(L.g,10)!=1?W=!1:(W=L.a.toString(),W=W.charAt(0)=="1"&&W.charAt(1)!="0"&&W.charAt(1)!="1"),W?(He=1,L.b.a("1").a(" "),L.o=!0):L.g.a[15]!=null&&(W=new RegExp("^(?:"+m(L.g,15)+")"),W=ie.match(W),W!=null&&W[0]!=null&&0<W[0].length&&(L.o=!0,He=W[0].length,L.b.a(ie.substring(0,He)))),n(L.a),L.a.a(ie.substring(He)),ie.substring(0,He)}function Ct(L){var W=L.u.toString(),ie=new RegExp("^(?:\\+|"+m(L.g,11)+")"),ie=W.match(ie);return ie!=null&&ie[0]!=null&&0<ie[0].length&&(L.o=!0,ie=ie[0].length,n(L.a),L.a.a(W.substring(ie)),n(L.b),L.b.a(W.substring(0,ie)),W.charAt(0)!="+"&&L.b.a(" "),!0)}function rt(L){if(L.a.b.length==0)return!1;var W,ie=new r;e:{if(W=L.a.toString(),W.length!=0&&W.charAt(0)!="0"){for(var He,ct=W.length,bt=1;3>=bt&&bt<=ct;++bt)if(He=parseInt(W.substring(0,bt),10),He in St){ie.a(W.substring(bt)),W=He;break e}}W=0}return W!=0&&(n(L.a),L.a.a(ie.toString()),ie=se(W),ie=="001"?L.g=_e(L.G,""+W):ie!=L.D&&(L.g=re(L,ie)),L.b.a(""+W).a(" "),L.h="",!0)}function je(L,W){var ie=L.m.toString();if(0<=ie.substring(L.s).search(L.H)){var He=ie.search(L.H),ie=ie.replace(L.H,W);return n(L.m),L.m.a(ie),L.s=He,ie.substring(0,L.s+1)}return L.f.length==1&&(L.l=!1),L.w="",L.i.toString()}var ce=this;r.prototype.b="",r.prototype.set=function(L){this.b=""+L},r.prototype.a=function(L,W,ie){if(this.b+=String(L),W!=null)for(var He=1;He<arguments.length;He++)this.b+=arguments[He];return this},r.prototype.toString=function(){return this.b};var Ke=1,Be=2,be=3,pt=4,Ze=6,Jt=16,At=18;c.prototype.set=function(L,W){N(this,L.b,W)},c.prototype.clone=function(){var L=new this.constructor;return L!=this&&(L.a={},L.b&&(L.b={}),d(L,this)),L},e(X,c);var Q=null;e(Ee,c);var Ue=null;e(Ie,c);var ot=null;X.prototype.j=function(){var L=Q;return L||(Q=L=z(X,{0:{name:"NumberFormat",I:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",v:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,defaultValue:!1,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}})),L},X.j=X.prototype.j,Ee.prototype.j=function(){var L=Ue;return L||(Ue=L=z(Ee,{0:{name:"PhoneNumberDesc",I:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},9:{name:"possible_length",v:!0,c:5,type:Number},10:{name:"possible_length_local_only",v:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String}})),L},Ee.j=Ee.prototype.j,Ie.prototype.j=function(){var L=ot;return L||(ot=L=z(Ie,{0:{name:"PhoneMetadata",I:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:Ee},2:{name:"fixed_line",c:11,type:Ee},3:{name:"mobile",c:11,type:Ee},4:{name:"toll_free",c:11,type:Ee},5:{name:"premium_rate",c:11,type:Ee},6:{name:"shared_cost",c:11,type:Ee},7:{name:"personal_number",c:11,type:Ee},8:{name:"voip",c:11,type:Ee},21:{name:"pager",c:11,type:Ee},25:{name:"uan",c:11,type:Ee},27:{name:"emergency",c:11,type:Ee},28:{name:"voicemail",c:11,type:Ee},29:{name:"short_code",c:11,type:Ee},30:{name:"standard_rate",c:11,type:Ee},31:{name:"carrier_specific",c:11,type:Ee},33:{name:"sms_services",c:11,type:Ee},24:{name:"no_international_dialling",c:11,type:Ee},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1,type:Boolean},19:{name:"number_format",v:!0,c:11,type:X},20:{name:"intl_number_format",v:!0,c:11,type:X},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String},26:{name:"leading_zero_possible",c:8,defaultValue:!1,type:Boolean}})),L},Ie.j=Ie.prototype.j,Fe.prototype.a=function(L){throw new L.b,Error("Unimplemented")},Fe.prototype.b=function(L,W){if(L.a==11||L.a==10)return W instanceof c?W:this.a(L.i.prototype.j(),W);if(L.a==14){if(typeof W=="string"&&Pe.test(W)){var ie=Number(W);if(0<ie)return ie}return W}if(!L.h)return W;if(ie=L.i,ie===String){if(typeof W=="number")return String(W)}else if(ie===Number&&typeof W=="string"&&(W==="Infinity"||W==="-Infinity"||W==="NaN"||Pe.test(W)))return Number(W);return W};var Pe=/^-?[0-9]+$/;e(Oe,Fe),Oe.prototype.a=function(L,W){var ie=new L.b;return ie.g=this,ie.a=W,ie.b={},ie},e(ze,Oe),ze.prototype.b=function(L,W){return L.a==8?!!W:Fe.prototype.b.apply(this,arguments)},ze.prototype.a=function(L,W){return ze.M.a.call(this,L,W)};var St={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" ")},ut={AG:[null,[null,null,"(?:268|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"268(?:4(?:6[0-38]|84)|56[0-2])\\d{4}",null,null,null,"2684601234",null,null,null,[7]],[null,null,"268(?:464|7(?:1[3-9]|2\\d|3[246]|64|[78][0-689]))\\d{4}",null,null,null,"2684641234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"26848[01]\\d{4}",null,null,null,"2684801234",null,null,null,[7]],"AG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"26840[69]\\d{4}",null,null,null,"2684061234",null,null,null,[7]],null,"268",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AI:[null,[null,null,"(?:264|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"2644(?:6[12]|9[78])\\d{4}",null,null,null,"2644612345",null,null,null,[7]],[null,null,"264(?:235|476|5(?:3[6-9]|8[1-4])|7(?:29|72))\\d{4}",null,null,null,"2642351234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AI",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"264",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AS:[null,[null,null,"(?:[58]\\d\\d|684|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"6846(?:22|33|44|55|77|88|9[19])\\d{4}",null,null,null,"6846221234",null,null,null,[7]],[null,null,"684(?:2(?:5[2468]|72)|7(?:3[13]|70))\\d{4}",null,null,null,"6847331234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"684",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BB:[null,[null,null,"(?:246|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"246(?:2(?:2[78]|7[0-4])|4(?:1[024-6]|2\\d|3[2-9])|5(?:20|[34]\\d|54|7[1-3])|6(?:2\\d|38)|7[35]7|9(?:1[89]|63))\\d{4}",null,null,null,"2464123456",null,null,null,[7]],[null,null,"246(?:2(?:[356]\\d|4[0-57-9]|8[0-79])|45\\d|69[5-7]|8(?:[2-5]\\d|83))\\d{4}",null,null,null,"2462501234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"(?:246976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002123456",null,null,null,[7]],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"24631\\d{5}",null,null,null,"2463101234",null,null,null,[7]],"BB",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"246",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"246(?:292|367|4(?:1[7-9]|3[01]|44|67)|7(?:36|53))\\d{4}",null,null,null,"2464301234",null,null,null,[7]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BM:[null,[null,null,"(?:441|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"441(?:2(?:02|23|[3479]\\d|61)|[46]\\d\\d|5(?:4\\d|60|89)|824)\\d{4}",null,null,null,"4412345678",null,null,null,[7]],[null,null,"441(?:[37]\\d|5[0-39])\\d{5}",null,null,null,"4413701234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"441",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BS:[null,[null,null,"(?:242|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"242(?:3(?:02|[236][1-9]|4[0-24-9]|5[0-68]|7[347]|8[0-4]|9[2-467])|461|502|6(?:0[1-4]|12|2[013]|[45]0|7[67]|8[78]|9[89])|7(?:02|88))\\d{4}",null,null,null,"2423456789",null,null,null,[7]],[null,null,"242(?:3(?:5[79]|7[56]|95)|4(?:[23][1-9]|4[1-35-9]|5[1-8]|6[2-8]|7\\d|81)|5(?:2[45]|3[35]|44|5[1-46-9]|65|77)|6[34]6|7(?:27|38)|8(?:0[1-9]|1[02-9]|2\\d|[89]9))\\d{4}",null,null,null,"2423591234",null,null,null,[7]],[null,null,"(?:242300|8(?:00|33|44|55|66|77|88)[2-9]\\d\\d)\\d{4}",null,null,null,"8002123456",null,null,null,[7]],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"242",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"242225[0-46-9]\\d{3}",null,null,null,"2422250123"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],CA:[null,[null,null,"(?:[2-8]\\d|90)\\d{8}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"(?:5(?:00|2[12]|33|44|66|77|88)|622)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"600[2-9]\\d{6}",null,null,null,"6002012345"],"CA",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DM:[null,[null,null,"(?:[58]\\d\\d|767|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"767(?:2(?:55|66)|4(?:2[01]|4[0-25-9])|50[0-4]|70[1-3])\\d{4}",null,null,null,"7674201234",null,null,null,[7]],[null,null,"767(?:2(?:[2-4689]5|7[5-7])|31[5-7]|61[1-7])\\d{4}",null,null,null,"7672251234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"767",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DO:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"8(?:[04]9[2-9]\\d\\d|29(?:2(?:[0-59]\\d|6[04-9]|7[0-27]|8[0237-9])|3(?:[0-35-9]\\d|4[7-9])|[45]\\d\\d|6(?:[0-27-9]\\d|[3-5][1-9]|6[0135-8])|7(?:0[013-9]|[1-37]\\d|4[1-35689]|5[1-4689]|6[1-57-9]|8[1-79]|9[1-8])|8(?:0[146-9]|1[0-48]|[248]\\d|3[1-79]|5[01589]|6[013-68]|7[124-8]|9[0-8])|9(?:[0-24]\\d|3[02-46-9]|5[0-79]|60|7[0169]|8[57-9]|9[02-9])))\\d{4}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8[024]9[2-9]\\d{6}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DO",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"8[024]9",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GD:[null,[null,null,"(?:473|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"473(?:2(?:3[0-2]|69)|3(?:2[89]|86)|4(?:[06]8|3[5-9]|4[0-49]|5[5-79]|73|90)|63[68]|7(?:58|84)|800|938)\\d{4}",null,null,null,"4732691234",null,null,null,[7]],[null,null,"473(?:4(?:0[2-79]|1[04-9]|2[0-5]|58)|5(?:2[01]|3[3-8])|901)\\d{4}",null,null,null,"4734031234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GD",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"473",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GU:[null,[null,null,"(?:[58]\\d\\d|671|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GU",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"671",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],JM:[null,[null,null,"(?:[58]\\d\\d|658|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:658[2-9]\\d\\d|876(?:5(?:0[12]|1[0-468]|2[35]|63)|6(?:0[1-3579]|1[0237-9]|[23]\\d|40|5[06]|6[2-589]|7[05]|8[04]|9[4-9])|7(?:0[2-689]|[1-6]\\d|8[056]|9[45])|9(?:0[1-8]|1[02378]|[2-8]\\d|9[2-468])))\\d{4}",null,null,null,"8765230123",null,null,null,[7]],[null,null,"876(?:(?:2[14-9]|[348]\\d)\\d|5(?:0[3-9]|[2-57-9]\\d|6[0-24-9])|7(?:0[07]|7\\d|8[1-47-9]|9[0-36-9])|9(?:[01]9|9[0579]))\\d{4}",null,null,null,"8762101234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"JM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"658|876",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KN:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"869(?:2(?:29|36)|302|4(?:6[015-9]|70))\\d{4}",null,null,null,"8692361234",null,null,null,[7]],[null,null,"869(?:5(?:5[6-8]|6[5-7])|66\\d|76[02-7])\\d{4}",null,null,null,"8697652917",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KN",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"869",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KY:[null,[null,null,"(?:345|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"345(?:2(?:22|44)|444|6(?:23|38|40)|7(?:4[35-79]|6[6-9]|77)|8(?:00|1[45]|25|[48]8)|9(?:14|4[035-9]))\\d{4}",null,null,null,"3452221234",null,null,null,[7]],[null,null,"345(?:32[1-9]|5(?:1[67]|2[5-79]|4[6-9]|50|76)|649|9(?:1[67]|2[2-9]|3[689]))\\d{4}",null,null,null,"3453231234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"(?:345976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KY",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"345849\\d{4}",null,null,null,"3458491234"],null,"345",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],LC:[null,[null,null,"(?:[58]\\d\\d|758|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"758(?:4(?:30|5\\d|6[2-9]|8[0-2])|57[0-2]|638)\\d{4}",null,null,null,"7584305678",null,null,null,[7]],[null,null,"758(?:28[4-7]|384|4(?:6[01]|8[4-9])|5(?:1[89]|20|84)|7(?:1[2-9]|2\\d|3[01]))\\d{4}",null,null,null,"7582845678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"LC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"758",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MP:[null,[null,null,"(?:[58]\\d\\d|(?:67|90)0)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MP",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"670",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MS:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d\\d|66449)\\d{5}",null,null,null,null,null,null,[10],[7]],[null,null,"664491\\d{4}",null,null,null,"6644912345",null,null,null,[7]],[null,null,"66449[2-6]\\d{4}",null,null,null,"6644923456",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"664",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],PR:[null,[null,null,"(?:[589]\\d\\d|787)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"PR",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"787|939",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],SX:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d|7215)\\d{6}",null,null,null,null,null,null,[10],[7]],[null,null,"7215(?:4[2-8]|8[239]|9[056])\\d{4}",null,null,null,"7215425678",null,null,null,[7]],[null,null,"7215(?:1[02]|2\\d|5[034679]|8[014-8])\\d{4}",null,null,null,"7215205678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"SX",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"721",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TC:[null,[null,null,"(?:[58]\\d\\d|649|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"649(?:712|9(?:4\\d|50))\\d{4}",null,null,null,"6497121234",null,null,null,[7]],[null,null,"649(?:2(?:3[129]|4[1-7])|3(?:3[1-389]|4[1-8])|4[34][1-3])\\d{4}",null,null,null,"6492311234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"64971[01]\\d{4}",null,null,null,"6497101234",null,null,null,[7]],"TC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"649",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TT:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"868(?:2(?:01|[23]\\d)|6(?:0[7-9]|1[02-8]|2[1-9]|[3-69]\\d|7[0-79])|82[124])\\d{4}",null,null,null,"8682211234",null,null,null,[7]],[null,null,"868(?:2(?:6[6-9]|[7-9]\\d)|[37](?:0[1-9]|1[02-9]|[2-9]\\d)|4[6-9]\\d|6(?:20|78|8\\d))\\d{4}",null,null,null,"8682911234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"TT",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"868",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,"868619\\d{4}",null,null,null,"8686191234",null,null,null,[7]]],US:[null,[null,null,"[2-9]\\d{9}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"US",1,"011","1",null,null,"1",null,null,1,[[null,"(\\d{3})(\\d{4})","$1-$2",["[2-9]"]],[null,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],null,null,1]],[[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[2-9]"]]],[null,null,null,null,null,null,null,null,null,[-1]],1,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"710[2-9]\\d{6}",null,null,null,"7102123456"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VC:[null,[null,null,"(?:[58]\\d\\d|784|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"784(?:266|3(?:6[6-9]|7\\d|8[0-24-6])|4(?:38|5[0-36-8]|8[0-8])|5(?:55|7[0-2]|93)|638|784)\\d{4}",null,null,null,"7842661234",null,null,null,[7]],[null,null,"784(?:4(?:3[0-5]|5[45]|89|9[0-8])|5(?:2[6-9]|3[0-4]))\\d{4}",null,null,null,"7844301234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"784",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VG:[null,[null,null,"(?:284|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"284(?:(?:229|774|8(?:52|6[459]))\\d|4(?:22\\d|9(?:[45]\\d|6[0-5])))\\d{3}",null,null,null,"2842291234",null,null,null,[7]],[null,null,"284(?:(?:3(?:0[0-3]|4[0-7]|68|9[34])|54[0-57])\\d|4(?:(?:4[0-6]|68)\\d|9(?:6[6-9]|9\\d)))\\d{3}",null,null,null,"2843001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"284",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VI:[null,[null,null,"(?:(?:34|90)0|[58]\\d\\d)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VI",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"340",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]]};V.b=function(){return V.a?V.a:V.a=new V};var or={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"},br=RegExp("[++]+"),et=RegExp("([0-90-9٠-٩۰-۹])"),Mr=/^\(?\$1\)?$/,Fr=new Ie;N(Fr,11,"NA");var dr=/\[([^\[\]])*\]/g,fr=/\d(?=[^,}][^,}])/g,Wt=RegExp("^[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*(\\$\\d[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*)+$"),Ot=/[- ]/;Te.prototype.K=function(){this.C="",n(this.i),n(this.u),n(this.m),this.s=0,this.w="",n(this.b),this.h="",n(this.a),this.l=!0,this.A=this.o=this.F=!1,this.f=[],this.B=!1,this.g!=this.J&&(this.g=re(this,this.D))},Te.prototype.L=function(L){return this.C=ne(this,L)},t("Cleave.AsYouTypeFormatter",Te),t("Cleave.AsYouTypeFormatter.prototype.inputDigit",Te.prototype.L),t("Cleave.AsYouTypeFormatter.prototype.clear",Te.prototype.K)}).call(typeof ln=="object"&&ln?ln:window);var uP=Object.defineProperty,lP=Object.getOwnPropertyDescriptor,Xd=(t,e,r,n)=>{for(var i=n>1?void 0:n?lP(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&uP(e,r,i),i};const cP=Ul.object({firstName:Ul.string().min(1,{message:"First name is required"}),lastName:Ul.string().min(1,{message:"Last name is required"}),email:Ul.string().email({message:"Invalid email address"}),phone:Ul.string().regex(/^(1-)?\d{3}-\d{3}-\d{4}$/,{message:"Invalid phone number"}).transform(t=>t.replace(/-/g,"").replace(/^1/,""))});let nu=class extends Jo{constructor(){super(...arguments),this.params={firstName:"",lastName:"",email:"",phone:""},this.errors=[]}firstUpdated(){this.phoneCleave=new L2(this.phoneInput,{phone:!0,phoneRegionCode:"US",delimiter:"-"})}submit(t){t.preventDefault();try{this.params=cP.parse(this.params)}catch(e){this.errors=e.errors;return}this.dispatchEvent(new CustomEvent("submit",{composed:!0,detail:this.params}))}cancel(){this.dispatchEvent(new CustomEvent("cancel"))}updateField(t,e){this.params={...this.params,[t]:e}}render(){return Hd`
44
44
  <div>
45
45
  <iai-chat-message-assistant
46
46
  content="Your contact information is required to transfer to a live agent."
@@ -385,7 +385,7 @@
385
385
  * @license
386
386
  * Copyright 2021 Google LLC
387
387
  * SPDX-License-Identifier: BSD-3-Clause
388
- */function wa(t,e,r){return t?e(t):r==null?void 0:r(t)}const Lv="-",SM=t=>{const e=TM(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:i=>{const a=i.split(Lv);return a[0]===""&&a.length!==1&&a.shift(),I_(a,e)||$M(i)},getConflictingClassGroupIds:(i,a)=>{const s=r[i]||[];return a&&n[i]?[...s,...n[i]]:s}}},I_=(t,e)=>{var r;if(t.length===0)return e.classGroupId;const n=t[0],i=e.nextPart.get(n),a=i?I_(t.slice(1),i):void 0;if(a)return a;if(e.validators.length===0)return;const s=t.join(Lv);return(r=e.validators.find(({validator:o})=>o(s)))==null?void 0:r.classGroupId},A_=/^\[(.+)\]$/,$M=t=>{if(A_.test(t)){const e=A_.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},TM=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return CM(Object.entries(t.classGroups),r).forEach(([i,a])=>{Dv(a,n,i,e)}),n},Dv=(t,e,r,n)=>{t.forEach(i=>{if(typeof i=="string"){const a=i===""?e:O_(e,i);a.classGroupId=r;return}if(typeof i=="function"){if(EM(i)){Dv(i(n),e,r,n);return}e.validators.push({validator:i,classGroupId:r});return}Object.entries(i).forEach(([a,s])=>{Dv(s,O_(e,a),r,n)})})},O_=(t,e)=>{let r=t;return e.split(Lv).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},EM=t=>t.isThemeGetter,CM=(t,e)=>e?t.map(([r,n])=>{const i=n.map(a=>typeof a=="string"?e+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([s,o])=>[e+s,o])):a);return[r,i]}):t,RM=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const i=(a,s)=>{r.set(a,s),e++,e>t&&(e=0,n=r,r=new Map)};return{get(a){let s=r.get(a);if(s!==void 0)return s;if((s=n.get(a))!==void 0)return i(a,s),s},set(a,s){r.has(a)?r.set(a,s):i(a,s)}}},P_="!",xM=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,i=e[0],a=e.length,s=o=>{const u=[];let l=0,c=0,d;for(let N=0;N<o.length;N++){let z=o[N];if(l===0){if(z===i&&(n||o.slice(N,N+a)===e)){u.push(o.slice(c,N)),c=N+a;continue}if(z==="/"){d=N;continue}}z==="["?l++:z==="]"&&l--}const f=u.length===0?o:o.substring(c),m=f.startsWith(P_),b=m?f.substring(1):f,A=d&&d>c?d-c:void 0;return{modifiers:u,hasImportantModifier:m,baseClassName:b,maybePostfixModifierPosition:A}};return r?o=>r({className:o,parseClassName:s}):s},IM=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},AM=t=>({cache:RM(t.cacheSize),parseClassName:xM(t),...SM(t)}),OM=/\s+/,PM=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i}=e,a=[],s=t.trim().split(OM);let o="";for(let u=s.length-1;u>=0;u-=1){const l=s[u],{modifiers:c,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:m}=r(l);let b=!!m,A=n(b?f.substring(0,m):f);if(!A){if(!b){o=l+(o.length>0?" "+o:o);continue}if(A=n(f),!A){o=l+(o.length>0?" "+o:o);continue}b=!1}const N=IM(c).join(":"),z=d?N+P_:N,X=z+A;if(a.includes(X))continue;a.push(X);const Ee=i(A,b);for(let Ie=0;Ie<Ee.length;++Ie){const Be=Ee[Ie];a.push(z+Be)}o=l+(o.length>0?" "+o:o)}return o};function MM(){let t=0,e,r,n="";for(;t<arguments.length;)(e=arguments[t++])&&(r=M_(e))&&(n&&(n+=" "),n+=r);return n}const M_=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=M_(t[n]))&&(r&&(r+=" "),r+=e);return r};function NM(t,...e){let r,n,i,a=s;function s(u){const l=e.reduce((c,d)=>d(c),t());return r=AM(l),n=r.cache.get,i=r.cache.set,a=o,o(u)}function o(u){const l=n(u);if(l)return l;const c=PM(u,r);return i(u,c),c}return function(){return a(MM.apply(null,arguments))}}const Ur=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},N_=/^\[(?:([a-z-]+):)?(.+)\]$/i,LM=/^\d+\/\d+$/,DM=new Set(["px","full","screen"]),jM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,UM=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,FM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,BM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,zM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_a=t=>du(t)||DM.has(t)||LM.test(t),is=t=>fu(t,"length",JM),du=t=>!!t&&!Number.isNaN(Number(t)),jv=t=>fu(t,"number",du),tc=t=>!!t&&Number.isInteger(Number(t)),HM=t=>t.endsWith("%")&&du(t.slice(0,-1)),sr=t=>N_.test(t),as=t=>jM.test(t),qM=new Set(["length","size","percentage"]),VM=t=>fu(t,qM,L_),WM=t=>fu(t,"position",L_),ZM=new Set(["image","url"]),GM=t=>fu(t,ZM,QM),KM=t=>fu(t,"",YM),rc=()=>!0,fu=(t,e,r)=>{const n=N_.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},JM=t=>UM.test(t)&&!FM.test(t),L_=()=>!1,YM=t=>BM.test(t),QM=t=>zM.test(t),XM=()=>{const t=Ur("colors"),e=Ur("spacing"),r=Ur("blur"),n=Ur("brightness"),i=Ur("borderColor"),a=Ur("borderRadius"),s=Ur("borderSpacing"),o=Ur("borderWidth"),u=Ur("contrast"),l=Ur("grayscale"),c=Ur("hueRotate"),d=Ur("invert"),f=Ur("gap"),m=Ur("gradientColorStops"),b=Ur("gradientColorStopPositions"),A=Ur("inset"),N=Ur("margin"),z=Ur("opacity"),X=Ur("padding"),Ee=Ur("saturate"),Ie=Ur("scale"),Be=Ur("sepia"),Oe=Ur("skew"),ze=Ur("space"),V=Ur("translate"),xe=()=>["auto","contain","none"],_e=()=>["auto","hidden","clip","visible","scroll"],se=()=>["auto",sr,e],Te=()=>[sr,e],re=()=>["",_a,is],oe=()=>["auto",du,sr],q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],Se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",sr],ke=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>[du,sr];return{cacheSize:500,separator:":",theme:{colors:[rc],spacing:[_a,is],blur:["none","",as,sr],brightness:M(),borderColor:[t],borderRadius:["none","","full",as,sr],borderSpacing:Te(),borderWidth:re(),contrast:M(),grayscale:ye(),hueRotate:M(),invert:ye(),gap:Te(),gradientColorStops:[t],gradientColorStopPositions:[HM,is],inset:se(),margin:se(),opacity:M(),padding:Te(),saturate:M(),scale:M(),sepia:ye(),skew:M(),space:Te(),translate:Te()},classGroups:{aspect:[{aspect:["auto","square","video",sr]}],container:["container"],columns:[{columns:[as]}],"break-after":[{"break-after":ke()}],"break-before":[{"break-before":ke()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...q(),sr]}],overflow:[{overflow:_e()}],"overflow-x":[{"overflow-x":_e()}],"overflow-y":[{"overflow-y":_e()}],overscroll:[{overscroll:xe()}],"overscroll-x":[{"overscroll-x":xe()}],"overscroll-y":[{"overscroll-y":xe()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[A]}],"inset-x":[{"inset-x":[A]}],"inset-y":[{"inset-y":[A]}],start:[{start:[A]}],end:[{end:[A]}],top:[{top:[A]}],right:[{right:[A]}],bottom:[{bottom:[A]}],left:[{left:[A]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",tc,sr]}],basis:[{basis:se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",sr]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",tc,sr]}],"grid-cols":[{"grid-cols":[rc]}],"col-start-end":[{col:["auto",{span:["full",tc,sr]},sr]}],"col-start":[{"col-start":oe()}],"col-end":[{"col-end":oe()}],"grid-rows":[{"grid-rows":[rc]}],"row-start-end":[{row:["auto",{span:[tc,sr]},sr]}],"row-start":[{"row-start":oe()}],"row-end":[{"row-end":oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",sr]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",sr]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...H()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...H(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...H(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[X]}],px:[{px:[X]}],py:[{py:[X]}],ps:[{ps:[X]}],pe:[{pe:[X]}],pt:[{pt:[X]}],pr:[{pr:[X]}],pb:[{pb:[X]}],pl:[{pl:[X]}],m:[{m:[N]}],mx:[{mx:[N]}],my:[{my:[N]}],ms:[{ms:[N]}],me:[{me:[N]}],mt:[{mt:[N]}],mr:[{mr:[N]}],mb:[{mb:[N]}],ml:[{ml:[N]}],"space-x":[{"space-x":[ze]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[ze]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",sr,e]}],"min-w":[{"min-w":[sr,e,"min","max","fit"]}],"max-w":[{"max-w":[sr,e,"none","full","min","max","fit","prose",{screen:[as]},as]}],h:[{h:[sr,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[sr,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[sr,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[sr,e,"auto","min","max","fit"]}],"font-size":[{text:["base",as,is]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",jv]}],"font-family":[{font:[rc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",sr]}],"line-clamp":[{"line-clamp":["none",du,jv]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",_a,sr]}],"list-image":[{"list-image":["none",sr]}],"list-style-type":[{list:["none","disc","decimal",sr]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[z]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[z]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",_a,is]}],"underline-offset":[{"underline-offset":["auto",_a,sr]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Te()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",sr]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",sr]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[z]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...q(),WM]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",VM]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},GM]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[z]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[z]}],"divide-style":[{divide:ne()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ne()]}],"outline-offset":[{"outline-offset":[_a,sr]}],"outline-w":[{outline:[_a,is]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[z]}],"ring-offset-w":[{"ring-offset":[_a,is]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",as,KM]}],"shadow-color":[{shadow:[rc]}],opacity:[{opacity:[z]}],"mix-blend":[{"mix-blend":[...Se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Se()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",as,sr]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[d]}],saturate:[{saturate:[Ee]}],sepia:[{sepia:[Be]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[z]}],"backdrop-saturate":[{"backdrop-saturate":[Ee]}],"backdrop-sepia":[{"backdrop-sepia":[Be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",sr]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",sr]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",sr]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[Ie]}],"scale-x":[{"scale-x":[Ie]}],"scale-y":[{"scale-y":[Ie]}],rotate:[{rotate:[tc,sr]}],"translate-x":[{"translate-x":[V]}],"translate-y":[{"translate-y":[V]}],"skew-x":[{"skew-x":[Oe]}],"skew-y":[{"skew-y":[Oe]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",sr]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",sr]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Te()}],"scroll-mx":[{"scroll-mx":Te()}],"scroll-my":[{"scroll-my":Te()}],"scroll-ms":[{"scroll-ms":Te()}],"scroll-me":[{"scroll-me":Te()}],"scroll-mt":[{"scroll-mt":Te()}],"scroll-mr":[{"scroll-mr":Te()}],"scroll-mb":[{"scroll-mb":Te()}],"scroll-ml":[{"scroll-ml":Te()}],"scroll-p":[{"scroll-p":Te()}],"scroll-px":[{"scroll-px":Te()}],"scroll-py":[{"scroll-py":Te()}],"scroll-ps":[{"scroll-ps":Te()}],"scroll-pe":[{"scroll-pe":Te()}],"scroll-pt":[{"scroll-pt":Te()}],"scroll-pr":[{"scroll-pr":Te()}],"scroll-pb":[{"scroll-pb":Te()}],"scroll-pl":[{"scroll-pl":Te()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",sr]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[_a,is,jv]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},eN=NM(XM);var tN=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function D_(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Uv={};(function(t){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function r(o,u,l,c){var d={timer:void 0,lastArgs:[]},f=function(){for(var m=this,b=[],A=0;A<arguments.length;A++)b[A]=arguments[A];d.lastArgs=b,d.timer?clearTimeout(d.timer):u&&l.apply(this,d.lastArgs),d.timer=setTimeout(function(){u||l.apply(m,d.lastArgs),d.timer=void 0},o)};return c&&(f=f.bind(c)),f.options=d,f}function n(o,u,l,c){var d;Object.defineProperty(l,c,{configurable:!0,enumerable:!1,get:function(){return d},set:function(f){d=r(o,u,f,this)}})}function i(o,u,l){var c=l.value;return l.value=r(o,u,c),l}function a(o,u){for(var l=[],c=2;c<arguments.length;c++)l[c-2]=arguments[c];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var d=l[0],f=l[1],m=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(d,f);if(m)return i(o,u,m);n(o,u,d,f)}function s(){for(var o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];var l=500,c=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var d=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(d=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(d=o[1]),d&&(c=d.leading),function(){for(var f=[],m=0;m<arguments.length;m++)f[m]=arguments[m];return a.apply(void 0,[l,c].concat(f))}}return a.apply(void 0,[l,c].concat(o))}Object.defineProperty(t,"__esModule",{value:!0}),t.cancel=e,t.debounce=s})(Uv);var yr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(yr||(yr={}));var Fv;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Fv||(Fv={}));const gt=yr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ss=t=>{switch(typeof t){case"undefined":return gt.undefined;case"string":return gt.string;case"number":return isNaN(t)?gt.nan:gt.number;case"boolean":return gt.boolean;case"function":return gt.function;case"bigint":return gt.bigint;case"symbol":return gt.symbol;case"object":return Array.isArray(t)?gt.array:t===null?gt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?gt.promise:typeof Map<"u"&&t instanceof Map?gt.map:typeof Set<"u"&&t instanceof Set?gt.set:typeof Date<"u"&&t instanceof Date?gt.date:gt.object;default:return gt.unknown}},st=yr.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"]),rN=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Si extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,yr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Si.create=t=>new Si(t);const nc=(t,e)=>{let r;switch(t.code){case st.invalid_type:t.received===gt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case st.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,yr.jsonStringifyReplacer)}`;break;case st.unrecognized_keys:r=`Unrecognized key(s) in object: ${yr.joinValues(t.keys,", ")}`;break;case st.invalid_union:r="Invalid input";break;case st.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${yr.joinValues(t.options)}`;break;case st.invalid_enum_value:r=`Invalid enum value. Expected ${yr.joinValues(t.options)}, received '${t.received}'`;break;case st.invalid_arguments:r="Invalid function arguments";break;case st.invalid_return_type:r="Invalid function return type";break;case st.invalid_date:r="Invalid date";break;case st.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}"`:yr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case st.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==="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 st.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 st.custom:r="Invalid input";break;case st.invalid_intersection_types:r="Intersection results could not be merged";break;case st.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case st.not_finite:r="Number must be finite";break;default:r=e.defaultError,yr.assertNever(t)}return{message:r}};let j_=nc;function nN(t){j_=t}function yf(){return j_}const bf=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:i.message||o}},iN=[];function _t(t,e){const r=bf({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yf(),nc].filter(n=>!!n)});t.common.issues.push(r)}class gn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return Xt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r)n.push({key:await i.key,value:await i.value});return gn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return Xt;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const Xt=Object.freeze({status:"aborted"}),U_=t=>({status:"dirty",value:t}),En=t=>({status:"valid",value:t}),Bv=t=>t.status==="aborted",zv=t=>t.status==="dirty",ic=t=>t.status==="valid",wf=t=>typeof Promise<"u"&&t instanceof Promise;var Dt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Dt||(Dt={}));class Zi{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const F_=(t,e)=>{if(ic(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 Si(t.common.issues);return this._error=r,this._error}}};function nr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>a.code!=="invalid_type"?{message:s.defaultError}:typeof s.data>"u"?{message:n??s.defaultError}:{message:r??s.defaultError},description:i}}class lr{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)}get description(){return this._def.description}_getType(e){return ss(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ss(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gn,ctx:{common:e.parent.common,data:e.data,parsedType:ss(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(wf(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 n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ss(e)},a=this._parseSync({data:e,path:i.path,parent:i});return F_(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={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:ss(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(wf(i)?i:Promise.resolve(i));return F_(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:st.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new Ei({schema:this,typeName:Bt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Sa.create(this,this._def)}nullable(){return co.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ti.create(this,this._def)}promise(){return mu.create(this,this._def)}or(e){return uc.create([this,e],this._def)}and(e){return lc.create(this,e,this._def)}transform(e){return new Ei({...nr(this._def),schema:this,typeName:Bt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new pc({...nr(this._def),innerType:this,defaultValue:r,typeName:Bt.ZodDefault})}brand(){return new z_({typeName:Bt.ZodBranded,type:this,...nr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Ef({...nr(this._def),innerType:this,catchValue:r,typeName:Bt.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return vc.create(this,e)}readonly(){return Rf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const aN=/^c[^\s-]{8,}$/i,sN=/^[a-z][a-z0-9]*$/,oN=/^[0-9A-HJKMNP-TV-Z]{26}$/,uN=/^[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,lN=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cN="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Hv;const dN=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,fN=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,hN=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function pN(t,e){return!!((e==="v4"||!e)&&dN.test(t)||(e==="v6"||!e)&&fN.test(t))}class $i extends lr{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==gt.string){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.string,received:i.parsedType}),Xt}const r=new gn;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,s=e.data.length<i.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?_t(n,{code:st.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&_t(n,{code:st.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")lN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"email",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Hv||(Hv=new RegExp(cN,"u")),Hv.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"emoji",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")uN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"uuid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")aN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"cuid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")sN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"cuid2",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")oN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"ulid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),_t(n,{validation:"url",code:st.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"regex",code:st.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.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),_t(n,{code:st.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?hN(i).test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="ip"?pN(e.data,i.version)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"ip",code:st.invalid_string,message:i.message}),r.dirty()):yr.assertNever(i);return{status:r.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:st.invalid_string,...Dt.errToObj(n)})}_addCheck(e){return new $i({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Dt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Dt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Dt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Dt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Dt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Dt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Dt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Dt.errToObj(e)})}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,...Dt.errToObj(e==null?void 0:e.message)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Dt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Dt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Dt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Dt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Dt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Dt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Dt.errToObj(r)})}nonempty(e){return this.min(1,Dt.errToObj(e))}trim(){return new $i({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 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}}$i.create=t=>{var e;return new $i({checks:[],typeName:Bt.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...nr(t)})};function vN(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class os extends lr{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)!==gt.number){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.number,received:i.parsedType}),Xt}let r;const n=new gn;for(const i of this._def.checks)i.kind==="int"?yr.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),_t(r,{code:st.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.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)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?vN(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_finite,message:i.message}),n.dirty()):yr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Dt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Dt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Dt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Dt.toString(r))}setLimit(e,r,n,i){return new os({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(e){return new os({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Dt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Dt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Dt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Dt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Dt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Dt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Dt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Dt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Dt.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"&&yr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}os.create=t=>new os({checks:[],typeName:Bt.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...nr(t)});class us extends lr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==gt.bigint){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.bigint,received:i.parsedType}),Xt}let r;const n=new gn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.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)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):yr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Dt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Dt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Dt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Dt.toString(r))}setLimit(e,r,n,i){return new us({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(e){return new us({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Dt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Dt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Dt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Dt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Dt.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}}us.create=t=>{var e;return new us({checks:[],typeName:Bt.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...nr(t)})};class ac extends lr{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==gt.boolean){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.boolean,received:r.parsedType}),Xt}return En(e.data)}}ac.create=t=>new ac({typeName:Bt.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...nr(t)});class oo extends lr{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==gt.date){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.date,received:i.parsedType}),Xt}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_date}),Xt}const r=new gn;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):yr.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new oo({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Dt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Dt.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}}oo.create=t=>new oo({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Bt.ZodDate,...nr(t)});class _f extends lr{_parse(e){if(this._getType(e)!==gt.symbol){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.symbol,received:r.parsedType}),Xt}return En(e.data)}}_f.create=t=>new _f({typeName:Bt.ZodSymbol,...nr(t)});class sc extends lr{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.undefined,received:r.parsedType}),Xt}return En(e.data)}}sc.create=t=>new sc({typeName:Bt.ZodUndefined,...nr(t)});class oc extends lr{_parse(e){if(this._getType(e)!==gt.null){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.null,received:r.parsedType}),Xt}return En(e.data)}}oc.create=t=>new oc({typeName:Bt.ZodNull,...nr(t)});class hu extends lr{constructor(){super(...arguments),this._any=!0}_parse(e){return En(e.data)}}hu.create=t=>new hu({typeName:Bt.ZodAny,...nr(t)});class uo extends lr{constructor(){super(...arguments),this._unknown=!0}_parse(e){return En(e.data)}}uo.create=t=>new uo({typeName:Bt.ZodUnknown,...nr(t)});class ka extends lr{_parse(e){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.never,received:r.parsedType}),Xt}}ka.create=t=>new ka({typeName:Bt.ZodNever,...nr(t)});class kf extends lr{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.void,received:r.parsedType}),Xt}return En(e.data)}}kf.create=t=>new kf({typeName:Bt.ZodVoid,...nr(t)});class Ti extends lr{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==gt.array)return _t(r,{code:st.invalid_type,expected:gt.array,received:r.parsedType}),Xt;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(_t(r,{code:s?st.too_big:st.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(_t(r,{code:st.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(_t(r,{code:st.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new Zi(r,s,r.path,o)))).then(s=>gn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new Zi(r,s,r.path,o)));return gn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new Ti({...this._def,minLength:{value:e,message:Dt.toString(r)}})}max(e,r){return new Ti({...this._def,maxLength:{value:e,message:Dt.toString(r)}})}length(e,r){return new Ti({...this._def,exactLength:{value:e,message:Dt.toString(r)}})}nonempty(e){return this.min(1,e)}}Ti.create=(t,e)=>new Ti({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Bt.ZodArray,...nr(e)});function pu(t){if(t instanceof Zr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Sa.create(pu(n))}return new Zr({...t._def,shape:()=>e})}else return t instanceof Ti?new Ti({...t._def,type:pu(t.element)}):t instanceof Sa?Sa.create(pu(t.unwrap())):t instanceof co?co.create(pu(t.unwrap())):t instanceof Gi?Gi.create(t.items.map(e=>pu(e))):t}class Zr extends lr{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=yr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==gt.object){const u=this._getOrReturnCtx(e);return _t(u,{code:st.invalid_type,expected:gt.object,received:u.parsedType}),Xt}const{status:r,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof ka&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||s.push(u);const o=[];for(const u of a){const l=i[u],c=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new Zi(n,c,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof ka){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of s)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")s.length>0&&(_t(n,{code:st.unrecognized_keys,keys:s}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of s){const c=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new Zi(n,c,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const c=await l.key;u.push({key:c,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>gn.mergeObjectSync(r,u)):gn.mergeObjectSync(r,o)}get shape(){return this._def.shape()}strict(e){return Dt.errToObj,new Zr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Dt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Zr({...this._def,unknownKeys:"strip"})}passthrough(){return new Zr({...this._def,unknownKeys:"passthrough"})}extend(e){return new Zr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Zr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Bt.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Zr({...this._def,catchall:e})}pick(e){const r={};return yr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Zr({...this._def,shape:()=>r})}omit(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Zr({...this._def,shape:()=>r})}deepPartial(){return pu(this)}partial(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new Zr({...this._def,shape:()=>r})}required(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof Sa;)i=i._def.innerType;r[n]=i}}),new Zr({...this._def,shape:()=>r})}keyof(){return B_(yr.objectKeys(this.shape))}}Zr.create=(t,e)=>new Zr({shape:()=>t,unknownKeys:"strip",catchall:ka.create(),typeName:Bt.ZodObject,...nr(e)}),Zr.strictCreate=(t,e)=>new Zr({shape:()=>t,unknownKeys:"strict",catchall:ka.create(),typeName:Bt.ZodObject,...nr(e)}),Zr.lazycreate=(t,e)=>new Zr({shape:t,unknownKeys:"strip",catchall:ka.create(),typeName:Bt.ZodObject,...nr(e)});class uc extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new Si(o.ctx.common.issues));return _t(r,{code:st.invalid_union,unionErrors:s}),Xt}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new Si(u));return _t(r,{code:st.invalid_union,unionErrors:o}),Xt}}get options(){return this._def.options}}uc.create=(t,e)=>new uc({options:t,typeName:Bt.ZodUnion,...nr(e)});const Sf=t=>t instanceof dc?Sf(t.schema):t instanceof Ei?Sf(t.innerType()):t instanceof fc?[t.value]:t instanceof ls?t.options:t instanceof hc?Object.keys(t.enum):t instanceof pc?Sf(t._def.innerType):t instanceof sc?[void 0]:t instanceof oc?[null]:null;class $f extends lr{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.object)return _t(r,{code:st.invalid_type,expected:gt.object,received:r.parsedType}),Xt;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(_t(r,{code:st.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Xt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=Sf(a.shape[e]);if(!s)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new $f({typeName:Bt.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...nr(n)})}}function qv(t,e){const r=ss(t),n=ss(e);if(t===e)return{valid:!0,data:t};if(r===gt.object&&n===gt.object){const i=yr.objectKeys(e),a=yr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=qv(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===gt.array&&n===gt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=qv(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===gt.date&&n===gt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class lc extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(Bv(a)||Bv(s))return Xt;const o=qv(a.value,s.value);return o.valid?((zv(a)||zv(s))&&r.dirty(),{status:r.value,value:o.data}):(_t(n,{code:st.invalid_intersection_types}),Xt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}lc.create=(t,e,r)=>new lc({left:t,right:e,typeName:Bt.ZodIntersection,...nr(r)});class Gi extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.array)return _t(n,{code:st.invalid_type,expected:gt.array,received:n.parsedType}),Xt;if(n.data.length<this._def.items.length)return _t(n,{code:st.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Xt;!this._def.rest&&n.data.length>this._def.items.length&&(_t(n,{code:st.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((a,s)=>{const o=this._def.items[s]||this._def.rest;return o?o._parse(new Zi(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>gn.mergeArray(r,a)):gn.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Gi({...this._def,rest:e})}}Gi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gi({items:t,typeName:Bt.ZodTuple,rest:null,...nr(e)})};class cc extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.object)return _t(n,{code:st.invalid_type,expected:gt.object,received:n.parsedType}),Xt;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new Zi(n,o,n.path,o)),value:s._parse(new Zi(n,n.data[o],n.path,o))});return n.common.async?gn.mergeObjectAsync(r,i):gn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof lr?new cc({keyType:e,valueType:r,typeName:Bt.ZodRecord,...nr(n)}):new cc({keyType:$i.create(),valueType:e,typeName:Bt.ZodRecord,...nr(r)})}}class Tf extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.map)return _t(n,{code:st.invalid_type,expected:gt.map,received:n.parsedType}),Xt;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new Zi(n,o,n.path,[l,"key"])),value:a._parse(new Zi(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return Xt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return Xt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}Tf.create=(t,e,r)=>new Tf({valueType:e,keyType:t,typeName:Bt.ZodMap,...nr(r)});class lo extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.set)return _t(n,{code:st.invalid_type,expected:gt.set,received:n.parsedType}),Xt;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(_t(n,{code:st.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(_t(n,{code:st.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return Xt;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new Zi(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new lo({...this._def,minSize:{value:e,message:Dt.toString(r)}})}max(e,r){return new lo({...this._def,maxSize:{value:e,message:Dt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}lo.create=(t,e)=>new lo({valueType:t,minSize:null,maxSize:null,typeName:Bt.ZodSet,...nr(e)});class vu extends lr{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.function)return _t(r,{code:st.invalid_type,expected:gt.function,received:r.parsedType}),Xt;function n(o,u){return bf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yf(),nc].filter(l=>!!l),issueData:{code:st.invalid_arguments,argumentsError:u}})}function i(o,u){return bf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yf(),nc].filter(l=>!!l),issueData:{code:st.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof mu){const o=this;return En(async function(...u){const l=new Si([]),c=await o._def.args.parseAsync(u,a).catch(f=>{throw l.addIssue(n(u,f)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(f=>{throw l.addIssue(i(d,f)),l})})}else{const o=this;return En(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Si([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new Si([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new vu({...this._def,args:Gi.create(e).rest(uo.create())})}returns(e){return new vu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new vu({args:e||Gi.create([]).rest(uo.create()),returns:r||uo.create(),typeName:Bt.ZodFunction,...nr(n)})}}class dc extends lr{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})}}dc.create=(t,e)=>new dc({getter:t,typeName:Bt.ZodLazy,...nr(e)});class fc extends lr{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return _t(r,{received:r.data,code:st.invalid_literal,expected:this._def.value}),Xt}return{status:"valid",value:e.data}}get value(){return this._def.value}}fc.create=(t,e)=>new fc({value:t,typeName:Bt.ZodLiteral,...nr(e)});function B_(t,e){return new ls({values:t,typeName:Bt.ZodEnum,...nr(e)})}class ls extends lr{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return _t(r,{expected:yr.joinValues(n),received:r.parsedType,code:st.invalid_type}),Xt}if(this._def.values.indexOf(e.data)===-1){const r=this._getOrReturnCtx(e),n=this._def.values;return _t(r,{received:r.data,code:st.invalid_enum_value,options:n}),Xt}return En(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){return ls.create(e)}exclude(e){return ls.create(this.options.filter(r=>!e.includes(r)))}}ls.create=B_;class hc extends lr{_parse(e){const r=yr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==gt.string&&n.parsedType!==gt.number){const i=yr.objectValues(r);return _t(n,{expected:yr.joinValues(i),received:n.parsedType,code:st.invalid_type}),Xt}if(r.indexOf(e.data)===-1){const i=yr.objectValues(r);return _t(n,{received:n.data,code:st.invalid_enum_value,options:i}),Xt}return En(e.data)}get enum(){return this._def.values}}hc.create=(t,e)=>new hc({values:t,typeName:Bt.ZodNativeEnum,...nr(e)});class mu extends lr{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.promise&&r.common.async===!1)return _t(r,{code:st.invalid_type,expected:gt.promise,received:r.parsedType}),Xt;const n=r.parsedType===gt.promise?r.data:Promise.resolve(r.data);return En(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}mu.create=(t,e)=>new mu({type:t,typeName:Bt.ZodPromise,...nr(e)});class Ei extends lr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Bt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{_t(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(s).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:s,path:n.path,parent:n})}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Xt:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Xt:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ic(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>ic(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);yr.assertNever(i)}}Ei.create=(t,e,r)=>new Ei({schema:t,typeName:Bt.ZodEffects,effect:e,...nr(r)}),Ei.createWithPreprocess=(t,e,r)=>new Ei({schema:e,effect:{type:"preprocess",transform:t},typeName:Bt.ZodEffects,...nr(r)});class Sa extends lr{_parse(e){return this._getType(e)===gt.undefined?En(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sa.create=(t,e)=>new Sa({innerType:t,typeName:Bt.ZodOptional,...nr(e)});class co extends lr{_parse(e){return this._getType(e)===gt.null?En(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}co.create=(t,e)=>new co({innerType:t,typeName:Bt.ZodNullable,...nr(e)});class pc extends lr{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===gt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}pc.create=(t,e)=>new pc({innerType:t,typeName:Bt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...nr(e)});class Ef extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return wf(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Si(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Si(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ef.create=(t,e)=>new Ef({innerType:t,typeName:Bt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...nr(e)});class Cf extends lr{_parse(e){if(this._getType(e)!==gt.nan){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.nan,received:r.parsedType}),Xt}return{status:"valid",value:e.data}}}Cf.create=t=>new Cf({typeName:Bt.ZodNaN,...nr(t)});const mN=Symbol("zod_brand");class z_ extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class vc extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Xt:i.status==="dirty"?(r.dirty(),U_(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Xt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new vc({in:e,out:r,typeName:Bt.ZodPipeline})}}class Rf extends lr{_parse(e){const r=this._def.innerType._parse(e);return ic(r)&&(r.value=Object.freeze(r.value)),r}}Rf.create=(t,e)=>new Rf({innerType:t,typeName:Bt.ZodReadonly,...nr(e)});const H_=(t,e={},r)=>t?hu.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):hu.create(),gN={object:Zr.lazycreate};var Bt;(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"})(Bt||(Bt={}));const yN=(t,e={message:`Input not instance of ${t.name}`})=>H_(r=>r instanceof t,e),q_=$i.create,V_=os.create,bN=Cf.create,wN=us.create,W_=ac.create,_N=oo.create,kN=_f.create,SN=sc.create,$N=oc.create,TN=hu.create,EN=uo.create,CN=ka.create,RN=kf.create,xN=Ti.create,IN=Zr.create,AN=Zr.strictCreate,ON=uc.create,PN=$f.create,MN=lc.create,NN=Gi.create,LN=cc.create,DN=Tf.create,jN=lo.create,UN=vu.create,FN=dc.create,BN=fc.create,zN=ls.create,HN=hc.create,qN=mu.create,Z_=Ei.create,VN=Sa.create,WN=co.create,ZN=Ei.createWithPreprocess,GN=vc.create;var yt=Object.freeze({__proto__:null,defaultErrorMap:nc,setErrorMap:nN,getErrorMap:yf,makeIssue:bf,EMPTY_PATH:iN,addIssueToContext:_t,ParseStatus:gn,INVALID:Xt,DIRTY:U_,OK:En,isAborted:Bv,isDirty:zv,isValid:ic,isAsync:wf,get util(){return yr},get objectUtil(){return Fv},ZodParsedType:gt,getParsedType:ss,ZodType:lr,ZodString:$i,ZodNumber:os,ZodBigInt:us,ZodBoolean:ac,ZodDate:oo,ZodSymbol:_f,ZodUndefined:sc,ZodNull:oc,ZodAny:hu,ZodUnknown:uo,ZodNever:ka,ZodVoid:kf,ZodArray:Ti,ZodObject:Zr,ZodUnion:uc,ZodDiscriminatedUnion:$f,ZodIntersection:lc,ZodTuple:Gi,ZodRecord:cc,ZodMap:Tf,ZodSet:lo,ZodFunction:vu,ZodLazy:dc,ZodLiteral:fc,ZodEnum:ls,ZodNativeEnum:hc,ZodPromise:mu,ZodEffects:Ei,ZodTransformer:Ei,ZodOptional:Sa,ZodNullable:co,ZodDefault:pc,ZodCatch:Ef,ZodNaN:Cf,BRAND:mN,ZodBranded:z_,ZodPipeline:vc,ZodReadonly:Rf,custom:H_,Schema:lr,ZodSchema:lr,late:gN,get ZodFirstPartyTypeKind(){return Bt},coerce:{string:t=>$i.create({...t,coerce:!0}),number:t=>os.create({...t,coerce:!0}),boolean:t=>ac.create({...t,coerce:!0}),bigint:t=>us.create({...t,coerce:!0}),date:t=>oo.create({...t,coerce:!0})},any:TN,array:xN,bigint:wN,boolean:W_,date:_N,discriminatedUnion:PN,effect:Z_,enum:zN,function:UN,instanceof:yN,intersection:MN,lazy:FN,literal:BN,map:DN,nan:bN,nativeEnum:HN,never:CN,null:$N,nullable:WN,number:V_,object:IN,oboolean:()=>W_().optional(),onumber:()=>V_().optional(),optional:VN,ostring:()=>q_().optional(),pipeline:GN,preprocess:ZN,promise:qN,record:LN,set:jN,strictObject:AN,string:q_,symbol:kN,transformer:Z_,tuple:NN,undefined:SN,union:ON,unknown:EN,void:RN,NEVER:Xt,ZodIssueCode:st,quotelessJson:rN,ZodError:Si});const KN={sm:"md:w-[350px]",md:"md:w-[500px]",lg:"md:w-[760px]",xl:"md:w-[900px]",xxl:"md:w-[1200px]"},JN={sm:"md:h-[400px]",md:"md:h-[500px]",lg:"md:h-[600px]",xl:"md:h-[700px]",xxl:"md:h-[800px]"},xf=yt.object({assistantId:yt.string(),clientId:yt.string().optional(),params:yt.record(yt.any()).default({}),config:yt.object({historyKey:yt.string().refine(t=>t.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:yt.string().default("Hello! How can I help you today?"),focusOnOpen:yt.boolean().default(!0),inactivityWarningMessage:yt.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:yt.string().default("Chat Ended"),resetEndedChatOnLoad:yt.boolean().default(!1),disableMessageRating:yt.boolean().default(!1),initialReplyMessage:yt.string().nullable().default(null),disclaimerMessage:yt.string().nullable().default(null),disclaimerPopover:yt.object({message:yt.string().nullable().default(null),agreeButtonText:yt.string().default("I Agree"),rememberDurationMinutes:yt.number().default(60*24*3)}).default({}),placement:yt.enum(["left","right"]).default("right"),openChatButton:yt.object({imageSrc:yt.string().nullable().default(null),width:yt.union([yt.string(),yt.number()]).default("48px"),height:yt.union([yt.string(),yt.number()]).default("48px"),cta:yt.string().nullable().default(null)}).default({}),chatWindow:yt.object({width:yt.enum(["sm","md","lg","xl","xxl"]).default("sm"),height:yt.enum(["sm","md","lg","xl","xxl"]).default("md"),header:yt.object({text:yt.string().nullable().default("AI Chat"),imageSrc:yt.string().nullable().default(null)}).default({}),showCloseButton:yt.boolean().default(!0)}).default({}),styles:yt.object({primaryColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null),linkColor:yt.string().nullable().default(null),openChatButton:yt.object({backgroundColor:yt.string().nullable().default(null),iconColor:yt.string().nullable().default(null)}).default({}),header:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),button:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),messages:yt.object({user:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),assistant:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({})}).default({})}).default({})}).default({}),handlers:yt.object({functionCalls:yt.record(yt.function().returns(yt.union([yt.any(),yt.promise(yt.any())]))).default({}),enhancedContent:yt.record(yt.function().returns(yt.union([yt.any(),yt.promise(yt.any())]))).default({})}).default({})});var YN=Object.defineProperty,QN=Object.getOwnPropertyDescriptor,gu=(t,e,r,n)=>{for(var i=n>1?void 0:n?QN(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&YN(e,r,i),i};let cs=class extends Ln{constructor(){super(...arguments),this.isOpen=!1,this.ctaClosed=!1,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?(kM(this,{allowTouchMove:t=>t.nodeName==="IAI-CHAT-POPUP"}),this.isIosDevice||(document.documentElement.style.overflow="hidden")):(x_(this),this.isIosDevice||(document.documentElement.style.overflow=this.initialHtmlOverflow))}}connectedCallback(){super.connectedCallback(),this.cleanOptions=xf.parse(this.options),this.identifyIosDevice(),this.setInitialHtmlOverflow(),this.initialScrollPosition={x:0,y:0},this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),x_(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const{placement:t,chatWindow:e}=this.cleanOptions.config,{height:r,cta:n}=this.cleanOptions.config.openChatButton,i=eN("chat-widget w-dvw h-dvh md:mx-8",KN[e.width],JN[e.height],this.isOpen?"":"invisible");return ar`
388
+ */function wa(t,e,r){return t?e(t):r==null?void 0:r(t)}const Lv="-",SM=t=>{const e=TM(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:i=>{const a=i.split(Lv);return a[0]===""&&a.length!==1&&a.shift(),I_(a,e)||$M(i)},getConflictingClassGroupIds:(i,a)=>{const s=r[i]||[];return a&&n[i]?[...s,...n[i]]:s}}},I_=(t,e)=>{var r;if(t.length===0)return e.classGroupId;const n=t[0],i=e.nextPart.get(n),a=i?I_(t.slice(1),i):void 0;if(a)return a;if(e.validators.length===0)return;const s=t.join(Lv);return(r=e.validators.find(({validator:o})=>o(s)))==null?void 0:r.classGroupId},A_=/^\[(.+)\]$/,$M=t=>{if(A_.test(t)){const e=A_.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},TM=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return CM(Object.entries(t.classGroups),r).forEach(([i,a])=>{Dv(a,n,i,e)}),n},Dv=(t,e,r,n)=>{t.forEach(i=>{if(typeof i=="string"){const a=i===""?e:O_(e,i);a.classGroupId=r;return}if(typeof i=="function"){if(EM(i)){Dv(i(n),e,r,n);return}e.validators.push({validator:i,classGroupId:r});return}Object.entries(i).forEach(([a,s])=>{Dv(s,O_(e,a),r,n)})})},O_=(t,e)=>{let r=t;return e.split(Lv).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},EM=t=>t.isThemeGetter,CM=(t,e)=>e?t.map(([r,n])=>{const i=n.map(a=>typeof a=="string"?e+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([s,o])=>[e+s,o])):a);return[r,i]}):t,RM=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const i=(a,s)=>{r.set(a,s),e++,e>t&&(e=0,n=r,r=new Map)};return{get(a){let s=r.get(a);if(s!==void 0)return s;if((s=n.get(a))!==void 0)return i(a,s),s},set(a,s){r.has(a)?r.set(a,s):i(a,s)}}},P_="!",xM=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,i=e[0],a=e.length,s=o=>{const u=[];let l=0,c=0,d;for(let N=0;N<o.length;N++){let z=o[N];if(l===0){if(z===i&&(n||o.slice(N,N+a)===e)){u.push(o.slice(c,N)),c=N+a;continue}if(z==="/"){d=N;continue}}z==="["?l++:z==="]"&&l--}const f=u.length===0?o:o.substring(c),m=f.startsWith(P_),b=m?f.substring(1):f,A=d&&d>c?d-c:void 0;return{modifiers:u,hasImportantModifier:m,baseClassName:b,maybePostfixModifierPosition:A}};return r?o=>r({className:o,parseClassName:s}):s},IM=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},AM=t=>({cache:RM(t.cacheSize),parseClassName:xM(t),...SM(t)}),OM=/\s+/,PM=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i}=e,a=[],s=t.trim().split(OM);let o="";for(let u=s.length-1;u>=0;u-=1){const l=s[u],{modifiers:c,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:m}=r(l);let b=!!m,A=n(b?f.substring(0,m):f);if(!A){if(!b){o=l+(o.length>0?" "+o:o);continue}if(A=n(f),!A){o=l+(o.length>0?" "+o:o);continue}b=!1}const N=IM(c).join(":"),z=d?N+P_:N,X=z+A;if(a.includes(X))continue;a.push(X);const Ee=i(A,b);for(let Ie=0;Ie<Ee.length;++Ie){const Fe=Ee[Ie];a.push(z+Fe)}o=l+(o.length>0?" "+o:o)}return o};function MM(){let t=0,e,r,n="";for(;t<arguments.length;)(e=arguments[t++])&&(r=M_(e))&&(n&&(n+=" "),n+=r);return n}const M_=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=M_(t[n]))&&(r&&(r+=" "),r+=e);return r};function NM(t,...e){let r,n,i,a=s;function s(u){const l=e.reduce((c,d)=>d(c),t());return r=AM(l),n=r.cache.get,i=r.cache.set,a=o,o(u)}function o(u){const l=n(u);if(l)return l;const c=PM(u,r);return i(u,c),c}return function(){return a(MM.apply(null,arguments))}}const Ur=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},N_=/^\[(?:([a-z-]+):)?(.+)\]$/i,LM=/^\d+\/\d+$/,DM=new Set(["px","full","screen"]),jM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,UM=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,FM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,BM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,zM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_a=t=>du(t)||DM.has(t)||LM.test(t),is=t=>fu(t,"length",JM),du=t=>!!t&&!Number.isNaN(Number(t)),jv=t=>fu(t,"number",du),tc=t=>!!t&&Number.isInteger(Number(t)),HM=t=>t.endsWith("%")&&du(t.slice(0,-1)),sr=t=>N_.test(t),as=t=>jM.test(t),qM=new Set(["length","size","percentage"]),VM=t=>fu(t,qM,L_),WM=t=>fu(t,"position",L_),ZM=new Set(["image","url"]),GM=t=>fu(t,ZM,QM),KM=t=>fu(t,"",YM),rc=()=>!0,fu=(t,e,r)=>{const n=N_.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},JM=t=>UM.test(t)&&!FM.test(t),L_=()=>!1,YM=t=>BM.test(t),QM=t=>zM.test(t),XM=()=>{const t=Ur("colors"),e=Ur("spacing"),r=Ur("blur"),n=Ur("brightness"),i=Ur("borderColor"),a=Ur("borderRadius"),s=Ur("borderSpacing"),o=Ur("borderWidth"),u=Ur("contrast"),l=Ur("grayscale"),c=Ur("hueRotate"),d=Ur("invert"),f=Ur("gap"),m=Ur("gradientColorStops"),b=Ur("gradientColorStopPositions"),A=Ur("inset"),N=Ur("margin"),z=Ur("opacity"),X=Ur("padding"),Ee=Ur("saturate"),Ie=Ur("scale"),Fe=Ur("sepia"),Oe=Ur("skew"),ze=Ur("space"),V=Ur("translate"),xe=()=>["auto","contain","none"],_e=()=>["auto","hidden","clip","visible","scroll"],se=()=>["auto",sr,e],Te=()=>[sr,e],re=()=>["",_a,is],oe=()=>["auto",du,sr],q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],Se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",sr],ke=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>[du,sr];return{cacheSize:500,separator:":",theme:{colors:[rc],spacing:[_a,is],blur:["none","",as,sr],brightness:M(),borderColor:[t],borderRadius:["none","","full",as,sr],borderSpacing:Te(),borderWidth:re(),contrast:M(),grayscale:ye(),hueRotate:M(),invert:ye(),gap:Te(),gradientColorStops:[t],gradientColorStopPositions:[HM,is],inset:se(),margin:se(),opacity:M(),padding:Te(),saturate:M(),scale:M(),sepia:ye(),skew:M(),space:Te(),translate:Te()},classGroups:{aspect:[{aspect:["auto","square","video",sr]}],container:["container"],columns:[{columns:[as]}],"break-after":[{"break-after":ke()}],"break-before":[{"break-before":ke()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...q(),sr]}],overflow:[{overflow:_e()}],"overflow-x":[{"overflow-x":_e()}],"overflow-y":[{"overflow-y":_e()}],overscroll:[{overscroll:xe()}],"overscroll-x":[{"overscroll-x":xe()}],"overscroll-y":[{"overscroll-y":xe()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[A]}],"inset-x":[{"inset-x":[A]}],"inset-y":[{"inset-y":[A]}],start:[{start:[A]}],end:[{end:[A]}],top:[{top:[A]}],right:[{right:[A]}],bottom:[{bottom:[A]}],left:[{left:[A]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",tc,sr]}],basis:[{basis:se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",sr]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",tc,sr]}],"grid-cols":[{"grid-cols":[rc]}],"col-start-end":[{col:["auto",{span:["full",tc,sr]},sr]}],"col-start":[{"col-start":oe()}],"col-end":[{"col-end":oe()}],"grid-rows":[{"grid-rows":[rc]}],"row-start-end":[{row:["auto",{span:[tc,sr]},sr]}],"row-start":[{"row-start":oe()}],"row-end":[{"row-end":oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",sr]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",sr]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...H()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...H(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...H(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[X]}],px:[{px:[X]}],py:[{py:[X]}],ps:[{ps:[X]}],pe:[{pe:[X]}],pt:[{pt:[X]}],pr:[{pr:[X]}],pb:[{pb:[X]}],pl:[{pl:[X]}],m:[{m:[N]}],mx:[{mx:[N]}],my:[{my:[N]}],ms:[{ms:[N]}],me:[{me:[N]}],mt:[{mt:[N]}],mr:[{mr:[N]}],mb:[{mb:[N]}],ml:[{ml:[N]}],"space-x":[{"space-x":[ze]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[ze]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",sr,e]}],"min-w":[{"min-w":[sr,e,"min","max","fit"]}],"max-w":[{"max-w":[sr,e,"none","full","min","max","fit","prose",{screen:[as]},as]}],h:[{h:[sr,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[sr,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[sr,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[sr,e,"auto","min","max","fit"]}],"font-size":[{text:["base",as,is]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",jv]}],"font-family":[{font:[rc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",sr]}],"line-clamp":[{"line-clamp":["none",du,jv]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",_a,sr]}],"list-image":[{"list-image":["none",sr]}],"list-style-type":[{list:["none","disc","decimal",sr]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[z]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[z]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",_a,is]}],"underline-offset":[{"underline-offset":["auto",_a,sr]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Te()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",sr]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",sr]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[z]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...q(),WM]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",VM]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},GM]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[z]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[z]}],"divide-style":[{divide:ne()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ne()]}],"outline-offset":[{"outline-offset":[_a,sr]}],"outline-w":[{outline:[_a,is]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[z]}],"ring-offset-w":[{"ring-offset":[_a,is]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",as,KM]}],"shadow-color":[{shadow:[rc]}],opacity:[{opacity:[z]}],"mix-blend":[{"mix-blend":[...Se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Se()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",as,sr]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[d]}],saturate:[{saturate:[Ee]}],sepia:[{sepia:[Fe]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[z]}],"backdrop-saturate":[{"backdrop-saturate":[Ee]}],"backdrop-sepia":[{"backdrop-sepia":[Fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",sr]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",sr]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",sr]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[Ie]}],"scale-x":[{"scale-x":[Ie]}],"scale-y":[{"scale-y":[Ie]}],rotate:[{rotate:[tc,sr]}],"translate-x":[{"translate-x":[V]}],"translate-y":[{"translate-y":[V]}],"skew-x":[{"skew-x":[Oe]}],"skew-y":[{"skew-y":[Oe]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",sr]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",sr]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Te()}],"scroll-mx":[{"scroll-mx":Te()}],"scroll-my":[{"scroll-my":Te()}],"scroll-ms":[{"scroll-ms":Te()}],"scroll-me":[{"scroll-me":Te()}],"scroll-mt":[{"scroll-mt":Te()}],"scroll-mr":[{"scroll-mr":Te()}],"scroll-mb":[{"scroll-mb":Te()}],"scroll-ml":[{"scroll-ml":Te()}],"scroll-p":[{"scroll-p":Te()}],"scroll-px":[{"scroll-px":Te()}],"scroll-py":[{"scroll-py":Te()}],"scroll-ps":[{"scroll-ps":Te()}],"scroll-pe":[{"scroll-pe":Te()}],"scroll-pt":[{"scroll-pt":Te()}],"scroll-pr":[{"scroll-pr":Te()}],"scroll-pb":[{"scroll-pb":Te()}],"scroll-pl":[{"scroll-pl":Te()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",sr]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[_a,is,jv]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},eN=NM(XM);var tN=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function D_(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Uv={};(function(t){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function r(o,u,l,c){var d={timer:void 0,lastArgs:[]},f=function(){for(var m=this,b=[],A=0;A<arguments.length;A++)b[A]=arguments[A];d.lastArgs=b,d.timer?clearTimeout(d.timer):u&&l.apply(this,d.lastArgs),d.timer=setTimeout(function(){u||l.apply(m,d.lastArgs),d.timer=void 0},o)};return c&&(f=f.bind(c)),f.options=d,f}function n(o,u,l,c){var d;Object.defineProperty(l,c,{configurable:!0,enumerable:!1,get:function(){return d},set:function(f){d=r(o,u,f,this)}})}function i(o,u,l){var c=l.value;return l.value=r(o,u,c),l}function a(o,u){for(var l=[],c=2;c<arguments.length;c++)l[c-2]=arguments[c];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var d=l[0],f=l[1],m=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(d,f);if(m)return i(o,u,m);n(o,u,d,f)}function s(){for(var o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];var l=500,c=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var d=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(d=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(d=o[1]),d&&(c=d.leading),function(){for(var f=[],m=0;m<arguments.length;m++)f[m]=arguments[m];return a.apply(void 0,[l,c].concat(f))}}return a.apply(void 0,[l,c].concat(o))}Object.defineProperty(t,"__esModule",{value:!0}),t.cancel=e,t.debounce=s})(Uv);var yr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(yr||(yr={}));var Fv;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Fv||(Fv={}));const gt=yr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ss=t=>{switch(typeof t){case"undefined":return gt.undefined;case"string":return gt.string;case"number":return isNaN(t)?gt.nan:gt.number;case"boolean":return gt.boolean;case"function":return gt.function;case"bigint":return gt.bigint;case"symbol":return gt.symbol;case"object":return Array.isArray(t)?gt.array:t===null?gt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?gt.promise:typeof Map<"u"&&t instanceof Map?gt.map:typeof Set<"u"&&t instanceof Set?gt.set:typeof Date<"u"&&t instanceof Date?gt.date:gt.object;default:return gt.unknown}},st=yr.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"]),rN=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Si extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,yr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Si.create=t=>new Si(t);const nc=(t,e)=>{let r;switch(t.code){case st.invalid_type:t.received===gt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case st.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,yr.jsonStringifyReplacer)}`;break;case st.unrecognized_keys:r=`Unrecognized key(s) in object: ${yr.joinValues(t.keys,", ")}`;break;case st.invalid_union:r="Invalid input";break;case st.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${yr.joinValues(t.options)}`;break;case st.invalid_enum_value:r=`Invalid enum value. Expected ${yr.joinValues(t.options)}, received '${t.received}'`;break;case st.invalid_arguments:r="Invalid function arguments";break;case st.invalid_return_type:r="Invalid function return type";break;case st.invalid_date:r="Invalid date";break;case st.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}"`:yr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case st.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==="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 st.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 st.custom:r="Invalid input";break;case st.invalid_intersection_types:r="Intersection results could not be merged";break;case st.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case st.not_finite:r="Number must be finite";break;default:r=e.defaultError,yr.assertNever(t)}return{message:r}};let j_=nc;function nN(t){j_=t}function yf(){return j_}const bf=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:i.message||o}},iN=[];function _t(t,e){const r=bf({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,yf(),nc].filter(n=>!!n)});t.common.issues.push(r)}class gn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return Xt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r)n.push({key:await i.key,value:await i.value});return gn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return Xt;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const Xt=Object.freeze({status:"aborted"}),U_=t=>({status:"dirty",value:t}),En=t=>({status:"valid",value:t}),Bv=t=>t.status==="aborted",zv=t=>t.status==="dirty",ic=t=>t.status==="valid",wf=t=>typeof Promise<"u"&&t instanceof Promise;var Dt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Dt||(Dt={}));class Zi{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const F_=(t,e)=>{if(ic(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 Si(t.common.issues);return this._error=r,this._error}}};function nr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>a.code!=="invalid_type"?{message:s.defaultError}:typeof s.data>"u"?{message:n??s.defaultError}:{message:r??s.defaultError},description:i}}class lr{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)}get description(){return this._def.description}_getType(e){return ss(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ss(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new gn,ctx:{common:e.parent.common,data:e.data,parsedType:ss(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(wf(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 n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ss(e)},a=this._parseSync({data:e,path:i.path,parent:i});return F_(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={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:ss(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(wf(i)?i:Promise.resolve(i));return F_(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:st.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new Ei({schema:this,typeName:Bt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Sa.create(this,this._def)}nullable(){return co.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ti.create(this,this._def)}promise(){return mu.create(this,this._def)}or(e){return uc.create([this,e],this._def)}and(e){return lc.create(this,e,this._def)}transform(e){return new Ei({...nr(this._def),schema:this,typeName:Bt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new pc({...nr(this._def),innerType:this,defaultValue:r,typeName:Bt.ZodDefault})}brand(){return new z_({typeName:Bt.ZodBranded,type:this,...nr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Ef({...nr(this._def),innerType:this,catchValue:r,typeName:Bt.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return vc.create(this,e)}readonly(){return Rf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const aN=/^c[^\s-]{8,}$/i,sN=/^[a-z][a-z0-9]*$/,oN=/^[0-9A-HJKMNP-TV-Z]{26}$/,uN=/^[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,lN=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cN="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Hv;const dN=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,fN=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,hN=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function pN(t,e){return!!((e==="v4"||!e)&&dN.test(t)||(e==="v6"||!e)&&fN.test(t))}class $i extends lr{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==gt.string){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.string,received:i.parsedType}),Xt}const r=new gn;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,s=e.data.length<i.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?_t(n,{code:st.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&_t(n,{code:st.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")lN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"email",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Hv||(Hv=new RegExp(cN,"u")),Hv.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"emoji",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")uN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"uuid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")aN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"cuid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")sN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"cuid2",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")oN.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"ulid",code:st.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),_t(n,{validation:"url",code:st.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"regex",code:st.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.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),_t(n,{code:st.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?hN(i).test(e.data)||(n=this._getOrReturnCtx(e,n),_t(n,{code:st.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="ip"?pN(e.data,i.version)||(n=this._getOrReturnCtx(e,n),_t(n,{validation:"ip",code:st.invalid_string,message:i.message}),r.dirty()):yr.assertNever(i);return{status:r.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:st.invalid_string,...Dt.errToObj(n)})}_addCheck(e){return new $i({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Dt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Dt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Dt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Dt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Dt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Dt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Dt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Dt.errToObj(e)})}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,...Dt.errToObj(e==null?void 0:e.message)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Dt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Dt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Dt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Dt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Dt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Dt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Dt.errToObj(r)})}nonempty(e){return this.min(1,Dt.errToObj(e))}trim(){return new $i({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $i({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 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}}$i.create=t=>{var e;return new $i({checks:[],typeName:Bt.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...nr(t)})};function vN(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class os extends lr{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)!==gt.number){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.number,received:i.parsedType}),Xt}let r;const n=new gn;for(const i of this._def.checks)i.kind==="int"?yr.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),_t(r,{code:st.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.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)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?vN(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_finite,message:i.message}),n.dirty()):yr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Dt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Dt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Dt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Dt.toString(r))}setLimit(e,r,n,i){return new os({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(e){return new os({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Dt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Dt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Dt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Dt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Dt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Dt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Dt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Dt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Dt.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"&&yr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}os.create=t=>new os({checks:[],typeName:Bt.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...nr(t)});class us extends lr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==gt.bigint){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.bigint,received:i.parsedType}),Xt}let r;const n=new gn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.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)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),_t(r,{code:st.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):yr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Dt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Dt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Dt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Dt.toString(r))}setLimit(e,r,n,i){return new us({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Dt.toString(i)}]})}_addCheck(e){return new us({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Dt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Dt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Dt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Dt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Dt.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}}us.create=t=>{var e;return new us({checks:[],typeName:Bt.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...nr(t)})};class ac extends lr{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==gt.boolean){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.boolean,received:r.parsedType}),Xt}return En(e.data)}}ac.create=t=>new ac({typeName:Bt.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...nr(t)});class oo extends lr{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==gt.date){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_type,expected:gt.date,received:i.parsedType}),Xt}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return _t(i,{code:st.invalid_date}),Xt}const r=new gn;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),_t(n,{code:st.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):yr.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new oo({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Dt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Dt.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}}oo.create=t=>new oo({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Bt.ZodDate,...nr(t)});class _f extends lr{_parse(e){if(this._getType(e)!==gt.symbol){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.symbol,received:r.parsedType}),Xt}return En(e.data)}}_f.create=t=>new _f({typeName:Bt.ZodSymbol,...nr(t)});class sc extends lr{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.undefined,received:r.parsedType}),Xt}return En(e.data)}}sc.create=t=>new sc({typeName:Bt.ZodUndefined,...nr(t)});class oc extends lr{_parse(e){if(this._getType(e)!==gt.null){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.null,received:r.parsedType}),Xt}return En(e.data)}}oc.create=t=>new oc({typeName:Bt.ZodNull,...nr(t)});class hu extends lr{constructor(){super(...arguments),this._any=!0}_parse(e){return En(e.data)}}hu.create=t=>new hu({typeName:Bt.ZodAny,...nr(t)});class uo extends lr{constructor(){super(...arguments),this._unknown=!0}_parse(e){return En(e.data)}}uo.create=t=>new uo({typeName:Bt.ZodUnknown,...nr(t)});class ka extends lr{_parse(e){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.never,received:r.parsedType}),Xt}}ka.create=t=>new ka({typeName:Bt.ZodNever,...nr(t)});class kf extends lr{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.void,received:r.parsedType}),Xt}return En(e.data)}}kf.create=t=>new kf({typeName:Bt.ZodVoid,...nr(t)});class Ti extends lr{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==gt.array)return _t(r,{code:st.invalid_type,expected:gt.array,received:r.parsedType}),Xt;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(_t(r,{code:s?st.too_big:st.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(_t(r,{code:st.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(_t(r,{code:st.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new Zi(r,s,r.path,o)))).then(s=>gn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new Zi(r,s,r.path,o)));return gn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new Ti({...this._def,minLength:{value:e,message:Dt.toString(r)}})}max(e,r){return new Ti({...this._def,maxLength:{value:e,message:Dt.toString(r)}})}length(e,r){return new Ti({...this._def,exactLength:{value:e,message:Dt.toString(r)}})}nonempty(e){return this.min(1,e)}}Ti.create=(t,e)=>new Ti({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Bt.ZodArray,...nr(e)});function pu(t){if(t instanceof Zr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Sa.create(pu(n))}return new Zr({...t._def,shape:()=>e})}else return t instanceof Ti?new Ti({...t._def,type:pu(t.element)}):t instanceof Sa?Sa.create(pu(t.unwrap())):t instanceof co?co.create(pu(t.unwrap())):t instanceof Gi?Gi.create(t.items.map(e=>pu(e))):t}class Zr extends lr{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=yr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==gt.object){const u=this._getOrReturnCtx(e);return _t(u,{code:st.invalid_type,expected:gt.object,received:u.parsedType}),Xt}const{status:r,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof ka&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||s.push(u);const o=[];for(const u of a){const l=i[u],c=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new Zi(n,c,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof ka){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of s)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")s.length>0&&(_t(n,{code:st.unrecognized_keys,keys:s}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of s){const c=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new Zi(n,c,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const c=await l.key;u.push({key:c,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>gn.mergeObjectSync(r,u)):gn.mergeObjectSync(r,o)}get shape(){return this._def.shape()}strict(e){return Dt.errToObj,new Zr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Dt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Zr({...this._def,unknownKeys:"strip"})}passthrough(){return new Zr({...this._def,unknownKeys:"passthrough"})}extend(e){return new Zr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Zr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Bt.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Zr({...this._def,catchall:e})}pick(e){const r={};return yr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Zr({...this._def,shape:()=>r})}omit(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Zr({...this._def,shape:()=>r})}deepPartial(){return pu(this)}partial(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new Zr({...this._def,shape:()=>r})}required(e){const r={};return yr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof Sa;)i=i._def.innerType;r[n]=i}}),new Zr({...this._def,shape:()=>r})}keyof(){return B_(yr.objectKeys(this.shape))}}Zr.create=(t,e)=>new Zr({shape:()=>t,unknownKeys:"strip",catchall:ka.create(),typeName:Bt.ZodObject,...nr(e)}),Zr.strictCreate=(t,e)=>new Zr({shape:()=>t,unknownKeys:"strict",catchall:ka.create(),typeName:Bt.ZodObject,...nr(e)}),Zr.lazycreate=(t,e)=>new Zr({shape:t,unknownKeys:"strip",catchall:ka.create(),typeName:Bt.ZodObject,...nr(e)});class uc extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new Si(o.ctx.common.issues));return _t(r,{code:st.invalid_union,unionErrors:s}),Xt}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new Si(u));return _t(r,{code:st.invalid_union,unionErrors:o}),Xt}}get options(){return this._def.options}}uc.create=(t,e)=>new uc({options:t,typeName:Bt.ZodUnion,...nr(e)});const Sf=t=>t instanceof dc?Sf(t.schema):t instanceof Ei?Sf(t.innerType()):t instanceof fc?[t.value]:t instanceof ls?t.options:t instanceof hc?Object.keys(t.enum):t instanceof pc?Sf(t._def.innerType):t instanceof sc?[void 0]:t instanceof oc?[null]:null;class $f extends lr{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.object)return _t(r,{code:st.invalid_type,expected:gt.object,received:r.parsedType}),Xt;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(_t(r,{code:st.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Xt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=Sf(a.shape[e]);if(!s)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new $f({typeName:Bt.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...nr(n)})}}function qv(t,e){const r=ss(t),n=ss(e);if(t===e)return{valid:!0,data:t};if(r===gt.object&&n===gt.object){const i=yr.objectKeys(e),a=yr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=qv(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===gt.array&&n===gt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=qv(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===gt.date&&n===gt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class lc extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(Bv(a)||Bv(s))return Xt;const o=qv(a.value,s.value);return o.valid?((zv(a)||zv(s))&&r.dirty(),{status:r.value,value:o.data}):(_t(n,{code:st.invalid_intersection_types}),Xt)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}lc.create=(t,e,r)=>new lc({left:t,right:e,typeName:Bt.ZodIntersection,...nr(r)});class Gi extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.array)return _t(n,{code:st.invalid_type,expected:gt.array,received:n.parsedType}),Xt;if(n.data.length<this._def.items.length)return _t(n,{code:st.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Xt;!this._def.rest&&n.data.length>this._def.items.length&&(_t(n,{code:st.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((a,s)=>{const o=this._def.items[s]||this._def.rest;return o?o._parse(new Zi(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>gn.mergeArray(r,a)):gn.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Gi({...this._def,rest:e})}}Gi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gi({items:t,typeName:Bt.ZodTuple,rest:null,...nr(e)})};class cc extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.object)return _t(n,{code:st.invalid_type,expected:gt.object,received:n.parsedType}),Xt;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new Zi(n,o,n.path,o)),value:s._parse(new Zi(n,n.data[o],n.path,o))});return n.common.async?gn.mergeObjectAsync(r,i):gn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof lr?new cc({keyType:e,valueType:r,typeName:Bt.ZodRecord,...nr(n)}):new cc({keyType:$i.create(),valueType:e,typeName:Bt.ZodRecord,...nr(r)})}}class Tf extends lr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.map)return _t(n,{code:st.invalid_type,expected:gt.map,received:n.parsedType}),Xt;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new Zi(n,o,n.path,[l,"key"])),value:a._parse(new Zi(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return Xt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return Xt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}Tf.create=(t,e,r)=>new Tf({valueType:e,keyType:t,typeName:Bt.ZodMap,...nr(r)});class lo extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.set)return _t(n,{code:st.invalid_type,expected:gt.set,received:n.parsedType}),Xt;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(_t(n,{code:st.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(_t(n,{code:st.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return Xt;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new Zi(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new lo({...this._def,minSize:{value:e,message:Dt.toString(r)}})}max(e,r){return new lo({...this._def,maxSize:{value:e,message:Dt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}lo.create=(t,e)=>new lo({valueType:t,minSize:null,maxSize:null,typeName:Bt.ZodSet,...nr(e)});class vu extends lr{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.function)return _t(r,{code:st.invalid_type,expected:gt.function,received:r.parsedType}),Xt;function n(o,u){return bf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yf(),nc].filter(l=>!!l),issueData:{code:st.invalid_arguments,argumentsError:u}})}function i(o,u){return bf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,yf(),nc].filter(l=>!!l),issueData:{code:st.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof mu){const o=this;return En(async function(...u){const l=new Si([]),c=await o._def.args.parseAsync(u,a).catch(f=>{throw l.addIssue(n(u,f)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(f=>{throw l.addIssue(i(d,f)),l})})}else{const o=this;return En(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Si([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new Si([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new vu({...this._def,args:Gi.create(e).rest(uo.create())})}returns(e){return new vu({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new vu({args:e||Gi.create([]).rest(uo.create()),returns:r||uo.create(),typeName:Bt.ZodFunction,...nr(n)})}}class dc extends lr{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})}}dc.create=(t,e)=>new dc({getter:t,typeName:Bt.ZodLazy,...nr(e)});class fc extends lr{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return _t(r,{received:r.data,code:st.invalid_literal,expected:this._def.value}),Xt}return{status:"valid",value:e.data}}get value(){return this._def.value}}fc.create=(t,e)=>new fc({value:t,typeName:Bt.ZodLiteral,...nr(e)});function B_(t,e){return new ls({values:t,typeName:Bt.ZodEnum,...nr(e)})}class ls extends lr{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return _t(r,{expected:yr.joinValues(n),received:r.parsedType,code:st.invalid_type}),Xt}if(this._def.values.indexOf(e.data)===-1){const r=this._getOrReturnCtx(e),n=this._def.values;return _t(r,{received:r.data,code:st.invalid_enum_value,options:n}),Xt}return En(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){return ls.create(e)}exclude(e){return ls.create(this.options.filter(r=>!e.includes(r)))}}ls.create=B_;class hc extends lr{_parse(e){const r=yr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==gt.string&&n.parsedType!==gt.number){const i=yr.objectValues(r);return _t(n,{expected:yr.joinValues(i),received:n.parsedType,code:st.invalid_type}),Xt}if(r.indexOf(e.data)===-1){const i=yr.objectValues(r);return _t(n,{received:n.data,code:st.invalid_enum_value,options:i}),Xt}return En(e.data)}get enum(){return this._def.values}}hc.create=(t,e)=>new hc({values:t,typeName:Bt.ZodNativeEnum,...nr(e)});class mu extends lr{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.promise&&r.common.async===!1)return _t(r,{code:st.invalid_type,expected:gt.promise,received:r.parsedType}),Xt;const n=r.parsedType===gt.promise?r.data:Promise.resolve(r.data);return En(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}mu.create=(t,e)=>new mu({type:t,typeName:Bt.ZodPromise,...nr(e)});class Ei extends lr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Bt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{_t(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(s).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:s,path:n.path,parent:n})}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Xt:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Xt:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ic(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>ic(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);yr.assertNever(i)}}Ei.create=(t,e,r)=>new Ei({schema:t,typeName:Bt.ZodEffects,effect:e,...nr(r)}),Ei.createWithPreprocess=(t,e,r)=>new Ei({schema:e,effect:{type:"preprocess",transform:t},typeName:Bt.ZodEffects,...nr(r)});class Sa extends lr{_parse(e){return this._getType(e)===gt.undefined?En(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sa.create=(t,e)=>new Sa({innerType:t,typeName:Bt.ZodOptional,...nr(e)});class co extends lr{_parse(e){return this._getType(e)===gt.null?En(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}co.create=(t,e)=>new co({innerType:t,typeName:Bt.ZodNullable,...nr(e)});class pc extends lr{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===gt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}pc.create=(t,e)=>new pc({innerType:t,typeName:Bt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...nr(e)});class Ef extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return wf(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Si(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Si(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ef.create=(t,e)=>new Ef({innerType:t,typeName:Bt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...nr(e)});class Cf extends lr{_parse(e){if(this._getType(e)!==gt.nan){const r=this._getOrReturnCtx(e);return _t(r,{code:st.invalid_type,expected:gt.nan,received:r.parsedType}),Xt}return{status:"valid",value:e.data}}}Cf.create=t=>new Cf({typeName:Bt.ZodNaN,...nr(t)});const mN=Symbol("zod_brand");class z_ extends lr{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class vc extends lr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Xt:i.status==="dirty"?(r.dirty(),U_(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Xt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new vc({in:e,out:r,typeName:Bt.ZodPipeline})}}class Rf extends lr{_parse(e){const r=this._def.innerType._parse(e);return ic(r)&&(r.value=Object.freeze(r.value)),r}}Rf.create=(t,e)=>new Rf({innerType:t,typeName:Bt.ZodReadonly,...nr(e)});const H_=(t,e={},r)=>t?hu.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):hu.create(),gN={object:Zr.lazycreate};var Bt;(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"})(Bt||(Bt={}));const yN=(t,e={message:`Input not instance of ${t.name}`})=>H_(r=>r instanceof t,e),q_=$i.create,V_=os.create,bN=Cf.create,wN=us.create,W_=ac.create,_N=oo.create,kN=_f.create,SN=sc.create,$N=oc.create,TN=hu.create,EN=uo.create,CN=ka.create,RN=kf.create,xN=Ti.create,IN=Zr.create,AN=Zr.strictCreate,ON=uc.create,PN=$f.create,MN=lc.create,NN=Gi.create,LN=cc.create,DN=Tf.create,jN=lo.create,UN=vu.create,FN=dc.create,BN=fc.create,zN=ls.create,HN=hc.create,qN=mu.create,Z_=Ei.create,VN=Sa.create,WN=co.create,ZN=Ei.createWithPreprocess,GN=vc.create;var yt=Object.freeze({__proto__:null,defaultErrorMap:nc,setErrorMap:nN,getErrorMap:yf,makeIssue:bf,EMPTY_PATH:iN,addIssueToContext:_t,ParseStatus:gn,INVALID:Xt,DIRTY:U_,OK:En,isAborted:Bv,isDirty:zv,isValid:ic,isAsync:wf,get util(){return yr},get objectUtil(){return Fv},ZodParsedType:gt,getParsedType:ss,ZodType:lr,ZodString:$i,ZodNumber:os,ZodBigInt:us,ZodBoolean:ac,ZodDate:oo,ZodSymbol:_f,ZodUndefined:sc,ZodNull:oc,ZodAny:hu,ZodUnknown:uo,ZodNever:ka,ZodVoid:kf,ZodArray:Ti,ZodObject:Zr,ZodUnion:uc,ZodDiscriminatedUnion:$f,ZodIntersection:lc,ZodTuple:Gi,ZodRecord:cc,ZodMap:Tf,ZodSet:lo,ZodFunction:vu,ZodLazy:dc,ZodLiteral:fc,ZodEnum:ls,ZodNativeEnum:hc,ZodPromise:mu,ZodEffects:Ei,ZodTransformer:Ei,ZodOptional:Sa,ZodNullable:co,ZodDefault:pc,ZodCatch:Ef,ZodNaN:Cf,BRAND:mN,ZodBranded:z_,ZodPipeline:vc,ZodReadonly:Rf,custom:H_,Schema:lr,ZodSchema:lr,late:gN,get ZodFirstPartyTypeKind(){return Bt},coerce:{string:t=>$i.create({...t,coerce:!0}),number:t=>os.create({...t,coerce:!0}),boolean:t=>ac.create({...t,coerce:!0}),bigint:t=>us.create({...t,coerce:!0}),date:t=>oo.create({...t,coerce:!0})},any:TN,array:xN,bigint:wN,boolean:W_,date:_N,discriminatedUnion:PN,effect:Z_,enum:zN,function:UN,instanceof:yN,intersection:MN,lazy:FN,literal:BN,map:DN,nan:bN,nativeEnum:HN,never:CN,null:$N,nullable:WN,number:V_,object:IN,oboolean:()=>W_().optional(),onumber:()=>V_().optional(),optional:VN,ostring:()=>q_().optional(),pipeline:GN,preprocess:ZN,promise:qN,record:LN,set:jN,strictObject:AN,string:q_,symbol:kN,transformer:Z_,tuple:NN,undefined:SN,union:ON,unknown:EN,void:RN,NEVER:Xt,ZodIssueCode:st,quotelessJson:rN,ZodError:Si});const KN={sm:"md:w-[350px]",md:"md:w-[500px]",lg:"md:w-[760px]",xl:"md:w-[900px]",xxl:"md:w-[1200px]"},JN={sm:"md:h-[400px]",md:"md:h-[500px]",lg:"md:h-[600px]",xl:"md:h-[700px]",xxl:"md:h-[800px]"},xf=yt.object({assistantId:yt.string(),clientId:yt.string().optional(),params:yt.record(yt.any()).default({}),config:yt.object({historyKey:yt.string().refine(t=>t.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:yt.string().default("Hello! How can I help you today?"),focusOnOpen:yt.boolean().default(!0),inactivityWarningMessage:yt.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:yt.string().default("Chat Ended"),resetEndedChatOnLoad:yt.boolean().default(!1),disableMessageRating:yt.boolean().default(!1),initialReplyMessage:yt.string().nullable().default(null),disclaimerMessage:yt.string().nullable().default(null),disclaimerPopover:yt.object({message:yt.string().nullable().default(null),agreeButtonText:yt.string().default("I Agree"),rememberDurationMinutes:yt.number().default(60*24*3)}).default({}),placement:yt.enum(["left","right"]).default("right"),openChatButton:yt.object({imageSrc:yt.string().nullable().default(null),width:yt.union([yt.string(),yt.number()]).default("48px"),height:yt.union([yt.string(),yt.number()]).default("48px"),cta:yt.string().nullable().default(null)}).default({}),chatWindow:yt.object({width:yt.enum(["sm","md","lg","xl","xxl"]).default("sm"),height:yt.enum(["sm","md","lg","xl","xxl"]).default("md"),header:yt.object({text:yt.string().nullable().default("AI Chat"),imageSrc:yt.string().nullable().default(null)}).default({}),showCloseButton:yt.boolean().default(!0)}).default({}),styles:yt.object({primaryColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null),linkColor:yt.string().nullable().default(null),openChatButton:yt.object({backgroundColor:yt.string().nullable().default(null),iconColor:yt.string().nullable().default(null)}).default({}),header:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),button:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),messages:yt.object({user:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({}),assistant:yt.object({backgroundColor:yt.string().nullable().default(null),textColor:yt.string().nullable().default(null)}).default({})}).default({})}).default({})}).default({}),handlers:yt.object({functionCalls:yt.record(yt.function().returns(yt.union([yt.any(),yt.promise(yt.any())]))).default({}),enhancedContent:yt.record(yt.function().returns(yt.union([yt.any(),yt.promise(yt.any())]))).default({})}).default({})});var YN=Object.defineProperty,QN=Object.getOwnPropertyDescriptor,gu=(t,e,r,n)=>{for(var i=n>1?void 0:n?QN(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&YN(e,r,i),i};let cs=class extends Ln{constructor(){super(...arguments),this.isOpen=!1,this.ctaClosed=!1,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?(kM(this,{allowTouchMove:t=>t.nodeName==="IAI-CHAT-POPUP"}),this.isIosDevice||(document.documentElement.style.overflow="hidden")):(x_(this),this.isIosDevice||(document.documentElement.style.overflow=this.initialHtmlOverflow))}}connectedCallback(){super.connectedCallback(),this.cleanOptions=xf.parse(this.options),this.identifyIosDevice(),this.setInitialHtmlOverflow(),this.initialScrollPosition={x:0,y:0},this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),x_(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const{placement:t,chatWindow:e}=this.cleanOptions.config,{height:r,cta:n}=this.cleanOptions.config.openChatButton,i=eN("chat-widget w-dvw h-dvh md:mx-8",KN[e.width],JN[e.height],this.isOpen?"":"invisible");return ar`
389
389
  <div
390
390
  class="chat-widget-popup fixed flex flex-col bottom-0 z-40 ${gf({"right-0 items-end":t==="right","left-0 items-start":t==="left"})}"
391
391
  style=${Yl({colorScheme:"normal"})}
@@ -427,7 +427,7 @@
427
427
  max-height: calc(100dvh - var(--iai-i-button-height, 48px) - 4rem);
428
428
  }
429
429
  }
430
- `],gu([jr({type:Object})],cs.prototype,"options",2),gu([Xs()],cs.prototype,"isOpen",2),gu([Xs()],cs.prototype,"ctaClosed",2),gu([cf("iai-chat")],cs.prototype,"chatWindow",2),gu([Uv.debounce(250)],cs.prototype,"onResizeHandler",2),cs=gu([Vi("iai-chat-popup")],cs);const XN=typeof window<"u"&&window||typeof global<"u"&&global||{},e4=XN.IAI_BACKEND_URL||"https://api.ai.inhabit.services",yu={async get(t,e={}){return this.request(t,{...e,method:"GET"})},async post(t,e={},r={}){return this.request(t,{...r,method:"POST",body:JSON.stringify(e)})},async put(t,e={},r={}){return this.request(t,{...r,method:"PUT",body:JSON.stringify(e)})},async delete(t,e={}){return this.request(t,{...e,method:"DELETE"})},async patch(t,e={},r={}){return this.request(t,{...r,method:"PATCH",body:JSON.stringify(e)})},async request(t,e={}){const{returnFullResponse:r=!1,...n}=e,i={...n,headers:{"Content-Type":"application/json",...n.headers}};t=t.replace(/^\//,"");const a=await fetch(`${e4}/${t}`,i);if(!a.ok){if(a.status===429){const o=+(a.headers.get("Retry-After")||30);throw new mc(`Rate limited fetching /${t}: retry after ${o} seconds`,a.status,{retryAfter:o})}const s=[`Failed to fetch /${t}:`];try{const{message:o}=await a.json();if(!o)throw new Error;s.push(o)}catch{s.push(`${a.status} (${a.statusText})`)}throw new mc(s.join(" "),a.status)}if(r)return a;try{return await a.json()}catch{return null}}};async function t4(t,e={},r){return yu.post("/threads",{assistantId:t,params:e,clientId:r})}async function r4(t,e="No reason provided"){await yu.post(`/threads/${t}/end`,{reason:e})}async function n4(t,e){return yu.post(`/threads/${t}/messages`,{content:e})}async function i4(t,e,r){await yu.put(`/threads/${t}/messages/${e}/rate`,{rating:r})}async function a4(t,e,r,n=!1){return yu.post(`/threads/${t}/functions/${e}`,{params:r,rerunLLM:n})}async function s4(t){return yu.post(`/threads/${t}/ping`)}class mc extends Error{constructor(e,r,n){super(e),this.status=r,this.details=n}}function o4(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}class u4{constructor(e,r={}){if(this._assistantId="",this._recurringKeepAliveInterval=null,this._recurringKeepAliveCallers=new Set,this._conversationDetails=null,this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.chatEndingWarningSent=!1,this.chatEnded=!1,this._resetCounter=0,this.onStorageEvent=n=>{var i;const[a,s,o]=((i=n.key)==null?void 0:i.split("-"))||[];if(!(a!=="iaiChat"||s!==this.options.historyKey))switch(o){case"messageHistory":this.onMessageHistoryStorageEvent(n);break;case"conversation":this.setConversationDetails(JSON.parse(n.newValue||"null"),!0);break;case"lastActivity":this.keepAlive(JSON.parse(n.newValue||"null"),!0);break;case"chatEndingWarningSent":this.setChatEndingWarningSent(JSON.parse(n.newValue||"false"),!0);break;case"chatEnded":this.setChatEnded(JSON.parse(n.newValue||"false"),!0);break;case"typing":this.setTyping(JSON.parse(n.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(n.newValue||"false"),!0);break}},this.userMessageTypingId=null,this._assistantId=e,this._clientId=r.clientId,this.options={params:{},resetEndedChatOnLoad:!1,historyKey:"main",...r},this._emitter=o4(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),r.events&&Object.entries(r.events).forEach(([n,i])=>{this._emitter.on(n,i)}),r.historyKey){this._messages=this.storageGet("messageHistory",[]);const n=this.storageGet("conversation");n&&this.setConversationDetails(n,!0);const i=this.storageGet("chatEndingWarningSent");i&&this.setChatEndingWarningSent(i,!0);const a=this.storageGet("chatEnded");a&&this.setChatEnded(a,!0);const s=this.storageGet("typing");s&&this.setTyping(s,!0);const o=this.storageGet("inputDisabled");o&&this.setInputDisabled(o,!0);const u=this.storageGet("lastActivity");u&&setTimeout(()=>this.keepAlive(u,!0),0),setTimeout(()=>{this.chatEnded&&this.options.resetEndedChatOnLoad&&this.reset()},0),window.addEventListener("storage",this.onStorageEvent)}}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const r=JSON.parse(e.newValue),n=this._messages.map(a=>a.id),i=r.map(a=>a.id);this._messages.forEach(a=>{i.includes(a.id)||this._emitter.emit("messageRemoved",a.id)}),r.forEach(a=>{n.includes(a.id)||this._emitter.emit("message",a)}),this._messages=r}async endChat(e,r=!0){!this.threadId||this.chatEnded||(r&&(this._emitter.emit("chatEnded"),this.setChatEnded(!0)),this.stopInactivityTimers(),await r4(this.threadId,e))}reset(e){this.endChat(e,!1).then(()=>{}),this._messages=[],this.setConversationDetails(null),this.setTyping(!1),this.setInputDisabled(!1),this.setChatEnded(!1),this._recurringKeepAliveCallers.forEach(r=>r()),this.stopInactivityTimers(),this.setChatEndingWarningSent(!1),this.storageRemoveAll(),this._resetCounter+=1,this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this.stopInactivityTimers(),this._emitter.emit("destroy")}stopInactivityTimers(){this._inactivityTimeout&&(clearTimeout(this._inactivityTimeout),this._inactivityTimeout=null),this._inactivityWarningTimeout&&(clearTimeout(this._inactivityWarningTimeout),this._inactivityWarningTimeout=null)}keepAlive(e=Date.now(),r=!1){if(this.stopInactivityTimers(),this.chatEnded||!e)return;const{timeUntilChatEnds:n,timeUntilWarnAboutChatEnding:i}=this;if(!n)return;r||this.storageSet("lastActivity",e);const a=Date.now()-e;if(a>n){if(this.chatEnded)return;this.setChatEnded(!0),this._emitter.emit("chatEnded")}else a>i?(this.sendChatEndingWarning(),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a)):(this.setChatEndingWarningSent(!1),this._inactivityWarningTimeout=setTimeout(()=>this.sendChatEndingWarning(),i-a),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a))}registerRecurringKeepAlive(){if(!this.chatStarted)throw new Error("Chat not started");const e=()=>{this._recurringKeepAliveCallers.delete(e),this._recurringKeepAliveCallers.size===0&&this._recurringKeepAliveInterval&&(clearInterval(this._recurringKeepAliveInterval),this._recurringKeepAliveInterval=null)};return this._recurringKeepAliveCallers.add(e),this._recurringKeepAliveInterval||(this._recurringKeepAliveInterval=setInterval(()=>{this.chatStarted&&(this.keepAlive(),s4(this.threadId).then(()=>{}))},3e4)),e}async startChat(){if(this.chatStarted)return;const e=this.getResetChecker(),{id:r,inactivityWaitTime:n,inactivityWarningTime:i}=await t4(this.assistantId,this.params,this.clientId);if(!r)throw new Vv("Could not start chat","ChatStartError");if(e.resetOccurred)throw new Vv("Chat was reset","ChatReset");this.setConversationDetails({threadId:r,inactivityWaitTime:n,inactivityWarningTime:i})}handleSendUserMessageResponse({messages:e,functions:r}){this.addMessages(e),r.forEach(n=>this._emitter.emit("functionCall",n))}addMessages(e){e.forEach(r=>this.addMessage(r))}addMessage(e){const r={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(r),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",r),r}removeMessage(e){this._messages.find(r=>r.id===e)&&(this._messages=this._messages.filter(r=>r.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e))}async respondToFunctionCall(e,r,n){if(!this.threadId)throw new Error("Thread not started");try{const i=this.getResetChecker();this.setTyping(!0),this.keepAlive();const a=await a4(this.threadId,e,r,n);if(i.resetOccurred)return;this.handleSendUserMessageResponse(a)}catch(i){i instanceof mc&&i.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${i.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",i)}finally{this.setTyping(!1)}}getTypingManager(){let e=null;return{start:()=>{e=Math.random().toString(36).substring(7),this.userMessageTypingId=e,this.setTyping(!0)},done:()=>{this.userMessageTypingId===e&&(this.setTyping(!1),this.userMessageTypingId=null)}}}async sendUserMessage(e){const r=this.getTypingManager();try{const n=this.getResetChecker();if(this.addMessage({role:"user",content:e}),r.start(),!this.chatStarted){const{initialReplyMessage:a}=this.options;a&&this.addMessage({role:"assistant",content:a});try{await this.startChat()}catch(s){if(s instanceof mc&&s.status===429){this.sendErrorMessage(`You are starting new chats too quickly. You may try again in ${s.details.retryAfter} second(s).`);return}if(s instanceof Vv&&s.name==="ChatReset")return;throw s}}this.keepAlive();const i=await n4(this.threadId,e);if(n.resetOccurred)return;this.handleSendUserMessageResponse(i)}catch(n){n instanceof mc&&n.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${n.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",n)}finally{r.done()}}async rateMessage(e,r){const n=this._messages.find(i=>i.id===e);!n||n.role!=="assistant"||(n.userRating=r,this.storageSet("messageHistory",this._messages),await i4(this.threadId,e,r))}sendErrorMessage(e="There was an unexpected error. Please try again later."){this.addMessage({role:"assistant",content:e})}setTyping(e,r=!1){this.isTyping=e,this._emitter.emit("typing",e),r||this.storageSet("typing",e)}setConversationDetails(e,r=!1){this._conversationDetails=e,r||this.storageSet("conversation",e)}setInputDisabled(e,r=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),r||this.storageSet("inputDisabled",e)}setChatEnded(e,r=!1){this.chatEnded=e,r||this.storageSet("chatEnded",e)}setChatEndingWarningSent(e,r=!1){this.chatEndingWarningSent=e,r||this.storageSet("chatEndingWarningSent",e)}sendChatEndingWarning(){this.chatEndingWarningSent||(this._emitter.emit("inactivityWarning"),this.setChatEndingWarningSent(!0))}getResetChecker(){const e=this._resetCounter,r=this;return{get resetOccurred(){return e!==r._resetCounter}}}get assistantId(){return this._assistantId}get clientId(){return this._clientId}get params(){return this.options.params}get threadId(){var e;return(e=this._conversationDetails)==null?void 0:e.threadId}get timeUntilChatEnds(){const{inactivityWaitTime:e}=this._conversationDetails||{};return e?e*60*1e3:null}get timeUntilWarnAboutChatEnding(){const{inactivityWaitTime:e=0,inactivityWarningTime:r=0}=this._conversationDetails||{};return(e-r)*60*1e3}get messages(){return this._messages}get chatStarted(){return!!this.threadId}storageSet(e,r){this.options.historyKey&&localStorage.setItem(`iaiChat-${this.options.historyKey}-${e}`,JSON.stringify(r))}storageGet(e,r=null){if(!this.options.historyKey)return null;const n=localStorage.getItem(`iaiChat-${this.options.historyKey}-${e}`);return n?JSON.parse(n):r}storageRemove(e){localStorage.removeItem(`iaiChat-${this.options.historyKey}-${e}`)}storageRemoveAll(){this.options.historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this.options.historyKey}-`)&&localStorage.removeItem(e)})}}class Vv extends Error{constructor(e,r){super(e),this.name=r}}var G_={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(tN,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",b="date",A="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,X={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Ee=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Ie={s:Ee,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Ee(Se,2,"0")+":"+Ee(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:b,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Be="en",Oe={};Oe[Be]=X;var ze="$isDayjsObject",V=function(oe){return oe instanceof Te||!(!oe||!oe[ze])},xe=function oe(q,ne,Se){var H;if(!q)return Be;if(typeof q=="string"){var ye=q.toLowerCase();Oe[ye]&&(H=ye),ne&&(Oe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var M=q.name;Oe[M]=q,H=M}return!Se&&H&&(Be=H),H||!Se&&Be},_e=function(oe,q){if(V(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Ie;se.l=xe,se.i=V,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=xe(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var M=ke[2]-1||0,Xe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)):new Date(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==A},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),M=function(be,pt){var Ze=se.w(H.$u?Date.UTC(H.$y,pt,be):new Date(H.$y,pt,be),H);return ye?Ze:Ze.endOf(l)},Xe=function(be,pt){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(pt)),H)},Ct=this.$W,rt=this.$M,je=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?M(1,0):M(31,11);case d:return ye?M(1,rt):M(0,rt+1);case c:var Ke=this.$locale().weekStart||0,Fe=(Ct<Ke?Ct+7:Ct)-Ke;return M(ye?je-Fe:je+(6-Fe),rt);case l:case b:return Xe(ce+"Hours",0);case u:return Xe(ce+"Minutes",1);case o:return Xe(ce+"Seconds",2);case s:return Xe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),M=(H={},H[l]=ke+"Date",H[b]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Xe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(b,1);Ct.$d[M](Xe),Ct.init(),this.$d=Ct.set(b,Math.min(this.$D,Ct.daysInMonth())).$d}else M&&this.$d[M](Xe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),M=function(rt){var je=_e(ye);return se.w(je.date(je.date()+Math.round(rt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return M(1);if(ke===c)return M(7);var Xe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Xe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||A;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),M=this.$H,Xe=this.$m,Ct=this.$M,rt=H.weekdays,je=H.months,ce=H.meridiem,Ke=function(pt,Ze,Jt,At){return pt&&(pt[Ze]||pt(Se,ye))||Jt[Ze].slice(0,At)},Fe=function(pt){return se.s(M%12||12,pt,"0")},be=ce||function(pt,Ze,Jt){var At=pt<12?"AM":"PM";return Jt?At.toLowerCase():At};return ye.replace(z,function(pt,Ze){return Ze||function(Jt){switch(Jt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ke(H.monthsShort,Ct,je,3);case"MMMM":return Ke(je,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ke(H.weekdaysMin,Se.$W,rt,2);case"ddd":return Ke(H.weekdaysShort,Se.$W,rt,3);case"dddd":return rt[Se.$W];case"H":return String(M);case"HH":return se.s(M,2,"0");case"h":return Fe(1);case"hh":return Fe(2);case"a":return be(M,Xe,!0);case"A":return be(M,Xe,!1);case"m":return String(Xe);case"mm":return se.s(Xe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(pt)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,M=se.p(Se),Xe=_e(ne),Ct=(Xe.utcOffset()-this.utcOffset())*n,rt=this-Xe,je=function(){return se.m(ke,Xe)};switch(M){case m:ye=je()/12;break;case d:ye=je();break;case f:ye=je()/3;break;case c:ye=(rt-Ct)/6048e5;break;case l:ye=(rt-Ct)/864e5;break;case u:ye=rt/i;break;case o:ye=rt/n;break;case s:ye=rt/r;break;default:ye=rt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Oe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=xe(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),re=Te.prototype;return _e.prototype=re,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",b]].forEach(function(oe){re[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=xe,_e.isDayjs=V,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Oe[Be],_e.Ls=Oe,_e.p={},_e})})(G_);var l4=G_.exports;const K_=D_(l4);function c4(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}/**
430
+ `],gu([jr({type:Object})],cs.prototype,"options",2),gu([Xs()],cs.prototype,"isOpen",2),gu([Xs()],cs.prototype,"ctaClosed",2),gu([cf("iai-chat")],cs.prototype,"chatWindow",2),gu([Uv.debounce(250)],cs.prototype,"onResizeHandler",2),cs=gu([Vi("iai-chat-popup")],cs);const XN=typeof window<"u"&&window||typeof global<"u"&&global||{},e4=XN.IAI_BACKEND_URL||"https://api.ai.inhabit.services",yu={async get(t,e={}){return this.request(t,{...e,method:"GET"})},async post(t,e={},r={}){return this.request(t,{...r,method:"POST",body:JSON.stringify(e)})},async put(t,e={},r={}){return this.request(t,{...r,method:"PUT",body:JSON.stringify(e)})},async delete(t,e={}){return this.request(t,{...e,method:"DELETE"})},async patch(t,e={},r={}){return this.request(t,{...r,method:"PATCH",body:JSON.stringify(e)})},async request(t,e={}){const{returnFullResponse:r=!1,...n}=e,i={...n,headers:{"Content-Type":"application/json",...n.headers}};t=t.replace(/^\//,"");const a=await fetch(`${e4}/${t}`,i);if(!a.ok){if(a.status===429){const o=+(a.headers.get("Retry-After")||30);throw new mc(`Rate limited fetching /${t}: retry after ${o} seconds`,a.status,{retryAfter:o})}const s=[`Failed to fetch /${t}:`];try{const{message:o}=await a.json();if(!o)throw new Error;s.push(o)}catch{s.push(`${a.status} (${a.statusText})`)}throw new mc(s.join(" "),a.status)}if(r)return a;try{return await a.json()}catch{return null}}};async function t4(t,e={},r){return yu.post("/threads",{assistantId:t,params:e,clientId:r})}async function r4(t,e="No reason provided"){await yu.post(`/threads/${t}/end`,{reason:e})}async function n4(t,e){return yu.post(`/threads/${t}/messages`,{content:e})}async function i4(t,e,r){await yu.put(`/threads/${t}/messages/${e}/rate`,{rating:r})}async function a4(t,e,r,n=!1){return yu.post(`/threads/${t}/functions/${e}`,{params:r,rerunLLM:n})}async function s4(t){return yu.post(`/threads/${t}/ping`)}class mc extends Error{constructor(e,r,n){super(e),this.status=r,this.details=n}}function o4(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}class u4{constructor(e,r={}){if(this._assistantId="",this._recurringKeepAliveInterval=null,this._recurringKeepAliveCallers=new Set,this._conversationDetails=null,this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.chatEndingWarningSent=!1,this.chatEnded=!1,this._resetCounter=0,this.onStorageEvent=n=>{var i;const[a,s,o]=((i=n.key)==null?void 0:i.split("-"))||[];if(!(a!=="iaiChat"||s!==this.options.historyKey))switch(o){case"messageHistory":this.onMessageHistoryStorageEvent(n);break;case"conversation":this.setConversationDetails(JSON.parse(n.newValue||"null"),!0);break;case"lastActivity":this.keepAlive(JSON.parse(n.newValue||"null"),!0);break;case"chatEndingWarningSent":this.setChatEndingWarningSent(JSON.parse(n.newValue||"false"),!0);break;case"chatEnded":this.setChatEnded(JSON.parse(n.newValue||"false"),!0);break;case"typing":this.setTyping(JSON.parse(n.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(n.newValue||"false"),!0);break}},this.userMessageTypingId=null,this._assistantId=e,this._clientId=r.clientId,this.options={params:{},resetEndedChatOnLoad:!1,historyKey:"main",...r},this._emitter=o4(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),r.events&&Object.entries(r.events).forEach(([n,i])=>{this._emitter.on(n,i)}),r.historyKey){this._messages=this.storageGet("messageHistory",[]);const n=this.storageGet("conversation");n&&this.setConversationDetails(n,!0);const i=this.storageGet("chatEndingWarningSent");i&&this.setChatEndingWarningSent(i,!0);const a=this.storageGet("chatEnded");a&&this.setChatEnded(a,!0);const s=this.storageGet("typing");s&&this.setTyping(s,!0);const o=this.storageGet("inputDisabled");o&&this.setInputDisabled(o,!0);const u=this.storageGet("lastActivity");u&&setTimeout(()=>this.keepAlive(u,!0),0),setTimeout(()=>{this.chatEnded&&this.options.resetEndedChatOnLoad&&this.reset()},0),window.addEventListener("storage",this.onStorageEvent)}}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const r=JSON.parse(e.newValue),n=this._messages.map(a=>a.id),i=r.map(a=>a.id);this._messages.forEach(a=>{i.includes(a.id)||this._emitter.emit("messageRemoved",a.id)}),r.forEach(a=>{n.includes(a.id)||this._emitter.emit("message",a)}),this._messages=r}async endChat(e,r=!0){!this.threadId||this.chatEnded||(r&&(this._emitter.emit("chatEnded"),this.setChatEnded(!0)),this.stopInactivityTimers(),await r4(this.threadId,e))}reset(e){this.endChat(e,!1).then(()=>{}),this._messages=[],this.setConversationDetails(null),this.setTyping(!1),this.setInputDisabled(!1),this.setChatEnded(!1),this._recurringKeepAliveCallers.forEach(r=>r()),this.stopInactivityTimers(),this.setChatEndingWarningSent(!1),this.storageRemoveAll(),this._resetCounter+=1,this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this.stopInactivityTimers(),this._emitter.emit("destroy")}stopInactivityTimers(){this._inactivityTimeout&&(clearTimeout(this._inactivityTimeout),this._inactivityTimeout=null),this._inactivityWarningTimeout&&(clearTimeout(this._inactivityWarningTimeout),this._inactivityWarningTimeout=null)}keepAlive(e=Date.now(),r=!1){if(this.stopInactivityTimers(),this.chatEnded||!e)return;const{timeUntilChatEnds:n,timeUntilWarnAboutChatEnding:i}=this;if(!n)return;r||this.storageSet("lastActivity",e);const a=Date.now()-e;if(a>n){if(this.chatEnded)return;this.setChatEnded(!0),this._emitter.emit("chatEnded")}else a>i?(this.sendChatEndingWarning(),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a)):(this.setChatEndingWarningSent(!1),this._inactivityWarningTimeout=setTimeout(()=>this.sendChatEndingWarning(),i-a),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a))}registerRecurringKeepAlive(){if(!this.chatStarted)throw new Error("Chat not started");const e=()=>{this._recurringKeepAliveCallers.delete(e),this._recurringKeepAliveCallers.size===0&&this._recurringKeepAliveInterval&&(clearInterval(this._recurringKeepAliveInterval),this._recurringKeepAliveInterval=null)};return this._recurringKeepAliveCallers.add(e),this._recurringKeepAliveInterval||(this._recurringKeepAliveInterval=setInterval(()=>{this.chatStarted&&(this.keepAlive(),s4(this.threadId).then(()=>{}))},3e4)),e}async startChat(){if(this.chatStarted)return;const e=this.getResetChecker(),{id:r,inactivityWaitTime:n,inactivityWarningTime:i}=await t4(this.assistantId,this.params,this.clientId);if(!r)throw new Vv("Could not start chat","ChatStartError");if(e.resetOccurred)throw new Vv("Chat was reset","ChatReset");this.setConversationDetails({threadId:r,inactivityWaitTime:n,inactivityWarningTime:i})}handleSendUserMessageResponse({messages:e,functions:r}){this.addMessages(e),r.forEach(n=>this._emitter.emit("functionCall",n))}addMessages(e){e.forEach(r=>this.addMessage(r))}addMessage(e){const r={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(r),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",r),r}removeMessage(e){this._messages.find(r=>r.id===e)&&(this._messages=this._messages.filter(r=>r.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e))}async respondToFunctionCall(e,r,n){if(!this.threadId)throw new Error("Thread not started");try{const i=this.getResetChecker();this.setTyping(!0),this.keepAlive();const a=await a4(this.threadId,e,r,n);if(i.resetOccurred)return;this.handleSendUserMessageResponse(a)}catch(i){i instanceof mc&&i.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${i.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",i)}finally{this.setTyping(!1)}}getTypingManager(){let e=null;return{start:()=>{e=Math.random().toString(36).substring(7),this.userMessageTypingId=e,this.setTyping(!0)},done:()=>{this.userMessageTypingId===e&&(this.setTyping(!1),this.userMessageTypingId=null)}}}async sendUserMessage(e){const r=this.getTypingManager();try{const n=this.getResetChecker();if(this.addMessage({role:"user",content:e}),r.start(),!this.chatStarted){const{initialReplyMessage:a}=this.options;a&&this.addMessage({role:"assistant",content:a});try{await this.startChat()}catch(s){if(s instanceof mc&&s.status===429){this.sendErrorMessage(`You are starting new chats too quickly. You may try again in ${s.details.retryAfter} second(s).`);return}if(s instanceof Vv&&s.name==="ChatReset")return;throw s}}this.keepAlive();const i=await n4(this.threadId,e);if(n.resetOccurred)return;this.handleSendUserMessageResponse(i)}catch(n){n instanceof mc&&n.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${n.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",n)}finally{r.done()}}async rateMessage(e,r){const n=this._messages.find(i=>i.id===e);!n||n.role!=="assistant"||(n.userRating=r,this.storageSet("messageHistory",this._messages),await i4(this.threadId,e,r))}sendErrorMessage(e="There was an unexpected error. Please try again later."){this.addMessage({role:"assistant",content:e})}setTyping(e,r=!1){this.isTyping=e,this._emitter.emit("typing",e),r||this.storageSet("typing",e)}setConversationDetails(e,r=!1){this._conversationDetails=e,r||this.storageSet("conversation",e)}setInputDisabled(e,r=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),r||this.storageSet("inputDisabled",e)}setChatEnded(e,r=!1){this.chatEnded=e,r||this.storageSet("chatEnded",e)}setChatEndingWarningSent(e,r=!1){this.chatEndingWarningSent=e,r||this.storageSet("chatEndingWarningSent",e)}sendChatEndingWarning(){this.chatEndingWarningSent||(this._emitter.emit("inactivityWarning"),this.setChatEndingWarningSent(!0))}getResetChecker(){const e=this._resetCounter,r=this;return{get resetOccurred(){return e!==r._resetCounter}}}get assistantId(){return this._assistantId}get clientId(){return this._clientId}get params(){return this.options.params}get threadId(){var e;return(e=this._conversationDetails)==null?void 0:e.threadId}get timeUntilChatEnds(){const{inactivityWaitTime:e}=this._conversationDetails||{};return e?e*60*1e3:null}get timeUntilWarnAboutChatEnding(){const{inactivityWaitTime:e=0,inactivityWarningTime:r=0}=this._conversationDetails||{};return(e-r)*60*1e3}get messages(){return this._messages}get chatStarted(){return!!this.threadId}storageSet(e,r){this.options.historyKey&&localStorage.setItem(`iaiChat-${this.options.historyKey}-${e}`,JSON.stringify(r))}storageGet(e,r=null){if(!this.options.historyKey)return null;const n=localStorage.getItem(`iaiChat-${this.options.historyKey}-${e}`);return n?JSON.parse(n):r}storageRemove(e){localStorage.removeItem(`iaiChat-${this.options.historyKey}-${e}`)}storageRemoveAll(){this.options.historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this.options.historyKey}-`)&&localStorage.removeItem(e)})}}class Vv extends Error{constructor(e,r){super(e),this.name=r}}var G_={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(tN,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",b="date",A="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,X={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Ee=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Ie={s:Ee,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Ee(Se,2,"0")+":"+Ee(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:b,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Fe="en",Oe={};Oe[Fe]=X;var ze="$isDayjsObject",V=function(oe){return oe instanceof Te||!(!oe||!oe[ze])},xe=function oe(q,ne,Se){var H;if(!q)return Fe;if(typeof q=="string"){var ye=q.toLowerCase();Oe[ye]&&(H=ye),ne&&(Oe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var M=q.name;Oe[M]=q,H=M}return!Se&&H&&(Fe=H),H||!Se&&Fe},_e=function(oe,q){if(V(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Ie;se.l=xe,se.i=V,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=xe(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var M=ke[2]-1||0,Xe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)):new Date(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==A},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),M=function(be,pt){var Ze=se.w(H.$u?Date.UTC(H.$y,pt,be):new Date(H.$y,pt,be),H);return ye?Ze:Ze.endOf(l)},Xe=function(be,pt){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(pt)),H)},Ct=this.$W,rt=this.$M,je=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?M(1,0):M(31,11);case d:return ye?M(1,rt):M(0,rt+1);case c:var Ke=this.$locale().weekStart||0,Be=(Ct<Ke?Ct+7:Ct)-Ke;return M(ye?je-Be:je+(6-Be),rt);case l:case b:return Xe(ce+"Hours",0);case u:return Xe(ce+"Minutes",1);case o:return Xe(ce+"Seconds",2);case s:return Xe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),M=(H={},H[l]=ke+"Date",H[b]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Xe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(b,1);Ct.$d[M](Xe),Ct.init(),this.$d=Ct.set(b,Math.min(this.$D,Ct.daysInMonth())).$d}else M&&this.$d[M](Xe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),M=function(rt){var je=_e(ye);return se.w(je.date(je.date()+Math.round(rt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return M(1);if(ke===c)return M(7);var Xe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Xe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||A;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),M=this.$H,Xe=this.$m,Ct=this.$M,rt=H.weekdays,je=H.months,ce=H.meridiem,Ke=function(pt,Ze,Jt,At){return pt&&(pt[Ze]||pt(Se,ye))||Jt[Ze].slice(0,At)},Be=function(pt){return se.s(M%12||12,pt,"0")},be=ce||function(pt,Ze,Jt){var At=pt<12?"AM":"PM";return Jt?At.toLowerCase():At};return ye.replace(z,function(pt,Ze){return Ze||function(Jt){switch(Jt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ke(H.monthsShort,Ct,je,3);case"MMMM":return Ke(je,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ke(H.weekdaysMin,Se.$W,rt,2);case"ddd":return Ke(H.weekdaysShort,Se.$W,rt,3);case"dddd":return rt[Se.$W];case"H":return String(M);case"HH":return se.s(M,2,"0");case"h":return Be(1);case"hh":return Be(2);case"a":return be(M,Xe,!0);case"A":return be(M,Xe,!1);case"m":return String(Xe);case"mm":return se.s(Xe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(pt)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,M=se.p(Se),Xe=_e(ne),Ct=(Xe.utcOffset()-this.utcOffset())*n,rt=this-Xe,je=function(){return se.m(ke,Xe)};switch(M){case m:ye=je()/12;break;case d:ye=je();break;case f:ye=je()/3;break;case c:ye=(rt-Ct)/6048e5;break;case l:ye=(rt-Ct)/864e5;break;case u:ye=rt/i;break;case o:ye=rt/n;break;case s:ye=rt/r;break;default:ye=rt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Oe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=xe(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),re=Te.prototype;return _e.prototype=re,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",b]].forEach(function(oe){re[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=xe,_e.isDayjs=V,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Oe[Fe],_e.Ls=Oe,_e.p={},_e})})(G_);var l4=G_.exports;const K_=D_(l4);function c4(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}/**
431
431
  * @license
432
432
  * Copyright 2017 Google LLC
433
433
  * SPDX-License-Identifier: BSD-3-Clause
@@ -439,11 +439,11 @@
439
439
  `);const i=this.lexer.state.top;this.lexer.state.top=!0;const a=this.lexer.blockTokens(n);return this.lexer.state.top=i,{type:"blockquote",raw:r[0],tokens:a,text:n}}}list(e){let r=this.rules.block.list.exec(e);if(r){let n=r[1].trim();const i=n.length>1,a={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");const s=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let o="",u="",l=!1;for(;e;){let c=!1;if(!(r=s.exec(e))||this.rules.block.hr.test(e))break;o=r[0],e=e.substring(o.length);let d=r[2].split(`
440
440
  `,1)[0].replace(/^\t+/,z=>" ".repeat(3*z.length)),f=e.split(`
441
441
  `,1)[0],m=0;this.options.pedantic?(m=2,u=d.trimStart()):(m=r[2].search(/[^ ]/),m=m>4?1:m,u=d.slice(m),m+=r[1].length);let b=!1;if(!d&&/^ *$/.test(f)&&(o+=f+`
442
- `,e=e.substring(f.length+1),c=!0),!c){const z=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),X=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),Ee=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),Ie=new RegExp(`^ {0,${Math.min(3,m-1)}}#`);for(;e;){const Be=e.split(`
443
- `,1)[0];if(f=Be,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),Ee.test(f)||Ie.test(f)||z.test(f)||X.test(e))break;if(f.search(/[^ ]/)>=m||!f.trim())u+=`
442
+ `,e=e.substring(f.length+1),c=!0),!c){const z=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),X=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),Ee=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),Ie=new RegExp(`^ {0,${Math.min(3,m-1)}}#`);for(;e;){const Fe=e.split(`
443
+ `,1)[0];if(f=Fe,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),Ee.test(f)||Ie.test(f)||z.test(f)||X.test(e))break;if(f.search(/[^ ]/)>=m||!f.trim())u+=`
444
444
  `+f.slice(m);else{if(b||d.search(/[^ ]/)>=4||Ee.test(d)||Ie.test(d)||X.test(d))break;u+=`
445
- `+f}!b&&!f.trim()&&(b=!0),o+=Be+`
446
- `,e=e.substring(Be.length+1),d=f.slice(m)}}a.loose||(l?a.loose=!0:/\n *\n *$/.test(o)&&(l=!0));let A=null,N;this.options.gfm&&(A=/^\[[ xX]\] /.exec(u),A&&(N=A[0]!=="[ ] ",u=u.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:o,task:!!A,checked:N,loose:!1,text:u,tokens:[]}),a.raw+=o}a.items[a.items.length-1].raw=o.trimEnd(),a.items[a.items.length-1].text=u.trimEnd(),a.raw=a.raw.trimEnd();for(let c=0;c<a.items.length;c++)if(this.lexer.state.top=!1,a.items[c].tokens=this.lexer.blockTokens(a.items[c].text,[]),!a.loose){const d=a.items[c].tokens.filter(m=>m.type==="space"),f=d.length>0&&d.some(m=>/\n.*\n/.test(m.raw));a.loose=f}if(a.loose)for(let c=0;c<a.items.length;c++)a.items[c].loose=!0;return a}}html(e){const r=this.rules.block.html.exec(e);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(e){const r=this.rules.block.def.exec(e);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),i=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:i,title:a}}}table(e){const r=this.rules.block.table.exec(e);if(!r||!/[:|]/.test(r[2]))return;const n=t1(r[1]),i=r[2].replace(/^\||\| *$/g,"").split("|"),a=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
445
+ `+f}!b&&!f.trim()&&(b=!0),o+=Fe+`
446
+ `,e=e.substring(Fe.length+1),d=f.slice(m)}}a.loose||(l?a.loose=!0:/\n *\n *$/.test(o)&&(l=!0));let A=null,N;this.options.gfm&&(A=/^\[[ xX]\] /.exec(u),A&&(N=A[0]!=="[ ] ",u=u.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:o,task:!!A,checked:N,loose:!1,text:u,tokens:[]}),a.raw+=o}a.items[a.items.length-1].raw=o.trimEnd(),a.items[a.items.length-1].text=u.trimEnd(),a.raw=a.raw.trimEnd();for(let c=0;c<a.items.length;c++)if(this.lexer.state.top=!1,a.items[c].tokens=this.lexer.blockTokens(a.items[c].text,[]),!a.loose){const d=a.items[c].tokens.filter(m=>m.type==="space"),f=d.length>0&&d.some(m=>/\n.*\n/.test(m.raw));a.loose=f}if(a.loose)for(let c=0;c<a.items.length;c++)a.items[c].loose=!0;return a}}html(e){const r=this.rules.block.html.exec(e);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(e){const r=this.rules.block.def.exec(e);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),i=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:i,title:a}}}table(e){const r=this.rules.block.table.exec(e);if(!r||!/[:|]/.test(r[2]))return;const n=t1(r[1]),i=r[2].replace(/^\||\| *$/g,"").split("|"),a=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
447
447
  `):[],s={type:"table",raw:r[0],header:[],align:[],rows:[]};if(n.length===i.length){for(const o of i)/^ *-+: *$/.test(o)?s.align.push("right"):/^ *:-+: *$/.test(o)?s.align.push("center"):/^ *:-+ *$/.test(o)?s.align.push("left"):s.align.push(null);for(const o of n)s.header.push({text:o,tokens:this.lexer.inline(o)});for(const o of a)s.rows.push(t1(o,s.header.length).map(u=>({text:u,tokens:this.lexer.inline(u)})));return s}}lheading(e){const r=this.rules.block.lheading.exec(e);if(r)return{type:"heading",raw:r[0],depth:r[2].charAt(0)==="="?1:2,text:r[1],tokens:this.lexer.inline(r[1])}}paragraph(e){const r=this.rules.block.paragraph.exec(e);if(r){const n=r[1].charAt(r[1].length-1)===`
448
448
  `?r[1].slice(0,-1):r[1];return{type:"paragraph",raw:r[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const r=this.rules.block.text.exec(e);if(r)return{type:"text",raw:r[0],text:r[0],tokens:this.lexer.inline(r[0])}}escape(e){const r=this.rules.inline.escape.exec(e);if(r)return{type:"escape",raw:r[0],text:Gn(r[1])}}tag(e){const r=this.rules.inline.tag.exec(e);if(r)return!this.lexer.state.inLink&&/^<a /i.test(r[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(r[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:r[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:r[0]}}link(e){const r=this.rules.inline.link.exec(e);if(r){const n=r[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const s=If(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{const s=y4(r[2],"()");if(s>-1){const o=(r[0].indexOf("!")===0?5:4)+r[1].length+s;r[2]=r[2].substring(0,s),r[0]=r[0].substring(0,o).trim(),r[3]=""}}let i=r[2],a="";if(this.options.pedantic){const s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);s&&(i=s[1],a=s[3])}else a=r[3]?r[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(n)?i=i.slice(1):i=i.slice(1,-1)),r1(r,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},r[0],this.lexer)}}reflink(e,r){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const i=(n[2]||n[1]).replace(/\s+/g," "),a=r[i.toLowerCase()];if(!a){const s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return r1(n,a,n[0],this.lexer)}}emStrong(e,r,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(/[\p{L}\p{N}]/u))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){const a=[...i[0]].length-1;let s,o,u=a,l=0;const c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,r=r.slice(-1*e.length+a);(i=c.exec(r))!=null;){if(s=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!s)continue;if(o=[...s].length,i[3]||i[4]){u+=o;continue}else if((i[5]||i[6])&&a%3&&!((a+o)%3)){l+=o;continue}if(u-=o,u>0)continue;o=Math.min(o,o+u+l);const d=[...i[0]][0].length,f=e.slice(0,a+i.index+d+o);if(Math.min(a,o)%2){const b=f.slice(1,-1);return{type:"em",raw:f,text:b,tokens:this.lexer.inlineTokens(b)}}const m=f.slice(2,-2);return{type:"strong",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){const r=this.rules.inline.code.exec(e);if(r){let n=r[2].replace(/\n/g," ");const i=/[^ ]/.test(n),a=/^ /.test(n)&&/ $/.test(n);return i&&a&&(n=n.substring(1,n.length-1)),n=Gn(n,!0),{type:"codespan",raw:r[0],text:n}}}br(e){const r=this.rules.inline.br.exec(e);if(r)return{type:"br",raw:r[0]}}del(e){const r=this.rules.inline.del.exec(e);if(r)return{type:"del",raw:r[0],text:r[2],tokens:this.lexer.inlineTokens(r[2])}}autolink(e){const r=this.rules.inline.autolink.exec(e);if(r){let n,i;return r[2]==="@"?(n=Gn(r[1]),i="mailto:"+n):(n=Gn(r[1]),i=n),{type:"link",raw:r[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var r;let n;if(n=this.rules.inline.url.exec(e)){let i,a;if(n[2]==="@")i=Gn(n[0]),a="mailto:"+i;else{let s;do s=n[0],n[0]=((r=this.rules.inline._backpedal.exec(n[0]))==null?void 0:r[0])??"";while(s!==n[0]);i=Gn(n[0]),n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:i,href:a,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){const r=this.rules.inline.text.exec(e);if(r){let n;return this.lexer.state.inRawBlock?n=r[0]:n=Gn(r[0]),{type:"text",raw:r[0],text:n}}}}const w4=/^(?: *(?:\n|$))+/,_4=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,k4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,yc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,S4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,n1=/(?:[*+-]|\d{1,9}[.)])/,i1=xr(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,n1).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),Gv=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$4=/^[^\n]+/,Kv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,T4=xr(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",Kv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),E4=xr(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,n1).getRegex(),Of="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Jv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,C4=xr("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",Jv).replace("tag",Of).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),a1=xr(Gv).replace("hr",yc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Of).getRegex(),R4=xr(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",a1).getRegex(),Yv={blockquote:R4,code:_4,def:T4,fences:k4,heading:S4,hr:yc,html:C4,lheading:i1,list:E4,newline:w4,paragraph:a1,table:gc,text:$4},s1=xr("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",yc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Of).getRegex(),x4={...Yv,table:s1,paragraph:xr(Gv).replace("hr",yc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",s1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Of).getRegex()},I4={...Yv,html:xr(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Jv).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:gc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:xr(Gv).replace("hr",yc).replace("heading",` *#{1,6} *[^
449
449
  ]`).replace("lheading",i1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},o1=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,A4=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,u1=/^( {2,}|\\)\n(?!\s*$)/,O4=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,bc="\\p{P}\\p{S}",P4=xr(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,bc).getRegex(),M4=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,N4=xr(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,bc).getRegex(),L4=xr("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,bc).getRegex(),D4=xr("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,bc).getRegex(),j4=xr(/\\([punct])/,"gu").replace(/punct/g,bc).getRegex(),U4=xr(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),F4=xr(Jv).replace("(?:-->|$)","-->").getRegex(),B4=xr("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",F4).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Pf=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,z4=xr(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",Pf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),l1=xr(/^!?\[(label)\]\[(ref)\]/).replace("label",Pf).replace("ref",Kv).getRegex(),c1=xr(/^!?\[(ref)\](?:\[\])?/).replace("ref",Kv).getRegex(),H4=xr("reflink|nolink(?!\\()","g").replace("reflink",l1).replace("nolink",c1).getRegex(),Qv={_backpedal:gc,anyPunctuation:j4,autolink:U4,blockSkip:M4,br:u1,code:A4,del:gc,emStrongLDelim:N4,emStrongRDelimAst:L4,emStrongRDelimUnd:D4,escape:o1,link:z4,nolink:c1,punctuation:P4,reflink:l1,reflinkSearch:H4,tag:B4,text:O4,url:gc},q4={...Qv,link:xr(/^!?\[(label)\]\((.*?)\)/).replace("label",Pf).getRegex(),reflink:xr(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Pf).getRegex()},Xv={...Qv,escape:xr(o1).replace("])","~|])").getRegex(),url:xr(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},V4={...Xv,br:xr(u1).replace("{2,}","*").getRegex(),text:xr(Xv.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Mf={normal:Yv,gfm:x4,pedantic:I4},wc={normal:Qv,gfm:Xv,breaks:V4,pedantic:q4};class Ki{constructor(e){Hr(this,"tokens"),Hr(this,"options"),Hr(this,"state"),Hr(this,"tokenizer"),Hr(this,"inlineQueue"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||fo,this.options.tokenizer=this.options.tokenizer||new Af,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const r={block:Mf.normal,inline:wc.normal};this.options.pedantic?(r.block=Mf.pedantic,r.inline=wc.pedantic):this.options.gfm&&(r.block=Mf.gfm,this.options.breaks?r.inline=wc.breaks:r.inline=wc.gfm),this.tokenizer.rules=r}static get rules(){return{block:Mf,inline:wc}}static lex(e,r){return new Ki(r).lex(e)}static lexInline(e,r){return new Ki(r).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
@@ -618,7 +618,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const n="<p>An err
618
618
  .name {
619
619
  color: #8c8c8c;
620
620
  }
621
- `],ii([jr({type:Object})],Dn.prototype,"options",2),ii([jr()],Dn.prototype,"disableInput",2),ii([jr()],Dn.prototype,"showTyping",2),ii([Xs()],Dn.prototype,"messages",2),ii([Xs()],Dn.prototype,"inputValue",2),ii([Xs()],Dn.prototype,"internalShowTyping",2),ii([Xs()],Dn.prototype,"showPopoverDisclaimer",2),ii([Xs()],Dn.prototype,"previousThreads",2),ii([cf("#chat-container")],Dn.prototype,"chatContainer",2),ii([cf("#message-input")],Dn.prototype,"inputElement",2),ii([Uv.debounce(1)],Dn.prototype,"scrollChatToBottom",1),Dn=ii([Vi("iai-chat")],Dn);var p1={exports:{}};(function(t){(function(e){if(typeof window>"u")return;var r=0,n=!1,i=!1,a="message",s=a.length,o="[iFrameSizer]",u=o.length,l=null,c=window.requestAnimationFrame,d=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),f={},m=null,b=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){V("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function A(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function N(Q,Ue,ot){Q.addEventListener(Ue,ot,!1)}function z(Q,Ue,ot){Q.removeEventListener(Ue,ot,!1)}function X(){var Q=["moz","webkit","o","ms"],Ue;for(Ue=0;Ue<Q.length&&!c;Ue+=1)c=window[Q[Ue]+"RequestAnimationFrame"];c?c=c.bind(window):Oe("setup","RequestAnimationFrame not supported")}function Ee(Q){var Ue="Host page: "+Q;return window.top!==window.self&&(Ue=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+Q:"Nested host page: "+Q),Ue}function Ie(Q){return o+"["+Ee(Q)+"]"}function Be(Q){return f[Q]?f[Q].log:n}function Oe(Q,Ue){xe("log",Q,Ue,Be(Q))}function ze(Q,Ue){xe("info",Q,Ue,Be(Q))}function V(Q,Ue){xe("warn",Q,Ue,!0)}function xe(Q,Ue,ot,Pe){Pe===!0&&typeof window.console=="object"&&console[Q](Ie(Ue),ot)}function _e(Q){function Ue(){function we(){H(ae),q(me),zt("onResized",ae)}ut("Height"),ut("Width"),ye(we,ae,"init")}function ot(){var we=$e.slice(u).split(":"),K=we[1]?parseInt(we[1],10):0,he=f[we[0]]&&f[we[0]].iframe,G=getComputedStyle(he);return{iframe:he,id:we[0],height:K+Pe(G)+St(G),width:we[2],type:we[3]}}function Pe(we){if(we.boxSizing!=="border-box")return 0;var K=we.paddingTop?parseInt(we.paddingTop,10):0,he=we.paddingBottom?parseInt(we.paddingBottom,10):0;return K+he}function St(we){if(we.boxSizing!=="border-box")return 0;var K=we.borderTopWidth?parseInt(we.borderTopWidth,10):0,he=we.borderBottomWidth?parseInt(we.borderBottomWidth,10):0;return K+he}function ut(we){var K=Number(f[me]["max"+we]),he=Number(f[me]["min"+we]),G=we.toLowerCase(),de=Number(ae[G]);Oe(me,"Checking "+G+" is in range "+he+"-"+K),de<he&&(de=he,Oe(me,"Set "+G+" to min value")),de>K&&(de=K,Oe(me,"Set "+G+" to max value")),ae[G]=""+de}function or(){function we(){function G(){var ee=0,Ye=!1;for(Oe(me,"Checking connection is from allowed list of origins: "+he);ee<he.length;ee++)if(he[ee]===K){Ye=!0;break}return Ye}function de(){var ee=f[me]&&f[me].remoteHost;return Oe(me,"Checking connection is from: "+ee),K===ee}return he.constructor===Array?G():de()}var K=Q.origin,he=f[me]&&f[me].checkOrigin;if(he&&""+K!="null"&&!we())throw new Error("Unexpected message received from: "+K+" for "+ae.iframe.id+". Message was: "+Q.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function br(){return o===(""+$e).slice(0,u)&&$e.slice(u).split(":")[0]in f}function et(){var we=ae.type in{true:1,false:1,undefined:1};return we&&Oe(me,"Ignoring init message from meta parent page"),we}function Mr(we){return $e.slice($e.indexOf(":")+s+we)}function Fr(we){Oe(me,"onMessage passed: {iframe: "+ae.iframe.id+", message: "+we+"}"),zt("onMessage",{iframe:ae.iframe,message:JSON.parse(we)}),Oe(me,"--")}function dr(){var we=document.body.getBoundingClientRect(),K=ae.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:K.height,iframeWidth:K.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(K.top-we.top,10),offsetLeft:parseInt(K.left-we.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function fr(we,K){function he(){ke("Send Page Info","pageInfo:"+dr(),we,K)}ce(he,32,K)}function Wt(){function we(de,ee){function Ye(){f[G]?fr(f[G].iframe,G):K()}["scroll","resize"].forEach(function(qe){Oe(G,de+qe+" listener for sendPageInfo"),ee(window,qe,Ye)})}function K(){we("Remove ",z)}function he(){we("Add ",N)}var G=me;he(),f[G]&&(f[G].stopPageInfo=K)}function Ot(){f[me]&&f[me].stopPageInfo&&(f[me].stopPageInfo(),delete f[me].stopPageInfo)}function L(){var we=!0;return ae.iframe===null&&(V(me,"IFrame ("+ae.id+") not found"),we=!1),we}function W(we){var K=we.getBoundingClientRect();return oe(me),{x:Math.floor(Number(K.left)+Number(l.x)),y:Math.floor(Number(K.top)+Number(l.y))}}function ie(we){function K(){l=ee,He(),Oe(me,"--")}function he(){return{x:Number(ae.width)+de.x,y:Number(ae.height)+de.y}}function G(){window.parentIFrame?window.parentIFrame["scrollTo"+(we?"Offset":"")](ee.x,ee.y):V(me,"Unable to scroll to requested position, window.parentIFrame not found")}var de=we?W(ae.iframe):{x:0,y:0},ee=he();Oe(me,"Reposition requested from iFrame (offset x:"+de.x+" y:"+de.y+")"),window.top===window.self?K():G()}function He(){zt("onScroll",l)===!1?ne():q(me)}function ct(we){function K(){var Ye=W(ee);Oe(me,"Moving to in page link (#"+G+") at x: "+Ye.x+" y: "+Ye.y),l={x:Ye.x,y:Ye.y},He(),Oe(me,"--")}function he(){window.parentIFrame?window.parentIFrame.moveToAnchor(G):Oe(me,"In page link #"+G+" not found and window.parentIFrame not found")}var G=we.split("#")[1]||"",de=decodeURIComponent(G),ee=document.getElementById(de)||document.getElementsByName(de)[0];ee?K():window.top===window.self?Oe(me,"In page link #"+G+" not found"):he()}function bt(we){var K={};if(Number(ae.width)===0&&Number(ae.height)===0){var he=Mr(9).split(":");K={x:he[1],y:he[0]}}else K={x:ae.width,y:ae.height};zt(we,{iframe:ae.iframe,screenX:Number(K.x),screenY:Number(K.y),type:ae.type})}function zt(we,K){return se(me,we,K)}function tr(){switch(f[me]&&f[me].firstRun&&pe(),ae.type){case"close":{re(ae.iframe);break}case"message":{Fr(Mr(6));break}case"mouseenter":{bt("onMouseEnter");break}case"mouseleave":{bt("onMouseLeave");break}case"autoResize":{f[me].autoResize=JSON.parse(Mr(9));break}case"scrollTo":{ie(!1);break}case"scrollToOffset":{ie(!0);break}case"pageInfo":{fr(f[me]&&f[me].iframe,me),Wt();break}case"pageInfoStop":{Ot();break}case"inPageLink":{ct(Mr(9));break}case"reset":{Se(ae);break}case"init":{Ue(),zt("onInit",ae.iframe);break}default:Number(ae.width)===0&&Number(ae.height)===0?V("Unsupported message received ("+ae.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):Ue()}}function Re(we){var K=!0;return f[we]||(K=!1,V(ae.type+" No settings for "+we+". Message was: "+$e)),K}function Ne(){for(var we in f)ke("iFrame requested init",M(we),f[we].iframe,we)}function pe(){f[me]&&(f[me].firstRun=!1)}var $e=Q.data,ae={},me=null;$e==="[iFrameResizerChild]Ready"?Ne():br()?(ae=ot(),me=ae.id,f[me]&&(f[me].loaded=!0),!et()&&Re(me)&&(Oe(me,"Received: "+$e),L()&&or()&&tr())):ze(me,"Ignored: "+$e)}function se(Q,Ue,ot){var Pe=null,St=null;if(f[Q])if(Pe=f[Q][Ue],typeof Pe=="function")St=Pe(ot);else throw new TypeError(Ue+" on iFrame["+Q+"] is not a function");return St}function Te(Q){var Ue=Q.id;delete f[Ue]}function re(Q){var Ue=Q.id;if(se(Ue,"onClose",Ue)===!1){Oe(Ue,"Close iframe cancelled by onClose event");return}Oe(Ue,"Removing iFrame: "+Ue);try{Q.parentNode&&Q.parentNode.removeChild(Q)}catch(ot){V(ot)}se(Ue,"onClosed",Ue),Oe(Ue,"--"),Te(Q)}function oe(Q){l===null&&(l={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset},Oe(Q,"Get page position: "+l.x+","+l.y))}function q(Q){l!==null&&(window.scrollTo(l.x,l.y),Oe(Q,"Set page position: "+l.x+","+l.y),ne())}function ne(){l=null}function Se(Q){function Ue(){H(Q),ke("reset","reset",Q.iframe,Q.id)}Oe(Q.id,"Size reset requested by "+(Q.type==="init"?"host page":"iFrame")),oe(Q.id),ye(Ue,Q,"reset")}function H(Q){function Ue(ut){if(!Q.id){Oe("undefined","messageData id not set");return}Q.iframe.style[ut]=Q[ut]+"px",Oe(Q.id,"IFrame ("+St+") "+ut+" set to "+Q[ut]+"px")}function ot(ut){!i&&Q[ut]==="0"&&(i=!0,Oe(St,"Hidden iFrame detected, creating visibility listener"),Ke())}function Pe(ut){Ue(ut),ot(ut)}var St=Q.iframe.id;f[St]&&(f[St].sizeHeight&&Pe("height"),f[St].sizeWidth&&Pe("width"))}function ye(Q,Ue,ot){ot!==Ue.type&&c&&!window.jasmine?(Oe(Ue.id,"Requesting animation frame"),c(Q)):Q()}function ke(Q,Ue,ot,Pe,St){function ut(){var Fr=f[Pe]&&f[Pe].targetOrigin;Oe(Pe,"["+Q+"] Sending msg to iframe["+Pe+"] ("+Ue+") targetOrigin: "+Fr),ot.contentWindow.postMessage(o+Ue,Fr)}function or(){V(Pe,"["+Q+"] IFrame("+Pe+") not found")}function br(){ot&&"contentWindow"in ot&&ot.contentWindow!==null?ut():or()}function et(){function Fr(){f[Pe]&&!f[Pe].loaded&&!Mr&&(Mr=!0,V(Pe,"IFrame has not responded within "+f[Pe].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}St&&f[Pe]&&f[Pe].warningTimeout&&(f[Pe].msgTimeout=setTimeout(Fr,f[Pe].warningTimeout))}var Mr=!1;Pe=Pe||ot.id,f[Pe]&&(br(),et())}function M(Q){return Q+":"+f[Q].bodyMarginV1+":"+f[Q].sizeWidth+":"+f[Q].log+":"+f[Q].interval+":"+f[Q].enablePublicMethods+":"+f[Q].autoResize+":"+f[Q].bodyMargin+":"+f[Q].heightCalculationMethod+":"+f[Q].bodyBackground+":"+f[Q].bodyPadding+":"+f[Q].tolerance+":"+f[Q].inPageLinks+":"+f[Q].resizeFrom+":"+f[Q].widthCalculationMethod+":"+f[Q].mouseEvents}function Xe(Q){return typeof Q=="number"}function Ct(Q,Ue){function ot(){function ie(ct){var bt=f[W][ct];bt!==1/0&&bt!==0&&(Q.style[ct]=Xe(bt)?bt+"px":bt,Oe(W,"Set "+ct+" = "+Q.style[ct]))}function He(ct){if(f[W]["min"+ct]>f[W]["max"+ct])throw new Error("Value for min"+ct+" can not be greater than max"+ct)}He("Height"),He("Width"),ie("maxHeight"),ie("minHeight"),ie("maxWidth"),ie("minWidth")}function Pe(){var ie=Ue&&Ue.id||b.id+r++;return document.getElementById(ie)!==null&&(ie+=r++),ie}function St(ie){if(typeof ie!="string")throw new TypeError("Invaild id for iFrame. Expected String");return ie===""&&(Q.id=ie=Pe(),n=(Ue||{}).log,Oe(ie,"Added missing iframe ID: "+ie+" ("+Q.src+")")),ie}function ut(){switch(Oe(W,"IFrame scrolling "+(f[W]&&f[W].scrolling?"enabled":"disabled")+" for "+W),Q.style.overflow=(f[W]&&f[W].scrolling)===!1?"hidden":"auto",f[W]&&f[W].scrolling){case"omit":break;case!0:{Q.scrolling="yes";break}case!1:{Q.scrolling="no";break}default:Q.scrolling=f[W]?f[W].scrolling:"no"}}function or(){(typeof(f[W]&&f[W].bodyMargin)=="number"||(f[W]&&f[W].bodyMargin)==="0")&&(f[W].bodyMarginV1=f[W].bodyMargin,f[W].bodyMargin=""+f[W].bodyMargin+"px")}function br(){var ie=f[W]&&f[W].firstRun,He=f[W]&&f[W].heightCalculationMethod in d;!ie&&He&&Se({iframe:Q,height:0,width:0,type:"init"})}function et(){f[W]&&(f[W].iframe.iFrameResizer={close:re.bind(null,f[W].iframe),removeListeners:Te.bind(null,f[W].iframe),resize:ke.bind(null,"Window resize","resize",f[W].iframe),moveToAnchor:function(ie){ke("Move to anchor","moveToAnchor:"+ie,f[W].iframe,W)},sendMessage:function(ie){ie=JSON.stringify(ie),ke("Send Message","message:"+ie,f[W].iframe,W)}})}function Mr(ie){function He(){ke("iFrame.onload",ie,Q,e,!0),br()}function ct(zt){if(Q.parentNode){var tr=new zt(function(Re){Re.forEach(function(Ne){var pe=Array.prototype.slice.call(Ne.removedNodes);pe.forEach(function($e){$e===Q&&re(Q)})})});tr.observe(Q.parentNode,{childList:!0})}}var bt=A();bt&&ct(bt),N(Q,"load",He),ke("init",ie,Q,e,!0)}function Fr(ie){if(typeof ie!="object")throw new TypeError("Options is not an object")}function dr(ie){for(var He in b)Object.prototype.hasOwnProperty.call(b,He)&&(f[W][He]=Object.prototype.hasOwnProperty.call(ie,He)?ie[He]:b[He])}function fr(ie){return ie===""||ie.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":ie}function Wt(ie){var He=ie.split("Callback");if(He.length===2){var ct="on"+He[0].charAt(0).toUpperCase()+He[0].slice(1);this[ct]=this[ie],delete this[ie],V(W,"Deprecated: '"+ie+"' has been renamed '"+ct+"'. The old method will be removed in the next major version.")}}function Ot(ie){ie=ie||{},f[W]=Object.create(null),f[W].iframe=Q,f[W].firstRun=!0,f[W].remoteHost=Q.src&&Q.src.split("/").slice(0,3).join("/"),Fr(ie),Object.keys(ie).forEach(Wt,ie),dr(ie),f[W]&&(f[W].targetOrigin=f[W].checkOrigin===!0?fr(f[W].remoteHost):"*")}function L(){return W in f&&"iFrameResizer"in Q}var W=St(Q.id);L()?V(W,"Ignored iFrame, already setup."):(Ot(Ue),ut(),ot(),or(),Mr(M(W)),et())}function rt(Q,Ue){m===null&&(m=setTimeout(function(){m=null,Q()},Ue))}var je={};function ce(Q,Ue,ot){je[ot]||(je[ot]=setTimeout(function(){je[ot]=null,Q()},Ue))}function Ke(){function Q(){function St(ut){function or(et){return(f[ut]&&f[ut].iframe.style[et])==="0px"}function br(et){return et.offsetParent!==null}f[ut]&&br(f[ut].iframe)&&(or("height")||or("width"))&&ke("Visibility change","resize",f[ut].iframe,ut)}Object.keys(f).forEach(function(ut){St(ut)})}function Ue(St){Oe("window","Mutation observed: "+St[0].target+" "+St[0].type),rt(Q,16)}function ot(){var St=document.querySelector("body"),ut={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},or=new Pe(Ue);or.observe(St,ut)}var Pe=A();Pe&&ot()}function Fe(Q){function Ue(){pt("Window "+Q,"resize")}Oe("window","Trigger event: "+Q),rt(Ue,16)}function be(){function Q(){pt("Tab Visible","resize")}document.visibilityState!=="hidden"&&(Oe("document","Trigger event: Visibility change"),rt(Q,16))}function pt(Q,Ue){function ot(Pe){return f[Pe]&&f[Pe].resizeFrom==="parent"&&f[Pe].autoResize&&!f[Pe].firstRun}Object.keys(f).forEach(function(Pe){ot(Pe)&&ke(Q,Ue,f[Pe].iframe,Pe)})}function Ze(){N(window,"message",_e),N(window,"resize",function(){Fe("resize")}),N(document,"visibilitychange",be),N(document,"-webkit-visibilitychange",be)}function Jt(){function Q(Pe,St){function ut(){if(St.tagName){if(St.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+St.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}St&&(ut(),Ct(St,Pe),ot.push(St))}function Ue(Pe){Pe&&Pe.enablePublicMethods&&V("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var ot;return X(),Ze(),function(Pe,St){switch(ot=[],Ue(Pe),typeof St){case"undefined":case"string":{Array.prototype.forEach.call(document.querySelectorAll(St||"iframe"),Q.bind(e,Pe));break}case"object":{Q(Pe,St);break}default:throw new TypeError("Unexpected data type ("+typeof St+")")}return ot}}function At(Q){Q.fn?Q.fn.iFrameResize||(Q.fn.iFrameResize=function(Ue){function ot(Pe,St){Ct(St,Ue)}return this.filter("iframe").each(ot).end()}):ze("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==e&&At(window.jQuery),t.exports=Jt(),window.iFrameResize=window.iFrameResize||Jt()})()})(p1);var X4=p1.exports;const e3=D_(X4);var t3=Object.defineProperty,r3=Object.getOwnPropertyDescriptor,am=(t,e,r,n)=>{for(var i=n>1?void 0:n?r3(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&t3(e,r,i),i};let $c=class extends Ln{constructor(){super(...arguments),this.src="",this.showCloseButton=!1}async onLoad(t){e3({log:!1,heightCalculationMethod:"max",onMessage:({message:e})=>{this.dispatchEvent(new CustomEvent("message-received",{bubbles:!0,composed:!0,detail:e}))}},t.target)}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return ar`
621
+ `],ii([jr({type:Object})],Dn.prototype,"options",2),ii([jr()],Dn.prototype,"disableInput",2),ii([jr()],Dn.prototype,"showTyping",2),ii([Xs()],Dn.prototype,"messages",2),ii([Xs()],Dn.prototype,"inputValue",2),ii([Xs()],Dn.prototype,"internalShowTyping",2),ii([Xs()],Dn.prototype,"showPopoverDisclaimer",2),ii([Xs()],Dn.prototype,"previousThreads",2),ii([cf("#chat-container")],Dn.prototype,"chatContainer",2),ii([cf("#message-input")],Dn.prototype,"inputElement",2),ii([Uv.debounce(1)],Dn.prototype,"scrollChatToBottom",1),Dn=ii([Vi("iai-chat")],Dn);var p1={exports:{}};(function(t){(function(e){if(typeof window>"u")return;var r=0,n=!1,i=!1,a="message",s=a.length,o="[iFrameSizer]",u=o.length,l=null,c=window.requestAnimationFrame,d=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),f={},m=null,b=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){V("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function A(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function N(Q,Ue,ot){Q.addEventListener(Ue,ot,!1)}function z(Q,Ue,ot){Q.removeEventListener(Ue,ot,!1)}function X(){var Q=["moz","webkit","o","ms"],Ue;for(Ue=0;Ue<Q.length&&!c;Ue+=1)c=window[Q[Ue]+"RequestAnimationFrame"];c?c=c.bind(window):Oe("setup","RequestAnimationFrame not supported")}function Ee(Q){var Ue="Host page: "+Q;return window.top!==window.self&&(Ue=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+Q:"Nested host page: "+Q),Ue}function Ie(Q){return o+"["+Ee(Q)+"]"}function Fe(Q){return f[Q]?f[Q].log:n}function Oe(Q,Ue){xe("log",Q,Ue,Fe(Q))}function ze(Q,Ue){xe("info",Q,Ue,Fe(Q))}function V(Q,Ue){xe("warn",Q,Ue,!0)}function xe(Q,Ue,ot,Pe){Pe===!0&&typeof window.console=="object"&&console[Q](Ie(Ue),ot)}function _e(Q){function Ue(){function we(){H(ae),q(me),zt("onResized",ae)}ut("Height"),ut("Width"),ye(we,ae,"init")}function ot(){var we=$e.slice(u).split(":"),K=we[1]?parseInt(we[1],10):0,he=f[we[0]]&&f[we[0]].iframe,G=getComputedStyle(he);return{iframe:he,id:we[0],height:K+Pe(G)+St(G),width:we[2],type:we[3]}}function Pe(we){if(we.boxSizing!=="border-box")return 0;var K=we.paddingTop?parseInt(we.paddingTop,10):0,he=we.paddingBottom?parseInt(we.paddingBottom,10):0;return K+he}function St(we){if(we.boxSizing!=="border-box")return 0;var K=we.borderTopWidth?parseInt(we.borderTopWidth,10):0,he=we.borderBottomWidth?parseInt(we.borderBottomWidth,10):0;return K+he}function ut(we){var K=Number(f[me]["max"+we]),he=Number(f[me]["min"+we]),G=we.toLowerCase(),de=Number(ae[G]);Oe(me,"Checking "+G+" is in range "+he+"-"+K),de<he&&(de=he,Oe(me,"Set "+G+" to min value")),de>K&&(de=K,Oe(me,"Set "+G+" to max value")),ae[G]=""+de}function or(){function we(){function G(){var ee=0,Ye=!1;for(Oe(me,"Checking connection is from allowed list of origins: "+he);ee<he.length;ee++)if(he[ee]===K){Ye=!0;break}return Ye}function de(){var ee=f[me]&&f[me].remoteHost;return Oe(me,"Checking connection is from: "+ee),K===ee}return he.constructor===Array?G():de()}var K=Q.origin,he=f[me]&&f[me].checkOrigin;if(he&&""+K!="null"&&!we())throw new Error("Unexpected message received from: "+K+" for "+ae.iframe.id+". Message was: "+Q.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function br(){return o===(""+$e).slice(0,u)&&$e.slice(u).split(":")[0]in f}function et(){var we=ae.type in{true:1,false:1,undefined:1};return we&&Oe(me,"Ignoring init message from meta parent page"),we}function Mr(we){return $e.slice($e.indexOf(":")+s+we)}function Fr(we){Oe(me,"onMessage passed: {iframe: "+ae.iframe.id+", message: "+we+"}"),zt("onMessage",{iframe:ae.iframe,message:JSON.parse(we)}),Oe(me,"--")}function dr(){var we=document.body.getBoundingClientRect(),K=ae.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:K.height,iframeWidth:K.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(K.top-we.top,10),offsetLeft:parseInt(K.left-we.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function fr(we,K){function he(){ke("Send Page Info","pageInfo:"+dr(),we,K)}ce(he,32,K)}function Wt(){function we(de,ee){function Ye(){f[G]?fr(f[G].iframe,G):K()}["scroll","resize"].forEach(function(qe){Oe(G,de+qe+" listener for sendPageInfo"),ee(window,qe,Ye)})}function K(){we("Remove ",z)}function he(){we("Add ",N)}var G=me;he(),f[G]&&(f[G].stopPageInfo=K)}function Ot(){f[me]&&f[me].stopPageInfo&&(f[me].stopPageInfo(),delete f[me].stopPageInfo)}function L(){var we=!0;return ae.iframe===null&&(V(me,"IFrame ("+ae.id+") not found"),we=!1),we}function W(we){var K=we.getBoundingClientRect();return oe(me),{x:Math.floor(Number(K.left)+Number(l.x)),y:Math.floor(Number(K.top)+Number(l.y))}}function ie(we){function K(){l=ee,He(),Oe(me,"--")}function he(){return{x:Number(ae.width)+de.x,y:Number(ae.height)+de.y}}function G(){window.parentIFrame?window.parentIFrame["scrollTo"+(we?"Offset":"")](ee.x,ee.y):V(me,"Unable to scroll to requested position, window.parentIFrame not found")}var de=we?W(ae.iframe):{x:0,y:0},ee=he();Oe(me,"Reposition requested from iFrame (offset x:"+de.x+" y:"+de.y+")"),window.top===window.self?K():G()}function He(){zt("onScroll",l)===!1?ne():q(me)}function ct(we){function K(){var Ye=W(ee);Oe(me,"Moving to in page link (#"+G+") at x: "+Ye.x+" y: "+Ye.y),l={x:Ye.x,y:Ye.y},He(),Oe(me,"--")}function he(){window.parentIFrame?window.parentIFrame.moveToAnchor(G):Oe(me,"In page link #"+G+" not found and window.parentIFrame not found")}var G=we.split("#")[1]||"",de=decodeURIComponent(G),ee=document.getElementById(de)||document.getElementsByName(de)[0];ee?K():window.top===window.self?Oe(me,"In page link #"+G+" not found"):he()}function bt(we){var K={};if(Number(ae.width)===0&&Number(ae.height)===0){var he=Mr(9).split(":");K={x:he[1],y:he[0]}}else K={x:ae.width,y:ae.height};zt(we,{iframe:ae.iframe,screenX:Number(K.x),screenY:Number(K.y),type:ae.type})}function zt(we,K){return se(me,we,K)}function tr(){switch(f[me]&&f[me].firstRun&&pe(),ae.type){case"close":{re(ae.iframe);break}case"message":{Fr(Mr(6));break}case"mouseenter":{bt("onMouseEnter");break}case"mouseleave":{bt("onMouseLeave");break}case"autoResize":{f[me].autoResize=JSON.parse(Mr(9));break}case"scrollTo":{ie(!1);break}case"scrollToOffset":{ie(!0);break}case"pageInfo":{fr(f[me]&&f[me].iframe,me),Wt();break}case"pageInfoStop":{Ot();break}case"inPageLink":{ct(Mr(9));break}case"reset":{Se(ae);break}case"init":{Ue(),zt("onInit",ae.iframe);break}default:Number(ae.width)===0&&Number(ae.height)===0?V("Unsupported message received ("+ae.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):Ue()}}function Re(we){var K=!0;return f[we]||(K=!1,V(ae.type+" No settings for "+we+". Message was: "+$e)),K}function Ne(){for(var we in f)ke("iFrame requested init",M(we),f[we].iframe,we)}function pe(){f[me]&&(f[me].firstRun=!1)}var $e=Q.data,ae={},me=null;$e==="[iFrameResizerChild]Ready"?Ne():br()?(ae=ot(),me=ae.id,f[me]&&(f[me].loaded=!0),!et()&&Re(me)&&(Oe(me,"Received: "+$e),L()&&or()&&tr())):ze(me,"Ignored: "+$e)}function se(Q,Ue,ot){var Pe=null,St=null;if(f[Q])if(Pe=f[Q][Ue],typeof Pe=="function")St=Pe(ot);else throw new TypeError(Ue+" on iFrame["+Q+"] is not a function");return St}function Te(Q){var Ue=Q.id;delete f[Ue]}function re(Q){var Ue=Q.id;if(se(Ue,"onClose",Ue)===!1){Oe(Ue,"Close iframe cancelled by onClose event");return}Oe(Ue,"Removing iFrame: "+Ue);try{Q.parentNode&&Q.parentNode.removeChild(Q)}catch(ot){V(ot)}se(Ue,"onClosed",Ue),Oe(Ue,"--"),Te(Q)}function oe(Q){l===null&&(l={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset},Oe(Q,"Get page position: "+l.x+","+l.y))}function q(Q){l!==null&&(window.scrollTo(l.x,l.y),Oe(Q,"Set page position: "+l.x+","+l.y),ne())}function ne(){l=null}function Se(Q){function Ue(){H(Q),ke("reset","reset",Q.iframe,Q.id)}Oe(Q.id,"Size reset requested by "+(Q.type==="init"?"host page":"iFrame")),oe(Q.id),ye(Ue,Q,"reset")}function H(Q){function Ue(ut){if(!Q.id){Oe("undefined","messageData id not set");return}Q.iframe.style[ut]=Q[ut]+"px",Oe(Q.id,"IFrame ("+St+") "+ut+" set to "+Q[ut]+"px")}function ot(ut){!i&&Q[ut]==="0"&&(i=!0,Oe(St,"Hidden iFrame detected, creating visibility listener"),Ke())}function Pe(ut){Ue(ut),ot(ut)}var St=Q.iframe.id;f[St]&&(f[St].sizeHeight&&Pe("height"),f[St].sizeWidth&&Pe("width"))}function ye(Q,Ue,ot){ot!==Ue.type&&c&&!window.jasmine?(Oe(Ue.id,"Requesting animation frame"),c(Q)):Q()}function ke(Q,Ue,ot,Pe,St){function ut(){var Fr=f[Pe]&&f[Pe].targetOrigin;Oe(Pe,"["+Q+"] Sending msg to iframe["+Pe+"] ("+Ue+") targetOrigin: "+Fr),ot.contentWindow.postMessage(o+Ue,Fr)}function or(){V(Pe,"["+Q+"] IFrame("+Pe+") not found")}function br(){ot&&"contentWindow"in ot&&ot.contentWindow!==null?ut():or()}function et(){function Fr(){f[Pe]&&!f[Pe].loaded&&!Mr&&(Mr=!0,V(Pe,"IFrame has not responded within "+f[Pe].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}St&&f[Pe]&&f[Pe].warningTimeout&&(f[Pe].msgTimeout=setTimeout(Fr,f[Pe].warningTimeout))}var Mr=!1;Pe=Pe||ot.id,f[Pe]&&(br(),et())}function M(Q){return Q+":"+f[Q].bodyMarginV1+":"+f[Q].sizeWidth+":"+f[Q].log+":"+f[Q].interval+":"+f[Q].enablePublicMethods+":"+f[Q].autoResize+":"+f[Q].bodyMargin+":"+f[Q].heightCalculationMethod+":"+f[Q].bodyBackground+":"+f[Q].bodyPadding+":"+f[Q].tolerance+":"+f[Q].inPageLinks+":"+f[Q].resizeFrom+":"+f[Q].widthCalculationMethod+":"+f[Q].mouseEvents}function Xe(Q){return typeof Q=="number"}function Ct(Q,Ue){function ot(){function ie(ct){var bt=f[W][ct];bt!==1/0&&bt!==0&&(Q.style[ct]=Xe(bt)?bt+"px":bt,Oe(W,"Set "+ct+" = "+Q.style[ct]))}function He(ct){if(f[W]["min"+ct]>f[W]["max"+ct])throw new Error("Value for min"+ct+" can not be greater than max"+ct)}He("Height"),He("Width"),ie("maxHeight"),ie("minHeight"),ie("maxWidth"),ie("minWidth")}function Pe(){var ie=Ue&&Ue.id||b.id+r++;return document.getElementById(ie)!==null&&(ie+=r++),ie}function St(ie){if(typeof ie!="string")throw new TypeError("Invaild id for iFrame. Expected String");return ie===""&&(Q.id=ie=Pe(),n=(Ue||{}).log,Oe(ie,"Added missing iframe ID: "+ie+" ("+Q.src+")")),ie}function ut(){switch(Oe(W,"IFrame scrolling "+(f[W]&&f[W].scrolling?"enabled":"disabled")+" for "+W),Q.style.overflow=(f[W]&&f[W].scrolling)===!1?"hidden":"auto",f[W]&&f[W].scrolling){case"omit":break;case!0:{Q.scrolling="yes";break}case!1:{Q.scrolling="no";break}default:Q.scrolling=f[W]?f[W].scrolling:"no"}}function or(){(typeof(f[W]&&f[W].bodyMargin)=="number"||(f[W]&&f[W].bodyMargin)==="0")&&(f[W].bodyMarginV1=f[W].bodyMargin,f[W].bodyMargin=""+f[W].bodyMargin+"px")}function br(){var ie=f[W]&&f[W].firstRun,He=f[W]&&f[W].heightCalculationMethod in d;!ie&&He&&Se({iframe:Q,height:0,width:0,type:"init"})}function et(){f[W]&&(f[W].iframe.iFrameResizer={close:re.bind(null,f[W].iframe),removeListeners:Te.bind(null,f[W].iframe),resize:ke.bind(null,"Window resize","resize",f[W].iframe),moveToAnchor:function(ie){ke("Move to anchor","moveToAnchor:"+ie,f[W].iframe,W)},sendMessage:function(ie){ie=JSON.stringify(ie),ke("Send Message","message:"+ie,f[W].iframe,W)}})}function Mr(ie){function He(){ke("iFrame.onload",ie,Q,e,!0),br()}function ct(zt){if(Q.parentNode){var tr=new zt(function(Re){Re.forEach(function(Ne){var pe=Array.prototype.slice.call(Ne.removedNodes);pe.forEach(function($e){$e===Q&&re(Q)})})});tr.observe(Q.parentNode,{childList:!0})}}var bt=A();bt&&ct(bt),N(Q,"load",He),ke("init",ie,Q,e,!0)}function Fr(ie){if(typeof ie!="object")throw new TypeError("Options is not an object")}function dr(ie){for(var He in b)Object.prototype.hasOwnProperty.call(b,He)&&(f[W][He]=Object.prototype.hasOwnProperty.call(ie,He)?ie[He]:b[He])}function fr(ie){return ie===""||ie.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":ie}function Wt(ie){var He=ie.split("Callback");if(He.length===2){var ct="on"+He[0].charAt(0).toUpperCase()+He[0].slice(1);this[ct]=this[ie],delete this[ie],V(W,"Deprecated: '"+ie+"' has been renamed '"+ct+"'. The old method will be removed in the next major version.")}}function Ot(ie){ie=ie||{},f[W]=Object.create(null),f[W].iframe=Q,f[W].firstRun=!0,f[W].remoteHost=Q.src&&Q.src.split("/").slice(0,3).join("/"),Fr(ie),Object.keys(ie).forEach(Wt,ie),dr(ie),f[W]&&(f[W].targetOrigin=f[W].checkOrigin===!0?fr(f[W].remoteHost):"*")}function L(){return W in f&&"iFrameResizer"in Q}var W=St(Q.id);L()?V(W,"Ignored iFrame, already setup."):(Ot(Ue),ut(),ot(),or(),Mr(M(W)),et())}function rt(Q,Ue){m===null&&(m=setTimeout(function(){m=null,Q()},Ue))}var je={};function ce(Q,Ue,ot){je[ot]||(je[ot]=setTimeout(function(){je[ot]=null,Q()},Ue))}function Ke(){function Q(){function St(ut){function or(et){return(f[ut]&&f[ut].iframe.style[et])==="0px"}function br(et){return et.offsetParent!==null}f[ut]&&br(f[ut].iframe)&&(or("height")||or("width"))&&ke("Visibility change","resize",f[ut].iframe,ut)}Object.keys(f).forEach(function(ut){St(ut)})}function Ue(St){Oe("window","Mutation observed: "+St[0].target+" "+St[0].type),rt(Q,16)}function ot(){var St=document.querySelector("body"),ut={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},or=new Pe(Ue);or.observe(St,ut)}var Pe=A();Pe&&ot()}function Be(Q){function Ue(){pt("Window "+Q,"resize")}Oe("window","Trigger event: "+Q),rt(Ue,16)}function be(){function Q(){pt("Tab Visible","resize")}document.visibilityState!=="hidden"&&(Oe("document","Trigger event: Visibility change"),rt(Q,16))}function pt(Q,Ue){function ot(Pe){return f[Pe]&&f[Pe].resizeFrom==="parent"&&f[Pe].autoResize&&!f[Pe].firstRun}Object.keys(f).forEach(function(Pe){ot(Pe)&&ke(Q,Ue,f[Pe].iframe,Pe)})}function Ze(){N(window,"message",_e),N(window,"resize",function(){Be("resize")}),N(document,"visibilitychange",be),N(document,"-webkit-visibilitychange",be)}function Jt(){function Q(Pe,St){function ut(){if(St.tagName){if(St.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+St.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}St&&(ut(),Ct(St,Pe),ot.push(St))}function Ue(Pe){Pe&&Pe.enablePublicMethods&&V("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var ot;return X(),Ze(),function(Pe,St){switch(ot=[],Ue(Pe),typeof St){case"undefined":case"string":{Array.prototype.forEach.call(document.querySelectorAll(St||"iframe"),Q.bind(e,Pe));break}case"object":{Q(Pe,St);break}default:throw new TypeError("Unexpected data type ("+typeof St+")")}return ot}}function At(Q){Q.fn?Q.fn.iFrameResize||(Q.fn.iFrameResize=function(Ue){function ot(Pe,St){Ct(St,Ue)}return this.filter("iframe").each(ot).end()}):ze("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==e&&At(window.jQuery),t.exports=Jt(),window.iFrameResize=window.iFrameResize||Jt()})()})(p1);var X4=p1.exports;const e3=D_(X4);var t3=Object.defineProperty,r3=Object.getOwnPropertyDescriptor,am=(t,e,r,n)=>{for(var i=n>1?void 0:n?r3(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&t3(e,r,i),i};let $c=class extends Ln{constructor(){super(...arguments),this.src="",this.showCloseButton=!1}async onLoad(t){e3({log:!1,heightCalculationMethod:"max",onMessage:({message:e})=>{this.dispatchEvent(new CustomEvent("message-received",{bubbles:!0,composed:!0,detail:e}))}},t.target)}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return ar`
622
622
  <div class="relative">
623
623
  ${wa(this.showCloseButton,()=>ar`
624
624
  <button class="absolute top-0 right-0 m-2 h-6 text-white focus:outline-none" @click="${this.close}">
@@ -774,12 +774,12 @@ Please report this to https://github.com/markedjs/marked.`,t){const n="<p>An err
774
774
  `})}
775
775
  </iai-chat-carousel>
776
776
  </div>
777
- `}var y1={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(ln,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",b="date",A="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,X={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Ee=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Ie={s:Ee,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Ee(Se,2,"0")+":"+Ee(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:b,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Be="en",Oe={};Oe[Be]=X;var ze="$isDayjsObject",V=function(oe){return oe instanceof Te||!(!oe||!oe[ze])},xe=function oe(q,ne,Se){var H;if(!q)return Be;if(typeof q=="string"){var ye=q.toLowerCase();Oe[ye]&&(H=ye),ne&&(Oe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var M=q.name;Oe[M]=q,H=M}return!Se&&H&&(Be=H),H||!Se&&Be},_e=function(oe,q){if(V(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Ie;se.l=xe,se.i=V,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=xe(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var M=ke[2]-1||0,Xe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)):new Date(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==A},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),M=function(be,pt){var Ze=se.w(H.$u?Date.UTC(H.$y,pt,be):new Date(H.$y,pt,be),H);return ye?Ze:Ze.endOf(l)},Xe=function(be,pt){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(pt)),H)},Ct=this.$W,rt=this.$M,je=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?M(1,0):M(31,11);case d:return ye?M(1,rt):M(0,rt+1);case c:var Ke=this.$locale().weekStart||0,Fe=(Ct<Ke?Ct+7:Ct)-Ke;return M(ye?je-Fe:je+(6-Fe),rt);case l:case b:return Xe(ce+"Hours",0);case u:return Xe(ce+"Minutes",1);case o:return Xe(ce+"Seconds",2);case s:return Xe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),M=(H={},H[l]=ke+"Date",H[b]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Xe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(b,1);Ct.$d[M](Xe),Ct.init(),this.$d=Ct.set(b,Math.min(this.$D,Ct.daysInMonth())).$d}else M&&this.$d[M](Xe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),M=function(rt){var je=_e(ye);return se.w(je.date(je.date()+Math.round(rt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return M(1);if(ke===c)return M(7);var Xe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Xe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||A;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),M=this.$H,Xe=this.$m,Ct=this.$M,rt=H.weekdays,je=H.months,ce=H.meridiem,Ke=function(pt,Ze,Jt,At){return pt&&(pt[Ze]||pt(Se,ye))||Jt[Ze].slice(0,At)},Fe=function(pt){return se.s(M%12||12,pt,"0")},be=ce||function(pt,Ze,Jt){var At=pt<12?"AM":"PM";return Jt?At.toLowerCase():At};return ye.replace(z,function(pt,Ze){return Ze||function(Jt){switch(Jt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ke(H.monthsShort,Ct,je,3);case"MMMM":return Ke(je,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ke(H.weekdaysMin,Se.$W,rt,2);case"ddd":return Ke(H.weekdaysShort,Se.$W,rt,3);case"dddd":return rt[Se.$W];case"H":return String(M);case"HH":return se.s(M,2,"0");case"h":return Fe(1);case"hh":return Fe(2);case"a":return be(M,Xe,!0);case"A":return be(M,Xe,!1);case"m":return String(Xe);case"mm":return se.s(Xe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(pt)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,M=se.p(Se),Xe=_e(ne),Ct=(Xe.utcOffset()-this.utcOffset())*n,rt=this-Xe,je=function(){return se.m(ke,Xe)};switch(M){case m:ye=je()/12;break;case d:ye=je();break;case f:ye=je()/3;break;case c:ye=(rt-Ct)/6048e5;break;case l:ye=(rt-Ct)/864e5;break;case u:ye=rt/i;break;case o:ye=rt/n;break;case s:ye=rt/r;break;default:ye=rt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Oe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=xe(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),re=Te.prototype;return _e.prototype=re,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",b]].forEach(function(oe){re[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=xe,_e.isDayjs=V,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Oe[Be],_e.Ls=Oe,_e.p={},_e})})(y1);var y3=y1.exports;const b3=sP(y3);function w3(t){return async function({id:r,params:n,chatWindow:i}){i.setInputDisabled(!0);const a=i.chatManager.registerRecurringKeepAlive(),{threadId:s}=i.chatManager,o={isAIChat:!0,guestCardId:n.guestCardId||null,AIChatSessionTimeout:!1,...s&&{AIChatUniqueSessionId:s},...n.firstName&&{firstName:n.firstName},...n.lastName&&{lastName:n.lastName},...n.email&&{email:n.email},...n.phoneNumber&&{phone:n.phoneNumber},...n.desiredMoveInDate&&{moveInDate:b3(n.desiredMoveInDate).format("MM/DD/YYYY")},...n.AccessWidgetLeadId&&{AccessWidgetLeadId:n.AccessWidgetLeadId}},u=document.createElement("iai-chat-iframe-modal");u.title="Schedule a Tour",u.src=`${t}?${new URLSearchParams(o).toString()}`,u.showHeader=!1;const l=()=>{a(),u.remove(),window.removeEventListener("beforeunload",f),i.removeEventListener("iai-chat-reset",l),i.setInputDisabled(!1)},c=async({detail:m})=>{if(m.type!=="tourScheduled")return;const{tourType:b,tourDate:A,tourTime:N,prospectName:z,guestCardId:X,accessWidgetLeadId:Ee}=m;l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Your tour has been scheduled!"});try{await i.sendFunctionCallResponse(r,{status:"scheduled",tourType:b,tourDate:A,tourTime:N,guestCardId:X,firstName:z,accessWidgetLeadId:Ee},!0)}finally{i.setInputDisabled(!1)}},d=async()=>{l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Tour Scheduler Closed"});try{await i.sendFunctionCallResponse(r,{status:"canceled"},!0)}finally{i.setInputDisabled(!1)}},f=async()=>{l(),i.addMessage({role:"system",content:"Tour Scheduler Closed"})};u.addEventListener("message-received",c),u.addEventListener("close",d),i.addEventListener("iai-chat-reset",l),window.addEventListener("beforeunload",f),document.body.appendChild(u),i.addMessage({role:"system",content:"Tour Scheduler Opened"})}}function b1(t,e){return function(){return t.apply(e,arguments)}}const{toString:_3}=Object.prototype,{getPrototypeOf:sm}=Object,Uf=(t=>e=>{const r=_3.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Ci=t=>(t=t.toLowerCase(),e=>Uf(e)===t),Ff=t=>e=>typeof e===t,{isArray:_u}=Array,Ec=Ff("undefined");function k3(t){return t!==null&&!Ec(t)&&t.constructor!==null&&!Ec(t.constructor)&&ai(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const w1=Ci("ArrayBuffer");function S3(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&w1(t.buffer),e}const $3=Ff("string"),ai=Ff("function"),_1=Ff("number"),Bf=t=>t!==null&&typeof t=="object",T3=t=>t===!0||t===!1,zf=t=>{if(Uf(t)!=="object")return!1;const e=sm(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},E3=Ci("Date"),C3=Ci("File"),R3=Ci("Blob"),x3=Ci("FileList"),I3=t=>Bf(t)&&ai(t.pipe),A3=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||ai(t.append)&&((e=Uf(t))==="formdata"||e==="object"&&ai(t.toString)&&t.toString()==="[object FormData]"))},O3=Ci("URLSearchParams"),[P3,M3,N3,L3]=["ReadableStream","Request","Response","Headers"].map(Ci),D3=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Cc(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),_u(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{const a=r?Object.getOwnPropertyNames(t):Object.keys(t),s=a.length;let o;for(n=0;n<s;n++)o=a[n],e.call(null,t[o],o,t)}}function k1(t,e){e=e.toLowerCase();const r=Object.keys(t);let n=r.length,i;for(;n-- >0;)if(i=r[n],e===i.toLowerCase())return i;return null}const S1=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,$1=t=>!Ec(t)&&t!==S1;function om(){const{caseless:t}=$1(this)&&this||{},e={},r=(n,i)=>{const a=t&&k1(e,i)||i;zf(e[a])&&zf(n)?e[a]=om(e[a],n):zf(n)?e[a]=om({},n):_u(n)?e[a]=n.slice():e[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Cc(arguments[n],r);return e}const j3=(t,e,r,{allOwnKeys:n}={})=>(Cc(e,(i,a)=>{r&&ai(i)?t[a]=b1(i,r):t[a]=i},{allOwnKeys:n}),t),U3=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),F3=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},B3=(t,e,r,n)=>{let i,a,s;const o={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),a=i.length;a-- >0;)s=i[a],(!n||n(s,t,e))&&!o[s]&&(e[s]=t[s],o[s]=!0);t=r!==!1&&sm(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},z3=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},H3=t=>{if(!t)return null;if(_u(t))return t;let e=t.length;if(!_1(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},q3=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&sm(Uint8Array)),V3=(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=n.next())&&!i.done;){const a=i.value;e.call(t,a[0],a[1])}},W3=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},Z3=Ci("HTMLFormElement"),G3=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),T1=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),K3=Ci("RegExp"),E1=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};Cc(r,(i,a)=>{let s;(s=e(i,a,t))!==!1&&(n[a]=s||i)}),Object.defineProperties(t,n)},J3=t=>{E1(t,(e,r)=>{if(ai(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(ai(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Y3=(t,e)=>{const r={},n=i=>{i.forEach(a=>{r[a]=!0})};return _u(t)?n(t):n(String(t).split(e)),r},Q3=()=>{},X3=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,um="abcdefghijklmnopqrstuvwxyz",C1="0123456789",R1={DIGIT:C1,ALPHA:um,ALPHA_DIGIT:um+um.toUpperCase()+C1},eL=(t=16,e=R1.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r};function tL(t){return!!(t&&ai(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const rL=t=>{const e=new Array(10),r=(n,i)=>{if(Bf(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[i]=n;const a=_u(n)?[]:{};return Cc(n,(s,o)=>{const u=r(s,i+1);!Ec(u)&&(a[o]=u)}),e[i]=void 0,a}}return n};return r(t,0)},nL=Ci("AsyncFunction"),De={isArray:_u,isArrayBuffer:w1,isBuffer:k3,isFormData:A3,isArrayBufferView:S3,isString:$3,isNumber:_1,isBoolean:T3,isObject:Bf,isPlainObject:zf,isReadableStream:P3,isRequest:M3,isResponse:N3,isHeaders:L3,isUndefined:Ec,isDate:E3,isFile:C3,isBlob:R3,isRegExp:K3,isFunction:ai,isStream:I3,isURLSearchParams:O3,isTypedArray:q3,isFileList:x3,forEach:Cc,merge:om,extend:j3,trim:D3,stripBOM:U3,inherits:F3,toFlatObject:B3,kindOf:Uf,kindOfTest:Ci,endsWith:z3,toArray:H3,forEachEntry:V3,matchAll:W3,isHTMLForm:Z3,hasOwnProperty:T1,hasOwnProp:T1,reduceDescriptors:E1,freezeMethods:J3,toObjectSet:Y3,toCamelCase:G3,noop:Q3,toFiniteNumber:X3,findKey:k1,global:S1,isContextDefined:$1,ALPHABET:R1,generateString:eL,isSpecCompliantForm:tL,toJSONObject:rL,isAsyncFn:nL,isThenable:t=>t&&(Bf(t)||ai(t))&&ai(t.then)&&ai(t.catch)};function ir(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}De.inherits(ir,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:De.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const x1=ir.prototype,I1={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{I1[t]={value:t}}),Object.defineProperties(ir,I1),Object.defineProperty(x1,"isAxiosError",{value:!0}),ir.from=(t,e,r,n,i,a)=>{const s=Object.create(x1);return De.toFlatObject(t,s,function(u){return u!==Error.prototype},o=>o!=="isAxiosError"),ir.call(s,t.message,e,r,n,i),s.cause=t,s.name=t.name,a&&Object.assign(s,a),s};const iL=null;function lm(t){return De.isPlainObject(t)||De.isArray(t)}function A1(t){return De.endsWith(t,"[]")?t.slice(0,-2):t}function O1(t,e,r){return t?t.concat(e).map(function(i,a){return i=A1(i),!r&&a?"["+i+"]":i}).join(r?".":""):e}function aL(t){return De.isArray(t)&&!t.some(lm)}const sL=De.toFlatObject(De,{},null,function(e){return/^is[A-Z]/.test(e)});function Hf(t,e,r){if(!De.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=De.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,N){return!De.isUndefined(N[A])});const n=r.metaTokens,i=r.visitor||c,a=r.dots,s=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&De.isSpecCompliantForm(e);if(!De.isFunction(i))throw new TypeError("visitor must be a function");function l(b){if(b===null)return"";if(De.isDate(b))return b.toISOString();if(!u&&De.isBlob(b))throw new ir("Blob is not supported. Use a Buffer instead.");return De.isArrayBuffer(b)||De.isTypedArray(b)?u&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function c(b,A,N){let z=b;if(b&&!N&&typeof b=="object"){if(De.endsWith(A,"{}"))A=n?A:A.slice(0,-2),b=JSON.stringify(b);else if(De.isArray(b)&&aL(b)||(De.isFileList(b)||De.endsWith(A,"[]"))&&(z=De.toArray(b)))return A=A1(A),z.forEach(function(Ee,Ie){!(De.isUndefined(Ee)||Ee===null)&&e.append(s===!0?O1([A],Ie,a):s===null?A:A+"[]",l(Ee))}),!1}return lm(b)?!0:(e.append(O1(N,A,a),l(b)),!1)}const d=[],f=Object.assign(sL,{defaultVisitor:c,convertValue:l,isVisitable:lm});function m(b,A){if(!De.isUndefined(b)){if(d.indexOf(b)!==-1)throw Error("Circular reference detected in "+A.join("."));d.push(b),De.forEach(b,function(z,X){(!(De.isUndefined(z)||z===null)&&i.call(e,z,De.isString(X)?X.trim():X,A,f))===!0&&m(z,A?A.concat(X):[X])}),d.pop()}}if(!De.isObject(t))throw new TypeError("data must be an object");return m(t),e}function P1(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function cm(t,e){this._pairs=[],t&&Hf(t,this,e)}const M1=cm.prototype;M1.append=function(e,r){this._pairs.push([e,r])},M1.toString=function(e){const r=e?function(n){return e.call(this,n,P1)}:P1;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function oL(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function N1(t,e,r){if(!e)return t;const n=r&&r.encode||oL,i=r&&r.serialize;let a;if(i?a=i(e,r):a=De.isURLSearchParams(e)?e.toString():new cm(e,r).toString(n),a){const s=t.indexOf("#");s!==-1&&(t=t.slice(0,s)),t+=(t.indexOf("?")===-1?"?":"&")+a}return t}class L1{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){De.forEach(this.handlers,function(n){n!==null&&e(n)})}}const D1={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},uL={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:cm,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},dm=typeof window<"u"&&typeof document<"u",lL=(t=>dm&&["ReactNative","NativeScript","NS"].indexOf(t)<0)(typeof navigator<"u"&&navigator.product),cL=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",dL=dm&&window.location.href||"http://localhost",Ri={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:dm,hasStandardBrowserEnv:lL,hasStandardBrowserWebWorkerEnv:cL,origin:dL},Symbol.toStringTag,{value:"Module"})),...uL};function fL(t,e){return Hf(t,new Ri.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return Ri.isNode&&De.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},e))}function hL(t){return De.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function pL(t){const e={},r=Object.keys(t);let n;const i=r.length;let a;for(n=0;n<i;n++)a=r[n],e[a]=t[a];return e}function j1(t){function e(r,n,i,a){let s=r[a++];if(s==="__proto__")return!0;const o=Number.isFinite(+s),u=a>=r.length;return s=!s&&De.isArray(i)?i.length:s,u?(De.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!o):((!i[s]||!De.isObject(i[s]))&&(i[s]=[]),e(r,n,i[s],a)&&De.isArray(i[s])&&(i[s]=pL(i[s])),!o)}if(De.isFormData(t)&&De.isFunction(t.entries)){const r={};return De.forEachEntry(t,(n,i)=>{e(hL(n),i,r,0)}),r}return null}function vL(t,e,r){if(De.isString(t))try{return(e||JSON.parse)(t),De.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const Rc={transitional:D1,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=De.isObject(e);if(a&&De.isHTMLForm(e)&&(e=new FormData(e)),De.isFormData(e))return i?JSON.stringify(j1(e)):e;if(De.isArrayBuffer(e)||De.isBuffer(e)||De.isStream(e)||De.isFile(e)||De.isBlob(e)||De.isReadableStream(e))return e;if(De.isArrayBufferView(e))return e.buffer;if(De.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return fL(e,this.formSerializer).toString();if((o=De.isFileList(e))||n.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return Hf(o?{"files[]":e}:e,u&&new u,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),vL(e)):e}],transformResponse:[function(e){const r=this.transitional||Rc.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(De.isResponse(e)||De.isReadableStream(e))return e;if(e&&De.isString(e)&&(n&&!this.responseType||i)){const s=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?ir.from(o,ir.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ri.classes.FormData,Blob:Ri.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};De.forEach(["delete","get","head","post","put","patch"],t=>{Rc.headers[t]={}});const mL=De.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gL=t=>{const e={};let r,n,i;return t&&t.split(`
777
+ `}var y1={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(ln,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",b="date",A="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,X={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Ee=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Ie={s:Ee,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Ee(Se,2,"0")+":"+Ee(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:b,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Fe="en",Oe={};Oe[Fe]=X;var ze="$isDayjsObject",V=function(oe){return oe instanceof Te||!(!oe||!oe[ze])},xe=function oe(q,ne,Se){var H;if(!q)return Fe;if(typeof q=="string"){var ye=q.toLowerCase();Oe[ye]&&(H=ye),ne&&(Oe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var M=q.name;Oe[M]=q,H=M}return!Se&&H&&(Fe=H),H||!Se&&Fe},_e=function(oe,q){if(V(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Ie;se.l=xe,se.i=V,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=xe(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var M=ke[2]-1||0,Xe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)):new Date(ke[1],M,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Xe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==A},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),M=function(be,pt){var Ze=se.w(H.$u?Date.UTC(H.$y,pt,be):new Date(H.$y,pt,be),H);return ye?Ze:Ze.endOf(l)},Xe=function(be,pt){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(pt)),H)},Ct=this.$W,rt=this.$M,je=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?M(1,0):M(31,11);case d:return ye?M(1,rt):M(0,rt+1);case c:var Ke=this.$locale().weekStart||0,Be=(Ct<Ke?Ct+7:Ct)-Ke;return M(ye?je-Be:je+(6-Be),rt);case l:case b:return Xe(ce+"Hours",0);case u:return Xe(ce+"Minutes",1);case o:return Xe(ce+"Seconds",2);case s:return Xe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),M=(H={},H[l]=ke+"Date",H[b]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Xe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(b,1);Ct.$d[M](Xe),Ct.init(),this.$d=Ct.set(b,Math.min(this.$D,Ct.daysInMonth())).$d}else M&&this.$d[M](Xe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),M=function(rt){var je=_e(ye);return se.w(je.date(je.date()+Math.round(rt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return M(1);if(ke===c)return M(7);var Xe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Xe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||A;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),M=this.$H,Xe=this.$m,Ct=this.$M,rt=H.weekdays,je=H.months,ce=H.meridiem,Ke=function(pt,Ze,Jt,At){return pt&&(pt[Ze]||pt(Se,ye))||Jt[Ze].slice(0,At)},Be=function(pt){return se.s(M%12||12,pt,"0")},be=ce||function(pt,Ze,Jt){var At=pt<12?"AM":"PM";return Jt?At.toLowerCase():At};return ye.replace(z,function(pt,Ze){return Ze||function(Jt){switch(Jt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ke(H.monthsShort,Ct,je,3);case"MMMM":return Ke(je,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ke(H.weekdaysMin,Se.$W,rt,2);case"ddd":return Ke(H.weekdaysShort,Se.$W,rt,3);case"dddd":return rt[Se.$W];case"H":return String(M);case"HH":return se.s(M,2,"0");case"h":return Be(1);case"hh":return Be(2);case"a":return be(M,Xe,!0);case"A":return be(M,Xe,!1);case"m":return String(Xe);case"mm":return se.s(Xe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(pt)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,M=se.p(Se),Xe=_e(ne),Ct=(Xe.utcOffset()-this.utcOffset())*n,rt=this-Xe,je=function(){return se.m(ke,Xe)};switch(M){case m:ye=je()/12;break;case d:ye=je();break;case f:ye=je()/3;break;case c:ye=(rt-Ct)/6048e5;break;case l:ye=(rt-Ct)/864e5;break;case u:ye=rt/i;break;case o:ye=rt/n;break;case s:ye=rt/r;break;default:ye=rt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Oe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=xe(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),re=Te.prototype;return _e.prototype=re,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",b]].forEach(function(oe){re[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=xe,_e.isDayjs=V,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Oe[Fe],_e.Ls=Oe,_e.p={},_e})})(y1);var y3=y1.exports;const b3=sP(y3);function w3(t){return async function({id:r,params:n,chatWindow:i}){i.setInputDisabled(!0);const a=i.chatManager.registerRecurringKeepAlive(),{threadId:s}=i.chatManager,o={isAIChat:!0,guestCardId:n.guestCardId||null,AIChatSessionTimeout:!1,...s&&{AIChatUniqueSessionId:s},...n.firstName&&{firstName:n.firstName},...n.lastName&&{lastName:n.lastName},...n.email&&{email:n.email},...n.phoneNumber&&{phone:n.phoneNumber},...n.desiredMoveInDate&&{moveInDate:b3(n.desiredMoveInDate).format("MM/DD/YYYY")},...n.AccessWidgetLeadId&&{AccessWidgetLeadId:n.AccessWidgetLeadId}},u=document.createElement("iai-chat-iframe-modal");u.title="Schedule a Tour",u.src=`${t}?${new URLSearchParams(o).toString()}`,u.showHeader=!1;const l=()=>{a(),u.remove(),window.removeEventListener("beforeunload",f),i.removeEventListener("iai-chat-reset",l),i.setInputDisabled(!1)},c=async({detail:m})=>{if(m.type!=="tourScheduled")return;const{tourType:b,tourDate:A,tourTime:N,prospectName:z,guestCardId:X,accessWidgetLeadId:Ee}=m;l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Your tour has been scheduled!"});try{await i.sendFunctionCallResponse(r,{status:"scheduled",tourType:b,tourDate:A,tourTime:N,guestCardId:X,firstName:z,accessWidgetLeadId:Ee},!0)}finally{i.setInputDisabled(!1)}},d=async()=>{l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Tour Scheduler Closed"});try{await i.sendFunctionCallResponse(r,{status:"canceled"},!0)}finally{i.setInputDisabled(!1)}},f=async()=>{l(),i.addMessage({role:"system",content:"Tour Scheduler Closed"})};u.addEventListener("message-received",c),u.addEventListener("close",d),i.addEventListener("iai-chat-reset",l),window.addEventListener("beforeunload",f),document.body.appendChild(u),i.addMessage({role:"system",content:"Tour Scheduler Opened"})}}function b1(t,e){return function(){return t.apply(e,arguments)}}const{toString:_3}=Object.prototype,{getPrototypeOf:sm}=Object,Uf=(t=>e=>{const r=_3.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Ci=t=>(t=t.toLowerCase(),e=>Uf(e)===t),Ff=t=>e=>typeof e===t,{isArray:_u}=Array,Ec=Ff("undefined");function k3(t){return t!==null&&!Ec(t)&&t.constructor!==null&&!Ec(t.constructor)&&ai(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const w1=Ci("ArrayBuffer");function S3(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&w1(t.buffer),e}const $3=Ff("string"),ai=Ff("function"),_1=Ff("number"),Bf=t=>t!==null&&typeof t=="object",T3=t=>t===!0||t===!1,zf=t=>{if(Uf(t)!=="object")return!1;const e=sm(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},E3=Ci("Date"),C3=Ci("File"),R3=Ci("Blob"),x3=Ci("FileList"),I3=t=>Bf(t)&&ai(t.pipe),A3=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||ai(t.append)&&((e=Uf(t))==="formdata"||e==="object"&&ai(t.toString)&&t.toString()==="[object FormData]"))},O3=Ci("URLSearchParams"),[P3,M3,N3,L3]=["ReadableStream","Request","Response","Headers"].map(Ci),D3=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Cc(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),_u(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{const a=r?Object.getOwnPropertyNames(t):Object.keys(t),s=a.length;let o;for(n=0;n<s;n++)o=a[n],e.call(null,t[o],o,t)}}function k1(t,e){e=e.toLowerCase();const r=Object.keys(t);let n=r.length,i;for(;n-- >0;)if(i=r[n],e===i.toLowerCase())return i;return null}const S1=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,$1=t=>!Ec(t)&&t!==S1;function om(){const{caseless:t}=$1(this)&&this||{},e={},r=(n,i)=>{const a=t&&k1(e,i)||i;zf(e[a])&&zf(n)?e[a]=om(e[a],n):zf(n)?e[a]=om({},n):_u(n)?e[a]=n.slice():e[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Cc(arguments[n],r);return e}const j3=(t,e,r,{allOwnKeys:n}={})=>(Cc(e,(i,a)=>{r&&ai(i)?t[a]=b1(i,r):t[a]=i},{allOwnKeys:n}),t),U3=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),F3=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},B3=(t,e,r,n)=>{let i,a,s;const o={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),a=i.length;a-- >0;)s=i[a],(!n||n(s,t,e))&&!o[s]&&(e[s]=t[s],o[s]=!0);t=r!==!1&&sm(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},z3=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},H3=t=>{if(!t)return null;if(_u(t))return t;let e=t.length;if(!_1(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},q3=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&sm(Uint8Array)),V3=(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=n.next())&&!i.done;){const a=i.value;e.call(t,a[0],a[1])}},W3=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},Z3=Ci("HTMLFormElement"),G3=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),T1=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),K3=Ci("RegExp"),E1=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};Cc(r,(i,a)=>{let s;(s=e(i,a,t))!==!1&&(n[a]=s||i)}),Object.defineProperties(t,n)},J3=t=>{E1(t,(e,r)=>{if(ai(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(ai(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Y3=(t,e)=>{const r={},n=i=>{i.forEach(a=>{r[a]=!0})};return _u(t)?n(t):n(String(t).split(e)),r},Q3=()=>{},X3=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,um="abcdefghijklmnopqrstuvwxyz",C1="0123456789",R1={DIGIT:C1,ALPHA:um,ALPHA_DIGIT:um+um.toUpperCase()+C1},eL=(t=16,e=R1.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r};function tL(t){return!!(t&&ai(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const rL=t=>{const e=new Array(10),r=(n,i)=>{if(Bf(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[i]=n;const a=_u(n)?[]:{};return Cc(n,(s,o)=>{const u=r(s,i+1);!Ec(u)&&(a[o]=u)}),e[i]=void 0,a}}return n};return r(t,0)},nL=Ci("AsyncFunction"),De={isArray:_u,isArrayBuffer:w1,isBuffer:k3,isFormData:A3,isArrayBufferView:S3,isString:$3,isNumber:_1,isBoolean:T3,isObject:Bf,isPlainObject:zf,isReadableStream:P3,isRequest:M3,isResponse:N3,isHeaders:L3,isUndefined:Ec,isDate:E3,isFile:C3,isBlob:R3,isRegExp:K3,isFunction:ai,isStream:I3,isURLSearchParams:O3,isTypedArray:q3,isFileList:x3,forEach:Cc,merge:om,extend:j3,trim:D3,stripBOM:U3,inherits:F3,toFlatObject:B3,kindOf:Uf,kindOfTest:Ci,endsWith:z3,toArray:H3,forEachEntry:V3,matchAll:W3,isHTMLForm:Z3,hasOwnProperty:T1,hasOwnProp:T1,reduceDescriptors:E1,freezeMethods:J3,toObjectSet:Y3,toCamelCase:G3,noop:Q3,toFiniteNumber:X3,findKey:k1,global:S1,isContextDefined:$1,ALPHABET:R1,generateString:eL,isSpecCompliantForm:tL,toJSONObject:rL,isAsyncFn:nL,isThenable:t=>t&&(Bf(t)||ai(t))&&ai(t.then)&&ai(t.catch)};function ir(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}De.inherits(ir,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:De.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const x1=ir.prototype,I1={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{I1[t]={value:t}}),Object.defineProperties(ir,I1),Object.defineProperty(x1,"isAxiosError",{value:!0}),ir.from=(t,e,r,n,i,a)=>{const s=Object.create(x1);return De.toFlatObject(t,s,function(u){return u!==Error.prototype},o=>o!=="isAxiosError"),ir.call(s,t.message,e,r,n,i),s.cause=t,s.name=t.name,a&&Object.assign(s,a),s};const iL=null;function lm(t){return De.isPlainObject(t)||De.isArray(t)}function A1(t){return De.endsWith(t,"[]")?t.slice(0,-2):t}function O1(t,e,r){return t?t.concat(e).map(function(i,a){return i=A1(i),!r&&a?"["+i+"]":i}).join(r?".":""):e}function aL(t){return De.isArray(t)&&!t.some(lm)}const sL=De.toFlatObject(De,{},null,function(e){return/^is[A-Z]/.test(e)});function Hf(t,e,r){if(!De.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=De.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(A,N){return!De.isUndefined(N[A])});const n=r.metaTokens,i=r.visitor||c,a=r.dots,s=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&De.isSpecCompliantForm(e);if(!De.isFunction(i))throw new TypeError("visitor must be a function");function l(b){if(b===null)return"";if(De.isDate(b))return b.toISOString();if(!u&&De.isBlob(b))throw new ir("Blob is not supported. Use a Buffer instead.");return De.isArrayBuffer(b)||De.isTypedArray(b)?u&&typeof Blob=="function"?new Blob([b]):Buffer.from(b):b}function c(b,A,N){let z=b;if(b&&!N&&typeof b=="object"){if(De.endsWith(A,"{}"))A=n?A:A.slice(0,-2),b=JSON.stringify(b);else if(De.isArray(b)&&aL(b)||(De.isFileList(b)||De.endsWith(A,"[]"))&&(z=De.toArray(b)))return A=A1(A),z.forEach(function(Ee,Ie){!(De.isUndefined(Ee)||Ee===null)&&e.append(s===!0?O1([A],Ie,a):s===null?A:A+"[]",l(Ee))}),!1}return lm(b)?!0:(e.append(O1(N,A,a),l(b)),!1)}const d=[],f=Object.assign(sL,{defaultVisitor:c,convertValue:l,isVisitable:lm});function m(b,A){if(!De.isUndefined(b)){if(d.indexOf(b)!==-1)throw Error("Circular reference detected in "+A.join("."));d.push(b),De.forEach(b,function(z,X){(!(De.isUndefined(z)||z===null)&&i.call(e,z,De.isString(X)?X.trim():X,A,f))===!0&&m(z,A?A.concat(X):[X])}),d.pop()}}if(!De.isObject(t))throw new TypeError("data must be an object");return m(t),e}function P1(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function cm(t,e){this._pairs=[],t&&Hf(t,this,e)}const M1=cm.prototype;M1.append=function(e,r){this._pairs.push([e,r])},M1.toString=function(e){const r=e?function(n){return e.call(this,n,P1)}:P1;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function oL(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function N1(t,e,r){if(!e)return t;const n=r&&r.encode||oL,i=r&&r.serialize;let a;if(i?a=i(e,r):a=De.isURLSearchParams(e)?e.toString():new cm(e,r).toString(n),a){const s=t.indexOf("#");s!==-1&&(t=t.slice(0,s)),t+=(t.indexOf("?")===-1?"?":"&")+a}return t}class L1{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){De.forEach(this.handlers,function(n){n!==null&&e(n)})}}const D1={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},uL={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:cm,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},dm=typeof window<"u"&&typeof document<"u",lL=(t=>dm&&["ReactNative","NativeScript","NS"].indexOf(t)<0)(typeof navigator<"u"&&navigator.product),cL=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",dL=dm&&window.location.href||"http://localhost",Ri={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:dm,hasStandardBrowserEnv:lL,hasStandardBrowserWebWorkerEnv:cL,origin:dL},Symbol.toStringTag,{value:"Module"})),...uL};function fL(t,e){return Hf(t,new Ri.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return Ri.isNode&&De.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},e))}function hL(t){return De.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function pL(t){const e={},r=Object.keys(t);let n;const i=r.length;let a;for(n=0;n<i;n++)a=r[n],e[a]=t[a];return e}function j1(t){function e(r,n,i,a){let s=r[a++];if(s==="__proto__")return!0;const o=Number.isFinite(+s),u=a>=r.length;return s=!s&&De.isArray(i)?i.length:s,u?(De.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!o):((!i[s]||!De.isObject(i[s]))&&(i[s]=[]),e(r,n,i[s],a)&&De.isArray(i[s])&&(i[s]=pL(i[s])),!o)}if(De.isFormData(t)&&De.isFunction(t.entries)){const r={};return De.forEachEntry(t,(n,i)=>{e(hL(n),i,r,0)}),r}return null}function vL(t,e,r){if(De.isString(t))try{return(e||JSON.parse)(t),De.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const Rc={transitional:D1,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=De.isObject(e);if(a&&De.isHTMLForm(e)&&(e=new FormData(e)),De.isFormData(e))return i?JSON.stringify(j1(e)):e;if(De.isArrayBuffer(e)||De.isBuffer(e)||De.isStream(e)||De.isFile(e)||De.isBlob(e)||De.isReadableStream(e))return e;if(De.isArrayBufferView(e))return e.buffer;if(De.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return fL(e,this.formSerializer).toString();if((o=De.isFileList(e))||n.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return Hf(o?{"files[]":e}:e,u&&new u,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),vL(e)):e}],transformResponse:[function(e){const r=this.transitional||Rc.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(De.isResponse(e)||De.isReadableStream(e))return e;if(e&&De.isString(e)&&(n&&!this.responseType||i)){const s=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?ir.from(o,ir.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Ri.classes.FormData,Blob:Ri.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};De.forEach(["delete","get","head","post","put","patch"],t=>{Rc.headers[t]={}});const mL=De.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),gL=t=>{const e={};let r,n,i;return t&&t.split(`
778
778
  `).forEach(function(s){i=s.indexOf(":"),r=s.substring(0,i).trim().toLowerCase(),n=s.substring(i+1).trim(),!(!r||e[r]&&mL[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e},U1=Symbol("internals");function xc(t){return t&&String(t).trim().toLowerCase()}function qf(t){return t===!1||t==null?t:De.isArray(t)?t.map(qf):String(t)}function yL(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}const bL=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function fm(t,e,r,n,i){if(De.isFunction(n))return n.call(this,e,r);if(i&&(e=r),!!De.isString(e)){if(De.isString(n))return e.indexOf(n)!==-1;if(De.isRegExp(n))return n.test(e)}}function wL(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function _L(t,e){const r=De.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(i,a,s){return this[n].call(this,e,i,a,s)},configurable:!0})})}class jn{constructor(e){e&&this.set(e)}set(e,r,n){const i=this;function a(o,u,l){const c=xc(u);if(!c)throw new Error("header name must be a non-empty string");const d=De.findKey(i,c);(!d||i[d]===void 0||l===!0||l===void 0&&i[d]!==!1)&&(i[d||u]=qf(o))}const s=(o,u)=>De.forEach(o,(l,c)=>a(l,c,u));if(De.isPlainObject(e)||e instanceof this.constructor)s(e,r);else if(De.isString(e)&&(e=e.trim())&&!bL(e))s(gL(e),r);else if(De.isHeaders(e))for(const[o,u]of e.entries())a(u,o,n);else e!=null&&a(r,e,n);return this}get(e,r){if(e=xc(e),e){const n=De.findKey(this,e);if(n){const i=this[n];if(!r)return i;if(r===!0)return yL(i);if(De.isFunction(r))return r.call(this,i,n);if(De.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=xc(e),e){const n=De.findKey(this,e);return!!(n&&this[n]!==void 0&&(!r||fm(this,this[n],n,r)))}return!1}delete(e,r){const n=this;let i=!1;function a(s){if(s=xc(s),s){const o=De.findKey(n,s);o&&(!r||fm(n,n[o],o,r))&&(delete n[o],i=!0)}}return De.isArray(e)?e.forEach(a):a(e),i}clear(e){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const a=r[n];(!e||fm(this,this[a],a,e,!0))&&(delete this[a],i=!0)}return i}normalize(e){const r=this,n={};return De.forEach(this,(i,a)=>{const s=De.findKey(n,a);if(s){r[s]=qf(i),delete r[a];return}const o=e?wL(a):String(a).trim();o!==a&&delete r[a],r[o]=qf(i),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const r=Object.create(null);return De.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=e&&De.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(`
779
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[U1]=this[U1]={accessors:{}}).accessors,i=this.prototype;function a(s){const o=xc(s);n[o]||(_L(i,s),n[o]=!0)}return De.isArray(e)?e.forEach(a):a(e),this}}jn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),De.reduceDescriptors(jn.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),De.freezeMethods(jn);function hm(t,e){const r=this||Rc,n=e||r,i=jn.from(n.headers);let a=n.data;return De.forEach(t,function(o){a=o.call(r,a,i.normalize(),e?e.status:void 0)}),i.normalize(),a}function F1(t){return!!(t&&t.__CANCEL__)}function ku(t,e,r){ir.call(this,t??"canceled",ir.ERR_CANCELED,e,r),this.name="CanceledError"}De.inherits(ku,ir,{__CANCEL__:!0});function B1(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new ir("Request failed with status code "+r.status,[ir.ERR_BAD_REQUEST,ir.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function kL(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function SL(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i=0,a=0,s;return e=e!==void 0?e:1e3,function(u){const l=Date.now(),c=n[a];s||(s=l),r[i]=u,n[i]=l;let d=a,f=0;for(;d!==i;)f+=r[d++],d=d%t;if(i=(i+1)%t,i===a&&(a=(a+1)%t),l-s<e)return;const m=c&&l-c;return m?Math.round(f*1e3/m):void 0}}function $L(t,e){let r=0;const n=1e3/e;let i=null;return function(){const s=this===!0,o=Date.now();if(s||o-r>n)return i&&(clearTimeout(i),i=null),r=o,t.apply(null,arguments);i||(i=setTimeout(()=>(i=null,r=Date.now(),t.apply(null,arguments)),n-(o-r)))}}const Vf=(t,e,r=3)=>{let n=0;const i=SL(50,250);return $L(a=>{const s=a.loaded,o=a.lengthComputable?a.total:void 0,u=s-n,l=i(u),c=s<=o;n=s;const d={loaded:s,total:o,progress:o?s/o:void 0,bytes:u,rate:l||void 0,estimated:l&&o&&c?(o-s)/l:void 0,event:a,lengthComputable:o!=null};d[e?"download":"upload"]=!0,t(d)},r)},TL=Ri.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");let n;function i(a){let s=a;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(s){const o=De.isString(s)?i(s):s;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}(),EL=Ri.hasStandardBrowserEnv?{write(t,e,r,n,i,a){const s=[t+"="+encodeURIComponent(e)];De.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),De.isString(n)&&s.push("path="+n),De.isString(i)&&s.push("domain="+i),a===!0&&s.push("secure"),document.cookie=s.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function CL(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function RL(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function z1(t,e){return t&&!CL(e)?RL(t,e):e}const H1=t=>t instanceof jn?{...t}:t;function vo(t,e){e=e||{};const r={};function n(l,c,d){return De.isPlainObject(l)&&De.isPlainObject(c)?De.merge.call({caseless:d},l,c):De.isPlainObject(c)?De.merge({},c):De.isArray(c)?c.slice():c}function i(l,c,d){if(De.isUndefined(c)){if(!De.isUndefined(l))return n(void 0,l,d)}else return n(l,c,d)}function a(l,c){if(!De.isUndefined(c))return n(void 0,c)}function s(l,c){if(De.isUndefined(c)){if(!De.isUndefined(l))return n(void 0,l)}else return n(void 0,c)}function o(l,c,d){if(d in e)return n(l,c);if(d in t)return n(void 0,l)}const u={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:o,headers:(l,c)=>i(H1(l),H1(c),!0)};return De.forEach(Object.keys(Object.assign({},t,e)),function(c){const d=u[c]||i,f=d(t[c],e[c],c);De.isUndefined(f)&&d!==o||(r[c]=f)}),r}const q1=t=>{const e=vo({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:s,auth:o}=e;e.headers=s=jn.from(s),e.url=N1(z1(e.baseURL,e.url),t.params,t.paramsSerializer),o&&s.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let u;if(De.isFormData(r)){if(Ri.hasStandardBrowserEnv||Ri.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[l,...c]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([l||"multipart/form-data",...c].join("; "))}}if(Ri.hasStandardBrowserEnv&&(n&&De.isFunction(n)&&(n=n(e)),n||n!==!1&&TL(e.url))){const l=i&&a&&EL.read(a);l&&s.set(i,l)}return e},xL=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const i=q1(t);let a=i.data;const s=jn.from(i.headers).normalize();let{responseType:o}=i,u;function l(){i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let c=new XMLHttpRequest;c.open(i.method.toUpperCase(),i.url,!0),c.timeout=i.timeout;function d(){if(!c)return;const m=jn.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),A={data:!o||o==="text"||o==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:m,config:t,request:c};B1(function(z){r(z),l()},function(z){n(z),l()},A),c=null}"onloadend"in c?c.onloadend=d:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(d)},c.onabort=function(){c&&(n(new ir("Request aborted",ir.ECONNABORTED,i,c)),c=null)},c.onerror=function(){n(new ir("Network Error",ir.ERR_NETWORK,i,c)),c=null},c.ontimeout=function(){let b=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const A=i.transitional||D1;i.timeoutErrorMessage&&(b=i.timeoutErrorMessage),n(new ir(b,A.clarifyTimeoutError?ir.ETIMEDOUT:ir.ECONNABORTED,i,c)),c=null},a===void 0&&s.setContentType(null),"setRequestHeader"in c&&De.forEach(s.toJSON(),function(b,A){c.setRequestHeader(A,b)}),De.isUndefined(i.withCredentials)||(c.withCredentials=!!i.withCredentials),o&&o!=="json"&&(c.responseType=i.responseType),typeof i.onDownloadProgress=="function"&&c.addEventListener("progress",Vf(i.onDownloadProgress,!0)),typeof i.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Vf(i.onUploadProgress)),(i.cancelToken||i.signal)&&(u=m=>{c&&(n(!m||m.type?new ku(null,t,c):m),c.abort(),c=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const f=kL(i.url);if(f&&Ri.protocols.indexOf(f)===-1){n(new ir("Unsupported protocol "+f+":",ir.ERR_BAD_REQUEST,t));return}c.send(a||null)})},IL=(t,e)=>{let r=new AbortController,n;const i=function(u){if(!n){n=!0,s();const l=u instanceof Error?u:this.reason;r.abort(l instanceof ir?l:new ku(l instanceof Error?l.message:l))}};let a=e&&setTimeout(()=>{i(new ir(`timeout ${e} of ms exceeded`,ir.ETIMEDOUT))},e);const s=()=>{t&&(a&&clearTimeout(a),a=null,t.forEach(u=>{u&&(u.removeEventListener?u.removeEventListener("abort",i):u.unsubscribe(i))}),t=null)};t.forEach(u=>u&&u.addEventListener&&u.addEventListener("abort",i));const{signal:o}=r;return o.unsubscribe=s,[o,()=>{a&&clearTimeout(a),a=null}]},AL=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,i;for(;n<r;)i=n+e,yield t.slice(n,i),n=i},OL=async function*(t,e,r){for await(const n of t)yield*AL(ArrayBuffer.isView(n)?n:await r(String(n)),e)},V1=(t,e,r,n,i)=>{const a=OL(t,e,i);let s=0;return new ReadableStream({type:"bytes",async pull(o){const{done:u,value:l}=await a.next();if(u){o.close(),n();return}let c=l.byteLength;r&&r(s+=c),o.enqueue(new Uint8Array(l))},cancel(o){return n(o),a.return()}},{highWaterMark:2})},W1=(t,e)=>{const r=t!=null;return n=>setTimeout(()=>e({lengthComputable:r,total:t,loaded:n}))},Wf=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Z1=Wf&&typeof ReadableStream=="function",pm=Wf&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),PL=Z1&&(()=>{let t=!1;const e=new Request(Ri.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),G1=64*1024,vm=Z1&&!!(()=>{try{return De.isReadableStream(new Response("").body)}catch{}})(),Zf={stream:vm&&(t=>t.body)};Wf&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Zf[e]&&(Zf[e]=De.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new ir(`Response type '${e}' is not supported`,ir.ERR_NOT_SUPPORT,n)})})})(new Response);const ML=async t=>{if(t==null)return 0;if(De.isBlob(t))return t.size;if(De.isSpecCompliantForm(t))return(await new Request(t).arrayBuffer()).byteLength;if(De.isArrayBufferView(t))return t.byteLength;if(De.isURLSearchParams(t)&&(t=t+""),De.isString(t))return(await pm(t)).byteLength},NL=async(t,e)=>{const r=De.toFiniteNumber(t.getContentLength());return r??ML(e)},mm={http:iL,xhr:xL,fetch:Wf&&(async t=>{let{url:e,method:r,data:n,signal:i,cancelToken:a,timeout:s,onDownloadProgress:o,onUploadProgress:u,responseType:l,headers:c,withCredentials:d="same-origin",fetchOptions:f}=q1(t);l=l?(l+"").toLowerCase():"text";let[m,b]=i||a||s?IL([i,a],s):[],A,N;const z=()=>{!A&&setTimeout(()=>{m&&m.unsubscribe()}),A=!0};let X;try{if(u&&PL&&r!=="get"&&r!=="head"&&(X=await NL(c,n))!==0){let Oe=new Request(e,{method:"POST",body:n,duplex:"half"}),ze;De.isFormData(n)&&(ze=Oe.headers.get("content-type"))&&c.setContentType(ze),Oe.body&&(n=V1(Oe.body,G1,W1(X,Vf(u)),null,pm))}De.isString(d)||(d=d?"cors":"omit"),N=new Request(e,{...f,signal:m,method:r.toUpperCase(),headers:c.normalize().toJSON(),body:n,duplex:"half",withCredentials:d});let Ee=await fetch(N);const Ie=vm&&(l==="stream"||l==="response");if(vm&&(o||Ie)){const Oe={};["status","statusText","headers"].forEach(V=>{Oe[V]=Ee[V]});const ze=De.toFiniteNumber(Ee.headers.get("content-length"));Ee=new Response(V1(Ee.body,G1,o&&W1(ze,Vf(o,!0)),Ie&&z,pm),Oe)}l=l||"text";let Be=await Zf[De.findKey(Zf,l)||"text"](Ee,t);return!Ie&&z(),b&&b(),await new Promise((Oe,ze)=>{B1(Oe,ze,{data:Be,headers:jn.from(Ee.headers),status:Ee.status,statusText:Ee.statusText,config:t,request:N})})}catch(Ee){throw z(),Ee&&Ee.name==="TypeError"&&/fetch/i.test(Ee.message)?Object.assign(new ir("Network Error",ir.ERR_NETWORK,t,N),{cause:Ee.cause||Ee}):ir.from(Ee,Ee&&Ee.code,t,N)}})};De.forEach(mm,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const K1=t=>`- ${t}`,LL=t=>De.isFunction(t)||t===null||t===!1,J1={getAdapter:t=>{t=De.isArray(t)?t:[t];const{length:e}=t;let r,n;const i={};for(let a=0;a<e;a++){r=t[a];let s;if(n=r,!LL(r)&&(n=mm[(s=String(r)).toLowerCase()],n===void 0))throw new ir(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+a]=n}if(!n){const a=Object.entries(i).map(([o,u])=>`adapter ${o} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=e?a.length>1?`since :
779
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[U1]=this[U1]={accessors:{}}).accessors,i=this.prototype;function a(s){const o=xc(s);n[o]||(_L(i,s),n[o]=!0)}return De.isArray(e)?e.forEach(a):a(e),this}}jn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),De.reduceDescriptors(jn.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),De.freezeMethods(jn);function hm(t,e){const r=this||Rc,n=e||r,i=jn.from(n.headers);let a=n.data;return De.forEach(t,function(o){a=o.call(r,a,i.normalize(),e?e.status:void 0)}),i.normalize(),a}function F1(t){return!!(t&&t.__CANCEL__)}function ku(t,e,r){ir.call(this,t??"canceled",ir.ERR_CANCELED,e,r),this.name="CanceledError"}De.inherits(ku,ir,{__CANCEL__:!0});function B1(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new ir("Request failed with status code "+r.status,[ir.ERR_BAD_REQUEST,ir.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function kL(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function SL(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i=0,a=0,s;return e=e!==void 0?e:1e3,function(u){const l=Date.now(),c=n[a];s||(s=l),r[i]=u,n[i]=l;let d=a,f=0;for(;d!==i;)f+=r[d++],d=d%t;if(i=(i+1)%t,i===a&&(a=(a+1)%t),l-s<e)return;const m=c&&l-c;return m?Math.round(f*1e3/m):void 0}}function $L(t,e){let r=0;const n=1e3/e;let i=null;return function(){const s=this===!0,o=Date.now();if(s||o-r>n)return i&&(clearTimeout(i),i=null),r=o,t.apply(null,arguments);i||(i=setTimeout(()=>(i=null,r=Date.now(),t.apply(null,arguments)),n-(o-r)))}}const Vf=(t,e,r=3)=>{let n=0;const i=SL(50,250);return $L(a=>{const s=a.loaded,o=a.lengthComputable?a.total:void 0,u=s-n,l=i(u),c=s<=o;n=s;const d={loaded:s,total:o,progress:o?s/o:void 0,bytes:u,rate:l||void 0,estimated:l&&o&&c?(o-s)/l:void 0,event:a,lengthComputable:o!=null};d[e?"download":"upload"]=!0,t(d)},r)},TL=Ri.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");let n;function i(a){let s=a;return e&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(s){const o=De.isString(s)?i(s):s;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}(),EL=Ri.hasStandardBrowserEnv?{write(t,e,r,n,i,a){const s=[t+"="+encodeURIComponent(e)];De.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),De.isString(n)&&s.push("path="+n),De.isString(i)&&s.push("domain="+i),a===!0&&s.push("secure"),document.cookie=s.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function CL(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function RL(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function z1(t,e){return t&&!CL(e)?RL(t,e):e}const H1=t=>t instanceof jn?{...t}:t;function vo(t,e){e=e||{};const r={};function n(l,c,d){return De.isPlainObject(l)&&De.isPlainObject(c)?De.merge.call({caseless:d},l,c):De.isPlainObject(c)?De.merge({},c):De.isArray(c)?c.slice():c}function i(l,c,d){if(De.isUndefined(c)){if(!De.isUndefined(l))return n(void 0,l,d)}else return n(l,c,d)}function a(l,c){if(!De.isUndefined(c))return n(void 0,c)}function s(l,c){if(De.isUndefined(c)){if(!De.isUndefined(l))return n(void 0,l)}else return n(void 0,c)}function o(l,c,d){if(d in e)return n(l,c);if(d in t)return n(void 0,l)}const u={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:o,headers:(l,c)=>i(H1(l),H1(c),!0)};return De.forEach(Object.keys(Object.assign({},t,e)),function(c){const d=u[c]||i,f=d(t[c],e[c],c);De.isUndefined(f)&&d!==o||(r[c]=f)}),r}const q1=t=>{const e=vo({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:s,auth:o}=e;e.headers=s=jn.from(s),e.url=N1(z1(e.baseURL,e.url),t.params,t.paramsSerializer),o&&s.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let u;if(De.isFormData(r)){if(Ri.hasStandardBrowserEnv||Ri.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[l,...c]=u?u.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([l||"multipart/form-data",...c].join("; "))}}if(Ri.hasStandardBrowserEnv&&(n&&De.isFunction(n)&&(n=n(e)),n||n!==!1&&TL(e.url))){const l=i&&a&&EL.read(a);l&&s.set(i,l)}return e},xL=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const i=q1(t);let a=i.data;const s=jn.from(i.headers).normalize();let{responseType:o}=i,u;function l(){i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let c=new XMLHttpRequest;c.open(i.method.toUpperCase(),i.url,!0),c.timeout=i.timeout;function d(){if(!c)return;const m=jn.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),A={data:!o||o==="text"||o==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:m,config:t,request:c};B1(function(z){r(z),l()},function(z){n(z),l()},A),c=null}"onloadend"in c?c.onloadend=d:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(d)},c.onabort=function(){c&&(n(new ir("Request aborted",ir.ECONNABORTED,i,c)),c=null)},c.onerror=function(){n(new ir("Network Error",ir.ERR_NETWORK,i,c)),c=null},c.ontimeout=function(){let b=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const A=i.transitional||D1;i.timeoutErrorMessage&&(b=i.timeoutErrorMessage),n(new ir(b,A.clarifyTimeoutError?ir.ETIMEDOUT:ir.ECONNABORTED,i,c)),c=null},a===void 0&&s.setContentType(null),"setRequestHeader"in c&&De.forEach(s.toJSON(),function(b,A){c.setRequestHeader(A,b)}),De.isUndefined(i.withCredentials)||(c.withCredentials=!!i.withCredentials),o&&o!=="json"&&(c.responseType=i.responseType),typeof i.onDownloadProgress=="function"&&c.addEventListener("progress",Vf(i.onDownloadProgress,!0)),typeof i.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Vf(i.onUploadProgress)),(i.cancelToken||i.signal)&&(u=m=>{c&&(n(!m||m.type?new ku(null,t,c):m),c.abort(),c=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const f=kL(i.url);if(f&&Ri.protocols.indexOf(f)===-1){n(new ir("Unsupported protocol "+f+":",ir.ERR_BAD_REQUEST,t));return}c.send(a||null)})},IL=(t,e)=>{let r=new AbortController,n;const i=function(u){if(!n){n=!0,s();const l=u instanceof Error?u:this.reason;r.abort(l instanceof ir?l:new ku(l instanceof Error?l.message:l))}};let a=e&&setTimeout(()=>{i(new ir(`timeout ${e} of ms exceeded`,ir.ETIMEDOUT))},e);const s=()=>{t&&(a&&clearTimeout(a),a=null,t.forEach(u=>{u&&(u.removeEventListener?u.removeEventListener("abort",i):u.unsubscribe(i))}),t=null)};t.forEach(u=>u&&u.addEventListener&&u.addEventListener("abort",i));const{signal:o}=r;return o.unsubscribe=s,[o,()=>{a&&clearTimeout(a),a=null}]},AL=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,i;for(;n<r;)i=n+e,yield t.slice(n,i),n=i},OL=async function*(t,e,r){for await(const n of t)yield*AL(ArrayBuffer.isView(n)?n:await r(String(n)),e)},V1=(t,e,r,n,i)=>{const a=OL(t,e,i);let s=0;return new ReadableStream({type:"bytes",async pull(o){const{done:u,value:l}=await a.next();if(u){o.close(),n();return}let c=l.byteLength;r&&r(s+=c),o.enqueue(new Uint8Array(l))},cancel(o){return n(o),a.return()}},{highWaterMark:2})},W1=(t,e)=>{const r=t!=null;return n=>setTimeout(()=>e({lengthComputable:r,total:t,loaded:n}))},Wf=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Z1=Wf&&typeof ReadableStream=="function",pm=Wf&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),PL=Z1&&(()=>{let t=!1;const e=new Request(Ri.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e})(),G1=64*1024,vm=Z1&&!!(()=>{try{return De.isReadableStream(new Response("").body)}catch{}})(),Zf={stream:vm&&(t=>t.body)};Wf&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Zf[e]&&(Zf[e]=De.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new ir(`Response type '${e}' is not supported`,ir.ERR_NOT_SUPPORT,n)})})})(new Response);const ML=async t=>{if(t==null)return 0;if(De.isBlob(t))return t.size;if(De.isSpecCompliantForm(t))return(await new Request(t).arrayBuffer()).byteLength;if(De.isArrayBufferView(t))return t.byteLength;if(De.isURLSearchParams(t)&&(t=t+""),De.isString(t))return(await pm(t)).byteLength},NL=async(t,e)=>{const r=De.toFiniteNumber(t.getContentLength());return r??ML(e)},mm={http:iL,xhr:xL,fetch:Wf&&(async t=>{let{url:e,method:r,data:n,signal:i,cancelToken:a,timeout:s,onDownloadProgress:o,onUploadProgress:u,responseType:l,headers:c,withCredentials:d="same-origin",fetchOptions:f}=q1(t);l=l?(l+"").toLowerCase():"text";let[m,b]=i||a||s?IL([i,a],s):[],A,N;const z=()=>{!A&&setTimeout(()=>{m&&m.unsubscribe()}),A=!0};let X;try{if(u&&PL&&r!=="get"&&r!=="head"&&(X=await NL(c,n))!==0){let Oe=new Request(e,{method:"POST",body:n,duplex:"half"}),ze;De.isFormData(n)&&(ze=Oe.headers.get("content-type"))&&c.setContentType(ze),Oe.body&&(n=V1(Oe.body,G1,W1(X,Vf(u)),null,pm))}De.isString(d)||(d=d?"cors":"omit"),N=new Request(e,{...f,signal:m,method:r.toUpperCase(),headers:c.normalize().toJSON(),body:n,duplex:"half",withCredentials:d});let Ee=await fetch(N);const Ie=vm&&(l==="stream"||l==="response");if(vm&&(o||Ie)){const Oe={};["status","statusText","headers"].forEach(V=>{Oe[V]=Ee[V]});const ze=De.toFiniteNumber(Ee.headers.get("content-length"));Ee=new Response(V1(Ee.body,G1,o&&W1(ze,Vf(o,!0)),Ie&&z,pm),Oe)}l=l||"text";let Fe=await Zf[De.findKey(Zf,l)||"text"](Ee,t);return!Ie&&z(),b&&b(),await new Promise((Oe,ze)=>{B1(Oe,ze,{data:Fe,headers:jn.from(Ee.headers),status:Ee.status,statusText:Ee.statusText,config:t,request:N})})}catch(Ee){throw z(),Ee&&Ee.name==="TypeError"&&/fetch/i.test(Ee.message)?Object.assign(new ir("Network Error",ir.ERR_NETWORK,t,N),{cause:Ee.cause||Ee}):ir.from(Ee,Ee&&Ee.code,t,N)}})};De.forEach(mm,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const K1=t=>`- ${t}`,LL=t=>De.isFunction(t)||t===null||t===!1,J1={getAdapter:t=>{t=De.isArray(t)?t:[t];const{length:e}=t;let r,n;const i={};for(let a=0;a<e;a++){r=t[a];let s;if(n=r,!LL(r)&&(n=mm[(s=String(r)).toLowerCase()],n===void 0))throw new ir(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+a]=n}if(!n){const a=Object.entries(i).map(([o,u])=>`adapter ${o} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=e?a.length>1?`since :
780
780
  `+a.map(K1).join(`
781
781
  `):" "+K1(a[0]):"as no adapter specified";throw new ir("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:mm};function gm(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new ku(null,t)}function Y1(t){return gm(t),t.headers=jn.from(t.headers),t.data=hm.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),J1.getAdapter(t.adapter||Rc.adapter)(t).then(function(n){return gm(t),n.data=hm.call(t,t.transformResponse,n),n.headers=jn.from(n.headers),n},function(n){return F1(n)||(gm(t),n&&n.response&&(n.response.data=hm.call(t,t.transformResponse,n.response),n.response.headers=jn.from(n.response.headers))),Promise.reject(n)})}const Q1="1.7.2",ym={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{ym[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const X1={};ym.transitional=function(e,r,n){function i(a,s){return"[Axios v"+Q1+"] Transitional option '"+a+"'"+s+(n?". "+n:"")}return(a,s,o)=>{if(e===!1)throw new ir(i(s," has been removed"+(r?" in "+r:"")),ir.ERR_DEPRECATED);return r&&!X1[s]&&(X1[s]=!0,console.warn(i(s," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(a,s,o):!0}};function DL(t,e,r){if(typeof t!="object")throw new ir("options must be an object",ir.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const a=n[i],s=e[a];if(s){const o=t[a],u=o===void 0||s(o,a,t);if(u!==!0)throw new ir("option "+a+" must be "+u,ir.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ir("Unknown option "+a,ir.ERR_BAD_OPTION)}}const bm={assertOptions:DL,validators:ym},hs=bm.validators;class mo{constructor(e){this.defaults=e,this.interceptors={request:new L1,response:new L1}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let i;Error.captureStackTrace?Error.captureStackTrace(i={}):i=new Error;const a=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?a&&!String(n.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(n.stack+=`
782
- `+a):n.stack=a}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=vo(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:a}=r;n!==void 0&&bm.assertOptions(n,{silentJSONParsing:hs.transitional(hs.boolean),forcedJSONParsing:hs.transitional(hs.boolean),clarifyTimeoutError:hs.transitional(hs.boolean)},!1),i!=null&&(De.isFunction(i)?r.paramsSerializer={serialize:i}:bm.assertOptions(i,{encode:hs.function,serialize:hs.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=a&&De.merge(a.common,a[r.method]);a&&De.forEach(["delete","get","head","post","put","patch","common"],b=>{delete a[b]}),r.headers=jn.concat(s,a);const o=[];let u=!0;this.interceptors.request.forEach(function(A){typeof A.runWhen=="function"&&A.runWhen(r)===!1||(u=u&&A.synchronous,o.unshift(A.fulfilled,A.rejected))});const l=[];this.interceptors.response.forEach(function(A){l.push(A.fulfilled,A.rejected)});let c,d=0,f;if(!u){const b=[Y1.bind(this),void 0];for(b.unshift.apply(b,o),b.push.apply(b,l),f=b.length,c=Promise.resolve(r);d<f;)c=c.then(b[d++],b[d++]);return c}f=o.length;let m=r;for(d=0;d<f;){const b=o[d++],A=o[d++];try{m=b(m)}catch(N){A.call(this,N);break}}try{c=Y1.call(this,m)}catch(b){return Promise.reject(b)}for(d=0,f=l.length;d<f;)c=c.then(l[d++],l[d++]);return c}getUri(e){e=vo(this.defaults,e);const r=z1(e.baseURL,e.url);return N1(r,e.params,e.paramsSerializer)}}De.forEach(["delete","get","head","options"],function(e){mo.prototype[e]=function(r,n){return this.request(vo(n||{},{method:e,url:r,data:(n||{}).data}))}}),De.forEach(["post","put","patch"],function(e){function r(n){return function(a,s,o){return this.request(vo(o||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:a,data:s}))}}mo.prototype[e]=r(),mo.prototype[e+"Form"]=r(!0)});class wm{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});const n=this;this.promise.then(i=>{if(!n._listeners)return;let a=n._listeners.length;for(;a-- >0;)n._listeners[a](i);n._listeners=null}),this.promise.then=i=>{let a;const s=new Promise(o=>{n.subscribe(o),a=o}).then(i);return s.cancel=function(){n.unsubscribe(a)},s},e(function(a,s,o){n.reason||(n.reason=new ku(a,s,o),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}static source(){let e;return{token:new wm(function(i){e=i}),cancel:e}}}function jL(t){return function(r){return t.apply(null,r)}}function UL(t){return De.isObject(t)&&t.isAxiosError===!0}const _m={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(_m).forEach(([t,e])=>{_m[e]=t});function ek(t){const e=new mo(t),r=b1(mo.prototype.request,e);return De.extend(r,mo.prototype,e,{allOwnKeys:!0}),De.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return ek(vo(t,i))},r}const Qr=ek(Rc);Qr.Axios=mo,Qr.CanceledError=ku,Qr.CancelToken=wm,Qr.isCancel=F1,Qr.VERSION=Q1,Qr.toFormData=Hf,Qr.AxiosError=ir,Qr.Cancel=Qr.CanceledError,Qr.all=function(e){return Promise.all(e)},Qr.spread=jL,Qr.isAxiosError=UL,Qr.mergeConfig=vo,Qr.AxiosHeaders=jn,Qr.formToJSON=t=>j1(De.isHTMLForm(t)?new FormData(t):t),Qr.getAdapter=J1.getAdapter,Qr.HttpStatusCode=_m,Qr.default=Qr;function tk(t,e){let r=!1;e.on("conversationCreated",()=>{t.setInputDisabled(!1),localStorage.setItem(go(t.cleanOptions.config.historyKey),JSON.stringify(e.getState()))}),e.on("agentJoined",o=>{t.addMessage({role:"system",content:"Agent has joined the chat"})}),e.on("agentLeftConversation",o=>{const u=e.getState().identity;if(o.identity===u){console.log("[transferToTwilio] Customer left (not showing message to self)");return}t.addMessage({role:"system",content:"Agent has left the chat"})}),e.on("agentTyping",o=>{o.identity!==e.getState().identity&&t.setTypingIndicatorVisible(!0)}),e.on("typingEnded",()=>{t.setTypingIndicatorVisible(!1)}),e.on("message",o=>{console.log("[transferToTwilio] Message event received");const u=o.author||o.identity||"unknown",l=o.body||o.message||"",c=e.getState().identity;if(u===c||u==="customer"||u==="user"){console.log("[transferToTwilio] Skipping own message from:",u);return}t.setTypingIndicatorVisible(!1),t.addMessage({role:"assistant",name:"Agent",content:l})}),e.on("conversationClosed",()=>{t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(go(t.cleanOptions.config.historyKey))}),e.on("conversationLeft",o=>{if(console.log("[transferToTwilio] Conversation left event"),r){console.log("[transferToTwilio] User-initiated reset, skipping end message"),r=!1;return}t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(go(t.cleanOptions.config.historyKey))}),e.on("error",o=>{console.error("[Twilio Error]:",o),t.addMessage({role:"system",content:`Error: ${o.message||"An error occurred"}`})}),e.on("connected",()=>{console.log("[Twilio] Connected to backend")}),e.on("disconnected",()=>{console.log("[Twilio] Disconnected from backend")}),e.connect();const n=async o=>{o.preventDefault(),t.addMessage({role:"user",content:o.detail.message}),await e.sendMessage({body:o.detail.message,author:"customer",triggerStudioFlow:!1})},i=async()=>{e.destroy(),t.removeEventListener("iai-chat-send-user-message",n),t.removeEventListener("iai-chat-reset",s),t.removeEventListener("iai-chat-destroy",i)},a=t.cleanOptions.config.disclaimerMessage,s=async()=>{r=!0,await e.terminateConversation(),await i(),localStorage.removeItem(go(t.cleanOptions.config.historyKey)),t.cleanOptions.config.disclaimerMessage=a};t.cleanOptions.config.disclaimerMessage="",t.addEventListener("iai-chat-send-user-message",n),t.addEventListener("iai-chat-reset",s),t.addEventListener("iai-chat-destroy",i)}function FL(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}var km;(t=>{(e=>{e.TEXT="TEXT"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.GENERIC="GENERIC",e.SMS="SMS",e.RCS="RCS",e.FACEBOOK="FACEBOOK",e.TWITTER="TWITTER",e.WHATSAPP="WHATSAPP",e.WECHAT="WECHAT",e.QQMOBILE="QQMOBILE",e.APPLE_BUSINESS_CHAT="APPLE_BUSINESS_CHAT",e.SKYPE="SKYPE",e.SNAPCHAT="SNAPCHAT",e.VIBER="VIBER",e.LINE="LINE",e.TELEGRAM="TELEGRAM",e.KAKAO="KAKAO"})(t.ContentType||(t.ContentType={})),(e=>{e.SYSTEM="SYSTEM",e.USER="USER"})(t.ConversationEventOrigin||(t.ConversationEventOrigin={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.TERMINATED="TERMINATED"})(t.ConversationStatus||(t.ConversationStatus={}))})(km||(km={})),km.AcknowledgeType;var qr;(t=>{(e=>{e.TEXT="TEXT",e.MEDIA="MEDIA"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.CONNECTING="connecting",e.CONNECTED="connected",e.DISCONNECTING="disconnecting",e.DISCONNECTED="disconnected",e.DENIED="denied",e.ERROR="error"})(t.ConnectionState||(t.ConnectionState={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE",e.CLOSED="CLOSED"})(t.ConversationStatus||(t.ConversationStatus={})),(e=>{e.CHAT="chat",e.SMS="sms",e.WHATSAPP="whatsapp"})(t.ParticipantType||(t.ParticipantType={})),(e=>{e.QUEUED="queued",e.SENT="sent",e.DELIVERED="delivered",e.READ="read",e.FAILED="failed",e.UNDELIVERED="undelivered"})(t.DeliveryStatus||(t.DeliveryStatus={}))})(qr||(qr={}));class Gf{constructor(){this._emitter=FL(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),this.client=null,this.conversation=null,this.accessToken=null,this.identity=null,this.conversationSid=null,this.conversationStarted=!1,this.connectionState=qr.ConnectionState.DISCONNECTED,this.conversationStatus=qr.ConversationStatus.PENDING,this.config=null,this.messageQueue=[]}serialize(){return JSON.stringify({accessToken:this.accessToken,identity:this.identity,conversationSid:this.conversationSid,conversationStarted:this.conversationStarted,connectionState:this.connectionState,conversationStatus:this.conversationStatus})}static deserialize(e){const r=JSON.parse(e),n=new Gf;return r.accessToken&&r.identity&&(n.accessToken=r.accessToken,n.identity=r.identity),r.conversationSid&&(n.conversationSid=r.conversationSid),n.conversationStarted=r.conversationStarted||!1,n.connectionState=r.connectionState||qr.ConnectionState.DISCONNECTED,n.conversationStatus=r.conversationStatus||qr.ConversationStatus.PENDING,n}setupClientListeners(){this.client&&(this.client.on("connectionStateChanged",e=>{const r=this.connectionState,n=this.mapConnectionState(e);this.connectionState=n,this._emitter.emit("connectionStateChanged",{previous:r,current:n}),n===qr.ConnectionState.CONNECTED&&r!==qr.ConnectionState.CONNECTED&&this.processMessageQueue()}),this.client.on("tokenAboutToExpire",async()=>{console.log("Token about to expire, refreshing..."),await this.refreshToken()}),this.client.on("tokenExpired",async()=>{console.warn("Token expired, refreshing..."),await this.refreshToken()}),this.client.on("conversationJoined",e=>{console.log("Conversation joined"),this._emitter.emit("conversationJoined",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("conversationLeft",e=>{console.log("Conversation left"),this._emitter.emit("conversationLeft",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("connectionError",e=>{console.error("Twilio connection error:",e),this.handleError("Connection error",e)}))}async initialize(e){try{this.config=e,this.accessToken=e.accessToken,this.identity=e.identity,this.tokenRefreshUrl=e.tokenRefreshUrl;const{Client:r}=await Promise.resolve().then(()=>Bie);this.client=new r(e.accessToken,{logLevel:e.logLevel||"error"}),this.setupClientListeners(),await this.waitForClientReady(),e.conversationSid&&(this.conversationSid=e.conversationSid,await this.joinConversation(e.conversationSid))}catch(r){throw console.error("Failed to initialize Twilio Manager:",r),this.handleError("Initialization failed",r),r}}async waitForClientReady(){return new Promise((e,r)=>{if(!this.client){r(new Error("Client not initialized"));return}const n=setTimeout(()=>{r(new Error("Client initialization timeout"))},3e4);this.client.on("initialized",()=>{clearTimeout(n),e()}),this.client.on("initFailed",i=>{clearTimeout(n),r(i)})})}mapConnectionState(e){switch(e){case"connecting":return qr.ConnectionState.CONNECTING;case"connected":return qr.ConnectionState.CONNECTED;case"disconnecting":return qr.ConnectionState.DISCONNECTING;case"disconnected":return qr.ConnectionState.DISCONNECTED;case"denied":return qr.ConnectionState.DENIED;case"error":return qr.ConnectionState.ERROR;default:return qr.ConnectionState.DISCONNECTED}}async refreshToken(){try{if(!this.tokenRefreshUrl)throw new Error("Token refresh URL not configured");const e=await fetch(this.tokenRefreshUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:this.identity})});if(!e.ok)throw new Error(`Token refresh failed: ${e.statusText}`);const r=await e.json();this.accessToken=r.token,this.client&&(await this.client.updateToken(r.token),console.log("Token refreshed successfully"),this._emitter.emit("tokenRefreshed",{timestamp:new Date}))}catch(e){throw console.error("Token refresh failed:",e),this.handleError("Token refresh failed",e),e}}async createConversation(e){try{if(!this.client)throw new Error("Client not initialized");const r=await this.client.createConversation({friendlyName:e.friendlyName,uniqueName:e.uniqueName,attributes:e.attributes});this.conversation=r,this.conversationSid=r.sid,await r.join(),this.setupConversationListeners(r);const n={sid:r.sid,friendlyName:r.friendlyName,uniqueName:r.uniqueName,attributes:r.attributes,dateCreated:r.dateCreated,dateUpdated:r.dateUpdated,state:r.state,status:qr.ConversationStatus.ACTIVE};return this.conversationStarted=!0,this.conversationStatus=qr.ConversationStatus.ACTIVE,this._emitter.emit("conversationCreated",n),n}catch(r){throw console.error("Failed to create conversation:",r),this.handleError("Conversation creation failed",r),r}}async joinConversation(e){try{if(!this.client)throw new Error("Client not initialized");console.log("Joining conversation:",e);const r=await this.client.getConversationBySid(e);try{await r.join()}catch(n){if(n.code!==50403)throw n}this.conversation=r,this.conversationSid=e,this.setupConversationListeners(r),this.conversationStarted=!0,this.conversationStatus=qr.ConversationStatus.ACTIVE,this._emitter.emit("conversationJoined",{conversationSid:e,timestamp:new Date})}catch(r){throw console.error("Failed to join conversation:",r),this.handleError("Failed to join conversation",r),r}}async initializeConversation(e){return this.createConversation(e)}setupConversationListeners(e){const r=(n,i)=>{let a;const s=o=>{try{const u=o.replace(/_([0-9A-Fa-f]{2})/g,"%$1");return decodeURIComponent(u)}catch(u){return console.warn("Could not decode Twilio identity:",u),o}};return n&&n.attributes&&(a=n.attributes.public_identity||n.attributes.full_name||n.attributes.friendlyName,a&&(a=s(a))),!a&&i&&(a=s(i)),a};e.on("messageAdded",async n=>{console.log("Message added");let i;try{const s=await e.getParticipantByIdentity(n.author);i=r(s,n.author)}catch(s){console.warn("Could not fetch participant info for friendly name:",s),i=r(null,n.author)}const a={index:n.index,sid:n.sid,body:n.body,author:n.author,authorFriendlyName:i,participantSid:n.participantSid,timestamp:n.dateCreated,attributes:n.attributes,media:n.attachedMedia};this._emitter.emit("message",a),n.author!==this.identity&&await this.acknowledgeMessage(n.index.toString())}),e.on("typingStarted",n=>{console.log("Typing started");const i={identity:n.identity,participantSid:n.sid,isTyping:!0};this._emitter.emit("agentTyping",i)}),e.on("typingEnded",n=>{console.log("Typing ended");const i={identity:n.identity,participantSid:n.sid,isTyping:!1};this._emitter.emit("typingEnded",i)}),e.on("participantJoined",n=>{console.log("Participant joined");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,attributes:n.attributes,timestamp:new Date};this._emitter.emit("agentJoined",a)}),e.on("participantLeft",n=>{console.log("Participant left");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,timestamp:new Date};this._emitter.emit("agentLeftConversation",a)}),e.on("participantUpdated",n=>{console.log("Participant updated"),this._emitter.emit("participantUpdated",n)}),e.on("updated",n=>{console.log("Conversation updated"),this._emitter.emit("conversationUpdated",n)})}async sendMessage(e,r){try{if(!this.conversation||!this.conversationStarted)throw new Error("Conversation not started");let n,i;if(typeof e=="string"?(n=e,i=r):(n=e.body,i=e.attributes),this.connectionState!==qr.ConnectionState.CONNECTED)return new Promise((s,o)=>{this.messageQueue.push({content:n,attributes:i,resolve:s,reject:o})});const a=await this.conversation.sendMessage(n,i);return this._emitter.emit("messageSent",{content:n,attributes:i,index:a,timestamp:new Date}),await Promise.resolve()}catch(n){throw console.error("Failed to send message:",n),this.handleError("Message sending failed",n),n}}async sendTyping(){try{if(!this.conversation)throw new Error("Conversation not started");this.typingTimeout&&clearTimeout(this.typingTimeout),await this.conversation.typing(),this.typingTimeout=setTimeout(()=>{this.typingTimeout=void 0},3e3)}catch(e){console.error("Failed to send typing indicator:",e)}}async acknowledgeMessage(e){try{if(!this.conversation)throw new Error("Conversation not started");const r=parseInt(e,10);if(isNaN(r)){console.warn("Invalid message ID format:",e);return}await this.conversation.updateLastReadMessageIndex(r),this._emitter.emit("messageAcknowledged",{messageId:e,timestamp:new Date})}catch(r){console.error("Failed to acknowledge message:",r)}}async processMessageQueue(){for(;this.messageQueue.length>0;){const e=this.messageQueue.shift();if(e)try{await this.sendMessage(e.content,e.attributes),e.resolve()}catch(r){e.reject(r)}}}async terminateConversation(){try{if(!this.conversation)throw new Error("Conversation not started");await this.conversation.leave(),this._emitter.emit("conversationTerminated",{conversationSid:this.conversationSid,timestamp:new Date}),this.conversation=null,this.conversationSid=null,this.conversationStarted=!1,this.conversationStatus=qr.ConversationStatus.CLOSED}catch(e){throw console.error("Failed to terminate conversation:",e),this.handleError("Conversation termination failed",e),e}}async connect(){if(!this.client)throw new Error("Client not initialized");if(!this.conversationSid)throw new Error("Conversation not started")}async reconnectClient(){try{if(!this.config)throw new Error("Configuration not available");await this.initialize(this.config),await this.processMessageQueue()}catch(e){throw console.error("Failed to reconnect client:",e),e}}async disconnect(){this.client&&(this.client=null),this.connectionState=qr.ConnectionState.DISCONNECTED}async reconnect(){await this.disconnect(),this.config&&await this.initialize(this.config)}destroy(){this.tokenRefreshTimeout&&(clearTimeout(this.tokenRefreshTimeout),this.tokenRefreshTimeout=void 0),this.typingTimeout&&(clearTimeout(this.typingTimeout),this.typingTimeout=void 0),this.client&&(this.client.shutdown(),this.client=null),this.conversation=null,this.conversationSid=null,this.accessToken=null,this.identity=null,this.conversationStarted=!1,this.connectionState=qr.ConnectionState.DISCONNECTED,this.conversationStatus=qr.ConversationStatus.CLOSED,this.messageQueue=[],this._emitter.all.clear()}handleError(e,r){const n={message:e,code:r==null?void 0:r.code,status:r==null?void 0:r.status,details:r,timestamp:new Date};this._emitter.emit("error",n)}get token(){return this.accessToken}get userIdentity(){return this.identity}get currentConversationSid(){return this.conversationSid}getConnectionStatus(){return this.connectionState}getConversationState(){return this.conversationStatus}isConnected(){return this.connectionState===qr.ConnectionState.CONNECTED}getClient(){return this.client}getConversation(){return this.conversation}getState(){return{system:"twilio",conversationSid:this.conversationSid,identity:this.identity,connectionState:this.connectionState,conversationStatus:this.conversationStatus,conversationStarted:this.conversationStarted}}}const BL=Qr.create({baseURL:"https://www.myshowing.com"});function go(t){return`any-${t||"main"}-chatSession`}async function zL({id:t,params:e,chatWindow:r,html:n}){const{threadId:i}=r.chatManager;r=r;const a=async()=>{var Oe;const{firstName:d,lastName:f,phone:m,email:b,propertyId:A}=e,N=(Oe=r.options)==null?void 0:Oe.params,z=A||e.propertyId||(N==null?void 0:N.propertyId),X=e.managementId||(N==null?void 0:N.managementId),Ee=e.conciergeWidgetSource||(N==null?void 0:N.conciergeWidgetSource);if(!X||!z)throw new Error("accountId (managementId) and propertyId are required to create a guest card");const Ie={firstName:d,lastName:f,phoneNumber:m,email:b,threadId:i,conciergeWidgetSource:Ee},Be=await BL.post(`/${X}/${z}/guestcards/create`,Ie);e.guestCardId=Be.data.guestCardId},s=async()=>{r.removeMessage("transferMessageId"),r.removeMessage("guestCardFormId"),await r.sendFunctionCallResponse(t,{transfer:"Declined"},!0),r.setInputDisabled(!1)},o=async()=>{r.removeMessage("transferMessageId"),e.guestCardId?(u(),await l()):await c()},u=()=>{r.addMessage({id:"waitMessageId",role:"system",content:"Please wait while we connect you to a live agent"}),r.setInputDisabled(!0)},l=async()=>{var Ee,Ie;await r.chatManager.endChat("Transferred to live agent",!1);const{summary:d,subject:f,guestCardId:m,firstName:b,lastName:A,phone:N,email:z}=e,X=e.propertyName||((Ie=(Ee=r.options)==null?void 0:Ee.params)==null?void 0:Ie.propertyName);{const Be="https://five9.ah.inhabit.work",Oe=z||`customer-${Date.now()}`,ze=await fetch(`${Be}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:Oe})});if(!ze.ok)throw new Error(`Failed to get Twilio token: ${ze.statusText}`);const{token:V}=await ze.json(),xe=new Gf;await xe.initialize({accessToken:V,identity:Oe,tokenRefreshUrl:`${Be}/api/twilio/token-refresh`,autoReconnect:!0,logLevel:"info"}),await xe.createConversation({friendlyName:`${b} ${A} - ${f||"Customer Chat"}`,uniqueName:`chat-${Date.now()}-${m}`,attributes:{pre_engagement_data:{gc_id:m,friendlyName:b,last_name:A,phone:N,email:z,question:f,aiSummary:d,propertyName:X}}});const _e="FW490d224a211a6f2bea01c23aaa492122";try{const{conversationSid:se}=xe.getState(),Te=await fetch(`${Be}/twilio-conversations/${se}/attach-studio-flow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowSid:_e,filters:["onMessageAdded"]})});if(Te.ok){const re=await Te.json()}else console.warn("[TransferToLiveAgent] Failed to attach Studio Flow webhook:",await Te.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching Studio Flow webhook:",se)}try{const{conversationSid:se}=xe.getState(),Te=`${Be}/twilio-conversations/${se}/webhooks`.replace(/^http:/,"https:"),re=await fetch(`${Be}/twilio-conversations/${se}/attach-webhook`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({webhookUrl:Te,method:"POST",filters:["onMessageAdded","onMessageUpdated","onParticipantAdded","onParticipantRemoved","onConversationUpdated"]})});if(re.ok){const oe=await re.json()}else console.warn("[TransferToLiveAgent] Failed to attach backend webhook:",await re.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching backend webhook:",se)}try{await xe.sendMessage({body:"Customer has been transferred to live agent",attributes:{gc_id:m,friendlyName:b,last_name:A,email:z,phone:N,question:f||"General inquiry",aiSummary:d||"No prior conversation",propertyName:X,messageType:"transfer_trigger"}})}catch(se){console.error("[TransferToLiveAgent] Error sending Studio Flow trigger message:",se)}localStorage.setItem(go(r.cleanOptions.config.historyKey),JSON.stringify(xe.getState())),r.setInputDisabled(!1),tk(r,xe)}},c=async()=>{const d=async f=>{e={...e,...f.detail},r.removeMessage("guestCardFormId"),u();try{await a()}catch(m){console.log(m)}await l()};r.addMessage({id:"guestCardFormId",role:"system",contentHtmlTemplate:n`
782
+ `+a):n.stack=a}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=vo(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:a}=r;n!==void 0&&bm.assertOptions(n,{silentJSONParsing:hs.transitional(hs.boolean),forcedJSONParsing:hs.transitional(hs.boolean),clarifyTimeoutError:hs.transitional(hs.boolean)},!1),i!=null&&(De.isFunction(i)?r.paramsSerializer={serialize:i}:bm.assertOptions(i,{encode:hs.function,serialize:hs.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=a&&De.merge(a.common,a[r.method]);a&&De.forEach(["delete","get","head","post","put","patch","common"],b=>{delete a[b]}),r.headers=jn.concat(s,a);const o=[];let u=!0;this.interceptors.request.forEach(function(A){typeof A.runWhen=="function"&&A.runWhen(r)===!1||(u=u&&A.synchronous,o.unshift(A.fulfilled,A.rejected))});const l=[];this.interceptors.response.forEach(function(A){l.push(A.fulfilled,A.rejected)});let c,d=0,f;if(!u){const b=[Y1.bind(this),void 0];for(b.unshift.apply(b,o),b.push.apply(b,l),f=b.length,c=Promise.resolve(r);d<f;)c=c.then(b[d++],b[d++]);return c}f=o.length;let m=r;for(d=0;d<f;){const b=o[d++],A=o[d++];try{m=b(m)}catch(N){A.call(this,N);break}}try{c=Y1.call(this,m)}catch(b){return Promise.reject(b)}for(d=0,f=l.length;d<f;)c=c.then(l[d++],l[d++]);return c}getUri(e){e=vo(this.defaults,e);const r=z1(e.baseURL,e.url);return N1(r,e.params,e.paramsSerializer)}}De.forEach(["delete","get","head","options"],function(e){mo.prototype[e]=function(r,n){return this.request(vo(n||{},{method:e,url:r,data:(n||{}).data}))}}),De.forEach(["post","put","patch"],function(e){function r(n){return function(a,s,o){return this.request(vo(o||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:a,data:s}))}}mo.prototype[e]=r(),mo.prototype[e+"Form"]=r(!0)});class wm{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});const n=this;this.promise.then(i=>{if(!n._listeners)return;let a=n._listeners.length;for(;a-- >0;)n._listeners[a](i);n._listeners=null}),this.promise.then=i=>{let a;const s=new Promise(o=>{n.subscribe(o),a=o}).then(i);return s.cancel=function(){n.unsubscribe(a)},s},e(function(a,s,o){n.reason||(n.reason=new ku(a,s,o),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}static source(){let e;return{token:new wm(function(i){e=i}),cancel:e}}}function jL(t){return function(r){return t.apply(null,r)}}function UL(t){return De.isObject(t)&&t.isAxiosError===!0}const _m={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(_m).forEach(([t,e])=>{_m[e]=t});function ek(t){const e=new mo(t),r=b1(mo.prototype.request,e);return De.extend(r,mo.prototype,e,{allOwnKeys:!0}),De.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return ek(vo(t,i))},r}const Qr=ek(Rc);Qr.Axios=mo,Qr.CanceledError=ku,Qr.CancelToken=wm,Qr.isCancel=F1,Qr.VERSION=Q1,Qr.toFormData=Hf,Qr.AxiosError=ir,Qr.Cancel=Qr.CanceledError,Qr.all=function(e){return Promise.all(e)},Qr.spread=jL,Qr.isAxiosError=UL,Qr.mergeConfig=vo,Qr.AxiosHeaders=jn,Qr.formToJSON=t=>j1(De.isHTMLForm(t)?new FormData(t):t),Qr.getAdapter=J1.getAdapter,Qr.HttpStatusCode=_m,Qr.default=Qr;function tk(t,e){let r=!1;e.on("conversationCreated",()=>{t.setInputDisabled(!1),localStorage.setItem(go(t.cleanOptions.config.historyKey),JSON.stringify(e.getState()))}),e.on("agentJoined",o=>{t.addMessage({role:"system",content:"Agent has joined the chat"})}),e.on("agentLeftConversation",o=>{const u=e.getState().identity;if(o.identity===u){console.log("[transferToTwilio] Customer left (not showing message to self)");return}t.addMessage({role:"system",content:"Agent has left the chat"})}),e.on("agentTyping",o=>{o.identity!==e.getState().identity&&t.setTypingIndicatorVisible(!0)}),e.on("typingEnded",()=>{t.setTypingIndicatorVisible(!1)}),e.on("message",o=>{console.log("[transferToTwilio] Message event received");const u=o.author||o.identity||"unknown",l=o.body||o.message||"",c=e.getState().identity;if(u===c||u==="customer"||u==="user"){console.log("[transferToTwilio] Skipping own message from:",u);return}t.setTypingIndicatorVisible(!1),t.addMessage({role:"assistant",name:"Agent",content:l})}),e.on("conversationClosed",()=>{t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(go(t.cleanOptions.config.historyKey))}),e.on("conversationLeft",o=>{if(console.log("[transferToTwilio] Conversation left event"),r){console.log("[transferToTwilio] User-initiated reset, skipping end message"),r=!1;return}t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(go(t.cleanOptions.config.historyKey))}),e.on("error",o=>{console.error("[Twilio Error]:",o),t.addMessage({role:"system",content:`Error: ${o.message||"An error occurred"}`})}),e.on("connected",()=>{console.log("[Twilio] Connected to backend")}),e.on("disconnected",()=>{console.log("[Twilio] Disconnected from backend")}),e.connect();const n=async o=>{o.preventDefault(),t.addMessage({role:"user",content:o.detail.message}),await e.sendMessage({body:o.detail.message,author:"customer",triggerStudioFlow:!1})},i=async()=>{e.destroy(),t.removeEventListener("iai-chat-send-user-message",n),t.removeEventListener("iai-chat-reset",s),t.removeEventListener("iai-chat-destroy",i)},a=t.cleanOptions.config.disclaimerMessage,s=async()=>{r=!0,await e.terminateConversation(),await i(),localStorage.removeItem(go(t.cleanOptions.config.historyKey)),t.cleanOptions.config.disclaimerMessage=a};t.cleanOptions.config.disclaimerMessage="",t.addEventListener("iai-chat-send-user-message",n),t.addEventListener("iai-chat-reset",s),t.addEventListener("iai-chat-destroy",i)}function FL(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}var km;(t=>{(e=>{e.TEXT="TEXT"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.GENERIC="GENERIC",e.SMS="SMS",e.RCS="RCS",e.FACEBOOK="FACEBOOK",e.TWITTER="TWITTER",e.WHATSAPP="WHATSAPP",e.WECHAT="WECHAT",e.QQMOBILE="QQMOBILE",e.APPLE_BUSINESS_CHAT="APPLE_BUSINESS_CHAT",e.SKYPE="SKYPE",e.SNAPCHAT="SNAPCHAT",e.VIBER="VIBER",e.LINE="LINE",e.TELEGRAM="TELEGRAM",e.KAKAO="KAKAO"})(t.ContentType||(t.ContentType={})),(e=>{e.SYSTEM="SYSTEM",e.USER="USER"})(t.ConversationEventOrigin||(t.ConversationEventOrigin={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.TERMINATED="TERMINATED"})(t.ConversationStatus||(t.ConversationStatus={}))})(km||(km={})),km.AcknowledgeType;var qr;(t=>{(e=>{e.TEXT="TEXT",e.MEDIA="MEDIA"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.CONNECTING="connecting",e.CONNECTED="connected",e.DISCONNECTING="disconnecting",e.DISCONNECTED="disconnected",e.DENIED="denied",e.ERROR="error"})(t.ConnectionState||(t.ConnectionState={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE",e.CLOSED="CLOSED"})(t.ConversationStatus||(t.ConversationStatus={})),(e=>{e.CHAT="chat",e.SMS="sms",e.WHATSAPP="whatsapp"})(t.ParticipantType||(t.ParticipantType={})),(e=>{e.QUEUED="queued",e.SENT="sent",e.DELIVERED="delivered",e.READ="read",e.FAILED="failed",e.UNDELIVERED="undelivered"})(t.DeliveryStatus||(t.DeliveryStatus={}))})(qr||(qr={}));class Gf{constructor(){this._emitter=FL(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),this.client=null,this.conversation=null,this.accessToken=null,this.identity=null,this.conversationSid=null,this.conversationStarted=!1,this.connectionState=qr.ConnectionState.DISCONNECTED,this.conversationStatus=qr.ConversationStatus.PENDING,this.config=null,this.messageQueue=[]}serialize(){return JSON.stringify({accessToken:this.accessToken,identity:this.identity,conversationSid:this.conversationSid,conversationStarted:this.conversationStarted,connectionState:this.connectionState,conversationStatus:this.conversationStatus})}static deserialize(e){const r=JSON.parse(e),n=new Gf;return r.accessToken&&r.identity&&(n.accessToken=r.accessToken,n.identity=r.identity),r.conversationSid&&(n.conversationSid=r.conversationSid),n.conversationStarted=r.conversationStarted||!1,n.connectionState=r.connectionState||qr.ConnectionState.DISCONNECTED,n.conversationStatus=r.conversationStatus||qr.ConversationStatus.PENDING,n}setupClientListeners(){this.client&&(this.client.on("connectionStateChanged",e=>{const r=this.connectionState,n=this.mapConnectionState(e);this.connectionState=n,this._emitter.emit("connectionStateChanged",{previous:r,current:n}),n===qr.ConnectionState.CONNECTED&&r!==qr.ConnectionState.CONNECTED&&this.processMessageQueue()}),this.client.on("tokenAboutToExpire",async()=>{console.log("Token about to expire, refreshing..."),await this.refreshToken()}),this.client.on("tokenExpired",async()=>{console.warn("Token expired, refreshing..."),await this.refreshToken()}),this.client.on("conversationJoined",e=>{console.log("Conversation joined"),this._emitter.emit("conversationJoined",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("conversationLeft",e=>{console.log("Conversation left"),this._emitter.emit("conversationLeft",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("connectionError",e=>{console.error("Twilio connection error:",e),this.handleError("Connection error",e)}))}async initialize(e){try{this.config=e,this.accessToken=e.accessToken,this.identity=e.identity,this.tokenRefreshUrl=e.tokenRefreshUrl;const{Client:r}=await Promise.resolve().then(()=>Bie);this.client=new r(e.accessToken,{logLevel:e.logLevel||"error"}),this.setupClientListeners(),await this.waitForClientReady(),e.conversationSid&&(this.conversationSid=e.conversationSid,await this.joinConversation(e.conversationSid))}catch(r){throw console.error("Failed to initialize Twilio Manager:",r),this.handleError("Initialization failed",r),r}}async waitForClientReady(){return new Promise((e,r)=>{if(!this.client){r(new Error("Client not initialized"));return}const n=setTimeout(()=>{r(new Error("Client initialization timeout"))},3e4);this.client.on("initialized",()=>{clearTimeout(n),e()}),this.client.on("initFailed",i=>{clearTimeout(n),r(i)})})}mapConnectionState(e){switch(e){case"connecting":return qr.ConnectionState.CONNECTING;case"connected":return qr.ConnectionState.CONNECTED;case"disconnecting":return qr.ConnectionState.DISCONNECTING;case"disconnected":return qr.ConnectionState.DISCONNECTED;case"denied":return qr.ConnectionState.DENIED;case"error":return qr.ConnectionState.ERROR;default:return qr.ConnectionState.DISCONNECTED}}async refreshToken(){try{if(!this.tokenRefreshUrl)throw new Error("Token refresh URL not configured");const e=await fetch(this.tokenRefreshUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:this.identity})});if(!e.ok)throw new Error(`Token refresh failed: ${e.statusText}`);const r=await e.json();this.accessToken=r.token,this.client&&(await this.client.updateToken(r.token),console.log("Token refreshed successfully"),this._emitter.emit("tokenRefreshed",{timestamp:new Date}))}catch(e){throw console.error("Token refresh failed:",e),this.handleError("Token refresh failed",e),e}}async createConversation(e){try{if(!this.client)throw new Error("Client not initialized");const r=await this.client.createConversation({friendlyName:e.friendlyName,uniqueName:e.uniqueName,attributes:e.attributes});this.conversation=r,this.conversationSid=r.sid,await r.join(),this.setupConversationListeners(r);const n={sid:r.sid,friendlyName:r.friendlyName,uniqueName:r.uniqueName,attributes:r.attributes,dateCreated:r.dateCreated,dateUpdated:r.dateUpdated,state:r.state,status:qr.ConversationStatus.ACTIVE};return this.conversationStarted=!0,this.conversationStatus=qr.ConversationStatus.ACTIVE,this._emitter.emit("conversationCreated",n),n}catch(r){throw console.error("Failed to create conversation:",r),this.handleError("Conversation creation failed",r),r}}async joinConversation(e){try{if(!this.client)throw new Error("Client not initialized");console.log("Joining conversation:",e);const r=await this.client.getConversationBySid(e);try{await r.join()}catch(n){if(n.code!==50403)throw n}this.conversation=r,this.conversationSid=e,this.setupConversationListeners(r),this.conversationStarted=!0,this.conversationStatus=qr.ConversationStatus.ACTIVE,this._emitter.emit("conversationJoined",{conversationSid:e,timestamp:new Date})}catch(r){throw console.error("Failed to join conversation:",r),this.handleError("Failed to join conversation",r),r}}async initializeConversation(e){return this.createConversation(e)}setupConversationListeners(e){const r=(n,i)=>{let a;const s=o=>{try{const u=o.replace(/_([0-9A-Fa-f]{2})/g,"%$1");return decodeURIComponent(u)}catch(u){return console.warn("Could not decode Twilio identity:",u),o}};return n&&n.attributes&&(a=n.attributes.public_identity||n.attributes.full_name||n.attributes.friendlyName,a&&(a=s(a))),!a&&i&&(a=s(i)),a};e.on("messageAdded",async n=>{console.log("Message added");let i;try{const s=await e.getParticipantByIdentity(n.author);i=r(s,n.author)}catch(s){console.warn("Could not fetch participant info for friendly name:",s),i=r(null,n.author)}const a={index:n.index,sid:n.sid,body:n.body,author:n.author,authorFriendlyName:i,participantSid:n.participantSid,timestamp:n.dateCreated,attributes:n.attributes,media:n.attachedMedia};this._emitter.emit("message",a),n.author!==this.identity&&await this.acknowledgeMessage(n.index.toString())}),e.on("typingStarted",n=>{console.log("Typing started");const i={identity:n.identity,participantSid:n.sid,isTyping:!0};this._emitter.emit("agentTyping",i)}),e.on("typingEnded",n=>{console.log("Typing ended");const i={identity:n.identity,participantSid:n.sid,isTyping:!1};this._emitter.emit("typingEnded",i)}),e.on("participantJoined",n=>{console.log("Participant joined");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,attributes:n.attributes,timestamp:new Date};this._emitter.emit("agentJoined",a)}),e.on("participantLeft",n=>{console.log("Participant left");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,timestamp:new Date};this._emitter.emit("agentLeftConversation",a)}),e.on("participantUpdated",n=>{console.log("Participant updated"),this._emitter.emit("participantUpdated",n)}),e.on("updated",n=>{console.log("Conversation updated"),this._emitter.emit("conversationUpdated",n)})}async sendMessage(e,r){try{if(!this.conversation||!this.conversationStarted)throw new Error("Conversation not started");let n,i;if(typeof e=="string"?(n=e,i=r):(n=e.body,i=e.attributes),this.connectionState!==qr.ConnectionState.CONNECTED)return new Promise((s,o)=>{this.messageQueue.push({content:n,attributes:i,resolve:s,reject:o})});const a=await this.conversation.sendMessage(n,i);return this._emitter.emit("messageSent",{content:n,attributes:i,index:a,timestamp:new Date}),await Promise.resolve()}catch(n){throw console.error("Failed to send message:",n),this.handleError("Message sending failed",n),n}}async sendTyping(){try{if(!this.conversation)throw new Error("Conversation not started");this.typingTimeout&&clearTimeout(this.typingTimeout),await this.conversation.typing(),this.typingTimeout=setTimeout(()=>{this.typingTimeout=void 0},3e3)}catch(e){console.error("Failed to send typing indicator:",e)}}async acknowledgeMessage(e){try{if(!this.conversation)throw new Error("Conversation not started");const r=parseInt(e,10);if(isNaN(r)){console.warn("Invalid message ID format:",e);return}await this.conversation.updateLastReadMessageIndex(r),this._emitter.emit("messageAcknowledged",{messageId:e,timestamp:new Date})}catch(r){console.error("Failed to acknowledge message:",r)}}async processMessageQueue(){for(;this.messageQueue.length>0;){const e=this.messageQueue.shift();if(e)try{await this.sendMessage(e.content,e.attributes),e.resolve()}catch(r){e.reject(r)}}}async terminateConversation(){try{if(!this.conversation)throw new Error("Conversation not started");await this.conversation.leave(),this._emitter.emit("conversationTerminated",{conversationSid:this.conversationSid,timestamp:new Date}),this.conversation=null,this.conversationSid=null,this.conversationStarted=!1,this.conversationStatus=qr.ConversationStatus.CLOSED}catch(e){throw console.error("Failed to terminate conversation:",e),this.handleError("Conversation termination failed",e),e}}async connect(){if(!this.client)throw new Error("Client not initialized");if(!this.conversationSid)throw new Error("Conversation not started")}async reconnectClient(){try{if(!this.config)throw new Error("Configuration not available");await this.initialize(this.config),await this.processMessageQueue()}catch(e){throw console.error("Failed to reconnect client:",e),e}}async disconnect(){this.client&&(this.client=null),this.connectionState=qr.ConnectionState.DISCONNECTED}async reconnect(){await this.disconnect(),this.config&&await this.initialize(this.config)}destroy(){this.tokenRefreshTimeout&&(clearTimeout(this.tokenRefreshTimeout),this.tokenRefreshTimeout=void 0),this.typingTimeout&&(clearTimeout(this.typingTimeout),this.typingTimeout=void 0),this.client&&(this.client.shutdown(),this.client=null),this.conversation=null,this.conversationSid=null,this.accessToken=null,this.identity=null,this.conversationStarted=!1,this.connectionState=qr.ConnectionState.DISCONNECTED,this.conversationStatus=qr.ConversationStatus.CLOSED,this.messageQueue=[],this._emitter.all.clear()}handleError(e,r){const n={message:e,code:r==null?void 0:r.code,status:r==null?void 0:r.status,details:r,timestamp:new Date};this._emitter.emit("error",n)}get token(){return this.accessToken}get userIdentity(){return this.identity}get currentConversationSid(){return this.conversationSid}getConnectionStatus(){return this.connectionState}getConversationState(){return this.conversationStatus}isConnected(){return this.connectionState===qr.ConnectionState.CONNECTED}getClient(){return this.client}getConversation(){return this.conversation}getState(){return{system:"twilio",conversationSid:this.conversationSid,identity:this.identity,connectionState:this.connectionState,conversationStatus:this.conversationStatus,conversationStarted:this.conversationStarted}}}const BL=Qr.create({baseURL:"https://www.myshowing.com"});function go(t){return`any-${t||"main"}-chatSession`}async function zL({id:t,params:e,chatWindow:r,html:n}){const{threadId:i}=r.chatManager;r=r;const a=async()=>{var Oe;const{firstName:d,lastName:f,phoneNumber:m,email:b,propertyId:A}=e,N=(Oe=r.options)==null?void 0:Oe.params,z=A||e.propertyId||(N==null?void 0:N.propertyId),X=e.managementId||(N==null?void 0:N.managementId),Ee=e.sourceId||(N==null?void 0:N.sourceId);if(!X||!z)throw new Error("accountId (managementId) and propertyId are required to create a guest card");const Ie={firstName:d,lastName:f,phoneNumber:m,email:b,threadId:i,sourceId:Ee},Fe=await BL.post(`/${X}/${z}/guestcards/create`,Ie);e.guestCardId=Fe.data.guestCardId},s=async()=>{r.removeMessage("transferMessageId"),r.removeMessage("guestCardFormId"),await r.sendFunctionCallResponse(t,{transfer:"Declined"},!0),r.setInputDisabled(!1)},o=async()=>{r.removeMessage("transferMessageId"),e.guestCardId?(u(),await l()):await c()},u=()=>{r.addMessage({id:"waitMessageId",role:"system",content:"Please wait while we connect you to a live agent"}),r.setInputDisabled(!0)},l=async()=>{var Ee,Ie;try{await r.sendFunctionCallResponse(t,{transfer:"Accepted",guestCardId:e.guestCardId,firstName:e.firstName,lastName:e.lastName,phoneNumber:e.phoneNumber,email:e.email},!0)}catch(Fe){console.error("Failed to send function response:",Fe)}await r.chatManager.endChat("Transferred to live agent",!1);const{summary:d,subject:f,guestCardId:m,firstName:b,lastName:A,phoneNumber:N,email:z}=e,X=e.propertyName||((Ie=(Ee=r.options)==null?void 0:Ee.params)==null?void 0:Ie.propertyName);{const Fe="https://five9.ah.inhabit.work",Oe=z||`customer-${Date.now()}`,ze=await fetch(`${Fe}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:Oe})});if(!ze.ok)throw new Error(`Failed to get Twilio token: ${ze.statusText}`);const{token:V}=await ze.json(),xe=new Gf;await xe.initialize({accessToken:V,identity:Oe,tokenRefreshUrl:`${Fe}/api/twilio/token-refresh`,autoReconnect:!0,logLevel:"info"}),await xe.createConversation({friendlyName:`${b} ${A} - ${f||"Customer Chat"}`,uniqueName:`chat-${Date.now()}-${m}`,attributes:{pre_engagement_data:{gc_id:m,friendlyName:b,last_name:A,phone:N,email:z,question:f,aiSummary:d,propertyName:X}}});const _e="FW490d224a211a6f2bea01c23aaa492122";try{const{conversationSid:se}=xe.getState(),Te=await fetch(`${Fe}/twilio-conversations/${se}/attach-studio-flow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowSid:_e,filters:["onMessageAdded"]})});if(Te.ok){const re=await Te.json()}else console.warn("[TransferToLiveAgent] Failed to attach Studio Flow webhook:",await Te.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching Studio Flow webhook:",se)}try{const{conversationSid:se}=xe.getState(),Te=`${Fe}/twilio-conversations/${se}/webhooks`.replace(/^http:/,"https:"),re=await fetch(`${Fe}/twilio-conversations/${se}/attach-webhook`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({webhookUrl:Te,method:"POST",filters:["onMessageAdded","onMessageUpdated","onParticipantAdded","onParticipantRemoved","onConversationUpdated"]})});if(re.ok){const oe=await re.json()}else console.warn("[TransferToLiveAgent] Failed to attach backend webhook:",await re.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching backend webhook:",se)}try{await xe.sendMessage({body:"Customer has been transferred to live agent",attributes:{gc_id:m,friendlyName:b,last_name:A,email:z,phone:N,question:f||"General inquiry",aiSummary:d||"No prior conversation",propertyName:X,messageType:"transfer_trigger"}})}catch(se){console.error("[TransferToLiveAgent] Error sending Studio Flow trigger message:",se)}localStorage.setItem(go(r.cleanOptions.config.historyKey),JSON.stringify(xe.getState())),r.setInputDisabled(!1),tk(r,xe)}},c=async()=>{const d=async f=>{e={...e,...f.detail,phoneNumber:f.detail.phone||f.detail.phoneNumber},r.removeMessage("guestCardFormId"),u();try{await a()}catch(m){console.log(m)}await l()};r.addMessage({id:"guestCardFormId",role:"system",contentHtmlTemplate:n`
783
783
  <any-contact-form
784
784
  .params=${e}
785
785
  @submit=${d}
@@ -790,10 +790,10 @@ Please report this to https://github.com/markedjs/marked.`,t){const n="<p>An err
790
790
  @transfer=${o}
791
791
  @cancel=${s}
792
792
  ></any-transfer-confirmation>
793
- `})}class HL{constructor(e,r){const n=xf.parse({assistantId:"657acbb4-d23e-487f-9090-4ac9a237b474",...e,config:{...e.config,styles:e.styles||{}}});n.handlers.functionCalls.transferToLiveAgent=zL,n.handlers.functionCalls.showScheduleTourWidget=w3(r.schedulerUrl),n.handlers.enhancedContent.unitList=g3,n.handlers.enhancedContent.photoViewer=m3,this.chatWidget=new v3(n);const i=localStorage.getItem(go(n.config.historyKey));if(i){const{chatWidget:a}=this;(async()=>{try{const s=JSON.parse(i),o="https://five9.ah.inhabit.work",u=s.identity||`customer-${Date.now()}`,l=await fetch(`${o}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:u})});if(!l.ok)throw new Error("Failed to get Twilio token for session restoration");const{token:c}=await l.json(),d=new Gf;await d.initialize({accessToken:c,identity:u,conversationSid:s.conversationSid,tokenRefreshUrl:`${o}/api/twilio/token-refresh`,autoReconnect:!0,logLevel:"info"}),tk(a.api.chatWindow,d)}catch(s){console.error("Failed to restore Twilio session:",s),localStorage.removeItem(go(n.config.historyKey))}})()}}destroy(){this.chatWidget.destroy()}}var rk={},Ic=function(t){return t&&t.Math===Math&&t},cr=Ic(typeof globalThis=="object"&&globalThis)||Ic(typeof window=="object"&&window)||Ic(typeof self=="object"&&self)||Ic(typeof ln=="object"&&ln)||Ic(typeof ln=="object"&&ln)||function(){return this}()||Function("return this")(),$a={},Vt=function(t){try{return!!t()}catch{return!0}},qL=Vt,Ar=!qL(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),VL=Vt,Ac=!VL(function(){var t=(function(){}).bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),WL=Ac,Kf=Function.prototype.call,Er=WL?Kf.bind(Kf):function(){return Kf.apply(Kf,arguments)},Oc={},nk={}.propertyIsEnumerable,ik=Object.getOwnPropertyDescriptor,ZL=ik&&!nk.call({1:2},1);Oc.f=ZL?function(e){var r=ik(this,e);return!!r&&r.enumerable}:nk;var yo=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},ak=Ac,sk=Function.prototype,Sm=sk.call,GL=ak&&sk.bind.bind(Sm,Sm),Kt=ak?GL:function(t){return function(){return Sm.apply(t,arguments)}},ok=Kt,KL=ok({}.toString),JL=ok("".slice),Yi=function(t){return JL(KL(t),8,-1)},YL=Kt,QL=Vt,XL=Yi,$m=Object,eD=YL("".split),Pc=QL(function(){return!$m("z").propertyIsEnumerable(0)})?function(t){return XL(t)==="String"?eD(t,""):$m(t)}:$m,xi=function(t){return t==null},tD=xi,rD=TypeError,Ii=function(t){if(tD(t))throw new rD("Can't call method on "+t);return t},nD=Pc,iD=Ii,Kn=function(t){return nD(iD(t))},Tm=typeof document=="object"&&document.all,Cr=typeof Tm>"u"&&Tm!==void 0?function(t){return typeof t=="function"||t===Tm}:function(t){return typeof t=="function"},aD=Cr,Lr=function(t){return typeof t=="object"?t!==null:aD(t)},Em=cr,sD=Cr,oD=function(t){return sD(t)?t:void 0},Ai=function(t,e){return arguments.length<2?oD(Em[t]):Em[t]&&Em[t][e]},uD=Kt,Ta=uD({}.isPrototypeOf),bo=typeof navigator<"u"&&String(navigator.userAgent)||"",uk=cr,Cm=bo,lk=uk.process,ck=uk.Deno,dk=lk&&lk.versions||ck&&ck.version,fk=dk&&dk.v8,Oi,Jf;fk&&(Oi=fk.split("."),Jf=Oi[0]>0&&Oi[0]<4?1:+(Oi[0]+Oi[1])),!Jf&&Cm&&(Oi=Cm.match(/Edge\/(\d+)/),(!Oi||Oi[1]>=74)&&(Oi=Cm.match(/Chrome\/(\d+)/),Oi&&(Jf=+Oi[1])));var Su=Jf,hk=Su,lD=Vt,cD=cr,dD=cD.String,$u=!!Object.getOwnPropertySymbols&&!lD(function(){var t=Symbol("symbol detection");return!dD(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&hk&&hk<41}),fD=$u,pk=fD&&!Symbol.sham&&typeof Symbol.iterator=="symbol",hD=Ai,pD=Cr,vD=Ta,mD=pk,gD=Object,Tu=mD?function(t){return typeof t=="symbol"}:function(t){var e=hD("Symbol");return pD(e)&&vD(e.prototype,gD(t))},yD=String,wo=function(t){try{return yD(t)}catch{return"Object"}},bD=Cr,wD=wo,_D=TypeError,si=function(t){if(bD(t))return t;throw new _D(wD(t)+" is not a function")},kD=si,SD=xi,_o=function(t,e){var r=t[e];return SD(r)?void 0:kD(r)},Rm=Er,xm=Cr,Im=Lr,$D=TypeError,TD=function(t,e){var r,n;if(e==="string"&&xm(r=t.toString)&&!Im(n=Rm(r,t))||xm(r=t.valueOf)&&!Im(n=Rm(r,t))||e!=="string"&&xm(r=t.toString)&&!Im(n=Rm(r,t)))return n;throw new $D("Can't convert object to primitive value")},vk={exports:{}},mk=!1,gk=cr,ED=Object.defineProperty,Am=function(t,e){try{ED(gk,t,{value:e,configurable:!0,writable:!0})}catch{gk[t]=e}return e},CD=cr,RD=Am,yk="__core-js_shared__",bk=vk.exports=CD[yk]||RD(yk,{});(bk.versions||(bk.versions=[])).push({version:"3.37.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Om=vk.exports,wk=Om,Eu=function(t,e){return wk[t]||(wk[t]=e||{})},xD=Ii,ID=Object,yn=function(t){return ID(xD(t))},AD=Kt,OD=yn,PD=AD({}.hasOwnProperty),Vr=Object.hasOwn||function(e,r){return PD(OD(e),r)},MD=Kt,ND=0,LD=Math.random(),DD=MD(1 .toString),Mc=function(t){return"Symbol("+(t===void 0?"":t)+")_"+DD(++ND+LD,36)},jD=cr,UD=Eu,_k=Vr,FD=Mc,BD=$u,zD=pk,Cu=jD.Symbol,Pm=UD("wks"),HD=zD?Cu.for||Cu:Cu&&Cu.withoutSetter||FD,Rr=function(t){return _k(Pm,t)||(Pm[t]=BD&&_k(Cu,t)?Cu[t]:HD("Symbol."+t)),Pm[t]},qD=Er,kk=Lr,Sk=Tu,VD=_o,WD=TD,ZD=Rr,GD=TypeError,KD=ZD("toPrimitive"),Mm=function(t,e){if(!kk(t)||Sk(t))return t;var r=VD(t,KD),n;if(r){if(e===void 0&&(e="default"),n=qD(r,t,e),!kk(n)||Sk(n))return n;throw new GD("Can't convert object to primitive value")}return e===void 0&&(e="number"),WD(t,e)},JD=Mm,YD=Tu,Yf=function(t){var e=JD(t,"string");return YD(e)?e:e+""},QD=cr,$k=Lr,Nm=QD.document,XD=$k(Nm)&&$k(Nm.createElement),Qf=function(t){return XD?Nm.createElement(t):{}},ej=Ar,tj=Vt,rj=Qf,Tk=!ej&&!tj(function(){return Object.defineProperty(rj("div"),"a",{get:function(){return 7}}).a!==7}),nj=Ar,ij=Er,aj=Oc,sj=yo,oj=Kn,uj=Yf,lj=Vr,cj=Tk,Ek=Object.getOwnPropertyDescriptor;$a.f=nj?Ek:function(e,r){if(e=oj(e),r=uj(r),cj)try{return Ek(e,r)}catch{}if(lj(e,r))return sj(!ij(aj.f,e,r),e[r])};var Cn={},dj=Ar,fj=Vt,Ck=dj&&fj(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),hj=Lr,pj=String,vj=TypeError,Gr=function(t){if(hj(t))return t;throw new vj(pj(t)+" is not an object")},mj=Ar,gj=Tk,yj=Ck,Xf=Gr,Rk=Yf,bj=TypeError,Lm=Object.defineProperty,wj=Object.getOwnPropertyDescriptor,Dm="enumerable",jm="configurable",Um="writable";Cn.f=mj?yj?function(e,r,n){if(Xf(e),r=Rk(r),Xf(n),typeof e=="function"&&r==="prototype"&&"value"in n&&Um in n&&!n[Um]){var i=wj(e,r);i&&i[Um]&&(e[r]=n.value,n={configurable:jm in n?n[jm]:i[jm],enumerable:Dm in n?n[Dm]:i[Dm],writable:!1})}return Lm(e,r,n)}:Lm:function(e,r,n){if(Xf(e),r=Rk(r),Xf(n),gj)try{return Lm(e,r,n)}catch{}if("get"in n||"set"in n)throw new bj("Accessors not supported");return"value"in n&&(e[r]=n.value),e};var _j=Ar,kj=Cn,Sj=yo,Ea=_j?function(t,e,r){return kj.f(t,e,Sj(1,r))}:function(t,e,r){return t[e]=r,t},xk={exports:{}},Fm=Ar,$j=Vr,Ik=Function.prototype,Tj=Fm&&Object.getOwnPropertyDescriptor,Bm=$j(Ik,"name"),Ej=Bm&&(function(){}).name==="something",Cj=Bm&&(!Fm||Fm&&Tj(Ik,"name").configurable),Nc={EXISTS:Bm,PROPER:Ej,CONFIGURABLE:Cj},Rj=Kt,xj=Cr,zm=Om,Ij=Rj(Function.toString);xj(zm.inspectSource)||(zm.inspectSource=function(t){return Ij(t)});var Hm=zm.inspectSource,Aj=cr,Oj=Cr,Ak=Aj.WeakMap,Pj=Oj(Ak)&&/native code/.test(String(Ak)),Mj=Eu,Nj=Mc,Ok=Mj("keys"),eh=function(t){return Ok[t]||(Ok[t]=Nj(t))},Lc={},Lj=Pj,Pk=cr,Dj=Lr,jj=Ea,qm=Vr,Vm=Om,Uj=eh,Fj=Lc,Mk="Object already initialized",Wm=Pk.TypeError,Bj=Pk.WeakMap,th,Dc,rh,zj=function(t){return rh(t)?Dc(t):th(t,{})},Hj=function(t){return function(e){var r;if(!Dj(e)||(r=Dc(e)).type!==t)throw new Wm("Incompatible receiver, "+t+" required");return r}};if(Lj||Vm.state){var Qi=Vm.state||(Vm.state=new Bj);Qi.get=Qi.get,Qi.has=Qi.has,Qi.set=Qi.set,th=function(t,e){if(Qi.has(t))throw new Wm(Mk);return e.facade=t,Qi.set(t,e),e},Dc=function(t){return Qi.get(t)||{}},rh=function(t){return Qi.has(t)}}else{var Ru=Uj("state");Fj[Ru]=!0,th=function(t,e){if(qm(t,Ru))throw new Wm(Mk);return e.facade=t,jj(t,Ru,e),e},Dc=function(t){return qm(t,Ru)?t[Ru]:{}},rh=function(t){return qm(t,Ru)}}var Jn={set:th,get:Dc,has:rh,enforce:zj,getterFor:Hj},Zm=Kt,qj=Vt,Vj=Cr,nh=Vr,Gm=Ar,Wj=Nc.CONFIGURABLE,Zj=Hm,Nk=Jn,Gj=Nk.enforce,Kj=Nk.get,Lk=String,ih=Object.defineProperty,Jj=Zm("".slice),Yj=Zm("".replace),Qj=Zm([].join),Xj=Gm&&!qj(function(){return ih(function(){},"length",{value:8}).length!==8}),eU=String(String).split("String"),tU=xk.exports=function(t,e,r){Jj(Lk(e),0,7)==="Symbol("&&(e="["+Yj(Lk(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!nh(t,"name")||Wj&&t.name!==e)&&(Gm?ih(t,"name",{value:e,configurable:!0}):t.name=e),Xj&&r&&nh(r,"arity")&&t.length!==r.arity&&ih(t,"length",{value:r.arity});try{r&&nh(r,"constructor")&&r.constructor?Gm&&ih(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch{}var n=Gj(t);return nh(n,"source")||(n.source=Qj(eU,typeof e=="string"?e:"")),t};Function.prototype.toString=tU(function(){return Vj(this)&&Kj(this).source||Zj(this)},"toString");var Dk=xk.exports,rU=Cr,nU=Cn,iU=Dk,aU=Am,Rn=function(t,e,r,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:e;if(rU(r)&&iU(r,a,n),n.global)i?t[e]=r:aU(e,r);else{try{n.unsafe?t[e]&&(i=!0):delete t[e]}catch{}i?t[e]=r:nU.f(t,e,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return t},ko={},sU=Math.ceil,oU=Math.floor,uU=Math.trunc||function(e){var r=+e;return(r>0?oU:sU)(r)},lU=uU,Xi=function(t){var e=+t;return e!==e||e===0?0:lU(e)},cU=Xi,dU=Math.max,fU=Math.min,xu=function(t,e){var r=cU(t);return r<0?dU(r+e,0):fU(r,e)},hU=Xi,pU=Math.min,Ca=function(t){var e=hU(t);return e>0?pU(e,9007199254740991):0},vU=Ca,bn=function(t){return vU(t.length)},mU=Kn,gU=xu,yU=bn,jk=function(t){return function(e,r,n){var i=mU(e),a=yU(i);if(a===0)return!t&&-1;var s=gU(n,a),o;if(t&&r!==r){for(;a>s;)if(o=i[s++],o!==o)return!0}else for(;a>s;s++)if((t||s in i)&&i[s]===r)return t||s||0;return!t&&-1}},ah={includes:jk(!0),indexOf:jk(!1)},bU=Kt,Km=Vr,wU=Kn,_U=ah.indexOf,kU=Lc,Uk=bU([].push),Fk=function(t,e){var r=wU(t),n=0,i=[],a;for(a in r)!Km(kU,a)&&Km(r,a)&&Uk(i,a);for(;e.length>n;)Km(r,a=e[n++])&&(~_U(i,a)||Uk(i,a));return i},Jm=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],SU=Fk,$U=Jm,TU=$U.concat("length","prototype");ko.f=Object.getOwnPropertyNames||function(e){return SU(e,TU)};var jc={};jc.f=Object.getOwnPropertySymbols;var EU=Ai,CU=Kt,RU=ko,xU=jc,IU=Gr,AU=CU([].concat),Bk=EU("Reflect","ownKeys")||function(e){var r=RU.f(IU(e)),n=xU.f;return n?AU(r,n(e)):r},zk=Vr,OU=Bk,PU=$a,MU=Cn,Ym=function(t,e,r){for(var n=OU(e),i=MU.f,a=PU.f,s=0;s<n.length;s++){var o=n[s];!zk(t,o)&&!(r&&zk(r,o))&&i(t,o,a(e,o))}},NU=Vt,LU=Cr,DU=/#|\.prototype\./,Uc=function(t,e){var r=UU[jU(t)];return r===BU?!0:r===FU?!1:LU(e)?NU(e):!!e},jU=Uc.normalize=function(t){return String(t).replace(DU,".").toLowerCase()},UU=Uc.data={},FU=Uc.NATIVE="N",BU=Uc.POLYFILL="P",sh=Uc,oh=cr,zU=$a.f,HU=Ea,qU=Rn,VU=Am,WU=Ym,ZU=sh,er=function(t,e){var r=t.target,n=t.global,i=t.stat,a,s,o,u,l,c;if(n?s=oh:i?s=oh[r]||VU(r,{}):s=oh[r]&&oh[r].prototype,s)for(o in e){if(l=e[o],t.dontCallGetSet?(c=zU(s,o),u=c&&c.value):u=s[o],a=ZU(n?o:r+(i?".":"#")+o,t.forced),!a&&u!==void 0){if(typeof l==typeof u)continue;WU(l,u)}(t.sham||u&&u.sham)&&HU(l,"sham",!0),qU(s,o,l,t)}},GU=Cn.f,KU=Vr,JU=Rr,Hk=JU("toStringTag"),ea=function(t,e,r){t&&!r&&(t=t.prototype),t&&!KU(t,Hk)&&GU(t,Hk,{configurable:!0,value:e})},YU=er,QU=cr,XU=ea;YU({global:!0},{Reflect:{}}),XU(QU.Reflect,"Reflect",!0);var e5=Ac,qk=Function.prototype,Vk=qk.apply,Wk=qk.call,So=typeof Reflect=="object"&&Reflect.apply||(e5?Wk.bind(Vk):function(){return Wk.apply(Vk,arguments)}),t5=Kt,ta=t5([].slice),Zk=Kt,r5=si,n5=Lr,i5=Vr,Gk=ta,a5=Ac,Kk=Function,s5=Zk([].concat),o5=Zk([].join),Qm={},u5=function(t,e,r){if(!i5(Qm,e)){for(var n=[],i=0;i<e;i++)n[i]="a["+i+"]";Qm[e]=Kk("C,a","return new C("+o5(n,",")+")")}return Qm[e](t,r)},l5=a5?Kk.bind:function(e){var r=r5(this),n=r.prototype,i=Gk(arguments,1),a=function(){var o=s5(i,Gk(arguments));return this instanceof a?u5(r,o.length,o):r.apply(e,o)};return n5(n)&&(a.prototype=n),a},c5=Rr,d5=c5("toStringTag"),Jk={};Jk[d5]="z";var Xm=String(Jk)==="[object z]",f5=Xm,h5=Cr,uh=Yi,p5=Rr,v5=p5("toStringTag"),m5=Object,g5=uh(function(){return arguments}())==="Arguments",y5=function(t,e){try{return t[e]}catch{}},Ra=f5?uh:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=y5(e=m5(t),v5))=="string"?r:g5?uh(e):(n=uh(e))==="Object"&&h5(e.callee)?"Arguments":n},b5=Kt,w5=Vt,Yk=Cr,_5=Ra,k5=Ai,S5=Hm,Qk=function(){},Xk=k5("Reflect","construct"),eg=/^\s*(?:class|function)\b/,$5=b5(eg.exec),T5=!eg.test(Qk),Fc=function(e){if(!Yk(e))return!1;try{return Xk(Qk,[],e),!0}catch{return!1}},eS=function(e){if(!Yk(e))return!1;switch(_5(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return T5||!!$5(eg,S5(e))}catch{return!0}};eS.sham=!0;var lh=!Xk||w5(function(){var t;return Fc(Fc.call)||!Fc(Object)||!Fc(function(){t=!0})||t})?eS:Fc,E5=lh,C5=wo,R5=TypeError,tg=function(t){if(E5(t))return t;throw new R5(C5(t)+" is not a constructor")},rg={},x5=Fk,I5=Jm,Bc=Object.keys||function(e){return x5(e,I5)},A5=Ar,O5=Ck,P5=Cn,M5=Gr,N5=Kn,L5=Bc;rg.f=A5&&!O5?Object.defineProperties:function(e,r){M5(e);for(var n=N5(r),i=L5(r),a=i.length,s=0,o;a>s;)P5.f(e,o=i[s++],n[o]);return e};var D5=Ai,tS=D5("document","documentElement"),j5=Gr,U5=rg,rS=Jm,F5=Lc,B5=tS,z5=Qf,H5=eh,nS=">",iS="<",ng="prototype",ig="script",aS=H5("IE_PROTO"),ag=function(){},sS=function(t){return iS+ig+nS+t+iS+"/"+ig+nS},oS=function(t){t.write(sS("")),t.close();var e=t.parentWindow.Object;return t=null,e},q5=function(){var t=z5("iframe"),e="java"+ig+":",r;return t.style.display="none",B5.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(sS("document.F=Object")),r.close(),r.F},ch,dh=function(){try{ch=new ActiveXObject("htmlfile")}catch{}dh=typeof document<"u"?document.domain&&ch?oS(ch):q5():oS(ch);for(var t=rS.length;t--;)delete dh[ng][rS[t]];return dh()};F5[aS]=!0;var ps=Object.create||function(e,r){var n;return e!==null?(ag[ng]=j5(e),n=new ag,ag[ng]=null,n[aS]=e):n=dh(),r===void 0?n:U5.f(n,r)},V5=er,W5=Ai,sg=So,Z5=l5,uS=tg,G5=Gr,lS=Lr,K5=ps,cS=Vt,og=W5("Reflect","construct"),J5=Object.prototype,Y5=[].push,dS=cS(function(){function t(){}return!(og(function(){},[],t)instanceof t)}),fS=!cS(function(){og(function(){})}),hS=dS||fS;V5({target:"Reflect",stat:!0,forced:hS,sham:hS},{construct:function(e,r){uS(e),G5(r);var n=arguments.length<3?e:uS(arguments[2]);if(fS&&!dS)return og(e,r,n);if(e===n){switch(r.length){case 0:return new e;case 1:return new e(r[0]);case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[1],r[2]);case 4:return new e(r[0],r[1],r[2],r[3])}var i=[null];return sg(Y5,i,r),new(sg(Z5,e,i))}var a=n.prototype,s=K5(lS(a)?a:J5),o=sg(e,s,r);return lS(o)?o:s}});var Q5=er,X5=yn,pS=Bc,e6=Vt,t6=e6(function(){pS(1)});Q5({target:"Object",stat:!0,forced:t6},{keys:function(e){return pS(X5(e))}});var r6=Ra,n6=String,rn=function(t){if(r6(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return n6(t)},ug={},i6=Yi,a6=Kn,vS=ko.f,s6=ta,mS=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],o6=function(t){try{return vS(t)}catch{return s6(mS)}};ug.f=function(e){return mS&&i6(e)==="Window"?o6(e):vS(a6(e))};var gS=Dk,u6=Cn,ra=function(t,e,r){return r.get&&gS(r.get,e,{getter:!0}),r.set&&gS(r.set,e,{setter:!0}),u6.f(t,e,r)},lg={},l6=Rr;lg.f=l6;var c6=cr,yS=c6,bS=yS,d6=Vr,f6=lg,h6=Cn.f,wS=function(t){var e=bS.Symbol||(bS.Symbol={});d6(e,t)||h6(e,t,{value:f6.f(t)})},p6=Er,v6=Ai,m6=Rr,g6=Rn,y6=function(){var t=v6("Symbol"),e=t&&t.prototype,r=e&&e.valueOf,n=m6("toPrimitive");e&&!e[n]&&g6(e,n,function(i){return p6(r,this)},{arity:1})},b6=Yi,w6=Kt,cg=function(t){if(b6(t)==="Function")return w6(t)},_S=cg,_6=si,k6=Ac,S6=_S(_S.bind),xa=function(t,e){return _6(t),e===void 0?t:k6?S6(t,e):function(){return t.apply(e,arguments)}},$6=Yi,zc=Array.isArray||function(e){return $6(e)==="Array"},kS=zc,T6=lh,E6=Lr,C6=Rr,R6=C6("species"),SS=Array,x6=function(t){var e;return kS(t)&&(e=t.constructor,T6(e)&&(e===SS||kS(e.prototype))?e=void 0:E6(e)&&(e=e[R6],e===null&&(e=void 0))),e===void 0?SS:e},I6=x6,dg=function(t,e){return new(I6(t))(e===0?0:e)},A6=xa,O6=Kt,P6=Pc,M6=yn,N6=bn,L6=dg,$S=O6([].push),vs=function(t){var e=t===1,r=t===2,n=t===3,i=t===4,a=t===6,s=t===7,o=t===5||a;return function(u,l,c,d){for(var f=M6(u),m=P6(f),b=N6(m),A=A6(l,c),N=0,z=d||L6,X=e?z(u,b):r||s?z(u,0):void 0,Ee,Ie;b>N;N++)if((o||N in m)&&(Ee=m[N],Ie=A(Ee,N,f),t))if(e)X[N]=Ie;else if(Ie)switch(t){case 3:return!0;case 5:return Ee;case 6:return N;case 2:$S(X,Ee)}else switch(t){case 4:return!1;case 7:$S(X,Ee)}return a?-1:n||i?i:X}},Un={forEach:vs(0),map:vs(1),filter:vs(2),some:vs(3),every:vs(4),find:vs(5),findIndex:vs(6),filterReject:vs(7)},fh=er,Hc=cr,fg=Er,D6=Kt,Iu=Ar,Au=$u,j6=Vt,fn=Vr,U6=Ta,hg=Gr,hh=Kn,pg=Yf,F6=rn,vg=yo,Ou=ps,TS=Bc,B6=ko,ES=ug,z6=jc,CS=$a,RS=Cn,H6=rg,xS=Oc,mg=Rn,q6=ra,gg=Eu,V6=eh,IS=Lc,AS=Mc,W6=Rr,Z6=lg,G6=wS,K6=y6,J6=ea,OS=Jn,ph=Un.forEach,Fn=V6("hidden"),vh="Symbol",qc="prototype",Y6=OS.set,PS=OS.getterFor(vh),oi=Object[qc],$o=Hc.Symbol,Vc=$o&&$o[qc],Q6=Hc.RangeError,X6=Hc.TypeError,yg=Hc.QObject,MS=CS.f,To=RS.f,NS=ES.f,eF=xS.f,LS=D6([].push),Ia=gg("symbols"),Wc=gg("op-symbols"),tF=gg("wks"),bg=!yg||!yg[qc]||!yg[qc].findChild,DS=function(t,e,r){var n=MS(oi,e);n&&delete oi[e],To(t,e,r),n&&t!==oi&&To(oi,e,n)},wg=Iu&&j6(function(){return Ou(To({},"a",{get:function(){return To(this,"a",{value:7}).a}})).a!==7})?DS:To,_g=function(t,e){var r=Ia[t]=Ou(Vc);return Y6(r,{type:vh,tag:t,description:e}),Iu||(r.description=e),r},mh=function(e,r,n){e===oi&&mh(Wc,r,n),hg(e);var i=pg(r);return hg(n),fn(Ia,i)?(n.enumerable?(fn(e,Fn)&&e[Fn][i]&&(e[Fn][i]=!1),n=Ou(n,{enumerable:vg(0,!1)})):(fn(e,Fn)||To(e,Fn,vg(1,Ou(null))),e[Fn][i]=!0),wg(e,i,n)):To(e,i,n)},kg=function(e,r){hg(e);var n=hh(r),i=TS(n).concat(FS(n));return ph(i,function(a){(!Iu||fg(Sg,n,a))&&mh(e,a,n[a])}),e},rF=function(e,r){return r===void 0?Ou(e):kg(Ou(e),r)},Sg=function(e){var r=pg(e),n=fg(eF,this,r);return this===oi&&fn(Ia,r)&&!fn(Wc,r)?!1:n||!fn(this,r)||!fn(Ia,r)||fn(this,Fn)&&this[Fn][r]?n:!0},jS=function(e,r){var n=hh(e),i=pg(r);if(!(n===oi&&fn(Ia,i)&&!fn(Wc,i))){var a=MS(n,i);return a&&fn(Ia,i)&&!(fn(n,Fn)&&n[Fn][i])&&(a.enumerable=!0),a}},US=function(e){var r=NS(hh(e)),n=[];return ph(r,function(i){!fn(Ia,i)&&!fn(IS,i)&&LS(n,i)}),n},FS=function(t){var e=t===oi,r=NS(e?Wc:hh(t)),n=[];return ph(r,function(i){fn(Ia,i)&&(!e||fn(oi,i))&&LS(n,Ia[i])}),n};Au||($o=function(){if(U6(Vc,this))throw new X6("Symbol is not a constructor");var e=!arguments.length||arguments[0]===void 0?void 0:F6(arguments[0]),r=AS(e),n=function(i){var a=this===void 0?Hc:this;a===oi&&fg(n,Wc,i),fn(a,Fn)&&fn(a[Fn],r)&&(a[Fn][r]=!1);var s=vg(1,i);try{wg(a,r,s)}catch(o){if(!(o instanceof Q6))throw o;DS(a,r,s)}};return Iu&&bg&&wg(oi,r,{configurable:!0,set:n}),_g(r,e)},Vc=$o[qc],mg(Vc,"toString",function(){return PS(this).tag}),mg($o,"withoutSetter",function(t){return _g(AS(t),t)}),xS.f=Sg,RS.f=mh,H6.f=kg,CS.f=jS,B6.f=ES.f=US,z6.f=FS,Z6.f=function(t){return _g(W6(t),t)},Iu&&(q6(Vc,"description",{configurable:!0,get:function(){return PS(this).description}}),mg(oi,"propertyIsEnumerable",Sg,{unsafe:!0}))),fh({global:!0,constructor:!0,wrap:!0,forced:!Au,sham:!Au},{Symbol:$o}),ph(TS(tF),function(t){G6(t)}),fh({target:vh,stat:!0,forced:!Au},{useSetter:function(){bg=!0},useSimple:function(){bg=!1}}),fh({target:"Object",stat:!0,forced:!Au,sham:!Iu},{create:rF,defineProperty:mh,defineProperties:kg,getOwnPropertyDescriptor:jS}),fh({target:"Object",stat:!0,forced:!Au},{getOwnPropertyNames:US}),K6(),J6($o,vh),IS[Fn]=!0;var nF=$u,BS=nF&&!!Symbol.for&&!!Symbol.keyFor,iF=er,aF=Ai,sF=Vr,oF=rn,zS=Eu,uF=BS,$g=zS("string-to-symbol-registry"),lF=zS("symbol-to-string-registry");iF({target:"Symbol",stat:!0,forced:!uF},{for:function(t){var e=oF(t);if(sF($g,e))return $g[e];var r=aF("Symbol")(e);return $g[e]=r,lF[r]=e,r}});var cF=er,dF=Vr,fF=Tu,hF=wo,pF=Eu,vF=BS,HS=pF("symbol-to-string-registry");cF({target:"Symbol",stat:!0,forced:!vF},{keyFor:function(e){if(!fF(e))throw new TypeError(hF(e)+" is not a symbol");if(dF(HS,e))return HS[e]}});var mF=Kt,qS=zc,gF=Cr,VS=Yi,yF=rn,WS=mF([].push),bF=function(t){if(gF(t))return t;if(qS(t)){for(var e=t.length,r=[],n=0;n<e;n++){var i=t[n];typeof i=="string"?WS(r,i):(typeof i=="number"||VS(i)==="Number"||VS(i)==="String")&&WS(r,yF(i))}var a=r.length,s=!0;return function(o,u){if(s)return s=!1,u;if(qS(this))return u;for(var l=0;l<a;l++)if(r[l]===o)return u}}},wF=er,ZS=Ai,GS=So,_F=Er,Zc=Kt,KS=Vt,JS=Cr,YS=Tu,QS=ta,kF=bF,SF=$u,$F=String,ms=ZS("JSON","stringify"),gh=Zc(/./.exec),XS=Zc("".charAt),TF=Zc("".charCodeAt),EF=Zc("".replace),CF=Zc(1 .toString),RF=/[\uD800-\uDFFF]/g,e$=/^[\uD800-\uDBFF]$/,t$=/^[\uDC00-\uDFFF]$/,r$=!SF||KS(function(){var t=ZS("Symbol")("stringify detection");return ms([t])!=="[null]"||ms({a:t})!=="{}"||ms(Object(t))!=="{}"}),n$=KS(function(){return ms("\uDF06\uD834")!=='"\\udf06\\ud834"'||ms("\uDEAD")!=='"\\udead"'}),xF=function(t,e){var r=QS(arguments),n=kF(e);if(!(!JS(n)&&(t===void 0||YS(t))))return r[1]=function(i,a){if(JS(n)&&(a=_F(n,this,$F(i),a)),!YS(a))return a},GS(ms,null,r)},IF=function(t,e,r){var n=XS(r,e-1),i=XS(r,e+1);return gh(e$,t)&&!gh(t$,i)||gh(t$,t)&&!gh(e$,n)?"\\u"+CF(TF(t,0),16):t};ms&&wF({target:"JSON",stat:!0,arity:3,forced:r$||n$},{stringify:function(e,r,n){var i=QS(arguments),a=GS(r$?xF:ms,null,i);return n$&&typeof a=="string"?EF(a,RF,IF):a}});var AF=er,OF=$u,PF=Vt,i$=jc,MF=yn,NF=!OF||PF(function(){i$.f(1)});AF({target:"Object",stat:!0,forced:NF},{getOwnPropertySymbols:function(e){var r=i$.f;return r?r(MF(e)):[]}});var LF=Vt,DF=Rr,jF=Su,UF=DF("species"),Gc=function(t){return jF>=51||!LF(function(){var e=[],r=e.constructor={};return r[UF]=function(){return{foo:1}},e[t](Boolean).foo!==1})},FF=er,BF=Un.filter,zF=Gc,HF=zF("filter");FF({target:"Array",proto:!0,forced:!HF},{filter:function(e){return BF(this,e,arguments.length>1?arguments[1]:void 0)}});var qF=er,VF=Vt,WF=Kn,a$=$a.f,s$=Ar,ZF=!s$||VF(function(){a$(1)});qF({target:"Object",stat:!0,forced:ZF,sham:!s$},{getOwnPropertyDescriptor:function(e,r){return a$(WF(e),r)}});var GF=Ar,KF=Cn,JF=yo,Kc=function(t,e,r){GF?KF.f(t,e,JF(0,r)):t[e]=r},YF=er,QF=Ar,XF=Bk,eB=Kn,tB=$a,rB=Kc;YF({target:"Object",stat:!0,sham:!QF},{getOwnPropertyDescriptors:function(e){for(var r=eB(e),n=tB.f,i=XF(r),a={},s=0,o,u;i.length>s;)u=n(r,o=i[s++]),u!==void 0&&rB(a,o,u);return a}});var o$={exports:{}};(function(t){function e(n,i,a,s,o,u,l){try{var c=n[u](l),d=c.value}catch(f){return void a(f)}c.done?i(d):Promise.resolve(d).then(s,o)}function r(n){return function(){var i=this,a=arguments;return new Promise(function(s,o){var u=n.apply(i,a);function l(d){e(u,s,o,l,c,"next",d)}function c(d){e(u,s,o,l,c,"throw",d)}l(void 0)})}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(o$);var Pu=o$.exports,u$={exports:{}};(function(t){function e(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(u$);var gs=u$.exports,l$={exports:{}},c$={exports:{}};(function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,a){return i.__proto__=a,i},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(c$);var Tg=c$.exports;(function(t){var e=Tg;function r(n,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),i&&e(n,i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(l$);var na=l$.exports,d$={exports:{}},f$={exports:{}};(function(t){function e(r){"@babel/helpers - typeof";return t.exports=e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(f$);var ui=f$.exports;(function(t){var e=ui.default,r=gs;function n(i,a){if(a&&(e(a)=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(d$);var ia=d$.exports,h$={exports:{}};(function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(h$);var li=h$.exports,p$={exports:{}},v$={exports:{}},m$={exports:{}};(function(t){var e=ui.default;function r(n,i){if(e(n)!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var s=a.call(n,i||"default");if(e(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(m$);var nB=m$.exports;(function(t){var e=ui.default,r=nB;function n(i){var a=r(i,"string");return e(a)=="symbol"?a:a+""}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(v$);var g$=v$.exports;(function(t){var e=g$;function r(n,i,a){return(i=e(i))in n?Object.defineProperty(n,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[i]=a,n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(p$);var ys=p$.exports,y$={exports:{}};(function(t){var e=g$;function r(i,a){for(var s=0;s<a.length;s++){var o=a[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(i,e(o.key),o)}}function n(i,a,s){return a&&r(i.prototype,a),s&&r(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(y$);var Aa=y$.exports,b$={exports:{}};(function(t){function e(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(b$);var aa=b$.exports,iB=er,aB=Un.map,sB=Gc,oB=sB("map");iB({target:"Array",proto:!0,forced:!oB},{map:function(e){return aB(this,e,arguments.length>1?arguments[1]:void 0)}});var uB=Xm,lB=Ra,cB=uB?{}.toString:function(){return"[object "+lB(this)+"]"},dB=Xm,fB=Rn,hB=cB;dB||fB(Object.prototype,"toString",hB,{unsafe:!0});var w$={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},pB=Qf,Eg=pB("span").classList,_$=Eg&&Eg.constructor&&Eg.constructor.prototype,k$=_$===Object.prototype?void 0:_$,vB=Vt,yh=function(t,e){var r=[][t];return!!r&&vB(function(){r.call(null,e||function(){return 1},1)})},mB=Un.forEach,gB=yh,yB=gB("forEach"),bB=yB?[].forEach:function(e){return mB(this,e,arguments.length>1?arguments[1]:void 0)},S$=cr,$$=w$,wB=k$,Cg=bB,_B=Ea,T$=function(t){if(t&&t.forEach!==Cg)try{_B(t,"forEach",Cg)}catch{t.forEach=Cg}};for(var Rg in $$)$$[Rg]&&T$(S$[Rg]&&S$[Rg].prototype);T$(wB);var kB=cr,SB=Yi,bh=SB(kB.process)==="process",$B=Kt,TB=si,EB=function(t,e,r){try{return $B(TB(Object.getOwnPropertyDescriptor(t,e)[r]))}catch{}},CB=Lr,RB=function(t){return CB(t)||t===null},xB=RB,IB=String,AB=TypeError,OB=function(t){if(xB(t))return t;throw new AB("Can't set "+IB(t)+" as a prototype")},PB=EB,MB=Lr,NB=Ii,LB=OB,Mu=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=PB(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch{}return function(i,a){return NB(i),LB(a),MB(i)&&(t?r(i,a):i.__proto__=a),i}}():void 0),DB=Ai,jB=ra,UB=Rr,FB=Ar,E$=UB("species"),wh=function(t){var e=DB(t);FB&&e&&!e[E$]&&jB(e,E$,{configurable:!0,get:function(){return this}})},BB=Ta,zB=TypeError,bs=function(t,e){if(BB(e,t))return t;throw new zB("Incorrect invocation")},C$=Gr,HB=tg,qB=xi,VB=Rr,WB=VB("species"),xg=function(t,e){var r=C$(t).constructor,n;return r===void 0||qB(n=C$(r)[WB])?e:HB(n)},ZB=TypeError,Ig=function(t,e){if(t<e)throw new ZB("Not enough arguments");return t},GB=bo,R$=/(?:ipad|iphone|ipod).*applewebkit/i.test(GB),Yn=cr,KB=So,JB=xa,x$=Cr,YB=Vr,I$=Vt,A$=tS,QB=ta,O$=Qf,XB=Ig,e8=R$,t8=bh,Ag=Yn.setImmediate,Og=Yn.clearImmediate,r8=Yn.process,Pg=Yn.Dispatch,n8=Yn.Function,P$=Yn.MessageChannel,i8=Yn.String,Mg=0,Jc={},M$="onreadystatechange",Yc,Eo,Ng,Lg;I$(function(){Yc=Yn.location});var Dg=function(t){if(YB(Jc,t)){var e=Jc[t];delete Jc[t],e()}},jg=function(t){return function(){Dg(t)}},N$=function(t){Dg(t.data)},L$=function(t){Yn.postMessage(i8(t),Yc.protocol+"//"+Yc.host)};(!Ag||!Og)&&(Ag=function(e){XB(arguments.length,1);var r=x$(e)?e:n8(e),n=QB(arguments,1);return Jc[++Mg]=function(){KB(r,void 0,n)},Eo(Mg),Mg},Og=function(e){delete Jc[e]},t8?Eo=function(t){r8.nextTick(jg(t))}:Pg&&Pg.now?Eo=function(t){Pg.now(jg(t))}:P$&&!e8?(Ng=new P$,Lg=Ng.port2,Ng.port1.onmessage=N$,Eo=JB(Lg.postMessage,Lg)):Yn.addEventListener&&x$(Yn.postMessage)&&!Yn.importScripts&&Yc&&Yc.protocol!=="file:"&&!I$(L$)?(Eo=L$,Yn.addEventListener("message",N$,!1)):M$ in O$("script")?Eo=function(t){A$.appendChild(O$("script"))[M$]=function(){A$.removeChild(this),Dg(t)}}:Eo=function(t){setTimeout(jg(t),0)});var D$={set:Ag,clear:Og},j$=cr,a8=Ar,s8=Object.getOwnPropertyDescriptor,U$=function(t){if(!a8)return j$[t];var e=s8(j$,t);return e&&e.value},F$=function(){this.head=null,this.tail=null};F$.prototype={add:function(t){var e={item:t,next:null},r=this.tail;r?r.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t){var e=this.head=t.next;return e===null&&(this.tail=null),t.item}}};var B$=F$,o8=bo,u8=/ipad|iphone|ipod/i.test(o8)&&typeof Pebble<"u",l8=bo,c8=/web0s(?!.*chrome)/i.test(l8),Nu=cr,d8=U$,z$=xa,Ug=D$.set,f8=B$,h8=R$,p8=u8,v8=c8,Fg=bh,H$=Nu.MutationObserver||Nu.WebKitMutationObserver,q$=Nu.document,V$=Nu.process,_h=Nu.Promise,Bg=d8("queueMicrotask"),Lu,zg,Hg,kh,W$;if(!Bg){var Sh=new f8,$h=function(){var t,e;for(Fg&&(t=V$.domain)&&t.exit();e=Sh.get();)try{e()}catch(r){throw Sh.head&&Lu(),r}t&&t.enter()};!h8&&!Fg&&!v8&&H$&&q$?(zg=!0,Hg=q$.createTextNode(""),new H$($h).observe(Hg,{characterData:!0}),Lu=function(){Hg.data=zg=!zg}):!p8&&_h&&_h.resolve?(kh=_h.resolve(void 0),kh.constructor=_h,W$=z$(kh.then,kh),Lu=function(){W$($h)}):Fg?Lu=function(){V$.nextTick($h)}:(Ug=z$(Ug,Nu),Lu=function(){Ug($h)}),Bg=function(t){Sh.head||Lu(),Sh.add(t)}}var m8=Bg,g8=function(t,e){try{arguments.length===1?console.error(t):console.error(t,e)}catch{}},qg=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}},y8=cr,Th=y8.Promise,Z$=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",b8=Z$,w8=bh,_8=!b8&&!w8&&typeof window=="object"&&typeof document=="object",k8=cr,Qc=Th,S8=Cr,$8=sh,T8=Hm,E8=Rr,C8=_8,R8=Z$,Vg=Su;Qc&&Qc.prototype;var x8=E8("species"),Wg=!1,G$=S8(k8.PromiseRejectionEvent),I8=$8("Promise",function(){var t=T8(Qc),e=t!==String(Qc);if(!e&&Vg===66)return!0;if(!Vg||Vg<51||!/native code/.test(t)){var r=new Qc(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=r.constructor={};if(i[x8]=n,Wg=r.then(function(){})instanceof n,!Wg)return!0}return!e&&(C8||R8)&&!G$}),Xc={CONSTRUCTOR:I8,REJECTION_EVENT:G$,SUBCLASSING:Wg},Du={},K$=si,A8=TypeError,O8=function(t){var e,r;this.promise=new t(function(n,i){if(e!==void 0||r!==void 0)throw new A8("Bad Promise constructor");e=n,r=i}),this.resolve=K$(e),this.reject=K$(r)};Du.f=function(t){return new O8(t)};var P8=er,Eh=bh,ws=cr,ju=Er,J$=Rn,Y$=Mu,M8=ea,N8=wh,L8=si,Ch=Cr,D8=Lr,j8=bs,U8=xg,Q$=D$.set,Zg=m8,F8=g8,B8=qg,z8=B$,X$=Jn,Rh=Th,Gg=Xc,eT=Du,xh="Promise",tT=Gg.CONSTRUCTOR,H8=Gg.REJECTION_EVENT,q8=Gg.SUBCLASSING,Kg=X$.getterFor(xh),V8=X$.set,Uu=Rh&&Rh.prototype,Co=Rh,Ih=Uu,rT=ws.TypeError,Jg=ws.document,Yg=ws.process,Qg=eT.f,W8=Qg,Z8=!!(Jg&&Jg.createEvent&&ws.dispatchEvent),nT="unhandledrejection",G8="rejectionhandled",iT=0,aT=1,K8=2,Xg=1,sT=2,Ah,oT,J8,uT,lT=function(t){var e;return D8(t)&&Ch(e=t.then)?e:!1},cT=function(t,e){var r=e.value,n=e.state===aT,i=n?t.ok:t.fail,a=t.resolve,s=t.reject,o=t.domain,u,l,c;try{i?(n||(e.rejection===sT&&Q8(e),e.rejection=Xg),i===!0?u=r:(o&&o.enter(),u=i(r),o&&(o.exit(),c=!0)),u===t.promise?s(new rT("Promise-chain cycle")):(l=lT(u))?ju(l,u,a,s):a(u)):s(r)}catch(d){o&&!c&&o.exit(),s(d)}},dT=function(t,e){t.notified||(t.notified=!0,Zg(function(){for(var r=t.reactions,n;n=r.get();)cT(n,t);t.notified=!1,e&&!t.rejection&&Y8(t)}))},fT=function(t,e,r){var n,i;Z8?(n=Jg.createEvent("Event"),n.promise=e,n.reason=r,n.initEvent(t,!1,!0),ws.dispatchEvent(n)):n={promise:e,reason:r},!H8&&(i=ws["on"+t])?i(n):t===nT&&F8("Unhandled promise rejection",r)},Y8=function(t){ju(Q$,ws,function(){var e=t.facade,r=t.value,n=hT(t),i;if(n&&(i=B8(function(){Eh?Yg.emit("unhandledRejection",r,e):fT(nT,e,r)}),t.rejection=Eh||hT(t)?sT:Xg,i.error))throw i.value})},hT=function(t){return t.rejection!==Xg&&!t.parent},Q8=function(t){ju(Q$,ws,function(){var e=t.facade;Eh?Yg.emit("rejectionHandled",e):fT(G8,e,t.value)})},Fu=function(t,e,r){return function(n){t(e,n,r)}},Bu=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=K8,dT(t,!0))},ey=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw new rT("Promise can't be resolved itself");var n=lT(e);n?Zg(function(){var i={done:!1};try{ju(n,e,Fu(ey,i,t),Fu(Bu,i,t))}catch(a){Bu(i,a,t)}}):(t.value=e,t.state=aT,dT(t,!1))}catch(i){Bu({done:!1},i,t)}}};if(tT&&(Co=function(e){j8(this,Ih),L8(e),ju(Ah,this);var r=Kg(this);try{e(Fu(ey,r),Fu(Bu,r))}catch(n){Bu(r,n)}},Ih=Co.prototype,Ah=function(e){V8(this,{type:xh,done:!1,notified:!1,parent:!1,reactions:new z8,rejection:!1,state:iT,value:void 0})},Ah.prototype=J$(Ih,"then",function(e,r){var n=Kg(this),i=Qg(U8(this,Co));return n.parent=!0,i.ok=Ch(e)?e:!0,i.fail=Ch(r)&&r,i.domain=Eh?Yg.domain:void 0,n.state===iT?n.reactions.add(i):Zg(function(){cT(i,n)}),i.promise}),oT=function(){var t=new Ah,e=Kg(t);this.promise=t,this.resolve=Fu(ey,e),this.reject=Fu(Bu,e)},eT.f=Qg=function(t){return t===Co||t===J8?new oT(t):W8(t)},Ch(Rh)&&Uu!==Object.prototype)){uT=Uu.then,q8||J$(Uu,"then",function(e,r){var n=this;return new Co(function(i,a){ju(uT,n,i,a)}).then(e,r)},{unsafe:!0});try{delete Uu.constructor}catch{}Y$&&Y$(Uu,Ih)}P8({global:!0,constructor:!0,wrap:!0,forced:tT},{Promise:Co}),M8(Co,xh,!1),N8(xh);var ed={},X8=Rr,e9=ed,t9=X8("iterator"),r9=Array.prototype,ty=function(t){return t!==void 0&&(e9.Array===t||r9[t9]===t)},n9=Ra,pT=_o,i9=xi,a9=ed,s9=Rr,o9=s9("iterator"),td=function(t){if(!i9(t))return pT(t,o9)||pT(t,"@@iterator")||a9[n9(t)]},u9=Er,l9=si,c9=Gr,d9=wo,f9=td,h9=TypeError,Oh=function(t,e){var r=arguments.length<2?f9(t):e;if(l9(r))return c9(u9(r,t));throw new h9(d9(t)+" is not iterable")},p9=Er,vT=Gr,v9=_o,mT=function(t,e,r){var n,i;vT(t);try{if(n=v9(t,"return"),!n){if(e==="throw")throw r;return r}n=p9(n,t)}catch(a){i=!0,n=a}if(e==="throw")throw r;if(i)throw n;return vT(n),r},m9=xa,g9=Er,y9=Gr,b9=wo,w9=ty,_9=bn,gT=Ta,k9=Oh,S9=td,yT=mT,$9=TypeError,Ph=function(t,e){this.stopped=t,this.result=e},bT=Ph.prototype,rd=function(t,e,r){var n=r&&r.that,i=!!(r&&r.AS_ENTRIES),a=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),o=!!(r&&r.INTERRUPTED),u=m9(e,n),l,c,d,f,m,b,A,N=function(X){return l&&yT(l,"normal",X),new Ph(!0,X)},z=function(X){return i?(y9(X),o?u(X[0],X[1],N):u(X[0],X[1])):o?u(X,N):u(X)};if(a)l=t.iterator;else if(s)l=t;else{if(c=S9(t),!c)throw new $9(b9(t)+" is not iterable");if(w9(c)){for(d=0,f=_9(t);f>d;d++)if(m=z(t[d]),m&&gT(bT,m))return m;return new Ph(!1)}l=k9(t,c)}for(b=a?t.next:l.next;!(A=g9(b,l)).done;){try{m=z(A.value)}catch(X){yT(l,"throw",X)}if(typeof m=="object"&&m&&gT(bT,m))return m}return new Ph(!1)},T9=Rr,wT=T9("iterator"),_T=!1;try{var E9=0,kT={next:function(){return{done:!!E9++}},return:function(){_T=!0}};kT[wT]=function(){return this},Array.from(kT,function(){throw 2})}catch{}var Mh=function(t,e){try{if(!e&&!_T)return!1}catch{return!1}var r=!1;try{var n={};n[wT]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch{}return r},C9=Th,R9=Mh,x9=Xc.CONSTRUCTOR,ST=x9||!R9(function(t){C9.all(t).then(void 0,function(){})}),I9=er,A9=Er,O9=si,P9=Du,M9=qg,N9=rd,L9=ST;I9({target:"Promise",stat:!0,forced:L9},{all:function(e){var r=this,n=P9.f(r),i=n.resolve,a=n.reject,s=M9(function(){var o=O9(r.resolve),u=[],l=0,c=1;N9(e,function(d){var f=l++,m=!1;c++,A9(o,r,d).then(function(b){m||(m=!0,u[f]=b,--c||i(u))},a)}),--c||i(u)});return s.error&&a(s.value),n.promise}});var D9=er,j9=Xc.CONSTRUCTOR,ry=Th,U9=Ai,F9=Cr,B9=Rn,$T=ry&&ry.prototype;if(D9({target:"Promise",proto:!0,forced:j9,real:!0},{catch:function(t){return this.then(void 0,t)}}),F9(ry)){var TT=U9("Promise").prototype.catch;$T.catch!==TT&&B9($T,"catch",TT,{unsafe:!0})}var z9=er,H9=Er,q9=si,V9=Du,W9=qg,Z9=rd,G9=ST;z9({target:"Promise",stat:!0,forced:G9},{race:function(e){var r=this,n=V9.f(r),i=n.reject,a=W9(function(){var s=q9(r.resolve);Z9(e,function(o){H9(s,r,o).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var K9=er,J9=Du,Y9=Xc.CONSTRUCTOR;K9({target:"Promise",stat:!0,forced:Y9},{reject:function(e){var r=J9.f(this),n=r.reject;return n(e),r.promise}});var Q9=Gr,X9=Lr,e7=Du,t7=function(t,e){if(Q9(t),X9(e)&&e.constructor===t)return e;var r=e7.f(t),n=r.resolve;return n(e),r.promise},r7=er,n7=Ai,i7=Xc.CONSTRUCTOR,a7=t7;n7("Promise"),r7({target:"Promise",stat:!0,forced:i7},{resolve:function(e){return a7(this,e)}});var ET={exports:{}},CT={exports:{}};(function(t){function e(r,n){this.v=r,this.k=n}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(CT);var RT=CT.exports,xT={exports:{}},IT={exports:{}};(function(t){function e(r,n,i,a){var s=Object.defineProperty;try{s({},"",{})}catch{s=0}t.exports=e=function(u,l,c,d){function f(m,b){e(u,m,function(A){return this._invoke(m,b,A)})}l?s?s(u,l,{value:c,enumerable:!d,configurable:!d,writable:!d}):u[l]=c:(f("next",0),f("throw",1),f("return",2))},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n,i,a)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(IT);var AT=IT.exports;(function(t){var e=AT;function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var n,i,a=typeof Symbol=="function"?Symbol:{},s=a.iterator||"@@iterator",o=a.toStringTag||"@@toStringTag";function u(N,z,X,Ee){var Ie=z&&z.prototype instanceof c?z:c,Be=Object.create(Ie.prototype);return e(Be,"_invoke",function(Oe,ze,V){var xe,_e,se,Te=0,re=V||[],oe=!1,q={p:0,n:0,v:n,a:ne,f:ne.bind(n,4),d:function(H,ye){return xe=H,_e=0,se=n,q.n=ye,l}};function ne(Se,H){for(_e=Se,se=H,i=0;!oe&&Te&&!ye&&i<re.length;i++){var ye,ke=re[i],M=q.p,Xe=ke[2];Se>3?(ye=Xe===H)&&(se=ke[(_e=ke[4])?5:(_e=3,3)],ke[4]=ke[5]=n):ke[0]<=M&&((ye=Se<2&&M<ke[1])?(_e=0,q.v=H,q.n=ke[1]):M<Xe&&(ye=Se<3||ke[0]>H||H>Xe)&&(ke[4]=Se,ke[5]=H,q.n=Xe,_e=0))}if(ye||Se>1)return l;throw oe=!0,H}return function(Se,H,ye){if(Te>1)throw TypeError("Generator is already running");for(oe&&H===1&&ne(H,ye),_e=H,se=ye;(i=_e<2?n:se)||!oe;){xe||(_e?_e<3?(_e>1&&(q.n=-1),ne(_e,se)):q.n=se:q.v=se);try{if(Te=2,xe){if(_e||(Se="next"),i=xe[Se]){if(!(i=i.call(xe,se)))throw TypeError("iterator result is not an object");if(!i.done)return i;se=i.value,_e<2&&(_e=0)}else _e===1&&(i=xe.return)&&i.call(xe),_e<2&&(se=TypeError("The iterator does not provide a '"+Se+"' method"),_e=1);xe=n}else if((i=(oe=q.n<0)?se:Oe.call(ze,q))!==l)break}catch(ke){xe=n,_e=1,se=ke}finally{Te=1}}return{value:i,done:oe}}}(N,X,Ee),!0),Be}var l={};function c(){}function d(){}function f(){}i=Object.getPrototypeOf;var m=[][s]?i(i([][s]())):(e(i={},s,function(){return this}),i),b=f.prototype=c.prototype=Object.create(m);function A(N){return Object.setPrototypeOf?Object.setPrototypeOf(N,f):(N.__proto__=f,e(N,o,"GeneratorFunction")),N.prototype=Object.create(b),N}return d.prototype=f,e(b,"constructor",f),e(f,"constructor",d),d.displayName="GeneratorFunction",e(f,o,"GeneratorFunction"),e(b),e(b,o,"Generator"),e(b,s,function(){return this}),e(b,"toString",function(){return"[object Generator]"}),(t.exports=r=function(){return{w:u,m:A}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(xT);var OT=xT.exports,PT={exports:{}},MT={exports:{}},NT={exports:{}};(function(t){var e=RT,r=AT;function n(i,a){function s(u,l,c,d){try{var f=i[u](l),m=f.value;return m instanceof e?a.resolve(m.v).then(function(b){s("next",b,c,d)},function(b){s("throw",b,c,d)}):a.resolve(m).then(function(b){f.value=b,c(f)},function(b){return s("throw",b,c,d)})}catch(b){d(b)}}var o;this.next||(r(n.prototype),r(n.prototype,typeof Symbol=="function"&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(u,l,c){function d(){return new a(function(f,m){s(u,c,f,m)})}return o=o?o.then(d,d):d()},!0)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(NT);var LT=NT.exports;(function(t){var e=OT,r=LT;function n(i,a,s,o,u){return new r(e().w(i,a,s,o),u||Promise)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(MT);var DT=MT.exports;(function(t){var e=DT;function r(n,i,a,s,o){var u=e(n,i,a,s,o);return u.next().then(function(l){return l.done?l.value:u.next()})}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(PT);var s7=PT.exports,jT={exports:{}};(function(t){function e(r){var n=Object(r),i=[];for(var a in n)i.unshift(a);return function s(){for(;i.length;)if((a=i.pop())in n)return s.value=a,s.done=!1,s;return s.done=!0,s}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(jT);var o7=jT.exports,UT={exports:{}};(function(t){var e=ui.default;function r(n){if(n!=null){var i=n[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],a=0;if(i)return i.call(n);if(typeof n.next=="function")return n;if(!isNaN(n.length))return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}}}throw new TypeError(e(n)+" is not iterable")}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(UT);var u7=UT.exports;(function(t){var e=RT,r=OT,n=s7,i=DT,a=LT,s=o7,o=u7;function u(){var l=r(),c=l.m(u),d=(Object.getPrototypeOf?Object.getPrototypeOf(c):c.__proto__).constructor;function f(A){var N=typeof A=="function"&&A.constructor;return!!N&&(N===d||(N.displayName||N.name)==="GeneratorFunction")}var m={throw:1,return:2,break:3,continue:3};function b(A){var N,z;return function(X){N||(N={stop:function(){return z(X.a,2)},catch:function(){return X.v},abrupt:function(Ie,Be){return z(X.a,m[Ie],Be)},delegateYield:function(Ie,Be,Oe){return N.resultName=Be,z(X.d,o(Ie),Oe)},finish:function(Ie){return z(X.f,Ie)}},z=function(Ie,Be,Oe){X.p=N.prev,X.n=N.next;try{return Ie(Be,Oe)}finally{N.next=X.n}}),N.resultName&&(N[N.resultName]=X.v,N.resultName=void 0),N.sent=X.v,N.next=X.n;try{return A.call(this,N)}finally{X.p=N.prev,X.n=N.next}}}return(t.exports=u=function(){return{wrap:function(z,X,Ee,Ie){return l.w(b(z),X,Ee,Ie&&Ie.reverse())},isGeneratorFunction:f,mark:l.m,awrap:function(z,X){return new e(z,X)},AsyncIterator:a,async:function(z,X,Ee,Ie,Be){return(f(X)?i:n)(b(z),X,Ee,Ie,Be)},keys:s,values:o}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=u,t.exports.__esModule=!0,t.exports.default=t.exports})(ET);var l7=ET.exports,Nh=l7(),zu=Nh;try{regeneratorRuntime=Nh}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Nh:Function("r","regeneratorRuntime = r")(Nh)}var c7=TypeError,d7=9007199254740991,FT=function(t){if(t>d7)throw c7("Maximum allowed index exceeded");return t},f7=er,h7=Vt,p7=zc,v7=Lr,m7=yn,g7=bn,BT=FT,zT=Kc,y7=dg,b7=Gc,w7=Rr,_7=Su,HT=w7("isConcatSpreadable"),k7=_7>=51||!h7(function(){var t=[];return t[HT]=!1,t.concat()[0]!==t}),S7=function(t){if(!v7(t))return!1;var e=t[HT];return e!==void 0?!!e:p7(t)},$7=!k7||!b7("concat");f7({target:"Array",proto:!0,arity:1,forced:$7},{concat:function(e){var r=m7(this),n=y7(r,0),i=0,a,s,o,u,l;for(a=-1,o=arguments.length;a<o;a++)if(l=a===-1?r:arguments[a],S7(l))for(u=g7(l),BT(i+u),s=0;s<u;s++,i++)s in l&&zT(n,i,l[s]);else BT(i+1),zT(n,i++,l);return n.length=i,n}});var T7=Gr,E7=mT,C7=function(t,e,r,n){try{return n?e(T7(r)[0],r[1]):e(r)}catch(i){E7(t,"throw",i)}},R7=xa,x7=Er,I7=yn,A7=C7,O7=ty,P7=lh,M7=bn,qT=Kc,N7=Oh,L7=td,VT=Array,WT=function(e){var r=I7(e),n=P7(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=R7(a,i>2?arguments[2]:void 0));var o=L7(r),u=0,l,c,d,f,m,b;if(o&&!(this===VT&&O7(o)))for(c=n?new this:[],f=N7(r,o),m=f.next;!(d=x7(m,f)).done;u++)b=s?A7(f,a,[d.value,u],!0):d.value,qT(c,u,b);else for(l=M7(r),c=n?new this(l):VT(l);l>u;u++)b=s?a(r[u],u):r[u],qT(c,u,b);return c.length=u,c},D7=er,j7=WT,U7=Mh,F7=!U7(function(t){Array.from(t)});D7({target:"Array",stat:!0,forced:F7},{from:j7});var ny=Kt,B7=Xi,z7=rn,H7=Ii,q7=ny("".charAt),ZT=ny("".charCodeAt),V7=ny("".slice),GT=function(t){return function(e,r){var n=z7(H7(e)),i=B7(r),a=n.length,s,o;return i<0||i>=a?t?"":void 0:(s=ZT(n,i),s<55296||s>56319||i+1===a||(o=ZT(n,i+1))<56320||o>57343?t?q7(n,i):s:t?V7(n,i,i+2):(s-55296<<10)+(o-56320)+65536)}},iy={codeAt:GT(!1),charAt:GT(!0)},W7=Vt,Z7=!W7(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),G7=Vr,K7=Cr,J7=yn,Y7=eh,Q7=Z7,KT=Y7("IE_PROTO"),ay=Object,X7=ay.prototype,nd=Q7?ay.getPrototypeOf:function(t){var e=J7(t);if(G7(e,KT))return e[KT];var r=e.constructor;return K7(r)&&e instanceof r?r.prototype:e instanceof ay?X7:null},ez=Vt,tz=Cr,rz=Lr,JT=nd,nz=Rn,iz=Rr,sy=iz("iterator"),YT=!1,Ro,oy,uy;[].keys&&(uy=[].keys(),"next"in uy?(oy=JT(JT(uy)),oy!==Object.prototype&&(Ro=oy)):YT=!0);var az=!rz(Ro)||ez(function(){var t={};return Ro[sy].call(t)!==t});az&&(Ro={}),tz(Ro[sy])||nz(Ro,sy,function(){return this});var QT={IteratorPrototype:Ro,BUGGY_SAFARI_ITERATORS:YT},sz=QT.IteratorPrototype,oz=ps,uz=yo,lz=ea,cz=ed,dz=function(){return this},XT=function(t,e,r,n){var i=e+" Iterator";return t.prototype=oz(sz,{next:uz(+!n,r)}),lz(t,i,!1),cz[i]=dz,t},fz=er,hz=Er,eE=Nc,pz=Cr,vz=XT,tE=nd,rE=Mu,mz=ea,gz=Ea,ly=Rn,yz=Rr,bz=ed,nE=QT,wz=eE.PROPER,_z=eE.CONFIGURABLE,iE=nE.IteratorPrototype,Lh=nE.BUGGY_SAFARI_ITERATORS,id=yz("iterator"),aE="keys",ad="values",sE="entries",kz=function(){return this},cy=function(t,e,r,n,i,a,s){vz(r,e,n);var o=function(z){if(z===i&&f)return f;if(!Lh&&z&&z in c)return c[z];switch(z){case aE:return function(){return new r(this,z)};case ad:return function(){return new r(this,z)};case sE:return function(){return new r(this,z)}}return function(){return new r(this)}},u=e+" Iterator",l=!1,c=t.prototype,d=c[id]||c["@@iterator"]||i&&c[i],f=!Lh&&d||o(i),m=e==="Array"&&c.entries||d,b,A,N;if(m&&(b=tE(m.call(new t)),b!==Object.prototype&&b.next&&(tE(b)!==iE&&(rE?rE(b,iE):pz(b[id])||ly(b,id,kz)),mz(b,u,!0))),wz&&i===ad&&d&&d.name!==ad&&(_z?gz(c,"name",ad):(l=!0,f=function(){return hz(d,this)})),i)if(A={values:o(ad),keys:a?f:o(aE),entries:o(sE)},s)for(N in A)(Lh||l||!(N in c))&&ly(c,N,A[N]);else fz({target:e,proto:!0,forced:Lh||l},A);return c[id]!==f&&ly(c,id,f,{name:i}),bz[e]=f,A},Dh=function(t,e){return{value:t,done:e}},Sz=iy.charAt,$z=rn,oE=Jn,Tz=cy,uE=Dh,lE="String Iterator",Ez=oE.set,Cz=oE.getterFor(lE);Tz(String,"String",function(t){Ez(this,{type:lE,string:$z(t),index:0})},function(){var e=Cz(this),r=e.string,n=e.index,i;return n>=r.length?uE(void 0,!0):(i=Sz(r,n),e.index+=i.length,uE(i,!1))});var cE={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(ln,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],a={},s=null;function o(A,N){var z=A[N];if(typeof z.bind=="function")return z.bind(A);try{return Function.prototype.bind.call(z,A)}catch{return function(){return Function.prototype.apply.apply(z,[A,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(A){return A==="debug"&&(A="log"),typeof console===r?!1:A==="trace"&&n?u:console[A]!==void 0?o(console,A):console.log!==void 0?o(console,"log"):e}function c(){for(var A=this.getLevel(),N=0;N<i.length;N++){var z=i[N];this[z]=N<A?e:this.methodFactory(z,A,this.name)}if(this.log=this.debug,typeof console===r&&A<this.levels.SILENT)return"No console available for logging"}function d(A){return function(){typeof console!==r&&(c.call(this),this[A].apply(this,arguments))}}function f(A,N,z){return l(A)||d.apply(this,arguments)}function m(A,N){var z=this,X,Ee,Ie,Be="loglevel";typeof A=="string"?Be+=":"+A:typeof A=="symbol"&&(Be=void 0);function Oe(se){var Te=(i[se]||"silent").toUpperCase();if(!(typeof window===r||!Be)){try{window.localStorage[Be]=Te;return}catch{}try{window.document.cookie=encodeURIComponent(Be)+"="+Te+";"}catch{}}}function ze(){var se;if(!(typeof window===r||!Be)){try{se=window.localStorage[Be]}catch{}if(typeof se===r)try{var Te=window.document.cookie,re=encodeURIComponent(Be),oe=Te.indexOf(re+"=");oe!==-1&&(se=/^([^;]+)/.exec(Te.slice(oe+re.length+1))[1])}catch{}return z.levels[se]===void 0&&(se=void 0),se}}function V(){if(!(typeof window===r||!Be)){try{window.localStorage.removeItem(Be)}catch{}try{window.document.cookie=encodeURIComponent(Be)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function xe(se){var Te=se;if(typeof Te=="string"&&z.levels[Te.toUpperCase()]!==void 0&&(Te=z.levels[Te.toUpperCase()]),typeof Te=="number"&&Te>=0&&Te<=z.levels.SILENT)return Te;throw new TypeError("log.setLevel() called with invalid level: "+se)}z.name=A,z.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},z.methodFactory=N||f,z.getLevel=function(){return Ie??Ee??X},z.setLevel=function(se,Te){return Ie=xe(se),Te!==!1&&Oe(Ie),c.call(z)},z.setDefaultLevel=function(se){Ee=xe(se),ze()||z.setLevel(se,!1)},z.resetLevel=function(){Ie=null,V(),c.call(z)},z.enableAll=function(se){z.setLevel(z.levels.TRACE,se)},z.disableAll=function(se){z.setLevel(z.levels.SILENT,se)},z.rebuild=function(){if(s!==z&&(X=xe(s.getLevel())),c.call(z),s===z)for(var se in a)a[se].rebuild()},X=xe(s?s.getLevel():"WARN");var _e=ze();_e!=null&&(Ie=xe(_e)),c.call(z)}s=new m,s.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=a[N];return z||(z=a[N]=new m(N,s.methodFactory)),z};var b=typeof window!==r?window.log:void 0;return s.noConflict=function(){return typeof window!==r&&window.log===s&&(window.log=b),s},s.getLoggers=function(){return a},s.default=s,s})})(cE);var Hu=cE.exports;const xo="\\d+(?:[\\.,]\\d+)?",Rz=`(${xo}W)`,xz=`(${xo}Y)?(${xo}M)?(${xo}D)?`,Iz=`T(${xo}H)?(${xo}M)?(${xo}S)?`,Az=`P(?:${Rz}|${xz}(?:${Iz})?)`,Oz=["weeks","years","months","days","hours","minutes","seconds"],dy=new RegExp(Az),dE=t=>t.match(dy).slice(1).reduce((e,r,n)=>(e[Oz[n]]=parseFloat(r)||0,e),{}),fy=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return n.setFullYear(n.getFullYear()+t.years),n.setMonth(n.getMonth()+t.months),n.setDate(n.getDate()+t.days),n.setHours(n.getHours()+t.hours),n.setMinutes(n.getMinutes()+t.minutes),n.setMilliseconds(n.getMilliseconds()+t.seconds*1e3),n.setDate(n.getDate()+t.weeks*7),n},fE=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return(fy(t,n).getTime()-n.getTime())/1e3},Pz=oP(Object.freeze(Object.defineProperty({__proto__:null,default:{end:fy,toSeconds:fE,pattern:dy,parse:dE},end:fy,parse:dE,pattern:dy,toSeconds:fE},Symbol.toStringTag,{value:"Module"})));var Mz=Rr,Nz=ps,Lz=Cn.f,hy=Mz("unscopables"),py=Array.prototype;py[hy]===void 0&&Lz(py,hy,{configurable:!0,value:Nz(null)});var vy=function(t){py[hy][t]=!0},Dz=Kn,my=vy,hE=ed,pE=Jn,jz=Cn.f,Uz=cy,jh=Dh,Fz=Ar,vE="Array Iterator",Bz=pE.set,zz=pE.getterFor(vE),mE=Uz(Array,"Array",function(t,e){Bz(this,{type:vE,target:Dz(t),index:0,kind:e})},function(){var t=zz(this),e=t.target,r=t.index++;if(!e||r>=e.length)return t.target=void 0,jh(void 0,!0);switch(t.kind){case"keys":return jh(r,!1);case"values":return jh(e[r],!1)}return jh([r,e[r]],!1)},"values"),gE=hE.Arguments=hE.Array;if(my("keys"),my("values"),my("entries"),Fz&&gE.name!=="values")try{jz(gE,"name",{value:"values"})}catch{}var yE=cr,bE=w$,Hz=k$,sd=mE,wE=Ea,qz=ea,Vz=Rr,gy=Vz("iterator"),yy=sd.values,_E=function(t,e){if(t){if(t[gy]!==yy)try{wE(t,gy,yy)}catch{t[gy]=yy}if(qz(t,e,!0),bE[e]){for(var r in sd)if(t[r]!==sd[r])try{wE(t,r,sd[r])}catch{t[r]=sd[r]}}}};for(var by in bE)_E(yE[by]&&yE[by].prototype,by);_E(Hz,"DOMTokenList");var Wz=Cr,Zz=Lr,kE=Mu,Uh=function(t,e,r){var n,i;return kE&&Wz(n=e.constructor)&&n!==r&&Zz(i=n.prototype)&&i!==r.prototype&&kE(t,i),t},Gz=Kt,Kz=Gz(1 .valueOf),Jz=`
793
+ `})}class HL{constructor(e,r){const n=xf.parse({assistantId:"657acbb4-d23e-487f-9090-4ac9a237b474",...e,config:{...e.config,styles:e.styles||{}}});n.handlers.functionCalls.transferToLiveAgent=zL,n.handlers.functionCalls.showScheduleTourWidget=w3(r.schedulerUrl),n.handlers.enhancedContent.unitList=g3,n.handlers.enhancedContent.photoViewer=m3,this.chatWidget=new v3(n);const i=localStorage.getItem(go(n.config.historyKey));if(i){const{chatWidget:a}=this;(async()=>{try{const s=JSON.parse(i),o="https://five9.ah.inhabit.work",u=s.identity||`customer-${Date.now()}`,l=await fetch(`${o}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:u})});if(!l.ok)throw new Error("Failed to get Twilio token for session restoration");const{token:c}=await l.json(),d=new Gf;await d.initialize({accessToken:c,identity:u,conversationSid:s.conversationSid,tokenRefreshUrl:`${o}/api/twilio/token-refresh`,autoReconnect:!0,logLevel:"info"}),tk(a.api.chatWindow,d)}catch(s){console.error("Failed to restore Twilio session:",s),localStorage.removeItem(go(n.config.historyKey))}})()}}destroy(){this.chatWidget.destroy()}}var rk={},Ic=function(t){return t&&t.Math===Math&&t},cr=Ic(typeof globalThis=="object"&&globalThis)||Ic(typeof window=="object"&&window)||Ic(typeof self=="object"&&self)||Ic(typeof ln=="object"&&ln)||Ic(typeof ln=="object"&&ln)||function(){return this}()||Function("return this")(),$a={},Vt=function(t){try{return!!t()}catch{return!0}},qL=Vt,Ar=!qL(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),VL=Vt,Ac=!VL(function(){var t=(function(){}).bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),WL=Ac,Kf=Function.prototype.call,Er=WL?Kf.bind(Kf):function(){return Kf.apply(Kf,arguments)},Oc={},nk={}.propertyIsEnumerable,ik=Object.getOwnPropertyDescriptor,ZL=ik&&!nk.call({1:2},1);Oc.f=ZL?function(e){var r=ik(this,e);return!!r&&r.enumerable}:nk;var yo=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},ak=Ac,sk=Function.prototype,Sm=sk.call,GL=ak&&sk.bind.bind(Sm,Sm),Kt=ak?GL:function(t){return function(){return Sm.apply(t,arguments)}},ok=Kt,KL=ok({}.toString),JL=ok("".slice),Yi=function(t){return JL(KL(t),8,-1)},YL=Kt,QL=Vt,XL=Yi,$m=Object,eD=YL("".split),Pc=QL(function(){return!$m("z").propertyIsEnumerable(0)})?function(t){return XL(t)==="String"?eD(t,""):$m(t)}:$m,xi=function(t){return t==null},tD=xi,rD=TypeError,Ii=function(t){if(tD(t))throw new rD("Can't call method on "+t);return t},nD=Pc,iD=Ii,Kn=function(t){return nD(iD(t))},Tm=typeof document=="object"&&document.all,Cr=typeof Tm>"u"&&Tm!==void 0?function(t){return typeof t=="function"||t===Tm}:function(t){return typeof t=="function"},aD=Cr,Lr=function(t){return typeof t=="object"?t!==null:aD(t)},Em=cr,sD=Cr,oD=function(t){return sD(t)?t:void 0},Ai=function(t,e){return arguments.length<2?oD(Em[t]):Em[t]&&Em[t][e]},uD=Kt,Ta=uD({}.isPrototypeOf),bo=typeof navigator<"u"&&String(navigator.userAgent)||"",uk=cr,Cm=bo,lk=uk.process,ck=uk.Deno,dk=lk&&lk.versions||ck&&ck.version,fk=dk&&dk.v8,Oi,Jf;fk&&(Oi=fk.split("."),Jf=Oi[0]>0&&Oi[0]<4?1:+(Oi[0]+Oi[1])),!Jf&&Cm&&(Oi=Cm.match(/Edge\/(\d+)/),(!Oi||Oi[1]>=74)&&(Oi=Cm.match(/Chrome\/(\d+)/),Oi&&(Jf=+Oi[1])));var Su=Jf,hk=Su,lD=Vt,cD=cr,dD=cD.String,$u=!!Object.getOwnPropertySymbols&&!lD(function(){var t=Symbol("symbol detection");return!dD(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&hk&&hk<41}),fD=$u,pk=fD&&!Symbol.sham&&typeof Symbol.iterator=="symbol",hD=Ai,pD=Cr,vD=Ta,mD=pk,gD=Object,Tu=mD?function(t){return typeof t=="symbol"}:function(t){var e=hD("Symbol");return pD(e)&&vD(e.prototype,gD(t))},yD=String,wo=function(t){try{return yD(t)}catch{return"Object"}},bD=Cr,wD=wo,_D=TypeError,si=function(t){if(bD(t))return t;throw new _D(wD(t)+" is not a function")},kD=si,SD=xi,_o=function(t,e){var r=t[e];return SD(r)?void 0:kD(r)},Rm=Er,xm=Cr,Im=Lr,$D=TypeError,TD=function(t,e){var r,n;if(e==="string"&&xm(r=t.toString)&&!Im(n=Rm(r,t))||xm(r=t.valueOf)&&!Im(n=Rm(r,t))||e!=="string"&&xm(r=t.toString)&&!Im(n=Rm(r,t)))return n;throw new $D("Can't convert object to primitive value")},vk={exports:{}},mk=!1,gk=cr,ED=Object.defineProperty,Am=function(t,e){try{ED(gk,t,{value:e,configurable:!0,writable:!0})}catch{gk[t]=e}return e},CD=cr,RD=Am,yk="__core-js_shared__",bk=vk.exports=CD[yk]||RD(yk,{});(bk.versions||(bk.versions=[])).push({version:"3.37.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Om=vk.exports,wk=Om,Eu=function(t,e){return wk[t]||(wk[t]=e||{})},xD=Ii,ID=Object,yn=function(t){return ID(xD(t))},AD=Kt,OD=yn,PD=AD({}.hasOwnProperty),Vr=Object.hasOwn||function(e,r){return PD(OD(e),r)},MD=Kt,ND=0,LD=Math.random(),DD=MD(1 .toString),Mc=function(t){return"Symbol("+(t===void 0?"":t)+")_"+DD(++ND+LD,36)},jD=cr,UD=Eu,_k=Vr,FD=Mc,BD=$u,zD=pk,Cu=jD.Symbol,Pm=UD("wks"),HD=zD?Cu.for||Cu:Cu&&Cu.withoutSetter||FD,Rr=function(t){return _k(Pm,t)||(Pm[t]=BD&&_k(Cu,t)?Cu[t]:HD("Symbol."+t)),Pm[t]},qD=Er,kk=Lr,Sk=Tu,VD=_o,WD=TD,ZD=Rr,GD=TypeError,KD=ZD("toPrimitive"),Mm=function(t,e){if(!kk(t)||Sk(t))return t;var r=VD(t,KD),n;if(r){if(e===void 0&&(e="default"),n=qD(r,t,e),!kk(n)||Sk(n))return n;throw new GD("Can't convert object to primitive value")}return e===void 0&&(e="number"),WD(t,e)},JD=Mm,YD=Tu,Yf=function(t){var e=JD(t,"string");return YD(e)?e:e+""},QD=cr,$k=Lr,Nm=QD.document,XD=$k(Nm)&&$k(Nm.createElement),Qf=function(t){return XD?Nm.createElement(t):{}},ej=Ar,tj=Vt,rj=Qf,Tk=!ej&&!tj(function(){return Object.defineProperty(rj("div"),"a",{get:function(){return 7}}).a!==7}),nj=Ar,ij=Er,aj=Oc,sj=yo,oj=Kn,uj=Yf,lj=Vr,cj=Tk,Ek=Object.getOwnPropertyDescriptor;$a.f=nj?Ek:function(e,r){if(e=oj(e),r=uj(r),cj)try{return Ek(e,r)}catch{}if(lj(e,r))return sj(!ij(aj.f,e,r),e[r])};var Cn={},dj=Ar,fj=Vt,Ck=dj&&fj(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),hj=Lr,pj=String,vj=TypeError,Gr=function(t){if(hj(t))return t;throw new vj(pj(t)+" is not an object")},mj=Ar,gj=Tk,yj=Ck,Xf=Gr,Rk=Yf,bj=TypeError,Lm=Object.defineProperty,wj=Object.getOwnPropertyDescriptor,Dm="enumerable",jm="configurable",Um="writable";Cn.f=mj?yj?function(e,r,n){if(Xf(e),r=Rk(r),Xf(n),typeof e=="function"&&r==="prototype"&&"value"in n&&Um in n&&!n[Um]){var i=wj(e,r);i&&i[Um]&&(e[r]=n.value,n={configurable:jm in n?n[jm]:i[jm],enumerable:Dm in n?n[Dm]:i[Dm],writable:!1})}return Lm(e,r,n)}:Lm:function(e,r,n){if(Xf(e),r=Rk(r),Xf(n),gj)try{return Lm(e,r,n)}catch{}if("get"in n||"set"in n)throw new bj("Accessors not supported");return"value"in n&&(e[r]=n.value),e};var _j=Ar,kj=Cn,Sj=yo,Ea=_j?function(t,e,r){return kj.f(t,e,Sj(1,r))}:function(t,e,r){return t[e]=r,t},xk={exports:{}},Fm=Ar,$j=Vr,Ik=Function.prototype,Tj=Fm&&Object.getOwnPropertyDescriptor,Bm=$j(Ik,"name"),Ej=Bm&&(function(){}).name==="something",Cj=Bm&&(!Fm||Fm&&Tj(Ik,"name").configurable),Nc={EXISTS:Bm,PROPER:Ej,CONFIGURABLE:Cj},Rj=Kt,xj=Cr,zm=Om,Ij=Rj(Function.toString);xj(zm.inspectSource)||(zm.inspectSource=function(t){return Ij(t)});var Hm=zm.inspectSource,Aj=cr,Oj=Cr,Ak=Aj.WeakMap,Pj=Oj(Ak)&&/native code/.test(String(Ak)),Mj=Eu,Nj=Mc,Ok=Mj("keys"),eh=function(t){return Ok[t]||(Ok[t]=Nj(t))},Lc={},Lj=Pj,Pk=cr,Dj=Lr,jj=Ea,qm=Vr,Vm=Om,Uj=eh,Fj=Lc,Mk="Object already initialized",Wm=Pk.TypeError,Bj=Pk.WeakMap,th,Dc,rh,zj=function(t){return rh(t)?Dc(t):th(t,{})},Hj=function(t){return function(e){var r;if(!Dj(e)||(r=Dc(e)).type!==t)throw new Wm("Incompatible receiver, "+t+" required");return r}};if(Lj||Vm.state){var Qi=Vm.state||(Vm.state=new Bj);Qi.get=Qi.get,Qi.has=Qi.has,Qi.set=Qi.set,th=function(t,e){if(Qi.has(t))throw new Wm(Mk);return e.facade=t,Qi.set(t,e),e},Dc=function(t){return Qi.get(t)||{}},rh=function(t){return Qi.has(t)}}else{var Ru=Uj("state");Fj[Ru]=!0,th=function(t,e){if(qm(t,Ru))throw new Wm(Mk);return e.facade=t,jj(t,Ru,e),e},Dc=function(t){return qm(t,Ru)?t[Ru]:{}},rh=function(t){return qm(t,Ru)}}var Jn={set:th,get:Dc,has:rh,enforce:zj,getterFor:Hj},Zm=Kt,qj=Vt,Vj=Cr,nh=Vr,Gm=Ar,Wj=Nc.CONFIGURABLE,Zj=Hm,Nk=Jn,Gj=Nk.enforce,Kj=Nk.get,Lk=String,ih=Object.defineProperty,Jj=Zm("".slice),Yj=Zm("".replace),Qj=Zm([].join),Xj=Gm&&!qj(function(){return ih(function(){},"length",{value:8}).length!==8}),eU=String(String).split("String"),tU=xk.exports=function(t,e,r){Jj(Lk(e),0,7)==="Symbol("&&(e="["+Yj(Lk(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!nh(t,"name")||Wj&&t.name!==e)&&(Gm?ih(t,"name",{value:e,configurable:!0}):t.name=e),Xj&&r&&nh(r,"arity")&&t.length!==r.arity&&ih(t,"length",{value:r.arity});try{r&&nh(r,"constructor")&&r.constructor?Gm&&ih(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch{}var n=Gj(t);return nh(n,"source")||(n.source=Qj(eU,typeof e=="string"?e:"")),t};Function.prototype.toString=tU(function(){return Vj(this)&&Kj(this).source||Zj(this)},"toString");var Dk=xk.exports,rU=Cr,nU=Cn,iU=Dk,aU=Am,Rn=function(t,e,r,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:e;if(rU(r)&&iU(r,a,n),n.global)i?t[e]=r:aU(e,r);else{try{n.unsafe?t[e]&&(i=!0):delete t[e]}catch{}i?t[e]=r:nU.f(t,e,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return t},ko={},sU=Math.ceil,oU=Math.floor,uU=Math.trunc||function(e){var r=+e;return(r>0?oU:sU)(r)},lU=uU,Xi=function(t){var e=+t;return e!==e||e===0?0:lU(e)},cU=Xi,dU=Math.max,fU=Math.min,xu=function(t,e){var r=cU(t);return r<0?dU(r+e,0):fU(r,e)},hU=Xi,pU=Math.min,Ca=function(t){var e=hU(t);return e>0?pU(e,9007199254740991):0},vU=Ca,bn=function(t){return vU(t.length)},mU=Kn,gU=xu,yU=bn,jk=function(t){return function(e,r,n){var i=mU(e),a=yU(i);if(a===0)return!t&&-1;var s=gU(n,a),o;if(t&&r!==r){for(;a>s;)if(o=i[s++],o!==o)return!0}else for(;a>s;s++)if((t||s in i)&&i[s]===r)return t||s||0;return!t&&-1}},ah={includes:jk(!0),indexOf:jk(!1)},bU=Kt,Km=Vr,wU=Kn,_U=ah.indexOf,kU=Lc,Uk=bU([].push),Fk=function(t,e){var r=wU(t),n=0,i=[],a;for(a in r)!Km(kU,a)&&Km(r,a)&&Uk(i,a);for(;e.length>n;)Km(r,a=e[n++])&&(~_U(i,a)||Uk(i,a));return i},Jm=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],SU=Fk,$U=Jm,TU=$U.concat("length","prototype");ko.f=Object.getOwnPropertyNames||function(e){return SU(e,TU)};var jc={};jc.f=Object.getOwnPropertySymbols;var EU=Ai,CU=Kt,RU=ko,xU=jc,IU=Gr,AU=CU([].concat),Bk=EU("Reflect","ownKeys")||function(e){var r=RU.f(IU(e)),n=xU.f;return n?AU(r,n(e)):r},zk=Vr,OU=Bk,PU=$a,MU=Cn,Ym=function(t,e,r){for(var n=OU(e),i=MU.f,a=PU.f,s=0;s<n.length;s++){var o=n[s];!zk(t,o)&&!(r&&zk(r,o))&&i(t,o,a(e,o))}},NU=Vt,LU=Cr,DU=/#|\.prototype\./,Uc=function(t,e){var r=UU[jU(t)];return r===BU?!0:r===FU?!1:LU(e)?NU(e):!!e},jU=Uc.normalize=function(t){return String(t).replace(DU,".").toLowerCase()},UU=Uc.data={},FU=Uc.NATIVE="N",BU=Uc.POLYFILL="P",sh=Uc,oh=cr,zU=$a.f,HU=Ea,qU=Rn,VU=Am,WU=Ym,ZU=sh,er=function(t,e){var r=t.target,n=t.global,i=t.stat,a,s,o,u,l,c;if(n?s=oh:i?s=oh[r]||VU(r,{}):s=oh[r]&&oh[r].prototype,s)for(o in e){if(l=e[o],t.dontCallGetSet?(c=zU(s,o),u=c&&c.value):u=s[o],a=ZU(n?o:r+(i?".":"#")+o,t.forced),!a&&u!==void 0){if(typeof l==typeof u)continue;WU(l,u)}(t.sham||u&&u.sham)&&HU(l,"sham",!0),qU(s,o,l,t)}},GU=Cn.f,KU=Vr,JU=Rr,Hk=JU("toStringTag"),ea=function(t,e,r){t&&!r&&(t=t.prototype),t&&!KU(t,Hk)&&GU(t,Hk,{configurable:!0,value:e})},YU=er,QU=cr,XU=ea;YU({global:!0},{Reflect:{}}),XU(QU.Reflect,"Reflect",!0);var e5=Ac,qk=Function.prototype,Vk=qk.apply,Wk=qk.call,So=typeof Reflect=="object"&&Reflect.apply||(e5?Wk.bind(Vk):function(){return Wk.apply(Vk,arguments)}),t5=Kt,ta=t5([].slice),Zk=Kt,r5=si,n5=Lr,i5=Vr,Gk=ta,a5=Ac,Kk=Function,s5=Zk([].concat),o5=Zk([].join),Qm={},u5=function(t,e,r){if(!i5(Qm,e)){for(var n=[],i=0;i<e;i++)n[i]="a["+i+"]";Qm[e]=Kk("C,a","return new C("+o5(n,",")+")")}return Qm[e](t,r)},l5=a5?Kk.bind:function(e){var r=r5(this),n=r.prototype,i=Gk(arguments,1),a=function(){var o=s5(i,Gk(arguments));return this instanceof a?u5(r,o.length,o):r.apply(e,o)};return n5(n)&&(a.prototype=n),a},c5=Rr,d5=c5("toStringTag"),Jk={};Jk[d5]="z";var Xm=String(Jk)==="[object z]",f5=Xm,h5=Cr,uh=Yi,p5=Rr,v5=p5("toStringTag"),m5=Object,g5=uh(function(){return arguments}())==="Arguments",y5=function(t,e){try{return t[e]}catch{}},Ra=f5?uh:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=y5(e=m5(t),v5))=="string"?r:g5?uh(e):(n=uh(e))==="Object"&&h5(e.callee)?"Arguments":n},b5=Kt,w5=Vt,Yk=Cr,_5=Ra,k5=Ai,S5=Hm,Qk=function(){},Xk=k5("Reflect","construct"),eg=/^\s*(?:class|function)\b/,$5=b5(eg.exec),T5=!eg.test(Qk),Fc=function(e){if(!Yk(e))return!1;try{return Xk(Qk,[],e),!0}catch{return!1}},eS=function(e){if(!Yk(e))return!1;switch(_5(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return T5||!!$5(eg,S5(e))}catch{return!0}};eS.sham=!0;var lh=!Xk||w5(function(){var t;return Fc(Fc.call)||!Fc(Object)||!Fc(function(){t=!0})||t})?eS:Fc,E5=lh,C5=wo,R5=TypeError,tg=function(t){if(E5(t))return t;throw new R5(C5(t)+" is not a constructor")},rg={},x5=Fk,I5=Jm,Bc=Object.keys||function(e){return x5(e,I5)},A5=Ar,O5=Ck,P5=Cn,M5=Gr,N5=Kn,L5=Bc;rg.f=A5&&!O5?Object.defineProperties:function(e,r){M5(e);for(var n=N5(r),i=L5(r),a=i.length,s=0,o;a>s;)P5.f(e,o=i[s++],n[o]);return e};var D5=Ai,tS=D5("document","documentElement"),j5=Gr,U5=rg,rS=Jm,F5=Lc,B5=tS,z5=Qf,H5=eh,nS=">",iS="<",ng="prototype",ig="script",aS=H5("IE_PROTO"),ag=function(){},sS=function(t){return iS+ig+nS+t+iS+"/"+ig+nS},oS=function(t){t.write(sS("")),t.close();var e=t.parentWindow.Object;return t=null,e},q5=function(){var t=z5("iframe"),e="java"+ig+":",r;return t.style.display="none",B5.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(sS("document.F=Object")),r.close(),r.F},ch,dh=function(){try{ch=new ActiveXObject("htmlfile")}catch{}dh=typeof document<"u"?document.domain&&ch?oS(ch):q5():oS(ch);for(var t=rS.length;t--;)delete dh[ng][rS[t]];return dh()};F5[aS]=!0;var ps=Object.create||function(e,r){var n;return e!==null?(ag[ng]=j5(e),n=new ag,ag[ng]=null,n[aS]=e):n=dh(),r===void 0?n:U5.f(n,r)},V5=er,W5=Ai,sg=So,Z5=l5,uS=tg,G5=Gr,lS=Lr,K5=ps,cS=Vt,og=W5("Reflect","construct"),J5=Object.prototype,Y5=[].push,dS=cS(function(){function t(){}return!(og(function(){},[],t)instanceof t)}),fS=!cS(function(){og(function(){})}),hS=dS||fS;V5({target:"Reflect",stat:!0,forced:hS,sham:hS},{construct:function(e,r){uS(e),G5(r);var n=arguments.length<3?e:uS(arguments[2]);if(fS&&!dS)return og(e,r,n);if(e===n){switch(r.length){case 0:return new e;case 1:return new e(r[0]);case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[1],r[2]);case 4:return new e(r[0],r[1],r[2],r[3])}var i=[null];return sg(Y5,i,r),new(sg(Z5,e,i))}var a=n.prototype,s=K5(lS(a)?a:J5),o=sg(e,s,r);return lS(o)?o:s}});var Q5=er,X5=yn,pS=Bc,e6=Vt,t6=e6(function(){pS(1)});Q5({target:"Object",stat:!0,forced:t6},{keys:function(e){return pS(X5(e))}});var r6=Ra,n6=String,rn=function(t){if(r6(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return n6(t)},ug={},i6=Yi,a6=Kn,vS=ko.f,s6=ta,mS=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],o6=function(t){try{return vS(t)}catch{return s6(mS)}};ug.f=function(e){return mS&&i6(e)==="Window"?o6(e):vS(a6(e))};var gS=Dk,u6=Cn,ra=function(t,e,r){return r.get&&gS(r.get,e,{getter:!0}),r.set&&gS(r.set,e,{setter:!0}),u6.f(t,e,r)},lg={},l6=Rr;lg.f=l6;var c6=cr,yS=c6,bS=yS,d6=Vr,f6=lg,h6=Cn.f,wS=function(t){var e=bS.Symbol||(bS.Symbol={});d6(e,t)||h6(e,t,{value:f6.f(t)})},p6=Er,v6=Ai,m6=Rr,g6=Rn,y6=function(){var t=v6("Symbol"),e=t&&t.prototype,r=e&&e.valueOf,n=m6("toPrimitive");e&&!e[n]&&g6(e,n,function(i){return p6(r,this)},{arity:1})},b6=Yi,w6=Kt,cg=function(t){if(b6(t)==="Function")return w6(t)},_S=cg,_6=si,k6=Ac,S6=_S(_S.bind),xa=function(t,e){return _6(t),e===void 0?t:k6?S6(t,e):function(){return t.apply(e,arguments)}},$6=Yi,zc=Array.isArray||function(e){return $6(e)==="Array"},kS=zc,T6=lh,E6=Lr,C6=Rr,R6=C6("species"),SS=Array,x6=function(t){var e;return kS(t)&&(e=t.constructor,T6(e)&&(e===SS||kS(e.prototype))?e=void 0:E6(e)&&(e=e[R6],e===null&&(e=void 0))),e===void 0?SS:e},I6=x6,dg=function(t,e){return new(I6(t))(e===0?0:e)},A6=xa,O6=Kt,P6=Pc,M6=yn,N6=bn,L6=dg,$S=O6([].push),vs=function(t){var e=t===1,r=t===2,n=t===3,i=t===4,a=t===6,s=t===7,o=t===5||a;return function(u,l,c,d){for(var f=M6(u),m=P6(f),b=N6(m),A=A6(l,c),N=0,z=d||L6,X=e?z(u,b):r||s?z(u,0):void 0,Ee,Ie;b>N;N++)if((o||N in m)&&(Ee=m[N],Ie=A(Ee,N,f),t))if(e)X[N]=Ie;else if(Ie)switch(t){case 3:return!0;case 5:return Ee;case 6:return N;case 2:$S(X,Ee)}else switch(t){case 4:return!1;case 7:$S(X,Ee)}return a?-1:n||i?i:X}},Un={forEach:vs(0),map:vs(1),filter:vs(2),some:vs(3),every:vs(4),find:vs(5),findIndex:vs(6),filterReject:vs(7)},fh=er,Hc=cr,fg=Er,D6=Kt,Iu=Ar,Au=$u,j6=Vt,fn=Vr,U6=Ta,hg=Gr,hh=Kn,pg=Yf,F6=rn,vg=yo,Ou=ps,TS=Bc,B6=ko,ES=ug,z6=jc,CS=$a,RS=Cn,H6=rg,xS=Oc,mg=Rn,q6=ra,gg=Eu,V6=eh,IS=Lc,AS=Mc,W6=Rr,Z6=lg,G6=wS,K6=y6,J6=ea,OS=Jn,ph=Un.forEach,Fn=V6("hidden"),vh="Symbol",qc="prototype",Y6=OS.set,PS=OS.getterFor(vh),oi=Object[qc],$o=Hc.Symbol,Vc=$o&&$o[qc],Q6=Hc.RangeError,X6=Hc.TypeError,yg=Hc.QObject,MS=CS.f,To=RS.f,NS=ES.f,eF=xS.f,LS=D6([].push),Ia=gg("symbols"),Wc=gg("op-symbols"),tF=gg("wks"),bg=!yg||!yg[qc]||!yg[qc].findChild,DS=function(t,e,r){var n=MS(oi,e);n&&delete oi[e],To(t,e,r),n&&t!==oi&&To(oi,e,n)},wg=Iu&&j6(function(){return Ou(To({},"a",{get:function(){return To(this,"a",{value:7}).a}})).a!==7})?DS:To,_g=function(t,e){var r=Ia[t]=Ou(Vc);return Y6(r,{type:vh,tag:t,description:e}),Iu||(r.description=e),r},mh=function(e,r,n){e===oi&&mh(Wc,r,n),hg(e);var i=pg(r);return hg(n),fn(Ia,i)?(n.enumerable?(fn(e,Fn)&&e[Fn][i]&&(e[Fn][i]=!1),n=Ou(n,{enumerable:vg(0,!1)})):(fn(e,Fn)||To(e,Fn,vg(1,Ou(null))),e[Fn][i]=!0),wg(e,i,n)):To(e,i,n)},kg=function(e,r){hg(e);var n=hh(r),i=TS(n).concat(FS(n));return ph(i,function(a){(!Iu||fg(Sg,n,a))&&mh(e,a,n[a])}),e},rF=function(e,r){return r===void 0?Ou(e):kg(Ou(e),r)},Sg=function(e){var r=pg(e),n=fg(eF,this,r);return this===oi&&fn(Ia,r)&&!fn(Wc,r)?!1:n||!fn(this,r)||!fn(Ia,r)||fn(this,Fn)&&this[Fn][r]?n:!0},jS=function(e,r){var n=hh(e),i=pg(r);if(!(n===oi&&fn(Ia,i)&&!fn(Wc,i))){var a=MS(n,i);return a&&fn(Ia,i)&&!(fn(n,Fn)&&n[Fn][i])&&(a.enumerable=!0),a}},US=function(e){var r=NS(hh(e)),n=[];return ph(r,function(i){!fn(Ia,i)&&!fn(IS,i)&&LS(n,i)}),n},FS=function(t){var e=t===oi,r=NS(e?Wc:hh(t)),n=[];return ph(r,function(i){fn(Ia,i)&&(!e||fn(oi,i))&&LS(n,Ia[i])}),n};Au||($o=function(){if(U6(Vc,this))throw new X6("Symbol is not a constructor");var e=!arguments.length||arguments[0]===void 0?void 0:F6(arguments[0]),r=AS(e),n=function(i){var a=this===void 0?Hc:this;a===oi&&fg(n,Wc,i),fn(a,Fn)&&fn(a[Fn],r)&&(a[Fn][r]=!1);var s=vg(1,i);try{wg(a,r,s)}catch(o){if(!(o instanceof Q6))throw o;DS(a,r,s)}};return Iu&&bg&&wg(oi,r,{configurable:!0,set:n}),_g(r,e)},Vc=$o[qc],mg(Vc,"toString",function(){return PS(this).tag}),mg($o,"withoutSetter",function(t){return _g(AS(t),t)}),xS.f=Sg,RS.f=mh,H6.f=kg,CS.f=jS,B6.f=ES.f=US,z6.f=FS,Z6.f=function(t){return _g(W6(t),t)},Iu&&(q6(Vc,"description",{configurable:!0,get:function(){return PS(this).description}}),mg(oi,"propertyIsEnumerable",Sg,{unsafe:!0}))),fh({global:!0,constructor:!0,wrap:!0,forced:!Au,sham:!Au},{Symbol:$o}),ph(TS(tF),function(t){G6(t)}),fh({target:vh,stat:!0,forced:!Au},{useSetter:function(){bg=!0},useSimple:function(){bg=!1}}),fh({target:"Object",stat:!0,forced:!Au,sham:!Iu},{create:rF,defineProperty:mh,defineProperties:kg,getOwnPropertyDescriptor:jS}),fh({target:"Object",stat:!0,forced:!Au},{getOwnPropertyNames:US}),K6(),J6($o,vh),IS[Fn]=!0;var nF=$u,BS=nF&&!!Symbol.for&&!!Symbol.keyFor,iF=er,aF=Ai,sF=Vr,oF=rn,zS=Eu,uF=BS,$g=zS("string-to-symbol-registry"),lF=zS("symbol-to-string-registry");iF({target:"Symbol",stat:!0,forced:!uF},{for:function(t){var e=oF(t);if(sF($g,e))return $g[e];var r=aF("Symbol")(e);return $g[e]=r,lF[r]=e,r}});var cF=er,dF=Vr,fF=Tu,hF=wo,pF=Eu,vF=BS,HS=pF("symbol-to-string-registry");cF({target:"Symbol",stat:!0,forced:!vF},{keyFor:function(e){if(!fF(e))throw new TypeError(hF(e)+" is not a symbol");if(dF(HS,e))return HS[e]}});var mF=Kt,qS=zc,gF=Cr,VS=Yi,yF=rn,WS=mF([].push),bF=function(t){if(gF(t))return t;if(qS(t)){for(var e=t.length,r=[],n=0;n<e;n++){var i=t[n];typeof i=="string"?WS(r,i):(typeof i=="number"||VS(i)==="Number"||VS(i)==="String")&&WS(r,yF(i))}var a=r.length,s=!0;return function(o,u){if(s)return s=!1,u;if(qS(this))return u;for(var l=0;l<a;l++)if(r[l]===o)return u}}},wF=er,ZS=Ai,GS=So,_F=Er,Zc=Kt,KS=Vt,JS=Cr,YS=Tu,QS=ta,kF=bF,SF=$u,$F=String,ms=ZS("JSON","stringify"),gh=Zc(/./.exec),XS=Zc("".charAt),TF=Zc("".charCodeAt),EF=Zc("".replace),CF=Zc(1 .toString),RF=/[\uD800-\uDFFF]/g,e$=/^[\uD800-\uDBFF]$/,t$=/^[\uDC00-\uDFFF]$/,r$=!SF||KS(function(){var t=ZS("Symbol")("stringify detection");return ms([t])!=="[null]"||ms({a:t})!=="{}"||ms(Object(t))!=="{}"}),n$=KS(function(){return ms("\uDF06\uD834")!=='"\\udf06\\ud834"'||ms("\uDEAD")!=='"\\udead"'}),xF=function(t,e){var r=QS(arguments),n=kF(e);if(!(!JS(n)&&(t===void 0||YS(t))))return r[1]=function(i,a){if(JS(n)&&(a=_F(n,this,$F(i),a)),!YS(a))return a},GS(ms,null,r)},IF=function(t,e,r){var n=XS(r,e-1),i=XS(r,e+1);return gh(e$,t)&&!gh(t$,i)||gh(t$,t)&&!gh(e$,n)?"\\u"+CF(TF(t,0),16):t};ms&&wF({target:"JSON",stat:!0,arity:3,forced:r$||n$},{stringify:function(e,r,n){var i=QS(arguments),a=GS(r$?xF:ms,null,i);return n$&&typeof a=="string"?EF(a,RF,IF):a}});var AF=er,OF=$u,PF=Vt,i$=jc,MF=yn,NF=!OF||PF(function(){i$.f(1)});AF({target:"Object",stat:!0,forced:NF},{getOwnPropertySymbols:function(e){var r=i$.f;return r?r(MF(e)):[]}});var LF=Vt,DF=Rr,jF=Su,UF=DF("species"),Gc=function(t){return jF>=51||!LF(function(){var e=[],r=e.constructor={};return r[UF]=function(){return{foo:1}},e[t](Boolean).foo!==1})},FF=er,BF=Un.filter,zF=Gc,HF=zF("filter");FF({target:"Array",proto:!0,forced:!HF},{filter:function(e){return BF(this,e,arguments.length>1?arguments[1]:void 0)}});var qF=er,VF=Vt,WF=Kn,a$=$a.f,s$=Ar,ZF=!s$||VF(function(){a$(1)});qF({target:"Object",stat:!0,forced:ZF,sham:!s$},{getOwnPropertyDescriptor:function(e,r){return a$(WF(e),r)}});var GF=Ar,KF=Cn,JF=yo,Kc=function(t,e,r){GF?KF.f(t,e,JF(0,r)):t[e]=r},YF=er,QF=Ar,XF=Bk,eB=Kn,tB=$a,rB=Kc;YF({target:"Object",stat:!0,sham:!QF},{getOwnPropertyDescriptors:function(e){for(var r=eB(e),n=tB.f,i=XF(r),a={},s=0,o,u;i.length>s;)u=n(r,o=i[s++]),u!==void 0&&rB(a,o,u);return a}});var o$={exports:{}};(function(t){function e(n,i,a,s,o,u,l){try{var c=n[u](l),d=c.value}catch(f){return void a(f)}c.done?i(d):Promise.resolve(d).then(s,o)}function r(n){return function(){var i=this,a=arguments;return new Promise(function(s,o){var u=n.apply(i,a);function l(d){e(u,s,o,l,c,"next",d)}function c(d){e(u,s,o,l,c,"throw",d)}l(void 0)})}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(o$);var Pu=o$.exports,u$={exports:{}};(function(t){function e(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(u$);var gs=u$.exports,l$={exports:{}},c$={exports:{}};(function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,a){return i.__proto__=a,i},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(c$);var Tg=c$.exports;(function(t){var e=Tg;function r(n,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),i&&e(n,i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(l$);var na=l$.exports,d$={exports:{}},f$={exports:{}};(function(t){function e(r){"@babel/helpers - typeof";return t.exports=e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(f$);var ui=f$.exports;(function(t){var e=ui.default,r=gs;function n(i,a){if(a&&(e(a)=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(d$);var ia=d$.exports,h$={exports:{}};(function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(h$);var li=h$.exports,p$={exports:{}},v$={exports:{}},m$={exports:{}};(function(t){var e=ui.default;function r(n,i){if(e(n)!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var s=a.call(n,i||"default");if(e(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(m$);var nB=m$.exports;(function(t){var e=ui.default,r=nB;function n(i){var a=r(i,"string");return e(a)=="symbol"?a:a+""}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(v$);var g$=v$.exports;(function(t){var e=g$;function r(n,i,a){return(i=e(i))in n?Object.defineProperty(n,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[i]=a,n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(p$);var ys=p$.exports,y$={exports:{}};(function(t){var e=g$;function r(i,a){for(var s=0;s<a.length;s++){var o=a[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(i,e(o.key),o)}}function n(i,a,s){return a&&r(i.prototype,a),s&&r(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(y$);var Aa=y$.exports,b$={exports:{}};(function(t){function e(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(b$);var aa=b$.exports,iB=er,aB=Un.map,sB=Gc,oB=sB("map");iB({target:"Array",proto:!0,forced:!oB},{map:function(e){return aB(this,e,arguments.length>1?arguments[1]:void 0)}});var uB=Xm,lB=Ra,cB=uB?{}.toString:function(){return"[object "+lB(this)+"]"},dB=Xm,fB=Rn,hB=cB;dB||fB(Object.prototype,"toString",hB,{unsafe:!0});var w$={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},pB=Qf,Eg=pB("span").classList,_$=Eg&&Eg.constructor&&Eg.constructor.prototype,k$=_$===Object.prototype?void 0:_$,vB=Vt,yh=function(t,e){var r=[][t];return!!r&&vB(function(){r.call(null,e||function(){return 1},1)})},mB=Un.forEach,gB=yh,yB=gB("forEach"),bB=yB?[].forEach:function(e){return mB(this,e,arguments.length>1?arguments[1]:void 0)},S$=cr,$$=w$,wB=k$,Cg=bB,_B=Ea,T$=function(t){if(t&&t.forEach!==Cg)try{_B(t,"forEach",Cg)}catch{t.forEach=Cg}};for(var Rg in $$)$$[Rg]&&T$(S$[Rg]&&S$[Rg].prototype);T$(wB);var kB=cr,SB=Yi,bh=SB(kB.process)==="process",$B=Kt,TB=si,EB=function(t,e,r){try{return $B(TB(Object.getOwnPropertyDescriptor(t,e)[r]))}catch{}},CB=Lr,RB=function(t){return CB(t)||t===null},xB=RB,IB=String,AB=TypeError,OB=function(t){if(xB(t))return t;throw new AB("Can't set "+IB(t)+" as a prototype")},PB=EB,MB=Lr,NB=Ii,LB=OB,Mu=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=PB(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch{}return function(i,a){return NB(i),LB(a),MB(i)&&(t?r(i,a):i.__proto__=a),i}}():void 0),DB=Ai,jB=ra,UB=Rr,FB=Ar,E$=UB("species"),wh=function(t){var e=DB(t);FB&&e&&!e[E$]&&jB(e,E$,{configurable:!0,get:function(){return this}})},BB=Ta,zB=TypeError,bs=function(t,e){if(BB(e,t))return t;throw new zB("Incorrect invocation")},C$=Gr,HB=tg,qB=xi,VB=Rr,WB=VB("species"),xg=function(t,e){var r=C$(t).constructor,n;return r===void 0||qB(n=C$(r)[WB])?e:HB(n)},ZB=TypeError,Ig=function(t,e){if(t<e)throw new ZB("Not enough arguments");return t},GB=bo,R$=/(?:ipad|iphone|ipod).*applewebkit/i.test(GB),Yn=cr,KB=So,JB=xa,x$=Cr,YB=Vr,I$=Vt,A$=tS,QB=ta,O$=Qf,XB=Ig,e8=R$,t8=bh,Ag=Yn.setImmediate,Og=Yn.clearImmediate,r8=Yn.process,Pg=Yn.Dispatch,n8=Yn.Function,P$=Yn.MessageChannel,i8=Yn.String,Mg=0,Jc={},M$="onreadystatechange",Yc,Eo,Ng,Lg;I$(function(){Yc=Yn.location});var Dg=function(t){if(YB(Jc,t)){var e=Jc[t];delete Jc[t],e()}},jg=function(t){return function(){Dg(t)}},N$=function(t){Dg(t.data)},L$=function(t){Yn.postMessage(i8(t),Yc.protocol+"//"+Yc.host)};(!Ag||!Og)&&(Ag=function(e){XB(arguments.length,1);var r=x$(e)?e:n8(e),n=QB(arguments,1);return Jc[++Mg]=function(){KB(r,void 0,n)},Eo(Mg),Mg},Og=function(e){delete Jc[e]},t8?Eo=function(t){r8.nextTick(jg(t))}:Pg&&Pg.now?Eo=function(t){Pg.now(jg(t))}:P$&&!e8?(Ng=new P$,Lg=Ng.port2,Ng.port1.onmessage=N$,Eo=JB(Lg.postMessage,Lg)):Yn.addEventListener&&x$(Yn.postMessage)&&!Yn.importScripts&&Yc&&Yc.protocol!=="file:"&&!I$(L$)?(Eo=L$,Yn.addEventListener("message",N$,!1)):M$ in O$("script")?Eo=function(t){A$.appendChild(O$("script"))[M$]=function(){A$.removeChild(this),Dg(t)}}:Eo=function(t){setTimeout(jg(t),0)});var D$={set:Ag,clear:Og},j$=cr,a8=Ar,s8=Object.getOwnPropertyDescriptor,U$=function(t){if(!a8)return j$[t];var e=s8(j$,t);return e&&e.value},F$=function(){this.head=null,this.tail=null};F$.prototype={add:function(t){var e={item:t,next:null},r=this.tail;r?r.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t){var e=this.head=t.next;return e===null&&(this.tail=null),t.item}}};var B$=F$,o8=bo,u8=/ipad|iphone|ipod/i.test(o8)&&typeof Pebble<"u",l8=bo,c8=/web0s(?!.*chrome)/i.test(l8),Nu=cr,d8=U$,z$=xa,Ug=D$.set,f8=B$,h8=R$,p8=u8,v8=c8,Fg=bh,H$=Nu.MutationObserver||Nu.WebKitMutationObserver,q$=Nu.document,V$=Nu.process,_h=Nu.Promise,Bg=d8("queueMicrotask"),Lu,zg,Hg,kh,W$;if(!Bg){var Sh=new f8,$h=function(){var t,e;for(Fg&&(t=V$.domain)&&t.exit();e=Sh.get();)try{e()}catch(r){throw Sh.head&&Lu(),r}t&&t.enter()};!h8&&!Fg&&!v8&&H$&&q$?(zg=!0,Hg=q$.createTextNode(""),new H$($h).observe(Hg,{characterData:!0}),Lu=function(){Hg.data=zg=!zg}):!p8&&_h&&_h.resolve?(kh=_h.resolve(void 0),kh.constructor=_h,W$=z$(kh.then,kh),Lu=function(){W$($h)}):Fg?Lu=function(){V$.nextTick($h)}:(Ug=z$(Ug,Nu),Lu=function(){Ug($h)}),Bg=function(t){Sh.head||Lu(),Sh.add(t)}}var m8=Bg,g8=function(t,e){try{arguments.length===1?console.error(t):console.error(t,e)}catch{}},qg=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}},y8=cr,Th=y8.Promise,Z$=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",b8=Z$,w8=bh,_8=!b8&&!w8&&typeof window=="object"&&typeof document=="object",k8=cr,Qc=Th,S8=Cr,$8=sh,T8=Hm,E8=Rr,C8=_8,R8=Z$,Vg=Su;Qc&&Qc.prototype;var x8=E8("species"),Wg=!1,G$=S8(k8.PromiseRejectionEvent),I8=$8("Promise",function(){var t=T8(Qc),e=t!==String(Qc);if(!e&&Vg===66)return!0;if(!Vg||Vg<51||!/native code/.test(t)){var r=new Qc(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=r.constructor={};if(i[x8]=n,Wg=r.then(function(){})instanceof n,!Wg)return!0}return!e&&(C8||R8)&&!G$}),Xc={CONSTRUCTOR:I8,REJECTION_EVENT:G$,SUBCLASSING:Wg},Du={},K$=si,A8=TypeError,O8=function(t){var e,r;this.promise=new t(function(n,i){if(e!==void 0||r!==void 0)throw new A8("Bad Promise constructor");e=n,r=i}),this.resolve=K$(e),this.reject=K$(r)};Du.f=function(t){return new O8(t)};var P8=er,Eh=bh,ws=cr,ju=Er,J$=Rn,Y$=Mu,M8=ea,N8=wh,L8=si,Ch=Cr,D8=Lr,j8=bs,U8=xg,Q$=D$.set,Zg=m8,F8=g8,B8=qg,z8=B$,X$=Jn,Rh=Th,Gg=Xc,eT=Du,xh="Promise",tT=Gg.CONSTRUCTOR,H8=Gg.REJECTION_EVENT,q8=Gg.SUBCLASSING,Kg=X$.getterFor(xh),V8=X$.set,Uu=Rh&&Rh.prototype,Co=Rh,Ih=Uu,rT=ws.TypeError,Jg=ws.document,Yg=ws.process,Qg=eT.f,W8=Qg,Z8=!!(Jg&&Jg.createEvent&&ws.dispatchEvent),nT="unhandledrejection",G8="rejectionhandled",iT=0,aT=1,K8=2,Xg=1,sT=2,Ah,oT,J8,uT,lT=function(t){var e;return D8(t)&&Ch(e=t.then)?e:!1},cT=function(t,e){var r=e.value,n=e.state===aT,i=n?t.ok:t.fail,a=t.resolve,s=t.reject,o=t.domain,u,l,c;try{i?(n||(e.rejection===sT&&Q8(e),e.rejection=Xg),i===!0?u=r:(o&&o.enter(),u=i(r),o&&(o.exit(),c=!0)),u===t.promise?s(new rT("Promise-chain cycle")):(l=lT(u))?ju(l,u,a,s):a(u)):s(r)}catch(d){o&&!c&&o.exit(),s(d)}},dT=function(t,e){t.notified||(t.notified=!0,Zg(function(){for(var r=t.reactions,n;n=r.get();)cT(n,t);t.notified=!1,e&&!t.rejection&&Y8(t)}))},fT=function(t,e,r){var n,i;Z8?(n=Jg.createEvent("Event"),n.promise=e,n.reason=r,n.initEvent(t,!1,!0),ws.dispatchEvent(n)):n={promise:e,reason:r},!H8&&(i=ws["on"+t])?i(n):t===nT&&F8("Unhandled promise rejection",r)},Y8=function(t){ju(Q$,ws,function(){var e=t.facade,r=t.value,n=hT(t),i;if(n&&(i=B8(function(){Eh?Yg.emit("unhandledRejection",r,e):fT(nT,e,r)}),t.rejection=Eh||hT(t)?sT:Xg,i.error))throw i.value})},hT=function(t){return t.rejection!==Xg&&!t.parent},Q8=function(t){ju(Q$,ws,function(){var e=t.facade;Eh?Yg.emit("rejectionHandled",e):fT(G8,e,t.value)})},Fu=function(t,e,r){return function(n){t(e,n,r)}},Bu=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=K8,dT(t,!0))},ey=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw new rT("Promise can't be resolved itself");var n=lT(e);n?Zg(function(){var i={done:!1};try{ju(n,e,Fu(ey,i,t),Fu(Bu,i,t))}catch(a){Bu(i,a,t)}}):(t.value=e,t.state=aT,dT(t,!1))}catch(i){Bu({done:!1},i,t)}}};if(tT&&(Co=function(e){j8(this,Ih),L8(e),ju(Ah,this);var r=Kg(this);try{e(Fu(ey,r),Fu(Bu,r))}catch(n){Bu(r,n)}},Ih=Co.prototype,Ah=function(e){V8(this,{type:xh,done:!1,notified:!1,parent:!1,reactions:new z8,rejection:!1,state:iT,value:void 0})},Ah.prototype=J$(Ih,"then",function(e,r){var n=Kg(this),i=Qg(U8(this,Co));return n.parent=!0,i.ok=Ch(e)?e:!0,i.fail=Ch(r)&&r,i.domain=Eh?Yg.domain:void 0,n.state===iT?n.reactions.add(i):Zg(function(){cT(i,n)}),i.promise}),oT=function(){var t=new Ah,e=Kg(t);this.promise=t,this.resolve=Fu(ey,e),this.reject=Fu(Bu,e)},eT.f=Qg=function(t){return t===Co||t===J8?new oT(t):W8(t)},Ch(Rh)&&Uu!==Object.prototype)){uT=Uu.then,q8||J$(Uu,"then",function(e,r){var n=this;return new Co(function(i,a){ju(uT,n,i,a)}).then(e,r)},{unsafe:!0});try{delete Uu.constructor}catch{}Y$&&Y$(Uu,Ih)}P8({global:!0,constructor:!0,wrap:!0,forced:tT},{Promise:Co}),M8(Co,xh,!1),N8(xh);var ed={},X8=Rr,e9=ed,t9=X8("iterator"),r9=Array.prototype,ty=function(t){return t!==void 0&&(e9.Array===t||r9[t9]===t)},n9=Ra,pT=_o,i9=xi,a9=ed,s9=Rr,o9=s9("iterator"),td=function(t){if(!i9(t))return pT(t,o9)||pT(t,"@@iterator")||a9[n9(t)]},u9=Er,l9=si,c9=Gr,d9=wo,f9=td,h9=TypeError,Oh=function(t,e){var r=arguments.length<2?f9(t):e;if(l9(r))return c9(u9(r,t));throw new h9(d9(t)+" is not iterable")},p9=Er,vT=Gr,v9=_o,mT=function(t,e,r){var n,i;vT(t);try{if(n=v9(t,"return"),!n){if(e==="throw")throw r;return r}n=p9(n,t)}catch(a){i=!0,n=a}if(e==="throw")throw r;if(i)throw n;return vT(n),r},m9=xa,g9=Er,y9=Gr,b9=wo,w9=ty,_9=bn,gT=Ta,k9=Oh,S9=td,yT=mT,$9=TypeError,Ph=function(t,e){this.stopped=t,this.result=e},bT=Ph.prototype,rd=function(t,e,r){var n=r&&r.that,i=!!(r&&r.AS_ENTRIES),a=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),o=!!(r&&r.INTERRUPTED),u=m9(e,n),l,c,d,f,m,b,A,N=function(X){return l&&yT(l,"normal",X),new Ph(!0,X)},z=function(X){return i?(y9(X),o?u(X[0],X[1],N):u(X[0],X[1])):o?u(X,N):u(X)};if(a)l=t.iterator;else if(s)l=t;else{if(c=S9(t),!c)throw new $9(b9(t)+" is not iterable");if(w9(c)){for(d=0,f=_9(t);f>d;d++)if(m=z(t[d]),m&&gT(bT,m))return m;return new Ph(!1)}l=k9(t,c)}for(b=a?t.next:l.next;!(A=g9(b,l)).done;){try{m=z(A.value)}catch(X){yT(l,"throw",X)}if(typeof m=="object"&&m&&gT(bT,m))return m}return new Ph(!1)},T9=Rr,wT=T9("iterator"),_T=!1;try{var E9=0,kT={next:function(){return{done:!!E9++}},return:function(){_T=!0}};kT[wT]=function(){return this},Array.from(kT,function(){throw 2})}catch{}var Mh=function(t,e){try{if(!e&&!_T)return!1}catch{return!1}var r=!1;try{var n={};n[wT]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch{}return r},C9=Th,R9=Mh,x9=Xc.CONSTRUCTOR,ST=x9||!R9(function(t){C9.all(t).then(void 0,function(){})}),I9=er,A9=Er,O9=si,P9=Du,M9=qg,N9=rd,L9=ST;I9({target:"Promise",stat:!0,forced:L9},{all:function(e){var r=this,n=P9.f(r),i=n.resolve,a=n.reject,s=M9(function(){var o=O9(r.resolve),u=[],l=0,c=1;N9(e,function(d){var f=l++,m=!1;c++,A9(o,r,d).then(function(b){m||(m=!0,u[f]=b,--c||i(u))},a)}),--c||i(u)});return s.error&&a(s.value),n.promise}});var D9=er,j9=Xc.CONSTRUCTOR,ry=Th,U9=Ai,F9=Cr,B9=Rn,$T=ry&&ry.prototype;if(D9({target:"Promise",proto:!0,forced:j9,real:!0},{catch:function(t){return this.then(void 0,t)}}),F9(ry)){var TT=U9("Promise").prototype.catch;$T.catch!==TT&&B9($T,"catch",TT,{unsafe:!0})}var z9=er,H9=Er,q9=si,V9=Du,W9=qg,Z9=rd,G9=ST;z9({target:"Promise",stat:!0,forced:G9},{race:function(e){var r=this,n=V9.f(r),i=n.reject,a=W9(function(){var s=q9(r.resolve);Z9(e,function(o){H9(s,r,o).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var K9=er,J9=Du,Y9=Xc.CONSTRUCTOR;K9({target:"Promise",stat:!0,forced:Y9},{reject:function(e){var r=J9.f(this),n=r.reject;return n(e),r.promise}});var Q9=Gr,X9=Lr,e7=Du,t7=function(t,e){if(Q9(t),X9(e)&&e.constructor===t)return e;var r=e7.f(t),n=r.resolve;return n(e),r.promise},r7=er,n7=Ai,i7=Xc.CONSTRUCTOR,a7=t7;n7("Promise"),r7({target:"Promise",stat:!0,forced:i7},{resolve:function(e){return a7(this,e)}});var ET={exports:{}},CT={exports:{}};(function(t){function e(r,n){this.v=r,this.k=n}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(CT);var RT=CT.exports,xT={exports:{}},IT={exports:{}};(function(t){function e(r,n,i,a){var s=Object.defineProperty;try{s({},"",{})}catch{s=0}t.exports=e=function(u,l,c,d){function f(m,b){e(u,m,function(A){return this._invoke(m,b,A)})}l?s?s(u,l,{value:c,enumerable:!d,configurable:!d,writable:!d}):u[l]=c:(f("next",0),f("throw",1),f("return",2))},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n,i,a)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(IT);var AT=IT.exports;(function(t){var e=AT;function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var n,i,a=typeof Symbol=="function"?Symbol:{},s=a.iterator||"@@iterator",o=a.toStringTag||"@@toStringTag";function u(N,z,X,Ee){var Ie=z&&z.prototype instanceof c?z:c,Fe=Object.create(Ie.prototype);return e(Fe,"_invoke",function(Oe,ze,V){var xe,_e,se,Te=0,re=V||[],oe=!1,q={p:0,n:0,v:n,a:ne,f:ne.bind(n,4),d:function(H,ye){return xe=H,_e=0,se=n,q.n=ye,l}};function ne(Se,H){for(_e=Se,se=H,i=0;!oe&&Te&&!ye&&i<re.length;i++){var ye,ke=re[i],M=q.p,Xe=ke[2];Se>3?(ye=Xe===H)&&(se=ke[(_e=ke[4])?5:(_e=3,3)],ke[4]=ke[5]=n):ke[0]<=M&&((ye=Se<2&&M<ke[1])?(_e=0,q.v=H,q.n=ke[1]):M<Xe&&(ye=Se<3||ke[0]>H||H>Xe)&&(ke[4]=Se,ke[5]=H,q.n=Xe,_e=0))}if(ye||Se>1)return l;throw oe=!0,H}return function(Se,H,ye){if(Te>1)throw TypeError("Generator is already running");for(oe&&H===1&&ne(H,ye),_e=H,se=ye;(i=_e<2?n:se)||!oe;){xe||(_e?_e<3?(_e>1&&(q.n=-1),ne(_e,se)):q.n=se:q.v=se);try{if(Te=2,xe){if(_e||(Se="next"),i=xe[Se]){if(!(i=i.call(xe,se)))throw TypeError("iterator result is not an object");if(!i.done)return i;se=i.value,_e<2&&(_e=0)}else _e===1&&(i=xe.return)&&i.call(xe),_e<2&&(se=TypeError("The iterator does not provide a '"+Se+"' method"),_e=1);xe=n}else if((i=(oe=q.n<0)?se:Oe.call(ze,q))!==l)break}catch(ke){xe=n,_e=1,se=ke}finally{Te=1}}return{value:i,done:oe}}}(N,X,Ee),!0),Fe}var l={};function c(){}function d(){}function f(){}i=Object.getPrototypeOf;var m=[][s]?i(i([][s]())):(e(i={},s,function(){return this}),i),b=f.prototype=c.prototype=Object.create(m);function A(N){return Object.setPrototypeOf?Object.setPrototypeOf(N,f):(N.__proto__=f,e(N,o,"GeneratorFunction")),N.prototype=Object.create(b),N}return d.prototype=f,e(b,"constructor",f),e(f,"constructor",d),d.displayName="GeneratorFunction",e(f,o,"GeneratorFunction"),e(b),e(b,o,"Generator"),e(b,s,function(){return this}),e(b,"toString",function(){return"[object Generator]"}),(t.exports=r=function(){return{w:u,m:A}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(xT);var OT=xT.exports,PT={exports:{}},MT={exports:{}},NT={exports:{}};(function(t){var e=RT,r=AT;function n(i,a){function s(u,l,c,d){try{var f=i[u](l),m=f.value;return m instanceof e?a.resolve(m.v).then(function(b){s("next",b,c,d)},function(b){s("throw",b,c,d)}):a.resolve(m).then(function(b){f.value=b,c(f)},function(b){return s("throw",b,c,d)})}catch(b){d(b)}}var o;this.next||(r(n.prototype),r(n.prototype,typeof Symbol=="function"&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(u,l,c){function d(){return new a(function(f,m){s(u,c,f,m)})}return o=o?o.then(d,d):d()},!0)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(NT);var LT=NT.exports;(function(t){var e=OT,r=LT;function n(i,a,s,o,u){return new r(e().w(i,a,s,o),u||Promise)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(MT);var DT=MT.exports;(function(t){var e=DT;function r(n,i,a,s,o){var u=e(n,i,a,s,o);return u.next().then(function(l){return l.done?l.value:u.next()})}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(PT);var s7=PT.exports,jT={exports:{}};(function(t){function e(r){var n=Object(r),i=[];for(var a in n)i.unshift(a);return function s(){for(;i.length;)if((a=i.pop())in n)return s.value=a,s.done=!1,s;return s.done=!0,s}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(jT);var o7=jT.exports,UT={exports:{}};(function(t){var e=ui.default;function r(n){if(n!=null){var i=n[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],a=0;if(i)return i.call(n);if(typeof n.next=="function")return n;if(!isNaN(n.length))return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}}}throw new TypeError(e(n)+" is not iterable")}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(UT);var u7=UT.exports;(function(t){var e=RT,r=OT,n=s7,i=DT,a=LT,s=o7,o=u7;function u(){var l=r(),c=l.m(u),d=(Object.getPrototypeOf?Object.getPrototypeOf(c):c.__proto__).constructor;function f(A){var N=typeof A=="function"&&A.constructor;return!!N&&(N===d||(N.displayName||N.name)==="GeneratorFunction")}var m={throw:1,return:2,break:3,continue:3};function b(A){var N,z;return function(X){N||(N={stop:function(){return z(X.a,2)},catch:function(){return X.v},abrupt:function(Ie,Fe){return z(X.a,m[Ie],Fe)},delegateYield:function(Ie,Fe,Oe){return N.resultName=Fe,z(X.d,o(Ie),Oe)},finish:function(Ie){return z(X.f,Ie)}},z=function(Ie,Fe,Oe){X.p=N.prev,X.n=N.next;try{return Ie(Fe,Oe)}finally{N.next=X.n}}),N.resultName&&(N[N.resultName]=X.v,N.resultName=void 0),N.sent=X.v,N.next=X.n;try{return A.call(this,N)}finally{X.p=N.prev,X.n=N.next}}}return(t.exports=u=function(){return{wrap:function(z,X,Ee,Ie){return l.w(b(z),X,Ee,Ie&&Ie.reverse())},isGeneratorFunction:f,mark:l.m,awrap:function(z,X){return new e(z,X)},AsyncIterator:a,async:function(z,X,Ee,Ie,Fe){return(f(X)?i:n)(b(z),X,Ee,Ie,Fe)},keys:s,values:o}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=u,t.exports.__esModule=!0,t.exports.default=t.exports})(ET);var l7=ET.exports,Nh=l7(),zu=Nh;try{regeneratorRuntime=Nh}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=Nh:Function("r","regeneratorRuntime = r")(Nh)}var c7=TypeError,d7=9007199254740991,FT=function(t){if(t>d7)throw c7("Maximum allowed index exceeded");return t},f7=er,h7=Vt,p7=zc,v7=Lr,m7=yn,g7=bn,BT=FT,zT=Kc,y7=dg,b7=Gc,w7=Rr,_7=Su,HT=w7("isConcatSpreadable"),k7=_7>=51||!h7(function(){var t=[];return t[HT]=!1,t.concat()[0]!==t}),S7=function(t){if(!v7(t))return!1;var e=t[HT];return e!==void 0?!!e:p7(t)},$7=!k7||!b7("concat");f7({target:"Array",proto:!0,arity:1,forced:$7},{concat:function(e){var r=m7(this),n=y7(r,0),i=0,a,s,o,u,l;for(a=-1,o=arguments.length;a<o;a++)if(l=a===-1?r:arguments[a],S7(l))for(u=g7(l),BT(i+u),s=0;s<u;s++,i++)s in l&&zT(n,i,l[s]);else BT(i+1),zT(n,i++,l);return n.length=i,n}});var T7=Gr,E7=mT,C7=function(t,e,r,n){try{return n?e(T7(r)[0],r[1]):e(r)}catch(i){E7(t,"throw",i)}},R7=xa,x7=Er,I7=yn,A7=C7,O7=ty,P7=lh,M7=bn,qT=Kc,N7=Oh,L7=td,VT=Array,WT=function(e){var r=I7(e),n=P7(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=R7(a,i>2?arguments[2]:void 0));var o=L7(r),u=0,l,c,d,f,m,b;if(o&&!(this===VT&&O7(o)))for(c=n?new this:[],f=N7(r,o),m=f.next;!(d=x7(m,f)).done;u++)b=s?A7(f,a,[d.value,u],!0):d.value,qT(c,u,b);else for(l=M7(r),c=n?new this(l):VT(l);l>u;u++)b=s?a(r[u],u):r[u],qT(c,u,b);return c.length=u,c},D7=er,j7=WT,U7=Mh,F7=!U7(function(t){Array.from(t)});D7({target:"Array",stat:!0,forced:F7},{from:j7});var ny=Kt,B7=Xi,z7=rn,H7=Ii,q7=ny("".charAt),ZT=ny("".charCodeAt),V7=ny("".slice),GT=function(t){return function(e,r){var n=z7(H7(e)),i=B7(r),a=n.length,s,o;return i<0||i>=a?t?"":void 0:(s=ZT(n,i),s<55296||s>56319||i+1===a||(o=ZT(n,i+1))<56320||o>57343?t?q7(n,i):s:t?V7(n,i,i+2):(s-55296<<10)+(o-56320)+65536)}},iy={codeAt:GT(!1),charAt:GT(!0)},W7=Vt,Z7=!W7(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),G7=Vr,K7=Cr,J7=yn,Y7=eh,Q7=Z7,KT=Y7("IE_PROTO"),ay=Object,X7=ay.prototype,nd=Q7?ay.getPrototypeOf:function(t){var e=J7(t);if(G7(e,KT))return e[KT];var r=e.constructor;return K7(r)&&e instanceof r?r.prototype:e instanceof ay?X7:null},ez=Vt,tz=Cr,rz=Lr,JT=nd,nz=Rn,iz=Rr,sy=iz("iterator"),YT=!1,Ro,oy,uy;[].keys&&(uy=[].keys(),"next"in uy?(oy=JT(JT(uy)),oy!==Object.prototype&&(Ro=oy)):YT=!0);var az=!rz(Ro)||ez(function(){var t={};return Ro[sy].call(t)!==t});az&&(Ro={}),tz(Ro[sy])||nz(Ro,sy,function(){return this});var QT={IteratorPrototype:Ro,BUGGY_SAFARI_ITERATORS:YT},sz=QT.IteratorPrototype,oz=ps,uz=yo,lz=ea,cz=ed,dz=function(){return this},XT=function(t,e,r,n){var i=e+" Iterator";return t.prototype=oz(sz,{next:uz(+!n,r)}),lz(t,i,!1),cz[i]=dz,t},fz=er,hz=Er,eE=Nc,pz=Cr,vz=XT,tE=nd,rE=Mu,mz=ea,gz=Ea,ly=Rn,yz=Rr,bz=ed,nE=QT,wz=eE.PROPER,_z=eE.CONFIGURABLE,iE=nE.IteratorPrototype,Lh=nE.BUGGY_SAFARI_ITERATORS,id=yz("iterator"),aE="keys",ad="values",sE="entries",kz=function(){return this},cy=function(t,e,r,n,i,a,s){vz(r,e,n);var o=function(z){if(z===i&&f)return f;if(!Lh&&z&&z in c)return c[z];switch(z){case aE:return function(){return new r(this,z)};case ad:return function(){return new r(this,z)};case sE:return function(){return new r(this,z)}}return function(){return new r(this)}},u=e+" Iterator",l=!1,c=t.prototype,d=c[id]||c["@@iterator"]||i&&c[i],f=!Lh&&d||o(i),m=e==="Array"&&c.entries||d,b,A,N;if(m&&(b=tE(m.call(new t)),b!==Object.prototype&&b.next&&(tE(b)!==iE&&(rE?rE(b,iE):pz(b[id])||ly(b,id,kz)),mz(b,u,!0))),wz&&i===ad&&d&&d.name!==ad&&(_z?gz(c,"name",ad):(l=!0,f=function(){return hz(d,this)})),i)if(A={values:o(ad),keys:a?f:o(aE),entries:o(sE)},s)for(N in A)(Lh||l||!(N in c))&&ly(c,N,A[N]);else fz({target:e,proto:!0,forced:Lh||l},A);return c[id]!==f&&ly(c,id,f,{name:i}),bz[e]=f,A},Dh=function(t,e){return{value:t,done:e}},Sz=iy.charAt,$z=rn,oE=Jn,Tz=cy,uE=Dh,lE="String Iterator",Ez=oE.set,Cz=oE.getterFor(lE);Tz(String,"String",function(t){Ez(this,{type:lE,string:$z(t),index:0})},function(){var e=Cz(this),r=e.string,n=e.index,i;return n>=r.length?uE(void 0,!0):(i=Sz(r,n),e.index+=i.length,uE(i,!1))});var cE={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(ln,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],a={},s=null;function o(A,N){var z=A[N];if(typeof z.bind=="function")return z.bind(A);try{return Function.prototype.bind.call(z,A)}catch{return function(){return Function.prototype.apply.apply(z,[A,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(A){return A==="debug"&&(A="log"),typeof console===r?!1:A==="trace"&&n?u:console[A]!==void 0?o(console,A):console.log!==void 0?o(console,"log"):e}function c(){for(var A=this.getLevel(),N=0;N<i.length;N++){var z=i[N];this[z]=N<A?e:this.methodFactory(z,A,this.name)}if(this.log=this.debug,typeof console===r&&A<this.levels.SILENT)return"No console available for logging"}function d(A){return function(){typeof console!==r&&(c.call(this),this[A].apply(this,arguments))}}function f(A,N,z){return l(A)||d.apply(this,arguments)}function m(A,N){var z=this,X,Ee,Ie,Fe="loglevel";typeof A=="string"?Fe+=":"+A:typeof A=="symbol"&&(Fe=void 0);function Oe(se){var Te=(i[se]||"silent").toUpperCase();if(!(typeof window===r||!Fe)){try{window.localStorage[Fe]=Te;return}catch{}try{window.document.cookie=encodeURIComponent(Fe)+"="+Te+";"}catch{}}}function ze(){var se;if(!(typeof window===r||!Fe)){try{se=window.localStorage[Fe]}catch{}if(typeof se===r)try{var Te=window.document.cookie,re=encodeURIComponent(Fe),oe=Te.indexOf(re+"=");oe!==-1&&(se=/^([^;]+)/.exec(Te.slice(oe+re.length+1))[1])}catch{}return z.levels[se]===void 0&&(se=void 0),se}}function V(){if(!(typeof window===r||!Fe)){try{window.localStorage.removeItem(Fe)}catch{}try{window.document.cookie=encodeURIComponent(Fe)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function xe(se){var Te=se;if(typeof Te=="string"&&z.levels[Te.toUpperCase()]!==void 0&&(Te=z.levels[Te.toUpperCase()]),typeof Te=="number"&&Te>=0&&Te<=z.levels.SILENT)return Te;throw new TypeError("log.setLevel() called with invalid level: "+se)}z.name=A,z.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},z.methodFactory=N||f,z.getLevel=function(){return Ie??Ee??X},z.setLevel=function(se,Te){return Ie=xe(se),Te!==!1&&Oe(Ie),c.call(z)},z.setDefaultLevel=function(se){Ee=xe(se),ze()||z.setLevel(se,!1)},z.resetLevel=function(){Ie=null,V(),c.call(z)},z.enableAll=function(se){z.setLevel(z.levels.TRACE,se)},z.disableAll=function(se){z.setLevel(z.levels.SILENT,se)},z.rebuild=function(){if(s!==z&&(X=xe(s.getLevel())),c.call(z),s===z)for(var se in a)a[se].rebuild()},X=xe(s?s.getLevel():"WARN");var _e=ze();_e!=null&&(Ie=xe(_e)),c.call(z)}s=new m,s.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=a[N];return z||(z=a[N]=new m(N,s.methodFactory)),z};var b=typeof window!==r?window.log:void 0;return s.noConflict=function(){return typeof window!==r&&window.log===s&&(window.log=b),s},s.getLoggers=function(){return a},s.default=s,s})})(cE);var Hu=cE.exports;const xo="\\d+(?:[\\.,]\\d+)?",Rz=`(${xo}W)`,xz=`(${xo}Y)?(${xo}M)?(${xo}D)?`,Iz=`T(${xo}H)?(${xo}M)?(${xo}S)?`,Az=`P(?:${Rz}|${xz}(?:${Iz})?)`,Oz=["weeks","years","months","days","hours","minutes","seconds"],dy=new RegExp(Az),dE=t=>t.match(dy).slice(1).reduce((e,r,n)=>(e[Oz[n]]=parseFloat(r)||0,e),{}),fy=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return n.setFullYear(n.getFullYear()+t.years),n.setMonth(n.getMonth()+t.months),n.setDate(n.getDate()+t.days),n.setHours(n.getHours()+t.hours),n.setMinutes(n.getMinutes()+t.minutes),n.setMilliseconds(n.getMilliseconds()+t.seconds*1e3),n.setDate(n.getDate()+t.weeks*7),n},fE=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return(fy(t,n).getTime()-n.getTime())/1e3},Pz=oP(Object.freeze(Object.defineProperty({__proto__:null,default:{end:fy,toSeconds:fE,pattern:dy,parse:dE},end:fy,parse:dE,pattern:dy,toSeconds:fE},Symbol.toStringTag,{value:"Module"})));var Mz=Rr,Nz=ps,Lz=Cn.f,hy=Mz("unscopables"),py=Array.prototype;py[hy]===void 0&&Lz(py,hy,{configurable:!0,value:Nz(null)});var vy=function(t){py[hy][t]=!0},Dz=Kn,my=vy,hE=ed,pE=Jn,jz=Cn.f,Uz=cy,jh=Dh,Fz=Ar,vE="Array Iterator",Bz=pE.set,zz=pE.getterFor(vE),mE=Uz(Array,"Array",function(t,e){Bz(this,{type:vE,target:Dz(t),index:0,kind:e})},function(){var t=zz(this),e=t.target,r=t.index++;if(!e||r>=e.length)return t.target=void 0,jh(void 0,!0);switch(t.kind){case"keys":return jh(r,!1);case"values":return jh(e[r],!1)}return jh([r,e[r]],!1)},"values"),gE=hE.Arguments=hE.Array;if(my("keys"),my("values"),my("entries"),Fz&&gE.name!=="values")try{jz(gE,"name",{value:"values"})}catch{}var yE=cr,bE=w$,Hz=k$,sd=mE,wE=Ea,qz=ea,Vz=Rr,gy=Vz("iterator"),yy=sd.values,_E=function(t,e){if(t){if(t[gy]!==yy)try{wE(t,gy,yy)}catch{t[gy]=yy}if(qz(t,e,!0),bE[e]){for(var r in sd)if(t[r]!==sd[r])try{wE(t,r,sd[r])}catch{t[r]=sd[r]}}}};for(var by in bE)_E(yE[by]&&yE[by].prototype,by);_E(Hz,"DOMTokenList");var Wz=Cr,Zz=Lr,kE=Mu,Uh=function(t,e,r){var n,i;return kE&&Wz(n=e.constructor)&&n!==r&&Zz(i=n.prototype)&&i!==r.prototype&&kE(t,i),t},Gz=Kt,Kz=Gz(1 .valueOf),Jz=`
794
794
  \v\f\r                 \u2028\u2029\uFEFF`,Yz=Kt,Qz=Ii,Xz=rn,wy=Jz,SE=Yz("".replace),eH=RegExp("^["+wy+"]+"),tH=RegExp("(^|[^"+wy+"])["+wy+"]+$"),_y=function(t){return function(e){var r=Xz(Qz(e));return t&1&&(r=SE(r,eH,"")),t&2&&(r=SE(r,tH,"$1")),r}},rH={start:_y(1),end:_y(2),trim:_y(3)},nH=er,$E=mk,iH=Ar,TE=cr,EE=yS,CE=Kt,aH=sh,RE=Vr,sH=Uh,oH=Ta,uH=Tu,xE=Mm,lH=Vt,cH=ko.f,dH=$a.f,fH=Cn.f,hH=Kz,pH=rH.trim,Fh="Number",qu=TE[Fh];EE[Fh];var ky=qu.prototype,vH=TE.TypeError,mH=CE("".slice),Bh=CE("".charCodeAt),gH=function(t){var e=xE(t,"number");return typeof e=="bigint"?e:yH(e)},yH=function(t){var e=xE(t,"number"),r,n,i,a,s,o,u,l;if(uH(e))throw new vH("Cannot convert a Symbol value to a number");if(typeof e=="string"&&e.length>2){if(e=pH(e),r=Bh(e,0),r===43||r===45){if(n=Bh(e,2),n===88||n===120)return NaN}else if(r===48){switch(Bh(e,1)){case 66:case 98:i=2,a=49;break;case 79:case 111:i=8,a=55;break;default:return+e}for(s=mH(e,2),o=s.length,u=0;u<o;u++)if(l=Bh(s,u),l<48||l>a)return NaN;return parseInt(s,i)}}return+e},Sy=aH(Fh,!qu(" 0o1")||!qu("0b1")||qu("+0x1")),bH=function(t){return oH(ky,t)&&lH(function(){hH(t)})},zh=function(e){var r=arguments.length<1?0:qu(gH(e));return bH(this)?sH(Object(r),this,zh):r};zh.prototype=ky,Sy&&!$E&&(ky.constructor=zh),nH({global:!0,constructor:!0,wrap:!0,forced:Sy},{Number:zh});var wH=function(t,e){for(var r=iH?cH(e):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),n=0,i;r.length>n;n++)RE(e,i=r[n])&&!RE(t,i)&&fH(t,i,dH(e,i))};(Sy||$E)&&wH(EE[Fh],qu);var _H=Gr,IE=function(){var t=_H(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e},$y=Vt,kH=cr,Ty=kH.RegExp,Ey=$y(function(){var t=Ty("a","y");return t.lastIndex=2,t.exec("abcd")!==null}),SH=Ey||$y(function(){return!Ty("a","y").sticky}),$H=Ey||$y(function(){var t=Ty("^r","gy");return t.lastIndex=2,t.exec("str")!==null}),AE={BROKEN_CARET:$H,MISSED_STICKY:SH,UNSUPPORTED_Y:Ey},TH=Vt,EH=cr,CH=EH.RegExp,RH=TH(function(){var t=CH(".","s");return!(t.dotAll&&t.test(`
795
795
  `)&&t.flags==="s")}),xH=Vt,IH=cr,AH=IH.RegExp,OH=xH(function(){var t=AH("(?<a>b)","g");return t.exec("b").groups.a!=="b"||"b".replace(t,"$<a>c")!=="bc"}),Vu=Er,Hh=Kt,PH=rn,MH=IE,NH=AE,LH=Eu,DH=ps,jH=Jn.get,UH=RH,FH=OH,BH=LH("native-string-replace",String.prototype.replace),qh=RegExp.prototype.exec,Cy=qh,zH=Hh("".charAt),HH=Hh("".indexOf),qH=Hh("".replace),Ry=Hh("".slice),xy=function(){var t=/a/,e=/b*/g;return Vu(qh,t,"a"),Vu(qh,e,"a"),t.lastIndex!==0||e.lastIndex!==0}(),OE=NH.BROKEN_CARET,Iy=/()??/.exec("")[1]!==void 0,VH=xy||Iy||OE||UH||FH;VH&&(Cy=function(e){var r=this,n=jH(r),i=PH(e),a=n.raw,s,o,u,l,c,d,f;if(a)return a.lastIndex=r.lastIndex,s=Vu(Cy,a,i),r.lastIndex=a.lastIndex,s;var m=n.groups,b=OE&&r.sticky,A=Vu(MH,r),N=r.source,z=0,X=i;if(b&&(A=qH(A,"y",""),HH(A,"g")===-1&&(A+="g"),X=Ry(i,r.lastIndex),r.lastIndex>0&&(!r.multiline||r.multiline&&zH(i,r.lastIndex-1)!==`
796
- `)&&(N="(?: "+N+")",X=" "+X,z++),o=new RegExp("^(?:"+N+")",A)),Iy&&(o=new RegExp("^"+N+"$(?!\\s)",A)),xy&&(u=r.lastIndex),l=Vu(qh,b?o:r,X),b?l?(l.input=Ry(l.input,z),l[0]=Ry(l[0],z),l.index=r.lastIndex,r.lastIndex+=l[0].length):r.lastIndex=0:xy&&l&&(r.lastIndex=r.global?l.index+l[0].length:u),Iy&&l&&l.length>1&&Vu(BH,l[0],o,function(){for(c=1;c<arguments.length-2;c++)arguments[c]===void 0&&(l[c]=void 0)}),l&&m)for(l.groups=d=DH(null),c=0;c<m.length;c++)f=m[c],d[f[0]]=l[f[1]];return l});var Ay=Cy,WH=er,PE=Ay;WH({target:"RegExp",proto:!0,forced:/./.exec!==PE},{exec:PE});var ME=Er,NE=Rn,ZH=Ay,LE=Vt,DE=Rr,GH=Ea,KH=DE("species"),Oy=RegExp.prototype,Vh=function(t,e,r,n){var i=DE(t),a=!LE(function(){var l={};return l[i]=function(){return 7},""[t](l)!==7}),s=a&&!LE(function(){var l=!1,c=/a/;return t==="split"&&(c={},c.constructor={},c.constructor[KH]=function(){return c},c.flags="",c[i]=/./[i]),c.exec=function(){return l=!0,null},c[i](""),!l});if(!a||!s||r){var o=/./[i],u=e(i,""[t],function(l,c,d,f,m){var b=c.exec;return b===ZH||b===Oy.exec?a&&!m?{done:!0,value:ME(o,c,d,f)}:{done:!0,value:ME(l,d,c,f)}:{done:!1}});NE(String.prototype,t,u[0]),NE(Oy,i,u[1])}n&&GH(Oy[i],"sham",!0)},JH=iy.charAt,Py=function(t,e,r){return e+(r?JH(t,e).length:1)},My=Kt,YH=yn,QH=Math.floor,Ny=My("".charAt),XH=My("".replace),Ly=My("".slice),eq=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,tq=/\$([$&'`]|\d{1,2})/g,rq=function(t,e,r,n,i,a){var s=r+t.length,o=n.length,u=tq;return i!==void 0&&(i=YH(i),u=eq),XH(a,u,function(l,c){var d;switch(Ny(c,0)){case"$":return"$";case"&":return t;case"`":return Ly(e,0,r);case"'":return Ly(e,s);case"<":d=i[Ly(c,1,-1)];break;default:var f=+c;if(f===0)return l;if(f>o){var m=QH(f/10);return m===0?l:m<=o?n[m-1]===void 0?Ny(c,1):n[m-1]+Ny(c,1):l}d=n[f-1]}return d===void 0?"":d})},jE=Er,nq=Gr,iq=Cr,aq=Yi,sq=Ay,oq=TypeError,Wh=function(t,e){var r=t.exec;if(iq(r)){var n=jE(r,t,e);return n!==null&&nq(n),n}if(aq(t)==="RegExp")return jE(sq,t,e);throw new oq("RegExp#exec called on incompatible receiver")},uq=So,UE=Er,Zh=Kt,lq=Vh,cq=Vt,dq=Gr,fq=Cr,hq=xi,pq=Xi,vq=Ca,Wu=rn,mq=Ii,gq=Py,yq=_o,bq=rq,wq=Wh,_q=Rr,Dy=_q("replace"),kq=Math.max,Sq=Math.min,$q=Zh([].concat),jy=Zh([].push),FE=Zh("".indexOf),BE=Zh("".slice),Tq=function(t){return t===void 0?t:String(t)},Eq=function(){return"a".replace(/./,"$0")==="$0"}(),zE=function(){return/./[Dy]?/./[Dy]("a","$0")==="":!1}(),Cq=!cq(function(){var t=/./;return t.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(t,"$<a>")!=="7"});lq("replace",function(t,e,r){var n=zE?"$":"$0";return[function(a,s){var o=mq(this),u=hq(a)?void 0:yq(a,Dy);return u?UE(u,a,o,s):UE(e,Wu(o),a,s)},function(i,a){var s=dq(this),o=Wu(i);if(typeof a=="string"&&FE(a,n)===-1&&FE(a,"$<")===-1){var u=r(e,s,o,a);if(u.done)return u.value}var l=fq(a);l||(a=Wu(a));var c=s.global,d;c&&(d=s.unicode,s.lastIndex=0);for(var f=[],m;m=wq(s,o),!(m===null||(jy(f,m),!c));){var b=Wu(m[0]);b===""&&(s.lastIndex=gq(o,vq(s.lastIndex),d))}for(var A="",N=0,z=0;z<f.length;z++){m=f[z];for(var X=Wu(m[0]),Ee=kq(Sq(pq(m.index),o.length),0),Ie=[],Be,Oe=1;Oe<m.length;Oe++)jy(Ie,Tq(m[Oe]));var ze=m.groups;if(l){var V=$q([X],Ie,Ee,o);ze!==void 0&&jy(V,ze),Be=Wu(uq(a,void 0,V))}else Be=bq(X,o,Ee,Ie,ze,a);Ee>=N&&(A+=BE(o,N,Ee)+Be,N=Ee+X.length)}return A+BE(o,N)}]},!Cq||!Eq||zE);var Rq=er,xq=Kt,Iq=Pc,Aq=Kn,Oq=yh,Pq=xq([].join),Mq=Iq!==Object,Nq=Mq||!Oq("join",",");Rq({target:"Array",proto:!0,forced:Nq},{join:function(e){return Pq(Aq(this),e===void 0?",":e)}});var nn={},Lq=Ar,Dq=Nc.EXISTS,HE=Kt,jq=ra,qE=Function.prototype,Uq=HE(qE.toString),VE=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Fq=HE(VE.exec),Bq="name";Lq&&!Dq&&jq(qE,Bq,{configurable:!0,get:function(){try{return Fq(VE,Uq(this))[1]}catch{return""}}});var WE={exports:{}},ZE={exports:{}};(function(t){function e(r){if(Array.isArray(r))return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(ZE);var zq=ZE.exports,GE={exports:{}};(function(t){function e(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var a,s,o,u,l=[],c=!0,d=!1;try{if(o=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;c=!1}else for(;!(c=(a=o.call(i)).done)&&(l.push(a.value),l.length!==n);c=!0);}catch(f){d=!0,s=f}finally{try{if(!c&&i.return!=null&&(u=i.return(),Object(u)!==u))return}finally{if(d)throw s}}return l}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(GE);var Hq=GE.exports,KE={exports:{}},JE={exports:{}};(function(t){function e(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,a=Array(n);i<n;i++)a[i]=r[i];return a}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(JE);var YE=JE.exports;(function(t){var e=YE;function r(n,i){if(n){if(typeof n=="string")return e(n,i);var a={}.toString.call(n).slice(8,-1);return a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set"?Array.from(n):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(n,i):void 0}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(KE);var QE=KE.exports,XE={exports:{}};(function(t){function e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
796
+ `)&&(N="(?: "+N+")",X=" "+X,z++),o=new RegExp("^(?:"+N+")",A)),Iy&&(o=new RegExp("^"+N+"$(?!\\s)",A)),xy&&(u=r.lastIndex),l=Vu(qh,b?o:r,X),b?l?(l.input=Ry(l.input,z),l[0]=Ry(l[0],z),l.index=r.lastIndex,r.lastIndex+=l[0].length):r.lastIndex=0:xy&&l&&(r.lastIndex=r.global?l.index+l[0].length:u),Iy&&l&&l.length>1&&Vu(BH,l[0],o,function(){for(c=1;c<arguments.length-2;c++)arguments[c]===void 0&&(l[c]=void 0)}),l&&m)for(l.groups=d=DH(null),c=0;c<m.length;c++)f=m[c],d[f[0]]=l[f[1]];return l});var Ay=Cy,WH=er,PE=Ay;WH({target:"RegExp",proto:!0,forced:/./.exec!==PE},{exec:PE});var ME=Er,NE=Rn,ZH=Ay,LE=Vt,DE=Rr,GH=Ea,KH=DE("species"),Oy=RegExp.prototype,Vh=function(t,e,r,n){var i=DE(t),a=!LE(function(){var l={};return l[i]=function(){return 7},""[t](l)!==7}),s=a&&!LE(function(){var l=!1,c=/a/;return t==="split"&&(c={},c.constructor={},c.constructor[KH]=function(){return c},c.flags="",c[i]=/./[i]),c.exec=function(){return l=!0,null},c[i](""),!l});if(!a||!s||r){var o=/./[i],u=e(i,""[t],function(l,c,d,f,m){var b=c.exec;return b===ZH||b===Oy.exec?a&&!m?{done:!0,value:ME(o,c,d,f)}:{done:!0,value:ME(l,d,c,f)}:{done:!1}});NE(String.prototype,t,u[0]),NE(Oy,i,u[1])}n&&GH(Oy[i],"sham",!0)},JH=iy.charAt,Py=function(t,e,r){return e+(r?JH(t,e).length:1)},My=Kt,YH=yn,QH=Math.floor,Ny=My("".charAt),XH=My("".replace),Ly=My("".slice),eq=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,tq=/\$([$&'`]|\d{1,2})/g,rq=function(t,e,r,n,i,a){var s=r+t.length,o=n.length,u=tq;return i!==void 0&&(i=YH(i),u=eq),XH(a,u,function(l,c){var d;switch(Ny(c,0)){case"$":return"$";case"&":return t;case"`":return Ly(e,0,r);case"'":return Ly(e,s);case"<":d=i[Ly(c,1,-1)];break;default:var f=+c;if(f===0)return l;if(f>o){var m=QH(f/10);return m===0?l:m<=o?n[m-1]===void 0?Ny(c,1):n[m-1]+Ny(c,1):l}d=n[f-1]}return d===void 0?"":d})},jE=Er,nq=Gr,iq=Cr,aq=Yi,sq=Ay,oq=TypeError,Wh=function(t,e){var r=t.exec;if(iq(r)){var n=jE(r,t,e);return n!==null&&nq(n),n}if(aq(t)==="RegExp")return jE(sq,t,e);throw new oq("RegExp#exec called on incompatible receiver")},uq=So,UE=Er,Zh=Kt,lq=Vh,cq=Vt,dq=Gr,fq=Cr,hq=xi,pq=Xi,vq=Ca,Wu=rn,mq=Ii,gq=Py,yq=_o,bq=rq,wq=Wh,_q=Rr,Dy=_q("replace"),kq=Math.max,Sq=Math.min,$q=Zh([].concat),jy=Zh([].push),FE=Zh("".indexOf),BE=Zh("".slice),Tq=function(t){return t===void 0?t:String(t)},Eq=function(){return"a".replace(/./,"$0")==="$0"}(),zE=function(){return/./[Dy]?/./[Dy]("a","$0")==="":!1}(),Cq=!cq(function(){var t=/./;return t.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(t,"$<a>")!=="7"});lq("replace",function(t,e,r){var n=zE?"$":"$0";return[function(a,s){var o=mq(this),u=hq(a)?void 0:yq(a,Dy);return u?UE(u,a,o,s):UE(e,Wu(o),a,s)},function(i,a){var s=dq(this),o=Wu(i);if(typeof a=="string"&&FE(a,n)===-1&&FE(a,"$<")===-1){var u=r(e,s,o,a);if(u.done)return u.value}var l=fq(a);l||(a=Wu(a));var c=s.global,d;c&&(d=s.unicode,s.lastIndex=0);for(var f=[],m;m=wq(s,o),!(m===null||(jy(f,m),!c));){var b=Wu(m[0]);b===""&&(s.lastIndex=gq(o,vq(s.lastIndex),d))}for(var A="",N=0,z=0;z<f.length;z++){m=f[z];for(var X=Wu(m[0]),Ee=kq(Sq(pq(m.index),o.length),0),Ie=[],Fe,Oe=1;Oe<m.length;Oe++)jy(Ie,Tq(m[Oe]));var ze=m.groups;if(l){var V=$q([X],Ie,Ee,o);ze!==void 0&&jy(V,ze),Fe=Wu(uq(a,void 0,V))}else Fe=bq(X,o,Ee,Ie,ze,a);Ee>=N&&(A+=BE(o,N,Ee)+Fe,N=Ee+X.length)}return A+BE(o,N)}]},!Cq||!Eq||zE);var Rq=er,xq=Kt,Iq=Pc,Aq=Kn,Oq=yh,Pq=xq([].join),Mq=Iq!==Object,Nq=Mq||!Oq("join",",");Rq({target:"Array",proto:!0,forced:Nq},{join:function(e){return Pq(Aq(this),e===void 0?",":e)}});var nn={},Lq=Ar,Dq=Nc.EXISTS,HE=Kt,jq=ra,qE=Function.prototype,Uq=HE(qE.toString),VE=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Fq=HE(VE.exec),Bq="name";Lq&&!Dq&&jq(qE,Bq,{configurable:!0,get:function(){try{return Fq(VE,Uq(this))[1]}catch{return""}}});var WE={exports:{}},ZE={exports:{}};(function(t){function e(r){if(Array.isArray(r))return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(ZE);var zq=ZE.exports,GE={exports:{}};(function(t){function e(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var a,s,o,u,l=[],c=!0,d=!1;try{if(o=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;c=!1}else for(;!(c=(a=o.call(i)).done)&&(l.push(a.value),l.length!==n);c=!0);}catch(f){d=!0,s=f}finally{try{if(!c&&i.return!=null&&(u=i.return(),Object(u)!==u))return}finally{if(d)throw s}}return l}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(GE);var Hq=GE.exports,KE={exports:{}},JE={exports:{}};(function(t){function e(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,a=Array(n);i<n;i++)a[i]=r[i];return a}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(JE);var YE=JE.exports;(function(t){var e=YE;function r(n,i){if(n){if(typeof n=="string")return e(n,i);var a={}.toString.call(n).slice(8,-1);return a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set"?Array.from(n):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(n,i):void 0}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(KE);var QE=KE.exports,XE={exports:{}};(function(t){function e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
797
797
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(XE);var qq=XE.exports;(function(t){var e=zq,r=Hq,n=QE,i=qq;function a(s,o){return e(s)||r(s,o)||n(s,o)||i()}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(WE);var od=WE.exports,Vq=er,eC=zc,Wq=lh,Zq=Lr,tC=xu,Gq=bn,Kq=Kn,Jq=Kc,Yq=Rr,Qq=Gc,Xq=ta,eV=Qq("slice"),tV=Yq("species"),Uy=Array,rV=Math.max;Vq({target:"Array",proto:!0,forced:!eV},{slice:function(e,r){var n=Kq(this),i=Gq(n),a=tC(e,i),s=tC(r===void 0?i:r,i),o,u,l;if(eC(n)&&(o=n.constructor,Wq(o)&&(o===Uy||eC(o.prototype))?o=void 0:Zq(o)&&(o=o[tV],o===null&&(o=void 0)),o===Uy||o===void 0))return Xq(n,a,s);for(u=new(o===void 0?Uy:o)(rV(s-a,0)),l=0;a<s;a++,l++)a in n&&Jq(u,l,n[a]);return u.length=l,u}});var nV=er,rC=Er,iV=Cr,nC=Gr,aV=rn,sV=function(){var t=!1,e=/[ac]/;return e.exec=function(){return t=!0,/./.exec.apply(this,arguments)},e.test("abc")===!0&&t}(),oV=/./.test;nV({target:"RegExp",proto:!0,forced:!sV},{test:function(t){var e=nC(this),r=aV(t),n=e.exec;if(!iV(n))return rC(oV,e,r);var i=rC(n,e,r);return i===null?!1:(nC(i),!0)}});var uV=er,lV=Ar,cV=cr,Gh=Kt,dV=Vr,fV=Cr,hV=Ta,pV=rn,vV=ra,mV=Ym,Oa=cV.Symbol,Io=Oa&&Oa.prototype;if(lV&&fV(Oa)&&(!("description"in Io)||Oa().description!==void 0)){var iC={},Kh=function(){var e=arguments.length<1||arguments[0]===void 0?void 0:pV(arguments[0]),r=hV(Io,this)?new Oa(e):e===void 0?Oa():Oa(e);return e===""&&(iC[r]=!0),r};mV(Kh,Oa),Kh.prototype=Io,Io.constructor=Kh;var gV=String(Oa("description detection"))==="Symbol(description detection)",yV=Gh(Io.valueOf),bV=Gh(Io.toString),wV=/^Symbol\((.*)\)[^)]+$/,_V=Gh("".replace),kV=Gh("".slice);vV(Io,"description",{configurable:!0,get:function(){var e=yV(this);if(dV(iC,e))return"";var r=bV(e),n=gV?kV(r,7,-1):_V(r,wV,"$1");return n===""?void 0:n}}),uV({global:!0,constructor:!0,forced:!0},{Symbol:Kh})}var SV=wS;SV("iterator");var aC={exports:{}},sC={exports:{}};(function(t){var e=YE;function r(n){if(Array.isArray(n))return e(n)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(sC);var $V=sC.exports,oC={exports:{}};(function(t){function e(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(oC);var TV=oC.exports,uC={exports:{}};(function(t){function e(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
798
798
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(uC);var EV=uC.exports;(function(t){var e=$V,r=TV,n=QE,i=EV;function a(s){return e(s)||r(s)||n(s)||i()}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(aC);var ud=aC.exports,CV=er,RV=ah.includes,xV=Vt,IV=vy,AV=xV(function(){return!Array(1).includes()});CV({target:"Array",proto:!0,forced:AV},{includes:function(e){return RV(this,e,arguments.length>1?arguments[1]:void 0)}}),IV("includes");var OV=Lr,PV=Math.floor,lC=Number.isInteger||function(e){return!OV(e)&&isFinite(e)&&PV(e)===e},MV=er,NV=lC;MV({target:"Number",stat:!0},{isInteger:NV});var cC=Ar,LV=Vt,dC=Kt,DV=nd,jV=Bc,UV=Kn,FV=Oc.f,fC=dC(FV),BV=dC([].push),zV=cC&&LV(function(){var t=Object.create(null);return t[2]=2,!fC(t,2)}),hC=function(t){return function(e){for(var r=UV(e),n=jV(r),i=zV&&DV(r)===null,a=n.length,s=0,o=[],u;a>s;)u=n[s++],(!cC||(i?u in r:fC(r,u)))&&BV(o,t?[u,r[u]]:r[u]);return o}},HV={entries:hC(!0),values:hC(!1)},qV=er,VV=HV.entries;qV({target:"Object",stat:!0},{entries:function(e){return VV(e)}});/*
799
799
  @license
@@ -819,7 +819,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
819
819
 
820
820
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
821
821
 
822
- */Object.defineProperty(Xh,"__esModule",{value:!0});var kW=ud,SW=aa,$W=Aa,TW=gs,EW=ep,CW=na,RW=ia,xW=li,IW=ys;function Na(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var kC=Na(kW),AW=Na(SW),OW=Na($W),PW=Na(TW),Ao=Na(EW),MW=Na(CW),NW=Na(RW),La=Na(xW),LW=Na(IW),DW;function ks(){}ks.prototype=Object.create(null);function Or(){Or.init.call(this)}Or.EventEmitter=Or,Or.usingDomains=!1,Or.prototype.domain=void 0,Or.prototype._events=void 0,Or.prototype._maxListeners=void 0,Or.defaultMaxListeners=10,Or.init=function(){this.domain=null,Or.usingDomains&&DW.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ks,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Or.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function SC(t){return t._maxListeners===void 0?Or.defaultMaxListeners:t._maxListeners}Or.prototype.getMaxListeners=function(){return SC(this)};function jW(t,e,r){if(e)t.call(r);else for(var n=t.length,i=cd(t,n),a=0;a<n;++a)i[a].call(r)}function UW(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=cd(t,i),s=0;s<i;++s)a[s].call(r,n)}function FW(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=cd(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function BW(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=cd(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function zW(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=cd(t,i),s=0;s<i;++s)a[s].apply(r,n)}Or.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:jW(n,d,this);break;case 2:UW(n,d,this,arguments[1]);break;case 3:FW(n,d,this,arguments[1],arguments[2]);break;case 4:BW(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];zW(n,d,this,a)}return!0};function $C(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new ks,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=SC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,HW(o)}return t}function HW(t){typeof console.warn=="function"?console.warn(t):console.log(t)}Or.prototype.addListener=function(e,r){return $C(this,e,r,!1)},Or.prototype.on=Or.prototype.addListener,Or.prototype.prependListener=function(e,r){return $C(this,e,r,!0)};function TC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}Or.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,TC(this,e,r)),this},Or.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,TC(this,e,r)),this},Or.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new ks:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new ks,this;delete i[e]}else qW(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},Or.prototype.off=function(t,e){return this.removeListener(t,e)},Or.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ks,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new ks:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new ks,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},Or.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=VW(r):n=[]):n=[],n},Or.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):EC.call(t,e)},Or.prototype.listenerCount=EC;function EC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}Or.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function qW(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function cd(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function VW(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function WW(t){var e=ZW();return function(){var n=La.default(t),i;if(e){var a=La.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return NW.default(this,i)}}function ZW(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var GW=function(t){MW.default(r,t);var e=WW(r);function r(){var n;return AW.default(this,r),n=e.call(this),LW.default(PW.default(n),"eventHistory",new Map),n}return OW.default(r,[{key:"on",value:function(i,a){return Ao.default(La.default(r.prototype),"on",this).call(this,i,a)}},{key:"once",value:function(i,a){return Ao.default(La.default(r.prototype),"once",this).call(this,i,a)}},{key:"off",value:function(i,a){return Ao.default(La.default(r.prototype),"off",this).call(this,i,a)}},{key:"emit",value:function(i){for(var a,s=arguments.length,o=new Array(s>1?s-1:0),u=1;u<s;u++)o[u-1]=arguments[u];return this.eventHistory.set(i,o),(a=Ao.default(La.default(r.prototype),"emit",this)).call.apply(a,[this,i].concat(o))}},{key:"addListener",value:function(i,a){return Ao.default(La.default(r.prototype),"addListener",this).call(this,i,a)}},{key:"removeListener",value:function(i,a){return Ao.default(La.default(r.prototype),"removeListener",this).call(this,i,a)}},{key:"addListenerWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0&&a.apply(void 0,kC.default(s)),this.addListener(i,a)}},{key:"onWithReplay",value:function(i,a){return this.addListenerWithReplay(i,a)}},{key:"onceWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0?(a.apply(void 0,kC.default(s)),this):Ao.default(La.default(r.prototype),"once",this).call(this,i,a)}}]),r}(Or);Xh.ReplayEventEmitter=GW;var tp={exports:{}};tp.exports,function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,a=2,s=9007199254740991,o="[object Arguments]",u="[object Array]",l="[object AsyncFunction]",c="[object Boolean]",d="[object Date]",f="[object Error]",m="[object Function]",b="[object GeneratorFunction]",A="[object Map]",N="[object Number]",z="[object Null]",X="[object Object]",Ee="[object Promise]",Ie="[object Proxy]",Be="[object RegExp]",Oe="[object Set]",ze="[object String]",V="[object Symbol]",xe="[object Undefined]",_e="[object WeakMap]",se="[object ArrayBuffer]",Te="[object DataView]",re="[object Float32Array]",oe="[object Float64Array]",q="[object Int8Array]",ne="[object Int16Array]",Se="[object Int32Array]",H="[object Uint8Array]",ye="[object Uint8ClampedArray]",ke="[object Uint16Array]",M="[object Uint32Array]",Xe=/[\\^$.*+?()[\]{}|]/g,Ct=/^\[object .+?Constructor\]$/,rt=/^(?:0|[1-9]\d*)$/,je={};je[re]=je[oe]=je[q]=je[ne]=je[Se]=je[H]=je[ye]=je[ke]=je[M]=!0,je[o]=je[u]=je[se]=je[c]=je[Te]=je[d]=je[f]=je[m]=je[A]=je[N]=je[X]=je[Be]=je[Oe]=je[ze]=je[_e]=!1;var ce=typeof ln=="object"&&ln&&ln.Object===Object&&ln,Ke=typeof self=="object"&&self&&self.Object===Object&&self,Fe=ce||Ke||Function("return this")(),be=e&&!e.nodeType&&e,pt=be&&!0&&t&&!t.nodeType&&t,Ze=pt&&pt.exports===be,Jt=Ze&&ce.process,At=function(){try{return Jt&&Jt.binding&&Jt.binding("util")}catch{}}(),Q=At&&At.isTypedArray;function Ue(F,ve){for(var We=-1,wt=F==null?0:F.length,Nr=0,Yt=[];++We<wt;){var zr=F[We];ve(zr,We,F)&&(Yt[Nr++]=zr)}return Yt}function ot(F,ve){for(var We=-1,wt=ve.length,Nr=F.length;++We<wt;)F[Nr+We]=ve[We];return F}function Pe(F,ve){for(var We=-1,wt=F==null?0:F.length;++We<wt;)if(ve(F[We],We,F))return!0;return!1}function St(F,ve){for(var We=-1,wt=Array(F);++We<F;)wt[We]=ve(We);return wt}function ut(F){return function(ve){return F(ve)}}function or(F,ve){return F.has(ve)}function br(F,ve){return F==null?void 0:F[ve]}function et(F){var ve=-1,We=Array(F.size);return F.forEach(function(wt,Nr){We[++ve]=[Nr,wt]}),We}function Mr(F,ve){return function(We){return F(ve(We))}}function Fr(F){var ve=-1,We=Array(F.size);return F.forEach(function(wt){We[++ve]=wt}),We}var dr=Array.prototype,fr=Function.prototype,Wt=Object.prototype,Ot=Fe["__core-js_shared__"],L=fr.toString,W=Wt.hasOwnProperty,ie=function(){var F=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||"");return F?"Symbol(src)_1."+F:""}(),He=Wt.toString,ct=RegExp("^"+L.call(W).replace(Xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bt=Ze?Fe.Buffer:void 0,zt=Fe.Symbol,tr=Fe.Uint8Array,Re=Wt.propertyIsEnumerable,Ne=dr.splice,pe=zt?zt.toStringTag:void 0,$e=Object.getOwnPropertySymbols,ae=bt?bt.isBuffer:void 0,me=Mr(Object.keys,Object),we=Ve(Fe,"DataView"),K=Ve(Fe,"Map"),he=Ve(Fe,"Promise"),G=Ve(Fe,"Set"),de=Ve(Fe,"WeakMap"),ee=Ve(Object,"create"),Ye=T(we),qe=T(K),dt=T(he),lt=T(G),ht=T(de),Rt=zt?zt.prototype:void 0,xt=Rt?Rt.valueOf:void 0;function kt(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function $t(){this.__data__=ee?ee(null):{},this.size=0}function It(F){var ve=this.has(F)&&delete this.__data__[F];return this.size-=ve?1:0,ve}function jt(F){var ve=this.__data__;if(ee){var We=ve[F];return We===n?void 0:We}return W.call(ve,F)?ve[F]:void 0}function sn(F){var ve=this.__data__;return ee?ve[F]!==void 0:W.call(ve,F)}function _n(F,ve){var We=this.__data__;return this.size+=this.has(F)?0:1,We[F]=ee&&ve===void 0?n:ve,this}kt.prototype.clear=$t,kt.prototype.delete=It,kt.prototype.get=jt,kt.prototype.has=sn,kt.prototype.set=_n;function Ut(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function qn(){this.__data__=[],this.size=0}function ha(F){var ve=this.__data__,We=Dr(ve,F);if(We<0)return!1;var wt=ve.length-1;return We==wt?ve.pop():Ne.call(ve,We,1),--this.size,!0}function Wa(F){var ve=this.__data__,We=Dr(ve,F);return We<0?void 0:ve[We][1]}function ti(F){return Dr(this.__data__,F)>-1}function pa(F,ve){var We=this.__data__,wt=Dr(We,F);return wt<0?(++this.size,We.push([F,ve])):We[wt][1]=ve,this}Ut.prototype.clear=qn,Ut.prototype.delete=ha,Ut.prototype.get=Wa,Ut.prototype.has=ti,Ut.prototype.set=pa;function ri(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function gi(){this.size=0,this.__data__={hash:new kt,map:new(K||Ut),string:new kt}}function Za(F){var ve=Ae(this,F).delete(F);return this.size-=ve?1:0,ve}function en(F){return Ae(this,F).get(F)}function ji(F){return Ae(this,F).has(F)}function Ms(F,ve){var We=Ae(this,F),wt=We.size;return We.set(F,ve),this.size+=We.size==wt?0:1,this}ri.prototype.clear=gi,ri.prototype.delete=Za,ri.prototype.get=en,ri.prototype.has=ji,ri.prototype.set=Ms;function Ui(F){var ve=-1,We=F==null?0:F.length;for(this.__data__=new ri;++ve<We;)this.add(F[ve])}function Ns(F){return this.__data__.set(F,n),this}function Bo(F){return this.__data__.has(F)}Ui.prototype.add=Ui.prototype.push=Ns,Ui.prototype.has=Bo;function Vn(F){var ve=this.__data__=new Ut(F);this.size=ve.size}function Ls(){this.__data__=new Ut,this.size=0}function zo(F){var ve=this.__data__,We=ve.delete(F);return this.size=ve.size,We}function Ho(F){return this.__data__.get(F)}function hn(F){return this.__data__.has(F)}function Ds(F,ve){var We=this.__data__;if(We instanceof Ut){var wt=We.__data__;if(!K||wt.length<r-1)return wt.push([F,ve]),this.size=++We.size,this;We=this.__data__=new ri(wt)}return We.set(F,ve),this.size=We.size,this}Vn.prototype.clear=Ls,Vn.prototype.delete=zo,Vn.prototype.get=Ho,Vn.prototype.has=hn,Vn.prototype.set=Ds;function Pn(F,ve){var We=P(F),wt=!We&&U(F),Nr=!We&&!wt&&Ce(F),Yt=!We&&!wt&&!Nr&&tn(F),zr=We||wt||Nr||Yt,Jr=zr?St(F.length,String):[],on=Jr.length;for(var Nt in F)W.call(F,Nt)&&!(zr&&(Nt=="length"||Nr&&(Nt=="offset"||Nt=="parent")||Yt&&(Nt=="buffer"||Nt=="byteLength"||Nt=="byteOffset")||Nn(Nt,on)))&&Jr.push(Nt);return Jr}function Dr(F,ve){for(var We=F.length;We--;)if($(F[We][0],ve))return We;return-1}function qo(F,ve,We){var wt=ve(F);return P(F)?wt:ot(wt,We(F))}function ni(F){return F==null?F===void 0?xe:z:pe&&pe in Object(F)?at(F):E(F)}function Mn(F){return Fi(F)&&ni(F)==o}function js(F,ve,We,wt,Nr){return F===ve?!0:F==null||ve==null||!Fi(F)&&!Fi(ve)?F!==F&&ve!==ve:te(F,ve,We,wt,js,Nr)}function te(F,ve,We,wt,Nr,Yt){var zr=P(F),Jr=P(ve),on=zr?u:Br(F),Nt=Jr?u:Br(ve);on=on==o?X:on,Nt=Nt==o?X:Nt;var Sn=on==X,$n=Nt==X,pn=on==Nt;if(pn&&Ce(F)){if(!Ce(ve))return!1;zr=!0,Sn=!1}if(pn&&!Sn)return Yt||(Yt=new Vn),zr||tn(F)?R(F,ve,We,wt,Nr,Yt):Z(F,ve,on,We,wt,Nr,Yt);if(!(We&i)){var Wn=Sn&&W.call(F,"__wrapped__"),Zt=$n&&W.call(ve,"__wrapped__");if(Wn||Zt){var va=Wn?F.value():F,C=Zt?ve.value():ve;return Yt||(Yt=new Vn),Nr(va,C,We,wt,Yt)}}return pn?(Yt||(Yt=new Vn),j(F,ve,We,wt,Nr,Yt)):!1}function ue(F){if(!vn(F)||D(F))return!1;var ve=it(F)?ct:Ct;return ve.test(T(F))}function I(F){return Fi(F)&&Pt(F.length)&&!!je[ni(F)]}function O(F){if(!B(F))return me(F);var ve=[];for(var We in Object(F))W.call(F,We)&&We!="constructor"&&ve.push(We);return ve}function R(F,ve,We,wt,Nr,Yt){var zr=We&i,Jr=F.length,on=ve.length;if(Jr!=on&&!(zr&&on>Jr))return!1;var Nt=Yt.get(F);if(Nt&&Yt.get(ve))return Nt==ve;var Sn=-1,$n=!0,pn=We&a?new Ui:void 0;for(Yt.set(F,ve),Yt.set(ve,F);++Sn<Jr;){var Wn=F[Sn],Zt=ve[Sn];if(wt)var va=zr?wt(Zt,Wn,Sn,ve,F,Yt):wt(Wn,Zt,Sn,F,ve,Yt);if(va!==void 0){if(va)continue;$n=!1;break}if(pn){if(!Pe(ve,function(C,x){if(!or(pn,x)&&(Wn===C||Nr(Wn,C,We,wt,Yt)))return pn.push(x)})){$n=!1;break}}else if(!(Wn===Zt||Nr(Wn,Zt,We,wt,Yt))){$n=!1;break}}return Yt.delete(F),Yt.delete(ve),$n}function Z(F,ve,We,wt,Nr,Yt,zr){switch(We){case Te:if(F.byteLength!=ve.byteLength||F.byteOffset!=ve.byteOffset)return!1;F=F.buffer,ve=ve.buffer;case se:return!(F.byteLength!=ve.byteLength||!Yt(new tr(F),new tr(ve)));case c:case d:case N:return $(+F,+ve);case f:return F.name==ve.name&&F.message==ve.message;case Be:case ze:return F==ve+"";case A:var Jr=et;case Oe:var on=wt&i;if(Jr||(Jr=Fr),F.size!=ve.size&&!on)return!1;var Nt=zr.get(F);if(Nt)return Nt==ve;wt|=a,zr.set(F,ve);var Sn=R(Jr(F),Jr(ve),wt,Nr,Yt,zr);return zr.delete(F),Sn;case V:if(xt)return xt.call(F)==xt.call(ve)}return!1}function j(F,ve,We,wt,Nr,Yt){var zr=We&i,Jr=Le(F),on=Jr.length,Nt=Le(ve),Sn=Nt.length;if(on!=Sn&&!zr)return!1;for(var $n=on;$n--;){var pn=Jr[$n];if(!(zr?pn in ve:W.call(ve,pn)))return!1}var Wn=Yt.get(F);if(Wn&&Yt.get(ve))return Wn==ve;var Zt=!0;Yt.set(F,ve),Yt.set(ve,F);for(var va=zr;++$n<on;){pn=Jr[$n];var C=F[pn],x=ve[pn];if(wt)var w=zr?wt(x,C,pn,ve,F,Yt):wt(C,x,pn,F,ve,Yt);if(!(w===void 0?C===x||Nr(C,x,We,wt,Yt):w)){Zt=!1;break}va||(va=pn=="constructor")}if(Zt&&!va){var p=F.constructor,h=ve.constructor;p!=h&&"constructor"in F&&"constructor"in ve&&!(typeof p=="function"&&p instanceof p&&typeof h=="function"&&h instanceof h)&&(Zt=!1)}return Yt.delete(F),Yt.delete(ve),Zt}function Le(F){return qo(F,Bi,Tt)}function Ae(F,ve){var We=F.__data__;return kn(ve)?We[typeof ve=="string"?"string":"hash"]:We.map}function Ve(F,ve){var We=br(F,ve);return ue(We)?We:void 0}function at(F){var ve=W.call(F,pe),We=F[pe];try{F[pe]=void 0;var wt=!0}catch{}var Nr=He.call(F);return wt&&(ve?F[pe]=We:delete F[pe]),Nr}var Tt=$e?function(F){return F==null?[]:(F=Object(F),Ue($e(F),function(ve){return Re.call(F,ve)}))}:Yp,Br=ni;(we&&Br(new we(new ArrayBuffer(1)))!=Te||K&&Br(new K)!=A||he&&Br(he.resolve())!=Ee||G&&Br(new G)!=Oe||de&&Br(new de)!=_e)&&(Br=function(F){var ve=ni(F),We=ve==X?F.constructor:void 0,wt=We?T(We):"";if(wt)switch(wt){case Ye:return Te;case qe:return A;case dt:return Ee;case lt:return Oe;case ht:return _e}return ve});function Nn(F,ve){return ve=ve??s,!!ve&&(typeof F=="number"||rt.test(F))&&F>-1&&F%1==0&&F<ve}function kn(F){var ve=typeof F;return ve=="string"||ve=="number"||ve=="symbol"||ve=="boolean"?F!=="__proto__":F===null}function D(F){return!!ie&&ie in F}function B(F){var ve=F&&F.constructor,We=typeof ve=="function"&&ve.prototype||Wt;return F===We}function E(F){return He.call(F)}function T(F){if(F!=null){try{return L.call(F)}catch{}try{return F+""}catch{}}return""}function $(F,ve){return F===ve||F!==F&&ve!==ve}var U=Mn(function(){return arguments}())?Mn:function(F){return Fi(F)&&W.call(F,"callee")&&!Re.call(F,"callee")},P=Array.isArray;function Me(F){return F!=null&&Pt(F.length)&&!it(F)}var Ce=ae||Vw;function Qe(F,ve){return js(F,ve)}function it(F){if(!vn(F))return!1;var ve=ni(F);return ve==m||ve==b||ve==l||ve==Ie}function Pt(F){return typeof F=="number"&&F>-1&&F%1==0&&F<=s}function vn(F){var ve=typeof F;return F!=null&&(ve=="object"||ve=="function")}function Fi(F){return F!=null&&typeof F=="object"}var tn=Q?ut(Q):I;function Bi(F){return Me(F)?Pn(F):O(F)}function Yp(){return[]}function Vw(){return!1}t.exports=Qe}(tp,tp.exports);var KW=tp.exports,CC={exports:{}},JW=Vt,YW=JW(function(){if(typeof ArrayBuffer=="function"){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}}),QW=Vt,XW=Lr,eZ=Yi,RC=YW,rp=Object.isExtensible,tZ=QW(function(){rp(1)}),rZ=tZ||RC?function(e){return!XW(e)||RC&&eZ(e)==="ArrayBuffer"?!1:rp?rp(e):!0}:rp,nZ=Vt,xC=!nZ(function(){return Object.isExtensible(Object.preventExtensions({}))}),iZ=er,aZ=Kt,sZ=Lc,oZ=Lr,zy=Vr,uZ=Cn.f,IC=ko,lZ=ug,Hy=rZ,cZ=Mc,dZ=xC,AC=!1,Da=cZ("meta"),fZ=0,qy=function(t){uZ(t,Da,{value:{objectID:"O"+fZ++,weakData:{}}})},hZ=function(t,e){if(!oZ(t))return typeof t=="symbol"?t:(typeof t=="string"?"S":"P")+t;if(!zy(t,Da)){if(!Hy(t))return"F";if(!e)return"E";qy(t)}return t[Da].objectID},pZ=function(t,e){if(!zy(t,Da)){if(!Hy(t))return!0;if(!e)return!1;qy(t)}return t[Da].weakData},vZ=function(t){return dZ&&AC&&Hy(t)&&!zy(t,Da)&&qy(t),t},mZ=function(){gZ.enable=function(){},AC=!0;var t=IC.f,e=aZ([].splice),r={};r[Da]=1,t(r).length&&(IC.f=function(n){for(var i=t(n),a=0,s=i.length;a<s;a++)if(i[a]===Da){e(i,a,1);break}return i},iZ({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:lZ.f}))},gZ=CC.exports={enable:mZ,fastKey:hZ,getWeakData:pZ,onFreeze:vZ};sZ[Da]=!0;var np=CC.exports,yZ=er,bZ=cr,wZ=Kt,OC=sh,_Z=Rn,kZ=np,SZ=rd,$Z=bs,TZ=Cr,EZ=xi,Vy=Lr,Wy=Vt,CZ=Mh,RZ=ea,xZ=Uh,Zy=function(t,e,r){var n=t.indexOf("Map")!==-1,i=t.indexOf("Weak")!==-1,a=n?"set":"add",s=bZ[t],o=s&&s.prototype,u=s,l={},c=function(z){var X=wZ(o[z]);_Z(o,z,z==="add"?function(Ie){return X(this,Ie===0?0:Ie),this}:z==="delete"?function(Ee){return i&&!Vy(Ee)?!1:X(this,Ee===0?0:Ee)}:z==="get"?function(Ie){return i&&!Vy(Ie)?void 0:X(this,Ie===0?0:Ie)}:z==="has"?function(Ie){return i&&!Vy(Ie)?!1:X(this,Ie===0?0:Ie)}:function(Ie,Be){return X(this,Ie===0?0:Ie,Be),this})},d=OC(t,!TZ(s)||!(i||o.forEach&&!Wy(function(){new s().entries().next()})));if(d)u=r.getConstructor(e,t,n,a),kZ.enable();else if(OC(t,!0)){var f=new u,m=f[a](i?{}:-0,1)!==f,b=Wy(function(){f.has(1)}),A=CZ(function(z){new s(z)}),N=!i&&Wy(function(){for(var z=new s,X=5;X--;)z[a](X,X);return!z.has(-0)});A||(u=e(function(z,X){$Z(z,o);var Ee=xZ(new s,z,u);return EZ(X)||SZ(X,Ee[a],{that:Ee,AS_ENTRIES:n}),Ee}),u.prototype=o,o.constructor=u),(b||N)&&(c("delete"),c("has"),n&&c("get")),(N||m)&&c(a),i&&o.clear&&delete o.clear}return l[t]=u,yZ({global:!0,constructor:!0,forced:u!==s},l),RZ(u,t),i||r.setStrong(u,t,n),u},IZ=Rn,ip=function(t,e,r){for(var n in e)IZ(t,n,e[n],r);return t},PC=ps,AZ=ra,MC=ip,OZ=xa,PZ=bs,MZ=xi,NZ=rd,LZ=cy,ap=Dh,DZ=wh,dd=Ar,NC=np.fastKey,LC=Jn,DC=LC.set,Gy=LC.getterFor,jC={getConstructor:function(t,e,r,n){var i=t(function(l,c){PZ(l,a),DC(l,{type:e,index:PC(null),first:void 0,last:void 0,size:0}),dd||(l.size=0),MZ(c)||NZ(c,l[n],{that:l,AS_ENTRIES:r})}),a=i.prototype,s=Gy(e),o=function(l,c,d){var f=s(l),m=u(l,c),b,A;return m?m.value=d:(f.last=m={index:A=NC(c,!0),key:c,value:d,previous:b=f.last,next:void 0,removed:!1},f.first||(f.first=m),b&&(b.next=m),dd?f.size++:l.size++,A!=="F"&&(f.index[A]=m)),l},u=function(l,c){var d=s(l),f=NC(c),m;if(f!=="F")return d.index[f];for(m=d.first;m;m=m.next)if(m.key===c)return m};return MC(a,{clear:function(){for(var c=this,d=s(c),f=d.first;f;)f.removed=!0,f.previous&&(f.previous=f.previous.next=void 0),f=f.next;d.first=d.last=void 0,d.index=PC(null),dd?d.size=0:c.size=0},delete:function(l){var c=this,d=s(c),f=u(c,l);if(f){var m=f.next,b=f.previous;delete d.index[f.index],f.removed=!0,b&&(b.next=m),m&&(m.previous=b),d.first===f&&(d.first=m),d.last===f&&(d.last=b),dd?d.size--:c.size--}return!!f},forEach:function(c){for(var d=s(this),f=OZ(c,arguments.length>1?arguments[1]:void 0),m;m=m?m.next:d.first;)for(f(m.value,m.key,this);m&&m.removed;)m=m.previous},has:function(c){return!!u(this,c)}}),MC(a,r?{get:function(c){var d=u(this,c);return d&&d.value},set:function(c,d){return o(this,c===0?0:c,d)}}:{add:function(c){return o(this,c=c===0?0:c,c)}}),dd&&AZ(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(t,e,r){var n=e+" Iterator",i=Gy(e),a=Gy(n);LZ(t,e,function(s,o){DC(this,{type:n,target:s,state:i(s),kind:o,last:void 0})},function(){for(var s=a(this),o=s.kind,u=s.last;u&&u.removed;)u=u.previous;return!s.target||!(s.last=u=u?u.next:s.state.first)?(s.target=void 0,ap(void 0,!0)):ap(o==="keys"?u.key:o==="values"?u.value:[u.key,u.value],!1)},r?"entries":"values",!r,!0),DZ(e)}},jZ=Zy,UZ=jC;jZ("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},UZ);var sa={};/*
822
+ */Object.defineProperty(Xh,"__esModule",{value:!0});var kW=ud,SW=aa,$W=Aa,TW=gs,EW=ep,CW=na,RW=ia,xW=li,IW=ys;function Na(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var kC=Na(kW),AW=Na(SW),OW=Na($W),PW=Na(TW),Ao=Na(EW),MW=Na(CW),NW=Na(RW),La=Na(xW),LW=Na(IW),DW;function ks(){}ks.prototype=Object.create(null);function Or(){Or.init.call(this)}Or.EventEmitter=Or,Or.usingDomains=!1,Or.prototype.domain=void 0,Or.prototype._events=void 0,Or.prototype._maxListeners=void 0,Or.defaultMaxListeners=10,Or.init=function(){this.domain=null,Or.usingDomains&&DW.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new ks,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Or.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function SC(t){return t._maxListeners===void 0?Or.defaultMaxListeners:t._maxListeners}Or.prototype.getMaxListeners=function(){return SC(this)};function jW(t,e,r){if(e)t.call(r);else for(var n=t.length,i=cd(t,n),a=0;a<n;++a)i[a].call(r)}function UW(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=cd(t,i),s=0;s<i;++s)a[s].call(r,n)}function FW(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=cd(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function BW(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=cd(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function zW(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=cd(t,i),s=0;s<i;++s)a[s].apply(r,n)}Or.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:jW(n,d,this);break;case 2:UW(n,d,this,arguments[1]);break;case 3:FW(n,d,this,arguments[1],arguments[2]);break;case 4:BW(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];zW(n,d,this,a)}return!0};function $C(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new ks,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=SC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,HW(o)}return t}function HW(t){typeof console.warn=="function"?console.warn(t):console.log(t)}Or.prototype.addListener=function(e,r){return $C(this,e,r,!1)},Or.prototype.on=Or.prototype.addListener,Or.prototype.prependListener=function(e,r){return $C(this,e,r,!0)};function TC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}Or.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,TC(this,e,r)),this},Or.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,TC(this,e,r)),this},Or.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new ks:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new ks,this;delete i[e]}else qW(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},Or.prototype.off=function(t,e){return this.removeListener(t,e)},Or.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new ks,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new ks:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new ks,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},Or.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=VW(r):n=[]):n=[],n},Or.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):EC.call(t,e)},Or.prototype.listenerCount=EC;function EC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}Or.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function qW(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function cd(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function VW(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function WW(t){var e=ZW();return function(){var n=La.default(t),i;if(e){var a=La.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return NW.default(this,i)}}function ZW(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var GW=function(t){MW.default(r,t);var e=WW(r);function r(){var n;return AW.default(this,r),n=e.call(this),LW.default(PW.default(n),"eventHistory",new Map),n}return OW.default(r,[{key:"on",value:function(i,a){return Ao.default(La.default(r.prototype),"on",this).call(this,i,a)}},{key:"once",value:function(i,a){return Ao.default(La.default(r.prototype),"once",this).call(this,i,a)}},{key:"off",value:function(i,a){return Ao.default(La.default(r.prototype),"off",this).call(this,i,a)}},{key:"emit",value:function(i){for(var a,s=arguments.length,o=new Array(s>1?s-1:0),u=1;u<s;u++)o[u-1]=arguments[u];return this.eventHistory.set(i,o),(a=Ao.default(La.default(r.prototype),"emit",this)).call.apply(a,[this,i].concat(o))}},{key:"addListener",value:function(i,a){return Ao.default(La.default(r.prototype),"addListener",this).call(this,i,a)}},{key:"removeListener",value:function(i,a){return Ao.default(La.default(r.prototype),"removeListener",this).call(this,i,a)}},{key:"addListenerWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0&&a.apply(void 0,kC.default(s)),this.addListener(i,a)}},{key:"onWithReplay",value:function(i,a){return this.addListenerWithReplay(i,a)}},{key:"onceWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0?(a.apply(void 0,kC.default(s)),this):Ao.default(La.default(r.prototype),"once",this).call(this,i,a)}}]),r}(Or);Xh.ReplayEventEmitter=GW;var tp={exports:{}};tp.exports,function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,a=2,s=9007199254740991,o="[object Arguments]",u="[object Array]",l="[object AsyncFunction]",c="[object Boolean]",d="[object Date]",f="[object Error]",m="[object Function]",b="[object GeneratorFunction]",A="[object Map]",N="[object Number]",z="[object Null]",X="[object Object]",Ee="[object Promise]",Ie="[object Proxy]",Fe="[object RegExp]",Oe="[object Set]",ze="[object String]",V="[object Symbol]",xe="[object Undefined]",_e="[object WeakMap]",se="[object ArrayBuffer]",Te="[object DataView]",re="[object Float32Array]",oe="[object Float64Array]",q="[object Int8Array]",ne="[object Int16Array]",Se="[object Int32Array]",H="[object Uint8Array]",ye="[object Uint8ClampedArray]",ke="[object Uint16Array]",M="[object Uint32Array]",Xe=/[\\^$.*+?()[\]{}|]/g,Ct=/^\[object .+?Constructor\]$/,rt=/^(?:0|[1-9]\d*)$/,je={};je[re]=je[oe]=je[q]=je[ne]=je[Se]=je[H]=je[ye]=je[ke]=je[M]=!0,je[o]=je[u]=je[se]=je[c]=je[Te]=je[d]=je[f]=je[m]=je[A]=je[N]=je[X]=je[Fe]=je[Oe]=je[ze]=je[_e]=!1;var ce=typeof ln=="object"&&ln&&ln.Object===Object&&ln,Ke=typeof self=="object"&&self&&self.Object===Object&&self,Be=ce||Ke||Function("return this")(),be=e&&!e.nodeType&&e,pt=be&&!0&&t&&!t.nodeType&&t,Ze=pt&&pt.exports===be,Jt=Ze&&ce.process,At=function(){try{return Jt&&Jt.binding&&Jt.binding("util")}catch{}}(),Q=At&&At.isTypedArray;function Ue(F,ve){for(var We=-1,wt=F==null?0:F.length,Nr=0,Yt=[];++We<wt;){var zr=F[We];ve(zr,We,F)&&(Yt[Nr++]=zr)}return Yt}function ot(F,ve){for(var We=-1,wt=ve.length,Nr=F.length;++We<wt;)F[Nr+We]=ve[We];return F}function Pe(F,ve){for(var We=-1,wt=F==null?0:F.length;++We<wt;)if(ve(F[We],We,F))return!0;return!1}function St(F,ve){for(var We=-1,wt=Array(F);++We<F;)wt[We]=ve(We);return wt}function ut(F){return function(ve){return F(ve)}}function or(F,ve){return F.has(ve)}function br(F,ve){return F==null?void 0:F[ve]}function et(F){var ve=-1,We=Array(F.size);return F.forEach(function(wt,Nr){We[++ve]=[Nr,wt]}),We}function Mr(F,ve){return function(We){return F(ve(We))}}function Fr(F){var ve=-1,We=Array(F.size);return F.forEach(function(wt){We[++ve]=wt}),We}var dr=Array.prototype,fr=Function.prototype,Wt=Object.prototype,Ot=Be["__core-js_shared__"],L=fr.toString,W=Wt.hasOwnProperty,ie=function(){var F=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||"");return F?"Symbol(src)_1."+F:""}(),He=Wt.toString,ct=RegExp("^"+L.call(W).replace(Xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bt=Ze?Be.Buffer:void 0,zt=Be.Symbol,tr=Be.Uint8Array,Re=Wt.propertyIsEnumerable,Ne=dr.splice,pe=zt?zt.toStringTag:void 0,$e=Object.getOwnPropertySymbols,ae=bt?bt.isBuffer:void 0,me=Mr(Object.keys,Object),we=Ve(Be,"DataView"),K=Ve(Be,"Map"),he=Ve(Be,"Promise"),G=Ve(Be,"Set"),de=Ve(Be,"WeakMap"),ee=Ve(Object,"create"),Ye=T(we),qe=T(K),dt=T(he),lt=T(G),ht=T(de),Rt=zt?zt.prototype:void 0,xt=Rt?Rt.valueOf:void 0;function kt(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function $t(){this.__data__=ee?ee(null):{},this.size=0}function It(F){var ve=this.has(F)&&delete this.__data__[F];return this.size-=ve?1:0,ve}function jt(F){var ve=this.__data__;if(ee){var We=ve[F];return We===n?void 0:We}return W.call(ve,F)?ve[F]:void 0}function sn(F){var ve=this.__data__;return ee?ve[F]!==void 0:W.call(ve,F)}function _n(F,ve){var We=this.__data__;return this.size+=this.has(F)?0:1,We[F]=ee&&ve===void 0?n:ve,this}kt.prototype.clear=$t,kt.prototype.delete=It,kt.prototype.get=jt,kt.prototype.has=sn,kt.prototype.set=_n;function Ut(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function qn(){this.__data__=[],this.size=0}function ha(F){var ve=this.__data__,We=Dr(ve,F);if(We<0)return!1;var wt=ve.length-1;return We==wt?ve.pop():Ne.call(ve,We,1),--this.size,!0}function Wa(F){var ve=this.__data__,We=Dr(ve,F);return We<0?void 0:ve[We][1]}function ti(F){return Dr(this.__data__,F)>-1}function pa(F,ve){var We=this.__data__,wt=Dr(We,F);return wt<0?(++this.size,We.push([F,ve])):We[wt][1]=ve,this}Ut.prototype.clear=qn,Ut.prototype.delete=ha,Ut.prototype.get=Wa,Ut.prototype.has=ti,Ut.prototype.set=pa;function ri(F){var ve=-1,We=F==null?0:F.length;for(this.clear();++ve<We;){var wt=F[ve];this.set(wt[0],wt[1])}}function gi(){this.size=0,this.__data__={hash:new kt,map:new(K||Ut),string:new kt}}function Za(F){var ve=Ae(this,F).delete(F);return this.size-=ve?1:0,ve}function en(F){return Ae(this,F).get(F)}function ji(F){return Ae(this,F).has(F)}function Ms(F,ve){var We=Ae(this,F),wt=We.size;return We.set(F,ve),this.size+=We.size==wt?0:1,this}ri.prototype.clear=gi,ri.prototype.delete=Za,ri.prototype.get=en,ri.prototype.has=ji,ri.prototype.set=Ms;function Ui(F){var ve=-1,We=F==null?0:F.length;for(this.__data__=new ri;++ve<We;)this.add(F[ve])}function Ns(F){return this.__data__.set(F,n),this}function Bo(F){return this.__data__.has(F)}Ui.prototype.add=Ui.prototype.push=Ns,Ui.prototype.has=Bo;function Vn(F){var ve=this.__data__=new Ut(F);this.size=ve.size}function Ls(){this.__data__=new Ut,this.size=0}function zo(F){var ve=this.__data__,We=ve.delete(F);return this.size=ve.size,We}function Ho(F){return this.__data__.get(F)}function hn(F){return this.__data__.has(F)}function Ds(F,ve){var We=this.__data__;if(We instanceof Ut){var wt=We.__data__;if(!K||wt.length<r-1)return wt.push([F,ve]),this.size=++We.size,this;We=this.__data__=new ri(wt)}return We.set(F,ve),this.size=We.size,this}Vn.prototype.clear=Ls,Vn.prototype.delete=zo,Vn.prototype.get=Ho,Vn.prototype.has=hn,Vn.prototype.set=Ds;function Pn(F,ve){var We=P(F),wt=!We&&U(F),Nr=!We&&!wt&&Ce(F),Yt=!We&&!wt&&!Nr&&tn(F),zr=We||wt||Nr||Yt,Jr=zr?St(F.length,String):[],on=Jr.length;for(var Nt in F)W.call(F,Nt)&&!(zr&&(Nt=="length"||Nr&&(Nt=="offset"||Nt=="parent")||Yt&&(Nt=="buffer"||Nt=="byteLength"||Nt=="byteOffset")||Nn(Nt,on)))&&Jr.push(Nt);return Jr}function Dr(F,ve){for(var We=F.length;We--;)if($(F[We][0],ve))return We;return-1}function qo(F,ve,We){var wt=ve(F);return P(F)?wt:ot(wt,We(F))}function ni(F){return F==null?F===void 0?xe:z:pe&&pe in Object(F)?at(F):E(F)}function Mn(F){return Fi(F)&&ni(F)==o}function js(F,ve,We,wt,Nr){return F===ve?!0:F==null||ve==null||!Fi(F)&&!Fi(ve)?F!==F&&ve!==ve:te(F,ve,We,wt,js,Nr)}function te(F,ve,We,wt,Nr,Yt){var zr=P(F),Jr=P(ve),on=zr?u:Br(F),Nt=Jr?u:Br(ve);on=on==o?X:on,Nt=Nt==o?X:Nt;var Sn=on==X,$n=Nt==X,pn=on==Nt;if(pn&&Ce(F)){if(!Ce(ve))return!1;zr=!0,Sn=!1}if(pn&&!Sn)return Yt||(Yt=new Vn),zr||tn(F)?R(F,ve,We,wt,Nr,Yt):Z(F,ve,on,We,wt,Nr,Yt);if(!(We&i)){var Wn=Sn&&W.call(F,"__wrapped__"),Zt=$n&&W.call(ve,"__wrapped__");if(Wn||Zt){var va=Wn?F.value():F,C=Zt?ve.value():ve;return Yt||(Yt=new Vn),Nr(va,C,We,wt,Yt)}}return pn?(Yt||(Yt=new Vn),j(F,ve,We,wt,Nr,Yt)):!1}function ue(F){if(!vn(F)||D(F))return!1;var ve=it(F)?ct:Ct;return ve.test(T(F))}function I(F){return Fi(F)&&Pt(F.length)&&!!je[ni(F)]}function O(F){if(!B(F))return me(F);var ve=[];for(var We in Object(F))W.call(F,We)&&We!="constructor"&&ve.push(We);return ve}function R(F,ve,We,wt,Nr,Yt){var zr=We&i,Jr=F.length,on=ve.length;if(Jr!=on&&!(zr&&on>Jr))return!1;var Nt=Yt.get(F);if(Nt&&Yt.get(ve))return Nt==ve;var Sn=-1,$n=!0,pn=We&a?new Ui:void 0;for(Yt.set(F,ve),Yt.set(ve,F);++Sn<Jr;){var Wn=F[Sn],Zt=ve[Sn];if(wt)var va=zr?wt(Zt,Wn,Sn,ve,F,Yt):wt(Wn,Zt,Sn,F,ve,Yt);if(va!==void 0){if(va)continue;$n=!1;break}if(pn){if(!Pe(ve,function(C,x){if(!or(pn,x)&&(Wn===C||Nr(Wn,C,We,wt,Yt)))return pn.push(x)})){$n=!1;break}}else if(!(Wn===Zt||Nr(Wn,Zt,We,wt,Yt))){$n=!1;break}}return Yt.delete(F),Yt.delete(ve),$n}function Z(F,ve,We,wt,Nr,Yt,zr){switch(We){case Te:if(F.byteLength!=ve.byteLength||F.byteOffset!=ve.byteOffset)return!1;F=F.buffer,ve=ve.buffer;case se:return!(F.byteLength!=ve.byteLength||!Yt(new tr(F),new tr(ve)));case c:case d:case N:return $(+F,+ve);case f:return F.name==ve.name&&F.message==ve.message;case Fe:case ze:return F==ve+"";case A:var Jr=et;case Oe:var on=wt&i;if(Jr||(Jr=Fr),F.size!=ve.size&&!on)return!1;var Nt=zr.get(F);if(Nt)return Nt==ve;wt|=a,zr.set(F,ve);var Sn=R(Jr(F),Jr(ve),wt,Nr,Yt,zr);return zr.delete(F),Sn;case V:if(xt)return xt.call(F)==xt.call(ve)}return!1}function j(F,ve,We,wt,Nr,Yt){var zr=We&i,Jr=Le(F),on=Jr.length,Nt=Le(ve),Sn=Nt.length;if(on!=Sn&&!zr)return!1;for(var $n=on;$n--;){var pn=Jr[$n];if(!(zr?pn in ve:W.call(ve,pn)))return!1}var Wn=Yt.get(F);if(Wn&&Yt.get(ve))return Wn==ve;var Zt=!0;Yt.set(F,ve),Yt.set(ve,F);for(var va=zr;++$n<on;){pn=Jr[$n];var C=F[pn],x=ve[pn];if(wt)var w=zr?wt(x,C,pn,ve,F,Yt):wt(C,x,pn,F,ve,Yt);if(!(w===void 0?C===x||Nr(C,x,We,wt,Yt):w)){Zt=!1;break}va||(va=pn=="constructor")}if(Zt&&!va){var p=F.constructor,h=ve.constructor;p!=h&&"constructor"in F&&"constructor"in ve&&!(typeof p=="function"&&p instanceof p&&typeof h=="function"&&h instanceof h)&&(Zt=!1)}return Yt.delete(F),Yt.delete(ve),Zt}function Le(F){return qo(F,Bi,Tt)}function Ae(F,ve){var We=F.__data__;return kn(ve)?We[typeof ve=="string"?"string":"hash"]:We.map}function Ve(F,ve){var We=br(F,ve);return ue(We)?We:void 0}function at(F){var ve=W.call(F,pe),We=F[pe];try{F[pe]=void 0;var wt=!0}catch{}var Nr=He.call(F);return wt&&(ve?F[pe]=We:delete F[pe]),Nr}var Tt=$e?function(F){return F==null?[]:(F=Object(F),Ue($e(F),function(ve){return Re.call(F,ve)}))}:Yp,Br=ni;(we&&Br(new we(new ArrayBuffer(1)))!=Te||K&&Br(new K)!=A||he&&Br(he.resolve())!=Ee||G&&Br(new G)!=Oe||de&&Br(new de)!=_e)&&(Br=function(F){var ve=ni(F),We=ve==X?F.constructor:void 0,wt=We?T(We):"";if(wt)switch(wt){case Ye:return Te;case qe:return A;case dt:return Ee;case lt:return Oe;case ht:return _e}return ve});function Nn(F,ve){return ve=ve??s,!!ve&&(typeof F=="number"||rt.test(F))&&F>-1&&F%1==0&&F<ve}function kn(F){var ve=typeof F;return ve=="string"||ve=="number"||ve=="symbol"||ve=="boolean"?F!=="__proto__":F===null}function D(F){return!!ie&&ie in F}function B(F){var ve=F&&F.constructor,We=typeof ve=="function"&&ve.prototype||Wt;return F===We}function E(F){return He.call(F)}function T(F){if(F!=null){try{return L.call(F)}catch{}try{return F+""}catch{}}return""}function $(F,ve){return F===ve||F!==F&&ve!==ve}var U=Mn(function(){return arguments}())?Mn:function(F){return Fi(F)&&W.call(F,"callee")&&!Re.call(F,"callee")},P=Array.isArray;function Me(F){return F!=null&&Pt(F.length)&&!it(F)}var Ce=ae||Vw;function Qe(F,ve){return js(F,ve)}function it(F){if(!vn(F))return!1;var ve=ni(F);return ve==m||ve==b||ve==l||ve==Ie}function Pt(F){return typeof F=="number"&&F>-1&&F%1==0&&F<=s}function vn(F){var ve=typeof F;return F!=null&&(ve=="object"||ve=="function")}function Fi(F){return F!=null&&typeof F=="object"}var tn=Q?ut(Q):I;function Bi(F){return Me(F)?Pn(F):O(F)}function Yp(){return[]}function Vw(){return!1}t.exports=Qe}(tp,tp.exports);var KW=tp.exports,CC={exports:{}},JW=Vt,YW=JW(function(){if(typeof ArrayBuffer=="function"){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}}),QW=Vt,XW=Lr,eZ=Yi,RC=YW,rp=Object.isExtensible,tZ=QW(function(){rp(1)}),rZ=tZ||RC?function(e){return!XW(e)||RC&&eZ(e)==="ArrayBuffer"?!1:rp?rp(e):!0}:rp,nZ=Vt,xC=!nZ(function(){return Object.isExtensible(Object.preventExtensions({}))}),iZ=er,aZ=Kt,sZ=Lc,oZ=Lr,zy=Vr,uZ=Cn.f,IC=ko,lZ=ug,Hy=rZ,cZ=Mc,dZ=xC,AC=!1,Da=cZ("meta"),fZ=0,qy=function(t){uZ(t,Da,{value:{objectID:"O"+fZ++,weakData:{}}})},hZ=function(t,e){if(!oZ(t))return typeof t=="symbol"?t:(typeof t=="string"?"S":"P")+t;if(!zy(t,Da)){if(!Hy(t))return"F";if(!e)return"E";qy(t)}return t[Da].objectID},pZ=function(t,e){if(!zy(t,Da)){if(!Hy(t))return!0;if(!e)return!1;qy(t)}return t[Da].weakData},vZ=function(t){return dZ&&AC&&Hy(t)&&!zy(t,Da)&&qy(t),t},mZ=function(){gZ.enable=function(){},AC=!0;var t=IC.f,e=aZ([].splice),r={};r[Da]=1,t(r).length&&(IC.f=function(n){for(var i=t(n),a=0,s=i.length;a<s;a++)if(i[a]===Da){e(i,a,1);break}return i},iZ({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:lZ.f}))},gZ=CC.exports={enable:mZ,fastKey:hZ,getWeakData:pZ,onFreeze:vZ};sZ[Da]=!0;var np=CC.exports,yZ=er,bZ=cr,wZ=Kt,OC=sh,_Z=Rn,kZ=np,SZ=rd,$Z=bs,TZ=Cr,EZ=xi,Vy=Lr,Wy=Vt,CZ=Mh,RZ=ea,xZ=Uh,Zy=function(t,e,r){var n=t.indexOf("Map")!==-1,i=t.indexOf("Weak")!==-1,a=n?"set":"add",s=bZ[t],o=s&&s.prototype,u=s,l={},c=function(z){var X=wZ(o[z]);_Z(o,z,z==="add"?function(Ie){return X(this,Ie===0?0:Ie),this}:z==="delete"?function(Ee){return i&&!Vy(Ee)?!1:X(this,Ee===0?0:Ee)}:z==="get"?function(Ie){return i&&!Vy(Ie)?void 0:X(this,Ie===0?0:Ie)}:z==="has"?function(Ie){return i&&!Vy(Ie)?!1:X(this,Ie===0?0:Ie)}:function(Ie,Fe){return X(this,Ie===0?0:Ie,Fe),this})},d=OC(t,!TZ(s)||!(i||o.forEach&&!Wy(function(){new s().entries().next()})));if(d)u=r.getConstructor(e,t,n,a),kZ.enable();else if(OC(t,!0)){var f=new u,m=f[a](i?{}:-0,1)!==f,b=Wy(function(){f.has(1)}),A=CZ(function(z){new s(z)}),N=!i&&Wy(function(){for(var z=new s,X=5;X--;)z[a](X,X);return!z.has(-0)});A||(u=e(function(z,X){$Z(z,o);var Ee=xZ(new s,z,u);return EZ(X)||SZ(X,Ee[a],{that:Ee,AS_ENTRIES:n}),Ee}),u.prototype=o,o.constructor=u),(b||N)&&(c("delete"),c("has"),n&&c("get")),(N||m)&&c(a),i&&o.clear&&delete o.clear}return l[t]=u,yZ({global:!0,constructor:!0,forced:u!==s},l),RZ(u,t),i||r.setStrong(u,t,n),u},IZ=Rn,ip=function(t,e,r){for(var n in e)IZ(t,n,e[n],r);return t},PC=ps,AZ=ra,MC=ip,OZ=xa,PZ=bs,MZ=xi,NZ=rd,LZ=cy,ap=Dh,DZ=wh,dd=Ar,NC=np.fastKey,LC=Jn,DC=LC.set,Gy=LC.getterFor,jC={getConstructor:function(t,e,r,n){var i=t(function(l,c){PZ(l,a),DC(l,{type:e,index:PC(null),first:void 0,last:void 0,size:0}),dd||(l.size=0),MZ(c)||NZ(c,l[n],{that:l,AS_ENTRIES:r})}),a=i.prototype,s=Gy(e),o=function(l,c,d){var f=s(l),m=u(l,c),b,A;return m?m.value=d:(f.last=m={index:A=NC(c,!0),key:c,value:d,previous:b=f.last,next:void 0,removed:!1},f.first||(f.first=m),b&&(b.next=m),dd?f.size++:l.size++,A!=="F"&&(f.index[A]=m)),l},u=function(l,c){var d=s(l),f=NC(c),m;if(f!=="F")return d.index[f];for(m=d.first;m;m=m.next)if(m.key===c)return m};return MC(a,{clear:function(){for(var c=this,d=s(c),f=d.first;f;)f.removed=!0,f.previous&&(f.previous=f.previous.next=void 0),f=f.next;d.first=d.last=void 0,d.index=PC(null),dd?d.size=0:c.size=0},delete:function(l){var c=this,d=s(c),f=u(c,l);if(f){var m=f.next,b=f.previous;delete d.index[f.index],f.removed=!0,b&&(b.next=m),m&&(m.previous=b),d.first===f&&(d.first=m),d.last===f&&(d.last=b),dd?d.size--:c.size--}return!!f},forEach:function(c){for(var d=s(this),f=OZ(c,arguments.length>1?arguments[1]:void 0),m;m=m?m.next:d.first;)for(f(m.value,m.key,this);m&&m.removed;)m=m.previous},has:function(c){return!!u(this,c)}}),MC(a,r?{get:function(c){var d=u(this,c);return d&&d.value},set:function(c,d){return o(this,c===0?0:c,d)}}:{add:function(c){return o(this,c=c===0?0:c,c)}}),dd&&AZ(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(t,e,r){var n=e+" Iterator",i=Gy(e),a=Gy(n);LZ(t,e,function(s,o){DC(this,{type:n,target:s,state:i(s),kind:o,last:void 0})},function(){for(var s=a(this),o=s.kind,u=s.last;u&&u.removed;)u=u.previous;return!s.target||!(s.last=u=u?u.next:s.state.first)?(s.target=void 0,ap(void 0,!0)):ap(o==="keys"?u.key:o==="values"?u.value:[u.key,u.value],!1)},r?"entries":"values",!r,!0),DZ(e)}},jZ=Zy,UZ=jC;jZ("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},UZ);var sa={};/*
823
823
  @license
824
824
  Copyright (c) 2016, Twilio, Inc.
825
825
 
@@ -835,12 +835,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
835
835
  OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
836
836
  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
837
837
 
838
- */Object.defineProperty(sa,"__esModule",{value:!0});var FZ=aa,BZ=Aa,zZ=gs,HZ=na,qZ=ia,VZ=li,WZ=ys;function Oo(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var Ky=Oo(FZ),Jy=Oo(BZ),ja=Oo(zZ),Yy=Oo(HZ),UC=Oo(qZ),sp=Oo(VZ),Ua=Oo(WZ),ZZ;function Ss(){}Ss.prototype=Object.create(null);function kr(){kr.init.call(this)}kr.EventEmitter=kr,kr.usingDomains=!1,kr.prototype.domain=void 0,kr.prototype._events=void 0,kr.prototype._maxListeners=void 0,kr.defaultMaxListeners=10,kr.init=function(){this.domain=null,kr.usingDomains&&ZZ.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new Ss,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},kr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function FC(t){return t._maxListeners===void 0?kr.defaultMaxListeners:t._maxListeners}kr.prototype.getMaxListeners=function(){return FC(this)};function GZ(t,e,r){if(e)t.call(r);else for(var n=t.length,i=fd(t,n),a=0;a<n;++a)i[a].call(r)}function KZ(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=fd(t,i),s=0;s<i;++s)a[s].call(r,n)}function JZ(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=fd(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function YZ(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=fd(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function QZ(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=fd(t,i),s=0;s<i;++s)a[s].apply(r,n)}kr.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:GZ(n,d,this);break;case 2:KZ(n,d,this,arguments[1]);break;case 3:JZ(n,d,this,arguments[1],arguments[2]);break;case 4:YZ(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];QZ(n,d,this,a)}return!0};function BC(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new Ss,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=FC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,XZ(o)}return t}function XZ(t){typeof console.warn=="function"?console.warn(t):console.log(t)}kr.prototype.addListener=function(e,r){return BC(this,e,r,!1)},kr.prototype.on=kr.prototype.addListener,kr.prototype.prependListener=function(e,r){return BC(this,e,r,!0)};function zC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}kr.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,zC(this,e,r)),this},kr.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,zC(this,e,r)),this},kr.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new Ss:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new Ss,this;delete i[e]}else eG(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},kr.prototype.off=function(t,e){return this.removeListener(t,e)},kr.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new Ss,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new Ss:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new Ss,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},kr.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=tG(r):n=[]):n=[],n},kr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):HC.call(t,e)},kr.prototype.listenerCount=HC;function HC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}kr.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function eG(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function fd(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function tG(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function qC(t){var e=rG();return function(){var n=sp.default(t),i;if(e){var a=sp.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return UC.default(this,i)}}function rG(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var VC=function(t){Yy.default(r,t);var e=qC(r);function r(n){var i;return Ky.default(this,r),i=e.call(this),Ua.default(ja.default(i),"timeout",null),Ua.default(ja.default(i),"startTimestamp",-1),i.minDelay=n.min,i.maxDelay=n.max,i.initialDelay=n.initial||0,i.maxAttemptsCount=n.maxAttemptsCount||0,i.maxAttemptsTime=n.maxAttemptsTime||0,i.randomness=n.randomness||0,i.inProgress=!1,i.attemptNum=0,i.prevDelay=0,i.currDelay=0,i}return Jy.default(r,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(i){if(typeof i=="number")return this.prevDelay=0,this.currDelay=i,i;if(this.attemptNum==0)return this.initialDelay;if(this.attemptNum==1)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var a=this.currDelay+this.prevDelay;return this.maxDelay&&a>this.maxDelay&&(this.currDelay=this.maxDelay,a=this.maxDelay),this.currDelay=a,a}},{key:"randomize",value:function(i){var a=i*this.randomness,s=Math.round(Math.random()*a*2-a);return Math.max(0,i+s)}},{key:"scheduleAttempt",value:function(i){var a=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount){this.cleanup(),this.emit("failed",new Error("Maximum attempt count limit reached"));return}var s=this.nextDelay(i);if(s=this.randomize(s),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+s){this.cleanup(),this.emit("failed",new Error("Maximum attempt time limit reached"));return}this.timeout=setTimeout(function(){return a.attempt()},s)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(i){this.emit("succeeded",i)}},{key:"failed",value:function(i,a){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(a)}}]),r}(kr),nG=function(t){Yy.default(r,t);var e=qC(r);function r(n){var i;return Ky.default(this,r),i=e.call(this),Ua.default(ja.default(i),"resolve",function(){}),Ua.default(ja.default(i),"reject",function(){}),i.retrier=new VC(n),i}return Jy.default(r,[{key:"run",value:function(i){var a=this;return this.retrier.on("attempt",function(){i().then(function(s){return a.retrier.succeeded(s)}).catch(function(s){return a.retrier.failed(s)})}),this.retrier.on("succeeded",function(s){return a.resolve(s)}),this.retrier.on("cancelled",function(){return a.reject(new Error("Cancelled"))}),this.retrier.on("failed",function(s){return a.reject(s)}),new Promise(function(s,o){a.resolve=s,a.reject=o,a.retrier.start()})}},{key:"cancel",value:function(){this.retrier.cancel()}}]),r}(kr);function iG(t){var e=aG();return function(){var n=sp.default(t),i;if(e){var a=sp.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return UC.default(this,i)}}function aG(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function op(t){return t!=null}var sG=function(t){Yy.default(r,t);var e=iG(r);function r(n){var i;Ky.default(this,r),i=e.call(this),Ua.default(ja.default(i),"backoffDelay",0),Ua.default(ja.default(i),"nextBackoffDelay",0),Ua.default(ja.default(i),"backoffNumber",0),Ua.default(ja.default(i),"timeoutID",null),Ua.default(ja.default(i),"maxNumberOfRetry",-1),n=n||{};var a=n,s=a.initialDelay,o=a.maxDelay,u=a.randomisationFactor,l=a.factor;if(op(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(op(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(op(u)&&(u<0||u>1))throw new Error("The randomisation factor must be between 0 and 1.");if(op(l)&&l<=1)throw new Error("Exponential factor should be greater than 1.");if(i.initialDelay=s||100,i.maxDelay=o||1e4,i.maxDelay<=i.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return i.randomisationFactor=u||0,i.factor=l||2,i.reset(),i}return Jy.default(r,[{key:"backoff",value:function(i){this.timeoutID==null&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",i),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,i)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(i){if(i<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(i));this.maxNumberOfRetry=i}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var i=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*i))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(i){return new r(i)}}]),r}(kr);sa.AsyncRetrier=nG,sa.Backoff=sG,sa.Retrier=VC;var Qy={},oG=Er,uG=Vr,lG=Ta,cG=IE,WC=RegExp.prototype,dG=function(t){var e=t.flags;return e===void 0&&!("flags"in WC)&&!uG(t,"flags")&&lG(WC,t)?oG(cG,t):e},fG=Nc.PROPER,hG=Rn,pG=Gr,ZC=rn,vG=Vt,mG=dG,Xy="toString",GC=RegExp.prototype,KC=GC[Xy],gG=vG(function(){return KC.call({source:"a",flags:"b"})!=="/a/b"}),yG=fG&&KC.name!==Xy;(gG||yG)&&hG(GC,Xy,function(){var e=pG(this),r=ZC(e.source),n=ZC(mG(e));return"/"+r+"/"+n},{unsafe:!0});var bG=Zy,wG=jC;bG("Set",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},wG);var JC={exports:{}};(function(t,e){(function(n,i){t.exports=i()})(ln,function(){return function(r){var n={};function i(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return r[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=r,i.c=n,i.i=function(a){return a},i.d=function(a,s,o){i.o(a,s)||Object.defineProperty(a,s,{configurable:!1,enumerable:!0,get:o})},i.n=function(a){var s=a&&a.__esModule?function(){return a.default}:function(){return a};return i.d(s,"a",s),s},i.o=function(a,s){return Object.prototype.hasOwnProperty.call(a,s)},i.p="",i(i.s=5)}([function(r,n,i){r.exports=function(a,s){var o,u,l;for(o=1;o<arguments.length;o++){u=arguments[o];for(l in u)u.hasOwnProperty(l)&&(a[l]=u[l])}return a}},function(r,n,i){var a=i(0);r.exports={build:function(s,o){var u,l,c,d=o.plugins;for(u=0,l=d.length;u<l;u++)c=d[u],c.methods&&a(s,c.methods),c.properties&&Object.defineProperties(s,c.properties)},hook:function(s,o,u){var l,c,d,f,m=s.config.plugins,b=[s.context];for(u&&(b=b.concat(u)),l=0,c=m.length;l<c;l++)f=m[l],d=m[l][o],d&&d.apply(f,b)}}},function(r,n,i){function a(s){if(s.length===0)return s;var o,u,l=s.split(/[_-]/);if(l.length===1&&l[0][0].toLowerCase()===l[0][0])return s;for(u=l[0].toLowerCase(),o=1;o<l.length;o++)u=u+l[o].charAt(0).toUpperCase()+l[o].substring(1).toLowerCase();return u}a.prepended=function(s,o){return o=a(o),s+o[0].toUpperCase()+o.substring(1)},r.exports=a},function(r,n,i){var a=i(0),s=i(2);function o(u,l){u=u||{},this.options=u,this.defaults=l.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(u.init),this.data=this.configureData(u.data),this.methods=this.configureMethods(u.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(u.transitions||[]),this.plugins=this.configurePlugins(u.plugins,l.plugin)}a(o.prototype,{addState:function(u){this.map[u]||(this.states.push(u),this.addStateLifecycleNames(u),this.map[u]={})},addStateLifecycleNames:function(u){this.lifecycle.onEnter[u]=s.prepended("onEnter",u),this.lifecycle.onLeave[u]=s.prepended("onLeave",u),this.lifecycle.on[u]=s.prepended("on",u)},addTransition:function(u){this.transitions.indexOf(u)<0&&(this.transitions.push(u),this.addTransitionLifecycleNames(u))},addTransitionLifecycleNames:function(u){this.lifecycle.onBefore[u]=s.prepended("onBefore",u),this.lifecycle.onAfter[u]=s.prepended("onAfter",u),this.lifecycle.on[u]=s.prepended("on",u)},mapTransition:function(u){var l=u.name,c=u.from,d=u.to;return this.addState(c),typeof d!="function"&&this.addState(d),this.addTransition(l),this.map[c][l]=u,u},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(u){return typeof u=="string"?this.mapTransition(a({},this.defaults.init,{to:u,active:!0})):typeof u=="object"?this.mapTransition(a({},this.defaults.init,u,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(u){return typeof u=="function"?u:typeof u=="object"?function(){return u}:function(){return{}}},configureMethods:function(u){return u||{}},configurePlugins:function(u,l){u=u||[];var c,d,f;for(c=0,d=u.length;c<d;c++)f=u[c],typeof f=="function"&&(u[c]=f=f()),f.configure&&f.configure(this);return u},configureTransitions:function(u){var l,c,d,f,m,b=this.defaults.wildcard;for(c=0;c<u.length;c++)for(d=u[c],f=Array.isArray(d.from)?d.from:[d.from||b],m=d.to||b,l=0;l<f.length;l++)this.mapTransition({name:d.name,from:f[l],to:m})},transitionFor:function(u,l){var c=this.defaults.wildcard;return this.map[u][l]||this.map[c][l]},transitionsFor:function(u){var l=this.defaults.wildcard;return Object.keys(this.map[u]).concat(Object.keys(this.map[l]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),r.exports=o},function(r,n,i){var a=i(0),s=i(6),o=i(1),u=[null,[]];function l(c,d){this.context=c,this.config=d,this.state=d.init.from,this.observers=[c]}a(l.prototype,{init:function(c){if(a(this.context,this.config.data.apply(this.context,c)),o.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(c){return Array.isArray(c)?c.indexOf(this.state)>=0:this.state===c},isPending:function(){return this.pending},can:function(c){return!this.isPending()&&!!this.seek(c)},cannot:function(c){return!this.can(c)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(c,d){var f=this.config.defaults.wildcard,m=this.config.transitionFor(this.state,c),b=m&&m.to;return typeof b=="function"?b.apply(this.context,d):b===f?this.state:b},fire:function(c,d){return this.transit(c,this.state,this.seek(c,d),d)},transit:function(c,d,f,m){var b=this.config.lifecycle,A=this.config.options.observeUnchangedState||d!==f;return f?this.isPending()?this.context.onPendingTransition(c,d,f):(this.config.addState(f),this.beginTransit(),m.unshift({transition:c,from:d,to:f,fsm:this.context}),this.observeEvents([this.observersForEvent(b.onBefore.transition),this.observersForEvent(b.onBefore[c]),A?this.observersForEvent(b.onLeave.state):u,A?this.observersForEvent(b.onLeave[d]):u,this.observersForEvent(b.on.transition),A?["doTransit",[this]]:u,A?this.observersForEvent(b.onEnter.state):u,A?this.observersForEvent(b.onEnter[f]):u,A?this.observersForEvent(b.on[f]):u,this.observersForEvent(b.onAfter.transition),this.observersForEvent(b.onAfter[c]),this.observersForEvent(b.on[c])],m)):this.context.onInvalidTransition(c,d,f)},beginTransit:function(){this.pending=!0},endTransit:function(c){return this.pending=!1,c},failTransit:function(c){throw this.pending=!1,c},doTransit:function(c){this.state=c.to},observe:function(c){if(c.length===2){var d={};d[c[0]]=c[1],this.observers.push(d)}else this.observers.push(c[0])},observersForEvent:function(c){for(var d=0,f=this.observers.length,m,b=[];d<f;d++)m=this.observers[d],m[c]&&b.push(m);return[c,b,!0]},observeEvents:function(c,d,f,m){if(c.length===0)return this.endTransit(m===void 0?!0:m);var b=c[0][0],A=c[0][1],N=c[0][2];if(d[0].event=b,b&&N&&b!==f&&o.hook(this,"lifecycle",d),A.length===0)return c.shift(),this.observeEvents(c,d,b,m);var z=A.shift(),X=z[b].apply(z,d);return X&&typeof X.then=="function"?X.then(this.observeEvents.bind(this,c,d,b)).catch(this.failTransit.bind(this)):X===!1?this.endTransit(!1):this.observeEvents(c,d,b,X)},onInvalidTransition:function(c,d,f){throw new s("transition is invalid in current state",c,d,f,this.state)},onPendingTransition:function(c,d,f){throw new s("transition is invalid while previous transition is still in progress",c,d,f,this.state)}}),r.exports=l},function(r,n,i){var a=i(0),s=i(2),o=i(1),u=i(3),l=i(4),c={is:function(N){return this._fsm.is(N)},can:function(N){return this._fsm.can(N)},cannot:function(N){return this._fsm.cannot(N)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(N,z,X){return this._fsm.onInvalidTransition(N,z,X)},onPendingTransition:function(N,z,X){return this._fsm.onPendingTransition(N,z,X)}},d={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(N){throw Error("use transitions to change state")}}};function f(N){return b(this||{},N)}function m(){var N,z;typeof arguments[0]=="function"?(N=arguments[0],z=arguments[1]||{}):(N=function(){this._fsm.apply(this,arguments)},z=arguments[0]||{});var X=new u(z,f);return A(N.prototype,X),N.prototype._fsm.config=X,N}function b(N,z){var X=new u(z,f);return A(N,X),N._fsm(),N}function A(N,z){if(typeof N!="object"||Array.isArray(N))throw Error("StateMachine can only be applied to objects");o.build(N,z),Object.defineProperties(N,d),a(N,c),a(N,z.methods),z.allTransitions().forEach(function(X){N[s(X)]=function(){return this._fsm.fire(X,[].slice.call(arguments))}}),N._fsm=function(){this._fsm=new l(this,z),this._fsm.init(arguments)}}f.version="3.0.1",f.factory=m,f.apply=b,f.defaults={wildcard:"*",init:{name:"init",from:"none"}},r.exports=f},function(r,n,i){r.exports=function(a,s,o,u,l){this.message=a,this.transition=s,this.from=o,this.to=u,this.current=l}}])})})(JC);var YC=JC.exports,eb={exports:{}},QC=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(QC){var XC=new Uint8Array(16);eb.exports=function(){return QC(XC),XC}}else{var eR=new Array(16);eb.exports=function(){for(var e=0,r;e<16;e++)e&3||(r=Math.random()*4294967296),eR[e]=r>>>((e&3)<<3)&255;return eR}}for(var tR=eb.exports,rR=[],up=0;up<256;++up)rR[up]=(up+256).toString(16).substr(1);function _G(t,e){var r=e||0,n=rR;return[n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]]].join("")}var nR=_G,kG=tR,SG=nR,iR,tb,rb=0,nb=0;function $G(t,e,r){var n=e&&r||0,i=e||[];t=t||{};var a=t.node||iR,s=t.clockseq!==void 0?t.clockseq:tb;if(a==null||s==null){var o=kG();a==null&&(a=iR=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=tb=(o[6]<<8|o[7])&16383)}var u=t.msecs!==void 0?t.msecs:new Date().getTime(),l=t.nsecs!==void 0?t.nsecs:nb+1,c=u-rb+(l-nb)/1e4;if(c<0&&t.clockseq===void 0&&(s=s+1&16383),(c<0||u>rb)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");rb=u,nb=l,tb=s,u+=122192928e5;var d=((u&268435455)*1e4+l)%4294967296;i[n++]=d>>>24&255,i[n++]=d>>>16&255,i[n++]=d>>>8&255,i[n++]=d&255;var f=u/4294967296*1e4&268435455;i[n++]=f>>>8&255,i[n++]=f&255,i[n++]=f>>>24&15|16,i[n++]=f>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return e||SG(i)}var TG=$G,EG=tR,CG=nR;function RG(t,e,r){var n=e&&r||0;typeof t=="string"&&(e=t==="binary"?new Array(16):null,t=null),t=t||{};var i=t.random||(t.rng||EG)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e)for(var a=0;a<16;++a)e[n+a]=i[a];return e||CG(i)}var xG=RG,IG=TG,aR=xG,ib=aR;ib.v1=IG,ib.v4=aR;var hd=ib,ab={exports:{}},sR=typeof ArrayBuffer<"u"&&typeof DataView<"u",AG=sR,sb=Ar,xn=cr,oR=Cr,lp=Lr,$s=Vr,ob=Ra,OG=wo,PG=Ea,ub=Rn,MG=ra,NG=Ta,cp=nd,Gu=Mu,LG=Rr,DG=Mc,uR=Jn,lR=uR.enforce,jG=uR.get,dp=xn.Int8Array,lb=dp&&dp.prototype,cR=xn.Uint8ClampedArray,dR=cR&&cR.prototype,oa=dp&&cp(dp),Pi=lb&&cp(lb),UG=Object.prototype,cb=xn.TypeError,fR=LG("toStringTag"),db=DG("TYPED_ARRAY_TAG"),fp="TypedArrayConstructor",Fa=AG&&!!Gu&&ob(xn.opera)!=="Opera",hR=!1,Bn,Ts,Ku,Ba={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},fb={BigInt64Array:8,BigUint64Array:8},FG=function(e){if(!lp(e))return!1;var r=ob(e);return r==="DataView"||$s(Ba,r)||$s(fb,r)},pR=function(t){var e=cp(t);if(lp(e)){var r=jG(e);return r&&$s(r,fp)?r[fp]:pR(e)}},vR=function(t){if(!lp(t))return!1;var e=ob(t);return $s(Ba,e)||$s(fb,e)},BG=function(t){if(vR(t))return t;throw new cb("Target is not a typed array")},zG=function(t){if(oR(t)&&(!Gu||NG(oa,t)))return t;throw new cb(OG(t)+" is not a typed array constructor")},HG=function(t,e,r,n){if(sb){if(r)for(var i in Ba){var a=xn[i];if(a&&$s(a.prototype,t))try{delete a.prototype[t]}catch{try{a.prototype[t]=e}catch{}}}(!Pi[t]||r)&&ub(Pi,t,r?e:Fa&&lb[t]||e,n)}},qG=function(t,e,r){var n,i;if(sb){if(Gu){if(r){for(n in Ba)if(i=xn[n],i&&$s(i,t))try{delete i[t]}catch{}}if(!oa[t]||r)try{return ub(oa,t,r?e:Fa&&oa[t]||e)}catch{}else return}for(n in Ba)i=xn[n],i&&(!i[t]||r)&&ub(i,t,e)}};for(Bn in Ba)Ts=xn[Bn],Ku=Ts&&Ts.prototype,Ku?lR(Ku)[fp]=Ts:Fa=!1;for(Bn in fb)Ts=xn[Bn],Ku=Ts&&Ts.prototype,Ku&&(lR(Ku)[fp]=Ts);if((!Fa||!oR(oa)||oa===Function.prototype)&&(oa=function(){throw new cb("Incorrect invocation")},Fa))for(Bn in Ba)xn[Bn]&&Gu(xn[Bn],oa);if((!Fa||!Pi||Pi===UG)&&(Pi=oa.prototype,Fa))for(Bn in Ba)xn[Bn]&&Gu(xn[Bn].prototype,Pi);if(Fa&&cp(dR)!==Pi&&Gu(dR,Pi),sb&&!$s(Pi,fR)){hR=!0,MG(Pi,fR,{configurable:!0,get:function(){return lp(this)?this[db]:void 0}});for(Bn in Ba)xn[Bn]&&PG(xn[Bn],db,Bn)}var Pr={NATIVE_ARRAY_BUFFER_VIEWS:Fa,TYPED_ARRAY_TAG:hR&&db,aTypedArray:BG,aTypedArrayConstructor:zG,exportTypedArrayMethod:HG,exportTypedArrayStaticMethod:qG,getTypedArrayConstructor:pR,isView:FG,isTypedArray:vR,TypedArray:oa,TypedArrayPrototype:Pi},mR=cr,hb=Vt,VG=Mh,WG=Pr.NATIVE_ARRAY_BUFFER_VIEWS,ZG=mR.ArrayBuffer,Po=mR.Int8Array,GG=!WG||!hb(function(){Po(1)})||!hb(function(){new Po(-1)})||!VG(function(t){new Po,new Po(null),new Po(1.5),new Po(t)},!0)||hb(function(){return new Po(new ZG(2),1,void 0).length!==1}),KG=Xi,JG=Ca,YG=RangeError,gR=function(t){if(t===void 0)return 0;var e=KG(t),r=JG(e);if(e!==r)throw new YG("Wrong length or index");return r},QG=Math.sign||function(e){var r=+e;return r===0||r!==r?r:r<0?-1:1},XG=QG,eK=Math.abs,yR=2220446049250313e-31,bR=1/yR,tK=function(t){return t+bR-bR},rK=function(t,e,r,n){var i=+t,a=eK(i),s=XG(i);if(a<n)return s*tK(a/n/e)*n*e;var o=(1+e/yR)*a,u=o-(o-a);return u>r||u!==u?s*(1/0):s*u},nK=rK,iK=11920928955078125e-23,aK=34028234663852886e22,sK=11754943508222875e-54,oK=Math.fround||function(e){return nK(e,iK,aK,sK)},uK=Array,lK=Math.abs,za=Math.pow,cK=Math.floor,dK=Math.log,fK=Math.LN2,hK=function(t,e,r){var n=uK(r),i=r*8-e-1,a=(1<<i)-1,s=a>>1,o=e===23?za(2,-24)-za(2,-77):0,u=t<0||t===0&&1/t<0?1:0,l=0,c,d,f;for(t=lK(t),t!==t||t===1/0?(d=t!==t?1:0,c=a):(c=cK(dK(t)/fK),f=za(2,-c),t*f<1&&(c--,f*=2),c+s>=1?t+=o/f:t+=o*za(2,1-s),t*f>=2&&(c++,f/=2),c+s>=a?(d=0,c=a):c+s>=1?(d=(t*f-1)*za(2,e),c+=s):(d=t*za(2,s-1)*za(2,e),c=0));e>=8;)n[l++]=d&255,d/=256,e-=8;for(c=c<<e|d,i+=e;i>0;)n[l++]=c&255,c/=256,i-=8;return n[--l]|=u*128,n},pK=function(t,e){var r=t.length,n=r*8-e-1,i=(1<<n)-1,a=i>>1,s=n-7,o=r-1,u=t[o--],l=u&127,c;for(u>>=7;s>0;)l=l*256+t[o--],s-=8;for(c=l&(1<<-s)-1,l>>=-s,s+=e;s>0;)c=c*256+t[o--],s-=8;if(l===0)l=1-a;else{if(l===i)return c?NaN:u?-1/0:1/0;c+=za(2,e),l-=a}return(u?-1:1)*c*za(2,l-e)},vK={pack:hK,unpack:pK},mK=yn,wR=xu,gK=bn,_R=function(e){for(var r=mK(this),n=gK(r),i=arguments.length,a=wR(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,o=s===void 0?n:wR(s,n);o>a;)r[a++]=e;return r},hp=cr,pb=Kt,vb=Ar,yK=sR,kR=Nc,bK=Ea,wK=ra,SR=ip,mb=Vt,pp=bs,_K=Xi,kK=Ca,vp=gR,SK=oK,$R=vK,$K=nd,TR=Mu,TK=_R,EK=ta,CK=Uh,RK=Ym,ER=ea,gb=Jn,xK=kR.PROPER,CR=kR.CONFIGURABLE,Ju="ArrayBuffer",mp="DataView",Yu="prototype",IK="Wrong length",RR="Wrong index",xR=gb.getterFor(Ju),pd=gb.getterFor(mp),IR=gb.set,Mi=hp[Ju],Qn=Mi,Qu=Qn&&Qn[Yu],ua=hp[mp],Mo=ua&&ua[Yu],AR=Object.prototype,AK=hp.Array,gp=hp.RangeError,OK=pb(TK),PK=pb([].reverse),OR=$R.pack,PR=$R.unpack,MR=function(t){return[t&255]},NR=function(t){return[t&255,t>>8&255]},LR=function(t){return[t&255,t>>8&255,t>>16&255,t>>24&255]},DR=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},MK=function(t){return OR(SK(t),23,4)},NK=function(t){return OR(t,52,8)},yp=function(t,e,r){wK(t[Yu],e,{configurable:!0,get:function(){return r(this)[e]}})},Es=function(t,e,r,n){var i=pd(t),a=vp(r),s=!!n;if(a+e>i.byteLength)throw new gp(RR);var o=i.bytes,u=a+i.byteOffset,l=EK(o,u,u+e);return s?l:PK(l)},Cs=function(t,e,r,n,i,a){var s=pd(t),o=vp(r),u=n(+i),l=!!a;if(o+e>s.byteLength)throw new gp(RR);for(var c=s.bytes,d=o+s.byteOffset,f=0;f<e;f++)c[d+f]=u[l?f:e-f-1]};if(!yK)Qn=function(e){pp(this,Qu);var r=vp(e);IR(this,{type:Ju,bytes:OK(AK(r),0),byteLength:r}),vb||(this.byteLength=r,this.detached=!1)},Qu=Qn[Yu],ua=function(e,r,n){pp(this,Mo),pp(e,Qu);var i=xR(e),a=i.byteLength,s=_K(r);if(s<0||s>a)throw new gp("Wrong offset");if(n=n===void 0?a-s:kK(n),s+n>a)throw new gp(IK);IR(this,{type:mp,buffer:e,byteLength:n,byteOffset:s,bytes:i.bytes}),vb||(this.buffer=e,this.byteLength=n,this.byteOffset=s)},Mo=ua[Yu],vb&&(yp(Qn,"byteLength",xR),yp(ua,"buffer",pd),yp(ua,"byteLength",pd),yp(ua,"byteOffset",pd)),SR(Mo,{getInt8:function(e){return Es(this,1,e)[0]<<24>>24},getUint8:function(e){return Es(this,1,e)[0]},getInt16:function(e){var r=Es(this,2,e,arguments.length>1?arguments[1]:!1);return(r[1]<<8|r[0])<<16>>16},getUint16:function(e){var r=Es(this,2,e,arguments.length>1?arguments[1]:!1);return r[1]<<8|r[0]},getInt32:function(e){return DR(Es(this,4,e,arguments.length>1?arguments[1]:!1))},getUint32:function(e){return DR(Es(this,4,e,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(e){return PR(Es(this,4,e,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(e){return PR(Es(this,8,e,arguments.length>1?arguments[1]:!1),52)},setInt8:function(e,r){Cs(this,1,e,MR,r)},setUint8:function(e,r){Cs(this,1,e,MR,r)},setInt16:function(e,r){Cs(this,2,e,NR,r,arguments.length>2?arguments[2]:!1)},setUint16:function(e,r){Cs(this,2,e,NR,r,arguments.length>2?arguments[2]:!1)},setInt32:function(e,r){Cs(this,4,e,LR,r,arguments.length>2?arguments[2]:!1)},setUint32:function(e,r){Cs(this,4,e,LR,r,arguments.length>2?arguments[2]:!1)},setFloat32:function(e,r){Cs(this,4,e,MK,r,arguments.length>2?arguments[2]:!1)},setFloat64:function(e,r){Cs(this,8,e,NK,r,arguments.length>2?arguments[2]:!1)}});else{var jR=xK&&Mi.name!==Ju;!mb(function(){Mi(1)})||!mb(function(){new Mi(-1)})||mb(function(){return new Mi,new Mi(1.5),new Mi(NaN),Mi.length!==1||jR&&!CR})?(Qn=function(e){return pp(this,Qu),CK(new Mi(vp(e)),this,Qn)},Qn[Yu]=Qu,Qu.constructor=Qn,RK(Qn,Mi)):jR&&CR&&bK(Mi,"name",Ju),TR&&$K(Mo)!==AR&&TR(Mo,AR);var bp=new ua(new Qn(2)),UR=pb(Mo.setInt8);bp.setInt8(0,2147483648),bp.setInt8(1,2147483649),(bp.getInt8(0)||!bp.getInt8(1))&&SR(Mo,{setInt8:function(e,r){UR(this,e,r<<24>>24)},setUint8:function(e,r){UR(this,e,r<<24>>24)}},{unsafe:!0})}ER(Qn,Ju),ER(ua,mp);var FR={ArrayBuffer:Qn,DataView:ua},LK=Xi,DK=RangeError,jK=function(t){var e=LK(t);if(e<0)throw new DK("The argument can't be less than 0");return e},UK=jK,FK=RangeError,BR=function(t,e){var r=UK(t);if(r%e)throw new FK("Wrong offset");return r},BK=Math.round,zK=function(t){var e=BK(t);return e<0?0:e>255?255:e&255},HK=Ra,qK=function(t){var e=HK(t);return e==="BigInt64Array"||e==="BigUint64Array"},VK=Mm,WK=TypeError,zR=function(t){var e=VK(t,"number");if(typeof e=="number")throw new WK("Can't convert number to bigint");return BigInt(e)},ZK=xa,GK=Er,KK=tg,JK=yn,YK=bn,QK=Oh,XK=td,eJ=ty,tJ=qK,rJ=Pr.aTypedArrayConstructor,nJ=zR,iJ=function(e){var r=KK(this),n=JK(e),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,o=XK(n),u,l,c,d,f,m,b,A;if(o&&!eJ(o))for(b=QK(n,o),A=b.next,n=[];!(m=GK(A,b)).done;)n.push(m.value);for(s&&i>2&&(a=ZK(a,arguments[2])),l=YK(n),c=new(rJ(r))(l),d=tJ(c),u=0;l>u;u++)f=s?a(n[u],u):n[u],c[u]=d?nJ(f):+f;return c},aJ=bn,HR=function(t,e,r){for(var n=0,i=arguments.length>2?r:aJ(e),a=new t(i);i>n;)a[n]=e[n++];return a},qR=er,VR=cr,WR=Er,sJ=Ar,oJ=GG,vd=Pr,ZR=FR,GR=bs,uJ=yo,md=Ea,lJ=lC,cJ=Ca,KR=gR,yb=BR,dJ=zK,JR=Yf,gd=Vr,fJ=Ra,bb=Lr,hJ=Tu,pJ=ps,vJ=Ta,wp=Mu,mJ=ko.f,YR=iJ,gJ=Un.forEach,yJ=wh,bJ=ra,QR=Cn,XR=$a,ex=HR,wb=Jn,wJ=Uh,_b=wb.get,_J=wb.set,kJ=wb.enforce,tx=QR.f,SJ=XR.f,kb=VR.RangeError,rx=ZR.ArrayBuffer,$J=rx.prototype,TJ=ZR.DataView,_p=vd.NATIVE_ARRAY_BUFFER_VIEWS,nx=vd.TYPED_ARRAY_TAG,ix=vd.TypedArray,yd=vd.TypedArrayPrototype,Sb=vd.isTypedArray,kp="BYTES_PER_ELEMENT",$b="Wrong length",Sp=function(t,e){bJ(t,e,{configurable:!0,get:function(){return _b(this)[e]}})},ax=function(t){var e;return vJ($J,t)||(e=fJ(t))==="ArrayBuffer"||e==="SharedArrayBuffer"},sx=function(t,e){return Sb(t)&&!hJ(e)&&e in t&&lJ(+e)&&e>=0},ox=function(e,r){return r=JR(r),sx(e,r)?uJ(2,e[r]):SJ(e,r)},ux=function(e,r,n){return r=JR(r),sx(e,r)&&bb(n)&&gd(n,"value")&&!gd(n,"get")&&!gd(n,"set")&&!n.configurable&&(!gd(n,"writable")||n.writable)&&(!gd(n,"enumerable")||n.enumerable)?(e[r]=n.value,e):tx(e,r,n)};sJ?(_p||(XR.f=ox,QR.f=ux,Sp(yd,"buffer"),Sp(yd,"byteOffset"),Sp(yd,"byteLength"),Sp(yd,"length")),qR({target:"Object",stat:!0,forced:!_p},{getOwnPropertyDescriptor:ox,defineProperty:ux}),ab.exports=function(t,e,r){var n=t.match(/\d+/)[0]/8,i=t+(r?"Clamped":"")+"Array",a="get"+t,s="set"+t,o=VR[i],u=o,l=u&&u.prototype,c={},d=function(A,N){var z=_b(A);return z.view[a](N*n+z.byteOffset,!0)},f=function(A,N,z){var X=_b(A);X.view[s](N*n+X.byteOffset,r?dJ(z):z,!0)},m=function(A,N){tx(A,N,{get:function(){return d(this,N)},set:function(z){return f(this,N,z)},enumerable:!0})};_p?oJ&&(u=e(function(A,N,z,X){return GR(A,l),wJ(function(){return bb(N)?ax(N)?X!==void 0?new o(N,yb(z,n),X):z!==void 0?new o(N,yb(z,n)):new o(N):Sb(N)?ex(u,N):WR(YR,u,N):new o(KR(N))}(),A,u)}),wp&&wp(u,ix),gJ(mJ(o),function(A){A in u||md(u,A,o[A])}),u.prototype=l):(u=e(function(A,N,z,X){GR(A,l);var Ee=0,Ie=0,Be,Oe,ze;if(!bb(N))ze=KR(N),Oe=ze*n,Be=new rx(Oe);else if(ax(N)){Be=N,Ie=yb(z,n);var V=N.byteLength;if(X===void 0){if(V%n)throw new kb($b);if(Oe=V-Ie,Oe<0)throw new kb($b)}else if(Oe=cJ(X)*n,Oe+Ie>V)throw new kb($b);ze=Oe/n}else return Sb(N)?ex(u,N):WR(YR,u,N);for(_J(A,{buffer:Be,byteOffset:Ie,byteLength:Oe,length:ze,view:new TJ(Be)});Ee<ze;)m(A,Ee++)}),wp&&wp(u,ix),l=u.prototype=pJ(yd)),l.constructor!==u&&md(l,"constructor",u),kJ(l).TypedArrayConstructor=u,nx&&md(l,nx,i);var b=u!==o;c[i]=u,qR({global:!0,constructor:!0,forced:b,sham:!_p},c),kp in u||md(u,kp,n),kp in l||md(l,kp,n),yJ(i)}):ab.exports=function(){};var EJ=ab.exports,CJ=EJ;CJ("Uint8",function(t){return function(r,n,i){return t(this,r,n,i)}});var lx=Pr,RJ=bn,xJ=Xi,IJ=lx.aTypedArray,AJ=lx.exportTypedArrayMethod;AJ("at",function(e){var r=IJ(this),n=RJ(r),i=xJ(e),a=i>=0?i:n+i;return a<0||a>=n?void 0:r[a]});var cx=wo,OJ=TypeError,Tb=function(t,e){if(!delete t[e])throw new OJ("Cannot delete property "+cx(e)+" of "+cx(t))},PJ=yn,Eb=xu,MJ=bn,NJ=Tb,LJ=Math.min,DJ=[].copyWithin||function(e,r){var n=PJ(this),i=MJ(n),a=Eb(e,i),s=Eb(r,i),o=arguments.length>2?arguments[2]:void 0,u=LJ((o===void 0?i:Eb(o,i))-s,i-a),l=1;for(s<a&&a<s+u&&(l=-1,s+=u-1,a+=u-1);u-- >0;)s in n?n[a]=n[s]:NJ(n,a),a+=l,s+=l;return n},jJ=Kt,dx=Pr,UJ=DJ,FJ=jJ(UJ),BJ=dx.aTypedArray,zJ=dx.exportTypedArrayMethod;zJ("copyWithin",function(e,r){return FJ(BJ(this),e,r,arguments.length>2?arguments[2]:void 0)});var fx=Pr,HJ=Un.every,qJ=fx.aTypedArray,VJ=fx.exportTypedArrayMethod;VJ("every",function(e){return HJ(qJ(this),e,arguments.length>1?arguments[1]:void 0)});var hx=Pr,WJ=_R,ZJ=zR,GJ=Ra,KJ=Er,JJ=Kt,YJ=Vt,QJ=hx.aTypedArray,XJ=hx.exportTypedArrayMethod,eY=JJ("".slice),tY=YJ(function(){var t=0;return new Int8Array(2).fill({valueOf:function(){return t++}}),t!==1});XJ("fill",function(e){var r=arguments.length;QJ(this);var n=eY(GJ(this),0,3)==="Big"?ZJ(e):+e;return KJ(WJ,this,n,r>1?arguments[1]:void 0,r>2?arguments[2]:void 0)},tY);var px=Pr,rY=xg,nY=px.aTypedArrayConstructor,iY=px.getTypedArrayConstructor,$p=function(t){return nY(rY(t,iY(t)))},aY=HR,sY=$p,oY=function(t,e){return aY(sY(t),e)},vx=Pr,uY=Un.filter,lY=oY,cY=vx.aTypedArray,dY=vx.exportTypedArrayMethod;dY("filter",function(e){var r=uY(cY(this),e,arguments.length>1?arguments[1]:void 0);return lY(this,r)});var mx=Pr,fY=Un.find,hY=mx.aTypedArray,pY=mx.exportTypedArrayMethod;pY("find",function(e){return fY(hY(this),e,arguments.length>1?arguments[1]:void 0)});var gx=Pr,vY=Un.findIndex,mY=gx.aTypedArray,gY=gx.exportTypedArrayMethod;gY("findIndex",function(e){return vY(mY(this),e,arguments.length>1?arguments[1]:void 0)});var yx=Pr,yY=Un.forEach,bY=yx.aTypedArray,wY=yx.exportTypedArrayMethod;wY("forEach",function(e){yY(bY(this),e,arguments.length>1?arguments[1]:void 0)});var bx=Pr,_Y=ah.includes,kY=bx.aTypedArray,SY=bx.exportTypedArrayMethod;SY("includes",function(e){return _Y(kY(this),e,arguments.length>1?arguments[1]:void 0)});var wx=Pr,$Y=ah.indexOf,TY=wx.aTypedArray,EY=wx.exportTypedArrayMethod;EY("indexOf",function(e){return $Y(TY(this),e,arguments.length>1?arguments[1]:void 0)});var CY=cr,RY=Vt,Cb=Kt,_x=Pr,Rb=mE,xY=Rr,xb=xY("iterator"),kx=CY.Uint8Array,IY=Cb(Rb.values),AY=Cb(Rb.keys),OY=Cb(Rb.entries),Ib=_x.aTypedArray,Tp=_x.exportTypedArrayMethod,Xu=kx&&kx.prototype,Ep=!RY(function(){Xu[xb].call([1])}),Sx=!!Xu&&Xu.values&&Xu[xb]===Xu.values&&Xu.values.name==="values",$x=function(){return IY(Ib(this))};Tp("entries",function(){return OY(Ib(this))},Ep),Tp("keys",function(){return AY(Ib(this))},Ep),Tp("values",$x,Ep||!Sx,{name:"values"}),Tp(xb,$x,Ep||!Sx,{name:"values"});var Tx=Pr,PY=Kt,MY=Tx.aTypedArray,NY=Tx.exportTypedArrayMethod,LY=PY([].join);NY("join",function(e){return LY(MY(this),e)});var DY=So,jY=Kn,UY=Xi,FY=bn,BY=yh,zY=Math.min,Ab=[].lastIndexOf,Ex=!!Ab&&1/[1].lastIndexOf(1,-0)<0,HY=BY("lastIndexOf"),qY=Ex||!HY,VY=qY?function(e){if(Ex)return DY(Ab,this,arguments)||0;var r=jY(this),n=FY(r);if(n===0)return-1;var i=n-1;for(arguments.length>1&&(i=zY(i,UY(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in r&&r[i]===e)return i||0;return-1}:Ab,Cx=Pr,WY=So,ZY=VY,GY=Cx.aTypedArray,KY=Cx.exportTypedArrayMethod;KY("lastIndexOf",function(e){var r=arguments.length;return WY(ZY,GY(this),r>1?[e,arguments[1]]:[e])});var Rx=Pr,JY=Un.map,YY=$p,QY=Rx.aTypedArray,XY=Rx.exportTypedArrayMethod;XY("map",function(e){return JY(QY(this),e,arguments.length>1?arguments[1]:void 0,function(r,n){return new(YY(r))(n)})});var eQ=si,tQ=yn,rQ=Pc,nQ=bn,xx=TypeError,Ix="Reduce of empty array with no initial value",Ax=function(t){return function(e,r,n,i){var a=tQ(e),s=rQ(a),o=nQ(a);if(eQ(r),o===0&&n<2)throw new xx(Ix);var u=t?o-1:0,l=t?-1:1;if(n<2)for(;;){if(u in s){i=s[u],u+=l;break}if(u+=l,t?u<0:o<=u)throw new xx(Ix)}for(;t?u>=0:o>u;u+=l)u in s&&(i=r(i,s[u],u,a));return i}},Ox={left:Ax(!1),right:Ax(!0)},Px=Pr,iQ=Ox.left,aQ=Px.aTypedArray,sQ=Px.exportTypedArrayMethod;sQ("reduce",function(e){var r=arguments.length;return iQ(aQ(this),e,r,r>1?arguments[1]:void 0)});var Mx=Pr,oQ=Ox.right,uQ=Mx.aTypedArray,lQ=Mx.exportTypedArrayMethod;lQ("reduceRight",function(e){var r=arguments.length;return oQ(uQ(this),e,r,r>1?arguments[1]:void 0)});var Nx=Pr,cQ=Nx.aTypedArray,dQ=Nx.exportTypedArrayMethod,fQ=Math.floor;dQ("reverse",function(){for(var e=this,r=cQ(e).length,n=fQ(r/2),i=0,a;i<n;)a=e[i],e[i++]=e[--r],e[r]=a;return e});var Lx=cr,Dx=Er,Ob=Pr,hQ=bn,pQ=BR,vQ=yn,jx=Vt,mQ=Lx.RangeError,Pb=Lx.Int8Array,Ux=Pb&&Pb.prototype,Fx=Ux&&Ux.set,gQ=Ob.aTypedArray,yQ=Ob.exportTypedArrayMethod,Mb=!jx(function(){var t=new Uint8ClampedArray(2);return Dx(Fx,t,{length:1,0:3},1),t[1]!==3}),bQ=Mb&&Ob.NATIVE_ARRAY_BUFFER_VIEWS&&jx(function(){var t=new Pb(2);return t.set(1),t.set("2",1),t[0]!==0||t[1]!==2});yQ("set",function(e){gQ(this);var r=pQ(arguments.length>1?arguments[1]:void 0,1),n=vQ(e);if(Mb)return Dx(Fx,this,n,r);var i=this.length,a=hQ(n),s=0;if(a+r>i)throw new mQ("Wrong length");for(;s<a;)this[r+s]=n[s++]},!Mb||bQ);var Bx=Pr,wQ=$p,_Q=Vt,kQ=ta,SQ=Bx.aTypedArray,$Q=Bx.exportTypedArrayMethod,TQ=_Q(function(){new Int8Array(1).slice()});$Q("slice",function(e,r){for(var n=kQ(SQ(this),e,r),i=wQ(this),a=0,s=n.length,o=new i(s);s>a;)o[a]=n[a++];return o},TQ);var zx=Pr,EQ=Un.some,CQ=zx.aTypedArray,RQ=zx.exportTypedArrayMethod;RQ("some",function(e){return EQ(CQ(this),e,arguments.length>1?arguments[1]:void 0)});var Hx=ta,xQ=Math.floor,Nb=function(t,e){var r=t.length;if(r<8)for(var n=1,i,a;n<r;){for(a=n,i=t[n];a&&e(t[a-1],i)>0;)t[a]=t[--a];a!==n++&&(t[a]=i)}else for(var s=xQ(r/2),o=Nb(Hx(t,0,s),e),u=Nb(Hx(t,s),e),l=o.length,c=u.length,d=0,f=0;d<l||f<c;)t[d+f]=d<l&&f<c?e(o[d],u[f])<=0?o[d++]:u[f++]:d<l?o[d++]:u[f++];return t},Lb=Nb,IQ=bo,qx=IQ.match(/firefox\/(\d+)/i),Vx=!!qx&&+qx[1],AQ=bo,Wx=/MSIE|Trident/.test(AQ),OQ=bo,Zx=OQ.match(/AppleWebKit\/(\d+)\./),Gx=!!Zx&&+Zx[1],PQ=cr,MQ=cg,Db=Vt,NQ=si,LQ=Lb,Kx=Pr,Jx=Vx,DQ=Wx,Yx=Su,Qx=Gx,jQ=Kx.aTypedArray,UQ=Kx.exportTypedArrayMethod,bd=PQ.Uint16Array,el=bd&&MQ(bd.prototype.sort),FQ=!!el&&!(Db(function(){el(new bd(2),null)})&&Db(function(){el(new bd(2),{})})),Xx=!!el&&!Db(function(){if(Yx)return Yx<74;if(Jx)return Jx<67;if(DQ)return!0;if(Qx)return Qx<602;var t=new bd(516),e=Array(516),r,n;for(r=0;r<516;r++)n=r%4,t[r]=515-r,e[r]=r-2*n+3;for(el(t,function(i,a){return(i/4|0)-(a/4|0)}),r=0;r<516;r++)if(t[r]!==e[r])return!0}),BQ=function(t){return function(e,r){return t!==void 0?+t(e,r)||0:r!==r?-1:e!==e?1:e===0&&r===0?1/e>0&&1/r<0?1:-1:e>r}};UQ("sort",function(e){return e!==void 0&&NQ(e),Xx?el(this,e):LQ(jQ(this),BQ(e))},!Xx||FQ);var eI=Pr,zQ=Ca,tI=xu,HQ=$p,qQ=eI.aTypedArray,VQ=eI.exportTypedArrayMethod;VQ("subarray",function(e,r){var n=qQ(this),i=n.length,a=tI(e,i),s=HQ(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,zQ((r===void 0?i:tI(r,i))-a))});var WQ=cr,ZQ=So,rI=Pr,jb=Vt,nI=ta,Cp=WQ.Int8Array,iI=rI.aTypedArray,GQ=rI.exportTypedArrayMethod,aI=[].toLocaleString,KQ=!!Cp&&jb(function(){aI.call(new Cp(1))}),JQ=jb(function(){return[1,2].toLocaleString()!==new Cp([1,2]).toLocaleString()})||!jb(function(){Cp.prototype.toLocaleString.call([1,2])});GQ("toLocaleString",function(){return ZQ(aI,KQ?nI(iI(this)):iI(this),nI(arguments))},JQ);var YQ=Pr.exportTypedArrayMethod,QQ=Vt,XQ=cr,eX=Kt,sI=XQ.Uint8Array,tX=sI&&sI.prototype||{},Rp=[].toString,rX=eX([].join);QQ(function(){Rp.call({})})&&(Rp=function(){return rX(this)});var nX=tX.toString!==Rp;YQ("toString",Rp,nX);var Ub=Er,oI=Kt,iX=Vh,aX=Gr,sX=xi,oX=Ii,uX=xg,lX=Py,cX=Ca,uI=rn,dX=_o,lI=Wh,fX=AE,hX=Vt,tl=fX.UNSUPPORTED_Y,pX=4294967295,vX=Math.min,Fb=oI([].push),Bb=oI("".slice),mX=!hX(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var r="ab".split(t);return r.length!==2||r[0]!=="a"||r[1]!=="b"}),cI="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;iX("split",function(t,e,r){var n="0".split(void 0,0).length?function(i,a){return i===void 0&&a===0?[]:Ub(e,this,i,a)}:e;return[function(a,s){var o=oX(this),u=sX(a)?void 0:dX(a,t);return u?Ub(u,a,o,s):Ub(n,uI(o),a,s)},function(i,a){var s=aX(this),o=uI(i);if(!cI){var u=r(n,s,o,a,n!==e);if(u.done)return u.value}var l=uX(s,RegExp),c=s.unicode,d=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(tl?"g":"y"),f=new l(tl?"^(?:"+s.source+")":s,d),m=a===void 0?pX:a>>>0;if(m===0)return[];if(o.length===0)return lI(f,o)===null?[o]:[];for(var b=0,A=0,N=[];A<o.length;){f.lastIndex=tl?0:A;var z=lI(f,tl?Bb(o,A):o),X;if(z===null||(X=vX(cX(f.lastIndex+(tl?A:0)),o.length))===b)A=lX(o,A,c);else{if(Fb(N,Bb(o,b,A)),N.length===m)return N;for(var Ee=1;Ee<=z.length-1;Ee++)if(Fb(N,z[Ee]),N.length===m)return N;A=b=X}}return Fb(N,Bb(o,b)),N}]},cI||!mX,tl);var dI={exports:{}},fI={exports:{}};(function(t){function e(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch{return typeof r=="function"}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(fI);var gX=fI.exports,hI={exports:{}},pI={exports:{}};(function(t){function e(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(t.exports=e=function(){return!!r},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(pI);var yX=pI.exports;(function(t){var e=yX,r=Tg;function n(i,a,s){if(e())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,a);var u=new(i.bind.apply(i,o));return s&&r(u,s.prototype),u}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(hI);var bX=hI.exports;(function(t){var e=li,r=Tg,n=gX,i=bX;function a(s){var o=typeof Map=="function"?new Map:void 0;return t.exports=a=function(l){if(l===null||!n(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(l))return o.get(l);o.set(l,c)}function c(){return i(l,arguments,e(this).constructor)}return c.prototype=Object.create(l.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),r(c,l)},t.exports.__esModule=!0,t.exports.default=t.exports,a(s)}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(dI);var wd=dI.exports,xp={exports:{}};/*!
838
+ */Object.defineProperty(sa,"__esModule",{value:!0});var FZ=aa,BZ=Aa,zZ=gs,HZ=na,qZ=ia,VZ=li,WZ=ys;function Oo(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var Ky=Oo(FZ),Jy=Oo(BZ),ja=Oo(zZ),Yy=Oo(HZ),UC=Oo(qZ),sp=Oo(VZ),Ua=Oo(WZ),ZZ;function Ss(){}Ss.prototype=Object.create(null);function kr(){kr.init.call(this)}kr.EventEmitter=kr,kr.usingDomains=!1,kr.prototype.domain=void 0,kr.prototype._events=void 0,kr.prototype._maxListeners=void 0,kr.defaultMaxListeners=10,kr.init=function(){this.domain=null,kr.usingDomains&&ZZ.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new Ss,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},kr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function FC(t){return t._maxListeners===void 0?kr.defaultMaxListeners:t._maxListeners}kr.prototype.getMaxListeners=function(){return FC(this)};function GZ(t,e,r){if(e)t.call(r);else for(var n=t.length,i=fd(t,n),a=0;a<n;++a)i[a].call(r)}function KZ(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=fd(t,i),s=0;s<i;++s)a[s].call(r,n)}function JZ(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=fd(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function YZ(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=fd(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function QZ(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=fd(t,i),s=0;s<i;++s)a[s].apply(r,n)}kr.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:GZ(n,d,this);break;case 2:KZ(n,d,this,arguments[1]);break;case 3:JZ(n,d,this,arguments[1],arguments[2]);break;case 4:YZ(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];QZ(n,d,this,a)}return!0};function BC(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new Ss,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=FC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,XZ(o)}return t}function XZ(t){typeof console.warn=="function"?console.warn(t):console.log(t)}kr.prototype.addListener=function(e,r){return BC(this,e,r,!1)},kr.prototype.on=kr.prototype.addListener,kr.prototype.prependListener=function(e,r){return BC(this,e,r,!0)};function zC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}kr.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,zC(this,e,r)),this},kr.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,zC(this,e,r)),this},kr.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new Ss:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new Ss,this;delete i[e]}else eG(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},kr.prototype.off=function(t,e){return this.removeListener(t,e)},kr.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new Ss,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new Ss:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new Ss,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},kr.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=tG(r):n=[]):n=[],n},kr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):HC.call(t,e)},kr.prototype.listenerCount=HC;function HC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}kr.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function eG(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function fd(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function tG(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function qC(t){var e=rG();return function(){var n=sp.default(t),i;if(e){var a=sp.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return UC.default(this,i)}}function rG(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var VC=function(t){Yy.default(r,t);var e=qC(r);function r(n){var i;return Ky.default(this,r),i=e.call(this),Ua.default(ja.default(i),"timeout",null),Ua.default(ja.default(i),"startTimestamp",-1),i.minDelay=n.min,i.maxDelay=n.max,i.initialDelay=n.initial||0,i.maxAttemptsCount=n.maxAttemptsCount||0,i.maxAttemptsTime=n.maxAttemptsTime||0,i.randomness=n.randomness||0,i.inProgress=!1,i.attemptNum=0,i.prevDelay=0,i.currDelay=0,i}return Jy.default(r,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(i){if(typeof i=="number")return this.prevDelay=0,this.currDelay=i,i;if(this.attemptNum==0)return this.initialDelay;if(this.attemptNum==1)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var a=this.currDelay+this.prevDelay;return this.maxDelay&&a>this.maxDelay&&(this.currDelay=this.maxDelay,a=this.maxDelay),this.currDelay=a,a}},{key:"randomize",value:function(i){var a=i*this.randomness,s=Math.round(Math.random()*a*2-a);return Math.max(0,i+s)}},{key:"scheduleAttempt",value:function(i){var a=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount){this.cleanup(),this.emit("failed",new Error("Maximum attempt count limit reached"));return}var s=this.nextDelay(i);if(s=this.randomize(s),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+s){this.cleanup(),this.emit("failed",new Error("Maximum attempt time limit reached"));return}this.timeout=setTimeout(function(){return a.attempt()},s)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(i){this.emit("succeeded",i)}},{key:"failed",value:function(i,a){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(a)}}]),r}(kr),nG=function(t){Yy.default(r,t);var e=qC(r);function r(n){var i;return Ky.default(this,r),i=e.call(this),Ua.default(ja.default(i),"resolve",function(){}),Ua.default(ja.default(i),"reject",function(){}),i.retrier=new VC(n),i}return Jy.default(r,[{key:"run",value:function(i){var a=this;return this.retrier.on("attempt",function(){i().then(function(s){return a.retrier.succeeded(s)}).catch(function(s){return a.retrier.failed(s)})}),this.retrier.on("succeeded",function(s){return a.resolve(s)}),this.retrier.on("cancelled",function(){return a.reject(new Error("Cancelled"))}),this.retrier.on("failed",function(s){return a.reject(s)}),new Promise(function(s,o){a.resolve=s,a.reject=o,a.retrier.start()})}},{key:"cancel",value:function(){this.retrier.cancel()}}]),r}(kr);function iG(t){var e=aG();return function(){var n=sp.default(t),i;if(e){var a=sp.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return UC.default(this,i)}}function aG(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function op(t){return t!=null}var sG=function(t){Yy.default(r,t);var e=iG(r);function r(n){var i;Ky.default(this,r),i=e.call(this),Ua.default(ja.default(i),"backoffDelay",0),Ua.default(ja.default(i),"nextBackoffDelay",0),Ua.default(ja.default(i),"backoffNumber",0),Ua.default(ja.default(i),"timeoutID",null),Ua.default(ja.default(i),"maxNumberOfRetry",-1),n=n||{};var a=n,s=a.initialDelay,o=a.maxDelay,u=a.randomisationFactor,l=a.factor;if(op(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(op(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(op(u)&&(u<0||u>1))throw new Error("The randomisation factor must be between 0 and 1.");if(op(l)&&l<=1)throw new Error("Exponential factor should be greater than 1.");if(i.initialDelay=s||100,i.maxDelay=o||1e4,i.maxDelay<=i.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return i.randomisationFactor=u||0,i.factor=l||2,i.reset(),i}return Jy.default(r,[{key:"backoff",value:function(i){this.timeoutID==null&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",i),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,i)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(i){if(i<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(i));this.maxNumberOfRetry=i}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var i=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*i))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(i){return new r(i)}}]),r}(kr);sa.AsyncRetrier=nG,sa.Backoff=sG,sa.Retrier=VC;var Qy={},oG=Er,uG=Vr,lG=Ta,cG=IE,WC=RegExp.prototype,dG=function(t){var e=t.flags;return e===void 0&&!("flags"in WC)&&!uG(t,"flags")&&lG(WC,t)?oG(cG,t):e},fG=Nc.PROPER,hG=Rn,pG=Gr,ZC=rn,vG=Vt,mG=dG,Xy="toString",GC=RegExp.prototype,KC=GC[Xy],gG=vG(function(){return KC.call({source:"a",flags:"b"})!=="/a/b"}),yG=fG&&KC.name!==Xy;(gG||yG)&&hG(GC,Xy,function(){var e=pG(this),r=ZC(e.source),n=ZC(mG(e));return"/"+r+"/"+n},{unsafe:!0});var bG=Zy,wG=jC;bG("Set",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},wG);var JC={exports:{}};(function(t,e){(function(n,i){t.exports=i()})(ln,function(){return function(r){var n={};function i(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return r[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=r,i.c=n,i.i=function(a){return a},i.d=function(a,s,o){i.o(a,s)||Object.defineProperty(a,s,{configurable:!1,enumerable:!0,get:o})},i.n=function(a){var s=a&&a.__esModule?function(){return a.default}:function(){return a};return i.d(s,"a",s),s},i.o=function(a,s){return Object.prototype.hasOwnProperty.call(a,s)},i.p="",i(i.s=5)}([function(r,n,i){r.exports=function(a,s){var o,u,l;for(o=1;o<arguments.length;o++){u=arguments[o];for(l in u)u.hasOwnProperty(l)&&(a[l]=u[l])}return a}},function(r,n,i){var a=i(0);r.exports={build:function(s,o){var u,l,c,d=o.plugins;for(u=0,l=d.length;u<l;u++)c=d[u],c.methods&&a(s,c.methods),c.properties&&Object.defineProperties(s,c.properties)},hook:function(s,o,u){var l,c,d,f,m=s.config.plugins,b=[s.context];for(u&&(b=b.concat(u)),l=0,c=m.length;l<c;l++)f=m[l],d=m[l][o],d&&d.apply(f,b)}}},function(r,n,i){function a(s){if(s.length===0)return s;var o,u,l=s.split(/[_-]/);if(l.length===1&&l[0][0].toLowerCase()===l[0][0])return s;for(u=l[0].toLowerCase(),o=1;o<l.length;o++)u=u+l[o].charAt(0).toUpperCase()+l[o].substring(1).toLowerCase();return u}a.prepended=function(s,o){return o=a(o),s+o[0].toUpperCase()+o.substring(1)},r.exports=a},function(r,n,i){var a=i(0),s=i(2);function o(u,l){u=u||{},this.options=u,this.defaults=l.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(u.init),this.data=this.configureData(u.data),this.methods=this.configureMethods(u.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(u.transitions||[]),this.plugins=this.configurePlugins(u.plugins,l.plugin)}a(o.prototype,{addState:function(u){this.map[u]||(this.states.push(u),this.addStateLifecycleNames(u),this.map[u]={})},addStateLifecycleNames:function(u){this.lifecycle.onEnter[u]=s.prepended("onEnter",u),this.lifecycle.onLeave[u]=s.prepended("onLeave",u),this.lifecycle.on[u]=s.prepended("on",u)},addTransition:function(u){this.transitions.indexOf(u)<0&&(this.transitions.push(u),this.addTransitionLifecycleNames(u))},addTransitionLifecycleNames:function(u){this.lifecycle.onBefore[u]=s.prepended("onBefore",u),this.lifecycle.onAfter[u]=s.prepended("onAfter",u),this.lifecycle.on[u]=s.prepended("on",u)},mapTransition:function(u){var l=u.name,c=u.from,d=u.to;return this.addState(c),typeof d!="function"&&this.addState(d),this.addTransition(l),this.map[c][l]=u,u},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(u){return typeof u=="string"?this.mapTransition(a({},this.defaults.init,{to:u,active:!0})):typeof u=="object"?this.mapTransition(a({},this.defaults.init,u,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(u){return typeof u=="function"?u:typeof u=="object"?function(){return u}:function(){return{}}},configureMethods:function(u){return u||{}},configurePlugins:function(u,l){u=u||[];var c,d,f;for(c=0,d=u.length;c<d;c++)f=u[c],typeof f=="function"&&(u[c]=f=f()),f.configure&&f.configure(this);return u},configureTransitions:function(u){var l,c,d,f,m,b=this.defaults.wildcard;for(c=0;c<u.length;c++)for(d=u[c],f=Array.isArray(d.from)?d.from:[d.from||b],m=d.to||b,l=0;l<f.length;l++)this.mapTransition({name:d.name,from:f[l],to:m})},transitionFor:function(u,l){var c=this.defaults.wildcard;return this.map[u][l]||this.map[c][l]},transitionsFor:function(u){var l=this.defaults.wildcard;return Object.keys(this.map[u]).concat(Object.keys(this.map[l]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),r.exports=o},function(r,n,i){var a=i(0),s=i(6),o=i(1),u=[null,[]];function l(c,d){this.context=c,this.config=d,this.state=d.init.from,this.observers=[c]}a(l.prototype,{init:function(c){if(a(this.context,this.config.data.apply(this.context,c)),o.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(c){return Array.isArray(c)?c.indexOf(this.state)>=0:this.state===c},isPending:function(){return this.pending},can:function(c){return!this.isPending()&&!!this.seek(c)},cannot:function(c){return!this.can(c)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(c,d){var f=this.config.defaults.wildcard,m=this.config.transitionFor(this.state,c),b=m&&m.to;return typeof b=="function"?b.apply(this.context,d):b===f?this.state:b},fire:function(c,d){return this.transit(c,this.state,this.seek(c,d),d)},transit:function(c,d,f,m){var b=this.config.lifecycle,A=this.config.options.observeUnchangedState||d!==f;return f?this.isPending()?this.context.onPendingTransition(c,d,f):(this.config.addState(f),this.beginTransit(),m.unshift({transition:c,from:d,to:f,fsm:this.context}),this.observeEvents([this.observersForEvent(b.onBefore.transition),this.observersForEvent(b.onBefore[c]),A?this.observersForEvent(b.onLeave.state):u,A?this.observersForEvent(b.onLeave[d]):u,this.observersForEvent(b.on.transition),A?["doTransit",[this]]:u,A?this.observersForEvent(b.onEnter.state):u,A?this.observersForEvent(b.onEnter[f]):u,A?this.observersForEvent(b.on[f]):u,this.observersForEvent(b.onAfter.transition),this.observersForEvent(b.onAfter[c]),this.observersForEvent(b.on[c])],m)):this.context.onInvalidTransition(c,d,f)},beginTransit:function(){this.pending=!0},endTransit:function(c){return this.pending=!1,c},failTransit:function(c){throw this.pending=!1,c},doTransit:function(c){this.state=c.to},observe:function(c){if(c.length===2){var d={};d[c[0]]=c[1],this.observers.push(d)}else this.observers.push(c[0])},observersForEvent:function(c){for(var d=0,f=this.observers.length,m,b=[];d<f;d++)m=this.observers[d],m[c]&&b.push(m);return[c,b,!0]},observeEvents:function(c,d,f,m){if(c.length===0)return this.endTransit(m===void 0?!0:m);var b=c[0][0],A=c[0][1],N=c[0][2];if(d[0].event=b,b&&N&&b!==f&&o.hook(this,"lifecycle",d),A.length===0)return c.shift(),this.observeEvents(c,d,b,m);var z=A.shift(),X=z[b].apply(z,d);return X&&typeof X.then=="function"?X.then(this.observeEvents.bind(this,c,d,b)).catch(this.failTransit.bind(this)):X===!1?this.endTransit(!1):this.observeEvents(c,d,b,X)},onInvalidTransition:function(c,d,f){throw new s("transition is invalid in current state",c,d,f,this.state)},onPendingTransition:function(c,d,f){throw new s("transition is invalid while previous transition is still in progress",c,d,f,this.state)}}),r.exports=l},function(r,n,i){var a=i(0),s=i(2),o=i(1),u=i(3),l=i(4),c={is:function(N){return this._fsm.is(N)},can:function(N){return this._fsm.can(N)},cannot:function(N){return this._fsm.cannot(N)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(N,z,X){return this._fsm.onInvalidTransition(N,z,X)},onPendingTransition:function(N,z,X){return this._fsm.onPendingTransition(N,z,X)}},d={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(N){throw Error("use transitions to change state")}}};function f(N){return b(this||{},N)}function m(){var N,z;typeof arguments[0]=="function"?(N=arguments[0],z=arguments[1]||{}):(N=function(){this._fsm.apply(this,arguments)},z=arguments[0]||{});var X=new u(z,f);return A(N.prototype,X),N.prototype._fsm.config=X,N}function b(N,z){var X=new u(z,f);return A(N,X),N._fsm(),N}function A(N,z){if(typeof N!="object"||Array.isArray(N))throw Error("StateMachine can only be applied to objects");o.build(N,z),Object.defineProperties(N,d),a(N,c),a(N,z.methods),z.allTransitions().forEach(function(X){N[s(X)]=function(){return this._fsm.fire(X,[].slice.call(arguments))}}),N._fsm=function(){this._fsm=new l(this,z),this._fsm.init(arguments)}}f.version="3.0.1",f.factory=m,f.apply=b,f.defaults={wildcard:"*",init:{name:"init",from:"none"}},r.exports=f},function(r,n,i){r.exports=function(a,s,o,u,l){this.message=a,this.transition=s,this.from=o,this.to=u,this.current=l}}])})})(JC);var YC=JC.exports,eb={exports:{}},QC=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(QC){var XC=new Uint8Array(16);eb.exports=function(){return QC(XC),XC}}else{var eR=new Array(16);eb.exports=function(){for(var e=0,r;e<16;e++)e&3||(r=Math.random()*4294967296),eR[e]=r>>>((e&3)<<3)&255;return eR}}for(var tR=eb.exports,rR=[],up=0;up<256;++up)rR[up]=(up+256).toString(16).substr(1);function _G(t,e){var r=e||0,n=rR;return[n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]]].join("")}var nR=_G,kG=tR,SG=nR,iR,tb,rb=0,nb=0;function $G(t,e,r){var n=e&&r||0,i=e||[];t=t||{};var a=t.node||iR,s=t.clockseq!==void 0?t.clockseq:tb;if(a==null||s==null){var o=kG();a==null&&(a=iR=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=tb=(o[6]<<8|o[7])&16383)}var u=t.msecs!==void 0?t.msecs:new Date().getTime(),l=t.nsecs!==void 0?t.nsecs:nb+1,c=u-rb+(l-nb)/1e4;if(c<0&&t.clockseq===void 0&&(s=s+1&16383),(c<0||u>rb)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");rb=u,nb=l,tb=s,u+=122192928e5;var d=((u&268435455)*1e4+l)%4294967296;i[n++]=d>>>24&255,i[n++]=d>>>16&255,i[n++]=d>>>8&255,i[n++]=d&255;var f=u/4294967296*1e4&268435455;i[n++]=f>>>8&255,i[n++]=f&255,i[n++]=f>>>24&15|16,i[n++]=f>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return e||SG(i)}var TG=$G,EG=tR,CG=nR;function RG(t,e,r){var n=e&&r||0;typeof t=="string"&&(e=t==="binary"?new Array(16):null,t=null),t=t||{};var i=t.random||(t.rng||EG)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e)for(var a=0;a<16;++a)e[n+a]=i[a];return e||CG(i)}var xG=RG,IG=TG,aR=xG,ib=aR;ib.v1=IG,ib.v4=aR;var hd=ib,ab={exports:{}},sR=typeof ArrayBuffer<"u"&&typeof DataView<"u",AG=sR,sb=Ar,xn=cr,oR=Cr,lp=Lr,$s=Vr,ob=Ra,OG=wo,PG=Ea,ub=Rn,MG=ra,NG=Ta,cp=nd,Gu=Mu,LG=Rr,DG=Mc,uR=Jn,lR=uR.enforce,jG=uR.get,dp=xn.Int8Array,lb=dp&&dp.prototype,cR=xn.Uint8ClampedArray,dR=cR&&cR.prototype,oa=dp&&cp(dp),Pi=lb&&cp(lb),UG=Object.prototype,cb=xn.TypeError,fR=LG("toStringTag"),db=DG("TYPED_ARRAY_TAG"),fp="TypedArrayConstructor",Fa=AG&&!!Gu&&ob(xn.opera)!=="Opera",hR=!1,Bn,Ts,Ku,Ba={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},fb={BigInt64Array:8,BigUint64Array:8},FG=function(e){if(!lp(e))return!1;var r=ob(e);return r==="DataView"||$s(Ba,r)||$s(fb,r)},pR=function(t){var e=cp(t);if(lp(e)){var r=jG(e);return r&&$s(r,fp)?r[fp]:pR(e)}},vR=function(t){if(!lp(t))return!1;var e=ob(t);return $s(Ba,e)||$s(fb,e)},BG=function(t){if(vR(t))return t;throw new cb("Target is not a typed array")},zG=function(t){if(oR(t)&&(!Gu||NG(oa,t)))return t;throw new cb(OG(t)+" is not a typed array constructor")},HG=function(t,e,r,n){if(sb){if(r)for(var i in Ba){var a=xn[i];if(a&&$s(a.prototype,t))try{delete a.prototype[t]}catch{try{a.prototype[t]=e}catch{}}}(!Pi[t]||r)&&ub(Pi,t,r?e:Fa&&lb[t]||e,n)}},qG=function(t,e,r){var n,i;if(sb){if(Gu){if(r){for(n in Ba)if(i=xn[n],i&&$s(i,t))try{delete i[t]}catch{}}if(!oa[t]||r)try{return ub(oa,t,r?e:Fa&&oa[t]||e)}catch{}else return}for(n in Ba)i=xn[n],i&&(!i[t]||r)&&ub(i,t,e)}};for(Bn in Ba)Ts=xn[Bn],Ku=Ts&&Ts.prototype,Ku?lR(Ku)[fp]=Ts:Fa=!1;for(Bn in fb)Ts=xn[Bn],Ku=Ts&&Ts.prototype,Ku&&(lR(Ku)[fp]=Ts);if((!Fa||!oR(oa)||oa===Function.prototype)&&(oa=function(){throw new cb("Incorrect invocation")},Fa))for(Bn in Ba)xn[Bn]&&Gu(xn[Bn],oa);if((!Fa||!Pi||Pi===UG)&&(Pi=oa.prototype,Fa))for(Bn in Ba)xn[Bn]&&Gu(xn[Bn].prototype,Pi);if(Fa&&cp(dR)!==Pi&&Gu(dR,Pi),sb&&!$s(Pi,fR)){hR=!0,MG(Pi,fR,{configurable:!0,get:function(){return lp(this)?this[db]:void 0}});for(Bn in Ba)xn[Bn]&&PG(xn[Bn],db,Bn)}var Pr={NATIVE_ARRAY_BUFFER_VIEWS:Fa,TYPED_ARRAY_TAG:hR&&db,aTypedArray:BG,aTypedArrayConstructor:zG,exportTypedArrayMethod:HG,exportTypedArrayStaticMethod:qG,getTypedArrayConstructor:pR,isView:FG,isTypedArray:vR,TypedArray:oa,TypedArrayPrototype:Pi},mR=cr,hb=Vt,VG=Mh,WG=Pr.NATIVE_ARRAY_BUFFER_VIEWS,ZG=mR.ArrayBuffer,Po=mR.Int8Array,GG=!WG||!hb(function(){Po(1)})||!hb(function(){new Po(-1)})||!VG(function(t){new Po,new Po(null),new Po(1.5),new Po(t)},!0)||hb(function(){return new Po(new ZG(2),1,void 0).length!==1}),KG=Xi,JG=Ca,YG=RangeError,gR=function(t){if(t===void 0)return 0;var e=KG(t),r=JG(e);if(e!==r)throw new YG("Wrong length or index");return r},QG=Math.sign||function(e){var r=+e;return r===0||r!==r?r:r<0?-1:1},XG=QG,eK=Math.abs,yR=2220446049250313e-31,bR=1/yR,tK=function(t){return t+bR-bR},rK=function(t,e,r,n){var i=+t,a=eK(i),s=XG(i);if(a<n)return s*tK(a/n/e)*n*e;var o=(1+e/yR)*a,u=o-(o-a);return u>r||u!==u?s*(1/0):s*u},nK=rK,iK=11920928955078125e-23,aK=34028234663852886e22,sK=11754943508222875e-54,oK=Math.fround||function(e){return nK(e,iK,aK,sK)},uK=Array,lK=Math.abs,za=Math.pow,cK=Math.floor,dK=Math.log,fK=Math.LN2,hK=function(t,e,r){var n=uK(r),i=r*8-e-1,a=(1<<i)-1,s=a>>1,o=e===23?za(2,-24)-za(2,-77):0,u=t<0||t===0&&1/t<0?1:0,l=0,c,d,f;for(t=lK(t),t!==t||t===1/0?(d=t!==t?1:0,c=a):(c=cK(dK(t)/fK),f=za(2,-c),t*f<1&&(c--,f*=2),c+s>=1?t+=o/f:t+=o*za(2,1-s),t*f>=2&&(c++,f/=2),c+s>=a?(d=0,c=a):c+s>=1?(d=(t*f-1)*za(2,e),c+=s):(d=t*za(2,s-1)*za(2,e),c=0));e>=8;)n[l++]=d&255,d/=256,e-=8;for(c=c<<e|d,i+=e;i>0;)n[l++]=c&255,c/=256,i-=8;return n[--l]|=u*128,n},pK=function(t,e){var r=t.length,n=r*8-e-1,i=(1<<n)-1,a=i>>1,s=n-7,o=r-1,u=t[o--],l=u&127,c;for(u>>=7;s>0;)l=l*256+t[o--],s-=8;for(c=l&(1<<-s)-1,l>>=-s,s+=e;s>0;)c=c*256+t[o--],s-=8;if(l===0)l=1-a;else{if(l===i)return c?NaN:u?-1/0:1/0;c+=za(2,e),l-=a}return(u?-1:1)*c*za(2,l-e)},vK={pack:hK,unpack:pK},mK=yn,wR=xu,gK=bn,_R=function(e){for(var r=mK(this),n=gK(r),i=arguments.length,a=wR(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,o=s===void 0?n:wR(s,n);o>a;)r[a++]=e;return r},hp=cr,pb=Kt,vb=Ar,yK=sR,kR=Nc,bK=Ea,wK=ra,SR=ip,mb=Vt,pp=bs,_K=Xi,kK=Ca,vp=gR,SK=oK,$R=vK,$K=nd,TR=Mu,TK=_R,EK=ta,CK=Uh,RK=Ym,ER=ea,gb=Jn,xK=kR.PROPER,CR=kR.CONFIGURABLE,Ju="ArrayBuffer",mp="DataView",Yu="prototype",IK="Wrong length",RR="Wrong index",xR=gb.getterFor(Ju),pd=gb.getterFor(mp),IR=gb.set,Mi=hp[Ju],Qn=Mi,Qu=Qn&&Qn[Yu],ua=hp[mp],Mo=ua&&ua[Yu],AR=Object.prototype,AK=hp.Array,gp=hp.RangeError,OK=pb(TK),PK=pb([].reverse),OR=$R.pack,PR=$R.unpack,MR=function(t){return[t&255]},NR=function(t){return[t&255,t>>8&255]},LR=function(t){return[t&255,t>>8&255,t>>16&255,t>>24&255]},DR=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},MK=function(t){return OR(SK(t),23,4)},NK=function(t){return OR(t,52,8)},yp=function(t,e,r){wK(t[Yu],e,{configurable:!0,get:function(){return r(this)[e]}})},Es=function(t,e,r,n){var i=pd(t),a=vp(r),s=!!n;if(a+e>i.byteLength)throw new gp(RR);var o=i.bytes,u=a+i.byteOffset,l=EK(o,u,u+e);return s?l:PK(l)},Cs=function(t,e,r,n,i,a){var s=pd(t),o=vp(r),u=n(+i),l=!!a;if(o+e>s.byteLength)throw new gp(RR);for(var c=s.bytes,d=o+s.byteOffset,f=0;f<e;f++)c[d+f]=u[l?f:e-f-1]};if(!yK)Qn=function(e){pp(this,Qu);var r=vp(e);IR(this,{type:Ju,bytes:OK(AK(r),0),byteLength:r}),vb||(this.byteLength=r,this.detached=!1)},Qu=Qn[Yu],ua=function(e,r,n){pp(this,Mo),pp(e,Qu);var i=xR(e),a=i.byteLength,s=_K(r);if(s<0||s>a)throw new gp("Wrong offset");if(n=n===void 0?a-s:kK(n),s+n>a)throw new gp(IK);IR(this,{type:mp,buffer:e,byteLength:n,byteOffset:s,bytes:i.bytes}),vb||(this.buffer=e,this.byteLength=n,this.byteOffset=s)},Mo=ua[Yu],vb&&(yp(Qn,"byteLength",xR),yp(ua,"buffer",pd),yp(ua,"byteLength",pd),yp(ua,"byteOffset",pd)),SR(Mo,{getInt8:function(e){return Es(this,1,e)[0]<<24>>24},getUint8:function(e){return Es(this,1,e)[0]},getInt16:function(e){var r=Es(this,2,e,arguments.length>1?arguments[1]:!1);return(r[1]<<8|r[0])<<16>>16},getUint16:function(e){var r=Es(this,2,e,arguments.length>1?arguments[1]:!1);return r[1]<<8|r[0]},getInt32:function(e){return DR(Es(this,4,e,arguments.length>1?arguments[1]:!1))},getUint32:function(e){return DR(Es(this,4,e,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(e){return PR(Es(this,4,e,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(e){return PR(Es(this,8,e,arguments.length>1?arguments[1]:!1),52)},setInt8:function(e,r){Cs(this,1,e,MR,r)},setUint8:function(e,r){Cs(this,1,e,MR,r)},setInt16:function(e,r){Cs(this,2,e,NR,r,arguments.length>2?arguments[2]:!1)},setUint16:function(e,r){Cs(this,2,e,NR,r,arguments.length>2?arguments[2]:!1)},setInt32:function(e,r){Cs(this,4,e,LR,r,arguments.length>2?arguments[2]:!1)},setUint32:function(e,r){Cs(this,4,e,LR,r,arguments.length>2?arguments[2]:!1)},setFloat32:function(e,r){Cs(this,4,e,MK,r,arguments.length>2?arguments[2]:!1)},setFloat64:function(e,r){Cs(this,8,e,NK,r,arguments.length>2?arguments[2]:!1)}});else{var jR=xK&&Mi.name!==Ju;!mb(function(){Mi(1)})||!mb(function(){new Mi(-1)})||mb(function(){return new Mi,new Mi(1.5),new Mi(NaN),Mi.length!==1||jR&&!CR})?(Qn=function(e){return pp(this,Qu),CK(new Mi(vp(e)),this,Qn)},Qn[Yu]=Qu,Qu.constructor=Qn,RK(Qn,Mi)):jR&&CR&&bK(Mi,"name",Ju),TR&&$K(Mo)!==AR&&TR(Mo,AR);var bp=new ua(new Qn(2)),UR=pb(Mo.setInt8);bp.setInt8(0,2147483648),bp.setInt8(1,2147483649),(bp.getInt8(0)||!bp.getInt8(1))&&SR(Mo,{setInt8:function(e,r){UR(this,e,r<<24>>24)},setUint8:function(e,r){UR(this,e,r<<24>>24)}},{unsafe:!0})}ER(Qn,Ju),ER(ua,mp);var FR={ArrayBuffer:Qn,DataView:ua},LK=Xi,DK=RangeError,jK=function(t){var e=LK(t);if(e<0)throw new DK("The argument can't be less than 0");return e},UK=jK,FK=RangeError,BR=function(t,e){var r=UK(t);if(r%e)throw new FK("Wrong offset");return r},BK=Math.round,zK=function(t){var e=BK(t);return e<0?0:e>255?255:e&255},HK=Ra,qK=function(t){var e=HK(t);return e==="BigInt64Array"||e==="BigUint64Array"},VK=Mm,WK=TypeError,zR=function(t){var e=VK(t,"number");if(typeof e=="number")throw new WK("Can't convert number to bigint");return BigInt(e)},ZK=xa,GK=Er,KK=tg,JK=yn,YK=bn,QK=Oh,XK=td,eJ=ty,tJ=qK,rJ=Pr.aTypedArrayConstructor,nJ=zR,iJ=function(e){var r=KK(this),n=JK(e),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,o=XK(n),u,l,c,d,f,m,b,A;if(o&&!eJ(o))for(b=QK(n,o),A=b.next,n=[];!(m=GK(A,b)).done;)n.push(m.value);for(s&&i>2&&(a=ZK(a,arguments[2])),l=YK(n),c=new(rJ(r))(l),d=tJ(c),u=0;l>u;u++)f=s?a(n[u],u):n[u],c[u]=d?nJ(f):+f;return c},aJ=bn,HR=function(t,e,r){for(var n=0,i=arguments.length>2?r:aJ(e),a=new t(i);i>n;)a[n]=e[n++];return a},qR=er,VR=cr,WR=Er,sJ=Ar,oJ=GG,vd=Pr,ZR=FR,GR=bs,uJ=yo,md=Ea,lJ=lC,cJ=Ca,KR=gR,yb=BR,dJ=zK,JR=Yf,gd=Vr,fJ=Ra,bb=Lr,hJ=Tu,pJ=ps,vJ=Ta,wp=Mu,mJ=ko.f,YR=iJ,gJ=Un.forEach,yJ=wh,bJ=ra,QR=Cn,XR=$a,ex=HR,wb=Jn,wJ=Uh,_b=wb.get,_J=wb.set,kJ=wb.enforce,tx=QR.f,SJ=XR.f,kb=VR.RangeError,rx=ZR.ArrayBuffer,$J=rx.prototype,TJ=ZR.DataView,_p=vd.NATIVE_ARRAY_BUFFER_VIEWS,nx=vd.TYPED_ARRAY_TAG,ix=vd.TypedArray,yd=vd.TypedArrayPrototype,Sb=vd.isTypedArray,kp="BYTES_PER_ELEMENT",$b="Wrong length",Sp=function(t,e){bJ(t,e,{configurable:!0,get:function(){return _b(this)[e]}})},ax=function(t){var e;return vJ($J,t)||(e=fJ(t))==="ArrayBuffer"||e==="SharedArrayBuffer"},sx=function(t,e){return Sb(t)&&!hJ(e)&&e in t&&lJ(+e)&&e>=0},ox=function(e,r){return r=JR(r),sx(e,r)?uJ(2,e[r]):SJ(e,r)},ux=function(e,r,n){return r=JR(r),sx(e,r)&&bb(n)&&gd(n,"value")&&!gd(n,"get")&&!gd(n,"set")&&!n.configurable&&(!gd(n,"writable")||n.writable)&&(!gd(n,"enumerable")||n.enumerable)?(e[r]=n.value,e):tx(e,r,n)};sJ?(_p||(XR.f=ox,QR.f=ux,Sp(yd,"buffer"),Sp(yd,"byteOffset"),Sp(yd,"byteLength"),Sp(yd,"length")),qR({target:"Object",stat:!0,forced:!_p},{getOwnPropertyDescriptor:ox,defineProperty:ux}),ab.exports=function(t,e,r){var n=t.match(/\d+/)[0]/8,i=t+(r?"Clamped":"")+"Array",a="get"+t,s="set"+t,o=VR[i],u=o,l=u&&u.prototype,c={},d=function(A,N){var z=_b(A);return z.view[a](N*n+z.byteOffset,!0)},f=function(A,N,z){var X=_b(A);X.view[s](N*n+X.byteOffset,r?dJ(z):z,!0)},m=function(A,N){tx(A,N,{get:function(){return d(this,N)},set:function(z){return f(this,N,z)},enumerable:!0})};_p?oJ&&(u=e(function(A,N,z,X){return GR(A,l),wJ(function(){return bb(N)?ax(N)?X!==void 0?new o(N,yb(z,n),X):z!==void 0?new o(N,yb(z,n)):new o(N):Sb(N)?ex(u,N):WR(YR,u,N):new o(KR(N))}(),A,u)}),wp&&wp(u,ix),gJ(mJ(o),function(A){A in u||md(u,A,o[A])}),u.prototype=l):(u=e(function(A,N,z,X){GR(A,l);var Ee=0,Ie=0,Fe,Oe,ze;if(!bb(N))ze=KR(N),Oe=ze*n,Fe=new rx(Oe);else if(ax(N)){Fe=N,Ie=yb(z,n);var V=N.byteLength;if(X===void 0){if(V%n)throw new kb($b);if(Oe=V-Ie,Oe<0)throw new kb($b)}else if(Oe=cJ(X)*n,Oe+Ie>V)throw new kb($b);ze=Oe/n}else return Sb(N)?ex(u,N):WR(YR,u,N);for(_J(A,{buffer:Fe,byteOffset:Ie,byteLength:Oe,length:ze,view:new TJ(Fe)});Ee<ze;)m(A,Ee++)}),wp&&wp(u,ix),l=u.prototype=pJ(yd)),l.constructor!==u&&md(l,"constructor",u),kJ(l).TypedArrayConstructor=u,nx&&md(l,nx,i);var b=u!==o;c[i]=u,qR({global:!0,constructor:!0,forced:b,sham:!_p},c),kp in u||md(u,kp,n),kp in l||md(l,kp,n),yJ(i)}):ab.exports=function(){};var EJ=ab.exports,CJ=EJ;CJ("Uint8",function(t){return function(r,n,i){return t(this,r,n,i)}});var lx=Pr,RJ=bn,xJ=Xi,IJ=lx.aTypedArray,AJ=lx.exportTypedArrayMethod;AJ("at",function(e){var r=IJ(this),n=RJ(r),i=xJ(e),a=i>=0?i:n+i;return a<0||a>=n?void 0:r[a]});var cx=wo,OJ=TypeError,Tb=function(t,e){if(!delete t[e])throw new OJ("Cannot delete property "+cx(e)+" of "+cx(t))},PJ=yn,Eb=xu,MJ=bn,NJ=Tb,LJ=Math.min,DJ=[].copyWithin||function(e,r){var n=PJ(this),i=MJ(n),a=Eb(e,i),s=Eb(r,i),o=arguments.length>2?arguments[2]:void 0,u=LJ((o===void 0?i:Eb(o,i))-s,i-a),l=1;for(s<a&&a<s+u&&(l=-1,s+=u-1,a+=u-1);u-- >0;)s in n?n[a]=n[s]:NJ(n,a),a+=l,s+=l;return n},jJ=Kt,dx=Pr,UJ=DJ,FJ=jJ(UJ),BJ=dx.aTypedArray,zJ=dx.exportTypedArrayMethod;zJ("copyWithin",function(e,r){return FJ(BJ(this),e,r,arguments.length>2?arguments[2]:void 0)});var fx=Pr,HJ=Un.every,qJ=fx.aTypedArray,VJ=fx.exportTypedArrayMethod;VJ("every",function(e){return HJ(qJ(this),e,arguments.length>1?arguments[1]:void 0)});var hx=Pr,WJ=_R,ZJ=zR,GJ=Ra,KJ=Er,JJ=Kt,YJ=Vt,QJ=hx.aTypedArray,XJ=hx.exportTypedArrayMethod,eY=JJ("".slice),tY=YJ(function(){var t=0;return new Int8Array(2).fill({valueOf:function(){return t++}}),t!==1});XJ("fill",function(e){var r=arguments.length;QJ(this);var n=eY(GJ(this),0,3)==="Big"?ZJ(e):+e;return KJ(WJ,this,n,r>1?arguments[1]:void 0,r>2?arguments[2]:void 0)},tY);var px=Pr,rY=xg,nY=px.aTypedArrayConstructor,iY=px.getTypedArrayConstructor,$p=function(t){return nY(rY(t,iY(t)))},aY=HR,sY=$p,oY=function(t,e){return aY(sY(t),e)},vx=Pr,uY=Un.filter,lY=oY,cY=vx.aTypedArray,dY=vx.exportTypedArrayMethod;dY("filter",function(e){var r=uY(cY(this),e,arguments.length>1?arguments[1]:void 0);return lY(this,r)});var mx=Pr,fY=Un.find,hY=mx.aTypedArray,pY=mx.exportTypedArrayMethod;pY("find",function(e){return fY(hY(this),e,arguments.length>1?arguments[1]:void 0)});var gx=Pr,vY=Un.findIndex,mY=gx.aTypedArray,gY=gx.exportTypedArrayMethod;gY("findIndex",function(e){return vY(mY(this),e,arguments.length>1?arguments[1]:void 0)});var yx=Pr,yY=Un.forEach,bY=yx.aTypedArray,wY=yx.exportTypedArrayMethod;wY("forEach",function(e){yY(bY(this),e,arguments.length>1?arguments[1]:void 0)});var bx=Pr,_Y=ah.includes,kY=bx.aTypedArray,SY=bx.exportTypedArrayMethod;SY("includes",function(e){return _Y(kY(this),e,arguments.length>1?arguments[1]:void 0)});var wx=Pr,$Y=ah.indexOf,TY=wx.aTypedArray,EY=wx.exportTypedArrayMethod;EY("indexOf",function(e){return $Y(TY(this),e,arguments.length>1?arguments[1]:void 0)});var CY=cr,RY=Vt,Cb=Kt,_x=Pr,Rb=mE,xY=Rr,xb=xY("iterator"),kx=CY.Uint8Array,IY=Cb(Rb.values),AY=Cb(Rb.keys),OY=Cb(Rb.entries),Ib=_x.aTypedArray,Tp=_x.exportTypedArrayMethod,Xu=kx&&kx.prototype,Ep=!RY(function(){Xu[xb].call([1])}),Sx=!!Xu&&Xu.values&&Xu[xb]===Xu.values&&Xu.values.name==="values",$x=function(){return IY(Ib(this))};Tp("entries",function(){return OY(Ib(this))},Ep),Tp("keys",function(){return AY(Ib(this))},Ep),Tp("values",$x,Ep||!Sx,{name:"values"}),Tp(xb,$x,Ep||!Sx,{name:"values"});var Tx=Pr,PY=Kt,MY=Tx.aTypedArray,NY=Tx.exportTypedArrayMethod,LY=PY([].join);NY("join",function(e){return LY(MY(this),e)});var DY=So,jY=Kn,UY=Xi,FY=bn,BY=yh,zY=Math.min,Ab=[].lastIndexOf,Ex=!!Ab&&1/[1].lastIndexOf(1,-0)<0,HY=BY("lastIndexOf"),qY=Ex||!HY,VY=qY?function(e){if(Ex)return DY(Ab,this,arguments)||0;var r=jY(this),n=FY(r);if(n===0)return-1;var i=n-1;for(arguments.length>1&&(i=zY(i,UY(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in r&&r[i]===e)return i||0;return-1}:Ab,Cx=Pr,WY=So,ZY=VY,GY=Cx.aTypedArray,KY=Cx.exportTypedArrayMethod;KY("lastIndexOf",function(e){var r=arguments.length;return WY(ZY,GY(this),r>1?[e,arguments[1]]:[e])});var Rx=Pr,JY=Un.map,YY=$p,QY=Rx.aTypedArray,XY=Rx.exportTypedArrayMethod;XY("map",function(e){return JY(QY(this),e,arguments.length>1?arguments[1]:void 0,function(r,n){return new(YY(r))(n)})});var eQ=si,tQ=yn,rQ=Pc,nQ=bn,xx=TypeError,Ix="Reduce of empty array with no initial value",Ax=function(t){return function(e,r,n,i){var a=tQ(e),s=rQ(a),o=nQ(a);if(eQ(r),o===0&&n<2)throw new xx(Ix);var u=t?o-1:0,l=t?-1:1;if(n<2)for(;;){if(u in s){i=s[u],u+=l;break}if(u+=l,t?u<0:o<=u)throw new xx(Ix)}for(;t?u>=0:o>u;u+=l)u in s&&(i=r(i,s[u],u,a));return i}},Ox={left:Ax(!1),right:Ax(!0)},Px=Pr,iQ=Ox.left,aQ=Px.aTypedArray,sQ=Px.exportTypedArrayMethod;sQ("reduce",function(e){var r=arguments.length;return iQ(aQ(this),e,r,r>1?arguments[1]:void 0)});var Mx=Pr,oQ=Ox.right,uQ=Mx.aTypedArray,lQ=Mx.exportTypedArrayMethod;lQ("reduceRight",function(e){var r=arguments.length;return oQ(uQ(this),e,r,r>1?arguments[1]:void 0)});var Nx=Pr,cQ=Nx.aTypedArray,dQ=Nx.exportTypedArrayMethod,fQ=Math.floor;dQ("reverse",function(){for(var e=this,r=cQ(e).length,n=fQ(r/2),i=0,a;i<n;)a=e[i],e[i++]=e[--r],e[r]=a;return e});var Lx=cr,Dx=Er,Ob=Pr,hQ=bn,pQ=BR,vQ=yn,jx=Vt,mQ=Lx.RangeError,Pb=Lx.Int8Array,Ux=Pb&&Pb.prototype,Fx=Ux&&Ux.set,gQ=Ob.aTypedArray,yQ=Ob.exportTypedArrayMethod,Mb=!jx(function(){var t=new Uint8ClampedArray(2);return Dx(Fx,t,{length:1,0:3},1),t[1]!==3}),bQ=Mb&&Ob.NATIVE_ARRAY_BUFFER_VIEWS&&jx(function(){var t=new Pb(2);return t.set(1),t.set("2",1),t[0]!==0||t[1]!==2});yQ("set",function(e){gQ(this);var r=pQ(arguments.length>1?arguments[1]:void 0,1),n=vQ(e);if(Mb)return Dx(Fx,this,n,r);var i=this.length,a=hQ(n),s=0;if(a+r>i)throw new mQ("Wrong length");for(;s<a;)this[r+s]=n[s++]},!Mb||bQ);var Bx=Pr,wQ=$p,_Q=Vt,kQ=ta,SQ=Bx.aTypedArray,$Q=Bx.exportTypedArrayMethod,TQ=_Q(function(){new Int8Array(1).slice()});$Q("slice",function(e,r){for(var n=kQ(SQ(this),e,r),i=wQ(this),a=0,s=n.length,o=new i(s);s>a;)o[a]=n[a++];return o},TQ);var zx=Pr,EQ=Un.some,CQ=zx.aTypedArray,RQ=zx.exportTypedArrayMethod;RQ("some",function(e){return EQ(CQ(this),e,arguments.length>1?arguments[1]:void 0)});var Hx=ta,xQ=Math.floor,Nb=function(t,e){var r=t.length;if(r<8)for(var n=1,i,a;n<r;){for(a=n,i=t[n];a&&e(t[a-1],i)>0;)t[a]=t[--a];a!==n++&&(t[a]=i)}else for(var s=xQ(r/2),o=Nb(Hx(t,0,s),e),u=Nb(Hx(t,s),e),l=o.length,c=u.length,d=0,f=0;d<l||f<c;)t[d+f]=d<l&&f<c?e(o[d],u[f])<=0?o[d++]:u[f++]:d<l?o[d++]:u[f++];return t},Lb=Nb,IQ=bo,qx=IQ.match(/firefox\/(\d+)/i),Vx=!!qx&&+qx[1],AQ=bo,Wx=/MSIE|Trident/.test(AQ),OQ=bo,Zx=OQ.match(/AppleWebKit\/(\d+)\./),Gx=!!Zx&&+Zx[1],PQ=cr,MQ=cg,Db=Vt,NQ=si,LQ=Lb,Kx=Pr,Jx=Vx,DQ=Wx,Yx=Su,Qx=Gx,jQ=Kx.aTypedArray,UQ=Kx.exportTypedArrayMethod,bd=PQ.Uint16Array,el=bd&&MQ(bd.prototype.sort),FQ=!!el&&!(Db(function(){el(new bd(2),null)})&&Db(function(){el(new bd(2),{})})),Xx=!!el&&!Db(function(){if(Yx)return Yx<74;if(Jx)return Jx<67;if(DQ)return!0;if(Qx)return Qx<602;var t=new bd(516),e=Array(516),r,n;for(r=0;r<516;r++)n=r%4,t[r]=515-r,e[r]=r-2*n+3;for(el(t,function(i,a){return(i/4|0)-(a/4|0)}),r=0;r<516;r++)if(t[r]!==e[r])return!0}),BQ=function(t){return function(e,r){return t!==void 0?+t(e,r)||0:r!==r?-1:e!==e?1:e===0&&r===0?1/e>0&&1/r<0?1:-1:e>r}};UQ("sort",function(e){return e!==void 0&&NQ(e),Xx?el(this,e):LQ(jQ(this),BQ(e))},!Xx||FQ);var eI=Pr,zQ=Ca,tI=xu,HQ=$p,qQ=eI.aTypedArray,VQ=eI.exportTypedArrayMethod;VQ("subarray",function(e,r){var n=qQ(this),i=n.length,a=tI(e,i),s=HQ(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,zQ((r===void 0?i:tI(r,i))-a))});var WQ=cr,ZQ=So,rI=Pr,jb=Vt,nI=ta,Cp=WQ.Int8Array,iI=rI.aTypedArray,GQ=rI.exportTypedArrayMethod,aI=[].toLocaleString,KQ=!!Cp&&jb(function(){aI.call(new Cp(1))}),JQ=jb(function(){return[1,2].toLocaleString()!==new Cp([1,2]).toLocaleString()})||!jb(function(){Cp.prototype.toLocaleString.call([1,2])});GQ("toLocaleString",function(){return ZQ(aI,KQ?nI(iI(this)):iI(this),nI(arguments))},JQ);var YQ=Pr.exportTypedArrayMethod,QQ=Vt,XQ=cr,eX=Kt,sI=XQ.Uint8Array,tX=sI&&sI.prototype||{},Rp=[].toString,rX=eX([].join);QQ(function(){Rp.call({})})&&(Rp=function(){return rX(this)});var nX=tX.toString!==Rp;YQ("toString",Rp,nX);var Ub=Er,oI=Kt,iX=Vh,aX=Gr,sX=xi,oX=Ii,uX=xg,lX=Py,cX=Ca,uI=rn,dX=_o,lI=Wh,fX=AE,hX=Vt,tl=fX.UNSUPPORTED_Y,pX=4294967295,vX=Math.min,Fb=oI([].push),Bb=oI("".slice),mX=!hX(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var r="ab".split(t);return r.length!==2||r[0]!=="a"||r[1]!=="b"}),cI="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;iX("split",function(t,e,r){var n="0".split(void 0,0).length?function(i,a){return i===void 0&&a===0?[]:Ub(e,this,i,a)}:e;return[function(a,s){var o=oX(this),u=sX(a)?void 0:dX(a,t);return u?Ub(u,a,o,s):Ub(n,uI(o),a,s)},function(i,a){var s=aX(this),o=uI(i);if(!cI){var u=r(n,s,o,a,n!==e);if(u.done)return u.value}var l=uX(s,RegExp),c=s.unicode,d=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(tl?"g":"y"),f=new l(tl?"^(?:"+s.source+")":s,d),m=a===void 0?pX:a>>>0;if(m===0)return[];if(o.length===0)return lI(f,o)===null?[o]:[];for(var b=0,A=0,N=[];A<o.length;){f.lastIndex=tl?0:A;var z=lI(f,tl?Bb(o,A):o),X;if(z===null||(X=vX(cX(f.lastIndex+(tl?A:0)),o.length))===b)A=lX(o,A,c);else{if(Fb(N,Bb(o,b,A)),N.length===m)return N;for(var Ee=1;Ee<=z.length-1;Ee++)if(Fb(N,z[Ee]),N.length===m)return N;A=b=X}}return Fb(N,Bb(o,b)),N}]},cI||!mX,tl);var dI={exports:{}},fI={exports:{}};(function(t){function e(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch{return typeof r=="function"}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(fI);var gX=fI.exports,hI={exports:{}},pI={exports:{}};(function(t){function e(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(t.exports=e=function(){return!!r},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(pI);var yX=pI.exports;(function(t){var e=yX,r=Tg;function n(i,a,s){if(e())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,a);var u=new(i.bind.apply(i,o));return s&&r(u,s.prototype),u}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(hI);var bX=hI.exports;(function(t){var e=li,r=Tg,n=gX,i=bX;function a(s){var o=typeof Map=="function"?new Map:void 0;return t.exports=a=function(l){if(l===null||!n(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(l))return o.get(l);o.set(l,c)}function c(){return i(l,arguments,e(this).constructor)}return c.prototype=Object.create(l.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),r(c,l)},t.exports.__esModule=!0,t.exports.default=t.exports,a(s)}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(dI);var wd=dI.exports,xp={exports:{}};/*!
839
839
  * Platform.js v1.3.6
840
840
  * Copyright 2014-2020 Benjamin Tan
841
841
  * Copyright 2011-2013 John-David Dalton
842
842
  * Available under MIT license
843
- */xp.exports,function(t,e){(function(){var r={function:!0,object:!0},n=r[typeof window]&&window||this,i=e,a=t&&!t.nodeType&&t,s=i&&a&&typeof ln=="object"&&ln;s&&(s.global===s||s.window===s||s.self===s)&&(n=s);var o=Math.pow(2,53)-1,u=/\bOpera/,l=Object.prototype,c=l.hasOwnProperty,d=l.toString;function f(V){return V=String(V),V.charAt(0).toUpperCase()+V.slice(1)}function m(V,xe,_e){var se={"10.0":"10","6.4":"10 Technical Preview","6.3":"8.1","6.2":"8","6.1":"Server 2008 R2 / 7","6.0":"Server 2008 / Vista","5.2":"Server 2003 / XP 64-bit","5.1":"XP","5.01":"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return xe&&_e&&/^Win/i.test(V)&&!/^Windows Phone /i.test(V)&&(se=se[/[\d.]+$/.exec(V)])&&(V="Windows "+se),V=String(V),xe&&_e&&(V=V.replace(RegExp(xe,"i"),_e)),V=A(V.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0]),V}function b(V,xe){var _e=-1,se=V?V.length:0;if(typeof se=="number"&&se>-1&&se<=o)for(;++_e<se;)xe(V[_e],_e,V);else N(V,xe)}function A(V){return V=Be(V),/^(?:webOS|i(?:OS|P))/.test(V)?V:f(V)}function N(V,xe){for(var _e in V)c.call(V,_e)&&xe(V[_e],_e,V)}function z(V){return V==null?f(V):d.call(V).slice(8,-1)}function X(V,xe){var _e=V!=null?typeof V[xe]:"number";return!/^(?:boolean|number|string|undefined)$/.test(_e)&&(_e=="object"?!!V[xe]:!0)}function Ee(V){return String(V).replace(/([ -])(?!$)/g,"$1?")}function Ie(V,xe){var _e=null;return b(V,function(se,Te){_e=xe(_e,se,Te,V)}),_e}function Be(V){return String(V).replace(/^ +| +$/g,"")}function Oe(V){var xe=n,_e=V&&typeof V=="object"&&z(V)!="String";_e&&(xe=V,V=null);var se=xe.navigator||{},Te=se.userAgent||"";V||(V=Te);var re=_e?!!se.likeChrome:/\bChrome\b/.test(V)&&!/internal|\n/i.test(d.toString()),oe="Object",q=_e?oe:"ScriptBridgingProxyObject",ne=_e?oe:"Environment",Se=_e&&xe.java?"JavaPackage":z(xe.java),H=_e?oe:"RuntimeObject",ye=/\bJava/.test(Se)&&xe.java,ke=ye&&z(xe.environment)==ne,M=ye?"a":"α",Xe=ye?"b":"β",Ct=xe.document||{},rt=xe.operamini||xe.opera,je=u.test(je=_e&&rt?rt["[[Class]]"]:z(rt))?je:rt=null,ce,Ke=V,Fe=[],be=null,pt=V==Te,Ze=pt&&rt&&typeof rt.version=="function"&&rt.version(),Jt,At=St([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),Q=or(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),Ue=et([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),ot=ut({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),Pe=br(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function St(fr){return Ie(fr,function(Wt,Ot){return Wt||RegExp("\\b"+(Ot.pattern||Ee(Ot))+"\\b","i").exec(V)&&(Ot.label||Ot)})}function ut(fr){return Ie(fr,function(Wt,Ot,L){return Wt||(Ot[Ue]||Ot[/^[a-z]+(?: +[a-z]+\b)*/i.exec(Ue)]||RegExp("\\b"+Ee(L)+"(?:\\b|\\w*\\d)","i").exec(V))&&L})}function or(fr){return Ie(fr,function(Wt,Ot){return Wt||RegExp("\\b"+(Ot.pattern||Ee(Ot))+"\\b","i").exec(V)&&(Ot.label||Ot)})}function br(fr){return Ie(fr,function(Wt,Ot){var L=Ot.pattern||Ee(Ot);return!Wt&&(Wt=RegExp("\\b"+L+"(?:/[\\d.]+|[ \\w.]*)","i").exec(V))&&(Wt=m(Wt,L,Ot.label||Ot)),Wt})}function et(fr){return Ie(fr,function(Wt,Ot){var L=Ot.pattern||Ee(Ot);return!Wt&&(Wt=RegExp("\\b"+L+" *\\d+[.\\w_]*","i").exec(V)||RegExp("\\b"+L+" *\\w+-[\\w]*","i").exec(V)||RegExp("\\b"+L+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(V))&&((Wt=String(Ot.label&&!RegExp(L,"i").test(Ot.label)?Ot.label:Wt).split("/"))[1]&&!/[\d.]+/.test(Wt[0])&&(Wt[0]+=" "+Wt[1]),Ot=Ot.label||Ot,Wt=A(Wt[0].replace(RegExp(L,"i"),Ot).replace(RegExp("; *(?:"+Ot+"[_-])?","i")," ").replace(RegExp("("+Ot+")[-_.]?(\\w)","i"),"$1 $2"))),Wt})}function Mr(fr){return Ie(fr,function(Wt,Ot){return Wt||(RegExp(Ot+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(V)||0)[1]||null})}function Fr(){return this.description||""}if(At&&(At=[At]),/\bAndroid\b/.test(Pe)&&!Ue&&(ce=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(V))&&(Ue=Be(ce[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),ot&&!Ue?Ue=et([ot]):ot&&Ue&&(Ue=Ue.replace(RegExp("^("+Ee(ot)+")[-_.\\s]","i"),ot+" ").replace(RegExp("^("+Ee(ot)+")[-_.]?(\\w)","i"),ot+" $2")),(ce=/\bGoogle TV\b/.exec(Ue))&&(Ue=ce[0]),/\bSimulator\b/i.test(V)&&(Ue=(Ue?Ue+" ":"")+"Simulator"),Q=="Opera Mini"&&/\bOPiOS\b/.test(V)&&Fe.push("running in Turbo/Uncompressed mode"),Q=="IE"&&/\blike iPhone OS\b/.test(V)?(ce=Oe(V.replace(/like iPhone OS/,"")),ot=ce.manufacturer,Ue=ce.product):/^iP/.test(Ue)?(Q||(Q="Safari"),Pe="iOS"+((ce=/ OS ([\d_]+)/i.exec(V))?" "+ce[1].replace(/_/g,"."):"")):Q=="Konqueror"&&/^Linux\b/i.test(Pe)?Pe="Kubuntu":ot&&ot!="Google"&&(/Chrome/.test(Q)&&!/\bMobile Safari\b/i.test(V)||/\bVita\b/.test(Ue))||/\bAndroid\b/.test(Pe)&&/^Chrome/.test(Q)&&/\bVersion\//i.test(V)?(Q="Android Browser",Pe=/\bAndroid\b/.test(Pe)?Pe:"Android"):Q=="Silk"?(/\bMobi/i.test(V)||(Pe="Android",Fe.unshift("desktop mode")),/Accelerated *= *true/i.test(V)&&Fe.unshift("accelerated")):Q=="UC Browser"&&/\bUCWEB\b/.test(V)?Fe.push("speed mode"):Q=="PaleMoon"&&(ce=/\bFirefox\/([\d.]+)\b/.exec(V))?Fe.push("identifying as Firefox "+ce[1]):Q=="Firefox"&&(ce=/\b(Mobile|Tablet|TV)\b/i.exec(V))?(Pe||(Pe="Firefox OS"),Ue||(Ue=ce[1])):!Q||(ce=!/\bMinefield\b/i.test(V)&&/\b(?:Firefox|Safari)\b/.exec(Q))?(Q&&!Ue&&/[\/,]|^[^(]+?\)/.test(V.slice(V.indexOf(ce+"/")+8))&&(Q=null),(ce=Ue||ot||Pe)&&(Ue||ot||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(Pe))&&(Q=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(Pe)?Pe:ce)+" Browser")):Q=="Electron"&&(ce=(/\bChrome\/([\d.]+)\b/.exec(V)||0)[1])&&Fe.push("Chromium "+ce),Ze||(Ze=Mr(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",Ee(Q),"(?:Firefox|Minefield|NetFront)"])),(ce=At=="iCab"&&parseFloat(Ze)>3&&"WebKit"||/\bOpera\b/.test(Q)&&(/\bOPR\b/.test(V)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(V)&&!/^(?:Trident|EdgeHTML)$/.test(At)&&"WebKit"||!At&&/\bMSIE\b/i.test(V)&&(Pe=="Mac OS"?"Tasman":"Trident")||At=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(Q)&&"NetFront")&&(At=[ce]),Q=="IE"&&(ce=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(V)||0)[1])?(Q+=" Mobile",Pe="Windows Phone "+(/\+$/.test(ce)?ce:ce+".x"),Fe.unshift("desktop mode")):/\bWPDesktop\b/i.test(V)?(Q="IE Mobile",Pe="Windows Phone 8.x",Fe.unshift("desktop mode"),Ze||(Ze=(/\brv:([\d.]+)/.exec(V)||0)[1])):Q!="IE"&&At=="Trident"&&(ce=/\brv:([\d.]+)/.exec(V))&&(Q&&Fe.push("identifying as "+Q+(Ze?" "+Ze:"")),Q="IE",Ze=ce[1]),pt){if(X(xe,"global"))if(ye&&(ce=ye.lang.System,Ke=ce.getProperty("os.arch"),Pe=Pe||ce.getProperty("os.name")+" "+ce.getProperty("os.version")),ke){try{Ze=xe.require("ringo/engine").version.join("."),Q="RingoJS"}catch{(ce=xe.system)&&ce.global.system==xe.system&&(Q="Narwhal",Pe||(Pe=ce[0].os||null))}Q||(Q="Rhino")}else typeof xe.process=="object"&&!xe.process.browser&&(ce=xe.process)&&(typeof ce.versions=="object"&&(typeof ce.versions.electron=="string"?(Fe.push("Node "+ce.versions.node),Q="Electron",Ze=ce.versions.electron):typeof ce.versions.nw=="string"&&(Fe.push("Chromium "+Ze,"Node "+ce.versions.node),Q="NW.js",Ze=ce.versions.nw)),Q||(Q="Node.js",Ke=ce.arch,Pe=ce.platform,Ze=/[\d.]+/.exec(ce.version),Ze=Ze?Ze[0]:null));else z(ce=xe.runtime)==q?(Q="Adobe AIR",Pe=ce.flash.system.Capabilities.os):z(ce=xe.phantom)==H?(Q="PhantomJS",Ze=(ce=ce.version||null)&&ce.major+"."+ce.minor+"."+ce.patch):typeof Ct.documentMode=="number"&&(ce=/\bTrident\/(\d+)/i.exec(V))?(Ze=[Ze,Ct.documentMode],(ce=+ce[1]+4)!=Ze[1]&&(Fe.push("IE "+Ze[1]+" mode"),At&&(At[1]=""),Ze[1]=ce),Ze=Q=="IE"?String(Ze[1].toFixed(1)):Ze[0]):typeof Ct.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(Q)&&(Fe.push("masking as "+Q+" "+Ze),Q="IE",Ze="11.0",At=["Trident"],Pe="Windows");Pe=Pe&&A(Pe)}if(Ze&&(ce=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(Ze)||/(?:alpha|beta)(?: ?\d)?/i.exec(V+";"+(pt&&se.appMinorVersion))||/\bMinefield\b/i.test(V)&&"a")&&(be=/b/i.test(ce)?"beta":"alpha",Ze=Ze.replace(RegExp(ce+"\\+?$"),"")+(be=="beta"?Xe:M)+(/\d+\+?/.exec(ce)||"")),Q=="Fennec"||Q=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(Pe))Q="Firefox Mobile";else if(Q=="Maxthon"&&Ze)Ze=Ze.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(Ue))Ue=="Xbox 360"&&(Pe=null),Ue=="Xbox 360"&&/\bIEMobile\b/.test(V)&&Fe.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(Q)||Q&&!Ue&&!/Browser|Mobi/.test(Q))&&(Pe=="Windows CE"||/Mobi/i.test(V)))Q+=" Mobile";else if(Q=="IE"&&pt)try{xe.external===null&&Fe.unshift("platform preview")}catch{Fe.unshift("embedded")}else(/\bBlackBerry\b/.test(Ue)||/\bBB10\b/.test(V))&&(ce=(RegExp(Ue.replace(/ +/g," *")+"/([.\\d]+)","i").exec(V)||0)[1]||Ze)?(ce=[ce,/BB10/.test(V)],Pe=(ce[1]?(Ue=null,ot="BlackBerry"):"Device Software")+" "+ce[0],Ze=null):this!=N&&Ue!="Wii"&&(pt&&rt||/Opera/.test(Q)&&/\b(?:MSIE|Firefox)\b/i.test(V)||Q=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test(Pe)||Q=="IE"&&(Pe&&!/^Win/.test(Pe)&&Ze>5.5||/\bWindows XP\b/.test(Pe)&&Ze>8||Ze==8&&!/\bTrident\b/.test(V)))&&!u.test(ce=Oe.call(N,V.replace(u,"")+";"))&&ce.name&&(ce="ing as "+ce.name+((ce=ce.version)?" "+ce:""),u.test(Q)?(/\bIE\b/.test(ce)&&Pe=="Mac OS"&&(Pe=null),ce="identify"+ce):(ce="mask"+ce,je?Q=A(je.replace(/([a-z])([A-Z])/g,"$1 $2")):Q="Opera",/\bIE\b/.test(ce)&&(Pe=null),pt||(Ze=null)),At=["Presto"],Fe.push(ce));(ce=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(V)||0)[1])&&(ce=[parseFloat(ce.replace(/\.(\d)$/,".0$1")),ce],Q=="Safari"&&ce[1].slice(-1)=="+"?(Q="WebKit Nightly",be="alpha",Ze=ce[1].slice(0,-1)):(Ze==ce[1]||Ze==(ce[2]=(/\bSafari\/([\d.]+\+?)/i.exec(V)||0)[1]))&&(Ze=null),ce[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(V)||0)[1],ce[0]==537.36&&ce[2]==537.36&&parseFloat(ce[1])>=28&&At=="WebKit"&&(At=["Blink"]),!pt||!re&&!ce[1]?(At&&(At[1]="like Safari"),ce=(ce=ce[0],ce<400?1:ce<500?2:ce<526?3:ce<533?4:ce<534?"4+":ce<535?5:ce<537?6:ce<538?7:ce<601?8:ce<602?9:ce<604?10:ce<606?11:ce<608?12:"12")):(At&&(At[1]="like Chrome"),ce=ce[1]||(ce=ce[0],ce<530?1:ce<532?2:ce<532.05?3:ce<533?4:ce<534.03?5:ce<534.07?6:ce<534.1?7:ce<534.13?8:ce<534.16?9:ce<534.24?10:ce<534.3?11:ce<535.01?12:ce<535.02?"13+":ce<535.07?15:ce<535.11?16:ce<535.19?17:ce<536.05?18:ce<536.1?19:ce<537.01?20:ce<537.11?"21+":ce<537.13?23:ce<537.18?24:ce<537.24?25:ce<537.36?26:At!="Blink"?"27":"28")),At&&(At[1]+=" "+(ce+=typeof ce=="number"?".x":/[.+]/.test(ce)?"":"+")),Q=="Safari"&&(!Ze||parseInt(Ze)>45)?Ze=ce:Q=="Chrome"&&/\bHeadlessChrome/i.test(V)&&Fe.unshift("headless")),Q=="Opera"&&(ce=/\bzbov|zvav$/.exec(Pe))?(Q+=" ",Fe.unshift("desktop mode"),ce=="zvav"?(Q+="Mini",Ze=null):Q+="Mobile",Pe=Pe.replace(RegExp(" *"+ce+"$"),"")):Q=="Safari"&&/\bChrome\b/.exec(At&&At[1])?(Fe.unshift("desktop mode"),Q="Chrome Mobile",Ze=null,/\bOS X\b/.test(Pe)?(ot="Apple",Pe="iOS 4.3+"):Pe=null):/\bSRWare Iron\b/.test(Q)&&!Ze&&(Ze=Mr("Chrome")),Ze&&Ze.indexOf(ce=/[\d.]+$/.exec(Pe))==0&&V.indexOf("/"+ce+"-")>-1&&(Pe=Be(Pe.replace(ce,""))),Pe&&Pe.indexOf(Q)!=-1&&!RegExp(Q+" OS").test(Pe)&&(Pe=Pe.replace(RegExp(" *"+Ee(Q)+" *"),"")),At&&!/\b(?:Avant|Nook)\b/.test(Q)&&(/Browser|Lunascape|Maxthon/.test(Q)||Q!="Safari"&&/^iOS/.test(Pe)&&/\bSafari\b/.test(At[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(Q)&&At[1])&&(ce=At[At.length-1])&&Fe.push(ce),Fe.length&&(Fe=["("+Fe.join("; ")+")"]),ot&&Ue&&Ue.indexOf(ot)<0&&Fe.push("on "+ot),Ue&&Fe.push((/^on /.test(Fe[Fe.length-1])?"":"on ")+Ue),Pe&&(ce=/ ([\d.+]+)$/.exec(Pe),Jt=ce&&Pe.charAt(Pe.length-ce[0].length-1)=="/",Pe={architecture:32,family:ce&&!Jt?Pe.replace(ce[0],""):Pe,version:ce?ce[1]:null,toString:function(){var fr=this.version;return this.family+(fr&&!Jt?" "+fr:"")+(this.architecture==64?" 64-bit":"")}}),(ce=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(Ke))&&!/\bi686\b/i.test(Ke)?(Pe&&(Pe.architecture=64,Pe.family=Pe.family.replace(RegExp(" *"+ce),"")),Q&&(/\bWOW64\b/i.test(V)||pt&&/\w(?:86|32)$/.test(se.cpuClass||se.platform)&&!/\bWin64; x64\b/i.test(V))&&Fe.unshift("32-bit")):Pe&&/^OS X/.test(Pe.family)&&Q=="Chrome"&&parseFloat(Ze)>=39&&(Pe.architecture=64),V||(V=null);var dr={};return dr.description=V,dr.layout=At&&At[0],dr.manufacturer=ot,dr.name=Q,dr.prerelease=be,dr.product=Ue,dr.ua=V,dr.version=Q&&Ze,dr.os=Pe||{architecture:null,family:null,version:null,toString:function(){return"null"}},dr.parse=Oe,dr.toString=Fr,dr.version&&Fe.unshift(Ze),dr.name&&Fe.unshift(Q),Pe&&Q&&!(Pe==String(Pe).split(" ")[0]&&(Pe==Q.split(" ")[0]||Ue))&&Fe.push(Ue?"("+Pe+")":"on "+Pe),Fe.length&&(dr.description=Fe.join(" ")),dr}var ze=Oe();i&&a?N(ze,function(V,xe){i[xe]=V}):n.platform=ze}).call(ln)}(xp,xp.exports);var zb=xp.exports,wX=Er,_X=Vh,kX=Gr,SX=xi,$X=Ca,Hb=rn,TX=Ii,EX=_o,CX=Py,vI=Wh;_X("match",function(t,e,r){return[function(i){var a=TX(this),s=SX(i)?void 0:EX(i,t);return s?wX(s,i,a):new RegExp(i)[t](Hb(a))},function(n){var i=kX(this),a=Hb(n),s=r(e,i,a);if(s.done)return s.value;if(!i.global)return vI(i,a);var o=i.unicode;i.lastIndex=0;for(var u=[],l=0,c;(c=vI(i,a))!==null;){var d=Hb(c[0]);u[l]=d,d===""&&(i.lastIndex=CX(a,$X(i.lastIndex),o)),l++}return l===0?null:u}]});var RX=Object.is||function(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r},xX=Er,IX=Vh,AX=Gr,OX=xi,PX=Ii,mI=RX,gI=rn,MX=_o,NX=Wh;IX("search",function(t,e,r){return[function(i){var a=PX(this),s=OX(i)?void 0:MX(i,t);return s?xX(s,i,a):new RegExp(i)[t](gI(a))},function(n){var i=AX(this),a=gI(n),s=r(e,i,a);if(s.done)return s.value;var o=i.lastIndex;mI(o,0)||(i.lastIndex=0);var u=NX(i,a);return mI(i.lastIndex,o)||(i.lastIndex=o),u===null?-1:u.index}]});var LX=Ar,DX=zc,jX=TypeError,UX=Object.getOwnPropertyDescriptor,FX=LX&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}(),BX=FX?function(t,e){if(DX(t)&&!UX(t,"length").writable)throw new jX("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e},zX=er,HX=yn,qX=xu,VX=Xi,WX=bn,ZX=BX,GX=FT,KX=dg,JX=Kc,qb=Tb,YX=Gc,QX=YX("splice"),XX=Math.max,eee=Math.min;zX({target:"Array",proto:!0,forced:!QX},{splice:function(e,r){var n=HX(this),i=WX(n),a=qX(e,i),s=arguments.length,o,u,l,c,d,f;for(s===0?o=u=0:s===1?(o=0,u=i-a):(o=s-2,u=eee(XX(VX(r),0),i-a)),GX(i+o-u),l=KX(n,u),c=0;c<u;c++)d=a+c,d in n&&JX(l,c,n[d]);if(l.length=u,o<u){for(c=a;c<i-u;c++)d=c+u,f=c+o,d in n?n[f]=n[d]:qb(n,f);for(c=i;c>i-u+o;c--)qb(n,c-1)}else if(o>u)for(c=i-u;c>a;c--)d=c+u-1,f=c+o-1,d in n?n[f]=n[d]:qb(n,f);for(c=0;c<o;c++)n[c+a]=arguments[c+2];return ZX(n,i-u+o),l}});/*
843
+ */xp.exports,function(t,e){(function(){var r={function:!0,object:!0},n=r[typeof window]&&window||this,i=e,a=t&&!t.nodeType&&t,s=i&&a&&typeof ln=="object"&&ln;s&&(s.global===s||s.window===s||s.self===s)&&(n=s);var o=Math.pow(2,53)-1,u=/\bOpera/,l=Object.prototype,c=l.hasOwnProperty,d=l.toString;function f(V){return V=String(V),V.charAt(0).toUpperCase()+V.slice(1)}function m(V,xe,_e){var se={"10.0":"10","6.4":"10 Technical Preview","6.3":"8.1","6.2":"8","6.1":"Server 2008 R2 / 7","6.0":"Server 2008 / Vista","5.2":"Server 2003 / XP 64-bit","5.1":"XP","5.01":"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return xe&&_e&&/^Win/i.test(V)&&!/^Windows Phone /i.test(V)&&(se=se[/[\d.]+$/.exec(V)])&&(V="Windows "+se),V=String(V),xe&&_e&&(V=V.replace(RegExp(xe,"i"),_e)),V=A(V.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0]),V}function b(V,xe){var _e=-1,se=V?V.length:0;if(typeof se=="number"&&se>-1&&se<=o)for(;++_e<se;)xe(V[_e],_e,V);else N(V,xe)}function A(V){return V=Fe(V),/^(?:webOS|i(?:OS|P))/.test(V)?V:f(V)}function N(V,xe){for(var _e in V)c.call(V,_e)&&xe(V[_e],_e,V)}function z(V){return V==null?f(V):d.call(V).slice(8,-1)}function X(V,xe){var _e=V!=null?typeof V[xe]:"number";return!/^(?:boolean|number|string|undefined)$/.test(_e)&&(_e=="object"?!!V[xe]:!0)}function Ee(V){return String(V).replace(/([ -])(?!$)/g,"$1?")}function Ie(V,xe){var _e=null;return b(V,function(se,Te){_e=xe(_e,se,Te,V)}),_e}function Fe(V){return String(V).replace(/^ +| +$/g,"")}function Oe(V){var xe=n,_e=V&&typeof V=="object"&&z(V)!="String";_e&&(xe=V,V=null);var se=xe.navigator||{},Te=se.userAgent||"";V||(V=Te);var re=_e?!!se.likeChrome:/\bChrome\b/.test(V)&&!/internal|\n/i.test(d.toString()),oe="Object",q=_e?oe:"ScriptBridgingProxyObject",ne=_e?oe:"Environment",Se=_e&&xe.java?"JavaPackage":z(xe.java),H=_e?oe:"RuntimeObject",ye=/\bJava/.test(Se)&&xe.java,ke=ye&&z(xe.environment)==ne,M=ye?"a":"α",Xe=ye?"b":"β",Ct=xe.document||{},rt=xe.operamini||xe.opera,je=u.test(je=_e&&rt?rt["[[Class]]"]:z(rt))?je:rt=null,ce,Ke=V,Be=[],be=null,pt=V==Te,Ze=pt&&rt&&typeof rt.version=="function"&&rt.version(),Jt,At=St([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),Q=or(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),Ue=et([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),ot=ut({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),Pe=br(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function St(fr){return Ie(fr,function(Wt,Ot){return Wt||RegExp("\\b"+(Ot.pattern||Ee(Ot))+"\\b","i").exec(V)&&(Ot.label||Ot)})}function ut(fr){return Ie(fr,function(Wt,Ot,L){return Wt||(Ot[Ue]||Ot[/^[a-z]+(?: +[a-z]+\b)*/i.exec(Ue)]||RegExp("\\b"+Ee(L)+"(?:\\b|\\w*\\d)","i").exec(V))&&L})}function or(fr){return Ie(fr,function(Wt,Ot){return Wt||RegExp("\\b"+(Ot.pattern||Ee(Ot))+"\\b","i").exec(V)&&(Ot.label||Ot)})}function br(fr){return Ie(fr,function(Wt,Ot){var L=Ot.pattern||Ee(Ot);return!Wt&&(Wt=RegExp("\\b"+L+"(?:/[\\d.]+|[ \\w.]*)","i").exec(V))&&(Wt=m(Wt,L,Ot.label||Ot)),Wt})}function et(fr){return Ie(fr,function(Wt,Ot){var L=Ot.pattern||Ee(Ot);return!Wt&&(Wt=RegExp("\\b"+L+" *\\d+[.\\w_]*","i").exec(V)||RegExp("\\b"+L+" *\\w+-[\\w]*","i").exec(V)||RegExp("\\b"+L+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(V))&&((Wt=String(Ot.label&&!RegExp(L,"i").test(Ot.label)?Ot.label:Wt).split("/"))[1]&&!/[\d.]+/.test(Wt[0])&&(Wt[0]+=" "+Wt[1]),Ot=Ot.label||Ot,Wt=A(Wt[0].replace(RegExp(L,"i"),Ot).replace(RegExp("; *(?:"+Ot+"[_-])?","i")," ").replace(RegExp("("+Ot+")[-_.]?(\\w)","i"),"$1 $2"))),Wt})}function Mr(fr){return Ie(fr,function(Wt,Ot){return Wt||(RegExp(Ot+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(V)||0)[1]||null})}function Fr(){return this.description||""}if(At&&(At=[At]),/\bAndroid\b/.test(Pe)&&!Ue&&(ce=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(V))&&(Ue=Fe(ce[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),ot&&!Ue?Ue=et([ot]):ot&&Ue&&(Ue=Ue.replace(RegExp("^("+Ee(ot)+")[-_.\\s]","i"),ot+" ").replace(RegExp("^("+Ee(ot)+")[-_.]?(\\w)","i"),ot+" $2")),(ce=/\bGoogle TV\b/.exec(Ue))&&(Ue=ce[0]),/\bSimulator\b/i.test(V)&&(Ue=(Ue?Ue+" ":"")+"Simulator"),Q=="Opera Mini"&&/\bOPiOS\b/.test(V)&&Be.push("running in Turbo/Uncompressed mode"),Q=="IE"&&/\blike iPhone OS\b/.test(V)?(ce=Oe(V.replace(/like iPhone OS/,"")),ot=ce.manufacturer,Ue=ce.product):/^iP/.test(Ue)?(Q||(Q="Safari"),Pe="iOS"+((ce=/ OS ([\d_]+)/i.exec(V))?" "+ce[1].replace(/_/g,"."):"")):Q=="Konqueror"&&/^Linux\b/i.test(Pe)?Pe="Kubuntu":ot&&ot!="Google"&&(/Chrome/.test(Q)&&!/\bMobile Safari\b/i.test(V)||/\bVita\b/.test(Ue))||/\bAndroid\b/.test(Pe)&&/^Chrome/.test(Q)&&/\bVersion\//i.test(V)?(Q="Android Browser",Pe=/\bAndroid\b/.test(Pe)?Pe:"Android"):Q=="Silk"?(/\bMobi/i.test(V)||(Pe="Android",Be.unshift("desktop mode")),/Accelerated *= *true/i.test(V)&&Be.unshift("accelerated")):Q=="UC Browser"&&/\bUCWEB\b/.test(V)?Be.push("speed mode"):Q=="PaleMoon"&&(ce=/\bFirefox\/([\d.]+)\b/.exec(V))?Be.push("identifying as Firefox "+ce[1]):Q=="Firefox"&&(ce=/\b(Mobile|Tablet|TV)\b/i.exec(V))?(Pe||(Pe="Firefox OS"),Ue||(Ue=ce[1])):!Q||(ce=!/\bMinefield\b/i.test(V)&&/\b(?:Firefox|Safari)\b/.exec(Q))?(Q&&!Ue&&/[\/,]|^[^(]+?\)/.test(V.slice(V.indexOf(ce+"/")+8))&&(Q=null),(ce=Ue||ot||Pe)&&(Ue||ot||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(Pe))&&(Q=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(Pe)?Pe:ce)+" Browser")):Q=="Electron"&&(ce=(/\bChrome\/([\d.]+)\b/.exec(V)||0)[1])&&Be.push("Chromium "+ce),Ze||(Ze=Mr(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",Ee(Q),"(?:Firefox|Minefield|NetFront)"])),(ce=At=="iCab"&&parseFloat(Ze)>3&&"WebKit"||/\bOpera\b/.test(Q)&&(/\bOPR\b/.test(V)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(V)&&!/^(?:Trident|EdgeHTML)$/.test(At)&&"WebKit"||!At&&/\bMSIE\b/i.test(V)&&(Pe=="Mac OS"?"Tasman":"Trident")||At=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(Q)&&"NetFront")&&(At=[ce]),Q=="IE"&&(ce=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(V)||0)[1])?(Q+=" Mobile",Pe="Windows Phone "+(/\+$/.test(ce)?ce:ce+".x"),Be.unshift("desktop mode")):/\bWPDesktop\b/i.test(V)?(Q="IE Mobile",Pe="Windows Phone 8.x",Be.unshift("desktop mode"),Ze||(Ze=(/\brv:([\d.]+)/.exec(V)||0)[1])):Q!="IE"&&At=="Trident"&&(ce=/\brv:([\d.]+)/.exec(V))&&(Q&&Be.push("identifying as "+Q+(Ze?" "+Ze:"")),Q="IE",Ze=ce[1]),pt){if(X(xe,"global"))if(ye&&(ce=ye.lang.System,Ke=ce.getProperty("os.arch"),Pe=Pe||ce.getProperty("os.name")+" "+ce.getProperty("os.version")),ke){try{Ze=xe.require("ringo/engine").version.join("."),Q="RingoJS"}catch{(ce=xe.system)&&ce.global.system==xe.system&&(Q="Narwhal",Pe||(Pe=ce[0].os||null))}Q||(Q="Rhino")}else typeof xe.process=="object"&&!xe.process.browser&&(ce=xe.process)&&(typeof ce.versions=="object"&&(typeof ce.versions.electron=="string"?(Be.push("Node "+ce.versions.node),Q="Electron",Ze=ce.versions.electron):typeof ce.versions.nw=="string"&&(Be.push("Chromium "+Ze,"Node "+ce.versions.node),Q="NW.js",Ze=ce.versions.nw)),Q||(Q="Node.js",Ke=ce.arch,Pe=ce.platform,Ze=/[\d.]+/.exec(ce.version),Ze=Ze?Ze[0]:null));else z(ce=xe.runtime)==q?(Q="Adobe AIR",Pe=ce.flash.system.Capabilities.os):z(ce=xe.phantom)==H?(Q="PhantomJS",Ze=(ce=ce.version||null)&&ce.major+"."+ce.minor+"."+ce.patch):typeof Ct.documentMode=="number"&&(ce=/\bTrident\/(\d+)/i.exec(V))?(Ze=[Ze,Ct.documentMode],(ce=+ce[1]+4)!=Ze[1]&&(Be.push("IE "+Ze[1]+" mode"),At&&(At[1]=""),Ze[1]=ce),Ze=Q=="IE"?String(Ze[1].toFixed(1)):Ze[0]):typeof Ct.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(Q)&&(Be.push("masking as "+Q+" "+Ze),Q="IE",Ze="11.0",At=["Trident"],Pe="Windows");Pe=Pe&&A(Pe)}if(Ze&&(ce=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(Ze)||/(?:alpha|beta)(?: ?\d)?/i.exec(V+";"+(pt&&se.appMinorVersion))||/\bMinefield\b/i.test(V)&&"a")&&(be=/b/i.test(ce)?"beta":"alpha",Ze=Ze.replace(RegExp(ce+"\\+?$"),"")+(be=="beta"?Xe:M)+(/\d+\+?/.exec(ce)||"")),Q=="Fennec"||Q=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(Pe))Q="Firefox Mobile";else if(Q=="Maxthon"&&Ze)Ze=Ze.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(Ue))Ue=="Xbox 360"&&(Pe=null),Ue=="Xbox 360"&&/\bIEMobile\b/.test(V)&&Be.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(Q)||Q&&!Ue&&!/Browser|Mobi/.test(Q))&&(Pe=="Windows CE"||/Mobi/i.test(V)))Q+=" Mobile";else if(Q=="IE"&&pt)try{xe.external===null&&Be.unshift("platform preview")}catch{Be.unshift("embedded")}else(/\bBlackBerry\b/.test(Ue)||/\bBB10\b/.test(V))&&(ce=(RegExp(Ue.replace(/ +/g," *")+"/([.\\d]+)","i").exec(V)||0)[1]||Ze)?(ce=[ce,/BB10/.test(V)],Pe=(ce[1]?(Ue=null,ot="BlackBerry"):"Device Software")+" "+ce[0],Ze=null):this!=N&&Ue!="Wii"&&(pt&&rt||/Opera/.test(Q)&&/\b(?:MSIE|Firefox)\b/i.test(V)||Q=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test(Pe)||Q=="IE"&&(Pe&&!/^Win/.test(Pe)&&Ze>5.5||/\bWindows XP\b/.test(Pe)&&Ze>8||Ze==8&&!/\bTrident\b/.test(V)))&&!u.test(ce=Oe.call(N,V.replace(u,"")+";"))&&ce.name&&(ce="ing as "+ce.name+((ce=ce.version)?" "+ce:""),u.test(Q)?(/\bIE\b/.test(ce)&&Pe=="Mac OS"&&(Pe=null),ce="identify"+ce):(ce="mask"+ce,je?Q=A(je.replace(/([a-z])([A-Z])/g,"$1 $2")):Q="Opera",/\bIE\b/.test(ce)&&(Pe=null),pt||(Ze=null)),At=["Presto"],Be.push(ce));(ce=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(V)||0)[1])&&(ce=[parseFloat(ce.replace(/\.(\d)$/,".0$1")),ce],Q=="Safari"&&ce[1].slice(-1)=="+"?(Q="WebKit Nightly",be="alpha",Ze=ce[1].slice(0,-1)):(Ze==ce[1]||Ze==(ce[2]=(/\bSafari\/([\d.]+\+?)/i.exec(V)||0)[1]))&&(Ze=null),ce[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(V)||0)[1],ce[0]==537.36&&ce[2]==537.36&&parseFloat(ce[1])>=28&&At=="WebKit"&&(At=["Blink"]),!pt||!re&&!ce[1]?(At&&(At[1]="like Safari"),ce=(ce=ce[0],ce<400?1:ce<500?2:ce<526?3:ce<533?4:ce<534?"4+":ce<535?5:ce<537?6:ce<538?7:ce<601?8:ce<602?9:ce<604?10:ce<606?11:ce<608?12:"12")):(At&&(At[1]="like Chrome"),ce=ce[1]||(ce=ce[0],ce<530?1:ce<532?2:ce<532.05?3:ce<533?4:ce<534.03?5:ce<534.07?6:ce<534.1?7:ce<534.13?8:ce<534.16?9:ce<534.24?10:ce<534.3?11:ce<535.01?12:ce<535.02?"13+":ce<535.07?15:ce<535.11?16:ce<535.19?17:ce<536.05?18:ce<536.1?19:ce<537.01?20:ce<537.11?"21+":ce<537.13?23:ce<537.18?24:ce<537.24?25:ce<537.36?26:At!="Blink"?"27":"28")),At&&(At[1]+=" "+(ce+=typeof ce=="number"?".x":/[.+]/.test(ce)?"":"+")),Q=="Safari"&&(!Ze||parseInt(Ze)>45)?Ze=ce:Q=="Chrome"&&/\bHeadlessChrome/i.test(V)&&Be.unshift("headless")),Q=="Opera"&&(ce=/\bzbov|zvav$/.exec(Pe))?(Q+=" ",Be.unshift("desktop mode"),ce=="zvav"?(Q+="Mini",Ze=null):Q+="Mobile",Pe=Pe.replace(RegExp(" *"+ce+"$"),"")):Q=="Safari"&&/\bChrome\b/.exec(At&&At[1])?(Be.unshift("desktop mode"),Q="Chrome Mobile",Ze=null,/\bOS X\b/.test(Pe)?(ot="Apple",Pe="iOS 4.3+"):Pe=null):/\bSRWare Iron\b/.test(Q)&&!Ze&&(Ze=Mr("Chrome")),Ze&&Ze.indexOf(ce=/[\d.]+$/.exec(Pe))==0&&V.indexOf("/"+ce+"-")>-1&&(Pe=Fe(Pe.replace(ce,""))),Pe&&Pe.indexOf(Q)!=-1&&!RegExp(Q+" OS").test(Pe)&&(Pe=Pe.replace(RegExp(" *"+Ee(Q)+" *"),"")),At&&!/\b(?:Avant|Nook)\b/.test(Q)&&(/Browser|Lunascape|Maxthon/.test(Q)||Q!="Safari"&&/^iOS/.test(Pe)&&/\bSafari\b/.test(At[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(Q)&&At[1])&&(ce=At[At.length-1])&&Be.push(ce),Be.length&&(Be=["("+Be.join("; ")+")"]),ot&&Ue&&Ue.indexOf(ot)<0&&Be.push("on "+ot),Ue&&Be.push((/^on /.test(Be[Be.length-1])?"":"on ")+Ue),Pe&&(ce=/ ([\d.+]+)$/.exec(Pe),Jt=ce&&Pe.charAt(Pe.length-ce[0].length-1)=="/",Pe={architecture:32,family:ce&&!Jt?Pe.replace(ce[0],""):Pe,version:ce?ce[1]:null,toString:function(){var fr=this.version;return this.family+(fr&&!Jt?" "+fr:"")+(this.architecture==64?" 64-bit":"")}}),(ce=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(Ke))&&!/\bi686\b/i.test(Ke)?(Pe&&(Pe.architecture=64,Pe.family=Pe.family.replace(RegExp(" *"+ce),"")),Q&&(/\bWOW64\b/i.test(V)||pt&&/\w(?:86|32)$/.test(se.cpuClass||se.platform)&&!/\bWin64; x64\b/i.test(V))&&Be.unshift("32-bit")):Pe&&/^OS X/.test(Pe.family)&&Q=="Chrome"&&parseFloat(Ze)>=39&&(Pe.architecture=64),V||(V=null);var dr={};return dr.description=V,dr.layout=At&&At[0],dr.manufacturer=ot,dr.name=Q,dr.prerelease=be,dr.product=Ue,dr.ua=V,dr.version=Q&&Ze,dr.os=Pe||{architecture:null,family:null,version:null,toString:function(){return"null"}},dr.parse=Oe,dr.toString=Fr,dr.version&&Be.unshift(Ze),dr.name&&Be.unshift(Q),Pe&&Q&&!(Pe==String(Pe).split(" ")[0]&&(Pe==Q.split(" ")[0]||Ue))&&Be.push(Ue?"("+Pe+")":"on "+Pe),Be.length&&(dr.description=Be.join(" ")),dr}var ze=Oe();i&&a?N(ze,function(V,xe){i[xe]=V}):n.platform=ze}).call(ln)}(xp,xp.exports);var zb=xp.exports,wX=Er,_X=Vh,kX=Gr,SX=xi,$X=Ca,Hb=rn,TX=Ii,EX=_o,CX=Py,vI=Wh;_X("match",function(t,e,r){return[function(i){var a=TX(this),s=SX(i)?void 0:EX(i,t);return s?wX(s,i,a):new RegExp(i)[t](Hb(a))},function(n){var i=kX(this),a=Hb(n),s=r(e,i,a);if(s.done)return s.value;if(!i.global)return vI(i,a);var o=i.unicode;i.lastIndex=0;for(var u=[],l=0,c;(c=vI(i,a))!==null;){var d=Hb(c[0]);u[l]=d,d===""&&(i.lastIndex=CX(a,$X(i.lastIndex),o)),l++}return l===0?null:u}]});var RX=Object.is||function(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r},xX=Er,IX=Vh,AX=Gr,OX=xi,PX=Ii,mI=RX,gI=rn,MX=_o,NX=Wh;IX("search",function(t,e,r){return[function(i){var a=PX(this),s=OX(i)?void 0:MX(i,t);return s?xX(s,i,a):new RegExp(i)[t](gI(a))},function(n){var i=AX(this),a=gI(n),s=r(e,i,a);if(s.done)return s.value;var o=i.lastIndex;mI(o,0)||(i.lastIndex=0);var u=NX(i,a);return mI(i.lastIndex,o)||(i.lastIndex=o),u===null?-1:u.index}]});var LX=Ar,DX=zc,jX=TypeError,UX=Object.getOwnPropertyDescriptor,FX=LX&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}(),BX=FX?function(t,e){if(DX(t)&&!UX(t,"length").writable)throw new jX("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e},zX=er,HX=yn,qX=xu,VX=Xi,WX=bn,ZX=BX,GX=FT,KX=dg,JX=Kc,qb=Tb,YX=Gc,QX=YX("splice"),XX=Math.max,eee=Math.min;zX({target:"Array",proto:!0,forced:!QX},{splice:function(e,r){var n=HX(this),i=WX(n),a=qX(e,i),s=arguments.length,o,u,l,c,d,f;for(s===0?o=u=0:s===1?(o=0,u=i-a):(o=s-2,u=eee(XX(VX(r),0),i-a)),GX(i+o-u),l=KX(n,u),c=0;c<u;c++)d=a+c,d in n&&JX(l,c,n[d]);if(l.length=u,o<u){for(c=a;c<i-u;c++)d=c+u,f=c+o,d in n?n[f]=n[d]:qb(n,f);for(c=i;c>i-u+o;c--)qb(n,c-1)}else if(o>u)for(c=i-u;c>a;c--)d=c+u-1,f=c+o-1,d in n?n[f]=n[d]:qb(n,f);for(c=0;c<o;c++)n[c+a]=arguments[c+2];return ZX(n,i-u+o),l}});/*
844
844
  @license
845
845
  The following license applies to all parts of this software except as
846
846
  documented below.
@@ -923,10 +923,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
923
923
  OTHER DEALINGS IN THE SOFTWARE.
924
924
 
925
925
 
926
- */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Pu,n=gs,i=ep,a=na,s=ia,o=li,u=Aa,l=aa,c=ys,d=zu,f=ui,m=nn,b=Hu,A=YC,N=hd,z=wd,X=sa,Ee=Xh,Ie=zb;function Be(te){return te&&typeof te=="object"&&"default"in te?te:{default:te}}function Oe(te){if(te&&te.__esModule)return te;var ue=Object.create(null);return te&&Object.keys(te).forEach(function(I){if(I!=="default"){var O=Object.getOwnPropertyDescriptor(te,I);Object.defineProperty(ue,I,O.get?O:{enumerable:!0,get:function(){return te[I]}})}}),ue.default=te,Object.freeze(ue)}var ze=Be(r),V=Be(n),xe=Be(i),_e=Be(a),se=Be(s),Te=Be(o),re=Be(u),oe=Be(l),q=Be(c),ne=Be(d),Se=Be(f),H=Oe(b),ye=Oe(A),ke=Be(z),M=Oe(Ie);function Xe(te,ue,I,O){var R=arguments.length,Z=R<3?ue:O===null?O=Object.getOwnPropertyDescriptor(ue,I):O,j;if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Z=Reflect.decorate(te,ue,I,O);else for(var Le=te.length-1;Le>=0;Le--)(j=te[Le])&&(Z=(R<3?j(Z):R>3?j(ue,I,Z):j(ue,I))||Z);return R>3&&Z&&Object.defineProperty(ue,I,Z),Z}function Ct(te,ue){if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(te,ue)}var rt=H.getLogger("twilsock");function je(te,ue){return["".concat(new Date().toISOString()," Twilsock ").concat(te,":")].concat(Array.from(ue))}var ce=function(){function te(ue){oe.default(this,te),q.default(this,"prefix",""),this.prefix=ue!=null&&ue.length>0?" "+ue+":":""}return re.default(te,[{key:"setLevel",value:function(I){rt.setLevel(I)}},{key:"trace",value:function(){if(rt.getLevel()==rt.levels.TRACE){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("T",O))}}},{key:"debug",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("D",O))}},{key:"info",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.info.apply(null,je("I",O))}},{key:"warn",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.warn.apply(null,je("W",O))}},{key:"error",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.error.apply(null,je("E",O))}}],[{key:"setLevel",value:function(I){rt.setLevel(I)}},{key:"trace",value:function(){if(rt.getLevel()==rt.levels.TRACE){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("T",O))}}},{key:"debug",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("D",O))}},{key:"info",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.info.apply(null,je("I",O))}},{key:"warn",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.warn.apply(null,je("W",O))}},{key:"error",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.error.apply(null,je("E",O))}}]),te}(),Ke=new ce(""),Fe="0.13.12",be=function(){function te(ue,I,O){oe.default(this,te),q.default(this,"confirmedCapabilities",new Set),this.activeGrant=I,this._token=ue;var R=O.region||"us1",Z="wss://tsock.".concat(R,".twilio.com/v3/wsconnect"),j=O.twilsock||O.Twilsock||{};this.url=j.uri||Z,this._continuationToken=O.continuationToken?O.continuationToken:null,this.logLevel=O.logLevel?O.logLevel:"error",this.retryPolicy=O.retryPolicy?O.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=O.clientMetadata?O.clientMetadata:{},this.clientMetadata.ver=Fe,this.initRegistrations=O.initRegistrations?O.initRegistrations:null,this.tweaks=O.tweaks?O.tweaks:null}return re.default(te,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(I){this._token=I}},{key:"updateContinuationToken",value:function(I){this._continuationToken=I}}]),te}(),pt=re.default(function te(ue){oe.default(this,te),this.id=ue||"TM".concat(N.v4())});function Ze(te){var ue=Jt();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Jt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At=function(te){_e.default(I,te);var ue=Ze(I);function I(O,R,Z,j,Le){var Ae;return oe.default(this,I),Ae=ue.call(this),q.default(V.default(Ae),"method","init"),Ae.token=O,Ae.continuation_token=R,Ae.metadata=Z,Ae.registrations=j,Ae.tweaks=Le,Ae.capabilities=["client_update","offline_storage","telemetry.v1"],Ae}return re.default(I)}(pt);function Q(te){var ue=Ue();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Ue(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ot=function(te){_e.default(I,te);var ue=Q(I);function I(O,R,Z,j,Le,Ae,Ve){var at;return oe.default(this,I),at=ue.call(this,O),at.continuationToken=R,at.continuationTokenStatus=j,at.offlineStorage=Le,at.initRegistrations=Ae,at.debugInfo=Ve,at.confirmedCapabilities=Z,at}return re.default(I)}(pt);function Pe(te){var ue=St();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function St(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ut=function(te){_e.default(I,te);var ue=Pe(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"method","update"),R.token=O,R}return re.default(I)}(pt);function or(te){var ue=br();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function br(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var et=function(te){_e.default(I,te);var ue=or(I);function I(O,R,Z){var j;return oe.default(this,I),j=ue.call(this),q.default(V.default(j),"method","message"),j.active_grant=O,j.payload_type=R,j.http_request=Z,j}return re.default(I)}(pt);function Mr(te){var ue=Fr();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Fr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var dr=function(te){_e.default(I,te);var ue=Mr(I);function I(O){var R;return oe.default(this,I),R=ue.call(this,O),q.default(V.default(R),"method","reply"),q.default(V.default(R),"payload_type","application/json"),q.default(V.default(R),"status",{code:200,status:"OK"}),R}return re.default(I)}(pt);function fr(te){var ue=Wt();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot=function(te){_e.default(I,te);var ue=fr(I);function I(){var O;return oe.default(this,I),O=ue.call(this),q.default(V.default(O),"method","close"),O}return re.default(I)}(pt);function L(te){var ue=W();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=re.default(function te(ue,I,O,R,Z,j){oe.default(this,te),this.start=ue,this.end=I,this.title=O,this.details=R,this.id=Z,this.type=j}),He=function(te){_e.default(I,te);var ue=L(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"method","telemetry.v1"),R.events=O,R}return re.default(I)}(pt);function ct(te){var ue=encodeURIComponent(te),I=ue.replace(/%([0-9A-F]{2})/g,function(O,R){return String.fromCharCode(+("0x"+R))});return I.length}function bt(te){var ue=encodeURIComponent(te),I=ue.replace(/%([0-9A-F]{2})/g,function(R,Z){return String.fromCharCode(+("0x"+Z))}),O=new Uint8Array(I.length);return Array.prototype.forEach.call(I,function(R,Z){O[Z]=R.charCodeAt(0)}),O}function zt(te){var ue=Array.prototype.map.call(te,function(O){return String.fromCharCode(O)}).join(""),I=ue.replace(/(.)/g,function(O,R){var Z=R.charCodeAt(0).toString(16).toUpperCase();return Z.length<2&&(Z="0"+Z),"%"+Z});return decodeURIComponent(I)}function tr(te){return JSON.parse(zt(te))}function Re(te){for(var ue="",I=0;I<te.length;++I){var O=String.fromCharCode(te[I]);if(ue+=O,O==="\r"){I+=2;break}}var R=ue.split(" ");return{size:I,protocol:R[0],version:R[1],headerSize:Number(R[2])}}var Ne=function(){function te(){oe.default(this,te)}return re.default(te,null,[{key:"parse",value:function(I){var O=2,R=new Uint8Array(I),Z=Re(R);if(Z.protocol!=="TWILSOCK"||Z.version!=="V3.0")return Ke.error("unsupported protocol: ".concat(Z.protocol," ver ").concat(Z.version)),null;var j;try{j=tr(R.subarray(Z.size,Z.size+Z.headerSize))}catch(at){return Ke.error("failed to parse message header",at,I),null}Ke.debug("message received:",j.method);var Le;if(j.payload_size>0){var Ae=O+Z.size+Z.headerSize,Ve=j.payload_size;if(!j.hasOwnProperty("payload_type")||j.payload_type.indexOf("application/json")===0)try{Le=tr(R.subarray(Ae,Ae+Ve))}catch(at){return Ke.error("failed to parse message body",at,I),null}else j.payload_type.indexOf("text/plain")===0&&(Le=zt(R.subarray(Ae,Ae+Ve)))}return{method:j.method,header:j,payload:Le}}},{key:"createPacket",value:function(I){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";I.payload_size=ct(O);var R=JSON.stringify(I),Z="TWILSOCK V3.0 "+ct(R);Ke.debug("send request:",Z+R+O);var j=bt(Z+`\r
926
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Pu,n=gs,i=ep,a=na,s=ia,o=li,u=Aa,l=aa,c=ys,d=zu,f=ui,m=nn,b=Hu,A=YC,N=hd,z=wd,X=sa,Ee=Xh,Ie=zb;function Fe(te){return te&&typeof te=="object"&&"default"in te?te:{default:te}}function Oe(te){if(te&&te.__esModule)return te;var ue=Object.create(null);return te&&Object.keys(te).forEach(function(I){if(I!=="default"){var O=Object.getOwnPropertyDescriptor(te,I);Object.defineProperty(ue,I,O.get?O:{enumerable:!0,get:function(){return te[I]}})}}),ue.default=te,Object.freeze(ue)}var ze=Fe(r),V=Fe(n),xe=Fe(i),_e=Fe(a),se=Fe(s),Te=Fe(o),re=Fe(u),oe=Fe(l),q=Fe(c),ne=Fe(d),Se=Fe(f),H=Oe(b),ye=Oe(A),ke=Fe(z),M=Oe(Ie);function Xe(te,ue,I,O){var R=arguments.length,Z=R<3?ue:O===null?O=Object.getOwnPropertyDescriptor(ue,I):O,j;if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Z=Reflect.decorate(te,ue,I,O);else for(var Le=te.length-1;Le>=0;Le--)(j=te[Le])&&(Z=(R<3?j(Z):R>3?j(ue,I,Z):j(ue,I))||Z);return R>3&&Z&&Object.defineProperty(ue,I,Z),Z}function Ct(te,ue){if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(te,ue)}var rt=H.getLogger("twilsock");function je(te,ue){return["".concat(new Date().toISOString()," Twilsock ").concat(te,":")].concat(Array.from(ue))}var ce=function(){function te(ue){oe.default(this,te),q.default(this,"prefix",""),this.prefix=ue!=null&&ue.length>0?" "+ue+":":""}return re.default(te,[{key:"setLevel",value:function(I){rt.setLevel(I)}},{key:"trace",value:function(){if(rt.getLevel()==rt.levels.TRACE){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("T",O))}}},{key:"debug",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("D",O))}},{key:"info",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.info.apply(null,je("I",O))}},{key:"warn",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.warn.apply(null,je("W",O))}},{key:"error",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.error.apply(null,je("E",O))}}],[{key:"setLevel",value:function(I){rt.setLevel(I)}},{key:"trace",value:function(){if(rt.getLevel()==rt.levels.TRACE){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("T",O))}}},{key:"debug",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.debug.apply(null,je("D",O))}},{key:"info",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.info.apply(null,je("I",O))}},{key:"warn",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.warn.apply(null,je("W",O))}},{key:"error",value:function(){for(var I=arguments.length,O=new Array(I),R=0;R<I;R++)O[R]=arguments[R];rt.error.apply(null,je("E",O))}}]),te}(),Ke=new ce(""),Be="0.13.12",be=function(){function te(ue,I,O){oe.default(this,te),q.default(this,"confirmedCapabilities",new Set),this.activeGrant=I,this._token=ue;var R=O.region||"us1",Z="wss://tsock.".concat(R,".twilio.com/v3/wsconnect"),j=O.twilsock||O.Twilsock||{};this.url=j.uri||Z,this._continuationToken=O.continuationToken?O.continuationToken:null,this.logLevel=O.logLevel?O.logLevel:"error",this.retryPolicy=O.retryPolicy?O.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=O.clientMetadata?O.clientMetadata:{},this.clientMetadata.ver=Be,this.initRegistrations=O.initRegistrations?O.initRegistrations:null,this.tweaks=O.tweaks?O.tweaks:null}return re.default(te,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(I){this._token=I}},{key:"updateContinuationToken",value:function(I){this._continuationToken=I}}]),te}(),pt=re.default(function te(ue){oe.default(this,te),this.id=ue||"TM".concat(N.v4())});function Ze(te){var ue=Jt();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Jt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At=function(te){_e.default(I,te);var ue=Ze(I);function I(O,R,Z,j,Le){var Ae;return oe.default(this,I),Ae=ue.call(this),q.default(V.default(Ae),"method","init"),Ae.token=O,Ae.continuation_token=R,Ae.metadata=Z,Ae.registrations=j,Ae.tweaks=Le,Ae.capabilities=["client_update","offline_storage","telemetry.v1"],Ae}return re.default(I)}(pt);function Q(te){var ue=Ue();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Ue(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ot=function(te){_e.default(I,te);var ue=Q(I);function I(O,R,Z,j,Le,Ae,Ve){var at;return oe.default(this,I),at=ue.call(this,O),at.continuationToken=R,at.continuationTokenStatus=j,at.offlineStorage=Le,at.initRegistrations=Ae,at.debugInfo=Ve,at.confirmedCapabilities=Z,at}return re.default(I)}(pt);function Pe(te){var ue=St();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function St(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ut=function(te){_e.default(I,te);var ue=Pe(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"method","update"),R.token=O,R}return re.default(I)}(pt);function or(te){var ue=br();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function br(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var et=function(te){_e.default(I,te);var ue=or(I);function I(O,R,Z){var j;return oe.default(this,I),j=ue.call(this),q.default(V.default(j),"method","message"),j.active_grant=O,j.payload_type=R,j.http_request=Z,j}return re.default(I)}(pt);function Mr(te){var ue=Fr();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Fr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var dr=function(te){_e.default(I,te);var ue=Mr(I);function I(O){var R;return oe.default(this,I),R=ue.call(this,O),q.default(V.default(R),"method","reply"),q.default(V.default(R),"payload_type","application/json"),q.default(V.default(R),"status",{code:200,status:"OK"}),R}return re.default(I)}(pt);function fr(te){var ue=Wt();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot=function(te){_e.default(I,te);var ue=fr(I);function I(){var O;return oe.default(this,I),O=ue.call(this),q.default(V.default(O),"method","close"),O}return re.default(I)}(pt);function L(te){var ue=W();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=re.default(function te(ue,I,O,R,Z,j){oe.default(this,te),this.start=ue,this.end=I,this.title=O,this.details=R,this.id=Z,this.type=j}),He=function(te){_e.default(I,te);var ue=L(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"method","telemetry.v1"),R.events=O,R}return re.default(I)}(pt);function ct(te){var ue=encodeURIComponent(te),I=ue.replace(/%([0-9A-F]{2})/g,function(O,R){return String.fromCharCode(+("0x"+R))});return I.length}function bt(te){var ue=encodeURIComponent(te),I=ue.replace(/%([0-9A-F]{2})/g,function(R,Z){return String.fromCharCode(+("0x"+Z))}),O=new Uint8Array(I.length);return Array.prototype.forEach.call(I,function(R,Z){O[Z]=R.charCodeAt(0)}),O}function zt(te){var ue=Array.prototype.map.call(te,function(O){return String.fromCharCode(O)}).join(""),I=ue.replace(/(.)/g,function(O,R){var Z=R.charCodeAt(0).toString(16).toUpperCase();return Z.length<2&&(Z="0"+Z),"%"+Z});return decodeURIComponent(I)}function tr(te){return JSON.parse(zt(te))}function Re(te){for(var ue="",I=0;I<te.length;++I){var O=String.fromCharCode(te[I]);if(ue+=O,O==="\r"){I+=2;break}}var R=ue.split(" ");return{size:I,protocol:R[0],version:R[1],headerSize:Number(R[2])}}var Ne=function(){function te(){oe.default(this,te)}return re.default(te,null,[{key:"parse",value:function(I){var O=2,R=new Uint8Array(I),Z=Re(R);if(Z.protocol!=="TWILSOCK"||Z.version!=="V3.0")return Ke.error("unsupported protocol: ".concat(Z.protocol," ver ").concat(Z.version)),null;var j;try{j=tr(R.subarray(Z.size,Z.size+Z.headerSize))}catch(at){return Ke.error("failed to parse message header",at,I),null}Ke.debug("message received:",j.method);var Le;if(j.payload_size>0){var Ae=O+Z.size+Z.headerSize,Ve=j.payload_size;if(!j.hasOwnProperty("payload_type")||j.payload_type.indexOf("application/json")===0)try{Le=tr(R.subarray(Ae,Ae+Ve))}catch(at){return Ke.error("failed to parse message body",at,I),null}else j.payload_type.indexOf("text/plain")===0&&(Le=zt(R.subarray(Ae,Ae+Ve)))}return{method:j.method,header:j,payload:Le}}},{key:"createPacket",value:function(I){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";I.payload_size=ct(O);var R=JSON.stringify(I),Z="TWILSOCK V3.0 "+ct(R);Ke.debug("send request:",Z+R+O);var j=bt(Z+`\r
927
927
  `+R+`\r
928
928
  `+O);return j.buffer}}]),te}();function pe(te){var ue=$e();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function $e(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ae=function(te){_e.default(I,te);var ue=pe(I);function I(O){return oe.default(this,I),ue.call(this,O)}return re.default(I)}(ke.default(Error));function me(te){var ue=we();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function we(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var K=function(te){_e.default(I,te);var ue=me(I);function I(O,R){var Z;return oe.default(this,I),Z=ue.call(this,O),Z.reply=R,Z}return re.default(I)}(ae);function he(te,ue){var I=Object.keys(te);if(Object.getOwnPropertySymbols){var O=Object.getOwnPropertySymbols(te);ue&&(O=O.filter(function(R){return Object.getOwnPropertyDescriptor(te,R).enumerable})),I.push.apply(I,O)}return I}function G(te){for(var ue=1;ue<arguments.length;ue++){var I=arguments[ue]!=null?arguments[ue]:{};ue%2?he(Object(I),!0).forEach(function(O){q.default(te,O,I[O])}):Object.getOwnPropertyDescriptors?Object.defineProperties(te,Object.getOwnPropertyDescriptors(I)):he(Object(I)).forEach(function(O){Object.defineProperty(te,O,Object.getOwnPropertyDescriptor(I,O))})}return te}function de(te){var ue=ee();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function ee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=function(te){_e.default(I,te);var ue=de(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"newBackoff",null),q.default(V.default(R),"usedBackoff",null),q.default(V.default(R),"retrier",null),R.options=O?G({},O):{},R}return re.default(I,[{key:"inProgress",get:function(){return!!this.retrier}},{key:"start",value:function(){if(this.inProgress)throw new Error("Already waiting for next attempt, call finishAttempt(success : boolean) to finish it");this.createRetrier()}},{key:"stop",value:function(){this.cleanRetrier(),this.newBackoff=null,this.usedBackoff=null}},{key:"modifyBackoff",value:function(R){this.newBackoff=R}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");if(this.newBackoff){var R=!this.usedBackoff||this.usedBackoff<this.newBackoff;if(R)this.createRetrier();else{var Z;(Z=this.retrier)===null||Z===void 0||Z.failed(new Error)}}else{var j;(j=this.retrier)===null||j===void 0||j.failed(new Error)}}},{key:"cancel",value:function(){var R;(R=this.retrier)===null||R===void 0||R.cancel()}},{key:"cleanRetrier",value:function(){var R,Z;(R=this.retrier)===null||R===void 0||R.removeAllListeners(),(Z=this.retrier)===null||Z===void 0||Z.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var R=G({},this.options);return this.newBackoff&&(R.min=this.newBackoff,R.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),R.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,R}},{key:"createRetrier",value:function(){var R=this;this.cleanRetrier();var Z=this.getRetryPolicy();this.retrier=new X.Retrier(Z),this.retrier.once("attempt",function(){var j,Le;(j=R.retrier)===null||j===void 0||j.on("attempt",function(){return R.emit("attempt")}),(Le=R.retrier)===null||Le===void 0||Le.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(j){return R.emit("failed",j)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),I}(Ee.ReplayEventEmitter);function qe(te){var ue=dt();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function dt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var lt=3e3;function ht(te){setTimeout(te,0)}var Rt=function(te){_e.default(I,te);var ue=qe(I);function I(O,R,Z){var j;oe.default(this,I),j=ue.call(this),q.default(V.default(j),"disconnectingTimer",null),q.default(V.default(j),"disconnectedPromiseResolve",null),q.default(V.default(j),"terminalStates",["disconnected","rejected"]),q.default(V.default(j),"tokenExpiredSasCode",20104),q.default(V.default(j),"terminationReason","Connection is not initialized"),j.websocket=O,j.websocket.on("connected",function(){return j.fsm.socketConnected()}),j.websocket.on("disconnected",function(){return j.fsm.socketClosed()}),j.websocket.on("message",function(Ae){return j.onIncomingMessage(Ae)}),j.websocket.on("socketError",function(Ae){j.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(Ae.message),httpStatusCode:null,errorCode:null}),j.emit("stateChanged","retrying")}),j.transport=R,j.config=Z,j.retrier=new Ye(Z.retryPolicy),j.retrier.on("attempt",function(){return j.retry()}),j.retrier.on("failed",function(Ae){Ke.warn("Retrying failed: ".concat(Ae.message)),j.disconnect()}),typeof window<"u"&&typeof window.addEventListener<"u"&&(window.addEventListener("online",function(){Ke.debug("Browser reported connectivity state: online"),j.resetBackoff(),j.fsm.systemOnline()}),window.addEventListener("offline",function(){Ke.debug("Browser reported connectivity state: offline"),j.websocket.close(),j.fsm.socketClosed()}));var Le=ye.factory({init:"disconnected",transitions:[{name:"userConnect",from:["disconnected","rejected"],to:"connecting"},{name:"userConnect",from:["connecting","connected"]},{name:"userDisconnect",from:["connecting","initialising","connected","updating","retrying","rejected","waitSocketClosed","waitOffloadSocketClosed"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"initialising"},{name:"socketClosed",from:["connecting","initialising","connected","updating","error","waitOffloadSocketClosed"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketClosed",from:["waitSocketClosed"],to:"disconnected"},{name:"socketClosed",from:["rejected"],to:"rejected"},{name:"initSuccess",from:["initialising"],to:"connected"},{name:"initError",from:["initialising"],to:"error"},{name:"tokenRejected",from:["initialising","updating"],to:"rejected"},{name:"protocolError",from:["initialising","connected","updating"],to:"error"},{name:"receiveClose",from:["initialising","connected","updating"],to:"waitSocketClosed"},{name:"receiveOffload",from:["initialising","connected","updating"],to:"waitOffloadSocketClosed"},{name:"unsupportedProtocol",from:["initialising","connected","updating"],to:"unsupported"},{name:"receiveFatalClose",from:["initialising","connected","updating"],to:"unsupported"},{name:"userUpdateToken",from:["disconnected","rejected","connecting","retrying"],to:"connecting"},{name:"userUpdateToken",from:["connected"],to:"updating"},{name:"updateSuccess",from:["updating"],to:"connected"},{name:"updateError",from:["updating"],to:"error"},{name:"userSend",from:["connected"],to:"connected"},{name:"systemOnline",from:["retrying"],to:"connecting"}],methods:{onConnecting:function(){j.setupSocket(),j.emit("connecting")},onEnterInitialising:function(){j.sendInit()},onLeaveInitialising:function(){j.cancelInit()},onEnterUpdating:function(){j.sendUpdate()},onLeaveUpdating:function(){j.cancelUpdate()},onEnterRetrying:function(){j.initRetry(),j.emit("connecting")},onEnterConnected:function(){j.resetBackoff(),j.onConnected()},onUserUpdateToken:function(){j.resetBackoff()},onTokenRejected:function(){j.resetBackoff(),j.closeSocket(!0),j.finalizeSocket()},onUserDisconnect:function(){j.closeSocket(!0)},onEnterDisconnecting:function(){j.startDisconnectTimer()},onLeaveDisconnecting:function(){j.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){j.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){j.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){j.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){j.cancelDisconnectTimer()},onDisconnected:function(){j.resetBackoff(),j.finalizeSocket()},onReceiveClose:function(){j.onCloseReceived()},onReceiveOffload:function(Ve,at){Ke.debug("onreceiveoffload: ",at),j.modifyBackoff(at.body),j.onCloseReceived()},onUnsupported:function(){j.closeSocket(!0),j.finalizeSocket()},onError:function(Ve,at){j.closeSocket(at),j.finalizeSocket()},onEnterState:function(Ve){Ve.from!=="none"&&j.changeState(Ve)},onInvalidTransition:function(Ve,at,Tt){Ke.warn("FSM: unexpected transition",at,Tt)}}});return j.fsm=new Le,j}return re.default(I,[{key:"changeState",value:function(R){Ke.debug("FSM: ".concat(R.transition,": ").concat(R.from," --> ").concat(R.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){Ke.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function(R){Ke.trace("modifyBackoff",R);var Z=R?R.backoff_policy:null;Z&&typeof Z.reconnect_min_ms=="number"&&this.retrier.modifyBackoff(Z.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var R=this;Ke.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){Ke.debug("disconnecting is timed out"),R.closeSocket(!0)},lt)}},{key:"cancelDisconnectTimer",value:function(){Ke.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return this.state==="connected"&&this.websocket.isConnected}},{key:"state",get:function(){switch(this.fsm.state){case"connecting":case"initialising":case"retrying":case"error":return"connecting";case"updating":case"connected":return"connected";case"rejected":return"denied";case"disconnecting":case"waitSocketClosed":case"waitOffloadSocketClosed":return"disconnecting";case"disconnected":default:return"disconnected"}}},{key:"initRetry",value:function(){Ke.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){this.fsm.state!="connecting"?(Ke.trace("retry"),this.websocket.close(),this.fsm.userRetry()):Ke.trace("can retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){Ke.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){Ke.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function(R){var Z=Ne.parse(R);if(Z){var j=Z.method,Le=Z.header,Ae=Z.payload;if(j!=="reply"&&this.confirmReceiving(Le),j==="notification")this.emit("message",Le.message_type,Ae);else if(Le.method==="reply")this.transport.processReply({id:Le.id,status:Le.status,header:Le,body:Ae});else if(Le.method==="client_update")Le.client_update_type==="token_about_to_expire"&&this.emit("tokenAboutToExpire");else if(Le.method==="close")if(Le.status.code===308)Ke.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:Le.status.status,body:Ae});else if(Le.status.code===406){var Ve="Server closed connection because can't parse protocol: ".concat(JSON.stringify(Le.status));this.emitReplyConnectionError(Ve,Le,!0),Ke.error(Ve),this.fsm.receiveFatalClose()}else Le.status.code===417?(Ke.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(Le.status))),this.fsm.receiveFatalClose(Le.status.status)):Le.status.code===410?(Ke.warn("Server closed connection: ".concat(JSON.stringify(Le.status))),this.fsm.receiveClose(Le.status.status),this.emit("tokenExpired")):Le.status.code===401?(Ke.error("Server closed connection: ".concat(JSON.stringify(Le.status))),this.fsm.receiveClose(Le.status.status)):(Ke.warn("unexpected message: ",Le.status),this.fsm.receiveOffload({status:Le.status.status,body:null}))}}},{key:"sendInit",value:function(){var O=ze.default(ne.default.mark(function Z(){var j,Le;return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Ke.trace("sendInit"),Ve.prev=1,this.emit("beforeSendInit"),Ve.next=5,this.transport.sendInit();case 5:j=Ve.sent,this.config.updateContinuationToken(j.continuationToken),this.config.confirmedCapabilities=j.confirmedCapabilities,this.fsm.initSuccess(j),this.emit("initialized",j),this.emit("tokenUpdated"),Ve.next=17;break;case 13:Ve.prev=13,Ve.t0=Ve.catch(1),Ve.t0 instanceof K?(Le=!1,Ke.warn("Init rejected by server: ".concat(JSON.stringify(Ve.t0.reply.status))),this.emit("sendInitFailed"),Ve.t0.reply.status.code===401||Ve.t0.reply.status.code===403?(Le=!0,this.fsm.tokenRejected(Ve.t0.reply.status),Ve.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Ve.t0.reply.status.code===429?(this.modifyBackoff(Ve.t0.reply.body),this.fsm.initError(!0)):Ve.t0.reply.status.code===500?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(Ve.t0.message,Ve.t0.reply,Le)):(this.terminationReason=Ve.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(Ve.t0.message,`
929
- `).concat(JSON.stringify(Ve.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Ve.t0);case 17:case"end":return Ve.stop()}},Z,this,[[1,13]])}));function R(){return O.apply(this,arguments)}return R}()},{key:"sendUpdate",value:function(){var O=ze.default(ne.default.mark(function Z(){var j,Le,Ae;return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return Ke.trace("sendUpdate"),j=new ut(this.config.token),at.prev=2,at.next=5,this.transport.sendWithReply(j);case 5:Le=at.sent,this.fsm.updateSuccess(Le.body),this.emit("tokenUpdated"),at.next=14;break;case 10:at.prev=10,at.t0=at.catch(2),at.t0 instanceof K?(Ae=!1,Ke.warn("Token update rejected by server: ".concat(JSON.stringify(at.t0.reply.status))),at.t0.reply.status.code===401||at.t0.reply.status.code===403?(Ae=!0,this.fsm.tokenRejected(at.t0.reply.status),at.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):at.t0.reply.status.code===429?(this.modifyBackoff(at.t0.reply.body),this.fsm.updateError(at.t0.reply.status)):this.fsm.updateError(at.t0.reply.status),this.emitReplyConnectionError(at.t0.message,at.t0.reply,Ae)):(this.emit("error",!1,at.t0.message,null,null),this.fsm.updateError(at.t0)),this.emit("tokenUpdated",at.t0);case 14:case"end":return at.stop()}},Z,this,[[2,10]])}));function R(){return O.apply(this,arguments)}return R}()},{key:"emitReplyConnectionError",value:function(R,Z,j){var Le=Z.status&&Z.status.description?Z.status.description:R,Ae=Z.status.code,Ve=Z.status&&Z.status.errorCode?Z.status.errorCode:null;j&&(this.terminationReason=Le),this.emit("connectionError",{terminal:j,message:"Connection error: ".concat(Le),httpStatusCode:Ae,errorCode:Ve})}},{key:"cancelInit",value:function(){Ke.trace("cancelInit")}},{key:"cancelUpdate",value:function(){Ke.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(R){Ke.trace("confirmReceiving");try{this.transport.send(new dr(R.id))}catch(Z){Ke.debug("failed to confirm packet receiving",Z)}}},{key:"closeSocket",value:function(R){var Z=this;Ke.trace("closeSocket (graceful: ".concat(R,")")),R&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),ht(function(){return Z.fsm.socketClosed()})}},{key:"connect",value:function(){Ke.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var R=this;return Ke.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(Z){R.disconnectedPromiseResolve=Z,R.fsm.userDisconnect()})}},{key:"updateToken",value:function(R){var Z=this;return Ke.trace("updateToken:",R),new Promise(function(j,Le){Z.once("tokenUpdated",function(Ae){Ae?Le(Ae):j()}),Z.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),I}(Ee.ReplayEventEmitter),xt=function(){function te(){oe.default(this,te)}return re.default(te,null,[{key:"getMetadata",value:function(I){var O,R,Z,j,Le,Ae,Ve,at,Tt=I&&I.clientMetadata?I.clientMetadata:{},Br=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Nn={env:(O=M.name)!==null&&O!==void 0?O:"unknown",envv:(R=M.version)!==null&&R!==void 0?R:"unknown",os:(Z=(j=M.os)===null||j===void 0?void 0:j.family)!==null&&Z!==void 0?Z:"unknown",osv:(Le=(Ae=M.os)===null||Ae===void 0?void 0:Ae.version)!==null&&Le!==void 0?Le:"unknown",osa:(Ve=(at=M.os)===null||at===void 0?void 0:at.architecture)!==null&&Ve!==void 0?Ve:"unknown",sdk:"js-default"},kn={};return Br.filter(function(D){return D in Tt||D in Nn}).forEach(function(D){return kn[D]=D in Tt?Tt[D]:Nn[D]}),kn}}]),te}(),kt=3e4;function $t(te){return te>=200&&te<300}function It(te){switch(Se.default(te)){case"undefined":return"";case"object":return JSON.stringify(te);default:return te}}var jt=function(){function te(ue,I){var O=this;oe.default(this,te),this.config=I,this.activeRequests=new Map,this.channel=ue,this.channel.on("reply",function(R){return O.processReply(R)}),this.channel.on("disconnected",function(){O.activeRequests.forEach(function(R){clearTimeout(R.timeout),R.reject(new ae("disconnected"))}),O.activeRequests.clear()})}return re.default(te,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(I){var O=this.activeRequests.get(I.id);O&&(clearTimeout(O.timeout),this.activeRequests.delete(I.id),$t(I.status.code)?O.resolve(I):(O.reject(new K("Transport failure: "+I.status.status,I)),Ke.trace("message rejected")))}},{key:"storeRequest",value:function(I,O,R){var Z={resolve:O,reject:R,timeout:setTimeout(function(){Ke.trace("request",I,"is timed out"),R(new ae("Twilsock: request timeout: "+I))},kt)};this.activeRequests.set(I,Z)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(I){clearTimeout(I.timeout),I.reject(new ae("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var ue=ze.default(ne.default.mark(function O(){var R,Z,j;return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return Ke.trace("sendInit"),R=xt.getMetadata(this.config),Z=new At(this.config.token,this.config.continuationToken,R,this.config.initRegistrations,this.config.tweaks),Ae.next=5,this.sendWithReply(Z);case 5:return j=Ae.sent,Ae.abrupt("return",new ot(j.id,j.header.continuation_token,new Set(j.header.capabilities),j.header.continuation_token_status,j.header.offline_storage,j.header.init_registrations,j.header.debug_info));case 7:case"end":return Ae.stop()}},O,this)}));function I(){return ue.apply(this,arguments)}return I}()},{key:"sendClose",value:function(){var I=new Ot;this.send(I)}},{key:"sendWithReply",value:function(I,O){var R=this;return new Promise(function(Z,j){var Le=R.send(I,O);R.storeRequest(Le,Z,j)})}},{key:"send",value:function(I,O){I.id=I.id||"TM".concat(N.v4());var R=Ne.createPacket(I,It(O));try{return this.channel.send(R),I.id}catch(Z){throw Ke.debug("failed to send ",I,Z),Ke.trace(Z.stack),Z}}}]),te}();function sn(te){var ue=_n();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function _n(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ut=function(te){_e.default(I,te);var ue=sn(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"socket",null),R.url=O,R.url=O,R.WebSocket=e.WebSocket||e.MozWebSocket||{},R}return re.default(I,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var R=this;Ke.trace("connecting to socket");var Z;try{Z=new this.WebSocket(this.url)}catch(j){Ke.debug("Socket error: ".concat(this.url)),this.emit("socketError",j);return}Z.binaryType="arraybuffer",Z.onopen=function(){Ke.debug("socket opened ".concat(R.url)),R.emit("connected")},Z.onclose=function(j){Ke.debug("socket closed",j),R.emit("disconnected",j)},Z.onerror=function(j){Ke.debug("Socket error:",j),R.emit("socketError",j)},Z.onmessage=function(j){R.emit("message",j.data)},this.socket=Z}},{key:"send",value:function(R){return this.socket&&this.socket.send(R)}},{key:"close",value:function(){if(Ke.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),I}(Ee.ReplayEventEmitter);function qn(te){var ue=ha();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function ha(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Wa=function(te){_e.default(I,te);var ue=qn(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),R.transport=O,R.registrations=new Map,R.registrationsInProgress=new Map,R}return re.default(I,[{key:"putNotificationContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){var Ae;return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return Ae={method:"put_notification_ctx",notification_ctx_id:j},at.next=3,this.transport.sendWithReply(Ae,Le);case 3:case"end":return at.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"deleteNotificationContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){var Le;return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Le={method:"delete_notification_ctx",notification_ctx_id:j},Ve.next=3,this.transport.sendWithReply(Le);case 3:case"end":return Ve.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"updateRegistration",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){var Ae,Ve;return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return Ke.debug("update registration for context",j),Ae=this.registrationsInProgress.get(j),Ae||(Ae=new Set,this.registrationsInProgress.set(j,Ae)),Ve=N.v4(),Ae.add(Ve),Tt.prev=5,Tt.next=8,this.putNotificationContext(j,Le);case 8:Ke.debug("registration attempt succeeded for context",Le),Ae.delete(Ve),Ae.size===0&&(this.registrationsInProgress.delete(j),this.emit("registered",j)),Tt.next=19;break;case 13:Tt.prev=13,Tt.t0=Tt.catch(5),Ke.warn("registration attempt failed for context",Le),Ke.debug(Tt.t0),Ae.delete(Ve),Ae.size===0&&(this.registrationsInProgress.delete(j),this.emit("registrationFailed",j,Tt.t0));case 19:case"end":return Tt.stop()}},Z,this,[[5,13]])}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"updateRegistrations",value:function(){var O=ze.default(ne.default.mark(function Z(){var j=this,Le;return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Ke.trace("refreshing ".concat(this.registrations.size," registrations")),Le=[],this.registrations.forEach(function(at,Tt){Le.push(j.updateRegistration(Tt,at))}),Ve.next=5,Promise.all(Le);case 5:case"end":return Ve.stop()}},Z,this)}));function R(){return O.apply(this,arguments)}return R}()},{key:"setNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:if(!(!j||!Le)){Ve.next=2;break}throw new ae("Invalid arguments provided");case 2:return this.registrations.set(j,Le),Ve.next=5,this.updateRegistration(j,Le);case 5:return Ve.abrupt("return",Ve.sent);case 6:case"end":return Ve.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"removeNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:if(this.registrations.has(j)){Ae.next=2;break}return Ae.abrupt("return");case 2:return Ae.next=4,this.deleteNotificationContext(j);case 4:this.transport.isConnected&&this.registrations.delete(j);case 5:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()}]),I}(Ee.ReplayEventEmitter);function ti(te){var ue=pa();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function pa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ri=function(te){_e.default(I,te);var ue=ti(I);function I(O,R,Z){var j;return oe.default(this,I),j=ue.call(this,R),j.status=O,j.description=R,j.body=Z,j}return re.default(I)}(ae);function gi(te){var ue=Za();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Za(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var en=function(te){_e.default(I,te);var ue=gi(I);function I(O){return oe.default(this,I),ue.call(this,O)}return re.default(I)}(ae),ji=2e4;function Ms(te){return te>=200&&te<300}function Ui(te){return te&&te.header&&te.header.http_status}function Ns(te){var ue=te.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(ue){var I={protocol:ue[1],host:ue[2],hostname:ue[3],port:ue[4],pathname:ue[5],search:ue[6],hash:ue[7],params:{}};if(I.search.length>0){var O=I.search.substring(1);I.params=O.split("&").map(function(R){return R.split("=")}).reduce(function(R,Z){return R.hasOwnProperty(Z[0])?Array.isArray(R[Z[0]])?R[Z[0]].push(Z[1]):R[Z[0]]=[R[Z[0]],Z[1]]:R[Z[0]]=Z[1],R},{})}return I}throw new ae("Incorrect URI: "+te)}function Bo(te,ue){var I=Ns(ue),O={method:te,host:I.host,path:I.pathname};return I.params&&(O.params=I.params),O}function Vn(te,ue,I,O,R){return{to:Bo(te,ue),headers:I,body:O,grant:R}}var Ls=function(){function te(ue,I,O){oe.default(this,te),this.config=O,this.transport=ue,this.pendingMessages=[],this.twilsock=I}return re.default(te,[{key:"saveMessage",value:function(I){var O=this;return new Promise(function(R,Z){var j={message:I,resolve:R,reject:Z,alreadyRejected:!1,timeout:setTimeout(function(){Ke.debug("request is timed out"),Z(new ae("request '".concat(I.to.method,"' to '").concat(I.to.host,"' timed out"))),j.alreadyRejected=!0},ji)};O.pendingMessages.push(j)})}},{key:"sendPendingMessages",value:function(){for(var I=this,O=function(){var j=I.pendingMessages[0];if(!j.alreadyRejected)try{var Le=j.message;I.actualSend(Le).then(function(Ae){return j.resolve(Ae)}).catch(function(Ae){return j.reject(Ae)}),clearTimeout(j.timeout)}catch(Ae){return Ke.debug("Failed to send pending message",Ae),"break"}I.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var R=O();if(R==="break")break}}},{key:"rejectPendingMessages",value:function(){var I=this;this.pendingMessages.forEach(function(O){O.reject(new en("Unable to connect: "+I.twilsock.getTerminationReason)),O.alreadyRejected=!0,clearTimeout(O.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var ue=ze.default(ne.default.mark(function O(R){var Z,j,Le,Ae,Ve,at,Tt,Br;return ne.default.wrap(function(kn){for(;;)switch(kn.prev=kn.next){case 0:return j=R.to,Le=R.headers,Ae=R.body,Ve=(Z=R.grant)!==null&&Z!==void 0?Z:this.config.activeGrant,at={host:j.host,path:j.path,method:j.method,params:j.params,headers:Le},Tt=new et(Ve,Le["Content-Type"]||"application/json",at),Ke.trace("Sending upstream message",Tt),kn.next=9,this.transport.sendWithReply(Tt,Ae);case 9:if(Br=kn.sent,Ke.trace("Received upstream message response",Br),!(Ui(Br)&&!Ms(Br.header.http_status.code))){kn.next=13;break}throw new ri(Br.header.http_status.code,Br.header.http_status.status,Br.body);case 13:return kn.abrupt("return",{status:Br.header.http_status,headers:Br.header.http_headers,body:Br.body});case 14:case"end":return kn.stop()}},O,this)}));function I(O){return ue.apply(this,arguments)}return I}()},{key:"send",value:function(I,O){var R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},Z=arguments.length>3?arguments[3]:void 0,j=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new en("Unable to connect: "+this.twilsock.getTerminationReason));var Le=Vn(I,O,R,Z,j);return this.twilsock.isConnected?this.actualSend(Le):this.saveMessage(Le)}}]),te}(),zo=function(){function te(){var ue=this;oe.default(this,te),this._promise=new Promise(function(I,O){ue._resolve=I,ue._reject=O})}return re.default(te,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(I){this._resolve(I)}},{key:"set",value:function(I){this._resolve(I)}},{key:"fail",value:function(I){this._reject(I)}}]),te}(),Ho=function(){function te(ue){oe.default(this,te),this.id=ue}return re.default(te,null,[{key:"create",value:function(I){if(I instanceof Object&&"storage_id"in I)return new te(I.storage_id);throw new ae('Field "storage_id" is missing')}}]),te}(),hn=function(){function te(){return oe.default(this,te),q.default(this,"initializedFlag","twilio_twilsock_token_storage"),q.default(this,"tokenStoragePrefix","twilio_continuation_token_"),te._instance||(this.initialize(),te._instance=this),te._instance}return re.default(te,[{key:"sessionStorage",value:function(){try{return e.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return e.window}catch{return null}}},{key:"storeToken",value:function(I,O){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(O),I)}},{key:"getStoredToken",value:function(I){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(I)):null}},{key:"initialize",value:function(){var I=this;if(this.canStore()){var O=this.sessionStorage.getItem(this.initializedFlag);O&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var R=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){R(I.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var I=[],O=0;O<this.sessionStorage.length;O++){var R=this.sessionStorage.key(O);R&&R.indexOf(this.tokenStoragePrefix)===0&&I.push(R)}var Z=this.sessionStorage.removeItem;I.forEach(function(j){return Z(j)}),Z(this.initializedFlag)}}},{key:"getKeyName",value:function(I){return"".concat(this.tokenStoragePrefix).concat(I)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),te}();q.default(hn,"_instance",null);var Ds=new hn,Pn=function(){function te(ue,I,O,R,Z,j){oe.default(this,te),this.title=ue,this.details=I,this.start=O,this.type=Z,this.id=j,this.end=R}return re.default(te,[{key:"toTelemetryEvent",value:function(){var I=new Date,O=this.start,R=this.end?this.end:I;if(R<O){var Z=R;R=O,O=Z}var j=O.getTime()-I.getTime(),Le=R.getTime()-I.getTime(),Ae=new ie(j,Le,this.title,this.details,this.id,this.type);return Ae}}]),te}();t.TelemetryPoint=void 0,function(te){te[te.Start=0]="Start",te[te.End=1]="End"}(t.TelemetryPoint||(t.TelemetryPoint={})),t.EventSendingLimitation=void 0,function(te){te[te.MinEventsPortion=0]="MinEventsPortion",te[te.AnyEvents=1]="AnyEvents",te[te.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(t.EventSendingLimitation||(t.EventSendingLimitation={}));var Dr=function(){function te(ue,I){oe.default(this,te),q.default(this,"minEventsPortionToSend",50),q.default(this,"maxEventsPortionToSend",100),q.default(this,"pendingEvents",new Map),q.default(this,"readyEvents",[]),q.default(this,"hasInitializationFinished",!1),q.default(this,"_canSendTelemetry",!1),this.config=ue,this.packetInterface=I}return re.default(te,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(I){Ke.debug("TelemetryTracker.canSendTelemetry: ".concat(I," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!I&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=I,I&&this.sendTelemetry(t.EventSendingLimitation.AnyEvents),I&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(I){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(I)}},{key:"addPartialEvent",value:function(I,O,R){Ke.debug("Adding ".concat(R===t.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(O,"' event"));var Z=this.pendingEvents.has(O);if(R===t.TelemetryPoint.Start)Z&&Ke.debug("Overwriting starting point for '".concat(O,"' event")),this.pendingEvents.set(O,I);else{if(!Z){Ke.info("Could not find started event for '".concat(O,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(O),I)),this.pendingEvents.delete(O)}}},{key:"getTelemetryToSend",value:function(I){return!this.canSendTelemetry||this.readyEvents.length==0?[]:I==t.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(I==t.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(I){var O=this,R=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),Z=this.readyEvents.splice(0,R);return I&&Z.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(j,Le){if(!(Z.length>=O.maxEventsPortionToSend)){var Ae=O.pendingEvents.get(Le);O.pendingEvents.delete(Le),Z.push(new Pn("[UNFINISHED] ".concat(Ae.title),Ae.details,Ae.start,null,Ae.type,Ae.id))}}),Z}},{key:"merge",value:function(I,O){return new Pn(O.title?O.title:I.title,O.details?O.details:I.details,I.start,O.end,O.type?O.type:I.type,O.id?O.id:I.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(t.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(I){var O=this.getTelemetryToSend(I);if(O.length!==0)try{this.packetInterface.send(new He(O.map(function(R){return R.toTelemetryEvent()})))}catch(R){Ke.debug("Error while sending ".concat(O.length," telemetry events due to ").concat(R,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(O)}}}]),te}();function qo(te){var ue=ni();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function ni(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Mn=re.default(function te(){oe.default(this,te)});q.default(Mn,"TWILSOCK_CONNECT","twilsock.sdk.connect"),q.default(Mn,"TWILSOCK_INIT","twilsock.sdk.init"),t.TwilsockClient=function(te){_e.default(I,te);var ue=qo(I);function I(O,R,Z){var j;oe.default(this,I),j=ue.call(this),q.default(V.default(j),"version",Fe),q.default(V.default(j),"offlineStorageDeferred",new zo),Z.continuationToken=Z.continuationToken?Z.continuationToken:Ds.getStoredToken(R);var Le=j.config=new be(O,R,Z);Ke.setLevel(Le.logLevel);var Ae=new Ut(Le.url),Ve=new jt(Ae,Le);return j.channel=new Rt(Ae,Ve,Le),j.registrations=new Wa(Ve),j.upstream=new Ls(Ve,j.channel,Le),j.telemetryTracker=new Dr(Le,Ve),j.channel.on("initialized",function(){return j.telemetryTracker.canSendTelemetry=!0}),Ae.on("disconnected",function(){return j.telemetryTracker.canSendTelemetry=!1}),j.registrations.on("registered",function(at){return j.emit("registered",at)}),j.channel.on("message",function(at,Tt){return setTimeout(function(){return j.emit("message",at,Tt)},0)}),j.channel.on("stateChanged",function(at){return setTimeout(function(){return j.emit("stateChanged",at)},0)}),j.channel.on("connectionError",function(at){return setTimeout(function(){return j.emit("connectionError",at)},0)}),j.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return j.emit("tokenAboutToExpire")},0)}),j.channel.on("tokenExpired",function(){return setTimeout(function(){return j.emit("tokenExpired")},0)}),j.channel.on("connected",function(){return j.registrations.updateRegistrations()}),j.channel.on("connected",function(){return j.upstream.sendPendingMessages()}),j.channel.on("connected",function(){return setTimeout(function(){return j.emit("connected")},0)}),j.channel.on("beforeConnect",function(){return j.telemetryTracker.addPartialEvent(new Pn("Establish WebSocket connection","",new Date),Mn.TWILSOCK_CONNECT,t.TelemetryPoint.Start)}),j.channel.on("connected",function(){return j.telemetryTracker.addPartialEvent(new Pn("Establish WebSocket connection","",new Date,new Date),Mn.TWILSOCK_CONNECT,t.TelemetryPoint.End)}),j.channel.on("beforeSendInit",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","",new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.Start)}),j.channel.on("initialized",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","Succeeded",new Date,new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("sendInitFailed",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","Failed",new Date,new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("initialized",function(at){j.handleStorageId(R,at),Ds.storeToken(at.continuationToken,R),setTimeout(function(){return j.emit("initialized",at)},0)}),j.channel.on("disconnected",function(){return setTimeout(function(){return j.emit("disconnected")},0)}),j.channel.on("disconnected",function(){return j.upstream.rejectPendingMessages()}),j.channel.on("disconnected",function(){return j.offlineStorageDeferred.fail(new ae("Client disconnected"))}),j.offlineStorageDeferred.promise.catch(function(){}),j}return re.default(I,[{key:"emit",value:function(R){for(var Z,j=arguments.length,Le=new Array(j>1?j-1:0),Ae=1;Ae<j;Ae++)Le[Ae-1]=arguments[Ae];return Ke.debug("Emitting ".concat(R.toString(),"(").concat(Le.map(function(Ve){return JSON.stringify(Ve)}).join(", "),")")),(Z=xe.default(Te.default(I.prototype),"emit",this)).call.apply(Z,[this,R].concat(Le))}},{key:"handleStorageId",value:function(R,Z){if(!Z.offlineStorage)this.offlineStorageDeferred.fail(new ae("No offline storage id"));else if(Z.offlineStorage.hasOwnProperty(R))try{this.offlineStorageDeferred.set(Ho.create(Z.offlineStorage[R])),Ke.debug("Offline storage for '".concat(R,"' product: ").concat(JSON.stringify(Z.offlineStorage[R]),"."))}catch(j){this.offlineStorageDeferred.fail(new ae("Failed to parse offline storage for ".concat(R," ").concat(JSON.stringify(Z.offlineStorage[R]),". ").concat(j,".")))}else this.offlineStorageDeferred.fail(new ae("No offline storage id for '".concat(R,"' product: ").concat(JSON.stringify(Z.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:if(Ke.trace("updating token '".concat(j,"'")),this.config.token!==j){Ae.next=3;break}return Ae.abrupt("return");case 3:return this.config.updateToken(j),Ae.next=6,this.channel.updateToken(j);case 6:return Ae.abrupt("return",Ae.sent);case 7:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"setNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Ve.next=2,this.registrations.setNotificationsContext(j,Le);case 2:case"end":return Ve.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"removeNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return Ae.next=2,this.registrations.removeNotificationsContext(j);case 2:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var O=ze.default(ne.default.mark(function Z(){return ne.default.wrap(function(Le){for(;;)switch(Le.prev=Le.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEventsIncludingUnfinished),Le.next=3,this.channel.disconnect();case 3:return Le.abrupt("return",Le.sent);case 4:case"end":return Le.stop()}},Z,this)}));function R(){return O.apply(this,arguments)}return R}()},{key:"get",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae){return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),at.next=3,this.upstream.send("GET",j,Le,void 0,Ae);case 3:return at.abrupt("return",at.sent);case 4:case"end":return at.stop()}},Z,this)}));function R(Z,j,Le){return O.apply(this,arguments)}return R}()},{key:"post",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("POST",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"put",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("PUT",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"delete",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("DELETE",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"addTelemetryEvent",value:function(R){this.telemetryTracker.addTelemetryEvent(R),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(R,Z,j){this.telemetryTracker.addPartialEvent(R,Z,j),j===t.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),I}(Ee.ReplayEventEmitter),t.TwilsockClient=Xe([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Ct("design:paramtypes",[String,String,Object])],t.TwilsockClient);var js=function(){function te(ue){oe.default(this,te),this.product=ue,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return re.default(te,[{key:"populateInitRegistrations",value:function(I){var O=new Set(this.message_types);for(var R in I)O.add(I[R]);this.message_types=Array.from(O)}}]),te}();t.InitRegistration=js,t.TelemetryEventDescription=Pn,t.TelemetryTracker=Dr,t.TransportUnavailableError=en,t.Twilsock=t.TwilsockClient,t.TwilsockError=ae})(Qy);var yI={},bI=Ar,tee=Kt,ree=Er,nee=Vt,Vb=Bc,iee=jc,aee=Oc,see=yn,oee=Pc,rl=Object.assign,wI=Object.defineProperty,uee=tee([].concat),_I=!rl||nee(function(){if(bI&&rl({b:1},rl(wI({},"a",{enumerable:!0,get:function(){wI(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var t={},e={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return t[r]=7,n.split("").forEach(function(i){e[i]=i}),rl({},t)[r]!==7||Vb(rl({},e)).join("")!==n})?function(e,r){for(var n=see(e),i=arguments.length,a=1,s=iee.f,o=aee.f;i>a;)for(var u=oee(arguments[a++]),l=s?uee(Vb(u),s(u)):Vb(u),c=l.length,d=0,f;c>d;)f=l[d++],(!bI||ree(o,u,f))&&(n[f]=u[f]);return n}:rl,lee=er,kI=_I;lee({target:"Object",stat:!0,arity:2,forced:Object.assign!==kI},{assign:kI});/*
929
+ `).concat(JSON.stringify(Ve.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Ve.t0);case 17:case"end":return Ve.stop()}},Z,this,[[1,13]])}));function R(){return O.apply(this,arguments)}return R}()},{key:"sendUpdate",value:function(){var O=ze.default(ne.default.mark(function Z(){var j,Le,Ae;return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return Ke.trace("sendUpdate"),j=new ut(this.config.token),at.prev=2,at.next=5,this.transport.sendWithReply(j);case 5:Le=at.sent,this.fsm.updateSuccess(Le.body),this.emit("tokenUpdated"),at.next=14;break;case 10:at.prev=10,at.t0=at.catch(2),at.t0 instanceof K?(Ae=!1,Ke.warn("Token update rejected by server: ".concat(JSON.stringify(at.t0.reply.status))),at.t0.reply.status.code===401||at.t0.reply.status.code===403?(Ae=!0,this.fsm.tokenRejected(at.t0.reply.status),at.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):at.t0.reply.status.code===429?(this.modifyBackoff(at.t0.reply.body),this.fsm.updateError(at.t0.reply.status)):this.fsm.updateError(at.t0.reply.status),this.emitReplyConnectionError(at.t0.message,at.t0.reply,Ae)):(this.emit("error",!1,at.t0.message,null,null),this.fsm.updateError(at.t0)),this.emit("tokenUpdated",at.t0);case 14:case"end":return at.stop()}},Z,this,[[2,10]])}));function R(){return O.apply(this,arguments)}return R}()},{key:"emitReplyConnectionError",value:function(R,Z,j){var Le=Z.status&&Z.status.description?Z.status.description:R,Ae=Z.status.code,Ve=Z.status&&Z.status.errorCode?Z.status.errorCode:null;j&&(this.terminationReason=Le),this.emit("connectionError",{terminal:j,message:"Connection error: ".concat(Le),httpStatusCode:Ae,errorCode:Ve})}},{key:"cancelInit",value:function(){Ke.trace("cancelInit")}},{key:"cancelUpdate",value:function(){Ke.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(R){Ke.trace("confirmReceiving");try{this.transport.send(new dr(R.id))}catch(Z){Ke.debug("failed to confirm packet receiving",Z)}}},{key:"closeSocket",value:function(R){var Z=this;Ke.trace("closeSocket (graceful: ".concat(R,")")),R&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),ht(function(){return Z.fsm.socketClosed()})}},{key:"connect",value:function(){Ke.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var R=this;return Ke.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(Z){R.disconnectedPromiseResolve=Z,R.fsm.userDisconnect()})}},{key:"updateToken",value:function(R){var Z=this;return Ke.trace("updateToken:",R),new Promise(function(j,Le){Z.once("tokenUpdated",function(Ae){Ae?Le(Ae):j()}),Z.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),I}(Ee.ReplayEventEmitter),xt=function(){function te(){oe.default(this,te)}return re.default(te,null,[{key:"getMetadata",value:function(I){var O,R,Z,j,Le,Ae,Ve,at,Tt=I&&I.clientMetadata?I.clientMetadata:{},Br=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Nn={env:(O=M.name)!==null&&O!==void 0?O:"unknown",envv:(R=M.version)!==null&&R!==void 0?R:"unknown",os:(Z=(j=M.os)===null||j===void 0?void 0:j.family)!==null&&Z!==void 0?Z:"unknown",osv:(Le=(Ae=M.os)===null||Ae===void 0?void 0:Ae.version)!==null&&Le!==void 0?Le:"unknown",osa:(Ve=(at=M.os)===null||at===void 0?void 0:at.architecture)!==null&&Ve!==void 0?Ve:"unknown",sdk:"js-default"},kn={};return Br.filter(function(D){return D in Tt||D in Nn}).forEach(function(D){return kn[D]=D in Tt?Tt[D]:Nn[D]}),kn}}]),te}(),kt=3e4;function $t(te){return te>=200&&te<300}function It(te){switch(Se.default(te)){case"undefined":return"";case"object":return JSON.stringify(te);default:return te}}var jt=function(){function te(ue,I){var O=this;oe.default(this,te),this.config=I,this.activeRequests=new Map,this.channel=ue,this.channel.on("reply",function(R){return O.processReply(R)}),this.channel.on("disconnected",function(){O.activeRequests.forEach(function(R){clearTimeout(R.timeout),R.reject(new ae("disconnected"))}),O.activeRequests.clear()})}return re.default(te,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(I){var O=this.activeRequests.get(I.id);O&&(clearTimeout(O.timeout),this.activeRequests.delete(I.id),$t(I.status.code)?O.resolve(I):(O.reject(new K("Transport failure: "+I.status.status,I)),Ke.trace("message rejected")))}},{key:"storeRequest",value:function(I,O,R){var Z={resolve:O,reject:R,timeout:setTimeout(function(){Ke.trace("request",I,"is timed out"),R(new ae("Twilsock: request timeout: "+I))},kt)};this.activeRequests.set(I,Z)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(I){clearTimeout(I.timeout),I.reject(new ae("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var ue=ze.default(ne.default.mark(function O(){var R,Z,j;return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return Ke.trace("sendInit"),R=xt.getMetadata(this.config),Z=new At(this.config.token,this.config.continuationToken,R,this.config.initRegistrations,this.config.tweaks),Ae.next=5,this.sendWithReply(Z);case 5:return j=Ae.sent,Ae.abrupt("return",new ot(j.id,j.header.continuation_token,new Set(j.header.capabilities),j.header.continuation_token_status,j.header.offline_storage,j.header.init_registrations,j.header.debug_info));case 7:case"end":return Ae.stop()}},O,this)}));function I(){return ue.apply(this,arguments)}return I}()},{key:"sendClose",value:function(){var I=new Ot;this.send(I)}},{key:"sendWithReply",value:function(I,O){var R=this;return new Promise(function(Z,j){var Le=R.send(I,O);R.storeRequest(Le,Z,j)})}},{key:"send",value:function(I,O){I.id=I.id||"TM".concat(N.v4());var R=Ne.createPacket(I,It(O));try{return this.channel.send(R),I.id}catch(Z){throw Ke.debug("failed to send ",I,Z),Ke.trace(Z.stack),Z}}}]),te}();function sn(te){var ue=_n();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function _n(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ut=function(te){_e.default(I,te);var ue=sn(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),q.default(V.default(R),"socket",null),R.url=O,R.url=O,R.WebSocket=e.WebSocket||e.MozWebSocket||{},R}return re.default(I,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var R=this;Ke.trace("connecting to socket");var Z;try{Z=new this.WebSocket(this.url)}catch(j){Ke.debug("Socket error: ".concat(this.url)),this.emit("socketError",j);return}Z.binaryType="arraybuffer",Z.onopen=function(){Ke.debug("socket opened ".concat(R.url)),R.emit("connected")},Z.onclose=function(j){Ke.debug("socket closed",j),R.emit("disconnected",j)},Z.onerror=function(j){Ke.debug("Socket error:",j),R.emit("socketError",j)},Z.onmessage=function(j){R.emit("message",j.data)},this.socket=Z}},{key:"send",value:function(R){return this.socket&&this.socket.send(R)}},{key:"close",value:function(){if(Ke.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),I}(Ee.ReplayEventEmitter);function qn(te){var ue=ha();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function ha(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Wa=function(te){_e.default(I,te);var ue=qn(I);function I(O){var R;return oe.default(this,I),R=ue.call(this),R.transport=O,R.registrations=new Map,R.registrationsInProgress=new Map,R}return re.default(I,[{key:"putNotificationContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){var Ae;return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return Ae={method:"put_notification_ctx",notification_ctx_id:j},at.next=3,this.transport.sendWithReply(Ae,Le);case 3:case"end":return at.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"deleteNotificationContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){var Le;return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Le={method:"delete_notification_ctx",notification_ctx_id:j},Ve.next=3,this.transport.sendWithReply(Le);case 3:case"end":return Ve.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"updateRegistration",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){var Ae,Ve;return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return Ke.debug("update registration for context",j),Ae=this.registrationsInProgress.get(j),Ae||(Ae=new Set,this.registrationsInProgress.set(j,Ae)),Ve=N.v4(),Ae.add(Ve),Tt.prev=5,Tt.next=8,this.putNotificationContext(j,Le);case 8:Ke.debug("registration attempt succeeded for context",Le),Ae.delete(Ve),Ae.size===0&&(this.registrationsInProgress.delete(j),this.emit("registered",j)),Tt.next=19;break;case 13:Tt.prev=13,Tt.t0=Tt.catch(5),Ke.warn("registration attempt failed for context",Le),Ke.debug(Tt.t0),Ae.delete(Ve),Ae.size===0&&(this.registrationsInProgress.delete(j),this.emit("registrationFailed",j,Tt.t0));case 19:case"end":return Tt.stop()}},Z,this,[[5,13]])}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"updateRegistrations",value:function(){var O=ze.default(ne.default.mark(function Z(){var j=this,Le;return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Ke.trace("refreshing ".concat(this.registrations.size," registrations")),Le=[],this.registrations.forEach(function(at,Tt){Le.push(j.updateRegistration(Tt,at))}),Ve.next=5,Promise.all(Le);case 5:case"end":return Ve.stop()}},Z,this)}));function R(){return O.apply(this,arguments)}return R}()},{key:"setNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:if(!(!j||!Le)){Ve.next=2;break}throw new ae("Invalid arguments provided");case 2:return this.registrations.set(j,Le),Ve.next=5,this.updateRegistration(j,Le);case 5:return Ve.abrupt("return",Ve.sent);case 6:case"end":return Ve.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"removeNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:if(this.registrations.has(j)){Ae.next=2;break}return Ae.abrupt("return");case 2:return Ae.next=4,this.deleteNotificationContext(j);case 4:this.transport.isConnected&&this.registrations.delete(j);case 5:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()}]),I}(Ee.ReplayEventEmitter);function ti(te){var ue=pa();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function pa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ri=function(te){_e.default(I,te);var ue=ti(I);function I(O,R,Z){var j;return oe.default(this,I),j=ue.call(this,R),j.status=O,j.description=R,j.body=Z,j}return re.default(I)}(ae);function gi(te){var ue=Za();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function Za(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var en=function(te){_e.default(I,te);var ue=gi(I);function I(O){return oe.default(this,I),ue.call(this,O)}return re.default(I)}(ae),ji=2e4;function Ms(te){return te>=200&&te<300}function Ui(te){return te&&te.header&&te.header.http_status}function Ns(te){var ue=te.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(ue){var I={protocol:ue[1],host:ue[2],hostname:ue[3],port:ue[4],pathname:ue[5],search:ue[6],hash:ue[7],params:{}};if(I.search.length>0){var O=I.search.substring(1);I.params=O.split("&").map(function(R){return R.split("=")}).reduce(function(R,Z){return R.hasOwnProperty(Z[0])?Array.isArray(R[Z[0]])?R[Z[0]].push(Z[1]):R[Z[0]]=[R[Z[0]],Z[1]]:R[Z[0]]=Z[1],R},{})}return I}throw new ae("Incorrect URI: "+te)}function Bo(te,ue){var I=Ns(ue),O={method:te,host:I.host,path:I.pathname};return I.params&&(O.params=I.params),O}function Vn(te,ue,I,O,R){return{to:Bo(te,ue),headers:I,body:O,grant:R}}var Ls=function(){function te(ue,I,O){oe.default(this,te),this.config=O,this.transport=ue,this.pendingMessages=[],this.twilsock=I}return re.default(te,[{key:"saveMessage",value:function(I){var O=this;return new Promise(function(R,Z){var j={message:I,resolve:R,reject:Z,alreadyRejected:!1,timeout:setTimeout(function(){Ke.debug("request is timed out"),Z(new ae("request '".concat(I.to.method,"' to '").concat(I.to.host,"' timed out"))),j.alreadyRejected=!0},ji)};O.pendingMessages.push(j)})}},{key:"sendPendingMessages",value:function(){for(var I=this,O=function(){var j=I.pendingMessages[0];if(!j.alreadyRejected)try{var Le=j.message;I.actualSend(Le).then(function(Ae){return j.resolve(Ae)}).catch(function(Ae){return j.reject(Ae)}),clearTimeout(j.timeout)}catch(Ae){return Ke.debug("Failed to send pending message",Ae),"break"}I.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var R=O();if(R==="break")break}}},{key:"rejectPendingMessages",value:function(){var I=this;this.pendingMessages.forEach(function(O){O.reject(new en("Unable to connect: "+I.twilsock.getTerminationReason)),O.alreadyRejected=!0,clearTimeout(O.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var ue=ze.default(ne.default.mark(function O(R){var Z,j,Le,Ae,Ve,at,Tt,Br;return ne.default.wrap(function(kn){for(;;)switch(kn.prev=kn.next){case 0:return j=R.to,Le=R.headers,Ae=R.body,Ve=(Z=R.grant)!==null&&Z!==void 0?Z:this.config.activeGrant,at={host:j.host,path:j.path,method:j.method,params:j.params,headers:Le},Tt=new et(Ve,Le["Content-Type"]||"application/json",at),Ke.trace("Sending upstream message",Tt),kn.next=9,this.transport.sendWithReply(Tt,Ae);case 9:if(Br=kn.sent,Ke.trace("Received upstream message response",Br),!(Ui(Br)&&!Ms(Br.header.http_status.code))){kn.next=13;break}throw new ri(Br.header.http_status.code,Br.header.http_status.status,Br.body);case 13:return kn.abrupt("return",{status:Br.header.http_status,headers:Br.header.http_headers,body:Br.body});case 14:case"end":return kn.stop()}},O,this)}));function I(O){return ue.apply(this,arguments)}return I}()},{key:"send",value:function(I,O){var R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},Z=arguments.length>3?arguments[3]:void 0,j=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new en("Unable to connect: "+this.twilsock.getTerminationReason));var Le=Vn(I,O,R,Z,j);return this.twilsock.isConnected?this.actualSend(Le):this.saveMessage(Le)}}]),te}(),zo=function(){function te(){var ue=this;oe.default(this,te),this._promise=new Promise(function(I,O){ue._resolve=I,ue._reject=O})}return re.default(te,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(I){this._resolve(I)}},{key:"set",value:function(I){this._resolve(I)}},{key:"fail",value:function(I){this._reject(I)}}]),te}(),Ho=function(){function te(ue){oe.default(this,te),this.id=ue}return re.default(te,null,[{key:"create",value:function(I){if(I instanceof Object&&"storage_id"in I)return new te(I.storage_id);throw new ae('Field "storage_id" is missing')}}]),te}(),hn=function(){function te(){return oe.default(this,te),q.default(this,"initializedFlag","twilio_twilsock_token_storage"),q.default(this,"tokenStoragePrefix","twilio_continuation_token_"),te._instance||(this.initialize(),te._instance=this),te._instance}return re.default(te,[{key:"sessionStorage",value:function(){try{return e.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return e.window}catch{return null}}},{key:"storeToken",value:function(I,O){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(O),I)}},{key:"getStoredToken",value:function(I){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(I)):null}},{key:"initialize",value:function(){var I=this;if(this.canStore()){var O=this.sessionStorage.getItem(this.initializedFlag);O&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var R=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){R(I.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var I=[],O=0;O<this.sessionStorage.length;O++){var R=this.sessionStorage.key(O);R&&R.indexOf(this.tokenStoragePrefix)===0&&I.push(R)}var Z=this.sessionStorage.removeItem;I.forEach(function(j){return Z(j)}),Z(this.initializedFlag)}}},{key:"getKeyName",value:function(I){return"".concat(this.tokenStoragePrefix).concat(I)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),te}();q.default(hn,"_instance",null);var Ds=new hn,Pn=function(){function te(ue,I,O,R,Z,j){oe.default(this,te),this.title=ue,this.details=I,this.start=O,this.type=Z,this.id=j,this.end=R}return re.default(te,[{key:"toTelemetryEvent",value:function(){var I=new Date,O=this.start,R=this.end?this.end:I;if(R<O){var Z=R;R=O,O=Z}var j=O.getTime()-I.getTime(),Le=R.getTime()-I.getTime(),Ae=new ie(j,Le,this.title,this.details,this.id,this.type);return Ae}}]),te}();t.TelemetryPoint=void 0,function(te){te[te.Start=0]="Start",te[te.End=1]="End"}(t.TelemetryPoint||(t.TelemetryPoint={})),t.EventSendingLimitation=void 0,function(te){te[te.MinEventsPortion=0]="MinEventsPortion",te[te.AnyEvents=1]="AnyEvents",te[te.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(t.EventSendingLimitation||(t.EventSendingLimitation={}));var Dr=function(){function te(ue,I){oe.default(this,te),q.default(this,"minEventsPortionToSend",50),q.default(this,"maxEventsPortionToSend",100),q.default(this,"pendingEvents",new Map),q.default(this,"readyEvents",[]),q.default(this,"hasInitializationFinished",!1),q.default(this,"_canSendTelemetry",!1),this.config=ue,this.packetInterface=I}return re.default(te,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(I){Ke.debug("TelemetryTracker.canSendTelemetry: ".concat(I," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!I&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=I,I&&this.sendTelemetry(t.EventSendingLimitation.AnyEvents),I&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(I){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(I)}},{key:"addPartialEvent",value:function(I,O,R){Ke.debug("Adding ".concat(R===t.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(O,"' event"));var Z=this.pendingEvents.has(O);if(R===t.TelemetryPoint.Start)Z&&Ke.debug("Overwriting starting point for '".concat(O,"' event")),this.pendingEvents.set(O,I);else{if(!Z){Ke.info("Could not find started event for '".concat(O,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(O),I)),this.pendingEvents.delete(O)}}},{key:"getTelemetryToSend",value:function(I){return!this.canSendTelemetry||this.readyEvents.length==0?[]:I==t.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(I==t.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(I){var O=this,R=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),Z=this.readyEvents.splice(0,R);return I&&Z.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(j,Le){if(!(Z.length>=O.maxEventsPortionToSend)){var Ae=O.pendingEvents.get(Le);O.pendingEvents.delete(Le),Z.push(new Pn("[UNFINISHED] ".concat(Ae.title),Ae.details,Ae.start,null,Ae.type,Ae.id))}}),Z}},{key:"merge",value:function(I,O){return new Pn(O.title?O.title:I.title,O.details?O.details:I.details,I.start,O.end,O.type?O.type:I.type,O.id?O.id:I.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(t.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(I){var O=this.getTelemetryToSend(I);if(O.length!==0)try{this.packetInterface.send(new He(O.map(function(R){return R.toTelemetryEvent()})))}catch(R){Ke.debug("Error while sending ".concat(O.length," telemetry events due to ").concat(R,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(O)}}}]),te}();function qo(te){var ue=ni();return function(){var O=Te.default(te),R;if(ue){var Z=Te.default(this).constructor;R=Reflect.construct(O,arguments,Z)}else R=O.apply(this,arguments);return se.default(this,R)}}function ni(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Mn=re.default(function te(){oe.default(this,te)});q.default(Mn,"TWILSOCK_CONNECT","twilsock.sdk.connect"),q.default(Mn,"TWILSOCK_INIT","twilsock.sdk.init"),t.TwilsockClient=function(te){_e.default(I,te);var ue=qo(I);function I(O,R,Z){var j;oe.default(this,I),j=ue.call(this),q.default(V.default(j),"version",Be),q.default(V.default(j),"offlineStorageDeferred",new zo),Z.continuationToken=Z.continuationToken?Z.continuationToken:Ds.getStoredToken(R);var Le=j.config=new be(O,R,Z);Ke.setLevel(Le.logLevel);var Ae=new Ut(Le.url),Ve=new jt(Ae,Le);return j.channel=new Rt(Ae,Ve,Le),j.registrations=new Wa(Ve),j.upstream=new Ls(Ve,j.channel,Le),j.telemetryTracker=new Dr(Le,Ve),j.channel.on("initialized",function(){return j.telemetryTracker.canSendTelemetry=!0}),Ae.on("disconnected",function(){return j.telemetryTracker.canSendTelemetry=!1}),j.registrations.on("registered",function(at){return j.emit("registered",at)}),j.channel.on("message",function(at,Tt){return setTimeout(function(){return j.emit("message",at,Tt)},0)}),j.channel.on("stateChanged",function(at){return setTimeout(function(){return j.emit("stateChanged",at)},0)}),j.channel.on("connectionError",function(at){return setTimeout(function(){return j.emit("connectionError",at)},0)}),j.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return j.emit("tokenAboutToExpire")},0)}),j.channel.on("tokenExpired",function(){return setTimeout(function(){return j.emit("tokenExpired")},0)}),j.channel.on("connected",function(){return j.registrations.updateRegistrations()}),j.channel.on("connected",function(){return j.upstream.sendPendingMessages()}),j.channel.on("connected",function(){return setTimeout(function(){return j.emit("connected")},0)}),j.channel.on("beforeConnect",function(){return j.telemetryTracker.addPartialEvent(new Pn("Establish WebSocket connection","",new Date),Mn.TWILSOCK_CONNECT,t.TelemetryPoint.Start)}),j.channel.on("connected",function(){return j.telemetryTracker.addPartialEvent(new Pn("Establish WebSocket connection","",new Date,new Date),Mn.TWILSOCK_CONNECT,t.TelemetryPoint.End)}),j.channel.on("beforeSendInit",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","",new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.Start)}),j.channel.on("initialized",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","Succeeded",new Date,new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("sendInitFailed",function(){return j.telemetryTracker.addPartialEvent(new Pn("Send Twilsock init","Failed",new Date,new Date),Mn.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("initialized",function(at){j.handleStorageId(R,at),Ds.storeToken(at.continuationToken,R),setTimeout(function(){return j.emit("initialized",at)},0)}),j.channel.on("disconnected",function(){return setTimeout(function(){return j.emit("disconnected")},0)}),j.channel.on("disconnected",function(){return j.upstream.rejectPendingMessages()}),j.channel.on("disconnected",function(){return j.offlineStorageDeferred.fail(new ae("Client disconnected"))}),j.offlineStorageDeferred.promise.catch(function(){}),j}return re.default(I,[{key:"emit",value:function(R){for(var Z,j=arguments.length,Le=new Array(j>1?j-1:0),Ae=1;Ae<j;Ae++)Le[Ae-1]=arguments[Ae];return Ke.debug("Emitting ".concat(R.toString(),"(").concat(Le.map(function(Ve){return JSON.stringify(Ve)}).join(", "),")")),(Z=xe.default(Te.default(I.prototype),"emit",this)).call.apply(Z,[this,R].concat(Le))}},{key:"handleStorageId",value:function(R,Z){if(!Z.offlineStorage)this.offlineStorageDeferred.fail(new ae("No offline storage id"));else if(Z.offlineStorage.hasOwnProperty(R))try{this.offlineStorageDeferred.set(Ho.create(Z.offlineStorage[R])),Ke.debug("Offline storage for '".concat(R,"' product: ").concat(JSON.stringify(Z.offlineStorage[R]),"."))}catch(j){this.offlineStorageDeferred.fail(new ae("Failed to parse offline storage for ".concat(R," ").concat(JSON.stringify(Z.offlineStorage[R]),". ").concat(j,".")))}else this.offlineStorageDeferred.fail(new ae("No offline storage id for '".concat(R,"' product: ").concat(JSON.stringify(Z.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:if(Ke.trace("updating token '".concat(j,"'")),this.config.token!==j){Ae.next=3;break}return Ae.abrupt("return");case 3:return this.config.updateToken(j),Ae.next=6,this.channel.updateToken(j);case 6:return Ae.abrupt("return",Ae.sent);case 7:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"setNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le){return ne.default.wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:return Ve.next=2,this.registrations.setNotificationsContext(j,Le);case 2:case"end":return Ve.stop()}},Z,this)}));function R(Z,j){return O.apply(this,arguments)}return R}()},{key:"removeNotificationsContext",value:function(){var O=ze.default(ne.default.mark(function Z(j){return ne.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return Ae.next=2,this.registrations.removeNotificationsContext(j);case 2:case"end":return Ae.stop()}},Z,this)}));function R(Z){return O.apply(this,arguments)}return R}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var O=ze.default(ne.default.mark(function Z(){return ne.default.wrap(function(Le){for(;;)switch(Le.prev=Le.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEventsIncludingUnfinished),Le.next=3,this.channel.disconnect();case 3:return Le.abrupt("return",Le.sent);case 4:case"end":return Le.stop()}},Z,this)}));function R(){return O.apply(this,arguments)}return R}()},{key:"get",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae){return ne.default.wrap(function(at){for(;;)switch(at.prev=at.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),at.next=3,this.upstream.send("GET",j,Le,void 0,Ae);case 3:return at.abrupt("return",at.sent);case 4:case"end":return at.stop()}},Z,this)}));function R(Z,j,Le){return O.apply(this,arguments)}return R}()},{key:"post",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("POST",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"put",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("PUT",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"delete",value:function(){var O=ze.default(ne.default.mark(function Z(j,Le,Ae,Ve){return ne.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Tt.next=3,this.upstream.send("DELETE",j,Le,Ae,Ve);case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},Z,this)}));function R(Z,j,Le,Ae){return O.apply(this,arguments)}return R}()},{key:"addTelemetryEvent",value:function(R){this.telemetryTracker.addTelemetryEvent(R),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(R,Z,j){this.telemetryTracker.addPartialEvent(R,Z,j),j===t.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),I}(Ee.ReplayEventEmitter),t.TwilsockClient=Xe([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Ct("design:paramtypes",[String,String,Object])],t.TwilsockClient);var js=function(){function te(ue){oe.default(this,te),this.product=ue,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return re.default(te,[{key:"populateInitRegistrations",value:function(I){var O=new Set(this.message_types);for(var R in I)O.add(I[R]);this.message_types=Array.from(O)}}]),te}();t.InitRegistration=js,t.TelemetryEventDescription=Pn,t.TelemetryTracker=Dr,t.TransportUnavailableError=en,t.Twilsock=t.TwilsockClient,t.TwilsockError=ae})(Qy);var yI={},bI=Ar,tee=Kt,ree=Er,nee=Vt,Vb=Bc,iee=jc,aee=Oc,see=yn,oee=Pc,rl=Object.assign,wI=Object.defineProperty,uee=tee([].concat),_I=!rl||nee(function(){if(bI&&rl({b:1},rl(wI({},"a",{enumerable:!0,get:function(){wI(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var t={},e={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return t[r]=7,n.split("").forEach(function(i){e[i]=i}),rl({},t)[r]!==7||Vb(rl({},e)).join("")!==n})?function(e,r){for(var n=see(e),i=arguments.length,a=1,s=iee.f,o=aee.f;i>a;)for(var u=oee(arguments[a++]),l=s?uee(Vb(u),s(u)):Vb(u),c=l.length,d=0,f;c>d;)f=l[d++],(!bI||ree(o,u,f))&&(n[f]=u[f]);return n}:rl,lee=er,kI=_I;lee({target:"Object",stat:!0,arity:2,forced:Object.assign!==kI},{assign:kI});/*
930
930
  @license
931
931
  The MIT License (MIT)
932
932
 
@@ -950,7 +950,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
950
950
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
951
951
  SOFTWARE.
952
952
 
953
- */(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Pu,r=aa,n=Aa,i=na,a=ia,s=li,o=zu,u=ui,l=Qy,c=gs,d=ys,f=sa,m=od,b=ud,A=Hu,N=hd,z=nn;function X(Re){return Re&&typeof Re=="object"&&"default"in Re?Re:{default:Re}}function Ee(Re){if(Re&&Re.__esModule)return Re;var Ne=Object.create(null);return Re&&Object.keys(Re).forEach(function(pe){if(pe!=="default"){var $e=Object.getOwnPropertyDescriptor(Re,pe);Object.defineProperty(Ne,pe,$e.get?$e:{enumerable:!0,get:function(){return Re[pe]}})}}),Ne.default=Re,Object.freeze(Ne)}var Ie=X(e),Be=X(r),Oe=X(n),ze=X(i),V=X(a),xe=X(s),_e=X(o),se=X(u),Te=X(c),re=X(d),oe=X(m),q=X(b),ne=Ee(A),Se=Ee(N);function H(Re,Ne,pe,$e){var ae=arguments.length,me=ae<3?Ne:$e===null?$e=Object.getOwnPropertyDescriptor(Ne,pe):$e,we;if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")me=Reflect.decorate(Re,Ne,pe,$e);else for(var K=Re.length-1;K>=0;K--)(we=Re[K])&&(me=(ae<3?we(me):ae>3?we(Ne,pe,me):we(Ne,pe))||me);return ae>3&&me&&Object.defineProperty(Ne,pe,me),me}function ye(Re,Ne){if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Re,Ne)}var ke;function M(){}M.prototype=Object.create(null);function Xe(){Xe.init.call(this)}Xe.EventEmitter=Xe,Xe.usingDomains=!1,Xe.prototype.domain=void 0,Xe.prototype._events=void 0,Xe.prototype._maxListeners=void 0,Xe.defaultMaxListeners=10,Xe.init=function(){this.domain=null,Xe.usingDomains&&ke.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new M,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Xe.prototype.setMaxListeners=function(Ne){if(typeof Ne!="number"||Ne<0||isNaN(Ne))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=Ne,this};function Ct(Re){return Re._maxListeners===void 0?Xe.defaultMaxListeners:Re._maxListeners}Xe.prototype.getMaxListeners=function(){return Ct(this)};function rt(Re,Ne,pe){if(Ne)Re.call(pe);else for(var $e=Re.length,ae=Q(Re,$e),me=0;me<$e;++me)ae[me].call(pe)}function je(Re,Ne,pe,$e){if(Ne)Re.call(pe,$e);else for(var ae=Re.length,me=Q(Re,ae),we=0;we<ae;++we)me[we].call(pe,$e)}function ce(Re,Ne,pe,$e,ae){if(Ne)Re.call(pe,$e,ae);else for(var me=Re.length,we=Q(Re,me),K=0;K<me;++K)we[K].call(pe,$e,ae)}function Ke(Re,Ne,pe,$e,ae,me){if(Ne)Re.call(pe,$e,ae,me);else for(var we=Re.length,K=Q(Re,we),he=0;he<we;++he)K[he].call(pe,$e,ae,me)}function Fe(Re,Ne,pe,$e){if(Ne)Re.apply(pe,$e);else for(var ae=Re.length,me=Q(Re,ae),we=0;we<ae;++we)me[we].apply(pe,$e)}Xe.prototype.emit=function(Ne){var pe,$e,ae,me,we,K,he,G=Ne==="error";if(K=this._events,K)G=G&&K.error==null;else if(!G)return!1;if(he=this.domain,G){if(pe=arguments[1],he)pe||(pe=new Error('Uncaught, unspecified "error" event')),pe.domainEmitter=this,pe.domain=he,pe.domainThrown=!1,he.emit("error",pe);else{if(pe instanceof Error)throw pe;var de=new Error('Uncaught, unspecified "error" event. ('+pe+")");throw de.context=pe,de}return!1}if($e=K[Ne],!$e)return!1;var ee=typeof $e=="function";switch(ae=arguments.length,ae){case 1:rt($e,ee,this);break;case 2:je($e,ee,this,arguments[1]);break;case 3:ce($e,ee,this,arguments[1],arguments[2]);break;case 4:Ke($e,ee,this,arguments[1],arguments[2],arguments[3]);break;default:for(me=new Array(ae-1),we=1;we<ae;we++)me[we-1]=arguments[we];Fe($e,ee,this,me)}return!0};function be(Re,Ne,pe,$e){var ae,me,we;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(me=Re._events,me?(me.newListener&&(Re.emit("newListener",Ne,pe.listener?pe.listener:pe),me=Re._events),we=me[Ne]):(me=Re._events=new M,Re._eventsCount=0),!we)we=me[Ne]=pe,++Re._eventsCount;else if(typeof we=="function"?we=me[Ne]=$e?[pe,we]:[we,pe]:$e?we.unshift(pe):we.push(pe),!we.warned&&(ae=Ct(Re),ae&&ae>0&&we.length>ae)){we.warned=!0;var K=new Error("Possible EventEmitter memory leak detected. "+we.length+" "+Ne+" listeners added. Use emitter.setMaxListeners() to increase limit");K.name="MaxListenersExceededWarning",K.emitter=Re,K.type=Ne,K.count=we.length,pt(K)}return Re}function pt(Re){typeof console.warn=="function"?console.warn(Re):console.log(Re)}Xe.prototype.addListener=function(Ne,pe){return be(this,Ne,pe,!1)},Xe.prototype.on=Xe.prototype.addListener,Xe.prototype.prependListener=function(Ne,pe){return be(this,Ne,pe,!0)};function Ze(Re,Ne,pe){var $e=!1;function ae(){Re.removeListener(Ne,ae),$e||($e=!0,pe.apply(Re,arguments))}return ae.listener=pe,ae}Xe.prototype.once=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.on(Ne,Ze(this,Ne,pe)),this},Xe.prototype.prependOnceListener=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(Ne,Ze(this,Ne,pe)),this},Xe.prototype.removeListener=function(Ne,pe){var $e,ae,me,we,K;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(ae=this._events,!ae)return this;if($e=ae[Ne],!$e)return this;if($e===pe||$e.listener&&$e.listener===pe)--this._eventsCount===0?this._events=new M:(delete ae[Ne],ae.removeListener&&this.emit("removeListener",Ne,$e.listener||pe));else if(typeof $e!="function"){for(me=-1,we=$e.length;we-- >0;)if($e[we]===pe||$e[we].listener&&$e[we].listener===pe){K=$e[we].listener,me=we;break}if(me<0)return this;if($e.length===1){if($e[0]=void 0,--this._eventsCount===0)return this._events=new M,this;delete ae[Ne]}else At($e,me);ae.removeListener&&this.emit("removeListener",Ne,K||pe)}return this},Xe.prototype.off=function(Re,Ne){return this.removeListener(Re,Ne)},Xe.prototype.removeAllListeners=function(Ne){var pe,$e;if($e=this._events,!$e)return this;if(!$e.removeListener)return arguments.length===0?(this._events=new M,this._eventsCount=0):$e[Ne]&&(--this._eventsCount===0?this._events=new M:delete $e[Ne]),this;if(arguments.length===0){for(var ae=Object.keys($e),me=0,we;me<ae.length;++me)we=ae[me],we!=="removeListener"&&this.removeAllListeners(we);return this.removeAllListeners("removeListener"),this._events=new M,this._eventsCount=0,this}if(pe=$e[Ne],typeof pe=="function")this.removeListener(Ne,pe);else if(pe)do this.removeListener(Ne,pe[pe.length-1]);while(pe[0]);return this},Xe.prototype.listeners=function(Ne){var pe,$e,ae=this._events;return ae?(pe=ae[Ne],pe?typeof pe=="function"?$e=[pe.listener||pe]:$e=Ue(pe):$e=[]):$e=[],$e},Xe.listenerCount=function(Re,Ne){return typeof Re.listenerCount=="function"?Re.listenerCount(Ne):Jt.call(Re,Ne)},Xe.prototype.listenerCount=Jt;function Jt(Re){var Ne=this._events;if(Ne){var pe=Ne[Re];if(typeof pe=="function")return 1;if(pe)return pe.length}return 0}Xe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function At(Re,Ne){for(var pe=Ne,$e=pe+1,ae=Re.length;$e<ae;pe+=1,$e+=1)Re[pe]=Re[$e];Re.pop()}function Q(Re,Ne){for(var pe=new Array(Ne);Ne--;)pe[Ne]=Re[Ne];return pe}function Ue(Re){for(var Ne=new Array(Re.length),pe=0;pe<Ne.length;++pe)Ne[pe]=Re[pe].listener||Re[pe];return Ne}var ot=ne.getLogger("twilio-notificatiions");function Pe(Re,Ne){return["".concat(new Date().toISOString()," Twilio.Notifications ").concat(Re,":")].concat(Array.from(Ne))}var St=function(){function Re(){Be.default(this,Re)}return Oe.default(Re,[{key:"setLevel",value:function(pe){ot.setLevel(pe)}},{key:"trace",value:function(){if(ot.getLevel()==ot.levels.TRACE){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.debug.apply(null,Pe("T",$e))}}},{key:"debug",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.debug.apply(null,Pe("D",$e))}},{key:"info",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.info.apply(null,Pe("I",$e))}},{key:"warn",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.warn.apply(null,Pe("W",$e))}},{key:"error",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.error.apply(null,Pe("E",$e))}}]),Re}(),ut=new St;function or(Re){var Ne=br();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function br(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var et=Oe.default(function Re(){var Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",$e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;Be.default(this,Re),this.token=Ne,this.notificationId=pe,this.messageTypes=$e});function Mr(Re,Ne){return[].concat(q.default(q.default(Re).filter(function(pe){return!Ne.has(pe)})),q.default(q.default(Ne).filter(function(pe){return!Re.has(pe)})))}function Fr(Re,Ne){var pe=new Set;return Re.notificationId!==Ne.notificationId&&pe.add("notificationId"),Re.token!==Ne.token&&pe.add("token"),Mr(Re.messageTypes,Ne.messageTypes).length>0&&pe.add("messageType"),[pe.size>0,pe]}var dr=function(Re){ze.default(pe,Re);var Ne=or(pe);function pe($e){var ae;return Be.default(this,pe),ae=Ne.call(this),re.default(Te.default(ae),"desiredState",new et),re.default(Te.default(ae),"currentState",new et),re.default(Te.default(ae),"_hasActiveAttempt",!1),ae.channelType=$e,ae}return Oe.default(pe,[{key:"setNotificationId",value:function(ae){this.desiredState.notificationId=ae}},{key:"isActive",value:function(){return this.desiredState.notificationId!==""}},{key:"subscribe",value:function(ae){if(this.desiredState.messageTypes.has(ae)){ut.debug("message type '".concat(ae,"' for channel ").concat(this.channelType," is already registered"));return}this.desiredState.messageTypes.add(ae)}},{key:"unsubscribe",value:function(ae){this.desiredState.messageTypes.has(ae)&&this.desiredState.messageTypes.delete(ae)}},{key:"updateToken",value:function(ae){this.desiredState.token=ae}},{key:"commitChanges",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we,K,he,G,de,ee;return _e.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:if(!this._hasActiveAttempt){qe.next=3;break}throw ut.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(we=Fr(this.desiredState,this.currentState),K=oe.default(we,2),he=K[0],G=K[1],he){qe.next=6;break}return qe.abrupt("return");case 6:if(this.currentState.notificationId||G.delete("notificationId"),ut.trace("Persisting ".concat(this.channelType," registration"),G,this.desiredState),qe.prev=8,this._hasActiveAttempt=!0,de=new et,de.token=this.desiredState.token,de.notificationId=this.desiredState.notificationId,de.messageTypes=new Set(this.desiredState.messageTypes),!(de.messageTypes.size>0)){qe.next=24;break}return qe.next=17,this.updateRegistration(de,G);case 17:ee=qe.sent,this.currentState.token=ee.token,this.currentState.notificationId=ee.notificationId,this.currentState.messageTypes=new Set(ee.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),qe.next=30;break;case 24:return qe.next=26,this.removeRegistration();case 26:this.currentState.token=de.token,this.currentState.notificationId=de.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:qe.next=35;break;case 32:throw qe.prev=32,qe.t0=qe.catch(8),qe.t0;case 35:return qe.prev=35,this._hasActiveAttempt=!1,qe.finish(35);case 38:case"end":return qe.stop()}},me,this,[[8,32,35,38]])}));function ae(){return $e.apply(this,arguments)}return ae}()}]),pe}(Xe);function fr(Re){var Ne=Wt();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot={min:2e3,max:12e4,randomness:.2},L=function(Re){ze.default(pe,Re);var Ne=fr(pe);function pe($e,ae,me,we){var K;return Be.default(this,pe),K=Ne.call(this,$e),re.default(Te.default(K),"registrationId",null),K.context=ae,K.twilsock=me,K.registrarUrl=we,K}return Oe.default(pe,[{key:"updateRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){var he=this,G,de,ee,Ye,qe;return _e.default.wrap(function(lt){for(;;)switch(lt.prev=lt.next){case 0:if(!K.has("notificationId")){lt.next=3;break}return lt.next=3,this.removeRegistration();case 3:if(!(!we.notificationId||!we.notificationId.length)){lt.next=6;break}throw ut.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return ut.trace("Registering",this.channelType,we),G={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(we.messageTypes),data:{registration_id:we.notificationId}},de=this.context.productId,ee="".concat(this.registrarUrl,"?productId=").concat(de),Ye={"Content-Type":"application/json"},ut.trace("Creating registration for channel ".concat(this.channelType)),lt.prev=12,lt.next=15,new f.AsyncRetrier(Ot).run(function(){return he.twilsock.post(ee,Ye,G,de)});case 15:qe=lt.sent,this.registrationId=qe.body.id,ut.debug("Registration created: ",qe),lt.next=24;break;case 20:throw lt.prev=20,lt.t0=lt.catch(12),ut.error("Registration failed: ",lt.t0),lt.t0;case 24:return lt.abrupt("return",we);case 25:case"end":return lt.stop()}},me,this,[[12,20]])}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we=this,K,he,G;return _e.default.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(this.registrationId){ee.next=2;break}return ee.abrupt("return");case 2:return K=this.context.productId,he="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(K),G={"Content-Type":"application/json"},ut.trace("Removing registration for ".concat(this.channelType)),ee.prev=6,ee.next=9,new f.AsyncRetrier(Object.assign(Ot,{maxAttemptsCount:3})).run(function(){return we.twilsock.delete(he,G,{},K)});case 9:this.registrationId=null,this.currentState.notificationId="",ut.debug("Registration removed for ".concat(this.channelType)),ee.next=18;break;case 14:throw ee.prev=14,ee.t0=ee.catch(6),ut.error("Failed to remove registration ",this.channelType,ee.t0),ee.t0;case 18:case"end":return ee.stop()}},me,this,[[6,14]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Ie.default(_e.default.mark(function me(we){var K=this,he,G,de,ee;return _e.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:if(we!==""){qe.next=2;break}throw new Error("Empty registration ID");case 2:return he=this.context.productId,G="".concat(this.registrarUrl,"?productId=").concat(he),de={"Content-Type":"application/json"},ee={binding_type:this.channelType,address:we},qe.prev=6,ut.trace("Removing old registrations for ".concat(this.channelType)),qe.next=10,new f.AsyncRetrier(Object.assign(Ot,{maxAttemptsCount:3})).run(function(){return K.twilsock.delete(G,de,ee,he)});case 10:this.registrationId=null,this.currentState.notificationId="",ut.debug("Registration removed for ".concat(this.channelType)),qe.next=19;break;case 15:throw qe.prev=15,qe.t0=qe.catch(6),ut.error("Failed to remove registration ",this.channelType,qe.t0),qe.t0;case 19:case"end":return qe.stop()}},me,this,[[6,15]])}));function ae(me){return $e.apply(this,arguments)}return ae}()}]),pe}(dr);function W(Re){var Ne=ie();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function ie(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var He=function(Re){ze.default(pe,Re);var Ne=W(pe);function pe($e,ae,me){var we;return Be.default(this,pe),we=Ne.call(this,"twilsock"),re.default(Te.default(we),"contextId",Se.v4()),we.productId=$e,we.platform=ae,we.twilsock=me,we}return Oe.default(pe,[{key:"updateRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){var he,G;return _e.default.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(K.has("messageType")){ee.next=2;break}return ee.abrupt("return",we);case 2:return he=Array.from(we.messageTypes),G={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:he},ee.prev=4,ee.next=7,this.twilsock.setNotificationsContext(this.contextId,G);case 7:ee.next=13;break;case 9:throw ee.prev=9,ee.t0=ee.catch(4),ut.error("Failed to update twilsock notification context: ".concat(ee.t0)),ee.t0;case 13:return ee.abrupt("return",we);case 14:case"end":return ee.stop()}},me,this,[[4,9]])}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return K.prev=0,K.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:K.next=9;break;case 5:throw K.prev=5,K.t0=K.catch(0),ut.error("Failed to remove twilsock notification context: ".concat(K.t0)),K.t0;case 9:case"end":return K.stop()}},me,this,[[0,5]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Ie.default(_e.default.mark(function me(we){return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:case"end":return he.stop()}},me)}));function ae(me){return $e.apply(this,arguments)}return ae}()}]),pe}(dr);function ct(Re){var Ne=bt();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function bt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var zt,tr=z.literal("apn","fcm","twilsock");t.Notifications=zt=function(Re){ze.default(pe,Re);var Ne=ct(pe);function pe($e){var ae,me,we,K,he,G,de,ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Be.default(this,pe),de=Ne.call(this),ee.logLevel=(ae=ee.logLevel)!==null&&ae!==void 0?ae:"error",ut.setLevel(ee.logLevel);var Ye=(me=ee.productId)!==null&&me!==void 0?me:"notifications",qe=!ee.twilsockClient,dt=ee.twilsockClient=(we=ee.twilsockClient)!==null&&we!==void 0?we:new l.TwilsockClient($e,Ye,ee),lt=(K=ee.notifications)!==null&&K!==void 0?K:{},ht=(he=(G=lt.region)!==null&&G!==void 0?G:ee.region)!==null&&he!==void 0?he:"us1",Rt="https://ers.".concat(ht,".twilio.com/v1/registrations"),xt=lt.ersUrl||Rt;de.connectors=new Map;var kt=zt._detectPlatform();return de.connectors.set("apn",new L("apn",{protocolVersion:4,productId:Ye,platform:kt},dt,xt)),de.connectors.set("fcm",new L("fcm",{protocolVersion:3,productId:Ye,platform:kt},dt,xt)),de.connectors.set("twilsock",new He(Ye,kt,dt)),dt.on("stateChanged",function($t){return de.emit("transportState",$t)}),de._connector("twilsock").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),de._connector("apn").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),de._connector("fcm").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),dt.on("message",function($t,It){return de._routeMessage($t,It)}),de.updateToken($e),qe&&(dt.connect(),de.twilsock=dt),de}return Oe.default(pe,[{key:"shutdown",value:function(){var $e=Ie.default(_e.default.mark(function me(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.connectors.clear(),!this.twilsock){K.next=4;break}return K.next=4,this.twilsock.disconnect();case 4:case"end":return K.stop()}},me,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"setPushRegistrationId",value:function(ae,me){ut.debug("Set ".concat(ae," push registration id '").concat(me,"'")),this._connector(ae).setNotificationId(me)}},{key:"subscribe",value:function(ae,me){ut.debug("Add ".concat(ae," subscriptions for message type ").concat(me)),this._connector(ae).subscribe(me)}},{key:"unsubscribe",value:function(ae,me){ut.debug("Remove ".concat(ae," subscriptions for message type ").concat(me)),this._connector(ae).unsubscribe(me)}},{key:"updateToken",value:function(ae){this.connectors.forEach(function(me){return me.updateToken(ae)})}},{key:"commitChanges",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we;return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:return we=[],this.connectors.forEach(function(G){G.isActive()&&we.push(G.commitChanges())}),he.next=4,Promise.all(we);case 4:case"end":return he.stop()}},me,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistrations",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){return _e.default.wrap(function(G){for(;;)switch(G.prev=G.next){case 0:return G.next=2,this._connector(we).sendDeviceRemoveRequest(K);case 2:case"end":return G.stop()}},me,this)}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"handlePushNotification",value:function(ae){return{messageType:ae.twi_message_type,payload:ae.payload}}},{key:"_routeMessage",value:function(ae,me){ut.debug("Notification message arrived: ",ae,me),this.emit("message",ae,me)}},{key:"_connector",value:function(ae){var me=this.connectors.get(ae);if(!me)throw new Error("Unknown channel type: ".concat(ae));return me}}],[{key:"_detectPlatform",value:function(){var ae="";return typeof navigator<"u"?(ae="unknown",typeof navigator.product<"u"&&(ae=navigator.product),typeof navigator.userAgent<"u"&&(ae=navigator.userAgent)):ae="web",ae.substring(0,128)}}]),pe}(Xe),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"setPushRegistrationId",null),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"subscribe",null),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"unsubscribe",null),H([z.validateTypes(z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String]),ye("design:returntype",void 0)],t.Notifications.prototype,"updateToken",null),H([z.validateTypesAsync(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",Promise)],t.Notifications.prototype,"removeRegistrations",null),t.Notifications=zt=H([z.validateConstructorTypes(z.nonEmptyString,[z.pureObject,"undefined",z.literal(null)]),ye("design:paramtypes",[String,Object])],t.Notifications)})(yI);var zn={},wn={};/*
953
+ */(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Pu,r=aa,n=Aa,i=na,a=ia,s=li,o=zu,u=ui,l=Qy,c=gs,d=ys,f=sa,m=od,b=ud,A=Hu,N=hd,z=nn;function X(Re){return Re&&typeof Re=="object"&&"default"in Re?Re:{default:Re}}function Ee(Re){if(Re&&Re.__esModule)return Re;var Ne=Object.create(null);return Re&&Object.keys(Re).forEach(function(pe){if(pe!=="default"){var $e=Object.getOwnPropertyDescriptor(Re,pe);Object.defineProperty(Ne,pe,$e.get?$e:{enumerable:!0,get:function(){return Re[pe]}})}}),Ne.default=Re,Object.freeze(Ne)}var Ie=X(e),Fe=X(r),Oe=X(n),ze=X(i),V=X(a),xe=X(s),_e=X(o),se=X(u),Te=X(c),re=X(d),oe=X(m),q=X(b),ne=Ee(A),Se=Ee(N);function H(Re,Ne,pe,$e){var ae=arguments.length,me=ae<3?Ne:$e===null?$e=Object.getOwnPropertyDescriptor(Ne,pe):$e,we;if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")me=Reflect.decorate(Re,Ne,pe,$e);else for(var K=Re.length-1;K>=0;K--)(we=Re[K])&&(me=(ae<3?we(me):ae>3?we(Ne,pe,me):we(Ne,pe))||me);return ae>3&&me&&Object.defineProperty(Ne,pe,me),me}function ye(Re,Ne){if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Re,Ne)}var ke;function M(){}M.prototype=Object.create(null);function Xe(){Xe.init.call(this)}Xe.EventEmitter=Xe,Xe.usingDomains=!1,Xe.prototype.domain=void 0,Xe.prototype._events=void 0,Xe.prototype._maxListeners=void 0,Xe.defaultMaxListeners=10,Xe.init=function(){this.domain=null,Xe.usingDomains&&ke.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new M,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Xe.prototype.setMaxListeners=function(Ne){if(typeof Ne!="number"||Ne<0||isNaN(Ne))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=Ne,this};function Ct(Re){return Re._maxListeners===void 0?Xe.defaultMaxListeners:Re._maxListeners}Xe.prototype.getMaxListeners=function(){return Ct(this)};function rt(Re,Ne,pe){if(Ne)Re.call(pe);else for(var $e=Re.length,ae=Q(Re,$e),me=0;me<$e;++me)ae[me].call(pe)}function je(Re,Ne,pe,$e){if(Ne)Re.call(pe,$e);else for(var ae=Re.length,me=Q(Re,ae),we=0;we<ae;++we)me[we].call(pe,$e)}function ce(Re,Ne,pe,$e,ae){if(Ne)Re.call(pe,$e,ae);else for(var me=Re.length,we=Q(Re,me),K=0;K<me;++K)we[K].call(pe,$e,ae)}function Ke(Re,Ne,pe,$e,ae,me){if(Ne)Re.call(pe,$e,ae,me);else for(var we=Re.length,K=Q(Re,we),he=0;he<we;++he)K[he].call(pe,$e,ae,me)}function Be(Re,Ne,pe,$e){if(Ne)Re.apply(pe,$e);else for(var ae=Re.length,me=Q(Re,ae),we=0;we<ae;++we)me[we].apply(pe,$e)}Xe.prototype.emit=function(Ne){var pe,$e,ae,me,we,K,he,G=Ne==="error";if(K=this._events,K)G=G&&K.error==null;else if(!G)return!1;if(he=this.domain,G){if(pe=arguments[1],he)pe||(pe=new Error('Uncaught, unspecified "error" event')),pe.domainEmitter=this,pe.domain=he,pe.domainThrown=!1,he.emit("error",pe);else{if(pe instanceof Error)throw pe;var de=new Error('Uncaught, unspecified "error" event. ('+pe+")");throw de.context=pe,de}return!1}if($e=K[Ne],!$e)return!1;var ee=typeof $e=="function";switch(ae=arguments.length,ae){case 1:rt($e,ee,this);break;case 2:je($e,ee,this,arguments[1]);break;case 3:ce($e,ee,this,arguments[1],arguments[2]);break;case 4:Ke($e,ee,this,arguments[1],arguments[2],arguments[3]);break;default:for(me=new Array(ae-1),we=1;we<ae;we++)me[we-1]=arguments[we];Be($e,ee,this,me)}return!0};function be(Re,Ne,pe,$e){var ae,me,we;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(me=Re._events,me?(me.newListener&&(Re.emit("newListener",Ne,pe.listener?pe.listener:pe),me=Re._events),we=me[Ne]):(me=Re._events=new M,Re._eventsCount=0),!we)we=me[Ne]=pe,++Re._eventsCount;else if(typeof we=="function"?we=me[Ne]=$e?[pe,we]:[we,pe]:$e?we.unshift(pe):we.push(pe),!we.warned&&(ae=Ct(Re),ae&&ae>0&&we.length>ae)){we.warned=!0;var K=new Error("Possible EventEmitter memory leak detected. "+we.length+" "+Ne+" listeners added. Use emitter.setMaxListeners() to increase limit");K.name="MaxListenersExceededWarning",K.emitter=Re,K.type=Ne,K.count=we.length,pt(K)}return Re}function pt(Re){typeof console.warn=="function"?console.warn(Re):console.log(Re)}Xe.prototype.addListener=function(Ne,pe){return be(this,Ne,pe,!1)},Xe.prototype.on=Xe.prototype.addListener,Xe.prototype.prependListener=function(Ne,pe){return be(this,Ne,pe,!0)};function Ze(Re,Ne,pe){var $e=!1;function ae(){Re.removeListener(Ne,ae),$e||($e=!0,pe.apply(Re,arguments))}return ae.listener=pe,ae}Xe.prototype.once=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.on(Ne,Ze(this,Ne,pe)),this},Xe.prototype.prependOnceListener=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(Ne,Ze(this,Ne,pe)),this},Xe.prototype.removeListener=function(Ne,pe){var $e,ae,me,we,K;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(ae=this._events,!ae)return this;if($e=ae[Ne],!$e)return this;if($e===pe||$e.listener&&$e.listener===pe)--this._eventsCount===0?this._events=new M:(delete ae[Ne],ae.removeListener&&this.emit("removeListener",Ne,$e.listener||pe));else if(typeof $e!="function"){for(me=-1,we=$e.length;we-- >0;)if($e[we]===pe||$e[we].listener&&$e[we].listener===pe){K=$e[we].listener,me=we;break}if(me<0)return this;if($e.length===1){if($e[0]=void 0,--this._eventsCount===0)return this._events=new M,this;delete ae[Ne]}else At($e,me);ae.removeListener&&this.emit("removeListener",Ne,K||pe)}return this},Xe.prototype.off=function(Re,Ne){return this.removeListener(Re,Ne)},Xe.prototype.removeAllListeners=function(Ne){var pe,$e;if($e=this._events,!$e)return this;if(!$e.removeListener)return arguments.length===0?(this._events=new M,this._eventsCount=0):$e[Ne]&&(--this._eventsCount===0?this._events=new M:delete $e[Ne]),this;if(arguments.length===0){for(var ae=Object.keys($e),me=0,we;me<ae.length;++me)we=ae[me],we!=="removeListener"&&this.removeAllListeners(we);return this.removeAllListeners("removeListener"),this._events=new M,this._eventsCount=0,this}if(pe=$e[Ne],typeof pe=="function")this.removeListener(Ne,pe);else if(pe)do this.removeListener(Ne,pe[pe.length-1]);while(pe[0]);return this},Xe.prototype.listeners=function(Ne){var pe,$e,ae=this._events;return ae?(pe=ae[Ne],pe?typeof pe=="function"?$e=[pe.listener||pe]:$e=Ue(pe):$e=[]):$e=[],$e},Xe.listenerCount=function(Re,Ne){return typeof Re.listenerCount=="function"?Re.listenerCount(Ne):Jt.call(Re,Ne)},Xe.prototype.listenerCount=Jt;function Jt(Re){var Ne=this._events;if(Ne){var pe=Ne[Re];if(typeof pe=="function")return 1;if(pe)return pe.length}return 0}Xe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function At(Re,Ne){for(var pe=Ne,$e=pe+1,ae=Re.length;$e<ae;pe+=1,$e+=1)Re[pe]=Re[$e];Re.pop()}function Q(Re,Ne){for(var pe=new Array(Ne);Ne--;)pe[Ne]=Re[Ne];return pe}function Ue(Re){for(var Ne=new Array(Re.length),pe=0;pe<Ne.length;++pe)Ne[pe]=Re[pe].listener||Re[pe];return Ne}var ot=ne.getLogger("twilio-notificatiions");function Pe(Re,Ne){return["".concat(new Date().toISOString()," Twilio.Notifications ").concat(Re,":")].concat(Array.from(Ne))}var St=function(){function Re(){Fe.default(this,Re)}return Oe.default(Re,[{key:"setLevel",value:function(pe){ot.setLevel(pe)}},{key:"trace",value:function(){if(ot.getLevel()==ot.levels.TRACE){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.debug.apply(null,Pe("T",$e))}}},{key:"debug",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.debug.apply(null,Pe("D",$e))}},{key:"info",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.info.apply(null,Pe("I",$e))}},{key:"warn",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.warn.apply(null,Pe("W",$e))}},{key:"error",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];ot.error.apply(null,Pe("E",$e))}}]),Re}(),ut=new St;function or(Re){var Ne=br();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function br(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var et=Oe.default(function Re(){var Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",$e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;Fe.default(this,Re),this.token=Ne,this.notificationId=pe,this.messageTypes=$e});function Mr(Re,Ne){return[].concat(q.default(q.default(Re).filter(function(pe){return!Ne.has(pe)})),q.default(q.default(Ne).filter(function(pe){return!Re.has(pe)})))}function Fr(Re,Ne){var pe=new Set;return Re.notificationId!==Ne.notificationId&&pe.add("notificationId"),Re.token!==Ne.token&&pe.add("token"),Mr(Re.messageTypes,Ne.messageTypes).length>0&&pe.add("messageType"),[pe.size>0,pe]}var dr=function(Re){ze.default(pe,Re);var Ne=or(pe);function pe($e){var ae;return Fe.default(this,pe),ae=Ne.call(this),re.default(Te.default(ae),"desiredState",new et),re.default(Te.default(ae),"currentState",new et),re.default(Te.default(ae),"_hasActiveAttempt",!1),ae.channelType=$e,ae}return Oe.default(pe,[{key:"setNotificationId",value:function(ae){this.desiredState.notificationId=ae}},{key:"isActive",value:function(){return this.desiredState.notificationId!==""}},{key:"subscribe",value:function(ae){if(this.desiredState.messageTypes.has(ae)){ut.debug("message type '".concat(ae,"' for channel ").concat(this.channelType," is already registered"));return}this.desiredState.messageTypes.add(ae)}},{key:"unsubscribe",value:function(ae){this.desiredState.messageTypes.has(ae)&&this.desiredState.messageTypes.delete(ae)}},{key:"updateToken",value:function(ae){this.desiredState.token=ae}},{key:"commitChanges",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we,K,he,G,de,ee;return _e.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:if(!this._hasActiveAttempt){qe.next=3;break}throw ut.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(we=Fr(this.desiredState,this.currentState),K=oe.default(we,2),he=K[0],G=K[1],he){qe.next=6;break}return qe.abrupt("return");case 6:if(this.currentState.notificationId||G.delete("notificationId"),ut.trace("Persisting ".concat(this.channelType," registration"),G,this.desiredState),qe.prev=8,this._hasActiveAttempt=!0,de=new et,de.token=this.desiredState.token,de.notificationId=this.desiredState.notificationId,de.messageTypes=new Set(this.desiredState.messageTypes),!(de.messageTypes.size>0)){qe.next=24;break}return qe.next=17,this.updateRegistration(de,G);case 17:ee=qe.sent,this.currentState.token=ee.token,this.currentState.notificationId=ee.notificationId,this.currentState.messageTypes=new Set(ee.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),qe.next=30;break;case 24:return qe.next=26,this.removeRegistration();case 26:this.currentState.token=de.token,this.currentState.notificationId=de.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:qe.next=35;break;case 32:throw qe.prev=32,qe.t0=qe.catch(8),qe.t0;case 35:return qe.prev=35,this._hasActiveAttempt=!1,qe.finish(35);case 38:case"end":return qe.stop()}},me,this,[[8,32,35,38]])}));function ae(){return $e.apply(this,arguments)}return ae}()}]),pe}(Xe);function fr(Re){var Ne=Wt();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot={min:2e3,max:12e4,randomness:.2},L=function(Re){ze.default(pe,Re);var Ne=fr(pe);function pe($e,ae,me,we){var K;return Fe.default(this,pe),K=Ne.call(this,$e),re.default(Te.default(K),"registrationId",null),K.context=ae,K.twilsock=me,K.registrarUrl=we,K}return Oe.default(pe,[{key:"updateRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){var he=this,G,de,ee,Ye,qe;return _e.default.wrap(function(lt){for(;;)switch(lt.prev=lt.next){case 0:if(!K.has("notificationId")){lt.next=3;break}return lt.next=3,this.removeRegistration();case 3:if(!(!we.notificationId||!we.notificationId.length)){lt.next=6;break}throw ut.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return ut.trace("Registering",this.channelType,we),G={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(we.messageTypes),data:{registration_id:we.notificationId}},de=this.context.productId,ee="".concat(this.registrarUrl,"?productId=").concat(de),Ye={"Content-Type":"application/json"},ut.trace("Creating registration for channel ".concat(this.channelType)),lt.prev=12,lt.next=15,new f.AsyncRetrier(Ot).run(function(){return he.twilsock.post(ee,Ye,G,de)});case 15:qe=lt.sent,this.registrationId=qe.body.id,ut.debug("Registration created: ",qe),lt.next=24;break;case 20:throw lt.prev=20,lt.t0=lt.catch(12),ut.error("Registration failed: ",lt.t0),lt.t0;case 24:return lt.abrupt("return",we);case 25:case"end":return lt.stop()}},me,this,[[12,20]])}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we=this,K,he,G;return _e.default.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(this.registrationId){ee.next=2;break}return ee.abrupt("return");case 2:return K=this.context.productId,he="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(K),G={"Content-Type":"application/json"},ut.trace("Removing registration for ".concat(this.channelType)),ee.prev=6,ee.next=9,new f.AsyncRetrier(Object.assign(Ot,{maxAttemptsCount:3})).run(function(){return we.twilsock.delete(he,G,{},K)});case 9:this.registrationId=null,this.currentState.notificationId="",ut.debug("Registration removed for ".concat(this.channelType)),ee.next=18;break;case 14:throw ee.prev=14,ee.t0=ee.catch(6),ut.error("Failed to remove registration ",this.channelType,ee.t0),ee.t0;case 18:case"end":return ee.stop()}},me,this,[[6,14]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Ie.default(_e.default.mark(function me(we){var K=this,he,G,de,ee;return _e.default.wrap(function(qe){for(;;)switch(qe.prev=qe.next){case 0:if(we!==""){qe.next=2;break}throw new Error("Empty registration ID");case 2:return he=this.context.productId,G="".concat(this.registrarUrl,"?productId=").concat(he),de={"Content-Type":"application/json"},ee={binding_type:this.channelType,address:we},qe.prev=6,ut.trace("Removing old registrations for ".concat(this.channelType)),qe.next=10,new f.AsyncRetrier(Object.assign(Ot,{maxAttemptsCount:3})).run(function(){return K.twilsock.delete(G,de,ee,he)});case 10:this.registrationId=null,this.currentState.notificationId="",ut.debug("Registration removed for ".concat(this.channelType)),qe.next=19;break;case 15:throw qe.prev=15,qe.t0=qe.catch(6),ut.error("Failed to remove registration ",this.channelType,qe.t0),qe.t0;case 19:case"end":return qe.stop()}},me,this,[[6,15]])}));function ae(me){return $e.apply(this,arguments)}return ae}()}]),pe}(dr);function W(Re){var Ne=ie();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function ie(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var He=function(Re){ze.default(pe,Re);var Ne=W(pe);function pe($e,ae,me){var we;return Fe.default(this,pe),we=Ne.call(this,"twilsock"),re.default(Te.default(we),"contextId",Se.v4()),we.productId=$e,we.platform=ae,we.twilsock=me,we}return Oe.default(pe,[{key:"updateRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){var he,G;return _e.default.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:if(K.has("messageType")){ee.next=2;break}return ee.abrupt("return",we);case 2:return he=Array.from(we.messageTypes),G={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:he},ee.prev=4,ee.next=7,this.twilsock.setNotificationsContext(this.contextId,G);case 7:ee.next=13;break;case 9:throw ee.prev=9,ee.t0=ee.catch(4),ut.error("Failed to update twilsock notification context: ".concat(ee.t0)),ee.t0;case 13:return ee.abrupt("return",we);case 14:case"end":return ee.stop()}},me,this,[[4,9]])}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Ie.default(_e.default.mark(function me(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return K.prev=0,K.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:K.next=9;break;case 5:throw K.prev=5,K.t0=K.catch(0),ut.error("Failed to remove twilsock notification context: ".concat(K.t0)),K.t0;case 9:case"end":return K.stop()}},me,this,[[0,5]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Ie.default(_e.default.mark(function me(we){return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:case"end":return he.stop()}},me)}));function ae(me){return $e.apply(this,arguments)}return ae}()}]),pe}(dr);function ct(Re){var Ne=bt();return function(){var $e=xe.default(Re),ae;if(Ne){var me=xe.default(this).constructor;ae=Reflect.construct($e,arguments,me)}else ae=$e.apply(this,arguments);return V.default(this,ae)}}function bt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var zt,tr=z.literal("apn","fcm","twilsock");t.Notifications=zt=function(Re){ze.default(pe,Re);var Ne=ct(pe);function pe($e){var ae,me,we,K,he,G,de,ee=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Fe.default(this,pe),de=Ne.call(this),ee.logLevel=(ae=ee.logLevel)!==null&&ae!==void 0?ae:"error",ut.setLevel(ee.logLevel);var Ye=(me=ee.productId)!==null&&me!==void 0?me:"notifications",qe=!ee.twilsockClient,dt=ee.twilsockClient=(we=ee.twilsockClient)!==null&&we!==void 0?we:new l.TwilsockClient($e,Ye,ee),lt=(K=ee.notifications)!==null&&K!==void 0?K:{},ht=(he=(G=lt.region)!==null&&G!==void 0?G:ee.region)!==null&&he!==void 0?he:"us1",Rt="https://ers.".concat(ht,".twilio.com/v1/registrations"),xt=lt.ersUrl||Rt;de.connectors=new Map;var kt=zt._detectPlatform();return de.connectors.set("apn",new L("apn",{protocolVersion:4,productId:Ye,platform:kt},dt,xt)),de.connectors.set("fcm",new L("fcm",{protocolVersion:3,productId:Ye,platform:kt},dt,xt)),de.connectors.set("twilsock",new He(Ye,kt,dt)),dt.on("stateChanged",function($t){return de.emit("transportState",$t)}),de._connector("twilsock").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),de._connector("apn").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),de._connector("fcm").on("stateChanged",function($t,It,jt){return de.emit("stateChanged",$t,It,jt)}),dt.on("message",function($t,It){return de._routeMessage($t,It)}),de.updateToken($e),qe&&(dt.connect(),de.twilsock=dt),de}return Oe.default(pe,[{key:"shutdown",value:function(){var $e=Ie.default(_e.default.mark(function me(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.connectors.clear(),!this.twilsock){K.next=4;break}return K.next=4,this.twilsock.disconnect();case 4:case"end":return K.stop()}},me,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"setPushRegistrationId",value:function(ae,me){ut.debug("Set ".concat(ae," push registration id '").concat(me,"'")),this._connector(ae).setNotificationId(me)}},{key:"subscribe",value:function(ae,me){ut.debug("Add ".concat(ae," subscriptions for message type ").concat(me)),this._connector(ae).subscribe(me)}},{key:"unsubscribe",value:function(ae,me){ut.debug("Remove ".concat(ae," subscriptions for message type ").concat(me)),this._connector(ae).unsubscribe(me)}},{key:"updateToken",value:function(ae){this.connectors.forEach(function(me){return me.updateToken(ae)})}},{key:"commitChanges",value:function(){var $e=Ie.default(_e.default.mark(function me(){var we;return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:return we=[],this.connectors.forEach(function(G){G.isActive()&&we.push(G.commitChanges())}),he.next=4,Promise.all(we);case 4:case"end":return he.stop()}},me,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistrations",value:function(){var $e=Ie.default(_e.default.mark(function me(we,K){return _e.default.wrap(function(G){for(;;)switch(G.prev=G.next){case 0:return G.next=2,this._connector(we).sendDeviceRemoveRequest(K);case 2:case"end":return G.stop()}},me,this)}));function ae(me,we){return $e.apply(this,arguments)}return ae}()},{key:"handlePushNotification",value:function(ae){return{messageType:ae.twi_message_type,payload:ae.payload}}},{key:"_routeMessage",value:function(ae,me){ut.debug("Notification message arrived: ",ae,me),this.emit("message",ae,me)}},{key:"_connector",value:function(ae){var me=this.connectors.get(ae);if(!me)throw new Error("Unknown channel type: ".concat(ae));return me}}],[{key:"_detectPlatform",value:function(){var ae="";return typeof navigator<"u"?(ae="unknown",typeof navigator.product<"u"&&(ae=navigator.product),typeof navigator.userAgent<"u"&&(ae=navigator.userAgent)):ae="web",ae.substring(0,128)}}]),pe}(Xe),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"setPushRegistrationId",null),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"subscribe",null),H([z.validateTypes(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"unsubscribe",null),H([z.validateTypes(z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String]),ye("design:returntype",void 0)],t.Notifications.prototype,"updateToken",null),H([z.validateTypesAsync(tr,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",Promise)],t.Notifications.prototype,"removeRegistrations",null),t.Notifications=zt=H([z.validateConstructorTypes(z.nonEmptyString,[z.pureObject,"undefined",z.literal(null)]),ye("design:paramtypes",[String,Object])],t.Notifications)})(yI);var zn={},wn={};/*
954
954
  @license
955
955
  Copyright (c) 2021 Twilio Inc.
956
956
 
@@ -1048,7 +1048,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1048
1048
  OTHER DEALINGS IN THE SOFTWARE.
1049
1049
 
1050
1050
 
1051
- */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Pu,n=Aa,i=gs,a=ep,s=na,o=ia,u=li,l=aa,c=ys,d=zu,f=ui,m=wn,b=Hu,A=YC,N=hd,z=wd,X=sa,Ee=zb;function Ie(D){return D&&typeof D=="object"&&"default"in D?D:{default:D}}function Be(D){if(D&&D.__esModule)return D;var B=Object.create(null);return D&&Object.keys(D).forEach(function(E){if(E!=="default"){var T=Object.getOwnPropertyDescriptor(D,E);Object.defineProperty(B,E,T.get?T:{enumerable:!0,get:function(){return D[E]}})}}),B.default=D,Object.freeze(B)}var Oe=Ie(r),ze=Ie(n),V=Ie(i),xe=Ie(a),_e=Ie(s),se=Ie(o),Te=Ie(u),re=Ie(l),oe=Ie(c),q=Ie(d),ne=Ie(f),Se=Be(b),H=Be(A),ye=Ie(z),ke=Be(Ee);function M(D,B,E,T){var $=arguments.length,U=$<3?B:T===null?T=Object.getOwnPropertyDescriptor(B,E):T,P;if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(D,B,E,T);else for(var Me=D.length-1;Me>=0;Me--)(P=D[Me])&&(U=($<3?P(U):$>3?P(B,E,U):P(B,E))||U);return $>3&&U&&Object.defineProperty(B,E,U),U}function Xe(D,B){if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(D,B)}var Ct;function rt(){}rt.prototype=Object.create(null);function je(){je.init.call(this)}je.EventEmitter=je,je.usingDomains=!1,je.prototype.domain=void 0,je.prototype._events=void 0,je.prototype._maxListeners=void 0,je.defaultMaxListeners=10,je.init=function(){this.domain=null,je.usingDomains&&Ct.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new rt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},je.prototype.setMaxListeners=function(B){if(typeof B!="number"||B<0||isNaN(B))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=B,this};function ce(D){return D._maxListeners===void 0?je.defaultMaxListeners:D._maxListeners}je.prototype.getMaxListeners=function(){return ce(this)};function Ke(D,B,E){if(B)D.call(E);else for(var T=D.length,$=Pe(D,T),U=0;U<T;++U)$[U].call(E)}function Fe(D,B,E,T){if(B)D.call(E,T);else for(var $=D.length,U=Pe(D,$),P=0;P<$;++P)U[P].call(E,T)}function be(D,B,E,T,$){if(B)D.call(E,T,$);else for(var U=D.length,P=Pe(D,U),Me=0;Me<U;++Me)P[Me].call(E,T,$)}function pt(D,B,E,T,$,U){if(B)D.call(E,T,$,U);else for(var P=D.length,Me=Pe(D,P),Ce=0;Ce<P;++Ce)Me[Ce].call(E,T,$,U)}function Ze(D,B,E,T){if(B)D.apply(E,T);else for(var $=D.length,U=Pe(D,$),P=0;P<$;++P)U[P].apply(E,T)}je.prototype.emit=function(B){var E,T,$,U,P,Me,Ce,Qe=B==="error";if(Me=this._events,Me)Qe=Qe&&Me.error==null;else if(!Qe)return!1;if(Ce=this.domain,Qe){if(E=arguments[1],Ce)E||(E=new Error('Uncaught, unspecified "error" event')),E.domainEmitter=this,E.domain=Ce,E.domainThrown=!1,Ce.emit("error",E);else{if(E instanceof Error)throw E;var it=new Error('Uncaught, unspecified "error" event. ('+E+")");throw it.context=E,it}return!1}if(T=Me[B],!T)return!1;var Pt=typeof T=="function";switch($=arguments.length,$){case 1:Ke(T,Pt,this);break;case 2:Fe(T,Pt,this,arguments[1]);break;case 3:be(T,Pt,this,arguments[1],arguments[2]);break;case 4:pt(T,Pt,this,arguments[1],arguments[2],arguments[3]);break;default:for(U=new Array($-1),P=1;P<$;P++)U[P-1]=arguments[P];Ze(T,Pt,this,U)}return!0};function Jt(D,B,E,T){var $,U,P;if(typeof E!="function")throw new TypeError('"listener" argument must be a function');if(U=D._events,U?(U.newListener&&(D.emit("newListener",B,E.listener?E.listener:E),U=D._events),P=U[B]):(U=D._events=new rt,D._eventsCount=0),!P)P=U[B]=E,++D._eventsCount;else if(typeof P=="function"?P=U[B]=T?[E,P]:[P,E]:T?P.unshift(E):P.push(E),!P.warned&&($=ce(D),$&&$>0&&P.length>$)){P.warned=!0;var Me=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+B+" listeners added. Use emitter.setMaxListeners() to increase limit");Me.name="MaxListenersExceededWarning",Me.emitter=D,Me.type=B,Me.count=P.length,At(Me)}return D}function At(D){typeof console.warn=="function"?console.warn(D):console.log(D)}je.prototype.addListener=function(B,E){return Jt(this,B,E,!1)},je.prototype.on=je.prototype.addListener,je.prototype.prependListener=function(B,E){return Jt(this,B,E,!0)};function Q(D,B,E){var T=!1;function $(){D.removeListener(B,$),T||(T=!0,E.apply(D,arguments))}return $.listener=E,$}je.prototype.once=function(B,E){if(typeof E!="function")throw new TypeError('"listener" argument must be a function');return this.on(B,Q(this,B,E)),this},je.prototype.prependOnceListener=function(B,E){if(typeof E!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(B,Q(this,B,E)),this},je.prototype.removeListener=function(B,E){var T,$,U,P,Me;if(typeof E!="function")throw new TypeError('"listener" argument must be a function');if($=this._events,!$)return this;if(T=$[B],!T)return this;if(T===E||T.listener&&T.listener===E)--this._eventsCount===0?this._events=new rt:(delete $[B],$.removeListener&&this.emit("removeListener",B,T.listener||E));else if(typeof T!="function"){for(U=-1,P=T.length;P-- >0;)if(T[P]===E||T[P].listener&&T[P].listener===E){Me=T[P].listener,U=P;break}if(U<0)return this;if(T.length===1){if(T[0]=void 0,--this._eventsCount===0)return this._events=new rt,this;delete $[B]}else ot(T,U);$.removeListener&&this.emit("removeListener",B,Me||E)}return this},je.prototype.off=function(D,B){return this.removeListener(D,B)},je.prototype.removeAllListeners=function(B){var E,T;if(T=this._events,!T)return this;if(!T.removeListener)return arguments.length===0?(this._events=new rt,this._eventsCount=0):T[B]&&(--this._eventsCount===0?this._events=new rt:delete T[B]),this;if(arguments.length===0){for(var $=Object.keys(T),U=0,P;U<$.length;++U)P=$[U],P!=="removeListener"&&this.removeAllListeners(P);return this.removeAllListeners("removeListener"),this._events=new rt,this._eventsCount=0,this}if(E=T[B],typeof E=="function")this.removeListener(B,E);else if(E)do this.removeListener(B,E[E.length-1]);while(E[0]);return this},je.prototype.listeners=function(B){var E,T,$=this._events;return $?(E=$[B],E?typeof E=="function"?T=[E.listener||E]:T=St(E):T=[]):T=[],T},je.listenerCount=function(D,B){return typeof D.listenerCount=="function"?D.listenerCount(B):Ue.call(D,B)},je.prototype.listenerCount=Ue;function Ue(D){var B=this._events;if(B){var E=B[D];if(typeof E=="function")return 1;if(E)return E.length}return 0}je.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function ot(D,B){for(var E=B,T=E+1,$=D.length;T<$;E+=1,T+=1)D[E]=D[T];D.pop()}function Pe(D,B){for(var E=new Array(B);B--;)E[B]=D[B];return E}function St(D){for(var B=new Array(D.length),E=0;E<B.length;++E)B[E]=D[E].listener||D[E];return B}var ut=Se.getLogger("twilsock");function or(D,B){return["".concat(new Date().toISOString()," Twilsock ").concat(D,":")].concat(Array.from(B))}var br=function(){function D(B){re.default(this,D),oe.default(this,"prefix",""),this.prefix=B!=null&&B.length>0?" "+B+":":""}return ze.default(D,[{key:"setLevel",value:function(E){ut.setLevel(E)}},{key:"trace",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.trace.apply(null,or("T",T))}},{key:"debug",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.debug.apply(null,or("D",T))}},{key:"info",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.info.apply(null,or("I",T))}},{key:"warn",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.warn.apply(null,or("W",T))}},{key:"error",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.error.apply(null,or("E",T))}}],[{key:"setLevel",value:function(E){ut.setLevel(E)}},{key:"trace",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.trace.apply(null,or("T",T))}},{key:"debug",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.debug.apply(null,or("D",T))}},{key:"info",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.info.apply(null,or("I",T))}},{key:"warn",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.warn.apply(null,or("W",T))}},{key:"error",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.error.apply(null,or("E",T))}}]),D}(),et=new br(""),Mr="0.12.2",Fr=function(){function D(B,E,T){re.default(this,D),oe.default(this,"confirmedCapabilities",new Set),this.activeGrant=E,this._token=B;var $=T.region||"us1",U="wss://tsock.".concat($,".twilio.com/v3/wsconnect"),P=T.twilsock||T.Twilsock||{};this.url=P.uri||U,this._continuationToken=T.continuationToken?T.continuationToken:null,this.logLevel=T.logLevel?T.logLevel:"error",this.retryPolicy=T.retryPolicy?T.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=T.clientMetadata?T.clientMetadata:{},this.clientMetadata.ver=Mr,this.initRegistrations=T.initRegistrations?T.initRegistrations:null,this.tweaks=T.tweaks?T.tweaks:null}return ze.default(D,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(E){this._token=E}},{key:"updateContinuationToken",value:function(E){this._continuationToken=E}}]),D}(),dr=function D(B){re.default(this,D),this.id=B||"TM".concat(N.v4())};function fr(D){var B=Wt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot=function(D){_e.default(E,D);var B=fr(E);function E(T,$,U,P,Me){var Ce;return re.default(this,E),Ce=B.call(this),oe.default(V.default(Ce),"method","init"),Ce.token=T,Ce.continuation_token=$,Ce.metadata=U,Ce.registrations=P,Ce.tweaks=Me,Ce.capabilities=["client_update","offline_storage","telemetry.v1"],Ce}return E}(dr);function L(D){var B=W();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=function(D){_e.default(E,D);var B=L(E);function E(T,$,U,P,Me,Ce,Qe){var it;return re.default(this,E),it=B.call(this,T),it.continuationToken=$,it.continuationTokenStatus=P,it.offlineStorage=Me,it.initRegistrations=Ce,it.debugInfo=Qe,it.confirmedCapabilities=U,it}return E}(dr);function He(D){var B=ct();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function ct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var bt=function(D){_e.default(E,D);var B=He(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"method","update"),$.token=T,$}return E}(dr);function zt(D){var B=tr();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function tr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Re=function(D){_e.default(E,D);var B=zt(E);function E(T,$,U){var P;return re.default(this,E),P=B.call(this),oe.default(V.default(P),"method","message"),P.active_grant=T,P.payload_type=$,P.http_request=U,P}return E}(dr);function Ne(D){var B=pe();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function pe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var $e=function(D){_e.default(E,D);var B=Ne(E);function E(T){var $;return re.default(this,E),$=B.call(this,T),oe.default(V.default($),"method","reply"),oe.default(V.default($),"payload_type","application/json"),oe.default(V.default($),"status",{code:200,status:"OK"}),$}return E}(dr);function ae(D){var B=me();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function me(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var we=function(D){_e.default(E,D);var B=ae(E);function E(){var T;return re.default(this,E),T=B.call(this),oe.default(V.default(T),"method","close"),T}return E}(dr);function K(D){var B=he();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function he(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var G=function D(B,E,T,$,U,P){re.default(this,D),this.start=B,this.end=E,this.title=T,this.details=$,this.id=U,this.type=P},de=function(D){_e.default(E,D);var B=K(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"method","telemetry.v1"),$.events=T,$}return E}(dr);function ee(D){var B=encodeURIComponent(D),E=B.replace(/%([0-9A-F]{2})/g,function(T,$){return String.fromCharCode(+("0x"+$))});return E.length}function Ye(D){var B=encodeURIComponent(D),E=B.replace(/%([0-9A-F]{2})/g,function($,U){return String.fromCharCode(+("0x"+U))}),T=new Uint8Array(E.length);return Array.prototype.forEach.call(E,function($,U){T[U]=$.charCodeAt(0)}),T}function qe(D){var B=Array.prototype.map.call(D,function(T){return String.fromCharCode(T)}).join(""),E=B.replace(/(.)/g,function(T,$){var U=$.charCodeAt(0).toString(16).toUpperCase();return U.length<2&&(U="0"+U),"%"+U});return decodeURIComponent(E)}function dt(D){return JSON.parse(qe(D))}function lt(D){for(var B="",E=0;E<D.length;++E){var T=String.fromCharCode(D[E]);if(B+=T,T==="\r"){E+=2;break}}var $=B.split(" ");return{size:E,protocol:$[0],version:$[1],headerSize:Number($[2])}}var ht=function(){function D(){re.default(this,D)}return ze.default(D,null,[{key:"parse",value:function(E){var T=2,$=new Uint8Array(E),U=lt($);if(U.protocol!=="TWILSOCK"||U.version!=="V3.0")return et.error("unsupported protocol: ".concat(U.protocol," ver ").concat(U.version)),null;var P;try{P=dt($.subarray(U.size,U.size+U.headerSize))}catch(it){return et.error("failed to parse message header",it,E),null}et.debug("message received: ",P.method),et.trace("message received: ",P);var Me;if(P.payload_size>0){var Ce=T+U.size+U.headerSize,Qe=P.payload_size;if(!P.hasOwnProperty("payload_type")||P.payload_type.indexOf("application/json")===0)try{Me=dt($.subarray(Ce,Ce+Qe))}catch(it){return et.error("failed to parse message body",it,E),null}else P.payload_type.indexOf("text/plain")===0&&(Me=qe($.subarray(Ce,Ce+Qe)))}return{method:P.method,header:P,payload:Me}}},{key:"createPacket",value:function(E){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";E.payload_size=ee(T);var $=JSON.stringify(E),U="TWILSOCK V3.0 "+ee($);et.debug("send request:",U+$+T);var P=Ye(U+`\r
1051
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Pu,n=Aa,i=gs,a=ep,s=na,o=ia,u=li,l=aa,c=ys,d=zu,f=ui,m=wn,b=Hu,A=YC,N=hd,z=wd,X=sa,Ee=zb;function Ie(D){return D&&typeof D=="object"&&"default"in D?D:{default:D}}function Fe(D){if(D&&D.__esModule)return D;var B=Object.create(null);return D&&Object.keys(D).forEach(function(E){if(E!=="default"){var T=Object.getOwnPropertyDescriptor(D,E);Object.defineProperty(B,E,T.get?T:{enumerable:!0,get:function(){return D[E]}})}}),B.default=D,Object.freeze(B)}var Oe=Ie(r),ze=Ie(n),V=Ie(i),xe=Ie(a),_e=Ie(s),se=Ie(o),Te=Ie(u),re=Ie(l),oe=Ie(c),q=Ie(d),ne=Ie(f),Se=Fe(b),H=Fe(A),ye=Ie(z),ke=Fe(Ee);function M(D,B,E,T){var $=arguments.length,U=$<3?B:T===null?T=Object.getOwnPropertyDescriptor(B,E):T,P;if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(D,B,E,T);else for(var Me=D.length-1;Me>=0;Me--)(P=D[Me])&&(U=($<3?P(U):$>3?P(B,E,U):P(B,E))||U);return $>3&&U&&Object.defineProperty(B,E,U),U}function Xe(D,B){if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(D,B)}var Ct;function rt(){}rt.prototype=Object.create(null);function je(){je.init.call(this)}je.EventEmitter=je,je.usingDomains=!1,je.prototype.domain=void 0,je.prototype._events=void 0,je.prototype._maxListeners=void 0,je.defaultMaxListeners=10,je.init=function(){this.domain=null,je.usingDomains&&Ct.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new rt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},je.prototype.setMaxListeners=function(B){if(typeof B!="number"||B<0||isNaN(B))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=B,this};function ce(D){return D._maxListeners===void 0?je.defaultMaxListeners:D._maxListeners}je.prototype.getMaxListeners=function(){return ce(this)};function Ke(D,B,E){if(B)D.call(E);else for(var T=D.length,$=Pe(D,T),U=0;U<T;++U)$[U].call(E)}function Be(D,B,E,T){if(B)D.call(E,T);else for(var $=D.length,U=Pe(D,$),P=0;P<$;++P)U[P].call(E,T)}function be(D,B,E,T,$){if(B)D.call(E,T,$);else for(var U=D.length,P=Pe(D,U),Me=0;Me<U;++Me)P[Me].call(E,T,$)}function pt(D,B,E,T,$,U){if(B)D.call(E,T,$,U);else for(var P=D.length,Me=Pe(D,P),Ce=0;Ce<P;++Ce)Me[Ce].call(E,T,$,U)}function Ze(D,B,E,T){if(B)D.apply(E,T);else for(var $=D.length,U=Pe(D,$),P=0;P<$;++P)U[P].apply(E,T)}je.prototype.emit=function(B){var E,T,$,U,P,Me,Ce,Qe=B==="error";if(Me=this._events,Me)Qe=Qe&&Me.error==null;else if(!Qe)return!1;if(Ce=this.domain,Qe){if(E=arguments[1],Ce)E||(E=new Error('Uncaught, unspecified "error" event')),E.domainEmitter=this,E.domain=Ce,E.domainThrown=!1,Ce.emit("error",E);else{if(E instanceof Error)throw E;var it=new Error('Uncaught, unspecified "error" event. ('+E+")");throw it.context=E,it}return!1}if(T=Me[B],!T)return!1;var Pt=typeof T=="function";switch($=arguments.length,$){case 1:Ke(T,Pt,this);break;case 2:Be(T,Pt,this,arguments[1]);break;case 3:be(T,Pt,this,arguments[1],arguments[2]);break;case 4:pt(T,Pt,this,arguments[1],arguments[2],arguments[3]);break;default:for(U=new Array($-1),P=1;P<$;P++)U[P-1]=arguments[P];Ze(T,Pt,this,U)}return!0};function Jt(D,B,E,T){var $,U,P;if(typeof E!="function")throw new TypeError('"listener" argument must be a function');if(U=D._events,U?(U.newListener&&(D.emit("newListener",B,E.listener?E.listener:E),U=D._events),P=U[B]):(U=D._events=new rt,D._eventsCount=0),!P)P=U[B]=E,++D._eventsCount;else if(typeof P=="function"?P=U[B]=T?[E,P]:[P,E]:T?P.unshift(E):P.push(E),!P.warned&&($=ce(D),$&&$>0&&P.length>$)){P.warned=!0;var Me=new Error("Possible EventEmitter memory leak detected. "+P.length+" "+B+" listeners added. Use emitter.setMaxListeners() to increase limit");Me.name="MaxListenersExceededWarning",Me.emitter=D,Me.type=B,Me.count=P.length,At(Me)}return D}function At(D){typeof console.warn=="function"?console.warn(D):console.log(D)}je.prototype.addListener=function(B,E){return Jt(this,B,E,!1)},je.prototype.on=je.prototype.addListener,je.prototype.prependListener=function(B,E){return Jt(this,B,E,!0)};function Q(D,B,E){var T=!1;function $(){D.removeListener(B,$),T||(T=!0,E.apply(D,arguments))}return $.listener=E,$}je.prototype.once=function(B,E){if(typeof E!="function")throw new TypeError('"listener" argument must be a function');return this.on(B,Q(this,B,E)),this},je.prototype.prependOnceListener=function(B,E){if(typeof E!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(B,Q(this,B,E)),this},je.prototype.removeListener=function(B,E){var T,$,U,P,Me;if(typeof E!="function")throw new TypeError('"listener" argument must be a function');if($=this._events,!$)return this;if(T=$[B],!T)return this;if(T===E||T.listener&&T.listener===E)--this._eventsCount===0?this._events=new rt:(delete $[B],$.removeListener&&this.emit("removeListener",B,T.listener||E));else if(typeof T!="function"){for(U=-1,P=T.length;P-- >0;)if(T[P]===E||T[P].listener&&T[P].listener===E){Me=T[P].listener,U=P;break}if(U<0)return this;if(T.length===1){if(T[0]=void 0,--this._eventsCount===0)return this._events=new rt,this;delete $[B]}else ot(T,U);$.removeListener&&this.emit("removeListener",B,Me||E)}return this},je.prototype.off=function(D,B){return this.removeListener(D,B)},je.prototype.removeAllListeners=function(B){var E,T;if(T=this._events,!T)return this;if(!T.removeListener)return arguments.length===0?(this._events=new rt,this._eventsCount=0):T[B]&&(--this._eventsCount===0?this._events=new rt:delete T[B]),this;if(arguments.length===0){for(var $=Object.keys(T),U=0,P;U<$.length;++U)P=$[U],P!=="removeListener"&&this.removeAllListeners(P);return this.removeAllListeners("removeListener"),this._events=new rt,this._eventsCount=0,this}if(E=T[B],typeof E=="function")this.removeListener(B,E);else if(E)do this.removeListener(B,E[E.length-1]);while(E[0]);return this},je.prototype.listeners=function(B){var E,T,$=this._events;return $?(E=$[B],E?typeof E=="function"?T=[E.listener||E]:T=St(E):T=[]):T=[],T},je.listenerCount=function(D,B){return typeof D.listenerCount=="function"?D.listenerCount(B):Ue.call(D,B)},je.prototype.listenerCount=Ue;function Ue(D){var B=this._events;if(B){var E=B[D];if(typeof E=="function")return 1;if(E)return E.length}return 0}je.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function ot(D,B){for(var E=B,T=E+1,$=D.length;T<$;E+=1,T+=1)D[E]=D[T];D.pop()}function Pe(D,B){for(var E=new Array(B);B--;)E[B]=D[B];return E}function St(D){for(var B=new Array(D.length),E=0;E<B.length;++E)B[E]=D[E].listener||D[E];return B}var ut=Se.getLogger("twilsock");function or(D,B){return["".concat(new Date().toISOString()," Twilsock ").concat(D,":")].concat(Array.from(B))}var br=function(){function D(B){re.default(this,D),oe.default(this,"prefix",""),this.prefix=B!=null&&B.length>0?" "+B+":":""}return ze.default(D,[{key:"setLevel",value:function(E){ut.setLevel(E)}},{key:"trace",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.trace.apply(null,or("T",T))}},{key:"debug",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.debug.apply(null,or("D",T))}},{key:"info",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.info.apply(null,or("I",T))}},{key:"warn",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.warn.apply(null,or("W",T))}},{key:"error",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.error.apply(null,or("E",T))}}],[{key:"setLevel",value:function(E){ut.setLevel(E)}},{key:"trace",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.trace.apply(null,or("T",T))}},{key:"debug",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.debug.apply(null,or("D",T))}},{key:"info",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.info.apply(null,or("I",T))}},{key:"warn",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.warn.apply(null,or("W",T))}},{key:"error",value:function(){for(var E=arguments.length,T=new Array(E),$=0;$<E;$++)T[$]=arguments[$];ut.error.apply(null,or("E",T))}}]),D}(),et=new br(""),Mr="0.12.2",Fr=function(){function D(B,E,T){re.default(this,D),oe.default(this,"confirmedCapabilities",new Set),this.activeGrant=E,this._token=B;var $=T.region||"us1",U="wss://tsock.".concat($,".twilio.com/v3/wsconnect"),P=T.twilsock||T.Twilsock||{};this.url=P.uri||U,this._continuationToken=T.continuationToken?T.continuationToken:null,this.logLevel=T.logLevel?T.logLevel:"error",this.retryPolicy=T.retryPolicy?T.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=T.clientMetadata?T.clientMetadata:{},this.clientMetadata.ver=Mr,this.initRegistrations=T.initRegistrations?T.initRegistrations:null,this.tweaks=T.tweaks?T.tweaks:null}return ze.default(D,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(E){this._token=E}},{key:"updateContinuationToken",value:function(E){this._continuationToken=E}}]),D}(),dr=function D(B){re.default(this,D),this.id=B||"TM".concat(N.v4())};function fr(D){var B=Wt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Wt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ot=function(D){_e.default(E,D);var B=fr(E);function E(T,$,U,P,Me){var Ce;return re.default(this,E),Ce=B.call(this),oe.default(V.default(Ce),"method","init"),Ce.token=T,Ce.continuation_token=$,Ce.metadata=U,Ce.registrations=P,Ce.tweaks=Me,Ce.capabilities=["client_update","offline_storage","telemetry.v1"],Ce}return E}(dr);function L(D){var B=W();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function W(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=function(D){_e.default(E,D);var B=L(E);function E(T,$,U,P,Me,Ce,Qe){var it;return re.default(this,E),it=B.call(this,T),it.continuationToken=$,it.continuationTokenStatus=P,it.offlineStorage=Me,it.initRegistrations=Ce,it.debugInfo=Qe,it.confirmedCapabilities=U,it}return E}(dr);function He(D){var B=ct();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function ct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var bt=function(D){_e.default(E,D);var B=He(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"method","update"),$.token=T,$}return E}(dr);function zt(D){var B=tr();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function tr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Re=function(D){_e.default(E,D);var B=zt(E);function E(T,$,U){var P;return re.default(this,E),P=B.call(this),oe.default(V.default(P),"method","message"),P.active_grant=T,P.payload_type=$,P.http_request=U,P}return E}(dr);function Ne(D){var B=pe();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function pe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var $e=function(D){_e.default(E,D);var B=Ne(E);function E(T){var $;return re.default(this,E),$=B.call(this,T),oe.default(V.default($),"method","reply"),oe.default(V.default($),"payload_type","application/json"),oe.default(V.default($),"status",{code:200,status:"OK"}),$}return E}(dr);function ae(D){var B=me();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function me(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var we=function(D){_e.default(E,D);var B=ae(E);function E(){var T;return re.default(this,E),T=B.call(this),oe.default(V.default(T),"method","close"),T}return E}(dr);function K(D){var B=he();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function he(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var G=function D(B,E,T,$,U,P){re.default(this,D),this.start=B,this.end=E,this.title=T,this.details=$,this.id=U,this.type=P},de=function(D){_e.default(E,D);var B=K(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"method","telemetry.v1"),$.events=T,$}return E}(dr);function ee(D){var B=encodeURIComponent(D),E=B.replace(/%([0-9A-F]{2})/g,function(T,$){return String.fromCharCode(+("0x"+$))});return E.length}function Ye(D){var B=encodeURIComponent(D),E=B.replace(/%([0-9A-F]{2})/g,function($,U){return String.fromCharCode(+("0x"+U))}),T=new Uint8Array(E.length);return Array.prototype.forEach.call(E,function($,U){T[U]=$.charCodeAt(0)}),T}function qe(D){var B=Array.prototype.map.call(D,function(T){return String.fromCharCode(T)}).join(""),E=B.replace(/(.)/g,function(T,$){var U=$.charCodeAt(0).toString(16).toUpperCase();return U.length<2&&(U="0"+U),"%"+U});return decodeURIComponent(E)}function dt(D){return JSON.parse(qe(D))}function lt(D){for(var B="",E=0;E<D.length;++E){var T=String.fromCharCode(D[E]);if(B+=T,T==="\r"){E+=2;break}}var $=B.split(" ");return{size:E,protocol:$[0],version:$[1],headerSize:Number($[2])}}var ht=function(){function D(){re.default(this,D)}return ze.default(D,null,[{key:"parse",value:function(E){var T=2,$=new Uint8Array(E),U=lt($);if(U.protocol!=="TWILSOCK"||U.version!=="V3.0")return et.error("unsupported protocol: ".concat(U.protocol," ver ").concat(U.version)),null;var P;try{P=dt($.subarray(U.size,U.size+U.headerSize))}catch(it){return et.error("failed to parse message header",it,E),null}et.debug("message received: ",P.method),et.trace("message received: ",P);var Me;if(P.payload_size>0){var Ce=T+U.size+U.headerSize,Qe=P.payload_size;if(!P.hasOwnProperty("payload_type")||P.payload_type.indexOf("application/json")===0)try{Me=dt($.subarray(Ce,Ce+Qe))}catch(it){return et.error("failed to parse message body",it,E),null}else P.payload_type.indexOf("text/plain")===0&&(Me=qe($.subarray(Ce,Ce+Qe)))}return{method:P.method,header:P,payload:Me}}},{key:"createPacket",value:function(E){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";E.payload_size=ee(T);var $=JSON.stringify(E),U="TWILSOCK V3.0 "+ee($);et.debug("send request:",U+$+T);var P=Ye(U+`\r
1052
1052
  `+$+`\r
1053
1053
  `+T);return P.buffer}}]),D}();function Rt(D){var B=xt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function xt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var kt=function(D){_e.default(E,D);var B=Rt(E);function E(T){return re.default(this,E),B.call(this,T)}return E}(ye.default(Error));function $t(D){var B=It();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function It(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var jt=function(D){_e.default(E,D);var B=$t(E);function E(T,$){var U;return re.default(this,E),U=B.call(this,T),U.reply=$,U}return E}(kt);function sn(D,B){var E=Object.keys(D);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(D);B&&(T=T.filter(function($){return Object.getOwnPropertyDescriptor(D,$).enumerable})),E.push.apply(E,T)}return E}function _n(D){for(var B=1;B<arguments.length;B++){var E=arguments[B]!=null?arguments[B]:{};B%2?sn(Object(E),!0).forEach(function(T){oe.default(D,T,E[T])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(E)):sn(Object(E)).forEach(function(T){Object.defineProperty(D,T,Object.getOwnPropertyDescriptor(E,T))})}return D}function Ut(D){var B=qn();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function qn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ha=function(D){_e.default(E,D);var B=Ut(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"newBackoff",null),oe.default(V.default($),"usedBackoff",null),oe.default(V.default($),"retrier",null),$.options=T?_n({},T):{},$}return ze.default(E,[{key:"inProgress",get:function(){return!!this.retrier}},{key:"start",value:function(){if(this.inProgress)throw new Error("Already waiting for next attempt, call finishAttempt(success : boolean) to finish it");this.createRetrier()}},{key:"stop",value:function(){this.cleanRetrier(),this.newBackoff=null,this.usedBackoff=null}},{key:"modifyBackoff",value:function($){this.newBackoff=$}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");if(this.newBackoff){var $=!this.usedBackoff||this.usedBackoff<this.newBackoff;if($)this.createRetrier();else{var U;(U=this.retrier)===null||U===void 0||U.failed(new Error)}}else{var P;(P=this.retrier)===null||P===void 0||P.failed(new Error)}}},{key:"cancel",value:function(){var $;($=this.retrier)===null||$===void 0||$.cancel()}},{key:"cleanRetrier",value:function(){var $,U;($=this.retrier)===null||$===void 0||$.removeAllListeners(),(U=this.retrier)===null||U===void 0||U.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var $=_n({},this.options);return this.newBackoff&&($.min=this.newBackoff,$.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),$.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,$}},{key:"createRetrier",value:function(){var $=this;this.cleanRetrier();var U=this.getRetryPolicy();this.retrier=new X.Retrier(U),this.retrier.once("attempt",function(){var P,Me;(P=$.retrier)===null||P===void 0||P.on("attempt",function(){return $.emit("attempt")}),(Me=$.retrier)===null||Me===void 0||Me.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(P){return $.emit("failed",P)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),E}(je);function Wa(D){var B=ti();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function ti(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var pa=3e3;function ri(D){setTimeout(D,0)}var gi=function(D){_e.default(E,D);var B=Wa(E);function E(T,$,U){var P;re.default(this,E),P=B.call(this),oe.default(V.default(P),"disconnectingTimer",null),oe.default(V.default(P),"disconnectedPromiseResolve",null),oe.default(V.default(P),"terminalStates",["disconnected","rejected"]),oe.default(V.default(P),"tokenExpiredSasCode",20104),oe.default(V.default(P),"terminationReason","Connection is not initialized"),P.websocket=T,P.websocket.on("connected",function(){return P.fsm.socketConnected()}),P.websocket.on("disconnected",function(){return P.fsm.socketClosed()}),P.websocket.on("message",function(Ce){return P.onIncomingMessage(Ce)}),P.websocket.on("socketError",function(Ce){return P.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(Ce.message),httpStatusCode:null,errorCode:null})}),P.transport=$,P.config=U,P.retrier=new ha(U.retryPolicy),P.retrier.on("attempt",function(){return P.retry()}),P.retrier.on("failed",function(Ce){et.warn("Retrying failed: ".concat(Ce.message)),P.disconnect()}),typeof window<"u"&&typeof window.addEventListener<"u"&&(window.addEventListener("online",function(){et.debug("Browser reported connectivity state: online"),P.resetBackoff(),P.fsm.systemOnline()}),window.addEventListener("offline",function(){et.debug("Browser reported connectivity state: offline"),P.websocket.close(),P.fsm.socketClosed()}));var Me=H.factory({init:"disconnected",transitions:[{name:"userConnect",from:["disconnected","rejected"],to:"connecting"},{name:"userConnect",from:["connecting","connected"]},{name:"userDisconnect",from:["connecting","initialising","connected","updating","retrying","rejected","waitSocketClosed","waitOffloadSocketClosed"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"initialising"},{name:"socketClosed",from:["connecting","initialising","connected","updating","error","waitOffloadSocketClosed"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketClosed",from:["waitSocketClosed"],to:"disconnected"},{name:"socketClosed",from:["rejected"],to:"rejected"},{name:"initSuccess",from:["initialising"],to:"connected"},{name:"initError",from:["initialising"],to:"error"},{name:"tokenRejected",from:["initialising","updating"],to:"rejected"},{name:"protocolError",from:["initialising","connected","updating"],to:"error"},{name:"receiveClose",from:["initialising","connected","updating"],to:"waitSocketClosed"},{name:"receiveOffload",from:["initialising","connected","updating"],to:"waitOffloadSocketClosed"},{name:"unsupportedProtocol",from:["initialising","connected","updating"],to:"unsupported"},{name:"receiveFatalClose",from:["initialising","connected","updating"],to:"unsupported"},{name:"userUpdateToken",from:["disconnected","rejected","connecting","retrying"],to:"connecting"},{name:"userUpdateToken",from:["connected"],to:"updating"},{name:"updateSuccess",from:["updating"],to:"connected"},{name:"updateError",from:["updating"],to:"error"},{name:"userSend",from:["connected"],to:"connected"},{name:"systemOnline",from:["retrying"],to:"connecting"}],methods:{onConnecting:function(){P.setupSocket(),P.emit("connecting")},onEnterInitialising:function(){P.sendInit()},onLeaveInitialising:function(){P.cancelInit()},onEnterUpdating:function(){P.sendUpdate()},onLeaveUpdating:function(){P.cancelUpdate()},onEnterRetrying:function(){P.initRetry(),P.emit("connecting")},onEnterConnected:function(){P.resetBackoff(),P.onConnected()},onUserUpdateToken:function(){P.resetBackoff()},onTokenRejected:function(){P.resetBackoff(),P.closeSocket(!0),P.finalizeSocket()},onUserDisconnect:function(){P.closeSocket(!0)},onEnterDisconnecting:function(){P.startDisconnectTimer()},onLeaveDisconnecting:function(){P.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){P.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){P.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){P.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){P.cancelDisconnectTimer()},onDisconnected:function(){P.resetBackoff(),P.finalizeSocket()},onReceiveClose:function(){P.onCloseReceived()},onReceiveOffload:function(Qe,it){et.debug("onreceiveoffload: ",it),P.modifyBackoff(it.body),P.onCloseReceived()},onUnsupported:function(){P.closeSocket(!0),P.finalizeSocket()},onError:function(Qe,it){P.closeSocket(it),P.finalizeSocket()},onEnterState:function(Qe){Qe.from!=="none"&&P.changeState(Qe)},onInvalidTransition:function(Qe,it,Pt){et.warn("FSM: unexpected transition",it,Pt)}}});return P.fsm=new Me,P}return ze.default(E,[{key:"changeState",value:function($){et.debug("FSM: ".concat($.transition,": ").concat($.from," --> ").concat($.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){et.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function($){et.trace("modifyBackoff",$);var U=$?$.backoff_policy:null;U&&typeof U.reconnect_min_ms=="number"&&this.retrier.modifyBackoff(U.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var $=this;et.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){et.debug("disconnecting is timed out"),$.closeSocket(!0)},pa)}},{key:"cancelDisconnectTimer",value:function(){et.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return this.state==="connected"&&this.websocket.isConnected}},{key:"state",get:function(){switch(this.fsm.state){case"connecting":case"initialising":case"retrying":case"error":return"connecting";case"updating":case"connected":return"connected";case"rejected":return"denied";case"disconnecting":case"waitSocketClosed":case"waitOffloadSocketClosed":return"disconnecting";case"disconnected":default:return"disconnected"}}},{key:"initRetry",value:function(){et.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){this.fsm.state!="connecting"?(et.trace("retry"),this.websocket.close(),this.fsm.userRetry()):et.trace("can retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){et.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){et.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function($){var U=ht.parse($);if(U){var P=U.method,Me=U.header,Ce=U.payload;if(P!=="reply"&&this.confirmReceiving(Me),P==="notification")this.emit("message",Me.message_type,Ce);else if(Me.method==="reply")this.transport.processReply({id:Me.id,status:Me.status,header:Me,body:Ce});else if(Me.method==="client_update")Me.client_update_type==="token_about_to_expire"&&this.emit("tokenAboutToExpire");else if(Me.method==="close")if(Me.status.code===308)et.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:Me.status.status,body:Ce});else if(Me.status.code===406){var Qe="Server closed connection because can't parse protocol: ".concat(JSON.stringify(Me.status));this.emitReplyConnectionError(Qe,Me,!0),et.error(Qe),this.fsm.receiveFatalClose()}else Me.status.code===417?(et.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(Me.status))),this.fsm.receiveFatalClose(Me.status.status)):Me.status.code===410?(et.warn("Server closed connection: ".concat(JSON.stringify(Me.status))),this.fsm.receiveClose(Me.status.status),this.emit("tokenExpired")):Me.status.code===401?(et.error("Server closed connection: ".concat(JSON.stringify(Me.status))),this.fsm.receiveClose(Me.status.status)):(et.warn("unexpected message: ",Me.status),this.fsm.receiveOffload({status:Me.status.status,body:null}))}}},{key:"sendInit",value:function(){var T=Oe.default(q.default.mark(function U(){var P,Me;return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return et.trace("sendInit"),Qe.prev=1,this.emit("beforeSendInit"),Qe.next=5,this.transport.sendInit();case 5:P=Qe.sent,this.config.updateContinuationToken(P.continuationToken),this.config.confirmedCapabilities=P.confirmedCapabilities,this.fsm.initSuccess(P),this.emit("initialized",P),this.emit("tokenUpdated"),Qe.next=17;break;case 13:Qe.prev=13,Qe.t0=Qe.catch(1),Qe.t0 instanceof jt?(Me=!1,et.warn("Init rejected by server: ".concat(JSON.stringify(Qe.t0.reply.status))),this.emit("sendInitFailed"),Qe.t0.reply.status.code===401||Qe.t0.reply.status.code===403?(Me=!0,this.fsm.tokenRejected(Qe.t0.reply.status),Qe.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Qe.t0.reply.status.code===429?(this.modifyBackoff(Qe.t0.reply.body),this.fsm.initError(!0)):Qe.t0.reply.status.code===500?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(Qe.t0.message,Qe.t0.reply,Me)):(this.terminationReason=Qe.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(Qe.t0.message,`
1054
1054
  `).concat(JSON.stringify(Qe.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Qe.t0);case 17:case"end":return Qe.stop()}},U,this,[[1,13]])}));function $(){return T.apply(this,arguments)}return $}()},{key:"sendUpdate",value:function(){var T=Oe.default(q.default.mark(function U(){var P,Me,Ce;return q.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return et.trace("sendUpdate"),P=new bt(this.config.token),it.prev=2,it.next=5,this.transport.sendWithReply(P);case 5:Me=it.sent,this.fsm.updateSuccess(Me.body),this.emit("tokenUpdated"),it.next=14;break;case 10:it.prev=10,it.t0=it.catch(2),it.t0 instanceof jt?(Ce=!1,et.warn("Token update rejected by server: ".concat(JSON.stringify(it.t0.reply.status))),it.t0.reply.status.code===401||it.t0.reply.status.code===403?(Ce=!0,this.fsm.tokenRejected(it.t0.reply.status),it.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):it.t0.reply.status.code===429?(this.modifyBackoff(it.t0.reply.body),this.fsm.updateError(it.t0.reply.status)):this.fsm.updateError(it.t0.reply.status),this.emitReplyConnectionError(it.t0.message,it.t0.reply,Ce)):(this.emit("error",!1,it.t0.message,null,null),this.fsm.updateError(it.t0)),this.emit("tokenUpdated",it.t0);case 14:case"end":return it.stop()}},U,this,[[2,10]])}));function $(){return T.apply(this,arguments)}return $}()},{key:"emitReplyConnectionError",value:function($,U,P){var Me=U.status&&U.status.description?U.status.description:$,Ce=U.status.code,Qe=U.status&&U.status.errorCode?U.status.errorCode:null;P&&(this.terminationReason=Me),this.emit("connectionError",{terminal:P,message:"Connection error: ".concat(Me),httpStatusCode:Ce,errorCode:Qe})}},{key:"cancelInit",value:function(){et.trace("cancelInit")}},{key:"cancelUpdate",value:function(){et.trace("cancelUpdate")}},{key:"confirmReceiving",value:function($){et.trace("confirmReceiving");try{this.transport.send(new $e($.id))}catch(U){et.debug("failed to confirm packet receiving",U)}}},{key:"closeSocket",value:function($){var U=this;et.trace("closeSocket (graceful: ".concat($,")")),$&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),ri(function(){return U.fsm.socketClosed()})}},{key:"connect",value:function(){et.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var $=this;return et.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(U){$.disconnectedPromiseResolve=U,$.fsm.userDisconnect()})}},{key:"updateToken",value:function($){var U=this;return et.trace("updateToken:",$),new Promise(function(P,Me){U.once("tokenUpdated",function(Ce){Ce?Me(Ce):P()}),U.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),E}(je),Za=function(){function D(){re.default(this,D)}return ze.default(D,null,[{key:"getMetadata",value:function(E){var T,$,U,P,Me,Ce,Qe,it,Pt=E&&E.clientMetadata?E.clientMetadata:{},vn=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Fi={env:(T=ke.name)!==null&&T!==void 0?T:"unknown",envv:($=ke.version)!==null&&$!==void 0?$:"unknown",os:(U=(P=ke.os)===null||P===void 0?void 0:P.family)!==null&&U!==void 0?U:"unknown",osv:(Me=(Ce=ke.os)===null||Ce===void 0?void 0:Ce.version)!==null&&Me!==void 0?Me:"unknown",osa:(Qe=(it=ke.os)===null||it===void 0?void 0:it.architecture)!==null&&Qe!==void 0?Qe:"unknown",sdk:"js-default"},tn={};return vn.filter(function(Bi){return Bi in Pt||Bi in Fi}).forEach(function(Bi){return tn[Bi]=Bi in Pt?Pt[Bi]:Fi[Bi]}),tn}}]),D}(),en=3e4;function ji(D){return D>=200&&D<300}function Ms(D){switch(ne.default(D)){case"undefined":return"";case"object":return JSON.stringify(D);default:return D}}var Ui=function(){function D(B,E){var T=this;re.default(this,D),this.config=E,this.activeRequests=new Map,this.channel=B,this.channel.on("reply",function($){return T.processReply($)}),this.channel.on("disconnected",function(){T.activeRequests.forEach(function($){clearTimeout($.timeout),$.reject(new kt("disconnected"))}),T.activeRequests.clear()})}return ze.default(D,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(E){var T=this.activeRequests.get(E.id);T&&(clearTimeout(T.timeout),this.activeRequests.delete(E.id),ji(E.status.code)?T.resolve(E):(T.reject(new jt("Transport failure: "+E.status.status,E)),et.trace("message rejected")))}},{key:"storeRequest",value:function(E,T,$){var U={resolve:T,reject:$,timeout:setTimeout(function(){et.trace("request",E,"is timed out"),$(new kt("Twilsock: request timeout: "+E))},en)};this.activeRequests.set(E,U)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(E){clearTimeout(E.timeout),E.reject(new kt("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var B=Oe.default(q.default.mark(function T(){var $,U,P;return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:return et.trace("sendInit"),$=Za.getMetadata(this.config),U=new Ot(this.config.token,this.config.continuationToken,$,this.config.initRegistrations,this.config.tweaks),Ce.next=5,this.sendWithReply(U);case 5:return P=Ce.sent,Ce.abrupt("return",new ie(P.id,P.header.continuation_token,new Set(P.header.capabilities),P.header.continuation_token_status,P.header.offline_storage,P.header.init_registrations,P.header.debug_info));case 7:case"end":return Ce.stop()}},T,this)}));function E(){return B.apply(this,arguments)}return E}()},{key:"sendClose",value:function(){var E=new we;this.send(E)}},{key:"sendWithReply",value:function(E,T){var $=this;return new Promise(function(U,P){var Me=$.send(E,T);$.storeRequest(Me,U,P)})}},{key:"send",value:function(E,T){E.id=E.id||"TM".concat(N.v4());var $=ht.createPacket(E,Ms(T));try{return this.channel.send($),E.id}catch(U){throw et.debug("failed to send ",E,U),et.trace(U.stack),U}}}]),D}();function Ns(D){var B=Bo();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Bo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Vn=function(D){_e.default(E,D);var B=Ns(E);function E(T){var $;return re.default(this,E),$=B.call(this),oe.default(V.default($),"socket",null),$.url=T,$.url=T,$.WebSocket=e.WebSocket||e.MozWebSocket||{},$}return ze.default(E,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var $=this;et.trace("connecting to socket");var U;try{U=new this.WebSocket(this.url)}catch(P){et.debug("Socket error: ".concat(this.url)),this.emit("socketError",P);return}U.binaryType="arraybuffer",U.onopen=function(){et.debug("socket opened ".concat($.url)),$.emit("connected")},U.onclose=function(P){et.debug("socket closed",P),$.emit("disconnected",P)},U.onerror=function(P){et.debug("Socket error:",P),$.emit("socketError",P)},U.onmessage=function(P){$.emit("message",P.data)},this.socket=U}},{key:"send",value:function($){return this.socket&&this.socket.send($)}},{key:"close",value:function(){if(et.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),E}(je);function Ls(D){var B=zo();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function zo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ho=function(D){_e.default(E,D);var B=Ls(E);function E(T){var $;return re.default(this,E),$=B.call(this),$.transport=T,$.registrations=new Map,$.registrationsInProgress=new Map,$}return ze.default(E,[{key:"putNotificationContext",value:function(){var T=Oe.default(q.default.mark(function U(P,Me){var Ce;return q.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return Ce={method:"put_notification_ctx",notification_ctx_id:P},it.next=3,this.transport.sendWithReply(Ce,Me);case 3:case"end":return it.stop()}},U,this)}));function $(U,P){return T.apply(this,arguments)}return $}()},{key:"deleteNotificationContext",value:function(){var T=Oe.default(q.default.mark(function U(P){var Me;return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return Me={method:"delete_notification_ctx",notification_ctx_id:P},Qe.next=3,this.transport.sendWithReply(Me);case 3:case"end":return Qe.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"updateRegistration",value:function(){var T=Oe.default(q.default.mark(function U(P,Me){var Ce,Qe;return q.default.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return et.debug("update registration for context",P),Ce=this.registrationsInProgress.get(P),Ce||(Ce=new Set,this.registrationsInProgress.set(P,Ce)),Qe=N.v4(),Ce.add(Qe),Pt.prev=5,Pt.next=8,this.putNotificationContext(P,Me);case 8:et.debug("registration attempt succeeded for context",Me),Ce.delete(Qe),Ce.size===0&&(this.registrationsInProgress.delete(P),this.emit("registered",P)),Pt.next=19;break;case 13:Pt.prev=13,Pt.t0=Pt.catch(5),et.warn("registration attempt failed for context",Me),et.debug(Pt.t0),Ce.delete(Qe),Ce.size===0&&(this.registrationsInProgress.delete(P),this.emit("registrationFailed",P,Pt.t0));case 19:case"end":return Pt.stop()}},U,this,[[5,13]])}));function $(U,P){return T.apply(this,arguments)}return $}()},{key:"updateRegistrations",value:function(){var T=Oe.default(q.default.mark(function U(){var P=this,Me;return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return et.trace("refreshing ".concat(this.registrations.size," registrations")),Me=[],this.registrations.forEach(function(it,Pt){Me.push(P.updateRegistration(Pt,it))}),Qe.next=5,Promise.all(Me);case 5:case"end":return Qe.stop()}},U,this)}));function $(){return T.apply(this,arguments)}return $}()},{key:"setNotificationsContext",value:function(){var T=Oe.default(q.default.mark(function U(P,Me){return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:if(!(!P||!Me)){Qe.next=2;break}throw new kt("Invalid arguments provided");case 2:return this.registrations.set(P,Me),Qe.next=5,this.updateRegistration(P,Me);case 5:return Qe.abrupt("return",Qe.sent);case 6:case"end":return Qe.stop()}},U,this)}));function $(U,P){return T.apply(this,arguments)}return $}()},{key:"removeNotificationsContext",value:function(){var T=Oe.default(q.default.mark(function U(P){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(this.registrations.has(P)){Ce.next=2;break}return Ce.abrupt("return");case 2:return Ce.next=4,this.deleteNotificationContext(P);case 4:this.transport.isConnected&&this.registrations.delete(P);case 5:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()}]),E}(je);function hn(D){var B=Ds();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Ds(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Pn=function(D){_e.default(E,D);var B=hn(E);function E(T,$,U){var P;return re.default(this,E),P=B.call(this,$),P.status=T,P.description=$,P.body=U,P}return E}(kt);function Dr(D){var B=qo();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function qo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ni=function(D){_e.default(E,D);var B=Dr(E);function E(T){return re.default(this,E),B.call(this,T)}return E}(kt),Mn=2e4;function js(D){return D>=200&&D<300}function te(D){return D&&D.header&&D.header.http_status}function ue(D){var B=D.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(B){var E={protocol:B[1],host:B[2],hostname:B[3],port:B[4],pathname:B[5],search:B[6],hash:B[7],params:{}};if(E.search.length>0){var T=E.search.substring(1);E.params=T.split("&").map(function($){return $.split("=")}).reduce(function($,U){return $.hasOwnProperty(U[0])?Array.isArray($[U[0]])?$[U[0]].push(U[1]):$[U[0]]=[$[U[0]],U[1]]:$[U[0]]=U[1],$},{})}return E}throw new kt("Incorrect URI: "+D)}function I(D,B){var E=ue(B),T={method:D,host:E.host,path:E.pathname};return E.params&&(T.params=E.params),T}function O(D,B,E,T,$){return{to:I(D,B),headers:E,body:T,grant:$}}var R=function(){function D(B,E,T){re.default(this,D),this.config=T,this.transport=B,this.pendingMessages=[],this.twilsock=E}return ze.default(D,[{key:"saveMessage",value:function(E){var T=this;return new Promise(function($,U){var P={message:E,resolve:$,reject:U,alreadyRejected:!1,timeout:setTimeout(function(){et.debug("request is timed out"),U(new kt("request '".concat(E.to.method,"' to '").concat(E.to.host,"' timed out"))),P.alreadyRejected=!0},Mn)};T.pendingMessages.push(P)})}},{key:"sendPendingMessages",value:function(){for(var E=this,T=function(){var P=E.pendingMessages[0];if(!P.alreadyRejected)try{var Me=P.message;E.actualSend(Me).then(function(Ce){return P.resolve(Ce)}).catch(function(Ce){return P.reject(Ce)}),clearTimeout(P.timeout)}catch(Ce){return et.debug("Failed to send pending message",Ce),"break"}E.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var $=T();if($==="break")break}}},{key:"rejectPendingMessages",value:function(){var E=this;this.pendingMessages.forEach(function(T){T.reject(new ni("Unable to connect: "+E.twilsock.getTerminationReason)),T.alreadyRejected=!0,clearTimeout(T.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var B=Oe.default(q.default.mark(function T($){var U,P,Me,Ce,Qe,it,Pt,vn;return q.default.wrap(function(tn){for(;;)switch(tn.prev=tn.next){case 0:return P=$.to,Me=$.headers,Ce=$.body,Qe=(U=$.grant)!==null&&U!==void 0?U:this.config.activeGrant,it={host:P.host,path:P.path,method:P.method,params:P.params,headers:Me},Pt=new Re(Qe,Me["Content-Type"]||"application/json",it),et.trace("Sending upstream message",Pt),tn.next=9,this.transport.sendWithReply(Pt,Ce);case 9:if(vn=tn.sent,et.trace("Received upstream message response",vn),!(te(vn)&&!js(vn.header.http_status.code))){tn.next=13;break}throw new Pn(vn.header.http_status.code,vn.header.http_status.status,vn.body);case 13:return tn.abrupt("return",{status:vn.header.http_status,headers:vn.header.http_headers,body:vn.body});case 14:case"end":return tn.stop()}},T,this)}));function E(T){return B.apply(this,arguments)}return E}()},{key:"send",value:function(E,T){var $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},U=arguments.length>3?arguments[3]:void 0,P=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new ni("Unable to connect: "+this.twilsock.getTerminationReason));var Me=O(E,T,$,U,P);return this.twilsock.isConnected?this.actualSend(Me):this.saveMessage(Me)}}]),D}(),Z=function(){function D(){var B=this;re.default(this,D),this._promise=new Promise(function(E,T){B._resolve=E,B._reject=T})}return ze.default(D,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(E){this._resolve(E)}},{key:"set",value:function(E){this._resolve(E)}},{key:"fail",value:function(E){this._reject(E)}}]),D}(),j=function(){function D(B){re.default(this,D),this.id=B}return ze.default(D,null,[{key:"create",value:function(E){if(E instanceof Object&&"storage_id"in E)return new D(E.storage_id);throw new kt('Field "storage_id" is missing')}}]),D}(),Le=function(){function D(){return re.default(this,D),oe.default(this,"initializedFlag","twilio_twilsock_token_storage"),oe.default(this,"tokenStoragePrefix","twilio_continuation_token_"),D._instance||(this.initialize(),D._instance=this),D._instance}return ze.default(D,[{key:"sessionStorage",value:function(){try{return e.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return e.window}catch{return null}}},{key:"storeToken",value:function(E,T){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(T),E)}},{key:"getStoredToken",value:function(E){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(E)):null}},{key:"initialize",value:function(){var E=this;if(this.canStore()){var T=this.sessionStorage.getItem(this.initializedFlag);T&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var $=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){$(E.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var E=[],T=0;T<this.sessionStorage.length;T++){var $=this.sessionStorage.key(T);$&&$.indexOf(this.tokenStoragePrefix)===0&&E.push($)}var U=this.sessionStorage.removeItem;E.forEach(function(P){return U(P)}),U(this.initializedFlag)}}},{key:"getKeyName",value:function(E){return"".concat(this.tokenStoragePrefix).concat(E)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),D}();oe.default(Le,"_instance",null);var Ae=new Le,Ve=function(){function D(B,E,T,$,U,P){re.default(this,D),this.title=B,this.details=E,this.start=T,this.type=U,this.id=P,this.end=$}return ze.default(D,[{key:"toTelemetryEvent",value:function(){var E=new Date,T=this.start,$=this.end?this.end:E;if($<T){var U=$;$=T,T=U}var P=T.getTime()-E.getTime(),Me=$.getTime()-E.getTime(),Ce=new G(P,Me,this.title,this.details,this.id,this.type);return Ce}}]),D}();t.TelemetryPoint=void 0,function(D){D[D.Start=0]="Start",D[D.End=1]="End"}(t.TelemetryPoint||(t.TelemetryPoint={})),t.EventSendingLimitation=void 0,function(D){D[D.MinEventsPortion=0]="MinEventsPortion",D[D.AnyEvents=1]="AnyEvents",D[D.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(t.EventSendingLimitation||(t.EventSendingLimitation={}));var at=function(){function D(B,E){re.default(this,D),oe.default(this,"minEventsPortionToSend",50),oe.default(this,"maxEventsPortionToSend",100),oe.default(this,"pendingEvents",new Map),oe.default(this,"readyEvents",[]),oe.default(this,"hasInitializationFinished",!1),oe.default(this,"_canSendTelemetry",!1),this.config=B,this.packetInterface=E}return ze.default(D,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(E){et.debug("TelemetryTracker.canSendTelemetry: ".concat(E," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!E&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=E,E&&this.sendTelemetry(t.EventSendingLimitation.AnyEvents),E&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(E){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(E)}},{key:"addPartialEvent",value:function(E,T,$){et.debug("Adding ".concat($===t.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(T,"' event"));var U=this.pendingEvents.has(T);if($===t.TelemetryPoint.Start)U&&et.debug("Overwriting starting point for '".concat(T,"' event")),this.pendingEvents.set(T,E);else{if(!U){et.info("Could not find started event for '".concat(T,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(T),E)),this.pendingEvents.delete(T)}}},{key:"getTelemetryToSend",value:function(E){return!this.canSendTelemetry||this.readyEvents.length==0?[]:E==t.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(E==t.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(E){var T=this,$=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),U=this.readyEvents.splice(0,$);return E&&U.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(P,Me){if(!(U.length>=T.maxEventsPortionToSend)){var Ce=T.pendingEvents.get(Me);T.pendingEvents.delete(Me),U.push(new Ve("[UNFINISHED] ".concat(Ce.title),Ce.details,Ce.start,null,Ce.type,Ce.id))}}),U}},{key:"merge",value:function(E,T){return new Ve(T.title?T.title:E.title,T.details?T.details:E.details,E.start,T.end,T.type?T.type:E.type,T.id?T.id:E.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(t.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(E){var T=this.getTelemetryToSend(E);if(T.length!==0)try{this.packetInterface.send(new de(T.map(function($){return $.toTelemetryEvent()})))}catch($){et.debug("Error while sending ".concat(T.length," telemetry events due to ").concat($,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(T)}}}]),D}();function Tt(D){var B=Br();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Br(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Nn=function D(){re.default(this,D)};oe.default(Nn,"TWILSOCK_CONNECT","twilsock.sdk.connect"),oe.default(Nn,"TWILSOCK_INIT","twilsock.sdk.init"),t.TwilsockClient=function(D){_e.default(E,D);var B=Tt(E);function E(T,$,U){var P;re.default(this,E),P=B.call(this),oe.default(V.default(P),"version",Mr),oe.default(V.default(P),"offlineStorageDeferred",new Z),U.continuationToken=U.continuationToken?U.continuationToken:Ae.getStoredToken($);var Me=P.config=new Fr(T,$,U);et.setLevel(Me.logLevel);var Ce=new Vn(Me.url),Qe=new Ui(Ce,Me);return P.channel=new gi(Ce,Qe,Me),P.registrations=new Ho(Qe),P.upstream=new R(Qe,P.channel,Me),P.telemetryTracker=new at(Me,Qe),P.channel.on("initialized",function(){return P.telemetryTracker.canSendTelemetry=!0}),Ce.on("disconnected",function(){return P.telemetryTracker.canSendTelemetry=!1}),P.registrations.on("registered",function(it){return P.emit("registered",it)}),P.channel.on("message",function(it,Pt){return setTimeout(function(){return P.emit("message",it,Pt)},0)}),P.channel.on("stateChanged",function(it){return setTimeout(function(){return P.emit("stateChanged",it)},0)}),P.channel.on("connectionError",function(it){return setTimeout(function(){return P.emit("connectionError",it)},0)}),P.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return P.emit("tokenAboutToExpire")},0)}),P.channel.on("tokenExpired",function(){return setTimeout(function(){return P.emit("tokenExpired")},0)}),P.channel.on("connected",function(){return P.registrations.updateRegistrations()}),P.channel.on("connected",function(){return P.upstream.sendPendingMessages()}),P.channel.on("connected",function(){return setTimeout(function(){return P.emit("connected")},0)}),P.channel.on("beforeConnect",function(){return P.telemetryTracker.addPartialEvent(new Ve("Establish WebSocket connection","",new Date),Nn.TWILSOCK_CONNECT,t.TelemetryPoint.Start)}),P.channel.on("connected",function(){return P.telemetryTracker.addPartialEvent(new Ve("Establish WebSocket connection","",new Date,new Date),Nn.TWILSOCK_CONNECT,t.TelemetryPoint.End)}),P.channel.on("beforeSendInit",function(){return P.telemetryTracker.addPartialEvent(new Ve("Send Twilsock init","",new Date),Nn.TWILSOCK_INIT,t.TelemetryPoint.Start)}),P.channel.on("initialized",function(){return P.telemetryTracker.addPartialEvent(new Ve("Send Twilsock init","Succeeded",new Date,new Date),Nn.TWILSOCK_INIT,t.TelemetryPoint.End)}),P.channel.on("sendInitFailed",function(){return P.telemetryTracker.addPartialEvent(new Ve("Send Twilsock init","Failed",new Date,new Date),Nn.TWILSOCK_INIT,t.TelemetryPoint.End)}),P.channel.on("initialized",function(it){P.handleStorageId($,it),Ae.storeToken(it.continuationToken,$),setTimeout(function(){return P.emit("initialized",it)},0)}),P.channel.on("disconnected",function(){return setTimeout(function(){return P.emit("disconnected")},0)}),P.channel.on("disconnected",function(){return P.upstream.rejectPendingMessages()}),P.channel.on("disconnected",function(){return P.offlineStorageDeferred.fail(new kt("Client disconnected"))}),P.offlineStorageDeferred.promise.catch(function(){}),P}return ze.default(E,[{key:"emit",value:function($){for(var U,P=arguments.length,Me=new Array(P>1?P-1:0),Ce=1;Ce<P;Ce++)Me[Ce-1]=arguments[Ce];return et.debug("Emitting ".concat($.toString(),"(").concat(Me.map(function(Qe){return JSON.stringify(Qe)}).join(", "),")")),(U=xe.default(Te.default(E.prototype),"emit",this)).call.apply(U,[this,$].concat(Me))}},{key:"handleStorageId",value:function($,U){if(!U.offlineStorage)this.offlineStorageDeferred.fail(new kt("No offline storage id"));else if(U.offlineStorage.hasOwnProperty($))try{this.offlineStorageDeferred.set(j.create(U.offlineStorage[$])),et.debug("Offline storage for '".concat($,"' product: ").concat(JSON.stringify(U.offlineStorage[$]),"."))}catch(P){this.offlineStorageDeferred.fail(new kt("Failed to parse offline storage for ".concat($," ").concat(JSON.stringify(U.offlineStorage[$]),". ").concat(P,".")))}else this.offlineStorageDeferred.fail(new kt("No offline storage id for '".concat($,"' product: ").concat(JSON.stringify(U.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var T=Oe.default(q.default.mark(function U(P){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(et.trace("updating token '".concat(P,"'")),this.config.token!==P){Ce.next=3;break}return Ce.abrupt("return");case 3:return this.config.updateToken(P),Ce.next=6,this.channel.updateToken(P);case 6:return Ce.abrupt("return",Ce.sent);case 7:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"setNotificationsContext",value:function(){var T=Oe.default(q.default.mark(function U(P,Me){return q.default.wrap(function(Qe){for(;;)switch(Qe.prev=Qe.next){case 0:return Qe.next=2,this.registrations.setNotificationsContext(P,Me);case 2:case"end":return Qe.stop()}},U,this)}));function $(U,P){return T.apply(this,arguments)}return $}()},{key:"removeNotificationsContext",value:function(){var T=Oe.default(q.default.mark(function U(P){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:return Ce.next=2,this.registrations.removeNotificationsContext(P);case 2:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var T=Oe.default(q.default.mark(function U(){return q.default.wrap(function(Me){for(;;)switch(Me.prev=Me.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEventsIncludingUnfinished),Me.next=3,this.channel.disconnect();case 3:return Me.abrupt("return",Me.sent);case 4:case"end":return Me.stop()}},U,this)}));function $(){return T.apply(this,arguments)}return $}()},{key:"get",value:function(){var T=Oe.default(q.default.mark(function U(P,Me,Ce){return q.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),it.next=3,this.upstream.send("GET",P,Me,void 0,Ce);case 3:return it.abrupt("return",it.sent);case 4:case"end":return it.stop()}},U,this)}));function $(U,P,Me){return T.apply(this,arguments)}return $}()},{key:"post",value:function(){var T=Oe.default(q.default.mark(function U(P,Me,Ce,Qe){return q.default.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Pt.next=3,this.upstream.send("POST",P,Me,Ce,Qe);case 3:return Pt.abrupt("return",Pt.sent);case 4:case"end":return Pt.stop()}},U,this)}));function $(U,P,Me,Ce){return T.apply(this,arguments)}return $}()},{key:"put",value:function(){var T=Oe.default(q.default.mark(function U(P,Me,Ce,Qe){return q.default.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Pt.next=3,this.upstream.send("PUT",P,Me,Ce,Qe);case 3:return Pt.abrupt("return",Pt.sent);case 4:case"end":return Pt.stop()}},U,this)}));function $(U,P,Me,Ce){return T.apply(this,arguments)}return $}()},{key:"delete",value:function(){var T=Oe.default(q.default.mark(function U(P,Me,Ce,Qe){return q.default.wrap(function(Pt){for(;;)switch(Pt.prev=Pt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Pt.next=3,this.upstream.send("DELETE",P,Me,Ce,Qe);case 3:return Pt.abrupt("return",Pt.sent);case 4:case"end":return Pt.stop()}},U,this)}));function $(U,P,Me,Ce){return T.apply(this,arguments)}return $}()},{key:"addTelemetryEvent",value:function($){this.telemetryTracker.addTelemetryEvent($),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function($,U,P){this.telemetryTracker.addPartialEvent($,U,P),P===t.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),E}(je),t.TwilsockClient=M([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Xe("design:paramtypes",[String,String,Object])],t.TwilsockClient);var kn=function(){function D(B){re.default(this,D),this.product=B,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return ze.default(D,[{key:"populateInitRegistrations",value:function(E){var T=new Set(this.message_types);for(var $ in E)T.add(E[$]);this.message_types=Array.from(T)}}]),D}();t.InitRegistration=kn,t.TelemetryEventDescription=Ve,t.TelemetryTracker=at,t.TransportUnavailableError=ni,t.Twilsock=t.TwilsockClient,t.TwilsockError=kt})(II);/*
@@ -1151,7 +1151,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1151
1151
  THIS SOFTWARE.
1152
1152
 
1153
1153
  */Object.defineProperty(zn,"__esModule",{value:!0});var jee=Pu,Uee=aa,Fee=Aa,Bee=gs,zee=na,Hee=ia,qee=li,Vee=ys,Wee=zu,Zee=ui,Ge=wn,Ap=II,Gee=wd,Kee=Hu,Jee=od,AI=sa,OI=hd,Yee=ep,Qee=zb;function Xn(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}function Jb(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var tt=Xn(jee),hr=Xn(Uee),wr=Xn(Fee),la=Xn(Bee),In=Xn(zee),xs=Xn(Hee),Kr=Xn(qee),Sr=Xn(Vee),fe=Xn(Wee),PI=Xn(Zee),Xee=Xn(Gee),ete=Jb(Kee),MI=Xn(Jee),tte=Jb(OI),kd=Xn(Yee),Op=Jb(Qee);function vr(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,s;if((typeof Reflect>"u"?"undefined":PI.default(Reflect))==="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(s=t[o])&&(a=(i<3?s(a):i>3?s(e,r,a):s(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function Je(t,e){if((typeof Reflect>"u"?"undefined":PI.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}var rte;function Is(){}Is.prototype=Object.create(null);function $r(){$r.init.call(this)}$r.EventEmitter=$r,$r.usingDomains=!1,$r.prototype.domain=void 0,$r.prototype._events=void 0,$r.prototype._maxListeners=void 0,$r.defaultMaxListeners=10,$r.init=function(){this.domain=null,$r.usingDomains&&rte.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new Is,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},$r.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function NI(t){return t._maxListeners===void 0?$r.defaultMaxListeners:t._maxListeners}$r.prototype.getMaxListeners=function(){return NI(this)};function nte(t,e,r){if(e)t.call(r);else for(var n=t.length,i=Sd(t,n),a=0;a<n;++a)i[a].call(r)}function ite(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=Sd(t,i),s=0;s<i;++s)a[s].call(r,n)}function ate(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=Sd(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function ste(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=Sd(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function ote(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=Sd(t,i),s=0;s<i;++s)a[s].apply(r,n)}$r.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:nte(n,d,this);break;case 2:ite(n,d,this,arguments[1]);break;case 3:ate(n,d,this,arguments[1],arguments[2]);break;case 4:ste(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];ote(n,d,this,a)}return!0};function LI(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new Is,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=NI(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,ute(o)}return t}function ute(t){typeof console.warn=="function"?console.warn(t):console.log(t)}$r.prototype.addListener=function(e,r){return LI(this,e,r,!1)},$r.prototype.on=$r.prototype.addListener,$r.prototype.prependListener=function(e,r){return LI(this,e,r,!0)};function DI(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}$r.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,DI(this,e,r)),this},$r.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,DI(this,e,r)),this},$r.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new Is:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new Is,this;delete i[e]}else lte(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},$r.prototype.off=function(t,e){return this.removeListener(t,e)},$r.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new Is,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new Is:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new Is,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},$r.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=cte(r):n=[]):n=[],n},$r.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):jI.call(t,e)},$r.prototype.listenerCount=jI;function jI(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}$r.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function lte(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function Sd(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function cte(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}var il=function(){function t(e){hr.default(this,t),this.base=e,this.args=new Array,this.paths=new Array}return wr.default(t,[{key:"pathSegment",value:function(r){return this.paths.push(encodeURIComponent(r)),this}},{key:"queryParam",value:function(r,n){return typeof n<"u"&&this.args.push(encodeURIComponent(r)+"="+encodeURIComponent(n)),this}},{key:"build",value:function(){var r=this.base;return this.paths.length&&(r+="/"+this.paths.join("/")),this.args.length&&(r+="?"+this.args.join("&")),r}}]),t}();function UI(t){var e=dte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return xs.default(this,i)}}function dte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Hn=function(t){In.default(r,t);var e=UI(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return hr.default(this,r),i=e.call(this),i.name=i.constructor.name,i.message="".concat(n," (status: ").concat(a,", code: ").concat(s,")"),i.status=a,i.code=s,i}return r}(Xee.default(Error)),fte=function(t){In.default(r,t);var e=UI(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;return hr.default(this,r),i=e.call(this,n,a,s),i.body=o,i}return r}(Hn);function Ni(t){return JSON.parse(JSON.stringify(t))}function FI(t){var e=t===void 0||Yb(t);if(!e)throw new Hn("Invalid pageSize parameter. Expected a positive integer, was '".concat(t,"'."),400,20007)}function hte(t){return!isNaN(parseInt(t))&&isFinite(t)}function Yb(t){return hte(t)&&t>0}var al=ete.getLogger("twilio-sync");function $d(t,e){return["".concat(new Date().toISOString()," Sync ").concat(t,":")].concat(Array.from(e))}var gr={setLevel:function(e){al.setLevel(e)},trace:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];al.trace.apply(null,$d("T",r))},debug:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];al.debug.apply(null,$d("D",r))},info:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];al.info.apply(null,$d("I",r))},warn:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];al.warn.apply(null,$d("W",r))},error:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];al.error.apply(null,$d("E",r))}},pte="/v4/Subscriptions",vte="/v3/Maps",mte="/v3/Lists",gte="/v3/Documents",yte="/v3/Streams",bte="/v3/Insights";function wte(t,e,r){return t&&typeof t[e]<"u"?t[e]:r}var _te=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hr.default(this,t);var r=e.region||"us1",n="https://cds.".concat(r,".twilio.com"),i=e.cdsUri||n;this.settings={subscriptionsUri:i+pte,documentsUri:i+gte,listsUri:i+mte,mapsUri:i+vte,streamsUri:i+yte,insightsUri:i+bte,sessionStorageEnabled:wte(e.Sync,"enableSessionStorage",!0),productId:e.productId}}return wr.default(t,[{key:"subscriptionsUri",get:function(){return this.settings.subscriptionsUri}},{key:"documentsUri",get:function(){return this.settings.documentsUri}},{key:"listsUri",get:function(){return this.settings.listsUri}},{key:"mapsUri",get:function(){return this.settings.mapsUri}},{key:"streamsUri",get:function(){return this.settings.streamsUri}},{key:"insightsUri",get:function(){return this.settings.insightsUri}},{key:"backoffConfig",get:function(){return this.settings.backoffConfig||{}}},{key:"sessionStorageEnabled",get:function(){return this.settings.sessionStorageEnabled}},{key:"productId",get:function(){return this.settings.productId}}]),t}();function Td(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=kte(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1154
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function kte(t,e){if(t){if(typeof t=="string")return BI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return BI(t,e)}}function BI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Ste=function(){function t(e){hr.default(this,t),this.localObject=e,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return wr.default(t,[{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}},{key:"update",value:function(r,n){this.localObject._update(r,n)}},{key:"updatePending",value:function(r,n){this.pendingAction=r,this.pendingCorrelationId=n}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(r){this.rejectedWithError=r.error,this.updatePending(null,null),this.localObject.reportFailure(new Hn("Failed to subscribe on service events: ".concat(r.error.message),r.error.status,r.error.code))}},{key:"complete",value:function(r){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(r)}},{key:"setSubscriptionState",value:function(r){this.localObject._setSubscriptionState(r)}}]),t}(),$te=function(){function t(e){var r=this;hr.default(this,t),Sr.default(this,"isConnected",!1),Sr.default(this,"maxBatchSize",100),Sr.default(this,"subscriptionTtlTimer",null),Sr.default(this,"pendingPokeReason",null),this.services=e,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;var n={randomisationFactor:.2,initialDelay:100,maxDelay:2*60*1e3};this.backoff=AI.Backoff.exponential(Object.assign(n,this.services.config.backoffConfig)),this.backoff.on("ready",function(){var i=r.getSubscriptionUpdateBatch(),a=i.action,s=i.subscriptions;a?r.applyNewSubscriptionUpdateBatch(a,s):(r.backoff.reset(),gr.debug("All subscriptions resolved."))})}return wr.default(t,[{key:"getSubscriptionUpdateBatch",value:function(){function r(a,s,o,u){var l=[],c=Td(a),d;try{for(c.s();!(d=c.n()).done;){var f=MI.default(d.value,2),m=f[0],b=f[1],A=s.get(m);if(!A&&o!==b.pendingAction&&!b.rejectedWithError&&(l.push(b),u&&l.length>=u))break}}catch(N){c.e(N)}finally{c.f()}return l}var n=r(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(n.length>0)return{action:"establish",subscriptions:n};var i=r(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return i.length>0?{action:"cancel",subscriptions:i}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:function(){var e=tt.default(fe.default.mark(function n(i,a){var s=this,o,u,l,c,d,f,m,b,A,N,z,X,Ee,Ie,Be,Oe;return fe.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(this.isConnected){V.next=4;break}return gr.debug("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),V.abrupt("return");case 4:a=this.processLocalActions(i,a),o=new Date().getTime(),u=Td(a);try{for(u.s();!(l=u.n()).done;)c=l.value,this.recordActionAttemptOn(c,i,o)}catch(xe){u.e(xe)}finally{u.f()}return d=this.pendingPokeReason,this.pendingPokeReason=null,V.prev=10,V.next=13,this.request(i,o,d,a);case 13:f=V.sent,m=f.body.max_batch_size,!isNaN(parseInt(m))&&isFinite(m)&&m>0&&(this.maxBatchSize=m),this.subscriptionTtlTimer||(b=f.body.ttl_in_s,A=!isNaN(parseFloat(b))&&isFinite(b),N=A&&b>0,N&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},b*1e3))),i==="establish"&&(z=f.body.estimated_delivery_in_ms,X=!isNaN(parseFloat(z))&&isFinite(z),Ee=X&&z>0,Ee?setTimeout(function(){return s.verifyPokeDelivery(o,z,a)},z):gr.error("Invalid timeout: ".concat(z)),a.filter(function(xe){return xe.pendingCorrelationId===o}).forEach(function(xe){return xe.setSubscriptionState("response_in_flight")})),this.backoff.reset(),V.next=26;break;case 21:V.prev=21,V.t0=V.catch(10),Ie=Td(a);try{for(Ie.s();!(Be=Ie.n()).done;)Oe=Be.value,this.recordActionFailureOn(Oe,i)}catch(xe){Ie.e(xe)}finally{Ie.f()}V.t0 instanceof Ap.TransportUnavailableError?(gr.debug("Twilsock connection (required for subscription) not ready (c:".concat(o,"); waiting…")),this.backoff.reset()):(gr.debug("Failed an attempt to ".concat(i," subscriptions (c:").concat(o,"); retrying"),V.t0),this.persist());case 26:case"end":return V.stop()}},n,this,[[10,21]])}));function r(n,i){return e.apply(this,arguments)}return r}()},{key:"verifyPokeDelivery",value:function(r,n,i){var a=this,s=this.latestPokeResponseArrivalTimestampByCorrelationId.get(r),o=s?new Date().getTime()-s:n;if(o>=n)i.filter(function(l){return l.pendingCorrelationId===r}).forEach(function(l){l.updatePending(null,null),l.retryCount++,a.persisted.delete(l.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(r);else{var u=n-o;setTimeout(function(){return a.verifyPokeDelivery(r,n,i)},u)}}},{key:"processLocalActions",value:function(r,n){return r==="cancel"?n.filter(function(i){return!i.rejectedWithError}):n}},{key:"recordActionAttemptOn",value:function(r,n,i){if(r.setSubscriptionState("request_in_flight"),n==="establish")this.persisted.set(r.sid,r),r.updatePending(n,i);else{var a=this.persisted.get(r.sid);a&&a.updatePending(n,i)}}},{key:"recordActionFailureOn",value:function(r,n){r.setSubscriptionState("none"),r.updatePending(null,null),n==="establish"&&this.persisted.delete(r.sid)}},{key:"request",value:function(r,n,i,a){var s=a.map(function(l){return{object_sid:l.sid,object_type:l.type,last_event_id:r==="establish"?l.lastEventId:void 0,index_name:r==="establish"?l.indexName:void 0,query_string:r==="establish"?l.queryString:void 0}}),o=a.filter(function(l){return l.retryCount>0}).length;gr.debug("Attempting '".concat(r,"' request (c:").concat(n,"):"),s);var u={event_protocol_version:4,action:r,correlation_id:n,retried_requests:o,ttl_in_s:-1,requests:s};return i==="ttl"&&(u.reason=i),this.services.network.post(this.services.config.subscriptionsUri,u)}},{key:"add",value:function(r,n){gr.debug("Establishing intent to subscribe to ".concat(r));var i=this.subscriptions.get(r);i&&n&&i.lastEventId===n.lastEventId||(this.persisted.delete(r),this.subscriptions.set(r,new Ste(n)),this.persist())}},{key:"remove",value:function(r){gr.debug("Establishing intent to unsubscribe from ".concat(r));var n=this.subscriptions.delete(r);n&&this.persist()}},{key:"acceptMessage",value:function(r,n){gr.trace("Subscriptions received",r);var i=r.event_type,a=typeof r.events<"u"?r.events:[r.event],s=r.correlation_id;s&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(s,new Date().getTime());var o=Td(a),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,c=void 0;switch(r.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(l,s);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(l,s);break;case"subscription_failed":this.applySubscriptionFailedMessage(l,s);break;case(c=i.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:{var d=void 0;switch(c[0]){case"map_":d=l.map_sid;break;case"list_":d=l.list_sid;break;case"document_":d=l.document_sid;break;case"stream_":d=l.stream_sid;break;case"live_query_":d=l.query_id,n=!1,r.strictly_ordered===!0&&(n=!0);break;default:d=void 0}this.applyEventToSubscribedEntity(d,l,i,n);break}default:gr.debug("Dropping unknown message type ".concat(i));break}}}catch(f){o.e(f)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(r,n){var i=r.object_sid,a=this.persisted.get(r.object_sid);a&&a.pendingCorrelationId===n?r.replay_status==="interrupted"?(gr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") interrupted; continuing eagerly.")),a.updatePending(null,null),this.persisted.delete(a.sid),this.backoff.reset()):r.replay_status==="completed"&&(gr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") completed. Subscription is ready.")),a.complete(r.last_event_id),this.persisted.set(r.object_sid,a),a.setSubscriptionState("established"),this.backoff.reset()):gr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(r,n){var i=this.persisted.get(r.object_sid);i&&i.pendingCorrelationId===n?(i.updatePending(null,null),i.setSubscriptionState("none"),this.persisted.delete(r.object_sid)):gr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(r,n){var i=r.object_sid,a=this.subscriptions.get(i),s=this.persisted.get(i);a&&s?s.pendingCorrelationId===n&&(gr.error("Failed to subscribe on ".concat(s.sid),r.error),s.markAsFailed(r),s.setSubscriptionState("none")):!a&&s&&(this.persisted.delete(i),s.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(r,n,i,a){var s=this;if(r){a=a||function(){var u=s.persisted.get(r);return u&&u.isEstablished}();var o=this.subscriptions.get(r);o?(n.type=i,o.update(n,a)):gr.debug("Message dropped for SID '".concat(r,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(r){this.isConnected=r,r&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(r){gr.debug("Triggering event replay for all subscriptions, reason=".concat(r)),this.pendingPokeReason=r,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var n=[],i=Td(this.persisted.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.reset(),s.rejectedWithError&&n.push(s)}}catch(c){i.e(c)}finally{i.f()}this.persisted.clear();for(var o=0,u=n;o<u.length;o++){var l=u[o];this.persisted.set(l.sid,l)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),t}(),Tte=4e3,Ete=6e4,Cte=9e4,Rte=.2;function zI(t){if(t.body&&t.body.message)return t.body.message;switch(t.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function HI(t){return t.body?t.body.code:0}function Ed(t){return t.status===409?new fte(zI(t),t.status,HI(t),t.body):t.status?new Hn(zI(t),t.status,HI(t)):t instanceof Ap.TransportUnavailableError?t:new Hn(t.message,0,0)}var xte=function(){function t(e,r,n){hr.default(this,t),this.clientInfo=e,this.config=r,this.transport=n}return wr.default(t,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+tte.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:Tte,max:Ete,maxAttemptsTime:Cte,randomness:Rte},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(r){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return new Promise(function(a,s){var o=[502,503,504];i&&o.push(429);var u=new AI.Retrier(n.backoffConfig());u.on("attempt",function(){r().then(function(l){return u.succeeded(l)}).catch(function(l){if(o.includes(l.status)){var c=parseInt(l.headers?l.headers["Retry-After"]:null);u.failed(Ed(l),isNaN(c)?null:c*1e3)}else l.message==="Twilsock disconnected"?u.failed(Ed(l)):(u.removeAllListeners(),u.cancel(),s(Ed(l)))})}),u.on("succeeded",function(l){a(l)}),u.on("cancelled",function(l){return s(Ed(l))}),u.on("failed",function(l){return s(Ed(l))}),u.start()})}},{key:"get",value:function(r){var n=this,i=this.createHeaders();return gr.debug("GET",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.get(r,i,n.config.productId)},!0)}},{key:"post",value:function(r,n,i){var a=this,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=this.createHeaders();return typeof i<"u"&&i!==null&&(o["If-Match"]=i),gr.debug("POST",r,"ID:",o["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.post(r,o,n,a.config.productId)},s)}},{key:"put",value:function(r,n,i){var a=this,s=this.createHeaders();return typeof i<"u"&&i!==null&&(s["If-Match"]=i),gr.debug("PUT",r,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.put(r,s,n,a.config.productId)},!1)}},{key:"delete",value:function(r){var n=this,i=this.createHeaders();return gr.debug("DELETE",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(r,i,n.config.productId)},!1)}}]),t}(),Ite=function(){function t(e,r){hr.default(this,t),this.config=e,this.storageId=null;try{this.storage=r||sessionStorage}catch{}}return wr.default(t,[{key:"storageKey",value:function(r,n){return"".concat(this.storageId,"::").concat(r,"::").concat(n)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(r){this.storageId=r}},{key:"store",value:function(r,n,i){return this.isReady?this._store(this.storageKey(r,n),i):null}},{key:"read",value:function(r,n){return this.isReady?this._read(this.storageKey(r,n)):null}},{key:"remove",value:function(r,n,i){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(r,n)),i&&this.storage.removeItem(this.storageKey(r,i))}catch{}}},{key:"update",value:function(r,n,i,a){if(!this.isReady)return null;this._apply(this.storageKey(r,n),a),i&&this._apply(this.storageKey(r,i),a)}},{key:"_store",value:function(r,n){try{this.storage.setItem(r,JSON.stringify(n))}catch{}}},{key:"_read",value:function(r){try{var n=this.storage.getItem(r);if(n)return JSON.parse(n)}catch{}return null}},{key:"_apply",value:function(r,n){var i=this._read(r);if(!i)return!1;this._store(r,Object.assign(i,n))}}]),t}();function Ate(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ote(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1154
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function kte(t,e){if(t){if(typeof t=="string")return BI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return BI(t,e)}}function BI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Ste=function(){function t(e){hr.default(this,t),this.localObject=e,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return wr.default(t,[{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}},{key:"update",value:function(r,n){this.localObject._update(r,n)}},{key:"updatePending",value:function(r,n){this.pendingAction=r,this.pendingCorrelationId=n}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(r){this.rejectedWithError=r.error,this.updatePending(null,null),this.localObject.reportFailure(new Hn("Failed to subscribe on service events: ".concat(r.error.message),r.error.status,r.error.code))}},{key:"complete",value:function(r){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(r)}},{key:"setSubscriptionState",value:function(r){this.localObject._setSubscriptionState(r)}}]),t}(),$te=function(){function t(e){var r=this;hr.default(this,t),Sr.default(this,"isConnected",!1),Sr.default(this,"maxBatchSize",100),Sr.default(this,"subscriptionTtlTimer",null),Sr.default(this,"pendingPokeReason",null),this.services=e,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;var n={randomisationFactor:.2,initialDelay:100,maxDelay:2*60*1e3};this.backoff=AI.Backoff.exponential(Object.assign(n,this.services.config.backoffConfig)),this.backoff.on("ready",function(){var i=r.getSubscriptionUpdateBatch(),a=i.action,s=i.subscriptions;a?r.applyNewSubscriptionUpdateBatch(a,s):(r.backoff.reset(),gr.debug("All subscriptions resolved."))})}return wr.default(t,[{key:"getSubscriptionUpdateBatch",value:function(){function r(a,s,o,u){var l=[],c=Td(a),d;try{for(c.s();!(d=c.n()).done;){var f=MI.default(d.value,2),m=f[0],b=f[1],A=s.get(m);if(!A&&o!==b.pendingAction&&!b.rejectedWithError&&(l.push(b),u&&l.length>=u))break}}catch(N){c.e(N)}finally{c.f()}return l}var n=r(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(n.length>0)return{action:"establish",subscriptions:n};var i=r(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return i.length>0?{action:"cancel",subscriptions:i}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:function(){var e=tt.default(fe.default.mark(function n(i,a){var s=this,o,u,l,c,d,f,m,b,A,N,z,X,Ee,Ie,Fe,Oe;return fe.default.wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(this.isConnected){V.next=4;break}return gr.debug("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),V.abrupt("return");case 4:a=this.processLocalActions(i,a),o=new Date().getTime(),u=Td(a);try{for(u.s();!(l=u.n()).done;)c=l.value,this.recordActionAttemptOn(c,i,o)}catch(xe){u.e(xe)}finally{u.f()}return d=this.pendingPokeReason,this.pendingPokeReason=null,V.prev=10,V.next=13,this.request(i,o,d,a);case 13:f=V.sent,m=f.body.max_batch_size,!isNaN(parseInt(m))&&isFinite(m)&&m>0&&(this.maxBatchSize=m),this.subscriptionTtlTimer||(b=f.body.ttl_in_s,A=!isNaN(parseFloat(b))&&isFinite(b),N=A&&b>0,N&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},b*1e3))),i==="establish"&&(z=f.body.estimated_delivery_in_ms,X=!isNaN(parseFloat(z))&&isFinite(z),Ee=X&&z>0,Ee?setTimeout(function(){return s.verifyPokeDelivery(o,z,a)},z):gr.error("Invalid timeout: ".concat(z)),a.filter(function(xe){return xe.pendingCorrelationId===o}).forEach(function(xe){return xe.setSubscriptionState("response_in_flight")})),this.backoff.reset(),V.next=26;break;case 21:V.prev=21,V.t0=V.catch(10),Ie=Td(a);try{for(Ie.s();!(Fe=Ie.n()).done;)Oe=Fe.value,this.recordActionFailureOn(Oe,i)}catch(xe){Ie.e(xe)}finally{Ie.f()}V.t0 instanceof Ap.TransportUnavailableError?(gr.debug("Twilsock connection (required for subscription) not ready (c:".concat(o,"); waiting…")),this.backoff.reset()):(gr.debug("Failed an attempt to ".concat(i," subscriptions (c:").concat(o,"); retrying"),V.t0),this.persist());case 26:case"end":return V.stop()}},n,this,[[10,21]])}));function r(n,i){return e.apply(this,arguments)}return r}()},{key:"verifyPokeDelivery",value:function(r,n,i){var a=this,s=this.latestPokeResponseArrivalTimestampByCorrelationId.get(r),o=s?new Date().getTime()-s:n;if(o>=n)i.filter(function(l){return l.pendingCorrelationId===r}).forEach(function(l){l.updatePending(null,null),l.retryCount++,a.persisted.delete(l.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(r);else{var u=n-o;setTimeout(function(){return a.verifyPokeDelivery(r,n,i)},u)}}},{key:"processLocalActions",value:function(r,n){return r==="cancel"?n.filter(function(i){return!i.rejectedWithError}):n}},{key:"recordActionAttemptOn",value:function(r,n,i){if(r.setSubscriptionState("request_in_flight"),n==="establish")this.persisted.set(r.sid,r),r.updatePending(n,i);else{var a=this.persisted.get(r.sid);a&&a.updatePending(n,i)}}},{key:"recordActionFailureOn",value:function(r,n){r.setSubscriptionState("none"),r.updatePending(null,null),n==="establish"&&this.persisted.delete(r.sid)}},{key:"request",value:function(r,n,i,a){var s=a.map(function(l){return{object_sid:l.sid,object_type:l.type,last_event_id:r==="establish"?l.lastEventId:void 0,index_name:r==="establish"?l.indexName:void 0,query_string:r==="establish"?l.queryString:void 0}}),o=a.filter(function(l){return l.retryCount>0}).length;gr.debug("Attempting '".concat(r,"' request (c:").concat(n,"):"),s);var u={event_protocol_version:4,action:r,correlation_id:n,retried_requests:o,ttl_in_s:-1,requests:s};return i==="ttl"&&(u.reason=i),this.services.network.post(this.services.config.subscriptionsUri,u)}},{key:"add",value:function(r,n){gr.debug("Establishing intent to subscribe to ".concat(r));var i=this.subscriptions.get(r);i&&n&&i.lastEventId===n.lastEventId||(this.persisted.delete(r),this.subscriptions.set(r,new Ste(n)),this.persist())}},{key:"remove",value:function(r){gr.debug("Establishing intent to unsubscribe from ".concat(r));var n=this.subscriptions.delete(r);n&&this.persist()}},{key:"acceptMessage",value:function(r,n){gr.trace("Subscriptions received",r);var i=r.event_type,a=typeof r.events<"u"?r.events:[r.event],s=r.correlation_id;s&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(s,new Date().getTime());var o=Td(a),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,c=void 0;switch(r.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(l,s);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(l,s);break;case"subscription_failed":this.applySubscriptionFailedMessage(l,s);break;case(c=i.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:{var d=void 0;switch(c[0]){case"map_":d=l.map_sid;break;case"list_":d=l.list_sid;break;case"document_":d=l.document_sid;break;case"stream_":d=l.stream_sid;break;case"live_query_":d=l.query_id,n=!1,r.strictly_ordered===!0&&(n=!0);break;default:d=void 0}this.applyEventToSubscribedEntity(d,l,i,n);break}default:gr.debug("Dropping unknown message type ".concat(i));break}}}catch(f){o.e(f)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(r,n){var i=r.object_sid,a=this.persisted.get(r.object_sid);a&&a.pendingCorrelationId===n?r.replay_status==="interrupted"?(gr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") interrupted; continuing eagerly.")),a.updatePending(null,null),this.persisted.delete(a.sid),this.backoff.reset()):r.replay_status==="completed"&&(gr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") completed. Subscription is ready.")),a.complete(r.last_event_id),this.persisted.set(r.object_sid,a),a.setSubscriptionState("established"),this.backoff.reset()):gr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(r,n){var i=this.persisted.get(r.object_sid);i&&i.pendingCorrelationId===n?(i.updatePending(null,null),i.setSubscriptionState("none"),this.persisted.delete(r.object_sid)):gr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(r,n){var i=r.object_sid,a=this.subscriptions.get(i),s=this.persisted.get(i);a&&s?s.pendingCorrelationId===n&&(gr.error("Failed to subscribe on ".concat(s.sid),r.error),s.markAsFailed(r),s.setSubscriptionState("none")):!a&&s&&(this.persisted.delete(i),s.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(r,n,i,a){var s=this;if(r){a=a||function(){var u=s.persisted.get(r);return u&&u.isEstablished}();var o=this.subscriptions.get(r);o?(n.type=i,o.update(n,a)):gr.debug("Message dropped for SID '".concat(r,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(r){this.isConnected=r,r&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(r){gr.debug("Triggering event replay for all subscriptions, reason=".concat(r)),this.pendingPokeReason=r,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var n=[],i=Td(this.persisted.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.reset(),s.rejectedWithError&&n.push(s)}}catch(c){i.e(c)}finally{i.f()}this.persisted.clear();for(var o=0,u=n;o<u.length;o++){var l=u[o];this.persisted.set(l.sid,l)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),t}(),Tte=4e3,Ete=6e4,Cte=9e4,Rte=.2;function zI(t){if(t.body&&t.body.message)return t.body.message;switch(t.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function HI(t){return t.body?t.body.code:0}function Ed(t){return t.status===409?new fte(zI(t),t.status,HI(t),t.body):t.status?new Hn(zI(t),t.status,HI(t)):t instanceof Ap.TransportUnavailableError?t:new Hn(t.message,0,0)}var xte=function(){function t(e,r,n){hr.default(this,t),this.clientInfo=e,this.config=r,this.transport=n}return wr.default(t,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+tte.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:Tte,max:Ete,maxAttemptsTime:Cte,randomness:Rte},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(r){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return new Promise(function(a,s){var o=[502,503,504];i&&o.push(429);var u=new AI.Retrier(n.backoffConfig());u.on("attempt",function(){r().then(function(l){return u.succeeded(l)}).catch(function(l){if(o.includes(l.status)){var c=parseInt(l.headers?l.headers["Retry-After"]:null);u.failed(Ed(l),isNaN(c)?null:c*1e3)}else l.message==="Twilsock disconnected"?u.failed(Ed(l)):(u.removeAllListeners(),u.cancel(),s(Ed(l)))})}),u.on("succeeded",function(l){a(l)}),u.on("cancelled",function(l){return s(Ed(l))}),u.on("failed",function(l){return s(Ed(l))}),u.start()})}},{key:"get",value:function(r){var n=this,i=this.createHeaders();return gr.debug("GET",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.get(r,i,n.config.productId)},!0)}},{key:"post",value:function(r,n,i){var a=this,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=this.createHeaders();return typeof i<"u"&&i!==null&&(o["If-Match"]=i),gr.debug("POST",r,"ID:",o["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.post(r,o,n,a.config.productId)},s)}},{key:"put",value:function(r,n,i){var a=this,s=this.createHeaders();return typeof i<"u"&&i!==null&&(s["If-Match"]=i),gr.debug("PUT",r,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.put(r,s,n,a.config.productId)},!1)}},{key:"delete",value:function(r){var n=this,i=this.createHeaders();return gr.debug("DELETE",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(r,i,n.config.productId)},!1)}}]),t}(),Ite=function(){function t(e,r){hr.default(this,t),this.config=e,this.storageId=null;try{this.storage=r||sessionStorage}catch{}}return wr.default(t,[{key:"storageKey",value:function(r,n){return"".concat(this.storageId,"::").concat(r,"::").concat(n)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(r){this.storageId=r}},{key:"store",value:function(r,n,i){return this.isReady?this._store(this.storageKey(r,n),i):null}},{key:"read",value:function(r,n){return this.isReady?this._read(this.storageKey(r,n)):null}},{key:"remove",value:function(r,n,i){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(r,n)),i&&this.storage.removeItem(this.storageKey(r,i))}catch{}}},{key:"update",value:function(r,n,i,a){if(!this.isReady)return null;this._apply(this.storageKey(r,n),a),i&&this._apply(this.storageKey(r,i),a)}},{key:"_store",value:function(r,n){try{this.storage.setItem(r,JSON.stringify(n))}catch{}}},{key:"_read",value:function(r){try{var n=this.storage.getItem(r);if(n)return JSON.parse(n)}catch{}return null}},{key:"_apply",value:function(r,n){var i=this._read(r);if(!i)return!1;this._store(r,Object.assign(i,n))}}]),t}();function Ate(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Ote(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1155
1155
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function Ote(t,e){if(t){if(typeof t=="string")return qI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return qI(t,e)}}function qI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Cd=function(){function t(e,r){hr.default(this,t),this.services=e,this.removalHandler=r,this.subscriptionState="none",this._attachedListeners=new Map}return wr.default(t,[{key:"_advanceLastEventId",value:function(r,n){}},{key:"reportFailure",value:function(r){r.status===404?this.onRemoved(!1):this.broadcastEventToListeners("failure",r)}},{key:"_subscribe",value:function(){this.services.router._subscribe(this.sid,this)}},{key:"_unsubscribe",value:function(){this.services.router._unsubscribe(this.sid)}},{key:"_setSubscriptionState",value:function(r){this.subscriptionState=r,this.broadcastEventToListeners("_subscriptionStateChanged",r)}},{key:"close",value:function(){this._unsubscribe(),this.removalHandler!=null&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(r){var n=r.listenerUuid,i=this._attachedListeners.get(n);i||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(n,r))}},{key:"detach",value:function(r){this._attachedListeners.delete(r),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(r,n){var i=Ate(this._attachedListeners.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.emit(r,n)}}catch(o){i.e(o)}finally{i.f()}}}]),t}(),VI=function(){function t(e){hr.default(this,t),Sr.default(this,"queuedRequests",[]),Sr.default(this,"isRequestInFlight",!1),this.inputMergingFunction=e}return wr.default(t,[{key:"add",value:function(r,n){var i=this,a=new Promise(function(s,o){return i.queuedRequests.push({input:r,requestFunction:n,resolve:s,reject:o})});return this.wakeupQueue(),a}},{key:"squashAndAdd",value:function(r,n){var i=this.queuedRequests;this.queuedRequests=[];var a;i.length>0?(a=i.map(function(o){return o.input}).reduce(this.inputMergingFunction),a=this.inputMergingFunction(a,r)):a=r;var s=this.add(a,n);return i.forEach(function(o){return s.then(o.resolve,o.reject)}),s}},{key:"isEmpty",value:function(){return this.queuedRequests.length===0&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var r=this;if(!(this.queuedRequests.length===0||this.isRequestInFlight)){var n=this.queuedRequests.shift();this.isRequestInFlight=!0,n.requestFunction(n.input).then(n.resolve,n.reject).then(function(i){r.isRequestInFlight=!1,r.wakeupQueue()})}}}]),t}(),WI=function(){function t(e){hr.default(this,t),Sr.default(this,"queueByNamespaceKey",new Map),this.inputReducer=e}return wr.default(t,[{key:"add",value:function(){var e=tt.default(fe.default.mark(function n(i,a,s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(l){return l.add(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function r(n,i,a){return e.apply(this,arguments)}return r}()},{key:"squashAndAdd",value:function(){var e=tt.default(fe.default.mark(function n(i,a,s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(l){return l.squashAndAdd(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function r(n,i,a){return e.apply(this,arguments)}return r}()},{key:"invokeQueueMethod",value:function(){var e=tt.default(fe.default.mark(function n(i,a){var s,o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.queueByNamespaceKey.has(i)||this.queueByNamespaceKey.set(i,new VI(this.inputReducer)),s=this.queueByNamespaceKey.get(i),o=a(s),this.queueByNamespaceKey.get(i).isEmpty()&&this.queueByNamespaceKey.delete(i),l.abrupt("return",o);case 5:case"end":return l.stop()}},n,this)}));function r(n,i){return e.apply(this,arguments)}return r}()}]),t}();function Pte(t){var e=Mte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return xs.default(this,i)}}function Mte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Rd=function(t){In.default(r,t);var e=Pte(r);function r(){var n;return hr.default(this,r),n=e.call(this),n.closed=!1,n.uuid=OI.v4(),n}return wr.default(r,[{key:"listenerUuid",get:function(){return this.uuid}},{key:"close",value:function(){this.removeAllListeners(),this.closed=!0}},{key:"ensureNotClosed",value:function(){if(this.closed)throw new Error("Invalid operation on closed object")}}]),r}($r);function ZI(t){var e=Nte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return xs.default(this,i)}}function Nte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Qb=function(t){In.default(r,t);var e=ZI(r);function r(n,i,a){var s;hr.default(this,r),s=e.call(this,n,a),Sr.default(la.default(s),"isDeleted",!1);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new VI(o),s.descriptor=i,s.descriptor.data=s.descriptor.data||{},s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return wr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"document"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"_update",value:function(i){switch(i.date_created=new Date(i.date_created),i.type){case"document_updated":if(i.id<=this.lastEventId){gr.trace("Document update skipped, current:",this.lastEventId,", remote:",i.id);break}var a=this.descriptor.data!==void 0?Ni(this.descriptor.data):null;this.descriptor.last_event_id=i.id,this.descriptor.revision=i.document_revision,this.descriptor.date_updated=i.date_created,this.descriptor.data=i.document_data,this.broadcastEventToListeners("updated",{data:i.document_data,isLocal:!1,previousData:a}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:i.id,revision:i.document_revision,date_updated:i.date_created,data:i.document_data});break;case"document_removed":this.onRemoved(!1);break}}},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u=this,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.squashAndAdd(l,function(f){return u._setUnconditionally(s,f.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u=this,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.add(l,function(f){return u._setWithIfMatch(s,f.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(function(c){return Object.assign(c,s)},o));case 1:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this._postUpdateToServer({ttl:s});case 2:o=l.sent,this.descriptor.date_expires=o.date_expires;case 4:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_setUnconditionally",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this._postUpdateToServer({data:s,revision:void 0,ttl:o});case 2:return u=c.sent,this._handleSuccessfulUpdateResult(u),c.abrupt("return",this.descriptor.data);case 5:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_setWithIfMatch",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(u=s(Ni(this.descriptor.data)),!u){f.next=22;break}return l=this.revision,f.prev=3,f.next=6,this._postUpdateToServer({data:u,revision:l,ttl:o});case 6:return c=f.sent,this._handleSuccessfulUpdateResult(c),f.abrupt("return",this.descriptor.data);case 11:if(f.prev=11,f.t0=f.catch(3),f.t0.status!==412){f.next=19;break}return f.next=16,this._softSync();case 16:return f.abrupt("return",this._setWithIfMatch(s));case 19:throw f.t0;case 20:f.next=23;break;case 22:return f.abrupt("return",this.descriptor.data);case 23:case"end":return f.stop()}},a,this,[[3,11]])}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_handleSuccessfulUpdateResult",value:function(i){if(!(i.last_event_id<=this.descriptor.last_event_id)){var a=this.descriptor.data!==void 0?Ni(this.descriptor.data):null;this.descriptor.revision=i.revision,this.descriptor.data=i.data,this.descriptor.last_event_id=i.last_event_id,this.descriptor.date_expires=i.date_expires,this.descriptor.date_updated=new Date(i.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:i.last_event_id,revision:i.revision,date_updated:i.date_updated,data:i.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:a})}}},{key:"_postUpdateToServer",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.isDeleted){d.next=17;break}return o={data:s.data},s.ttl!==void 0&&(o.ttl=s.ttl),u=s.revision,d.prev=4,d.next=7,this.services.network.post(this.uri,o,u);case 7:return l=d.sent,d.abrupt("return",{revision:l.body.revision,data:s.data,last_event_id:l.body.last_event_id,date_updated:l.body.date_updated,date_expires:l.body.date_expires});case 11:throw d.prev=11,d.t0=d.catch(4),d.t0.status===404&&this.onRemoved(!1),d.t0;case 15:d.next=18;break;case 17:return d.abrupt("return",Promise.reject(new Hn("The Document has been removed",404,54100)));case 18:case"end":return d.stop()}},a,this,[[4,11]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_softSync",value:function(){var n=tt.default(fe.default.mark(function a(){var s=this;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.network.get(this.uri).then(function(l){var c={type:"document_updated",id:l.body.last_event_id,document_revision:l.body.revision,document_data:l.body.data,date_created:l.body.date_updated};return s._update(c),s}).catch(function(l){l.status===404?s.onRemoved(!1):gr.error("Can't get updates for ".concat(s.sid,":"),l)}));case 1:case"end":return u.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"onRemoved",value:function(i){if(!this.isDeleted){var a=this.descriptor.data!==void 0?Ni(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i,previousData:a})}}},{key:"removeDocument",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.isDeleted){o.next=6;break}return o.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),o.next=7;break;case 6:return o.abrupt("return",Promise.reject(new Hn("The Document has been removed",404,54100)));case 7:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()}],[{key:"type",get:function(){return"document"}}]),r}(Cd),ci=function(t){In.default(r,t);var e=ZI(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.syncDocumentImpl=n,i.syncDocumentImpl.attach(la.default(i)),i}return wr.default(r,[{key:"uri",get:function(){return this.syncDocumentImpl.uri}},{key:"revision",get:function(){return this.syncDocumentImpl.revision}},{key:"lastEventId",get:function(){return this.syncDocumentImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncDocumentImpl.dateExpires}},{key:"type",get:function(){return Qb.type}},{key:"sid",get:function(){return this.syncDocumentImpl.sid}},{key:"data",get:function(){return this.syncDocumentImpl.data}},{key:"dateUpdated",get:function(){return this.syncDocumentImpl.dateUpdated}},{key:"uniqueName",get:function(){return this.syncDocumentImpl.uniqueName}},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.set(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.mutate(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.update(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncDocumentImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeDocument",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){kd.default(Kr.default(r.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Qb.type}}]),r}(Rd);Sr.default(ci,"removed","removed"),Sr.default(ci,"updated","updated"),vr([Ge.validateTypesAsync(Ge.pureObject,["undefined",Ge.objectSchema("document metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object,Object]),Je("design:returntype",Promise)],ci.prototype,"set",null),vr([Ge.validateTypesAsync("function",["undefined",Ge.objectSchema("document metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Function,Object]),Je("design:returntype",Promise)],ci.prototype,"mutate",null),vr([Ge.validateTypesAsync(Ge.pureObject,["undefined",Ge.objectSchema("document metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object,Object]),Je("design:returntype",Promise)],ci.prototype,"update",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],ci.prototype,"setTtl",null);var Xb=function(){function t(e){hr.default(this,t),this.descriptor=e}return wr.default(t,[{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}},{key:"update",value:function(r,n,i,a){return this.descriptor.lastEventId=r,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.dateUpdated=a,this}},{key:"updateDateExpires",value:function(r){this.descriptor.dateExpires=r}}]),t}(),ew=function(){function t(e,r,n,i){hr.default(this,t),this.prevToken=n,this.nextToken=i,this.items=e,this.source=r}return wr.default(t,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:function(){var e=tt.default(fe.default.mark(function n(){return fe.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasNextPage){a.next=2;break}throw new Error("No next page");case 2:return a.abrupt("return",this.source(this.nextToken));case 3:case"end":return a.stop()}},n,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"prevPage",value:function(){var e=tt.default(fe.default.mark(function n(){return fe.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasPrevPage){a.next=2;break}throw new Error("No previous page");case 2:return a.abrupt("return",this.source(this.prevToken));case 3:case"end":return a.stop()}},n,this)}));function r(){return e.apply(this,arguments)}return r}()}]),t}();function Lte(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Dte(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1156
1156
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function Dte(t,e){if(t){if(typeof t=="string")return GI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return GI(t,e)}}function GI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var jte=function(){function t(e,r){hr.default(this,t),this.balanceFactor=0,this.key=e,this.value=r,this.parent=null,this.left=null,this.right=null}return wr.default(t,[{key:"isRoot",get:function(){return this.parent===null}},{key:"isLeaf",get:function(){return this.left===null&&this.right===null}},{key:"isLeftChild",get:function(){return this.parent.left===this}},{key:"update",value:function(r){this.value=r}},{key:"replace",value:function(r,n){r&&(this.left===n?this.left=n:this.right===n&&(this.right=n))}}]),t}(),Ute=function(){function t(e,r){hr.default(this,t),this.isLessThan=e||function(n,i){return n<i},this.isEqual=r||function(n,i){return n===i},this.root=null,this.count=null}return wr.default(t,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(r,n){var i=this.getNode(r);i?i.update(n):this.insert(r,n)}},{key:"insert",value:function(r,n){var i=new jte(r,n);if(this.count++,!this.root){this.root=i;return}for(var a=this.root;;)if(this.isLessThan(r,a.key))if(a.left)a=a.left;else{a.left=i;break}else if(a.right)a=a.right;else{a.right=i;break}for(i.parent=a,a=i;a.parent;){var s=a.parent,o=s.balanceFactor;if(a.isLeftChild?s.balanceFactor++:s.balanceFactor--,Math.abs(s.balanceFactor)<Math.abs(o))break;if(s.balanceFactor<-1||s.balanceFactor>1){this.rebalance(s);break}a=s}}},{key:"get",value:function(r){for(var n=this.root;n;){if(this.isEqual(r,n.key))return n.value;this.isLessThan(r,n.key)?n=n.left:n=n.right}return null}},{key:"delete",value:function(r){var n=this.getNode(r);if(!n||n.key!==r)return null;var i=n.parent,a=n.left,s=n.right;if(!!a!=!!s){var o=a||s;!i&&!o?this.root=null:i&&!o?this.root=o:(i.replace(n,null),this.rebalance(i))}else{for(var u=n.left;u.right;)u=u.right;if(n.left===u)n.isRoot?(this.root=u,u.parent=null):(n.isLeftChild?n.parent.left=u:n.parent.right=u,u.parent=n.parent),u.right=n.right,u.right.parent=u,u.balanceFactor=n.balanceFactor,n={parent:u,isLeftChild:!0};else{var l=u.parent,c=u.left;l.right=c,c&&(c.parent=l),n.isRoot?(this.root=u,u.parent=null):(n.isLeftChild?n.parent.left=u:n.parent.right=u,u.parent=n.parent),u.right=n.right,u.right.parent=u,u.left=n.left,u.left.parent=u,u.balanceFactor=n.balanceFactor,n={parent:l,isLeftChild:!1}}}for(this.count--;n.parent;){var d=n.parent,f=d.balanceFactor;if(n.isLeftChild?d.balanceFactor-=1:d.balanceFactor+=1,Math.abs(d.balanceFactor)>Math.abs(f))if(d.balanceFactor<-1||d.balanceFactor>1)if(this.rebalance(d),d.parent.balanceFactor===0)n=d.parent;else break;else break;else n=d}return null}},{key:"getNode",value:function(r){for(var n=this.root;n;){if(this.isEqual(r,n.key))return n;this.isLessThan(r,n.key)?n=n.left:n=n.right}return null}},{key:"rebalance",value:function(r){r.balanceFactor<0?r.right.balanceFactor>0?(this.rotateRight(r.right),this.rotateLeft(r)):this.rotateLeft(r):r.balanceFactor>0&&(r.left.balanceFactor<0?(this.rotateLeft(r.left),this.rotateRight(r)):this.rotateRight(r))}},{key:"rotateLeft",value:function(r){var n=r.right;r.right=n.left,n.left!==null&&(n.left.parent=r),n.parent=r.parent,n.parent===null?this.root=n:r.isLeftChild?n.parent.left=n:n.parent.right=n,n.left=r,r.parent=n,r.balanceFactor=r.balanceFactor+1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor+1-Math.max(r.balanceFactor,0)}},{key:"rotateRight",value:function(r){var n=r.left;r.left=n.right,n.right!==null&&(n.right.parent=r),n.parent=r.parent,n.parent===null?this.root=n:r.isLeftChild?n.parent.left=n:n.parent.right=n,n.right=r,r.parent=n,r.balanceFactor=r.balanceFactor-1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor-1-Math.max(r.balanceFactor,0)}},{key:Symbol.iterator,value:fe.default.mark(function e(){var r,n,i;return fe.default.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:r=Lte(this.getIterator()),s.prev=1,r.s();case 3:if((n=r.n()).done){s.next=9;break}return i=n.value,s.next=7,i;case 7:s.next=3;break;case 9:s.next=14;break;case 11:s.prev=11,s.t0=s.catch(1),r.e(s.t0);case 14:return s.prev=14,r.f(),s.finish(14);case 17:case"end":return s.stop()}},e,this,[[1,11,14,17]])})},{key:"getIterator",value:fe.default.mark(function e(){var r,n,i,a=arguments;return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:r=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(r,n.key)||r===null&&!n.left)){o.next=5;break}return o.abrupt("break",8);case 5:this.isLessThan(r,n.key)||r===null?n=n.left:n=n.right,o.next=2;break;case 8:if(n){o.next=10;break}return o.abrupt("return",null);case 10:i=!0;case 11:if(!i){o.next=29;break}return o.next=14,[n.key,n.value];case 14:if(i=!1,!n.right){o.next=21;break}for(n=n.right;n.left;)n=n.left;i=!0,o.next=27;break;case 21:if(!n.parent){o.next=26;break}i=n.parent.left===n,n=n.parent,o.next=27;break;case 26:return o.abrupt("break",37);case 27:o.next=35;break;case 29:if(!n.parent){o.next=34;break}i=n.parent.left===n,n=n.parent,o.next=35;break;case 34:return o.abrupt("break",37);case 35:o.next=11;break;case 37:return o.abrupt("return",null);case 38:case"end":return o.stop()}},e,this)})},{key:"getReverseIterator",value:fe.default.mark(function e(){var r,n,i,a=arguments;return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:r=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(r,n.key)||r===null&&!n.right)){o.next=5;break}return o.abrupt("break",8);case 5:!this.isLessThan(r,n.key)||r===null?n=n.right:n=n.left,o.next=2;break;case 8:if(n){o.next=10;break}return o.abrupt("return",null);case 10:i=!0;case 11:if(!i){o.next=29;break}return o.next=14,[n.key,n.value];case 14:if(i=!1,!n.left){o.next=21;break}for(n=n.left;n.right;)n=n.right;i=!0,o.next=27;break;case 21:if(!n.parent){o.next=26;break}i=n.parent.right===n,n=n.parent,o.next=27;break;case 26:return o.abrupt("break",37);case 27:o.next=35;break;case 29:if(!n.parent){o.next=34;break}i=n.parent.right===n,n=n.parent,o.next=35;break;case 34:return o.abrupt("break",37);case 35:o.next=11;break;case 37:return o.abrupt("return",null);case 38:case"end":return o.stop()}},e,this)})}]),t}();function Fte(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Bte(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1157
1157
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function Bte(t,e){if(t){if(typeof t=="string")return KI(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return KI(t,e)}}function KI(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var zte=function(){function t(e,r){hr.default(this,t),this.value=e,this.revision=r||0}return wr.default(t,[{key:"isValid",get:function(){return!0}}]),t}(),Hte=function(){function t(e){hr.default(this,t),this.revision=e}return wr.default(t,[{key:"isValid",get:function(){return!1}}]),t}(),tw=function(){function t(){hr.default(this,t),this.items=new Ute}return wr.default(t,[{key:"store",value:function(r,n,i){var a=this.items.get(r);return a&&a.revision>i?a.isValid?a.value:null:(this.items.set(r,new zte(n,i)),n)}},{key:"delete",value:function(r,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,a=this.items.get(r);(!a||a.revision<n||a&&i===!0)&&this.items.set(r,new Hte(n))}},{key:"isKnown",value:function(r,n){var i=this.items.get(r);return i&&i.revision>=n}},{key:"get",value:function(r){var n=this.items.get(r);return n&&n.isValid?n.value:null}},{key:"has",value:function(r){var n=this.items.get(r);return n&&n.isValid}},{key:"forEach",value:function(r){if(this.items){var n=Fte(this.items),i;try{for(n.s();!(i=n.n()).done;){var a=MI.default(i.value,2),s=a[0],o=a[1];o.isValid&&r(s,o.value)}}catch(u){n.e(u)}finally{n.f()}}}}]),t}();function JI(t){var e=qte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return xs.default(this,i)}}function qte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var rw=function(t){In.default(r,t);var e=JI(r);function r(n,i,a){var s;hr.default(this,r),s=e.call(this,n,a);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new WI(o),s.cache=new tw,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return wr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"list"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"_addOrUpdateItemOnServer",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u,l){var c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return c={data:o},l!==void 0&&(c.ttl=l),m.next=4,this.services.network.post(s,c,u);case 4:return d=m.sent,d.body.data=o,d.body.date_updated=new Date(d.body.date_updated),m.abrupt("return",d.body);case 8:case"end":return m.stop()}},a,this)}));function i(a,s,o,u){return n.apply(this,arguments)}return i}()},{key:"push",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return u=(o||{}).ttl,f.next=3,this._addOrUpdateItemOnServer(this.links.items,s,void 0,u);case 3:return l=f.sent,c=Number(l.index),this._handleItemMutated(c,l.url,l.last_event_id,l.revision,s,l.date_updated,l.date_expires,!0,!1),f.abrupt("return",this.cache.get(c));case 7:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.squashAndAdd(s,c,function(m){return l._updateItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemUnconditionally",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return l=f.sent,f.next=5,this._addOrUpdateItemOnServer(l.uri,o,void 0,u);case 5:return c=f.sent,this._handleItemMutated(s,c.url,c.last_event_id,c.revision,c.data,c.date_updated,c.date_expires,!1,!1),f.abrupt("return",this.cache.get(s));case 8:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemWithIfMatch",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l,c,d,f;return fe.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.get(s);case 2:if(l=b.sent,c=o(Ni(l.data)),!c){b.next=25;break}return d=l.revision,b.prev=6,b.next=9,this._addOrUpdateItemOnServer(l.uri,c,d,u);case 9:return f=b.sent,this._handleItemMutated(s,f.url,f.last_event_id,f.revision,f.data,f.date_updated,f.date_expires,!1,!1),b.abrupt("return",this.cache.get(s));case 14:if(b.prev=14,b.t0=b.catch(6),b.t0.status!==412){b.next=22;break}return b.next=19,this._getItemFromServer(s);case 19:return b.abrupt("return",this._updateItemWithIfMatch(s,o,u));case 22:throw b.t0;case 23:b.next=26;break;case 25:return b.abrupt("return",l);case 26:case"end":return b.stop()}},a,this,[[6,14]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.add(s,c,function(m){return l._updateItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",this.mutate(s,function(d){return Object.assign(d,o)},u));case 1:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return o=d.sent,u=Ni(o.data),d.next=6,this.services.network.delete(o.uri);case 6:l=d.sent,this._handleItemRemoved(s,l.body.last_event_id,u,new Date(l.body.date_updated),!1);case 8:case"end":return d.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=tt.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o=this.cache.get(s),!o){l.next=5;break}return l.abrupt("return",o);case 5:return l.abrupt("return",this._getItemFromServer(s));case 6:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=tt.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.queryItems({index:s});case 2:if(o=l.sent,!(o.items.length<1)){l.next=7;break}throw new Hn("No item with index ".concat(s," found"),404,54151);case 7:return l.abrupt("return",o.items[0]);case 8:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new il(this.links.items).queryParam("From",s.from).queryParam("PageSize",s.limit).queryParam("Index",s.index).queryParam("PageToken",s.pageToken).queryParam("Order",s.order).build(),m.next=4,this.services.network.get(u);case 4:return l=m.sent,c=l.body.items.map(function(b){b.date_updated=new Date(b.date_updated);var A=o.cache.get(b.index);return A?o._handleItemMutated(b.index,b.url,b.last_event_id,b.revision,b.data,b.date_updated,b.date_expires,!1,!0):o.cache.store(Number(b.index),new Xb({index:Number(b.index),uri:b.url,revision:b.revision,lastEventId:b.last_event_id,dateUpdated:b.date_updated,dateExpires:b.date_expires,data:b.data}),b.last_event_id),o.cache.get(b.index)}),d=l.body.meta,m.abrupt("return",new ew(c,function(b){return o.queryItems({pageToken:b})},d.previous_token,d.next_token));case 8:case"end":return m.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},FI(s.pageSize),s.limit=s.pageSize||s.limit||50,s.order=s.order||"asc",u.abrupt("return",this.queryItems(s));case 5:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getContext",value:function(){var n=tt.default(fe.default.mark(function a(){var s;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.context){u.next=5;break}return u.next=3,this.services.network.get(this.links.context);case 3:s=u.sent,this._updateContextIfRequired(s.body.data,s.body.last_event_id);case 5:return u.abrupt("return",this.context);case 6:case"end":return u.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return u=f.sent,l={ttl:o},f.next=6,this.services.network.post(u.uri,l);case 6:c=f.sent,u.updateDateExpires(c.body.date_expires);case 8:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}},{key:"shouldIgnoreEvent",value:function(i,a){return this.cache.isKnown(i,a)}},{key:"_update",value:function(i,a){var s=Number(i.item_index);switch(i.date_created=new Date(i.date_created),i.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(s,i.item_url,i.id,i.item_revision,i.item_data,i.date_created,void 0,i.type==="list_item_added",!0);break;case"list_item_removed":this._handleItemRemoved(s,i.id,i.item_data,i.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(i.context_data,i.id,i.date_created);break;case"list_removed":this.onRemoved(!1);break}a&&this._advanceLastEventId(i.id,i.list_revision)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i,a&&(this.descriptor.revision=a))}},{key:"_updateRootDateUpdated",value:function(i){(!this.descriptor.date_updated||i.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=i,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:i}))}},{key:"_handleItemMutated",value:function(i,a,s,o,u,l,c,d,f){if(this.shouldIgnoreEvent(i,s)){gr.trace("Item ".concat(i," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(s));return}this._updateRootDateUpdated(l);var m=this.cache.get(i);if(!m){var b=new Xb({index:i,uri:a,lastEventId:s,revision:o,data:u,dateUpdated:l,dateExpires:c});this.cache.store(i,b,s),this.emitItemMutationEvent(b,f,d);return}var A=Ni(m.data);m.update(s,o,u,l),this.cache.store(i,m,s),c!==void 0&&m.updateDateExpires(c),this.emitItemMutationEvent(m,f,!1,A)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",l={item:i,isLocal:!a};s||(l.previousItemData=o),this.broadcastEventToListeners(u,l)}},{key:"_handleItemRemoved",value:function(i,a,s,o,u){this._updateRootDateUpdated(o),this.cache.delete(i,a),this.broadcastEventToListeners("itemRemoved",{index:i,isLocal:!u,previousItemData:s})}},{key:"_handleContextUpdate",value:function(i,a,s){this._updateRootDateUpdated(s),this._updateContextIfRequired(i,a)&&this.broadcastEventToListeners("contextUpdated",{context:i,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(i,a){return!this.contextEventId||a>this.contextEventId?(this.context=i,this.contextEventId=a,!0):(gr.trace("Context update skipped, current:",this.lastEventId,", remote:",a),!1)}}],[{key:"type",get:function(){return"list"}}]),r}(Cd),Xr=function(t){In.default(r,t);var e=JI(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.syncListImpl=n,i.syncListImpl.attach(la.default(i)),i}return wr.default(r,[{key:"uri",get:function(){return this.syncListImpl.uri}},{key:"revision",get:function(){return this.syncListImpl.revision}},{key:"lastEventId",get:function(){return this.syncListImpl.lastEventId}},{key:"links",get:function(){return this.syncListImpl.links}},{key:"dateExpires",get:function(){return this.syncListImpl.dateExpires}},{key:"type",get:function(){return rw.type}},{key:"sid",get:function(){return this.syncListImpl.sid}},{key:"uniqueName",get:function(){return this.syncListImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncListImpl.dateUpdated}},{key:"push",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.push(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.set(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.mutate(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.update(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.remove(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.get(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getContext",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.getItems(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.setItemTtl(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){kd.default(Kr.default(r.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return rw.type}}]),r}(Rd);Sr.default(Xr,"itemAdded","itemAdded"),Sr.default(Xr,"itemUpdated","itemUpdated"),Sr.default(Xr,"itemRemoved","itemRemoved"),Sr.default(Xr,"removed","removed"),vr([Ge.validateTypesAsync(Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object,Object]),Je("design:returntype",Promise)],Xr.prototype,"push",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger,Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Number,Object,Object]),Je("design:returntype",Promise)],Xr.prototype,"set",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger,"function",["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Number,Function,Object]),Je("design:returntype",Promise)],Xr.prototype,"mutate",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger,Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Number,Object,Object]),Je("design:returntype",Promise)],Xr.prototype,"update",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],Xr.prototype,"remove",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],Xr.prototype,"get",null),vr([Ge.validateTypesAsync(["undefined",Ge.objectSchema("query options",{from:[Ge.nonNegativeInteger,"undefined"],pageSize:[Ge.custom(function(t){return[Yb(t),"a positive integer"]}),"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],Xr.prototype,"getItems",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],Xr.prototype,"setTtl",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger,Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number,Number]),Je("design:returntype",Promise)],Xr.prototype,"setItemTtl",null);var xd=function(){function t(e){hr.default(this,t),this.descriptor=e}return wr.default(t,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"key",get:function(){return this.descriptor.key}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"update",value:function(r,n,i,a){return this.descriptor.last_event_id=r,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.date_updated=a,this}},{key:"updateDateExpires",value:function(r){this.descriptor.date_expires=r}}]),t}();function YI(t){var e=Vte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return xs.default(this,i)}}function Vte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var nw=function(t){In.default(r,t);var e=YI(r);function r(n,i,a){var s;hr.default(this,r),s=e.call(this,n,a);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new WI(o),s.cache=new tw,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),i.items&&i.items.forEach(function(u){u.date_updated=new Date(u.date_updated),s.cache.store(u.key,new xd(u),u.last_event_id)}),s}return wr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"map"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.squashAndAdd(s,c,function(m){return l._putItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(s!=null){u.next=2;break}throw new Hn("SyncMapItem key may not be empty",400,54209);case 2:if(!this.cache.has(s)){u.next=6;break}return u.abrupt("return",this.cache.get(s));case 6:return u.abrupt("return",this._getItemFromServer(s));case 7:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=tt.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.queryItems({key:s});case 2:if(o=l.sent,!(o.items.length<1)){l.next=7;break}throw new Hn("The specified Map Item does not exist",404,54201);case 7:return l.abrupt("return",o.items[0]);case 8:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.add(s,c,function(m){return l._putItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",this.mutate(s,function(d){return Object.assign(d,o)},u));case 1:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemUnconditionally",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this._putItemToServer(s,o,void 0,u);case 2:return l=f.sent,c=l.item,this._handleItemMutated(c.key,c.url,c.last_event_id,c.revision,c.data,c.date_updated,c.date_expires,l.added,!1),f.abrupt("return",this.cache.get(c.key));case 6:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemWithIfMatch",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){var l,c,d,f,m;return fe.default.wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,this.get(s).catch(function(N){if(N.status===404)return new xd({key:s,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw N});case 2:if(l=A.sent,c=o(Ni(l.data)),!c){A.next=26;break}return d=l.revision,A.prev=6,A.next=9,this._putItemToServer(s,c,d,u);case 9:return f=A.sent,m=f.item,this._handleItemMutated(m.key,m.url,m.last_event_id,m.revision,m.data,m.date_updated,m.date_expires,f.added,!1),A.abrupt("return",this.cache.get(m.key));case 15:if(A.prev=15,A.t0=A.catch(6),A.t0.status!==412){A.next=23;break}return A.next=20,this._getItemFromServer(s);case 20:return A.abrupt("return",this._putItemWithIfMatch(s,o,u));case 23:throw A.t0;case 24:A.next=27;break;case 26:return A.abrupt("return",l);case 27:case"end":return A.stop()}},a,this,[[6,15]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemToServer",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u,l){var c,d,f,m,b;return fe.default.wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return c=new il(this.links.items).pathSegment(s).build(),d={data:o},l!==void 0&&(d.ttl=l),N.prev=3,N.next=6,this.services.network.put(c,d,u);case 6:return f=N.sent,m=f.body,m.data=o,m.date_updated=new Date(m.date_updated),b=f.status.code===201,N.abrupt("return",{added:b,item:m});case 14:throw N.prev=14,N.t0=N.catch(3),N.t0.status===404&&this.onRemoved(!1),N.t0;case 18:case"end":return N.stop()}},a,this,[[3,14]])}));function i(a,s,o,u){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return o=d.sent,u=Ni(o.data),d.next=6,this.services.network.delete(o.uri);case 6:l=d.sent,this._handleItemRemoved(s,l.body.last_event_id,u,new Date(l.body.date_updated),!1);case 8:case"end":return d.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new il(this.links.items).queryParam("From",s.from).queryParam("PageSize",s.limit).queryParam("Key",s.key).queryParam("PageToken",s.pageToken).queryParam("Order",s.order).build(),m.next=4,this.services.network.get(u);case 4:return l=m.sent,c=l.body.items.map(function(b){b.date_updated=new Date(b.date_updated);var A=o.cache.get(b.key);return A?o._handleItemMutated(b.key,b.url,b.last_event_id,b.revision,b.data,b.date_updated,b.date_expires,!1,!0):o.cache.store(b.key,new xd(b),b.last_event_id),o.cache.get(b.key)}),d=l.body.meta,m.abrupt("return",new ew(c,function(b){return o.queryItems({pageToken:b})},d.previous_token,d.next_token));case 8:case"end":return m.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},FI(s.pageSize),s.limit=s.pageSize||s.limit||50,s.order=s.order||"asc",u.abrupt("return",this.queryItems(s));case 5:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shouldIgnoreEvent",value:function(i,a){return this.cache.isKnown(i,a)}},{key:"_update",value:function(i,a){switch(i.date_created=new Date(i.date_created),i.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(i.item_key,i.item_url,i.id,i.item_revision,i.item_data,i.date_created,void 0,i.type==="map_item_added",!0);break;case"map_item_removed":this._handleItemRemoved(i.item_key,i.id,i.item_data,i.date_created,!0);break;case"map_removed":this.onRemoved(!1);break}a&&this._advanceLastEventId(i.id,i.map_revision)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i,a&&(this.descriptor.revision=a))}},{key:"_updateRootDateUpdated",value:function(i){(!this.descriptor.date_updated||i.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=i,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:i}))}},{key:"_handleItemMutated",value:function(i,a,s,o,u,l,c,d,f){if(this.shouldIgnoreEvent(i,s)){gr.trace("SyncMapItem ",i," update skipped, current:",this.lastEventId,", remote:",s);return}this._updateRootDateUpdated(l);var m=this.cache.get(i);if(!m){var b=new xd({key:i,url:a,last_event_id:s,revision:o,data:u,date_updated:l,date_expires:c});this.cache.store(i,b,s),this.emitItemMutationEvent(b,f,d);return}var A=Ni(m.data);m.update(s,o,u,l),this.cache.store(i,m,s),c!==void 0&&m.updateDateExpires(c),this.emitItemMutationEvent(m,f,!1,A)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",l={item:i,isLocal:!a};s||(l.previousItemData=o),this.broadcastEventToListeners(u,l)}},{key:"_handleItemRemoved",value:function(i,a,s,o,u){this._updateRootDateUpdated(o),this.cache.delete(i,a),this.broadcastEventToListeners("itemRemoved",{key:i,isLocal:!u,previousItemData:s})}},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return u=f.sent,l={ttl:o},f.next=6,this.services.network.post(u.uri,l);case 6:c=f.sent,u.updateDateExpires(c.body.date_expires);case 8:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()}],[{key:"type",get:function(){return"map"}}]),r}(Cd),an=function(t){In.default(r,t);var e=YI(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.syncMapImpl=n,i.syncMapImpl.attach(la.default(i)),i}return wr.default(r,[{key:"uri",get:function(){return this.syncMapImpl.uri}},{key:"links",get:function(){return this.syncMapImpl.links}},{key:"revision",get:function(){return this.syncMapImpl.revision}},{key:"lastEventId",get:function(){return this.syncMapImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncMapImpl.dateExpires}},{key:"type",get:function(){return nw.type}},{key:"sid",get:function(){return this.syncMapImpl.sid}},{key:"uniqueName",get:function(){return this.syncMapImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncMapImpl.dateUpdated}},{key:"set",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.set(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.get(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.mutate(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=tt.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.update(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.remove(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.getItems(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=tt.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.setItemTtl(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.next=3,this.syncMapImpl.removeMap();case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){kd.default(Kr.default(r.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return nw.type}}]),r}(Rd);Sr.default(an,"itemAdded","itemAdded"),Sr.default(an,"itemUpdated","itemUpdated"),Sr.default(an,"itemRemoved","itemRemoved"),Sr.default(an,"removed","removed"),vr([Ge.validateTypesAsync("string",Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[String,Object,Object]),Je("design:returntype",Promise)],an.prototype,"set",null),vr([Ge.validateTypesAsync("string"),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],an.prototype,"get",null),vr([Ge.validateTypesAsync("string","function",["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[String,Function,Object]),Je("design:returntype",Promise)],an.prototype,"mutate",null),vr([Ge.validateTypesAsync("string",Ge.pureObject,["undefined",Ge.objectSchema("item metadata",{ttl:[Ge.nonNegativeInteger,"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[String,Object,Object]),Je("design:returntype",Promise)],an.prototype,"update",null),vr([Ge.validateTypesAsync("string"),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],an.prototype,"remove",null),vr([Ge.validateTypesAsync(["undefined",Ge.objectSchema("query options",{from:["string","undefined"],pageSize:[Ge.custom(function(t){return[Yb(t),"a positive integer"]}),"undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],an.prototype,"getItems",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],an.prototype,"setTtl",null),vr([Ge.validateTypesAsync("string",Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[String,Number]),Je("design:returntype",Promise)],an.prototype,"setItemTtl",null);function QI(t){var e=Wte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return xs.default(this,i)}}function Wte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Id=function(t){In.default(r,t);var e=QI(r);function r(n,i,a){var s;return hr.default(this,r),s=e.call(this,n,a),s.descriptor=i,s}return wr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"stream"}},{key:"lastEventId",get:function(){return null}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"publishMessage",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return o={data:s},f.next=3,this.services.network.post(this.links.messages,o);case 3:return u=f.sent,l=u.body,c=this._handleMessagePublished(l.sid,s,!1),f.abrupt("return",c);case 7:case"end":return f.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"_update",value:function(i){switch(i.type){case"stream_message_published":{this._handleMessagePublished(i.message_sid,i.message_data,!0);break}case"stream_removed":{this.onRemoved(!1);break}}}},{key:"_handleMessagePublished",value:function(i,a,s){var o={sid:i,data:a};return this.broadcastEventToListeners("messagePublished",{message:o,isLocal:!s}),o}},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}}],[{key:"type",get:function(){return"stream"}}]),r}(Cd);vr([Ge.validateTypesAsync(Ge.pureObject),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],Id.prototype,"publishMessage",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],Id.prototype,"setTtl",null);var ca=function(t){In.default(r,t);var e=QI(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.syncStreamImpl=n,i.syncStreamImpl.attach(la.default(i)),i}return wr.default(r,[{key:"uri",get:function(){return this.syncStreamImpl.uri}},{key:"links",get:function(){return this.syncStreamImpl.links}},{key:"dateExpires",get:function(){return this.syncStreamImpl.dateExpires}},{key:"type",get:function(){return Id.type}},{key:"lastEventId",get:function(){return null}},{key:"sid",get:function(){return this.syncStreamImpl.sid}},{key:"uniqueName",get:function(){return this.syncStreamImpl.uniqueName}},{key:"publishMessage",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncStreamImpl.publishMessage(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncStreamImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){kd.default(Kr.default(r.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return Id.type}}]),r}(Rd);Sr.default(ca,"messagePublished","messagePublished"),Sr.default(ca,"removed","removed"),vr([Ge.validateTypesAsync(Ge.pureObject),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ca.prototype,"publishMessage",null),vr([Ge.validateTypesAsync(Ge.nonNegativeInteger),Je("design:type",Function),Je("design:paramtypes",[Number]),Je("design:returntype",Promise)],ca.prototype,"setTtl",null);var Zte=function t(e){hr.default(this,t),this.sdk="js",this.sdkVer=e,this.os=Op.os.family,this.osVer=Op.os.version,this.pl=Op.name,this.plVer=Op.version},Gte=function(){function t(){hr.default(this,t),this.names=new Map,this.entities=new Map}return wr.default(t,[{key:"store",value:function(r){var n=this.entities.get(r.sid);return n||(this.entities.set(r.sid,r),r.uniqueName&&this.names.set(r.type+"::"+r.uniqueName,r.sid),r)}},{key:"getResolved",value:function(r,n){var i=this.names.get(n+"::"+r);return i?this.entities.get(i):null}},{key:"get",value:function(r,n){return this.entities.get(r)||this.getResolved(r,n)||null}},{key:"remove",value:function(r){var n=this.entities.get(r);n&&(this.entities.delete(r),n.uniqueName&&this.names.delete(n.type+"::"+n.uniqueName))}}]),t}();function iw(t){var e=Kte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return xs.default(this,i)}}function Kte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Jte=function t(){hr.default(this,t)},aw=function(t){In.default(r,t);var e=iw(r);function r(n,i,a,s){var o;return hr.default(this,r),o=e.call(this,i,a),o.descriptor=n,o.cache=new tw,s&&s.forEach(function(u){o.cache.store(u.key,{key:u.key,value:u.data},u.revision)}),o}return wr.default(r,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return r.type}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"indexName",get:function(){return this.descriptor.indexName}},{key:"queryString",get:function(){return this.descriptor.queryExpression}},{key:"queryUri",get:function(){return this.descriptor.queryUri}},{key:"liveQueryDescriptor",get:function(){return this.descriptor}},{key:"onRemoved",value:function(){}},{key:"getItems",value:function(){var i={};return this.cache.forEach(function(a,s){i[a]=s.value}),i}},{key:"_update",value:function(i,a){switch(i.type){case"live_query_item_updated":this.handleItemMutated(i.item_key,i.item_data,i.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(i.item_key,i.item_revision);break;case"live_query_updated":this.handleBatchUpdate(i.items);break}a&&this._advanceLastEventId(i.last_event_id)}},{key:"handleItemMutated",value:function(i,a,s){if(this.shouldIgnoreEvent(i,s))gr.trace("Item ".concat(i," update skipped, revision: ").concat(s));else{var o={key:i,value:a};this.cache.store(i,o,s),this.broadcastEventToListeners("itemUpdated",o)}}},{key:"handleItemRemoved",value:function(i,a){var s=a===null;this.shouldIgnoreEvent(i,a)?gr.trace("Item ".concat(i," delete skipped, revision: ").concat(a)):(this.cache.delete(i,a,s),this.broadcastEventToListeners("itemRemoved",{key:i}))}},{key:"handleBatchUpdate",value:function(i){var a=this,s={};i!=null&&i.forEach(function(u){s[u.key]={data:u.data,revision:u.revision}}),this.cache.forEach(function(u,l){var c=s[u];c!=null?a.handleItemMutated(u,c.data,c.revision):a.handleItemRemoved(u,null),delete s[u]});for(var o in s)this.handleItemMutated(o,s[o].data,s[o].revision)}},{key:"shouldIgnoreEvent",value:function(i,a){return i!=null&&a!=null&&this.cache.isKnown(i,a)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i)}}],[{key:"type",get:function(){return"live_query"}}]),r}(Cd);function XI(t){return sw.apply(this,arguments)}function sw(){return sw=tt.default(fe.default.mark(function t(e){var r,n,i,a,s,o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(r=e.network,n=e.queryString,i=e.uri,a=e.type,n!=null){l.next=3;break}throw new Hn("Invalid query",400,54507);case 3:return s={query_string:n},a===Ha.type&&(s.type=a),l.next=7,r.post(i,s,void 0,!0);case 7:return o=l.sent,l.abrupt("return",o.body);case 9:case"end":return l.stop()}},t)})),sw.apply(this,arguments)}var Ha=function(t){In.default(r,t);var e=iw(r);function r(n){var i;return hr.default(this,r),i=e.call(this),i.liveQueryImpl=n,i.liveQueryImpl.attach(la.default(i)),i}return wr.default(r,[{key:"type",get:function(){return aw.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){kd.default(Kr.default(r.prototype),"close",this).call(this),this.liveQueryImpl.detach(this.listenerUuid)}},{key:"getItems",value:function(){return this.ensureNotClosed(),this.liveQueryImpl.getItems()}}],[{key:"type",get:function(){return aw.type}}]),r}(Rd);Sr.default(Ha,"itemUpdated","itemUpdated"),Sr.default(Ha,"itemRemoved","itemRemoved");var Ad=function(t){In.default(r,t);var e=iw(r);function r(n){var i;return hr.default(this,r),i=e.call(this),Sr.default(la.default(i),"queryExpression",null),Sr.default(la.default(i),"items",{}),Object.assign(la.default(i),n),i.updateIndexName(n.indexName),i}return wr.default(r,[{key:"type",get:function(){return r.type}},{key:"search",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.items={},l.abrupt("return",XI({network:this.network,uri:this.queryUri,queryString:s}).then(function(c){o.queryExpression=s,c.items&&c.items.forEach(function(d){o.items[d.key]=d.data}),o.emit("searchResult",o.getItems())}).catch(function(c){throw gr.error("Error '".concat(c.message,"' while executing query '").concat(s,"'")),o.queryExpression=null,c}));case 2:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"subscribe",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.queryExpression!=null){o.next=2;break}return o.abrupt("return",Promise.reject(new Hn("Invalid query",400,54507)));case 2:return o.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(i){this.indexName=i,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(i){return new il(this.insightsUri).pathSegment(i).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),r}($r);Sr.default(Ad,"searchResult","searchResult"),vr([Ge.validateTypesAsync("string"),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],Ad.prototype,"search",null),vr([Ge.validateTypes(Ge.nonEmptyString),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",void 0)],Ad.prototype,"updateIndexName",null);var Yte="3.1.0";function Qte(t){var e=Xte();return function(){var n=Kr.default(t),i;if(e){var a=Kr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return xs.default(this,i)}}function Xte(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function eA(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function tA(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?eA(Object(r),!0).forEach(function(n){Sr.default(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):eA(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}var ere="data_sync",ow=Yte;function Pp(t){if(t){if(typeof t=="string")return{id:t,mode:"open_or_create"};var e=t.mode||(t.id?"open_or_create":"create_new");return tA(tA({},t),{},{mode:e})}else return{mode:"create_new"}}var rA="com.twilio.rtd.cds.document",nA="com.twilio.rtd.cds.list",iA="com.twilio.rtd.cds.map",aA="twilio.sync.event",ei=function(t){In.default(r,t);var e=Qte(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(hr.default(this,r),i=e.call(this),!n)throw new Error("Sync library needs a valid Twilio token to be passed");a.hasOwnProperty("logLevel")?gr.setLevel(a.logLevel):gr.setLevel("silent");var s=a.productId=a.productId||ere;a.clientMetadata=a.clientMetadata||{},a.clientMetadata.hasOwnProperty("type")||(a.clientMetadata.type="sync"),a.clientMetadata.hasOwnProperty("sdk")||(a.clientMetadata.sdk="JS",a.clientMetadata.sdkv=ow);var o=!a.twilsockClient;if(!a.initRegistrations){var u=new Ap.InitRegistration(s);r.populateInitRegistrations(u),a.initRegistrations=[u]}var l=a.twilsockClient=a.twilsockClient||new Ap.Twilsock(n,s,a);l.on("tokenAboutToExpire",function(m){return i.emit("tokenAboutToExpire",m)}),l.on("tokenExpired",function(){return i.emit("tokenExpired")}),l.on("connectionError",function(m){return i.emit("connectionError",m)}),l.on("stateChanged",function(m){i.emit("connectionStateChanged",m),i.services.subscriptions.onConnectionStateChanged(m==="connected")}),l.on("message",function(m,b){return i._routeMessage(m,b)});var c=new _te(a),d=new xte(new Zte(ow),c,l),f=new Ite(c);return i.services={config:c,twilsock:l,network:d,storage:f,router:la.default(i),subscriptions:null},i.services.subscriptions=new $te(i.services),i.entities=new Gte,o&&l.connect(),i}return wr.default(r,[{key:"_routeMessage",value:function(i,a){switch(gr.trace("Notification type:",i,"content:",a),i){case rA:case nA:case iA:this.services.subscriptions.acceptMessage(a,!1);break;case aA:this.services.subscriptions.acceptMessage(a,!0);break}}},{key:"_subscribe",value:function(i,a){this.services.subscriptions.add(i,a)}},{key:"_unsubscribe",value:function(i){this.services.subscriptions.remove(i)}},{key:"connectionState",get:function(){return this.services.twilsock.state}},{key:"ensureReady",value:function(){var n=tt.default(fe.default.mark(function a(){var s;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.services.config.sessionStorageEnabled){u.next=2;break}return u.abrupt("return");case 2:return u.prev=2,u.next=5,this.services.twilsock.storageId();case 5:s=u.sent,this.services.storage.updateStorageId(s.id),u.next=12;break;case 9:u.prev=9,u.t0=u.catch(2),gr.warn("Failed to initialize storage",u.t0);case 12:case"end":return u.stop()}},a,this,[[2,9]])}));function i(){return n.apply(this,arguments)}return i}()},{key:"storeRootInSessionCache",value:function(i,a,s){if(!(!this.services.config.sessionStorageEnabled||!a)){var o=Ni(s);(i===Xr.type||i===an.type)&&(o.last_event_id=null,delete o.items),this.services.storage.store(i,a,o)}}},{key:"readRootFromSessionCache",value:function(i,a){return!this.services.config.sessionStorageEnabled||!a?null:this.services.storage.read(i,a)}},{key:"_get",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l,c,d=arguments;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(u=d.length>2&&d[2]!==void 0?d[2]:!1,o){m.next=3;break}throw new Hn("Cannot get entity without id",404);case 3:return l=new il(s).pathSegment(o).queryParam("Include",u?"items":void 0).build(),m.next=6,this.services.network.get(l);case 6:return c=m.sent,m.abrupt("return",c.body);case 8:case"end":return m.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_createDocument",value:function(i,a,s){var o={unique_name:i,data:a||{}};return s!==void 0&&(o.ttl=s),this.services.network.post(this.services.config.documentsUri,o).then(function(u){return u.body.data=o.data,u.body})}},{key:"_getDocument",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(ci.type,s)||this._get(this.services.config.documentsUri,s));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createList",value:function(i,a,s,o){var u={unique_name:i,purpose:a,context:s};return o!==void 0&&(u.ttl=o),this.services.network.post(this.services.config.listsUri,u).then(function(l){return l.body})}},{key:"_getList",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(Xr.type,s)||this._get(this.services.config.listsUri,s));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createMap",value:function(i,a){var s={unique_name:i};return a!==void 0&&(s.ttl=a),this.services.network.post(this.services.config.mapsUri,s).then(function(o){return o.body})}},{key:"_getMap",value:function(){var n=tt.default(fe.default.mark(function a(s){var o,u=arguments;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return o=u.length>1&&u[1]!==void 0?u[1]:!1,c.abrupt("return",this.readRootFromSessionCache(an.type,s)||this._get(this.services.config.mapsUri,s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getStream",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(ca.type,s)||this._get(this.services.config.streamsUri,s,!1));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createStream",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return u={unique_name:s},o!==void 0&&(u.ttl=o),d.next=4,this.services.network.post(this.services.config.streamsUri,u);case 4:return l=d.sent,d.abrupt("return",l.body);case 6:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_getLiveQuery",value:function(i){return this.readRootFromSessionCache(Ha.type,i)}},{key:"getCached",value:function(i,a){return i&&this.entities.get(i,a)||null}},{key:"removeFromCacheAndSession",value:function(i,a,s){this.entities.remove(a),this.services.config.sessionStorageEnabled&&this.services.storage.remove(i,a,s)}},{key:"document",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=Pp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createDocument(u.id,u.data,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,ci.type),!c){m.next=14;break}return m.abrupt("return",new ci(c));case 14:return m.prev=14,m.next=17,this._getDocument(u.id);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createDocument(u.id,u.data,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.document(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(ci.type,u.id,l),d=new Qb(this.services,l,function(b,A,N){return o.removeFromCacheAndSession(b,A,N)}),d=this.entities.store(d),m.abrupt("return",new ci(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"map",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=Pp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createMap(u.id,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,an.type),!c){m.next=14;break}return m.abrupt("return",new an(c));case 14:return m.prev=14,m.next=17,this._getMap(u.id,u.includeItems);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createMap(u.id,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.map(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(an.type,u.id,l),d=new nw(this.services,l,function(b,A,N){return o.removeFromCacheAndSession(b,A,N)}),d=this.entities.store(d),m.abrupt("return",new an(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"list",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=Pp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createList(u.id,u.purpose,u.context,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,Xr.type),!c){m.next=14;break}return m.abrupt("return",new Xr(c));case 14:return m.prev=14,m.next=17,this._getList(u.id);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createList(u.id,u.purpose,u.context,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.list(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(Xr.type,u.id,l),d=new rw(this.services,l,function(b,A,N){return o.removeFromCacheAndSession(b,A,N)}),d=this.entities.store(d),m.abrupt("return",new Xr(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"stream",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u,l,c,d,f;return fe.default.wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.next=2,this.ensureReady();case 2:if(u=Pp(s),u.mode!=="create_new"){b.next=9;break}return b.next=6,this._createStream(u.id,u.ttl);case 6:l=b.sent,b.next=39;break;case 9:if(c=this.getCached(u.id,ca.type),!c){b.next=14;break}return b.abrupt("return",new ca(c));case 14:return b.prev=14,b.next=17,this._getStream(u.id);case 17:l=b.sent,b.next=39;break;case 20:if(b.prev=20,b.t0=b.catch(14),!(b.t0.status!==404||u.mode==="open_existing")){b.next=26;break}throw b.t0;case 26:return b.prev=26,b.next=29,this._createStream(u.id,u.ttl);case 29:l=b.sent,b.next=39;break;case 32:if(b.prev=32,b.t1=b.catch(26),b.t1.status!==409){b.next=38;break}return b.abrupt("return",this.stream(s));case 38:throw b.t1;case 39:return this.storeRootInSessionCache(ca.type,u.id,l),d=function(N,z,X){return o.removeFromCacheAndSession(N,z,X)},f=new Id(this.services,l,d),f=this.entities.store(f),b.abrupt("return",new ca(f));case 44:case"end":return b.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shutdown",value:function(){var n=tt.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.subscriptions.shutdown();case 2:return o.next=4,this.services.twilsock.disconnect();case 4:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"updateToken",value:function(){var n=tt.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.twilsock.updateToken(s).catch(function(l){var c,d=l==null||(c=l.reply)===null||c===void 0?void 0:c.status;throw(d==null?void 0:d.code)===401&&(d==null?void 0:d.status)==="UNAUTHORIZED"?new Hn("Updated token was rejected by server",400,51130):l}));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"liveQuery",value:function(){var n=tt.default(fe.default.mark(function a(s,o){var u=this,l,c,d,f,m;return fe.default.wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,this.ensureReady();case 2:return l=new il(this.services.config.insightsUri).pathSegment(s).pathSegment("Items").build(),A.next=5,XI({network:this.services.network,uri:l,queryString:o,type:Ha.type});case 5:return c=A.sent,d=this.getCached(c.query_id,Ha.type),d||(f=this._getLiveQuery(c.query_id),f||(f={indexName:s,queryExpression:o,sid:c.query_id,queryUri:l,last_event_id:c.last_event_id}),m=function(z,X,Ee){return u.removeFromCacheAndSession(z,X,Ee)},d=new aw(f,this.services,m,c.items)),this.storeRootInSessionCache(Ha.type,c.query_id,d.liveQueryDescriptor),d=this.entities.store(d),A.abrupt("return",new Ha(d));case 11:case"end":return A.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"instantQuery",value:function(){var n=tt.default(fe.default.mark(function a(s){var o=this,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.ensureReady();case 2:return u=function(f,m){return o.liveQuery(f,m)},c.abrupt("return",new Ad({indexName:s,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:u}));case 4:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()}],[{key:"populateInitRegistrations",value:function(i){i.populateInitRegistrations([aA,rA,nA,iA])}},{key:"version",get:function(){return ow}}]),r}($r);Sr.default(ei,"connectionStateChanged","connectionStateChanged"),Sr.default(ei,"connectionError","connectionError"),Sr.default(ei,"tokenAboutToExpire","tokenAboutToExpire"),Sr.default(ei,"tokenExpired","tokenExpired"),vr([Ge.validateTypesAsync(["undefined","string",Ge.objectSchema("open document options",{id:["string","undefined"],mode:[Ge.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ge.nonNegativeInteger,"undefined"],data:[Ge.pureObject,"undefined",Ge.literal(null)]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ei.prototype,"document",null),vr([Ge.validateTypesAsync(["undefined","string",Ge.objectSchema("open map options",{id:["string","undefined"],mode:[Ge.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ge.nonNegativeInteger,"undefined"],data:[Ge.pureObject,"undefined",Ge.literal(null)],includeItems:["boolean","undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ei.prototype,"map",null),vr([Ge.validateTypesAsync(["undefined","string",Ge.objectSchema("open list options",{id:["string","undefined"],mode:[Ge.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ge.nonNegativeInteger,"undefined"],data:[Ge.pureObject,"undefined",Ge.literal(null)],purpose:["string","undefined"],context:[Ge.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ei.prototype,"list",null),vr([Ge.validateTypesAsync(["undefined","string",Ge.objectSchema("open stream options",{id:["string","undefined"],mode:[Ge.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[Ge.nonNegativeInteger,"undefined"],data:[Ge.pureObject,"undefined",Ge.literal(null)]})]),Je("design:type",Function),Je("design:paramtypes",[Object]),Je("design:returntype",Promise)],ei.prototype,"stream",null),vr([Ge.validateTypesAsync(Ge.nonEmptyString),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],ei.prototype,"updateToken",null),vr([Ge.validateTypesAsync(Ge.nonEmptyString,"string"),Je("design:type",Function),Je("design:paramtypes",[String,String]),Je("design:returntype",Promise)],ei.prototype,"liveQuery",null),vr([Ge.validateTypesAsync(Ge.nonEmptyString),Je("design:type",Function),Je("design:paramtypes",[String]),Je("design:returntype",Promise)],ei.prototype,"instantQuery",null),zn.Client=ei,zn.InsightsItem=Jte,zn.InstantQuery=Ad,zn.LiveQuery=Ha,zn.Paginator=ew,zn.SyncClient=ei,zn.SyncDocument=ci,zn.SyncList=Xr,zn.SyncListItem=Xb,zn.SyncMap=an,zn.SyncMapItem=xd,zn.SyncStream=ca;var sA={},tre=Lr,rre=Yi,nre=Rr,ire=nre("match"),are=function(t){var e;return tre(t)&&((e=t[ire])!==void 0?!!e:rre(t)==="RegExp")},sre=are,ore=TypeError,oA=function(t){if(sre(t))throw new ore("The method doesn't accept regular expressions");return t},ure=Rr,lre=ure("match"),uA=function(t){var e=/./;try{"/./"[t](e)}catch{try{return e[lre]=!1,"/./"[t](e)}catch{}}return!1},cre=er,dre=cg,fre=$a.f,hre=Ca,lA=rn,pre=oA,vre=Ii,mre=uA,gre=dre("".slice),yre=Math.min,cA=mre("startsWith"),bre=!cA&&!!function(){var t=fre(String.prototype,"startsWith");return t&&!t.writable}();cre({target:"String",proto:!0,forced:!bre&&!cA},{startsWith:function(e){var r=lA(vre(this));pre(e);var n=hre(yre(arguments.length>1?arguments[1]:void 0,r.length)),i=lA(e);return gre(r,n,n+i.length)===i}});var wre=Vt,_re=Rr,kre=Ar,dA=mk,Sre=_re("iterator"),fA=!wre(function(){var t=new URL("b?a=1&b=2&c=3","http://a"),e=t.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return t.pathname="c%20d",e.forEach(function(i,a){e.delete("b"),n+=a+i}),r.delete("a",2),r.delete("b",void 0),dA&&(!t.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b"))||!e.size&&(dA||!kre)||!e.sort||t.href!=="http://a/c%20d?a=1&c=3"||e.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!e[Sre]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://тест").host!=="xn--e1aybc"||new URL("http://a#б").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),Do=Kt,uw=2147483647,Od=36,hA=1,lw=26,$re=38,Tre=700,Ere=72,Cre=128,Rre="-",xre=/[^\0-\u007E]/,pA=/[.\u3002\uFF0E\uFF61]/g,vA="Overflow: input needs wider integers to process",cw=Od-hA,mA=RangeError,Ire=Do(pA.exec),sl=Math.floor,dw=String.fromCharCode,gA=Do("".charCodeAt),yA=Do([].join),As=Do([].push),Are=Do("".replace),Ore=Do("".split),Pre=Do("".toLowerCase),Mre=function(t){for(var e=[],r=0,n=t.length;r<n;){var i=gA(t,r++);if(i>=55296&&i<=56319&&r<n){var a=gA(t,r++);(a&64512)===56320?As(e,((i&1023)<<10)+(a&1023)+65536):(As(e,i),r--)}else As(e,i)}return e},bA=function(t){return t+22+75*(t<26)},Nre=function(t,e,r){var n=0;for(t=r?sl(t/Tre):t>>1,t+=sl(t/e);t>cw*lw>>1;)t=sl(t/cw),n+=Od;return sl(n+(cw+1)*t/(t+$re))},Lre=function(t){var e=[];t=Mre(t);var r=t.length,n=Cre,i=0,a=Ere,s,o;for(s=0;s<t.length;s++)o=t[s],o<128&&As(e,dw(o));var u=e.length,l=u;for(u&&As(e,Rre);l<r;){var c=uw;for(s=0;s<t.length;s++)o=t[s],o>=n&&o<c&&(c=o);var d=l+1;if(c-n>sl((uw-i)/d))throw new mA(vA);for(i+=(c-n)*d,n=c,s=0;s<t.length;s++){if(o=t[s],o<n&&++i>uw)throw new mA(vA);if(o===n){for(var f=i,m=Od;;){var b=m<=a?hA:m>=a+lw?lw:m-a;if(f<b)break;var A=f-b,N=Od-b;As(e,dw(bA(b+A%N))),f=sl(A/N),m+=Od}As(e,dw(bA(f))),a=Nre(i,d,l===u),i=0,l++}}i++,n++}return yA(e,"")},Dre=function(t){var e=[],r=Ore(Are(Pre(t),pA,"."),"."),n,i;for(n=0;n<r.length;n++)i=r[n],As(e,Ire(xre,i)?"xn--"+Lre(i):i);return yA(e,".")},fw=er,Mp=cr,hw=U$,Np=Er,da=Kt,Pd=Ar,wA=fA,_A=Rn,jre=ra,Ure=ip,Fre=ea,Bre=XT,pw=Jn,kA=bs,vw=Cr,zre=Vr,Hre=xa,qre=Ra,Vre=Gr,SA=Lr,An=rn,Wre=ps,$A=yo,TA=Oh,Zre=td,Lp=Dh,ol=Ig,Gre=Rr,Kre=Lb,Jre=Gre("iterator"),ul="URLSearchParams",EA=ul+"Iterator",CA=pw.set,di=pw.getterFor(ul),Yre=pw.getterFor(EA),RA=hw("fetch"),Dp=hw("Request"),Md=hw("Headers"),mw=Dp&&Dp.prototype,xA=Md&&Md.prototype,Qre=Mp.RegExp,Xre=Mp.TypeError,IA=Mp.decodeURIComponent,ene=Mp.encodeURIComponent,tne=da("".charAt),AA=da([].join),jo=da([].push),gw=da("".replace),rne=da([].shift),OA=da([].splice),PA=da("".split),nne=da("".slice),ine=/\+/g,MA=Array(4),ane=function(t){return MA[t-1]||(MA[t-1]=Qre("((?:%[\\da-f]{2}){"+t+"})","gi"))},sne=function(t){try{return IA(t)}catch{return t}},NA=function(t){var e=gw(t,ine," "),r=4;try{return IA(e)}catch{for(;r;)e=gw(e,ane(r--),sne);return e}},one=/[!'()~]|%20/g,une={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},lne=function(t){return une[t]},LA=function(t){return gw(ene(t),one,lne)},yw=Bre(function(e,r){CA(this,{type:EA,target:di(e).entries,index:0,kind:r})},ul,function(){var e=Yre(this),r=e.target,n=e.index++;if(!r||n>=r.length)return e.target=void 0,Lp(void 0,!0);var i=r[n];switch(e.kind){case"keys":return Lp(i.key,!1);case"values":return Lp(i.value,!1)}return Lp([i.key,i.value],!1)},!0),DA=function(t){this.entries=[],this.url=null,t!==void 0&&(SA(t)?this.parseObject(t):this.parseQuery(typeof t=="string"?tne(t,0)==="?"?nne(t,1):t:An(t)))};DA.prototype={type:ul,bindURL:function(t){this.url=t,this.update()},parseObject:function(t){var e=this.entries,r=Zre(t),n,i,a,s,o,u,l;if(r)for(n=TA(t,r),i=n.next;!(a=Np(i,n)).done;){if(s=TA(Vre(a.value)),o=s.next,(u=Np(o,s)).done||(l=Np(o,s)).done||!Np(o,s).done)throw new Xre("Expected sequence with length 2");jo(e,{key:An(u.value),value:An(l.value)})}else for(var c in t)zre(t,c)&&jo(e,{key:c,value:An(t[c])})},parseQuery:function(t){if(t)for(var e=this.entries,r=PA(t,"&"),n=0,i,a;n<r.length;)i=r[n++],i.length&&(a=PA(i,"="),jo(e,{key:NA(rne(a)),value:NA(AA(a,"="))}))},serialize:function(){for(var t=this.entries,e=[],r=0,n;r<t.length;)n=t[r++],jo(e,LA(n.key)+"="+LA(n.value));return AA(e,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var jp=function(){kA(this,ll);var e=arguments.length>0?arguments[0]:void 0,r=CA(this,new DA(e));Pd||(this.size=r.entries.length)},ll=jp.prototype;if(Ure(ll,{append:function(e,r){var n=di(this);ol(arguments.length,2),jo(n.entries,{key:An(e),value:An(r)}),Pd||this.length++,n.updateURL()},delete:function(t){for(var e=di(this),r=ol(arguments.length,1),n=e.entries,i=An(t),a=r<2?void 0:arguments[1],s=a===void 0?a:An(a),o=0;o<n.length;){var u=n[o];if(u.key===i&&(s===void 0||u.value===s)){if(OA(n,o,1),s!==void 0)break}else o++}Pd||(this.size=n.length),e.updateURL()},get:function(e){var r=di(this).entries;ol(arguments.length,1);for(var n=An(e),i=0;i<r.length;i++)if(r[i].key===n)return r[i].value;return null},getAll:function(e){var r=di(this).entries;ol(arguments.length,1);for(var n=An(e),i=[],a=0;a<r.length;a++)r[a].key===n&&jo(i,r[a].value);return i},has:function(e){for(var r=di(this).entries,n=ol(arguments.length,1),i=An(e),a=n<2?void 0:arguments[1],s=a===void 0?a:An(a),o=0;o<r.length;){var u=r[o++];if(u.key===i&&(s===void 0||u.value===s))return!0}return!1},set:function(e,r){var n=di(this);ol(arguments.length,1);for(var i=n.entries,a=!1,s=An(e),o=An(r),u=0,l;u<i.length;u++)l=i[u],l.key===s&&(a?OA(i,u--,1):(a=!0,l.value=o));a||jo(i,{key:s,value:o}),Pd||(this.size=i.length),n.updateURL()},sort:function(){var e=di(this);Kre(e.entries,function(r,n){return r.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var r=di(this).entries,n=Hre(e,arguments.length>1?arguments[1]:void 0),i=0,a;i<r.length;)a=r[i++],n(a.value,a.key,this)},keys:function(){return new yw(this,"keys")},values:function(){return new yw(this,"values")},entries:function(){return new yw(this,"entries")}},{enumerable:!0}),_A(ll,Jre,ll.entries,{name:"entries"}),_A(ll,"toString",function(){return di(this).serialize()},{enumerable:!0}),Pd&&jre(ll,"size",{get:function(){return di(this).entries.length},configurable:!0,enumerable:!0}),Fre(jp,ul),fw({global:!0,constructor:!0,forced:!wA},{URLSearchParams:jp}),!wA&&vw(Md)){var cne=da(xA.has),dne=da(xA.set),jA=function(t){if(SA(t)){var e=t.body,r;if(qre(e)===ul)return r=t.headers?new Md(t.headers):new Md,cne(r,"content-type")||dne(r,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Wre(t,{body:$A(0,An(e)),headers:$A(0,r)})}return t};if(vw(RA)&&fw({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return RA(e,arguments.length>1?jA(arguments[1]):{})}}),vw(Dp)){var bw=function(e){return kA(this,mw),new Dp(e,arguments.length>1?jA(arguments[1]):{})};mw.constructor=bw,bw.prototype=mw,fw({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:bw})}}var fne={URLSearchParams:jp,getState:di},hne=er,ww=Ar,pne=fA,_w=cr,UA=xa,fi=Kt,Up=Rn,hi=ra,vne=bs,kw=Vr,Sw=_I,cl=WT,Li=ta,mne=iy.codeAt,gne=Dre,qa=rn,yne=ea,bne=Ig,FA=fne,BA=Jn,wne=BA.set,Fp=BA.getterFor("URL"),_ne=FA.URLSearchParams,kne=FA.getState,Nd=_w.URL,$w=_w.TypeError,Bp=_w.parseInt,Sne=Math.floor,zA=Math.pow,pi=fi("".charAt),Di=fi(/./.exec),Ld=fi([].join),$ne=fi(1 .toString),Tne=fi([].pop),dl=fi([].push),Tw=fi("".replace),Ene=fi([].shift),Cne=fi("".split),Dd=fi("".slice),zp=fi("".toLowerCase),Rne=fi([].unshift),xne="Invalid authority",Ew="Invalid scheme",Uo="Invalid host",HA="Invalid port",qA=/[a-z]/i,Ine=/[\d+-.a-z]/i,Cw=/\d/,Ane=/^0x/i,One=/^[0-7]+$/,Pne=/^\d+$/,VA=/^[\da-f]+$/i,Mne=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Nne=/[\0\t\n\r #/:<>?@[\\\]^|]/,Lne=/^[\u0000-\u0020]+/,Dne=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,jne=/[\t\n\r]/g,vi,Une=function(t){var e=Cne(t,"."),r,n,i,a,s,o,u;if(e.length&&e[e.length-1]===""&&e.length--,r=e.length,r>4)return t;for(n=[],i=0;i<r;i++){if(a=e[i],a==="")return t;if(s=10,a.length>1&&pi(a,0)==="0"&&(s=Di(Ane,a)?16:8,a=Dd(a,s===8?1:2)),a==="")o=0;else{if(!Di(s===10?Pne:s===8?One:VA,a))return t;o=Bp(a,s)}dl(n,o)}for(i=0;i<r;i++)if(o=n[i],i===r-1){if(o>=zA(256,5-r))return null}else if(o>255)return null;for(u=Tne(n),i=0;i<n.length;i++)u+=n[i]*zA(256,3-i);return u},Fne=function(t){var e=[0,0,0,0,0,0,0,0],r=0,n=null,i=0,a,s,o,u,l,c,d,f=function(){return pi(t,i)};if(f()===":"){if(pi(t,1)!==":")return;i+=2,r++,n=r}for(;f();){if(r===8)return;if(f()===":"){if(n!==null)return;i++,r++,n=r;continue}for(a=s=0;s<4&&Di(VA,f());)a=a*16+Bp(f(),16),i++,s++;if(f()==="."){if(s===0||(i-=s,r>6))return;for(o=0;f();){if(u=null,o>0)if(f()==="."&&o<4)i++;else return;if(!Di(Cw,f()))return;for(;Di(Cw,f());){if(l=Bp(f(),10),u===null)u=l;else{if(u===0)return;u=u*10+l}if(u>255)return;i++}e[r]=e[r]*256+u,o++,(o===2||o===4)&&r++}if(o!==4)return;break}else if(f()===":"){if(i++,!f())return}else if(f())return;e[r++]=a}if(n!==null)for(c=r-n,r=7;r!==0&&c>0;)d=e[r],e[r--]=e[n+c-1],e[n+--c]=d;else if(r!==8)return;return e},Bne=function(t){for(var e=null,r=1,n=null,i=0,a=0;a<8;a++)t[a]!==0?(i>r&&(e=n,r=i),n=null,i=0):(n===null&&(n=a),++i);return i>r&&(e=n,r=i),e},jd=function(t){var e,r,n,i;if(typeof t=="number"){for(e=[],r=0;r<4;r++)Rne(e,t%256),t=Sne(t/256);return Ld(e,".")}else if(typeof t=="object"){for(e="",n=Bne(t),r=0;r<8;r++)i&&t[r]===0||(i&&(i=!1),n===r?(e+=r?":":"::",i=!0):(e+=$ne(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},Hp={},WA=Sw({},Hp,{" ":1,'"':1,"<":1,">":1,"`":1}),ZA=Sw({},WA,{"#":1,"?":1,"{":1,"}":1}),Rw=Sw({},ZA,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Os=function(t,e){var r=mne(t,0);return r>32&&r<127&&!kw(e,t)?t:encodeURIComponent(t)},qp={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Ud=function(t,e){var r;return t.length===2&&Di(qA,pi(t,0))&&((r=pi(t,1))===":"||!e&&r==="|")},GA=function(t){var e;return t.length>1&&Ud(Dd(t,0,2))&&(t.length===2||(e=pi(t,2))==="/"||e==="\\"||e==="?"||e==="#")},zne=function(t){return t==="."||zp(t)==="%2e"},Hne=function(t){return t=zp(t),t===".."||t==="%2e."||t===".%2e"||t==="%2e%2e"},xw={},KA={},Iw={},JA={},YA={},Aw={},QA={},XA={},Vp={},Wp={},Ow={},Pw={},Mw={},Nw={},e2={},Lw={},fl={},fa={},t2={},Fo={},Va={},Dw=function(t,e,r){var n=qa(t),i,a,s;if(e){if(a=this.parse(n),a)throw new $w(a);this.searchParams=null}else{if(r!==void 0&&(i=new Dw(r,!0)),a=this.parse(n,null,i),a)throw new $w(a);s=kne(new _ne),s.bindURL(this),this.searchParams=s}};Dw.prototype={type:"URL",parse:function(t,e,r){var n=this,i=e||xw,a=0,s="",o=!1,u=!1,l=!1,c,d,f,m;for(t=qa(t),e||(n.scheme="",n.username="",n.password="",n.host=null,n.port=null,n.path=[],n.query=null,n.fragment=null,n.cannotBeABaseURL=!1,t=Tw(t,Lne,""),t=Tw(t,Dne,"$1")),t=Tw(t,jne,""),c=cl(t);a<=c.length;){switch(d=c[a],i){case xw:if(d&&Di(qA,d))s+=zp(d),i=KA;else{if(e)return Ew;i=Iw;continue}break;case KA:if(d&&(Di(Ine,d)||d==="+"||d==="-"||d==="."))s+=zp(d);else if(d===":"){if(e&&(n.isSpecial()!==kw(qp,s)||s==="file"&&(n.includesCredentials()||n.port!==null)||n.scheme==="file"&&!n.host))return;if(n.scheme=s,e){n.isSpecial()&&qp[n.scheme]===n.port&&(n.port=null);return}s="",n.scheme==="file"?i=Nw:n.isSpecial()&&r&&r.scheme===n.scheme?i=JA:n.isSpecial()?i=XA:c[a+1]==="/"?(i=YA,a++):(n.cannotBeABaseURL=!0,dl(n.path,""),i=t2)}else{if(e)return Ew;s="",i=Iw,a=0;continue}break;case Iw:if(!r||r.cannotBeABaseURL&&d!=="#")return Ew;if(r.cannotBeABaseURL&&d==="#"){n.scheme=r.scheme,n.path=Li(r.path),n.query=r.query,n.fragment="",n.cannotBeABaseURL=!0,i=Va;break}i=r.scheme==="file"?Nw:Aw;continue;case JA:if(d==="/"&&c[a+1]==="/")i=Vp,a++;else{i=Aw;continue}break;case YA:if(d==="/"){i=Wp;break}else{i=fa;continue}case Aw:if(n.scheme=r.scheme,d===vi)n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=Li(r.path),n.query=r.query;else if(d==="/"||d==="\\"&&n.isSpecial())i=QA;else if(d==="?")n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=Li(r.path),n.query="",i=Fo;else if(d==="#")n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=Li(r.path),n.query=r.query,n.fragment="",i=Va;else{n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=Li(r.path),n.path.length--,i=fa;continue}break;case QA:if(n.isSpecial()&&(d==="/"||d==="\\"))i=Vp;else if(d==="/")i=Wp;else{n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,i=fa;continue}break;case XA:if(i=Vp,d!=="/"||pi(s,a+1)!=="/")continue;a++;break;case Vp:if(d!=="/"&&d!=="\\"){i=Wp;continue}break;case Wp:if(d==="@"){o&&(s="%40"+s),o=!0,f=cl(s);for(var b=0;b<f.length;b++){var A=f[b];if(A===":"&&!l){l=!0;continue}var N=Os(A,Rw);l?n.password+=N:n.username+=N}s=""}else if(d===vi||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()){if(o&&s==="")return xne;a-=cl(s).length+1,s="",i=Ow}else s+=d;break;case Ow:case Pw:if(e&&n.scheme==="file"){i=Lw;continue}else if(d===":"&&!u){if(s==="")return Uo;if(m=n.parseHost(s),m)return m;if(s="",i=Mw,e===Pw)return}else if(d===vi||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()){if(n.isSpecial()&&s==="")return Uo;if(e&&s===""&&(n.includesCredentials()||n.port!==null))return;if(m=n.parseHost(s),m)return m;if(s="",i=fl,e)return;continue}else d==="["?u=!0:d==="]"&&(u=!1),s+=d;break;case Mw:if(Di(Cw,d))s+=d;else if(d===vi||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()||e){if(s!==""){var z=Bp(s,10);if(z>65535)return HA;n.port=n.isSpecial()&&z===qp[n.scheme]?null:z,s=""}if(e)return;i=fl;continue}else return HA;break;case Nw:if(n.scheme="file",d==="/"||d==="\\")i=e2;else if(r&&r.scheme==="file")switch(d){case vi:n.host=r.host,n.path=Li(r.path),n.query=r.query;break;case"?":n.host=r.host,n.path=Li(r.path),n.query="",i=Fo;break;case"#":n.host=r.host,n.path=Li(r.path),n.query=r.query,n.fragment="",i=Va;break;default:GA(Ld(Li(c,a),""))||(n.host=r.host,n.path=Li(r.path),n.shortenPath()),i=fa;continue}else{i=fa;continue}break;case e2:if(d==="/"||d==="\\"){i=Lw;break}r&&r.scheme==="file"&&!GA(Ld(Li(c,a),""))&&(Ud(r.path[0],!0)?dl(n.path,r.path[0]):n.host=r.host),i=fa;continue;case Lw:if(d===vi||d==="/"||d==="\\"||d==="?"||d==="#"){if(!e&&Ud(s))i=fa;else if(s===""){if(n.host="",e)return;i=fl}else{if(m=n.parseHost(s),m)return m;if(n.host==="localhost"&&(n.host=""),e)return;s="",i=fl}continue}else s+=d;break;case fl:if(n.isSpecial()){if(i=fa,d!=="/"&&d!=="\\")continue}else if(!e&&d==="?")n.query="",i=Fo;else if(!e&&d==="#")n.fragment="",i=Va;else if(d!==vi&&(i=fa,d!=="/"))continue;break;case fa:if(d===vi||d==="/"||d==="\\"&&n.isSpecial()||!e&&(d==="?"||d==="#")){if(Hne(s)?(n.shortenPath(),d!=="/"&&!(d==="\\"&&n.isSpecial())&&dl(n.path,"")):zne(s)?d!=="/"&&!(d==="\\"&&n.isSpecial())&&dl(n.path,""):(n.scheme==="file"&&!n.path.length&&Ud(s)&&(n.host&&(n.host=""),s=pi(s,0)+":"),dl(n.path,s)),s="",n.scheme==="file"&&(d===vi||d==="?"||d==="#"))for(;n.path.length>1&&n.path[0]==="";)Ene(n.path);d==="?"?(n.query="",i=Fo):d==="#"&&(n.fragment="",i=Va)}else s+=Os(d,ZA);break;case t2:d==="?"?(n.query="",i=Fo):d==="#"?(n.fragment="",i=Va):d!==vi&&(n.path[0]+=Os(d,Hp));break;case Fo:!e&&d==="#"?(n.fragment="",i=Va):d!==vi&&(d==="'"&&n.isSpecial()?n.query+="%27":d==="#"?n.query+="%23":n.query+=Os(d,Hp));break;case Va:d!==vi&&(n.fragment+=Os(d,WA));break}a++}},parseHost:function(t){var e,r,n;if(pi(t,0)==="["){if(pi(t,t.length-1)!=="]"||(e=Fne(Dd(t,1,-1)),!e))return Uo;this.host=e}else if(this.isSpecial()){if(t=gne(t),Di(Mne,t)||(e=Une(t),e===null))return Uo;this.host=e}else{if(Di(Nne,t))return Uo;for(e="",r=cl(t),n=0;n<r.length;n++)e+=Os(r[n],Hp);this.host=e}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme==="file"},includesCredentials:function(){return this.username!==""||this.password!==""},isSpecial:function(){return kw(qp,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;e&&(this.scheme!=="file"||e!==1||!Ud(t[0],!0))&&t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,i=t.host,a=t.port,s=t.path,o=t.query,u=t.fragment,l=e+":";return i!==null?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=jd(i),a!==null&&(l+=":"+a)):e==="file"&&(l+="//"),l+=t.cannotBeABaseURL?s[0]:s.length?"/"+Ld(s,"/"):"",o!==null&&(l+="?"+o),u!==null&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw new $w(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if(t==="blob")try{return new hl(t.path[0]).origin}catch{return"null"}return t==="file"||!this.isSpecial()?"null":t+"://"+jd(this.host)+(e!==null?":"+e:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(qa(t)+":",xw)},getUsername:function(){return this.username},setUsername:function(t){var e=cl(qa(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=Os(e[r],Rw)}},getPassword:function(){return this.password},setPassword:function(t){var e=cl(qa(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=Os(e[r],Rw)}},getHost:function(){var t=this.host,e=this.port;return t===null?"":e===null?jd(t):jd(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,Ow)},getHostname:function(){var t=this.host;return t===null?"":jd(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,Pw)},getPort:function(){var t=this.port;return t===null?"":qa(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(t=qa(t),t===""?this.port=null:this.parse(t,Mw))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+Ld(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,fl))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){t=qa(t),t===""?this.query=null:(pi(t,0)==="?"&&(t=Dd(t,1)),this.query="",this.parse(t,Fo)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){if(t=qa(t),t===""){this.fragment=null;return}pi(t,0)==="#"&&(t=Dd(t,1)),this.fragment="",this.parse(t,Va)},update:function(){this.query=this.searchParams.serialize()||null}};var hl=function(e){var r=vne(this,On),n=bne(arguments.length,1)>1?arguments[1]:void 0,i=wne(r,new Dw(e,!1,n));ww||(r.href=i.serialize(),r.origin=i.getOrigin(),r.protocol=i.getProtocol(),r.username=i.getUsername(),r.password=i.getPassword(),r.host=i.getHost(),r.hostname=i.getHostname(),r.port=i.getPort(),r.pathname=i.getPathname(),r.search=i.getSearch(),r.searchParams=i.getSearchParams(),r.hash=i.getHash())},On=hl.prototype,mi=function(t,e){return{get:function(){return Fp(this)[t]()},set:e&&function(r){return Fp(this)[e](r)},configurable:!0,enumerable:!0}};if(ww&&(hi(On,"href",mi("serialize","setHref")),hi(On,"origin",mi("getOrigin")),hi(On,"protocol",mi("getProtocol","setProtocol")),hi(On,"username",mi("getUsername","setUsername")),hi(On,"password",mi("getPassword","setPassword")),hi(On,"host",mi("getHost","setHost")),hi(On,"hostname",mi("getHostname","setHostname")),hi(On,"port",mi("getPort","setPort")),hi(On,"pathname",mi("getPathname","setPathname")),hi(On,"search",mi("getSearch","setSearch")),hi(On,"searchParams",mi("getSearchParams")),hi(On,"hash",mi("getHash","setHash"))),Up(On,"toJSON",function(){return Fp(this).serialize()},{enumerable:!0}),Up(On,"toString",function(){return Fp(this).serialize()},{enumerable:!0}),Nd){var r2=Nd.createObjectURL,n2=Nd.revokeObjectURL;r2&&Up(hl,"createObjectURL",UA(r2,Nd)),n2&&Up(hl,"revokeObjectURL",UA(n2,Nd))}yne(hl,"URL"),hne({global:!0,constructor:!0,forced:!pne,sham:!ww},{URL:hl});/*
@@ -1170,9 +1170,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1170
1170
  OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
1171
1171
  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1172
1172
 
1173
- */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=aa,n=Aa,i=na,a=ia,s=li,o=wd,u=ys,l=Pu,c=zu,d=ui,f=Hu,m=sa,b=nn;function A(K){return K&&typeof K=="object"&&"default"in K?K:{default:K}}function N(K){if(K&&K.__esModule)return K;var he=Object.create(null);return K&&Object.keys(K).forEach(function(G){if(G!=="default"){var de=Object.getOwnPropertyDescriptor(K,G);Object.defineProperty(he,G,de.get?de:{enumerable:!0,get:function(){return K[G]}})}}),he.default=K,Object.freeze(he)}var z=A(r),X=A(n),Ee=A(i),Ie=A(a),Be=A(s),Oe=A(o),ze=A(u),V=A(l),xe=A(c),_e=A(d),se=N(f),Te={exports:{}},re=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(re){var oe=new Uint8Array(16);Te.exports=function(){return re(oe),oe}}else{var q=new Array(16);Te.exports=function(){for(var he=0,G;he<16;he++)he&3||(G=Math.random()*4294967296),q[he]=G>>>((he&3)<<3)&255;return q}}for(var ne=[],Se=0;Se<256;++Se)ne[Se]=(Se+256).toString(16).substr(1);function H(K,he){var G=he||0,de=ne;return[de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]]].join("")}var ye=H,ke=Te.exports,M=ye,Xe,Ct,rt=0,je=0;function ce(K,he,G){var de=he&&G||0,ee=he||[];K=K||{};var Ye=K.node||Xe,qe=K.clockseq!==void 0?K.clockseq:Ct;if(Ye==null||qe==null){var dt=ke();Ye==null&&(Ye=Xe=[dt[0]|1,dt[1],dt[2],dt[3],dt[4],dt[5]]),qe==null&&(qe=Ct=(dt[6]<<8|dt[7])&16383)}var lt=K.msecs!==void 0?K.msecs:new Date().getTime(),ht=K.nsecs!==void 0?K.nsecs:je+1,Rt=lt-rt+(ht-je)/1e4;if(Rt<0&&K.clockseq===void 0&&(qe=qe+1&16383),(Rt<0||lt>rt)&&K.nsecs===void 0&&(ht=0),ht>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");rt=lt,je=ht,Ct=qe,lt+=122192928e5;var xt=((lt&268435455)*1e4+ht)%4294967296;ee[de++]=xt>>>24&255,ee[de++]=xt>>>16&255,ee[de++]=xt>>>8&255,ee[de++]=xt&255;var kt=lt/4294967296*1e4&268435455;ee[de++]=kt>>>8&255,ee[de++]=kt&255,ee[de++]=kt>>>24&15|16,ee[de++]=kt>>>16&255,ee[de++]=qe>>>8|128,ee[de++]=qe&255;for(var $t=0;$t<6;++$t)ee[de+$t]=Ye[$t];return he||M(ee)}var Ke=ce,Fe=Te.exports,be=ye;function pt(K,he,G){var de=he&&G||0;typeof K=="string"&&(he=K==="binary"?new Array(16):null,K=null),K=K||{};var ee=K.random||(K.rng||Fe)();if(ee[6]=ee[6]&15|64,ee[8]=ee[8]&63|128,he)for(var Ye=0;Ye<16;++Ye)he[de+Ye]=ee[Ye];return he||be(ee)}var Ze=pt,Jt=Ke,At=Ze,Q=At;Q.v1=Jt,Q.v4=At;var Ue=Q;function ot(K){var he=Pe();return function(){var de=Be.default(K),ee;if(he){var Ye=Be.default(this).constructor;ee=Reflect.construct(de,arguments,Ye)}else ee=de.apply(this,arguments);return Ie.default(this,ee)}}function Pe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var St=function(K){Ee.default(G,K);var he=ot(G);function G(de){var ee;z.default(this,G);var Ye=Ue.v4(),qe;return ee=he.call(this,function(dt,lt){return qe=lt,de(function(ht){G.cancellationMap.delete(Ye),dt(ht)},function(ht){G.cancellationMap.delete(Ye),lt(ht)},function(ht){G.cancellationMap.set(Ye,ht)})}),ee.id=Ye,ee.rejectPromise=qe,ee}return X.default(G,[{key:"cancel",value:function(){var ee=G.cancellationMap.get(this.id);return ee==null||ee(),this.rejectPromise&&(this.catch(function(){}),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),G}(Oe.default(Promise));ze.default(St,"cancellationMap",new Map);function ut(K,he,G,de){var ee=arguments.length,Ye=ee<3?he:de===null?de=Object.getOwnPropertyDescriptor(he,G):de,qe;if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Ye=Reflect.decorate(K,he,G,de);else for(var dt=K.length-1;dt>=0;dt--)(qe=K[dt])&&(Ye=(ee<3?qe(Ye):ee>3?qe(he,G,Ye):qe(he,G))||Ye);return ee>3&&Ye&&Object.defineProperty(he,G,Ye),Ye}function or(K,he){if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(K,he)}function br(K,he){return["".concat(new Date().toISOString()," MCS Client ").concat(K,":")].concat(Array.from(he))}var et=function(){function K(he){z.default(this,K),ze.default(this,"prefix",""),this.prefix=he!=null&&he.length>0?he+" ":""}return X.default(K,[{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br(this.prefix+"T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br(this.prefix+"D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.info.apply(null,br(this.prefix+"I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.warn.apply(null,br(this.prefix+"W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.error.apply(null,br(this.prefix+"E",de))}}],[{key:"scope",value:function(G){return new K(G)}},{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br("T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br("D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.info.apply(null,br("I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.warn.apply(null,br("W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.error.apply(null,br("E",de))}}]),K}(),Mr=1e3,Fr=4e3,dr=3,fr=!0,Wt=function(he){return"https://mcs.".concat(he??"us1",".twilio.com")},Ot=function(he){return he.startsWith("http")},L=function(he,G){return"".concat(Ot(he)?"":Wt(G)).concat(he)},W=function(){function K(he,G,de,ee){var Ye,qe,dt,lt,ht,Rt;z.default(this,K);var xt=(Ye=(qe=ee.MCS)!==null&&qe!==void 0?qe:ee)!==null&&Ye!==void 0?Ye:{};this.region=(dt=(lt=xt.region)!==null&&lt!==void 0?lt:ee.region)!==null&&dt!==void 0?dt:"us1",this.mediaUrl=L(G,this.region),this.mediaSetUrl=de?L(de):"".concat(this.mediaUrl,"Set"),this.token=he,this.retryWhenThrottledOverride=(ht=xt.retryWhenThrottledOverride)!==null&&ht!==void 0?ht:fr,this.backoffConfigOverride=(Rt=xt.backoffConfigOverride)!==null&&Rt!==void 0?Rt:K.backoffConfigDefault}return X.default(K,[{key:"updateToken",value:function(G){this.token=G}}],[{key:"backoffConfigDefault",get:function(){return{min:Mr,max:Fr,maxAttemptsCount:dr}}},{key:"retryWhenThrottledDefault",get:function(){return fr}}]),K}(),ie=function(){function K(he,G,de){z.default(this,K),this.config=he,this.network=G,this._update(de)}return X.default(K,[{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}},{key:"getContentUrl",value:function(){var G=this;return new St(function(){var de=V.default(xe.default.mark(function ee(Ye,qe,dt){var lt,ht;return xe.default.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:return lt=G.network.get("".concat(G.config.mediaUrl,"/").concat(G.sid)),dt(function(){return lt.cancel()}),xt.prev=2,xt.next=5,lt;case 5:ht=xt.sent,G._update(ht.body),Ye(G.state.contentDirectUrl),xt.next=13;break;case 10:xt.prev=10,xt.t0=xt.catch(2),qe(xt.t0);case 13:case"end":return xt.stop()}},ee,null,[[2,10]])}));return function(ee,Ye,qe){return de.apply(this,arguments)}}())}},{key:"_update",value:function(G){var de,ee,Ye,qe;this.state={sid:G.sid,serviceSid:G.service_sid,channelSid:G.channel_sid,messageSid:G.message_sid,dateCreated:G.date_created?new Date(G.date_created):null,dateUploadUpdated:G.date_upload_updated?new Date(G.date_upload_updated):null,dateUpdated:G.date_updated?new Date(G.date_updated):null,size:G.size,contentType:G.content_type,author:G.author,url:G.url,contentUrl:G.links.content,contentDirectUrl:(de=G.links.content_direct_temporary)!==null&&de!==void 0?de:null,filename:(ee=G.filename)!==null&&ee!==void 0?ee:null,category:(Ye=G.category)!==null&&Ye!==void 0?Ye:"media",isMultipartUpstream:(qe=G.is_multipart_upstream)!==null&&qe!==void 0?qe:!1}}},{key:"_state",value:function(){var G;return{sid:this.state.sid,category:this.state.category,filename:(G=this.state.filename)!==null&&G!==void 0?G:null,contentType:this.state.contentType,size:this.state.size}}}]),K}();function He(K){var he=ct();return function(){var de=Be.default(K),ee;if(he){var Ye=Be.default(this).constructor;ee=Reflect.construct(de,arguments,Ye)}else ee=de.apply(this,arguments);return Ie.default(this,ee)}}function ct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var bt=function(K){Ee.default(G,K);var he=He(G);function G(de,ee,Ye,qe,dt){var lt;return z.default(this,G),lt=he.call(this,de),lt.code=ee,lt.body=Ye,lt.status=qe,lt.headers=dt,lt}return X.default(G)}(Oe.default(Error)),zt=e.XMLHttpRequest||{};function tr(K){return K?K.split(`\r
1173
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=aa,n=Aa,i=na,a=ia,s=li,o=wd,u=ys,l=Pu,c=zu,d=ui,f=Hu,m=sa,b=nn;function A(K){return K&&typeof K=="object"&&"default"in K?K:{default:K}}function N(K){if(K&&K.__esModule)return K;var he=Object.create(null);return K&&Object.keys(K).forEach(function(G){if(G!=="default"){var de=Object.getOwnPropertyDescriptor(K,G);Object.defineProperty(he,G,de.get?de:{enumerable:!0,get:function(){return K[G]}})}}),he.default=K,Object.freeze(he)}var z=A(r),X=A(n),Ee=A(i),Ie=A(a),Fe=A(s),Oe=A(o),ze=A(u),V=A(l),xe=A(c),_e=A(d),se=N(f),Te={exports:{}},re=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(re){var oe=new Uint8Array(16);Te.exports=function(){return re(oe),oe}}else{var q=new Array(16);Te.exports=function(){for(var he=0,G;he<16;he++)he&3||(G=Math.random()*4294967296),q[he]=G>>>((he&3)<<3)&255;return q}}for(var ne=[],Se=0;Se<256;++Se)ne[Se]=(Se+256).toString(16).substr(1);function H(K,he){var G=he||0,de=ne;return[de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]]].join("")}var ye=H,ke=Te.exports,M=ye,Xe,Ct,rt=0,je=0;function ce(K,he,G){var de=he&&G||0,ee=he||[];K=K||{};var Ye=K.node||Xe,qe=K.clockseq!==void 0?K.clockseq:Ct;if(Ye==null||qe==null){var dt=ke();Ye==null&&(Ye=Xe=[dt[0]|1,dt[1],dt[2],dt[3],dt[4],dt[5]]),qe==null&&(qe=Ct=(dt[6]<<8|dt[7])&16383)}var lt=K.msecs!==void 0?K.msecs:new Date().getTime(),ht=K.nsecs!==void 0?K.nsecs:je+1,Rt=lt-rt+(ht-je)/1e4;if(Rt<0&&K.clockseq===void 0&&(qe=qe+1&16383),(Rt<0||lt>rt)&&K.nsecs===void 0&&(ht=0),ht>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");rt=lt,je=ht,Ct=qe,lt+=122192928e5;var xt=((lt&268435455)*1e4+ht)%4294967296;ee[de++]=xt>>>24&255,ee[de++]=xt>>>16&255,ee[de++]=xt>>>8&255,ee[de++]=xt&255;var kt=lt/4294967296*1e4&268435455;ee[de++]=kt>>>8&255,ee[de++]=kt&255,ee[de++]=kt>>>24&15|16,ee[de++]=kt>>>16&255,ee[de++]=qe>>>8|128,ee[de++]=qe&255;for(var $t=0;$t<6;++$t)ee[de+$t]=Ye[$t];return he||M(ee)}var Ke=ce,Be=Te.exports,be=ye;function pt(K,he,G){var de=he&&G||0;typeof K=="string"&&(he=K==="binary"?new Array(16):null,K=null),K=K||{};var ee=K.random||(K.rng||Be)();if(ee[6]=ee[6]&15|64,ee[8]=ee[8]&63|128,he)for(var Ye=0;Ye<16;++Ye)he[de+Ye]=ee[Ye];return he||be(ee)}var Ze=pt,Jt=Ke,At=Ze,Q=At;Q.v1=Jt,Q.v4=At;var Ue=Q;function ot(K){var he=Pe();return function(){var de=Fe.default(K),ee;if(he){var Ye=Fe.default(this).constructor;ee=Reflect.construct(de,arguments,Ye)}else ee=de.apply(this,arguments);return Ie.default(this,ee)}}function Pe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var St=function(K){Ee.default(G,K);var he=ot(G);function G(de){var ee;z.default(this,G);var Ye=Ue.v4(),qe;return ee=he.call(this,function(dt,lt){return qe=lt,de(function(ht){G.cancellationMap.delete(Ye),dt(ht)},function(ht){G.cancellationMap.delete(Ye),lt(ht)},function(ht){G.cancellationMap.set(Ye,ht)})}),ee.id=Ye,ee.rejectPromise=qe,ee}return X.default(G,[{key:"cancel",value:function(){var ee=G.cancellationMap.get(this.id);return ee==null||ee(),this.rejectPromise&&(this.catch(function(){}),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),G}(Oe.default(Promise));ze.default(St,"cancellationMap",new Map);function ut(K,he,G,de){var ee=arguments.length,Ye=ee<3?he:de===null?de=Object.getOwnPropertyDescriptor(he,G):de,qe;if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Ye=Reflect.decorate(K,he,G,de);else for(var dt=K.length-1;dt>=0;dt--)(qe=K[dt])&&(Ye=(ee<3?qe(Ye):ee>3?qe(he,G,Ye):qe(he,G))||Ye);return ee>3&&Ye&&Object.defineProperty(he,G,Ye),Ye}function or(K,he){if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(K,he)}function br(K,he){return["".concat(new Date().toISOString()," MCS Client ").concat(K,":")].concat(Array.from(he))}var et=function(){function K(he){z.default(this,K),ze.default(this,"prefix",""),this.prefix=he!=null&&he.length>0?he+" ":""}return X.default(K,[{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br(this.prefix+"T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br(this.prefix+"D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.info.apply(null,br(this.prefix+"I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.warn.apply(null,br(this.prefix+"W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.error.apply(null,br(this.prefix+"E",de))}}],[{key:"scope",value:function(G){return new K(G)}},{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br("T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.debug.apply(null,br("D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.info.apply(null,br("I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.warn.apply(null,br("W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),ee=0;ee<G;ee++)de[ee]=arguments[ee];se.error.apply(null,br("E",de))}}]),K}(),Mr=1e3,Fr=4e3,dr=3,fr=!0,Wt=function(he){return"https://mcs.".concat(he??"us1",".twilio.com")},Ot=function(he){return he.startsWith("http")},L=function(he,G){return"".concat(Ot(he)?"":Wt(G)).concat(he)},W=function(){function K(he,G,de,ee){var Ye,qe,dt,lt,ht,Rt;z.default(this,K);var xt=(Ye=(qe=ee.MCS)!==null&&qe!==void 0?qe:ee)!==null&&Ye!==void 0?Ye:{};this.region=(dt=(lt=xt.region)!==null&&lt!==void 0?lt:ee.region)!==null&&dt!==void 0?dt:"us1",this.mediaUrl=L(G,this.region),this.mediaSetUrl=de?L(de):"".concat(this.mediaUrl,"Set"),this.token=he,this.retryWhenThrottledOverride=(ht=xt.retryWhenThrottledOverride)!==null&&ht!==void 0?ht:fr,this.backoffConfigOverride=(Rt=xt.backoffConfigOverride)!==null&&Rt!==void 0?Rt:K.backoffConfigDefault}return X.default(K,[{key:"updateToken",value:function(G){this.token=G}}],[{key:"backoffConfigDefault",get:function(){return{min:Mr,max:Fr,maxAttemptsCount:dr}}},{key:"retryWhenThrottledDefault",get:function(){return fr}}]),K}(),ie=function(){function K(he,G,de){z.default(this,K),this.config=he,this.network=G,this._update(de)}return X.default(K,[{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}},{key:"getContentUrl",value:function(){var G=this;return new St(function(){var de=V.default(xe.default.mark(function ee(Ye,qe,dt){var lt,ht;return xe.default.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:return lt=G.network.get("".concat(G.config.mediaUrl,"/").concat(G.sid)),dt(function(){return lt.cancel()}),xt.prev=2,xt.next=5,lt;case 5:ht=xt.sent,G._update(ht.body),Ye(G.state.contentDirectUrl),xt.next=13;break;case 10:xt.prev=10,xt.t0=xt.catch(2),qe(xt.t0);case 13:case"end":return xt.stop()}},ee,null,[[2,10]])}));return function(ee,Ye,qe){return de.apply(this,arguments)}}())}},{key:"_update",value:function(G){var de,ee,Ye,qe;this.state={sid:G.sid,serviceSid:G.service_sid,channelSid:G.channel_sid,messageSid:G.message_sid,dateCreated:G.date_created?new Date(G.date_created):null,dateUploadUpdated:G.date_upload_updated?new Date(G.date_upload_updated):null,dateUpdated:G.date_updated?new Date(G.date_updated):null,size:G.size,contentType:G.content_type,author:G.author,url:G.url,contentUrl:G.links.content,contentDirectUrl:(de=G.links.content_direct_temporary)!==null&&de!==void 0?de:null,filename:(ee=G.filename)!==null&&ee!==void 0?ee:null,category:(Ye=G.category)!==null&&Ye!==void 0?Ye:"media",isMultipartUpstream:(qe=G.is_multipart_upstream)!==null&&qe!==void 0?qe:!1}}},{key:"_state",value:function(){var G;return{sid:this.state.sid,category:this.state.category,filename:(G=this.state.filename)!==null&&G!==void 0?G:null,contentType:this.state.contentType,size:this.state.size}}}]),K}();function He(K){var he=ct();return function(){var de=Fe.default(K),ee;if(he){var Ye=Fe.default(this).constructor;ee=Reflect.construct(de,arguments,Ye)}else ee=de.apply(this,arguments);return Ie.default(this,ee)}}function ct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var bt=function(K){Ee.default(G,K);var he=He(G);function G(de,ee,Ye,qe,dt){var lt;return z.default(this,G),lt=he.call(this,de),lt.code=ee,lt.body=Ye,lt.status=qe,lt.headers=dt,lt}return X.default(G)}(Oe.default(Error)),zt=e.XMLHttpRequest||{};function tr(K){return K?K.split(`\r
1174
1174
  `).map(function(he){return he.split(": ")}).filter(function(he){return he.length===2&&he[1].length>0}).reduce(function(he,G){return he[G[0]]=G[1],he},{}):{}}function Re(K){var he=K.getResponseHeader("Content-Type");if(!he||he.indexOf("application/json")!==0||K.responseText.length===0)return K.responseText;try{return JSON.parse(K.responseText)}catch{return K.responseText}}var Ne=function(){function K(){z.default(this,K)}return X.default(K,[{key:"get",value:function(G,de){return K.request("GET",G,de)}},{key:"post",value:function(G,de,ee){return K.request("POST",G,de,ee)}}],[{key:"request",value:function(G,de,ee,Ye){return new St(function(qe,dt,lt){var ht=new zt,Rt=!1;lt(function(){ht.abort(),Rt=!0}),ht.open(G,de,!0),ht.onreadystatechange=function(){if(!(ht.readyState!==4||Rt)){var $t=tr(ht.getAllResponseHeaders()),It=Re(ht);if(200<=ht.status&&ht.status<300)qe({status:ht.status,headers:$t,body:It});else{var jt,sn=(jt=ht.statusText)!==null&&jt!==void 0?jt:"NONE",_n;if(typeof It=="string")if(It&&It.split(`
1175
- `,2).length===1)_n=It;else{var Ut,qn=(Ut=It.replace(/<.*?>/g,"").split(/\r\n/g).filter(function(Wa){return Wa.length})[0])===null||Ut===void 0?void 0:Ut.split(" ");_n=(qn==null?void 0:qn.length)>2?qn==null?void 0:qn.slice(1).join(" "):""}else _n=JSON.stringify(It);var ha="".concat(ht.status,": [").concat(sn,"] ").concat(_n);dt(new bt(ha,ht.status,It,sn,$t))}}};for(var xt in ee)ht.setRequestHeader(xt,ee[xt]),xt==="Content-Type"&&ee[xt]==="application/json"&&(Ye=JSON.stringify(Ye));ht.send(Ye)})}}]),K}(),pe=et.scope("Network"),$e=function(){function K(he,G){z.default(this,K),this.config=he,this.transport=G}return X.default(K,[{key:"backoffConfig",value:function(){return Object.assign(W.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var G,de;return(G=(de=this.config.retryWhenThrottledOverride)!==null&&de!==void 0?de:W.retryWhenThrottledDefault)!==null&&G!==void 0?G:!1}},{key:"executeWithRetry",value:function(G,de){var ee=this;return new St(function(){var Ye=V.default(xe.default.mark(function qe(dt,lt,ht){var Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:Rt=new m.Retrier(ee.backoffConfig()),xt=[502,503,504],de&&xt.push(429),ht(function(){Rt.cancel(),Rt.removeAllListeners()}),Rt.on("attempt",V.default(xe.default.mark(function It(){var jt,sn;return xe.default.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:return Ut.prev=0,jt=G(),ht(function(){jt.cancel(),Rt.cancel(),Rt.removeAllListeners()}),Ut.next=5,jt;case 5:sn=Ut.sent,Rt.succeeded(sn),Ut.next=12;break;case 9:Ut.prev=9,Ut.t0=Ut.catch(0),xt.indexOf(Ut.t0.status)>-1||Ut.t0.message==="Twilsock disconnected"?Rt.failed(Ut.t0):(Rt.removeAllListeners(),Rt.cancel(),lt(Ut.t0));case 12:case"end":return Ut.stop()}},It,null,[[0,9]])}))),Rt.on("succeeded",function(It){dt(It)}),Rt.on("cancelled",function(It){return lt(It)}),Rt.on("failed",function(It){return lt(It)}),Rt.start();case 9:case"end":return $t.stop()}},qe)}));return function(qe,dt,lt){return Ye.apply(this,arguments)}}())}},{key:"get",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return ht={"X-Twilio-Token":de.config.token},Rt=de.executeWithRetry(function(){return de.transport.get(G,ht)},de.retryWhenThrottled()),pe.trace("sending GET request to ",G," headers ",ht),lt(function(){return Rt.cancel()}),$t.prev=4,$t.next=7,Rt;case 7:xt=$t.sent,pe.trace("response",xt),qe(xt),$t.next=16;break;case 12:$t.prev=12,$t.t0=$t.catch(4),pe.debug("get() error ".concat($t.t0)),dt($t.t0);case 16:case"end":return $t.stop()}},Ye,null,[[4,12]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"post",value:function(G,de,ee,Ye,qe){var dt=this,lt={"X-Twilio-Token":this.config.token};(typeof FormData>"u"||!(ee instanceof FormData))&&Ye&&Object.assign(lt,{"Content-Type":Ye});var ht=new URL(G);return de&&ht.searchParams.append("Category",de),qe&&ht.searchParams.append("Filename",qe),new St(function(){var Rt=V.default(xe.default.mark(function xt(kt,$t,It){var jt,sn;return xe.default.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:return jt=dt.transport.post(ht.href,lt,ee),It(function(){return jt.cancel()}),pe.trace("sending POST request to ".concat(G," with headers ").concat(lt)),Ut.prev=3,Ut.next=6,jt;case 6:sn=Ut.sent,Ut.next=17;break;case 9:if(Ut.prev=9,Ut.t0=Ut.catch(3),!(e.XMLHttpRequest===void 0&&ee instanceof FormData)){Ut.next=14;break}return $t(new TypeError("Posting FormData supported only with browser engine's FormData")),Ut.abrupt("return");case 14:return pe.debug("post() error ".concat(Ut.t0)),$t(Ut.t0),Ut.abrupt("return");case 17:pe.trace("response",sn),kt(sn);case 19:case"end":return Ut.stop()}},xt,null,[[3,9]])}));return function(xt,kt,$t){return Rt.apply(this,arguments)}}())}}]),K}(),ae="0.6.13",me,we=et.scope("");t.default=(me=function(){function K(he,G,de){var ee,Ye,qe=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};z.default(this,K),this.options=qe,this.options.logLevel=(ee=this.options.logLevel)!==null&&ee!==void 0?ee:"silent",this.config=new W(he,G,de,this.options),we.setLevel(this.options.logLevel),this.options.transport=(Ye=this.options.transport)!==null&&Ye!==void 0?Ye:new Ne,this.transport=this.options.transport,this.network=new $e(this.config,this.transport)}return X.default(K,[{key:"updateToken",value:function(G){we.info("updateToken"),this.config.updateToken(G)}},{key:"get",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt;return xe.default.wrap(function(kt){for(;;)switch(kt.prev=kt.next){case 0:return ht=de.network.get("".concat(de.config.mediaUrl,"/").concat(G)),lt(function(){return ht.cancel()}),kt.prev=2,kt.next=5,ht;case 5:Rt=kt.sent,qe(new ie(de.config,de.network,Rt.body)),kt.next=12;break;case 9:kt.prev=9,kt.t0=kt.catch(2),dt(kt.t0);case 12:case"end":return kt.stop()}},Ye,null,[[2,9]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"post",value:function(G,de,ee,Ye){var qe=this;return new St(function(){var dt=V.default(xe.default.mark(function lt(ht,Rt,xt){var kt,$t;return xe.default.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:return kt=qe.network.post(qe.config.mediaUrl,ee??"media",de,G,Ye),xt(function(){return kt.cancel()}),jt.prev=2,jt.next=5,kt;case 5:$t=jt.sent,ht(new ie(qe.config,qe.network,$t.body)),jt.next=12;break;case 9:jt.prev=9,jt.t0=jt.catch(2),Rt(jt.t0);case 12:case"end":return jt.stop()}},lt,null,[[2,9]])}));return function(lt,ht,Rt){return dt.apply(this,arguments)}}())}},{key:"postFormData",value:function(G,de){var ee=this;return new St(function(){var Ye=V.default(xe.default.mark(function qe(dt,lt,ht){var Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return Rt=ee.network.post(ee.config.mediaUrl,de??"media",G),ht(function(){return Rt.cancel()}),$t.prev=2,$t.next=5,Rt;case 5:xt=$t.sent,dt(new ie(ee.config,ee.network,xt.body)),$t.next=12;break;case 9:$t.prev=9,$t.t0=$t.catch(2),lt($t.t0);case 12:case"end":return $t.stop()}},qe,null,[[2,9]])}));return function(qe,dt,lt){return Ye.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt,kt;return xe.default.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return ht={command:"get",list:G.map(function(jt){return{media_sid:jt}})},Rt=de.network.post("".concat(de.config.mediaSetUrl),null,ht,"application/json"),lt(function(){return Rt.cancel()}),It.prev=3,It.next=6,Rt;case 6:xt=It.sent,kt=xt.body.map(function(jt){if(jt.code!==200){dt("Failed to obtain detailed information about Media items (failed SID ".concat(jt.media_record.sid,")"));return}return new ie(de.config,de.network,jt.media_record)}),qe(kt),It.next=14;break;case 11:It.prev=11,It.t0=It.catch(3),dt(It.t0);case 14:case"end":return It.stop()}},Ye,null,[[3,11]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt,kt;return xe.default.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return ht={command:"get",list:G.map(function(jt){return{media_sid:jt}})},Rt=de.network.post("".concat(de.config.mediaSetUrl),null,ht,"application/json"),lt(function(){return Rt.cancel()}),It.prev=3,It.next=6,Rt;case 6:xt=It.sent,kt=new Map,xt.body.forEach(function(jt){if(jt.code!==200){dt("Failed to obtain detailed information about Media items (failed SID ".concat(jt.media_record.sid,")"));return}kt.set(jt.media_record.sid,jt.media_record.links.content_direct_temporary)}),qe(kt),It.next=15;break;case 12:It.prev=12,It.t0=It.catch(3),dt(It.t0);case 15:case"end":return It.stop()}},Ye,null,[[3,12]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}}]),K}(),ze.default(me,"version",ae),me),ut([b.validateTypes(b.nonEmptyString),or("design:type",Function),or("design:paramtypes",[String]),or("design:returntype",void 0)],t.default.prototype,"updateToken",null),ut([b.validateTypesAsync(b.nonEmptyString),or("design:type",Function),or("design:paramtypes",[String]),or("design:returntype",St)],t.default.prototype,"get",null),t.default=ut([b.validateConstructorTypes(b.nonEmptyString,b.nonEmptyString,[b.nonEmptyString,b.literal(null)],[b.pureObject,"undefined"]),or("design:paramtypes",[String,String,Object,Object])],t.default),t.CancellablePromise=St,t.Client=t.default,t.McsClient=t.default,t.McsMedia=ie,t.Media=ie})(sA);var qne=er,Vne=cr,Wne=FR,Zne=wh,jw="ArrayBuffer",i2=Wne[jw],Gne=Vne[jw];qne({global:!0,constructor:!0,forced:Gne!==i2},{ArrayBuffer:i2}),Zne(jw);var Kne=er,a2=Kt,Jne=si,Yne=yn,s2=bn,Qne=Tb,o2=rn,Uw=Vt,Xne=Lb,eie=yh,u2=Vx,tie=Wx,l2=Su,c2=Gx,Ps=[],d2=a2(Ps.sort),rie=a2(Ps.push),nie=Uw(function(){Ps.sort(void 0)}),iie=Uw(function(){Ps.sort(null)}),aie=eie("sort"),f2=!Uw(function(){if(l2)return l2<70;if(!(u2&&u2>3)){if(tie)return!0;if(c2)return c2<603;var t="",e,r,n,i;for(e=65;e<76;e++){switch(r=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)Ps.push({k:r+i,v:n})}for(Ps.sort(function(a,s){return s.v-a.v}),i=0;i<Ps.length;i++)r=Ps[i].k.charAt(0),t.charAt(t.length-1)!==r&&(t+=r);return t!=="DGBEFHACIJK"}}),sie=nie||!iie||!aie||!f2,oie=function(t){return function(e,r){return r===void 0?-1:e===void 0?1:t!==void 0?+t(e,r)||0:o2(e)>o2(r)?1:-1}};Kne({target:"Array",proto:!0,forced:sie},{sort:function(e){e!==void 0&&Jne(e);var r=Yne(this);if(f2)return e===void 0?d2(r):d2(r,e);var n=[],i=s2(r),a,s;for(s=0;s<i;s++)s in r&&rie(n,r[s]);for(Xne(n,oie(e)),a=s2(n),s=0;s<a;)r[s]=n[s++];for(;s<i;)Qne(r,s++);return r}});var uie=er,lie=Kt,cie=oA,die=Ii,h2=rn,fie=uA,hie=lie("".indexOf);uie({target:"String",proto:!0,forced:!fie("includes")},{includes:function(e){return!!~hie(h2(die(this)),h2(cie(e)),arguments.length>1?arguments[1]:void 0)}});var pie=Kt,p2=ip,Zp=np.getWeakData,vie=bs,mie=Gr,gie=xi,Fw=Lr,yie=rd,v2=Un,m2=Vr,g2=Jn,bie=g2.set,wie=g2.getterFor,_ie=v2.find,kie=v2.findIndex,Sie=pie([].splice),$ie=0,Gp=function(t){return t.frozen||(t.frozen=new y2)},y2=function(){this.entries=[]},Bw=function(t,e){return _ie(t.entries,function(r){return r[0]===e})};y2.prototype={get:function(t){var e=Bw(this,t);if(e)return e[1]},has:function(t){return!!Bw(this,t)},set:function(t,e){var r=Bw(this,t);r?r[1]=e:this.entries.push([t,e])},delete:function(t){var e=kie(this.entries,function(r){return r[0]===t});return~e&&Sie(this.entries,e,1),!!~e}};var Tie={getConstructor:function(t,e,r,n){var i=t(function(u,l){vie(u,a),bie(u,{type:e,id:$ie++,frozen:void 0}),gie(l)||yie(l,u[n],{that:u,AS_ENTRIES:r})}),a=i.prototype,s=wie(e),o=function(u,l,c){var d=s(u),f=Zp(mie(l),!0);return f===!0?Gp(d).set(l,c):f[d.id]=c,u};return p2(a,{delete:function(u){var l=s(this);if(!Fw(u))return!1;var c=Zp(u);return c===!0?Gp(l).delete(u):c&&m2(c,l.id)&&delete c[l.id]},has:function(l){var c=s(this);if(!Fw(l))return!1;var d=Zp(l);return d===!0?Gp(c).has(l):d&&m2(d,c.id)}}),p2(a,r?{get:function(l){var c=s(this);if(Fw(l)){var d=Zp(l);return d===!0?Gp(c).get(l):d?d[c.id]:void 0}},set:function(l,c){return o(this,l,c)}}:{add:function(l){return o(this,l,!0)}}),i}},Eie=Zy,Cie=Tie;Eie("WeakSet",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Cie);var Kp={},b2={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(ln,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(A,N){var z=A[N];if(typeof z.bind=="function")return z.bind(A);try{return Function.prototype.bind.call(z,A)}catch{return function(){return Function.prototype.apply.apply(z,[A,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(A){return A==="debug"&&(A="log"),typeof console===r?!1:A==="trace"&&n?s:console[A]!==void 0?a(console,A):console.log!==void 0?a(console,"log"):e}function u(A,N){for(var z=0;z<i.length;z++){var X=i[z];this[X]=z<A?e:this.methodFactory(X,A,N)}this.log=this.debug}function l(A,N,z){return function(){typeof console!==r&&(u.call(this,N,z),this[A].apply(this,arguments))}}function c(A,N,z){return o(A)||l.apply(this,arguments)}function d(A,N,z){var X=this,Ee;N=N??"WARN";var Ie="loglevel";typeof A=="string"?Ie+=":"+A:typeof A=="symbol"&&(Ie=void 0);function Be(xe){var _e=(i[xe]||"silent").toUpperCase();if(!(typeof window===r||!Ie)){try{window.localStorage[Ie]=_e;return}catch{}try{window.document.cookie=encodeURIComponent(Ie)+"="+_e+";"}catch{}}}function Oe(){var xe;if(!(typeof window===r||!Ie)){try{xe=window.localStorage[Ie]}catch{}if(typeof xe===r)try{var _e=window.document.cookie,se=_e.indexOf(encodeURIComponent(Ie)+"=");se!==-1&&(xe=/^([^;]+)/.exec(_e.slice(se))[1])}catch{}return X.levels[xe]===void 0&&(xe=void 0),xe}}function ze(){if(!(typeof window===r||!Ie)){try{window.localStorage.removeItem(Ie);return}catch{}try{window.document.cookie=encodeURIComponent(Ie)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}X.name=A,X.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},X.methodFactory=z||c,X.getLevel=function(){return Ee},X.setLevel=function(xe,_e){if(typeof xe=="string"&&X.levels[xe.toUpperCase()]!==void 0&&(xe=X.levels[xe.toUpperCase()]),typeof xe=="number"&&xe>=0&&xe<=X.levels.SILENT){if(Ee=xe,_e!==!1&&Be(xe),u.call(X,xe,A),typeof console===r&&xe<X.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+xe},X.setDefaultLevel=function(xe){N=xe,Oe()||X.setLevel(xe,!1)},X.resetLevel=function(){X.setLevel(N,!1),ze()},X.enableAll=function(xe){X.setLevel(X.levels.TRACE,xe)},X.disableAll=function(xe){X.setLevel(X.levels.SILENT,xe)};var V=Oe();V==null&&(V=N),X.setLevel(V,!1)}var f=new d,m={};f.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=m[N];return z||(z=m[N]=new d(N,f.getLevel(),f.methodFactory)),z};var b=typeof window!==r?window.log:void 0;return f.noConflict=function(){return typeof window!==r&&window.log===f&&(window.log=b),f},f.getLoggers=function(){return m},f.default=f,f})})(b2);var Rie=b2.exports;/*
1175
+ `,2).length===1)_n=It;else{var Ut,qn=(Ut=It.replace(/<.*?>/g,"").split(/\r\n/g).filter(function(Wa){return Wa.length})[0])===null||Ut===void 0?void 0:Ut.split(" ");_n=(qn==null?void 0:qn.length)>2?qn==null?void 0:qn.slice(1).join(" "):""}else _n=JSON.stringify(It);var ha="".concat(ht.status,": [").concat(sn,"] ").concat(_n);dt(new bt(ha,ht.status,It,sn,$t))}}};for(var xt in ee)ht.setRequestHeader(xt,ee[xt]),xt==="Content-Type"&&ee[xt]==="application/json"&&(Ye=JSON.stringify(Ye));ht.send(Ye)})}}]),K}(),pe=et.scope("Network"),$e=function(){function K(he,G){z.default(this,K),this.config=he,this.transport=G}return X.default(K,[{key:"backoffConfig",value:function(){return Object.assign(W.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var G,de;return(G=(de=this.config.retryWhenThrottledOverride)!==null&&de!==void 0?de:W.retryWhenThrottledDefault)!==null&&G!==void 0?G:!1}},{key:"executeWithRetry",value:function(G,de){var ee=this;return new St(function(){var Ye=V.default(xe.default.mark(function qe(dt,lt,ht){var Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:Rt=new m.Retrier(ee.backoffConfig()),xt=[502,503,504],de&&xt.push(429),ht(function(){Rt.cancel(),Rt.removeAllListeners()}),Rt.on("attempt",V.default(xe.default.mark(function It(){var jt,sn;return xe.default.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:return Ut.prev=0,jt=G(),ht(function(){jt.cancel(),Rt.cancel(),Rt.removeAllListeners()}),Ut.next=5,jt;case 5:sn=Ut.sent,Rt.succeeded(sn),Ut.next=12;break;case 9:Ut.prev=9,Ut.t0=Ut.catch(0),xt.indexOf(Ut.t0.status)>-1||Ut.t0.message==="Twilsock disconnected"?Rt.failed(Ut.t0):(Rt.removeAllListeners(),Rt.cancel(),lt(Ut.t0));case 12:case"end":return Ut.stop()}},It,null,[[0,9]])}))),Rt.on("succeeded",function(It){dt(It)}),Rt.on("cancelled",function(It){return lt(It)}),Rt.on("failed",function(It){return lt(It)}),Rt.start();case 9:case"end":return $t.stop()}},qe)}));return function(qe,dt,lt){return Ye.apply(this,arguments)}}())}},{key:"get",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return ht={"X-Twilio-Token":de.config.token},Rt=de.executeWithRetry(function(){return de.transport.get(G,ht)},de.retryWhenThrottled()),pe.trace("sending GET request to ",G," headers ",ht),lt(function(){return Rt.cancel()}),$t.prev=4,$t.next=7,Rt;case 7:xt=$t.sent,pe.trace("response",xt),qe(xt),$t.next=16;break;case 12:$t.prev=12,$t.t0=$t.catch(4),pe.debug("get() error ".concat($t.t0)),dt($t.t0);case 16:case"end":return $t.stop()}},Ye,null,[[4,12]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"post",value:function(G,de,ee,Ye,qe){var dt=this,lt={"X-Twilio-Token":this.config.token};(typeof FormData>"u"||!(ee instanceof FormData))&&Ye&&Object.assign(lt,{"Content-Type":Ye});var ht=new URL(G);return de&&ht.searchParams.append("Category",de),qe&&ht.searchParams.append("Filename",qe),new St(function(){var Rt=V.default(xe.default.mark(function xt(kt,$t,It){var jt,sn;return xe.default.wrap(function(Ut){for(;;)switch(Ut.prev=Ut.next){case 0:return jt=dt.transport.post(ht.href,lt,ee),It(function(){return jt.cancel()}),pe.trace("sending POST request to ".concat(G," with headers ").concat(lt)),Ut.prev=3,Ut.next=6,jt;case 6:sn=Ut.sent,Ut.next=17;break;case 9:if(Ut.prev=9,Ut.t0=Ut.catch(3),!(e.XMLHttpRequest===void 0&&ee instanceof FormData)){Ut.next=14;break}return $t(new TypeError("Posting FormData supported only with browser engine's FormData")),Ut.abrupt("return");case 14:return pe.debug("post() error ".concat(Ut.t0)),$t(Ut.t0),Ut.abrupt("return");case 17:pe.trace("response",sn),kt(sn);case 19:case"end":return Ut.stop()}},xt,null,[[3,9]])}));return function(xt,kt,$t){return Rt.apply(this,arguments)}}())}}]),K}(),ae="0.6.13",me,we=et.scope("");t.default=(me=function(){function K(he,G,de){var ee,Ye,qe=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};z.default(this,K),this.options=qe,this.options.logLevel=(ee=this.options.logLevel)!==null&&ee!==void 0?ee:"silent",this.config=new W(he,G,de,this.options),we.setLevel(this.options.logLevel),this.options.transport=(Ye=this.options.transport)!==null&&Ye!==void 0?Ye:new Ne,this.transport=this.options.transport,this.network=new $e(this.config,this.transport)}return X.default(K,[{key:"updateToken",value:function(G){we.info("updateToken"),this.config.updateToken(G)}},{key:"get",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt;return xe.default.wrap(function(kt){for(;;)switch(kt.prev=kt.next){case 0:return ht=de.network.get("".concat(de.config.mediaUrl,"/").concat(G)),lt(function(){return ht.cancel()}),kt.prev=2,kt.next=5,ht;case 5:Rt=kt.sent,qe(new ie(de.config,de.network,Rt.body)),kt.next=12;break;case 9:kt.prev=9,kt.t0=kt.catch(2),dt(kt.t0);case 12:case"end":return kt.stop()}},Ye,null,[[2,9]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"post",value:function(G,de,ee,Ye){var qe=this;return new St(function(){var dt=V.default(xe.default.mark(function lt(ht,Rt,xt){var kt,$t;return xe.default.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:return kt=qe.network.post(qe.config.mediaUrl,ee??"media",de,G,Ye),xt(function(){return kt.cancel()}),jt.prev=2,jt.next=5,kt;case 5:$t=jt.sent,ht(new ie(qe.config,qe.network,$t.body)),jt.next=12;break;case 9:jt.prev=9,jt.t0=jt.catch(2),Rt(jt.t0);case 12:case"end":return jt.stop()}},lt,null,[[2,9]])}));return function(lt,ht,Rt){return dt.apply(this,arguments)}}())}},{key:"postFormData",value:function(G,de){var ee=this;return new St(function(){var Ye=V.default(xe.default.mark(function qe(dt,lt,ht){var Rt,xt;return xe.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return Rt=ee.network.post(ee.config.mediaUrl,de??"media",G),ht(function(){return Rt.cancel()}),$t.prev=2,$t.next=5,Rt;case 5:xt=$t.sent,dt(new ie(ee.config,ee.network,xt.body)),$t.next=12;break;case 9:$t.prev=9,$t.t0=$t.catch(2),lt($t.t0);case 12:case"end":return $t.stop()}},qe,null,[[2,9]])}));return function(qe,dt,lt){return Ye.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt,kt;return xe.default.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return ht={command:"get",list:G.map(function(jt){return{media_sid:jt}})},Rt=de.network.post("".concat(de.config.mediaSetUrl),null,ht,"application/json"),lt(function(){return Rt.cancel()}),It.prev=3,It.next=6,Rt;case 6:xt=It.sent,kt=xt.body.map(function(jt){if(jt.code!==200){dt("Failed to obtain detailed information about Media items (failed SID ".concat(jt.media_record.sid,")"));return}return new ie(de.config,de.network,jt.media_record)}),qe(kt),It.next=14;break;case 11:It.prev=11,It.t0=It.catch(3),dt(It.t0);case 14:case"end":return It.stop()}},Ye,null,[[3,11]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(G){var de=this;return new St(function(){var ee=V.default(xe.default.mark(function Ye(qe,dt,lt){var ht,Rt,xt,kt;return xe.default.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return ht={command:"get",list:G.map(function(jt){return{media_sid:jt}})},Rt=de.network.post("".concat(de.config.mediaSetUrl),null,ht,"application/json"),lt(function(){return Rt.cancel()}),It.prev=3,It.next=6,Rt;case 6:xt=It.sent,kt=new Map,xt.body.forEach(function(jt){if(jt.code!==200){dt("Failed to obtain detailed information about Media items (failed SID ".concat(jt.media_record.sid,")"));return}kt.set(jt.media_record.sid,jt.media_record.links.content_direct_temporary)}),qe(kt),It.next=15;break;case 12:It.prev=12,It.t0=It.catch(3),dt(It.t0);case 15:case"end":return It.stop()}},Ye,null,[[3,12]])}));return function(Ye,qe,dt){return ee.apply(this,arguments)}}())}}]),K}(),ze.default(me,"version",ae),me),ut([b.validateTypes(b.nonEmptyString),or("design:type",Function),or("design:paramtypes",[String]),or("design:returntype",void 0)],t.default.prototype,"updateToken",null),ut([b.validateTypesAsync(b.nonEmptyString),or("design:type",Function),or("design:paramtypes",[String]),or("design:returntype",St)],t.default.prototype,"get",null),t.default=ut([b.validateConstructorTypes(b.nonEmptyString,b.nonEmptyString,[b.nonEmptyString,b.literal(null)],[b.pureObject,"undefined"]),or("design:paramtypes",[String,String,Object,Object])],t.default),t.CancellablePromise=St,t.Client=t.default,t.McsClient=t.default,t.McsMedia=ie,t.Media=ie})(sA);var qne=er,Vne=cr,Wne=FR,Zne=wh,jw="ArrayBuffer",i2=Wne[jw],Gne=Vne[jw];qne({global:!0,constructor:!0,forced:Gne!==i2},{ArrayBuffer:i2}),Zne(jw);var Kne=er,a2=Kt,Jne=si,Yne=yn,s2=bn,Qne=Tb,o2=rn,Uw=Vt,Xne=Lb,eie=yh,u2=Vx,tie=Wx,l2=Su,c2=Gx,Ps=[],d2=a2(Ps.sort),rie=a2(Ps.push),nie=Uw(function(){Ps.sort(void 0)}),iie=Uw(function(){Ps.sort(null)}),aie=eie("sort"),f2=!Uw(function(){if(l2)return l2<70;if(!(u2&&u2>3)){if(tie)return!0;if(c2)return c2<603;var t="",e,r,n,i;for(e=65;e<76;e++){switch(r=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)Ps.push({k:r+i,v:n})}for(Ps.sort(function(a,s){return s.v-a.v}),i=0;i<Ps.length;i++)r=Ps[i].k.charAt(0),t.charAt(t.length-1)!==r&&(t+=r);return t!=="DGBEFHACIJK"}}),sie=nie||!iie||!aie||!f2,oie=function(t){return function(e,r){return r===void 0?-1:e===void 0?1:t!==void 0?+t(e,r)||0:o2(e)>o2(r)?1:-1}};Kne({target:"Array",proto:!0,forced:sie},{sort:function(e){e!==void 0&&Jne(e);var r=Yne(this);if(f2)return e===void 0?d2(r):d2(r,e);var n=[],i=s2(r),a,s;for(s=0;s<i;s++)s in r&&rie(n,r[s]);for(Xne(n,oie(e)),a=s2(n),s=0;s<a;)r[s]=n[s++];for(;s<i;)Qne(r,s++);return r}});var uie=er,lie=Kt,cie=oA,die=Ii,h2=rn,fie=uA,hie=lie("".indexOf);uie({target:"String",proto:!0,forced:!fie("includes")},{includes:function(e){return!!~hie(h2(die(this)),h2(cie(e)),arguments.length>1?arguments[1]:void 0)}});var pie=Kt,p2=ip,Zp=np.getWeakData,vie=bs,mie=Gr,gie=xi,Fw=Lr,yie=rd,v2=Un,m2=Vr,g2=Jn,bie=g2.set,wie=g2.getterFor,_ie=v2.find,kie=v2.findIndex,Sie=pie([].splice),$ie=0,Gp=function(t){return t.frozen||(t.frozen=new y2)},y2=function(){this.entries=[]},Bw=function(t,e){return _ie(t.entries,function(r){return r[0]===e})};y2.prototype={get:function(t){var e=Bw(this,t);if(e)return e[1]},has:function(t){return!!Bw(this,t)},set:function(t,e){var r=Bw(this,t);r?r[1]=e:this.entries.push([t,e])},delete:function(t){var e=kie(this.entries,function(r){return r[0]===t});return~e&&Sie(this.entries,e,1),!!~e}};var Tie={getConstructor:function(t,e,r,n){var i=t(function(u,l){vie(u,a),bie(u,{type:e,id:$ie++,frozen:void 0}),gie(l)||yie(l,u[n],{that:u,AS_ENTRIES:r})}),a=i.prototype,s=wie(e),o=function(u,l,c){var d=s(u),f=Zp(mie(l),!0);return f===!0?Gp(d).set(l,c):f[d.id]=c,u};return p2(a,{delete:function(u){var l=s(this);if(!Fw(u))return!1;var c=Zp(u);return c===!0?Gp(l).delete(u):c&&m2(c,l.id)&&delete c[l.id]},has:function(l){var c=s(this);if(!Fw(l))return!1;var d=Zp(l);return d===!0?Gp(c).has(l):d&&m2(d,c.id)}}),p2(a,r?{get:function(l){var c=s(this);if(Fw(l)){var d=Zp(l);return d===!0?Gp(c).get(l):d?d[c.id]:void 0}},set:function(l,c){return o(this,l,c)}}:{add:function(l){return o(this,l,!0)}}),i}},Eie=Zy,Cie=Tie;Eie("WeakSet",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Cie);var Kp={},b2={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(ln,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(A,N){var z=A[N];if(typeof z.bind=="function")return z.bind(A);try{return Function.prototype.bind.call(z,A)}catch{return function(){return Function.prototype.apply.apply(z,[A,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(A){return A==="debug"&&(A="log"),typeof console===r?!1:A==="trace"&&n?s:console[A]!==void 0?a(console,A):console.log!==void 0?a(console,"log"):e}function u(A,N){for(var z=0;z<i.length;z++){var X=i[z];this[X]=z<A?e:this.methodFactory(X,A,N)}this.log=this.debug}function l(A,N,z){return function(){typeof console!==r&&(u.call(this,N,z),this[A].apply(this,arguments))}}function c(A,N,z){return o(A)||l.apply(this,arguments)}function d(A,N,z){var X=this,Ee;N=N??"WARN";var Ie="loglevel";typeof A=="string"?Ie+=":"+A:typeof A=="symbol"&&(Ie=void 0);function Fe(xe){var _e=(i[xe]||"silent").toUpperCase();if(!(typeof window===r||!Ie)){try{window.localStorage[Ie]=_e;return}catch{}try{window.document.cookie=encodeURIComponent(Ie)+"="+_e+";"}catch{}}}function Oe(){var xe;if(!(typeof window===r||!Ie)){try{xe=window.localStorage[Ie]}catch{}if(typeof xe===r)try{var _e=window.document.cookie,se=_e.indexOf(encodeURIComponent(Ie)+"=");se!==-1&&(xe=/^([^;]+)/.exec(_e.slice(se))[1])}catch{}return X.levels[xe]===void 0&&(xe=void 0),xe}}function ze(){if(!(typeof window===r||!Ie)){try{window.localStorage.removeItem(Ie);return}catch{}try{window.document.cookie=encodeURIComponent(Ie)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}X.name=A,X.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},X.methodFactory=z||c,X.getLevel=function(){return Ee},X.setLevel=function(xe,_e){if(typeof xe=="string"&&X.levels[xe.toUpperCase()]!==void 0&&(xe=X.levels[xe.toUpperCase()]),typeof xe=="number"&&xe>=0&&xe<=X.levels.SILENT){if(Ee=xe,_e!==!1&&Fe(xe),u.call(X,xe,A),typeof console===r&&xe<X.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+xe},X.setDefaultLevel=function(xe){N=xe,Oe()||X.setLevel(xe,!1)},X.resetLevel=function(){X.setLevel(N,!1),ze()},X.enableAll=function(xe){X.setLevel(X.levels.TRACE,xe)},X.disableAll=function(xe){X.setLevel(X.levels.SILENT,xe)};var V=Oe();V==null&&(V=N),X.setLevel(V,!1)}var f=new d,m={};f.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=m[N];return z||(z=m[N]=new d(N,f.getLevel(),f.methodFactory)),z};var b=typeof window!==r?window.log:void 0;return f.noConflict=function(){return typeof window!==r&&window.log===f&&(window.log=b),f},f.getLoggers=function(){return m},f.default=f,f})})(b2);var Rie=b2.exports;/*
1176
1176
  @license
1177
1177
  Copyright (c) 2022 Twilio Inc.
1178
1178
 
@@ -1310,10 +1310,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1310
1310
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1311
1311
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1312
1312
 
1313
- */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Pu,n=gs,i=na,a=ia,s=li,o=ys,u=Aa,l=aa,c=zu,d=ui,f=Hu,m=Pz,b=nn,A=ud,N=Xh,z=KW,X=od,Ee=sa,Ie=Qy,Be=yI,Oe=zn,ze=sA,V=Kp,xe=wd,_e=hd;function se(C){return C&&typeof C=="object"&&"default"in C?C:{default:C}}function Te(C){if(C&&C.__esModule)return C;var x=Object.create(null);return C&&Object.keys(C).forEach(function(w){if(w!=="default"){var p=Object.getOwnPropertyDescriptor(C,w);Object.defineProperty(x,w,p.get?p:{enumerable:!0,get:function(){return C[w]}})}}),x.default=C,Object.freeze(x)}var re=se(r),oe=se(n),q=se(i),ne=se(a),Se=se(s),H=se(o),ye=se(u),ke=se(l),M=se(c),Xe=se(d),Ct=Te(f),rt=se(A),je=se(z),ce=se(X),Ke=se(xe);function Fe(C,x,w,p){var h=arguments.length,_=h<3?x:p===null?p=Object.getOwnPropertyDescriptor(x,w):p,v;if((typeof Reflect>"u"?"undefined":Xe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(C,x,w,p);else for(var g=C.length-1;g>=0;g--)(v=C[g])&&(_=(h<3?v(_):h>3?v(x,w,_):v(x,w))||_);return h>3&&_&&Object.defineProperty(x,w,_),_}function be(C,x){if((typeof Reflect>"u"?"undefined":Xe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(C,x)}function pt(C,x){return["".concat(new Date().toISOString()," Conversations ").concat(C,":")].concat(Array.from(x))}var Ze=Ct.getLogger("twilio-conversations"),Jt=function(){function C(x){ke.default(this,C),H.default(this,"prefix",""),this.prefix=x!=null&&x.length>0?x+" ":""}return ye.default(C,[{key:"setLevel",value:function(w){Ze.setLevel(w)}},{key:"trace",value:function(){if(Ze.getLevel()==Ze.levels.TRACE){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt(this.prefix+"T",p))}}},{key:"debug",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt(this.prefix+"D",p))}},{key:"info",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.info.apply(null,pt(this.prefix+"I",p))}},{key:"warn",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.warn.apply(null,pt(this.prefix+"W",p))}},{key:"error",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.error.apply(null,pt(this.prefix+"E",p))}}],[{key:"scope",value:function(w){return new C(w)}},{key:"setLevel",value:function(w){Ze.setLevel(w)}},{key:"trace",value:function(){if(Ze.getLevel()==Ze.levels.TRACE){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt("T",p))}}},{key:"debug",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt("D",p))}},{key:"info",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.info.apply(null,pt("I",p))}},{key:"warn",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.warn.apply(null,pt("W",p))}},{key:"error",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.error.apply(null,pt("E",p))}}]),C}();function At(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function Q(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?At(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):At(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}var Ue=5,ot="PT5S",Pe="PT5S",St=100,ut=1e3,or=4e3,br=3,et=!0,Mr=100,Fr=1e3,dr=ye.default(function C(){var x,w,p,h,_,v,g,y,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},S=arguments.length>1?arguments[1]:void 0,Y=arguments.length>2?arguments[2]:void 0;ke.default(this,C),H.default(this,"typingIndicatorTimeoutDefault",Ue*1e3);var J=k.Chat||k.IPMessaging||k||{};this.productId=J.productId,this.links={myConversations:S.links.my_conversations,conversations:S.links.conversations,users:S.links.users,currentUser:S.links.current_user,typing:S.links.typing,mediaService:S.links.media_service,mediaSetService:S.links.media_set_service,messagesReceipts:S.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:S.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:S.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:S.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:S.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:S.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=J.typingIndicatorTimeoutOverride,this.backoffConfiguration=Q({min:ut,max:or,maxAttemptsCount:br},J.backoffConfigOverride),this.retryWhenThrottled=J.retryWhenThrottledOverride!==void 0?J.retryWhenThrottledOverride:et,this.userInfosToSubscribe=(x=(w=J.userInfosToSubscribeOverride)!==null&&w!==void 0?w:S.options.user_infos_to_subscribe)!==null&&x!==void 0?x:St,this.reachabilityEnabled=S.options.reachability_enabled,this.userIdentity=S.identity,this.userInfo=S.sync_objects.my_user_info,this.myConversations=S.sync_objects.my_conversations;var le=(p=(h=J.httpCacheIntervalOverride)!==null&&h!==void 0?h:S.options.http_cache_interval)!==null&&p!==void 0?p:ot;try{this.httpCacheInterval=m.toSeconds(m.parse(le))}catch{Y.error("Failed to parse http cache interval ".concat(le,", using default value ").concat(ot)),this.httpCacheInterval=m.toSeconds(m.parse(ot))}var ge=(_=(v=J.consumptionReportIntervalOverride)!==null&&v!==void 0?v:S.options.consumption_report_interval)!==null&&_!==void 0?_:Pe;try{this.consumptionReportInterval=m.toSeconds(m.parse(ge))}catch{Y.error("Failed to parse consumption report interval ".concat(ge,", using default value ").concat(Pe)),this.consumptionReportInterval=m.toSeconds(m.parse(Pe))}this.channelMetadataCacheCapacity=(g=k.channelMetadataCacheCapacity)!==null&&g!==void 0?g:Mr,this.messageRecipientsCacheCapacity=(y=k.messageRecipientsCacheCapacity)!==null&&y!==void 0?y:Fr});function fr(C){return JSON.parse(JSON.stringify(C))}function Wt(C){return typeof C<"u"&&!isNaN(Number(C))?Number(C):null}function Ot(C){try{return new Date(C)}catch{return null}}function L(C,x,w){var p={};if(C)try{p=JSON.parse(C)}catch(h){w.warn(x,h)}return p}var W=function(){function C(x){ke.default(this,C),this.base=x.replace(/\/$/,""),this.args=[],this.paths=[]}return ye.default(C,[{key:"arg",value:function(w,p){return typeof p<"u"&&this.args.push(encodeURIComponent(w)+"="+encodeURIComponent(p)),this}},{key:"path",value:function(w){return this.paths.push(encodeURIComponent(w)),this}},{key:"build",value:function(){var w=this.base;return this.paths.length&&(w+="/"+this.paths.join("/")),this.args.length&&(w+="?"+this.args.join("&")),w}}]),C}(),ie=b.custom(function(C){return[["string","number","boolean","object"].includes(Xe.default(C)),"a JSON type"]}),He=b.custom(function(C){return[["undefined","string","number","boolean","object"].includes(Xe.default(C)),"an optional JSON type"]}),ct=b.objectSchema("send media options",{contentType:[b.literal(null),"string"],filename:["string","undefined"],media:[b.literal("null"),"string"].concat(rt.default(typeof Buffer=="function"?[Buffer]:[]),rt.default(typeof Blob=="function"?[Blob]:[]))});function bt(C){var x=zt();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function zt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var tr=Jt.scope("User"),Re=function(C){q.default(w,C);var x=bt(w);function w(p,h,_,v){var g;return ke.default(this,w),g=x.call(this),H.default(oe.default(g),"promiseToFetch",null),H.default(oe.default(g),"updated","updated"),H.default(oe.default(g),"userSubscribed","userSubscribed"),H.default(oe.default(g),"userUnsubscribed","userUnsubscribed"),g.services=v,g.subscribed="initializing",g.setMaxListeners(0),g.state={identity:p,entityName:h,friendlyName:null,attributes:{},online:null,notifiable:null},g._initializationPromise=new Promise(function(y){g._resolveInitializationPromise=y}),_!==null&&g._resolveInitialization(_,p,h,!1),g}return ye.default(w,[{key:"identity",get:function(){return this.state.identity},set:function(h){this.state.identity=h}},{key:"entityName",set:function(h){this.state.entityName=h}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return this.subscribed=="subscribed"}},{key:"_update",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return Y.next=2,this._initializationPromise;case 2:y=[],tr.debug("User for",this.state.identity,"updated:",v,g),Y.t0=v,Y.next=Y.t0==="friendlyName"?7:Y.t0==="attributes"?9:Y.t0==="reachability"?12:15;break;case 7:return this.state.friendlyName!==g.value&&(y.push("friendlyName"),this.state.friendlyName=g.value),Y.abrupt("break",16);case 9:return k=L(g.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),tr),je.default(this.state.attributes,k)||(this.state.attributes=k,y.push("attributes")),Y.abrupt("break",16);case 12:return this.state.online!==g.online&&(this.state.online=g.online,y.push("reachabilityOnline")),this.state.notifiable!==g.notifiable&&(this.state.notifiable=g.notifiable,y.push("reachabilityNotifiable")),Y.abrupt("break",16);case 15:return Y.abrupt("return");case 16:y.length>0&&this.emit("updated",{user:this,updateReasons:y});case 17:case"end":return Y.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_updateReachabilityInfo",value:function(){var p=re.default(M.default.mark(function _(v,g){var y=this;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){S.next=4;break}return S.abrupt("return",Promise.resolve());case 4:return S.abrupt("return",v.get("reachability").then(g).catch(function(Y){tr.warn("Failed to get reachability info for ",y.state.identity,Y)}));case 5:case"end":return S.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_fetch",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.state.entityName){y.next=4;break}return y.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(k){return v.entity=k,k.on("itemUpdated",function(S){return tr.debug(v.state.entityName+" ("+v.state.identity+") itemUpdated: "+S.item.key),v._update(S.item.key,S.item.data)}),k.on("itemAdded",function(S){return tr.debug(v.state.entityName+" ("+v.state.identity+") itemAdded: "+S.item.key),v._update(S.item.key,S.item.data)}),Promise.all([k.get("friendlyName").then(function(S){return v._update(S.key,S.data)}),k.get("attributes").then(function(S){return v._update(S.key,S.data)}),v._updateReachabilityInfo(k,function(S){return v._update(S.key,S.data)})])}).then(function(){return tr.debug("Fetched for",v.identity),v.subscribed="subscribed",v.emit("userSubscribed",v),v}).catch(function(k){throw v.promiseToFetch=null,k}),y.abrupt("return",this.promiseToFetch);case 6:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_ensureFetched",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:return g.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:v});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){g.next=9;break}return g.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_resolveInitialization",value:function(h,_,v,g){this.configuration=h,this.identity=_,this.entityName=v,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),g&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),w}(N.ReplayEventEmitter);Fe([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],Re.prototype,"updateAttributes",null),Fe([b.validateTypesAsync(["string"]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],Re.prototype,"updateFriendlyName",null);function Ne(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=pe(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1314
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function pe(C,x){if(C){if(typeof C=="string")return $e(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return $e(C,x)}}function $e(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}var ae=function(){function C(x,w){ke.default(this,C),this.configuration=x,this.services=w,this.cache=new Map,this.cacheLifetime=this.configuration.httpCacheInterval*100,this.cleanupCache()}return ye.default(C,[{key:"isExpired",value:function(w){return!this.cacheLifetime||Date.now()-w>this.cacheLifetime}},{key:"cleanupCache",value:function(){var w=Ne(this.cache),p;try{for(w.s();!(p=w.n()).done;){var h=ce.default(p.value,2),_=h[0],v=h[1];this.isExpired(v.timestamp)&&this.cache.delete(_)}}catch(g){w.e(g)}finally{w.f()}this.cache.size===0&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var w=this;this.timer=this.timer||setInterval(function(){return w.cleanupCache()},this.cacheLifetime*2)}},{key:"executeWithRetry",value:function(w){var p=this,h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return new Promise(function(_,v){var g=[502,503,504];h&&g.push(429);var y=new Ee.Retrier(p.configuration.backoffConfiguration);y.on("attempt",function(){w().then(function(k){return y.succeeded(k)}).catch(function(k){g.indexOf(k.status)>-1||k.message==="Twilsock disconnected"?y.failed(k):(y.removeAllListeners(),y.cancel(),v(k))})}),y.on("succeeded",function(k){_(k)}),y.on("cancelled",function(k){return v(k)}),y.on("failed",function(k){return v(k)}),y.start()})}},{key:"get",value:function(){var x=re.default(M.default.mark(function p(h){var _=this,v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(v=this.cache.get(h),!(v&&!this.isExpired(v.timestamp))){S.next=3;break}return S.abrupt("return",v.response);case 3:return g={},S.next=6,this.executeWithRetry(function(){return _.services.transport.get(h,g,_.configuration.productId)},this.configuration.retryWhenThrottled);case 6:return y=S.sent,this.cache.set(h,{response:y,timestamp:Date.now()}),this.pokeTimer(),S.abrupt("return",y);case 10:case"end":return S.stop()}},p,this)}));function w(p){return x.apply(this,arguments)}return w}()}]),C}(),me=ye.default(function C(){ke.default(this,C)});H.default(me,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),H.default(me,"NEW_MESSAGE","twilio.conversations.new_message"),H.default(me,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),H.default(me,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),H.default(me,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");function we(C){var x=K();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function K(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var he=Jt.scope("Participant"),G=function(C){q.default(w,C);var x=we(w);function w(p,h,_,v,g){var y,k,S;if(ke.default(this,w),S=x.call(this),S.conversation=_,S.links=v,S.services=g,S.state={attributes:L(p.attributes,"Retrieved malformed attributes from the server for participant: "+h,he),dateCreated:p.dateCreated?Ot(p.dateCreated):null,dateUpdated:p.dateCreated?Ot(p.dateUpdated):null,sid:h,typingTimeout:null,isTyping:!1,identity:p.identity,roleSid:(y=p.roleSid)!==null&&y!==void 0?y:"",lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,lastReadTimestamp:p.lastConsumptionTimestamp?Ot(p.lastConsumptionTimestamp):null,type:p.type||"chat",userInfo:p.userInfo,bindings:(k=p.bindings)!==null&&k!==void 0?k:{}},!p.identity&&!p.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return S}return ye.default(w,[{key:"sid",get:function(){return this.state.sid}},{key:"attributes",get:function(){return this.state.attributes}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"identity",get:function(){return this.state.identity}},{key:"isTyping",get:function(){return this.state.isTyping}},{key:"lastReadMessageIndex",get:function(){return this.state.lastReadMessageIndex}},{key:"lastReadTimestamp",get:function(){return this.state.lastReadTimestamp}},{key:"roleSid",get:function(){return this.state.roleSid}},{key:"type",get:function(){return this.state.type}},{key:"bindings",get:function(){var h;return(h=this.state.bindings)!==null&&h!==void 0?h:{}}},{key:"_startTyping",value:function(h){var _=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit(w.typingStarted,this),this.conversation.emit(I.typingStarted,this),this.state.typingTimeout=Number(setTimeout(function(){return _._endTyping()},h)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit(w.typingEnded,this),this.conversation.emit(I.typingEnded,this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(h){var _=[],v=L(h.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,he);h.attributes&&!je.default(this.state.attributes,v)&&(this.state.attributes=v,_.push("attributes"));var g=Ot(h.dateUpdated);h.dateUpdated&&(g==null?void 0:g.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=g,_.push("dateUpdated"));var y=Ot(h.dateCreated);if(h.dateCreated&&(y==null?void 0:y.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=y,_.push("dateCreated")),h.roleSid&&this.state.roleSid!==h.roleSid&&(this.state.roleSid=h.roleSid,_.push("roleSid")),(Number.isInteger(h.lastConsumedMessageIndex)||h.lastConsumedMessageIndex===null)&&this.state.lastReadMessageIndex!==h.lastConsumedMessageIndex&&(this.state.lastReadMessageIndex=h.lastConsumedMessageIndex,_.push("lastReadMessageIndex")),h.lastConsumptionTimestamp){var k=new Date(h.lastConsumptionTimestamp);(!this.state.lastReadTimestamp||this.state.lastReadTimestamp.getTime()!==k.getTime())&&(this.state.lastReadTimestamp=k,_.push("lastReadTimestamp"))}return h.bindings&&!je.default(this.state.bindings,h.bindings)&&(this.state.bindings=h.bindings,_.push("bindings")),_.length>0&&this.emit(w.updated,{participant:this,updateReasons:_}),this}},{key:"getUser",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.type=="chat"){g.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return g.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter);H.default(G,"typingStarted","typingStarted"),H.default(G,"typingEnded","typingEnded"),H.default(G,"updated","updated"),Fe([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],G.prototype,"updateAttributes",null);function de(C){var x=ee();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function ee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=Jt.scope("Participants"),qe=function(C){q.default(w,C);var x=de(w);function w(p,h,_,v){var g;return ke.default(this,w),g=x.call(this),H.default(oe.default(g),"rosterEntityPromise",null),g.conversation=p,g.participants=h,g.links=_,g.services=v,g}return ye.default(w,[{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this.rosterEntityPromise){y.next=6;break}return y.next=3,this.rosterEntityPromise;case 3:v=y.sent,v.close(),this.rosterEntityPromise=null;case 6:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"subscribe",value:function(h){var _=this,v=typeof h=="string"?this.services.syncClient.map({id:h,mode:"open_existing"}):Promise.resolve(h);return this.rosterEntityPromise=this.rosterEntityPromise||v.then(function(g){g.on(Oe.SyncMap.itemAdded,function(S){Ye.debug(_.conversation.sid+" itemAdded: "+S.item.key),_.upsertParticipant(S.item.key,S.item.data).then(function(Y){_.emit(I.participantJoined,Y)})}),g.on(Oe.SyncMap.itemRemoved,function(S){Ye.debug(_.conversation.sid+" itemRemoved: "+S.key);var Y=S.key;if(_.participants.has(Y)){var J=_.participants.get(Y);_.participants.delete(Y),J&&_.emit(I.participantLeft,J)}}),g.on(Oe.SyncMap.itemUpdated,function(S){Ye.debug(_.conversation.sid+" itemUpdated: "+S.item.key),_.upsertParticipant(S.item.key,S.item.data).catch(function(Y){return Ye.error(Y)})});var y=[],k=function S(Y){return Y.items.forEach(function(J){y.push(_.upsertParticipant(J.key,J.data))}),Y.hasNextPage?Y.nextPage().then(S):null};return g.getItems().then(k).then(function(){return Promise.all(y)}).then(function(){return g})}).catch(function(g){throw _.rosterEntityPromise=null,_.services.syncClient.connectionState!="disconnected"&&Ye.error("Failed to get roster object for conversation",_.conversation.sid,g),Ye.debug("ERROR: Failed to get roster object for conversation",_.conversation.sid,g),g})}},{key:"upsertParticipantFromResponse",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y,J,le,ge;return M.default.wrap(function(Et){for(;;)switch(Et.prev=Et.next){case 0:return y=v.sid,k=v.attributes,S=v.date_created,Y=v.date_updated,J=v.identity,le=v.role_sid,ge=v.messaging_binding,Et.next=3,this.upsertParticipant(y,{attributes:k,dateCreated:new Date(S),dateUpdated:new Date(Y),identity:J,roleSid:le,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:(g=ge==null?void 0:ge.type)!==null&&g!==void 0?g:"chat"});case 3:return Et.abrupt("return",Et.sent);case 4:case"end":return Et.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"upsertParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y=this,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(k=this.participants.get(v),!k){J.next=3;break}return J.abrupt("return",k._update(g));case 3:return S={self:"".concat(this.links.participants,"/").concat(v)},k=new G(g,v,this.conversation,S,this.services),this.participants.set(v,k),k.on(G.updated,function(le){return y.emit(I.participantUpdated,le)}),J.abrupt("return",k);case 8:case"end":return J.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var k=[];return v.participants.forEach(function(S){return k.push(S)}),k}):[]);case 1:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g=this;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var S=g.participants.get(v);if(!S)throw new Error("Participant with SID "+v+" was not found");return S}):null);case 1:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return y=null,S.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){if(g.participants.forEach(function(Y){Y.identity===v&&(y=Y)}),!y)throw new Error("Participant with identity "+v+" was not found");return y}):null);case 2:case"end":return S.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"add",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:v,attributes:typeof g<"u"?JSON.stringify(g):void 0});case 2:return k.abrupt("return",k.sent);case 3:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k,S,Y,J=arguments;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return S=J.length>2&&J[2]!==void 0?J[2]:{},Y=J.length>3&&J[3]!==void 0?J[3]:{},ge.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:typeof S<"u"?JSON.stringify(S):void 0,messaging_binding:{address:g,proxy_address:v,name:Y==null||(y=Y.email)===null||y===void 0?void 0:y.name,level:Y==null||(k=Y.email)===null||k===void 0?void 0:k.level}});case 4:return ge.abrupt("return",ge.sent);case 5:case"end":return ge.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(h){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(encodeURIComponent(h)))}}]),w}(N.ReplayEventEmitter),dt=function(){function C(x,w){var p;ke.default(this,C),H.default(this,"mcsMedia",null),this.services=w,x instanceof ze.McsMedia&&(this.mcsMedia=x),this.state={sid:x.sid,category:x.category,filename:(p=x.filename)!==null&&p!==void 0?p:null,contentType:x.contentType,size:x.size}}return ye.default(C,[{key:"sid",get:function(){return this.state.sid}},{key:"filename",get:function(){return this.state.filename}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"category",get:function(){return this.state.category}},{key:"getContentTemporaryUrl",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(k=w.mcsMedia?void 0:w._fetchMcsMedia(),S=(y=w.mcsMedia)===null||y===void 0?void 0:y.getContentUrl(),g(function(){k&&k.cancel(),S&&S.cancel()}),le.prev=3,S){le.next=9;break}return le.next=7,k;case 7:Y=le.sent,S=Y==null?void 0:Y.getContentUrl();case 9:if(le.t0=_,!S){le.next=16;break}return le.next=13,S;case 13:le.t1=le.sent,le.next=17;break;case 16:le.t1=null;case 17:le.t2=le.t1,(0,le.t0)(le.t2),le.next=24;break;case 21:le.prev=21,le.t3=le.catch(3),v(le.t3);case 24:case"end":return le.stop()}},h,null,[[3,21]])}));return function(h,_,v){return p.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return w.services.mcsClient===null&&v(new Error("Media Content Service is unavailable")),y=w.services.mcsClient.get(w.state.sid),g(function(){return y.cancel()}),S.prev=3,S.next=6,y;case 6:w.mcsMedia=S.sent,w.state=w.mcsMedia._state(),_(w.mcsMedia),S.next=14;break;case 11:S.prev=11,S.t0=S.catch(3),v(S.t0);case 14:case"end":return S.stop()}},h,null,[[3,11]])}));return function(h,_,v){return p.apply(this,arguments)}}())}},{key:"_state",value:function(){return this.state}}]),C}(),lt=function(){function C(x){ke.default(this,C),this.state=x}return ye.default(C,[{key:"total",get:function(){return this.state.total}},{key:"sent",get:function(){return this.state.sent}},{key:"delivered",get:function(){return this.state.delivered}},{key:"read",get:function(){return this.state.read}},{key:"undelivered",get:function(){return this.state.undelivered}},{key:"failed",get:function(){return this.state.failed}},{key:"_update",value:function(w){this.state=w}},{key:"_isEquals",value:function(w){var p=this.total===w.total,h=this.sent===w.sent,_=this.delivered===w.delivered,v=this.read===w.read,g=this.undelivered===w.undelivered,y=this.failed===w.failed;return p&&h&&_&&v&&g&&y}}]),C}(),ht=function(){function C(x,w,p,h){ke.default(this,C),this.state={prevToken:p,nextToken:h,source:w,items:x}}return ye.default(C,[{key:"hasNextPage",get:function(){return!!this.state.nextToken}},{key:"hasPrevPage",get:function(){return!!this.state.prevToken}},{key:"items",get:function(){return this.state.items}},{key:"nextPage",value:function(){return this.hasNextPage?this.state.source(this.state.nextToken):Promise.reject(new Error("No next page"))}},{key:"prevPage",value:function(){return this.hasPrevPage?this.state.source(this.state.prevToken):Promise.reject(new Error("No previous page"))}}]),C}(),Rt=ye.default(function C(x){ke.default(this,C),this.sid=x.sid,this.messageSid=x.message_sid,this.conversationSid=x.conversation_sid,this.channelMessageSid=x.channel_message_sid,this.participantSid=x.participant_sid,this.status=x.status||"queued",this.errorCode=x.error_code||0,this.dateCreated=x.date_created,this.dateUpdated=x.date_updated}),xt=function(x){return x.map(function(w){var p,h,_,v,g=JSON.stringify(w);switch(w.type){case"QUICK_REPLY":return{type:"reply",title:w.title,id:(p=w.id)!==null&&p!==void 0?p:"",index:(h=w.index)!==null&&h!==void 0?h:0,rawData:g};case"PHONE_NUMBER":return{type:"phone",title:w.title,phone:(_=w.phone)!==null&&_!==void 0?_:"",rawData:g};case"URL":return{type:"url",title:w.title,url:(v=w.url)!==null&&v!==void 0?v:"",rawData:g};default:return{type:"other",rawData:g}}})},kt=function(x,w){var p=JSON.stringify(w);switch(x){case"twilio/text":{var h=w;return{type:"text",body:h.body,rawData:p}}case"twilio/media":{var _=w;return{type:"media",body:_.body,media:_.media,rawData:p}}case"twilio/location":{var v=w;return{type:"location",longitude:v.longitude,latitude:v.latitude,label:v.label,rawData:p}}case"twilio/quick-reply":{var g=w;return{type:"quickReply",body:g.body,replies:g.actions,rawData:p}}case"twilio/call-to-action":{var y=w;return{type:"callToAction",body:y.body,actions:xt(y.actions),rawData:p}}case"twilio/list-picker":{var k=w;return{type:"listPicker",body:k.body,button:k.button,items:k.items,rawData:p}}case"twilio/card":{var S,Y,J=w;return{type:"card",title:J.title,subtitle:J.subtitle,media:(S=J.media)!==null&&S!==void 0?S:[],actions:xt((Y=J.actions)!==null&&Y!==void 0?Y:[]),rawData:p}}default:return{type:"other",rawData:p}}},$t=function(x){for(var w=new Map,p=0,h=Object.entries(x);p<h.length;p++){var _=ce.default(h[p],2),v=_[0],g=_[1];w.set(v,kt(v,g))}return w},It=function(){function C(x,w){ke.default(this,C),this.name=x,this.value=w}return ye.default(C,[{key:"copyWithValue",value:function(w){return new C(this.name,w)}}]),C}(),jt=ye.default(function C(x){ke.default(this,C),this.sid=x.sid,this.friendlyName=x.friendly_name,this.variables=Object.entries(JSON.parse(x.variables)).map(function(w){var p=ce.default(w,2),h=p[0],_=p[1];return new It(h,_)}),this.variants=$t(x.variants),this.dateCreated=new Date(x.date_created),this.dateUpdated=new Date(x.date_updated)});function sn(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function _n(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?sn(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):sn(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Ut(C){var x=qn();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function qn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ha(C,x){Wa(C,x),x.add(C)}function Wa(C,x){if(x.has(C))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ti(C,x,w){if(!x.has(C))throw new TypeError("attempted to get private field on non-instance");return w}var pa=Jt.scope("Message"),ri=e.XMLHttpRequest||{},gi=new WeakSet,Za=new WeakSet,en=function(C){q.default(w,C);var x=Ut(w);function w(p,h,_,v,g,y){var k,S,Y,J,le,ge,vt,Et;return ke.default(this,w),Et=x.call(this),ha(oe.default(Et),Za),ha(oe.default(Et),gi),Et.conversation=_,Et.links=v,Et.configuration=g,Et.services=y,Et.state={sid:h.sid,index:p,author:h.author,subject:h.subject,contentSid:h.contentSid,body:(k=h.text)!==null&&k!==void 0?k:null,timestamp:h.timestamp?new Date(h.timestamp):null,dateUpdated:h.dateUpdated?new Date(h.dateUpdated):null,lastUpdatedBy:(S=h.lastUpdatedBy)!==null&&S!==void 0?S:null,attributes:L(h.attributes,"Got malformed attributes for the message ".concat(h.sid),pa),type:(Y=h.type)!==null&&Y!==void 0?Y:"text",media:null,medias:null,participantSid:(J=h.memberSid)!==null&&J!==void 0?J:null,aggregatedDeliveryReceipt:h.delivery?new lt(h.delivery):null,hasChannelMetadata:(le=h.channelMetadata)!==null&&le!==void 0?le:!1},ti(oe.default(Et),Za,Ms).call(oe.default(Et),(ge=h.medias)!==null&&ge!==void 0?ge:null,(vt=h.media)!==null&&vt!==void 0?vt:null),Et}return ye.default(w,[{key:"sid",get:function(){return this.state.sid}},{key:"author",get:function(){return this.state.author}},{key:"subject",get:function(){return this.state.subject}},{key:"contentSid",get:function(){return this.state.contentSid}},{key:"body",get:function(){return this.state.body}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"index",get:function(){return this.state.index}},{key:"lastUpdatedBy",get:function(){return this.state.lastUpdatedBy}},{key:"dateCreated",get:function(){return this.state.timestamp}},{key:"attributes",get:function(){return this.state.attributes}},{key:"type",get:function(){return this.state.type}},{key:"media",get:function(){return this.state.media}},{key:"attachedMedia",get:function(){return this.getMediaByCategories(["media"])}},{key:"participantSid",get:function(){return this.state.participantSid}},{key:"aggregatedDeliveryReceipt",get:function(){return this.state.aggregatedDeliveryReceipt}},{key:"getMediaByCategory",value:function(h){return this.getMediaByCategories(h)}},{key:"getMediaByCategories",value:function(h){var _;return((_=this.state.medias)!==null&&_!==void 0?_:[]).filter(function(v){return h.includes(v.category)})}},{key:"getEmailBody",value:function(){var h,_,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(h=(_=this.getMediaByCategories(["body"]))===null||_===void 0?void 0:_.filter(function(g){return g.contentType==v}).shift())!==null&&h!==void 0?h:null}},{key:"getEmailHistory",value:function(){var h,_,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(h=(_=this.getMediaByCategories(["history"]))===null||_===void 0?void 0:_.filter(function(g){return g.contentType==v}).shift())!==null&&h!==void 0?h:null}},{key:"_update",value:function(h){var _,v=this,g,y,k,S=[];(h.text||typeof h.text=="string")&&h.text!==this.state.body&&(this.state.body=h.text,S.push("body")),h.subject&&h.subject!==this.state.subject&&(this.state.subject=h.subject,S.push("subject")),h.lastUpdatedBy&&h.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=h.lastUpdatedBy,S.push("lastUpdatedBy")),h.author&&h.author!==this.state.author&&(this.state.author=h.author,S.push("author")),h.dateUpdated&&new Date(h.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(h.dateUpdated),S.push("dateUpdated")),h.timestamp&&new Date(h.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(h.timestamp),S.push("dateCreated"));var Y=L(h.attributes,"Got malformed attributes for the message ".concat(this.sid),pa);je.default(this.state.attributes,Y)||(this.state.attributes=Y,S.push("attributes"));var J=h.delivery,le=this.state.aggregatedDeliveryReceipt,ge=!!J&&!!J.total&&!!J.delivered&&!!J.failed&&!!J.read&&!!J.sent&&!!J.undelivered;ge&&(le?le._isEquals(J)||(le._update(J),S.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new lt(J),S.push("deliveryReceipt")));var vt=((_=h.medias)!==null&&_!==void 0?_:[]).map(function(_r){var mr;return(mr=ti(v,gi,ji).call(v,_r))===null||mr===void 0?void 0:mr._state()}).filter(function(_r){return _r!==null}),Et=((g=this.state.medias)!==null&&g!==void 0?g:[]).map(function(_r){return _r._state()}).filter(function(_r){return _r!==null});if(!je.default(vt,Et)||!je.default((y=ti(this,gi,ji).call(this,h.media))===null||y===void 0?void 0:y._state(),(k=this.state.media)===null||k===void 0?void 0:k._state())){var Ht,Qt;ti(this,Za,Ms).call(this,(Ht=h.medias)!==null&&Ht!==void 0?Ht:null,(Qt=h.media)!==null&&Qt!==void 0?Qt:null),S.push("media")}S.length>0&&this.emit("updated",{message:this,updateReasons:S})}},{key:"getParticipant",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(g=null,!this.state.participantSid){S.next=5;break}return S.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch(function(){return pa.debug('Participant with sid "'.concat(v.participantSid,'" not found for message ').concat(v.sid)),null});case 4:g=S.sent;case 5:if(!(!g&&this.state.author)){S.next=9;break}return S.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch(function(){return pa.debug('Participant with identity "'.concat(v.author,'" not found for message ').concat(v.sid)),null});case 8:g=S.sent;case 9:if(!g){S.next=11;break}return S.abrupt("return",g);case 11:throw y="Participant with ",this.state.participantSid&&(y+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(y+="or "),y+="identity '"+this.state.author+"' "),y==="Participant with "&&(y="Participant "),y+="was not found",new Error(y);case 17:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getDetailedDeliveryReceipts",value:function(){var p=re.default(M.default.mark(function _(){var v,g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:v=k.sent,g=v.items;case 4:if(!v.hasNextPage){k.next=11;break}return k.next=7,v.nextPage();case 7:v=k.sent,g=[].concat(rt.default(g),rt.default(v.items)),k.next=4;break;case 11:return k.abrupt("return",g);case 12:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateBody",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:v});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:typeof v<"u"?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"attachTemporaryUrlsFor",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(y=v==null?void 0:v.map(function(Y){return Y.sid}),!(this.services.mcsClient&&y)){S.next=7;break}return S.next=4,this.services.mcsClient.mediaSetGet(y);case 4:return S.abrupt("return",S.sent.map(function(Y){return new dt(Y,g.services)}));case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return S.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMedia",value:function(h){var _=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(_)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var _=this;return new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(Y=_.services.mcsClient.mediaSetGetContentUrls(h??[]),!(!_.services.mcsClient||!h)){ge.next=4;break}return k(new Error("Media Content Service is unavailable")),ge.abrupt("return");case 4:return S(function(){Y.cancel()}),ge.prev=5,ge.next=8,Y;case 8:J=ge.sent,y(J),ge.next=15;break;case 12:ge.prev=12,ge.t0=ge.catch(5),k(ge.t0);case 15:case"end":return ge.stop()}},g,null,[[5,12]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var h,_=this.attachedMedia,v=(h=_==null?void 0:_.map(function(g){return g.sid}))!==null&&h!==void 0?h:[];return this.getTemporaryContentUrlsForMediaSids(v)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),k=new W(y).arg("PageToken",v==null?void 0:v.pageToken).arg("PageSize",v==null?void 0:v.pageSize).build(),J.next=4,this.services.network.get(k);case 4:return S=J.sent,J.abrupt("return",new ht(S.body.delivery_receipts.map(function(le){return new Rt(le)}),function(le,ge){return g._getDetailedDeliveryReceiptsPaginator({pageToken:le,pageSize:ge})},S.body.meta.previous_token,S.body.meta.next_token));case 6:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getContentData",value:function(){var h=this;return new ze.CancellablePromise(function(){var _=re.default(M.default.mark(function v(g,y,k){var S,Y,J,le,ge,vt,Et,Ht,Qt,_r;return M.default.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:if(h.state.contentSid!==null){Gt.next=3;break}return g(null),Gt.abrupt("return");case 3:if(S=h.getMediaByCategories(["body"]),S!==null){Gt.next=7;break}return g(null),Gt.abrupt("return");case 7:if(Y="application/x-vnd.com.twilio.rich.",J=S.filter(function(yi){return yi.contentType.startsWith(Y)}),J.length!==0){Gt.next=12;break}return g(null),Gt.abrupt("return");case 12:return le=J[0],ge=le.getContentTemporaryUrl(),k(function(){ge.cancel()}),Gt.prev=15,Gt.next=18,ge;case 18:vt=Gt.sent,Gt.next=25;break;case 21:return Gt.prev=21,Gt.t0=Gt.catch(15),y(Gt.t0),Gt.abrupt("return");case 25:if(vt!==null){Gt.next=28;break}return g(null),Gt.abrupt("return");case 28:return Et=new Promise(function(yi,Qp){var Lt,Us=!1,bi=new ri;bi.open("GET",(Lt=vt)!==null&&Lt!==void 0?Lt:"",!0),bi.responseType="text",bi.onreadystatechange=function(){bi.readyState!==4||Us||yi(bi.responseText)},bi.onerror=function(){Qp(bi.statusText)},k(function(){Us=!0,bi.abort(),Qp(new Error("XHR has been aborted"))}),bi.send()}),Gt.prev=29,Gt.next=32,Et;case 32:Qt=Gt.sent,Ht=JSON.parse(Qt),Gt.next=40;break;case 36:return Gt.prev=36,Gt.t1=Gt.catch(29),y(Gt.t1),Gt.abrupt("return");case 40:_r=le.contentType.replace(Y,"").replace(".","/"),g(kt(_r,Ht.data));case 42:case"end":return Gt.stop()}},v,null,[[15,21],[29,36]])}));return function(v,g,y){return _.apply(this,arguments)}}())}},{key:"getChannelMetadata",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.state.hasChannelMetadata){g.next=2;break}return g.abrupt("return",null);case 2:return g.next=4,this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid,this.sid);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid,this.sid);case 2:return g.abrupt("return",g.sent);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter);function ji(C){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return C?x?new dt(_n(_n({},C),{},{category:x}),this.services):new dt(C,this.services):null}function Ms(C,x){var w=this;this.state.media=ti(this,gi,ji).call(this,x),this.state.medias=C?C.map(function(p){return ti(w,gi,ji).call(w,p)}).filter(function(p){return p!==null}):x&&!C?[ti(this,gi,ji).call(this,x,"media")].filter(function(p){return p!==null}):null}H.default(en,"updated","updated"),Fe([V.deprecated("getMediaByCategory","getMediaByCategories"),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Array)],en.prototype,"getMediaByCategory",null),Fe([b.validateTypes([b.nonEmptyString,"undefined"]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",dt)],en.prototype,"getEmailBody",null),Fe([b.validateTypes([b.nonEmptyString,"undefined"]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",dt)],en.prototype,"getEmailHistory",null),Fe([b.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],en.prototype,"updateBody",null),Fe([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],en.prototype,"updateAttributes",null),Fe([V.deprecated("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Promise)],en.prototype,"attachTemporaryUrlsFor",null),Fe([b.validateTypesAsync(b.nonEmptyArray("media",dt)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],en.prototype,"getTemporaryContentUrlsForMedia",null),Fe([b.validateTypesAsync(b.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],en.prototype,"getTemporaryContentUrlsForMediaSids",null);function Ui(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function Ns(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?Ui(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):Ui(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Bo(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Vn(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1315
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Vn(C,x){if(C){if(typeof C=="string")return Ls(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Ls(C,x)}}function Ls(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}function zo(C){var x=Ho();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Ho(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var hn=Jt.scope("Messages"),Ds=function(C){q.default(w,C);var x=zo(w);function w(p,h,_){var v;return ke.default(this,w),v=x.call(this),v.conversation=p,v.configuration=h,v.services=_,v.messagesByIndex=new Map,v.messagesListPromise=null,v}return ye.default(w,[{key:"subscribe",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!this.messagesListPromise){S.next=2;break}return S.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise=typeof v=="string"?this.services.syncClient.list({id:v,mode:"open_existing"}):Promise.resolve(v),S.prev=3,S.next=6,this.messagesListPromise;case 6:return y=S.sent,y.on("itemAdded",function(Y){hn.debug("".concat(g.conversation.sid," itemAdded: ").concat(Y.item.index));var J={self:"".concat(g.conversation._links.messages,"/").concat(Y.item.data.sid),conversation:g.conversation._links.self,messages_receipts:"".concat(g.conversation._links.messages,"/").concat(Y.item.data.sid,"/Receipts")},le=new en(Y.item.index,Y.item.data,g.conversation,J,g.configuration,g.services);if(g.messagesByIndex.has(le.index)){hn.debug("Message arrived, but is already known and ignored",g.conversation.sid,le.index);return}g.messagesByIndex.set(le.index,le),le.on("updated",function(ge){return g.emit("messageUpdated",ge)}),g.emit("messageAdded",le)}),y.on("itemRemoved",function(Y){hn.debug("#{this.conversation.sid} itemRemoved: ".concat(Y.index));var J=Y.index;if(g.messagesByIndex.has(J)){var le=g.messagesByIndex.get(J);if(!le)return;g.messagesByIndex.delete(le.index),le.removeAllListeners("updated"),g.emit("messageRemoved",le)}}),y.on("itemUpdated",function(Y){hn.debug("".concat(g.conversation.sid," itemUpdated: ").concat(Y.item.index));var J=g.messagesByIndex.get(Y.item.index);J&&J._update(Y.item.data)}),S.abrupt("return",y);case 13:throw S.prev=13,S.t0=S.catch(3),this.messagesListPromise=null,this.services.syncClient.connectionState!=="disconnected"&&hn.error("Failed to get messages object for conversation",this.conversation.sid,S.t0),hn.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,S.t0),S.t0;case 19:case"end":return S.stop()}},_,this,[[3,13]])}));function h(_){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.messagesListPromise){y.next=2;break}return y.abrupt("return");case 2:return y.next=4,this.messagesListPromise;case 4:v=y.sent,v.close(),this.messagesListPromise=null;case 7:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"sendV2",value:function(h){var _=this;return hn.debug("Sending message V2",h.mediaContent,h.attributes,h.emailOptions),new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J,le,ge,vt,Et,Ht,Qt,_r,mr,Gt,yi;return M.default.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:J=[],le=[],S(function(){le.forEach(function(Us){return Us.cancel()})}),ge=Bo(h.mediaContent),Lt.prev=4,ge.s();case 6:if((vt=ge.n()).done){Lt.next=25;break}return Et=ce.default(vt.value,2),Ht=Et[0],Qt=Et[1],Lt.prev=8,hn.debug("Adding media to a message as ".concat(Qt instanceof FormData?"FormData":"SendMediaOptions"),Qt),Gt=Qt instanceof FormData?_.services.mcsClient.postFormData(Qt,Ht):_.services.mcsClient.post((_r=Qt.contentType)!==null&&_r!==void 0?_r:"",(mr=Qt.media)!==null&&mr!==void 0?mr:"",Ht,Qt.filename),le.push(Gt),Lt.t0=J,Lt.next=15,Gt;case 15:Lt.t1=Lt.sent,Lt.t0.push.call(Lt.t0,Lt.t1),Lt.next=23;break;case 19:return Lt.prev=19,Lt.t2=Lt.catch(8),k(Lt.t2),Lt.abrupt("return");case 23:Lt.next=6;break;case 25:Lt.next=30;break;case 27:Lt.prev=27,Lt.t3=Lt.catch(4),ge.e(Lt.t3);case 30:return Lt.prev=30,ge.f(),Lt.finish(30);case 33:return yi=_.services.commandExecutor.mutateResource("post",_.conversation._links.messages,{body:h.text,subject:(Y=h.emailOptions)===null||Y===void 0?void 0:Y.subject,media_sids:J.map(function(Us){return Us.sid}),attributes:typeof h.attributes<"u"?JSON.stringify(h.attributes):void 0,content_sid:h.contentSid,content_variables:typeof h.contentVariables<"u"?JSON.stringify(h.contentVariables.reduce(function(Us,bi){return Ns(Ns({},Us),{},H.default({},bi.name,bi.value))},{})):void 0}),Lt.prev=34,Lt.t4=y,Lt.next=38,yi;case 38:Lt.t5=Lt.sent,(0,Lt.t4)(Lt.t5),Lt.next=45;break;case 42:Lt.prev=42,Lt.t6=Lt.catch(34),k(Lt.t6);case 45:case"end":return Lt.stop()}},g,null,[[4,27,30,33],[8,19],[34,42]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"send",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k=arguments;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return g=k.length>1&&k[1]!==void 0?k[1]:{},y=k.length>2?k[2]:void 0,hn.debug("Sending text message",v,g,y),Y.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:v??"",attributes:typeof g<"u"?JSON.stringify(g):void 0,subject:y==null?void 0:y.subject}));case 4:case"end":return Y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"sendMedia",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y,J=arguments;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(k=J.length>1&&J[1]!==void 0?J[1]:{},S=J.length>2?J[2]:void 0,hn.debug("Sending media message",v,k,S),hn.debug("Sending media message as ".concat(v instanceof FormData?"FormData":"SendMediaOptions"),v,k),!(v instanceof FormData)){ge.next=10;break}return ge.next=7,this.services.mcsClient.postFormData(v);case 7:ge.t0=ge.sent,ge.next=13;break;case 10:return ge.next=12,this.services.mcsClient.post((g=v.contentType)!==null&&g!==void 0?g:"",(y=v.media)!==null&&y!==void 0?y:"","media",v.filename);case 12:ge.t0=ge.sent;case 13:return Y=ge.t0,ge.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[Y.sid],attributes:typeof k<"u"?JSON.stringify(k):void 0});case 16:return ge.abrupt("return",ge.sent);case 17:case"end":return ge.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k=arguments;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=k.length>2&&k[2]!==void 0?k[2]:"backwards",Y.abrupt("return",this._getMessages(v,g,y));case 2:case"end":return Y.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_wrapPaginator",value:function(h,_,v){var g=this,y=h==="desc",k=function(){return _.nextPage().then(function(J){return g._wrapPaginator(h,J,v)})},S=function(){return _.prevPage().then(function(J){return g._wrapPaginator(h,J,v)})};return v(_.items).then(function(Y){return{items:Y.sort(function(J,le){return J.index-le.index}),hasPrevPage:y?_.hasNextPage:_.hasPrevPage,hasNextPage:y?_.hasPrevPage:_.hasNextPage,prevPage:y?k:S,nextPage:y?S:k}})}},{key:"_upsertMessage",value:function(h,_){var v=this,g=this.messagesByIndex.get(h);if(g)return g;var y={self:"".concat(this.conversation._links.messages,"/").concat(_.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(_.sid,"/Receipts")},k=new en(h,_,this.conversation,y,this.configuration,this.services);return this.messagesByIndex.set(k.index,k),k.on("updated",function(S){return v.emit("messageUpdated",S)}),k}},{key:"_getMessages",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y,k,S,Y,J,le=arguments;return M.default.wrap(function(vt){for(;;)switch(vt.prev=vt.next){case 0:return g=le.length>0&&le[0]!==void 0?le[0]:30,y=le.length>1&&le[1]!==void 0?le[1]:"end",k=le.length>2&&le[2]!==void 0?le[2]:"forward",S=k==="backwards"?"desc":"asc",vt.next=6,this.messagesListPromise;case 6:return Y=vt.sent,vt.next=9,Y==null?void 0:Y.getItems({from:y!=="end"?y:void 0,pageSize:g,order:S,limit:g});case 9:return J=vt.sent,vt.next=12,this._wrapPaginator(S,J,function(Et){return Promise.all(Et.map(function(Ht){return v._upsertMessage(Ht.index,Ht.data)}))});case 12:return vt.abrupt("return",vt.sent);case 13:case"end":return vt.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter),Pn=function(){function C(x){ke.default(this,C),H.default(this,"attributes",{}),H.default(this,"mediaContent",[]),H.default(this,"emailOptions",{}),this.messagesEntity=x}return ye.default(C,[{key:"send",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=w.messagesEntity.sendV2(w),g(function(){return y.cancel()}),Y.prev=2,Y.next=5,y;case 5:k=Y.sent,_(Wt(k.index)),Y.next=12;break;case 9:Y.prev=9,Y.t0=Y.catch(2),v(Y.t0);case 12:case"end":return Y.stop()}},h,null,[[2,9]])}));return function(h,_,v){return p.apply(this,arguments)}}())}}]),C}(),Dr=function(){function C(x,w){ke.default(this,C),this.limits=x,this.message=new Pn(w),this.emailBodies=new Map,this.emailHistories=new Map}return ye.default(C,[{key:"setBody",value:function(w){return this.message.text=w,this}},{key:"setSubject",value:function(w){return this.message.emailOptions.subject=w,this}},{key:"setAttributes",value:function(w){return this.message.attributes=w,this}},{key:"setEmailBody",value:function(w,p){return this.emailBodies.set(w,p),this}},{key:"setEmailHistory",value:function(w,p){return this.emailHistories.set(w,p),this}},{key:"setContentTemplate",value:function(w){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return this.message.contentSid=w,this.message.contentVariables=p,this}},{key:"addMedia",value:function(w){if(typeof FormData>"u"&&w instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(w instanceof FormData)){var p=w;if(!p.contentType||!p.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",w]),this}},{key:"build",value:function(){var w=this;if(this.emailBodies.forEach(function(p,h){if(!w.limits.emailBodiesAllowedContentTypes.includes(h))throw new Error("Unsupported email body content type ".concat(h))}),this.emailHistories.forEach(function(p,h){if(!w.limits.emailHistoriesAllowedContentTypes.includes(h))throw new Error("Unsupported email history content type ".concat(h))}),this.emailBodies.size>this.limits.emailBodiesAllowedContentTypes.length)throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size," > ").concat(this.limits.emailBodiesAllowedContentTypes.length,")"));if(this.emailHistories.size>this.limits.emailHistoriesAllowedContentTypes.length)throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size," > ").concat(this.limits.emailHistoriesAllowedContentTypes.length,")"));if(this.message.mediaContent.length>this.limits.mediaAttachmentsCountLimit)throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length," > ").concat(this.limits.mediaAttachmentsCountLimit,")"));return this.emailBodies.forEach(function(p){w.message.mediaContent.push(["body",p])}),this.emailHistories.forEach(function(p){w.message.mediaContent.push(["history",p])}),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),C}();Fe([b.validateTypes("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Dr)],Dr.prototype,"setBody",null),Fe([b.validateTypes("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Dr)],Dr.prototype,"setSubject",null),Fe([b.validateTypes(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Dr)],Dr.prototype,"setAttributes",null),Fe([b.validateTypes("string",[FormData,ct]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Dr)],Dr.prototype,"setEmailBody",null),Fe([b.validateTypes("string",[FormData,ct]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Dr)],Dr.prototype,"setEmailHistory",null),Fe([b.validateTypes("string",[b.array("content variables",It),"undefined"]),be("design:type",Function),be("design:paramtypes",[String,Array]),be("design:returntype",Dr)],Dr.prototype,"setContentTemplate",null),Fe([b.validateTypes([FormData,ct]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Dr)],Dr.prototype,"addMedia",null);function qo(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=ni(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1316
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function ni(C,x){if(C){if(typeof C=="string")return Mn(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Mn(C,x)}}function Mn(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}function js(C){var x=te();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function te(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ue={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"},I=function(C){q.default(w,C);var x=js(w);function w(p,h,_,v,g){var y,k,S;ke.default(this,w),S=x.call(this),S.sid=h,S._links=_,S._configuration=v,S._services=g,S._entityName=p.channel,S._internalState={uniqueName:p.uniqueName||null,status:"notParticipating",attributes:(y=p.attributes)!==null&&y!==void 0?y:{},createdBy:p.createdBy,dateCreated:Ot(p.dateCreated),dateUpdated:Ot(p.dateUpdated),friendlyName:p.friendlyName||null,lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,bindings:(k=p.bindings)!==null&&k!==void 0?k:{}},p.notificationLevel&&(S._internalState.notificationLevel=p.notificationLevel);var Y={participants:S._links.participants};return S._participants=new Map,S._participantsEntity=new qe(oe.default(S),S._participants,Y,S._services),S._participantsEntity.on(w.participantJoined,function(J){return S.emit(w.participantJoined,J)}),S._participantsEntity.on(w.participantLeft,function(J){return S.emit(w.participantLeft,J)}),S._participantsEntity.on(w.participantUpdated,function(J){return S.emit(w.participantUpdated,J)}),S._messagesEntity=new Ds(oe.default(S),v,g),S._messagesEntity.on(w.messageAdded,function(J){return S._onMessageAdded(J)}),S._messagesEntity.on(w.messageUpdated,function(J){return S.emit(w.messageUpdated,J)}),S._messagesEntity.on(w.messageRemoved,function(J){return S.emit(w.messageRemoved,J)}),S}return ye.default(w,[{key:"uniqueName",get:function(){return this._internalState.uniqueName}},{key:"status",get:function(){return this._internalState.status}},{key:"friendlyName",get:function(){return this._internalState.friendlyName}},{key:"dateUpdated",get:function(){return this._internalState.dateUpdated}},{key:"dateCreated",get:function(){return this._internalState.dateCreated}},{key:"createdBy",get:function(){var h;return(h=this._internalState.createdBy)!==null&&h!==void 0?h:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var h;return(h=this._internalState.lastMessage)!==null&&h!==void 0?h:void 0}},{key:"notificationLevel",get:function(){var h;return(h=this._internalState.notificationLevel)!==null&&h!==void 0?h:"default"}},{key:"bindings",get:function(){return this._internalState.bindings}},{key:"limits",get:function(){return this._configuration.limits}},{key:"state",get:function(){return this._internalState.state}},{key:"_statusSource",get:function(){return this._dataSource}},{key:"add",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.abrupt("return",this._participantsEntity.add(v,g??{}));case 1:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k,S=arguments;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=S.length>2&&S[2]!==void 0?S[2]:{},k=S.length>3&&S[3]!==void 0?S[3]:{},J.abrupt("return",this._participantsEntity.addNonChatParticipant(v,g,y??{},k??{}));case 3:case"end":return J.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"advanceLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._subscribeStreams();case 2:if(!(v<((g=this.lastReadMessageIndex)!==null&&g!==void 0?g:0))){k.next=6;break}return k.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:return k.abrupt("return",k.sent);case 6:return k.next=8,this._setLastReadMessageIndex(v);case 8:return k.abrupt("return",k.sent);case 9:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"delete",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getAttributes",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribe();case 2:return g.abrupt("return",this.attributes);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=re.default(M.default.mark(function _(v,g,y){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._subscribeStreams();case 2:return S.abrupt("return",this._messagesEntity.getMessages(v,g,y));case 3:case"end":return S.stop()}},_,this)}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantsCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new W(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.participants_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this._participantsEntity.getParticipantBySid(v));case 1:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=re.default(M.default.mark(function _(){var v,g=arguments;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return v=g.length>0&&g[0]!==void 0?g[0]:"",k.abrupt("return",this._participantsEntity.getParticipantByIdentity(v??""));case 2:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessagesCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new W(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.messages_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getUnreadMessagesCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return v=new W(this._configuration.links.myConversations).path(this.sid).build(),S.next=3,this._services.network.get(v);case 3:if(g=S.sent,g.body.conversation_sid===this.sid){S.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if(y=g.body.unread_messages_count,typeof y!="number"){S.next=9;break}return S.abrupt("return",y);case 9:return S.abrupt("return",null);case 10:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"join",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"leave",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this._internalState.status!=="joined"){g.next=3;break}return g.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return g.abrupt("return",this);case 4:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"removeParticipant",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._participantsEntity.remove(typeof v=="string"?v:v.sid);case 2:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"sendMessage",value:function(){var p=re.default(M.default.mark(function _(v,g,y){var k,S,Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(!(typeof v=="string"||v===null)){ge.next=5;break}return ge.next=3,this._messagesEntity.send(v,g,y);case 3:return Y=ge.sent,ge.abrupt("return",(S=Wt(Y.index))!==null&&S!==void 0?S:0);case 5:return ge.next=7,this._messagesEntity.sendMedia(v,g,y);case 7:return J=ge.sent,ge.abrupt("return",(k=Wt(J.index))!==null&&k!==void 0?k:0);case 9:case"end":return ge.stop()}},_,this)}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"prepareMessage",value:function(){return new Dr(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.next=4,this.getMessages(1);case 4:if(v=y.sent,!(v.items.length>0)){y.next=7;break}return y.abrupt("return",this.advanceLastReadMessageIndex(v.items[0].index));case 7:return y.abrupt("return",0);case 8:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setAllMessagesUnread",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.next=4,this._setLastReadMessageIndex(null);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setUserNotificationLevel",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:v});case 2:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:v!==void 0?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.friendlyName===v){y.next=3;break}return y.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:v});case 3:return y.abrupt("return",this);case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.abrupt("return",this._setLastReadMessageIndex(v));case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.uniqueName===v){y.next=4;break}return v||(v=""),y.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:v});case 4:return y.abrupt("return",this);case 5:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid,v);case 2:return y.abrupt("return",y.sent);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"_subscribe",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._entityPromise){y.next=2;break}return y.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),y.prev=3,y.next=6,this._entityPromise;case 6:return this._entity=y.sent,this._entity.on(Oe.SyncDocument.updated,function(k){return v._update(k.data)}),this._entity.on(Oe.SyncDocument.removed,function(){return v.emit(w.removed,v)}),this._update(this._entity.data),y.abrupt("return",this._entity);case 13:throw y.prev=13,y.t0=y.catch(3),this._entity=null,this._entityPromise=null,this._services.syncClient.connectionState!="disconnected"&&w._logger.error("Failed to get conversation object",y.t0),w._logger.debug("ERROR: Failed to get conversation object",y.t0),y.t0;case 20:case"end":return y.stop()}},_,this,[[3,13]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_fetchStreams",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._streamsPromise){y.next=2;break}return y.abrupt("return",this._streamsPromise);case 2:return this._streamsPromise=new Promise(function(){var k=re.default(M.default.mark(function S(Y,J){var le,ge,vt,Et,Ht;return M.default.wrap(function(_r){for(;;)switch(_r.prev=_r.next){case 0:return _r.prev=0,_r.next=3,v._subscribe();case 3:_r.next=9;break;case 5:return _r.prev=5,_r.t0=_r.catch(0),w._logger.trace("Failed to subscribe to conversation",_r.t0),_r.abrupt("return",J(_r.t0));case 9:w._logger.trace("_streamsAvailable, this.entity.data=",(le=v._entity)===null||le===void 0?void 0:le.data),vt=(ge=v._entity)===null||ge===void 0?void 0:ge.data,Et=v._services.syncClient.list({id:vt.messages,mode:"open_existing"}).then(function(mr){return v._messagesList=mr,mr}),Ht=v._services.syncClient.map({id:vt.roster,mode:"open_existing"}).then(function(mr){return v._participantsMap=mr,mr}),Promise.all([Et,Ht]).then(function(){return Y(!0)}).catch(function(mr){w._logger.trace("Failed to fetch conversation streams for conversation",v.sid,mr),J(mr)});case 14:case"end":return _r.stop()}},S,null,[[0,5]])}));return function(S,Y){return k.apply(this,arguments)}}()),y.abrupt("return",this._streamsPromise.catch(function(k){throw v._streamsPromise=null,k}));case 4:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeStreams",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y,k,S,Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return ge.prev=0,ge.next=3,this._fetchStreams();case 3:return w._logger.trace("_subscribeStreams, this.entity.data=",(v=this._entity)===null||v===void 0?void 0:v.data),S=(g=this._entity)===null||g===void 0?void 0:g.data,Y=S.messages,J=S.roster,ge.next=9,Promise.all([this._messagesEntity.subscribe((y=this._messagesList)!==null&&y!==void 0?y:Y),this._participantsEntity.subscribe((k=this._participantsMap)!==null&&k!==void 0?k:J)]);case 9:ge.next=16;break;case 11:throw ge.prev=11,ge.t0=ge.catch(0),this._services.syncClient.connectionState!=="disconnected"&&w._logger.error("Failed to subscribe on conversation objects",this.sid,ge.t0),w._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,ge.t0),ge.t0;case 16:case"end":return ge.stop()}},_,this,[[0,11]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return this._entity&&(this._entity.close(),this._entity=null,this._entityPromise=null),g.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 2:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_setStatus",value:function(h,_){var v=this;if(this._dataSource=_,this._internalState.status!==h){if(this._internalState.status=h,h==="joined"){this._subscribeStreams().catch(function(g){if(w._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g});return}this._entityPromise&&this._unsubscribe().catch(function(g){if(w._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g})}}},{key:"_update",value:function(h){var _,v,g,y,k;w._logger.trace("_update",h),w.preprocessUpdate(h,this.sid);for(var S=new Set,Y=0,J=Object.keys(h);Y<J.length;Y++){var le=J[Y],ge=ue[le];if(ge)switch(ge){case ue.status:if(!h.status||h.status==="unknown"||this._internalState.status===h.status)break;this._internalState.status=h.status,S.add(ge);break;case ue.attributes:if(je.default(this._internalState.attributes,h.attributes))break;this._internalState.attributes=h.attributes,S.add(ge);break;case ue.lastConsumedMessageIndex:if(h.lastConsumedMessageIndex===void 0||h.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=h.lastConsumedMessageIndex,S.add("lastReadMessageIndex");break;case ue.lastMessage:if(this._internalState.lastMessage&&!h.lastMessage){delete this._internalState.lastMessage,S.add(ge);break}this._internalState.lastMessage=this._internalState.lastMessage||{},((_=h.lastMessage)===null||_===void 0?void 0:_.index)!==void 0&&h.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=h.lastMessage.index,S.add(ge)),((v=h.lastMessage)===null||v===void 0?void 0:v.timestamp)!==void 0&&((g=this._internalState.lastMessage)===null||g===void 0||(y=g.dateCreated)===null||y===void 0?void 0:y.getTime())!==h.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=h.lastMessage.timestamp,S.add(ge)),je.default(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case ue.state:var vt=h.state||void 0;if(vt!==void 0&&(vt.dateUpdated=new Date(vt.dateUpdated)),je.default(this._internalState.state,vt))break;this._internalState.state=vt,S.add(ge);break;case ue.bindings:if(je.default(this._internalState.bindings,h.bindings))break;this._internalState.bindings=h.bindings,S.add(ge);break;default:var Et=h[le]instanceof Date,Ht=Et&&((k=this._internalState[ge])===null||k===void 0?void 0:k.getTime())===h[le].getTime(),Qt=!Et&&this[ge]===h[le];if(Ht||Qt)break;this._internalState[ge]=h[le],S.add(ge)}}S.size>0&&this.emit(w.updated,{conversation:this,updateReasons:rt.default(S)})}},{key:"_onMessageAdded",value:function(h){var _=qo(this._participants.values()),v;try{for(_.s();!(v=_.n()).done;){var g=v.value;if(g.identity===h.author){g._endTyping();break}}}catch(y){_.e(y)}finally{_.f()}this.emit(w.messageAdded,h)}},{key:"_setLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:v});case 2:return g=k.sent,k.abrupt("return",g.unread_messages_count);case 4:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()}],[{key:"preprocessUpdate",value:function(h,_){try{typeof h.attributes=="string"?h.attributes=JSON.parse(h.attributes):h.attributes&&JSON.stringify(h.attributes)}catch{w._logger.warn("Retrieved malformed attributes from the server for conversation: "+_),h.attributes={}}try{h.dateCreated&&(h.dateCreated=new Date(h.dateCreated))}catch{w._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+_),delete h.dateCreated}try{h.dateUpdated&&(h.dateUpdated=new Date(h.dateUpdated))}catch{w._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+_),delete h.dateUpdated}try{h.lastMessage&&h.lastMessage.timestamp&&(h.lastMessage.timestamp=new Date(h.lastMessage.timestamp))}catch{w._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+_),delete h.lastMessage.timestamp}}}]),w}(N.ReplayEventEmitter);H.default(I,"participantJoined","participantJoined"),H.default(I,"participantLeft","participantLeft"),H.default(I,"participantUpdated","participantUpdated"),H.default(I,"messageAdded","messageAdded"),H.default(I,"messageRemoved","messageRemoved"),H.default(I,"messageUpdated","messageUpdated"),H.default(I,"typingEnded","typingEnded"),H.default(I,"typingStarted","typingStarted"),H.default(I,"updated","updated"),H.default(I,"removed","removed"),H.default(I,"_logger",Jt.scope("Conversation")),Fe([b.validateTypesAsync(b.nonEmptyString,He),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],I.prototype,"add",null),Fe([b.validateTypesAsync(b.nonEmptyString,b.nonEmptyString,He,He),be("design:type",Function),be("design:paramtypes",[String,String,Object,Object]),be("design:returntype",Promise)],I.prototype,"addNonChatParticipant",null),Fe([b.validateTypesAsync(b.nonNegativeInteger),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],I.prototype,"advanceLastReadMessageIndex",null),Fe([b.validateTypesAsync(["undefined",b.nonNegativeInteger],["undefined",b.nonNegativeInteger],["undefined",b.literal("backwards","forward")]),be("design:type",Function),be("design:paramtypes",[Number,Number,String]),be("design:returntype",Promise)],I.prototype,"getMessages",null),Fe([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"getParticipantBySid",null),Fe([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"getParticipantByIdentity",null),Fe([b.validateTypesAsync([b.nonEmptyString,G]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],I.prototype,"removeParticipant",null),Fe([b.validateTypesAsync(["string",FormData,b.literal(null),b.objectSchema("media options",{contentType:b.nonEmptyString,media:b.custom(function(C){var x=typeof C=="string"&&C.length>0||C instanceof Uint8Array||C instanceof ArrayBuffer;return typeof Blob=="function"&&(x=x||C instanceof Blob),[x,"a non-empty string, an instance of Buffer or an instance of Blob"]})})],He,["undefined",b.literal(null),b.objectSchema("email attributes",{subject:[b.nonEmptyString,"undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object,Object,Object]),be("design:returntype",Promise)],I.prototype,"sendMessage",null),Fe([b.validateTypesAsync(b.literal("default","muted")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"setUserNotificationLevel",null),Fe([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],I.prototype,"updateAttributes",null),Fe([b.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"updateFriendlyName",null),Fe([b.validateTypesAsync([b.literal(null),b.nonNegativeInteger]),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],I.prototype,"updateLastReadMessageIndex",null),Fe([b.validateTypesAsync(["string",b.literal(null)]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"updateUniqueName",null);var O=function(){function C(){var x=this;ke.default(this,C),this._promise=new Promise(function(w,p){x._resolve=w,x._reject=p})}return ye.default(C,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(w){this._resolve(w)}},{key:"set",value:function(w){this.current=w,this._resolve(w)}},{key:"fail",value:function(w){this._reject(w)}}]),C}();function R(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Z(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1313
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Pu,n=gs,i=na,a=ia,s=li,o=ys,u=Aa,l=aa,c=zu,d=ui,f=Hu,m=Pz,b=nn,A=ud,N=Xh,z=KW,X=od,Ee=sa,Ie=Qy,Fe=yI,Oe=zn,ze=sA,V=Kp,xe=wd,_e=hd;function se(C){return C&&typeof C=="object"&&"default"in C?C:{default:C}}function Te(C){if(C&&C.__esModule)return C;var x=Object.create(null);return C&&Object.keys(C).forEach(function(w){if(w!=="default"){var p=Object.getOwnPropertyDescriptor(C,w);Object.defineProperty(x,w,p.get?p:{enumerable:!0,get:function(){return C[w]}})}}),x.default=C,Object.freeze(x)}var re=se(r),oe=se(n),q=se(i),ne=se(a),Se=se(s),H=se(o),ye=se(u),ke=se(l),M=se(c),Xe=se(d),Ct=Te(f),rt=se(A),je=se(z),ce=se(X),Ke=se(xe);function Be(C,x,w,p){var h=arguments.length,_=h<3?x:p===null?p=Object.getOwnPropertyDescriptor(x,w):p,v;if((typeof Reflect>"u"?"undefined":Xe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(C,x,w,p);else for(var g=C.length-1;g>=0;g--)(v=C[g])&&(_=(h<3?v(_):h>3?v(x,w,_):v(x,w))||_);return h>3&&_&&Object.defineProperty(x,w,_),_}function be(C,x){if((typeof Reflect>"u"?"undefined":Xe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(C,x)}function pt(C,x){return["".concat(new Date().toISOString()," Conversations ").concat(C,":")].concat(Array.from(x))}var Ze=Ct.getLogger("twilio-conversations"),Jt=function(){function C(x){ke.default(this,C),H.default(this,"prefix",""),this.prefix=x!=null&&x.length>0?x+" ":""}return ye.default(C,[{key:"setLevel",value:function(w){Ze.setLevel(w)}},{key:"trace",value:function(){if(Ze.getLevel()==Ze.levels.TRACE){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt(this.prefix+"T",p))}}},{key:"debug",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt(this.prefix+"D",p))}},{key:"info",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.info.apply(null,pt(this.prefix+"I",p))}},{key:"warn",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.warn.apply(null,pt(this.prefix+"W",p))}},{key:"error",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.error.apply(null,pt(this.prefix+"E",p))}}],[{key:"scope",value:function(w){return new C(w)}},{key:"setLevel",value:function(w){Ze.setLevel(w)}},{key:"trace",value:function(){if(Ze.getLevel()==Ze.levels.TRACE){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt("T",p))}}},{key:"debug",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.debug.apply(null,pt("D",p))}},{key:"info",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.info.apply(null,pt("I",p))}},{key:"warn",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.warn.apply(null,pt("W",p))}},{key:"error",value:function(){for(var w=arguments.length,p=new Array(w),h=0;h<w;h++)p[h]=arguments[h];Ze.error.apply(null,pt("E",p))}}]),C}();function At(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function Q(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?At(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):At(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}var Ue=5,ot="PT5S",Pe="PT5S",St=100,ut=1e3,or=4e3,br=3,et=!0,Mr=100,Fr=1e3,dr=ye.default(function C(){var x,w,p,h,_,v,g,y,k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},S=arguments.length>1?arguments[1]:void 0,Y=arguments.length>2?arguments[2]:void 0;ke.default(this,C),H.default(this,"typingIndicatorTimeoutDefault",Ue*1e3);var J=k.Chat||k.IPMessaging||k||{};this.productId=J.productId,this.links={myConversations:S.links.my_conversations,conversations:S.links.conversations,users:S.links.users,currentUser:S.links.current_user,typing:S.links.typing,mediaService:S.links.media_service,mediaSetService:S.links.media_set_service,messagesReceipts:S.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:S.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:S.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:S.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:S.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:S.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=J.typingIndicatorTimeoutOverride,this.backoffConfiguration=Q({min:ut,max:or,maxAttemptsCount:br},J.backoffConfigOverride),this.retryWhenThrottled=J.retryWhenThrottledOverride!==void 0?J.retryWhenThrottledOverride:et,this.userInfosToSubscribe=(x=(w=J.userInfosToSubscribeOverride)!==null&&w!==void 0?w:S.options.user_infos_to_subscribe)!==null&&x!==void 0?x:St,this.reachabilityEnabled=S.options.reachability_enabled,this.userIdentity=S.identity,this.userInfo=S.sync_objects.my_user_info,this.myConversations=S.sync_objects.my_conversations;var le=(p=(h=J.httpCacheIntervalOverride)!==null&&h!==void 0?h:S.options.http_cache_interval)!==null&&p!==void 0?p:ot;try{this.httpCacheInterval=m.toSeconds(m.parse(le))}catch{Y.error("Failed to parse http cache interval ".concat(le,", using default value ").concat(ot)),this.httpCacheInterval=m.toSeconds(m.parse(ot))}var ge=(_=(v=J.consumptionReportIntervalOverride)!==null&&v!==void 0?v:S.options.consumption_report_interval)!==null&&_!==void 0?_:Pe;try{this.consumptionReportInterval=m.toSeconds(m.parse(ge))}catch{Y.error("Failed to parse consumption report interval ".concat(ge,", using default value ").concat(Pe)),this.consumptionReportInterval=m.toSeconds(m.parse(Pe))}this.channelMetadataCacheCapacity=(g=k.channelMetadataCacheCapacity)!==null&&g!==void 0?g:Mr,this.messageRecipientsCacheCapacity=(y=k.messageRecipientsCacheCapacity)!==null&&y!==void 0?y:Fr});function fr(C){return JSON.parse(JSON.stringify(C))}function Wt(C){return typeof C<"u"&&!isNaN(Number(C))?Number(C):null}function Ot(C){try{return new Date(C)}catch{return null}}function L(C,x,w){var p={};if(C)try{p=JSON.parse(C)}catch(h){w.warn(x,h)}return p}var W=function(){function C(x){ke.default(this,C),this.base=x.replace(/\/$/,""),this.args=[],this.paths=[]}return ye.default(C,[{key:"arg",value:function(w,p){return typeof p<"u"&&this.args.push(encodeURIComponent(w)+"="+encodeURIComponent(p)),this}},{key:"path",value:function(w){return this.paths.push(encodeURIComponent(w)),this}},{key:"build",value:function(){var w=this.base;return this.paths.length&&(w+="/"+this.paths.join("/")),this.args.length&&(w+="?"+this.args.join("&")),w}}]),C}(),ie=b.custom(function(C){return[["string","number","boolean","object"].includes(Xe.default(C)),"a JSON type"]}),He=b.custom(function(C){return[["undefined","string","number","boolean","object"].includes(Xe.default(C)),"an optional JSON type"]}),ct=b.objectSchema("send media options",{contentType:[b.literal(null),"string"],filename:["string","undefined"],media:[b.literal("null"),"string"].concat(rt.default(typeof Buffer=="function"?[Buffer]:[]),rt.default(typeof Blob=="function"?[Blob]:[]))});function bt(C){var x=zt();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function zt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var tr=Jt.scope("User"),Re=function(C){q.default(w,C);var x=bt(w);function w(p,h,_,v){var g;return ke.default(this,w),g=x.call(this),H.default(oe.default(g),"promiseToFetch",null),H.default(oe.default(g),"updated","updated"),H.default(oe.default(g),"userSubscribed","userSubscribed"),H.default(oe.default(g),"userUnsubscribed","userUnsubscribed"),g.services=v,g.subscribed="initializing",g.setMaxListeners(0),g.state={identity:p,entityName:h,friendlyName:null,attributes:{},online:null,notifiable:null},g._initializationPromise=new Promise(function(y){g._resolveInitializationPromise=y}),_!==null&&g._resolveInitialization(_,p,h,!1),g}return ye.default(w,[{key:"identity",get:function(){return this.state.identity},set:function(h){this.state.identity=h}},{key:"entityName",set:function(h){this.state.entityName=h}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return this.subscribed=="subscribed"}},{key:"_update",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return Y.next=2,this._initializationPromise;case 2:y=[],tr.debug("User for",this.state.identity,"updated:",v,g),Y.t0=v,Y.next=Y.t0==="friendlyName"?7:Y.t0==="attributes"?9:Y.t0==="reachability"?12:15;break;case 7:return this.state.friendlyName!==g.value&&(y.push("friendlyName"),this.state.friendlyName=g.value),Y.abrupt("break",16);case 9:return k=L(g.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),tr),je.default(this.state.attributes,k)||(this.state.attributes=k,y.push("attributes")),Y.abrupt("break",16);case 12:return this.state.online!==g.online&&(this.state.online=g.online,y.push("reachabilityOnline")),this.state.notifiable!==g.notifiable&&(this.state.notifiable=g.notifiable,y.push("reachabilityNotifiable")),Y.abrupt("break",16);case 15:return Y.abrupt("return");case 16:y.length>0&&this.emit("updated",{user:this,updateReasons:y});case 17:case"end":return Y.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_updateReachabilityInfo",value:function(){var p=re.default(M.default.mark(function _(v,g){var y=this;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){S.next=4;break}return S.abrupt("return",Promise.resolve());case 4:return S.abrupt("return",v.get("reachability").then(g).catch(function(Y){tr.warn("Failed to get reachability info for ",y.state.identity,Y)}));case 5:case"end":return S.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_fetch",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.state.entityName){y.next=4;break}return y.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(k){return v.entity=k,k.on("itemUpdated",function(S){return tr.debug(v.state.entityName+" ("+v.state.identity+") itemUpdated: "+S.item.key),v._update(S.item.key,S.item.data)}),k.on("itemAdded",function(S){return tr.debug(v.state.entityName+" ("+v.state.identity+") itemAdded: "+S.item.key),v._update(S.item.key,S.item.data)}),Promise.all([k.get("friendlyName").then(function(S){return v._update(S.key,S.data)}),k.get("attributes").then(function(S){return v._update(S.key,S.data)}),v._updateReachabilityInfo(k,function(S){return v._update(S.key,S.data)})])}).then(function(){return tr.debug("Fetched for",v.identity),v.subscribed="subscribed",v.emit("userSubscribed",v),v}).catch(function(k){throw v.promiseToFetch=null,k}),y.abrupt("return",this.promiseToFetch);case 6:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_ensureFetched",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:return g.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:v});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){g.next=9;break}return g.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_resolveInitialization",value:function(h,_,v,g){this.configuration=h,this.identity=_,this.entityName=v,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),g&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),w}(N.ReplayEventEmitter);Be([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],Re.prototype,"updateAttributes",null),Be([b.validateTypesAsync(["string"]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],Re.prototype,"updateFriendlyName",null);function Ne(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=pe(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1314
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function pe(C,x){if(C){if(typeof C=="string")return $e(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return $e(C,x)}}function $e(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}var ae=function(){function C(x,w){ke.default(this,C),this.configuration=x,this.services=w,this.cache=new Map,this.cacheLifetime=this.configuration.httpCacheInterval*100,this.cleanupCache()}return ye.default(C,[{key:"isExpired",value:function(w){return!this.cacheLifetime||Date.now()-w>this.cacheLifetime}},{key:"cleanupCache",value:function(){var w=Ne(this.cache),p;try{for(w.s();!(p=w.n()).done;){var h=ce.default(p.value,2),_=h[0],v=h[1];this.isExpired(v.timestamp)&&this.cache.delete(_)}}catch(g){w.e(g)}finally{w.f()}this.cache.size===0&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var w=this;this.timer=this.timer||setInterval(function(){return w.cleanupCache()},this.cacheLifetime*2)}},{key:"executeWithRetry",value:function(w){var p=this,h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return new Promise(function(_,v){var g=[502,503,504];h&&g.push(429);var y=new Ee.Retrier(p.configuration.backoffConfiguration);y.on("attempt",function(){w().then(function(k){return y.succeeded(k)}).catch(function(k){g.indexOf(k.status)>-1||k.message==="Twilsock disconnected"?y.failed(k):(y.removeAllListeners(),y.cancel(),v(k))})}),y.on("succeeded",function(k){_(k)}),y.on("cancelled",function(k){return v(k)}),y.on("failed",function(k){return v(k)}),y.start()})}},{key:"get",value:function(){var x=re.default(M.default.mark(function p(h){var _=this,v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(v=this.cache.get(h),!(v&&!this.isExpired(v.timestamp))){S.next=3;break}return S.abrupt("return",v.response);case 3:return g={},S.next=6,this.executeWithRetry(function(){return _.services.transport.get(h,g,_.configuration.productId)},this.configuration.retryWhenThrottled);case 6:return y=S.sent,this.cache.set(h,{response:y,timestamp:Date.now()}),this.pokeTimer(),S.abrupt("return",y);case 10:case"end":return S.stop()}},p,this)}));function w(p){return x.apply(this,arguments)}return w}()}]),C}(),me=ye.default(function C(){ke.default(this,C)});H.default(me,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),H.default(me,"NEW_MESSAGE","twilio.conversations.new_message"),H.default(me,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),H.default(me,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),H.default(me,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");function we(C){var x=K();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function K(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var he=Jt.scope("Participant"),G=function(C){q.default(w,C);var x=we(w);function w(p,h,_,v,g){var y,k,S;if(ke.default(this,w),S=x.call(this),S.conversation=_,S.links=v,S.services=g,S.state={attributes:L(p.attributes,"Retrieved malformed attributes from the server for participant: "+h,he),dateCreated:p.dateCreated?Ot(p.dateCreated):null,dateUpdated:p.dateCreated?Ot(p.dateUpdated):null,sid:h,typingTimeout:null,isTyping:!1,identity:p.identity,roleSid:(y=p.roleSid)!==null&&y!==void 0?y:"",lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,lastReadTimestamp:p.lastConsumptionTimestamp?Ot(p.lastConsumptionTimestamp):null,type:p.type||"chat",userInfo:p.userInfo,bindings:(k=p.bindings)!==null&&k!==void 0?k:{}},!p.identity&&!p.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return S}return ye.default(w,[{key:"sid",get:function(){return this.state.sid}},{key:"attributes",get:function(){return this.state.attributes}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"identity",get:function(){return this.state.identity}},{key:"isTyping",get:function(){return this.state.isTyping}},{key:"lastReadMessageIndex",get:function(){return this.state.lastReadMessageIndex}},{key:"lastReadTimestamp",get:function(){return this.state.lastReadTimestamp}},{key:"roleSid",get:function(){return this.state.roleSid}},{key:"type",get:function(){return this.state.type}},{key:"bindings",get:function(){var h;return(h=this.state.bindings)!==null&&h!==void 0?h:{}}},{key:"_startTyping",value:function(h){var _=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit(w.typingStarted,this),this.conversation.emit(I.typingStarted,this),this.state.typingTimeout=Number(setTimeout(function(){return _._endTyping()},h)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit(w.typingEnded,this),this.conversation.emit(I.typingEnded,this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(h){var _=[],v=L(h.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,he);h.attributes&&!je.default(this.state.attributes,v)&&(this.state.attributes=v,_.push("attributes"));var g=Ot(h.dateUpdated);h.dateUpdated&&(g==null?void 0:g.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=g,_.push("dateUpdated"));var y=Ot(h.dateCreated);if(h.dateCreated&&(y==null?void 0:y.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=y,_.push("dateCreated")),h.roleSid&&this.state.roleSid!==h.roleSid&&(this.state.roleSid=h.roleSid,_.push("roleSid")),(Number.isInteger(h.lastConsumedMessageIndex)||h.lastConsumedMessageIndex===null)&&this.state.lastReadMessageIndex!==h.lastConsumedMessageIndex&&(this.state.lastReadMessageIndex=h.lastConsumedMessageIndex,_.push("lastReadMessageIndex")),h.lastConsumptionTimestamp){var k=new Date(h.lastConsumptionTimestamp);(!this.state.lastReadTimestamp||this.state.lastReadTimestamp.getTime()!==k.getTime())&&(this.state.lastReadTimestamp=k,_.push("lastReadTimestamp"))}return h.bindings&&!je.default(this.state.bindings,h.bindings)&&(this.state.bindings=h.bindings,_.push("bindings")),_.length>0&&this.emit(w.updated,{participant:this,updateReasons:_}),this}},{key:"getUser",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.type=="chat"){g.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return g.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter);H.default(G,"typingStarted","typingStarted"),H.default(G,"typingEnded","typingEnded"),H.default(G,"updated","updated"),Be([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],G.prototype,"updateAttributes",null);function de(C){var x=ee();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function ee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=Jt.scope("Participants"),qe=function(C){q.default(w,C);var x=de(w);function w(p,h,_,v){var g;return ke.default(this,w),g=x.call(this),H.default(oe.default(g),"rosterEntityPromise",null),g.conversation=p,g.participants=h,g.links=_,g.services=v,g}return ye.default(w,[{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this.rosterEntityPromise){y.next=6;break}return y.next=3,this.rosterEntityPromise;case 3:v=y.sent,v.close(),this.rosterEntityPromise=null;case 6:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"subscribe",value:function(h){var _=this,v=typeof h=="string"?this.services.syncClient.map({id:h,mode:"open_existing"}):Promise.resolve(h);return this.rosterEntityPromise=this.rosterEntityPromise||v.then(function(g){g.on(Oe.SyncMap.itemAdded,function(S){Ye.debug(_.conversation.sid+" itemAdded: "+S.item.key),_.upsertParticipant(S.item.key,S.item.data).then(function(Y){_.emit(I.participantJoined,Y)})}),g.on(Oe.SyncMap.itemRemoved,function(S){Ye.debug(_.conversation.sid+" itemRemoved: "+S.key);var Y=S.key;if(_.participants.has(Y)){var J=_.participants.get(Y);_.participants.delete(Y),J&&_.emit(I.participantLeft,J)}}),g.on(Oe.SyncMap.itemUpdated,function(S){Ye.debug(_.conversation.sid+" itemUpdated: "+S.item.key),_.upsertParticipant(S.item.key,S.item.data).catch(function(Y){return Ye.error(Y)})});var y=[],k=function S(Y){return Y.items.forEach(function(J){y.push(_.upsertParticipant(J.key,J.data))}),Y.hasNextPage?Y.nextPage().then(S):null};return g.getItems().then(k).then(function(){return Promise.all(y)}).then(function(){return g})}).catch(function(g){throw _.rosterEntityPromise=null,_.services.syncClient.connectionState!="disconnected"&&Ye.error("Failed to get roster object for conversation",_.conversation.sid,g),Ye.debug("ERROR: Failed to get roster object for conversation",_.conversation.sid,g),g})}},{key:"upsertParticipantFromResponse",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y,J,le,ge;return M.default.wrap(function(Et){for(;;)switch(Et.prev=Et.next){case 0:return y=v.sid,k=v.attributes,S=v.date_created,Y=v.date_updated,J=v.identity,le=v.role_sid,ge=v.messaging_binding,Et.next=3,this.upsertParticipant(y,{attributes:k,dateCreated:new Date(S),dateUpdated:new Date(Y),identity:J,roleSid:le,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:(g=ge==null?void 0:ge.type)!==null&&g!==void 0?g:"chat"});case 3:return Et.abrupt("return",Et.sent);case 4:case"end":return Et.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"upsertParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y=this,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(k=this.participants.get(v),!k){J.next=3;break}return J.abrupt("return",k._update(g));case 3:return S={self:"".concat(this.links.participants,"/").concat(v)},k=new G(g,v,this.conversation,S,this.services),this.participants.set(v,k),k.on(G.updated,function(le){return y.emit(I.participantUpdated,le)}),J.abrupt("return",k);case 8:case"end":return J.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var k=[];return v.participants.forEach(function(S){return k.push(S)}),k}):[]);case 1:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g=this;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var S=g.participants.get(v);if(!S)throw new Error("Participant with SID "+v+" was not found");return S}):null);case 1:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return y=null,S.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){if(g.participants.forEach(function(Y){Y.identity===v&&(y=Y)}),!y)throw new Error("Participant with identity "+v+" was not found");return y}):null);case 2:case"end":return S.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"add",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:v,attributes:typeof g<"u"?JSON.stringify(g):void 0});case 2:return k.abrupt("return",k.sent);case 3:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k,S,Y,J=arguments;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return S=J.length>2&&J[2]!==void 0?J[2]:{},Y=J.length>3&&J[3]!==void 0?J[3]:{},ge.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:typeof S<"u"?JSON.stringify(S):void 0,messaging_binding:{address:g,proxy_address:v,name:Y==null||(y=Y.email)===null||y===void 0?void 0:y.name,level:Y==null||(k=Y.email)===null||k===void 0?void 0:k.level}});case 4:return ge.abrupt("return",ge.sent);case 5:case"end":return ge.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(h){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(encodeURIComponent(h)))}}]),w}(N.ReplayEventEmitter),dt=function(){function C(x,w){var p;ke.default(this,C),H.default(this,"mcsMedia",null),this.services=w,x instanceof ze.McsMedia&&(this.mcsMedia=x),this.state={sid:x.sid,category:x.category,filename:(p=x.filename)!==null&&p!==void 0?p:null,contentType:x.contentType,size:x.size}}return ye.default(C,[{key:"sid",get:function(){return this.state.sid}},{key:"filename",get:function(){return this.state.filename}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"category",get:function(){return this.state.category}},{key:"getContentTemporaryUrl",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(k=w.mcsMedia?void 0:w._fetchMcsMedia(),S=(y=w.mcsMedia)===null||y===void 0?void 0:y.getContentUrl(),g(function(){k&&k.cancel(),S&&S.cancel()}),le.prev=3,S){le.next=9;break}return le.next=7,k;case 7:Y=le.sent,S=Y==null?void 0:Y.getContentUrl();case 9:if(le.t0=_,!S){le.next=16;break}return le.next=13,S;case 13:le.t1=le.sent,le.next=17;break;case 16:le.t1=null;case 17:le.t2=le.t1,(0,le.t0)(le.t2),le.next=24;break;case 21:le.prev=21,le.t3=le.catch(3),v(le.t3);case 24:case"end":return le.stop()}},h,null,[[3,21]])}));return function(h,_,v){return p.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return w.services.mcsClient===null&&v(new Error("Media Content Service is unavailable")),y=w.services.mcsClient.get(w.state.sid),g(function(){return y.cancel()}),S.prev=3,S.next=6,y;case 6:w.mcsMedia=S.sent,w.state=w.mcsMedia._state(),_(w.mcsMedia),S.next=14;break;case 11:S.prev=11,S.t0=S.catch(3),v(S.t0);case 14:case"end":return S.stop()}},h,null,[[3,11]])}));return function(h,_,v){return p.apply(this,arguments)}}())}},{key:"_state",value:function(){return this.state}}]),C}(),lt=function(){function C(x){ke.default(this,C),this.state=x}return ye.default(C,[{key:"total",get:function(){return this.state.total}},{key:"sent",get:function(){return this.state.sent}},{key:"delivered",get:function(){return this.state.delivered}},{key:"read",get:function(){return this.state.read}},{key:"undelivered",get:function(){return this.state.undelivered}},{key:"failed",get:function(){return this.state.failed}},{key:"_update",value:function(w){this.state=w}},{key:"_isEquals",value:function(w){var p=this.total===w.total,h=this.sent===w.sent,_=this.delivered===w.delivered,v=this.read===w.read,g=this.undelivered===w.undelivered,y=this.failed===w.failed;return p&&h&&_&&v&&g&&y}}]),C}(),ht=function(){function C(x,w,p,h){ke.default(this,C),this.state={prevToken:p,nextToken:h,source:w,items:x}}return ye.default(C,[{key:"hasNextPage",get:function(){return!!this.state.nextToken}},{key:"hasPrevPage",get:function(){return!!this.state.prevToken}},{key:"items",get:function(){return this.state.items}},{key:"nextPage",value:function(){return this.hasNextPage?this.state.source(this.state.nextToken):Promise.reject(new Error("No next page"))}},{key:"prevPage",value:function(){return this.hasPrevPage?this.state.source(this.state.prevToken):Promise.reject(new Error("No previous page"))}}]),C}(),Rt=ye.default(function C(x){ke.default(this,C),this.sid=x.sid,this.messageSid=x.message_sid,this.conversationSid=x.conversation_sid,this.channelMessageSid=x.channel_message_sid,this.participantSid=x.participant_sid,this.status=x.status||"queued",this.errorCode=x.error_code||0,this.dateCreated=x.date_created,this.dateUpdated=x.date_updated}),xt=function(x){return x.map(function(w){var p,h,_,v,g=JSON.stringify(w);switch(w.type){case"QUICK_REPLY":return{type:"reply",title:w.title,id:(p=w.id)!==null&&p!==void 0?p:"",index:(h=w.index)!==null&&h!==void 0?h:0,rawData:g};case"PHONE_NUMBER":return{type:"phone",title:w.title,phone:(_=w.phone)!==null&&_!==void 0?_:"",rawData:g};case"URL":return{type:"url",title:w.title,url:(v=w.url)!==null&&v!==void 0?v:"",rawData:g};default:return{type:"other",rawData:g}}})},kt=function(x,w){var p=JSON.stringify(w);switch(x){case"twilio/text":{var h=w;return{type:"text",body:h.body,rawData:p}}case"twilio/media":{var _=w;return{type:"media",body:_.body,media:_.media,rawData:p}}case"twilio/location":{var v=w;return{type:"location",longitude:v.longitude,latitude:v.latitude,label:v.label,rawData:p}}case"twilio/quick-reply":{var g=w;return{type:"quickReply",body:g.body,replies:g.actions,rawData:p}}case"twilio/call-to-action":{var y=w;return{type:"callToAction",body:y.body,actions:xt(y.actions),rawData:p}}case"twilio/list-picker":{var k=w;return{type:"listPicker",body:k.body,button:k.button,items:k.items,rawData:p}}case"twilio/card":{var S,Y,J=w;return{type:"card",title:J.title,subtitle:J.subtitle,media:(S=J.media)!==null&&S!==void 0?S:[],actions:xt((Y=J.actions)!==null&&Y!==void 0?Y:[]),rawData:p}}default:return{type:"other",rawData:p}}},$t=function(x){for(var w=new Map,p=0,h=Object.entries(x);p<h.length;p++){var _=ce.default(h[p],2),v=_[0],g=_[1];w.set(v,kt(v,g))}return w},It=function(){function C(x,w){ke.default(this,C),this.name=x,this.value=w}return ye.default(C,[{key:"copyWithValue",value:function(w){return new C(this.name,w)}}]),C}(),jt=ye.default(function C(x){ke.default(this,C),this.sid=x.sid,this.friendlyName=x.friendly_name,this.variables=Object.entries(JSON.parse(x.variables)).map(function(w){var p=ce.default(w,2),h=p[0],_=p[1];return new It(h,_)}),this.variants=$t(x.variants),this.dateCreated=new Date(x.date_created),this.dateUpdated=new Date(x.date_updated)});function sn(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function _n(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?sn(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):sn(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Ut(C){var x=qn();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function qn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ha(C,x){Wa(C,x),x.add(C)}function Wa(C,x){if(x.has(C))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ti(C,x,w){if(!x.has(C))throw new TypeError("attempted to get private field on non-instance");return w}var pa=Jt.scope("Message"),ri=e.XMLHttpRequest||{},gi=new WeakSet,Za=new WeakSet,en=function(C){q.default(w,C);var x=Ut(w);function w(p,h,_,v,g,y){var k,S,Y,J,le,ge,vt,Et;return ke.default(this,w),Et=x.call(this),ha(oe.default(Et),Za),ha(oe.default(Et),gi),Et.conversation=_,Et.links=v,Et.configuration=g,Et.services=y,Et.state={sid:h.sid,index:p,author:h.author,subject:h.subject,contentSid:h.contentSid,body:(k=h.text)!==null&&k!==void 0?k:null,timestamp:h.timestamp?new Date(h.timestamp):null,dateUpdated:h.dateUpdated?new Date(h.dateUpdated):null,lastUpdatedBy:(S=h.lastUpdatedBy)!==null&&S!==void 0?S:null,attributes:L(h.attributes,"Got malformed attributes for the message ".concat(h.sid),pa),type:(Y=h.type)!==null&&Y!==void 0?Y:"text",media:null,medias:null,participantSid:(J=h.memberSid)!==null&&J!==void 0?J:null,aggregatedDeliveryReceipt:h.delivery?new lt(h.delivery):null,hasChannelMetadata:(le=h.channelMetadata)!==null&&le!==void 0?le:!1},ti(oe.default(Et),Za,Ms).call(oe.default(Et),(ge=h.medias)!==null&&ge!==void 0?ge:null,(vt=h.media)!==null&&vt!==void 0?vt:null),Et}return ye.default(w,[{key:"sid",get:function(){return this.state.sid}},{key:"author",get:function(){return this.state.author}},{key:"subject",get:function(){return this.state.subject}},{key:"contentSid",get:function(){return this.state.contentSid}},{key:"body",get:function(){return this.state.body}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"index",get:function(){return this.state.index}},{key:"lastUpdatedBy",get:function(){return this.state.lastUpdatedBy}},{key:"dateCreated",get:function(){return this.state.timestamp}},{key:"attributes",get:function(){return this.state.attributes}},{key:"type",get:function(){return this.state.type}},{key:"media",get:function(){return this.state.media}},{key:"attachedMedia",get:function(){return this.getMediaByCategories(["media"])}},{key:"participantSid",get:function(){return this.state.participantSid}},{key:"aggregatedDeliveryReceipt",get:function(){return this.state.aggregatedDeliveryReceipt}},{key:"getMediaByCategory",value:function(h){return this.getMediaByCategories(h)}},{key:"getMediaByCategories",value:function(h){var _;return((_=this.state.medias)!==null&&_!==void 0?_:[]).filter(function(v){return h.includes(v.category)})}},{key:"getEmailBody",value:function(){var h,_,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(h=(_=this.getMediaByCategories(["body"]))===null||_===void 0?void 0:_.filter(function(g){return g.contentType==v}).shift())!==null&&h!==void 0?h:null}},{key:"getEmailHistory",value:function(){var h,_,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(h=(_=this.getMediaByCategories(["history"]))===null||_===void 0?void 0:_.filter(function(g){return g.contentType==v}).shift())!==null&&h!==void 0?h:null}},{key:"_update",value:function(h){var _,v=this,g,y,k,S=[];(h.text||typeof h.text=="string")&&h.text!==this.state.body&&(this.state.body=h.text,S.push("body")),h.subject&&h.subject!==this.state.subject&&(this.state.subject=h.subject,S.push("subject")),h.lastUpdatedBy&&h.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=h.lastUpdatedBy,S.push("lastUpdatedBy")),h.author&&h.author!==this.state.author&&(this.state.author=h.author,S.push("author")),h.dateUpdated&&new Date(h.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(h.dateUpdated),S.push("dateUpdated")),h.timestamp&&new Date(h.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(h.timestamp),S.push("dateCreated"));var Y=L(h.attributes,"Got malformed attributes for the message ".concat(this.sid),pa);je.default(this.state.attributes,Y)||(this.state.attributes=Y,S.push("attributes"));var J=h.delivery,le=this.state.aggregatedDeliveryReceipt,ge=!!J&&!!J.total&&!!J.delivered&&!!J.failed&&!!J.read&&!!J.sent&&!!J.undelivered;ge&&(le?le._isEquals(J)||(le._update(J),S.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new lt(J),S.push("deliveryReceipt")));var vt=((_=h.medias)!==null&&_!==void 0?_:[]).map(function(_r){var mr;return(mr=ti(v,gi,ji).call(v,_r))===null||mr===void 0?void 0:mr._state()}).filter(function(_r){return _r!==null}),Et=((g=this.state.medias)!==null&&g!==void 0?g:[]).map(function(_r){return _r._state()}).filter(function(_r){return _r!==null});if(!je.default(vt,Et)||!je.default((y=ti(this,gi,ji).call(this,h.media))===null||y===void 0?void 0:y._state(),(k=this.state.media)===null||k===void 0?void 0:k._state())){var Ht,Qt;ti(this,Za,Ms).call(this,(Ht=h.medias)!==null&&Ht!==void 0?Ht:null,(Qt=h.media)!==null&&Qt!==void 0?Qt:null),S.push("media")}S.length>0&&this.emit("updated",{message:this,updateReasons:S})}},{key:"getParticipant",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(g=null,!this.state.participantSid){S.next=5;break}return S.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch(function(){return pa.debug('Participant with sid "'.concat(v.participantSid,'" not found for message ').concat(v.sid)),null});case 4:g=S.sent;case 5:if(!(!g&&this.state.author)){S.next=9;break}return S.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch(function(){return pa.debug('Participant with identity "'.concat(v.author,'" not found for message ').concat(v.sid)),null});case 8:g=S.sent;case 9:if(!g){S.next=11;break}return S.abrupt("return",g);case 11:throw y="Participant with ",this.state.participantSid&&(y+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(y+="or "),y+="identity '"+this.state.author+"' "),y==="Participant with "&&(y="Participant "),y+="was not found",new Error(y);case 17:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getDetailedDeliveryReceipts",value:function(){var p=re.default(M.default.mark(function _(){var v,g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:v=k.sent,g=v.items;case 4:if(!v.hasNextPage){k.next=11;break}return k.next=7,v.nextPage();case 7:v=k.sent,g=[].concat(rt.default(g),rt.default(v.items)),k.next=4;break;case 11:return k.abrupt("return",g);case 12:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateBody",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:v});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:typeof v<"u"?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"attachTemporaryUrlsFor",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(y=v==null?void 0:v.map(function(Y){return Y.sid}),!(this.services.mcsClient&&y)){S.next=7;break}return S.next=4,this.services.mcsClient.mediaSetGet(y);case 4:return S.abrupt("return",S.sent.map(function(Y){return new dt(Y,g.services)}));case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return S.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMedia",value:function(h){var _=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(_)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var _=this;return new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(Y=_.services.mcsClient.mediaSetGetContentUrls(h??[]),!(!_.services.mcsClient||!h)){ge.next=4;break}return k(new Error("Media Content Service is unavailable")),ge.abrupt("return");case 4:return S(function(){Y.cancel()}),ge.prev=5,ge.next=8,Y;case 8:J=ge.sent,y(J),ge.next=15;break;case 12:ge.prev=12,ge.t0=ge.catch(5),k(ge.t0);case 15:case"end":return ge.stop()}},g,null,[[5,12]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var h,_=this.attachedMedia,v=(h=_==null?void 0:_.map(function(g){return g.sid}))!==null&&h!==void 0?h:[];return this.getTemporaryContentUrlsForMediaSids(v)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),k=new W(y).arg("PageToken",v==null?void 0:v.pageToken).arg("PageSize",v==null?void 0:v.pageSize).build(),J.next=4,this.services.network.get(k);case 4:return S=J.sent,J.abrupt("return",new ht(S.body.delivery_receipts.map(function(le){return new Rt(le)}),function(le,ge){return g._getDetailedDeliveryReceiptsPaginator({pageToken:le,pageSize:ge})},S.body.meta.previous_token,S.body.meta.next_token));case 6:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getContentData",value:function(){var h=this;return new ze.CancellablePromise(function(){var _=re.default(M.default.mark(function v(g,y,k){var S,Y,J,le,ge,vt,Et,Ht,Qt,_r;return M.default.wrap(function(Gt){for(;;)switch(Gt.prev=Gt.next){case 0:if(h.state.contentSid!==null){Gt.next=3;break}return g(null),Gt.abrupt("return");case 3:if(S=h.getMediaByCategories(["body"]),S!==null){Gt.next=7;break}return g(null),Gt.abrupt("return");case 7:if(Y="application/x-vnd.com.twilio.rich.",J=S.filter(function(yi){return yi.contentType.startsWith(Y)}),J.length!==0){Gt.next=12;break}return g(null),Gt.abrupt("return");case 12:return le=J[0],ge=le.getContentTemporaryUrl(),k(function(){ge.cancel()}),Gt.prev=15,Gt.next=18,ge;case 18:vt=Gt.sent,Gt.next=25;break;case 21:return Gt.prev=21,Gt.t0=Gt.catch(15),y(Gt.t0),Gt.abrupt("return");case 25:if(vt!==null){Gt.next=28;break}return g(null),Gt.abrupt("return");case 28:return Et=new Promise(function(yi,Qp){var Lt,Us=!1,bi=new ri;bi.open("GET",(Lt=vt)!==null&&Lt!==void 0?Lt:"",!0),bi.responseType="text",bi.onreadystatechange=function(){bi.readyState!==4||Us||yi(bi.responseText)},bi.onerror=function(){Qp(bi.statusText)},k(function(){Us=!0,bi.abort(),Qp(new Error("XHR has been aborted"))}),bi.send()}),Gt.prev=29,Gt.next=32,Et;case 32:Qt=Gt.sent,Ht=JSON.parse(Qt),Gt.next=40;break;case 36:return Gt.prev=36,Gt.t1=Gt.catch(29),y(Gt.t1),Gt.abrupt("return");case 40:_r=le.contentType.replace(Y,"").replace(".","/"),g(kt(_r,Ht.data));case 42:case"end":return Gt.stop()}},v,null,[[15,21],[29,36]])}));return function(v,g,y){return _.apply(this,arguments)}}())}},{key:"getChannelMetadata",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.state.hasChannelMetadata){g.next=2;break}return g.abrupt("return",null);case 2:return g.next=4,this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid,this.sid);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid,this.sid);case 2:return g.abrupt("return",g.sent);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter);function ji(C){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return C?x?new dt(_n(_n({},C),{},{category:x}),this.services):new dt(C,this.services):null}function Ms(C,x){var w=this;this.state.media=ti(this,gi,ji).call(this,x),this.state.medias=C?C.map(function(p){return ti(w,gi,ji).call(w,p)}).filter(function(p){return p!==null}):x&&!C?[ti(this,gi,ji).call(this,x,"media")].filter(function(p){return p!==null}):null}H.default(en,"updated","updated"),Be([V.deprecated("getMediaByCategory","getMediaByCategories"),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Array)],en.prototype,"getMediaByCategory",null),Be([b.validateTypes([b.nonEmptyString,"undefined"]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",dt)],en.prototype,"getEmailBody",null),Be([b.validateTypes([b.nonEmptyString,"undefined"]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",dt)],en.prototype,"getEmailHistory",null),Be([b.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],en.prototype,"updateBody",null),Be([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],en.prototype,"updateAttributes",null),Be([V.deprecated("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Promise)],en.prototype,"attachTemporaryUrlsFor",null),Be([b.validateTypesAsync(b.nonEmptyArray("media",dt)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],en.prototype,"getTemporaryContentUrlsForMedia",null),Be([b.validateTypesAsync(b.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],en.prototype,"getTemporaryContentUrlsForMediaSids",null);function Ui(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function Ns(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?Ui(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):Ui(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Bo(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Vn(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1315
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Vn(C,x){if(C){if(typeof C=="string")return Ls(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Ls(C,x)}}function Ls(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}function zo(C){var x=Ho();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Ho(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var hn=Jt.scope("Messages"),Ds=function(C){q.default(w,C);var x=zo(w);function w(p,h,_){var v;return ke.default(this,w),v=x.call(this),v.conversation=p,v.configuration=h,v.services=_,v.messagesByIndex=new Map,v.messagesListPromise=null,v}return ye.default(w,[{key:"subscribe",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!this.messagesListPromise){S.next=2;break}return S.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise=typeof v=="string"?this.services.syncClient.list({id:v,mode:"open_existing"}):Promise.resolve(v),S.prev=3,S.next=6,this.messagesListPromise;case 6:return y=S.sent,y.on("itemAdded",function(Y){hn.debug("".concat(g.conversation.sid," itemAdded: ").concat(Y.item.index));var J={self:"".concat(g.conversation._links.messages,"/").concat(Y.item.data.sid),conversation:g.conversation._links.self,messages_receipts:"".concat(g.conversation._links.messages,"/").concat(Y.item.data.sid,"/Receipts")},le=new en(Y.item.index,Y.item.data,g.conversation,J,g.configuration,g.services);if(g.messagesByIndex.has(le.index)){hn.debug("Message arrived, but is already known and ignored",g.conversation.sid,le.index);return}g.messagesByIndex.set(le.index,le),le.on("updated",function(ge){return g.emit("messageUpdated",ge)}),g.emit("messageAdded",le)}),y.on("itemRemoved",function(Y){hn.debug("#{this.conversation.sid} itemRemoved: ".concat(Y.index));var J=Y.index;if(g.messagesByIndex.has(J)){var le=g.messagesByIndex.get(J);if(!le)return;g.messagesByIndex.delete(le.index),le.removeAllListeners("updated"),g.emit("messageRemoved",le)}}),y.on("itemUpdated",function(Y){hn.debug("".concat(g.conversation.sid," itemUpdated: ").concat(Y.item.index));var J=g.messagesByIndex.get(Y.item.index);J&&J._update(Y.item.data)}),S.abrupt("return",y);case 13:throw S.prev=13,S.t0=S.catch(3),this.messagesListPromise=null,this.services.syncClient.connectionState!=="disconnected"&&hn.error("Failed to get messages object for conversation",this.conversation.sid,S.t0),hn.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,S.t0),S.t0;case 19:case"end":return S.stop()}},_,this,[[3,13]])}));function h(_){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.messagesListPromise){y.next=2;break}return y.abrupt("return");case 2:return y.next=4,this.messagesListPromise;case 4:v=y.sent,v.close(),this.messagesListPromise=null;case 7:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"sendV2",value:function(h){var _=this;return hn.debug("Sending message V2",h.mediaContent,h.attributes,h.emailOptions),new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J,le,ge,vt,Et,Ht,Qt,_r,mr,Gt,yi;return M.default.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:J=[],le=[],S(function(){le.forEach(function(Us){return Us.cancel()})}),ge=Bo(h.mediaContent),Lt.prev=4,ge.s();case 6:if((vt=ge.n()).done){Lt.next=25;break}return Et=ce.default(vt.value,2),Ht=Et[0],Qt=Et[1],Lt.prev=8,hn.debug("Adding media to a message as ".concat(Qt instanceof FormData?"FormData":"SendMediaOptions"),Qt),Gt=Qt instanceof FormData?_.services.mcsClient.postFormData(Qt,Ht):_.services.mcsClient.post((_r=Qt.contentType)!==null&&_r!==void 0?_r:"",(mr=Qt.media)!==null&&mr!==void 0?mr:"",Ht,Qt.filename),le.push(Gt),Lt.t0=J,Lt.next=15,Gt;case 15:Lt.t1=Lt.sent,Lt.t0.push.call(Lt.t0,Lt.t1),Lt.next=23;break;case 19:return Lt.prev=19,Lt.t2=Lt.catch(8),k(Lt.t2),Lt.abrupt("return");case 23:Lt.next=6;break;case 25:Lt.next=30;break;case 27:Lt.prev=27,Lt.t3=Lt.catch(4),ge.e(Lt.t3);case 30:return Lt.prev=30,ge.f(),Lt.finish(30);case 33:return yi=_.services.commandExecutor.mutateResource("post",_.conversation._links.messages,{body:h.text,subject:(Y=h.emailOptions)===null||Y===void 0?void 0:Y.subject,media_sids:J.map(function(Us){return Us.sid}),attributes:typeof h.attributes<"u"?JSON.stringify(h.attributes):void 0,content_sid:h.contentSid,content_variables:typeof h.contentVariables<"u"?JSON.stringify(h.contentVariables.reduce(function(Us,bi){return Ns(Ns({},Us),{},H.default({},bi.name,bi.value))},{})):void 0}),Lt.prev=34,Lt.t4=y,Lt.next=38,yi;case 38:Lt.t5=Lt.sent,(0,Lt.t4)(Lt.t5),Lt.next=45;break;case 42:Lt.prev=42,Lt.t6=Lt.catch(34),k(Lt.t6);case 45:case"end":return Lt.stop()}},g,null,[[4,27,30,33],[8,19],[34,42]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"send",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k=arguments;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return g=k.length>1&&k[1]!==void 0?k[1]:{},y=k.length>2?k[2]:void 0,hn.debug("Sending text message",v,g,y),Y.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:v??"",attributes:typeof g<"u"?JSON.stringify(g):void 0,subject:y==null?void 0:y.subject}));case 4:case"end":return Y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"sendMedia",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y,J=arguments;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(k=J.length>1&&J[1]!==void 0?J[1]:{},S=J.length>2?J[2]:void 0,hn.debug("Sending media message",v,k,S),hn.debug("Sending media message as ".concat(v instanceof FormData?"FormData":"SendMediaOptions"),v,k),!(v instanceof FormData)){ge.next=10;break}return ge.next=7,this.services.mcsClient.postFormData(v);case 7:ge.t0=ge.sent,ge.next=13;break;case 10:return ge.next=12,this.services.mcsClient.post((g=v.contentType)!==null&&g!==void 0?g:"",(y=v.media)!==null&&y!==void 0?y:"","media",v.filename);case 12:ge.t0=ge.sent;case 13:return Y=ge.t0,ge.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[Y.sid],attributes:typeof k<"u"?JSON.stringify(k):void 0});case 16:return ge.abrupt("return",ge.sent);case 17:case"end":return ge.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k=arguments;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=k.length>2&&k[2]!==void 0?k[2]:"backwards",Y.abrupt("return",this._getMessages(v,g,y));case 2:case"end":return Y.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_wrapPaginator",value:function(h,_,v){var g=this,y=h==="desc",k=function(){return _.nextPage().then(function(J){return g._wrapPaginator(h,J,v)})},S=function(){return _.prevPage().then(function(J){return g._wrapPaginator(h,J,v)})};return v(_.items).then(function(Y){return{items:Y.sort(function(J,le){return J.index-le.index}),hasPrevPage:y?_.hasNextPage:_.hasPrevPage,hasNextPage:y?_.hasPrevPage:_.hasNextPage,prevPage:y?k:S,nextPage:y?S:k}})}},{key:"_upsertMessage",value:function(h,_){var v=this,g=this.messagesByIndex.get(h);if(g)return g;var y={self:"".concat(this.conversation._links.messages,"/").concat(_.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(_.sid,"/Receipts")},k=new en(h,_,this.conversation,y,this.configuration,this.services);return this.messagesByIndex.set(k.index,k),k.on("updated",function(S){return v.emit("messageUpdated",S)}),k}},{key:"_getMessages",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y,k,S,Y,J,le=arguments;return M.default.wrap(function(vt){for(;;)switch(vt.prev=vt.next){case 0:return g=le.length>0&&le[0]!==void 0?le[0]:30,y=le.length>1&&le[1]!==void 0?le[1]:"end",k=le.length>2&&le[2]!==void 0?le[2]:"forward",S=k==="backwards"?"desc":"asc",vt.next=6,this.messagesListPromise;case 6:return Y=vt.sent,vt.next=9,Y==null?void 0:Y.getItems({from:y!=="end"?y:void 0,pageSize:g,order:S,limit:g});case 9:return J=vt.sent,vt.next=12,this._wrapPaginator(S,J,function(Et){return Promise.all(Et.map(function(Ht){return v._upsertMessage(Ht.index,Ht.data)}))});case 12:return vt.abrupt("return",vt.sent);case 13:case"end":return vt.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter),Pn=function(){function C(x){ke.default(this,C),H.default(this,"attributes",{}),H.default(this,"mediaContent",[]),H.default(this,"emailOptions",{}),this.messagesEntity=x}return ye.default(C,[{key:"send",value:function(){var w=this;return new ze.CancellablePromise(function(){var p=re.default(M.default.mark(function h(_,v,g){var y,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=w.messagesEntity.sendV2(w),g(function(){return y.cancel()}),Y.prev=2,Y.next=5,y;case 5:k=Y.sent,_(Wt(k.index)),Y.next=12;break;case 9:Y.prev=9,Y.t0=Y.catch(2),v(Y.t0);case 12:case"end":return Y.stop()}},h,null,[[2,9]])}));return function(h,_,v){return p.apply(this,arguments)}}())}}]),C}(),Dr=function(){function C(x,w){ke.default(this,C),this.limits=x,this.message=new Pn(w),this.emailBodies=new Map,this.emailHistories=new Map}return ye.default(C,[{key:"setBody",value:function(w){return this.message.text=w,this}},{key:"setSubject",value:function(w){return this.message.emailOptions.subject=w,this}},{key:"setAttributes",value:function(w){return this.message.attributes=w,this}},{key:"setEmailBody",value:function(w,p){return this.emailBodies.set(w,p),this}},{key:"setEmailHistory",value:function(w,p){return this.emailHistories.set(w,p),this}},{key:"setContentTemplate",value:function(w){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return this.message.contentSid=w,this.message.contentVariables=p,this}},{key:"addMedia",value:function(w){if(typeof FormData>"u"&&w instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(w instanceof FormData)){var p=w;if(!p.contentType||!p.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",w]),this}},{key:"build",value:function(){var w=this;if(this.emailBodies.forEach(function(p,h){if(!w.limits.emailBodiesAllowedContentTypes.includes(h))throw new Error("Unsupported email body content type ".concat(h))}),this.emailHistories.forEach(function(p,h){if(!w.limits.emailHistoriesAllowedContentTypes.includes(h))throw new Error("Unsupported email history content type ".concat(h))}),this.emailBodies.size>this.limits.emailBodiesAllowedContentTypes.length)throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size," > ").concat(this.limits.emailBodiesAllowedContentTypes.length,")"));if(this.emailHistories.size>this.limits.emailHistoriesAllowedContentTypes.length)throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size," > ").concat(this.limits.emailHistoriesAllowedContentTypes.length,")"));if(this.message.mediaContent.length>this.limits.mediaAttachmentsCountLimit)throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length," > ").concat(this.limits.mediaAttachmentsCountLimit,")"));return this.emailBodies.forEach(function(p){w.message.mediaContent.push(["body",p])}),this.emailHistories.forEach(function(p){w.message.mediaContent.push(["history",p])}),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),C}();Be([b.validateTypes("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Dr)],Dr.prototype,"setBody",null),Be([b.validateTypes("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Dr)],Dr.prototype,"setSubject",null),Be([b.validateTypes(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Dr)],Dr.prototype,"setAttributes",null),Be([b.validateTypes("string",[FormData,ct]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Dr)],Dr.prototype,"setEmailBody",null),Be([b.validateTypes("string",[FormData,ct]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Dr)],Dr.prototype,"setEmailHistory",null),Be([b.validateTypes("string",[b.array("content variables",It),"undefined"]),be("design:type",Function),be("design:paramtypes",[String,Array]),be("design:returntype",Dr)],Dr.prototype,"setContentTemplate",null),Be([b.validateTypes([FormData,ct]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Dr)],Dr.prototype,"addMedia",null);function qo(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=ni(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1316
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function ni(C,x){if(C){if(typeof C=="string")return Mn(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Mn(C,x)}}function Mn(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}function js(C){var x=te();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function te(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ue={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"},I=function(C){q.default(w,C);var x=js(w);function w(p,h,_,v,g){var y,k,S;ke.default(this,w),S=x.call(this),S.sid=h,S._links=_,S._configuration=v,S._services=g,S._entityName=p.channel,S._internalState={uniqueName:p.uniqueName||null,status:"notParticipating",attributes:(y=p.attributes)!==null&&y!==void 0?y:{},createdBy:p.createdBy,dateCreated:Ot(p.dateCreated),dateUpdated:Ot(p.dateUpdated),friendlyName:p.friendlyName||null,lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,bindings:(k=p.bindings)!==null&&k!==void 0?k:{}},p.notificationLevel&&(S._internalState.notificationLevel=p.notificationLevel);var Y={participants:S._links.participants};return S._participants=new Map,S._participantsEntity=new qe(oe.default(S),S._participants,Y,S._services),S._participantsEntity.on(w.participantJoined,function(J){return S.emit(w.participantJoined,J)}),S._participantsEntity.on(w.participantLeft,function(J){return S.emit(w.participantLeft,J)}),S._participantsEntity.on(w.participantUpdated,function(J){return S.emit(w.participantUpdated,J)}),S._messagesEntity=new Ds(oe.default(S),v,g),S._messagesEntity.on(w.messageAdded,function(J){return S._onMessageAdded(J)}),S._messagesEntity.on(w.messageUpdated,function(J){return S.emit(w.messageUpdated,J)}),S._messagesEntity.on(w.messageRemoved,function(J){return S.emit(w.messageRemoved,J)}),S}return ye.default(w,[{key:"uniqueName",get:function(){return this._internalState.uniqueName}},{key:"status",get:function(){return this._internalState.status}},{key:"friendlyName",get:function(){return this._internalState.friendlyName}},{key:"dateUpdated",get:function(){return this._internalState.dateUpdated}},{key:"dateCreated",get:function(){return this._internalState.dateCreated}},{key:"createdBy",get:function(){var h;return(h=this._internalState.createdBy)!==null&&h!==void 0?h:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var h;return(h=this._internalState.lastMessage)!==null&&h!==void 0?h:void 0}},{key:"notificationLevel",get:function(){var h;return(h=this._internalState.notificationLevel)!==null&&h!==void 0?h:"default"}},{key:"bindings",get:function(){return this._internalState.bindings}},{key:"limits",get:function(){return this._configuration.limits}},{key:"state",get:function(){return this._internalState.state}},{key:"_statusSource",get:function(){return this._dataSource}},{key:"add",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.abrupt("return",this._participantsEntity.add(v,g??{}));case 1:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k,S=arguments;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=S.length>2&&S[2]!==void 0?S[2]:{},k=S.length>3&&S[3]!==void 0?S[3]:{},J.abrupt("return",this._participantsEntity.addNonChatParticipant(v,g,y??{},k??{}));case 3:case"end":return J.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"advanceLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._subscribeStreams();case 2:if(!(v<((g=this.lastReadMessageIndex)!==null&&g!==void 0?g:0))){k.next=6;break}return k.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:return k.abrupt("return",k.sent);case 6:return k.next=8,this._setLastReadMessageIndex(v);case 8:return k.abrupt("return",k.sent);case 9:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"delete",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getAttributes",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribe();case 2:return g.abrupt("return",this.attributes);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=re.default(M.default.mark(function _(v,g,y){return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._subscribeStreams();case 2:return S.abrupt("return",this._messagesEntity.getMessages(v,g,y));case 3:case"end":return S.stop()}},_,this)}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantsCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new W(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.participants_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this._participantsEntity.getParticipantBySid(v));case 1:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=re.default(M.default.mark(function _(){var v,g=arguments;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return v=g.length>0&&g[0]!==void 0?g[0]:"",k.abrupt("return",this._participantsEntity.getParticipantByIdentity(v??""));case 2:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessagesCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new W(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.messages_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getUnreadMessagesCount",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return v=new W(this._configuration.links.myConversations).path(this.sid).build(),S.next=3,this._services.network.get(v);case 3:if(g=S.sent,g.body.conversation_sid===this.sid){S.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if(y=g.body.unread_messages_count,typeof y!="number"){S.next=9;break}return S.abrupt("return",y);case 9:return S.abrupt("return",null);case 10:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"join",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"leave",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this._internalState.status!=="joined"){g.next=3;break}return g.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return g.abrupt("return",this);case 4:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"removeParticipant",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._participantsEntity.remove(typeof v=="string"?v:v.sid);case 2:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"sendMessage",value:function(){var p=re.default(M.default.mark(function _(v,g,y){var k,S,Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(!(typeof v=="string"||v===null)){ge.next=5;break}return ge.next=3,this._messagesEntity.send(v,g,y);case 3:return Y=ge.sent,ge.abrupt("return",(S=Wt(Y.index))!==null&&S!==void 0?S:0);case 5:return ge.next=7,this._messagesEntity.sendMedia(v,g,y);case 7:return J=ge.sent,ge.abrupt("return",(k=Wt(J.index))!==null&&k!==void 0?k:0);case 9:case"end":return ge.stop()}},_,this)}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"prepareMessage",value:function(){return new Dr(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.next=4,this.getMessages(1);case 4:if(v=y.sent,!(v.items.length>0)){y.next=7;break}return y.abrupt("return",this.advanceLastReadMessageIndex(v.items[0].index));case 7:return y.abrupt("return",0);case 8:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setAllMessagesUnread",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.next=4,this._setLastReadMessageIndex(null);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setUserNotificationLevel",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:v});case 2:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:v!==void 0?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.friendlyName===v){y.next=3;break}return y.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:v});case 3:return y.abrupt("return",this);case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.abrupt("return",this._setLastReadMessageIndex(v));case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"updateUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.uniqueName===v){y.next=4;break}return v||(v=""),y.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:v});case 4:return y.abrupt("return",this);case 5:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid,v);case 2:return y.abrupt("return",y.sent);case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"_subscribe",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._entityPromise){y.next=2;break}return y.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),y.prev=3,y.next=6,this._entityPromise;case 6:return this._entity=y.sent,this._entity.on(Oe.SyncDocument.updated,function(k){return v._update(k.data)}),this._entity.on(Oe.SyncDocument.removed,function(){return v.emit(w.removed,v)}),this._update(this._entity.data),y.abrupt("return",this._entity);case 13:throw y.prev=13,y.t0=y.catch(3),this._entity=null,this._entityPromise=null,this._services.syncClient.connectionState!="disconnected"&&w._logger.error("Failed to get conversation object",y.t0),w._logger.debug("ERROR: Failed to get conversation object",y.t0),y.t0;case 20:case"end":return y.stop()}},_,this,[[3,13]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_fetchStreams",value:function(){var p=re.default(M.default.mark(function _(){var v=this;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._streamsPromise){y.next=2;break}return y.abrupt("return",this._streamsPromise);case 2:return this._streamsPromise=new Promise(function(){var k=re.default(M.default.mark(function S(Y,J){var le,ge,vt,Et,Ht;return M.default.wrap(function(_r){for(;;)switch(_r.prev=_r.next){case 0:return _r.prev=0,_r.next=3,v._subscribe();case 3:_r.next=9;break;case 5:return _r.prev=5,_r.t0=_r.catch(0),w._logger.trace("Failed to subscribe to conversation",_r.t0),_r.abrupt("return",J(_r.t0));case 9:w._logger.trace("_streamsAvailable, this.entity.data=",(le=v._entity)===null||le===void 0?void 0:le.data),vt=(ge=v._entity)===null||ge===void 0?void 0:ge.data,Et=v._services.syncClient.list({id:vt.messages,mode:"open_existing"}).then(function(mr){return v._messagesList=mr,mr}),Ht=v._services.syncClient.map({id:vt.roster,mode:"open_existing"}).then(function(mr){return v._participantsMap=mr,mr}),Promise.all([Et,Ht]).then(function(){return Y(!0)}).catch(function(mr){w._logger.trace("Failed to fetch conversation streams for conversation",v.sid,mr),J(mr)});case 14:case"end":return _r.stop()}},S,null,[[0,5]])}));return function(S,Y){return k.apply(this,arguments)}}()),y.abrupt("return",this._streamsPromise.catch(function(k){throw v._streamsPromise=null,k}));case 4:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeStreams",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y,k,S,Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return ge.prev=0,ge.next=3,this._fetchStreams();case 3:return w._logger.trace("_subscribeStreams, this.entity.data=",(v=this._entity)===null||v===void 0?void 0:v.data),S=(g=this._entity)===null||g===void 0?void 0:g.data,Y=S.messages,J=S.roster,ge.next=9,Promise.all([this._messagesEntity.subscribe((y=this._messagesList)!==null&&y!==void 0?y:Y),this._participantsEntity.subscribe((k=this._participantsMap)!==null&&k!==void 0?k:J)]);case 9:ge.next=16;break;case 11:throw ge.prev=11,ge.t0=ge.catch(0),this._services.syncClient.connectionState!=="disconnected"&&w._logger.error("Failed to subscribe on conversation objects",this.sid,ge.t0),w._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,ge.t0),ge.t0;case 16:case"end":return ge.stop()}},_,this,[[0,11]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_unsubscribe",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return this._entity&&(this._entity.close(),this._entity=null,this._entityPromise=null),g.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 2:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_setStatus",value:function(h,_){var v=this;if(this._dataSource=_,this._internalState.status!==h){if(this._internalState.status=h,h==="joined"){this._subscribeStreams().catch(function(g){if(w._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g});return}this._entityPromise&&this._unsubscribe().catch(function(g){if(w._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g})}}},{key:"_update",value:function(h){var _,v,g,y,k;w._logger.trace("_update",h),w.preprocessUpdate(h,this.sid);for(var S=new Set,Y=0,J=Object.keys(h);Y<J.length;Y++){var le=J[Y],ge=ue[le];if(ge)switch(ge){case ue.status:if(!h.status||h.status==="unknown"||this._internalState.status===h.status)break;this._internalState.status=h.status,S.add(ge);break;case ue.attributes:if(je.default(this._internalState.attributes,h.attributes))break;this._internalState.attributes=h.attributes,S.add(ge);break;case ue.lastConsumedMessageIndex:if(h.lastConsumedMessageIndex===void 0||h.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=h.lastConsumedMessageIndex,S.add("lastReadMessageIndex");break;case ue.lastMessage:if(this._internalState.lastMessage&&!h.lastMessage){delete this._internalState.lastMessage,S.add(ge);break}this._internalState.lastMessage=this._internalState.lastMessage||{},((_=h.lastMessage)===null||_===void 0?void 0:_.index)!==void 0&&h.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=h.lastMessage.index,S.add(ge)),((v=h.lastMessage)===null||v===void 0?void 0:v.timestamp)!==void 0&&((g=this._internalState.lastMessage)===null||g===void 0||(y=g.dateCreated)===null||y===void 0?void 0:y.getTime())!==h.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=h.lastMessage.timestamp,S.add(ge)),je.default(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case ue.state:var vt=h.state||void 0;if(vt!==void 0&&(vt.dateUpdated=new Date(vt.dateUpdated)),je.default(this._internalState.state,vt))break;this._internalState.state=vt,S.add(ge);break;case ue.bindings:if(je.default(this._internalState.bindings,h.bindings))break;this._internalState.bindings=h.bindings,S.add(ge);break;default:var Et=h[le]instanceof Date,Ht=Et&&((k=this._internalState[ge])===null||k===void 0?void 0:k.getTime())===h[le].getTime(),Qt=!Et&&this[ge]===h[le];if(Ht||Qt)break;this._internalState[ge]=h[le],S.add(ge)}}S.size>0&&this.emit(w.updated,{conversation:this,updateReasons:rt.default(S)})}},{key:"_onMessageAdded",value:function(h){var _=qo(this._participants.values()),v;try{for(_.s();!(v=_.n()).done;){var g=v.value;if(g.identity===h.author){g._endTyping();break}}}catch(y){_.e(y)}finally{_.f()}this.emit(w.messageAdded,h)}},{key:"_setLastReadMessageIndex",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:v});case 2:return g=k.sent,k.abrupt("return",g.unread_messages_count);case 4:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()}],[{key:"preprocessUpdate",value:function(h,_){try{typeof h.attributes=="string"?h.attributes=JSON.parse(h.attributes):h.attributes&&JSON.stringify(h.attributes)}catch{w._logger.warn("Retrieved malformed attributes from the server for conversation: "+_),h.attributes={}}try{h.dateCreated&&(h.dateCreated=new Date(h.dateCreated))}catch{w._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+_),delete h.dateCreated}try{h.dateUpdated&&(h.dateUpdated=new Date(h.dateUpdated))}catch{w._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+_),delete h.dateUpdated}try{h.lastMessage&&h.lastMessage.timestamp&&(h.lastMessage.timestamp=new Date(h.lastMessage.timestamp))}catch{w._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+_),delete h.lastMessage.timestamp}}}]),w}(N.ReplayEventEmitter);H.default(I,"participantJoined","participantJoined"),H.default(I,"participantLeft","participantLeft"),H.default(I,"participantUpdated","participantUpdated"),H.default(I,"messageAdded","messageAdded"),H.default(I,"messageRemoved","messageRemoved"),H.default(I,"messageUpdated","messageUpdated"),H.default(I,"typingEnded","typingEnded"),H.default(I,"typingStarted","typingStarted"),H.default(I,"updated","updated"),H.default(I,"removed","removed"),H.default(I,"_logger",Jt.scope("Conversation")),Be([b.validateTypesAsync(b.nonEmptyString,He),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],I.prototype,"add",null),Be([b.validateTypesAsync(b.nonEmptyString,b.nonEmptyString,He,He),be("design:type",Function),be("design:paramtypes",[String,String,Object,Object]),be("design:returntype",Promise)],I.prototype,"addNonChatParticipant",null),Be([b.validateTypesAsync(b.nonNegativeInteger),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],I.prototype,"advanceLastReadMessageIndex",null),Be([b.validateTypesAsync(["undefined",b.nonNegativeInteger],["undefined",b.nonNegativeInteger],["undefined",b.literal("backwards","forward")]),be("design:type",Function),be("design:paramtypes",[Number,Number,String]),be("design:returntype",Promise)],I.prototype,"getMessages",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"getParticipantBySid",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"getParticipantByIdentity",null),Be([b.validateTypesAsync([b.nonEmptyString,G]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],I.prototype,"removeParticipant",null),Be([b.validateTypesAsync(["string",FormData,b.literal(null),b.objectSchema("media options",{contentType:b.nonEmptyString,media:b.custom(function(C){var x=typeof C=="string"&&C.length>0||C instanceof Uint8Array||C instanceof ArrayBuffer;return typeof Blob=="function"&&(x=x||C instanceof Blob),[x,"a non-empty string, an instance of Buffer or an instance of Blob"]})})],He,["undefined",b.literal(null),b.objectSchema("email attributes",{subject:[b.nonEmptyString,"undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object,Object,Object]),be("design:returntype",Promise)],I.prototype,"sendMessage",null),Be([b.validateTypesAsync(b.literal("default","muted")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"setUserNotificationLevel",null),Be([b.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],I.prototype,"updateAttributes",null),Be([b.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"updateFriendlyName",null),Be([b.validateTypesAsync([b.literal(null),b.nonNegativeInteger]),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],I.prototype,"updateLastReadMessageIndex",null),Be([b.validateTypesAsync(["string",b.literal(null)]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],I.prototype,"updateUniqueName",null);var O=function(){function C(){var x=this;ke.default(this,C),this._promise=new Promise(function(w,p){x._resolve=w,x._reject=p})}return ye.default(C,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(w){this._resolve(w)}},{key:"set",value:function(w){this.current=w,this._resolve(w)}},{key:"fail",value:function(w){this._reject(w)}}]),C}();function R(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Z(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1317
1317
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Z(C,x){if(C){if(typeof C=="string")return j(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return j(C,x)}}function j(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}function Le(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function Ae(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?Le(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):Le(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Ve(C){var x=at();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function at(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Tt=Jt.scope("Conversations"),Br=function(C){q.default(w,C);var x=Ve(w);function w(p,h){var _;return ke.default(this,w),_=x.call(this),H.default(oe.default(_),"conversations",new Map),H.default(oe.default(_),"myConversationsRead",new O),H.default(oe.default(_),"tombstones",new Set),H.default(oe.default(_),"myConversationsFetched",!1),_.configuration=p,_.services=h,_}return ye.default(w,[{key:"addConversation",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y,J,le,ge,vt,Et;return M.default.wrap(function(Qt){for(;;)switch(Qt.prev=Qt.next){case 0:return S=typeof(v==null?void 0:v.attributes)<"u"?v.attributes:{},Qt.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:v.friendlyName,unique_name:v.uniqueName,access:v.access,attributes:typeof S<"u"?JSON.stringify(S):void 0});case 3:if(Y=Qt.sent,J=(g=Y.sid)!==null&&g!==void 0?g:null,le=(y=(k=Y.sync_objects)===null||k===void 0?void 0:k.conversation)!==null&&y!==void 0?y:null,ge=Ae({self:Y.url},Y.links),vt=this.conversations.get(J),!vt){Qt.next=12;break}return Qt.next=11,vt._subscribe();case 11:return Qt.abrupt("return",vt);case 12:return Et=new I({channel:le,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},J,ge,this.configuration,this.services),this.conversations.set(Et.sid,Et),this._registerForEvents(Et),Qt.next=17,Et._subscribe();case 17:return this.emit("conversationAdded",Et),Qt.abrupt("return",Et);case 19:case"end":return Qt.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"fetchConversations",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y,k,S,Y,J,le;return M.default.wrap(function(vt){for(;;)switch(vt.prev=vt.next){case 0:return vt.prev=0,vt.next=3,this._getMap();case 3:return g=vt.sent,g.on(Oe.SyncMap.itemAdded,function(Et){Tt.debug("itemAdded: ".concat(Et.item.key)),v._upsertConversation("sync",Et.item.key,Et.item.data)}),g.on(Oe.SyncMap.itemRemoved,function(Et){Tt.debug("itemRemoved: ".concat(Et.key));var Ht=Et.key;v.myConversationsFetched||v.tombstones.add(Ht);var Qt=v.conversations.get(Ht);Qt&&(Qt.status==="joined"&&(Qt._setStatus("notParticipating","sync"),v.emit("conversationLeft",Qt)),v.conversations.delete(Ht),v.emit("conversationRemoved",Qt),Qt.emit("removed",Qt))}),g.on(Oe.SyncMap.itemUpdated,function(Et){Tt.debug("itemUpdated: ".concat(Et.item.key)),v._upsertConversation("sync",Et.item.key,Et.item.data)}),vt.next=9,this._fetchMyConversations();case 9:y=vt.sent,k=[],S=R(y);try{for(S.s();!(Y=S.n()).done;)J=Y.value,k.push(this._upsertConversation("rest",J.channel_sid,J))}catch(Et){S.e(Et)}finally{S.f()}return this.myConversationsRead.set(!0),vt.next=16,Promise.all(k);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),Tt.debug("The conversations list has been successfully fetched"),vt.abrupt("return",this);case 22:throw vt.prev=22,vt.t0=vt.catch(0),le="Failed to fetch the conversations list",this.services.syncClient.connectionState!=="disconnected"&&Tt.error(le,vt.t0),Tt.debug("ERROR: ".concat(le),vt.t0),vt.t0;case 28:case"end":return vt.stop()}},_,this,[[0,22]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"getConversations",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g,y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._getMap();case 2:return g=S.sent,S.next=5,g.getItems();case 5:return y=S.sent,S.abrupt("return",this._wrapPaginator(y,function(Y){return Promise.all(Y.map(function(J){return v._upsertConversation("sync",J.key,J.data)}))}));case 7:case"end":return S.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getConversation",value:function(){var p=re.default(M.default.mark(function _(v){var g=this,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.next=2,this._getMap();case 2:return y=J.sent,J.next=5,y.getItems({key:v});case 5:return k=J.sent,S=k.items.map(function(le){return g._upsertConversation("sync",le.key,le.data)}),J.abrupt("return",S.length>0?S[0]:null);case 8:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getConversationByUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:return g=new W(this.configuration.links.myConversations).path(v).build(),le.next=3,this.services.network.get(g);case 3:return y=le.sent,k=y.body,S=k.conversation_sid,Y={entityName:null,lastConsumedMessageIndex:k.last_read_message_index,status:(k==null?void 0:k.status)||"unknown",friendlyName:k.friendly_name,dateUpdated:k.date_updated,dateCreated:k.date_created,uniqueName:k.unique_name,createdBy:k.created_by,attributes:k.attributes,channel:k.sync_objects.conversation,roster:k.sync_objects.participants,messages:k.sync_objects.messages,notificationLevel:k==null?void 0:k.notification_level,sid:S},le.abrupt("return",S?this._upsertConversation("sync",S,Y):null);case 8:case"end":return le.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"peekConversation",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return g=new W(this.configuration.links.conversations).path(v).build(),J.next=3,this.services.network.get(g);case 3:return y=J.sent,k=y.body,S={entityName:null,status:(k==null?void 0:k.status)||"unknown",friendlyName:k.friendly_name,dateUpdated:k.date_updated,dateCreated:k.date_created,uniqueName:k.unique_name,createdBy:k.created_by,attributes:k.attributes,channel:k.sync_objects.conversation||"".concat(v,".channel"),roster:k.sync_objects.participants,messages:k.sync_objects.messages,notificationLevel:k==null?void 0:k.notification_level,sid:v},J.abrupt("return",this._upsertConversation("sync",v,S));case 7:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"_getMap",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return g.abrupt("return",g.sent);case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_wrapPaginator",value:function(){var p=re.default(M.default.mark(function _(v,g){var y=this,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return Y.next=2,g(v.items);case 2:return k=Y.sent,Y.abrupt("return",{items:k.filter(function(J){return J!==null}),hasNextPage:v.hasNextPage,hasPrevPage:v.hasPrevPage,nextPage:function(){return v.nextPage().then(function(le){return y._wrapPaginator(le,g)})},prevPage:function(){return v.prevPage().then(function(le){return y._wrapPaginator(le,g)})}});case 4:case"end":return Y.stop()}},_)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"_updateConversation",value:function(){var p=re.default(M.default.mark(function _(v,g,y){var k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(k=g._statusSource!==void 0&&v!==g._statusSource,S=v!=="rest"||g._statusSource==="sync",!(k&&S&&v!=="sync")){le.next=5;break}return Tt.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:g.sid,data:y.status,conversation:g.status}),le.abrupt("return");case 5:if(!(y.status==="joined"&&g.status!=="joined")){le.next=15;break}return g._setStatus("joined",v),Y={},typeof y.notificationLevel<"u"&&(Y.notificationLevel=y.notificationLevel),typeof y.lastConsumedMessageIndex<"u"&&(Y.lastConsumedMessageIndex=y.lastConsumedMessageIndex),je.default(Y,{})||g._update(Y),le.next=13,g._subscribe();case 13:return this.emit("conversationJoined",g),le.abrupt("return");case 15:if(!(y.status==="notParticipating"&&g.status==="joined")){le.next=22;break}return g._setStatus("notParticipating",v),g._update(y),le.next=20,g._subscribe();case 20:return this.emit("conversationLeft",g),le.abrupt("return");case 22:if(y.status!=="notParticipating"){le.next=26;break}return le.next=25,g._subscribe();case 25:return le.abrupt("return");case 26:g._update(y);case 27:case"end":return le.stop()}},_,this)}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"_upsertConversation",value:function(){var p=re.default(M.default.mark(function _(v,g,y){var k,S,Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(Tt.trace("upsertConversation called for ".concat(g),y),k=this.conversations.get(g),!k){ge.next=9;break}return Tt.trace("upsertConversation: the conversation ".concat(k.sid," is known;")+"its status is known from the source ".concat(k._statusSource," ")+"and the update came from the source ".concat(v),k),ge.next=6,this._updateConversation(v,k,y);case 6:return ge.next=8,k._subscribe();case 8:return ge.abrupt("return",k);case 9:if(!(v==="rest"&&this.tombstones.has(g))){ge.next=12;break}return Tt.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",g),ge.abrupt("return",null);case 12:return Tt.trace("upsertConversation: creating a local conversation object with sid "+g,y),S="".concat(this.configuration.links.conversations,"/").concat(g),Y={self:S,messages:"".concat(S,"/Messages"),participants:"".concat(S,"/Participants")},J=new I(y,g,Y,this.configuration,this.services),this.conversations.set(g,J),ge.prev=17,ge.next=20,J._subscribe();case 20:if(y.status!=="joined"){ge.next=23;break}return ge.next=23,J._fetchStreams();case 23:ge.next=32;break;case 25:if(ge.prev=25,ge.t0=ge.catch(17),ge.t0.name==="SyncError"){ge.next=29;break}throw ge.t0;case 29:return Tt.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",g,ge.t0),this.conversations.delete(g),ge.abrupt("return",null);case 32:return this._registerForEvents(J),this.emit("conversationAdded",J),y.status==="joined"&&(J._setStatus("joined",v),this.emit("conversationJoined",J)),ge.abrupt("return",J);case 36:case"end":return ge.stop()}},_,this,[[17,25]])}));function h(_,v,g){return p.apply(this,arguments)}return h}()},{key:"_fetchMyConversations",value:function(){var p=re.default(M.default.mark(function _(){var v,g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:v=[],g=null;case 2:return k=new W(this.configuration.links.myConversations),g&&k.arg("PageToken",g),le.next=6,this.services.network.get(k.build());case 6:S=le.sent,Y=(y=S.body)===null||y===void 0?void 0:y.conversations.map(function(ge){return{descriptor:ge,channel_sid:ge.conversation_sid,status:ge.status,channel:ge.sync_objects.conversation,messages:ge.sync_objects.messages,roster:ge.sync_objects.participants||"".concat(ge.conversation_sid,".roster"),lastConsumedMessageIndex:ge.last_read_message_index,notificationLevel:ge.notification_level}}),g=S.body.meta.next_token,v=[].concat(rt.default(v),rt.default(Y));case 10:if(g){le.next=2;break}case 11:return le.abrupt("return",v);case 12:case"end":return le.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_onConversationRemoved",value:function(h){var _=this.conversations.get(h);_&&(this.conversations.delete(h),this.emit("conversationRemoved",_))}},{key:"_registerForEvents",value:function(h){var _=this;h.on("removed",function(){return _._onConversationRemoved(h.sid)}),h.on("updated",function(v){return _.emit("conversationUpdated",v)}),h.on("participantJoined",function(v){return _.emit("participantJoined",v)}),h.on("participantLeft",function(v){return _.emit("participantLeft",v)}),h.on("participantUpdated",function(v){return _.emit("participantUpdated",v)}),h.on("messageAdded",function(v){return _.emit("messageAdded",v)}),h.on("messageUpdated",function(v){return _.emit("messageUpdated",v)}),h.on("messageRemoved",function(v){return _.emit("messageRemoved",v)}),h.on("typingStarted",function(v){return _.emit("typingStarted",v)}),h.on("typingEnded",function(v){return _.emit("typingEnded",v)})}}]),w}(N.ReplayEventEmitter);function Nn(C){var x=kn();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function kn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var D=function(C){q.default(w,C);var x=Nn(w);function w(p,h,_){var v;return ke.default(this,w),v=x.call(this),v.configuration=h,v.services=_,v.fifoStack=[],v.myself=p,v.myself.on("updated",function(g){return v.emit("userUpdated",g)}),v.myself.on("userSubscribed",function(){return v.emit("userSubscribed",v.myself)}),v.myself.on("userUnsubscribed",function(){v.emit("userUnsubscribed",v.myself),v.myself._ensureFetched()}),v.subscribedUsers=new Map,v}return ye.default(w,[{key:"handleUnsubscribeUser",value:function(h){this.subscribedUsers.has(h.identity)&&this.subscribedUsers.delete(h.identity);var _=0,v=this.fifoStack.find(function(g,y){return g==h.identity?(_=y,!0):!1});v&&this.fifoStack.splice(_,1),this.emit("userUnsubscribed",h)}},{key:"handleSubscribeUser",value:function(h){if(!this.subscribedUsers.has(h.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var _,v,g=this.fifoStack.shift();(_=this.subscribedUsers)===null||_===void 0||(v=_.get(g))===null||v===void 0||v.unsubscribe()}this.fifoStack.push(h.identity),this.subscribedUsers.set(h.identity,h),this.emit("userSubscribed",h)}}},{key:"getUser",value:function(){var p=re.default(M.default.mark(function _(v,g){var y,k=this,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:return le.next=2,this.myself._ensureFetched();case 2:if(v!=this.myself.identity){le.next=4;break}return le.abrupt("return",this.myself);case 4:if(S=this.subscribedUsers.get(v),!S){le.next=7;break}return le.abrupt("return",S);case 7:if(!((y=g)!==null&&y!==void 0)){le.next=11;break}le.next=14;break;case 11:return le.next=13,this.getSyncUniqueName(v);case 13:g=le.sent;case 14:return Y=new Re(v,g,this.configuration,this.services),Y.on("updated",function(ge){return k.emit("userUpdated",ge)}),Y.on("userSubscribed",function(){return k.handleSubscribeUser(Y)}),Y.on("userUnsubscribed",function(){return k.handleUnsubscribeUser(Y)}),le.next=20,Y._ensureFetched();case 20:return le.abrupt("return",Y);case 21:case"end":return le.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"getSubscribedUsers",value:function(){var p=re.default(M.default.mark(function _(){var v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.myself._ensureFetched();case 2:return v=[this.myself],this.subscribedUsers.forEach(function(k){return v.push(k)}),y.abrupt("return",v);case 5:case"end":return y.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getSyncUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){var g,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return k=new W(this.configuration.links.users).path(v).build(),J.next=3,this.services.network.get(k);case 3:return S=J.sent,J.abrupt("return",(g=(y=S.body)===null||y===void 0?void 0:y.sync_objects.user_info_map)!==null&&g!==void 0?g:"");case 5:case"end":return J.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()}]),w}(N.ReplayEventEmitter),B=Jt.scope("TypingIndicator"),E=function(){function C(x,w,p){ke.default(this,C),this.configuration=w,this.services=p,this.getConversation=x,this.serviceTypingTimeout=null,this.sentUpdates=new Map}return ye.default(C,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var w=this;this.services.notificationClient.on("message",function(){var p=re.default(M.default.mark(function h(_,v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(_!==me.TYPING_INDICATOR){y.next=3;break}return y.next=3,w._handleRemoteTyping(v);case 3:case"end":return y.stop()}},h)}));return function(h,_){return p.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:function(){var x=re.default(M.default.mark(function p(h){var _=this;return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:B.trace("Got new typing indicator ",h),this.getConversation(h.channel_sid).then(function(y){y&&y._participants.forEach(function(k){if(!(k.identity!==h.identity&&k.type!=="apple")){var S=_.configuration.typingIndicatorTimeoutOverride?_.configuration.typingIndicatorTimeoutOverride+1e3:h.typing_timeout*1e3;k._startTyping(S)}})}).catch(function(y){throw B.error(y),y});case 2:case"end":return g.stop()}},p,this)}));function w(p){return x.apply(this,arguments)}return w}()},{key:"send",value:function(w){var p=this.sentUpdates.get(w);return p&&p>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(w,Date.now()),this._send(w))}},{key:"_send",value:function(w){var p=this;B.trace("Sending typing indicator");var h=this.configuration.links.typing,_={"Content-Type":"application/x-www-form-urlencoded"},v="ChannelSid=".concat(w);return this.services.twilsockClient.post(h,_,v,this.configuration.productId).then(function(g){g.body.hasOwnProperty("typing_timeout")&&(p.serviceTypingTimeout=g.body.typing_timeout*1e3)}).catch(function(g){throw B.error("Failed to send typing indicator:",g),g})}}]),C}(),T=ye.default(function C(x){ke.default(this,C),this.title=x.title||null,this.body=x.body||null,this.sound=x.sound||null,this.badge=x.badge||null,this.action=x.action||null,this.type=x.type||null,this.data=x.data||{}}),$="2.6.5";function U(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function P(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?U(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):U(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function Me(C){var x=Ce();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Ce(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Qe=function(x){return x.replace(/(^\/+|\/+$)/g,"")},it=function(x){return x.status.code===202},Pt=function(C){q.default(w,C);var x=Me(w);function w(p){return ke.default(this,w),x.call(this,p)}return ye.default(w)}(Ke.default(Error)),vn=function(){function C(x,w,p){ke.default(this,C),this._serviceUrl=x,this._services=w,this._productId=p}return ye.default(C,[{key:"_preProcessUrl",value:function(w){var p=Qe(w);return/^https?:\/\//.test(w)?p:"".concat(Qe(this._serviceUrl),"/").concat(p)}},{key:"_makeRequest",value:function(){var x=re.default(M.default.mark(function p(h,_,v,g){var y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:y=this._preProcessUrl(_),k=P({"Content-Type":"application/json; charset=utf-8"},g||{}),le.t0=h,le.next=le.t0==="get"?5:le.t0==="post"?11:le.t0==="delete"?15:19;break;case 5:return Y=y,v&&(Y+="?"+Object.entries(v).map(function(ge){return ge.map(encodeURIComponent).join("=")}).join("&")),le.next=9,this._services.transport.get(Y,k,this._productId);case 9:return S=le.sent,le.abrupt("break",19);case 11:return le.next=13,this._services.transport.post(y,k,JSON.stringify(v),this._productId);case 13:return S=le.sent,le.abrupt("break",19);case 15:return le.next=17,this._services.transport.delete(y,k,{},this._productId);case 17:return S=le.sent,le.abrupt("break",19);case 19:if(!(S.status.code<200||S.status.code>=300)){le.next=21;break}throw new Error("Request responded with a non-success code ".concat(S.status.code));case 21:return le.abrupt("return",S);case 22:case"end":return le.stop()}},p,this)}));function w(p,h,_,v){return x.apply(this,arguments)}return w}()},{key:"fetchResource",value:function(){var x=re.default(M.default.mark(function p(h,_){var v=this,g,y,k;return M.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return g=6,y=new Ee.AsyncRetrier({min:50,max:1600,maxAttemptsCount:g}),Y.prev=2,Y.next=5,y.run(re.default(M.default.mark(function J(){var le,ge,vt;return M.default.wrap(function(Ht){for(;;)switch(Ht.prev=Ht.next){case 0:return Ht.prev=0,Ht.next=3,v._makeRequest("get",h,_);case 3:return le=Ht.sent,Ht.abrupt("return",{type:"success",data:le.body});case 7:if(Ht.prev=7,Ht.t0=Ht.catch(0),!((Ht.t0===null||Ht.t0===void 0||(ge=Ht.t0.body)===null||ge===void 0?void 0:ge.status)===404&&(Ht.t0===null||Ht.t0===void 0||(vt=Ht.t0.body)===null||vt===void 0?void 0:vt.code)===50530)){Ht.next=11;break}return Ht.abrupt("return",{type:"noMetadata"});case 11:throw Ht.t0;case 12:case"end":return Ht.stop()}},J,null,[[0,7]])})));case 5:k=Y.sent,Y.next=11;break;case 8:throw Y.prev=8,Y.t0=Y.catch(2),new Error('Fetch resource from "'.concat(h,'" failed.'));case 11:if(k.type!=="noMetadata"){Y.next=13;break}throw new Pt("No metadata found.");case 13:return Y.abrupt("return",k.data);case 14:case"end":return Y.stop()}},p,null,[[2,8]])}));function w(p,h){return x.apply(this,arguments)}return w}()},{key:"mutateResource",value:function(){var x=re.default(M.default.mark(function p(h,_,v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._makeRequest(h,_,v,{"X-Twilio-Mutation-Id":_e.v4()});case 2:if(g=k.sent,!it(g)){k.next=7;break}return k.next=6,this.fetchResource(g.body.resource_url);case 6:return k.abrupt("return",k.sent);case 7:return k.abrupt("return",g.body);case 8:case"end":return k.stop()}},p,this)}));function w(p,h,_){return x.apply(this,arguments)}return w}()}]),C}(),Fi=function(){function C(x){var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:100,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5e3;ke.default(this,C),H.default(this,"_cachedTemplates",null),this._services=x,this._pageSize=w,this._cacheTtlMs=p}return ye.default(C,[{key:"getContentTemplates",value:function(){var x=re.default(M.default.mark(function p(){var h=this,_,v,g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(this._cachedTemplates===null){le.next=2;break}return le.abrupt("return",this._cachedTemplates);case 2:return le.next=4,this._fetchContentTemplates();case 4:_=le.sent,v=ce.default(_,2),g=v[0],y=v[1],k=g;case 9:if(y===null){le.next=19;break}return le.next=12,this._fetchContentTemplates(y);case 12:S=le.sent,Y=ce.default(S,2),g=Y[0],y=Y[1],k=[].concat(rt.default(k),rt.default(g)),le.next=9;break;case 19:return this._cachedTemplates=Object.freeze(k),setTimeout(function(){h._cachedTemplates=null},this._cacheTtlMs),le.abrupt("return",k);case 22:case"end":return le.stop()}},p,this)}));function w(){return x.apply(this,arguments)}return w}()},{key:"_fetchContentTemplates",value:function(){var x=re.default(M.default.mark(function p(h){var _,v,g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return _="Client/v2/ContentTemplates",v=new W(_),v.arg("PageSize",this._pageSize),h!==void 0&&v.arg("PageToken",h),k.next=6,this._services.commandExecutor.fetchResource(v.build());case 6:return g=k.sent,k.abrupt("return",[g.templates.map(function(S){return new jt(S)}),g.meta.next_token]);case 8:case"end":return k.stop()}},p,this)}));function w(p){return x.apply(this,arguments)}return w}()}]),C}();function tn(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Bi(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1318
1318
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Bi(C,x){if(C){if(typeof C=="string")return Yp(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Yp(C,x)}}function Yp(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}var Vw=function(C){function x(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ke.default(this,x),!(w.maxSize&&w.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=w.maxSize,this.onEviction=w.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}return ye.default(x,[{key:"_set",value:function(p,h){if(this.cache.set(p,h),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function"){var _=tn(this.oldCache.entries()),v;try{for(_.s();!(v=_.n()).done;){var g=ce.default(v.value,2),y=g[0],k=g[1];this.onEviction(y,k)}}catch(S){_.e(S)}finally{_.f()}}this.oldCache=this.cache,this.cache=new Map}}},{key:"get",value:function(p){if(this.cache.has(p))return this.cache.get(p);if(this.oldCache.has(p)){var h=this.oldCache.get(p);return this.oldCache.delete(p),this._set(p,h),h}}},{key:"set",value:function(p,h){return this.cache.has(p)?this.cache.set(p,h):this._set(p,h),this}},{key:"has",value:function(p){return this.cache.has(p)||this.oldCache.has(p)}},{key:"peek",value:function(p){if(this.cache.has(p))return this.cache.get(p);if(this.oldCache.has(p))return this.oldCache.get(p)}},{key:"delete",value:function(p){var h=this.cache.delete(p);return h&&this._size--,this.oldCache.delete(p)||h}},{key:"clear",value:function(){this.cache.clear(),this.oldCache.clear(),this._size=0}},{key:"keys",value:M.default.mark(function w(){var p,h,_,v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:p=tn(this),y.prev=1,p.s();case 3:if((h=p.n()).done){y.next=9;break}return _=ce.default(h.value,1),v=_[0],y.next=7,v;case 7:y.next=3;break;case 9:y.next=14;break;case 11:y.prev=11,y.t0=y.catch(1),p.e(y.t0);case 14:return y.prev=14,p.f(),y.finish(14);case 17:case"end":return y.stop()}},w,this,[[1,11,14,17]])})},{key:"values",value:M.default.mark(function w(){var p,h,_,v;return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:p=tn(this),y.prev=1,p.s();case 3:if((h=p.n()).done){y.next=9;break}return _=ce.default(h.value,2),v=_[1],y.next=7,v;case 7:y.next=3;break;case 9:y.next=14;break;case 11:y.prev=11,y.t0=y.catch(1),p.e(y.t0);case 14:return y.prev=14,p.f(),y.finish(14);case 17:case"end":return y.stop()}},w,this,[[1,11,14,17]])})},{key:C,value:M.default.mark(function w(){var p,h,_,v,g,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:p=tn(this.cache),J.prev=1,p.s();case 3:if((h=p.n()).done){J.next=9;break}return _=h.value,J.next=7,_;case 7:J.next=3;break;case 9:J.next=14;break;case 11:J.prev=11,J.t0=J.catch(1),p.e(J.t0);case 14:return J.prev=14,p.f(),J.finish(14);case 17:v=tn(this.oldCache),J.prev=18,v.s();case 20:if((g=v.n()).done){J.next=28;break}if(y=g.value,k=ce.default(y,1),S=k[0],this.cache.has(S)){J.next=26;break}return J.next=26,y;case 26:J.next=20;break;case 28:J.next=33;break;case 30:J.prev=30,J.t1=J.catch(18),v.e(J.t1);case 33:return J.prev=33,v.f(),J.finish(33);case 36:case"end":return J.stop()}},w,this,[[1,11,14,17],[18,30,33,36]])})},{key:"size",get:function(){var p=0,h=tn(this.oldCache.keys()),_;try{for(h.s();!(_=h.n()).done;){var v=_.value;this.cache.has(v)||p++}}catch(g){h.e(g)}finally{h.f()}return Math.min(this._size+p,this.maxSize)}}]),x}(Symbol.iterator),F=Vw,ve=ye.default(function C(x,w){ke.default(this,C),this.type=x,this.data=w,Object.freeze(w)}),We=function(){function C(x,w){ke.default(this,C),this._services=x,this._configuration=w,this._cache=new F({maxSize:w.channelMetadataCacheCapacity})}return ye.default(C,[{key:"getChannelMetadata",value:function(){var x=re.default(M.default.mark(function p(h,_){var v,g,y,k,S;return M.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(v="".concat(h,",").concat(_),g=this._cache.get(v),!g){J.next=4;break}return J.abrupt("return",g.item);case 4:return y="".concat(this._configuration.links.conversations,"/").concat(h,"/Messages/").concat(_,"/ChannelMetadata"),J.prev=5,J.next=8,this._services.commandExecutor.fetchResource(y);case 8:k=J.sent,J.next=17;break;case 11:if(J.prev=11,J.t0=J.catch(5),!(J.t0 instanceof Pt)){J.next=16;break}return this._cache.set(v,{item:null}),J.abrupt("return",null);case 16:throw new Error(J.t0);case 17:return S=new ve(k.type,k.data),this._cache.set(v,{item:S}),J.abrupt("return",S);case 20:case"end":return J.stop()}},p,this,[[5,11]])}));function w(p,h){return x.apply(this,arguments)}return w}()}]),C}();function wt(C,x){var w=typeof Symbol<"u"&&C[Symbol.iterator]||C["@@iterator"];if(!w){if(Array.isArray(C)||(w=Nr(C))||x){w&&(C=w);var p=0,h=function(){};return{s:h,n:function(){return p>=C.length?{done:!0}:{done:!1,value:C[p++]}},e:function(k){throw k},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1319
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Nr(C,x){if(C){if(typeof C=="string")return Yt(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Yt(C,x)}}function Yt(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}var zr=ye.default(function C(x){ke.default(this,C),H.default(this,"type","email"),this.messageSid=x.message_sid,this.level=x.level,this.name=x.name,this.address=x.address}),Jr=ye.default(function C(x){ke.default(this,C),this.type=x.type,this.messageSid=x.message_sid,this.rawData=JSON.stringify(x)}),on=function(){function C(x,w){ke.default(this,C),this._services=x,this._configuration=w,this._cache=new F({maxSize:w.messageRecipientsCacheCapacity})}return ye.default(C,[{key:"getRecipientsFromMessage",value:function(){var x=re.default(M.default.mark(function p(h,_){var v=this,g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(g="".concat(h,",").concat(_),y=this._cache.get(g),!y){le.next=4;break}return le.abrupt("return",y.item);case 4:return k=new W(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("MessageSid",_).build(),le.next=7,this._services.commandExecutor.fetchResource(k);case 7:return S=le.sent,Y=S.message_recipients.map(function(ge){return v._wrapResponse(ge)}),Y.length>0&&this._cache.set(g,{item:Y}),le.abrupt("return",Y);case 11:case"end":return le.stop()}},p,this)}));function w(p,h){return x.apply(this,arguments)}return w}()},{key:"getRecipientsFromConversation",value:function(){var x=re.default(M.default.mark(function p(h,_){var v,g,y=this,k,S,Y,J,le,ge,vt,Et,Ht,Qt;return M.default.wrap(function(mr){for(;;)switch(mr.prev=mr.next){case 0:return k=new W(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("PageToken",(v=_==null?void 0:_.pageToken)!==null&&v!==void 0?v:void 0).arg("PageSize",(g=_==null?void 0:_.pageSize)!==null&&g!==void 0?g:void 0).build(),mr.next=3,this._services.commandExecutor.fetchResource(k);case 3:S=mr.sent,Y=S.message_recipients.map(function(Gt){return y._wrapResponse(Gt)}),J=wt(Y);try{for(J.s();!(le=J.n()).done;)Et=le.value,Ht="".concat(h,",").concat(Et.messageSid),Qt=(ge=(vt=this._cache.get(Ht))===null||vt===void 0?void 0:vt.item)!==null&&ge!==void 0?ge:[],this._cache.set(Ht,{item:[].concat(rt.default(Qt),[Et])})}catch(Gt){J.e(Gt)}finally{J.f()}return mr.abrupt("return",new ht(Y,function(Gt,yi){return y.getRecipientsFromConversation(h,{pageToken:Gt,pageSize:yi})},S.meta.previous_token,S.meta.next_token));case 8:case"end":return mr.stop()}},p,this)}));function w(p,h){return x.apply(this,arguments)}return w}()},{key:"_wrapResponse",value:function(w){switch(w.type){case"email":return new zr(w);default:return new Jr(w)}}}]),C}(),Nt;function Sn(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function $n(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?Sn(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):Sn(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function pn(C){var x=Wn();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Wn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Zt,va=ye.default(function C(){ke.default(this,C)});t.Client=Zt=(Nt=function(C){q.default(w,C);var x=pn(w);function w(p){var h,_,v,g,y,k,S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ke.default(this,w),k=x.call(this),H.default(oe.default(k),"version",$),H.default(oe.default(k),"connectionState","unknown"),H.default(oe.default(k),"parsePushNotification",Zt.parsePushNotification),k._fpaToken=p??"",k._options=S??{},!k._options.disableDeepClone){var Y=$n($n({},k._options),{},{transport:void 0,twilsockClient:void 0});Y=fr(Y),Y.transport=k._options.transport,Y.twilsockClient=k._options.twilsockClient,k._options=Y}k._options.logLevel=(h=k._options.logLevel)!==null&&h!==void 0?h:"silent",Zt._logger.setLevel(k._options.logLevel);var J=k._options.productId="ip_messaging";if(k._options.clientMetadata=k._options.clientMetadata||{},k._options.clientMetadata.hasOwnProperty("type")||(k._options.clientMetadata.type="conversations"),k._options.clientMetadata.hasOwnProperty("sdk")||(k._options.clientMetadata.sdk="JS",k._options.clientMetadata.sdkv=$),k._options.Sync=k._options.Sync||{},typeof k._options.Sync.enableSessionStorage>"u"&&(k._options.Sync.enableSessionStorage=!0),k._options.region&&(k._options.Sync.region=k._options.region),!p)throw new Error("A valid Twilio token should be provided");k._services=new va,k._myself=new Re("","",null,k._services);var le=!k._options.twilsockClient;if(!k._options.initRegistrations){var ge=new Ie.InitRegistration(J);Zt.populateInitRegistrations(ge),k._options.initRegistrations=[ge]}k._services.twilsockClient=k._options.twilsockClient=(_=k._options.twilsockClient)!==null&&_!==void 0?_:new Ie.TwilsockClient(p,J,k._options),k._services.twilsockClient.on(Zt.tokenAboutToExpire,function(){return k.emit(Zt.tokenAboutToExpire)}),k._services.twilsockClient.on(Zt.tokenExpired,function(){return k.emit(Zt.tokenExpired)}),k._services.twilsockClient.on(Zt.connectionError,function(mr){return k.emit(Zt.connectionError,mr)}),k._services.twilsockClient.on("stateChanged",function(mr){Zt._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(mr)),mr!==k.connectionState&&(k.connectionState=mr,k.emit(Zt.connectionStateChanged,k.connectionState))}),k._services.transport=k._options.transport=(v=k._options.transport)!==null&&v!==void 0?v:k._options.twilsockClient,k._services.notificationClient=k._options.notificationsClient=(g=k._options.notificationsClient)!==null&&g!==void 0?g:new Be.Notifications(p,k._options),k._services.syncClient=k._options.syncClient=(y=k._options.syncClient)!==null&&y!==void 0?y:new Oe.SyncClient(p,k._options);var vt=(S==null?void 0:S.Chat)||(S==null?void 0:S.IPMessaging)||S||{},Et=vt.region||(S==null?void 0:S.region),Ht=vt.apiUri||vt.typingUri||"https://aim.".concat(Et||"us1",".twilio.com");k._services.commandExecutor=new vn(Ht,{transport:k._options.transport},J),k._services.contentClient=new Fi(k._services);var Qt=function(Gt){k._rejectEnsureReady(Gt),k.emit(Zt.stateChanged,"failed"),k.emit(Zt.initFailed,{error:Gt})},_r=function(){Qt({terminal:!0,message:"Twilsock has disconnected."}),k._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1)};return k._services.twilsockClient.once("connectionError",Qt),k._services.twilsockClient.once("disconnected",_r),k._services.twilsockClient.once("connected",re.default(M.default.mark(function mr(){var Gt,yi;return M.default.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:return Zt._logger.debug("ConversationsClient started INITIALIZING"),k._services.twilsockClient.off("connectionError",Qt),k._services.twilsockClient.off("disconnected",_r),Lt.prev=3,Gt="conversations.client.startup",k._services.twilsockClient.addPartialTelemetryEvent(new Ie.TelemetryEventDescription(Gt,"Conversations client startup",new Date),Gt,Ie.TelemetryPoint.Start),Lt.next=8,k._initialize();case 8:k._services.twilsockClient.addPartialTelemetryEvent(new Ie.TelemetryEventDescription("","",new Date),Gt,Ie.TelemetryPoint.End),Lt.next=17;break;case 11:Lt.prev=11,Lt.t0=Lt.catch(3),yi={terminal:!0,message:Lt.t0.message},k._rejectEnsureReady(yi),k.emit(Zt.stateChanged,"failed"),k.emit(Zt.initFailed,{error:yi});case 17:case"end":return Lt.stop()}},mr,null,[[3,11]])}))),k._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1),le&&k._services.twilsockClient.connect(),k}return ye.default(w,[{key:"user",get:function(){return this._myself}},{key:"reachabilityEnabled",get:function(){if(!this._configuration)throw new Error("Reachability information could not yet be accessed as the client has not yet been initialized. Subscribe to the 'stateChanged' event to properly react to the client initialization.");return this._configuration.reachabilityEnabled}},{key:"token",get:function(){return this._fpaToken}},{key:"shutdown",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateToken",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:if(Zt._logger.info("updateToken"),this._fpaToken!==v){y.next=5;break}return y.abrupt("return",this);case 5:return y.next=7,this._services.twilsockClient.updateToken(v);case 7:return y.next=9,this._services.notificationClient.updateToken(v);case 9:return y.next=11,this._services.mcsClient.updateToken(v);case 11:return this._fpaToken=v,y.abrupt("return",this);case 13:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getConversationBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return k.next=6,this._conversationsEntity.getConversation(v);case 6:if(g=k.sent,g){k.next=12;break}return k.next=10,this.peekConversationBySid(v);case 10:g=k.sent,g&&V.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(g){k.next=14;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 14:return k.abrupt("return",g);case 15:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"peekConversationBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.peekConversation(v);case 4:if(g=k.sent,g){k.next=7;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 7:return k.abrupt("return",g);case 8:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getConversationByUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return k.next=6,this._conversationsEntity.getConversationByUniqueName(v);case 6:if(g=k.sent,g){k.next=9;break}throw new Error("Conversation with unique name ".concat(v," was not found."));case 9:return k.abrupt("return",g);case 10:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getSubscribedConversations",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._conversationsPromise.then(function(y){return y.getConversations()}));case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"createConversation",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return v=v||{},y.abrupt("return",this._conversationsPromise.then(function(k){return k.addConversation(v)}));case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"setPushRegistrationId",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(v),this._services.notificationClient.setPushRegistrationId(v,g),k.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"unsetPushRegistrationId",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(v),y.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"removePushRegistrations",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.notificationClient.removeRegistrations(v,g);case 2:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"handlePushNotification",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:Zt._logger.debug("handlePushNotification, notificationPayload=",v),this.emit("pushNotification",Zt.parsePushNotification(v));case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getUser",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.abrupt("return",this._services.users.getUser(v));case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getSubscribedUsers",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var _=this;return new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(!(!_._services.mcsClient||!h)){ge.next=3;break}return k(new Error("Media Content Service is unavailable")),ge.abrupt("return");case 3:return Y=_._services.mcsClient.mediaSetGetContentUrls(h),S(function(){Y.cancel()}),ge.prev=5,ge.next=8,Y;case 8:J=ge.sent,y(J),ge.next=15;break;case 12:ge.prev=12,ge.t0=ge.catch(5),k(ge.t0);case 15:case"end":return ge.stop()}},g,null,[[5,12]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(h){var _=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(_)}},{key:"getContentTemplates",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.contentClient.getContentTemplates();case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_initialize",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return g=k.sent,this._configuration=new dr(this._options,g,Zt._logger),this._services.channelMetadataClient=new We(this._services,this._configuration),this._services.messageRecipientsClient=new on(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new E(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new ae(this._configuration,this._services),this._services.users=new D(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",function(S){v.emit("userSubscribed",S)}),this._services.users.on("userUpdated",function(S){return v.emit("userUpdated",S)}),this._services.users.on("userUnsubscribed",function(S){v.emit("userUnsubscribed",S)}),this._conversationsEntity=new Br(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",function(S){v.emit("conversationAdded",S)}),this._conversationsEntity.on("conversationRemoved",function(S){v.emit("conversationRemoved",S)}),this._conversationsEntity.on("conversationJoined",function(S){v.emit("conversationJoined",S)}),this._conversationsEntity.on("conversationLeft",function(S){v.emit("conversationLeft",S)}),this._conversationsEntity.on("conversationUpdated",function(S){return v.emit("conversationUpdated",S)}),this._conversationsEntity.on("participantJoined",function(S){v.emit("participantJoined",S)}),this._conversationsEntity.on("participantLeft",function(S){v.emit("participantLeft",S)}),this._conversationsEntity.on("participantUpdated",function(S){return v.emit("participantUpdated",S)}),this._conversationsEntity.on("messageAdded",function(S){return v.emit("messageAdded",S)}),this._conversationsEntity.on("messageUpdated",function(S){return v.emit("messageUpdated",S)}),this._conversationsEntity.on("messageRemoved",function(S){return v.emit("messageRemoved",S)}),this._conversationsEntity.on("typingStarted",function(S){return v.emit("typingStarted",S)}),this._conversationsEntity.on("typingEnded",function(S){return v.emit("typingEnded",S)}),this._conversationsPromise=this._conversationsEntity.fetchConversations().then(function(){return v._conversationsEntity}).catch(function(S){throw console.error("Failed to fetch conversations _conversationsPromise -> client.ts",S),S}),k.next=30,this._services.users.myself._ensureFetched();case 30:Zt._supportedPushChannels.forEach(function(S){return v._subscribeToPushNotifications(S)}),this._services.typingIndicator.initialize(),this._services.mcsClient=new ze.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,$n($n({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(Zt.stateChanged,"initialized"),this.emit(Zt.initialized);case 36:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeToPushNotifications",value:function(h){var _=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(v){_._services.notificationClient.subscribe(h,v)})}},{key:"_unsubscribeFromPushNotifications",value:function(h){var _=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(v){_._services.notificationClient.unsubscribe(h,v)})}},{key:"_initializeEnsureReady",value:function(h){var _=this;this._ensureReady=new Promise(function(v,g){_._resolveEnsureReady=v,_._rejectEnsureReady=g}).catch(function(v){if(h)throw v})}}],[{key:"create",value:function(){var p=re.default(M.default.mark(function _(v,g){var y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!(g!=null&&g.twilsockClient)){S.next=2;break}throw new Error("Obsolete usage of ConversationsClient.create() factory method: if you pass twilsock from the outside then you must use ConversationsClient constructor and be prepared to work with uninitialized client.");case 2:return y=new Zt(v,g),S.next=5,y._ensureReady;case 5:return S.abrupt("return",y);case 6:case"end":return S.stop()}},_)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"parsePushNotification",value:function(h){if(Zt._logger.debug("parsePushNotification, notificationPayload=",h),typeof h.aps<"u"){if(!h.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var _=Zt._parsePushNotificationChatData(h),v=h.aps,g,y=null;if(typeof v.alert=="string")g=v.alert||null;else{var k,S;g=((k=v.alert)===null||k===void 0?void 0:k.body)||null,y=((S=v.alert)===null||S===void 0?void 0:S.title)||null}return new T({title:y,body:g,sound:v.sound||null,badge:v.badge||null,action:v.category||null,type:h.twi_message_type,data:_})}if(typeof h.data<"u"){var Y=h.data;if(!Y.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var J=Zt._parsePushNotificationChatData(h.data);return new T({title:Y.twi_title||null,body:Y.twi_body||null,sound:Y.twi_sound||null,badge:null,action:Y.twi_action||null,type:Y.twi_message_type,data:J})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(h){var _={};for(var v in Zt._supportedPushDataFields){var g=h[v];if(!(typeof g>"u"||g===null)){if(v==="message_index"||v==="media_count"){var y=Wt(g);y!==null&&(_[Zt._supportedPushDataFields[v]]=y);continue}if(v==="media"){if(typeof g=="string")try{_[Zt._supportedPushDataFields[v]]=JSON.parse(g)}catch{Zt._logger.debug("Media message notification parsing error")}continue}_[Zt._supportedPushDataFields[v]]=g}}return _}},{key:"populateInitRegistrations",value:function(h){h.populateInitRegistrations([me.TYPING_INDICATOR]),Oe.SyncClient.populateInitRegistrations(h)}}]),w}(N.ReplayEventEmitter),H.default(Nt,"conversationAdded","conversationAdded"),H.default(Nt,"conversationJoined","conversationJoined"),H.default(Nt,"conversationLeft","conversationLeft"),H.default(Nt,"conversationRemoved","conversationRemoved"),H.default(Nt,"conversationUpdated","conversationUpdated"),H.default(Nt,"participantJoined","participantJoined"),H.default(Nt,"participantLeft","participantLeft"),H.default(Nt,"participantUpdated","participantUpdated"),H.default(Nt,"messageAdded","messageAdded"),H.default(Nt,"messageRemoved","messageRemoved"),H.default(Nt,"messageUpdated","messageUpdated"),H.default(Nt,"tokenAboutToExpire","tokenAboutToExpire"),H.default(Nt,"tokenExpired","tokenExpired"),H.default(Nt,"typingEnded","typingEnded"),H.default(Nt,"typingStarted","typingStarted"),H.default(Nt,"pushNotification","pushNotification"),H.default(Nt,"userSubscribed","userSubscribed"),H.default(Nt,"userUnsubscribed","userUnsubscribed"),H.default(Nt,"userUpdated","userUpdated"),H.default(Nt,"stateChanged","stateChanged"),H.default(Nt,"initialized","initialized"),H.default(Nt,"initFailed","initFailed"),H.default(Nt,"connectionStateChanged","connectionStateChanged"),H.default(Nt,"connectionError","connectionError"),H.default(Nt,"version",$),H.default(Nt,"_logger",Jt.scope("Client")),H.default(Nt,"_supportedPushChannels",["fcm","apn"]),H.default(Nt,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),Nt),Fe([V.deprecated("token"),be("design:type",String),be("design:paramtypes",[])],t.Client.prototype,"token",null),Fe([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"updateToken",null),Fe([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationBySid",null),Fe([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"peekConversationBySid",null),Fe([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationByUniqueName",null),Fe([b.validateTypesAsync(["undefined",b.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"createConversation",null),Fe([b.validateTypesAsync(b.literal("fcm","apn"),"string"),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"setPushRegistrationId",null),Fe([b.validateTypesAsync(b.literal("fcm","apn")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"unsetPushRegistrationId",null),Fe([b.validateTypesAsync(b.literal("fcm","apn"),b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"removePushRegistrations",null),Fe([b.validateTypesAsync(b.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"handlePushNotification",null),Fe([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getUser",null),Fe([b.validateTypesAsync(b.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),Fe([b.validateTypesAsync(b.nonEmptyArray("media",dt)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMedia",null),Fe([V.deprecated("Client.create()","new Client()"),b.validateTypesAsync("string",["undefined",b.pureObject]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],t.Client,"create",null),Fe([b.validateTypes(b.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",T)],t.Client,"parsePushNotification",null),t.Client=Zt=Fe([b.validateConstructorTypes(b.nonEmptyString,[b.pureObject,"undefined"]),be("design:paramtypes",[String,Object])],t.Client),Object.defineProperty(t,"CancellablePromise",{enumerable:!0,get:function(){return ze.CancellablePromise}}),t.AggregatedDeliveryReceipt=lt,t.ChannelMetadata=ve,t.ContentTemplate=jt,t.ContentTemplateVariable=It,t.Conversation=I,t.DetailedDeliveryReceipt=Rt,t.EmailRecipientDescriptor=zr,t.Media=dt,t.Message=en,t.MessageBuilder=Dr,t.NotificationTypes=me,t.Participant=G,t.PushNotification=T,t.RestPaginator=ht,t.UnknownRecipientDescriptor=Jr,t.UnsentMessage=Pn,t.User=Re})(rk);const Bie=pl({__proto__:null},[rk]);Vo.AnyChatWidget=HL,Object.defineProperty(Vo,Symbol.toStringTag,{value:"Module"})});
1319
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var _=!0,v=!1,g;return{s:function(){w=w.call(C)},n:function(){var k=w.next();return _=k.done,k},e:function(k){v=!0,g=k},f:function(){try{!_&&w.return!=null&&w.return()}finally{if(v)throw g}}}}function Nr(C,x){if(C){if(typeof C=="string")return Yt(C,x);var w=Object.prototype.toString.call(C).slice(8,-1);if(w==="Object"&&C.constructor&&(w=C.constructor.name),w==="Map"||w==="Set")return Array.from(C);if(w==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(w))return Yt(C,x)}}function Yt(C,x){(x==null||x>C.length)&&(x=C.length);for(var w=0,p=new Array(x);w<x;w++)p[w]=C[w];return p}var zr=ye.default(function C(x){ke.default(this,C),H.default(this,"type","email"),this.messageSid=x.message_sid,this.level=x.level,this.name=x.name,this.address=x.address}),Jr=ye.default(function C(x){ke.default(this,C),this.type=x.type,this.messageSid=x.message_sid,this.rawData=JSON.stringify(x)}),on=function(){function C(x,w){ke.default(this,C),this._services=x,this._configuration=w,this._cache=new F({maxSize:w.messageRecipientsCacheCapacity})}return ye.default(C,[{key:"getRecipientsFromMessage",value:function(){var x=re.default(M.default.mark(function p(h,_){var v=this,g,y,k,S,Y;return M.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(g="".concat(h,",").concat(_),y=this._cache.get(g),!y){le.next=4;break}return le.abrupt("return",y.item);case 4:return k=new W(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("MessageSid",_).build(),le.next=7,this._services.commandExecutor.fetchResource(k);case 7:return S=le.sent,Y=S.message_recipients.map(function(ge){return v._wrapResponse(ge)}),Y.length>0&&this._cache.set(g,{item:Y}),le.abrupt("return",Y);case 11:case"end":return le.stop()}},p,this)}));function w(p,h){return x.apply(this,arguments)}return w}()},{key:"getRecipientsFromConversation",value:function(){var x=re.default(M.default.mark(function p(h,_){var v,g,y=this,k,S,Y,J,le,ge,vt,Et,Ht,Qt;return M.default.wrap(function(mr){for(;;)switch(mr.prev=mr.next){case 0:return k=new W(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("PageToken",(v=_==null?void 0:_.pageToken)!==null&&v!==void 0?v:void 0).arg("PageSize",(g=_==null?void 0:_.pageSize)!==null&&g!==void 0?g:void 0).build(),mr.next=3,this._services.commandExecutor.fetchResource(k);case 3:S=mr.sent,Y=S.message_recipients.map(function(Gt){return y._wrapResponse(Gt)}),J=wt(Y);try{for(J.s();!(le=J.n()).done;)Et=le.value,Ht="".concat(h,",").concat(Et.messageSid),Qt=(ge=(vt=this._cache.get(Ht))===null||vt===void 0?void 0:vt.item)!==null&&ge!==void 0?ge:[],this._cache.set(Ht,{item:[].concat(rt.default(Qt),[Et])})}catch(Gt){J.e(Gt)}finally{J.f()}return mr.abrupt("return",new ht(Y,function(Gt,yi){return y.getRecipientsFromConversation(h,{pageToken:Gt,pageSize:yi})},S.meta.previous_token,S.meta.next_token));case 8:case"end":return mr.stop()}},p,this)}));function w(p,h){return x.apply(this,arguments)}return w}()},{key:"_wrapResponse",value:function(w){switch(w.type){case"email":return new zr(w);default:return new Jr(w)}}}]),C}(),Nt;function Sn(C,x){var w=Object.keys(C);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(C);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(C,h).enumerable})),w.push.apply(w,p)}return w}function $n(C){for(var x=1;x<arguments.length;x++){var w=arguments[x]!=null?arguments[x]:{};x%2?Sn(Object(w),!0).forEach(function(p){H.default(C,p,w[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(w)):Sn(Object(w)).forEach(function(p){Object.defineProperty(C,p,Object.getOwnPropertyDescriptor(w,p))})}return C}function pn(C){var x=Wn();return function(){var p=Se.default(C),h;if(x){var _=Se.default(this).constructor;h=Reflect.construct(p,arguments,_)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Wn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Zt,va=ye.default(function C(){ke.default(this,C)});t.Client=Zt=(Nt=function(C){q.default(w,C);var x=pn(w);function w(p){var h,_,v,g,y,k,S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ke.default(this,w),k=x.call(this),H.default(oe.default(k),"version",$),H.default(oe.default(k),"connectionState","unknown"),H.default(oe.default(k),"parsePushNotification",Zt.parsePushNotification),k._fpaToken=p??"",k._options=S??{},!k._options.disableDeepClone){var Y=$n($n({},k._options),{},{transport:void 0,twilsockClient:void 0});Y=fr(Y),Y.transport=k._options.transport,Y.twilsockClient=k._options.twilsockClient,k._options=Y}k._options.logLevel=(h=k._options.logLevel)!==null&&h!==void 0?h:"silent",Zt._logger.setLevel(k._options.logLevel);var J=k._options.productId="ip_messaging";if(k._options.clientMetadata=k._options.clientMetadata||{},k._options.clientMetadata.hasOwnProperty("type")||(k._options.clientMetadata.type="conversations"),k._options.clientMetadata.hasOwnProperty("sdk")||(k._options.clientMetadata.sdk="JS",k._options.clientMetadata.sdkv=$),k._options.Sync=k._options.Sync||{},typeof k._options.Sync.enableSessionStorage>"u"&&(k._options.Sync.enableSessionStorage=!0),k._options.region&&(k._options.Sync.region=k._options.region),!p)throw new Error("A valid Twilio token should be provided");k._services=new va,k._myself=new Re("","",null,k._services);var le=!k._options.twilsockClient;if(!k._options.initRegistrations){var ge=new Ie.InitRegistration(J);Zt.populateInitRegistrations(ge),k._options.initRegistrations=[ge]}k._services.twilsockClient=k._options.twilsockClient=(_=k._options.twilsockClient)!==null&&_!==void 0?_:new Ie.TwilsockClient(p,J,k._options),k._services.twilsockClient.on(Zt.tokenAboutToExpire,function(){return k.emit(Zt.tokenAboutToExpire)}),k._services.twilsockClient.on(Zt.tokenExpired,function(){return k.emit(Zt.tokenExpired)}),k._services.twilsockClient.on(Zt.connectionError,function(mr){return k.emit(Zt.connectionError,mr)}),k._services.twilsockClient.on("stateChanged",function(mr){Zt._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(mr)),mr!==k.connectionState&&(k.connectionState=mr,k.emit(Zt.connectionStateChanged,k.connectionState))}),k._services.transport=k._options.transport=(v=k._options.transport)!==null&&v!==void 0?v:k._options.twilsockClient,k._services.notificationClient=k._options.notificationsClient=(g=k._options.notificationsClient)!==null&&g!==void 0?g:new Fe.Notifications(p,k._options),k._services.syncClient=k._options.syncClient=(y=k._options.syncClient)!==null&&y!==void 0?y:new Oe.SyncClient(p,k._options);var vt=(S==null?void 0:S.Chat)||(S==null?void 0:S.IPMessaging)||S||{},Et=vt.region||(S==null?void 0:S.region),Ht=vt.apiUri||vt.typingUri||"https://aim.".concat(Et||"us1",".twilio.com");k._services.commandExecutor=new vn(Ht,{transport:k._options.transport},J),k._services.contentClient=new Fi(k._services);var Qt=function(Gt){k._rejectEnsureReady(Gt),k.emit(Zt.stateChanged,"failed"),k.emit(Zt.initFailed,{error:Gt})},_r=function(){Qt({terminal:!0,message:"Twilsock has disconnected."}),k._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1)};return k._services.twilsockClient.once("connectionError",Qt),k._services.twilsockClient.once("disconnected",_r),k._services.twilsockClient.once("connected",re.default(M.default.mark(function mr(){var Gt,yi;return M.default.wrap(function(Lt){for(;;)switch(Lt.prev=Lt.next){case 0:return Zt._logger.debug("ConversationsClient started INITIALIZING"),k._services.twilsockClient.off("connectionError",Qt),k._services.twilsockClient.off("disconnected",_r),Lt.prev=3,Gt="conversations.client.startup",k._services.twilsockClient.addPartialTelemetryEvent(new Ie.TelemetryEventDescription(Gt,"Conversations client startup",new Date),Gt,Ie.TelemetryPoint.Start),Lt.next=8,k._initialize();case 8:k._services.twilsockClient.addPartialTelemetryEvent(new Ie.TelemetryEventDescription("","",new Date),Gt,Ie.TelemetryPoint.End),Lt.next=17;break;case 11:Lt.prev=11,Lt.t0=Lt.catch(3),yi={terminal:!0,message:Lt.t0.message},k._rejectEnsureReady(yi),k.emit(Zt.stateChanged,"failed"),k.emit(Zt.initFailed,{error:yi});case 17:case"end":return Lt.stop()}},mr,null,[[3,11]])}))),k._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1),le&&k._services.twilsockClient.connect(),k}return ye.default(w,[{key:"user",get:function(){return this._myself}},{key:"reachabilityEnabled",get:function(){if(!this._configuration)throw new Error("Reachability information could not yet be accessed as the client has not yet been initialized. Subscribe to the 'stateChanged' event to properly react to the client initialization.");return this._configuration.reachabilityEnabled}},{key:"token",get:function(){return this._fpaToken}},{key:"shutdown",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateToken",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:if(Zt._logger.info("updateToken"),this._fpaToken!==v){y.next=5;break}return y.abrupt("return",this);case 5:return y.next=7,this._services.twilsockClient.updateToken(v);case 7:return y.next=9,this._services.notificationClient.updateToken(v);case 9:return y.next=11,this._services.mcsClient.updateToken(v);case 11:return this._fpaToken=v,y.abrupt("return",this);case 13:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getConversationBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return k.next=6,this._conversationsEntity.getConversation(v);case 6:if(g=k.sent,g){k.next=12;break}return k.next=10,this.peekConversationBySid(v);case 10:g=k.sent,g&&V.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(g){k.next=14;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 14:return k.abrupt("return",g);case 15:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"peekConversationBySid",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.peekConversation(v);case 4:if(g=k.sent,g){k.next=7;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 7:return k.abrupt("return",g);case 8:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getConversationByUniqueName",value:function(){var p=re.default(M.default.mark(function _(v){var g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return k.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return k.next=6,this._conversationsEntity.getConversationByUniqueName(v);case 6:if(g=k.sent,g){k.next=9;break}throw new Error("Conversation with unique name ".concat(v," was not found."));case 9:return k.abrupt("return",g);case 10:case"end":return k.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getSubscribedConversations",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._conversationsPromise.then(function(y){return y.getConversations()}));case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"createConversation",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return v=v||{},y.abrupt("return",this._conversationsPromise.then(function(k){return k.addConversation(v)}));case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"setPushRegistrationId",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(v),this._services.notificationClient.setPushRegistrationId(v,g),k.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"unsetPushRegistrationId",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(v),y.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"removePushRegistrations",value:function(){var p=re.default(M.default.mark(function _(v,g){return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.notificationClient.removeRegistrations(v,g);case 2:case"end":return k.stop()}},_,this)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"handlePushNotification",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:Zt._logger.debug("handlePushNotification, notificationPayload=",v),this.emit("pushNotification",Zt.parsePushNotification(v));case 4:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getUser",value:function(){var p=re.default(M.default.mark(function _(v){return M.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.abrupt("return",this._services.users.getUser(v));case 3:case"end":return y.stop()}},_,this)}));function h(_){return p.apply(this,arguments)}return h}()},{key:"getSubscribedUsers",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var _=this;return new ze.CancellablePromise(function(){var v=re.default(M.default.mark(function g(y,k,S){var Y,J;return M.default.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(!(!_._services.mcsClient||!h)){ge.next=3;break}return k(new Error("Media Content Service is unavailable")),ge.abrupt("return");case 3:return Y=_._services.mcsClient.mediaSetGetContentUrls(h),S(function(){Y.cancel()}),ge.prev=5,ge.next=8,Y;case 8:J=ge.sent,y(J),ge.next=15;break;case 12:ge.prev=12,ge.t0=ge.catch(5),k(ge.t0);case 15:case"end":return ge.stop()}},g,null,[[5,12]])}));return function(g,y,k){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(h){var _=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(_)}},{key:"getContentTemplates",value:function(){var p=re.default(M.default.mark(function _(){return M.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.contentClient.getContentTemplates();case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_initialize",value:function(){var p=re.default(M.default.mark(function _(){var v=this,g;return M.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return g=k.sent,this._configuration=new dr(this._options,g,Zt._logger),this._services.channelMetadataClient=new We(this._services,this._configuration),this._services.messageRecipientsClient=new on(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new E(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new ae(this._configuration,this._services),this._services.users=new D(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",function(S){v.emit("userSubscribed",S)}),this._services.users.on("userUpdated",function(S){return v.emit("userUpdated",S)}),this._services.users.on("userUnsubscribed",function(S){v.emit("userUnsubscribed",S)}),this._conversationsEntity=new Br(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",function(S){v.emit("conversationAdded",S)}),this._conversationsEntity.on("conversationRemoved",function(S){v.emit("conversationRemoved",S)}),this._conversationsEntity.on("conversationJoined",function(S){v.emit("conversationJoined",S)}),this._conversationsEntity.on("conversationLeft",function(S){v.emit("conversationLeft",S)}),this._conversationsEntity.on("conversationUpdated",function(S){return v.emit("conversationUpdated",S)}),this._conversationsEntity.on("participantJoined",function(S){v.emit("participantJoined",S)}),this._conversationsEntity.on("participantLeft",function(S){v.emit("participantLeft",S)}),this._conversationsEntity.on("participantUpdated",function(S){return v.emit("participantUpdated",S)}),this._conversationsEntity.on("messageAdded",function(S){return v.emit("messageAdded",S)}),this._conversationsEntity.on("messageUpdated",function(S){return v.emit("messageUpdated",S)}),this._conversationsEntity.on("messageRemoved",function(S){return v.emit("messageRemoved",S)}),this._conversationsEntity.on("typingStarted",function(S){return v.emit("typingStarted",S)}),this._conversationsEntity.on("typingEnded",function(S){return v.emit("typingEnded",S)}),this._conversationsPromise=this._conversationsEntity.fetchConversations().then(function(){return v._conversationsEntity}).catch(function(S){throw console.error("Failed to fetch conversations _conversationsPromise -> client.ts",S),S}),k.next=30,this._services.users.myself._ensureFetched();case 30:Zt._supportedPushChannels.forEach(function(S){return v._subscribeToPushNotifications(S)}),this._services.typingIndicator.initialize(),this._services.mcsClient=new ze.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,$n($n({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(Zt.stateChanged,"initialized"),this.emit(Zt.initialized);case 36:case"end":return k.stop()}},_,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeToPushNotifications",value:function(h){var _=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(v){_._services.notificationClient.subscribe(h,v)})}},{key:"_unsubscribeFromPushNotifications",value:function(h){var _=this;[me.NEW_MESSAGE,me.ADDED_TO_CONVERSATION,me.REMOVED_FROM_CONVERSATION,me.TYPING_INDICATOR,me.CONSUMPTION_UPDATE].forEach(function(v){_._services.notificationClient.unsubscribe(h,v)})}},{key:"_initializeEnsureReady",value:function(h){var _=this;this._ensureReady=new Promise(function(v,g){_._resolveEnsureReady=v,_._rejectEnsureReady=g}).catch(function(v){if(h)throw v})}}],[{key:"create",value:function(){var p=re.default(M.default.mark(function _(v,g){var y;return M.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!(g!=null&&g.twilsockClient)){S.next=2;break}throw new Error("Obsolete usage of ConversationsClient.create() factory method: if you pass twilsock from the outside then you must use ConversationsClient constructor and be prepared to work with uninitialized client.");case 2:return y=new Zt(v,g),S.next=5,y._ensureReady;case 5:return S.abrupt("return",y);case 6:case"end":return S.stop()}},_)}));function h(_,v){return p.apply(this,arguments)}return h}()},{key:"parsePushNotification",value:function(h){if(Zt._logger.debug("parsePushNotification, notificationPayload=",h),typeof h.aps<"u"){if(!h.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var _=Zt._parsePushNotificationChatData(h),v=h.aps,g,y=null;if(typeof v.alert=="string")g=v.alert||null;else{var k,S;g=((k=v.alert)===null||k===void 0?void 0:k.body)||null,y=((S=v.alert)===null||S===void 0?void 0:S.title)||null}return new T({title:y,body:g,sound:v.sound||null,badge:v.badge||null,action:v.category||null,type:h.twi_message_type,data:_})}if(typeof h.data<"u"){var Y=h.data;if(!Y.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var J=Zt._parsePushNotificationChatData(h.data);return new T({title:Y.twi_title||null,body:Y.twi_body||null,sound:Y.twi_sound||null,badge:null,action:Y.twi_action||null,type:Y.twi_message_type,data:J})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(h){var _={};for(var v in Zt._supportedPushDataFields){var g=h[v];if(!(typeof g>"u"||g===null)){if(v==="message_index"||v==="media_count"){var y=Wt(g);y!==null&&(_[Zt._supportedPushDataFields[v]]=y);continue}if(v==="media"){if(typeof g=="string")try{_[Zt._supportedPushDataFields[v]]=JSON.parse(g)}catch{Zt._logger.debug("Media message notification parsing error")}continue}_[Zt._supportedPushDataFields[v]]=g}}return _}},{key:"populateInitRegistrations",value:function(h){h.populateInitRegistrations([me.TYPING_INDICATOR]),Oe.SyncClient.populateInitRegistrations(h)}}]),w}(N.ReplayEventEmitter),H.default(Nt,"conversationAdded","conversationAdded"),H.default(Nt,"conversationJoined","conversationJoined"),H.default(Nt,"conversationLeft","conversationLeft"),H.default(Nt,"conversationRemoved","conversationRemoved"),H.default(Nt,"conversationUpdated","conversationUpdated"),H.default(Nt,"participantJoined","participantJoined"),H.default(Nt,"participantLeft","participantLeft"),H.default(Nt,"participantUpdated","participantUpdated"),H.default(Nt,"messageAdded","messageAdded"),H.default(Nt,"messageRemoved","messageRemoved"),H.default(Nt,"messageUpdated","messageUpdated"),H.default(Nt,"tokenAboutToExpire","tokenAboutToExpire"),H.default(Nt,"tokenExpired","tokenExpired"),H.default(Nt,"typingEnded","typingEnded"),H.default(Nt,"typingStarted","typingStarted"),H.default(Nt,"pushNotification","pushNotification"),H.default(Nt,"userSubscribed","userSubscribed"),H.default(Nt,"userUnsubscribed","userUnsubscribed"),H.default(Nt,"userUpdated","userUpdated"),H.default(Nt,"stateChanged","stateChanged"),H.default(Nt,"initialized","initialized"),H.default(Nt,"initFailed","initFailed"),H.default(Nt,"connectionStateChanged","connectionStateChanged"),H.default(Nt,"connectionError","connectionError"),H.default(Nt,"version",$),H.default(Nt,"_logger",Jt.scope("Client")),H.default(Nt,"_supportedPushChannels",["fcm","apn"]),H.default(Nt,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),Nt),Be([V.deprecated("token"),be("design:type",String),be("design:paramtypes",[])],t.Client.prototype,"token",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"updateToken",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationBySid",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"peekConversationBySid",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationByUniqueName",null),Be([b.validateTypesAsync(["undefined",b.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"createConversation",null),Be([b.validateTypesAsync(b.literal("fcm","apn"),"string"),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"setPushRegistrationId",null),Be([b.validateTypesAsync(b.literal("fcm","apn")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"unsetPushRegistrationId",null),Be([b.validateTypesAsync(b.literal("fcm","apn"),b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"removePushRegistrations",null),Be([b.validateTypesAsync(b.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"handlePushNotification",null),Be([b.validateTypesAsync(b.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getUser",null),Be([b.validateTypesAsync(b.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),Be([b.validateTypesAsync(b.nonEmptyArray("media",dt)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMedia",null),Be([V.deprecated("Client.create()","new Client()"),b.validateTypesAsync("string",["undefined",b.pureObject]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],t.Client,"create",null),Be([b.validateTypes(b.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",T)],t.Client,"parsePushNotification",null),t.Client=Zt=Be([b.validateConstructorTypes(b.nonEmptyString,[b.pureObject,"undefined"]),be("design:paramtypes",[String,Object])],t.Client),Object.defineProperty(t,"CancellablePromise",{enumerable:!0,get:function(){return ze.CancellablePromise}}),t.AggregatedDeliveryReceipt=lt,t.ChannelMetadata=ve,t.ContentTemplate=jt,t.ContentTemplateVariable=It,t.Conversation=I,t.DetailedDeliveryReceipt=Rt,t.EmailRecipientDescriptor=zr,t.Media=dt,t.Message=en,t.MessageBuilder=Dr,t.NotificationTypes=me,t.Participant=G,t.PushNotification=T,t.RestPaginator=ht,t.UnknownRecipientDescriptor=Jr,t.UnsentMessage=Pn,t.User=Re})(rk);const Bie=pl({__proto__:null},[rk]);Vo.AnyChatWidget=HL,Object.defineProperty(Vo,Symbol.toStringTag,{value:"Module"})});