@cloudbase/js-sdk
Version:
cloudbase javascript sdk
1 lines • 58.9 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_realtime",[],t):"object"==typeof exports?exports.cloudbase_realtime=t():e.cloudbase_realtime=t()}("undefined"!=typeof window?window:this,(()=>(()=>{var e={982:(e,t,n)=>{e=n.nmd(e);var r="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",l="[object Map]",h="[object Number]",d="[object Object]",f="[object Promise]",p="[object RegExp]",v="[object Set]",_="[object String]",g="[object Symbol]",E="[object WeakMap]",y="[object ArrayBuffer]",I="[object DataView]",m="[object Float32Array]",w="[object Float64Array]",b="[object Int8Array]",S="[object Int16Array]",T="[object Int32Array]",A="[object Uint8Array]",R="[object Uint8ClampedArray]",C="[object Uint16Array]",N="[object Uint32Array]",D=/\w*$/,L=/^\[object .+?Constructor\]$/,O=/^(?:0|[1-9]\d*)$/,W={};W[i]=W["[object Array]"]=W[y]=W[I]=W[s]=W[a]=W[m]=W[w]=W[b]=W[S]=W[T]=W[l]=W[h]=W[d]=W[p]=W[v]=W[_]=W[g]=W[A]=W[R]=W[C]=W[N]=!0,W["[object Error]"]=W[c]=W[E]=!1;var P="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,M="object"==typeof self&&self&&self.Object===Object&&self,j=P||M||Function("return this")(),x=t&&!t.nodeType&&t,k=x&&e&&!e.nodeType&&e,K=k&&k.exports===x;function B(e,t){return e.set(t[0],t[1]),e}function H(e,t){return e.add(t),e}function q(e,t,n,r){var o=-1,i=e?e.length:0;for(r&&i&&(n=e[++o]);++o<i;)n=t(n,e[o],o,e);return n}function F(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function G(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function U(e,t){return function(n){return e(t(n))}}function V(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var $,J=Array.prototype,X=Function.prototype,z=Object.prototype,Q=j["__core-js_shared__"],Y=($=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+$:"",Z=X.toString,ee=z.hasOwnProperty,te=z.toString,ne=RegExp("^"+Z.call(ee).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=K?j.Buffer:void 0,oe=j.Symbol,ie=j.Uint8Array,se=U(Object.getPrototypeOf,Object),ae=Object.create,ce=z.propertyIsEnumerable,ue=J.splice,le=Object.getOwnPropertySymbols,he=re?re.isBuffer:void 0,de=U(Object.keys,Object),fe=je(j,"DataView"),pe=je(j,"Map"),ve=je(j,"Promise"),_e=je(j,"Set"),ge=je(j,"WeakMap"),Ee=je(Object,"create"),ye=He(fe),Ie=He(pe),me=He(ve),we=He(_e),be=He(ge),Se=oe?oe.prototype:void 0,Te=Se?Se.valueOf:void 0;function Ae(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Re(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Ce(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Ne(e){this.__data__=new Re(e)}function De(e,t,n){var r=e[t];ee.call(e,t)&&qe(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function Le(e,t){for(var n=e.length;n--;)if(qe(e[n][0],t))return n;return-1}function Oe(e,t,n,r,o,f,E){var L;if(r&&(L=f?r(e,o,f,E):r(e)),void 0!==L)return L;if(!$e(e))return e;var O=Fe(e);if(O){if(L=function(e){var t=e.length,n=e.constructor(t);return t&&"string"==typeof e[0]&&ee.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!t)return function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}(e,L)}else{var P=ke(e),M=P==c||P==u;if(Ue(e))return function(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}(e,t);if(P==d||P==i||M&&!f){if(F(e))return f?e:{};if(L=function(e){return"function"!=typeof e.constructor||Be(e)?{}:$e(t=se(e))?ae(t):{};var t}(M?{}:e),!t)return function(e,t){return Pe(e,xe(e),t)}(e,function(e,t){return e&&Pe(t,Je(t),e)}(L,e))}else{if(!W[P])return f?e:{};L=function(e,t,n,r){var o,i=e.constructor;switch(t){case y:return We(e);case s:case a:return new i(+e);case I:return function(e,t){var n=t?We(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,r);case m:case w:case b:case S:case T:case A:case R:case C:case N:return function(e,t){var n=t?We(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(e,r);case l:return function(e,t,n){return q(t?n(G(e),!0):G(e),B,new e.constructor)}(e,r,n);case h:case _:return new i(e);case p:return function(e){var t=new e.constructor(e.source,D.exec(e));return t.lastIndex=e.lastIndex,t}(e);case v:return function(e,t,n){return q(t?n(V(e),!0):V(e),H,new e.constructor)}(e,r,n);case g:return o=e,Te?Object(Te.call(o)):{}}}(e,P,Oe,t)}}E||(E=new Ne);var j=E.get(e);if(j)return j;if(E.set(e,L),!O)var x=n?function(e){return function(e,t,n){var r=t(e);return Fe(e)?r:function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}(r,n(e))}(e,Je,xe)}(e):Je(e);return function(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n););}(x||e,(function(o,i){x&&(o=e[i=o]),De(L,i,Oe(o,t,n,r,i,e,E))})),L}function We(e){var t=new e.constructor(e.byteLength);return new ie(t).set(new ie(e)),t}function Pe(e,t,n,r){n||(n={});for(var o=-1,i=t.length;++o<i;){var s=t[o],a=r?r(n[s],e[s],s,n,e):void 0;De(n,s,void 0===a?e[s]:a)}return n}function Me(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function je(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!$e(e)||(t=e,Y&&Y in t))&&(Ve(e)||F(e)?ne:L).test(He(e));var t}(n)?n:void 0}Ae.prototype.clear=function(){this.__data__=Ee?Ee(null):{}},Ae.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},Ae.prototype.get=function(e){var t=this.__data__;if(Ee){var n=t[e];return n===r?void 0:n}return ee.call(t,e)?t[e]:void 0},Ae.prototype.has=function(e){var t=this.__data__;return Ee?void 0!==t[e]:ee.call(t,e)},Ae.prototype.set=function(e,t){return this.__data__[e]=Ee&&void 0===t?r:t,this},Re.prototype.clear=function(){this.__data__=[]},Re.prototype.delete=function(e){var t=this.__data__,n=Le(t,e);return!(n<0||(n==t.length-1?t.pop():ue.call(t,n,1),0))},Re.prototype.get=function(e){var t=this.__data__,n=Le(t,e);return n<0?void 0:t[n][1]},Re.prototype.has=function(e){return Le(this.__data__,e)>-1},Re.prototype.set=function(e,t){var n=this.__data__,r=Le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},Ce.prototype.clear=function(){this.__data__={hash:new Ae,map:new(pe||Re),string:new Ae}},Ce.prototype.delete=function(e){return Me(this,e).delete(e)},Ce.prototype.get=function(e){return Me(this,e).get(e)},Ce.prototype.has=function(e){return Me(this,e).has(e)},Ce.prototype.set=function(e,t){return Me(this,e).set(e,t),this},Ne.prototype.clear=function(){this.__data__=new Re},Ne.prototype.delete=function(e){return this.__data__.delete(e)},Ne.prototype.get=function(e){return this.__data__.get(e)},Ne.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Re){var r=n.__data__;if(!pe||r.length<199)return r.push([e,t]),this;n=this.__data__=new Ce(r)}return n.set(e,t),this};var xe=le?U(le,Object):function(){return[]},ke=function(e){return te.call(e)};function Ke(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||O.test(e))&&e>-1&&e%1==0&&e<t}function Be(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||z)}function He(e){if(null!=e){try{return Z.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function qe(e,t){return e===t||e!=e&&t!=t}(fe&&ke(new fe(new ArrayBuffer(1)))!=I||pe&&ke(new pe)!=l||ve&&ke(ve.resolve())!=f||_e&&ke(new _e)!=v||ge&&ke(new ge)!=E)&&(ke=function(e){var t=te.call(e),n=t==d?e.constructor:void 0,r=n?He(n):void 0;if(r)switch(r){case ye:return I;case Ie:return l;case me:return f;case we:return v;case be:return E}return t});var Fe=Array.isArray;function Ge(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}(e.length)&&!Ve(e)}var Ue=he||function(){return!1};function Ve(e){var t=$e(e)?te.call(e):"";return t==c||t==u}function $e(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Je(e){return Ge(e)?function(e,t){var n=Fe(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Ge(e)}(e)&&ee.call(e,"callee")&&(!ce.call(e,"callee")||te.call(e)==i)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,o=!!r;for(var s in e)!t&&!ee.call(e,s)||o&&("length"==s||Ke(s,r))||n.push(s);return n}(e):function(e){if(!Be(e))return de(e);var t=[];for(var n in Object(e))ee.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return Oe(e,!0,!0)}},478:(e,t,n)=>{var r,o="__lodash_hash_undefined__",i=1/0,s=9007199254740991,a="[object Function]",c="[object GeneratorFunction]",u="[object Symbol]",l=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,h=/^\w*$/,d=/^\./,f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,p=/\\(\\)?/g,v=/^\[object .+?Constructor\]$/,_=/^(?:0|[1-9]\d*)$/,g="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,E="object"==typeof self&&self&&self.Object===Object&&self,y=g||E||Function("return this")(),I=Array.prototype,m=Function.prototype,w=Object.prototype,b=y["__core-js_shared__"],S=(r=/[^.]+$/.exec(b&&b.keys&&b.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",T=m.toString,A=w.hasOwnProperty,R=w.toString,C=RegExp("^"+T.call(A).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),N=y.Symbol,D=I.splice,L=H(y,"Map"),O=H(Object,"create"),W=N?N.prototype:void 0,P=W?W.toString:void 0;function M(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function j(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function x(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function k(e,t,n){var r=e[t];A.call(e,t)&&V(r,n)&&(void 0!==n||t in e)||(e[t]=n)}function K(e,t){for(var n=e.length;n--;)if(V(e[n][0],t))return n;return-1}function B(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function H(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){if(!J(e)||S&&S in e)return!1;var t=function(e){var t=J(e)?R.call(e):"";return t==a||t==c}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?C:v;return t.test(function(e){if(null!=e){try{return T.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}(n)?n:void 0}function q(e,t){return!!(t=null==t?s:t)&&("number"==typeof e||_.test(e))&&e>-1&&e%1==0&&e<t}M.prototype.clear=function(){this.__data__=O?O(null):{}},M.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},M.prototype.get=function(e){var t=this.__data__;if(O){var n=t[e];return n===o?void 0:n}return A.call(t,e)?t[e]:void 0},M.prototype.has=function(e){var t=this.__data__;return O?void 0!==t[e]:A.call(t,e)},M.prototype.set=function(e,t){return this.__data__[e]=O&&void 0===t?o:t,this},j.prototype.clear=function(){this.__data__=[]},j.prototype.delete=function(e){var t=this.__data__,n=K(t,e);return!(n<0||(n==t.length-1?t.pop():D.call(t,n,1),0))},j.prototype.get=function(e){var t=this.__data__,n=K(t,e);return n<0?void 0:t[n][1]},j.prototype.has=function(e){return K(this.__data__,e)>-1},j.prototype.set=function(e,t){var n=this.__data__,r=K(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},x.prototype.clear=function(){this.__data__={hash:new M,map:new(L||j),string:new M}},x.prototype.delete=function(e){return B(this,e).delete(e)},x.prototype.get=function(e){return B(this,e).get(e)},x.prototype.has=function(e){return B(this,e).has(e)},x.prototype.set=function(e,t){return B(this,e).set(e,t),this};var F=U((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(X(e))return P?P.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(t);var n=[];return d.test(e)&&n.push(""),e.replace(f,(function(e,t,r,o){n.push(r?o.replace(p,"$1"):t||e)})),n}));function G(e){if("string"==typeof e||X(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function U(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(U.Cache||x),n}function V(e,t){return e===t||e!=e&&t!=t}U.Cache=x;var $=Array.isArray;function J(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function X(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&R.call(e)==u}e.exports=function(e,t,n){return null==e?e:function(e,t,n,r){if(!J(e))return e;t=function(e,t){if($(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!X(e))||h.test(e)||!l.test(e)||null!=t&&e in Object(t)}(t,e)?[t]:function(e){return $(e)?e:F(e)}(t);for(var o=-1,i=t.length,s=i-1,a=e;null!=a&&++o<i;){var c=G(t[o]),u=n;if(o!=s){var d=a[c];void 0===(u=r?r(d,c,a):void 0)&&(u=J(d)?d:q(t[o+1])?[]:{})}k(a,c,u),a=a[c]}return e}(e,t,n)}},104:(e,t,n)=>{var r,o="__lodash_hash_undefined__",i=1/0,s="[object Function]",a="[object GeneratorFunction]",c="[object Symbol]",u=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,l=/^\w*$/,h=/^\./,d=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,f=/\\(\\)?/g,p=/^\[object .+?Constructor\]$/,v="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,_="object"==typeof self&&self&&self.Object===Object&&self,g=v||_||Function("return this")(),E=Array.prototype,y=Function.prototype,I=Object.prototype,m=g["__core-js_shared__"],w=(r=/[^.]+$/.exec(m&&m.keys&&m.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",b=y.toString,S=I.hasOwnProperty,T=I.toString,A=RegExp("^"+b.call(S).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),R=g.Symbol,C=E.splice,N=K(g,"Map"),D=K(Object,"create"),L=R?R.prototype:void 0,O=L?L.toString:void 0;function W(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function P(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function M(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function j(e,t){for(var n,r,o=e.length;o--;)if((n=e[o][0])===(r=t)||n!=n&&r!=r)return o;return-1}function x(e){return G(e)?e:H(e)}function k(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function K(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){if(!U(e)||w&&w in e)return!1;var t=function(e){var t=U(e)?T.call(e):"";return t==s||t==a}(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?A:p;return t.test(function(e){if(null!=e){try{return b.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}(n)?n:void 0}function B(e,t){if(G(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!V(e))||l.test(e)||!u.test(e)||null!=t&&e in Object(t)}W.prototype.clear=function(){this.__data__=D?D(null):{}},W.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},W.prototype.get=function(e){var t=this.__data__;if(D){var n=t[e];return n===o?void 0:n}return S.call(t,e)?t[e]:void 0},W.prototype.has=function(e){var t=this.__data__;return D?void 0!==t[e]:S.call(t,e)},W.prototype.set=function(e,t){return this.__data__[e]=D&&void 0===t?o:t,this},P.prototype.clear=function(){this.__data__=[]},P.prototype.delete=function(e){var t=this.__data__,n=j(t,e);return!(n<0||(n==t.length-1?t.pop():C.call(t,n,1),0))},P.prototype.get=function(e){var t=this.__data__,n=j(t,e);return n<0?void 0:t[n][1]},P.prototype.has=function(e){return j(this.__data__,e)>-1},P.prototype.set=function(e,t){var n=this.__data__,r=j(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},M.prototype.clear=function(){this.__data__={hash:new W,map:new(N||P),string:new W}},M.prototype.delete=function(e){return k(this,e).delete(e)},M.prototype.get=function(e){return k(this,e).get(e)},M.prototype.has=function(e){return k(this,e).has(e)},M.prototype.set=function(e,t){return k(this,e).set(e,t),this};var H=F((function(e){var t;e=null==(t=e)?"":function(e){if("string"==typeof e)return e;if(V(e))return O?O.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(t);var n=[];return h.test(e)&&n.push(""),e.replace(d,(function(e,t,r,o){n.push(r?o.replace(f,"$1"):t||e)})),n}));function q(e){if("string"==typeof e||V(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function F(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=e.apply(this,r);return n.cache=i.set(o,s),s};return n.cache=new(F.Cache||M),n}F.Cache=M;var G=Array.isArray;function U(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function V(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&T.call(e)==c}e.exports=function(e,t){return null==e||function(e,t){e=function(e,t){return 1==t.length?e:function(e,t){for(var n=0,r=(t=B(t,e)?[t]:x(t)).length;null!=e&&n<r;)e=e[q(t[n++])];return n&&n==r?e:void 0}(e,function(e,t,n){var r=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=Array(o);++r<o;)i[r]=e[r+t];return i}(t,0,-1))}(e,t=B(t,e)?[t]:x(t));var n,r,o=q((r=(n=t)?n.length:0)?n[r-1]:void 0);return!(null!=e&&S.call(e,o))||delete e[o]}(e,t)}},63:(e,t,n)=>{"use strict";n.r(t),n.d(t,{registerRealtime:()=>H});var r=n(478),o=n.n(r),i=n(104),s=n.n(i),a=n(982),c=n.n(a);function u(e){return void 0===e&&(e=""),"".concat(e?"".concat(e,"_"):"").concat(+new Date,"_").concat(Math.random())}var l,h,d=function(e){this.close=e.close,this.onChange=e.onChange,this.onError=e.onError,e.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return e.virtualClient}})},f=function(e){var t,n,r=e.id,o=e.docChanges,i=e.docs,s=e.msgType,a=e.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return t||(t=JSON.parse(JSON.stringify(o))),t},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})},p=(l=function(e,t){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},l(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),v=function(e){function t(t){var n=e.call(this,"Watch Error ".concat(JSON.stringify(t.msgData)," (requestid: ").concat(t.requestId,")"))||this;return n.isRealtimeErrorMessageError=!0,n.payload=t,n}return p(t,e),t}(Error),_=function(e){return null==e?void 0:e.isRealtimeErrorMessageError},g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="timeout",t.payload=null,t.generic=!0,t}return p(t,e),t}(Error),E=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="cancelled",t.payload=null,t.generic=!0,t}return p(t,e),t}(Error),y=function(e){function t(t){var n=e.call(this,t.errMsg)||this;return n.errCode="UNKNOWN_ERROR",Object.defineProperties(n,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(I[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e}}}),n.errCode=t.errCode||"UNKNOWN_ERROR",n.errMsg=t.errMsg,n}return p(t,e),Object.defineProperty(t.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(e){this.errMsg=e},enumerable:!1,configurable:!0}),t}(Error),I={UNKNOWN_ERROR:"UNKNOWN_ERROR",SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL",SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG:"SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG",SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA:"SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR",SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED:"SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED",SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL:"SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL",SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR:"SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR"},m=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},w=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},b=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},S=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};!function(e){e.LOGGINGIN="LOGGINGIN",e.INITING="INITING",e.REBUILDING="REBUILDING",e.ACTIVE="ACTIVE",e.ERRORED="ERRORED",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.PAUSED="PAUSED",e.RESUMING="RESUMING"}(h||(h={}));var T=function(){function e(e){var t=this;this.watchStatus=h.INITING,this.wsLogin=function(e,n){return w(t,void 0,void 0,(function(){var t;return b(this,(function(r){switch(r.label){case 0:return this.watchStatus=h.LOGGINGIN,[4,this.login(e,n)];case 1:return t=r.sent(),this.envId||(this.envId=t.envId),[2,t]}}))}))},this.initWatch=function(e){return w(t,void 0,void 0,(function(){var t,n=this;return b(this,(function(r){switch(r.label){case 0:if(null!==this.initWatchPromise&&void 0!==this.initWatchPromise)return[2,this.initWatchPromise];this.initWatchPromise=new Promise((function(t,r){w(n,void 0,void 0,(function(){var n,o,i,s,a,c,l,d,p,v;return b(this,(function(_){switch(_.label){case 0:return _.trys.push([0,3,,4]),this.watchStatus===h.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:return n=_.sent().envId,this.watchStatus===h.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,t()]):(this.watchStatus=h.INITING,o={watchId:this.watchId,requestId:u(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(i=_.sent(),s=i.msgData,a=s.events,c=s.currEvent,this.sessionInfo={queryID:i.msgData.queryID,currentEventId:c-1,currentDocs:[]},a.length>0){for(l=0,d=a;l<d.length;l++)d[l].ID=c;this.handleServerEvents(i)}else this.sessionInfo.currentEventId=c,p=new f({id:c,docChanges:[],docs:[],type:"init"}),this.listener.onChange(p),this.scheduleSendACK();return this.onWatchStart(this,this.sessionInfo.queryID),this.watchStatus=h.ACTIVE,this.availableRetries.INIT_WATCH=2,t(),[3,4];case 3:return v=_.sent(),this.handleWatchEstablishmentError(v,{operationName:"INIT_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(t?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(e){return w(t,void 0,void 0,(function(){var t,n=this;return b(this,(function(r){switch(r.label){case 0:if(null!==this.rebuildWatchPromise&&void 0!==this.rebuildWatchPromise)return[2,this.rebuildWatchPromise];this.rebuildWatchPromise=new Promise((function(t,r){w(n,void 0,void 0,(function(){var n,o,i,s;return b(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),this.watchStatus===h.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):[4,this.wsLogin(this.envId,e)];case 1:if(n=a.sent().envId,!this.sessionInfo)throw new Error("can not rebuildWatch without a successful initWatch (lack of sessionInfo)");return this.watchStatus===h.PAUSED?(console.log("[realtime] rebuildWatch cancelled on pause"),[2,t()]):(this.watchStatus=h.REBUILDING,o={watchId:this.watchId,requestId:u(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return i=a.sent(),this.handleServerEvents(i),this.watchStatus=h.ACTIVE,this.availableRetries.REBUILD_WATCH=2,t(),[3,4];case 3:return s=a.sent(),this.handleWatchEstablishmentError(s,{operationName:"REBUILD_WATCH",resolve:t,reject:r}),[3,4];case 4:return[2]}}))}))})),t=!1,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return r.sent(),t=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(t?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(e,n){return w(t,void 0,void 0,(function(){var t,r,o,i=this;return b(this,(function(s){return t="INIT_WATCH"===n.operationName,r=function(){i.closeWithError(new y({errCode:t?I.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:I.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),n.reject(e)},o=function(e){i.useRetryTicket(n.operationName)?t?(i.initWatchPromise=void 0,n.resolve(i.initWatch(e))):(i.rebuildWatchPromise=void 0,n.resolve(i.rebuildWatch(e))):r()},this.handleCommonError(e,{onSignError:function(){return o(!0)},onTimeoutError:function(){return o(!1)},onNotRetryableError:r,onCancelledError:n.reject,onUnknownError:function(){w(i,void 0,void 0,(function(){var e,t=this;return b(this,(function(r){switch(r.label){case 0:return r.trys.push([0,8,,9]),e=function(){return w(t,void 0,void 0,(function(){return b(this,(function(e){switch(e.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return e.sent(),o(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,e()];case 1:return r.sent(),[3,7];case 2:return[4,m(100)];case 3:return r.sent(),this.watchStatus!==h.PAUSED?[3,4]:(n.reject(new E("".concat(n.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,e()];case 5:return r.sent(),[3,7];case 6:o(!1),r.label=7;case 7:return[3,9];case 8:return r.sent(),o(!0),[3,9];case 9:return[2]}}))}))}}),[2]}))}))},this.closeWatch=function(){return w(t,void 0,void 0,(function(){var e,t,n;return b(this,(function(r){switch(r.label){case 0:if(e=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==h.ACTIVE)return this.watchStatus=h.CLOSED,this.onWatchClose(this,e),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=h.CLOSING,t={watchId:this.watchId,requestId:u(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:t})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=h.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,e),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){t.clearACKSchedule(),t.ackTimeoutId=setTimeout((function(){t.waitExpectedTimeoutId?t.scheduleSendACK():t.sendACK()}),1e4)},this.clearACKSchedule=function(){t.ackTimeoutId&&clearTimeout(t.ackTimeoutId)},this.sendACK=function(){return w(t,void 0,void 0,(function(){var e,t,n;return b(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==h.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(e={watchId:this.watchId,requestId:u(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:e})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(t=r.sent(),_(t))switch((n=t.payload).msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return this.rebuildWatch(),[2];case"QUERYID_INVALID_ERROR":case"SYS_ERR":case"INVALIID_ENV":case"COLLECTION_PERMISSION_DENIED":return this.closeWithError(new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if(_(e))switch(e.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void t.onSignError(e);default:return void t.onNotRetryableError(e)}else{if(function(e){return"timeout"===e.type}(e))return void t.onTimeoutError(e);if(function(e){return"cancelled"===e.type}(e))return void t.onCancelledError(e)}t.onUnknownError(e)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=e.envId,this.collectionName=e.collectionName,this.query=e.query,this.limit=e.limit,this.orderBy=e.orderBy,this.send=e.send,this.login=e.login,this.isWSConnected=e.isWSConnected,this.onceWSConnected=e.onceWSConnected,this.getWaitExpectedTimeoutLength=e.getWaitExpectedTimeoutLength,this.onWatchStart=e.onWatchStart,this.onWatchClose=e.onWatchClose,this.debug=e.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new d({close:function(){t.closeWatch()},onChange:e.onChange,onError:e.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return e.prototype.onMessage=function(e){var t=this;switch(this.watchStatus){case h.PAUSED:if("ERROR"!==e.msgType)return;break;case h.LOGGINGIN:case h.INITING:case h.REBUILDING:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received while ".concat(this.watchStatus));case h.CLOSED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has closed");case h.ERRORED:return void console.warn("[realtime listener] internal non-fatal error: unexpected message received when the watch has ended with error")}if(this.sessionInfo)switch(this.scheduleSendACK(),e.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(e.msgData.currEvent," ignored"),e),this.handleServerEvents(e);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<e.msgData.currEvent&&(this.sessionInfo.expectEventId=e.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){t.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength ".concat(this.getWaitExpectedTimeoutLength())));break;case"ERROR":this.closeWithError(new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:"".concat(e.msgData.code," - ").concat(e.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(e.msgType,": "),e)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},e.prototype.closeWithError=function(e){var t;this.watchStatus=h.ERRORED,this.clearACKSchedule(),this.listener.onError(e),this.onWatchClose(this,(null===(t=this.sessionInfo)||void 0===t?void 0:t.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.pause=function(){this.watchStatus=h.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},e.prototype.resume=function(){return w(this,void 0,void 0,(function(){var e;return b(this,(function(t){switch(t.label){case 0:this.watchStatus=h.RESUMING,console.log("[realtime] client resuming with ".concat(this.sessionInfo?"REBUILD_WATCH":"INIT_WATCH"," (").concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return t.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return e=t.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),e),[3,4];case 4:return[2]}}))}))},e.prototype.useRetryTicket=function(e){return!!(this.availableRetries[e]&&this.availableRetries[e]>0)&&(this.availableRetries[e]-=1,console.log("[realtime] ".concat(e," use a retry ticket, now only ").concat(this.availableRetries[e]," retry left")),!0)},e.prototype.handleServerEvents=function(e){return w(this,void 0,void 0,(function(){var t;return b(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(e)];case 1:return n.sent(),this.postHandleServerEventsValidityCheck(e),[3,3];case 2:throw t=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",t),t;case 3:return[2]}}))}))},e.prototype.handleServerEventsInternel=function(e){return w(this,void 0,void 0,(function(){var t,n,r,i,a,u,l,h,d,p,v,_;return b(this,(function(g){switch(g.label){case 0:if(t=e.requestId,n=e.msgData.events,r=e.msgType,!n.length||!this.sessionInfo)return[2];i=this.sessionInfo;try{a=n.map(A)}catch(e){return this.closeWithError(new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:e})),[2]}u=S([],i.currentDocs,!0),l=!1,h=function(n,h){var p,v,_,g,E,m,w,T,A,R,C,N;return b(this,(function(b){switch(b.label){case 0:return p=a[n],i.currentEventId>=p.id?(!a[n-1]||p.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur ".concat(i.currentEventId," but got ").concat(p.id)):console.error("[realtime listener] server non-fatal error: events out of order (the latter event's id is smaller than that of the former) (requestId ".concat(t,")")),[2,"continue"]):[3,1];case 1:if(i.currentEventId!==p.id-1)return[3,2];switch(p.dataType){case"update":if(!p.doc)switch(p.queueType){case"update":case"dequeue":if(v=u.find((function(e){return e._id===p.docId})),v){if(_=c()(v),p.updatedFields&&Object.keys(p.updatedFields).forEach((function(e){o()(_,e,p.updatedFields[e])})),p.removedFields)for(g=0,E=p.removedFields;g<E.length;g++)m=E[g],s()(_,m);p.doc=_}else console.error("[realtime listener] internal non-fatal server error: unexpected update dataType event where no doc is associated.");break;case"enqueue":throw T=new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '.concat(e.requestId,")")}),d.closeWithError(T),T}break;case"replace":if(!p.doc)throw T=new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(e.requestId,")")}),d.closeWithError(T),T;break;case"remove":(w=u.find((function(e){return e._id===p.docId})))?p.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!p.doc)switch(p.queueType){case"dequeue":(w=u.find((function(e){return e._id===p.docId})))?p.doc=w:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw T=new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '.concat(e.requestId,")")}),d.closeWithError(T),T}}switch(p.queueType){case"init":l?u.push(p.doc):(l=!0,u=[p.doc]);break;case"enqueue":u.push(p.doc);break;case"dequeue":A=u.findIndex((function(e){return e._id===p.docId})),A>-1?u.splice(A,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":A=u.findIndex((function(e){return e._id===p.docId})),A>-1?u[A]=p.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===h-1||a[n+1]&&a[n+1].id!==p.id)&&(R=S([],u,!0),C=a.slice(0,n+1).filter((function(e){return e.id===p.id})),d.sessionInfo.currentEventId=p.id,d.sessionInfo.currentDocs=u,N=new f({id:p.id,docChanges:C,docs:R,msgType:r}),d.listener.onChange(N)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(d.sessionInfo.currentEventId," but got ").concat(p.id)),[4,d.rebuildWatch()];case 3:return b.sent(),[2,{value:void 0}];case 4:return[2]}}))},d=this,p=0,v=a.length,g.label=1;case 1:return p<v?[5,h(p,v)]:[3,4];case 2:if("object"==typeof(_=g.sent()))return[2,_.value];g.label=3;case 3:return p++,[3,1];case 4:return[2]}}))}))},e.prototype.postHandleServerEventsValidityCheck=function(e){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<e.msgData.currEvent&&console.warn("[realtime listener] internal non-fatal error: client eventId does not match with server event id after server event handling")):console.error("[realtime listener] internal non-fatal error: sessionInfo lost after server event handling, this should never occur")},e.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},e}();function A(e){var t={id:e.ID,dataType:e.DataType,queueType:e.QueueType,docId:e.DocID,doc:e.Doc&&"{}"!==e.Doc?JSON.parse(e.Doc):void 0};return"update"===e.DataType&&(e.UpdatedFields&&(t.updatedFields=JSON.parse(e.UpdatedFields)),(e.removedFields||e.RemovedFields)&&(t.removedFields=JSON.parse(e.removedFields))),t}var R,C={1e3:{code:1e3,name:"Normal Closure",description:"Normal closure; the connection successfully completed whatever purpose for which it was created."},1001:{code:1001,name:"Going Away",description:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{code:1002,name:"Protocol Error",description:"The endpoint is terminating the connection due to a protocol error."},1003:{code:1003,name:"Unsupported Data",description:"The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data)."},1005:{code:1005,name:"No Status Received",description:"Indicates that no status code was provided even though one was expected."},1006:{code:1006,name:"Abnormal Closure",description:"Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{code:1007,name:"Invalid frame payload data",description:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{code:1008,name:"Policy Violation",description:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{code:1009,name:"Message too big",description:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{code:1010,name:"Missing Extension",description:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{code:1011,name:"Internal Error",description:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{code:1012,name:"Service Restart",description:"The server is terminating the connection because it is restarting."},1013:{code:1013,name:"Try Again Later",description:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{code:1014,name:"Bad Gateway",description:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{code:1015,name:"TLS Handshake",description:"Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},3e3:{code:3e3,name:"Reconnect WebSocket",description:"The client is terminating the connection because it wants to reconnect"},3001:{code:3001,name:"No Realtime Listeners",description:"The client is terminating the connection because no more realtime listeners exist"},3002:{code:3002,name:"Heartbeat Ping Error",description:"The client is terminating the connection due to its failure in sending heartbeat messages"},3003:{code:3003,name:"Heartbeat Pong Timeout Error",description:"The client is terminating the connection because no heartbeat response is received from the server"},3050:{code:3050,name:"Server Close",description:"The client is terminating the connection because no heartbeat response is received from the server"}};!function(e){e[e.NormalClosure=1e3]="NormalClosure",e[e.GoingAway=1001]="GoingAway",e[e.ProtocolError=1002]="ProtocolError",e[e.UnsupportedData=1003]="UnsupportedData",e[e.NoStatusReceived=1005]="NoStatusReceived",e[e.AbnormalClosure=1006]="AbnormalClosure",e[e.InvalidFramePayloadData=1007]="InvalidFramePayloadData",e[e.PolicyViolation=1008]="PolicyViolation",e[e.MessageTooBig=1009]="MessageTooBig",e[e.MissingExtension=1010]="MissingExtension",e[e.InternalError=1011]="InternalError",e[e.ServiceRestart=1012]="ServiceRestart",e[e.TryAgainLater=1013]="TryAgainLater",e[e.BadGateway=1014]="BadGateway",e[e.TLSHandshake=1015]="TLSHandshake",e[e.ReconnectWebSocket=3e3]="ReconnectWebSocket",e[e.NoRealtimeListeners=3001]="NoRealtimeListeners",e[e.HeartbeatPingError=3002]="HeartbeatPingError",e[e.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",e[e.NoAuthentication=3050]="NoAuthentication"}(R||(R={}));var N=function(e,t){var n=C[e],r=n?"".concat(n.name,", code ").concat(e,", reason ").concat(t||n.description):"code ".concat(e);return new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:r})},D=null,L="web";function O(){return D}function W(){return L}function P(e){L=e}var M=function(){return M=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},M.apply(this,arguments)},j=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},x=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},k=function(){function e(e){var t=this;this.virtualWSClient=new Set,this.queryIdClientMap=new Map,this.watchIdClientMap=new Map,this.pingFailed=0,this.pongMissed=0,this.logins=new Map,this.wsReadySubsribers=[],this.wsResponseWait=new Map,this.rttObserved=[],this.send=function(e){return j(t,void 0,void 0,(function(){var t=this;return x(this,(function(n){return[2,new Promise((function(n,r){j(t,void 0,void 0,(function(){var t,o,i,s,a,c,u,l,h=this;return x(this,(function(d){switch(d.label){case 0:o=!1,i=!1,s=function(e){o=!0,t&&clearTimeout(t),n(e)},a=function(e){i=!0,t&&clearTimeout(t),r(e)},e.timeout&&(t=setTimeout((function(){j(h,void 0,void 0,(function(){return x(this,(function(e){switch(e.label){case 0:return o&&i?[3,2]:[4,m(0)];case 1:e.sent(),o&&i||a(new g("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),d.label=1;case 1:return d.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:d.sent(),d.label=3;case 3:if(!this.ws)return a(new Error("invalid state: ws connection not exists, can not send message")),[2];if(1!==this.ws.readyState)return a(new Error("ws readyState invalid: ".concat(this.ws.readyState,", can not send message"))),[2];e.waitResponse&&(c={resolve:s,reject:a,skipOnMessage:e.skipOnMessage},this.wsResponseWait.set(e.msg.requestId,c)),d.label=4;case 4:return d.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(e.msg))];case 5:return d.sent(),e.waitResponse||s(void 0),[3,7];case 6:return(u=d.sent())&&(a(u),e.waitResponse&&this.wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return l=d.sent(),a(l),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(e){t.virtualWSClient.forEach((function(t){t.closeWithError(e)}))},this.pauseClients=function(e){(e||t.virtualWSClient).forEach((function(e){e.pause()}))},this.resumeClients=function(e){(e||t.virtualWSClient).forEach((function(e){e.resume()}))},this.initWebSocketConnection=function(e,n){return void 0===n&&(n=t.maxReconnect),j(t,void 0,void 0,(function(){var t=this;return x(this,(function(r){switch(r.label){case 0:if(e&&this.reconnectState)return[2];if(e&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];e&&this.pauseClients(),this.close(R.ReconnectWebSocket),this.wsInitPromise=new Promise((function(r,o){j(t,void 0,void 0,(function(){var t,i,s=this;return x(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,11]),[4,this.getWsSign()];case 1:return t=a.sent(),[4,new Promise((function(e){var n=t.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=O();s.ws=r?new r(n):new WebSocket(n),e(void 0)}))];case 2:return a.sent(),this.ws.connect?[4,this.ws.connect()]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,this.initWebSocketEvent()];case 5:return a.sent(),r(),e&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return i=a.sent(),console.error("[realtime] initWebSocketConnection connect fail",i),n>0?(this.wsInitPromise=void 0,[4,m(this.reconnectInterval)]):[3,9];case 7:a.sent(),e&&(this.reconnectState=!1),a.label=8;case 8:return r(this.initWebSocketConnection(e,n-1)),[3,10];case 9:o(i),e&&this.closeAllClients(new y({errCode:I.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:i})),a.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return r.sent(),this.wsReadySubsribers.forEach((function(e){return(0,e.resolve)()})),[3,5];case 3:return r.sent(),this.wsReadySubsribers.forEach((function(e){return(0,e.reject)()})),[3,5];case 4:return this.wsInit