@twilio/conversations 2.7.0-rc.3 → 2.7.0

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.
@@ -126,5 +126,5 @@ This software includes platform.js under the following license.
126
126
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
127
127
 
128
128
  */
129
- this.Twilio=this.Twilio||{},this.Twilio.Conversations=function(e){"use strict";var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{};function r(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var i=function(e){return e&&e.Math==Math&&e},a=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof n&&n)||function(){return this}()||Function("return this")(),o={},s=function(e){try{return!!e()}catch(e){return!0}},u=!s((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),c={},l={}.propertyIsEnumerable,f=Object.getOwnPropertyDescriptor,d=f&&!l.call({1:2},1);c.f=d?function(e){var t=f(this,e);return!!t&&t.enumerable}:l;var p,h,v=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},y={}.toString,g=function(e){return y.call(e).slice(8,-1)},m=g,b="".split,w=s((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==m(e)?b.call(e,""):Object(e)}:Object,k=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},_=w,x=k,S=function(e){return _(x(e))},E=function(e){return"object"==typeof e?null!==e:"function"==typeof e},R=a,I=function(e){return"function"==typeof e?e:void 0},T=function(e,t){return arguments.length<2?I(R[e]):R[e]&&R[e][t]},C=T("navigator","userAgent")||"",O=a,P=C,A=O.process,j=O.Deno,M=A&&A.versions||j&&j.version,L=M&&M.v8;L?h=(p=L.split("."))[0]<4?1:p[0]+p[1]:P&&(!(p=P.match(/Edge\/(\d+)/))||p[1]>=74)&&(p=P.match(/Chrome\/(\d+)/))&&(h=p[1]);var U=h&&+h,N=U,D=s,F=!!Object.getOwnPropertySymbols&&!D((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&N&&N<41})),B=F&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,q=T,z=B?function(e){return"symbol"==typeof e}:function(e){var t=q("Symbol");return"function"==typeof t&&Object(e)instanceof t},W=E,K={exports:{}},V=a,$=function(e,t){try{Object.defineProperty(V,e,{value:t,configurable:!0,writable:!0})}catch(n){V[e]=t}return t},G=$,J="__core-js_shared__",H=a[J]||G(J,{}),Y=H;(K.exports=function(e,t){return Y[e]||(Y[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.17.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"});var Q=k,X=function(e){return Object(Q(e))},Z=X,ee={}.hasOwnProperty,te=Object.hasOwn||function(e,t){return ee.call(Z(e),t)},ne=0,re=Math.random(),ie=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++ne+re).toString(36)},ae=a,oe=K.exports,se=te,ue=ie,ce=F,le=B,fe=oe("wks"),de=ae.Symbol,pe=le?de:de&&de.withoutSetter||ue,he=function(e){return se(fe,e)&&(ce||"string"==typeof fe[e])||(ce&&se(de,e)?fe[e]=de[e]:fe[e]=pe("Symbol."+e)),fe[e]},ve=E,ye=z,ge=function(e,t){var n,r;if("string"===t&&"function"==typeof(n=e.toString)&&!W(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!W(r=n.call(e)))return r;if("string"!==t&&"function"==typeof(n=e.toString)&&!W(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},me=he("toPrimitive"),be=function(e,t){if(!ve(e)||ye(e))return e;var n,r=e[me];if(void 0!==r){if(void 0===t&&(t="default"),n=r.call(e,t),!ve(n)||ye(n))return n;throw TypeError("Can't convert object to primitive value")}return void 0===t&&(t="number"),ge(e,t)},we=be,ke=z,_e=function(e){var t=we(e,"string");return ke(t)?t:String(t)},xe=E,Se=a.document,Ee=xe(Se)&&xe(Se.createElement),Re=function(e){return Ee?Se.createElement(e):{}},Ie=Re,Te=!u&&!s((function(){return 7!=Object.defineProperty(Ie("div"),"a",{get:function(){return 7}}).a})),Ce=u,Oe=c,Pe=v,Ae=S,je=_e,Me=te,Le=Te,Ue=Object.getOwnPropertyDescriptor;o.f=Ce?Ue:function(e,t){if(e=Ae(e),t=je(t),Le)try{return Ue(e,t)}catch(e){}if(Me(e,t))return Pe(!Oe.f.call(e,t),e[t])};var Ne={},De=E,Fe=function(e){if(!De(e))throw TypeError(String(e)+" is not an object");return e},Be=u,qe=Te,ze=Fe,We=_e,Ke=Object.defineProperty;Ne.f=Be?Ke:function(e,t,n){if(ze(e),t=We(t),ze(n),qe)try{return Ke(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Ve=Ne,$e=v,Ge=u?function(e,t,n){return Ve.f(e,t,$e(1,n))}:function(e,t,n){return e[t]=n,e},Je={exports:{}},He=H,Ye=Function.toString;"function"!=typeof He.inspectSource&&(He.inspectSource=function(e){return Ye.call(e)});var Qe,Xe,Ze,et=He.inspectSource,tt=et,nt=a.WeakMap,rt="function"==typeof nt&&/native code/.test(tt(nt)),it=K.exports,at=ie,ot=it("keys"),st=function(e){return ot[e]||(ot[e]=at(e))},ut={},ct=rt,lt=E,ft=Ge,dt=te,pt=H,ht=st,vt=ut,yt="Object already initialized",gt=a.WeakMap;if(ct||pt.state){var mt=pt.state||(pt.state=new gt),bt=mt.get,wt=mt.has,kt=mt.set;Qe=function(e,t){if(wt.call(mt,e))throw new TypeError(yt);return t.facade=e,kt.call(mt,e,t),t},Xe=function(e){return bt.call(mt,e)||{}},Ze=function(e){return wt.call(mt,e)}}else{var _t=ht("state");vt[_t]=!0,Qe=function(e,t){if(dt(e,_t))throw new TypeError(yt);return t.facade=e,ft(e,_t,t),t},Xe=function(e){return dt(e,_t)?e[_t]:{}},Ze=function(e){return dt(e,_t)}}var xt={set:Qe,get:Xe,has:Ze,enforce:function(e){return Ze(e)?Xe(e):Qe(e,{})},getterFor:function(e){return function(t){var n;if(!lt(t)||(n=Xe(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},St=a,Et=Ge,Rt=te,It=$,Tt=et,Ct=xt.get,Ot=xt.enforce,Pt=String(String).split("String");(Je.exports=function(e,t,n,r){var i,a=!!r&&!!r.unsafe,o=!!r&&!!r.enumerable,s=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof t||Rt(n,"name")||Et(n,"name",t),(i=Ot(n)).source||(i.source=Pt.join("string"==typeof t?t:""))),e!==St?(a?!s&&e[t]&&(o=!0):delete e[t],o?e[t]=n:Et(e,t,n)):o?e[t]=n:It(t,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&Ct(this).source||Tt(this)}));var At={},jt=Math.ceil,Mt=Math.floor,Lt=function(e){return isNaN(e=+e)?0:(e>0?Mt:jt)(e)},Ut=Lt,Nt=Math.min,Dt=function(e){return e>0?Nt(Ut(e),9007199254740991):0},Ft=Lt,Bt=Math.max,qt=Math.min,zt=function(e,t){var n=Ft(e);return n<0?Bt(n+t,0):qt(n,t)},Wt=S,Kt=Dt,Vt=zt,$t=function(e){return function(t,n,r){var i,a=Wt(t),o=Kt(a.length),s=Vt(r,o);if(e&&n!=n){for(;o>s;)if((i=a[s++])!=i)return!0}else for(;o>s;s++)if((e||s in a)&&a[s]===n)return e||s||0;return!e&&-1}},Gt={includes:$t(!0),indexOf:$t(!1)},Jt=te,Ht=S,Yt=Gt.indexOf,Qt=ut,Xt=function(e,t){var n,r=Ht(e),i=0,a=[];for(n in r)!Jt(Qt,n)&&Jt(r,n)&&a.push(n);for(;t.length>i;)Jt(r,n=t[i++])&&(~Yt(a,n)||a.push(n));return a},Zt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],en=Xt,tn=Zt.concat("length","prototype");At.f=Object.getOwnPropertyNames||function(e){return en(e,tn)};var nn={};nn.f=Object.getOwnPropertySymbols;var rn=At,an=nn,on=Fe,sn=T("Reflect","ownKeys")||function(e){var t=rn.f(on(e)),n=an.f;return n?t.concat(n(e)):t},un=te,cn=sn,ln=o,fn=Ne,dn=function(e,t){for(var n=cn(t),r=fn.f,i=ln.f,a=0;a<n.length;a++){var o=n[a];un(e,o)||r(e,o,i(t,o))}},pn=s,hn=/#|\.prototype\./,vn=function(e,t){var n=gn[yn(e)];return n==bn||n!=mn&&("function"==typeof t?pn(t):!!t)},yn=vn.normalize=function(e){return String(e).replace(hn,".").toLowerCase()},gn=vn.data={},mn=vn.NATIVE="N",bn=vn.POLYFILL="P",wn=vn,kn=a,_n=o.f,xn=Ge,Sn=Je.exports,En=$,Rn=dn,In=wn,Tn=function(e,t){var n,r,i,a,o,s=e.target,u=e.global,c=e.stat;if(n=u?kn:c?kn[s]||En(s,{}):(kn[s]||{}).prototype)for(r in t){if(a=t[r],i=e.noTargetGet?(o=_n(n,r))&&o.value:n[r],!In(u?r:s+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof a==typeof i)continue;Rn(a,i)}(e.sham||i&&i.sham)&&xn(a,"sham",!0),Sn(n,r,a,e)}},Cn=Ne.f,On=te,Pn=he("toStringTag"),An=function(e,t,n){e&&!On(e=n?e:e.prototype,Pn)&&Cn(e,Pn,{configurable:!0,value:t})},jn=a,Mn=An;Tn({global:!0},{Reflect:{}}),Mn(jn.Reflect,"Reflect",!0);var Ln,Un=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},Nn=Xt,Dn=Zt,Fn=Object.keys||function(e){return Nn(e,Dn)},Bn=Ne,qn=Fe,zn=Fn,Wn=u?Object.defineProperties:function(e,t){qn(e);for(var n,r=zn(t),i=r.length,a=0;i>a;)Bn.f(e,n=r[a++],t[n]);return e},Kn=T("document","documentElement"),Vn=Fe,$n=Wn,Gn=Zt,Jn=ut,Hn=Kn,Yn=Re,Qn=st("IE_PROTO"),Xn=function(){},Zn=function(e){return"<script>"+e+"</"+"script>"},er=function(e){e.write(Zn("")),e.close();var t=e.parentWindow.Object;return e=null,t},tr=function(){try{Ln=new ActiveXObject("htmlfile")}catch(e){}var e,t;tr="undefined"!=typeof document?document.domain&&Ln?er(Ln):((t=Yn("iframe")).style.display="none",Hn.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Zn("document.F=Object")),e.close(),e.F):er(Ln);for(var n=Gn.length;n--;)delete tr.prototype[Gn[n]];return tr()};Jn[Qn]=!0;var nr=Object.create||function(e,t){var n;return null!==e?(Xn.prototype=Vn(e),n=new Xn,Xn.prototype=null,n[Qn]=e):n=tr(),void 0===t?n:$n(n,t)},rr=Un,ir=E,ar=[].slice,or={},sr=function(e,t,n){if(!(t in or)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";or[t]=Function("C,a","return new C("+r.join(",")+")")}return or[t](e,n)},ur=Function.bind||function(e){var t=rr(this),n=ar.call(arguments,1),r=function(){var i=n.concat(ar.call(arguments));return this instanceof r?sr(t,i.length,i):t.apply(e,i)};return ir(t.prototype)&&(r.prototype=t.prototype),r},cr=Tn,lr=Un,fr=Fe,dr=E,pr=nr,hr=ur,vr=s,yr=T("Reflect","construct"),gr=vr((function(){function e(){}return!(yr((function(){}),[],e)instanceof e)})),mr=!vr((function(){yr((function(){}))})),br=gr||mr;cr({target:"Reflect",stat:!0,forced:br,sham:br},{construct:function(e,t){lr(e),fr(t);var n=arguments.length<3?e:lr(arguments[2]);if(mr&&!gr)return yr(e,t,n);if(e==n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return r.push.apply(r,t),new(hr.apply(e,r))}var i=n.prototype,a=pr(dr(i)?i:Object.prototype),o=Function.apply.call(e,a,t);return dr(o)?o:a}});var wr=X,kr=Fn;Tn({target:"Object",stat:!0,forced:s((function(){kr(1)}))},{keys:function(e){return kr(wr(e))}});var _r=g,xr=Array.isArray||function(e){return"Array"==_r(e)},Sr=z,Er=function(e){if(Sr(e))throw TypeError("Cannot convert a Symbol value to a string");return String(e)},Rr={},Ir=S,Tr=At.f,Cr={}.toString,Or="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Rr.f=function(e){return Or&&"[object Window]"==Cr.call(e)?function(e){try{return Tr(e)}catch(e){return Or.slice()}}(e):Tr(Ir(e))};var Pr={},Ar=he;Pr.f=Ar;var jr=a,Mr=te,Lr=Pr,Ur=Ne.f,Nr=function(e){var t=jr.Symbol||(jr.Symbol={});Mr(t,e)||Ur(t,e,{value:Lr.f(e)})},Dr=Un,Fr=function(e,t,n){if(Dr(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}},Br=E,qr=xr,zr=he("species"),Wr=function(e){var t;return qr(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!qr(t.prototype)?Br(t)&&null===(t=t[zr])&&(t=void 0):t=void 0),void 0===t?Array:t},Kr=function(e,t){return new(Wr(e))(0===t?0:t)},Vr=Fr,$r=w,Gr=X,Jr=Dt,Hr=Kr,Yr=[].push,Qr=function(e){var t=1==e,n=2==e,r=3==e,i=4==e,a=6==e,o=7==e,s=5==e||a;return function(u,c,l,f){for(var d,p,h=Gr(u),v=$r(h),y=Vr(c,l,3),g=Jr(v.length),m=0,b=f||Hr,w=t?b(u,g):n||o?b(u,0):void 0;g>m;m++)if((s||m in v)&&(p=y(d=v[m],m,h),e))if(t)w[m]=p;else if(p)switch(e){case 3:return!0;case 5:return d;case 6:return m;case 2:Yr.call(w,d)}else switch(e){case 4:return!1;case 7:Yr.call(w,d)}return a?-1:r||i?i:w}},Xr={forEach:Qr(0),map:Qr(1),filter:Qr(2),some:Qr(3),every:Qr(4),find:Qr(5),findIndex:Qr(6),filterReject:Qr(7)},Zr=Tn,ei=a,ti=T,ni=u,ri=F,ii=s,ai=te,oi=xr,si=E,ui=z,ci=Fe,li=X,fi=S,di=_e,pi=Er,hi=v,vi=nr,yi=Fn,gi=At,mi=Rr,bi=nn,wi=o,ki=Ne,_i=c,xi=Ge,Si=Je.exports,Ei=K.exports,Ri=ut,Ii=ie,Ti=he,Ci=Pr,Oi=Nr,Pi=An,Ai=xt,ji=Xr.forEach,Mi=st("hidden"),Li="Symbol",Ui=Ti("toPrimitive"),Ni=Ai.set,Di=Ai.getterFor(Li),Fi=Object.prototype,Bi=ei.Symbol,qi=ti("JSON","stringify"),zi=wi.f,Wi=ki.f,Ki=mi.f,Vi=_i.f,$i=Ei("symbols"),Gi=Ei("op-symbols"),Ji=Ei("string-to-symbol-registry"),Hi=Ei("symbol-to-string-registry"),Yi=Ei("wks"),Qi=ei.QObject,Xi=!Qi||!Qi.prototype||!Qi.prototype.findChild,Zi=ni&&ii((function(){return 7!=vi(Wi({},"a",{get:function(){return Wi(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=zi(Fi,t);r&&delete Fi[t],Wi(e,t,n),r&&e!==Fi&&Wi(Fi,t,r)}:Wi,ea=function(e,t){var n=$i[e]=vi(Bi.prototype);return Ni(n,{type:Li,tag:e,description:t}),ni||(n.description=t),n},ta=function(e,t,n){e===Fi&&ta(Gi,t,n),ci(e);var r=di(t);return ci(n),ai($i,r)?(n.enumerable?(ai(e,Mi)&&e[Mi][r]&&(e[Mi][r]=!1),n=vi(n,{enumerable:hi(0,!1)})):(ai(e,Mi)||Wi(e,Mi,hi(1,{})),e[Mi][r]=!0),Zi(e,r,n)):Wi(e,r,n)},na=function(e,t){ci(e);var n=fi(t),r=yi(n).concat(oa(n));return ji(r,(function(t){ni&&!ra.call(n,t)||ta(e,t,n[t])})),e},ra=function(e){var t=di(e),n=Vi.call(this,t);return!(this===Fi&&ai($i,t)&&!ai(Gi,t))&&(!(n||!ai(this,t)||!ai($i,t)||ai(this,Mi)&&this[Mi][t])||n)},ia=function(e,t){var n=fi(e),r=di(t);if(n!==Fi||!ai($i,r)||ai(Gi,r)){var i=zi(n,r);return!i||!ai($i,r)||ai(n,Mi)&&n[Mi][r]||(i.enumerable=!0),i}},aa=function(e){var t=Ki(fi(e)),n=[];return ji(t,(function(e){ai($i,e)||ai(Ri,e)||n.push(e)})),n},oa=function(e){var t=e===Fi,n=Ki(t?Gi:fi(e)),r=[];return ji(n,(function(e){!ai($i,e)||t&&!ai(Fi,e)||r.push($i[e])})),r};(ri||(Bi=function(){if(this instanceof Bi)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?pi(arguments[0]):void 0,t=Ii(e),n=function(e){this===Fi&&n.call(Gi,e),ai(this,Mi)&&ai(this[Mi],t)&&(this[Mi][t]=!1),Zi(this,t,hi(1,e))};return ni&&Xi&&Zi(Fi,t,{configurable:!0,set:n}),ea(t,e)},Si(Bi.prototype,"toString",(function(){return Di(this).tag})),Si(Bi,"withoutSetter",(function(e){return ea(Ii(e),e)})),_i.f=ra,ki.f=ta,wi.f=ia,gi.f=mi.f=aa,bi.f=oa,Ci.f=function(e){return ea(Ti(e),e)},ni&&(Wi(Bi.prototype,"description",{configurable:!0,get:function(){return Di(this).description}}),Si(Fi,"propertyIsEnumerable",ra,{unsafe:!0}))),Zr({global:!0,wrap:!0,forced:!ri,sham:!ri},{Symbol:Bi}),ji(yi(Yi),(function(e){Oi(e)})),Zr({target:Li,stat:!0,forced:!ri},{for:function(e){var t=pi(e);if(ai(Ji,t))return Ji[t];var n=Bi(t);return Ji[t]=n,Hi[n]=t,n},keyFor:function(e){if(!ui(e))throw TypeError(e+" is not a symbol");if(ai(Hi,e))return Hi[e]},useSetter:function(){Xi=!0},useSimple:function(){Xi=!1}}),Zr({target:"Object",stat:!0,forced:!ri,sham:!ni},{create:function(e,t){return void 0===t?vi(e):na(vi(e),t)},defineProperty:ta,defineProperties:na,getOwnPropertyDescriptor:ia}),Zr({target:"Object",stat:!0,forced:!ri},{getOwnPropertyNames:aa,getOwnPropertySymbols:oa}),Zr({target:"Object",stat:!0,forced:ii((function(){bi.f(1)}))},{getOwnPropertySymbols:function(e){return bi.f(li(e))}}),qi)&&Zr({target:"JSON",stat:!0,forced:!ri||ii((function(){var e=Bi();return"[null]"!=qi([e])||"{}"!=qi({a:e})||"{}"!=qi(Object(e))}))},{stringify:function(e,t,n){for(var r,i=[e],a=1;arguments.length>a;)i.push(arguments[a++]);if(r=t,(si(t)||void 0!==e)&&!ui(e))return oi(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!ui(t))return t}),i[1]=t,qi.apply(null,i)}});Bi.prototype[Ui]||xi(Bi.prototype,Ui,Bi.prototype.valueOf),Pi(Bi,Li),Ri[Mi]=!0;var sa=s,ua=U,ca=he("species"),la=function(e){return ua>=51||!sa((function(){var t=[];return(t.constructor={})[ca]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},fa=Xr.filter;Tn({target:"Array",proto:!0,forced:!la("filter")},{filter:function(e){return fa(this,e,arguments.length>1?arguments[1]:void 0)}});var da=Tn,pa=s,ha=S,va=o.f,ya=u,ga=pa((function(){va(1)}));da({target:"Object",stat:!0,forced:!ya||ga,sham:!ya},{getOwnPropertyDescriptor:function(e,t){return va(ha(e),t)}});var ma=_e,ba=Ne,wa=v,ka=function(e,t,n){var r=ma(t);r in e?ba.f(e,r,wa(0,n)):e[r]=n},_a=sn,xa=S,Sa=o,Ea=ka;function Ra(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function Ia(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Ra(a,r,i,o,s,"next",e)}function s(e){Ra(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Ta(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ca(e,t){return Ca=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ca(e,t)}function Oa(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ca(e,t)}function Pa(e){return Pa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pa(e)}function Aa(e,t){if(t&&("object"===Pa(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Ta(e)}function ja(e){return ja=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ja(e)}function Ma(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function La(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ua(e,t,n){return t&&La(e.prototype,t),n&&La(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Na(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Tn({target:"Object",stat:!0,sham:!u},{getOwnPropertyDescriptors:function(e){for(var t,n,r=xa(e),i=Sa.f,a=_a(r),o={},s=0;a.length>s;)void 0!==(n=i(r,t=a[s++]))&&Ea(o,t,n);return o}});var Da=Xr.map;Tn({target:"Array",proto:!0,forced:!la("map")},{map:function(e){return Da(this,e,arguments.length>1?arguments[1]:void 0)}});var Fa={};Fa[he("toStringTag")]="z";var Ba="[object z]"===String(Fa),qa=Ba,za=g,Wa=he("toStringTag"),Ka="Arguments"==za(function(){return arguments}()),Va=qa?za:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),Wa))?n:Ka?za(t):"Object"==(r=za(t))&&"function"==typeof t.callee?"Arguments":r},$a=Va,Ga=Ba?{}.toString:function(){return"[object "+$a(this)+"]"},Ja=Ba,Ha=Je.exports,Ya=Ga;Ja||Ha(Object.prototype,"toString",Ya,{unsafe:!0});var Qa={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},Xa=Re("span").classList,Za=Xa&&Xa.constructor&&Xa.constructor.prototype,eo=Za===Object.prototype?void 0:Za,to=s,no=function(e,t){var n=[][e];return!!n&&to((function(){n.call(null,t||function(){throw 1},1)}))},ro=Xr.forEach,io=no("forEach")?[].forEach:function(e){return ro(this,e,arguments.length>1?arguments[1]:void 0)},ao=a,oo=Qa,so=eo,uo=io,co=Ge,lo=function(e){if(e&&e.forEach!==uo)try{co(e,"forEach",uo)}catch(t){e.forEach=uo}};for(var fo in oo)lo(ao[fo]&&ao[fo].prototype);lo(so);var po=a.Promise,ho=Je.exports,vo=function(e,t,n){for(var r in t)ho(e,r,t[r],n);return e},yo=E,go=Fe,mo=function(e){if(!yo(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e},bo=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return go(n),mo(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),wo=T,ko=Ne,_o=u,xo=he("species"),So=function(e){var t=wo(e),n=ko.f;_o&&t&&!t[xo]&&n(t,xo,{configurable:!0,get:function(){return this}})},Eo=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},Ro={},Io=Ro,To=he("iterator"),Co=Array.prototype,Oo=function(e){return void 0!==e&&(Io.Array===e||Co[To]===e)},Po=Va,Ao=Ro,jo=he("iterator"),Mo=function(e){if(null!=e)return e[jo]||e["@@iterator"]||Ao[Po(e)]},Lo=Fe,Uo=Mo,No=function(e,t){var n=arguments.length<2?Uo(e):t;if("function"!=typeof n)throw TypeError(String(e)+" is not iterable");return Lo(n.call(e))},Do=Fe,Fo=function(e,t,n){var r,i;Do(e);try{if(void 0===(r=e.return)){if("throw"===t)throw n;return n}r=r.call(e)}catch(e){i=!0,r=e}if("throw"===t)throw n;if(i)throw r;return Do(r),n},Bo=Fe,qo=Oo,zo=Dt,Wo=Fr,Ko=No,Vo=Mo,$o=Fo,Go=function(e,t){this.stopped=e,this.result=t},Jo=function(e,t,n){var r,i,a,o,s,u,c,l=n&&n.that,f=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),h=Wo(t,l,1+f+p),v=function(e){return r&&$o(r,"normal",e),new Go(!0,e)},y=function(e){return f?(Bo(e),p?h(e[0],e[1],v):h(e[0],e[1])):p?h(e,v):h(e)};if(d)r=e;else{if("function"!=typeof(i=Vo(e)))throw TypeError("Target is not iterable");if(qo(i)){for(a=0,o=zo(e.length);o>a;a++)if((s=y(e[a]))&&s instanceof Go)return s;return new Go(!1)}r=Ko(e,i)}for(u=r.next;!(c=u.call(r)).done;){try{s=y(c.value)}catch(e){$o(r,"throw",e)}if("object"==typeof s&&s&&s instanceof Go)return s}return new Go(!1)},Ho=he("iterator"),Yo=!1;try{var Qo=0,Xo={next:function(){return{done:!!Qo++}},return:function(){Yo=!0}};Xo[Ho]=function(){return this},Array.from(Xo,(function(){throw 2}))}catch(e){}var Zo,es,ts,ns,rs=function(e,t){if(!t&&!Yo)return!1;var n=!1;try{var r={};r[Ho]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},is=Fe,as=Un,os=he("species"),ss=function(e,t){var n,r=is(e).constructor;return void 0===r||null==(n=is(r)[os])?t:as(n)},us=/(?:ipad|iphone|ipod).*applewebkit/i.test(C),cs="process"==g(a.process),ls=a,fs=s,ds=Fr,ps=Kn,hs=Re,vs=us,ys=cs,gs=ls.setImmediate,ms=ls.clearImmediate,bs=ls.process,ws=ls.MessageChannel,ks=ls.Dispatch,_s=0,xs={},Ss="onreadystatechange";try{Zo=ls.location}catch(e){}var Es=function(e){if(xs.hasOwnProperty(e)){var t=xs[e];delete xs[e],t()}},Rs=function(e){return function(){Es(e)}},Is=function(e){Es(e.data)},Ts=function(e){ls.postMessage(String(e),Zo.protocol+"//"+Zo.host)};gs&&ms||(gs=function(e){for(var t=[],n=arguments.length,r=1;n>r;)t.push(arguments[r++]);return xs[++_s]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},es(_s),_s},ms=function(e){delete xs[e]},ys?es=function(e){bs.nextTick(Rs(e))}:ks&&ks.now?es=function(e){ks.now(Rs(e))}:ws&&!vs?(ns=(ts=new ws).port2,ts.port1.onmessage=Is,es=ds(ns.postMessage,ns,1)):ls.addEventListener&&"function"==typeof postMessage&&!ls.importScripts&&Zo&&"file:"!==Zo.protocol&&!fs(Ts)?(es=Ts,ls.addEventListener("message",Is,!1)):es=Ss in hs("script")?function(e){ps.appendChild(hs("script")).onreadystatechange=function(){ps.removeChild(this),Es(e)}}:function(e){setTimeout(Rs(e),0)});var Cs,Os,Ps,As,js,Ms,Ls,Us,Ns={set:gs,clear:ms},Ds=a,Fs=/ipad|iphone|ipod/i.test(C)&&void 0!==Ds.Pebble,Bs=/web0s(?!.*chrome)/i.test(C),qs=a,zs=o.f,Ws=Ns.set,Ks=us,Vs=Fs,$s=Bs,Gs=cs,Js=qs.MutationObserver||qs.WebKitMutationObserver,Hs=qs.document,Ys=qs.process,Qs=qs.Promise,Xs=zs(qs,"queueMicrotask"),Zs=Xs&&Xs.value;Zs||(Cs=function(){var e,t;for(Gs&&(e=Ys.domain)&&e.exit();Os;){t=Os.fn,Os=Os.next;try{t()}catch(e){throw Os?As():Ps=void 0,e}}Ps=void 0,e&&e.enter()},Ks||Gs||$s||!Js||!Hs?!Vs&&Qs&&Qs.resolve?((Ls=Qs.resolve(void 0)).constructor=Qs,Us=Ls.then,As=function(){Us.call(Ls,Cs)}):As=Gs?function(){Ys.nextTick(Cs)}:function(){Ws.call(qs,Cs)}:(js=!0,Ms=Hs.createTextNode(""),new Js(Cs).observe(Ms,{characterData:!0}),As=function(){Ms.data=js=!js}));var eu=Zs||function(e){var t={fn:e,next:void 0};Ps&&(Ps.next=t),Os||(Os=t,As()),Ps=t},tu={},nu=Un,ru=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=nu(t),this.reject=nu(n)};tu.f=function(e){return new ru(e)};var iu,au,ou,su,uu=Fe,cu=E,lu=tu,fu=a,du="object"==typeof window,pu=Tn,hu=a,vu=T,yu=po,gu=Je.exports,mu=vo,bu=bo,wu=An,ku=So,_u=E,xu=Un,Su=Eo,Eu=et,Ru=Jo,Iu=rs,Tu=ss,Cu=Ns.set,Ou=eu,Pu=function(e,t){if(uu(e),cu(t)&&t.constructor===e)return t;var n=lu.f(e);return(0,n.resolve)(t),n.promise},Au=function(e,t){var n=fu.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))},ju=tu,Mu=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Lu=xt,Uu=wn,Nu=du,Du=cs,Fu=U,Bu=he("species"),qu="Promise",zu=Lu.get,Wu=Lu.set,Ku=Lu.getterFor(qu),Vu=yu&&yu.prototype,$u=yu,Gu=Vu,Ju=hu.TypeError,Hu=hu.document,Yu=hu.process,Qu=ju.f,Xu=Qu,Zu=!!(Hu&&Hu.createEvent&&hu.dispatchEvent),ec="function"==typeof PromiseRejectionEvent,tc="unhandledrejection",nc=!1,rc=Uu(qu,(function(){var e=Eu($u),t=e!==String($u);if(!t&&66===Fu)return!0;if(Fu>=51&&/native code/.test(e))return!1;var n=new $u((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};return(n.constructor={})[Bu]=r,!(nc=n.then((function(){}))instanceof r)||!t&&Nu&&!ec})),ic=rc||!Iu((function(e){$u.all(e).catch((function(){}))})),ac=function(e){var t;return!(!_u(e)||"function"!=typeof(t=e.then))&&t},oc=function(e,t){if(!e.notified){e.notified=!0;var n=e.reactions;Ou((function(){for(var r=e.value,i=1==e.state,a=0;n.length>a;){var o,s,u,c=n[a++],l=i?c.ok:c.fail,f=c.resolve,d=c.reject,p=c.domain;try{l?(i||(2===e.rejection&&lc(e),e.rejection=1),!0===l?o=r:(p&&p.enter(),o=l(r),p&&(p.exit(),u=!0)),o===c.promise?d(Ju("Promise-chain cycle")):(s=ac(o))?s.call(o,f,d):f(o)):d(r)}catch(e){p&&!u&&p.exit(),d(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&uc(e)}))}},sc=function(e,t,n){var r,i;Zu?((r=Hu.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),hu.dispatchEvent(r)):r={promise:t,reason:n},!ec&&(i=hu["on"+e])?i(r):e===tc&&Au("Unhandled promise rejection",n)},uc=function(e){Cu.call(hu,(function(){var t,n=e.facade,r=e.value;if(cc(e)&&(t=Mu((function(){Du?Yu.emit("unhandledRejection",r,n):sc(tc,n,r)})),e.rejection=Du||cc(e)?2:1,t.error))throw t.value}))},cc=function(e){return 1!==e.rejection&&!e.parent},lc=function(e){Cu.call(hu,(function(){var t=e.facade;Du?Yu.emit("rejectionHandled",t):sc("rejectionhandled",t,e.value)}))},fc=function(e,t,n){return function(r){e(t,r,n)}},dc=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,oc(e,!0))},pc=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw Ju("Promise can't be resolved itself");var r=ac(t);r?Ou((function(){var n={done:!1};try{r.call(t,fc(pc,n,e),fc(dc,n,e))}catch(t){dc(n,t,e)}})):(e.value=t,e.state=1,oc(e,!1))}catch(t){dc({done:!1},t,e)}}};if(rc&&(Gu=($u=function(e){Su(this,$u,qu),xu(e),iu.call(this);var t=zu(this);try{e(fc(pc,t),fc(dc,t))}catch(e){dc(t,e)}}).prototype,(iu=function(e){Wu(this,{type:qu,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=mu(Gu,{then:function(e,t){var n=Ku(this),r=Qu(Tu(this,$u));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=Du?Yu.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&oc(n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),au=function(){var e=new iu,t=zu(e);this.promise=e,this.resolve=fc(pc,t),this.reject=fc(dc,t)},ju.f=Qu=function(e){return e===$u||e===ou?new au(e):Xu(e)},"function"==typeof yu&&Vu!==Object.prototype)){su=Vu.then,nc||(gu(Vu,"then",(function(e,t){var n=this;return new $u((function(e,t){su.call(n,e,t)})).then(e,t)}),{unsafe:!0}),gu(Vu,"catch",Gu.catch,{unsafe:!0}));try{delete Vu.constructor}catch(e){}bu&&bu(Vu,Gu)}pu({global:!0,wrap:!0,forced:rc},{Promise:$u}),wu($u,qu,!1),ku(qu),ou=vu(qu),pu({target:qu,stat:!0,forced:rc},{reject:function(e){var t=Qu(this);return t.reject.call(void 0,e),t.promise}}),pu({target:qu,stat:!0,forced:rc},{resolve:function(e){return Pu(this,e)}}),pu({target:qu,stat:!0,forced:ic},{all:function(e){var t=this,n=Qu(t),r=n.resolve,i=n.reject,a=Mu((function(){var n=xu(t.resolve),a=[],o=0,s=1;Ru(e,(function(e){var u=o++,c=!1;a.push(void 0),s++,n.call(t,e).then((function(e){c||(c=!0,a[u]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise},race:function(e){var t=this,n=Qu(t),r=n.reject,i=Mu((function(){var i=xu(t.resolve);Ru(e,(function(e){i.call(t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var hc,vc=Object.prototype,yc=vc.hasOwnProperty,gc="function"==typeof Symbol?Symbol:{},mc=gc.iterator||"@@iterator",bc=gc.asyncIterator||"@@asyncIterator",wc=gc.toStringTag||"@@toStringTag";function kc(e,t,n,r){var i=t&&t.prototype instanceof Tc?t:Tc,a=Object.create(i.prototype),o=new qc(r||[]);return a._invoke=function(e,t,n){var r=xc;return function(i,a){if(r===Ec)throw new Error("Generator is already running");if(r===Rc){if("throw"===i)throw a;return Wc()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=Dc(o,n);if(s){if(s===Ic)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===xc)throw r=Rc,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=Ec;var u=_c(e,t,n);if("normal"===u.type){if(r=n.done?Rc:Sc,u.arg===Ic)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=Rc,n.method="throw",n.arg=u.arg)}}}(e,n,o),a}function _c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}var xc="suspendedStart",Sc="suspendedYield",Ec="executing",Rc="completed",Ic={};function Tc(){}function Cc(){}function Oc(){}var Pc={};Pc[mc]=function(){return this};var Ac=Object.getPrototypeOf,jc=Ac&&Ac(Ac(zc([])));jc&&jc!==vc&&yc.call(jc,mc)&&(Pc=jc);var Mc=Oc.prototype=Tc.prototype=Object.create(Pc);function Lc(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function Uc(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===Cc||"GeneratorFunction"===(t.displayName||t.name))}function Nc(e,t){function n(r,i,a,o){var s=_c(e[r],e,i);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"===Pa(c)&&yc.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,a,o)}),(function(e){n("throw",e,a,o)})):t.resolve(c).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,o)}))}o(s.arg)}var r;this._invoke=function(e,i){function a(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(a,a):a()}}function Dc(e,t){var n=e.iterator[t.method];if(n===hc){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=hc,Dc(e,t),"throw"===t.method))return Ic;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return Ic}var r=_c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,Ic;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=hc),t.delegate=null,Ic):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,Ic)}function Fc(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function Bc(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function qc(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(Fc,this),this.reset(!0)}function zc(e){if(e){var t=e[mc];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(yc.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=hc,t.done=!0,t};return r.next=r}}return{next:Wc}}function Wc(){return{value:hc,done:!0}}Cc.prototype=Mc.constructor=Oc,Oc.constructor=Cc,Oc[wc]=Cc.displayName="GeneratorFunction",Lc(Nc.prototype),Nc.prototype[bc]=function(){return this},Lc(Mc),Mc[wc]="Generator",Mc[mc]=function(){return this},Mc.toString=function(){return"[object Generator]"},qc.prototype={constructor:qc,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=hc,this.done=!1,this.delegate=null,this.method="next",this.arg=hc,this.tryEntries.forEach(Bc),!e)for(var t in this)"t"===t.charAt(0)&&yc.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=hc)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=hc),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var o=yc.call(i,"catchLoc"),s=yc.call(i,"finallyLoc");if(o&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&yc.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,Ic):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),Ic},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),Bc(n),Ic}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;Bc(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:zc(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=hc),Ic}};var Kc={wrap:kc,isGeneratorFunction:Uc,AsyncIterator:Nc,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,Oc):(e.__proto__=Oc,wc in e||(e[wc]="GeneratorFunction")),e.prototype=Object.create(Mc),e},awrap:function(e){return{__await:e}},async:function(e,t,n,r,i){void 0===i&&(i=Promise);var a=new Nc(kc(e,t,n,r),i);return Uc(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},keys:function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},values:zc},Vc=Object.freeze({__proto__:null,default:Kc});function $c(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":Pa(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function Gc(e,t){if("object"===("undefined"==typeof Reflect?"undefined":Pa(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var Jc=Tn,Hc=s,Yc=xr,Qc=E,Xc=X,Zc=Dt,el=ka,tl=Kr,nl=la,rl=U,il=he("isConcatSpreadable"),al=9007199254740991,ol="Maximum allowed index exceeded",sl=rl>=51||!Hc((function(){var e=[];return e[il]=!1,e.concat()[0]!==e})),ul=nl("concat"),cl=function(e){if(!Qc(e))return!1;var t=e[il];return void 0!==t?!!t:Yc(e)};Jc({target:"Array",proto:!0,forced:!sl||!ul},{concat:function(e){var t,n,r,i,a,o=Xc(this),s=tl(o,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(cl(a=-1===t?o:arguments[t])){if(u+(i=Zc(a.length))>al)throw TypeError(ol);for(n=0;n<i;n++,u++)n in a&&el(s,u,a[n])}else{if(u>=al)throw TypeError(ol);el(s,u++,a)}return s.length=u,s}});var ll=Fe,fl=Fo,dl=Fr,pl=X,hl=function(e,t,n,r){try{return r?t(ll(n)[0],n[1]):t(n)}catch(t){fl(e,"throw",t)}},vl=Oo,yl=Dt,gl=ka,ml=No,bl=Mo,wl=function(e){var t,n,r,i,a,o,s=pl(e),u="function"==typeof this?this:Array,c=arguments.length,l=c>1?arguments[1]:void 0,f=void 0!==l,d=bl(s),p=0;if(f&&(l=dl(l,c>2?arguments[2]:void 0,2)),null==d||u==Array&&vl(d))for(n=new u(t=yl(s.length));t>p;p++)o=f?l(s[p],p):s[p],gl(n,p,o);else for(a=(i=ml(s,d)).next,n=new u;!(r=a.call(i)).done;p++)o=f?hl(i,l,[r.value,p],!0):r.value,gl(n,p,o);return n.length=p,n},kl=wl;Tn({target:"Array",stat:!0,forced:!rs((function(e){Array.from(e)}))},{from:kl});var _l,xl,Sl,El=Lt,Rl=Er,Il=k,Tl=function(e){return function(t,n){var r,i,a=Rl(Il(t)),o=El(n),s=a.length;return o<0||o>=s?e?"":void 0:(r=a.charCodeAt(o))<55296||r>56319||o+1===s||(i=a.charCodeAt(o+1))<56320||i>57343?e?a.charAt(o):r:e?a.slice(o,o+2):i-56320+(r-55296<<10)+65536}},Cl={codeAt:Tl(!1),charAt:Tl(!0)},Ol=!s((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Pl=te,Al=X,jl=Ol,Ml=st("IE_PROTO"),Ll=Object.prototype,Ul=jl?Object.getPrototypeOf:function(e){return e=Al(e),Pl(e,Ml)?e[Ml]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?Ll:null},Nl=s,Dl=Ul,Fl=Ge,Bl=he("iterator"),ql=!1;[].keys&&("next"in(Sl=[].keys())?(xl=Dl(Dl(Sl)))!==Object.prototype&&(_l=xl):ql=!0);var zl=null==_l||Nl((function(){var e={};return _l[Bl].call(e)!==e}));zl&&(_l={}),"function"!=typeof _l[Bl]&&Fl(_l,Bl,(function(){return this}));var Wl={IteratorPrototype:_l,BUGGY_SAFARI_ITERATORS:ql},Kl=Wl.IteratorPrototype,Vl=nr,$l=v,Gl=An,Jl=Ro,Hl=function(){return this},Yl=function(e,t,n){var r=t+" Iterator";return e.prototype=Vl(Kl,{next:$l(1,n)}),Gl(e,r,!1),Jl[r]=Hl,e},Ql=Tn,Xl=Yl,Zl=Ul,ef=bo,tf=An,nf=Ge,rf=Je.exports,af=Ro,of=Wl.IteratorPrototype,sf=Wl.BUGGY_SAFARI_ITERATORS,uf=he("iterator"),cf="keys",lf="values",ff="entries",df=function(){return this},pf=function(e,t,n,r,i,a,o){Xl(n,t,r);var s,u,c,l=function(e){if(e===i&&v)return v;if(!sf&&e in p)return p[e];switch(e){case cf:case lf:case ff:return function(){return new n(this,e)}}return function(){return new n(this)}},f=t+" Iterator",d=!1,p=e.prototype,h=p[uf]||p["@@iterator"]||i&&p[i],v=!sf&&h||l(i),y="Array"==t&&p.entries||h;if(y&&(s=Zl(y.call(new e)))!==Object.prototype&&s.next&&(Zl(s)!==of&&(ef?ef(s,of):"function"!=typeof s[uf]&&nf(s,uf,df)),tf(s,f,!0)),i==lf&&h&&h.name!==lf&&(d=!0,v=function(){return h.call(this)}),p[uf]!==v&&nf(p,uf,v),af[t]=v,i)if(u={values:l(lf),keys:a?v:l(cf),entries:l(ff)},o)for(c in u)(sf||d||!(c in p))&&rf(p,c,u[c]);else Ql({target:t,proto:!0,forced:sf||d},u);return u},hf=Cl.charAt,vf=Er,yf=xt,gf=pf,mf="String Iterator",bf=yf.set,wf=yf.getterFor(mf);gf(String,"String",(function(e){bf(this,{type:mf,string:vf(e),index:0})}),(function(){var e,t=wf(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=hf(n,r),t.index+=e.length,{value:e,done:!1})}));var kf,_f,xf,Sf={exports:{}};function Ef(e,t){return["".concat((new Date).toISOString()," Conversations ").concat(e,":")].concat(Array.from(t))}_f=n,xf=function(){var e=function(){},t="undefined",n=("undefined"==typeof window?"undefined":Pa(window))!==t&&Pa(window.navigator)!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function i(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(r){return"debug"===r&&(r="log"),("undefined"==typeof console?"undefined":Pa(console))!==t&&("trace"===r&&n?a:void 0!==console[r]?i(console,r):void 0!==console.log?i(console,"log"):e)}function s(t,n){for(var i=0;i<r.length;i++){var a=r[i];this[a]=i<t?e:this.methodFactory(a,t,n)}this.log=this.debug}function u(e,n,r){return function(){("undefined"==typeof console?"undefined":Pa(console))!==t&&(s.call(this,n,r),this[e].apply(this,arguments))}}function c(e,t,n){return o(e)||u.apply(this,arguments)}function l(e,n,i){var a,o=this;n=null==n?"WARN":n;var u="loglevel";function l(){var e;if(("undefined"==typeof window?"undefined":Pa(window))!==t&&u){try{e=window.localStorage[u]}catch(e){}if(Pa(e)===t)try{var n=window.document.cookie,r=n.indexOf(encodeURIComponent(u)+"=");-1!==r&&(e=/^([^;]+)/.exec(n.slice(r))[1])}catch(e){}return void 0===o.levels[e]&&(e=void 0),e}}"string"==typeof e?u+=":"+e:"symbol"===Pa(e)&&(u=void 0),o.name=e,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=i||c,o.getLevel=function(){return a},o.setLevel=function(n,i){if("string"==typeof n&&void 0!==o.levels[n.toUpperCase()]&&(n=o.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(("undefined"==typeof window?"undefined":Pa(window))!==t&&u){try{return void(window.localStorage[u]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+n+";"}catch(e){}}}(n),s.call(o,n,e),("undefined"==typeof console?"undefined":Pa(console))===t&&n<o.levels.SILENT)return"No console available for logging"},o.setDefaultLevel=function(e){n=e,l()||o.setLevel(e,!1)},o.resetLevel=function(){o.setLevel(n,!1),function(){if(("undefined"==typeof window?"undefined":Pa(window))!==t&&u){try{return void window.localStorage.removeItem(u)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},o.enableAll=function(e){o.setLevel(o.levels.TRACE,e)},o.disableAll=function(e){o.setLevel(o.levels.SILENT,e)};var f=l();null==f&&(f=n),o.setLevel(f,!1)}var f=new l,d={};f.getLogger=function(e){if("symbol"!==Pa(e)&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=d[e];return t||(t=d[e]=new l(e,f.getLevel(),f.methodFactory)),t};var p=("undefined"==typeof window?"undefined":Pa(window))!==t?window.log:void 0;return f.noConflict=function(){return("undefined"==typeof window?"undefined":Pa(window))!==t&&window.log===f&&(window.log=p),f},f.getLoggers=function(){return d},f.default=f,f},(kf=Sf).exports?kf.exports=xf():_f.log=xf();var Rf,If,Tf=Sf.exports.getLogger("twilio-conversations"),Cf=function(){function e(t){Na(this,e),Ma(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return Ua(e,[{key:"setLevel",value:function(e){Tf.setLevel(e)}},{key:"trace",value:function(){if(Tf.getLevel()==Tf.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.debug.apply(null,Ef(this.prefix+"T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.debug.apply(null,Ef(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.info.apply(null,Ef(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.warn.apply(null,Ef(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.error.apply(null,Ef(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){Tf.setLevel(e)}},{key:"trace",value:function(){if(Tf.getLevel()==Tf.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.debug.apply(null,Ef("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.debug.apply(null,Ef("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.info.apply(null,Ef("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.warn.apply(null,Ef("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.error.apply(null,Ef("E",t))}}]),e}(),Of={};Object.defineProperty(Of,"__esModule",{value:!0});var Pf=["weeks","years","months","days","hours","minutes","seconds"],Af=Of.pattern=new RegExp("P(?:(\\d+(?:[\\.,]\\d+)?W)|(\\d+(?:[\\.,]\\d+)?Y)?(\\d+(?:[\\.,]\\d+)?M)?(\\d+(?:[\\.,]\\d+)?D)?(?:T(\\d+(?:[\\.,]\\d+)?H)?(\\d+(?:[\\.,]\\d+)?M)?(\\d+(?:[\\.,]\\d+)?S)?)?)"),jf=If=Of.parse=function(e){return e.match(Af).slice(1).reduce((function(e,t,n){return e[Pf[n]]=parseFloat(t)||0,e}),{})},Mf=Of.end=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return r.setFullYear(r.getFullYear()+e.years),r.setMonth(r.getMonth()+e.months),r.setDate(r.getDate()+e.days),r.setHours(r.getHours()+e.hours),r.setMinutes(r.getMinutes()+e.minutes),r.setMilliseconds(r.getMilliseconds()+1e3*e.seconds),r.setDate(r.getDate()+7*e.weeks),r},Lf=Rf=Of.toSeconds=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return(Mf(e,r).getTime()-r.getTime())/1e3};function Uf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Nf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Uf(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Uf(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}Of.default={end:Mf,toSeconds:Lf,pattern:Af,parse:jf};var Df="PT5S",Ff="PT5S",Bf=Ua((function e(){var t,n,r,i,a,o,s,u,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=arguments.length>1?arguments[1]:void 0,f=arguments.length>2?arguments[2]:void 0;Na(this,e),Ma(this,"typingIndicatorTimeoutDefault",5e3);var d=c.Chat||c.IPMessaging||c||{};this.productId=d.productId,this.links={myConversations:l.links.my_conversations,conversations:l.links.conversations,users:l.links.users,currentUser:l.links.current_user,typing:l.links.typing,mediaService:l.links.media_service,mediaSetService:l.links.media_set_service,messagesReceipts:l.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:l.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:l.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:l.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:l.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:l.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=d.typingIndicatorTimeoutOverride,this.backoffConfiguration=Nf({min:1e3,max:4e3,maxAttemptsCount:3},d.backoffConfigOverride),this.retryWhenThrottled=void 0===d.retryWhenThrottledOverride||d.retryWhenThrottledOverride,this.userInfosToSubscribe=null!==(t=null!==(n=d.userInfosToSubscribeOverride)&&void 0!==n?n:l.options.user_infos_to_subscribe)&&void 0!==t?t:100,this.reachabilityEnabled=l.options.reachability_enabled,this.userIdentity=l.identity,this.userInfo=l.sync_objects.my_user_info,this.myConversations=l.sync_objects.my_conversations;var p=null!==(r=null!==(i=d.httpCacheIntervalOverride)&&void 0!==i?i:l.options.http_cache_interval)&&void 0!==r?r:Df;try{this.httpCacheInterval=Rf(If(p))}catch(e){f.error("Failed to parse http cache interval ".concat(p,", using default value ").concat(Df)),this.httpCacheInterval=Rf(If(Df))}var h=null!==(a=null!==(o=d.consumptionReportIntervalOverride)&&void 0!==o?o:l.options.consumption_report_interval)&&void 0!==a?a:Ff;try{this.consumptionReportInterval=Rf(If(h))}catch(e){f.error("Failed to parse consumption report interval ".concat(h,", using default value ").concat(Ff)),this.consumptionReportInterval=Rf(If(Ff))}this.channelMetadataCacheCapacity=null!==(s=c.channelMetadataCacheCapacity)&&void 0!==s?s:100,this.messageRecipientsCacheCapacity=null!==(u=c.messageRecipientsCacheCapacity)&&void 0!==u?u:1e3})),qf=nr,zf=Ne,Wf=he("unscopables"),Kf=Array.prototype;null==Kf[Wf]&&zf.f(Kf,Wf,{configurable:!0,value:qf(null)});var Vf=function(e){Kf[Wf][e]=!0},$f=S,Gf=Vf,Jf=Ro,Hf=xt,Yf=pf,Qf="Array Iterator",Xf=Hf.set,Zf=Hf.getterFor(Qf),ed=Yf(Array,"Array",(function(e,t){Xf(this,{type:Qf,target:$f(e),index:0,kind:t})}),(function(){var e=Zf(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values");Jf.Arguments=Jf.Array,Gf("keys"),Gf("values"),Gf("entries");var td=a,nd=Qa,rd=eo,id=ed,ad=Ge,od=he,sd=od("iterator"),ud=od("toStringTag"),cd=id.values,ld=function(e,t){if(e){if(e[sd]!==cd)try{ad(e,sd,cd)}catch(t){e[sd]=cd}if(e[ud]||ad(e,ud,t),nd[t])for(var n in id)if(e[n]!==id[n])try{ad(e,n,id[n])}catch(t){e[n]=id[n]}}};for(var fd in nd)ld(td[fd]&&td[fd].prototype,fd);ld(rd,"DOMTokenList");var dd=Tn,pd=s,hd=T("JSON","stringify"),vd=/[\uD800-\uDFFF]/g,yd=/^[\uD800-\uDBFF]$/,gd=/^[\uDC00-\uDFFF]$/,md=function(e,t,n){var r=n.charAt(t-1),i=n.charAt(t+1);return yd.test(e)&&!gd.test(i)||gd.test(e)&&!yd.test(r)?"\\u"+e.charCodeAt(0).toString(16):e},bd=pd((function(){return'"\\udf06\\ud834"'!==hd("\udf06\ud834")||'"\\udead"'!==hd("\udead")}));hd&&dd({target:"JSON",stat:!0,forced:bd},{stringify:function(e,t,n){var r=hd.apply(null,arguments);return"string"==typeof r?r.replace(vd,md):r}});var wd=E,kd=bo,_d=function(e,t,n){var r,i;return kd&&"function"==typeof(r=t.constructor)&&r!==n&&wd(i=r.prototype)&&i!==n.prototype&&kd(e,i),e},xd=k,Sd=Er,Ed="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Rd=RegExp("^"+Ed+Ed+"*"),Id=RegExp(Ed+Ed+"*$"),Td=function(e){return function(t){var n=Sd(xd(t));return 1&e&&(n=n.replace(Rd,"")),2&e&&(n=n.replace(Id,"")),n}},Cd={start:Td(1),end:Td(2),trim:Td(3)},Od=u,Pd=a,Ad=wn,jd=Je.exports,Md=te,Ld=g,Ud=_d,Nd=z,Dd=be,Fd=s,Bd=nr,qd=At.f,zd=o.f,Wd=Ne.f,Kd=Cd.trim,Vd="Number",$d=Pd.Number,Gd=$d.prototype,Jd=Ld(Bd(Gd))==Vd,Hd=function(e){if(Nd(e))throw TypeError("Cannot convert a Symbol value to a number");var t,n,r,i,a,o,s,u,c=Dd(e,"number");if("string"==typeof c&&c.length>2)if(43===(t=(c=Kd(c)).charCodeAt(0))||45===t){if(88===(n=c.charCodeAt(2))||120===n)return NaN}else if(48===t){switch(c.charCodeAt(1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+c}for(o=(a=c.slice(2)).length,s=0;s<o;s++)if((u=a.charCodeAt(s))<48||u>i)return NaN;return parseInt(a,r)}return+c};if(Ad(Vd,!$d(" 0o1")||!$d("0b1")||$d("+0x1"))){for(var Yd,Qd=function(e){var t=arguments.length<1?0:e,n=this;return n instanceof Qd&&(Jd?Fd((function(){Gd.valueOf.call(n)})):Ld(n)!=Vd)?Ud(new $d(Hd(t)),n,Qd):Hd(t)},Xd=Od?qd($d):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,fromString,range".split(","),Zd=0;Xd.length>Zd;Zd++)Md($d,Yd=Xd[Zd])&&!Md(Qd,Yd)&&Wd(Qd,Yd,zd($d,Yd));Qd.prototype=Gd,Gd.constructor=Qd,jd(Pd,Vd,Qd)}var ep=Fe,tp=function(){var e=ep(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t},np={},rp=s,ip=a.RegExp;np.UNSUPPORTED_Y=rp((function(){var e=ip("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),np.BROKEN_CARET=rp((function(){var e=ip("^r","gy");return e.lastIndex=2,null!=e.exec("str")}));var ap,op,sp=s,up=a.RegExp,cp=sp((function(){var e=up(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),lp=s,fp=a.RegExp,dp=lp((function(){var e=fp("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),pp=Er,hp=tp,vp=np,yp=K.exports,gp=nr,mp=xt.get,bp=cp,wp=dp,kp=RegExp.prototype.exec,_p=yp("native-string-replace",String.prototype.replace),xp=kp,Sp=(ap=/a/,op=/b*/g,kp.call(ap,"a"),kp.call(op,"a"),0!==ap.lastIndex||0!==op.lastIndex),Ep=vp.UNSUPPORTED_Y||vp.BROKEN_CARET,Rp=void 0!==/()??/.exec("")[1];(Sp||Rp||Ep||bp||wp)&&(xp=function(e){var t,n,r,i,a,o,s,u=this,c=mp(u),l=pp(e),f=c.raw;if(f)return f.lastIndex=u.lastIndex,t=xp.call(f,l),u.lastIndex=f.lastIndex,t;var d=c.groups,p=Ep&&u.sticky,h=hp.call(u),v=u.source,y=0,g=l;if(p&&(-1===(h=h.replace("y","")).indexOf("g")&&(h+="g"),g=l.slice(u.lastIndex),u.lastIndex>0&&(!u.multiline||u.multiline&&"\n"!==l.charAt(u.lastIndex-1))&&(v="(?: "+v+")",g=" "+g,y++),n=new RegExp("^(?:"+v+")",h)),Rp&&(n=new RegExp("^"+v+"$(?!\\s)",h)),Sp&&(r=u.lastIndex),i=kp.call(p?n:u,g),p?i?(i.input=i.input.slice(y),i[0]=i[0].slice(y),i.index=u.lastIndex,u.lastIndex+=i[0].length):u.lastIndex=0:Sp&&i&&(u.lastIndex=u.global?i.index+i[0].length:r),Rp&&i&&i.length>1&&_p.call(i[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(i[a]=void 0)})),i&&d)for(i.groups=o=gp(null),a=0;a<d.length;a++)o[(s=d[a])[0]]=i[s[1]];return i});var Ip=xp;Tn({target:"RegExp",proto:!0,forced:/./.exec!==Ip},{exec:Ip});var Tp=Je.exports,Cp=Ip,Op=s,Pp=he,Ap=Ge,jp=Pp("species"),Mp=RegExp.prototype,Lp=function(e,t,n,r){var i=Pp(e),a=!Op((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),o=a&&!Op((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[jp]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return t=!0,null},n[i](""),!t}));if(!a||!o||n){var s=/./[i],u=t(i,""[e],(function(e,t,n,r,i){var o=t.exec;return o===Cp||o===Mp.exec?a&&!i?{done:!0,value:s.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}));Tp(String.prototype,e,u[0]),Tp(Mp,i,u[1])}r&&Ap(Mp[i],"sham",!0)},Up=Cl.charAt,Np=function(e,t,n){return t+(n?Up(e,t).length:1)},Dp=X,Fp=Math.floor,Bp="".replace,qp=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,zp=/\$([$&'`]|\d{1,2})/g,Wp=g,Kp=Ip,Vp=function(e,t){var n=e.exec;if("function"==typeof n){var r=n.call(e,t);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==Wp(e))throw TypeError("RegExp#exec called on incompatible receiver");return Kp.call(e,t)},$p=Lp,Gp=s,Jp=Fe,Hp=Lt,Yp=Dt,Qp=Er,Xp=k,Zp=Np,eh=function(e,t,n,r,i,a){var o=n+e.length,s=r.length,u=zp;return void 0!==i&&(i=Dp(i),u=qp),Bp.call(a,u,(function(a,u){var c;switch(u.charAt(0)){case"$":return"$";case"&":return e;case"`":return t.slice(0,n);case"'":return t.slice(o);case"<":c=i[u.slice(1,-1)];break;default:var l=+u;if(0===l)return a;if(l>s){var f=Fp(l/10);return 0===f?a:f<=s?void 0===r[f-1]?u.charAt(1):r[f-1]+u.charAt(1):a}c=r[l-1]}return void 0===c?"":c}))},th=Vp,nh=he("replace"),rh=Math.max,ih=Math.min,ah="$0"==="a".replace(/./,"$0"),oh=!!/./[nh]&&""===/./[nh]("a","$0"),sh=!Gp((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));$p("replace",(function(e,t,n){var r=oh?"$":"$0";return[function(e,n){var r=Xp(this),i=null==e?void 0:e[nh];return void 0!==i?i.call(e,r,n):t.call(Qp(r),e,n)},function(e,i){var a=Jp(this),o=Qp(e);if("string"==typeof i&&-1===i.indexOf(r)&&-1===i.indexOf("$<")){var s=n(t,a,o,i);if(s.done)return s.value}var u="function"==typeof i;u||(i=Qp(i));var c=a.global;if(c){var l=a.unicode;a.lastIndex=0}for(var f=[];;){var d=th(a,o);if(null===d)break;if(f.push(d),!c)break;""===Qp(d[0])&&(a.lastIndex=Zp(o,Yp(a.lastIndex),l))}for(var p,h="",v=0,y=0;y<f.length;y++){d=f[y];for(var g=Qp(d[0]),m=rh(ih(Hp(d.index),o.length),0),b=[],w=1;w<d.length;w++)b.push(void 0===(p=d[w])?p:String(p));var k=d.groups;if(u){var _=[g].concat(b,m,o);void 0!==k&&_.push(k);var x=Qp(i.apply(void 0,_))}else x=eh(g,o,m,b,k,i);m>=v&&(h+=o.slice(v,m)+x,v=m+g.length)}return h+o.slice(v)}]}),!sh||!ah||oh);var uh=Tn,ch=S,lh=[].join,fh=w!=Object,dh=no("join",",");function ph(e){return JSON.parse(JSON.stringify(e))}function hh(e){return void 0===e||isNaN(Number(e))?null:Number(e)}function vh(e){try{return new Date(e)}catch(e){return null}}function yh(e,t,n){var r={};if(e)try{r=JSON.parse(e)}catch(e){n.warn(t,e)}return r}uh({target:"Array",proto:!0,forced:fh||!dh},{join:function(e){return lh.call(ch(this),void 0===e?",":e)}});var gh=function(){function e(t){Na(this,e),this.base=t.replace(/\/$/,""),this.args=[],this.paths=[]}return Ua(e,[{key:"arg",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"path",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}();function mh(e,t){if(e===t)return!0;if(null===e||null===t||void 0===e||void 0===t)return e===t;if(Pa(e)!==Pa(t))return!1;if("object"!==Pa(e))return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((function(e,n){return mh(e,t[n])}));if(Array.isArray(e)||Array.isArray(t))return!1;var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((function(n){return mh(e[n],t[n])}))}var bh={},wh={exports:{}};!function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(wh);var kh=u,_h=Ne.f,xh=Function.prototype,Sh=xh.toString,Eh=/^\s*function ([^ (]*)/,Rh="name";kh&&!(Rh in xh)&&_h(xh,Rh,{configurable:!0,get:function(){try{return Sh.call(this).match(Eh)[1]}catch(e){return""}}});var Ih={exports:{}},Th={exports:{}};!function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}(Th);var Ch={exports:{}};!function(e){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a=[],o=!0,s=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports}(Ch);var Oh={exports:{}},Ph={exports:{}};!function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports}(Ph),function(e){var t=Ph.exports;e.exports=function(e,n){if(e){if("string"==typeof e)return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}(Oh);var Ah={exports:{}};!function(e){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}(Ah),function(e){var t=Th.exports,n=Ch.exports,r=Oh.exports,i=Ah.exports;e.exports=function(e,a){return t(e)||n(e,a)||r(e,a)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(Ih);var jh=Tn,Mh=E,Lh=xr,Uh=zt,Nh=Dt,Dh=S,Fh=ka,Bh=he,qh=la("slice"),zh=Bh("species"),Wh=[].slice,Kh=Math.max;jh({target:"Array",proto:!0,forced:!qh},{slice:function(e,t){var n,r,i,a=Dh(this),o=Nh(a.length),s=Uh(e,o),u=Uh(void 0===t?o:t,o);if(Lh(a)&&("function"!=typeof(n=a.constructor)||n!==Array&&!Lh(n.prototype)?Mh(n)&&null===(n=n[zh])&&(n=void 0):n=void 0,n===Array||void 0===n))return Wh.call(a,s,u);for(r=new(void 0===n?Array:n)(Kh(u-s,0)),i=0;s<u;s++,i++)s in a&&Fh(r,i,a[s]);return r.length=i,r}});var Vh=Tn,$h=E,Gh=function(){var e=!1,t=/[ac]/;return t.exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e}(),Jh=/./.test;Vh({target:"RegExp",proto:!0,forced:!Gh},{test:function(e){if("function"!=typeof this.exec)return Jh.call(this,e);var t=this.exec(e);if(null!==t&&!$h(t))throw new Error("RegExp exec method returned something other than an Object or null");return!!t}});var Hh=Tn,Yh=u,Qh=a,Xh=te,Zh=E,ev=Ne.f,tv=dn,nv=Qh.Symbol;if(Yh&&"function"==typeof nv&&(!("description"in nv.prototype)||void 0!==nv().description)){var rv={},iv=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof iv?new nv(e):void 0===e?nv():nv(e);return""===e&&(rv[t]=!0),t};tv(iv,nv);var av=iv.prototype=nv.prototype;av.constructor=iv;var ov=av.toString,sv="Symbol(test)"==String(nv("test")),uv=/^Symbol\((.*)\)[^)]+$/;ev(av,"description",{configurable:!0,get:function(){var e=Zh(this)?this.valueOf():this,t=ov.call(e);if(Xh(rv,e))return"";var n=sv?t.slice(7,-1):t.replace(uv,"$1");return""===n?void 0:n}}),Hh({global:!0,forced:!0},{Symbol:iv})}Nr("iterator");var cv={exports:{}},lv={exports:{}};!function(e){var t=Ph.exports;e.exports=function(e){if(Array.isArray(e))return t(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(lv);var fv={exports:{}};!function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(fv);var dv={exports:{}};!function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}(dv),function(e){var t=lv.exports,n=fv.exports,r=Oh.exports,i=dv.exports;e.exports=function(e){return t(e)||n(e)||r(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(cv);var pv={exports:{}};!function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports}(pv);var hv={exports:{}};!function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports}(hv);var vv={exports:{}},yv={exports:{}};!function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(yv),function(e){var t=yv.exports;e.exports=function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&t(e,n)},e.exports.__esModule=!0,e.exports.default=e.exports}(vv);var gv={exports:{}},mv={exports:{}};!function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports}(mv),function(e){var t=wh.exports.default,n=mv.exports;e.exports=function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(gv);var bv={exports:{}};!function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(bv);var wv=Gt.includes,kv=Vf;Tn({target:"Array",proto:!0},{includes:function(e){return wv(this,e,arguments.length>1?arguments[1]:void 0)}}),kv("includes");var _v=E,xv=Math.floor,Sv=function(e){return!_v(e)&&isFinite(e)&&xv(e)===e};Tn({target:"Number",stat:!0},{isInteger:Sv});var Ev=u,Rv=Fn,Iv=S,Tv=c.f,Cv=function(e){return function(t){for(var n,r=Iv(t),i=Rv(r),a=i.length,o=0,s=[];a>o;)n=i[o++],Ev&&!Tv.call(r,n)||s.push(e?[n,r[n]]:r[n]);return s}},Ov={entries:Cv(!0),values:Cv(!1)}.entries;Tn({target:"Object",stat:!0},{entries:function(e){return Ov(e)}}),Object.defineProperty(bh,"__esModule",{value:!0});var Pv=Ih.exports,Av=cv.exports,jv=pv.exports,Mv=hv.exports,Lv=vv.exports,Uv=gv.exports,Nv=bv.exports;function Dv(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var Fv=Dv(wh.exports),Bv=Dv(Pv),qv=Dv(Av),zv=Dv(jv),Wv=Dv(Mv),Kv=Dv(Lv),Vv=Dv(Uv),$v=Dv(Nv),Gv=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return{checks:t}},Jv=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Gv((function(e){for(var n=!1,r=[],i=0,a=t;i<a.length;i++){var o=a[i];"string"!=typeof o?(n=n||e instanceof o,r.push("an instance of ".concat(o.name))):(n=n||Fv.default(e)===o,r.push("of type ".concat(o)))}return[n,r]}))};function Hv(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=$v.default(e);if(t){var i=$v.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Vv.default(this,n)}}function Yv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Qv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Qv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Qv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Xv=function(e,t){if(t.length>e.length)throw new Error("Expected at most ".concat(e.length," argument(s), but got ").concat(t.length));for(;t.length<e.length;)t.push(void 0);var n,r=Yv(t.entries());try{for(r.s();!(n=r.n()).done;){var i=Bv.default(n.value,2),a=i[0],o=i[1],s=ny(e[a],o),u=Bv.default(s,4),c=u[0],l=u[1],f=u[2],d=u[3];if(!c)throw new Error("Argument ".concat(a+1," is expected to be ").concat(f).concat(d," but got ").concat(l))}}catch(e){r.e(e)}finally{r.f()}},Zv=function(e){var t,n,r;(["undefined","boolean","number","bigint","string"].includes(Fv.default(e))&&(n="string"==typeof e?'"'.concat(e,'"'):"".concat(e)),"object"===Fv.default(e)&&"Object"!==(null==e||null===(t=e.constructor)||void 0===t?void 0:t.name))&&(n=null===e?"null":"instance of ".concat(null==e||null===(r=e.constructor)||void 0===r?void 0:r.name));return n||(n=Fv.default(e)),n},ey=function(e){var t,n=[],r=Yv(e);try{for(r.s();!(t=r.n()).done;){var i=t.value;n.push(ty(i))}}catch(e){r.e(e)}finally{r.f()}return n},ty=function(e){var t,n=[],r=Yv(Array.isArray(e)?e:[e]);try{for(r.s();!(t=r.n()).done;){var i=t.value;"string"!=typeof i&&"function"!=typeof i?n.push(i):n.push(Jv(i))}}catch(e){r.e(e)}finally{r.f()}return n},ny=function(e,t){var n,r,i=[],a=!1,o=Yv(e);try{for(o.s();!(r=o.n()).done;){var s,u=Yv(r.value.checks);try{for(u.s();!(s=u.n()).done;){var c=(0,s.value)(t),l=Bv.default(c,3),f=l[0],d=l[1],p=l[2];a=a||f,!n&&p&&(n=p),d&&(i=[].concat(qv.default(i),"string"==typeof d?[d]:qv.default(d)))}}catch(e){u.e(e)}finally{u.f()}}}catch(e){o.e(e)}finally{o.f()}if(a)return[!0];var h=n||Zv(t),v=i.length-1;return[!1,h,v>0?"".concat(i.slice(0,v).join(", ")," or ").concat(i[v]):i.join(", "),v>1?";":","]};function ry(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return iy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return iy(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function iy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ay=Gv((function(e){return["string"==typeof e&&e.length>0,"a non-empty string"]})),oy=Gv((function(e){return["number"==typeof e&&Number.isInteger(e)&&e>=0,"a non-negative integer"]})),sy=Gv((function(e){return["object"===Fv.default(e)&&null!==e&&!Array.isArray(e),"a pure object (non-null and non-array)"]}));function uy(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cy(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function cy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ly=bh.array=function(e,t){return Gv((function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(e)];var r,i=uy(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Bv.default(r.value,2),o=a[0],s=a[1],u=ny(ty(t),s),c=Bv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid array of ".concat(e," (index ").concat(o," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},fy=bh.custom=Gv,dy=bh.literal=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Gv((function(e){for(var n=!1,r=[],i=0,a=t;i<a.length;i++){var o=a[i];n=n||e===o,r.push("string"==typeof o?'"'.concat(o,'"'):"".concat(o))}return[n,r]}))},py=bh.nonEmptyArray=function(e,t){return Gv((function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(e)];var r,i=ry(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Bv.default(r.value,2),o=a[0],s=a[1],u=ny(ty(t),s),c=Bv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid non-empty array of ".concat(e," (index ").concat(o," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},hy=bh.nonEmptyString=ay,vy=bh.nonNegativeInteger=oy,yy=bh.objectSchema=function(e,t){return Gv((function(n){if("object"!==Fv.default(n)||null===n||Array.isArray(n))return[!1,"valid ".concat(e," (should be a pure object)")];for(var r=0,i=Object.entries(t);r<i.length;r++){var a=Bv.default(i[r],2),o=a[0],s=a[1],u=ny(ty(s),n[o]),c=Bv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"valid ".concat(e,' (key "').concat(o,'" should be ').concat(d,")"),"malformed ".concat(e,' (key "').concat(o,'" is ').concat(f,")")]}return[!0]}))},gy=bh.pureObject=sy;bh.runtimeTypeValidation=Xv,bh.stringifyReceivedType=Zv,bh.type=Jv;var my=bh.validateConstructorTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=ey(t);return function(e){return function(e){Kv.default(n,e);var t=Hv(n);function n(){Wv.default(this,n);for(var e=arguments.length,i=new Array(e),a=0;a<e;a++)i[a]=arguments[a];return Xv(r,i),t.call.apply(t,[this].concat(i))}return zv.default(n)}(e)}},by=bh.validateTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=ey(t);return function(e,t,n){if("function"!=typeof n.value)throw new Error("The validateTypes decorator can only be applied to methods");var i=n.value;n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Xv(r,t),i.apply(this,t)}}},wy=bh.validateTypesAsync=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=ey(t);return function(e,t,n){if("function"!=typeof n.value)throw new Error("The validateTypesAsync decorator can only be applied to methods");var i=n.value;n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];try{Xv(r,t)}catch(e){return Promise.reject(e)}return i.apply(this,t)}}};function ky(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _y(e,t){if(e){if("string"==typeof e)return ky(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ky(e,t):void 0}}function xy(e){return function(e){if(Array.isArray(e))return ky(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Sy=fy((function(e){return[["string","number","boolean","object"].includes(Pa(e)),"a JSON type"]})),Ey=fy((function(e){return[["undefined","string","number","boolean","object"].includes(Pa(e)),"an optional JSON type"]})),Ry=yy("send media options",{contentType:[dy(null),"string"],filename:["string","undefined"],media:[dy("null"),"string"].concat(xy("function"==typeof Buffer?[Buffer]:[]),xy("function"==typeof Blob?[Blob]:[]))}),Iy={},Ty={exports:{}},Cy={exports:{}};!function(e){var t=bv.exports;e.exports=function(e,n){for(;!Object.prototype.hasOwnProperty.call(e,n)&&null!==(e=t(e)););return e},e.exports.__esModule=!0,e.exports.default=e.exports}(Cy),function(e){var t=Cy.exports;function n(){return"undefined"!=typeof Reflect&&Reflect.get?(e.exports=n=Reflect.get,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=n=function(e,n,r){var i=t(e,n);if(i){var a=Object.getOwnPropertyDescriptor(i,n);return a.get?a.get.call(arguments.length<3?e:r):a.value}},e.exports.__esModule=!0,e.exports.default=e.exports),n.apply(this,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(Ty);var Oy={exports:{}};!function(e){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports}(Oy),Object.defineProperty(Iy,"__esModule",{value:!0});var Py=hv.exports,Ay=pv.exports,jy=mv.exports,My=Ty.exports,Ly=vv.exports,Uy=gv.exports,Ny=bv.exports,Dy=Oy.exports;function Fy(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var By=Fy(cv.exports),qy=Fy(Py),zy=Fy(Ay),Wy=Fy(jy),Ky=Fy(My),Vy=Fy(Ly),$y=Fy(Uy),Gy=Fy(Ny),Jy=Fy(Dy);function Hy(){}function Yy(){Yy.init.call(this)}function Qy(e){return void 0===e._maxListeners?Yy.defaultMaxListeners:e._maxListeners}function Xy(e,t,n){if(t)e.call(n);else for(var r=e.length,i=og(e,r),a=0;a<r;++a)i[a].call(n)}function Zy(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=og(e,i),o=0;o<i;++o)a[o].call(n,r)}function eg(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=og(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function tg(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=og(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function ng(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=og(e,i),o=0;o<i;++o)a[o].apply(n,r)}function rg(e,t,n,r){var i,a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new Hy,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=Qy(e))&&i>0&&o.length>i){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else o=a[t]=n,++e._eventsCount;return e}function ig(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function ag(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function og(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function sg(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Gy.default(e);if(t){var i=Gy.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return $y.default(this,n)}}Hy.prototype=Object.create(null),Yy.EventEmitter=Yy,Yy.usingDomains=!1,Yy.prototype.domain=void 0,Yy.prototype._events=void 0,Yy.prototype._maxListeners=void 0,Yy.defaultMaxListeners=10,Yy.init=function(){this.domain=null,Yy.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Hy,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Yy.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Yy.prototype.getMaxListeners=function(){return Qy(this)},Yy.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:Xy(n,l,this);break;case 2:Zy(n,l,this,arguments[1]);break;case 3:eg(n,l,this,arguments[1],arguments[2]);break;case 4:tg(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];ng(n,l,this,i)}return!0},Yy.prototype.addListener=function(e,t){return rg(this,e,t,!1)},Yy.prototype.on=Yy.prototype.addListener,Yy.prototype.prependListener=function(e,t){return rg(this,e,t,!0)},Yy.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,ig(this,e,t)),this},Yy.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,ig(this,e,t)),this},Yy.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new Hy:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new Hy,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},Yy.prototype.off=function(e,t){return this.removeListener(e,t)},Yy.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Hy,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new Hy:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Hy,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Yy.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},Yy.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):ag.call(e,t)},Yy.prototype.listenerCount=ag,Yy.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var ug=function(e){Vy.default(n,e);var t=sg(n);function n(){var e;return qy.default(this,n),e=t.call(this),Jy.default(Wy.default(e),"eventHistory",new Map),e}return zy.default(n,[{key:"on",value:function(e,t){return Ky.default(Gy.default(n.prototype),"on",this).call(this,e,t)}},{key:"once",value:function(e,t){return Ky.default(Gy.default(n.prototype),"once",this).call(this,e,t)}},{key:"off",value:function(e,t){return Ky.default(Gy.default(n.prototype),"off",this).call(this,e,t)}},{key:"emit",value:function(e){for(var t,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return this.eventHistory.set(e,i),(t=Ky.default(Gy.default(n.prototype),"emit",this)).call.apply(t,[this,e].concat(i))}},{key:"addListener",value:function(e,t){return Ky.default(Gy.default(n.prototype),"addListener",this).call(this,e,t)}},{key:"removeListener",value:function(e,t){return Ky.default(Gy.default(n.prototype),"removeListener",this).call(this,e,t)}},{key:"addListenerWithReplay",value:function(e,t){var n=this.eventHistory.get(e);return void 0!==n&&t.apply(void 0,By.default(n)),this.addListener(e,t)}},{key:"onWithReplay",value:function(e,t){return this.addListenerWithReplay(e,t)}},{key:"onceWithReplay",value:function(e,t){var r=this.eventHistory.get(e);return void 0!==r?(t.apply(void 0,By.default(r)),this):Ky.default(Gy.default(n.prototype),"once",this).call(this,e,t)}}]),n}(Yy),cg=Iy.ReplayEventEmitter=ug;function lg(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}var fg=Cf.scope("User"),User=function(e){Oa(User,e);var t,n,r,i,a,o,s,u=lg(User);function User(e,t,n,r){var i;return Na(this,User),Ma(Ta(i=u.call(this)),"promiseToFetch",null),Ma(Ta(i),"updated","updated"),Ma(Ta(i),"userSubscribed","userSubscribed"),Ma(Ta(i),"userUnsubscribed","userUnsubscribed"),i.services=r,i.subscribed="initializing",i.setMaxListeners(0),i.state={identity:e,entityName:t,friendlyName:null,attributes:{},online:null,notifiable:null},i._initializationPromise=new Promise((function(e){i._resolveInitializationPromise=e})),null!==n&&i._resolveInitialization(n,e,t,!1),i}return Ua(User,[{key:"identity",get:function(){return this.state.identity},set:function(e){this.state.identity=e}},{key:"entityName",set:function(e){this.state.entityName=e}},{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"subscribed"==this.subscribed}},{key:"_update",value:(s=Ia(Kc.mark((function e(t,n){var r,i;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:r=[],fg.debug("User for",this.state.identity,"updated:",t,n),e.t0=t,e.next="friendlyName"===e.t0?7:"attributes"===e.t0?9:"reachability"===e.t0?12:15;break;case 7:return this.state.friendlyName!==n.value&&(r.push("friendlyName"),this.state.friendlyName=n.value),e.abrupt("break",16);case 9:return i=yh(n.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),fg),mh(this.state.attributes,i)||(this.state.attributes=i,r.push("attributes")),e.abrupt("break",16);case 12:return this.state.online!==n.online&&(this.state.online=n.online,r.push("reachabilityOnline")),this.state.notifiable!==n.notifiable&&(this.state.notifiable=n.notifiable,r.push("reachabilityNotifiable")),e.abrupt("break",16);case 15:return e.abrupt("return");case 16:r.length>0&&this.emit("updated",{user:this,updateReasons:r});case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_updateReachabilityInfo",value:(o=Ia(Kc.mark((function e(t,n){var r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){e.next=4;break}return e.abrupt("return",Promise.resolve());case 4:return e.abrupt("return",t.get("reachability").then(n).catch((function(e){fg.warn("Failed to get reachability info for ",r.state.identity,e)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"_fetch",value:(a=Ia(Kc.mark((function e(){var t=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(this.state.entityName){e.next=4;break}return e.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then((function(e){return t.entity=e,e.on("itemUpdated",(function(e){return fg.debug(t.state.entityName+" ("+t.state.identity+") itemUpdated: "+e.item.key),t._update(e.item.key,e.item.data)})),e.on("itemAdded",(function(e){return fg.debug(t.state.entityName+" ("+t.state.identity+") itemAdded: "+e.item.key),t._update(e.item.key,e.item.data)})),Promise.all([e.get("friendlyName").then((function(e){return t._update(e.key,e.data)})),e.get("attributes").then((function(e){return t._update(e.key,e.data)})),t._updateReachabilityInfo(e,(function(e){return t._update(e.key,e.data)}))])})).then((function(){return fg.debug("Fetched for",t.identity),t.subscribed="subscribed",t.emit("userSubscribed",t),t})).catch((function(e){throw t.promiseToFetch=null,e})),e.abrupt("return",this.promiseToFetch);case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_ensureFetched",value:(i=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:return e.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateAttributes",value:(r=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if("unsubscribed"!=this.subscribed){e.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return e.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(t)});case 6:return e.abrupt("return",this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"updateFriendlyName",value:(n=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if("unsubscribed"!=this.subscribed){e.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return e.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:t});case 6:return e.abrupt("return",this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribe",value:(t=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){e.next=9;break}return e.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_resolveInitialization",value:function(e,t,n,r){this.configuration=e,this.identity=t,this.entityName=n,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),r&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),User}(cg);function dg(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a=[],o=!0,s=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}}(e,t)||_y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}$c([wy(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],User.prototype,"updateAttributes",null),$c([wy(["string"]),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],User.prototype,"updateFriendlyName",null);var pg={exports:{}},hg=!s((function(){return Object.isExtensible(Object.preventExtensions({}))})),vg=Tn,yg=ut,gg=E,mg=te,bg=Ne.f,wg=At,kg=Rr,_g=hg,xg=!1,Sg=ie("meta"),Eg=0,Rg=Object.isExtensible||function(){return!0},Ig=function(e){bg(e,Sg,{value:{objectID:"O"+Eg++,weakData:{}}})},Tg=pg.exports={enable:function(){Tg.enable=function(){},xg=!0;var e=wg.f,t=[].splice,n={};n[Sg]=1,e(n).length&&(wg.f=function(n){for(var r=e(n),i=0,a=r.length;i<a;i++)if(r[i]===Sg){t.call(r,i,1);break}return r},vg({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:kg.f}))},fastKey:function(e,t){if(!gg(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!mg(e,Sg)){if(!Rg(e))return"F";if(!t)return"E";Ig(e)}return e[Sg].objectID},getWeakData:function(e,t){if(!mg(e,Sg)){if(!Rg(e))return!0;if(!t)return!1;Ig(e)}return e[Sg].weakData},onFreeze:function(e){return _g&&xg&&Rg(e)&&!mg(e,Sg)&&Ig(e),e}};yg[Sg]=!0;var Cg=Tn,Og=a,Pg=wn,Ag=Je.exports,jg=pg.exports,Mg=Jo,Lg=Eo,Ug=E,Ng=s,Dg=rs,Fg=An,Bg=_d,qg=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),a=r?"set":"add",o=Og[e],s=o&&o.prototype,u=o,c={},l=function(e){var t=s[e];Ag(s,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!Ug(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return i&&!Ug(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!Ug(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(Pg(e,"function"!=typeof o||!(i||s.forEach&&!Ng((function(){(new o).entries().next()})))))u=n.getConstructor(t,e,r,a),jg.enable();else if(Pg(e,!0)){var f=new u,d=f[a](i?{}:-0,1)!=f,p=Ng((function(){f.has(1)})),h=Dg((function(e){new o(e)})),v=!i&&Ng((function(){for(var e=new o,t=5;t--;)e[a](t,t);return!e.has(-0)}));h||((u=t((function(t,n){Lg(t,u,e);var i=Bg(new o,t,u);return null!=n&&Mg(n,i[a],{that:i,AS_ENTRIES:r}),i}))).prototype=s,s.constructor=u),(p||v)&&(l("delete"),l("has"),r&&l("get")),(v||d)&&l(a),i&&s.clear&&delete s.clear}return c[e]=u,Cg({global:!0,forced:u!=o},c),Fg(u,e),i||n.setStrong(u,e,r),u},zg=Ne.f,Wg=nr,Kg=vo,Vg=Fr,$g=Eo,Gg=Jo,Jg=pf,Hg=So,Yg=u,Qg=pg.exports.fastKey,Xg=xt.set,Zg=xt.getterFor,em={getConstructor:function(e,t,n,r){var i=e((function(e,a){$g(e,i,t),Xg(e,{type:t,index:Wg(null),first:void 0,last:void 0,size:0}),Yg||(e.size=0),null!=a&&Gg(a,e[r],{that:e,AS_ENTRIES:n})})),a=Zg(t),o=function(e,t,n){var r,i,o=a(e),u=s(e,t);return u?u.value=n:(o.last=u={index:i=Qg(t,!0),key:t,value:n,previous:r=o.last,next:void 0,removed:!1},o.first||(o.first=u),r&&(r.next=u),Yg?o.size++:e.size++,"F"!==i&&(o.index[i]=u)),e},s=function(e,t){var n,r=a(e),i=Qg(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return Kg(i.prototype,{clear:function(){for(var e=a(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,Yg?e.size=0:this.size=0},delete:function(e){var t=this,n=a(t),r=s(t,e);if(r){var i=r.next,o=r.previous;delete n.index[r.index],r.removed=!0,o&&(o.next=i),i&&(i.previous=o),n.first==r&&(n.first=i),n.last==r&&(n.last=o),Yg?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=a(this),r=Vg(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!s(this,e)}}),Kg(i.prototype,n?{get:function(e){var t=s(this,e);return t&&t.value},set:function(e,t){return o(this,0===e?0:e,t)}}:{add:function(e){return o(this,e=0===e?0:e,e)}}),Yg&&zg(i.prototype,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=Zg(t),a=Zg(r);Jg(e,t,(function(e,t){Xg(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),Hg(t)}};qg("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),em);var tm={};Object.defineProperty(tm,"__esModule",{value:!0});var nm=pv.exports,rm=mv.exports,im=vv.exports,am=gv.exports,om=bv.exports,sm=Oy.exports;function um(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var cm=um(hv.exports),lm=um(nm),fm=um(rm),dm=um(im),pm=um(am),hm=um(om),vm=um(sm);function ym(){}function gm(){gm.init.call(this)}function mm(e){return void 0===e._maxListeners?gm.defaultMaxListeners:e._maxListeners}function bm(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Im(e,r),a=0;a<r;++a)i[a].call(n)}function wm(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=Im(e,i),o=0;o<i;++o)a[o].call(n,r)}function km(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=Im(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function _m(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=Im(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function xm(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=Im(e,i),o=0;o<i;++o)a[o].apply(n,r)}function Sm(e,t,n,r){var i,a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new ym,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=mm(e))&&i>0&&o.length>i){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else o=a[t]=n,++e._eventsCount;return e}function Em(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function Rm(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function Im(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function Tm(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=hm.default(e);if(t){var i=hm.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pm.default(this,n)}}ym.prototype=Object.create(null),gm.EventEmitter=gm,gm.usingDomains=!1,gm.prototype.domain=void 0,gm.prototype._events=void 0,gm.prototype._maxListeners=void 0,gm.defaultMaxListeners=10,gm.init=function(){this.domain=null,gm.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new ym,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},gm.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},gm.prototype.getMaxListeners=function(){return mm(this)},gm.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:bm(n,l,this);break;case 2:wm(n,l,this,arguments[1]);break;case 3:km(n,l,this,arguments[1],arguments[2]);break;case 4:_m(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];xm(n,l,this,i)}return!0},gm.prototype.addListener=function(e,t){return Sm(this,e,t,!1)},gm.prototype.on=gm.prototype.addListener,gm.prototype.prependListener=function(e,t){return Sm(this,e,t,!0)},gm.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Em(this,e,t)),this},gm.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Em(this,e,t)),this},gm.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new ym:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new ym,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},gm.prototype.off=function(e,t){return this.removeListener(e,t)},gm.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new ym,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new ym:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new ym,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},gm.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},gm.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Rm.call(e,t)},gm.prototype.listenerCount=Rm,gm.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Cm=function(e){dm.default(n,e);var t=Tm(n);function n(e){var r;return cm.default(this,n),r=t.call(this),vm.default(fm.default(r),"timeout",null),vm.default(fm.default(r),"startTimestamp",-1),r.minDelay=e.min,r.maxDelay=e.max,r.initialDelay=e.initial||0,r.maxAttemptsCount=e.maxAttemptsCount||0,r.maxAttemptsTime=e.maxAttemptsTime||0,r.randomness=e.randomness||0,r.inProgress=!1,r.attemptNum=0,r.prevDelay=0,r.currDelay=0,r}return lm.default(n,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(e){if("number"==typeof e)return this.prevDelay=0,this.currDelay=e,e;if(0==this.attemptNum)return this.initialDelay;if(1==this.attemptNum)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var t=this.currDelay+this.prevDelay;return this.maxDelay&&t>this.maxDelay&&(this.currDelay=this.maxDelay,t=this.maxDelay),this.currDelay=t,t}},{key:"randomize",value:function(e){var t=e*this.randomness,n=Math.round(Math.random()*t*2-t);return Math.max(0,e+n)}},{key:"scheduleAttempt",value:function(e){var t=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt count limit reached"));var n=this.nextDelay(e);if(n=this.randomize(n),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+n)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt time limit reached"));this.timeout=setTimeout((function(){return t.attempt()}),n)}},{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(e){this.emit("succeeded",e)}},{key:"failed",value:function(e,t){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(t)}}]),n}(gm),Om=function(e){dm.default(n,e);var t=Tm(n);function n(e){var r;return cm.default(this,n),r=t.call(this),vm.default(fm.default(r),"resolve",(function(){})),vm.default(fm.default(r),"reject",(function(){})),r.retrier=new Cm(e),r}return lm.default(n,[{key:"run",value:function(e){var t=this;return this.retrier.on("attempt",(function(){e().then((function(e){return t.retrier.succeeded(e)})).catch((function(e){return t.retrier.failed(e)}))})),this.retrier.on("succeeded",(function(e){return t.resolve(e)})),this.retrier.on("cancelled",(function(){return t.reject(new Error("Cancelled"))})),this.retrier.on("failed",(function(e){return t.reject(e)})),new Promise((function(e,n){t.resolve=e,t.reject=n,t.retrier.start()}))}},{key:"cancel",value:function(){this.retrier.cancel()}}]),n}(gm);function Pm(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=hm.default(e);if(t){var i=hm.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pm.default(this,n)}}function Am(e){return null!=e}var jm=function(e){dm.default(n,e);var t=Pm(n);function n(e){var r;cm.default(this,n),r=t.call(this),vm.default(fm.default(r),"backoffDelay",0),vm.default(fm.default(r),"nextBackoffDelay",0),vm.default(fm.default(r),"backoffNumber",0),vm.default(fm.default(r),"timeoutID",null),vm.default(fm.default(r),"maxNumberOfRetry",-1);var i=e=e||{},a=i.initialDelay,o=i.maxDelay,s=i.randomisationFactor,u=i.factor;if(Am(a)&&a<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(Am(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(Am(s)&&(s<0||s>1))throw new Error("The randomisation factor must be between 0 and 1.");if(Am(u)&&u<=1)throw new Error("Exponential factor should be greater than 1.");if(r.initialDelay=a||100,r.maxDelay=o||1e4,r.maxDelay<=r.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return r.randomisationFactor=s||0,r.factor=u||2,r.reset(),r}return lm.default(n,[{key:"backoff",value:function(e){null==this.timeoutID&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",e),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,e)))}},{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(e){if(e<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(e));this.maxNumberOfRetry=e}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var e=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*e))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(e){return new n(e)}}]),n}(gm),Mm=tm.AsyncRetrier=Om;tm.Backoff=jm;var Lm=tm.Retrier=Cm;function Um(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Nm(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nm(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Nm(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Dm=function(){function e(t,n){Na(this,e),this.configuration=t,this.services=n,this.cache=new Map,this.cacheLifetime=100*this.configuration.httpCacheInterval,this.cleanupCache()}return Ua(e,[{key:"isExpired",value:function(e){return!this.cacheLifetime||Date.now()-e>this.cacheLifetime}},{key:"cleanupCache",value:function(){var e,t=Um(this.cache);try{for(t.s();!(e=t.n()).done;){var n=dg(e.value,2),r=n[0],i=n[1];this.isExpired(i.timestamp)&&this.cache.delete(r)}}catch(e){t.e(e)}finally{t.f()}0===this.cache.size&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var e=this;this.timer=this.timer||setInterval((function(){return e.cleanupCache()}),2*this.cacheLifetime)}},{key:"executeWithRetry",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((function(r,i){var a=[502,503,504];n&&a.push(429);var o=new Lm(t.configuration.backoffConfiguration);o.on("attempt",(function(){e().then((function(e){return o.succeeded(e)})).catch((function(e){a.indexOf(e.status)>-1||"Twilsock disconnected"===e.message?o.failed(e):(o.removeAllListeners(),o.cancel(),i(e))}))})),o.on("succeeded",(function(e){r(e)})),o.on("cancelled",(function(e){return i(e)})),o.on("failed",(function(e){return i(e)})),o.start()}))}},{key:"get",value:function(){var e=Ia(Kc.mark((function e(t){var n,r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))||this.isExpired(n.timestamp)){e.next=3;break}return e.abrupt("return",n.response);case 3:return r={},e.next=6,this.executeWithRetry((function(){return a.services.transport.get(t,r,a.configuration.productId)}),this.configuration.retryWhenThrottled);case 6:return i=e.sent,this.cache.set(t,{response:i,timestamp:Date.now()}),this.pokeTimer(),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}(),Fm=Ua((function e(){Na(this,e)}));Ma(Fm,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),Ma(Fm,"NEW_MESSAGE","twilio.conversations.new_message"),Ma(Fm,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),Ma(Fm,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),Ma(Fm,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");var Bm={},qm={exports:{}};!function(e){function t(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var n=this,r=arguments;return new Promise((function(i,a){var o=e.apply(n,r);function s(e){t(o,i,a,s,u,"next",e)}function u(e){t(o,i,a,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports}(qm);var zm=r(Vc),Wm=Je.exports,Km=Fe,Vm=Er,$m=s,Gm=tp,Jm="toString",Hm=RegExp.prototype,Ym=Hm.toString,Qm=$m((function(){return"/a/b"!=Ym.call({source:"a",flags:"b"})})),Xm=Ym.name!=Jm;(Qm||Xm)&&Wm(RegExp.prototype,Jm,(function(){var e=Km(this),t=Vm(e.source),n=e.flags;return"/"+t+"/"+Vm(void 0===n&&e instanceof RegExp&&!("flags"in Hm)?Gm.call(e):n)}),{unsafe:!0}),qg("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),em);var Zm={exports:{}};!function(e,t){var n;n=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t,n){e.exports=function(e,t){var n,r,i;for(n=1;n<arguments.length;n++)for(i in r=arguments[n])r.hasOwnProperty(i)&&(e[i]=r[i]);return e}},function(e,t,n){var r=n(0);e.exports={build:function(e,t){var n,i,a,o=t.plugins;for(n=0,i=o.length;n<i;n++)(a=o[n]).methods&&r(e,a.methods),a.properties&&Object.defineProperties(e,a.properties)},hook:function(e,t,n){var r,i,a,o,s=e.config.plugins,u=[e.context];for(n&&(u=u.concat(n)),r=0,i=s.length;r<i;r++)o=s[r],(a=s[r][t])&&a.apply(o,u)}}},function(e,t,n){function r(e){if(0===e.length)return e;var t,n,r=e.split(/[_-]/);if(1===r.length&&r[0][0].toLowerCase()===r[0][0])return e;for(n=r[0].toLowerCase(),t=1;t<r.length;t++)n=n+r[t].charAt(0).toUpperCase()+r[t].substring(1).toLowerCase();return n}r.prepended=function(e,t){return e+(t=r(t))[0].toUpperCase()+t.substring(1)},e.exports=r},function(e,t,n){var r=n(0),i=n(2);function a(e,t){e=e||{},this.options=e,this.defaults=t.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(e.init),this.data=this.configureData(e.data),this.methods=this.configureMethods(e.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(e.transitions||[]),this.plugins=this.configurePlugins(e.plugins,t.plugin)}r(a.prototype,{addState:function(e){this.map[e]||(this.states.push(e),this.addStateLifecycleNames(e),this.map[e]={})},addStateLifecycleNames:function(e){this.lifecycle.onEnter[e]=i.prepended("onEnter",e),this.lifecycle.onLeave[e]=i.prepended("onLeave",e),this.lifecycle.on[e]=i.prepended("on",e)},addTransition:function(e){this.transitions.indexOf(e)<0&&(this.transitions.push(e),this.addTransitionLifecycleNames(e))},addTransitionLifecycleNames:function(e){this.lifecycle.onBefore[e]=i.prepended("onBefore",e),this.lifecycle.onAfter[e]=i.prepended("onAfter",e),this.lifecycle.on[e]=i.prepended("on",e)},mapTransition:function(e){var t=e.name,n=e.from,r=e.to;return this.addState(n),"function"!=typeof r&&this.addState(r),this.addTransition(t),this.map[n][t]=e,e},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(e){return"string"==typeof e?this.mapTransition(r({},this.defaults.init,{to:e,active:!0})):"object"===Pa(e)?this.mapTransition(r({},this.defaults.init,e,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(e){return"function"==typeof e?e:"object"===Pa(e)?function(){return e}:function(){return{}}},configureMethods:function(e){return e||{}},configurePlugins:function(e,t){var n,r,i;for(n=0,r=(e=e||[]).length;n<r;n++)"function"==typeof(i=e[n])&&(e[n]=i=i()),i.configure&&i.configure(this);return e},configureTransitions:function(e){var t,n,r,i,a,o=this.defaults.wildcard;for(n=0;n<e.length;n++)for(r=e[n],i=Array.isArray(r.from)?r.from:[r.from||o],a=r.to||o,t=0;t<i.length;t++)this.mapTransition({name:r.name,from:i[t],to:a})},transitionFor:function(e,t){var n=this.defaults.wildcard;return this.map[e][t]||this.map[n][t]},transitionsFor:function(e){var t=this.defaults.wildcard;return Object.keys(this.map[e]).concat(Object.keys(this.map[t]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),e.exports=a},function(e,t,n){var r=n(0),i=n(6),a=n(1),o=[null,[]];function s(e,t){this.context=e,this.config=t,this.state=t.init.from,this.observers=[e]}r(s.prototype,{init:function(e){if(r(this.context,this.config.data.apply(this.context,e)),a.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(e){return Array.isArray(e)?e.indexOf(this.state)>=0:this.state===e},isPending:function(){return this.pending},can:function(e){return!this.isPending()&&!!this.seek(e)},cannot:function(e){return!this.can(e)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(e,t){var n=this.config.defaults.wildcard,r=this.config.transitionFor(this.state,e),i=r&&r.to;return"function"==typeof i?i.apply(this.context,t):i===n?this.state:i},fire:function(e,t){return this.transit(e,this.state,this.seek(e,t),t)},transit:function(e,t,n,r){var i=this.config.lifecycle,a=this.config.options.observeUnchangedState||t!==n;return n?this.isPending()?this.context.onPendingTransition(e,t,n):(this.config.addState(n),this.beginTransit(),r.unshift({transition:e,from:t,to:n,fsm:this.context}),this.observeEvents([this.observersForEvent(i.onBefore.transition),this.observersForEvent(i.onBefore[e]),a?this.observersForEvent(i.onLeave.state):o,a?this.observersForEvent(i.onLeave[t]):o,this.observersForEvent(i.on.transition),a?["doTransit",[this]]:o,a?this.observersForEvent(i.onEnter.state):o,a?this.observersForEvent(i.onEnter[n]):o,a?this.observersForEvent(i.on[n]):o,this.observersForEvent(i.onAfter.transition),this.observersForEvent(i.onAfter[e]),this.observersForEvent(i.on[e])],r)):this.context.onInvalidTransition(e,t,n)},beginTransit:function(){this.pending=!0},endTransit:function(e){return this.pending=!1,e},failTransit:function(e){throw this.pending=!1,e},doTransit:function(e){this.state=e.to},observe:function(e){if(2===e.length){var t={};t[e[0]]=e[1],this.observers.push(t)}else this.observers.push(e[0])},observersForEvent:function(e){for(var t,n=0,r=this.observers.length,i=[];n<r;n++)(t=this.observers[n])[e]&&i.push(t);return[e,i,!0]},observeEvents:function(e,t,n,r){if(0===e.length)return this.endTransit(void 0===r||r);var i=e[0][0],o=e[0][1],s=e[0][2];if(t[0].event=i,i&&s&&i!==n&&a.hook(this,"lifecycle",t),0===o.length)return e.shift(),this.observeEvents(e,t,i,r);var u=o.shift(),c=u[i].apply(u,t);return c&&"function"==typeof c.then?c.then(this.observeEvents.bind(this,e,t,i)).catch(this.failTransit.bind(this)):!1===c?this.endTransit(!1):this.observeEvents(e,t,i,c)},onInvalidTransition:function(e,t,n){throw new i("transition is invalid in current state",e,t,n,this.state)},onPendingTransition:function(e,t,n){throw new i("transition is invalid while previous transition is still in progress",e,t,n,this.state)}}),e.exports=s},function(e,t,n){var r=n(0),i=n(2),a=n(1),o=n(3),s=n(4),u={is:function(e){return this._fsm.is(e)},can:function(e){return this._fsm.can(e)},cannot:function(e){return this._fsm.cannot(e)},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(e,t,n){return this._fsm.onInvalidTransition(e,t,n)},onPendingTransition:function(e,t,n){return this._fsm.onPendingTransition(e,t,n)}},c={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(e){throw Error("use transitions to change state")}}};function l(e){return f(this||{},e)}function f(e,t){return d(e,new o(t,l)),e._fsm(),e}function d(e,t){if("object"!==Pa(e)||Array.isArray(e))throw Error("StateMachine can only be applied to objects");a.build(e,t),Object.defineProperties(e,c),r(e,u),r(e,t.methods),t.allTransitions().forEach((function(t){e[i(t)]=function(){return this._fsm.fire(t,[].slice.call(arguments))}})),e._fsm=function(){this._fsm=new s(this,t),this._fsm.init(arguments)}}l.version="3.0.1",l.factory=function(){var e,t;"function"==typeof arguments[0]?(e=arguments[0],t=arguments[1]||{}):(e=function(){this._fsm.apply(this,arguments)},t=arguments[0]||{});var n=new o(t,l);return d(e.prototype,n),e.prototype._fsm.config=n,e},l.apply=f,l.defaults={wildcard:"*",init:{name:"init",from:"none"}},e.exports=l},function(e,t,n){e.exports=function(e,t,n,r,i){this.message=e,this.transition=t,this.from=n,this.to=r,this.current=i}}])},e.exports=n()}(Zm);var eb,tb={},nb={},rb={};Object.defineProperty(rb,"__esModule",{value:!0}),rb.default=function(){if(!eb&&!(eb="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return eb(ib)};var ib=new Uint8Array(16);var ab={},ob={},sb={};Object.defineProperty(sb,"__esModule",{value:!0}),sb.default=void 0;sb.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Object.defineProperty(ob,"__esModule",{value:!0}),ob.default=void 0;var ub,cb=(ub=sb)&&ub.__esModule?ub:{default:ub};var lb=function(e){return"string"==typeof e&&cb.default.test(e)};ob.default=lb,Object.defineProperty(ab,"__esModule",{value:!0}),ab.default=void 0,ab.unsafeStringify=hb;var fb=function(e){return e&&e.__esModule?e:{default:e}}(ob);for(var db=[],pb=0;pb<256;++pb)db.push((pb+256).toString(16).slice(1));function hb(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return db[e[t+0]]+db[e[t+1]]+db[e[t+2]]+db[e[t+3]]+"-"+db[e[t+4]]+db[e[t+5]]+"-"+db[e[t+6]]+db[e[t+7]]+"-"+db[e[t+8]]+db[e[t+9]]+"-"+db[e[t+10]]+db[e[t+11]]+db[e[t+12]]+db[e[t+13]]+db[e[t+14]]+db[e[t+15]]}var vb=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=hb(e,t);if(!(0,fb.default)(n))throw TypeError("Stringified UUID is invalid");return n};ab.default=vb,Object.defineProperty(nb,"__esModule",{value:!0}),nb.default=void 0;var yb,gb,mb=function(e){return e&&e.__esModule?e:{default:e}}(rb),bb=ab;var wb=0,kb=0;var _b=function(e,t,n){var r=t&&n||0,i=t||new Array(16),a=(e=e||{}).node||yb,o=void 0!==e.clockseq?e.clockseq:gb;if(null==a||null==o){var s=e.random||(e.rng||mb.default)();null==a&&(a=yb=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==o&&(o=gb=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:Date.now(),c=void 0!==e.nsecs?e.nsecs:kb+1,l=u-wb+(c-kb)/1e4;if(l<0&&void 0===e.clockseq&&(o=o+1&16383),(l<0||u>wb)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");wb=u,kb=c,gb=o;var f=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var d=u/4294967296*1e4&268435455;i[r++]=d>>>8&255,i[r++]=255&d,i[r++]=d>>>24&15|16,i[r++]=d>>>16&255,i[r++]=o>>>8|128,i[r++]=255&o;for(var p=0;p<6;++p)i[r+p]=a[p];return t||(0,bb.unsafeStringify)(i)};nb.default=_b;var xb={},Sb={},Eb={};Object.defineProperty(Eb,"__esModule",{value:!0}),Eb.default=void 0;var Rb=function(e){return e&&e.__esModule?e:{default:e}}(ob);var Ib=function(e){if(!(0,Rb.default)(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};Eb.default=Ib,Object.defineProperty(Sb,"__esModule",{value:!0}),Sb.URL=Sb.DNS=void 0,Sb.default=function(e,t,n){function r(e,r,i,a){var o;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=(0,Cb.default)(r)),16!==(null===(o=r)||void 0===o?void 0:o.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+e.length);if(s.set(r),s.set(e,r.length),(s=n(s))[6]=15&s[6]|t,s[8]=63&s[8]|128,i){a=a||0;for(var u=0;u<16;++u)i[a+u]=s[u];return i}return(0,Tb.unsafeStringify)(s)}try{r.name=e}catch(e){}return r.DNS=Ob,r.URL=Pb,r};var Tb=ab,Cb=function(e){return e&&e.__esModule?e:{default:e}}(Eb);var Ob="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Sb.DNS=Ob;var Pb="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Sb.URL=Pb;var Ab={};function jb(e){return 14+(e+64>>>9<<4)+1}function Mb(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function Lb(e,t,n,r,i,a){return Mb((o=Mb(Mb(t,e),Mb(r,a)))<<(s=i)|o>>>32-s,n);var o,s}function Ub(e,t,n,r,i,a,o){return Lb(t&n|~t&r,e,t,i,a,o)}function Nb(e,t,n,r,i,a,o){return Lb(t&r|n&~r,e,t,i,a,o)}function Db(e,t,n,r,i,a,o){return Lb(t^n^r,e,t,i,a,o)}function Fb(e,t,n,r,i,a,o){return Lb(n^(t|~r),e,t,i,a,o)}Object.defineProperty(Ab,"__esModule",{value:!0}),Ab.default=void 0;var Bb=function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(15&a),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[jb(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,u=r,c=i,l=a;n=Ub(n,r,i,a,e[o],7,-680876936),a=Ub(a,n,r,i,e[o+1],12,-389564586),i=Ub(i,a,n,r,e[o+2],17,606105819),r=Ub(r,i,a,n,e[o+3],22,-1044525330),n=Ub(n,r,i,a,e[o+4],7,-176418897),a=Ub(a,n,r,i,e[o+5],12,1200080426),i=Ub(i,a,n,r,e[o+6],17,-1473231341),r=Ub(r,i,a,n,e[o+7],22,-45705983),n=Ub(n,r,i,a,e[o+8],7,1770035416),a=Ub(a,n,r,i,e[o+9],12,-1958414417),i=Ub(i,a,n,r,e[o+10],17,-42063),r=Ub(r,i,a,n,e[o+11],22,-1990404162),n=Ub(n,r,i,a,e[o+12],7,1804603682),a=Ub(a,n,r,i,e[o+13],12,-40341101),i=Ub(i,a,n,r,e[o+14],17,-1502002290),n=Nb(n,r=Ub(r,i,a,n,e[o+15],22,1236535329),i,a,e[o+1],5,-165796510),a=Nb(a,n,r,i,e[o+6],9,-1069501632),i=Nb(i,a,n,r,e[o+11],14,643717713),r=Nb(r,i,a,n,e[o],20,-373897302),n=Nb(n,r,i,a,e[o+5],5,-701558691),a=Nb(a,n,r,i,e[o+10],9,38016083),i=Nb(i,a,n,r,e[o+15],14,-660478335),r=Nb(r,i,a,n,e[o+4],20,-405537848),n=Nb(n,r,i,a,e[o+9],5,568446438),a=Nb(a,n,r,i,e[o+14],9,-1019803690),i=Nb(i,a,n,r,e[o+3],14,-187363961),r=Nb(r,i,a,n,e[o+8],20,1163531501),n=Nb(n,r,i,a,e[o+13],5,-1444681467),a=Nb(a,n,r,i,e[o+2],9,-51403784),i=Nb(i,a,n,r,e[o+7],14,1735328473),n=Db(n,r=Nb(r,i,a,n,e[o+12],20,-1926607734),i,a,e[o+5],4,-378558),a=Db(a,n,r,i,e[o+8],11,-2022574463),i=Db(i,a,n,r,e[o+11],16,1839030562),r=Db(r,i,a,n,e[o+14],23,-35309556),n=Db(n,r,i,a,e[o+1],4,-1530992060),a=Db(a,n,r,i,e[o+4],11,1272893353),i=Db(i,a,n,r,e[o+7],16,-155497632),r=Db(r,i,a,n,e[o+10],23,-1094730640),n=Db(n,r,i,a,e[o+13],4,681279174),a=Db(a,n,r,i,e[o],11,-358537222),i=Db(i,a,n,r,e[o+3],16,-722521979),r=Db(r,i,a,n,e[o+6],23,76029189),n=Db(n,r,i,a,e[o+9],4,-640364487),a=Db(a,n,r,i,e[o+12],11,-421815835),i=Db(i,a,n,r,e[o+15],16,530742520),n=Fb(n,r=Db(r,i,a,n,e[o+2],23,-995338651),i,a,e[o],6,-198630844),a=Fb(a,n,r,i,e[o+7],10,1126891415),i=Fb(i,a,n,r,e[o+14],15,-1416354905),r=Fb(r,i,a,n,e[o+5],21,-57434055),n=Fb(n,r,i,a,e[o+12],6,1700485571),a=Fb(a,n,r,i,e[o+3],10,-1894986606),i=Fb(i,a,n,r,e[o+10],15,-1051523),r=Fb(r,i,a,n,e[o+1],21,-2054922799),n=Fb(n,r,i,a,e[o+8],6,1873313359),a=Fb(a,n,r,i,e[o+15],10,-30611744),i=Fb(i,a,n,r,e[o+6],15,-1560198380),r=Fb(r,i,a,n,e[o+13],21,1309151649),n=Fb(n,r,i,a,e[o+4],6,-145523070),a=Fb(a,n,r,i,e[o+11],10,-1120210379),i=Fb(i,a,n,r,e[o+2],15,718787259),r=Fb(r,i,a,n,e[o+9],21,-343485551),n=Mb(n,s),r=Mb(r,u),i=Mb(i,c),a=Mb(a,l)}return[n,r,i,a]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(jb(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))};Ab.default=Bb,Object.defineProperty(xb,"__esModule",{value:!0}),xb.default=void 0;var qb=Wb(Sb),zb=Wb(Ab);function Wb(e){return e&&e.__esModule?e:{default:e}}var Kb=(0,qb.default)("v3",48,zb.default);xb.default=Kb;var Vb={},$b={};Object.defineProperty($b,"__esModule",{value:!0}),$b.default=void 0;var Gb={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};$b.default=Gb,Object.defineProperty(Vb,"__esModule",{value:!0}),Vb.default=void 0;var Jb=Qb($b),Hb=Qb(rb),Yb=ab;function Qb(e){return e&&e.__esModule?e:{default:e}}var Xb=function(e,t,n){if(Jb.default.randomUUID&&!t&&!e)return Jb.default.randomUUID();var r=(e=e||{}).random||(e.rng||Hb.default)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return(0,Yb.unsafeStringify)(r)};Vb.default=Xb;var Zb={},ew={};function tw(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function nw(e,t){return e<<t|e>>>32-t}Object.defineProperty(ew,"__esModule",{value:!0}),ew.default=void 0;var rw=function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=new Array(o),u=0;u<o;++u){for(var c=new Uint32Array(16),l=0;l<16;++l)c[l]=e[64*u+4*l]<<24|e[64*u+4*l+1]<<16|e[64*u+4*l+2]<<8|e[64*u+4*l+3];s[u]=c}s[o-1][14]=8*(e.length-1)/Math.pow(2,32),s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=8*(e.length-1)&4294967295;for(var f=0;f<o;++f){for(var d=new Uint32Array(80),p=0;p<16;++p)d[p]=s[f][p];for(var h=16;h<80;++h)d[h]=nw(d[h-3]^d[h-8]^d[h-14]^d[h-16],1);for(var v=n[0],y=n[1],g=n[2],m=n[3],b=n[4],w=0;w<80;++w){var k=Math.floor(w/20),_=nw(v,5)+tw(k,y,g,m)+b+t[k]+d[w]>>>0;b=m,m=g,g=nw(y,30)>>>0,y=v,v=_}n[0]=n[0]+v>>>0,n[1]=n[1]+y>>>0,n[2]=n[2]+g>>>0,n[3]=n[3]+m>>>0,n[4]=n[4]+b>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]};ew.default=rw,Object.defineProperty(Zb,"__esModule",{value:!0}),Zb.default=void 0;var iw=ow(Sb),aw=ow(ew);function ow(e){return e&&e.__esModule?e:{default:e}}var sw=(0,iw.default)("v5",80,aw.default);Zb.default=sw;var uw={};Object.defineProperty(uw,"__esModule",{value:!0}),uw.default=void 0;uw.default="00000000-0000-0000-0000-000000000000";var cw={};Object.defineProperty(cw,"__esModule",{value:!0}),cw.default=void 0;var lw=function(e){return e&&e.__esModule?e:{default:e}}(ob);var fw=function(e){if(!(0,lw.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)};cw.default=fw,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return o.default}});var t=l(nb),n=l(xb),r=l(Vb),i=l(Zb),a=l(uw),o=l(cw),s=l(ob),u=l(ab),c=l(Eb);function l(e){return e&&e.__esModule?e:{default:e}}}(tb);var dw,pw,hw,vw={exports:{}},yw="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,gw=yw,mw=u,bw=a,ww=E,kw=te,_w=Va,xw=Ge,Sw=Je.exports,Ew=Ne.f,Rw=Ul,Iw=bo,Tw=he,Cw=ie,Ow=bw.Int8Array,Pw=Ow&&Ow.prototype,Aw=bw.Uint8ClampedArray,jw=Aw&&Aw.prototype,Mw=Ow&&Rw(Ow),Lw=Pw&&Rw(Pw),Uw=Object.prototype,Nw=Uw.isPrototypeOf,Dw=Tw("toStringTag"),Fw=Cw("TYPED_ARRAY_TAG"),Bw=Cw("TYPED_ARRAY_CONSTRUCTOR"),qw=gw&&!!Iw&&"Opera"!==_w(bw.opera),zw=!1,Ww={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Kw={BigInt64Array:8,BigUint64Array:8},Vw=function(e){if(!ww(e))return!1;var t=_w(e);return kw(Ww,t)||kw(Kw,t)};for(dw in Ww)(hw=(pw=bw[dw])&&pw.prototype)?xw(hw,Bw,pw):qw=!1;for(dw in Kw)(hw=(pw=bw[dw])&&pw.prototype)&&xw(hw,Bw,pw);if((!qw||"function"!=typeof Mw||Mw===Function.prototype)&&(Mw=function(){throw TypeError("Incorrect invocation")},qw))for(dw in Ww)bw[dw]&&Iw(bw[dw],Mw);if((!qw||!Lw||Lw===Uw)&&(Lw=Mw.prototype,qw))for(dw in Ww)bw[dw]&&Iw(bw[dw].prototype,Lw);if(qw&&Rw(jw)!==Lw&&Iw(jw,Lw),mw&&!kw(Lw,Dw))for(dw in zw=!0,Ew(Lw,Dw,{get:function(){return ww(this)?this[Fw]:void 0}}),Ww)bw[dw]&&xw(bw[dw],Fw,dw);var $w={NATIVE_ARRAY_BUFFER_VIEWS:qw,TYPED_ARRAY_CONSTRUCTOR:Bw,TYPED_ARRAY_TAG:zw&&Fw,aTypedArray:function(e){if(Vw(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(Iw&&!Nw.call(Mw,e))throw TypeError("Target is not a typed array constructor");return e},exportTypedArrayMethod:function(e,t,n){if(mw){if(n)for(var r in Ww){var i=bw[r];if(i&&kw(i.prototype,e))try{delete i.prototype[e]}catch(e){}}Lw[e]&&!n||Sw(Lw,e,n?t:qw&&Pw[e]||t)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(mw){if(Iw){if(n)for(r in Ww)if((i=bw[r])&&kw(i,e))try{delete i[e]}catch(e){}if(Mw[e]&&!n)return;try{return Sw(Mw,e,n?t:qw&&Mw[e]||t)}catch(e){}}for(r in Ww)!(i=bw[r])||i[e]&&!n||Sw(i,e,t)}},isView:function(e){if(!ww(e))return!1;var t=_w(e);return"DataView"===t||kw(Ww,t)||kw(Kw,t)},isTypedArray:Vw,TypedArray:Mw,TypedArrayPrototype:Lw},Gw=a,Jw=s,Hw=rs,Yw=$w.NATIVE_ARRAY_BUFFER_VIEWS,Qw=Gw.ArrayBuffer,Xw=Gw.Int8Array,Zw=!Yw||!Jw((function(){Xw(1)}))||!Jw((function(){new Xw(-1)}))||!Hw((function(e){new Xw,new Xw(null),new Xw(1.5),new Xw(e)}),!0)||Jw((function(){return 1!==new Xw(new Qw(2),1,void 0).length})),ek=Lt,tk=Dt,nk=function(e){if(void 0===e)return 0;var t=ek(e),n=tk(t);if(t!==n)throw RangeError("Wrong length or index");return n},rk=Math.abs,ik=Math.pow,ak=Math.floor,ok=Math.log,sk=Math.LN2,uk=X,ck=zt,lk=Dt,fk=function(e){for(var t=uk(this),n=lk(t.length),r=arguments.length,i=ck(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,o=void 0===a?n:ck(a,n);o>i;)t[i++]=e;return t},dk=a,pk=u,hk=yw,vk=Ge,yk=vo,gk=s,mk=Eo,bk=Lt,wk=Dt,kk=nk,_k={pack:function(e,t,n){var r,i,a,o=new Array(n),s=8*n-t-1,u=(1<<s)-1,c=u>>1,l=23===t?ik(2,-24)-ik(2,-77):0,f=e<0||0===e&&1/e<0?1:0,d=0;for((e=rk(e))!=e||e===1/0?(i=e!=e?1:0,r=u):(r=ak(ok(e)/sk),e*(a=ik(2,-r))<1&&(r--,a*=2),(e+=r+c>=1?l/a:l*ik(2,1-c))*a>=2&&(r++,a/=2),r+c>=u?(i=0,r=u):r+c>=1?(i=(e*a-1)*ik(2,t),r+=c):(i=e*ik(2,c-1)*ik(2,t),r=0));t>=8;o[d++]=255&i,i/=256,t-=8);for(r=r<<t|i,s+=t;s>0;o[d++]=255&r,r/=256,s-=8);return o[--d]|=128*f,o},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,a=(1<<i)-1,o=a>>1,s=i-7,u=r-1,c=e[u--],l=127&c;for(c>>=7;s>0;l=256*l+e[u],u--,s-=8);for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;n=256*n+e[u],u--,s-=8);if(0===l)l=1-o;else{if(l===a)return n?NaN:c?-1/0:1/0;n+=ik(2,t),l-=o}return(c?-1:1)*n*ik(2,l-t)}},xk=Ul,Sk=bo,Ek=At.f,Rk=Ne.f,Ik=fk,Tk=An,Ck=xt.get,Ok=xt.set,Pk="ArrayBuffer",Ak="DataView",jk="Wrong index",Mk=dk.ArrayBuffer,Lk=Mk,Uk=dk.DataView,Nk=Uk&&Uk.prototype,Dk=Object.prototype,Fk=dk.RangeError,Bk=_k.pack,qk=_k.unpack,zk=function(e){return[255&e]},Wk=function(e){return[255&e,e>>8&255]},Kk=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Vk=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},$k=function(e){return Bk(e,23,4)},Gk=function(e){return Bk(e,52,8)},Jk=function(e,t){Rk(e.prototype,t,{get:function(){return Ck(this)[t]}})},Hk=function(e,t,n,r){var i=kk(n),a=Ck(e);if(i+t>a.byteLength)throw Fk(jk);var o=Ck(a.buffer).bytes,s=i+a.byteOffset,u=o.slice(s,s+t);return r?u:u.reverse()},Yk=function(e,t,n,r,i,a){var o=kk(n),s=Ck(e);if(o+t>s.byteLength)throw Fk(jk);for(var u=Ck(s.buffer).bytes,c=o+s.byteOffset,l=r(+i),f=0;f<t;f++)u[c+f]=l[a?f:t-f-1]};if(hk){if(!gk((function(){Mk(1)}))||!gk((function(){new Mk(-1)}))||gk((function(){return new Mk,new Mk(1.5),new Mk(NaN),Mk.name!=Pk}))){for(var Qk,Xk=(Lk=function(e){return mk(this,Lk),new Mk(kk(e))}).prototype=Mk.prototype,Zk=Ek(Mk),e_=0;Zk.length>e_;)(Qk=Zk[e_++])in Lk||vk(Lk,Qk,Mk[Qk]);Xk.constructor=Lk}Sk&&xk(Nk)!==Dk&&Sk(Nk,Dk);var t_=new Uk(new Lk(2)),n_=Nk.setInt8;t_.setInt8(0,2147483648),t_.setInt8(1,2147483649),!t_.getInt8(0)&&t_.getInt8(1)||yk(Nk,{setInt8:function(e,t){n_.call(this,e,t<<24>>24)},setUint8:function(e,t){n_.call(this,e,t<<24>>24)}},{unsafe:!0})}else Lk=function(e){mk(this,Lk,Pk);var t=kk(e);Ok(this,{bytes:Ik.call(new Array(t),0),byteLength:t}),pk||(this.byteLength=t)},Uk=function(e,t,n){mk(this,Uk,Ak),mk(e,Lk,Ak);var r=Ck(e).byteLength,i=bk(t);if(i<0||i>r)throw Fk("Wrong offset");if(i+(n=void 0===n?r-i:wk(n))>r)throw Fk("Wrong length");Ok(this,{buffer:e,byteLength:n,byteOffset:i}),pk||(this.buffer=e,this.byteLength=n,this.byteOffset=i)},pk&&(Jk(Lk,"byteLength"),Jk(Uk,"buffer"),Jk(Uk,"byteLength"),Jk(Uk,"byteOffset")),yk(Uk.prototype,{getInt8:function(e){return Hk(this,1,e)[0]<<24>>24},getUint8:function(e){return Hk(this,1,e)[0]},getInt16:function(e){var t=Hk(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Hk(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Vk(Hk(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Vk(Hk(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return qk(Hk(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return qk(Hk(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Yk(this,1,e,zk,t)},setUint8:function(e,t){Yk(this,1,e,zk,t)},setInt16:function(e,t){Yk(this,2,e,Wk,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Yk(this,2,e,Wk,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Yk(this,4,e,Kk,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Yk(this,4,e,Kk,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Yk(this,4,e,$k,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Yk(this,8,e,Gk,t,arguments.length>2?arguments[2]:void 0)}});Tk(Lk,Pk),Tk(Uk,Ak);var r_={ArrayBuffer:Lk,DataView:Uk},i_=Lt,a_=function(e){var t=i_(e);if(t<0)throw RangeError("The argument can't be less than 0");return t},o_=function(e,t){var n=a_(e);if(n%t)throw RangeError("Wrong offset");return n},s_=X,u_=Dt,c_=No,l_=Mo,f_=Oo,d_=Fr,p_=$w.aTypedArrayConstructor,h_=Tn,v_=a,y_=u,g_=Zw,m_=$w,b_=r_,w_=Eo,k_=v,__=Ge,x_=Sv,S_=Dt,E_=nk,R_=o_,I_=_e,T_=te,C_=Va,O_=E,P_=z,A_=nr,j_=bo,M_=At.f,L_=function(e){var t,n,r,i,a,o,s=s_(e),u=arguments.length,c=u>1?arguments[1]:void 0,l=void 0!==c,f=l_(s);if(null!=f&&!f_(f))for(o=(a=c_(s,f)).next,s=[];!(i=o.call(a)).done;)s.push(i.value);for(l&&u>2&&(c=d_(c,arguments[2],2)),n=u_(s.length),r=new(p_(this))(n),t=0;n>t;t++)r[t]=l?c(s[t],t):s[t];return r},U_=Xr.forEach,N_=So,D_=Ne,F_=o,B_=_d,q_=xt.get,z_=xt.set,W_=D_.f,K_=F_.f,V_=Math.round,$_=v_.RangeError,G_=b_.ArrayBuffer,J_=b_.DataView,H_=m_.NATIVE_ARRAY_BUFFER_VIEWS,Y_=m_.TYPED_ARRAY_CONSTRUCTOR,Q_=m_.TYPED_ARRAY_TAG,X_=m_.TypedArray,Z_=m_.TypedArrayPrototype,ex=m_.aTypedArrayConstructor,tx=m_.isTypedArray,nx="BYTES_PER_ELEMENT",rx="Wrong length",ix=function(e,t){for(var n=0,r=t.length,i=new(ex(e))(r);r>n;)i[n]=t[n++];return i},ax=function(e,t){W_(e,t,{get:function(){return q_(this)[t]}})},ox=function(e){var t;return e instanceof G_||"ArrayBuffer"==(t=C_(e))||"SharedArrayBuffer"==t},sx=function(e,t){return tx(e)&&!P_(t)&&t in e&&x_(+t)&&t>=0},ux=function(e,t){return t=I_(t),sx(e,t)?k_(2,e[t]):K_(e,t)},cx=function(e,t,n){return t=I_(t),!(sx(e,t)&&O_(n)&&T_(n,"value"))||T_(n,"get")||T_(n,"set")||n.configurable||T_(n,"writable")&&!n.writable||T_(n,"enumerable")&&!n.enumerable?W_(e,t,n):(e[t]=n.value,e)};y_?(H_||(F_.f=ux,D_.f=cx,ax(Z_,"buffer"),ax(Z_,"byteOffset"),ax(Z_,"byteLength"),ax(Z_,"length")),h_({target:"Object",stat:!0,forced:!H_},{getOwnPropertyDescriptor:ux,defineProperty:cx}),vw.exports=function(e,t,n){var r=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=v_[i],u=s,c=u&&u.prototype,l={},f=function(e,t){W_(e,t,{get:function(){return function(e,t){var n=q_(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=q_(e);n&&(i=(i=V_(i))<0?0:i>255?255:255&i),a.view[o](t*r+a.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};H_?g_&&(u=t((function(e,t,n,a){return w_(e,u,i),B_(O_(t)?ox(t)?void 0!==a?new s(t,R_(n,r),a):void 0!==n?new s(t,R_(n,r)):new s(t):tx(t)?ix(u,t):L_.call(u,t):new s(E_(t)),e,u)})),j_&&j_(u,X_),U_(M_(s),(function(e){e in u||__(u,e,s[e])})),u.prototype=c):(u=t((function(e,t,n,a){w_(e,u,i);var o,s,c,l=0,d=0;if(O_(t)){if(!ox(t))return tx(t)?ix(u,t):L_.call(u,t);o=t,d=R_(n,r);var p=t.byteLength;if(void 0===a){if(p%r)throw $_(rx);if((s=p-d)<0)throw $_(rx)}else if((s=S_(a)*r)+d>p)throw $_(rx);c=s/r}else c=E_(t),o=new G_(s=c*r);for(z_(e,{buffer:o,byteOffset:d,byteLength:s,length:c,view:new J_(o)});l<c;)f(e,l++)})),j_&&j_(u,X_),c=u.prototype=A_(Z_)),c.constructor!==u&&__(c,"constructor",u),__(c,Y_,u),Q_&&__(c,Q_,i),l[i]=u,h_({global:!0,forced:u!=s,sham:!H_},l),nx in u||__(u,nx,r),nx in c||__(c,nx,r),N_(i)}):vw.exports=function(){},(0,vw.exports)("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var lx=Dt,fx=Lt,dx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("at",(function(e){var t=dx(this),n=lx(t.length),r=fx(e),i=r>=0?r:n+r;return i<0||i>=n?void 0:t[i]}));var px=X,hx=zt,vx=Dt,yx=Math.min,gx=[].copyWithin||function(e,t){var n=px(this),r=vx(n.length),i=hx(e,r),a=hx(t,r),o=arguments.length>2?arguments[2]:void 0,s=yx((void 0===o?r:hx(o,r))-a,r-i),u=1;for(a<i&&i<a+s&&(u=-1,a+=s-1,i+=s-1);s-- >0;)a in n?n[i]=n[a]:delete n[i],i+=u,a+=u;return n},mx=gx,bx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("copyWithin",(function(e,t){return mx.call(bx(this),e,t,arguments.length>2?arguments[2]:void 0)}));var wx=Xr.every,kx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("every",(function(e){return wx(kx(this),e,arguments.length>1?arguments[1]:void 0)}));var _x=fk,xx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("fill",(function(e){return _x.apply(xx(this),arguments)}));var Sx=ss,Ex=$w.TYPED_ARRAY_CONSTRUCTOR,Rx=$w.aTypedArrayConstructor,Ix=function(e){return Rx(Sx(e,e[Ex]))},Tx=function(e,t){for(var n=0,r=t.length,i=new e(r);r>n;)i[n]=t[n++];return i},Cx=Ix,Ox=Xr.filter,Px=function(e,t){return Tx(Cx(e),t)},Ax=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("filter",(function(e){var t=Ox(Ax(this),e,arguments.length>1?arguments[1]:void 0);return Px(this,t)}));var jx=Xr.find,Mx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("find",(function(e){return jx(Mx(this),e,arguments.length>1?arguments[1]:void 0)}));var Lx=Xr.findIndex,Ux=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("findIndex",(function(e){return Lx(Ux(this),e,arguments.length>1?arguments[1]:void 0)}));var Nx=Xr.forEach,Dx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("forEach",(function(e){Nx(Dx(this),e,arguments.length>1?arguments[1]:void 0)}));var Fx=Gt.includes,Bx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("includes",(function(e){return Fx(Bx(this),e,arguments.length>1?arguments[1]:void 0)}));var qx=Gt.indexOf,zx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("indexOf",(function(e){return qx(zx(this),e,arguments.length>1?arguments[1]:void 0)}));var Wx=a,Kx=$w,Vx=ed,$x=he("iterator"),Gx=Wx.Uint8Array,Jx=Vx.values,Hx=Vx.keys,Yx=Vx.entries,Qx=Kx.aTypedArray,Xx=Kx.exportTypedArrayMethod,Zx=Gx&&Gx.prototype[$x],eS=!!Zx&&("values"==Zx.name||null==Zx.name),tS=function(){return Jx.call(Qx(this))};Xx("entries",(function(){return Yx.call(Qx(this))})),Xx("keys",(function(){return Hx.call(Qx(this))})),Xx("values",tS,!eS),Xx($x,tS,!eS);var nS=$w.aTypedArray,rS=[].join;(0,$w.exportTypedArrayMethod)("join",(function(e){return rS.apply(nS(this),arguments)}));var iS=S,aS=Lt,oS=Dt,sS=no,uS=Math.min,cS=[].lastIndexOf,lS=!!cS&&1/[1].lastIndexOf(1,-0)<0,fS=sS("lastIndexOf"),dS=lS||!fS?function(e){if(lS)return cS.apply(this,arguments)||0;var t=iS(this),n=oS(t.length),r=n-1;for(arguments.length>1&&(r=uS(r,aS(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:cS,pS=dS,hS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("lastIndexOf",(function(e){return pS.apply(hS(this),arguments)}));var vS=Xr.map,yS=Ix,gS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("map",(function(e){return vS(gS(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(yS(e))(t)}))}));var mS=Un,bS=X,wS=w,kS=Dt,_S=function(e){return function(t,n,r,i){mS(n);var a=bS(t),o=wS(a),s=kS(a.length),u=e?s-1:0,c=e?-1:1;if(r<2)for(;;){if(u in o){i=o[u],u+=c;break}if(u+=c,e?u<0:s<=u)throw TypeError("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=c)u in o&&(i=n(i,o[u],u,a));return i}},xS={left:_S(!1),right:_S(!0)},SS=xS.left,ES=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("reduce",(function(e){return SS(ES(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var RS=xS.right,IS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("reduceRight",(function(e){return RS(IS(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var TS=$w.aTypedArray,CS=$w.exportTypedArrayMethod,OS=Math.floor;CS("reverse",(function(){for(var e,t=this,n=TS(t).length,r=OS(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var PS=Dt,AS=o_,jS=X,MS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("set",(function(e){MS(this);var t=AS(arguments.length>1?arguments[1]:void 0,1),n=this.length,r=jS(e),i=PS(r.length),a=0;if(i+t>n)throw RangeError("Wrong length");for(;a<i;)this[t+a]=r[a++]}),s((function(){new Int8Array(1).set({})})));var LS=Ix,US=$w.aTypedArray,NS=[].slice;(0,$w.exportTypedArrayMethod)("slice",(function(e,t){for(var n=NS.call(US(this),e,t),r=LS(this),i=0,a=n.length,o=new r(a);a>i;)o[i]=n[i++];return o}),s((function(){new Int8Array(1).slice()})));var DS=Xr.some,FS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("some",(function(e){return DS(FS(this),e,arguments.length>1?arguments[1]:void 0)}));var BS=Math.floor,qS=function(e,t){var n=e.length,r=BS(n/2);return n<8?zS(e,t):WS(qS(e.slice(0,r),t),qS(e.slice(r),t),t)},zS=function(e,t){for(var n,r,i=e.length,a=1;a<i;){for(r=a,n=e[a];r&&t(e[r-1],n)>0;)e[r]=e[--r];r!==a++&&(e[r]=n)}return e},WS=function(e,t,n){for(var r=e.length,i=t.length,a=0,o=0,s=[];a<r||o<i;)a<r&&o<i?s.push(n(e[a],t[o])<=0?e[a++]:t[o++]):s.push(a<r?e[a++]:t[o++]);return s},KS=qS,VS=C.match(/firefox\/(\d+)/i),$S=!!VS&&+VS[1],GS=/MSIE|Trident/.test(C),JS=C.match(/AppleWebKit\/(\d+)\./),HS=!!JS&&+JS[1],YS=s,QS=Un,XS=Dt,ZS=KS,eE=$S,tE=GS,nE=U,rE=HS,iE=$w.aTypedArray,aE=$w.exportTypedArrayMethod,oE=a.Uint16Array,sE=oE&&oE.prototype.sort,uE=!!sE&&!YS((function(){var e=new oE(2);e.sort(null),e.sort({})})),cE=!!sE&&!YS((function(){if(nE)return nE<74;if(eE)return eE<67;if(tE)return!0;if(rE)return rE<602;var e,t,n=new oE(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(n.sort((function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));aE("sort",(function(e){var t=this;if(void 0!==e&&QS(e),cE)return sE.call(t,e);iE(t);var n,r=XS(t.length),i=Array(r);for(n=0;n<r;n++)i[n]=t[n];for(i=ZS(t,function(e){return function(t,n){return void 0!==e?+e(t,n)||0:n!=n?-1:t!=t?1:0===t&&0===n?1/t>0&&1/n<0?1:-1:t>n}}(e)),n=0;n<r;n++)t[n]=i[n];return t}),!cE||uE);var lE=Dt,fE=zt,dE=Ix,pE=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("subarray",(function(e,t){var n=pE(this),r=n.length,i=fE(e,r);return new(dE(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,lE((void 0===t?r:fE(t,r))-i))}));var hE=$w,vE=s,yE=a.Int8Array,gE=hE.aTypedArray,mE=hE.exportTypedArrayMethod,bE=[].toLocaleString,wE=[].slice,kE=!!yE&&vE((function(){bE.call(new yE(1))}));mE("toLocaleString",(function(){return bE.apply(kE?wE.call(gE(this)):gE(this),arguments)}),vE((function(){return[1,2].toLocaleString()!=new yE([1,2]).toLocaleString()}))||!vE((function(){yE.prototype.toLocaleString.call([1,2])})));var _E=$w.exportTypedArrayMethod,xE=s,SE=a.Uint8Array,EE=SE&&SE.prototype||{},RE=[].toString,IE=[].join;xE((function(){RE.call({})}))&&(RE=function(){return IE.call(this)});var TE=EE.toString!=RE;_E("toString",RE,TE);var CE=E,OE=g,PE=he("match"),AE=function(e){var t;return CE(e)&&(void 0!==(t=e[PE])?!!t:"RegExp"==OE(e))},jE=Lp,ME=AE,LE=Fe,UE=k,NE=ss,DE=Np,FE=Dt,BE=Er,qE=Vp,zE=Ip,WE=s,KE=np.UNSUPPORTED_Y,VE=[].push,$E=Math.min,GE=4294967295,JE=!WE((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]}));jE("split",(function(e,t,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,n){var r=BE(UE(this)),i=void 0===n?GE:n>>>0;if(0===i)return[];if(void 0===e)return[r];if(!ME(e))return t.call(r,e,i);for(var a,o,s,u=[],c=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,f=new RegExp(e.source,c+"g");(a=zE.call(f,r))&&!((o=f.lastIndex)>l&&(u.push(r.slice(l,a.index)),a.length>1&&a.index<r.length&&VE.apply(u,a.slice(1)),s=a[0].length,l=o,u.length>=i));)f.lastIndex===a.index&&f.lastIndex++;return l===r.length?!s&&f.test("")||u.push(""):u.push(r.slice(l)),u.length>i?u.slice(0,i):u}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t.call(this,e,n)}:t,[function(t,n){var i=UE(this),a=null==t?void 0:t[e];return void 0!==a?a.call(t,i,n):r.call(BE(i),t,n)},function(e,i){var a=LE(this),o=BE(e),s=n(r,a,o,i,r!==t);if(s.done)return s.value;var u=NE(a,RegExp),c=a.unicode,l=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(KE?"g":"y"),f=new u(KE?"^(?:"+a.source+")":a,l),d=void 0===i?GE:i>>>0;if(0===d)return[];if(0===o.length)return null===qE(f,o)?[o]:[];for(var p=0,h=0,v=[];h<o.length;){f.lastIndex=KE?0:h;var y,g=qE(f,KE?o.slice(h):o);if(null===g||(y=$E(FE(f.lastIndex+(KE?h:0)),o.length))===p)h=DE(o,h,c);else{if(v.push(o.slice(p,h)),v.length===d)return v;for(var m=1;m<=g.length-1;m++)if(v.push(g[m]),v.length===d)return v;h=p=y}}return v.push(o.slice(p)),v}]}),!JE,KE);var HE={exports:{}},YE={exports:{}};!function(e){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")},e.exports.__esModule=!0,e.exports.default=e.exports}(YE);var QE={exports:{}},XE={exports:{}};!function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}(XE),function(e){var t=yv.exports,n=XE.exports;function r(i,a,o){return n()?(e.exports=r=Reflect.construct,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=r=function(e,n,r){var i=[null];i.push.apply(i,n);var a=new(Function.bind.apply(e,i));return r&&t(a,r.prototype),a},e.exports.__esModule=!0,e.exports.default=e.exports),r.apply(null,arguments)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(QE),function(e){var t=bv.exports,n=yv.exports,r=YE.exports,i=QE.exports;function a(o){var s="function"==typeof Map?new Map:void 0;return e.exports=a=function(e){if(null===e||!r(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==s){if(s.has(e))return s.get(e);s.set(e,a)}function a(){return i(e,arguments,t(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),n(a,e)},e.exports.__esModule=!0,e.exports.default=e.exports,a(o)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}(HE);var ZE={exports:{}};!function(e,t){(function(){var r={function:!0,object:!0}["undefined"==typeof window?"undefined":Pa(window)]&&window||this,i=t,a=e&&!e.nodeType&&e,o=i&&a&&"object"==Pa(n)&&n;!o||o.global!==o&&o.window!==o&&o.self!==o||(r=o);var s=Math.pow(2,53)-1,u=/\bOpera/,c=Object.prototype,l=c.hasOwnProperty,f=c.toString;function d(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function p(e){return e=m(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:d(e)}function h(e,t){for(var n in e)l.call(e,n)&&t(e[n],n,e)}function v(e){return null==e?d(e):f.call(e).slice(8,-1)}function y(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function g(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=s)for(;++n<r;)t(e[n],n,e);else h(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function m(e){return String(e).replace(/^ +| +$/g,"")}var b=function e(t){var n=r,i=t&&"object"==Pa(t)&&"String"!=v(t);i&&(n=t,t=null);var a=n.navigator||{},o=a.userAgent||"";t||(t=o);var s,c,l=i?!!a.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(f.toString()),d="Object",b=i?d:"ScriptBridgingProxyObject",w=i?d:"Environment",k=i&&n.java?"JavaPackage":v(n.java),_=i?d:"RuntimeObject",x=/\bJava/.test(k)&&n.java,S=x&&v(n.environment)==w,E=x?"a":"α",R=x?"b":"β",I=n.document||{},T=n.operamini||n.opera,C=u.test(C=i&&T?T["[[Class]]"]:v(T))?C:T=null,O=t,P=[],A=null,j=t==o,M=j&&T&&"function"==typeof T.version&&T.version(),L=g([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)})),U=function(e){return g(e,(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)}))}(["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"]),N=B([{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"]),D=function(e){return g(e,(function(e,n,r){return e||(n[N]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(N)]||RegExp("\\b"+y(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r}))}({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}}),F=function(e){return g(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"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 t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),p(e.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])}(e,r,n.label||n)),e}))}(["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 B(e){return g(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=p(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function q(e){return g(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(L&&(L=[L]),/\bAndroid\b/.test(F)&&!N&&(s=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(N=m(s[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),D&&!N?N=B([D]):D&&N&&(N=N.replace(RegExp("^("+y(D)+")[-_.\\s]","i"),D+" ").replace(RegExp("^("+y(D)+")[-_.]?(\\w)","i"),D+" $2")),(s=/\bGoogle TV\b/.exec(N))&&(N=s[0]),/\bSimulator\b/i.test(t)&&(N=(N?N+" ":"")+"Simulator"),"Opera Mini"==U&&/\bOPiOS\b/.test(t)&&P.push("running in Turbo/Uncompressed mode"),"IE"==U&&/\blike iPhone OS\b/.test(t)?(D=(s=e(t.replace(/like iPhone OS/,""))).manufacturer,N=s.product):/^iP/.test(N)?(U||(U="Safari"),F="iOS"+((s=/ OS ([\d_]+)/i.exec(t))?" "+s[1].replace(/_/g,"."):"")):"Konqueror"==U&&/^Linux\b/i.test(F)?F="Kubuntu":D&&"Google"!=D&&(/Chrome/.test(U)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(N))||/\bAndroid\b/.test(F)&&/^Chrome/.test(U)&&/\bVersion\//i.test(t)?(U="Android Browser",F=/\bAndroid\b/.test(F)?F:"Android"):"Silk"==U?(/\bMobi/i.test(t)||(F="Android",P.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&P.unshift("accelerated")):"UC Browser"==U&&/\bUCWEB\b/.test(t)?P.push("speed mode"):"PaleMoon"==U&&(s=/\bFirefox\/([\d.]+)\b/.exec(t))?P.push("identifying as Firefox "+s[1]):"Firefox"==U&&(s=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(F||(F="Firefox OS"),N||(N=s[1])):!U||(s=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(U))?(U&&!N&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(s+"/")+8))&&(U=null),(s=N||D||F)&&(N||D||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(F))&&(U=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(F)?F:s)+" Browser")):"Electron"==U&&(s=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&P.push("Chromium "+s),M||(M=q(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",y(U),"(?:Firefox|Minefield|NetFront)"])),(s=("iCab"==L&&parseFloat(M)>3?"WebKit":/\bOpera\b/.test(U)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(L)&&"WebKit"||!L&&/\bMSIE\b/i.test(t)&&("Mac OS"==F?"Tasman":"Trident")||"WebKit"==L&&/\bPlayStation\b(?! Vita\b)/i.test(U)&&"NetFront")&&(L=[s]),"IE"==U&&(s=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(U+=" Mobile",F="Windows Phone "+(/\+$/.test(s)?s:s+".x"),P.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(U="IE Mobile",F="Windows Phone 8.x",P.unshift("desktop mode"),M||(M=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=U&&"Trident"==L&&(s=/\brv:([\d.]+)/.exec(t))&&(U&&P.push("identifying as "+U+(M?" "+M:"")),U="IE",M=s[1]),j){if(function(e,t){var n=null!=e?Pa(e[t]):"number";return!(/^(?:boolean|number|string|undefined)$/.test(n)||"object"==n&&!e[t])}(n,"global"))if(x&&(O=(s=x.lang.System).getProperty("os.arch"),F=F||s.getProperty("os.name")+" "+s.getProperty("os.version")),S){try{M=n.require("ringo/engine").version.join("."),U="RingoJS"}catch(e){(s=n.system)&&s.global.system==n.system&&(U="Narwhal",F||(F=s[0].os||null))}U||(U="Rhino")}else"object"==Pa(n.process)&&!n.process.browser&&(s=n.process)&&("object"==Pa(s.versions)&&("string"==typeof s.versions.electron?(P.push("Node "+s.versions.node),U="Electron",M=s.versions.electron):"string"==typeof s.versions.nw&&(P.push("Chromium "+M,"Node "+s.versions.node),U="NW.js",M=s.versions.nw)),U||(U="Node.js",O=s.arch,F=s.platform,M=(M=/[\d.]+/.exec(s.version))?M[0]:null));else v(s=n.runtime)==b?(U="Adobe AIR",F=s.flash.system.Capabilities.os):v(s=n.phantom)==_?(U="PhantomJS",M=(s=s.version||null)&&s.major+"."+s.minor+"."+s.patch):"number"==typeof I.documentMode&&(s=/\bTrident\/(\d+)/i.exec(t))?(M=[M,I.documentMode],(s=+s[1]+4)!=M[1]&&(P.push("IE "+M[1]+" mode"),L&&(L[1]=""),M[1]=s),M="IE"==U?String(M[1].toFixed(1)):M[0]):"number"==typeof I.documentMode&&/^(?:Chrome|Firefox)\b/.test(U)&&(P.push("masking as "+U+" "+M),U="IE",M="11.0",L=["Trident"],F="Windows");F=F&&p(F)}if(M&&(s=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(M)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(j&&a.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(A=/b/i.test(s)?"beta":"alpha",M=M.replace(RegExp(s+"\\+?$"),"")+("beta"==A?R:E)+(/\d+\+?/.exec(s)||"")),"Fennec"==U||"Firefox"==U&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(F))U="Firefox Mobile";else if("Maxthon"==U&&M)M=M.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(N))"Xbox 360"==N&&(F=null),"Xbox 360"==N&&/\bIEMobile\b/.test(t)&&P.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(U)&&(!U||N||/Browser|Mobi/.test(U))||"Windows CE"!=F&&!/Mobi/i.test(t))if("IE"==U&&j)try{null===n.external&&P.unshift("platform preview")}catch(e){P.unshift("embedded")}else(/\bBlackBerry\b/.test(N)||/\bBB10\b/.test(t))&&(s=(RegExp(N.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||M)?(F=((s=[s,/BB10/.test(t)])[1]?(N=null,D="BlackBerry"):"Device Software")+" "+s[0],M=null):this!=h&&"Wii"!=N&&(j&&T||/Opera/.test(U)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==U&&/\bOS X (?:\d+\.){2,}/.test(F)||"IE"==U&&(F&&!/^Win/.test(F)&&M>5.5||/\bWindows XP\b/.test(F)&&M>8||8==M&&!/\bTrident\b/.test(t)))&&!u.test(s=e.call(h,t.replace(u,"")+";"))&&s.name&&(s="ing as "+s.name+((s=s.version)?" "+s:""),u.test(U)?(/\bIE\b/.test(s)&&"Mac OS"==F&&(F=null),s="identify"+s):(s="mask"+s,U=C?p(C.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(s)&&(F=null),j||(M=null)),L=["Presto"],P.push(s));else U+=" Mobile";(s=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(s=[parseFloat(s.replace(/\.(\d)$/,".0$1")),s],"Safari"==U&&"+"==s[1].slice(-1)?(U="WebKit Nightly",A="alpha",M=s[1].slice(0,-1)):M!=s[1]&&M!=(s[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(M=null),s[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==s[0]&&537.36==s[2]&&parseFloat(s[1])>=28&&"WebKit"==L&&(L=["Blink"]),j&&(l||s[1])?(L&&(L[1]="like Chrome"),s=s[1]||((s=s[0])<530?1:s<532?2:s<532.05?3:s<533?4:s<534.03?5:s<534.07?6:s<534.1?7:s<534.13?8:s<534.16?9:s<534.24?10:s<534.3?11:s<535.01?12:s<535.02?"13+":s<535.07?15:s<535.11?16:s<535.19?17:s<536.05?18:s<536.1?19:s<537.01?20:s<537.11?"21+":s<537.13?23:s<537.18?24:s<537.24?25:s<537.36?26:"Blink"!=L?"27":"28")):(L&&(L[1]="like Safari"),s=(s=s[0])<400?1:s<500?2:s<526?3:s<533?4:s<534?"4+":s<535?5:s<537?6:s<538?7:s<601?8:s<602?9:s<604?10:s<606?11:s<608?12:"12"),L&&(L[1]+=" "+(s+="number"==typeof s?".x":/[.+]/.test(s)?"":"+")),"Safari"==U&&(!M||parseInt(M)>45)?M=s:"Chrome"==U&&/\bHeadlessChrome/i.test(t)&&P.unshift("headless")),"Opera"==U&&(s=/\bzbov|zvav$/.exec(F))?(U+=" ",P.unshift("desktop mode"),"zvav"==s?(U+="Mini",M=null):U+="Mobile",F=F.replace(RegExp(" *"+s+"$"),"")):"Safari"==U&&/\bChrome\b/.exec(L&&L[1])?(P.unshift("desktop mode"),U="Chrome Mobile",M=null,/\bOS X\b/.test(F)?(D="Apple",F="iOS 4.3+"):F=null):/\bSRWare Iron\b/.test(U)&&!M&&(M=q("Chrome")),M&&0==M.indexOf(s=/[\d.]+$/.exec(F))&&t.indexOf("/"+s+"-")>-1&&(F=m(F.replace(s,""))),F&&-1!=F.indexOf(U)&&!RegExp(U+" OS").test(F)&&(F=F.replace(RegExp(" *"+y(U)+" *"),"")),L&&!/\b(?:Avant|Nook)\b/.test(U)&&(/Browser|Lunascape|Maxthon/.test(U)||"Safari"!=U&&/^iOS/.test(F)&&/\bSafari\b/.test(L[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(U)&&L[1])&&(s=L[L.length-1])&&P.push(s),P.length&&(P=["("+P.join("; ")+")"]),D&&N&&N.indexOf(D)<0&&P.push("on "+D),N&&P.push((/^on /.test(P[P.length-1])?"":"on ")+N),F&&(s=/ ([\d.+]+)$/.exec(F),c=s&&"/"==F.charAt(F.length-s[0].length-1),F={architecture:32,family:s&&!c?F.replace(s[0],""):F,version:s?s[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(s=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(O))&&!/\bi686\b/i.test(O)?(F&&(F.architecture=64,F.family=F.family.replace(RegExp(" *"+s),"")),U&&(/\bWOW64\b/i.test(t)||j&&/\w(?:86|32)$/.test(a.cpuClass||a.platform)&&!/\bWin64; x64\b/i.test(t))&&P.unshift("32-bit")):F&&/^OS X/.test(F.family)&&"Chrome"==U&&parseFloat(M)>=39&&(F.architecture=64),t||(t=null);var z={};return z.description=t,z.layout=L&&L[0],z.manufacturer=D,z.name=U,z.prerelease=A,z.product=N,z.ua=t,z.version=U&&M,z.os=F||{architecture:null,family:null,version:null,toString:function(){return"null"}},z.parse=e,z.toString=function(){return this.description||""},z.version&&P.unshift(M),z.name&&P.unshift(U),F&&U&&(F!=String(F).split(" ")[0]||F!=U.split(" ")[0]&&!N)&&P.push(N?"("+F+")":"on "+F),P.length&&(z.description=P.join(" ")),z}();i&&a?h(b,(function(e,t){i[t]=e})):r.platform=b}).call(n)}(ZE,ZE.exports);var eR=Fe,tR=Dt,nR=Er,rR=k,iR=Np,aR=Vp;Lp("match",(function(e,t,n){return[function(t){var n=rR(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](nR(n))},function(e){var r=eR(this),i=nR(e),a=n(t,r,i);if(a.done)return a.value;if(!r.global)return aR(r,i);var o=r.unicode;r.lastIndex=0;for(var s,u=[],c=0;null!==(s=aR(r,i));){var l=nR(s[0]);u[c]=l,""===l&&(r.lastIndex=iR(i,tR(r.lastIndex),o)),c++}return 0===c?null:u}]}));var oR=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},sR=Fe,uR=k,cR=oR,lR=Er,fR=Vp;Lp("search",(function(e,t,n){return[function(t){var n=uR(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](lR(n))},function(e){var r=sR(this),i=lR(e),a=n(t,r,i);if(a.done)return a.value;var o=r.lastIndex;cR(o,0)||(r.lastIndex=0);var s=fR(r,i);return cR(r.lastIndex,o)||(r.lastIndex=o),null===s?-1:s.index}]}));var dR=Tn,pR=zt,hR=Lt,vR=Dt,yR=X,gR=Kr,mR=ka,bR=la("splice"),wR=Math.max,kR=Math.min,_R=9007199254740991,xR="Maximum allowed length exceeded";dR({target:"Array",proto:!0,forced:!bR},{splice:function(e,t){var n,r,i,a,o,s,u=yR(this),c=vR(u.length),l=pR(e,c),f=arguments.length;if(0===f?n=r=0:1===f?(n=0,r=c-l):(n=f-2,r=kR(wR(hR(t),0),c-l)),c+n-r>_R)throw TypeError(xR);for(i=gR(u,r),a=0;a<r;a++)(o=l+a)in u&&mR(i,a,u[o]);if(i.length=r,n<r){for(a=l;a<c-r;a++)s=a+n,(o=a+r)in u?u[s]=u[o]:delete u[s];for(a=c;a>c-r+n;a--)delete u[a-1]}else if(n>r)for(a=c-r;a>l;a--)s=a+n-1,(o=a+r-1)in u?u[s]=u[o]:delete u[s];for(a=0;a<n;a++)u[a+l]=arguments[a+2];return u.length=c-r+n,i}}),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=qm.exports,r=mv.exports,i=Ty.exports,a=vv.exports,o=gv.exports,s=bv.exports,u=pv.exports,c=hv.exports,l=Oy.exports,f=zm,d=wh.exports,p=bh,h=Sf.exports,v=Zm.exports,y=tb,g=HE.exports,m=tm,b=Iy,w=ZE.exports;function k(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function _(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var x=k(n),S=k(r),E=k(i),R=k(a),I=k(o),T=k(s),C=k(u),O=k(c),P=k(l),A=k(f),j=k(d),M=_(h),L=_(v),U=k(g),N=_(w);var D=M.getLogger("twilsock");function F(e,t){return["".concat((new Date).toISOString()," Twilsock ").concat(e,":")].concat(Array.from(t))}var B=function(){function e(t){O.default(this,e),P.default(this,"prefix",""),this.prefix=null!=t&&t.length>0?" "+t+":":""}return C.default(e,[{key:"setLevel",value:function(e){D.setLevel(e)}},{key:"trace",value:function(){if(D.getLevel()==D.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.debug.apply(null,F("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.debug.apply(null,F("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.info.apply(null,F("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.warn.apply(null,F("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.error.apply(null,F("E",t))}}],[{key:"setLevel",value:function(e){D.setLevel(e)}},{key:"trace",value:function(){if(D.getLevel()==D.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.debug.apply(null,F("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.debug.apply(null,F("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.info.apply(null,F("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.warn.apply(null,F("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.error.apply(null,F("E",t))}}]),e}(),q=new B(""),z="0.14.0-rc.2",W=function(){function e(t,n,r){O.default(this,e),P.default(this,"confirmedCapabilities",new Set),this.activeGrant=n,this._token=t;var i=r.region||"us1",a="wss://tsock.".concat(i,".twilio.com/v3/wsconnect"),o=r.twilsock||r.Twilsock||{};this.url=o.uri||a,this._continuationToken=r.continuationToken?r.continuationToken:null,this.logLevel=r.logLevel?r.logLevel:"error",this.retryPolicy=r.retryPolicy?r.retryPolicy:{min:1e3,max:12e4,randomness:.2},this.clientMetadata=r.clientMetadata?r.clientMetadata:{},this.clientMetadata.ver=z,this.initRegistrations=r.initRegistrations?r.initRegistrations:null,this.tweaks=r.tweaks?r.tweaks:null}return C.default(e,[{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}}]),e}(),K=C.default((function e(t){O.default(this,e),this.id=t||"TM".concat(y.v4())}));function V(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var $=function(e){R.default(n,e);var t=V(n);function n(e,r,i,a,o){var s;return O.default(this,n),s=t.call(this),P.default(S.default(s),"method","init"),s.token=e,s.continuation_token=r,s.metadata=i,s.registrations=a,s.tweaks=o,s.capabilities=["client_update","offline_storage","telemetry.v1"],s}return C.default(n)}(K);function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var J=function(e){R.default(n,e);var t=G(n);function n(e,r,i,a,o,s,u){var c;return O.default(this,n),(c=t.call(this,e)).continuationToken=r,c.continuationTokenStatus=a,c.offlineStorage=o,c.initRegistrations=s,c.debugInfo=u,c.confirmedCapabilities=i,c}return C.default(n)}(K);function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Y=function(e){R.default(n,e);var t=H(n);function n(e){var r;return O.default(this,n),r=t.call(this),P.default(S.default(r),"method","update"),r.token=e,r}return C.default(n)}(K);function Q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Message=function(e){R.default(Message,e);var t=Q(Message);function Message(e,n,r){var i;return O.default(this,Message),i=t.call(this),P.default(S.default(i),"method","message"),i.active_grant=e,i.payload_type=n,i.http_request=r,i}return C.default(Message)}(K);function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Z=function(e){R.default(n,e);var t=X(n);function n(e){var r;return O.default(this,n),r=t.call(this,e),P.default(S.default(r),"method","reply"),P.default(S.default(r),"payload_type","application/json"),P.default(S.default(r),"status",{code:200,status:"OK"}),r}return C.default(n)}(K);function ee(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var te=function(e){R.default(n,e);var t=ee(n);function n(){var e;return O.default(this,n),e=t.call(this),P.default(S.default(e),"method","close"),e}return C.default(n)}(K);function ne(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var re=C.default((function e(t,n,r,i,a,o){O.default(this,e),this.start=t,this.end=n,this.title=r,this.details=i,this.id=a,this.type=o})),ie=function(e){R.default(n,e);var t=ne(n);function n(e){var r;return O.default(this,n),r=t.call(this),P.default(S.default(r),"method","telemetry.v1"),r.events=e,r}return C.default(n)}(K);function ae(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(Number("0x"+t))})).length}function oe(e){var t=encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(Number("0x"+t))})),n=new Uint8Array(t.length);return Array.prototype.forEach.call(t,(function(e,t){n[t]=e.charCodeAt(0)})),n}function se(e){var t=Array.prototype.map.call(e,(function(e){return String.fromCharCode(e)})).join("").replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}));return decodeURIComponent(t)}function ue(e){return JSON.parse(se(e))}var ce=function(){function e(){O.default(this,e)}return C.default(e,null,[{key:"parse",value:function(e){var t,n,r=new Uint8Array(e),i=function(e){for(var t="",n=0;n<e.length;++n){var r=String.fromCharCode(e[n]);if(t+=r,"\r"===r){n+=2;break}}var i=t.split(" ");return{size:n,protocol:i[0],version:i[1],headerSize:Number(i[2])}}(r);if("TWILSOCK"!==i.protocol||"V3.0"!==i.version)return q.error("unsupported protocol: ".concat(i.protocol," ver ").concat(i.version)),null;try{t=ue(r.subarray(i.size,i.size+i.headerSize))}catch(t){return q.error("failed to parse message header",t,e),null}if(q.debug("message received:",t.method),t.payload_size>0){var a=2+i.size+i.headerSize,o=t.payload_size;if(t.hasOwnProperty("payload_type")&&0!==t.payload_type.indexOf("application/json"))0===t.payload_type.indexOf("text/plain")&&(n=se(r.subarray(a,a+o)));else try{n=ue(r.subarray(a,a+o))}catch(t){return q.error("failed to parse message body",t,e),null}}return{method:t.method,header:t,payload:n}}},{key:"createPacket",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";e.payload_size=ae(t);var n=JSON.stringify(e),r="TWILSOCK V3.0 "+ae(n);q.debug("send request:",r+n+t);var i=oe(r+"\r\n"+n+"\r\n"+t);return i.buffer}}]),e}();function le(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var fe=function(e){R.default(n,e);var t=le(n);function n(e){return O.default(this,n),t.call(this,e)}return C.default(n)}(U.default(Error));function de(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var pe=function(e){R.default(n,e);var t=de(n);function n(e,r){var i;return O.default(this,n),(i=t.call(this,e)).reply=r,i}return C.default(n)}(fe);function he(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ve(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?he(Object(n),!0).forEach((function(t){P.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):he(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ye(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var ge=function(e){R.default(n,e);var t=ye(n);function n(e){var r;return O.default(this,n),r=t.call(this),P.default(S.default(r),"newBackoff",null),P.default(S.default(r),"usedBackoff",null),P.default(S.default(r),"retrier",null),r.options=e?ve({},e):{},r}return C.default(n,[{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(e){this.newBackoff=e}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");var e,t;this.newBackoff?!this.usedBackoff||this.usedBackoff<this.newBackoff?this.createRetrier():null===(e=this.retrier)||void 0===e||e.failed(new Error):null===(t=this.retrier)||void 0===t||t.failed(new Error)}},{key:"cancel",value:function(){var e;null===(e=this.retrier)||void 0===e||e.cancel()}},{key:"cleanRetrier",value:function(){var e,t;null===(e=this.retrier)||void 0===e||e.removeAllListeners(),null===(t=this.retrier)||void 0===t||t.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var e=ve({},this.options);return this.newBackoff&&(e.min=this.newBackoff,e.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),e.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,e}},{key:"createRetrier",value:function(){var e=this;this.cleanRetrier();var t=this.getRetryPolicy();this.retrier=new m.Retrier(t),this.retrier.once("attempt",(function(){var t,n;null===(t=e.retrier)||void 0===t||t.on("attempt",(function(){return e.emit("attempt")})),null===(n=e.retrier)||void 0===n||n.failed(new Error("Skipping first attempt"))})),this.retrier.on("failed",(function(t){return e.emit("failed",t)})),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),n}(b.ReplayEventEmitter);function me(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var be=function(e){R.default(i,e);var t,n,r=me(i);function i(e,t,n){var a;O.default(this,i),a=r.call(this),P.default(S.default(a),"disconnectingTimer",null),P.default(S.default(a),"disconnectedPromiseResolve",null),P.default(S.default(a),"terminalStates",["disconnected","rejected"]),P.default(S.default(a),"tokenExpiredSasCode",20104),P.default(S.default(a),"terminationReason","Connection is not initialized"),a.websocket=e,a.websocket.on("connected",(function(){return a.fsm.socketConnected()})),a.websocket.on("disconnected",(function(){return a.fsm.socketClosed()})),a.websocket.on("message",(function(e){return a.onIncomingMessage(e)})),a.websocket.on("socketError",(function(e){a.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(e.message),httpStatusCode:null,errorCode:null}),a.emit("stateChanged","retrying")})),a.transport=t,a.config=n,a.retrier=new ge(n.retryPolicy),a.retrier.on("attempt",(function(){return a.retry()})),a.retrier.on("failed",(function(e){q.warn("Retrying failed: ".concat(e.message)),a.disconnect()})),"undefined"!=typeof window&&void 0!==window.addEventListener&&(window.addEventListener("online",(function(){q.debug("Browser reported connectivity state: online"),a.resetBackoff(),a.fsm.systemOnline()})),window.addEventListener("offline",(function(){q.debug("Browser reported connectivity state: offline"),a.websocket.close(),a.fsm.socketClosed()})));var o=L.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(){a.setupSocket(),a.emit("connecting")},onEnterInitialising:function(){a.sendInit()},onLeaveInitialising:function(){a.cancelInit()},onEnterUpdating:function(){a.sendUpdate()},onLeaveUpdating:function(){a.cancelUpdate()},onEnterRetrying:function(){a.initRetry(),a.emit("connecting")},onEnterConnected:function(){a.resetBackoff(),a.onConnected()},onUserUpdateToken:function(){a.resetBackoff()},onTokenRejected:function(){a.resetBackoff(),a.closeSocket(!0),a.finalizeSocket()},onUserDisconnect:function(){a.closeSocket(!0)},onEnterDisconnecting:function(){a.startDisconnectTimer()},onLeaveDisconnecting:function(){a.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){a.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){a.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){a.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){a.cancelDisconnectTimer()},onDisconnected:function(){a.resetBackoff(),a.finalizeSocket()},onReceiveClose:function(){a.onCloseReceived()},onReceiveOffload:function(e,t){q.debug("onreceiveoffload: ",t),a.modifyBackoff(t.body),a.onCloseReceived()},onUnsupported:function(){a.closeSocket(!0),a.finalizeSocket()},onError:function(e,t){a.closeSocket(t),a.finalizeSocket()},onEnterState:function(e){"none"!==e.from&&a.changeState(e)},onInvalidTransition:function(e,t,n){q.warn("FSM: unexpected transition",t,n)}}});return a.fsm=new o,a}return C.default(i,[{key:"changeState",value:function(e){q.debug("FSM: ".concat(e.transition,": ").concat(e.from," --\x3e ").concat(e.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){q.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function(e){q.trace("modifyBackoff",e);var t=e?e.backoff_policy:null;t&&"number"==typeof t.reconnect_min_ms&&this.retrier.modifyBackoff(t.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var e=this;q.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout((function(){q.debug("disconnecting is timed out"),e.closeSocket(!0)}),3e3)}},{key:"cancelDisconnectTimer",value:function(){q.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return"connected"===this.state&&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";default:return"disconnected"}}},{key:"initRetry",value:function(){q.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){"connecting"!=this.fsm.state?(q.trace("retry"),this.websocket.close(),this.fsm.userRetry()):q.trace("can\t retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){q.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){q.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function(e){var t=ce.parse(e);if(t){var n=t.method,r=t.header,i=t.payload;if("reply"!==n&&this.confirmReceiving(r),"notification"===n)this.emit("message",r.message_type,i);else if("reply"===r.method)this.transport.processReply({id:r.id,status:r.status,header:r,body:i});else if("client_update"===r.method)"token_about_to_expire"===r.client_update_type&&this.emit("tokenAboutToExpire");else if("close"===r.method)if(308===r.status.code)q.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:r.status.status,body:i});else if(406===r.status.code){var a="Server closed connection because can't parse protocol: ".concat(JSON.stringify(r.status));this.emitReplyConnectionError(a,r,!0),q.error(a),this.fsm.receiveFatalClose()}else 417===r.status.code?(q.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(r.status))),this.fsm.receiveFatalClose(r.status.status)):410===r.status.code?(q.warn("Server closed connection: ".concat(JSON.stringify(r.status))),this.fsm.receiveClose(r.status.status),this.emit("tokenExpired")):401===r.status.code?(q.error("Server closed connection: ".concat(JSON.stringify(r.status))),this.fsm.receiveClose(r.status.status)):(q.warn("unexpected message: ",r.status),this.fsm.receiveOffload({status:r.status.status,body:null}))}}},{key:"sendInit",value:(n=x.default(A.default.mark((function e(){var t,n;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.trace("sendInit"),e.prev=1,this.emit("beforeSendInit"),e.next=5,this.transport.sendInit();case 5:t=e.sent,this.config.updateContinuationToken(t.continuationToken),this.config.confirmedCapabilities=t.confirmedCapabilities,this.fsm.initSuccess(t),this.emit("initialized",t),this.emit("tokenUpdated"),e.next=17;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof pe?(n=!1,q.warn("Init rejected by server: ".concat(JSON.stringify(e.t0.reply.status))),this.emit("sendInitFailed"),401===e.t0.reply.status.code||403===e.t0.reply.status.code?(n=!0,this.fsm.tokenRejected(e.t0.reply.status),e.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):429===e.t0.reply.status.code?(this.modifyBackoff(e.t0.reply.body),this.fsm.initError(!0)):500===e.t0.reply.status.code?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(e.t0.message,e.t0.reply,n)):(this.terminationReason=e.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(e.t0.message,"\n").concat(JSON.stringify(e.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",e.t0);case 17:case"end":return e.stop()}}),e,this,[[1,13]])}))),function(){return n.apply(this,arguments)})},{key:"sendUpdate",value:(t=x.default(A.default.mark((function e(){var t,n,r;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.trace("sendUpdate"),t=new Y(this.config.token),e.prev=2,e.next=5,this.transport.sendWithReply(t);case 5:n=e.sent,this.fsm.updateSuccess(n.body),this.emit("tokenUpdated"),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(2),e.t0 instanceof pe?(r=!1,q.warn("Token update rejected by server: ".concat(JSON.stringify(e.t0.reply.status))),401===e.t0.reply.status.code||403===e.t0.reply.status.code?(r=!0,this.fsm.tokenRejected(e.t0.reply.status),e.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):429===e.t0.reply.status.code?(this.modifyBackoff(e.t0.reply.body),this.fsm.updateError(e.t0.reply.status)):this.fsm.updateError(e.t0.reply.status),this.emitReplyConnectionError(e.t0.message,e.t0.reply,r)):(this.emit("error",!1,e.t0.message,null,null),this.fsm.updateError(e.t0)),this.emit("tokenUpdated",e.t0);case 14:case"end":return e.stop()}}),e,this,[[2,10]])}))),function(){return t.apply(this,arguments)})},{key:"emitReplyConnectionError",value:function(e,t,n){var r=t.status&&t.status.description?t.status.description:e,i=t.status.code,a=t.status&&t.status.errorCode?t.status.errorCode:null;n&&(this.terminationReason=r),this.emit("connectionError",{terminal:n,message:"Connection error: ".concat(r),httpStatusCode:i,errorCode:a})}},{key:"cancelInit",value:function(){q.trace("cancelInit")}},{key:"cancelUpdate",value:function(){q.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(e){q.trace("confirmReceiving");try{this.transport.send(new Z(e.id))}catch(e){q.debug("failed to confirm packet receiving",e)}}},{key:"closeSocket",value:function(e){var t=this;q.trace("closeSocket (graceful: ".concat(e,")")),e&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),function(e){setTimeout(e,0)}((function(){return t.fsm.socketClosed()}))}},{key:"connect",value:function(){q.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var e=this;return q.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise((function(t){e.disconnectedPromiseResolve=t,e.fsm.userDisconnect()}))}},{key:"updateToken",value:function(e){var t=this;return q.trace("updateToken:",e),new Promise((function(e,n){t.once("tokenUpdated",(function(t){t?n(t):e()})),t.fsm.userUpdateToken()}))}},{key:"isTerminalState",get:function(){return-1!==this.terminalStates.indexOf(this.fsm.state)}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),i}(b.ReplayEventEmitter),we=function(){function e(){O.default(this,e)}return C.default(e,null,[{key:"getMetadata",value:function(e){var t,n,r,i,a,o,s,u,c=e&&e.clientMetadata?e.clientMetadata:{},l={env:null!==(t=N.name)&&void 0!==t?t:"unknown",envv:null!==(n=N.version)&&void 0!==n?n:"unknown",os:null!==(r=null===(i=N.os)||void 0===i?void 0:i.family)&&void 0!==r?r:"unknown",osv:null!==(a=null===(o=N.os)||void 0===o?void 0:o.version)&&void 0!==a?a:"unknown",osa:null!==(s=null===(u=N.os)||void 0===u?void 0:u.architecture)&&void 0!==s?s:"unknown",sdk:"js-default"},f={};return["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"].filter((function(e){return e in c||e in l})).forEach((function(e){return f[e]=e in c?c[e]:l[e]})),f}}]),e}();var ke=function(){function e(t,n){var r=this;O.default(this,e),this.config=n,this.activeRequests=new Map,this.channel=t,this.channel.on("reply",(function(e){return r.processReply(e)})),this.channel.on("disconnected",(function(){r.activeRequests.forEach((function(e){clearTimeout(e.timeout),e.reject(new fe("disconnected"))})),r.activeRequests.clear()}))}var t;return C.default(e,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(e){var t,n=this.activeRequests.get(e.id);n&&(clearTimeout(n.timeout),this.activeRequests.delete(e.id),(t=e.status.code)>=200&&t<300?n.resolve(e):(n.reject(new pe("Transport failure: "+e.status.status,e)),q.trace("message rejected")))}},{key:"storeRequest",value:function(e,t,n){var r={resolve:t,reject:n,timeout:setTimeout((function(){q.trace("request",e,"is timed out"),n(new fe("Twilsock: request timeout: "+e))}),3e4)};this.activeRequests.set(e,r)}},{key:"shutdown",value:function(){this.activeRequests.forEach((function(e){clearTimeout(e.timeout),e.reject(new fe("Twilsock: request cancelled by user"))})),this.activeRequests.clear()}},{key:"sendInit",value:(t=x.default(A.default.mark((function e(){var t,n,r;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.trace("sendInit"),t=we.getMetadata(this.config),n=new $(this.config.token,this.config.continuationToken,t,this.config.initRegistrations,this.config.tweaks),e.next=5,this.sendWithReply(n);case 5:return r=e.sent,e.abrupt("return",new J(r.id,r.header.continuation_token,new Set(r.header.capabilities),r.header.continuation_token_status,r.header.offline_storage,r.header.init_registrations,r.header.debug_info));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"sendClose",value:function(){var e=new te;this.send(e)}},{key:"sendWithReply",value:function(e,t){var n=this;return new Promise((function(r,i){var a=n.send(e,t);n.storeRequest(a,r,i)}))}},{key:"send",value:function(e,t){e.id=e.id||"TM".concat(y.v4());var n=ce.createPacket(e,function(e){switch(j.default(e)){case"undefined":return"";case"object":return JSON.stringify(e);default:return e}}(t));try{return this.channel.send(n),e.id}catch(t){throw q.debug("failed to send ",e,t),q.trace(t.stack),t}}}]),e}();function _e(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var xe=function(e){R.default(r,e);var n=_e(r);function r(e){var i;return O.default(this,r),i=n.call(this),P.default(S.default(i),"socket",null),i.url=e,i.url=e,i.WebSocket=t.WebSocket||t.MozWebSocket||{},i}return C.default(r,[{key:"isConnected",get:function(){return!!this.socket&&1===this.socket.readyState}},{key:"connect",value:function(){var e,t=this;q.trace("connecting to socket");try{e=new this.WebSocket(this.url)}catch(e){return q.debug("Socket error: ".concat(this.url)),void this.emit("socketError",e)}e.binaryType="arraybuffer",e.onopen=function(){q.debug("socket opened ".concat(t.url)),t.emit("connected")},e.onclose=function(e){q.debug("socket closed",e),t.emit("disconnected",e)},e.onerror=function(e){q.debug("Socket error:",e),t.emit("socketError",e)},e.onmessage=function(e){t.emit("message",e.data)},this.socket=e}},{key:"send",value:function(e){return this.socket&&this.socket.send(e)}},{key:"close",value:function(){if(q.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{}}}}]),r}(b.ReplayEventEmitter);function Se(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Ee=function(e){R.default(u,e);var t,n,r,i,a,o,s=Se(u);function u(e){var t;return O.default(this,u),(t=s.call(this)).transport=e,t.registrations=new Map,t.registrationsInProgress=new Map,t}return C.default(u,[{key:"putNotificationContext",value:(o=x.default(A.default.mark((function e(t,n){var r;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={method:"put_notification_ctx",notification_ctx_id:t},e.next=3,this.transport.sendWithReply(r,n);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"deleteNotificationContext",value:(a=x.default(A.default.mark((function e(t){var n;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={method:"delete_notification_ctx",notification_ctx_id:t},e.next=3,this.transport.sendWithReply(n);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateRegistration",value:(i=x.default(A.default.mark((function e(t,n){var r,i;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.debug("update registration for context",t),(r=this.registrationsInProgress.get(t))||(r=new Set,this.registrationsInProgress.set(t,r)),i=y.v4(),r.add(i),e.prev=5,e.next=8,this.putNotificationContext(t,n);case 8:q.debug("registration attempt succeeded for context",n),r.delete(i),0===r.size&&(this.registrationsInProgress.delete(t),this.emit("registered",t)),e.next=19;break;case 13:e.prev=13,e.t0=e.catch(5),q.warn("registration attempt failed for context",n),q.debug(e.t0),r.delete(i),0===r.size&&(this.registrationsInProgress.delete(t),this.emit("registrationFailed",t,e.t0));case 19:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e,t){return i.apply(this,arguments)})},{key:"updateRegistrations",value:(r=x.default(A.default.mark((function e(){var t,n=this;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.trace("refreshing ".concat(this.registrations.size," registrations")),t=[],this.registrations.forEach((function(e,r){t.push(n.updateRegistration(r,e))})),e.next=5,Promise.all(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"setNotificationsContext",value:(n=x.default(A.default.mark((function e(t,n){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&n){e.next=2;break}throw new fe("Invalid arguments provided");case 2:return this.registrations.set(t,n),e.next=5,this.updateRegistration(t,n);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeNotificationsContext",value:(t=x.default(A.default.mark((function e(t){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.registrations.has(t)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.deleteNotificationContext(t);case 4:this.transport.isConnected&&this.registrations.delete(t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),u}(b.ReplayEventEmitter);function Re(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Ie=function(e){R.default(n,e);var t=Re(n);function n(e,r,i){var a;return O.default(this,n),(a=t.call(this,r)).status=e,a.description=r,a.body=i,a}return C.default(n)}(fe);function Te(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Ce=function(e){R.default(n,e);var t=Te(n);function n(e){return O.default(this,n),t.call(this,e)}return C.default(n)}(fe);function Oe(e,t){var n=function(e){var t=e.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(t){var n={protocol:t[1],host:t[2],hostname:t[3],port:t[4],pathname:t[5],search:t[6],hash:t[7],params:{}};if(n.search.length>0){var r=n.search.substring(1);n.params=r.split("&").map((function(e){return e.split("=")})).reduce((function(e,t){return e.hasOwnProperty(t[0])?Array.isArray(e[t[0]])?e[t[0]].push(t[1]):e[t[0]]=[e[t[0]],t[1]]:e[t[0]]=t[1],e}),{})}return n}throw new fe("Incorrect URI: "+e)}(t),r={method:e,host:n.host,path:n.pathname};return n.params&&(r.params=n.params),r}function Pe(e,t,n,r,i){return{to:Oe(e,t),headers:n,body:r,grant:i}}var Ae=function(){function e(t,n,r){O.default(this,e),this.config=r,this.transport=t,this.pendingMessages=[],this.twilsock=n}var t;return C.default(e,[{key:"saveMessage",value:function(e){var t=this;return new Promise((function(n,r){var i={message:e,resolve:n,reject:r,alreadyRejected:!1,timeout:setTimeout((function(){q.debug("request is timed out"),r(new fe("request '".concat(e.to.method,"' to '").concat(e.to.host,"' timed out"))),i.alreadyRejected=!0}),2e4)};t.pendingMessages.push(i)}))}},{key:"sendPendingMessages",value:function(){for(var e=this,t=function(){var t=e.pendingMessages[0];if(!t.alreadyRejected)try{var n=t.message;e.actualSend(n).then((function(e){return t.resolve(e)})).catch((function(e){return t.reject(e)})),clearTimeout(t.timeout)}catch(e){return q.debug("Failed to send pending message",e),"break"}e.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){if("break"===t())break}}},{key:"rejectPendingMessages",value:function(){var e=this;this.pendingMessages.forEach((function(t){t.reject(new Ce("Unable to connect: "+e.twilsock.getTerminationReason)),t.alreadyRejected=!0,clearTimeout(t.timeout)})),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:(t=x.default(A.default.mark((function e(t){var n,r,i,a,o,s,u,c;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.to,i=t.headers,a=t.body,o=null!==(n=t.grant)&&void 0!==n?n:this.config.activeGrant,s={host:r.host,path:r.path,method:r.method,params:r.params,headers:i},u=new Message(o,i["Content-Type"]||"application/json",s),q.trace("Sending upstream message",u),e.next=9,this.transport.sendWithReply(u,a);case 9:if(c=e.sent,q.trace("Received upstream message response",c),!((f=c)&&f.header&&f.header.http_status)||(l=c.header.http_status.code)>=200&&l<300){e.next=13;break}throw new Ie(c.header.http_status.code,c.header.http_status.status,c.body);case 13:return e.abrupt("return",{status:c.header.http_status,headers:c.header.http_headers,body:c.body});case 14:case"end":return e.stop()}var l,f}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new Ce("Unable to connect: "+this.twilsock.getTerminationReason));var a=Pe(e,t,n,r,i);return this.twilsock.isConnected?this.actualSend(a):this.saveMessage(a)}}]),e}(),je=function(){function e(){var t=this;O.default(this,e),this._promise=new Promise((function(e,n){t._resolve=e,t._reject=n}))}return C.default(e,[{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)}}]),e}(),Me=function(){function e(t){O.default(this,e),this.id=t}return C.default(e,null,[{key:"create",value:function(t){if(t instanceof Object&&"storage_id"in t)return new e(t.storage_id);throw new fe('Field "storage_id" is missing')}}]),e}(),Le=function(){function e(){return O.default(this,e),P.default(this,"initializedFlag","twilio_twilsock_token_storage"),P.default(this,"tokenStoragePrefix","twilio_continuation_token_"),e._instance||(this.initialize(),e._instance=this),e._instance}return C.default(e,[{key:"sessionStorage",value:function(){try{return t.sessionStorage}catch(e){return null}}},{key:"window",value:function(){try{return t.window}catch(e){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()){this.sessionStorage.getItem(this.initializedFlag)&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var t=this.sessionStorage.removeItem;this.window.addEventListener("unload",(function(){t(e.initializedFlag)}))}}},{key:"clear",value:function(){if(this.canStore()){for(var e=[],t=0;t<this.sessionStorage.length;t++){var n=this.sessionStorage.key(t);n&&0===n.indexOf(this.tokenStoragePrefix)&&e.push(n)}var r=this.sessionStorage.removeItem;e.forEach((function(e){return r(e)})),r(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)}}]),e}();P.default(Le,"_instance",null);var Ue,Ne,De=new Le,Fe=function(){function e(t,n,r,i,a,o){O.default(this,e),this.title=t,this.details=n,this.start=r,this.type=a,this.id=o,this.end=i}return C.default(e,[{key:"toTelemetryEvent",value:function(){var e=new Date,t=this.start,n=this.end?this.end:e;if(n<t){var r=n;n=t,t=r}var i=t.getTime()-e.getTime(),a=n.getTime()-e.getTime();return new re(i,a,this.title,this.details,this.id,this.type)}}]),e}();e.TelemetryPoint=void 0,(Ue=e.TelemetryPoint||(e.TelemetryPoint={}))[Ue.Start=0]="Start",Ue[Ue.End=1]="End",e.EventSendingLimitation=void 0,(Ne=e.EventSendingLimitation||(e.EventSendingLimitation={}))[Ne.MinEventsPortion=0]="MinEventsPortion",Ne[Ne.AnyEvents=1]="AnyEvents",Ne[Ne.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished";var Be=function(){function t(e,n){O.default(this,t),P.default(this,"minEventsPortionToSend",50),P.default(this,"maxEventsPortionToSend",100),P.default(this,"pendingEvents",new Map),P.default(this,"readyEvents",[]),P.default(this,"hasInitializationFinished",!1),P.default(this,"_canSendTelemetry",!1),this.config=e,this.packetInterface=n}return C.default(t,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(t){q.debug("TelemetryTracker.canSendTelemetry: ".concat(t," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!t&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=t,t&&this.sendTelemetry(e.EventSendingLimitation.AnyEvents),t&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(e){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(e)}},{key:"addPartialEvent",value:function(t,n,r){q.debug("Adding ".concat(r===e.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(n,"' event"));var i=this.pendingEvents.has(n);if(r===e.TelemetryPoint.Start)i&&q.debug("Overwriting starting point for '".concat(n,"' event")),this.pendingEvents.set(n,t);else{if(!i)return void q.info("Could not find started event for '".concat(n,"' event"));this.addTelemetryEvent(this.merge(this.pendingEvents.get(n),t)),this.pendingEvents.delete(n)}}},{key:"getTelemetryToSend",value:function(t){return this.canSendTelemetry&&0!=this.readyEvents.length?t==e.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(t==e.EventSendingLimitation.AnyEventsIncludingUnfinished):[]}},{key:"getTelemetryPortion",value:function(e){var t=this,n=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),r=this.readyEvents.splice(0,n);return e&&r.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach((function(e,n){if(!(r.length>=t.maxEventsPortionToSend)){var i=t.pendingEvents.get(n);t.pendingEvents.delete(n),r.push(new Fe("[UNFINISHED] ".concat(i.title),i.details,i.start,null,i.type,i.id))}})),r}},{key:"merge",value:function(e,t){return new Fe(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(e.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(e){var t=this.getTelemetryToSend(e);if(0!==t.length)try{this.packetInterface.send(new ie(t.map((function(e){return e.toTelemetryEvent()}))))}catch(e){q.debug("Error while sending ".concat(t.length," telemetry events due to ").concat(e,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(t)}}}]),t}();function qe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var ze=C.default((function e(){O.default(this,e)}));P.default(ze,"TWILSOCK_CONNECT","twilsock.sdk.connect"),P.default(ze,"TWILSOCK_INIT","twilsock.sdk.init"),e.TwilsockClient=function(t){R.default(f,t);var n,r,i,a,o,s,u,c,l=qe(f);function f(t,n,r){var i;O.default(this,f),i=l.call(this),P.default(S.default(i),"version",z),P.default(S.default(i),"offlineStorageDeferred",new je),r.continuationToken=r.continuationToken?r.continuationToken:De.getStoredToken(n);var a=i.config=new W(t,n,r);q.setLevel(a.logLevel);var o=new xe(a.url),s=new ke(o,a);return i.channel=new be(o,s,a),i.registrations=new Ee(s),i.upstream=new Ae(s,i.channel,a),i.telemetryTracker=new Be(a,s),i.channel.on("initialized",(function(){return i.telemetryTracker.canSendTelemetry=!0})),o.on("disconnected",(function(){return i.telemetryTracker.canSendTelemetry=!1})),i.registrations.on("registered",(function(e){return i.emit("registered",e)})),i.channel.on("message",(function(e,t){return setTimeout((function(){return i.emit("message",e,t)}),0)})),i.channel.on("stateChanged",(function(e){return setTimeout((function(){return i.emit("stateChanged",e)}),0)})),i.channel.on("connectionError",(function(e){return setTimeout((function(){return i.emit("connectionError",e)}),0)})),i.channel.on("tokenAboutToExpire",(function(){return setTimeout((function(){return i.emit("tokenAboutToExpire")}),0)})),i.channel.on("tokenExpired",(function(){return setTimeout((function(){return i.emit("tokenExpired")}),0)})),i.channel.on("connected",(function(){return i.registrations.updateRegistrations()})),i.channel.on("connected",(function(){return i.upstream.sendPendingMessages()})),i.channel.on("connected",(function(){return setTimeout((function(){return i.emit("connected")}),0)})),i.channel.on("beforeConnect",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Establish WebSocket connection","",new Date),ze.TWILSOCK_CONNECT,e.TelemetryPoint.Start)})),i.channel.on("connected",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Establish WebSocket connection","",new Date,new Date),ze.TWILSOCK_CONNECT,e.TelemetryPoint.End)})),i.channel.on("beforeSendInit",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Send Twilsock init","",new Date),ze.TWILSOCK_INIT,e.TelemetryPoint.Start)})),i.channel.on("initialized",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Send Twilsock init","Succeeded",new Date,new Date),ze.TWILSOCK_INIT,e.TelemetryPoint.End)})),i.channel.on("sendInitFailed",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Send Twilsock init","Failed",new Date,new Date),ze.TWILSOCK_INIT,e.TelemetryPoint.End)})),i.channel.on("initialized",(function(e){i.handleStorageId(n,e),De.storeToken(e.continuationToken,n),setTimeout((function(){return i.emit("initialized",e)}),0)})),i.channel.on("disconnected",(function(){return setTimeout((function(){return i.emit("disconnected")}),0)})),i.channel.on("disconnected",(function(){return i.upstream.rejectPendingMessages()})),i.channel.on("disconnected",(function(){return i.offlineStorageDeferred.fail(new fe("Client disconnected"))})),i.offlineStorageDeferred.promise.catch((function(){})),i}return C.default(f,[{key:"emit",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return q.debug("Emitting ".concat(e.toString(),"(").concat(r.map((function(e){return JSON.stringify(e)})).join(", "),")")),(t=E.default(T.default(f.prototype),"emit",this)).call.apply(t,[this,e].concat(r))}},{key:"handleStorageId",value:function(e,t){if(t.offlineStorage)if(t.offlineStorage.hasOwnProperty(e))try{this.offlineStorageDeferred.set(Me.create(t.offlineStorage[e])),q.debug("Offline storage for '".concat(e,"' product: ").concat(JSON.stringify(t.offlineStorage[e]),"."))}catch(n){this.offlineStorageDeferred.fail(new fe("Failed to parse offline storage for ".concat(e," ").concat(JSON.stringify(t.offlineStorage[e]),". ").concat(n,".")))}else this.offlineStorageDeferred.fail(new fe("No offline storage id for '".concat(e,"' product: ").concat(JSON.stringify(t.offlineStorage))));else this.offlineStorageDeferred.fail(new fe("No offline storage id"))}},{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:(c=x.default(A.default.mark((function e(t){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(q.trace("updating token '".concat(t,"'")),this.config.token!==t){e.next=3;break}return e.abrupt("return");case 3:return this.config.updateToken(t),e.next=6,this.channel.updateToken(t);case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setNotificationsContext",value:(u=x.default(A.default.mark((function e(t,n){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.registrations.setNotificationsContext(t,n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"removeNotificationsContext",value:(s=x.default(A.default.mark((function e(t){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.registrations.removeNotificationsContext(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:(o=x.default(A.default.mark((function t(){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEventsIncludingUnfinished),t.next=3,this.channel.disconnect();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"get",value:(a=x.default(A.default.mark((function t(n,r,i){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),t.next=3,this.upstream.send("GET",n,r,void 0,i);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,n){return a.apply(this,arguments)})},{key:"post",value:(i=x.default(A.default.mark((function t(n,r,i,a){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),t.next=3,this.upstream.send("POST",n,r,i,a);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,n,r){return i.apply(this,arguments)})},{key:"put",value:(r=x.default(A.default.mark((function t(n,r,i,a){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),t.next=3,this.upstream.send("PUT",n,r,i,a);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"delete",value:(n=x.default(A.default.mark((function t(n,r,i,a){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),t.next=3,this.upstream.send("DELETE",n,r,i,a);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"addTelemetryEvent",value:function(e){this.telemetryTracker.addTelemetryEvent(e),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(t,n,r){this.telemetryTracker.addPartialEvent(t,n,r),r===e.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),f}(b.ReplayEventEmitter),e.TwilsockClient=function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":j.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}([p.validateConstructorTypes(p.nonEmptyString,p.nonEmptyString,[p.pureObject,"undefined",p.literal(null)]),function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":j.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[String,String,Object])],e.TwilsockClient);var We=function(){function e(t){O.default(this,e),this.product=t,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return C.default(e,[{key:"populateInitRegistrations",value:function(e){var t=new Set(this.message_types);for(var n in e)t.add(e[n]);this.message_types=Array.from(t)}}]),e}();e.InitRegistration=We,e.TelemetryEventDescription=Fe,e.TelemetryTracker=Be,e.TransportUnavailableError=Ce,e.Twilsock=e.TwilsockClient,e.TwilsockError=fe}(Bm);var SR={},ER=u,RR=s,IR=Fn,TR=nn,CR=c,OR=X,PR=w,AR=Object.assign,jR=Object.defineProperty,MR=!AR||RR((function(){if(ER&&1!==AR({b:1},AR(jR({},"a",{enumerable:!0,get:function(){jR(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!=AR({},e)[n]||IR(AR({},t)).join("")!=r}))?function(e,t){for(var n=OR(e),r=arguments.length,i=1,a=TR.f,o=CR.f;r>i;)for(var s,u=PR(arguments[i++]),c=a?IR(u).concat(a(u)):IR(u),l=c.length,f=0;l>f;)s=c[f++],ER&&!o.call(u,s)||(n[s]=u[s]);return n}:AR,LR=MR;Tn({target:"Object",stat:!0,forced:Object.assign!==LR},{assign:LR}),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=qm.exports,n=hv.exports,r=pv.exports,i=vv.exports,a=gv.exports,o=bv.exports,s=zm,u=wh.exports,c=Bm,l=mv.exports,f=Oy.exports,d=tm,p=Ih.exports,h=cv.exports,v=Sf.exports,y=tb,g=bh;function m(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var w=m(t),k=m(n),_=m(r),x=m(i),S=m(a),E=m(o),R=m(s),I=m(u),T=m(l),C=m(f),O=m(p),P=m(h),A=b(v),j=b(y);function M(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":I.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function L(e,t){if("object"===("undefined"==typeof Reflect?"undefined":I.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function U(){}function N(){N.init.call(this)}function D(e){return void 0===e._maxListeners?N.defaultMaxListeners:e._maxListeners}function F(e,t,n){if(t)e.call(n);else for(var r=e.length,i=G(e,r),a=0;a<r;++a)i[a].call(n)}function B(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=G(e,i),o=0;o<i;++o)a[o].call(n,r)}function q(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=G(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function z(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=G(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function W(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=G(e,i),o=0;o<i;++o)a[o].apply(n,r)}function K(e,t,n,r){var i,a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new U,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=D(e))&&i>0&&o.length>i){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else o=a[t]=n,++e._eventsCount;return e}function V(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function $(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function G(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}U.prototype=Object.create(null),N.EventEmitter=N,N.usingDomains=!1,N.prototype.domain=void 0,N.prototype._events=void 0,N.prototype._maxListeners=void 0,N.defaultMaxListeners=10,N.init=function(){this.domain=null,N.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new U,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},N.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},N.prototype.getMaxListeners=function(){return D(this)},N.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:F(n,l,this);break;case 2:B(n,l,this,arguments[1]);break;case 3:q(n,l,this,arguments[1],arguments[2]);break;case 4:z(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];W(n,l,this,i)}return!0},N.prototype.addListener=function(e,t){return K(this,e,t,!1)},N.prototype.on=N.prototype.addListener,N.prototype.prependListener=function(e,t){return K(this,e,t,!0)},N.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,V(this,e,t)),this},N.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,V(this,e,t)),this},N.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new U:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new U,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},N.prototype.off=function(e,t){return this.removeListener(e,t)},N.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new U,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new U:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new U,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},N.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},N.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):$.call(e,t)},N.prototype.listenerCount=$,N.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var J=A.getLogger("twilio-notificatiions");function H(e,t){return["".concat((new Date).toISOString()," Twilio.Notifications ").concat(e,":")].concat(Array.from(t))}var Y=function(){function e(){k.default(this,e)}return _.default(e,[{key:"setLevel",value:function(e){J.setLevel(e)}},{key:"trace",value:function(){if(J.getLevel()==J.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.debug.apply(null,H("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.debug.apply(null,H("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.info.apply(null,H("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.warn.apply(null,H("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.error.apply(null,H("E",t))}}]),e}(),Q=new Y;function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return S.default(this,n)}}var Z=_.default((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;k.default(this,e),this.token=t,this.notificationId=n,this.messageTypes=r}));function ee(e,t){var n=new Set;return e.notificationId!==t.notificationId&&n.add("notificationId"),e.token!==t.token&&n.add("token"),function(e,t){return[].concat(P.default(P.default(e).filter((function(e){return!t.has(e)}))),P.default(P.default(t).filter((function(t){return!e.has(t)}))))}(e.messageTypes,t.messageTypes).length>0&&n.add("messageType"),[n.size>0,n]}var te=function(e){x.default(r,e);var t,n=X(r);function r(e){var t;return k.default(this,r),t=n.call(this),C.default(T.default(t),"desiredState",new Z),C.default(T.default(t),"currentState",new Z),C.default(T.default(t),"_hasActiveAttempt",!1),t.channelType=e,t}return _.default(r,[{key:"setNotificationId",value:function(e){this.desiredState.notificationId=e}},{key:"isActive",value:function(){return""!==this.desiredState.notificationId}},{key:"subscribe",value:function(e){this.desiredState.messageTypes.has(e)?Q.debug("message type '".concat(e,"' for channel ").concat(this.channelType," is already registered")):this.desiredState.messageTypes.add(e)}},{key:"unsubscribe",value:function(e){this.desiredState.messageTypes.has(e)&&this.desiredState.messageTypes.delete(e)}},{key:"updateToken",value:function(e){this.desiredState.token=e}},{key:"commitChanges",value:(t=w.default(R.default.mark((function e(){var t,n,r,i,a,o;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._hasActiveAttempt){e.next=3;break}throw Q.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(t=ee(this.desiredState,this.currentState),n=O.default(t,2),r=n[0],i=n[1],r){e.next=6;break}return e.abrupt("return");case 6:if(this.currentState.notificationId||i.delete("notificationId"),Q.trace("Persisting ".concat(this.channelType," registration"),i,this.desiredState),e.prev=8,this._hasActiveAttempt=!0,(a=new Z).token=this.desiredState.token,a.notificationId=this.desiredState.notificationId,a.messageTypes=new Set(this.desiredState.messageTypes),!(a.messageTypes.size>0)){e.next=24;break}return e.next=17,this.updateRegistration(a,i);case 17:o=e.sent,this.currentState.token=o.token,this.currentState.notificationId=o.notificationId,this.currentState.messageTypes=new Set(o.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),e.next=30;break;case 24:return e.next=26,this.removeRegistration();case 26:this.currentState.token=a.token,this.currentState.notificationId=a.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:e.next=35;break;case 32:throw e.prev=32,e.t0=e.catch(8),e.t0;case 35:return e.prev=35,this._hasActiveAttempt=!1,e.finish(35);case 38:case"end":return e.stop()}}),e,this,[[8,32,35,38]])}))),function(){return t.apply(this,arguments)})}]),r}(N);function ne(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return S.default(this,n)}}var re={min:2e3,max:12e4,randomness:.2},ie=function(e){x.default(a,e);var t,n,r,i=ne(a);function a(e,t,n,r){var o;return k.default(this,a),o=i.call(this,e),C.default(T.default(o),"registrationId",null),o.context=t,o.twilsock=n,o.registrarUrl=r,o}return _.default(a,[{key:"updateRegistration",value:(r=w.default(R.default.mark((function e(t,n){var r,i,a,o,s,u=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.has("notificationId")){e.next=3;break}return e.next=3,this.removeRegistration();case 3:if(t.notificationId&&t.notificationId.length){e.next=6;break}throw Q.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return Q.trace("Registering",this.channelType,t),r={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(t.messageTypes),data:{registration_id:t.notificationId}},i=this.context.productId,a="".concat(this.registrarUrl,"?productId=").concat(i),o={"Content-Type":"application/json"},Q.trace("Creating registration for channel ".concat(this.channelType)),e.prev=12,e.next=15,new d.AsyncRetrier(re).run((function(){return u.twilsock.post(a,o,r,i)}));case 15:s=e.sent,this.registrationId=s.body.id,Q.debug("Registration created: ",s),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),Q.error("Registration failed: ",e.t0),e.t0;case 24:return e.abrupt("return",t);case 25:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t){return r.apply(this,arguments)})},{key:"removeRegistration",value:(n=w.default(R.default.mark((function e(){var t,n,r,i=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.registrationId){e.next=2;break}return e.abrupt("return");case 2:return t=this.context.productId,n="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(t),r={"Content-Type":"application/json"},Q.trace("Removing registration for ".concat(this.channelType)),e.prev=6,e.next=9,new d.AsyncRetrier(Object.assign(re,{maxAttemptsCount:3})).run((function(){return i.twilsock.delete(n,r,{},t)}));case 9:this.registrationId=null,this.currentState.notificationId="",Q.debug("Registration removed for ".concat(this.channelType)),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(6),Q.error("Failed to remove registration ",this.channelType,e.t0),e.t0;case 18:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(){return n.apply(this,arguments)})},{key:"sendDeviceRemoveRequest",value:(t=w.default(R.default.mark((function e(t){var n,r,i,a,o=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!==t){e.next=2;break}throw new Error("Empty registration ID");case 2:return n=this.context.productId,r="".concat(this.registrarUrl,"?productId=").concat(n),i={"Content-Type":"application/json"},a={binding_type:this.channelType,address:t},e.prev=6,Q.trace("Removing old registrations for ".concat(this.channelType)),e.next=10,new d.AsyncRetrier(Object.assign(re,{maxAttemptsCount:3})).run((function(){return o.twilsock.delete(r,i,a,n)}));case 10:this.registrationId=null,this.currentState.notificationId="",Q.debug("Registration removed for ".concat(this.channelType)),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),Q.error("Failed to remove registration ",this.channelType,e.t0),e.t0;case 19:case"end":return e.stop()}}),e,this,[[6,15]])}))),function(e){return t.apply(this,arguments)})}]),a}(te);function ae(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return S.default(this,n)}}var oe,se=function(e){x.default(a,e);var t,n,r,i=ae(a);function a(e,t,n){var r;return k.default(this,a),r=i.call(this,"twilsock"),C.default(T.default(r),"contextId",j.v4()),r.productId=e,r.platform=t,r.twilsock=n,r}return _.default(a,[{key:"updateRegistration",value:(r=w.default(R.default.mark((function e(t,n){var r,i;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.has("messageType")){e.next=2;break}return e.abrupt("return",t);case 2:return r=Array.from(t.messageTypes),i={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:r},e.prev=4,e.next=7,this.twilsock.setNotificationsContext(this.contextId,i);case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(4),Q.error("Failed to update twilsock notification context: ".concat(e.t0)),e.t0;case 13:return e.abrupt("return",t);case 14:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return r.apply(this,arguments)})},{key:"removeRegistration",value:(n=w.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:e.next=9;break;case 5:throw e.prev=5,e.t0=e.catch(0),Q.error("Failed to remove twilsock notification context: ".concat(e.t0)),e.t0;case 9:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(){return n.apply(this,arguments)})},{key:"sendDeviceRemoveRequest",value:(t=w.default(R.default.mark((function e(t){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),a}(te);function ue(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return S.default(this,n)}}var ce=g.literal("apn","fcm","twilsock");e.Notifications=oe=function(e){x.default(Client,e);var t,n,r,i=ue(Client);function Client(e){var t,n,r,a,o,s,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};k.default(this,Client),u=i.call(this),l.logLevel=null!==(t=l.logLevel)&&void 0!==t?t:"error",Q.setLevel(l.logLevel);var f=null!==(n=l.productId)&&void 0!==n?n:"notifications",d=!l.twilsockClient,p=l.twilsockClient=null!==(r=l.twilsockClient)&&void 0!==r?r:new c.TwilsockClient(e,f,l),h=null!==(a=l.notifications)&&void 0!==a?a:{},v=null!==(o=null!==(s=h.region)&&void 0!==s?s:l.region)&&void 0!==o?o:"us1",y="https://ers.".concat(v,".twilio.com/v1/registrations"),g=h.ersUrl||y;u.connectors=new Map;var m=oe._detectPlatform();return u.connectors.set("apn",new ie("apn",{protocolVersion:4,productId:f,platform:m},p,g)),u.connectors.set("fcm",new ie("fcm",{protocolVersion:3,productId:f,platform:m},p,g)),u.connectors.set("twilsock",new se(f,m,p)),p.on("stateChanged",(function(e){return u.emit("transportState",e)})),u._connector("twilsock").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),u._connector("apn").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),u._connector("fcm").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),p.on("message",(function(e,t){return u._routeMessage(e,t)})),u.updateToken(e),d&&(p.connect(),u.twilsock=p),u}return _.default(Client,[{key:"shutdown",value:(r=w.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectors.clear(),!this.twilsock){e.next=4;break}return e.next=4,this.twilsock.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"setPushRegistrationId",value:function(e,t){Q.debug("Set ".concat(e," push registration id '").concat(t,"'")),this._connector(e).setNotificationId(t)}},{key:"subscribe",value:function(e,t){Q.debug("Add ".concat(e," subscriptions for message type ").concat(t)),this._connector(e).subscribe(t)}},{key:"unsubscribe",value:function(e,t){Q.debug("Remove ".concat(e," subscriptions for message type ").concat(t)),this._connector(e).unsubscribe(t)}},{key:"updateToken",value:function(e){this.connectors.forEach((function(t){return t.updateToken(e)}))}},{key:"commitChanges",value:(n=w.default(R.default.mark((function e(){var t;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],this.connectors.forEach((function(e){e.isActive()&&t.push(e.commitChanges())})),e.next=4,Promise.all(t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"removeRegistrations",value:(t=w.default(R.default.mark((function e(t,n){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._connector(t).sendDeviceRemoveRequest(n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"handlePushNotification",value:function(e){return{messageType:e.twi_message_type,payload:e.payload}}},{key:"_routeMessage",value:function(e,t){Q.debug("Notification message arrived: ",e,t),this.emit("message",e,t)}},{key:"_connector",value:function(e){var t=this.connectors.get(e);if(!t)throw new Error("Unknown channel type: ".concat(e));return t}}],[{key:"_detectPlatform",value:function(){var e="";return"undefined"!=typeof navigator?(e="unknown",void 0!==navigator.product&&(e=navigator.product),void 0!==navigator.userAgent&&(e=navigator.userAgent)):e="web",e.substring(0,128)}}]),Client}(N),M([g.validateTypes(ce,g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),M([g.validateTypes(ce,g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),M([g.validateTypes(ce,g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),M([g.validateTypes(g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),M([g.validateTypesAsync(ce,g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=oe=M([g.validateConstructorTypes(g.nonEmptyString,[g.pureObject,"undefined",g.literal(null)]),L("design:paramtypes",[String,Object])],e.Notifications)}(SR);var UR={},NR=Tn,DR=Un,FR=X,BR=Dt,qR=Er,zR=s,WR=KS,KR=no,VR=$S,$R=GS,GR=U,JR=HS,HR=[],YR=HR.sort,QR=zR((function(){HR.sort(void 0)})),XR=zR((function(){HR.sort(null)})),ZR=KR("sort"),eI=!zR((function(){if(GR)return GR<70;if(!(VR&&VR>3)){if($R)return!0;if(JR)return JR<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=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(r=0;r<47;r++)HR.push({k:t+r,v:n})}for(HR.sort((function(e,t){return t.v-e.v})),r=0;r<HR.length;r++)t=HR[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));NR({target:"Array",proto:!0,forced:QR||!XR||!ZR||!eI},{sort:function(e){void 0!==e&&DR(e);var t=FR(this);if(eI)return void 0===e?YR.call(t):YR.call(t,e);var n,r,i=[],a=BR(t.length);for(r=0;r<a;r++)r in t&&i.push(t[r]);for(i=WR(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:qR(t)>qR(n)?1:-1}}(e)),n=i.length,r=0;r<n;)t[r]=i[r++];for(;r<a;)delete t[r++];return t}}),Object.defineProperty(UR,"__esModule",{value:!0});var tI=qm.exports,nI=hv.exports,rI=pv.exports,iI=mv.exports,aI=vv.exports,oI=gv.exports,sI=bv.exports,uI=Oy.exports,cI=zm,lI=wh.exports,fI=bh,dI=Bm,pI=HE.exports,hI=Sf.exports,vI=Ih.exports,yI=tm,gI=tb,mI=Ty.exports,bI=Iy,wI=cv.exports,kI=ZE.exports;function _I(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function xI(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var SI=_I(tI),EI=_I(nI),RI=_I(rI),II=_I(iI),TI=_I(aI),CI=_I(oI),OI=_I(sI),PI=_I(uI),AI=_I(cI),jI=_I(lI),MI=_I(pI),LI=xI(hI),UI=_I(vI),NI=xI(gI),DI=_I(mI),FI=_I(wI),BI=xI(kI);function qI(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":jI.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function zI(e,t){if("object"===("undefined"==typeof Reflect?"undefined":jI.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var WI=function(){function e(t){EI.default(this,e),this.base=t,this.args=new Array,this.paths=new Array}return RI.default(e,[{key:"pathSegment",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"queryParam",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}();function KI(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var SyncError=function(e){TI.default(SyncError,e);var t=KI(SyncError);function SyncError(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return EI.default(this,SyncError),(n=t.call(this)).name=n.constructor.name,n.message="".concat(e," (status: ").concat(r,", code: ").concat(i,")"),n.status=r,n.code=i,n}return RI.default(SyncError)}(MI.default(Error)),VI=function(e){TI.default(n,e);var t=KI(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;return EI.default(this,n),(r=t.call(this,e,i,a)).body=o,r}return RI.default(n)}(SyncError);function $I(e){return JSON.parse(JSON.stringify(e))}function GI(e){if(!(void 0===e||JI(e)))throw new SyncError("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function JI(e){return function(e){return!isNaN(parseInt(e))&&isFinite(e)}(e)&&e>0}var HI=LI.getLogger("twilio-sync");function YI(e,t){return["".concat((new Date).toISOString()," Sync ").concat(e,":")].concat(Array.from(t))}var QI=function(e){HI.setLevel(e)},XI=function(){if(HI.getLevel()==HI.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];HI.debug.apply(null,YI("T",t))}},ZI=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];HI.debug.apply(null,YI("D",t))},eT=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];HI.warn.apply(null,YI("W",t))},tT=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];HI.error.apply(null,YI("E",t))},nT="/v4/Subscriptions",rT="/v3/Maps",iT="/v3/Lists",aT="/v3/Documents",oT="/v3/Streams",sT="/v3/Insights";function uT(e,t,n){return e&&void 0!==e[t]?e[t]:n}var cT=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};EI.default(this,e);var n=t.region||"us1",r="https://cds.".concat(n,".twilio.com"),i=t.cdsUri||r;this.settings={subscriptionsUri:i+nT,documentsUri:i+aT,listsUri:i+iT,mapsUri:i+rT,streamsUri:i+oT,insightsUri:i+sT,sessionStorageEnabled:uT(t.Sync,"enableSessionStorage",!0),productId:t.productId}}return RI.default(e,[{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}}]),e}();function lT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return fT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function fT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var dT=function(){function e(t){EI.default(this,e),this.localObject=t,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return RI.default(e,[{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(e,t){this.localObject._update(e,t)}},{key:"updatePending",value:function(e,t){this.pendingAction=e,this.pendingCorrelationId=t}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(e){this.rejectedWithError=e.error,this.updatePending(null,null),this.localObject.reportFailure(new SyncError("Failed to subscribe on service events: ".concat(e.error.message),e.error.status,e.error.code))}},{key:"complete",value:function(e){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(e)}},{key:"setSubscriptionState",value:function(e){this.localObject._setSubscriptionState(e)}}]),e}(),pT=function(){function e(t){var n=this;EI.default(this,e),PI.default(this,"isConnected",!1),PI.default(this,"maxBatchSize",100),PI.default(this,"subscriptionTtlTimer",null),PI.default(this,"pendingPokeReason",null),this.services=t,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;this.backoff=yI.Backoff.exponential(Object.assign({randomisationFactor:.2,initialDelay:100,maxDelay:12e4},this.services.config.backoffConfig)),this.backoff.on("ready",(function(){var e=n.getSubscriptionUpdateBatch(),t=e.action,r=e.subscriptions;t?n.applyNewSubscriptionUpdateBatch(t,r):(n.backoff.reset(),ZI("All subscriptions resolved."))}))}var t;return RI.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function e(e,t,n,r){var i,a=[],o=lT(e);try{for(o.s();!(i=o.n()).done;){var s=UI.default(i.value,2),u=s[0],c=s[1];if(!t.get(u)&&n!==c.pendingAction&&!c.rejectedWithError&&(a.push(c),r&&a.length>=r))break}}catch(e){o.e(e)}finally{o.f()}return a}var t=e(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(t.length>0)return{action:"establish",subscriptions:t};var n=e(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return n.length>0?{action:"cancel",subscriptions:n}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:(t=SI.default(AI.default.mark((function e(t,n){var r,i,a,o,s,u,c,l,f,d,p,h,v=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=4;break}return ZI("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),e.abrupt("return");case 4:n=this.processLocalActions(t,n),r=(new Date).getTime(),i=lT(n);try{for(i.s();!(a=i.n()).done;)o=a.value,this.recordActionAttemptOn(o,t,r)}catch(e){i.e(e)}finally{i.f()}return s=this.pendingPokeReason,this.pendingPokeReason=null,e.prev=10,e.next=13,this.request(t,r,s,n);case 13:u=e.sent,c=u.body.max_batch_size,!isNaN(parseInt(c))&&isFinite(c)&&c>0&&(this.maxBatchSize=c),this.subscriptionTtlTimer||(l=u.body.ttl_in_s,!isNaN(parseFloat(l))&&isFinite(l)&&l>0&&(this.subscriptionTtlTimer=setTimeout((function(){return v.onSubscriptionTtlElapsed()}),1e3*l))),"establish"===t&&(f=u.body.estimated_delivery_in_ms,!isNaN(parseFloat(f))&&isFinite(f)&&f>0?setTimeout((function(){return v.verifyPokeDelivery(r,f,n)}),f):tT("Invalid timeout: ".concat(f)),n.filter((function(e){return e.pendingCorrelationId===r})).forEach((function(e){return e.setSubscriptionState("response_in_flight")}))),this.backoff.reset(),e.next=26;break;case 21:e.prev=21,e.t0=e.catch(10),d=lT(n);try{for(d.s();!(p=d.n()).done;)h=p.value,this.recordActionFailureOn(h,t)}catch(e){d.e(e)}finally{d.f()}e.t0 instanceof dI.TransportUnavailableError?(ZI("Twilsock connection (required for subscription) not ready (c:".concat(r,"); waiting…")),this.backoff.reset()):(ZI("Failed an attempt to ".concat(t," subscriptions (c:").concat(r,"); retrying"),e.t0),this.persist());case 26:case"end":return e.stop()}}),e,this,[[10,21]])}))),function(e,n){return t.apply(this,arguments)})},{key:"verifyPokeDelivery",value:function(e,t,n){var r=this,i=this.latestPokeResponseArrivalTimestampByCorrelationId.get(e),a=i?(new Date).getTime()-i:t;a>=t?(n.filter((function(t){return t.pendingCorrelationId===e})).forEach((function(e){e.updatePending(null,null),e.retryCount++,r.persisted.delete(e.sid)})),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(e)):setTimeout((function(){return r.verifyPokeDelivery(e,t,n)}),t-a)}},{key:"processLocalActions",value:function(e,t){return"cancel"===e?t.filter((function(e){return!e.rejectedWithError})):t}},{key:"recordActionAttemptOn",value:function(e,t,n){if(e.setSubscriptionState("request_in_flight"),"establish"===t)this.persisted.set(e.sid,e),e.updatePending(t,n);else{var r=this.persisted.get(e.sid);r&&r.updatePending(t,n)}}},{key:"recordActionFailureOn",value:function(e,t){e.setSubscriptionState("none"),e.updatePending(null,null),"establish"===t&&this.persisted.delete(e.sid)}},{key:"request",value:function(e,t,n,r){var i=r.map((function(t){return{object_sid:t.sid,object_type:t.type,last_event_id:"establish"===e?t.lastEventId:void 0,index_name:"establish"===e?t.indexName:void 0,query_string:"establish"===e?t.queryString:void 0}})),a=r.filter((function(e){return e.retryCount>0})).length;ZI("Attempting '".concat(e,"' request (c:").concat(t,"):"),i);var o={event_protocol_version:4,action:e,correlation_id:t,retried_requests:a,ttl_in_s:-1,requests:i};return"ttl"===n&&(o.reason=n),this.services.network.post(this.services.config.subscriptionsUri,o)}},{key:"add",value:function(e,t){ZI("Establishing intent to subscribe to ".concat(e));var n=this.subscriptions.get(e);n&&t&&n.lastEventId===t.lastEventId||(this.persisted.delete(e),this.subscriptions.set(e,new dT(t)),this.persist())}},{key:"remove",value:function(e){ZI("Establishing intent to unsubscribe from ".concat(e)),this.subscriptions.delete(e)&&this.persist()}},{key:"acceptMessage",value:function(e,t){XI("Subscriptions received",e);var n=e.event_type,r=void 0!==e.events?e.events:[e.event],i=e.correlation_id;i&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(i,(new Date).getTime());var a,o=lT(r);try{for(o.s();!(a=o.n()).done;){var s=a.value,u=void 0;switch(e.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(s,i);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(s,i);break;case"subscription_failed":this.applySubscriptionFailedMessage(s,i);break;case(u=n.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:var c=void 0;switch(u[0]){case"map_":c=s.map_sid;break;case"list_":c=s.list_sid;break;case"document_":c=s.document_sid;break;case"stream_":c=s.stream_sid;break;case"live_query_":c=s.query_id,t=!1,!0===e.strictly_ordered&&(t=!0);break;default:c=void 0}this.applyEventToSubscribedEntity(c,s,n,t);break;default:ZI("Dropping unknown message type ".concat(n))}}}catch(e){o.e(e)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(e,t){var n=e.object_sid,r=this.persisted.get(e.object_sid);r&&r.pendingCorrelationId===t?"interrupted"===e.replay_status?(ZI("Event Replay for subscription to ".concat(n," (c:").concat(t,") interrupted; continuing eagerly.")),r.updatePending(null,null),this.persisted.delete(r.sid),this.backoff.reset()):"completed"===e.replay_status&&(ZI("Event Replay for subscription to ".concat(n," (c:").concat(t,") completed. Subscription is ready.")),r.complete(e.last_event_id),this.persisted.set(e.object_sid,r),r.setSubscriptionState("established"),this.backoff.reset()):ZI("Late message for ".concat(e.object_sid," (c:").concat(t,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(e,t){var n=this.persisted.get(e.object_sid);n&&n.pendingCorrelationId===t?(n.updatePending(null,null),n.setSubscriptionState("none"),this.persisted.delete(e.object_sid)):ZI("Late message for ".concat(e.object_sid," (c:").concat(t,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(e,t){var n=e.object_sid,r=this.subscriptions.get(n),i=this.persisted.get(n);r&&i?i.pendingCorrelationId===t&&(tT("Failed to subscribe on ".concat(i.sid),e.error),i.markAsFailed(e),i.setSubscriptionState("none")):!r&&i&&(this.persisted.delete(n),i.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(e,t,n,r){if(e){var i;r=r||(i=this.persisted.get(e))&&i.isEstablished;var a=this.subscriptions.get(e);a?(t.type=n,a.update(t,r)):ZI("Message dropped for SID '".concat(e,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(e){this.isConnected=e,e&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(e){ZI("Triggering event replay for all subscriptions, reason=".concat(e)),this.pendingPokeReason=e,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var t,n=[],r=lT(this.persisted.values());try{for(r.s();!(t=r.n()).done;){var i=t.value;i.reset(),i.rejectedWithError&&n.push(i)}}catch(e){r.e(e)}finally{r.f()}this.persisted.clear();for(var a=0,o=n;a<o.length;a++){var s=o[a];this.persisted.set(s.sid,s)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}();function hT(e){if(e.body&&e.body.message)return e.body.message;switch(e.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function vT(e){return e.body?e.body.code:0}function yT(e){return 409===e.status?new VI(hT(e),e.status,vT(e),e.body):e.status?new SyncError(hT(e),e.status,vT(e)):e instanceof dI.TransportUnavailableError?e:new SyncError(e.message,0,0)}var gT=function(){function e(t,n,r){EI.default(this,e),this.clientInfo=t,this.config=n,this.transport=r}return RI.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+NI.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:4e3,max:6e4,maxAttemptsTime:9e4,randomness:.2},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new Promise((function(r,i){var a=[502,503,504];n&&a.push(429);var o=new yI.Retrier(t.backoffConfig());o.on("attempt",(function(){e().then((function(e){return o.succeeded(e)})).catch((function(e){if(a.includes(e.status)){var t=parseInt(e.headers?e.headers["Retry-After"]:null);o.failed(yT(e),isNaN(t)?null:1e3*t)}else"Twilsock disconnected"===e.message?o.failed(yT(e)):(o.removeAllListeners(),o.cancel(),i(yT(e)))}))})),o.on("succeeded",(function(e){r(e)})),o.on("cancelled",(function(e){return i(yT(e))})),o.on("failed",(function(e){return i(yT(e))})),o.start()}))}},{key:"get",value:function(e){var t=this,n=this.createHeaders();return ZI("GET",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry((function(){return t.transport.get(e,n,t.config.productId)}),!0)}},{key:"post",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=this.createHeaders();return null!=n&&(a["If-Match"]=n),ZI("POST",e,"ID:",a["Twilio-Request-Id"]),this.executeWithRetry((function(){return r.transport.post(e,a,t,r.config.productId)}),i)}},{key:"put",value:function(e,t,n){var r=this,i=this.createHeaders();return null!=n&&(i["If-Match"]=n),ZI("PUT",e,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry((function(){return r.transport.put(e,i,t,r.config.productId)}),!1)}},{key:"delete",value:function(e){var t=this,n=this.createHeaders();return ZI("DELETE",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry((function(){return t.transport.delete(e,n,t.config.productId)}),!1)}}]),e}(),mT=function(){function e(t,n){EI.default(this,e),this.config=t,this.storageId=null;try{this.storage=n||sessionStorage}catch(e){}}return RI.default(e,[{key:"storageKey",value:function(e,t){return"".concat(this.storageId,"::").concat(e,"::").concat(t)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(e){this.storageId=e}},{key:"store",value:function(e,t,n){return this.isReady?this._store(this.storageKey(e,t),n):null}},{key:"read",value:function(e,t){return this.isReady?this._read(this.storageKey(e,t)):null}},{key:"remove",value:function(e,t,n){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(e,t)),n&&this.storage.removeItem(this.storageKey(e,n))}catch(e){}}},{key:"update",value:function(e,t,n,r){if(!this.isReady)return null;this._apply(this.storageKey(e,t),r),n&&this._apply(this.storageKey(e,n),r)}},{key:"_store",value:function(e,t){try{this.storage.setItem(e,JSON.stringify(t))}catch(e){}}},{key:"_read",value:function(e){try{var t=this.storage.getItem(e);if(t)return JSON.parse(t)}catch(e){}return null}},{key:"_apply",value:function(e,t){var n=this._read(e);if(!n)return!1;this._store(e,Object.assign(n,t))}}]),e}();function bT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return wT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function wT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var kT=function(){function e(t,n){EI.default(this,e),this.services=t,this.removalHandler=n,this.subscriptionState="none",this._attachedListeners=new Map}return RI.default(e,[{key:"_advanceLastEventId",value:function(e,t){}},{key:"reportFailure",value:function(e){404===e.status?this.onRemoved(!1):this.broadcastEventToListeners("failure",e)}},{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(e){this.subscriptionState=e,this.broadcastEventToListeners("_subscriptionStateChanged",e)}},{key:"close",value:function(){this._unsubscribe(),null!=this.removalHandler&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(e){var t=e.listenerUuid;this._attachedListeners.get(t)||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(t,e))}},{key:"detach",value:function(e){this._attachedListeners.delete(e),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i,a=bT(this._attachedListeners.values());try{for(a.s();!(i=a.n()).done;){var o=i.value;o.emit.apply(o,[e].concat(n))}}catch(e){a.e(e)}finally{a.f()}}}]),e}(),_T=function(){function e(t){EI.default(this,e),PI.default(this,"queuedRequests",[]),PI.default(this,"isRequestInFlight",!1),this.inputMergingFunction=t}return RI.default(e,[{key:"add",value:function(e,t){var n=this,r=new Promise((function(r,i){return n.queuedRequests.push({input:e,requestFunction:t,resolve:r,reject:i})}));return this.wakeupQueue(),r}},{key:"squashAndAdd",value:function(e,t){var n,r=this.queuedRequests;this.queuedRequests=[],r.length>0?(n=r.map((function(e){return e.input})).reduce(this.inputMergingFunction),n=this.inputMergingFunction(n,e)):n=e;var i=this.add(n,t);return r.forEach((function(e){return i.then(e.resolve,e.reject)})),i}},{key:"isEmpty",value:function(){return 0===this.queuedRequests.length&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var e=this;if(0!==this.queuedRequests.length&&!this.isRequestInFlight){var t=this.queuedRequests.shift();this.isRequestInFlight=!0,t.requestFunction(t.input).then(t.resolve,t.reject).then((function(t){e.isRequestInFlight=!1,e.wakeupQueue()}))}}}]),e}(),xT=function(){function e(t){EI.default(this,e),PI.default(this,"queueByNamespaceKey",new Map),this.inputReducer=t}var t,n,r;return RI.default(e,[{key:"add",value:(r=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,(function(e){return e.add(n,r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"squashAndAdd",value:(n=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,(function(e){return e.squashAndAdd(n,r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"invokeQueueMethod",value:(t=SI.default(AI.default.mark((function e(t,n){var r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queueByNamespaceKey.has(t)||this.queueByNamespaceKey.set(t,new _T(this.inputReducer)),r=this.queueByNamespaceKey.get(t),i=n(r),this.queueByNamespaceKey.get(t).isEmpty()&&this.queueByNamespaceKey.delete(t),e.abrupt("return",i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]),e}();function ST(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var ET=function(e){TI.default(n,e);var t=ST(n);function n(){var e;return EI.default(this,n),(e=t.call(this)).closed=!1,e.uuid=gI.v4(),e}return RI.default(n,[{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")}}]),n}(bI.ReplayEventEmitter);function RT(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var IT=function(e){TI.default(f,e);var t,n,r,i,a,o,s,u,c,l=RT(f);function f(e,t,n){var r;EI.default(this,f),r=l.call(this,e,n),PI.default(II.default(r),"isDeleted",!1);return r.updateMergingQueue=new _T((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.descriptor=t,r.descriptor.data=r.descriptor.data||{},r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return RI.default(f,[{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(e){switch(e.date_created=new Date(e.date_created),e.type){case"document_updated":if(e.id<=this.lastEventId){XI("Document update skipped, current:",this.lastEventId,", remote:",e.id);break}var t=void 0!==this.descriptor.data?$I(this.descriptor.data):null;this.descriptor.last_event_id=e.id,this.descriptor.revision=e.document_revision,this.descriptor.date_updated=e.date_created,this.descriptor.data=e.document_data,this.broadcastEventToListeners("updated",{data:e.document_data,isLocal:!1,previousData:t}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.id,revision:e.document_revision,date_updated:e.date_created,data:e.document_data});break;case"document_removed":this.onRemoved(!1)}}},{key:"set",value:(c=SI.default(AI.default.mark((function e(t,n){var r,i=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(r,(function(e){return i._setUnconditionally(t,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"mutate",value:(u=SI.default(AI.default.mark((function e(t,n){var r,i=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},e.abrupt("return",this.updateMergingQueue.add(r,(function(e){return i._setWithIfMatch(t,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"update",value:(s=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate((function(e){return Object.assign(e,t)}),n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"setTtl",value:(o=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({ttl:t});case 2:n=e.sent,this.descriptor.date_expires=n.date_expires;case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_setUnconditionally",value:(a=SI.default(AI.default.mark((function e(t,n){var r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({data:t,revision:void 0,ttl:n});case 2:return r=e.sent,this._handleSuccessfulUpdateResult(r),e.abrupt("return",this.descriptor.data);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"_setWithIfMatch",value:(i=SI.default(AI.default.mark((function e(t,n){var r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t($I(this.descriptor.data)))){e.next=22;break}return i=this.revision,e.prev=3,e.next=6,this._postUpdateToServer({data:r,revision:i,ttl:n});case 6:return a=e.sent,this._handleSuccessfulUpdateResult(a),e.abrupt("return",this.descriptor.data);case 11:if(e.prev=11,e.t0=e.catch(3),412!==e.t0.status){e.next=19;break}return e.next=16,this._softSync();case 16:return e.abrupt("return",this._setWithIfMatch(t));case 19:throw e.t0;case 20:e.next=23;break;case 22:return e.abrupt("return",this.descriptor.data);case 23:case"end":return e.stop()}}),e,this,[[3,11]])}))),function(e,t){return i.apply(this,arguments)})},{key:"_handleSuccessfulUpdateResult",value:function(e){if(!(e.last_event_id<=this.descriptor.last_event_id)){var t=void 0!==this.descriptor.data?$I(this.descriptor.data):null;this.descriptor.revision=e.revision,this.descriptor.data=e.data,this.descriptor.last_event_id=e.last_event_id,this.descriptor.date_expires=e.date_expires,this.descriptor.date_updated=new Date(e.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.last_event_id,revision:e.revision,date_updated:e.date_updated,data:e.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:t})}}},{key:"_postUpdateToServer",value:(r=SI.default(AI.default.mark((function e(t){var n,r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=17;break}return n={data:t.data},void 0!==t.ttl&&(n.ttl=t.ttl),r=t.revision,e.prev=4,e.next=7,this.services.network.post(this.uri,n,r);case 7:return i=e.sent,e.abrupt("return",{revision:i.body.revision,data:t.data,last_event_id:i.body.last_event_id,date_updated:i.body.date_updated,date_expires:i.body.date_expires});case 11:throw e.prev=11,e.t0=e.catch(4),404===e.t0.status&&this.onRemoved(!1),e.t0;case 15:e.next=18;break;case 17:return e.abrupt("return",Promise.reject(new SyncError("The Document has been removed",404,54100)));case 18:case"end":return e.stop()}}),e,this,[[4,11]])}))),function(e){return r.apply(this,arguments)})},{key:"_softSync",value:(n=SI.default(AI.default.mark((function e(){var t=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.network.get(this.uri).then((function(e){var n={type:"document_updated",id:e.body.last_event_id,document_revision:e.body.revision,document_data:e.body.data,date_created:e.body.date_updated};return t._update(n),t})).catch((function(e){404===e.status?t.onRemoved(!1):tT("Can't get updates for ".concat(t.sid,":"),e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"onRemoved",value:function(e){if(!this.isDeleted){var t=void 0!==this.descriptor.data?$I(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e,previousData:t})}}},{key:"removeDocument",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=6;break}return e.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),e.next=7;break;case 6:return e.abrupt("return",Promise.reject(new SyncError("The Document has been removed",404,54100)));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"type",get:function(){return"document"}}]),f}(kT),TT=function(e){TI.default(s,e);var t,n,r,i,a,o=RT(s);function s(e){var t;return EI.default(this,s),(t=o.call(this)).syncDocumentImpl=e,t.syncDocumentImpl.attach(II.default(t)),t}return RI.default(s,[{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 IT.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:(a=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.set(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"mutate",value:(i=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.mutate(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"update",value:(r=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.update(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setTtl",value:(n=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"removeDocument",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){DI.default(OI.default(s.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return IT.type}}]),s}(ET);PI.default(TT,"removed","removed"),PI.default(TT,"updated","updated"),qI([fI.validateTypesAsync(fI.pureObject,["undefined",fI.objectSchema("document metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object,Object]),zI("design:returntype",Promise)],TT.prototype,"set",null),qI([fI.validateTypesAsync("function",["undefined",fI.objectSchema("document metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Function,Object]),zI("design:returntype",Promise)],TT.prototype,"mutate",null),qI([fI.validateTypesAsync(fI.pureObject,["undefined",fI.objectSchema("document metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object,Object]),zI("design:returntype",Promise)],TT.prototype,"update",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],TT.prototype,"setTtl",null);var CT=function(){function e(t){EI.default(this,e),this.descriptor=t}return RI.default(e,[{key:"url",get:function(){return this.descriptor.url}},{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:"cacheKey",get:function(){return this.index}},{key:"update",value:function(e,t,n,r){return this.descriptor.lastEventId=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.dateUpdated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.dateExpires=e}}]),e}(),Paginator=function(){function Paginator(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;EI.default(this,Paginator),this.items=e,this.source=t,this.prevPageItemId=n,this.nextPageItemId=r}var e,t;return RI.default(Paginator,[{key:"nextPage",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasNextPage){e.next=2;break}throw new Error("No next page");case 2:return e.abrupt("return",this.source({nextPageItemId:this.nextPageItemId}));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"prevPage",value:(e=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasPrevPage){e.next=2;break}throw new Error("No previous page");case 2:return e.abrupt("return",this.source({prevPageItemId:this.prevPageItemId}));case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"hasNextPage",get:function(){return null!==this.nextPageItemId}},{key:"hasPrevPage",get:function(){return null!==this.prevPageItemId}}]),Paginator}();function OT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return PT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return PT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function PT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var AT=function(){function e(t,n){EI.default(this,e),this.balanceFactor=0,this.key=t,this.value=n,this.parent=null,this.left=null,this.right=null}return RI.default(e,[{key:"isRoot",get:function(){return null===this.parent}},{key:"isLeaf",get:function(){return null===this.left&&null===this.right}},{key:"isLeftChild",get:function(){return this.parent.left===this}},{key:"update",value:function(e){this.value=e}},{key:"replace",value:function(e,t){e&&(this.left===t?this.left=t:this.right===t&&(this.right=t))}}]),e}(),jT=function(e){function t(e,n){EI.default(this,t),this.isLessThan=e||function(e,t){return e<t},this.isEqual=n||function(e,t){return e===t},this.root=null,this.count=null}return RI.default(t,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(e,t){var n=this.getNode(e);n?n.update(t):this.insert(e,t)}},{key:"insert",value:function(e,t){var n=new AT(e,t);if(this.count++,this.root){for(var r=this.root;;)if(this.isLessThan(e,r.key)){if(!r.left){r.left=n;break}r=r.left}else{if(!r.right){r.right=n;break}r=r.right}for(n.parent=r,r=n;r.parent;){var i=r.parent,a=i.balanceFactor;if(r.isLeftChild?i.balanceFactor++:i.balanceFactor--,Math.abs(i.balanceFactor)<Math.abs(a))break;if(i.balanceFactor<-1||i.balanceFactor>1){this.rebalance(i);break}r=i}}else this.root=n}},{key:"get",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t.value;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"delete",value:function(e){var t=this.getNode(e);if(!t||t.key!==e)return null;var n=t.parent,r=t.left,i=t.right;if(!!r!=!!i){var a=r||i;n||a?n&&!a?this.root=a:(n.replace(t,null),this.rebalance(n)):this.root=null}else{for(var o=t.left;o.right;)o=o.right;if(t.left===o)t.isRoot?(this.root=o,o.parent=null):(t.isLeftChild?t.parent.left=o:t.parent.right=o,o.parent=t.parent),o.right=t.right,o.right.parent=o,o.balanceFactor=t.balanceFactor,t={parent:o,isLeftChild:!0};else{var s=o.parent,u=o.left;s.right=u,u&&(u.parent=s),t.isRoot?(this.root=o,o.parent=null):(t.isLeftChild?t.parent.left=o:t.parent.right=o,o.parent=t.parent),o.right=t.right,o.right.parent=o,o.left=t.left,o.left.parent=o,o.balanceFactor=t.balanceFactor,t={parent:s,isLeftChild:!1}}}for(this.count--;t.parent;){var c=t.parent,l=c.balanceFactor;if(t.isLeftChild?c.balanceFactor-=1:c.balanceFactor+=1,Math.abs(c.balanceFactor)>Math.abs(l)){if(!(c.balanceFactor<-1||c.balanceFactor>1))break;if(this.rebalance(c),0!==c.parent.balanceFactor)break;t=c.parent}else t=c}return null}},{key:"getNode",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"rebalance",value:function(e){e.balanceFactor<0?e.right.balanceFactor>0?(this.rotateRight(e.right),this.rotateLeft(e)):this.rotateLeft(e):e.balanceFactor>0&&(e.left.balanceFactor<0?(this.rotateLeft(e.left),this.rotateRight(e)):this.rotateRight(e))}},{key:"rotateLeft",value:function(e){var t=e.right;e.right=t.left,null!==t.left&&(t.left.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.left=e,e.parent=t,e.balanceFactor=e.balanceFactor+1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor+1-Math.max(e.balanceFactor,0)}},{key:"rotateRight",value:function(e){var t=e.left;e.left=t.right,null!==t.right&&(t.right.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.right=e,e.parent=t,e.balanceFactor=e.balanceFactor-1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor-1-Math.max(e.balanceFactor,0)}},{key:e,value:AI.default.mark((function e(){var t,n,r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=OT(this.getIterator()),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=n.value,e.next=7,r;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:"getIterator",value:AI.default.mark((function e(){var t,n,r,i=arguments;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i.length>0&&void 0!==i[0]?i[0]:null,n=this.root;case 2:if(!n){e.next=8;break}if(!this.isEqual(t,n.key)&&(null!==t||n.left)){e.next=5;break}return e.abrupt("break",8);case 5:n=this.isLessThan(t,n.key)||null===t?n.left:n.right,e.next=2;break;case 8:if(n){e.next=10;break}return e.abrupt("return",null);case 10:r=!0;case 11:if(!r){e.next=29;break}return e.next=14,[n.key,n.value];case 14:if(r=!1,!n.right){e.next=21;break}for(n=n.right;n.left;)n=n.left;r=!0,e.next=27;break;case 21:if(!n.parent){e.next=26;break}r=n.parent.left===n,n=n.parent,e.next=27;break;case 26:return e.abrupt("break",37);case 27:e.next=35;break;case 29:if(!n.parent){e.next=34;break}r=n.parent.left===n,n=n.parent,e.next=35;break;case 34:return e.abrupt("break",37);case 35:e.next=11;break;case 37:return e.abrupt("return",null);case 38:case"end":return e.stop()}}),e,this)}))},{key:"getReverseIterator",value:AI.default.mark((function e(){var t,n,r,i=arguments;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i.length>0&&void 0!==i[0]?i[0]:null,n=this.root;case 2:if(!n){e.next=8;break}if(!this.isEqual(t,n.key)&&(null!==t||n.right)){e.next=5;break}return e.abrupt("break",8);case 5:n=this.isLessThan(t,n.key)&&null!==t?n.left:n.right,e.next=2;break;case 8:if(n){e.next=10;break}return e.abrupt("return",null);case 10:r=!0;case 11:if(!r){e.next=29;break}return e.next=14,[n.key,n.value];case 14:if(r=!1,!n.left){e.next=21;break}for(n=n.left;n.right;)n=n.right;r=!0,e.next=27;break;case 21:if(!n.parent){e.next=26;break}r=n.parent.right===n,n=n.parent,e.next=27;break;case 26:return e.abrupt("break",37);case 27:e.next=35;break;case 29:if(!n.parent){e.next=34;break}r=n.parent.right===n,n=n.parent,e.next=35;break;case 34:return e.abrupt("break",37);case 35:e.next=11;break;case 37:return e.abrupt("return",null);case 38:case"end":return e.stop()}}),e,this)}))}]),t}(Symbol.iterator);function MT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return LT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return LT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function LT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var UT=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];EI.default(this,e),this._data=t,this.lastEventId=n||0,this.isLeftBound=r,this.isRightBound=i}return RI.default(e,[{key:"isValid",get:function(){return!0}},{key:"value",get:function(){return this._data}}]),e}(),NT=function(){function e(t){EI.default(this,e),this.lastEventId=t,this.isLeftBound=!1,this.isRightBound=!1}return RI.default(e,[{key:"isValid",get:function(){return!1}},{key:"value",get:function(){return null}}]),e}(),DT=function(){function e(){EI.default(this,e),PI.default(this,"items",new jT),PI.default(this,"beginKey",null),PI.default(this,"endKey",null),this.items.clear()}return RI.default(e,[{key:"size",get:function(){return this.items.size}},{key:"collectionBegin",get:function(){return this.beginKey}},{key:"collectionEnd",get:function(){return this.endKey}},{key:"has",value:function(e){var t,n=this.items.get(e);return null!==(t=null==n?void 0:n.isValid)&&void 0!==t&&t}},{key:"exists",value:function(e){return!!this.items.get(e)}},{key:"getValue",value:function(e){var t,n=this.items.get(e);return null!==(t=null==n?void 0:n.value)&&void 0!==t?t:null}},{key:"get",value:function(e){return this.items.get(e)}},{key:"getNextItem",value:function(e,t,n){return null===e?this.getFirstItem(t):n?this.getValue(e):this.getAdjacentItem(e,t)}},{key:"getFirstItem",value:function(e){var t="asc"===e?this.beginKey:this.endKey;if(this.exists(t)){var n=this.items.get(t);return n.isValid?n.value:this.getAdjacentItem(t,e)}return null}},{key:"getAdjacentItem",value:function(e,t){var n,r=MT("asc"===t?this.items.getIterator(e):this.items.getReverseIterator(e));try{for(r.s();!(n=r.n()).done;){var i=UI.default(n.value,2),a=(i[0],i[1]);if("asc"===t?a.isRightBound:a.isLeftBound)break;if(a.isValid)return a.value}}catch(e){r.e(e)}finally{r.f()}return null}},{key:"store",value:function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=this.items.get(e);if(a&&a.lastEventId>n)return a.value;if(this.items.set(e,new UT(t,n,a?a.isLeftBound&&r:r,a?a.isRightBound&&i:i)),null!==this.beginKey&&e<this.beginKey){var o=this.items.get(this.beginKey);o&&(o.isLeftBound=!1),this.beginKey=e}if(null!==this.endKey&&this.endKey<e){var s=this.items.get(this.endKey);s&&(s.isRightBound=!1),this.endKey=e}return t}},{key:"populate",value:function(e,t,n){var r=this;if(e.length){var i=FI.default(e);if(i.sort((function(e,t){return e.cacheKey===t.cacheKey?0:e.cacheKey>t.cacheKey?1:-1})),i.forEach((function(e,t){r.store(e.cacheKey,e,e.lastEventId,0===t,t===i.length-1)})),t){var a=i[0].cacheKey;(!this.beginKey||a<this.beginKey)&&(this.beginKey=a)}if(n){var o=i[i.length-1].cacheKey;(!this.endKey||this.endKey<o)&&(this.endKey=o)}}}},{key:"delete",value:function(e,t){var n=this.items.get(e);(null===n||null===t||n.lastEventId<t)&&this.items.set(e,new NT(t))}},{key:"isKnown",value:function(e,t){var n=this.items.get(e);return n&&n.lastEventId>=t}},{key:"getIterator",value:AI.default.mark((function e(t){var n,r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===t&&null!==this.beginKey&&(t=this.beginKey),null!==t){e.next=3;break}return e.abrupt("return");case 3:n=MT(this.items.getIterator(t)),e.prev=4,n.s();case 6:if((r=n.n()).done){e.next=16;break}if(i=UI.default(r.value,2),(a=i[1]).isValid){e.next=10;break}return e.abrupt("continue",14);case 10:return e.next=12,a;case 12:if(!a.isRightBound){e.next=14;break}return e.abrupt("break",16);case 14:e.next=6;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(4),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[4,18,21,24]])}))},{key:"getReverseIterator",value:AI.default.mark((function e(t){var n,r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===t&&null!==this.endKey&&(t=this.endKey),null!==t){e.next=3;break}return e.abrupt("return");case 3:n=MT(this.items.getReverseIterator(t)),e.prev=4,n.s();case 6:if((r=n.n()).done){e.next=16;break}if(i=UI.default(r.value,2),(a=i[1]).isValid){e.next=10;break}return e.abrupt("continue",14);case 10:return e.next=12,a;case 12:if(!a.isLeftBound){e.next=14;break}return e.abrupt("break",16);case 14:e.next=6;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(4),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[4,18,21,24]])}))},{key:"forEach",value:function(e){if(this.items){var t,n=MT(this.items);try{for(n.s();!(t=n.n()).done;){var r=UI.default(t.value,2),i=r[0],a=r[1];a.isValid&&e(i,a.value)}}catch(e){n.e(e)}finally{n.f()}}}}]),e}(),FT="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{},BT={exports:{}};function qT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return zT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function zT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function WT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function KT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?WT(Object(n),!0).forEach((function(t){PI.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WT(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function VT(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}!function(e,t){(function(){var n,r="Expected a function",i="__lodash_hash_undefined__",a="__lodash_placeholder__",o=16,s=32,u=64,c=128,l=256,f=1/0,d=9007199254740991,p=NaN,h=4294967295,v=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",s],["partialRight",u],["rearg",l]],y="[object Arguments]",g="[object Array]",m="[object Boolean]",b="[object Date]",w="[object Error]",k="[object Function]",_="[object GeneratorFunction]",x="[object Map]",S="[object Number]",E="[object Object]",R="[object Promise]",I="[object RegExp]",T="[object Set]",C="[object String]",O="[object Symbol]",P="[object WeakMap]",A="[object ArrayBuffer]",j="[object DataView]",M="[object Float32Array]",L="[object Float64Array]",U="[object Int8Array]",N="[object Int16Array]",D="[object Int32Array]",F="[object Uint8Array]",B="[object Uint8ClampedArray]",q="[object Uint16Array]",z="[object Uint32Array]",W=/\b__p \+= '';/g,K=/\b(__p \+=) '' \+/g,V=/(__e\(.*?\)|\b__t\)) \+\n'';/g,$=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,J=RegExp($.source),H=RegExp(G.source),Y=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ee=/^\w*$/,te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ne=/[\\^$.*+?()[\]{}|]/g,re=RegExp(ne.source),ie=/^\s+/,ae=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ue=/,? & /,ce=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,fe=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pe=/\w*$/,he=/^[-+]0x[0-9a-f]+$/i,ve=/^0b[01]+$/i,ye=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,we=/($^)/,ke=/['\n\r\u2028\u2029\\]/g,_e="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xe="\\u2700-\\u27bf",Se="a-z\\xdf-\\xf6\\xf8-\\xff",Ee="A-Z\\xc0-\\xd6\\xd8-\\xde",Re="\\ufe0e\\ufe0f",Ie="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Te="['’]",Ce="[\\ud800-\\udfff]",Oe="["+Ie+"]",Pe="["+_e+"]",Ae="\\d+",je="[\\u2700-\\u27bf]",Me="["+Se+"]",Le="[^\\ud800-\\udfff"+Ie+Ae+xe+Se+Ee+"]",Ue="\\ud83c[\\udffb-\\udfff]",Ne="[^\\ud800-\\udfff]",De="(?:\\ud83c[\\udde6-\\uddff]){2}",Fe="[\\ud800-\\udbff][\\udc00-\\udfff]",Be="["+Ee+"]",qe="(?:"+Me+"|"+Le+")",ze="(?:"+Be+"|"+Le+")",We="(?:['’](?:d|ll|m|re|s|t|ve))?",Ke="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ve="(?:"+Pe+"|"+Ue+")"+"?",$e="[\\ufe0e\\ufe0f]?",Ge=$e+Ve+("(?:\\u200d(?:"+[Ne,De,Fe].join("|")+")"+$e+Ve+")*"),Je="(?:"+[je,De,Fe].join("|")+")"+Ge,He="(?:"+[Ne+Pe+"?",Pe,De,Fe,Ce].join("|")+")",Ye=RegExp(Te,"g"),Qe=RegExp(Pe,"g"),Xe=RegExp(Ue+"(?="+Ue+")|"+He+Ge,"g"),Ze=RegExp([Be+"?"+Me+"+"+We+"(?="+[Oe,Be,"$"].join("|")+")",ze+"+"+Ke+"(?="+[Oe,Be+qe,"$"].join("|")+")",Be+"?"+qe+"+"+We,Be+"+"+Ke,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ae,Je].join("|"),"g"),et=RegExp("[\\u200d\\ud800-\\udfff"+_e+Re+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],rt=-1,it={};it[M]=it[L]=it[U]=it[N]=it[D]=it[F]=it[B]=it[q]=it[z]=!0,it[y]=it[g]=it[A]=it[m]=it[j]=it[b]=it[w]=it[k]=it[x]=it[S]=it[E]=it[I]=it[T]=it[C]=it[P]=!1;var at={};at[y]=at[g]=at[A]=at[j]=at[m]=at[b]=at[M]=at[L]=at[U]=at[N]=at[D]=at[x]=at[S]=at[E]=at[I]=at[T]=at[C]=at[O]=at[F]=at[B]=at[q]=at[z]=!0,at[w]=at[k]=at[P]=!1;var ot={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},st=parseFloat,ut=parseInt,ct="object"==jI.default(FT)&&FT&&FT.Object===Object&&FT,lt="object"==("undefined"==typeof self?"undefined":jI.default(self))&&self&&self.Object===Object&&self,ft=ct||lt||Function("return this")(),dt=t&&!t.nodeType&&t,pt=dt&&e&&!e.nodeType&&e,ht=pt&&pt.exports===dt,vt=ht&&ct.process,yt=function(){try{var e=pt&&pt.require&&pt.require("util").types;return e||vt&&vt.binding&&vt.binding("util")}catch(e){}}(),gt=yt&&yt.isArrayBuffer,mt=yt&&yt.isDate,bt=yt&&yt.isMap,wt=yt&&yt.isRegExp,kt=yt&&yt.isSet,_t=yt&&yt.isTypedArray;function xt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function St(e,t,n,r){for(var i=-1,a=null==e?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function Et(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}function Rt(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function It(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function Tt(e,t){for(var n=-1,r=null==e?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function Ct(e,t){return!!(null==e?0:e.length)&&Ft(e,t,0)>-1}function Ot(e,t,n){for(var r=-1,i=null==e?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function Pt(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function At(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function jt(e,t,n,r){var i=-1,a=null==e?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function Mt(e,t,n,r){var i=null==e?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}function Lt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Ut=Wt("length");function Nt(e,t,n){var r;return n(e,(function(e,n,i){if(t(e,n,i))return r=n,!1})),r}function Dt(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Ft(e,t,n){return t==t?function(e,t,n){var r=n-1,i=e.length;for(;++r<i;)if(e[r]===t)return r;return-1}(e,t,n):Dt(e,qt,n)}function Bt(e,t,n,r){for(var i=n-1,a=e.length;++i<a;)if(r(e[i],t))return i;return-1}function qt(e){return e!=e}function zt(e,t){var n=null==e?0:e.length;return n?$t(e,t)/n:p}function Wt(e){return function(t){return null==t?n:t[e]}}function Kt(e){return function(t){return null==e?n:e[t]}}function Vt(e,t,n,r,i){return i(e,(function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)})),n}function $t(e,t){for(var r,i=-1,a=e.length;++i<a;){var o=t(e[i]);o!==n&&(r=r===n?o:r+o)}return r}function Gt(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function Jt(e){return e?e.slice(0,pn(e)+1).replace(ie,""):e}function Ht(e){return function(t){return e(t)}}function Yt(e,t){return Pt(t,(function(t){return e[t]}))}function Qt(e,t){return e.has(t)}function Xt(e,t){for(var n=-1,r=e.length;++n<r&&Ft(t,e[n],0)>-1;);return n}function Zt(e,t){for(var n=e.length;n--&&Ft(t,e[n],0)>-1;);return n}function en(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var tn=Kt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),nn=Kt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function rn(e){return"\\"+ot[e]}function an(e){return et.test(e)}function on(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function sn(e,t){return function(n){return e(t(n))}}function un(e,t){for(var n=-1,r=e.length,i=0,o=[];++n<r;){var s=e[n];s!==t&&s!==a||(e[n]=a,o[i++]=n)}return o}function cn(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}function ln(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=[e,e]})),n}function fn(e){return an(e)?function(e){var t=Xe.lastIndex=0;for(;Xe.test(e);)++t;return t}(e):Ut(e)}function dn(e){return an(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function pn(e){for(var t=e.length;t--&&ae.test(e.charAt(t)););return t}var hn=Kt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var vn=function e(t){var ae=(t=null==t?ft:vn.defaults(ft.Object(),t,vn.pick(ft,nt))).Array,_e=t.Date,xe=t.Error,Se=t.Function,Ee=t.Math,Re=t.Object,Ie=t.RegExp,Te=t.String,Ce=t.TypeError,Oe=ae.prototype,Pe=Se.prototype,Ae=Re.prototype,je=t["__core-js_shared__"],Me=Pe.toString,Le=Ae.hasOwnProperty,Ue=0,Ne=function(){var e=/[^.]+$/.exec(je&&je.keys&&je.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),De=Ae.toString,Fe=Me.call(Re),Be=ft._,qe=Ie("^"+Me.call(Le).replace(ne,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=ht?t.Buffer:n,We=t.Symbol,Ke=t.Uint8Array,Ve=ze?ze.allocUnsafe:n,$e=sn(Re.getPrototypeOf,Re),Ge=Re.create,Je=Ae.propertyIsEnumerable,He=Oe.splice,Xe=We?We.isConcatSpreadable:n,et=We?We.iterator:n,ot=We?We.toStringTag:n,ct=function(){try{var e=da(Re,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==ft.clearTimeout&&t.clearTimeout,dt=_e&&_e.now!==ft.Date.now&&_e.now,pt=t.setTimeout!==ft.setTimeout&&t.setTimeout,vt=Ee.ceil,yt=Ee.floor,Ut=Re.getOwnPropertySymbols,Kt=ze?ze.isBuffer:n,yn=t.isFinite,gn=Oe.join,mn=sn(Re.keys,Re),bn=Ee.max,wn=Ee.min,kn=_e.now,_n=t.parseInt,xn=Ee.random,Sn=Oe.reverse,En=da(t,"DataView"),Rn=da(t,"Map"),In=da(t,"Promise"),Tn=da(t,"Set"),Cn=da(t,"WeakMap"),On=da(Re,"create"),Pn=Cn&&new Cn,An={},jn=Fa(En),Mn=Fa(Rn),Ln=Fa(In),Un=Fa(Tn),Nn=Fa(Cn),Dn=We?We.prototype:n,Fn=Dn?Dn.valueOf:n,Bn=Dn?Dn.toString:n;function qn(e){if(rs(e)&&!$o(e)&&!(e instanceof Vn)){if(e instanceof Kn)return e;if(Le.call(e,"__wrapped__"))return Ba(e)}return new Kn(e)}var zn=function(){function e(){}return function(t){if(!ns(t))return{};if(Ge)return Ge(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Wn(){}function Kn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function Vn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=h,this.__views__=[]}function $n(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Gn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Hn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Jn;++t<n;)this.add(e[t])}function Yn(e){var t=this.__data__=new Gn(e);this.size=t.size}function Qn(e,t){var n=$o(e),r=!n&&Vo(e),i=!n&&!r&&Yo(e),a=!n&&!r&&!i&&fs(e),o=n||r||i||a,s=o?Gt(e.length,Te):[],u=s.length;for(var c in e)!t&&!Le.call(e,c)||o&&("length"==c||i&&("offset"==c||"parent"==c)||a&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ba(c,u))||s.push(c);return s}function Xn(e){var t=e.length;return t?e[Hr(0,t-1)]:n}function Zn(e,t){return Ua(Oi(e),ur(t,0,e.length))}function er(e){return Ua(Oi(e))}function tr(e,t,r){(r!==n&&!zo(e[t],r)||r===n&&!(t in e))&&or(e,t,r)}function nr(e,t,r){var i=e[t];Le.call(e,t)&&zo(i,r)&&(r!==n||t in e)||or(e,t,r)}function rr(e,t){for(var n=e.length;n--;)if(zo(e[n][0],t))return n;return-1}function ir(e,t,n,r){return pr(e,(function(e,i,a){t(r,e,n(e),a)})),r}function ar(e,t){return e&&Pi(t,js(t),e)}function or(e,t,n){"__proto__"==t&&ct?ct(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function sr(e,t){for(var r=-1,i=t.length,a=ae(i),o=null==e;++r<i;)a[r]=o?n:Ts(e,t[r]);return a}function ur(e,t,r){return e==e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function cr(e,t,r,i,a,o){var s,u=1&t,c=2&t,l=4&t;if(r&&(s=a?r(e,i,a,o):r(e)),s!==n)return s;if(!ns(e))return e;var f=$o(e);if(f){if(s=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Le.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!u)return Oi(e,s)}else{var d=va(e),p=d==k||d==_;if(Yo(e))return Si(e,u);if(d==E||d==y||p&&!a){if(s=c||p?{}:ga(e),!u)return c?function(e,t){return Pi(e,ha(e),t)}(e,function(e,t){return e&&Pi(t,Ms(t),e)}(s,e)):function(e,t){return Pi(e,pa(e),t)}(e,ar(s,e))}else{if(!at[d])return a?e:{};s=function(e,t,n){var r=e.constructor;switch(t){case A:return Ei(e);case m:case b:return new r(+e);case j:return function(e,t){var n=t?Ei(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case M:case L:case U:case N:case D:case F:case B:case q:case z:return Ri(e,n);case x:return new r;case S:case C:return new r(e);case I:return function(e){var t=new e.constructor(e.source,pe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case T:return new r;case O:return i=e,Fn?Re(Fn.call(i)):{}}var i}(e,d,u)}}o||(o=new Yn);var h=o.get(e);if(h)return h;o.set(e,s),us(e)?e.forEach((function(n){s.add(cr(n,t,r,n,e,o))})):is(e)&&e.forEach((function(n,i){s.set(i,cr(n,t,r,i,e,o))}));var v=f?n:(l?c?aa:ia:c?Ms:js)(e);return Et(v||e,(function(n,i){v&&(n=e[i=n]),nr(s,i,cr(n,t,r,i,e,o))})),s}function lr(e,t,r){var i=r.length;if(null==e)return!i;for(e=Re(e);i--;){var a=r[i],o=t[a],s=e[a];if(s===n&&!(a in e)||!o(s))return!1}return!0}function fr(e,t,i){if("function"!=typeof e)throw new Ce(r);return Aa((function(){e.apply(n,i)}),t)}function dr(e,t,n,r){var i=-1,a=Ct,o=!0,s=e.length,u=[],c=t.length;if(!s)return u;n&&(t=Pt(t,Ht(n))),r?(a=Ot,o=!1):t.length>=200&&(a=Qt,o=!1,t=new Hn(t));e:for(;++i<s;){var l=e[i],f=null==n?l:n(l);if(l=r||0!==l?l:0,o&&f==f){for(var d=c;d--;)if(t[d]===f)continue e;u.push(l)}else a(t,f,r)||u.push(l)}return u}qn.templateSettings={escape:Y,evaluate:Q,interpolate:X,variable:"",imports:{_:qn}},qn.prototype=Wn.prototype,qn.prototype.constructor=qn,Kn.prototype=zn(Wn.prototype),Kn.prototype.constructor=Kn,Vn.prototype=zn(Wn.prototype),Vn.prototype.constructor=Vn,$n.prototype.clear=function(){this.__data__=On?On(null):{},this.size=0},$n.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},$n.prototype.get=function(e){var t=this.__data__;if(On){var r=t[e];return r===i?n:r}return Le.call(t,e)?t[e]:n},$n.prototype.has=function(e){var t=this.__data__;return On?t[e]!==n:Le.call(t,e)},$n.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=On&&t===n?i:t,this},Gn.prototype.clear=function(){this.__data__=[],this.size=0},Gn.prototype.delete=function(e){var t=this.__data__,n=rr(t,e);return!(n<0)&&(n==t.length-1?t.pop():He.call(t,n,1),--this.size,!0)},Gn.prototype.get=function(e){var t=this.__data__,r=rr(t,e);return r<0?n:t[r][1]},Gn.prototype.has=function(e){return rr(this.__data__,e)>-1},Gn.prototype.set=function(e,t){var n=this.__data__,r=rr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Jn.prototype.clear=function(){this.size=0,this.__data__={hash:new $n,map:new(Rn||Gn),string:new $n}},Jn.prototype.delete=function(e){var t=la(this,e).delete(e);return this.size-=t?1:0,t},Jn.prototype.get=function(e){return la(this,e).get(e)},Jn.prototype.has=function(e){return la(this,e).has(e)},Jn.prototype.set=function(e,t){var n=la(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Hn.prototype.add=Hn.prototype.push=function(e){return this.__data__.set(e,i),this},Hn.prototype.has=function(e){return this.__data__.has(e)},Yn.prototype.clear=function(){this.__data__=new Gn,this.size=0},Yn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Yn.prototype.get=function(e){return this.__data__.get(e)},Yn.prototype.has=function(e){return this.__data__.has(e)},Yn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Gn){var r=n.__data__;if(!Rn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Jn(r)}return n.set(e,t),this.size=n.size,this};var pr=Mi(kr),hr=Mi(_r,!0);function vr(e,t){var n=!0;return pr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function yr(e,t,r){for(var i=-1,a=e.length;++i<a;){var o=e[i],s=t(o);if(null!=s&&(u===n?s==s&&!ls(s):r(s,u)))var u=s,c=o}return c}function gr(e,t){var n=[];return pr(e,(function(e,r,i){t(e,r,i)&&n.push(e)})),n}function mr(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=ma),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?mr(s,t-1,n,r,i):At(i,s):r||(i[i.length]=s)}return i}var br=Li(),wr=Li(!0);function kr(e,t){return e&&br(e,t,js)}function _r(e,t){return e&&wr(e,t,js)}function xr(e,t){return Tt(t,(function(t){return Zo(e[t])}))}function Sr(e,t){for(var r=0,i=(t=wi(t,e)).length;null!=e&&r<i;)e=e[Da(t[r++])];return r&&r==i?e:n}function Er(e,t,n){var r=t(e);return $o(e)?r:At(r,n(e))}function Rr(e){return null==e?e===n?"[object Undefined]":"[object Null]":ot&&ot in Re(e)?function(e){var t=Le.call(e,ot),r=e[ot];try{e[ot]=n;var i=!0}catch(e){}var a=De.call(e);i&&(t?e[ot]=r:delete e[ot]);return a}(e):function(e){return De.call(e)}(e)}function Ir(e,t){return e>t}function Tr(e,t){return null!=e&&Le.call(e,t)}function Cr(e,t){return null!=e&&t in Re(e)}function Or(e,t,r){for(var i=r?Ot:Ct,a=e[0].length,o=e.length,s=o,u=ae(o),c=1/0,l=[];s--;){var f=e[s];s&&t&&(f=Pt(f,Ht(t))),c=wn(f.length,c),u[s]=!r&&(t||a>=120&&f.length>=120)?new Hn(s&&f):n}f=e[0];var d=-1,p=u[0];e:for(;++d<a&&l.length<c;){var h=f[d],v=t?t(h):h;if(h=r||0!==h?h:0,!(p?Qt(p,v):i(l,v,r))){for(s=o;--s;){var y=u[s];if(!(y?Qt(y,v):i(e[s],v,r)))continue e}p&&p.push(v),l.push(h)}}return l}function Pr(e,t,r){var i=null==(e=Ta(e,t=wi(t,e)))?e:e[Da(Qa(t))];return null==i?n:xt(i,e,r)}function Ar(e){return rs(e)&&Rr(e)==y}function jr(e,t,r,i,a){return e===t||(null==e||null==t||!rs(e)&&!rs(t)?e!=e&&t!=t:function(e,t,r,i,a,o){var s=$o(e),u=$o(t),c=s?g:va(e),l=u?g:va(t),f=(c=c==y?E:c)==E,d=(l=l==y?E:l)==E,p=c==l;if(p&&Yo(e)){if(!Yo(t))return!1;s=!0,f=!1}if(p&&!f)return o||(o=new Yn),s||fs(e)?na(e,t,r,i,a,o):function(e,t,n,r,i,a,o){switch(n){case j:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case A:return!(e.byteLength!=t.byteLength||!a(new Ke(e),new Ke(t)));case m:case b:case S:return zo(+e,+t);case w:return e.name==t.name&&e.message==t.message;case I:case C:return e==t+"";case x:var s=on;case T:var u=1&r;if(s||(s=cn),e.size!=t.size&&!u)return!1;var c=o.get(e);if(c)return c==t;r|=2,o.set(e,t);var l=na(s(e),s(t),r,i,a,o);return o.delete(e),l;case O:if(Fn)return Fn.call(e)==Fn.call(t)}return!1}(e,t,c,r,i,a,o);if(!(1&r)){var h=f&&Le.call(e,"__wrapped__"),v=d&&Le.call(t,"__wrapped__");if(h||v){var k=h?e.value():e,_=v?t.value():t;return o||(o=new Yn),a(k,_,r,i,o)}}if(!p)return!1;return o||(o=new Yn),function(e,t,r,i,a,o){var s=1&r,u=ia(e),c=u.length,l=ia(t).length;if(c!=l&&!s)return!1;var f=c;for(;f--;){var d=u[f];if(!(s?d in t:Le.call(t,d)))return!1}var p=o.get(e),h=o.get(t);if(p&&h)return p==t&&h==e;var v=!0;o.set(e,t),o.set(t,e);var y=s;for(;++f<c;){var g=e[d=u[f]],m=t[d];if(i)var b=s?i(m,g,d,t,e,o):i(g,m,d,e,t,o);if(!(b===n?g===m||a(g,m,r,i,o):b)){v=!1;break}y||(y="constructor"==d)}if(v&&!y){var w=e.constructor,k=t.constructor;w==k||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof k&&k instanceof k||(v=!1)}return o.delete(e),o.delete(t),v}(e,t,r,i,a,o)}(e,t,r,i,jr,a))}function Mr(e,t,r,i){var a=r.length,o=a,s=!i;if(null==e)return!o;for(e=Re(e);a--;){var u=r[a];if(s&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++a<o;){var c=(u=r[a])[0],l=e[c],f=u[1];if(s&&u[2]){if(l===n&&!(c in e))return!1}else{var d=new Yn;if(i)var p=i(l,f,c,e,t,d);if(!(p===n?jr(f,l,3,i,d):p))return!1}}return!0}function Lr(e){return!(!ns(e)||(t=e,Ne&&Ne in t))&&(Zo(e)?qe:ye).test(Fa(e));var t}function Ur(e){return"function"==typeof e?e:null==e?au:"object"==jI.default(e)?$o(e)?zr(e[0],e[1]):qr(e):hu(e)}function Nr(e){if(!Sa(e))return mn(e);var t=[];for(var n in Re(e))Le.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Dr(e){if(!ns(e))return function(e){var t=[];if(null!=e)for(var n in Re(e))t.push(n);return t}(e);var t=Sa(e),n=[];for(var r in e)("constructor"!=r||!t&&Le.call(e,r))&&n.push(r);return n}function Fr(e,t){return e<t}function Br(e,t){var n=-1,r=Jo(e)?ae(e.length):[];return pr(e,(function(e,i,a){r[++n]=t(e,i,a)})),r}function qr(e){var t=fa(e);return 1==t.length&&t[0][2]?Ra(t[0][0],t[0][1]):function(n){return n===e||Mr(n,e,t)}}function zr(e,t){return ka(e)&&Ea(t)?Ra(Da(e),t):function(r){var i=Ts(r,e);return i===n&&i===t?Cs(r,e):jr(t,i,3)}}function Wr(e,t,r,i,a){e!==t&&br(t,(function(o,s){if(a||(a=new Yn),ns(o))!function(e,t,r,i,a,o,s){var u=Oa(e,r),c=Oa(t,r),l=s.get(c);if(l)return void tr(e,r,l);var f=o?o(u,c,r+"",e,t,s):n,d=f===n;if(d){var p=$o(c),h=!p&&Yo(c),v=!p&&!h&&fs(c);f=c,p||h||v?$o(u)?f=u:Ho(u)?f=Oi(u):h?(d=!1,f=Si(c,!0)):v?(d=!1,f=Ri(c,!0)):f=[]:os(c)||Vo(c)?(f=u,Vo(u)?f=bs(u):ns(u)&&!Zo(u)||(f=ga(c))):d=!1}d&&(s.set(c,f),a(f,c,i,o,s),s.delete(c));tr(e,r,f)}(e,t,s,r,Wr,i,a);else{var u=i?i(Oa(e,s),o,s+"",e,t,a):n;u===n&&(u=o),tr(e,s,u)}}),Ms)}function Kr(e,t){var r=e.length;if(r)return ba(t+=t<0?r:0,r)?e[t]:n}function Vr(e,t,n){t=t.length?Pt(t,(function(e){return $o(e)?function(t){return Sr(t,1===e.length?e[0]:e)}:e})):[au];var r=-1;t=Pt(t,Ht(ca()));var i=Br(e,(function(e,n,i){var a=Pt(t,(function(t){return t(e)}));return{criteria:a,index:++r,value:e}}));return function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}(i,(function(e,t){return function(e,t,n){var r=-1,i=e.criteria,a=t.criteria,o=i.length,s=n.length;for(;++r<o;){var u=Ii(i[r],a[r]);if(u)return r>=s?u:u*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)}))}function $r(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Sr(e,o);n(s,o)&&ei(a,wi(o,e),s)}return a}function Gr(e,t,n,r){var i=r?Bt:Ft,a=-1,o=t.length,s=e;for(e===t&&(t=Oi(t)),n&&(s=Pt(e,Ht(n)));++a<o;)for(var u=0,c=t[a],l=n?n(c):c;(u=i(s,l,u,r))>-1;)s!==e&&He.call(s,u,1),He.call(e,u,1);return e}function Jr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==a){var a=i;ba(i)?He.call(e,i,1):di(e,i)}}return e}function Hr(e,t){return e+yt(xn()*(t-e+1))}function Yr(e,t){var n="";if(!e||t<1||t>d)return n;do{t%2&&(n+=e),(t=yt(t/2))&&(e+=e)}while(t);return n}function Qr(e,t){return ja(Ia(e,t,au),e+"")}function Xr(e){return Xn(zs(e))}function Zr(e,t){var n=zs(e);return Ua(n,ur(t,0,n.length))}function ei(e,t,r,i){if(!ns(e))return e;for(var a=-1,o=(t=wi(t,e)).length,s=o-1,u=e;null!=u&&++a<o;){var c=Da(t[a]),l=r;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(a!=s){var f=u[c];(l=i?i(f,c,u):n)===n&&(l=ns(f)?f:ba(t[a+1])?[]:{})}nr(u,c,l),u=u[c]}return e}var ti=Pn?function(e,t){return Pn.set(e,t),e}:au,ni=ct?function(e,t){return ct(e,"toString",{configurable:!0,enumerable:!1,value:nu(t),writable:!0})}:au;function ri(e){return Ua(zs(e))}function ii(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=ae(i);++r<i;)a[r]=e[r+t];return a}function ai(e,t){var n;return pr(e,(function(e,r,i){return!(n=t(e,r,i))})),!!n}function oi(e,t,n){var r=0,i=null==e?r:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;r<i;){var a=r+i>>>1,o=e[a];null!==o&&!ls(o)&&(n?o<=t:o<t)?r=a+1:i=a}return i}return si(e,t,au,n)}function si(e,t,r,i){var a=0,o=null==e?0:e.length;if(0===o)return 0;for(var s=(t=r(t))!=t,u=null===t,c=ls(t),l=t===n;a<o;){var f=yt((a+o)/2),d=r(e[f]),p=d!==n,h=null===d,v=d==d,y=ls(d);if(s)var g=i||v;else g=l?v&&(i||p):u?v&&p&&(i||!h):c?v&&p&&!h&&(i||!y):!h&&!y&&(i?d<=t:d<t);g?a=f+1:o=f}return wn(o,4294967294)}function ui(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n],s=t?t(o):o;if(!n||!zo(s,u)){var u=s;a[i++]=0===o?0:o}}return a}function ci(e){return"number"==typeof e?e:ls(e)?p:+e}function li(e){if("string"==typeof e)return e;if($o(e))return Pt(e,li)+"";if(ls(e))return Bn?Bn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function fi(e,t,n){var r=-1,i=Ct,a=e.length,o=!0,s=[],u=s;if(n)o=!1,i=Ot;else if(a>=200){var c=t?null:Yi(e);if(c)return cn(c);o=!1,i=Qt,u=new Hn}else u=t?[]:s;e:for(;++r<a;){var l=e[r],f=t?t(l):l;if(l=n||0!==l?l:0,o&&f==f){for(var d=u.length;d--;)if(u[d]===f)continue e;t&&u.push(f),s.push(l)}else i(u,f,n)||(u!==s&&u.push(f),s.push(l))}return s}function di(e,t){return null==(e=Ta(e,t=wi(t,e)))||delete e[Da(Qa(t))]}function pi(e,t,n,r){return ei(e,t,n(Sr(e,t)),r)}function hi(e,t,n,r){for(var i=e.length,a=r?i:-1;(r?a--:++a<i)&&t(e[a],a,e););return n?ii(e,r?0:a,r?a+1:i):ii(e,r?a+1:0,r?i:a)}function vi(e,t){var n=e;return n instanceof Vn&&(n=n.value()),jt(t,(function(e,t){return t.func.apply(t.thisArg,At([e],t.args))}),n)}function yi(e,t,n){var r=e.length;if(r<2)return r?fi(e[0]):[];for(var i=-1,a=ae(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=dr(a[i]||o,e[s],t,n));return fi(mr(a,1),t,n)}function gi(e,t,r){for(var i=-1,a=e.length,o=t.length,s={};++i<a;){var u=i<o?t[i]:n;r(s,e[i],u)}return s}function mi(e){return Ho(e)?e:[]}function bi(e){return"function"==typeof e?e:au}function wi(e,t){return $o(e)?e:ka(e,t)?[e]:Na(ws(e))}var ki=Qr;function _i(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:ii(e,t,r)}var xi=lt||function(e){return ft.clearTimeout(e)};function Si(e,t){if(t)return e.slice();var n=e.length,r=Ve?Ve(n):new e.constructor(n);return e.copy(r),r}function Ei(e){var t=new e.constructor(e.byteLength);return new Ke(t).set(new Ke(e)),t}function Ri(e,t){var n=t?Ei(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ii(e,t){if(e!==t){var r=e!==n,i=null===e,a=e==e,o=ls(e),s=t!==n,u=null===t,c=t==t,l=ls(t);if(!u&&!l&&!o&&e>t||o&&s&&c&&!u&&!l||i&&s&&c||!r&&c||!a)return 1;if(!i&&!o&&!l&&e<t||l&&r&&a&&!i&&!o||u&&r&&a||!s&&a||!c)return-1}return 0}function Ti(e,t,n,r){for(var i=-1,a=e.length,o=n.length,s=-1,u=t.length,c=bn(a-o,0),l=ae(u+c),f=!r;++s<u;)l[s]=t[s];for(;++i<o;)(f||i<a)&&(l[n[i]]=e[i]);for(;c--;)l[s++]=e[i++];return l}function Ci(e,t,n,r){for(var i=-1,a=e.length,o=-1,s=n.length,u=-1,c=t.length,l=bn(a-s,0),f=ae(l+c),d=!r;++i<l;)f[i]=e[i];for(var p=i;++u<c;)f[p+u]=t[u];for(;++o<s;)(d||i<a)&&(f[p+n[o]]=e[i++]);return f}function Oi(e,t){var n=-1,r=e.length;for(t||(t=ae(r));++n<r;)t[n]=e[n];return t}function Pi(e,t,r,i){var a=!r;r||(r={});for(var o=-1,s=t.length;++o<s;){var u=t[o],c=i?i(r[u],e[u],u,r,e):n;c===n&&(c=e[u]),a?or(r,u,c):nr(r,u,c)}return r}function Ai(e,t){return function(n,r){var i=$o(n)?St:ir,a=t?t():{};return i(n,e,ca(r,2),a)}}function ji(e){return Qr((function(t,r){var i=-1,a=r.length,o=a>1?r[a-1]:n,s=a>2?r[2]:n;for(o=e.length>3&&"function"==typeof o?(a--,o):n,s&&wa(r[0],r[1],s)&&(o=a<3?n:o,a=1),t=Re(t);++i<a;){var u=r[i];u&&e(t,u,i,o)}return t}))}function Mi(e,t){return function(n,r){if(null==n)return n;if(!Jo(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Re(n);(t?a--:++a<i)&&!1!==r(o[a],a,o););return n}}function Li(e){return function(t,n,r){for(var i=-1,a=Re(t),o=r(t),s=o.length;s--;){var u=o[e?s:++i];if(!1===n(a[u],u,a))break}return t}}function Ui(e){return function(t){var r=an(t=ws(t))?dn(t):n,i=r?r[0]:t.charAt(0),a=r?_i(r,1).join(""):t.slice(1);return i[e]()+a}}function Ni(e){return function(t){return jt(Zs(Vs(t).replace(Ye,"")),e,"")}}function Di(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=zn(e.prototype),r=e.apply(n,t);return ns(r)?r:n}}function Fi(e){return function(t,r,i){var a=Re(t);if(!Jo(t)){var o=ca(r,3);t=js(t),r=function(e){return o(a[e],e,a)}}var s=e(t,r,i);return s>-1?a[o?t[s]:s]:n}}function Bi(e){return ra((function(t){var i=t.length,a=i,o=Kn.prototype.thru;for(e&&t.reverse();a--;){var s=t[a];if("function"!=typeof s)throw new Ce(r);if(o&&!u&&"wrapper"==sa(s))var u=new Kn([],!0)}for(a=u?a:i;++a<i;){var c=sa(s=t[a]),l="wrapper"==c?oa(s):n;u=l&&_a(l[0])&&424==l[1]&&!l[4].length&&1==l[9]?u[sa(l[0])].apply(u,l[3]):1==s.length&&_a(s)?u[c]():u.thru(s)}return function(){var e=arguments,n=e[0];if(u&&1==e.length&&$o(n))return u.plant(n).value();for(var r=0,a=i?t[r].apply(this,e):n;++r<i;)a=t[r].call(this,a);return a}}))}function qi(e,t,r,i,a,o,s,u,l,f){var d=t&c,p=1&t,h=2&t,v=24&t,y=512&t,g=h?n:Di(e);return function n(){for(var c=arguments.length,m=ae(c),b=c;b--;)m[b]=arguments[b];if(v)var w=ua(n),k=en(m,w);if(i&&(m=Ti(m,i,a,v)),o&&(m=Ci(m,o,s,v)),c-=k,v&&c<f){var _=un(m,w);return Ji(e,t,qi,n.placeholder,r,m,_,u,l,f-c)}var x=p?r:this,S=h?x[e]:e;return c=m.length,u?m=Ca(m,u):y&&c>1&&m.reverse(),d&&l<c&&(m.length=l),this&&this!==ft&&this instanceof n&&(S=g||Di(S)),S.apply(x,m)}}function zi(e,t){return function(n,r){return function(e,t,n,r){return kr(e,(function(e,i,a){t(r,n(e),i,a)})),r}(n,e,t(r),{})}}function Wi(e,t){return function(r,i){var a;if(r===n&&i===n)return t;if(r!==n&&(a=r),i!==n){if(a===n)return i;"string"==typeof r||"string"==typeof i?(r=li(r),i=li(i)):(r=ci(r),i=ci(i)),a=e(r,i)}return a}}function Ki(e){return ra((function(t){return t=Pt(t,Ht(ca())),Qr((function(n){var r=this;return e(t,(function(e){return xt(e,r,n)}))}))}))}function Vi(e,t){var r=(t=t===n?" ":li(t)).length;if(r<2)return r?Yr(t,e):t;var i=Yr(t,vt(e/fn(t)));return an(t)?_i(dn(i),0,e).join(""):i.slice(0,e)}function $i(e){return function(t,r,i){return i&&"number"!=typeof i&&wa(t,r,i)&&(r=i=n),t=vs(t),r===n?(r=t,t=0):r=vs(r),function(e,t,n,r){for(var i=-1,a=bn(vt((t-e)/(n||1)),0),o=ae(a);a--;)o[r?a:++i]=e,e+=n;return o}(t,r,i=i===n?t<r?1:-1:vs(i),e)}}function Gi(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=ms(t),n=ms(n)),e(t,n)}}function Ji(e,t,r,i,a,o,c,l,f,d){var p=8&t;t|=p?s:u,4&(t&=~(p?u:s))||(t&=-4);var h=[e,t,a,p?o:n,p?c:n,p?n:o,p?n:c,l,f,d],v=r.apply(n,h);return _a(e)&&Pa(v,h),v.placeholder=i,Ma(v,e,t)}function Hi(e){var t=Ee[e];return function(e,n){if(e=ms(e),(n=null==n?0:wn(ys(n),292))&&yn(e)){var r=(ws(e)+"e").split("e");return+((r=(ws(t(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return t(e)}}var Yi=Tn&&1/cn(new Tn([,-0]))[1]==f?function(e){return new Tn(e)}:lu;function Qi(e){return function(t){var n=va(t);return n==x?on(t):n==T?ln(t):function(e,t){return Pt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Xi(e,t,i,f,d,p,h,v){var y=2&t;if(!y&&"function"!=typeof e)throw new Ce(r);var g=f?f.length:0;if(g||(t&=-97,f=d=n),h=h===n?h:bn(ys(h),0),v=v===n?v:ys(v),g-=d?d.length:0,t&u){var m=f,b=d;f=d=n}var w=y?n:oa(e),k=[e,t,i,f,d,m,b,p,h,v];if(w&&function(e,t){var n=e[1],r=t[1],i=n|r,o=i<131,s=r==c&&8==n||r==c&&n==l&&e[7].length<=t[8]||384==r&&t[7].length<=t[8]&&8==n;if(!o&&!s)return e;1&r&&(e[2]=t[2],i|=1&n?0:4);var u=t[3];if(u){var f=e[3];e[3]=f?Ti(f,u,t[4]):u,e[4]=f?un(e[3],a):t[4]}(u=t[5])&&(f=e[5],e[5]=f?Ci(f,u,t[6]):u,e[6]=f?un(e[5],a):t[6]);(u=t[7])&&(e[7]=u);r&c&&(e[8]=null==e[8]?t[8]:wn(e[8],t[8]));null==e[9]&&(e[9]=t[9]);e[0]=t[0],e[1]=i}(k,w),e=k[0],t=k[1],i=k[2],f=k[3],d=k[4],!(v=k[9]=k[9]===n?y?0:e.length:bn(k[9]-g,0))&&24&t&&(t&=-25),t&&1!=t)_=8==t||t==o?function(e,t,r){var i=Di(e);return function a(){for(var o=arguments.length,s=ae(o),u=o,c=ua(a);u--;)s[u]=arguments[u];var l=o<3&&s[0]!==c&&s[o-1]!==c?[]:un(s,c);return(o-=l.length)<r?Ji(e,t,qi,a.placeholder,n,s,l,n,n,r-o):xt(this&&this!==ft&&this instanceof a?i:e,this,s)}}(e,t,v):t!=s&&33!=t||d.length?qi.apply(n,k):function(e,t,n,r){var i=1&t,a=Di(e);return function t(){for(var o=-1,s=arguments.length,u=-1,c=r.length,l=ae(c+s),f=this&&this!==ft&&this instanceof t?a:e;++u<c;)l[u]=r[u];for(;s--;)l[u++]=arguments[++o];return xt(f,i?n:this,l)}}(e,t,i,f);else var _=function(e,t,n){var r=1&t,i=Di(e);return function t(){return(this&&this!==ft&&this instanceof t?i:e).apply(r?n:this,arguments)}}(e,t,i);return Ma((w?ti:Pa)(_,k),e,t)}function Zi(e,t,r,i){return e===n||zo(e,Ae[r])&&!Le.call(i,r)?t:e}function ea(e,t,r,i,a,o){return ns(e)&&ns(t)&&(o.set(t,e),Wr(e,t,n,ea,o),o.delete(t)),e}function ta(e){return os(e)?n:e}function na(e,t,r,i,a,o){var s=1&r,u=e.length,c=t.length;if(u!=c&&!(s&&c>u))return!1;var l=o.get(e),f=o.get(t);if(l&&f)return l==t&&f==e;var d=-1,p=!0,h=2&r?new Hn:n;for(o.set(e,t),o.set(t,e);++d<u;){var v=e[d],y=t[d];if(i)var g=s?i(y,v,d,t,e,o):i(v,y,d,e,t,o);if(g!==n){if(g)continue;p=!1;break}if(h){if(!Lt(t,(function(e,t){if(!Qt(h,t)&&(v===e||a(v,e,r,i,o)))return h.push(t)}))){p=!1;break}}else if(v!==y&&!a(v,y,r,i,o)){p=!1;break}}return o.delete(e),o.delete(t),p}function ra(e){return ja(Ia(e,n,$a),e+"")}function ia(e){return Er(e,js,pa)}function aa(e){return Er(e,Ms,ha)}var oa=Pn?function(e){return Pn.get(e)}:lu;function sa(e){for(var t=e.name+"",n=An[t],r=Le.call(An,t)?n.length:0;r--;){var i=n[r],a=i.func;if(null==a||a==e)return i.name}return t}function ua(e){return(Le.call(qn,"placeholder")?qn:e).placeholder}function ca(){var e=qn.iteratee||ou;return e=e===ou?Ur:e,arguments.length?e(arguments[0],arguments[1]):e}function la(e,t){var n=e.__data__;return function(e){var t=jI.default(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function fa(e){for(var t=js(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Ea(i)]}return t}function da(e,t){var r=function(e,t){return null==e?n:e[t]}(e,t);return Lr(r)?r:n}var pa=Ut?function(e){return null==e?[]:(e=Re(e),Tt(Ut(e),(function(t){return Je.call(e,t)})))}:gu,ha=Ut?function(e){for(var t=[];e;)At(t,pa(e)),e=$e(e);return t}:gu,va=Rr;function ya(e,t,n){for(var r=-1,i=(t=wi(t,e)).length,a=!1;++r<i;){var o=Da(t[r]);if(!(a=null!=e&&n(e,o)))break;e=e[o]}return a||++r!=i?a:!!(i=null==e?0:e.length)&&ts(i)&&ba(o,i)&&($o(e)||Vo(e))}function ga(e){return"function"!=typeof e.constructor||Sa(e)?{}:zn($e(e))}function ma(e){return $o(e)||Vo(e)||!!(Xe&&e&&e[Xe])}function ba(e,t){var n=jI.default(e);return!!(t=null==t?d:t)&&("number"==n||"symbol"!=n&&me.test(e))&&e>-1&&e%1==0&&e<t}function wa(e,t,n){if(!ns(n))return!1;var r=jI.default(t);return!!("number"==r?Jo(n)&&ba(t,n.length):"string"==r&&t in n)&&zo(n[t],e)}function ka(e,t){if($o(e))return!1;var n=jI.default(e);return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!ls(e))||(ee.test(e)||!Z.test(e)||null!=t&&e in Re(t))}function _a(e){var t=sa(e),n=qn[t];if("function"!=typeof n||!(t in Vn.prototype))return!1;if(e===n)return!0;var r=oa(n);return!!r&&e===r[0]}(En&&va(new En(new ArrayBuffer(1)))!=j||Rn&&va(new Rn)!=x||In&&va(In.resolve())!=R||Tn&&va(new Tn)!=T||Cn&&va(new Cn)!=P)&&(va=function(e){var t=Rr(e),r=t==E?e.constructor:n,i=r?Fa(r):"";if(i)switch(i){case jn:return j;case Mn:return x;case Ln:return R;case Un:return T;case Nn:return P}return t});var xa=je?Zo:mu;function Sa(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ae)}function Ea(e){return e==e&&!ns(e)}function Ra(e,t){return function(r){return null!=r&&(r[e]===t&&(t!==n||e in Re(r)))}}function Ia(e,t,r){return t=bn(t===n?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=bn(n.length-t,0),o=ae(a);++i<a;)o[i]=n[t+i];i=-1;for(var s=ae(t+1);++i<t;)s[i]=n[i];return s[t]=r(o),xt(e,this,s)}}function Ta(e,t){return t.length<2?e:Sr(e,ii(t,0,-1))}function Ca(e,t){for(var r=e.length,i=wn(t.length,r),a=Oi(e);i--;){var o=t[i];e[i]=ba(o,r)?a[o]:n}return e}function Oa(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Pa=La(ti),Aa=pt||function(e,t){return ft.setTimeout(e,t)},ja=La(ni);function Ma(e,t,n){var r=t+"";return ja(e,function(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return Et(v,(function(n){var r="_."+n[0];t&n[1]&&!Ct(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ue):[]}(r),n)))}function La(e){var t=0,r=0;return function(){var i=kn(),a=16-(i-r);if(r=i,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Ua(e,t){var r=-1,i=e.length,a=i-1;for(t=t===n?i:t;++r<t;){var o=Hr(r,a),s=e[o];e[o]=e[r],e[r]=s}return e.length=t,e}var Na=function(e){var t=Uo(e,(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(te,(function(e,n,r,i){t.push(r?i.replace(fe,"$1"):n||e)})),t}));function Da(e){if("string"==typeof e||ls(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Fa(e){if(null!=e){try{return Me.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ba(e){if(e instanceof Vn)return e.clone();var t=new Kn(e.__wrapped__,e.__chain__);return t.__actions__=Oi(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var qa=Qr((function(e,t){return Ho(e)?dr(e,mr(t,1,Ho,!0)):[]})),za=Qr((function(e,t){var r=Qa(t);return Ho(r)&&(r=n),Ho(e)?dr(e,mr(t,1,Ho,!0),ca(r,2)):[]})),Wa=Qr((function(e,t){var r=Qa(t);return Ho(r)&&(r=n),Ho(e)?dr(e,mr(t,1,Ho,!0),n,r):[]}));function Ka(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:ys(n);return i<0&&(i=bn(r+i,0)),Dt(e,ca(t,3),i)}function Va(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var a=i-1;return r!==n&&(a=ys(r),a=r<0?bn(i+a,0):wn(a,i-1)),Dt(e,ca(t,3),a,!0)}function $a(e){return(null==e?0:e.length)?mr(e,1):[]}function Ga(e){return e&&e.length?e[0]:n}var Ja=Qr((function(e){var t=Pt(e,mi);return t.length&&t[0]===e[0]?Or(t):[]})),Ha=Qr((function(e){var t=Qa(e),r=Pt(e,mi);return t===Qa(r)?t=n:r.pop(),r.length&&r[0]===e[0]?Or(r,ca(t,2)):[]})),Ya=Qr((function(e){var t=Qa(e),r=Pt(e,mi);return(t="function"==typeof t?t:n)&&r.pop(),r.length&&r[0]===e[0]?Or(r,n,t):[]}));function Qa(e){var t=null==e?0:e.length;return t?e[t-1]:n}var Xa=Qr(Za);function Za(e,t){return e&&e.length&&t&&t.length?Gr(e,t):e}var eo=ra((function(e,t){var n=null==e?0:e.length,r=sr(e,t);return Jr(e,Pt(t,(function(e){return ba(e,n)?+e:e})).sort(Ii)),r}));function to(e){return null==e?e:Sn.call(e)}var no=Qr((function(e){return fi(mr(e,1,Ho,!0))})),ro=Qr((function(e){var t=Qa(e);return Ho(t)&&(t=n),fi(mr(e,1,Ho,!0),ca(t,2))})),io=Qr((function(e){var t=Qa(e);return t="function"==typeof t?t:n,fi(mr(e,1,Ho,!0),n,t)}));function ao(e){if(!e||!e.length)return[];var t=0;return e=Tt(e,(function(e){if(Ho(e))return t=bn(e.length,t),!0})),Gt(t,(function(t){return Pt(e,Wt(t))}))}function oo(e,t){if(!e||!e.length)return[];var r=ao(e);return null==t?r:Pt(r,(function(e){return xt(t,n,e)}))}var so=Qr((function(e,t){return Ho(e)?dr(e,t):[]})),uo=Qr((function(e){return yi(Tt(e,Ho))})),co=Qr((function(e){var t=Qa(e);return Ho(t)&&(t=n),yi(Tt(e,Ho),ca(t,2))})),lo=Qr((function(e){var t=Qa(e);return t="function"==typeof t?t:n,yi(Tt(e,Ho),n,t)})),fo=Qr(ao);var po=Qr((function(e){var t=e.length,r=t>1?e[t-1]:n;return r="function"==typeof r?(e.pop(),r):n,oo(e,r)}));function ho(e){var t=qn(e);return t.__chain__=!0,t}function vo(e,t){return t(e)}var yo=ra((function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,a=function(t){return sr(t,e)};return!(t>1||this.__actions__.length)&&i instanceof Vn&&ba(r)?((i=i.slice(r,+r+(t?1:0))).__actions__.push({func:vo,args:[a],thisArg:n}),new Kn(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(n),e}))):this.thru(a)}));var go=Ai((function(e,t,n){Le.call(e,n)?++e[n]:or(e,n,1)}));var mo=Fi(Ka),bo=Fi(Va);function wo(e,t){return($o(e)?Et:pr)(e,ca(t,3))}function ko(e,t){return($o(e)?Rt:hr)(e,ca(t,3))}var _o=Ai((function(e,t,n){Le.call(e,n)?e[n].push(t):or(e,n,[t])}));var xo=Qr((function(e,t,n){var r=-1,i="function"==typeof t,a=Jo(e)?ae(e.length):[];return pr(e,(function(e){a[++r]=i?xt(t,e,n):Pr(e,t,n)})),a})),So=Ai((function(e,t,n){or(e,n,t)}));function Eo(e,t){return($o(e)?Pt:Br)(e,ca(t,3))}var Ro=Ai((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var Io=Qr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&wa(e,t[0],t[1])?t=[]:n>2&&wa(t[0],t[1],t[2])&&(t=[t[0]]),Vr(e,mr(t,1),[])})),To=dt||function(){return ft.Date.now()};function Co(e,t,r){return t=r?n:t,t=e&&null==t?e.length:t,Xi(e,c,n,n,n,n,t)}function Oo(e,t){var i;if("function"!=typeof t)throw new Ce(r);return e=ys(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=n),i}}var Po=Qr((function(e,t,n){var r=1;if(n.length){var i=un(n,ua(Po));r|=s}return Xi(e,r,t,n,i)})),Ao=Qr((function(e,t,n){var r=3;if(n.length){var i=un(n,ua(Ao));r|=s}return Xi(t,r,e,n,i)}));function jo(e,t,i){var a,o,s,u,c,l,f=0,d=!1,p=!1,h=!0;if("function"!=typeof e)throw new Ce(r);function v(t){var r=a,i=o;return a=o=n,f=t,u=e.apply(i,r)}function y(e){return f=e,c=Aa(m,t),d?v(e):u}function g(e){var r=e-l;return l===n||r>=t||r<0||p&&e-f>=s}function m(){var e=To();if(g(e))return b(e);c=Aa(m,function(e){var n=t-(e-l);return p?wn(n,s-(e-f)):n}(e))}function b(e){return c=n,h&&a?v(e):(a=o=n,u)}function w(){var e=To(),r=g(e);if(a=arguments,o=this,l=e,r){if(c===n)return y(l);if(p)return xi(c),c=Aa(m,t),v(l)}return c===n&&(c=Aa(m,t)),u}return t=ms(t)||0,ns(i)&&(d=!!i.leading,s=(p="maxWait"in i)?bn(ms(i.maxWait)||0,t):s,h="trailing"in i?!!i.trailing:h),w.cancel=function(){c!==n&&xi(c),f=0,a=l=o=c=n},w.flush=function(){return c===n?u:b(To())},w}var Mo=Qr((function(e,t){return fr(e,1,t)})),Lo=Qr((function(e,t,n){return fr(e,ms(t)||0,n)}));function Uo(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ce(r);var n=function n(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Uo.Cache||Jn),n}function No(e){if("function"!=typeof e)throw new Ce(r);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Uo.Cache=Jn;var Do=ki((function(e,t){var n=(t=1==t.length&&$o(t[0])?Pt(t[0],Ht(ca())):Pt(mr(t,1),Ht(ca()))).length;return Qr((function(r){for(var i=-1,a=wn(r.length,n);++i<a;)r[i]=t[i].call(this,r[i]);return xt(e,this,r)}))})),Fo=Qr((function(e,t){var r=un(t,ua(Fo));return Xi(e,s,n,t,r)})),Bo=Qr((function(e,t){var r=un(t,ua(Bo));return Xi(e,u,n,t,r)})),qo=ra((function(e,t){return Xi(e,l,n,n,n,t)}));function zo(e,t){return e===t||e!=e&&t!=t}var Wo=Gi(Ir),Ko=Gi((function(e,t){return e>=t})),Vo=Ar(function(){return arguments}())?Ar:function(e){return rs(e)&&Le.call(e,"callee")&&!Je.call(e,"callee")},$o=ae.isArray,Go=gt?Ht(gt):function(e){return rs(e)&&Rr(e)==A};function Jo(e){return null!=e&&ts(e.length)&&!Zo(e)}function Ho(e){return rs(e)&&Jo(e)}var Yo=Kt||mu,Qo=mt?Ht(mt):function(e){return rs(e)&&Rr(e)==b};function Xo(e){if(!rs(e))return!1;var t=Rr(e);return t==w||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!os(e)}function Zo(e){if(!ns(e))return!1;var t=Rr(e);return t==k||t==_||"[object AsyncFunction]"==t||"[object Proxy]"==t}function es(e){return"number"==typeof e&&e==ys(e)}function ts(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=d}function ns(e){var t=jI.default(e);return null!=e&&("object"==t||"function"==t)}function rs(e){return null!=e&&"object"==jI.default(e)}var is=bt?Ht(bt):function(e){return rs(e)&&va(e)==x};function as(e){return"number"==typeof e||rs(e)&&Rr(e)==S}function os(e){if(!rs(e)||Rr(e)!=E)return!1;var t=$e(e);if(null===t)return!0;var n=Le.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Me.call(n)==Fe}var ss=wt?Ht(wt):function(e){return rs(e)&&Rr(e)==I};var us=kt?Ht(kt):function(e){return rs(e)&&va(e)==T};function cs(e){return"string"==typeof e||!$o(e)&&rs(e)&&Rr(e)==C}function ls(e){return"symbol"==jI.default(e)||rs(e)&&Rr(e)==O}var fs=_t?Ht(_t):function(e){return rs(e)&&ts(e.length)&&!!it[Rr(e)]};var ds=Gi(Fr),ps=Gi((function(e,t){return e<=t}));function hs(e){if(!e)return[];if(Jo(e))return cs(e)?dn(e):Oi(e);if(et&&e[et])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[et]());var t=va(e);return(t==x?on:t==T?cn:zs)(e)}function vs(e){return e?(e=ms(e))===f||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ys(e){var t=vs(e),n=t%1;return t==t?n?t-n:t:0}function gs(e){return e?ur(ys(e),0,h):0}function ms(e){if("number"==typeof e)return e;if(ls(e))return p;if(ns(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ns(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Jt(e);var n=ve.test(e);return n||ge.test(e)?ut(e.slice(2),n?2:8):he.test(e)?p:+e}function bs(e){return Pi(e,Ms(e))}function ws(e){return null==e?"":li(e)}var ks=ji((function(e,t){if(Sa(t)||Jo(t))Pi(t,js(t),e);else for(var n in t)Le.call(t,n)&&nr(e,n,t[n])})),_s=ji((function(e,t){Pi(t,Ms(t),e)})),xs=ji((function(e,t,n,r){Pi(t,Ms(t),e,r)})),Ss=ji((function(e,t,n,r){Pi(t,js(t),e,r)})),Es=ra(sr);var Rs=Qr((function(e,t){e=Re(e);var r=-1,i=t.length,a=i>2?t[2]:n;for(a&&wa(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=Ms(o),u=-1,c=s.length;++u<c;){var l=s[u],f=e[l];(f===n||zo(f,Ae[l])&&!Le.call(e,l))&&(e[l]=o[l])}return e})),Is=Qr((function(e){return e.push(n,ea),xt(Us,n,e)}));function Ts(e,t,r){var i=null==e?n:Sr(e,t);return i===n?r:i}function Cs(e,t){return null!=e&&ya(e,t,Cr)}var Os=zi((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),e[t]=n}),nu(au)),Ps=zi((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),Le.call(e,t)?e[t].push(n):e[t]=[n]}),ca),As=Qr(Pr);function js(e){return Jo(e)?Qn(e):Nr(e)}function Ms(e){return Jo(e)?Qn(e,!0):Dr(e)}var Ls=ji((function(e,t,n){Wr(e,t,n)})),Us=ji((function(e,t,n,r){Wr(e,t,n,r)})),Ns=ra((function(e,t){var n={};if(null==e)return n;var r=!1;t=Pt(t,(function(t){return t=wi(t,e),r||(r=t.length>1),t})),Pi(e,aa(e),n),r&&(n=cr(n,7,ta));for(var i=t.length;i--;)di(n,t[i]);return n}));var Ds=ra((function(e,t){return null==e?{}:function(e,t){return $r(e,t,(function(t,n){return Cs(e,n)}))}(e,t)}));function Fs(e,t){if(null==e)return{};var n=Pt(aa(e),(function(e){return[e]}));return t=ca(t),$r(e,n,(function(e,n){return t(e,n[0])}))}var Bs=Qi(js),qs=Qi(Ms);function zs(e){return null==e?[]:Yt(e,js(e))}var Ws=Ni((function(e,t,n){return t=t.toLowerCase(),e+(n?Ks(t):t)}));function Ks(e){return Xs(ws(e).toLowerCase())}function Vs(e){return(e=ws(e))&&e.replace(be,tn).replace(Qe,"")}var $s=Ni((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Gs=Ni((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Js=Ui("toLowerCase");var Hs=Ni((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Ys=Ni((function(e,t,n){return e+(n?" ":"")+Xs(t)}));var Qs=Ni((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Xs=Ui("toUpperCase");function Zs(e,t,r){return e=ws(e),(t=r?n:t)===n?function(e){return tt.test(e)}(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.match(ce)||[]}(e):e.match(t)||[]}var eu=Qr((function(e,t){try{return xt(e,n,t)}catch(e){return Xo(e)?e:new xe(e)}})),tu=ra((function(e,t){return Et(t,(function(t){t=Da(t),or(e,t,Po(e[t],e))})),e}));function nu(e){return function(){return e}}var ru=Bi(),iu=Bi(!0);function au(e){return e}function ou(e){return Ur("function"==typeof e?e:cr(e,1))}var su=Qr((function(e,t){return function(n){return Pr(n,e,t)}})),uu=Qr((function(e,t){return function(n){return Pr(e,n,t)}}));function cu(e,t,n){var r=js(t),i=xr(t,r);null!=n||ns(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=xr(t,js(t)));var a=!(ns(n)&&"chain"in n&&!n.chain),o=Zo(e);return Et(i,(function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__),i=n.__actions__=Oi(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,At([this.value()],arguments))})})),e}function lu(){}var fu=Ki(Pt),du=Ki(It),pu=Ki(Lt);function hu(e){return ka(e)?Wt(Da(e)):function(e){return function(t){return Sr(t,e)}}(e)}var vu=$i(),yu=$i(!0);function gu(){return[]}function mu(){return!1}var bu=Wi((function(e,t){return e+t}),0),wu=Hi("ceil"),ku=Wi((function(e,t){return e/t}),1),_u=Hi("floor");var xu,Su=Wi((function(e,t){return e*t}),1),Eu=Hi("round"),Ru=Wi((function(e,t){return e-t}),0);return qn.after=function(e,t){if("function"!=typeof t)throw new Ce(r);return e=ys(e),function(){if(--e<1)return t.apply(this,arguments)}},qn.ary=Co,qn.assign=ks,qn.assignIn=_s,qn.assignInWith=xs,qn.assignWith=Ss,qn.at=Es,qn.before=Oo,qn.bind=Po,qn.bindAll=tu,qn.bindKey=Ao,qn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return $o(e)?e:[e]},qn.chain=ho,qn.chunk=function(e,t,r){t=(r?wa(e,t,r):t===n)?1:bn(ys(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var a=0,o=0,s=ae(vt(i/t));a<i;)s[o++]=ii(e,a,a+=t);return s},qn.compact=function(e){for(var t=-1,n=null==e?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i},qn.concat=function(){var e=arguments.length;if(!e)return[];for(var t=ae(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return At($o(n)?Oi(n):[n],mr(t,1))},qn.cond=function(e){var t=null==e?0:e.length,n=ca();return e=t?Pt(e,(function(e){if("function"!=typeof e[1])throw new Ce(r);return[n(e[0]),e[1]]})):[],Qr((function(n){for(var r=-1;++r<t;){var i=e[r];if(xt(i[0],this,n))return xt(i[1],this,n)}}))},qn.conforms=function(e){return function(e){var t=js(e);return function(n){return lr(n,e,t)}}(cr(e,1))},qn.constant=nu,qn.countBy=go,qn.create=function(e,t){var n=zn(e);return null==t?n:ar(n,t)},qn.curry=function e(t,r,i){var a=Xi(t,8,n,n,n,n,n,r=i?n:r);return a.placeholder=e.placeholder,a},qn.curryRight=function e(t,r,i){var a=Xi(t,o,n,n,n,n,n,r=i?n:r);return a.placeholder=e.placeholder,a},qn.debounce=jo,qn.defaults=Rs,qn.defaultsDeep=Is,qn.defer=Mo,qn.delay=Lo,qn.difference=qa,qn.differenceBy=za,qn.differenceWith=Wa,qn.drop=function(e,t,r){var i=null==e?0:e.length;return i?ii(e,(t=r||t===n?1:ys(t))<0?0:t,i):[]},qn.dropRight=function(e,t,r){var i=null==e?0:e.length;return i?ii(e,0,(t=i-(t=r||t===n?1:ys(t)))<0?0:t):[]},qn.dropRightWhile=function(e,t){return e&&e.length?hi(e,ca(t,3),!0,!0):[]},qn.dropWhile=function(e,t){return e&&e.length?hi(e,ca(t,3),!0):[]},qn.fill=function(e,t,r,i){var a=null==e?0:e.length;return a?(r&&"number"!=typeof r&&wa(e,t,r)&&(r=0,i=a),function(e,t,r,i){var a=e.length;for((r=ys(r))<0&&(r=-r>a?0:a+r),(i=i===n||i>a?a:ys(i))<0&&(i+=a),i=r>i?0:gs(i);r<i;)e[r++]=t;return e}(e,t,r,i)):[]},qn.filter=function(e,t){return($o(e)?Tt:gr)(e,ca(t,3))},qn.flatMap=function(e,t){return mr(Eo(e,t),1)},qn.flatMapDeep=function(e,t){return mr(Eo(e,t),f)},qn.flatMapDepth=function(e,t,r){return r=r===n?1:ys(r),mr(Eo(e,t),r)},qn.flatten=$a,qn.flattenDeep=function(e){return(null==e?0:e.length)?mr(e,f):[]},qn.flattenDepth=function(e,t){return(null==e?0:e.length)?mr(e,t=t===n?1:ys(t)):[]},qn.flip=function(e){return Xi(e,512)},qn.flow=ru,qn.flowRight=iu,qn.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={};++t<n;){var i=e[t];r[i[0]]=i[1]}return r},qn.functions=function(e){return null==e?[]:xr(e,js(e))},qn.functionsIn=function(e){return null==e?[]:xr(e,Ms(e))},qn.groupBy=_o,qn.initial=function(e){return(null==e?0:e.length)?ii(e,0,-1):[]},qn.intersection=Ja,qn.intersectionBy=Ha,qn.intersectionWith=Ya,qn.invert=Os,qn.invertBy=Ps,qn.invokeMap=xo,qn.iteratee=ou,qn.keyBy=So,qn.keys=js,qn.keysIn=Ms,qn.map=Eo,qn.mapKeys=function(e,t){var n={};return t=ca(t,3),kr(e,(function(e,r,i){or(n,t(e,r,i),e)})),n},qn.mapValues=function(e,t){var n={};return t=ca(t,3),kr(e,(function(e,r,i){or(n,r,t(e,r,i))})),n},qn.matches=function(e){return qr(cr(e,1))},qn.matchesProperty=function(e,t){return zr(e,cr(t,1))},qn.memoize=Uo,qn.merge=Ls,qn.mergeWith=Us,qn.method=su,qn.methodOf=uu,qn.mixin=cu,qn.negate=No,qn.nthArg=function(e){return e=ys(e),Qr((function(t){return Kr(t,e)}))},qn.omit=Ns,qn.omitBy=function(e,t){return Fs(e,No(ca(t)))},qn.once=function(e){return Oo(2,e)},qn.orderBy=function(e,t,r,i){return null==e?[]:($o(t)||(t=null==t?[]:[t]),$o(r=i?n:r)||(r=null==r?[]:[r]),Vr(e,t,r))},qn.over=fu,qn.overArgs=Do,qn.overEvery=du,qn.overSome=pu,qn.partial=Fo,qn.partialRight=Bo,qn.partition=Ro,qn.pick=Ds,qn.pickBy=Fs,qn.property=hu,qn.propertyOf=function(e){return function(t){return null==e?n:Sr(e,t)}},qn.pull=Xa,qn.pullAll=Za,qn.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?Gr(e,t,ca(n,2)):e},qn.pullAllWith=function(e,t,r){return e&&e.length&&t&&t.length?Gr(e,t,n,r):e},qn.pullAt=eo,qn.range=vu,qn.rangeRight=yu,qn.rearg=qo,qn.reject=function(e,t){return($o(e)?Tt:gr)(e,No(ca(t,3)))},qn.remove=function(e,t){var n=[];if(!e||!e.length)return n;var r=-1,i=[],a=e.length;for(t=ca(t,3);++r<a;){var o=e[r];t(o,r,e)&&(n.push(o),i.push(r))}return Jr(e,i),n},qn.rest=function(e,t){if("function"!=typeof e)throw new Ce(r);return Qr(e,t=t===n?t:ys(t))},qn.reverse=to,qn.sampleSize=function(e,t,r){return t=(r?wa(e,t,r):t===n)?1:ys(t),($o(e)?Zn:Zr)(e,t)},qn.set=function(e,t,n){return null==e?e:ei(e,t,n)},qn.setWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:ei(e,t,r,i)},qn.shuffle=function(e){return($o(e)?er:ri)(e)},qn.slice=function(e,t,r){var i=null==e?0:e.length;return i?(r&&"number"!=typeof r&&wa(e,t,r)?(t=0,r=i):(t=null==t?0:ys(t),r=r===n?i:ys(r)),ii(e,t,r)):[]},qn.sortBy=Io,qn.sortedUniq=function(e){return e&&e.length?ui(e):[]},qn.sortedUniqBy=function(e,t){return e&&e.length?ui(e,ca(t,2)):[]},qn.split=function(e,t,r){return r&&"number"!=typeof r&&wa(e,t,r)&&(t=r=n),(r=r===n?h:r>>>0)?(e=ws(e))&&("string"==typeof t||null!=t&&!ss(t))&&!(t=li(t))&&an(e)?_i(dn(e),0,r):e.split(t,r):[]},qn.spread=function(e,t){if("function"!=typeof e)throw new Ce(r);return t=null==t?0:bn(ys(t),0),Qr((function(n){var r=n[t],i=_i(n,0,t);return r&&At(i,r),xt(e,this,i)}))},qn.tail=function(e){var t=null==e?0:e.length;return t?ii(e,1,t):[]},qn.take=function(e,t,r){return e&&e.length?ii(e,0,(t=r||t===n?1:ys(t))<0?0:t):[]},qn.takeRight=function(e,t,r){var i=null==e?0:e.length;return i?ii(e,(t=i-(t=r||t===n?1:ys(t)))<0?0:t,i):[]},qn.takeRightWhile=function(e,t){return e&&e.length?hi(e,ca(t,3),!1,!0):[]},qn.takeWhile=function(e,t){return e&&e.length?hi(e,ca(t,3)):[]},qn.tap=function(e,t){return t(e),e},qn.throttle=function(e,t,n){var i=!0,a=!0;if("function"!=typeof e)throw new Ce(r);return ns(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),jo(e,t,{leading:i,maxWait:t,trailing:a})},qn.thru=vo,qn.toArray=hs,qn.toPairs=Bs,qn.toPairsIn=qs,qn.toPath=function(e){return $o(e)?Pt(e,Da):ls(e)?[e]:Oi(Na(ws(e)))},qn.toPlainObject=bs,qn.transform=function(e,t,n){var r=$o(e),i=r||Yo(e)||fs(e);if(t=ca(t,4),null==n){var a=e&&e.constructor;n=i?r?new a:[]:ns(e)&&Zo(a)?zn($e(e)):{}}return(i?Et:kr)(e,(function(e,r,i){return t(n,e,r,i)})),n},qn.unary=function(e){return Co(e,1)},qn.union=no,qn.unionBy=ro,qn.unionWith=io,qn.uniq=function(e){return e&&e.length?fi(e):[]},qn.uniqBy=function(e,t){return e&&e.length?fi(e,ca(t,2)):[]},qn.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?fi(e,n,t):[]},qn.unset=function(e,t){return null==e||di(e,t)},qn.unzip=ao,qn.unzipWith=oo,qn.update=function(e,t,n){return null==e?e:pi(e,t,bi(n))},qn.updateWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:pi(e,t,bi(r),i)},qn.values=zs,qn.valuesIn=function(e){return null==e?[]:Yt(e,Ms(e))},qn.without=so,qn.words=Zs,qn.wrap=function(e,t){return Fo(bi(t),e)},qn.xor=uo,qn.xorBy=co,qn.xorWith=lo,qn.zip=fo,qn.zipObject=function(e,t){return gi(e||[],t||[],nr)},qn.zipObjectDeep=function(e,t){return gi(e||[],t||[],ei)},qn.zipWith=po,qn.entries=Bs,qn.entriesIn=qs,qn.extend=_s,qn.extendWith=xs,cu(qn,qn),qn.add=bu,qn.attempt=eu,qn.camelCase=Ws,qn.capitalize=Ks,qn.ceil=wu,qn.clamp=function(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=(r=ms(r))==r?r:0),t!==n&&(t=(t=ms(t))==t?t:0),ur(ms(e),t,r)},qn.clone=function(e){return cr(e,4)},qn.cloneDeep=function(e){return cr(e,5)},qn.cloneDeepWith=function(e,t){return cr(e,5,t="function"==typeof t?t:n)},qn.cloneWith=function(e,t){return cr(e,4,t="function"==typeof t?t:n)},qn.conformsTo=function(e,t){return null==t||lr(e,t,js(t))},qn.deburr=Vs,qn.defaultTo=function(e,t){return null==e||e!=e?t:e},qn.divide=ku,qn.endsWith=function(e,t,r){e=ws(e),t=li(t);var i=e.length,a=r=r===n?i:ur(ys(r),0,i);return(r-=t.length)>=0&&e.slice(r,a)==t},qn.eq=zo,qn.escape=function(e){return(e=ws(e))&&H.test(e)?e.replace(G,nn):e},qn.escapeRegExp=function(e){return(e=ws(e))&&re.test(e)?e.replace(ne,"\\$&"):e},qn.every=function(e,t,r){var i=$o(e)?It:vr;return r&&wa(e,t,r)&&(t=n),i(e,ca(t,3))},qn.find=mo,qn.findIndex=Ka,qn.findKey=function(e,t){return Nt(e,ca(t,3),kr)},qn.findLast=bo,qn.findLastIndex=Va,qn.findLastKey=function(e,t){return Nt(e,ca(t,3),_r)},qn.floor=_u,qn.forEach=wo,qn.forEachRight=ko,qn.forIn=function(e,t){return null==e?e:br(e,ca(t,3),Ms)},qn.forInRight=function(e,t){return null==e?e:wr(e,ca(t,3),Ms)},qn.forOwn=function(e,t){return e&&kr(e,ca(t,3))},qn.forOwnRight=function(e,t){return e&&_r(e,ca(t,3))},qn.get=Ts,qn.gt=Wo,qn.gte=Ko,qn.has=function(e,t){return null!=e&&ya(e,t,Tr)},qn.hasIn=Cs,qn.head=Ga,qn.identity=au,qn.includes=function(e,t,n,r){e=Jo(e)?e:zs(e),n=n&&!r?ys(n):0;var i=e.length;return n<0&&(n=bn(i+n,0)),cs(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Ft(e,t,n)>-1},qn.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:ys(n);return i<0&&(i=bn(r+i,0)),Ft(e,t,i)},qn.inRange=function(e,t,r){return t=vs(t),r===n?(r=t,t=0):r=vs(r),function(e,t,n){return e>=wn(t,n)&&e<bn(t,n)}(e=ms(e),t,r)},qn.invoke=As,qn.isArguments=Vo,qn.isArray=$o,qn.isArrayBuffer=Go,qn.isArrayLike=Jo,qn.isArrayLikeObject=Ho,qn.isBoolean=function(e){return!0===e||!1===e||rs(e)&&Rr(e)==m},qn.isBuffer=Yo,qn.isDate=Qo,qn.isElement=function(e){return rs(e)&&1===e.nodeType&&!os(e)},qn.isEmpty=function(e){if(null==e)return!0;if(Jo(e)&&($o(e)||"string"==typeof e||"function"==typeof e.splice||Yo(e)||fs(e)||Vo(e)))return!e.length;var t=va(e);if(t==x||t==T)return!e.size;if(Sa(e))return!Nr(e).length;for(var n in e)if(Le.call(e,n))return!1;return!0},qn.isEqual=function(e,t){return jr(e,t)},qn.isEqualWith=function(e,t,r){var i=(r="function"==typeof r?r:n)?r(e,t):n;return i===n?jr(e,t,n,r):!!i},qn.isError=Xo,qn.isFinite=function(e){return"number"==typeof e&&yn(e)},qn.isFunction=Zo,qn.isInteger=es,qn.isLength=ts,qn.isMap=is,qn.isMatch=function(e,t){return e===t||Mr(e,t,fa(t))},qn.isMatchWith=function(e,t,r){return r="function"==typeof r?r:n,Mr(e,t,fa(t),r)},qn.isNaN=function(e){return as(e)&&e!=+e},qn.isNative=function(e){if(xa(e))throw new xe("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(e)},qn.isNil=function(e){return null==e},qn.isNull=function(e){return null===e},qn.isNumber=as,qn.isObject=ns,qn.isObjectLike=rs,qn.isPlainObject=os,qn.isRegExp=ss,qn.isSafeInteger=function(e){return es(e)&&e>=-9007199254740991&&e<=d},qn.isSet=us,qn.isString=cs,qn.isSymbol=ls,qn.isTypedArray=fs,qn.isUndefined=function(e){return e===n},qn.isWeakMap=function(e){return rs(e)&&va(e)==P},qn.isWeakSet=function(e){return rs(e)&&"[object WeakSet]"==Rr(e)},qn.join=function(e,t){return null==e?"":gn.call(e,t)},qn.kebabCase=$s,qn.last=Qa,qn.lastIndexOf=function(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var a=i;return r!==n&&(a=(a=ys(r))<0?bn(i+a,0):wn(a,i-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,a):Dt(e,qt,a,!0)},qn.lowerCase=Gs,qn.lowerFirst=Js,qn.lt=ds,qn.lte=ps,qn.max=function(e){return e&&e.length?yr(e,au,Ir):n},qn.maxBy=function(e,t){return e&&e.length?yr(e,ca(t,2),Ir):n},qn.mean=function(e){return zt(e,au)},qn.meanBy=function(e,t){return zt(e,ca(t,2))},qn.min=function(e){return e&&e.length?yr(e,au,Fr):n},qn.minBy=function(e,t){return e&&e.length?yr(e,ca(t,2),Fr):n},qn.stubArray=gu,qn.stubFalse=mu,qn.stubObject=function(){return{}},qn.stubString=function(){return""},qn.stubTrue=function(){return!0},qn.multiply=Su,qn.nth=function(e,t){return e&&e.length?Kr(e,ys(t)):n},qn.noConflict=function(){return ft._===this&&(ft._=Be),this},qn.noop=lu,qn.now=To,qn.pad=function(e,t,n){e=ws(e);var r=(t=ys(t))?fn(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Vi(yt(i),n)+e+Vi(vt(i),n)},qn.padEnd=function(e,t,n){e=ws(e);var r=(t=ys(t))?fn(e):0;return t&&r<t?e+Vi(t-r,n):e},qn.padStart=function(e,t,n){e=ws(e);var r=(t=ys(t))?fn(e):0;return t&&r<t?Vi(t-r,n)+e:e},qn.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),_n(ws(e).replace(ie,""),t||0)},qn.random=function(e,t,r){if(r&&"boolean"!=typeof r&&wa(e,t,r)&&(t=r=n),r===n&&("boolean"==typeof t?(r=t,t=n):"boolean"==typeof e&&(r=e,e=n)),e===n&&t===n?(e=0,t=1):(e=vs(e),t===n?(t=e,e=0):t=vs(t)),e>t){var i=e;e=t,t=i}if(r||e%1||t%1){var a=xn();return wn(e+a*(t-e+st("1e-"+((a+"").length-1))),t)}return Hr(e,t)},qn.reduce=function(e,t,n){var r=$o(e)?jt:Vt,i=arguments.length<3;return r(e,ca(t,4),n,i,pr)},qn.reduceRight=function(e,t,n){var r=$o(e)?Mt:Vt,i=arguments.length<3;return r(e,ca(t,4),n,i,hr)},qn.repeat=function(e,t,r){return t=(r?wa(e,t,r):t===n)?1:ys(t),Yr(ws(e),t)},qn.replace=function(){var e=arguments,t=ws(e[0]);return e.length<3?t:t.replace(e[1],e[2])},qn.result=function(e,t,r){var i=-1,a=(t=wi(t,e)).length;for(a||(a=1,e=n);++i<a;){var o=null==e?n:e[Da(t[i])];o===n&&(i=a,o=r),e=Zo(o)?o.call(e):o}return e},qn.round=Eu,qn.runInContext=e,qn.sample=function(e){return($o(e)?Xn:Xr)(e)},qn.size=function(e){if(null==e)return 0;if(Jo(e))return cs(e)?fn(e):e.length;var t=va(e);return t==x||t==T?e.size:Nr(e).length},qn.snakeCase=Hs,qn.some=function(e,t,r){var i=$o(e)?Lt:ai;return r&&wa(e,t,r)&&(t=n),i(e,ca(t,3))},qn.sortedIndex=function(e,t){return oi(e,t)},qn.sortedIndexBy=function(e,t,n){return si(e,t,ca(n,2))},qn.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=oi(e,t);if(r<n&&zo(e[r],t))return r}return-1},qn.sortedLastIndex=function(e,t){return oi(e,t,!0)},qn.sortedLastIndexBy=function(e,t,n){return si(e,t,ca(n,2),!0)},qn.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var n=oi(e,t,!0)-1;if(zo(e[n],t))return n}return-1},qn.startCase=Ys,qn.startsWith=function(e,t,n){return e=ws(e),n=null==n?0:ur(ys(n),0,e.length),t=li(t),e.slice(n,n+t.length)==t},qn.subtract=Ru,qn.sum=function(e){return e&&e.length?$t(e,au):0},qn.sumBy=function(e,t){return e&&e.length?$t(e,ca(t,2)):0},qn.template=function(e,t,r){var i=qn.templateSettings;r&&wa(e,t,r)&&(t=n),e=ws(e),t=xs({},t,i,Zi);var a,o,s=xs({},t.imports,i.imports,Zi),u=js(s),c=Yt(s,u),l=0,f=t.interpolate||we,d="__p += '",p=Ie((t.escape||we).source+"|"+f.source+"|"+(f===X?de:we).source+"|"+(t.evaluate||we).source+"|$","g"),h="//# sourceURL="+(Le.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rt+"]")+"\n";e.replace(p,(function(t,n,r,i,s,u){return r||(r=i),d+=e.slice(l,u).replace(ke,rn),n&&(a=!0,d+="' +\n__e("+n+") +\n'"),s&&(o=!0,d+="';\n"+s+";\n__p += '"),r&&(d+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),l=u+t.length,t})),d+="';\n";var v=Le.call(t,"variable")&&t.variable;if(v){if(le.test(v))throw new xe("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(o?d.replace(W,""):d).replace(K,"$1").replace(V,"$1;"),d="function("+(v||"obj")+") {\n"+(v?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var y=eu((function(){return Se(u,h+"return "+d).apply(n,c)}));if(y.source=d,Xo(y))throw y;return y},qn.times=function(e,t){if((e=ys(e))<1||e>d)return[];var n=h,r=wn(e,h);t=ca(t),e-=h;for(var i=Gt(r,t);++n<e;)t(n);return i},qn.toFinite=vs,qn.toInteger=ys,qn.toLength=gs,qn.toLower=function(e){return ws(e).toLowerCase()},qn.toNumber=ms,qn.toSafeInteger=function(e){return e?ur(ys(e),-9007199254740991,d):0===e?e:0},qn.toString=ws,qn.toUpper=function(e){return ws(e).toUpperCase()},qn.trim=function(e,t,r){if((e=ws(e))&&(r||t===n))return Jt(e);if(!e||!(t=li(t)))return e;var i=dn(e),a=dn(t);return _i(i,Xt(i,a),Zt(i,a)+1).join("")},qn.trimEnd=function(e,t,r){if((e=ws(e))&&(r||t===n))return e.slice(0,pn(e)+1);if(!e||!(t=li(t)))return e;var i=dn(e);return _i(i,0,Zt(i,dn(t))+1).join("")},qn.trimStart=function(e,t,r){if((e=ws(e))&&(r||t===n))return e.replace(ie,"");if(!e||!(t=li(t)))return e;var i=dn(e);return _i(i,Xt(i,dn(t))).join("")},qn.truncate=function(e,t){var r=30,i="...";if(ns(t)){var a="separator"in t?t.separator:a;r="length"in t?ys(t.length):r,i="omission"in t?li(t.omission):i}var o=(e=ws(e)).length;if(an(e)){var s=dn(e);o=s.length}if(r>=o)return e;var u=r-fn(i);if(u<1)return i;var c=s?_i(s,0,u).join(""):e.slice(0,u);if(a===n)return c+i;if(s&&(u+=c.length-u),ss(a)){if(e.slice(u).search(a)){var l,f=c;for(a.global||(a=Ie(a.source,ws(pe.exec(a))+"g")),a.lastIndex=0;l=a.exec(f);)var d=l.index;c=c.slice(0,d===n?u:d)}}else if(e.indexOf(li(a),u)!=u){var p=c.lastIndexOf(a);p>-1&&(c=c.slice(0,p))}return c+i},qn.unescape=function(e){return(e=ws(e))&&J.test(e)?e.replace($,hn):e},qn.uniqueId=function(e){var t=++Ue;return ws(e)+t},qn.upperCase=Qs,qn.upperFirst=Xs,qn.each=wo,qn.eachRight=ko,qn.first=Ga,cu(qn,(xu={},kr(qn,(function(e,t){Le.call(qn.prototype,t)||(xu[t]=e)})),xu),{chain:!1}),qn.VERSION="4.17.21",Et(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){qn[e].placeholder=qn})),Et(["drop","take"],(function(e,t){Vn.prototype[e]=function(r){r=r===n?1:bn(ys(r),0);var i=this.__filtered__&&!t?new Vn(this):this.clone();return i.__filtered__?i.__takeCount__=wn(r,i.__takeCount__):i.__views__.push({size:wn(r,h),type:e+(i.__dir__<0?"Right":"")}),i},Vn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Et(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;Vn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:ca(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),Et(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Vn.prototype[e]=function(){return this[n](1).value()[0]}})),Et(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Vn.prototype[e]=function(){return this.__filtered__?new Vn(this):this[n](1)}})),Vn.prototype.compact=function(){return this.filter(au)},Vn.prototype.find=function(e){return this.filter(e).head()},Vn.prototype.findLast=function(e){return this.reverse().find(e)},Vn.prototype.invokeMap=Qr((function(e,t){return"function"==typeof e?new Vn(this):this.map((function(n){return Pr(n,e,t)}))})),Vn.prototype.reject=function(e){return this.filter(No(ca(e)))},Vn.prototype.slice=function(e,t){e=ys(e);var r=this;return r.__filtered__&&(e>0||t<0)?new Vn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(r=(t=ys(t))<0?r.dropRight(-t):r.take(t-e)),r)},Vn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Vn.prototype.toArray=function(){return this.take(h)},kr(Vn.prototype,(function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=qn[i?"take"+("last"==t?"Right":""):t],o=i||/^find/.test(t);a&&(qn.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,u=t instanceof Vn,c=s[0],l=u||$o(t),f=function(e){var t=a.apply(qn,At([e],s));return i&&d?t[0]:t};l&&r&&"function"==typeof c&&1!=c.length&&(u=l=!1);var d=this.__chain__,p=!!this.__actions__.length,h=o&&!d,v=u&&!p;if(!o&&l){t=v?t:new Vn(this);var y=e.apply(t,s);return y.__actions__.push({func:vo,args:[f],thisArg:n}),new Kn(y,d)}return h&&v?e.apply(this,s):(y=this.thru(f),h?i?y.value()[0]:y.value():y)})})),Et(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Oe[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);qn.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply($o(i)?i:[],e)}return this[n]((function(n){return t.apply($o(n)?n:[],e)}))}})),kr(Vn.prototype,(function(e,t){var n=qn[t];if(n){var r=n.name+"";Le.call(An,r)||(An[r]=[]),An[r].push({name:t,func:n})}})),An[qi(n,2).name]=[{name:"wrapper",func:n}],Vn.prototype.clone=function(){var e=new Vn(this.__wrapped__);return e.__actions__=Oi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Oi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Oi(this.__views__),e},Vn.prototype.reverse=function(){if(this.__filtered__){var e=new Vn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Vn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=$o(e),r=t<0,i=n?e.length:0,a=function(e,t,n){var r=-1,i=n.length;for(;++r<i;){var a=n[r],o=a.size;switch(a.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=wn(t,e+o);break;case"takeRight":e=bn(e,t-o)}}return{start:e,end:t}}(0,i,this.__views__),o=a.start,s=a.end,u=s-o,c=r?s:o-1,l=this.__iteratees__,f=l.length,d=0,p=wn(u,this.__takeCount__);if(!n||!r&&i==u&&p==u)return vi(e,this.__actions__);var h=[];e:for(;u--&&d<p;){for(var v=-1,y=e[c+=t];++v<f;){var g=l[v],m=g.iteratee,b=g.type,w=m(y);if(2==b)y=w;else if(!w){if(1==b)continue e;break e}}h[d++]=y}return h},qn.prototype.at=yo,qn.prototype.chain=function(){return ho(this)},qn.prototype.commit=function(){return new Kn(this.value(),this.__chain__)},qn.prototype.next=function(){this.__values__===n&&(this.__values__=hs(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},qn.prototype.plant=function(e){for(var t,r=this;r instanceof Wn;){var i=Ba(r);i.__index__=0,i.__values__=n,t?a.__wrapped__=i:t=i;var a=i;r=r.__wrapped__}return a.__wrapped__=e,t},qn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Vn){var t=e;return this.__actions__.length&&(t=new Vn(this)),(t=t.reverse()).__actions__.push({func:vo,args:[to],thisArg:n}),new Kn(t,this.__chain__)}return this.thru(to)},qn.prototype.toJSON=qn.prototype.valueOf=qn.prototype.value=function(){return vi(this.__wrapped__,this.__actions__)},qn.prototype.first=qn.prototype.head,et&&(qn.prototype[et]=function(){return this}),qn}();pt?((pt.exports=vn)._=vn,dt._=vn):ft._=vn}).call(FT)}(BT,BT.exports);var $T=function(e){TI.default(m,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g=VT(m);function m(e,t,n){var r;EI.default(this,m);return(r=g.call(this,e,n)).updateMergingQueue=new xT((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new DT,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return RI.default(m,[{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:(y=SI.default(AI.default.mark((function e(t,n,r,i){var a,o;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a={data:n},void 0!==i&&(a.ttl=i),e.next=4,this.services.network.post(t,a,r);case 4:return(o=e.sent).body.data=n,o.body.date_updated=new Date(o.body.date_updated),e.abrupt("return",o.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r){return y.apply(this,arguments)})},{key:"push",value:(v=SI.default(AI.default.mark((function e(t,n){var r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(n||{}).ttl,e.next=3,this._addOrUpdateItemOnServer(this.links.items,t,void 0,r);case 3:return i=e.sent,a=Number(i.index),this._handleItemMutated(a,i.url,i.last_event_id,i.revision,t,i.date_updated,i.date_expires,!0,!1),e.abrupt("return",this.cache.getValue(a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"set",value:(h=SI.default(AI.default.mark((function e(t,n,r){var i,a=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,(function(e){return a._updateItemUnconditionally(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return h.apply(this,arguments)})},{key:"_updateItemUnconditionally",value:(p=SI.default(AI.default.mark((function e(t,n,r){var i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return i=e.sent,e.next=5,this._addOrUpdateItemOnServer(i.url,n,void 0,r);case 5:return a=e.sent,this._handleItemMutated(t,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,!1,!1),e.abrupt("return",this.cache.getValue(t));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return p.apply(this,arguments)})},{key:"_updateItemWithIfMatch",value:(d=SI.default(AI.default.mark((function e(t,n,r){var i,a,o,s;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:if(i=e.sent,!(a=n($I(i.data)))){e.next=25;break}return o=i.revision,e.prev=6,e.next=9,this._addOrUpdateItemOnServer(i.url,a,o,r);case 9:return s=e.sent,this._handleItemMutated(t,s.url,s.last_event_id,s.revision,s.data,s.date_updated,s.date_expires,!1,!1),e.abrupt("return",this.cache.getValue(t));case 14:if(e.prev=14,e.t0=e.catch(6),412!==e.t0.status){e.next=22;break}return e.next=19,this._getItemFromServer(t);case 19:return e.abrupt("return",this._updateItemWithIfMatch(t,n,r));case 22:throw e.t0;case 23:e.next=26;break;case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(e,t,n){return d.apply(this,arguments)})},{key:"mutate",value:(f=SI.default(AI.default.mark((function e(t,n,r){var i,a=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.add(t,i,(function(e){return a._updateItemWithIfMatch(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return f.apply(this,arguments)})},{key:"update",value:(l=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,(function(e){return Object.assign(e,n)}),r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"remove",value:(c=SI.default(AI.default.mark((function e(t){var n,r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=$I(n.data),e.next=6,this.services.network.delete(n.url);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"get",value:function(){var e=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))){e.next=3;break}return e.abrupt("return",n.value);case 3:return e.abrupt("return",this._getItemFromServer(t));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(u=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._queryItemsFromServer({index:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new SyncError("No item with index ".concat(t," found"),404,54151);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"queryItems",value:function(){var e=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g,m,b,w,k,_,x,S,E,R,I,T,C;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.index){e.next=5;break}if(!(l=this.cache.get(t.index))){e.next=4;break}return e.abrupt("return",this.makePaginator(l.isValid?[l.value]:[],t,!1,!1));case 4:return e.abrupt("return",this._querySingleItemFromServer(t.index));case 5:f=!!t.nextPageItemId||!!t.prevPageItemId,d=KT({},t),f&&(t.from=null!==(p=null!==(h=t.nextPageItemId)&&void 0!==h?h:t.prevPageItemId)&&void 0!==p?p:t.from),v=!!t.prevPageItemId,y="desc"===t.order?v?this.cache.getIterator(null!==(n=null!==(r=t.prevPageItemId)&&void 0!==r?r:t.from)&&void 0!==n?n:null):this.cache.getReverseIterator(null!==(i=null!==(a=t.nextPageItemId)&&void 0!==a?a:t.from)&&void 0!==i?i:null):v?this.cache.getReverseIterator(null!==(o=null!==(s=t.prevPageItemId)&&void 0!==s?s:t.from)&&void 0!==o?o:null):this.cache.getIterator(null!==(u=null!==(c=t.nextPageItemId)&&void 0!==c?c:t.from)&&void 0!==u?u:null),g=[],m=f?t.limit+1:t.limit,b=qT(y),e.prev=13,b.s();case 15:if((w=b.n()).done){e.next=25;break}if(k=w.value,!f||k.value.index!=t.from){e.next=19;break}return e.abrupt("continue",23);case 19:if(g.push(k.value),!(g.length>=t.limit)){e.next=23;break}return v&&BT.exports.reverse(g),e.abrupt("return",this.makePaginator(g,t,this._prevPageAllowed(g,t.order),this._nextPageAllowed(g,t.order)));case 23:e.next=15;break;case 25:e.next=30;break;case 27:e.prev=27,e.t0=e.catch(13),b.e(e.t0);case 30:return e.prev=30,b.f(),e.finish(30);case 33:if(g.length>0&&(t.from=BT.exports.last(g).index),_=Math.max(m-g.length,10),v&&(t.order="desc"===t.order?"asc":"desc"),!(t.from!==("desc"===d.order?v?this.cache.collectionEnd:this.cache.collectionBegin:v?this.cache.collectionBegin:this.cache.collectionEnd))){e.next=66;break}return e.next=40,this._queryItemsFromServer(KT(KT({},t),{},{limit:_}));case 40:x=e.sent,S=x.items,"desc"===d.order?(E=!x.hasNextPage,R=!x.hasPrevPage):(E=!x.hasPrevPage,R=!x.hasNextPage),this.cache.populate(S,E,R),I=qT(S),e.prev=45,I.s();case 47:if((T=I.n()).done){e.next=56;break}if(C=T.value,!(g.length>0||f)||C.index!=t.from){e.next=51;break}return e.abrupt("continue",54);case 51:if(v?g.unshift(C):g.push(C),!(g.length>=t.limit)){e.next=54;break}return e.abrupt("break",56);case 54:e.next=47;break;case 56:e.next=61;break;case 58:e.prev=58,e.t1=e.catch(45),I.e(e.t1);case 61:return e.prev=61,I.f(),e.finish(61);case 64:e.next=67;break;case 66:v&&BT.exports.reverse(g);case 67:return e.abrupt("return",this.makePaginator(g,d,this._prevPageAllowed(g,d.order),this._nextPageAllowed(g,d.order)));case 68:case"end":return e.stop()}}),e,this,[[13,27,30,33],[45,58,61,64]])})));return function(t){return e.apply(this,arguments)}}()},{key:"_prevPageAllowed",value:function(e,t){return e.length>0&&BT.exports.head(e).index!==("desc"===t?this.cache.collectionEnd:this.cache.collectionBegin)}},{key:"_nextPageAllowed",value:function(e,t){return e.length>0&&BT.exports.last(e).index!==("desc"===t?this.cache.collectionBegin:this.cache.collectionEnd)}},{key:"makePaginator",value:function(e,t,n,r){var i=this;t.nextPageItemId=t.prevPageItemId=null;var a=n&&this._prevPageAllowed(e,t.order),o=r&&this._nextPageAllowed(e,t.order);return new Paginator(e,(function(e){return i.queryItems(KT(KT({},t),e))}),a?BT.exports.head(e).index:null,o?BT.exports.last(e).index:null)}},{key:"_querySingleItemFromServer",value:(s=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._queryItemsFromServer({index:t});case 2:return 0===(n=e.sent).items.length&&this.cache.exists(t)&&this.cache.delete(t,null),e.abrupt("return",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"_queryItemsFromServer",value:(o=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s,u=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new WI(this.links.items).queryParam("HideExpired",!0).queryParam("Index",t.index).queryParam("PageToken",t.pageToken).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Order",t.order).build(),e.next=3,this.services.network.get(i);case 3:return a=e.sent,o=(null!==(n=null===(r=a.body)||void 0===r?void 0:r.items)&&void 0!==n?n:[]).map((function(e){e.date_updated=new Date(e.date_updated);var t=u.cache.get(e.index);if(t&&t.value)u._handleItemMutated(e.index,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0);else{var n=new CT({index:e.index,url:e.url,lastEventId:e.last_event_id,revision:e.revision,data:e.data,dateUpdated:e.date_updated,dateExpires:e.date_expires});u.cache.store(e.index,n,e.last_event_id)}return u.cache.getValue(e.index)})),s=a.body.meta,e.abrupt("return",this.makePaginator(o,t,!!s.previous_token,!!s.next_token));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getItems",value:(a=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GI((t=t||{}).pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getContext",value:(i=SI.default(AI.default.mark((function e(){var t;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.context){e.next=5;break}return e.next=3,this.services.network.get(this.links.context);case 3:t=e.sent,this._updateContextIfRequired(t.body.data,t.body.last_event_id);case 5:return e.abrupt("return",this.context);case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setTtl",value:(r=SI.default(AI.default.mark((function e(t){var n,r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=SI.default(AI.default.mark((function e(t,n){var r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return r=e.sent,i={ttl:n},e.next=6,this.services.network.post(r.url,i);case 6:a=e.sent,r.updateDateExpires(a.body.date_expires);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeList",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){var n=Number(e.item_index);switch(e.date_created=new Date(e.date_created),e.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(n,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,e.date_expires,"list_item_added"===e.type,!0);break;case"list_item_removed":this._handleItemRemoved(n,e.id,e.item_data,e.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(e.context_data,e.id,e.date_created);break;case"list_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.list_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,a,o,s,u){if(this.shouldIgnoreEvent(e,n))XI("Item ".concat(e," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(n));else{this._updateRootDateUpdated(a);var c=this.cache.getValue(e);if(!c){var l=new CT({index:e,url:t,lastEventId:n,revision:r,data:i,dateUpdated:a,dateExpires:o});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,s)}var f=$I(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==o&&c.updateDateExpires(o),this.emitItemMutationEvent(c,u,!1,f)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",a={item:e,isLocal:!t};n||(a.previousItemData=r),this.broadcastEventToListeners(i,a)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{index:e,isLocal:!i,previousItemData:n})}},{key:"_handleContextUpdate",value:function(e,t,n){this._updateRootDateUpdated(n),this._updateContextIfRequired(e,t)&&this.broadcastEventToListeners("contextUpdated",{context:e,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(e,t){return!this.contextEventId||t>this.contextEventId?(this.context=e,this.contextEventId=t,!0):(XI("Context update skipped, current:",this.lastEventId,", remote:",t),!1)}}],[{key:"type",get:function(){return"list"}}]),m}(kT),GT=function(e){TI.default(p,e);var t,n,r,i,a,o,s,u,c,l,f,d=VT(p);function p(e){var t;return EI.default(this,p),(t=d.call(this)).syncListImpl=e,t.syncListImpl.attach(II.default(t)),t}return RI.default(p,[{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 $T.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:(f=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.push(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"set",value:(l=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.set(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"mutate",value:(c=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.mutate(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"update",value:(u=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.update(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"remove",value:(s=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.remove(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"get",value:(o=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.get(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getContext",value:(a=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getItems",value:(i=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getItems(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setTtl",value:(r=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeList",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){DI.default(OI.default(p.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return $T.type}}]),p}(ET);PI.default(GT,"itemAdded","itemAdded"),PI.default(GT,"itemUpdated","itemUpdated"),PI.default(GT,"itemRemoved","itemRemoved"),PI.default(GT,"removed","removed"),qI([fI.validateTypesAsync(fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object,Object]),zI("design:returntype",Promise)],GT.prototype,"push",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger,fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Number,Object,Object]),zI("design:returntype",Promise)],GT.prototype,"set",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger,"function",["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Number,Function,Object]),zI("design:returntype",Promise)],GT.prototype,"mutate",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger,fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Number,Object,Object]),zI("design:returntype",Promise)],GT.prototype,"update",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],GT.prototype,"remove",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],GT.prototype,"get",null),qI([fI.validateTypesAsync(["undefined",fI.objectSchema("query options",{from:[fI.nonNegativeInteger,"undefined"],pageSize:[fI.custom((function(e){return[JI(e),"a positive integer"]})),"undefined"],order:[fI.custom((function(e){return["asc"===e||"desc"===e,"either 'asc' or 'desc'"]})),"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],GT.prototype,"getItems",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],GT.prototype,"setTtl",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger,fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number,Number]),zI("design:returntype",Promise)],GT.prototype,"setItemTtl",null);var JT=function(){function e(t){EI.default(this,e),this.descriptor=t}return RI.default(e,[{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:"cacheKey",get:function(){return this.key}},{key:"update",value:function(e,t,n,r){return this.descriptor.last_event_id=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.date_updated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.date_expires=e}}]),e}();function HT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return YT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return YT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function YT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function QT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function XT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?QT(Object(n),!0).forEach((function(t){PI.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QT(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ZT(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var eC=function(e){TI.default(y,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v=ZT(y);function y(e,t,n){var r;EI.default(this,y);return(r=v.call(this,e,n)).updateMergingQueue=new xT((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new DT,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),t.items&&t.items.forEach((function(e){e.date_updated=new Date(e.date_updated),r.cache.store(e.key,new JT(e),e.last_event_id)})),r}return RI.default(y,[{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:(h=SI.default(AI.default.mark((function e(t,n,r){var i,a=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,(function(e){return a._putItemUnconditionally(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return h.apply(this,arguments)})},{key:"get",value:function(){var e=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new SyncError("SyncMapItem key may not be empty",400,54209);case 2:if(!this.cache.has(t)){e.next=6;break}return e.abrupt("return",this.cache.getValue(t));case 6:return e.abrupt("return",this._getItemFromServer(t));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(p=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._queryItemsFromServer({key:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new SyncError("The specified Map Item does not exist",404,54201);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"mutate",value:(d=SI.default(AI.default.mark((function e(t,n,r){var i,a=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.add(t,i,(function(e){return a._putItemWithIfMatch(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"update",value:(f=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,(function(e){return Object.assign(e,n)}),r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return f.apply(this,arguments)})},{key:"_putItemUnconditionally",value:(l=SI.default(AI.default.mark((function e(t,n,r){var i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._putItemToServer(t,n,void 0,r);case 2:return i=e.sent,a=i.item,this._handleItemMutated(a.key,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,i.added,!1),e.abrupt("return",this.cache.getValue(a.key));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"_putItemWithIfMatch",value:(c=SI.default(AI.default.mark((function e(t,n,r){var i,a,o,s,u;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t).catch((function(e){if(404===e.status)return new JT({key:t,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw e}));case 2:if(i=e.sent,!(a=n($I(i.data)))){e.next=26;break}return o=i.revision,e.prev=6,e.next=9,this._putItemToServer(t,a,o,r);case 9:return s=e.sent,u=s.item,this._handleItemMutated(u.key,u.url,u.last_event_id,u.revision,u.data,u.date_updated,u.date_expires,s.added,!1),e.abrupt("return",this.cache.getValue(u.key));case 15:if(e.prev=15,e.t0=e.catch(6),412!==e.t0.status){e.next=23;break}return e.next=20,this._getItemFromServer(t);case 20:return e.abrupt("return",this._putItemWithIfMatch(t,n,r));case 23:throw e.t0;case 24:e.next=27;break;case 26:return e.abrupt("return",i);case 27:case"end":return e.stop()}}),e,this,[[6,15]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"_putItemToServer",value:(u=SI.default(AI.default.mark((function e(t,n,r,i){var a,o,s,u,c;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new WI(this.links.items).pathSegment(t).build(),o={data:n},void 0!==i&&(o.ttl=i),e.prev=3,e.next=6,this.services.network.put(a,o,r);case 6:return s=e.sent,(u=s.body).data=n,u.date_updated=new Date(u.date_updated),c=201===s.status.code,e.abrupt("return",{added:c,item:u});case 14:throw e.prev=14,e.t0=e.catch(3),404===e.t0.status&&this.onRemoved(!1),e.t0;case 18:case"end":return e.stop()}}),e,this,[[3,14]])}))),function(e,t,n,r){return u.apply(this,arguments)})},{key:"remove",value:(s=SI.default(AI.default.mark((function e(t){var n,r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=$I(n.data),e.next=6,this.services.network.delete(n.uri);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"queryItems",value:function(){var e=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g,m,b,w,k,_,x,S,E,R,I,T,C;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.key){e.next=5;break}if(!(l=this.cache.get(t.key))){e.next=4;break}return e.abrupt("return",this.makePaginator(l.isValid?[l.value]:[],t,!1,!1));case 4:return e.abrupt("return",this._querySingleItemFromServer(t.key));case 5:f=!!t.nextPageItemId||!!t.prevPageItemId,d=XT({},t),f&&(t.from=null!==(p=null!==(h=t.nextPageItemId)&&void 0!==h?h:t.prevPageItemId)&&void 0!==p?p:t.from),v=!!t.prevPageItemId,y="desc"===t.order?v?this.cache.getIterator(null!==(n=null!==(r=t.prevPageItemId)&&void 0!==r?r:t.from)&&void 0!==n?n:null):this.cache.getReverseIterator(null!==(i=null!==(a=t.nextPageItemId)&&void 0!==a?a:t.from)&&void 0!==i?i:null):v?this.cache.getReverseIterator(null!==(o=null!==(s=t.prevPageItemId)&&void 0!==s?s:t.from)&&void 0!==o?o:null):this.cache.getIterator(null!==(u=null!==(c=t.nextPageItemId)&&void 0!==c?c:t.from)&&void 0!==u?u:null),g=[],m=f?t.limit+1:t.limit,b=HT(y),e.prev=13,b.s();case 15:if((w=b.n()).done){e.next=25;break}if(k=w.value,!f||k.value.key!=t.from){e.next=19;break}return e.abrupt("continue",23);case 19:if(g.push(k.value),!(g.length>=t.limit)){e.next=23;break}return v&&BT.exports.reverse(g),e.abrupt("return",this.makePaginator(g,t,this._prevPageAllowed(g,t.order),this._nextPageAllowed(g,t.order)));case 23:e.next=15;break;case 25:e.next=30;break;case 27:e.prev=27,e.t0=e.catch(13),b.e(e.t0);case 30:return e.prev=30,b.f(),e.finish(30);case 33:if(g.length>0&&(t.from=BT.exports.last(g).key),_=Math.max(m-g.length,10),v&&(t.order="desc"===t.order?"asc":"desc"),!(t.from!==("desc"===d.order?v?this.cache.collectionEnd:this.cache.collectionBegin:v?this.cache.collectionBegin:this.cache.collectionEnd))){e.next=66;break}return e.next=40,this._queryItemsFromServer(XT(XT({},t),{},{limit:_}));case 40:x=e.sent,S=x.items,"desc"===d.order?(E=!x.hasNextPage,R=!x.hasPrevPage):(E=!x.hasPrevPage,R=!x.hasNextPage),this.cache.populate(S,E,R),I=HT(S),e.prev=45,I.s();case 47:if((T=I.n()).done){e.next=56;break}if(C=T.value,!(g.length>0||f)||C.key!=t.from){e.next=51;break}return e.abrupt("continue",54);case 51:if(v?g.unshift(C):g.push(C),!(g.length>=t.limit)){e.next=54;break}return e.abrupt("break",56);case 54:e.next=47;break;case 56:e.next=61;break;case 58:e.prev=58,e.t1=e.catch(45),I.e(e.t1);case 61:return e.prev=61,I.f(),e.finish(61);case 64:e.next=67;break;case 66:v&&BT.exports.reverse(g);case 67:return e.abrupt("return",this.makePaginator(g,d,this._prevPageAllowed(g,d.order),this._nextPageAllowed(g,d.order)));case 68:case"end":return e.stop()}}),e,this,[[13,27,30,33],[45,58,61,64]])})));return function(t){return e.apply(this,arguments)}}()},{key:"_prevPageAllowed",value:function(e,t){return e.length>0&&BT.exports.head(e).key!==("desc"===t?this.cache.collectionEnd:this.cache.collectionBegin)}},{key:"_nextPageAllowed",value:function(e,t){return e.length>0&&BT.exports.last(e).key!==("desc"===t?this.cache.collectionBegin:this.cache.collectionEnd)}},{key:"makePaginator",value:function(e,t,n,r){var i=this;t.nextPageItemId=t.prevPageItemId=null;var a=n&&this._prevPageAllowed(e,t.order),o=r&&this._nextPageAllowed(e,t.order);return new Paginator(e,(function(e){return i.queryItems(XT(XT({},t),e))}),a?BT.exports.head(e).key:null,o?BT.exports.last(e).key:null)}},{key:"_querySingleItemFromServer",value:(o=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._queryItemsFromServer({key:t});case 2:return 0===(n=e.sent).items.length&&this.cache.exists(t)&&this.cache.delete(t,null),e.abrupt("return",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_queryItemsFromServer",value:(a=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s,u=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new WI(this.links.items).queryParam("HideExpired",!0).queryParam("Key",t.key).queryParam("PageToken",t.pageToken).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Order",t.order).build(),e.next=3,this.services.network.get(i);case 3:return a=e.sent,o=(null!==(n=null===(r=a.body)||void 0===r?void 0:r.items)&&void 0!==n?n:[]).map((function(e){e.date_updated=new Date(e.date_updated);var t=u.cache.get(e.key);if(t&&t.value)u._handleItemMutated(e.key,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0);else{var n=new JT({key:e.key,url:e.url,last_event_id:e.last_event_id,revision:e.revision,data:e.data,date_updated:e.date_updated,date_expires:e.date_expires});u.cache.store(e.key,n,e.last_event_id)}return u.cache.getValue(e.key)})),s=a.body.meta,e.abrupt("return",this.makePaginator(o,t,!!s.previous_token,!!s.next_token));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getItems",value:(i=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GI((t=t||{}).pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){switch(e.date_created=new Date(e.date_created),e.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(e.item_key,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,e.date_expires,"map_item_added"===e.type,!0);break;case"map_item_removed":this._handleItemRemoved(e.item_key,e.id,e.item_data,e.date_created,!0);break;case"map_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.map_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,a,o,s,u){if(this.shouldIgnoreEvent(e,n))XI("SyncMapItem ",e," update skipped, current:",this.lastEventId,", remote:",n);else{this._updateRootDateUpdated(a);var c=this.cache.getValue(e);if(!c){var l=new JT({key:e,url:t,last_event_id:n,revision:r,data:i,date_updated:a,date_expires:o});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,s)}var f=$I(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==o&&c.updateDateExpires(o),this.emitItemMutationEvent(c,u,!1,f)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",a={item:e,isLocal:!t};n||(a.previousItemData=r),this.broadcastEventToListeners(i,a)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{key:e,isLocal:!i,previousItemData:n})}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"setTtl",value:(r=SI.default(AI.default.mark((function e(t){var n,r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=SI.default(AI.default.mark((function e(t,n){var r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return r=e.sent,i={ttl:n},e.next=6,this.services.network.post(r.uri,i);case 6:a=e.sent,r.updateDateExpires(a.body.date_expires);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeMap",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"type",get:function(){return"map"}}]),y}(kT),tC=function(e){TI.default(f,e);var t,n,r,i,a,o,s,u,c,l=ZT(f);function f(e){var t;return EI.default(this,f),(t=l.call(this)).syncMapImpl=e,t.syncMapImpl.attach(II.default(t)),t}return RI.default(f,[{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 eC.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:(c=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.set(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"get",value:(u=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.get(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"mutate",value:(s=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.mutate(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return s.apply(this,arguments)})},{key:"update",value:(o=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.update(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return o.apply(this,arguments)})},{key:"remove",value:(a=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.remove(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getItems",value:(i=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.getItems(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setTtl",value:(r=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeMap",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.next=3,this.syncMapImpl.removeMap();case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){DI.default(OI.default(f.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return eC.type}}]),f}(ET);function nC(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}PI.default(tC,"itemAdded","itemAdded"),PI.default(tC,"itemUpdated","itemUpdated"),PI.default(tC,"itemRemoved","itemRemoved"),PI.default(tC,"removed","removed"),qI([fI.validateTypesAsync("string",fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[String,Object,Object]),zI("design:returntype",Promise)],tC.prototype,"set",null),qI([fI.validateTypesAsync("string"),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],tC.prototype,"get",null),qI([fI.validateTypesAsync("string","function",["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[String,Function,Object]),zI("design:returntype",Promise)],tC.prototype,"mutate",null),qI([fI.validateTypesAsync("string",fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[String,Object,Object]),zI("design:returntype",Promise)],tC.prototype,"update",null),qI([fI.validateTypesAsync("string"),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],tC.prototype,"remove",null),qI([fI.validateTypesAsync(["undefined",fI.objectSchema("query options",{from:["string","undefined"],pageSize:[fI.custom((function(e){return[JI(e),"a positive integer"]})),"undefined"],order:[fI.custom((function(e){return["asc"===e||"desc"===e,"either 'asc' or 'desc'"]})),"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],tC.prototype,"getItems",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],tC.prototype,"setTtl",null),qI([fI.validateTypesAsync("string",fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[String,Number]),zI("design:returntype",Promise)],tC.prototype,"setItemTtl",null);var rC=function(e){TI.default(a,e);var t,n,r,i=nC(a);function a(e,t,n){var r;return EI.default(this,a),(r=i.call(this,e,n)).descriptor=t,r}return RI.default(a,[{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:(r=SI.default(AI.default.mark((function e(t){var n,r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={data:t},e.next=3,this.services.network.post(this.links.messages,n);case 3:return r=e.sent,i=r.body,a=this._handleMessagePublished(i.sid,t,!1),e.abrupt("return",a);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setTtl",value:(n=SI.default(AI.default.mark((function e(t){var n,r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return n.apply(this,arguments)})},{key:"removeStream",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_update",value:function(e){switch(e.type){case"stream_message_published":this._handleMessagePublished(e.message_sid,e.message_data,!0);break;case"stream_removed":this.onRemoved(!1)}}},{key:"_handleMessagePublished",value:function(e,t,n){var r={sid:e,data:t};return this.broadcastEventToListeners("messagePublished",{message:r,isLocal:!n}),r}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}}],[{key:"type",get:function(){return"stream"}}]),a}(kT);qI([fI.validateTypesAsync(fI.pureObject),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],rC.prototype,"publishMessage",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],rC.prototype,"setTtl",null);var iC=function(e){TI.default(a,e);var t,n,r,i=nC(a);function a(e){var t;return EI.default(this,a),(t=i.call(this)).syncStreamImpl=e,t.syncStreamImpl.attach(II.default(t)),t}return RI.default(a,[{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 rC.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:(r=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.publishMessage(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setTtl",value:(n=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"removeStream",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){DI.default(OI.default(a.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return rC.type}}]),a}(ET);PI.default(iC,"messagePublished","messagePublished"),PI.default(iC,"removed","removed"),qI([fI.validateTypesAsync(fI.pureObject),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],iC.prototype,"publishMessage",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],iC.prototype,"setTtl",null);var aC=RI.default((function e(t){EI.default(this,e),this.sdk="js",this.sdkVer=t,this.os=BI.os.family,this.osVer=BI.os.version,this.pl=BI.name,this.plVer=BI.version})),oC=function(){function e(){EI.default(this,e),this.names=new Map,this.entities=new Map}return RI.default(e,[{key:"store",value:function(e){var t=this.entities.get(e.sid);return t||(this.entities.set(e.sid,e),e.uniqueName&&this.names.set(e.type+"::"+e.uniqueName,e.sid),e)}},{key:"getResolved",value:function(e,t){var n=this.names.get(t+"::"+e);return n?this.entities.get(n):null}},{key:"get",value:function(e,t){return this.entities.get(e)||this.getResolved(e,t)||null}},{key:"remove",value:function(e){var t=this.entities.get(e);t&&(this.entities.delete(e),t.uniqueName&&this.names.delete(t.type+"::"+t.uniqueName))}}]),e}();function sC(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var uC=function(){function e(t,n,r){EI.default(this,e),this.key=t,this.value=n,this.lastEventId=r}return RI.default(e,[{key:"cacheKey",get:function(){return this.key}}]),e}(),cC=function(e){TI.default(n,e);var t=sC(n);function n(e,r,i,a){var o;return EI.default(this,n),(o=t.call(this,r,i)).descriptor=e,o.cache=new DT,a&&a.forEach((function(e){var t=new uC(e.key,e.data,e.revision);o.cache.store(e.key,t,e.revision)})),o}return RI.default(n,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return n.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 e={};return this.cache.forEach((function(t,n){e[t]=n.value})),e}},{key:"_update",value:function(e,t){switch(e.type){case"live_query_item_updated":this.handleItemMutated(e.item_key,e.item_data,e.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(e.item_key,e.item_revision);break;case"live_query_updated":this.handleBatchUpdate(e.items)}t&&this._advanceLastEventId(e.last_event_id)}},{key:"handleItemMutated",value:function(e,t,n){if(this.shouldIgnoreEvent(e,n))XI("Item ".concat(e," update skipped, revision: ").concat(n));else{var r=new uC(e,t,n);this.cache.store(e,r,n),this.broadcastEventToListeners("itemUpdated",r)}}},{key:"handleItemRemoved",value:function(e,t){this.shouldIgnoreEvent(e,t)?XI("Item ".concat(e," delete skipped, revision: ").concat(t)):(this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{key:e}))}},{key:"handleBatchUpdate",value:function(e){var t=this,n={};for(var r in null!=e&&e.forEach((function(e){n[e.key]={data:e.data,revision:e.revision}})),this.cache.forEach((function(e,r){var i=n[e];null!=i?t.handleItemMutated(e,i.data,i.revision):t.handleItemRemoved(e,null),delete n[e]})),n)this.handleItemMutated(r,n[r].data,n[r].revision)}},{key:"shouldIgnoreEvent",value:function(e,t){return null!=e&&null!=t&&this.cache.isKnown(e,t)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e)}}],[{key:"type",get:function(){return"live_query"}}]),n}(kT);function lC(e){return fC.apply(this,arguments)}function fC(){return fC=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.network,r=t.queryString,i=t.uri,a=t.type,null!=r){e.next=3;break}throw new SyncError("Invalid query",400,54507);case 3:return o={query_string:r},a===dC.type&&(o.type=a),e.next=7,n.post(i,o,void 0,!0);case 7:return s=e.sent,e.abrupt("return",s.body);case 9:case"end":return e.stop()}}),e)}))),fC.apply(this,arguments)}var dC=function(e){TI.default(n,e);var t=sC(n);function n(e){var r;return EI.default(this,n),(r=t.call(this)).liveQueryImpl=e,r.liveQueryImpl.attach(II.default(r)),r}return RI.default(n,[{key:"type",get:function(){return cC.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){DI.default(OI.default(n.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 cC.type}}]),n}(ET);PI.default(dC,"itemUpdated","itemUpdated"),PI.default(dC,"itemRemoved","itemRemoved");var pC=function(e){TI.default(i,e);var t,n,r=sC(i);function i(e){var t;return EI.default(this,i),t=r.call(this),PI.default(II.default(t),"queryExpression",null),PI.default(II.default(t),"items",{}),Object.assign(II.default(t),e),t.updateIndexName(e.indexName),t}return RI.default(i,[{key:"type",get:function(){return i.type}},{key:"search",value:(n=SI.default(AI.default.mark((function e(t){var n,r=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.items={},e.prev=1,e.next=4,lC({network:this.network,uri:this.queryUri,queryString:t});case 4:n=e.sent,this.queryExpression=t,n.items&&n.items.forEach((function(e){r.items[e.key]=e.data})),this.emit("searchResult",this.getItems()),e.next=15;break;case 10:throw e.prev=10,e.t0=e.catch(1),tT("Error '".concat(e.t0.message,"' while executing query '").concat(t,"'")),this.queryExpression=null,e.t0;case 15:case"end":return e.stop()}}),e,this,[[1,10]])}))),function(e){return n.apply(this,arguments)})},{key:"subscribe",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.queryExpression){e.next=2;break}return e.abrupt("return",Promise.reject(new SyncError("Invalid query",400,54507)));case 2:return e.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(e){this.indexName=e,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(e){return new WI(this.insightsUri).pathSegment(e).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),i}(bI.ReplayEventEmitter);PI.default(pC,"searchResult","searchResult"),qI([fI.validateTypesAsync("string"),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],pC.prototype,"search",null),qI([fI.validateTypes(fI.nonEmptyString),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",void 0)],pC.prototype,"updateIndexName",null);function hC(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}function vC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function yC(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vC(Object(n),!0).forEach((function(t){PI.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vC(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var gC="data_sync",mC="3.4.0-rc.2";function bC(e){if(e){if("string"==typeof e)return{id:e,mode:"open_or_create"};var t=e.mode||(e.id?"open_or_create":"create_new");return yC(yC({},e),{},{mode:t})}return{mode:"create_new"}}var wC="com.twilio.rtd.cds.document",kC="com.twilio.rtd.cds.list",_C="com.twilio.rtd.cds.map",xC="twilio.sync.event",Client=function(e){TI.default(Client,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y=hC(Client);function Client(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(EI.default(this,Client),n=y.call(this),!e)throw new Error("Sync library needs a valid Twilio token to be passed");r.hasOwnProperty("logLevel")?QI(r.logLevel):QI("silent");var i=r.productId=r.productId||gC;r.clientMetadata=r.clientMetadata||{},r.clientMetadata.hasOwnProperty("type")||(r.clientMetadata.type="sync"),r.clientMetadata.hasOwnProperty("sdk")||(r.clientMetadata.sdk="JS",r.clientMetadata.sdkv=mC);var a=!r.twilsockClient;if(!r.initRegistrations){var o=new dI.InitRegistration(i);Client.populateInitRegistrations(o),r.initRegistrations=[o]}var s=r.twilsockClient=null!==(t=r.twilsockClient)&&void 0!==t?t:new dI.Twilsock(e,i,r);s.on("tokenAboutToExpire",(function(){return n.emit("tokenAboutToExpire")})),s.on("tokenExpired",(function(){return n.emit("tokenExpired")})),s.on("connectionError",(function(e){return n.emit("connectionError",e)})),s.on("stateChanged",(function(e){n.emit("connectionStateChanged",e),n.services.subscriptions.onConnectionStateChanged("connected"===e)})),s.on("message",(function(e,t){return n._routeMessage(e,t)}));var u=new cT(r),c=new gT(new aC(mC),u,s),l=new mT(u);return n.services={config:u,twilsock:s,network:c,storage:l,router:II.default(n),subscriptions:null},n.services.subscriptions=new pT(n.services),n.entities=new oC,a&&s.connect(),n}return RI.default(Client,[{key:"_routeMessage",value:function(e,t){switch(XI("Notification type:",e,"content:",t),e){case wC:case kC:case _C:this.services.subscriptions.acceptMessage(t,!1);break;case xC:this.services.subscriptions.acceptMessage(t,!0)}}},{key:"_subscribe",value:function(e,t){this.services.subscriptions.add(e,t)}},{key:"_unsubscribe",value:function(e){this.services.subscriptions.remove(e)}},{key:"connectionState",get:function(){return this.services.twilsock.state}},{key:"ensureReady",value:(v=SI.default(AI.default.mark((function e(){var t;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.services.config.sessionStorageEnabled){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.services.twilsock.storageId();case 5:t=e.sent,this.services.storage.updateStorageId(t.id),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),eT("Failed to initialize storage",e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])}))),function(){return v.apply(this,arguments)})},{key:"storeRootInSessionCache",value:function(e,t,n){if(this.services.config.sessionStorageEnabled&&t){var r=$I(n);e!==GT.type&&e!==tC.type||(r.last_event_id=null,delete r.items),this.services.storage.store(e,t,r)}}},{key:"readRootFromSessionCache",value:function(e,t){return this.services.config.sessionStorageEnabled&&t?this.services.storage.read(e,t):null}},{key:"_get",value:(h=SI.default(AI.default.mark((function e(t,n){var r,i,a,o=arguments;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=o.length>2&&void 0!==o[2]&&o[2],n){e.next=3;break}throw new SyncError("Cannot get entity without id",404);case 3:return i=new WI(t).pathSegment(n).queryParam("Include",r?"items":void 0).build(),e.next=6,this.services.network.get(i);case 6:return a=e.sent,e.abrupt("return",a.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"_createDocument",value:function(e,t,n){var r={unique_name:e,data:t||{}};return void 0!==n&&(r.ttl=n),this.services.network.post(this.services.config.documentsUri,r).then((function(e){return e.body.data=r.data,e.body}))}},{key:"_getDocument",value:(p=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(TT.type,t)||this._get(this.services.config.documentsUri,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"_createList",value:function(e,t,n,r){var i={unique_name:e,purpose:t,context:n};return void 0!==r&&(i.ttl=r),this.services.network.post(this.services.config.listsUri,i).then((function(e){return e.body}))}},{key:"_getList",value:(d=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(GT.type,t)||this._get(this.services.config.listsUri,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"_createMap",value:function(e,t){var n={unique_name:e};return void 0!==t&&(n.ttl=t),this.services.network.post(this.services.config.mapsUri,n).then((function(e){return e.body}))}},{key:"_getMap",value:(f=SI.default(AI.default.mark((function e(t){var n,r=arguments;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.length>1&&void 0!==r[1]&&r[1],e.abrupt("return",this.readRootFromSessionCache(tC.type,t)||this._get(this.services.config.mapsUri,t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"_getStream",value:(l=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(iC.type,t)||this._get(this.services.config.streamsUri,t,!1));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"_createStream",value:(c=SI.default(AI.default.mark((function e(t,n){var r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={unique_name:t},void 0!==n&&(r.ttl=n),e.next=4,this.services.network.post(this.services.config.streamsUri,r);case 4:return i=e.sent,e.abrupt("return",i.body);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"_getLiveQuery",value:function(e){return this.readRootFromSessionCache(dC.type,e)}},{key:"getCached",value:function(e,t){return e&&this.entities.get(e,t)||null}},{key:"removeFromCacheAndSession",value:function(e,t,n){this.entities.remove(t),this.services.config.sessionStorageEnabled&&this.services.storage.remove(e,t,n)}},{key:"document",value:(u=SI.default(AI.default.mark((function e(t){var n,r,i,a,o=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=bC(t)).mode){e.next=9;break}return e.next=6,this._createDocument(n.id,n.data,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,TT.type))){e.next=14;break}return e.abrupt("return",new TT(i));case 14:return e.prev=14,e.next=17,this._getDocument(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createDocument(n.id,n.data,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.document(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(TT.type,n.id,r),a=new IT(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new TT(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return u.apply(this,arguments)})},{key:"map",value:(s=SI.default(AI.default.mark((function e(t){var n,r,i,a,o=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=bC(t)).mode){e.next=9;break}return e.next=6,this._createMap(n.id,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,tC.type))){e.next=14;break}return e.abrupt("return",new tC(i));case 14:return e.prev=14,e.next=17,this._getMap(n.id,n.includeItems);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createMap(n.id,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.map(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(tC.type,n.id,r),a=new eC(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new tC(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return s.apply(this,arguments)})},{key:"list",value:(o=SI.default(AI.default.mark((function e(t){var n,r,i,a,o=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=bC(t)).mode){e.next=9;break}return e.next=6,this._createList(n.id,n.purpose,n.context,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,GT.type))){e.next=14;break}return e.abrupt("return",new GT(i));case 14:return e.prev=14,e.next=17,this._getList(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createList(n.id,n.purpose,n.context,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.list(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(GT.type,n.id,r),a=new $T(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new GT(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return o.apply(this,arguments)})},{key:"stream",value:(a=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=bC(t)).mode){e.next=9;break}return e.next=6,this._createStream(n.id,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,iC.type))){e.next=14;break}return e.abrupt("return",new iC(i));case 14:return e.prev=14,e.next=17,this._getStream(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createStream(n.id,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.stream(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(iC.type,n.id,r),a=function(e,t,n){return s.removeFromCacheAndSession(e,t,n)},o=new rC(this.services,r,a),o=this.entities.store(o),e.abrupt("return",new iC(o));case 44:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return a.apply(this,arguments)})},{key:"shutdown",value:(i=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.subscriptions.shutdown();case 2:return e.next=4,this.services.twilsock.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateToken",value:(r=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.twilsock.updateToken(t).catch((function(e){var t,n=null==e||null===(t=e.reply)||void 0===t?void 0:t.status;if(401===(null==n?void 0:n.code)&&"UNAUTHORIZED"===(null==n?void 0:n.status))throw new SyncError("Updated token was rejected by server",400,51130);throw e})));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"liveQuery",value:(n=SI.default(AI.default.mark((function e(t,n){var r,i,a,o,s,u=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return r=new WI(this.services.config.insightsUri).pathSegment(t).pathSegment("Items").build(),e.next=5,lC({network:this.services.network,uri:r,queryString:n,type:dC.type});case 5:return i=e.sent,(a=this.getCached(i.query_id,dC.type))||((o=this._getLiveQuery(i.query_id))||(o={indexName:t,queryExpression:n,sid:i.query_id,queryUri:r,last_event_id:i.last_event_id}),s=function(e,t,n){return u.removeFromCacheAndSession(e,t,n)},a=new cC(o,this.services,s,i.items)),this.storeRootInSessionCache(dC.type,i.query_id,a.liveQueryDescriptor),a=this.entities.store(a),e.abrupt("return",new dC(a));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"instantQuery",value:(t=SI.default(AI.default.mark((function e(t){var n,r=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return n=function(e,t){return r.liveQuery(e,t)},e.abrupt("return",new pC({indexName:t,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:n}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"populateInitRegistrations",value:function(e){e.populateInitRegistrations([xC,wC,kC,_C])}},{key:"version",get:function(){return mC}}]),Client}(bI.ReplayEventEmitter);PI.default(Client,"connectionStateChanged","connectionStateChanged"),PI.default(Client,"connectionError","connectionError"),PI.default(Client,"tokenAboutToExpire","tokenAboutToExpire"),PI.default(Client,"tokenExpired","tokenExpired"),qI([fI.validateTypesAsync(["undefined","string",fI.objectSchema("open document options",{id:["string","undefined"],mode:[fI.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[fI.nonNegativeInteger,"undefined"],data:[fI.pureObject,"undefined",fI.literal(null)]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],Client.prototype,"document",null),qI([fI.validateTypesAsync(["undefined","string",fI.objectSchema("open map options",{id:["string","undefined"],mode:[fI.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[fI.nonNegativeInteger,"undefined"],data:[fI.pureObject,"undefined",fI.literal(null)],includeItems:["boolean","undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],Client.prototype,"map",null),qI([fI.validateTypesAsync(["undefined","string",fI.objectSchema("open list options",{id:["string","undefined"],mode:[fI.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[fI.nonNegativeInteger,"undefined"],data:[fI.pureObject,"undefined",fI.literal(null)],purpose:["string","undefined"],context:[fI.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],Client.prototype,"list",null),qI([fI.validateTypesAsync(["undefined","string",fI.objectSchema("open stream options",{id:["string","undefined"],mode:[fI.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[fI.nonNegativeInteger,"undefined"],data:[fI.pureObject,"undefined",fI.literal(null)]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],Client.prototype,"stream",null),qI([fI.validateTypesAsync(fI.nonEmptyString),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],Client.prototype,"updateToken",null),qI([fI.validateTypesAsync(fI.nonEmptyString,"string"),zI("design:type",Function),zI("design:paramtypes",[String,String]),zI("design:returntype",Promise)],Client.prototype,"liveQuery",null),qI([fI.validateTypesAsync(fI.nonEmptyString),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],Client.prototype,"instantQuery",null),UR.Client=Client,UR.InsightsItem=uC,UR.InstantQuery=pC,UR.LiveQuery=dC,UR.Paginator=Paginator;var SC=UR.SyncClient=Client,EC=UR.SyncDocument=TT;UR.SyncList=GT,UR.SyncListItem=CT;var RC=UR.SyncMap=tC;UR.SyncMapItem=JT,UR.SyncStream=iC;var IC,TC={},CC=AE,OC=function(e){if(CC(e))throw TypeError("The method doesn't accept regular expressions");return e},PC=he("match"),AC=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[PC]=!1,"/./"[e](t)}catch(e){}}return!1},jC=Tn,MC=o.f,LC=Dt,UC=Er,NC=OC,DC=k,FC=AC,BC="".startsWith,qC=Math.min,zC=FC("startsWith");jC({target:"String",proto:!0,forced:!!(zC||(IC=MC(String.prototype,"startsWith"),!IC||IC.writable))&&!zC},{startsWith:function(e){var t=UC(DC(this));NC(e);var n=LC(qC(arguments.length>1?arguments[1]:void 0,t.length)),r=UC(e);return BC?BC.call(t,r,n):t.slice(n,n+r.length)===r}});var WC=s,KC=he("iterator"),VC=!WC((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[KC]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),$C=2147483647,GC=/[^\0-\u007E]/,JC=/[.\u3002\uFF0E\uFF61]/g,HC="Overflow: input needs wider integers to process",YC=Math.floor,QC=String.fromCharCode,XC=function(e){return e+22+75*(e<26)},ZC=function(e,t,n){var r=0;for(e=n?YC(e/700):e>>1,e+=YC(e/t);e>455;r+=36)e=YC(e/35);return YC(r+36*e/(e+38))},eO=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){var a=e.charCodeAt(n++);56320==(64512&a)?t.push(((1023&i)<<10)+(1023&a)+65536):(t.push(i),n--)}else t.push(i)}return t}(e);var n,r,i=e.length,a=128,o=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&t.push(QC(r));var u=t.length,c=u;for(u&&t.push("-");c<i;){var l=$C;for(n=0;n<e.length;n++)(r=e[n])>=a&&r<l&&(l=r);var f=c+1;if(l-a>YC(($C-o)/f))throw RangeError(HC);for(o+=(l-a)*f,a=l,n=0;n<e.length;n++){if((r=e[n])<a&&++o>$C)throw RangeError(HC);if(r==a){for(var d=o,p=36;;p+=36){var h=p<=s?1:p>=s+26?26:p-s;if(d<h)break;var v=d-h,y=36-h;t.push(QC(XC(h+v%y))),d=YC(v/y)}t.push(QC(XC(d))),s=ZC(o,f,c==u),o=0,++c}}++o,++a}return t.join("")},tO=Tn,nO=T,rO=VC,iO=Je.exports,aO=vo,oO=An,sO=Yl,uO=xt,cO=Eo,lO=te,fO=Fr,dO=Va,pO=Fe,hO=E,vO=Er,yO=nr,gO=v,mO=No,bO=Mo,wO=he,kO=nO("fetch"),_O=nO("Request"),xO=_O&&_O.prototype,SO=nO("Headers"),EO=wO("iterator"),RO="URLSearchParams",IO="URLSearchParamsIterator",TO=uO.set,CO=uO.getterFor(RO),OO=uO.getterFor(IO),PO=/\+/g,AO=Array(4),jO=function(e){return AO[e-1]||(AO[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},MO=function(e){try{return decodeURIComponent(e)}catch(t){return e}},LO=function(e){var t=e.replace(PO," "),n=4;try{return decodeURIComponent(t)}catch(e){for(;n;)t=t.replace(jO(n--),MO);return t}},UO=/[!'()~]|%20/g,NO={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},DO=function(e){return NO[e]},FO=function(e){return encodeURIComponent(e).replace(UO,DO)},BO=function(e,t){if(t)for(var n,r,i=t.split("&"),a=0;a<i.length;)(n=i[a++]).length&&(r=n.split("="),e.push({key:LO(r.shift()),value:LO(r.join("="))}))},qO=function(e){this.entries.length=0,BO(this.entries,e)},zO=function(e,t){if(e<t)throw TypeError("Not enough arguments")},WO=sO((function(e,t){TO(this,{type:IO,iterator:mO(CO(e).entries),kind:t})}),"Iterator",(function(){var e=OO(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),n})),KO=function(){cO(this,KO,RO);var e,t,n,r,i,a,o,s,u,c=arguments.length>0?arguments[0]:void 0,l=this,f=[];if(TO(l,{type:RO,entries:f,updateURL:function(){},updateSearchParams:qO}),void 0!==c)if(hO(c))if("function"==typeof(e=bO(c)))for(n=(t=mO(c,e)).next;!(r=n.call(t)).done;){if((o=(a=(i=mO(pO(r.value))).next).call(i)).done||(s=a.call(i)).done||!a.call(i).done)throw TypeError("Expected sequence with length 2");f.push({key:vO(o.value),value:vO(s.value)})}else for(u in c)lO(c,u)&&f.push({key:u,value:vO(c[u])});else BO(f,"string"==typeof c?"?"===c.charAt(0)?c.slice(1):c:vO(c))},VO=KO.prototype;if(aO(VO,{append:function(e,t){zO(arguments.length,2);var n=CO(this);n.entries.push({key:vO(e),value:vO(t)}),n.updateURL()},delete:function(e){zO(arguments.length,1);for(var t=CO(this),n=t.entries,r=vO(e),i=0;i<n.length;)n[i].key===r?n.splice(i,1):i++;t.updateURL()},get:function(e){zO(arguments.length,1);for(var t=CO(this).entries,n=vO(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){zO(arguments.length,1);for(var t=CO(this).entries,n=vO(e),r=[],i=0;i<t.length;i++)t[i].key===n&&r.push(t[i].value);return r},has:function(e){zO(arguments.length,1);for(var t=CO(this).entries,n=vO(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){zO(arguments.length,1);for(var n,r=CO(this),i=r.entries,a=!1,o=vO(e),s=vO(t),u=0;u<i.length;u++)(n=i[u]).key===o&&(a?i.splice(u--,1):(a=!0,n.value=s));a||i.push({key:o,value:s}),r.updateURL()},sort:function(){var e,t,n,r=CO(this),i=r.entries,a=i.slice();for(i.length=0,n=0;n<a.length;n++){for(e=a[n],t=0;t<n;t++)if(i[t].key>e.key){i.splice(t,0,e);break}t===n&&i.push(e)}r.updateURL()},forEach:function(e){for(var t,n=CO(this).entries,r=fO(e,arguments.length>1?arguments[1]:void 0,3),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new WO(this,"keys")},values:function(){return new WO(this,"values")},entries:function(){return new WO(this,"entries")}},{enumerable:!0}),iO(VO,EO,VO.entries),iO(VO,"toString",(function(){for(var e,t=CO(this).entries,n=[],r=0;r<t.length;)e=t[r++],n.push(FO(e.key)+"="+FO(e.value));return n.join("&")}),{enumerable:!0}),oO(KO,RO),tO({global:!0,forced:!rO},{URLSearchParams:KO}),!rO&&"function"==typeof SO){var $O=function(e){if(hO(e)){var t,n=e.body;if(dO(n)===RO)return(t=e.headers?new SO(e.headers):new SO).has("content-type")||t.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),yO(e,{body:gO(0,String(n)),headers:gO(0,t)})}return e};if("function"==typeof kO&&tO({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return kO(e,arguments.length>1?$O(arguments[1]):{})}}),"function"==typeof _O){var GO=function(e){return cO(this,GO,"Request"),new _O(e,arguments.length>1?$O(arguments[1]):{})};xO.constructor=GO,GO.prototype=xO,tO({global:!0,forced:!0},{Request:GO})}}var JO,HO={URLSearchParams:KO,getState:CO},YO=Tn,QO=u,XO=VC,ZO=a,eP=Wn,tP=Je.exports,nP=Eo,rP=te,iP=MR,aP=wl,oP=Cl.codeAt,sP=function(e){var t,n,r=[],i=e.toLowerCase().replace(JC,".").split(".");for(t=0;t<i.length;t++)n=i[t],r.push(GC.test(n)?"xn--"+eO(n):n);return r.join(".")},uP=Er,cP=An,lP=HO,fP=xt,dP=ZO.URL,pP=lP.URLSearchParams,hP=lP.getState,vP=fP.set,yP=fP.getterFor("URL"),gP=Math.floor,mP=Math.pow,bP="Invalid scheme",wP="Invalid host",kP="Invalid port",_P=/[A-Za-z]/,xP=/[\d+-.A-Za-z]/,SP=/\d/,EP=/^0x/i,RP=/^[0-7]+$/,IP=/^\d+$/,TP=/^[\dA-Fa-f]+$/,CP=/[\0\t\n\r #%/:<>?@[\\\]^|]/,OP=/[\0\t\n\r #/:<>?@[\\\]^|]/,PP=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,AP=/[\t\n\r]/g,jP=function(e,t){var n,r,i;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return wP;if(!(n=LP(t.slice(1,-1))))return wP;e.host=n}else if(WP(e)){if(t=sP(t),CP.test(t))return wP;if(null===(n=MP(t)))return wP;e.host=n}else{if(OP.test(t))return wP;for(n="",r=aP(t),i=0;i<r.length;i++)n+=qP(r[i],NP);e.host=n}},MP=function(e){var t,n,r,i,a,o,s,u=e.split(".");if(u.length&&""==u[u.length-1]&&u.pop(),(t=u.length)>4)return e;for(n=[],r=0;r<t;r++){if(""==(i=u[r]))return e;if(a=10,i.length>1&&"0"==i.charAt(0)&&(a=EP.test(i)?16:8,i=i.slice(8==a?1:2)),""===i)o=0;else{if(!(10==a?IP:8==a?RP:TP).test(i))return e;o=parseInt(i,a)}n.push(o)}for(r=0;r<t;r++)if(o=n[r],r==t-1){if(o>=mP(256,5-t))return null}else if(o>255)return null;for(s=n.pop(),r=0;r<n.length;r++)s+=n[r]*mP(256,3-r);return s},LP=function(e){var t,n,r,i,a,o,s,u=[0,0,0,0,0,0,0,0],c=0,l=null,f=0,d=function(){return e.charAt(f)};if(":"==d()){if(":"!=e.charAt(1))return;f+=2,l=++c}for(;d();){if(8==c)return;if(":"!=d()){for(t=n=0;n<4&&TP.test(d());)t=16*t+parseInt(d(),16),f++,n++;if("."==d()){if(0==n)return;if(f-=n,c>6)return;for(r=0;d();){if(i=null,r>0){if(!("."==d()&&r<4))return;f++}if(!SP.test(d()))return;for(;SP.test(d());){if(a=parseInt(d(),10),null===i)i=a;else{if(0==i)return;i=10*i+a}if(i>255)return;f++}u[c]=256*u[c]+i,2!=++r&&4!=r||c++}if(4!=r)return;break}if(":"==d()){if(f++,!d())return}else if(d())return;u[c++]=t}else{if(null!==l)return;f++,l=++c}}if(null!==l)for(o=c-l,c=7;0!=c&&o>0;)s=u[c],u[c--]=u[l+o-1],u[l+--o]=s;else if(8!=c)return;return u},UP=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=gP(e/256);return t.join(".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++i);return i>n&&(t=r,n=i),t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=e[n].toString(16),n<7&&(t+=":")));return"["+t+"]"}return e},NP={},DP=iP({},NP,{" ":1,'"':1,"<":1,">":1,"`":1}),FP=iP({},DP,{"#":1,"?":1,"{":1,"}":1}),BP=iP({},FP,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),qP=function(e,t){var n=oP(e,0);return n>32&&n<127&&!rP(t,e)?e:encodeURIComponent(e)},zP={ftp:21,file:null,http:80,https:443,ws:80,wss:443},WP=function(e){return rP(zP,e.scheme)},KP=function(e){return""!=e.username||""!=e.password},VP=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},$P=function(e,t){var n;return 2==e.length&&_P.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)},GP=function(e){var t;return e.length>1&&$P(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},JP=function(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&$P(t[0],!0)||t.pop()},HP=function(e){return"."===e||"%2e"===e.toLowerCase()},YP={},QP={},XP={},ZP={},eA={},tA={},nA={},rA={},iA={},aA={},oA={},sA={},uA={},cA={},lA={},fA={},dA={},pA={},hA={},vA={},yA={},gA=function(e,t,n,r){var i,a,o,s,u,c=n||YP,l=0,f="",d=!1,p=!1,h=!1;for(n||(e.scheme="",e.username="",e.password="",e.host=null,e.port=null,e.path=[],e.query=null,e.fragment=null,e.cannotBeABaseURL=!1,t=t.replace(PP,"")),t=t.replace(AP,""),i=aP(t);l<=i.length;){switch(a=i[l],c){case YP:if(!a||!_P.test(a)){if(n)return bP;c=XP;continue}f+=a.toLowerCase(),c=QP;break;case QP:if(a&&(xP.test(a)||"+"==a||"-"==a||"."==a))f+=a.toLowerCase();else{if(":"!=a){if(n)return bP;f="",c=XP,l=0;continue}if(n&&(WP(e)!=rP(zP,f)||"file"==f&&(KP(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=f,n)return void(WP(e)&&zP[e.scheme]==e.port&&(e.port=null));f="","file"==e.scheme?c=cA:WP(e)&&r&&r.scheme==e.scheme?c=ZP:WP(e)?c=rA:"/"==i[l+1]?(c=eA,l++):(e.cannotBeABaseURL=!0,e.path.push(""),c=hA)}break;case XP:if(!r||r.cannotBeABaseURL&&"#"!=a)return bP;if(r.cannotBeABaseURL&&"#"==a){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,c=yA;break}c="file"==r.scheme?cA:tA;continue;case ZP:if("/"!=a||"/"!=i[l+1]){c=tA;continue}c=iA,l++;break;case eA:if("/"==a){c=aA;break}c=pA;continue;case tA:if(e.scheme=r.scheme,a==JO)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query;else if("/"==a||"\\"==a&&WP(e))c=nA;else if("?"==a)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query="",c=vA;else{if("#"!=a){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.path.pop(),c=pA;continue}e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query,e.fragment="",c=yA}break;case nA:if(!WP(e)||"/"!=a&&"\\"!=a){if("/"!=a){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,c=pA;continue}c=aA}else c=iA;break;case rA:if(c=iA,"/"!=a||"/"!=f.charAt(l+1))continue;l++;break;case iA:if("/"!=a&&"\\"!=a){c=aA;continue}break;case aA:if("@"==a){d&&(f="%40"+f),d=!0,o=aP(f);for(var v=0;v<o.length;v++){var y=o[v];if(":"!=y||h){var g=qP(y,BP);h?e.password+=g:e.username+=g}else h=!0}f=""}else if(a==JO||"/"==a||"?"==a||"#"==a||"\\"==a&&WP(e)){if(d&&""==f)return"Invalid authority";l-=aP(f).length+1,f="",c=oA}else f+=a;break;case oA:case sA:if(n&&"file"==e.scheme){c=fA;continue}if(":"!=a||p){if(a==JO||"/"==a||"?"==a||"#"==a||"\\"==a&&WP(e)){if(WP(e)&&""==f)return wP;if(n&&""==f&&(KP(e)||null!==e.port))return;if(s=jP(e,f))return s;if(f="",c=dA,n)return;continue}"["==a?p=!0:"]"==a&&(p=!1),f+=a}else{if(""==f)return wP;if(s=jP(e,f))return s;if(f="",c=uA,n==sA)return}break;case uA:if(!SP.test(a)){if(a==JO||"/"==a||"?"==a||"#"==a||"\\"==a&&WP(e)||n){if(""!=f){var m=parseInt(f,10);if(m>65535)return kP;e.port=WP(e)&&m===zP[e.scheme]?null:m,f=""}if(n)return;c=dA;continue}return kP}f+=a;break;case cA:if(e.scheme="file","/"==a||"\\"==a)c=lA;else{if(!r||"file"!=r.scheme){c=pA;continue}if(a==JO)e.host=r.host,e.path=r.path.slice(),e.query=r.query;else if("?"==a)e.host=r.host,e.path=r.path.slice(),e.query="",c=vA;else{if("#"!=a){GP(i.slice(l).join(""))||(e.host=r.host,e.path=r.path.slice(),JP(e)),c=pA;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",c=yA}}break;case lA:if("/"==a||"\\"==a){c=fA;break}r&&"file"==r.scheme&&!GP(i.slice(l).join(""))&&($P(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),c=pA;continue;case fA:if(a==JO||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&$P(f))c=pA;else if(""==f){if(e.host="",n)return;c=dA}else{if(s=jP(e,f))return s;if("localhost"==e.host&&(e.host=""),n)return;f="",c=dA}continue}f+=a;break;case dA:if(WP(e)){if(c=pA,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=JO&&(c=pA,"/"!=a))continue}else e.fragment="",c=yA;else e.query="",c=vA;break;case pA:if(a==JO||"/"==a||"\\"==a&&WP(e)||!n&&("?"==a||"#"==a)){if(".."===(u=(u=f).toLowerCase())||"%2e."===u||".%2e"===u||"%2e%2e"===u?(JP(e),"/"==a||"\\"==a&&WP(e)||e.path.push("")):HP(f)?"/"==a||"\\"==a&&WP(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&$P(f)&&(e.host&&(e.host=""),f=f.charAt(0)+":"),e.path.push(f)),f="","file"==e.scheme&&(a==JO||"?"==a||"#"==a))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==a?(e.query="",c=vA):"#"==a&&(e.fragment="",c=yA)}else f+=qP(a,FP);break;case hA:"?"==a?(e.query="",c=vA):"#"==a?(e.fragment="",c=yA):a!=JO&&(e.path[0]+=qP(a,NP));break;case vA:n||"#"!=a?a!=JO&&("'"==a&&WP(e)?e.query+="%27":e.query+="#"==a?"%23":qP(a,NP)):(e.fragment="",c=yA);break;case yA:a!=JO&&(e.fragment+=qP(a,DP))}l++}},mA=function(e){var t,n,r=nP(this,mA,"URL"),i=arguments.length>1?arguments[1]:void 0,a=uP(e),o=vP(r,{type:"URL"});if(void 0!==i)if(i instanceof mA)t=yP(i);else if(n=gA(t={},uP(i)))throw TypeError(n);if(n=gA(o,a,null,t))throw TypeError(n);var s=o.searchParams=new pP,u=hP(s);u.updateSearchParams(o.query),u.updateURL=function(){o.query=String(s)||null},QO||(r.href=wA.call(r),r.origin=kA.call(r),r.protocol=_A.call(r),r.username=xA.call(r),r.password=SA.call(r),r.host=EA.call(r),r.hostname=RA.call(r),r.port=IA.call(r),r.pathname=TA.call(r),r.search=CA.call(r),r.searchParams=OA.call(r),r.hash=PA.call(r))},bA=mA.prototype,wA=function(){var e=yP(this),t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,o=e.path,s=e.query,u=e.fragment,c=t+":";return null!==i?(c+="//",KP(e)&&(c+=n+(r?":"+r:"")+"@"),c+=UP(i),null!==a&&(c+=":"+a)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?o[0]:o.length?"/"+o.join("/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},kA=function(){var e=yP(this),t=e.scheme,n=e.port;if("blob"==t)try{return new mA(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&WP(e)?t+"://"+UP(e.host)+(null!==n?":"+n:""):"null"},_A=function(){return yP(this).scheme+":"},xA=function(){return yP(this).username},SA=function(){return yP(this).password},EA=function(){var e=yP(this),t=e.host,n=e.port;return null===t?"":null===n?UP(t):UP(t)+":"+n},RA=function(){var e=yP(this).host;return null===e?"":UP(e)},IA=function(){var e=yP(this).port;return null===e?"":String(e)},TA=function(){var e=yP(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},CA=function(){var e=yP(this).query;return e?"?"+e:""},OA=function(){return yP(this).searchParams},PA=function(){var e=yP(this).fragment;return e?"#"+e:""},AA=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(QO&&eP(bA,{href:AA(wA,(function(e){var t=yP(this),n=uP(e),r=gA(t,n);if(r)throw TypeError(r);hP(t.searchParams).updateSearchParams(t.query)})),origin:AA(kA),protocol:AA(_A,(function(e){var t=yP(this);gA(t,uP(e)+":",YP)})),username:AA(xA,(function(e){var t=yP(this),n=aP(uP(e));if(!VP(t)){t.username="";for(var r=0;r<n.length;r++)t.username+=qP(n[r],BP)}})),password:AA(SA,(function(e){var t=yP(this),n=aP(uP(e));if(!VP(t)){t.password="";for(var r=0;r<n.length;r++)t.password+=qP(n[r],BP)}})),host:AA(EA,(function(e){var t=yP(this);t.cannotBeABaseURL||gA(t,uP(e),oA)})),hostname:AA(RA,(function(e){var t=yP(this);t.cannotBeABaseURL||gA(t,uP(e),sA)})),port:AA(IA,(function(e){var t=yP(this);VP(t)||(""==(e=uP(e))?t.port=null:gA(t,e,uA))})),pathname:AA(TA,(function(e){var t=yP(this);t.cannotBeABaseURL||(t.path=[],gA(t,uP(e),dA))})),search:AA(CA,(function(e){var t=yP(this);""==(e=uP(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",gA(t,e,vA)),hP(t.searchParams).updateSearchParams(t.query)})),searchParams:AA(OA),hash:AA(PA,(function(e){var t=yP(this);""!=(e=uP(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",gA(t,e,yA)):t.fragment=null}))}),tP(bA,"toJSON",(function(){return wA.call(this)}),{enumerable:!0}),tP(bA,"toString",(function(){return wA.call(this)}),{enumerable:!0}),dP){var jA=dP.createObjectURL,MA=dP.revokeObjectURL;jA&&tP(mA,"createObjectURL",(function(e){return jA.apply(dP,arguments)})),MA&&tP(mA,"revokeObjectURL",(function(e){return MA.apply(dP,arguments)}))}cP(mA,"URL"),YO({global:!0,forced:!XO,sham:!QO},{URL:mA}),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=hv.exports,r=pv.exports,i=vv.exports,a=gv.exports,o=bv.exports,s=HE.exports,u=Oy.exports,c=qm.exports,l=zm,f=wh.exports,d=Sf.exports,p=tm,h=bh;function v(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function y(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var g=v(n),m=v(r),b=v(i),w=v(a),k=v(o),_=v(s),x=v(u),S=v(c),E=v(l),R=v(f),I=y(d),T={exports:{}},C="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(C){var O=new Uint8Array(16);T.exports=function(){return C(O),O}}else{var P=new Array(16);T.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),P[t]=e>>>((3&t)<<3)&255;return P}}for(var A=[],j=0;j<256;++j)A[j]=(j+256).toString(16).substr(1);var M,L,U=function(e,t){var n=t||0,r=A;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")},N=T.exports,D=U,F=0,B=0;var q=function(e,t,n){var r=t&&n||0,i=t||[],a=(e=e||{}).node||M,o=void 0!==e.clockseq?e.clockseq:L;if(null==a||null==o){var s=N();null==a&&(a=M=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==o&&(o=L=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:B+1,l=u-F+(c-B)/1e4;if(l<0&&void 0===e.clockseq&&(o=o+1&16383),(l<0||u>F)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");F=u,B=c,L=o;var f=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var d=u/4294967296*1e4&268435455;i[r++]=d>>>8&255,i[r++]=255&d,i[r++]=d>>>24&15|16,i[r++]=d>>>16&255,i[r++]=o>>>8|128,i[r++]=255&o;for(var p=0;p<6;++p)i[r+p]=a[p];return t||D(i)},z=T.exports,W=U;var K=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||z)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var a=0;a<16;++a)t[r+a]=i[a];return t||W(i)},V=q,$=K,G=$;G.v1=V,G.v4=$;var J=G;function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=k.default(e);if(t){var i=k.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return w.default(this,n)}}var Y=function(e){b.default(n,e);var t=H(n);function n(e){var r;g.default(this,n);var i,a=J.v4();return(r=t.call(this,(function(t,r){return i=r,e((function(e){n.cancellationMap.delete(a),t(e)}),(function(e){n.cancellationMap.delete(a),r(e)}),(function(e){n.cancellationMap.set(a,e)}))}))).id=a,r.rejectPromise=i,r}return m.default(n,[{key:"cancel",value:function(){var e=n.cancellationMap.get(this.id);return null==e||e(),this.rejectPromise&&(this.catch((function(){})),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),n}(_.default(Promise));function Q(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":R.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function X(e,t){if("object"===("undefined"==typeof Reflect?"undefined":R.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function Z(e,t){return["".concat((new Date).toISOString()," MCS Client ").concat(e,":")].concat(Array.from(t))}x.default(Y,"cancellationMap",new Map);var ee=function(){function e(t){g.default(this,e),x.default(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return m.default(e,[{key:"setLevel",value:function(e){I.setLevel(e)}},{key:"trace",value:function(){if(I.getLevel()==I.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.debug.apply(null,Z(this.prefix+"T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.debug.apply(null,Z(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.info.apply(null,Z(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.warn.apply(null,Z(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.error.apply(null,Z(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){I.setLevel(e)}},{key:"trace",value:function(){if(I.getLevel()==I.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.debug.apply(null,Z("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.debug.apply(null,Z("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.info.apply(null,Z("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.warn.apply(null,Z("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.error.apply(null,Z("E",t))}}]),e}(),te=function(e,t){return"".concat((n=e,n.startsWith("http")?"":function(e){return"https://mcs.".concat(null!=e?e:"us1",".twilio.com")}(t))).concat(e);var n},ne=function(){function e(t,n,r,i){var a,o,s,u,c,l;g.default(this,e);var f=null!==(a=null!==(o=i.MCS)&&void 0!==o?o:i)&&void 0!==a?a:{};this.region=null!==(s=null!==(u=f.region)&&void 0!==u?u:i.region)&&void 0!==s?s:"us1",this.mediaUrl=te(n,this.region),this.mediaSetUrl=r?te(r):"".concat(this.mediaUrl,"Set"),this.token=t,this.retryWhenThrottledOverride=null===(c=f.retryWhenThrottledOverride)||void 0===c||c,this.backoffConfigOverride=null!==(l=f.backoffConfigOverride)&&void 0!==l?l:e.backoffConfigDefault}return m.default(e,[{key:"updateToken",value:function(e){this.token=e}}],[{key:"backoffConfigDefault",get:function(){return{min:1e3,max:4e3,maxAttemptsCount:3}}},{key:"retryWhenThrottledDefault",get:function(){return true}}]),e}(),Media=function(){function Media(e,t,n){g.default(this,Media),this.config=e,this.network=t,this._update(n)}return m.default(Media,[{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 e=this;return new Y(function(){var t=S.default(E.default.mark((function t(n,r,i){var a,o;return E.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.network.get("".concat(e.config.mediaUrl,"/").concat(e.sid)),i((function(){return a.cancel()})),t.prev=2,t.next=5,a;case 5:o=t.sent,e._update(o.body),n(e.state.contentDirectUrl),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),r(t.t0);case 13:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_update",value:function(e){var t,n,r,i;this.state={sid:e.sid,serviceSid:e.service_sid,channelSid:e.channel_sid,messageSid:e.message_sid,dateCreated:e.date_created?new Date(e.date_created):null,dateUploadUpdated:e.date_upload_updated?new Date(e.date_upload_updated):null,dateUpdated:e.date_updated?new Date(e.date_updated):null,size:e.size,contentType:e.content_type,author:e.author,url:e.url,contentUrl:e.links.content,contentDirectUrl:null!==(t=e.links.content_direct_temporary)&&void 0!==t?t:null,filename:null!==(n=e.filename)&&void 0!==n?n:null,category:null!==(r=e.category)&&void 0!==r?r:"media",isMultipartUpstream:null!==(i=e.is_multipart_upstream)&&void 0!==i&&i}}},{key:"_state",value:function(){var e;return{sid:this.state.sid,category:this.state.category,filename:null!==(e=this.state.filename)&&void 0!==e?e:null,contentType:this.state.contentType,size:this.state.size}}}]),Media}();function re(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=k.default(e);if(t){var i=k.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return w.default(this,n)}}var ie=function(e){b.default(n,e);var t=re(n);function n(e,r,i,a,o){var s;return g.default(this,n),(s=t.call(this,e)).code=r,s.body=i,s.status=a,s.headers=o,s}return m.default(n)}(_.default(Error)),ae=t.XMLHttpRequest||{};var oe,se=function(){function e(){g.default(this,e)}return m.default(e,[{key:"get",value:function(t,n){return e.request("GET",t,n)}},{key:"post",value:function(t,n,r){return e.request("POST",t,n,r)}}],[{key:"request",value:function(e,t,n,r){return new Y((function(i,a,o){var s=new ae,u=!1;for(var c in o((function(){s.abort(),u=!0})),s.open(e,t,!0),s.onreadystatechange=function(){if(4===s.readyState&&!u){var e,t=(e=s.getAllResponseHeaders())?e.split("\r\n").map((function(e){return e.split(": ")})).filter((function(e){return 2===e.length&&e[1].length>0})).reduce((function(e,t){return e[t[0]]=t[1],e}),{}):{},n=function(e){var t=e.getResponseHeader("Content-Type");if(!t||0!==t.indexOf("application/json")||0===e.responseText.length)return e.responseText;try{return JSON.parse(e.responseText)}catch(t){return e.responseText}}(s);if(200<=s.status&&s.status<300)i({status:s.status,headers:t,body:n});else{var r,o,c=null!==(r=s.statusText)&&void 0!==r?r:"NONE";if("string"==typeof n)if(n&&1===n.split("\n",2).length)o=n;else{var l,f=null===(l=n.replace(/<.*?>/g,"").split(/\r\n/g).filter((function(e){return e.length}))[0])||void 0===l?void 0:l.split(" ");o=(null==f?void 0:f.length)>2?null==f?void 0:f.slice(1).join(" "):""}else o=JSON.stringify(n);var d="".concat(s.status,": [").concat(c,"] ").concat(o);a(new ie(d,s.status,n,c,t))}}},n)s.setRequestHeader(c,n[c]),"Content-Type"===c&&"application/json"===n[c]&&(r=JSON.stringify(r));s.send(r)}))}}]),e}(),ue=ee.scope("Network"),ce=function(){function e(t,n){g.default(this,e),this.config=t,this.transport=n}return m.default(e,[{key:"backoffConfig",value:function(){return Object.assign(ne.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var e,t;return null!==(e=null!==(t=this.config.retryWhenThrottledOverride)&&void 0!==t?t:ne.retryWhenThrottledDefault)&&void 0!==e&&e}},{key:"executeWithRetry",value:function(e,t){var n=this;return new Y(function(){var r=S.default(E.default.mark((function r(i,a,o){var s,u;return E.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:s=new p.Retrier(n.backoffConfig()),u=[502,503,504],t&&u.push(429),o((function(){s.cancel(),s.removeAllListeners()})),s.on("attempt",S.default(E.default.mark((function t(){var n,r;return E.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n=e(),o((function(){n.cancel(),s.cancel(),s.removeAllListeners()})),t.next=5,n;case 5:r=t.sent,s.succeeded(r),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(0),u.indexOf(t.t0.status)>-1||"Twilsock disconnected"===t.t0.message?s.failed(t.t0):(s.removeAllListeners(),s.cancel(),a(t.t0));case 12:case"end":return t.stop()}}),t,null,[[0,9]])})))),s.on("succeeded",(function(e){i(e)})),s.on("cancelled",(function(e){return a(e)})),s.on("failed",(function(e){return a(e)})),s.start();case 9:case"end":return r.stop()}}),r)})));return function(e,t,n){return r.apply(this,arguments)}}())}},{key:"get",value:function(e){var t=this;return new Y(function(){var n=S.default(E.default.mark((function n(r,i,a){var o,s,u;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={"X-Twilio-Token":t.config.token},s=t.executeWithRetry((function(){return t.transport.get(e,o)}),t.retryWhenThrottled()),ue.trace("sending GET request to ",e," headers ",o),a((function(){return s.cancel()})),n.prev=4,n.next=7,s;case 7:u=n.sent,ue.trace("response",u),r(u),n.next=16;break;case 12:n.prev=12,n.t0=n.catch(4),ue.debug("get() error ".concat(n.t0)),i(n.t0);case 16:case"end":return n.stop()}}),n,null,[[4,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"post",value:function(e,n,r,i,a){var o=this,s={"X-Twilio-Token":this.config.token};"undefined"!=typeof FormData&&r instanceof FormData||!i||Object.assign(s,{"Content-Type":i});var u=new URL(e);return n&&u.searchParams.append("Category",n),a&&u.searchParams.append("Filename",a),new Y(function(){var n=S.default(E.default.mark((function n(i,a,c){var l,f;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return l=o.transport.post(u.href,s,r),c((function(){return l.cancel()})),ue.trace("sending POST request to ".concat(e," with headers ").concat(s)),n.prev=3,n.next=6,l;case 6:f=n.sent,n.next=17;break;case 9:if(n.prev=9,n.t0=n.catch(3),!(void 0===t.XMLHttpRequest&&r instanceof FormData)){n.next=14;break}return a(new TypeError("Posting FormData supported only with browser engine's FormData")),n.abrupt("return");case 14:return ue.debug("post() error ".concat(n.t0)),a(n.t0),n.abrupt("return");case 17:ue.trace("response",f),i(f);case 19:case"end":return n.stop()}}),n,null,[[3,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}}]),e}(),le=ee.scope("");e.default=(oe=function(){function Client(e,t,n){var r,i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};g.default(this,Client),this.options=a,this.options.logLevel=null!==(r=this.options.logLevel)&&void 0!==r?r:"silent",this.config=new ne(e,t,n,this.options),le.setLevel(this.options.logLevel),this.options.transport=null!==(i=this.options.transport)&&void 0!==i?i:new se,this.transport=this.options.transport,this.network=new ce(this.config,this.transport)}return m.default(Client,[{key:"updateToken",value:function(e){le.info("updateToken"),this.config.updateToken(e)}},{key:"get",value:function(e){var t=this;return new Y(function(){var n=S.default(E.default.mark((function n(r,i,a){var o,s;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=t.network.get("".concat(t.config.mediaUrl,"/").concat(e)),a((function(){return o.cancel()})),n.prev=2,n.next=5,o;case 5:s=n.sent,r(new Media(t.config,t.network,s.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"post",value:function(e,t,n,r){var i=this;return new Y(function(){var a=S.default(E.default.mark((function a(o,s,u){var c,l;return E.default.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return c=i.network.post(i.config.mediaUrl,null!=n?n:"media",t,e,r),u((function(){return c.cancel()})),a.prev=2,a.next=5,c;case 5:l=a.sent,o(new Media(i.config,i.network,l.body)),a.next=12;break;case 9:a.prev=9,a.t0=a.catch(2),s(a.t0);case 12:case"end":return a.stop()}}),a,null,[[2,9]])})));return function(e,t,n){return a.apply(this,arguments)}}())}},{key:"postFormData",value:function(e,t){var n=this;return new Y(function(){var r=S.default(E.default.mark((function r(i,a,o){var s,u;return E.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return s=n.network.post(n.config.mediaUrl,null!=t?t:"media",e),o((function(){return s.cancel()})),r.prev=2,r.next=5,s;case 5:u=r.sent,i(new Media(n.config,n.network,u.body)),r.next=12;break;case 9:r.prev=9,r.t0=r.catch(2),a(r.t0);case 12:case"end":return r.stop()}}),r,null,[[2,9]])})));return function(e,t,n){return r.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(e){var t=this;return new Y(function(){var n=S.default(E.default.mark((function n(r,i,a){var o,s,u,c;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={command:"get",list:e.map((function(e){return{media_sid:e}}))},s=t.network.post("".concat(t.config.mediaSetUrl),null,o,"application/json"),a((function(){return s.cancel()})),n.prev=3,n.next=6,s;case 6:u=n.sent,c=u.body.map((function(e){if(200===e.code)return new Media(t.config,t.network,e.media_record);i("Failed to obtain detailed information about Media items (failed SID ".concat(e.media_record.sid,")"))})),r(c),n.next=14;break;case 11:n.prev=11,n.t0=n.catch(3),i(n.t0);case 14:case"end":return n.stop()}}),n,null,[[3,11]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(e){var t=this;return new Y(function(){var n=S.default(E.default.mark((function n(r,i,a){var o,s,u,c;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={command:"get",list:e.map((function(e){return{media_sid:e}}))},s=t.network.post("".concat(t.config.mediaSetUrl),null,o,"application/json"),a((function(){return s.cancel()})),n.prev=3,n.next=6,s;case 6:u=n.sent,c=new Map,u.body.forEach((function(e){200===e.code?c.set(e.media_record.sid,e.media_record.links.content_direct_temporary):i("Failed to obtain detailed information about Media items (failed SID ".concat(e.media_record.sid,")"))})),r(c),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(3),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[3,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}}]),Client}(),x.default(oe,"version","0.7.0-rc.2"),oe),Q([h.validateTypes(h.nonEmptyString),X("design:type",Function),X("design:paramtypes",[String]),X("design:returntype",void 0)],e.default.prototype,"updateToken",null),Q([h.validateTypesAsync(h.nonEmptyString),X("design:type",Function),X("design:paramtypes",[String]),X("design:returntype",Y)],e.default.prototype,"get",null),e.default=Q([h.validateConstructorTypes(h.nonEmptyString,h.nonEmptyString,[h.nonEmptyString,h.literal(null)],[h.pureObject,"undefined"]),X("design:paramtypes",[String,String,Object,Object])],e.default),e.CancellablePromise=Y,e.Client=e.default,e.McsClient=e.default,e.McsMedia=Media,e.Media=Media}(TC);var LA=So,UA="ArrayBuffer",NA=r_.ArrayBuffer;function DA(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}Tn({global:!0,forced:a.ArrayBuffer!==NA},{ArrayBuffer:NA}),LA(UA);var FA=Cf.scope("Participant"),Participant=function(e){Oa(Participant,e);var t,n,r,i=DA(Participant);function Participant(e,t,n,r,a){var o,s,u;if(Na(this,Participant),(u=i.call(this)).conversation=n,u.links=r,u.services=a,u.state={attributes:yh(e.attributes,"Retrieved malformed attributes from the server for participant: "+t,FA),dateCreated:e.dateCreated?vh(e.dateCreated):null,dateUpdated:e.dateCreated?vh(e.dateUpdated):null,sid:t,typingTimeout:null,isTyping:!1,identity:e.identity,roleSid:null!==(o=e.roleSid)&&void 0!==o?o:"",lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,lastReadTimestamp:e.lastConsumptionTimestamp?vh(e.lastConsumptionTimestamp):null,type:e.type||"chat",userInfo:e.userInfo,bindings:null!==(s=e.bindings)&&void 0!==s?s:{}},!e.identity&&!e.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return u}return Ua(Participant,[{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 e;return null!==(e=this.state.bindings)&&void 0!==e?e:{}}},{key:"_startTyping",value:function(e){var t=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit(Participant.typingStarted,this),this.conversation.emit(Conversation.typingStarted,this),this.state.typingTimeout=Number(setTimeout((function(){return t._endTyping()}),e)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit(Participant.typingEnded,this),this.conversation.emit(Conversation.typingEnded,this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(e){var t=[],n=yh(e.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,FA);e.attributes&&!mh(this.state.attributes,n)&&(this.state.attributes=n,t.push("attributes"));var r=vh(e.dateUpdated);e.dateUpdated&&(null==r?void 0:r.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=r,t.push("dateUpdated"));var i=vh(e.dateCreated);if(e.dateCreated&&(null==i?void 0:i.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=i,t.push("dateCreated")),e.roleSid&&this.state.roleSid!==e.roleSid&&(this.state.roleSid=e.roleSid,t.push("roleSid")),!Number.isInteger(e.lastConsumedMessageIndex)&&null!==e.lastConsumedMessageIndex||this.state.lastReadMessageIndex===e.lastConsumedMessageIndex||(this.state.lastReadMessageIndex=e.lastConsumedMessageIndex,t.push("lastReadMessageIndex")),e.lastConsumptionTimestamp){var a=new Date(e.lastConsumptionTimestamp);this.state.lastReadTimestamp&&this.state.lastReadTimestamp.getTime()===a.getTime()||(this.state.lastReadTimestamp=a,t.push("lastReadTimestamp"))}return e.bindings&&!mh(this.state.bindings,e.bindings)&&(this.state.bindings=e.bindings,t.push("bindings")),t.length>0&&this.emit(Participant.updated,{participant:this,updateReasons:t}),this}},{key:"getUser",value:(r=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("chat"==this.type){e.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return e.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"remove",value:(n=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateAttributes",value:(t=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(t)});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),Participant}(cg);function BA(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}Ma(Participant,"typingStarted","typingStarted"),Ma(Participant,"typingEnded","typingEnded"),Ma(Participant,"updated","updated"),$c([wy(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],Participant.prototype,"updateAttributes",null);var qA=Cf.scope("Participants"),zA=function(e){Oa(l,e);var t,n,r,i,a,o,s,u,c=BA(l);function l(e,t,n,r){var i;return Na(this,l),Ma(Ta(i=c.call(this)),"rosterEntityPromise",null),i.conversation=e,i.participants=t,i.links=n,i.services=r,i}return Ua(l,[{key:"unsubscribe",value:(u=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.rosterEntityPromise){e.next=6;break}return e.next=3,this.rosterEntityPromise;case 3:e.sent.close(),this.rosterEntityPromise=null;case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"subscribe",value:function(e){var t=this,n="string"==typeof e?this.services.syncClient.map({id:e,mode:"open_existing"}):Promise.resolve(e);return this.rosterEntityPromise=this.rosterEntityPromise||n.then((function(e){e.on(RC.itemAdded,(function(e){qA.debug(t.conversation.sid+" itemAdded: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).then((function(e){t.emit(Conversation.participantJoined,e)}))})),e.on(RC.itemRemoved,(function(e){qA.debug(t.conversation.sid+" itemRemoved: "+e.key);var n=e.key;if(t.participants.has(n)){var r=t.participants.get(n);t.participants.delete(n),r&&t.emit(Conversation.participantLeft,r)}})),e.on(RC.itemUpdated,(function(e){qA.debug(t.conversation.sid+" itemUpdated: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).catch((function(e){return qA.error(e)}))}));var n=[];return e.getItems().then((function e(r){return r.items.forEach((function(e){n.push(t.upsertParticipant(e.key,e.data))})),r.hasNextPage?r.nextPage().then(e):null})).then((function(){return Promise.all(n)})).then((function(){return e}))})).catch((function(e){throw t.rosterEntityPromise=null,"disconnected"!=t.services.syncClient.connectionState&&qA.error("Failed to get roster object for conversation",t.conversation.sid,e),qA.debug("ERROR: Failed to get roster object for conversation",t.conversation.sid,e),e}))}},{key:"upsertParticipantFromResponse",value:(s=Ia(Kc.mark((function e(t){var n,r,i,a,o,s,u,c;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.sid,i=t.attributes,a=t.date_created,o=t.date_updated,s=t.identity,u=t.role_sid,c=t.messaging_binding,e.next=3,this.upsertParticipant(r,{attributes:i,dateCreated:new Date(a),dateUpdated:new Date(o),identity:s,roleSid:u,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:null!==(n=null==c?void 0:c.type)&&void 0!==n?n:"chat"});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"upsertParticipant",value:(o=Ia(Kc.mark((function e(t,n){var r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.participants.get(t))){e.next=3;break}return e.abrupt("return",r._update(n));case 3:return i={self:"".concat(this.links.participants,"/").concat(t)},r=new Participant(n,t,this.conversation,i,this.services),this.participants.set(t,r),r.on(Participant.updated,(function(e){return a.emit(Conversation.participantUpdated,e)})),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getParticipants",value:(a=Ia(Kc.mark((function e(){var t=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){var e=[];return t.participants.forEach((function(t){return e.push(t)})),e})):[]);case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getParticipantBySid",value:(i=Ia(Kc.mark((function e(t){var n=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){var e=n.participants.get(t);if(!e)throw new Error("Participant with SID "+t+" was not found");return e})):null);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(r=Ia(Kc.mark((function e(t){var n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null,e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){if(r.participants.forEach((function(e){e.identity===t&&(n=e)})),!n)throw new Error("Participant with identity "+t+" was not found");return n})):null);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"add",value:(n=Ia(Kc.mark((function e(t,n){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:t,attributes:void 0!==n?JSON.stringify(n):void 0});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"addNonChatParticipant",value:(t=Ia(Kc.mark((function e(t,n){var r,i,a,o,s=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=s.length>2&&void 0!==s[2]?s[2]:{},o=s.length>3&&void 0!==s[3]?s[3]:{},e.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:void 0!==a?JSON.stringify(a):void 0,messaging_binding:{address:n,proxy_address:t,name:null==o||null===(r=o.email)||void 0===r?void 0:r.name,level:null==o||null===(i=o.email)||void 0===i?void 0:i.level}});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"remove",value:function(e){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(encodeURIComponent(e)))}}]),l}(cg),WA=OC,KA=k,VA=Er;Tn({target:"String",proto:!0,forced:!AC("includes")},{includes:function(e){return!!~VA(KA(this)).indexOf(VA(WA(e)),arguments.length>1?arguments[1]:void 0)}});var $A=vo,GA=pg.exports.getWeakData,JA=Fe,HA=E,YA=Eo,QA=Jo,XA=te,ZA=xt.set,ej=xt.getterFor,tj=Xr.find,nj=Xr.findIndex,rj=0,ij=function(e){return e.frozen||(e.frozen=new aj)},aj=function(){this.entries=[]},oj=function(e,t){return tj(e.entries,(function(e){return e[0]===t}))};aj.prototype={get:function(e){var t=oj(this,e);if(t)return t[1]},has:function(e){return!!oj(this,e)},set:function(e,t){var n=oj(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=nj(this.entries,(function(t){return t[0]===e}));return~t&&this.entries.splice(t,1),!!~t}};var sj={getConstructor:function(e,t,n,r){var i=e((function(e,a){YA(e,i,t),ZA(e,{type:t,id:rj++,frozen:void 0}),null!=a&&QA(a,e[r],{that:e,AS_ENTRIES:n})})),a=ej(t),o=function(e,t,n){var r=a(e),i=GA(JA(t),!0);return!0===i?ij(r).set(t,n):i[r.id]=n,e};return $A(i.prototype,{delete:function(e){var t=a(this);if(!HA(e))return!1;var n=GA(e);return!0===n?ij(t).delete(e):n&&XA(n,t.id)&&delete n[t.id]},has:function(e){var t=a(this);if(!HA(e))return!1;var n=GA(e);return!0===n?ij(t).has(e):n&&XA(n,t.id)}}),$A(i.prototype,n?{get:function(e){var t=a(this);if(HA(e)){var n=GA(e);return!0===n?ij(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return o(this,e,t)}}:{add:function(e){return o(this,e,!0)}}),i}};qg("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),sj);var Media=function(){function Media(e,t){var n;Na(this,Media),Ma(this,"mcsMedia",null),this.services=t,e instanceof TC.McsMedia&&(this.mcsMedia=e),this.state={sid:e.sid,category:e.category,filename:null!==(n=e.filename)&&void 0!==n?n:null,contentType:e.contentType,size:e.size}}return Ua(Media,[{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 e=this;return new TC.CancellablePromise(function(){var t=Ia(Kc.mark((function t(n,r,i){var a,o,s,u;return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=e.mcsMedia?void 0:e._fetchMcsMedia(),s=null===(a=e.mcsMedia)||void 0===a?void 0:a.getContentUrl(),i((function(){o&&o.cancel(),s&&s.cancel()})),t.prev=3,s){t.next=9;break}return t.next=7,o;case 7:u=t.sent,s=null==u?void 0:u.getContentUrl();case 9:if(t.t0=n,!s){t.next=16;break}return t.next=13,s;case 13:t.t1=t.sent,t.next=17;break;case 16:t.t1=null;case 17:t.t2=t.t1,(0,t.t0)(t.t2),t.next=24;break;case 21:t.prev=21,t.t3=t.catch(3),r(t.t3);case 24:case"end":return t.stop()}}),t,null,[[3,21]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var e=this;return new TC.CancellablePromise(function(){var t=Ia(Kc.mark((function t(n,r,i){var a;return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===e.services.mcsClient&&r(new Error("Media Content Service is unavailable")),a=e.services.mcsClient.get(e.state.sid),i((function(){return a.cancel()})),t.prev=3,t.next=6,a;case 6:e.mcsMedia=t.sent,e.state=e.mcsMedia._state(),n(e.mcsMedia),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(3),r(t.t0);case 14:case"end":return t.stop()}}),t,null,[[3,11]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_state",value:function(){return this.state}}]),Media}(),AggregatedDeliveryReceipt=function(){function AggregatedDeliveryReceipt(e){Na(this,AggregatedDeliveryReceipt),this.state=e}return Ua(AggregatedDeliveryReceipt,[{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(e){this.state=e}},{key:"_isEquals",value:function(e){var t=this.total===e.total,n=this.sent===e.sent,r=this.delivered===e.delivered,i=this.read===e.read,a=this.undelivered===e.undelivered,o=this.failed===e.failed;return t&&n&&r&&i&&a&&o}}]),AggregatedDeliveryReceipt}(),uj=function(){function e(t,n,r,i){Na(this,e),this.state={prevToken:r,nextToken:i,source:n,items:t}}return Ua(e,[{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"))}}]),e}(),DetailedDeliveryReceipt=Ua((function DetailedDeliveryReceipt(e){Na(this,DetailedDeliveryReceipt),this.sid=e.sid,this.messageSid=e.message_sid,this.conversationSid=e.conversation_sid,this.channelMessageSid=e.channel_message_sid,this.participantSid=e.participant_sid,this.status=e.status||"queued",this.errorCode=e.error_code||0,this.dateCreated=e.date_created,this.dateUpdated=e.date_updated})),cj={};function lj(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}Object.defineProperty(cj,"__esModule",{value:!0});var fj=lj(Sf.exports),dj=function(e){var t=fj.default.getLevel();fj.default.setLevel("warn"),fj.default.warn(e),fj.default.setLevel(t)},pj=cj.deprecated=function(e,t,n){return function(r,i,a){if("function"!=typeof a.value&&void 0===(null==a?void 0:a.get))throw new Error("The deprecated decorator can only be applied to methods or getters");if("function"!=typeof a.value){var o=a.get;a.get=function(){return dj("The getter ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),null==o?void 0:o.apply(this)}}else{var s=a.value;a.value=function(){dj("The method ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:"."));for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return s.apply(this,i)}}}},hj=cj.deprecationWarning=dj,vj=function(e){return e.map((function(e){var t,n,r,i,a=JSON.stringify(e);switch(e.type){case"QUICK_REPLY":return{type:"reply",title:e.title,id:null!==(t=e.id)&&void 0!==t?t:"",index:null!==(n=e.index)&&void 0!==n?n:0,rawData:a};case"PHONE_NUMBER":return{type:"phone",title:e.title,phone:null!==(r=e.phone)&&void 0!==r?r:"",rawData:a};case"URL":return{type:"url",title:e.title,url:null!==(i=e.url)&&void 0!==i?i:"",rawData:a};default:return{type:"other",rawData:a}}}))},yj=function(e,t){var n=JSON.stringify(t);switch(e){case"twilio/text":return{type:"text",body:t.body,rawData:n};case"twilio/media":var r=t;return{type:"media",body:r.body,media:r.media,rawData:n};case"twilio/location":var i=t;return{type:"location",longitude:i.longitude,latitude:i.latitude,label:i.label,rawData:n};case"twilio/quick-reply":var a=t;return{type:"quickReply",body:a.body,replies:a.actions,rawData:n};case"twilio/call-to-action":var o=t;return{type:"callToAction",body:o.body,actions:vj(o.actions),rawData:n};case"twilio/list-picker":var s=t;return{type:"listPicker",body:s.body,button:s.button,items:s.items,rawData:n};case"twilio/card":var u,c,l=t;return{type:"card",title:l.title,subtitle:l.subtitle,media:null!==(u=l.media)&&void 0!==u?u:[],actions:vj(null!==(c=l.actions)&&void 0!==c?c:[]),rawData:n};default:return{type:"other",rawData:n}}},ContentTemplateVariable=function(){function ContentTemplateVariable(e,t){Na(this,ContentTemplateVariable),this.name=e,this.value=t}return Ua(ContentTemplateVariable,[{key:"copyWithValue",value:function(e){return new ContentTemplateVariable(this.name,e)}}]),ContentTemplateVariable}(),gj=Ua((function e(t){Na(this,e),this.sid=t.sid,this.friendlyName=t.friendly_name,this.variables=Object.entries(JSON.parse(t.variables)).map((function(e){var t=dg(e,2),n=t[0],r=t[1];return new ContentTemplateVariable(n,r)})),this.variants=function(e){for(var t=new Map,n=0,r=Object.entries(e);n<r.length;n++){var i=dg(r[n],2),a=i[0],o=i[1];t.set(a,yj(a,o))}return t}(t.variants),this.dateCreated=new Date(t.date_created),this.dateUpdated=new Date(t.date_updated)}));function mj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function bj(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mj(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mj(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function wj(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}function kj(e,t){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.add(e)}function _j(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}var xj=Cf.scope("Message"),Sj=t.XMLHttpRequest||{},Ej=new WeakSet,Rj=new WeakSet,Message=function(e){Oa(Message,e);var t,n,r,i,a,o,s,u,c,l=wj(Message);function Message(e,t,n,r,i,a){var o,s,u,c,f,d,p,h;return Na(this,Message),kj(Ta(h=l.call(this)),Rj),kj(Ta(h),Ej),h.conversation=n,h.links=r,h.configuration=i,h.services=a,h.state={sid:t.sid,index:e,author:t.author,subject:t.subject,contentSid:t.contentSid,body:null!==(o=t.text)&&void 0!==o?o:null,timestamp:t.timestamp?new Date(t.timestamp):null,dateUpdated:t.dateUpdated?new Date(t.dateUpdated):null,lastUpdatedBy:null!==(s=t.lastUpdatedBy)&&void 0!==s?s:null,attributes:yh(t.attributes,"Got malformed attributes for the message ".concat(t.sid),xj),type:null!==(u=t.type)&&void 0!==u?u:"text",media:null,medias:null,participantSid:null!==(c=t.memberSid)&&void 0!==c?c:null,aggregatedDeliveryReceipt:t.delivery?new AggregatedDeliveryReceipt(t.delivery):null,hasChannelMetadata:null!==(f=t.channelMetadata)&&void 0!==f&&f},_j(Ta(h),Rj,Tj).call(Ta(h),null!==(d=t.medias)&&void 0!==d?d:null,null!==(p=t.media)&&void 0!==p?p:null),h}return Ua(Message,[{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(e){return this.getMediaByCategories(e)}},{key:"getMediaByCategories",value:function(e){var t;return(null!==(t=this.state.medias)&&void 0!==t?t:[]).filter((function(t){return e.includes(t.category)}))}},{key:"getEmailBody",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!==(e=null===(t=this.getMediaByCategories(["body"]))||void 0===t?void 0:t.filter((function(e){return e.contentType==n})).shift())&&void 0!==e?e:null}},{key:"getEmailHistory",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!==(e=null===(t=this.getMediaByCategories(["history"]))||void 0===t?void 0:t.filter((function(e){return e.contentType==n})).shift())&&void 0!==e?e:null}},{key:"_update",value:function(e){var t,n,r,i,a=this,o=[];!e.text&&"string"!=typeof e.text||e.text===this.state.body||(this.state.body=e.text,o.push("body")),e.subject&&e.subject!==this.state.subject&&(this.state.subject=e.subject,o.push("subject")),e.lastUpdatedBy&&e.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=e.lastUpdatedBy,o.push("lastUpdatedBy")),e.author&&e.author!==this.state.author&&(this.state.author=e.author,o.push("author")),e.dateUpdated&&new Date(e.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(e.dateUpdated),o.push("dateUpdated")),e.timestamp&&new Date(e.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(e.timestamp),o.push("dateCreated"));var s=yh(e.attributes,"Got malformed attributes for the message ".concat(this.sid),xj);mh(this.state.attributes,s)||(this.state.attributes=s,o.push("attributes"));var u,c,l=e.delivery,f=this.state.aggregatedDeliveryReceipt;(!!(l&&l.total&&l.delivered&&l.failed&&l.read&&l.sent&&l.undelivered)&&(f?f._isEquals(l)||(f._update(l),o.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new AggregatedDeliveryReceipt(l),o.push("deliveryReceipt"))),mh((null!==(t=e.medias)&&void 0!==t?t:[]).map((function(e){var t;return null===(t=_j(a,Ej,Ij).call(a,e))||void 0===t?void 0:t._state()})).filter((function(e){return!(null===e)})),(null!==(n=this.state.medias)&&void 0!==n?n:[]).map((function(e){return e._state()})).filter((function(e){return!(null===e)})))&&mh(null===(r=_j(this,Ej,Ij).call(this,e.media))||void 0===r?void 0:r._state(),null===(i=this.state.media)||void 0===i?void 0:i._state()))||(_j(this,Rj,Tj).call(this,null!==(u=e.medias)&&void 0!==u?u:null,null!==(c=e.media)&&void 0!==c?c:null),o.push("media"));o.length>0&&this.emit("updated",{message:this,updateReasons:o})}},{key:"getParticipant",value:(c=Ia(Kc.mark((function e(){var t,n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=null,!this.state.participantSid){e.next=5;break}return e.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch((function(){return xj.debug('Participant with sid "'.concat(r.participantSid,'" not found for message ').concat(r.sid)),null}));case 4:t=e.sent;case 5:if(t||!this.state.author){e.next=9;break}return e.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch((function(){return xj.debug('Participant with identity "'.concat(r.author,'" not found for message ').concat(r.sid)),null}));case 8:t=e.sent;case 9:if(!t){e.next=11;break}return e.abrupt("return",t);case 11:throw n="Participant with ",this.state.participantSid&&(n+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(n+="or "),n+="identity '"+this.state.author+"' "),"Participant with "===n&&(n="Participant "),n+="was not found",new Error(n);case 17:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getDetailedDeliveryReceipts",value:(u=Ia(Kc.mark((function e(){var t,n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:t=e.sent,n=t.items;case 4:if(!t.hasNextPage){e.next=11;break}return e.next=7,t.nextPage();case 7:t=e.sent,n=[].concat(xy(n),xy(t.items)),e.next=4;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"remove",value:(s=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"updateBody",value:(o=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:t});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"updateAttributes",value:(a=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:void 0!==t?JSON.stringify(t):void 0});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"attachTemporaryUrlsFor",value:(i=Ia(Kc.mark((function e(t){var n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=null==t?void 0:t.map((function(e){return e.sid})),!this.services.mcsClient||!n){e.next=7;break}return e.next=4,this.services.mcsClient.mediaSetGet(n);case 4:return e.abrupt("return",e.sent.map((function(e){return new Media(e,r.services)})));case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getTemporaryContentUrlsForMedia",value:function(e){var t=e.map((function(e){return e.sid}));return this.getTemporaryContentUrlsForMediaSids(t)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(e){var t=this;return new TC.CancellablePromise(function(){var n=Ia(Kc.mark((function n(r,i,a){var o,s;return Kc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=t.services.mcsClient.mediaSetGetContentUrls(null!=e?e:[]),t.services.mcsClient&&e){n.next=4;break}return i(new Error("Media Content Service is unavailable")),n.abrupt("return");case 4:return a((function(){o.cancel()})),n.prev=5,n.next=8,o;case 8:s=n.sent,r(s),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[5,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var e,t=this.attachedMedia,n=null!==(e=null==t?void 0:t.map((function(e){return e.sid})))&&void 0!==e?e:[];return this.getTemporaryContentUrlsForMediaSids(n)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:(r=Ia(Kc.mark((function e(t){var n,r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),r=new gh(n).arg("PageToken",null==t?void 0:t.pageToken).arg("PageSize",null==t?void 0:t.pageSize).build(),e.next=4,this.services.network.get(r);case 4:return i=e.sent,e.abrupt("return",new uj(i.body.delivery_receipts.map((function(e){return new DetailedDeliveryReceipt(e)})),(function(e,t){return a._getDetailedDeliveryReceiptsPaginator({pageToken:e,pageSize:t})}),i.body.meta.previous_token,i.body.meta.next_token));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getContentData",value:function(){var e=this;return new TC.CancellablePromise(function(){var t=Ia(Kc.mark((function t(n,r,i){var a,o,s,u,c,l,f,d,p,h;return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==e.state.contentSid){t.next=3;break}return n(null),t.abrupt("return");case 3:if(null!==(a=e.getMediaByCategories(["body"]))){t.next=7;break}return n(null),t.abrupt("return");case 7:if(o="application/x-vnd.com.twilio.rich.",0!==(s=a.filter((function(e){return e.contentType.startsWith(o)}))).length){t.next=12;break}return n(null),t.abrupt("return");case 12:return u=s[0],c=u.getContentTemporaryUrl(),i((function(){c.cancel()})),t.prev=15,t.next=18,c;case 18:l=t.sent,t.next=25;break;case 21:return t.prev=21,t.t0=t.catch(15),r(t.t0),t.abrupt("return");case 25:if(null!==l){t.next=28;break}return n(null),t.abrupt("return");case 28:return f=new Promise((function(e,t){var n,r=!1,a=new Sj;a.open("GET",null!==(n=l)&&void 0!==n?n:"",!0),a.responseType="text",a.onreadystatechange=function(){4!==a.readyState||r||e(a.responseText)},a.onerror=function(){t(a.statusText)},i((function(){r=!0,a.abort(),t(new Error("XHR has been aborted"))})),a.send()})),t.prev=29,t.next=32,f;case 32:p=t.sent,d=JSON.parse(p),t.next=40;break;case 36:return t.prev=36,t.t1=t.catch(29),r(t.t1),t.abrupt("return");case 40:h=u.contentType.replace(o,"").replace(".","/"),n(yj(h,d.data));case 42:case"end":return t.stop()}}),t,null,[[15,21],[29,36]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"getChannelMetadata",value:(n=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state.hasChannelMetadata){e.next=2;break}return e.abrupt("return",null);case 2:return e.next=4,this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid,this.sid);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getMessageRecipients",value:(t=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid,this.sid);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),Message}(cg);function Ij(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e?new Media(t?bj(bj({},e),{},{category:t}):e,this.services):null}function Tj(e,t){var n=this;this.state.media=_j(this,Ej,Ij).call(this,t),this.state.medias=e?e.map((function(e){return _j(n,Ej,Ij).call(n,e)})).filter((function(e){return null!==e})):t&&!e?[_j(this,Ej,Ij).call(this,t,"media")].filter((function(e){return null!==e})):null}function Cj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Oj(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Cj(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cj(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Pj(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Aj(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Aj(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Aj(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function jj(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}Ma(Message,"updated","updated"),$c([pj("getMediaByCategory","getMediaByCategories"),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",Array)],Message.prototype,"getMediaByCategory",null),$c([by([hy,"undefined"]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Media)],Message.prototype,"getEmailBody",null),$c([by([hy,"undefined"]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Media)],Message.prototype,"getEmailHistory",null),$c([wy("string"),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Message.prototype,"updateBody",null),$c([wy(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],Message.prototype,"updateAttributes",null),$c([pj("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",Promise)],Message.prototype,"attachTemporaryUrlsFor",null),$c([wy(py("media",Media)),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",TC.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMedia",null),$c([wy(py("strings","string")),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",TC.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMediaSids",null);var Mj=Cf.scope("Messages"),Lj=function(e){Oa(u,e);var t,n,r,i,a,o,s=jj(u);function u(e,t,n){var r;return Na(this,u),(r=s.call(this)).conversation=e,r.configuration=t,r.services=n,r.messagesByIndex=new Map,r.messagesListPromise=null,r}return Ua(u,[{key:"subscribe",value:(o=Ia(Kc.mark((function e(t){var n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesListPromise){e.next=2;break}return e.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise="string"==typeof t?this.services.syncClient.list({id:t,mode:"open_existing"}):Promise.resolve(t),e.prev=3,e.next=6,this.messagesListPromise;case 6:return(n=e.sent).on("itemAdded",(function(e){Mj.debug("".concat(r.conversation.sid," itemAdded: ").concat(e.item.index));var t={self:"".concat(r.conversation._links.messages,"/").concat(e.item.data.sid),conversation:r.conversation._links.self,messages_receipts:"".concat(r.conversation._links.messages,"/").concat(e.item.data.sid,"/Receipts")},n=new Message(e.item.index,e.item.data,r.conversation,t,r.configuration,r.services);r.messagesByIndex.has(n.index)?Mj.debug("Message arrived, but is already known and ignored",r.conversation.sid,n.index):(r.messagesByIndex.set(n.index,n),n.on("updated",(function(e){return r.emit("messageUpdated",e)})),r.emit("messageAdded",n))})),n.on("itemRemoved",(function(e){Mj.debug("#{this.conversation.sid} itemRemoved: ".concat(e.index));var t=e.index;if(r.messagesByIndex.has(t)){var n=r.messagesByIndex.get(t);if(!n)return;r.messagesByIndex.delete(n.index),n.removeAllListeners("updated"),r.emit("messageRemoved",n)}})),n.on("itemUpdated",(function(e){Mj.debug("".concat(r.conversation.sid," itemUpdated: ").concat(e.item.index));var t=r.messagesByIndex.get(e.item.index);t&&t._update(e.item.data)})),e.abrupt("return",n);case 13:throw e.prev=13,e.t0=e.catch(3),this.messagesListPromise=null,"disconnected"!==this.services.syncClient.connectionState&&Mj.error("Failed to get messages object for conversation",this.conversation.sid,e.t0),Mj.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,e.t0),e.t0;case 19:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(e){return o.apply(this,arguments)})},{key:"unsubscribe",value:(a=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.messagesListPromise){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.messagesListPromise;case 4:e.sent.close(),this.messagesListPromise=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"sendV2",value:function(e){var t=this;return Mj.debug("Sending message V2",e.mediaContent,e.attributes,e.emailOptions),new TC.CancellablePromise(function(){var n=Ia(Kc.mark((function n(r,i,a){var o,s,u,c,l,f,d,p,h,v,y,g;return Kc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:s=[],u=[],a((function(){u.forEach((function(e){return e.cancel()}))})),c=Pj(e.mediaContent),n.prev=4,c.s();case 6:if((l=c.n()).done){n.next=25;break}return f=dg(l.value,2),d=f[0],p=f[1],n.prev=8,Mj.debug("Adding media to a message as ".concat(p instanceof FormData?"FormData":"SendMediaOptions"),p),y=p instanceof FormData?t.services.mcsClient.postFormData(p,d):t.services.mcsClient.post(null!==(h=p.contentType)&&void 0!==h?h:"",null!==(v=p.media)&&void 0!==v?v:"",d,p.filename),u.push(y),n.t0=s,n.next=15,y;case 15:n.t1=n.sent,n.t0.push.call(n.t0,n.t1),n.next=23;break;case 19:return n.prev=19,n.t2=n.catch(8),i(n.t2),n.abrupt("return");case 23:n.next=6;break;case 25:n.next=30;break;case 27:n.prev=27,n.t3=n.catch(4),c.e(n.t3);case 30:return n.prev=30,c.f(),n.finish(30);case 33:return g=t.services.commandExecutor.mutateResource("post",t.conversation._links.messages,{body:e.text,subject:null===(o=e.emailOptions)||void 0===o?void 0:o.subject,media_sids:s.map((function(e){return e.sid})),attributes:void 0!==e.attributes?JSON.stringify(e.attributes):void 0,content_sid:e.contentSid,content_variables:void 0!==e.contentVariables?JSON.stringify(e.contentVariables.reduce((function(e,t){return Oj(Oj({},e),{},Ma({},t.name,t.value))}),{})):void 0}),n.prev=34,n.t4=r,n.next=38,g;case 38:n.t5=n.sent,(0,n.t4)(n.t5),n.next=45;break;case 42:n.prev=42,n.t6=n.catch(34),i(n.t6);case 45:case"end":return n.stop()}}),n,null,[[4,27,30,33],[8,19],[34,42]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"send",value:(i=Ia(Kc.mark((function e(t){var n,r,i=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2?i[2]:void 0,Mj.debug("Sending text message",t,n,r),e.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:null!=t?t:"",attributes:void 0!==n?JSON.stringify(n):void 0,subject:null==r?void 0:r.subject}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendMedia",value:(r=Ia(Kc.mark((function e(t){var n,r,i,a,o,s=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=s.length>1&&void 0!==s[1]?s[1]:{},a=s.length>2?s[2]:void 0,Mj.debug("Sending media message",t,i,a),Mj.debug("Sending media message as ".concat(t instanceof FormData?"FormData":"SendMediaOptions"),t,i),!(t instanceof FormData)){e.next=10;break}return e.next=7,this.services.mcsClient.postFormData(t);case 7:e.t0=e.sent,e.next=13;break;case 10:return e.next=12,this.services.mcsClient.post(null!==(n=t.contentType)&&void 0!==n?n:"",null!==(r=t.media)&&void 0!==r?r:"","media",t.filename);case 12:e.t0=e.sent;case 13:return o=e.t0,e.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[o.sid],attributes:void 0!==i?JSON.stringify(i):void 0});case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getMessages",value:(n=Ia(Kc.mark((function e(t,n){var r,i=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>2&&void 0!==i[2]?i[2]:"backwards",e.abrupt("return",this._getMessages(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_wrapPaginator",value:function(e,t,n){var r=this,i="desc"===e,a=function(){return t.nextPage().then((function(t){return r._wrapPaginator(e,t,n)}))},o=function(){return t.prevPage().then((function(t){return r._wrapPaginator(e,t,n)}))};return n(t.items).then((function(e){return{items:e.sort((function(e,t){return e.index-t.index})),hasPrevPage:i?t.hasNextPage:t.hasPrevPage,hasNextPage:i?t.hasPrevPage:t.hasNextPage,prevPage:i?a:o,nextPage:i?o:a}}))}},{key:"_upsertMessage",value:function(e,t){var n=this,r=this.messagesByIndex.get(e);if(r)return r;var i={self:"".concat(this.conversation._links.messages,"/").concat(t.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(t.sid,"/Receipts")},a=new Message(e,t,this.conversation,i,this.configuration,this.services);return this.messagesByIndex.set(a.index,a),a.on("updated",(function(e){return n.emit("messageUpdated",e)})),a}},{key:"_getMessages",value:(t=Ia(Kc.mark((function e(){var t,n,r,i,a,o,s=this,u=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:30,n=u.length>1&&void 0!==u[1]?u[1]:"end",r=u.length>2&&void 0!==u[2]?u[2]:"forward",i="backwards"===r?"desc":"asc",e.next=6,this.messagesListPromise;case 6:return a=e.sent,e.next=9,null==a?void 0:a.getItems({from:"end"!==n?n:void 0,pageSize:t,order:i,limit:t});case 9:return o=e.sent,e.next=12,this._wrapPaginator(i,o,(function(e){return Promise.all(e.map((function(e){return s._upsertMessage(e.index,e.data)})))}));case 12:return e.abrupt("return",e.sent);case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),u}(cg),Uj=function(){function e(t){Na(this,e),Ma(this,"attributes",{}),Ma(this,"mediaContent",[]),Ma(this,"emailOptions",{}),this.messagesEntity=t}return Ua(e,[{key:"send",value:function(){var e=this;return new TC.CancellablePromise(function(){var t=Ia(Kc.mark((function t(n,r,i){var a,o;return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.messagesEntity.sendV2(e),i((function(){return a.cancel()})),t.prev=2,t.next=5,a;case 5:o=t.sent,n(hh(o.index)),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),r(t.t0);case 12:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e,n,r){return t.apply(this,arguments)}}())}}]),e}(),Nj=function(){function e(t,n){Na(this,e),this.limits=t,this.message=new Uj(n),this.emailBodies=new Map,this.emailHistories=new Map}return Ua(e,[{key:"setBody",value:function(e){return this.message.text=e,this}},{key:"setSubject",value:function(e){return this.message.emailOptions.subject=e,this}},{key:"setAttributes",value:function(e){return this.message.attributes=e,this}},{key:"setEmailBody",value:function(e,t){return this.emailBodies.set(e,t),this}},{key:"setEmailHistory",value:function(e,t){return this.emailHistories.set(e,t),this}},{key:"setContentTemplate",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.message.contentSid=e,this.message.contentVariables=t,this}},{key:"addMedia",value:function(e){if("undefined"==typeof FormData&&e instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(e instanceof FormData)){var t=e;if(!t.contentType||!t.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",e]),this}},{key:"build",value:function(){var e=this;if(this.emailBodies.forEach((function(t,n){if(!e.limits.emailBodiesAllowedContentTypes.includes(n))throw new Error("Unsupported email body content type ".concat(n))})),this.emailHistories.forEach((function(t,n){if(!e.limits.emailHistoriesAllowedContentTypes.includes(n))throw new Error("Unsupported email history content type ".concat(n))})),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(t){e.message.mediaContent.push(["body",t])})),this.emailHistories.forEach((function(t){e.message.mediaContent.push(["history",t])})),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),e}();function Dj(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Fj(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fj(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Fj(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Bj(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}$c([by("string"),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Nj)],Nj.prototype,"setBody",null),$c([by("string"),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Nj)],Nj.prototype,"setSubject",null),$c([by(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Nj)],Nj.prototype,"setAttributes",null),$c([by("string",[FormData,Ry]),Gc("design:type",Function),Gc("design:paramtypes",[String,Object]),Gc("design:returntype",Nj)],Nj.prototype,"setEmailBody",null),$c([by("string",[FormData,Ry]),Gc("design:type",Function),Gc("design:paramtypes",[String,Object]),Gc("design:returntype",Nj)],Nj.prototype,"setEmailHistory",null),$c([by("string",[ly("content variables",ContentTemplateVariable),"undefined"]),Gc("design:type",Function),Gc("design:paramtypes",[String,Array]),Gc("design:returntype",Nj)],Nj.prototype,"setContentTemplate",null),$c([by([FormData,Ry]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Nj)],Nj.prototype,"addMedia",null);var qj={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"},Conversation=function(e){Oa(Conversation,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g,m,b,w,k,_,x,S,E,R,I,T,C,O=Bj(Conversation);function Conversation(e,t,n,r,i){var a,o,s;Na(this,Conversation),(s=O.call(this)).sid=t,s._links=n,s._configuration=r,s._services=i,s._entityName=e.channel,s._internalState={uniqueName:e.uniqueName||null,status:"notParticipating",attributes:null!==(a=e.attributes)&&void 0!==a?a:{},createdBy:e.createdBy,dateCreated:vh(e.dateCreated),dateUpdated:vh(e.dateUpdated),friendlyName:e.friendlyName||null,lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,bindings:null!==(o=e.bindings)&&void 0!==o?o:{}},e.notificationLevel&&(s._internalState.notificationLevel=e.notificationLevel);var u={participants:s._links.participants};return s._participants=new Map,s._participantsEntity=new zA(Ta(s),s._participants,u,s._services),s._participantsEntity.on(Conversation.participantJoined,(function(e){return s.emit(Conversation.participantJoined,e)})),s._participantsEntity.on(Conversation.participantLeft,(function(e){return s.emit(Conversation.participantLeft,e)})),s._participantsEntity.on(Conversation.participantUpdated,(function(e){return s.emit(Conversation.participantUpdated,e)})),s._messagesEntity=new Lj(Ta(s),r,i),s._messagesEntity.on(Conversation.messageAdded,(function(e){return s._onMessageAdded(e)})),s._messagesEntity.on(Conversation.messageUpdated,(function(e){return s.emit(Conversation.messageUpdated,e)})),s._messagesEntity.on(Conversation.messageRemoved,(function(e){return s.emit(Conversation.messageRemoved,e)})),s}return Ua(Conversation,[{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 e;return null!==(e=this._internalState.createdBy)&&void 0!==e?e:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var e;return null!==(e=this._internalState.lastMessage)&&void 0!==e?e:void 0}},{key:"notificationLevel",get:function(){var e;return null!==(e=this._internalState.notificationLevel)&&void 0!==e?e:"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:(C=Ia(Kc.mark((function e(t,n){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._participantsEntity.add(t,null!=n?n:{}));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return C.apply(this,arguments)})},{key:"addNonChatParticipant",value:(T=Ia(Kc.mark((function e(t,n){var r,i,a=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>2&&void 0!==a[2]?a[2]:{},i=a.length>3&&void 0!==a[3]?a[3]:{},e.abrupt("return",this._participantsEntity.addNonChatParticipant(t,n,null!=r?r:{},null!=i?i:{}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"advanceLastReadMessageIndex",value:(I=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:if(!(t<(null!==(n=this.lastReadMessageIndex)&&void 0!==n?n:0))){e.next=6;break}return e.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:case 8:return e.abrupt("return",e.sent);case 6:return e.next=8,this._setLastReadMessageIndex(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"delete",value:(R=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"getAttributes",value:(E=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return e.abrupt("return",this.attributes);case 3:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"getMessages",value:(S=Ia(Kc.mark((function e(t,n,r){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._messagesEntity.getMessages(t,n,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return S.apply(this,arguments)})},{key:"getParticipants",value:(x=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"getParticipantsCount",value:(_=Ia(Kc.mark((function e(){var t,n,r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gh(this._configuration.links.conversations).path(this.sid).build(),e.next=3,this._services.network.get(n);case 3:return r=e.sent,e.abrupt("return",null!==(t=r.body.participants_count)&&void 0!==t?t:0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"getParticipantBySid",value:(k=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._participantsEntity.getParticipantBySid(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(w=Ia(Kc.mark((function e(){var t,n=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:"",e.abrupt("return",this._participantsEntity.getParticipantByIdentity(null!=t?t:""));case 2:case"end":return e.stop()}}),e,this)}))),function(){return w.apply(this,arguments)})},{key:"getMessagesCount",value:(b=Ia(Kc.mark((function e(){var t,n,r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gh(this._configuration.links.conversations).path(this.sid).build(),e.next=3,this._services.network.get(n);case 3:return r=e.sent,e.abrupt("return",null!==(t=r.body.messages_count)&&void 0!==t?t:0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"getUnreadMessagesCount",value:(m=Ia(Kc.mark((function e(){var t,n,r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new gh(this._configuration.links.myConversations).path(this.sid).build(),e.next=3,this._services.network.get(t);case 3:if((n=e.sent).body.conversation_sid===this.sid){e.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if("number"!=typeof(r=n.body.unread_messages_count)){e.next=9;break}return e.abrupt("return",r);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"join",value:(g=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"leave",value:(y=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("joined"!==this._internalState.status){e.next=3;break}return e.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"removeParticipant",value:(v=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._participantsEntity.remove("string"==typeof t?t:t.sid);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"sendMessage",value:(h=Ia(Kc.mark((function e(t,n,r){var i,a,o,s;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t&&null!==t){e.next=5;break}return e.next=3,this._messagesEntity.send(t,n,r);case 3:return o=e.sent,e.abrupt("return",null!==(a=hh(o.index))&&void 0!==a?a:0);case 5:return e.next=7,this._messagesEntity.sendMedia(t,n,r);case 7:return s=e.sent,e.abrupt("return",null!==(i=hh(s.index))&&void 0!==i?i:0);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return h.apply(this,arguments)})},{key:"prepareMessage",value:function(){return new Nj(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:(p=Ia(Kc.mark((function e(){var t;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this.getMessages(1);case 4:if(!((t=e.sent).items.length>0)){e.next=7;break}return e.abrupt("return",this.advanceLastReadMessageIndex(t.items[0].index));case 7:return e.abrupt("return",0);case 8:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"setAllMessagesUnread",value:(d=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this._setLastReadMessageIndex(null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"setUserNotificationLevel",value:(f=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:t});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:(l=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:void 0!==t?JSON.stringify(t):void 0});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateFriendlyName",value:(c=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._internalState.friendlyName===t){e.next=3;break}return e.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:t});case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateLastReadMessageIndex",value:(u=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._setLastReadMessageIndex(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"updateUniqueName",value:(s=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._internalState.uniqueName===t){e.next=4;break}return t||(t=""),e.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:t});case 4:return e.abrupt("return",this);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getMessageRecipients",value:(o=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_subscribe",value:(a=Ia(Kc.mark((function e(){var t=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._entityPromise){e.next=2;break}return e.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),e.prev=3,e.next=6,this._entityPromise;case 6:return this._entity=e.sent,this._entity.on(EC.updated,(function(e){return t._update(e.data)})),this._entity.on(EC.removed,(function(){return t.emit(Conversation.removed,t)})),this._update(this._entity.data),e.abrupt("return",this._entity);case 13:throw e.prev=13,e.t0=e.catch(3),this._entity=null,this._entityPromise=null,"disconnected"!=this._services.syncClient.connectionState&&Conversation._logger.error("Failed to get conversation object",e.t0),Conversation._logger.debug("ERROR: Failed to get conversation object",e.t0),e.t0;case 20:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(){return a.apply(this,arguments)})},{key:"_fetchStreams",value:(i=Ia(Kc.mark((function e(){var t=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._streamsPromise){e.next=2;break}return e.abrupt("return",this._streamsPromise);case 2:return this._streamsPromise=new Promise(function(){var e=Ia(Kc.mark((function e(n,r){var i,a,o,s,u;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t._subscribe();case 3:e.next=9;break;case 5:return e.prev=5,e.t0=e.catch(0),Conversation._logger.trace("Failed to subscribe to conversation",e.t0),e.abrupt("return",r(e.t0));case 9:Conversation._logger.trace("_streamsAvailable, this.entity.data=",null===(i=t._entity)||void 0===i?void 0:i.data),o=null===(a=t._entity)||void 0===a?void 0:a.data,s=t._services.syncClient.list({id:o.messages,mode:"open_existing"}).then((function(e){return t._messagesList=e,e})),u=t._services.syncClient.map({id:o.roster,mode:"open_existing"}).then((function(e){return t._participantsMap=e,e})),Promise.all([s,u]).then((function(){return n(!0)})).catch((function(e){Conversation._logger.trace("Failed to fetch conversation streams for conversation",t.sid,e),r(e)}));case 14:case"end":return e.stop()}}),e,null,[[0,5]])})));return function(t,n){return e.apply(this,arguments)}}()),e.abrupt("return",this._streamsPromise.catch((function(e){throw t._streamsPromise=null,e})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_subscribeStreams",value:(r=Ia(Kc.mark((function e(){var t,n,r,i,a,o,s;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._fetchStreams();case 3:return Conversation._logger.trace("_subscribeStreams, this.entity.data=",null===(t=this._entity)||void 0===t?void 0:t.data),a=null===(n=this._entity)||void 0===n?void 0:n.data,o=a.messages,s=a.roster,e.next=9,Promise.all([this._messagesEntity.subscribe(null!==(r=this._messagesList)&&void 0!==r?r:o),this._participantsEntity.subscribe(null!==(i=this._participantsMap)&&void 0!==i?i:s)]);case 9:e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(0),"disconnected"!==this._services.syncClient.connectionState&&Conversation._logger.error("Failed to subscribe on conversation objects",this.sid,e.t0),Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,11]])}))),function(){return r.apply(this,arguments)})},{key:"_unsubscribe",value:(n=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._entity&&(this._entity.close(),this._entity=null,this._entityPromise=null),e.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_setStatus",value:function(e,t){var n=this;this._dataSource=t,this._internalState.status!==e&&(this._internalState.status=e,"joined"!==e?this._entityPromise&&this._unsubscribe().catch((function(t){if(Conversation._logger.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n._services.syncClient.connectionState)throw t})):this._subscribeStreams().catch((function(t){if(Conversation._logger.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n._services.syncClient.connectionState)throw t})))}},{key:"_update",value:function(e){var t,n,r,i,a;Conversation._logger.trace("_update",e),Conversation.preprocessUpdate(e,this.sid);for(var o=new Set,s=0,u=Object.keys(e);s<u.length;s++){var c=u[s],l=qj[c];if(l)switch(l){case qj.status:if(!e.status||"unknown"===e.status||this._internalState.status===e.status)break;this._internalState.status=e.status,o.add(l);break;case qj.attributes:if(mh(this._internalState.attributes,e.attributes))break;this._internalState.attributes=e.attributes,o.add(l);break;case qj.lastConsumedMessageIndex:if(void 0===e.lastConsumedMessageIndex||e.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=e.lastConsumedMessageIndex,o.add("lastReadMessageIndex");break;case qj.lastMessage:if(this._internalState.lastMessage&&!e.lastMessage){delete this._internalState.lastMessage,o.add(l);break}this._internalState.lastMessage=this._internalState.lastMessage||{},void 0!==(null===(t=e.lastMessage)||void 0===t?void 0:t.index)&&e.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=e.lastMessage.index,o.add(l)),void 0!==(null===(n=e.lastMessage)||void 0===n?void 0:n.timestamp)&&(null===(r=this._internalState.lastMessage)||void 0===r||null===(i=r.dateCreated)||void 0===i?void 0:i.getTime())!==e.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=e.lastMessage.timestamp,o.add(l)),mh(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case qj.state:var f=e.state||void 0;if(void 0!==f&&(f.dateUpdated=new Date(f.dateUpdated)),mh(this._internalState.state,f))break;this._internalState.state=f,o.add(l);break;case qj.bindings:if(mh(this._internalState.bindings,e.bindings))break;this._internalState.bindings=e.bindings,o.add(l);break;default:var d=e[c]instanceof Date,p=d&&(null===(a=this._internalState[l])||void 0===a?void 0:a.getTime())===e[c].getTime(),h=!d&&this[l]===e[c];if(p||h)break;this._internalState[l]=e[c],o.add(l)}}o.size>0&&this.emit(Conversation.updated,{conversation:this,updateReasons:xy(o)})}},{key:"_onMessageAdded",value:function(e){var t,n=Dj(this._participants.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.identity===e.author){r._endTyping();break}}}catch(e){n.e(e)}finally{n.f()}this.emit(Conversation.messageAdded,e)}},{key:"_setLastReadMessageIndex",value:(t=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:t});case 2:return n=e.sent,e.abrupt("return",n.unread_messages_count);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"preprocessUpdate",value:function(e,t){try{"string"==typeof e.attributes?e.attributes=JSON.parse(e.attributes):e.attributes&&JSON.stringify(e.attributes)}catch(n){Conversation._logger.warn("Retrieved malformed attributes from the server for conversation: "+t),e.attributes={}}try{e.dateCreated&&(e.dateCreated=new Date(e.dateCreated))}catch(n){Conversation._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+t),delete e.dateCreated}try{e.dateUpdated&&(e.dateUpdated=new Date(e.dateUpdated))}catch(n){Conversation._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+t),delete e.dateUpdated}try{e.lastMessage&&e.lastMessage.timestamp&&(e.lastMessage.timestamp=new Date(e.lastMessage.timestamp))}catch(n){Conversation._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+t),delete e.lastMessage.timestamp}}}]),Conversation}(cg);Ma(Conversation,"participantJoined","participantJoined"),Ma(Conversation,"participantLeft","participantLeft"),Ma(Conversation,"participantUpdated","participantUpdated"),Ma(Conversation,"messageAdded","messageAdded"),Ma(Conversation,"messageRemoved","messageRemoved"),Ma(Conversation,"messageUpdated","messageUpdated"),Ma(Conversation,"typingEnded","typingEnded"),Ma(Conversation,"typingStarted","typingStarted"),Ma(Conversation,"updated","updated"),Ma(Conversation,"removed","removed"),Ma(Conversation,"_logger",Cf.scope("Conversation")),$c([wy(hy,Ey),Gc("design:type",Function),Gc("design:paramtypes",[String,Object]),Gc("design:returntype",Promise)],Conversation.prototype,"add",null),$c([wy(hy,hy,Ey,Ey),Gc("design:type",Function),Gc("design:paramtypes",[String,String,Object,Object]),Gc("design:returntype",Promise)],Conversation.prototype,"addNonChatParticipant",null),$c([wy(vy),Gc("design:type",Function),Gc("design:paramtypes",[Number]),Gc("design:returntype",Promise)],Conversation.prototype,"advanceLastReadMessageIndex",null),$c([wy(["undefined",vy],["undefined",vy],["undefined",dy("backwards","forward")]),Gc("design:type",Function),Gc("design:paramtypes",[Number,Number,String]),Gc("design:returntype",Promise)],Conversation.prototype,"getMessages",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"getParticipantBySid",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"getParticipantByIdentity",null),$c([wy([hy,Participant]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],Conversation.prototype,"removeParticipant",null),$c([wy(["string",FormData,dy(null),yy("media options",{contentType:hy,media:fy((function(e){var t="string"==typeof e&&e.length>0||e instanceof Uint8Array||e instanceof ArrayBuffer;return"function"==typeof Blob&&(t=t||e instanceof Blob),[t,"a non-empty string, an instance of Buffer or an instance of Blob"]}))})],Ey,["undefined",dy(null),yy("email attributes",{subject:[hy,"undefined"]})]),Gc("design:type",Function),Gc("design:paramtypes",[Object,Object,Object]),Gc("design:returntype",Promise)],Conversation.prototype,"sendMessage",null),$c([wy(dy("default","muted")),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"setUserNotificationLevel",null),$c([wy(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],Conversation.prototype,"updateAttributes",null),$c([wy("string"),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"updateFriendlyName",null),$c([wy([dy(null),vy]),Gc("design:type",Function),Gc("design:paramtypes",[Number]),Gc("design:returntype",Promise)],Conversation.prototype,"updateLastReadMessageIndex",null),$c([wy(["string",dy(null)]),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"updateUniqueName",null);var zj=function(){function e(){var t=this;Na(this,e),this._promise=new Promise((function(e,n){t._resolve=e,t._reject=n}))}return Ua(e,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(e){this._resolve(e)}},{key:"set",value:function(e){this.current=e,this._resolve(e)}},{key:"fail",value:function(e){this._reject(e)}}]),e}();function Wj(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Kj(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Kj(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Kj(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Vj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vj(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vj(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Gj(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}var Jj=Cf.scope("Conversations"),Hj=function(e){Oa(p,e);var t,n,r,i,a,o,s,u,c,l,f,d=Gj(p);function p(e,t){var n;return Na(this,p),Ma(Ta(n=d.call(this)),"conversations",new Map),Ma(Ta(n),"myConversationsRead",new zj),Ma(Ta(n),"tombstones",new Set),Ma(Ta(n),"myConversationsFetched",!1),n.configuration=e,n.services=t,n}return Ua(p,[{key:"addConversation",value:(f=Ia(Kc.mark((function e(t){var n,r,i,a,o,s,u,c,l,f;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=void 0!==(null==t?void 0:t.attributes)?t.attributes:{},e.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:t.friendlyName,unique_name:t.uniqueName,access:t.access,attributes:void 0!==a?JSON.stringify(a):void 0});case 3:if(o=e.sent,s=null!==(n=o.sid)&&void 0!==n?n:null,u=null!==(r=null===(i=o.sync_objects)||void 0===i?void 0:i.conversation)&&void 0!==r?r:null,c=$j({self:o.url},o.links),!(l=this.conversations.get(s))){e.next=12;break}return e.next=11,l._subscribe();case 11:return e.abrupt("return",l);case 12:return f=new Conversation({channel:u,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},s,c,this.configuration,this.services),this.conversations.set(f.sid,f),this._registerForEvents(f),e.next=17,f._subscribe();case 17:return this.emit("conversationAdded",f),e.abrupt("return",f);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"fetchConversations",value:(l=Ia(Kc.mark((function e(){var t,n,r,i,a,o,s,u=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._getMap();case 3:return(t=e.sent).on(RC.itemAdded,(function(e){Jj.debug("itemAdded: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),t.on(RC.itemRemoved,(function(e){Jj.debug("itemRemoved: ".concat(e.key));var t=e.key;u.myConversationsFetched||u.tombstones.add(t);var n=u.conversations.get(t);n&&("joined"===n.status&&(n._setStatus("notParticipating","sync"),u.emit("conversationLeft",n)),u.conversations.delete(t),u.emit("conversationRemoved",n),n.emit("removed",n))})),t.on(RC.itemUpdated,(function(e){Jj.debug("itemUpdated: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),e.next=9,this._fetchMyConversations();case 9:n=e.sent,r=[],i=Wj(n);try{for(i.s();!(a=i.n()).done;)o=a.value,r.push(this._upsertConversation("rest",o.channel_sid,o))}catch(e){i.e(e)}finally{i.f()}return this.myConversationsRead.set(!0),e.next=16,Promise.all(r);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),Jj.debug("The conversations list has been successfully fetched"),e.abrupt("return",this);case 22:throw e.prev=22,e.t0=e.catch(0),s="Failed to fetch the conversations list","disconnected"!==this.services.syncClient.connectionState&&Jj.error(s,e.t0),Jj.debug("ERROR: ".concat(s),e.t0),e.t0;case 28:case"end":return e.stop()}}),e,this,[[0,22]])}))),function(){return l.apply(this,arguments)})},{key:"getConversations",value:(c=Ia(Kc.mark((function e(){var t,n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getMap();case 2:return t=e.sent,e.next=5,t.getItems();case 5:return n=e.sent,e.abrupt("return",this._wrapPaginator(n,(function(e){return Promise.all(e.map((function(e){return r._upsertConversation("sync",e.key,e.data)})))})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getConversation",value:(u=Ia(Kc.mark((function e(t){var n,r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getMap();case 2:return n=e.sent,e.next=5,n.getItems({key:t});case 5:return r=e.sent,i=r.items.map((function(e){return a._upsertConversation("sync",e.key,e.data)})),e.abrupt("return",i.length>0?i[0]:null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getConversationByUniqueName",value:(s=Ia(Kc.mark((function e(t){var n,r,i,a,o;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gh(this.configuration.links.myConversations).path(t).build(),e.next=3,this.services.network.get(n);case 3:return r=e.sent,i=r.body,a=i.conversation_sid,o={entityName:null,lastConsumedMessageIndex:i.last_read_message_index,status:(null==i?void 0:i.status)||"unknown",friendlyName:i.friendly_name,dateUpdated:i.date_updated,dateCreated:i.date_created,uniqueName:i.unique_name,createdBy:i.created_by,attributes:i.attributes,channel:i.sync_objects.conversation,roster:i.sync_objects.participants,messages:i.sync_objects.messages,notificationLevel:null==i?void 0:i.notification_level,sid:a},e.abrupt("return",a?this._upsertConversation("sync",a,o):null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"peekConversation",value:(o=Ia(Kc.mark((function e(t){var n,r,i,a;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gh(this.configuration.links.conversations).path(t).build(),e.next=3,this.services.network.get(n);case 3:return r=e.sent,i=r.body,a={entityName:null,status:(null==i?void 0:i.status)||"unknown",friendlyName:i.friendly_name,dateUpdated:i.date_updated,dateCreated:i.date_created,uniqueName:i.unique_name,createdBy:i.created_by,attributes:i.attributes,channel:i.sync_objects.conversation||"".concat(t,".channel"),roster:i.sync_objects.participants,messages:i.sync_objects.messages,notificationLevel:null==i?void 0:i.notification_level,sid:t},e.abrupt("return",this._upsertConversation("sync",t,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_getMap",value:(a=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_wrapPaginator",value:(i=Ia(Kc.mark((function e(t,n){var r,i=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(t.items);case 2:return r=e.sent,e.abrupt("return",{items:r.filter((function(e){return null!==e})),hasNextPage:t.hasNextPage,hasPrevPage:t.hasPrevPage,nextPage:function(){return t.nextPage().then((function(e){return i._wrapPaginator(e,n)}))},prevPage:function(){return t.prevPage().then((function(e){return i._wrapPaginator(e,n)}))}});case 4:case"end":return e.stop()}}),e)}))),function(e,t){return i.apply(this,arguments)})},{key:"_updateConversation",value:(r=Ia(Kc.mark((function e(t,n,r){var i,a,o;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=void 0!==n._statusSource&&t!==n._statusSource,a="rest"!==t||"sync"===n._statusSource,!i||!a||"sync"===t){e.next=5;break}return Jj.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:n.sid,data:r.status,conversation:n.status}),e.abrupt("return");case 5:if("joined"!==r.status||"joined"===n.status){e.next=15;break}return n._setStatus("joined",t),o={},void 0!==r.notificationLevel&&(o.notificationLevel=r.notificationLevel),void 0!==r.lastConsumedMessageIndex&&(o.lastConsumedMessageIndex=r.lastConsumedMessageIndex),mh(o,{})||n._update(o),e.next=13,n._subscribe();case 13:return this.emit("conversationJoined",n),e.abrupt("return");case 15:if("notParticipating"!==r.status||"joined"!==n.status){e.next=22;break}return n._setStatus("notParticipating",t),n._update(r),e.next=20,n._subscribe();case 20:return this.emit("conversationLeft",n),e.abrupt("return");case 22:if("notParticipating"!==r.status){e.next=26;break}return e.next=25,n._subscribe();case 25:return e.abrupt("return");case 26:n._update(r);case 27:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"_upsertConversation",value:(n=Ia(Kc.mark((function e(t,n,r){var i,a,o,s;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Jj.trace("upsertConversation called for ".concat(n),r),!(i=this.conversations.get(n))){e.next=9;break}return Jj.trace("upsertConversation: the conversation ".concat(i.sid," is known;")+"its status is known from the source ".concat(i._statusSource," ")+"and the update came from the source ".concat(t),i),e.next=6,this._updateConversation(t,i,r);case 6:return e.next=8,i._subscribe();case 8:return e.abrupt("return",i);case 9:if("rest"!==t||!this.tombstones.has(n)){e.next=12;break}return Jj.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",n),e.abrupt("return",null);case 12:return Jj.trace("upsertConversation: creating a local conversation object with sid "+n,r),a="".concat(this.configuration.links.conversations,"/").concat(n),o={self:a,messages:"".concat(a,"/Messages"),participants:"".concat(a,"/Participants")},s=new Conversation(r,n,o,this.configuration,this.services),this.conversations.set(n,s),e.prev=17,e.next=20,s._subscribe();case 20:if("joined"!==r.status){e.next=23;break}return e.next=23,s._fetchStreams();case 23:e.next=32;break;case 25:if(e.prev=25,e.t0=e.catch(17),"SyncError"===e.t0.name){e.next=29;break}throw e.t0;case 29:return Jj.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",n,e.t0),this.conversations.delete(n),e.abrupt("return",null);case 32:return this._registerForEvents(s),this.emit("conversationAdded",s),"joined"===r.status&&(s._setStatus("joined",t),this.emit("conversationJoined",s)),e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this,[[17,25]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_fetchMyConversations",value:(t=Ia(Kc.mark((function e(){var t,n,r,i,a,o;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=null;case 2:return i=new gh(this.configuration.links.myConversations),n&&i.arg("PageToken",n),e.next=6,this.services.network.get(i.build());case 6:a=e.sent,o=null===(r=a.body)||void 0===r?void 0:r.conversations.map((function(e){return{descriptor:e,channel_sid:e.conversation_sid,status:e.status,channel:e.sync_objects.conversation,messages:e.sync_objects.messages,roster:e.sync_objects.participants||"".concat(e.conversation_sid,".roster"),lastConsumedMessageIndex:e.last_read_message_index,notificationLevel:e.notification_level}})),n=a.body.meta.next_token,t=[].concat(xy(t),xy(o));case 10:if(n){e.next=2;break}case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onConversationRemoved",value:function(e){var t=this.conversations.get(e);t&&(this.conversations.delete(e),this.emit("conversationRemoved",t))}},{key:"_registerForEvents",value:function(e){var t=this;e.on("removed",(function(){return t._onConversationRemoved(e.sid)})),e.on("updated",(function(e){return t.emit("conversationUpdated",e)})),e.on("participantJoined",(function(e){return t.emit("participantJoined",e)})),e.on("participantLeft",(function(e){return t.emit("participantLeft",e)})),e.on("participantUpdated",(function(e){return t.emit("participantUpdated",e)})),e.on("messageAdded",(function(e){return t.emit("messageAdded",e)})),e.on("messageUpdated",(function(e){return t.emit("messageUpdated",e)})),e.on("messageRemoved",(function(e){return t.emit("messageRemoved",e)})),e.on("typingStarted",(function(e){return t.emit("typingStarted",e)})),e.on("typingEnded",(function(e){return t.emit("typingEnded",e)}))}}]),p}(cg),Yj=Tn,Qj=Xr.find,Xj=Vf,Zj="find",eM=!0;function tM(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}Zj in[]&&Array(1).find((function(){eM=!1})),Yj({target:"Array",proto:!0,forced:eM},{find:function(e){return Qj(this,e,arguments.length>1?arguments[1]:void 0)}}),Xj(Zj);var nM,rM=function(e){Oa(a,e);var t,n,r,i=tM(a);function a(e,t,n){var r;return Na(this,a),(r=i.call(this)).configuration=t,r.services=n,r.fifoStack=[],r.myself=e,r.myself.on("updated",(function(e){return r.emit("userUpdated",e)})),r.myself.on("userSubscribed",(function(){return r.emit("userSubscribed",r.myself)})),r.myself.on("userUnsubscribed",(function(){r.emit("userUnsubscribed",r.myself),r.myself._ensureFetched()})),r.subscribedUsers=new Map,r}return Ua(a,[{key:"handleUnsubscribeUser",value:function(e){this.subscribedUsers.has(e.identity)&&this.subscribedUsers.delete(e.identity);var t=0;this.fifoStack.find((function(n,r){return n==e.identity&&(t=r,!0)}))&&this.fifoStack.splice(t,1),this.emit("userUnsubscribed",e)}},{key:"handleSubscribeUser",value:function(e){if(!this.subscribedUsers.has(e.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var t,n,r=this.fifoStack.shift();null===(t=this.subscribedUsers)||void 0===t||null===(n=t.get(r))||void 0===n||n.unsubscribe()}this.fifoStack.push(e.identity),this.subscribedUsers.set(e.identity,e),this.emit("userSubscribed",e)}}},{key:"getUser",value:(r=Ia(Kc.mark((function e(t,n){var r,i,a,o=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.myself._ensureFetched();case 2:if(t!=this.myself.identity){e.next=4;break}return e.abrupt("return",this.myself);case 4:if(!(i=this.subscribedUsers.get(t))){e.next=7;break}return e.abrupt("return",i);case 7:if(null===(r=n)||void 0===r){e.next=11;break}e.next=14;break;case 11:return e.next=13,this.getSyncUniqueName(t);case 13:n=e.sent;case 14:return(a=new User(t,n,this.configuration,this.services)).on("updated",(function(e){return o.emit("userUpdated",e)})),a.on("userSubscribed",(function(){return o.handleSubscribeUser(a)})),a.on("userUnsubscribed",(function(){return o.handleUnsubscribeUser(a)})),e.next=20,a._ensureFetched();case 20:return e.abrupt("return",a);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getSubscribedUsers",value:(n=Ia(Kc.mark((function e(){var t;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.myself._ensureFetched();case 2:return t=[this.myself],this.subscribedUsers.forEach((function(e){return t.push(e)})),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getSyncUniqueName",value:(t=Ia(Kc.mark((function e(t){var n,r,i,a;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new gh(this.configuration.links.users).path(t).build(),e.next=3,this.services.network.get(i);case 3:return a=e.sent,e.abrupt("return",null!==(n=null===(r=a.body)||void 0===r?void 0:r.sync_objects.user_info_map)&&void 0!==n?n:"");case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),a}(cg),iM=Cf.scope("TypingIndicator"),aM=function(){function e(t,n,r){Na(this,e),this.configuration=n,this.services=r,this.getConversation=t,this.serviceTypingTimeout=null,this.sentUpdates=new Map}var t;return Ua(e,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var e=this;this.services.notificationClient.on("message",function(){var t=Ia(Kc.mark((function t(n,r){return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==Fm.TYPING_INDICATOR){t.next=3;break}return t.next=3,e._handleRemoteTyping(r);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:(t=Ia(Kc.mark((function e(t){var n=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:iM.trace("Got new typing indicator ",t),this.getConversation(t.channel_sid).then((function(e){e&&e._participants.forEach((function(e){if(e.identity===t.identity||"apple"===e.type){var r=n.configuration.typingIndicatorTimeoutOverride?n.configuration.typingIndicatorTimeoutOverride+1e3:1e3*t.typing_timeout;e._startTyping(r)}}))})).catch((function(e){throw iM.error(e),e}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"send",value:function(e){var t=this.sentUpdates.get(e);return t&&t>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(e,Date.now()),this._send(e))}},{key:"_send",value:function(e){var t=this;iM.trace("Sending typing indicator");var n=this.configuration.links.typing,r="ChannelSid=".concat(e);return this.services.twilsockClient.post(n,{"Content-Type":"application/x-www-form-urlencoded"},r,this.configuration.productId).then((function(e){e.body.hasOwnProperty("typing_timeout")&&(t.serviceTypingTimeout=1e3*e.body.typing_timeout)})).catch((function(e){throw iM.error("Failed to send typing indicator:",e),e}))}}]),e}(),PushNotification=Ua((function PushNotification(e){Na(this,PushNotification),this.title=e.title||null,this.body=e.body||null,this.sound=e.sound||null,this.badge=e.badge||null,this.action=e.action||null,this.type=e.type||null,this.data=e.data||{}})),oM="2.7.0-rc.3";function sM(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function uM(e,t,n){return uM=sM()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&Ca(i,n.prototype),i},uM.apply(null,arguments)}function cM(e){var t="function"==typeof Map?new Map:void 0;return cM=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return uM(e,arguments,ja(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Ca(r,e)},cM(e)}var lM=new Uint8Array(16);function fM(){if(!nM&&!(nM="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return nM(lM)}for(var dM=[],pM=0;pM<256;++pM)dM.push((pM+256).toString(16).slice(1));var hM={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function vM(e,t,n){if(hM.randomUUID&&!t&&!e)return hM.randomUUID();var r=(e=e||{}).random||(e.rng||fM)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return dM[e[t+0]]+dM[e[t+1]]+dM[e[t+2]]+dM[e[t+3]]+"-"+dM[e[t+4]]+dM[e[t+5]]+"-"+dM[e[t+6]]+dM[e[t+7]]+"-"+dM[e[t+8]]+dM[e[t+9]]+"-"+dM[e[t+10]]+dM[e[t+11]]+dM[e[t+12]]+dM[e[t+13]]+dM[e[t+14]]+dM[e[t+15]]}(r)}function yM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function gM(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yM(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yM(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function mM(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}var bM=function(e){return e.replace(/(^\/+|\/+$)/g,"")},wM=function(e){Oa(n,e);var t=mM(n);function n(e){return Na(this,n),t.call(this,e)}return Ua(n)}(cM(Error)),kM=function(){function e(t,n,r){Na(this,e),this._serviceUrl=t,this._services=n,this._productId=r}var t,n,r;return Ua(e,[{key:"_preProcessUrl",value:function(e){var t=bM(e);return/^https?:\/\//.test(e)?t:"".concat(bM(this._serviceUrl),"/").concat(t)}},{key:"_makeRequest",value:(r=Ia(Kc.mark((function e(t,n,r,i){var a,o,s,u;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._preProcessUrl(n),o=gM({"Content-Type":"application/json; charset=utf-8"},i||{}),e.t0=t,e.next="get"===e.t0?5:"post"===e.t0?11:"delete"===e.t0?15:19;break;case 5:return u=a,r&&(u+="?"+Object.entries(r).map((function(e){return e.map(encodeURIComponent).join("=")})).join("&")),e.next=9,this._services.transport.get(u,o,this._productId);case 9:case 13:case 17:return s=e.sent,e.abrupt("break",19);case 11:return e.next=13,this._services.transport.post(a,o,JSON.stringify(r),this._productId);case 15:return e.next=17,this._services.transport.delete(a,o,{},this._productId);case 19:if(!(s.status.code<200||s.status.code>=300)){e.next=21;break}throw new Error("Request responded with a non-success code ".concat(s.status.code));case 21:return e.abrupt("return",s);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"fetchResource",value:(n=Ia(Kc.mark((function e(t,n){var r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Mm({min:50,max:1600,maxAttemptsCount:6}),e.prev=2,e.next=5,r.run(Ia(Kc.mark((function e(){var r,i,o;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,a._makeRequest("get",t,n);case 3:return r=e.sent,e.abrupt("return",{type:"success",data:r.body});case 7:if(e.prev=7,e.t0=e.catch(0),404!==(null===e.t0||void 0===e.t0||null===(i=e.t0.body)||void 0===i?void 0:i.status)||50530!==(null===e.t0||void 0===e.t0||null===(o=e.t0.body)||void 0===o?void 0:o.code)){e.next=11;break}return e.abrupt("return",{type:"noMetadata"});case 11:throw e.t0;case 12:case"end":return e.stop()}}),e,null,[[0,7]])}))));case 5:i=e.sent,e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(2),new Error('Fetch resource from "'.concat(t,'" failed.'));case 11:if("noMetadata"!==i.type){e.next=13;break}throw new wM("No metadata found.");case 13:return e.abrupt("return",i.data);case 14:case"end":return e.stop()}}),e,null,[[2,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"mutateResource",value:(t=Ia(Kc.mark((function e(t,n,r){var i;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n,r,{"X-Twilio-Mutation-Id":vM()});case 2:if(202!==(i=e.sent).status.code){e.next=7;break}return e.next=6,this.fetchResource(i.body.resource_url);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return",i.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,n,r){return t.apply(this,arguments)})}]),e}(),_M=Tn,xM=hg,SM=s,EM=E,RM=pg.exports.onFreeze,IM=Object.freeze;_M({target:"Object",stat:!0,forced:SM((function(){IM(1)})),sham:!xM},{freeze:function(e){return IM&&EM(e)?IM(RM(e)):e}});var TM=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;Na(this,e),Ma(this,"_cachedTemplates",null),this._services=t,this._pageSize=n,this._cacheTtlMs=r}var t,n;return Ua(e,[{key:"getContentTemplates",value:(n=Ia(Kc.mark((function e(){var t,n,r,i,a,o,s,u=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===this._cachedTemplates){e.next=2;break}return e.abrupt("return",this._cachedTemplates);case 2:return e.next=4,this._fetchContentTemplates();case 4:t=e.sent,n=dg(t,2),r=n[0],i=n[1],a=r;case 9:if(null===i){e.next=19;break}return e.next=12,this._fetchContentTemplates(i);case 12:o=e.sent,s=dg(o,2),r=s[0],i=s[1],a=[].concat(xy(a),xy(r)),e.next=9;break;case 19:return this._cachedTemplates=Object.freeze(a),setTimeout((function(){u._cachedTemplates=null}),this._cacheTtlMs),e.abrupt("return",a);case 22:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_fetchContentTemplates",value:(t=Ia(Kc.mark((function e(t){var n,r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new gh("Client/v2/ContentTemplates")).arg("PageSize",this._pageSize),void 0!==t&&n.arg("PageToken",t),e.next=6,this._services.commandExecutor.fetchResource(n.build());case 6:return r=e.sent,e.abrupt("return",[r.templates.map((function(e){return new gj(e)})),r.meta.next_token]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();function CM(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return OM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return OM(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function OM(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var PM=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Na(this,t),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}return Ua(t,[{key:"_set",value:function(e,t){if(this.cache.set(e,t),this._size++,this._size>=this.maxSize){if(this._size=0,"function"==typeof this.onEviction){var n,r=CM(this.oldCache.entries());try{for(r.s();!(n=r.n()).done;){var i=dg(n.value,2),a=i[0],o=i[1];this.onEviction(a,o)}}catch(e){r.e(e)}finally{r.f()}}this.oldCache=this.cache,this.cache=new Map}}},{key:"get",value:function(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){var t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}},{key:"set",value:function(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}},{key:"has",value:function(e){return this.cache.has(e)||this.oldCache.has(e)}},{key:"peek",value:function(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}},{key:"delete",value:function(e){var t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}},{key:"clear",value:function(){this.cache.clear(),this.oldCache.clear(),this._size=0}},{key:"keys",value:Kc.mark((function e(){var t,n,r,i;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=CM(this),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=dg(n.value,1),i=r[0],e.next=7,i;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:"values",value:Kc.mark((function e(){var t,n,r,i;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=CM(this),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=dg(n.value,2),i=r[1],e.next=7,i;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:e,value:Kc.mark((function e(){var t,n,r,i,a,o,s,u;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=CM(this.cache),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=n.value,e.next=7,r;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:i=CM(this.oldCache),e.prev=18,i.s();case 20:if((a=i.n()).done){e.next=28;break}if(o=a.value,s=dg(o,1),u=s[0],this.cache.has(u)){e.next=26;break}return e.next=26,o;case 26:e.next=20;break;case 28:e.next=33;break;case 30:e.prev=30,e.t1=e.catch(18),i.e(e.t1);case 33:return e.prev=33,i.f(),e.finish(33);case 36:case"end":return e.stop()}}),e,this,[[1,11,14,17],[18,30,33,36]])}))},{key:"size",get:function(){var e,t=0,n=CM(this.oldCache.keys());try{for(n.s();!(e=n.n()).done;){var r=e.value;this.cache.has(r)||t++}}catch(e){n.e(e)}finally{n.f()}return Math.min(this._size+t,this.maxSize)}}]),t}(Symbol.iterator),AM=PM,jM=Ua((function e(t,n){Na(this,e),this.type=t,this.data=n,Object.freeze(n)})),MM=function(){function e(t,n){Na(this,e),this._services=t,this._configuration=n,this._cache=new AM({maxSize:n.channelMetadataCacheCapacity})}var t;return Ua(e,[{key:"getChannelMetadata",value:(t=Ia(Kc.mark((function e(t,n){var r,i,a,o,s;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r="".concat(t,",").concat(n),!(i=this._cache.get(r))){e.next=4;break}return e.abrupt("return",i.item);case 4:return a="".concat(this._configuration.links.conversations,"/").concat(t,"/Messages/").concat(n,"/ChannelMetadata"),e.prev=5,e.next=8,this._services.commandExecutor.fetchResource(a);case 8:o=e.sent,e.next=17;break;case 11:if(e.prev=11,e.t0=e.catch(5),!(e.t0 instanceof wM)){e.next=16;break}return this._cache.set(r,{item:null}),e.abrupt("return",null);case 16:throw new Error(e.t0);case 17:return s=new jM(o.type,o.data),this._cache.set(r,{item:s}),e.abrupt("return",s);case 20:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(e,n){return t.apply(this,arguments)})}]),e}();function LM(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return UM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return UM(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function UM(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var NM,DM,FM=Ua((function e(t){Na(this,e),Ma(this,"type","email"),this.messageSid=t.message_sid,this.level=t.level,this.name=t.name,this.address=t.address})),BM=Ua((function e(t){Na(this,e),this.type=t.type,this.messageSid=t.message_sid,this.rawData=JSON.stringify(t)})),qM=function(){function e(t,n){Na(this,e),this._services=t,this._configuration=n,this._cache=new AM({maxSize:n.messageRecipientsCacheCapacity})}var t,n;return Ua(e,[{key:"getRecipientsFromMessage",value:(n=Ia(Kc.mark((function e(t,n){var r,i,a,o,s,u=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r="".concat(t,",").concat(n),!(i=this._cache.get(r))){e.next=4;break}return e.abrupt("return",i.item);case 4:return a=new gh(this._configuration.links.conversations).path(t).path("MessageRecipients").arg("MessageSid",n).build(),e.next=7,this._services.commandExecutor.fetchResource(a);case 7:return o=e.sent,(s=o.message_recipients.map((function(e){return u._wrapResponse(e)}))).length>0&&this._cache.set(r,{item:s}),e.abrupt("return",s);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"getRecipientsFromConversation",value:(t=Ia(Kc.mark((function e(t,n){var r,i,a,o,s,u,c,l,f,d,p,h,v=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new gh(this._configuration.links.conversations).path(t).path("MessageRecipients").arg("PageToken",null!==(r=null==n?void 0:n.pageToken)&&void 0!==r?r:void 0).arg("PageSize",null!==(i=null==n?void 0:n.pageSize)&&void 0!==i?i:void 0).build(),e.next=3,this._services.commandExecutor.fetchResource(a);case 3:o=e.sent,s=o.message_recipients.map((function(e){return v._wrapResponse(e)})),u=LM(s);try{for(u.s();!(c=u.n()).done;)d=c.value,p="".concat(t,",").concat(d.messageSid),h=null!==(l=null===(f=this._cache.get(p))||void 0===f?void 0:f.item)&&void 0!==l?l:[],this._cache.set(p,{item:[].concat(xy(h),[d])})}catch(e){u.e(e)}finally{u.f()}return e.abrupt("return",new uj(s,(function(e,n){return v.getRecipientsFromConversation(t,{pageToken:e,pageSize:n})}),o.meta.previous_token,o.meta.next_token));case 8:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"_wrapResponse",value:function(e){return"email"===e.type?new FM(e):new BM(e)}}]),e}();function zM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function WM(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?zM(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zM(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function KM(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}var VM=Ua((function e(){Na(this,e)}));return e.Client=(NM=function(e){Oa(Client,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g=KM(Client);function Client(e){var t,n,r,i,a,o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Na(this,Client),Ma(Ta(o=g.call(this)),"version",oM),Ma(Ta(o),"connectionState","unknown"),Ma(Ta(o),"parsePushNotification",DM.parsePushNotification),o._fpaToken=null!=e?e:"",o._options=null!=s?s:{},!o._options.disableDeepClone){var u=WM(WM({},o._options),{},{transport:void 0,twilsockClient:void 0});(u=ph(u)).transport=o._options.transport,u.twilsockClient=o._options.twilsockClient,o._options=u}o._options.logLevel=null!==(t=o._options.logLevel)&&void 0!==t?t:"silent",DM._logger.setLevel(o._options.logLevel);var c=o._options.productId="ip_messaging";if(o._options.clientMetadata=o._options.clientMetadata||{},o._options.clientMetadata.hasOwnProperty("type")||(o._options.clientMetadata.type="conversations"),o._options.clientMetadata.hasOwnProperty("sdk")||(o._options.clientMetadata.sdk="JS",o._options.clientMetadata.sdkv=oM),o._options.Sync=o._options.Sync||{},void 0===o._options.Sync.enableSessionStorage&&(o._options.Sync.enableSessionStorage=!0),o._options.region&&(o._options.Sync.region=o._options.region),!e)throw new Error("A valid Twilio token should be provided");o._services=new VM,o._myself=new User("","",null,o._services);var l=!o._options.twilsockClient;if(!o._options.initRegistrations){var f=new Bm.InitRegistration(c);DM.populateInitRegistrations(f),o._options.initRegistrations=[f]}o._services.twilsockClient=o._options.twilsockClient=null!==(n=o._options.twilsockClient)&&void 0!==n?n:new Bm.TwilsockClient(e,c,o._options),o._services.twilsockClient.on(DM.tokenAboutToExpire,(function(){return o.emit(DM.tokenAboutToExpire)})),o._services.twilsockClient.on(DM.tokenExpired,(function(){return o.emit(DM.tokenExpired)})),o._services.twilsockClient.on(DM.connectionError,(function(e){return o.emit(DM.connectionError,e)})),o._services.twilsockClient.on("stateChanged",(function(e){DM._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(e)),e!==o.connectionState&&(o.connectionState=e,o.emit(DM.connectionStateChanged,o.connectionState))})),o._services.transport=o._options.transport=null!==(r=o._options.transport)&&void 0!==r?r:o._options.twilsockClient,o._services.notificationClient=o._options.notificationsClient=null!==(i=o._options.notificationsClient)&&void 0!==i?i:new SR.Notifications(e,o._options),o._services.syncClient=o._options.syncClient=null!==(a=o._options.syncClient)&&void 0!==a?a:new SC(e,o._options);var d=(null==s?void 0:s.Chat)||(null==s?void 0:s.IPMessaging)||s||{},p=d.region||(null==s?void 0:s.region),h=d.apiUri||d.typingUri||"https://aim.".concat(p||"us1",".twilio.com");o._services.commandExecutor=new kM(h,{transport:o._options.transport},c),o._services.contentClient=new TM(o._services);var v=function(e){o._rejectEnsureReady(e),o.emit(DM.stateChanged,"failed"),o.emit(DM.initFailed,{error:e})},y=function(){v({terminal:!0,message:"Twilsock has disconnected."}),o._initializeEnsureReady((null==s?void 0:s.throwErrorsAlways)||!1)};return o._services.twilsockClient.once("connectionError",v),o._services.twilsockClient.once("disconnected",y),o._services.twilsockClient.once("connected",Ia(Kc.mark((function e(){var t,n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return DM._logger.debug("ConversationsClient started INITIALIZING"),o._services.twilsockClient.off("connectionError",v),o._services.twilsockClient.off("disconnected",y),e.prev=3,t="conversations.client.startup",o._services.twilsockClient.addPartialTelemetryEvent(new Bm.TelemetryEventDescription(t,"Conversations client startup",new Date),t,Bm.TelemetryPoint.Start),e.next=8,o._initialize();case 8:o._services.twilsockClient.addPartialTelemetryEvent(new Bm.TelemetryEventDescription("","",new Date),t,Bm.TelemetryPoint.End),e.next=17;break;case 11:e.prev=11,e.t0=e.catch(3),n={terminal:!0,message:e.t0.message},o._rejectEnsureReady(n),o.emit(DM.stateChanged,"failed"),o.emit(DM.initFailed,{error:n});case 17:case"end":return e.stop()}}),e,null,[[3,11]])})))),o._initializeEnsureReady((null==s?void 0:s.throwErrorsAlways)||!1),l&&o._services.twilsockClient.connect(),o}return Ua(Client,[{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:(y=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"updateToken",value:(v=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:if(DM._logger.info("updateToken"),this._fpaToken!==t){e.next=5;break}return e.abrupt("return",this);case 5:return e.next=7,this._services.twilsockClient.updateToken(t);case 7:return e.next=9,this._services.notificationClient.updateToken(t);case 9:return e.next=11,this._services.mcsClient.updateToken(t);case 11:return this._fpaToken=t,e.abrupt("return",this);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"getConversationBySid",value:(h=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return e.next=6,this._conversationsEntity.getConversation(t);case 6:if(n=e.sent){e.next=12;break}return e.next=10,this.peekConversationBySid(t);case 10:(n=e.sent)&&hj("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(n){e.next=14;break}throw new Error("Conversation with SID ".concat(t," was not found."));case 14:return e.abrupt("return",n);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"peekConversationBySid",value:(p=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.peekConversation(t);case 4:if(n=e.sent){e.next=7;break}throw new Error("Conversation with SID ".concat(t," was not found."));case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"getConversationByUniqueName",value:(d=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return e.next=6,this._conversationsEntity.getConversationByUniqueName(t);case 6:if(n=e.sent){e.next=9;break}throw new Error("Conversation with unique name ".concat(t," was not found."));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"getSubscribedConversations",value:(f=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._conversationsPromise.then((function(e){return e.getConversations()})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"createConversation",value:(l=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return t=t||{},e.abrupt("return",this._conversationsPromise.then((function(e){return e.addConversation(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"setPushRegistrationId",value:(c=Ia(Kc.mark((function e(t,n){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(t),this._services.notificationClient.setPushRegistrationId(t,n),e.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"unsetPushRegistrationId",value:(u=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(t),e.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"removePushRegistrations",value:(s=Ia(Kc.mark((function e(t,n){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.notificationClient.removeRegistrations(t,n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handlePushNotification",value:(o=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:DM._logger.debug("handlePushNotification, notificationPayload=",t),this.emit("pushNotification",DM.parsePushNotification(t));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getUser",value:(a=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._services.users.getUser(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getSubscribedUsers",value:(i=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getTemporaryContentUrlsForMediaSids",value:function(e){var t=this;return new TC.CancellablePromise(function(){var n=Ia(Kc.mark((function n(r,i,a){var o,s;return Kc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t._services.mcsClient&&e){n.next=3;break}return i(new Error("Media Content Service is unavailable")),n.abrupt("return");case 3:return o=t._services.mcsClient.mediaSetGetContentUrls(e),a((function(){o.cancel()})),n.prev=5,n.next=8,o;case 8:s=n.sent,r(s),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[5,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(e){var t=e.map((function(e){return e.sid}));return this.getTemporaryContentUrlsForMediaSids(t)}},{key:"getContentTemplates",value:(r=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._services.contentClient.getContentTemplates();case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_initialize",value:(n=Ia(Kc.mark((function e(){var t,n=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return t=e.sent,this._configuration=new Bf(this._options,t,DM._logger),this._services.channelMetadataClient=new MM(this._services,this._configuration),this._services.messageRecipientsClient=new qM(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new aM(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new Dm(this._configuration,this._services),this._services.users=new rM(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",(function(e){n.emit("userSubscribed",e)})),this._services.users.on("userUpdated",(function(e){return n.emit("userUpdated",e)})),this._services.users.on("userUnsubscribed",(function(e){n.emit("userUnsubscribed",e)})),this._conversationsEntity=new Hj(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",(function(e){n.emit("conversationAdded",e)})),this._conversationsEntity.on("conversationRemoved",(function(e){n.emit("conversationRemoved",e)})),this._conversationsEntity.on("conversationJoined",(function(e){n.emit("conversationJoined",e)})),this._conversationsEntity.on("conversationLeft",(function(e){n.emit("conversationLeft",e)})),this._conversationsEntity.on("conversationUpdated",(function(e){return n.emit("conversationUpdated",e)})),this._conversationsEntity.on("participantJoined",(function(e){n.emit("participantJoined",e)})),this._conversationsEntity.on("participantLeft",(function(e){n.emit("participantLeft",e)})),this._conversationsEntity.on("participantUpdated",(function(e){return n.emit("participantUpdated",e)})),this._conversationsEntity.on("messageAdded",(function(e){return n.emit("messageAdded",e)})),this._conversationsEntity.on("messageUpdated",(function(e){return n.emit("messageUpdated",e)})),this._conversationsEntity.on("messageRemoved",(function(e){return n.emit("messageRemoved",e)})),this._conversationsEntity.on("typingStarted",(function(e){return n.emit("typingStarted",e)})),this._conversationsEntity.on("typingEnded",(function(e){return n.emit("typingEnded",e)})),this._conversationsPromise=this._conversationsEntity.fetchConversations().then((function(){return n._conversationsEntity})).catch((function(e){throw console.error("Failed to fetch conversations _conversationsPromise -> client.ts",e),e})),e.next=30,this._services.users.myself._ensureFetched();case 30:DM._supportedPushChannels.forEach((function(e){return n._subscribeToPushNotifications(e)})),this._services.typingIndicator.initialize(),this._services.mcsClient=new TC.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,WM(WM({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(DM.stateChanged,"initialized"),this.emit(DM.initialized);case 36:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_subscribeToPushNotifications",value:function(e){var t=this;[Fm.NEW_MESSAGE,Fm.ADDED_TO_CONVERSATION,Fm.REMOVED_FROM_CONVERSATION,Fm.TYPING_INDICATOR,Fm.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.subscribe(e,n)}))}},{key:"_unsubscribeFromPushNotifications",value:function(e){var t=this;[Fm.NEW_MESSAGE,Fm.ADDED_TO_CONVERSATION,Fm.REMOVED_FROM_CONVERSATION,Fm.TYPING_INDICATOR,Fm.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.unsubscribe(e,n)}))}},{key:"_initializeEnsureReady",value:function(e){var t=this;this._ensureReady=new Promise((function(e,n){t._resolveEnsureReady=e,t._rejectEnsureReady=n})).catch((function(t){if(e)throw t}))}}],[{key:"create",value:(t=Ia(Kc.mark((function e(t,n){var r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n||!n.twilsockClient){e.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 r=new DM(t,n),e.next=5,r._ensureReady;case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"parsePushNotification",value:function(e){if(DM._logger.debug("parsePushNotification, notificationPayload=",e),void 0!==e.aps){if(!e.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var t,n,r,i=DM._parsePushNotificationChatData(e),a=e.aps,o=null;if("string"==typeof a.alert)t=a.alert||null;else t=(null===(n=a.alert)||void 0===n?void 0:n.body)||null,o=(null===(r=a.alert)||void 0===r?void 0:r.title)||null;return new PushNotification({title:o,body:t,sound:a.sound||null,badge:a.badge||null,action:a.category||null,type:e.twi_message_type,data:i})}if(void 0!==e.data){var s=e.data;if(!s.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var u=DM._parsePushNotificationChatData(e.data);return new PushNotification({title:s.twi_title||null,body:s.twi_body||null,sound:s.twi_sound||null,badge:null,action:s.twi_action||null,type:s.twi_message_type,data:u})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(e){var t={};for(var n in DM._supportedPushDataFields){var r=e[n];if(null!=r)if("message_index"!==n&&"media_count"!==n){if("media"!==n)t[DM._supportedPushDataFields[n]]=r;else if("string"==typeof r)try{t[DM._supportedPushDataFields[n]]=JSON.parse(r)}catch(e){DM._logger.debug("Media message notification parsing error")}}else{var i=hh(r);null!==i&&(t[DM._supportedPushDataFields[n]]=i)}}return t}},{key:"populateInitRegistrations",value:function(e){e.populateInitRegistrations([Fm.TYPING_INDICATOR]),SC.populateInitRegistrations(e)}}]),Client}(cg),Ma(NM,"conversationAdded","conversationAdded"),Ma(NM,"conversationJoined","conversationJoined"),Ma(NM,"conversationLeft","conversationLeft"),Ma(NM,"conversationRemoved","conversationRemoved"),Ma(NM,"conversationUpdated","conversationUpdated"),Ma(NM,"participantJoined","participantJoined"),Ma(NM,"participantLeft","participantLeft"),Ma(NM,"participantUpdated","participantUpdated"),Ma(NM,"messageAdded","messageAdded"),Ma(NM,"messageRemoved","messageRemoved"),Ma(NM,"messageUpdated","messageUpdated"),Ma(NM,"tokenAboutToExpire","tokenAboutToExpire"),Ma(NM,"tokenExpired","tokenExpired"),Ma(NM,"typingEnded","typingEnded"),Ma(NM,"typingStarted","typingStarted"),Ma(NM,"pushNotification","pushNotification"),Ma(NM,"userSubscribed","userSubscribed"),Ma(NM,"userUnsubscribed","userUnsubscribed"),Ma(NM,"userUpdated","userUpdated"),Ma(NM,"stateChanged","stateChanged"),Ma(NM,"initialized","initialized"),Ma(NM,"initFailed","initFailed"),Ma(NM,"connectionStateChanged","connectionStateChanged"),Ma(NM,"connectionError","connectionError"),Ma(NM,"version",oM),Ma(NM,"_logger",Cf.scope("Client")),Ma(NM,"_supportedPushChannels",["fcm","apn"]),Ma(NM,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),DM=NM),$c([pj("token"),Gc("design:type",String),Gc("design:paramtypes",[])],e.Client.prototype,"token",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"updateToken",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),$c([wy(["undefined",yy("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],e.Client.prototype,"createConversation",null),$c([wy(dy("fcm","apn"),"string"),Gc("design:type",Function),Gc("design:paramtypes",[String,String]),Gc("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),$c([wy(dy("fcm","apn")),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),$c([wy(dy("fcm","apn"),hy),Gc("design:type",Function),Gc("design:paramtypes",[String,String]),Gc("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),$c([wy(gy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"getUser",null),$c([wy(py("strings","string")),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",TC.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),$c([wy(py("media",Media)),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",TC.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),$c([pj("Client.create()","new Client()"),wy("string",["undefined",gy]),Gc("design:type",Function),Gc("design:paramtypes",[String,Object]),Gc("design:returntype",Promise)],e.Client,"create",null),$c([by(gy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",PushNotification)],e.Client,"parsePushNotification",null),e.Client=DM=$c([my(hy,[gy,"undefined"]),Gc("design:paramtypes",[String,Object])],e.Client),e.AggregatedDeliveryReceipt=AggregatedDeliveryReceipt,e.CancellablePromise=TC.CancellablePromise,e.ChannelMetadata=jM,e.ContentTemplate=gj,e.ContentTemplateVariable=ContentTemplateVariable,e.Conversation=Conversation,e.DetailedDeliveryReceipt=DetailedDeliveryReceipt,e.EmailRecipientDescriptor=FM,e.Media=Media,e.Message=Message,e.MessageBuilder=Nj,e.NotificationTypes=Fm,e.Participant=Participant,e.PushNotification=PushNotification,e.RestPaginator=uj,e.UnknownRecipientDescriptor=BM,e.UnsentMessage=Uj,e.User=User,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
129
+ this.Twilio=this.Twilio||{},this.Twilio.Conversations=function(e){"use strict";var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{};function r(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var i=function(e){return e&&e.Math==Math&&e},a=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof n&&n)||function(){return this}()||Function("return this")(),o={},s=function(e){try{return!!e()}catch(e){return!0}},u=!s((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),c={},l={}.propertyIsEnumerable,f=Object.getOwnPropertyDescriptor,d=f&&!l.call({1:2},1);c.f=d?function(e){var t=f(this,e);return!!t&&t.enumerable}:l;var p,h,v=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},y={}.toString,g=function(e){return y.call(e).slice(8,-1)},m=g,b="".split,w=s((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==m(e)?b.call(e,""):Object(e)}:Object,k=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},_=w,x=k,S=function(e){return _(x(e))},E=function(e){return"object"==typeof e?null!==e:"function"==typeof e},R=a,I=function(e){return"function"==typeof e?e:void 0},T=function(e,t){return arguments.length<2?I(R[e]):R[e]&&R[e][t]},C=T("navigator","userAgent")||"",O=a,P=C,A=O.process,j=O.Deno,M=A&&A.versions||j&&j.version,L=M&&M.v8;L?h=(p=L.split("."))[0]<4?1:p[0]+p[1]:P&&(!(p=P.match(/Edge\/(\d+)/))||p[1]>=74)&&(p=P.match(/Chrome\/(\d+)/))&&(h=p[1]);var U=h&&+h,N=U,D=s,F=!!Object.getOwnPropertySymbols&&!D((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&N&&N<41})),B=F&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,q=T,z=B?function(e){return"symbol"==typeof e}:function(e){var t=q("Symbol");return"function"==typeof t&&Object(e)instanceof t},W=E,K={exports:{}},V=a,$=function(e,t){try{Object.defineProperty(V,e,{value:t,configurable:!0,writable:!0})}catch(n){V[e]=t}return t},G=$,J="__core-js_shared__",H=a[J]||G(J,{}),Y=H;(K.exports=function(e,t){return Y[e]||(Y[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.17.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"});var Q=k,X=function(e){return Object(Q(e))},Z=X,ee={}.hasOwnProperty,te=Object.hasOwn||function(e,t){return ee.call(Z(e),t)},ne=0,re=Math.random(),ie=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++ne+re).toString(36)},ae=a,oe=K.exports,se=te,ue=ie,ce=F,le=B,fe=oe("wks"),de=ae.Symbol,pe=le?de:de&&de.withoutSetter||ue,he=function(e){return se(fe,e)&&(ce||"string"==typeof fe[e])||(ce&&se(de,e)?fe[e]=de[e]:fe[e]=pe("Symbol."+e)),fe[e]},ve=E,ye=z,ge=function(e,t){var n,r;if("string"===t&&"function"==typeof(n=e.toString)&&!W(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!W(r=n.call(e)))return r;if("string"!==t&&"function"==typeof(n=e.toString)&&!W(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},me=he("toPrimitive"),be=function(e,t){if(!ve(e)||ye(e))return e;var n,r=e[me];if(void 0!==r){if(void 0===t&&(t="default"),n=r.call(e,t),!ve(n)||ye(n))return n;throw TypeError("Can't convert object to primitive value")}return void 0===t&&(t="number"),ge(e,t)},we=be,ke=z,_e=function(e){var t=we(e,"string");return ke(t)?t:String(t)},xe=E,Se=a.document,Ee=xe(Se)&&xe(Se.createElement),Re=function(e){return Ee?Se.createElement(e):{}},Ie=Re,Te=!u&&!s((function(){return 7!=Object.defineProperty(Ie("div"),"a",{get:function(){return 7}}).a})),Ce=u,Oe=c,Pe=v,Ae=S,je=_e,Me=te,Le=Te,Ue=Object.getOwnPropertyDescriptor;o.f=Ce?Ue:function(e,t){if(e=Ae(e),t=je(t),Le)try{return Ue(e,t)}catch(e){}if(Me(e,t))return Pe(!Oe.f.call(e,t),e[t])};var Ne={},De=E,Fe=function(e){if(!De(e))throw TypeError(String(e)+" is not an object");return e},Be=u,qe=Te,ze=Fe,We=_e,Ke=Object.defineProperty;Ne.f=Be?Ke:function(e,t,n){if(ze(e),t=We(t),ze(n),qe)try{return Ke(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Ve=Ne,$e=v,Ge=u?function(e,t,n){return Ve.f(e,t,$e(1,n))}:function(e,t,n){return e[t]=n,e},Je={exports:{}},He=H,Ye=Function.toString;"function"!=typeof He.inspectSource&&(He.inspectSource=function(e){return Ye.call(e)});var Qe,Xe,Ze,et=He.inspectSource,tt=et,nt=a.WeakMap,rt="function"==typeof nt&&/native code/.test(tt(nt)),it=K.exports,at=ie,ot=it("keys"),st=function(e){return ot[e]||(ot[e]=at(e))},ut={},ct=rt,lt=E,ft=Ge,dt=te,pt=H,ht=st,vt=ut,yt="Object already initialized",gt=a.WeakMap;if(ct||pt.state){var mt=pt.state||(pt.state=new gt),bt=mt.get,wt=mt.has,kt=mt.set;Qe=function(e,t){if(wt.call(mt,e))throw new TypeError(yt);return t.facade=e,kt.call(mt,e,t),t},Xe=function(e){return bt.call(mt,e)||{}},Ze=function(e){return wt.call(mt,e)}}else{var _t=ht("state");vt[_t]=!0,Qe=function(e,t){if(dt(e,_t))throw new TypeError(yt);return t.facade=e,ft(e,_t,t),t},Xe=function(e){return dt(e,_t)?e[_t]:{}},Ze=function(e){return dt(e,_t)}}var xt={set:Qe,get:Xe,has:Ze,enforce:function(e){return Ze(e)?Xe(e):Qe(e,{})},getterFor:function(e){return function(t){var n;if(!lt(t)||(n=Xe(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},St=a,Et=Ge,Rt=te,It=$,Tt=et,Ct=xt.get,Ot=xt.enforce,Pt=String(String).split("String");(Je.exports=function(e,t,n,r){var i,a=!!r&&!!r.unsafe,o=!!r&&!!r.enumerable,s=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof t||Rt(n,"name")||Et(n,"name",t),(i=Ot(n)).source||(i.source=Pt.join("string"==typeof t?t:""))),e!==St?(a?!s&&e[t]&&(o=!0):delete e[t],o?e[t]=n:Et(e,t,n)):o?e[t]=n:It(t,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&Ct(this).source||Tt(this)}));var At={},jt=Math.ceil,Mt=Math.floor,Lt=function(e){return isNaN(e=+e)?0:(e>0?Mt:jt)(e)},Ut=Lt,Nt=Math.min,Dt=function(e){return e>0?Nt(Ut(e),9007199254740991):0},Ft=Lt,Bt=Math.max,qt=Math.min,zt=function(e,t){var n=Ft(e);return n<0?Bt(n+t,0):qt(n,t)},Wt=S,Kt=Dt,Vt=zt,$t=function(e){return function(t,n,r){var i,a=Wt(t),o=Kt(a.length),s=Vt(r,o);if(e&&n!=n){for(;o>s;)if((i=a[s++])!=i)return!0}else for(;o>s;s++)if((e||s in a)&&a[s]===n)return e||s||0;return!e&&-1}},Gt={includes:$t(!0),indexOf:$t(!1)},Jt=te,Ht=S,Yt=Gt.indexOf,Qt=ut,Xt=function(e,t){var n,r=Ht(e),i=0,a=[];for(n in r)!Jt(Qt,n)&&Jt(r,n)&&a.push(n);for(;t.length>i;)Jt(r,n=t[i++])&&(~Yt(a,n)||a.push(n));return a},Zt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],en=Xt,tn=Zt.concat("length","prototype");At.f=Object.getOwnPropertyNames||function(e){return en(e,tn)};var nn={};nn.f=Object.getOwnPropertySymbols;var rn=At,an=nn,on=Fe,sn=T("Reflect","ownKeys")||function(e){var t=rn.f(on(e)),n=an.f;return n?t.concat(n(e)):t},un=te,cn=sn,ln=o,fn=Ne,dn=function(e,t){for(var n=cn(t),r=fn.f,i=ln.f,a=0;a<n.length;a++){var o=n[a];un(e,o)||r(e,o,i(t,o))}},pn=s,hn=/#|\.prototype\./,vn=function(e,t){var n=gn[yn(e)];return n==bn||n!=mn&&("function"==typeof t?pn(t):!!t)},yn=vn.normalize=function(e){return String(e).replace(hn,".").toLowerCase()},gn=vn.data={},mn=vn.NATIVE="N",bn=vn.POLYFILL="P",wn=vn,kn=a,_n=o.f,xn=Ge,Sn=Je.exports,En=$,Rn=dn,In=wn,Tn=function(e,t){var n,r,i,a,o,s=e.target,u=e.global,c=e.stat;if(n=u?kn:c?kn[s]||En(s,{}):(kn[s]||{}).prototype)for(r in t){if(a=t[r],i=e.noTargetGet?(o=_n(n,r))&&o.value:n[r],!In(u?r:s+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof a==typeof i)continue;Rn(a,i)}(e.sham||i&&i.sham)&&xn(a,"sham",!0),Sn(n,r,a,e)}},Cn=Ne.f,On=te,Pn=he("toStringTag"),An=function(e,t,n){e&&!On(e=n?e:e.prototype,Pn)&&Cn(e,Pn,{configurable:!0,value:t})},jn=a,Mn=An;Tn({global:!0},{Reflect:{}}),Mn(jn.Reflect,"Reflect",!0);var Ln,Un=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},Nn=Xt,Dn=Zt,Fn=Object.keys||function(e){return Nn(e,Dn)},Bn=Ne,qn=Fe,zn=Fn,Wn=u?Object.defineProperties:function(e,t){qn(e);for(var n,r=zn(t),i=r.length,a=0;i>a;)Bn.f(e,n=r[a++],t[n]);return e},Kn=T("document","documentElement"),Vn=Fe,$n=Wn,Gn=Zt,Jn=ut,Hn=Kn,Yn=Re,Qn=st("IE_PROTO"),Xn=function(){},Zn=function(e){return"<script>"+e+"</"+"script>"},er=function(e){e.write(Zn("")),e.close();var t=e.parentWindow.Object;return e=null,t},tr=function(){try{Ln=new ActiveXObject("htmlfile")}catch(e){}var e,t;tr="undefined"!=typeof document?document.domain&&Ln?er(Ln):((t=Yn("iframe")).style.display="none",Hn.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Zn("document.F=Object")),e.close(),e.F):er(Ln);for(var n=Gn.length;n--;)delete tr.prototype[Gn[n]];return tr()};Jn[Qn]=!0;var nr=Object.create||function(e,t){var n;return null!==e?(Xn.prototype=Vn(e),n=new Xn,Xn.prototype=null,n[Qn]=e):n=tr(),void 0===t?n:$n(n,t)},rr=Un,ir=E,ar=[].slice,or={},sr=function(e,t,n){if(!(t in or)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";or[t]=Function("C,a","return new C("+r.join(",")+")")}return or[t](e,n)},ur=Function.bind||function(e){var t=rr(this),n=ar.call(arguments,1),r=function(){var i=n.concat(ar.call(arguments));return this instanceof r?sr(t,i.length,i):t.apply(e,i)};return ir(t.prototype)&&(r.prototype=t.prototype),r},cr=Tn,lr=Un,fr=Fe,dr=E,pr=nr,hr=ur,vr=s,yr=T("Reflect","construct"),gr=vr((function(){function e(){}return!(yr((function(){}),[],e)instanceof e)})),mr=!vr((function(){yr((function(){}))})),br=gr||mr;cr({target:"Reflect",stat:!0,forced:br,sham:br},{construct:function(e,t){lr(e),fr(t);var n=arguments.length<3?e:lr(arguments[2]);if(mr&&!gr)return yr(e,t,n);if(e==n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return r.push.apply(r,t),new(hr.apply(e,r))}var i=n.prototype,a=pr(dr(i)?i:Object.prototype),o=Function.apply.call(e,a,t);return dr(o)?o:a}});var wr=X,kr=Fn;Tn({target:"Object",stat:!0,forced:s((function(){kr(1)}))},{keys:function(e){return kr(wr(e))}});var _r=g,xr=Array.isArray||function(e){return"Array"==_r(e)},Sr=z,Er=function(e){if(Sr(e))throw TypeError("Cannot convert a Symbol value to a string");return String(e)},Rr={},Ir=S,Tr=At.f,Cr={}.toString,Or="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Rr.f=function(e){return Or&&"[object Window]"==Cr.call(e)?function(e){try{return Tr(e)}catch(e){return Or.slice()}}(e):Tr(Ir(e))};var Pr={},Ar=he;Pr.f=Ar;var jr=a,Mr=te,Lr=Pr,Ur=Ne.f,Nr=function(e){var t=jr.Symbol||(jr.Symbol={});Mr(t,e)||Ur(t,e,{value:Lr.f(e)})},Dr=Un,Fr=function(e,t,n){if(Dr(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}},Br=E,qr=xr,zr=he("species"),Wr=function(e){var t;return qr(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!qr(t.prototype)?Br(t)&&null===(t=t[zr])&&(t=void 0):t=void 0),void 0===t?Array:t},Kr=function(e,t){return new(Wr(e))(0===t?0:t)},Vr=Fr,$r=w,Gr=X,Jr=Dt,Hr=Kr,Yr=[].push,Qr=function(e){var t=1==e,n=2==e,r=3==e,i=4==e,a=6==e,o=7==e,s=5==e||a;return function(u,c,l,f){for(var d,p,h=Gr(u),v=$r(h),y=Vr(c,l,3),g=Jr(v.length),m=0,b=f||Hr,w=t?b(u,g):n||o?b(u,0):void 0;g>m;m++)if((s||m in v)&&(p=y(d=v[m],m,h),e))if(t)w[m]=p;else if(p)switch(e){case 3:return!0;case 5:return d;case 6:return m;case 2:Yr.call(w,d)}else switch(e){case 4:return!1;case 7:Yr.call(w,d)}return a?-1:r||i?i:w}},Xr={forEach:Qr(0),map:Qr(1),filter:Qr(2),some:Qr(3),every:Qr(4),find:Qr(5),findIndex:Qr(6),filterReject:Qr(7)},Zr=Tn,ei=a,ti=T,ni=u,ri=F,ii=s,ai=te,oi=xr,si=E,ui=z,ci=Fe,li=X,fi=S,di=_e,pi=Er,hi=v,vi=nr,yi=Fn,gi=At,mi=Rr,bi=nn,wi=o,ki=Ne,_i=c,xi=Ge,Si=Je.exports,Ei=K.exports,Ri=ut,Ii=ie,Ti=he,Ci=Pr,Oi=Nr,Pi=An,Ai=xt,ji=Xr.forEach,Mi=st("hidden"),Li="Symbol",Ui=Ti("toPrimitive"),Ni=Ai.set,Di=Ai.getterFor(Li),Fi=Object.prototype,Bi=ei.Symbol,qi=ti("JSON","stringify"),zi=wi.f,Wi=ki.f,Ki=mi.f,Vi=_i.f,$i=Ei("symbols"),Gi=Ei("op-symbols"),Ji=Ei("string-to-symbol-registry"),Hi=Ei("symbol-to-string-registry"),Yi=Ei("wks"),Qi=ei.QObject,Xi=!Qi||!Qi.prototype||!Qi.prototype.findChild,Zi=ni&&ii((function(){return 7!=vi(Wi({},"a",{get:function(){return Wi(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=zi(Fi,t);r&&delete Fi[t],Wi(e,t,n),r&&e!==Fi&&Wi(Fi,t,r)}:Wi,ea=function(e,t){var n=$i[e]=vi(Bi.prototype);return Ni(n,{type:Li,tag:e,description:t}),ni||(n.description=t),n},ta=function(e,t,n){e===Fi&&ta(Gi,t,n),ci(e);var r=di(t);return ci(n),ai($i,r)?(n.enumerable?(ai(e,Mi)&&e[Mi][r]&&(e[Mi][r]=!1),n=vi(n,{enumerable:hi(0,!1)})):(ai(e,Mi)||Wi(e,Mi,hi(1,{})),e[Mi][r]=!0),Zi(e,r,n)):Wi(e,r,n)},na=function(e,t){ci(e);var n=fi(t),r=yi(n).concat(oa(n));return ji(r,(function(t){ni&&!ra.call(n,t)||ta(e,t,n[t])})),e},ra=function(e){var t=di(e),n=Vi.call(this,t);return!(this===Fi&&ai($i,t)&&!ai(Gi,t))&&(!(n||!ai(this,t)||!ai($i,t)||ai(this,Mi)&&this[Mi][t])||n)},ia=function(e,t){var n=fi(e),r=di(t);if(n!==Fi||!ai($i,r)||ai(Gi,r)){var i=zi(n,r);return!i||!ai($i,r)||ai(n,Mi)&&n[Mi][r]||(i.enumerable=!0),i}},aa=function(e){var t=Ki(fi(e)),n=[];return ji(t,(function(e){ai($i,e)||ai(Ri,e)||n.push(e)})),n},oa=function(e){var t=e===Fi,n=Ki(t?Gi:fi(e)),r=[];return ji(n,(function(e){!ai($i,e)||t&&!ai(Fi,e)||r.push($i[e])})),r};(ri||(Bi=function(){if(this instanceof Bi)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?pi(arguments[0]):void 0,t=Ii(e),n=function(e){this===Fi&&n.call(Gi,e),ai(this,Mi)&&ai(this[Mi],t)&&(this[Mi][t]=!1),Zi(this,t,hi(1,e))};return ni&&Xi&&Zi(Fi,t,{configurable:!0,set:n}),ea(t,e)},Si(Bi.prototype,"toString",(function(){return Di(this).tag})),Si(Bi,"withoutSetter",(function(e){return ea(Ii(e),e)})),_i.f=ra,ki.f=ta,wi.f=ia,gi.f=mi.f=aa,bi.f=oa,Ci.f=function(e){return ea(Ti(e),e)},ni&&(Wi(Bi.prototype,"description",{configurable:!0,get:function(){return Di(this).description}}),Si(Fi,"propertyIsEnumerable",ra,{unsafe:!0}))),Zr({global:!0,wrap:!0,forced:!ri,sham:!ri},{Symbol:Bi}),ji(yi(Yi),(function(e){Oi(e)})),Zr({target:Li,stat:!0,forced:!ri},{for:function(e){var t=pi(e);if(ai(Ji,t))return Ji[t];var n=Bi(t);return Ji[t]=n,Hi[n]=t,n},keyFor:function(e){if(!ui(e))throw TypeError(e+" is not a symbol");if(ai(Hi,e))return Hi[e]},useSetter:function(){Xi=!0},useSimple:function(){Xi=!1}}),Zr({target:"Object",stat:!0,forced:!ri,sham:!ni},{create:function(e,t){return void 0===t?vi(e):na(vi(e),t)},defineProperty:ta,defineProperties:na,getOwnPropertyDescriptor:ia}),Zr({target:"Object",stat:!0,forced:!ri},{getOwnPropertyNames:aa,getOwnPropertySymbols:oa}),Zr({target:"Object",stat:!0,forced:ii((function(){bi.f(1)}))},{getOwnPropertySymbols:function(e){return bi.f(li(e))}}),qi)&&Zr({target:"JSON",stat:!0,forced:!ri||ii((function(){var e=Bi();return"[null]"!=qi([e])||"{}"!=qi({a:e})||"{}"!=qi(Object(e))}))},{stringify:function(e,t,n){for(var r,i=[e],a=1;arguments.length>a;)i.push(arguments[a++]);if(r=t,(si(t)||void 0!==e)&&!ui(e))return oi(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!ui(t))return t}),i[1]=t,qi.apply(null,i)}});Bi.prototype[Ui]||xi(Bi.prototype,Ui,Bi.prototype.valueOf),Pi(Bi,Li),Ri[Mi]=!0;var sa=s,ua=U,ca=he("species"),la=function(e){return ua>=51||!sa((function(){var t=[];return(t.constructor={})[ca]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},fa=Xr.filter;Tn({target:"Array",proto:!0,forced:!la("filter")},{filter:function(e){return fa(this,e,arguments.length>1?arguments[1]:void 0)}});var da=Tn,pa=s,ha=S,va=o.f,ya=u,ga=pa((function(){va(1)}));da({target:"Object",stat:!0,forced:!ya||ga,sham:!ya},{getOwnPropertyDescriptor:function(e,t){return va(ha(e),t)}});var ma=_e,ba=Ne,wa=v,ka=function(e,t,n){var r=ma(t);r in e?ba.f(e,r,wa(0,n)):e[r]=n},_a=sn,xa=S,Sa=o,Ea=ka;function Ra(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function Ia(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){Ra(a,r,i,o,s,"next",e)}function s(e){Ra(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Ta(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ca(e,t){return Ca=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ca(e,t)}function Oa(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ca(e,t)}function Pa(e){return Pa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pa(e)}function Aa(e,t){if(t&&("object"===Pa(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Ta(e)}function ja(e){return ja=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},ja(e)}function Ma(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function La(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ua(e,t,n){return t&&La(e.prototype,t),n&&La(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Na(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Tn({target:"Object",stat:!0,sham:!u},{getOwnPropertyDescriptors:function(e){for(var t,n,r=xa(e),i=Sa.f,a=_a(r),o={},s=0;a.length>s;)void 0!==(n=i(r,t=a[s++]))&&Ea(o,t,n);return o}});var Da=Xr.map;Tn({target:"Array",proto:!0,forced:!la("map")},{map:function(e){return Da(this,e,arguments.length>1?arguments[1]:void 0)}});var Fa={};Fa[he("toStringTag")]="z";var Ba="[object z]"===String(Fa),qa=Ba,za=g,Wa=he("toStringTag"),Ka="Arguments"==za(function(){return arguments}()),Va=qa?za:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),Wa))?n:Ka?za(t):"Object"==(r=za(t))&&"function"==typeof t.callee?"Arguments":r},$a=Va,Ga=Ba?{}.toString:function(){return"[object "+$a(this)+"]"},Ja=Ba,Ha=Je.exports,Ya=Ga;Ja||Ha(Object.prototype,"toString",Ya,{unsafe:!0});var Qa={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},Xa=Re("span").classList,Za=Xa&&Xa.constructor&&Xa.constructor.prototype,eo=Za===Object.prototype?void 0:Za,to=s,no=function(e,t){var n=[][e];return!!n&&to((function(){n.call(null,t||function(){throw 1},1)}))},ro=Xr.forEach,io=no("forEach")?[].forEach:function(e){return ro(this,e,arguments.length>1?arguments[1]:void 0)},ao=a,oo=Qa,so=eo,uo=io,co=Ge,lo=function(e){if(e&&e.forEach!==uo)try{co(e,"forEach",uo)}catch(t){e.forEach=uo}};for(var fo in oo)lo(ao[fo]&&ao[fo].prototype);lo(so);var po=a.Promise,ho=Je.exports,vo=function(e,t,n){for(var r in t)ho(e,r,t[r],n);return e},yo=E,go=Fe,mo=function(e){if(!yo(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e},bo=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return go(n),mo(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),wo=T,ko=Ne,_o=u,xo=he("species"),So=function(e){var t=wo(e),n=ko.f;_o&&t&&!t[xo]&&n(t,xo,{configurable:!0,get:function(){return this}})},Eo=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},Ro={},Io=Ro,To=he("iterator"),Co=Array.prototype,Oo=function(e){return void 0!==e&&(Io.Array===e||Co[To]===e)},Po=Va,Ao=Ro,jo=he("iterator"),Mo=function(e){if(null!=e)return e[jo]||e["@@iterator"]||Ao[Po(e)]},Lo=Fe,Uo=Mo,No=function(e,t){var n=arguments.length<2?Uo(e):t;if("function"!=typeof n)throw TypeError(String(e)+" is not iterable");return Lo(n.call(e))},Do=Fe,Fo=function(e,t,n){var r,i;Do(e);try{if(void 0===(r=e.return)){if("throw"===t)throw n;return n}r=r.call(e)}catch(e){i=!0,r=e}if("throw"===t)throw n;if(i)throw r;return Do(r),n},Bo=Fe,qo=Oo,zo=Dt,Wo=Fr,Ko=No,Vo=Mo,$o=Fo,Go=function(e,t){this.stopped=e,this.result=t},Jo=function(e,t,n){var r,i,a,o,s,u,c,l=n&&n.that,f=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),h=Wo(t,l,1+f+p),v=function(e){return r&&$o(r,"normal",e),new Go(!0,e)},y=function(e){return f?(Bo(e),p?h(e[0],e[1],v):h(e[0],e[1])):p?h(e,v):h(e)};if(d)r=e;else{if("function"!=typeof(i=Vo(e)))throw TypeError("Target is not iterable");if(qo(i)){for(a=0,o=zo(e.length);o>a;a++)if((s=y(e[a]))&&s instanceof Go)return s;return new Go(!1)}r=Ko(e,i)}for(u=r.next;!(c=u.call(r)).done;){try{s=y(c.value)}catch(e){$o(r,"throw",e)}if("object"==typeof s&&s&&s instanceof Go)return s}return new Go(!1)},Ho=he("iterator"),Yo=!1;try{var Qo=0,Xo={next:function(){return{done:!!Qo++}},return:function(){Yo=!0}};Xo[Ho]=function(){return this},Array.from(Xo,(function(){throw 2}))}catch(e){}var Zo,es,ts,ns,rs=function(e,t){if(!t&&!Yo)return!1;var n=!1;try{var r={};r[Ho]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},is=Fe,as=Un,os=he("species"),ss=function(e,t){var n,r=is(e).constructor;return void 0===r||null==(n=is(r)[os])?t:as(n)},us=/(?:ipad|iphone|ipod).*applewebkit/i.test(C),cs="process"==g(a.process),ls=a,fs=s,ds=Fr,ps=Kn,hs=Re,vs=us,ys=cs,gs=ls.setImmediate,ms=ls.clearImmediate,bs=ls.process,ws=ls.MessageChannel,ks=ls.Dispatch,_s=0,xs={},Ss="onreadystatechange";try{Zo=ls.location}catch(e){}var Es=function(e){if(xs.hasOwnProperty(e)){var t=xs[e];delete xs[e],t()}},Rs=function(e){return function(){Es(e)}},Is=function(e){Es(e.data)},Ts=function(e){ls.postMessage(String(e),Zo.protocol+"//"+Zo.host)};gs&&ms||(gs=function(e){for(var t=[],n=arguments.length,r=1;n>r;)t.push(arguments[r++]);return xs[++_s]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},es(_s),_s},ms=function(e){delete xs[e]},ys?es=function(e){bs.nextTick(Rs(e))}:ks&&ks.now?es=function(e){ks.now(Rs(e))}:ws&&!vs?(ns=(ts=new ws).port2,ts.port1.onmessage=Is,es=ds(ns.postMessage,ns,1)):ls.addEventListener&&"function"==typeof postMessage&&!ls.importScripts&&Zo&&"file:"!==Zo.protocol&&!fs(Ts)?(es=Ts,ls.addEventListener("message",Is,!1)):es=Ss in hs("script")?function(e){ps.appendChild(hs("script")).onreadystatechange=function(){ps.removeChild(this),Es(e)}}:function(e){setTimeout(Rs(e),0)});var Cs,Os,Ps,As,js,Ms,Ls,Us,Ns={set:gs,clear:ms},Ds=a,Fs=/ipad|iphone|ipod/i.test(C)&&void 0!==Ds.Pebble,Bs=/web0s(?!.*chrome)/i.test(C),qs=a,zs=o.f,Ws=Ns.set,Ks=us,Vs=Fs,$s=Bs,Gs=cs,Js=qs.MutationObserver||qs.WebKitMutationObserver,Hs=qs.document,Ys=qs.process,Qs=qs.Promise,Xs=zs(qs,"queueMicrotask"),Zs=Xs&&Xs.value;Zs||(Cs=function(){var e,t;for(Gs&&(e=Ys.domain)&&e.exit();Os;){t=Os.fn,Os=Os.next;try{t()}catch(e){throw Os?As():Ps=void 0,e}}Ps=void 0,e&&e.enter()},Ks||Gs||$s||!Js||!Hs?!Vs&&Qs&&Qs.resolve?((Ls=Qs.resolve(void 0)).constructor=Qs,Us=Ls.then,As=function(){Us.call(Ls,Cs)}):As=Gs?function(){Ys.nextTick(Cs)}:function(){Ws.call(qs,Cs)}:(js=!0,Ms=Hs.createTextNode(""),new Js(Cs).observe(Ms,{characterData:!0}),As=function(){Ms.data=js=!js}));var eu=Zs||function(e){var t={fn:e,next:void 0};Ps&&(Ps.next=t),Os||(Os=t,As()),Ps=t},tu={},nu=Un,ru=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=nu(t),this.reject=nu(n)};tu.f=function(e){return new ru(e)};var iu,au,ou,su,uu=Fe,cu=E,lu=tu,fu=a,du="object"==typeof window,pu=Tn,hu=a,vu=T,yu=po,gu=Je.exports,mu=vo,bu=bo,wu=An,ku=So,_u=E,xu=Un,Su=Eo,Eu=et,Ru=Jo,Iu=rs,Tu=ss,Cu=Ns.set,Ou=eu,Pu=function(e,t){if(uu(e),cu(t)&&t.constructor===e)return t;var n=lu.f(e);return(0,n.resolve)(t),n.promise},Au=function(e,t){var n=fu.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))},ju=tu,Mu=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Lu=xt,Uu=wn,Nu=du,Du=cs,Fu=U,Bu=he("species"),qu="Promise",zu=Lu.get,Wu=Lu.set,Ku=Lu.getterFor(qu),Vu=yu&&yu.prototype,$u=yu,Gu=Vu,Ju=hu.TypeError,Hu=hu.document,Yu=hu.process,Qu=ju.f,Xu=Qu,Zu=!!(Hu&&Hu.createEvent&&hu.dispatchEvent),ec="function"==typeof PromiseRejectionEvent,tc="unhandledrejection",nc=!1,rc=Uu(qu,(function(){var e=Eu($u),t=e!==String($u);if(!t&&66===Fu)return!0;if(Fu>=51&&/native code/.test(e))return!1;var n=new $u((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};return(n.constructor={})[Bu]=r,!(nc=n.then((function(){}))instanceof r)||!t&&Nu&&!ec})),ic=rc||!Iu((function(e){$u.all(e).catch((function(){}))})),ac=function(e){var t;return!(!_u(e)||"function"!=typeof(t=e.then))&&t},oc=function(e,t){if(!e.notified){e.notified=!0;var n=e.reactions;Ou((function(){for(var r=e.value,i=1==e.state,a=0;n.length>a;){var o,s,u,c=n[a++],l=i?c.ok:c.fail,f=c.resolve,d=c.reject,p=c.domain;try{l?(i||(2===e.rejection&&lc(e),e.rejection=1),!0===l?o=r:(p&&p.enter(),o=l(r),p&&(p.exit(),u=!0)),o===c.promise?d(Ju("Promise-chain cycle")):(s=ac(o))?s.call(o,f,d):f(o)):d(r)}catch(e){p&&!u&&p.exit(),d(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&uc(e)}))}},sc=function(e,t,n){var r,i;Zu?((r=Hu.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),hu.dispatchEvent(r)):r={promise:t,reason:n},!ec&&(i=hu["on"+e])?i(r):e===tc&&Au("Unhandled promise rejection",n)},uc=function(e){Cu.call(hu,(function(){var t,n=e.facade,r=e.value;if(cc(e)&&(t=Mu((function(){Du?Yu.emit("unhandledRejection",r,n):sc(tc,n,r)})),e.rejection=Du||cc(e)?2:1,t.error))throw t.value}))},cc=function(e){return 1!==e.rejection&&!e.parent},lc=function(e){Cu.call(hu,(function(){var t=e.facade;Du?Yu.emit("rejectionHandled",t):sc("rejectionhandled",t,e.value)}))},fc=function(e,t,n){return function(r){e(t,r,n)}},dc=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,oc(e,!0))},pc=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw Ju("Promise can't be resolved itself");var r=ac(t);r?Ou((function(){var n={done:!1};try{r.call(t,fc(pc,n,e),fc(dc,n,e))}catch(t){dc(n,t,e)}})):(e.value=t,e.state=1,oc(e,!1))}catch(t){dc({done:!1},t,e)}}};if(rc&&(Gu=($u=function(e){Su(this,$u,qu),xu(e),iu.call(this);var t=zu(this);try{e(fc(pc,t),fc(dc,t))}catch(e){dc(t,e)}}).prototype,(iu=function(e){Wu(this,{type:qu,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=mu(Gu,{then:function(e,t){var n=Ku(this),r=Qu(Tu(this,$u));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=Du?Yu.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&oc(n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),au=function(){var e=new iu,t=zu(e);this.promise=e,this.resolve=fc(pc,t),this.reject=fc(dc,t)},ju.f=Qu=function(e){return e===$u||e===ou?new au(e):Xu(e)},"function"==typeof yu&&Vu!==Object.prototype)){su=Vu.then,nc||(gu(Vu,"then",(function(e,t){var n=this;return new $u((function(e,t){su.call(n,e,t)})).then(e,t)}),{unsafe:!0}),gu(Vu,"catch",Gu.catch,{unsafe:!0}));try{delete Vu.constructor}catch(e){}bu&&bu(Vu,Gu)}pu({global:!0,wrap:!0,forced:rc},{Promise:$u}),wu($u,qu,!1),ku(qu),ou=vu(qu),pu({target:qu,stat:!0,forced:rc},{reject:function(e){var t=Qu(this);return t.reject.call(void 0,e),t.promise}}),pu({target:qu,stat:!0,forced:rc},{resolve:function(e){return Pu(this,e)}}),pu({target:qu,stat:!0,forced:ic},{all:function(e){var t=this,n=Qu(t),r=n.resolve,i=n.reject,a=Mu((function(){var n=xu(t.resolve),a=[],o=0,s=1;Ru(e,(function(e){var u=o++,c=!1;a.push(void 0),s++,n.call(t,e).then((function(e){c||(c=!0,a[u]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise},race:function(e){var t=this,n=Qu(t),r=n.reject,i=Mu((function(){var i=xu(t.resolve);Ru(e,(function(e){i.call(t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var hc,vc=Object.prototype,yc=vc.hasOwnProperty,gc="function"==typeof Symbol?Symbol:{},mc=gc.iterator||"@@iterator",bc=gc.asyncIterator||"@@asyncIterator",wc=gc.toStringTag||"@@toStringTag";function kc(e,t,n,r){var i=t&&t.prototype instanceof Tc?t:Tc,a=Object.create(i.prototype),o=new qc(r||[]);return a._invoke=function(e,t,n){var r=xc;return function(i,a){if(r===Ec)throw new Error("Generator is already running");if(r===Rc){if("throw"===i)throw a;return Wc()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=Dc(o,n);if(s){if(s===Ic)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===xc)throw r=Rc,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=Ec;var u=_c(e,t,n);if("normal"===u.type){if(r=n.done?Rc:Sc,u.arg===Ic)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=Rc,n.method="throw",n.arg=u.arg)}}}(e,n,o),a}function _c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}var xc="suspendedStart",Sc="suspendedYield",Ec="executing",Rc="completed",Ic={};function Tc(){}function Cc(){}function Oc(){}var Pc={};Pc[mc]=function(){return this};var Ac=Object.getPrototypeOf,jc=Ac&&Ac(Ac(zc([])));jc&&jc!==vc&&yc.call(jc,mc)&&(Pc=jc);var Mc=Oc.prototype=Tc.prototype=Object.create(Pc);function Lc(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function Uc(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===Cc||"GeneratorFunction"===(t.displayName||t.name))}function Nc(e,t){function n(r,i,a,o){var s=_c(e[r],e,i);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"===Pa(c)&&yc.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,a,o)}),(function(e){n("throw",e,a,o)})):t.resolve(c).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,o)}))}o(s.arg)}var r;this._invoke=function(e,i){function a(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(a,a):a()}}function Dc(e,t){var n=e.iterator[t.method];if(n===hc){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=hc,Dc(e,t),"throw"===t.method))return Ic;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return Ic}var r=_c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,Ic;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=hc),t.delegate=null,Ic):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,Ic)}function Fc(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function Bc(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function qc(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(Fc,this),this.reset(!0)}function zc(e){if(e){var t=e[mc];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(yc.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=hc,t.done=!0,t};return r.next=r}}return{next:Wc}}function Wc(){return{value:hc,done:!0}}Cc.prototype=Mc.constructor=Oc,Oc.constructor=Cc,Oc[wc]=Cc.displayName="GeneratorFunction",Lc(Nc.prototype),Nc.prototype[bc]=function(){return this},Lc(Mc),Mc[wc]="Generator",Mc[mc]=function(){return this},Mc.toString=function(){return"[object Generator]"},qc.prototype={constructor:qc,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=hc,this.done=!1,this.delegate=null,this.method="next",this.arg=hc,this.tryEntries.forEach(Bc),!e)for(var t in this)"t"===t.charAt(0)&&yc.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=hc)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=hc),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var o=yc.call(i,"catchLoc"),s=yc.call(i,"finallyLoc");if(o&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(o){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&yc.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,Ic):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),Ic},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),Bc(n),Ic}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;Bc(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:zc(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=hc),Ic}};var Kc={wrap:kc,isGeneratorFunction:Uc,AsyncIterator:Nc,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,Oc):(e.__proto__=Oc,wc in e||(e[wc]="GeneratorFunction")),e.prototype=Object.create(Mc),e},awrap:function(e){return{__await:e}},async:function(e,t,n,r,i){void 0===i&&(i=Promise);var a=new Nc(kc(e,t,n,r),i);return Uc(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},keys:function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},values:zc},Vc=Object.freeze({__proto__:null,default:Kc});function $c(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":Pa(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function Gc(e,t){if("object"===("undefined"==typeof Reflect?"undefined":Pa(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var Jc=Tn,Hc=s,Yc=xr,Qc=E,Xc=X,Zc=Dt,el=ka,tl=Kr,nl=la,rl=U,il=he("isConcatSpreadable"),al=9007199254740991,ol="Maximum allowed index exceeded",sl=rl>=51||!Hc((function(){var e=[];return e[il]=!1,e.concat()[0]!==e})),ul=nl("concat"),cl=function(e){if(!Qc(e))return!1;var t=e[il];return void 0!==t?!!t:Yc(e)};Jc({target:"Array",proto:!0,forced:!sl||!ul},{concat:function(e){var t,n,r,i,a,o=Xc(this),s=tl(o,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(cl(a=-1===t?o:arguments[t])){if(u+(i=Zc(a.length))>al)throw TypeError(ol);for(n=0;n<i;n++,u++)n in a&&el(s,u,a[n])}else{if(u>=al)throw TypeError(ol);el(s,u++,a)}return s.length=u,s}});var ll=Fe,fl=Fo,dl=Fr,pl=X,hl=function(e,t,n,r){try{return r?t(ll(n)[0],n[1]):t(n)}catch(t){fl(e,"throw",t)}},vl=Oo,yl=Dt,gl=ka,ml=No,bl=Mo,wl=function(e){var t,n,r,i,a,o,s=pl(e),u="function"==typeof this?this:Array,c=arguments.length,l=c>1?arguments[1]:void 0,f=void 0!==l,d=bl(s),p=0;if(f&&(l=dl(l,c>2?arguments[2]:void 0,2)),null==d||u==Array&&vl(d))for(n=new u(t=yl(s.length));t>p;p++)o=f?l(s[p],p):s[p],gl(n,p,o);else for(a=(i=ml(s,d)).next,n=new u;!(r=a.call(i)).done;p++)o=f?hl(i,l,[r.value,p],!0):r.value,gl(n,p,o);return n.length=p,n},kl=wl;Tn({target:"Array",stat:!0,forced:!rs((function(e){Array.from(e)}))},{from:kl});var _l,xl,Sl,El=Lt,Rl=Er,Il=k,Tl=function(e){return function(t,n){var r,i,a=Rl(Il(t)),o=El(n),s=a.length;return o<0||o>=s?e?"":void 0:(r=a.charCodeAt(o))<55296||r>56319||o+1===s||(i=a.charCodeAt(o+1))<56320||i>57343?e?a.charAt(o):r:e?a.slice(o,o+2):i-56320+(r-55296<<10)+65536}},Cl={codeAt:Tl(!1),charAt:Tl(!0)},Ol=!s((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Pl=te,Al=X,jl=Ol,Ml=st("IE_PROTO"),Ll=Object.prototype,Ul=jl?Object.getPrototypeOf:function(e){return e=Al(e),Pl(e,Ml)?e[Ml]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?Ll:null},Nl=s,Dl=Ul,Fl=Ge,Bl=he("iterator"),ql=!1;[].keys&&("next"in(Sl=[].keys())?(xl=Dl(Dl(Sl)))!==Object.prototype&&(_l=xl):ql=!0);var zl=null==_l||Nl((function(){var e={};return _l[Bl].call(e)!==e}));zl&&(_l={}),"function"!=typeof _l[Bl]&&Fl(_l,Bl,(function(){return this}));var Wl={IteratorPrototype:_l,BUGGY_SAFARI_ITERATORS:ql},Kl=Wl.IteratorPrototype,Vl=nr,$l=v,Gl=An,Jl=Ro,Hl=function(){return this},Yl=function(e,t,n){var r=t+" Iterator";return e.prototype=Vl(Kl,{next:$l(1,n)}),Gl(e,r,!1),Jl[r]=Hl,e},Ql=Tn,Xl=Yl,Zl=Ul,ef=bo,tf=An,nf=Ge,rf=Je.exports,af=Ro,of=Wl.IteratorPrototype,sf=Wl.BUGGY_SAFARI_ITERATORS,uf=he("iterator"),cf="keys",lf="values",ff="entries",df=function(){return this},pf=function(e,t,n,r,i,a,o){Xl(n,t,r);var s,u,c,l=function(e){if(e===i&&v)return v;if(!sf&&e in p)return p[e];switch(e){case cf:case lf:case ff:return function(){return new n(this,e)}}return function(){return new n(this)}},f=t+" Iterator",d=!1,p=e.prototype,h=p[uf]||p["@@iterator"]||i&&p[i],v=!sf&&h||l(i),y="Array"==t&&p.entries||h;if(y&&(s=Zl(y.call(new e)))!==Object.prototype&&s.next&&(Zl(s)!==of&&(ef?ef(s,of):"function"!=typeof s[uf]&&nf(s,uf,df)),tf(s,f,!0)),i==lf&&h&&h.name!==lf&&(d=!0,v=function(){return h.call(this)}),p[uf]!==v&&nf(p,uf,v),af[t]=v,i)if(u={values:l(lf),keys:a?v:l(cf),entries:l(ff)},o)for(c in u)(sf||d||!(c in p))&&rf(p,c,u[c]);else Ql({target:t,proto:!0,forced:sf||d},u);return u},hf=Cl.charAt,vf=Er,yf=xt,gf=pf,mf="String Iterator",bf=yf.set,wf=yf.getterFor(mf);gf(String,"String",(function(e){bf(this,{type:mf,string:vf(e),index:0})}),(function(){var e,t=wf(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=hf(n,r),t.index+=e.length,{value:e,done:!1})}));var kf,_f,xf,Sf={exports:{}};function Ef(e,t){return["".concat((new Date).toISOString()," Conversations ").concat(e,":")].concat(Array.from(t))}_f=n,xf=function(){var e=function(){},t="undefined",n=("undefined"==typeof window?"undefined":Pa(window))!==t&&Pa(window.navigator)!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function i(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(r){return"debug"===r&&(r="log"),("undefined"==typeof console?"undefined":Pa(console))!==t&&("trace"===r&&n?a:void 0!==console[r]?i(console,r):void 0!==console.log?i(console,"log"):e)}function s(t,n){for(var i=0;i<r.length;i++){var a=r[i];this[a]=i<t?e:this.methodFactory(a,t,n)}this.log=this.debug}function u(e,n,r){return function(){("undefined"==typeof console?"undefined":Pa(console))!==t&&(s.call(this,n,r),this[e].apply(this,arguments))}}function c(e,t,n){return o(e)||u.apply(this,arguments)}function l(e,n,i){var a,o=this;n=null==n?"WARN":n;var u="loglevel";function l(){var e;if(("undefined"==typeof window?"undefined":Pa(window))!==t&&u){try{e=window.localStorage[u]}catch(e){}if(Pa(e)===t)try{var n=window.document.cookie,r=n.indexOf(encodeURIComponent(u)+"=");-1!==r&&(e=/^([^;]+)/.exec(n.slice(r))[1])}catch(e){}return void 0===o.levels[e]&&(e=void 0),e}}"string"==typeof e?u+=":"+e:"symbol"===Pa(e)&&(u=void 0),o.name=e,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=i||c,o.getLevel=function(){return a},o.setLevel=function(n,i){if("string"==typeof n&&void 0!==o.levels[n.toUpperCase()]&&(n=o.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(("undefined"==typeof window?"undefined":Pa(window))!==t&&u){try{return void(window.localStorage[u]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+n+";"}catch(e){}}}(n),s.call(o,n,e),("undefined"==typeof console?"undefined":Pa(console))===t&&n<o.levels.SILENT)return"No console available for logging"},o.setDefaultLevel=function(e){n=e,l()||o.setLevel(e,!1)},o.resetLevel=function(){o.setLevel(n,!1),function(){if(("undefined"==typeof window?"undefined":Pa(window))!==t&&u){try{return void window.localStorage.removeItem(u)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},o.enableAll=function(e){o.setLevel(o.levels.TRACE,e)},o.disableAll=function(e){o.setLevel(o.levels.SILENT,e)};var f=l();null==f&&(f=n),o.setLevel(f,!1)}var f=new l,d={};f.getLogger=function(e){if("symbol"!==Pa(e)&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=d[e];return t||(t=d[e]=new l(e,f.getLevel(),f.methodFactory)),t};var p=("undefined"==typeof window?"undefined":Pa(window))!==t?window.log:void 0;return f.noConflict=function(){return("undefined"==typeof window?"undefined":Pa(window))!==t&&window.log===f&&(window.log=p),f},f.getLoggers=function(){return d},f.default=f,f},(kf=Sf).exports?kf.exports=xf():_f.log=xf();var Rf,If,Tf=Sf.exports.getLogger("twilio-conversations"),Cf=function(){function e(t){Na(this,e),Ma(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return Ua(e,[{key:"setLevel",value:function(e){Tf.setLevel(e)}},{key:"trace",value:function(){if(Tf.getLevel()==Tf.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.debug.apply(null,Ef(this.prefix+"T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.debug.apply(null,Ef(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.info.apply(null,Ef(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.warn.apply(null,Ef(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.error.apply(null,Ef(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){Tf.setLevel(e)}},{key:"trace",value:function(){if(Tf.getLevel()==Tf.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.debug.apply(null,Ef("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.debug.apply(null,Ef("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.info.apply(null,Ef("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.warn.apply(null,Ef("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Tf.error.apply(null,Ef("E",t))}}]),e}(),Of={};Object.defineProperty(Of,"__esModule",{value:!0});var Pf=["weeks","years","months","days","hours","minutes","seconds"],Af=Of.pattern=new RegExp("P(?:(\\d+(?:[\\.,]\\d+)?W)|(\\d+(?:[\\.,]\\d+)?Y)?(\\d+(?:[\\.,]\\d+)?M)?(\\d+(?:[\\.,]\\d+)?D)?(?:T(\\d+(?:[\\.,]\\d+)?H)?(\\d+(?:[\\.,]\\d+)?M)?(\\d+(?:[\\.,]\\d+)?S)?)?)"),jf=If=Of.parse=function(e){return e.match(Af).slice(1).reduce((function(e,t,n){return e[Pf[n]]=parseFloat(t)||0,e}),{})},Mf=Of.end=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return r.setFullYear(r.getFullYear()+e.years),r.setMonth(r.getMonth()+e.months),r.setDate(r.getDate()+e.days),r.setHours(r.getHours()+e.hours),r.setMinutes(r.getMinutes()+e.minutes),r.setMilliseconds(r.getMilliseconds()+1e3*e.seconds),r.setDate(r.getDate()+7*e.weeks),r},Lf=Rf=Of.toSeconds=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return(Mf(e,r).getTime()-r.getTime())/1e3};function Uf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Nf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Uf(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Uf(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}Of.default={end:Mf,toSeconds:Lf,pattern:Af,parse:jf};var Df="PT5S",Ff="PT5S",Bf=Ua((function e(){var t,n,r,i,a,o,s,u,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=arguments.length>1?arguments[1]:void 0,f=arguments.length>2?arguments[2]:void 0;Na(this,e),Ma(this,"typingIndicatorTimeoutDefault",5e3);var d=c.Chat||c.IPMessaging||c||{};this.productId=d.productId,this.links={myConversations:l.links.my_conversations,conversations:l.links.conversations,users:l.links.users,currentUser:l.links.current_user,typing:l.links.typing,mediaService:l.links.media_service,mediaSetService:l.links.media_set_service,messagesReceipts:l.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:l.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:l.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:l.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:l.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:l.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=d.typingIndicatorTimeoutOverride,this.backoffConfiguration=Nf({min:1e3,max:4e3,maxAttemptsCount:3},d.backoffConfigOverride),this.retryWhenThrottled=void 0===d.retryWhenThrottledOverride||d.retryWhenThrottledOverride,this.userInfosToSubscribe=null!==(t=null!==(n=d.userInfosToSubscribeOverride)&&void 0!==n?n:l.options.user_infos_to_subscribe)&&void 0!==t?t:100,this.reachabilityEnabled=l.options.reachability_enabled,this.userIdentity=l.identity,this.userInfo=l.sync_objects.my_user_info,this.myConversations=l.sync_objects.my_conversations;var p=null!==(r=null!==(i=d.httpCacheIntervalOverride)&&void 0!==i?i:l.options.http_cache_interval)&&void 0!==r?r:Df;try{this.httpCacheInterval=Rf(If(p))}catch(e){f.error("Failed to parse http cache interval ".concat(p,", using default value ").concat(Df)),this.httpCacheInterval=Rf(If(Df))}var h=null!==(a=null!==(o=d.consumptionReportIntervalOverride)&&void 0!==o?o:l.options.consumption_report_interval)&&void 0!==a?a:Ff;try{this.consumptionReportInterval=Rf(If(h))}catch(e){f.error("Failed to parse consumption report interval ".concat(h,", using default value ").concat(Ff)),this.consumptionReportInterval=Rf(If(Ff))}this.channelMetadataCacheCapacity=null!==(s=c.channelMetadataCacheCapacity)&&void 0!==s?s:100,this.messageRecipientsCacheCapacity=null!==(u=c.messageRecipientsCacheCapacity)&&void 0!==u?u:1e3})),qf=nr,zf=Ne,Wf=he("unscopables"),Kf=Array.prototype;null==Kf[Wf]&&zf.f(Kf,Wf,{configurable:!0,value:qf(null)});var Vf=function(e){Kf[Wf][e]=!0},$f=S,Gf=Vf,Jf=Ro,Hf=xt,Yf=pf,Qf="Array Iterator",Xf=Hf.set,Zf=Hf.getterFor(Qf),ed=Yf(Array,"Array",(function(e,t){Xf(this,{type:Qf,target:$f(e),index:0,kind:t})}),(function(){var e=Zf(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values");Jf.Arguments=Jf.Array,Gf("keys"),Gf("values"),Gf("entries");var td=a,nd=Qa,rd=eo,id=ed,ad=Ge,od=he,sd=od("iterator"),ud=od("toStringTag"),cd=id.values,ld=function(e,t){if(e){if(e[sd]!==cd)try{ad(e,sd,cd)}catch(t){e[sd]=cd}if(e[ud]||ad(e,ud,t),nd[t])for(var n in id)if(e[n]!==id[n])try{ad(e,n,id[n])}catch(t){e[n]=id[n]}}};for(var fd in nd)ld(td[fd]&&td[fd].prototype,fd);ld(rd,"DOMTokenList");var dd=Tn,pd=s,hd=T("JSON","stringify"),vd=/[\uD800-\uDFFF]/g,yd=/^[\uD800-\uDBFF]$/,gd=/^[\uDC00-\uDFFF]$/,md=function(e,t,n){var r=n.charAt(t-1),i=n.charAt(t+1);return yd.test(e)&&!gd.test(i)||gd.test(e)&&!yd.test(r)?"\\u"+e.charCodeAt(0).toString(16):e},bd=pd((function(){return'"\\udf06\\ud834"'!==hd("\udf06\ud834")||'"\\udead"'!==hd("\udead")}));hd&&dd({target:"JSON",stat:!0,forced:bd},{stringify:function(e,t,n){var r=hd.apply(null,arguments);return"string"==typeof r?r.replace(vd,md):r}});var wd=E,kd=bo,_d=function(e,t,n){var r,i;return kd&&"function"==typeof(r=t.constructor)&&r!==n&&wd(i=r.prototype)&&i!==n.prototype&&kd(e,i),e},xd=k,Sd=Er,Ed="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Rd=RegExp("^"+Ed+Ed+"*"),Id=RegExp(Ed+Ed+"*$"),Td=function(e){return function(t){var n=Sd(xd(t));return 1&e&&(n=n.replace(Rd,"")),2&e&&(n=n.replace(Id,"")),n}},Cd={start:Td(1),end:Td(2),trim:Td(3)},Od=u,Pd=a,Ad=wn,jd=Je.exports,Md=te,Ld=g,Ud=_d,Nd=z,Dd=be,Fd=s,Bd=nr,qd=At.f,zd=o.f,Wd=Ne.f,Kd=Cd.trim,Vd="Number",$d=Pd.Number,Gd=$d.prototype,Jd=Ld(Bd(Gd))==Vd,Hd=function(e){if(Nd(e))throw TypeError("Cannot convert a Symbol value to a number");var t,n,r,i,a,o,s,u,c=Dd(e,"number");if("string"==typeof c&&c.length>2)if(43===(t=(c=Kd(c)).charCodeAt(0))||45===t){if(88===(n=c.charCodeAt(2))||120===n)return NaN}else if(48===t){switch(c.charCodeAt(1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+c}for(o=(a=c.slice(2)).length,s=0;s<o;s++)if((u=a.charCodeAt(s))<48||u>i)return NaN;return parseInt(a,r)}return+c};if(Ad(Vd,!$d(" 0o1")||!$d("0b1")||$d("+0x1"))){for(var Yd,Qd=function(e){var t=arguments.length<1?0:e,n=this;return n instanceof Qd&&(Jd?Fd((function(){Gd.valueOf.call(n)})):Ld(n)!=Vd)?Ud(new $d(Hd(t)),n,Qd):Hd(t)},Xd=Od?qd($d):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,fromString,range".split(","),Zd=0;Xd.length>Zd;Zd++)Md($d,Yd=Xd[Zd])&&!Md(Qd,Yd)&&Wd(Qd,Yd,zd($d,Yd));Qd.prototype=Gd,Gd.constructor=Qd,jd(Pd,Vd,Qd)}var ep=Fe,tp=function(){var e=ep(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t},np={},rp=s,ip=a.RegExp;np.UNSUPPORTED_Y=rp((function(){var e=ip("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),np.BROKEN_CARET=rp((function(){var e=ip("^r","gy");return e.lastIndex=2,null!=e.exec("str")}));var ap,op,sp=s,up=a.RegExp,cp=sp((function(){var e=up(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),lp=s,fp=a.RegExp,dp=lp((function(){var e=fp("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),pp=Er,hp=tp,vp=np,yp=K.exports,gp=nr,mp=xt.get,bp=cp,wp=dp,kp=RegExp.prototype.exec,_p=yp("native-string-replace",String.prototype.replace),xp=kp,Sp=(ap=/a/,op=/b*/g,kp.call(ap,"a"),kp.call(op,"a"),0!==ap.lastIndex||0!==op.lastIndex),Ep=vp.UNSUPPORTED_Y||vp.BROKEN_CARET,Rp=void 0!==/()??/.exec("")[1];(Sp||Rp||Ep||bp||wp)&&(xp=function(e){var t,n,r,i,a,o,s,u=this,c=mp(u),l=pp(e),f=c.raw;if(f)return f.lastIndex=u.lastIndex,t=xp.call(f,l),u.lastIndex=f.lastIndex,t;var d=c.groups,p=Ep&&u.sticky,h=hp.call(u),v=u.source,y=0,g=l;if(p&&(-1===(h=h.replace("y","")).indexOf("g")&&(h+="g"),g=l.slice(u.lastIndex),u.lastIndex>0&&(!u.multiline||u.multiline&&"\n"!==l.charAt(u.lastIndex-1))&&(v="(?: "+v+")",g=" "+g,y++),n=new RegExp("^(?:"+v+")",h)),Rp&&(n=new RegExp("^"+v+"$(?!\\s)",h)),Sp&&(r=u.lastIndex),i=kp.call(p?n:u,g),p?i?(i.input=i.input.slice(y),i[0]=i[0].slice(y),i.index=u.lastIndex,u.lastIndex+=i[0].length):u.lastIndex=0:Sp&&i&&(u.lastIndex=u.global?i.index+i[0].length:r),Rp&&i&&i.length>1&&_p.call(i[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(i[a]=void 0)})),i&&d)for(i.groups=o=gp(null),a=0;a<d.length;a++)o[(s=d[a])[0]]=i[s[1]];return i});var Ip=xp;Tn({target:"RegExp",proto:!0,forced:/./.exec!==Ip},{exec:Ip});var Tp=Je.exports,Cp=Ip,Op=s,Pp=he,Ap=Ge,jp=Pp("species"),Mp=RegExp.prototype,Lp=function(e,t,n,r){var i=Pp(e),a=!Op((function(){var t={};return t[i]=function(){return 7},7!=""[e](t)})),o=a&&!Op((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[jp]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return t=!0,null},n[i](""),!t}));if(!a||!o||n){var s=/./[i],u=t(i,""[e],(function(e,t,n,r,i){var o=t.exec;return o===Cp||o===Mp.exec?a&&!i?{done:!0,value:s.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}));Tp(String.prototype,e,u[0]),Tp(Mp,i,u[1])}r&&Ap(Mp[i],"sham",!0)},Up=Cl.charAt,Np=function(e,t,n){return t+(n?Up(e,t).length:1)},Dp=X,Fp=Math.floor,Bp="".replace,qp=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,zp=/\$([$&'`]|\d{1,2})/g,Wp=g,Kp=Ip,Vp=function(e,t){var n=e.exec;if("function"==typeof n){var r=n.call(e,t);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==Wp(e))throw TypeError("RegExp#exec called on incompatible receiver");return Kp.call(e,t)},$p=Lp,Gp=s,Jp=Fe,Hp=Lt,Yp=Dt,Qp=Er,Xp=k,Zp=Np,eh=function(e,t,n,r,i,a){var o=n+e.length,s=r.length,u=zp;return void 0!==i&&(i=Dp(i),u=qp),Bp.call(a,u,(function(a,u){var c;switch(u.charAt(0)){case"$":return"$";case"&":return e;case"`":return t.slice(0,n);case"'":return t.slice(o);case"<":c=i[u.slice(1,-1)];break;default:var l=+u;if(0===l)return a;if(l>s){var f=Fp(l/10);return 0===f?a:f<=s?void 0===r[f-1]?u.charAt(1):r[f-1]+u.charAt(1):a}c=r[l-1]}return void 0===c?"":c}))},th=Vp,nh=he("replace"),rh=Math.max,ih=Math.min,ah="$0"==="a".replace(/./,"$0"),oh=!!/./[nh]&&""===/./[nh]("a","$0"),sh=!Gp((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));$p("replace",(function(e,t,n){var r=oh?"$":"$0";return[function(e,n){var r=Xp(this),i=null==e?void 0:e[nh];return void 0!==i?i.call(e,r,n):t.call(Qp(r),e,n)},function(e,i){var a=Jp(this),o=Qp(e);if("string"==typeof i&&-1===i.indexOf(r)&&-1===i.indexOf("$<")){var s=n(t,a,o,i);if(s.done)return s.value}var u="function"==typeof i;u||(i=Qp(i));var c=a.global;if(c){var l=a.unicode;a.lastIndex=0}for(var f=[];;){var d=th(a,o);if(null===d)break;if(f.push(d),!c)break;""===Qp(d[0])&&(a.lastIndex=Zp(o,Yp(a.lastIndex),l))}for(var p,h="",v=0,y=0;y<f.length;y++){d=f[y];for(var g=Qp(d[0]),m=rh(ih(Hp(d.index),o.length),0),b=[],w=1;w<d.length;w++)b.push(void 0===(p=d[w])?p:String(p));var k=d.groups;if(u){var _=[g].concat(b,m,o);void 0!==k&&_.push(k);var x=Qp(i.apply(void 0,_))}else x=eh(g,o,m,b,k,i);m>=v&&(h+=o.slice(v,m)+x,v=m+g.length)}return h+o.slice(v)}]}),!sh||!ah||oh);var uh=Tn,ch=S,lh=[].join,fh=w!=Object,dh=no("join",",");function ph(e){return JSON.parse(JSON.stringify(e))}function hh(e){return void 0===e||isNaN(Number(e))?null:Number(e)}function vh(e){try{return new Date(e)}catch(e){return null}}function yh(e,t,n){var r={};if(e)try{r=JSON.parse(e)}catch(e){n.warn(t,e)}return r}uh({target:"Array",proto:!0,forced:fh||!dh},{join:function(e){return lh.call(ch(this),void 0===e?",":e)}});var gh=function(){function e(t){Na(this,e),this.base=t.replace(/\/$/,""),this.args=[],this.paths=[]}return Ua(e,[{key:"arg",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"path",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}();function mh(e,t){if(e===t)return!0;if(null===e||null===t||void 0===e||void 0===t)return e===t;if(Pa(e)!==Pa(t))return!1;if("object"!==Pa(e))return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((function(e,n){return mh(e,t[n])}));if(Array.isArray(e)||Array.isArray(t))return!1;var n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every((function(n){return mh(e[n],t[n])}))}var bh={},wh={exports:{}};!function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(wh);var kh=u,_h=Ne.f,xh=Function.prototype,Sh=xh.toString,Eh=/^\s*function ([^ (]*)/,Rh="name";kh&&!(Rh in xh)&&_h(xh,Rh,{configurable:!0,get:function(){try{return Sh.call(this).match(Eh)[1]}catch(e){return""}}});var Ih={exports:{}},Th={exports:{}};!function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}(Th);var Ch={exports:{}};!function(e){e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a=[],o=!0,s=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports}(Ch);var Oh={exports:{}},Ph={exports:{}};!function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports}(Ph),function(e){var t=Ph.exports;e.exports=function(e,n){if(e){if("string"==typeof e)return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}(Oh);var Ah={exports:{}};!function(e){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}(Ah),function(e){var t=Th.exports,n=Ch.exports,r=Oh.exports,i=Ah.exports;e.exports=function(e,a){return t(e)||n(e,a)||r(e,a)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(Ih);var jh=Tn,Mh=E,Lh=xr,Uh=zt,Nh=Dt,Dh=S,Fh=ka,Bh=he,qh=la("slice"),zh=Bh("species"),Wh=[].slice,Kh=Math.max;jh({target:"Array",proto:!0,forced:!qh},{slice:function(e,t){var n,r,i,a=Dh(this),o=Nh(a.length),s=Uh(e,o),u=Uh(void 0===t?o:t,o);if(Lh(a)&&("function"!=typeof(n=a.constructor)||n!==Array&&!Lh(n.prototype)?Mh(n)&&null===(n=n[zh])&&(n=void 0):n=void 0,n===Array||void 0===n))return Wh.call(a,s,u);for(r=new(void 0===n?Array:n)(Kh(u-s,0)),i=0;s<u;s++,i++)s in a&&Fh(r,i,a[s]);return r.length=i,r}});var Vh=Tn,$h=E,Gh=function(){var e=!1,t=/[ac]/;return t.exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e}(),Jh=/./.test;Vh({target:"RegExp",proto:!0,forced:!Gh},{test:function(e){if("function"!=typeof this.exec)return Jh.call(this,e);var t=this.exec(e);if(null!==t&&!$h(t))throw new Error("RegExp exec method returned something other than an Object or null");return!!t}});var Hh=Tn,Yh=u,Qh=a,Xh=te,Zh=E,ev=Ne.f,tv=dn,nv=Qh.Symbol;if(Yh&&"function"==typeof nv&&(!("description"in nv.prototype)||void 0!==nv().description)){var rv={},iv=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof iv?new nv(e):void 0===e?nv():nv(e);return""===e&&(rv[t]=!0),t};tv(iv,nv);var av=iv.prototype=nv.prototype;av.constructor=iv;var ov=av.toString,sv="Symbol(test)"==String(nv("test")),uv=/^Symbol\((.*)\)[^)]+$/;ev(av,"description",{configurable:!0,get:function(){var e=Zh(this)?this.valueOf():this,t=ov.call(e);if(Xh(rv,e))return"";var n=sv?t.slice(7,-1):t.replace(uv,"$1");return""===n?void 0:n}}),Hh({global:!0,forced:!0},{Symbol:iv})}Nr("iterator");var cv={exports:{}},lv={exports:{}};!function(e){var t=Ph.exports;e.exports=function(e){if(Array.isArray(e))return t(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(lv);var fv={exports:{}};!function(e){e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(fv);var dv={exports:{}};!function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports}(dv),function(e){var t=lv.exports,n=fv.exports,r=Oh.exports,i=dv.exports;e.exports=function(e){return t(e)||n(e)||r(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(cv);var pv={exports:{}};!function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports}(pv);var hv={exports:{}};!function(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports}(hv);var vv={exports:{}},yv={exports:{}};!function(e){function t(n,r){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(yv),function(e){var t=yv.exports;e.exports=function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&t(e,n)},e.exports.__esModule=!0,e.exports.default=e.exports}(vv);var gv={exports:{}},mv={exports:{}};!function(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports}(mv),function(e){var t=wh.exports.default,n=mv.exports;e.exports=function(e,r){if(r&&("object"===t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(gv);var bv={exports:{}};!function(e){function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(bv);var wv=Gt.includes,kv=Vf;Tn({target:"Array",proto:!0},{includes:function(e){return wv(this,e,arguments.length>1?arguments[1]:void 0)}}),kv("includes");var _v=E,xv=Math.floor,Sv=function(e){return!_v(e)&&isFinite(e)&&xv(e)===e};Tn({target:"Number",stat:!0},{isInteger:Sv});var Ev=u,Rv=Fn,Iv=S,Tv=c.f,Cv=function(e){return function(t){for(var n,r=Iv(t),i=Rv(r),a=i.length,o=0,s=[];a>o;)n=i[o++],Ev&&!Tv.call(r,n)||s.push(e?[n,r[n]]:r[n]);return s}},Ov={entries:Cv(!0),values:Cv(!1)}.entries;Tn({target:"Object",stat:!0},{entries:function(e){return Ov(e)}}),Object.defineProperty(bh,"__esModule",{value:!0});var Pv=Ih.exports,Av=cv.exports,jv=pv.exports,Mv=hv.exports,Lv=vv.exports,Uv=gv.exports,Nv=bv.exports;function Dv(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var Fv=Dv(wh.exports),Bv=Dv(Pv),qv=Dv(Av),zv=Dv(jv),Wv=Dv(Mv),Kv=Dv(Lv),Vv=Dv(Uv),$v=Dv(Nv),Gv=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return{checks:t}},Jv=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Gv((function(e){for(var n=!1,r=[],i=0,a=t;i<a.length;i++){var o=a[i];"string"!=typeof o?(n=n||e instanceof o,r.push("an instance of ".concat(o.name))):(n=n||Fv.default(e)===o,r.push("of type ".concat(o)))}return[n,r]}))};function Hv(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=$v.default(e);if(t){var i=$v.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Vv.default(this,n)}}function Yv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Qv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Qv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Qv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Xv=function(e,t){if(t.length>e.length)throw new Error("Expected at most ".concat(e.length," argument(s), but got ").concat(t.length));for(;t.length<e.length;)t.push(void 0);var n,r=Yv(t.entries());try{for(r.s();!(n=r.n()).done;){var i=Bv.default(n.value,2),a=i[0],o=i[1],s=ny(e[a],o),u=Bv.default(s,4),c=u[0],l=u[1],f=u[2],d=u[3];if(!c)throw new Error("Argument ".concat(a+1," is expected to be ").concat(f).concat(d," but got ").concat(l))}}catch(e){r.e(e)}finally{r.f()}},Zv=function(e){var t,n,r;(["undefined","boolean","number","bigint","string"].includes(Fv.default(e))&&(n="string"==typeof e?'"'.concat(e,'"'):"".concat(e)),"object"===Fv.default(e)&&"Object"!==(null==e||null===(t=e.constructor)||void 0===t?void 0:t.name))&&(n=null===e?"null":"instance of ".concat(null==e||null===(r=e.constructor)||void 0===r?void 0:r.name));return n||(n=Fv.default(e)),n},ey=function(e){var t,n=[],r=Yv(e);try{for(r.s();!(t=r.n()).done;){var i=t.value;n.push(ty(i))}}catch(e){r.e(e)}finally{r.f()}return n},ty=function(e){var t,n=[],r=Yv(Array.isArray(e)?e:[e]);try{for(r.s();!(t=r.n()).done;){var i=t.value;"string"!=typeof i&&"function"!=typeof i?n.push(i):n.push(Jv(i))}}catch(e){r.e(e)}finally{r.f()}return n},ny=function(e,t){var n,r,i=[],a=!1,o=Yv(e);try{for(o.s();!(r=o.n()).done;){var s,u=Yv(r.value.checks);try{for(u.s();!(s=u.n()).done;){var c=(0,s.value)(t),l=Bv.default(c,3),f=l[0],d=l[1],p=l[2];a=a||f,!n&&p&&(n=p),d&&(i=[].concat(qv.default(i),"string"==typeof d?[d]:qv.default(d)))}}catch(e){u.e(e)}finally{u.f()}}}catch(e){o.e(e)}finally{o.f()}if(a)return[!0];var h=n||Zv(t),v=i.length-1;return[!1,h,v>0?"".concat(i.slice(0,v).join(", ")," or ").concat(i[v]):i.join(", "),v>1?";":","]};function ry(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return iy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return iy(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function iy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ay=Gv((function(e){return["string"==typeof e&&e.length>0,"a non-empty string"]})),oy=Gv((function(e){return["number"==typeof e&&Number.isInteger(e)&&e>=0,"a non-negative integer"]})),sy=Gv((function(e){return["object"===Fv.default(e)&&null!==e&&!Array.isArray(e),"a pure object (non-null and non-array)"]}));function uy(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cy(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function cy(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ly=bh.array=function(e,t){return Gv((function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(e)];var r,i=uy(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Bv.default(r.value,2),o=a[0],s=a[1],u=ny(ty(t),s),c=Bv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid array of ".concat(e," (index ").concat(o," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},fy=bh.custom=Gv,dy=bh.literal=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Gv((function(e){for(var n=!1,r=[],i=0,a=t;i<a.length;i++){var o=a[i];n=n||e===o,r.push("string"==typeof o?'"'.concat(o,'"'):"".concat(o))}return[n,r]}))},py=bh.nonEmptyArray=function(e,t){return Gv((function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(e)];var r,i=ry(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Bv.default(r.value,2),o=a[0],s=a[1],u=ny(ty(t),s),c=Bv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid non-empty array of ".concat(e," (index ").concat(o," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(o," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},hy=bh.nonEmptyString=ay,vy=bh.nonNegativeInteger=oy,yy=bh.objectSchema=function(e,t){return Gv((function(n){if("object"!==Fv.default(n)||null===n||Array.isArray(n))return[!1,"valid ".concat(e," (should be a pure object)")];for(var r=0,i=Object.entries(t);r<i.length;r++){var a=Bv.default(i[r],2),o=a[0],s=a[1],u=ny(ty(s),n[o]),c=Bv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"valid ".concat(e,' (key "').concat(o,'" should be ').concat(d,")"),"malformed ".concat(e,' (key "').concat(o,'" is ').concat(f,")")]}return[!0]}))},gy=bh.pureObject=sy;bh.runtimeTypeValidation=Xv,bh.stringifyReceivedType=Zv,bh.type=Jv;var my=bh.validateConstructorTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=ey(t);return function(e){return function(e){Kv.default(n,e);var t=Hv(n);function n(){Wv.default(this,n);for(var e=arguments.length,i=new Array(e),a=0;a<e;a++)i[a]=arguments[a];return Xv(r,i),t.call.apply(t,[this].concat(i))}return zv.default(n)}(e)}},by=bh.validateTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=ey(t);return function(e,t,n){if("function"!=typeof n.value)throw new Error("The validateTypes decorator can only be applied to methods");var i=n.value;n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Xv(r,t),i.apply(this,t)}}},wy=bh.validateTypesAsync=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=ey(t);return function(e,t,n){if("function"!=typeof n.value)throw new Error("The validateTypesAsync decorator can only be applied to methods");var i=n.value;n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];try{Xv(r,t)}catch(e){return Promise.reject(e)}return i.apply(this,t)}}};function ky(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _y(e,t){if(e){if("string"==typeof e)return ky(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ky(e,t):void 0}}function xy(e){return function(e){if(Array.isArray(e))return ky(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Sy=fy((function(e){return[["string","number","boolean","object"].includes(Pa(e)),"a JSON type"]})),Ey=fy((function(e){return[["undefined","string","number","boolean","object"].includes(Pa(e)),"an optional JSON type"]})),Ry=yy("send media options",{contentType:[dy(null),"string"],filename:["string","undefined"],media:[dy("null"),"string"].concat(xy("function"==typeof Buffer?[Buffer]:[]),xy("function"==typeof Blob?[Blob]:[]))}),Iy={},Ty={exports:{}},Cy={exports:{}};!function(e){var t=bv.exports;e.exports=function(e,n){for(;!Object.prototype.hasOwnProperty.call(e,n)&&null!==(e=t(e)););return e},e.exports.__esModule=!0,e.exports.default=e.exports}(Cy),function(e){var t=Cy.exports;function n(){return"undefined"!=typeof Reflect&&Reflect.get?(e.exports=n=Reflect.get,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=n=function(e,n,r){var i=t(e,n);if(i){var a=Object.getOwnPropertyDescriptor(i,n);return a.get?a.get.call(arguments.length<3?e:r):a.value}},e.exports.__esModule=!0,e.exports.default=e.exports),n.apply(this,arguments)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(Ty);var Oy={exports:{}};!function(e){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports}(Oy),Object.defineProperty(Iy,"__esModule",{value:!0});var Py=hv.exports,Ay=pv.exports,jy=mv.exports,My=Ty.exports,Ly=vv.exports,Uy=gv.exports,Ny=bv.exports,Dy=Oy.exports;function Fy(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var By=Fy(cv.exports),qy=Fy(Py),zy=Fy(Ay),Wy=Fy(jy),Ky=Fy(My),Vy=Fy(Ly),$y=Fy(Uy),Gy=Fy(Ny),Jy=Fy(Dy);function Hy(){}function Yy(){Yy.init.call(this)}function Qy(e){return void 0===e._maxListeners?Yy.defaultMaxListeners:e._maxListeners}function Xy(e,t,n){if(t)e.call(n);else for(var r=e.length,i=og(e,r),a=0;a<r;++a)i[a].call(n)}function Zy(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=og(e,i),o=0;o<i;++o)a[o].call(n,r)}function eg(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=og(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function tg(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=og(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function ng(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=og(e,i),o=0;o<i;++o)a[o].apply(n,r)}function rg(e,t,n,r){var i,a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new Hy,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=Qy(e))&&i>0&&o.length>i){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else o=a[t]=n,++e._eventsCount;return e}function ig(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function ag(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function og(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function sg(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Gy.default(e);if(t){var i=Gy.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return $y.default(this,n)}}Hy.prototype=Object.create(null),Yy.EventEmitter=Yy,Yy.usingDomains=!1,Yy.prototype.domain=void 0,Yy.prototype._events=void 0,Yy.prototype._maxListeners=void 0,Yy.defaultMaxListeners=10,Yy.init=function(){this.domain=null,Yy.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Hy,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Yy.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Yy.prototype.getMaxListeners=function(){return Qy(this)},Yy.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:Xy(n,l,this);break;case 2:Zy(n,l,this,arguments[1]);break;case 3:eg(n,l,this,arguments[1],arguments[2]);break;case 4:tg(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];ng(n,l,this,i)}return!0},Yy.prototype.addListener=function(e,t){return rg(this,e,t,!1)},Yy.prototype.on=Yy.prototype.addListener,Yy.prototype.prependListener=function(e,t){return rg(this,e,t,!0)},Yy.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,ig(this,e,t)),this},Yy.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,ig(this,e,t)),this},Yy.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new Hy:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new Hy,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},Yy.prototype.off=function(e,t){return this.removeListener(e,t)},Yy.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Hy,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new Hy:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new Hy,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Yy.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},Yy.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):ag.call(e,t)},Yy.prototype.listenerCount=ag,Yy.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var ug=function(e){Vy.default(n,e);var t=sg(n);function n(){var e;return qy.default(this,n),e=t.call(this),Jy.default(Wy.default(e),"eventHistory",new Map),e}return zy.default(n,[{key:"on",value:function(e,t){return Ky.default(Gy.default(n.prototype),"on",this).call(this,e,t)}},{key:"once",value:function(e,t){return Ky.default(Gy.default(n.prototype),"once",this).call(this,e,t)}},{key:"off",value:function(e,t){return Ky.default(Gy.default(n.prototype),"off",this).call(this,e,t)}},{key:"emit",value:function(e){for(var t,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return this.eventHistory.set(e,i),(t=Ky.default(Gy.default(n.prototype),"emit",this)).call.apply(t,[this,e].concat(i))}},{key:"addListener",value:function(e,t){return Ky.default(Gy.default(n.prototype),"addListener",this).call(this,e,t)}},{key:"removeListener",value:function(e,t){return Ky.default(Gy.default(n.prototype),"removeListener",this).call(this,e,t)}},{key:"addListenerWithReplay",value:function(e,t){var n=this.eventHistory.get(e);return void 0!==n&&t.apply(void 0,By.default(n)),this.addListener(e,t)}},{key:"onWithReplay",value:function(e,t){return this.addListenerWithReplay(e,t)}},{key:"onceWithReplay",value:function(e,t){var r=this.eventHistory.get(e);return void 0!==r?(t.apply(void 0,By.default(r)),this):Ky.default(Gy.default(n.prototype),"once",this).call(this,e,t)}}]),n}(Yy),cg=Iy.ReplayEventEmitter=ug;function lg(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}var fg=Cf.scope("User"),User=function(e){Oa(User,e);var t,n,r,i,a,o,s,u=lg(User);function User(e,t,n,r){var i;return Na(this,User),Ma(Ta(i=u.call(this)),"promiseToFetch",null),Ma(Ta(i),"updated","updated"),Ma(Ta(i),"userSubscribed","userSubscribed"),Ma(Ta(i),"userUnsubscribed","userUnsubscribed"),i.services=r,i.subscribed="initializing",i.setMaxListeners(0),i.state={identity:e,entityName:t,friendlyName:null,attributes:{},online:null,notifiable:null},i._initializationPromise=new Promise((function(e){i._resolveInitializationPromise=e})),null!==n&&i._resolveInitialization(n,e,t,!1),i}return Ua(User,[{key:"identity",get:function(){return this.state.identity},set:function(e){this.state.identity=e}},{key:"entityName",set:function(e){this.state.entityName=e}},{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"subscribed"==this.subscribed}},{key:"_update",value:(s=Ia(Kc.mark((function e(t,n){var r,i;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:r=[],fg.debug("User for",this.state.identity,"updated:",t,n),e.t0=t,e.next="friendlyName"===e.t0?7:"attributes"===e.t0?9:"reachability"===e.t0?12:15;break;case 7:return this.state.friendlyName!==n.value&&(r.push("friendlyName"),this.state.friendlyName=n.value),e.abrupt("break",16);case 9:return i=yh(n.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),fg),mh(this.state.attributes,i)||(this.state.attributes=i,r.push("attributes")),e.abrupt("break",16);case 12:return this.state.online!==n.online&&(this.state.online=n.online,r.push("reachabilityOnline")),this.state.notifiable!==n.notifiable&&(this.state.notifiable=n.notifiable,r.push("reachabilityNotifiable")),e.abrupt("break",16);case 15:return e.abrupt("return");case 16:r.length>0&&this.emit("updated",{user:this,updateReasons:r});case 17:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_updateReachabilityInfo",value:(o=Ia(Kc.mark((function e(t,n){var r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){e.next=4;break}return e.abrupt("return",Promise.resolve());case 4:return e.abrupt("return",t.get("reachability").then(n).catch((function(e){fg.warn("Failed to get reachability info for ",r.state.identity,e)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"_fetch",value:(a=Ia(Kc.mark((function e(){var t=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(this.state.entityName){e.next=4;break}return e.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then((function(e){return t.entity=e,e.on("itemUpdated",(function(e){return fg.debug(t.state.entityName+" ("+t.state.identity+") itemUpdated: "+e.item.key),t._update(e.item.key,e.item.data)})),e.on("itemAdded",(function(e){return fg.debug(t.state.entityName+" ("+t.state.identity+") itemAdded: "+e.item.key),t._update(e.item.key,e.item.data)})),Promise.all([e.get("friendlyName").then((function(e){return t._update(e.key,e.data)})),e.get("attributes").then((function(e){return t._update(e.key,e.data)})),t._updateReachabilityInfo(e,(function(e){return t._update(e.key,e.data)}))])})).then((function(){return fg.debug("Fetched for",t.identity),t.subscribed="subscribed",t.emit("userSubscribed",t),t})).catch((function(e){throw t.promiseToFetch=null,e})),e.abrupt("return",this.promiseToFetch);case 6:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_ensureFetched",value:(i=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:return e.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateAttributes",value:(r=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if("unsubscribed"!=this.subscribed){e.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return e.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(t)});case 6:return e.abrupt("return",this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"updateFriendlyName",value:(n=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if("unsubscribed"!=this.subscribed){e.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return e.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:t});case 6:return e.abrupt("return",this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribe",value:(t=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){e.next=9;break}return e.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_resolveInitialization",value:function(e,t,n,r){this.configuration=e,this.identity=t,this.entityName=n,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),r&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),User}(cg);function dg(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a=[],o=!0,s=!1;try{for(n=n.call(e);!(o=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}}(e,t)||_y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}$c([wy(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],User.prototype,"updateAttributes",null),$c([wy(["string"]),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],User.prototype,"updateFriendlyName",null);var pg={exports:{}},hg=!s((function(){return Object.isExtensible(Object.preventExtensions({}))})),vg=Tn,yg=ut,gg=E,mg=te,bg=Ne.f,wg=At,kg=Rr,_g=hg,xg=!1,Sg=ie("meta"),Eg=0,Rg=Object.isExtensible||function(){return!0},Ig=function(e){bg(e,Sg,{value:{objectID:"O"+Eg++,weakData:{}}})},Tg=pg.exports={enable:function(){Tg.enable=function(){},xg=!0;var e=wg.f,t=[].splice,n={};n[Sg]=1,e(n).length&&(wg.f=function(n){for(var r=e(n),i=0,a=r.length;i<a;i++)if(r[i]===Sg){t.call(r,i,1);break}return r},vg({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:kg.f}))},fastKey:function(e,t){if(!gg(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!mg(e,Sg)){if(!Rg(e))return"F";if(!t)return"E";Ig(e)}return e[Sg].objectID},getWeakData:function(e,t){if(!mg(e,Sg)){if(!Rg(e))return!0;if(!t)return!1;Ig(e)}return e[Sg].weakData},onFreeze:function(e){return _g&&xg&&Rg(e)&&!mg(e,Sg)&&Ig(e),e}};yg[Sg]=!0;var Cg=Tn,Og=a,Pg=wn,Ag=Je.exports,jg=pg.exports,Mg=Jo,Lg=Eo,Ug=E,Ng=s,Dg=rs,Fg=An,Bg=_d,qg=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),a=r?"set":"add",o=Og[e],s=o&&o.prototype,u=o,c={},l=function(e){var t=s[e];Ag(s,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!Ug(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return i&&!Ug(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!Ug(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(Pg(e,"function"!=typeof o||!(i||s.forEach&&!Ng((function(){(new o).entries().next()})))))u=n.getConstructor(t,e,r,a),jg.enable();else if(Pg(e,!0)){var f=new u,d=f[a](i?{}:-0,1)!=f,p=Ng((function(){f.has(1)})),h=Dg((function(e){new o(e)})),v=!i&&Ng((function(){for(var e=new o,t=5;t--;)e[a](t,t);return!e.has(-0)}));h||((u=t((function(t,n){Lg(t,u,e);var i=Bg(new o,t,u);return null!=n&&Mg(n,i[a],{that:i,AS_ENTRIES:r}),i}))).prototype=s,s.constructor=u),(p||v)&&(l("delete"),l("has"),r&&l("get")),(v||d)&&l(a),i&&s.clear&&delete s.clear}return c[e]=u,Cg({global:!0,forced:u!=o},c),Fg(u,e),i||n.setStrong(u,e,r),u},zg=Ne.f,Wg=nr,Kg=vo,Vg=Fr,$g=Eo,Gg=Jo,Jg=pf,Hg=So,Yg=u,Qg=pg.exports.fastKey,Xg=xt.set,Zg=xt.getterFor,em={getConstructor:function(e,t,n,r){var i=e((function(e,a){$g(e,i,t),Xg(e,{type:t,index:Wg(null),first:void 0,last:void 0,size:0}),Yg||(e.size=0),null!=a&&Gg(a,e[r],{that:e,AS_ENTRIES:n})})),a=Zg(t),o=function(e,t,n){var r,i,o=a(e),u=s(e,t);return u?u.value=n:(o.last=u={index:i=Qg(t,!0),key:t,value:n,previous:r=o.last,next:void 0,removed:!1},o.first||(o.first=u),r&&(r.next=u),Yg?o.size++:e.size++,"F"!==i&&(o.index[i]=u)),e},s=function(e,t){var n,r=a(e),i=Qg(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return Kg(i.prototype,{clear:function(){for(var e=a(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,Yg?e.size=0:this.size=0},delete:function(e){var t=this,n=a(t),r=s(t,e);if(r){var i=r.next,o=r.previous;delete n.index[r.index],r.removed=!0,o&&(o.next=i),i&&(i.previous=o),n.first==r&&(n.first=i),n.last==r&&(n.last=o),Yg?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=a(this),r=Vg(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!s(this,e)}}),Kg(i.prototype,n?{get:function(e){var t=s(this,e);return t&&t.value},set:function(e,t){return o(this,0===e?0:e,t)}}:{add:function(e){return o(this,e=0===e?0:e,e)}}),Yg&&zg(i.prototype,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=Zg(t),a=Zg(r);Jg(e,t,(function(e,t){Xg(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),Hg(t)}};qg("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),em);var tm={};Object.defineProperty(tm,"__esModule",{value:!0});var nm=pv.exports,rm=mv.exports,im=vv.exports,am=gv.exports,om=bv.exports,sm=Oy.exports;function um(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var cm=um(hv.exports),lm=um(nm),fm=um(rm),dm=um(im),pm=um(am),hm=um(om),vm=um(sm);function ym(){}function gm(){gm.init.call(this)}function mm(e){return void 0===e._maxListeners?gm.defaultMaxListeners:e._maxListeners}function bm(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Im(e,r),a=0;a<r;++a)i[a].call(n)}function wm(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=Im(e,i),o=0;o<i;++o)a[o].call(n,r)}function km(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=Im(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function _m(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=Im(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function xm(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=Im(e,i),o=0;o<i;++o)a[o].apply(n,r)}function Sm(e,t,n,r){var i,a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new ym,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=mm(e))&&i>0&&o.length>i){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else o=a[t]=n,++e._eventsCount;return e}function Em(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function Rm(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function Im(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function Tm(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=hm.default(e);if(t){var i=hm.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pm.default(this,n)}}ym.prototype=Object.create(null),gm.EventEmitter=gm,gm.usingDomains=!1,gm.prototype.domain=void 0,gm.prototype._events=void 0,gm.prototype._maxListeners=void 0,gm.defaultMaxListeners=10,gm.init=function(){this.domain=null,gm.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new ym,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},gm.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},gm.prototype.getMaxListeners=function(){return mm(this)},gm.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:bm(n,l,this);break;case 2:wm(n,l,this,arguments[1]);break;case 3:km(n,l,this,arguments[1],arguments[2]);break;case 4:_m(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];xm(n,l,this,i)}return!0},gm.prototype.addListener=function(e,t){return Sm(this,e,t,!1)},gm.prototype.on=gm.prototype.addListener,gm.prototype.prependListener=function(e,t){return Sm(this,e,t,!0)},gm.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Em(this,e,t)),this},gm.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Em(this,e,t)),this},gm.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new ym:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new ym,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},gm.prototype.off=function(e,t){return this.removeListener(e,t)},gm.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new ym,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new ym:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new ym,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},gm.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},gm.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Rm.call(e,t)},gm.prototype.listenerCount=Rm,gm.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Cm=function(e){dm.default(n,e);var t=Tm(n);function n(e){var r;return cm.default(this,n),r=t.call(this),vm.default(fm.default(r),"timeout",null),vm.default(fm.default(r),"startTimestamp",-1),r.minDelay=e.min,r.maxDelay=e.max,r.initialDelay=e.initial||0,r.maxAttemptsCount=e.maxAttemptsCount||0,r.maxAttemptsTime=e.maxAttemptsTime||0,r.randomness=e.randomness||0,r.inProgress=!1,r.attemptNum=0,r.prevDelay=0,r.currDelay=0,r}return lm.default(n,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(e){if("number"==typeof e)return this.prevDelay=0,this.currDelay=e,e;if(0==this.attemptNum)return this.initialDelay;if(1==this.attemptNum)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var t=this.currDelay+this.prevDelay;return this.maxDelay&&t>this.maxDelay&&(this.currDelay=this.maxDelay,t=this.maxDelay),this.currDelay=t,t}},{key:"randomize",value:function(e){var t=e*this.randomness,n=Math.round(Math.random()*t*2-t);return Math.max(0,e+n)}},{key:"scheduleAttempt",value:function(e){var t=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt count limit reached"));var n=this.nextDelay(e);if(n=this.randomize(n),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+n)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt time limit reached"));this.timeout=setTimeout((function(){return t.attempt()}),n)}},{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(e){this.emit("succeeded",e)}},{key:"failed",value:function(e,t){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(t)}}]),n}(gm),Om=function(e){dm.default(n,e);var t=Tm(n);function n(e){var r;return cm.default(this,n),r=t.call(this),vm.default(fm.default(r),"resolve",(function(){})),vm.default(fm.default(r),"reject",(function(){})),r.retrier=new Cm(e),r}return lm.default(n,[{key:"run",value:function(e){var t=this;return this.retrier.on("attempt",(function(){e().then((function(e){return t.retrier.succeeded(e)})).catch((function(e){return t.retrier.failed(e)}))})),this.retrier.on("succeeded",(function(e){return t.resolve(e)})),this.retrier.on("cancelled",(function(){return t.reject(new Error("Cancelled"))})),this.retrier.on("failed",(function(e){return t.reject(e)})),new Promise((function(e,n){t.resolve=e,t.reject=n,t.retrier.start()}))}},{key:"cancel",value:function(){this.retrier.cancel()}}]),n}(gm);function Pm(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=hm.default(e);if(t){var i=hm.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return pm.default(this,n)}}function Am(e){return null!=e}var jm=function(e){dm.default(n,e);var t=Pm(n);function n(e){var r;cm.default(this,n),r=t.call(this),vm.default(fm.default(r),"backoffDelay",0),vm.default(fm.default(r),"nextBackoffDelay",0),vm.default(fm.default(r),"backoffNumber",0),vm.default(fm.default(r),"timeoutID",null),vm.default(fm.default(r),"maxNumberOfRetry",-1);var i=e=e||{},a=i.initialDelay,o=i.maxDelay,s=i.randomisationFactor,u=i.factor;if(Am(a)&&a<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(Am(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(Am(s)&&(s<0||s>1))throw new Error("The randomisation factor must be between 0 and 1.");if(Am(u)&&u<=1)throw new Error("Exponential factor should be greater than 1.");if(r.initialDelay=a||100,r.maxDelay=o||1e4,r.maxDelay<=r.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return r.randomisationFactor=s||0,r.factor=u||2,r.reset(),r}return lm.default(n,[{key:"backoff",value:function(e){null==this.timeoutID&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",e),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,e)))}},{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(e){if(e<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(e));this.maxNumberOfRetry=e}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var e=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*e))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(e){return new n(e)}}]),n}(gm),Mm=tm.AsyncRetrier=Om;tm.Backoff=jm;var Lm=tm.Retrier=Cm;function Um(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Nm(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nm(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Nm(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Dm=function(){function e(t,n){Na(this,e),this.configuration=t,this.services=n,this.cache=new Map,this.cacheLifetime=100*this.configuration.httpCacheInterval,this.cleanupCache()}return Ua(e,[{key:"isExpired",value:function(e){return!this.cacheLifetime||Date.now()-e>this.cacheLifetime}},{key:"cleanupCache",value:function(){var e,t=Um(this.cache);try{for(t.s();!(e=t.n()).done;){var n=dg(e.value,2),r=n[0],i=n[1];this.isExpired(i.timestamp)&&this.cache.delete(r)}}catch(e){t.e(e)}finally{t.f()}0===this.cache.size&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var e=this;this.timer=this.timer||setInterval((function(){return e.cleanupCache()}),2*this.cacheLifetime)}},{key:"executeWithRetry",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((function(r,i){var a=[502,503,504];n&&a.push(429);var o=new Lm(t.configuration.backoffConfiguration);o.on("attempt",(function(){e().then((function(e){return o.succeeded(e)})).catch((function(e){a.indexOf(e.status)>-1||"Twilsock disconnected"===e.message?o.failed(e):(o.removeAllListeners(),o.cancel(),i(e))}))})),o.on("succeeded",(function(e){r(e)})),o.on("cancelled",(function(e){return i(e)})),o.on("failed",(function(e){return i(e)})),o.start()}))}},{key:"get",value:function(){var e=Ia(Kc.mark((function e(t){var n,r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))||this.isExpired(n.timestamp)){e.next=3;break}return e.abrupt("return",n.response);case 3:return r={},e.next=6,this.executeWithRetry((function(){return a.services.transport.get(t,r,a.configuration.productId)}),this.configuration.retryWhenThrottled);case 6:return i=e.sent,this.cache.set(t,{response:i,timestamp:Date.now()}),this.pokeTimer(),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}(),Fm=Ua((function e(){Na(this,e)}));Ma(Fm,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),Ma(Fm,"NEW_MESSAGE","twilio.conversations.new_message"),Ma(Fm,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),Ma(Fm,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),Ma(Fm,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");var Bm={},qm={exports:{}};!function(e){function t(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var n=this,r=arguments;return new Promise((function(i,a){var o=e.apply(n,r);function s(e){t(o,i,a,s,u,"next",e)}function u(e){t(o,i,a,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports}(qm);var zm=r(Vc),Wm=Je.exports,Km=Fe,Vm=Er,$m=s,Gm=tp,Jm="toString",Hm=RegExp.prototype,Ym=Hm.toString,Qm=$m((function(){return"/a/b"!=Ym.call({source:"a",flags:"b"})})),Xm=Ym.name!=Jm;(Qm||Xm)&&Wm(RegExp.prototype,Jm,(function(){var e=Km(this),t=Vm(e.source),n=e.flags;return"/"+t+"/"+Vm(void 0===n&&e instanceof RegExp&&!("flags"in Hm)?Gm.call(e):n)}),{unsafe:!0}),qg("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),em);var Zm={exports:{}};!function(e,t){var n;n=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t,n){e.exports=function(e,t){var n,r,i;for(n=1;n<arguments.length;n++)for(i in r=arguments[n])r.hasOwnProperty(i)&&(e[i]=r[i]);return e}},function(e,t,n){var r=n(0);e.exports={build:function(e,t){var n,i,a,o=t.plugins;for(n=0,i=o.length;n<i;n++)(a=o[n]).methods&&r(e,a.methods),a.properties&&Object.defineProperties(e,a.properties)},hook:function(e,t,n){var r,i,a,o,s=e.config.plugins,u=[e.context];for(n&&(u=u.concat(n)),r=0,i=s.length;r<i;r++)o=s[r],(a=s[r][t])&&a.apply(o,u)}}},function(e,t,n){function r(e){if(0===e.length)return e;var t,n,r=e.split(/[_-]/);if(1===r.length&&r[0][0].toLowerCase()===r[0][0])return e;for(n=r[0].toLowerCase(),t=1;t<r.length;t++)n=n+r[t].charAt(0).toUpperCase()+r[t].substring(1).toLowerCase();return n}r.prepended=function(e,t){return e+(t=r(t))[0].toUpperCase()+t.substring(1)},e.exports=r},function(e,t,n){var r=n(0),i=n(2);function a(e,t){e=e||{},this.options=e,this.defaults=t.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(e.init),this.data=this.configureData(e.data),this.methods=this.configureMethods(e.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(e.transitions||[]),this.plugins=this.configurePlugins(e.plugins,t.plugin)}r(a.prototype,{addState:function(e){this.map[e]||(this.states.push(e),this.addStateLifecycleNames(e),this.map[e]={})},addStateLifecycleNames:function(e){this.lifecycle.onEnter[e]=i.prepended("onEnter",e),this.lifecycle.onLeave[e]=i.prepended("onLeave",e),this.lifecycle.on[e]=i.prepended("on",e)},addTransition:function(e){this.transitions.indexOf(e)<0&&(this.transitions.push(e),this.addTransitionLifecycleNames(e))},addTransitionLifecycleNames:function(e){this.lifecycle.onBefore[e]=i.prepended("onBefore",e),this.lifecycle.onAfter[e]=i.prepended("onAfter",e),this.lifecycle.on[e]=i.prepended("on",e)},mapTransition:function(e){var t=e.name,n=e.from,r=e.to;return this.addState(n),"function"!=typeof r&&this.addState(r),this.addTransition(t),this.map[n][t]=e,e},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(e){return"string"==typeof e?this.mapTransition(r({},this.defaults.init,{to:e,active:!0})):"object"===Pa(e)?this.mapTransition(r({},this.defaults.init,e,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(e){return"function"==typeof e?e:"object"===Pa(e)?function(){return e}:function(){return{}}},configureMethods:function(e){return e||{}},configurePlugins:function(e,t){var n,r,i;for(n=0,r=(e=e||[]).length;n<r;n++)"function"==typeof(i=e[n])&&(e[n]=i=i()),i.configure&&i.configure(this);return e},configureTransitions:function(e){var t,n,r,i,a,o=this.defaults.wildcard;for(n=0;n<e.length;n++)for(r=e[n],i=Array.isArray(r.from)?r.from:[r.from||o],a=r.to||o,t=0;t<i.length;t++)this.mapTransition({name:r.name,from:i[t],to:a})},transitionFor:function(e,t){var n=this.defaults.wildcard;return this.map[e][t]||this.map[n][t]},transitionsFor:function(e){var t=this.defaults.wildcard;return Object.keys(this.map[e]).concat(Object.keys(this.map[t]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),e.exports=a},function(e,t,n){var r=n(0),i=n(6),a=n(1),o=[null,[]];function s(e,t){this.context=e,this.config=t,this.state=t.init.from,this.observers=[e]}r(s.prototype,{init:function(e){if(r(this.context,this.config.data.apply(this.context,e)),a.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(e){return Array.isArray(e)?e.indexOf(this.state)>=0:this.state===e},isPending:function(){return this.pending},can:function(e){return!this.isPending()&&!!this.seek(e)},cannot:function(e){return!this.can(e)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(e,t){var n=this.config.defaults.wildcard,r=this.config.transitionFor(this.state,e),i=r&&r.to;return"function"==typeof i?i.apply(this.context,t):i===n?this.state:i},fire:function(e,t){return this.transit(e,this.state,this.seek(e,t),t)},transit:function(e,t,n,r){var i=this.config.lifecycle,a=this.config.options.observeUnchangedState||t!==n;return n?this.isPending()?this.context.onPendingTransition(e,t,n):(this.config.addState(n),this.beginTransit(),r.unshift({transition:e,from:t,to:n,fsm:this.context}),this.observeEvents([this.observersForEvent(i.onBefore.transition),this.observersForEvent(i.onBefore[e]),a?this.observersForEvent(i.onLeave.state):o,a?this.observersForEvent(i.onLeave[t]):o,this.observersForEvent(i.on.transition),a?["doTransit",[this]]:o,a?this.observersForEvent(i.onEnter.state):o,a?this.observersForEvent(i.onEnter[n]):o,a?this.observersForEvent(i.on[n]):o,this.observersForEvent(i.onAfter.transition),this.observersForEvent(i.onAfter[e]),this.observersForEvent(i.on[e])],r)):this.context.onInvalidTransition(e,t,n)},beginTransit:function(){this.pending=!0},endTransit:function(e){return this.pending=!1,e},failTransit:function(e){throw this.pending=!1,e},doTransit:function(e){this.state=e.to},observe:function(e){if(2===e.length){var t={};t[e[0]]=e[1],this.observers.push(t)}else this.observers.push(e[0])},observersForEvent:function(e){for(var t,n=0,r=this.observers.length,i=[];n<r;n++)(t=this.observers[n])[e]&&i.push(t);return[e,i,!0]},observeEvents:function(e,t,n,r){if(0===e.length)return this.endTransit(void 0===r||r);var i=e[0][0],o=e[0][1],s=e[0][2];if(t[0].event=i,i&&s&&i!==n&&a.hook(this,"lifecycle",t),0===o.length)return e.shift(),this.observeEvents(e,t,i,r);var u=o.shift(),c=u[i].apply(u,t);return c&&"function"==typeof c.then?c.then(this.observeEvents.bind(this,e,t,i)).catch(this.failTransit.bind(this)):!1===c?this.endTransit(!1):this.observeEvents(e,t,i,c)},onInvalidTransition:function(e,t,n){throw new i("transition is invalid in current state",e,t,n,this.state)},onPendingTransition:function(e,t,n){throw new i("transition is invalid while previous transition is still in progress",e,t,n,this.state)}}),e.exports=s},function(e,t,n){var r=n(0),i=n(2),a=n(1),o=n(3),s=n(4),u={is:function(e){return this._fsm.is(e)},can:function(e){return this._fsm.can(e)},cannot:function(e){return this._fsm.cannot(e)},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(e,t,n){return this._fsm.onInvalidTransition(e,t,n)},onPendingTransition:function(e,t,n){return this._fsm.onPendingTransition(e,t,n)}},c={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(e){throw Error("use transitions to change state")}}};function l(e){return f(this||{},e)}function f(e,t){return d(e,new o(t,l)),e._fsm(),e}function d(e,t){if("object"!==Pa(e)||Array.isArray(e))throw Error("StateMachine can only be applied to objects");a.build(e,t),Object.defineProperties(e,c),r(e,u),r(e,t.methods),t.allTransitions().forEach((function(t){e[i(t)]=function(){return this._fsm.fire(t,[].slice.call(arguments))}})),e._fsm=function(){this._fsm=new s(this,t),this._fsm.init(arguments)}}l.version="3.0.1",l.factory=function(){var e,t;"function"==typeof arguments[0]?(e=arguments[0],t=arguments[1]||{}):(e=function(){this._fsm.apply(this,arguments)},t=arguments[0]||{});var n=new o(t,l);return d(e.prototype,n),e.prototype._fsm.config=n,e},l.apply=f,l.defaults={wildcard:"*",init:{name:"init",from:"none"}},e.exports=l},function(e,t,n){e.exports=function(e,t,n,r,i){this.message=e,this.transition=t,this.from=n,this.to=r,this.current=i}}])},e.exports=n()}(Zm);var eb,tb={},nb={},rb={};Object.defineProperty(rb,"__esModule",{value:!0}),rb.default=function(){if(!eb&&!(eb="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return eb(ib)};var ib=new Uint8Array(16);var ab={},ob={},sb={};Object.defineProperty(sb,"__esModule",{value:!0}),sb.default=void 0;sb.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,Object.defineProperty(ob,"__esModule",{value:!0}),ob.default=void 0;var ub,cb=(ub=sb)&&ub.__esModule?ub:{default:ub};var lb=function(e){return"string"==typeof e&&cb.default.test(e)};ob.default=lb,Object.defineProperty(ab,"__esModule",{value:!0}),ab.default=void 0,ab.unsafeStringify=hb;var fb=function(e){return e&&e.__esModule?e:{default:e}}(ob);for(var db=[],pb=0;pb<256;++pb)db.push((pb+256).toString(16).slice(1));function hb(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return db[e[t+0]]+db[e[t+1]]+db[e[t+2]]+db[e[t+3]]+"-"+db[e[t+4]]+db[e[t+5]]+"-"+db[e[t+6]]+db[e[t+7]]+"-"+db[e[t+8]]+db[e[t+9]]+"-"+db[e[t+10]]+db[e[t+11]]+db[e[t+12]]+db[e[t+13]]+db[e[t+14]]+db[e[t+15]]}var vb=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=hb(e,t);if(!(0,fb.default)(n))throw TypeError("Stringified UUID is invalid");return n};ab.default=vb,Object.defineProperty(nb,"__esModule",{value:!0}),nb.default=void 0;var yb,gb,mb=function(e){return e&&e.__esModule?e:{default:e}}(rb),bb=ab;var wb=0,kb=0;var _b=function(e,t,n){var r=t&&n||0,i=t||new Array(16),a=(e=e||{}).node||yb,o=void 0!==e.clockseq?e.clockseq:gb;if(null==a||null==o){var s=e.random||(e.rng||mb.default)();null==a&&(a=yb=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==o&&(o=gb=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:Date.now(),c=void 0!==e.nsecs?e.nsecs:kb+1,l=u-wb+(c-kb)/1e4;if(l<0&&void 0===e.clockseq&&(o=o+1&16383),(l<0||u>wb)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");wb=u,kb=c,gb=o;var f=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var d=u/4294967296*1e4&268435455;i[r++]=d>>>8&255,i[r++]=255&d,i[r++]=d>>>24&15|16,i[r++]=d>>>16&255,i[r++]=o>>>8|128,i[r++]=255&o;for(var p=0;p<6;++p)i[r+p]=a[p];return t||(0,bb.unsafeStringify)(i)};nb.default=_b;var xb={},Sb={},Eb={};Object.defineProperty(Eb,"__esModule",{value:!0}),Eb.default=void 0;var Rb=function(e){return e&&e.__esModule?e:{default:e}}(ob);var Ib=function(e){if(!(0,Rb.default)(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};Eb.default=Ib,Object.defineProperty(Sb,"__esModule",{value:!0}),Sb.URL=Sb.DNS=void 0,Sb.default=function(e,t,n){function r(e,r,i,a){var o;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=(0,Cb.default)(r)),16!==(null===(o=r)||void 0===o?void 0:o.length))throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+e.length);if(s.set(r),s.set(e,r.length),(s=n(s))[6]=15&s[6]|t,s[8]=63&s[8]|128,i){a=a||0;for(var u=0;u<16;++u)i[a+u]=s[u];return i}return(0,Tb.unsafeStringify)(s)}try{r.name=e}catch(e){}return r.DNS=Ob,r.URL=Pb,r};var Tb=ab,Cb=function(e){return e&&e.__esModule?e:{default:e}}(Eb);var Ob="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Sb.DNS=Ob;var Pb="6ba7b811-9dad-11d1-80b4-00c04fd430c8";Sb.URL=Pb;var Ab={};function jb(e){return 14+(e+64>>>9<<4)+1}function Mb(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function Lb(e,t,n,r,i,a){return Mb((o=Mb(Mb(t,e),Mb(r,a)))<<(s=i)|o>>>32-s,n);var o,s}function Ub(e,t,n,r,i,a,o){return Lb(t&n|~t&r,e,t,i,a,o)}function Nb(e,t,n,r,i,a,o){return Lb(t&r|n&~r,e,t,i,a,o)}function Db(e,t,n,r,i,a,o){return Lb(t^n^r,e,t,i,a,o)}function Fb(e,t,n,r,i,a,o){return Lb(n^(t|~r),e,t,i,a,o)}Object.defineProperty(Ab,"__esModule",{value:!0}),Ab.default=void 0;var Bb=function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255,o=parseInt(r.charAt(a>>>4&15)+r.charAt(15&a),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[jb(t)-1]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o<e.length;o+=16){var s=n,u=r,c=i,l=a;n=Ub(n,r,i,a,e[o],7,-680876936),a=Ub(a,n,r,i,e[o+1],12,-389564586),i=Ub(i,a,n,r,e[o+2],17,606105819),r=Ub(r,i,a,n,e[o+3],22,-1044525330),n=Ub(n,r,i,a,e[o+4],7,-176418897),a=Ub(a,n,r,i,e[o+5],12,1200080426),i=Ub(i,a,n,r,e[o+6],17,-1473231341),r=Ub(r,i,a,n,e[o+7],22,-45705983),n=Ub(n,r,i,a,e[o+8],7,1770035416),a=Ub(a,n,r,i,e[o+9],12,-1958414417),i=Ub(i,a,n,r,e[o+10],17,-42063),r=Ub(r,i,a,n,e[o+11],22,-1990404162),n=Ub(n,r,i,a,e[o+12],7,1804603682),a=Ub(a,n,r,i,e[o+13],12,-40341101),i=Ub(i,a,n,r,e[o+14],17,-1502002290),n=Nb(n,r=Ub(r,i,a,n,e[o+15],22,1236535329),i,a,e[o+1],5,-165796510),a=Nb(a,n,r,i,e[o+6],9,-1069501632),i=Nb(i,a,n,r,e[o+11],14,643717713),r=Nb(r,i,a,n,e[o],20,-373897302),n=Nb(n,r,i,a,e[o+5],5,-701558691),a=Nb(a,n,r,i,e[o+10],9,38016083),i=Nb(i,a,n,r,e[o+15],14,-660478335),r=Nb(r,i,a,n,e[o+4],20,-405537848),n=Nb(n,r,i,a,e[o+9],5,568446438),a=Nb(a,n,r,i,e[o+14],9,-1019803690),i=Nb(i,a,n,r,e[o+3],14,-187363961),r=Nb(r,i,a,n,e[o+8],20,1163531501),n=Nb(n,r,i,a,e[o+13],5,-1444681467),a=Nb(a,n,r,i,e[o+2],9,-51403784),i=Nb(i,a,n,r,e[o+7],14,1735328473),n=Db(n,r=Nb(r,i,a,n,e[o+12],20,-1926607734),i,a,e[o+5],4,-378558),a=Db(a,n,r,i,e[o+8],11,-2022574463),i=Db(i,a,n,r,e[o+11],16,1839030562),r=Db(r,i,a,n,e[o+14],23,-35309556),n=Db(n,r,i,a,e[o+1],4,-1530992060),a=Db(a,n,r,i,e[o+4],11,1272893353),i=Db(i,a,n,r,e[o+7],16,-155497632),r=Db(r,i,a,n,e[o+10],23,-1094730640),n=Db(n,r,i,a,e[o+13],4,681279174),a=Db(a,n,r,i,e[o],11,-358537222),i=Db(i,a,n,r,e[o+3],16,-722521979),r=Db(r,i,a,n,e[o+6],23,76029189),n=Db(n,r,i,a,e[o+9],4,-640364487),a=Db(a,n,r,i,e[o+12],11,-421815835),i=Db(i,a,n,r,e[o+15],16,530742520),n=Fb(n,r=Db(r,i,a,n,e[o+2],23,-995338651),i,a,e[o],6,-198630844),a=Fb(a,n,r,i,e[o+7],10,1126891415),i=Fb(i,a,n,r,e[o+14],15,-1416354905),r=Fb(r,i,a,n,e[o+5],21,-57434055),n=Fb(n,r,i,a,e[o+12],6,1700485571),a=Fb(a,n,r,i,e[o+3],10,-1894986606),i=Fb(i,a,n,r,e[o+10],15,-1051523),r=Fb(r,i,a,n,e[o+1],21,-2054922799),n=Fb(n,r,i,a,e[o+8],6,1873313359),a=Fb(a,n,r,i,e[o+15],10,-30611744),i=Fb(i,a,n,r,e[o+6],15,-1560198380),r=Fb(r,i,a,n,e[o+13],21,1309151649),n=Fb(n,r,i,a,e[o+4],6,-145523070),a=Fb(a,n,r,i,e[o+11],10,-1120210379),i=Fb(i,a,n,r,e[o+2],15,718787259),r=Fb(r,i,a,n,e[o+9],21,-343485551),n=Mb(n,s),r=Mb(r,u),i=Mb(i,c),a=Mb(a,l)}return[n,r,i,a]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(jb(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8*e.length))};Ab.default=Bb,Object.defineProperty(xb,"__esModule",{value:!0}),xb.default=void 0;var qb=Wb(Sb),zb=Wb(Ab);function Wb(e){return e&&e.__esModule?e:{default:e}}var Kb=(0,qb.default)("v3",48,zb.default);xb.default=Kb;var Vb={},$b={};Object.defineProperty($b,"__esModule",{value:!0}),$b.default=void 0;var Gb={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};$b.default=Gb,Object.defineProperty(Vb,"__esModule",{value:!0}),Vb.default=void 0;var Jb=Qb($b),Hb=Qb(rb),Yb=ab;function Qb(e){return e&&e.__esModule?e:{default:e}}var Xb=function(e,t,n){if(Jb.default.randomUUID&&!t&&!e)return Jb.default.randomUUID();var r=(e=e||{}).random||(e.rng||Hb.default)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return(0,Yb.unsafeStringify)(r)};Vb.default=Xb;var Zb={},ew={};function tw(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function nw(e,t){return e<<t|e>>>32-t}Object.defineProperty(ew,"__esModule",{value:!0}),ew.default=void 0;var rw=function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i)e.push(r.charCodeAt(i))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var a=e.length/4+2,o=Math.ceil(a/16),s=new Array(o),u=0;u<o;++u){for(var c=new Uint32Array(16),l=0;l<16;++l)c[l]=e[64*u+4*l]<<24|e[64*u+4*l+1]<<16|e[64*u+4*l+2]<<8|e[64*u+4*l+3];s[u]=c}s[o-1][14]=8*(e.length-1)/Math.pow(2,32),s[o-1][14]=Math.floor(s[o-1][14]),s[o-1][15]=8*(e.length-1)&4294967295;for(var f=0;f<o;++f){for(var d=new Uint32Array(80),p=0;p<16;++p)d[p]=s[f][p];for(var h=16;h<80;++h)d[h]=nw(d[h-3]^d[h-8]^d[h-14]^d[h-16],1);for(var v=n[0],y=n[1],g=n[2],m=n[3],b=n[4],w=0;w<80;++w){var k=Math.floor(w/20),_=nw(v,5)+tw(k,y,g,m)+b+t[k]+d[w]>>>0;b=m,m=g,g=nw(y,30)>>>0,y=v,v=_}n[0]=n[0]+v>>>0,n[1]=n[1]+y>>>0,n[2]=n[2]+g>>>0,n[3]=n[3]+m>>>0,n[4]=n[4]+b>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]};ew.default=rw,Object.defineProperty(Zb,"__esModule",{value:!0}),Zb.default=void 0;var iw=ow(Sb),aw=ow(ew);function ow(e){return e&&e.__esModule?e:{default:e}}var sw=(0,iw.default)("v5",80,aw.default);Zb.default=sw;var uw={};Object.defineProperty(uw,"__esModule",{value:!0}),uw.default=void 0;uw.default="00000000-0000-0000-0000-000000000000";var cw={};Object.defineProperty(cw,"__esModule",{value:!0}),cw.default=void 0;var lw=function(e){return e&&e.__esModule?e:{default:e}}(ob);var fw=function(e){if(!(0,lw.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)};cw.default=fw,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return a.default}}),Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return c.default}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.default}}),Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return r.default}}),Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return i.default}}),Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return s.default}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return o.default}});var t=l(nb),n=l(xb),r=l(Vb),i=l(Zb),a=l(uw),o=l(cw),s=l(ob),u=l(ab),c=l(Eb);function l(e){return e&&e.__esModule?e:{default:e}}}(tb);var dw,pw,hw,vw={exports:{}},yw="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,gw=yw,mw=u,bw=a,ww=E,kw=te,_w=Va,xw=Ge,Sw=Je.exports,Ew=Ne.f,Rw=Ul,Iw=bo,Tw=he,Cw=ie,Ow=bw.Int8Array,Pw=Ow&&Ow.prototype,Aw=bw.Uint8ClampedArray,jw=Aw&&Aw.prototype,Mw=Ow&&Rw(Ow),Lw=Pw&&Rw(Pw),Uw=Object.prototype,Nw=Uw.isPrototypeOf,Dw=Tw("toStringTag"),Fw=Cw("TYPED_ARRAY_TAG"),Bw=Cw("TYPED_ARRAY_CONSTRUCTOR"),qw=gw&&!!Iw&&"Opera"!==_w(bw.opera),zw=!1,Ww={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Kw={BigInt64Array:8,BigUint64Array:8},Vw=function(e){if(!ww(e))return!1;var t=_w(e);return kw(Ww,t)||kw(Kw,t)};for(dw in Ww)(hw=(pw=bw[dw])&&pw.prototype)?xw(hw,Bw,pw):qw=!1;for(dw in Kw)(hw=(pw=bw[dw])&&pw.prototype)&&xw(hw,Bw,pw);if((!qw||"function"!=typeof Mw||Mw===Function.prototype)&&(Mw=function(){throw TypeError("Incorrect invocation")},qw))for(dw in Ww)bw[dw]&&Iw(bw[dw],Mw);if((!qw||!Lw||Lw===Uw)&&(Lw=Mw.prototype,qw))for(dw in Ww)bw[dw]&&Iw(bw[dw].prototype,Lw);if(qw&&Rw(jw)!==Lw&&Iw(jw,Lw),mw&&!kw(Lw,Dw))for(dw in zw=!0,Ew(Lw,Dw,{get:function(){return ww(this)?this[Fw]:void 0}}),Ww)bw[dw]&&xw(bw[dw],Fw,dw);var $w={NATIVE_ARRAY_BUFFER_VIEWS:qw,TYPED_ARRAY_CONSTRUCTOR:Bw,TYPED_ARRAY_TAG:zw&&Fw,aTypedArray:function(e){if(Vw(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(Iw&&!Nw.call(Mw,e))throw TypeError("Target is not a typed array constructor");return e},exportTypedArrayMethod:function(e,t,n){if(mw){if(n)for(var r in Ww){var i=bw[r];if(i&&kw(i.prototype,e))try{delete i.prototype[e]}catch(e){}}Lw[e]&&!n||Sw(Lw,e,n?t:qw&&Pw[e]||t)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(mw){if(Iw){if(n)for(r in Ww)if((i=bw[r])&&kw(i,e))try{delete i[e]}catch(e){}if(Mw[e]&&!n)return;try{return Sw(Mw,e,n?t:qw&&Mw[e]||t)}catch(e){}}for(r in Ww)!(i=bw[r])||i[e]&&!n||Sw(i,e,t)}},isView:function(e){if(!ww(e))return!1;var t=_w(e);return"DataView"===t||kw(Ww,t)||kw(Kw,t)},isTypedArray:Vw,TypedArray:Mw,TypedArrayPrototype:Lw},Gw=a,Jw=s,Hw=rs,Yw=$w.NATIVE_ARRAY_BUFFER_VIEWS,Qw=Gw.ArrayBuffer,Xw=Gw.Int8Array,Zw=!Yw||!Jw((function(){Xw(1)}))||!Jw((function(){new Xw(-1)}))||!Hw((function(e){new Xw,new Xw(null),new Xw(1.5),new Xw(e)}),!0)||Jw((function(){return 1!==new Xw(new Qw(2),1,void 0).length})),ek=Lt,tk=Dt,nk=function(e){if(void 0===e)return 0;var t=ek(e),n=tk(t);if(t!==n)throw RangeError("Wrong length or index");return n},rk=Math.abs,ik=Math.pow,ak=Math.floor,ok=Math.log,sk=Math.LN2,uk=X,ck=zt,lk=Dt,fk=function(e){for(var t=uk(this),n=lk(t.length),r=arguments.length,i=ck(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,o=void 0===a?n:ck(a,n);o>i;)t[i++]=e;return t},dk=a,pk=u,hk=yw,vk=Ge,yk=vo,gk=s,mk=Eo,bk=Lt,wk=Dt,kk=nk,_k={pack:function(e,t,n){var r,i,a,o=new Array(n),s=8*n-t-1,u=(1<<s)-1,c=u>>1,l=23===t?ik(2,-24)-ik(2,-77):0,f=e<0||0===e&&1/e<0?1:0,d=0;for((e=rk(e))!=e||e===1/0?(i=e!=e?1:0,r=u):(r=ak(ok(e)/sk),e*(a=ik(2,-r))<1&&(r--,a*=2),(e+=r+c>=1?l/a:l*ik(2,1-c))*a>=2&&(r++,a/=2),r+c>=u?(i=0,r=u):r+c>=1?(i=(e*a-1)*ik(2,t),r+=c):(i=e*ik(2,c-1)*ik(2,t),r=0));t>=8;o[d++]=255&i,i/=256,t-=8);for(r=r<<t|i,s+=t;s>0;o[d++]=255&r,r/=256,s-=8);return o[--d]|=128*f,o},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,a=(1<<i)-1,o=a>>1,s=i-7,u=r-1,c=e[u--],l=127&c;for(c>>=7;s>0;l=256*l+e[u],u--,s-=8);for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;n=256*n+e[u],u--,s-=8);if(0===l)l=1-o;else{if(l===a)return n?NaN:c?-1/0:1/0;n+=ik(2,t),l-=o}return(c?-1:1)*n*ik(2,l-t)}},xk=Ul,Sk=bo,Ek=At.f,Rk=Ne.f,Ik=fk,Tk=An,Ck=xt.get,Ok=xt.set,Pk="ArrayBuffer",Ak="DataView",jk="Wrong index",Mk=dk.ArrayBuffer,Lk=Mk,Uk=dk.DataView,Nk=Uk&&Uk.prototype,Dk=Object.prototype,Fk=dk.RangeError,Bk=_k.pack,qk=_k.unpack,zk=function(e){return[255&e]},Wk=function(e){return[255&e,e>>8&255]},Kk=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Vk=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},$k=function(e){return Bk(e,23,4)},Gk=function(e){return Bk(e,52,8)},Jk=function(e,t){Rk(e.prototype,t,{get:function(){return Ck(this)[t]}})},Hk=function(e,t,n,r){var i=kk(n),a=Ck(e);if(i+t>a.byteLength)throw Fk(jk);var o=Ck(a.buffer).bytes,s=i+a.byteOffset,u=o.slice(s,s+t);return r?u:u.reverse()},Yk=function(e,t,n,r,i,a){var o=kk(n),s=Ck(e);if(o+t>s.byteLength)throw Fk(jk);for(var u=Ck(s.buffer).bytes,c=o+s.byteOffset,l=r(+i),f=0;f<t;f++)u[c+f]=l[a?f:t-f-1]};if(hk){if(!gk((function(){Mk(1)}))||!gk((function(){new Mk(-1)}))||gk((function(){return new Mk,new Mk(1.5),new Mk(NaN),Mk.name!=Pk}))){for(var Qk,Xk=(Lk=function(e){return mk(this,Lk),new Mk(kk(e))}).prototype=Mk.prototype,Zk=Ek(Mk),e_=0;Zk.length>e_;)(Qk=Zk[e_++])in Lk||vk(Lk,Qk,Mk[Qk]);Xk.constructor=Lk}Sk&&xk(Nk)!==Dk&&Sk(Nk,Dk);var t_=new Uk(new Lk(2)),n_=Nk.setInt8;t_.setInt8(0,2147483648),t_.setInt8(1,2147483649),!t_.getInt8(0)&&t_.getInt8(1)||yk(Nk,{setInt8:function(e,t){n_.call(this,e,t<<24>>24)},setUint8:function(e,t){n_.call(this,e,t<<24>>24)}},{unsafe:!0})}else Lk=function(e){mk(this,Lk,Pk);var t=kk(e);Ok(this,{bytes:Ik.call(new Array(t),0),byteLength:t}),pk||(this.byteLength=t)},Uk=function(e,t,n){mk(this,Uk,Ak),mk(e,Lk,Ak);var r=Ck(e).byteLength,i=bk(t);if(i<0||i>r)throw Fk("Wrong offset");if(i+(n=void 0===n?r-i:wk(n))>r)throw Fk("Wrong length");Ok(this,{buffer:e,byteLength:n,byteOffset:i}),pk||(this.buffer=e,this.byteLength=n,this.byteOffset=i)},pk&&(Jk(Lk,"byteLength"),Jk(Uk,"buffer"),Jk(Uk,"byteLength"),Jk(Uk,"byteOffset")),yk(Uk.prototype,{getInt8:function(e){return Hk(this,1,e)[0]<<24>>24},getUint8:function(e){return Hk(this,1,e)[0]},getInt16:function(e){var t=Hk(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Hk(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Vk(Hk(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Vk(Hk(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return qk(Hk(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return qk(Hk(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Yk(this,1,e,zk,t)},setUint8:function(e,t){Yk(this,1,e,zk,t)},setInt16:function(e,t){Yk(this,2,e,Wk,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Yk(this,2,e,Wk,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Yk(this,4,e,Kk,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Yk(this,4,e,Kk,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Yk(this,4,e,$k,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Yk(this,8,e,Gk,t,arguments.length>2?arguments[2]:void 0)}});Tk(Lk,Pk),Tk(Uk,Ak);var r_={ArrayBuffer:Lk,DataView:Uk},i_=Lt,a_=function(e){var t=i_(e);if(t<0)throw RangeError("The argument can't be less than 0");return t},o_=function(e,t){var n=a_(e);if(n%t)throw RangeError("Wrong offset");return n},s_=X,u_=Dt,c_=No,l_=Mo,f_=Oo,d_=Fr,p_=$w.aTypedArrayConstructor,h_=Tn,v_=a,y_=u,g_=Zw,m_=$w,b_=r_,w_=Eo,k_=v,__=Ge,x_=Sv,S_=Dt,E_=nk,R_=o_,I_=_e,T_=te,C_=Va,O_=E,P_=z,A_=nr,j_=bo,M_=At.f,L_=function(e){var t,n,r,i,a,o,s=s_(e),u=arguments.length,c=u>1?arguments[1]:void 0,l=void 0!==c,f=l_(s);if(null!=f&&!f_(f))for(o=(a=c_(s,f)).next,s=[];!(i=o.call(a)).done;)s.push(i.value);for(l&&u>2&&(c=d_(c,arguments[2],2)),n=u_(s.length),r=new(p_(this))(n),t=0;n>t;t++)r[t]=l?c(s[t],t):s[t];return r},U_=Xr.forEach,N_=So,D_=Ne,F_=o,B_=_d,q_=xt.get,z_=xt.set,W_=D_.f,K_=F_.f,V_=Math.round,$_=v_.RangeError,G_=b_.ArrayBuffer,J_=b_.DataView,H_=m_.NATIVE_ARRAY_BUFFER_VIEWS,Y_=m_.TYPED_ARRAY_CONSTRUCTOR,Q_=m_.TYPED_ARRAY_TAG,X_=m_.TypedArray,Z_=m_.TypedArrayPrototype,ex=m_.aTypedArrayConstructor,tx=m_.isTypedArray,nx="BYTES_PER_ELEMENT",rx="Wrong length",ix=function(e,t){for(var n=0,r=t.length,i=new(ex(e))(r);r>n;)i[n]=t[n++];return i},ax=function(e,t){W_(e,t,{get:function(){return q_(this)[t]}})},ox=function(e){var t;return e instanceof G_||"ArrayBuffer"==(t=C_(e))||"SharedArrayBuffer"==t},sx=function(e,t){return tx(e)&&!P_(t)&&t in e&&x_(+t)&&t>=0},ux=function(e,t){return t=I_(t),sx(e,t)?k_(2,e[t]):K_(e,t)},cx=function(e,t,n){return t=I_(t),!(sx(e,t)&&O_(n)&&T_(n,"value"))||T_(n,"get")||T_(n,"set")||n.configurable||T_(n,"writable")&&!n.writable||T_(n,"enumerable")&&!n.enumerable?W_(e,t,n):(e[t]=n.value,e)};y_?(H_||(F_.f=ux,D_.f=cx,ax(Z_,"buffer"),ax(Z_,"byteOffset"),ax(Z_,"byteLength"),ax(Z_,"length")),h_({target:"Object",stat:!0,forced:!H_},{getOwnPropertyDescriptor:ux,defineProperty:cx}),vw.exports=function(e,t,n){var r=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=v_[i],u=s,c=u&&u.prototype,l={},f=function(e,t){W_(e,t,{get:function(){return function(e,t){var n=q_(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=q_(e);n&&(i=(i=V_(i))<0?0:i>255?255:255&i),a.view[o](t*r+a.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};H_?g_&&(u=t((function(e,t,n,a){return w_(e,u,i),B_(O_(t)?ox(t)?void 0!==a?new s(t,R_(n,r),a):void 0!==n?new s(t,R_(n,r)):new s(t):tx(t)?ix(u,t):L_.call(u,t):new s(E_(t)),e,u)})),j_&&j_(u,X_),U_(M_(s),(function(e){e in u||__(u,e,s[e])})),u.prototype=c):(u=t((function(e,t,n,a){w_(e,u,i);var o,s,c,l=0,d=0;if(O_(t)){if(!ox(t))return tx(t)?ix(u,t):L_.call(u,t);o=t,d=R_(n,r);var p=t.byteLength;if(void 0===a){if(p%r)throw $_(rx);if((s=p-d)<0)throw $_(rx)}else if((s=S_(a)*r)+d>p)throw $_(rx);c=s/r}else c=E_(t),o=new G_(s=c*r);for(z_(e,{buffer:o,byteOffset:d,byteLength:s,length:c,view:new J_(o)});l<c;)f(e,l++)})),j_&&j_(u,X_),c=u.prototype=A_(Z_)),c.constructor!==u&&__(c,"constructor",u),__(c,Y_,u),Q_&&__(c,Q_,i),l[i]=u,h_({global:!0,forced:u!=s,sham:!H_},l),nx in u||__(u,nx,r),nx in c||__(c,nx,r),N_(i)}):vw.exports=function(){},(0,vw.exports)("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var lx=Dt,fx=Lt,dx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("at",(function(e){var t=dx(this),n=lx(t.length),r=fx(e),i=r>=0?r:n+r;return i<0||i>=n?void 0:t[i]}));var px=X,hx=zt,vx=Dt,yx=Math.min,gx=[].copyWithin||function(e,t){var n=px(this),r=vx(n.length),i=hx(e,r),a=hx(t,r),o=arguments.length>2?arguments[2]:void 0,s=yx((void 0===o?r:hx(o,r))-a,r-i),u=1;for(a<i&&i<a+s&&(u=-1,a+=s-1,i+=s-1);s-- >0;)a in n?n[i]=n[a]:delete n[i],i+=u,a+=u;return n},mx=gx,bx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("copyWithin",(function(e,t){return mx.call(bx(this),e,t,arguments.length>2?arguments[2]:void 0)}));var wx=Xr.every,kx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("every",(function(e){return wx(kx(this),e,arguments.length>1?arguments[1]:void 0)}));var _x=fk,xx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("fill",(function(e){return _x.apply(xx(this),arguments)}));var Sx=ss,Ex=$w.TYPED_ARRAY_CONSTRUCTOR,Rx=$w.aTypedArrayConstructor,Ix=function(e){return Rx(Sx(e,e[Ex]))},Tx=function(e,t){for(var n=0,r=t.length,i=new e(r);r>n;)i[n]=t[n++];return i},Cx=Ix,Ox=Xr.filter,Px=function(e,t){return Tx(Cx(e),t)},Ax=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("filter",(function(e){var t=Ox(Ax(this),e,arguments.length>1?arguments[1]:void 0);return Px(this,t)}));var jx=Xr.find,Mx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("find",(function(e){return jx(Mx(this),e,arguments.length>1?arguments[1]:void 0)}));var Lx=Xr.findIndex,Ux=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("findIndex",(function(e){return Lx(Ux(this),e,arguments.length>1?arguments[1]:void 0)}));var Nx=Xr.forEach,Dx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("forEach",(function(e){Nx(Dx(this),e,arguments.length>1?arguments[1]:void 0)}));var Fx=Gt.includes,Bx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("includes",(function(e){return Fx(Bx(this),e,arguments.length>1?arguments[1]:void 0)}));var qx=Gt.indexOf,zx=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("indexOf",(function(e){return qx(zx(this),e,arguments.length>1?arguments[1]:void 0)}));var Wx=a,Kx=$w,Vx=ed,$x=he("iterator"),Gx=Wx.Uint8Array,Jx=Vx.values,Hx=Vx.keys,Yx=Vx.entries,Qx=Kx.aTypedArray,Xx=Kx.exportTypedArrayMethod,Zx=Gx&&Gx.prototype[$x],eS=!!Zx&&("values"==Zx.name||null==Zx.name),tS=function(){return Jx.call(Qx(this))};Xx("entries",(function(){return Yx.call(Qx(this))})),Xx("keys",(function(){return Hx.call(Qx(this))})),Xx("values",tS,!eS),Xx($x,tS,!eS);var nS=$w.aTypedArray,rS=[].join;(0,$w.exportTypedArrayMethod)("join",(function(e){return rS.apply(nS(this),arguments)}));var iS=S,aS=Lt,oS=Dt,sS=no,uS=Math.min,cS=[].lastIndexOf,lS=!!cS&&1/[1].lastIndexOf(1,-0)<0,fS=sS("lastIndexOf"),dS=lS||!fS?function(e){if(lS)return cS.apply(this,arguments)||0;var t=iS(this),n=oS(t.length),r=n-1;for(arguments.length>1&&(r=uS(r,aS(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:cS,pS=dS,hS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("lastIndexOf",(function(e){return pS.apply(hS(this),arguments)}));var vS=Xr.map,yS=Ix,gS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("map",(function(e){return vS(gS(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(yS(e))(t)}))}));var mS=Un,bS=X,wS=w,kS=Dt,_S=function(e){return function(t,n,r,i){mS(n);var a=bS(t),o=wS(a),s=kS(a.length),u=e?s-1:0,c=e?-1:1;if(r<2)for(;;){if(u in o){i=o[u],u+=c;break}if(u+=c,e?u<0:s<=u)throw TypeError("Reduce of empty array with no initial value")}for(;e?u>=0:s>u;u+=c)u in o&&(i=n(i,o[u],u,a));return i}},xS={left:_S(!1),right:_S(!0)},SS=xS.left,ES=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("reduce",(function(e){return SS(ES(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var RS=xS.right,IS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("reduceRight",(function(e){return RS(IS(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var TS=$w.aTypedArray,CS=$w.exportTypedArrayMethod,OS=Math.floor;CS("reverse",(function(){for(var e,t=this,n=TS(t).length,r=OS(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var PS=Dt,AS=o_,jS=X,MS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("set",(function(e){MS(this);var t=AS(arguments.length>1?arguments[1]:void 0,1),n=this.length,r=jS(e),i=PS(r.length),a=0;if(i+t>n)throw RangeError("Wrong length");for(;a<i;)this[t+a]=r[a++]}),s((function(){new Int8Array(1).set({})})));var LS=Ix,US=$w.aTypedArray,NS=[].slice;(0,$w.exportTypedArrayMethod)("slice",(function(e,t){for(var n=NS.call(US(this),e,t),r=LS(this),i=0,a=n.length,o=new r(a);a>i;)o[i]=n[i++];return o}),s((function(){new Int8Array(1).slice()})));var DS=Xr.some,FS=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("some",(function(e){return DS(FS(this),e,arguments.length>1?arguments[1]:void 0)}));var BS=Math.floor,qS=function(e,t){var n=e.length,r=BS(n/2);return n<8?zS(e,t):WS(qS(e.slice(0,r),t),qS(e.slice(r),t),t)},zS=function(e,t){for(var n,r,i=e.length,a=1;a<i;){for(r=a,n=e[a];r&&t(e[r-1],n)>0;)e[r]=e[--r];r!==a++&&(e[r]=n)}return e},WS=function(e,t,n){for(var r=e.length,i=t.length,a=0,o=0,s=[];a<r||o<i;)a<r&&o<i?s.push(n(e[a],t[o])<=0?e[a++]:t[o++]):s.push(a<r?e[a++]:t[o++]);return s},KS=qS,VS=C.match(/firefox\/(\d+)/i),$S=!!VS&&+VS[1],GS=/MSIE|Trident/.test(C),JS=C.match(/AppleWebKit\/(\d+)\./),HS=!!JS&&+JS[1],YS=s,QS=Un,XS=Dt,ZS=KS,eE=$S,tE=GS,nE=U,rE=HS,iE=$w.aTypedArray,aE=$w.exportTypedArrayMethod,oE=a.Uint16Array,sE=oE&&oE.prototype.sort,uE=!!sE&&!YS((function(){var e=new oE(2);e.sort(null),e.sort({})})),cE=!!sE&&!YS((function(){if(nE)return nE<74;if(eE)return eE<67;if(tE)return!0;if(rE)return rE<602;var e,t,n=new oE(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(n.sort((function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));aE("sort",(function(e){var t=this;if(void 0!==e&&QS(e),cE)return sE.call(t,e);iE(t);var n,r=XS(t.length),i=Array(r);for(n=0;n<r;n++)i[n]=t[n];for(i=ZS(t,function(e){return function(t,n){return void 0!==e?+e(t,n)||0:n!=n?-1:t!=t?1:0===t&&0===n?1/t>0&&1/n<0?1:-1:t>n}}(e)),n=0;n<r;n++)t[n]=i[n];return t}),!cE||uE);var lE=Dt,fE=zt,dE=Ix,pE=$w.aTypedArray;(0,$w.exportTypedArrayMethod)("subarray",(function(e,t){var n=pE(this),r=n.length,i=fE(e,r);return new(dE(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,lE((void 0===t?r:fE(t,r))-i))}));var hE=$w,vE=s,yE=a.Int8Array,gE=hE.aTypedArray,mE=hE.exportTypedArrayMethod,bE=[].toLocaleString,wE=[].slice,kE=!!yE&&vE((function(){bE.call(new yE(1))}));mE("toLocaleString",(function(){return bE.apply(kE?wE.call(gE(this)):gE(this),arguments)}),vE((function(){return[1,2].toLocaleString()!=new yE([1,2]).toLocaleString()}))||!vE((function(){yE.prototype.toLocaleString.call([1,2])})));var _E=$w.exportTypedArrayMethod,xE=s,SE=a.Uint8Array,EE=SE&&SE.prototype||{},RE=[].toString,IE=[].join;xE((function(){RE.call({})}))&&(RE=function(){return IE.call(this)});var TE=EE.toString!=RE;_E("toString",RE,TE);var CE=E,OE=g,PE=he("match"),AE=function(e){var t;return CE(e)&&(void 0!==(t=e[PE])?!!t:"RegExp"==OE(e))},jE=Lp,ME=AE,LE=Fe,UE=k,NE=ss,DE=Np,FE=Dt,BE=Er,qE=Vp,zE=Ip,WE=s,KE=np.UNSUPPORTED_Y,VE=[].push,$E=Math.min,GE=4294967295,JE=!WE((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]}));jE("split",(function(e,t,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,n){var r=BE(UE(this)),i=void 0===n?GE:n>>>0;if(0===i)return[];if(void 0===e)return[r];if(!ME(e))return t.call(r,e,i);for(var a,o,s,u=[],c=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,f=new RegExp(e.source,c+"g");(a=zE.call(f,r))&&!((o=f.lastIndex)>l&&(u.push(r.slice(l,a.index)),a.length>1&&a.index<r.length&&VE.apply(u,a.slice(1)),s=a[0].length,l=o,u.length>=i));)f.lastIndex===a.index&&f.lastIndex++;return l===r.length?!s&&f.test("")||u.push(""):u.push(r.slice(l)),u.length>i?u.slice(0,i):u}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t.call(this,e,n)}:t,[function(t,n){var i=UE(this),a=null==t?void 0:t[e];return void 0!==a?a.call(t,i,n):r.call(BE(i),t,n)},function(e,i){var a=LE(this),o=BE(e),s=n(r,a,o,i,r!==t);if(s.done)return s.value;var u=NE(a,RegExp),c=a.unicode,l=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(KE?"g":"y"),f=new u(KE?"^(?:"+a.source+")":a,l),d=void 0===i?GE:i>>>0;if(0===d)return[];if(0===o.length)return null===qE(f,o)?[o]:[];for(var p=0,h=0,v=[];h<o.length;){f.lastIndex=KE?0:h;var y,g=qE(f,KE?o.slice(h):o);if(null===g||(y=$E(FE(f.lastIndex+(KE?h:0)),o.length))===p)h=DE(o,h,c);else{if(v.push(o.slice(p,h)),v.length===d)return v;for(var m=1;m<=g.length-1;m++)if(v.push(g[m]),v.length===d)return v;h=p=y}}return v.push(o.slice(p)),v}]}),!JE,KE);var HE={exports:{}},YE={exports:{}};!function(e){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")},e.exports.__esModule=!0,e.exports.default=e.exports}(YE);var QE={exports:{}},XE={exports:{}};!function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}(XE),function(e){var t=yv.exports,n=XE.exports;function r(i,a,o){return n()?(e.exports=r=Reflect.construct,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=r=function(e,n,r){var i=[null];i.push.apply(i,n);var a=new(Function.bind.apply(e,i));return r&&t(a,r.prototype),a},e.exports.__esModule=!0,e.exports.default=e.exports),r.apply(null,arguments)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}(QE),function(e){var t=bv.exports,n=yv.exports,r=YE.exports,i=QE.exports;function a(o){var s="function"==typeof Map?new Map:void 0;return e.exports=a=function(e){if(null===e||!r(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==s){if(s.has(e))return s.get(e);s.set(e,a)}function a(){return i(e,arguments,t(this).constructor)}return a.prototype=Object.create(e.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),n(a,e)},e.exports.__esModule=!0,e.exports.default=e.exports,a(o)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}(HE);var ZE={exports:{}};!function(e,t){(function(){var r={function:!0,object:!0}["undefined"==typeof window?"undefined":Pa(window)]&&window||this,i=t,a=e&&!e.nodeType&&e,o=i&&a&&"object"==Pa(n)&&n;!o||o.global!==o&&o.window!==o&&o.self!==o||(r=o);var s=Math.pow(2,53)-1,u=/\bOpera/,c=Object.prototype,l=c.hasOwnProperty,f=c.toString;function d(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function p(e){return e=m(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:d(e)}function h(e,t){for(var n in e)l.call(e,n)&&t(e[n],n,e)}function v(e){return null==e?d(e):f.call(e).slice(8,-1)}function y(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function g(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=s)for(;++n<r;)t(e[n],n,e);else h(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function m(e){return String(e).replace(/^ +| +$/g,"")}var b=function e(t){var n=r,i=t&&"object"==Pa(t)&&"String"!=v(t);i&&(n=t,t=null);var a=n.navigator||{},o=a.userAgent||"";t||(t=o);var s,c,l=i?!!a.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(f.toString()),d="Object",b=i?d:"ScriptBridgingProxyObject",w=i?d:"Environment",k=i&&n.java?"JavaPackage":v(n.java),_=i?d:"RuntimeObject",x=/\bJava/.test(k)&&n.java,S=x&&v(n.environment)==w,E=x?"a":"α",R=x?"b":"β",I=n.document||{},T=n.operamini||n.opera,C=u.test(C=i&&T?T["[[Class]]"]:v(T))?C:T=null,O=t,P=[],A=null,j=t==o,M=j&&T&&"function"==typeof T.version&&T.version(),L=g([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)})),U=function(e){return g(e,(function(e,n){return e||RegExp("\\b"+(n.pattern||y(n))+"\\b","i").exec(t)&&(n.label||n)}))}(["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"]),N=B([{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"]),D=function(e){return g(e,(function(e,n,r){return e||(n[N]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(N)]||RegExp("\\b"+y(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r}))}({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}}),F=function(e){return g(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"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 t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),p(e.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])}(e,r,n.label||n)),e}))}(["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 B(e){return g(e,(function(e,n){var r=n.pattern||y(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=p(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function q(e){return g(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(L&&(L=[L]),/\bAndroid\b/.test(F)&&!N&&(s=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(N=m(s[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),D&&!N?N=B([D]):D&&N&&(N=N.replace(RegExp("^("+y(D)+")[-_.\\s]","i"),D+" ").replace(RegExp("^("+y(D)+")[-_.]?(\\w)","i"),D+" $2")),(s=/\bGoogle TV\b/.exec(N))&&(N=s[0]),/\bSimulator\b/i.test(t)&&(N=(N?N+" ":"")+"Simulator"),"Opera Mini"==U&&/\bOPiOS\b/.test(t)&&P.push("running in Turbo/Uncompressed mode"),"IE"==U&&/\blike iPhone OS\b/.test(t)?(D=(s=e(t.replace(/like iPhone OS/,""))).manufacturer,N=s.product):/^iP/.test(N)?(U||(U="Safari"),F="iOS"+((s=/ OS ([\d_]+)/i.exec(t))?" "+s[1].replace(/_/g,"."):"")):"Konqueror"==U&&/^Linux\b/i.test(F)?F="Kubuntu":D&&"Google"!=D&&(/Chrome/.test(U)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(N))||/\bAndroid\b/.test(F)&&/^Chrome/.test(U)&&/\bVersion\//i.test(t)?(U="Android Browser",F=/\bAndroid\b/.test(F)?F:"Android"):"Silk"==U?(/\bMobi/i.test(t)||(F="Android",P.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&P.unshift("accelerated")):"UC Browser"==U&&/\bUCWEB\b/.test(t)?P.push("speed mode"):"PaleMoon"==U&&(s=/\bFirefox\/([\d.]+)\b/.exec(t))?P.push("identifying as Firefox "+s[1]):"Firefox"==U&&(s=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(F||(F="Firefox OS"),N||(N=s[1])):!U||(s=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(U))?(U&&!N&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(s+"/")+8))&&(U=null),(s=N||D||F)&&(N||D||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(F))&&(U=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(F)?F:s)+" Browser")):"Electron"==U&&(s=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&P.push("Chromium "+s),M||(M=q(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",y(U),"(?:Firefox|Minefield|NetFront)"])),(s=("iCab"==L&&parseFloat(M)>3?"WebKit":/\bOpera\b/.test(U)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(L)&&"WebKit"||!L&&/\bMSIE\b/i.test(t)&&("Mac OS"==F?"Tasman":"Trident")||"WebKit"==L&&/\bPlayStation\b(?! Vita\b)/i.test(U)&&"NetFront")&&(L=[s]),"IE"==U&&(s=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(U+=" Mobile",F="Windows Phone "+(/\+$/.test(s)?s:s+".x"),P.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(U="IE Mobile",F="Windows Phone 8.x",P.unshift("desktop mode"),M||(M=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=U&&"Trident"==L&&(s=/\brv:([\d.]+)/.exec(t))&&(U&&P.push("identifying as "+U+(M?" "+M:"")),U="IE",M=s[1]),j){if(function(e,t){var n=null!=e?Pa(e[t]):"number";return!(/^(?:boolean|number|string|undefined)$/.test(n)||"object"==n&&!e[t])}(n,"global"))if(x&&(O=(s=x.lang.System).getProperty("os.arch"),F=F||s.getProperty("os.name")+" "+s.getProperty("os.version")),S){try{M=n.require("ringo/engine").version.join("."),U="RingoJS"}catch(e){(s=n.system)&&s.global.system==n.system&&(U="Narwhal",F||(F=s[0].os||null))}U||(U="Rhino")}else"object"==Pa(n.process)&&!n.process.browser&&(s=n.process)&&("object"==Pa(s.versions)&&("string"==typeof s.versions.electron?(P.push("Node "+s.versions.node),U="Electron",M=s.versions.electron):"string"==typeof s.versions.nw&&(P.push("Chromium "+M,"Node "+s.versions.node),U="NW.js",M=s.versions.nw)),U||(U="Node.js",O=s.arch,F=s.platform,M=(M=/[\d.]+/.exec(s.version))?M[0]:null));else v(s=n.runtime)==b?(U="Adobe AIR",F=s.flash.system.Capabilities.os):v(s=n.phantom)==_?(U="PhantomJS",M=(s=s.version||null)&&s.major+"."+s.minor+"."+s.patch):"number"==typeof I.documentMode&&(s=/\bTrident\/(\d+)/i.exec(t))?(M=[M,I.documentMode],(s=+s[1]+4)!=M[1]&&(P.push("IE "+M[1]+" mode"),L&&(L[1]=""),M[1]=s),M="IE"==U?String(M[1].toFixed(1)):M[0]):"number"==typeof I.documentMode&&/^(?:Chrome|Firefox)\b/.test(U)&&(P.push("masking as "+U+" "+M),U="IE",M="11.0",L=["Trident"],F="Windows");F=F&&p(F)}if(M&&(s=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(M)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(j&&a.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(A=/b/i.test(s)?"beta":"alpha",M=M.replace(RegExp(s+"\\+?$"),"")+("beta"==A?R:E)+(/\d+\+?/.exec(s)||"")),"Fennec"==U||"Firefox"==U&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(F))U="Firefox Mobile";else if("Maxthon"==U&&M)M=M.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(N))"Xbox 360"==N&&(F=null),"Xbox 360"==N&&/\bIEMobile\b/.test(t)&&P.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(U)&&(!U||N||/Browser|Mobi/.test(U))||"Windows CE"!=F&&!/Mobi/i.test(t))if("IE"==U&&j)try{null===n.external&&P.unshift("platform preview")}catch(e){P.unshift("embedded")}else(/\bBlackBerry\b/.test(N)||/\bBB10\b/.test(t))&&(s=(RegExp(N.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||M)?(F=((s=[s,/BB10/.test(t)])[1]?(N=null,D="BlackBerry"):"Device Software")+" "+s[0],M=null):this!=h&&"Wii"!=N&&(j&&T||/Opera/.test(U)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==U&&/\bOS X (?:\d+\.){2,}/.test(F)||"IE"==U&&(F&&!/^Win/.test(F)&&M>5.5||/\bWindows XP\b/.test(F)&&M>8||8==M&&!/\bTrident\b/.test(t)))&&!u.test(s=e.call(h,t.replace(u,"")+";"))&&s.name&&(s="ing as "+s.name+((s=s.version)?" "+s:""),u.test(U)?(/\bIE\b/.test(s)&&"Mac OS"==F&&(F=null),s="identify"+s):(s="mask"+s,U=C?p(C.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(s)&&(F=null),j||(M=null)),L=["Presto"],P.push(s));else U+=" Mobile";(s=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(s=[parseFloat(s.replace(/\.(\d)$/,".0$1")),s],"Safari"==U&&"+"==s[1].slice(-1)?(U="WebKit Nightly",A="alpha",M=s[1].slice(0,-1)):M!=s[1]&&M!=(s[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(M=null),s[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==s[0]&&537.36==s[2]&&parseFloat(s[1])>=28&&"WebKit"==L&&(L=["Blink"]),j&&(l||s[1])?(L&&(L[1]="like Chrome"),s=s[1]||((s=s[0])<530?1:s<532?2:s<532.05?3:s<533?4:s<534.03?5:s<534.07?6:s<534.1?7:s<534.13?8:s<534.16?9:s<534.24?10:s<534.3?11:s<535.01?12:s<535.02?"13+":s<535.07?15:s<535.11?16:s<535.19?17:s<536.05?18:s<536.1?19:s<537.01?20:s<537.11?"21+":s<537.13?23:s<537.18?24:s<537.24?25:s<537.36?26:"Blink"!=L?"27":"28")):(L&&(L[1]="like Safari"),s=(s=s[0])<400?1:s<500?2:s<526?3:s<533?4:s<534?"4+":s<535?5:s<537?6:s<538?7:s<601?8:s<602?9:s<604?10:s<606?11:s<608?12:"12"),L&&(L[1]+=" "+(s+="number"==typeof s?".x":/[.+]/.test(s)?"":"+")),"Safari"==U&&(!M||parseInt(M)>45)?M=s:"Chrome"==U&&/\bHeadlessChrome/i.test(t)&&P.unshift("headless")),"Opera"==U&&(s=/\bzbov|zvav$/.exec(F))?(U+=" ",P.unshift("desktop mode"),"zvav"==s?(U+="Mini",M=null):U+="Mobile",F=F.replace(RegExp(" *"+s+"$"),"")):"Safari"==U&&/\bChrome\b/.exec(L&&L[1])?(P.unshift("desktop mode"),U="Chrome Mobile",M=null,/\bOS X\b/.test(F)?(D="Apple",F="iOS 4.3+"):F=null):/\bSRWare Iron\b/.test(U)&&!M&&(M=q("Chrome")),M&&0==M.indexOf(s=/[\d.]+$/.exec(F))&&t.indexOf("/"+s+"-")>-1&&(F=m(F.replace(s,""))),F&&-1!=F.indexOf(U)&&!RegExp(U+" OS").test(F)&&(F=F.replace(RegExp(" *"+y(U)+" *"),"")),L&&!/\b(?:Avant|Nook)\b/.test(U)&&(/Browser|Lunascape|Maxthon/.test(U)||"Safari"!=U&&/^iOS/.test(F)&&/\bSafari\b/.test(L[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(U)&&L[1])&&(s=L[L.length-1])&&P.push(s),P.length&&(P=["("+P.join("; ")+")"]),D&&N&&N.indexOf(D)<0&&P.push("on "+D),N&&P.push((/^on /.test(P[P.length-1])?"":"on ")+N),F&&(s=/ ([\d.+]+)$/.exec(F),c=s&&"/"==F.charAt(F.length-s[0].length-1),F={architecture:32,family:s&&!c?F.replace(s[0],""):F,version:s?s[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(s=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(O))&&!/\bi686\b/i.test(O)?(F&&(F.architecture=64,F.family=F.family.replace(RegExp(" *"+s),"")),U&&(/\bWOW64\b/i.test(t)||j&&/\w(?:86|32)$/.test(a.cpuClass||a.platform)&&!/\bWin64; x64\b/i.test(t))&&P.unshift("32-bit")):F&&/^OS X/.test(F.family)&&"Chrome"==U&&parseFloat(M)>=39&&(F.architecture=64),t||(t=null);var z={};return z.description=t,z.layout=L&&L[0],z.manufacturer=D,z.name=U,z.prerelease=A,z.product=N,z.ua=t,z.version=U&&M,z.os=F||{architecture:null,family:null,version:null,toString:function(){return"null"}},z.parse=e,z.toString=function(){return this.description||""},z.version&&P.unshift(M),z.name&&P.unshift(U),F&&U&&(F!=String(F).split(" ")[0]||F!=U.split(" ")[0]&&!N)&&P.push(N?"("+F+")":"on "+F),P.length&&(z.description=P.join(" ")),z}();i&&a?h(b,(function(e,t){i[t]=e})):r.platform=b}).call(n)}(ZE,ZE.exports);var eR=Fe,tR=Dt,nR=Er,rR=k,iR=Np,aR=Vp;Lp("match",(function(e,t,n){return[function(t){var n=rR(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](nR(n))},function(e){var r=eR(this),i=nR(e),a=n(t,r,i);if(a.done)return a.value;if(!r.global)return aR(r,i);var o=r.unicode;r.lastIndex=0;for(var s,u=[],c=0;null!==(s=aR(r,i));){var l=nR(s[0]);u[c]=l,""===l&&(r.lastIndex=iR(i,tR(r.lastIndex),o)),c++}return 0===c?null:u}]}));var oR=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},sR=Fe,uR=k,cR=oR,lR=Er,fR=Vp;Lp("search",(function(e,t,n){return[function(t){var n=uR(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](lR(n))},function(e){var r=sR(this),i=lR(e),a=n(t,r,i);if(a.done)return a.value;var o=r.lastIndex;cR(o,0)||(r.lastIndex=0);var s=fR(r,i);return cR(r.lastIndex,o)||(r.lastIndex=o),null===s?-1:s.index}]}));var dR=Tn,pR=zt,hR=Lt,vR=Dt,yR=X,gR=Kr,mR=ka,bR=la("splice"),wR=Math.max,kR=Math.min,_R=9007199254740991,xR="Maximum allowed length exceeded";dR({target:"Array",proto:!0,forced:!bR},{splice:function(e,t){var n,r,i,a,o,s,u=yR(this),c=vR(u.length),l=pR(e,c),f=arguments.length;if(0===f?n=r=0:1===f?(n=0,r=c-l):(n=f-2,r=kR(wR(hR(t),0),c-l)),c+n-r>_R)throw TypeError(xR);for(i=gR(u,r),a=0;a<r;a++)(o=l+a)in u&&mR(i,a,u[o]);if(i.length=r,n<r){for(a=l;a<c-r;a++)s=a+n,(o=a+r)in u?u[s]=u[o]:delete u[s];for(a=c;a>c-r+n;a--)delete u[a-1]}else if(n>r)for(a=c-r;a>l;a--)s=a+n-1,(o=a+r-1)in u?u[s]=u[o]:delete u[s];for(a=0;a<n;a++)u[a+l]=arguments[a+2];return u.length=c-r+n,i}}),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=qm.exports,r=mv.exports,i=Ty.exports,a=vv.exports,o=gv.exports,s=bv.exports,u=pv.exports,c=hv.exports,l=Oy.exports,f=zm,d=wh.exports,p=bh,h=Sf.exports,v=Zm.exports,y=tb,g=HE.exports,m=tm,b=Iy,w=ZE.exports;function k(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function _(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var x=k(n),S=k(r),E=k(i),R=k(a),I=k(o),T=k(s),C=k(u),O=k(c),P=k(l),A=k(f),j=k(d),M=_(h),L=_(v),U=k(g),N=_(w);var D=M.getLogger("twilsock");function F(e,t){return["".concat((new Date).toISOString()," Twilsock ").concat(e,":")].concat(Array.from(t))}var B=function(){function e(t){O.default(this,e),P.default(this,"prefix",""),this.prefix=null!=t&&t.length>0?" "+t+":":""}return C.default(e,[{key:"setLevel",value:function(e){D.setLevel(e)}},{key:"trace",value:function(){if(D.getLevel()==D.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.debug.apply(null,F("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.debug.apply(null,F("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.info.apply(null,F("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.warn.apply(null,F("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.error.apply(null,F("E",t))}}],[{key:"setLevel",value:function(e){D.setLevel(e)}},{key:"trace",value:function(){if(D.getLevel()==D.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.debug.apply(null,F("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.debug.apply(null,F("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.info.apply(null,F("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.warn.apply(null,F("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];D.error.apply(null,F("E",t))}}]),e}(),q=new B(""),z="0.14.0",W=function(){function e(t,n,r){O.default(this,e),P.default(this,"confirmedCapabilities",new Set),this.activeGrant=n,this._token=t;var i=r.region||"us1",a="wss://tsock.".concat(i,".twilio.com/v3/wsconnect"),o=r.twilsock||r.Twilsock||{};this.url=o.uri||a,this._continuationToken=r.continuationToken?r.continuationToken:null,this.logLevel=r.logLevel?r.logLevel:"error",this.retryPolicy=r.retryPolicy?r.retryPolicy:{min:1e3,max:12e4,randomness:.2},this.clientMetadata=r.clientMetadata?r.clientMetadata:{},this.clientMetadata.ver=z,this.initRegistrations=r.initRegistrations?r.initRegistrations:null,this.tweaks=r.tweaks?r.tweaks:null}return C.default(e,[{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}}]),e}(),K=C.default((function e(t){O.default(this,e),this.id=t||"TM".concat(y.v4())}));function V(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var $=function(e){R.default(n,e);var t=V(n);function n(e,r,i,a,o){var s;return O.default(this,n),s=t.call(this),P.default(S.default(s),"method","init"),s.token=e,s.continuation_token=r,s.metadata=i,s.registrations=a,s.tweaks=o,s.capabilities=["client_update","offline_storage","telemetry.v1"],s}return C.default(n)}(K);function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var J=function(e){R.default(n,e);var t=G(n);function n(e,r,i,a,o,s,u){var c;return O.default(this,n),(c=t.call(this,e)).continuationToken=r,c.continuationTokenStatus=a,c.offlineStorage=o,c.initRegistrations=s,c.debugInfo=u,c.confirmedCapabilities=i,c}return C.default(n)}(K);function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Y=function(e){R.default(n,e);var t=H(n);function n(e){var r;return O.default(this,n),r=t.call(this),P.default(S.default(r),"method","update"),r.token=e,r}return C.default(n)}(K);function Q(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Message=function(e){R.default(Message,e);var t=Q(Message);function Message(e,n,r){var i;return O.default(this,Message),i=t.call(this),P.default(S.default(i),"method","message"),i.active_grant=e,i.payload_type=n,i.http_request=r,i}return C.default(Message)}(K);function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Z=function(e){R.default(n,e);var t=X(n);function n(e){var r;return O.default(this,n),r=t.call(this,e),P.default(S.default(r),"method","reply"),P.default(S.default(r),"payload_type","application/json"),P.default(S.default(r),"status",{code:200,status:"OK"}),r}return C.default(n)}(K);function ee(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var te=function(e){R.default(n,e);var t=ee(n);function n(){var e;return O.default(this,n),e=t.call(this),P.default(S.default(e),"method","close"),e}return C.default(n)}(K);function ne(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var re=C.default((function e(t,n,r,i,a,o){O.default(this,e),this.start=t,this.end=n,this.title=r,this.details=i,this.id=a,this.type=o})),ie=function(e){R.default(n,e);var t=ne(n);function n(e){var r;return O.default(this,n),r=t.call(this),P.default(S.default(r),"method","telemetry.v1"),r.events=e,r}return C.default(n)}(K);function ae(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(Number("0x"+t))})).length}function oe(e){var t=encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(Number("0x"+t))})),n=new Uint8Array(t.length);return Array.prototype.forEach.call(t,(function(e,t){n[t]=e.charCodeAt(0)})),n}function se(e){var t=Array.prototype.map.call(e,(function(e){return String.fromCharCode(e)})).join("").replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n}));return decodeURIComponent(t)}function ue(e){return JSON.parse(se(e))}var ce=function(){function e(){O.default(this,e)}return C.default(e,null,[{key:"parse",value:function(e){var t,n,r=new Uint8Array(e),i=function(e){for(var t="",n=0;n<e.length;++n){var r=String.fromCharCode(e[n]);if(t+=r,"\r"===r){n+=2;break}}var i=t.split(" ");return{size:n,protocol:i[0],version:i[1],headerSize:Number(i[2])}}(r);if("TWILSOCK"!==i.protocol||"V3.0"!==i.version)return q.error("unsupported protocol: ".concat(i.protocol," ver ").concat(i.version)),null;try{t=ue(r.subarray(i.size,i.size+i.headerSize))}catch(t){return q.error("failed to parse message header",t,e),null}if(q.debug("message received:",t.method),t.payload_size>0){var a=2+i.size+i.headerSize,o=t.payload_size;if(t.hasOwnProperty("payload_type")&&0!==t.payload_type.indexOf("application/json"))0===t.payload_type.indexOf("text/plain")&&(n=se(r.subarray(a,a+o)));else try{n=ue(r.subarray(a,a+o))}catch(t){return q.error("failed to parse message body",t,e),null}}return{method:t.method,header:t,payload:n}}},{key:"createPacket",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";e.payload_size=ae(t);var n=JSON.stringify(e),r="TWILSOCK V3.0 "+ae(n);q.debug("send request:",r+n+t);var i=oe(r+"\r\n"+n+"\r\n"+t);return i.buffer}}]),e}();function le(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var fe=function(e){R.default(n,e);var t=le(n);function n(e){return O.default(this,n),t.call(this,e)}return C.default(n)}(U.default(Error));function de(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var pe=function(e){R.default(n,e);var t=de(n);function n(e,r){var i;return O.default(this,n),(i=t.call(this,e)).reply=r,i}return C.default(n)}(fe);function he(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ve(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?he(Object(n),!0).forEach((function(t){P.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):he(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ye(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var ge=function(e){R.default(n,e);var t=ye(n);function n(e){var r;return O.default(this,n),r=t.call(this),P.default(S.default(r),"newBackoff",null),P.default(S.default(r),"usedBackoff",null),P.default(S.default(r),"retrier",null),r.options=e?ve({},e):{},r}return C.default(n,[{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(e){this.newBackoff=e}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");var e,t;this.newBackoff?!this.usedBackoff||this.usedBackoff<this.newBackoff?this.createRetrier():null===(e=this.retrier)||void 0===e||e.failed(new Error):null===(t=this.retrier)||void 0===t||t.failed(new Error)}},{key:"cancel",value:function(){var e;null===(e=this.retrier)||void 0===e||e.cancel()}},{key:"cleanRetrier",value:function(){var e,t;null===(e=this.retrier)||void 0===e||e.removeAllListeners(),null===(t=this.retrier)||void 0===t||t.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var e=ve({},this.options);return this.newBackoff&&(e.min=this.newBackoff,e.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),e.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,e}},{key:"createRetrier",value:function(){var e=this;this.cleanRetrier();var t=this.getRetryPolicy();this.retrier=new m.Retrier(t),this.retrier.once("attempt",(function(){var t,n;null===(t=e.retrier)||void 0===t||t.on("attempt",(function(){return e.emit("attempt")})),null===(n=e.retrier)||void 0===n||n.failed(new Error("Skipping first attempt"))})),this.retrier.on("failed",(function(t){return e.emit("failed",t)})),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),n}(b.ReplayEventEmitter);function me(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var be=function(e){R.default(i,e);var t,n,r=me(i);function i(e,t,n){var a;O.default(this,i),a=r.call(this),P.default(S.default(a),"disconnectingTimer",null),P.default(S.default(a),"disconnectedPromiseResolve",null),P.default(S.default(a),"terminalStates",["disconnected","rejected"]),P.default(S.default(a),"tokenExpiredSasCode",20104),P.default(S.default(a),"terminationReason","Connection is not initialized"),a.websocket=e,a.websocket.on("connected",(function(){return a.fsm.socketConnected()})),a.websocket.on("disconnected",(function(){return a.fsm.socketClosed()})),a.websocket.on("message",(function(e){return a.onIncomingMessage(e)})),a.websocket.on("socketError",(function(e){a.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(e.message),httpStatusCode:null,errorCode:null}),a.emit("stateChanged","retrying")})),a.transport=t,a.config=n,a.retrier=new ge(n.retryPolicy),a.retrier.on("attempt",(function(){return a.retry()})),a.retrier.on("failed",(function(e){q.warn("Retrying failed: ".concat(e.message)),a.disconnect()})),"undefined"!=typeof window&&void 0!==window.addEventListener&&(window.addEventListener("online",(function(){q.debug("Browser reported connectivity state: online"),a.resetBackoff(),a.fsm.systemOnline()})),window.addEventListener("offline",(function(){q.debug("Browser reported connectivity state: offline"),a.websocket.close(),a.fsm.socketClosed()})));var o=L.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(){a.setupSocket(),a.emit("connecting")},onEnterInitialising:function(){a.sendInit()},onLeaveInitialising:function(){a.cancelInit()},onEnterUpdating:function(){a.sendUpdate()},onLeaveUpdating:function(){a.cancelUpdate()},onEnterRetrying:function(){a.initRetry(),a.emit("connecting")},onEnterConnected:function(){a.resetBackoff(),a.onConnected()},onUserUpdateToken:function(){a.resetBackoff()},onTokenRejected:function(){a.resetBackoff(),a.closeSocket(!0),a.finalizeSocket()},onUserDisconnect:function(){a.closeSocket(!0)},onEnterDisconnecting:function(){a.startDisconnectTimer()},onLeaveDisconnecting:function(){a.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){a.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){a.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){a.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){a.cancelDisconnectTimer()},onDisconnected:function(){a.resetBackoff(),a.finalizeSocket()},onReceiveClose:function(){a.onCloseReceived()},onReceiveOffload:function(e,t){q.debug("onreceiveoffload: ",t),a.modifyBackoff(t.body),a.onCloseReceived()},onUnsupported:function(){a.closeSocket(!0),a.finalizeSocket()},onError:function(e,t){a.closeSocket(t),a.finalizeSocket()},onEnterState:function(e){"none"!==e.from&&a.changeState(e)},onInvalidTransition:function(e,t,n){q.warn("FSM: unexpected transition",t,n)}}});return a.fsm=new o,a}return C.default(i,[{key:"changeState",value:function(e){q.debug("FSM: ".concat(e.transition,": ").concat(e.from," --\x3e ").concat(e.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){q.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function(e){q.trace("modifyBackoff",e);var t=e?e.backoff_policy:null;t&&"number"==typeof t.reconnect_min_ms&&this.retrier.modifyBackoff(t.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var e=this;q.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout((function(){q.debug("disconnecting is timed out"),e.closeSocket(!0)}),3e3)}},{key:"cancelDisconnectTimer",value:function(){q.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return"connected"===this.state&&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";default:return"disconnected"}}},{key:"initRetry",value:function(){q.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){"connecting"!=this.fsm.state?(q.trace("retry"),this.websocket.close(),this.fsm.userRetry()):q.trace("can\t retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){q.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){q.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function(e){var t=ce.parse(e);if(t){var n=t.method,r=t.header,i=t.payload;if("reply"!==n&&this.confirmReceiving(r),"notification"===n)this.emit("message",r.message_type,i);else if("reply"===r.method)this.transport.processReply({id:r.id,status:r.status,header:r,body:i});else if("client_update"===r.method)"token_about_to_expire"===r.client_update_type&&this.emit("tokenAboutToExpire");else if("close"===r.method)if(308===r.status.code)q.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:r.status.status,body:i});else if(406===r.status.code){var a="Server closed connection because can't parse protocol: ".concat(JSON.stringify(r.status));this.emitReplyConnectionError(a,r,!0),q.error(a),this.fsm.receiveFatalClose()}else 417===r.status.code?(q.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(r.status))),this.fsm.receiveFatalClose(r.status.status)):410===r.status.code?(q.warn("Server closed connection: ".concat(JSON.stringify(r.status))),this.fsm.receiveClose(r.status.status),this.emit("tokenExpired")):401===r.status.code?(q.error("Server closed connection: ".concat(JSON.stringify(r.status))),this.fsm.receiveClose(r.status.status)):(q.warn("unexpected message: ",r.status),this.fsm.receiveOffload({status:r.status.status,body:null}))}}},{key:"sendInit",value:(n=x.default(A.default.mark((function e(){var t,n;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.trace("sendInit"),e.prev=1,this.emit("beforeSendInit"),e.next=5,this.transport.sendInit();case 5:t=e.sent,this.config.updateContinuationToken(t.continuationToken),this.config.confirmedCapabilities=t.confirmedCapabilities,this.fsm.initSuccess(t),this.emit("initialized",t),this.emit("tokenUpdated"),e.next=17;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof pe?(n=!1,q.warn("Init rejected by server: ".concat(JSON.stringify(e.t0.reply.status))),this.emit("sendInitFailed"),401===e.t0.reply.status.code||403===e.t0.reply.status.code?(n=!0,this.fsm.tokenRejected(e.t0.reply.status),e.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):429===e.t0.reply.status.code?(this.modifyBackoff(e.t0.reply.body),this.fsm.initError(!0)):500===e.t0.reply.status.code?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(e.t0.message,e.t0.reply,n)):(this.terminationReason=e.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(e.t0.message,"\n").concat(JSON.stringify(e.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",e.t0);case 17:case"end":return e.stop()}}),e,this,[[1,13]])}))),function(){return n.apply(this,arguments)})},{key:"sendUpdate",value:(t=x.default(A.default.mark((function e(){var t,n,r;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.trace("sendUpdate"),t=new Y(this.config.token),e.prev=2,e.next=5,this.transport.sendWithReply(t);case 5:n=e.sent,this.fsm.updateSuccess(n.body),this.emit("tokenUpdated"),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(2),e.t0 instanceof pe?(r=!1,q.warn("Token update rejected by server: ".concat(JSON.stringify(e.t0.reply.status))),401===e.t0.reply.status.code||403===e.t0.reply.status.code?(r=!0,this.fsm.tokenRejected(e.t0.reply.status),e.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):429===e.t0.reply.status.code?(this.modifyBackoff(e.t0.reply.body),this.fsm.updateError(e.t0.reply.status)):this.fsm.updateError(e.t0.reply.status),this.emitReplyConnectionError(e.t0.message,e.t0.reply,r)):(this.emit("error",!1,e.t0.message,null,null),this.fsm.updateError(e.t0)),this.emit("tokenUpdated",e.t0);case 14:case"end":return e.stop()}}),e,this,[[2,10]])}))),function(){return t.apply(this,arguments)})},{key:"emitReplyConnectionError",value:function(e,t,n){var r=t.status&&t.status.description?t.status.description:e,i=t.status.code,a=t.status&&t.status.errorCode?t.status.errorCode:null;n&&(this.terminationReason=r),this.emit("connectionError",{terminal:n,message:"Connection error: ".concat(r),httpStatusCode:i,errorCode:a})}},{key:"cancelInit",value:function(){q.trace("cancelInit")}},{key:"cancelUpdate",value:function(){q.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(e){q.trace("confirmReceiving");try{this.transport.send(new Z(e.id))}catch(e){q.debug("failed to confirm packet receiving",e)}}},{key:"closeSocket",value:function(e){var t=this;q.trace("closeSocket (graceful: ".concat(e,")")),e&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),function(e){setTimeout(e,0)}((function(){return t.fsm.socketClosed()}))}},{key:"connect",value:function(){q.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var e=this;return q.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise((function(t){e.disconnectedPromiseResolve=t,e.fsm.userDisconnect()}))}},{key:"updateToken",value:function(e){var t=this;return q.trace("updateToken:",e),new Promise((function(e,n){t.once("tokenUpdated",(function(t){t?n(t):e()})),t.fsm.userUpdateToken()}))}},{key:"isTerminalState",get:function(){return-1!==this.terminalStates.indexOf(this.fsm.state)}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),i}(b.ReplayEventEmitter),we=function(){function e(){O.default(this,e)}return C.default(e,null,[{key:"getMetadata",value:function(e){var t,n,r,i,a,o,s,u,c=e&&e.clientMetadata?e.clientMetadata:{},l={env:null!==(t=N.name)&&void 0!==t?t:"unknown",envv:null!==(n=N.version)&&void 0!==n?n:"unknown",os:null!==(r=null===(i=N.os)||void 0===i?void 0:i.family)&&void 0!==r?r:"unknown",osv:null!==(a=null===(o=N.os)||void 0===o?void 0:o.version)&&void 0!==a?a:"unknown",osa:null!==(s=null===(u=N.os)||void 0===u?void 0:u.architecture)&&void 0!==s?s:"unknown",sdk:"js-default"},f={};return["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"].filter((function(e){return e in c||e in l})).forEach((function(e){return f[e]=e in c?c[e]:l[e]})),f}}]),e}();var ke=function(){function e(t,n){var r=this;O.default(this,e),this.config=n,this.activeRequests=new Map,this.channel=t,this.channel.on("reply",(function(e){return r.processReply(e)})),this.channel.on("disconnected",(function(){r.activeRequests.forEach((function(e){clearTimeout(e.timeout),e.reject(new fe("disconnected"))})),r.activeRequests.clear()}))}var t;return C.default(e,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(e){var t,n=this.activeRequests.get(e.id);n&&(clearTimeout(n.timeout),this.activeRequests.delete(e.id),(t=e.status.code)>=200&&t<300?n.resolve(e):(n.reject(new pe("Transport failure: "+e.status.status,e)),q.trace("message rejected")))}},{key:"storeRequest",value:function(e,t,n){var r={resolve:t,reject:n,timeout:setTimeout((function(){q.trace("request",e,"is timed out"),n(new fe("Twilsock: request timeout: "+e))}),3e4)};this.activeRequests.set(e,r)}},{key:"shutdown",value:function(){this.activeRequests.forEach((function(e){clearTimeout(e.timeout),e.reject(new fe("Twilsock: request cancelled by user"))})),this.activeRequests.clear()}},{key:"sendInit",value:(t=x.default(A.default.mark((function e(){var t,n,r;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.trace("sendInit"),t=we.getMetadata(this.config),n=new $(this.config.token,this.config.continuationToken,t,this.config.initRegistrations,this.config.tweaks),e.next=5,this.sendWithReply(n);case 5:return r=e.sent,e.abrupt("return",new J(r.id,r.header.continuation_token,new Set(r.header.capabilities),r.header.continuation_token_status,r.header.offline_storage,r.header.init_registrations,r.header.debug_info));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"sendClose",value:function(){var e=new te;this.send(e)}},{key:"sendWithReply",value:function(e,t){var n=this;return new Promise((function(r,i){var a=n.send(e,t);n.storeRequest(a,r,i)}))}},{key:"send",value:function(e,t){e.id=e.id||"TM".concat(y.v4());var n=ce.createPacket(e,function(e){switch(j.default(e)){case"undefined":return"";case"object":return JSON.stringify(e);default:return e}}(t));try{return this.channel.send(n),e.id}catch(t){throw q.debug("failed to send ",e,t),q.trace(t.stack),t}}}]),e}();function _e(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var xe=function(e){R.default(r,e);var n=_e(r);function r(e){var i;return O.default(this,r),i=n.call(this),P.default(S.default(i),"socket",null),i.url=e,i.url=e,i.WebSocket=t.WebSocket||t.MozWebSocket||{},i}return C.default(r,[{key:"isConnected",get:function(){return!!this.socket&&1===this.socket.readyState}},{key:"connect",value:function(){var e,t=this;q.trace("connecting to socket");try{e=new this.WebSocket(this.url)}catch(e){return q.debug("Socket error: ".concat(this.url)),void this.emit("socketError",e)}e.binaryType="arraybuffer",e.onopen=function(){q.debug("socket opened ".concat(t.url)),t.emit("connected")},e.onclose=function(e){q.debug("socket closed",e),t.emit("disconnected",e)},e.onerror=function(e){q.debug("Socket error:",e),t.emit("socketError",e)},e.onmessage=function(e){t.emit("message",e.data)},this.socket=e}},{key:"send",value:function(e){return this.socket&&this.socket.send(e)}},{key:"close",value:function(){if(q.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{}}}}]),r}(b.ReplayEventEmitter);function Se(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Ee=function(e){R.default(u,e);var t,n,r,i,a,o,s=Se(u);function u(e){var t;return O.default(this,u),(t=s.call(this)).transport=e,t.registrations=new Map,t.registrationsInProgress=new Map,t}return C.default(u,[{key:"putNotificationContext",value:(o=x.default(A.default.mark((function e(t,n){var r;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={method:"put_notification_ctx",notification_ctx_id:t},e.next=3,this.transport.sendWithReply(r,n);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"deleteNotificationContext",value:(a=x.default(A.default.mark((function e(t){var n;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={method:"delete_notification_ctx",notification_ctx_id:t},e.next=3,this.transport.sendWithReply(n);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateRegistration",value:(i=x.default(A.default.mark((function e(t,n){var r,i;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.debug("update registration for context",t),(r=this.registrationsInProgress.get(t))||(r=new Set,this.registrationsInProgress.set(t,r)),i=y.v4(),r.add(i),e.prev=5,e.next=8,this.putNotificationContext(t,n);case 8:q.debug("registration attempt succeeded for context",n),r.delete(i),0===r.size&&(this.registrationsInProgress.delete(t),this.emit("registered",t)),e.next=19;break;case 13:e.prev=13,e.t0=e.catch(5),q.warn("registration attempt failed for context",n),q.debug(e.t0),r.delete(i),0===r.size&&(this.registrationsInProgress.delete(t),this.emit("registrationFailed",t,e.t0));case 19:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e,t){return i.apply(this,arguments)})},{key:"updateRegistrations",value:(r=x.default(A.default.mark((function e(){var t,n=this;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q.trace("refreshing ".concat(this.registrations.size," registrations")),t=[],this.registrations.forEach((function(e,r){t.push(n.updateRegistration(r,e))})),e.next=5,Promise.all(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"setNotificationsContext",value:(n=x.default(A.default.mark((function e(t,n){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&n){e.next=2;break}throw new fe("Invalid arguments provided");case 2:return this.registrations.set(t,n),e.next=5,this.updateRegistration(t,n);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeNotificationsContext",value:(t=x.default(A.default.mark((function e(t){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.registrations.has(t)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.deleteNotificationContext(t);case 4:this.transport.isConnected&&this.registrations.delete(t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),u}(b.ReplayEventEmitter);function Re(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Ie=function(e){R.default(n,e);var t=Re(n);function n(e,r,i){var a;return O.default(this,n),(a=t.call(this,r)).status=e,a.description=r,a.body=i,a}return C.default(n)}(fe);function Te(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var Ce=function(e){R.default(n,e);var t=Te(n);function n(e){return O.default(this,n),t.call(this,e)}return C.default(n)}(fe);function Oe(e,t){var n=function(e){var t=e.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(t){var n={protocol:t[1],host:t[2],hostname:t[3],port:t[4],pathname:t[5],search:t[6],hash:t[7],params:{}};if(n.search.length>0){var r=n.search.substring(1);n.params=r.split("&").map((function(e){return e.split("=")})).reduce((function(e,t){return e.hasOwnProperty(t[0])?Array.isArray(e[t[0]])?e[t[0]].push(t[1]):e[t[0]]=[e[t[0]],t[1]]:e[t[0]]=t[1],e}),{})}return n}throw new fe("Incorrect URI: "+e)}(t),r={method:e,host:n.host,path:n.pathname};return n.params&&(r.params=n.params),r}function Pe(e,t,n,r,i){return{to:Oe(e,t),headers:n,body:r,grant:i}}var Ae=function(){function e(t,n,r){O.default(this,e),this.config=r,this.transport=t,this.pendingMessages=[],this.twilsock=n}var t;return C.default(e,[{key:"saveMessage",value:function(e){var t=this;return new Promise((function(n,r){var i={message:e,resolve:n,reject:r,alreadyRejected:!1,timeout:setTimeout((function(){q.debug("request is timed out"),r(new fe("request '".concat(e.to.method,"' to '").concat(e.to.host,"' timed out"))),i.alreadyRejected=!0}),2e4)};t.pendingMessages.push(i)}))}},{key:"sendPendingMessages",value:function(){for(var e=this,t=function(){var t=e.pendingMessages[0];if(!t.alreadyRejected)try{var n=t.message;e.actualSend(n).then((function(e){return t.resolve(e)})).catch((function(e){return t.reject(e)})),clearTimeout(t.timeout)}catch(e){return q.debug("Failed to send pending message",e),"break"}e.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){if("break"===t())break}}},{key:"rejectPendingMessages",value:function(){var e=this;this.pendingMessages.forEach((function(t){t.reject(new Ce("Unable to connect: "+e.twilsock.getTerminationReason)),t.alreadyRejected=!0,clearTimeout(t.timeout)})),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:(t=x.default(A.default.mark((function e(t){var n,r,i,a,o,s,u,c;return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.to,i=t.headers,a=t.body,o=null!==(n=t.grant)&&void 0!==n?n:this.config.activeGrant,s={host:r.host,path:r.path,method:r.method,params:r.params,headers:i},u=new Message(o,i["Content-Type"]||"application/json",s),q.trace("Sending upstream message",u),e.next=9,this.transport.sendWithReply(u,a);case 9:if(c=e.sent,q.trace("Received upstream message response",c),!((f=c)&&f.header&&f.header.http_status)||(l=c.header.http_status.code)>=200&&l<300){e.next=13;break}throw new Ie(c.header.http_status.code,c.header.http_status.status,c.body);case 13:return e.abrupt("return",{status:c.header.http_status,headers:c.header.http_headers,body:c.body});case 14:case"end":return e.stop()}var l,f}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new Ce("Unable to connect: "+this.twilsock.getTerminationReason));var a=Pe(e,t,n,r,i);return this.twilsock.isConnected?this.actualSend(a):this.saveMessage(a)}}]),e}(),je=function(){function e(){var t=this;O.default(this,e),this._promise=new Promise((function(e,n){t._resolve=e,t._reject=n}))}return C.default(e,[{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)}}]),e}(),Me=function(){function e(t){O.default(this,e),this.id=t}return C.default(e,null,[{key:"create",value:function(t){if(t instanceof Object&&"storage_id"in t)return new e(t.storage_id);throw new fe('Field "storage_id" is missing')}}]),e}(),Le=function(){function e(){return O.default(this,e),P.default(this,"initializedFlag","twilio_twilsock_token_storage"),P.default(this,"tokenStoragePrefix","twilio_continuation_token_"),e._instance||(this.initialize(),e._instance=this),e._instance}return C.default(e,[{key:"sessionStorage",value:function(){try{return t.sessionStorage}catch(e){return null}}},{key:"window",value:function(){try{return t.window}catch(e){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()){this.sessionStorage.getItem(this.initializedFlag)&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var t=this.sessionStorage.removeItem;this.window.addEventListener("unload",(function(){t(e.initializedFlag)}))}}},{key:"clear",value:function(){if(this.canStore()){for(var e=[],t=0;t<this.sessionStorage.length;t++){var n=this.sessionStorage.key(t);n&&0===n.indexOf(this.tokenStoragePrefix)&&e.push(n)}var r=this.sessionStorage.removeItem;e.forEach((function(e){return r(e)})),r(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)}}]),e}();P.default(Le,"_instance",null);var Ue,Ne,De=new Le,Fe=function(){function e(t,n,r,i,a,o){O.default(this,e),this.title=t,this.details=n,this.start=r,this.type=a,this.id=o,this.end=i}return C.default(e,[{key:"toTelemetryEvent",value:function(){var e=new Date,t=this.start,n=this.end?this.end:e;if(n<t){var r=n;n=t,t=r}var i=t.getTime()-e.getTime(),a=n.getTime()-e.getTime();return new re(i,a,this.title,this.details,this.id,this.type)}}]),e}();e.TelemetryPoint=void 0,(Ue=e.TelemetryPoint||(e.TelemetryPoint={}))[Ue.Start=0]="Start",Ue[Ue.End=1]="End",e.EventSendingLimitation=void 0,(Ne=e.EventSendingLimitation||(e.EventSendingLimitation={}))[Ne.MinEventsPortion=0]="MinEventsPortion",Ne[Ne.AnyEvents=1]="AnyEvents",Ne[Ne.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished";var Be=function(){function t(e,n){O.default(this,t),P.default(this,"minEventsPortionToSend",50),P.default(this,"maxEventsPortionToSend",100),P.default(this,"pendingEvents",new Map),P.default(this,"readyEvents",[]),P.default(this,"hasInitializationFinished",!1),P.default(this,"_canSendTelemetry",!1),this.config=e,this.packetInterface=n}return C.default(t,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(t){q.debug("TelemetryTracker.canSendTelemetry: ".concat(t," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!t&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=t,t&&this.sendTelemetry(e.EventSendingLimitation.AnyEvents),t&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(e){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(e)}},{key:"addPartialEvent",value:function(t,n,r){q.debug("Adding ".concat(r===e.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(n,"' event"));var i=this.pendingEvents.has(n);if(r===e.TelemetryPoint.Start)i&&q.debug("Overwriting starting point for '".concat(n,"' event")),this.pendingEvents.set(n,t);else{if(!i)return void q.info("Could not find started event for '".concat(n,"' event"));this.addTelemetryEvent(this.merge(this.pendingEvents.get(n),t)),this.pendingEvents.delete(n)}}},{key:"getTelemetryToSend",value:function(t){return this.canSendTelemetry&&0!=this.readyEvents.length?t==e.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(t==e.EventSendingLimitation.AnyEventsIncludingUnfinished):[]}},{key:"getTelemetryPortion",value:function(e){var t=this,n=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),r=this.readyEvents.splice(0,n);return e&&r.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach((function(e,n){if(!(r.length>=t.maxEventsPortionToSend)){var i=t.pendingEvents.get(n);t.pendingEvents.delete(n),r.push(new Fe("[UNFINISHED] ".concat(i.title),i.details,i.start,null,i.type,i.id))}})),r}},{key:"merge",value:function(e,t){return new Fe(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(e.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(e){var t=this.getTelemetryToSend(e);if(0!==t.length)try{this.packetInterface.send(new ie(t.map((function(e){return e.toTelemetryEvent()}))))}catch(e){q.debug("Error while sending ".concat(t.length," telemetry events due to ").concat(e,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(t)}}}]),t}();function qe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=T.default(e);if(t){var i=T.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return I.default(this,n)}}var ze=C.default((function e(){O.default(this,e)}));P.default(ze,"TWILSOCK_CONNECT","twilsock.sdk.connect"),P.default(ze,"TWILSOCK_INIT","twilsock.sdk.init"),e.TwilsockClient=function(t){R.default(f,t);var n,r,i,a,o,s,u,c,l=qe(f);function f(t,n,r){var i;O.default(this,f),i=l.call(this),P.default(S.default(i),"version",z),P.default(S.default(i),"offlineStorageDeferred",new je),r.continuationToken=r.continuationToken?r.continuationToken:De.getStoredToken(n);var a=i.config=new W(t,n,r);q.setLevel(a.logLevel);var o=new xe(a.url),s=new ke(o,a);return i.channel=new be(o,s,a),i.registrations=new Ee(s),i.upstream=new Ae(s,i.channel,a),i.telemetryTracker=new Be(a,s),i.channel.on("initialized",(function(){return i.telemetryTracker.canSendTelemetry=!0})),o.on("disconnected",(function(){return i.telemetryTracker.canSendTelemetry=!1})),i.registrations.on("registered",(function(e){return i.emit("registered",e)})),i.channel.on("message",(function(e,t){return setTimeout((function(){return i.emit("message",e,t)}),0)})),i.channel.on("stateChanged",(function(e){return setTimeout((function(){return i.emit("stateChanged",e)}),0)})),i.channel.on("connectionError",(function(e){return setTimeout((function(){return i.emit("connectionError",e)}),0)})),i.channel.on("tokenAboutToExpire",(function(){return setTimeout((function(){return i.emit("tokenAboutToExpire")}),0)})),i.channel.on("tokenExpired",(function(){return setTimeout((function(){return i.emit("tokenExpired")}),0)})),i.channel.on("connected",(function(){return i.registrations.updateRegistrations()})),i.channel.on("connected",(function(){return i.upstream.sendPendingMessages()})),i.channel.on("connected",(function(){return setTimeout((function(){return i.emit("connected")}),0)})),i.channel.on("beforeConnect",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Establish WebSocket connection","",new Date),ze.TWILSOCK_CONNECT,e.TelemetryPoint.Start)})),i.channel.on("connected",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Establish WebSocket connection","",new Date,new Date),ze.TWILSOCK_CONNECT,e.TelemetryPoint.End)})),i.channel.on("beforeSendInit",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Send Twilsock init","",new Date),ze.TWILSOCK_INIT,e.TelemetryPoint.Start)})),i.channel.on("initialized",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Send Twilsock init","Succeeded",new Date,new Date),ze.TWILSOCK_INIT,e.TelemetryPoint.End)})),i.channel.on("sendInitFailed",(function(){return i.telemetryTracker.addPartialEvent(new Fe("Send Twilsock init","Failed",new Date,new Date),ze.TWILSOCK_INIT,e.TelemetryPoint.End)})),i.channel.on("initialized",(function(e){i.handleStorageId(n,e),De.storeToken(e.continuationToken,n),setTimeout((function(){return i.emit("initialized",e)}),0)})),i.channel.on("disconnected",(function(){return setTimeout((function(){return i.emit("disconnected")}),0)})),i.channel.on("disconnected",(function(){return i.upstream.rejectPendingMessages()})),i.channel.on("disconnected",(function(){return i.offlineStorageDeferred.fail(new fe("Client disconnected"))})),i.offlineStorageDeferred.promise.catch((function(){})),i}return C.default(f,[{key:"emit",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return q.debug("Emitting ".concat(e.toString(),"(").concat(r.map((function(e){return JSON.stringify(e)})).join(", "),")")),(t=E.default(T.default(f.prototype),"emit",this)).call.apply(t,[this,e].concat(r))}},{key:"handleStorageId",value:function(e,t){if(t.offlineStorage)if(t.offlineStorage.hasOwnProperty(e))try{this.offlineStorageDeferred.set(Me.create(t.offlineStorage[e])),q.debug("Offline storage for '".concat(e,"' product: ").concat(JSON.stringify(t.offlineStorage[e]),"."))}catch(n){this.offlineStorageDeferred.fail(new fe("Failed to parse offline storage for ".concat(e," ").concat(JSON.stringify(t.offlineStorage[e]),". ").concat(n,".")))}else this.offlineStorageDeferred.fail(new fe("No offline storage id for '".concat(e,"' product: ").concat(JSON.stringify(t.offlineStorage))));else this.offlineStorageDeferred.fail(new fe("No offline storage id"))}},{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:(c=x.default(A.default.mark((function e(t){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(q.trace("updating token '".concat(t,"'")),this.config.token!==t){e.next=3;break}return e.abrupt("return");case 3:return this.config.updateToken(t),e.next=6,this.channel.updateToken(t);case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"setNotificationsContext",value:(u=x.default(A.default.mark((function e(t,n){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.registrations.setNotificationsContext(t,n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"removeNotificationsContext",value:(s=x.default(A.default.mark((function e(t){return A.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.registrations.removeNotificationsContext(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:(o=x.default(A.default.mark((function t(){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEventsIncludingUnfinished),t.next=3,this.channel.disconnect();case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"get",value:(a=x.default(A.default.mark((function t(n,r,i){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),t.next=3,this.upstream.send("GET",n,r,void 0,i);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,n){return a.apply(this,arguments)})},{key:"post",value:(i=x.default(A.default.mark((function t(n,r,i,a){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),t.next=3,this.upstream.send("POST",n,r,i,a);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,n,r){return i.apply(this,arguments)})},{key:"put",value:(r=x.default(A.default.mark((function t(n,r,i,a){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),t.next=3,this.upstream.send("PUT",n,r,i,a);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"delete",value:(n=x.default(A.default.mark((function t(n,r,i,a){return A.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.telemetryTracker.sendTelemetry(e.EventSendingLimitation.AnyEvents),t.next=3,this.upstream.send("DELETE",n,r,i,a);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,r,i){return n.apply(this,arguments)})},{key:"addTelemetryEvent",value:function(e){this.telemetryTracker.addTelemetryEvent(e),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(t,n,r){this.telemetryTracker.addPartialEvent(t,n,r),r===e.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),f}(b.ReplayEventEmitter),e.TwilsockClient=function(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":j.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}([p.validateConstructorTypes(p.nonEmptyString,p.nonEmptyString,[p.pureObject,"undefined",p.literal(null)]),function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":j.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}("design:paramtypes",[String,String,Object])],e.TwilsockClient);var We=function(){function e(t){O.default(this,e),this.product=t,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return C.default(e,[{key:"populateInitRegistrations",value:function(e){var t=new Set(this.message_types);for(var n in e)t.add(e[n]);this.message_types=Array.from(t)}}]),e}();e.InitRegistration=We,e.TelemetryEventDescription=Fe,e.TelemetryTracker=Be,e.TransportUnavailableError=Ce,e.Twilsock=e.TwilsockClient,e.TwilsockError=fe}(Bm);var SR={},ER=u,RR=s,IR=Fn,TR=nn,CR=c,OR=X,PR=w,AR=Object.assign,jR=Object.defineProperty,MR=!AR||RR((function(){if(ER&&1!==AR({b:1},AR(jR({},"a",{enumerable:!0,get:function(){jR(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!=AR({},e)[n]||IR(AR({},t)).join("")!=r}))?function(e,t){for(var n=OR(e),r=arguments.length,i=1,a=TR.f,o=CR.f;r>i;)for(var s,u=PR(arguments[i++]),c=a?IR(u).concat(a(u)):IR(u),l=c.length,f=0;l>f;)s=c[f++],ER&&!o.call(u,s)||(n[s]=u[s]);return n}:AR,LR=MR;Tn({target:"Object",stat:!0,forced:Object.assign!==LR},{assign:LR}),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=qm.exports,n=hv.exports,r=pv.exports,i=vv.exports,a=gv.exports,o=bv.exports,s=zm,u=wh.exports,c=Bm,l=mv.exports,f=Oy.exports,d=tm,p=Ih.exports,h=cv.exports,v=Sf.exports,y=tb,g=bh;function m(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function b(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var w=m(t),k=m(n),_=m(r),x=m(i),S=m(a),E=m(o),R=m(s),I=m(u),T=m(l),C=m(f),O=m(p),P=m(h),A=b(v),j=b(y);function M(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":I.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function L(e,t){if("object"===("undefined"==typeof Reflect?"undefined":I.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function U(){}function N(){N.init.call(this)}function D(e){return void 0===e._maxListeners?N.defaultMaxListeners:e._maxListeners}function F(e,t,n){if(t)e.call(n);else for(var r=e.length,i=G(e,r),a=0;a<r;++a)i[a].call(n)}function B(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=G(e,i),o=0;o<i;++o)a[o].call(n,r)}function q(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,o=G(e,a),s=0;s<a;++s)o[s].call(n,r,i)}function z(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var o=e.length,s=G(e,o),u=0;u<o;++u)s[u].call(n,r,i,a)}function W(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=G(e,i),o=0;o<i;++o)a[o].apply(n,r)}function K(e,t,n,r){var i,a,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=new U,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=D(e))&&i>0&&o.length>i){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else o=a[t]=n,++e._eventsCount;return e}function V(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function $(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function G(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}U.prototype=Object.create(null),N.EventEmitter=N,N.usingDomains=!1,N.prototype.domain=void 0,N.prototype._events=void 0,N.prototype._maxListeners=void 0,N.defaultMaxListeners=10,N.init=function(){this.domain=null,N.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new U,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},N.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},N.prototype.getMaxListeners=function(){return D(this)},N.prototype.emit=function(e){var t,n,r,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(n=o[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:F(n,l,this);break;case 2:B(n,l,this,arguments[1]);break;case 3:q(n,l,this,arguments[1],arguments[2]);break;case 4:z(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),a=1;a<r;a++)i[a-1]=arguments[a];W(n,l,this,i)}return!0},N.prototype.addListener=function(e,t){return K(this,e,t,!1)},N.prototype.on=N.prototype.addListener,N.prototype.prependListener=function(e,t){return K(this,e,t,!0)},N.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,V(this,e,t)),this},N.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,V(this,e,t)),this},N.prototype.removeListener=function(e,t){var n,r,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new U:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,a=n.length;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new U,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},N.prototype.off=function(e,t){return this.removeListener(e,t)},N.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new U,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new U:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),a=0;a<i.length;++a)"removeListener"!==(r=i[a])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new U,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},N.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},N.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):$.call(e,t)},N.prototype.listenerCount=$,N.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var J=A.getLogger("twilio-notificatiions");function H(e,t){return["".concat((new Date).toISOString()," Twilio.Notifications ").concat(e,":")].concat(Array.from(t))}var Y=function(){function e(){k.default(this,e)}return _.default(e,[{key:"setLevel",value:function(e){J.setLevel(e)}},{key:"trace",value:function(){if(J.getLevel()==J.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.debug.apply(null,H("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.debug.apply(null,H("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.info.apply(null,H("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.warn.apply(null,H("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];J.error.apply(null,H("E",t))}}]),e}(),Q=new Y;function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return S.default(this,n)}}var Z=_.default((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;k.default(this,e),this.token=t,this.notificationId=n,this.messageTypes=r}));function ee(e,t){var n=new Set;return e.notificationId!==t.notificationId&&n.add("notificationId"),e.token!==t.token&&n.add("token"),function(e,t){return[].concat(P.default(P.default(e).filter((function(e){return!t.has(e)}))),P.default(P.default(t).filter((function(t){return!e.has(t)}))))}(e.messageTypes,t.messageTypes).length>0&&n.add("messageType"),[n.size>0,n]}var te=function(e){x.default(r,e);var t,n=X(r);function r(e){var t;return k.default(this,r),t=n.call(this),C.default(T.default(t),"desiredState",new Z),C.default(T.default(t),"currentState",new Z),C.default(T.default(t),"_hasActiveAttempt",!1),t.channelType=e,t}return _.default(r,[{key:"setNotificationId",value:function(e){this.desiredState.notificationId=e}},{key:"isActive",value:function(){return""!==this.desiredState.notificationId}},{key:"subscribe",value:function(e){this.desiredState.messageTypes.has(e)?Q.debug("message type '".concat(e,"' for channel ").concat(this.channelType," is already registered")):this.desiredState.messageTypes.add(e)}},{key:"unsubscribe",value:function(e){this.desiredState.messageTypes.has(e)&&this.desiredState.messageTypes.delete(e)}},{key:"updateToken",value:function(e){this.desiredState.token=e}},{key:"commitChanges",value:(t=w.default(R.default.mark((function e(){var t,n,r,i,a,o;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._hasActiveAttempt){e.next=3;break}throw Q.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(t=ee(this.desiredState,this.currentState),n=O.default(t,2),r=n[0],i=n[1],r){e.next=6;break}return e.abrupt("return");case 6:if(this.currentState.notificationId||i.delete("notificationId"),Q.trace("Persisting ".concat(this.channelType," registration"),i,this.desiredState),e.prev=8,this._hasActiveAttempt=!0,(a=new Z).token=this.desiredState.token,a.notificationId=this.desiredState.notificationId,a.messageTypes=new Set(this.desiredState.messageTypes),!(a.messageTypes.size>0)){e.next=24;break}return e.next=17,this.updateRegistration(a,i);case 17:o=e.sent,this.currentState.token=o.token,this.currentState.notificationId=o.notificationId,this.currentState.messageTypes=new Set(o.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),e.next=30;break;case 24:return e.next=26,this.removeRegistration();case 26:this.currentState.token=a.token,this.currentState.notificationId=a.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:e.next=35;break;case 32:throw e.prev=32,e.t0=e.catch(8),e.t0;case 35:return e.prev=35,this._hasActiveAttempt=!1,e.finish(35);case 38:case"end":return e.stop()}}),e,this,[[8,32,35,38]])}))),function(){return t.apply(this,arguments)})}]),r}(N);function ne(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return S.default(this,n)}}var re={min:2e3,max:12e4,randomness:.2},ie=function(e){x.default(a,e);var t,n,r,i=ne(a);function a(e,t,n,r){var o;return k.default(this,a),o=i.call(this,e),C.default(T.default(o),"registrationId",null),o.context=t,o.twilsock=n,o.registrarUrl=r,o}return _.default(a,[{key:"updateRegistration",value:(r=w.default(R.default.mark((function e(t,n){var r,i,a,o,s,u=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.has("notificationId")){e.next=3;break}return e.next=3,this.removeRegistration();case 3:if(t.notificationId&&t.notificationId.length){e.next=6;break}throw Q.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return Q.trace("Registering",this.channelType,t),r={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(t.messageTypes),data:{registration_id:t.notificationId}},i=this.context.productId,a="".concat(this.registrarUrl,"?productId=").concat(i),o={"Content-Type":"application/json"},Q.trace("Creating registration for channel ".concat(this.channelType)),e.prev=12,e.next=15,new d.AsyncRetrier(re).run((function(){return u.twilsock.post(a,o,r,i)}));case 15:s=e.sent,this.registrationId=s.body.id,Q.debug("Registration created: ",s),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),Q.error("Registration failed: ",e.t0),e.t0;case 24:return e.abrupt("return",t);case 25:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t){return r.apply(this,arguments)})},{key:"removeRegistration",value:(n=w.default(R.default.mark((function e(){var t,n,r,i=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.registrationId){e.next=2;break}return e.abrupt("return");case 2:return t=this.context.productId,n="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(t),r={"Content-Type":"application/json"},Q.trace("Removing registration for ".concat(this.channelType)),e.prev=6,e.next=9,new d.AsyncRetrier(Object.assign(re,{maxAttemptsCount:3})).run((function(){return i.twilsock.delete(n,r,{},t)}));case 9:this.registrationId=null,this.currentState.notificationId="",Q.debug("Registration removed for ".concat(this.channelType)),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(6),Q.error("Failed to remove registration ",this.channelType,e.t0),e.t0;case 18:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(){return n.apply(this,arguments)})},{key:"sendDeviceRemoveRequest",value:(t=w.default(R.default.mark((function e(t){var n,r,i,a,o=this;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!==t){e.next=2;break}throw new Error("Empty registration ID");case 2:return n=this.context.productId,r="".concat(this.registrarUrl,"?productId=").concat(n),i={"Content-Type":"application/json"},a={binding_type:this.channelType,address:t},e.prev=6,Q.trace("Removing old registrations for ".concat(this.channelType)),e.next=10,new d.AsyncRetrier(Object.assign(re,{maxAttemptsCount:3})).run((function(){return o.twilsock.delete(r,i,a,n)}));case 10:this.registrationId=null,this.currentState.notificationId="",Q.debug("Registration removed for ".concat(this.channelType)),e.next=19;break;case 15:throw e.prev=15,e.t0=e.catch(6),Q.error("Failed to remove registration ",this.channelType,e.t0),e.t0;case 19:case"end":return e.stop()}}),e,this,[[6,15]])}))),function(e){return t.apply(this,arguments)})}]),a}(te);function ae(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return S.default(this,n)}}var oe,se=function(e){x.default(a,e);var t,n,r,i=ae(a);function a(e,t,n){var r;return k.default(this,a),r=i.call(this,"twilsock"),C.default(T.default(r),"contextId",j.v4()),r.productId=e,r.platform=t,r.twilsock=n,r}return _.default(a,[{key:"updateRegistration",value:(r=w.default(R.default.mark((function e(t,n){var r,i;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.has("messageType")){e.next=2;break}return e.abrupt("return",t);case 2:return r=Array.from(t.messageTypes),i={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:r},e.prev=4,e.next=7,this.twilsock.setNotificationsContext(this.contextId,i);case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(4),Q.error("Failed to update twilsock notification context: ".concat(e.t0)),e.t0;case 13:return e.abrupt("return",t);case 14:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return r.apply(this,arguments)})},{key:"removeRegistration",value:(n=w.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:e.next=9;break;case 5:throw e.prev=5,e.t0=e.catch(0),Q.error("Failed to remove twilsock notification context: ".concat(e.t0)),e.t0;case 9:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(){return n.apply(this,arguments)})},{key:"sendDeviceRemoveRequest",value:(t=w.default(R.default.mark((function e(t){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),a}(te);function ue(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=E.default(e);if(t){var i=E.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return S.default(this,n)}}var ce=g.literal("apn","fcm","twilsock");e.Notifications=oe=function(e){x.default(Client,e);var t,n,r,i=ue(Client);function Client(e){var t,n,r,a,o,s,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};k.default(this,Client),u=i.call(this),l.logLevel=null!==(t=l.logLevel)&&void 0!==t?t:"error",Q.setLevel(l.logLevel);var f=null!==(n=l.productId)&&void 0!==n?n:"notifications",d=!l.twilsockClient,p=l.twilsockClient=null!==(r=l.twilsockClient)&&void 0!==r?r:new c.TwilsockClient(e,f,l),h=null!==(a=l.notifications)&&void 0!==a?a:{},v=null!==(o=null!==(s=h.region)&&void 0!==s?s:l.region)&&void 0!==o?o:"us1",y="https://ers.".concat(v,".twilio.com/v1/registrations"),g=h.ersUrl||y;u.connectors=new Map;var m=oe._detectPlatform();return u.connectors.set("apn",new ie("apn",{protocolVersion:4,productId:f,platform:m},p,g)),u.connectors.set("fcm",new ie("fcm",{protocolVersion:3,productId:f,platform:m},p,g)),u.connectors.set("twilsock",new se(f,m,p)),p.on("stateChanged",(function(e){return u.emit("transportState",e)})),u._connector("twilsock").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),u._connector("apn").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),u._connector("fcm").on("stateChanged",(function(e,t,n){return u.emit("stateChanged",e,t,n)})),p.on("message",(function(e,t){return u._routeMessage(e,t)})),u.updateToken(e),d&&(p.connect(),u.twilsock=p),u}return _.default(Client,[{key:"shutdown",value:(r=w.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectors.clear(),!this.twilsock){e.next=4;break}return e.next=4,this.twilsock.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"setPushRegistrationId",value:function(e,t){Q.debug("Set ".concat(e," push registration id '").concat(t,"'")),this._connector(e).setNotificationId(t)}},{key:"subscribe",value:function(e,t){Q.debug("Add ".concat(e," subscriptions for message type ").concat(t)),this._connector(e).subscribe(t)}},{key:"unsubscribe",value:function(e,t){Q.debug("Remove ".concat(e," subscriptions for message type ").concat(t)),this._connector(e).unsubscribe(t)}},{key:"updateToken",value:function(e){this.connectors.forEach((function(t){return t.updateToken(e)}))}},{key:"commitChanges",value:(n=w.default(R.default.mark((function e(){var t;return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],this.connectors.forEach((function(e){e.isActive()&&t.push(e.commitChanges())})),e.next=4,Promise.all(t);case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"removeRegistrations",value:(t=w.default(R.default.mark((function e(t,n){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._connector(t).sendDeviceRemoveRequest(n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"handlePushNotification",value:function(e){return{messageType:e.twi_message_type,payload:e.payload}}},{key:"_routeMessage",value:function(e,t){Q.debug("Notification message arrived: ",e,t),this.emit("message",e,t)}},{key:"_connector",value:function(e){var t=this.connectors.get(e);if(!t)throw new Error("Unknown channel type: ".concat(e));return t}}],[{key:"_detectPlatform",value:function(){var e="";return"undefined"!=typeof navigator?(e="unknown",void 0!==navigator.product&&(e=navigator.product),void 0!==navigator.userAgent&&(e=navigator.userAgent)):e="web",e.substring(0,128)}}]),Client}(N),M([g.validateTypes(ce,g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),M([g.validateTypes(ce,g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),M([g.validateTypes(ce,g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),M([g.validateTypes(g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),M([g.validateTypesAsync(ce,g.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=oe=M([g.validateConstructorTypes(g.nonEmptyString,[g.pureObject,"undefined",g.literal(null)]),L("design:paramtypes",[String,Object])],e.Notifications)}(SR);var UR={},NR=Tn,DR=Un,FR=X,BR=Dt,qR=Er,zR=s,WR=KS,KR=no,VR=$S,$R=GS,GR=U,JR=HS,HR=[],YR=HR.sort,QR=zR((function(){HR.sort(void 0)})),XR=zR((function(){HR.sort(null)})),ZR=KR("sort"),eI=!zR((function(){if(GR)return GR<70;if(!(VR&&VR>3)){if($R)return!0;if(JR)return JR<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=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(r=0;r<47;r++)HR.push({k:t+r,v:n})}for(HR.sort((function(e,t){return t.v-e.v})),r=0;r<HR.length;r++)t=HR[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));NR({target:"Array",proto:!0,forced:QR||!XR||!ZR||!eI},{sort:function(e){void 0!==e&&DR(e);var t=FR(this);if(eI)return void 0===e?YR.call(t):YR.call(t,e);var n,r,i=[],a=BR(t.length);for(r=0;r<a;r++)r in t&&i.push(t[r]);for(i=WR(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:qR(t)>qR(n)?1:-1}}(e)),n=i.length,r=0;r<n;)t[r]=i[r++];for(;r<a;)delete t[r++];return t}}),Object.defineProperty(UR,"__esModule",{value:!0});var tI=qm.exports,nI=hv.exports,rI=pv.exports,iI=mv.exports,aI=vv.exports,oI=gv.exports,sI=bv.exports,uI=Oy.exports,cI=zm,lI=wh.exports,fI=bh,dI=Bm,pI=HE.exports,hI=Sf.exports,vI=Ih.exports,yI=tm,gI=tb,mI=Ty.exports,bI=Iy,wI=cv.exports,kI=ZE.exports;function _I(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function xI(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var SI=_I(tI),EI=_I(nI),RI=_I(rI),II=_I(iI),TI=_I(aI),CI=_I(oI),OI=_I(sI),PI=_I(uI),AI=_I(cI),jI=_I(lI),MI=_I(pI),LI=xI(hI),UI=_I(vI),NI=xI(gI),DI=_I(mI),FI=_I(wI),BI=xI(kI);function qI(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":jI.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function zI(e,t){if("object"===("undefined"==typeof Reflect?"undefined":jI.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var WI=function(){function e(t){EI.default(this,e),this.base=t,this.args=new Array,this.paths=new Array}return RI.default(e,[{key:"pathSegment",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"queryParam",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}();function KI(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var SyncError=function(e){TI.default(SyncError,e);var t=KI(SyncError);function SyncError(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return EI.default(this,SyncError),(n=t.call(this)).name=n.constructor.name,n.message="".concat(e," (status: ").concat(r,", code: ").concat(i,")"),n.status=r,n.code=i,n}return RI.default(SyncError)}(MI.default(Error)),VI=function(e){TI.default(n,e);var t=KI(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;return EI.default(this,n),(r=t.call(this,e,i,a)).body=o,r}return RI.default(n)}(SyncError);function $I(e){return JSON.parse(JSON.stringify(e))}function GI(e){if(!(void 0===e||JI(e)))throw new SyncError("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function JI(e){return function(e){return!isNaN(parseInt(e))&&isFinite(e)}(e)&&e>0}var HI=LI.getLogger("twilio-sync");function YI(e,t){return["".concat((new Date).toISOString()," Sync ").concat(e,":")].concat(Array.from(t))}var QI=function(e){HI.setLevel(e)},XI=function(){if(HI.getLevel()==HI.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];HI.debug.apply(null,YI("T",t))}},ZI=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];HI.debug.apply(null,YI("D",t))},eT=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];HI.warn.apply(null,YI("W",t))},tT=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];HI.error.apply(null,YI("E",t))},nT="/v4/Subscriptions",rT="/v3/Maps",iT="/v3/Lists",aT="/v3/Documents",oT="/v3/Streams",sT="/v3/Insights";function uT(e,t,n){return e&&void 0!==e[t]?e[t]:n}var cT=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};EI.default(this,e);var n=t.region||"us1",r="https://cds.".concat(n,".twilio.com"),i=t.cdsUri||r;this.settings={subscriptionsUri:i+nT,documentsUri:i+aT,listsUri:i+iT,mapsUri:i+rT,streamsUri:i+oT,insightsUri:i+sT,sessionStorageEnabled:uT(t.Sync,"enableSessionStorage",!0),productId:t.productId}}return RI.default(e,[{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}}]),e}();function lT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return fT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function fT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var dT=function(){function e(t){EI.default(this,e),this.localObject=t,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return RI.default(e,[{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(e,t){this.localObject._update(e,t)}},{key:"updatePending",value:function(e,t){this.pendingAction=e,this.pendingCorrelationId=t}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(e){this.rejectedWithError=e.error,this.updatePending(null,null),this.localObject.reportFailure(new SyncError("Failed to subscribe on service events: ".concat(e.error.message),e.error.status,e.error.code))}},{key:"complete",value:function(e){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(e)}},{key:"setSubscriptionState",value:function(e){this.localObject._setSubscriptionState(e)}}]),e}(),pT=function(){function e(t){var n=this;EI.default(this,e),PI.default(this,"isConnected",!1),PI.default(this,"maxBatchSize",100),PI.default(this,"subscriptionTtlTimer",null),PI.default(this,"pendingPokeReason",null),this.services=t,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;this.backoff=yI.Backoff.exponential(Object.assign({randomisationFactor:.2,initialDelay:100,maxDelay:12e4},this.services.config.backoffConfig)),this.backoff.on("ready",(function(){var e=n.getSubscriptionUpdateBatch(),t=e.action,r=e.subscriptions;t?n.applyNewSubscriptionUpdateBatch(t,r):(n.backoff.reset(),ZI("All subscriptions resolved."))}))}var t;return RI.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function e(e,t,n,r){var i,a=[],o=lT(e);try{for(o.s();!(i=o.n()).done;){var s=UI.default(i.value,2),u=s[0],c=s[1];if(!t.get(u)&&n!==c.pendingAction&&!c.rejectedWithError&&(a.push(c),r&&a.length>=r))break}}catch(e){o.e(e)}finally{o.f()}return a}var t=e(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(t.length>0)return{action:"establish",subscriptions:t};var n=e(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return n.length>0?{action:"cancel",subscriptions:n}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:(t=SI.default(AI.default.mark((function e(t,n){var r,i,a,o,s,u,c,l,f,d,p,h,v=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=4;break}return ZI("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),e.abrupt("return");case 4:n=this.processLocalActions(t,n),r=(new Date).getTime(),i=lT(n);try{for(i.s();!(a=i.n()).done;)o=a.value,this.recordActionAttemptOn(o,t,r)}catch(e){i.e(e)}finally{i.f()}return s=this.pendingPokeReason,this.pendingPokeReason=null,e.prev=10,e.next=13,this.request(t,r,s,n);case 13:u=e.sent,c=u.body.max_batch_size,!isNaN(parseInt(c))&&isFinite(c)&&c>0&&(this.maxBatchSize=c),this.subscriptionTtlTimer||(l=u.body.ttl_in_s,!isNaN(parseFloat(l))&&isFinite(l)&&l>0&&(this.subscriptionTtlTimer=setTimeout((function(){return v.onSubscriptionTtlElapsed()}),1e3*l))),"establish"===t&&(f=u.body.estimated_delivery_in_ms,!isNaN(parseFloat(f))&&isFinite(f)&&f>0?setTimeout((function(){return v.verifyPokeDelivery(r,f,n)}),f):tT("Invalid timeout: ".concat(f)),n.filter((function(e){return e.pendingCorrelationId===r})).forEach((function(e){return e.setSubscriptionState("response_in_flight")}))),this.backoff.reset(),e.next=26;break;case 21:e.prev=21,e.t0=e.catch(10),d=lT(n);try{for(d.s();!(p=d.n()).done;)h=p.value,this.recordActionFailureOn(h,t)}catch(e){d.e(e)}finally{d.f()}e.t0 instanceof dI.TransportUnavailableError?(ZI("Twilsock connection (required for subscription) not ready (c:".concat(r,"); waiting…")),this.backoff.reset()):(ZI("Failed an attempt to ".concat(t," subscriptions (c:").concat(r,"); retrying"),e.t0),this.persist());case 26:case"end":return e.stop()}}),e,this,[[10,21]])}))),function(e,n){return t.apply(this,arguments)})},{key:"verifyPokeDelivery",value:function(e,t,n){var r=this,i=this.latestPokeResponseArrivalTimestampByCorrelationId.get(e),a=i?(new Date).getTime()-i:t;a>=t?(n.filter((function(t){return t.pendingCorrelationId===e})).forEach((function(e){e.updatePending(null,null),e.retryCount++,r.persisted.delete(e.sid)})),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(e)):setTimeout((function(){return r.verifyPokeDelivery(e,t,n)}),t-a)}},{key:"processLocalActions",value:function(e,t){return"cancel"===e?t.filter((function(e){return!e.rejectedWithError})):t}},{key:"recordActionAttemptOn",value:function(e,t,n){if(e.setSubscriptionState("request_in_flight"),"establish"===t)this.persisted.set(e.sid,e),e.updatePending(t,n);else{var r=this.persisted.get(e.sid);r&&r.updatePending(t,n)}}},{key:"recordActionFailureOn",value:function(e,t){e.setSubscriptionState("none"),e.updatePending(null,null),"establish"===t&&this.persisted.delete(e.sid)}},{key:"request",value:function(e,t,n,r){var i=r.map((function(t){return{object_sid:t.sid,object_type:t.type,last_event_id:"establish"===e?t.lastEventId:void 0,index_name:"establish"===e?t.indexName:void 0,query_string:"establish"===e?t.queryString:void 0}})),a=r.filter((function(e){return e.retryCount>0})).length;ZI("Attempting '".concat(e,"' request (c:").concat(t,"):"),i);var o={event_protocol_version:4,action:e,correlation_id:t,retried_requests:a,ttl_in_s:-1,requests:i};return"ttl"===n&&(o.reason=n),this.services.network.post(this.services.config.subscriptionsUri,o)}},{key:"add",value:function(e,t){ZI("Establishing intent to subscribe to ".concat(e));var n=this.subscriptions.get(e);n&&t&&n.lastEventId===t.lastEventId||(this.persisted.delete(e),this.subscriptions.set(e,new dT(t)),this.persist())}},{key:"remove",value:function(e){ZI("Establishing intent to unsubscribe from ".concat(e)),this.subscriptions.delete(e)&&this.persist()}},{key:"acceptMessage",value:function(e,t){XI("Subscriptions received",e);var n=e.event_type,r=void 0!==e.events?e.events:[e.event],i=e.correlation_id;i&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(i,(new Date).getTime());var a,o=lT(r);try{for(o.s();!(a=o.n()).done;){var s=a.value,u=void 0;switch(e.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(s,i);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(s,i);break;case"subscription_failed":this.applySubscriptionFailedMessage(s,i);break;case(u=n.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:var c=void 0;switch(u[0]){case"map_":c=s.map_sid;break;case"list_":c=s.list_sid;break;case"document_":c=s.document_sid;break;case"stream_":c=s.stream_sid;break;case"live_query_":c=s.query_id,t=!1,!0===e.strictly_ordered&&(t=!0);break;default:c=void 0}this.applyEventToSubscribedEntity(c,s,n,t);break;default:ZI("Dropping unknown message type ".concat(n))}}}catch(e){o.e(e)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(e,t){var n=e.object_sid,r=this.persisted.get(e.object_sid);r&&r.pendingCorrelationId===t?"interrupted"===e.replay_status?(ZI("Event Replay for subscription to ".concat(n," (c:").concat(t,") interrupted; continuing eagerly.")),r.updatePending(null,null),this.persisted.delete(r.sid),this.backoff.reset()):"completed"===e.replay_status&&(ZI("Event Replay for subscription to ".concat(n," (c:").concat(t,") completed. Subscription is ready.")),r.complete(e.last_event_id),this.persisted.set(e.object_sid,r),r.setSubscriptionState("established"),this.backoff.reset()):ZI("Late message for ".concat(e.object_sid," (c:").concat(t,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(e,t){var n=this.persisted.get(e.object_sid);n&&n.pendingCorrelationId===t?(n.updatePending(null,null),n.setSubscriptionState("none"),this.persisted.delete(e.object_sid)):ZI("Late message for ".concat(e.object_sid," (c:").concat(t,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(e,t){var n=e.object_sid,r=this.subscriptions.get(n),i=this.persisted.get(n);r&&i?i.pendingCorrelationId===t&&(tT("Failed to subscribe on ".concat(i.sid),e.error),i.markAsFailed(e),i.setSubscriptionState("none")):!r&&i&&(this.persisted.delete(n),i.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(e,t,n,r){if(e){var i;r=r||(i=this.persisted.get(e))&&i.isEstablished;var a=this.subscriptions.get(e);a?(t.type=n,a.update(t,r)):ZI("Message dropped for SID '".concat(e,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(e){this.isConnected=e,e&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(e){ZI("Triggering event replay for all subscriptions, reason=".concat(e)),this.pendingPokeReason=e,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var t,n=[],r=lT(this.persisted.values());try{for(r.s();!(t=r.n()).done;){var i=t.value;i.reset(),i.rejectedWithError&&n.push(i)}}catch(e){r.e(e)}finally{r.f()}this.persisted.clear();for(var a=0,o=n;a<o.length;a++){var s=o[a];this.persisted.set(s.sid,s)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}();function hT(e){if(e.body&&e.body.message)return e.body.message;switch(e.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function vT(e){return e.body?e.body.code:0}function yT(e){return 409===e.status?new VI(hT(e),e.status,vT(e),e.body):e.status?new SyncError(hT(e),e.status,vT(e)):e instanceof dI.TransportUnavailableError?e:new SyncError(e.message,0,0)}var gT=function(){function e(t,n,r){EI.default(this,e),this.clientInfo=t,this.config=n,this.transport=r}return RI.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+NI.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:4e3,max:6e4,maxAttemptsTime:9e4,randomness:.2},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new Promise((function(r,i){var a=[502,503,504];n&&a.push(429);var o=new yI.Retrier(t.backoffConfig());o.on("attempt",(function(){e().then((function(e){return o.succeeded(e)})).catch((function(e){if(a.includes(e.status)){var t=parseInt(e.headers?e.headers["Retry-After"]:null);o.failed(yT(e),isNaN(t)?null:1e3*t)}else"Twilsock disconnected"===e.message?o.failed(yT(e)):(o.removeAllListeners(),o.cancel(),i(yT(e)))}))})),o.on("succeeded",(function(e){r(e)})),o.on("cancelled",(function(e){return i(yT(e))})),o.on("failed",(function(e){return i(yT(e))})),o.start()}))}},{key:"get",value:function(e){var t=this,n=this.createHeaders();return ZI("GET",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry((function(){return t.transport.get(e,n,t.config.productId)}),!0)}},{key:"post",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=this.createHeaders();return null!=n&&(a["If-Match"]=n),ZI("POST",e,"ID:",a["Twilio-Request-Id"]),this.executeWithRetry((function(){return r.transport.post(e,a,t,r.config.productId)}),i)}},{key:"put",value:function(e,t,n){var r=this,i=this.createHeaders();return null!=n&&(i["If-Match"]=n),ZI("PUT",e,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry((function(){return r.transport.put(e,i,t,r.config.productId)}),!1)}},{key:"delete",value:function(e){var t=this,n=this.createHeaders();return ZI("DELETE",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry((function(){return t.transport.delete(e,n,t.config.productId)}),!1)}}]),e}(),mT=function(){function e(t,n){EI.default(this,e),this.config=t,this.storageId=null;try{this.storage=n||sessionStorage}catch(e){}}return RI.default(e,[{key:"storageKey",value:function(e,t){return"".concat(this.storageId,"::").concat(e,"::").concat(t)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(e){this.storageId=e}},{key:"store",value:function(e,t,n){return this.isReady?this._store(this.storageKey(e,t),n):null}},{key:"read",value:function(e,t){return this.isReady?this._read(this.storageKey(e,t)):null}},{key:"remove",value:function(e,t,n){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(e,t)),n&&this.storage.removeItem(this.storageKey(e,n))}catch(e){}}},{key:"update",value:function(e,t,n,r){if(!this.isReady)return null;this._apply(this.storageKey(e,t),r),n&&this._apply(this.storageKey(e,n),r)}},{key:"_store",value:function(e,t){try{this.storage.setItem(e,JSON.stringify(t))}catch(e){}}},{key:"_read",value:function(e){try{var t=this.storage.getItem(e);if(t)return JSON.parse(t)}catch(e){}return null}},{key:"_apply",value:function(e,t){var n=this._read(e);if(!n)return!1;this._store(e,Object.assign(n,t))}}]),e}();function bT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return wT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function wT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var kT=function(){function e(t,n){EI.default(this,e),this.services=t,this.removalHandler=n,this.subscriptionState="none",this._attachedListeners=new Map}return RI.default(e,[{key:"_advanceLastEventId",value:function(e,t){}},{key:"reportFailure",value:function(e){404===e.status?this.onRemoved(!1):this.broadcastEventToListeners("failure",e)}},{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(e){this.subscriptionState=e,this.broadcastEventToListeners("_subscriptionStateChanged",e)}},{key:"close",value:function(){this._unsubscribe(),null!=this.removalHandler&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(e){var t=e.listenerUuid;this._attachedListeners.get(t)||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(t,e))}},{key:"detach",value:function(e){this._attachedListeners.delete(e),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i,a=bT(this._attachedListeners.values());try{for(a.s();!(i=a.n()).done;){var o=i.value;o.emit.apply(o,[e].concat(n))}}catch(e){a.e(e)}finally{a.f()}}}]),e}(),_T=function(){function e(t){EI.default(this,e),PI.default(this,"queuedRequests",[]),PI.default(this,"isRequestInFlight",!1),this.inputMergingFunction=t}return RI.default(e,[{key:"add",value:function(e,t){var n=this,r=new Promise((function(r,i){return n.queuedRequests.push({input:e,requestFunction:t,resolve:r,reject:i})}));return this.wakeupQueue(),r}},{key:"squashAndAdd",value:function(e,t){var n,r=this.queuedRequests;this.queuedRequests=[],r.length>0?(n=r.map((function(e){return e.input})).reduce(this.inputMergingFunction),n=this.inputMergingFunction(n,e)):n=e;var i=this.add(n,t);return r.forEach((function(e){return i.then(e.resolve,e.reject)})),i}},{key:"isEmpty",value:function(){return 0===this.queuedRequests.length&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var e=this;if(0!==this.queuedRequests.length&&!this.isRequestInFlight){var t=this.queuedRequests.shift();this.isRequestInFlight=!0,t.requestFunction(t.input).then(t.resolve,t.reject).then((function(t){e.isRequestInFlight=!1,e.wakeupQueue()}))}}}]),e}(),xT=function(){function e(t){EI.default(this,e),PI.default(this,"queueByNamespaceKey",new Map),this.inputReducer=t}var t,n,r;return RI.default(e,[{key:"add",value:(r=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,(function(e){return e.add(n,r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"squashAndAdd",value:(n=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,(function(e){return e.squashAndAdd(n,r)})));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"invokeQueueMethod",value:(t=SI.default(AI.default.mark((function e(t,n){var r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queueByNamespaceKey.has(t)||this.queueByNamespaceKey.set(t,new _T(this.inputReducer)),r=this.queueByNamespaceKey.get(t),i=n(r),this.queueByNamespaceKey.get(t).isEmpty()&&this.queueByNamespaceKey.delete(t),e.abrupt("return",i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]),e}();function ST(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var ET=function(e){TI.default(n,e);var t=ST(n);function n(){var e;return EI.default(this,n),(e=t.call(this)).closed=!1,e.uuid=gI.v4(),e}return RI.default(n,[{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")}}]),n}(bI.ReplayEventEmitter);function RT(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var IT=function(e){TI.default(f,e);var t,n,r,i,a,o,s,u,c,l=RT(f);function f(e,t,n){var r;EI.default(this,f),r=l.call(this,e,n),PI.default(II.default(r),"isDeleted",!1);return r.updateMergingQueue=new _T((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.descriptor=t,r.descriptor.data=r.descriptor.data||{},r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return RI.default(f,[{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(e){switch(e.date_created=new Date(e.date_created),e.type){case"document_updated":if(e.id<=this.lastEventId){XI("Document update skipped, current:",this.lastEventId,", remote:",e.id);break}var t=void 0!==this.descriptor.data?$I(this.descriptor.data):null;this.descriptor.last_event_id=e.id,this.descriptor.revision=e.document_revision,this.descriptor.date_updated=e.date_created,this.descriptor.data=e.document_data,this.broadcastEventToListeners("updated",{data:e.document_data,isLocal:!1,previousData:t}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.id,revision:e.document_revision,date_updated:e.date_created,data:e.document_data});break;case"document_removed":this.onRemoved(!1)}}},{key:"set",value:(c=SI.default(AI.default.mark((function e(t,n){var r,i=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(r,(function(e){return i._setUnconditionally(t,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"mutate",value:(u=SI.default(AI.default.mark((function e(t,n){var r,i=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},e.abrupt("return",this.updateMergingQueue.add(r,(function(e){return i._setWithIfMatch(t,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"update",value:(s=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate((function(e){return Object.assign(e,t)}),n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"setTtl",value:(o=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({ttl:t});case 2:n=e.sent,this.descriptor.date_expires=n.date_expires;case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_setUnconditionally",value:(a=SI.default(AI.default.mark((function e(t,n){var r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({data:t,revision:void 0,ttl:n});case 2:return r=e.sent,this._handleSuccessfulUpdateResult(r),e.abrupt("return",this.descriptor.data);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"_setWithIfMatch",value:(i=SI.default(AI.default.mark((function e(t,n){var r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t($I(this.descriptor.data)))){e.next=22;break}return i=this.revision,e.prev=3,e.next=6,this._postUpdateToServer({data:r,revision:i,ttl:n});case 6:return a=e.sent,this._handleSuccessfulUpdateResult(a),e.abrupt("return",this.descriptor.data);case 11:if(e.prev=11,e.t0=e.catch(3),412!==e.t0.status){e.next=19;break}return e.next=16,this._softSync();case 16:return e.abrupt("return",this._setWithIfMatch(t));case 19:throw e.t0;case 20:e.next=23;break;case 22:return e.abrupt("return",this.descriptor.data);case 23:case"end":return e.stop()}}),e,this,[[3,11]])}))),function(e,t){return i.apply(this,arguments)})},{key:"_handleSuccessfulUpdateResult",value:function(e){if(!(e.last_event_id<=this.descriptor.last_event_id)){var t=void 0!==this.descriptor.data?$I(this.descriptor.data):null;this.descriptor.revision=e.revision,this.descriptor.data=e.data,this.descriptor.last_event_id=e.last_event_id,this.descriptor.date_expires=e.date_expires,this.descriptor.date_updated=new Date(e.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.last_event_id,revision:e.revision,date_updated:e.date_updated,data:e.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:t})}}},{key:"_postUpdateToServer",value:(r=SI.default(AI.default.mark((function e(t){var n,r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=17;break}return n={data:t.data},void 0!==t.ttl&&(n.ttl=t.ttl),r=t.revision,e.prev=4,e.next=7,this.services.network.post(this.uri,n,r);case 7:return i=e.sent,e.abrupt("return",{revision:i.body.revision,data:t.data,last_event_id:i.body.last_event_id,date_updated:i.body.date_updated,date_expires:i.body.date_expires});case 11:throw e.prev=11,e.t0=e.catch(4),404===e.t0.status&&this.onRemoved(!1),e.t0;case 15:e.next=18;break;case 17:return e.abrupt("return",Promise.reject(new SyncError("The Document has been removed",404,54100)));case 18:case"end":return e.stop()}}),e,this,[[4,11]])}))),function(e){return r.apply(this,arguments)})},{key:"_softSync",value:(n=SI.default(AI.default.mark((function e(){var t=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.network.get(this.uri).then((function(e){var n={type:"document_updated",id:e.body.last_event_id,document_revision:e.body.revision,document_data:e.body.data,date_created:e.body.date_updated};return t._update(n),t})).catch((function(e){404===e.status?t.onRemoved(!1):tT("Can't get updates for ".concat(t.sid,":"),e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"onRemoved",value:function(e){if(!this.isDeleted){var t=void 0!==this.descriptor.data?$I(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e,previousData:t})}}},{key:"removeDocument",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=6;break}return e.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),e.next=7;break;case 6:return e.abrupt("return",Promise.reject(new SyncError("The Document has been removed",404,54100)));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"type",get:function(){return"document"}}]),f}(kT),TT=function(e){TI.default(s,e);var t,n,r,i,a,o=RT(s);function s(e){var t;return EI.default(this,s),(t=o.call(this)).syncDocumentImpl=e,t.syncDocumentImpl.attach(II.default(t)),t}return RI.default(s,[{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 IT.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:(a=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.set(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"mutate",value:(i=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.mutate(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"update",value:(r=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.update(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setTtl",value:(n=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"removeDocument",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){DI.default(OI.default(s.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return IT.type}}]),s}(ET);PI.default(TT,"removed","removed"),PI.default(TT,"updated","updated"),qI([fI.validateTypesAsync(fI.pureObject,["undefined",fI.objectSchema("document metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object,Object]),zI("design:returntype",Promise)],TT.prototype,"set",null),qI([fI.validateTypesAsync("function",["undefined",fI.objectSchema("document metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Function,Object]),zI("design:returntype",Promise)],TT.prototype,"mutate",null),qI([fI.validateTypesAsync(fI.pureObject,["undefined",fI.objectSchema("document metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object,Object]),zI("design:returntype",Promise)],TT.prototype,"update",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],TT.prototype,"setTtl",null);var CT=function(){function e(t){EI.default(this,e),this.descriptor=t}return RI.default(e,[{key:"url",get:function(){return this.descriptor.url}},{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:"cacheKey",get:function(){return this.index}},{key:"update",value:function(e,t,n,r){return this.descriptor.lastEventId=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.dateUpdated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.dateExpires=e}}]),e}(),Paginator=function(){function Paginator(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;EI.default(this,Paginator),this.items=e,this.source=t,this.prevPageItemId=n,this.nextPageItemId=r}var e,t;return RI.default(Paginator,[{key:"nextPage",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasNextPage){e.next=2;break}throw new Error("No next page");case 2:return e.abrupt("return",this.source({nextPageItemId:this.nextPageItemId}));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"prevPage",value:(e=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasPrevPage){e.next=2;break}throw new Error("No previous page");case 2:return e.abrupt("return",this.source({prevPageItemId:this.prevPageItemId}));case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"hasNextPage",get:function(){return null!==this.nextPageItemId}},{key:"hasPrevPage",get:function(){return null!==this.prevPageItemId}}]),Paginator}();function OT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return PT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return PT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function PT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var AT=function(){function e(t,n){EI.default(this,e),this.balanceFactor=0,this.key=t,this.value=n,this.parent=null,this.left=null,this.right=null}return RI.default(e,[{key:"isRoot",get:function(){return null===this.parent}},{key:"isLeaf",get:function(){return null===this.left&&null===this.right}},{key:"isLeftChild",get:function(){return this.parent.left===this}},{key:"update",value:function(e){this.value=e}},{key:"replace",value:function(e,t){e&&(this.left===t?this.left=t:this.right===t&&(this.right=t))}}]),e}(),jT=function(e){function t(e,n){EI.default(this,t),this.isLessThan=e||function(e,t){return e<t},this.isEqual=n||function(e,t){return e===t},this.root=null,this.count=null}return RI.default(t,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(e,t){var n=this.getNode(e);n?n.update(t):this.insert(e,t)}},{key:"insert",value:function(e,t){var n=new AT(e,t);if(this.count++,this.root){for(var r=this.root;;)if(this.isLessThan(e,r.key)){if(!r.left){r.left=n;break}r=r.left}else{if(!r.right){r.right=n;break}r=r.right}for(n.parent=r,r=n;r.parent;){var i=r.parent,a=i.balanceFactor;if(r.isLeftChild?i.balanceFactor++:i.balanceFactor--,Math.abs(i.balanceFactor)<Math.abs(a))break;if(i.balanceFactor<-1||i.balanceFactor>1){this.rebalance(i);break}r=i}}else this.root=n}},{key:"get",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t.value;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"delete",value:function(e){var t=this.getNode(e);if(!t||t.key!==e)return null;var n=t.parent,r=t.left,i=t.right;if(!!r!=!!i){var a=r||i;n||a?n&&!a?this.root=a:(n.replace(t,null),this.rebalance(n)):this.root=null}else{for(var o=t.left;o.right;)o=o.right;if(t.left===o)t.isRoot?(this.root=o,o.parent=null):(t.isLeftChild?t.parent.left=o:t.parent.right=o,o.parent=t.parent),o.right=t.right,o.right.parent=o,o.balanceFactor=t.balanceFactor,t={parent:o,isLeftChild:!0};else{var s=o.parent,u=o.left;s.right=u,u&&(u.parent=s),t.isRoot?(this.root=o,o.parent=null):(t.isLeftChild?t.parent.left=o:t.parent.right=o,o.parent=t.parent),o.right=t.right,o.right.parent=o,o.left=t.left,o.left.parent=o,o.balanceFactor=t.balanceFactor,t={parent:s,isLeftChild:!1}}}for(this.count--;t.parent;){var c=t.parent,l=c.balanceFactor;if(t.isLeftChild?c.balanceFactor-=1:c.balanceFactor+=1,Math.abs(c.balanceFactor)>Math.abs(l)){if(!(c.balanceFactor<-1||c.balanceFactor>1))break;if(this.rebalance(c),0!==c.parent.balanceFactor)break;t=c.parent}else t=c}return null}},{key:"getNode",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"rebalance",value:function(e){e.balanceFactor<0?e.right.balanceFactor>0?(this.rotateRight(e.right),this.rotateLeft(e)):this.rotateLeft(e):e.balanceFactor>0&&(e.left.balanceFactor<0?(this.rotateLeft(e.left),this.rotateRight(e)):this.rotateRight(e))}},{key:"rotateLeft",value:function(e){var t=e.right;e.right=t.left,null!==t.left&&(t.left.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.left=e,e.parent=t,e.balanceFactor=e.balanceFactor+1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor+1-Math.max(e.balanceFactor,0)}},{key:"rotateRight",value:function(e){var t=e.left;e.left=t.right,null!==t.right&&(t.right.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.right=e,e.parent=t,e.balanceFactor=e.balanceFactor-1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor-1-Math.max(e.balanceFactor,0)}},{key:e,value:AI.default.mark((function e(){var t,n,r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=OT(this.getIterator()),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=n.value,e.next=7,r;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:"getIterator",value:AI.default.mark((function e(){var t,n,r,i=arguments;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i.length>0&&void 0!==i[0]?i[0]:null,n=this.root;case 2:if(!n){e.next=8;break}if(!this.isEqual(t,n.key)&&(null!==t||n.left)){e.next=5;break}return e.abrupt("break",8);case 5:n=this.isLessThan(t,n.key)||null===t?n.left:n.right,e.next=2;break;case 8:if(n){e.next=10;break}return e.abrupt("return",null);case 10:r=!0;case 11:if(!r){e.next=29;break}return e.next=14,[n.key,n.value];case 14:if(r=!1,!n.right){e.next=21;break}for(n=n.right;n.left;)n=n.left;r=!0,e.next=27;break;case 21:if(!n.parent){e.next=26;break}r=n.parent.left===n,n=n.parent,e.next=27;break;case 26:return e.abrupt("break",37);case 27:e.next=35;break;case 29:if(!n.parent){e.next=34;break}r=n.parent.left===n,n=n.parent,e.next=35;break;case 34:return e.abrupt("break",37);case 35:e.next=11;break;case 37:return e.abrupt("return",null);case 38:case"end":return e.stop()}}),e,this)}))},{key:"getReverseIterator",value:AI.default.mark((function e(){var t,n,r,i=arguments;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=i.length>0&&void 0!==i[0]?i[0]:null,n=this.root;case 2:if(!n){e.next=8;break}if(!this.isEqual(t,n.key)&&(null!==t||n.right)){e.next=5;break}return e.abrupt("break",8);case 5:n=this.isLessThan(t,n.key)&&null!==t?n.left:n.right,e.next=2;break;case 8:if(n){e.next=10;break}return e.abrupt("return",null);case 10:r=!0;case 11:if(!r){e.next=29;break}return e.next=14,[n.key,n.value];case 14:if(r=!1,!n.left){e.next=21;break}for(n=n.left;n.right;)n=n.right;r=!0,e.next=27;break;case 21:if(!n.parent){e.next=26;break}r=n.parent.right===n,n=n.parent,e.next=27;break;case 26:return e.abrupt("break",37);case 27:e.next=35;break;case 29:if(!n.parent){e.next=34;break}r=n.parent.right===n,n=n.parent,e.next=35;break;case 34:return e.abrupt("break",37);case 35:e.next=11;break;case 37:return e.abrupt("return",null);case 38:case"end":return e.stop()}}),e,this)}))}]),t}(Symbol.iterator);function MT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return LT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return LT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function LT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var UT=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];EI.default(this,e),this._data=t,this.lastEventId=n||0,this.isLeftBound=r,this.isRightBound=i}return RI.default(e,[{key:"isValid",get:function(){return!0}},{key:"value",get:function(){return this._data}}]),e}(),NT=function(){function e(t){EI.default(this,e),this.lastEventId=t,this.isLeftBound=!1,this.isRightBound=!1}return RI.default(e,[{key:"isValid",get:function(){return!1}},{key:"value",get:function(){return null}}]),e}(),DT=function(){function e(){EI.default(this,e),PI.default(this,"items",new jT),PI.default(this,"beginKey",null),PI.default(this,"endKey",null),this.items.clear()}return RI.default(e,[{key:"size",get:function(){return this.items.size}},{key:"collectionBegin",get:function(){return this.beginKey}},{key:"collectionEnd",get:function(){return this.endKey}},{key:"has",value:function(e){var t,n=this.items.get(e);return null!==(t=null==n?void 0:n.isValid)&&void 0!==t&&t}},{key:"exists",value:function(e){return!!this.items.get(e)}},{key:"getValue",value:function(e){var t,n=this.items.get(e);return null!==(t=null==n?void 0:n.value)&&void 0!==t?t:null}},{key:"get",value:function(e){return this.items.get(e)}},{key:"getNextItem",value:function(e,t,n){return null===e?this.getFirstItem(t):n?this.getValue(e):this.getAdjacentItem(e,t)}},{key:"getFirstItem",value:function(e){var t="asc"===e?this.beginKey:this.endKey;if(this.exists(t)){var n=this.items.get(t);return n.isValid?n.value:this.getAdjacentItem(t,e)}return null}},{key:"getAdjacentItem",value:function(e,t){var n,r=MT("asc"===t?this.items.getIterator(e):this.items.getReverseIterator(e));try{for(r.s();!(n=r.n()).done;){var i=UI.default(n.value,2),a=(i[0],i[1]);if("asc"===t?a.isRightBound:a.isLeftBound)break;if(a.isValid)return a.value}}catch(e){r.e(e)}finally{r.f()}return null}},{key:"store",value:function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=this.items.get(e);if(a&&a.lastEventId>n)return a.value;if(this.items.set(e,new UT(t,n,a?a.isLeftBound&&r:r,a?a.isRightBound&&i:i)),null!==this.beginKey&&e<this.beginKey){var o=this.items.get(this.beginKey);o&&(o.isLeftBound=!1),this.beginKey=e}if(null!==this.endKey&&this.endKey<e){var s=this.items.get(this.endKey);s&&(s.isRightBound=!1),this.endKey=e}return t}},{key:"populate",value:function(e,t,n){var r=this;if(e.length){var i=FI.default(e);if(i.sort((function(e,t){return e.cacheKey===t.cacheKey?0:e.cacheKey>t.cacheKey?1:-1})),i.forEach((function(e,t){r.store(e.cacheKey,e,e.lastEventId,0===t,t===i.length-1)})),t){var a=i[0].cacheKey;(!this.beginKey||a<this.beginKey)&&(this.beginKey=a)}if(n){var o=i[i.length-1].cacheKey;(!this.endKey||this.endKey<o)&&(this.endKey=o)}}}},{key:"delete",value:function(e,t){var n=this.items.get(e);(null===n||null===t||n.lastEventId<t)&&this.items.set(e,new NT(t))}},{key:"isKnown",value:function(e,t){var n=this.items.get(e);return n&&n.lastEventId>=t}},{key:"getIterator",value:AI.default.mark((function e(t){var n,r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===t&&null!==this.beginKey&&(t=this.beginKey),null!==t){e.next=3;break}return e.abrupt("return");case 3:n=MT(this.items.getIterator(t)),e.prev=4,n.s();case 6:if((r=n.n()).done){e.next=16;break}if(i=UI.default(r.value,2),(a=i[1]).isValid){e.next=10;break}return e.abrupt("continue",14);case 10:return e.next=12,a;case 12:if(!a.isRightBound){e.next=14;break}return e.abrupt("break",16);case 14:e.next=6;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(4),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[4,18,21,24]])}))},{key:"getReverseIterator",value:AI.default.mark((function e(t){var n,r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===t&&null!==this.endKey&&(t=this.endKey),null!==t){e.next=3;break}return e.abrupt("return");case 3:n=MT(this.items.getReverseIterator(t)),e.prev=4,n.s();case 6:if((r=n.n()).done){e.next=16;break}if(i=UI.default(r.value,2),(a=i[1]).isValid){e.next=10;break}return e.abrupt("continue",14);case 10:return e.next=12,a;case 12:if(!a.isLeftBound){e.next=14;break}return e.abrupt("break",16);case 14:e.next=6;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(4),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[4,18,21,24]])}))},{key:"forEach",value:function(e){if(this.items){var t,n=MT(this.items);try{for(n.s();!(t=n.n()).done;){var r=UI.default(t.value,2),i=r[0],a=r[1];a.isValid&&e(i,a.value)}}catch(e){n.e(e)}finally{n.f()}}}}]),e}(),FT="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{},BT={exports:{}};function qT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return zT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function zT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function WT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function KT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?WT(Object(n),!0).forEach((function(t){PI.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WT(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function VT(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}!function(e,t){(function(){var n,r="Expected a function",i="__lodash_hash_undefined__",a="__lodash_placeholder__",o=16,s=32,u=64,c=128,l=256,f=1/0,d=9007199254740991,p=NaN,h=4294967295,v=[["ary",c],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",s],["partialRight",u],["rearg",l]],y="[object Arguments]",g="[object Array]",m="[object Boolean]",b="[object Date]",w="[object Error]",k="[object Function]",_="[object GeneratorFunction]",x="[object Map]",S="[object Number]",E="[object Object]",R="[object Promise]",I="[object RegExp]",T="[object Set]",C="[object String]",O="[object Symbol]",P="[object WeakMap]",A="[object ArrayBuffer]",j="[object DataView]",M="[object Float32Array]",L="[object Float64Array]",U="[object Int8Array]",N="[object Int16Array]",D="[object Int32Array]",F="[object Uint8Array]",B="[object Uint8ClampedArray]",q="[object Uint16Array]",z="[object Uint32Array]",W=/\b__p \+= '';/g,K=/\b(__p \+=) '' \+/g,V=/(__e\(.*?\)|\b__t\)) \+\n'';/g,$=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,J=RegExp($.source),H=RegExp(G.source),Y=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ee=/^\w*$/,te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ne=/[\\^$.*+?()[\]{}|]/g,re=RegExp(ne.source),ie=/^\s+/,ae=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ue=/,? & /,ce=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,fe=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pe=/\w*$/,he=/^[-+]0x[0-9a-f]+$/i,ve=/^0b[01]+$/i,ye=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,we=/($^)/,ke=/['\n\r\u2028\u2029\\]/g,_e="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",xe="\\u2700-\\u27bf",Se="a-z\\xdf-\\xf6\\xf8-\\xff",Ee="A-Z\\xc0-\\xd6\\xd8-\\xde",Re="\\ufe0e\\ufe0f",Ie="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Te="['’]",Ce="[\\ud800-\\udfff]",Oe="["+Ie+"]",Pe="["+_e+"]",Ae="\\d+",je="[\\u2700-\\u27bf]",Me="["+Se+"]",Le="[^\\ud800-\\udfff"+Ie+Ae+xe+Se+Ee+"]",Ue="\\ud83c[\\udffb-\\udfff]",Ne="[^\\ud800-\\udfff]",De="(?:\\ud83c[\\udde6-\\uddff]){2}",Fe="[\\ud800-\\udbff][\\udc00-\\udfff]",Be="["+Ee+"]",qe="(?:"+Me+"|"+Le+")",ze="(?:"+Be+"|"+Le+")",We="(?:['’](?:d|ll|m|re|s|t|ve))?",Ke="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ve="(?:"+Pe+"|"+Ue+")"+"?",$e="[\\ufe0e\\ufe0f]?",Ge=$e+Ve+("(?:\\u200d(?:"+[Ne,De,Fe].join("|")+")"+$e+Ve+")*"),Je="(?:"+[je,De,Fe].join("|")+")"+Ge,He="(?:"+[Ne+Pe+"?",Pe,De,Fe,Ce].join("|")+")",Ye=RegExp(Te,"g"),Qe=RegExp(Pe,"g"),Xe=RegExp(Ue+"(?="+Ue+")|"+He+Ge,"g"),Ze=RegExp([Be+"?"+Me+"+"+We+"(?="+[Oe,Be,"$"].join("|")+")",ze+"+"+Ke+"(?="+[Oe,Be+qe,"$"].join("|")+")",Be+"?"+qe+"+"+We,Be+"+"+Ke,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ae,Je].join("|"),"g"),et=RegExp("[\\u200d\\ud800-\\udfff"+_e+Re+"]"),tt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],rt=-1,it={};it[M]=it[L]=it[U]=it[N]=it[D]=it[F]=it[B]=it[q]=it[z]=!0,it[y]=it[g]=it[A]=it[m]=it[j]=it[b]=it[w]=it[k]=it[x]=it[S]=it[E]=it[I]=it[T]=it[C]=it[P]=!1;var at={};at[y]=at[g]=at[A]=at[j]=at[m]=at[b]=at[M]=at[L]=at[U]=at[N]=at[D]=at[x]=at[S]=at[E]=at[I]=at[T]=at[C]=at[O]=at[F]=at[B]=at[q]=at[z]=!0,at[w]=at[k]=at[P]=!1;var ot={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},st=parseFloat,ut=parseInt,ct="object"==jI.default(FT)&&FT&&FT.Object===Object&&FT,lt="object"==("undefined"==typeof self?"undefined":jI.default(self))&&self&&self.Object===Object&&self,ft=ct||lt||Function("return this")(),dt=t&&!t.nodeType&&t,pt=dt&&e&&!e.nodeType&&e,ht=pt&&pt.exports===dt,vt=ht&&ct.process,yt=function(){try{var e=pt&&pt.require&&pt.require("util").types;return e||vt&&vt.binding&&vt.binding("util")}catch(e){}}(),gt=yt&&yt.isArrayBuffer,mt=yt&&yt.isDate,bt=yt&&yt.isMap,wt=yt&&yt.isRegExp,kt=yt&&yt.isSet,_t=yt&&yt.isTypedArray;function xt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function St(e,t,n,r){for(var i=-1,a=null==e?0:e.length;++i<a;){var o=e[i];t(r,o,n(o),e)}return r}function Et(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}function Rt(e,t){for(var n=null==e?0:e.length;n--&&!1!==t(e[n],n,e););return e}function It(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(!t(e[n],n,e))return!1;return!0}function Tt(e,t){for(var n=-1,r=null==e?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function Ct(e,t){return!!(null==e?0:e.length)&&Ft(e,t,0)>-1}function Ot(e,t,n){for(var r=-1,i=null==e?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function Pt(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}function At(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function jt(e,t,n,r){var i=-1,a=null==e?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function Mt(e,t,n,r){var i=null==e?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n}function Lt(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var Ut=Wt("length");function Nt(e,t,n){var r;return n(e,(function(e,n,i){if(t(e,n,i))return r=n,!1})),r}function Dt(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Ft(e,t,n){return t==t?function(e,t,n){var r=n-1,i=e.length;for(;++r<i;)if(e[r]===t)return r;return-1}(e,t,n):Dt(e,qt,n)}function Bt(e,t,n,r){for(var i=n-1,a=e.length;++i<a;)if(r(e[i],t))return i;return-1}function qt(e){return e!=e}function zt(e,t){var n=null==e?0:e.length;return n?$t(e,t)/n:p}function Wt(e){return function(t){return null==t?n:t[e]}}function Kt(e){return function(t){return null==e?n:e[t]}}function Vt(e,t,n,r,i){return i(e,(function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)})),n}function $t(e,t){for(var r,i=-1,a=e.length;++i<a;){var o=t(e[i]);o!==n&&(r=r===n?o:r+o)}return r}function Gt(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function Jt(e){return e?e.slice(0,pn(e)+1).replace(ie,""):e}function Ht(e){return function(t){return e(t)}}function Yt(e,t){return Pt(t,(function(t){return e[t]}))}function Qt(e,t){return e.has(t)}function Xt(e,t){for(var n=-1,r=e.length;++n<r&&Ft(t,e[n],0)>-1;);return n}function Zt(e,t){for(var n=e.length;n--&&Ft(t,e[n],0)>-1;);return n}function en(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var tn=Kt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),nn=Kt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function rn(e){return"\\"+ot[e]}function an(e){return et.test(e)}function on(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function sn(e,t){return function(n){return e(t(n))}}function un(e,t){for(var n=-1,r=e.length,i=0,o=[];++n<r;){var s=e[n];s!==t&&s!==a||(e[n]=a,o[i++]=n)}return o}function cn(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}function ln(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=[e,e]})),n}function fn(e){return an(e)?function(e){var t=Xe.lastIndex=0;for(;Xe.test(e);)++t;return t}(e):Ut(e)}function dn(e){return an(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function pn(e){for(var t=e.length;t--&&ae.test(e.charAt(t)););return t}var hn=Kt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var vn=function e(t){var ae=(t=null==t?ft:vn.defaults(ft.Object(),t,vn.pick(ft,nt))).Array,_e=t.Date,xe=t.Error,Se=t.Function,Ee=t.Math,Re=t.Object,Ie=t.RegExp,Te=t.String,Ce=t.TypeError,Oe=ae.prototype,Pe=Se.prototype,Ae=Re.prototype,je=t["__core-js_shared__"],Me=Pe.toString,Le=Ae.hasOwnProperty,Ue=0,Ne=function(){var e=/[^.]+$/.exec(je&&je.keys&&je.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),De=Ae.toString,Fe=Me.call(Re),Be=ft._,qe=Ie("^"+Me.call(Le).replace(ne,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=ht?t.Buffer:n,We=t.Symbol,Ke=t.Uint8Array,Ve=ze?ze.allocUnsafe:n,$e=sn(Re.getPrototypeOf,Re),Ge=Re.create,Je=Ae.propertyIsEnumerable,He=Oe.splice,Xe=We?We.isConcatSpreadable:n,et=We?We.iterator:n,ot=We?We.toStringTag:n,ct=function(){try{var e=da(Re,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==ft.clearTimeout&&t.clearTimeout,dt=_e&&_e.now!==ft.Date.now&&_e.now,pt=t.setTimeout!==ft.setTimeout&&t.setTimeout,vt=Ee.ceil,yt=Ee.floor,Ut=Re.getOwnPropertySymbols,Kt=ze?ze.isBuffer:n,yn=t.isFinite,gn=Oe.join,mn=sn(Re.keys,Re),bn=Ee.max,wn=Ee.min,kn=_e.now,_n=t.parseInt,xn=Ee.random,Sn=Oe.reverse,En=da(t,"DataView"),Rn=da(t,"Map"),In=da(t,"Promise"),Tn=da(t,"Set"),Cn=da(t,"WeakMap"),On=da(Re,"create"),Pn=Cn&&new Cn,An={},jn=Fa(En),Mn=Fa(Rn),Ln=Fa(In),Un=Fa(Tn),Nn=Fa(Cn),Dn=We?We.prototype:n,Fn=Dn?Dn.valueOf:n,Bn=Dn?Dn.toString:n;function qn(e){if(rs(e)&&!$o(e)&&!(e instanceof Vn)){if(e instanceof Kn)return e;if(Le.call(e,"__wrapped__"))return Ba(e)}return new Kn(e)}var zn=function(){function e(){}return function(t){if(!ns(t))return{};if(Ge)return Ge(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function Wn(){}function Kn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function Vn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=h,this.__views__=[]}function $n(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Gn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Hn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Jn;++t<n;)this.add(e[t])}function Yn(e){var t=this.__data__=new Gn(e);this.size=t.size}function Qn(e,t){var n=$o(e),r=!n&&Vo(e),i=!n&&!r&&Yo(e),a=!n&&!r&&!i&&fs(e),o=n||r||i||a,s=o?Gt(e.length,Te):[],u=s.length;for(var c in e)!t&&!Le.call(e,c)||o&&("length"==c||i&&("offset"==c||"parent"==c)||a&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ba(c,u))||s.push(c);return s}function Xn(e){var t=e.length;return t?e[Hr(0,t-1)]:n}function Zn(e,t){return Ua(Oi(e),ur(t,0,e.length))}function er(e){return Ua(Oi(e))}function tr(e,t,r){(r!==n&&!zo(e[t],r)||r===n&&!(t in e))&&or(e,t,r)}function nr(e,t,r){var i=e[t];Le.call(e,t)&&zo(i,r)&&(r!==n||t in e)||or(e,t,r)}function rr(e,t){for(var n=e.length;n--;)if(zo(e[n][0],t))return n;return-1}function ir(e,t,n,r){return pr(e,(function(e,i,a){t(r,e,n(e),a)})),r}function ar(e,t){return e&&Pi(t,js(t),e)}function or(e,t,n){"__proto__"==t&&ct?ct(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function sr(e,t){for(var r=-1,i=t.length,a=ae(i),o=null==e;++r<i;)a[r]=o?n:Ts(e,t[r]);return a}function ur(e,t,r){return e==e&&(r!==n&&(e=e<=r?e:r),t!==n&&(e=e>=t?e:t)),e}function cr(e,t,r,i,a,o){var s,u=1&t,c=2&t,l=4&t;if(r&&(s=a?r(e,i,a,o):r(e)),s!==n)return s;if(!ns(e))return e;var f=$o(e);if(f){if(s=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Le.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!u)return Oi(e,s)}else{var d=va(e),p=d==k||d==_;if(Yo(e))return Si(e,u);if(d==E||d==y||p&&!a){if(s=c||p?{}:ga(e),!u)return c?function(e,t){return Pi(e,ha(e),t)}(e,function(e,t){return e&&Pi(t,Ms(t),e)}(s,e)):function(e,t){return Pi(e,pa(e),t)}(e,ar(s,e))}else{if(!at[d])return a?e:{};s=function(e,t,n){var r=e.constructor;switch(t){case A:return Ei(e);case m:case b:return new r(+e);case j:return function(e,t){var n=t?Ei(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case M:case L:case U:case N:case D:case F:case B:case q:case z:return Ri(e,n);case x:return new r;case S:case C:return new r(e);case I:return function(e){var t=new e.constructor(e.source,pe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case T:return new r;case O:return i=e,Fn?Re(Fn.call(i)):{}}var i}(e,d,u)}}o||(o=new Yn);var h=o.get(e);if(h)return h;o.set(e,s),us(e)?e.forEach((function(n){s.add(cr(n,t,r,n,e,o))})):is(e)&&e.forEach((function(n,i){s.set(i,cr(n,t,r,i,e,o))}));var v=f?n:(l?c?aa:ia:c?Ms:js)(e);return Et(v||e,(function(n,i){v&&(n=e[i=n]),nr(s,i,cr(n,t,r,i,e,o))})),s}function lr(e,t,r){var i=r.length;if(null==e)return!i;for(e=Re(e);i--;){var a=r[i],o=t[a],s=e[a];if(s===n&&!(a in e)||!o(s))return!1}return!0}function fr(e,t,i){if("function"!=typeof e)throw new Ce(r);return Aa((function(){e.apply(n,i)}),t)}function dr(e,t,n,r){var i=-1,a=Ct,o=!0,s=e.length,u=[],c=t.length;if(!s)return u;n&&(t=Pt(t,Ht(n))),r?(a=Ot,o=!1):t.length>=200&&(a=Qt,o=!1,t=new Hn(t));e:for(;++i<s;){var l=e[i],f=null==n?l:n(l);if(l=r||0!==l?l:0,o&&f==f){for(var d=c;d--;)if(t[d]===f)continue e;u.push(l)}else a(t,f,r)||u.push(l)}return u}qn.templateSettings={escape:Y,evaluate:Q,interpolate:X,variable:"",imports:{_:qn}},qn.prototype=Wn.prototype,qn.prototype.constructor=qn,Kn.prototype=zn(Wn.prototype),Kn.prototype.constructor=Kn,Vn.prototype=zn(Wn.prototype),Vn.prototype.constructor=Vn,$n.prototype.clear=function(){this.__data__=On?On(null):{},this.size=0},$n.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},$n.prototype.get=function(e){var t=this.__data__;if(On){var r=t[e];return r===i?n:r}return Le.call(t,e)?t[e]:n},$n.prototype.has=function(e){var t=this.__data__;return On?t[e]!==n:Le.call(t,e)},$n.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=On&&t===n?i:t,this},Gn.prototype.clear=function(){this.__data__=[],this.size=0},Gn.prototype.delete=function(e){var t=this.__data__,n=rr(t,e);return!(n<0)&&(n==t.length-1?t.pop():He.call(t,n,1),--this.size,!0)},Gn.prototype.get=function(e){var t=this.__data__,r=rr(t,e);return r<0?n:t[r][1]},Gn.prototype.has=function(e){return rr(this.__data__,e)>-1},Gn.prototype.set=function(e,t){var n=this.__data__,r=rr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Jn.prototype.clear=function(){this.size=0,this.__data__={hash:new $n,map:new(Rn||Gn),string:new $n}},Jn.prototype.delete=function(e){var t=la(this,e).delete(e);return this.size-=t?1:0,t},Jn.prototype.get=function(e){return la(this,e).get(e)},Jn.prototype.has=function(e){return la(this,e).has(e)},Jn.prototype.set=function(e,t){var n=la(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Hn.prototype.add=Hn.prototype.push=function(e){return this.__data__.set(e,i),this},Hn.prototype.has=function(e){return this.__data__.has(e)},Yn.prototype.clear=function(){this.__data__=new Gn,this.size=0},Yn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Yn.prototype.get=function(e){return this.__data__.get(e)},Yn.prototype.has=function(e){return this.__data__.has(e)},Yn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Gn){var r=n.__data__;if(!Rn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Jn(r)}return n.set(e,t),this.size=n.size,this};var pr=Mi(kr),hr=Mi(_r,!0);function vr(e,t){var n=!0;return pr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function yr(e,t,r){for(var i=-1,a=e.length;++i<a;){var o=e[i],s=t(o);if(null!=s&&(u===n?s==s&&!ls(s):r(s,u)))var u=s,c=o}return c}function gr(e,t){var n=[];return pr(e,(function(e,r,i){t(e,r,i)&&n.push(e)})),n}function mr(e,t,n,r,i){var a=-1,o=e.length;for(n||(n=ma),i||(i=[]);++a<o;){var s=e[a];t>0&&n(s)?t>1?mr(s,t-1,n,r,i):At(i,s):r||(i[i.length]=s)}return i}var br=Li(),wr=Li(!0);function kr(e,t){return e&&br(e,t,js)}function _r(e,t){return e&&wr(e,t,js)}function xr(e,t){return Tt(t,(function(t){return Zo(e[t])}))}function Sr(e,t){for(var r=0,i=(t=wi(t,e)).length;null!=e&&r<i;)e=e[Da(t[r++])];return r&&r==i?e:n}function Er(e,t,n){var r=t(e);return $o(e)?r:At(r,n(e))}function Rr(e){return null==e?e===n?"[object Undefined]":"[object Null]":ot&&ot in Re(e)?function(e){var t=Le.call(e,ot),r=e[ot];try{e[ot]=n;var i=!0}catch(e){}var a=De.call(e);i&&(t?e[ot]=r:delete e[ot]);return a}(e):function(e){return De.call(e)}(e)}function Ir(e,t){return e>t}function Tr(e,t){return null!=e&&Le.call(e,t)}function Cr(e,t){return null!=e&&t in Re(e)}function Or(e,t,r){for(var i=r?Ot:Ct,a=e[0].length,o=e.length,s=o,u=ae(o),c=1/0,l=[];s--;){var f=e[s];s&&t&&(f=Pt(f,Ht(t))),c=wn(f.length,c),u[s]=!r&&(t||a>=120&&f.length>=120)?new Hn(s&&f):n}f=e[0];var d=-1,p=u[0];e:for(;++d<a&&l.length<c;){var h=f[d],v=t?t(h):h;if(h=r||0!==h?h:0,!(p?Qt(p,v):i(l,v,r))){for(s=o;--s;){var y=u[s];if(!(y?Qt(y,v):i(e[s],v,r)))continue e}p&&p.push(v),l.push(h)}}return l}function Pr(e,t,r){var i=null==(e=Ta(e,t=wi(t,e)))?e:e[Da(Qa(t))];return null==i?n:xt(i,e,r)}function Ar(e){return rs(e)&&Rr(e)==y}function jr(e,t,r,i,a){return e===t||(null==e||null==t||!rs(e)&&!rs(t)?e!=e&&t!=t:function(e,t,r,i,a,o){var s=$o(e),u=$o(t),c=s?g:va(e),l=u?g:va(t),f=(c=c==y?E:c)==E,d=(l=l==y?E:l)==E,p=c==l;if(p&&Yo(e)){if(!Yo(t))return!1;s=!0,f=!1}if(p&&!f)return o||(o=new Yn),s||fs(e)?na(e,t,r,i,a,o):function(e,t,n,r,i,a,o){switch(n){case j:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case A:return!(e.byteLength!=t.byteLength||!a(new Ke(e),new Ke(t)));case m:case b:case S:return zo(+e,+t);case w:return e.name==t.name&&e.message==t.message;case I:case C:return e==t+"";case x:var s=on;case T:var u=1&r;if(s||(s=cn),e.size!=t.size&&!u)return!1;var c=o.get(e);if(c)return c==t;r|=2,o.set(e,t);var l=na(s(e),s(t),r,i,a,o);return o.delete(e),l;case O:if(Fn)return Fn.call(e)==Fn.call(t)}return!1}(e,t,c,r,i,a,o);if(!(1&r)){var h=f&&Le.call(e,"__wrapped__"),v=d&&Le.call(t,"__wrapped__");if(h||v){var k=h?e.value():e,_=v?t.value():t;return o||(o=new Yn),a(k,_,r,i,o)}}if(!p)return!1;return o||(o=new Yn),function(e,t,r,i,a,o){var s=1&r,u=ia(e),c=u.length,l=ia(t).length;if(c!=l&&!s)return!1;var f=c;for(;f--;){var d=u[f];if(!(s?d in t:Le.call(t,d)))return!1}var p=o.get(e),h=o.get(t);if(p&&h)return p==t&&h==e;var v=!0;o.set(e,t),o.set(t,e);var y=s;for(;++f<c;){var g=e[d=u[f]],m=t[d];if(i)var b=s?i(m,g,d,t,e,o):i(g,m,d,e,t,o);if(!(b===n?g===m||a(g,m,r,i,o):b)){v=!1;break}y||(y="constructor"==d)}if(v&&!y){var w=e.constructor,k=t.constructor;w==k||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof k&&k instanceof k||(v=!1)}return o.delete(e),o.delete(t),v}(e,t,r,i,a,o)}(e,t,r,i,jr,a))}function Mr(e,t,r,i){var a=r.length,o=a,s=!i;if(null==e)return!o;for(e=Re(e);a--;){var u=r[a];if(s&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++a<o;){var c=(u=r[a])[0],l=e[c],f=u[1];if(s&&u[2]){if(l===n&&!(c in e))return!1}else{var d=new Yn;if(i)var p=i(l,f,c,e,t,d);if(!(p===n?jr(f,l,3,i,d):p))return!1}}return!0}function Lr(e){return!(!ns(e)||(t=e,Ne&&Ne in t))&&(Zo(e)?qe:ye).test(Fa(e));var t}function Ur(e){return"function"==typeof e?e:null==e?au:"object"==jI.default(e)?$o(e)?zr(e[0],e[1]):qr(e):hu(e)}function Nr(e){if(!Sa(e))return mn(e);var t=[];for(var n in Re(e))Le.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Dr(e){if(!ns(e))return function(e){var t=[];if(null!=e)for(var n in Re(e))t.push(n);return t}(e);var t=Sa(e),n=[];for(var r in e)("constructor"!=r||!t&&Le.call(e,r))&&n.push(r);return n}function Fr(e,t){return e<t}function Br(e,t){var n=-1,r=Jo(e)?ae(e.length):[];return pr(e,(function(e,i,a){r[++n]=t(e,i,a)})),r}function qr(e){var t=fa(e);return 1==t.length&&t[0][2]?Ra(t[0][0],t[0][1]):function(n){return n===e||Mr(n,e,t)}}function zr(e,t){return ka(e)&&Ea(t)?Ra(Da(e),t):function(r){var i=Ts(r,e);return i===n&&i===t?Cs(r,e):jr(t,i,3)}}function Wr(e,t,r,i,a){e!==t&&br(t,(function(o,s){if(a||(a=new Yn),ns(o))!function(e,t,r,i,a,o,s){var u=Oa(e,r),c=Oa(t,r),l=s.get(c);if(l)return void tr(e,r,l);var f=o?o(u,c,r+"",e,t,s):n,d=f===n;if(d){var p=$o(c),h=!p&&Yo(c),v=!p&&!h&&fs(c);f=c,p||h||v?$o(u)?f=u:Ho(u)?f=Oi(u):h?(d=!1,f=Si(c,!0)):v?(d=!1,f=Ri(c,!0)):f=[]:os(c)||Vo(c)?(f=u,Vo(u)?f=bs(u):ns(u)&&!Zo(u)||(f=ga(c))):d=!1}d&&(s.set(c,f),a(f,c,i,o,s),s.delete(c));tr(e,r,f)}(e,t,s,r,Wr,i,a);else{var u=i?i(Oa(e,s),o,s+"",e,t,a):n;u===n&&(u=o),tr(e,s,u)}}),Ms)}function Kr(e,t){var r=e.length;if(r)return ba(t+=t<0?r:0,r)?e[t]:n}function Vr(e,t,n){t=t.length?Pt(t,(function(e){return $o(e)?function(t){return Sr(t,1===e.length?e[0]:e)}:e})):[au];var r=-1;t=Pt(t,Ht(ca()));var i=Br(e,(function(e,n,i){var a=Pt(t,(function(t){return t(e)}));return{criteria:a,index:++r,value:e}}));return function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}(i,(function(e,t){return function(e,t,n){var r=-1,i=e.criteria,a=t.criteria,o=i.length,s=n.length;for(;++r<o;){var u=Ii(i[r],a[r]);if(u)return r>=s?u:u*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)}))}function $r(e,t,n){for(var r=-1,i=t.length,a={};++r<i;){var o=t[r],s=Sr(e,o);n(s,o)&&ei(a,wi(o,e),s)}return a}function Gr(e,t,n,r){var i=r?Bt:Ft,a=-1,o=t.length,s=e;for(e===t&&(t=Oi(t)),n&&(s=Pt(e,Ht(n)));++a<o;)for(var u=0,c=t[a],l=n?n(c):c;(u=i(s,l,u,r))>-1;)s!==e&&He.call(s,u,1),He.call(e,u,1);return e}function Jr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==a){var a=i;ba(i)?He.call(e,i,1):di(e,i)}}return e}function Hr(e,t){return e+yt(xn()*(t-e+1))}function Yr(e,t){var n="";if(!e||t<1||t>d)return n;do{t%2&&(n+=e),(t=yt(t/2))&&(e+=e)}while(t);return n}function Qr(e,t){return ja(Ia(e,t,au),e+"")}function Xr(e){return Xn(zs(e))}function Zr(e,t){var n=zs(e);return Ua(n,ur(t,0,n.length))}function ei(e,t,r,i){if(!ns(e))return e;for(var a=-1,o=(t=wi(t,e)).length,s=o-1,u=e;null!=u&&++a<o;){var c=Da(t[a]),l=r;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(a!=s){var f=u[c];(l=i?i(f,c,u):n)===n&&(l=ns(f)?f:ba(t[a+1])?[]:{})}nr(u,c,l),u=u[c]}return e}var ti=Pn?function(e,t){return Pn.set(e,t),e}:au,ni=ct?function(e,t){return ct(e,"toString",{configurable:!0,enumerable:!1,value:nu(t),writable:!0})}:au;function ri(e){return Ua(zs(e))}function ii(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var a=ae(i);++r<i;)a[r]=e[r+t];return a}function ai(e,t){var n;return pr(e,(function(e,r,i){return!(n=t(e,r,i))})),!!n}function oi(e,t,n){var r=0,i=null==e?r:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;r<i;){var a=r+i>>>1,o=e[a];null!==o&&!ls(o)&&(n?o<=t:o<t)?r=a+1:i=a}return i}return si(e,t,au,n)}function si(e,t,r,i){var a=0,o=null==e?0:e.length;if(0===o)return 0;for(var s=(t=r(t))!=t,u=null===t,c=ls(t),l=t===n;a<o;){var f=yt((a+o)/2),d=r(e[f]),p=d!==n,h=null===d,v=d==d,y=ls(d);if(s)var g=i||v;else g=l?v&&(i||p):u?v&&p&&(i||!h):c?v&&p&&!h&&(i||!y):!h&&!y&&(i?d<=t:d<t);g?a=f+1:o=f}return wn(o,4294967294)}function ui(e,t){for(var n=-1,r=e.length,i=0,a=[];++n<r;){var o=e[n],s=t?t(o):o;if(!n||!zo(s,u)){var u=s;a[i++]=0===o?0:o}}return a}function ci(e){return"number"==typeof e?e:ls(e)?p:+e}function li(e){if("string"==typeof e)return e;if($o(e))return Pt(e,li)+"";if(ls(e))return Bn?Bn.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function fi(e,t,n){var r=-1,i=Ct,a=e.length,o=!0,s=[],u=s;if(n)o=!1,i=Ot;else if(a>=200){var c=t?null:Yi(e);if(c)return cn(c);o=!1,i=Qt,u=new Hn}else u=t?[]:s;e:for(;++r<a;){var l=e[r],f=t?t(l):l;if(l=n||0!==l?l:0,o&&f==f){for(var d=u.length;d--;)if(u[d]===f)continue e;t&&u.push(f),s.push(l)}else i(u,f,n)||(u!==s&&u.push(f),s.push(l))}return s}function di(e,t){return null==(e=Ta(e,t=wi(t,e)))||delete e[Da(Qa(t))]}function pi(e,t,n,r){return ei(e,t,n(Sr(e,t)),r)}function hi(e,t,n,r){for(var i=e.length,a=r?i:-1;(r?a--:++a<i)&&t(e[a],a,e););return n?ii(e,r?0:a,r?a+1:i):ii(e,r?a+1:0,r?i:a)}function vi(e,t){var n=e;return n instanceof Vn&&(n=n.value()),jt(t,(function(e,t){return t.func.apply(t.thisArg,At([e],t.args))}),n)}function yi(e,t,n){var r=e.length;if(r<2)return r?fi(e[0]):[];for(var i=-1,a=ae(r);++i<r;)for(var o=e[i],s=-1;++s<r;)s!=i&&(a[i]=dr(a[i]||o,e[s],t,n));return fi(mr(a,1),t,n)}function gi(e,t,r){for(var i=-1,a=e.length,o=t.length,s={};++i<a;){var u=i<o?t[i]:n;r(s,e[i],u)}return s}function mi(e){return Ho(e)?e:[]}function bi(e){return"function"==typeof e?e:au}function wi(e,t){return $o(e)?e:ka(e,t)?[e]:Na(ws(e))}var ki=Qr;function _i(e,t,r){var i=e.length;return r=r===n?i:r,!t&&r>=i?e:ii(e,t,r)}var xi=lt||function(e){return ft.clearTimeout(e)};function Si(e,t){if(t)return e.slice();var n=e.length,r=Ve?Ve(n):new e.constructor(n);return e.copy(r),r}function Ei(e){var t=new e.constructor(e.byteLength);return new Ke(t).set(new Ke(e)),t}function Ri(e,t){var n=t?Ei(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ii(e,t){if(e!==t){var r=e!==n,i=null===e,a=e==e,o=ls(e),s=t!==n,u=null===t,c=t==t,l=ls(t);if(!u&&!l&&!o&&e>t||o&&s&&c&&!u&&!l||i&&s&&c||!r&&c||!a)return 1;if(!i&&!o&&!l&&e<t||l&&r&&a&&!i&&!o||u&&r&&a||!s&&a||!c)return-1}return 0}function Ti(e,t,n,r){for(var i=-1,a=e.length,o=n.length,s=-1,u=t.length,c=bn(a-o,0),l=ae(u+c),f=!r;++s<u;)l[s]=t[s];for(;++i<o;)(f||i<a)&&(l[n[i]]=e[i]);for(;c--;)l[s++]=e[i++];return l}function Ci(e,t,n,r){for(var i=-1,a=e.length,o=-1,s=n.length,u=-1,c=t.length,l=bn(a-s,0),f=ae(l+c),d=!r;++i<l;)f[i]=e[i];for(var p=i;++u<c;)f[p+u]=t[u];for(;++o<s;)(d||i<a)&&(f[p+n[o]]=e[i++]);return f}function Oi(e,t){var n=-1,r=e.length;for(t||(t=ae(r));++n<r;)t[n]=e[n];return t}function Pi(e,t,r,i){var a=!r;r||(r={});for(var o=-1,s=t.length;++o<s;){var u=t[o],c=i?i(r[u],e[u],u,r,e):n;c===n&&(c=e[u]),a?or(r,u,c):nr(r,u,c)}return r}function Ai(e,t){return function(n,r){var i=$o(n)?St:ir,a=t?t():{};return i(n,e,ca(r,2),a)}}function ji(e){return Qr((function(t,r){var i=-1,a=r.length,o=a>1?r[a-1]:n,s=a>2?r[2]:n;for(o=e.length>3&&"function"==typeof o?(a--,o):n,s&&wa(r[0],r[1],s)&&(o=a<3?n:o,a=1),t=Re(t);++i<a;){var u=r[i];u&&e(t,u,i,o)}return t}))}function Mi(e,t){return function(n,r){if(null==n)return n;if(!Jo(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Re(n);(t?a--:++a<i)&&!1!==r(o[a],a,o););return n}}function Li(e){return function(t,n,r){for(var i=-1,a=Re(t),o=r(t),s=o.length;s--;){var u=o[e?s:++i];if(!1===n(a[u],u,a))break}return t}}function Ui(e){return function(t){var r=an(t=ws(t))?dn(t):n,i=r?r[0]:t.charAt(0),a=r?_i(r,1).join(""):t.slice(1);return i[e]()+a}}function Ni(e){return function(t){return jt(Zs(Vs(t).replace(Ye,"")),e,"")}}function Di(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=zn(e.prototype),r=e.apply(n,t);return ns(r)?r:n}}function Fi(e){return function(t,r,i){var a=Re(t);if(!Jo(t)){var o=ca(r,3);t=js(t),r=function(e){return o(a[e],e,a)}}var s=e(t,r,i);return s>-1?a[o?t[s]:s]:n}}function Bi(e){return ra((function(t){var i=t.length,a=i,o=Kn.prototype.thru;for(e&&t.reverse();a--;){var s=t[a];if("function"!=typeof s)throw new Ce(r);if(o&&!u&&"wrapper"==sa(s))var u=new Kn([],!0)}for(a=u?a:i;++a<i;){var c=sa(s=t[a]),l="wrapper"==c?oa(s):n;u=l&&_a(l[0])&&424==l[1]&&!l[4].length&&1==l[9]?u[sa(l[0])].apply(u,l[3]):1==s.length&&_a(s)?u[c]():u.thru(s)}return function(){var e=arguments,n=e[0];if(u&&1==e.length&&$o(n))return u.plant(n).value();for(var r=0,a=i?t[r].apply(this,e):n;++r<i;)a=t[r].call(this,a);return a}}))}function qi(e,t,r,i,a,o,s,u,l,f){var d=t&c,p=1&t,h=2&t,v=24&t,y=512&t,g=h?n:Di(e);return function n(){for(var c=arguments.length,m=ae(c),b=c;b--;)m[b]=arguments[b];if(v)var w=ua(n),k=en(m,w);if(i&&(m=Ti(m,i,a,v)),o&&(m=Ci(m,o,s,v)),c-=k,v&&c<f){var _=un(m,w);return Ji(e,t,qi,n.placeholder,r,m,_,u,l,f-c)}var x=p?r:this,S=h?x[e]:e;return c=m.length,u?m=Ca(m,u):y&&c>1&&m.reverse(),d&&l<c&&(m.length=l),this&&this!==ft&&this instanceof n&&(S=g||Di(S)),S.apply(x,m)}}function zi(e,t){return function(n,r){return function(e,t,n,r){return kr(e,(function(e,i,a){t(r,n(e),i,a)})),r}(n,e,t(r),{})}}function Wi(e,t){return function(r,i){var a;if(r===n&&i===n)return t;if(r!==n&&(a=r),i!==n){if(a===n)return i;"string"==typeof r||"string"==typeof i?(r=li(r),i=li(i)):(r=ci(r),i=ci(i)),a=e(r,i)}return a}}function Ki(e){return ra((function(t){return t=Pt(t,Ht(ca())),Qr((function(n){var r=this;return e(t,(function(e){return xt(e,r,n)}))}))}))}function Vi(e,t){var r=(t=t===n?" ":li(t)).length;if(r<2)return r?Yr(t,e):t;var i=Yr(t,vt(e/fn(t)));return an(t)?_i(dn(i),0,e).join(""):i.slice(0,e)}function $i(e){return function(t,r,i){return i&&"number"!=typeof i&&wa(t,r,i)&&(r=i=n),t=vs(t),r===n?(r=t,t=0):r=vs(r),function(e,t,n,r){for(var i=-1,a=bn(vt((t-e)/(n||1)),0),o=ae(a);a--;)o[r?a:++i]=e,e+=n;return o}(t,r,i=i===n?t<r?1:-1:vs(i),e)}}function Gi(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=ms(t),n=ms(n)),e(t,n)}}function Ji(e,t,r,i,a,o,c,l,f,d){var p=8&t;t|=p?s:u,4&(t&=~(p?u:s))||(t&=-4);var h=[e,t,a,p?o:n,p?c:n,p?n:o,p?n:c,l,f,d],v=r.apply(n,h);return _a(e)&&Pa(v,h),v.placeholder=i,Ma(v,e,t)}function Hi(e){var t=Ee[e];return function(e,n){if(e=ms(e),(n=null==n?0:wn(ys(n),292))&&yn(e)){var r=(ws(e)+"e").split("e");return+((r=(ws(t(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return t(e)}}var Yi=Tn&&1/cn(new Tn([,-0]))[1]==f?function(e){return new Tn(e)}:lu;function Qi(e){return function(t){var n=va(t);return n==x?on(t):n==T?ln(t):function(e,t){return Pt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Xi(e,t,i,f,d,p,h,v){var y=2&t;if(!y&&"function"!=typeof e)throw new Ce(r);var g=f?f.length:0;if(g||(t&=-97,f=d=n),h=h===n?h:bn(ys(h),0),v=v===n?v:ys(v),g-=d?d.length:0,t&u){var m=f,b=d;f=d=n}var w=y?n:oa(e),k=[e,t,i,f,d,m,b,p,h,v];if(w&&function(e,t){var n=e[1],r=t[1],i=n|r,o=i<131,s=r==c&&8==n||r==c&&n==l&&e[7].length<=t[8]||384==r&&t[7].length<=t[8]&&8==n;if(!o&&!s)return e;1&r&&(e[2]=t[2],i|=1&n?0:4);var u=t[3];if(u){var f=e[3];e[3]=f?Ti(f,u,t[4]):u,e[4]=f?un(e[3],a):t[4]}(u=t[5])&&(f=e[5],e[5]=f?Ci(f,u,t[6]):u,e[6]=f?un(e[5],a):t[6]);(u=t[7])&&(e[7]=u);r&c&&(e[8]=null==e[8]?t[8]:wn(e[8],t[8]));null==e[9]&&(e[9]=t[9]);e[0]=t[0],e[1]=i}(k,w),e=k[0],t=k[1],i=k[2],f=k[3],d=k[4],!(v=k[9]=k[9]===n?y?0:e.length:bn(k[9]-g,0))&&24&t&&(t&=-25),t&&1!=t)_=8==t||t==o?function(e,t,r){var i=Di(e);return function a(){for(var o=arguments.length,s=ae(o),u=o,c=ua(a);u--;)s[u]=arguments[u];var l=o<3&&s[0]!==c&&s[o-1]!==c?[]:un(s,c);return(o-=l.length)<r?Ji(e,t,qi,a.placeholder,n,s,l,n,n,r-o):xt(this&&this!==ft&&this instanceof a?i:e,this,s)}}(e,t,v):t!=s&&33!=t||d.length?qi.apply(n,k):function(e,t,n,r){var i=1&t,a=Di(e);return function t(){for(var o=-1,s=arguments.length,u=-1,c=r.length,l=ae(c+s),f=this&&this!==ft&&this instanceof t?a:e;++u<c;)l[u]=r[u];for(;s--;)l[u++]=arguments[++o];return xt(f,i?n:this,l)}}(e,t,i,f);else var _=function(e,t,n){var r=1&t,i=Di(e);return function t(){return(this&&this!==ft&&this instanceof t?i:e).apply(r?n:this,arguments)}}(e,t,i);return Ma((w?ti:Pa)(_,k),e,t)}function Zi(e,t,r,i){return e===n||zo(e,Ae[r])&&!Le.call(i,r)?t:e}function ea(e,t,r,i,a,o){return ns(e)&&ns(t)&&(o.set(t,e),Wr(e,t,n,ea,o),o.delete(t)),e}function ta(e){return os(e)?n:e}function na(e,t,r,i,a,o){var s=1&r,u=e.length,c=t.length;if(u!=c&&!(s&&c>u))return!1;var l=o.get(e),f=o.get(t);if(l&&f)return l==t&&f==e;var d=-1,p=!0,h=2&r?new Hn:n;for(o.set(e,t),o.set(t,e);++d<u;){var v=e[d],y=t[d];if(i)var g=s?i(y,v,d,t,e,o):i(v,y,d,e,t,o);if(g!==n){if(g)continue;p=!1;break}if(h){if(!Lt(t,(function(e,t){if(!Qt(h,t)&&(v===e||a(v,e,r,i,o)))return h.push(t)}))){p=!1;break}}else if(v!==y&&!a(v,y,r,i,o)){p=!1;break}}return o.delete(e),o.delete(t),p}function ra(e){return ja(Ia(e,n,$a),e+"")}function ia(e){return Er(e,js,pa)}function aa(e){return Er(e,Ms,ha)}var oa=Pn?function(e){return Pn.get(e)}:lu;function sa(e){for(var t=e.name+"",n=An[t],r=Le.call(An,t)?n.length:0;r--;){var i=n[r],a=i.func;if(null==a||a==e)return i.name}return t}function ua(e){return(Le.call(qn,"placeholder")?qn:e).placeholder}function ca(){var e=qn.iteratee||ou;return e=e===ou?Ur:e,arguments.length?e(arguments[0],arguments[1]):e}function la(e,t){var n=e.__data__;return function(e){var t=jI.default(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function fa(e){for(var t=js(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,Ea(i)]}return t}function da(e,t){var r=function(e,t){return null==e?n:e[t]}(e,t);return Lr(r)?r:n}var pa=Ut?function(e){return null==e?[]:(e=Re(e),Tt(Ut(e),(function(t){return Je.call(e,t)})))}:gu,ha=Ut?function(e){for(var t=[];e;)At(t,pa(e)),e=$e(e);return t}:gu,va=Rr;function ya(e,t,n){for(var r=-1,i=(t=wi(t,e)).length,a=!1;++r<i;){var o=Da(t[r]);if(!(a=null!=e&&n(e,o)))break;e=e[o]}return a||++r!=i?a:!!(i=null==e?0:e.length)&&ts(i)&&ba(o,i)&&($o(e)||Vo(e))}function ga(e){return"function"!=typeof e.constructor||Sa(e)?{}:zn($e(e))}function ma(e){return $o(e)||Vo(e)||!!(Xe&&e&&e[Xe])}function ba(e,t){var n=jI.default(e);return!!(t=null==t?d:t)&&("number"==n||"symbol"!=n&&me.test(e))&&e>-1&&e%1==0&&e<t}function wa(e,t,n){if(!ns(n))return!1;var r=jI.default(t);return!!("number"==r?Jo(n)&&ba(t,n.length):"string"==r&&t in n)&&zo(n[t],e)}function ka(e,t){if($o(e))return!1;var n=jI.default(e);return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!ls(e))||(ee.test(e)||!Z.test(e)||null!=t&&e in Re(t))}function _a(e){var t=sa(e),n=qn[t];if("function"!=typeof n||!(t in Vn.prototype))return!1;if(e===n)return!0;var r=oa(n);return!!r&&e===r[0]}(En&&va(new En(new ArrayBuffer(1)))!=j||Rn&&va(new Rn)!=x||In&&va(In.resolve())!=R||Tn&&va(new Tn)!=T||Cn&&va(new Cn)!=P)&&(va=function(e){var t=Rr(e),r=t==E?e.constructor:n,i=r?Fa(r):"";if(i)switch(i){case jn:return j;case Mn:return x;case Ln:return R;case Un:return T;case Nn:return P}return t});var xa=je?Zo:mu;function Sa(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ae)}function Ea(e){return e==e&&!ns(e)}function Ra(e,t){return function(r){return null!=r&&(r[e]===t&&(t!==n||e in Re(r)))}}function Ia(e,t,r){return t=bn(t===n?e.length-1:t,0),function(){for(var n=arguments,i=-1,a=bn(n.length-t,0),o=ae(a);++i<a;)o[i]=n[t+i];i=-1;for(var s=ae(t+1);++i<t;)s[i]=n[i];return s[t]=r(o),xt(e,this,s)}}function Ta(e,t){return t.length<2?e:Sr(e,ii(t,0,-1))}function Ca(e,t){for(var r=e.length,i=wn(t.length,r),a=Oi(e);i--;){var o=t[i];e[i]=ba(o,r)?a[o]:n}return e}function Oa(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Pa=La(ti),Aa=pt||function(e,t){return ft.setTimeout(e,t)},ja=La(ni);function Ma(e,t,n){var r=t+"";return ja(e,function(e,t){var n=t.length;if(!n)return e;var r=n-1;return t[r]=(n>1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return Et(v,(function(n){var r="_."+n[0];t&n[1]&&!Ct(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ue):[]}(r),n)))}function La(e){var t=0,r=0;return function(){var i=kn(),a=16-(i-r);if(r=i,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Ua(e,t){var r=-1,i=e.length,a=i-1;for(t=t===n?i:t;++r<t;){var o=Hr(r,a),s=e[o];e[o]=e[r],e[r]=s}return e.length=t,e}var Na=function(e){var t=Uo(e,(function(e){return 500===n.size&&n.clear(),e})),n=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(te,(function(e,n,r,i){t.push(r?i.replace(fe,"$1"):n||e)})),t}));function Da(e){if("string"==typeof e||ls(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Fa(e){if(null!=e){try{return Me.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ba(e){if(e instanceof Vn)return e.clone();var t=new Kn(e.__wrapped__,e.__chain__);return t.__actions__=Oi(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var qa=Qr((function(e,t){return Ho(e)?dr(e,mr(t,1,Ho,!0)):[]})),za=Qr((function(e,t){var r=Qa(t);return Ho(r)&&(r=n),Ho(e)?dr(e,mr(t,1,Ho,!0),ca(r,2)):[]})),Wa=Qr((function(e,t){var r=Qa(t);return Ho(r)&&(r=n),Ho(e)?dr(e,mr(t,1,Ho,!0),n,r):[]}));function Ka(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:ys(n);return i<0&&(i=bn(r+i,0)),Dt(e,ca(t,3),i)}function Va(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var a=i-1;return r!==n&&(a=ys(r),a=r<0?bn(i+a,0):wn(a,i-1)),Dt(e,ca(t,3),a,!0)}function $a(e){return(null==e?0:e.length)?mr(e,1):[]}function Ga(e){return e&&e.length?e[0]:n}var Ja=Qr((function(e){var t=Pt(e,mi);return t.length&&t[0]===e[0]?Or(t):[]})),Ha=Qr((function(e){var t=Qa(e),r=Pt(e,mi);return t===Qa(r)?t=n:r.pop(),r.length&&r[0]===e[0]?Or(r,ca(t,2)):[]})),Ya=Qr((function(e){var t=Qa(e),r=Pt(e,mi);return(t="function"==typeof t?t:n)&&r.pop(),r.length&&r[0]===e[0]?Or(r,n,t):[]}));function Qa(e){var t=null==e?0:e.length;return t?e[t-1]:n}var Xa=Qr(Za);function Za(e,t){return e&&e.length&&t&&t.length?Gr(e,t):e}var eo=ra((function(e,t){var n=null==e?0:e.length,r=sr(e,t);return Jr(e,Pt(t,(function(e){return ba(e,n)?+e:e})).sort(Ii)),r}));function to(e){return null==e?e:Sn.call(e)}var no=Qr((function(e){return fi(mr(e,1,Ho,!0))})),ro=Qr((function(e){var t=Qa(e);return Ho(t)&&(t=n),fi(mr(e,1,Ho,!0),ca(t,2))})),io=Qr((function(e){var t=Qa(e);return t="function"==typeof t?t:n,fi(mr(e,1,Ho,!0),n,t)}));function ao(e){if(!e||!e.length)return[];var t=0;return e=Tt(e,(function(e){if(Ho(e))return t=bn(e.length,t),!0})),Gt(t,(function(t){return Pt(e,Wt(t))}))}function oo(e,t){if(!e||!e.length)return[];var r=ao(e);return null==t?r:Pt(r,(function(e){return xt(t,n,e)}))}var so=Qr((function(e,t){return Ho(e)?dr(e,t):[]})),uo=Qr((function(e){return yi(Tt(e,Ho))})),co=Qr((function(e){var t=Qa(e);return Ho(t)&&(t=n),yi(Tt(e,Ho),ca(t,2))})),lo=Qr((function(e){var t=Qa(e);return t="function"==typeof t?t:n,yi(Tt(e,Ho),n,t)})),fo=Qr(ao);var po=Qr((function(e){var t=e.length,r=t>1?e[t-1]:n;return r="function"==typeof r?(e.pop(),r):n,oo(e,r)}));function ho(e){var t=qn(e);return t.__chain__=!0,t}function vo(e,t){return t(e)}var yo=ra((function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,a=function(t){return sr(t,e)};return!(t>1||this.__actions__.length)&&i instanceof Vn&&ba(r)?((i=i.slice(r,+r+(t?1:0))).__actions__.push({func:vo,args:[a],thisArg:n}),new Kn(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(n),e}))):this.thru(a)}));var go=Ai((function(e,t,n){Le.call(e,n)?++e[n]:or(e,n,1)}));var mo=Fi(Ka),bo=Fi(Va);function wo(e,t){return($o(e)?Et:pr)(e,ca(t,3))}function ko(e,t){return($o(e)?Rt:hr)(e,ca(t,3))}var _o=Ai((function(e,t,n){Le.call(e,n)?e[n].push(t):or(e,n,[t])}));var xo=Qr((function(e,t,n){var r=-1,i="function"==typeof t,a=Jo(e)?ae(e.length):[];return pr(e,(function(e){a[++r]=i?xt(t,e,n):Pr(e,t,n)})),a})),So=Ai((function(e,t,n){or(e,n,t)}));function Eo(e,t){return($o(e)?Pt:Br)(e,ca(t,3))}var Ro=Ai((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var Io=Qr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&wa(e,t[0],t[1])?t=[]:n>2&&wa(t[0],t[1],t[2])&&(t=[t[0]]),Vr(e,mr(t,1),[])})),To=dt||function(){return ft.Date.now()};function Co(e,t,r){return t=r?n:t,t=e&&null==t?e.length:t,Xi(e,c,n,n,n,n,t)}function Oo(e,t){var i;if("function"!=typeof t)throw new Ce(r);return e=ys(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=n),i}}var Po=Qr((function(e,t,n){var r=1;if(n.length){var i=un(n,ua(Po));r|=s}return Xi(e,r,t,n,i)})),Ao=Qr((function(e,t,n){var r=3;if(n.length){var i=un(n,ua(Ao));r|=s}return Xi(t,r,e,n,i)}));function jo(e,t,i){var a,o,s,u,c,l,f=0,d=!1,p=!1,h=!0;if("function"!=typeof e)throw new Ce(r);function v(t){var r=a,i=o;return a=o=n,f=t,u=e.apply(i,r)}function y(e){return f=e,c=Aa(m,t),d?v(e):u}function g(e){var r=e-l;return l===n||r>=t||r<0||p&&e-f>=s}function m(){var e=To();if(g(e))return b(e);c=Aa(m,function(e){var n=t-(e-l);return p?wn(n,s-(e-f)):n}(e))}function b(e){return c=n,h&&a?v(e):(a=o=n,u)}function w(){var e=To(),r=g(e);if(a=arguments,o=this,l=e,r){if(c===n)return y(l);if(p)return xi(c),c=Aa(m,t),v(l)}return c===n&&(c=Aa(m,t)),u}return t=ms(t)||0,ns(i)&&(d=!!i.leading,s=(p="maxWait"in i)?bn(ms(i.maxWait)||0,t):s,h="trailing"in i?!!i.trailing:h),w.cancel=function(){c!==n&&xi(c),f=0,a=l=o=c=n},w.flush=function(){return c===n?u:b(To())},w}var Mo=Qr((function(e,t){return fr(e,1,t)})),Lo=Qr((function(e,t,n){return fr(e,ms(t)||0,n)}));function Uo(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ce(r);var n=function n(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Uo.Cache||Jn),n}function No(e){if("function"!=typeof e)throw new Ce(r);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Uo.Cache=Jn;var Do=ki((function(e,t){var n=(t=1==t.length&&$o(t[0])?Pt(t[0],Ht(ca())):Pt(mr(t,1),Ht(ca()))).length;return Qr((function(r){for(var i=-1,a=wn(r.length,n);++i<a;)r[i]=t[i].call(this,r[i]);return xt(e,this,r)}))})),Fo=Qr((function(e,t){var r=un(t,ua(Fo));return Xi(e,s,n,t,r)})),Bo=Qr((function(e,t){var r=un(t,ua(Bo));return Xi(e,u,n,t,r)})),qo=ra((function(e,t){return Xi(e,l,n,n,n,t)}));function zo(e,t){return e===t||e!=e&&t!=t}var Wo=Gi(Ir),Ko=Gi((function(e,t){return e>=t})),Vo=Ar(function(){return arguments}())?Ar:function(e){return rs(e)&&Le.call(e,"callee")&&!Je.call(e,"callee")},$o=ae.isArray,Go=gt?Ht(gt):function(e){return rs(e)&&Rr(e)==A};function Jo(e){return null!=e&&ts(e.length)&&!Zo(e)}function Ho(e){return rs(e)&&Jo(e)}var Yo=Kt||mu,Qo=mt?Ht(mt):function(e){return rs(e)&&Rr(e)==b};function Xo(e){if(!rs(e))return!1;var t=Rr(e);return t==w||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!os(e)}function Zo(e){if(!ns(e))return!1;var t=Rr(e);return t==k||t==_||"[object AsyncFunction]"==t||"[object Proxy]"==t}function es(e){return"number"==typeof e&&e==ys(e)}function ts(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=d}function ns(e){var t=jI.default(e);return null!=e&&("object"==t||"function"==t)}function rs(e){return null!=e&&"object"==jI.default(e)}var is=bt?Ht(bt):function(e){return rs(e)&&va(e)==x};function as(e){return"number"==typeof e||rs(e)&&Rr(e)==S}function os(e){if(!rs(e)||Rr(e)!=E)return!1;var t=$e(e);if(null===t)return!0;var n=Le.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Me.call(n)==Fe}var ss=wt?Ht(wt):function(e){return rs(e)&&Rr(e)==I};var us=kt?Ht(kt):function(e){return rs(e)&&va(e)==T};function cs(e){return"string"==typeof e||!$o(e)&&rs(e)&&Rr(e)==C}function ls(e){return"symbol"==jI.default(e)||rs(e)&&Rr(e)==O}var fs=_t?Ht(_t):function(e){return rs(e)&&ts(e.length)&&!!it[Rr(e)]};var ds=Gi(Fr),ps=Gi((function(e,t){return e<=t}));function hs(e){if(!e)return[];if(Jo(e))return cs(e)?dn(e):Oi(e);if(et&&e[et])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[et]());var t=va(e);return(t==x?on:t==T?cn:zs)(e)}function vs(e){return e?(e=ms(e))===f||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ys(e){var t=vs(e),n=t%1;return t==t?n?t-n:t:0}function gs(e){return e?ur(ys(e),0,h):0}function ms(e){if("number"==typeof e)return e;if(ls(e))return p;if(ns(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ns(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Jt(e);var n=ve.test(e);return n||ge.test(e)?ut(e.slice(2),n?2:8):he.test(e)?p:+e}function bs(e){return Pi(e,Ms(e))}function ws(e){return null==e?"":li(e)}var ks=ji((function(e,t){if(Sa(t)||Jo(t))Pi(t,js(t),e);else for(var n in t)Le.call(t,n)&&nr(e,n,t[n])})),_s=ji((function(e,t){Pi(t,Ms(t),e)})),xs=ji((function(e,t,n,r){Pi(t,Ms(t),e,r)})),Ss=ji((function(e,t,n,r){Pi(t,js(t),e,r)})),Es=ra(sr);var Rs=Qr((function(e,t){e=Re(e);var r=-1,i=t.length,a=i>2?t[2]:n;for(a&&wa(t[0],t[1],a)&&(i=1);++r<i;)for(var o=t[r],s=Ms(o),u=-1,c=s.length;++u<c;){var l=s[u],f=e[l];(f===n||zo(f,Ae[l])&&!Le.call(e,l))&&(e[l]=o[l])}return e})),Is=Qr((function(e){return e.push(n,ea),xt(Us,n,e)}));function Ts(e,t,r){var i=null==e?n:Sr(e,t);return i===n?r:i}function Cs(e,t){return null!=e&&ya(e,t,Cr)}var Os=zi((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),e[t]=n}),nu(au)),Ps=zi((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=De.call(t)),Le.call(e,t)?e[t].push(n):e[t]=[n]}),ca),As=Qr(Pr);function js(e){return Jo(e)?Qn(e):Nr(e)}function Ms(e){return Jo(e)?Qn(e,!0):Dr(e)}var Ls=ji((function(e,t,n){Wr(e,t,n)})),Us=ji((function(e,t,n,r){Wr(e,t,n,r)})),Ns=ra((function(e,t){var n={};if(null==e)return n;var r=!1;t=Pt(t,(function(t){return t=wi(t,e),r||(r=t.length>1),t})),Pi(e,aa(e),n),r&&(n=cr(n,7,ta));for(var i=t.length;i--;)di(n,t[i]);return n}));var Ds=ra((function(e,t){return null==e?{}:function(e,t){return $r(e,t,(function(t,n){return Cs(e,n)}))}(e,t)}));function Fs(e,t){if(null==e)return{};var n=Pt(aa(e),(function(e){return[e]}));return t=ca(t),$r(e,n,(function(e,n){return t(e,n[0])}))}var Bs=Qi(js),qs=Qi(Ms);function zs(e){return null==e?[]:Yt(e,js(e))}var Ws=Ni((function(e,t,n){return t=t.toLowerCase(),e+(n?Ks(t):t)}));function Ks(e){return Xs(ws(e).toLowerCase())}function Vs(e){return(e=ws(e))&&e.replace(be,tn).replace(Qe,"")}var $s=Ni((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Gs=Ni((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Js=Ui("toLowerCase");var Hs=Ni((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Ys=Ni((function(e,t,n){return e+(n?" ":"")+Xs(t)}));var Qs=Ni((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Xs=Ui("toUpperCase");function Zs(e,t,r){return e=ws(e),(t=r?n:t)===n?function(e){return tt.test(e)}(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.match(ce)||[]}(e):e.match(t)||[]}var eu=Qr((function(e,t){try{return xt(e,n,t)}catch(e){return Xo(e)?e:new xe(e)}})),tu=ra((function(e,t){return Et(t,(function(t){t=Da(t),or(e,t,Po(e[t],e))})),e}));function nu(e){return function(){return e}}var ru=Bi(),iu=Bi(!0);function au(e){return e}function ou(e){return Ur("function"==typeof e?e:cr(e,1))}var su=Qr((function(e,t){return function(n){return Pr(n,e,t)}})),uu=Qr((function(e,t){return function(n){return Pr(e,n,t)}}));function cu(e,t,n){var r=js(t),i=xr(t,r);null!=n||ns(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=xr(t,js(t)));var a=!(ns(n)&&"chain"in n&&!n.chain),o=Zo(e);return Et(i,(function(n){var r=t[n];e[n]=r,o&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__),i=n.__actions__=Oi(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,At([this.value()],arguments))})})),e}function lu(){}var fu=Ki(Pt),du=Ki(It),pu=Ki(Lt);function hu(e){return ka(e)?Wt(Da(e)):function(e){return function(t){return Sr(t,e)}}(e)}var vu=$i(),yu=$i(!0);function gu(){return[]}function mu(){return!1}var bu=Wi((function(e,t){return e+t}),0),wu=Hi("ceil"),ku=Wi((function(e,t){return e/t}),1),_u=Hi("floor");var xu,Su=Wi((function(e,t){return e*t}),1),Eu=Hi("round"),Ru=Wi((function(e,t){return e-t}),0);return qn.after=function(e,t){if("function"!=typeof t)throw new Ce(r);return e=ys(e),function(){if(--e<1)return t.apply(this,arguments)}},qn.ary=Co,qn.assign=ks,qn.assignIn=_s,qn.assignInWith=xs,qn.assignWith=Ss,qn.at=Es,qn.before=Oo,qn.bind=Po,qn.bindAll=tu,qn.bindKey=Ao,qn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return $o(e)?e:[e]},qn.chain=ho,qn.chunk=function(e,t,r){t=(r?wa(e,t,r):t===n)?1:bn(ys(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var a=0,o=0,s=ae(vt(i/t));a<i;)s[o++]=ii(e,a,a+=t);return s},qn.compact=function(e){for(var t=-1,n=null==e?0:e.length,r=0,i=[];++t<n;){var a=e[t];a&&(i[r++]=a)}return i},qn.concat=function(){var e=arguments.length;if(!e)return[];for(var t=ae(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return At($o(n)?Oi(n):[n],mr(t,1))},qn.cond=function(e){var t=null==e?0:e.length,n=ca();return e=t?Pt(e,(function(e){if("function"!=typeof e[1])throw new Ce(r);return[n(e[0]),e[1]]})):[],Qr((function(n){for(var r=-1;++r<t;){var i=e[r];if(xt(i[0],this,n))return xt(i[1],this,n)}}))},qn.conforms=function(e){return function(e){var t=js(e);return function(n){return lr(n,e,t)}}(cr(e,1))},qn.constant=nu,qn.countBy=go,qn.create=function(e,t){var n=zn(e);return null==t?n:ar(n,t)},qn.curry=function e(t,r,i){var a=Xi(t,8,n,n,n,n,n,r=i?n:r);return a.placeholder=e.placeholder,a},qn.curryRight=function e(t,r,i){var a=Xi(t,o,n,n,n,n,n,r=i?n:r);return a.placeholder=e.placeholder,a},qn.debounce=jo,qn.defaults=Rs,qn.defaultsDeep=Is,qn.defer=Mo,qn.delay=Lo,qn.difference=qa,qn.differenceBy=za,qn.differenceWith=Wa,qn.drop=function(e,t,r){var i=null==e?0:e.length;return i?ii(e,(t=r||t===n?1:ys(t))<0?0:t,i):[]},qn.dropRight=function(e,t,r){var i=null==e?0:e.length;return i?ii(e,0,(t=i-(t=r||t===n?1:ys(t)))<0?0:t):[]},qn.dropRightWhile=function(e,t){return e&&e.length?hi(e,ca(t,3),!0,!0):[]},qn.dropWhile=function(e,t){return e&&e.length?hi(e,ca(t,3),!0):[]},qn.fill=function(e,t,r,i){var a=null==e?0:e.length;return a?(r&&"number"!=typeof r&&wa(e,t,r)&&(r=0,i=a),function(e,t,r,i){var a=e.length;for((r=ys(r))<0&&(r=-r>a?0:a+r),(i=i===n||i>a?a:ys(i))<0&&(i+=a),i=r>i?0:gs(i);r<i;)e[r++]=t;return e}(e,t,r,i)):[]},qn.filter=function(e,t){return($o(e)?Tt:gr)(e,ca(t,3))},qn.flatMap=function(e,t){return mr(Eo(e,t),1)},qn.flatMapDeep=function(e,t){return mr(Eo(e,t),f)},qn.flatMapDepth=function(e,t,r){return r=r===n?1:ys(r),mr(Eo(e,t),r)},qn.flatten=$a,qn.flattenDeep=function(e){return(null==e?0:e.length)?mr(e,f):[]},qn.flattenDepth=function(e,t){return(null==e?0:e.length)?mr(e,t=t===n?1:ys(t)):[]},qn.flip=function(e){return Xi(e,512)},qn.flow=ru,qn.flowRight=iu,qn.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={};++t<n;){var i=e[t];r[i[0]]=i[1]}return r},qn.functions=function(e){return null==e?[]:xr(e,js(e))},qn.functionsIn=function(e){return null==e?[]:xr(e,Ms(e))},qn.groupBy=_o,qn.initial=function(e){return(null==e?0:e.length)?ii(e,0,-1):[]},qn.intersection=Ja,qn.intersectionBy=Ha,qn.intersectionWith=Ya,qn.invert=Os,qn.invertBy=Ps,qn.invokeMap=xo,qn.iteratee=ou,qn.keyBy=So,qn.keys=js,qn.keysIn=Ms,qn.map=Eo,qn.mapKeys=function(e,t){var n={};return t=ca(t,3),kr(e,(function(e,r,i){or(n,t(e,r,i),e)})),n},qn.mapValues=function(e,t){var n={};return t=ca(t,3),kr(e,(function(e,r,i){or(n,r,t(e,r,i))})),n},qn.matches=function(e){return qr(cr(e,1))},qn.matchesProperty=function(e,t){return zr(e,cr(t,1))},qn.memoize=Uo,qn.merge=Ls,qn.mergeWith=Us,qn.method=su,qn.methodOf=uu,qn.mixin=cu,qn.negate=No,qn.nthArg=function(e){return e=ys(e),Qr((function(t){return Kr(t,e)}))},qn.omit=Ns,qn.omitBy=function(e,t){return Fs(e,No(ca(t)))},qn.once=function(e){return Oo(2,e)},qn.orderBy=function(e,t,r,i){return null==e?[]:($o(t)||(t=null==t?[]:[t]),$o(r=i?n:r)||(r=null==r?[]:[r]),Vr(e,t,r))},qn.over=fu,qn.overArgs=Do,qn.overEvery=du,qn.overSome=pu,qn.partial=Fo,qn.partialRight=Bo,qn.partition=Ro,qn.pick=Ds,qn.pickBy=Fs,qn.property=hu,qn.propertyOf=function(e){return function(t){return null==e?n:Sr(e,t)}},qn.pull=Xa,qn.pullAll=Za,qn.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?Gr(e,t,ca(n,2)):e},qn.pullAllWith=function(e,t,r){return e&&e.length&&t&&t.length?Gr(e,t,n,r):e},qn.pullAt=eo,qn.range=vu,qn.rangeRight=yu,qn.rearg=qo,qn.reject=function(e,t){return($o(e)?Tt:gr)(e,No(ca(t,3)))},qn.remove=function(e,t){var n=[];if(!e||!e.length)return n;var r=-1,i=[],a=e.length;for(t=ca(t,3);++r<a;){var o=e[r];t(o,r,e)&&(n.push(o),i.push(r))}return Jr(e,i),n},qn.rest=function(e,t){if("function"!=typeof e)throw new Ce(r);return Qr(e,t=t===n?t:ys(t))},qn.reverse=to,qn.sampleSize=function(e,t,r){return t=(r?wa(e,t,r):t===n)?1:ys(t),($o(e)?Zn:Zr)(e,t)},qn.set=function(e,t,n){return null==e?e:ei(e,t,n)},qn.setWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:ei(e,t,r,i)},qn.shuffle=function(e){return($o(e)?er:ri)(e)},qn.slice=function(e,t,r){var i=null==e?0:e.length;return i?(r&&"number"!=typeof r&&wa(e,t,r)?(t=0,r=i):(t=null==t?0:ys(t),r=r===n?i:ys(r)),ii(e,t,r)):[]},qn.sortBy=Io,qn.sortedUniq=function(e){return e&&e.length?ui(e):[]},qn.sortedUniqBy=function(e,t){return e&&e.length?ui(e,ca(t,2)):[]},qn.split=function(e,t,r){return r&&"number"!=typeof r&&wa(e,t,r)&&(t=r=n),(r=r===n?h:r>>>0)?(e=ws(e))&&("string"==typeof t||null!=t&&!ss(t))&&!(t=li(t))&&an(e)?_i(dn(e),0,r):e.split(t,r):[]},qn.spread=function(e,t){if("function"!=typeof e)throw new Ce(r);return t=null==t?0:bn(ys(t),0),Qr((function(n){var r=n[t],i=_i(n,0,t);return r&&At(i,r),xt(e,this,i)}))},qn.tail=function(e){var t=null==e?0:e.length;return t?ii(e,1,t):[]},qn.take=function(e,t,r){return e&&e.length?ii(e,0,(t=r||t===n?1:ys(t))<0?0:t):[]},qn.takeRight=function(e,t,r){var i=null==e?0:e.length;return i?ii(e,(t=i-(t=r||t===n?1:ys(t)))<0?0:t,i):[]},qn.takeRightWhile=function(e,t){return e&&e.length?hi(e,ca(t,3),!1,!0):[]},qn.takeWhile=function(e,t){return e&&e.length?hi(e,ca(t,3)):[]},qn.tap=function(e,t){return t(e),e},qn.throttle=function(e,t,n){var i=!0,a=!0;if("function"!=typeof e)throw new Ce(r);return ns(n)&&(i="leading"in n?!!n.leading:i,a="trailing"in n?!!n.trailing:a),jo(e,t,{leading:i,maxWait:t,trailing:a})},qn.thru=vo,qn.toArray=hs,qn.toPairs=Bs,qn.toPairsIn=qs,qn.toPath=function(e){return $o(e)?Pt(e,Da):ls(e)?[e]:Oi(Na(ws(e)))},qn.toPlainObject=bs,qn.transform=function(e,t,n){var r=$o(e),i=r||Yo(e)||fs(e);if(t=ca(t,4),null==n){var a=e&&e.constructor;n=i?r?new a:[]:ns(e)&&Zo(a)?zn($e(e)):{}}return(i?Et:kr)(e,(function(e,r,i){return t(n,e,r,i)})),n},qn.unary=function(e){return Co(e,1)},qn.union=no,qn.unionBy=ro,qn.unionWith=io,qn.uniq=function(e){return e&&e.length?fi(e):[]},qn.uniqBy=function(e,t){return e&&e.length?fi(e,ca(t,2)):[]},qn.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?fi(e,n,t):[]},qn.unset=function(e,t){return null==e||di(e,t)},qn.unzip=ao,qn.unzipWith=oo,qn.update=function(e,t,n){return null==e?e:pi(e,t,bi(n))},qn.updateWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:pi(e,t,bi(r),i)},qn.values=zs,qn.valuesIn=function(e){return null==e?[]:Yt(e,Ms(e))},qn.without=so,qn.words=Zs,qn.wrap=function(e,t){return Fo(bi(t),e)},qn.xor=uo,qn.xorBy=co,qn.xorWith=lo,qn.zip=fo,qn.zipObject=function(e,t){return gi(e||[],t||[],nr)},qn.zipObjectDeep=function(e,t){return gi(e||[],t||[],ei)},qn.zipWith=po,qn.entries=Bs,qn.entriesIn=qs,qn.extend=_s,qn.extendWith=xs,cu(qn,qn),qn.add=bu,qn.attempt=eu,qn.camelCase=Ws,qn.capitalize=Ks,qn.ceil=wu,qn.clamp=function(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=(r=ms(r))==r?r:0),t!==n&&(t=(t=ms(t))==t?t:0),ur(ms(e),t,r)},qn.clone=function(e){return cr(e,4)},qn.cloneDeep=function(e){return cr(e,5)},qn.cloneDeepWith=function(e,t){return cr(e,5,t="function"==typeof t?t:n)},qn.cloneWith=function(e,t){return cr(e,4,t="function"==typeof t?t:n)},qn.conformsTo=function(e,t){return null==t||lr(e,t,js(t))},qn.deburr=Vs,qn.defaultTo=function(e,t){return null==e||e!=e?t:e},qn.divide=ku,qn.endsWith=function(e,t,r){e=ws(e),t=li(t);var i=e.length,a=r=r===n?i:ur(ys(r),0,i);return(r-=t.length)>=0&&e.slice(r,a)==t},qn.eq=zo,qn.escape=function(e){return(e=ws(e))&&H.test(e)?e.replace(G,nn):e},qn.escapeRegExp=function(e){return(e=ws(e))&&re.test(e)?e.replace(ne,"\\$&"):e},qn.every=function(e,t,r){var i=$o(e)?It:vr;return r&&wa(e,t,r)&&(t=n),i(e,ca(t,3))},qn.find=mo,qn.findIndex=Ka,qn.findKey=function(e,t){return Nt(e,ca(t,3),kr)},qn.findLast=bo,qn.findLastIndex=Va,qn.findLastKey=function(e,t){return Nt(e,ca(t,3),_r)},qn.floor=_u,qn.forEach=wo,qn.forEachRight=ko,qn.forIn=function(e,t){return null==e?e:br(e,ca(t,3),Ms)},qn.forInRight=function(e,t){return null==e?e:wr(e,ca(t,3),Ms)},qn.forOwn=function(e,t){return e&&kr(e,ca(t,3))},qn.forOwnRight=function(e,t){return e&&_r(e,ca(t,3))},qn.get=Ts,qn.gt=Wo,qn.gte=Ko,qn.has=function(e,t){return null!=e&&ya(e,t,Tr)},qn.hasIn=Cs,qn.head=Ga,qn.identity=au,qn.includes=function(e,t,n,r){e=Jo(e)?e:zs(e),n=n&&!r?ys(n):0;var i=e.length;return n<0&&(n=bn(i+n,0)),cs(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Ft(e,t,n)>-1},qn.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:ys(n);return i<0&&(i=bn(r+i,0)),Ft(e,t,i)},qn.inRange=function(e,t,r){return t=vs(t),r===n?(r=t,t=0):r=vs(r),function(e,t,n){return e>=wn(t,n)&&e<bn(t,n)}(e=ms(e),t,r)},qn.invoke=As,qn.isArguments=Vo,qn.isArray=$o,qn.isArrayBuffer=Go,qn.isArrayLike=Jo,qn.isArrayLikeObject=Ho,qn.isBoolean=function(e){return!0===e||!1===e||rs(e)&&Rr(e)==m},qn.isBuffer=Yo,qn.isDate=Qo,qn.isElement=function(e){return rs(e)&&1===e.nodeType&&!os(e)},qn.isEmpty=function(e){if(null==e)return!0;if(Jo(e)&&($o(e)||"string"==typeof e||"function"==typeof e.splice||Yo(e)||fs(e)||Vo(e)))return!e.length;var t=va(e);if(t==x||t==T)return!e.size;if(Sa(e))return!Nr(e).length;for(var n in e)if(Le.call(e,n))return!1;return!0},qn.isEqual=function(e,t){return jr(e,t)},qn.isEqualWith=function(e,t,r){var i=(r="function"==typeof r?r:n)?r(e,t):n;return i===n?jr(e,t,n,r):!!i},qn.isError=Xo,qn.isFinite=function(e){return"number"==typeof e&&yn(e)},qn.isFunction=Zo,qn.isInteger=es,qn.isLength=ts,qn.isMap=is,qn.isMatch=function(e,t){return e===t||Mr(e,t,fa(t))},qn.isMatchWith=function(e,t,r){return r="function"==typeof r?r:n,Mr(e,t,fa(t),r)},qn.isNaN=function(e){return as(e)&&e!=+e},qn.isNative=function(e){if(xa(e))throw new xe("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Lr(e)},qn.isNil=function(e){return null==e},qn.isNull=function(e){return null===e},qn.isNumber=as,qn.isObject=ns,qn.isObjectLike=rs,qn.isPlainObject=os,qn.isRegExp=ss,qn.isSafeInteger=function(e){return es(e)&&e>=-9007199254740991&&e<=d},qn.isSet=us,qn.isString=cs,qn.isSymbol=ls,qn.isTypedArray=fs,qn.isUndefined=function(e){return e===n},qn.isWeakMap=function(e){return rs(e)&&va(e)==P},qn.isWeakSet=function(e){return rs(e)&&"[object WeakSet]"==Rr(e)},qn.join=function(e,t){return null==e?"":gn.call(e,t)},qn.kebabCase=$s,qn.last=Qa,qn.lastIndexOf=function(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var a=i;return r!==n&&(a=(a=ys(r))<0?bn(i+a,0):wn(a,i-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,a):Dt(e,qt,a,!0)},qn.lowerCase=Gs,qn.lowerFirst=Js,qn.lt=ds,qn.lte=ps,qn.max=function(e){return e&&e.length?yr(e,au,Ir):n},qn.maxBy=function(e,t){return e&&e.length?yr(e,ca(t,2),Ir):n},qn.mean=function(e){return zt(e,au)},qn.meanBy=function(e,t){return zt(e,ca(t,2))},qn.min=function(e){return e&&e.length?yr(e,au,Fr):n},qn.minBy=function(e,t){return e&&e.length?yr(e,ca(t,2),Fr):n},qn.stubArray=gu,qn.stubFalse=mu,qn.stubObject=function(){return{}},qn.stubString=function(){return""},qn.stubTrue=function(){return!0},qn.multiply=Su,qn.nth=function(e,t){return e&&e.length?Kr(e,ys(t)):n},qn.noConflict=function(){return ft._===this&&(ft._=Be),this},qn.noop=lu,qn.now=To,qn.pad=function(e,t,n){e=ws(e);var r=(t=ys(t))?fn(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Vi(yt(i),n)+e+Vi(vt(i),n)},qn.padEnd=function(e,t,n){e=ws(e);var r=(t=ys(t))?fn(e):0;return t&&r<t?e+Vi(t-r,n):e},qn.padStart=function(e,t,n){e=ws(e);var r=(t=ys(t))?fn(e):0;return t&&r<t?Vi(t-r,n)+e:e},qn.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),_n(ws(e).replace(ie,""),t||0)},qn.random=function(e,t,r){if(r&&"boolean"!=typeof r&&wa(e,t,r)&&(t=r=n),r===n&&("boolean"==typeof t?(r=t,t=n):"boolean"==typeof e&&(r=e,e=n)),e===n&&t===n?(e=0,t=1):(e=vs(e),t===n?(t=e,e=0):t=vs(t)),e>t){var i=e;e=t,t=i}if(r||e%1||t%1){var a=xn();return wn(e+a*(t-e+st("1e-"+((a+"").length-1))),t)}return Hr(e,t)},qn.reduce=function(e,t,n){var r=$o(e)?jt:Vt,i=arguments.length<3;return r(e,ca(t,4),n,i,pr)},qn.reduceRight=function(e,t,n){var r=$o(e)?Mt:Vt,i=arguments.length<3;return r(e,ca(t,4),n,i,hr)},qn.repeat=function(e,t,r){return t=(r?wa(e,t,r):t===n)?1:ys(t),Yr(ws(e),t)},qn.replace=function(){var e=arguments,t=ws(e[0]);return e.length<3?t:t.replace(e[1],e[2])},qn.result=function(e,t,r){var i=-1,a=(t=wi(t,e)).length;for(a||(a=1,e=n);++i<a;){var o=null==e?n:e[Da(t[i])];o===n&&(i=a,o=r),e=Zo(o)?o.call(e):o}return e},qn.round=Eu,qn.runInContext=e,qn.sample=function(e){return($o(e)?Xn:Xr)(e)},qn.size=function(e){if(null==e)return 0;if(Jo(e))return cs(e)?fn(e):e.length;var t=va(e);return t==x||t==T?e.size:Nr(e).length},qn.snakeCase=Hs,qn.some=function(e,t,r){var i=$o(e)?Lt:ai;return r&&wa(e,t,r)&&(t=n),i(e,ca(t,3))},qn.sortedIndex=function(e,t){return oi(e,t)},qn.sortedIndexBy=function(e,t,n){return si(e,t,ca(n,2))},qn.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=oi(e,t);if(r<n&&zo(e[r],t))return r}return-1},qn.sortedLastIndex=function(e,t){return oi(e,t,!0)},qn.sortedLastIndexBy=function(e,t,n){return si(e,t,ca(n,2),!0)},qn.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var n=oi(e,t,!0)-1;if(zo(e[n],t))return n}return-1},qn.startCase=Ys,qn.startsWith=function(e,t,n){return e=ws(e),n=null==n?0:ur(ys(n),0,e.length),t=li(t),e.slice(n,n+t.length)==t},qn.subtract=Ru,qn.sum=function(e){return e&&e.length?$t(e,au):0},qn.sumBy=function(e,t){return e&&e.length?$t(e,ca(t,2)):0},qn.template=function(e,t,r){var i=qn.templateSettings;r&&wa(e,t,r)&&(t=n),e=ws(e),t=xs({},t,i,Zi);var a,o,s=xs({},t.imports,i.imports,Zi),u=js(s),c=Yt(s,u),l=0,f=t.interpolate||we,d="__p += '",p=Ie((t.escape||we).source+"|"+f.source+"|"+(f===X?de:we).source+"|"+(t.evaluate||we).source+"|$","g"),h="//# sourceURL="+(Le.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rt+"]")+"\n";e.replace(p,(function(t,n,r,i,s,u){return r||(r=i),d+=e.slice(l,u).replace(ke,rn),n&&(a=!0,d+="' +\n__e("+n+") +\n'"),s&&(o=!0,d+="';\n"+s+";\n__p += '"),r&&(d+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),l=u+t.length,t})),d+="';\n";var v=Le.call(t,"variable")&&t.variable;if(v){if(le.test(v))throw new xe("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(o?d.replace(W,""):d).replace(K,"$1").replace(V,"$1;"),d="function("+(v||"obj")+") {\n"+(v?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var y=eu((function(){return Se(u,h+"return "+d).apply(n,c)}));if(y.source=d,Xo(y))throw y;return y},qn.times=function(e,t){if((e=ys(e))<1||e>d)return[];var n=h,r=wn(e,h);t=ca(t),e-=h;for(var i=Gt(r,t);++n<e;)t(n);return i},qn.toFinite=vs,qn.toInteger=ys,qn.toLength=gs,qn.toLower=function(e){return ws(e).toLowerCase()},qn.toNumber=ms,qn.toSafeInteger=function(e){return e?ur(ys(e),-9007199254740991,d):0===e?e:0},qn.toString=ws,qn.toUpper=function(e){return ws(e).toUpperCase()},qn.trim=function(e,t,r){if((e=ws(e))&&(r||t===n))return Jt(e);if(!e||!(t=li(t)))return e;var i=dn(e),a=dn(t);return _i(i,Xt(i,a),Zt(i,a)+1).join("")},qn.trimEnd=function(e,t,r){if((e=ws(e))&&(r||t===n))return e.slice(0,pn(e)+1);if(!e||!(t=li(t)))return e;var i=dn(e);return _i(i,0,Zt(i,dn(t))+1).join("")},qn.trimStart=function(e,t,r){if((e=ws(e))&&(r||t===n))return e.replace(ie,"");if(!e||!(t=li(t)))return e;var i=dn(e);return _i(i,Xt(i,dn(t))).join("")},qn.truncate=function(e,t){var r=30,i="...";if(ns(t)){var a="separator"in t?t.separator:a;r="length"in t?ys(t.length):r,i="omission"in t?li(t.omission):i}var o=(e=ws(e)).length;if(an(e)){var s=dn(e);o=s.length}if(r>=o)return e;var u=r-fn(i);if(u<1)return i;var c=s?_i(s,0,u).join(""):e.slice(0,u);if(a===n)return c+i;if(s&&(u+=c.length-u),ss(a)){if(e.slice(u).search(a)){var l,f=c;for(a.global||(a=Ie(a.source,ws(pe.exec(a))+"g")),a.lastIndex=0;l=a.exec(f);)var d=l.index;c=c.slice(0,d===n?u:d)}}else if(e.indexOf(li(a),u)!=u){var p=c.lastIndexOf(a);p>-1&&(c=c.slice(0,p))}return c+i},qn.unescape=function(e){return(e=ws(e))&&J.test(e)?e.replace($,hn):e},qn.uniqueId=function(e){var t=++Ue;return ws(e)+t},qn.upperCase=Qs,qn.upperFirst=Xs,qn.each=wo,qn.eachRight=ko,qn.first=Ga,cu(qn,(xu={},kr(qn,(function(e,t){Le.call(qn.prototype,t)||(xu[t]=e)})),xu),{chain:!1}),qn.VERSION="4.17.21",Et(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){qn[e].placeholder=qn})),Et(["drop","take"],(function(e,t){Vn.prototype[e]=function(r){r=r===n?1:bn(ys(r),0);var i=this.__filtered__&&!t?new Vn(this):this.clone();return i.__filtered__?i.__takeCount__=wn(r,i.__takeCount__):i.__views__.push({size:wn(r,h),type:e+(i.__dir__<0?"Right":"")}),i},Vn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Et(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;Vn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:ca(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),Et(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Vn.prototype[e]=function(){return this[n](1).value()[0]}})),Et(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Vn.prototype[e]=function(){return this.__filtered__?new Vn(this):this[n](1)}})),Vn.prototype.compact=function(){return this.filter(au)},Vn.prototype.find=function(e){return this.filter(e).head()},Vn.prototype.findLast=function(e){return this.reverse().find(e)},Vn.prototype.invokeMap=Qr((function(e,t){return"function"==typeof e?new Vn(this):this.map((function(n){return Pr(n,e,t)}))})),Vn.prototype.reject=function(e){return this.filter(No(ca(e)))},Vn.prototype.slice=function(e,t){e=ys(e);var r=this;return r.__filtered__&&(e>0||t<0)?new Vn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(r=(t=ys(t))<0?r.dropRight(-t):r.take(t-e)),r)},Vn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Vn.prototype.toArray=function(){return this.take(h)},kr(Vn.prototype,(function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),a=qn[i?"take"+("last"==t?"Right":""):t],o=i||/^find/.test(t);a&&(qn.prototype[t]=function(){var t=this.__wrapped__,s=i?[1]:arguments,u=t instanceof Vn,c=s[0],l=u||$o(t),f=function(e){var t=a.apply(qn,At([e],s));return i&&d?t[0]:t};l&&r&&"function"==typeof c&&1!=c.length&&(u=l=!1);var d=this.__chain__,p=!!this.__actions__.length,h=o&&!d,v=u&&!p;if(!o&&l){t=v?t:new Vn(this);var y=e.apply(t,s);return y.__actions__.push({func:vo,args:[f],thisArg:n}),new Kn(y,d)}return h&&v?e.apply(this,s):(y=this.thru(f),h?i?y.value()[0]:y.value():y)})})),Et(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Oe[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);qn.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply($o(i)?i:[],e)}return this[n]((function(n){return t.apply($o(n)?n:[],e)}))}})),kr(Vn.prototype,(function(e,t){var n=qn[t];if(n){var r=n.name+"";Le.call(An,r)||(An[r]=[]),An[r].push({name:t,func:n})}})),An[qi(n,2).name]=[{name:"wrapper",func:n}],Vn.prototype.clone=function(){var e=new Vn(this.__wrapped__);return e.__actions__=Oi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Oi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Oi(this.__views__),e},Vn.prototype.reverse=function(){if(this.__filtered__){var e=new Vn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Vn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=$o(e),r=t<0,i=n?e.length:0,a=function(e,t,n){var r=-1,i=n.length;for(;++r<i;){var a=n[r],o=a.size;switch(a.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=wn(t,e+o);break;case"takeRight":e=bn(e,t-o)}}return{start:e,end:t}}(0,i,this.__views__),o=a.start,s=a.end,u=s-o,c=r?s:o-1,l=this.__iteratees__,f=l.length,d=0,p=wn(u,this.__takeCount__);if(!n||!r&&i==u&&p==u)return vi(e,this.__actions__);var h=[];e:for(;u--&&d<p;){for(var v=-1,y=e[c+=t];++v<f;){var g=l[v],m=g.iteratee,b=g.type,w=m(y);if(2==b)y=w;else if(!w){if(1==b)continue e;break e}}h[d++]=y}return h},qn.prototype.at=yo,qn.prototype.chain=function(){return ho(this)},qn.prototype.commit=function(){return new Kn(this.value(),this.__chain__)},qn.prototype.next=function(){this.__values__===n&&(this.__values__=hs(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},qn.prototype.plant=function(e){for(var t,r=this;r instanceof Wn;){var i=Ba(r);i.__index__=0,i.__values__=n,t?a.__wrapped__=i:t=i;var a=i;r=r.__wrapped__}return a.__wrapped__=e,t},qn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Vn){var t=e;return this.__actions__.length&&(t=new Vn(this)),(t=t.reverse()).__actions__.push({func:vo,args:[to],thisArg:n}),new Kn(t,this.__chain__)}return this.thru(to)},qn.prototype.toJSON=qn.prototype.valueOf=qn.prototype.value=function(){return vi(this.__wrapped__,this.__actions__)},qn.prototype.first=qn.prototype.head,et&&(qn.prototype[et]=function(){return this}),qn}();pt?((pt.exports=vn)._=vn,dt._=vn):ft._=vn}).call(FT)}(BT,BT.exports);var $T=function(e){TI.default(m,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g=VT(m);function m(e,t,n){var r;EI.default(this,m);return(r=g.call(this,e,n)).updateMergingQueue=new xT((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new DT,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return RI.default(m,[{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:(y=SI.default(AI.default.mark((function e(t,n,r,i){var a,o;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a={data:n},void 0!==i&&(a.ttl=i),e.next=4,this.services.network.post(t,a,r);case 4:return(o=e.sent).body.data=n,o.body.date_updated=new Date(o.body.date_updated),e.abrupt("return",o.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r){return y.apply(this,arguments)})},{key:"push",value:(v=SI.default(AI.default.mark((function e(t,n){var r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(n||{}).ttl,e.next=3,this._addOrUpdateItemOnServer(this.links.items,t,void 0,r);case 3:return i=e.sent,a=Number(i.index),this._handleItemMutated(a,i.url,i.last_event_id,i.revision,t,i.date_updated,i.date_expires,!0,!1),e.abrupt("return",this.cache.getValue(a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"set",value:(h=SI.default(AI.default.mark((function e(t,n,r){var i,a=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,(function(e){return a._updateItemUnconditionally(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return h.apply(this,arguments)})},{key:"_updateItemUnconditionally",value:(p=SI.default(AI.default.mark((function e(t,n,r){var i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return i=e.sent,e.next=5,this._addOrUpdateItemOnServer(i.url,n,void 0,r);case 5:return a=e.sent,this._handleItemMutated(t,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,!1,!1),e.abrupt("return",this.cache.getValue(t));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return p.apply(this,arguments)})},{key:"_updateItemWithIfMatch",value:(d=SI.default(AI.default.mark((function e(t,n,r){var i,a,o,s;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:if(i=e.sent,!(a=n($I(i.data)))){e.next=25;break}return o=i.revision,e.prev=6,e.next=9,this._addOrUpdateItemOnServer(i.url,a,o,r);case 9:return s=e.sent,this._handleItemMutated(t,s.url,s.last_event_id,s.revision,s.data,s.date_updated,s.date_expires,!1,!1),e.abrupt("return",this.cache.getValue(t));case 14:if(e.prev=14,e.t0=e.catch(6),412!==e.t0.status){e.next=22;break}return e.next=19,this._getItemFromServer(t);case 19:return e.abrupt("return",this._updateItemWithIfMatch(t,n,r));case 22:throw e.t0;case 23:e.next=26;break;case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}}),e,this,[[6,14]])}))),function(e,t,n){return d.apply(this,arguments)})},{key:"mutate",value:(f=SI.default(AI.default.mark((function e(t,n,r){var i,a=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.add(t,i,(function(e){return a._updateItemWithIfMatch(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return f.apply(this,arguments)})},{key:"update",value:(l=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,(function(e){return Object.assign(e,n)}),r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"remove",value:(c=SI.default(AI.default.mark((function e(t){var n,r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=$I(n.data),e.next=6,this.services.network.delete(n.url);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"get",value:function(){var e=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))){e.next=3;break}return e.abrupt("return",n.value);case 3:return e.abrupt("return",this._getItemFromServer(t));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(u=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._queryItemsFromServer({index:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new SyncError("No item with index ".concat(t," found"),404,54151);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"queryItems",value:function(){var e=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g,m,b,w,k,_,x,S,E,R,I,T,C;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.index){e.next=5;break}if(!(l=this.cache.get(t.index))){e.next=4;break}return e.abrupt("return",this.makePaginator(l.isValid?[l.value]:[],t,!1,!1));case 4:return e.abrupt("return",this._querySingleItemFromServer(t.index));case 5:f=!!t.nextPageItemId||!!t.prevPageItemId,d=KT({},t),f&&(t.from=null!==(p=null!==(h=t.nextPageItemId)&&void 0!==h?h:t.prevPageItemId)&&void 0!==p?p:t.from),v=!!t.prevPageItemId,y="desc"===t.order?v?this.cache.getIterator(null!==(n=null!==(r=t.prevPageItemId)&&void 0!==r?r:t.from)&&void 0!==n?n:null):this.cache.getReverseIterator(null!==(i=null!==(a=t.nextPageItemId)&&void 0!==a?a:t.from)&&void 0!==i?i:null):v?this.cache.getReverseIterator(null!==(o=null!==(s=t.prevPageItemId)&&void 0!==s?s:t.from)&&void 0!==o?o:null):this.cache.getIterator(null!==(u=null!==(c=t.nextPageItemId)&&void 0!==c?c:t.from)&&void 0!==u?u:null),g=[],m=f?t.limit+1:t.limit,b=qT(y),e.prev=13,b.s();case 15:if((w=b.n()).done){e.next=25;break}if(k=w.value,!f||k.value.index!=t.from){e.next=19;break}return e.abrupt("continue",23);case 19:if(g.push(k.value),!(g.length>=t.limit)){e.next=23;break}return v&&BT.exports.reverse(g),e.abrupt("return",this.makePaginator(g,t,this._prevPageAllowed(g,t.order),this._nextPageAllowed(g,t.order)));case 23:e.next=15;break;case 25:e.next=30;break;case 27:e.prev=27,e.t0=e.catch(13),b.e(e.t0);case 30:return e.prev=30,b.f(),e.finish(30);case 33:if(g.length>0&&(t.from=BT.exports.last(g).index),_=Math.max(m-g.length,10),v&&(t.order="desc"===t.order?"asc":"desc"),!(t.from!==("desc"===d.order?v?this.cache.collectionEnd:this.cache.collectionBegin:v?this.cache.collectionBegin:this.cache.collectionEnd))){e.next=66;break}return e.next=40,this._queryItemsFromServer(KT(KT({},t),{},{limit:_}));case 40:x=e.sent,S=x.items,"desc"===d.order?(E=!x.hasNextPage,R=!x.hasPrevPage):(E=!x.hasPrevPage,R=!x.hasNextPage),this.cache.populate(S,E,R),I=qT(S),e.prev=45,I.s();case 47:if((T=I.n()).done){e.next=56;break}if(C=T.value,!(g.length>0||f)||C.index!=t.from){e.next=51;break}return e.abrupt("continue",54);case 51:if(v?g.unshift(C):g.push(C),!(g.length>=t.limit)){e.next=54;break}return e.abrupt("break",56);case 54:e.next=47;break;case 56:e.next=61;break;case 58:e.prev=58,e.t1=e.catch(45),I.e(e.t1);case 61:return e.prev=61,I.f(),e.finish(61);case 64:e.next=67;break;case 66:v&&BT.exports.reverse(g);case 67:return e.abrupt("return",this.makePaginator(g,d,this._prevPageAllowed(g,d.order),this._nextPageAllowed(g,d.order)));case 68:case"end":return e.stop()}}),e,this,[[13,27,30,33],[45,58,61,64]])})));return function(t){return e.apply(this,arguments)}}()},{key:"_prevPageAllowed",value:function(e,t){return e.length>0&&BT.exports.head(e).index!==("desc"===t?this.cache.collectionEnd:this.cache.collectionBegin)}},{key:"_nextPageAllowed",value:function(e,t){return e.length>0&&BT.exports.last(e).index!==("desc"===t?this.cache.collectionBegin:this.cache.collectionEnd)}},{key:"makePaginator",value:function(e,t,n,r){var i=this;t.nextPageItemId=t.prevPageItemId=null;var a=n&&this._prevPageAllowed(e,t.order),o=r&&this._nextPageAllowed(e,t.order);return new Paginator(e,(function(e){return i.queryItems(KT(KT({},t),e))}),a?BT.exports.head(e).index:null,o?BT.exports.last(e).index:null)}},{key:"_querySingleItemFromServer",value:(s=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._queryItemsFromServer({index:t});case 2:return 0===(n=e.sent).items.length&&this.cache.exists(t)&&this.cache.delete(t,null),e.abrupt("return",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"_queryItemsFromServer",value:(o=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s,u=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new WI(this.links.items).queryParam("HideExpired",!0).queryParam("Index",t.index).queryParam("PageToken",t.pageToken).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Order",t.order).build(),e.next=3,this.services.network.get(i);case 3:return a=e.sent,o=(null!==(n=null===(r=a.body)||void 0===r?void 0:r.items)&&void 0!==n?n:[]).map((function(e){e.date_updated=new Date(e.date_updated);var t=u.cache.get(e.index);if(t&&t.value)u._handleItemMutated(e.index,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0);else{var n=new CT({index:e.index,url:e.url,lastEventId:e.last_event_id,revision:e.revision,data:e.data,dateUpdated:e.date_updated,dateExpires:e.date_expires});u.cache.store(e.index,n,e.last_event_id)}return u.cache.getValue(e.index)})),s=a.body.meta,e.abrupt("return",this.makePaginator(o,t,!!s.previous_token,!!s.next_token));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getItems",value:(a=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GI((t=t||{}).pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getContext",value:(i=SI.default(AI.default.mark((function e(){var t;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.context){e.next=5;break}return e.next=3,this.services.network.get(this.links.context);case 3:t=e.sent,this._updateContextIfRequired(t.body.data,t.body.last_event_id);case 5:return e.abrupt("return",this.context);case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setTtl",value:(r=SI.default(AI.default.mark((function e(t){var n,r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=SI.default(AI.default.mark((function e(t,n){var r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return r=e.sent,i={ttl:n},e.next=6,this.services.network.post(r.url,i);case 6:a=e.sent,r.updateDateExpires(a.body.date_expires);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeList",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){var n=Number(e.item_index);switch(e.date_created=new Date(e.date_created),e.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(n,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,e.date_expires,"list_item_added"===e.type,!0);break;case"list_item_removed":this._handleItemRemoved(n,e.id,e.item_data,e.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(e.context_data,e.id,e.date_created);break;case"list_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.list_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,a,o,s,u){if(this.shouldIgnoreEvent(e,n))XI("Item ".concat(e," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(n));else{this._updateRootDateUpdated(a);var c=this.cache.getValue(e);if(!c){var l=new CT({index:e,url:t,lastEventId:n,revision:r,data:i,dateUpdated:a,dateExpires:o});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,s)}var f=$I(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==o&&c.updateDateExpires(o),this.emitItemMutationEvent(c,u,!1,f)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",a={item:e,isLocal:!t};n||(a.previousItemData=r),this.broadcastEventToListeners(i,a)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{index:e,isLocal:!i,previousItemData:n})}},{key:"_handleContextUpdate",value:function(e,t,n){this._updateRootDateUpdated(n),this._updateContextIfRequired(e,t)&&this.broadcastEventToListeners("contextUpdated",{context:e,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(e,t){return!this.contextEventId||t>this.contextEventId?(this.context=e,this.contextEventId=t,!0):(XI("Context update skipped, current:",this.lastEventId,", remote:",t),!1)}}],[{key:"type",get:function(){return"list"}}]),m}(kT),GT=function(e){TI.default(p,e);var t,n,r,i,a,o,s,u,c,l,f,d=VT(p);function p(e){var t;return EI.default(this,p),(t=d.call(this)).syncListImpl=e,t.syncListImpl.attach(II.default(t)),t}return RI.default(p,[{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 $T.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:(f=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.push(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return f.apply(this,arguments)})},{key:"set",value:(l=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.set(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"mutate",value:(c=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.mutate(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"update",value:(u=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.update(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"remove",value:(s=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.remove(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"get",value:(o=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.get(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getContext",value:(a=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getItems",value:(i=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getItems(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setTtl",value:(r=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeList",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){DI.default(OI.default(p.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return $T.type}}]),p}(ET);PI.default(GT,"itemAdded","itemAdded"),PI.default(GT,"itemUpdated","itemUpdated"),PI.default(GT,"itemRemoved","itemRemoved"),PI.default(GT,"removed","removed"),qI([fI.validateTypesAsync(fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object,Object]),zI("design:returntype",Promise)],GT.prototype,"push",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger,fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Number,Object,Object]),zI("design:returntype",Promise)],GT.prototype,"set",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger,"function",["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Number,Function,Object]),zI("design:returntype",Promise)],GT.prototype,"mutate",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger,fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Number,Object,Object]),zI("design:returntype",Promise)],GT.prototype,"update",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],GT.prototype,"remove",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],GT.prototype,"get",null),qI([fI.validateTypesAsync(["undefined",fI.objectSchema("query options",{from:[fI.nonNegativeInteger,"undefined"],pageSize:[fI.custom((function(e){return[JI(e),"a positive integer"]})),"undefined"],order:[fI.custom((function(e){return["asc"===e||"desc"===e,"either 'asc' or 'desc'"]})),"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],GT.prototype,"getItems",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],GT.prototype,"setTtl",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger,fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number,Number]),zI("design:returntype",Promise)],GT.prototype,"setItemTtl",null);var JT=function(){function e(t){EI.default(this,e),this.descriptor=t}return RI.default(e,[{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:"cacheKey",get:function(){return this.key}},{key:"update",value:function(e,t,n,r){return this.descriptor.last_event_id=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.date_updated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.date_expires=e}}]),e}();function HT(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return YT(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return YT(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function YT(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function QT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function XT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?QT(Object(n),!0).forEach((function(t){PI.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QT(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ZT(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var eC=function(e){TI.default(y,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v=ZT(y);function y(e,t,n){var r;EI.default(this,y);return(r=v.call(this,e,n)).updateMergingQueue=new xT((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new DT,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),t.items&&t.items.forEach((function(e){e.date_updated=new Date(e.date_updated),r.cache.store(e.key,new JT(e),e.last_event_id)})),r}return RI.default(y,[{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:(h=SI.default(AI.default.mark((function e(t,n,r){var i,a=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,(function(e){return a._putItemUnconditionally(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return h.apply(this,arguments)})},{key:"get",value:function(){var e=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new SyncError("SyncMapItem key may not be empty",400,54209);case 2:if(!this.cache.has(t)){e.next=6;break}return e.abrupt("return",this.cache.getValue(t));case 6:return e.abrupt("return",this._getItemFromServer(t));case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(p=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._queryItemsFromServer({key:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new SyncError("The specified Map Item does not exist",404,54201);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"mutate",value:(d=SI.default(AI.default.mark((function e(t,n,r){var i,a=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},e.abrupt("return",this.updateMergingQueue.add(t,i,(function(e){return a._putItemWithIfMatch(t,n,e.ttl)})));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return d.apply(this,arguments)})},{key:"update",value:(f=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,(function(e){return Object.assign(e,n)}),r));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return f.apply(this,arguments)})},{key:"_putItemUnconditionally",value:(l=SI.default(AI.default.mark((function e(t,n,r){var i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._putItemToServer(t,n,void 0,r);case 2:return i=e.sent,a=i.item,this._handleItemMutated(a.key,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,i.added,!1),e.abrupt("return",this.cache.getValue(a.key));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"_putItemWithIfMatch",value:(c=SI.default(AI.default.mark((function e(t,n,r){var i,a,o,s,u;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t).catch((function(e){if(404===e.status)return new JT({key:t,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw e}));case 2:if(i=e.sent,!(a=n($I(i.data)))){e.next=26;break}return o=i.revision,e.prev=6,e.next=9,this._putItemToServer(t,a,o,r);case 9:return s=e.sent,u=s.item,this._handleItemMutated(u.key,u.url,u.last_event_id,u.revision,u.data,u.date_updated,u.date_expires,s.added,!1),e.abrupt("return",this.cache.getValue(u.key));case 15:if(e.prev=15,e.t0=e.catch(6),412!==e.t0.status){e.next=23;break}return e.next=20,this._getItemFromServer(t);case 20:return e.abrupt("return",this._putItemWithIfMatch(t,n,r));case 23:throw e.t0;case 24:e.next=27;break;case 26:return e.abrupt("return",i);case 27:case"end":return e.stop()}}),e,this,[[6,15]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"_putItemToServer",value:(u=SI.default(AI.default.mark((function e(t,n,r,i){var a,o,s,u,c;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new WI(this.links.items).pathSegment(t).build(),o={data:n},void 0!==i&&(o.ttl=i),e.prev=3,e.next=6,this.services.network.put(a,o,r);case 6:return s=e.sent,(u=s.body).data=n,u.date_updated=new Date(u.date_updated),c=201===s.status.code,e.abrupt("return",{added:c,item:u});case 14:throw e.prev=14,e.t0=e.catch(3),404===e.t0.status&&this.onRemoved(!1),e.t0;case 18:case"end":return e.stop()}}),e,this,[[3,14]])}))),function(e,t,n,r){return u.apply(this,arguments)})},{key:"remove",value:(s=SI.default(AI.default.mark((function e(t){var n,r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=$I(n.data),e.next=6,this.services.network.delete(n.uri);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"queryItems",value:function(){var e=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g,m,b,w,k,_,x,S,E,R,I,T,C;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.key){e.next=5;break}if(!(l=this.cache.get(t.key))){e.next=4;break}return e.abrupt("return",this.makePaginator(l.isValid?[l.value]:[],t,!1,!1));case 4:return e.abrupt("return",this._querySingleItemFromServer(t.key));case 5:f=!!t.nextPageItemId||!!t.prevPageItemId,d=XT({},t),f&&(t.from=null!==(p=null!==(h=t.nextPageItemId)&&void 0!==h?h:t.prevPageItemId)&&void 0!==p?p:t.from),v=!!t.prevPageItemId,y="desc"===t.order?v?this.cache.getIterator(null!==(n=null!==(r=t.prevPageItemId)&&void 0!==r?r:t.from)&&void 0!==n?n:null):this.cache.getReverseIterator(null!==(i=null!==(a=t.nextPageItemId)&&void 0!==a?a:t.from)&&void 0!==i?i:null):v?this.cache.getReverseIterator(null!==(o=null!==(s=t.prevPageItemId)&&void 0!==s?s:t.from)&&void 0!==o?o:null):this.cache.getIterator(null!==(u=null!==(c=t.nextPageItemId)&&void 0!==c?c:t.from)&&void 0!==u?u:null),g=[],m=f?t.limit+1:t.limit,b=HT(y),e.prev=13,b.s();case 15:if((w=b.n()).done){e.next=25;break}if(k=w.value,!f||k.value.key!=t.from){e.next=19;break}return e.abrupt("continue",23);case 19:if(g.push(k.value),!(g.length>=t.limit)){e.next=23;break}return v&&BT.exports.reverse(g),e.abrupt("return",this.makePaginator(g,t,this._prevPageAllowed(g,t.order),this._nextPageAllowed(g,t.order)));case 23:e.next=15;break;case 25:e.next=30;break;case 27:e.prev=27,e.t0=e.catch(13),b.e(e.t0);case 30:return e.prev=30,b.f(),e.finish(30);case 33:if(g.length>0&&(t.from=BT.exports.last(g).key),_=Math.max(m-g.length,10),v&&(t.order="desc"===t.order?"asc":"desc"),!(t.from!==("desc"===d.order?v?this.cache.collectionEnd:this.cache.collectionBegin:v?this.cache.collectionBegin:this.cache.collectionEnd))){e.next=66;break}return e.next=40,this._queryItemsFromServer(XT(XT({},t),{},{limit:_}));case 40:x=e.sent,S=x.items,"desc"===d.order?(E=!x.hasNextPage,R=!x.hasPrevPage):(E=!x.hasPrevPage,R=!x.hasNextPage),this.cache.populate(S,E,R),I=HT(S),e.prev=45,I.s();case 47:if((T=I.n()).done){e.next=56;break}if(C=T.value,!(g.length>0||f)||C.key!=t.from){e.next=51;break}return e.abrupt("continue",54);case 51:if(v?g.unshift(C):g.push(C),!(g.length>=t.limit)){e.next=54;break}return e.abrupt("break",56);case 54:e.next=47;break;case 56:e.next=61;break;case 58:e.prev=58,e.t1=e.catch(45),I.e(e.t1);case 61:return e.prev=61,I.f(),e.finish(61);case 64:e.next=67;break;case 66:v&&BT.exports.reverse(g);case 67:return e.abrupt("return",this.makePaginator(g,d,this._prevPageAllowed(g,d.order),this._nextPageAllowed(g,d.order)));case 68:case"end":return e.stop()}}),e,this,[[13,27,30,33],[45,58,61,64]])})));return function(t){return e.apply(this,arguments)}}()},{key:"_prevPageAllowed",value:function(e,t){return e.length>0&&BT.exports.head(e).key!==("desc"===t?this.cache.collectionEnd:this.cache.collectionBegin)}},{key:"_nextPageAllowed",value:function(e,t){return e.length>0&&BT.exports.last(e).key!==("desc"===t?this.cache.collectionBegin:this.cache.collectionEnd)}},{key:"makePaginator",value:function(e,t,n,r){var i=this;t.nextPageItemId=t.prevPageItemId=null;var a=n&&this._prevPageAllowed(e,t.order),o=r&&this._nextPageAllowed(e,t.order);return new Paginator(e,(function(e){return i.queryItems(XT(XT({},t),e))}),a?BT.exports.head(e).key:null,o?BT.exports.last(e).key:null)}},{key:"_querySingleItemFromServer",value:(o=SI.default(AI.default.mark((function e(t){var n;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._queryItemsFromServer({key:t});case 2:return 0===(n=e.sent).items.length&&this.cache.exists(t)&&this.cache.delete(t,null),e.abrupt("return",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_queryItemsFromServer",value:(a=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s,u=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new WI(this.links.items).queryParam("HideExpired",!0).queryParam("Key",t.key).queryParam("PageToken",t.pageToken).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Order",t.order).build(),e.next=3,this.services.network.get(i);case 3:return a=e.sent,o=(null!==(n=null===(r=a.body)||void 0===r?void 0:r.items)&&void 0!==n?n:[]).map((function(e){e.date_updated=new Date(e.date_updated);var t=u.cache.get(e.key);if(t&&t.value)u._handleItemMutated(e.key,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0);else{var n=new JT({key:e.key,url:e.url,last_event_id:e.last_event_id,revision:e.revision,data:e.data,date_updated:e.date_updated,date_expires:e.date_expires});u.cache.store(e.key,n,e.last_event_id)}return u.cache.getValue(e.key)})),s=a.body.meta,e.abrupt("return",this.makePaginator(o,t,!!s.previous_token,!!s.next_token));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getItems",value:(i=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GI((t=t||{}).pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){switch(e.date_created=new Date(e.date_created),e.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(e.item_key,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,e.date_expires,"map_item_added"===e.type,!0);break;case"map_item_removed":this._handleItemRemoved(e.item_key,e.id,e.item_data,e.date_created,!0);break;case"map_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.map_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,a,o,s,u){if(this.shouldIgnoreEvent(e,n))XI("SyncMapItem ",e," update skipped, current:",this.lastEventId,", remote:",n);else{this._updateRootDateUpdated(a);var c=this.cache.getValue(e);if(!c){var l=new JT({key:e,url:t,last_event_id:n,revision:r,data:i,date_updated:a,date_expires:o});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,s)}var f=$I(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==o&&c.updateDateExpires(o),this.emitItemMutationEvent(c,u,!1,f)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",a={item:e,isLocal:!t};n||(a.previousItemData=r),this.broadcastEventToListeners(i,a)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{key:e,isLocal:!i,previousItemData:n})}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"setTtl",value:(r=SI.default(AI.default.mark((function e(t){var n,r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=SI.default(AI.default.mark((function e(t,n){var r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return r=e.sent,i={ttl:n},e.next=6,this.services.network.post(r.uri,i);case 6:a=e.sent,r.updateDateExpires(a.body.date_expires);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeMap",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}],[{key:"type",get:function(){return"map"}}]),y}(kT),tC=function(e){TI.default(f,e);var t,n,r,i,a,o,s,u,c,l=ZT(f);function f(e){var t;return EI.default(this,f),(t=l.call(this)).syncMapImpl=e,t.syncMapImpl.attach(II.default(t)),t}return RI.default(f,[{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 eC.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:(c=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.set(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return c.apply(this,arguments)})},{key:"get",value:(u=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.get(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"mutate",value:(s=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.mutate(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return s.apply(this,arguments)})},{key:"update",value:(o=SI.default(AI.default.mark((function e(t,n,r){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.update(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return o.apply(this,arguments)})},{key:"remove",value:(a=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.remove(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getItems",value:(i=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.getItems(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setTtl",value:(r=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setItemTtl",value:(n=SI.default(AI.default.mark((function e(t,n){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"removeMap",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.next=3,this.syncMapImpl.removeMap();case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){DI.default(OI.default(f.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return eC.type}}]),f}(ET);function nC(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}PI.default(tC,"itemAdded","itemAdded"),PI.default(tC,"itemUpdated","itemUpdated"),PI.default(tC,"itemRemoved","itemRemoved"),PI.default(tC,"removed","removed"),qI([fI.validateTypesAsync("string",fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[String,Object,Object]),zI("design:returntype",Promise)],tC.prototype,"set",null),qI([fI.validateTypesAsync("string"),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],tC.prototype,"get",null),qI([fI.validateTypesAsync("string","function",["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[String,Function,Object]),zI("design:returntype",Promise)],tC.prototype,"mutate",null),qI([fI.validateTypesAsync("string",fI.pureObject,["undefined",fI.objectSchema("item metadata",{ttl:[fI.nonNegativeInteger,"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[String,Object,Object]),zI("design:returntype",Promise)],tC.prototype,"update",null),qI([fI.validateTypesAsync("string"),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],tC.prototype,"remove",null),qI([fI.validateTypesAsync(["undefined",fI.objectSchema("query options",{from:["string","undefined"],pageSize:[fI.custom((function(e){return[JI(e),"a positive integer"]})),"undefined"],order:[fI.custom((function(e){return["asc"===e||"desc"===e,"either 'asc' or 'desc'"]})),"undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],tC.prototype,"getItems",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],tC.prototype,"setTtl",null),qI([fI.validateTypesAsync("string",fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[String,Number]),zI("design:returntype",Promise)],tC.prototype,"setItemTtl",null);var rC=function(e){TI.default(a,e);var t,n,r,i=nC(a);function a(e,t,n){var r;return EI.default(this,a),(r=i.call(this,e,n)).descriptor=t,r}return RI.default(a,[{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:(r=SI.default(AI.default.mark((function e(t){var n,r,i,a;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={data:t},e.next=3,this.services.network.post(this.links.messages,n);case 3:return r=e.sent,i=r.body,a=this._handleMessagePublished(i.sid,t,!1),e.abrupt("return",a);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setTtl",value:(n=SI.default(AI.default.mark((function e(t){var n,r;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n={ttl:t},e.next=4,this.services.network.post(this.uri,n);case 4:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),404===e.t0.status&&this.onRemoved(!1),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return n.apply(this,arguments)})},{key:"removeStream",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_update",value:function(e){switch(e.type){case"stream_message_published":this._handleMessagePublished(e.message_sid,e.message_data,!0);break;case"stream_removed":this.onRemoved(!1)}}},{key:"_handleMessagePublished",value:function(e,t,n){var r={sid:e,data:t};return this.broadcastEventToListeners("messagePublished",{message:r,isLocal:!n}),r}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}}],[{key:"type",get:function(){return"stream"}}]),a}(kT);qI([fI.validateTypesAsync(fI.pureObject),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],rC.prototype,"publishMessage",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],rC.prototype,"setTtl",null);var iC=function(e){TI.default(a,e);var t,n,r,i=nC(a);function a(e){var t;return EI.default(this,a),(t=i.call(this)).syncStreamImpl=e,t.syncStreamImpl.attach(II.default(t)),t}return RI.default(a,[{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 rC.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:(r=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.publishMessage(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setTtl",value:(n=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.setTtl(t));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"removeStream",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"close",value:function(){DI.default(OI.default(a.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return rC.type}}]),a}(ET);PI.default(iC,"messagePublished","messagePublished"),PI.default(iC,"removed","removed"),qI([fI.validateTypesAsync(fI.pureObject),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],iC.prototype,"publishMessage",null),qI([fI.validateTypesAsync(fI.nonNegativeInteger),zI("design:type",Function),zI("design:paramtypes",[Number]),zI("design:returntype",Promise)],iC.prototype,"setTtl",null);var aC=RI.default((function e(t){EI.default(this,e),this.sdk="js",this.sdkVer=t,this.os=BI.os.family,this.osVer=BI.os.version,this.pl=BI.name,this.plVer=BI.version})),oC=function(){function e(){EI.default(this,e),this.names=new Map,this.entities=new Map}return RI.default(e,[{key:"store",value:function(e){var t=this.entities.get(e.sid);return t||(this.entities.set(e.sid,e),e.uniqueName&&this.names.set(e.type+"::"+e.uniqueName,e.sid),e)}},{key:"getResolved",value:function(e,t){var n=this.names.get(t+"::"+e);return n?this.entities.get(n):null}},{key:"get",value:function(e,t){return this.entities.get(e)||this.getResolved(e,t)||null}},{key:"remove",value:function(e){var t=this.entities.get(e);t&&(this.entities.delete(e),t.uniqueName&&this.names.delete(t.type+"::"+t.uniqueName))}}]),e}();function sC(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}var uC=function(){function e(t,n,r){EI.default(this,e),this.key=t,this.value=n,this.lastEventId=r}return RI.default(e,[{key:"cacheKey",get:function(){return this.key}}]),e}(),cC=function(e){TI.default(n,e);var t=sC(n);function n(e,r,i,a){var o;return EI.default(this,n),(o=t.call(this,r,i)).descriptor=e,o.cache=new DT,a&&a.forEach((function(e){var t=new uC(e.key,e.data,e.revision);o.cache.store(e.key,t,e.revision)})),o}return RI.default(n,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return n.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 e={};return this.cache.forEach((function(t,n){e[t]=n.value})),e}},{key:"_update",value:function(e,t){switch(e.type){case"live_query_item_updated":this.handleItemMutated(e.item_key,e.item_data,e.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(e.item_key,e.item_revision);break;case"live_query_updated":this.handleBatchUpdate(e.items)}t&&this._advanceLastEventId(e.last_event_id)}},{key:"handleItemMutated",value:function(e,t,n){if(this.shouldIgnoreEvent(e,n))XI("Item ".concat(e," update skipped, revision: ").concat(n));else{var r=new uC(e,t,n);this.cache.store(e,r,n),this.broadcastEventToListeners("itemUpdated",r)}}},{key:"handleItemRemoved",value:function(e,t){this.shouldIgnoreEvent(e,t)?XI("Item ".concat(e," delete skipped, revision: ").concat(t)):(this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{key:e}))}},{key:"handleBatchUpdate",value:function(e){var t=this,n={};for(var r in null!=e&&e.forEach((function(e){n[e.key]={data:e.data,revision:e.revision}})),this.cache.forEach((function(e,r){var i=n[e];null!=i?t.handleItemMutated(e,i.data,i.revision):t.handleItemRemoved(e,null),delete n[e]})),n)this.handleItemMutated(r,n[r].data,n[r].revision)}},{key:"shouldIgnoreEvent",value:function(e,t){return null!=e&&null!=t&&this.cache.isKnown(e,t)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e)}}],[{key:"type",get:function(){return"live_query"}}]),n}(kT);function lC(e){return fC.apply(this,arguments)}function fC(){return fC=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.network,r=t.queryString,i=t.uri,a=t.type,null!=r){e.next=3;break}throw new SyncError("Invalid query",400,54507);case 3:return o={query_string:r},a===dC.type&&(o.type=a),e.next=7,n.post(i,o,void 0,!0);case 7:return s=e.sent,e.abrupt("return",s.body);case 9:case"end":return e.stop()}}),e)}))),fC.apply(this,arguments)}var dC=function(e){TI.default(n,e);var t=sC(n);function n(e){var r;return EI.default(this,n),(r=t.call(this)).liveQueryImpl=e,r.liveQueryImpl.attach(II.default(r)),r}return RI.default(n,[{key:"type",get:function(){return cC.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){DI.default(OI.default(n.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 cC.type}}]),n}(ET);PI.default(dC,"itemUpdated","itemUpdated"),PI.default(dC,"itemRemoved","itemRemoved");var pC=function(e){TI.default(i,e);var t,n,r=sC(i);function i(e){var t;return EI.default(this,i),t=r.call(this),PI.default(II.default(t),"queryExpression",null),PI.default(II.default(t),"items",{}),Object.assign(II.default(t),e),t.updateIndexName(e.indexName),t}return RI.default(i,[{key:"type",get:function(){return i.type}},{key:"search",value:(n=SI.default(AI.default.mark((function e(t){var n,r=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.items={},e.prev=1,e.next=4,lC({network:this.network,uri:this.queryUri,queryString:t});case 4:n=e.sent,this.queryExpression=t,n.items&&n.items.forEach((function(e){r.items[e.key]=e.data})),this.emit("searchResult",this.getItems()),e.next=15;break;case 10:throw e.prev=10,e.t0=e.catch(1),tT("Error '".concat(e.t0.message,"' while executing query '").concat(t,"'")),this.queryExpression=null,e.t0;case 15:case"end":return e.stop()}}),e,this,[[1,10]])}))),function(e){return n.apply(this,arguments)})},{key:"subscribe",value:(t=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.queryExpression){e.next=2;break}return e.abrupt("return",Promise.reject(new SyncError("Invalid query",400,54507)));case 2:return e.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(e){this.indexName=e,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(e){return new WI(this.insightsUri).pathSegment(e).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),i}(bI.ReplayEventEmitter);PI.default(pC,"searchResult","searchResult"),qI([fI.validateTypesAsync("string"),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],pC.prototype,"search",null),qI([fI.validateTypes(fI.nonEmptyString),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",void 0)],pC.prototype,"updateIndexName",null);function hC(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=OI.default(e);if(t){var i=OI.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return CI.default(this,n)}}function vC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function yC(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vC(Object(n),!0).forEach((function(t){PI.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vC(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var gC="data_sync",mC="3.4.0";function bC(e){if(e){if("string"==typeof e)return{id:e,mode:"open_or_create"};var t=e.mode||(e.id?"open_or_create":"create_new");return yC(yC({},e),{},{mode:t})}return{mode:"create_new"}}var wC="com.twilio.rtd.cds.document",kC="com.twilio.rtd.cds.list",_C="com.twilio.rtd.cds.map",xC="twilio.sync.event",Client=function(e){TI.default(Client,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y=hC(Client);function Client(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(EI.default(this,Client),n=y.call(this),!e)throw new Error("Sync library needs a valid Twilio token to be passed");r.hasOwnProperty("logLevel")?QI(r.logLevel):QI("silent");var i=r.productId=r.productId||gC;r.clientMetadata=r.clientMetadata||{},r.clientMetadata.hasOwnProperty("type")||(r.clientMetadata.type="sync"),r.clientMetadata.hasOwnProperty("sdk")||(r.clientMetadata.sdk="JS",r.clientMetadata.sdkv=mC);var a=!r.twilsockClient;if(!r.initRegistrations){var o=new dI.InitRegistration(i);Client.populateInitRegistrations(o),r.initRegistrations=[o]}var s=r.twilsockClient=null!==(t=r.twilsockClient)&&void 0!==t?t:new dI.Twilsock(e,i,r);s.on("tokenAboutToExpire",(function(){return n.emit("tokenAboutToExpire")})),s.on("tokenExpired",(function(){return n.emit("tokenExpired")})),s.on("connectionError",(function(e){return n.emit("connectionError",e)})),s.on("stateChanged",(function(e){n.emit("connectionStateChanged",e),n.services.subscriptions.onConnectionStateChanged("connected"===e)})),s.on("message",(function(e,t){return n._routeMessage(e,t)}));var u=new cT(r),c=new gT(new aC(mC),u,s),l=new mT(u);return n.services={config:u,twilsock:s,network:c,storage:l,router:II.default(n),subscriptions:null},n.services.subscriptions=new pT(n.services),n.entities=new oC,a&&s.connect(),n}return RI.default(Client,[{key:"_routeMessage",value:function(e,t){switch(XI("Notification type:",e,"content:",t),e){case wC:case kC:case _C:this.services.subscriptions.acceptMessage(t,!1);break;case xC:this.services.subscriptions.acceptMessage(t,!0)}}},{key:"_subscribe",value:function(e,t){this.services.subscriptions.add(e,t)}},{key:"_unsubscribe",value:function(e){this.services.subscriptions.remove(e)}},{key:"connectionState",get:function(){return this.services.twilsock.state}},{key:"ensureReady",value:(v=SI.default(AI.default.mark((function e(){var t;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.services.config.sessionStorageEnabled){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.services.twilsock.storageId();case 5:t=e.sent,this.services.storage.updateStorageId(t.id),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),eT("Failed to initialize storage",e.t0);case 12:case"end":return e.stop()}}),e,this,[[2,9]])}))),function(){return v.apply(this,arguments)})},{key:"storeRootInSessionCache",value:function(e,t,n){if(this.services.config.sessionStorageEnabled&&t){var r=$I(n);e!==GT.type&&e!==tC.type||(r.last_event_id=null,delete r.items),this.services.storage.store(e,t,r)}}},{key:"readRootFromSessionCache",value:function(e,t){return this.services.config.sessionStorageEnabled&&t?this.services.storage.read(e,t):null}},{key:"_get",value:(h=SI.default(AI.default.mark((function e(t,n){var r,i,a,o=arguments;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=o.length>2&&void 0!==o[2]&&o[2],n){e.next=3;break}throw new SyncError("Cannot get entity without id",404);case 3:return i=new WI(t).pathSegment(n).queryParam("Include",r?"items":void 0).build(),e.next=6,this.services.network.get(i);case 6:return a=e.sent,e.abrupt("return",a.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"_createDocument",value:function(e,t,n){var r={unique_name:e,data:t||{}};return void 0!==n&&(r.ttl=n),this.services.network.post(this.services.config.documentsUri,r).then((function(e){return e.body.data=r.data,e.body}))}},{key:"_getDocument",value:(p=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(TT.type,t)||this._get(this.services.config.documentsUri,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"_createList",value:function(e,t,n,r){var i={unique_name:e,purpose:t,context:n};return void 0!==r&&(i.ttl=r),this.services.network.post(this.services.config.listsUri,i).then((function(e){return e.body}))}},{key:"_getList",value:(d=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(GT.type,t)||this._get(this.services.config.listsUri,t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"_createMap",value:function(e,t){var n={unique_name:e};return void 0!==t&&(n.ttl=t),this.services.network.post(this.services.config.mapsUri,n).then((function(e){return e.body}))}},{key:"_getMap",value:(f=SI.default(AI.default.mark((function e(t){var n,r=arguments;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.length>1&&void 0!==r[1]&&r[1],e.abrupt("return",this.readRootFromSessionCache(tC.type,t)||this._get(this.services.config.mapsUri,t,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"_getStream",value:(l=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(iC.type,t)||this._get(this.services.config.streamsUri,t,!1));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"_createStream",value:(c=SI.default(AI.default.mark((function e(t,n){var r,i;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={unique_name:t},void 0!==n&&(r.ttl=n),e.next=4,this.services.network.post(this.services.config.streamsUri,r);case 4:return i=e.sent,e.abrupt("return",i.body);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"_getLiveQuery",value:function(e){return this.readRootFromSessionCache(dC.type,e)}},{key:"getCached",value:function(e,t){return e&&this.entities.get(e,t)||null}},{key:"removeFromCacheAndSession",value:function(e,t,n){this.entities.remove(t),this.services.config.sessionStorageEnabled&&this.services.storage.remove(e,t,n)}},{key:"document",value:(u=SI.default(AI.default.mark((function e(t){var n,r,i,a,o=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=bC(t)).mode){e.next=9;break}return e.next=6,this._createDocument(n.id,n.data,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,TT.type))){e.next=14;break}return e.abrupt("return",new TT(i));case 14:return e.prev=14,e.next=17,this._getDocument(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createDocument(n.id,n.data,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.document(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(TT.type,n.id,r),a=new IT(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new TT(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return u.apply(this,arguments)})},{key:"map",value:(s=SI.default(AI.default.mark((function e(t){var n,r,i,a,o=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=bC(t)).mode){e.next=9;break}return e.next=6,this._createMap(n.id,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,tC.type))){e.next=14;break}return e.abrupt("return",new tC(i));case 14:return e.prev=14,e.next=17,this._getMap(n.id,n.includeItems);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createMap(n.id,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.map(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(tC.type,n.id,r),a=new eC(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new tC(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return s.apply(this,arguments)})},{key:"list",value:(o=SI.default(AI.default.mark((function e(t){var n,r,i,a,o=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=bC(t)).mode){e.next=9;break}return e.next=6,this._createList(n.id,n.purpose,n.context,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,GT.type))){e.next=14;break}return e.abrupt("return",new GT(i));case 14:return e.prev=14,e.next=17,this._getList(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createList(n.id,n.purpose,n.context,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.list(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(GT.type,n.id,r),a=new $T(this.services,r,(function(e,t,n){return o.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new GT(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return o.apply(this,arguments)})},{key:"stream",value:(a=SI.default(AI.default.mark((function e(t){var n,r,i,a,o,s=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=bC(t)).mode){e.next=9;break}return e.next=6,this._createStream(n.id,n.ttl);case 6:case 17:case 29:r=e.sent,e.next=39;break;case 9:if(!(i=this.getCached(n.id,iC.type))){e.next=14;break}return e.abrupt("return",new iC(i));case 14:return e.prev=14,e.next=17,this._getStream(n.id);case 20:if(e.prev=20,e.t0=e.catch(14),404===e.t0.status&&"open_existing"!==n.mode){e.next=26;break}throw e.t0;case 26:return e.prev=26,e.next=29,this._createStream(n.id,n.ttl);case 32:if(e.prev=32,e.t1=e.catch(26),409!==e.t1.status){e.next=38;break}return e.abrupt("return",this.stream(t));case 38:throw e.t1;case 39:return this.storeRootInSessionCache(iC.type,n.id,r),a=function(e,t,n){return s.removeFromCacheAndSession(e,t,n)},o=new rC(this.services,r,a),o=this.entities.store(o),e.abrupt("return",new iC(o));case 44:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return a.apply(this,arguments)})},{key:"shutdown",value:(i=SI.default(AI.default.mark((function e(){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.subscriptions.shutdown();case 2:return e.next=4,this.services.twilsock.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"updateToken",value:(r=SI.default(AI.default.mark((function e(t){return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.twilsock.updateToken(t).catch((function(e){var t,n=null==e||null===(t=e.reply)||void 0===t?void 0:t.status;if(401===(null==n?void 0:n.code)&&"UNAUTHORIZED"===(null==n?void 0:n.status))throw new SyncError("Updated token was rejected by server",400,51130);throw e})));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"liveQuery",value:(n=SI.default(AI.default.mark((function e(t,n){var r,i,a,o,s,u=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return r=new WI(this.services.config.insightsUri).pathSegment(t).pathSegment("Items").build(),e.next=5,lC({network:this.services.network,uri:r,queryString:n,type:dC.type});case 5:return i=e.sent,(a=this.getCached(i.query_id,dC.type))||((o=this._getLiveQuery(i.query_id))||(o={indexName:t,queryExpression:n,sid:i.query_id,queryUri:r,last_event_id:i.last_event_id}),s=function(e,t,n){return u.removeFromCacheAndSession(e,t,n)},a=new cC(o,this.services,s,i.items)),this.storeRootInSessionCache(dC.type,i.query_id,a.liveQueryDescriptor),a=this.entities.store(a),e.abrupt("return",new dC(a));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"instantQuery",value:(t=SI.default(AI.default.mark((function e(t){var n,r=this;return AI.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return n=function(e,t){return r.liveQuery(e,t)},e.abrupt("return",new pC({indexName:t,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:n}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"populateInitRegistrations",value:function(e){e.populateInitRegistrations([xC,wC,kC,_C])}},{key:"version",get:function(){return mC}}]),Client}(bI.ReplayEventEmitter);PI.default(Client,"connectionStateChanged","connectionStateChanged"),PI.default(Client,"connectionError","connectionError"),PI.default(Client,"tokenAboutToExpire","tokenAboutToExpire"),PI.default(Client,"tokenExpired","tokenExpired"),qI([fI.validateTypesAsync(["undefined","string",fI.objectSchema("open document options",{id:["string","undefined"],mode:[fI.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[fI.nonNegativeInteger,"undefined"],data:[fI.pureObject,"undefined",fI.literal(null)]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],Client.prototype,"document",null),qI([fI.validateTypesAsync(["undefined","string",fI.objectSchema("open map options",{id:["string","undefined"],mode:[fI.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[fI.nonNegativeInteger,"undefined"],data:[fI.pureObject,"undefined",fI.literal(null)],includeItems:["boolean","undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],Client.prototype,"map",null),qI([fI.validateTypesAsync(["undefined","string",fI.objectSchema("open list options",{id:["string","undefined"],mode:[fI.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[fI.nonNegativeInteger,"undefined"],data:[fI.pureObject,"undefined",fI.literal(null)],purpose:["string","undefined"],context:[fI.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],Client.prototype,"list",null),qI([fI.validateTypesAsync(["undefined","string",fI.objectSchema("open stream options",{id:["string","undefined"],mode:[fI.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[fI.nonNegativeInteger,"undefined"],data:[fI.pureObject,"undefined",fI.literal(null)]})]),zI("design:type",Function),zI("design:paramtypes",[Object]),zI("design:returntype",Promise)],Client.prototype,"stream",null),qI([fI.validateTypesAsync(fI.nonEmptyString),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],Client.prototype,"updateToken",null),qI([fI.validateTypesAsync(fI.nonEmptyString,"string"),zI("design:type",Function),zI("design:paramtypes",[String,String]),zI("design:returntype",Promise)],Client.prototype,"liveQuery",null),qI([fI.validateTypesAsync(fI.nonEmptyString),zI("design:type",Function),zI("design:paramtypes",[String]),zI("design:returntype",Promise)],Client.prototype,"instantQuery",null),UR.Client=Client,UR.InsightsItem=uC,UR.InstantQuery=pC,UR.LiveQuery=dC,UR.Paginator=Paginator;var SC=UR.SyncClient=Client,EC=UR.SyncDocument=TT;UR.SyncList=GT,UR.SyncListItem=CT;var RC=UR.SyncMap=tC;UR.SyncMapItem=JT,UR.SyncStream=iC;var IC,TC={},CC=AE,OC=function(e){if(CC(e))throw TypeError("The method doesn't accept regular expressions");return e},PC=he("match"),AC=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[PC]=!1,"/./"[e](t)}catch(e){}}return!1},jC=Tn,MC=o.f,LC=Dt,UC=Er,NC=OC,DC=k,FC=AC,BC="".startsWith,qC=Math.min,zC=FC("startsWith");jC({target:"String",proto:!0,forced:!!(zC||(IC=MC(String.prototype,"startsWith"),!IC||IC.writable))&&!zC},{startsWith:function(e){var t=UC(DC(this));NC(e);var n=LC(qC(arguments.length>1?arguments[1]:void 0,t.length)),r=UC(e);return BC?BC.call(t,r,n):t.slice(n,n+r.length)===r}});var WC=s,KC=he("iterator"),VC=!WC((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[KC]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),$C=2147483647,GC=/[^\0-\u007E]/,JC=/[.\u3002\uFF0E\uFF61]/g,HC="Overflow: input needs wider integers to process",YC=Math.floor,QC=String.fromCharCode,XC=function(e){return e+22+75*(e<26)},ZC=function(e,t,n){var r=0;for(e=n?YC(e/700):e>>1,e+=YC(e/t);e>455;r+=36)e=YC(e/35);return YC(r+36*e/(e+38))},eO=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){var a=e.charCodeAt(n++);56320==(64512&a)?t.push(((1023&i)<<10)+(1023&a)+65536):(t.push(i),n--)}else t.push(i)}return t}(e);var n,r,i=e.length,a=128,o=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&t.push(QC(r));var u=t.length,c=u;for(u&&t.push("-");c<i;){var l=$C;for(n=0;n<e.length;n++)(r=e[n])>=a&&r<l&&(l=r);var f=c+1;if(l-a>YC(($C-o)/f))throw RangeError(HC);for(o+=(l-a)*f,a=l,n=0;n<e.length;n++){if((r=e[n])<a&&++o>$C)throw RangeError(HC);if(r==a){for(var d=o,p=36;;p+=36){var h=p<=s?1:p>=s+26?26:p-s;if(d<h)break;var v=d-h,y=36-h;t.push(QC(XC(h+v%y))),d=YC(v/y)}t.push(QC(XC(d))),s=ZC(o,f,c==u),o=0,++c}}++o,++a}return t.join("")},tO=Tn,nO=T,rO=VC,iO=Je.exports,aO=vo,oO=An,sO=Yl,uO=xt,cO=Eo,lO=te,fO=Fr,dO=Va,pO=Fe,hO=E,vO=Er,yO=nr,gO=v,mO=No,bO=Mo,wO=he,kO=nO("fetch"),_O=nO("Request"),xO=_O&&_O.prototype,SO=nO("Headers"),EO=wO("iterator"),RO="URLSearchParams",IO="URLSearchParamsIterator",TO=uO.set,CO=uO.getterFor(RO),OO=uO.getterFor(IO),PO=/\+/g,AO=Array(4),jO=function(e){return AO[e-1]||(AO[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},MO=function(e){try{return decodeURIComponent(e)}catch(t){return e}},LO=function(e){var t=e.replace(PO," "),n=4;try{return decodeURIComponent(t)}catch(e){for(;n;)t=t.replace(jO(n--),MO);return t}},UO=/[!'()~]|%20/g,NO={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},DO=function(e){return NO[e]},FO=function(e){return encodeURIComponent(e).replace(UO,DO)},BO=function(e,t){if(t)for(var n,r,i=t.split("&"),a=0;a<i.length;)(n=i[a++]).length&&(r=n.split("="),e.push({key:LO(r.shift()),value:LO(r.join("="))}))},qO=function(e){this.entries.length=0,BO(this.entries,e)},zO=function(e,t){if(e<t)throw TypeError("Not enough arguments")},WO=sO((function(e,t){TO(this,{type:IO,iterator:mO(CO(e).entries),kind:t})}),"Iterator",(function(){var e=OO(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),n})),KO=function(){cO(this,KO,RO);var e,t,n,r,i,a,o,s,u,c=arguments.length>0?arguments[0]:void 0,l=this,f=[];if(TO(l,{type:RO,entries:f,updateURL:function(){},updateSearchParams:qO}),void 0!==c)if(hO(c))if("function"==typeof(e=bO(c)))for(n=(t=mO(c,e)).next;!(r=n.call(t)).done;){if((o=(a=(i=mO(pO(r.value))).next).call(i)).done||(s=a.call(i)).done||!a.call(i).done)throw TypeError("Expected sequence with length 2");f.push({key:vO(o.value),value:vO(s.value)})}else for(u in c)lO(c,u)&&f.push({key:u,value:vO(c[u])});else BO(f,"string"==typeof c?"?"===c.charAt(0)?c.slice(1):c:vO(c))},VO=KO.prototype;if(aO(VO,{append:function(e,t){zO(arguments.length,2);var n=CO(this);n.entries.push({key:vO(e),value:vO(t)}),n.updateURL()},delete:function(e){zO(arguments.length,1);for(var t=CO(this),n=t.entries,r=vO(e),i=0;i<n.length;)n[i].key===r?n.splice(i,1):i++;t.updateURL()},get:function(e){zO(arguments.length,1);for(var t=CO(this).entries,n=vO(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){zO(arguments.length,1);for(var t=CO(this).entries,n=vO(e),r=[],i=0;i<t.length;i++)t[i].key===n&&r.push(t[i].value);return r},has:function(e){zO(arguments.length,1);for(var t=CO(this).entries,n=vO(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){zO(arguments.length,1);for(var n,r=CO(this),i=r.entries,a=!1,o=vO(e),s=vO(t),u=0;u<i.length;u++)(n=i[u]).key===o&&(a?i.splice(u--,1):(a=!0,n.value=s));a||i.push({key:o,value:s}),r.updateURL()},sort:function(){var e,t,n,r=CO(this),i=r.entries,a=i.slice();for(i.length=0,n=0;n<a.length;n++){for(e=a[n],t=0;t<n;t++)if(i[t].key>e.key){i.splice(t,0,e);break}t===n&&i.push(e)}r.updateURL()},forEach:function(e){for(var t,n=CO(this).entries,r=fO(e,arguments.length>1?arguments[1]:void 0,3),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new WO(this,"keys")},values:function(){return new WO(this,"values")},entries:function(){return new WO(this,"entries")}},{enumerable:!0}),iO(VO,EO,VO.entries),iO(VO,"toString",(function(){for(var e,t=CO(this).entries,n=[],r=0;r<t.length;)e=t[r++],n.push(FO(e.key)+"="+FO(e.value));return n.join("&")}),{enumerable:!0}),oO(KO,RO),tO({global:!0,forced:!rO},{URLSearchParams:KO}),!rO&&"function"==typeof SO){var $O=function(e){if(hO(e)){var t,n=e.body;if(dO(n)===RO)return(t=e.headers?new SO(e.headers):new SO).has("content-type")||t.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),yO(e,{body:gO(0,String(n)),headers:gO(0,t)})}return e};if("function"==typeof kO&&tO({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return kO(e,arguments.length>1?$O(arguments[1]):{})}}),"function"==typeof _O){var GO=function(e){return cO(this,GO,"Request"),new _O(e,arguments.length>1?$O(arguments[1]):{})};xO.constructor=GO,GO.prototype=xO,tO({global:!0,forced:!0},{Request:GO})}}var JO,HO={URLSearchParams:KO,getState:CO},YO=Tn,QO=u,XO=VC,ZO=a,eP=Wn,tP=Je.exports,nP=Eo,rP=te,iP=MR,aP=wl,oP=Cl.codeAt,sP=function(e){var t,n,r=[],i=e.toLowerCase().replace(JC,".").split(".");for(t=0;t<i.length;t++)n=i[t],r.push(GC.test(n)?"xn--"+eO(n):n);return r.join(".")},uP=Er,cP=An,lP=HO,fP=xt,dP=ZO.URL,pP=lP.URLSearchParams,hP=lP.getState,vP=fP.set,yP=fP.getterFor("URL"),gP=Math.floor,mP=Math.pow,bP="Invalid scheme",wP="Invalid host",kP="Invalid port",_P=/[A-Za-z]/,xP=/[\d+-.A-Za-z]/,SP=/\d/,EP=/^0x/i,RP=/^[0-7]+$/,IP=/^\d+$/,TP=/^[\dA-Fa-f]+$/,CP=/[\0\t\n\r #%/:<>?@[\\\]^|]/,OP=/[\0\t\n\r #/:<>?@[\\\]^|]/,PP=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,AP=/[\t\n\r]/g,jP=function(e,t){var n,r,i;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return wP;if(!(n=LP(t.slice(1,-1))))return wP;e.host=n}else if(WP(e)){if(t=sP(t),CP.test(t))return wP;if(null===(n=MP(t)))return wP;e.host=n}else{if(OP.test(t))return wP;for(n="",r=aP(t),i=0;i<r.length;i++)n+=qP(r[i],NP);e.host=n}},MP=function(e){var t,n,r,i,a,o,s,u=e.split(".");if(u.length&&""==u[u.length-1]&&u.pop(),(t=u.length)>4)return e;for(n=[],r=0;r<t;r++){if(""==(i=u[r]))return e;if(a=10,i.length>1&&"0"==i.charAt(0)&&(a=EP.test(i)?16:8,i=i.slice(8==a?1:2)),""===i)o=0;else{if(!(10==a?IP:8==a?RP:TP).test(i))return e;o=parseInt(i,a)}n.push(o)}for(r=0;r<t;r++)if(o=n[r],r==t-1){if(o>=mP(256,5-t))return null}else if(o>255)return null;for(s=n.pop(),r=0;r<n.length;r++)s+=n[r]*mP(256,3-r);return s},LP=function(e){var t,n,r,i,a,o,s,u=[0,0,0,0,0,0,0,0],c=0,l=null,f=0,d=function(){return e.charAt(f)};if(":"==d()){if(":"!=e.charAt(1))return;f+=2,l=++c}for(;d();){if(8==c)return;if(":"!=d()){for(t=n=0;n<4&&TP.test(d());)t=16*t+parseInt(d(),16),f++,n++;if("."==d()){if(0==n)return;if(f-=n,c>6)return;for(r=0;d();){if(i=null,r>0){if(!("."==d()&&r<4))return;f++}if(!SP.test(d()))return;for(;SP.test(d());){if(a=parseInt(d(),10),null===i)i=a;else{if(0==i)return;i=10*i+a}if(i>255)return;f++}u[c]=256*u[c]+i,2!=++r&&4!=r||c++}if(4!=r)return;break}if(":"==d()){if(f++,!d())return}else if(d())return;u[c++]=t}else{if(null!==l)return;f++,l=++c}}if(null!==l)for(o=c-l,c=7;0!=c&&o>0;)s=u[c],u[c--]=u[l+o-1],u[l+--o]=s;else if(8!=c)return;return u},UP=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=gP(e/256);return t.join(".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++i);return i>n&&(t=r,n=i),t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=e[n].toString(16),n<7&&(t+=":")));return"["+t+"]"}return e},NP={},DP=iP({},NP,{" ":1,'"':1,"<":1,">":1,"`":1}),FP=iP({},DP,{"#":1,"?":1,"{":1,"}":1}),BP=iP({},FP,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),qP=function(e,t){var n=oP(e,0);return n>32&&n<127&&!rP(t,e)?e:encodeURIComponent(e)},zP={ftp:21,file:null,http:80,https:443,ws:80,wss:443},WP=function(e){return rP(zP,e.scheme)},KP=function(e){return""!=e.username||""!=e.password},VP=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},$P=function(e,t){var n;return 2==e.length&&_P.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)},GP=function(e){var t;return e.length>1&&$P(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},JP=function(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&$P(t[0],!0)||t.pop()},HP=function(e){return"."===e||"%2e"===e.toLowerCase()},YP={},QP={},XP={},ZP={},eA={},tA={},nA={},rA={},iA={},aA={},oA={},sA={},uA={},cA={},lA={},fA={},dA={},pA={},hA={},vA={},yA={},gA=function(e,t,n,r){var i,a,o,s,u,c=n||YP,l=0,f="",d=!1,p=!1,h=!1;for(n||(e.scheme="",e.username="",e.password="",e.host=null,e.port=null,e.path=[],e.query=null,e.fragment=null,e.cannotBeABaseURL=!1,t=t.replace(PP,"")),t=t.replace(AP,""),i=aP(t);l<=i.length;){switch(a=i[l],c){case YP:if(!a||!_P.test(a)){if(n)return bP;c=XP;continue}f+=a.toLowerCase(),c=QP;break;case QP:if(a&&(xP.test(a)||"+"==a||"-"==a||"."==a))f+=a.toLowerCase();else{if(":"!=a){if(n)return bP;f="",c=XP,l=0;continue}if(n&&(WP(e)!=rP(zP,f)||"file"==f&&(KP(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=f,n)return void(WP(e)&&zP[e.scheme]==e.port&&(e.port=null));f="","file"==e.scheme?c=cA:WP(e)&&r&&r.scheme==e.scheme?c=ZP:WP(e)?c=rA:"/"==i[l+1]?(c=eA,l++):(e.cannotBeABaseURL=!0,e.path.push(""),c=hA)}break;case XP:if(!r||r.cannotBeABaseURL&&"#"!=a)return bP;if(r.cannotBeABaseURL&&"#"==a){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,c=yA;break}c="file"==r.scheme?cA:tA;continue;case ZP:if("/"!=a||"/"!=i[l+1]){c=tA;continue}c=iA,l++;break;case eA:if("/"==a){c=aA;break}c=pA;continue;case tA:if(e.scheme=r.scheme,a==JO)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query;else if("/"==a||"\\"==a&&WP(e))c=nA;else if("?"==a)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query="",c=vA;else{if("#"!=a){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.path.pop(),c=pA;continue}e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query,e.fragment="",c=yA}break;case nA:if(!WP(e)||"/"!=a&&"\\"!=a){if("/"!=a){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,c=pA;continue}c=aA}else c=iA;break;case rA:if(c=iA,"/"!=a||"/"!=f.charAt(l+1))continue;l++;break;case iA:if("/"!=a&&"\\"!=a){c=aA;continue}break;case aA:if("@"==a){d&&(f="%40"+f),d=!0,o=aP(f);for(var v=0;v<o.length;v++){var y=o[v];if(":"!=y||h){var g=qP(y,BP);h?e.password+=g:e.username+=g}else h=!0}f=""}else if(a==JO||"/"==a||"?"==a||"#"==a||"\\"==a&&WP(e)){if(d&&""==f)return"Invalid authority";l-=aP(f).length+1,f="",c=oA}else f+=a;break;case oA:case sA:if(n&&"file"==e.scheme){c=fA;continue}if(":"!=a||p){if(a==JO||"/"==a||"?"==a||"#"==a||"\\"==a&&WP(e)){if(WP(e)&&""==f)return wP;if(n&&""==f&&(KP(e)||null!==e.port))return;if(s=jP(e,f))return s;if(f="",c=dA,n)return;continue}"["==a?p=!0:"]"==a&&(p=!1),f+=a}else{if(""==f)return wP;if(s=jP(e,f))return s;if(f="",c=uA,n==sA)return}break;case uA:if(!SP.test(a)){if(a==JO||"/"==a||"?"==a||"#"==a||"\\"==a&&WP(e)||n){if(""!=f){var m=parseInt(f,10);if(m>65535)return kP;e.port=WP(e)&&m===zP[e.scheme]?null:m,f=""}if(n)return;c=dA;continue}return kP}f+=a;break;case cA:if(e.scheme="file","/"==a||"\\"==a)c=lA;else{if(!r||"file"!=r.scheme){c=pA;continue}if(a==JO)e.host=r.host,e.path=r.path.slice(),e.query=r.query;else if("?"==a)e.host=r.host,e.path=r.path.slice(),e.query="",c=vA;else{if("#"!=a){GP(i.slice(l).join(""))||(e.host=r.host,e.path=r.path.slice(),JP(e)),c=pA;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",c=yA}}break;case lA:if("/"==a||"\\"==a){c=fA;break}r&&"file"==r.scheme&&!GP(i.slice(l).join(""))&&($P(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),c=pA;continue;case fA:if(a==JO||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&$P(f))c=pA;else if(""==f){if(e.host="",n)return;c=dA}else{if(s=jP(e,f))return s;if("localhost"==e.host&&(e.host=""),n)return;f="",c=dA}continue}f+=a;break;case dA:if(WP(e)){if(c=pA,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=JO&&(c=pA,"/"!=a))continue}else e.fragment="",c=yA;else e.query="",c=vA;break;case pA:if(a==JO||"/"==a||"\\"==a&&WP(e)||!n&&("?"==a||"#"==a)){if(".."===(u=(u=f).toLowerCase())||"%2e."===u||".%2e"===u||"%2e%2e"===u?(JP(e),"/"==a||"\\"==a&&WP(e)||e.path.push("")):HP(f)?"/"==a||"\\"==a&&WP(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&$P(f)&&(e.host&&(e.host=""),f=f.charAt(0)+":"),e.path.push(f)),f="","file"==e.scheme&&(a==JO||"?"==a||"#"==a))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==a?(e.query="",c=vA):"#"==a&&(e.fragment="",c=yA)}else f+=qP(a,FP);break;case hA:"?"==a?(e.query="",c=vA):"#"==a?(e.fragment="",c=yA):a!=JO&&(e.path[0]+=qP(a,NP));break;case vA:n||"#"!=a?a!=JO&&("'"==a&&WP(e)?e.query+="%27":e.query+="#"==a?"%23":qP(a,NP)):(e.fragment="",c=yA);break;case yA:a!=JO&&(e.fragment+=qP(a,DP))}l++}},mA=function(e){var t,n,r=nP(this,mA,"URL"),i=arguments.length>1?arguments[1]:void 0,a=uP(e),o=vP(r,{type:"URL"});if(void 0!==i)if(i instanceof mA)t=yP(i);else if(n=gA(t={},uP(i)))throw TypeError(n);if(n=gA(o,a,null,t))throw TypeError(n);var s=o.searchParams=new pP,u=hP(s);u.updateSearchParams(o.query),u.updateURL=function(){o.query=String(s)||null},QO||(r.href=wA.call(r),r.origin=kA.call(r),r.protocol=_A.call(r),r.username=xA.call(r),r.password=SA.call(r),r.host=EA.call(r),r.hostname=RA.call(r),r.port=IA.call(r),r.pathname=TA.call(r),r.search=CA.call(r),r.searchParams=OA.call(r),r.hash=PA.call(r))},bA=mA.prototype,wA=function(){var e=yP(this),t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,o=e.path,s=e.query,u=e.fragment,c=t+":";return null!==i?(c+="//",KP(e)&&(c+=n+(r?":"+r:"")+"@"),c+=UP(i),null!==a&&(c+=":"+a)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?o[0]:o.length?"/"+o.join("/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},kA=function(){var e=yP(this),t=e.scheme,n=e.port;if("blob"==t)try{return new mA(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&WP(e)?t+"://"+UP(e.host)+(null!==n?":"+n:""):"null"},_A=function(){return yP(this).scheme+":"},xA=function(){return yP(this).username},SA=function(){return yP(this).password},EA=function(){var e=yP(this),t=e.host,n=e.port;return null===t?"":null===n?UP(t):UP(t)+":"+n},RA=function(){var e=yP(this).host;return null===e?"":UP(e)},IA=function(){var e=yP(this).port;return null===e?"":String(e)},TA=function(){var e=yP(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},CA=function(){var e=yP(this).query;return e?"?"+e:""},OA=function(){return yP(this).searchParams},PA=function(){var e=yP(this).fragment;return e?"#"+e:""},AA=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(QO&&eP(bA,{href:AA(wA,(function(e){var t=yP(this),n=uP(e),r=gA(t,n);if(r)throw TypeError(r);hP(t.searchParams).updateSearchParams(t.query)})),origin:AA(kA),protocol:AA(_A,(function(e){var t=yP(this);gA(t,uP(e)+":",YP)})),username:AA(xA,(function(e){var t=yP(this),n=aP(uP(e));if(!VP(t)){t.username="";for(var r=0;r<n.length;r++)t.username+=qP(n[r],BP)}})),password:AA(SA,(function(e){var t=yP(this),n=aP(uP(e));if(!VP(t)){t.password="";for(var r=0;r<n.length;r++)t.password+=qP(n[r],BP)}})),host:AA(EA,(function(e){var t=yP(this);t.cannotBeABaseURL||gA(t,uP(e),oA)})),hostname:AA(RA,(function(e){var t=yP(this);t.cannotBeABaseURL||gA(t,uP(e),sA)})),port:AA(IA,(function(e){var t=yP(this);VP(t)||(""==(e=uP(e))?t.port=null:gA(t,e,uA))})),pathname:AA(TA,(function(e){var t=yP(this);t.cannotBeABaseURL||(t.path=[],gA(t,uP(e),dA))})),search:AA(CA,(function(e){var t=yP(this);""==(e=uP(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",gA(t,e,vA)),hP(t.searchParams).updateSearchParams(t.query)})),searchParams:AA(OA),hash:AA(PA,(function(e){var t=yP(this);""!=(e=uP(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",gA(t,e,yA)):t.fragment=null}))}),tP(bA,"toJSON",(function(){return wA.call(this)}),{enumerable:!0}),tP(bA,"toString",(function(){return wA.call(this)}),{enumerable:!0}),dP){var jA=dP.createObjectURL,MA=dP.revokeObjectURL;jA&&tP(mA,"createObjectURL",(function(e){return jA.apply(dP,arguments)})),MA&&tP(mA,"revokeObjectURL",(function(e){return MA.apply(dP,arguments)}))}cP(mA,"URL"),YO({global:!0,forced:!XO,sham:!QO},{URL:mA}),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=hv.exports,r=pv.exports,i=vv.exports,a=gv.exports,o=bv.exports,s=HE.exports,u=Oy.exports,c=qm.exports,l=zm,f=wh.exports,d=Sf.exports,p=tm,h=bh;function v(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function y(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var g=v(n),m=v(r),b=v(i),w=v(a),k=v(o),_=v(s),x=v(u),S=v(c),E=v(l),R=v(f),I=y(d),T={exports:{}},C="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(C){var O=new Uint8Array(16);T.exports=function(){return C(O),O}}else{var P=new Array(16);T.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),P[t]=e>>>((3&t)<<3)&255;return P}}for(var A=[],j=0;j<256;++j)A[j]=(j+256).toString(16).substr(1);var M,L,U=function(e,t){var n=t||0,r=A;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")},N=T.exports,D=U,F=0,B=0;var q=function(e,t,n){var r=t&&n||0,i=t||[],a=(e=e||{}).node||M,o=void 0!==e.clockseq?e.clockseq:L;if(null==a||null==o){var s=N();null==a&&(a=M=[1|s[0],s[1],s[2],s[3],s[4],s[5]]),null==o&&(o=L=16383&(s[6]<<8|s[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:B+1,l=u-F+(c-B)/1e4;if(l<0&&void 0===e.clockseq&&(o=o+1&16383),(l<0||u>F)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");F=u,B=c,L=o;var f=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[r++]=f>>>24&255,i[r++]=f>>>16&255,i[r++]=f>>>8&255,i[r++]=255&f;var d=u/4294967296*1e4&268435455;i[r++]=d>>>8&255,i[r++]=255&d,i[r++]=d>>>24&15|16,i[r++]=d>>>16&255,i[r++]=o>>>8|128,i[r++]=255&o;for(var p=0;p<6;++p)i[r+p]=a[p];return t||D(i)},z=T.exports,W=U;var K=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||z)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var a=0;a<16;++a)t[r+a]=i[a];return t||W(i)},V=q,$=K,G=$;G.v1=V,G.v4=$;var J=G;function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=k.default(e);if(t){var i=k.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return w.default(this,n)}}var Y=function(e){b.default(n,e);var t=H(n);function n(e){var r;g.default(this,n);var i,a=J.v4();return(r=t.call(this,(function(t,r){return i=r,e((function(e){n.cancellationMap.delete(a),t(e)}),(function(e){n.cancellationMap.delete(a),r(e)}),(function(e){n.cancellationMap.set(a,e)}))}))).id=a,r.rejectPromise=i,r}return m.default(n,[{key:"cancel",value:function(){var e=n.cancellationMap.get(this.id);return null==e||e(),this.rejectPromise&&(this.catch((function(){})),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),n}(_.default(Promise));function Q(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":R.default(Reflect))&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function X(e,t){if("object"===("undefined"==typeof Reflect?"undefined":R.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function Z(e,t){return["".concat((new Date).toISOString()," MCS Client ").concat(e,":")].concat(Array.from(t))}x.default(Y,"cancellationMap",new Map);var ee=function(){function e(t){g.default(this,e),x.default(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return m.default(e,[{key:"setLevel",value:function(e){I.setLevel(e)}},{key:"trace",value:function(){if(I.getLevel()==I.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.debug.apply(null,Z(this.prefix+"T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.debug.apply(null,Z(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.info.apply(null,Z(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.warn.apply(null,Z(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.error.apply(null,Z(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){I.setLevel(e)}},{key:"trace",value:function(){if(I.getLevel()==I.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.debug.apply(null,Z("T",t))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.debug.apply(null,Z("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.info.apply(null,Z("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.warn.apply(null,Z("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];I.error.apply(null,Z("E",t))}}]),e}(),te=function(e,t){return"".concat((n=e,n.startsWith("http")?"":function(e){return"https://mcs.".concat(null!=e?e:"us1",".twilio.com")}(t))).concat(e);var n},ne=function(){function e(t,n,r,i){var a,o,s,u,c,l;g.default(this,e);var f=null!==(a=null!==(o=i.MCS)&&void 0!==o?o:i)&&void 0!==a?a:{};this.region=null!==(s=null!==(u=f.region)&&void 0!==u?u:i.region)&&void 0!==s?s:"us1",this.mediaUrl=te(n,this.region),this.mediaSetUrl=r?te(r):"".concat(this.mediaUrl,"Set"),this.token=t,this.retryWhenThrottledOverride=null===(c=f.retryWhenThrottledOverride)||void 0===c||c,this.backoffConfigOverride=null!==(l=f.backoffConfigOverride)&&void 0!==l?l:e.backoffConfigDefault}return m.default(e,[{key:"updateToken",value:function(e){this.token=e}}],[{key:"backoffConfigDefault",get:function(){return{min:1e3,max:4e3,maxAttemptsCount:3}}},{key:"retryWhenThrottledDefault",get:function(){return true}}]),e}(),Media=function(){function Media(e,t,n){g.default(this,Media),this.config=e,this.network=t,this._update(n)}return m.default(Media,[{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 e=this;return new Y(function(){var t=S.default(E.default.mark((function t(n,r,i){var a,o;return E.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.network.get("".concat(e.config.mediaUrl,"/").concat(e.sid)),i((function(){return a.cancel()})),t.prev=2,t.next=5,a;case 5:o=t.sent,e._update(o.body),n(e.state.contentDirectUrl),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),r(t.t0);case 13:case"end":return t.stop()}}),t,null,[[2,10]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_update",value:function(e){var t,n,r,i;this.state={sid:e.sid,serviceSid:e.service_sid,channelSid:e.channel_sid,messageSid:e.message_sid,dateCreated:e.date_created?new Date(e.date_created):null,dateUploadUpdated:e.date_upload_updated?new Date(e.date_upload_updated):null,dateUpdated:e.date_updated?new Date(e.date_updated):null,size:e.size,contentType:e.content_type,author:e.author,url:e.url,contentUrl:e.links.content,contentDirectUrl:null!==(t=e.links.content_direct_temporary)&&void 0!==t?t:null,filename:null!==(n=e.filename)&&void 0!==n?n:null,category:null!==(r=e.category)&&void 0!==r?r:"media",isMultipartUpstream:null!==(i=e.is_multipart_upstream)&&void 0!==i&&i}}},{key:"_state",value:function(){var e;return{sid:this.state.sid,category:this.state.category,filename:null!==(e=this.state.filename)&&void 0!==e?e:null,contentType:this.state.contentType,size:this.state.size}}}]),Media}();function re(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=k.default(e);if(t){var i=k.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return w.default(this,n)}}var ie=function(e){b.default(n,e);var t=re(n);function n(e,r,i,a,o){var s;return g.default(this,n),(s=t.call(this,e)).code=r,s.body=i,s.status=a,s.headers=o,s}return m.default(n)}(_.default(Error)),ae=t.XMLHttpRequest||{};var oe,se=function(){function e(){g.default(this,e)}return m.default(e,[{key:"get",value:function(t,n){return e.request("GET",t,n)}},{key:"post",value:function(t,n,r){return e.request("POST",t,n,r)}}],[{key:"request",value:function(e,t,n,r){return new Y((function(i,a,o){var s=new ae,u=!1;for(var c in o((function(){s.abort(),u=!0})),s.open(e,t,!0),s.onreadystatechange=function(){if(4===s.readyState&&!u){var e,t=(e=s.getAllResponseHeaders())?e.split("\r\n").map((function(e){return e.split(": ")})).filter((function(e){return 2===e.length&&e[1].length>0})).reduce((function(e,t){return e[t[0]]=t[1],e}),{}):{},n=function(e){var t=e.getResponseHeader("Content-Type");if(!t||0!==t.indexOf("application/json")||0===e.responseText.length)return e.responseText;try{return JSON.parse(e.responseText)}catch(t){return e.responseText}}(s);if(200<=s.status&&s.status<300)i({status:s.status,headers:t,body:n});else{var r,o,c=null!==(r=s.statusText)&&void 0!==r?r:"NONE";if("string"==typeof n)if(n&&1===n.split("\n",2).length)o=n;else{var l,f=null===(l=n.replace(/<.*?>/g,"").split(/\r\n/g).filter((function(e){return e.length}))[0])||void 0===l?void 0:l.split(" ");o=(null==f?void 0:f.length)>2?null==f?void 0:f.slice(1).join(" "):""}else o=JSON.stringify(n);var d="".concat(s.status,": [").concat(c,"] ").concat(o);a(new ie(d,s.status,n,c,t))}}},n)s.setRequestHeader(c,n[c]),"Content-Type"===c&&"application/json"===n[c]&&(r=JSON.stringify(r));s.send(r)}))}}]),e}(),ue=ee.scope("Network"),ce=function(){function e(t,n){g.default(this,e),this.config=t,this.transport=n}return m.default(e,[{key:"backoffConfig",value:function(){return Object.assign(ne.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var e,t;return null!==(e=null!==(t=this.config.retryWhenThrottledOverride)&&void 0!==t?t:ne.retryWhenThrottledDefault)&&void 0!==e&&e}},{key:"executeWithRetry",value:function(e,t){var n=this;return new Y(function(){var r=S.default(E.default.mark((function r(i,a,o){var s,u;return E.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:s=new p.Retrier(n.backoffConfig()),u=[502,503,504],t&&u.push(429),o((function(){s.cancel(),s.removeAllListeners()})),s.on("attempt",S.default(E.default.mark((function t(){var n,r;return E.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n=e(),o((function(){n.cancel(),s.cancel(),s.removeAllListeners()})),t.next=5,n;case 5:r=t.sent,s.succeeded(r),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(0),u.indexOf(t.t0.status)>-1||"Twilsock disconnected"===t.t0.message?s.failed(t.t0):(s.removeAllListeners(),s.cancel(),a(t.t0));case 12:case"end":return t.stop()}}),t,null,[[0,9]])})))),s.on("succeeded",(function(e){i(e)})),s.on("cancelled",(function(e){return a(e)})),s.on("failed",(function(e){return a(e)})),s.start();case 9:case"end":return r.stop()}}),r)})));return function(e,t,n){return r.apply(this,arguments)}}())}},{key:"get",value:function(e){var t=this;return new Y(function(){var n=S.default(E.default.mark((function n(r,i,a){var o,s,u;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={"X-Twilio-Token":t.config.token},s=t.executeWithRetry((function(){return t.transport.get(e,o)}),t.retryWhenThrottled()),ue.trace("sending GET request to ",e," headers ",o),a((function(){return s.cancel()})),n.prev=4,n.next=7,s;case 7:u=n.sent,ue.trace("response",u),r(u),n.next=16;break;case 12:n.prev=12,n.t0=n.catch(4),ue.debug("get() error ".concat(n.t0)),i(n.t0);case 16:case"end":return n.stop()}}),n,null,[[4,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"post",value:function(e,n,r,i,a){var o=this,s={"X-Twilio-Token":this.config.token};"undefined"!=typeof FormData&&r instanceof FormData||!i||Object.assign(s,{"Content-Type":i});var u=new URL(e);return n&&u.searchParams.append("Category",n),a&&u.searchParams.append("Filename",a),new Y(function(){var n=S.default(E.default.mark((function n(i,a,c){var l,f;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return l=o.transport.post(u.href,s,r),c((function(){return l.cancel()})),ue.trace("sending POST request to ".concat(e," with headers ").concat(s)),n.prev=3,n.next=6,l;case 6:f=n.sent,n.next=17;break;case 9:if(n.prev=9,n.t0=n.catch(3),!(void 0===t.XMLHttpRequest&&r instanceof FormData)){n.next=14;break}return a(new TypeError("Posting FormData supported only with browser engine's FormData")),n.abrupt("return");case 14:return ue.debug("post() error ".concat(n.t0)),a(n.t0),n.abrupt("return");case 17:ue.trace("response",f),i(f);case 19:case"end":return n.stop()}}),n,null,[[3,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}}]),e}(),le=ee.scope("");e.default=(oe=function(){function Client(e,t,n){var r,i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};g.default(this,Client),this.options=a,this.options.logLevel=null!==(r=this.options.logLevel)&&void 0!==r?r:"silent",this.config=new ne(e,t,n,this.options),le.setLevel(this.options.logLevel),this.options.transport=null!==(i=this.options.transport)&&void 0!==i?i:new se,this.transport=this.options.transport,this.network=new ce(this.config,this.transport)}return m.default(Client,[{key:"updateToken",value:function(e){le.info("updateToken"),this.config.updateToken(e)}},{key:"get",value:function(e){var t=this;return new Y(function(){var n=S.default(E.default.mark((function n(r,i,a){var o,s;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=t.network.get("".concat(t.config.mediaUrl,"/").concat(e)),a((function(){return o.cancel()})),n.prev=2,n.next=5,o;case 5:s=n.sent,r(new Media(t.config,t.network,s.body)),n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i(n.t0);case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"post",value:function(e,t,n,r){var i=this;return new Y(function(){var a=S.default(E.default.mark((function a(o,s,u){var c,l;return E.default.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return c=i.network.post(i.config.mediaUrl,null!=n?n:"media",t,e,r),u((function(){return c.cancel()})),a.prev=2,a.next=5,c;case 5:l=a.sent,o(new Media(i.config,i.network,l.body)),a.next=12;break;case 9:a.prev=9,a.t0=a.catch(2),s(a.t0);case 12:case"end":return a.stop()}}),a,null,[[2,9]])})));return function(e,t,n){return a.apply(this,arguments)}}())}},{key:"postFormData",value:function(e,t){var n=this;return new Y(function(){var r=S.default(E.default.mark((function r(i,a,o){var s,u;return E.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return s=n.network.post(n.config.mediaUrl,null!=t?t:"media",e),o((function(){return s.cancel()})),r.prev=2,r.next=5,s;case 5:u=r.sent,i(new Media(n.config,n.network,u.body)),r.next=12;break;case 9:r.prev=9,r.t0=r.catch(2),a(r.t0);case 12:case"end":return r.stop()}}),r,null,[[2,9]])})));return function(e,t,n){return r.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(e){var t=this;return new Y(function(){var n=S.default(E.default.mark((function n(r,i,a){var o,s,u,c;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={command:"get",list:e.map((function(e){return{media_sid:e}}))},s=t.network.post("".concat(t.config.mediaSetUrl),null,o,"application/json"),a((function(){return s.cancel()})),n.prev=3,n.next=6,s;case 6:u=n.sent,c=u.body.map((function(e){if(200===e.code)return new Media(t.config,t.network,e.media_record);i("Failed to obtain detailed information about Media items (failed SID ".concat(e.media_record.sid,")"))})),r(c),n.next=14;break;case 11:n.prev=11,n.t0=n.catch(3),i(n.t0);case 14:case"end":return n.stop()}}),n,null,[[3,11]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(e){var t=this;return new Y(function(){var n=S.default(E.default.mark((function n(r,i,a){var o,s,u,c;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o={command:"get",list:e.map((function(e){return{media_sid:e}}))},s=t.network.post("".concat(t.config.mediaSetUrl),null,o,"application/json"),a((function(){return s.cancel()})),n.prev=3,n.next=6,s;case 6:u=n.sent,c=new Map,u.body.forEach((function(e){200===e.code?c.set(e.media_record.sid,e.media_record.links.content_direct_temporary):i("Failed to obtain detailed information about Media items (failed SID ".concat(e.media_record.sid,")"))})),r(c),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(3),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[3,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}}]),Client}(),x.default(oe,"version","0.7.0"),oe),Q([h.validateTypes(h.nonEmptyString),X("design:type",Function),X("design:paramtypes",[String]),X("design:returntype",void 0)],e.default.prototype,"updateToken",null),Q([h.validateTypesAsync(h.nonEmptyString),X("design:type",Function),X("design:paramtypes",[String]),X("design:returntype",Y)],e.default.prototype,"get",null),e.default=Q([h.validateConstructorTypes(h.nonEmptyString,h.nonEmptyString,[h.nonEmptyString,h.literal(null)],[h.pureObject,"undefined"]),X("design:paramtypes",[String,String,Object,Object])],e.default),e.CancellablePromise=Y,e.Client=e.default,e.McsClient=e.default,e.McsMedia=Media,e.Media=Media}(TC);var LA=So,UA="ArrayBuffer",NA=r_.ArrayBuffer;function DA(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}Tn({global:!0,forced:a.ArrayBuffer!==NA},{ArrayBuffer:NA}),LA(UA);var FA=Cf.scope("Participant"),Participant=function(e){Oa(Participant,e);var t,n,r,i=DA(Participant);function Participant(e,t,n,r,a){var o,s,u;if(Na(this,Participant),(u=i.call(this)).conversation=n,u.links=r,u.services=a,u.state={attributes:yh(e.attributes,"Retrieved malformed attributes from the server for participant: "+t,FA),dateCreated:e.dateCreated?vh(e.dateCreated):null,dateUpdated:e.dateCreated?vh(e.dateUpdated):null,sid:t,typingTimeout:null,isTyping:!1,identity:e.identity,roleSid:null!==(o=e.roleSid)&&void 0!==o?o:"",lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,lastReadTimestamp:e.lastConsumptionTimestamp?vh(e.lastConsumptionTimestamp):null,type:e.type||"chat",userInfo:e.userInfo,bindings:null!==(s=e.bindings)&&void 0!==s?s:{}},!e.identity&&!e.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return u}return Ua(Participant,[{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 e;return null!==(e=this.state.bindings)&&void 0!==e?e:{}}},{key:"_startTyping",value:function(e){var t=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit(Participant.typingStarted,this),this.conversation.emit(Conversation.typingStarted,this),this.state.typingTimeout=Number(setTimeout((function(){return t._endTyping()}),e)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit(Participant.typingEnded,this),this.conversation.emit(Conversation.typingEnded,this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(e){var t=[],n=yh(e.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,FA);e.attributes&&!mh(this.state.attributes,n)&&(this.state.attributes=n,t.push("attributes"));var r=vh(e.dateUpdated);e.dateUpdated&&(null==r?void 0:r.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=r,t.push("dateUpdated"));var i=vh(e.dateCreated);if(e.dateCreated&&(null==i?void 0:i.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=i,t.push("dateCreated")),e.roleSid&&this.state.roleSid!==e.roleSid&&(this.state.roleSid=e.roleSid,t.push("roleSid")),!Number.isInteger(e.lastConsumedMessageIndex)&&null!==e.lastConsumedMessageIndex||this.state.lastReadMessageIndex===e.lastConsumedMessageIndex||(this.state.lastReadMessageIndex=e.lastConsumedMessageIndex,t.push("lastReadMessageIndex")),e.lastConsumptionTimestamp){var a=new Date(e.lastConsumptionTimestamp);this.state.lastReadTimestamp&&this.state.lastReadTimestamp.getTime()===a.getTime()||(this.state.lastReadTimestamp=a,t.push("lastReadTimestamp"))}return e.bindings&&!mh(this.state.bindings,e.bindings)&&(this.state.bindings=e.bindings,t.push("bindings")),t.length>0&&this.emit(Participant.updated,{participant:this,updateReasons:t}),this}},{key:"getUser",value:(r=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("chat"==this.type){e.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return e.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"remove",value:(n=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateAttributes",value:(t=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(t)});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),Participant}(cg);function BA(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}Ma(Participant,"typingStarted","typingStarted"),Ma(Participant,"typingEnded","typingEnded"),Ma(Participant,"updated","updated"),$c([wy(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],Participant.prototype,"updateAttributes",null);var qA=Cf.scope("Participants"),zA=function(e){Oa(l,e);var t,n,r,i,a,o,s,u,c=BA(l);function l(e,t,n,r){var i;return Na(this,l),Ma(Ta(i=c.call(this)),"rosterEntityPromise",null),i.conversation=e,i.participants=t,i.links=n,i.services=r,i}return Ua(l,[{key:"unsubscribe",value:(u=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.rosterEntityPromise){e.next=6;break}return e.next=3,this.rosterEntityPromise;case 3:e.sent.close(),this.rosterEntityPromise=null;case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"subscribe",value:function(e){var t=this,n="string"==typeof e?this.services.syncClient.map({id:e,mode:"open_existing"}):Promise.resolve(e);return this.rosterEntityPromise=this.rosterEntityPromise||n.then((function(e){e.on(RC.itemAdded,(function(e){qA.debug(t.conversation.sid+" itemAdded: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).then((function(e){t.emit(Conversation.participantJoined,e)}))})),e.on(RC.itemRemoved,(function(e){qA.debug(t.conversation.sid+" itemRemoved: "+e.key);var n=e.key;if(t.participants.has(n)){var r=t.participants.get(n);t.participants.delete(n),r&&t.emit(Conversation.participantLeft,r)}})),e.on(RC.itemUpdated,(function(e){qA.debug(t.conversation.sid+" itemUpdated: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).catch((function(e){return qA.error(e)}))}));var n=[];return e.getItems().then((function e(r){return r.items.forEach((function(e){n.push(t.upsertParticipant(e.key,e.data))})),r.hasNextPage?r.nextPage().then(e):null})).then((function(){return Promise.all(n)})).then((function(){return e}))})).catch((function(e){throw t.rosterEntityPromise=null,"disconnected"!=t.services.syncClient.connectionState&&qA.error("Failed to get roster object for conversation",t.conversation.sid,e),qA.debug("ERROR: Failed to get roster object for conversation",t.conversation.sid,e),e}))}},{key:"upsertParticipantFromResponse",value:(s=Ia(Kc.mark((function e(t){var n,r,i,a,o,s,u,c;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.sid,i=t.attributes,a=t.date_created,o=t.date_updated,s=t.identity,u=t.role_sid,c=t.messaging_binding,e.next=3,this.upsertParticipant(r,{attributes:i,dateCreated:new Date(a),dateUpdated:new Date(o),identity:s,roleSid:u,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:null!==(n=null==c?void 0:c.type)&&void 0!==n?n:"chat"});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"upsertParticipant",value:(o=Ia(Kc.mark((function e(t,n){var r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.participants.get(t))){e.next=3;break}return e.abrupt("return",r._update(n));case 3:return i={self:"".concat(this.links.participants,"/").concat(t)},r=new Participant(n,t,this.conversation,i,this.services),this.participants.set(t,r),r.on(Participant.updated,(function(e){return a.emit(Conversation.participantUpdated,e)})),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getParticipants",value:(a=Ia(Kc.mark((function e(){var t=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){var e=[];return t.participants.forEach((function(t){return e.push(t)})),e})):[]);case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"getParticipantBySid",value:(i=Ia(Kc.mark((function e(t){var n=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){var e=n.participants.get(t);if(!e)throw new Error("Participant with SID "+t+" was not found");return e})):null);case 1:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(r=Ia(Kc.mark((function e(t){var n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null,e.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then((function(){if(r.participants.forEach((function(e){e.identity===t&&(n=e)})),!n)throw new Error("Participant with identity "+t+" was not found");return n})):null);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"add",value:(n=Ia(Kc.mark((function e(t,n){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:t,attributes:void 0!==n?JSON.stringify(n):void 0});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"addNonChatParticipant",value:(t=Ia(Kc.mark((function e(t,n){var r,i,a,o,s=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=s.length>2&&void 0!==s[2]?s[2]:{},o=s.length>3&&void 0!==s[3]?s[3]:{},e.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:void 0!==a?JSON.stringify(a):void 0,messaging_binding:{address:n,proxy_address:t,name:null==o||null===(r=o.email)||void 0===r?void 0:r.name,level:null==o||null===(i=o.email)||void 0===i?void 0:i.level}});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"remove",value:function(e){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(encodeURIComponent(e)))}}]),l}(cg),WA=OC,KA=k,VA=Er;Tn({target:"String",proto:!0,forced:!AC("includes")},{includes:function(e){return!!~VA(KA(this)).indexOf(VA(WA(e)),arguments.length>1?arguments[1]:void 0)}});var $A=vo,GA=pg.exports.getWeakData,JA=Fe,HA=E,YA=Eo,QA=Jo,XA=te,ZA=xt.set,ej=xt.getterFor,tj=Xr.find,nj=Xr.findIndex,rj=0,ij=function(e){return e.frozen||(e.frozen=new aj)},aj=function(){this.entries=[]},oj=function(e,t){return tj(e.entries,(function(e){return e[0]===t}))};aj.prototype={get:function(e){var t=oj(this,e);if(t)return t[1]},has:function(e){return!!oj(this,e)},set:function(e,t){var n=oj(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=nj(this.entries,(function(t){return t[0]===e}));return~t&&this.entries.splice(t,1),!!~t}};var sj={getConstructor:function(e,t,n,r){var i=e((function(e,a){YA(e,i,t),ZA(e,{type:t,id:rj++,frozen:void 0}),null!=a&&QA(a,e[r],{that:e,AS_ENTRIES:n})})),a=ej(t),o=function(e,t,n){var r=a(e),i=GA(JA(t),!0);return!0===i?ij(r).set(t,n):i[r.id]=n,e};return $A(i.prototype,{delete:function(e){var t=a(this);if(!HA(e))return!1;var n=GA(e);return!0===n?ij(t).delete(e):n&&XA(n,t.id)&&delete n[t.id]},has:function(e){var t=a(this);if(!HA(e))return!1;var n=GA(e);return!0===n?ij(t).has(e):n&&XA(n,t.id)}}),$A(i.prototype,n?{get:function(e){var t=a(this);if(HA(e)){var n=GA(e);return!0===n?ij(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return o(this,e,t)}}:{add:function(e){return o(this,e,!0)}}),i}};qg("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),sj);var Media=function(){function Media(e,t){var n;Na(this,Media),Ma(this,"mcsMedia",null),this.services=t,e instanceof TC.McsMedia&&(this.mcsMedia=e),this.state={sid:e.sid,category:e.category,filename:null!==(n=e.filename)&&void 0!==n?n:null,contentType:e.contentType,size:e.size}}return Ua(Media,[{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 e=this;return new TC.CancellablePromise(function(){var t=Ia(Kc.mark((function t(n,r,i){var a,o,s,u;return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=e.mcsMedia?void 0:e._fetchMcsMedia(),s=null===(a=e.mcsMedia)||void 0===a?void 0:a.getContentUrl(),i((function(){o&&o.cancel(),s&&s.cancel()})),t.prev=3,s){t.next=9;break}return t.next=7,o;case 7:u=t.sent,s=null==u?void 0:u.getContentUrl();case 9:if(t.t0=n,!s){t.next=16;break}return t.next=13,s;case 13:t.t1=t.sent,t.next=17;break;case 16:t.t1=null;case 17:t.t2=t.t1,(0,t.t0)(t.t2),t.next=24;break;case 21:t.prev=21,t.t3=t.catch(3),r(t.t3);case 24:case"end":return t.stop()}}),t,null,[[3,21]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var e=this;return new TC.CancellablePromise(function(){var t=Ia(Kc.mark((function t(n,r,i){var a;return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===e.services.mcsClient&&r(new Error("Media Content Service is unavailable")),a=e.services.mcsClient.get(e.state.sid),i((function(){return a.cancel()})),t.prev=3,t.next=6,a;case 6:e.mcsMedia=t.sent,e.state=e.mcsMedia._state(),n(e.mcsMedia),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(3),r(t.t0);case 14:case"end":return t.stop()}}),t,null,[[3,11]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"_state",value:function(){return this.state}}]),Media}(),AggregatedDeliveryReceipt=function(){function AggregatedDeliveryReceipt(e){Na(this,AggregatedDeliveryReceipt),this.state=e}return Ua(AggregatedDeliveryReceipt,[{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(e){this.state=e}},{key:"_isEquals",value:function(e){var t=this.total===e.total,n=this.sent===e.sent,r=this.delivered===e.delivered,i=this.read===e.read,a=this.undelivered===e.undelivered,o=this.failed===e.failed;return t&&n&&r&&i&&a&&o}}]),AggregatedDeliveryReceipt}(),uj=function(){function e(t,n,r,i){Na(this,e),this.state={prevToken:r,nextToken:i,source:n,items:t}}return Ua(e,[{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"))}}]),e}(),DetailedDeliveryReceipt=Ua((function DetailedDeliveryReceipt(e){Na(this,DetailedDeliveryReceipt),this.sid=e.sid,this.messageSid=e.message_sid,this.conversationSid=e.conversation_sid,this.channelMessageSid=e.channel_message_sid,this.participantSid=e.participant_sid,this.status=e.status||"queued",this.errorCode=e.error_code||0,this.dateCreated=e.date_created,this.dateUpdated=e.date_updated})),cj={};function lj(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}Object.defineProperty(cj,"__esModule",{value:!0});var fj=lj(Sf.exports),dj=function(e){var t=fj.default.getLevel();fj.default.setLevel("warn"),fj.default.warn(e),fj.default.setLevel(t)},pj=cj.deprecated=function(e,t,n){return function(r,i,a){if("function"!=typeof a.value&&void 0===(null==a?void 0:a.get))throw new Error("The deprecated decorator can only be applied to methods or getters");if("function"!=typeof a.value){var o=a.get;a.get=function(){return dj("The getter ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),null==o?void 0:o.apply(this)}}else{var s=a.value;a.value=function(){dj("The method ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:"."));for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return s.apply(this,i)}}}},hj=cj.deprecationWarning=dj,vj=function(e){return e.map((function(e){var t,n,r,i,a=JSON.stringify(e);switch(e.type){case"QUICK_REPLY":return{type:"reply",title:e.title,id:null!==(t=e.id)&&void 0!==t?t:"",index:null!==(n=e.index)&&void 0!==n?n:0,rawData:a};case"PHONE_NUMBER":return{type:"phone",title:e.title,phone:null!==(r=e.phone)&&void 0!==r?r:"",rawData:a};case"URL":return{type:"url",title:e.title,url:null!==(i=e.url)&&void 0!==i?i:"",rawData:a};default:return{type:"other",rawData:a}}}))},yj=function(e,t){var n=JSON.stringify(t);switch(e){case"twilio/text":return{type:"text",body:t.body,rawData:n};case"twilio/media":var r=t;return{type:"media",body:r.body,media:r.media,rawData:n};case"twilio/location":var i=t;return{type:"location",longitude:i.longitude,latitude:i.latitude,label:i.label,rawData:n};case"twilio/quick-reply":var a=t;return{type:"quickReply",body:a.body,replies:a.actions,rawData:n};case"twilio/call-to-action":var o=t;return{type:"callToAction",body:o.body,actions:vj(o.actions),rawData:n};case"twilio/list-picker":var s=t;return{type:"listPicker",body:s.body,button:s.button,items:s.items,rawData:n};case"twilio/card":var u,c,l=t;return{type:"card",title:l.title,subtitle:l.subtitle,media:null!==(u=l.media)&&void 0!==u?u:[],actions:vj(null!==(c=l.actions)&&void 0!==c?c:[]),rawData:n};default:return{type:"other",rawData:n}}},ContentTemplateVariable=function(){function ContentTemplateVariable(e,t){Na(this,ContentTemplateVariable),this.name=e,this.value=t}return Ua(ContentTemplateVariable,[{key:"copyWithValue",value:function(e){return new ContentTemplateVariable(this.name,e)}}]),ContentTemplateVariable}(),gj=Ua((function e(t){Na(this,e),this.sid=t.sid,this.friendlyName=t.friendly_name,this.variables=Object.entries(JSON.parse(t.variables)).map((function(e){var t=dg(e,2),n=t[0],r=t[1];return new ContentTemplateVariable(n,r)})),this.variants=function(e){for(var t=new Map,n=0,r=Object.entries(e);n<r.length;n++){var i=dg(r[n],2),a=i[0],o=i[1];t.set(a,yj(a,o))}return t}(t.variants),this.dateCreated=new Date(t.date_created),this.dateUpdated=new Date(t.date_updated)}));function mj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function bj(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mj(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mj(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function wj(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}function kj(e,t){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.add(e)}function _j(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}var xj=Cf.scope("Message"),Sj=t.XMLHttpRequest||{},Ej=new WeakSet,Rj=new WeakSet,Message=function(e){Oa(Message,e);var t,n,r,i,a,o,s,u,c,l=wj(Message);function Message(e,t,n,r,i,a){var o,s,u,c,f,d,p,h;return Na(this,Message),kj(Ta(h=l.call(this)),Rj),kj(Ta(h),Ej),h.conversation=n,h.links=r,h.configuration=i,h.services=a,h.state={sid:t.sid,index:e,author:t.author,subject:t.subject,contentSid:t.contentSid,body:null!==(o=t.text)&&void 0!==o?o:null,timestamp:t.timestamp?new Date(t.timestamp):null,dateUpdated:t.dateUpdated?new Date(t.dateUpdated):null,lastUpdatedBy:null!==(s=t.lastUpdatedBy)&&void 0!==s?s:null,attributes:yh(t.attributes,"Got malformed attributes for the message ".concat(t.sid),xj),type:null!==(u=t.type)&&void 0!==u?u:"text",media:null,medias:null,participantSid:null!==(c=t.memberSid)&&void 0!==c?c:null,aggregatedDeliveryReceipt:t.delivery?new AggregatedDeliveryReceipt(t.delivery):null,hasChannelMetadata:null!==(f=t.channelMetadata)&&void 0!==f&&f},_j(Ta(h),Rj,Tj).call(Ta(h),null!==(d=t.medias)&&void 0!==d?d:null,null!==(p=t.media)&&void 0!==p?p:null),h}return Ua(Message,[{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(e){return this.getMediaByCategories(e)}},{key:"getMediaByCategories",value:function(e){var t;return(null!==(t=this.state.medias)&&void 0!==t?t:[]).filter((function(t){return e.includes(t.category)}))}},{key:"getEmailBody",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!==(e=null===(t=this.getMediaByCategories(["body"]))||void 0===t?void 0:t.filter((function(e){return e.contentType==n})).shift())&&void 0!==e?e:null}},{key:"getEmailHistory",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!==(e=null===(t=this.getMediaByCategories(["history"]))||void 0===t?void 0:t.filter((function(e){return e.contentType==n})).shift())&&void 0!==e?e:null}},{key:"_update",value:function(e){var t,n,r,i,a=this,o=[];!e.text&&"string"!=typeof e.text||e.text===this.state.body||(this.state.body=e.text,o.push("body")),e.subject&&e.subject!==this.state.subject&&(this.state.subject=e.subject,o.push("subject")),e.lastUpdatedBy&&e.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=e.lastUpdatedBy,o.push("lastUpdatedBy")),e.author&&e.author!==this.state.author&&(this.state.author=e.author,o.push("author")),e.dateUpdated&&new Date(e.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(e.dateUpdated),o.push("dateUpdated")),e.timestamp&&new Date(e.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(e.timestamp),o.push("dateCreated"));var s=yh(e.attributes,"Got malformed attributes for the message ".concat(this.sid),xj);mh(this.state.attributes,s)||(this.state.attributes=s,o.push("attributes"));var u,c,l=e.delivery,f=this.state.aggregatedDeliveryReceipt;(!!(l&&l.total&&l.delivered&&l.failed&&l.read&&l.sent&&l.undelivered)&&(f?f._isEquals(l)||(f._update(l),o.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new AggregatedDeliveryReceipt(l),o.push("deliveryReceipt"))),mh((null!==(t=e.medias)&&void 0!==t?t:[]).map((function(e){var t;return null===(t=_j(a,Ej,Ij).call(a,e))||void 0===t?void 0:t._state()})).filter((function(e){return!(null===e)})),(null!==(n=this.state.medias)&&void 0!==n?n:[]).map((function(e){return e._state()})).filter((function(e){return!(null===e)})))&&mh(null===(r=_j(this,Ej,Ij).call(this,e.media))||void 0===r?void 0:r._state(),null===(i=this.state.media)||void 0===i?void 0:i._state()))||(_j(this,Rj,Tj).call(this,null!==(u=e.medias)&&void 0!==u?u:null,null!==(c=e.media)&&void 0!==c?c:null),o.push("media"));o.length>0&&this.emit("updated",{message:this,updateReasons:o})}},{key:"getParticipant",value:(c=Ia(Kc.mark((function e(){var t,n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=null,!this.state.participantSid){e.next=5;break}return e.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch((function(){return xj.debug('Participant with sid "'.concat(r.participantSid,'" not found for message ').concat(r.sid)),null}));case 4:t=e.sent;case 5:if(t||!this.state.author){e.next=9;break}return e.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch((function(){return xj.debug('Participant with identity "'.concat(r.author,'" not found for message ').concat(r.sid)),null}));case 8:t=e.sent;case 9:if(!t){e.next=11;break}return e.abrupt("return",t);case 11:throw n="Participant with ",this.state.participantSid&&(n+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(n+="or "),n+="identity '"+this.state.author+"' "),"Participant with "===n&&(n="Participant "),n+="was not found",new Error(n);case 17:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getDetailedDeliveryReceipts",value:(u=Ia(Kc.mark((function e(){var t,n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:t=e.sent,n=t.items;case 4:if(!t.hasNextPage){e.next=11;break}return e.next=7,t.nextPage();case 7:t=e.sent,n=[].concat(xy(n),xy(t.items)),e.next=4;break;case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"remove",value:(s=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"updateBody",value:(o=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:t});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"updateAttributes",value:(a=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:void 0!==t?JSON.stringify(t):void 0});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"attachTemporaryUrlsFor",value:(i=Ia(Kc.mark((function e(t){var n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=null==t?void 0:t.map((function(e){return e.sid})),!this.services.mcsClient||!n){e.next=7;break}return e.next=4,this.services.mcsClient.mediaSetGet(n);case 4:return e.abrupt("return",e.sent.map((function(e){return new Media(e,r.services)})));case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getTemporaryContentUrlsForMedia",value:function(e){var t=e.map((function(e){return e.sid}));return this.getTemporaryContentUrlsForMediaSids(t)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(e){var t=this;return new TC.CancellablePromise(function(){var n=Ia(Kc.mark((function n(r,i,a){var o,s;return Kc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=t.services.mcsClient.mediaSetGetContentUrls(null!=e?e:[]),t.services.mcsClient&&e){n.next=4;break}return i(new Error("Media Content Service is unavailable")),n.abrupt("return");case 4:return a((function(){o.cancel()})),n.prev=5,n.next=8,o;case 8:s=n.sent,r(s),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[5,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var e,t=this.attachedMedia,n=null!==(e=null==t?void 0:t.map((function(e){return e.sid})))&&void 0!==e?e:[];return this.getTemporaryContentUrlsForMediaSids(n)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:(r=Ia(Kc.mark((function e(t){var n,r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),r=new gh(n).arg("PageToken",null==t?void 0:t.pageToken).arg("PageSize",null==t?void 0:t.pageSize).build(),e.next=4,this.services.network.get(r);case 4:return i=e.sent,e.abrupt("return",new uj(i.body.delivery_receipts.map((function(e){return new DetailedDeliveryReceipt(e)})),(function(e,t){return a._getDetailedDeliveryReceiptsPaginator({pageToken:e,pageSize:t})}),i.body.meta.previous_token,i.body.meta.next_token));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getContentData",value:function(){var e=this;return new TC.CancellablePromise(function(){var t=Ia(Kc.mark((function t(n,r,i){var a,o,s,u,c,l,f,d,p,h;return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==e.state.contentSid){t.next=3;break}return n(null),t.abrupt("return");case 3:if(null!==(a=e.getMediaByCategories(["body"]))){t.next=7;break}return n(null),t.abrupt("return");case 7:if(o="application/x-vnd.com.twilio.rich.",0!==(s=a.filter((function(e){return e.contentType.startsWith(o)}))).length){t.next=12;break}return n(null),t.abrupt("return");case 12:return u=s[0],c=u.getContentTemporaryUrl(),i((function(){c.cancel()})),t.prev=15,t.next=18,c;case 18:l=t.sent,t.next=25;break;case 21:return t.prev=21,t.t0=t.catch(15),r(t.t0),t.abrupt("return");case 25:if(null!==l){t.next=28;break}return n(null),t.abrupt("return");case 28:return f=new Promise((function(e,t){var n,r=!1,a=new Sj;a.open("GET",null!==(n=l)&&void 0!==n?n:"",!0),a.responseType="text",a.onreadystatechange=function(){4!==a.readyState||r||e(a.responseText)},a.onerror=function(){t(a.statusText)},i((function(){r=!0,a.abort(),t(new Error("XHR has been aborted"))})),a.send()})),t.prev=29,t.next=32,f;case 32:p=t.sent,d=JSON.parse(p),t.next=40;break;case 36:return t.prev=36,t.t1=t.catch(29),r(t.t1),t.abrupt("return");case 40:h=u.contentType.replace(o,"").replace(".","/"),n(yj(h,d.data));case 42:case"end":return t.stop()}}),t,null,[[15,21],[29,36]])})));return function(e,n,r){return t.apply(this,arguments)}}())}},{key:"getChannelMetadata",value:(n=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state.hasChannelMetadata){e.next=2;break}return e.abrupt("return",null);case 2:return e.next=4,this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid,this.sid);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getMessageRecipients",value:(t=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid,this.sid);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),Message}(cg);function Ij(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e?new Media(t?bj(bj({},e),{},{category:t}):e,this.services):null}function Tj(e,t){var n=this;this.state.media=_j(this,Ej,Ij).call(this,t),this.state.medias=e?e.map((function(e){return _j(n,Ej,Ij).call(n,e)})).filter((function(e){return null!==e})):t&&!e?[_j(this,Ej,Ij).call(this,t,"media")].filter((function(e){return null!==e})):null}function Cj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Oj(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Cj(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cj(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Pj(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Aj(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Aj(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Aj(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function jj(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}Ma(Message,"updated","updated"),$c([pj("getMediaByCategory","getMediaByCategories"),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",Array)],Message.prototype,"getMediaByCategory",null),$c([by([hy,"undefined"]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Media)],Message.prototype,"getEmailBody",null),$c([by([hy,"undefined"]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Media)],Message.prototype,"getEmailHistory",null),$c([wy("string"),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Message.prototype,"updateBody",null),$c([wy(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],Message.prototype,"updateAttributes",null),$c([pj("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",Promise)],Message.prototype,"attachTemporaryUrlsFor",null),$c([wy(py("media",Media)),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",TC.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMedia",null),$c([wy(py("strings","string")),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",TC.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMediaSids",null);var Mj=Cf.scope("Messages"),Lj=function(e){Oa(u,e);var t,n,r,i,a,o,s=jj(u);function u(e,t,n){var r;return Na(this,u),(r=s.call(this)).conversation=e,r.configuration=t,r.services=n,r.messagesByIndex=new Map,r.messagesListPromise=null,r}return Ua(u,[{key:"subscribe",value:(o=Ia(Kc.mark((function e(t){var n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesListPromise){e.next=2;break}return e.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise="string"==typeof t?this.services.syncClient.list({id:t,mode:"open_existing"}):Promise.resolve(t),e.prev=3,e.next=6,this.messagesListPromise;case 6:return(n=e.sent).on("itemAdded",(function(e){Mj.debug("".concat(r.conversation.sid," itemAdded: ").concat(e.item.index));var t={self:"".concat(r.conversation._links.messages,"/").concat(e.item.data.sid),conversation:r.conversation._links.self,messages_receipts:"".concat(r.conversation._links.messages,"/").concat(e.item.data.sid,"/Receipts")},n=new Message(e.item.index,e.item.data,r.conversation,t,r.configuration,r.services);r.messagesByIndex.has(n.index)?Mj.debug("Message arrived, but is already known and ignored",r.conversation.sid,n.index):(r.messagesByIndex.set(n.index,n),n.on("updated",(function(e){return r.emit("messageUpdated",e)})),r.emit("messageAdded",n))})),n.on("itemRemoved",(function(e){Mj.debug("#{this.conversation.sid} itemRemoved: ".concat(e.index));var t=e.index;if(r.messagesByIndex.has(t)){var n=r.messagesByIndex.get(t);if(!n)return;r.messagesByIndex.delete(n.index),n.removeAllListeners("updated"),r.emit("messageRemoved",n)}})),n.on("itemUpdated",(function(e){Mj.debug("".concat(r.conversation.sid," itemUpdated: ").concat(e.item.index));var t=r.messagesByIndex.get(e.item.index);t&&t._update(e.item.data)})),e.abrupt("return",n);case 13:throw e.prev=13,e.t0=e.catch(3),this.messagesListPromise=null,"disconnected"!==this.services.syncClient.connectionState&&Mj.error("Failed to get messages object for conversation",this.conversation.sid,e.t0),Mj.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,e.t0),e.t0;case 19:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(e){return o.apply(this,arguments)})},{key:"unsubscribe",value:(a=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.messagesListPromise){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.messagesListPromise;case 4:e.sent.close(),this.messagesListPromise=null;case 7:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"sendV2",value:function(e){var t=this;return Mj.debug("Sending message V2",e.mediaContent,e.attributes,e.emailOptions),new TC.CancellablePromise(function(){var n=Ia(Kc.mark((function n(r,i,a){var o,s,u,c,l,f,d,p,h,v,y,g;return Kc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:s=[],u=[],a((function(){u.forEach((function(e){return e.cancel()}))})),c=Pj(e.mediaContent),n.prev=4,c.s();case 6:if((l=c.n()).done){n.next=25;break}return f=dg(l.value,2),d=f[0],p=f[1],n.prev=8,Mj.debug("Adding media to a message as ".concat(p instanceof FormData?"FormData":"SendMediaOptions"),p),y=p instanceof FormData?t.services.mcsClient.postFormData(p,d):t.services.mcsClient.post(null!==(h=p.contentType)&&void 0!==h?h:"",null!==(v=p.media)&&void 0!==v?v:"",d,p.filename),u.push(y),n.t0=s,n.next=15,y;case 15:n.t1=n.sent,n.t0.push.call(n.t0,n.t1),n.next=23;break;case 19:return n.prev=19,n.t2=n.catch(8),i(n.t2),n.abrupt("return");case 23:n.next=6;break;case 25:n.next=30;break;case 27:n.prev=27,n.t3=n.catch(4),c.e(n.t3);case 30:return n.prev=30,c.f(),n.finish(30);case 33:return g=t.services.commandExecutor.mutateResource("post",t.conversation._links.messages,{body:e.text,subject:null===(o=e.emailOptions)||void 0===o?void 0:o.subject,media_sids:s.map((function(e){return e.sid})),attributes:void 0!==e.attributes?JSON.stringify(e.attributes):void 0,content_sid:e.contentSid,content_variables:void 0!==e.contentVariables?JSON.stringify(e.contentVariables.reduce((function(e,t){return Oj(Oj({},e),{},Ma({},t.name,t.value))}),{})):void 0}),n.prev=34,n.t4=r,n.next=38,g;case 38:n.t5=n.sent,(0,n.t4)(n.t5),n.next=45;break;case 42:n.prev=42,n.t6=n.catch(34),i(n.t6);case 45:case"end":return n.stop()}}),n,null,[[4,27,30,33],[8,19],[34,42]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"send",value:(i=Ia(Kc.mark((function e(t){var n,r,i=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},r=i.length>2?i[2]:void 0,Mj.debug("Sending text message",t,n,r),e.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:null!=t?t:"",attributes:void 0!==n?JSON.stringify(n):void 0,subject:null==r?void 0:r.subject}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendMedia",value:(r=Ia(Kc.mark((function e(t){var n,r,i,a,o,s=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=s.length>1&&void 0!==s[1]?s[1]:{},a=s.length>2?s[2]:void 0,Mj.debug("Sending media message",t,i,a),Mj.debug("Sending media message as ".concat(t instanceof FormData?"FormData":"SendMediaOptions"),t,i),!(t instanceof FormData)){e.next=10;break}return e.next=7,this.services.mcsClient.postFormData(t);case 7:e.t0=e.sent,e.next=13;break;case 10:return e.next=12,this.services.mcsClient.post(null!==(n=t.contentType)&&void 0!==n?n:"",null!==(r=t.media)&&void 0!==r?r:"","media",t.filename);case 12:e.t0=e.sent;case 13:return o=e.t0,e.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[o.sid],attributes:void 0!==i?JSON.stringify(i):void 0});case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"getMessages",value:(n=Ia(Kc.mark((function e(t,n){var r,i=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>2&&void 0!==i[2]?i[2]:"backwards",e.abrupt("return",this._getMessages(t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_wrapPaginator",value:function(e,t,n){var r=this,i="desc"===e,a=function(){return t.nextPage().then((function(t){return r._wrapPaginator(e,t,n)}))},o=function(){return t.prevPage().then((function(t){return r._wrapPaginator(e,t,n)}))};return n(t.items).then((function(e){return{items:e.sort((function(e,t){return e.index-t.index})),hasPrevPage:i?t.hasNextPage:t.hasPrevPage,hasNextPage:i?t.hasPrevPage:t.hasNextPage,prevPage:i?a:o,nextPage:i?o:a}}))}},{key:"_upsertMessage",value:function(e,t){var n=this,r=this.messagesByIndex.get(e);if(r)return r;var i={self:"".concat(this.conversation._links.messages,"/").concat(t.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(t.sid,"/Receipts")},a=new Message(e,t,this.conversation,i,this.configuration,this.services);return this.messagesByIndex.set(a.index,a),a.on("updated",(function(e){return n.emit("messageUpdated",e)})),a}},{key:"_getMessages",value:(t=Ia(Kc.mark((function e(){var t,n,r,i,a,o,s=this,u=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:30,n=u.length>1&&void 0!==u[1]?u[1]:"end",r=u.length>2&&void 0!==u[2]?u[2]:"forward",i="backwards"===r?"desc":"asc",e.next=6,this.messagesListPromise;case 6:return a=e.sent,e.next=9,null==a?void 0:a.getItems({from:"end"!==n?n:void 0,pageSize:t,order:i,limit:t});case 9:return o=e.sent,e.next=12,this._wrapPaginator(i,o,(function(e){return Promise.all(e.map((function(e){return s._upsertMessage(e.index,e.data)})))}));case 12:return e.abrupt("return",e.sent);case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),u}(cg),Uj=function(){function e(t){Na(this,e),Ma(this,"attributes",{}),Ma(this,"mediaContent",[]),Ma(this,"emailOptions",{}),this.messagesEntity=t}return Ua(e,[{key:"send",value:function(){var e=this;return new TC.CancellablePromise(function(){var t=Ia(Kc.mark((function t(n,r,i){var a,o;return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.messagesEntity.sendV2(e),i((function(){return a.cancel()})),t.prev=2,t.next=5,a;case 5:o=t.sent,n(hh(o.index)),t.next=12;break;case 9:t.prev=9,t.t0=t.catch(2),r(t.t0);case 12:case"end":return t.stop()}}),t,null,[[2,9]])})));return function(e,n,r){return t.apply(this,arguments)}}())}}]),e}(),Nj=function(){function e(t,n){Na(this,e),this.limits=t,this.message=new Uj(n),this.emailBodies=new Map,this.emailHistories=new Map}return Ua(e,[{key:"setBody",value:function(e){return this.message.text=e,this}},{key:"setSubject",value:function(e){return this.message.emailOptions.subject=e,this}},{key:"setAttributes",value:function(e){return this.message.attributes=e,this}},{key:"setEmailBody",value:function(e,t){return this.emailBodies.set(e,t),this}},{key:"setEmailHistory",value:function(e,t){return this.emailHistories.set(e,t),this}},{key:"setContentTemplate",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return this.message.contentSid=e,this.message.contentVariables=t,this}},{key:"addMedia",value:function(e){if("undefined"==typeof FormData&&e instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(e instanceof FormData)){var t=e;if(!t.contentType||!t.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",e]),this}},{key:"build",value:function(){var e=this;if(this.emailBodies.forEach((function(t,n){if(!e.limits.emailBodiesAllowedContentTypes.includes(n))throw new Error("Unsupported email body content type ".concat(n))})),this.emailHistories.forEach((function(t,n){if(!e.limits.emailHistoriesAllowedContentTypes.includes(n))throw new Error("Unsupported email history content type ".concat(n))})),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(t){e.message.mediaContent.push(["body",t])})),this.emailHistories.forEach((function(t){e.message.mediaContent.push(["history",t])})),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),e}();function Dj(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Fj(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fj(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Fj(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Bj(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}$c([by("string"),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Nj)],Nj.prototype,"setBody",null),$c([by("string"),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Nj)],Nj.prototype,"setSubject",null),$c([by(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Nj)],Nj.prototype,"setAttributes",null),$c([by("string",[FormData,Ry]),Gc("design:type",Function),Gc("design:paramtypes",[String,Object]),Gc("design:returntype",Nj)],Nj.prototype,"setEmailBody",null),$c([by("string",[FormData,Ry]),Gc("design:type",Function),Gc("design:paramtypes",[String,Object]),Gc("design:returntype",Nj)],Nj.prototype,"setEmailHistory",null),$c([by("string",[ly("content variables",ContentTemplateVariable),"undefined"]),Gc("design:type",Function),Gc("design:paramtypes",[String,Array]),Gc("design:returntype",Nj)],Nj.prototype,"setContentTemplate",null),$c([by([FormData,Ry]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Nj)],Nj.prototype,"addMedia",null);var qj={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"},Conversation=function(e){Oa(Conversation,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g,m,b,w,k,_,x,S,E,R,I,T,C,O=Bj(Conversation);function Conversation(e,t,n,r,i){var a,o,s;Na(this,Conversation),(s=O.call(this)).sid=t,s._links=n,s._configuration=r,s._services=i,s._entityName=e.channel,s._internalState={uniqueName:e.uniqueName||null,status:"notParticipating",attributes:null!==(a=e.attributes)&&void 0!==a?a:{},createdBy:e.createdBy,dateCreated:vh(e.dateCreated),dateUpdated:vh(e.dateUpdated),friendlyName:e.friendlyName||null,lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,bindings:null!==(o=e.bindings)&&void 0!==o?o:{}},e.notificationLevel&&(s._internalState.notificationLevel=e.notificationLevel);var u={participants:s._links.participants};return s._participants=new Map,s._participantsEntity=new zA(Ta(s),s._participants,u,s._services),s._participantsEntity.on(Conversation.participantJoined,(function(e){return s.emit(Conversation.participantJoined,e)})),s._participantsEntity.on(Conversation.participantLeft,(function(e){return s.emit(Conversation.participantLeft,e)})),s._participantsEntity.on(Conversation.participantUpdated,(function(e){return s.emit(Conversation.participantUpdated,e)})),s._messagesEntity=new Lj(Ta(s),r,i),s._messagesEntity.on(Conversation.messageAdded,(function(e){return s._onMessageAdded(e)})),s._messagesEntity.on(Conversation.messageUpdated,(function(e){return s.emit(Conversation.messageUpdated,e)})),s._messagesEntity.on(Conversation.messageRemoved,(function(e){return s.emit(Conversation.messageRemoved,e)})),s}return Ua(Conversation,[{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 e;return null!==(e=this._internalState.createdBy)&&void 0!==e?e:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var e;return null!==(e=this._internalState.lastMessage)&&void 0!==e?e:void 0}},{key:"notificationLevel",get:function(){var e;return null!==(e=this._internalState.notificationLevel)&&void 0!==e?e:"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:(C=Ia(Kc.mark((function e(t,n){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._participantsEntity.add(t,null!=n?n:{}));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return C.apply(this,arguments)})},{key:"addNonChatParticipant",value:(T=Ia(Kc.mark((function e(t,n){var r,i,a=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>2&&void 0!==a[2]?a[2]:{},i=a.length>3&&void 0!==a[3]?a[3]:{},e.abrupt("return",this._participantsEntity.addNonChatParticipant(t,n,null!=r?r:{},null!=i?i:{}));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"advanceLastReadMessageIndex",value:(I=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:if(!(t<(null!==(n=this.lastReadMessageIndex)&&void 0!==n?n:0))){e.next=6;break}return e.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:case 8:return e.abrupt("return",e.sent);case 6:return e.next=8,this._setLastReadMessageIndex(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return I.apply(this,arguments)})},{key:"delete",value:(R=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return R.apply(this,arguments)})},{key:"getAttributes",value:(E=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return e.abrupt("return",this.attributes);case 3:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"getMessages",value:(S=Ia(Kc.mark((function e(t,n,r){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._messagesEntity.getMessages(t,n,r));case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return S.apply(this,arguments)})},{key:"getParticipants",value:(x=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return e.stop()}}),e,this)}))),function(){return x.apply(this,arguments)})},{key:"getParticipantsCount",value:(_=Ia(Kc.mark((function e(){var t,n,r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gh(this._configuration.links.conversations).path(this.sid).build(),e.next=3,this._services.network.get(n);case 3:return r=e.sent,e.abrupt("return",null!==(t=r.body.participants_count)&&void 0!==t?t:0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{key:"getParticipantBySid",value:(k=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._participantsEntity.getParticipantBySid(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(w=Ia(Kc.mark((function e(){var t,n=arguments;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]?n[0]:"",e.abrupt("return",this._participantsEntity.getParticipantByIdentity(null!=t?t:""));case 2:case"end":return e.stop()}}),e,this)}))),function(){return w.apply(this,arguments)})},{key:"getMessagesCount",value:(b=Ia(Kc.mark((function e(){var t,n,r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gh(this._configuration.links.conversations).path(this.sid).build(),e.next=3,this._services.network.get(n);case 3:return r=e.sent,e.abrupt("return",null!==(t=r.body.messages_count)&&void 0!==t?t:0);case 5:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"getUnreadMessagesCount",value:(m=Ia(Kc.mark((function e(){var t,n,r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new gh(this._configuration.links.myConversations).path(this.sid).build(),e.next=3,this._services.network.get(t);case 3:if((n=e.sent).body.conversation_sid===this.sid){e.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if("number"!=typeof(r=n.body.unread_messages_count)){e.next=9;break}return e.abrupt("return",r);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"join",value:(g=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(){return g.apply(this,arguments)})},{key:"leave",value:(y=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("joined"!==this._internalState.status){e.next=3;break}return e.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"removeParticipant",value:(v=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._participantsEntity.remove("string"==typeof t?t:t.sid);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"sendMessage",value:(h=Ia(Kc.mark((function e(t,n,r){var i,a,o,s;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t&&null!==t){e.next=5;break}return e.next=3,this._messagesEntity.send(t,n,r);case 3:return o=e.sent,e.abrupt("return",null!==(a=hh(o.index))&&void 0!==a?a:0);case 5:return e.next=7,this._messagesEntity.sendMedia(t,n,r);case 7:return s=e.sent,e.abrupt("return",null!==(i=hh(s.index))&&void 0!==i?i:0);case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return h.apply(this,arguments)})},{key:"prepareMessage",value:function(){return new Nj(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:(p=Ia(Kc.mark((function e(){var t;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this.getMessages(1);case 4:if(!((t=e.sent).items.length>0)){e.next=7;break}return e.abrupt("return",this.advanceLastReadMessageIndex(t.items[0].index));case 7:return e.abrupt("return",0);case 8:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"setAllMessagesUnread",value:(d=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this._setLastReadMessageIndex(null);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"setUserNotificationLevel",value:(f=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:t});case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:(l=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:void 0!==t?JSON.stringify(t):void 0});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"updateFriendlyName",value:(c=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._internalState.friendlyName===t){e.next=3;break}return e.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:t});case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateLastReadMessageIndex",value:(u=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this._setLastReadMessageIndex(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"updateUniqueName",value:(s=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._internalState.uniqueName===t){e.next=4;break}return t||(t=""),e.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:t});case 4:return e.abrupt("return",this);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getMessageRecipients",value:(o=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_subscribe",value:(a=Ia(Kc.mark((function e(){var t=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._entityPromise){e.next=2;break}return e.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),e.prev=3,e.next=6,this._entityPromise;case 6:return this._entity=e.sent,this._entity.on(EC.updated,(function(e){return t._update(e.data)})),this._entity.on(EC.removed,(function(){return t.emit(Conversation.removed,t)})),this._update(this._entity.data),e.abrupt("return",this._entity);case 13:throw e.prev=13,e.t0=e.catch(3),this._entity=null,this._entityPromise=null,"disconnected"!=this._services.syncClient.connectionState&&Conversation._logger.error("Failed to get conversation object",e.t0),Conversation._logger.debug("ERROR: Failed to get conversation object",e.t0),e.t0;case 20:case"end":return e.stop()}}),e,this,[[3,13]])}))),function(){return a.apply(this,arguments)})},{key:"_fetchStreams",value:(i=Ia(Kc.mark((function e(){var t=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._streamsPromise){e.next=2;break}return e.abrupt("return",this._streamsPromise);case 2:return this._streamsPromise=new Promise(function(){var e=Ia(Kc.mark((function e(n,r){var i,a,o,s,u;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t._subscribe();case 3:e.next=9;break;case 5:return e.prev=5,e.t0=e.catch(0),Conversation._logger.trace("Failed to subscribe to conversation",e.t0),e.abrupt("return",r(e.t0));case 9:Conversation._logger.trace("_streamsAvailable, this.entity.data=",null===(i=t._entity)||void 0===i?void 0:i.data),o=null===(a=t._entity)||void 0===a?void 0:a.data,s=t._services.syncClient.list({id:o.messages,mode:"open_existing"}).then((function(e){return t._messagesList=e,e})),u=t._services.syncClient.map({id:o.roster,mode:"open_existing"}).then((function(e){return t._participantsMap=e,e})),Promise.all([s,u]).then((function(){return n(!0)})).catch((function(e){Conversation._logger.trace("Failed to fetch conversation streams for conversation",t.sid,e),r(e)}));case 14:case"end":return e.stop()}}),e,null,[[0,5]])})));return function(t,n){return e.apply(this,arguments)}}()),e.abrupt("return",this._streamsPromise.catch((function(e){throw t._streamsPromise=null,e})));case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_subscribeStreams",value:(r=Ia(Kc.mark((function e(){var t,n,r,i,a,o,s;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._fetchStreams();case 3:return Conversation._logger.trace("_subscribeStreams, this.entity.data=",null===(t=this._entity)||void 0===t?void 0:t.data),a=null===(n=this._entity)||void 0===n?void 0:n.data,o=a.messages,s=a.roster,e.next=9,Promise.all([this._messagesEntity.subscribe(null!==(r=this._messagesList)&&void 0!==r?r:o),this._participantsEntity.subscribe(null!==(i=this._participantsMap)&&void 0!==i?i:s)]);case 9:e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(0),"disconnected"!==this._services.syncClient.connectionState&&Conversation._logger.error("Failed to subscribe on conversation objects",this.sid,e.t0),Conversation._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,11]])}))),function(){return r.apply(this,arguments)})},{key:"_unsubscribe",value:(n=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._entity&&(this._entity.close(),this._entity=null,this._entityPromise=null),e.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_setStatus",value:function(e,t){var n=this;this._dataSource=t,this._internalState.status!==e&&(this._internalState.status=e,"joined"!==e?this._entityPromise&&this._unsubscribe().catch((function(t){if(Conversation._logger.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n._services.syncClient.connectionState)throw t})):this._subscribeStreams().catch((function(t){if(Conversation._logger.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n._services.syncClient.connectionState)throw t})))}},{key:"_update",value:function(e){var t,n,r,i,a;Conversation._logger.trace("_update",e),Conversation.preprocessUpdate(e,this.sid);for(var o=new Set,s=0,u=Object.keys(e);s<u.length;s++){var c=u[s],l=qj[c];if(l)switch(l){case qj.status:if(!e.status||"unknown"===e.status||this._internalState.status===e.status)break;this._internalState.status=e.status,o.add(l);break;case qj.attributes:if(mh(this._internalState.attributes,e.attributes))break;this._internalState.attributes=e.attributes,o.add(l);break;case qj.lastConsumedMessageIndex:if(void 0===e.lastConsumedMessageIndex||e.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=e.lastConsumedMessageIndex,o.add("lastReadMessageIndex");break;case qj.lastMessage:if(this._internalState.lastMessage&&!e.lastMessage){delete this._internalState.lastMessage,o.add(l);break}this._internalState.lastMessage=this._internalState.lastMessage||{},void 0!==(null===(t=e.lastMessage)||void 0===t?void 0:t.index)&&e.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=e.lastMessage.index,o.add(l)),void 0!==(null===(n=e.lastMessage)||void 0===n?void 0:n.timestamp)&&(null===(r=this._internalState.lastMessage)||void 0===r||null===(i=r.dateCreated)||void 0===i?void 0:i.getTime())!==e.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=e.lastMessage.timestamp,o.add(l)),mh(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case qj.state:var f=e.state||void 0;if(void 0!==f&&(f.dateUpdated=new Date(f.dateUpdated)),mh(this._internalState.state,f))break;this._internalState.state=f,o.add(l);break;case qj.bindings:if(mh(this._internalState.bindings,e.bindings))break;this._internalState.bindings=e.bindings,o.add(l);break;default:var d=e[c]instanceof Date,p=d&&(null===(a=this._internalState[l])||void 0===a?void 0:a.getTime())===e[c].getTime(),h=!d&&this[l]===e[c];if(p||h)break;this._internalState[l]=e[c],o.add(l)}}o.size>0&&this.emit(Conversation.updated,{conversation:this,updateReasons:xy(o)})}},{key:"_onMessageAdded",value:function(e){var t,n=Dj(this._participants.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.identity===e.author){r._endTyping();break}}}catch(e){n.e(e)}finally{n.f()}this.emit(Conversation.messageAdded,e)}},{key:"_setLastReadMessageIndex",value:(t=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:t});case 2:return n=e.sent,e.abrupt("return",n.unread_messages_count);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"preprocessUpdate",value:function(e,t){try{"string"==typeof e.attributes?e.attributes=JSON.parse(e.attributes):e.attributes&&JSON.stringify(e.attributes)}catch(n){Conversation._logger.warn("Retrieved malformed attributes from the server for conversation: "+t),e.attributes={}}try{e.dateCreated&&(e.dateCreated=new Date(e.dateCreated))}catch(n){Conversation._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+t),delete e.dateCreated}try{e.dateUpdated&&(e.dateUpdated=new Date(e.dateUpdated))}catch(n){Conversation._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+t),delete e.dateUpdated}try{e.lastMessage&&e.lastMessage.timestamp&&(e.lastMessage.timestamp=new Date(e.lastMessage.timestamp))}catch(n){Conversation._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+t),delete e.lastMessage.timestamp}}}]),Conversation}(cg);Ma(Conversation,"participantJoined","participantJoined"),Ma(Conversation,"participantLeft","participantLeft"),Ma(Conversation,"participantUpdated","participantUpdated"),Ma(Conversation,"messageAdded","messageAdded"),Ma(Conversation,"messageRemoved","messageRemoved"),Ma(Conversation,"messageUpdated","messageUpdated"),Ma(Conversation,"typingEnded","typingEnded"),Ma(Conversation,"typingStarted","typingStarted"),Ma(Conversation,"updated","updated"),Ma(Conversation,"removed","removed"),Ma(Conversation,"_logger",Cf.scope("Conversation")),$c([wy(hy,Ey),Gc("design:type",Function),Gc("design:paramtypes",[String,Object]),Gc("design:returntype",Promise)],Conversation.prototype,"add",null),$c([wy(hy,hy,Ey,Ey),Gc("design:type",Function),Gc("design:paramtypes",[String,String,Object,Object]),Gc("design:returntype",Promise)],Conversation.prototype,"addNonChatParticipant",null),$c([wy(vy),Gc("design:type",Function),Gc("design:paramtypes",[Number]),Gc("design:returntype",Promise)],Conversation.prototype,"advanceLastReadMessageIndex",null),$c([wy(["undefined",vy],["undefined",vy],["undefined",dy("backwards","forward")]),Gc("design:type",Function),Gc("design:paramtypes",[Number,Number,String]),Gc("design:returntype",Promise)],Conversation.prototype,"getMessages",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"getParticipantBySid",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"getParticipantByIdentity",null),$c([wy([hy,Participant]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],Conversation.prototype,"removeParticipant",null),$c([wy(["string",FormData,dy(null),yy("media options",{contentType:hy,media:fy((function(e){var t="string"==typeof e&&e.length>0||e instanceof Uint8Array||e instanceof ArrayBuffer;return"function"==typeof Blob&&(t=t||e instanceof Blob),[t,"a non-empty string, an instance of Buffer or an instance of Blob"]}))})],Ey,["undefined",dy(null),yy("email attributes",{subject:[hy,"undefined"]})]),Gc("design:type",Function),Gc("design:paramtypes",[Object,Object,Object]),Gc("design:returntype",Promise)],Conversation.prototype,"sendMessage",null),$c([wy(dy("default","muted")),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"setUserNotificationLevel",null),$c([wy(Sy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],Conversation.prototype,"updateAttributes",null),$c([wy("string"),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"updateFriendlyName",null),$c([wy([dy(null),vy]),Gc("design:type",Function),Gc("design:paramtypes",[Number]),Gc("design:returntype",Promise)],Conversation.prototype,"updateLastReadMessageIndex",null),$c([wy(["string",dy(null)]),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],Conversation.prototype,"updateUniqueName",null);var zj=function(){function e(){var t=this;Na(this,e),this._promise=new Promise((function(e,n){t._resolve=e,t._reject=n}))}return Ua(e,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(e){this._resolve(e)}},{key:"set",value:function(e){this.current=e,this._resolve(e)}},{key:"fail",value:function(e){this._reject(e)}}]),e}();function Wj(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Kj(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Kj(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function Kj(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Vj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vj(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vj(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Gj(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}var Jj=Cf.scope("Conversations"),Hj=function(e){Oa(p,e);var t,n,r,i,a,o,s,u,c,l,f,d=Gj(p);function p(e,t){var n;return Na(this,p),Ma(Ta(n=d.call(this)),"conversations",new Map),Ma(Ta(n),"myConversationsRead",new zj),Ma(Ta(n),"tombstones",new Set),Ma(Ta(n),"myConversationsFetched",!1),n.configuration=e,n.services=t,n}return Ua(p,[{key:"addConversation",value:(f=Ia(Kc.mark((function e(t){var n,r,i,a,o,s,u,c,l,f;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=void 0!==(null==t?void 0:t.attributes)?t.attributes:{},e.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:t.friendlyName,unique_name:t.uniqueName,access:t.access,attributes:void 0!==a?JSON.stringify(a):void 0});case 3:if(o=e.sent,s=null!==(n=o.sid)&&void 0!==n?n:null,u=null!==(r=null===(i=o.sync_objects)||void 0===i?void 0:i.conversation)&&void 0!==r?r:null,c=$j({self:o.url},o.links),!(l=this.conversations.get(s))){e.next=12;break}return e.next=11,l._subscribe();case 11:return e.abrupt("return",l);case 12:return f=new Conversation({channel:u,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},s,c,this.configuration,this.services),this.conversations.set(f.sid,f),this._registerForEvents(f),e.next=17,f._subscribe();case 17:return this.emit("conversationAdded",f),e.abrupt("return",f);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"fetchConversations",value:(l=Ia(Kc.mark((function e(){var t,n,r,i,a,o,s,u=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._getMap();case 3:return(t=e.sent).on(RC.itemAdded,(function(e){Jj.debug("itemAdded: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),t.on(RC.itemRemoved,(function(e){Jj.debug("itemRemoved: ".concat(e.key));var t=e.key;u.myConversationsFetched||u.tombstones.add(t);var n=u.conversations.get(t);n&&("joined"===n.status&&(n._setStatus("notParticipating","sync"),u.emit("conversationLeft",n)),u.conversations.delete(t),u.emit("conversationRemoved",n),n.emit("removed",n))})),t.on(RC.itemUpdated,(function(e){Jj.debug("itemUpdated: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),e.next=9,this._fetchMyConversations();case 9:n=e.sent,r=[],i=Wj(n);try{for(i.s();!(a=i.n()).done;)o=a.value,r.push(this._upsertConversation("rest",o.channel_sid,o))}catch(e){i.e(e)}finally{i.f()}return this.myConversationsRead.set(!0),e.next=16,Promise.all(r);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),Jj.debug("The conversations list has been successfully fetched"),e.abrupt("return",this);case 22:throw e.prev=22,e.t0=e.catch(0),s="Failed to fetch the conversations list","disconnected"!==this.services.syncClient.connectionState&&Jj.error(s,e.t0),Jj.debug("ERROR: ".concat(s),e.t0),e.t0;case 28:case"end":return e.stop()}}),e,this,[[0,22]])}))),function(){return l.apply(this,arguments)})},{key:"getConversations",value:(c=Ia(Kc.mark((function e(){var t,n,r=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getMap();case 2:return t=e.sent,e.next=5,t.getItems();case 5:return n=e.sent,e.abrupt("return",this._wrapPaginator(n,(function(e){return Promise.all(e.map((function(e){return r._upsertConversation("sync",e.key,e.data)})))})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"getConversation",value:(u=Ia(Kc.mark((function e(t){var n,r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getMap();case 2:return n=e.sent,e.next=5,n.getItems({key:t});case 5:return r=e.sent,i=r.items.map((function(e){return a._upsertConversation("sync",e.key,e.data)})),e.abrupt("return",i.length>0?i[0]:null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getConversationByUniqueName",value:(s=Ia(Kc.mark((function e(t){var n,r,i,a,o;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gh(this.configuration.links.myConversations).path(t).build(),e.next=3,this.services.network.get(n);case 3:return r=e.sent,i=r.body,a=i.conversation_sid,o={entityName:null,lastConsumedMessageIndex:i.last_read_message_index,status:(null==i?void 0:i.status)||"unknown",friendlyName:i.friendly_name,dateUpdated:i.date_updated,dateCreated:i.date_created,uniqueName:i.unique_name,createdBy:i.created_by,attributes:i.attributes,channel:i.sync_objects.conversation,roster:i.sync_objects.participants,messages:i.sync_objects.messages,notificationLevel:null==i?void 0:i.notification_level,sid:a},e.abrupt("return",a?this._upsertConversation("sync",a,o):null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"peekConversation",value:(o=Ia(Kc.mark((function e(t){var n,r,i,a;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new gh(this.configuration.links.conversations).path(t).build(),e.next=3,this.services.network.get(n);case 3:return r=e.sent,i=r.body,a={entityName:null,status:(null==i?void 0:i.status)||"unknown",friendlyName:i.friendly_name,dateUpdated:i.date_updated,dateCreated:i.date_created,uniqueName:i.unique_name,createdBy:i.created_by,attributes:i.attributes,channel:i.sync_objects.conversation||"".concat(t,".channel"),roster:i.sync_objects.participants,messages:i.sync_objects.messages,notificationLevel:null==i?void 0:i.notification_level,sid:t},e.abrupt("return",this._upsertConversation("sync",t,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"_getMap",value:(a=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"_wrapPaginator",value:(i=Ia(Kc.mark((function e(t,n){var r,i=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n(t.items);case 2:return r=e.sent,e.abrupt("return",{items:r.filter((function(e){return null!==e})),hasNextPage:t.hasNextPage,hasPrevPage:t.hasPrevPage,nextPage:function(){return t.nextPage().then((function(e){return i._wrapPaginator(e,n)}))},prevPage:function(){return t.prevPage().then((function(e){return i._wrapPaginator(e,n)}))}});case 4:case"end":return e.stop()}}),e)}))),function(e,t){return i.apply(this,arguments)})},{key:"_updateConversation",value:(r=Ia(Kc.mark((function e(t,n,r){var i,a,o;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=void 0!==n._statusSource&&t!==n._statusSource,a="rest"!==t||"sync"===n._statusSource,!i||!a||"sync"===t){e.next=5;break}return Jj.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:n.sid,data:r.status,conversation:n.status}),e.abrupt("return");case 5:if("joined"!==r.status||"joined"===n.status){e.next=15;break}return n._setStatus("joined",t),o={},void 0!==r.notificationLevel&&(o.notificationLevel=r.notificationLevel),void 0!==r.lastConsumedMessageIndex&&(o.lastConsumedMessageIndex=r.lastConsumedMessageIndex),mh(o,{})||n._update(o),e.next=13,n._subscribe();case 13:return this.emit("conversationJoined",n),e.abrupt("return");case 15:if("notParticipating"!==r.status||"joined"!==n.status){e.next=22;break}return n._setStatus("notParticipating",t),n._update(r),e.next=20,n._subscribe();case 20:return this.emit("conversationLeft",n),e.abrupt("return");case 22:if("notParticipating"!==r.status){e.next=26;break}return e.next=25,n._subscribe();case 25:return e.abrupt("return");case 26:n._update(r);case 27:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"_upsertConversation",value:(n=Ia(Kc.mark((function e(t,n,r){var i,a,o,s;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Jj.trace("upsertConversation called for ".concat(n),r),!(i=this.conversations.get(n))){e.next=9;break}return Jj.trace("upsertConversation: the conversation ".concat(i.sid," is known;")+"its status is known from the source ".concat(i._statusSource," ")+"and the update came from the source ".concat(t),i),e.next=6,this._updateConversation(t,i,r);case 6:return e.next=8,i._subscribe();case 8:return e.abrupt("return",i);case 9:if("rest"!==t||!this.tombstones.has(n)){e.next=12;break}return Jj.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",n),e.abrupt("return",null);case 12:return Jj.trace("upsertConversation: creating a local conversation object with sid "+n,r),a="".concat(this.configuration.links.conversations,"/").concat(n),o={self:a,messages:"".concat(a,"/Messages"),participants:"".concat(a,"/Participants")},s=new Conversation(r,n,o,this.configuration,this.services),this.conversations.set(n,s),e.prev=17,e.next=20,s._subscribe();case 20:if("joined"!==r.status){e.next=23;break}return e.next=23,s._fetchStreams();case 23:e.next=32;break;case 25:if(e.prev=25,e.t0=e.catch(17),"SyncError"===e.t0.name){e.next=29;break}throw e.t0;case 29:return Jj.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",n,e.t0),this.conversations.delete(n),e.abrupt("return",null);case 32:return this._registerForEvents(s),this.emit("conversationAdded",s),"joined"===r.status&&(s._setStatus("joined",t),this.emit("conversationJoined",s)),e.abrupt("return",s);case 36:case"end":return e.stop()}}),e,this,[[17,25]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_fetchMyConversations",value:(t=Ia(Kc.mark((function e(){var t,n,r,i,a,o;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=null;case 2:return i=new gh(this.configuration.links.myConversations),n&&i.arg("PageToken",n),e.next=6,this.services.network.get(i.build());case 6:a=e.sent,o=null===(r=a.body)||void 0===r?void 0:r.conversations.map((function(e){return{descriptor:e,channel_sid:e.conversation_sid,status:e.status,channel:e.sync_objects.conversation,messages:e.sync_objects.messages,roster:e.sync_objects.participants||"".concat(e.conversation_sid,".roster"),lastConsumedMessageIndex:e.last_read_message_index,notificationLevel:e.notification_level}})),n=a.body.meta.next_token,t=[].concat(xy(t),xy(o));case 10:if(n){e.next=2;break}case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onConversationRemoved",value:function(e){var t=this.conversations.get(e);t&&(this.conversations.delete(e),this.emit("conversationRemoved",t))}},{key:"_registerForEvents",value:function(e){var t=this;e.on("removed",(function(){return t._onConversationRemoved(e.sid)})),e.on("updated",(function(e){return t.emit("conversationUpdated",e)})),e.on("participantJoined",(function(e){return t.emit("participantJoined",e)})),e.on("participantLeft",(function(e){return t.emit("participantLeft",e)})),e.on("participantUpdated",(function(e){return t.emit("participantUpdated",e)})),e.on("messageAdded",(function(e){return t.emit("messageAdded",e)})),e.on("messageUpdated",(function(e){return t.emit("messageUpdated",e)})),e.on("messageRemoved",(function(e){return t.emit("messageRemoved",e)})),e.on("typingStarted",(function(e){return t.emit("typingStarted",e)})),e.on("typingEnded",(function(e){return t.emit("typingEnded",e)}))}}]),p}(cg),Yj=Tn,Qj=Xr.find,Xj=Vf,Zj="find",eM=!0;function tM(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}Zj in[]&&Array(1).find((function(){eM=!1})),Yj({target:"Array",proto:!0,forced:eM},{find:function(e){return Qj(this,e,arguments.length>1?arguments[1]:void 0)}}),Xj(Zj);var nM,rM=function(e){Oa(a,e);var t,n,r,i=tM(a);function a(e,t,n){var r;return Na(this,a),(r=i.call(this)).configuration=t,r.services=n,r.fifoStack=[],r.myself=e,r.myself.on("updated",(function(e){return r.emit("userUpdated",e)})),r.myself.on("userSubscribed",(function(){return r.emit("userSubscribed",r.myself)})),r.myself.on("userUnsubscribed",(function(){r.emit("userUnsubscribed",r.myself),r.myself._ensureFetched()})),r.subscribedUsers=new Map,r}return Ua(a,[{key:"handleUnsubscribeUser",value:function(e){this.subscribedUsers.has(e.identity)&&this.subscribedUsers.delete(e.identity);var t=0;this.fifoStack.find((function(n,r){return n==e.identity&&(t=r,!0)}))&&this.fifoStack.splice(t,1),this.emit("userUnsubscribed",e)}},{key:"handleSubscribeUser",value:function(e){if(!this.subscribedUsers.has(e.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var t,n,r=this.fifoStack.shift();null===(t=this.subscribedUsers)||void 0===t||null===(n=t.get(r))||void 0===n||n.unsubscribe()}this.fifoStack.push(e.identity),this.subscribedUsers.set(e.identity,e),this.emit("userSubscribed",e)}}},{key:"getUser",value:(r=Ia(Kc.mark((function e(t,n){var r,i,a,o=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.myself._ensureFetched();case 2:if(t!=this.myself.identity){e.next=4;break}return e.abrupt("return",this.myself);case 4:if(!(i=this.subscribedUsers.get(t))){e.next=7;break}return e.abrupt("return",i);case 7:if(null===(r=n)||void 0===r){e.next=11;break}e.next=14;break;case 11:return e.next=13,this.getSyncUniqueName(t);case 13:n=e.sent;case 14:return(a=new User(t,n,this.configuration,this.services)).on("updated",(function(e){return o.emit("userUpdated",e)})),a.on("userSubscribed",(function(){return o.handleSubscribeUser(a)})),a.on("userUnsubscribed",(function(){return o.handleUnsubscribeUser(a)})),e.next=20,a._ensureFetched();case 20:return e.abrupt("return",a);case 21:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"getSubscribedUsers",value:(n=Ia(Kc.mark((function e(){var t;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.myself._ensureFetched();case 2:return t=[this.myself],this.subscribedUsers.forEach((function(e){return t.push(e)})),e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getSyncUniqueName",value:(t=Ia(Kc.mark((function e(t){var n,r,i,a;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new gh(this.configuration.links.users).path(t).build(),e.next=3,this.services.network.get(i);case 3:return a=e.sent,e.abrupt("return",null!==(n=null===(r=a.body)||void 0===r?void 0:r.sync_objects.user_info_map)&&void 0!==n?n:"");case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),a}(cg),iM=Cf.scope("TypingIndicator"),aM=function(){function e(t,n,r){Na(this,e),this.configuration=n,this.services=r,this.getConversation=t,this.serviceTypingTimeout=null,this.sentUpdates=new Map}var t;return Ua(e,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var e=this;this.services.notificationClient.on("message",function(){var t=Ia(Kc.mark((function t(n,r){return Kc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==Fm.TYPING_INDICATOR){t.next=3;break}return t.next=3,e._handleRemoteTyping(r);case 3:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:(t=Ia(Kc.mark((function e(t){var n=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:iM.trace("Got new typing indicator ",t),this.getConversation(t.channel_sid).then((function(e){e&&e._participants.forEach((function(e){if(e.identity===t.identity||"apple"===e.type){var r=n.configuration.typingIndicatorTimeoutOverride?n.configuration.typingIndicatorTimeoutOverride+1e3:1e3*t.typing_timeout;e._startTyping(r)}}))})).catch((function(e){throw iM.error(e),e}));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"send",value:function(e){var t=this.sentUpdates.get(e);return t&&t>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(e,Date.now()),this._send(e))}},{key:"_send",value:function(e){var t=this;iM.trace("Sending typing indicator");var n=this.configuration.links.typing,r="ChannelSid=".concat(e);return this.services.twilsockClient.post(n,{"Content-Type":"application/x-www-form-urlencoded"},r,this.configuration.productId).then((function(e){e.body.hasOwnProperty("typing_timeout")&&(t.serviceTypingTimeout=1e3*e.body.typing_timeout)})).catch((function(e){throw iM.error("Failed to send typing indicator:",e),e}))}}]),e}(),PushNotification=Ua((function PushNotification(e){Na(this,PushNotification),this.title=e.title||null,this.body=e.body||null,this.sound=e.sound||null,this.badge=e.badge||null,this.action=e.action||null,this.type=e.type||null,this.data=e.data||{}})),oM="2.7.0";function sM(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function uM(e,t,n){return uM=sM()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&Ca(i,n.prototype),i},uM.apply(null,arguments)}function cM(e){var t="function"==typeof Map?new Map:void 0;return cM=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return uM(e,arguments,ja(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Ca(r,e)},cM(e)}var lM=new Uint8Array(16);function fM(){if(!nM&&!(nM="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return nM(lM)}for(var dM=[],pM=0;pM<256;++pM)dM.push((pM+256).toString(16).slice(1));var hM={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function vM(e,t,n){if(hM.randomUUID&&!t&&!e)return hM.randomUUID();var r=(e=e||{}).random||(e.rng||fM)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return dM[e[t+0]]+dM[e[t+1]]+dM[e[t+2]]+dM[e[t+3]]+"-"+dM[e[t+4]]+dM[e[t+5]]+"-"+dM[e[t+6]]+dM[e[t+7]]+"-"+dM[e[t+8]]+dM[e[t+9]]+"-"+dM[e[t+10]]+dM[e[t+11]]+dM[e[t+12]]+dM[e[t+13]]+dM[e[t+14]]+dM[e[t+15]]}(r)}function yM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function gM(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yM(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yM(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function mM(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}var bM=function(e){return e.replace(/(^\/+|\/+$)/g,"")},wM=function(e){Oa(n,e);var t=mM(n);function n(e){return Na(this,n),t.call(this,e)}return Ua(n)}(cM(Error)),kM=function(){function e(t,n,r){Na(this,e),this._serviceUrl=t,this._services=n,this._productId=r}var t,n,r;return Ua(e,[{key:"_preProcessUrl",value:function(e){var t=bM(e);return/^https?:\/\//.test(e)?t:"".concat(bM(this._serviceUrl),"/").concat(t)}},{key:"_makeRequest",value:(r=Ia(Kc.mark((function e(t,n,r,i){var a,o,s,u;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._preProcessUrl(n),o=gM({"Content-Type":"application/json; charset=utf-8"},i||{}),e.t0=t,e.next="get"===e.t0?5:"post"===e.t0?11:"delete"===e.t0?15:19;break;case 5:return u=a,r&&(u+="?"+Object.entries(r).map((function(e){return e.map(encodeURIComponent).join("=")})).join("&")),e.next=9,this._services.transport.get(u,o,this._productId);case 9:case 13:case 17:return s=e.sent,e.abrupt("break",19);case 11:return e.next=13,this._services.transport.post(a,o,JSON.stringify(r),this._productId);case 15:return e.next=17,this._services.transport.delete(a,o,{},this._productId);case 19:if(!(s.status.code<200||s.status.code>=300)){e.next=21;break}throw new Error("Request responded with a non-success code ".concat(s.status.code));case 21:return e.abrupt("return",s);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"fetchResource",value:(n=Ia(Kc.mark((function e(t,n){var r,i,a=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Mm({min:50,max:1600,maxAttemptsCount:6}),e.prev=2,e.next=5,r.run(Ia(Kc.mark((function e(){var r,i,o;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,a._makeRequest("get",t,n);case 3:return r=e.sent,e.abrupt("return",{type:"success",data:r.body});case 7:if(e.prev=7,e.t0=e.catch(0),404!==(null===e.t0||void 0===e.t0||null===(i=e.t0.body)||void 0===i?void 0:i.status)||50530!==(null===e.t0||void 0===e.t0||null===(o=e.t0.body)||void 0===o?void 0:o.code)){e.next=11;break}return e.abrupt("return",{type:"noMetadata"});case 11:throw e.t0;case 12:case"end":return e.stop()}}),e,null,[[0,7]])}))));case 5:i=e.sent,e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(2),new Error('Fetch resource from "'.concat(t,'" failed.'));case 11:if("noMetadata"!==i.type){e.next=13;break}throw new wM("No metadata found.");case 13:return e.abrupt("return",i.data);case 14:case"end":return e.stop()}}),e,null,[[2,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"mutateResource",value:(t=Ia(Kc.mark((function e(t,n,r){var i;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n,r,{"X-Twilio-Mutation-Id":vM()});case 2:if(202!==(i=e.sent).status.code){e.next=7;break}return e.next=6,this.fetchResource(i.body.resource_url);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return",i.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,n,r){return t.apply(this,arguments)})}]),e}(),_M=Tn,xM=hg,SM=s,EM=E,RM=pg.exports.onFreeze,IM=Object.freeze;_M({target:"Object",stat:!0,forced:SM((function(){IM(1)})),sham:!xM},{freeze:function(e){return IM&&EM(e)?IM(RM(e)):e}});var TM=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;Na(this,e),Ma(this,"_cachedTemplates",null),this._services=t,this._pageSize=n,this._cacheTtlMs=r}var t,n;return Ua(e,[{key:"getContentTemplates",value:(n=Ia(Kc.mark((function e(){var t,n,r,i,a,o,s,u=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===this._cachedTemplates){e.next=2;break}return e.abrupt("return",this._cachedTemplates);case 2:return e.next=4,this._fetchContentTemplates();case 4:t=e.sent,n=dg(t,2),r=n[0],i=n[1],a=r;case 9:if(null===i){e.next=19;break}return e.next=12,this._fetchContentTemplates(i);case 12:o=e.sent,s=dg(o,2),r=s[0],i=s[1],a=[].concat(xy(a),xy(r)),e.next=9;break;case 19:return this._cachedTemplates=Object.freeze(a),setTimeout((function(){u._cachedTemplates=null}),this._cacheTtlMs),e.abrupt("return",a);case 22:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_fetchContentTemplates",value:(t=Ia(Kc.mark((function e(t){var n,r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new gh("Client/v2/ContentTemplates")).arg("PageSize",this._pageSize),void 0!==t&&n.arg("PageToken",t),e.next=6,this._services.commandExecutor.fetchResource(n.build());case 6:return r=e.sent,e.abrupt("return",[r.templates.map((function(e){return new gj(e)})),r.meta.next_token]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();function CM(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return OM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return OM(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function OM(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var PM=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Na(this,t),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}return Ua(t,[{key:"_set",value:function(e,t){if(this.cache.set(e,t),this._size++,this._size>=this.maxSize){if(this._size=0,"function"==typeof this.onEviction){var n,r=CM(this.oldCache.entries());try{for(r.s();!(n=r.n()).done;){var i=dg(n.value,2),a=i[0],o=i[1];this.onEviction(a,o)}}catch(e){r.e(e)}finally{r.f()}}this.oldCache=this.cache,this.cache=new Map}}},{key:"get",value:function(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){var t=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,t),t}}},{key:"set",value:function(e,t){return this.cache.has(e)?this.cache.set(e,t):this._set(e,t),this}},{key:"has",value:function(e){return this.cache.has(e)||this.oldCache.has(e)}},{key:"peek",value:function(e){return this.cache.has(e)?this.cache.get(e):this.oldCache.has(e)?this.oldCache.get(e):void 0}},{key:"delete",value:function(e){var t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}},{key:"clear",value:function(){this.cache.clear(),this.oldCache.clear(),this._size=0}},{key:"keys",value:Kc.mark((function e(){var t,n,r,i;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=CM(this),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=dg(n.value,1),i=r[0],e.next=7,i;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:"values",value:Kc.mark((function e(){var t,n,r,i;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=CM(this),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=dg(n.value,2),i=r[1],e.next=7,i;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[1,11,14,17]])}))},{key:e,value:Kc.mark((function e(){var t,n,r,i,a,o,s,u;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=CM(this.cache),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=n.value,e.next=7,r;case 7:e.next=3;break;case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(1),t.e(e.t0);case 14:return e.prev=14,t.f(),e.finish(14);case 17:i=CM(this.oldCache),e.prev=18,i.s();case 20:if((a=i.n()).done){e.next=28;break}if(o=a.value,s=dg(o,1),u=s[0],this.cache.has(u)){e.next=26;break}return e.next=26,o;case 26:e.next=20;break;case 28:e.next=33;break;case 30:e.prev=30,e.t1=e.catch(18),i.e(e.t1);case 33:return e.prev=33,i.f(),e.finish(33);case 36:case"end":return e.stop()}}),e,this,[[1,11,14,17],[18,30,33,36]])}))},{key:"size",get:function(){var e,t=0,n=CM(this.oldCache.keys());try{for(n.s();!(e=n.n()).done;){var r=e.value;this.cache.has(r)||t++}}catch(e){n.e(e)}finally{n.f()}return Math.min(this._size+t,this.maxSize)}}]),t}(Symbol.iterator),AM=PM,jM=Ua((function e(t,n){Na(this,e),this.type=t,this.data=n,Object.freeze(n)})),MM=function(){function e(t,n){Na(this,e),this._services=t,this._configuration=n,this._cache=new AM({maxSize:n.channelMetadataCacheCapacity})}var t;return Ua(e,[{key:"getChannelMetadata",value:(t=Ia(Kc.mark((function e(t,n){var r,i,a,o,s;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r="".concat(t,",").concat(n),!(i=this._cache.get(r))){e.next=4;break}return e.abrupt("return",i.item);case 4:return a="".concat(this._configuration.links.conversations,"/").concat(t,"/Messages/").concat(n,"/ChannelMetadata"),e.prev=5,e.next=8,this._services.commandExecutor.fetchResource(a);case 8:o=e.sent,e.next=17;break;case 11:if(e.prev=11,e.t0=e.catch(5),!(e.t0 instanceof wM)){e.next=16;break}return this._cache.set(r,{item:null}),e.abrupt("return",null);case 16:throw new Error(e.t0);case 17:return s=new jM(o.type,o.data),this._cache.set(r,{item:s}),e.abrupt("return",s);case 20:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(e,n){return t.apply(this,arguments)})}]),e}();function LM(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return UM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return UM(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function UM(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var NM,DM,FM=Ua((function e(t){Na(this,e),Ma(this,"type","email"),this.messageSid=t.message_sid,this.level=t.level,this.name=t.name,this.address=t.address})),BM=Ua((function e(t){Na(this,e),this.type=t.type,this.messageSid=t.message_sid,this.rawData=JSON.stringify(t)})),qM=function(){function e(t,n){Na(this,e),this._services=t,this._configuration=n,this._cache=new AM({maxSize:n.messageRecipientsCacheCapacity})}var t,n;return Ua(e,[{key:"getRecipientsFromMessage",value:(n=Ia(Kc.mark((function e(t,n){var r,i,a,o,s,u=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r="".concat(t,",").concat(n),!(i=this._cache.get(r))){e.next=4;break}return e.abrupt("return",i.item);case 4:return a=new gh(this._configuration.links.conversations).path(t).path("MessageRecipients").arg("MessageSid",n).build(),e.next=7,this._services.commandExecutor.fetchResource(a);case 7:return o=e.sent,(s=o.message_recipients.map((function(e){return u._wrapResponse(e)}))).length>0&&this._cache.set(r,{item:s}),e.abrupt("return",s);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"getRecipientsFromConversation",value:(t=Ia(Kc.mark((function e(t,n){var r,i,a,o,s,u,c,l,f,d,p,h,v=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new gh(this._configuration.links.conversations).path(t).path("MessageRecipients").arg("PageToken",null!==(r=null==n?void 0:n.pageToken)&&void 0!==r?r:void 0).arg("PageSize",null!==(i=null==n?void 0:n.pageSize)&&void 0!==i?i:void 0).build(),e.next=3,this._services.commandExecutor.fetchResource(a);case 3:o=e.sent,s=o.message_recipients.map((function(e){return v._wrapResponse(e)})),u=LM(s);try{for(u.s();!(c=u.n()).done;)d=c.value,p="".concat(t,",").concat(d.messageSid),h=null!==(l=null===(f=this._cache.get(p))||void 0===f?void 0:f.item)&&void 0!==l?l:[],this._cache.set(p,{item:[].concat(xy(h),[d])})}catch(e){u.e(e)}finally{u.f()}return e.abrupt("return",new uj(s,(function(e,n){return v.getRecipientsFromConversation(t,{pageToken:e,pageSize:n})}),o.meta.previous_token,o.meta.next_token));case 8:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})},{key:"_wrapResponse",value:function(e){return"email"===e.type?new FM(e):new BM(e)}}]),e}();function zM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function WM(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?zM(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zM(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function KM(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ja(e);if(t){var i=ja(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Aa(this,n)}}var VM=Ua((function e(){Na(this,e)}));return e.Client=(NM=function(e){Oa(Client,e);var t,n,r,i,a,o,s,u,c,l,f,d,p,h,v,y,g=KM(Client);function Client(e){var t,n,r,i,a,o,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Na(this,Client),Ma(Ta(o=g.call(this)),"version",oM),Ma(Ta(o),"connectionState","unknown"),Ma(Ta(o),"parsePushNotification",DM.parsePushNotification),o._fpaToken=null!=e?e:"",o._options=null!=s?s:{},!o._options.disableDeepClone){var u=WM(WM({},o._options),{},{transport:void 0,twilsockClient:void 0});(u=ph(u)).transport=o._options.transport,u.twilsockClient=o._options.twilsockClient,o._options=u}o._options.logLevel=null!==(t=o._options.logLevel)&&void 0!==t?t:"silent",DM._logger.setLevel(o._options.logLevel);var c=o._options.productId="ip_messaging";if(o._options.clientMetadata=o._options.clientMetadata||{},o._options.clientMetadata.hasOwnProperty("type")||(o._options.clientMetadata.type="conversations"),o._options.clientMetadata.hasOwnProperty("sdk")||(o._options.clientMetadata.sdk="JS",o._options.clientMetadata.sdkv=oM),o._options.Sync=o._options.Sync||{},void 0===o._options.Sync.enableSessionStorage&&(o._options.Sync.enableSessionStorage=!0),o._options.region&&(o._options.Sync.region=o._options.region),!e)throw new Error("A valid Twilio token should be provided");o._services=new VM,o._myself=new User("","",null,o._services);var l=!o._options.twilsockClient;if(!o._options.initRegistrations){var f=new Bm.InitRegistration(c);DM.populateInitRegistrations(f),o._options.initRegistrations=[f]}o._services.twilsockClient=o._options.twilsockClient=null!==(n=o._options.twilsockClient)&&void 0!==n?n:new Bm.TwilsockClient(e,c,o._options),o._services.twilsockClient.on(DM.tokenAboutToExpire,(function(){return o.emit(DM.tokenAboutToExpire)})),o._services.twilsockClient.on(DM.tokenExpired,(function(){return o.emit(DM.tokenExpired)})),o._services.twilsockClient.on(DM.connectionError,(function(e){return o.emit(DM.connectionError,e)})),o._services.twilsockClient.on("stateChanged",(function(e){DM._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(e)),e!==o.connectionState&&(o.connectionState=e,o.emit(DM.connectionStateChanged,o.connectionState))})),o._services.transport=o._options.transport=null!==(r=o._options.transport)&&void 0!==r?r:o._options.twilsockClient,o._services.notificationClient=o._options.notificationsClient=null!==(i=o._options.notificationsClient)&&void 0!==i?i:new SR.Notifications(e,o._options),o._services.syncClient=o._options.syncClient=null!==(a=o._options.syncClient)&&void 0!==a?a:new SC(e,o._options);var d=(null==s?void 0:s.Chat)||(null==s?void 0:s.IPMessaging)||s||{},p=d.region||(null==s?void 0:s.region),h=d.apiUri||d.typingUri||"https://aim.".concat(p||"us1",".twilio.com");o._services.commandExecutor=new kM(h,{transport:o._options.transport},c),o._services.contentClient=new TM(o._services);var v=function(e){o._rejectEnsureReady(e),o.emit(DM.stateChanged,"failed"),o.emit(DM.initFailed,{error:e})},y=function(){v({terminal:!0,message:"Twilsock has disconnected."}),o._initializeEnsureReady((null==s?void 0:s.throwErrorsAlways)||!1)};return o._services.twilsockClient.once("connectionError",v),o._services.twilsockClient.once("disconnected",y),o._services.twilsockClient.once("connected",Ia(Kc.mark((function e(){var t,n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return DM._logger.debug("ConversationsClient started INITIALIZING"),o._services.twilsockClient.off("connectionError",v),o._services.twilsockClient.off("disconnected",y),e.prev=3,t="conversations.client.startup",o._services.twilsockClient.addPartialTelemetryEvent(new Bm.TelemetryEventDescription(t,"Conversations client startup",new Date),t,Bm.TelemetryPoint.Start),e.next=8,o._initialize();case 8:o._services.twilsockClient.addPartialTelemetryEvent(new Bm.TelemetryEventDescription("","",new Date),t,Bm.TelemetryPoint.End),e.next=17;break;case 11:e.prev=11,e.t0=e.catch(3),n={terminal:!0,message:e.t0.message},o._rejectEnsureReady(n),o.emit(DM.stateChanged,"failed"),o.emit(DM.initFailed,{error:n});case 17:case"end":return e.stop()}}),e,null,[[3,11]])})))),o._initializeEnsureReady((null==s?void 0:s.throwErrorsAlways)||!1),l&&o._services.twilsockClient.connect(),o}return Ua(Client,[{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:(y=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"updateToken",value:(v=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:if(DM._logger.info("updateToken"),this._fpaToken!==t){e.next=5;break}return e.abrupt("return",this);case 5:return e.next=7,this._services.twilsockClient.updateToken(t);case 7:return e.next=9,this._services.notificationClient.updateToken(t);case 9:return e.next=11,this._services.mcsClient.updateToken(t);case 11:return this._fpaToken=t,e.abrupt("return",this);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"getConversationBySid",value:(h=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return e.next=6,this._conversationsEntity.getConversation(t);case 6:if(n=e.sent){e.next=12;break}return e.next=10,this.peekConversationBySid(t);case 10:(n=e.sent)&&hj("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(n){e.next=14;break}throw new Error("Conversation with SID ".concat(t," was not found."));case 14:return e.abrupt("return",n);case 15:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"peekConversationBySid",value:(p=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.peekConversation(t);case 4:if(n=e.sent){e.next=7;break}throw new Error("Conversation with SID ".concat(t," was not found."));case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"getConversationByUniqueName",value:(d=Ia(Kc.mark((function e(t){var n;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return e.next=6,this._conversationsEntity.getConversationByUniqueName(t);case 6:if(n=e.sent){e.next=9;break}throw new Error("Conversation with unique name ".concat(t," was not found."));case 9:return e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"getSubscribedConversations",value:(f=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._conversationsPromise.then((function(e){return e.getConversations()})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"createConversation",value:(l=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return t=t||{},e.abrupt("return",this._conversationsPromise.then((function(e){return e.addConversation(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"setPushRegistrationId",value:(c=Ia(Kc.mark((function e(t,n){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(t),this._services.notificationClient.setPushRegistrationId(t,n),e.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"unsetPushRegistrationId",value:(u=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(t),e.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"removePushRegistrations",value:(s=Ia(Kc.mark((function e(t,n){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.notificationClient.removeRegistrations(t,n);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handlePushNotification",value:(o=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:DM._logger.debug("handlePushNotification, notificationPayload=",t),this.emit("pushNotification",DM.parsePushNotification(t));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getUser",value:(a=Ia(Kc.mark((function e(t){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._services.users.getUser(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"getSubscribedUsers",value:(i=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getTemporaryContentUrlsForMediaSids",value:function(e){var t=this;return new TC.CancellablePromise(function(){var n=Ia(Kc.mark((function n(r,i,a){var o,s;return Kc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(t._services.mcsClient&&e){n.next=3;break}return i(new Error("Media Content Service is unavailable")),n.abrupt("return");case 3:return o=t._services.mcsClient.mediaSetGetContentUrls(e),a((function(){o.cancel()})),n.prev=5,n.next=8,o;case 8:s=n.sent,r(s),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(5),i(n.t0);case 15:case"end":return n.stop()}}),n,null,[[5,12]])})));return function(e,t,r){return n.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(e){var t=e.map((function(e){return e.sid}));return this.getTemporaryContentUrlsForMediaSids(t)}},{key:"getContentTemplates",value:(r=Ia(Kc.mark((function e(){return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:return e.next=4,this._services.contentClient.getContentTemplates();case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_initialize",value:(n=Ia(Kc.mark((function e(){var t,n=this;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return t=e.sent,this._configuration=new Bf(this._options,t,DM._logger),this._services.channelMetadataClient=new MM(this._services,this._configuration),this._services.messageRecipientsClient=new qM(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new aM(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new Dm(this._configuration,this._services),this._services.users=new rM(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",(function(e){n.emit("userSubscribed",e)})),this._services.users.on("userUpdated",(function(e){return n.emit("userUpdated",e)})),this._services.users.on("userUnsubscribed",(function(e){n.emit("userUnsubscribed",e)})),this._conversationsEntity=new Hj(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",(function(e){n.emit("conversationAdded",e)})),this._conversationsEntity.on("conversationRemoved",(function(e){n.emit("conversationRemoved",e)})),this._conversationsEntity.on("conversationJoined",(function(e){n.emit("conversationJoined",e)})),this._conversationsEntity.on("conversationLeft",(function(e){n.emit("conversationLeft",e)})),this._conversationsEntity.on("conversationUpdated",(function(e){return n.emit("conversationUpdated",e)})),this._conversationsEntity.on("participantJoined",(function(e){n.emit("participantJoined",e)})),this._conversationsEntity.on("participantLeft",(function(e){n.emit("participantLeft",e)})),this._conversationsEntity.on("participantUpdated",(function(e){return n.emit("participantUpdated",e)})),this._conversationsEntity.on("messageAdded",(function(e){return n.emit("messageAdded",e)})),this._conversationsEntity.on("messageUpdated",(function(e){return n.emit("messageUpdated",e)})),this._conversationsEntity.on("messageRemoved",(function(e){return n.emit("messageRemoved",e)})),this._conversationsEntity.on("typingStarted",(function(e){return n.emit("typingStarted",e)})),this._conversationsEntity.on("typingEnded",(function(e){return n.emit("typingEnded",e)})),this._conversationsPromise=this._conversationsEntity.fetchConversations().then((function(){return n._conversationsEntity})).catch((function(e){throw console.error("Failed to fetch conversations _conversationsPromise -> client.ts",e),e})),e.next=30,this._services.users.myself._ensureFetched();case 30:DM._supportedPushChannels.forEach((function(e){return n._subscribeToPushNotifications(e)})),this._services.typingIndicator.initialize(),this._services.mcsClient=new TC.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,WM(WM({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(DM.stateChanged,"initialized"),this.emit(DM.initialized);case 36:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_subscribeToPushNotifications",value:function(e){var t=this;[Fm.NEW_MESSAGE,Fm.ADDED_TO_CONVERSATION,Fm.REMOVED_FROM_CONVERSATION,Fm.TYPING_INDICATOR,Fm.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.subscribe(e,n)}))}},{key:"_unsubscribeFromPushNotifications",value:function(e){var t=this;[Fm.NEW_MESSAGE,Fm.ADDED_TO_CONVERSATION,Fm.REMOVED_FROM_CONVERSATION,Fm.TYPING_INDICATOR,Fm.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.unsubscribe(e,n)}))}},{key:"_initializeEnsureReady",value:function(e){var t=this;this._ensureReady=new Promise((function(e,n){t._resolveEnsureReady=e,t._rejectEnsureReady=n})).catch((function(t){if(e)throw t}))}}],[{key:"create",value:(t=Ia(Kc.mark((function e(t,n){var r;return Kc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==n||!n.twilsockClient){e.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 r=new DM(t,n),e.next=5,r._ensureReady;case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"parsePushNotification",value:function(e){if(DM._logger.debug("parsePushNotification, notificationPayload=",e),void 0!==e.aps){if(!e.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var t,n,r,i=DM._parsePushNotificationChatData(e),a=e.aps,o=null;if("string"==typeof a.alert)t=a.alert||null;else t=(null===(n=a.alert)||void 0===n?void 0:n.body)||null,o=(null===(r=a.alert)||void 0===r?void 0:r.title)||null;return new PushNotification({title:o,body:t,sound:a.sound||null,badge:a.badge||null,action:a.category||null,type:e.twi_message_type,data:i})}if(void 0!==e.data){var s=e.data;if(!s.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var u=DM._parsePushNotificationChatData(e.data);return new PushNotification({title:s.twi_title||null,body:s.twi_body||null,sound:s.twi_sound||null,badge:null,action:s.twi_action||null,type:s.twi_message_type,data:u})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(e){var t={};for(var n in DM._supportedPushDataFields){var r=e[n];if(null!=r)if("message_index"!==n&&"media_count"!==n){if("media"!==n)t[DM._supportedPushDataFields[n]]=r;else if("string"==typeof r)try{t[DM._supportedPushDataFields[n]]=JSON.parse(r)}catch(e){DM._logger.debug("Media message notification parsing error")}}else{var i=hh(r);null!==i&&(t[DM._supportedPushDataFields[n]]=i)}}return t}},{key:"populateInitRegistrations",value:function(e){e.populateInitRegistrations([Fm.TYPING_INDICATOR]),SC.populateInitRegistrations(e)}}]),Client}(cg),Ma(NM,"conversationAdded","conversationAdded"),Ma(NM,"conversationJoined","conversationJoined"),Ma(NM,"conversationLeft","conversationLeft"),Ma(NM,"conversationRemoved","conversationRemoved"),Ma(NM,"conversationUpdated","conversationUpdated"),Ma(NM,"participantJoined","participantJoined"),Ma(NM,"participantLeft","participantLeft"),Ma(NM,"participantUpdated","participantUpdated"),Ma(NM,"messageAdded","messageAdded"),Ma(NM,"messageRemoved","messageRemoved"),Ma(NM,"messageUpdated","messageUpdated"),Ma(NM,"tokenAboutToExpire","tokenAboutToExpire"),Ma(NM,"tokenExpired","tokenExpired"),Ma(NM,"typingEnded","typingEnded"),Ma(NM,"typingStarted","typingStarted"),Ma(NM,"pushNotification","pushNotification"),Ma(NM,"userSubscribed","userSubscribed"),Ma(NM,"userUnsubscribed","userUnsubscribed"),Ma(NM,"userUpdated","userUpdated"),Ma(NM,"stateChanged","stateChanged"),Ma(NM,"initialized","initialized"),Ma(NM,"initFailed","initFailed"),Ma(NM,"connectionStateChanged","connectionStateChanged"),Ma(NM,"connectionError","connectionError"),Ma(NM,"version",oM),Ma(NM,"_logger",Cf.scope("Client")),Ma(NM,"_supportedPushChannels",["fcm","apn"]),Ma(NM,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),DM=NM),$c([pj("token"),Gc("design:type",String),Gc("design:paramtypes",[])],e.Client.prototype,"token",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"updateToken",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),$c([wy(["undefined",yy("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],e.Client.prototype,"createConversation",null),$c([wy(dy("fcm","apn"),"string"),Gc("design:type",Function),Gc("design:paramtypes",[String,String]),Gc("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),$c([wy(dy("fcm","apn")),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),$c([wy(dy("fcm","apn"),hy),Gc("design:type",Function),Gc("design:paramtypes",[String,String]),Gc("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),$c([wy(gy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),$c([wy(hy),Gc("design:type",Function),Gc("design:paramtypes",[String]),Gc("design:returntype",Promise)],e.Client.prototype,"getUser",null),$c([wy(py("strings","string")),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",TC.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),$c([wy(py("media",Media)),Gc("design:type",Function),Gc("design:paramtypes",[Array]),Gc("design:returntype",TC.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),$c([pj("Client.create()","new Client()"),wy("string",["undefined",gy]),Gc("design:type",Function),Gc("design:paramtypes",[String,Object]),Gc("design:returntype",Promise)],e.Client,"create",null),$c([by(gy),Gc("design:type",Function),Gc("design:paramtypes",[Object]),Gc("design:returntype",PushNotification)],e.Client,"parsePushNotification",null),e.Client=DM=$c([my(hy,[gy,"undefined"]),Gc("design:paramtypes",[String,Object])],e.Client),e.AggregatedDeliveryReceipt=AggregatedDeliveryReceipt,e.CancellablePromise=TC.CancellablePromise,e.ChannelMetadata=jM,e.ContentTemplate=gj,e.ContentTemplateVariable=ContentTemplateVariable,e.Conversation=Conversation,e.DetailedDeliveryReceipt=DetailedDeliveryReceipt,e.EmailRecipientDescriptor=FM,e.Media=Media,e.Message=Message,e.MessageBuilder=Nj,e.NotificationTypes=Fm,e.Participant=Participant,e.PushNotification=PushNotification,e.RestPaginator=uj,e.UnknownRecipientDescriptor=BM,e.UnsentMessage=Uj,e.User=User,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
130
130
  //# sourceMappingURL=twilio-conversations.min.js.map