@twilio/conversations 2.6.3-rc.5 → 2.6.3-rc.8

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")(),s={},o=function(e){try{return!!e()}catch(e){return!0}},u=!o((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,m=function(e){return y.call(e).slice(8,-1)},g=m,b="".split,k=o((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==g(e)?b.call(e,""):Object(e)}:Object,w=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},x=k,_=w,S=function(e){return x(_(e))},E=function(e){return"object"==typeof e?null!==e:"function"==typeof e},T=a,R=function(e){return"function"==typeof e?e:void 0},C=function(e,t){return arguments.length<2?R(T[e]):T[e]&&T[e][t]},I=C("navigator","userAgent")||"",O=a,P=I,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 N=h&&+h,U=N,D=o,F=!!Object.getOwnPropertySymbols&&!D((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&U&&U<41})),B=F&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,q=C,z=B?function(e){return"symbol"==typeof e}:function(e){var t=q("Symbol");return"function"==typeof t&&Object(e)instanceof t},W=E,G={exports:{}},V=a,$=function(e,t){try{Object.defineProperty(V,e,{value:t,configurable:!0,writable:!0})}catch(n){V[e]=t}return t},J=$,K="__core-js_shared__",H=a[K]||J(K,{}),Y=H;(G.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=w,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,se=G.exports,oe=te,ue=ie,ce=F,le=B,fe=se("wks"),de=ae.Symbol,pe=le?de:de&&de.withoutSetter||ue,he=function(e){return oe(fe,e)&&(ce||"string"==typeof fe[e])||(ce&&oe(de,e)?fe[e]=de[e]:fe[e]=pe("Symbol."+e)),fe[e]},ve=E,ye=z,me=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")},ge=he("toPrimitive"),be=function(e,t){if(!ve(e)||ye(e))return e;var n,r=e[ge];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"),me(e,t)},ke=be,we=z,xe=function(e){var t=ke(e,"string");return we(t)?t:String(t)},_e=E,Se=a.document,Ee=_e(Se)&&_e(Se.createElement),Te=function(e){return Ee?Se.createElement(e):{}},Re=Te,Ce=!u&&!o((function(){return 7!=Object.defineProperty(Re("div"),"a",{get:function(){return 7}}).a})),Ie=u,Oe=c,Pe=v,Ae=S,je=xe,Me=te,Le=Ce,Ne=Object.getOwnPropertyDescriptor;s.f=Ie?Ne:function(e,t){if(e=Ae(e),t=je(t),Le)try{return Ne(e,t)}catch(e){}if(Me(e,t))return Pe(!Oe.f.call(e,t),e[t])};var Ue={},De=E,Fe=function(e){if(!De(e))throw TypeError(String(e)+" is not an object");return e},Be=u,qe=Ce,ze=Fe,We=xe,Ge=Object.defineProperty;Ue.f=Be?Ge:function(e,t,n){if(ze(e),t=We(t),ze(n),qe)try{return Ge(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=Ue,$e=v,Je=u?function(e,t,n){return Ve.f(e,t,$e(1,n))}:function(e,t,n){return e[t]=n,e},Ke={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=G.exports,at=ie,st=it("keys"),ot=function(e){return st[e]||(st[e]=at(e))},ut={},ct=rt,lt=E,ft=Je,dt=te,pt=H,ht=ot,vt=ut,yt="Object already initialized",mt=a.WeakMap;if(ct||pt.state){var gt=pt.state||(pt.state=new mt),bt=gt.get,kt=gt.has,wt=gt.set;Qe=function(e,t){if(kt.call(gt,e))throw new TypeError(yt);return t.facade=e,wt.call(gt,e,t),t},Xe=function(e){return bt.call(gt,e)||{}},Ze=function(e){return kt.call(gt,e)}}else{var xt=ht("state");vt[xt]=!0,Qe=function(e,t){if(dt(e,xt))throw new TypeError(yt);return t.facade=e,ft(e,xt,t),t},Xe=function(e){return dt(e,xt)?e[xt]:{}},Ze=function(e){return dt(e,xt)}}var _t={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=Je,Tt=te,Rt=$,Ct=et,It=_t.get,Ot=_t.enforce,Pt=String(String).split("String");(Ke.exports=function(e,t,n,r){var i,a=!!r&&!!r.unsafe,s=!!r&&!!r.enumerable,o=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof t||Tt(n,"name")||Et(n,"name",t),(i=Ot(n)).source||(i.source=Pt.join("string"==typeof t?t:""))),e!==St?(a?!o&&e[t]&&(s=!0):delete e[t],s?e[t]=n:Et(e,t,n)):s?e[t]=n:Rt(t,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&It(this).source||Ct(this)}));var At={},jt=Math.ceil,Mt=Math.floor,Lt=function(e){return isNaN(e=+e)?0:(e>0?Mt:jt)(e)},Nt=Lt,Ut=Math.min,Dt=function(e){return e>0?Ut(Nt(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,Gt=Dt,Vt=zt,$t=function(e){return function(t,n,r){var i,a=Wt(t),s=Gt(a.length),o=Vt(r,s);if(e&&n!=n){for(;s>o;)if((i=a[o++])!=i)return!0}else for(;s>o;o++)if((e||o in a)&&a[o]===n)return e||o||0;return!e&&-1}},Jt={includes:$t(!0),indexOf:$t(!1)},Kt=te,Ht=S,Yt=Jt.indexOf,Qt=ut,Xt=function(e,t){var n,r=Ht(e),i=0,a=[];for(n in r)!Kt(Qt,n)&&Kt(r,n)&&a.push(n);for(;t.length>i;)Kt(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,sn=Fe,on=C("Reflect","ownKeys")||function(e){var t=rn.f(sn(e)),n=an.f;return n?t.concat(n(e)):t},un=te,cn=on,ln=s,fn=Ue,dn=function(e,t){for(var n=cn(t),r=fn.f,i=ln.f,a=0;a<n.length;a++){var s=n[a];un(e,s)||r(e,s,i(t,s))}},pn=o,hn=/#|\.prototype\./,vn=function(e,t){var n=mn[yn(e)];return n==bn||n!=gn&&("function"==typeof t?pn(t):!!t)},yn=vn.normalize=function(e){return String(e).replace(hn,".").toLowerCase()},mn=vn.data={},gn=vn.NATIVE="N",bn=vn.POLYFILL="P",kn=vn,wn=a,xn=s.f,_n=Je,Sn=Ke.exports,En=$,Tn=dn,Rn=kn,Cn=function(e,t){var n,r,i,a,s,o=e.target,u=e.global,c=e.stat;if(n=u?wn:c?wn[o]||En(o,{}):(wn[o]||{}).prototype)for(r in t){if(a=t[r],i=e.noTargetGet?(s=xn(n,r))&&s.value:n[r],!Rn(u?r:o+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof a==typeof i)continue;Tn(a,i)}(e.sham||i&&i.sham)&&_n(a,"sham",!0),Sn(n,r,a,e)}},In=Ue.f,On=te,Pn=he("toStringTag"),An=function(e,t,n){e&&!On(e=n?e:e.prototype,Pn)&&In(e,Pn,{configurable:!0,value:t})},jn=a,Mn=An;Cn({global:!0},{Reflect:{}}),Mn(jn.Reflect,"Reflect",!0);var Ln,Nn=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},Un=Xt,Dn=Zt,Fn=Object.keys||function(e){return Un(e,Dn)},Bn=Ue,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},Gn=C("document","documentElement"),Vn=Fe,$n=Wn,Jn=Zt,Kn=ut,Hn=Gn,Yn=Te,Qn=ot("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=Jn.length;n--;)delete tr.prototype[Jn[n]];return tr()};Kn[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=Nn,ir=E,ar=[].slice,sr={},or=function(e,t,n){if(!(t in sr)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";sr[t]=Function("C,a","return new C("+r.join(",")+")")}return sr[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?or(t,i.length,i):t.apply(e,i)};return ir(t.prototype)&&(r.prototype=t.prototype),r},cr=Cn,lr=Nn,fr=Fe,dr=E,pr=nr,hr=ur,vr=o,yr=C("Reflect","construct"),mr=vr((function(){function e(){}return!(yr((function(){}),[],e)instanceof e)})),gr=!vr((function(){yr((function(){}))})),br=mr||gr;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(gr&&!mr)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),s=Function.apply.call(e,a,t);return dr(s)?s:a}});var kr=X,wr=Fn;Cn({target:"Object",stat:!0,forced:o((function(){wr(1)}))},{keys:function(e){return wr(kr(e))}});var xr=m,_r=Array.isArray||function(e){return"Array"==xr(e)},Sr=z,Er=function(e){if(Sr(e))throw TypeError("Cannot convert a Symbol value to a string");return String(e)},Tr={},Rr=S,Cr=At.f,Ir={}.toString,Or="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Tr.f=function(e){return Or&&"[object Window]"==Ir.call(e)?function(e){try{return Cr(e)}catch(e){return Or.slice()}}(e):Cr(Rr(e))};var Pr={},Ar=he;Pr.f=Ar;var jr=a,Mr=te,Lr=Pr,Nr=Ue.f,Ur=function(e){var t=jr.Symbol||(jr.Symbol={});Mr(t,e)||Nr(t,e,{value:Lr.f(e)})},Dr=Nn,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=_r,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},Gr=function(e,t){return new(Wr(e))(0===t?0:t)},Vr=Fr,$r=k,Jr=X,Kr=Dt,Hr=Gr,Yr=[].push,Qr=function(e){var t=1==e,n=2==e,r=3==e,i=4==e,a=6==e,s=7==e,o=5==e||a;return function(u,c,l,f){for(var d,p,h=Jr(u),v=$r(h),y=Vr(c,l,3),m=Kr(v.length),g=0,b=f||Hr,k=t?b(u,m):n||s?b(u,0):void 0;m>g;g++)if((o||g in v)&&(p=y(d=v[g],g,h),e))if(t)k[g]=p;else if(p)switch(e){case 3:return!0;case 5:return d;case 6:return g;case 2:Yr.call(k,d)}else switch(e){case 4:return!1;case 7:Yr.call(k,d)}return a?-1:r||i?i:k}},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=Cn,ei=a,ti=C,ni=u,ri=F,ii=o,ai=te,si=_r,oi=E,ui=z,ci=Fe,li=X,fi=S,di=xe,pi=Er,hi=v,vi=nr,yi=Fn,mi=At,gi=Tr,bi=nn,ki=s,wi=Ue,xi=c,_i=Je,Si=Ke.exports,Ei=G.exports,Ti=ut,Ri=ie,Ci=he,Ii=Pr,Oi=Ur,Pi=An,Ai=_t,ji=Xr.forEach,Mi=ot("hidden"),Li="Symbol",Ni=Ci("toPrimitive"),Ui=Ai.set,Di=Ai.getterFor(Li),Fi=Object.prototype,Bi=ei.Symbol,qi=ti("JSON","stringify"),zi=ki.f,Wi=wi.f,Gi=gi.f,Vi=xi.f,$i=Ei("symbols"),Ji=Ei("op-symbols"),Ki=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 Ui(n,{type:Li,tag:e,description:t}),ni||(n.description=t),n},ta=function(e,t,n){e===Fi&&ta(Ji,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(sa(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(Ji,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(Ji,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=Gi(fi(e)),n=[];return ji(t,(function(e){ai($i,e)||ai(Ti,e)||n.push(e)})),n},sa=function(e){var t=e===Fi,n=Gi(t?Ji: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=Ri(e),n=function(e){this===Fi&&n.call(Ji,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(Ri(e),e)})),xi.f=ra,wi.f=ta,ki.f=ia,mi.f=gi.f=aa,bi.f=sa,Ii.f=function(e){return ea(Ci(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(Ki,t))return Ki[t];var n=Bi(t);return Ki[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:sa}),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,(oi(t)||void 0!==e)&&!ui(e))return si(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[Ni]||_i(Bi.prototype,Ni,Bi.prototype.valueOf),Pi(Bi,Li),Ti[Mi]=!0;var oa=o,ua=N,ca=he("species"),la=function(e){return ua>=51||!oa((function(){var t=[];return(t.constructor={})[ca]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},fa=Xr.filter;Cn({target:"Array",proto:!0,forced:!la("filter")},{filter:function(e){return fa(this,e,arguments.length>1?arguments[1]:void 0)}});var da=Cn,pa=o,ha=S,va=s.f,ya=u,ma=pa((function(){va(1)}));da({target:"Object",stat:!0,forced:!ya||ma,sham:!ya},{getOwnPropertyDescriptor:function(e,t){return va(ha(e),t)}});var ga=xe,ba=Ue,ka=v,wa=function(e,t,n){var r=ga(t);r in e?ba.f(e,r,ka(0,n)):e[r]=n},xa=on,_a=S,Sa=s,Ea=wa;function Ta(e,t,n,r,i,a,s){try{var o=e[a](s),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).then(r,i)}function Ra(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function s(e){Ta(a,r,i,s,o,"next",e)}function o(e){Ta(a,r,i,s,o,"throw",e)}s(void 0)}))}}function Ca(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ia(e,t){return Ia=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ia(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&&Ia(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 Ca(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 Na(e,t,n){return t&&La(e.prototype,t),n&&La(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ua(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Cn({target:"Object",stat:!0,sham:!u},{getOwnPropertyDescriptors:function(e){for(var t,n,r=_a(e),i=Sa.f,a=xa(r),s={},o=0;a.length>o;)void 0!==(n=i(r,t=a[o++]))&&Ea(s,t,n);return s}});var Da=Xr.map;Cn({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=m,Wa=he("toStringTag"),Ga="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:Ga?za(t):"Object"==(r=za(t))&&"function"==typeof t.callee?"Arguments":r},$a=Va,Ja=Ba?{}.toString:function(){return"[object "+$a(this)+"]"},Ka=Ba,Ha=Ke.exports,Ya=Ja;Ka||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=Te("span").classList,Za=Xa&&Xa.constructor&&Xa.constructor.prototype,es=Za===Object.prototype?void 0:Za,ts=o,ns=function(e,t){var n=[][e];return!!n&&ts((function(){n.call(null,t||function(){throw 1},1)}))},rs=Xr.forEach,is=ns("forEach")?[].forEach:function(e){return rs(this,e,arguments.length>1?arguments[1]:void 0)},as=a,ss=Qa,os=es,us=is,cs=Je,ls=function(e){if(e&&e.forEach!==us)try{cs(e,"forEach",us)}catch(t){e.forEach=us}};for(var fs in ss)ls(as[fs]&&as[fs].prototype);ls(os);var ds=a.Promise,ps=Ke.exports,hs=function(e,t,n){for(var r in t)ps(e,r,t[r],n);return e},vs=E,ys=Fe,ms=function(e){if(!vs(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e},gs=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 ys(n),ms(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),bs=C,ks=Ue,ws=u,xs=he("species"),_s=function(e){var t=bs(e),n=ks.f;ws&&t&&!t[xs]&&n(t,xs,{configurable:!0,get:function(){return this}})},Ss=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},Es={},Ts=Es,Rs=he("iterator"),Cs=Array.prototype,Is=function(e){return void 0!==e&&(Ts.Array===e||Cs[Rs]===e)},Os=Va,Ps=Es,As=he("iterator"),js=function(e){if(null!=e)return e[As]||e["@@iterator"]||Ps[Os(e)]},Ms=Fe,Ls=js,Ns=function(e,t){var n=arguments.length<2?Ls(e):t;if("function"!=typeof n)throw TypeError(String(e)+" is not iterable");return Ms(n.call(e))},Us=Fe,Ds=function(e,t,n){var r,i;Us(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 Us(r),n},Fs=Fe,Bs=Is,qs=Dt,zs=Fr,Ws=Ns,Gs=js,Vs=Ds,$s=function(e,t){this.stopped=e,this.result=t},Js=function(e,t,n){var r,i,a,s,o,u,c,l=n&&n.that,f=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),h=zs(t,l,1+f+p),v=function(e){return r&&Vs(r,"normal",e),new $s(!0,e)},y=function(e){return f?(Fs(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=Gs(e)))throw TypeError("Target is not iterable");if(Bs(i)){for(a=0,s=qs(e.length);s>a;a++)if((o=y(e[a]))&&o instanceof $s)return o;return new $s(!1)}r=Ws(e,i)}for(u=r.next;!(c=u.call(r)).done;){try{o=y(c.value)}catch(e){Vs(r,"throw",e)}if("object"==typeof o&&o&&o instanceof $s)return o}return new $s(!1)},Ks=he("iterator"),Hs=!1;try{var Ys=0,Qs={next:function(){return{done:!!Ys++}},return:function(){Hs=!0}};Qs[Ks]=function(){return this},Array.from(Qs,(function(){throw 2}))}catch(e){}var Xs,Zs,eo,to,no=function(e,t){if(!t&&!Hs)return!1;var n=!1;try{var r={};r[Ks]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},ro=Fe,io=Nn,ao=he("species"),so=function(e,t){var n,r=ro(e).constructor;return void 0===r||null==(n=ro(r)[ao])?t:io(n)},oo=/(?:ipad|iphone|ipod).*applewebkit/i.test(I),uo="process"==m(a.process),co=a,lo=o,fo=Fr,po=Gn,ho=Te,vo=oo,yo=uo,mo=co.setImmediate,go=co.clearImmediate,bo=co.process,ko=co.MessageChannel,wo=co.Dispatch,xo=0,_o={},So="onreadystatechange";try{Xs=co.location}catch(e){}var Eo=function(e){if(_o.hasOwnProperty(e)){var t=_o[e];delete _o[e],t()}},To=function(e){return function(){Eo(e)}},Ro=function(e){Eo(e.data)},Co=function(e){co.postMessage(String(e),Xs.protocol+"//"+Xs.host)};mo&&go||(mo=function(e){for(var t=[],n=arguments.length,r=1;n>r;)t.push(arguments[r++]);return _o[++xo]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},Zs(xo),xo},go=function(e){delete _o[e]},yo?Zs=function(e){bo.nextTick(To(e))}:wo&&wo.now?Zs=function(e){wo.now(To(e))}:ko&&!vo?(to=(eo=new ko).port2,eo.port1.onmessage=Ro,Zs=fo(to.postMessage,to,1)):co.addEventListener&&"function"==typeof postMessage&&!co.importScripts&&Xs&&"file:"!==Xs.protocol&&!lo(Co)?(Zs=Co,co.addEventListener("message",Ro,!1)):Zs=So in ho("script")?function(e){po.appendChild(ho("script")).onreadystatechange=function(){po.removeChild(this),Eo(e)}}:function(e){setTimeout(To(e),0)});var Io,Oo,Po,Ao,jo,Mo,Lo,No,Uo={set:mo,clear:go},Do=a,Fo=/ipad|iphone|ipod/i.test(I)&&void 0!==Do.Pebble,Bo=/web0s(?!.*chrome)/i.test(I),qo=a,zo=s.f,Wo=Uo.set,Go=oo,Vo=Fo,$o=Bo,Jo=uo,Ko=qo.MutationObserver||qo.WebKitMutationObserver,Ho=qo.document,Yo=qo.process,Qo=qo.Promise,Xo=zo(qo,"queueMicrotask"),Zo=Xo&&Xo.value;Zo||(Io=function(){var e,t;for(Jo&&(e=Yo.domain)&&e.exit();Oo;){t=Oo.fn,Oo=Oo.next;try{t()}catch(e){throw Oo?Ao():Po=void 0,e}}Po=void 0,e&&e.enter()},Go||Jo||$o||!Ko||!Ho?!Vo&&Qo&&Qo.resolve?((Lo=Qo.resolve(void 0)).constructor=Qo,No=Lo.then,Ao=function(){No.call(Lo,Io)}):Ao=Jo?function(){Yo.nextTick(Io)}:function(){Wo.call(qo,Io)}:(jo=!0,Mo=Ho.createTextNode(""),new Ko(Io).observe(Mo,{characterData:!0}),Ao=function(){Mo.data=jo=!jo}));var eu=Zo||function(e){var t={fn:e,next:void 0};Po&&(Po.next=t),Oo||(Oo=t,Ao()),Po=t},tu={},nu=Nn,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,su,ou,uu=Fe,cu=E,lu=tu,fu=a,du="object"==typeof window,pu=Cn,hu=a,vu=C,yu=ds,mu=Ke.exports,gu=hs,bu=gs,ku=An,wu=_s,xu=E,_u=Nn,Su=Ss,Eu=et,Tu=Js,Ru=no,Cu=so,Iu=Uo.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=_t,Nu=kn,Uu=du,Du=uo,Fu=N,Bu=he("species"),qu="Promise",zu=Lu.get,Wu=Lu.set,Gu=Lu.getterFor(qu),Vu=yu&&yu.prototype,$u=yu,Ju=Vu,Ku=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=Nu(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&&Uu&&!ec})),ic=rc||!Ru((function(e){$u.all(e).catch((function(){}))})),ac=function(e){var t;return!(!xu(e)||"function"!=typeof(t=e.then))&&t},sc=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 s,o,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?s=r:(p&&p.enter(),s=l(r),p&&(p.exit(),u=!0)),s===c.promise?d(Ku("Promise-chain cycle")):(o=ac(s))?o.call(s,f,d):f(s)):d(r)}catch(e){p&&!u&&p.exit(),d(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&uc(e)}))}},oc=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){Iu.call(hu,(function(){var t,n=e.facade,r=e.value;if(cc(e)&&(t=Mu((function(){Du?Yu.emit("unhandledRejection",r,n):oc(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){Iu.call(hu,(function(){var t=e.facade;Du?Yu.emit("rejectionHandled",t):oc("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,sc(e,!0))},pc=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw Ku("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,sc(e,!1))}catch(t){dc({done:!1},t,e)}}};if(rc&&(Ju=($u=function(e){Su(this,$u,qu),_u(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=gu(Ju,{then:function(e,t){var n=Gu(this),r=Qu(Cu(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&&sc(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===su?new au(e):Xu(e)},"function"==typeof yu&&Vu!==Object.prototype)){ou=Vu.then,nc||(mu(Vu,"then",(function(e,t){var n=this;return new $u((function(e,t){ou.call(n,e,t)})).then(e,t)}),{unsafe:!0}),mu(Vu,"catch",Ju.catch,{unsafe:!0}));try{delete Vu.constructor}catch(e){}bu&&bu(Vu,Ju)}pu({global:!0,wrap:!0,forced:rc},{Promise:$u}),ku($u,qu,!1),wu(qu),su=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=_u(t.resolve),a=[],s=0,o=1;Tu(e,(function(e){var u=s++,c=!1;a.push(void 0),o++,n.call(t,e).then((function(e){c||(c=!0,a[u]=e,--o||r(a))}),i)})),--o||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=_u(t.resolve);Tu(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,mc="function"==typeof Symbol?Symbol:{},gc=mc.iterator||"@@iterator",bc=mc.asyncIterator||"@@asyncIterator",kc=mc.toStringTag||"@@toStringTag";function wc(e,t,n,r){var i=t&&t.prototype instanceof Cc?t:Cc,a=Object.create(i.prototype),s=new qc(r||[]);return a._invoke=function(e,t,n){var r=_c;return function(i,a){if(r===Ec)throw new Error("Generator is already running");if(r===Tc){if("throw"===i)throw a;return Wc()}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var o=Dc(s,n);if(o){if(o===Rc)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===_c)throw r=Tc,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=Ec;var u=xc(e,t,n);if("normal"===u.type){if(r=n.done?Tc:Sc,u.arg===Rc)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=Tc,n.method="throw",n.arg=u.arg)}}}(e,n,s),a}function xc(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}var _c="suspendedStart",Sc="suspendedYield",Ec="executing",Tc="completed",Rc={};function Cc(){}function Ic(){}function Oc(){}var Pc={};Pc[gc]=function(){return this};var Ac=Object.getPrototypeOf,jc=Ac&&Ac(Ac(zc([])));jc&&jc!==vc&&yc.call(jc,gc)&&(Pc=jc);var Mc=Oc.prototype=Cc.prototype=Object.create(Pc);function Lc(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function Nc(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===Ic||"GeneratorFunction"===(t.displayName||t.name))}function Uc(e,t){function n(r,i,a,s){var o=xc(e[r],e,i);if("throw"!==o.type){var u=o.arg,c=u.value;return c&&"object"===Pa(c)&&yc.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(c).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(o.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 Rc;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return Rc}var r=xc(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,Rc;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,Rc):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,Rc)}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[gc];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}}Ic.prototype=Mc.constructor=Oc,Oc.constructor=Ic,Oc[kc]=Ic.displayName="GeneratorFunction",Lc(Uc.prototype),Uc.prototype[bc]=function(){return this},Lc(Mc),Mc[kc]="Generator",Mc[gc]=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 s=yc.call(i,"catchLoc"),o=yc.call(i,"finallyLoc");if(s&&o){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!o)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,Rc):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),Rc},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),Rc}},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),Rc}};var Gc={wrap:wc,isGeneratorFunction:Nc,AsyncIterator:Uc,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,Oc):(e.__proto__=Oc,kc in e||(e[kc]="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 Uc(wc(e,t,n,r),i);return Nc(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:Gc});function $c(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":Pa(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function Jc(e,t){if("object"===("undefined"==typeof Reflect?"undefined":Pa(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var Kc=Cn,Hc=o,Yc=_r,Qc=E,Xc=X,Zc=Dt,el=wa,tl=Gr,nl=la,rl=N,il=he("isConcatSpreadable"),al=9007199254740991,sl="Maximum allowed index exceeded",ol=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)};Kc({target:"Array",proto:!0,forced:!ol||!ul},{concat:function(e){var t,n,r,i,a,s=Xc(this),o=tl(s,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(cl(a=-1===t?s:arguments[t])){if(u+(i=Zc(a.length))>al)throw TypeError(sl);for(n=0;n<i;n++,u++)n in a&&el(o,u,a[n])}else{if(u>=al)throw TypeError(sl);el(o,u++,a)}return o.length=u,o}});var ll=Fe,fl=Ds,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=Is,yl=Dt,ml=wa,gl=Ns,bl=js,kl=function(e){var t,n,r,i,a,s,o=pl(e),u="function"==typeof this?this:Array,c=arguments.length,l=c>1?arguments[1]:void 0,f=void 0!==l,d=bl(o),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(o.length));t>p;p++)s=f?l(o[p],p):o[p],ml(n,p,s);else for(a=(i=gl(o,d)).next,n=new u;!(r=a.call(i)).done;p++)s=f?hl(i,l,[r.value,p],!0):r.value,ml(n,p,s);return n.length=p,n},wl=kl;Cn({target:"Array",stat:!0,forced:!no((function(e){Array.from(e)}))},{from:wl});var xl,_l,Sl,El=Lt,Tl=Er,Rl=w,Cl=function(e){return function(t,n){var r,i,a=Tl(Rl(t)),s=El(n),o=a.length;return s<0||s>=o?e?"":void 0:(r=a.charCodeAt(s))<55296||r>56319||s+1===o||(i=a.charCodeAt(s+1))<56320||i>57343?e?a.charAt(s):r:e?a.slice(s,s+2):i-56320+(r-55296<<10)+65536}},Il={codeAt:Cl(!1),charAt:Cl(!0)},Ol=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Pl=te,Al=X,jl=Ol,Ml=ot("IE_PROTO"),Ll=Object.prototype,Nl=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},Ul=o,Dl=Nl,Fl=Je,Bl=he("iterator"),ql=!1;[].keys&&("next"in(Sl=[].keys())?(_l=Dl(Dl(Sl)))!==Object.prototype&&(xl=_l):ql=!0);var zl=null==xl||Ul((function(){var e={};return xl[Bl].call(e)!==e}));zl&&(xl={}),"function"!=typeof xl[Bl]&&Fl(xl,Bl,(function(){return this}));var Wl={IteratorPrototype:xl,BUGGY_SAFARI_ITERATORS:ql},Gl=Wl.IteratorPrototype,Vl=nr,$l=v,Jl=An,Kl=Es,Hl=function(){return this},Yl=function(e,t,n){var r=t+" Iterator";return e.prototype=Vl(Gl,{next:$l(1,n)}),Jl(e,r,!1),Kl[r]=Hl,e},Ql=Cn,Xl=Yl,Zl=Nl,ef=gs,tf=An,nf=Je,rf=Ke.exports,af=Es,sf=Wl.IteratorPrototype,of=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,s){Xl(n,t,r);var o,u,c,l=function(e){if(e===i&&v)return v;if(!of&&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=!of&&h||l(i),y="Array"==t&&p.entries||h;if(y&&(o=Zl(y.call(new e)))!==Object.prototype&&o.next&&(Zl(o)!==sf&&(ef?ef(o,sf):"function"!=typeof o[uf]&&nf(o,uf,df)),tf(o,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)},s)for(c in u)(of||d||!(c in p))&&rf(p,c,u[c]);else Ql({target:t,proto:!0,forced:of||d},u);return u},hf=Il.charAt,vf=Er,yf=_t,mf=pf,gf="String Iterator",bf=yf.set,kf=yf.getterFor(gf);mf(String,"String",(function(e){bf(this,{type:gf,string:vf(e),index:0})}),(function(){var e,t=kf(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 wf,xf,_f,Sf={exports:{}};function Ef(e,t){return["".concat((new Date).toISOString()," Conversations ").concat(e,":")].concat(Array.from(t))}xf=n,_f=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 s(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 o(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&&(o.call(this,n,r),this[e].apply(this,arguments))}}function c(e,t,n){return s(e)||u.apply(this,arguments)}function l(e,n,i){var a,s=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===s.levels[e]&&(e=void 0),e}}"string"==typeof e?u+=":"+e:"symbol"===Pa(e)&&(u=void 0),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=i||c,s.getLevel=function(){return a},s.setLevel=function(n,i){if("string"==typeof n&&void 0!==s.levels[n.toUpperCase()]&&(n=s.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=s.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),o.call(s,n,e),("undefined"==typeof console?"undefined":Pa(console))===t&&n<s.levels.SILENT)return"No console available for logging"},s.setDefaultLevel=function(e){n=e,l()||s.setLevel(e,!1)},s.resetLevel=function(){s.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){}}}()},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var f=l();null==f&&(f=n),s.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},(wf=Sf).exports?wf.exports=_f():xf.log=_f();var Tf,Rf,Cf=Sf.exports.getLogger("twilio-conversations"),If=function(){function e(t){Ua(this,e),Ma(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return Na(e,[{key:"setLevel",value:function(e){Cf.setLevel(e)}},{key:"trace",value:function(){if(Cf.getLevel()==Cf.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Cf.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];Cf.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];Cf.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];Cf.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];Cf.error.apply(null,Ef(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){Cf.setLevel(e)}},{key:"trace",value:function(){if(Cf.getLevel()==Cf.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Cf.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];Cf.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];Cf.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];Cf.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];Cf.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=Rf=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=Tf=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 Nf(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 Uf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Nf(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Nf(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=Na((function e(){var t,n,r,i,a,s,o,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;Ua(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=Uf({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=Tf(Rf(p))}catch(e){f.error("Failed to parse http cache interval ".concat(p,", using default value ").concat(Df)),this.httpCacheInterval=Tf(Rf(Df))}var h=null!==(a=null!==(s=d.consumptionReportIntervalOverride)&&void 0!==s?s:l.options.consumption_report_interval)&&void 0!==a?a:Ff;try{this.consumptionReportInterval=Tf(Rf(h))}catch(e){f.error("Failed to parse consumption report interval ".concat(h,", using default value ").concat(Ff)),this.consumptionReportInterval=Tf(Rf(Ff))}this.channelMetadataCacheCapacity=null!==(o=c.channelMetadataCacheCapacity)&&void 0!==o?o:100,this.messageRecipientsCacheCapacity=null!==(u=c.messageRecipientsCacheCapacity)&&void 0!==u?u:1e3})),qf=nr,zf=Ue,Wf=he("unscopables"),Gf=Array.prototype;null==Gf[Wf]&&zf.f(Gf,Wf,{configurable:!0,value:qf(null)});var Vf=function(e){Gf[Wf][e]=!0},$f=S,Jf=Vf,Kf=Es,Hf=_t,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");Kf.Arguments=Kf.Array,Jf("keys"),Jf("values"),Jf("entries");var td=a,nd=Qa,rd=es,id=ed,ad=Je,sd=he,od=sd("iterator"),ud=sd("toStringTag"),cd=id.values,ld=function(e,t){if(e){if(e[od]!==cd)try{ad(e,od,cd)}catch(t){e[od]=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=Cn,pd=o,hd=C("JSON","stringify"),vd=/[\uD800-\uDFFF]/g,yd=/^[\uD800-\uDBFF]$/,md=/^[\uDC00-\uDFFF]$/,gd=function(e,t,n){var r=n.charAt(t-1),i=n.charAt(t+1);return yd.test(e)&&!md.test(i)||md.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,gd):r}});var kd=E,wd=gs,xd=function(e,t,n){var r,i;return wd&&"function"==typeof(r=t.constructor)&&r!==n&&kd(i=r.prototype)&&i!==n.prototype&&wd(e,i),e},_d=w,Sd=Er,Ed="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Td=RegExp("^"+Ed+Ed+"*"),Rd=RegExp(Ed+Ed+"*$"),Cd=function(e){return function(t){var n=Sd(_d(t));return 1&e&&(n=n.replace(Td,"")),2&e&&(n=n.replace(Rd,"")),n}},Id={start:Cd(1),end:Cd(2),trim:Cd(3)},Od=u,Pd=a,Ad=kn,jd=Ke.exports,Md=te,Ld=m,Nd=xd,Ud=z,Dd=be,Fd=o,Bd=nr,qd=At.f,zd=s.f,Wd=Ue.f,Gd=Id.trim,Vd="Number",$d=Pd.Number,Jd=$d.prototype,Kd=Ld(Bd(Jd))==Vd,Hd=function(e){if(Ud(e))throw TypeError("Cannot convert a Symbol value to a number");var t,n,r,i,a,s,o,u,c=Dd(e,"number");if("string"==typeof c&&c.length>2)if(43===(t=(c=Gd(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(s=(a=c.slice(2)).length,o=0;o<s;o++)if((u=a.charCodeAt(o))<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&&(Kd?Fd((function(){Jd.valueOf.call(n)})):Ld(n)!=Vd)?Nd(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=Jd,Jd.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=o,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,sp,op=o,up=a.RegExp,cp=op((function(){var e=up(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),lp=o,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=G.exports,mp=nr,gp=_t.get,bp=cp,kp=dp,wp=RegExp.prototype.exec,xp=yp("native-string-replace",String.prototype.replace),_p=wp,Sp=(ap=/a/,sp=/b*/g,wp.call(ap,"a"),wp.call(sp,"a"),0!==ap.lastIndex||0!==sp.lastIndex),Ep=vp.UNSUPPORTED_Y||vp.BROKEN_CARET,Tp=void 0!==/()??/.exec("")[1];(Sp||Tp||Ep||bp||kp)&&(_p=function(e){var t,n,r,i,a,s,o,u=this,c=gp(u),l=pp(e),f=c.raw;if(f)return f.lastIndex=u.lastIndex,t=_p.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,m=l;if(p&&(-1===(h=h.replace("y","")).indexOf("g")&&(h+="g"),m=l.slice(u.lastIndex),u.lastIndex>0&&(!u.multiline||u.multiline&&"\n"!==l.charAt(u.lastIndex-1))&&(v="(?: "+v+")",m=" "+m,y++),n=new RegExp("^(?:"+v+")",h)),Tp&&(n=new RegExp("^"+v+"$(?!\\s)",h)),Sp&&(r=u.lastIndex),i=wp.call(p?n:u,m),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),Tp&&i&&i.length>1&&xp.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=s=mp(null),a=0;a<d.length;a++)s[(o=d[a])[0]]=i[o[1]];return i});var Rp=_p;Cn({target:"RegExp",proto:!0,forced:/./.exec!==Rp},{exec:Rp});var Cp=Ke.exports,Ip=Rp,Op=o,Pp=he,Ap=Je,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)})),s=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||!s||n){var o=/./[i],u=t(i,""[e],(function(e,t,n,r,i){var s=t.exec;return s===Ip||s===Mp.exec?a&&!i?{done:!0,value:o.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}));Cp(String.prototype,e,u[0]),Cp(Mp,i,u[1])}r&&Ap(Mp[i],"sham",!0)},Np=Il.charAt,Up=function(e,t,n){return t+(n?Np(e,t).length:1)},Dp=X,Fp=Math.floor,Bp="".replace,qp=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,zp=/\$([$&'`]|\d{1,2})/g,Wp=m,Gp=Rp,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 Gp.call(e,t)},$p=Lp,Jp=o,Kp=Fe,Hp=Lt,Yp=Dt,Qp=Er,Xp=w,Zp=Up,eh=function(e,t,n,r,i,a){var s=n+e.length,o=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(s);case"<":c=i[u.slice(1,-1)];break;default:var l=+u;if(0===l)return a;if(l>o){var f=Fp(l/10);return 0===f?a:f<=o?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"),sh=!!/./[nh]&&""===/./[nh]("a","$0"),oh=!Jp((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=sh?"$":"$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=Kp(this),s=Qp(e);if("string"==typeof i&&-1===i.indexOf(r)&&-1===i.indexOf("$<")){var o=n(t,a,s,i);if(o.done)return o.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,s);if(null===d)break;if(f.push(d),!c)break;""===Qp(d[0])&&(a.lastIndex=Zp(s,Yp(a.lastIndex),l))}for(var p,h="",v=0,y=0;y<f.length;y++){d=f[y];for(var m=Qp(d[0]),g=rh(ih(Hp(d.index),s.length),0),b=[],k=1;k<d.length;k++)b.push(void 0===(p=d[k])?p:String(p));var w=d.groups;if(u){var x=[m].concat(b,g,s);void 0!==w&&x.push(w);var _=Qp(i.apply(void 0,x))}else _=eh(m,s,g,b,w,i);g>=v&&(h+=s.slice(v,g)+_,v=g+m.length)}return h+s.slice(v)}]}),!oh||!ah||sh);var uh=Cn,ch=S,lh=[].join,fh=k!=Object,dh=ns("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 mh=function(){function e(t){Ua(this,e),this.base=t.replace(/\/$/,""),this.args=[],this.paths=[]}return Na(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}(),gh={},bh={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}(bh);var kh=u,wh=Ue.f,xh=Function.prototype,_h=xh.toString,Sh=/^\s*function ([^ (]*)/,Eh="name";kh&&!(Eh in xh)&&wh(xh,Eh,{configurable:!0,get:function(){try{return _h.call(this).match(Sh)[1]}catch(e){return""}}});var Th={exports:{}},Rh={exports:{}};!function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}(Rh);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=[],s=!0,o=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){o=!0,i=e}finally{try{s||null==n.return||n.return()}finally{if(o)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports}(Ch);var Ih={exports:{}},Oh={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}(Oh),function(e){var t=Oh.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}(Ih);var Ph={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}(Ph),function(e){var t=Rh.exports,n=Ch.exports,r=Ih.exports,i=Ph.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}(Th);var Ah=Cn,jh=E,Mh=_r,Lh=zt,Nh=Dt,Uh=S,Dh=wa,Fh=he,Bh=la("slice"),qh=Fh("species"),zh=[].slice,Wh=Math.max;Ah({target:"Array",proto:!0,forced:!Bh},{slice:function(e,t){var n,r,i,a=Uh(this),s=Nh(a.length),o=Lh(e,s),u=Lh(void 0===t?s:t,s);if(Mh(a)&&("function"!=typeof(n=a.constructor)||n!==Array&&!Mh(n.prototype)?jh(n)&&null===(n=n[qh])&&(n=void 0):n=void 0,n===Array||void 0===n))return zh.call(a,o,u);for(r=new(void 0===n?Array:n)(Wh(u-o,0)),i=0;o<u;o++,i++)o in a&&Dh(r,i,a[o]);return r.length=i,r}});var Gh=Cn,Vh=E,$h=function(){var e=!1,t=/[ac]/;return t.exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e}(),Jh=/./.test;Gh({target:"RegExp",proto:!0,forced:!$h},{test:function(e){if("function"!=typeof this.exec)return Jh.call(this,e);var t=this.exec(e);if(null!==t&&!Vh(t))throw new Error("RegExp exec method returned something other than an Object or null");return!!t}});var Kh=Cn,Hh=u,Yh=a,Qh=te,Xh=E,Zh=Ue.f,ev=dn,tv=Yh.Symbol;if(Hh&&"function"==typeof tv&&(!("description"in tv.prototype)||void 0!==tv().description)){var nv={},rv=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof rv?new tv(e):void 0===e?tv():tv(e);return""===e&&(nv[t]=!0),t};ev(rv,tv);var iv=rv.prototype=tv.prototype;iv.constructor=rv;var av=iv.toString,sv="Symbol(test)"==String(tv("test")),ov=/^Symbol\((.*)\)[^)]+$/;Zh(iv,"description",{configurable:!0,get:function(){var e=Xh(this)?this.valueOf():this,t=av.call(e);if(Qh(nv,e))return"";var n=sv?t.slice(7,-1):t.replace(ov,"$1");return""===n?void 0:n}}),Kh({global:!0,forced:!0},{Symbol:rv})}Ur("iterator");var uv={exports:{}},cv={exports:{}};!function(e){var t=Oh.exports;e.exports=function(e){if(Array.isArray(e))return t(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(cv);var lv={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}(lv);var fv={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}(fv),function(e){var t=cv.exports,n=lv.exports,r=Ih.exports,i=fv.exports;e.exports=function(e){return t(e)||n(e)||r(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(uv);var dv={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}(dv);var pv={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}(pv);var hv={exports:{}},vv={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}(vv),function(e){var t=vv.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}(hv);var yv={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=bh.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}(yv);var gv={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}(gv);var bv=Jt.includes,kv=Vf;Cn({target:"Array",proto:!0},{includes:function(e){return bv(this,e,arguments.length>1?arguments[1]:void 0)}}),kv("includes");var wv=E,xv=Math.floor,_v=function(e){return!wv(e)&&isFinite(e)&&xv(e)===e};Cn({target:"Number",stat:!0},{isInteger:_v});var Sv=u,Ev=Fn,Tv=S,Rv=c.f,Cv=function(e){return function(t){for(var n,r=Tv(t),i=Ev(r),a=i.length,s=0,o=[];a>s;)n=i[s++],Sv&&!Rv.call(r,n)||o.push(e?[n,r[n]]:r[n]);return o}},Iv={entries:Cv(!0),values:Cv(!1)}.entries;Cn({target:"Object",stat:!0},{entries:function(e){return Iv(e)}}),Object.defineProperty(gh,"__esModule",{value:!0});var Ov=Th.exports,Pv=uv.exports,Av=dv.exports,jv=pv.exports,Mv=hv.exports,Lv=yv.exports,Nv=gv.exports;function Uv(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var Dv=Uv(bh.exports),Fv=Uv(Ov),Bv=Uv(Pv),qv=Uv(Av),zv=Uv(jv),Wv=Uv(Mv),Gv=Uv(Lv),Vv=Uv(Nv),$v=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 $v((function(e){for(var n=!1,r=[],i=0,a=t;i<a.length;i++){var s=a[i];"string"!=typeof s?(n=n||e instanceof s,r.push("an instance of ".concat(s.name))):(n=n||Dv.default(e)===s,r.push("of type ".concat(s)))}return[n,r]}))};function Kv(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=Vv.default(e);if(t){var i=Vv.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Gv.default(this,n)}}function Hv(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 Yv(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 Yv(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function Yv(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 Qv=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=Hv(t.entries());try{for(r.s();!(n=r.n()).done;){var i=Fv.default(n.value,2),a=i[0],s=i[1],o=ty(e[a],s),u=Fv.default(o,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()}},Xv=function(e){var t,n,r;(["undefined","boolean","number","bigint","string"].includes(Dv.default(e))&&(n="string"==typeof e?'"'.concat(e,'"'):"".concat(e)),"object"===Dv.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=Dv.default(e)),n},Zv=function(e){var t,n=[],r=Hv(e);try{for(r.s();!(t=r.n()).done;){var i=t.value;n.push(ey(i))}}catch(e){r.e(e)}finally{r.f()}return n},ey=function(e){var t,n=[],r=Hv(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},ty=function(e,t){var n,r,i=[],a=!1,s=Hv(e);try{for(s.s();!(r=s.n()).done;){var o,u=Hv(r.value.checks);try{for(u.s();!(o=u.n()).done;){var c=(0,o.value)(t),l=Fv.default(c,3),f=l[0],d=l[1],p=l[2];a=a||f,!n&&p&&(n=p),d&&(i=[].concat(Bv.default(i),"string"==typeof d?[d]:Bv.default(d)))}}catch(e){u.e(e)}finally{u.f()}}}catch(e){s.e(e)}finally{s.f()}if(a)return[!0];var h=n||Xv(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 ny(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 ry(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 ry(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function ry(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 iy=$v((function(e){return["string"==typeof e&&e.length>0,"a non-empty string"]})),ay=$v((function(e){return["number"==typeof e&&Number.isInteger(e)&&e>=0,"a non-negative integer"]})),sy=$v((function(e){return["object"===Dv.default(e)&&null!==e&&!Array.isArray(e),"a pure object (non-null and non-array)"]}));function oy(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 uy(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 uy(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function uy(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 cy=gh.array=function(e,t){return $v((function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(e)];var r,i=oy(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Fv.default(r.value,2),s=a[0],o=a[1],u=ty(ey(t),o),c=Fv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid array of ".concat(e," (index ").concat(s," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(s," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},ly=gh.custom=$v,fy=gh.literal=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $v((function(e){for(var n=!1,r=[],i=0,a=t;i<a.length;i++){var s=a[i];n=n||e===s,r.push("string"==typeof s?'"'.concat(s,'"'):"".concat(s))}return[n,r]}))},dy=gh.nonEmptyArray=function(e,t){return $v((function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(e)];var r,i=ny(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Fv.default(r.value,2),s=a[0],o=a[1],u=ty(ey(t),o),c=Fv.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(s," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(s," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},py=gh.nonEmptyString=iy,hy=gh.nonNegativeInteger=ay,vy=gh.objectSchema=function(e,t){return $v((function(n){if("object"!==Dv.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=Fv.default(i[r],2),s=a[0],o=a[1],u=ty(ey(o),n[s]),c=Fv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"valid ".concat(e,' (key "').concat(s,'" should be ').concat(d,")"),"malformed ".concat(e,' (key "').concat(s,'" is ').concat(f,")")]}return[!0]}))},yy=gh.pureObject=sy;gh.runtimeTypeValidation=Qv,gh.stringifyReceivedType=Xv,gh.type=Jv;var my=gh.validateConstructorTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Zv(t);return function(e){return function(e){Wv.default(n,e);var t=Kv(n);function n(){zv.default(this,n);for(var e=arguments.length,i=new Array(e),a=0;a<e;a++)i[a]=arguments[a];return Qv(r,i),t.call.apply(t,[this].concat(i))}return qv.default(n)}(e)}},gy=gh.validateTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Zv(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 Qv(r,t),i.apply(this,t)}}},by=gh.validateTypesAsync=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Zv(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{Qv(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 wy(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)||wy(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 _y=ly((function(e){return[["string","number","boolean","object"].includes(Pa(e)),"a JSON type"]})),Sy=ly((function(e){return[["undefined","string","number","boolean","object"].includes(Pa(e)),"an optional JSON type"]})),Ey=vy("send media options",{contentType:[fy(null),"string"],filename:["string","undefined"],media:[fy("null"),"string"].concat(xy("function"==typeof Buffer?[Buffer]:[]),xy("function"==typeof Blob?[Blob]:[]))}),Ty={},Ry={exports:{}},Cy={exports:{}};!function(e){var t=gv.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}(Ry);var Iy={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}(Iy),Object.defineProperty(Ty,"__esModule",{value:!0});var Oy=pv.exports,Py=dv.exports,Ay=mv.exports,jy=Ry.exports,My=hv.exports,Ly=yv.exports,Ny=gv.exports,Uy=Iy.exports;function Dy(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var Fy=Dy(uv.exports),By=Dy(Oy),qy=Dy(Py),zy=Dy(Ay),Wy=Dy(jy),Gy=Dy(My),Vy=Dy(Ly),$y=Dy(Ny),Jy=Dy(Uy);function Ky(){}function Hy(){Hy.init.call(this)}function Yy(e){return void 0===e._maxListeners?Hy.defaultMaxListeners:e._maxListeners}function Qy(e,t,n){if(t)e.call(n);else for(var r=e.length,i=am(e,r),a=0;a<r;++a)i[a].call(n)}function Xy(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=am(e,i),s=0;s<i;++s)a[s].call(n,r)}function Zy(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,s=am(e,a),o=0;o<a;++o)s[o].call(n,r,i)}function em(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var s=e.length,o=am(e,s),u=0;u<s;++u)o[u].call(n,r,i,a)}function tm(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=am(e,i),s=0;s<i;++s)a[s].apply(n,r)}function nm(e,t,n,r){var i,a,s,o;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),s=a[t]):(a=e._events=new Ky,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=Yy(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,o=u,"function"==typeof console.warn?console.warn(o):console.log(o)}}else s=a[t]=n,++e._eventsCount;return e}function rm(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 im(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 am(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function sm(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=$y.default(e);if(t){var i=$y.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Vy.default(this,n)}}Ky.prototype=Object.create(null),Hy.EventEmitter=Hy,Hy.usingDomains=!1,Hy.prototype.domain=void 0,Hy.prototype._events=void 0,Hy.prototype._maxListeners=void 0,Hy.defaultMaxListeners=10,Hy.init=function(){this.domain=null,Hy.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ky,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Hy.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},Hy.prototype.getMaxListeners=function(){return Yy(this)},Hy.prototype.emit=function(e){var t,n,r,i,a,s,o,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){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=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:Qy(n,l,this);break;case 2:Xy(n,l,this,arguments[1]);break;case 3:Zy(n,l,this,arguments[1],arguments[2]);break;case 4:em(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];tm(n,l,this,i)}return!0},Hy.prototype.addListener=function(e,t){return nm(this,e,t,!1)},Hy.prototype.on=Hy.prototype.addListener,Hy.prototype.prependListener=function(e,t){return nm(this,e,t,!0)},Hy.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,rm(this,e,t)),this},Hy.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,rm(this,e,t)),this},Hy.prototype.removeListener=function(e,t){var n,r,i,a,s;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 Ky:(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){s=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 Ky,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,s||t)}return this},Hy.prototype.off=function(e,t){return this.removeListener(e,t)},Hy.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Ky,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new Ky: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 Ky,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},Hy.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},Hy.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):im.call(e,t)},Hy.prototype.listenerCount=im,Hy.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var om=function(e){Gy.default(n,e);var t=sm(n);function n(){var e;return By.default(this,n),e=t.call(this),Jy.default(zy.default(e),"eventHistory",new Map),e}return qy.default(n,[{key:"on",value:function(e,t){return Wy.default($y.default(n.prototype),"on",this).call(this,e,t)}},{key:"once",value:function(e,t){return Wy.default($y.default(n.prototype),"once",this).call(this,e,t)}},{key:"off",value:function(e,t){return Wy.default($y.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=Wy.default($y.default(n.prototype),"emit",this)).call.apply(t,[this,e].concat(i))}},{key:"addListener",value:function(e,t){return Wy.default($y.default(n.prototype),"addListener",this).call(this,e,t)}},{key:"removeListener",value:function(e,t){return Wy.default($y.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,Fy.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,Fy.default(r)),this):Wy.default($y.default(n.prototype),"once",this).call(this,e,t)}}]),n}(Hy),um=Ty.ReplayEventEmitter=om,cm={exports:{}};!function(e,t){var r="__lodash_hash_undefined__",i=9007199254740991,a="[object Arguments]",s="[object Array]",o="[object Boolean]",u="[object Date]",c="[object Error]",l="[object Function]",f="[object Map]",d="[object Number]",p="[object Object]",h="[object Promise]",v="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object WeakMap]",k="[object ArrayBuffer]",w="[object DataView]",x=/^\[object .+?Constructor\]$/,_=/^(?:0|[1-9]\d*)$/,S={};S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S[a]=S[s]=S[k]=S[o]=S[w]=S[u]=S[c]=S[l]=S[f]=S[d]=S[p]=S[v]=S[y]=S[m]=S[b]=!1;var E="object"==Pa(n)&&n&&n.Object===Object&&n,T="object"==("undefined"==typeof self?"undefined":Pa(self))&&self&&self.Object===Object&&self,R=E||T||Function("return this")(),C=t&&!t.nodeType&&t,I=C&&e&&!e.nodeType&&e,O=I&&I.exports===C,P=O&&E.process,A=function(){try{return P&&P.binding&&P.binding("util")}catch(e){}}(),j=A&&A.isTypedArray;function M(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function L(e,t){return e.has(t)}function N(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function U(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var D,F,B=Array.prototype,q=Function.prototype,z=Object.prototype,W=R["__core-js_shared__"],G=q.toString,V=z.hasOwnProperty,$=function(){var e=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),J=z.toString,K=RegExp("^"+G.call(V).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),H=O?R.Buffer:void 0,Y=R.Symbol,Q=R.Uint8Array,X=z.propertyIsEnumerable,Z=B.splice,ee=Y?Y.toStringTag:void 0,te=Object.getOwnPropertySymbols,ne=H?H.isBuffer:void 0,re=(D=Object.keys,F=Object,function(e){return D(F(e))}),ie=Ae(R,"DataView"),ae=Ae(R,"Map"),se=Ae(R,"Promise"),oe=Ae(R,"Set"),ue=Ae(R,"WeakMap"),ce=Ae(Object,"create"),le=Ne(ie),fe=Ne(ae),de=Ne(se),pe=Ne(oe),he=Ne(ue),ve=Y?Y.prototype:void 0,ye=ve?ve.valueOf:void 0;function me(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 ge(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 be(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 ke(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new be;++t<n;)this.add(e[t])}function we(e){var t=this.__data__=new ge(e);this.size=t.size}function xe(e,t){var n=Fe(e),r=!n&&De(e),i=!n&&!r&&Be(e),a=!n&&!r&&!i&&Ve(e),s=n||r||i||a,o=s?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],u=o.length;for(var c in e)!t&&!V.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||a&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Le(c,u))||o.push(c);return o}function _e(e,t){for(var n=e.length;n--;)if(Ue(e[n][0],t))return n;return-1}function Se(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ee&&ee in Object(e)?function(e){var t=V.call(e,ee),n=e[ee];try{e[ee]=void 0;var r=!0}catch(e){}var i=J.call(e);r&&(t?e[ee]=n:delete e[ee]);return i}(e):function(e){return J.call(e)}(e)}function Ee(e){return Ge(e)&&Se(e)==a}function Te(e,t,n,r,i){return e===t||(null==e||null==t||!Ge(e)&&!Ge(t)?e!=e&&t!=t:function(e,t,n,r,i,l){var h=Fe(e),b=Fe(t),x=h?s:Me(e),_=b?s:Me(t),S=(x=x==a?p:x)==p,E=(_=_==a?p:_)==p,T=x==_;if(T&&Be(e)){if(!Be(t))return!1;h=!0,S=!1}if(T&&!S)return l||(l=new we),h||Ve(e)?Ie(e,t,n,r,i,l):function(e,t,n,r,i,a,s){switch(n){case w:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case k:return!(e.byteLength!=t.byteLength||!a(new Q(e),new Q(t)));case o:case u:case d:return Ue(+e,+t);case c:return e.name==t.name&&e.message==t.message;case v:case m:return e==t+"";case f:var l=N;case y:var p=1&r;if(l||(l=U),e.size!=t.size&&!p)return!1;var h=s.get(e);if(h)return h==t;r|=2,s.set(e,t);var b=Ie(l(e),l(t),r,i,a,s);return s.delete(e),b;case g:if(ye)return ye.call(e)==ye.call(t)}return!1}(e,t,x,n,r,i,l);if(!(1&n)){var R=S&&V.call(e,"__wrapped__"),C=E&&V.call(t,"__wrapped__");if(R||C){var I=R?e.value():e,O=C?t.value():t;return l||(l=new we),i(I,O,n,r,l)}}if(!T)return!1;return l||(l=new we),function(e,t,n,r,i,a){var s=1&n,o=Oe(e),u=o.length,c=Oe(t).length;if(u!=c&&!s)return!1;var l=u;for(;l--;){var f=o[l];if(!(s?f in t:V.call(t,f)))return!1}var d=a.get(e);if(d&&a.get(t))return d==t;var p=!0;a.set(e,t),a.set(t,e);var h=s;for(;++l<u;){var v=e[f=o[l]],y=t[f];if(r)var m=s?r(y,v,f,t,e,a):r(v,y,f,e,t,a);if(!(void 0===m?v===y||i(v,y,n,r,a):m)){p=!1;break}h||(h="constructor"==f)}if(p&&!h){var g=e.constructor,b=t.constructor;g==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(p=!1)}return a.delete(e),a.delete(t),p}(e,t,n,r,i,l)}(e,t,n,r,Te,i))}function Re(e){return!(!We(e)||function(e){return!!$&&$ in e}(e))&&(qe(e)?K:x).test(Ne(e))}function Ce(e){if(n=(t=e)&&t.constructor,r="function"==typeof n&&n.prototype||z,t!==r)return re(e);var t,n,r,i=[];for(var a in Object(e))V.call(e,a)&&"constructor"!=a&&i.push(a);return i}function Ie(e,t,n,r,i,a){var s=1&n,o=e.length,u=t.length;if(o!=u&&!(s&&u>o))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var l=-1,f=!0,d=2&n?new ke:void 0;for(a.set(e,t),a.set(t,e);++l<o;){var p=e[l],h=t[l];if(r)var v=s?r(h,p,l,t,e,a):r(p,h,l,e,t,a);if(void 0!==v){if(v)continue;f=!1;break}if(d){if(!M(t,(function(e,t){if(!L(d,t)&&(p===e||i(p,e,n,r,a)))return d.push(t)}))){f=!1;break}}else if(p!==h&&!i(p,h,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f}function Oe(e){return function(e,t,n){var r=t(e);return Fe(e)?r:function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}(r,n(e))}(e,$e,je)}function Pe(e,t){var n=e.__data__;return function(e){var t=Pa(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function Ae(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Re(n)?n:void 0}me.prototype.clear=function(){this.__data__=ce?ce(null):{},this.size=0},me.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},me.prototype.get=function(e){var t=this.__data__;if(ce){var n=t[e];return n===r?void 0:n}return V.call(t,e)?t[e]:void 0},me.prototype.has=function(e){var t=this.__data__;return ce?void 0!==t[e]:V.call(t,e)},me.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ce&&void 0===t?r:t,this},ge.prototype.clear=function(){this.__data__=[],this.size=0},ge.prototype.delete=function(e){var t=this.__data__,n=_e(t,e);return!(n<0)&&(n==t.length-1?t.pop():Z.call(t,n,1),--this.size,!0)},ge.prototype.get=function(e){var t=this.__data__,n=_e(t,e);return n<0?void 0:t[n][1]},ge.prototype.has=function(e){return _e(this.__data__,e)>-1},ge.prototype.set=function(e,t){var n=this.__data__,r=_e(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},be.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(ae||ge),string:new me}},be.prototype.delete=function(e){var t=Pe(this,e).delete(e);return this.size-=t?1:0,t},be.prototype.get=function(e){return Pe(this,e).get(e)},be.prototype.has=function(e){return Pe(this,e).has(e)},be.prototype.set=function(e,t){var n=Pe(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},ke.prototype.add=ke.prototype.push=function(e){return this.__data__.set(e,r),this},ke.prototype.has=function(e){return this.__data__.has(e)},we.prototype.clear=function(){this.__data__=new ge,this.size=0},we.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},we.prototype.get=function(e){return this.__data__.get(e)},we.prototype.has=function(e){return this.__data__.has(e)},we.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ge){var r=n.__data__;if(!ae||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new be(r)}return n.set(e,t),this.size=n.size,this};var je=te?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,a=[];++n<r;){var s=e[n];t(s,n,e)&&(a[i++]=s)}return a}(te(e),(function(t){return X.call(e,t)})))}:function(){return[]},Me=Se;function Le(e,t){return!!(t=null==t?i:t)&&("number"==typeof e||_.test(e))&&e>-1&&e%1==0&&e<t}function Ne(e){if(null!=e){try{return G.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ue(e,t){return e===t||e!=e&&t!=t}(ie&&Me(new ie(new ArrayBuffer(1)))!=w||ae&&Me(new ae)!=f||se&&Me(se.resolve())!=h||oe&&Me(new oe)!=y||ue&&Me(new ue)!=b)&&(Me=function(e){var t=Se(e),n=t==p?e.constructor:void 0,r=n?Ne(n):"";if(r)switch(r){case le:return w;case fe:return f;case de:return h;case pe:return y;case he:return b}return t});var De=Ee(function(){return arguments}())?Ee:function(e){return Ge(e)&&V.call(e,"callee")&&!X.call(e,"callee")},Fe=Array.isArray;var Be=ne||function(){return!1};function qe(e){if(!We(e))return!1;var t=Se(e);return t==l||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=i}function We(e){var t=Pa(e);return null!=e&&("object"==t||"function"==t)}function Ge(e){return null!=e&&"object"==Pa(e)}var Ve=j?function(e){return function(t){return e(t)}}(j):function(e){return Ge(e)&&ze(e.length)&&!!S[Se(e)]};function $e(e){return null!=(t=e)&&ze(t.length)&&!qe(t)?xe(e):Ce(e);var t}e.exports=function(e,t){return Te(e,t)}}(cm,cm.exports);var lm=cm.exports;function fm(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 dm=If.scope("User"),User=function(e){Oa(User,e);var t,n,r,i,a,s,o,u=fm(User);function User(e,t,n,r){var i;return Ua(this,User),Ma(Ca(i=u.call(this)),"promiseToFetch",null),Ma(Ca(i),"updated","updated"),Ma(Ca(i),"userSubscribed","userSubscribed"),Ma(Ca(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 Na(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:(o=Ra(Gc.mark((function e(t,n){var r,i;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:r=[],dm.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),dm),lm(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 o.apply(this,arguments)})},{key:"_updateReachabilityInfo",value:(s=Ra(Gc.mark((function e(t,n){var r=this;return Gc.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){dm.warn("Failed to get reachability info for ",r.state.identity,e)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_fetch",value:(a=Ra(Gc.mark((function e(){var t=this;return Gc.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 dm.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 dm.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 dm.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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(){return Gc.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}(um);function pm(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=[],s=!0,o=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){o=!0,i=e}finally{try{s||null==n.return||n.return()}finally{if(o)throw i}}return a}}(e,t)||wy(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([by(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],User.prototype,"updateAttributes",null),$c([by(["string"]),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],User.prototype,"updateFriendlyName",null);var hm={exports:{}},vm=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),ym=Cn,mm=ut,gm=E,bm=te,km=Ue.f,wm=At,xm=Tr,_m=vm,Sm=!1,Em=ie("meta"),Tm=0,Rm=Object.isExtensible||function(){return!0},Cm=function(e){km(e,Em,{value:{objectID:"O"+Tm++,weakData:{}}})},Im=hm.exports={enable:function(){Im.enable=function(){},Sm=!0;var e=wm.f,t=[].splice,n={};n[Em]=1,e(n).length&&(wm.f=function(n){for(var r=e(n),i=0,a=r.length;i<a;i++)if(r[i]===Em){t.call(r,i,1);break}return r},ym({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:xm.f}))},fastKey:function(e,t){if(!gm(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!bm(e,Em)){if(!Rm(e))return"F";if(!t)return"E";Cm(e)}return e[Em].objectID},getWeakData:function(e,t){if(!bm(e,Em)){if(!Rm(e))return!0;if(!t)return!1;Cm(e)}return e[Em].weakData},onFreeze:function(e){return _m&&Sm&&Rm(e)&&!bm(e,Em)&&Cm(e),e}};mm[Em]=!0;var Om=Cn,Pm=a,Am=kn,jm=Ke.exports,Mm=hm.exports,Lm=Js,Nm=Ss,Um=E,Dm=o,Fm=no,Bm=An,qm=xd,zm=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),a=r?"set":"add",s=Pm[e],o=s&&s.prototype,u=s,c={},l=function(e){var t=o[e];jm(o,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!Um(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return i&&!Um(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!Um(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(Am(e,"function"!=typeof s||!(i||o.forEach&&!Dm((function(){(new s).entries().next()})))))u=n.getConstructor(t,e,r,a),Mm.enable();else if(Am(e,!0)){var f=new u,d=f[a](i?{}:-0,1)!=f,p=Dm((function(){f.has(1)})),h=Fm((function(e){new s(e)})),v=!i&&Dm((function(){for(var e=new s,t=5;t--;)e[a](t,t);return!e.has(-0)}));h||((u=t((function(t,n){Nm(t,u,e);var i=qm(new s,t,u);return null!=n&&Lm(n,i[a],{that:i,AS_ENTRIES:r}),i}))).prototype=o,o.constructor=u),(p||v)&&(l("delete"),l("has"),r&&l("get")),(v||d)&&l(a),i&&o.clear&&delete o.clear}return c[e]=u,Om({global:!0,forced:u!=s},c),Bm(u,e),i||n.setStrong(u,e,r),u},Wm=Ue.f,Gm=nr,Vm=hs,$m=Fr,Jm=Ss,Km=Js,Hm=pf,Ym=_s,Qm=u,Xm=hm.exports.fastKey,Zm=_t.set,eg=_t.getterFor,tg={getConstructor:function(e,t,n,r){var i=e((function(e,a){Jm(e,i,t),Zm(e,{type:t,index:Gm(null),first:void 0,last:void 0,size:0}),Qm||(e.size=0),null!=a&&Km(a,e[r],{that:e,AS_ENTRIES:n})})),a=eg(t),s=function(e,t,n){var r,i,s=a(e),u=o(e,t);return u?u.value=n:(s.last=u={index:i=Xm(t,!0),key:t,value:n,previous:r=s.last,next:void 0,removed:!1},s.first||(s.first=u),r&&(r.next=u),Qm?s.size++:e.size++,"F"!==i&&(s.index[i]=u)),e},o=function(e,t){var n,r=a(e),i=Xm(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return Vm(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,Qm?e.size=0:this.size=0},delete:function(e){var t=this,n=a(t),r=o(t,e);if(r){var i=r.next,s=r.previous;delete n.index[r.index],r.removed=!0,s&&(s.next=i),i&&(i.previous=s),n.first==r&&(n.first=i),n.last==r&&(n.last=s),Qm?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=a(this),r=$m(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!!o(this,e)}}),Vm(i.prototype,n?{get:function(e){var t=o(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),Qm&&Wm(i.prototype,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=eg(t),a=eg(r);Hm(e,t,(function(e,t){Zm(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),Ym(t)}};zm("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),tg);var ng={};Object.defineProperty(ng,"__esModule",{value:!0});var rg=dv.exports,ig=mv.exports,ag=hv.exports,sg=yv.exports,og=gv.exports,ug=Iy.exports;function cg(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var lg=cg(pv.exports),fg=cg(rg),dg=cg(ig),pg=cg(ag),hg=cg(sg),vg=cg(og),yg=cg(ug);function mg(){}function gg(){gg.init.call(this)}function bg(e){return void 0===e._maxListeners?gg.defaultMaxListeners:e._maxListeners}function kg(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Cg(e,r),a=0;a<r;++a)i[a].call(n)}function wg(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=Cg(e,i),s=0;s<i;++s)a[s].call(n,r)}function xg(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,s=Cg(e,a),o=0;o<a;++o)s[o].call(n,r,i)}function _g(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var s=e.length,o=Cg(e,s),u=0;u<s;++u)o[u].call(n,r,i,a)}function Sg(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=Cg(e,i),s=0;s<i;++s)a[s].apply(n,r)}function Eg(e,t,n,r){var i,a,s,o;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),s=a[t]):(a=e._events=new mg,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=bg(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,o=u,"function"==typeof console.warn?console.warn(o):console.log(o)}}else s=a[t]=n,++e._eventsCount;return e}function Tg(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 Rg(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 Cg(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function Ig(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=vg.default(e);if(t){var i=vg.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return hg.default(this,n)}}mg.prototype=Object.create(null),gg.EventEmitter=gg,gg.usingDomains=!1,gg.prototype.domain=void 0,gg.prototype._events=void 0,gg.prototype._maxListeners=void 0,gg.defaultMaxListeners=10,gg.init=function(){this.domain=null,gg.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new mg,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},gg.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},gg.prototype.getMaxListeners=function(){return bg(this)},gg.prototype.emit=function(e){var t,n,r,i,a,s,o,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){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=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:kg(n,l,this);break;case 2:wg(n,l,this,arguments[1]);break;case 3:xg(n,l,this,arguments[1],arguments[2]);break;case 4:_g(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];Sg(n,l,this,i)}return!0},gg.prototype.addListener=function(e,t){return Eg(this,e,t,!1)},gg.prototype.on=gg.prototype.addListener,gg.prototype.prependListener=function(e,t){return Eg(this,e,t,!0)},gg.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Tg(this,e,t)),this},gg.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Tg(this,e,t)),this},gg.prototype.removeListener=function(e,t){var n,r,i,a,s;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 mg:(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){s=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 mg,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,s||t)}return this},gg.prototype.off=function(e,t){return this.removeListener(e,t)},gg.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new mg,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new mg: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 mg,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},gg.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},gg.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Rg.call(e,t)},gg.prototype.listenerCount=Rg,gg.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Og=function(e){pg.default(n,e);var t=Ig(n);function n(e){var r;return lg.default(this,n),r=t.call(this),yg.default(dg.default(r),"timeout",null),yg.default(dg.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 fg.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}(gg),Pg=function(e){pg.default(n,e);var t=Ig(n);function n(e){var r;return lg.default(this,n),r=t.call(this),yg.default(dg.default(r),"resolve",(function(){})),yg.default(dg.default(r),"reject",(function(){})),r.retrier=new Og(e),r}return fg.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}(gg);function Ag(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=vg.default(e);if(t){var i=vg.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return hg.default(this,n)}}function jg(e){return null!=e}var Mg=function(e){pg.default(n,e);var t=Ag(n);function n(e){var r;lg.default(this,n),r=t.call(this),yg.default(dg.default(r),"backoffDelay",0),yg.default(dg.default(r),"nextBackoffDelay",0),yg.default(dg.default(r),"backoffNumber",0),yg.default(dg.default(r),"timeoutID",null),yg.default(dg.default(r),"maxNumberOfRetry",-1);var i=e=e||{},a=i.initialDelay,s=i.maxDelay,o=i.randomisationFactor,u=i.factor;if(jg(a)&&a<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(jg(s)&&s<=1)throw new Error("The maximal timeout must be greater than 1.");if(jg(o)&&(o<0||o>1))throw new Error("The randomisation factor must be between 0 and 1.");if(jg(u)&&u<=1)throw new Error("Exponential factor should be greater than 1.");if(r.initialDelay=a||100,r.maxDelay=s||1e4,r.maxDelay<=r.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return r.randomisationFactor=o||0,r.factor=u||2,r.reset(),r}return fg.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}(gg),Lg=ng.AsyncRetrier=Pg;ng.Backoff=Mg;var Ng=ng.Retrier=Og;function Ug(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 Dg(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 Dg(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function Dg(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 Fg=function(){function e(t,n){Ua(this,e),this.configuration=t,this.services=n,this.cache=new Map,this.cacheLifetime=100*this.configuration.httpCacheInterval,this.cleanupCache()}return Na(e,[{key:"isExpired",value:function(e){return!this.cacheLifetime||Date.now()-e>this.cacheLifetime}},{key:"cleanupCache",value:function(){var e,t=Ug(this.cache);try{for(t.s();!(e=t.n()).done;){var n=pm(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 s=new Ng(t.configuration.backoffConfiguration);s.on("attempt",(function(){e().then((function(e){return s.succeeded(e)})).catch((function(e){a.indexOf(e.status)>-1||"Twilsock disconnected"===e.message?s.failed(e):(s.removeAllListeners(),s.cancel(),i(e))}))})),s.on("succeeded",(function(e){r(e)})),s.on("cancelled",(function(e){return i(e)})),s.on("failed",(function(e){return i(e)})),s.start()}))}},{key:"get",value:function(){var e=Ra(Gc.mark((function e(t){var n,r,i,a=this;return Gc.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}(),Bg=Na((function e(){Ua(this,e)}));Ma(Bg,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),Ma(Bg,"NEW_MESSAGE","twilio.conversations.new_message"),Ma(Bg,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),Ma(Bg,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),Ma(Bg,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");var qg={},zg={exports:{}};!function(e){function t(e,t,n,r,i,a,s){try{var o=e[a](s),u=o.value}catch(e){return void n(e)}o.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 s=e.apply(n,r);function o(e){t(s,i,a,o,u,"next",e)}function u(e){t(s,i,a,o,u,"throw",e)}o(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports}(zg);var Wg=r(Vc),Gg=Ke.exports,Vg=Fe,$g=Er,Jg=o,Kg=tp,Hg="toString",Yg=RegExp.prototype,Qg=Yg.toString,Xg=Jg((function(){return"/a/b"!=Qg.call({source:"a",flags:"b"})})),Zg=Qg.name!=Hg;(Xg||Zg)&&Gg(RegExp.prototype,Hg,(function(){var e=Vg(this),t=$g(e.source),n=e.flags;return"/"+t+"/"+$g(void 0===n&&e instanceof RegExp&&!("flags"in Yg)?Kg.call(e):n)}),{unsafe:!0}),zm("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),tg);var eb={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,s=t.plugins;for(n=0,i=s.length;n<i;n++)(a=s[n]).methods&&r(e,a.methods),a.properties&&Object.defineProperties(e,a.properties)},hook:function(e,t,n){var r,i,a,s,o=e.config.plugins,u=[e.context];for(n&&(u=u.concat(n)),r=0,i=o.length;r<i;r++)s=o[r],(a=o[r][t])&&a.apply(s,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,s=this.defaults.wildcard;for(n=0;n<e.length;n++)for(r=e[n],i=Array.isArray(r.from)?r.from:[r.from||s],a=r.to||s,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),s=[null,[]];function o(e,t){this.context=e,this.config=t,this.state=t.init.from,this.observers=[e]}r(o.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):s,a?this.observersForEvent(i.onLeave[t]):s,this.observersForEvent(i.on.transition),a?["doTransit",[this]]:s,a?this.observersForEvent(i.onEnter.state):s,a?this.observersForEvent(i.onEnter[n]):s,a?this.observersForEvent(i.on[n]):s,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],s=e[0][1],o=e[0][2];if(t[0].event=i,i&&o&&i!==n&&a.hook(this,"lifecycle",t),0===s.length)return e.shift(),this.observeEvents(e,t,i,r);var u=s.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=o},function(e,t,n){var r=n(0),i=n(2),a=n(1),s=n(3),o=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 s(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 o(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 s(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()}(eb);var tb={exports:{}},nb="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(nb){var rb=new Uint8Array(16);tb.exports=function(){return nb(rb),rb}}else{var ib=new Array(16);tb.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),ib[t]=e>>>((3&t)<<3)&255;return ib}}for(var ab=[],sb=0;sb<256;++sb)ab[sb]=(sb+256).toString(16).substr(1);var ob,ub,cb=function(e,t){var n=t||0,r=ab;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("")},lb=tb.exports,fb=cb,db=0,pb=0;var hb=function(e,t,n){var r=t&&n||0,i=t||[],a=(e=e||{}).node||ob,s=void 0!==e.clockseq?e.clockseq:ub;if(null==a||null==s){var o=lb();null==a&&(a=ob=[1|o[0],o[1],o[2],o[3],o[4],o[5]]),null==s&&(s=ub=16383&(o[6]<<8|o[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:pb+1,l=u-db+(c-pb)/1e4;if(l<0&&void 0===e.clockseq&&(s=s+1&16383),(l<0||u>db)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");db=u,pb=c,ub=s;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++]=s>>>8|128,i[r++]=255&s;for(var p=0;p<6;++p)i[r+p]=a[p];return t||fb(i)},vb=tb.exports,yb=cb;var mb=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||vb)();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||yb(i)},gb=hb,bb=mb,kb=bb;kb.v1=gb,kb.v4=bb;var wb,xb,_b,Sb=kb,Eb={exports:{}},Tb="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Rb=Tb,Cb=u,Ib=a,Ob=E,Pb=te,Ab=Va,jb=Je,Mb=Ke.exports,Lb=Ue.f,Nb=Nl,Ub=gs,Db=he,Fb=ie,Bb=Ib.Int8Array,qb=Bb&&Bb.prototype,zb=Ib.Uint8ClampedArray,Wb=zb&&zb.prototype,Gb=Bb&&Nb(Bb),Vb=qb&&Nb(qb),$b=Object.prototype,Jb=$b.isPrototypeOf,Kb=Db("toStringTag"),Hb=Fb("TYPED_ARRAY_TAG"),Yb=Fb("TYPED_ARRAY_CONSTRUCTOR"),Qb=Rb&&!!Ub&&"Opera"!==Ab(Ib.opera),Xb=!1,Zb={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},ek={BigInt64Array:8,BigUint64Array:8},tk=function(e){if(!Ob(e))return!1;var t=Ab(e);return Pb(Zb,t)||Pb(ek,t)};for(wb in Zb)(_b=(xb=Ib[wb])&&xb.prototype)?jb(_b,Yb,xb):Qb=!1;for(wb in ek)(_b=(xb=Ib[wb])&&xb.prototype)&&jb(_b,Yb,xb);if((!Qb||"function"!=typeof Gb||Gb===Function.prototype)&&(Gb=function(){throw TypeError("Incorrect invocation")},Qb))for(wb in Zb)Ib[wb]&&Ub(Ib[wb],Gb);if((!Qb||!Vb||Vb===$b)&&(Vb=Gb.prototype,Qb))for(wb in Zb)Ib[wb]&&Ub(Ib[wb].prototype,Vb);if(Qb&&Nb(Wb)!==Vb&&Ub(Wb,Vb),Cb&&!Pb(Vb,Kb))for(wb in Xb=!0,Lb(Vb,Kb,{get:function(){return Ob(this)?this[Hb]:void 0}}),Zb)Ib[wb]&&jb(Ib[wb],Hb,wb);var nk={NATIVE_ARRAY_BUFFER_VIEWS:Qb,TYPED_ARRAY_CONSTRUCTOR:Yb,TYPED_ARRAY_TAG:Xb&&Hb,aTypedArray:function(e){if(tk(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(Ub&&!Jb.call(Gb,e))throw TypeError("Target is not a typed array constructor");return e},exportTypedArrayMethod:function(e,t,n){if(Cb){if(n)for(var r in Zb){var i=Ib[r];if(i&&Pb(i.prototype,e))try{delete i.prototype[e]}catch(e){}}Vb[e]&&!n||Mb(Vb,e,n?t:Qb&&qb[e]||t)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(Cb){if(Ub){if(n)for(r in Zb)if((i=Ib[r])&&Pb(i,e))try{delete i[e]}catch(e){}if(Gb[e]&&!n)return;try{return Mb(Gb,e,n?t:Qb&&Gb[e]||t)}catch(e){}}for(r in Zb)!(i=Ib[r])||i[e]&&!n||Mb(i,e,t)}},isView:function(e){if(!Ob(e))return!1;var t=Ab(e);return"DataView"===t||Pb(Zb,t)||Pb(ek,t)},isTypedArray:tk,TypedArray:Gb,TypedArrayPrototype:Vb},rk=a,ik=o,ak=no,sk=nk.NATIVE_ARRAY_BUFFER_VIEWS,ok=rk.ArrayBuffer,uk=rk.Int8Array,ck=!sk||!ik((function(){uk(1)}))||!ik((function(){new uk(-1)}))||!ak((function(e){new uk,new uk(null),new uk(1.5),new uk(e)}),!0)||ik((function(){return 1!==new uk(new ok(2),1,void 0).length})),lk=Lt,fk=Dt,dk=function(e){if(void 0===e)return 0;var t=lk(e),n=fk(t);if(t!==n)throw RangeError("Wrong length or index");return n},pk=Math.abs,hk=Math.pow,vk=Math.floor,yk=Math.log,mk=Math.LN2,gk=X,bk=zt,kk=Dt,wk=function(e){for(var t=gk(this),n=kk(t.length),r=arguments.length,i=bk(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,s=void 0===a?n:bk(a,n);s>i;)t[i++]=e;return t},xk=a,_k=u,Sk=Tb,Ek=Je,Tk=hs,Rk=o,Ck=Ss,Ik=Lt,Ok=Dt,Pk=dk,Ak={pack:function(e,t,n){var r,i,a,s=new Array(n),o=8*n-t-1,u=(1<<o)-1,c=u>>1,l=23===t?hk(2,-24)-hk(2,-77):0,f=e<0||0===e&&1/e<0?1:0,d=0;for((e=pk(e))!=e||e===1/0?(i=e!=e?1:0,r=u):(r=vk(yk(e)/mk),e*(a=hk(2,-r))<1&&(r--,a*=2),(e+=r+c>=1?l/a:l*hk(2,1-c))*a>=2&&(r++,a/=2),r+c>=u?(i=0,r=u):r+c>=1?(i=(e*a-1)*hk(2,t),r+=c):(i=e*hk(2,c-1)*hk(2,t),r=0));t>=8;s[d++]=255&i,i/=256,t-=8);for(r=r<<t|i,o+=t;o>0;s[d++]=255&r,r/=256,o-=8);return s[--d]|=128*f,s},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,a=(1<<i)-1,s=a>>1,o=i-7,u=r-1,c=e[u--],l=127&c;for(c>>=7;o>0;l=256*l+e[u],u--,o-=8);for(n=l&(1<<-o)-1,l>>=-o,o+=t;o>0;n=256*n+e[u],u--,o-=8);if(0===l)l=1-s;else{if(l===a)return n?NaN:c?-1/0:1/0;n+=hk(2,t),l-=s}return(c?-1:1)*n*hk(2,l-t)}},jk=Nl,Mk=gs,Lk=At.f,Nk=Ue.f,Uk=wk,Dk=An,Fk=_t.get,Bk=_t.set,qk="ArrayBuffer",zk="DataView",Wk="Wrong index",Gk=xk.ArrayBuffer,Vk=Gk,$k=xk.DataView,Jk=$k&&$k.prototype,Kk=Object.prototype,Hk=xk.RangeError,Yk=Ak.pack,Qk=Ak.unpack,Xk=function(e){return[255&e]},Zk=function(e){return[255&e,e>>8&255]},ew=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},tw=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},nw=function(e){return Yk(e,23,4)},rw=function(e){return Yk(e,52,8)},iw=function(e,t){Nk(e.prototype,t,{get:function(){return Fk(this)[t]}})},aw=function(e,t,n,r){var i=Pk(n),a=Fk(e);if(i+t>a.byteLength)throw Hk(Wk);var s=Fk(a.buffer).bytes,o=i+a.byteOffset,u=s.slice(o,o+t);return r?u:u.reverse()},sw=function(e,t,n,r,i,a){var s=Pk(n),o=Fk(e);if(s+t>o.byteLength)throw Hk(Wk);for(var u=Fk(o.buffer).bytes,c=s+o.byteOffset,l=r(+i),f=0;f<t;f++)u[c+f]=l[a?f:t-f-1]};if(Sk){if(!Rk((function(){Gk(1)}))||!Rk((function(){new Gk(-1)}))||Rk((function(){return new Gk,new Gk(1.5),new Gk(NaN),Gk.name!=qk}))){for(var ow,uw=(Vk=function(e){return Ck(this,Vk),new Gk(Pk(e))}).prototype=Gk.prototype,cw=Lk(Gk),lw=0;cw.length>lw;)(ow=cw[lw++])in Vk||Ek(Vk,ow,Gk[ow]);uw.constructor=Vk}Mk&&jk(Jk)!==Kk&&Mk(Jk,Kk);var fw=new $k(new Vk(2)),dw=Jk.setInt8;fw.setInt8(0,2147483648),fw.setInt8(1,2147483649),!fw.getInt8(0)&&fw.getInt8(1)||Tk(Jk,{setInt8:function(e,t){dw.call(this,e,t<<24>>24)},setUint8:function(e,t){dw.call(this,e,t<<24>>24)}},{unsafe:!0})}else Vk=function(e){Ck(this,Vk,qk);var t=Pk(e);Bk(this,{bytes:Uk.call(new Array(t),0),byteLength:t}),_k||(this.byteLength=t)},$k=function(e,t,n){Ck(this,$k,zk),Ck(e,Vk,zk);var r=Fk(e).byteLength,i=Ik(t);if(i<0||i>r)throw Hk("Wrong offset");if(i+(n=void 0===n?r-i:Ok(n))>r)throw Hk("Wrong length");Bk(this,{buffer:e,byteLength:n,byteOffset:i}),_k||(this.buffer=e,this.byteLength=n,this.byteOffset=i)},_k&&(iw(Vk,"byteLength"),iw($k,"buffer"),iw($k,"byteLength"),iw($k,"byteOffset")),Tk($k.prototype,{getInt8:function(e){return aw(this,1,e)[0]<<24>>24},getUint8:function(e){return aw(this,1,e)[0]},getInt16:function(e){var t=aw(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=aw(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return tw(aw(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return tw(aw(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return Qk(aw(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return Qk(aw(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){sw(this,1,e,Xk,t)},setUint8:function(e,t){sw(this,1,e,Xk,t)},setInt16:function(e,t){sw(this,2,e,Zk,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){sw(this,2,e,Zk,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){sw(this,4,e,ew,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){sw(this,4,e,ew,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){sw(this,4,e,nw,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){sw(this,8,e,rw,t,arguments.length>2?arguments[2]:void 0)}});Dk(Vk,qk),Dk($k,zk);var pw={ArrayBuffer:Vk,DataView:$k},hw=Lt,vw=function(e){var t=hw(e);if(t<0)throw RangeError("The argument can't be less than 0");return t},yw=function(e,t){var n=vw(e);if(n%t)throw RangeError("Wrong offset");return n},mw=X,gw=Dt,bw=Ns,kw=js,ww=Is,xw=Fr,_w=nk.aTypedArrayConstructor,Sw=Cn,Ew=a,Tw=u,Rw=ck,Cw=nk,Iw=pw,Ow=Ss,Pw=v,Aw=Je,jw=_v,Mw=Dt,Lw=dk,Nw=yw,Uw=xe,Dw=te,Fw=Va,Bw=E,qw=z,zw=nr,Ww=gs,Gw=At.f,Vw=function(e){var t,n,r,i,a,s,o=mw(e),u=arguments.length,c=u>1?arguments[1]:void 0,l=void 0!==c,f=kw(o);if(null!=f&&!ww(f))for(s=(a=bw(o,f)).next,o=[];!(i=s.call(a)).done;)o.push(i.value);for(l&&u>2&&(c=xw(c,arguments[2],2)),n=gw(o.length),r=new(_w(this))(n),t=0;n>t;t++)r[t]=l?c(o[t],t):o[t];return r},$w=Xr.forEach,Jw=_s,Kw=Ue,Hw=s,Yw=xd,Qw=_t.get,Xw=_t.set,Zw=Kw.f,ex=Hw.f,tx=Math.round,nx=Ew.RangeError,rx=Iw.ArrayBuffer,ix=Iw.DataView,ax=Cw.NATIVE_ARRAY_BUFFER_VIEWS,sx=Cw.TYPED_ARRAY_CONSTRUCTOR,ox=Cw.TYPED_ARRAY_TAG,ux=Cw.TypedArray,cx=Cw.TypedArrayPrototype,lx=Cw.aTypedArrayConstructor,fx=Cw.isTypedArray,dx="BYTES_PER_ELEMENT",px="Wrong length",hx=function(e,t){for(var n=0,r=t.length,i=new(lx(e))(r);r>n;)i[n]=t[n++];return i},vx=function(e,t){Zw(e,t,{get:function(){return Qw(this)[t]}})},yx=function(e){var t;return e instanceof rx||"ArrayBuffer"==(t=Fw(e))||"SharedArrayBuffer"==t},mx=function(e,t){return fx(e)&&!qw(t)&&t in e&&jw(+t)&&t>=0},gx=function(e,t){return t=Uw(t),mx(e,t)?Pw(2,e[t]):ex(e,t)},bx=function(e,t,n){return t=Uw(t),!(mx(e,t)&&Bw(n)&&Dw(n,"value"))||Dw(n,"get")||Dw(n,"set")||n.configurable||Dw(n,"writable")&&!n.writable||Dw(n,"enumerable")&&!n.enumerable?Zw(e,t,n):(e[t]=n.value,e)};Tw?(ax||(Hw.f=gx,Kw.f=bx,vx(cx,"buffer"),vx(cx,"byteOffset"),vx(cx,"byteLength"),vx(cx,"length")),Sw({target:"Object",stat:!0,forced:!ax},{getOwnPropertyDescriptor:gx,defineProperty:bx}),Eb.exports=function(e,t,n){var r=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,s="set"+e,o=Ew[i],u=o,c=u&&u.prototype,l={},f=function(e,t){Zw(e,t,{get:function(){return function(e,t){var n=Qw(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=Qw(e);n&&(i=(i=tx(i))<0?0:i>255?255:255&i),a.view[s](t*r+a.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};ax?Rw&&(u=t((function(e,t,n,a){return Ow(e,u,i),Yw(Bw(t)?yx(t)?void 0!==a?new o(t,Nw(n,r),a):void 0!==n?new o(t,Nw(n,r)):new o(t):fx(t)?hx(u,t):Vw.call(u,t):new o(Lw(t)),e,u)})),Ww&&Ww(u,ux),$w(Gw(o),(function(e){e in u||Aw(u,e,o[e])})),u.prototype=c):(u=t((function(e,t,n,a){Ow(e,u,i);var s,o,c,l=0,d=0;if(Bw(t)){if(!yx(t))return fx(t)?hx(u,t):Vw.call(u,t);s=t,d=Nw(n,r);var p=t.byteLength;if(void 0===a){if(p%r)throw nx(px);if((o=p-d)<0)throw nx(px)}else if((o=Mw(a)*r)+d>p)throw nx(px);c=o/r}else c=Lw(t),s=new rx(o=c*r);for(Xw(e,{buffer:s,byteOffset:d,byteLength:o,length:c,view:new ix(s)});l<c;)f(e,l++)})),Ww&&Ww(u,ux),c=u.prototype=zw(cx)),c.constructor!==u&&Aw(c,"constructor",u),Aw(c,sx,u),ox&&Aw(c,ox,i),l[i]=u,Sw({global:!0,forced:u!=o,sham:!ax},l),dx in u||Aw(u,dx,r),dx in c||Aw(c,dx,r),Jw(i)}):Eb.exports=function(){},(0,Eb.exports)("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var kx=Dt,wx=Lt,xx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("at",(function(e){var t=xx(this),n=kx(t.length),r=wx(e),i=r>=0?r:n+r;return i<0||i>=n?void 0:t[i]}));var _x=X,Sx=zt,Ex=Dt,Tx=Math.min,Rx=[].copyWithin||function(e,t){var n=_x(this),r=Ex(n.length),i=Sx(e,r),a=Sx(t,r),s=arguments.length>2?arguments[2]:void 0,o=Tx((void 0===s?r:Sx(s,r))-a,r-i),u=1;for(a<i&&i<a+o&&(u=-1,a+=o-1,i+=o-1);o-- >0;)a in n?n[i]=n[a]:delete n[i],i+=u,a+=u;return n},Cx=Rx,Ix=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("copyWithin",(function(e,t){return Cx.call(Ix(this),e,t,arguments.length>2?arguments[2]:void 0)}));var Ox=Xr.every,Px=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("every",(function(e){return Ox(Px(this),e,arguments.length>1?arguments[1]:void 0)}));var Ax=wk,jx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("fill",(function(e){return Ax.apply(jx(this),arguments)}));var Mx=so,Lx=nk.TYPED_ARRAY_CONSTRUCTOR,Nx=nk.aTypedArrayConstructor,Ux=function(e){return Nx(Mx(e,e[Lx]))},Dx=function(e,t){for(var n=0,r=t.length,i=new e(r);r>n;)i[n]=t[n++];return i},Fx=Ux,Bx=Xr.filter,qx=function(e,t){return Dx(Fx(e),t)},zx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("filter",(function(e){var t=Bx(zx(this),e,arguments.length>1?arguments[1]:void 0);return qx(this,t)}));var Wx=Xr.find,Gx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("find",(function(e){return Wx(Gx(this),e,arguments.length>1?arguments[1]:void 0)}));var Vx=Xr.findIndex,$x=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("findIndex",(function(e){return Vx($x(this),e,arguments.length>1?arguments[1]:void 0)}));var Jx=Xr.forEach,Kx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("forEach",(function(e){Jx(Kx(this),e,arguments.length>1?arguments[1]:void 0)}));var Hx=Jt.includes,Yx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("includes",(function(e){return Hx(Yx(this),e,arguments.length>1?arguments[1]:void 0)}));var Qx=Jt.indexOf,Xx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("indexOf",(function(e){return Qx(Xx(this),e,arguments.length>1?arguments[1]:void 0)}));var Zx=a,e_=nk,t_=ed,n_=he("iterator"),r_=Zx.Uint8Array,i_=t_.values,a_=t_.keys,s_=t_.entries,o_=e_.aTypedArray,u_=e_.exportTypedArrayMethod,c_=r_&&r_.prototype[n_],l_=!!c_&&("values"==c_.name||null==c_.name),f_=function(){return i_.call(o_(this))};u_("entries",(function(){return s_.call(o_(this))})),u_("keys",(function(){return a_.call(o_(this))})),u_("values",f_,!l_),u_(n_,f_,!l_);var d_=nk.aTypedArray,p_=[].join;(0,nk.exportTypedArrayMethod)("join",(function(e){return p_.apply(d_(this),arguments)}));var h_=S,v_=Lt,y_=Dt,m_=ns,g_=Math.min,b_=[].lastIndexOf,k_=!!b_&&1/[1].lastIndexOf(1,-0)<0,w_=m_("lastIndexOf"),x_=k_||!w_?function(e){if(k_)return b_.apply(this,arguments)||0;var t=h_(this),n=y_(t.length),r=n-1;for(arguments.length>1&&(r=g_(r,v_(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:b_,__=x_,S_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("lastIndexOf",(function(e){return __.apply(S_(this),arguments)}));var E_=Xr.map,T_=Ux,R_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("map",(function(e){return E_(R_(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(T_(e))(t)}))}));var C_=Nn,I_=X,O_=k,P_=Dt,A_=function(e){return function(t,n,r,i){C_(n);var a=I_(t),s=O_(a),o=P_(a.length),u=e?o-1:0,c=e?-1:1;if(r<2)for(;;){if(u in s){i=s[u],u+=c;break}if(u+=c,e?u<0:o<=u)throw TypeError("Reduce of empty array with no initial value")}for(;e?u>=0:o>u;u+=c)u in s&&(i=n(i,s[u],u,a));return i}},j_={left:A_(!1),right:A_(!0)},M_=j_.left,L_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("reduce",(function(e){return M_(L_(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var N_=j_.right,U_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("reduceRight",(function(e){return N_(U_(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var D_=nk.aTypedArray,F_=nk.exportTypedArrayMethod,B_=Math.floor;F_("reverse",(function(){for(var e,t=this,n=D_(t).length,r=B_(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var q_=Dt,z_=yw,W_=X,G_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("set",(function(e){G_(this);var t=z_(arguments.length>1?arguments[1]:void 0,1),n=this.length,r=W_(e),i=q_(r.length),a=0;if(i+t>n)throw RangeError("Wrong length");for(;a<i;)this[t+a]=r[a++]}),o((function(){new Int8Array(1).set({})})));var V_=Ux,$_=nk.aTypedArray,J_=[].slice;(0,nk.exportTypedArrayMethod)("slice",(function(e,t){for(var n=J_.call($_(this),e,t),r=V_(this),i=0,a=n.length,s=new r(a);a>i;)s[i]=n[i++];return s}),o((function(){new Int8Array(1).slice()})));var K_=Xr.some,H_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("some",(function(e){return K_(H_(this),e,arguments.length>1?arguments[1]:void 0)}));var Y_=Math.floor,Q_=function(e,t){var n=e.length,r=Y_(n/2);return n<8?X_(e,t):Z_(Q_(e.slice(0,r),t),Q_(e.slice(r),t),t)},X_=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},Z_=function(e,t,n){for(var r=e.length,i=t.length,a=0,s=0,o=[];a<r||s<i;)a<r&&s<i?o.push(n(e[a],t[s])<=0?e[a++]:t[s++]):o.push(a<r?e[a++]:t[s++]);return o},eS=Q_,tS=I.match(/firefox\/(\d+)/i),nS=!!tS&&+tS[1],rS=/MSIE|Trident/.test(I),iS=I.match(/AppleWebKit\/(\d+)\./),aS=!!iS&&+iS[1],sS=o,oS=Nn,uS=Dt,cS=eS,lS=nS,fS=rS,dS=N,pS=aS,hS=nk.aTypedArray,vS=nk.exportTypedArrayMethod,yS=a.Uint16Array,mS=yS&&yS.prototype.sort,gS=!!mS&&!sS((function(){var e=new yS(2);e.sort(null),e.sort({})})),bS=!!mS&&!sS((function(){if(dS)return dS<74;if(lS)return lS<67;if(fS)return!0;if(pS)return pS<602;var e,t,n=new yS(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}));vS("sort",(function(e){var t=this;if(void 0!==e&&oS(e),bS)return mS.call(t,e);hS(t);var n,r=uS(t.length),i=Array(r);for(n=0;n<r;n++)i[n]=t[n];for(i=cS(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}),!bS||gS);var kS=Dt,wS=zt,xS=Ux,_S=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("subarray",(function(e,t){var n=_S(this),r=n.length,i=wS(e,r);return new(xS(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,kS((void 0===t?r:wS(t,r))-i))}));var SS=nk,ES=o,TS=a.Int8Array,RS=SS.aTypedArray,CS=SS.exportTypedArrayMethod,IS=[].toLocaleString,OS=[].slice,PS=!!TS&&ES((function(){IS.call(new TS(1))}));CS("toLocaleString",(function(){return IS.apply(PS?OS.call(RS(this)):RS(this),arguments)}),ES((function(){return[1,2].toLocaleString()!=new TS([1,2]).toLocaleString()}))||!ES((function(){TS.prototype.toLocaleString.call([1,2])})));var AS=nk.exportTypedArrayMethod,jS=o,MS=a.Uint8Array,LS=MS&&MS.prototype||{},NS=[].toString,US=[].join;jS((function(){NS.call({})}))&&(NS=function(){return US.call(this)});var DS=LS.toString!=NS;AS("toString",NS,DS);var FS=E,BS=m,qS=he("match"),zS=function(e){var t;return FS(e)&&(void 0!==(t=e[qS])?!!t:"RegExp"==BS(e))},WS=Lp,GS=zS,VS=Fe,$S=w,JS=so,KS=Up,HS=Dt,YS=Er,QS=Vp,XS=Rp,ZS=o,eE=np.UNSUPPORTED_Y,tE=[].push,nE=Math.min,rE=4294967295,iE=!ZS((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]}));WS("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=YS($S(this)),i=void 0===n?rE:n>>>0;if(0===i)return[];if(void 0===e)return[r];if(!GS(e))return t.call(r,e,i);for(var a,s,o,u=[],c=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,f=new RegExp(e.source,c+"g");(a=XS.call(f,r))&&!((s=f.lastIndex)>l&&(u.push(r.slice(l,a.index)),a.length>1&&a.index<r.length&&tE.apply(u,a.slice(1)),o=a[0].length,l=s,u.length>=i));)f.lastIndex===a.index&&f.lastIndex++;return l===r.length?!o&&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=$S(this),a=null==t?void 0:t[e];return void 0!==a?a.call(t,i,n):r.call(YS(i),t,n)},function(e,i){var a=VS(this),s=YS(e),o=n(r,a,s,i,r!==t);if(o.done)return o.value;var u=JS(a,RegExp),c=a.unicode,l=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(eE?"g":"y"),f=new u(eE?"^(?:"+a.source+")":a,l),d=void 0===i?rE:i>>>0;if(0===d)return[];if(0===s.length)return null===QS(f,s)?[s]:[];for(var p=0,h=0,v=[];h<s.length;){f.lastIndex=eE?0:h;var y,m=QS(f,eE?s.slice(h):s);if(null===m||(y=nE(HS(f.lastIndex+(eE?h:0)),s.length))===p)h=KS(s,h,c);else{if(v.push(s.slice(p,h)),v.length===d)return v;for(var g=1;g<=m.length-1;g++)if(v.push(m[g]),v.length===d)return v;h=p=y}}return v.push(s.slice(p)),v}]}),!iE,eE);var aE={exports:{}},sE={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}(sE);var oE={exports:{}},uE={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}(uE),function(e){var t=vv.exports,n=uE.exports;function r(i,a,s){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}(oE),function(e){var t=gv.exports,n=vv.exports,r=sE.exports,i=oE.exports;function a(s){var o="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!==o){if(o.has(e))return o.get(e);o.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(s)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}(aE);var cE={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,s=i&&a&&"object"==Pa(n)&&n;!s||s.global!==s&&s.window!==s&&s.self!==s||(r=s);var o=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=g(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 m(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=o)for(;++n<r;)t(e[n],n,e);else h(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function g(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||{},s=a.userAgent||"";t||(t=s);var o,c,l=i?!!a.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(f.toString()),d="Object",b=i?d:"ScriptBridgingProxyObject",k=i?d:"Environment",w=i&&n.java?"JavaPackage":v(n.java),x=i?d:"RuntimeObject",_=/\bJava/.test(w)&&n.java,S=_&&v(n.environment)==k,E=_?"a":"α",T=_?"b":"β",R=n.document||{},C=n.operamini||n.opera,I=u.test(I=i&&C?C["[[Class]]"]:v(C))?I:C=null,O=t,P=[],A=null,j=t==s,M=j&&C&&"function"==typeof C.version&&C.version(),L=m([{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)})),N=function(e){return m(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"]),U=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 m(e,(function(e,n,r){return e||(n[U]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(U)]||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 m(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 m(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 m(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)&&!U&&(o=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(U=g(o[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),D&&!U?U=B([D]):D&&U&&(U=U.replace(RegExp("^("+y(D)+")[-_.\\s]","i"),D+" ").replace(RegExp("^("+y(D)+")[-_.]?(\\w)","i"),D+" $2")),(o=/\bGoogle TV\b/.exec(U))&&(U=o[0]),/\bSimulator\b/i.test(t)&&(U=(U?U+" ":"")+"Simulator"),"Opera Mini"==N&&/\bOPiOS\b/.test(t)&&P.push("running in Turbo/Uncompressed mode"),"IE"==N&&/\blike iPhone OS\b/.test(t)?(D=(o=e(t.replace(/like iPhone OS/,""))).manufacturer,U=o.product):/^iP/.test(U)?(N||(N="Safari"),F="iOS"+((o=/ OS ([\d_]+)/i.exec(t))?" "+o[1].replace(/_/g,"."):"")):"Konqueror"==N&&/^Linux\b/i.test(F)?F="Kubuntu":D&&"Google"!=D&&(/Chrome/.test(N)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(U))||/\bAndroid\b/.test(F)&&/^Chrome/.test(N)&&/\bVersion\//i.test(t)?(N="Android Browser",F=/\bAndroid\b/.test(F)?F:"Android"):"Silk"==N?(/\bMobi/i.test(t)||(F="Android",P.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&P.unshift("accelerated")):"UC Browser"==N&&/\bUCWEB\b/.test(t)?P.push("speed mode"):"PaleMoon"==N&&(o=/\bFirefox\/([\d.]+)\b/.exec(t))?P.push("identifying as Firefox "+o[1]):"Firefox"==N&&(o=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(F||(F="Firefox OS"),U||(U=o[1])):!N||(o=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(N))?(N&&!U&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(o+"/")+8))&&(N=null),(o=U||D||F)&&(U||D||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(F))&&(N=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(F)?F:o)+" Browser")):"Electron"==N&&(o=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&P.push("Chromium "+o),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(N),"(?:Firefox|Minefield|NetFront)"])),(o=("iCab"==L&&parseFloat(M)>3?"WebKit":/\bOpera\b/.test(N)&&(/\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(N)&&"NetFront")&&(L=[o]),"IE"==N&&(o=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(N+=" Mobile",F="Windows Phone "+(/\+$/.test(o)?o:o+".x"),P.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(N="IE Mobile",F="Windows Phone 8.x",P.unshift("desktop mode"),M||(M=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=N&&"Trident"==L&&(o=/\brv:([\d.]+)/.exec(t))&&(N&&P.push("identifying as "+N+(M?" "+M:"")),N="IE",M=o[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(_&&(O=(o=_.lang.System).getProperty("os.arch"),F=F||o.getProperty("os.name")+" "+o.getProperty("os.version")),S){try{M=n.require("ringo/engine").version.join("."),N="RingoJS"}catch(e){(o=n.system)&&o.global.system==n.system&&(N="Narwhal",F||(F=o[0].os||null))}N||(N="Rhino")}else"object"==Pa(n.process)&&!n.process.browser&&(o=n.process)&&("object"==Pa(o.versions)&&("string"==typeof o.versions.electron?(P.push("Node "+o.versions.node),N="Electron",M=o.versions.electron):"string"==typeof o.versions.nw&&(P.push("Chromium "+M,"Node "+o.versions.node),N="NW.js",M=o.versions.nw)),N||(N="Node.js",O=o.arch,F=o.platform,M=(M=/[\d.]+/.exec(o.version))?M[0]:null));else v(o=n.runtime)==b?(N="Adobe AIR",F=o.flash.system.Capabilities.os):v(o=n.phantom)==x?(N="PhantomJS",M=(o=o.version||null)&&o.major+"."+o.minor+"."+o.patch):"number"==typeof R.documentMode&&(o=/\bTrident\/(\d+)/i.exec(t))?(M=[M,R.documentMode],(o=+o[1]+4)!=M[1]&&(P.push("IE "+M[1]+" mode"),L&&(L[1]=""),M[1]=o),M="IE"==N?String(M[1].toFixed(1)):M[0]):"number"==typeof R.documentMode&&/^(?:Chrome|Firefox)\b/.test(N)&&(P.push("masking as "+N+" "+M),N="IE",M="11.0",L=["Trident"],F="Windows");F=F&&p(F)}if(M&&(o=/(?:[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(o)?"beta":"alpha",M=M.replace(RegExp(o+"\\+?$"),"")+("beta"==A?T:E)+(/\d+\+?/.exec(o)||"")),"Fennec"==N||"Firefox"==N&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(F))N="Firefox Mobile";else if("Maxthon"==N&&M)M=M.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(U))"Xbox 360"==U&&(F=null),"Xbox 360"==U&&/\bIEMobile\b/.test(t)&&P.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(N)&&(!N||U||/Browser|Mobi/.test(N))||"Windows CE"!=F&&!/Mobi/i.test(t))if("IE"==N&&j)try{null===n.external&&P.unshift("platform preview")}catch(e){P.unshift("embedded")}else(/\bBlackBerry\b/.test(U)||/\bBB10\b/.test(t))&&(o=(RegExp(U.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||M)?(F=((o=[o,/BB10/.test(t)])[1]?(U=null,D="BlackBerry"):"Device Software")+" "+o[0],M=null):this!=h&&"Wii"!=U&&(j&&C||/Opera/.test(N)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==N&&/\bOS X (?:\d+\.){2,}/.test(F)||"IE"==N&&(F&&!/^Win/.test(F)&&M>5.5||/\bWindows XP\b/.test(F)&&M>8||8==M&&!/\bTrident\b/.test(t)))&&!u.test(o=e.call(h,t.replace(u,"")+";"))&&o.name&&(o="ing as "+o.name+((o=o.version)?" "+o:""),u.test(N)?(/\bIE\b/.test(o)&&"Mac OS"==F&&(F=null),o="identify"+o):(o="mask"+o,N=I?p(I.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(o)&&(F=null),j||(M=null)),L=["Presto"],P.push(o));else N+=" Mobile";(o=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(o=[parseFloat(o.replace(/\.(\d)$/,".0$1")),o],"Safari"==N&&"+"==o[1].slice(-1)?(N="WebKit Nightly",A="alpha",M=o[1].slice(0,-1)):M!=o[1]&&M!=(o[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(M=null),o[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==o[0]&&537.36==o[2]&&parseFloat(o[1])>=28&&"WebKit"==L&&(L=["Blink"]),j&&(l||o[1])?(L&&(L[1]="like Chrome"),o=o[1]||((o=o[0])<530?1:o<532?2:o<532.05?3:o<533?4:o<534.03?5:o<534.07?6:o<534.1?7:o<534.13?8:o<534.16?9:o<534.24?10:o<534.3?11:o<535.01?12:o<535.02?"13+":o<535.07?15:o<535.11?16:o<535.19?17:o<536.05?18:o<536.1?19:o<537.01?20:o<537.11?"21+":o<537.13?23:o<537.18?24:o<537.24?25:o<537.36?26:"Blink"!=L?"27":"28")):(L&&(L[1]="like Safari"),o=(o=o[0])<400?1:o<500?2:o<526?3:o<533?4:o<534?"4+":o<535?5:o<537?6:o<538?7:o<601?8:o<602?9:o<604?10:o<606?11:o<608?12:"12"),L&&(L[1]+=" "+(o+="number"==typeof o?".x":/[.+]/.test(o)?"":"+")),"Safari"==N&&(!M||parseInt(M)>45)?M=o:"Chrome"==N&&/\bHeadlessChrome/i.test(t)&&P.unshift("headless")),"Opera"==N&&(o=/\bzbov|zvav$/.exec(F))?(N+=" ",P.unshift("desktop mode"),"zvav"==o?(N+="Mini",M=null):N+="Mobile",F=F.replace(RegExp(" *"+o+"$"),"")):"Safari"==N&&/\bChrome\b/.exec(L&&L[1])?(P.unshift("desktop mode"),N="Chrome Mobile",M=null,/\bOS X\b/.test(F)?(D="Apple",F="iOS 4.3+"):F=null):/\bSRWare Iron\b/.test(N)&&!M&&(M=q("Chrome")),M&&0==M.indexOf(o=/[\d.]+$/.exec(F))&&t.indexOf("/"+o+"-")>-1&&(F=g(F.replace(o,""))),F&&-1!=F.indexOf(N)&&!RegExp(N+" OS").test(F)&&(F=F.replace(RegExp(" *"+y(N)+" *"),"")),L&&!/\b(?:Avant|Nook)\b/.test(N)&&(/Browser|Lunascape|Maxthon/.test(N)||"Safari"!=N&&/^iOS/.test(F)&&/\bSafari\b/.test(L[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(N)&&L[1])&&(o=L[L.length-1])&&P.push(o),P.length&&(P=["("+P.join("; ")+")"]),D&&U&&U.indexOf(D)<0&&P.push("on "+D),U&&P.push((/^on /.test(P[P.length-1])?"":"on ")+U),F&&(o=/ ([\d.+]+)$/.exec(F),c=o&&"/"==F.charAt(F.length-o[0].length-1),F={architecture:32,family:o&&!c?F.replace(o[0],""):F,version:o?o[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(o=/\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(" *"+o),"")),N&&(/\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"==N&&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=N,z.prerelease=A,z.product=U,z.ua=t,z.version=N&&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(N),F&&N&&(F!=String(F).split(" ")[0]||F!=N.split(" ")[0]&&!U)&&P.push(U?"("+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)}(cE,cE.exports);var lE=Fe,fE=Dt,dE=Er,pE=w,hE=Up,vE=Vp;Lp("match",(function(e,t,n){return[function(t){var n=pE(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](dE(n))},function(e){var r=lE(this),i=dE(e),a=n(t,r,i);if(a.done)return a.value;if(!r.global)return vE(r,i);var s=r.unicode;r.lastIndex=0;for(var o,u=[],c=0;null!==(o=vE(r,i));){var l=dE(o[0]);u[c]=l,""===l&&(r.lastIndex=hE(i,fE(r.lastIndex),s)),c++}return 0===c?null:u}]}));var yE=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},mE=Fe,gE=w,bE=yE,kE=Er,wE=Vp;Lp("search",(function(e,t,n){return[function(t){var n=gE(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](kE(n))},function(e){var r=mE(this),i=kE(e),a=n(t,r,i);if(a.done)return a.value;var s=r.lastIndex;bE(s,0)||(r.lastIndex=0);var o=wE(r,i);return bE(r.lastIndex,s)||(r.lastIndex=s),null===o?-1:o.index}]}));var xE=Cn,_E=zt,SE=Lt,EE=Dt,TE=X,RE=Gr,CE=wa,IE=la("splice"),OE=Math.max,PE=Math.min,AE=9007199254740991,jE="Maximum allowed length exceeded";xE({target:"Array",proto:!0,forced:!IE},{splice:function(e,t){var n,r,i,a,s,o,u=TE(this),c=EE(u.length),l=_E(e,c),f=arguments.length;if(0===f?n=r=0:1===f?(n=0,r=c-l):(n=f-2,r=PE(OE(SE(t),0),c-l)),c+n-r>AE)throw TypeError(jE);for(i=RE(u,r),a=0;a<r;a++)(s=l+a)in u&&CE(i,a,u[s]);if(i.length=r,n<r){for(a=l;a<c-r;a++)o=a+n,(s=a+r)in u?u[o]=u[s]:delete u[o];for(a=c;a>c-r+n;a--)delete u[a-1]}else if(n>r)for(a=c-r;a>l;a--)o=a+n-1,(s=a+r-1)in u?u[o]=u[s]:delete u[o];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=zg.exports,r=mv.exports,i=Ry.exports,a=hv.exports,s=yv.exports,o=gv.exports,u=dv.exports,c=pv.exports,l=Iy.exports,f=Wg,d=bh.exports,p=gh,h=Sf.exports,v=eb.exports,y=Sb,m=aE.exports,g=ng,b=Ty,k=cE.exports;function w(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function x(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(n),S=w(r),E=w(i),T=w(a),R=w(s),C=w(o),I=w(u),O=w(c),P=w(l),A=w(f),j=w(d),M=x(h),L=x(v),N=w(m),U=x(k);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 I.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.13.10-rc.5",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"),s=r.twilsock||r.Twilsock||{};this.url=s.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 I.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}(),G=I.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var $=function(e){T.default(n,e);var t=V(n);function n(e,r,i,a,s){var o;return O.default(this,n),o=t.call(this),P.default(S.default(o),"method","init"),o.token=e,o.continuation_token=r,o.metadata=i,o.registrations=a,o.tweaks=s,o.capabilities=["client_update","offline_storage","telemetry.v1"],o}return I.default(n)}(G);function J(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var K=function(e){T.default(n,e);var t=J(n);function n(e,r,i,a,s,o,u){var c;return O.default(this,n),(c=t.call(this,e)).continuationToken=r,c.continuationTokenStatus=a,c.offlineStorage=s,c.initRegistrations=o,c.debugInfo=u,c.confirmedCapabilities=i,c}return I.default(n)}(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Y=function(e){T.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 I.default(n)}(G);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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Message=function(e){T.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 I.default(Message)}(G);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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Z=function(e){T.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 I.default(n)}(G);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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var te=function(e){T.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 I.default(n)}(G);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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var re=I.default((function e(t,n,r,i,a,s){O.default(this,e),this.start=t,this.end=n,this.title=r,this.details=i,this.id=a,this.type=s})),ie=function(e){T.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 I.default(n)}(G);function ae(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(Number("0x"+t))})).length}function se(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 oe(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(oe(e))}var ce=function(){function e(){O.default(this,e)}return I.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,s=t.payload_size;if(t.hasOwnProperty("payload_type")&&0!==t.payload_type.indexOf("application/json"))0===t.payload_type.indexOf("text/plain")&&(n=oe(r.subarray(a,a+s)));else try{n=ue(r.subarray(a,a+s))}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=se(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var fe=function(e){T.default(n,e);var t=le(n);function n(e){return O.default(this,n),t.call(this,e)}return I.default(n)}(N.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var pe=function(e){T.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 I.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var me=function(e){T.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 I.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 g.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 ge(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var be=function(e){T.default(i,e);var t,n,r=ge(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 me(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 s=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 s,a}return I.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=_.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=_.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(),setTimeout((function(){return t.fsm.socketClosed()}),0)}},{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),ke=function(){function e(){O.default(this,e)}return I.default(e,null,[{key:"getMetadata",value:function(e){var t,n,r,i,a,s,o,u,c=e&&e.clientMetadata?e.clientMetadata:{},l={env:null!==(t=U.name)&&void 0!==t?t:"unknown",envv:null!==(n=U.version)&&void 0!==n?n:"unknown",os:null!==(r=null===(i=U.os)||void 0===i?void 0:i.family)&&void 0!==r?r:"unknown",osv:null!==(a=null===(s=U.os)||void 0===s?void 0:s.version)&&void 0!==a?a:"unknown",osa:null!==(o=null===(u=U.os)||void 0===u?void 0:u.architecture)&&void 0!==o?o:"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 we=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 I.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=_.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=ke.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 K(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 xe(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var _e=function(e){T.default(r,e);var n=xe(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 I.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Ee=function(e){T.default(u,e);var t,n,r,i,a,s,o=Se(u);function u(e){var t;return O.default(this,u),(t=o.call(this)).transport=e,t.registrations=new Map,t.registrationsInProgress=new Map,t}return I.default(u,[{key:"putNotificationContext",value:(s=_.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 s.apply(this,arguments)})},{key:"deleteNotificationContext",value:(a=_.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=_.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=_.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=_.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=_.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 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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Re=function(e){T.default(n,e);var t=Te(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 I.default(n)}(fe);function Ce(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Ie=function(e){T.default(n,e);var t=Ce(n);function n(e){return O.default(this,n),t.call(this,e)}return I.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 I.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 Ie("Unable to connect: "+e.twilsock.getTerminationReason)),t.alreadyRejected=!0,clearTimeout(t.timeout)})),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:(t=_.default(A.default.mark((function e(t){var n,r,i,a,s,o,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,s=null!==(n=t.grant)&&void 0!==n?n:this.config.activeGrant,o={host:r.host,path:r.path,method:r.method,params:r.params,headers:i},u=new Message(s,i["Content-Type"]||"application/json",o),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 Re(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 Ie("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 I.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 I.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 I.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 Ne,Ue,De=new Le,Fe=function(){function e(t,n,r,i,a,s){O.default(this,e),this.title=t,this.details=n,this.start=r,this.type=a,this.id=s,this.end=i}return I.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,(Ne=e.TelemetryPoint||(e.TelemetryPoint={}))[Ne.Start=0]="Start",Ne[Ne.End=1]="End",e.EventSendingLimitation=void 0,(Ue=e.EventSendingLimitation||(e.EventSendingLimitation={}))[Ue.MinEventsPortion=0]="MinEventsPortion",Ue[Ue.AnyEvents=1]="AnyEvents",Ue[Ue.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 I.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var ze=I.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){T.default(f,t);var n,r,i,a,s,o,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 s=new _e(a.url),o=new we(s,a);return i.channel=new be(s,o,a),i.registrations=new Ee(o),i.upstream=new Ae(o,i.channel,a),i.telemetryTracker=new Be(a,o),i.channel.on("initialized",(function(){return i.telemetryTracker.canSendTelemetry=!0})),s.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 I.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(C.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=_.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=_.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:(o=_.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 o.apply(this,arguments)})},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:(s=_.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 s.apply(this,arguments)})},{key:"get",value:(a=_.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=_.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=_.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=_.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,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":j.default(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}([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 I.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=Ie,e.Twilsock=e.TwilsockClient,e.TwilsockError=fe}(qg);var ME={},LE=u,NE=o,UE=Fn,DE=nn,FE=c,BE=X,qE=k,zE=Object.assign,WE=Object.defineProperty,GE=!zE||NE((function(){if(LE&&1!==zE({b:1},zE(WE({},"a",{enumerable:!0,get:function(){WE(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!=zE({},e)[n]||UE(zE({},t)).join("")!=r}))?function(e,t){for(var n=BE(e),r=arguments.length,i=1,a=DE.f,s=FE.f;r>i;)for(var o,u=qE(arguments[i++]),c=a?UE(u).concat(a(u)):UE(u),l=c.length,f=0;l>f;)o=c[f++],LE&&!s.call(u,o)||(n[o]=u[o]);return n}:zE,VE=GE;Cn({target:"Object",stat:!0,forced:Object.assign!==VE},{assign:VE}),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=zg.exports,n=pv.exports,r=dv.exports,i=hv.exports,a=yv.exports,s=gv.exports,o=Wg,u=bh.exports,c=qg,l=mv.exports,f=Iy.exports,d=ng,p=Th.exports,h=uv.exports,v=Sf.exports,y=Sb,m=gh;function g(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 k=g(t),w=g(n),x=g(r),_=g(i),S=g(a),E=g(s),T=g(o),R=g(u),C=g(l),I=g(f),O=g(p),P=g(h),A=b(v),j=b(y);function M(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":R.default(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function L(e,t){if("object"===("undefined"==typeof Reflect?"undefined":R.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function N(){}function U(){U.init.call(this)}function D(e){return void 0===e._maxListeners?U.defaultMaxListeners:e._maxListeners}function F(e,t,n){if(t)e.call(n);else for(var r=e.length,i=J(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=J(e,i),s=0;s<i;++s)a[s].call(n,r)}function q(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,s=J(e,a),o=0;o<a;++o)s[o].call(n,r,i)}function z(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var s=e.length,o=J(e,s),u=0;u<s;++u)o[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=J(e,i),s=0;s<i;++s)a[s].apply(n,r)}function G(e,t,n,r){var i,a,s,o;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),s=a[t]):(a=e._events=new N,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=D(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,o=u,"function"==typeof console.warn?console.warn(o):console.log(o)}}else s=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 J(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}N.prototype=Object.create(null),U.EventEmitter=U,U.usingDomains=!1,U.prototype.domain=void 0,U.prototype._events=void 0,U.prototype._maxListeners=void 0,U.defaultMaxListeners=10,U.init=function(){this.domain=null,U.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new N,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},U.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},U.prototype.getMaxListeners=function(){return D(this)},U.prototype.emit=function(e){var t,n,r,i,a,s,o,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){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=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=s[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},U.prototype.addListener=function(e,t){return G(this,e,t,!1)},U.prototype.on=U.prototype.addListener,U.prototype.prependListener=function(e,t){return G(this,e,t,!0)},U.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},U.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},U.prototype.removeListener=function(e,t){var n,r,i,a,s;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 N:(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){s=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 N,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,s||t)}return this},U.prototype.off=function(e,t){return this.removeListener(e,t)},U.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new N,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new N: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 N,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},U.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},U.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):$.call(e,t)},U.prototype.listenerCount=$,U.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var K=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(){w.default(this,e)}return x.default(e,[{key:"setLevel",value:function(e){K.setLevel(e)}},{key:"trace",value:function(){if(K.getLevel()==K.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];K.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];K.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];K.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];K.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];K.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=x.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;w.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){_.default(r,e);var t,n=X(r);function r(e){var t;return w.default(this,r),t=n.call(this),I.default(C.default(t),"desiredState",new Z),I.default(C.default(t),"currentState",new Z),I.default(C.default(t),"_hasActiveAttempt",!1),t.channelType=e,t}return x.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=k.default(T.default.mark((function e(){var t,n,r,i,a,s;return T.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:s=e.sent,this.currentState.token=s.token,this.currentState.notificationId=s.notificationId,this.currentState.messageTypes=new Set(s.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}(U);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){_.default(a,e);var t,n,r,i=ne(a);function a(e,t,n,r){var s;return w.default(this,a),s=i.call(this,e),I.default(C.default(s),"registrationId",null),s.context=t,s.twilsock=n,s.registrarUrl=r,s}return x.default(a,[{key:"updateRegistration",value:(r=k.default(T.default.mark((function e(t,n){var r,i,a,s,o,u=this;return T.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),s={"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,s,r,i)}));case 15:o=e.sent,this.registrationId=o.body.id,Q.debug("Registration created: ",o),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=k.default(T.default.mark((function e(){var t,n,r,i=this;return T.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=k.default(T.default.mark((function e(t){var n,r,i,a,s=this;return T.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 s.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 se,oe=function(e){_.default(a,e);var t,n,r,i=ae(a);function a(e,t,n){var r;return w.default(this,a),r=i.call(this,"twilsock"),I.default(C.default(r),"contextId",j.v4()),r.productId=e,r.platform=t,r.twilsock=n,r}return x.default(a,[{key:"updateRegistration",value:(r=k.default(T.default.mark((function e(t,n){var r,i;return T.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=k.default(T.default.mark((function e(){return T.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=k.default(T.default.mark((function e(t){return T.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=m.literal("apn","fcm","twilsock");e.Notifications=se=function(e){_.default(Client,e);var t,n,r,i=ue(Client);function Client(e){var t,n,r,a,s,o,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};w.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!==(s=null!==(o=h.region)&&void 0!==o?o:l.region)&&void 0!==s?s:"us1",y="https://ers.".concat(v,".twilio.com/v1/registrations"),m=h.ersUrl||y;u.connectors=new Map;var g=se._detectPlatform();return u.connectors.set("apn",new ie("apn",{protocolVersion:4,productId:f,platform:g},p,m)),u.connectors.set("fcm",new ie("fcm",{protocolVersion:3,productId:f,platform:g},p,m)),u.connectors.set("twilsock",new oe(f,g,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 x.default(Client,[{key:"shutdown",value:(r=k.default(T.default.mark((function e(){return T.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=k.default(T.default.mark((function e(){var t;return T.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=k.default(T.default.mark((function e(t,n){return T.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}(U),M([m.validateTypes(ce,m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),M([m.validateTypes(ce,m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),M([m.validateTypes(ce,m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),M([m.validateTypes(m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),M([m.validateTypesAsync(ce,m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=se=M([m.validateConstructorTypes(m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),L("design:paramtypes",[String,Object])],e.Notifications)}(ME);var $E={};Object.defineProperty($E,"__esModule",{value:!0});var JE=zg.exports,KE=pv.exports,HE=dv.exports,YE=mv.exports,QE=hv.exports,XE=yv.exports,ZE=gv.exports,eT=Iy.exports,tT=Wg,nT=bh.exports,rT=gh,iT=qg,aT=aE.exports,sT=Sf.exports,oT=Th.exports,uT=ng,cT=Sb,lT=Ry.exports,fT=cE.exports;function dT(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function pT(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 hT=dT(JE),vT=dT(KE),yT=dT(HE),mT=dT(YE),gT=dT(QE),bT=dT(XE),kT=dT(ZE),wT=dT(eT),xT=dT(tT),_T=dT(nT),ST=dT(aT),ET=pT(sT),TT=dT(oT),RT=pT(cT),CT=dT(lT),IT=pT(fT);function OT(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":_T.default(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function PT(e,t){if("object"===("undefined"==typeof Reflect?"undefined":_T.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function AT(){}function jT(){jT.init.call(this)}function MT(e){return void 0===e._maxListeners?jT.defaultMaxListeners:e._maxListeners}function LT(e,t,n){if(t)e.call(n);else for(var r=e.length,i=WT(e,r),a=0;a<r;++a)i[a].call(n)}function NT(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=WT(e,i),s=0;s<i;++s)a[s].call(n,r)}function UT(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,s=WT(e,a),o=0;o<a;++o)s[o].call(n,r,i)}function DT(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var s=e.length,o=WT(e,s),u=0;u<s;++u)o[u].call(n,r,i,a)}function FT(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=WT(e,i),s=0;s<i;++s)a[s].apply(n,r)}function BT(e,t,n,r){var i,a,s,o;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),s=a[t]):(a=e._events=new AT,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=MT(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,o=u,"function"==typeof console.warn?console.warn(o):console.log(o)}}else s=a[t]=n,++e._eventsCount;return e}function qT(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 zT(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 WT(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}AT.prototype=Object.create(null),jT.EventEmitter=jT,jT.usingDomains=!1,jT.prototype.domain=void 0,jT.prototype._events=void 0,jT.prototype._maxListeners=void 0,jT.defaultMaxListeners=10,jT.init=function(){this.domain=null,jT.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new AT,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},jT.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},jT.prototype.getMaxListeners=function(){return MT(this)},jT.prototype.emit=function(e){var t,n,r,i,a,s,o,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){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=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:LT(n,l,this);break;case 2:NT(n,l,this,arguments[1]);break;case 3:UT(n,l,this,arguments[1],arguments[2]);break;case 4:DT(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];FT(n,l,this,i)}return!0},jT.prototype.addListener=function(e,t){return BT(this,e,t,!1)},jT.prototype.on=jT.prototype.addListener,jT.prototype.prependListener=function(e,t){return BT(this,e,t,!0)},jT.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,qT(this,e,t)),this},jT.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,qT(this,e,t)),this},jT.prototype.removeListener=function(e,t){var n,r,i,a,s;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 AT:(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){s=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 AT,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,s||t)}return this},jT.prototype.off=function(e,t){return this.removeListener(e,t)},jT.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new AT,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new AT: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 AT,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},jT.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},jT.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):zT.call(e,t)},jT.prototype.listenerCount=zT,jT.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var GT=function(){function e(t){vT.default(this,e),this.base=t,this.args=new Array,this.paths=new Array}return yT.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 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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var SyncError=function(e){gT.default(SyncError,e);var t=VT(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 vT.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 SyncError}(ST.default(Error)),$T=function(e){gT.default(n,e);var t=VT(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,s=arguments.length>3?arguments[3]:void 0;return vT.default(this,n),(r=t.call(this,e,i,a)).body=s,r}return n}(SyncError);function JT(e){return JSON.parse(JSON.stringify(e))}function KT(e){if(!(void 0===e||HT(e)))throw new SyncError("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function HT(e){return function(e){return!isNaN(parseInt(e))&&isFinite(e)}(e)&&e>0}var YT=ET.getLogger("twilio-sync");function QT(e,t){return["".concat((new Date).toISOString()," Sync ").concat(e,":")].concat(Array.from(t))}var XT=function(e){YT.setLevel(e)},ZT=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];YT.trace.apply(null,QT("T",t))},eR=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];YT.debug.apply(null,QT("D",t))},tR=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];YT.warn.apply(null,QT("W",t))},nR=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];YT.error.apply(null,QT("E",t))},rR="/v4/Subscriptions",iR="/v3/Maps",aR="/v3/Lists",sR="/v3/Documents",oR="/v3/Streams",uR="/v3/Insights";function cR(e,t,n){return e&&void 0!==e[t]?e[t]:n}var lR=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};vT.default(this,e);var n=t.region||"us1",r="https://cds.".concat(n,".twilio.com"),i=t.cdsUri||r;this.settings={subscriptionsUri:i+rR,documentsUri:i+sR,listsUri:i+aR,mapsUri:i+iR,streamsUri:i+oR,insightsUri:i+uR,sessionStorageEnabled:cR(t.Sync,"enableSessionStorage",!0),productId:t.productId}}return yT.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 fR(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 dR(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 dR(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function dR(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 pR=function(){function e(t){vT.default(this,e),this.localObject=t,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return yT.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}(),hR=function(){function e(t){var n=this;vT.default(this,e),wT.default(this,"isConnected",!1),wT.default(this,"maxBatchSize",100),wT.default(this,"subscriptionTtlTimer",null),wT.default(this,"pendingPokeReason",null),this.services=t,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;this.backoff=uT.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(),eR("All subscriptions resolved."))}))}var t;return yT.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function e(e,t,n,r){var i,a=[],s=fR(e);try{for(s.s();!(i=s.n()).done;){var o=TT.default(i.value,2),u=o[0],c=o[1];if(!t.get(u)&&n!==c.pendingAction&&!c.rejectedWithError&&(a.push(c),r&&a.length>=r))break}}catch(e){s.e(e)}finally{s.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=hT.default(xT.default.mark((function e(t,n){var r,i,a,s,o,u,c,l,f,d,p,h,v=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=4;break}return eR("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=fR(n);try{for(i.s();!(a=i.n()).done;)s=a.value,this.recordActionAttemptOn(s,t,r)}catch(e){i.e(e)}finally{i.f()}return o=this.pendingPokeReason,this.pendingPokeReason=null,e.prev=10,e.next=13,this.request(t,r,o,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):nR("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=fR(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 iT.TransportUnavailableError?(eR("Twilsock connection (required for subscription) not ready (c:".concat(r,"); waiting…")),this.backoff.reset()):(eR("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;eR("Attempting '".concat(e,"' request (c:").concat(t,"):"),i);var s={event_protocol_version:4,action:e,correlation_id:t,retried_requests:a,ttl_in_s:-1,requests:i};return"ttl"===n&&(s.reason=n),this.services.network.post(this.services.config.subscriptionsUri,s)}},{key:"add",value:function(e,t){eR("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 pR(t)),this.persist())}},{key:"remove",value:function(e){eR("Establishing intent to unsubscribe from ".concat(e)),this.subscriptions.delete(e)&&this.persist()}},{key:"acceptMessage",value:function(e,t){ZT("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,s=fR(r);try{for(s.s();!(a=s.n()).done;){var o=a.value,u=void 0;switch(e.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(o,i);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(o,i);break;case"subscription_failed":this.applySubscriptionFailedMessage(o,i);break;case(u=n.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:var c=void 0;switch(u[0]){case"map_":c=o.map_sid;break;case"list_":c=o.list_sid;break;case"document_":c=o.document_sid;break;case"stream_":c=o.stream_sid;break;case"live_query_":c=o.query_id,t=!1,!0===e.strictly_ordered&&(t=!0);break;default:c=void 0}this.applyEventToSubscribedEntity(c,o,n,t);break;default:eR("Dropping unknown message type ".concat(n))}}}catch(e){s.e(e)}finally{s.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?(eR("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&&(eR("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()):eR("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)):eR("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&&(nR("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)):eR("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){eR("Triggering event replay for all subscriptions, reason=".concat(e)),this.pendingPokeReason=e,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var t,n=[],r=fR(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,s=n;a<s.length;a++){var o=s[a];this.persisted.set(o.sid,o)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}();function vR(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 yR(e){return e.body?e.body.code:0}function mR(e){return 409===e.status?new $T(vR(e),e.status,yR(e),e.body):e.status?new SyncError(vR(e),e.status,yR(e)):e instanceof iT.TransportUnavailableError?e:new SyncError(e.message,0,0)}var gR=function(){function e(t,n,r){vT.default(this,e),this.clientInfo=t,this.config=n,this.transport=r}return yT.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+RT.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 s=new uT.Retrier(t.backoffConfig());s.on("attempt",(function(){e().then((function(e){return s.succeeded(e)})).catch((function(e){if(a.includes(e.status)){var t=parseInt(e.headers?e.headers["Retry-After"]:null);s.failed(mR(e),isNaN(t)?null:1e3*t)}else"Twilsock disconnected"===e.message?s.failed(mR(e)):(s.removeAllListeners(),s.cancel(),i(mR(e)))}))})),s.on("succeeded",(function(e){r(e)})),s.on("cancelled",(function(e){return i(mR(e))})),s.on("failed",(function(e){return i(mR(e))})),s.start()}))}},{key:"get",value:function(e){var t=this,n=this.createHeaders();return eR("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),eR("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),eR("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 eR("DELETE",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry((function(){return t.transport.delete(e,n,t.config.productId)}),!1)}}]),e}(),bR=function(){function e(t,n){vT.default(this,e),this.config=t,this.storageId=null;try{this.storage=n||sessionStorage}catch(e){}}return yT.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 kR(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 wR(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 wR(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function wR(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 xR=function(){function e(t,n){vT.default(this,e),this.services=t,this.removalHandler=n,this.subscriptionState="none",this._attachedListeners=new Map}return yT.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,t){var n,r=kR(this._attachedListeners.values());try{for(r.s();!(n=r.n()).done;){n.value.emit(e,t)}}catch(e){r.e(e)}finally{r.f()}}}]),e}(),_R=function(){function e(t){vT.default(this,e),wT.default(this,"queuedRequests",[]),wT.default(this,"isRequestInFlight",!1),this.inputMergingFunction=t}return yT.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}(),SR=function(){function e(t){vT.default(this,e),wT.default(this,"queueByNamespaceKey",new Map),this.inputReducer=t}var t,n,r;return yT.default(e,[{key:"add",value:(r=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queueByNamespaceKey.has(t)||this.queueByNamespaceKey.set(t,new _R(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 ER(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var TR=function(e){gT.default(n,e);var t=ER(n);function n(){var e;return vT.default(this,n),(e=t.call(this)).closed=!1,e.uuid=cT.v4(),e}return yT.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}(jT);function RR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var CR=function(e){gT.default(f,e);var t,n,r,i,a,s,o,u,c,l=RR(f);function f(e,t,n){var r;vT.default(this,f),r=l.call(this,e,n),wT.default(mT.default(r),"isDeleted",!1);return r.updateMergingQueue=new _R((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 yT.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){ZT("Document update skipped, current:",this.lastEventId,", remote:",e.id);break}var t=void 0!==this.descriptor.data?JT(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=hT.default(xT.default.mark((function e(t,n){var r,i=this;return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i=this;return xT.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:(o=hT.default(xT.default.mark((function e(t,n){return xT.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 o.apply(this,arguments)})},{key:"setTtl",value:(s=hT.default(xT.default.mark((function e(t){var n;return xT.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 s.apply(this,arguments)})},{key:"_setUnconditionally",value:(a=hT.default(xT.default.mark((function e(t,n){var r;return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i,a;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t(JT(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?JT(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=hT.default(xT.default.mark((function e(t){var n,r,i;return xT.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=hT.default(xT.default.mark((function e(){var t=this;return xT.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):nR("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?JT(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=hT.default(xT.default.mark((function e(){return xT.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}(xR),IR=function(e){gT.default(o,e);var t,n,r,i,a,s=RR(o);function o(e){var t;return vT.default(this,o),(t=s.call(this)).syncDocumentImpl=e,t.syncDocumentImpl.attach(mT.default(t)),t}return yT.default(o,[{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 CR.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(){return xT.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(){CT.default(kT.default(o.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return CR.type}}]),o}(TR);wT.default(IR,"removed","removed"),wT.default(IR,"updated","updated"),OT([rT.validateTypesAsync(rT.pureObject,["undefined",rT.objectSchema("document metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object,Object]),PT("design:returntype",Promise)],IR.prototype,"set",null),OT([rT.validateTypesAsync("function",["undefined",rT.objectSchema("document metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Function,Object]),PT("design:returntype",Promise)],IR.prototype,"mutate",null),OT([rT.validateTypesAsync(rT.pureObject,["undefined",rT.objectSchema("document metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object,Object]),PT("design:returntype",Promise)],IR.prototype,"update",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],IR.prototype,"setTtl",null);var OR=function(){function e(t){vT.default(this,e),this.descriptor=t}return yT.default(e,[{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}},{key:"update",value:function(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,n,r){vT.default(this,Paginator),this.prevToken=n,this.nextToken=r,this.items=e,this.source=t}var e,t;return yT.default(Paginator,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:(t=hT.default(xT.default.mark((function e(){return xT.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(this.nextToken));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"prevPage",value:(e=hT.default(xT.default.mark((function e(){return xT.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(this.prevToken));case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]),Paginator}();function PR(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 AR(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 AR(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function AR(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 jR=function(){function e(t,n){vT.default(this,e),this.balanceFactor=0,this.key=t,this.value=n,this.parent=null,this.left=null,this.right=null}return yT.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}(),MR=function(){function e(t,n){vT.default(this,e),this.isLessThan=t||function(e,t){return e<t},this.isEqual=n||function(e,t){return e===t},this.root=null,this.count=null}return yT.default(e,[{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 jR(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 s=t.left;s.right;)s=s.right;if(t.left===s)t.isRoot?(this.root=s,s.parent=null):(t.isLeftChild?t.parent.left=s:t.parent.right=s,s.parent=t.parent),s.right=t.right,s.right.parent=s,s.balanceFactor=t.balanceFactor,t={parent:s,isLeftChild:!0};else{var o=s.parent,u=s.left;o.right=u,u&&(u.parent=o),t.isRoot?(this.root=s,s.parent=null):(t.isLeftChild?t.parent.left=s:t.parent.right=s,s.parent=t.parent),s.right=t.right,s.right.parent=s,s.left=t.left,s.left.parent=s,s.balanceFactor=t.balanceFactor,t={parent:o,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:Symbol.iterator,value:xT.default.mark((function e(){var t,n,r;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=PR(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:xT.default.mark((function e(){var t,n,r,i=arguments;return xT.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:xT.default.mark((function e(){var t,n,r,i=arguments;return xT.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)}))}]),e}();function LR(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 NR(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 NR(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function NR(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 UR=function(){function e(t,n){vT.default(this,e),this.value=t,this.revision=n||0}return yT.default(e,[{key:"isValid",get:function(){return!0}}]),e}(),DR=function(){function e(t){vT.default(this,e),this.revision=t}return yT.default(e,[{key:"isValid",get:function(){return!1}}]),e}(),FR=function(){function e(){vT.default(this,e),this.items=new MR}return yT.default(e,[{key:"store",value:function(e,t,n){var r=this.items.get(e);return r&&r.revision>n?r.isValid?r.value:null:(this.items.set(e,new UR(t,n)),t)}},{key:"delete",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.items.get(e);(!r||r.revision<t||r&&!0===n)&&this.items.set(e,new DR(t))}},{key:"isKnown",value:function(e,t){var n=this.items.get(e);return n&&n.revision>=t}},{key:"get",value:function(e){var t=this.items.get(e);return t&&t.isValid?t.value:null}},{key:"has",value:function(e){var t=this.items.get(e);return t&&t.isValid}},{key:"forEach",value:function(e){if(this.items){var t,n=LR(this.items);try{for(n.s();!(t=n.n()).done;){var r=TT.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}();function BR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var qR=function(e){gT.default(y,e);var t,n,r,i,a,s,o,u,c,l,f,d,p,h,v=BR(y);function y(e,t,n){var r;vT.default(this,y);return(r=v.call(this,e,n)).updateMergingQueue=new SR((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new FR,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return yT.default(y,[{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:(h=hT.default(xT.default.mark((function e(t,n,r,i){var a,s;return xT.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(s=e.sent).body.data=n,s.body.date_updated=new Date(s.body.date_updated),e.abrupt("return",s.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r){return h.apply(this,arguments)})},{key:"push",value:(p=hT.default(xT.default.mark((function e(t,n){var r,i,a;return xT.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.get(a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"set",value:(d=hT.default(xT.default.mark((function e(t,n,r){var i,a=this;return xT.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 d.apply(this,arguments)})},{key:"_updateItemUnconditionally",value:(f=hT.default(xT.default.mark((function e(t,n,r){var i,a;return xT.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.uri,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.get(t));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return f.apply(this,arguments)})},{key:"_updateItemWithIfMatch",value:(l=hT.default(xT.default.mark((function e(t,n,r){var i,a,s,o;return xT.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(JT(i.data)))){e.next=25;break}return s=i.revision,e.prev=6,e.next=9,this._addOrUpdateItemOnServer(i.uri,a,s,r);case 9:return o=e.sent,this._handleItemMutated(t,o.url,o.last_event_id,o.revision,o.data,o.date_updated,o.date_expires,!1,!1),e.abrupt("return",this.cache.get(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 l.apply(this,arguments)})},{key:"mutate",value:(c=hT.default(xT.default.mark((function e(t,n,r){var i,a=this;return xT.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 c.apply(this,arguments)})},{key:"update",value:(u=hT.default(xT.default.mark((function e(t,n,r){return xT.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 u.apply(this,arguments)})},{key:"remove",value:(o=hT.default(xT.default.mark((function e(t){var n,r,i;return xT.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=JT(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 o.apply(this,arguments)})},{key:"get",value:function(){var e=hT.default(xT.default.mark((function e(t){var n;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))){e.next=5;break}return e.abrupt("return",n);case 5:return e.abrupt("return",this._getItemFromServer(t));case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(s=hT.default(xT.default.mark((function e(t){var n;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({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 s.apply(this,arguments)})},{key:"queryItems",value:function(){var e=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new GT(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Index",t.index).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map((function(e){return e.date_updated=new Date(e.date_updated),s.cache.get(e.index)?s._handleItemMutated(e.index,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):s.cache.store(Number(e.index),new OR({index:Number(e.index),uri:e.url,revision:e.revision,lastEventId:e.last_event_id,dateUpdated:e.date_updated,dateExpires:e.date_expires,data:e.data}),e.last_event_id),s.cache.get(e.index)})),a=r.body.meta,e.abrupt("return",new Paginator(i,(function(e){return s.queryItems({pageToken:e})}),a.previous_token,a.next_token));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:(a=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return KT((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=hT.default(xT.default.mark((function e(){var t;return xT.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=hT.default(xT.default.mark((function e(t){var n,r;return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i,a;return xT.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:"removeList",value:(t=hT.default(xT.default.mark((function e(){return xT.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,void 0,"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,s,o,u){if(this.shouldIgnoreEvent(e,n))ZT("Item ".concat(e," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(n));else{this._updateRootDateUpdated(a);var c=this.cache.get(e);if(!c){var l=new OR({index:e,uri:t,lastEventId:n,revision:r,data:i,dateUpdated:a,dateExpires:s});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,o)}var f=JT(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==s&&c.updateDateExpires(s),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):(ZT("Context update skipped, current:",this.lastEventId,", remote:",t),!1)}}],[{key:"type",get:function(){return"list"}}]),y}(xR),zR=function(e){gT.default(p,e);var t,n,r,i,a,s,o,u,c,l,f,d=BR(p);function p(e){var t;return vT.default(this,p),(t=d.call(this)).syncListImpl=e,t.syncListImpl.attach(mT.default(t)),t}return yT.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 qR.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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:(o=hT.default(xT.default.mark((function e(t){return xT.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 o.apply(this,arguments)})},{key:"get",value:(s=hT.default(xT.default.mark((function e(t){return xT.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 s.apply(this,arguments)})},{key:"getContext",value:(a=hT.default(xT.default.mark((function e(){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(){return xT.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(){CT.default(kT.default(p.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return qR.type}}]),p}(TR);wT.default(zR,"itemAdded","itemAdded"),wT.default(zR,"itemUpdated","itemUpdated"),wT.default(zR,"itemRemoved","itemRemoved"),wT.default(zR,"removed","removed"),OT([rT.validateTypesAsync(rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object,Object]),PT("design:returntype",Promise)],zR.prototype,"push",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger,rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Number,Object,Object]),PT("design:returntype",Promise)],zR.prototype,"set",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger,"function",["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Number,Function,Object]),PT("design:returntype",Promise)],zR.prototype,"mutate",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger,rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Number,Object,Object]),PT("design:returntype",Promise)],zR.prototype,"update",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],zR.prototype,"remove",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],zR.prototype,"get",null),OT([rT.validateTypesAsync(["undefined",rT.objectSchema("query options",{from:[rT.nonNegativeInteger,"undefined"],pageSize:[rT.custom((function(e){return[HT(e),"a positive integer"]})),"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],zR.prototype,"getItems",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],zR.prototype,"setTtl",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger,rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number,Number]),PT("design:returntype",Promise)],zR.prototype,"setItemTtl",null);var WR=function(){function e(t){vT.default(this,e),this.descriptor=t}return yT.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:"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 GR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var VR=function(e){gT.default(h,e);var t,n,r,i,a,s,o,u,c,l,f,d,p=GR(h);function h(e,t,n){var r;vT.default(this,h);return(r=p.call(this,e,n)).updateMergingQueue=new SR((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new FR,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 WR(e),e.last_event_id)})),r}return yT.default(h,[{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:(d=hT.default(xT.default.mark((function e(t,n,r){var i,a=this;return xT.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 d.apply(this,arguments)})},{key:"get",value:function(){var e=hT.default(xT.default.mark((function e(t){return xT.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.get(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:(f=hT.default(xT.default.mark((function e(t){var n;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({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 f.apply(this,arguments)})},{key:"mutate",value:(l=hT.default(xT.default.mark((function e(t,n,r){var i,a=this;return xT.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 l.apply(this,arguments)})},{key:"update",value:(c=hT.default(xT.default.mark((function e(t,n,r){return xT.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 c.apply(this,arguments)})},{key:"_putItemUnconditionally",value:(u=hT.default(xT.default.mark((function e(t,n,r){var i,a;return xT.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.get(a.key));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"_putItemWithIfMatch",value:(o=hT.default(xT.default.mark((function e(t,n,r){var i,a,s,o,u;return xT.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 WR({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(JT(i.data)))){e.next=26;break}return s=i.revision,e.prev=6,e.next=9,this._putItemToServer(t,a,s,r);case 9:return o=e.sent,u=o.item,this._handleItemMutated(u.key,u.url,u.last_event_id,u.revision,u.data,u.date_updated,u.date_expires,o.added,!1),e.abrupt("return",this.cache.get(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 o.apply(this,arguments)})},{key:"_putItemToServer",value:(s=hT.default(xT.default.mark((function e(t,n,r,i){var a,s,o,u,c;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new GT(this.links.items).pathSegment(t).build(),s={data:n},void 0!==i&&(s.ttl=i),e.prev=3,e.next=6,this.services.network.put(a,s,r);case 6:return o=e.sent,(u=o.body).data=n,u.date_updated=new Date(u.date_updated),c=201===o.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 s.apply(this,arguments)})},{key:"remove",value:(a=hT.default(xT.default.mark((function e(t){var n,r,i;return xT.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=JT(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 a.apply(this,arguments)})},{key:"queryItems",value:function(){var e=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new GT(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Key",t.key).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map((function(e){return e.date_updated=new Date(e.date_updated),s.cache.get(e.key)?s._handleItemMutated(e.key,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):s.cache.store(e.key,new WR(e),e.last_event_id),s.cache.get(e.key)})),a=r.body.meta,e.abrupt("return",new Paginator(i,(function(e){return s.queryItems({pageToken:e})}),a.previous_token,a.next_token));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:(i=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return KT((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,void 0,"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,s,o,u){if(this.shouldIgnoreEvent(e,n))ZT("SyncMapItem ",e," update skipped, current:",this.lastEventId,", remote:",n);else{this._updateRootDateUpdated(a);var c=this.cache.get(e);if(!c){var l=new WR({key:e,url:t,last_event_id:n,revision:r,data:i,date_updated:a,date_expires:s});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,o)}var f=JT(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==s&&c.updateDateExpires(s),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=hT.default(xT.default.mark((function e(t){var n,r;return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i,a;return xT.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=hT.default(xT.default.mark((function e(){return xT.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"}}]),h}(xR),$R=function(e){gT.default(f,e);var t,n,r,i,a,s,o,u,c,l=GR(f);function f(e){var t;return vT.default(this,f),(t=l.call(this)).syncMapImpl=e,t.syncMapImpl.attach(mT.default(t)),t}return yT.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 VR.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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:(o=hT.default(xT.default.mark((function e(t,n,r){return xT.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 o.apply(this,arguments)})},{key:"update",value:(s=hT.default(xT.default.mark((function e(t,n,r){return xT.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 s.apply(this,arguments)})},{key:"remove",value:(a=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(){return xT.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(){CT.default(kT.default(f.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return VR.type}}]),f}(TR);function JR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}wT.default($R,"itemAdded","itemAdded"),wT.default($R,"itemUpdated","itemUpdated"),wT.default($R,"itemRemoved","itemRemoved"),wT.default($R,"removed","removed"),OT([rT.validateTypesAsync("string",rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[String,Object,Object]),PT("design:returntype",Promise)],$R.prototype,"set",null),OT([rT.validateTypesAsync("string"),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],$R.prototype,"get",null),OT([rT.validateTypesAsync("string","function",["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[String,Function,Object]),PT("design:returntype",Promise)],$R.prototype,"mutate",null),OT([rT.validateTypesAsync("string",rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[String,Object,Object]),PT("design:returntype",Promise)],$R.prototype,"update",null),OT([rT.validateTypesAsync("string"),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],$R.prototype,"remove",null),OT([rT.validateTypesAsync(["undefined",rT.objectSchema("query options",{from:["string","undefined"],pageSize:[rT.custom((function(e){return[HT(e),"a positive integer"]})),"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],$R.prototype,"getItems",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],$R.prototype,"setTtl",null),OT([rT.validateTypesAsync("string",rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[String,Number]),PT("design:returntype",Promise)],$R.prototype,"setItemTtl",null);var KR=function(e){gT.default(a,e);var t,n,r,i=JR(a);function a(e,t,n){var r;return vT.default(this,a),(r=i.call(this,e,n)).descriptor=t,r}return yT.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=hT.default(xT.default.mark((function e(t){var n,r,i,a;return xT.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=hT.default(xT.default.mark((function e(t){var n,r;return xT.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=hT.default(xT.default.mark((function e(){return xT.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}(xR);OT([rT.validateTypesAsync(rT.pureObject),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],KR.prototype,"publishMessage",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],KR.prototype,"setTtl",null);var HR=function(e){gT.default(a,e);var t,n,r,i=JR(a);function a(e){var t;return vT.default(this,a),(t=i.call(this)).syncStreamImpl=e,t.syncStreamImpl.attach(mT.default(t)),t}return yT.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 KR.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(){return xT.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(){CT.default(kT.default(a.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return KR.type}}]),a}(TR);wT.default(HR,"messagePublished","messagePublished"),wT.default(HR,"removed","removed"),OT([rT.validateTypesAsync(rT.pureObject),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],HR.prototype,"publishMessage",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],HR.prototype,"setTtl",null);var YR=function e(t){vT.default(this,e),this.sdk="js",this.sdkVer=t,this.os=IT.os.family,this.osVer=IT.os.version,this.pl=IT.name,this.plVer=IT.version},QR=function(){function e(){vT.default(this,e),this.names=new Map,this.entities=new Map}return yT.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 XR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var ZR=function(e){gT.default(n,e);var t=XR(n);function n(e,r,i,a){var s;return vT.default(this,n),(s=t.call(this,r,i)).descriptor=e,s.cache=new FR,a&&a.forEach((function(e){s.cache.store(e.key,{key:e.key,value:e.data},e.revision)})),s}return yT.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))ZT("Item ".concat(e," update skipped, revision: ").concat(n));else{var r={key:e,value:t};this.cache.store(e,r,n),this.broadcastEventToListeners("itemUpdated",r)}}},{key:"handleItemRemoved",value:function(e,t){var n=null===t;this.shouldIgnoreEvent(e,t)?ZT("Item ".concat(e," delete skipped, revision: ").concat(t)):(this.cache.delete(e,t,n),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}(xR);function eC(e){return tC.apply(this,arguments)}function tC(){return tC=hT.default(xT.default.mark((function e(t){var n,r,i,a,s,o;return xT.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 s={query_string:r},a===nC.type&&(s.type=a),e.next=7,n.post(i,s,void 0,!0);case 7:return o=e.sent,e.abrupt("return",o.body);case 9:case"end":return e.stop()}}),e)}))),tC.apply(this,arguments)}var nC=function(e){gT.default(n,e);var t=XR(n);function n(e){var r;return vT.default(this,n),(r=t.call(this)).liveQueryImpl=e,r.liveQueryImpl.attach(mT.default(r)),r}return yT.default(n,[{key:"type",get:function(){return ZR.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){CT.default(kT.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 ZR.type}}]),n}(TR);wT.default(nC,"itemUpdated","itemUpdated"),wT.default(nC,"itemRemoved","itemRemoved");var rC=function(e){gT.default(i,e);var t,n,r=XR(i);function i(e){var t;return vT.default(this,i),t=r.call(this),wT.default(mT.default(t),"queryExpression",null),wT.default(mT.default(t),"items",{}),Object.assign(mT.default(t),e),t.updateIndexName(e.indexName),t}return yT.default(i,[{key:"type",get:function(){return i.type}},{key:"search",value:(n=hT.default(xT.default.mark((function e(t){var n=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.items={},e.abrupt("return",eC({network:this.network,uri:this.queryUri,queryString:t}).then((function(e){n.queryExpression=t,e.items&&e.items.forEach((function(e){n.items[e.key]=e.data})),n.emit("searchResult",n.getItems())})).catch((function(e){throw nR("Error '".concat(e.message,"' while executing query '").concat(t,"'")),n.queryExpression=null,e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"subscribe",value:(t=hT.default(xT.default.mark((function e(){return xT.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 GT(this.insightsUri).pathSegment(e).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),i}(jT);wT.default(rC,"searchResult","searchResult"),OT([rT.validateTypesAsync("string"),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],rC.prototype,"search",null),OT([rT.validateTypes(rT.nonEmptyString),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",void 0)],rC.prototype,"updateIndexName",null);function iC(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}function aC(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 sC(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?aC(Object(n),!0).forEach((function(t){wT.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aC(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var oC="data_sync",uC="3.1.0";function cC(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 sC(sC({},e),{},{mode:t})}return{mode:"create_new"}}var lC="com.twilio.rtd.cds.document",fC="com.twilio.rtd.cds.list",dC="com.twilio.rtd.cds.map",pC="twilio.sync.event",Client=function(e){gT.default(Client,e);var t,n,r,i,a,s,o,u,c,l,f,d,p,h,v,y=iC(Client);function Client(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(vT.default(this,Client),t=y.call(this),!e)throw new Error("Sync library needs a valid Twilio token to be passed");n.hasOwnProperty("logLevel")?XT(n.logLevel):XT("silent");var r=n.productId=n.productId||oC;n.clientMetadata=n.clientMetadata||{},n.clientMetadata.hasOwnProperty("type")||(n.clientMetadata.type="sync"),n.clientMetadata.hasOwnProperty("sdk")||(n.clientMetadata.sdk="JS",n.clientMetadata.sdkv=uC);var i=!n.twilsockClient;if(!n.initRegistrations){var a=new iT.InitRegistration(r);Client.populateInitRegistrations(a),n.initRegistrations=[a]}var s=n.twilsockClient=n.twilsockClient||new iT.Twilsock(e,r,n);s.on("tokenAboutToExpire",(function(e){return t.emit("tokenAboutToExpire",e)})),s.on("tokenExpired",(function(){return t.emit("tokenExpired")})),s.on("connectionError",(function(e){return t.emit("connectionError",e)})),s.on("stateChanged",(function(e){t.emit("connectionStateChanged",e),t.services.subscriptions.onConnectionStateChanged("connected"===e)})),s.on("message",(function(e,n){return t._routeMessage(e,n)}));var o=new lR(n),u=new gR(new YR(uC),o,s),c=new bR(o);return t.services={config:o,twilsock:s,network:u,storage:c,router:mT.default(t),subscriptions:null},t.services.subscriptions=new hR(t.services),t.entities=new QR,i&&s.connect(),t}return yT.default(Client,[{key:"_routeMessage",value:function(e,t){switch(ZT("Notification type:",e,"content:",t),e){case lC:case fC:case dC:this.services.subscriptions.acceptMessage(t,!1);break;case pC: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=hT.default(xT.default.mark((function e(){var t;return xT.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),tR("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=JT(n);e!==zR.type&&e!==$R.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=hT.default(xT.default.mark((function e(t,n){var r,i,a,s=arguments;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>2&&void 0!==s[2]&&s[2],n){e.next=3;break}throw new SyncError("Cannot get entity without id",404);case 3:return i=new GT(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=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(IR.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=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(zR.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=hT.default(xT.default.mark((function e(t){var n,r=arguments;return xT.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($R.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=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(HR.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=hT.default(xT.default.mark((function e(t,n){var r,i;return xT.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(nC.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=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=cC(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,IR.type))){e.next=14;break}return e.abrupt("return",new IR(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(IR.type,n.id,r),a=new CR(this.services,r,(function(e,t,n){return s.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new IR(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return u.apply(this,arguments)})},{key:"map",value:(o=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=cC(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,$R.type))){e.next=14;break}return e.abrupt("return",new $R(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($R.type,n.id,r),a=new VR(this.services,r,(function(e,t,n){return s.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new $R(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return o.apply(this,arguments)})},{key:"list",value:(s=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=cC(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,zR.type))){e.next=14;break}return e.abrupt("return",new zR(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(zR.type,n.id,r),a=new qR(this.services,r,(function(e,t,n){return s.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new zR(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return s.apply(this,arguments)})},{key:"stream",value:(a=hT.default(xT.default.mark((function e(t){var n,r,i,a,s,o=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=cC(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,HR.type))){e.next=14;break}return e.abrupt("return",new HR(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(HR.type,n.id,r),a=function(e,t,n){return o.removeFromCacheAndSession(e,t,n)},s=new KR(this.services,r,a),s=this.entities.store(s),e.abrupt("return",new HR(s));case 44:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return a.apply(this,arguments)})},{key:"shutdown",value:(i=hT.default(xT.default.mark((function e(){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i,a,s,o,u=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return r=new GT(this.services.config.insightsUri).pathSegment(t).pathSegment("Items").build(),e.next=5,eC({network:this.services.network,uri:r,queryString:n,type:nC.type});case 5:return i=e.sent,(a=this.getCached(i.query_id,nC.type))||((s=this._getLiveQuery(i.query_id))||(s={indexName:t,queryExpression:n,sid:i.query_id,queryUri:r,last_event_id:i.last_event_id}),o=function(e,t,n){return u.removeFromCacheAndSession(e,t,n)},a=new ZR(s,this.services,o,i.items)),this.storeRootInSessionCache(nC.type,i.query_id,a.liveQueryDescriptor),a=this.entities.store(a),e.abrupt("return",new nC(a));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"instantQuery",value:(t=hT.default(xT.default.mark((function e(t){var n,r=this;return xT.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 rC({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([pC,lC,fC,dC])}},{key:"version",get:function(){return uC}}]),Client}(jT);wT.default(Client,"connectionStateChanged","connectionStateChanged"),wT.default(Client,"connectionError","connectionError"),wT.default(Client,"tokenAboutToExpire","tokenAboutToExpire"),wT.default(Client,"tokenExpired","tokenExpired"),OT([rT.validateTypesAsync(["undefined","string",rT.objectSchema("open document options",{id:["string","undefined"],mode:[rT.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[rT.nonNegativeInteger,"undefined"],data:[rT.pureObject,"undefined",rT.literal(null)]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],Client.prototype,"document",null),OT([rT.validateTypesAsync(["undefined","string",rT.objectSchema("open map options",{id:["string","undefined"],mode:[rT.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[rT.nonNegativeInteger,"undefined"],data:[rT.pureObject,"undefined",rT.literal(null)],includeItems:["boolean","undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],Client.prototype,"map",null),OT([rT.validateTypesAsync(["undefined","string",rT.objectSchema("open list options",{id:["string","undefined"],mode:[rT.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[rT.nonNegativeInteger,"undefined"],data:[rT.pureObject,"undefined",rT.literal(null)],purpose:["string","undefined"],context:[rT.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],Client.prototype,"list",null),OT([rT.validateTypesAsync(["undefined","string",rT.objectSchema("open stream options",{id:["string","undefined"],mode:[rT.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[rT.nonNegativeInteger,"undefined"],data:[rT.pureObject,"undefined",rT.literal(null)]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],Client.prototype,"stream",null),OT([rT.validateTypesAsync(rT.nonEmptyString),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],Client.prototype,"updateToken",null),OT([rT.validateTypesAsync(rT.nonEmptyString,"string"),PT("design:type",Function),PT("design:paramtypes",[String,String]),PT("design:returntype",Promise)],Client.prototype,"liveQuery",null),OT([rT.validateTypesAsync(rT.nonEmptyString),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],Client.prototype,"instantQuery",null),$E.Client=Client,$E.InsightsItem=function e(){vT.default(this,e)},$E.InstantQuery=rC,$E.LiveQuery=nC,$E.Paginator=Paginator;var hC=$E.SyncClient=Client,vC=$E.SyncDocument=IR;$E.SyncList=zR,$E.SyncListItem=OR;var yC=$E.SyncMap=$R;$E.SyncMapItem=WR,$E.SyncStream=HR;var mC,gC={},bC=zS,kC=function(e){if(bC(e))throw TypeError("The method doesn't accept regular expressions");return e},wC=he("match"),xC=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[wC]=!1,"/./"[e](t)}catch(e){}}return!1},_C=Cn,SC=s.f,EC=Dt,TC=Er,RC=kC,CC=w,IC=xC,OC="".startsWith,PC=Math.min,AC=IC("startsWith");_C({target:"String",proto:!0,forced:!!(AC||(mC=SC(String.prototype,"startsWith"),!mC||mC.writable))&&!AC},{startsWith:function(e){var t=TC(CC(this));RC(e);var n=EC(PC(arguments.length>1?arguments[1]:void 0,t.length)),r=TC(e);return OC?OC.call(t,r,n):t.slice(n,n+r.length)===r}});var jC=o,MC=he("iterator"),LC=!jC((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[MC]||"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})),NC=2147483647,UC=/[^\0-\u007E]/,DC=/[.\u3002\uFF0E\uFF61]/g,FC="Overflow: input needs wider integers to process",BC=Math.floor,qC=String.fromCharCode,zC=function(e){return e+22+75*(e<26)},WC=function(e,t,n){var r=0;for(e=n?BC(e/700):e>>1,e+=BC(e/t);e>455;r+=36)e=BC(e/35);return BC(r+36*e/(e+38))},GC=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,s=0,o=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=NC;for(n=0;n<e.length;n++)(r=e[n])>=a&&r<l&&(l=r);var f=c+1;if(l-a>BC((NC-s)/f))throw RangeError(FC);for(s+=(l-a)*f,a=l,n=0;n<e.length;n++){if((r=e[n])<a&&++s>NC)throw RangeError(FC);if(r==a){for(var d=s,p=36;;p+=36){var h=p<=o?1:p>=o+26?26:p-o;if(d<h)break;var v=d-h,y=36-h;t.push(qC(zC(h+v%y))),d=BC(v/y)}t.push(qC(zC(d))),o=WC(s,f,c==u),s=0,++c}}++s,++a}return t.join("")},VC=Cn,$C=C,JC=LC,KC=Ke.exports,HC=hs,YC=An,QC=Yl,XC=_t,ZC=Ss,eI=te,tI=Fr,nI=Va,rI=Fe,iI=E,aI=Er,sI=nr,oI=v,uI=Ns,cI=js,lI=he,fI=$C("fetch"),dI=$C("Request"),pI=dI&&dI.prototype,hI=$C("Headers"),vI=lI("iterator"),yI="URLSearchParams",mI="URLSearchParamsIterator",gI=XC.set,bI=XC.getterFor(yI),kI=XC.getterFor(mI),wI=/\+/g,xI=Array(4),_I=function(e){return xI[e-1]||(xI[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},SI=function(e){try{return decodeURIComponent(e)}catch(t){return e}},EI=function(e){var t=e.replace(wI," "),n=4;try{return decodeURIComponent(t)}catch(e){for(;n;)t=t.replace(_I(n--),SI);return t}},TI=/[!'()~]|%20/g,RI={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},CI=function(e){return RI[e]},II=function(e){return encodeURIComponent(e).replace(TI,CI)},OI=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:EI(r.shift()),value:EI(r.join("="))}))},PI=function(e){this.entries.length=0,OI(this.entries,e)},AI=function(e,t){if(e<t)throw TypeError("Not enough arguments")},jI=QC((function(e,t){gI(this,{type:mI,iterator:uI(bI(e).entries),kind:t})}),"Iterator",(function(){var e=kI(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})),MI=function(){ZC(this,MI,yI);var e,t,n,r,i,a,s,o,u,c=arguments.length>0?arguments[0]:void 0,l=this,f=[];if(gI(l,{type:yI,entries:f,updateURL:function(){},updateSearchParams:PI}),void 0!==c)if(iI(c))if("function"==typeof(e=cI(c)))for(n=(t=uI(c,e)).next;!(r=n.call(t)).done;){if((s=(a=(i=uI(rI(r.value))).next).call(i)).done||(o=a.call(i)).done||!a.call(i).done)throw TypeError("Expected sequence with length 2");f.push({key:aI(s.value),value:aI(o.value)})}else for(u in c)eI(c,u)&&f.push({key:u,value:aI(c[u])});else OI(f,"string"==typeof c?"?"===c.charAt(0)?c.slice(1):c:aI(c))},LI=MI.prototype;if(HC(LI,{append:function(e,t){AI(arguments.length,2);var n=bI(this);n.entries.push({key:aI(e),value:aI(t)}),n.updateURL()},delete:function(e){AI(arguments.length,1);for(var t=bI(this),n=t.entries,r=aI(e),i=0;i<n.length;)n[i].key===r?n.splice(i,1):i++;t.updateURL()},get:function(e){AI(arguments.length,1);for(var t=bI(this).entries,n=aI(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){AI(arguments.length,1);for(var t=bI(this).entries,n=aI(e),r=[],i=0;i<t.length;i++)t[i].key===n&&r.push(t[i].value);return r},has:function(e){AI(arguments.length,1);for(var t=bI(this).entries,n=aI(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){AI(arguments.length,1);for(var n,r=bI(this),i=r.entries,a=!1,s=aI(e),o=aI(t),u=0;u<i.length;u++)(n=i[u]).key===s&&(a?i.splice(u--,1):(a=!0,n.value=o));a||i.push({key:s,value:o}),r.updateURL()},sort:function(){var e,t,n,r=bI(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=bI(this).entries,r=tI(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 jI(this,"keys")},values:function(){return new jI(this,"values")},entries:function(){return new jI(this,"entries")}},{enumerable:!0}),KC(LI,vI,LI.entries),KC(LI,"toString",(function(){for(var e,t=bI(this).entries,n=[],r=0;r<t.length;)e=t[r++],n.push(II(e.key)+"="+II(e.value));return n.join("&")}),{enumerable:!0}),YC(MI,yI),VC({global:!0,forced:!JC},{URLSearchParams:MI}),!JC&&"function"==typeof hI){var NI=function(e){if(iI(e)){var t,n=e.body;if(nI(n)===yI)return(t=e.headers?new hI(e.headers):new hI).has("content-type")||t.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),sI(e,{body:oI(0,String(n)),headers:oI(0,t)})}return e};if("function"==typeof fI&&VC({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return fI(e,arguments.length>1?NI(arguments[1]):{})}}),"function"==typeof dI){var UI=function(e){return ZC(this,UI,"Request"),new dI(e,arguments.length>1?NI(arguments[1]):{})};pI.constructor=UI,UI.prototype=pI,VC({global:!0,forced:!0},{Request:UI})}}var DI,FI={URLSearchParams:MI,getState:bI},BI=Cn,qI=u,zI=LC,WI=a,GI=Wn,VI=Ke.exports,$I=Ss,JI=te,KI=GE,HI=kl,YI=Il.codeAt,QI=function(e){var t,n,r=[],i=e.toLowerCase().replace(DC,".").split(".");for(t=0;t<i.length;t++)n=i[t],r.push(UC.test(n)?"xn--"+GC(n):n);return r.join(".")},XI=Er,ZI=An,eO=FI,tO=_t,nO=WI.URL,rO=eO.URLSearchParams,iO=eO.getState,aO=tO.set,sO=tO.getterFor("URL"),oO=Math.floor,uO=Math.pow,cO="Invalid scheme",lO="Invalid host",fO="Invalid port",dO=/[A-Za-z]/,pO=/[\d+-.A-Za-z]/,hO=/\d/,vO=/^0x/i,yO=/^[0-7]+$/,mO=/^\d+$/,gO=/^[\dA-Fa-f]+$/,bO=/[\0\t\n\r #%/:<>?@[\\\]^|]/,kO=/[\0\t\n\r #/:<>?@[\\\]^|]/,wO=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,xO=/[\t\n\r]/g,_O=function(e,t){var n,r,i;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return lO;if(!(n=EO(t.slice(1,-1))))return lO;e.host=n}else if(jO(e)){if(t=QI(t),bO.test(t))return lO;if(null===(n=SO(t)))return lO;e.host=n}else{if(kO.test(t))return lO;for(n="",r=HI(t),i=0;i<r.length;i++)n+=PO(r[i],RO);e.host=n}},SO=function(e){var t,n,r,i,a,s,o,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=vO.test(i)?16:8,i=i.slice(8==a?1:2)),""===i)s=0;else{if(!(10==a?mO:8==a?yO:gO).test(i))return e;s=parseInt(i,a)}n.push(s)}for(r=0;r<t;r++)if(s=n[r],r==t-1){if(s>=uO(256,5-t))return null}else if(s>255)return null;for(o=n.pop(),r=0;r<n.length;r++)o+=n[r]*uO(256,3-r);return o},EO=function(e){var t,n,r,i,a,s,o,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&&gO.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(!hO.test(d()))return;for(;hO.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(s=c-l,c=7;0!=c&&s>0;)o=u[c],u[c--]=u[l+s-1],u[l+--s]=o;else if(8!=c)return;return u},TO=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=oO(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},RO={},CO=KI({},RO,{" ":1,'"':1,"<":1,">":1,"`":1}),IO=KI({},CO,{"#":1,"?":1,"{":1,"}":1}),OO=KI({},IO,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),PO=function(e,t){var n=YI(e,0);return n>32&&n<127&&!JI(t,e)?e:encodeURIComponent(e)},AO={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jO=function(e){return JI(AO,e.scheme)},MO=function(e){return""!=e.username||""!=e.password},LO=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},NO=function(e,t){var n;return 2==e.length&&dO.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)},UO=function(e){var t;return e.length>1&&NO(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},DO=function(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&NO(t[0],!0)||t.pop()},FO=function(e){return"."===e||"%2e"===e.toLowerCase()},BO={},qO={},zO={},WO={},GO={},VO={},$O={},JO={},KO={},HO={},YO={},QO={},XO={},ZO={},eP={},tP={},nP={},rP={},iP={},aP={},sP={},oP=function(e,t,n,r){var i,a,s,o,u,c=n||BO,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(wO,"")),t=t.replace(xO,""),i=HI(t);l<=i.length;){switch(a=i[l],c){case BO:if(!a||!dO.test(a)){if(n)return cO;c=zO;continue}f+=a.toLowerCase(),c=qO;break;case qO:if(a&&(pO.test(a)||"+"==a||"-"==a||"."==a))f+=a.toLowerCase();else{if(":"!=a){if(n)return cO;f="",c=zO,l=0;continue}if(n&&(jO(e)!=JI(AO,f)||"file"==f&&(MO(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=f,n)return void(jO(e)&&AO[e.scheme]==e.port&&(e.port=null));f="","file"==e.scheme?c=ZO:jO(e)&&r&&r.scheme==e.scheme?c=WO:jO(e)?c=JO:"/"==i[l+1]?(c=GO,l++):(e.cannotBeABaseURL=!0,e.path.push(""),c=iP)}break;case zO:if(!r||r.cannotBeABaseURL&&"#"!=a)return cO;if(r.cannotBeABaseURL&&"#"==a){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,c=sP;break}c="file"==r.scheme?ZO:VO;continue;case WO:if("/"!=a||"/"!=i[l+1]){c=VO;continue}c=KO,l++;break;case GO:if("/"==a){c=HO;break}c=rP;continue;case VO:if(e.scheme=r.scheme,a==DI)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&&jO(e))c=$O;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=aP;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=rP;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=sP}break;case $O:if(!jO(e)||"/"!=a&&"\\"!=a){if("/"!=a){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,c=rP;continue}c=HO}else c=KO;break;case JO:if(c=KO,"/"!=a||"/"!=f.charAt(l+1))continue;l++;break;case KO:if("/"!=a&&"\\"!=a){c=HO;continue}break;case HO:if("@"==a){d&&(f="%40"+f),d=!0,s=HI(f);for(var v=0;v<s.length;v++){var y=s[v];if(":"!=y||h){var m=PO(y,OO);h?e.password+=m:e.username+=m}else h=!0}f=""}else if(a==DI||"/"==a||"?"==a||"#"==a||"\\"==a&&jO(e)){if(d&&""==f)return"Invalid authority";l-=HI(f).length+1,f="",c=YO}else f+=a;break;case YO:case QO:if(n&&"file"==e.scheme){c=tP;continue}if(":"!=a||p){if(a==DI||"/"==a||"?"==a||"#"==a||"\\"==a&&jO(e)){if(jO(e)&&""==f)return lO;if(n&&""==f&&(MO(e)||null!==e.port))return;if(o=_O(e,f))return o;if(f="",c=nP,n)return;continue}"["==a?p=!0:"]"==a&&(p=!1),f+=a}else{if(""==f)return lO;if(o=_O(e,f))return o;if(f="",c=XO,n==QO)return}break;case XO:if(!hO.test(a)){if(a==DI||"/"==a||"?"==a||"#"==a||"\\"==a&&jO(e)||n){if(""!=f){var g=parseInt(f,10);if(g>65535)return fO;e.port=jO(e)&&g===AO[e.scheme]?null:g,f=""}if(n)return;c=nP;continue}return fO}f+=a;break;case ZO:if(e.scheme="file","/"==a||"\\"==a)c=eP;else{if(!r||"file"!=r.scheme){c=rP;continue}if(a==DI)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=aP;else{if("#"!=a){UO(i.slice(l).join(""))||(e.host=r.host,e.path=r.path.slice(),DO(e)),c=rP;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",c=sP}}break;case eP:if("/"==a||"\\"==a){c=tP;break}r&&"file"==r.scheme&&!UO(i.slice(l).join(""))&&(NO(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),c=rP;continue;case tP:if(a==DI||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&NO(f))c=rP;else if(""==f){if(e.host="",n)return;c=nP}else{if(o=_O(e,f))return o;if("localhost"==e.host&&(e.host=""),n)return;f="",c=nP}continue}f+=a;break;case nP:if(jO(e)){if(c=rP,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=DI&&(c=rP,"/"!=a))continue}else e.fragment="",c=sP;else e.query="",c=aP;break;case rP:if(a==DI||"/"==a||"\\"==a&&jO(e)||!n&&("?"==a||"#"==a)){if(".."===(u=(u=f).toLowerCase())||"%2e."===u||".%2e"===u||"%2e%2e"===u?(DO(e),"/"==a||"\\"==a&&jO(e)||e.path.push("")):FO(f)?"/"==a||"\\"==a&&jO(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&NO(f)&&(e.host&&(e.host=""),f=f.charAt(0)+":"),e.path.push(f)),f="","file"==e.scheme&&(a==DI||"?"==a||"#"==a))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==a?(e.query="",c=aP):"#"==a&&(e.fragment="",c=sP)}else f+=PO(a,IO);break;case iP:"?"==a?(e.query="",c=aP):"#"==a?(e.fragment="",c=sP):a!=DI&&(e.path[0]+=PO(a,RO));break;case aP:n||"#"!=a?a!=DI&&("'"==a&&jO(e)?e.query+="%27":e.query+="#"==a?"%23":PO(a,RO)):(e.fragment="",c=sP);break;case sP:a!=DI&&(e.fragment+=PO(a,CO))}l++}},uP=function(e){var t,n,r=$I(this,uP,"URL"),i=arguments.length>1?arguments[1]:void 0,a=XI(e),s=aO(r,{type:"URL"});if(void 0!==i)if(i instanceof uP)t=sO(i);else if(n=oP(t={},XI(i)))throw TypeError(n);if(n=oP(s,a,null,t))throw TypeError(n);var o=s.searchParams=new rO,u=iO(o);u.updateSearchParams(s.query),u.updateURL=function(){s.query=String(o)||null},qI||(r.href=lP.call(r),r.origin=fP.call(r),r.protocol=dP.call(r),r.username=pP.call(r),r.password=hP.call(r),r.host=vP.call(r),r.hostname=yP.call(r),r.port=mP.call(r),r.pathname=gP.call(r),r.search=bP.call(r),r.searchParams=kP.call(r),r.hash=wP.call(r))},cP=uP.prototype,lP=function(){var e=sO(this),t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,s=e.path,o=e.query,u=e.fragment,c=t+":";return null!==i?(c+="//",MO(e)&&(c+=n+(r?":"+r:"")+"@"),c+=TO(i),null!==a&&(c+=":"+a)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?s[0]:s.length?"/"+s.join("/"):"",null!==o&&(c+="?"+o),null!==u&&(c+="#"+u),c},fP=function(){var e=sO(this),t=e.scheme,n=e.port;if("blob"==t)try{return new uP(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&jO(e)?t+"://"+TO(e.host)+(null!==n?":"+n:""):"null"},dP=function(){return sO(this).scheme+":"},pP=function(){return sO(this).username},hP=function(){return sO(this).password},vP=function(){var e=sO(this),t=e.host,n=e.port;return null===t?"":null===n?TO(t):TO(t)+":"+n},yP=function(){var e=sO(this).host;return null===e?"":TO(e)},mP=function(){var e=sO(this).port;return null===e?"":String(e)},gP=function(){var e=sO(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},bP=function(){var e=sO(this).query;return e?"?"+e:""},kP=function(){return sO(this).searchParams},wP=function(){var e=sO(this).fragment;return e?"#"+e:""},xP=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(qI&&GI(cP,{href:xP(lP,(function(e){var t=sO(this),n=XI(e),r=oP(t,n);if(r)throw TypeError(r);iO(t.searchParams).updateSearchParams(t.query)})),origin:xP(fP),protocol:xP(dP,(function(e){var t=sO(this);oP(t,XI(e)+":",BO)})),username:xP(pP,(function(e){var t=sO(this),n=HI(XI(e));if(!LO(t)){t.username="";for(var r=0;r<n.length;r++)t.username+=PO(n[r],OO)}})),password:xP(hP,(function(e){var t=sO(this),n=HI(XI(e));if(!LO(t)){t.password="";for(var r=0;r<n.length;r++)t.password+=PO(n[r],OO)}})),host:xP(vP,(function(e){var t=sO(this);t.cannotBeABaseURL||oP(t,XI(e),YO)})),hostname:xP(yP,(function(e){var t=sO(this);t.cannotBeABaseURL||oP(t,XI(e),QO)})),port:xP(mP,(function(e){var t=sO(this);LO(t)||(""==(e=XI(e))?t.port=null:oP(t,e,XO))})),pathname:xP(gP,(function(e){var t=sO(this);t.cannotBeABaseURL||(t.path=[],oP(t,XI(e),nP))})),search:xP(bP,(function(e){var t=sO(this);""==(e=XI(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",oP(t,e,aP)),iO(t.searchParams).updateSearchParams(t.query)})),searchParams:xP(kP),hash:xP(wP,(function(e){var t=sO(this);""!=(e=XI(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",oP(t,e,sP)):t.fragment=null}))}),VI(cP,"toJSON",(function(){return lP.call(this)}),{enumerable:!0}),VI(cP,"toString",(function(){return lP.call(this)}),{enumerable:!0}),nO){var _P=nO.createObjectURL,SP=nO.revokeObjectURL;_P&&VI(uP,"createObjectURL",(function(e){return _P.apply(nO,arguments)})),SP&&VI(uP,"revokeObjectURL",(function(e){return SP.apply(nO,arguments)}))}ZI(uP,"URL"),BI({global:!0,forced:!zI,sham:!qI},{URL:uP}),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=pv.exports,r=dv.exports,i=hv.exports,a=yv.exports,s=gv.exports,o=aE.exports,u=Iy.exports,c=zg.exports,l=Wg,f=bh.exports,d=Sf.exports,p=ng,h=gh;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 m=v(n),g=v(r),b=v(i),k=v(a),w=v(s),x=v(o),_=v(u),S=v(c),E=v(l),T=v(f),R=y(d),C={exports:{}},I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(I){var O=new Uint8Array(16);C.exports=function(){return I(O),O}}else{var P=new Array(16);C.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,N=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("")},U=C.exports,D=N,F=0,B=0;var q=function(e,t,n){var r=t&&n||0,i=t||[],a=(e=e||{}).node||M,s=void 0!==e.clockseq?e.clockseq:L;if(null==a||null==s){var o=U();null==a&&(a=M=[1|o[0],o[1],o[2],o[3],o[4],o[5]]),null==s&&(s=L=16383&(o[6]<<8|o[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&&(s=s+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=s;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++]=s>>>8|128,i[r++]=255&s;for(var p=0;p<6;++p)i[r+p]=a[p];return t||D(i)},z=C.exports,W=N;var G=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,$=G,J=$;J.v1=V,J.v4=$;var K=J;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=w.default(e);if(t){var i=w.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return k.default(this,n)}}var Y=function(e){b.default(n,e);var t=H(n);function n(e){var r;m.default(this,n);var i,a=K.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 g.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}(x.default(Promise));function Q(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":T.default(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function X(e,t){if("object"===("undefined"==typeof Reflect?"undefined":T.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))}_.default(Y,"cancellationMap",new Map);var ee=function(){function e(t){m.default(this,e),_.default(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return g.default(e,[{key:"setLevel",value:function(e){R.setLevel(e)}},{key:"trace",value:function(){if(R.getLevel()==R.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];R.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];R.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];R.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];R.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];R.error.apply(null,Z(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){R.setLevel(e)}},{key:"trace",value:function(){if(R.getLevel()==R.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];R.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];R.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];R.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];R.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];R.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,s,o,u,c,l;m.default(this,e);var f=null!==(a=null!==(s=i.MCS)&&void 0!==s?s:i)&&void 0!==a?a:{};this.region=null!==(o=null!==(u=f.region)&&void 0!==u?u:i.region)&&void 0!==o?o:"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 g.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){m.default(this,Media),this.config=e,this.network=t,this._update(n)}return g.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,s;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:s=t.sent,e._update(s.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=w.default(e);if(t){var i=w.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return k.default(this,n)}}var ie=function(e){b.default(n,e);var t=re(n);function n(e,r,i,a,s){var o;return m.default(this,n),(o=t.call(this,e)).code=r,o.body=i,o.status=a,o.headers=s,o}return g.default(n)}(x.default(Error)),ae=t.XMLHttpRequest||{};var se,oe=function(){function e(){m.default(this,e)}return g.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,s){var o=new ae,u=!1;for(var c in s((function(){o.abort(),u=!0})),o.open(e,t,!0),o.onreadystatechange=function(){if(4===o.readyState&&!u){var e,t=(e=o.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}}(o);if(200<=o.status&&o.status<300)i({status:o.status,headers:t,body:n});else{var r,s,c=null!==(r=o.statusText)&&void 0!==r?r:"NONE";if("string"==typeof n)if(n&&1===n.split("\n",2).length)s=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(" ");s=(null==f?void 0:f.length)>2?null==f?void 0:f.slice(1).join(" "):""}else s=JSON.stringify(n);var d="".concat(o.status,": [").concat(c,"] ").concat(s);a(new ie(d,o.status,n,c,t))}}},n)o.setRequestHeader(c,n[c]),"Content-Type"===c&&"application/json"===n[c]&&(r=JSON.stringify(r));o.send(r)}))}}]),e}(),ue=ee.scope("Network"),ce=function(){function e(t,n){m.default(this,e),this.config=t,this.transport=n}return g.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,s){var o,u;return E.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:o=new p.Retrier(n.backoffConfig()),u=[502,503,504],t&&u.push(429),s((function(){o.cancel(),o.removeAllListeners()})),o.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(),s((function(){n.cancel(),o.cancel(),o.removeAllListeners()})),t.next=5,n;case 5:r=t.sent,o.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?o.failed(t.t0):(o.removeAllListeners(),o.cancel(),a(t.t0));case 12:case"end":return t.stop()}}),t,null,[[0,9]])})))),o.on("succeeded",(function(e){i(e)})),o.on("cancelled",(function(e){return a(e)})),o.on("failed",(function(e){return a(e)})),o.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 s,o,u;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s={"X-Twilio-Token":t.config.token},o=t.executeWithRetry((function(){return t.transport.get(e,s)}),t.retryWhenThrottled()),ue.trace("sending GET request to ",e," headers ",s),a((function(){return o.cancel()})),n.prev=4,n.next=7,o;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 s=this,o={"X-Twilio-Token":this.config.token};"undefined"!=typeof FormData&&r instanceof FormData||!i||Object.assign(o,{"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=s.transport.post(u.href,o,r),c((function(){return l.cancel()})),ue.trace("sending POST request to ".concat(e," with headers ").concat(o)),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=(se=function(){function Client(e,t,n){var r,i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};m.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 oe,this.transport=this.options.transport,this.network=new ce(this.config,this.transport)}return g.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 s,o;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=t.network.get("".concat(t.config.mediaUrl,"/").concat(e)),a((function(){return s.cancel()})),n.prev=2,n.next=5,s;case 5:o=n.sent,r(new Media(t.config,t.network,o.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(s,o,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,s(new Media(i.config,i.network,l.body)),a.next=12;break;case 9:a.prev=9,a.t0=a.catch(2),o(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,s){var o,u;return E.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=n.network.post(n.config.mediaUrl,null!=t?t:"media",e),s((function(){return o.cancel()})),r.prev=2,r.next=5,o;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 s,o,u,c;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s={command:"get",list:e.map((function(e){return{media_sid:e}}))},o=t.network.post("".concat(t.config.mediaSetUrl),null,s,"application/json"),a((function(){return o.cancel()})),n.prev=3,n.next=6,o;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 s,o,u,c;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s={command:"get",list:e.map((function(e){return{media_sid:e}}))},o=t.network.post("".concat(t.config.mediaSetUrl),null,s,"application/json"),a((function(){return o.cancel()})),n.prev=3,n.next=6,o;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}(),_.default(se,"version","0.6.11-rc.5"),se),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}(gC);var EP=_s,TP="ArrayBuffer",RP=pw.ArrayBuffer;function CP(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)}}Cn({global:!0,forced:a.ArrayBuffer!==RP},{ArrayBuffer:RP}),EP(TP);var IP=If.scope("Participant"),Participant=function(e){Oa(Participant,e);var t,n,r,i=CP(Participant);function Participant(e,t,n,r,a){var s,o,u;if(Ua(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,IP),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!==(s=e.roleSid)&&void 0!==s?s:"",lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,lastReadTimestamp:e.lastConsumptionTimestamp?vh(e.lastConsumptionTimestamp):null,type:e.type||"chat",userInfo:e.userInfo,bindings:null!==(o=e.bindings)&&void 0!==o?o:{}},!e.identity&&!e.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return u}return Na(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,IP);e.attributes&&!lm(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&&!lm(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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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}(um);function OP(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([by(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],Participant.prototype,"updateAttributes",null);var PP=If.scope("Participants"),AP=function(e){Oa(l,e);var t,n,r,i,a,s,o,u,c=OP(l);function l(e,t,n,r){var i;return Ua(this,l),Ma(Ca(i=c.call(this)),"rosterEntityPromise",null),i.conversation=e,i.participants=t,i.links=n,i.services=r,i}return Na(l,[{key:"unsubscribe",value:(u=Ra(Gc.mark((function e(){return Gc.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(yC.itemAdded,(function(e){PP.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(yC.itemRemoved,(function(e){PP.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(yC.itemUpdated,(function(e){PP.debug(t.conversation.sid+" itemUpdated: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).catch((function(e){return PP.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&&PP.error("Failed to get roster object for conversation",t.conversation.sid,e),PP.debug("ERROR: Failed to get roster object for conversation",t.conversation.sid,e),e}))}},{key:"upsertParticipantFromResponse",value:(o=Ra(Gc.mark((function e(t){var n,r,i,a,s,o,u,c;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.sid,i=t.attributes,a=t.date_created,s=t.date_updated,o=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(s),identity:o,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 o.apply(this,arguments)})},{key:"upsertParticipant",value:(s=Ra(Gc.mark((function e(t,n){var r,i,a=this;return Gc.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 s.apply(this,arguments)})},{key:"getParticipants",value:(a=Ra(Gc.mark((function e(){var t=this;return Gc.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=Ra(Gc.mark((function e(t){var n=this;return Gc.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=Ra(Gc.mark((function e(t){var n,r=this;return Gc.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=Ra(Gc.mark((function e(t,n){return Gc.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=Ra(Gc.mark((function e(t,n){var r,i,a,s,o=arguments;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=o.length>2&&void 0!==o[2]?o[2]:{},s=o.length>3&&void 0!==o[3]?o[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==s||null===(r=s.email)||void 0===r?void 0:r.name,level:null==s||null===(i=s.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}(um),jP=Cn,MP=Nn,LP=X,NP=Dt,UP=Er,DP=o,FP=eS,BP=ns,qP=nS,zP=rS,WP=N,GP=aS,VP=[],$P=VP.sort,JP=DP((function(){VP.sort(void 0)})),KP=DP((function(){VP.sort(null)})),HP=BP("sort"),YP=!DP((function(){if(WP)return WP<70;if(!(qP&&qP>3)){if(zP)return!0;if(GP)return GP<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++)VP.push({k:t+r,v:n})}for(VP.sort((function(e,t){return t.v-e.v})),r=0;r<VP.length;r++)t=VP[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));jP({target:"Array",proto:!0,forced:JP||!KP||!HP||!YP},{sort:function(e){void 0!==e&&MP(e);var t=LP(this);if(YP)return void 0===e?$P.call(t):$P.call(t,e);var n,r,i=[],a=NP(t.length);for(r=0;r<a;r++)r in t&&i.push(t[r]);for(i=FP(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:UP(t)>UP(n)?1:-1}}(e)),n=i.length,r=0;r<n;)t[r]=i[r++];for(;r<a;)delete t[r++];return t}});var QP=kC,XP=w,ZP=Er;Cn({target:"String",proto:!0,forced:!xC("includes")},{includes:function(e){return!!~ZP(XP(this)).indexOf(ZP(QP(e)),arguments.length>1?arguments[1]:void 0)}});var eA=hs,tA=hm.exports.getWeakData,nA=Fe,rA=E,iA=Ss,aA=Js,sA=te,oA=_t.set,uA=_t.getterFor,cA=Xr.find,lA=Xr.findIndex,fA=0,dA=function(e){return e.frozen||(e.frozen=new pA)},pA=function(){this.entries=[]},hA=function(e,t){return cA(e.entries,(function(e){return e[0]===t}))};pA.prototype={get:function(e){var t=hA(this,e);if(t)return t[1]},has:function(e){return!!hA(this,e)},set:function(e,t){var n=hA(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=lA(this.entries,(function(t){return t[0]===e}));return~t&&this.entries.splice(t,1),!!~t}};var vA={getConstructor:function(e,t,n,r){var i=e((function(e,a){iA(e,i,t),oA(e,{type:t,id:fA++,frozen:void 0}),null!=a&&aA(a,e[r],{that:e,AS_ENTRIES:n})})),a=uA(t),s=function(e,t,n){var r=a(e),i=tA(nA(t),!0);return!0===i?dA(r).set(t,n):i[r.id]=n,e};return eA(i.prototype,{delete:function(e){var t=a(this);if(!rA(e))return!1;var n=tA(e);return!0===n?dA(t).delete(e):n&&sA(n,t.id)&&delete n[t.id]},has:function(e){var t=a(this);if(!rA(e))return!1;var n=tA(e);return!0===n?dA(t).has(e):n&&sA(n,t.id)}}),eA(i.prototype,n?{get:function(e){var t=a(this);if(rA(e)){var n=tA(e);return!0===n?dA(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}};zm("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),vA);var Media=function(){function Media(e,t){var n;Ua(this,Media),Ma(this,"mcsMedia",null),this.services=t,e instanceof gC.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 Na(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 gC.CancellablePromise(function(){var t=Ra(Gc.mark((function t(n,r,i){var a,s,o,u;return Gc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=e.mcsMedia?void 0:e._fetchMcsMedia(),o=null===(a=e.mcsMedia)||void 0===a?void 0:a.getContentUrl(),i((function(){s&&s.cancel(),o&&o.cancel()})),t.prev=3,o){t.next=9;break}return t.next=7,s;case 7:u=t.sent,o=null==u?void 0:u.getContentUrl();case 9:if(t.t0=n,!o){t.next=16;break}return t.next=13,o;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 gC.CancellablePromise(function(){var t=Ra(Gc.mark((function t(n,r,i){var a;return Gc.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){Ua(this,AggregatedDeliveryReceipt),this.state=e}return Na(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,s=this.failed===e.failed;return t&&n&&r&&i&&a&&s}}]),AggregatedDeliveryReceipt}(),yA=function(){function e(t,n,r,i){Ua(this,e),this.state={prevToken:r,nextToken:i,source:n,items:t}}return Na(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=Na((function DetailedDeliveryReceipt(e){Ua(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})),mA={};function gA(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}Object.defineProperty(mA,"__esModule",{value:!0});var bA=gA(Sf.exports),kA=function(e){var t=bA.default.getLevel();bA.default.setLevel("warn"),bA.default.warn(e),bA.default.setLevel(t)},wA=mA.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 s=a.get;a.get=function(){return kA("The getter ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),null==s?void 0:s.apply(this)}}else{var o=a.value;a.value=function(){kA("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 o.apply(this,i)}}}},xA=mA.deprecationWarning=kA,_A=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}}}))},SA=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 s=t;return{type:"callToAction",body:s.body,actions:_A(s.actions),rawData:n};case"twilio/list-picker":var o=t;return{type:"listPicker",body:o.body,button:o.button,items:o.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:_A(null!==(c=l.actions)&&void 0!==c?c:[]),rawData:n};default:return{type:"other",rawData:n}}},ContentTemplateVariable=function(){function ContentTemplateVariable(e,t){Ua(this,ContentTemplateVariable),this.name=e,this.value=t}return Na(ContentTemplateVariable,[{key:"copyWithValue",value:function(e){return new ContentTemplateVariable(this.name,e)}}]),ContentTemplateVariable}(),EA=Na((function e(t){Ua(this,e),this.sid=t.sid,this.friendlyName=t.friendly_name,this.variables=Object.entries(JSON.parse(t.variables)).map((function(e){var t=pm(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=pm(r[n],2),a=i[0],s=i[1];t.set(a,SA(a,s))}return t}(t.variants),this.dateCreated=new Date(t.date_created),this.dateUpdated=new Date(t.date_updated)}));function TA(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 RA(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?TA(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):TA(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function CA(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 IA(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 OA(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}var PA=If.scope("Message"),AA=t.XMLHttpRequest||{},jA=new WeakSet,MA=new WeakSet,Message=function(e){Oa(Message,e);var t,n,r,i,a,s,o,u,c,l=CA(Message);function Message(e,t,n,r,i,a){var s,o,u,c,f,d,p,h;return Ua(this,Message),IA(Ca(h=l.call(this)),MA),IA(Ca(h),jA),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!==(s=t.text)&&void 0!==s?s:null,timestamp:t.timestamp?new Date(t.timestamp):null,dateUpdated:t.dateUpdated?new Date(t.dateUpdated):null,lastUpdatedBy:null!==(o=t.lastUpdatedBy)&&void 0!==o?o:null,attributes:yh(t.attributes,"Got malformed attributes for the message ".concat(t.sid),PA),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},OA(Ca(h),MA,NA).call(Ca(h),null!==(d=t.medias)&&void 0!==d?d:null,null!==(p=t.media)&&void 0!==p?p:null),h}return Na(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,s=[];!e.text&&"string"!=typeof e.text||e.text===this.state.body||(this.state.body=e.text,s.push("body")),e.subject&&e.subject!==this.state.subject&&(this.state.subject=e.subject,s.push("subject")),e.lastUpdatedBy&&e.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=e.lastUpdatedBy,s.push("lastUpdatedBy")),e.author&&e.author!==this.state.author&&(this.state.author=e.author,s.push("author")),e.dateUpdated&&new Date(e.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(e.dateUpdated),s.push("dateUpdated")),e.timestamp&&new Date(e.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(e.timestamp),s.push("dateCreated"));var o=yh(e.attributes,"Got malformed attributes for the message ".concat(this.sid),PA);lm(this.state.attributes,o)||(this.state.attributes=o,s.push("attributes"));var u=e.delivery,c=this.state.aggregatedDeliveryReceipt;!!(u&&u.total&&u.delivered&&u.failed&&u.read&&u.sent&&u.undelivered)&&(c?c._isEquals(u)||(c._update(u),s.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new AggregatedDeliveryReceipt(u),s.push("deliveryReceipt")));var l,f,d=(null!==(t=e.medias)&&void 0!==t?t:[]).map((function(e){var t;return null===(t=OA(a,jA,LA).call(a,e))||void 0===t?void 0:t._state()})).filter((function(e){return!(null===e)})),p=(null!==(n=this.state.medias)&&void 0!==n?n:[]).map((function(e){return e._state()})).filter((function(e){return!(null===e)}));lm(d,p)&&lm(null===(r=OA(this,jA,LA).call(this,e.media))||void 0===r?void 0:r._state(),null===(i=this.state.media)||void 0===i?void 0:i._state())||(OA(this,MA,NA).call(this,null!==(l=e.medias)&&void 0!==l?l:null,null!==(f=e.media)&&void 0!==f?f:null),s.push("media"));s.length>0&&this.emit("updated",{message:this,updateReasons:s})}},{key:"getParticipant",value:(c=Ra(Gc.mark((function e(){var t,n,r=this;return Gc.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 PA.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 PA.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=Ra(Gc.mark((function e(){var t,n;return Gc.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:(o=Ra(Gc.mark((function e(){return Gc.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 o.apply(this,arguments)})},{key:"updateBody",value:(s=Ra(Gc.mark((function e(t){return Gc.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 s.apply(this,arguments)})},{key:"updateAttributes",value:(a=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){var n,r=this;return Gc.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 gC.CancellablePromise(function(){var n=Ra(Gc.mark((function n(r,i,a){var s,o;return Gc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(s=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(){s.cancel()})),n.prev=5,n.next=8,s;case 8:o=n.sent,r(o),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=Ra(Gc.mark((function e(t){var n,r,i,a=this;return Gc.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 mh(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 yA(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 gC.CancellablePromise(function(){var t=Ra(Gc.mark((function t(n,r,i){var a,s,o,u,c,l,f,d,p,h;return Gc.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(s="application/x-vnd.com.twilio.rich.",0!==(o=a.filter((function(e){return e.contentType.startsWith(s)}))).length){t.next=12;break}return n(null),t.abrupt("return");case 12:return u=o[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 AA;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(s,"").replace(".","/"),n(SA(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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(){return Gc.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}(um);function LA(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e?new Media(t?RA(RA({},e),{},{category:t}):e,this.services):null}function NA(e,t){var n=this;this.state.media=OA(this,jA,LA).call(this,t),this.state.medias=e?e.map((function(e){return OA(n,jA,LA).call(n,e)})).filter((function(e){return null!==e})):t&&!e?[OA(this,jA,LA).call(this,t,"media")].filter((function(e){return null!==e})):null}function UA(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 DA(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?UA(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):UA(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function FA(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 BA(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 BA(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function BA(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 qA(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([wA("getMediaByCategory","getMediaByCategories"),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",Array)],Message.prototype,"getMediaByCategory",null),$c([gy([py,"undefined"]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Media)],Message.prototype,"getEmailBody",null),$c([gy([py,"undefined"]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Media)],Message.prototype,"getEmailHistory",null),$c([by("string"),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Message.prototype,"updateBody",null),$c([by(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],Message.prototype,"updateAttributes",null),$c([wA("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",Promise)],Message.prototype,"attachTemporaryUrlsFor",null),$c([by(dy("media",Media)),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",gC.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMedia",null),$c([by(dy("strings","string")),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",gC.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMediaSids",null);var zA=If.scope("Messages"),WA=function(e){Oa(u,e);var t,n,r,i,a,s,o=qA(u);function u(e,t,n){var r;return Ua(this,u),(r=o.call(this)).conversation=e,r.configuration=t,r.services=n,r.messagesByIndex=new Map,r.messagesListPromise=null,r}return Na(u,[{key:"subscribe",value:(s=Ra(Gc.mark((function e(t){var n,r=this;return Gc.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){zA.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)?zA.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){zA.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){zA.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&&zA.error("Failed to get messages object for conversation",this.conversation.sid,e.t0),zA.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 s.apply(this,arguments)})},{key:"unsubscribe",value:(a=Ra(Gc.mark((function e(){return Gc.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 zA.debug("Sending message V2",e.mediaContent,e.attributes,e.emailOptions),new gC.CancellablePromise(function(){var n=Ra(Gc.mark((function n(r,i,a){var s,o,u,c,l,f,d,p,h,v,y,m;return Gc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:o=[],u=[],a((function(){u.forEach((function(e){return e.cancel()}))})),c=FA(e.mediaContent),n.prev=4,c.s();case 6:if((l=c.n()).done){n.next=25;break}return f=pm(l.value,2),d=f[0],p=f[1],n.prev=8,zA.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=o,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 m=t.services.commandExecutor.mutateResource("post",t.conversation._links.messages,{body:e.text,subject:null===(s=e.emailOptions)||void 0===s?void 0:s.subject,media_sids:o.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 DA(DA({},e),{},Ma({},t.name,t.value))}),{})):void 0}),n.prev=34,n.t4=r,n.next=38,m;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=Ra(Gc.mark((function e(t){var n,r,i=arguments;return Gc.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,zA.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=Ra(Gc.mark((function e(t){var n,r,i,a,s,o=arguments;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:{},a=o.length>2?o[2]:void 0,zA.debug("Sending media message",t,i,a),zA.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 s=e.t0,e.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[s.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=Ra(Gc.mark((function e(t,n){var r,i=arguments;return Gc.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)}))},s=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:s,nextPage:i?s: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=Ra(Gc.mark((function e(){var t,n,r,i,a,s,o=this,u=arguments;return Gc.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 s=e.sent,e.next=12,this._wrapPaginator(i,s,(function(e){return Promise.all(e.map((function(e){return o._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}(um),GA=function(){function e(t){Ua(this,e),Ma(this,"attributes",{}),Ma(this,"mediaContent",[]),Ma(this,"emailOptions",{}),this.messagesEntity=t}return Na(e,[{key:"send",value:function(){var e=this;return new gC.CancellablePromise(function(){var t=Ra(Gc.mark((function t(n,r,i){var a,s;return Gc.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:s=t.sent,n(hh(s.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}(),VA=function(){function e(t,n){Ua(this,e),this.limits=t,this.message=new GA(n),this.emailBodies=new Map,this.emailHistories=new Map}return Na(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 $A(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 JA(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 JA(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function JA(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 KA(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([gy("string"),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",VA)],VA.prototype,"setBody",null),$c([gy("string"),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",VA)],VA.prototype,"setSubject",null),$c([gy(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",VA)],VA.prototype,"setAttributes",null),$c([gy("string",[FormData,Ey]),Jc("design:type",Function),Jc("design:paramtypes",[String,Object]),Jc("design:returntype",VA)],VA.prototype,"setEmailBody",null),$c([gy("string",[FormData,Ey]),Jc("design:type",Function),Jc("design:paramtypes",[String,Object]),Jc("design:returntype",VA)],VA.prototype,"setEmailHistory",null),$c([gy("string",[cy("content variables",ContentTemplateVariable),"undefined"]),Jc("design:type",Function),Jc("design:paramtypes",[String,Array]),Jc("design:returntype",VA)],VA.prototype,"setContentTemplate",null),$c([gy([FormData,Ey]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",VA)],VA.prototype,"addMedia",null);var HA={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,s,o,u,c,l,f,d,p,h,v,y,m,g,b,k,w,x,_,S,E,T,R,C,I,O=KA(Conversation);function Conversation(e,t,n,r,i){var a,s,o;Ua(this,Conversation),(o=O.call(this)).sid=t,o._links=n,o._configuration=r,o._services=i,o._entityName=e.channel,o._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!==(s=e.bindings)&&void 0!==s?s:{}},e.notificationLevel&&(o._internalState.notificationLevel=e.notificationLevel);var u={participants:o._links.participants};return o._participants=new Map,o._participantsEntity=new AP(Ca(o),o._participants,u,o._services),o._participantsEntity.on(Conversation.participantJoined,(function(e){return o.emit(Conversation.participantJoined,e)})),o._participantsEntity.on(Conversation.participantLeft,(function(e){return o.emit(Conversation.participantLeft,e)})),o._participantsEntity.on(Conversation.participantUpdated,(function(e){return o.emit(Conversation.participantUpdated,e)})),o._messagesEntity=new WA(Ca(o),r,i),o._messagesEntity.on(Conversation.messageAdded,(function(e){return o._onMessageAdded(e)})),o._messagesEntity.on(Conversation.messageUpdated,(function(e){return o.emit(Conversation.messageUpdated,e)})),o._messagesEntity.on(Conversation.messageRemoved,(function(e){return o.emit(Conversation.messageRemoved,e)})),o}return Na(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:(I=Ra(Gc.mark((function e(t,n){return Gc.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 I.apply(this,arguments)})},{key:"addNonChatParticipant",value:(C=Ra(Gc.mark((function e(t,n){var r,i,a=arguments;return Gc.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 C.apply(this,arguments)})},{key:"advanceLastReadMessageIndex",value:(R=Ra(Gc.mark((function e(t){var n;return Gc.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 R.apply(this,arguments)})},{key:"delete",value:(T=Ra(Gc.mark((function e(){return Gc.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 T.apply(this,arguments)})},{key:"getAttributes",value:(E=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t,n,r){return Gc.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:(_=Ra(Gc.mark((function e(){return Gc.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 _.apply(this,arguments)})},{key:"getParticipantsCount",value:(x=Ra(Gc.mark((function e(){var t,n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mh(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 x.apply(this,arguments)})},{key:"getParticipantBySid",value:(w=Ra(Gc.mark((function e(t){return Gc.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 w.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(k=Ra(Gc.mark((function e(){var t,n=arguments;return Gc.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 k.apply(this,arguments)})},{key:"getMessagesCount",value:(b=Ra(Gc.mark((function e(){var t,n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mh(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:(g=Ra(Gc.mark((function e(){var t,n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new mh(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 g.apply(this,arguments)})},{key:"join",value:(m=Ra(Gc.mark((function e(){return Gc.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 m.apply(this,arguments)})},{key:"leave",value:(y=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t,n,r){var i,a,s,o;return Gc.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 s=e.sent,e.abrupt("return",null!==(a=hh(s.index))&&void 0!==a?a:0);case 5:return e.next=7,this._messagesEntity.sendMedia(t,n,r);case 7:return o=e.sent,e.abrupt("return",null!==(i=hh(o.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 VA(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:(p=Ra(Gc.mark((function e(){var t;return Gc.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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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:(o=Ra(Gc.mark((function e(t){return Gc.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 o.apply(this,arguments)})},{key:"getMessageRecipients",value:(s=Ra(Gc.mark((function e(t){return Gc.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 s.apply(this,arguments)})},{key:"_subscribe",value:(a=Ra(Gc.mark((function e(){var t=this;return Gc.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(vC.updated,(function(e){return t._update(e.data)})),this._entity.on(vC.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=Ra(Gc.mark((function e(){var t,n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return Conversation._logger.trace("_streamsAvailable, this.entity.data=",null===(t=this._entity)||void 0===t?void 0:t.data),r=null===(n=this._entity)||void 0===n?void 0:n.data,e.next=6,this._services.syncClient.list({id:r.messages,mode:"open_existing"});case 6:return this._messagesList=e.sent,e.next=9,this._services.syncClient.map({id:r.roster,mode:"open_existing"});case 9:this._participantsMap=e.sent;case 10:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_subscribeStreams",value:(r=Ra(Gc.mark((function e(){var t,n,r,i,a,s,o;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._subscribe();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,s=a.messages,o=a.roster,e.next=9,Promise.all([this._messagesEntity.subscribe(null!==(r=this._messagesList)&&void 0!==r?r:s),this._participantsEntity.subscribe(null!==(i=this._participantsMap)&&void 0!==i?i:o)]);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=Ra(Gc.mark((function e(){return Gc.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 s=new Set,o=0,u=Object.keys(e);o<u.length;o++){var c=u[o],l=HA[c];if(l)switch(l){case HA.status:if(!e.status||"unknown"===e.status||this._internalState.status===e.status)break;this._internalState.status=e.status,s.add(l);break;case HA.attributes:if(lm(this._internalState.attributes,e.attributes))break;this._internalState.attributes=e.attributes,s.add(l);break;case HA.lastConsumedMessageIndex:if(void 0===e.lastConsumedMessageIndex||e.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=e.lastConsumedMessageIndex,s.add("lastReadMessageIndex");break;case HA.lastMessage:if(this._internalState.lastMessage&&!e.lastMessage){delete this._internalState.lastMessage,s.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,s.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,s.add(l)),lm(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case HA.state:var f=e.state||void 0;if(void 0!==f&&(f.dateUpdated=new Date(f.dateUpdated)),lm(this._internalState.state,f))break;this._internalState.state=f,s.add(l);break;case HA.bindings:if(lm(this._internalState.bindings,e.bindings))break;this._internalState.bindings=e.bindings,s.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],s.add(l)}}s.size>0&&this.emit(Conversation.updated,{conversation:this,updateReasons:xy(s)})}},{key:"_onMessageAdded",value:function(e){var t,n=$A(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=Ra(Gc.mark((function e(t){var n;return Gc.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}(um);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",If.scope("Conversation")),$c([by(py,Sy),Jc("design:type",Function),Jc("design:paramtypes",[String,Object]),Jc("design:returntype",Promise)],Conversation.prototype,"add",null),$c([by(py,py,Sy,Sy),Jc("design:type",Function),Jc("design:paramtypes",[String,String,Object,Object]),Jc("design:returntype",Promise)],Conversation.prototype,"addNonChatParticipant",null),$c([by(hy),Jc("design:type",Function),Jc("design:paramtypes",[Number]),Jc("design:returntype",Promise)],Conversation.prototype,"advanceLastReadMessageIndex",null),$c([by(["undefined",hy],["undefined",hy],["undefined",fy("backwards","forward")]),Jc("design:type",Function),Jc("design:paramtypes",[Number,Number,String]),Jc("design:returntype",Promise)],Conversation.prototype,"getMessages",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"getParticipantBySid",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"getParticipantByIdentity",null),$c([by([py,Participant]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],Conversation.prototype,"removeParticipant",null),$c([by(["string",FormData,fy(null),vy("media options",{contentType:py,media:ly((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"]}))})],Sy,["undefined",fy(null),vy("email attributes",{subject:[py,"undefined"]})]),Jc("design:type",Function),Jc("design:paramtypes",[Object,Object,Object]),Jc("design:returntype",Promise)],Conversation.prototype,"sendMessage",null),$c([by(fy("default","muted")),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"setUserNotificationLevel",null),$c([by(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],Conversation.prototype,"updateAttributes",null),$c([by("string"),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"updateFriendlyName",null),$c([by([fy(null),hy]),Jc("design:type",Function),Jc("design:paramtypes",[Number]),Jc("design:returntype",Promise)],Conversation.prototype,"updateLastReadMessageIndex",null),$c([by(["string",fy(null)]),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"updateUniqueName",null);var YA=function(){function e(){var t=this;Ua(this,e),this._promise=new Promise((function(e,n){t._resolve=e,t._reject=n}))}return Na(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 QA(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 XA(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 XA(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function XA(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 ZA(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 ej(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ZA(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZA(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function tj(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 nj=If.scope("Conversations"),rj=function(e){Oa(p,e);var t,n,r,i,a,s,o,u,c,l,f,d=tj(p);function p(e,t){var n;return Ua(this,p),Ma(Ca(n=d.call(this)),"conversations",new Map),Ma(Ca(n),"myConversationsRead",new YA),Ma(Ca(n),"tombstones",new Set),Ma(Ca(n),"myConversationsFetched",!1),n.configuration=e,n.services=t,n}return Na(p,[{key:"addConversation",value:(f=Ra(Gc.mark((function e(t){var n,r,i,a,s,o,u,c,l,f;return Gc.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(s=e.sent,o=null!==(n=s.sid)&&void 0!==n?n:null,u=null!==(r=null===(i=s.sync_objects)||void 0===i?void 0:i.conversation)&&void 0!==r?r:null,c=ej({self:s.url},s.links),!(l=this.conversations.get(o))){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},o,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=Ra(Gc.mark((function e(){var t,n,r,i,a,s,o,u=this;return Gc.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(yC.itemAdded,(function(e){nj.debug("itemAdded: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),t.on(yC.itemRemoved,(function(e){nj.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(yC.itemUpdated,(function(e){nj.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=QA(n);try{for(i.s();!(a=i.n()).done;)s=a.value,r.push(this._upsertConversation("rest",s.channel_sid,s))}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(),nj.debug("The conversations list has been successfully fetched"),e.abrupt("return",this);case 22:throw e.prev=22,e.t0=e.catch(0),o="Failed to fetch the conversations list","disconnected"!==this.services.syncClient.connectionState&&nj.error(o,e.t0),nj.debug("ERROR: ".concat(o),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=Ra(Gc.mark((function e(){var t,n,r=this;return Gc.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=Ra(Gc.mark((function e(t){var n,r,i,a=this;return Gc.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:(o=Ra(Gc.mark((function e(t){var n,r,i,a,s;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mh(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,s={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,s):null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"peekConversation",value:(s=Ra(Gc.mark((function e(t){var n,r,i,a;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mh(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 s.apply(this,arguments)})},{key:"_getMap",value:(a=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t,n){var r,i=this;return Gc.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=Ra(Gc.mark((function e(t,n,r){var i,a,s;return Gc.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 nj.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),s={},void 0!==r.notificationLevel&&(s.notificationLevel=r.notificationLevel),void 0!==r.lastConsumedMessageIndex&&(s.lastConsumedMessageIndex=r.lastConsumedMessageIndex),lm(s,{})||n._update(s),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=Ra(Gc.mark((function e(t,n,r){var i,a,s,o;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(nj.trace("upsertConversation called for ".concat(n),r),!(i=this.conversations.get(n))){e.next=9;break}return nj.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 nj.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",n),e.abrupt("return",null);case 12:return nj.trace("upsertConversation: creating a local conversation object with sid "+n,r),a="".concat(this.configuration.links.conversations,"/").concat(n),s={self:a,messages:"".concat(a,"/Messages"),participants:"".concat(a,"/Participants")},o=new Conversation(r,n,s,this.configuration,this.services),this.conversations.set(n,o),e.prev=17,e.next=20,o._subscribe();case 20:if("joined"!==r.status){e.next=23;break}return e.next=23,o._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 nj.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(o),this.emit("conversationAdded",o),"joined"===r.status&&(o._setStatus("joined",t),this.emit("conversationJoined",o)),e.abrupt("return",o);case 36:case"end":return e.stop()}}),e,this,[[17,25]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_fetchMyConversations",value:(t=Ra(Gc.mark((function e(){var t,n,r,i,a,s;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=null;case 2:return i=new mh(this.configuration.links.myConversations),n&&i.arg("PageToken",n),e.next=6,this.services.network.get(i.build());case 6:a=e.sent,s=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(s));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}(um),ij=Cn,aj=Xr.find,sj=Vf,oj="find",uj=!0;function cj(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)}}oj in[]&&Array(1).find((function(){uj=!1})),ij({target:"Array",proto:!0,forced:uj},{find:function(e){return aj(this,e,arguments.length>1?arguments[1]:void 0)}}),sj(oj);var lj=function(e){Oa(a,e);var t,n,r,i=cj(a);function a(e,t,n){var r;return Ua(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 Na(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=Ra(Gc.mark((function e(t,n){var r,i,a,s=this;return Gc.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 s.emit("userUpdated",e)})),a.on("userSubscribed",(function(){return s.handleSubscribeUser(a)})),a.on("userUnsubscribed",(function(){return s.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=Ra(Gc.mark((function e(){var t;return Gc.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=Ra(Gc.mark((function e(t){var n,r,i,a;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new mh(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}(um),fj=If.scope("TypingIndicator"),dj=function(){function e(t,n,r){Ua(this,e),this.configuration=n,this.services=r,this.getConversation=t,this.serviceTypingTimeout=null,this.sentUpdates=new Map}var t;return Na(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=Ra(Gc.mark((function t(n,r){return Gc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==Bg.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=Ra(Gc.mark((function e(t){var n=this;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:fj.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 fj.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;fj.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 fj.error("Failed to send typing indicator:",e),e}))}}]),e}(),PushNotification=Na((function PushNotification(e){Ua(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||{}})),pj="2.6.3-rc.5";function hj(){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 vj(e,t,n){return vj=hj()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&Ia(i,n.prototype),i},vj.apply(null,arguments)}function yj(e){var t="function"==typeof Map?new Map:void 0;return yj=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 vj(e,arguments,ja(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Ia(r,e)},yj(e)}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 gj(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 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)}}var kj=function(e){return e.replace(/(^\/+|\/+$)/g,"")},wj=function(e){Oa(n,e);var t=bj(n);function n(e){return Ua(this,n),t.call(this,e)}return Na(n)}(yj(Error)),xj=function(){function e(t,n,r){Ua(this,e),this._serviceUrl=t,this._services=n,this._productId=r}var t,n,r;return Na(e,[{key:"_preProcessUrl",value:function(e){var t=kj(e);return/^https?:\/\//.test(e)?t:"".concat(kj(this._serviceUrl),"/").concat(t)}},{key:"_makeRequest",value:(r=Ra(Gc.mark((function e(t,n,r,i){var a,s,o,u;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._preProcessUrl(n),s=gj({"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,s,this._productId);case 9:case 13:case 17:return o=e.sent,e.abrupt("break",19);case 11:return e.next=13,this._services.transport.post(a,s,JSON.stringify(r),this._productId);case 15:return e.next=17,this._services.transport.delete(a,s,{},this._productId);case 19:if(!(o.status.code<200||o.status.code>=300)){e.next=21;break}throw new Error("Request responded with a non-success code ".concat(o.status.code));case 21:return e.abrupt("return",o);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"fetchResource",value:(n=Ra(Gc.mark((function e(t,n){var r,i,a=this;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Lg({min:50,max:1600,maxAttemptsCount:6}),e.prev=2,e.next=5,r.run(Ra(Gc.mark((function e(){var r,i,s;return Gc.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===(s=e.t0.body)||void 0===s?void 0:s.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 wj("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=Ra(Gc.mark((function e(t,n,r){var i;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n,r,{"X-Twilio-Mutation-Id":Sb.v4()});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}(),_j=Cn,Sj=vm,Ej=o,Tj=E,Rj=hm.exports.onFreeze,Cj=Object.freeze;_j({target:"Object",stat:!0,forced:Ej((function(){Cj(1)})),sham:!Sj},{freeze:function(e){return Cj&&Tj(e)?Cj(Rj(e)):e}});var Ij=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;Ua(this,e),Ma(this,"_cachedTemplates",null),this._services=t,this._pageSize=n,this._cacheTtlMs=r}var t,n;return Na(e,[{key:"getContentTemplates",value:(n=Ra(Gc.mark((function e(){var t,n,r,i,a,s,o,u=this;return Gc.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=pm(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:s=e.sent,o=pm(s,2),r=o[0],i=o[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=Ra(Gc.mark((function e(t){var n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new mh("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 EA(e)})),r.meta.next_token]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();function Oj(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 Pj(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 Pj(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function Pj(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 Aj=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Ua(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 Na(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=Oj(this.oldCache.entries());try{for(r.s();!(n=r.n()).done;){var i=pm(n.value,2),a=i[0],s=i[1];this.onEviction(a,s)}}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:Gc.mark((function e(){var t,n,r,i;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Oj(this),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=pm(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:Gc.mark((function e(){var t,n,r,i;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Oj(this),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=pm(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:Gc.mark((function e(){var t,n,r,i,a,s,o,u;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Oj(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=Oj(this.oldCache),e.prev=18,i.s();case 20:if((a=i.n()).done){e.next=28;break}if(s=a.value,o=pm(s,1),u=o[0],this.cache.has(u)){e.next=26;break}return e.next=26,s;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=Oj(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),jj=Aj,Mj=Na((function e(t,n){Ua(this,e),this.type=t,this.data=n,Object.freeze(n)})),Lj=function(){function e(t,n){Ua(this,e),this._services=t,this._configuration=n,this._cache=new jj({maxSize:n.channelMetadataCacheCapacity})}var t;return Na(e,[{key:"getChannelMetadata",value:(t=Ra(Gc.mark((function e(t,n){var r,i,a,s,o;return Gc.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:s=e.sent,e.next=17;break;case 11:if(e.prev=11,e.t0=e.catch(5),!(e.t0 instanceof wj)){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 o=new Mj(s.type,s.data),this._cache.set(r,{item:o}),e.abrupt("return",o);case 20:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(e,n){return t.apply(this,arguments)})}]),e}();function Nj(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 Uj(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 Uj(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function Uj(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 Dj,Fj,Bj=Na((function e(t){Ua(this,e),Ma(this,"type","email"),this.messageSid=t.message_sid,this.level=t.level,this.name=t.name,this.address=t.address})),qj=Na((function e(t){Ua(this,e),this.type=t.type,this.messageSid=t.message_sid,this.rawData=JSON.stringify(t)})),zj=function(){function e(t,n){Ua(this,e),this._services=t,this._configuration=n,this._cache=new jj({maxSize:n.messageRecipientsCacheCapacity})}var t,n;return Na(e,[{key:"getRecipientsFromMessage",value:(n=Ra(Gc.mark((function e(t,n){var r,i,a,s,o,u=this;return Gc.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 mh(this._configuration.links.conversations).path(t).path("MessageRecipients").arg("MessageSid",n).build(),e.next=7,this._services.commandExecutor.fetchResource(a);case 7:return s=e.sent,(o=s.message_recipients.map((function(e){return u._wrapResponse(e)}))).length>0&&this._cache.set(r,{item:o}),e.abrupt("return",o);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"getRecipientsFromConversation",value:(t=Ra(Gc.mark((function e(t,n){var r,i,a,s,o,u,c,l,f,d,p,h,v=this;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new mh(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:s=e.sent,o=s.message_recipients.map((function(e){return v._wrapResponse(e)})),u=Nj(o);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 yA(o,(function(e,n){return v.getRecipientsFromConversation(t,{pageToken:e,pageSize:n})}),s.meta.previous_token,s.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 Bj(e):new qj(e)}}]),e}();function Wj(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 Gj(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wj(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wj(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Vj(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 $j=Na((function e(){Ua(this,e)}));return e.Client=(Dj=function(e){Oa(Client,e);var t,n,r,i,a,s,o,u,c,l,f,d,p,h,v,y,m=Vj(Client);function Client(e){var t,n,r,i,a,s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Ua(this,Client),Ma(Ca(s=m.call(this)),"version",pj),Ma(Ca(s),"connectionState","unknown"),Ma(Ca(s),"parsePushNotification",Fj.parsePushNotification),s._fpaToken=null!=e?e:"",s._options=null!=o?o:{},!s._options.disableDeepClone){var u=Gj(Gj({},s._options),{},{transport:void 0,twilsockClient:void 0});(u=ph(u)).transport=s._options.transport,u.twilsockClient=s._options.twilsockClient,s._options=u}s._options.logLevel=null!==(t=s._options.logLevel)&&void 0!==t?t:"silent",Fj._logger.setLevel(s._options.logLevel);var c=s._options.productId="ip_messaging";if(s._options.clientMetadata=s._options.clientMetadata||{},s._options.clientMetadata.hasOwnProperty("type")||(s._options.clientMetadata.type="conversations"),s._options.clientMetadata.hasOwnProperty("sdk")||(s._options.clientMetadata.sdk="JS",s._options.clientMetadata.sdkv=pj),s._options.Sync=s._options.Sync||{},void 0===s._options.Sync.enableSessionStorage&&(s._options.Sync.enableSessionStorage=!0),s._options.region&&(s._options.Sync.region=s._options.region),!e)throw new Error("A valid Twilio token should be provided");s._services=new $j,s._myself=new User("","",null,s._services);var l=!s._options.twilsockClient;if(!s._options.initRegistrations){var f=new qg.InitRegistration(c);Fj.populateInitRegistrations(f),s._options.initRegistrations=[f]}s._services.twilsockClient=s._options.twilsockClient=null!==(n=s._options.twilsockClient)&&void 0!==n?n:new qg.TwilsockClient(e,c,s._options),s._services.twilsockClient.on(Fj.tokenAboutToExpire,(function(){return s.emit(Fj.tokenAboutToExpire)})),s._services.twilsockClient.on(Fj.tokenExpired,(function(){return s.emit(Fj.tokenExpired)})),s._services.twilsockClient.on(Fj.connectionError,(function(e){return s.emit(Fj.connectionError,e)})),s._services.twilsockClient.on("stateChanged",(function(e){Fj._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(e)),e!==s.connectionState&&(s.connectionState=e,s.emit(Fj.connectionStateChanged,s.connectionState))})),s._services.transport=s._options.transport=null!==(r=s._options.transport)&&void 0!==r?r:s._options.twilsockClient,s._services.notificationClient=s._options.notificationsClient=null!==(i=s._options.notificationsClient)&&void 0!==i?i:new ME.Notifications(e,s._options),s._services.syncClient=s._options.syncClient=null!==(a=s._options.syncClient)&&void 0!==a?a:new hC(e,s._options);var d=(null==o?void 0:o.Chat)||(null==o?void 0:o.IPMessaging)||o||{},p=d.region||(null==o?void 0:o.region),h=d.apiUri||d.typingUri||"https://aim.".concat(p||"us1",".twilio.com");s._services.commandExecutor=new xj(h,{transport:s._options.transport},c),s._services.contentClient=new Ij(s._services);var v=function(e){s._rejectEnsureReady(e),s.emit(Fj.stateChanged,"failed"),s.emit(Fj.initFailed,{error:e})},y=function(){v({terminal:!0,message:"Twilsock has disconnected."}),s._initializeEnsureReady((null==o?void 0:o.throwErrorsAlways)||!1)};return s._services.twilsockClient.once("connectionError",v),s._services.twilsockClient.once("disconnected",y),s._services.twilsockClient.once("connected",Ra(Gc.mark((function e(){var t,n;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Fj._logger.debug("ConversationsClient started INITIALIZING"),s._services.twilsockClient.off("connectionError",v),s._services.twilsockClient.off("disconnected",y),e.prev=3,t="conversations.client.startup",s._services.twilsockClient.addPartialTelemetryEvent(new qg.TelemetryEventDescription(t,"Conversations client startup",new Date),t,qg.TelemetryPoint.Start),e.next=8,s._initialize();case 8:s._services.twilsockClient.addPartialTelemetryEvent(new qg.TelemetryEventDescription("","",new Date),t,qg.TelemetryPoint.End),e.next=17;break;case 11:e.prev=11,e.t0=e.catch(3),n={terminal:!0,message:e.t0.message},s._rejectEnsureReady(n),s.emit(Fj.stateChanged,"failed"),s.emit(Fj.initFailed,{error:n});case 17:case"end":return e.stop()}}),e,null,[[3,11]])})))),s._initializeEnsureReady((null==o?void 0:o.throwErrorsAlways)||!1),l&&s._services.twilsockClient.connect(),s}return Na(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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:if(Fj._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=Ra(Gc.mark((function e(t){var n;return Gc.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)&&xA("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=Ra(Gc.mark((function e(t){var n;return Gc.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=Ra(Gc.mark((function e(t){var n;return Gc.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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t,n){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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:(o=Ra(Gc.mark((function e(t,n){return Gc.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 o.apply(this,arguments)})},{key:"handlePushNotification",value:(s=Ra(Gc.mark((function e(t){return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:Fj._logger.debug("handlePushNotification, notificationPayload=",t),this.emit("pushNotification",Fj.parsePushNotification(t));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getUser",value:(a=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(){return Gc.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 gC.CancellablePromise(function(){var n=Ra(Gc.mark((function n(r,i,a){var s,o;return Gc.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 s=t._services.mcsClient.mediaSetGetContentUrls(e),a((function(){s.cancel()})),n.prev=5,n.next=8,s;case 8:o=n.sent,r(o),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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(){var t,n=this;return Gc.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,Fj._logger),this._services.channelMetadataClient=new Lj(this._services,this._configuration),this._services.messageRecipientsClient=new zj(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new dj(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new Fg(this._configuration,this._services),this._services.users=new lj(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 rj(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:Fj._supportedPushChannels.forEach((function(e){return n._subscribeToPushNotifications(e)})),this._services.typingIndicator.initialize(),this._services.mcsClient=new gC.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,Gj(Gj({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(Fj.stateChanged,"initialized"),this.emit(Fj.initialized);case 36:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_subscribeToPushNotifications",value:function(e){var t=this;[Bg.NEW_MESSAGE,Bg.ADDED_TO_CONVERSATION,Bg.REMOVED_FROM_CONVERSATION,Bg.TYPING_INDICATOR,Bg.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.subscribe(e,n)}))}},{key:"_unsubscribeFromPushNotifications",value:function(e){var t=this;[Bg.NEW_MESSAGE,Bg.ADDED_TO_CONVERSATION,Bg.REMOVED_FROM_CONVERSATION,Bg.TYPING_INDICATOR,Bg.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=Ra(Gc.mark((function e(t,n){var r;return Gc.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 Fj(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(Fj._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=Fj._parsePushNotificationChatData(e),a=e.aps,s=null;if("string"==typeof a.alert)t=a.alert||null;else t=(null===(n=a.alert)||void 0===n?void 0:n.body)||null,s=(null===(r=a.alert)||void 0===r?void 0:r.title)||null;return new PushNotification({title:s,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 o=e.data;if(!o.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var u=Fj._parsePushNotificationChatData(e.data);return new PushNotification({title:o.twi_title||null,body:o.twi_body||null,sound:o.twi_sound||null,badge:null,action:o.twi_action||null,type:o.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 Fj._supportedPushDataFields){var r=e[n];if(null!=r)if("message_index"!==n&&"media_count"!==n){if("media"!==n)t[Fj._supportedPushDataFields[n]]=r;else if("string"==typeof r)try{t[Fj._supportedPushDataFields[n]]=JSON.parse(r)}catch(e){Fj._logger.debug("Media message notification parsing error")}}else{var i=hh(r);null!==i&&(t[Fj._supportedPushDataFields[n]]=i)}}return t}},{key:"populateInitRegistrations",value:function(e){e.populateInitRegistrations([Bg.TYPING_INDICATOR]),hC.populateInitRegistrations(e)}}]),Client}(um),Ma(Dj,"conversationAdded","conversationAdded"),Ma(Dj,"conversationJoined","conversationJoined"),Ma(Dj,"conversationLeft","conversationLeft"),Ma(Dj,"conversationRemoved","conversationRemoved"),Ma(Dj,"conversationUpdated","conversationUpdated"),Ma(Dj,"participantJoined","participantJoined"),Ma(Dj,"participantLeft","participantLeft"),Ma(Dj,"participantUpdated","participantUpdated"),Ma(Dj,"messageAdded","messageAdded"),Ma(Dj,"messageRemoved","messageRemoved"),Ma(Dj,"messageUpdated","messageUpdated"),Ma(Dj,"tokenAboutToExpire","tokenAboutToExpire"),Ma(Dj,"tokenExpired","tokenExpired"),Ma(Dj,"typingEnded","typingEnded"),Ma(Dj,"typingStarted","typingStarted"),Ma(Dj,"pushNotification","pushNotification"),Ma(Dj,"userSubscribed","userSubscribed"),Ma(Dj,"userUnsubscribed","userUnsubscribed"),Ma(Dj,"userUpdated","userUpdated"),Ma(Dj,"stateChanged","stateChanged"),Ma(Dj,"initialized","initialized"),Ma(Dj,"initFailed","initFailed"),Ma(Dj,"connectionStateChanged","connectionStateChanged"),Ma(Dj,"connectionError","connectionError"),Ma(Dj,"version",pj),Ma(Dj,"_logger",If.scope("Client")),Ma(Dj,"_supportedPushChannels",["fcm","apn"]),Ma(Dj,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),Fj=Dj),$c([wA("token"),Jc("design:type",String),Jc("design:paramtypes",[])],e.Client.prototype,"token",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"updateToken",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),$c([by(["undefined",vy("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],e.Client.prototype,"createConversation",null),$c([by(fy("fcm","apn"),"string"),Jc("design:type",Function),Jc("design:paramtypes",[String,String]),Jc("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),$c([by(fy("fcm","apn")),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),$c([by(fy("fcm","apn"),py),Jc("design:type",Function),Jc("design:paramtypes",[String,String]),Jc("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),$c([by(yy),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"getUser",null),$c([by(dy("strings","string")),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",gC.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),$c([by(dy("media",Media)),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",gC.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),$c([wA("Client.create()","new Client()"),by("string",["undefined",yy]),Jc("design:type",Function),Jc("design:paramtypes",[String,Object]),Jc("design:returntype",Promise)],e.Client,"create",null),$c([gy(yy),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",PushNotification)],e.Client,"parsePushNotification",null),e.Client=Fj=$c([my(py,[yy,"undefined"]),Jc("design:paramtypes",[String,Object])],e.Client),e.AggregatedDeliveryReceipt=AggregatedDeliveryReceipt,e.CancellablePromise=gC.CancellablePromise,e.ChannelMetadata=Mj,e.ContentTemplate=EA,e.ContentTemplateVariable=ContentTemplateVariable,e.Conversation=Conversation,e.DetailedDeliveryReceipt=DetailedDeliveryReceipt,e.EmailRecipientDescriptor=Bj,e.Media=Media,e.Message=Message,e.MessageBuilder=VA,e.NotificationTypes=Bg,e.Participant=Participant,e.PushNotification=PushNotification,e.RestPaginator=yA,e.UnknownRecipientDescriptor=qj,e.UnsentMessage=GA,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")(),s={},o=function(e){try{return!!e()}catch(e){return!0}},u=!o((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,m=function(e){return y.call(e).slice(8,-1)},g=m,b="".split,k=o((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==g(e)?b.call(e,""):Object(e)}:Object,w=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},x=k,_=w,S=function(e){return x(_(e))},E=function(e){return"object"==typeof e?null!==e:"function"==typeof e},T=a,R=function(e){return"function"==typeof e?e:void 0},C=function(e,t){return arguments.length<2?R(T[e]):T[e]&&T[e][t]},I=C("navigator","userAgent")||"",O=a,P=I,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 N=h&&+h,U=N,D=o,F=!!Object.getOwnPropertySymbols&&!D((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&U&&U<41})),B=F&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,q=C,z=B?function(e){return"symbol"==typeof e}:function(e){var t=q("Symbol");return"function"==typeof t&&Object(e)instanceof t},W=E,G={exports:{}},V=a,$=function(e,t){try{Object.defineProperty(V,e,{value:t,configurable:!0,writable:!0})}catch(n){V[e]=t}return t},J=$,K="__core-js_shared__",H=a[K]||J(K,{}),Y=H;(G.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=w,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,se=G.exports,oe=te,ue=ie,ce=F,le=B,fe=se("wks"),de=ae.Symbol,pe=le?de:de&&de.withoutSetter||ue,he=function(e){return oe(fe,e)&&(ce||"string"==typeof fe[e])||(ce&&oe(de,e)?fe[e]=de[e]:fe[e]=pe("Symbol."+e)),fe[e]},ve=E,ye=z,me=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")},ge=he("toPrimitive"),be=function(e,t){if(!ve(e)||ye(e))return e;var n,r=e[ge];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"),me(e,t)},ke=be,we=z,xe=function(e){var t=ke(e,"string");return we(t)?t:String(t)},_e=E,Se=a.document,Ee=_e(Se)&&_e(Se.createElement),Te=function(e){return Ee?Se.createElement(e):{}},Re=Te,Ce=!u&&!o((function(){return 7!=Object.defineProperty(Re("div"),"a",{get:function(){return 7}}).a})),Ie=u,Oe=c,Pe=v,Ae=S,je=xe,Me=te,Le=Ce,Ne=Object.getOwnPropertyDescriptor;s.f=Ie?Ne:function(e,t){if(e=Ae(e),t=je(t),Le)try{return Ne(e,t)}catch(e){}if(Me(e,t))return Pe(!Oe.f.call(e,t),e[t])};var Ue={},De=E,Fe=function(e){if(!De(e))throw TypeError(String(e)+" is not an object");return e},Be=u,qe=Ce,ze=Fe,We=xe,Ge=Object.defineProperty;Ue.f=Be?Ge:function(e,t,n){if(ze(e),t=We(t),ze(n),qe)try{return Ge(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=Ue,$e=v,Je=u?function(e,t,n){return Ve.f(e,t,$e(1,n))}:function(e,t,n){return e[t]=n,e},Ke={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=G.exports,at=ie,st=it("keys"),ot=function(e){return st[e]||(st[e]=at(e))},ut={},ct=rt,lt=E,ft=Je,dt=te,pt=H,ht=ot,vt=ut,yt="Object already initialized",mt=a.WeakMap;if(ct||pt.state){var gt=pt.state||(pt.state=new mt),bt=gt.get,kt=gt.has,wt=gt.set;Qe=function(e,t){if(kt.call(gt,e))throw new TypeError(yt);return t.facade=e,wt.call(gt,e,t),t},Xe=function(e){return bt.call(gt,e)||{}},Ze=function(e){return kt.call(gt,e)}}else{var xt=ht("state");vt[xt]=!0,Qe=function(e,t){if(dt(e,xt))throw new TypeError(yt);return t.facade=e,ft(e,xt,t),t},Xe=function(e){return dt(e,xt)?e[xt]:{}},Ze=function(e){return dt(e,xt)}}var _t={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=Je,Tt=te,Rt=$,Ct=et,It=_t.get,Ot=_t.enforce,Pt=String(String).split("String");(Ke.exports=function(e,t,n,r){var i,a=!!r&&!!r.unsafe,s=!!r&&!!r.enumerable,o=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof t||Tt(n,"name")||Et(n,"name",t),(i=Ot(n)).source||(i.source=Pt.join("string"==typeof t?t:""))),e!==St?(a?!o&&e[t]&&(s=!0):delete e[t],s?e[t]=n:Et(e,t,n)):s?e[t]=n:Rt(t,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&It(this).source||Ct(this)}));var At={},jt=Math.ceil,Mt=Math.floor,Lt=function(e){return isNaN(e=+e)?0:(e>0?Mt:jt)(e)},Nt=Lt,Ut=Math.min,Dt=function(e){return e>0?Ut(Nt(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,Gt=Dt,Vt=zt,$t=function(e){return function(t,n,r){var i,a=Wt(t),s=Gt(a.length),o=Vt(r,s);if(e&&n!=n){for(;s>o;)if((i=a[o++])!=i)return!0}else for(;s>o;o++)if((e||o in a)&&a[o]===n)return e||o||0;return!e&&-1}},Jt={includes:$t(!0),indexOf:$t(!1)},Kt=te,Ht=S,Yt=Jt.indexOf,Qt=ut,Xt=function(e,t){var n,r=Ht(e),i=0,a=[];for(n in r)!Kt(Qt,n)&&Kt(r,n)&&a.push(n);for(;t.length>i;)Kt(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,sn=Fe,on=C("Reflect","ownKeys")||function(e){var t=rn.f(sn(e)),n=an.f;return n?t.concat(n(e)):t},un=te,cn=on,ln=s,fn=Ue,dn=function(e,t){for(var n=cn(t),r=fn.f,i=ln.f,a=0;a<n.length;a++){var s=n[a];un(e,s)||r(e,s,i(t,s))}},pn=o,hn=/#|\.prototype\./,vn=function(e,t){var n=mn[yn(e)];return n==bn||n!=gn&&("function"==typeof t?pn(t):!!t)},yn=vn.normalize=function(e){return String(e).replace(hn,".").toLowerCase()},mn=vn.data={},gn=vn.NATIVE="N",bn=vn.POLYFILL="P",kn=vn,wn=a,xn=s.f,_n=Je,Sn=Ke.exports,En=$,Tn=dn,Rn=kn,Cn=function(e,t){var n,r,i,a,s,o=e.target,u=e.global,c=e.stat;if(n=u?wn:c?wn[o]||En(o,{}):(wn[o]||{}).prototype)for(r in t){if(a=t[r],i=e.noTargetGet?(s=xn(n,r))&&s.value:n[r],!Rn(u?r:o+(c?".":"#")+r,e.forced)&&void 0!==i){if(typeof a==typeof i)continue;Tn(a,i)}(e.sham||i&&i.sham)&&_n(a,"sham",!0),Sn(n,r,a,e)}},In=Ue.f,On=te,Pn=he("toStringTag"),An=function(e,t,n){e&&!On(e=n?e:e.prototype,Pn)&&In(e,Pn,{configurable:!0,value:t})},jn=a,Mn=An;Cn({global:!0},{Reflect:{}}),Mn(jn.Reflect,"Reflect",!0);var Ln,Nn=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e},Un=Xt,Dn=Zt,Fn=Object.keys||function(e){return Un(e,Dn)},Bn=Ue,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},Gn=C("document","documentElement"),Vn=Fe,$n=Wn,Jn=Zt,Kn=ut,Hn=Gn,Yn=Te,Qn=ot("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=Jn.length;n--;)delete tr.prototype[Jn[n]];return tr()};Kn[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=Nn,ir=E,ar=[].slice,sr={},or=function(e,t,n){if(!(t in sr)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";sr[t]=Function("C,a","return new C("+r.join(",")+")")}return sr[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?or(t,i.length,i):t.apply(e,i)};return ir(t.prototype)&&(r.prototype=t.prototype),r},cr=Cn,lr=Nn,fr=Fe,dr=E,pr=nr,hr=ur,vr=o,yr=C("Reflect","construct"),mr=vr((function(){function e(){}return!(yr((function(){}),[],e)instanceof e)})),gr=!vr((function(){yr((function(){}))})),br=mr||gr;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(gr&&!mr)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),s=Function.apply.call(e,a,t);return dr(s)?s:a}});var kr=X,wr=Fn;Cn({target:"Object",stat:!0,forced:o((function(){wr(1)}))},{keys:function(e){return wr(kr(e))}});var xr=m,_r=Array.isArray||function(e){return"Array"==xr(e)},Sr=z,Er=function(e){if(Sr(e))throw TypeError("Cannot convert a Symbol value to a string");return String(e)},Tr={},Rr=S,Cr=At.f,Ir={}.toString,Or="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Tr.f=function(e){return Or&&"[object Window]"==Ir.call(e)?function(e){try{return Cr(e)}catch(e){return Or.slice()}}(e):Cr(Rr(e))};var Pr={},Ar=he;Pr.f=Ar;var jr=a,Mr=te,Lr=Pr,Nr=Ue.f,Ur=function(e){var t=jr.Symbol||(jr.Symbol={});Mr(t,e)||Nr(t,e,{value:Lr.f(e)})},Dr=Nn,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=_r,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},Gr=function(e,t){return new(Wr(e))(0===t?0:t)},Vr=Fr,$r=k,Jr=X,Kr=Dt,Hr=Gr,Yr=[].push,Qr=function(e){var t=1==e,n=2==e,r=3==e,i=4==e,a=6==e,s=7==e,o=5==e||a;return function(u,c,l,f){for(var d,p,h=Jr(u),v=$r(h),y=Vr(c,l,3),m=Kr(v.length),g=0,b=f||Hr,k=t?b(u,m):n||s?b(u,0):void 0;m>g;g++)if((o||g in v)&&(p=y(d=v[g],g,h),e))if(t)k[g]=p;else if(p)switch(e){case 3:return!0;case 5:return d;case 6:return g;case 2:Yr.call(k,d)}else switch(e){case 4:return!1;case 7:Yr.call(k,d)}return a?-1:r||i?i:k}},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=Cn,ei=a,ti=C,ni=u,ri=F,ii=o,ai=te,si=_r,oi=E,ui=z,ci=Fe,li=X,fi=S,di=xe,pi=Er,hi=v,vi=nr,yi=Fn,mi=At,gi=Tr,bi=nn,ki=s,wi=Ue,xi=c,_i=Je,Si=Ke.exports,Ei=G.exports,Ti=ut,Ri=ie,Ci=he,Ii=Pr,Oi=Ur,Pi=An,Ai=_t,ji=Xr.forEach,Mi=ot("hidden"),Li="Symbol",Ni=Ci("toPrimitive"),Ui=Ai.set,Di=Ai.getterFor(Li),Fi=Object.prototype,Bi=ei.Symbol,qi=ti("JSON","stringify"),zi=ki.f,Wi=wi.f,Gi=gi.f,Vi=xi.f,$i=Ei("symbols"),Ji=Ei("op-symbols"),Ki=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 Ui(n,{type:Li,tag:e,description:t}),ni||(n.description=t),n},ta=function(e,t,n){e===Fi&&ta(Ji,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(sa(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(Ji,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(Ji,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=Gi(fi(e)),n=[];return ji(t,(function(e){ai($i,e)||ai(Ti,e)||n.push(e)})),n},sa=function(e){var t=e===Fi,n=Gi(t?Ji: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=Ri(e),n=function(e){this===Fi&&n.call(Ji,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(Ri(e),e)})),xi.f=ra,wi.f=ta,ki.f=ia,mi.f=gi.f=aa,bi.f=sa,Ii.f=function(e){return ea(Ci(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(Ki,t))return Ki[t];var n=Bi(t);return Ki[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:sa}),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,(oi(t)||void 0!==e)&&!ui(e))return si(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[Ni]||_i(Bi.prototype,Ni,Bi.prototype.valueOf),Pi(Bi,Li),Ti[Mi]=!0;var oa=o,ua=N,ca=he("species"),la=function(e){return ua>=51||!oa((function(){var t=[];return(t.constructor={})[ca]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},fa=Xr.filter;Cn({target:"Array",proto:!0,forced:!la("filter")},{filter:function(e){return fa(this,e,arguments.length>1?arguments[1]:void 0)}});var da=Cn,pa=o,ha=S,va=s.f,ya=u,ma=pa((function(){va(1)}));da({target:"Object",stat:!0,forced:!ya||ma,sham:!ya},{getOwnPropertyDescriptor:function(e,t){return va(ha(e),t)}});var ga=xe,ba=Ue,ka=v,wa=function(e,t,n){var r=ga(t);r in e?ba.f(e,r,ka(0,n)):e[r]=n},xa=on,_a=S,Sa=s,Ea=wa;function Ta(e,t,n,r,i,a,s){try{var o=e[a](s),u=o.value}catch(e){return void n(e)}o.done?t(u):Promise.resolve(u).then(r,i)}function Ra(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function s(e){Ta(a,r,i,s,o,"next",e)}function o(e){Ta(a,r,i,s,o,"throw",e)}s(void 0)}))}}function Ca(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ia(e,t){return Ia=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},Ia(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&&Ia(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 Ca(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 Na(e,t,n){return t&&La(e.prototype,t),n&&La(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ua(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Cn({target:"Object",stat:!0,sham:!u},{getOwnPropertyDescriptors:function(e){for(var t,n,r=_a(e),i=Sa.f,a=xa(r),s={},o=0;a.length>o;)void 0!==(n=i(r,t=a[o++]))&&Ea(s,t,n);return s}});var Da=Xr.map;Cn({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=m,Wa=he("toStringTag"),Ga="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:Ga?za(t):"Object"==(r=za(t))&&"function"==typeof t.callee?"Arguments":r},$a=Va,Ja=Ba?{}.toString:function(){return"[object "+$a(this)+"]"},Ka=Ba,Ha=Ke.exports,Ya=Ja;Ka||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=Te("span").classList,Za=Xa&&Xa.constructor&&Xa.constructor.prototype,es=Za===Object.prototype?void 0:Za,ts=o,ns=function(e,t){var n=[][e];return!!n&&ts((function(){n.call(null,t||function(){throw 1},1)}))},rs=Xr.forEach,is=ns("forEach")?[].forEach:function(e){return rs(this,e,arguments.length>1?arguments[1]:void 0)},as=a,ss=Qa,os=es,us=is,cs=Je,ls=function(e){if(e&&e.forEach!==us)try{cs(e,"forEach",us)}catch(t){e.forEach=us}};for(var fs in ss)ls(as[fs]&&as[fs].prototype);ls(os);var ds=a.Promise,ps=Ke.exports,hs=function(e,t,n){for(var r in t)ps(e,r,t[r],n);return e},vs=E,ys=Fe,ms=function(e){if(!vs(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e},gs=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 ys(n),ms(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),bs=C,ks=Ue,ws=u,xs=he("species"),_s=function(e){var t=bs(e),n=ks.f;ws&&t&&!t[xs]&&n(t,xs,{configurable:!0,get:function(){return this}})},Ss=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},Es={},Ts=Es,Rs=he("iterator"),Cs=Array.prototype,Is=function(e){return void 0!==e&&(Ts.Array===e||Cs[Rs]===e)},Os=Va,Ps=Es,As=he("iterator"),js=function(e){if(null!=e)return e[As]||e["@@iterator"]||Ps[Os(e)]},Ms=Fe,Ls=js,Ns=function(e,t){var n=arguments.length<2?Ls(e):t;if("function"!=typeof n)throw TypeError(String(e)+" is not iterable");return Ms(n.call(e))},Us=Fe,Ds=function(e,t,n){var r,i;Us(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 Us(r),n},Fs=Fe,Bs=Is,qs=Dt,zs=Fr,Ws=Ns,Gs=js,Vs=Ds,$s=function(e,t){this.stopped=e,this.result=t},Js=function(e,t,n){var r,i,a,s,o,u,c,l=n&&n.that,f=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),h=zs(t,l,1+f+p),v=function(e){return r&&Vs(r,"normal",e),new $s(!0,e)},y=function(e){return f?(Fs(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=Gs(e)))throw TypeError("Target is not iterable");if(Bs(i)){for(a=0,s=qs(e.length);s>a;a++)if((o=y(e[a]))&&o instanceof $s)return o;return new $s(!1)}r=Ws(e,i)}for(u=r.next;!(c=u.call(r)).done;){try{o=y(c.value)}catch(e){Vs(r,"throw",e)}if("object"==typeof o&&o&&o instanceof $s)return o}return new $s(!1)},Ks=he("iterator"),Hs=!1;try{var Ys=0,Qs={next:function(){return{done:!!Ys++}},return:function(){Hs=!0}};Qs[Ks]=function(){return this},Array.from(Qs,(function(){throw 2}))}catch(e){}var Xs,Zs,eo,to,no=function(e,t){if(!t&&!Hs)return!1;var n=!1;try{var r={};r[Ks]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},ro=Fe,io=Nn,ao=he("species"),so=function(e,t){var n,r=ro(e).constructor;return void 0===r||null==(n=ro(r)[ao])?t:io(n)},oo=/(?:ipad|iphone|ipod).*applewebkit/i.test(I),uo="process"==m(a.process),co=a,lo=o,fo=Fr,po=Gn,ho=Te,vo=oo,yo=uo,mo=co.setImmediate,go=co.clearImmediate,bo=co.process,ko=co.MessageChannel,wo=co.Dispatch,xo=0,_o={},So="onreadystatechange";try{Xs=co.location}catch(e){}var Eo=function(e){if(_o.hasOwnProperty(e)){var t=_o[e];delete _o[e],t()}},To=function(e){return function(){Eo(e)}},Ro=function(e){Eo(e.data)},Co=function(e){co.postMessage(String(e),Xs.protocol+"//"+Xs.host)};mo&&go||(mo=function(e){for(var t=[],n=arguments.length,r=1;n>r;)t.push(arguments[r++]);return _o[++xo]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},Zs(xo),xo},go=function(e){delete _o[e]},yo?Zs=function(e){bo.nextTick(To(e))}:wo&&wo.now?Zs=function(e){wo.now(To(e))}:ko&&!vo?(to=(eo=new ko).port2,eo.port1.onmessage=Ro,Zs=fo(to.postMessage,to,1)):co.addEventListener&&"function"==typeof postMessage&&!co.importScripts&&Xs&&"file:"!==Xs.protocol&&!lo(Co)?(Zs=Co,co.addEventListener("message",Ro,!1)):Zs=So in ho("script")?function(e){po.appendChild(ho("script")).onreadystatechange=function(){po.removeChild(this),Eo(e)}}:function(e){setTimeout(To(e),0)});var Io,Oo,Po,Ao,jo,Mo,Lo,No,Uo={set:mo,clear:go},Do=a,Fo=/ipad|iphone|ipod/i.test(I)&&void 0!==Do.Pebble,Bo=/web0s(?!.*chrome)/i.test(I),qo=a,zo=s.f,Wo=Uo.set,Go=oo,Vo=Fo,$o=Bo,Jo=uo,Ko=qo.MutationObserver||qo.WebKitMutationObserver,Ho=qo.document,Yo=qo.process,Qo=qo.Promise,Xo=zo(qo,"queueMicrotask"),Zo=Xo&&Xo.value;Zo||(Io=function(){var e,t;for(Jo&&(e=Yo.domain)&&e.exit();Oo;){t=Oo.fn,Oo=Oo.next;try{t()}catch(e){throw Oo?Ao():Po=void 0,e}}Po=void 0,e&&e.enter()},Go||Jo||$o||!Ko||!Ho?!Vo&&Qo&&Qo.resolve?((Lo=Qo.resolve(void 0)).constructor=Qo,No=Lo.then,Ao=function(){No.call(Lo,Io)}):Ao=Jo?function(){Yo.nextTick(Io)}:function(){Wo.call(qo,Io)}:(jo=!0,Mo=Ho.createTextNode(""),new Ko(Io).observe(Mo,{characterData:!0}),Ao=function(){Mo.data=jo=!jo}));var eu=Zo||function(e){var t={fn:e,next:void 0};Po&&(Po.next=t),Oo||(Oo=t,Ao()),Po=t},tu={},nu=Nn,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,su,ou,uu=Fe,cu=E,lu=tu,fu=a,du="object"==typeof window,pu=Cn,hu=a,vu=C,yu=ds,mu=Ke.exports,gu=hs,bu=gs,ku=An,wu=_s,xu=E,_u=Nn,Su=Ss,Eu=et,Tu=Js,Ru=no,Cu=so,Iu=Uo.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=_t,Nu=kn,Uu=du,Du=uo,Fu=N,Bu=he("species"),qu="Promise",zu=Lu.get,Wu=Lu.set,Gu=Lu.getterFor(qu),Vu=yu&&yu.prototype,$u=yu,Ju=Vu,Ku=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=Nu(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&&Uu&&!ec})),ic=rc||!Ru((function(e){$u.all(e).catch((function(){}))})),ac=function(e){var t;return!(!xu(e)||"function"!=typeof(t=e.then))&&t},sc=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 s,o,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?s=r:(p&&p.enter(),s=l(r),p&&(p.exit(),u=!0)),s===c.promise?d(Ku("Promise-chain cycle")):(o=ac(s))?o.call(s,f,d):f(s)):d(r)}catch(e){p&&!u&&p.exit(),d(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&uc(e)}))}},oc=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){Iu.call(hu,(function(){var t,n=e.facade,r=e.value;if(cc(e)&&(t=Mu((function(){Du?Yu.emit("unhandledRejection",r,n):oc(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){Iu.call(hu,(function(){var t=e.facade;Du?Yu.emit("rejectionHandled",t):oc("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,sc(e,!0))},pc=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw Ku("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,sc(e,!1))}catch(t){dc({done:!1},t,e)}}};if(rc&&(Ju=($u=function(e){Su(this,$u,qu),_u(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=gu(Ju,{then:function(e,t){var n=Gu(this),r=Qu(Cu(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&&sc(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===su?new au(e):Xu(e)},"function"==typeof yu&&Vu!==Object.prototype)){ou=Vu.then,nc||(mu(Vu,"then",(function(e,t){var n=this;return new $u((function(e,t){ou.call(n,e,t)})).then(e,t)}),{unsafe:!0}),mu(Vu,"catch",Ju.catch,{unsafe:!0}));try{delete Vu.constructor}catch(e){}bu&&bu(Vu,Ju)}pu({global:!0,wrap:!0,forced:rc},{Promise:$u}),ku($u,qu,!1),wu(qu),su=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=_u(t.resolve),a=[],s=0,o=1;Tu(e,(function(e){var u=s++,c=!1;a.push(void 0),o++,n.call(t,e).then((function(e){c||(c=!0,a[u]=e,--o||r(a))}),i)})),--o||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=_u(t.resolve);Tu(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,mc="function"==typeof Symbol?Symbol:{},gc=mc.iterator||"@@iterator",bc=mc.asyncIterator||"@@asyncIterator",kc=mc.toStringTag||"@@toStringTag";function wc(e,t,n,r){var i=t&&t.prototype instanceof Cc?t:Cc,a=Object.create(i.prototype),s=new qc(r||[]);return a._invoke=function(e,t,n){var r=_c;return function(i,a){if(r===Ec)throw new Error("Generator is already running");if(r===Tc){if("throw"===i)throw a;return Wc()}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var o=Dc(s,n);if(o){if(o===Rc)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===_c)throw r=Tc,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=Ec;var u=xc(e,t,n);if("normal"===u.type){if(r=n.done?Tc:Sc,u.arg===Rc)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=Tc,n.method="throw",n.arg=u.arg)}}}(e,n,s),a}function xc(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}var _c="suspendedStart",Sc="suspendedYield",Ec="executing",Tc="completed",Rc={};function Cc(){}function Ic(){}function Oc(){}var Pc={};Pc[gc]=function(){return this};var Ac=Object.getPrototypeOf,jc=Ac&&Ac(Ac(zc([])));jc&&jc!==vc&&yc.call(jc,gc)&&(Pc=jc);var Mc=Oc.prototype=Cc.prototype=Object.create(Pc);function Lc(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function Nc(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===Ic||"GeneratorFunction"===(t.displayName||t.name))}function Uc(e,t){function n(r,i,a,s){var o=xc(e[r],e,i);if("throw"!==o.type){var u=o.arg,c=u.value;return c&&"object"===Pa(c)&&yc.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(c).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(o.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 Rc;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return Rc}var r=xc(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,Rc;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,Rc):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,Rc)}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[gc];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}}Ic.prototype=Mc.constructor=Oc,Oc.constructor=Ic,Oc[kc]=Ic.displayName="GeneratorFunction",Lc(Uc.prototype),Uc.prototype[bc]=function(){return this},Lc(Mc),Mc[kc]="Generator",Mc[gc]=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 s=yc.call(i,"catchLoc"),o=yc.call(i,"finallyLoc");if(s&&o){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!o)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,Rc):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),Rc},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),Rc}},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),Rc}};var Gc={wrap:wc,isGeneratorFunction:Nc,AsyncIterator:Uc,mark:function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,Oc):(e.__proto__=Oc,kc in e||(e[kc]="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 Uc(wc(e,t,n,r),i);return Nc(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:Gc});function $c(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":Pa(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function Jc(e,t){if("object"===("undefined"==typeof Reflect?"undefined":Pa(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var Kc=Cn,Hc=o,Yc=_r,Qc=E,Xc=X,Zc=Dt,el=wa,tl=Gr,nl=la,rl=N,il=he("isConcatSpreadable"),al=9007199254740991,sl="Maximum allowed index exceeded",ol=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)};Kc({target:"Array",proto:!0,forced:!ol||!ul},{concat:function(e){var t,n,r,i,a,s=Xc(this),o=tl(s,0),u=0;for(t=-1,r=arguments.length;t<r;t++)if(cl(a=-1===t?s:arguments[t])){if(u+(i=Zc(a.length))>al)throw TypeError(sl);for(n=0;n<i;n++,u++)n in a&&el(o,u,a[n])}else{if(u>=al)throw TypeError(sl);el(o,u++,a)}return o.length=u,o}});var ll=Fe,fl=Ds,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=Is,yl=Dt,ml=wa,gl=Ns,bl=js,kl=function(e){var t,n,r,i,a,s,o=pl(e),u="function"==typeof this?this:Array,c=arguments.length,l=c>1?arguments[1]:void 0,f=void 0!==l,d=bl(o),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(o.length));t>p;p++)s=f?l(o[p],p):o[p],ml(n,p,s);else for(a=(i=gl(o,d)).next,n=new u;!(r=a.call(i)).done;p++)s=f?hl(i,l,[r.value,p],!0):r.value,ml(n,p,s);return n.length=p,n},wl=kl;Cn({target:"Array",stat:!0,forced:!no((function(e){Array.from(e)}))},{from:wl});var xl,_l,Sl,El=Lt,Tl=Er,Rl=w,Cl=function(e){return function(t,n){var r,i,a=Tl(Rl(t)),s=El(n),o=a.length;return s<0||s>=o?e?"":void 0:(r=a.charCodeAt(s))<55296||r>56319||s+1===o||(i=a.charCodeAt(s+1))<56320||i>57343?e?a.charAt(s):r:e?a.slice(s,s+2):i-56320+(r-55296<<10)+65536}},Il={codeAt:Cl(!1),charAt:Cl(!0)},Ol=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Pl=te,Al=X,jl=Ol,Ml=ot("IE_PROTO"),Ll=Object.prototype,Nl=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},Ul=o,Dl=Nl,Fl=Je,Bl=he("iterator"),ql=!1;[].keys&&("next"in(Sl=[].keys())?(_l=Dl(Dl(Sl)))!==Object.prototype&&(xl=_l):ql=!0);var zl=null==xl||Ul((function(){var e={};return xl[Bl].call(e)!==e}));zl&&(xl={}),"function"!=typeof xl[Bl]&&Fl(xl,Bl,(function(){return this}));var Wl={IteratorPrototype:xl,BUGGY_SAFARI_ITERATORS:ql},Gl=Wl.IteratorPrototype,Vl=nr,$l=v,Jl=An,Kl=Es,Hl=function(){return this},Yl=function(e,t,n){var r=t+" Iterator";return e.prototype=Vl(Gl,{next:$l(1,n)}),Jl(e,r,!1),Kl[r]=Hl,e},Ql=Cn,Xl=Yl,Zl=Nl,ef=gs,tf=An,nf=Je,rf=Ke.exports,af=Es,sf=Wl.IteratorPrototype,of=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,s){Xl(n,t,r);var o,u,c,l=function(e){if(e===i&&v)return v;if(!of&&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=!of&&h||l(i),y="Array"==t&&p.entries||h;if(y&&(o=Zl(y.call(new e)))!==Object.prototype&&o.next&&(Zl(o)!==sf&&(ef?ef(o,sf):"function"!=typeof o[uf]&&nf(o,uf,df)),tf(o,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)},s)for(c in u)(of||d||!(c in p))&&rf(p,c,u[c]);else Ql({target:t,proto:!0,forced:of||d},u);return u},hf=Il.charAt,vf=Er,yf=_t,mf=pf,gf="String Iterator",bf=yf.set,kf=yf.getterFor(gf);mf(String,"String",(function(e){bf(this,{type:gf,string:vf(e),index:0})}),(function(){var e,t=kf(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 wf,xf,_f,Sf={exports:{}};function Ef(e,t){return["".concat((new Date).toISOString()," Conversations ").concat(e,":")].concat(Array.from(t))}xf=n,_f=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 s(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 o(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&&(o.call(this,n,r),this[e].apply(this,arguments))}}function c(e,t,n){return s(e)||u.apply(this,arguments)}function l(e,n,i){var a,s=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===s.levels[e]&&(e=void 0),e}}"string"==typeof e?u+=":"+e:"symbol"===Pa(e)&&(u=void 0),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=i||c,s.getLevel=function(){return a},s.setLevel=function(n,i){if("string"==typeof n&&void 0!==s.levels[n.toUpperCase()]&&(n=s.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=s.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),o.call(s,n,e),("undefined"==typeof console?"undefined":Pa(console))===t&&n<s.levels.SILENT)return"No console available for logging"},s.setDefaultLevel=function(e){n=e,l()||s.setLevel(e,!1)},s.resetLevel=function(){s.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){}}}()},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var f=l();null==f&&(f=n),s.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},(wf=Sf).exports?wf.exports=_f():xf.log=_f();var Tf,Rf,Cf=Sf.exports.getLogger("twilio-conversations"),If=function(){function e(t){Ua(this,e),Ma(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return Na(e,[{key:"setLevel",value:function(e){Cf.setLevel(e)}},{key:"trace",value:function(){if(Cf.getLevel()==Cf.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Cf.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];Cf.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];Cf.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];Cf.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];Cf.error.apply(null,Ef(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){Cf.setLevel(e)}},{key:"trace",value:function(){if(Cf.getLevel()==Cf.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];Cf.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];Cf.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];Cf.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];Cf.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];Cf.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=Rf=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=Tf=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 Nf(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 Uf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Nf(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Nf(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=Na((function e(){var t,n,r,i,a,s,o,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;Ua(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=Uf({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=Tf(Rf(p))}catch(e){f.error("Failed to parse http cache interval ".concat(p,", using default value ").concat(Df)),this.httpCacheInterval=Tf(Rf(Df))}var h=null!==(a=null!==(s=d.consumptionReportIntervalOverride)&&void 0!==s?s:l.options.consumption_report_interval)&&void 0!==a?a:Ff;try{this.consumptionReportInterval=Tf(Rf(h))}catch(e){f.error("Failed to parse consumption report interval ".concat(h,", using default value ").concat(Ff)),this.consumptionReportInterval=Tf(Rf(Ff))}this.channelMetadataCacheCapacity=null!==(o=c.channelMetadataCacheCapacity)&&void 0!==o?o:100,this.messageRecipientsCacheCapacity=null!==(u=c.messageRecipientsCacheCapacity)&&void 0!==u?u:1e3})),qf=nr,zf=Ue,Wf=he("unscopables"),Gf=Array.prototype;null==Gf[Wf]&&zf.f(Gf,Wf,{configurable:!0,value:qf(null)});var Vf=function(e){Gf[Wf][e]=!0},$f=S,Jf=Vf,Kf=Es,Hf=_t,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");Kf.Arguments=Kf.Array,Jf("keys"),Jf("values"),Jf("entries");var td=a,nd=Qa,rd=es,id=ed,ad=Je,sd=he,od=sd("iterator"),ud=sd("toStringTag"),cd=id.values,ld=function(e,t){if(e){if(e[od]!==cd)try{ad(e,od,cd)}catch(t){e[od]=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=Cn,pd=o,hd=C("JSON","stringify"),vd=/[\uD800-\uDFFF]/g,yd=/^[\uD800-\uDBFF]$/,md=/^[\uDC00-\uDFFF]$/,gd=function(e,t,n){var r=n.charAt(t-1),i=n.charAt(t+1);return yd.test(e)&&!md.test(i)||md.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,gd):r}});var kd=E,wd=gs,xd=function(e,t,n){var r,i;return wd&&"function"==typeof(r=t.constructor)&&r!==n&&kd(i=r.prototype)&&i!==n.prototype&&wd(e,i),e},_d=w,Sd=Er,Ed="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Td=RegExp("^"+Ed+Ed+"*"),Rd=RegExp(Ed+Ed+"*$"),Cd=function(e){return function(t){var n=Sd(_d(t));return 1&e&&(n=n.replace(Td,"")),2&e&&(n=n.replace(Rd,"")),n}},Id={start:Cd(1),end:Cd(2),trim:Cd(3)},Od=u,Pd=a,Ad=kn,jd=Ke.exports,Md=te,Ld=m,Nd=xd,Ud=z,Dd=be,Fd=o,Bd=nr,qd=At.f,zd=s.f,Wd=Ue.f,Gd=Id.trim,Vd="Number",$d=Pd.Number,Jd=$d.prototype,Kd=Ld(Bd(Jd))==Vd,Hd=function(e){if(Ud(e))throw TypeError("Cannot convert a Symbol value to a number");var t,n,r,i,a,s,o,u,c=Dd(e,"number");if("string"==typeof c&&c.length>2)if(43===(t=(c=Gd(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(s=(a=c.slice(2)).length,o=0;o<s;o++)if((u=a.charCodeAt(o))<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&&(Kd?Fd((function(){Jd.valueOf.call(n)})):Ld(n)!=Vd)?Nd(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=Jd,Jd.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=o,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,sp,op=o,up=a.RegExp,cp=op((function(){var e=up(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),lp=o,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=G.exports,mp=nr,gp=_t.get,bp=cp,kp=dp,wp=RegExp.prototype.exec,xp=yp("native-string-replace",String.prototype.replace),_p=wp,Sp=(ap=/a/,sp=/b*/g,wp.call(ap,"a"),wp.call(sp,"a"),0!==ap.lastIndex||0!==sp.lastIndex),Ep=vp.UNSUPPORTED_Y||vp.BROKEN_CARET,Tp=void 0!==/()??/.exec("")[1];(Sp||Tp||Ep||bp||kp)&&(_p=function(e){var t,n,r,i,a,s,o,u=this,c=gp(u),l=pp(e),f=c.raw;if(f)return f.lastIndex=u.lastIndex,t=_p.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,m=l;if(p&&(-1===(h=h.replace("y","")).indexOf("g")&&(h+="g"),m=l.slice(u.lastIndex),u.lastIndex>0&&(!u.multiline||u.multiline&&"\n"!==l.charAt(u.lastIndex-1))&&(v="(?: "+v+")",m=" "+m,y++),n=new RegExp("^(?:"+v+")",h)),Tp&&(n=new RegExp("^"+v+"$(?!\\s)",h)),Sp&&(r=u.lastIndex),i=wp.call(p?n:u,m),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),Tp&&i&&i.length>1&&xp.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=s=mp(null),a=0;a<d.length;a++)s[(o=d[a])[0]]=i[o[1]];return i});var Rp=_p;Cn({target:"RegExp",proto:!0,forced:/./.exec!==Rp},{exec:Rp});var Cp=Ke.exports,Ip=Rp,Op=o,Pp=he,Ap=Je,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)})),s=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||!s||n){var o=/./[i],u=t(i,""[e],(function(e,t,n,r,i){var s=t.exec;return s===Ip||s===Mp.exec?a&&!i?{done:!0,value:o.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}));Cp(String.prototype,e,u[0]),Cp(Mp,i,u[1])}r&&Ap(Mp[i],"sham",!0)},Np=Il.charAt,Up=function(e,t,n){return t+(n?Np(e,t).length:1)},Dp=X,Fp=Math.floor,Bp="".replace,qp=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,zp=/\$([$&'`]|\d{1,2})/g,Wp=m,Gp=Rp,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 Gp.call(e,t)},$p=Lp,Jp=o,Kp=Fe,Hp=Lt,Yp=Dt,Qp=Er,Xp=w,Zp=Up,eh=function(e,t,n,r,i,a){var s=n+e.length,o=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(s);case"<":c=i[u.slice(1,-1)];break;default:var l=+u;if(0===l)return a;if(l>o){var f=Fp(l/10);return 0===f?a:f<=o?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"),sh=!!/./[nh]&&""===/./[nh]("a","$0"),oh=!Jp((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=sh?"$":"$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=Kp(this),s=Qp(e);if("string"==typeof i&&-1===i.indexOf(r)&&-1===i.indexOf("$<")){var o=n(t,a,s,i);if(o.done)return o.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,s);if(null===d)break;if(f.push(d),!c)break;""===Qp(d[0])&&(a.lastIndex=Zp(s,Yp(a.lastIndex),l))}for(var p,h="",v=0,y=0;y<f.length;y++){d=f[y];for(var m=Qp(d[0]),g=rh(ih(Hp(d.index),s.length),0),b=[],k=1;k<d.length;k++)b.push(void 0===(p=d[k])?p:String(p));var w=d.groups;if(u){var x=[m].concat(b,g,s);void 0!==w&&x.push(w);var _=Qp(i.apply(void 0,x))}else _=eh(m,s,g,b,w,i);g>=v&&(h+=s.slice(v,g)+_,v=g+m.length)}return h+s.slice(v)}]}),!oh||!ah||sh);var uh=Cn,ch=S,lh=[].join,fh=k!=Object,dh=ns("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 mh=function(){function e(t){Ua(this,e),this.base=t.replace(/\/$/,""),this.args=[],this.paths=[]}return Na(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}(),gh={},bh={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}(bh);var kh=u,wh=Ue.f,xh=Function.prototype,_h=xh.toString,Sh=/^\s*function ([^ (]*)/,Eh="name";kh&&!(Eh in xh)&&wh(xh,Eh,{configurable:!0,get:function(){try{return _h.call(this).match(Sh)[1]}catch(e){return""}}});var Th={exports:{}},Rh={exports:{}};!function(e){e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports}(Rh);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=[],s=!0,o=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){o=!0,i=e}finally{try{s||null==n.return||n.return()}finally{if(o)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports}(Ch);var Ih={exports:{}},Oh={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}(Oh),function(e){var t=Oh.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}(Ih);var Ph={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}(Ph),function(e){var t=Rh.exports,n=Ch.exports,r=Ih.exports,i=Ph.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}(Th);var Ah=Cn,jh=E,Mh=_r,Lh=zt,Nh=Dt,Uh=S,Dh=wa,Fh=he,Bh=la("slice"),qh=Fh("species"),zh=[].slice,Wh=Math.max;Ah({target:"Array",proto:!0,forced:!Bh},{slice:function(e,t){var n,r,i,a=Uh(this),s=Nh(a.length),o=Lh(e,s),u=Lh(void 0===t?s:t,s);if(Mh(a)&&("function"!=typeof(n=a.constructor)||n!==Array&&!Mh(n.prototype)?jh(n)&&null===(n=n[qh])&&(n=void 0):n=void 0,n===Array||void 0===n))return zh.call(a,o,u);for(r=new(void 0===n?Array:n)(Wh(u-o,0)),i=0;o<u;o++,i++)o in a&&Dh(r,i,a[o]);return r.length=i,r}});var Gh=Cn,Vh=E,$h=function(){var e=!1,t=/[ac]/;return t.exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e}(),Jh=/./.test;Gh({target:"RegExp",proto:!0,forced:!$h},{test:function(e){if("function"!=typeof this.exec)return Jh.call(this,e);var t=this.exec(e);if(null!==t&&!Vh(t))throw new Error("RegExp exec method returned something other than an Object or null");return!!t}});var Kh=Cn,Hh=u,Yh=a,Qh=te,Xh=E,Zh=Ue.f,ev=dn,tv=Yh.Symbol;if(Hh&&"function"==typeof tv&&(!("description"in tv.prototype)||void 0!==tv().description)){var nv={},rv=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof rv?new tv(e):void 0===e?tv():tv(e);return""===e&&(nv[t]=!0),t};ev(rv,tv);var iv=rv.prototype=tv.prototype;iv.constructor=rv;var av=iv.toString,sv="Symbol(test)"==String(tv("test")),ov=/^Symbol\((.*)\)[^)]+$/;Zh(iv,"description",{configurable:!0,get:function(){var e=Xh(this)?this.valueOf():this,t=av.call(e);if(Qh(nv,e))return"";var n=sv?t.slice(7,-1):t.replace(ov,"$1");return""===n?void 0:n}}),Kh({global:!0,forced:!0},{Symbol:rv})}Ur("iterator");var uv={exports:{}},cv={exports:{}};!function(e){var t=Oh.exports;e.exports=function(e){if(Array.isArray(e))return t(e)},e.exports.__esModule=!0,e.exports.default=e.exports}(cv);var lv={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}(lv);var fv={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}(fv),function(e){var t=cv.exports,n=lv.exports,r=Ih.exports,i=fv.exports;e.exports=function(e){return t(e)||n(e)||r(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports}(uv);var dv={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}(dv);var pv={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}(pv);var hv={exports:{}},vv={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}(vv),function(e){var t=vv.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}(hv);var yv={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=bh.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}(yv);var gv={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}(gv);var bv=Jt.includes,kv=Vf;Cn({target:"Array",proto:!0},{includes:function(e){return bv(this,e,arguments.length>1?arguments[1]:void 0)}}),kv("includes");var wv=E,xv=Math.floor,_v=function(e){return!wv(e)&&isFinite(e)&&xv(e)===e};Cn({target:"Number",stat:!0},{isInteger:_v});var Sv=u,Ev=Fn,Tv=S,Rv=c.f,Cv=function(e){return function(t){for(var n,r=Tv(t),i=Ev(r),a=i.length,s=0,o=[];a>s;)n=i[s++],Sv&&!Rv.call(r,n)||o.push(e?[n,r[n]]:r[n]);return o}},Iv={entries:Cv(!0),values:Cv(!1)}.entries;Cn({target:"Object",stat:!0},{entries:function(e){return Iv(e)}}),Object.defineProperty(gh,"__esModule",{value:!0});var Ov=Th.exports,Pv=uv.exports,Av=dv.exports,jv=pv.exports,Mv=hv.exports,Lv=yv.exports,Nv=gv.exports;function Uv(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var Dv=Uv(bh.exports),Fv=Uv(Ov),Bv=Uv(Pv),qv=Uv(Av),zv=Uv(jv),Wv=Uv(Mv),Gv=Uv(Lv),Vv=Uv(Nv),$v=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 $v((function(e){for(var n=!1,r=[],i=0,a=t;i<a.length;i++){var s=a[i];"string"!=typeof s?(n=n||e instanceof s,r.push("an instance of ".concat(s.name))):(n=n||Dv.default(e)===s,r.push("of type ".concat(s)))}return[n,r]}))};function Kv(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=Vv.default(e);if(t){var i=Vv.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Gv.default(this,n)}}function Hv(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 Yv(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 Yv(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function Yv(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 Qv=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=Hv(t.entries());try{for(r.s();!(n=r.n()).done;){var i=Fv.default(n.value,2),a=i[0],s=i[1],o=ty(e[a],s),u=Fv.default(o,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()}},Xv=function(e){var t,n,r;(["undefined","boolean","number","bigint","string"].includes(Dv.default(e))&&(n="string"==typeof e?'"'.concat(e,'"'):"".concat(e)),"object"===Dv.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=Dv.default(e)),n},Zv=function(e){var t,n=[],r=Hv(e);try{for(r.s();!(t=r.n()).done;){var i=t.value;n.push(ey(i))}}catch(e){r.e(e)}finally{r.f()}return n},ey=function(e){var t,n=[],r=Hv(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},ty=function(e,t){var n,r,i=[],a=!1,s=Hv(e);try{for(s.s();!(r=s.n()).done;){var o,u=Hv(r.value.checks);try{for(u.s();!(o=u.n()).done;){var c=(0,o.value)(t),l=Fv.default(c,3),f=l[0],d=l[1],p=l[2];a=a||f,!n&&p&&(n=p),d&&(i=[].concat(Bv.default(i),"string"==typeof d?[d]:Bv.default(d)))}}catch(e){u.e(e)}finally{u.f()}}}catch(e){s.e(e)}finally{s.f()}if(a)return[!0];var h=n||Xv(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 ny(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 ry(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 ry(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function ry(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 iy=$v((function(e){return["string"==typeof e&&e.length>0,"a non-empty string"]})),ay=$v((function(e){return["number"==typeof e&&Number.isInteger(e)&&e>=0,"a non-negative integer"]})),sy=$v((function(e){return["object"===Dv.default(e)&&null!==e&&!Array.isArray(e),"a pure object (non-null and non-array)"]}));function oy(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 uy(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 uy(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function uy(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 cy=gh.array=function(e,t){return $v((function(n){if(!Array.isArray(n))return[!1,"an array of ".concat(e)];var r,i=oy(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Fv.default(r.value,2),s=a[0],o=a[1],u=ty(ey(t),o),c=Fv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"a valid array of ".concat(e," (index ").concat(s," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(s," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},ly=gh.custom=$v,fy=gh.literal=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return $v((function(e){for(var n=!1,r=[],i=0,a=t;i<a.length;i++){var s=a[i];n=n||e===s,r.push("string"==typeof s?'"'.concat(s,'"'):"".concat(s))}return[n,r]}))},dy=gh.nonEmptyArray=function(e,t){return $v((function(n){if(!Array.isArray(n)||n.length<1)return[!1,"a non-empty array of ".concat(e)];var r,i=ny(n.entries());try{for(i.s();!(r=i.n()).done;){var a=Fv.default(r.value,2),s=a[0],o=a[1],u=ty(ey(t),o),c=Fv.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(s," should be ").concat(d,")"),"malformed array of ".concat(e," (index ").concat(s," is ").concat(f,")")]}}catch(e){i.e(e)}finally{i.f()}return[!0]}))},py=gh.nonEmptyString=iy,hy=gh.nonNegativeInteger=ay,vy=gh.objectSchema=function(e,t){return $v((function(n){if("object"!==Dv.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=Fv.default(i[r],2),s=a[0],o=a[1],u=ty(ey(o),n[s]),c=Fv.default(u,3),l=c[0],f=c[1],d=c[2];if(!l)return[!1,"valid ".concat(e,' (key "').concat(s,'" should be ').concat(d,")"),"malformed ".concat(e,' (key "').concat(s,'" is ').concat(f,")")]}return[!0]}))},yy=gh.pureObject=sy;gh.runtimeTypeValidation=Qv,gh.stringifyReceivedType=Xv,gh.type=Jv;var my=gh.validateConstructorTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Zv(t);return function(e){return function(e){Wv.default(n,e);var t=Kv(n);function n(){zv.default(this,n);for(var e=arguments.length,i=new Array(e),a=0;a<e;a++)i[a]=arguments[a];return Qv(r,i),t.call.apply(t,[this].concat(i))}return qv.default(n)}(e)}},gy=gh.validateTypes=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Zv(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 Qv(r,t),i.apply(this,t)}}},by=gh.validateTypesAsync=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Zv(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{Qv(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 wy(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)||wy(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 _y=ly((function(e){return[["string","number","boolean","object"].includes(Pa(e)),"a JSON type"]})),Sy=ly((function(e){return[["undefined","string","number","boolean","object"].includes(Pa(e)),"an optional JSON type"]})),Ey=vy("send media options",{contentType:[fy(null),"string"],filename:["string","undefined"],media:[fy("null"),"string"].concat(xy("function"==typeof Buffer?[Buffer]:[]),xy("function"==typeof Blob?[Blob]:[]))}),Ty={},Ry={exports:{}},Cy={exports:{}};!function(e){var t=gv.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}(Ry);var Iy={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}(Iy),Object.defineProperty(Ty,"__esModule",{value:!0});var Oy=pv.exports,Py=dv.exports,Ay=mv.exports,jy=Ry.exports,My=hv.exports,Ly=yv.exports,Ny=gv.exports,Uy=Iy.exports;function Dy(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var Fy=Dy(uv.exports),By=Dy(Oy),qy=Dy(Py),zy=Dy(Ay),Wy=Dy(jy),Gy=Dy(My),Vy=Dy(Ly),$y=Dy(Ny),Jy=Dy(Uy);function Ky(){}function Hy(){Hy.init.call(this)}function Yy(e){return void 0===e._maxListeners?Hy.defaultMaxListeners:e._maxListeners}function Qy(e,t,n){if(t)e.call(n);else for(var r=e.length,i=am(e,r),a=0;a<r;++a)i[a].call(n)}function Xy(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=am(e,i),s=0;s<i;++s)a[s].call(n,r)}function Zy(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,s=am(e,a),o=0;o<a;++o)s[o].call(n,r,i)}function em(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var s=e.length,o=am(e,s),u=0;u<s;++u)o[u].call(n,r,i,a)}function tm(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=am(e,i),s=0;s<i;++s)a[s].apply(n,r)}function nm(e,t,n,r){var i,a,s,o;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),s=a[t]):(a=e._events=new Ky,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=Yy(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,o=u,"function"==typeof console.warn?console.warn(o):console.log(o)}}else s=a[t]=n,++e._eventsCount;return e}function rm(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 im(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 am(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function sm(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=$y.default(e);if(t){var i=$y.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Vy.default(this,n)}}Ky.prototype=Object.create(null),Hy.EventEmitter=Hy,Hy.usingDomains=!1,Hy.prototype.domain=void 0,Hy.prototype._events=void 0,Hy.prototype._maxListeners=void 0,Hy.defaultMaxListeners=10,Hy.init=function(){this.domain=null,Hy.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Ky,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Hy.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},Hy.prototype.getMaxListeners=function(){return Yy(this)},Hy.prototype.emit=function(e){var t,n,r,i,a,s,o,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){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=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:Qy(n,l,this);break;case 2:Xy(n,l,this,arguments[1]);break;case 3:Zy(n,l,this,arguments[1],arguments[2]);break;case 4:em(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];tm(n,l,this,i)}return!0},Hy.prototype.addListener=function(e,t){return nm(this,e,t,!1)},Hy.prototype.on=Hy.prototype.addListener,Hy.prototype.prependListener=function(e,t){return nm(this,e,t,!0)},Hy.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,rm(this,e,t)),this},Hy.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,rm(this,e,t)),this},Hy.prototype.removeListener=function(e,t){var n,r,i,a,s;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 Ky:(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){s=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 Ky,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,s||t)}return this},Hy.prototype.off=function(e,t){return this.removeListener(e,t)},Hy.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new Ky,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new Ky: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 Ky,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},Hy.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},Hy.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):im.call(e,t)},Hy.prototype.listenerCount=im,Hy.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var om=function(e){Gy.default(n,e);var t=sm(n);function n(){var e;return By.default(this,n),e=t.call(this),Jy.default(zy.default(e),"eventHistory",new Map),e}return qy.default(n,[{key:"on",value:function(e,t){return Wy.default($y.default(n.prototype),"on",this).call(this,e,t)}},{key:"once",value:function(e,t){return Wy.default($y.default(n.prototype),"once",this).call(this,e,t)}},{key:"off",value:function(e,t){return Wy.default($y.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=Wy.default($y.default(n.prototype),"emit",this)).call.apply(t,[this,e].concat(i))}},{key:"addListener",value:function(e,t){return Wy.default($y.default(n.prototype),"addListener",this).call(this,e,t)}},{key:"removeListener",value:function(e,t){return Wy.default($y.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,Fy.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,Fy.default(r)),this):Wy.default($y.default(n.prototype),"once",this).call(this,e,t)}}]),n}(Hy),um=Ty.ReplayEventEmitter=om,cm={exports:{}};!function(e,t){var r="__lodash_hash_undefined__",i=9007199254740991,a="[object Arguments]",s="[object Array]",o="[object Boolean]",u="[object Date]",c="[object Error]",l="[object Function]",f="[object Map]",d="[object Number]",p="[object Object]",h="[object Promise]",v="[object RegExp]",y="[object Set]",m="[object String]",g="[object Symbol]",b="[object WeakMap]",k="[object ArrayBuffer]",w="[object DataView]",x=/^\[object .+?Constructor\]$/,_=/^(?:0|[1-9]\d*)$/,S={};S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S[a]=S[s]=S[k]=S[o]=S[w]=S[u]=S[c]=S[l]=S[f]=S[d]=S[p]=S[v]=S[y]=S[m]=S[b]=!1;var E="object"==Pa(n)&&n&&n.Object===Object&&n,T="object"==("undefined"==typeof self?"undefined":Pa(self))&&self&&self.Object===Object&&self,R=E||T||Function("return this")(),C=t&&!t.nodeType&&t,I=C&&e&&!e.nodeType&&e,O=I&&I.exports===C,P=O&&E.process,A=function(){try{return P&&P.binding&&P.binding("util")}catch(e){}}(),j=A&&A.isTypedArray;function M(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function L(e,t){return e.has(t)}function N(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function U(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var D,F,B=Array.prototype,q=Function.prototype,z=Object.prototype,W=R["__core-js_shared__"],G=q.toString,V=z.hasOwnProperty,$=function(){var e=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),J=z.toString,K=RegExp("^"+G.call(V).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),H=O?R.Buffer:void 0,Y=R.Symbol,Q=R.Uint8Array,X=z.propertyIsEnumerable,Z=B.splice,ee=Y?Y.toStringTag:void 0,te=Object.getOwnPropertySymbols,ne=H?H.isBuffer:void 0,re=(D=Object.keys,F=Object,function(e){return D(F(e))}),ie=Ae(R,"DataView"),ae=Ae(R,"Map"),se=Ae(R,"Promise"),oe=Ae(R,"Set"),ue=Ae(R,"WeakMap"),ce=Ae(Object,"create"),le=Ne(ie),fe=Ne(ae),de=Ne(se),pe=Ne(oe),he=Ne(ue),ve=Y?Y.prototype:void 0,ye=ve?ve.valueOf:void 0;function me(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 ge(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 be(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 ke(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new be;++t<n;)this.add(e[t])}function we(e){var t=this.__data__=new ge(e);this.size=t.size}function xe(e,t){var n=Fe(e),r=!n&&De(e),i=!n&&!r&&Be(e),a=!n&&!r&&!i&&Ve(e),s=n||r||i||a,o=s?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],u=o.length;for(var c in e)!t&&!V.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||a&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Le(c,u))||o.push(c);return o}function _e(e,t){for(var n=e.length;n--;)if(Ue(e[n][0],t))return n;return-1}function Se(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ee&&ee in Object(e)?function(e){var t=V.call(e,ee),n=e[ee];try{e[ee]=void 0;var r=!0}catch(e){}var i=J.call(e);r&&(t?e[ee]=n:delete e[ee]);return i}(e):function(e){return J.call(e)}(e)}function Ee(e){return Ge(e)&&Se(e)==a}function Te(e,t,n,r,i){return e===t||(null==e||null==t||!Ge(e)&&!Ge(t)?e!=e&&t!=t:function(e,t,n,r,i,l){var h=Fe(e),b=Fe(t),x=h?s:Me(e),_=b?s:Me(t),S=(x=x==a?p:x)==p,E=(_=_==a?p:_)==p,T=x==_;if(T&&Be(e)){if(!Be(t))return!1;h=!0,S=!1}if(T&&!S)return l||(l=new we),h||Ve(e)?Ie(e,t,n,r,i,l):function(e,t,n,r,i,a,s){switch(n){case w:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case k:return!(e.byteLength!=t.byteLength||!a(new Q(e),new Q(t)));case o:case u:case d:return Ue(+e,+t);case c:return e.name==t.name&&e.message==t.message;case v:case m:return e==t+"";case f:var l=N;case y:var p=1&r;if(l||(l=U),e.size!=t.size&&!p)return!1;var h=s.get(e);if(h)return h==t;r|=2,s.set(e,t);var b=Ie(l(e),l(t),r,i,a,s);return s.delete(e),b;case g:if(ye)return ye.call(e)==ye.call(t)}return!1}(e,t,x,n,r,i,l);if(!(1&n)){var R=S&&V.call(e,"__wrapped__"),C=E&&V.call(t,"__wrapped__");if(R||C){var I=R?e.value():e,O=C?t.value():t;return l||(l=new we),i(I,O,n,r,l)}}if(!T)return!1;return l||(l=new we),function(e,t,n,r,i,a){var s=1&n,o=Oe(e),u=o.length,c=Oe(t).length;if(u!=c&&!s)return!1;var l=u;for(;l--;){var f=o[l];if(!(s?f in t:V.call(t,f)))return!1}var d=a.get(e);if(d&&a.get(t))return d==t;var p=!0;a.set(e,t),a.set(t,e);var h=s;for(;++l<u;){var v=e[f=o[l]],y=t[f];if(r)var m=s?r(y,v,f,t,e,a):r(v,y,f,e,t,a);if(!(void 0===m?v===y||i(v,y,n,r,a):m)){p=!1;break}h||(h="constructor"==f)}if(p&&!h){var g=e.constructor,b=t.constructor;g==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(p=!1)}return a.delete(e),a.delete(t),p}(e,t,n,r,i,l)}(e,t,n,r,Te,i))}function Re(e){return!(!We(e)||function(e){return!!$&&$ in e}(e))&&(qe(e)?K:x).test(Ne(e))}function Ce(e){if(n=(t=e)&&t.constructor,r="function"==typeof n&&n.prototype||z,t!==r)return re(e);var t,n,r,i=[];for(var a in Object(e))V.call(e,a)&&"constructor"!=a&&i.push(a);return i}function Ie(e,t,n,r,i,a){var s=1&n,o=e.length,u=t.length;if(o!=u&&!(s&&u>o))return!1;var c=a.get(e);if(c&&a.get(t))return c==t;var l=-1,f=!0,d=2&n?new ke:void 0;for(a.set(e,t),a.set(t,e);++l<o;){var p=e[l],h=t[l];if(r)var v=s?r(h,p,l,t,e,a):r(p,h,l,e,t,a);if(void 0!==v){if(v)continue;f=!1;break}if(d){if(!M(t,(function(e,t){if(!L(d,t)&&(p===e||i(p,e,n,r,a)))return d.push(t)}))){f=!1;break}}else if(p!==h&&!i(p,h,n,r,a)){f=!1;break}}return a.delete(e),a.delete(t),f}function Oe(e){return function(e,t,n){var r=t(e);return Fe(e)?r:function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}(r,n(e))}(e,$e,je)}function Pe(e,t){var n=e.__data__;return function(e){var t=Pa(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function Ae(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Re(n)?n:void 0}me.prototype.clear=function(){this.__data__=ce?ce(null):{},this.size=0},me.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},me.prototype.get=function(e){var t=this.__data__;if(ce){var n=t[e];return n===r?void 0:n}return V.call(t,e)?t[e]:void 0},me.prototype.has=function(e){var t=this.__data__;return ce?void 0!==t[e]:V.call(t,e)},me.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ce&&void 0===t?r:t,this},ge.prototype.clear=function(){this.__data__=[],this.size=0},ge.prototype.delete=function(e){var t=this.__data__,n=_e(t,e);return!(n<0)&&(n==t.length-1?t.pop():Z.call(t,n,1),--this.size,!0)},ge.prototype.get=function(e){var t=this.__data__,n=_e(t,e);return n<0?void 0:t[n][1]},ge.prototype.has=function(e){return _e(this.__data__,e)>-1},ge.prototype.set=function(e,t){var n=this.__data__,r=_e(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},be.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(ae||ge),string:new me}},be.prototype.delete=function(e){var t=Pe(this,e).delete(e);return this.size-=t?1:0,t},be.prototype.get=function(e){return Pe(this,e).get(e)},be.prototype.has=function(e){return Pe(this,e).has(e)},be.prototype.set=function(e,t){var n=Pe(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},ke.prototype.add=ke.prototype.push=function(e){return this.__data__.set(e,r),this},ke.prototype.has=function(e){return this.__data__.has(e)},we.prototype.clear=function(){this.__data__=new ge,this.size=0},we.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},we.prototype.get=function(e){return this.__data__.get(e)},we.prototype.has=function(e){return this.__data__.has(e)},we.prototype.set=function(e,t){var n=this.__data__;if(n instanceof ge){var r=n.__data__;if(!ae||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new be(r)}return n.set(e,t),this.size=n.size,this};var je=te?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,a=[];++n<r;){var s=e[n];t(s,n,e)&&(a[i++]=s)}return a}(te(e),(function(t){return X.call(e,t)})))}:function(){return[]},Me=Se;function Le(e,t){return!!(t=null==t?i:t)&&("number"==typeof e||_.test(e))&&e>-1&&e%1==0&&e<t}function Ne(e){if(null!=e){try{return G.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ue(e,t){return e===t||e!=e&&t!=t}(ie&&Me(new ie(new ArrayBuffer(1)))!=w||ae&&Me(new ae)!=f||se&&Me(se.resolve())!=h||oe&&Me(new oe)!=y||ue&&Me(new ue)!=b)&&(Me=function(e){var t=Se(e),n=t==p?e.constructor:void 0,r=n?Ne(n):"";if(r)switch(r){case le:return w;case fe:return f;case de:return h;case pe:return y;case he:return b}return t});var De=Ee(function(){return arguments}())?Ee:function(e){return Ge(e)&&V.call(e,"callee")&&!X.call(e,"callee")},Fe=Array.isArray;var Be=ne||function(){return!1};function qe(e){if(!We(e))return!1;var t=Se(e);return t==l||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=i}function We(e){var t=Pa(e);return null!=e&&("object"==t||"function"==t)}function Ge(e){return null!=e&&"object"==Pa(e)}var Ve=j?function(e){return function(t){return e(t)}}(j):function(e){return Ge(e)&&ze(e.length)&&!!S[Se(e)]};function $e(e){return null!=(t=e)&&ze(t.length)&&!qe(t)?xe(e):Ce(e);var t}e.exports=function(e,t){return Te(e,t)}}(cm,cm.exports);var lm=cm.exports;function fm(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 dm=If.scope("User"),User=function(e){Oa(User,e);var t,n,r,i,a,s,o,u=fm(User);function User(e,t,n,r){var i;return Ua(this,User),Ma(Ca(i=u.call(this)),"promiseToFetch",null),Ma(Ca(i),"updated","updated"),Ma(Ca(i),"userSubscribed","userSubscribed"),Ma(Ca(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 Na(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:(o=Ra(Gc.mark((function e(t,n){var r,i;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._initializationPromise;case 2:r=[],dm.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),dm),lm(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 o.apply(this,arguments)})},{key:"_updateReachabilityInfo",value:(s=Ra(Gc.mark((function e(t,n){var r=this;return Gc.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){dm.warn("Failed to get reachability info for ",r.state.identity,e)})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_fetch",value:(a=Ra(Gc.mark((function e(){var t=this;return Gc.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 dm.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 dm.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 dm.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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(){return Gc.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}(um);function pm(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=[],s=!0,o=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){o=!0,i=e}finally{try{s||null==n.return||n.return()}finally{if(o)throw i}}return a}}(e,t)||wy(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([by(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],User.prototype,"updateAttributes",null),$c([by(["string"]),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],User.prototype,"updateFriendlyName",null);var hm={exports:{}},vm=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),ym=Cn,mm=ut,gm=E,bm=te,km=Ue.f,wm=At,xm=Tr,_m=vm,Sm=!1,Em=ie("meta"),Tm=0,Rm=Object.isExtensible||function(){return!0},Cm=function(e){km(e,Em,{value:{objectID:"O"+Tm++,weakData:{}}})},Im=hm.exports={enable:function(){Im.enable=function(){},Sm=!0;var e=wm.f,t=[].splice,n={};n[Em]=1,e(n).length&&(wm.f=function(n){for(var r=e(n),i=0,a=r.length;i<a;i++)if(r[i]===Em){t.call(r,i,1);break}return r},ym({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:xm.f}))},fastKey:function(e,t){if(!gm(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!bm(e,Em)){if(!Rm(e))return"F";if(!t)return"E";Cm(e)}return e[Em].objectID},getWeakData:function(e,t){if(!bm(e,Em)){if(!Rm(e))return!0;if(!t)return!1;Cm(e)}return e[Em].weakData},onFreeze:function(e){return _m&&Sm&&Rm(e)&&!bm(e,Em)&&Cm(e),e}};mm[Em]=!0;var Om=Cn,Pm=a,Am=kn,jm=Ke.exports,Mm=hm.exports,Lm=Js,Nm=Ss,Um=E,Dm=o,Fm=no,Bm=An,qm=xd,zm=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),a=r?"set":"add",s=Pm[e],o=s&&s.prototype,u=s,c={},l=function(e){var t=o[e];jm(o,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(i&&!Um(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return i&&!Um(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(i&&!Um(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(Am(e,"function"!=typeof s||!(i||o.forEach&&!Dm((function(){(new s).entries().next()})))))u=n.getConstructor(t,e,r,a),Mm.enable();else if(Am(e,!0)){var f=new u,d=f[a](i?{}:-0,1)!=f,p=Dm((function(){f.has(1)})),h=Fm((function(e){new s(e)})),v=!i&&Dm((function(){for(var e=new s,t=5;t--;)e[a](t,t);return!e.has(-0)}));h||((u=t((function(t,n){Nm(t,u,e);var i=qm(new s,t,u);return null!=n&&Lm(n,i[a],{that:i,AS_ENTRIES:r}),i}))).prototype=o,o.constructor=u),(p||v)&&(l("delete"),l("has"),r&&l("get")),(v||d)&&l(a),i&&o.clear&&delete o.clear}return c[e]=u,Om({global:!0,forced:u!=s},c),Bm(u,e),i||n.setStrong(u,e,r),u},Wm=Ue.f,Gm=nr,Vm=hs,$m=Fr,Jm=Ss,Km=Js,Hm=pf,Ym=_s,Qm=u,Xm=hm.exports.fastKey,Zm=_t.set,eg=_t.getterFor,tg={getConstructor:function(e,t,n,r){var i=e((function(e,a){Jm(e,i,t),Zm(e,{type:t,index:Gm(null),first:void 0,last:void 0,size:0}),Qm||(e.size=0),null!=a&&Km(a,e[r],{that:e,AS_ENTRIES:n})})),a=eg(t),s=function(e,t,n){var r,i,s=a(e),u=o(e,t);return u?u.value=n:(s.last=u={index:i=Xm(t,!0),key:t,value:n,previous:r=s.last,next:void 0,removed:!1},s.first||(s.first=u),r&&(r.next=u),Qm?s.size++:e.size++,"F"!==i&&(s.index[i]=u)),e},o=function(e,t){var n,r=a(e),i=Xm(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return Vm(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,Qm?e.size=0:this.size=0},delete:function(e){var t=this,n=a(t),r=o(t,e);if(r){var i=r.next,s=r.previous;delete n.index[r.index],r.removed=!0,s&&(s.next=i),i&&(i.previous=s),n.first==r&&(n.first=i),n.last==r&&(n.last=s),Qm?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=a(this),r=$m(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!!o(this,e)}}),Vm(i.prototype,n?{get:function(e){var t=o(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),Qm&&Wm(i.prototype,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=eg(t),a=eg(r);Hm(e,t,(function(e,t){Zm(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),Ym(t)}};zm("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),tg);var ng={};Object.defineProperty(ng,"__esModule",{value:!0});var rg=dv.exports,ig=mv.exports,ag=hv.exports,sg=yv.exports,og=gv.exports,ug=Iy.exports;function cg(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}var lg=cg(pv.exports),fg=cg(rg),dg=cg(ig),pg=cg(ag),hg=cg(sg),vg=cg(og),yg=cg(ug);function mg(){}function gg(){gg.init.call(this)}function bg(e){return void 0===e._maxListeners?gg.defaultMaxListeners:e._maxListeners}function kg(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Cg(e,r),a=0;a<r;++a)i[a].call(n)}function wg(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=Cg(e,i),s=0;s<i;++s)a[s].call(n,r)}function xg(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,s=Cg(e,a),o=0;o<a;++o)s[o].call(n,r,i)}function _g(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var s=e.length,o=Cg(e,s),u=0;u<s;++u)o[u].call(n,r,i,a)}function Sg(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=Cg(e,i),s=0;s<i;++s)a[s].apply(n,r)}function Eg(e,t,n,r){var i,a,s,o;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),s=a[t]):(a=e._events=new mg,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=bg(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,o=u,"function"==typeof console.warn?console.warn(o):console.log(o)}}else s=a[t]=n,++e._eventsCount;return e}function Tg(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 Rg(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 Cg(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}function Ig(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=vg.default(e);if(t){var i=vg.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return hg.default(this,n)}}mg.prototype=Object.create(null),gg.EventEmitter=gg,gg.usingDomains=!1,gg.prototype.domain=void 0,gg.prototype._events=void 0,gg.prototype._maxListeners=void 0,gg.defaultMaxListeners=10,gg.init=function(){this.domain=null,gg.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new mg,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},gg.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},gg.prototype.getMaxListeners=function(){return bg(this)},gg.prototype.emit=function(e){var t,n,r,i,a,s,o,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){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=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:kg(n,l,this);break;case 2:wg(n,l,this,arguments[1]);break;case 3:xg(n,l,this,arguments[1],arguments[2]);break;case 4:_g(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];Sg(n,l,this,i)}return!0},gg.prototype.addListener=function(e,t){return Eg(this,e,t,!1)},gg.prototype.on=gg.prototype.addListener,gg.prototype.prependListener=function(e,t){return Eg(this,e,t,!0)},gg.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Tg(this,e,t)),this},gg.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Tg(this,e,t)),this},gg.prototype.removeListener=function(e,t){var n,r,i,a,s;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 mg:(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){s=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 mg,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,s||t)}return this},gg.prototype.off=function(e,t){return this.removeListener(e,t)},gg.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new mg,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new mg: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 mg,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},gg.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},gg.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Rg.call(e,t)},gg.prototype.listenerCount=Rg,gg.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Og=function(e){pg.default(n,e);var t=Ig(n);function n(e){var r;return lg.default(this,n),r=t.call(this),yg.default(dg.default(r),"timeout",null),yg.default(dg.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 fg.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}(gg),Pg=function(e){pg.default(n,e);var t=Ig(n);function n(e){var r;return lg.default(this,n),r=t.call(this),yg.default(dg.default(r),"resolve",(function(){})),yg.default(dg.default(r),"reject",(function(){})),r.retrier=new Og(e),r}return fg.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}(gg);function Ag(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=vg.default(e);if(t){var i=vg.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return hg.default(this,n)}}function jg(e){return null!=e}var Mg=function(e){pg.default(n,e);var t=Ag(n);function n(e){var r;lg.default(this,n),r=t.call(this),yg.default(dg.default(r),"backoffDelay",0),yg.default(dg.default(r),"nextBackoffDelay",0),yg.default(dg.default(r),"backoffNumber",0),yg.default(dg.default(r),"timeoutID",null),yg.default(dg.default(r),"maxNumberOfRetry",-1);var i=e=e||{},a=i.initialDelay,s=i.maxDelay,o=i.randomisationFactor,u=i.factor;if(jg(a)&&a<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(jg(s)&&s<=1)throw new Error("The maximal timeout must be greater than 1.");if(jg(o)&&(o<0||o>1))throw new Error("The randomisation factor must be between 0 and 1.");if(jg(u)&&u<=1)throw new Error("Exponential factor should be greater than 1.");if(r.initialDelay=a||100,r.maxDelay=s||1e4,r.maxDelay<=r.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return r.randomisationFactor=o||0,r.factor=u||2,r.reset(),r}return fg.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}(gg),Lg=ng.AsyncRetrier=Pg;ng.Backoff=Mg;var Ng=ng.Retrier=Og;function Ug(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 Dg(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 Dg(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function Dg(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 Fg=function(){function e(t,n){Ua(this,e),this.configuration=t,this.services=n,this.cache=new Map,this.cacheLifetime=100*this.configuration.httpCacheInterval,this.cleanupCache()}return Na(e,[{key:"isExpired",value:function(e){return!this.cacheLifetime||Date.now()-e>this.cacheLifetime}},{key:"cleanupCache",value:function(){var e,t=Ug(this.cache);try{for(t.s();!(e=t.n()).done;){var n=pm(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 s=new Ng(t.configuration.backoffConfiguration);s.on("attempt",(function(){e().then((function(e){return s.succeeded(e)})).catch((function(e){a.indexOf(e.status)>-1||"Twilsock disconnected"===e.message?s.failed(e):(s.removeAllListeners(),s.cancel(),i(e))}))})),s.on("succeeded",(function(e){r(e)})),s.on("cancelled",(function(e){return i(e)})),s.on("failed",(function(e){return i(e)})),s.start()}))}},{key:"get",value:function(){var e=Ra(Gc.mark((function e(t){var n,r,i,a=this;return Gc.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}(),Bg=Na((function e(){Ua(this,e)}));Ma(Bg,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),Ma(Bg,"NEW_MESSAGE","twilio.conversations.new_message"),Ma(Bg,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),Ma(Bg,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),Ma(Bg,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");var qg={},zg={exports:{}};!function(e){function t(e,t,n,r,i,a,s){try{var o=e[a](s),u=o.value}catch(e){return void n(e)}o.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 s=e.apply(n,r);function o(e){t(s,i,a,o,u,"next",e)}function u(e){t(s,i,a,o,u,"throw",e)}o(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports}(zg);var Wg=r(Vc),Gg=Ke.exports,Vg=Fe,$g=Er,Jg=o,Kg=tp,Hg="toString",Yg=RegExp.prototype,Qg=Yg.toString,Xg=Jg((function(){return"/a/b"!=Qg.call({source:"a",flags:"b"})})),Zg=Qg.name!=Hg;(Xg||Zg)&&Gg(RegExp.prototype,Hg,(function(){var e=Vg(this),t=$g(e.source),n=e.flags;return"/"+t+"/"+$g(void 0===n&&e instanceof RegExp&&!("flags"in Yg)?Kg.call(e):n)}),{unsafe:!0}),zm("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),tg);var eb={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,s=t.plugins;for(n=0,i=s.length;n<i;n++)(a=s[n]).methods&&r(e,a.methods),a.properties&&Object.defineProperties(e,a.properties)},hook:function(e,t,n){var r,i,a,s,o=e.config.plugins,u=[e.context];for(n&&(u=u.concat(n)),r=0,i=o.length;r<i;r++)s=o[r],(a=o[r][t])&&a.apply(s,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,s=this.defaults.wildcard;for(n=0;n<e.length;n++)for(r=e[n],i=Array.isArray(r.from)?r.from:[r.from||s],a=r.to||s,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),s=[null,[]];function o(e,t){this.context=e,this.config=t,this.state=t.init.from,this.observers=[e]}r(o.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):s,a?this.observersForEvent(i.onLeave[t]):s,this.observersForEvent(i.on.transition),a?["doTransit",[this]]:s,a?this.observersForEvent(i.onEnter.state):s,a?this.observersForEvent(i.onEnter[n]):s,a?this.observersForEvent(i.on[n]):s,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],s=e[0][1],o=e[0][2];if(t[0].event=i,i&&o&&i!==n&&a.hook(this,"lifecycle",t),0===s.length)return e.shift(),this.observeEvents(e,t,i,r);var u=s.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=o},function(e,t,n){var r=n(0),i=n(2),a=n(1),s=n(3),o=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 s(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 o(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 s(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()}(eb);var tb={exports:{}},nb="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(nb){var rb=new Uint8Array(16);tb.exports=function(){return nb(rb),rb}}else{var ib=new Array(16);tb.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),ib[t]=e>>>((3&t)<<3)&255;return ib}}for(var ab=[],sb=0;sb<256;++sb)ab[sb]=(sb+256).toString(16).substr(1);var ob,ub,cb=function(e,t){var n=t||0,r=ab;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("")},lb=tb.exports,fb=cb,db=0,pb=0;var hb=function(e,t,n){var r=t&&n||0,i=t||[],a=(e=e||{}).node||ob,s=void 0!==e.clockseq?e.clockseq:ub;if(null==a||null==s){var o=lb();null==a&&(a=ob=[1|o[0],o[1],o[2],o[3],o[4],o[5]]),null==s&&(s=ub=16383&(o[6]<<8|o[7]))}var u=void 0!==e.msecs?e.msecs:(new Date).getTime(),c=void 0!==e.nsecs?e.nsecs:pb+1,l=u-db+(c-pb)/1e4;if(l<0&&void 0===e.clockseq&&(s=s+1&16383),(l<0||u>db)&&void 0===e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");db=u,pb=c,ub=s;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++]=s>>>8|128,i[r++]=255&s;for(var p=0;p<6;++p)i[r+p]=a[p];return t||fb(i)},vb=tb.exports,yb=cb;var mb=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||vb)();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||yb(i)},gb=hb,bb=mb,kb=bb;kb.v1=gb,kb.v4=bb;var wb,xb,_b,Sb=kb,Eb={exports:{}},Tb="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Rb=Tb,Cb=u,Ib=a,Ob=E,Pb=te,Ab=Va,jb=Je,Mb=Ke.exports,Lb=Ue.f,Nb=Nl,Ub=gs,Db=he,Fb=ie,Bb=Ib.Int8Array,qb=Bb&&Bb.prototype,zb=Ib.Uint8ClampedArray,Wb=zb&&zb.prototype,Gb=Bb&&Nb(Bb),Vb=qb&&Nb(qb),$b=Object.prototype,Jb=$b.isPrototypeOf,Kb=Db("toStringTag"),Hb=Fb("TYPED_ARRAY_TAG"),Yb=Fb("TYPED_ARRAY_CONSTRUCTOR"),Qb=Rb&&!!Ub&&"Opera"!==Ab(Ib.opera),Xb=!1,Zb={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},ek={BigInt64Array:8,BigUint64Array:8},tk=function(e){if(!Ob(e))return!1;var t=Ab(e);return Pb(Zb,t)||Pb(ek,t)};for(wb in Zb)(_b=(xb=Ib[wb])&&xb.prototype)?jb(_b,Yb,xb):Qb=!1;for(wb in ek)(_b=(xb=Ib[wb])&&xb.prototype)&&jb(_b,Yb,xb);if((!Qb||"function"!=typeof Gb||Gb===Function.prototype)&&(Gb=function(){throw TypeError("Incorrect invocation")},Qb))for(wb in Zb)Ib[wb]&&Ub(Ib[wb],Gb);if((!Qb||!Vb||Vb===$b)&&(Vb=Gb.prototype,Qb))for(wb in Zb)Ib[wb]&&Ub(Ib[wb].prototype,Vb);if(Qb&&Nb(Wb)!==Vb&&Ub(Wb,Vb),Cb&&!Pb(Vb,Kb))for(wb in Xb=!0,Lb(Vb,Kb,{get:function(){return Ob(this)?this[Hb]:void 0}}),Zb)Ib[wb]&&jb(Ib[wb],Hb,wb);var nk={NATIVE_ARRAY_BUFFER_VIEWS:Qb,TYPED_ARRAY_CONSTRUCTOR:Yb,TYPED_ARRAY_TAG:Xb&&Hb,aTypedArray:function(e){if(tk(e))return e;throw TypeError("Target is not a typed array")},aTypedArrayConstructor:function(e){if(Ub&&!Jb.call(Gb,e))throw TypeError("Target is not a typed array constructor");return e},exportTypedArrayMethod:function(e,t,n){if(Cb){if(n)for(var r in Zb){var i=Ib[r];if(i&&Pb(i.prototype,e))try{delete i.prototype[e]}catch(e){}}Vb[e]&&!n||Mb(Vb,e,n?t:Qb&&qb[e]||t)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(Cb){if(Ub){if(n)for(r in Zb)if((i=Ib[r])&&Pb(i,e))try{delete i[e]}catch(e){}if(Gb[e]&&!n)return;try{return Mb(Gb,e,n?t:Qb&&Gb[e]||t)}catch(e){}}for(r in Zb)!(i=Ib[r])||i[e]&&!n||Mb(i,e,t)}},isView:function(e){if(!Ob(e))return!1;var t=Ab(e);return"DataView"===t||Pb(Zb,t)||Pb(ek,t)},isTypedArray:tk,TypedArray:Gb,TypedArrayPrototype:Vb},rk=a,ik=o,ak=no,sk=nk.NATIVE_ARRAY_BUFFER_VIEWS,ok=rk.ArrayBuffer,uk=rk.Int8Array,ck=!sk||!ik((function(){uk(1)}))||!ik((function(){new uk(-1)}))||!ak((function(e){new uk,new uk(null),new uk(1.5),new uk(e)}),!0)||ik((function(){return 1!==new uk(new ok(2),1,void 0).length})),lk=Lt,fk=Dt,dk=function(e){if(void 0===e)return 0;var t=lk(e),n=fk(t);if(t!==n)throw RangeError("Wrong length or index");return n},pk=Math.abs,hk=Math.pow,vk=Math.floor,yk=Math.log,mk=Math.LN2,gk=X,bk=zt,kk=Dt,wk=function(e){for(var t=gk(this),n=kk(t.length),r=arguments.length,i=bk(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,s=void 0===a?n:bk(a,n);s>i;)t[i++]=e;return t},xk=a,_k=u,Sk=Tb,Ek=Je,Tk=hs,Rk=o,Ck=Ss,Ik=Lt,Ok=Dt,Pk=dk,Ak={pack:function(e,t,n){var r,i,a,s=new Array(n),o=8*n-t-1,u=(1<<o)-1,c=u>>1,l=23===t?hk(2,-24)-hk(2,-77):0,f=e<0||0===e&&1/e<0?1:0,d=0;for((e=pk(e))!=e||e===1/0?(i=e!=e?1:0,r=u):(r=vk(yk(e)/mk),e*(a=hk(2,-r))<1&&(r--,a*=2),(e+=r+c>=1?l/a:l*hk(2,1-c))*a>=2&&(r++,a/=2),r+c>=u?(i=0,r=u):r+c>=1?(i=(e*a-1)*hk(2,t),r+=c):(i=e*hk(2,c-1)*hk(2,t),r=0));t>=8;s[d++]=255&i,i/=256,t-=8);for(r=r<<t|i,o+=t;o>0;s[d++]=255&r,r/=256,o-=8);return s[--d]|=128*f,s},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,a=(1<<i)-1,s=a>>1,o=i-7,u=r-1,c=e[u--],l=127&c;for(c>>=7;o>0;l=256*l+e[u],u--,o-=8);for(n=l&(1<<-o)-1,l>>=-o,o+=t;o>0;n=256*n+e[u],u--,o-=8);if(0===l)l=1-s;else{if(l===a)return n?NaN:c?-1/0:1/0;n+=hk(2,t),l-=s}return(c?-1:1)*n*hk(2,l-t)}},jk=Nl,Mk=gs,Lk=At.f,Nk=Ue.f,Uk=wk,Dk=An,Fk=_t.get,Bk=_t.set,qk="ArrayBuffer",zk="DataView",Wk="Wrong index",Gk=xk.ArrayBuffer,Vk=Gk,$k=xk.DataView,Jk=$k&&$k.prototype,Kk=Object.prototype,Hk=xk.RangeError,Yk=Ak.pack,Qk=Ak.unpack,Xk=function(e){return[255&e]},Zk=function(e){return[255&e,e>>8&255]},ew=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},tw=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},nw=function(e){return Yk(e,23,4)},rw=function(e){return Yk(e,52,8)},iw=function(e,t){Nk(e.prototype,t,{get:function(){return Fk(this)[t]}})},aw=function(e,t,n,r){var i=Pk(n),a=Fk(e);if(i+t>a.byteLength)throw Hk(Wk);var s=Fk(a.buffer).bytes,o=i+a.byteOffset,u=s.slice(o,o+t);return r?u:u.reverse()},sw=function(e,t,n,r,i,a){var s=Pk(n),o=Fk(e);if(s+t>o.byteLength)throw Hk(Wk);for(var u=Fk(o.buffer).bytes,c=s+o.byteOffset,l=r(+i),f=0;f<t;f++)u[c+f]=l[a?f:t-f-1]};if(Sk){if(!Rk((function(){Gk(1)}))||!Rk((function(){new Gk(-1)}))||Rk((function(){return new Gk,new Gk(1.5),new Gk(NaN),Gk.name!=qk}))){for(var ow,uw=(Vk=function(e){return Ck(this,Vk),new Gk(Pk(e))}).prototype=Gk.prototype,cw=Lk(Gk),lw=0;cw.length>lw;)(ow=cw[lw++])in Vk||Ek(Vk,ow,Gk[ow]);uw.constructor=Vk}Mk&&jk(Jk)!==Kk&&Mk(Jk,Kk);var fw=new $k(new Vk(2)),dw=Jk.setInt8;fw.setInt8(0,2147483648),fw.setInt8(1,2147483649),!fw.getInt8(0)&&fw.getInt8(1)||Tk(Jk,{setInt8:function(e,t){dw.call(this,e,t<<24>>24)},setUint8:function(e,t){dw.call(this,e,t<<24>>24)}},{unsafe:!0})}else Vk=function(e){Ck(this,Vk,qk);var t=Pk(e);Bk(this,{bytes:Uk.call(new Array(t),0),byteLength:t}),_k||(this.byteLength=t)},$k=function(e,t,n){Ck(this,$k,zk),Ck(e,Vk,zk);var r=Fk(e).byteLength,i=Ik(t);if(i<0||i>r)throw Hk("Wrong offset");if(i+(n=void 0===n?r-i:Ok(n))>r)throw Hk("Wrong length");Bk(this,{buffer:e,byteLength:n,byteOffset:i}),_k||(this.buffer=e,this.byteLength=n,this.byteOffset=i)},_k&&(iw(Vk,"byteLength"),iw($k,"buffer"),iw($k,"byteLength"),iw($k,"byteOffset")),Tk($k.prototype,{getInt8:function(e){return aw(this,1,e)[0]<<24>>24},getUint8:function(e){return aw(this,1,e)[0]},getInt16:function(e){var t=aw(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=aw(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return tw(aw(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return tw(aw(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return Qk(aw(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return Qk(aw(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){sw(this,1,e,Xk,t)},setUint8:function(e,t){sw(this,1,e,Xk,t)},setInt16:function(e,t){sw(this,2,e,Zk,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){sw(this,2,e,Zk,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){sw(this,4,e,ew,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){sw(this,4,e,ew,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){sw(this,4,e,nw,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){sw(this,8,e,rw,t,arguments.length>2?arguments[2]:void 0)}});Dk(Vk,qk),Dk($k,zk);var pw={ArrayBuffer:Vk,DataView:$k},hw=Lt,vw=function(e){var t=hw(e);if(t<0)throw RangeError("The argument can't be less than 0");return t},yw=function(e,t){var n=vw(e);if(n%t)throw RangeError("Wrong offset");return n},mw=X,gw=Dt,bw=Ns,kw=js,ww=Is,xw=Fr,_w=nk.aTypedArrayConstructor,Sw=Cn,Ew=a,Tw=u,Rw=ck,Cw=nk,Iw=pw,Ow=Ss,Pw=v,Aw=Je,jw=_v,Mw=Dt,Lw=dk,Nw=yw,Uw=xe,Dw=te,Fw=Va,Bw=E,qw=z,zw=nr,Ww=gs,Gw=At.f,Vw=function(e){var t,n,r,i,a,s,o=mw(e),u=arguments.length,c=u>1?arguments[1]:void 0,l=void 0!==c,f=kw(o);if(null!=f&&!ww(f))for(s=(a=bw(o,f)).next,o=[];!(i=s.call(a)).done;)o.push(i.value);for(l&&u>2&&(c=xw(c,arguments[2],2)),n=gw(o.length),r=new(_w(this))(n),t=0;n>t;t++)r[t]=l?c(o[t],t):o[t];return r},$w=Xr.forEach,Jw=_s,Kw=Ue,Hw=s,Yw=xd,Qw=_t.get,Xw=_t.set,Zw=Kw.f,ex=Hw.f,tx=Math.round,nx=Ew.RangeError,rx=Iw.ArrayBuffer,ix=Iw.DataView,ax=Cw.NATIVE_ARRAY_BUFFER_VIEWS,sx=Cw.TYPED_ARRAY_CONSTRUCTOR,ox=Cw.TYPED_ARRAY_TAG,ux=Cw.TypedArray,cx=Cw.TypedArrayPrototype,lx=Cw.aTypedArrayConstructor,fx=Cw.isTypedArray,dx="BYTES_PER_ELEMENT",px="Wrong length",hx=function(e,t){for(var n=0,r=t.length,i=new(lx(e))(r);r>n;)i[n]=t[n++];return i},vx=function(e,t){Zw(e,t,{get:function(){return Qw(this)[t]}})},yx=function(e){var t;return e instanceof rx||"ArrayBuffer"==(t=Fw(e))||"SharedArrayBuffer"==t},mx=function(e,t){return fx(e)&&!qw(t)&&t in e&&jw(+t)&&t>=0},gx=function(e,t){return t=Uw(t),mx(e,t)?Pw(2,e[t]):ex(e,t)},bx=function(e,t,n){return t=Uw(t),!(mx(e,t)&&Bw(n)&&Dw(n,"value"))||Dw(n,"get")||Dw(n,"set")||n.configurable||Dw(n,"writable")&&!n.writable||Dw(n,"enumerable")&&!n.enumerable?Zw(e,t,n):(e[t]=n.value,e)};Tw?(ax||(Hw.f=gx,Kw.f=bx,vx(cx,"buffer"),vx(cx,"byteOffset"),vx(cx,"byteLength"),vx(cx,"length")),Sw({target:"Object",stat:!0,forced:!ax},{getOwnPropertyDescriptor:gx,defineProperty:bx}),Eb.exports=function(e,t,n){var r=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,s="set"+e,o=Ew[i],u=o,c=u&&u.prototype,l={},f=function(e,t){Zw(e,t,{get:function(){return function(e,t){var n=Qw(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=Qw(e);n&&(i=(i=tx(i))<0?0:i>255?255:255&i),a.view[s](t*r+a.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};ax?Rw&&(u=t((function(e,t,n,a){return Ow(e,u,i),Yw(Bw(t)?yx(t)?void 0!==a?new o(t,Nw(n,r),a):void 0!==n?new o(t,Nw(n,r)):new o(t):fx(t)?hx(u,t):Vw.call(u,t):new o(Lw(t)),e,u)})),Ww&&Ww(u,ux),$w(Gw(o),(function(e){e in u||Aw(u,e,o[e])})),u.prototype=c):(u=t((function(e,t,n,a){Ow(e,u,i);var s,o,c,l=0,d=0;if(Bw(t)){if(!yx(t))return fx(t)?hx(u,t):Vw.call(u,t);s=t,d=Nw(n,r);var p=t.byteLength;if(void 0===a){if(p%r)throw nx(px);if((o=p-d)<0)throw nx(px)}else if((o=Mw(a)*r)+d>p)throw nx(px);c=o/r}else c=Lw(t),s=new rx(o=c*r);for(Xw(e,{buffer:s,byteOffset:d,byteLength:o,length:c,view:new ix(s)});l<c;)f(e,l++)})),Ww&&Ww(u,ux),c=u.prototype=zw(cx)),c.constructor!==u&&Aw(c,"constructor",u),Aw(c,sx,u),ox&&Aw(c,ox,i),l[i]=u,Sw({global:!0,forced:u!=o,sham:!ax},l),dx in u||Aw(u,dx,r),dx in c||Aw(c,dx,r),Jw(i)}):Eb.exports=function(){},(0,Eb.exports)("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var kx=Dt,wx=Lt,xx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("at",(function(e){var t=xx(this),n=kx(t.length),r=wx(e),i=r>=0?r:n+r;return i<0||i>=n?void 0:t[i]}));var _x=X,Sx=zt,Ex=Dt,Tx=Math.min,Rx=[].copyWithin||function(e,t){var n=_x(this),r=Ex(n.length),i=Sx(e,r),a=Sx(t,r),s=arguments.length>2?arguments[2]:void 0,o=Tx((void 0===s?r:Sx(s,r))-a,r-i),u=1;for(a<i&&i<a+o&&(u=-1,a+=o-1,i+=o-1);o-- >0;)a in n?n[i]=n[a]:delete n[i],i+=u,a+=u;return n},Cx=Rx,Ix=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("copyWithin",(function(e,t){return Cx.call(Ix(this),e,t,arguments.length>2?arguments[2]:void 0)}));var Ox=Xr.every,Px=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("every",(function(e){return Ox(Px(this),e,arguments.length>1?arguments[1]:void 0)}));var Ax=wk,jx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("fill",(function(e){return Ax.apply(jx(this),arguments)}));var Mx=so,Lx=nk.TYPED_ARRAY_CONSTRUCTOR,Nx=nk.aTypedArrayConstructor,Ux=function(e){return Nx(Mx(e,e[Lx]))},Dx=function(e,t){for(var n=0,r=t.length,i=new e(r);r>n;)i[n]=t[n++];return i},Fx=Ux,Bx=Xr.filter,qx=function(e,t){return Dx(Fx(e),t)},zx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("filter",(function(e){var t=Bx(zx(this),e,arguments.length>1?arguments[1]:void 0);return qx(this,t)}));var Wx=Xr.find,Gx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("find",(function(e){return Wx(Gx(this),e,arguments.length>1?arguments[1]:void 0)}));var Vx=Xr.findIndex,$x=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("findIndex",(function(e){return Vx($x(this),e,arguments.length>1?arguments[1]:void 0)}));var Jx=Xr.forEach,Kx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("forEach",(function(e){Jx(Kx(this),e,arguments.length>1?arguments[1]:void 0)}));var Hx=Jt.includes,Yx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("includes",(function(e){return Hx(Yx(this),e,arguments.length>1?arguments[1]:void 0)}));var Qx=Jt.indexOf,Xx=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("indexOf",(function(e){return Qx(Xx(this),e,arguments.length>1?arguments[1]:void 0)}));var Zx=a,e_=nk,t_=ed,n_=he("iterator"),r_=Zx.Uint8Array,i_=t_.values,a_=t_.keys,s_=t_.entries,o_=e_.aTypedArray,u_=e_.exportTypedArrayMethod,c_=r_&&r_.prototype[n_],l_=!!c_&&("values"==c_.name||null==c_.name),f_=function(){return i_.call(o_(this))};u_("entries",(function(){return s_.call(o_(this))})),u_("keys",(function(){return a_.call(o_(this))})),u_("values",f_,!l_),u_(n_,f_,!l_);var d_=nk.aTypedArray,p_=[].join;(0,nk.exportTypedArrayMethod)("join",(function(e){return p_.apply(d_(this),arguments)}));var h_=S,v_=Lt,y_=Dt,m_=ns,g_=Math.min,b_=[].lastIndexOf,k_=!!b_&&1/[1].lastIndexOf(1,-0)<0,w_=m_("lastIndexOf"),x_=k_||!w_?function(e){if(k_)return b_.apply(this,arguments)||0;var t=h_(this),n=y_(t.length),r=n-1;for(arguments.length>1&&(r=g_(r,v_(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:b_,__=x_,S_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("lastIndexOf",(function(e){return __.apply(S_(this),arguments)}));var E_=Xr.map,T_=Ux,R_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("map",(function(e){return E_(R_(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(T_(e))(t)}))}));var C_=Nn,I_=X,O_=k,P_=Dt,A_=function(e){return function(t,n,r,i){C_(n);var a=I_(t),s=O_(a),o=P_(a.length),u=e?o-1:0,c=e?-1:1;if(r<2)for(;;){if(u in s){i=s[u],u+=c;break}if(u+=c,e?u<0:o<=u)throw TypeError("Reduce of empty array with no initial value")}for(;e?u>=0:o>u;u+=c)u in s&&(i=n(i,s[u],u,a));return i}},j_={left:A_(!1),right:A_(!0)},M_=j_.left,L_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("reduce",(function(e){return M_(L_(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var N_=j_.right,U_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("reduceRight",(function(e){return N_(U_(this),e,arguments.length,arguments.length>1?arguments[1]:void 0)}));var D_=nk.aTypedArray,F_=nk.exportTypedArrayMethod,B_=Math.floor;F_("reverse",(function(){for(var e,t=this,n=D_(t).length,r=B_(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var q_=Dt,z_=yw,W_=X,G_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("set",(function(e){G_(this);var t=z_(arguments.length>1?arguments[1]:void 0,1),n=this.length,r=W_(e),i=q_(r.length),a=0;if(i+t>n)throw RangeError("Wrong length");for(;a<i;)this[t+a]=r[a++]}),o((function(){new Int8Array(1).set({})})));var V_=Ux,$_=nk.aTypedArray,J_=[].slice;(0,nk.exportTypedArrayMethod)("slice",(function(e,t){for(var n=J_.call($_(this),e,t),r=V_(this),i=0,a=n.length,s=new r(a);a>i;)s[i]=n[i++];return s}),o((function(){new Int8Array(1).slice()})));var K_=Xr.some,H_=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("some",(function(e){return K_(H_(this),e,arguments.length>1?arguments[1]:void 0)}));var Y_=Math.floor,Q_=function(e,t){var n=e.length,r=Y_(n/2);return n<8?X_(e,t):Z_(Q_(e.slice(0,r),t),Q_(e.slice(r),t),t)},X_=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},Z_=function(e,t,n){for(var r=e.length,i=t.length,a=0,s=0,o=[];a<r||s<i;)a<r&&s<i?o.push(n(e[a],t[s])<=0?e[a++]:t[s++]):o.push(a<r?e[a++]:t[s++]);return o},eS=Q_,tS=I.match(/firefox\/(\d+)/i),nS=!!tS&&+tS[1],rS=/MSIE|Trident/.test(I),iS=I.match(/AppleWebKit\/(\d+)\./),aS=!!iS&&+iS[1],sS=o,oS=Nn,uS=Dt,cS=eS,lS=nS,fS=rS,dS=N,pS=aS,hS=nk.aTypedArray,vS=nk.exportTypedArrayMethod,yS=a.Uint16Array,mS=yS&&yS.prototype.sort,gS=!!mS&&!sS((function(){var e=new yS(2);e.sort(null),e.sort({})})),bS=!!mS&&!sS((function(){if(dS)return dS<74;if(lS)return lS<67;if(fS)return!0;if(pS)return pS<602;var e,t,n=new yS(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}));vS("sort",(function(e){var t=this;if(void 0!==e&&oS(e),bS)return mS.call(t,e);hS(t);var n,r=uS(t.length),i=Array(r);for(n=0;n<r;n++)i[n]=t[n];for(i=cS(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}),!bS||gS);var kS=Dt,wS=zt,xS=Ux,_S=nk.aTypedArray;(0,nk.exportTypedArrayMethod)("subarray",(function(e,t){var n=_S(this),r=n.length,i=wS(e,r);return new(xS(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,kS((void 0===t?r:wS(t,r))-i))}));var SS=nk,ES=o,TS=a.Int8Array,RS=SS.aTypedArray,CS=SS.exportTypedArrayMethod,IS=[].toLocaleString,OS=[].slice,PS=!!TS&&ES((function(){IS.call(new TS(1))}));CS("toLocaleString",(function(){return IS.apply(PS?OS.call(RS(this)):RS(this),arguments)}),ES((function(){return[1,2].toLocaleString()!=new TS([1,2]).toLocaleString()}))||!ES((function(){TS.prototype.toLocaleString.call([1,2])})));var AS=nk.exportTypedArrayMethod,jS=o,MS=a.Uint8Array,LS=MS&&MS.prototype||{},NS=[].toString,US=[].join;jS((function(){NS.call({})}))&&(NS=function(){return US.call(this)});var DS=LS.toString!=NS;AS("toString",NS,DS);var FS=E,BS=m,qS=he("match"),zS=function(e){var t;return FS(e)&&(void 0!==(t=e[qS])?!!t:"RegExp"==BS(e))},WS=Lp,GS=zS,VS=Fe,$S=w,JS=so,KS=Up,HS=Dt,YS=Er,QS=Vp,XS=Rp,ZS=o,eE=np.UNSUPPORTED_Y,tE=[].push,nE=Math.min,rE=4294967295,iE=!ZS((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]}));WS("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=YS($S(this)),i=void 0===n?rE:n>>>0;if(0===i)return[];if(void 0===e)return[r];if(!GS(e))return t.call(r,e,i);for(var a,s,o,u=[],c=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,f=new RegExp(e.source,c+"g");(a=XS.call(f,r))&&!((s=f.lastIndex)>l&&(u.push(r.slice(l,a.index)),a.length>1&&a.index<r.length&&tE.apply(u,a.slice(1)),o=a[0].length,l=s,u.length>=i));)f.lastIndex===a.index&&f.lastIndex++;return l===r.length?!o&&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=$S(this),a=null==t?void 0:t[e];return void 0!==a?a.call(t,i,n):r.call(YS(i),t,n)},function(e,i){var a=VS(this),s=YS(e),o=n(r,a,s,i,r!==t);if(o.done)return o.value;var u=JS(a,RegExp),c=a.unicode,l=(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.unicode?"u":"")+(eE?"g":"y"),f=new u(eE?"^(?:"+a.source+")":a,l),d=void 0===i?rE:i>>>0;if(0===d)return[];if(0===s.length)return null===QS(f,s)?[s]:[];for(var p=0,h=0,v=[];h<s.length;){f.lastIndex=eE?0:h;var y,m=QS(f,eE?s.slice(h):s);if(null===m||(y=nE(HS(f.lastIndex+(eE?h:0)),s.length))===p)h=KS(s,h,c);else{if(v.push(s.slice(p,h)),v.length===d)return v;for(var g=1;g<=m.length-1;g++)if(v.push(m[g]),v.length===d)return v;h=p=y}}return v.push(s.slice(p)),v}]}),!iE,eE);var aE={exports:{}},sE={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}(sE);var oE={exports:{}},uE={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}(uE),function(e){var t=vv.exports,n=uE.exports;function r(i,a,s){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}(oE),function(e){var t=gv.exports,n=vv.exports,r=sE.exports,i=oE.exports;function a(s){var o="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!==o){if(o.has(e))return o.get(e);o.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(s)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports}(aE);var cE={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,s=i&&a&&"object"==Pa(n)&&n;!s||s.global!==s&&s.window!==s&&s.self!==s||(r=s);var o=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=g(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 m(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=o)for(;++n<r;)t(e[n],n,e);else h(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function g(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||{},s=a.userAgent||"";t||(t=s);var o,c,l=i?!!a.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(f.toString()),d="Object",b=i?d:"ScriptBridgingProxyObject",k=i?d:"Environment",w=i&&n.java?"JavaPackage":v(n.java),x=i?d:"RuntimeObject",_=/\bJava/.test(w)&&n.java,S=_&&v(n.environment)==k,E=_?"a":"α",T=_?"b":"β",R=n.document||{},C=n.operamini||n.opera,I=u.test(I=i&&C?C["[[Class]]"]:v(C))?I:C=null,O=t,P=[],A=null,j=t==s,M=j&&C&&"function"==typeof C.version&&C.version(),L=m([{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)})),N=function(e){return m(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"]),U=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 m(e,(function(e,n,r){return e||(n[U]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(U)]||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 m(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 m(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 m(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)&&!U&&(o=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(U=g(o[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),D&&!U?U=B([D]):D&&U&&(U=U.replace(RegExp("^("+y(D)+")[-_.\\s]","i"),D+" ").replace(RegExp("^("+y(D)+")[-_.]?(\\w)","i"),D+" $2")),(o=/\bGoogle TV\b/.exec(U))&&(U=o[0]),/\bSimulator\b/i.test(t)&&(U=(U?U+" ":"")+"Simulator"),"Opera Mini"==N&&/\bOPiOS\b/.test(t)&&P.push("running in Turbo/Uncompressed mode"),"IE"==N&&/\blike iPhone OS\b/.test(t)?(D=(o=e(t.replace(/like iPhone OS/,""))).manufacturer,U=o.product):/^iP/.test(U)?(N||(N="Safari"),F="iOS"+((o=/ OS ([\d_]+)/i.exec(t))?" "+o[1].replace(/_/g,"."):"")):"Konqueror"==N&&/^Linux\b/i.test(F)?F="Kubuntu":D&&"Google"!=D&&(/Chrome/.test(N)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(U))||/\bAndroid\b/.test(F)&&/^Chrome/.test(N)&&/\bVersion\//i.test(t)?(N="Android Browser",F=/\bAndroid\b/.test(F)?F:"Android"):"Silk"==N?(/\bMobi/i.test(t)||(F="Android",P.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&P.unshift("accelerated")):"UC Browser"==N&&/\bUCWEB\b/.test(t)?P.push("speed mode"):"PaleMoon"==N&&(o=/\bFirefox\/([\d.]+)\b/.exec(t))?P.push("identifying as Firefox "+o[1]):"Firefox"==N&&(o=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(F||(F="Firefox OS"),U||(U=o[1])):!N||(o=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(N))?(N&&!U&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(o+"/")+8))&&(N=null),(o=U||D||F)&&(U||D||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(F))&&(N=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(F)?F:o)+" Browser")):"Electron"==N&&(o=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&P.push("Chromium "+o),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(N),"(?:Firefox|Minefield|NetFront)"])),(o=("iCab"==L&&parseFloat(M)>3?"WebKit":/\bOpera\b/.test(N)&&(/\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(N)&&"NetFront")&&(L=[o]),"IE"==N&&(o=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(N+=" Mobile",F="Windows Phone "+(/\+$/.test(o)?o:o+".x"),P.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(N="IE Mobile",F="Windows Phone 8.x",P.unshift("desktop mode"),M||(M=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=N&&"Trident"==L&&(o=/\brv:([\d.]+)/.exec(t))&&(N&&P.push("identifying as "+N+(M?" "+M:"")),N="IE",M=o[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(_&&(O=(o=_.lang.System).getProperty("os.arch"),F=F||o.getProperty("os.name")+" "+o.getProperty("os.version")),S){try{M=n.require("ringo/engine").version.join("."),N="RingoJS"}catch(e){(o=n.system)&&o.global.system==n.system&&(N="Narwhal",F||(F=o[0].os||null))}N||(N="Rhino")}else"object"==Pa(n.process)&&!n.process.browser&&(o=n.process)&&("object"==Pa(o.versions)&&("string"==typeof o.versions.electron?(P.push("Node "+o.versions.node),N="Electron",M=o.versions.electron):"string"==typeof o.versions.nw&&(P.push("Chromium "+M,"Node "+o.versions.node),N="NW.js",M=o.versions.nw)),N||(N="Node.js",O=o.arch,F=o.platform,M=(M=/[\d.]+/.exec(o.version))?M[0]:null));else v(o=n.runtime)==b?(N="Adobe AIR",F=o.flash.system.Capabilities.os):v(o=n.phantom)==x?(N="PhantomJS",M=(o=o.version||null)&&o.major+"."+o.minor+"."+o.patch):"number"==typeof R.documentMode&&(o=/\bTrident\/(\d+)/i.exec(t))?(M=[M,R.documentMode],(o=+o[1]+4)!=M[1]&&(P.push("IE "+M[1]+" mode"),L&&(L[1]=""),M[1]=o),M="IE"==N?String(M[1].toFixed(1)):M[0]):"number"==typeof R.documentMode&&/^(?:Chrome|Firefox)\b/.test(N)&&(P.push("masking as "+N+" "+M),N="IE",M="11.0",L=["Trident"],F="Windows");F=F&&p(F)}if(M&&(o=/(?:[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(o)?"beta":"alpha",M=M.replace(RegExp(o+"\\+?$"),"")+("beta"==A?T:E)+(/\d+\+?/.exec(o)||"")),"Fennec"==N||"Firefox"==N&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(F))N="Firefox Mobile";else if("Maxthon"==N&&M)M=M.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(U))"Xbox 360"==U&&(F=null),"Xbox 360"==U&&/\bIEMobile\b/.test(t)&&P.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(N)&&(!N||U||/Browser|Mobi/.test(N))||"Windows CE"!=F&&!/Mobi/i.test(t))if("IE"==N&&j)try{null===n.external&&P.unshift("platform preview")}catch(e){P.unshift("embedded")}else(/\bBlackBerry\b/.test(U)||/\bBB10\b/.test(t))&&(o=(RegExp(U.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||M)?(F=((o=[o,/BB10/.test(t)])[1]?(U=null,D="BlackBerry"):"Device Software")+" "+o[0],M=null):this!=h&&"Wii"!=U&&(j&&C||/Opera/.test(N)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==N&&/\bOS X (?:\d+\.){2,}/.test(F)||"IE"==N&&(F&&!/^Win/.test(F)&&M>5.5||/\bWindows XP\b/.test(F)&&M>8||8==M&&!/\bTrident\b/.test(t)))&&!u.test(o=e.call(h,t.replace(u,"")+";"))&&o.name&&(o="ing as "+o.name+((o=o.version)?" "+o:""),u.test(N)?(/\bIE\b/.test(o)&&"Mac OS"==F&&(F=null),o="identify"+o):(o="mask"+o,N=I?p(I.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(o)&&(F=null),j||(M=null)),L=["Presto"],P.push(o));else N+=" Mobile";(o=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(o=[parseFloat(o.replace(/\.(\d)$/,".0$1")),o],"Safari"==N&&"+"==o[1].slice(-1)?(N="WebKit Nightly",A="alpha",M=o[1].slice(0,-1)):M!=o[1]&&M!=(o[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(M=null),o[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==o[0]&&537.36==o[2]&&parseFloat(o[1])>=28&&"WebKit"==L&&(L=["Blink"]),j&&(l||o[1])?(L&&(L[1]="like Chrome"),o=o[1]||((o=o[0])<530?1:o<532?2:o<532.05?3:o<533?4:o<534.03?5:o<534.07?6:o<534.1?7:o<534.13?8:o<534.16?9:o<534.24?10:o<534.3?11:o<535.01?12:o<535.02?"13+":o<535.07?15:o<535.11?16:o<535.19?17:o<536.05?18:o<536.1?19:o<537.01?20:o<537.11?"21+":o<537.13?23:o<537.18?24:o<537.24?25:o<537.36?26:"Blink"!=L?"27":"28")):(L&&(L[1]="like Safari"),o=(o=o[0])<400?1:o<500?2:o<526?3:o<533?4:o<534?"4+":o<535?5:o<537?6:o<538?7:o<601?8:o<602?9:o<604?10:o<606?11:o<608?12:"12"),L&&(L[1]+=" "+(o+="number"==typeof o?".x":/[.+]/.test(o)?"":"+")),"Safari"==N&&(!M||parseInt(M)>45)?M=o:"Chrome"==N&&/\bHeadlessChrome/i.test(t)&&P.unshift("headless")),"Opera"==N&&(o=/\bzbov|zvav$/.exec(F))?(N+=" ",P.unshift("desktop mode"),"zvav"==o?(N+="Mini",M=null):N+="Mobile",F=F.replace(RegExp(" *"+o+"$"),"")):"Safari"==N&&/\bChrome\b/.exec(L&&L[1])?(P.unshift("desktop mode"),N="Chrome Mobile",M=null,/\bOS X\b/.test(F)?(D="Apple",F="iOS 4.3+"):F=null):/\bSRWare Iron\b/.test(N)&&!M&&(M=q("Chrome")),M&&0==M.indexOf(o=/[\d.]+$/.exec(F))&&t.indexOf("/"+o+"-")>-1&&(F=g(F.replace(o,""))),F&&-1!=F.indexOf(N)&&!RegExp(N+" OS").test(F)&&(F=F.replace(RegExp(" *"+y(N)+" *"),"")),L&&!/\b(?:Avant|Nook)\b/.test(N)&&(/Browser|Lunascape|Maxthon/.test(N)||"Safari"!=N&&/^iOS/.test(F)&&/\bSafari\b/.test(L[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(N)&&L[1])&&(o=L[L.length-1])&&P.push(o),P.length&&(P=["("+P.join("; ")+")"]),D&&U&&U.indexOf(D)<0&&P.push("on "+D),U&&P.push((/^on /.test(P[P.length-1])?"":"on ")+U),F&&(o=/ ([\d.+]+)$/.exec(F),c=o&&"/"==F.charAt(F.length-o[0].length-1),F={architecture:32,family:o&&!c?F.replace(o[0],""):F,version:o?o[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(o=/\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(" *"+o),"")),N&&(/\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"==N&&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=N,z.prerelease=A,z.product=U,z.ua=t,z.version=N&&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(N),F&&N&&(F!=String(F).split(" ")[0]||F!=N.split(" ")[0]&&!U)&&P.push(U?"("+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)}(cE,cE.exports);var lE=Fe,fE=Dt,dE=Er,pE=w,hE=Up,vE=Vp;Lp("match",(function(e,t,n){return[function(t){var n=pE(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](dE(n))},function(e){var r=lE(this),i=dE(e),a=n(t,r,i);if(a.done)return a.value;if(!r.global)return vE(r,i);var s=r.unicode;r.lastIndex=0;for(var o,u=[],c=0;null!==(o=vE(r,i));){var l=dE(o[0]);u[c]=l,""===l&&(r.lastIndex=hE(i,fE(r.lastIndex),s)),c++}return 0===c?null:u}]}));var yE=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},mE=Fe,gE=w,bE=yE,kE=Er,wE=Vp;Lp("search",(function(e,t,n){return[function(t){var n=gE(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](kE(n))},function(e){var r=mE(this),i=kE(e),a=n(t,r,i);if(a.done)return a.value;var s=r.lastIndex;bE(s,0)||(r.lastIndex=0);var o=wE(r,i);return bE(r.lastIndex,s)||(r.lastIndex=s),null===o?-1:o.index}]}));var xE=Cn,_E=zt,SE=Lt,EE=Dt,TE=X,RE=Gr,CE=wa,IE=la("splice"),OE=Math.max,PE=Math.min,AE=9007199254740991,jE="Maximum allowed length exceeded";xE({target:"Array",proto:!0,forced:!IE},{splice:function(e,t){var n,r,i,a,s,o,u=TE(this),c=EE(u.length),l=_E(e,c),f=arguments.length;if(0===f?n=r=0:1===f?(n=0,r=c-l):(n=f-2,r=PE(OE(SE(t),0),c-l)),c+n-r>AE)throw TypeError(jE);for(i=RE(u,r),a=0;a<r;a++)(s=l+a)in u&&CE(i,a,u[s]);if(i.length=r,n<r){for(a=l;a<c-r;a++)o=a+n,(s=a+r)in u?u[o]=u[s]:delete u[o];for(a=c;a>c-r+n;a--)delete u[a-1]}else if(n>r)for(a=c-r;a>l;a--)o=a+n-1,(s=a+r-1)in u?u[o]=u[s]:delete u[o];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=zg.exports,r=mv.exports,i=Ry.exports,a=hv.exports,s=yv.exports,o=gv.exports,u=dv.exports,c=pv.exports,l=Iy.exports,f=Wg,d=bh.exports,p=gh,h=Sf.exports,v=eb.exports,y=Sb,m=aE.exports,g=ng,b=Ty,k=cE.exports;function w(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function x(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(n),S=w(r),E=w(i),T=w(a),R=w(s),C=w(o),I=w(u),O=w(c),P=w(l),A=w(f),j=w(d),M=x(h),L=x(v),N=w(m),U=x(k);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 I.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.13.10-rc.8",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"),s=r.twilsock||r.Twilsock||{};this.url=s.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 I.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}(),G=I.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var $=function(e){T.default(n,e);var t=V(n);function n(e,r,i,a,s){var o;return O.default(this,n),o=t.call(this),P.default(S.default(o),"method","init"),o.token=e,o.continuation_token=r,o.metadata=i,o.registrations=a,o.tweaks=s,o.capabilities=["client_update","offline_storage","telemetry.v1"],o}return I.default(n)}(G);function J(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var K=function(e){T.default(n,e);var t=J(n);function n(e,r,i,a,s,o,u){var c;return O.default(this,n),(c=t.call(this,e)).continuationToken=r,c.continuationTokenStatus=a,c.offlineStorage=s,c.initRegistrations=o,c.debugInfo=u,c.confirmedCapabilities=i,c}return I.default(n)}(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Y=function(e){T.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 I.default(n)}(G);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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Message=function(e){T.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 I.default(Message)}(G);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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Z=function(e){T.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 I.default(n)}(G);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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var te=function(e){T.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 I.default(n)}(G);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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var re=I.default((function e(t,n,r,i,a,s){O.default(this,e),this.start=t,this.end=n,this.title=r,this.details=i,this.id=a,this.type=s})),ie=function(e){T.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 I.default(n)}(G);function ae(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(function(e,t){return String.fromCharCode(Number("0x"+t))})).length}function se(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 oe(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(oe(e))}var ce=function(){function e(){O.default(this,e)}return I.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,s=t.payload_size;if(t.hasOwnProperty("payload_type")&&0!==t.payload_type.indexOf("application/json"))0===t.payload_type.indexOf("text/plain")&&(n=oe(r.subarray(a,a+s)));else try{n=ue(r.subarray(a,a+s))}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=se(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var fe=function(e){T.default(n,e);var t=le(n);function n(e){return O.default(this,n),t.call(this,e)}return I.default(n)}(N.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var pe=function(e){T.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 I.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var me=function(e){T.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 I.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 g.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 ge(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var be=function(e){T.default(i,e);var t,n,r=ge(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 me(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 s=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 s,a}return I.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=_.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=_.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(),setTimeout((function(){return t.fsm.socketClosed()}),0)}},{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),ke=function(){function e(){O.default(this,e)}return I.default(e,null,[{key:"getMetadata",value:function(e){var t,n,r,i,a,s,o,u,c=e&&e.clientMetadata?e.clientMetadata:{},l={env:null!==(t=U.name)&&void 0!==t?t:"unknown",envv:null!==(n=U.version)&&void 0!==n?n:"unknown",os:null!==(r=null===(i=U.os)||void 0===i?void 0:i.family)&&void 0!==r?r:"unknown",osv:null!==(a=null===(s=U.os)||void 0===s?void 0:s.version)&&void 0!==a?a:"unknown",osa:null!==(o=null===(u=U.os)||void 0===u?void 0:u.architecture)&&void 0!==o?o:"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 we=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 I.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=_.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=ke.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 K(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 xe(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var _e=function(e){T.default(r,e);var n=xe(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 I.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Ee=function(e){T.default(u,e);var t,n,r,i,a,s,o=Se(u);function u(e){var t;return O.default(this,u),(t=o.call(this)).transport=e,t.registrations=new Map,t.registrationsInProgress=new Map,t}return I.default(u,[{key:"putNotificationContext",value:(s=_.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 s.apply(this,arguments)})},{key:"deleteNotificationContext",value:(a=_.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=_.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=_.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=_.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=_.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 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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Re=function(e){T.default(n,e);var t=Te(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 I.default(n)}(fe);function Ce(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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var Ie=function(e){T.default(n,e);var t=Ce(n);function n(e){return O.default(this,n),t.call(this,e)}return I.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 I.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 Ie("Unable to connect: "+e.twilsock.getTerminationReason)),t.alreadyRejected=!0,clearTimeout(t.timeout)})),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:(t=_.default(A.default.mark((function e(t){var n,r,i,a,s,o,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,s=null!==(n=t.grant)&&void 0!==n?n:this.config.activeGrant,o={host:r.host,path:r.path,method:r.method,params:r.params,headers:i},u=new Message(s,i["Content-Type"]||"application/json",o),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 Re(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 Ie("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 I.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 I.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 I.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 Ne,Ue,De=new Le,Fe=function(){function e(t,n,r,i,a,s){O.default(this,e),this.title=t,this.details=n,this.start=r,this.type=a,this.id=s,this.end=i}return I.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,(Ne=e.TelemetryPoint||(e.TelemetryPoint={}))[Ne.Start=0]="Start",Ne[Ne.End=1]="End",e.EventSendingLimitation=void 0,(Ue=e.EventSendingLimitation||(e.EventSendingLimitation={}))[Ue.MinEventsPortion=0]="MinEventsPortion",Ue[Ue.AnyEvents=1]="AnyEvents",Ue[Ue.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 I.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=C.default(e);if(t){var i=C.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return R.default(this,n)}}var ze=I.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){T.default(f,t);var n,r,i,a,s,o,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 s=new _e(a.url),o=new we(s,a);return i.channel=new be(s,o,a),i.registrations=new Ee(o),i.upstream=new Ae(o,i.channel,a),i.telemetryTracker=new Be(a,o),i.channel.on("initialized",(function(){return i.telemetryTracker.canSendTelemetry=!0})),s.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 I.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(C.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=_.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=_.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:(o=_.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 o.apply(this,arguments)})},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:(s=_.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 s.apply(this,arguments)})},{key:"get",value:(a=_.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=_.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=_.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=_.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,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":j.default(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}([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 I.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=Ie,e.Twilsock=e.TwilsockClient,e.TwilsockError=fe}(qg);var ME={},LE=u,NE=o,UE=Fn,DE=nn,FE=c,BE=X,qE=k,zE=Object.assign,WE=Object.defineProperty,GE=!zE||NE((function(){if(LE&&1!==zE({b:1},zE(WE({},"a",{enumerable:!0,get:function(){WE(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!=zE({},e)[n]||UE(zE({},t)).join("")!=r}))?function(e,t){for(var n=BE(e),r=arguments.length,i=1,a=DE.f,s=FE.f;r>i;)for(var o,u=qE(arguments[i++]),c=a?UE(u).concat(a(u)):UE(u),l=c.length,f=0;l>f;)o=c[f++],LE&&!s.call(u,o)||(n[o]=u[o]);return n}:zE,VE=GE;Cn({target:"Object",stat:!0,forced:Object.assign!==VE},{assign:VE}),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=zg.exports,n=pv.exports,r=dv.exports,i=hv.exports,a=yv.exports,s=gv.exports,o=Wg,u=bh.exports,c=qg,l=mv.exports,f=Iy.exports,d=ng,p=Th.exports,h=uv.exports,v=Sf.exports,y=Sb,m=gh;function g(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 k=g(t),w=g(n),x=g(r),_=g(i),S=g(a),E=g(s),T=g(o),R=g(u),C=g(l),I=g(f),O=g(p),P=g(h),A=b(v),j=b(y);function M(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":R.default(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function L(e,t){if("object"===("undefined"==typeof Reflect?"undefined":R.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function N(){}function U(){U.init.call(this)}function D(e){return void 0===e._maxListeners?U.defaultMaxListeners:e._maxListeners}function F(e,t,n){if(t)e.call(n);else for(var r=e.length,i=J(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=J(e,i),s=0;s<i;++s)a[s].call(n,r)}function q(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,s=J(e,a),o=0;o<a;++o)s[o].call(n,r,i)}function z(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var s=e.length,o=J(e,s),u=0;u<s;++u)o[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=J(e,i),s=0;s<i;++s)a[s].apply(n,r)}function G(e,t,n,r){var i,a,s,o;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),s=a[t]):(a=e._events=new N,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=D(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,o=u,"function"==typeof console.warn?console.warn(o):console.log(o)}}else s=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 J(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}N.prototype=Object.create(null),U.EventEmitter=U,U.usingDomains=!1,U.prototype.domain=void 0,U.prototype._events=void 0,U.prototype._maxListeners=void 0,U.defaultMaxListeners=10,U.init=function(){this.domain=null,U.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new N,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},U.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},U.prototype.getMaxListeners=function(){return D(this)},U.prototype.emit=function(e){var t,n,r,i,a,s,o,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){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=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=s[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},U.prototype.addListener=function(e,t){return G(this,e,t,!1)},U.prototype.on=U.prototype.addListener,U.prototype.prependListener=function(e,t){return G(this,e,t,!0)},U.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},U.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},U.prototype.removeListener=function(e,t){var n,r,i,a,s;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 N:(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){s=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 N,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,s||t)}return this},U.prototype.off=function(e,t){return this.removeListener(e,t)},U.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new N,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new N: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 N,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},U.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},U.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):$.call(e,t)},U.prototype.listenerCount=$,U.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var K=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(){w.default(this,e)}return x.default(e,[{key:"setLevel",value:function(e){K.setLevel(e)}},{key:"trace",value:function(){if(K.getLevel()==K.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];K.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];K.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];K.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];K.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];K.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=x.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;w.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){_.default(r,e);var t,n=X(r);function r(e){var t;return w.default(this,r),t=n.call(this),I.default(C.default(t),"desiredState",new Z),I.default(C.default(t),"currentState",new Z),I.default(C.default(t),"_hasActiveAttempt",!1),t.channelType=e,t}return x.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=k.default(T.default.mark((function e(){var t,n,r,i,a,s;return T.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:s=e.sent,this.currentState.token=s.token,this.currentState.notificationId=s.notificationId,this.currentState.messageTypes=new Set(s.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}(U);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){_.default(a,e);var t,n,r,i=ne(a);function a(e,t,n,r){var s;return w.default(this,a),s=i.call(this,e),I.default(C.default(s),"registrationId",null),s.context=t,s.twilsock=n,s.registrarUrl=r,s}return x.default(a,[{key:"updateRegistration",value:(r=k.default(T.default.mark((function e(t,n){var r,i,a,s,o,u=this;return T.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),s={"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,s,r,i)}));case 15:o=e.sent,this.registrationId=o.body.id,Q.debug("Registration created: ",o),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=k.default(T.default.mark((function e(){var t,n,r,i=this;return T.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=k.default(T.default.mark((function e(t){var n,r,i,a,s=this;return T.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 s.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 se,oe=function(e){_.default(a,e);var t,n,r,i=ae(a);function a(e,t,n){var r;return w.default(this,a),r=i.call(this,"twilsock"),I.default(C.default(r),"contextId",j.v4()),r.productId=e,r.platform=t,r.twilsock=n,r}return x.default(a,[{key:"updateRegistration",value:(r=k.default(T.default.mark((function e(t,n){var r,i;return T.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=k.default(T.default.mark((function e(){return T.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=k.default(T.default.mark((function e(t){return T.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=m.literal("apn","fcm","twilsock");e.Notifications=se=function(e){_.default(Client,e);var t,n,r,i=ue(Client);function Client(e){var t,n,r,a,s,o,u,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};w.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!==(s=null!==(o=h.region)&&void 0!==o?o:l.region)&&void 0!==s?s:"us1",y="https://ers.".concat(v,".twilio.com/v1/registrations"),m=h.ersUrl||y;u.connectors=new Map;var g=se._detectPlatform();return u.connectors.set("apn",new ie("apn",{protocolVersion:4,productId:f,platform:g},p,m)),u.connectors.set("fcm",new ie("fcm",{protocolVersion:3,productId:f,platform:g},p,m)),u.connectors.set("twilsock",new oe(f,g,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 x.default(Client,[{key:"shutdown",value:(r=k.default(T.default.mark((function e(){return T.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=k.default(T.default.mark((function e(){var t;return T.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=k.default(T.default.mark((function e(t,n){return T.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}(U),M([m.validateTypes(ce,m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"setPushRegistrationId",null),M([m.validateTypes(ce,m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"subscribe",null),M([m.validateTypes(ce,m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",void 0)],e.Notifications.prototype,"unsubscribe",null),M([m.validateTypes(m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String]),L("design:returntype",void 0)],e.Notifications.prototype,"updateToken",null),M([m.validateTypesAsync(ce,m.nonEmptyString),L("design:type",Function),L("design:paramtypes",[String,String]),L("design:returntype",Promise)],e.Notifications.prototype,"removeRegistrations",null),e.Notifications=se=M([m.validateConstructorTypes(m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),L("design:paramtypes",[String,Object])],e.Notifications)}(ME);var $E={};Object.defineProperty($E,"__esModule",{value:!0});var JE=zg.exports,KE=pv.exports,HE=dv.exports,YE=mv.exports,QE=hv.exports,XE=yv.exports,ZE=gv.exports,eT=Iy.exports,tT=Wg,nT=bh.exports,rT=gh,iT=qg,aT=aE.exports,sT=Sf.exports,oT=Th.exports,uT=ng,cT=Sb,lT=Ry.exports,fT=cE.exports;function dT(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}function pT(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 hT=dT(JE),vT=dT(KE),yT=dT(HE),mT=dT(YE),gT=dT(QE),bT=dT(XE),kT=dT(ZE),wT=dT(eT),xT=dT(tT),_T=dT(nT),ST=dT(aT),ET=pT(sT),TT=dT(oT),RT=pT(cT),CT=dT(lT),IT=pT(fT);function OT(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":_T.default(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function PT(e,t){if("object"===("undefined"==typeof Reflect?"undefined":_T.default(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function AT(){}function jT(){jT.init.call(this)}function MT(e){return void 0===e._maxListeners?jT.defaultMaxListeners:e._maxListeners}function LT(e,t,n){if(t)e.call(n);else for(var r=e.length,i=WT(e,r),a=0;a<r;++a)i[a].call(n)}function NT(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,a=WT(e,i),s=0;s<i;++s)a[s].call(n,r)}function UT(e,t,n,r,i){if(t)e.call(n,r,i);else for(var a=e.length,s=WT(e,a),o=0;o<a;++o)s[o].call(n,r,i)}function DT(e,t,n,r,i,a){if(t)e.call(n,r,i,a);else for(var s=e.length,o=WT(e,s),u=0;u<s;++u)o[u].call(n,r,i,a)}function FT(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,a=WT(e,i),s=0;s<i;++s)a[s].apply(n,r)}function BT(e,t,n,r){var i,a,s,o;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),s=a[t]):(a=e._events=new AT,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=MT(e))&&i>0&&s.length>i){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,o=u,"function"==typeof console.warn?console.warn(o):console.log(o)}}else s=a[t]=n,++e._eventsCount;return e}function qT(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 zT(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 WT(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}AT.prototype=Object.create(null),jT.EventEmitter=jT,jT.usingDomains=!1,jT.prototype.domain=void 0,jT.prototype._events=void 0,jT.prototype._maxListeners=void 0,jT.defaultMaxListeners=10,jT.init=function(){this.domain=null,jT.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new AT,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},jT.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},jT.prototype.getMaxListeners=function(){return MT(this)},jT.prototype.emit=function(e){var t,n,r,i,a,s,o,u="error"===e;if(s=this._events)u=u&&null==s.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){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=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:LT(n,l,this);break;case 2:NT(n,l,this,arguments[1]);break;case 3:UT(n,l,this,arguments[1],arguments[2]);break;case 4:DT(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];FT(n,l,this,i)}return!0},jT.prototype.addListener=function(e,t){return BT(this,e,t,!1)},jT.prototype.on=jT.prototype.addListener,jT.prototype.prependListener=function(e,t){return BT(this,e,t,!0)},jT.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,qT(this,e,t)),this},jT.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,qT(this,e,t)),this},jT.prototype.removeListener=function(e,t){var n,r,i,a,s;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 AT:(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){s=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 AT,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,s||t)}return this},jT.prototype.off=function(e,t){return this.removeListener(e,t)},jT.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new AT,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new AT: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 AT,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},jT.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},jT.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):zT.call(e,t)},jT.prototype.listenerCount=zT,jT.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var GT=function(){function e(t){vT.default(this,e),this.base=t,this.args=new Array,this.paths=new Array}return yT.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 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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var SyncError=function(e){gT.default(SyncError,e);var t=VT(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 vT.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 SyncError}(ST.default(Error)),$T=function(e){gT.default(n,e);var t=VT(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,s=arguments.length>3?arguments[3]:void 0;return vT.default(this,n),(r=t.call(this,e,i,a)).body=s,r}return n}(SyncError);function JT(e){return JSON.parse(JSON.stringify(e))}function KT(e){if(!(void 0===e||HT(e)))throw new SyncError("Invalid pageSize parameter. Expected a positive integer, was '".concat(e,"'."),400,20007)}function HT(e){return function(e){return!isNaN(parseInt(e))&&isFinite(e)}(e)&&e>0}var YT=ET.getLogger("twilio-sync");function QT(e,t){return["".concat((new Date).toISOString()," Sync ").concat(e,":")].concat(Array.from(t))}var XT=function(e){YT.setLevel(e)},ZT=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];YT.trace.apply(null,QT("T",t))},eR=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];YT.debug.apply(null,QT("D",t))},tR=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];YT.warn.apply(null,QT("W",t))},nR=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];YT.error.apply(null,QT("E",t))},rR="/v4/Subscriptions",iR="/v3/Maps",aR="/v3/Lists",sR="/v3/Documents",oR="/v3/Streams",uR="/v3/Insights";function cR(e,t,n){return e&&void 0!==e[t]?e[t]:n}var lR=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};vT.default(this,e);var n=t.region||"us1",r="https://cds.".concat(n,".twilio.com"),i=t.cdsUri||r;this.settings={subscriptionsUri:i+rR,documentsUri:i+sR,listsUri:i+aR,mapsUri:i+iR,streamsUri:i+oR,insightsUri:i+uR,sessionStorageEnabled:cR(t.Sync,"enableSessionStorage",!0),productId:t.productId}}return yT.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 fR(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 dR(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 dR(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function dR(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 pR=function(){function e(t){vT.default(this,e),this.localObject=t,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return yT.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}(),hR=function(){function e(t){var n=this;vT.default(this,e),wT.default(this,"isConnected",!1),wT.default(this,"maxBatchSize",100),wT.default(this,"subscriptionTtlTimer",null),wT.default(this,"pendingPokeReason",null),this.services=t,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;this.backoff=uT.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(),eR("All subscriptions resolved."))}))}var t;return yT.default(e,[{key:"getSubscriptionUpdateBatch",value:function(){function e(e,t,n,r){var i,a=[],s=fR(e);try{for(s.s();!(i=s.n()).done;){var o=TT.default(i.value,2),u=o[0],c=o[1];if(!t.get(u)&&n!==c.pendingAction&&!c.rejectedWithError&&(a.push(c),r&&a.length>=r))break}}catch(e){s.e(e)}finally{s.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=hT.default(xT.default.mark((function e(t,n){var r,i,a,s,o,u,c,l,f,d,p,h,v=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=4;break}return eR("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=fR(n);try{for(i.s();!(a=i.n()).done;)s=a.value,this.recordActionAttemptOn(s,t,r)}catch(e){i.e(e)}finally{i.f()}return o=this.pendingPokeReason,this.pendingPokeReason=null,e.prev=10,e.next=13,this.request(t,r,o,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):nR("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=fR(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 iT.TransportUnavailableError?(eR("Twilsock connection (required for subscription) not ready (c:".concat(r,"); waiting…")),this.backoff.reset()):(eR("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;eR("Attempting '".concat(e,"' request (c:").concat(t,"):"),i);var s={event_protocol_version:4,action:e,correlation_id:t,retried_requests:a,ttl_in_s:-1,requests:i};return"ttl"===n&&(s.reason=n),this.services.network.post(this.services.config.subscriptionsUri,s)}},{key:"add",value:function(e,t){eR("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 pR(t)),this.persist())}},{key:"remove",value:function(e){eR("Establishing intent to unsubscribe from ".concat(e)),this.subscriptions.delete(e)&&this.persist()}},{key:"acceptMessage",value:function(e,t){ZT("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,s=fR(r);try{for(s.s();!(a=s.n()).done;){var o=a.value,u=void 0;switch(e.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(o,i);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(o,i);break;case"subscription_failed":this.applySubscriptionFailedMessage(o,i);break;case(u=n.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:var c=void 0;switch(u[0]){case"map_":c=o.map_sid;break;case"list_":c=o.list_sid;break;case"document_":c=o.document_sid;break;case"stream_":c=o.stream_sid;break;case"live_query_":c=o.query_id,t=!1,!0===e.strictly_ordered&&(t=!0);break;default:c=void 0}this.applyEventToSubscribedEntity(c,o,n,t);break;default:eR("Dropping unknown message type ".concat(n))}}}catch(e){s.e(e)}finally{s.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?(eR("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&&(eR("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()):eR("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)):eR("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&&(nR("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)):eR("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){eR("Triggering event replay for all subscriptions, reason=".concat(e)),this.pendingPokeReason=e,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var t,n=[],r=fR(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,s=n;a<s.length;a++){var o=s[a];this.persisted.set(o.sid,o)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}();function vR(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 yR(e){return e.body?e.body.code:0}function mR(e){return 409===e.status?new $T(vR(e),e.status,yR(e),e.body):e.status?new SyncError(vR(e),e.status,yR(e)):e instanceof iT.TransportUnavailableError?e:new SyncError(e.message,0,0)}var gR=function(){function e(t,n,r){vT.default(this,e),this.clientInfo=t,this.config=n,this.transport=r}return yT.default(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+RT.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 s=new uT.Retrier(t.backoffConfig());s.on("attempt",(function(){e().then((function(e){return s.succeeded(e)})).catch((function(e){if(a.includes(e.status)){var t=parseInt(e.headers?e.headers["Retry-After"]:null);s.failed(mR(e),isNaN(t)?null:1e3*t)}else"Twilsock disconnected"===e.message?s.failed(mR(e)):(s.removeAllListeners(),s.cancel(),i(mR(e)))}))})),s.on("succeeded",(function(e){r(e)})),s.on("cancelled",(function(e){return i(mR(e))})),s.on("failed",(function(e){return i(mR(e))})),s.start()}))}},{key:"get",value:function(e){var t=this,n=this.createHeaders();return eR("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),eR("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),eR("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 eR("DELETE",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry((function(){return t.transport.delete(e,n,t.config.productId)}),!1)}}]),e}(),bR=function(){function e(t,n){vT.default(this,e),this.config=t,this.storageId=null;try{this.storage=n||sessionStorage}catch(e){}}return yT.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 kR(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 wR(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 wR(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function wR(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 xR=function(){function e(t,n){vT.default(this,e),this.services=t,this.removalHandler=n,this.subscriptionState="none",this._attachedListeners=new Map}return yT.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,t){var n,r=kR(this._attachedListeners.values());try{for(r.s();!(n=r.n()).done;){n.value.emit(e,t)}}catch(e){r.e(e)}finally{r.f()}}}]),e}(),_R=function(){function e(t){vT.default(this,e),wT.default(this,"queuedRequests",[]),wT.default(this,"isRequestInFlight",!1),this.inputMergingFunction=t}return yT.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}(),SR=function(){function e(t){vT.default(this,e),wT.default(this,"queueByNamespaceKey",new Map),this.inputReducer=t}var t,n,r;return yT.default(e,[{key:"add",value:(r=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.queueByNamespaceKey.has(t)||this.queueByNamespaceKey.set(t,new _R(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 ER(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var TR=function(e){gT.default(n,e);var t=ER(n);function n(){var e;return vT.default(this,n),(e=t.call(this)).closed=!1,e.uuid=cT.v4(),e}return yT.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}(jT);function RR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var CR=function(e){gT.default(f,e);var t,n,r,i,a,s,o,u,c,l=RR(f);function f(e,t,n){var r;vT.default(this,f),r=l.call(this,e,n),wT.default(mT.default(r),"isDeleted",!1);return r.updateMergingQueue=new _R((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 yT.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){ZT("Document update skipped, current:",this.lastEventId,", remote:",e.id);break}var t=void 0!==this.descriptor.data?JT(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=hT.default(xT.default.mark((function e(t,n){var r,i=this;return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i=this;return xT.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:(o=hT.default(xT.default.mark((function e(t,n){return xT.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 o.apply(this,arguments)})},{key:"setTtl",value:(s=hT.default(xT.default.mark((function e(t){var n;return xT.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 s.apply(this,arguments)})},{key:"_setUnconditionally",value:(a=hT.default(xT.default.mark((function e(t,n){var r;return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i,a;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t(JT(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?JT(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=hT.default(xT.default.mark((function e(t){var n,r,i;return xT.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=hT.default(xT.default.mark((function e(){var t=this;return xT.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):nR("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?JT(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=hT.default(xT.default.mark((function e(){return xT.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}(xR),IR=function(e){gT.default(o,e);var t,n,r,i,a,s=RR(o);function o(e){var t;return vT.default(this,o),(t=s.call(this)).syncDocumentImpl=e,t.syncDocumentImpl.attach(mT.default(t)),t}return yT.default(o,[{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 CR.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(){return xT.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(){CT.default(kT.default(o.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return CR.type}}]),o}(TR);wT.default(IR,"removed","removed"),wT.default(IR,"updated","updated"),OT([rT.validateTypesAsync(rT.pureObject,["undefined",rT.objectSchema("document metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object,Object]),PT("design:returntype",Promise)],IR.prototype,"set",null),OT([rT.validateTypesAsync("function",["undefined",rT.objectSchema("document metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Function,Object]),PT("design:returntype",Promise)],IR.prototype,"mutate",null),OT([rT.validateTypesAsync(rT.pureObject,["undefined",rT.objectSchema("document metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object,Object]),PT("design:returntype",Promise)],IR.prototype,"update",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],IR.prototype,"setTtl",null);var OR=function(){function e(t){vT.default(this,e),this.descriptor=t}return yT.default(e,[{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}},{key:"update",value:function(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,n,r){vT.default(this,Paginator),this.prevToken=n,this.nextToken=r,this.items=e,this.source=t}var e,t;return yT.default(Paginator,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:(t=hT.default(xT.default.mark((function e(){return xT.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(this.nextToken));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"prevPage",value:(e=hT.default(xT.default.mark((function e(){return xT.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(this.prevToken));case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]),Paginator}();function PR(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 AR(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 AR(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function AR(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 jR=function(){function e(t,n){vT.default(this,e),this.balanceFactor=0,this.key=t,this.value=n,this.parent=null,this.left=null,this.right=null}return yT.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}(),MR=function(){function e(t,n){vT.default(this,e),this.isLessThan=t||function(e,t){return e<t},this.isEqual=n||function(e,t){return e===t},this.root=null,this.count=null}return yT.default(e,[{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 jR(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 s=t.left;s.right;)s=s.right;if(t.left===s)t.isRoot?(this.root=s,s.parent=null):(t.isLeftChild?t.parent.left=s:t.parent.right=s,s.parent=t.parent),s.right=t.right,s.right.parent=s,s.balanceFactor=t.balanceFactor,t={parent:s,isLeftChild:!0};else{var o=s.parent,u=s.left;o.right=u,u&&(u.parent=o),t.isRoot?(this.root=s,s.parent=null):(t.isLeftChild?t.parent.left=s:t.parent.right=s,s.parent=t.parent),s.right=t.right,s.right.parent=s,s.left=t.left,s.left.parent=s,s.balanceFactor=t.balanceFactor,t={parent:o,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:Symbol.iterator,value:xT.default.mark((function e(){var t,n,r;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=PR(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:xT.default.mark((function e(){var t,n,r,i=arguments;return xT.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:xT.default.mark((function e(){var t,n,r,i=arguments;return xT.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)}))}]),e}();function LR(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 NR(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 NR(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function NR(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 UR=function(){function e(t,n){vT.default(this,e),this.value=t,this.revision=n||0}return yT.default(e,[{key:"isValid",get:function(){return!0}}]),e}(),DR=function(){function e(t){vT.default(this,e),this.revision=t}return yT.default(e,[{key:"isValid",get:function(){return!1}}]),e}(),FR=function(){function e(){vT.default(this,e),this.items=new MR}return yT.default(e,[{key:"store",value:function(e,t,n){var r=this.items.get(e);return r&&r.revision>n?r.isValid?r.value:null:(this.items.set(e,new UR(t,n)),t)}},{key:"delete",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.items.get(e);(!r||r.revision<t||r&&!0===n)&&this.items.set(e,new DR(t))}},{key:"isKnown",value:function(e,t){var n=this.items.get(e);return n&&n.revision>=t}},{key:"get",value:function(e){var t=this.items.get(e);return t&&t.isValid?t.value:null}},{key:"has",value:function(e){var t=this.items.get(e);return t&&t.isValid}},{key:"forEach",value:function(e){if(this.items){var t,n=LR(this.items);try{for(n.s();!(t=n.n()).done;){var r=TT.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}();function BR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var qR=function(e){gT.default(y,e);var t,n,r,i,a,s,o,u,c,l,f,d,p,h,v=BR(y);function y(e,t,n){var r;vT.default(this,y);return(r=v.call(this,e,n)).updateMergingQueue=new SR((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new FR,r.descriptor=t,r.descriptor.date_updated=new Date(r.descriptor.date_updated),r}return yT.default(y,[{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:(h=hT.default(xT.default.mark((function e(t,n,r,i){var a,s;return xT.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(s=e.sent).body.data=n,s.body.date_updated=new Date(s.body.date_updated),e.abrupt("return",s.body);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n,r){return h.apply(this,arguments)})},{key:"push",value:(p=hT.default(xT.default.mark((function e(t,n){var r,i,a;return xT.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.get(a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"set",value:(d=hT.default(xT.default.mark((function e(t,n,r){var i,a=this;return xT.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 d.apply(this,arguments)})},{key:"_updateItemUnconditionally",value:(f=hT.default(xT.default.mark((function e(t,n,r){var i,a;return xT.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.uri,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.get(t));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return f.apply(this,arguments)})},{key:"_updateItemWithIfMatch",value:(l=hT.default(xT.default.mark((function e(t,n,r){var i,a,s,o;return xT.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(JT(i.data)))){e.next=25;break}return s=i.revision,e.prev=6,e.next=9,this._addOrUpdateItemOnServer(i.uri,a,s,r);case 9:return o=e.sent,this._handleItemMutated(t,o.url,o.last_event_id,o.revision,o.data,o.date_updated,o.date_expires,!1,!1),e.abrupt("return",this.cache.get(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 l.apply(this,arguments)})},{key:"mutate",value:(c=hT.default(xT.default.mark((function e(t,n,r){var i,a=this;return xT.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 c.apply(this,arguments)})},{key:"update",value:(u=hT.default(xT.default.mark((function e(t,n,r){return xT.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 u.apply(this,arguments)})},{key:"remove",value:(o=hT.default(xT.default.mark((function e(t){var n,r,i;return xT.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=JT(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 o.apply(this,arguments)})},{key:"get",value:function(){var e=hT.default(xT.default.mark((function e(t){var n;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))){e.next=5;break}return e.abrupt("return",n);case 5:return e.abrupt("return",this._getItemFromServer(t));case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:(s=hT.default(xT.default.mark((function e(t){var n;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({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 s.apply(this,arguments)})},{key:"queryItems",value:function(){var e=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new GT(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Index",t.index).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map((function(e){return e.date_updated=new Date(e.date_updated),s.cache.get(e.index)?s._handleItemMutated(e.index,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):s.cache.store(Number(e.index),new OR({index:Number(e.index),uri:e.url,revision:e.revision,lastEventId:e.last_event_id,dateUpdated:e.date_updated,dateExpires:e.date_expires,data:e.data}),e.last_event_id),s.cache.get(e.index)})),a=r.body.meta,e.abrupt("return",new Paginator(i,(function(e){return s.queryItems({pageToken:e})}),a.previous_token,a.next_token));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:(a=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return KT((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=hT.default(xT.default.mark((function e(){var t;return xT.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=hT.default(xT.default.mark((function e(t){var n,r;return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i,a;return xT.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:"removeList",value:(t=hT.default(xT.default.mark((function e(){return xT.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,void 0,"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,s,o,u){if(this.shouldIgnoreEvent(e,n))ZT("Item ".concat(e," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(n));else{this._updateRootDateUpdated(a);var c=this.cache.get(e);if(!c){var l=new OR({index:e,uri:t,lastEventId:n,revision:r,data:i,dateUpdated:a,dateExpires:s});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,o)}var f=JT(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==s&&c.updateDateExpires(s),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):(ZT("Context update skipped, current:",this.lastEventId,", remote:",t),!1)}}],[{key:"type",get:function(){return"list"}}]),y}(xR),zR=function(e){gT.default(p,e);var t,n,r,i,a,s,o,u,c,l,f,d=BR(p);function p(e){var t;return vT.default(this,p),(t=d.call(this)).syncListImpl=e,t.syncListImpl.attach(mT.default(t)),t}return yT.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 qR.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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:(o=hT.default(xT.default.mark((function e(t){return xT.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 o.apply(this,arguments)})},{key:"get",value:(s=hT.default(xT.default.mark((function e(t){return xT.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 s.apply(this,arguments)})},{key:"getContext",value:(a=hT.default(xT.default.mark((function e(){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(){return xT.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(){CT.default(kT.default(p.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return qR.type}}]),p}(TR);wT.default(zR,"itemAdded","itemAdded"),wT.default(zR,"itemUpdated","itemUpdated"),wT.default(zR,"itemRemoved","itemRemoved"),wT.default(zR,"removed","removed"),OT([rT.validateTypesAsync(rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object,Object]),PT("design:returntype",Promise)],zR.prototype,"push",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger,rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Number,Object,Object]),PT("design:returntype",Promise)],zR.prototype,"set",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger,"function",["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Number,Function,Object]),PT("design:returntype",Promise)],zR.prototype,"mutate",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger,rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Number,Object,Object]),PT("design:returntype",Promise)],zR.prototype,"update",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],zR.prototype,"remove",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],zR.prototype,"get",null),OT([rT.validateTypesAsync(["undefined",rT.objectSchema("query options",{from:[rT.nonNegativeInteger,"undefined"],pageSize:[rT.custom((function(e){return[HT(e),"a positive integer"]})),"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],zR.prototype,"getItems",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],zR.prototype,"setTtl",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger,rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number,Number]),PT("design:returntype",Promise)],zR.prototype,"setItemTtl",null);var WR=function(){function e(t){vT.default(this,e),this.descriptor=t}return yT.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:"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 GR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var VR=function(e){gT.default(h,e);var t,n,r,i,a,s,o,u,c,l,f,d,p=GR(h);function h(e,t,n){var r;vT.default(this,h);return(r=p.call(this,e,n)).updateMergingQueue=new SR((function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e})),r.cache=new FR,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 WR(e),e.last_event_id)})),r}return yT.default(h,[{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:(d=hT.default(xT.default.mark((function e(t,n,r){var i,a=this;return xT.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 d.apply(this,arguments)})},{key:"get",value:function(){var e=hT.default(xT.default.mark((function e(t){return xT.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.get(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:(f=hT.default(xT.default.mark((function e(t){var n;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({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 f.apply(this,arguments)})},{key:"mutate",value:(l=hT.default(xT.default.mark((function e(t,n,r){var i,a=this;return xT.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 l.apply(this,arguments)})},{key:"update",value:(c=hT.default(xT.default.mark((function e(t,n,r){return xT.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 c.apply(this,arguments)})},{key:"_putItemUnconditionally",value:(u=hT.default(xT.default.mark((function e(t,n,r){var i,a;return xT.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.get(a.key));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"_putItemWithIfMatch",value:(o=hT.default(xT.default.mark((function e(t,n,r){var i,a,s,o,u;return xT.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 WR({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(JT(i.data)))){e.next=26;break}return s=i.revision,e.prev=6,e.next=9,this._putItemToServer(t,a,s,r);case 9:return o=e.sent,u=o.item,this._handleItemMutated(u.key,u.url,u.last_event_id,u.revision,u.data,u.date_updated,u.date_expires,o.added,!1),e.abrupt("return",this.cache.get(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 o.apply(this,arguments)})},{key:"_putItemToServer",value:(s=hT.default(xT.default.mark((function e(t,n,r,i){var a,s,o,u,c;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new GT(this.links.items).pathSegment(t).build(),s={data:n},void 0!==i&&(s.ttl=i),e.prev=3,e.next=6,this.services.network.put(a,s,r);case 6:return o=e.sent,(u=o.body).data=n,u.date_updated=new Date(u.date_updated),c=201===o.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 s.apply(this,arguments)})},{key:"remove",value:(a=hT.default(xT.default.mark((function e(t){var n,r,i;return xT.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=JT(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 a.apply(this,arguments)})},{key:"queryItems",value:function(){var e=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new GT(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Key",t.key).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map((function(e){return e.date_updated=new Date(e.date_updated),s.cache.get(e.key)?s._handleItemMutated(e.key,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):s.cache.store(e.key,new WR(e),e.last_event_id),s.cache.get(e.key)})),a=r.body.meta,e.abrupt("return",new Paginator(i,(function(e){return s.queryItems({pageToken:e})}),a.previous_token,a.next_token));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:(i=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return KT((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,void 0,"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,s,o,u){if(this.shouldIgnoreEvent(e,n))ZT("SyncMapItem ",e," update skipped, current:",this.lastEventId,", remote:",n);else{this._updateRootDateUpdated(a);var c=this.cache.get(e);if(!c){var l=new WR({key:e,url:t,last_event_id:n,revision:r,data:i,date_updated:a,date_expires:s});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,o)}var f=JT(c.data);c.update(n,r,i,a),this.cache.store(e,c,n),void 0!==s&&c.updateDateExpires(s),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=hT.default(xT.default.mark((function e(t){var n,r;return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i,a;return xT.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=hT.default(xT.default.mark((function e(){return xT.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"}}]),h}(xR),$R=function(e){gT.default(f,e);var t,n,r,i,a,s,o,u,c,l=GR(f);function f(e){var t;return vT.default(this,f),(t=l.call(this)).syncMapImpl=e,t.syncMapImpl.attach(mT.default(t)),t}return yT.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 VR.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=hT.default(xT.default.mark((function e(t,n,r){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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:(o=hT.default(xT.default.mark((function e(t,n,r){return xT.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 o.apply(this,arguments)})},{key:"update",value:(s=hT.default(xT.default.mark((function e(t,n,r){return xT.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 s.apply(this,arguments)})},{key:"remove",value:(a=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t,n){return xT.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=hT.default(xT.default.mark((function e(){return xT.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(){CT.default(kT.default(f.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return VR.type}}]),f}(TR);function JR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}wT.default($R,"itemAdded","itemAdded"),wT.default($R,"itemUpdated","itemUpdated"),wT.default($R,"itemRemoved","itemRemoved"),wT.default($R,"removed","removed"),OT([rT.validateTypesAsync("string",rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[String,Object,Object]),PT("design:returntype",Promise)],$R.prototype,"set",null),OT([rT.validateTypesAsync("string"),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],$R.prototype,"get",null),OT([rT.validateTypesAsync("string","function",["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[String,Function,Object]),PT("design:returntype",Promise)],$R.prototype,"mutate",null),OT([rT.validateTypesAsync("string",rT.pureObject,["undefined",rT.objectSchema("item metadata",{ttl:[rT.nonNegativeInteger,"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[String,Object,Object]),PT("design:returntype",Promise)],$R.prototype,"update",null),OT([rT.validateTypesAsync("string"),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],$R.prototype,"remove",null),OT([rT.validateTypesAsync(["undefined",rT.objectSchema("query options",{from:["string","undefined"],pageSize:[rT.custom((function(e){return[HT(e),"a positive integer"]})),"undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],$R.prototype,"getItems",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],$R.prototype,"setTtl",null),OT([rT.validateTypesAsync("string",rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[String,Number]),PT("design:returntype",Promise)],$R.prototype,"setItemTtl",null);var KR=function(e){gT.default(a,e);var t,n,r,i=JR(a);function a(e,t,n){var r;return vT.default(this,a),(r=i.call(this,e,n)).descriptor=t,r}return yT.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=hT.default(xT.default.mark((function e(t){var n,r,i,a;return xT.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=hT.default(xT.default.mark((function e(t){var n,r;return xT.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=hT.default(xT.default.mark((function e(){return xT.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}(xR);OT([rT.validateTypesAsync(rT.pureObject),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],KR.prototype,"publishMessage",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],KR.prototype,"setTtl",null);var HR=function(e){gT.default(a,e);var t,n,r,i=JR(a);function a(e){var t;return vT.default(this,a),(t=i.call(this)).syncStreamImpl=e,t.syncStreamImpl.attach(mT.default(t)),t}return yT.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 KR.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(){return xT.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(){CT.default(kT.default(a.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return KR.type}}]),a}(TR);wT.default(HR,"messagePublished","messagePublished"),wT.default(HR,"removed","removed"),OT([rT.validateTypesAsync(rT.pureObject),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],HR.prototype,"publishMessage",null),OT([rT.validateTypesAsync(rT.nonNegativeInteger),PT("design:type",Function),PT("design:paramtypes",[Number]),PT("design:returntype",Promise)],HR.prototype,"setTtl",null);var YR=function e(t){vT.default(this,e),this.sdk="js",this.sdkVer=t,this.os=IT.os.family,this.osVer=IT.os.version,this.pl=IT.name,this.plVer=IT.version},QR=function(){function e(){vT.default(this,e),this.names=new Map,this.entities=new Map}return yT.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 XR(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}var ZR=function(e){gT.default(n,e);var t=XR(n);function n(e,r,i,a){var s;return vT.default(this,n),(s=t.call(this,r,i)).descriptor=e,s.cache=new FR,a&&a.forEach((function(e){s.cache.store(e.key,{key:e.key,value:e.data},e.revision)})),s}return yT.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))ZT("Item ".concat(e," update skipped, revision: ").concat(n));else{var r={key:e,value:t};this.cache.store(e,r,n),this.broadcastEventToListeners("itemUpdated",r)}}},{key:"handleItemRemoved",value:function(e,t){var n=null===t;this.shouldIgnoreEvent(e,t)?ZT("Item ".concat(e," delete skipped, revision: ").concat(t)):(this.cache.delete(e,t,n),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}(xR);function eC(e){return tC.apply(this,arguments)}function tC(){return tC=hT.default(xT.default.mark((function e(t){var n,r,i,a,s,o;return xT.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 s={query_string:r},a===nC.type&&(s.type=a),e.next=7,n.post(i,s,void 0,!0);case 7:return o=e.sent,e.abrupt("return",o.body);case 9:case"end":return e.stop()}}),e)}))),tC.apply(this,arguments)}var nC=function(e){gT.default(n,e);var t=XR(n);function n(e){var r;return vT.default(this,n),(r=t.call(this)).liveQueryImpl=e,r.liveQueryImpl.attach(mT.default(r)),r}return yT.default(n,[{key:"type",get:function(){return ZR.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){CT.default(kT.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 ZR.type}}]),n}(TR);wT.default(nC,"itemUpdated","itemUpdated"),wT.default(nC,"itemRemoved","itemRemoved");var rC=function(e){gT.default(i,e);var t,n,r=XR(i);function i(e){var t;return vT.default(this,i),t=r.call(this),wT.default(mT.default(t),"queryExpression",null),wT.default(mT.default(t),"items",{}),Object.assign(mT.default(t),e),t.updateIndexName(e.indexName),t}return yT.default(i,[{key:"type",get:function(){return i.type}},{key:"search",value:(n=hT.default(xT.default.mark((function e(t){var n=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.items={},e.abrupt("return",eC({network:this.network,uri:this.queryUri,queryString:t}).then((function(e){n.queryExpression=t,e.items&&e.items.forEach((function(e){n.items[e.key]=e.data})),n.emit("searchResult",n.getItems())})).catch((function(e){throw nR("Error '".concat(e.message,"' while executing query '").concat(t,"'")),n.queryExpression=null,e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"subscribe",value:(t=hT.default(xT.default.mark((function e(){return xT.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 GT(this.insightsUri).pathSegment(e).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),i}(jT);wT.default(rC,"searchResult","searchResult"),OT([rT.validateTypesAsync("string"),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],rC.prototype,"search",null),OT([rT.validateTypes(rT.nonEmptyString),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",void 0)],rC.prototype,"updateIndexName",null);function iC(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=kT.default(e);if(t){var i=kT.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return bT.default(this,n)}}function aC(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 sC(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?aC(Object(n),!0).forEach((function(t){wT.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aC(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var oC="data_sync",uC="3.1.0";function cC(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 sC(sC({},e),{},{mode:t})}return{mode:"create_new"}}var lC="com.twilio.rtd.cds.document",fC="com.twilio.rtd.cds.list",dC="com.twilio.rtd.cds.map",pC="twilio.sync.event",Client=function(e){gT.default(Client,e);var t,n,r,i,a,s,o,u,c,l,f,d,p,h,v,y=iC(Client);function Client(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(vT.default(this,Client),t=y.call(this),!e)throw new Error("Sync library needs a valid Twilio token to be passed");n.hasOwnProperty("logLevel")?XT(n.logLevel):XT("silent");var r=n.productId=n.productId||oC;n.clientMetadata=n.clientMetadata||{},n.clientMetadata.hasOwnProperty("type")||(n.clientMetadata.type="sync"),n.clientMetadata.hasOwnProperty("sdk")||(n.clientMetadata.sdk="JS",n.clientMetadata.sdkv=uC);var i=!n.twilsockClient;if(!n.initRegistrations){var a=new iT.InitRegistration(r);Client.populateInitRegistrations(a),n.initRegistrations=[a]}var s=n.twilsockClient=n.twilsockClient||new iT.Twilsock(e,r,n);s.on("tokenAboutToExpire",(function(e){return t.emit("tokenAboutToExpire",e)})),s.on("tokenExpired",(function(){return t.emit("tokenExpired")})),s.on("connectionError",(function(e){return t.emit("connectionError",e)})),s.on("stateChanged",(function(e){t.emit("connectionStateChanged",e),t.services.subscriptions.onConnectionStateChanged("connected"===e)})),s.on("message",(function(e,n){return t._routeMessage(e,n)}));var o=new lR(n),u=new gR(new YR(uC),o,s),c=new bR(o);return t.services={config:o,twilsock:s,network:u,storage:c,router:mT.default(t),subscriptions:null},t.services.subscriptions=new hR(t.services),t.entities=new QR,i&&s.connect(),t}return yT.default(Client,[{key:"_routeMessage",value:function(e,t){switch(ZT("Notification type:",e,"content:",t),e){case lC:case fC:case dC:this.services.subscriptions.acceptMessage(t,!1);break;case pC: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=hT.default(xT.default.mark((function e(){var t;return xT.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),tR("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=JT(n);e!==zR.type&&e!==$R.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=hT.default(xT.default.mark((function e(t,n){var r,i,a,s=arguments;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=s.length>2&&void 0!==s[2]&&s[2],n){e.next=3;break}throw new SyncError("Cannot get entity without id",404);case 3:return i=new GT(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=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(IR.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=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(zR.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=hT.default(xT.default.mark((function e(t){var n,r=arguments;return xT.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($R.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=hT.default(xT.default.mark((function e(t){return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(HR.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=hT.default(xT.default.mark((function e(t,n){var r,i;return xT.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(nC.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=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=cC(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,IR.type))){e.next=14;break}return e.abrupt("return",new IR(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(IR.type,n.id,r),a=new CR(this.services,r,(function(e,t,n){return s.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new IR(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return u.apply(this,arguments)})},{key:"map",value:(o=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=cC(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,$R.type))){e.next=14;break}return e.abrupt("return",new $R(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($R.type,n.id,r),a=new VR(this.services,r,(function(e,t,n){return s.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new $R(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return o.apply(this,arguments)})},{key:"list",value:(s=hT.default(xT.default.mark((function e(t){var n,r,i,a,s=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=cC(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,zR.type))){e.next=14;break}return e.abrupt("return",new zR(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(zR.type,n.id,r),a=new qR(this.services,r,(function(e,t,n){return s.removeFromCacheAndSession(e,t,n)})),a=this.entities.store(a),e.abrupt("return",new zR(a));case 43:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return s.apply(this,arguments)})},{key:"stream",value:(a=hT.default(xT.default.mark((function e(t){var n,r,i,a,s,o=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if("create_new"!==(n=cC(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,HR.type))){e.next=14;break}return e.abrupt("return",new HR(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(HR.type,n.id,r),a=function(e,t,n){return o.removeFromCacheAndSession(e,t,n)},s=new KR(this.services,r,a),s=this.entities.store(s),e.abrupt("return",new HR(s));case 44:case"end":return e.stop()}}),e,this,[[14,20],[26,32]])}))),function(e){return a.apply(this,arguments)})},{key:"shutdown",value:(i=hT.default(xT.default.mark((function e(){return xT.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=hT.default(xT.default.mark((function e(t){return xT.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=hT.default(xT.default.mark((function e(t,n){var r,i,a,s,o,u=this;return xT.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return r=new GT(this.services.config.insightsUri).pathSegment(t).pathSegment("Items").build(),e.next=5,eC({network:this.services.network,uri:r,queryString:n,type:nC.type});case 5:return i=e.sent,(a=this.getCached(i.query_id,nC.type))||((s=this._getLiveQuery(i.query_id))||(s={indexName:t,queryExpression:n,sid:i.query_id,queryUri:r,last_event_id:i.last_event_id}),o=function(e,t,n){return u.removeFromCacheAndSession(e,t,n)},a=new ZR(s,this.services,o,i.items)),this.storeRootInSessionCache(nC.type,i.query_id,a.liveQueryDescriptor),a=this.entities.store(a),e.abrupt("return",new nC(a));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"instantQuery",value:(t=hT.default(xT.default.mark((function e(t){var n,r=this;return xT.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 rC({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([pC,lC,fC,dC])}},{key:"version",get:function(){return uC}}]),Client}(jT);wT.default(Client,"connectionStateChanged","connectionStateChanged"),wT.default(Client,"connectionError","connectionError"),wT.default(Client,"tokenAboutToExpire","tokenAboutToExpire"),wT.default(Client,"tokenExpired","tokenExpired"),OT([rT.validateTypesAsync(["undefined","string",rT.objectSchema("open document options",{id:["string","undefined"],mode:[rT.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[rT.nonNegativeInteger,"undefined"],data:[rT.pureObject,"undefined",rT.literal(null)]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],Client.prototype,"document",null),OT([rT.validateTypesAsync(["undefined","string",rT.objectSchema("open map options",{id:["string","undefined"],mode:[rT.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[rT.nonNegativeInteger,"undefined"],data:[rT.pureObject,"undefined",rT.literal(null)],includeItems:["boolean","undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],Client.prototype,"map",null),OT([rT.validateTypesAsync(["undefined","string",rT.objectSchema("open list options",{id:["string","undefined"],mode:[rT.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[rT.nonNegativeInteger,"undefined"],data:[rT.pureObject,"undefined",rT.literal(null)],purpose:["string","undefined"],context:[rT.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],Client.prototype,"list",null),OT([rT.validateTypesAsync(["undefined","string",rT.objectSchema("open stream options",{id:["string","undefined"],mode:[rT.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[rT.nonNegativeInteger,"undefined"],data:[rT.pureObject,"undefined",rT.literal(null)]})]),PT("design:type",Function),PT("design:paramtypes",[Object]),PT("design:returntype",Promise)],Client.prototype,"stream",null),OT([rT.validateTypesAsync(rT.nonEmptyString),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],Client.prototype,"updateToken",null),OT([rT.validateTypesAsync(rT.nonEmptyString,"string"),PT("design:type",Function),PT("design:paramtypes",[String,String]),PT("design:returntype",Promise)],Client.prototype,"liveQuery",null),OT([rT.validateTypesAsync(rT.nonEmptyString),PT("design:type",Function),PT("design:paramtypes",[String]),PT("design:returntype",Promise)],Client.prototype,"instantQuery",null),$E.Client=Client,$E.InsightsItem=function e(){vT.default(this,e)},$E.InstantQuery=rC,$E.LiveQuery=nC,$E.Paginator=Paginator;var hC=$E.SyncClient=Client,vC=$E.SyncDocument=IR;$E.SyncList=zR,$E.SyncListItem=OR;var yC=$E.SyncMap=$R;$E.SyncMapItem=WR,$E.SyncStream=HR;var mC,gC={},bC=zS,kC=function(e){if(bC(e))throw TypeError("The method doesn't accept regular expressions");return e},wC=he("match"),xC=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[wC]=!1,"/./"[e](t)}catch(e){}}return!1},_C=Cn,SC=s.f,EC=Dt,TC=Er,RC=kC,CC=w,IC=xC,OC="".startsWith,PC=Math.min,AC=IC("startsWith");_C({target:"String",proto:!0,forced:!!(AC||(mC=SC(String.prototype,"startsWith"),!mC||mC.writable))&&!AC},{startsWith:function(e){var t=TC(CC(this));RC(e);var n=EC(PC(arguments.length>1?arguments[1]:void 0,t.length)),r=TC(e);return OC?OC.call(t,r,n):t.slice(n,n+r.length)===r}});var jC=o,MC=he("iterator"),LC=!jC((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[MC]||"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})),NC=2147483647,UC=/[^\0-\u007E]/,DC=/[.\u3002\uFF0E\uFF61]/g,FC="Overflow: input needs wider integers to process",BC=Math.floor,qC=String.fromCharCode,zC=function(e){return e+22+75*(e<26)},WC=function(e,t,n){var r=0;for(e=n?BC(e/700):e>>1,e+=BC(e/t);e>455;r+=36)e=BC(e/35);return BC(r+36*e/(e+38))},GC=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,s=0,o=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=NC;for(n=0;n<e.length;n++)(r=e[n])>=a&&r<l&&(l=r);var f=c+1;if(l-a>BC((NC-s)/f))throw RangeError(FC);for(s+=(l-a)*f,a=l,n=0;n<e.length;n++){if((r=e[n])<a&&++s>NC)throw RangeError(FC);if(r==a){for(var d=s,p=36;;p+=36){var h=p<=o?1:p>=o+26?26:p-o;if(d<h)break;var v=d-h,y=36-h;t.push(qC(zC(h+v%y))),d=BC(v/y)}t.push(qC(zC(d))),o=WC(s,f,c==u),s=0,++c}}++s,++a}return t.join("")},VC=Cn,$C=C,JC=LC,KC=Ke.exports,HC=hs,YC=An,QC=Yl,XC=_t,ZC=Ss,eI=te,tI=Fr,nI=Va,rI=Fe,iI=E,aI=Er,sI=nr,oI=v,uI=Ns,cI=js,lI=he,fI=$C("fetch"),dI=$C("Request"),pI=dI&&dI.prototype,hI=$C("Headers"),vI=lI("iterator"),yI="URLSearchParams",mI="URLSearchParamsIterator",gI=XC.set,bI=XC.getterFor(yI),kI=XC.getterFor(mI),wI=/\+/g,xI=Array(4),_I=function(e){return xI[e-1]||(xI[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},SI=function(e){try{return decodeURIComponent(e)}catch(t){return e}},EI=function(e){var t=e.replace(wI," "),n=4;try{return decodeURIComponent(t)}catch(e){for(;n;)t=t.replace(_I(n--),SI);return t}},TI=/[!'()~]|%20/g,RI={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},CI=function(e){return RI[e]},II=function(e){return encodeURIComponent(e).replace(TI,CI)},OI=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:EI(r.shift()),value:EI(r.join("="))}))},PI=function(e){this.entries.length=0,OI(this.entries,e)},AI=function(e,t){if(e<t)throw TypeError("Not enough arguments")},jI=QC((function(e,t){gI(this,{type:mI,iterator:uI(bI(e).entries),kind:t})}),"Iterator",(function(){var e=kI(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})),MI=function(){ZC(this,MI,yI);var e,t,n,r,i,a,s,o,u,c=arguments.length>0?arguments[0]:void 0,l=this,f=[];if(gI(l,{type:yI,entries:f,updateURL:function(){},updateSearchParams:PI}),void 0!==c)if(iI(c))if("function"==typeof(e=cI(c)))for(n=(t=uI(c,e)).next;!(r=n.call(t)).done;){if((s=(a=(i=uI(rI(r.value))).next).call(i)).done||(o=a.call(i)).done||!a.call(i).done)throw TypeError("Expected sequence with length 2");f.push({key:aI(s.value),value:aI(o.value)})}else for(u in c)eI(c,u)&&f.push({key:u,value:aI(c[u])});else OI(f,"string"==typeof c?"?"===c.charAt(0)?c.slice(1):c:aI(c))},LI=MI.prototype;if(HC(LI,{append:function(e,t){AI(arguments.length,2);var n=bI(this);n.entries.push({key:aI(e),value:aI(t)}),n.updateURL()},delete:function(e){AI(arguments.length,1);for(var t=bI(this),n=t.entries,r=aI(e),i=0;i<n.length;)n[i].key===r?n.splice(i,1):i++;t.updateURL()},get:function(e){AI(arguments.length,1);for(var t=bI(this).entries,n=aI(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){AI(arguments.length,1);for(var t=bI(this).entries,n=aI(e),r=[],i=0;i<t.length;i++)t[i].key===n&&r.push(t[i].value);return r},has:function(e){AI(arguments.length,1);for(var t=bI(this).entries,n=aI(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){AI(arguments.length,1);for(var n,r=bI(this),i=r.entries,a=!1,s=aI(e),o=aI(t),u=0;u<i.length;u++)(n=i[u]).key===s&&(a?i.splice(u--,1):(a=!0,n.value=o));a||i.push({key:s,value:o}),r.updateURL()},sort:function(){var e,t,n,r=bI(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=bI(this).entries,r=tI(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 jI(this,"keys")},values:function(){return new jI(this,"values")},entries:function(){return new jI(this,"entries")}},{enumerable:!0}),KC(LI,vI,LI.entries),KC(LI,"toString",(function(){for(var e,t=bI(this).entries,n=[],r=0;r<t.length;)e=t[r++],n.push(II(e.key)+"="+II(e.value));return n.join("&")}),{enumerable:!0}),YC(MI,yI),VC({global:!0,forced:!JC},{URLSearchParams:MI}),!JC&&"function"==typeof hI){var NI=function(e){if(iI(e)){var t,n=e.body;if(nI(n)===yI)return(t=e.headers?new hI(e.headers):new hI).has("content-type")||t.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),sI(e,{body:oI(0,String(n)),headers:oI(0,t)})}return e};if("function"==typeof fI&&VC({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return fI(e,arguments.length>1?NI(arguments[1]):{})}}),"function"==typeof dI){var UI=function(e){return ZC(this,UI,"Request"),new dI(e,arguments.length>1?NI(arguments[1]):{})};pI.constructor=UI,UI.prototype=pI,VC({global:!0,forced:!0},{Request:UI})}}var DI,FI={URLSearchParams:MI,getState:bI},BI=Cn,qI=u,zI=LC,WI=a,GI=Wn,VI=Ke.exports,$I=Ss,JI=te,KI=GE,HI=kl,YI=Il.codeAt,QI=function(e){var t,n,r=[],i=e.toLowerCase().replace(DC,".").split(".");for(t=0;t<i.length;t++)n=i[t],r.push(UC.test(n)?"xn--"+GC(n):n);return r.join(".")},XI=Er,ZI=An,eO=FI,tO=_t,nO=WI.URL,rO=eO.URLSearchParams,iO=eO.getState,aO=tO.set,sO=tO.getterFor("URL"),oO=Math.floor,uO=Math.pow,cO="Invalid scheme",lO="Invalid host",fO="Invalid port",dO=/[A-Za-z]/,pO=/[\d+-.A-Za-z]/,hO=/\d/,vO=/^0x/i,yO=/^[0-7]+$/,mO=/^\d+$/,gO=/^[\dA-Fa-f]+$/,bO=/[\0\t\n\r #%/:<>?@[\\\]^|]/,kO=/[\0\t\n\r #/:<>?@[\\\]^|]/,wO=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,xO=/[\t\n\r]/g,_O=function(e,t){var n,r,i;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return lO;if(!(n=EO(t.slice(1,-1))))return lO;e.host=n}else if(jO(e)){if(t=QI(t),bO.test(t))return lO;if(null===(n=SO(t)))return lO;e.host=n}else{if(kO.test(t))return lO;for(n="",r=HI(t),i=0;i<r.length;i++)n+=PO(r[i],RO);e.host=n}},SO=function(e){var t,n,r,i,a,s,o,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=vO.test(i)?16:8,i=i.slice(8==a?1:2)),""===i)s=0;else{if(!(10==a?mO:8==a?yO:gO).test(i))return e;s=parseInt(i,a)}n.push(s)}for(r=0;r<t;r++)if(s=n[r],r==t-1){if(s>=uO(256,5-t))return null}else if(s>255)return null;for(o=n.pop(),r=0;r<n.length;r++)o+=n[r]*uO(256,3-r);return o},EO=function(e){var t,n,r,i,a,s,o,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&&gO.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(!hO.test(d()))return;for(;hO.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(s=c-l,c=7;0!=c&&s>0;)o=u[c],u[c--]=u[l+s-1],u[l+--s]=o;else if(8!=c)return;return u},TO=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=oO(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},RO={},CO=KI({},RO,{" ":1,'"':1,"<":1,">":1,"`":1}),IO=KI({},CO,{"#":1,"?":1,"{":1,"}":1}),OO=KI({},IO,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),PO=function(e,t){var n=YI(e,0);return n>32&&n<127&&!JI(t,e)?e:encodeURIComponent(e)},AO={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jO=function(e){return JI(AO,e.scheme)},MO=function(e){return""!=e.username||""!=e.password},LO=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},NO=function(e,t){var n;return 2==e.length&&dO.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)},UO=function(e){var t;return e.length>1&&NO(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},DO=function(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&NO(t[0],!0)||t.pop()},FO=function(e){return"."===e||"%2e"===e.toLowerCase()},BO={},qO={},zO={},WO={},GO={},VO={},$O={},JO={},KO={},HO={},YO={},QO={},XO={},ZO={},eP={},tP={},nP={},rP={},iP={},aP={},sP={},oP=function(e,t,n,r){var i,a,s,o,u,c=n||BO,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(wO,"")),t=t.replace(xO,""),i=HI(t);l<=i.length;){switch(a=i[l],c){case BO:if(!a||!dO.test(a)){if(n)return cO;c=zO;continue}f+=a.toLowerCase(),c=qO;break;case qO:if(a&&(pO.test(a)||"+"==a||"-"==a||"."==a))f+=a.toLowerCase();else{if(":"!=a){if(n)return cO;f="",c=zO,l=0;continue}if(n&&(jO(e)!=JI(AO,f)||"file"==f&&(MO(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=f,n)return void(jO(e)&&AO[e.scheme]==e.port&&(e.port=null));f="","file"==e.scheme?c=ZO:jO(e)&&r&&r.scheme==e.scheme?c=WO:jO(e)?c=JO:"/"==i[l+1]?(c=GO,l++):(e.cannotBeABaseURL=!0,e.path.push(""),c=iP)}break;case zO:if(!r||r.cannotBeABaseURL&&"#"!=a)return cO;if(r.cannotBeABaseURL&&"#"==a){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,c=sP;break}c="file"==r.scheme?ZO:VO;continue;case WO:if("/"!=a||"/"!=i[l+1]){c=VO;continue}c=KO,l++;break;case GO:if("/"==a){c=HO;break}c=rP;continue;case VO:if(e.scheme=r.scheme,a==DI)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&&jO(e))c=$O;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=aP;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=rP;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=sP}break;case $O:if(!jO(e)||"/"!=a&&"\\"!=a){if("/"!=a){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,c=rP;continue}c=HO}else c=KO;break;case JO:if(c=KO,"/"!=a||"/"!=f.charAt(l+1))continue;l++;break;case KO:if("/"!=a&&"\\"!=a){c=HO;continue}break;case HO:if("@"==a){d&&(f="%40"+f),d=!0,s=HI(f);for(var v=0;v<s.length;v++){var y=s[v];if(":"!=y||h){var m=PO(y,OO);h?e.password+=m:e.username+=m}else h=!0}f=""}else if(a==DI||"/"==a||"?"==a||"#"==a||"\\"==a&&jO(e)){if(d&&""==f)return"Invalid authority";l-=HI(f).length+1,f="",c=YO}else f+=a;break;case YO:case QO:if(n&&"file"==e.scheme){c=tP;continue}if(":"!=a||p){if(a==DI||"/"==a||"?"==a||"#"==a||"\\"==a&&jO(e)){if(jO(e)&&""==f)return lO;if(n&&""==f&&(MO(e)||null!==e.port))return;if(o=_O(e,f))return o;if(f="",c=nP,n)return;continue}"["==a?p=!0:"]"==a&&(p=!1),f+=a}else{if(""==f)return lO;if(o=_O(e,f))return o;if(f="",c=XO,n==QO)return}break;case XO:if(!hO.test(a)){if(a==DI||"/"==a||"?"==a||"#"==a||"\\"==a&&jO(e)||n){if(""!=f){var g=parseInt(f,10);if(g>65535)return fO;e.port=jO(e)&&g===AO[e.scheme]?null:g,f=""}if(n)return;c=nP;continue}return fO}f+=a;break;case ZO:if(e.scheme="file","/"==a||"\\"==a)c=eP;else{if(!r||"file"!=r.scheme){c=rP;continue}if(a==DI)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=aP;else{if("#"!=a){UO(i.slice(l).join(""))||(e.host=r.host,e.path=r.path.slice(),DO(e)),c=rP;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",c=sP}}break;case eP:if("/"==a||"\\"==a){c=tP;break}r&&"file"==r.scheme&&!UO(i.slice(l).join(""))&&(NO(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),c=rP;continue;case tP:if(a==DI||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&NO(f))c=rP;else if(""==f){if(e.host="",n)return;c=nP}else{if(o=_O(e,f))return o;if("localhost"==e.host&&(e.host=""),n)return;f="",c=nP}continue}f+=a;break;case nP:if(jO(e)){if(c=rP,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=DI&&(c=rP,"/"!=a))continue}else e.fragment="",c=sP;else e.query="",c=aP;break;case rP:if(a==DI||"/"==a||"\\"==a&&jO(e)||!n&&("?"==a||"#"==a)){if(".."===(u=(u=f).toLowerCase())||"%2e."===u||".%2e"===u||"%2e%2e"===u?(DO(e),"/"==a||"\\"==a&&jO(e)||e.path.push("")):FO(f)?"/"==a||"\\"==a&&jO(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&NO(f)&&(e.host&&(e.host=""),f=f.charAt(0)+":"),e.path.push(f)),f="","file"==e.scheme&&(a==DI||"?"==a||"#"==a))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==a?(e.query="",c=aP):"#"==a&&(e.fragment="",c=sP)}else f+=PO(a,IO);break;case iP:"?"==a?(e.query="",c=aP):"#"==a?(e.fragment="",c=sP):a!=DI&&(e.path[0]+=PO(a,RO));break;case aP:n||"#"!=a?a!=DI&&("'"==a&&jO(e)?e.query+="%27":e.query+="#"==a?"%23":PO(a,RO)):(e.fragment="",c=sP);break;case sP:a!=DI&&(e.fragment+=PO(a,CO))}l++}},uP=function(e){var t,n,r=$I(this,uP,"URL"),i=arguments.length>1?arguments[1]:void 0,a=XI(e),s=aO(r,{type:"URL"});if(void 0!==i)if(i instanceof uP)t=sO(i);else if(n=oP(t={},XI(i)))throw TypeError(n);if(n=oP(s,a,null,t))throw TypeError(n);var o=s.searchParams=new rO,u=iO(o);u.updateSearchParams(s.query),u.updateURL=function(){s.query=String(o)||null},qI||(r.href=lP.call(r),r.origin=fP.call(r),r.protocol=dP.call(r),r.username=pP.call(r),r.password=hP.call(r),r.host=vP.call(r),r.hostname=yP.call(r),r.port=mP.call(r),r.pathname=gP.call(r),r.search=bP.call(r),r.searchParams=kP.call(r),r.hash=wP.call(r))},cP=uP.prototype,lP=function(){var e=sO(this),t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,s=e.path,o=e.query,u=e.fragment,c=t+":";return null!==i?(c+="//",MO(e)&&(c+=n+(r?":"+r:"")+"@"),c+=TO(i),null!==a&&(c+=":"+a)):"file"==t&&(c+="//"),c+=e.cannotBeABaseURL?s[0]:s.length?"/"+s.join("/"):"",null!==o&&(c+="?"+o),null!==u&&(c+="#"+u),c},fP=function(){var e=sO(this),t=e.scheme,n=e.port;if("blob"==t)try{return new uP(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&jO(e)?t+"://"+TO(e.host)+(null!==n?":"+n:""):"null"},dP=function(){return sO(this).scheme+":"},pP=function(){return sO(this).username},hP=function(){return sO(this).password},vP=function(){var e=sO(this),t=e.host,n=e.port;return null===t?"":null===n?TO(t):TO(t)+":"+n},yP=function(){var e=sO(this).host;return null===e?"":TO(e)},mP=function(){var e=sO(this).port;return null===e?"":String(e)},gP=function(){var e=sO(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},bP=function(){var e=sO(this).query;return e?"?"+e:""},kP=function(){return sO(this).searchParams},wP=function(){var e=sO(this).fragment;return e?"#"+e:""},xP=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(qI&&GI(cP,{href:xP(lP,(function(e){var t=sO(this),n=XI(e),r=oP(t,n);if(r)throw TypeError(r);iO(t.searchParams).updateSearchParams(t.query)})),origin:xP(fP),protocol:xP(dP,(function(e){var t=sO(this);oP(t,XI(e)+":",BO)})),username:xP(pP,(function(e){var t=sO(this),n=HI(XI(e));if(!LO(t)){t.username="";for(var r=0;r<n.length;r++)t.username+=PO(n[r],OO)}})),password:xP(hP,(function(e){var t=sO(this),n=HI(XI(e));if(!LO(t)){t.password="";for(var r=0;r<n.length;r++)t.password+=PO(n[r],OO)}})),host:xP(vP,(function(e){var t=sO(this);t.cannotBeABaseURL||oP(t,XI(e),YO)})),hostname:xP(yP,(function(e){var t=sO(this);t.cannotBeABaseURL||oP(t,XI(e),QO)})),port:xP(mP,(function(e){var t=sO(this);LO(t)||(""==(e=XI(e))?t.port=null:oP(t,e,XO))})),pathname:xP(gP,(function(e){var t=sO(this);t.cannotBeABaseURL||(t.path=[],oP(t,XI(e),nP))})),search:xP(bP,(function(e){var t=sO(this);""==(e=XI(e))?t.query=null:("?"==e.charAt(0)&&(e=e.slice(1)),t.query="",oP(t,e,aP)),iO(t.searchParams).updateSearchParams(t.query)})),searchParams:xP(kP),hash:xP(wP,(function(e){var t=sO(this);""!=(e=XI(e))?("#"==e.charAt(0)&&(e=e.slice(1)),t.fragment="",oP(t,e,sP)):t.fragment=null}))}),VI(cP,"toJSON",(function(){return lP.call(this)}),{enumerable:!0}),VI(cP,"toString",(function(){return lP.call(this)}),{enumerable:!0}),nO){var _P=nO.createObjectURL,SP=nO.revokeObjectURL;_P&&VI(uP,"createObjectURL",(function(e){return _P.apply(nO,arguments)})),SP&&VI(uP,"revokeObjectURL",(function(e){return SP.apply(nO,arguments)}))}ZI(uP,"URL"),BI({global:!0,forced:!zI,sham:!qI},{URL:uP}),function(e){var t=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};Object.defineProperty(e,"__esModule",{value:!0});var n=pv.exports,r=dv.exports,i=hv.exports,a=yv.exports,s=gv.exports,o=aE.exports,u=Iy.exports,c=zg.exports,l=Wg,f=bh.exports,d=Sf.exports,p=ng,h=gh;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 m=v(n),g=v(r),b=v(i),k=v(a),w=v(s),x=v(o),_=v(u),S=v(c),E=v(l),T=v(f),R=y(d),C={exports:{}},I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(I){var O=new Uint8Array(16);C.exports=function(){return I(O),O}}else{var P=new Array(16);C.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,N=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("")},U=C.exports,D=N,F=0,B=0;var q=function(e,t,n){var r=t&&n||0,i=t||[],a=(e=e||{}).node||M,s=void 0!==e.clockseq?e.clockseq:L;if(null==a||null==s){var o=U();null==a&&(a=M=[1|o[0],o[1],o[2],o[3],o[4],o[5]]),null==s&&(s=L=16383&(o[6]<<8|o[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&&(s=s+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=s;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++]=s>>>8|128,i[r++]=255&s;for(var p=0;p<6;++p)i[r+p]=a[p];return t||D(i)},z=C.exports,W=N;var G=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,$=G,J=$;J.v1=V,J.v4=$;var K=J;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=w.default(e);if(t){var i=w.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return k.default(this,n)}}var Y=function(e){b.default(n,e);var t=H(n);function n(e){var r;m.default(this,n);var i,a=K.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 g.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}(x.default(Promise));function Q(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":T.default(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}function X(e,t){if("object"===("undefined"==typeof Reflect?"undefined":T.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))}_.default(Y,"cancellationMap",new Map);var ee=function(){function e(t){m.default(this,e),_.default(this,"prefix",""),this.prefix=null!=t&&t.length>0?t+" ":""}return g.default(e,[{key:"setLevel",value:function(e){R.setLevel(e)}},{key:"trace",value:function(){if(R.getLevel()==R.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];R.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];R.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];R.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];R.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];R.error.apply(null,Z(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){R.setLevel(e)}},{key:"trace",value:function(){if(R.getLevel()==R.levels.TRACE){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];R.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];R.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];R.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];R.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];R.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,s,o,u,c,l;m.default(this,e);var f=null!==(a=null!==(s=i.MCS)&&void 0!==s?s:i)&&void 0!==a?a:{};this.region=null!==(o=null!==(u=f.region)&&void 0!==u?u:i.region)&&void 0!==o?o:"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 g.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){m.default(this,Media),this.config=e,this.network=t,this._update(n)}return g.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,s;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:s=t.sent,e._update(s.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=w.default(e);if(t){var i=w.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return k.default(this,n)}}var ie=function(e){b.default(n,e);var t=re(n);function n(e,r,i,a,s){var o;return m.default(this,n),(o=t.call(this,e)).code=r,o.body=i,o.status=a,o.headers=s,o}return g.default(n)}(x.default(Error)),ae=t.XMLHttpRequest||{};var se,oe=function(){function e(){m.default(this,e)}return g.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,s){var o=new ae,u=!1;for(var c in s((function(){o.abort(),u=!0})),o.open(e,t,!0),o.onreadystatechange=function(){if(4===o.readyState&&!u){var e,t=(e=o.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}}(o);if(200<=o.status&&o.status<300)i({status:o.status,headers:t,body:n});else{var r,s,c=null!==(r=o.statusText)&&void 0!==r?r:"NONE";if("string"==typeof n)if(n&&1===n.split("\n",2).length)s=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(" ");s=(null==f?void 0:f.length)>2?null==f?void 0:f.slice(1).join(" "):""}else s=JSON.stringify(n);var d="".concat(o.status,": [").concat(c,"] ").concat(s);a(new ie(d,o.status,n,c,t))}}},n)o.setRequestHeader(c,n[c]),"Content-Type"===c&&"application/json"===n[c]&&(r=JSON.stringify(r));o.send(r)}))}}]),e}(),ue=ee.scope("Network"),ce=function(){function e(t,n){m.default(this,e),this.config=t,this.transport=n}return g.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,s){var o,u;return E.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:o=new p.Retrier(n.backoffConfig()),u=[502,503,504],t&&u.push(429),s((function(){o.cancel(),o.removeAllListeners()})),o.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(),s((function(){n.cancel(),o.cancel(),o.removeAllListeners()})),t.next=5,n;case 5:r=t.sent,o.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?o.failed(t.t0):(o.removeAllListeners(),o.cancel(),a(t.t0));case 12:case"end":return t.stop()}}),t,null,[[0,9]])})))),o.on("succeeded",(function(e){i(e)})),o.on("cancelled",(function(e){return a(e)})),o.on("failed",(function(e){return a(e)})),o.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 s,o,u;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s={"X-Twilio-Token":t.config.token},o=t.executeWithRetry((function(){return t.transport.get(e,s)}),t.retryWhenThrottled()),ue.trace("sending GET request to ",e," headers ",s),a((function(){return o.cancel()})),n.prev=4,n.next=7,o;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 s=this,o={"X-Twilio-Token":this.config.token};"undefined"!=typeof FormData&&r instanceof FormData||!i||Object.assign(o,{"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=s.transport.post(u.href,o,r),c((function(){return l.cancel()})),ue.trace("sending POST request to ".concat(e," with headers ").concat(o)),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=(se=function(){function Client(e,t,n){var r,i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};m.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 oe,this.transport=this.options.transport,this.network=new ce(this.config,this.transport)}return g.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 s,o;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s=t.network.get("".concat(t.config.mediaUrl,"/").concat(e)),a((function(){return s.cancel()})),n.prev=2,n.next=5,s;case 5:o=n.sent,r(new Media(t.config,t.network,o.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(s,o,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,s(new Media(i.config,i.network,l.body)),a.next=12;break;case 9:a.prev=9,a.t0=a.catch(2),o(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,s){var o,u;return E.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=n.network.post(n.config.mediaUrl,null!=t?t:"media",e),s((function(){return o.cancel()})),r.prev=2,r.next=5,o;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 s,o,u,c;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s={command:"get",list:e.map((function(e){return{media_sid:e}}))},o=t.network.post("".concat(t.config.mediaSetUrl),null,s,"application/json"),a((function(){return o.cancel()})),n.prev=3,n.next=6,o;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 s,o,u,c;return E.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return s={command:"get",list:e.map((function(e){return{media_sid:e}}))},o=t.network.post("".concat(t.config.mediaSetUrl),null,s,"application/json"),a((function(){return o.cancel()})),n.prev=3,n.next=6,o;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}(),_.default(se,"version","0.6.11-rc.8"),se),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}(gC);var EP=_s,TP="ArrayBuffer",RP=pw.ArrayBuffer;function CP(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)}}Cn({global:!0,forced:a.ArrayBuffer!==RP},{ArrayBuffer:RP}),EP(TP);var IP=If.scope("Participant"),Participant=function(e){Oa(Participant,e);var t,n,r,i=CP(Participant);function Participant(e,t,n,r,a){var s,o,u;if(Ua(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,IP),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!==(s=e.roleSid)&&void 0!==s?s:"",lastReadMessageIndex:Number.isInteger(e.lastConsumedMessageIndex)?e.lastConsumedMessageIndex:null,lastReadTimestamp:e.lastConsumptionTimestamp?vh(e.lastConsumptionTimestamp):null,type:e.type||"chat",userInfo:e.userInfo,bindings:null!==(o=e.bindings)&&void 0!==o?o:{}},!e.identity&&!e.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return u}return Na(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,IP);e.attributes&&!lm(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&&!lm(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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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}(um);function OP(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([by(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],Participant.prototype,"updateAttributes",null);var PP=If.scope("Participants"),AP=function(e){Oa(l,e);var t,n,r,i,a,s,o,u,c=OP(l);function l(e,t,n,r){var i;return Ua(this,l),Ma(Ca(i=c.call(this)),"rosterEntityPromise",null),i.conversation=e,i.participants=t,i.links=n,i.services=r,i}return Na(l,[{key:"unsubscribe",value:(u=Ra(Gc.mark((function e(){return Gc.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(yC.itemAdded,(function(e){PP.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(yC.itemRemoved,(function(e){PP.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(yC.itemUpdated,(function(e){PP.debug(t.conversation.sid+" itemUpdated: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).catch((function(e){return PP.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&&PP.error("Failed to get roster object for conversation",t.conversation.sid,e),PP.debug("ERROR: Failed to get roster object for conversation",t.conversation.sid,e),e}))}},{key:"upsertParticipantFromResponse",value:(o=Ra(Gc.mark((function e(t){var n,r,i,a,s,o,u,c;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.sid,i=t.attributes,a=t.date_created,s=t.date_updated,o=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(s),identity:o,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 o.apply(this,arguments)})},{key:"upsertParticipant",value:(s=Ra(Gc.mark((function e(t,n){var r,i,a=this;return Gc.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 s.apply(this,arguments)})},{key:"getParticipants",value:(a=Ra(Gc.mark((function e(){var t=this;return Gc.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=Ra(Gc.mark((function e(t){var n=this;return Gc.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=Ra(Gc.mark((function e(t){var n,r=this;return Gc.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=Ra(Gc.mark((function e(t,n){return Gc.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=Ra(Gc.mark((function e(t,n){var r,i,a,s,o=arguments;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=o.length>2&&void 0!==o[2]?o[2]:{},s=o.length>3&&void 0!==o[3]?o[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==s||null===(r=s.email)||void 0===r?void 0:r.name,level:null==s||null===(i=s.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}(um),jP=Cn,MP=Nn,LP=X,NP=Dt,UP=Er,DP=o,FP=eS,BP=ns,qP=nS,zP=rS,WP=N,GP=aS,VP=[],$P=VP.sort,JP=DP((function(){VP.sort(void 0)})),KP=DP((function(){VP.sort(null)})),HP=BP("sort"),YP=!DP((function(){if(WP)return WP<70;if(!(qP&&qP>3)){if(zP)return!0;if(GP)return GP<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++)VP.push({k:t+r,v:n})}for(VP.sort((function(e,t){return t.v-e.v})),r=0;r<VP.length;r++)t=VP[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));jP({target:"Array",proto:!0,forced:JP||!KP||!HP||!YP},{sort:function(e){void 0!==e&&MP(e);var t=LP(this);if(YP)return void 0===e?$P.call(t):$P.call(t,e);var n,r,i=[],a=NP(t.length);for(r=0;r<a;r++)r in t&&i.push(t[r]);for(i=FP(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:UP(t)>UP(n)?1:-1}}(e)),n=i.length,r=0;r<n;)t[r]=i[r++];for(;r<a;)delete t[r++];return t}});var QP=kC,XP=w,ZP=Er;Cn({target:"String",proto:!0,forced:!xC("includes")},{includes:function(e){return!!~ZP(XP(this)).indexOf(ZP(QP(e)),arguments.length>1?arguments[1]:void 0)}});var eA=hs,tA=hm.exports.getWeakData,nA=Fe,rA=E,iA=Ss,aA=Js,sA=te,oA=_t.set,uA=_t.getterFor,cA=Xr.find,lA=Xr.findIndex,fA=0,dA=function(e){return e.frozen||(e.frozen=new pA)},pA=function(){this.entries=[]},hA=function(e,t){return cA(e.entries,(function(e){return e[0]===t}))};pA.prototype={get:function(e){var t=hA(this,e);if(t)return t[1]},has:function(e){return!!hA(this,e)},set:function(e,t){var n=hA(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=lA(this.entries,(function(t){return t[0]===e}));return~t&&this.entries.splice(t,1),!!~t}};var vA={getConstructor:function(e,t,n,r){var i=e((function(e,a){iA(e,i,t),oA(e,{type:t,id:fA++,frozen:void 0}),null!=a&&aA(a,e[r],{that:e,AS_ENTRIES:n})})),a=uA(t),s=function(e,t,n){var r=a(e),i=tA(nA(t),!0);return!0===i?dA(r).set(t,n):i[r.id]=n,e};return eA(i.prototype,{delete:function(e){var t=a(this);if(!rA(e))return!1;var n=tA(e);return!0===n?dA(t).delete(e):n&&sA(n,t.id)&&delete n[t.id]},has:function(e){var t=a(this);if(!rA(e))return!1;var n=tA(e);return!0===n?dA(t).has(e):n&&sA(n,t.id)}}),eA(i.prototype,n?{get:function(e){var t=a(this);if(rA(e)){var n=tA(e);return!0===n?dA(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}};zm("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),vA);var Media=function(){function Media(e,t){var n;Ua(this,Media),Ma(this,"mcsMedia",null),this.services=t,e instanceof gC.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 Na(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 gC.CancellablePromise(function(){var t=Ra(Gc.mark((function t(n,r,i){var a,s,o,u;return Gc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=e.mcsMedia?void 0:e._fetchMcsMedia(),o=null===(a=e.mcsMedia)||void 0===a?void 0:a.getContentUrl(),i((function(){s&&s.cancel(),o&&o.cancel()})),t.prev=3,o){t.next=9;break}return t.next=7,s;case 7:u=t.sent,o=null==u?void 0:u.getContentUrl();case 9:if(t.t0=n,!o){t.next=16;break}return t.next=13,o;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 gC.CancellablePromise(function(){var t=Ra(Gc.mark((function t(n,r,i){var a;return Gc.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){Ua(this,AggregatedDeliveryReceipt),this.state=e}return Na(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,s=this.failed===e.failed;return t&&n&&r&&i&&a&&s}}]),AggregatedDeliveryReceipt}(),yA=function(){function e(t,n,r,i){Ua(this,e),this.state={prevToken:r,nextToken:i,source:n,items:t}}return Na(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=Na((function DetailedDeliveryReceipt(e){Ua(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})),mA={};function gA(e){return e&&"object"===Pa(e)&&"default"in e?e:{default:e}}Object.defineProperty(mA,"__esModule",{value:!0});var bA=gA(Sf.exports),kA=function(e){var t=bA.default.getLevel();bA.default.setLevel("warn"),bA.default.warn(e),bA.default.setLevel(t)},wA=mA.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 s=a.get;a.get=function(){return kA("The getter ".concat(e," is deprecated").concat(t?", use "+t+" instead":"").concat(n?", "+n:".")),null==s?void 0:s.apply(this)}}else{var o=a.value;a.value=function(){kA("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 o.apply(this,i)}}}},xA=mA.deprecationWarning=kA,_A=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}}}))},SA=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 s=t;return{type:"callToAction",body:s.body,actions:_A(s.actions),rawData:n};case"twilio/list-picker":var o=t;return{type:"listPicker",body:o.body,button:o.button,items:o.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:_A(null!==(c=l.actions)&&void 0!==c?c:[]),rawData:n};default:return{type:"other",rawData:n}}},ContentTemplateVariable=function(){function ContentTemplateVariable(e,t){Ua(this,ContentTemplateVariable),this.name=e,this.value=t}return Na(ContentTemplateVariable,[{key:"copyWithValue",value:function(e){return new ContentTemplateVariable(this.name,e)}}]),ContentTemplateVariable}(),EA=Na((function e(t){Ua(this,e),this.sid=t.sid,this.friendlyName=t.friendly_name,this.variables=Object.entries(JSON.parse(t.variables)).map((function(e){var t=pm(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=pm(r[n],2),a=i[0],s=i[1];t.set(a,SA(a,s))}return t}(t.variants),this.dateCreated=new Date(t.date_created),this.dateUpdated=new Date(t.date_updated)}));function TA(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 RA(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?TA(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):TA(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function CA(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 IA(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 OA(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}var PA=If.scope("Message"),AA=t.XMLHttpRequest||{},jA=new WeakSet,MA=new WeakSet,Message=function(e){Oa(Message,e);var t,n,r,i,a,s,o,u,c,l=CA(Message);function Message(e,t,n,r,i,a){var s,o,u,c,f,d,p,h;return Ua(this,Message),IA(Ca(h=l.call(this)),MA),IA(Ca(h),jA),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!==(s=t.text)&&void 0!==s?s:null,timestamp:t.timestamp?new Date(t.timestamp):null,dateUpdated:t.dateUpdated?new Date(t.dateUpdated):null,lastUpdatedBy:null!==(o=t.lastUpdatedBy)&&void 0!==o?o:null,attributes:yh(t.attributes,"Got malformed attributes for the message ".concat(t.sid),PA),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},OA(Ca(h),MA,NA).call(Ca(h),null!==(d=t.medias)&&void 0!==d?d:null,null!==(p=t.media)&&void 0!==p?p:null),h}return Na(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,s=[];!e.text&&"string"!=typeof e.text||e.text===this.state.body||(this.state.body=e.text,s.push("body")),e.subject&&e.subject!==this.state.subject&&(this.state.subject=e.subject,s.push("subject")),e.lastUpdatedBy&&e.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=e.lastUpdatedBy,s.push("lastUpdatedBy")),e.author&&e.author!==this.state.author&&(this.state.author=e.author,s.push("author")),e.dateUpdated&&new Date(e.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(e.dateUpdated),s.push("dateUpdated")),e.timestamp&&new Date(e.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(e.timestamp),s.push("dateCreated"));var o=yh(e.attributes,"Got malformed attributes for the message ".concat(this.sid),PA);lm(this.state.attributes,o)||(this.state.attributes=o,s.push("attributes"));var u=e.delivery,c=this.state.aggregatedDeliveryReceipt;!!(u&&u.total&&u.delivered&&u.failed&&u.read&&u.sent&&u.undelivered)&&(c?c._isEquals(u)||(c._update(u),s.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new AggregatedDeliveryReceipt(u),s.push("deliveryReceipt")));var l,f,d=(null!==(t=e.medias)&&void 0!==t?t:[]).map((function(e){var t;return null===(t=OA(a,jA,LA).call(a,e))||void 0===t?void 0:t._state()})).filter((function(e){return!(null===e)})),p=(null!==(n=this.state.medias)&&void 0!==n?n:[]).map((function(e){return e._state()})).filter((function(e){return!(null===e)}));lm(d,p)&&lm(null===(r=OA(this,jA,LA).call(this,e.media))||void 0===r?void 0:r._state(),null===(i=this.state.media)||void 0===i?void 0:i._state())||(OA(this,MA,NA).call(this,null!==(l=e.medias)&&void 0!==l?l:null,null!==(f=e.media)&&void 0!==f?f:null),s.push("media"));s.length>0&&this.emit("updated",{message:this,updateReasons:s})}},{key:"getParticipant",value:(c=Ra(Gc.mark((function e(){var t,n,r=this;return Gc.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 PA.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 PA.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=Ra(Gc.mark((function e(){var t,n;return Gc.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:(o=Ra(Gc.mark((function e(){return Gc.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 o.apply(this,arguments)})},{key:"updateBody",value:(s=Ra(Gc.mark((function e(t){return Gc.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 s.apply(this,arguments)})},{key:"updateAttributes",value:(a=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){var n,r=this;return Gc.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 gC.CancellablePromise(function(){var n=Ra(Gc.mark((function n(r,i,a){var s,o;return Gc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(s=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(){s.cancel()})),n.prev=5,n.next=8,s;case 8:o=n.sent,r(o),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=Ra(Gc.mark((function e(t){var n,r,i,a=this;return Gc.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 mh(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 yA(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 gC.CancellablePromise(function(){var t=Ra(Gc.mark((function t(n,r,i){var a,s,o,u,c,l,f,d,p,h;return Gc.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(s="application/x-vnd.com.twilio.rich.",0!==(o=a.filter((function(e){return e.contentType.startsWith(s)}))).length){t.next=12;break}return n(null),t.abrupt("return");case 12:return u=o[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 AA;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(s,"").replace(".","/"),n(SA(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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(){return Gc.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}(um);function LA(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e?new Media(t?RA(RA({},e),{},{category:t}):e,this.services):null}function NA(e,t){var n=this;this.state.media=OA(this,jA,LA).call(this,t),this.state.medias=e?e.map((function(e){return OA(n,jA,LA).call(n,e)})).filter((function(e){return null!==e})):t&&!e?[OA(this,jA,LA).call(this,t,"media")].filter((function(e){return null!==e})):null}function UA(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 DA(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?UA(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):UA(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function FA(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 BA(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 BA(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function BA(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 qA(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([wA("getMediaByCategory","getMediaByCategories"),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",Array)],Message.prototype,"getMediaByCategory",null),$c([gy([py,"undefined"]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Media)],Message.prototype,"getEmailBody",null),$c([gy([py,"undefined"]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Media)],Message.prototype,"getEmailHistory",null),$c([by("string"),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Message.prototype,"updateBody",null),$c([by(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],Message.prototype,"updateAttributes",null),$c([wA("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",Promise)],Message.prototype,"attachTemporaryUrlsFor",null),$c([by(dy("media",Media)),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",gC.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMedia",null),$c([by(dy("strings","string")),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",gC.CancellablePromise)],Message.prototype,"getTemporaryContentUrlsForMediaSids",null);var zA=If.scope("Messages"),WA=function(e){Oa(u,e);var t,n,r,i,a,s,o=qA(u);function u(e,t,n){var r;return Ua(this,u),(r=o.call(this)).conversation=e,r.configuration=t,r.services=n,r.messagesByIndex=new Map,r.messagesListPromise=null,r}return Na(u,[{key:"subscribe",value:(s=Ra(Gc.mark((function e(t){var n,r=this;return Gc.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){zA.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)?zA.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){zA.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){zA.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&&zA.error("Failed to get messages object for conversation",this.conversation.sid,e.t0),zA.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 s.apply(this,arguments)})},{key:"unsubscribe",value:(a=Ra(Gc.mark((function e(){return Gc.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 zA.debug("Sending message V2",e.mediaContent,e.attributes,e.emailOptions),new gC.CancellablePromise(function(){var n=Ra(Gc.mark((function n(r,i,a){var s,o,u,c,l,f,d,p,h,v,y,m;return Gc.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:o=[],u=[],a((function(){u.forEach((function(e){return e.cancel()}))})),c=FA(e.mediaContent),n.prev=4,c.s();case 6:if((l=c.n()).done){n.next=25;break}return f=pm(l.value,2),d=f[0],p=f[1],n.prev=8,zA.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=o,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 m=t.services.commandExecutor.mutateResource("post",t.conversation._links.messages,{body:e.text,subject:null===(s=e.emailOptions)||void 0===s?void 0:s.subject,media_sids:o.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 DA(DA({},e),{},Ma({},t.name,t.value))}),{})):void 0}),n.prev=34,n.t4=r,n.next=38,m;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=Ra(Gc.mark((function e(t){var n,r,i=arguments;return Gc.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,zA.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=Ra(Gc.mark((function e(t){var n,r,i,a,s,o=arguments;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:{},a=o.length>2?o[2]:void 0,zA.debug("Sending media message",t,i,a),zA.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 s=e.t0,e.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[s.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=Ra(Gc.mark((function e(t,n){var r,i=arguments;return Gc.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)}))},s=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:s,nextPage:i?s: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=Ra(Gc.mark((function e(){var t,n,r,i,a,s,o=this,u=arguments;return Gc.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 s=e.sent,e.next=12,this._wrapPaginator(i,s,(function(e){return Promise.all(e.map((function(e){return o._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}(um),GA=function(){function e(t){Ua(this,e),Ma(this,"attributes",{}),Ma(this,"mediaContent",[]),Ma(this,"emailOptions",{}),this.messagesEntity=t}return Na(e,[{key:"send",value:function(){var e=this;return new gC.CancellablePromise(function(){var t=Ra(Gc.mark((function t(n,r,i){var a,s;return Gc.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:s=t.sent,n(hh(s.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}(),VA=function(){function e(t,n){Ua(this,e),this.limits=t,this.message=new GA(n),this.emailBodies=new Map,this.emailHistories=new Map}return Na(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 $A(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 JA(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 JA(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function JA(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 KA(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([gy("string"),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",VA)],VA.prototype,"setBody",null),$c([gy("string"),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",VA)],VA.prototype,"setSubject",null),$c([gy(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",VA)],VA.prototype,"setAttributes",null),$c([gy("string",[FormData,Ey]),Jc("design:type",Function),Jc("design:paramtypes",[String,Object]),Jc("design:returntype",VA)],VA.prototype,"setEmailBody",null),$c([gy("string",[FormData,Ey]),Jc("design:type",Function),Jc("design:paramtypes",[String,Object]),Jc("design:returntype",VA)],VA.prototype,"setEmailHistory",null),$c([gy("string",[cy("content variables",ContentTemplateVariable),"undefined"]),Jc("design:type",Function),Jc("design:paramtypes",[String,Array]),Jc("design:returntype",VA)],VA.prototype,"setContentTemplate",null),$c([gy([FormData,Ey]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",VA)],VA.prototype,"addMedia",null);var HA={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,s,o,u,c,l,f,d,p,h,v,y,m,g,b,k,w,x,_,S,E,T,R,C,I,O=KA(Conversation);function Conversation(e,t,n,r,i){var a,s,o;Ua(this,Conversation),(o=O.call(this)).sid=t,o._links=n,o._configuration=r,o._services=i,o._entityName=e.channel,o._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!==(s=e.bindings)&&void 0!==s?s:{}},e.notificationLevel&&(o._internalState.notificationLevel=e.notificationLevel);var u={participants:o._links.participants};return o._participants=new Map,o._participantsEntity=new AP(Ca(o),o._participants,u,o._services),o._participantsEntity.on(Conversation.participantJoined,(function(e){return o.emit(Conversation.participantJoined,e)})),o._participantsEntity.on(Conversation.participantLeft,(function(e){return o.emit(Conversation.participantLeft,e)})),o._participantsEntity.on(Conversation.participantUpdated,(function(e){return o.emit(Conversation.participantUpdated,e)})),o._messagesEntity=new WA(Ca(o),r,i),o._messagesEntity.on(Conversation.messageAdded,(function(e){return o._onMessageAdded(e)})),o._messagesEntity.on(Conversation.messageUpdated,(function(e){return o.emit(Conversation.messageUpdated,e)})),o._messagesEntity.on(Conversation.messageRemoved,(function(e){return o.emit(Conversation.messageRemoved,e)})),o}return Na(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:(I=Ra(Gc.mark((function e(t,n){return Gc.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 I.apply(this,arguments)})},{key:"addNonChatParticipant",value:(C=Ra(Gc.mark((function e(t,n){var r,i,a=arguments;return Gc.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 C.apply(this,arguments)})},{key:"advanceLastReadMessageIndex",value:(R=Ra(Gc.mark((function e(t){var n;return Gc.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 R.apply(this,arguments)})},{key:"delete",value:(T=Ra(Gc.mark((function e(){return Gc.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 T.apply(this,arguments)})},{key:"getAttributes",value:(E=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t,n,r){return Gc.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:(_=Ra(Gc.mark((function e(){return Gc.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 _.apply(this,arguments)})},{key:"getParticipantsCount",value:(x=Ra(Gc.mark((function e(){var t,n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mh(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 x.apply(this,arguments)})},{key:"getParticipantBySid",value:(w=Ra(Gc.mark((function e(t){return Gc.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 w.apply(this,arguments)})},{key:"getParticipantByIdentity",value:(k=Ra(Gc.mark((function e(){var t,n=arguments;return Gc.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 k.apply(this,arguments)})},{key:"getMessagesCount",value:(b=Ra(Gc.mark((function e(){var t,n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mh(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:(g=Ra(Gc.mark((function e(){var t,n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new mh(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 g.apply(this,arguments)})},{key:"join",value:(m=Ra(Gc.mark((function e(){return Gc.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 m.apply(this,arguments)})},{key:"leave",value:(y=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t,n,r){var i,a,s,o;return Gc.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 s=e.sent,e.abrupt("return",null!==(a=hh(s.index))&&void 0!==a?a:0);case 5:return e.next=7,this._messagesEntity.sendMedia(t,n,r);case 7:return o=e.sent,e.abrupt("return",null!==(i=hh(o.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 VA(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:(p=Ra(Gc.mark((function e(){var t;return Gc.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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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:(o=Ra(Gc.mark((function e(t){return Gc.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 o.apply(this,arguments)})},{key:"getMessageRecipients",value:(s=Ra(Gc.mark((function e(t){return Gc.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 s.apply(this,arguments)})},{key:"_subscribe",value:(a=Ra(Gc.mark((function e(){var t=this;return Gc.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(vC.updated,(function(e){return t._update(e.data)})),this._entity.on(vC.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=Ra(Gc.mark((function e(){var t,n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return Conversation._logger.trace("_streamsAvailable, this.entity.data=",null===(t=this._entity)||void 0===t?void 0:t.data),r=null===(n=this._entity)||void 0===n?void 0:n.data,e.next=6,this._services.syncClient.list({id:r.messages,mode:"open_existing"});case 6:return this._messagesList=e.sent,e.next=9,this._services.syncClient.map({id:r.roster,mode:"open_existing"});case 9:this._participantsMap=e.sent;case 10:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_subscribeStreams",value:(r=Ra(Gc.mark((function e(){var t,n,r,i,a,s,o;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._subscribe();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,s=a.messages,o=a.roster,e.next=9,Promise.all([this._messagesEntity.subscribe(null!==(r=this._messagesList)&&void 0!==r?r:s),this._participantsEntity.subscribe(null!==(i=this._participantsMap)&&void 0!==i?i:o)]);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=Ra(Gc.mark((function e(){return Gc.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 s=new Set,o=0,u=Object.keys(e);o<u.length;o++){var c=u[o],l=HA[c];if(l)switch(l){case HA.status:if(!e.status||"unknown"===e.status||this._internalState.status===e.status)break;this._internalState.status=e.status,s.add(l);break;case HA.attributes:if(lm(this._internalState.attributes,e.attributes))break;this._internalState.attributes=e.attributes,s.add(l);break;case HA.lastConsumedMessageIndex:if(void 0===e.lastConsumedMessageIndex||e.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=e.lastConsumedMessageIndex,s.add("lastReadMessageIndex");break;case HA.lastMessage:if(this._internalState.lastMessage&&!e.lastMessage){delete this._internalState.lastMessage,s.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,s.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,s.add(l)),lm(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case HA.state:var f=e.state||void 0;if(void 0!==f&&(f.dateUpdated=new Date(f.dateUpdated)),lm(this._internalState.state,f))break;this._internalState.state=f,s.add(l);break;case HA.bindings:if(lm(this._internalState.bindings,e.bindings))break;this._internalState.bindings=e.bindings,s.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],s.add(l)}}s.size>0&&this.emit(Conversation.updated,{conversation:this,updateReasons:xy(s)})}},{key:"_onMessageAdded",value:function(e){var t,n=$A(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=Ra(Gc.mark((function e(t){var n;return Gc.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}(um);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",If.scope("Conversation")),$c([by(py,Sy),Jc("design:type",Function),Jc("design:paramtypes",[String,Object]),Jc("design:returntype",Promise)],Conversation.prototype,"add",null),$c([by(py,py,Sy,Sy),Jc("design:type",Function),Jc("design:paramtypes",[String,String,Object,Object]),Jc("design:returntype",Promise)],Conversation.prototype,"addNonChatParticipant",null),$c([by(hy),Jc("design:type",Function),Jc("design:paramtypes",[Number]),Jc("design:returntype",Promise)],Conversation.prototype,"advanceLastReadMessageIndex",null),$c([by(["undefined",hy],["undefined",hy],["undefined",fy("backwards","forward")]),Jc("design:type",Function),Jc("design:paramtypes",[Number,Number,String]),Jc("design:returntype",Promise)],Conversation.prototype,"getMessages",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"getParticipantBySid",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"getParticipantByIdentity",null),$c([by([py,Participant]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],Conversation.prototype,"removeParticipant",null),$c([by(["string",FormData,fy(null),vy("media options",{contentType:py,media:ly((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"]}))})],Sy,["undefined",fy(null),vy("email attributes",{subject:[py,"undefined"]})]),Jc("design:type",Function),Jc("design:paramtypes",[Object,Object,Object]),Jc("design:returntype",Promise)],Conversation.prototype,"sendMessage",null),$c([by(fy("default","muted")),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"setUserNotificationLevel",null),$c([by(_y),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],Conversation.prototype,"updateAttributes",null),$c([by("string"),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"updateFriendlyName",null),$c([by([fy(null),hy]),Jc("design:type",Function),Jc("design:paramtypes",[Number]),Jc("design:returntype",Promise)],Conversation.prototype,"updateLastReadMessageIndex",null),$c([by(["string",fy(null)]),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],Conversation.prototype,"updateUniqueName",null);var YA=function(){function e(){var t=this;Ua(this,e),this._promise=new Promise((function(e,n){t._resolve=e,t._reject=n}))}return Na(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 QA(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 XA(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 XA(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function XA(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 ZA(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 ej(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ZA(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ZA(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function tj(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 nj=If.scope("Conversations"),rj=function(e){Oa(p,e);var t,n,r,i,a,s,o,u,c,l,f,d=tj(p);function p(e,t){var n;return Ua(this,p),Ma(Ca(n=d.call(this)),"conversations",new Map),Ma(Ca(n),"myConversationsRead",new YA),Ma(Ca(n),"tombstones",new Set),Ma(Ca(n),"myConversationsFetched",!1),n.configuration=e,n.services=t,n}return Na(p,[{key:"addConversation",value:(f=Ra(Gc.mark((function e(t){var n,r,i,a,s,o,u,c,l,f;return Gc.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(s=e.sent,o=null!==(n=s.sid)&&void 0!==n?n:null,u=null!==(r=null===(i=s.sync_objects)||void 0===i?void 0:i.conversation)&&void 0!==r?r:null,c=ej({self:s.url},s.links),!(l=this.conversations.get(o))){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},o,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=Ra(Gc.mark((function e(){var t,n,r,i,a,s,o,u=this;return Gc.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(yC.itemAdded,(function(e){nj.debug("itemAdded: ".concat(e.item.key)),u._upsertConversation("sync",e.item.key,e.item.data)})),t.on(yC.itemRemoved,(function(e){nj.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(yC.itemUpdated,(function(e){nj.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=QA(n);try{for(i.s();!(a=i.n()).done;)s=a.value,r.push(this._upsertConversation("rest",s.channel_sid,s))}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(),nj.debug("The conversations list has been successfully fetched"),e.abrupt("return",this);case 22:throw e.prev=22,e.t0=e.catch(0),o="Failed to fetch the conversations list","disconnected"!==this.services.syncClient.connectionState&&nj.error(o,e.t0),nj.debug("ERROR: ".concat(o),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=Ra(Gc.mark((function e(){var t,n,r=this;return Gc.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=Ra(Gc.mark((function e(t){var n,r,i,a=this;return Gc.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:(o=Ra(Gc.mark((function e(t){var n,r,i,a,s;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mh(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,s={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,s):null);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"peekConversation",value:(s=Ra(Gc.mark((function e(t){var n,r,i,a;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new mh(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 s.apply(this,arguments)})},{key:"_getMap",value:(a=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t,n){var r,i=this;return Gc.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=Ra(Gc.mark((function e(t,n,r){var i,a,s;return Gc.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 nj.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),s={},void 0!==r.notificationLevel&&(s.notificationLevel=r.notificationLevel),void 0!==r.lastConsumedMessageIndex&&(s.lastConsumedMessageIndex=r.lastConsumedMessageIndex),lm(s,{})||n._update(s),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=Ra(Gc.mark((function e(t,n,r){var i,a,s,o;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(nj.trace("upsertConversation called for ".concat(n),r),!(i=this.conversations.get(n))){e.next=9;break}return nj.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 nj.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",n),e.abrupt("return",null);case 12:return nj.trace("upsertConversation: creating a local conversation object with sid "+n,r),a="".concat(this.configuration.links.conversations,"/").concat(n),s={self:a,messages:"".concat(a,"/Messages"),participants:"".concat(a,"/Participants")},o=new Conversation(r,n,s,this.configuration,this.services),this.conversations.set(n,o),e.prev=17,e.next=20,o._subscribe();case 20:if("joined"!==r.status){e.next=23;break}return e.next=23,o._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 nj.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(o),this.emit("conversationAdded",o),"joined"===r.status&&(o._setStatus("joined",t),this.emit("conversationJoined",o)),e.abrupt("return",o);case 36:case"end":return e.stop()}}),e,this,[[17,25]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"_fetchMyConversations",value:(t=Ra(Gc.mark((function e(){var t,n,r,i,a,s;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=null;case 2:return i=new mh(this.configuration.links.myConversations),n&&i.arg("PageToken",n),e.next=6,this.services.network.get(i.build());case 6:a=e.sent,s=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(s));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}(um),ij=Cn,aj=Xr.find,sj=Vf,oj="find",uj=!0;function cj(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)}}oj in[]&&Array(1).find((function(){uj=!1})),ij({target:"Array",proto:!0,forced:uj},{find:function(e){return aj(this,e,arguments.length>1?arguments[1]:void 0)}}),sj(oj);var lj=function(e){Oa(a,e);var t,n,r,i=cj(a);function a(e,t,n){var r;return Ua(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 Na(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=Ra(Gc.mark((function e(t,n){var r,i,a,s=this;return Gc.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 s.emit("userUpdated",e)})),a.on("userSubscribed",(function(){return s.handleSubscribeUser(a)})),a.on("userUnsubscribed",(function(){return s.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=Ra(Gc.mark((function e(){var t;return Gc.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=Ra(Gc.mark((function e(t){var n,r,i,a;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new mh(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}(um),fj=If.scope("TypingIndicator"),dj=function(){function e(t,n,r){Ua(this,e),this.configuration=n,this.services=r,this.getConversation=t,this.serviceTypingTimeout=null,this.sentUpdates=new Map}var t;return Na(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=Ra(Gc.mark((function t(n,r){return Gc.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n!==Bg.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=Ra(Gc.mark((function e(t){var n=this;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:fj.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 fj.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;fj.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 fj.error("Failed to send typing indicator:",e),e}))}}]),e}(),PushNotification=Na((function PushNotification(e){Ua(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||{}})),pj="2.6.3-rc.8";function hj(){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 vj(e,t,n){return vj=hj()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&Ia(i,n.prototype),i},vj.apply(null,arguments)}function yj(e){var t="function"==typeof Map?new Map:void 0;return yj=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 vj(e,arguments,ja(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Ia(r,e)},yj(e)}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 gj(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 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)}}var kj=function(e){return e.replace(/(^\/+|\/+$)/g,"")},wj=function(e){Oa(n,e);var t=bj(n);function n(e){return Ua(this,n),t.call(this,e)}return Na(n)}(yj(Error)),xj=function(){function e(t,n,r){Ua(this,e),this._serviceUrl=t,this._services=n,this._productId=r}var t,n,r;return Na(e,[{key:"_preProcessUrl",value:function(e){var t=kj(e);return/^https?:\/\//.test(e)?t:"".concat(kj(this._serviceUrl),"/").concat(t)}},{key:"_makeRequest",value:(r=Ra(Gc.mark((function e(t,n,r,i){var a,s,o,u;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=this._preProcessUrl(n),s=gj({"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,s,this._productId);case 9:case 13:case 17:return o=e.sent,e.abrupt("break",19);case 11:return e.next=13,this._services.transport.post(a,s,JSON.stringify(r),this._productId);case 15:return e.next=17,this._services.transport.delete(a,s,{},this._productId);case 19:if(!(o.status.code<200||o.status.code>=300)){e.next=21;break}throw new Error("Request responded with a non-success code ".concat(o.status.code));case 21:return e.abrupt("return",o);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"fetchResource",value:(n=Ra(Gc.mark((function e(t,n){var r,i,a=this;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new Lg({min:50,max:1600,maxAttemptsCount:6}),e.prev=2,e.next=5,r.run(Ra(Gc.mark((function e(){var r,i,s;return Gc.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===(s=e.t0.body)||void 0===s?void 0:s.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 wj("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=Ra(Gc.mark((function e(t,n,r){var i;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._makeRequest(t,n,r,{"X-Twilio-Mutation-Id":Sb.v4()});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}(),_j=Cn,Sj=vm,Ej=o,Tj=E,Rj=hm.exports.onFreeze,Cj=Object.freeze;_j({target:"Object",stat:!0,forced:Ej((function(){Cj(1)})),sham:!Sj},{freeze:function(e){return Cj&&Tj(e)?Cj(Rj(e)):e}});var Ij=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;Ua(this,e),Ma(this,"_cachedTemplates",null),this._services=t,this._pageSize=n,this._cacheTtlMs=r}var t,n;return Na(e,[{key:"getContentTemplates",value:(n=Ra(Gc.mark((function e(){var t,n,r,i,a,s,o,u=this;return Gc.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=pm(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:s=e.sent,o=pm(s,2),r=o[0],i=o[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=Ra(Gc.mark((function e(t){var n,r;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new mh("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 EA(e)})),r.meta.next_token]);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();function Oj(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 Pj(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 Pj(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function Pj(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 Aj=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Ua(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 Na(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=Oj(this.oldCache.entries());try{for(r.s();!(n=r.n()).done;){var i=pm(n.value,2),a=i[0],s=i[1];this.onEviction(a,s)}}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:Gc.mark((function e(){var t,n,r,i;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Oj(this),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=pm(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:Gc.mark((function e(){var t,n,r,i;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Oj(this),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=9;break}return r=pm(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:Gc.mark((function e(){var t,n,r,i,a,s,o,u;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Oj(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=Oj(this.oldCache),e.prev=18,i.s();case 20:if((a=i.n()).done){e.next=28;break}if(s=a.value,o=pm(s,1),u=o[0],this.cache.has(u)){e.next=26;break}return e.next=26,s;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=Oj(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),jj=Aj,Mj=Na((function e(t,n){Ua(this,e),this.type=t,this.data=n,Object.freeze(n)})),Lj=function(){function e(t,n){Ua(this,e),this._services=t,this._configuration=n,this._cache=new jj({maxSize:n.channelMetadataCacheCapacity})}var t;return Na(e,[{key:"getChannelMetadata",value:(t=Ra(Gc.mark((function e(t,n){var r,i,a,s,o;return Gc.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:s=e.sent,e.next=17;break;case 11:if(e.prev=11,e.t0=e.catch(5),!(e.t0 instanceof wj)){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 o=new Mj(s.type,s.data),this._cache.set(r,{item:o}),e.abrupt("return",o);case 20:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(e,n){return t.apply(this,arguments)})}]),e}();function Nj(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 Uj(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 Uj(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,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}function Uj(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 Dj,Fj,Bj=Na((function e(t){Ua(this,e),Ma(this,"type","email"),this.messageSid=t.message_sid,this.level=t.level,this.name=t.name,this.address=t.address})),qj=Na((function e(t){Ua(this,e),this.type=t.type,this.messageSid=t.message_sid,this.rawData=JSON.stringify(t)})),zj=function(){function e(t,n){Ua(this,e),this._services=t,this._configuration=n,this._cache=new jj({maxSize:n.messageRecipientsCacheCapacity})}var t,n;return Na(e,[{key:"getRecipientsFromMessage",value:(n=Ra(Gc.mark((function e(t,n){var r,i,a,s,o,u=this;return Gc.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 mh(this._configuration.links.conversations).path(t).path("MessageRecipients").arg("MessageSid",n).build(),e.next=7,this._services.commandExecutor.fetchResource(a);case 7:return s=e.sent,(o=s.message_recipients.map((function(e){return u._wrapResponse(e)}))).length>0&&this._cache.set(r,{item:o}),e.abrupt("return",o);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"getRecipientsFromConversation",value:(t=Ra(Gc.mark((function e(t,n){var r,i,a,s,o,u,c,l,f,d,p,h,v=this;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new mh(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:s=e.sent,o=s.message_recipients.map((function(e){return v._wrapResponse(e)})),u=Nj(o);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 yA(o,(function(e,n){return v.getRecipientsFromConversation(t,{pageToken:e,pageSize:n})}),s.meta.previous_token,s.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 Bj(e):new qj(e)}}]),e}();function Wj(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 Gj(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wj(Object(n),!0).forEach((function(t){Ma(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wj(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Vj(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 $j=Na((function e(){Ua(this,e)}));return e.Client=(Dj=function(e){Oa(Client,e);var t,n,r,i,a,s,o,u,c,l,f,d,p,h,v,y,m=Vj(Client);function Client(e){var t,n,r,i,a,s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Ua(this,Client),Ma(Ca(s=m.call(this)),"version",pj),Ma(Ca(s),"connectionState","unknown"),Ma(Ca(s),"parsePushNotification",Fj.parsePushNotification),s._fpaToken=null!=e?e:"",s._options=null!=o?o:{},!s._options.disableDeepClone){var u=Gj(Gj({},s._options),{},{transport:void 0,twilsockClient:void 0});(u=ph(u)).transport=s._options.transport,u.twilsockClient=s._options.twilsockClient,s._options=u}s._options.logLevel=null!==(t=s._options.logLevel)&&void 0!==t?t:"silent",Fj._logger.setLevel(s._options.logLevel);var c=s._options.productId="ip_messaging";if(s._options.clientMetadata=s._options.clientMetadata||{},s._options.clientMetadata.hasOwnProperty("type")||(s._options.clientMetadata.type="conversations"),s._options.clientMetadata.hasOwnProperty("sdk")||(s._options.clientMetadata.sdk="JS",s._options.clientMetadata.sdkv=pj),s._options.Sync=s._options.Sync||{},void 0===s._options.Sync.enableSessionStorage&&(s._options.Sync.enableSessionStorage=!0),s._options.region&&(s._options.Sync.region=s._options.region),!e)throw new Error("A valid Twilio token should be provided");s._services=new $j,s._myself=new User("","",null,s._services);var l=!s._options.twilsockClient;if(!s._options.initRegistrations){var f=new qg.InitRegistration(c);Fj.populateInitRegistrations(f),s._options.initRegistrations=[f]}s._services.twilsockClient=s._options.twilsockClient=null!==(n=s._options.twilsockClient)&&void 0!==n?n:new qg.TwilsockClient(e,c,s._options),s._services.twilsockClient.on(Fj.tokenAboutToExpire,(function(){return s.emit(Fj.tokenAboutToExpire)})),s._services.twilsockClient.on(Fj.tokenExpired,(function(){return s.emit(Fj.tokenExpired)})),s._services.twilsockClient.on(Fj.connectionError,(function(e){return s.emit(Fj.connectionError,e)})),s._services.twilsockClient.on("stateChanged",(function(e){Fj._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(e)),e!==s.connectionState&&(s.connectionState=e,s.emit(Fj.connectionStateChanged,s.connectionState))})),s._services.transport=s._options.transport=null!==(r=s._options.transport)&&void 0!==r?r:s._options.twilsockClient,s._services.notificationClient=s._options.notificationsClient=null!==(i=s._options.notificationsClient)&&void 0!==i?i:new ME.Notifications(e,s._options),s._services.syncClient=s._options.syncClient=null!==(a=s._options.syncClient)&&void 0!==a?a:new hC(e,s._options);var d=(null==o?void 0:o.Chat)||(null==o?void 0:o.IPMessaging)||o||{},p=d.region||(null==o?void 0:o.region),h=d.apiUri||d.typingUri||"https://aim.".concat(p||"us1",".twilio.com");s._services.commandExecutor=new xj(h,{transport:s._options.transport},c),s._services.contentClient=new Ij(s._services);var v=function(e){s._rejectEnsureReady(e),s.emit(Fj.stateChanged,"failed"),s.emit(Fj.initFailed,{error:e})},y=function(){v({terminal:!0,message:"Twilsock has disconnected."}),s._initializeEnsureReady((null==o?void 0:o.throwErrorsAlways)||!1)};return s._services.twilsockClient.once("connectionError",v),s._services.twilsockClient.once("disconnected",y),s._services.twilsockClient.once("connected",Ra(Gc.mark((function e(){var t,n;return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Fj._logger.debug("ConversationsClient started INITIALIZING"),s._services.twilsockClient.off("connectionError",v),s._services.twilsockClient.off("disconnected",y),e.prev=3,t="conversations.client.startup",s._services.twilsockClient.addPartialTelemetryEvent(new qg.TelemetryEventDescription(t,"Conversations client startup",new Date),t,qg.TelemetryPoint.Start),e.next=8,s._initialize();case 8:s._services.twilsockClient.addPartialTelemetryEvent(new qg.TelemetryEventDescription("","",new Date),t,qg.TelemetryPoint.End),e.next=17;break;case 11:e.prev=11,e.t0=e.catch(3),n={terminal:!0,message:e.t0.message},s._rejectEnsureReady(n),s.emit(Fj.stateChanged,"failed"),s.emit(Fj.initFailed,{error:n});case 17:case"end":return e.stop()}}),e,null,[[3,11]])})))),s._initializeEnsureReady((null==o?void 0:o.throwErrorsAlways)||!1),l&&s._services.twilsockClient.connect(),s}return Na(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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:if(Fj._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=Ra(Gc.mark((function e(t){var n;return Gc.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)&&xA("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=Ra(Gc.mark((function e(t){var n;return Gc.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=Ra(Gc.mark((function e(t){var n;return Gc.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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(t,n){return Gc.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=Ra(Gc.mark((function e(t){return Gc.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:(o=Ra(Gc.mark((function e(t,n){return Gc.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 o.apply(this,arguments)})},{key:"handlePushNotification",value:(s=Ra(Gc.mark((function e(t){return Gc.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ensureReady;case 2:Fj._logger.debug("handlePushNotification, notificationPayload=",t),this.emit("pushNotification",Fj.parsePushNotification(t));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"getUser",value:(a=Ra(Gc.mark((function e(t){return Gc.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=Ra(Gc.mark((function e(){return Gc.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 gC.CancellablePromise(function(){var n=Ra(Gc.mark((function n(r,i,a){var s,o;return Gc.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 s=t._services.mcsClient.mediaSetGetContentUrls(e),a((function(){s.cancel()})),n.prev=5,n.next=8,s;case 8:o=n.sent,r(o),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=Ra(Gc.mark((function e(){return Gc.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=Ra(Gc.mark((function e(){var t,n=this;return Gc.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,Fj._logger),this._services.channelMetadataClient=new Lj(this._services,this._configuration),this._services.messageRecipientsClient=new zj(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new dj(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new Fg(this._configuration,this._services),this._services.users=new lj(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 rj(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:Fj._supportedPushChannels.forEach((function(e){return n._subscribeToPushNotifications(e)})),this._services.typingIndicator.initialize(),this._services.mcsClient=new gC.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,Gj(Gj({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(Fj.stateChanged,"initialized"),this.emit(Fj.initialized);case 36:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_subscribeToPushNotifications",value:function(e){var t=this;[Bg.NEW_MESSAGE,Bg.ADDED_TO_CONVERSATION,Bg.REMOVED_FROM_CONVERSATION,Bg.TYPING_INDICATOR,Bg.CONSUMPTION_UPDATE].forEach((function(n){t._services.notificationClient.subscribe(e,n)}))}},{key:"_unsubscribeFromPushNotifications",value:function(e){var t=this;[Bg.NEW_MESSAGE,Bg.ADDED_TO_CONVERSATION,Bg.REMOVED_FROM_CONVERSATION,Bg.TYPING_INDICATOR,Bg.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=Ra(Gc.mark((function e(t,n){var r;return Gc.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 Fj(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(Fj._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=Fj._parsePushNotificationChatData(e),a=e.aps,s=null;if("string"==typeof a.alert)t=a.alert||null;else t=(null===(n=a.alert)||void 0===n?void 0:n.body)||null,s=(null===(r=a.alert)||void 0===r?void 0:r.title)||null;return new PushNotification({title:s,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 o=e.data;if(!o.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var u=Fj._parsePushNotificationChatData(e.data);return new PushNotification({title:o.twi_title||null,body:o.twi_body||null,sound:o.twi_sound||null,badge:null,action:o.twi_action||null,type:o.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 Fj._supportedPushDataFields){var r=e[n];if(null!=r)if("message_index"!==n&&"media_count"!==n){if("media"!==n)t[Fj._supportedPushDataFields[n]]=r;else if("string"==typeof r)try{t[Fj._supportedPushDataFields[n]]=JSON.parse(r)}catch(e){Fj._logger.debug("Media message notification parsing error")}}else{var i=hh(r);null!==i&&(t[Fj._supportedPushDataFields[n]]=i)}}return t}},{key:"populateInitRegistrations",value:function(e){e.populateInitRegistrations([Bg.TYPING_INDICATOR]),hC.populateInitRegistrations(e)}}]),Client}(um),Ma(Dj,"conversationAdded","conversationAdded"),Ma(Dj,"conversationJoined","conversationJoined"),Ma(Dj,"conversationLeft","conversationLeft"),Ma(Dj,"conversationRemoved","conversationRemoved"),Ma(Dj,"conversationUpdated","conversationUpdated"),Ma(Dj,"participantJoined","participantJoined"),Ma(Dj,"participantLeft","participantLeft"),Ma(Dj,"participantUpdated","participantUpdated"),Ma(Dj,"messageAdded","messageAdded"),Ma(Dj,"messageRemoved","messageRemoved"),Ma(Dj,"messageUpdated","messageUpdated"),Ma(Dj,"tokenAboutToExpire","tokenAboutToExpire"),Ma(Dj,"tokenExpired","tokenExpired"),Ma(Dj,"typingEnded","typingEnded"),Ma(Dj,"typingStarted","typingStarted"),Ma(Dj,"pushNotification","pushNotification"),Ma(Dj,"userSubscribed","userSubscribed"),Ma(Dj,"userUnsubscribed","userUnsubscribed"),Ma(Dj,"userUpdated","userUpdated"),Ma(Dj,"stateChanged","stateChanged"),Ma(Dj,"initialized","initialized"),Ma(Dj,"initFailed","initFailed"),Ma(Dj,"connectionStateChanged","connectionStateChanged"),Ma(Dj,"connectionError","connectionError"),Ma(Dj,"version",pj),Ma(Dj,"_logger",If.scope("Client")),Ma(Dj,"_supportedPushChannels",["fcm","apn"]),Ma(Dj,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),Fj=Dj),$c([wA("token"),Jc("design:type",String),Jc("design:paramtypes",[])],e.Client.prototype,"token",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"updateToken",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"getConversationBySid",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"peekConversationBySid",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"getConversationByUniqueName",null),$c([by(["undefined",vy("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],e.Client.prototype,"createConversation",null),$c([by(fy("fcm","apn"),"string"),Jc("design:type",Function),Jc("design:paramtypes",[String,String]),Jc("design:returntype",Promise)],e.Client.prototype,"setPushRegistrationId",null),$c([by(fy("fcm","apn")),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"unsetPushRegistrationId",null),$c([by(fy("fcm","apn"),py),Jc("design:type",Function),Jc("design:paramtypes",[String,String]),Jc("design:returntype",Promise)],e.Client.prototype,"removePushRegistrations",null),$c([by(yy),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",Promise)],e.Client.prototype,"handlePushNotification",null),$c([by(py),Jc("design:type",Function),Jc("design:paramtypes",[String]),Jc("design:returntype",Promise)],e.Client.prototype,"getUser",null),$c([by(dy("strings","string")),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",gC.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),$c([by(dy("media",Media)),Jc("design:type",Function),Jc("design:paramtypes",[Array]),Jc("design:returntype",gC.CancellablePromise)],e.Client.prototype,"getTemporaryContentUrlsForMedia",null),$c([wA("Client.create()","new Client()"),by("string",["undefined",yy]),Jc("design:type",Function),Jc("design:paramtypes",[String,Object]),Jc("design:returntype",Promise)],e.Client,"create",null),$c([gy(yy),Jc("design:type",Function),Jc("design:paramtypes",[Object]),Jc("design:returntype",PushNotification)],e.Client,"parsePushNotification",null),e.Client=Fj=$c([my(py,[yy,"undefined"]),Jc("design:paramtypes",[String,Object])],e.Client),e.AggregatedDeliveryReceipt=AggregatedDeliveryReceipt,e.CancellablePromise=gC.CancellablePromise,e.ChannelMetadata=Mj,e.ContentTemplate=EA,e.ContentTemplateVariable=ContentTemplateVariable,e.Conversation=Conversation,e.DetailedDeliveryReceipt=DetailedDeliveryReceipt,e.EmailRecipientDescriptor=Bj,e.Media=Media,e.Message=Message,e.MessageBuilder=VA,e.NotificationTypes=Bg,e.Participant=Participant,e.PushNotification=PushNotification,e.RestPaginator=yA,e.UnknownRecipientDescriptor=qj,e.UnsentMessage=GA,e.User=User,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
130
130
  //# sourceMappingURL=twilio-conversations.min.js.map