@onyx-p/imlib-web 1.0.11 → 1.0.12
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.
- package/dist/index.esm.js +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -15,7 +15,7 @@ return e.mode.CTRGladman=function(){var t=e.lib.BlockCipherMode.extend();functio
|
|
15
15
|
|
16
16
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
17
17
|
*/
|
18
|
-
return function(t){var r=e,n=r.lib,o=n.WordArray,i=n.Hasher,s=r.algo,a=o.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=o.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=o.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=o.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),d=o.create([0,1518500249,1859775393,2400959708,2840853838]),h=o.create([1352829926,1548603684,1836072691,2053994217,0]),f=s.RIPEMD160=i.extend({_doReset:function(){this._hash=o.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,o=e[n];e[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i,s,f,w,O,C,_,S,I,E,T,R=this._hash.words,k=d.words,A=h.words,N=a.words,x=c.words,D=l.words,M=u.words;for(C=i=R[0],_=s=R[1],S=f=R[2],I=w=R[3],E=O=R[4],r=0;r<80;r+=1)T=i+e[t+N[r]]|0,T+=r<16?p(s,f,w)+k[0]:r<32?g(s,f,w)+k[1]:r<48?y(s,f,w)+k[2]:r<64?v(s,f,w)+k[3]:m(s,f,w)+k[4],T=(T=b(T|=0,D[r]))+O|0,i=O,O=w,w=b(f,10),f=s,s=T,T=C+e[t+x[r]]|0,T+=r<16?m(_,S,I)+A[0]:r<32?v(_,S,I)+A[1]:r<48?y(_,S,I)+A[2]:r<64?g(_,S,I)+A[3]:p(_,S,I)+A[4],T=(T=b(T|=0,M[r]))+E|0,C=E,E=I,I=b(S,10),S=_,_=T;T=R[1]+f+I|0,R[1]=R[2]+w+E|0,R[2]=R[3]+O+C|0,R[3]=R[4]+i+_|0,R[4]=R[0]+s+S|0,R[0]=T},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var o=this._hash,i=o.words,s=0;s<5;s++){var a=i[s];i[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return o},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,r){return e^t^r}function g(e,t,r){return e&t|~e&r}function y(e,t,r){return(e|~t)^r}function v(e,t,r){return e&r|t&~r}function m(e,t,r){return e^(t|~r)}function b(e,t){return e<<t|e>>>32-t}r.RIPEMD160=i._createHelper(f),r.HmacRIPEMD160=i._createHmacHelper(f)}(),e.RIPEMD160}(z())),ke(),Ae||(Ae=1,Ne.exports=function(e){return n=(r=(t=e).lib).Base,o=r.WordArray,s=(i=t.algo).SHA1,a=i.HMAC,c=i.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=a.create(r.hasher,e),i=o.create(),s=o.create([1]),c=i.words,l=s.words,u=r.keySize,d=r.iterations;c.length<u;){var h=n.update(t).finalize(s);n.reset();for(var f=h.words,p=f.length,g=h,y=1;y<d;y++){g=n.finalize(g),n.reset();for(var v=g.words,m=0;m<p;m++)f[m]^=v[m]}i.concat(h),l[0]++}return i.sigBytes=4*u,i}}),t.PBKDF2=function(e,t,r){return c.create(r).compute(e,t)},e.PBKDF2;var t,r,n,o,i,s,a,c}(z(),de(),ke())),Me(),Ue(),Fe(),He(),Ve(),Je(),Ze||(Ze=1,Xe.exports=function(e){return e.mode.ECB=((t=e.lib.BlockCipherMode.extend()).Encryptor=t.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),t.Decryptor=t.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),t),e.mode.ECB;var t}(z(),Ue())),Ye||(Ye=1,Qe.exports=function(e){return e.pad.AnsiX923={pad:function(e,t){var r=e.sigBytes,n=4*t,o=n-r%n,i=r+o-1;e.clamp(),e.words[i>>>2]|=o<<24-i%4*8,e.sigBytes+=o},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Ansix923}(z(),Ue())),et||(et=1,tt.exports=function(e){return e.pad.Iso10126={pad:function(t,r){var n=4*r,o=n-t.sigBytes%n;t.concat(e.lib.WordArray.random(o-1)).concat(e.lib.WordArray.create([o<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Iso10126}(z(),Ue())),rt||(rt=1,nt.exports=function(e){return e.pad.Iso97971={pad:function(t,r){t.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(t,r)},unpad:function(t){e.pad.ZeroPadding.unpad(t),t.sigBytes--}},e.pad.Iso97971}(z(),Ue())),ot||(ot=1,it.exports=function(e){return e.pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){var t=e.words,r=e.sigBytes-1;for(r=e.sigBytes-1;r>=0;r--)if(t[r>>>2]>>>24-r%4*8&255){e.sigBytes=r+1;break}}},e.pad.ZeroPadding}(z(),Ue())),st||(st=1,at.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(z(),Ue())),ct||(ct=1,lt.exports=function(e){return r=(t=e).lib.CipherParams,n=t.enc.Hex,t.format.Hex={stringify:function(e){return e.ciphertext.toString(n)},parse:function(e){var t=n.parse(e);return r.create({ciphertext:t})}},e.format.Hex;var t,r,n}(z(),Ue())),ut||(ut=1,dt.exports=function(e){return function(){var t=e,r=t.lib.BlockCipher,n=t.algo,o=[],i=[],s=[],a=[],c=[],l=[],u=[],d=[],h=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var p=n^n<<1^n<<2^n<<3^n<<4;p=p>>>8^255&p^99,o[r]=p,i[p]=r;var g=e[r],y=e[g],v=e[y],m=257*e[p]^16843008*p;s[r]=m<<24|m>>>8,a[r]=m<<16|m>>>16,c[r]=m<<8|m>>>24,l[r]=m,m=16843009*v^65537*y^257*g^16843008*r,u[p]=m<<24|m>>>8,d[p]=m<<16|m>>>16,h[p]=m<<8|m>>>24,f[p]=m,r?(r=g^e[e[e[v^g]]],n^=e[e[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],g=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),i=this._keySchedule=[],s=0;s<n;s++)s<r?i[s]=t[s]:(l=i[s-1],s%r?r>6&&s%r==4&&(l=o[l>>>24]<<24|o[l>>>16&255]<<16|o[l>>>8&255]<<8|o[255&l]):(l=o[(l=l<<8|l>>>24)>>>24]<<24|o[l>>>16&255]<<16|o[l>>>8&255]<<8|o[255&l],l^=p[s/r|0]<<24),i[s]=i[s-r]^l);for(var a=this._invKeySchedule=[],c=0;c<n;c++){if(s=n-c,c%4)var l=i[s];else l=i[s-4];a[c]=c<4||s<=4?l:u[o[l>>>24]]^d[o[l>>>16&255]]^h[o[l>>>8&255]]^f[o[255&l]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,l,o)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,u,d,h,f,i),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,o,i,s,a){for(var c=this._nRounds,l=e[t]^r[0],u=e[t+1]^r[1],d=e[t+2]^r[2],h=e[t+3]^r[3],f=4,p=1;p<c;p++){var g=n[l>>>24]^o[u>>>16&255]^i[d>>>8&255]^s[255&h]^r[f++],y=n[u>>>24]^o[d>>>16&255]^i[h>>>8&255]^s[255&l]^r[f++],v=n[d>>>24]^o[h>>>16&255]^i[l>>>8&255]^s[255&u]^r[f++],m=n[h>>>24]^o[l>>>16&255]^i[u>>>8&255]^s[255&d]^r[f++];l=g,u=y,d=v,h=m}g=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[d>>>8&255]<<8|a[255&h])^r[f++],y=(a[u>>>24]<<24|a[d>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[f++],v=(a[d>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^r[f++],m=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&d])^r[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=m},keySize:8});t.AES=r._createHelper(g)}(),e.AES}(z(),re(),ce(),Me(),Ue())),pt(),gt||(gt=1,yt.exports=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,o=n.RC4=r.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,n=this._S=[],o=0;o<256;o++)n[o]=o;o=0;for(var i=0;o<256;o++){var s=o%r,a=t[s>>>2]>>>24-s%4*8&255;i=(i+n[o]+a)%256;var c=n[o];n[o]=n[i],n[i]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=i.call(this)},keySize:8,ivSize:0});function i(){for(var e=this._S,t=this._i,r=this._j,n=0,o=0;o<4;o++){r=(r+e[t=(t+1)%256])%256;var i=e[t];e[t]=e[r],e[r]=i,n|=e[(e[t]+e[r])%256]<<24-8*o}return this._i=t,this._j=r,n}t.RC4=r._createHelper(o);var s=n.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)i.call(this)}});t.RC4Drop=r._createHelper(s)}(),e.RC4}(z(),re(),ce(),Me(),Ue())),vt||(vt=1,mt.exports=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,o=[],i=[],s=[],a=n.Rabbit=r.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],o=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,r=0;r<4;r++)c.call(this);for(r=0;r<8;r++)o[r]^=n[r+4&7];if(t){var i=t.words,s=i[0],a=i[1],l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(o[0]^=l,o[1]^=d,o[2]^=u,o[3]^=h,o[4]^=l,o[5]^=d,o[6]^=u,o[7]^=h,r=0;r<4;r++)c.call(this)}},_doProcessBlock:function(e,t){var r=this._X;c.call(this),o[0]=r[0]^r[5]>>>16^r[3]<<16,o[1]=r[2]^r[7]>>>16^r[5]<<16,o[2]=r[4]^r[1]>>>16^r[7]<<16,o[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)o[n]=16711935&(o[n]<<8|o[n]>>>24)|4278255360&(o[n]<<24|o[n]>>>8),e[t+n]^=o[n]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<i[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<i[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<i[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<i[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<i[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<i[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<i[6]>>>0?1:0)|0,this._b=t[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=e[r]+t[r],o=65535&n,a=n>>>16,c=((o*o>>>17)+o*a>>>15)+a*a,l=((4294901760&n)*n|0)+((65535&n)*n|0);s[r]=c^l}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}t.Rabbit=r._createHelper(a)}(),e.Rabbit}(z(),re(),ce(),Me(),Ue())),bt||(bt=1,wt.exports=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,o=[],i=[],s=[],a=n.RabbitLegacy=r.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var o=0;o<4;o++)c.call(this);for(o=0;o<8;o++)n[o]^=r[o+4&7];if(t){var i=t.words,s=i[0],a=i[1],l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(n[0]^=l,n[1]^=d,n[2]^=u,n[3]^=h,n[4]^=l,n[5]^=d,n[6]^=u,n[7]^=h,o=0;o<4;o++)c.call(this)}},_doProcessBlock:function(e,t){var r=this._X;c.call(this),o[0]=r[0]^r[5]>>>16^r[3]<<16,o[1]=r[2]^r[7]>>>16^r[5]<<16,o[2]=r[4]^r[1]>>>16^r[7]<<16,o[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)o[n]=16711935&(o[n]<<8|o[n]>>>24)|4278255360&(o[n]<<24|o[n]>>>8),e[t+n]^=o[n]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<i[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<i[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<i[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<i[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<i[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<i[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<i[6]>>>0?1:0)|0,this._b=t[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=e[r]+t[r],o=65535&n,a=n>>>16,c=((o*o>>>17)+o*a>>>15)+a*a,l=((4294901760&n)*n|0)+((65535&n)*n|0);s[r]=c^l}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}t.RabbitLegacy=r._createHelper(a)}(),e.RabbitLegacy}(z(),re(),ce(),Me(),Ue())));const Ct=e=>Object.keys(e),_t=e=>{const t={};return Object.keys(e).forEach((r=>{const n=e[r];f(n)&&(t[r]=m(n)?_t(n):n)})),t},St=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,r=null;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];r||(r=setTimeout((()=>{e.call(null,...o),r=null}),t))}},It=Ot.enc.Utf8.parse("skdjhfgc9829kslf"),Et=Ot.enc.Utf8.parse("qwdkshjf9838jsdf"),Tt={get:function(e){let t=localStorage.getItem(e);if(!f(t))return t;try{return t=JSON.parse(t),t}catch{return t}},set:function(e,t){f(t)?localStorage.setItem(e,JSON.stringify(t)):this.remove(e)},remove:function(e){localStorage.removeItem(e)}},Rt={get:function(e){let t=localStorage.getItem(e);if(f(t)){const e=Ot.enc.Hex.parse(t),r=Ot.enc.Base64.stringify(e);t=Ot.AES.decrypt(r,It,{iv:Et}).toString(Ot.enc.Utf8)}if(!f(t))return t;try{return t=JSON.parse(t),t}catch{return t}},set:function(e,t){if(f(t)){const r=Ot.AES.encrypt(JSON.stringify(t),It,{iv:Et}).ciphertext.toString();localStorage.setItem(e,r)}else this.remove(e)},remove:function(e){localStorage.removeItem(e)}};class kt{constructor(e){d(this,"cache",void 0),d(this,"storageKey",void 0),d(this,"saveFunc",void 0);const t=e?`ACIM-${e}`:"ACIM-",r=Tt.get(t)||{};this.cache=r,this.storageKey=t,this.saveFunc=St((()=>{Tt.set(this.storageKey,this.cache)}),10)}set(e,t){this.cache[e]=t,this.saveFunc()}remove(e){delete this.cache[e],this.saveFunc()}clear(){Tt.remove(this.storageKey),this.cache={}}get(e){return this.cache[e]}getCache(){return this.cache||{}}}var At={exports:{}},Nt={},xt={},Dt=function(e,t){var r=new Array(arguments.length-1),n=0,o=2,i=!0;for(;o<arguments.length;)r[n++]=arguments[o++];return new Promise((function(o,s){r[n]=function(e){if(i)if(i=!1,e)s(e);else{for(var t=new Array(arguments.length-1),r=0;r<t.length;)t[r++]=arguments[r];o.apply(null,t)}};try{e.apply(t||null,r)}catch(e){i&&(i=!1,s(e))}}))};var Mt={};!function(e){var t=Mt;t.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var r=new Array(64),n=new Array(123),o=0;o<64;)n[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;t.encode=function(e,t,n){for(var o,i=null,s=[],a=0,c=0;t<n;){var l=e[t++];switch(c){case 0:s[a++]=r[l>>2],o=(3&l)<<4,c=1;break;case 1:s[a++]=r[o|l>>4],o=(15&l)<<2,c=2;break;case 2:s[a++]=r[o|l>>6],s[a++]=r[63&l],c=0}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return c&&(s[a++]=r[o],s[a++]=61,1===c&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var i="invalid encoding";t.decode=function(e,t,r){for(var o,s=r,a=0,c=0;c<e.length;){var l=e.charCodeAt(c++);if(61===l&&a>1)break;if(void 0===(l=n[l]))throw Error(i);switch(a){case 0:o=l,a=1;break;case 1:t[r++]=o<<2|(48&l)>>4,o=l,a=2;break;case 2:t[r++]=(15&o)<<4|(60&l)>>2,o=l,a=3;break;case 3:t[r++]=(3&o)<<6|l,a=0}}if(1===a)throw Error(i);return r-s},t.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}}();var Lt=Bt;function Bt(){this._listeners={}}Bt.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},Bt.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n<r.length;)r[n].fn===t?r.splice(n,1):++n;return this},Bt.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,r)}return this};var Ut=jt(jt);function jt(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function o(e,n,o){t[0]=e,n[o]=r[0],n[o+1]=r[1],n[o+2]=r[2],n[o+3]=r[3]}function i(e,n,o){t[0]=e,n[o]=r[3],n[o+1]=r[2],n[o+2]=r[1],n[o+3]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function a(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?o:i,e.writeFloatBE=n?i:o,e.readFloatLE=n?s:a,e.readFloatBE=n?a:s}():function(){function t(e,t,r,n){var o=t<0?1:0;if(o&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((o<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((o<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var i=Math.floor(Math.log(t)/Math.LN2);e((o<<31|i+127<<23|8388607&Math.round(t*Math.pow(2,-i)*8388608))>>>0,r,n)}}function r(e,t,r){var n=e(t,r),o=2*(n>>31)+1,i=n>>>23&255,s=8388607&n;return 255===i?s?NaN:o*(1/0):0===i?1401298464324817e-60*o*s:o*Math.pow(2,i-150)*(s+8388608)}e.writeFloatLE=t.bind(null,Pt),e.writeFloatBE=t.bind(null,Ft),e.readFloatLE=r.bind(null,Gt),e.readFloatBE=r.bind(null,qt)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function o(e,n,o){t[0]=e,n[o]=r[0],n[o+1]=r[1],n[o+2]=r[2],n[o+3]=r[3],n[o+4]=r[4],n[o+5]=r[5],n[o+6]=r[6],n[o+7]=r[7]}function i(e,n,o){t[0]=e,n[o]=r[7],n[o+1]=r[6],n[o+2]=r[5],n[o+3]=r[4],n[o+4]=r[3],n[o+5]=r[2],n[o+6]=r[1],n[o+7]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function a(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?o:i,e.writeDoubleBE=n?i:o,e.readDoubleLE=n?s:a,e.readDoubleBE=n?a:s}():function(){function t(e,t,r,n,o,i){var s=n<0?1:0;if(s&&(n=-n),0===n)e(0,o,i+t),e(1/n>0?0:2147483648,o,i+r);else if(isNaN(n))e(0,o,i+t),e(2146959360,o,i+r);else if(n>17976931348623157e292)e(0,o,i+t),e((s<<31|2146435072)>>>0,o,i+r);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,o,i+t),e((s<<31|a/4294967296)>>>0,o,i+r);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=n*Math.pow(2,-c))>>>0,o,i+t),e((s<<31|c+1023<<20|1048576*a&1048575)>>>0,o,i+r)}}}function r(e,t,r,n,o){var i=e(n,o+t),s=e(n,o+r),a=2*(s>>31)+1,c=s>>>20&2047,l=4294967296*(1048575&s)+i;return 2047===c?l?NaN:a*(1/0):0===c?5e-324*a*l:a*Math.pow(2,c-1075)*(l+4503599627370496)}e.writeDoubleLE=t.bind(null,Pt,0,4),e.writeDoubleBE=t.bind(null,Ft,4,0),e.readDoubleLE=r.bind(null,Gt,0,4),e.readDoubleBE=r.bind(null,qt,4,0)}(),e}function Pt(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Ft(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function Gt(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function qt(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var Ht=function(e){try{var t=void 0;t}catch(e){}return null};var zt={};!function(e){var t=zt;t.length=function(e){for(var t=0,r=0,n=0;n<e.length;++n)(r=e.charCodeAt(n))<128?t+=1:r<2048?t+=2:55296==(64512&r)&&56320==(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},t.read=function(e,t,r){if(r-t<1)return"";for(var n,o=null,i=[],s=0;t<r;)(n=e[t++])<128?i[s++]=n:n>191&&n<224?i[s++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(n>>10),i[s++]=56320+(1023&n)):i[s++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o?(s&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))},t.write=function(e,t,r){for(var n,o,i=r,s=0;s<e.length;++s)(n=e.charCodeAt(s))<128?t[r++]=n:n<2048?(t[r++]=n>>6|192,t[r++]=63&n|128):55296==(64512&n)&&56320==(64512&(o=e.charCodeAt(s+1)))?(n=65536+((1023&n)<<10)+(1023&o),++s,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-i}}();var Kt,Vt,Wt,$t=function(e,t,r){var n=r||8192,o=n>>>1,i=null,s=n;return function(r){if(r<1||r>o)return e(r);s+r>n&&(i=e(n),s=0);var a=t.call(i,s,s+=r);return 7&s&&(s=1+(7|s)),a}};function Jt(){return Wt||(Wt=1,function(e){var t=xt;function r(e,t,r){for(var n=Object.keys(t),o=0;o<n.length;++o)void 0!==e[n[o]]&&r||(e[n[o]]=t[n[o]]);return e}function n(e){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),n&&r(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:()=>e,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}t.asPromise=Dt,t.base64=Mt,t.EventEmitter=Lt,t.float=Ut,t.inquire=Ht,t.utf8=zt,t.pool=$t,t.LongBits=function(){if(Vt)return Kt;Vt=1,Kt=t;var e=Jt();function t(e,t){this.lo=e>>>0,this.hi=t>>>0}var r=t.zero=new t(0,0);r.toNumber=function(){return 0},r.zzEncode=r.zzDecode=function(){return this},r.length=function(){return 1};var n=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(e){if(0===e)return r;var n=e<0;n&&(e=-e);var o=e>>>0,i=(e-o)/4294967296>>>0;return n&&(i=~i>>>0,o=~o>>>0,++o>4294967295&&(o=0,++i>4294967295&&(i=0))),new t(o,i)},t.from=function(n){if("number"==typeof n)return t.fromNumber(n);if(e.isString(n)){if(!e.Long)return t.fromNumber(parseInt(n,10));n=e.Long.fromString(n)}return n.low||n.high?new t(n.low>>>0,n.high>>>0):r},t.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},t.prototype.toLong=function(t){return e.Long?new e.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var o=String.prototype.charCodeAt;return t.fromHash=function(e){return e===n?r:new t((o.call(e,0)|o.call(e,1)<<8|o.call(e,2)<<16|o.call(e,3)<<24)>>>0,(o.call(e,4)|o.call(e,5)<<8|o.call(e,6)<<16|o.call(e,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},t.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},t.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10},Kt}(),t.isNode=Boolean(void 0!==P&&P&&P.process&&P.process.versions&&P.process.versions.node),t.global=t.isNode&&P||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||P,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.isString=function(e){return"string"==typeof e||e instanceof String},t.isObject=function(e){return e&&"object"==typeof e},t.isset=t.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},t.Buffer=function(){try{var e=t.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(e){return"number"==typeof e?t.Buffer?t._Buffer_allocUnsafe(e):new t.Array(e):t.Buffer?t._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},t.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(e){return e?t.LongBits.from(e).toHash():t.LongBits.zeroHash},t.longFromHash=function(e,r){var n=t.LongBits.fromHash(e);return t.Long?t.Long.fromBits(n.lo,n.hi,r):n.toNumber(Boolean(r))},t.merge=r,t.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},t.newError=n,t.ProtocolError=n("ProtocolError"),t.oneOfGetter=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},t.oneOfSetter=function(e){return function(t){for(var r=0;r<e.length;++r)e[r]!==t&&delete this[e[r]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var e=t.Buffer;e?(t._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,r){return new e(t,r)},t._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):t._Buffer_from=t._Buffer_allocUnsafe=null}}()),xt}var Zt,Xt=ir,Yt=Jt(),Qt=Yt.LongBits,er=Yt.base64,tr=Yt.utf8;function rr(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function nr(){}function or(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function ir(){this.len=0,this.head=new rr(nr,0,0),this.tail=this.head,this.states=null}var sr=function(){return Yt.Buffer?function(){return(ir.create=function(){return new Zt})()}:function(){return new ir}};function ar(e,t,r){t[r]=255&e}function cr(e,t){this.len=e,this.next=void 0,this.val=t}function lr(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function ur(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}ir.create=sr(),ir.alloc=function(e){return new Yt.Array(e)},Yt.Array!==Array&&(ir.alloc=Yt.pool(ir.alloc,Yt.Array.prototype.subarray)),ir.prototype._push=function(e,t,r){return this.tail=this.tail.next=new rr(e,t,r),this.len+=t,this},cr.prototype=Object.create(rr.prototype),cr.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},ir.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new cr((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},ir.prototype.int32=function(e){return e<0?this._push(lr,10,Qt.fromNumber(e)):this.uint32(e)},ir.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},ir.prototype.uint64=function(e){var t=Qt.from(e);return this._push(lr,t.length(),t)},ir.prototype.int64=ir.prototype.uint64,ir.prototype.sint64=function(e){var t=Qt.from(e).zzEncode();return this._push(lr,t.length(),t)},ir.prototype.bool=function(e){return this._push(ar,1,e?1:0)},ir.prototype.fixed32=function(e){return this._push(ur,4,e>>>0)},ir.prototype.sfixed32=ir.prototype.fixed32,ir.prototype.fixed64=function(e){var t=Qt.from(e);return this._push(ur,4,t.lo)._push(ur,4,t.hi)},ir.prototype.sfixed64=ir.prototype.fixed64,ir.prototype.float=function(e){return this._push(Yt.float.writeFloatLE,4,e)},ir.prototype.double=function(e){return this._push(Yt.float.writeDoubleLE,8,e)};var dr=Yt.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n<e.length;++n)t[r+n]=e[n]};ir.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(ar,1,0);if(Yt.isString(e)){var r=ir.alloc(t=er.length(e));er.decode(e,r,0),e=r}return this.uint32(t)._push(dr,t,e)},ir.prototype.string=function(e){var t=tr.length(e);return t?this.uint32(t)._push(tr.write,t,e):this._push(ar,1,0)},ir.prototype.fork=function(){return this.states=new or(this),this.head=this.tail=new rr(nr,0,0),this.len=0,this},ir.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new rr(nr,0,0),this.len=0),this},ir.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},ir.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},ir._configure=function(e){Zt=e,ir.create=sr(),Zt._configure()};var hr=gr,fr=Xt;(gr.prototype=Object.create(fr.prototype)).constructor=gr;var pr=Jt();function gr(){fr.call(this)}function yr(e,t,r){e.length<40?pr.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}gr._configure=function(){gr.alloc=pr._Buffer_allocUnsafe,gr.writeBytesBuffer=pr.Buffer&&pr.Buffer.prototype instanceof Uint8Array&&"set"===pr.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n<e.length;)t[r++]=e[n++]}},gr.prototype.bytes=function(e){pr.isString(e)&&(e=pr._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(gr.writeBytesBuffer,t,e),this},gr.prototype.string=function(e){var t=pr.Buffer.byteLength(e);return this.uint32(t),t&&this._push(yr,t,e),this},gr._configure();var vr,mr=_r,br=Jt(),wr=br.LongBits,Or=br.utf8;function Cr(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function _r(e){this.buf=e,this.pos=0,this.len=e.length}var Sr,Ir="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new _r(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new _r(e);throw Error("illegal buffer")},Er=function(){return br.Buffer?function(e){return(_r.create=function(e){return br.Buffer.isBuffer(e)?new vr(e):Ir(e)})(e)}:Ir};function Tr(){var e=new wr(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Cr(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Cr(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function Rr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function kr(){if(this.pos+8>this.len)throw Cr(this,8);return new wr(Rr(this.buf,this.pos+=4),Rr(this.buf,this.pos+=4))}_r.create=Er(),_r.prototype._slice=br.Array.prototype.subarray||br.Array.prototype.slice,_r.prototype.uint32=(Sr=4294967295,function(){if(Sr=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return Sr;if(Sr=(Sr|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return Sr;if(Sr=(Sr|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return Sr;if(Sr=(Sr|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return Sr;if(Sr=(Sr|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return Sr;if((this.pos+=5)>this.len)throw this.pos=this.len,Cr(this,10);return Sr}),_r.prototype.int32=function(){return 0|this.uint32()},_r.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},_r.prototype.bool=function(){return 0!==this.uint32()},_r.prototype.fixed32=function(){if(this.pos+4>this.len)throw Cr(this,4);return Rr(this.buf,this.pos+=4)},_r.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Cr(this,4);return 0|Rr(this.buf,this.pos+=4)},_r.prototype.float=function(){if(this.pos+4>this.len)throw Cr(this,4);var e=br.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},_r.prototype.double=function(){if(this.pos+8>this.len)throw Cr(this,4);var e=br.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},_r.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw Cr(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},_r.prototype.string=function(){var e=this.bytes();return Or.read(e,0,e.length)},_r.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw Cr(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Cr(this)}while(128&this.buf[this.pos++]);return this},_r.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},_r._configure=function(e){vr=e,_r.create=Er(),vr._configure();var t=br.Long?"toLong":"toNumber";br.merge(_r.prototype,{int64:function(){return Tr.call(this)[t](!1)},uint64:function(){return Tr.call(this)[t](!0)},sint64:function(){return Tr.call(this).zzDecode()[t](!1)},fixed64:function(){return kr.call(this)[t](!0)},sfixed64:function(){return kr.call(this)[t](!1)}})};var Ar=Dr,Nr=mr;(Dr.prototype=Object.create(Nr.prototype)).constructor=Dr;var xr=Jt();function Dr(e){Nr.call(this,e)}Dr._configure=function(){xr.Buffer&&(Dr.prototype._slice=xr.Buffer.prototype.slice)},Dr.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},Dr._configure();var Mr,Lr={},Br=jr,Ur=Jt();function jr(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");Ur.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(jr.prototype=Object.create(Ur.EventEmitter.prototype)).constructor=jr,jr.prototype.rpcCall=function e(t,r,n,o,i){if(!o)throw TypeError("request must be specified");var s=this;if(!i)return Ur.asPromise(e,s,t,r,n,o);if(s.rpcImpl)try{return s.rpcImpl(t,r[s.requestDelimited?"encodeDelimited":"encode"](o).finish(),(function(e,r){if(e)return s.emit("error",e,t),i(e);if(null!==r){if(!(r instanceof n))try{r=n[s.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return s.emit("error",e,t),i(e)}return s.emit("data",r,t),i(null,r)}s.end(!0)}))}catch(e){return s.emit("error",e,t),void setTimeout((function(){i(e)}),0)}else setTimeout((function(){i(Error("already ended"))}),0)},jr.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},Mr=Lr,Mr.Service=Br;var Pr={};!function(e){var t=Nt;function r(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}t.build="minimal",t.Writer=Xt,t.BufferWriter=hr,t.Reader=mr,t.BufferReader=Ar,t.util=Jt(),t.rpc=Lr,t.roots=Pr,t.configure=r,r()}(),At.exports=Nt;const Fr=At.exports.Writer,Gr=At.exports.util,qr=At.exports.roots.default||(At.exports.roots.default={}),Hr=qr.NetworkRequest=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cmdId=0,e.prototype.messageSeq=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.deviceId=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.sessionId=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.uid=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.protocolVersion=0,e.prototype.destId="",e.prototype.body=Gr.newBuffer([]),e.prototype.token="",e.encode=function(e,t){return t||(t=Fr.create()),null!=e.cmdId&&Object.hasOwnProperty.call(e,"cmdId")&&t.uint32(8).int32(e.cmdId),null!=e.messageSeq&&Object.hasOwnProperty.call(e,"messageSeq")&&t.uint32(16).int64(e.messageSeq),null!=e.deviceId&&Object.hasOwnProperty.call(e,"deviceId")&&t.uint32(24).int64(e.deviceId),null!=e.sessionId&&Object.hasOwnProperty.call(e,"sessionId")&&t.uint32(32).int64(e.sessionId),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(40).int64(e.uid),null!=e.protocolVersion&&Object.hasOwnProperty.call(e,"protocolVersion")&&t.uint32(48).int32(e.protocolVersion),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(58).string(e.destId),null!=e.body&&Object.hasOwnProperty.call(e,"body")&&t.uint32(66).bytes(e.body),null!=e.token&&Object.hasOwnProperty.call(e,"token")&&t.uint32(74).string(e.token),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NetworkRequest"},e})(),zr=qr.HeartbeatReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.pingId=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.disconnectDelay=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Fr.create()),null!=e.pingId&&Object.hasOwnProperty.call(e,"pingId")&&t.uint32(8).int64(e.pingId),null!=e.disconnectDelay&&Object.hasOwnProperty.call(e,"disconnectDelay")&&t.uint32(16).int64(e.disconnectDelay),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/HeartbeatReq"},e})(),Kr=qr.AuthSignIn2TokenReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.token="",e.prototype.deviceType=0,e.prototype.imei="",e.prototype.brand="",e.prototype.model="",e.prototype.apnsToken="",e.prototype.bandId="",e.encode=function(e,t){return t||(t=Fr.create()),null!=e.token&&Object.hasOwnProperty.call(e,"token")&&t.uint32(10).string(e.token),null!=e.deviceType&&Object.hasOwnProperty.call(e,"deviceType")&&t.uint32(16).int32(e.deviceType),null!=e.imei&&Object.hasOwnProperty.call(e,"imei")&&t.uint32(26).string(e.imei),null!=e.brand&&Object.hasOwnProperty.call(e,"brand")&&t.uint32(34).string(e.brand),null!=e.model&&Object.hasOwnProperty.call(e,"model")&&t.uint32(42).string(e.model),null!=e.apnsToken&&Object.hasOwnProperty.call(e,"apnsToken")&&t.uint32(50).string(e.apnsToken),null!=e.bandId&&Object.hasOwnProperty.call(e,"bandId")&&t.uint32(58).string(e.bandId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2TokenReq"},e})();qr.SystemCurrentTimeMillisReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.encode=function(e,t){return t||(t=Fr.create()),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SystemCurrentTimeMillisReq"},e})();var Vr=At.exports,Wr=Vr.Reader,$r=Vr.util,Jr=Vr.roots.default||(Vr.roots.default={});Jr.NetworkResponse=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cmdId=0,e.prototype.messageSeq=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.deviceId=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.uid=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.protocolVersion=0,e.prototype.body=$r.newBuffer([]),e.prototype.code=0,e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.NetworkResponse;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.cmdId=e.int32();break;case 2:n.messageSeq=e.int64();break;case 3:n.deviceId=e.int64();break;case 5:n.uid=e.int64();break;case 6:n.protocolVersion=e.int32();break;case 8:n.body=e.bytes();break;case 9:n.code=e.int32();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NetworkResponse"},e}(),Jr.AuthSignIn2TokenResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.sessionId=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.noNickName=!1,e.prototype.noEmail=!1,e.prototype.cert="",e.prototype.bodyAes=null,e.prototype.userFileDomain="",e.prototype.dialogFileDomain="",e.prototype.user=null,e.prototype.fileDomain="",e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.AuthSignIn2TokenResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.deviceId=e.int64();break;case 4:n.sessionId=e.int64();break;case 5:n.noNickName=e.bool();break;case 6:n.noEmail=e.bool();break;case 7:n.cert=e.string();break;case 8:n.bodyAes=Jr.UserAesKeyAndIV.decode(e,e.uint32());break;case 9:n.userFileDomain=e.string();break;case 10:n.dialogFileDomain=e.string();break;case 11:n.user=Jr.User.decode(e,e.uint32());break;case 14:n.fileDomain=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2TokenResp"},e}(),Jr.UserAesKeyAndIV=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.aesKey="",e.prototype.aesIV="",e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.UserAesKeyAndIV;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.aesKey=e.string();break;case 2:n.aesIV=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UserAesKeyAndIV"},e}(),Jr.User=function(){function e(e){if(this.aliasMobile=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.uid=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.nickName="",e.prototype.langCode="",e.prototype.phone="",e.prototype.numberInPhoneBook="",e.prototype.smallAvatarUrl="",e.prototype.originalAvatarUrl="",e.prototype.email="",e.prototype.qrcodeString="",e.prototype.gender=0,e.prototype.contactStatus=0,e.prototype.alias="",e.prototype.aliasMobile=$r.emptyArray,e.prototype.aliasDesp="",e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.User;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.uid=e.int64();break;case 2:n.nickName=e.string();break;case 3:n.langCode=e.string();break;case 4:n.phone=e.string();break;case 5:n.numberInPhoneBook=e.string();break;case 6:n.smallAvatarUrl=e.string();break;case 7:n.originalAvatarUrl=e.string();break;case 8:n.email=e.string();break;case 9:n.qrcodeString=e.string();break;case 10:n.gender=e.int32();break;case 11:n.contactStatus=e.int32();break;case 12:n.alias=e.string();break;case 13:n.aliasMobile&&n.aliasMobile.length||(n.aliasMobile=[]),n.aliasMobile.push(e.string());break;case 14:n.aliasDesp=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/User"},e}(),Jr.SystemCurrentTimeMillisResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.currentTimeMillis=$r.Long?$r.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.SystemCurrentTimeMillisResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.currentTimeMillis=e.int64();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SystemCurrentTimeMillisResp"},e}(),Jr.BaseResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.BaseResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/BaseResp"},e}();var Zr=Jr;class Xr{constructor(){d(this,"pool",[])}writeIn8(e){this.pool.push(e)}writeInt16(e){this.pool.push(e>>>0&255),this.pool.push(e>>>8&255)}writeInt32(e){this.pool.push(e>>>0&255),this.pool.push(e>>>8&255),this.pool.push(e>>>16&255),this.pool.push(e>>>24&255)}writeArr(e){return this.pool.push(...e),e}getBytesArray(){return this.pool}}class Yr{constructor(e){d(this,"pool",void 0),d(this,"position",0),this.pool=e}check(){return this.position>=this.pool.length}readInt8(){const e=this.pool[this.position];return this.position+=1,e<<24>>24}readInt32(){const e=this.pool[this.position+0],t=this.pool[this.position+1],r=this.pool[this.position+2],n=this.pool[this.position+3];return this.position+=4,e<<0|t<<8|r<<16|n<<24}readArr(e){const t=this.pool.subarray(this.position,this.position+e);return this.position+=e,t}}const Qr=e=>{let r;switch(e){case 0:r=t.SUCCESS;break;case 1610743809:r=t.NOT_IN_GROUP;break;case 1610678275:r=t.RC_MSG_CONTENT_EXCEED_LIMIT;break;case 1610678276:r=t.REJECTED_BY_BLACKLIST;break;case 3:r=t.PARAMETER_ERROR;break;case 22408:r=t.FORBIDDEN_IN_GROUP;break;default:r=t.UNKNOWN}return r};
|
18
|
+
return function(t){var r=e,n=r.lib,o=n.WordArray,i=n.Hasher,s=r.algo,a=o.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=o.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),l=o.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=o.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),d=o.create([0,1518500249,1859775393,2400959708,2840853838]),h=o.create([1352829926,1548603684,1836072691,2053994217,0]),f=s.RIPEMD160=i.extend({_doReset:function(){this._hash=o.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,o=e[n];e[n]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i,s,f,w,O,C,_,S,I,E,T,R=this._hash.words,k=d.words,A=h.words,N=a.words,x=c.words,D=l.words,M=u.words;for(C=i=R[0],_=s=R[1],S=f=R[2],I=w=R[3],E=O=R[4],r=0;r<80;r+=1)T=i+e[t+N[r]]|0,T+=r<16?p(s,f,w)+k[0]:r<32?g(s,f,w)+k[1]:r<48?y(s,f,w)+k[2]:r<64?v(s,f,w)+k[3]:m(s,f,w)+k[4],T=(T=b(T|=0,D[r]))+O|0,i=O,O=w,w=b(f,10),f=s,s=T,T=C+e[t+x[r]]|0,T+=r<16?m(_,S,I)+A[0]:r<32?v(_,S,I)+A[1]:r<48?y(_,S,I)+A[2]:r<64?g(_,S,I)+A[3]:p(_,S,I)+A[4],T=(T=b(T|=0,M[r]))+E|0,C=E,E=I,I=b(S,10),S=_,_=T;T=R[1]+f+I|0,R[1]=R[2]+w+E|0,R[2]=R[3]+O+C|0,R[3]=R[4]+i+_|0,R[4]=R[0]+s+S|0,R[0]=T},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var o=this._hash,i=o.words,s=0;s<5;s++){var a=i[s];i[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return o},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,r){return e^t^r}function g(e,t,r){return e&t|~e&r}function y(e,t,r){return(e|~t)^r}function v(e,t,r){return e&r|t&~r}function m(e,t,r){return e^(t|~r)}function b(e,t){return e<<t|e>>>32-t}r.RIPEMD160=i._createHelper(f),r.HmacRIPEMD160=i._createHmacHelper(f)}(),e.RIPEMD160}(z())),ke(),Ae||(Ae=1,Ne.exports=function(e){return n=(r=(t=e).lib).Base,o=r.WordArray,s=(i=t.algo).SHA1,a=i.HMAC,c=i.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=a.create(r.hasher,e),i=o.create(),s=o.create([1]),c=i.words,l=s.words,u=r.keySize,d=r.iterations;c.length<u;){var h=n.update(t).finalize(s);n.reset();for(var f=h.words,p=f.length,g=h,y=1;y<d;y++){g=n.finalize(g),n.reset();for(var v=g.words,m=0;m<p;m++)f[m]^=v[m]}i.concat(h),l[0]++}return i.sigBytes=4*u,i}}),t.PBKDF2=function(e,t,r){return c.create(r).compute(e,t)},e.PBKDF2;var t,r,n,o,i,s,a,c}(z(),de(),ke())),Me(),Ue(),Fe(),He(),Ve(),Je(),Ze||(Ze=1,Xe.exports=function(e){return e.mode.ECB=((t=e.lib.BlockCipherMode.extend()).Encryptor=t.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),t.Decryptor=t.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),t),e.mode.ECB;var t}(z(),Ue())),Ye||(Ye=1,Qe.exports=function(e){return e.pad.AnsiX923={pad:function(e,t){var r=e.sigBytes,n=4*t,o=n-r%n,i=r+o-1;e.clamp(),e.words[i>>>2]|=o<<24-i%4*8,e.sigBytes+=o},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Ansix923}(z(),Ue())),et||(et=1,tt.exports=function(e){return e.pad.Iso10126={pad:function(t,r){var n=4*r,o=n-t.sigBytes%n;t.concat(e.lib.WordArray.random(o-1)).concat(e.lib.WordArray.create([o<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Iso10126}(z(),Ue())),rt||(rt=1,nt.exports=function(e){return e.pad.Iso97971={pad:function(t,r){t.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(t,r)},unpad:function(t){e.pad.ZeroPadding.unpad(t),t.sigBytes--}},e.pad.Iso97971}(z(),Ue())),ot||(ot=1,it.exports=function(e){return e.pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){var t=e.words,r=e.sigBytes-1;for(r=e.sigBytes-1;r>=0;r--)if(t[r>>>2]>>>24-r%4*8&255){e.sigBytes=r+1;break}}},e.pad.ZeroPadding}(z(),Ue())),st||(st=1,at.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(z(),Ue())),ct||(ct=1,lt.exports=function(e){return r=(t=e).lib.CipherParams,n=t.enc.Hex,t.format.Hex={stringify:function(e){return e.ciphertext.toString(n)},parse:function(e){var t=n.parse(e);return r.create({ciphertext:t})}},e.format.Hex;var t,r,n}(z(),Ue())),ut||(ut=1,dt.exports=function(e){return function(){var t=e,r=t.lib.BlockCipher,n=t.algo,o=[],i=[],s=[],a=[],c=[],l=[],u=[],d=[],h=[],f=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var p=n^n<<1^n<<2^n<<3^n<<4;p=p>>>8^255&p^99,o[r]=p,i[p]=r;var g=e[r],y=e[g],v=e[y],m=257*e[p]^16843008*p;s[r]=m<<24|m>>>8,a[r]=m<<16|m>>>16,c[r]=m<<8|m>>>24,l[r]=m,m=16843009*v^65537*y^257*g^16843008*r,u[p]=m<<24|m>>>8,d[p]=m<<16|m>>>16,h[p]=m<<8|m>>>24,f[p]=m,r?(r=g^e[e[e[v^g]]],n^=e[e[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],g=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),i=this._keySchedule=[],s=0;s<n;s++)s<r?i[s]=t[s]:(l=i[s-1],s%r?r>6&&s%r==4&&(l=o[l>>>24]<<24|o[l>>>16&255]<<16|o[l>>>8&255]<<8|o[255&l]):(l=o[(l=l<<8|l>>>24)>>>24]<<24|o[l>>>16&255]<<16|o[l>>>8&255]<<8|o[255&l],l^=p[s/r|0]<<24),i[s]=i[s-r]^l);for(var a=this._invKeySchedule=[],c=0;c<n;c++){if(s=n-c,c%4)var l=i[s];else l=i[s-4];a[c]=c<4||s<=4?l:u[o[l>>>24]]^d[o[l>>>16&255]]^h[o[l>>>8&255]]^f[o[255&l]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,l,o)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,u,d,h,f,i),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,o,i,s,a){for(var c=this._nRounds,l=e[t]^r[0],u=e[t+1]^r[1],d=e[t+2]^r[2],h=e[t+3]^r[3],f=4,p=1;p<c;p++){var g=n[l>>>24]^o[u>>>16&255]^i[d>>>8&255]^s[255&h]^r[f++],y=n[u>>>24]^o[d>>>16&255]^i[h>>>8&255]^s[255&l]^r[f++],v=n[d>>>24]^o[h>>>16&255]^i[l>>>8&255]^s[255&u]^r[f++],m=n[h>>>24]^o[l>>>16&255]^i[u>>>8&255]^s[255&d]^r[f++];l=g,u=y,d=v,h=m}g=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[d>>>8&255]<<8|a[255&h])^r[f++],y=(a[u>>>24]<<24|a[d>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[f++],v=(a[d>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^r[f++],m=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&d])^r[f++],e[t]=g,e[t+1]=y,e[t+2]=v,e[t+3]=m},keySize:8});t.AES=r._createHelper(g)}(),e.AES}(z(),re(),ce(),Me(),Ue())),pt(),gt||(gt=1,yt.exports=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,o=n.RC4=r.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,n=this._S=[],o=0;o<256;o++)n[o]=o;o=0;for(var i=0;o<256;o++){var s=o%r,a=t[s>>>2]>>>24-s%4*8&255;i=(i+n[o]+a)%256;var c=n[o];n[o]=n[i],n[i]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=i.call(this)},keySize:8,ivSize:0});function i(){for(var e=this._S,t=this._i,r=this._j,n=0,o=0;o<4;o++){r=(r+e[t=(t+1)%256])%256;var i=e[t];e[t]=e[r],e[r]=i,n|=e[(e[t]+e[r])%256]<<24-8*o}return this._i=t,this._j=r,n}t.RC4=r._createHelper(o);var s=n.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)i.call(this)}});t.RC4Drop=r._createHelper(s)}(),e.RC4}(z(),re(),ce(),Me(),Ue())),vt||(vt=1,mt.exports=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,o=[],i=[],s=[],a=n.Rabbit=r.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],o=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,r=0;r<4;r++)c.call(this);for(r=0;r<8;r++)o[r]^=n[r+4&7];if(t){var i=t.words,s=i[0],a=i[1],l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(o[0]^=l,o[1]^=d,o[2]^=u,o[3]^=h,o[4]^=l,o[5]^=d,o[6]^=u,o[7]^=h,r=0;r<4;r++)c.call(this)}},_doProcessBlock:function(e,t){var r=this._X;c.call(this),o[0]=r[0]^r[5]>>>16^r[3]<<16,o[1]=r[2]^r[7]>>>16^r[5]<<16,o[2]=r[4]^r[1]>>>16^r[7]<<16,o[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)o[n]=16711935&(o[n]<<8|o[n]>>>24)|4278255360&(o[n]<<24|o[n]>>>8),e[t+n]^=o[n]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<i[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<i[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<i[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<i[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<i[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<i[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<i[6]>>>0?1:0)|0,this._b=t[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=e[r]+t[r],o=65535&n,a=n>>>16,c=((o*o>>>17)+o*a>>>15)+a*a,l=((4294901760&n)*n|0)+((65535&n)*n|0);s[r]=c^l}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}t.Rabbit=r._createHelper(a)}(),e.Rabbit}(z(),re(),ce(),Me(),Ue())),bt||(bt=1,wt.exports=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,o=[],i=[],s=[],a=n.RabbitLegacy=r.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var o=0;o<4;o++)c.call(this);for(o=0;o<8;o++)n[o]^=r[o+4&7];if(t){var i=t.words,s=i[0],a=i[1],l=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),d=l>>>16|4294901760&u,h=u<<16|65535&l;for(n[0]^=l,n[1]^=d,n[2]^=u,n[3]^=h,n[4]^=l,n[5]^=d,n[6]^=u,n[7]^=h,o=0;o<4;o++)c.call(this)}},_doProcessBlock:function(e,t){var r=this._X;c.call(this),o[0]=r[0]^r[5]>>>16^r[3]<<16,o[1]=r[2]^r[7]>>>16^r[5]<<16,o[2]=r[4]^r[1]>>>16^r[7]<<16,o[3]=r[6]^r[3]>>>16^r[1]<<16;for(var n=0;n<4;n++)o[n]=16711935&(o[n]<<8|o[n]>>>24)|4278255360&(o[n]<<24|o[n]>>>8),e[t+n]^=o[n]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<i[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<i[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<i[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<i[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<i[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<i[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<i[6]>>>0?1:0)|0,this._b=t[7]>>>0<i[7]>>>0?1:0,r=0;r<8;r++){var n=e[r]+t[r],o=65535&n,a=n>>>16,c=((o*o>>>17)+o*a>>>15)+a*a,l=((4294901760&n)*n|0)+((65535&n)*n|0);s[r]=c^l}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}t.RabbitLegacy=r._createHelper(a)}(),e.RabbitLegacy}(z(),re(),ce(),Me(),Ue())));const Ct=e=>Object.keys(e),_t=e=>{const t={};return Object.keys(e).forEach((r=>{const n=e[r];f(n)&&(t[r]=m(n)?_t(n):n)})),t},St=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,r=null;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];r||(r=setTimeout((()=>{e.call(null,...o),r=null}),t))}},It=Ot.enc.Utf8.parse("skdjhfgc9829kslf"),Et=Ot.enc.Utf8.parse("qwdkshjf9838jsdf"),Tt={get:function(e){let t=localStorage.getItem(e);if(!f(t))return t;try{return t=JSON.parse(t),t}catch{return t}},set:function(e,t){f(t)?localStorage.setItem(e,JSON.stringify(t)):this.remove(e)},remove:function(e){localStorage.removeItem(e)}},Rt={get:function(e){let t=localStorage.getItem(e);if(f(t)){const e=Ot.enc.Hex.parse(t),r=Ot.enc.Base64.stringify(e);t=Ot.AES.decrypt(r,It,{iv:Et}).toString(Ot.enc.Utf8)}if(!f(t))return t;try{return t=JSON.parse(t),t}catch{return t}},set:function(e,t){if(f(t)){const r=Ot.AES.encrypt(JSON.stringify(t),It,{iv:Et}).ciphertext.toString();localStorage.setItem(e,r)}else this.remove(e)},remove:function(e){localStorage.removeItem(e)}};class kt{constructor(e){d(this,"cache",void 0),d(this,"storageKey",void 0),d(this,"saveFunc",void 0);const t=e?`ACIM-${e}`:"ACIM-",r=Tt.get(t)||{};this.cache=r,this.storageKey=t,this.saveFunc=St((()=>{Tt.set(this.storageKey,this.cache)}),10)}set(e,t){this.cache[e]=t,this.saveFunc()}remove(e){delete this.cache[e],this.saveFunc()}clear(){Tt.remove(this.storageKey),this.cache={}}get(e){return this.cache[e]}getCache(){return this.cache||{}}}var At={exports:{}},Nt={},xt={},Dt=function(e,t){var r=new Array(arguments.length-1),n=0,o=2,i=!0;for(;o<arguments.length;)r[n++]=arguments[o++];return new Promise((function(o,s){r[n]=function(e){if(i)if(i=!1,e)s(e);else{for(var t=new Array(arguments.length-1),r=0;r<t.length;)t[r++]=arguments[r];o.apply(null,t)}};try{e.apply(t||null,r)}catch(e){i&&(i=!1,s(e))}}))};var Mt={};!function(e){var t=Mt;t.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var r=new Array(64),n=new Array(123),o=0;o<64;)n[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;t.encode=function(e,t,n){for(var o,i=null,s=[],a=0,c=0;t<n;){var l=e[t++];switch(c){case 0:s[a++]=r[l>>2],o=(3&l)<<4,c=1;break;case 1:s[a++]=r[o|l>>4],o=(15&l)<<2,c=2;break;case 2:s[a++]=r[o|l>>6],s[a++]=r[63&l],c=0}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return c&&(s[a++]=r[o],s[a++]=61,1===c&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var i="invalid encoding";t.decode=function(e,t,r){for(var o,s=r,a=0,c=0;c<e.length;){var l=e.charCodeAt(c++);if(61===l&&a>1)break;if(void 0===(l=n[l]))throw Error(i);switch(a){case 0:o=l,a=1;break;case 1:t[r++]=o<<2|(48&l)>>4,o=l,a=2;break;case 2:t[r++]=(15&o)<<4|(60&l)>>2,o=l,a=3;break;case 3:t[r++]=(3&o)<<6|l,a=0}}if(1===a)throw Error(i);return r-s},t.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}}();var Lt=Bt;function Bt(){this._listeners={}}Bt.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},Bt.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n<r.length;)r[n].fn===t?r.splice(n,1):++n;return this},Bt.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,r)}return this};var Ut=jt(jt);function jt(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function o(e,n,o){t[0]=e,n[o]=r[0],n[o+1]=r[1],n[o+2]=r[2],n[o+3]=r[3]}function i(e,n,o){t[0]=e,n[o]=r[3],n[o+1]=r[2],n[o+2]=r[1],n[o+3]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function a(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?o:i,e.writeFloatBE=n?i:o,e.readFloatLE=n?s:a,e.readFloatBE=n?a:s}():function(){function t(e,t,r,n){var o=t<0?1:0;if(o&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((o<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((o<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var i=Math.floor(Math.log(t)/Math.LN2);e((o<<31|i+127<<23|8388607&Math.round(t*Math.pow(2,-i)*8388608))>>>0,r,n)}}function r(e,t,r){var n=e(t,r),o=2*(n>>31)+1,i=n>>>23&255,s=8388607&n;return 255===i?s?NaN:o*(1/0):0===i?1401298464324817e-60*o*s:o*Math.pow(2,i-150)*(s+8388608)}e.writeFloatLE=t.bind(null,Pt),e.writeFloatBE=t.bind(null,Ft),e.readFloatLE=r.bind(null,Gt),e.readFloatBE=r.bind(null,qt)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function o(e,n,o){t[0]=e,n[o]=r[0],n[o+1]=r[1],n[o+2]=r[2],n[o+3]=r[3],n[o+4]=r[4],n[o+5]=r[5],n[o+6]=r[6],n[o+7]=r[7]}function i(e,n,o){t[0]=e,n[o]=r[7],n[o+1]=r[6],n[o+2]=r[5],n[o+3]=r[4],n[o+4]=r[3],n[o+5]=r[2],n[o+6]=r[1],n[o+7]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function a(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?o:i,e.writeDoubleBE=n?i:o,e.readDoubleLE=n?s:a,e.readDoubleBE=n?a:s}():function(){function t(e,t,r,n,o,i){var s=n<0?1:0;if(s&&(n=-n),0===n)e(0,o,i+t),e(1/n>0?0:2147483648,o,i+r);else if(isNaN(n))e(0,o,i+t),e(2146959360,o,i+r);else if(n>17976931348623157e292)e(0,o,i+t),e((s<<31|2146435072)>>>0,o,i+r);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,o,i+t),e((s<<31|a/4294967296)>>>0,o,i+r);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=n*Math.pow(2,-c))>>>0,o,i+t),e((s<<31|c+1023<<20|1048576*a&1048575)>>>0,o,i+r)}}}function r(e,t,r,n,o){var i=e(n,o+t),s=e(n,o+r),a=2*(s>>31)+1,c=s>>>20&2047,l=4294967296*(1048575&s)+i;return 2047===c?l?NaN:a*(1/0):0===c?5e-324*a*l:a*Math.pow(2,c-1075)*(l+4503599627370496)}e.writeDoubleLE=t.bind(null,Pt,0,4),e.writeDoubleBE=t.bind(null,Ft,4,0),e.readDoubleLE=r.bind(null,Gt,0,4),e.readDoubleBE=r.bind(null,qt,4,0)}(),e}function Pt(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Ft(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function Gt(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function qt(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}var Ht=function(e){try{var t=void 0;t}catch(e){}return null};var zt={};!function(e){var t=zt;t.length=function(e){for(var t=0,r=0,n=0;n<e.length;++n)(r=e.charCodeAt(n))<128?t+=1:r<2048?t+=2:55296==(64512&r)&&56320==(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},t.read=function(e,t,r){if(r-t<1)return"";for(var n,o=null,i=[],s=0;t<r;)(n=e[t++])<128?i[s++]=n:n>191&&n<224?i[s++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(n>>10),i[s++]=56320+(1023&n)):i[s++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o?(s&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))},t.write=function(e,t,r){for(var n,o,i=r,s=0;s<e.length;++s)(n=e.charCodeAt(s))<128?t[r++]=n:n<2048?(t[r++]=n>>6|192,t[r++]=63&n|128):55296==(64512&n)&&56320==(64512&(o=e.charCodeAt(s+1)))?(n=65536+((1023&n)<<10)+(1023&o),++s,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-i}}();var Kt,Vt,Wt,$t=function(e,t,r){var n=r||8192,o=n>>>1,i=null,s=n;return function(r){if(r<1||r>o)return e(r);s+r>n&&(i=e(n),s=0);var a=t.call(i,s,s+=r);return 7&s&&(s=1+(7|s)),a}};function Jt(){return Wt||(Wt=1,function(e){var t=xt;function r(e,t,r){for(var n=Object.keys(t),o=0;o<n.length;++o)void 0!==e[n[o]]&&r||(e[n[o]]=t[n[o]]);return e}function n(e){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),n&&r(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}t.asPromise=Dt,t.base64=Mt,t.EventEmitter=Lt,t.float=Ut,t.inquire=Ht,t.utf8=zt,t.pool=$t,t.LongBits=function(){if(Vt)return Kt;Vt=1,Kt=t;var e=Jt();function t(e,t){this.lo=e>>>0,this.hi=t>>>0}var r=t.zero=new t(0,0);r.toNumber=function(){return 0},r.zzEncode=r.zzDecode=function(){return this},r.length=function(){return 1};var n=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(e){if(0===e)return r;var n=e<0;n&&(e=-e);var o=e>>>0,i=(e-o)/4294967296>>>0;return n&&(i=~i>>>0,o=~o>>>0,++o>4294967295&&(o=0,++i>4294967295&&(i=0))),new t(o,i)},t.from=function(n){if("number"==typeof n)return t.fromNumber(n);if(e.isString(n)){if(!e.Long)return t.fromNumber(parseInt(n,10));n=e.Long.fromString(n)}return n.low||n.high?new t(n.low>>>0,n.high>>>0):r},t.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},t.prototype.toLong=function(t){return e.Long?new e.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var o=String.prototype.charCodeAt;return t.fromHash=function(e){return e===n?r:new t((o.call(e,0)|o.call(e,1)<<8|o.call(e,2)<<16|o.call(e,3)<<24)>>>0,(o.call(e,4)|o.call(e,5)<<8|o.call(e,6)<<16|o.call(e,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},t.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},t.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10},Kt}(),t.isNode=Boolean(void 0!==P&&P&&P.process&&P.process.versions&&P.process.versions.node),t.global=t.isNode&&P||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||P,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.isString=function(e){return"string"==typeof e||e instanceof String},t.isObject=function(e){return e&&"object"==typeof e},t.isset=t.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},t.Buffer=function(){try{var e=t.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(e){return"number"==typeof e?t.Buffer?t._Buffer_allocUnsafe(e):new t.Array(e):t.Buffer?t._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},t.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(e){return e?t.LongBits.from(e).toHash():t.LongBits.zeroHash},t.longFromHash=function(e,r){var n=t.LongBits.fromHash(e);return t.Long?t.Long.fromBits(n.lo,n.hi,r):n.toNumber(Boolean(r))},t.merge=r,t.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},t.newError=n,t.ProtocolError=n("ProtocolError"),t.oneOfGetter=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},t.oneOfSetter=function(e){return function(t){for(var r=0;r<e.length;++r)e[r]!==t&&delete this[e[r]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var e=t.Buffer;e?(t._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,r){return new e(t,r)},t._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):t._Buffer_from=t._Buffer_allocUnsafe=null}}()),xt}var Zt,Xt=ir,Yt=Jt(),Qt=Yt.LongBits,er=Yt.base64,tr=Yt.utf8;function rr(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function nr(){}function or(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function ir(){this.len=0,this.head=new rr(nr,0,0),this.tail=this.head,this.states=null}var sr=function(){return Yt.Buffer?function(){return(ir.create=function(){return new Zt})()}:function(){return new ir}};function ar(e,t,r){t[r]=255&e}function cr(e,t){this.len=e,this.next=void 0,this.val=t}function lr(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function ur(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}ir.create=sr(),ir.alloc=function(e){return new Yt.Array(e)},Yt.Array!==Array&&(ir.alloc=Yt.pool(ir.alloc,Yt.Array.prototype.subarray)),ir.prototype._push=function(e,t,r){return this.tail=this.tail.next=new rr(e,t,r),this.len+=t,this},cr.prototype=Object.create(rr.prototype),cr.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},ir.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new cr((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},ir.prototype.int32=function(e){return e<0?this._push(lr,10,Qt.fromNumber(e)):this.uint32(e)},ir.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},ir.prototype.uint64=function(e){var t=Qt.from(e);return this._push(lr,t.length(),t)},ir.prototype.int64=ir.prototype.uint64,ir.prototype.sint64=function(e){var t=Qt.from(e).zzEncode();return this._push(lr,t.length(),t)},ir.prototype.bool=function(e){return this._push(ar,1,e?1:0)},ir.prototype.fixed32=function(e){return this._push(ur,4,e>>>0)},ir.prototype.sfixed32=ir.prototype.fixed32,ir.prototype.fixed64=function(e){var t=Qt.from(e);return this._push(ur,4,t.lo)._push(ur,4,t.hi)},ir.prototype.sfixed64=ir.prototype.fixed64,ir.prototype.float=function(e){return this._push(Yt.float.writeFloatLE,4,e)},ir.prototype.double=function(e){return this._push(Yt.float.writeDoubleLE,8,e)};var dr=Yt.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n<e.length;++n)t[r+n]=e[n]};ir.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(ar,1,0);if(Yt.isString(e)){var r=ir.alloc(t=er.length(e));er.decode(e,r,0),e=r}return this.uint32(t)._push(dr,t,e)},ir.prototype.string=function(e){var t=tr.length(e);return t?this.uint32(t)._push(tr.write,t,e):this._push(ar,1,0)},ir.prototype.fork=function(){return this.states=new or(this),this.head=this.tail=new rr(nr,0,0),this.len=0,this},ir.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new rr(nr,0,0),this.len=0),this},ir.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},ir.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},ir._configure=function(e){Zt=e,ir.create=sr(),Zt._configure()};var hr=gr,fr=Xt;(gr.prototype=Object.create(fr.prototype)).constructor=gr;var pr=Jt();function gr(){fr.call(this)}function yr(e,t,r){e.length<40?pr.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}gr._configure=function(){gr.alloc=pr._Buffer_allocUnsafe,gr.writeBytesBuffer=pr.Buffer&&pr.Buffer.prototype instanceof Uint8Array&&"set"===pr.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n<e.length;)t[r++]=e[n++]}},gr.prototype.bytes=function(e){pr.isString(e)&&(e=pr._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(gr.writeBytesBuffer,t,e),this},gr.prototype.string=function(e){var t=pr.Buffer.byteLength(e);return this.uint32(t),t&&this._push(yr,t,e),this},gr._configure();var vr,mr=_r,br=Jt(),wr=br.LongBits,Or=br.utf8;function Cr(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function _r(e){this.buf=e,this.pos=0,this.len=e.length}var Sr,Ir="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new _r(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new _r(e);throw Error("illegal buffer")},Er=function(){return br.Buffer?function(e){return(_r.create=function(e){return br.Buffer.isBuffer(e)?new vr(e):Ir(e)})(e)}:Ir};function Tr(){var e=new wr(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Cr(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Cr(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function Rr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function kr(){if(this.pos+8>this.len)throw Cr(this,8);return new wr(Rr(this.buf,this.pos+=4),Rr(this.buf,this.pos+=4))}_r.create=Er(),_r.prototype._slice=br.Array.prototype.subarray||br.Array.prototype.slice,_r.prototype.uint32=(Sr=4294967295,function(){if(Sr=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return Sr;if(Sr=(Sr|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return Sr;if(Sr=(Sr|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return Sr;if(Sr=(Sr|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return Sr;if(Sr=(Sr|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return Sr;if((this.pos+=5)>this.len)throw this.pos=this.len,Cr(this,10);return Sr}),_r.prototype.int32=function(){return 0|this.uint32()},_r.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},_r.prototype.bool=function(){return 0!==this.uint32()},_r.prototype.fixed32=function(){if(this.pos+4>this.len)throw Cr(this,4);return Rr(this.buf,this.pos+=4)},_r.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Cr(this,4);return 0|Rr(this.buf,this.pos+=4)},_r.prototype.float=function(){if(this.pos+4>this.len)throw Cr(this,4);var e=br.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},_r.prototype.double=function(){if(this.pos+8>this.len)throw Cr(this,4);var e=br.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},_r.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw Cr(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},_r.prototype.string=function(){var e=this.bytes();return Or.read(e,0,e.length)},_r.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw Cr(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Cr(this)}while(128&this.buf[this.pos++]);return this},_r.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},_r._configure=function(e){vr=e,_r.create=Er(),vr._configure();var t=br.Long?"toLong":"toNumber";br.merge(_r.prototype,{int64:function(){return Tr.call(this)[t](!1)},uint64:function(){return Tr.call(this)[t](!0)},sint64:function(){return Tr.call(this).zzDecode()[t](!1)},fixed64:function(){return kr.call(this)[t](!0)},sfixed64:function(){return kr.call(this)[t](!1)}})};var Ar=Dr,Nr=mr;(Dr.prototype=Object.create(Nr.prototype)).constructor=Dr;var xr=Jt();function Dr(e){Nr.call(this,e)}Dr._configure=function(){xr.Buffer&&(Dr.prototype._slice=xr.Buffer.prototype.slice)},Dr.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},Dr._configure();var Mr,Lr={},Br=jr,Ur=Jt();function jr(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");Ur.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(jr.prototype=Object.create(Ur.EventEmitter.prototype)).constructor=jr,jr.prototype.rpcCall=function e(t,r,n,o,i){if(!o)throw TypeError("request must be specified");var s=this;if(!i)return Ur.asPromise(e,s,t,r,n,o);if(s.rpcImpl)try{return s.rpcImpl(t,r[s.requestDelimited?"encodeDelimited":"encode"](o).finish(),(function(e,r){if(e)return s.emit("error",e,t),i(e);if(null!==r){if(!(r instanceof n))try{r=n[s.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return s.emit("error",e,t),i(e)}return s.emit("data",r,t),i(null,r)}s.end(!0)}))}catch(e){return s.emit("error",e,t),void setTimeout((function(){i(e)}),0)}else setTimeout((function(){i(Error("already ended"))}),0)},jr.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},Mr=Lr,Mr.Service=Br;var Pr={};!function(e){var t=Nt;function r(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}t.build="minimal",t.Writer=Xt,t.BufferWriter=hr,t.Reader=mr,t.BufferReader=Ar,t.util=Jt(),t.rpc=Lr,t.roots=Pr,t.configure=r,r()}(),At.exports=Nt;const Fr=At.exports.Writer,Gr=At.exports.util,qr=At.exports.roots.default||(At.exports.roots.default={}),Hr=qr.NetworkRequest=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cmdId=0,e.prototype.messageSeq=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.deviceId=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.sessionId=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.uid=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.protocolVersion=0,e.prototype.destId="",e.prototype.body=Gr.newBuffer([]),e.prototype.token="",e.encode=function(e,t){return t||(t=Fr.create()),null!=e.cmdId&&Object.hasOwnProperty.call(e,"cmdId")&&t.uint32(8).int32(e.cmdId),null!=e.messageSeq&&Object.hasOwnProperty.call(e,"messageSeq")&&t.uint32(16).int64(e.messageSeq),null!=e.deviceId&&Object.hasOwnProperty.call(e,"deviceId")&&t.uint32(24).int64(e.deviceId),null!=e.sessionId&&Object.hasOwnProperty.call(e,"sessionId")&&t.uint32(32).int64(e.sessionId),null!=e.uid&&Object.hasOwnProperty.call(e,"uid")&&t.uint32(40).int64(e.uid),null!=e.protocolVersion&&Object.hasOwnProperty.call(e,"protocolVersion")&&t.uint32(48).int32(e.protocolVersion),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(58).string(e.destId),null!=e.body&&Object.hasOwnProperty.call(e,"body")&&t.uint32(66).bytes(e.body),null!=e.token&&Object.hasOwnProperty.call(e,"token")&&t.uint32(74).string(e.token),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NetworkRequest"},e})(),zr=qr.HeartbeatReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.pingId=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.prototype.disconnectDelay=Gr.Long?Gr.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Fr.create()),null!=e.pingId&&Object.hasOwnProperty.call(e,"pingId")&&t.uint32(8).int64(e.pingId),null!=e.disconnectDelay&&Object.hasOwnProperty.call(e,"disconnectDelay")&&t.uint32(16).int64(e.disconnectDelay),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/HeartbeatReq"},e})(),Kr=qr.AuthSignIn2TokenReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.token="",e.prototype.deviceType=0,e.prototype.imei="",e.prototype.brand="",e.prototype.model="",e.prototype.apnsToken="",e.prototype.bandId="",e.encode=function(e,t){return t||(t=Fr.create()),null!=e.token&&Object.hasOwnProperty.call(e,"token")&&t.uint32(10).string(e.token),null!=e.deviceType&&Object.hasOwnProperty.call(e,"deviceType")&&t.uint32(16).int32(e.deviceType),null!=e.imei&&Object.hasOwnProperty.call(e,"imei")&&t.uint32(26).string(e.imei),null!=e.brand&&Object.hasOwnProperty.call(e,"brand")&&t.uint32(34).string(e.brand),null!=e.model&&Object.hasOwnProperty.call(e,"model")&&t.uint32(42).string(e.model),null!=e.apnsToken&&Object.hasOwnProperty.call(e,"apnsToken")&&t.uint32(50).string(e.apnsToken),null!=e.bandId&&Object.hasOwnProperty.call(e,"bandId")&&t.uint32(58).string(e.bandId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2TokenReq"},e})();qr.SystemCurrentTimeMillisReq=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.encode=function(e,t){return t||(t=Fr.create()),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SystemCurrentTimeMillisReq"},e})();var Vr=At.exports,Wr=Vr.Reader,$r=Vr.util,Jr=Vr.roots.default||(Vr.roots.default={});Jr.NetworkResponse=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.cmdId=0,e.prototype.messageSeq=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.deviceId=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.uid=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.protocolVersion=0,e.prototype.body=$r.newBuffer([]),e.prototype.code=0,e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.NetworkResponse;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.cmdId=e.int32();break;case 2:n.messageSeq=e.int64();break;case 3:n.deviceId=e.int64();break;case 5:n.uid=e.int64();break;case 6:n.protocolVersion=e.int32();break;case 8:n.body=e.bytes();break;case 9:n.code=e.int32();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NetworkResponse"},e}(),Jr.AuthSignIn2TokenResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.deviceId=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.sessionId=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.noNickName=!1,e.prototype.noEmail=!1,e.prototype.cert="",e.prototype.bodyAes=null,e.prototype.userFileDomain="",e.prototype.dialogFileDomain="",e.prototype.user=null,e.prototype.fileDomain="",e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.AuthSignIn2TokenResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.deviceId=e.int64();break;case 4:n.sessionId=e.int64();break;case 5:n.noNickName=e.bool();break;case 6:n.noEmail=e.bool();break;case 7:n.cert=e.string();break;case 8:n.bodyAes=Jr.UserAesKeyAndIV.decode(e,e.uint32());break;case 9:n.userFileDomain=e.string();break;case 10:n.dialogFileDomain=e.string();break;case 11:n.user=Jr.User.decode(e,e.uint32());break;case 14:n.fileDomain=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AuthSignIn2TokenResp"},e}(),Jr.UserAesKeyAndIV=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.aesKey="",e.prototype.aesIV="",e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.UserAesKeyAndIV;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.aesKey=e.string();break;case 2:n.aesIV=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UserAesKeyAndIV"},e}(),Jr.User=function(){function e(e){if(this.aliasMobile=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.uid=$r.Long?$r.Long.fromBits(0,0,!1):0,e.prototype.nickName="",e.prototype.langCode="",e.prototype.phone="",e.prototype.numberInPhoneBook="",e.prototype.smallAvatarUrl="",e.prototype.originalAvatarUrl="",e.prototype.email="",e.prototype.qrcodeString="",e.prototype.gender=0,e.prototype.contactStatus=0,e.prototype.alias="",e.prototype.aliasMobile=$r.emptyArray,e.prototype.aliasDesp="",e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.User;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.uid=e.int64();break;case 2:n.nickName=e.string();break;case 3:n.langCode=e.string();break;case 4:n.phone=e.string();break;case 5:n.numberInPhoneBook=e.string();break;case 6:n.smallAvatarUrl=e.string();break;case 7:n.originalAvatarUrl=e.string();break;case 8:n.email=e.string();break;case 9:n.qrcodeString=e.string();break;case 10:n.gender=e.int32();break;case 11:n.contactStatus=e.int32();break;case 12:n.alias=e.string();break;case 13:n.aliasMobile&&n.aliasMobile.length||(n.aliasMobile=[]),n.aliasMobile.push(e.string());break;case 14:n.aliasDesp=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/User"},e}(),Jr.SystemCurrentTimeMillisResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.currentTimeMillis=$r.Long?$r.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.SystemCurrentTimeMillisResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.currentTimeMillis=e.int64();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SystemCurrentTimeMillisResp"},e}(),Jr.BaseResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.decode=function(e,t){e instanceof Wr||(e=Wr.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Jr.BaseResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/BaseResp"},e}();var Zr=Jr;class Xr{constructor(){d(this,"pool",[])}writeIn8(e){this.pool.push(e)}writeInt16(e){this.pool.push(e>>>0&255),this.pool.push(e>>>8&255)}writeInt32(e){this.pool.push(e>>>0&255),this.pool.push(e>>>8&255),this.pool.push(e>>>16&255),this.pool.push(e>>>24&255)}writeArr(e){return this.pool.push(...e),e}getBytesArray(){return this.pool}}class Yr{constructor(e){d(this,"pool",void 0),d(this,"position",0),this.pool=e}check(){return this.position>=this.pool.length}readInt8(){const e=this.pool[this.position];return this.position+=1,e<<24>>24}readInt32(){const e=this.pool[this.position+0],t=this.pool[this.position+1],r=this.pool[this.position+2],n=this.pool[this.position+3];return this.position+=4,e<<0|t<<8|r<<16|n<<24}readArr(e){const t=this.pool.subarray(this.position,this.position+e);return this.position+=e,t}}const Qr=e=>{let r;switch(e){case 0:r=t.SUCCESS;break;case 1610743809:r=t.NOT_IN_GROUP;break;case 1610678275:r=t.RC_MSG_CONTENT_EXCEED_LIMIT;break;case 1610678276:r=t.REJECTED_BY_BLACKLIST;break;case 3:r=t.PARAMETER_ERROR;break;case 22408:r=t.FORBIDDEN_IN_GROUP;break;default:r=t.UNKNOWN}return r};
|
19
19
|
/**
|
20
20
|
* @license
|
21
21
|
* Copyright 2009 The Closure Library Authors
|
@@ -34,4 +34,4 @@ return function(t){var r=e,n=r.lib,o=n.WordArray,i=n.Hasher,s=r.algo,a=o.create(
|
|
34
34
|
* limitations under the License.
|
35
35
|
*
|
36
36
|
* SPDX-License-Identifier: Apache-2.0
|
37
|
-
*/var en=null;try{en=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function tn(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function rn(e){return!0===(e&&e.__isLong__)}function nn(e){var t=Math.clz32(e&-e);return e?31-t:t}tn.prototype.__isLong__,Object.defineProperty(tn.prototype,"__isLong__",{value:!0}),tn.isLong=rn;var on={},sn={};function an(e,t){var r,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=sn[e])?n:(r=ln(e,0,!0),o&&(sn[e]=r),r):(o=-128<=(e|=0)&&e<128)&&(n=on[e])?n:(r=ln(e,e<0?-1:0,!1),o&&(on[e]=r),r)}function cn(e,t){if(isNaN(e))return t?mn:vn;if(t){if(e<0)return mn;if(e>=pn)return _n}else{if(e<=-gn)return Sn;if(e+1>=gn)return Cn}return e<0?cn(-e,t).neg():ln(e%fn|0,e/fn|0,t)}function ln(e,t,r){return new tn(e,t,r)}tn.fromInt=an,tn.fromNumber=cn,tn.fromBits=ln;var un=Math.pow;function dn(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?mn:vn;if((r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return dn(e.substring(1),t,r).neg();for(var o=cn(un(r,8)),i=vn,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),c=parseInt(e.substring(s,s+a),r);if(a<8){var l=cn(un(r,a));i=i.mul(l).add(cn(c))}else i=(i=i.mul(o)).add(cn(c))}return i.unsigned=t,i}function hn(e,t){return"number"==typeof e?cn(e,t):"string"==typeof e?dn(e,t):ln(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}tn.fromString=dn,tn.fromValue=hn;var fn=4294967296,pn=fn*fn,gn=pn/2,yn=an(1<<24),vn=an(0);tn.ZERO=vn;var mn=an(0,!0);tn.UZERO=mn;var bn=an(1);tn.ONE=bn;var wn=an(1,!0);tn.UONE=wn;var On=an(-1);tn.NEG_ONE=On;var Cn=ln(-1,2147483647,!1);tn.MAX_VALUE=Cn;var _n=ln(-1,-1,!0);tn.MAX_UNSIGNED_VALUE=_n;var Sn=ln(0,-2147483648,!1);tn.MIN_VALUE=Sn;var In=tn.prototype;In.toInt=function(){return this.unsigned?this.low>>>0:this.low},In.toNumber=function(){return this.unsigned?(this.high>>>0)*fn+(this.low>>>0):this.high*fn+(this.low>>>0)},In.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(Sn)){var t=cn(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var o=cn(un(e,6),this.unsigned),i=this,s="";;){var a=i.div(o),c=(i.sub(a.mul(o)).toInt()>>>0).toString(e);if((i=a).isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}},In.getHighBits=function(){return this.high},In.getHighBitsUnsigned=function(){return this.high>>>0},In.getLowBits=function(){return this.low},In.getLowBitsUnsigned=function(){return this.low>>>0},In.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Sn)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},In.isZero=function(){return 0===this.high&&0===this.low},In.eqz=In.isZero,In.isNegative=function(){return!this.unsigned&&this.high<0},In.isPositive=function(){return this.unsigned||this.high>=0},In.isOdd=function(){return 1==(1&this.low)},In.isEven=function(){return 0==(1&this.low)},In.equals=function(e){return rn(e)||(e=hn(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},In.eq=In.equals,In.notEquals=function(e){return!this.eq(e)},In.neq=In.notEquals,In.ne=In.notEquals,In.lessThan=function(e){return this.comp(e)<0},In.lt=In.lessThan,In.lessThanOrEqual=function(e){return this.comp(e)<=0},In.lte=In.lessThanOrEqual,In.le=In.lessThanOrEqual,In.greaterThan=function(e){return this.comp(e)>0},In.gt=In.greaterThan,In.greaterThanOrEqual=function(e){return this.comp(e)>=0},In.gte=In.greaterThanOrEqual,In.ge=In.greaterThanOrEqual,In.compare=function(e){if(rn(e)||(e=hn(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},In.comp=In.compare,In.negate=function(){return!this.unsigned&&this.eq(Sn)?Sn:this.not().add(bn)},In.neg=In.negate,In.add=function(e){rn(e)||(e=hn(e));var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16,c=0,l=0,u=0,d=0;return u+=(d+=o+(65535&e.low))>>>16,l+=(u+=n+a)>>>16,c+=(l+=r+s)>>>16,c+=t+i,ln((u&=65535)<<16|(d&=65535),(c&=65535)<<16|(l&=65535),this.unsigned)},In.subtract=function(e){return rn(e)||(e=hn(e)),this.add(e.neg())},In.sub=In.subtract,In.multiply=function(e){if(this.isZero())return this;if(rn(e)||(e=hn(e)),en)return ln(en.mul(this.low,this.high,e.low,e.high),en.get_high(),this.unsigned);if(e.isZero())return this.unsigned?mn:vn;if(this.eq(Sn))return e.isOdd()?Sn:vn;if(e.eq(Sn))return this.isOdd()?Sn:vn;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(yn)&&e.lt(yn))return cn(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16,c=65535&e.low,l=0,u=0,d=0,h=0;return d+=(h+=o*c)>>>16,u+=(d+=n*c)>>>16,d&=65535,u+=(d+=o*a)>>>16,l+=(u+=r*c)>>>16,u&=65535,l+=(u+=n*a)>>>16,u&=65535,l+=(u+=o*s)>>>16,l+=t*c+r*a+n*s+o*i,ln((d&=65535)<<16|(h&=65535),(l&=65535)<<16|(u&=65535),this.unsigned)},In.mul=In.multiply,In.divide=function(e){if(rn(e)||(e=hn(e)),e.isZero())throw Error("division by zero");var t,r,n;if(en)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?ln((this.unsigned?en.div_u:en.div_s)(this.low,this.high,e.low,e.high),en.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?mn:vn;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return mn;if(e.gt(this.shru(1)))return wn;n=mn}else{if(this.eq(Sn))return e.eq(bn)||e.eq(On)?Sn:e.eq(Sn)?bn:(t=this.shr(1).div(e).shl(1)).eq(vn)?e.isNegative()?bn:On:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(Sn))return this.unsigned?mn:vn;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=vn}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),i=o<=48?1:un(2,o-48),s=cn(t),a=s.mul(e);a.isNegative()||a.gt(r);)a=(s=cn(t-=i,this.unsigned)).mul(e);s.isZero()&&(s=bn),n=n.add(s),r=r.sub(a)}return n},In.div=In.divide,In.modulo=function(e){return rn(e)||(e=hn(e)),en?ln((this.unsigned?en.rem_u:en.rem_s)(this.low,this.high,e.low,e.high),en.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},In.mod=In.modulo,In.rem=In.modulo,In.not=function(){return ln(~this.low,~this.high,this.unsigned)},In.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},In.clz=In.countLeadingZeros,In.countTrailingZeros=function(){return this.low?nn(this.low):nn(this.high)+32},In.ctz=In.countTrailingZeros,In.and=function(e){return rn(e)||(e=hn(e)),ln(this.low&e.low,this.high&e.high,this.unsigned)},In.or=function(e){return rn(e)||(e=hn(e)),ln(this.low|e.low,this.high|e.high,this.unsigned)},In.xor=function(e){return rn(e)||(e=hn(e)),ln(this.low^e.low,this.high^e.high,this.unsigned)},In.shiftLeft=function(e){return rn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ln(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):ln(0,this.low<<e-32,this.unsigned)},In.shl=In.shiftLeft,In.shiftRight=function(e){return rn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ln(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):ln(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},In.shr=In.shiftRight,In.shiftRightUnsigned=function(e){return rn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ln(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):ln(32===e?this.high:this.high>>>e-32,0,this.unsigned)},In.shru=In.shiftRightUnsigned,In.shr_u=In.shiftRightUnsigned,In.rotateLeft=function(e){var t;return rn(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?ln(this.high,this.low,this.unsigned):e<32?(t=32-e,ln(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),ln(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},In.rotl=In.rotateLeft,In.rotateRight=function(e){var t;return rn(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?ln(this.high,this.low,this.unsigned):e<32?(t=32-e,ln(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),ln(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},In.rotr=In.rotateRight,In.toSigned=function(){return this.unsigned?ln(this.low,this.high,!1):this},In.toUnsigned=function(){return this.unsigned?this:ln(this.low,this.high,!0)},In.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},In.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},In.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},tn.fromBytes=function(e,t,r){return r?tn.fromBytesLE(e,t):tn.fromBytesBE(e,t)},tn.fromBytesLE=function(e,t){return new tn(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},tn.fromBytesBE=function(e,t){return new tn(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};const En={webSocketTimeout:5e3,signalTimeout:3e4,pingInterval:15e3,pingTimeout:5e3,pingFailedTimes:2,reconnectIntervalMin:250,reconnectIntervalMax:64e3,reconnectRaisingBase:2};const Tn=t=>e[t],Rn=()=>{const e="ACDeviceId";let t="";const r=Rt.get(e);return r?t=r:(t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),Rt.set(e,t)),t},kn=e=>{const t=new Xr;return t.writeIn8(67),t.writeIn8(255),t.writeInt32(e.length+7),t.writeArr(Array.from(e)),t.writeIn8(0),new Int8Array(t.getBytesArray()).buffer},An=e=>{const t=new Yr(new Uint8Array(e));t.readInt8(),t.readInt8();const r=t.readInt32(),n=t.readArr(r-7);if(t.readInt8(),e.byteLength!==r)throw new Error("packet resolve failed");return n};var Nn=new class{constructor(t){d(this,"url",""),d(this,"watcher",void 0),d(this,"provider",void 0),d(this,"options",void 0),d(this,"socket",void 0),d(this,"status",e.DISCONNECTED),d(this,"autoReconnect",!1),d(this,"isAuthorized",!1),d(this,"profile",void 0),d(this,"responseCallbacks",new Map),d(this,"failedCount",0),d(this,"reconnectTimer",void 0),d(this,"token",""),d(this,"connectResolve",void 0),d(this,"idCount",0),this.options=Object.assign(En,t)}setServerInfo(e){this.url=e}setCallback(e,t){this.watcher=e,this.provider=t}async connect(r){return this.token=r,new Promise((r=>{this.connectResolve=r,this.open().then((e=>e===t.SUCCESS?!f(this.provider)||this.provider.needReAuth()?this.auth():t.SUCCESS:e)).then((n=>{var o;(r(n),n===t.SUCCESS)?(this.isAuthorized=!0,this.profile=null===(o=this.provider)||void 0===o?void 0:o.profile(),this.autoReconnect=!0,this.onConnect()):this.onDisconnect(n===t.TIMEOUT?e.NETWORK_UNAVAILABLE:e.WEBSOCKET_UNAVAILABLE)}))}))}async send(e,r,n){var o;let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.options.signalTimeout;const{code:s,data:a}=await this.sendRawData(e,f(r)&&f(n.encoder)?n.encoder.encode(r).finish():new Uint8Array,i);if(0!==s)return{code:s,msg:"time out",data:null};if(!f(a)||!f(n.decoder))return{code:t.SUCCESS,msg:""};const c=null===(o=n.decoder)||void 0===o?void 0:o.decode(a);return c.errorCode?{code:Qr(c.errorCode),msg:c.errorMessage,data:null}:{data:c,code:t.SUCCESS,msg:""}}async sendRawData(e,r){var n,o,i;let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.options.signalTimeout;if(!this.socket)return{code:t.RC_NET_CHANNEL_INVALID};if(!this.isAuthorized&&!this.isAuthCommand(e))return{code:t.RC_NET_CHANNEL_INVALID};const a=this.generateMessageSeq(),c={cmdId:e,messageSeq:tn.fromNumber(a),deviceId:(null===(n=this.profile)||void 0===n?void 0:n.deviceId)??tn.fromInt(7),sessionId:(null===(o=this.profile)||void 0===o?void 0:o.sessionId)??tn.ZERO,uid:(null===(i=this.profile)||void 0===i?void 0:i.uid)??tn.ZERO,protocolVersion:0,destId:"",body:r,token:this.token};E.reqInfo(`websocket send -> cmd: 0x${e.toString(16)}, messageSeq: ${a}`),this.socket.send(kn(Hr.encode(c).finish()));const l=await new Promise((e=>{this.responseCallbacks.set(a,e),setTimeout((()=>{this.responseCallbacks.get(a)&&this.responseCallbacks.delete(a),e(null)}),s)}));return l?{code:0,data:l}:(E.warn(`send timeout -> cmd: 0x${e.toString(16)}, messageSeq: ${a}, timeout: ${s}`),{code:t.TIMEOUT})}close(){var r;this.autoReconnect=!1,this.doClose(),this.setStatus(e.DISCONNECTED),null===(r=this.connectResolve)||void 0===r||r.call(this,t.RC_SOCKET_DISCONNECTED)}async open(){const r=this.url;E.info(`conenct start -> ${r}`),this.setStatus(e.CONNECTING);const n=function(e,t){const r=new WebSocket(e,t);return r.binaryType="arraybuffer",{onClose(e){r.onclose=t=>{const{code:r,reason:n}=t;null==e||e(r,n)}},onError(e){r.onerror=t=>{e(t)}},onMessage(e){r.onmessage=t=>{e(t.data)}},onOpen(e){r.onopen=e},send(e){r.send(e)},close(e,t){r.close(e,t)}}}(this.url);this.socket=n;return await new Promise((o=>{n.onMessage((e=>{"ArrayBuffer"===h(e)?this.onReceiveMessage(e):E.error("Socket received invalid data:",e)})),n.onClose(((r,n)=>{E.warn("websocket closed -> code:",r,"reason:",n),this.onDisconnect(e.CONNECTION_CLOSED),o(t.RC_SOCKET_DISCONNECTED)})),n.onError((r=>{E.error("websocket error -> ",r),this.onDisconnect(e.WEBSOCKET_ERROR),o(t.RC_SOCKET_NOT_CREATED)})),n.onOpen((()=>{E.info("websocket open -> ",r),o(t.SUCCESS)})),setTimeout((()=>{o(t.TIMEOUT)}),this.options.webSocketTimeout)}))}async auth(){var e,r,n,o;E.info(`start auth -> ${this.token}`);const i={token:this.token,deviceType:7,imei:Rn(),brand:"",model:"",apnsToken:"",bandId:""},{code:s,msg:a,data:c}=await this.send(j.Auth,i,{encoder:Kr,decoder:Zr.AuthSignIn2TokenResp},8e3);return s===t.SUCCESS||c?(E.info("auth success -> ",null===(e=c.user)||void 0===e||null===(r=e.uid)||void 0===r?void 0:r.toString()),null===(n=this.watcher)||void 0===n||null===(o=n.onAuth)||void 0===o||o.call(n,c),t.SUCCESS):(E.warn("auth failed -> "+a),t.RC_CONN_NOT_AUTHRORIZED)}async checkAlive(){if(!this.socket||!this.isAuthorized)return;E.debug("send ping ->");const r={pingId:tn.ZERO,disconnectDelay:tn.ZERO},{code:n}=await this.send(j.Heartbean,r,{encoder:zr},this.options.pingTimeout);n===t.SUCCESS?(E.debug("recv pong <-"),this.failedCount=0,setTimeout((()=>this.checkAlive()),this.options.pingInterval)):(this.failedCount+=1,E.warn(`ping failed count: ${this.failedCount}, code: ${n}`),this.failedCount>=this.options.pingFailedTimes?(this.failedCount=0,E.warn("ping timeout, close current websocket to reconnect!"),this.onDisconnect(e.NETWORK_UNAVAILABLE)):this.checkAlive())}onReceiveMessage(t){let r;try{const e=An(t);r=Zr.NetworkResponse.decode(e)}catch(t){return E.error("unpack payload error -> ",t),void this.onDisconnect(e.DISCONNECT_BY_SERVER)}if(r.code)return void this.onDisconnect(e.DISCONNECT_BY_SERVER);if(r.cmdId===j.SessionKilledPush)return void this.onDisconnect(e.KICKED_OFFLINE_BY_OTHER_CLIENT);if(r.cmdId===j.SignOutPish||r.cmdId===j.SignOutPish2)return void this.onDisconnect(e.DISCONNECT_BY_SERVER);if(r.cmdId===j.UserFrozenToLogin||r.cmdId===j.UserFrozenToLogin2)return void this.onDisconnect(e.BLOCKED);const n=tn.isLong(r.messageSeq)?r.messageSeq.toNumber():0;E.reqInfo(`websocket recv ack -> messageSeq: ${n}`);const o=this.responseCallbacks.get(n);var i;f(o)?(o(r.body),this.responseCallbacks.delete(n)):(E.reqInfo(`websocket recv -> cmd: 0x${r.cmdId.toString(16)}, messageSeq: ${n}`),null===(i=this.watcher)||void 0===i||i.message(r.cmdId,r.body))}async try2Reconnect(){this.reconnectTimer=setTimeout((()=>{this.reconnectTimer=null,this.connect(this.token)}),5e3)}onConnect(){this.setStatus(e.CONNECTED),this.checkAlive(),f(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}onDisconnect(e){f(this.socket)&&(this.doClose(),this.isConnectionAvailable()&&(this.setStatus(e),this.autoReconnect&&this.isConnectionAvailable()&&this.try2Reconnect()))}doClose(){if(f(this.socket)){const e=this.socket;this.socket=null,e.onClose(null),e.close()}f(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.isAuthorized=!1,this.profile=null;for(const e of this.responseCallbacks.values())e(null);this.responseCallbacks.clear()}isConnectionAvailable(){return this.status!==e.DISCONNECTED&&this.status!==e.KICKED_OFFLINE_BY_OTHER_CLIENT&&this.status!==e.BLOCKED&&this.status!==e.DISCONNECT_BY_SERVER}setStatus(e){var t;e!==this.status&&(E.info(`socketServer is changing status from ${Tn(this.status)} to ${Tn(e)}`),this.status=e,null===(t=this.watcher)||void 0===t||t.status(e))}isAuthCommand(e){return e===j.Auth}generateMessageSeq(){return++this.idCount}};var xn=new class{constructor(){d(this,"_user",void 0),this._user=this.createDefaultUser()}get uid(){return this.user.uid.toString()}get user(){return this._user}setLogged(e,t){const r=e.user;f(r)&&(this._user={active:!0,uid:r.uid??tn.UZERO,deviceId:e.deviceId,sessionId:e.sessionId,token:t})}logOut(){this._user=this.createDefaultUser()}createDefaultUser(){return{active:!1,uid:tn.UZERO,deviceId:tn.UZERO,sessionId:tn.UZERO,token:""}}},Dn=At.exports,Mn=Dn.Reader,Ln=Dn.util,Bn=Dn.roots.default||(Dn.roots.default={});Bn.NewMessageNotificationResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.NewMessageNotificationResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.seqno=e.int64();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NewMessageNotificationResp"},e}(),Bn.SendPrivateChatMessageResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.msgId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.SendPrivateChatMessageResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;case 6:n.seqno=e.int64();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageResp"},e}(),Bn.GetNewMessageResp=function(){function e(e){if(this.msg={},e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.offset=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.msg=Ln.emptyObject,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r,n,o=void 0===t?e.len:e.pos+t,i=new Bn.GetNewMessageResp;e.pos<o;){var s=e.uint32();switch(s>>>3){case 1:i.errorCode=e.int32();break;case 2:i.errorMessage=e.string();break;case 3:i.offset=e.int64();break;case 4:i.seqno=e.int64();break;case 5:i.msg===Ln.emptyObject&&(i.msg={});var a=e.uint32()+e.pos;for(r="",n=null;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:r=e.string();break;case 2:n=Bn.DialogMessageList.decode(e,e.uint32());break;default:e.skipType(7&c)}}i.msg[r]=n;break;default:e.skipType(7&s)}}return i},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageResp"},e}(),Bn.DialogMessageList=function(){function e(e){if(this.dialogMessage=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialogMessage=Ln.emptyArray,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.DialogMessageList;e.pos<r;){var o=e.uint32();if(o>>>3==1)n.dialogMessage&&n.dialogMessage.length||(n.dialogMessage=[]),n.dialogMessage.push(Bn.DialogMessage.decode(e,e.uint32()));else e.skipType(7&o)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessageList"},e}(),Bn.DialogMessage=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msgId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.localId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.msgStatus=0,e.prototype.srcId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.destId="",e.prototype.isOut=!1,e.prototype.senderCategory=0,e.prototype.msgCategory=0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.msgSendTime=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.burnAfterReadingFlag=!1,e.prototype.atFlag=!1,e.prototype.replyFlag=!1,e.prototype.referenceFlag=!1,e.prototype.msgIdReferenced=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.uploadFlag=!1,e.prototype.burnAfterReadingTime=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.sharingGroupFlag=!1,e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.extra="",e.prototype.msgContent=Ln.newBuffer([]),e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.DialogMessage;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.msgId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgStatus=e.int32();break;case 4:n.srcId=e.int64();break;case 5:n.destId=e.string();break;case 6:n.isOut=e.bool();break;case 7:n.senderCategory=e.int32();break;case 8:n.msgCategory=e.int32();break;case 9:n.msgPreContent=e.string();break;case 10:n.msgPostContent=e.string();break;case 11:n.mediaFlag=e.bool();break;case 12:n.mediaConstructor=e.int32();break;case 13:n.mediaAttribute=e.string();break;case 14:n.msgSendTime=e.int64();break;case 15:n.burnAfterReadingFlag=e.bool();break;case 16:n.atFlag=e.bool();break;case 17:n.replyFlag=e.bool();break;case 18:n.referenceFlag=e.bool();break;case 19:n.msgIdReferenced=e.int64();break;case 20:n.uploadFlag=e.bool();break;case 21:n.burnAfterReadingTime=e.int64();break;case 22:n.sharingGroupFlag=e.bool();break;case 23:n.seqno=e.int64();break;case 24:n.extra=e.string();break;case 25:n.msgContent=e.bytes();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessage"},e}(),Bn.GetBriefDialogListResp=function(){function e(e){if(this.notExistDestId=[],this.briefDialog={},e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.notExistDestId=Ln.emptyArray,e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.briefDialog=Ln.emptyObject,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r,n,o=void 0===t?e.len:e.pos+t,i=new Bn.GetBriefDialogListResp;e.pos<o;){var s=e.uint32();switch(s>>>3){case 1:i.errorCode=e.int32();break;case 2:i.errorMessage=e.string();break;case 3:if(i.notExistDestId&&i.notExistDestId.length||(i.notExistDestId=[]),2==(7&s))for(var a=e.uint32()+e.pos;e.pos<a;)i.notExistDestId.push(e.int64());else i.notExistDestId.push(e.int64());break;case 4:i.seqno=e.int64();break;case 5:i.briefDialog===Ln.emptyObject&&(i.briefDialog={});a=e.uint32()+e.pos;for(r="",n=null;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:r=e.string();break;case 2:n=Bn.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&c)}}i.briefDialog[r]=n;break;default:e.skipType(7&s)}}return i},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListResp"},e}(),Bn.BriefDialog=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.dialogTitle="",e.prototype.smallAvatarUrl="",e.prototype.backgroundImage="",e.prototype.stickyFlag=!1,e.prototype.muteFlag=!1,e.prototype.blockFlag=!1,e.prototype.burnAfterReadingFlag=!1,e.prototype.takeScreenshotFlag=!1,e.prototype.groupFlag=!1,e.prototype.pushNotificationLevel=0,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.BriefDialog;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.destId=e.string();break;case 2:n.dialogTitle=e.string();break;case 3:n.smallAvatarUrl=e.string();break;case 4:n.backgroundImage=e.string();break;case 5:n.stickyFlag=e.bool();break;case 6:n.muteFlag=e.bool();break;case 7:n.blockFlag=e.bool();break;case 8:n.burnAfterReadingFlag=e.bool();break;case 9:n.takeScreenshotFlag=e.bool();break;case 10:n.groupFlag=e.bool();break;case 15:n.pushNotificationLevel=e.int32();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/BriefDialog"},e}(),Bn.GetDialogKeyResp=function(){function e(e){if(this.retryUid=[],this.entry={},e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.dialogKeyVersion=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.retryUid=Ln.emptyArray,e.prototype.entry=Ln.emptyObject,e.prototype.serverSign="",e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r,n,o=void 0===t?e.len:e.pos+t,i=new Bn.GetDialogKeyResp;e.pos<o;){var s=e.uint32();switch(s>>>3){case 1:i.errorCode=e.int32();break;case 2:i.errorMessage=e.string();break;case 3:i.dialogKeyVersion=e.int64();break;case 4:if(i.retryUid&&i.retryUid.length||(i.retryUid=[]),2==(7&s))for(var a=e.uint32()+e.pos;e.pos<a;)i.retryUid.push(e.int64());else i.retryUid.push(e.int64());break;case 5:i.entry===Ln.emptyObject&&(i.entry={});a=e.uint32()+e.pos;for(r="",n=null;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:r=e.string();break;case 2:n=Bn.AesKeyAndIV.decode(e,e.uint32());break;default:e.skipType(7&c)}}i.entry[r]=n;break;case 6:i.serverSign=e.string();break;default:e.skipType(7&s)}}return i},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyResp"},e}(),Bn.AesKeyAndIV=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.aesKey="",e.prototype.aesIV="",e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.AesKeyAndIV;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.aesKey=e.string();break;case 2:n.aesIV=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AesKeyAndIV"},e}(),Bn.GetHistoryMessageResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.msg=null,e.prototype.isEnd=!1,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.GetHistoryMessageResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.msg=Bn.DialogMessageList.decode(e,e.uint32());break;case 4:n.isEnd=e.bool();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageResp"},e}(),Bn.GetWebDialogListResp=function(){function e(e){if(this.fullDialog=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.fullDialog=Ln.emptyArray,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.GetWebDialogListResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.fullDialog&&n.fullDialog.length||(n.fullDialog=[]),n.fullDialog.push(Bn.WebFullDialog.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListResp"},e}(),Bn.WebFullDialog=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialog=null,e.prototype.msg=null,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.WebFullDialog;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.dialog=Bn.BriefDialog.decode(e,e.uint32());break;case 2:n.msg=Bn.DialogMessage.decode(e,e.uint32());break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebFullDialog"},e}(),Bn.GetNewSettingDialogListResp=function(){function e(e){if(this.briefDialog={},e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.briefDialog=Ln.emptyObject,e.prototype.setTime=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r,n,o=void 0===t?e.len:e.pos+t,i=new Bn.GetNewSettingDialogListResp;e.pos<o;){var s=e.uint32();switch(s>>>3){case 1:i.errorCode=e.int32();break;case 2:i.errorMessage=e.string();break;case 3:i.briefDialog===Ln.emptyObject&&(i.briefDialog={});var a=e.uint32()+e.pos;for(r="",n=null;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:r=e.string();break;case 2:n=Bn.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&c)}}i.briefDialog[r]=n;break;case 4:i.setTime=e.int64();break;default:e.skipType(7&s)}}return i},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListResp"},e}();var Un=Bn;var jn=new class{constructor(){d(this,"_token",""),d(this,"_uploadUrl",""),d(this,"_downloadUrl",""),d(this,"_cert","")}set imInitToken(e){this._token=e}get imInitToken(){return this._token}get fileUploadUrl(){return this._uploadUrl}get cert(){return this._cert}get fileDownloadUrl(){return this._downloadUrl}setFileServerInfo(e,t,r){this._uploadUrl=e,this._downloadUrl=t,this._cert=r}getFileAbsoluteUri(e){return O(e)?e.startsWith("http")?e:this.fileDownloadUrl+e:e}try2ExtractFileRelativeUri(e){return O(e)&&e.startsWith(this.fileDownloadUrl)?e.substring(this.fileDownloadUrl.length):e}};const Pn=e=>{if(!O(e.targetId+""))return"";switch(e.conversationType){case n.PRIVATE:return"P::"+e.targetId;case n.GROUP:return"G::"+e.targetId;case n.ULTRA_GROUP:return`SG::${e.targetId}_${e.channelId??""}`;default:return""}},Fn=e=>{if(!O(e))return null;const t=e.split("::");if(2!==t.length)return null;const r=t[0];if("G"===r)return{conversationType:n.GROUP,targetId:t[1]};if("P"===r)return{conversationType:n.PRIVATE,targetId:t[1]};if("SG"===r){const e=t[1].indexOf("_");if(e>0){const r=t[1].substring(0,e),o=t[1].substring(e+1);return{conversationType:n.ULTRA_GROUP,targetId:r,channelId:o}}return 0===e?null:{conversationType:n.ULTRA_GROUP,targetId:t[1]}}return null},Gn=e=>e.startsWith("SG")||e.startsWith("G");var qn=At.exports,Hn=qn.Writer,zn=qn.util,Kn=qn.roots.default||(qn.roots.default={});Kn.SendPrivateChatMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.localId=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.extra="",e.prototype.thumbnail="",e.prototype.msgContent=zn.newBuffer([]),e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.extra&&Object.hasOwnProperty.call(e,"extra")&&t.uint32(66).string(e.extra),null!=e.thumbnail&&Object.hasOwnProperty.call(e,"thumbnail")&&t.uint32(74).string(e.thumbnail),null!=e.msgContent&&Object.hasOwnProperty.call(e,"msgContent")&&t.uint32(82).bytes(e.msgContent),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageReq"},e}(),Kn.DeletePrivateChatDialogReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatDialogReq"},e}(),Kn.GetNewMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.offset=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(8).int64(e.offset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(16).int32(e.rows),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageReq"},e}(),Kn.UpdatePrivateChatDialogStickyConfigReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(16).bool(e.stickyFlag),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogStickyConfigReq"},e}(),Kn.UpdatePrivateChatDialogMuteConfigReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(16).bool(e.muteFlag),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogMuteConfigReq"},e}(),Kn.DeleteChatMessageReq=function(){function e(e){if(this.msgIdList=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.msgId=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=zn.emptyArray,e.encode=function(e,t){if(t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),null!=e.msgIdList&&e.msgIdList.length){t.uint32(26).fork();for(var r=0;r<e.msgIdList.length;++r)t.int64(e.msgIdList[r]);t.ldelim()}return t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteChatMessageReq"},e}(),Kn.DeletePrivateChatHistoryReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.msgId=zn.Long?zn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatHistoryReq"},e}(),Kn.CleanHistoryMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.type=0,e.prototype.msgTime=zn.Long?zn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(16).int32(e.type),null!=e.msgTime&&Object.hasOwnProperty.call(e,"msgTime")&&t.uint32(24).int64(e.msgTime),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/CleanHistoryMessageReq"},e}(),Kn.GetBriefDialogListReq=function(){function e(e){if(this.destId=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=zn.emptyArray,e.encode=function(e,t){if(t||(t=Hn.create()),null!=e.destId&&e.destId.length)for(var r=0;r<e.destId.length;++r)t.uint32(10).string(e.destId[r]);return t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListReq"},e}(),Kn.GetDialogKeyReq=function(){function e(e){if(this.destId=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=zn.emptyArray,e.prototype.clientSign="",e.encode=function(e,t){if(t||(t=Hn.create()),null!=e.destId&&e.destId.length)for(var r=0;r<e.destId.length;++r)t.uint32(10).string(e.destId[r]);return null!=e.clientSign&&Object.hasOwnProperty.call(e,"clientSign")&&t.uint32(18).string(e.clientSign),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyReq"},e}(),Kn.RecallPrivateChatMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.msgId=zn.Long?zn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallPrivateChatMessageReq"},e}(),Kn.GetHistoryMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialogKeys="",e.prototype.offset=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.oldOffset=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.dialogKeys&&Object.hasOwnProperty.call(e,"dialogKeys")&&t.uint32(10).string(e.dialogKeys),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(16).int64(e.offset),null!=e.oldOffset&&Object.hasOwnProperty.call(e,"oldOffset")&&t.uint32(24).int64(e.oldOffset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(32).int32(e.rows),null!=e.newToOld&&Object.hasOwnProperty.call(e,"newToOld")&&t.uint32(40).bool(e.newToOld),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageReq"},e}(),Kn.GetWebDialogListReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.type=0,e.prototype.offset=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(16).int64(e.offset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(24).int32(e.rows),null!=e.newToOld&&Object.hasOwnProperty.call(e,"newToOld")&&t.uint32(32).bool(e.newToOld),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListReq"},e}(),Kn.GetNewSettingDialogListReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.time=zn.Long?zn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.time&&Object.hasOwnProperty.call(e,"time")&&t.uint32(8).int64(e.time),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListReq"},e}();var Vn=Kn,Wn=At.exports,$n=Wn.Writer,Jn=Wn.util,Zn=Wn.roots.default||(Wn.roots.default={});Zn.SendGroupChatMessageReq=function(){function e(e){if(this.at=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.prototype.localId=Jn.Long?Jn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.at=Jn.emptyArray,e.prototype.extra="",e.prototype.assign="",e.prototype.atAll=!1,e.prototype.msgContent=Jn.newBuffer([]),e.encode=function(e,t){if(t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.at&&e.at.length){t.uint32(66).fork();for(var r=0;r<e.at.length;++r)t.int64(e.at[r]);t.ldelim()}return null!=e.extra&&Object.hasOwnProperty.call(e,"extra")&&t.uint32(74).string(e.extra),null!=e.assign&&Object.hasOwnProperty.call(e,"assign")&&t.uint32(82).string(e.assign),null!=e.atAll&&Object.hasOwnProperty.call(e,"atAll")&&t.uint32(88).bool(e.atAll),null!=e.msgContent&&Object.hasOwnProperty.call(e,"msgContent")&&t.uint32(98).bytes(e.msgContent),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageReq"},e}(),Zn.DeleteGroupChatHistoryReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatHistoryReq"},e}(),Zn.UpdateGroupChatDialogStickyConfigReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(16).bool(e.stickyFlag),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogStickyConfigReq"},e}(),Zn.UpdateGroupChatDialogMuteConfigReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(16).bool(e.muteFlag),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogMuteConfigReq"},e}(),Zn.RecallGroupChatMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.prototype.msgId=Jn.Long?Jn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallGroupChatMessageReq"},e}(),Zn.DeleteGroupChatDialogReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatDialogReq"},e}();var Xn=Zn;const Yn=At.exports.Reader,Qn=At.exports.util,eo=At.exports.roots.default||(At.exports.roots.default={}),to=eo.SendGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Qn.Long?Qn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Qn.Long?Qn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Qn.Long?Qn.Long.fromBits(0,0,!1):0,e.prototype.seqno=Qn.Long?Qn.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Yn||(e=Yn.create(e));let r=void 0===t?e.len:e.pos+t,n=new eo.SendGroupChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;case 6:n.seqno=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageResp"},e})();let ro=0;const no=async()=>{const e=(new Date).getTime(),{code:r,data:n}=await Nn.send(j.GetServerTime,null,{decoder:Zr.SystemCurrentTimeMillisResp});if(r===t.SUCCESS){const{currentTimeMillis:t}=n;ro=t.toNumber()-e}},oo=()=>(new Date).getTime()+ro,io=new Set;var so={addMessage(e){io.add(e)},remove(e){io.delete(e)},has:e=>io.has(e),reset(){io.clear()}};const ao=new Set;var co={addMessage(e){ao.add(e)},remove(e){ao.delete(e)},has:e=>ao.has(e),reset(){ao.clear()}};const lo=new Map;function uo(e){lo.set(e.getObjectId(),e.decode.bind(e))}class ho{constructor(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];d(this,"messageType",void 0),d(this,"content",void 0),d(this,"isPersited",void 0),d(this,"isCounted",void 0),d(this,"isStatusMessage",void 0),this.messageType=e,this.content=t,o?(this.isPersited=!1,this.isCounted=!1):(this.isPersited=r,this.isCounted=n),this.isStatusMessage=o}get objectId(){return this.constructor.getObjectId()}static getObjectId(){throw new Error("Method not implemented.")}static decode(e){throw new Error("Method not implemented.")}encode(){throw new Error("Method not implemented.")}}const fo=0,po=268439552,go=268439563,yo=268439562,vo=268439553,mo=268439581,bo=268439597,wo=268439613,Oo=268439629,Co=1610678301,_o=268439645,So="RC:TxtMsg",Io="RC:HQVCMsg",Eo="RC:FileMsg",To="RC:ImgMsg",Ro="RC:GIFMsg",ko="RC:RcCmd",Ao="RC:CmdMsg";class No extends ho{constructor(e){super(So,e)}static getObjectId(){return fo}static decode(e){const{user:t,extra:r,content:n}=e;return new No({user:t,extra:r,content:n})}encode(){const{user:e,extra:t,content:r}=this.content;return{user:e,extra:t,content:r}}}class xo extends ho{constructor(e){super(To,e)}static getObjectId(){return po}static decode(e){const{user:t,extra:r,thumbnailObjectKey:n,originalObjectKey:o,width:i,height:s}=e;return new xo({user:t,extra:r,content:n,imageUri:jn.getFileAbsoluteUri(o),width:i,height:s})}encode(){const{user:e,extra:t,content:r,imageUri:n,width:o,height:i}=this.content;return{user:e,extra:t,thumbnailObjectKey:r,originalObjectKey:jn.try2ExtractFileRelativeUri(n),width:o&&Math.floor(o),height:i&&Math.floor(i)}}}class Do extends ho{constructor(e){super(Ro,e)}static getObjectId(){return go}static decode(e){const{user:t,extra:r,size:n,originalObjectKey:o,width:i,height:s}=e;return new Do({user:t,extra:r,gifDataSize:n,remoteUrl:jn.getFileAbsoluteUri(o),width:i,height:s})}encode(){const{user:e,extra:t,gifDataSize:r,remoteUrl:n,width:o,height:i}=this.content;return{user:e,extra:t,size:r,originalObjectKey:jn.try2ExtractFileRelativeUri(n),width:o&&Math.floor(o),height:i&&Math.floor(i),extension:"gif"}}}class Mo extends ho{constructor(e){super(Io,e)}static getObjectId(){return vo}static decode(e){const{user:t,extra:r,length:n,audioObjectKey:o,extension:i}=e;return new Mo({user:t,extra:r,remoteUrl:jn.getFileAbsoluteUri(o),duration:n,type:i})}encode(){const{user:e,extra:t,remoteUrl:r,duration:n,type:o}=this.content;return{user:e,extra:t,length:n,audioObjectKey:jn.try2ExtractFileRelativeUri(r),extension:o}}}class Lo extends ho{constructor(e){super(Eo,e)}static getObjectId(){return yo}static decode(e){const{user:t,extra:r,title:n,extension:o,size:i,originalObjectKey:s}=e;return new Lo({user:t,extra:r,name:n,size:i,type:o,fileUrl:s})}encode(){const{user:e,extra:t,name:r,size:n,type:o,fileUrl:i}=this.content;return{user:e,extra:t,title:r,originalObjectKey:jn.try2ExtractFileRelativeUri(i),extension:o,size:n}}}class Bo extends ho{constructor(e){super(ko,e,!0,!1,!1)}static getObjectId(){return Co}static decode(e){return new Bo(e)}encode(){return this.content}}class Uo extends ho{constructor(e){super(Ao,e,!1,!1)}static getObjectId(){return _o}static decode(e){return new Uo(e)}encode(){return this.content}}class jo extends ho{static decode(e){const{messageType:t,fields:r,user:n,extra:o}=e;return new this(t,{...r,user:n,extra:o})}encode(){const{user:e,extra:t,mentionedInfo:r,...n}=this.content;return{messageType:this.messageType,fields:n,user:e,extra:t}}}class Po extends jo{constructor(e,t){super(e,t,!1,!1)}static getObjectId(){return mo}}class Fo extends jo{constructor(e,t){super(e,t,!0,!1)}static getObjectId(){return bo}}class Go extends jo{constructor(e,t){super(e,t,!0,!1)}static getObjectId(){return wo}}class qo extends jo{constructor(e,t){super(e,t,!1,!1,!0)}static getObjectId(){return Oo}}var Ho=new class{constructor(){d(this,"aesKeyRecord",new Map)}async getDialogAesKey(e){return O(e)?this.aesKeyRecord.has(e)?this.aesKeyRecord.get(e):new Promise((t=>{this.getDialogAesKeyListFromRemote([e]).then((r=>{t(r.get(e))})),setTimeout((()=>{t(null)}),8e3)})):null}getDialogAesKeyList(e){return new Promise((t=>{const r=new Map;this.getDialogAesKeyListInBatches(e,((n,o)=>{if(o.size)for(const[e,t]of o)r.set(e,t);(r.size===e.length||n)&&t(r)}))}))}getDialogAesKeyListInBatches(e,t){const r=new Map,n=[];e.forEach((e=>{if(!O(e))return;const t=this.getDialogAesKeyFromLocal(e);t?r.set(e,t):n.push(e)})),t(!1,r),n.length&&this.getDialogAesKeyListFromRemote(n).then((e=>{t(!0,e)}))}reset(){this.aesKeyRecord.clear()}async getDialogAesKeyListFromRemote(e){if(!e.length)return new Map;const{code:r,data:n}=await(o=e,Nn.send(j.GetDialogKey,{destId:o,clientSign:""},{encoder:Vn.GetDialogKeyReq,decoder:Un.GetDialogKeyResp}));var o;if(r===t.SUCCESS){const e=new Map;for(const t in n.entry){var i,s;const r=n.entry[t];if(null!==(i=r.aesKey)&&void 0!==i&&i.length&&null!==(s=r.aesIV)&&void 0!==s&&s.length){const n={key:r.aesKey,iv:r.aesIV};e.set(t,n),this.aesKeyRecord.set(t,n)}}return e}return new Map}getDialogAesKeyFromLocal(e){return O(e)?this.aesKeyRecord.get(e):null}};const zo="time",Ko=(e,t)=>[e,t,zo].join("_");class Vo{constructor(e,t){d(this,"appkey",void 0),d(this,"userId",void 0),d(this,"inBoxOffset",tn.ZERO),this.appkey=e,this.userId=t}setInboxOffset(e){if(this.inBoxOffset>e)return;this.inBoxOffset=e;const t=Ko(this.appkey,this.userId);Rt.set(t,e.toString())}getInboxOffset(){if(this.inBoxOffset.isZero()){const e=Ko(this.appkey,this.userId);this.inBoxOffset=tn.fromString(Rt.get(e)??"0")}return this.inBoxOffset}}const Wo=e=>{const t=[];let r,n,o;for(n=0;n<e.length;++n)for(r=e[n],o=3;o>=0;--o)t.push(r>>8*o&255);return new Uint8Array(t)};const $o=(e,t,r)=>{const n={};return e.forEach((e=>{const o=Jo(e,t.get(e),r.get(e));o.length&&(n[e]=o)})),n},Jo=(e,t,r)=>{const n=Fn(e);if(!n)return[];const o=new Set;let i=[];return t.forEach((e=>{const t=e;let c=t.mediaConstructor,l=Zo(t,r);if(!l)return;if(1610678290===c||1610743841===c){const{msgId:e,sendTime:r}=l,i={sentTime:r,messageUId:e,conversationType:n.conversationType,targetId:t.isOut?n.targetId:xn.uid,channelId:n.channelId};c=Co,l=i,o.add(e)}const u=function(e,t){const r=lo.get(e);return r?r(t):null}(c,l);if(f(u)){const e={...n,senderUserId:t.srcId.toString(),messageDirection:t.isOut?s.SEND:s.RECEIVE,isCounted:u.isCounted,isMentioned:t.atFlag,content:u.content,messageType:u.messageType,isOffLineMessage:!1,isPersited:u.isPersited,messageId:tn.isLong(t.localId)?t.localId.toNumber():void 0,messageUId:t.msgId.toString(),sentTime:t.seqno.toNumber(),receivedTime:oo(),isStatusMessage:u.isStatusMessage,receivedStatus:a.READ,disableNotification:!1};if(e.isStatusMessage&&oo()-e.sentTime>6e3)return;i.push(e)}})),o.size&&(i=i.filter((e=>!o.has(e.messageUId)))),i},Zo=(e,t)=>{try{var r,n;let o;o=null!==(r=e.msgContent)&&void 0!==r&&r.length?((e,t)=>{const r=window.btoa(String.fromCharCode(...e));return Ot.AES.decrypt(r,Ot.enc.Utf8.parse(t.key),{iv:f(t.iv)?Ot.enc.Utf8.parse(t.iv):void 0}).toString(Ot.enc.Utf8)})(e.msgContent,t):e.msgPreContent??"",1610678290!==e.mediaConstructor&&1610743841!==e.mediaConstructor||(o=Xo(o));let i={};return null!==(n=o)&&void 0!==n&&n.length&&(i=JSON.parse(o)),i}catch(t){return E.error("decode message content fail -> uid:",e.msgId.toString()),null}},Xo=e=>e.replace(/("msgId")\s*:\s*(\d+)/g,((e,t,r)=>`${t}:"${r}"`));var Yo={parse:function(e,t){const r=new Map;if(Object.keys(e).forEach((t=>{var n;const o=null===(n=e[t].dialogMessage)||void 0===n?void 0:n.filter((e=>!e.sharingGroupFlag));null!=o&&o.length&&r.set(t,o)})),!r.size)return void t(!0,{});const n=new Set(r.keys());Ho.getDialogAesKeyListInBatches([...r.keys()],((e,o)=>{if(o.size){const e=[...o.keys()];for(const t of e)n.delete(t);t(!n.size,$o(e,r,o))}n.size&&e&&t(!0,{})}))},parseSingleDialogMessages:Jo};function Qo(e){if(!f(e))return e;if(Array.isArray(e))return e.map((e=>Qo(e)));if(m(e)){const t={};return Object.keys(e).forEach((r=>{t[r]=Qo(e[r])})),t}return e}const ei={unreadMessageCount:{keyName:"c",defaultVal:0},lastUnreadTime:{keyName:"t",defaultVal:0},notificationStatus:{keyName:"nc",defaultVal:2},notificationLevel:{keyName:"nl",defaultVal:0},isTop:{keyName:"it",defaultVal:!1},mentionedUIds:{keyName:"mu",defaultVal:null}};class ti{constructor(e,t){d(this,"localStore",void 0);const r=`con-${e}-${t}`;this.localStore=new kt(r)}getStoreKey(e){return`${e.conversationType}_${e.targetId}_${e.channelId??""}`}getConOptionByKey(e){const t=(e=e||"").split("_");if(t.length>=2){const e=t.shift(),r=t.shift(),n=t.join("_");return{conversationType:Number(e),targetId:r,channelId:n}}return{conversationType:n.PRIVATE,targetId:"",channelId:""}}updateUnreadCount(e){const{conversationType:t,targetId:r,channelId:n,content:o,messageType:i,sentTime:a,isCounted:c,messageDirection:l}=e,u=l===s.SEND,d=i===ko,h=m(o),f={conversationType:t,targetId:r,channelId:n},p=this.get(f)||{},g=p.lastUnreadTime||0,y=p.unreadMessageCount||0;if(!(g>a)&&!u){if(c&&(p.unreadMessageCount=y+1,p.lastUnreadTime=a),d&&h){g>=o.sentTime&&y&&(p.unreadMessageCount=y-1)}this.set(f,p)}}updateMentionedData(e){const{conversationType:t,targetId:r,channelId:o,messageUId:i,messageType:a,isMentioned:c,messageDirection:l,content:u}=e;if(l===s.SEND||!c&&a!==ko)return;const d=this.getStoreKey({conversationType:t,targetId:r,channelId:o}),h=this.localStore.get(d)||{},f=ei.mentionedUIds.keyName,p=h[f]||[];if(c&&t===n.GROUP&&(p.includes(i)||p.push(i)),a===ko&&t===n.GROUP){const e=u,t=p.indexOf(e.messageUId);t>=0&&p.splice(t,1)}p.length?h[f]=p:delete h[f],C(h)?this.localStore.set(d,h):this.localStore.remove(d)}set(e,t){const r=this.getStoreKey(e),n=this.localStore.get(r)||{};for(const e of Ct(t)){const r=ei[e],o=t[e];if(y(null==r?void 0:r.keyName)||y(o))continue;o===r.defaultVal?delete n[r.keyName]:n[r.keyName]=o,n[ei.unreadMessageCount.keyName]||(delete n[ei.lastUnreadTime.keyName],delete n[ei.mentionedUIds.keyName])}C(n)?this.localStore.set(r,n):this.localStore.remove(r)}get(e){const t=this.getStoreKey(e),r=this.localStore.get(t)||{},n={};for(const e of Ct(ei)){const{keyName:t,defaultVal:i}=ei[e];var o;if("mentionedUIds"===e)n.unreadMentionedCount=(null===(o=r[t])||void 0===o?void 0:o.length)??0,n.hasMentioned=!!n.unreadMentionedCount;else n[e]=r[t]||Qo(i)}return n}getAll(){const e=this.localStore.getCache()||{},t=[];for(const r in e){const n=this.getConOptionByKey(r),o=e[r];for(const e of Ct(ei)){const{keyName:t,defaultVal:r}=ei[e];"mentionedUIds"!==e&&(n[e]=o[t]||Qo(r))}t.push(n)}return t}}const ri=e=>{const t=e.destId??"",r=Fn(t);if(!r)return;return{...r,unreadMessageCount:0,notificationStatus:e.muteFlag?i.OPEN:i.CLOSE,notificationLevel:p(e.pushNotificationLevel)&&0!==e.pushNotificationLevel&&f(c[e.pushNotificationLevel])?e.pushNotificationLevel:e.muteFlag?c.AT_USER_NOTIFICATION:c.NOT_SET,isTop:!!e.stickyFlag,lastUnreadTime:0}};class ni{constructor(e,t){d(this,"storageKey",void 0),d(this,"eventEmitter",void 0),d(this,"isPulling",!1),this.storageKey=`con-s-${e}-${t}`,this.eventEmitter=new B}async pull(){if(this.isPulling)return;let e;this.isPulling=!0;const r=Rt.get(this.storageKey);e=p(r)&&r>0?r:oo()-1e4;let{code:n,data:o}=await(e=>Nn.send(j.GetDialogChangedStatus,{time:tn.fromNumber(e)},{encoder:Vn.GetNewSettingDialogListReq,decoder:Un.GetNewSettingDialogListResp}))(e);n===t.SUCCESS&&(o.setTime.toNumber()>0&&Rt.set(this.storageKey,o.setTime.toNumber()),o.briefDialog&&Ct(o.briefDialog).forEach((e=>{const t=o.briefDialog[e],r=ri(t);r&&this.eventEmitter.emit("STATUS_CHANGED",r)}))),this.isPulling=!1}watch(e){this.eventEmitter.on("STATUS_CHANGED",(t=>{e(t)}))}}class oi{constructor(e,t,r){d(this,"updatedConversationFunc",void 0),d(this,"store",void 0),d(this,"draftMap",new Map),d(this,"localConversationSet",new Set),d(this,"updatedConversations",[]),d(this,"notify",void 0),d(this,"statusManager",void 0),this.updatedConversationFunc=r,this.store=new ti(e,t),this.notify=St(this.notifyConversationChanged.bind(this),0),this.statusManager=new ni(e,t),this.statusManager.watch((e=>{this.addStatus(e,!0)}))}getConversationKey(e){return`${e.conversationType}_${e.targetId}_${e.channelId??""}`}setUpdatedConversation(e){const t=this.updatedConversations.findIndex((t=>this.getConversationKey(e.conversation)===this.getConversationKey(t.conversation)));t>=0?(e={conversation:Object.assign(this.updatedConversations[t].conversation,e.conversation),updatedItems:Object.assign(this.updatedConversations[t].updatedItems,e.updatedItems)},this.updatedConversations[t]=e):this.updatedConversations.push(e),this.notify()}notifyConversationChanged(){var e;const t=this.updatedConversations.map((e=>({conversation:{...e.conversation,...this.store.get(e.conversation)},updatedItems:e.updatedItems})));this.updatedConversations=[],null===(e=this.updatedConversationFunc)||void 0===e||e.call(this,t)}syncConversationStatus(){this.statusManager.pull()}async loadConvsationsIfNotExist(e){if(null==e||!e.length)return;const r=e.filter((e=>!this.localConversationSet.has(this.getConversationKey(e))));if(!r.length)return;const n=r.map(Pn).filter(O);if(!n.length)return;const{code:o,data:i}=await(e=>Nn.send(j.GetBriefDialogList,{destId:e},{encoder:Vn.GetBriefDialogListReq,decoder:Un.GetBriefDialogListResp}))(n);o===t.SUCCESS&&Ct(i.briefDialog).forEach((e=>{const t=i.briefDialog[e],r=ri(t);r&&(this.localConversationSet.add(this.getConversationKey(r)),this.addStatus(r,!0))}))}addLocalConversation(e){const{conversationType:t,targetId:r,channelId:n,isTop:o,notificationStatus:i,notificationLevel:s}=e;this.localConversationSet.add(this.getConversationKey(e)),this.addStatus({conversationType:t,targetId:r,channelId:n,isTop:o,notificationStatus:i,notificationLevel:s},!1)}addStatus(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{conversationType:r,targetId:n,notificationStatus:o,notificationLevel:i,isTop:s,channelId:a}=e,c={conversationType:r,targetId:n,channelId:a},l=oo(),u=this.store.get(c),d={};f(i)&&u.notificationLevel!==i&&(d.notificationLevel={time:l,val:i}),f(o)&&u.notificationStatus!==o&&(d.notificationStatus={time:l,val:o}),f(s)&&u.isTop!==s&&(d.isTop={time:l,val:s}),this.store.set(c,{notificationStatus:o,isTop:s,notificationLevel:i}),Object.keys(d).length&&t&&this.setUpdatedConversation({conversation:c,updatedItems:d})}setConversationCacheByMessage(e){const{conversationType:t,isPersited:r,targetId:n,channelId:o}=e,i={conversationType:t,targetId:n,channelId:o},s={conversation:i,updatedItems:{}},a=Qo(this.get(i));this.store.updateUnreadCount(e),this.store.updateMentionedData(e);const c=this.get(i);a.unreadMessageCount!==c.unreadMessageCount&&(s.updatedItems.unreadMessageCount={time:e.sentTime,val:c.unreadMessageCount}),a.hasMentioned!==c.hasMentioned&&(s.updatedItems.hasMentioned={time:e.sentTime,val:c.hasMentioned}),a.unreadMentionedCount!==c.unreadMentionedCount&&(s.updatedItems.unreadMentionedCount={time:e.sentTime,val:c.unreadMentionedCount}),r&&(s.conversation.latestMessage=e,s.updatedItems.latestMessage={time:e.sentTime,val:e}),Object.keys(s.updatedItems).length&&this.setUpdatedConversation(s)}get(e){return this.store.get(e)}getAllUnreadCount(e,t){const r=this.store.getAll();let n=0;return r.forEach((r=>{let{unreadMessageCount:o,notificationStatus:s,notificationLevel:a,conversationType:c}=r;o=o||0;const l=s===i.OPEN||a>0;!t&&l||(e.length>0?e.includes(+c)&&(n+=+o):n+=+o)})),n}getUnreadCount(e){return this.store.get(e).unreadMessageCount||0}clearUnreadCount(e){const t=this.store.get(e),{unreadMessageCount:r,unreadMentionedCount:n}=t;(r||n)&&(t.unreadMessageCount=0,t.hasMentioned=!1,t.unreadMentionedCount=0),this.store.set(e,t);const o={};r&&(o.unreadMessageCount={val:0,time:oo()}),n&&(o.hasMentioned={val:!1,time:oo()},o.unreadMentionedCount={val:0,time:oo()}),Object.keys(o).length&&this.setUpdatedConversation({conversation:e,updatedItems:o})}clearAllUnreadCount(){this.store.getAll().forEach((e=>this.clearUnreadCount(e)))}getNotificationLevel(e){return this.store.get(e).notificationLevel}getNotificationStatus(e){return this.store.get(e).notificationStatus||2}setDraft(e,t){this.draftMap.set(this.getConversationKey(e),t)}getDraft(e){return this.draftMap.get(this.getConversationKey(e))??""}clearDraft(e){this.draftMap.delete(this.getConversationKey(e))}getBlockConversationList(){return this.store.getAll().filter((e=>e.notificationStatus===i.OPEN||e.notificationLevel>0)).map((e=>({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId})))}getTopConversationList(){return(this.store.getAll()||{}).filter((e=>e.isTop)).map((e=>({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId})))}getUnreadMentionedCount(e){return this.get(e).unreadMentionedCount||0}getAllUnreadMentionedCount(){const e=this.store.getAll();let t=0;return e.forEach((e=>{let{unreadMentionedCount:r}=e;r=r||0,t+=Number(r)})),t}getAllConversationState(){return this.store.getAll().map((e=>{let{unreadMessageCount:t,unreadMentionedCount:r,conversationType:n,targetId:o,channelId:i}=e;return{conversationType:n,targetId:o,channelId:i,unreadCount:t,unreadMentionedCount:r??0}})).filter((e=>e.unreadCount>0))}destroyed(){this.updatedConversationFunc=void 0}}const ii={addStatus:function(e,t){},setConversationCacheByMessage:function(e){},get:function(e){return null},getAllUnreadCount:function(e,t){return 0},getUnreadCount:function(e){return 0},clearUnreadCount:function(e){},clearAllUnreadCount(){},getNotificationLevel:function(e){return c.NOT_SET},getNotificationStatus:function(e){return i.CLOSE},setDraft:function(e,t){},getDraft:function(e){return""},clearDraft:function(e){},getBlockConversationList:function(){return[]},getTopConversationList:function(){return[]},getUnreadMentionedCount:function(e){return 0},getAllUnreadMentionedCount:function(){return 0},getAllConversationState:function(){return[]},addLocalConversation:function(e){},loadConvsationsIfNotExist:function(e){},destroyed(){},syncConversationStatus:function(){}};let si;var ai={create(e,t,r){si=new oi(e,t,r)},get:()=>si??ii};class ci{constructor(e,t){d(this,"watcher",void 0),d(this,"pullingMsg",!1),d(this,"letterbox",void 0),d(this,"serverMsgSeqno",tn.ZERO),d(this,"pullOfflineFinished",!1),d(this,"intervalTimer",void 0),d(this,"retryTimer",void 0),d(this,"latestSyncTimestamp",0),d(this,"started",!1),this.watcher=e,this.letterbox=new Vo(t.appkey,xn.uid)}start(){this.started=!0,this.pullOfflineFinished=!1,this.startPullInterval()}stop(){this.started=!1,this.stopPullInterval(),this.cancelRetryTask()}syncMsg(e){this.serverMsgSeqno=e,this.pullMsg()}startPullInterval(){this.stopPullInterval();this.intervalTimer=setInterval((()=>{Date.now()-this.latestSyncTimestamp>=18e4&&this.pullMsg()}),3e4),this.latestSyncTimestamp=Date.now(),this.pullMsg()}stopPullInterval(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null)}try2RePullMsg(){this.retryTimer=setTimeout((()=>{this.retryTimer=null,this.pullMsg()}),1e3)}cancelRetryTask(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}async pullMsg(){if(this.pullingMsg)return;if(!this.started)return;this.cancelRetryTask(),this.pullingMsg=!0;const e=this.letterbox.getInboxOffset();this.pullOfflineFinished||E.info(`pullMsg -> time: ${e}`),this.latestSyncTimestamp=Date.now();const{code:r,data:n}=await((e,t)=>Nn.send(j.GetNewMessage,{offset:e,rows:t},{encoder:Vn.GetNewMessageReq,decoder:Un.GetNewMessageResp}))(e,60);if(r!==t.SUCCESS)return this.pullOfflineFinished||E.warn("pullMsg failed -> code:",r),this.pullingMsg=!1,void this.try2RePullMsg();const{offset:o,seqno:i,msg:a}=n,c=Object.keys(a).map(Fn).filter((e=>f(e)));ai.get().loadConvsationsIfNotExist(c),Yo.parse(a,((e,t)=>{const r=[],n=[],a=!this.pullOfflineFinished;var c,l;(Object.keys(t).forEach((e=>{const o=t[e],i=[];if(o.forEach((e=>{e.messageDirection===s.SEND&&e.messageId&&so.has(e.messageId)?so.remove(e.messageId):e.messageType===ko&&co.has(e.content.messageUId)?co.remove(e.content.messageUId):(e.isOffLineMessage=a,ai.get().setConversationCacheByMessage(e),i.push(e))})),r.push(...i),this.isExistPersistedMessage(i)){const t=Fn(e);t&&n.push(t)}})),r.length)&&(null===(c=(l=this.watcher).batchMessage)||void 0===c||c.call(l,r));if(n.length&&ai.get().loadConvsationsIfNotExist(n),e){var u;i.ge(this.serverMsgSeqno)&&(this.serverMsgSeqno=i);const e=this.serverMsgSeqno.lessThanOrEqual(o);this.pullOfflineFinished||E.info(`pullMsg success -> syncTime: ${o}, finished: ${e}`),null===(u=this.letterbox)||void 0===u||u.setInboxOffset(o),this.pullingMsg=!1,e&&!this.pullOfflineFinished&&(this.pullOfflineFinished=!0,this.watcher.pullFinished&&this.watcher.pullFinished()),e||this.pullMsg()}}))}isExistPersistedMessage(e){return e.some((e=>e.isPersited))}}class li{static init(e){return this._loader||(this._loader=new li(e)),this._loader}static get loader(){return this._loader}constructor(t){d(this,"options",void 0),d(this,"connectionStatus",e.DISCONNECTED),d(this,"isInternalConnected",!1),d(this,"watcher",void 0),d(this,"messageLoader",void 0),this.options=t,this.watcher={onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0,pullFinished:void 0,batchMessage:void 0,conversationState:void 0},Nn.setServerInfo(this.getWebSocketUrl()),Nn.setCallback({status:this.connectionStatusListener.bind(this),message:this.messageListener.bind(this),onAuth:this.authListener.bind(this)},{needReAuth:this.needReAuthProvider.bind(this),profile:this.needProfileProvider.bind(this)}),this.registerMessage()}getWebSocketUrl(){var e;const t=null===(e=this.options)||void 0===e?void 0:e.serverInfo;return O(t)?w(r=t)&&/wss?:\/\//.test(r)?t:"ws://"+t:"wss://tt.mimelabs.xyz:8991";var r}registerMessage(){uo(No),uo(xo),uo(Do),uo(Mo),uo(Po),uo(Go),uo(Fo),uo(qo),uo(Bo),uo(Uo)}async connect(r){if(this.connectionStatus===e.CONNECTED)return{code:t.SUCCESS,userId:xn.uid+""};if(this.connectionStatus===e.CONNECTING)return{code:t.BIZ_ERROR_CONNECTING};if("string"!=typeof r||0===r.length)return{code:t.RC_CONN_USER_OR_PASSWD_ERROR};jn.imInitToken=r;const n=await Nn.connect(r);var o;n===t.SUCCESS&&(this.isInternalConnected=!0,ai.get().destroyed(),ai.create(this.options.appkey,xn.uid,this.watcher.conversationState),null===(o=this.messageLoader)||void 0===o||o.stop(),this.messageLoader=new ci(this.watcher,this.options),no(),so.reset(),co.reset(),Ho.reset());return{code:n,userId:xn.uid+""}}reconnect(){return this.isInternalConnected?Promise.resolve({code:t.CAN_NOT_RECONNECT}):this.connect(jn.imInitToken)}disconnect(){return this.isInternalConnected=!1,Nn.close(),Promise.resolve()}getConnectionStatus(){return this.connectionStatus}assignWatcher(e){Ct(this.watcher).forEach((t=>{if(Object.prototype.hasOwnProperty.call(e,t)){const r=e[t];this.watcher[t]=v(r)?r:void 0}}))}resetWatcher(){Ct(this.watcher).forEach((e=>{this.watcher[e]=void 0}))}async connectionStatusListener(t){this.connectionStatus=t,setTimeout((()=>{switch(t){case e.BLOCKED:case e.KICKED_OFFLINE_BY_OTHER_CLIENT:case e.DISCONNECT_BY_SERVER:this.handleDisconnect();break;case e.CONNECTING:this.handleConnecting();break;case e.CONNECTED:this.handleConnected();break;case e.DISCONNECTED:this.handleDisconnect()}}),0)}handleConnecting(){var e,t;null===(e=(t=this.watcher).onConnecting)||void 0===e||e.call(t)}handleConnected(){var t,r,n;null===(t=(r=this.watcher).onConnected)||void 0===t||t.call(r),null===(n=this.messageLoader)||void 0===n||n.start(),setTimeout((()=>{this.connectionStatus===e.CONNECTED&&ai.get().syncConversationStatus()}),2e3)}handleDisconnect(){var e,t,r;null===(e=(t=this.watcher).onDisconnect)||void 0===e||e.call(t),null===(r=this.messageLoader)||void 0===r||r.stop()}handleSuspend(){var e,t;null===(e=(t=this.watcher).onSuspend)||void 0===e||e.call(t)}messageListener(e,t){if(e===j.NewMessagePush){var r;const e=Un.NewMessageNotificationResp.decode(t);null===(r=this.messageLoader)||void 0===r||r.syncMsg(e.seqno)}else e===j.DialogChangedPush&&ai.get().syncConversationStatus()}authListener(e){jn.setFileServerInfo(e.fileDomain,e.dialogFileDomain,e.cert),xn.setLogged(e,jn.imInitToken)}needReAuthProvider(){return!xn.user.active||xn.user.token!==jn.imInitToken}needProfileProvider(){if(!this.needReAuthProvider()){const{deviceId:e,sessionId:t,uid:r}=xn.user;return{deviceId:e,sessionId:t,uid:r}}return null}}d(li,"_loader",void 0);var ui={exports:{}},di={exports:{}},hi={exports:{}},fi={exports:{}},pi=gi;function gi(e,t){"string"==typeof e&&(t=e,e=void 0);var r=[];function n(e){if("string"!=typeof e){var t=o();if(gi.verbose&&console.log("codegen: "+t),t="return "+t,e){for(var i=Object.keys(e),s=new Array(i.length+1),a=new Array(i.length),c=0;c<i.length;)s[c]=i[c],a[c]=e[i[c++]];return s[c]=t,Function.apply(null,s).apply(null,a)}return Function(t)()}for(var l=new Array(arguments.length-1),u=0;u<l.length;)l[u]=arguments[++u];if(u=0,e=e.replace(/%([%dfijs])/g,(function(e,t){var r=l[u++];switch(t){case"d":case"f":return String(Number(r));case"i":return String(Math.floor(r));case"j":return JSON.stringify(r);case"s":return String(r)}return"%"})),u!==l.length)throw Error("parameter count mismatch");return r.push(e),n}function o(n){return"function "+(n||t||"")+"("+(e&&e.join(",")||"")+"){\n "+r.join("\n ")+"\n}"}return n.toString=o,n}gi.verbose=!1;var yi=bi,vi=Dt,mi=Ht();function bi(e,t,r){return"function"==typeof t?(r=t,t={}):t||(t={}),r?!t.xhr&&mi&&mi.readFile?mi.readFile(e,(function(n,o){return n&&"undefined"!=typeof XMLHttpRequest?bi.xhr(e,t,r):n?r(n):r(null,t.binary?o:o.toString("utf8"))})):bi.xhr(e,t,r):vi(bi,this,e,t)}bi.xhr=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){if(0!==n.status&&200!==n.status)return r(Error("status "+n.status));if(t.binary){var e=n.response;if(!e){e=[];for(var o=0;o<n.responseText.length;++o)e.push(255&n.responseText.charCodeAt(o))}return r(null,"undefined"!=typeof Uint8Array?new Uint8Array(e):e)}return r(null,n.responseText)}},t.binary&&("overrideMimeType"in n&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.responseType="arraybuffer"),n.open("GET",e),n.send()};var wi={};!function(e){var t=e,r=t.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},n=t.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=r(e),o="";n&&(o=t.shift()+"/");for(var i=0;i<t.length;)".."===t[i]?i>0&&".."!==t[i-1]?t.splice(--i,2):n?t.splice(i,1):++i:"."===t[i]?t.splice(i,1):++i;return o+t.join("/")};t.resolve=function(e,t,o){return o||(t=n(t)),r(t)?t:(o||(e=n(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?n(e+"/"+t):t)}}(wi);var Oi,Ci,_i,Si,Ii,Ei,Ti,Ri,ki,Ai,Ni,xi,Di,Mi={};function Li(){return Oi||(Oi=1,function(e){var t=Mi,r=ps(),n=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function o(e,t){var r=0,o={};for(t|=0;r<e.length;)o[n[r+t]]=e[r++];return o}t.basic=o([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),t.defaults=o([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",r.emptyArray,null]),t.long=o([0,0,0,1,1],7),t.mapKey=o([0,0,0,5,5,0,0,0,1,1,0,2],2),t.packed=o([1,5,0,0,0,5,5,0,0,0,1,1,0])}()),Mi}function Bi(){if(_i)return Ci;_i=1,Ci=s;var e=gs();((s.prototype=Object.create(e.prototype)).constructor=s).className="Field";var t,r=ys(),n=Li(),o=ps(),i=/^required|optional|repeated$/;function s(t,r,s,a,c,l,u){if(o.isObject(a)?(u=c,l=a,a=c=void 0):o.isObject(c)&&(u=l,l=c,c=void 0),e.call(this,t,l),!o.isInteger(r)||r<0)throw TypeError("id must be a non-negative integer");if(!o.isString(s))throw TypeError("type must be a string");if(void 0!==a&&!i.test(a=a.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==c&&!o.isString(c))throw TypeError("extend must be a string");"proto3_optional"===a&&(a="optional"),this.rule=a&&"optional"!==a?a:void 0,this.type=s,this.id=r,this.extend=c||void 0,this.required="required"===a,this.optional=!this.required,this.repeated="repeated"===a,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!o.Long&&void 0!==n.long[s],this.bytes="bytes"===s,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=u}return s.fromJSON=function(e,t){return new s(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(s.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),s.prototype.setOption=function(t,r,n){return"packed"===t&&(this._packed=null),e.prototype.setOption.call(this,t,r,n)},s.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return o.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},s.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=n.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof t?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof r&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof r)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=o.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var i;o.base64.test(this.typeDefault)?o.base64.decode(this.typeDefault,i=o.newBuffer(o.base64.length(this.typeDefault)),0):o.utf8.write(this.typeDefault,i=o.newBuffer(o.utf8.length(this.typeDefault)),0),this.typeDefault=i}return this.map?this.defaultValue=o.emptyObject:this.repeated?this.defaultValue=o.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof t&&(this.parent.ctor.prototype[this.name]=this.defaultValue),e.prototype.resolve.call(this)},s.d=function(e,t,r,n){return"function"==typeof t?t=o.decorateType(t).name:t&&"object"==typeof t&&(t=o.decorateEnum(t).name),function(i,a){o.decorateType(i.constructor).add(new s(a,e,t,r,{default:n}))}},s._configure=function(e){t=e},Ci}function Ui(){if(Ii)return Si;Ii=1,Si=n;var e=gs();((n.prototype=Object.create(e.prototype)).constructor=n).className="OneOf";var t=Bi(),r=ps();function n(t,r,n,o){if(Array.isArray(r)||(n=r,r=void 0),e.call(this,t,n),void 0!==r&&!Array.isArray(r))throw TypeError("fieldNames must be an Array");this.oneof=r||[],this.fieldsArray=[],this.comment=o}function o(e){if(e.parent)for(var t=0;t<e.fieldsArray.length;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}return n.fromJSON=function(e,t){return new n(e,t.oneof,t.options,t.comment)},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])},n.prototype.add=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,o(this),this},n.prototype.remove=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");var r=this.fieldsArray.indexOf(e);if(r<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(r,1),(r=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(r,1),e.partOf=null,this},n.prototype.onAdd=function(t){e.prototype.onAdd.call(this,t);for(var r=0;r<this.oneof.length;++r){var n=t.get(this.oneof[r]);n&&!n.partOf&&(n.partOf=this,this.fieldsArray.push(n))}o(this)},n.prototype.onRemove=function(t){for(var r,n=0;n<this.fieldsArray.length;++n)(r=this.fieldsArray[n]).parent&&r.parent.remove(r);e.prototype.onRemove.call(this,t)},n.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(t,o){r.decorateType(t.constructor).add(new n(o,e)),Object.defineProperty(t,o,{get:r.oneOfGetter(e),set:r.oneOfSetter(e)})}},Si}function ji(){if(Ti)return Ei;Ti=1,Ei=c;var e=gs();((c.prototype=Object.create(e.prototype)).constructor=c).className="Namespace";var t,r,n,o=Bi(),i=ps(),s=Ui();function a(e,t){if(e&&e.length){for(var r={},n=0;n<e.length;++n)r[e[n].name]=e[n].toJSON(t);return r}}function c(t,r){e.call(this,t,r),this.nested=void 0,this._nestedArray=null}function l(e){return e._nestedArray=null,e}return c.fromJSON=function(e,t){return new c(e,t.options).addJSON(t.nested)},c.arrayToJSON=a,c.isReservedId=function(e,t){if(e)for(var r=0;r<e.length;++r)if("string"!=typeof e[r]&&e[r][0]<=t&&e[r][1]>t)return!0;return!1},c.isReservedName=function(e,t){if(e)for(var r=0;r<e.length;++r)if(e[r]===t)return!0;return!1},Object.defineProperty(c.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=i.toArray(this.nested))}}),c.prototype.toJSON=function(e){return i.toObject(["options",this.options,"nested",a(this.nestedArray,e)])},c.prototype.addJSON=function(e){if(e)for(var i,s=Object.keys(e),a=0;a<s.length;++a)i=e[s[a]],this.add((void 0!==i.fields?t.fromJSON:void 0!==i.values?n.fromJSON:void 0!==i.methods?r.fromJSON:void 0!==i.id?o.fromJSON:c.fromJSON)(s[a],i));return this},c.prototype.get=function(e){return this.nested&&this.nested[e]||null},c.prototype.getEnum=function(e){if(this.nested&&this.nested[e]instanceof n)return this.nested[e].values;throw Error("no such enum: "+e)},c.prototype.add=function(e){if(!(e instanceof o&&void 0!==e.extend||e instanceof t||e instanceof s||e instanceof n||e instanceof r||e instanceof c))throw TypeError("object must be a valid nested object");if(this.nested){var i=this.get(e.name);if(i){if(!(i instanceof c&&e instanceof c)||i instanceof t||i instanceof r)throw Error("duplicate name '"+e.name+"' in "+this);for(var a=i.nestedArray,u=0;u<a.length;++u)e.add(a[u]);this.remove(i),this.nested||(this.nested={}),e.setOptions(i.options,!0)}}else this.nested={};return this.nested[e.name]=e,e.onAdd(this),l(this)},c.prototype.remove=function(t){if(!(t instanceof e))throw TypeError("object must be a ReflectionObject");if(t.parent!==this)throw Error(t+" is not a member of "+this);return delete this.nested[t.name],Object.keys(this.nested).length||(this.nested=void 0),t.onRemove(this),l(this)},c.prototype.define=function(e,t){if(i.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&""===e[0])throw Error("path must be relative");for(var r=this;e.length>0;){var n=e.shift();if(r.nested&&r.nested[n]){if(!((r=r.nested[n])instanceof c))throw Error("path conflicts with non-namespace objects")}else r.add(r=new c(n))}return t&&r.addJSON(t),r},c.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t<e.length;)e[t]instanceof c?e[t++].resolveAll():e[t++].resolve();return this.resolve()},c.prototype.lookup=function(e,t,r){if("boolean"==typeof t?(r=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),i.isString(e)&&e.length){if("."===e)return this.root;e=e.split(".")}else if(!e.length)return this;if(""===e[0])return this.root.lookup(e.slice(1),t);var n=this.get(e[0]);if(n){if(1===e.length){if(!t||t.indexOf(n.constructor)>-1)return n}else if(n instanceof c&&(n=n.lookup(e.slice(1),t,!0)))return n}else for(var o=0;o<this.nestedArray.length;++o)if(this._nestedArray[o]instanceof c&&(n=this._nestedArray[o].lookup(e,t,!0)))return n;return null===this.parent||r?null:this.parent.lookup(e,t)},c.prototype.lookupType=function(e){var r=this.lookup(e,[t]);if(!r)throw Error("no such type: "+e);return r},c.prototype.lookupEnum=function(e){var t=this.lookup(e,[n]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},c.prototype.lookupTypeOrEnum=function(e){var r=this.lookup(e,[t,n]);if(!r)throw Error("no such Type or Enum '"+e+"' in "+this);return r},c.prototype.lookupService=function(e){var t=this.lookup(e,[r]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},c._configure=function(e,o,i){t=e,r=o,n=i},Ei}function Pi(){if(ki)return Ri;ki=1,Ri=n;var e=Bi();((n.prototype=Object.create(e.prototype)).constructor=n).className="MapField";var t=Li(),r=ps();function n(t,n,o,i,s,a){if(e.call(this,t,n,i,void 0,void 0,s,a),!r.isString(o))throw TypeError("keyType must be a string");this.keyType=o,this.resolvedKeyType=null,this.map=!0}return n.fromJSON=function(e,t){return new n(e,t.id,t.keyType,t.type,t.options,t.comment)},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},n.prototype.resolve=function(){if(this.resolved)return this;if(void 0===t.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return e.prototype.resolve.call(this)},n.d=function(e,t,o){return"function"==typeof o?o=r.decorateType(o).name:o&&"object"==typeof o&&(o=r.decorateEnum(o).name),function(i,s){r.decorateType(i.constructor).add(new n(s,e,t,o))}},Ri}function Fi(){if(Ni)return Ai;Ni=1,Ai=r;var e=gs();((r.prototype=Object.create(e.prototype)).constructor=r).className="Method";var t=ps();function r(r,n,o,i,s,a,c,l,u){if(t.isObject(s)?(c=s,s=a=void 0):t.isObject(a)&&(c=a,a=void 0),void 0!==n&&!t.isString(n))throw TypeError("type must be a string");if(!t.isString(o))throw TypeError("requestType must be a string");if(!t.isString(i))throw TypeError("responseType must be a string");e.call(this,r,c),this.type=n||"rpc",this.requestType=o,this.requestStream=!!s||void 0,this.responseType=i,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=l,this.parsedOptions=u}return r.fromJSON=function(e,t){return new r(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},r.prototype.toJSON=function(e){var r=!!e&&Boolean(e.keepComments);return t.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",r?this.comment:void 0,"parsedOptions",this.parsedOptions])},r.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),e.prototype.resolve.call(this))},Ai}function Gi(){if(Di)return xi;Di=1,xi=o;var e=ji();((o.prototype=Object.create(e.prototype)).constructor=o).className="Service";var t=Fi(),r=ps(),n=Lr;function o(t,r){e.call(this,t,r),this.methods={},this._methodsArray=null}function i(e){return e._methodsArray=null,e}return o.fromJSON=function(e,r){var n=new o(e,r.options);if(r.methods)for(var i=Object.keys(r.methods),s=0;s<i.length;++s)n.add(t.fromJSON(i[s],r.methods[i[s]]));return r.nested&&n.addJSON(r.nested),n.comment=r.comment,n},o.prototype.toJSON=function(t){var n=e.prototype.toJSON.call(this,t),o=!!t&&Boolean(t.keepComments);return r.toObject(["options",n&&n.options||void 0,"methods",e.arrayToJSON(this.methodsArray,t)||{},"nested",n&&n.nested||void 0,"comment",o?this.comment:void 0])},Object.defineProperty(o.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=r.toArray(this.methods))}}),o.prototype.get=function(t){return this.methods[t]||e.prototype.get.call(this,t)},o.prototype.resolveAll=function(){for(var t=this.methodsArray,r=0;r<t.length;++r)t[r].resolve();return e.prototype.resolve.call(this)},o.prototype.add=function(r){if(this.get(r.name))throw Error("duplicate name '"+r.name+"' in "+this);return r instanceof t?(this.methods[r.name]=r,r.parent=this,i(this)):e.prototype.add.call(this,r)},o.prototype.remove=function(r){if(r instanceof t){if(this.methods[r.name]!==r)throw Error(r+" is not a member of "+this);return delete this.methods[r.name],r.parent=null,i(this)}return e.prototype.remove.call(this,r)},o.prototype.create=function(e,t,o){for(var i,s=new n.Service(e,t,o),a=0;a<this.methodsArray.length;++a){var c=r.lcFirst((i=this._methodsArray[a]).resolve().name).replace(/[^$\w_]/g,"");s[c]=r.codegen(["r","c"],r.isReserved(c)?c+"_":c)("return this.rpcCall(m,q,s,r,c)")({m:i,q:i.resolvedRequestType.ctor,s:i.resolvedResponseType.ctor})}return s},xi}var qi,Hi,zi,Ki,Vi=$i,Wi=Jt();function $i(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)this[t[r]]=e[t[r]]}function Ji(){if(Hi)return qi;Hi=1,qi=function(o){var i=r.codegen(["r","l"],o.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(o.fieldsArray.filter((function(e){return e.map})).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");o.group&&i("if((t&7)===4)")("break");i("switch(t>>>3){");for(var s=0;s<o.fieldsArray.length;++s){var a=o._fieldsArray[s].resolve(),c=a.resolvedType instanceof e?"int32":a.type,l="m"+r.safeProp(a.name);i("case %i: {",a.id),a.map?(i("if(%s===util.emptyObject)",l)("%s={}",l)("var c2 = r.uint32()+r.pos"),void 0!==t.defaults[a.keyType]?i("k=%j",t.defaults[a.keyType]):i("k=null"),void 0!==t.defaults[c]?i("value=%j",t.defaults[c]):i("value=null"),i("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",a.keyType)("case 2:"),void 0===t.basic[c]?i("value=types[%i].decode(r,r.uint32())",s):i("value=r.%s()",c),i("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==t.long[a.keyType]?i('%s[typeof k==="object"?util.longToHash(k):k]=value',l):i("%s[k]=value",l)):a.repeated?(i("if(!(%s&&%s.length))",l,l)("%s=[]",l),void 0!==t.packed[c]&&i("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",l,c)("}else"),void 0===t.basic[c]?i(a.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",l,s):i("%s.push(r.%s())",l,c)):void 0===t.basic[c]?i(a.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",l,s):i("%s=r.%s()",l,c),i("break")("}")}for(i("default:")("r.skipType(t&7)")("break")("}")("}"),s=0;s<o._fieldsArray.length;++s){var u=o._fieldsArray[s];u.required&&i("if(!m.hasOwnProperty(%j))",u.name)("throw util.ProtocolError(%j,{instance:m})",n(u))}return i("return m")};var e=ys(),t=Li(),r=ps();function n(e){return"missing required '"+e.name+"'"}return qi}function Zi(){if(Ki)return zi;Ki=1,zi=function(e){var i=t.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),s=e.oneofsArray,a={};s.length&&i("var p={}");for(var c=0;c<e.fieldsArray.length;++c){var l=e._fieldsArray[c].resolve(),u="m"+t.safeProp(l.name);if(l.optional&&i("if(%s!=null&&m.hasOwnProperty(%j)){",u,l.name),l.map)i("if(!util.isObject(%s))",u)("return%j",r(l,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),o(i,l,"k[i]"),n(i,l,c,u+"[k[i]]")("}");else if(l.repeated)i("if(!Array.isArray(%s))",u)("return%j",r(l,"array"))("for(var i=0;i<%s.length;++i){",u),n(i,l,c,u+"[i]")("}");else{if(l.partOf){var d=t.safeProp(l.partOf.name);1===a[l.partOf.name]&&i("if(p%s===1)",d)("return%j",l.partOf.name+": multiple values"),a[l.partOf.name]=1,i("p%s=1",d)}n(i,l,c,u)}l.optional&&i("}")}return i("return null")};var e=ys(),t=ps();function r(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function n(t,n,o,i){if(n.resolvedType)if(n.resolvedType instanceof e){t("switch(%s){",i)("default:")("return%j",r(n,"enum value"));for(var s=Object.keys(n.resolvedType.values),a=0;a<s.length;++a)t("case %i:",n.resolvedType.values[s[a]]);t("break")("}")}else t("{")("var e=types[%i].verify(%s);",o,i)("if(e)")("return%j+e",n.name+".")("}");else switch(n.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",i)("return%j",r(n,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":t("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",i,i,i,i)("return%j",r(n,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',i)("return%j",r(n,"number"));break;case"bool":t('if(typeof %s!=="boolean")',i)("return%j",r(n,"boolean"));break;case"string":t("if(!util.isString(%s))",i)("return%j",r(n,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',i,i,i)("return%j",r(n,"buffer"))}return t}function o(e,t,n){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",n)("return%j",r(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",n)("return%j",r(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",n)("return%j",r(t,"boolean key"))}return e}return zi}$i.create=function(e){return this.$type.create(e)},$i.encode=function(e,t){return this.$type.encode(e,t)},$i.encodeDelimited=function(e,t){return this.$type.encodeDelimited(e,t)},$i.decode=function(e){return this.$type.decode(e)},$i.decodeDelimited=function(e){return this.$type.decodeDelimited(e)},$i.verify=function(e){return this.$type.verify(e)},$i.fromObject=function(e){return this.$type.fromObject(e)},$i.toObject=function(e,t){return this.$type.toObject(e,t)},$i.prototype.toJSON=function(){return this.$type.toObject(this,Wi.toJSONOptions)};var Xi,Yi={};function Qi(){return Xi||(Xi=1,function(e){var t=e,r=ys(),n=ps();function o(e,t,n,o){var i=!1;if(t.resolvedType)if(t.resolvedType instanceof r){e("switch(d%s){",o);for(var s=t.resolvedType.values,a=Object.keys(s),c=0;c<a.length;++c)s[a[c]]!==t.typeDefault||i||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',o,o,o),t.repeated||e("break"),i=!0),e("case%j:",a[c])("case %i:",s[a[c]])("m%s=%j",o,s[a[c]])("break");e("}")}else e('if(typeof d%s!=="object")',o)("throw TypeError(%j)",t.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",o,n,o);else{var l=!1;switch(t.type){case"double":case"float":e("m%s=Number(d%s)",o,o);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",o,o);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",o,o);break;case"uint64":l=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",o,o,l)('else if(typeof d%s==="string")',o)("m%s=parseInt(d%s,10)",o,o)('else if(typeof d%s==="number")',o)("m%s=d%s",o,o)('else if(typeof d%s==="object")',o)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",o,o,o,l?"true":"");break;case"bytes":e('if(typeof d%s==="string")',o)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",o,o,o)("else if(d%s.length >= 0)",o)("m%s=d%s",o,o);break;case"string":e("m%s=String(d%s)",o,o);break;case"bool":e("m%s=Boolean(d%s)",o,o)}}return e}function i(e,t,n,o){if(t.resolvedType)t.resolvedType instanceof r?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",o,n,o,o,n,o,o):e("d%s=types[%i].toObject(m%s,o)",o,n,o);else{var i=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",o,o,o,o);break;case"uint64":i=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',o)("d%s=o.longs===String?String(m%s):m%s",o,o,o)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",o,o,o,o,i?"true":"",o);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",o,o,o,o,o);break;default:e("d%s=m%s",o,o)}}return e}t.fromObject=function(e){var t=e.fieldsArray,i=n.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return i("return new this.ctor");i("var m=new this.ctor");for(var s=0;s<t.length;++s){var a=t[s].resolve(),c=n.safeProp(a.name);a.map?(i("if(d%s){",c)('if(typeof d%s!=="object")',c)("throw TypeError(%j)",a.fullName+": object expected")("m%s={}",c)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",c),o(i,a,s,c+"[ks[i]]")("}")("}")):a.repeated?(i("if(d%s){",c)("if(!Array.isArray(d%s))",c)("throw TypeError(%j)",a.fullName+": array expected")("m%s=[]",c)("for(var i=0;i<d%s.length;++i){",c),o(i,a,s,c+"[i]")("}")("}")):(a.resolvedType instanceof r||i("if(d%s!=null){",c),o(i,a,s,c),a.resolvedType instanceof r||i("}"))}return i("return m")},t.toObject=function(e){var t=e.fieldsArray.slice().sort(n.compareFieldsById);if(!t.length)return n.codegen()("return {}");for(var o=n.codegen(["m","o"],e.name+"$toObject")("if(!o)")("o={}")("var d={}"),s=[],a=[],c=[],l=0;l<t.length;++l)t[l].partOf||(t[l].resolve().repeated?s:t[l].map?a:c).push(t[l]);if(s.length){for(o("if(o.arrays||o.defaults){"),l=0;l<s.length;++l)o("d%s=[]",n.safeProp(s[l].name));o("}")}if(a.length){for(o("if(o.objects||o.defaults){"),l=0;l<a.length;++l)o("d%s={}",n.safeProp(a[l].name));o("}")}if(c.length){for(o("if(o.defaults){"),l=0;l<c.length;++l){var u=c[l],d=n.safeProp(u.name);if(u.resolvedType instanceof r)o("d%s=o.enums===String?%j:%j",d,u.resolvedType.valuesById[u.typeDefault],u.typeDefault);else if(u.long)o("if(util.Long){")("var n=new util.Long(%i,%i,%j)",u.typeDefault.low,u.typeDefault.high,u.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",d)("}else")("d%s=o.longs===String?%j:%i",d,u.typeDefault.toString(),u.typeDefault.toNumber());else if(u.bytes){var h="["+Array.prototype.slice.call(u.typeDefault).join(",")+"]";o("if(o.bytes===String)d%s=%j",d,String.fromCharCode.apply(String,u.typeDefault))("else{")("d%s=%s",d,h)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",d,d)("}")}else o("d%s=%j",d,u.typeDefault)}o("}")}var f=!1;for(l=0;l<t.length;++l){u=t[l];var p=e._fieldsArray.indexOf(u);d=n.safeProp(u.name);u.map?(f||(f=!0,o("var ks2")),o("if(m%s&&(ks2=Object.keys(m%s)).length){",d,d)("d%s={}",d)("for(var j=0;j<ks2.length;++j){"),i(o,u,p,d+"[ks2[j]]")("}")):u.repeated?(o("if(m%s&&m%s.length){",d,d)("d%s=[]",d)("for(var j=0;j<m%s.length;++j){",d),i(o,u,p,d+"[j]")("}")):(o("if(m%s!=null&&m.hasOwnProperty(%j)){",d,u.name),i(o,u,p,d),u.partOf&&o("if(o.oneofs)")("d%s=%j",n.safeProp(u.partOf.name),u.name)),o("}")}return o("return d")}}(Yi)),Yi}var es,ts,rs,ns,os,is,ss,as,cs,ls,us,ds={};function hs(){if(ts)return es;ts=1,es=g;var e=ji();((g.prototype=Object.create(e.prototype)).constructor=g).className="Type";var t=ys(),r=Ui(),n=Bi(),o=Pi(),i=Gi(),s=Vi,a=mr,c=Xt,l=ps(),u=vs(),d=Ji(),h=Zi(),f=Qi(),p=ds;function g(t,r){e.call(this,t,r),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function y(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}return Object.defineProperties(g.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t<e.length;++t){var r=this.fields[e[t]],n=r.id;if(this._fieldsById[n])throw Error("duplicate id "+n+" in "+this);this._fieldsById[n]=r}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=l.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=l.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=g.generateConstructor(this)())},set:function(e){var t=e.prototype;t instanceof s||((e.prototype=new s).constructor=e,l.merge(e.prototype,t)),e.$type=e.prototype.$type=this,l.merge(e,s,!0),this._ctor=e;for(var r=0;r<this.fieldsArray.length;++r)this._fieldsArray[r].resolve();var n={};for(r=0;r<this.oneofsArray.length;++r)n[this._oneofsArray[r].resolve().name]={get:l.oneOfGetter(this._oneofsArray[r].oneof),set:l.oneOfSetter(this._oneofsArray[r].oneof)};r&&Object.defineProperties(e.prototype,n)}}}),g.generateConstructor=function(e){for(var t,r=l.codegen(["p"],e.name),n=0;n<e.fieldsArray.length;++n)(t=e._fieldsArray[n]).map?r("this%s={}",l.safeProp(t.name)):t.repeated&&r("this%s=[]",l.safeProp(t.name));return r("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")},g.fromJSON=function(s,a){var c=new g(s,a.options);c.extensions=a.extensions,c.reserved=a.reserved;for(var l=Object.keys(a.fields),u=0;u<l.length;++u)c.add((void 0!==a.fields[l[u]].keyType?o.fromJSON:n.fromJSON)(l[u],a.fields[l[u]]));if(a.oneofs)for(l=Object.keys(a.oneofs),u=0;u<l.length;++u)c.add(r.fromJSON(l[u],a.oneofs[l[u]]));if(a.nested)for(l=Object.keys(a.nested),u=0;u<l.length;++u){var d=a.nested[l[u]];c.add((void 0!==d.id?n.fromJSON:void 0!==d.fields?g.fromJSON:void 0!==d.values?t.fromJSON:void 0!==d.methods?i.fromJSON:e.fromJSON)(l[u],d))}return a.extensions&&a.extensions.length&&(c.extensions=a.extensions),a.reserved&&a.reserved.length&&(c.reserved=a.reserved),a.group&&(c.group=!0),a.comment&&(c.comment=a.comment),c},g.prototype.toJSON=function(t){var r=e.prototype.toJSON.call(this,t),n=!!t&&Boolean(t.keepComments);return l.toObject(["options",r&&r.options||void 0,"oneofs",e.arrayToJSON(this.oneofsArray,t),"fields",e.arrayToJSON(this.fieldsArray.filter((function(e){return!e.declaringField})),t)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",r&&r.nested||void 0,"comment",n?this.comment:void 0])},g.prototype.resolveAll=function(){for(var t=this.fieldsArray,r=0;r<t.length;)t[r++].resolve();var n=this.oneofsArray;for(r=0;r<n.length;)n[r++].resolve();return e.prototype.resolveAll.call(this)},g.prototype.get=function(e){return this.fields[e]||this.oneofs&&this.oneofs[e]||this.nested&&this.nested[e]||null},g.prototype.add=function(t){if(this.get(t.name))throw Error("duplicate name '"+t.name+"' in "+this);if(t instanceof n&&void 0===t.extend){if(this._fieldsById?this._fieldsById[t.id]:this.fieldsById[t.id])throw Error("duplicate id "+t.id+" in "+this);if(this.isReservedId(t.id))throw Error("id "+t.id+" is reserved in "+this);if(this.isReservedName(t.name))throw Error("name '"+t.name+"' is reserved in "+this);return t.parent&&t.parent.remove(t),this.fields[t.name]=t,t.message=this,t.onAdd(this),y(this)}return t instanceof r?(this.oneofs||(this.oneofs={}),this.oneofs[t.name]=t,t.onAdd(this),y(this)):e.prototype.add.call(this,t)},g.prototype.remove=function(t){if(t instanceof n&&void 0===t.extend){if(!this.fields||this.fields[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.fields[t.name],t.parent=null,t.onRemove(this),y(this)}if(t instanceof r){if(!this.oneofs||this.oneofs[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.oneofs[t.name],t.parent=null,t.onRemove(this),y(this)}return e.prototype.remove.call(this,t)},g.prototype.isReservedId=function(t){return e.isReservedId(this.reserved,t)},g.prototype.isReservedName=function(t){return e.isReservedName(this.reserved,t)},g.prototype.create=function(e){return new this.ctor(e)},g.prototype.setup=function(){for(var e=this.fullName,t=[],r=0;r<this.fieldsArray.length;++r)t.push(this._fieldsArray[r].resolve().resolvedType);this.encode=u(this)({Writer:c,types:t,util:l}),this.decode=d(this)({Reader:a,types:t,util:l}),this.verify=h(this)({types:t,util:l}),this.fromObject=f.fromObject(this)({types:t,util:l}),this.toObject=f.toObject(this)({types:t,util:l});var n=p[e];if(n){var o=Object.create(this);o.fromObject=this.fromObject,this.fromObject=n.fromObject.bind(o),o.toObject=this.toObject,this.toObject=n.toObject.bind(o)}return this},g.prototype.encode=function(e,t){return this.setup().encode(e,t)},g.prototype.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},g.prototype.decode=function(e,t){return this.setup().decode(e,t)},g.prototype.decodeDelimited=function(e){return e instanceof a||(e=a.create(e)),this.decode(e,e.uint32())},g.prototype.verify=function(e){return this.setup().verify(e)},g.prototype.fromObject=function(e){return this.setup().fromObject(e)},g.prototype.toObject=function(e,t){return this.setup().toObject(e,t)},g.d=function(e){return function(t){l.decorateType(t,e)}},es}function fs(){if(ns)return rs;ns=1,rs=c;var e=ji();((c.prototype=Object.create(e.prototype)).constructor=c).className="Root";var t,r,n,o=Bi(),i=ys(),s=Ui(),a=ps();function c(t){e.call(this,"",t),this.deferred=[],this.files=[]}function l(){}c.fromJSON=function(e,t){return t||(t=new c),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},c.prototype.resolvePath=a.path.resolve,c.prototype.fetch=a.fetch,c.prototype.load=function e(t,o,i){"function"==typeof o&&(i=o,o=void 0);var s=this;if(!i)return a.asPromise(e,s,t,o);var c=i===l;function u(e,t){if(i){var r=i;if(i=null,c)throw e;r(e,t)}}function d(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in n)return r}return null}function h(e,t){try{if(a.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),a.isString(t)){r.filename=e;var n,i=r(t,s,o),l=0;if(i.imports)for(;l<i.imports.length;++l)(n=d(i.imports[l])||s.resolvePath(e,i.imports[l]))&&f(n);if(i.weakImports)for(l=0;l<i.weakImports.length;++l)(n=d(i.weakImports[l])||s.resolvePath(e,i.weakImports[l]))&&f(n,!0)}else s.setOptions(t.options).addJSON(t.nested)}catch(e){u(e)}c||p||u(null,s)}function f(e,t){if(!(s.files.indexOf(e)>-1))if(s.files.push(e),e in n)c?h(e,n[e]):(++p,setTimeout((function(){--p,h(e,n[e])})));else if(c){var r;try{r=a.fs.readFileSync(e).toString("utf8")}catch(e){return void(t||u(e))}h(e,r)}else++p,s.fetch(e,(function(r,n){--p,i&&(r?t?p||u(null,s):u(r):h(e,n))}))}var p=0;a.isString(t)&&(t=[t]);for(var g,y=0;y<t.length;++y)(g=s.resolvePath("",t[y]))&&f(g);if(c)return s;p||u(null,s)},c.prototype.loadSync=function(e,t){if(!a.isNode)throw Error("not supported");return this.load(e,t,l)},c.prototype.resolveAll=function(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map((function(e){return"'extend "+e.extend+"' in "+e.parent.fullName})).join(", "));return e.prototype.resolveAll.call(this)};var u=/^[A-Z]/;function d(e,t){var r=t.parent.lookup(t.extend);if(r){var n=new o(t.fullName,t.id,t.type,t.rule,void 0,t.options);return n.declaringField=t,t.extensionField=n,r.add(n),!0}return!1}return c.prototype._handleAdd=function(e){if(e instanceof o)void 0===e.extend||e.extensionField||d(0,e)||this.deferred.push(e);else if(e instanceof i)u.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof s)){if(e instanceof t)for(var r=0;r<this.deferred.length;)d(0,this.deferred[r])?this.deferred.splice(r,1):++r;for(var n=0;n<e.nestedArray.length;++n)this._handleAdd(e._nestedArray[n]);u.test(e.name)&&(e.parent[e.name]=e)}},c.prototype._handleRemove=function(t){if(t instanceof o){if(void 0!==t.extend)if(t.extensionField)t.extensionField.parent.remove(t.extensionField),t.extensionField=null;else{var r=this.deferred.indexOf(t);r>-1&&this.deferred.splice(r,1)}}else if(t instanceof i)u.test(t.name)&&delete t.parent[t.name];else if(t instanceof e){for(var n=0;n<t.nestedArray.length;++n)this._handleRemove(t._nestedArray[n]);u.test(t.name)&&delete t.parent[t.name]}},c._configure=function(e,o,i){t=e,r=o,n=i},rs}function ps(){return os||(os=1,function(e){var t,r,n=fi.exports=Jt(),o=Pr;n.codegen=pi,n.fetch=yi,n.path=wi,n.fs=n.inquire("fs"),n.toArray=function(e){if(e){for(var t=Object.keys(e),r=new Array(t.length),n=0;n<t.length;)r[n]=e[t[n++]];return r}return[]},n.toObject=function(e){for(var t={},r=0;r<e.length;){var n=e[r++],o=e[r++];void 0!==o&&(t[n]=o)}return t};var i=/\\/g,s=/"/g;n.isReserved=function(e){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(e)},n.safeProp=function(e){return!/^[$\w_]+$/.test(e)||n.isReserved(e)?'["'+e.replace(i,"\\\\").replace(s,'\\"')+'"]':"."+e},n.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var a=/_([a-z])/g;n.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(a,(function(e,t){return t.toUpperCase()}))},n.compareFieldsById=function(e,t){return e.id-t.id},n.decorateType=function(e,r){if(e.$type)return r&&e.$type.name!==r&&(n.decorateRoot.remove(e.$type),e.$type.name=r,n.decorateRoot.add(e.$type)),e.$type;t||(t=hs());var o=new t(r||e.name);return n.decorateRoot.add(o),o.ctor=e,Object.defineProperty(e,"$type",{value:o,enumerable:!1}),Object.defineProperty(e.prototype,"$type",{value:o,enumerable:!1}),o};var c=0;n.decorateEnum=function(e){if(e.$type)return e.$type;r||(r=ys());var t=new r("Enum"+c++,e);return n.decorateRoot.add(t),Object.defineProperty(e,"$type",{value:t,enumerable:!1}),t},n.setProperty=function(e,t,r){if("object"!=typeof e)throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,r,n){var o=r.shift();if("__proto__"===o)return t;if(r.length>0)t[o]=e(t[o]||{},r,n);else{var i=t[o];i&&(n=[].concat(i).concat(n)),t[o]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(n,"decorateRoot",{get:function(){return o.decorated||(o.decorated=new(fs()))}})}()),fi.exports}function gs(){if(ss)return is;ss=1,is=r,r.className="ReflectionObject";var e,t=ps();function r(e,r){if(!t.isString(e))throw TypeError("name must be a string");if(r&&!t.isObject(r))throw TypeError("options must be an object");this.options=r,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(r.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),r.prototype.toJSON=function(){throw Error()},r.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var r=t.root;r instanceof e&&r._handleAdd(this)},r.prototype.onRemove=function(t){var r=t.root;r instanceof e&&r._handleRemove(this),this.parent=null,this.resolved=!1},r.prototype.resolve=function(){return this.resolved||this.root instanceof e&&(this.resolved=!0),this},r.prototype.getOption=function(e){if(this.options)return this.options[e]},r.prototype.setOption=function(e,t,r){return r&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},r.prototype.setParsedOption=function(e,r,n){this.parsedOptions||(this.parsedOptions=[]);var o=this.parsedOptions;if(n){var i=o.find((function(t){return Object.prototype.hasOwnProperty.call(t,e)}));if(i){var s=i[e];t.setProperty(s,n,r)}else(i={})[e]=t.setProperty({},n,r),o.push(i)}else{var a={};a[e]=r,o.push(a)}return this},r.prototype.setOptions=function(e,t){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)this.setOption(r[n],e[r[n]],t);return this},r.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},r._configure=function(t){e=t},is}function ys(){if(cs)return as;cs=1,as=n;var e=gs();((n.prototype=Object.create(e.prototype)).constructor=n).className="Enum";var t=ji(),r=ps();function n(t,r,n,o,i,s){if(e.call(this,t,n),r&&"object"!=typeof r)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=o,this.comments=i||{},this.valuesOptions=s,this.reserved=void 0,r)for(var a=Object.keys(r),c=0;c<a.length;++c)"number"==typeof r[a[c]]&&(this.valuesById[this.values[a[c]]=r[a[c]]]=a[c])}return n.fromJSON=function(e,t){var r=new n(e,t.values,t.options,t.comment,t.comments);return r.reserved=t.reserved,r},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",t?this.comment:void 0,"comments",t?this.comments:void 0])},n.prototype.add=function(e,t,n,o){if(!r.isString(e))throw TypeError("name must be a string");if(!r.isInteger(t))throw TypeError("id must be an integer");if(void 0!==this.values[e])throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(t))throw Error("id "+t+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(void 0!==this.valuesById[t]){if(!this.options||!this.options.allow_alias)throw Error("duplicate id "+t+" in "+this);this.values[e]=t}else this.valuesById[this.values[e]=t]=e;return o&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=o||null),this.comments[e]=n||null,this},n.prototype.remove=function(e){if(!r.isString(e))throw TypeError("name must be a string");var t=this.values[e];if(null==t)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[t],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this},n.prototype.isReservedId=function(e){return t.isReservedId(this.reserved,e)},n.prototype.isReservedName=function(e){return t.isReservedName(this.reserved,e)},as}function vs(){if(us)return ls;us=1,ls=function(o){for(var i,s=r.codegen(["m","w"],o.name+"$encode")("if(!w)")("w=Writer.create()"),a=o.fieldsArray.slice().sort(r.compareFieldsById),c=0;c<a.length;++c){var l=a[c].resolve(),u=o._fieldsArray.indexOf(l),d=l.resolvedType instanceof e?"int32":l.type,h=t.basic[d];i="m"+r.safeProp(l.name),l.map?(s("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",i,l.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",i)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(l.id<<3|2)>>>0,8|t.mapKey[l.keyType],l.keyType),void 0===h?s("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,i):s(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|h,d,i),s("}")("}")):l.repeated?(s("if(%s!=null&&%s.length){",i,i),l.packed&&void 0!==t.packed[d]?s("w.uint32(%i).fork()",(l.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",i)("w.%s(%s[i])",d,i)("w.ldelim()"):(s("for(var i=0;i<%s.length;++i)",i),void 0===h?n(s,l,u,i+"[i]"):s("w.uint32(%i).%s(%s[i])",(l.id<<3|h)>>>0,d,i)),s("}")):(l.optional&&s("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",i,l.name),void 0===h?n(s,l,u,i):s("w.uint32(%i).%s(%s)",(l.id<<3|h)>>>0,d,i))}return s("return w")};var e=ys(),t=Li(),r=ps();function n(e,t,r,n){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,n,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,n,(t.id<<3|2)>>>0)}return ls}!function(e){var t=Vi;e[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),r=this.lookup(t);if(r){var n="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===n.indexOf("/")&&(n="/"+n),this.create({type_url:n,value:r.encode(r.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,r){var n="",o="";if(r&&r.json&&e.type_url&&e.value){o=e.type_url.substring(e.type_url.lastIndexOf("/")+1),n=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var i=this.lookup(o);i&&(e=i.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof t){var s=e.$type.toObject(e,r);return""===n&&(n="type.googleapis.com/"),o=n+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),s["@type"]=o,s}return this.toObject(e,r)}}}(ds),function(e){var t=hi.exports=Nt;t.build="light",t.load=function(e,r,n){return"function"==typeof r?(n=r,r=new t.Root):r||(r=new t.Root),r.load(e,n)},t.loadSync=function(e,r){return r||(r=new t.Root),r.loadSync(e)},t.encoder=vs(),t.decoder=Ji(),t.verifier=Zi(),t.converter=Qi(),t.ReflectionObject=gs(),t.Namespace=ji(),t.Root=fs(),t.Enum=ys(),t.Type=hs(),t.Field=Bi(),t.OneOf=Ui(),t.MapField=Pi(),t.Service=Gi(),t.Method=Fi(),t.Message=Vi,t.wrappers=ds,t.types=Li(),t.util=ps(),t.ReflectionObject._configure(t.Root),t.Namespace._configure(t.Type,t.Service,t.Enum),t.Root._configure(t.Type),t.Field._configure(t.Type)}();var ms=ks,bs=/[\s{}=;:[\],'"()<>]/g,ws=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,Os=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,Cs=/^ *[*/]+ */,_s=/^\s*\*?\/*/,Ss=/\n/g,Is=/\s/,Es=/\\(.?)/g,Ts={0:"\0",r:"\r",n:"\n",t:"\t"};function Rs(e){return e.replace(Es,(function(e,t){switch(t){case"\\":case"":return t;default:return Ts[t]||""}}))}function ks(e,t){e=e.toString();var r=0,n=e.length,o=1,i=0,s={},a=[],c=null;function l(e){return Error("illegal "+e+" (line "+o+")")}function u(t){return e.charAt(t)}function d(r,n,a){var c,l={type:e.charAt(r++),lineEmpty:!1,leading:a},u=r-(t?2:3);do{if(--u<0||"\n"===(c=e.charAt(u))){l.lineEmpty=!0;break}}while(" "===c||"\t"===c);for(var d=e.substring(r,n).split(Ss),h=0;h<d.length;++h)d[h]=d[h].replace(t?_s:Cs,"").trim();l.text=d.join("\n").trim(),s[o]=l,i=o}function h(t){var r=f(t),n=e.substring(t,r);return/^\s*\/{1,2}/.test(n)}function f(e){for(var t=e;t<n&&"\n"!==u(t);)t++;return t}function p(){if(a.length>0)return a.shift();if(c)return function(){var t="'"===c?Os:ws;t.lastIndex=r-1;var n=t.exec(e);if(!n)throw l("string");return r=t.lastIndex,g(c),c=null,Rs(n[1])}();var i,s,p,y,v,m=0===r;do{if(r===n)return null;for(i=!1;Is.test(p=u(r));)if("\n"===p&&(m=!0,++o),++r===n)return null;if("/"===u(r)){if(++r===n)throw l("comment");if("/"===u(r))if(t){if(y=r,v=!1,h(r)){v=!0;do{if((r=f(r))===n)break;if(r++,!m)break}while(h(r))}else r=Math.min(n,f(r)+1);v&&(d(y,r,m),m=!0),o++,i=!0}else{for(v="/"===u(y=r+1);"\n"!==u(++r);)if(r===n)return null;++r,v&&(d(y,r-1,m),m=!0),++o,i=!0}else{if("*"!==(p=u(r)))return"/";y=r+1,v=t||"*"===u(y);do{if("\n"===p&&++o,++r===n)throw l("comment");s=p,p=u(r)}while("*"!==s||"/"!==p);++r,v&&(d(y,r-2,m),m=!0),i=!0}}}while(i);var b=r;if(bs.lastIndex=0,!bs.test(u(b++)))for(;b<n&&!bs.test(u(b));)++b;var w=e.substring(r,r=b);return'"'!==w&&"'"!==w||(c=w),w}function g(e){a.push(e)}function y(){if(!a.length){var e=p();if(null===e)return null;g(e)}return a[0]}return Object.defineProperty({next:p,peek:y,push:g,skip:function(e,t){var r=y();if(r===e)return p(),!0;if(!t)throw l("token '"+r+"', '"+e+"' expected");return!1},cmnt:function(e){var r,n=null;return void 0===e?(r=s[o-1],delete s[o-1],r&&(t||"*"===r.type||r.lineEmpty)&&(n=r.leading?r.text:null)):(i<e&&y(),r=s[e],delete s[e],!r||r.lineEmpty||!t&&"/"!==r.type||(n=r.leading?null:r.text)),n}},"line",{get:function(){return o}})}ks.unescape=Rs;var As=Ys;Ys.filename=null,Ys.defaults={keepCase:!1};var Ns=ms,xs=fs(),Ds=hs(),Ms=Bi(),Ls=Pi(),Bs=Ui(),Us=ys(),js=Gi(),Ps=Fi(),Fs=Li(),Gs=ps(),qs=/^[1-9][0-9]*$/,Hs=/^-?[1-9][0-9]*$/,zs=/^0[x][0-9a-fA-F]+$/,Ks=/^-?0[x][0-9a-fA-F]+$/,Vs=/^0[0-7]+$/,Ws=/^-?0[0-7]+$/,$s=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,Js=/^[a-zA-Z_][a-zA-Z_0-9]*$/,Zs=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,Xs=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function Ys(e,t,r){t instanceof xs||(r=t,t=new xs),r||(r=Ys.defaults);var n,o,i,s,a,c=r.preferTrailingComment||!1,l=Ns(e,r.alternateCommentMode||!1),u=l.next,d=l.push,h=l.peek,f=l.skip,p=l.cmnt,g=!0,y=!1,v=t,m=r.keepCase?function(e){return e}:Gs.camelCase;function b(e,t,r){var n=Ys.filename;return r||(Ys.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(n?n+", ":"")+"line "+l.line+")")}function w(){var e,t=[];do{if('"'!==(e=u())&&"'"!==e)throw b(e);t.push(u()),f(e),e=h()}while('"'===e||"'"===e);return t.join("")}function O(e){var t=u();switch(t){case"'":case'"':return d(t),w();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var r=1;"-"===e.charAt(0)&&(r=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return r*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(qs.test(e))return r*parseInt(e,10);if(zs.test(e))return r*parseInt(e,16);if(Vs.test(e))return r*parseInt(e,8);if($s.test(e))return r*parseFloat(e);throw b(e,"number",t)}(t,!0)}catch(r){if(e&&Zs.test(t))return t;throw b(t,"value")}}function C(e,t){var r,n;do{!t||'"'!==(r=h())&&"'"!==r?e.push([n=_(u()),f("to",!0)?_(u()):n]):e.push(w())}while(f(",",!0));f(";")}function _(e,t){switch(e){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!t&&"-"===e.charAt(0))throw b(e,"id");if(Hs.test(e))return parseInt(e,10);if(Ks.test(e))return parseInt(e,16);if(Ws.test(e))return parseInt(e,8);throw b(e,"id")}function S(){if(void 0!==n)throw b("package");if(n=u(),!Zs.test(n))throw b(n,"name");v=v.define(n),f(";")}function I(){var e,t=h();switch(t){case"weak":e=i||(i=[]),u();break;case"public":u();default:e=o||(o=[])}t=w(),f(";"),e.push(t)}function E(){if(f("="),s=w(),!(y="proto3"===s)&&"proto2"!==s)throw b(s,"syntax");f(";")}function T(e,t){switch(t){case"option":return x(e,t),f(";"),!0;case"message":return k(e,t),!0;case"enum":return N(e,t),!0;case"service":return function(e,t){if(!Js.test(t=u()))throw b(t,"service name");var r=new js(t);R(r,(function(e){if(!T(r,e)){if("rpc"!==e)throw b(e);!function(e,t){var r=p(),n=t;if(!Js.test(t=u()))throw b(t,"name");var o,i,s,a,c=t;f("("),f("stream",!0)&&(i=!0);if(!Zs.test(t=u()))throw b(t);o=t,f(")"),f("returns"),f("("),f("stream",!0)&&(a=!0);if(!Zs.test(t=u()))throw b(t);s=t,f(")");var l=new Ps(c,n,o,s,i,a);l.comment=r,R(l,(function(e){if("option"!==e)throw b(e);x(l,e),f(";")})),e.add(l)}(r,e)}})),e.add(r)}(e,t),!0;case"extend":return function(e,t){if(!Zs.test(t=u()))throw b(t,"reference");var r=t;R(null,(function(t){switch(t){case"required":case"repeated":A(e,t,r);break;case"optional":A(e,y?"proto3_optional":"optional",r);break;default:if(!y||!Zs.test(t))throw b(t);d(t),A(e,"optional",r)}}))}(e,t),!0}return!1}function R(e,t,r){var n=l.line;if(e&&("string"!=typeof e.comment&&(e.comment=p()),e.filename=Ys.filename),f("{",!0)){for(var o;"}"!==(o=u());)t(o);f(";",!0)}else r&&r(),f(";"),e&&("string"!=typeof e.comment||c)&&(e.comment=p(n)||e.comment)}function k(e,t){if(!Js.test(t=u()))throw b(t,"type name");var r=new Ds(t);R(r,(function(e){if(!T(r,e))switch(e){case"map":!function(e){f("<");var t=u();if(void 0===Fs.mapKey[t])throw b(t,"type");f(",");var r=u();if(!Zs.test(r))throw b(r,"type");f(">");var n=u();if(!Js.test(n))throw b(n,"name");f("=");var o=new Ls(m(n),_(u()),t,r);R(o,(function(e){if("option"!==e)throw b(e);x(o,e),f(";")}),(function(){L(o)})),e.add(o)}(r);break;case"required":case"repeated":A(r,e);break;case"optional":A(r,y?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!Js.test(t=u()))throw b(t,"name");var r=new Bs(m(t));R(r,(function(e){"option"===e?(x(r,e),f(";")):(d(e),A(r,"optional"))})),e.add(r)}(r,e);break;case"extensions":C(r.extensions||(r.extensions=[]));break;case"reserved":C(r.reserved||(r.reserved=[]),!0);break;default:if(!y||!Zs.test(e))throw b(e);d(e),A(r,"optional")}})),e.add(r)}function A(e,t,r){var n=u();if("group"!==n){if(!Zs.test(n))throw b(n,"type");var o=u();if(!Js.test(o))throw b(o,"name");o=m(o),f("=");var i=new Ms(o,_(u()),n,t,r);if(R(i,(function(e){if("option"!==e)throw b(e);x(i,e),f(";")}),(function(){L(i)})),"proto3_optional"===t){var s=new Bs("_"+o);i.setOption("proto3_optional",!0),s.add(i),e.add(s)}else e.add(i);y||!i.repeated||void 0===Fs.packed[n]&&void 0!==Fs.basic[n]||i.setOption("packed",!1,!0)}else!function(e,t){var r=u();if(!Js.test(r))throw b(r,"name");var n=Gs.lcFirst(r);r===n&&(r=Gs.ucFirst(r));f("=");var o=_(u()),i=new Ds(r);i.group=!0;var s=new Ms(n,o,r,t);s.filename=Ys.filename,R(i,(function(e){switch(e){case"option":x(i,e),f(";");break;case"required":case"repeated":A(i,e);break;case"optional":A(i,y?"proto3_optional":"optional");break;case"message":k(i,e);break;case"enum":N(i,e);break;default:throw b(e)}})),e.add(i).add(s)}(e,t)}function N(e,t){if(!Js.test(t=u()))throw b(t,"name");var r=new Us(t);R(r,(function(e){switch(e){case"option":x(r,e),f(";");break;case"reserved":C(r.reserved||(r.reserved=[]),!0);break;default:!function(e,t){if(!Js.test(t))throw b(t,"name");f("=");var r=_(u(),!0),n={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};R(n,(function(e){if("option"!==e)throw b(e);x(n,e),f(";")}),(function(){L(n)})),e.add(t,r,n.comment,n.options)}(r,e)}})),e.add(r)}function x(e,t){var r=f("(",!0);if(!Zs.test(t=u()))throw b(t,"name");var n,o=t,i=o;r&&(f(")"),i=o="("+o+")",t=h(),Xs.test(t)&&(n=t.slice(1),o+=t,u())),f("="),function(e,t,r,n){e.setParsedOption&&e.setParsedOption(t,r,n)}(e,i,D(e,o),n)}function D(e,t){if(f("{",!0)){for(var r={};!f("}",!0);){if(!Js.test(a=u()))throw b(a,"name");var n,o=a;if(f(":",!0),"{"===h())n=D(e,t+"."+a);else if("["===h()){var i;if(n=[],f("[",!0)){do{i=O(!0),n.push(i)}while(f(",",!0));f("]"),void 0!==i&&M(e,t+"."+a,i)}}else n=O(!0),M(e,t+"."+a,n);var s=r[o];s&&(n=[].concat(s).concat(n)),r[o]=n,f(",",!0),f(";",!0)}return r}var c=O(!0);return M(e,t,c),c}function M(e,t,r){e.setOption&&e.setOption(t,r)}function L(e){if(f("[",!0)){do{x(e,"option")}while(f(",",!0));f("]")}return e}for(;null!==(a=u());)switch(a){case"package":if(!g)throw b(a);S();break;case"import":if(!g)throw b(a);I();break;case"syntax":if(!g)throw b(a);E();break;case"option":x(v,a),f(";");break;default:if(T(v,a)){g=!1;continue}throw b(a)}return Ys.filename=null,{package:n,imports:o,weakImports:i,syntax:s,root:t}}var Qs,ea=ra,ta=/\/|\./;function ra(e,t){ta.test(e)||(e="google/protobuf/"+e+".proto",t={nested:{google:{nested:{protobuf:{nested:t}}}}}),ra[e]=t}ra("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),ra("duration",{Duration:Qs={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),ra("timestamp",{Timestamp:Qs}),ra("empty",{Empty:{fields:{}}}),ra("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),ra("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),ra("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),ra.get=function(e){return ra[e]||null},function(e){var t=di.exports=hi.exports;t.build="full",t.tokenize=ms,t.parse=As,t.common=ea,t.Root._configure(t.Type,t.parse,t.common)}();var na=F(ui.exports=di.exports);const oa=e=>{const t=window.URL||window.webkitURL;return t?t.createObjectURL(e):""},ia=e=>{const t=e.name;return O(t)?t.substring(t.lastIndexOf(".")+1):e.type.indexOf("/")>0?e.type.substring(e.type.lastIndexOf("/")+1):""},sa=e=>{(window.URL||window.webkitURL).revokeObjectURL(e)},aa=e=>{const t=e.match(/data:([^;]+)/)[1],r=e.replace(/^[^,]+,/,""),n=window.atob(r);let o=n.length;const i=new Uint8Array(n.length);for(;o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:t})};class ca{constructor(e){d(this,"options",void 0),d(this,"xhr",void 0),this.options=e}upload(e,t){const r=new XMLHttpRequest;r.open("POST",this.options.uploadUrl,!0),r.onreadystatechange=()=>{if(4===r.readyState){const o=r.responseText||"{}",i=JSON.parse(o);if(200===r.status&&200===i.code){var e;let r={url:i.url};this.options.transformer&&(r=this.options.transformer(r)),null===(e=t.onCompleted)||void 0===e||e.call(t,r)}else{var n;null===(n=t.onError)||void 0===n||n.call(t,"upload fail")}}},r.setRequestHeader("device","7"),r.setRequestHeader("cert",this.options.cert??"");const n=ia(e),o=function(){let e=(new Date).getTime();return"xxxxxx4xxxyxxxxxxx".replace(/[xy]/g,(function(t){const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)}))}()+(n.length?`.${n}`:""),i=new FormData;i.append("file",e),i.append("name","file"),i.append("fileName",o),i.append("token",this.options.token),r.send(i),this.xhr=r}cancel(){var e;null===(e=this.xhr)||void 0===e||e.abort()}}const la=e=>new Promise(((t,r)=>{const n=e=>{0!==e.width||0!==e.height?t(e):r()},o=new Image;if(o.addEventListener("load",(e=>n(e.target))),o.addEventListener("error",r),o.src=e,o.complete)return void n(o);const i=setInterval((()=>{o.complete&&(n(o),clearInterval(i))}),40)}));class ua{constructor(e,t){d(this,"uploadInstance",void 0),d(this,"options",void 0),this.uploadInstance=e,this.options=t}async upload(e,t){try{const r=oa(e),n=await la(r);sa(r);const{imageFile:o,compressWidth:i,compressHeight:s}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image/jpeg";t=Math.min(1,t);const n=e.width,o=e.height;let i=n,s=o;if(t<1){const e=n<o,t=e?o/1680:n/1680;n>1680&&o>1680?e?(s=1680,i/=t):(i=1680,s/=t):n>1680&&o>160?(i=1680,s/=t,s<160&&(s=160,i=n/(o/160))):o>1680&&n>160&&(s=1680,i/=t,i<160&&(i=160,s=o/(n/160)))}i=Math.floor(i),s=Math.floor(s);const a=document.createElement("canvas");a.width=i,a.height=s;const c=a.getContext("2d");return c.fillStyle="#FFF",c.fillRect(0,0,i,s),c.drawImage(e,0,0,n,o,0,0,i,s),r&&"image/png"!=r||(r="image/jpeg"),{imageFile:aa(a.toDataURL(r,Math.min(.92,t))),compressWidth:i,compressHeight:s}}(n,.85,e.type),a=((e,t)=>{const r=document.createElement("canvas"),n=r.getContext("2d"),o=function(e,t,r){const n=e<t;let o,i,s,a=0,c=0;const l=function(){return n?(o=e/100,i=100,s=t/o,c=(s-r.maxHeight)/2):(o=t/100,s=100,i=e/o,a=(i-r.maxWidth)/2),{w:i,h:s,x:-a,y:-c}},u=function(){return n?(o=t/r.maxHeight,s=r.maxHeight,i=e/o):(o=e/r.maxWidth,i=r.maxWidth,s=t/o),{w:i,h:s,x:-a,y:-c}};return(n?t/e:e/t)>r.scale?l():u()}(e.width,e.height,t);r.width=o.w>t.maxWidth?t.maxWidth:o.w,r.height=o.h>t.maxHeight?t.maxHeight:o.h,null==n||n.drawImage(e,o.x,o.y,o.w,o.h);try{let e=r.toDataURL("image/jpeg",t.quality);const n=new RegExp("^data:image/[^;]+;base64,");return e=e.replace(n,""),e}catch(e){throw new Error(e)}})(n,{maxHeight:160,maxWidth:160,quality:.6,scale:2.4});this.uploadInstance.upload(o,{...t,onCompleted:r=>{var n;null===(n=t.onCompleted)||void 0===n||n.call(t,{url:r.url,thumbnail:a,width:i,height:s,type:e.type})}})}catch(e){var r;null===(r=t.onError)||void 0===r||r.call(t,"MEDIA_EXCEPTION")}}cancel(){this.uploadInstance.cancel()}}class da{constructor(e){d(this,"uploadInstance",void 0),this.uploadInstance=e}async upload(e,t){if(e.size>2097152)t.onError&&t.onError("GIF_MSG_SIZE_LIMIT_EXCEED");else try{const r=oa(e),n=await la(r);sa(r),this.uploadInstance.upload(e,{...t,onCompleted:r=>{var o;null===(o=t.onCompleted)||void 0===o||o.call(t,{url:r.url,size:e.size,width:n.width,height:n.height})}})}catch(e){var r;null===(r=t.onError)||void 0===r||r.call(t,"MEDIA_EXCEPTION")}}cancel(){this.uploadInstance.cancel()}}let ha;class fa{constructor(e){d(this,"uploadInstance",void 0),this.uploadInstance=e}upload(e,t){var r;(r=e,_(r.arrayBuffer)?r.arrayBuffer():new Promise(((e,t)=>{const n=new FileReader;n.addEventListener("load",(r=>{r.target?e(r.target.result):t("null")})),n.addEventListener("error",(e=>t(e))),n.readAsArrayBuffer(r)}))).then(this.getAudioInfo).then((r=>{this.uploadInstance.upload(e,{...t,onCompleted:n=>{var o;null===(o=t.onCompleted)||void 0===o||o.call(t,{url:n.url,type:ia(e),...r})}})})).catch((()=>{var e;null===(e=t.onError)||void 0===e||e.call(t,"MEDIA_EXCEPTION")}))}cancel(){this.uploadInstance.cancel()}getAudioInfo(e){const t=ha||new AudioContext;return ha=t,new Promise(((r,n)=>{t.decodeAudioData(e,(function(e){r({duration:e.duration,length:e.length})}),n)}))}}class pa{constructor(e){d(this,"uploadInstance",void 0),this.uploadInstance=e}upload(e,t){if(e.size>104857600)t.onError&&t.onError("FILE_MSG_SIZE_LIMIT_EXCEED");else try{this.uploadInstance.upload(e,{...t,onCompleted:r=>{var n;null===(n=t.onCompleted)||void 0===n||n.call(t,{url:r.url,name:e.name,type:ia(e),size:e.size})}})}catch(e){var r;null===(r=t.onError)||void 0===r||r.call(t,"MEDIA_EXCEPTION")}}cancel(){this.uploadInstance.cancel()}}var ga;!function(e){e[e.IMAGE=1]="IMAGE",e[e.GIF=2]="GIF",e[e.AUDIO=3]="AUDIO",e[e.VIDEO=4]="VIDEO",e[e.FILE=5]="FILE",e[e.SIGHT=6]="SIGHT"}(ga||(ga={}));const ya=(e,t,r,n,o,i)=>({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId,senderUserId:t,messageDirection:s.SEND,isCounted:r.isCounted,isMentioned:!1,content:r.content,messageType:r.messageType,isOffLineMessage:!1,isPersited:r.isPersited,messageId:n,messageUId:o,sentTime:i,receivedTime:0,isStatusMessage:r.isStatusMessage,receivedStatus:a.UNREAD,disableNotification:!1});let va=0;const ma=[To,Io];async function ba(r,i,s){var a;if(!li.loader||li.loader.getConnectionStatus()!==e.CONNECTED)return{code:t.RC_NET_CHANNEL_INVALID};s=s||{};const c=JSON.stringify(_t(i.encode()));if(function(e){let t=0;if("utf-16"===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf-8"))for(let r=0,n=e.length;r<n;r++)t+=e.charCodeAt(r)<=65535?2:4;else for(let r=0,n=e.length;r<n;r++){const n=e.charCodeAt(r);t+=n<127?1:n<=2047?2:n<=65535?3:4}return t}(c)>81920)return{code:t.RC_MSG_CONTENT_EXCEED_LIMIT};const l=Pn(r);let u;u=f(null===(a=s)||void 0===a?void 0:a.messageId)&&s.messageId>0?s.messageId:function(){va++;const e=oo();return va<e&&(va=e),23e13+va}(),so.addMessage(u);const d=ya(r,xn.uid,i,u,"",function(){Ta++;const e=oo();Ta<e&&(Ta=e);return Ta}());s.onSendBefore&&s.onSendBefore(d),i.isPersited&&ai.get().loadConvsationsIfNotExist([r]);const h=await Ho.getDialogAesKey(l);if(!h)return{code:t.MSG_ENCRYPT_ERROR,data:d};const p=((e,t)=>{if(!O(e))return new Uint8Array;const r=Ot.AES.encrypt(e,Ot.enc.Utf8.parse(t.key),{iv:f(t.iv)?Ot.enc.Utf8.parse(t.iv):void 0});return Wo(r.ciphertext.words)})(c,h),g={localId:tn.fromNumber(u),mediaFlag:ma.includes(i.messageType),mediaConstructor:i.objectId,mediaAttribute:"",msgPreContent:"",msgPostContent:"",msgContent:p};let y;if(r.conversationType===n.GROUP){var v,m;const e={...g,groupId:l};if(null!==(v=s)&&void 0!==v&&null!==(m=v.directionalUserIdList)&&void 0!==m&&m.length&&(e.assign=s.directionalUserIdList.join(",")),f(i.content.mentionedInfo)){var b;const t=i.content.mentionedInfo;t.type===o.ALL?e.atAll=!0:t.type===o.SINGAL&&null!==(b=t.userIdList)&&void 0!==b&&b.length&&(e.at=t.userIdList.map((e=>tn.fromString(e))))}y=await(w=e,Nn.send(j.SendGroupChatMessage,w,{encoder:Xn.SendGroupChatMessageReq,decoder:to}))}else{const e={...g,destId:l};y=await(e=>Nn.send(j.SendPrivateChatMessage,e,{encoder:Vn.SendPrivateChatMessageReq,decoder:Un.SendPrivateChatMessageResp}))(e)}var w;return y.code===t.SUCCESS&&(d.sentTime=y.data.seqno.toNumber(),d.messageUId=y.data.msgId.toString(),ai.get().setConversationCacheByMessage(d)),{code:y.code,data:d}}const wa=Ia(ga.IMAGE,((e,t)=>new xo({content:e.thumbnail,imageUri:e.url,width:e.width,height:e.height,user:t.user,extra:t.extra}))),Oa=Ia(ga.GIF,((e,t)=>new Do({gifDataSize:e.size,remoteUrl:e.url,width:e.width,height:e.height,user:t.user,extra:t.extra}))),Ca=Ia(ga.AUDIO,((e,t)=>new Mo({remoteUrl:e.url,duration:e.duration,type:e.type,user:t.user,extra:t.extra}))),_a=Ia(ga.FILE,((e,t)=>new Lo({fileUrl:e.url,name:e.name,type:e.type,size:e.size,user:t.user,extra:t.extra}))),Sa=async(e,r)=>{const n=Pn(e);co.addMessage(r.messageUId);const o=await((e,t)=>{let r;return r=Gn(e)?Nn.send(j.RecallGroupMessage,{groupId:e,msgId:tn.fromString(t)},{encoder:Xn.RecallGroupChatMessageReq,decoder:Zr.BaseResp}):Nn.send(j.RecallPrivateMessage,{destId:e,msgId:tn.fromString(t)},{encoder:Vn.RecallPrivateChatMessageReq,decoder:Zr.BaseResp}),r})(n,r.messageUId);if(o.code!==t.SUCCESS)return{code:o.code};const i=new Bo({sentTime:r.sentTime,messageUId:r.messageUId,...e}),s=ya(e,xn.uid,i,0,"",oo());return ai.get().setConversationCacheByMessage(s),{code:t.SUCCESS,data:s}};function Ia(e,r){return function(n,o,i,s){return new Promise((a=>{((e,t,r,n)=>{var o;const i=new ca({token:jn.imInitToken,uploadUrl:jn.fileUploadUrl,cert:jn.cert,transformer:e=>({...e,url:jn.getFileAbsoluteUri(e.url)})});let s;switch(t){case ga.IMAGE:s=new ua(i,r);break;case ga.GIF:s=new da(i);break;case ga.AUDIO:s=new fa(i);break;case ga.FILE:s=new pa(i)}null===(o=s)||void 0===o||o.upload(e,{onProgress:(e,t)=>n.onProgress(Math.floor(e/t*100)),onError:()=>n.onFail(),onCompleted:n.onSuccess})})(o.file,e,s,{onProgress:e=>(null==i?void 0:i.onProgress)&&i.onProgress(e),onSuccess:e=>{const t=(null==i?void 0:i.onComplete)&&i.onComplete({url:jn.getFileAbsoluteUri(e.url)})||r(e,o);ba(n,t,s).then(a)},onFail:()=>{a({code:t.UPLOAD_FILE_FAILED})}})}))}}let Ea,Ta=1;class Ra extends B{constructor(e){if(Ra.imClient)return E.error("Please do not perform the init method repeatedly"),Ra.imClient;super(),d(this,"options",void 0),d(this,"libLoader",void 0),d(this,"getServerTime",oo),d(this,"sendMessage",ba),d(this,"sendImageMessage",wa),d(this,"sendGIFMessage",Oa),d(this,"sendHQVoiceMessage",Ca),d(this,"sendFileMessage",_a),d(this,"recallMsg",Sa),this.options=e,this.fixedProtobuf(),f(e.logLevel)&&E.setLogLevel(e.logLevel),f(e.logStdout)&&E.setLogStdout(e.logStdout),E.debug("IMClient.init -> ",e.appkey),this.libLoader=li.init(e),this.watch(),Ra.imClient=this}fixedProtobuf(){na.util.Long=tn,na.configure()}watch(){this.libLoader.assignWatcher({onConnecting:()=>{this.emit(u.CONNECTING)},onConnected:()=>{this.emit(u.CONNECTED)},onDisconnect:()=>{this.emit(u.DISCONNECT,this.libLoader.getConnectionStatus())},onSuspend:()=>{this.emit(u.SUSPEND,this.libLoader.getConnectionStatus())},batchMessage:e=>{this.emit(u.MESSAGES,{messages:e})},pullFinished:()=>{this.emit(u.PULL_OFFLINE_MESSAGE_FINISHED)},conversationState:e=>{this.emit(u.CONVERSATION,{conversations:e})}})}connect(e){return this.libLoader.connect(e)}disconnect(){return this.libLoader.disconnect()}getConnectionStatus(){return this.libLoader.getConnectionStatus()}async getRemoteHistoryMessages(e,n){const o=Pn(e);return(e=>{const t={dialogKeys:e.dialogId,newToOld:e.newToOld,rows:e.count};return e.newToOld?t.offset=tn.fromNumber(e.offset):t.oldOffset=tn.fromNumber(e.offset),Nn.send(e.dialogId.startsWith("SG")?j.GetSuperGroupRemoteMessages:j.GetRemoteMessages,t,{encoder:Vn.GetHistoryMessageReq,decoder:Un.GetHistoryMessageResp})})({dialogId:o,offset:n.timestamp??0,count:n.count??20,newToOld:0===n.order}).then((e=>{let{code:n,data:i}=e;return new Promise((e=>{n===t.SUCCESS?Yo.parse({[o]:i.msg??{}},((r,n)=>{const s=n[o]??[];s.sort(((e,t)=>e.sentTime-t.sentTime)),e({code:t.SUCCESS,data:{list:s,hasMore:!i.isEnd}})})):e({code:n,msg:r(n)})}))}))}async deleteRemoteMessage(e,t){return(r=Pn(e),n=t.map((e=>e.messageUId)),Nn.send(j.DeleteChatMessages,{destId:r,msgIdList:n.map((e=>tn.fromString(e)))},{encoder:Vn.DeleteChatMessageReq,decoder:Zr.BaseResp})).then((e=>e.code));var r,n}async deleteRemoteMessageByTimestamp(e,t){return((e,t)=>Nn.send(j.ClearChatHistoryMessage,{destId:e,type:Gn(e)?1:0,msgTime:tn.fromNumber(t)},{encoder:Vn.CleanHistoryMessageReq,decoder:Zr.BaseResp}))(Pn(e),0===t?Number.MAX_VALUE:t).then((e=>e.code))}async getConversationList(e,r,n,o){const i={rows:e,type:r??0,offset:tn.fromNumber(n),newToOld:0===o},{code:s,data:a}=await(e=>Nn.send(j.GetDialogList,e,{encoder:Vn.GetWebDialogListReq,decoder:Un.GetWebDialogListResp}))(i);if(console.log("getConversationList",i,a),s!==t.SUCCESS)return{code:s};const c=a.fullDialog.map((e=>{var t;return null===(t=e.dialog)||void 0===t?void 0:t.destId})).filter(O);await Ho.getDialogAesKeyList(c);const l=[];for(const e of a.fullDialog){const t=this.formatConversation(e);if(t){const e={conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId};ai.get().addLocalConversation(t);const r=ai.get().get(e);Object.assign(t,r),l.push(t)}}return{code:t.SUCCESS,data:l}}getBlockConversationList(){const e=ai.get().getBlockConversationList();return Promise.resolve({code:t.SUCCESS,data:e})}getTopConversationList(){const e=ai.get().getTopConversationList();return Promise.resolve({code:t.SUCCESS,data:e})}async getConversation(e){const r=ai.get().get(e);if(!r)return{code:t.CONVER_GET_ERROR};const{code:n,data:o}=await this.getRemoteHistoryMessages(e,{count:1,order:0});if(n!==t.SUCCESS)return{code:t.CONVER_GET_ERROR};const i=null==o?void 0:o.list[0],s={...e,...r,latestMessage:i};return{code:t.SUCCESS,data:s}}removeConversation(e){return(e=>{let t;return t=Gn(e)?Nn.send(j.DeleteGroupDialog,{groupId:e},{encoder:Xn.DeleteGroupChatDialogReq,decoder:Zr.BaseResp}):Nn.send(j.DeletePrivateDialog,{destId:e},{encoder:Vn.DeletePrivateChatDialogReq,decoder:Zr.BaseResp}),t})(Pn(e)).then((e=>e.code))}getUnreadMentionedCount(e){return ai.get().getUnreadMentionedCount(e)}getAllUnreadMentionedCount(){return ai.get().getAllUnreadMentionedCount()}getAllConversationState(){return ai.get().getAllConversationState()}getAllConversationUnreadCount(e,t){return ai.get().getAllUnreadCount(e,t)}getConversationUnreadCount(e){return ai.get().getUnreadCount(e)}clearConversationUnreadCount(e){ai.get().clearUnreadCount(e)}clearAllConversationsUnreadCount(){ai.get().clearAllUnreadCount()}getConversationNotificationLevel(e){return ai.get().getNotificationLevel(e)}setConversationNotificationStatus(e,t){return((e,t)=>{let r;return r=Gn(e)?Nn.send(j.UpdateGroupChatMuteConfig,{groupId:e,muteFlag:t},{encoder:Xn.UpdateGroupChatDialogMuteConfigReq,decoder:Zr.BaseResp}):Nn.send(j.UpdatePrivateChatMuteConfig,{destId:e,muteFlag:t},{encoder:Vn.UpdatePrivateChatDialogMuteConfigReq,decoder:Zr.BaseResp}),r})(Pn(e),t===i.OPEN).then((r=>(!r.code&&ai.get().addStatus({...e,notificationStatus:t,notificationLevel:t==i.OPEN?c.AT_USER_NOTIFICATION:c.NOT_SET},!0),r.code)))}getConversationNotificationStatus(e){return ai.get().getNotificationStatus(e)}setConversationToTop(e,t){return((e,t)=>{let r;return r=Gn(e)?Nn.send(j.UpdateGroupChatStickyConfig,{groupId:e,stickyFlag:t},{encoder:Xn.UpdateGroupChatDialogStickyConfigReq,decoder:Zr.BaseResp}):Nn.send(j.UpdatePrivateChatStickyConfig,{destId:e,stickyFlag:t},{encoder:Vn.UpdatePrivateChatDialogStickyConfigReq,decoder:Zr.BaseResp}),r})(Pn(e),t).then((r=>(!r.code&&ai.get().addStatus({...e,isTop:t},!0),r.code)))}saveConversationMessageDraft(e,t){ai.get().setDraft(e,t)}getConversationMessageDraft(e){return ai.get().getDraft(e)}clearConversationMessageDraft(e){ai.get().clearDraft(e)}formatConversation(e){const{dialog:t,msg:r}=e,n=t.destId??"",o=ri(t);if(!o)return;const i=Ho.getDialogAesKeyFromLocal(n);if(!i)return;const s=Yo.parseSingleDialogMessages(n,[r],i)[0];return s?(o.latestMessage=s,o):void 0}}d(Ra,"imClient",void 0);const ka=e=>{Ea=Ea||new Ra(e)},Aa=async e=>{M("token",e,T,!0);const n=await Ea.connect(e);return n.code===t.SUCCESS?{code:n.code,data:{userId:n.userId}}:{code:n.code,msg:r(n.code)}},Na=()=>Ea.disconnect(),xa=()=>Ea.getConnectionStatus(),Da=()=>Ea.getServerTime(),Ma=(e,t,r)=>{Ea.on(e,t,r)};function La(e,t,r){Ea.once(e,t,r)}const Ba=(e,t,r)=>{Ea.off(e,t,r)},Ua=async e=>{E.debug("get conversation list ->");const{code:n,data:o}=await Ea.getConversationList((null==e?void 0:e.count)??20,null,(null==e?void 0:e.startTime)??0,(null==e?void 0:e.order)??0);return n!==t.SUCCESS&&E.warn("get conversation list fail ->"+n+":"+r(n)),{code:n,msg:r(n),data:o}},ja=async e=>{M("options",e,x,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get conversation ->"+n);const{code:o,data:i}=await Ea.getConversation(e);return o!==t.SUCCESS?(E.warn("get conversation fail ->"+o+":"+r(o)+","+n),{code:o,msg:r(o)}):{code:o,data:i}},Pa=async e=>{M("options",e,x,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("remove conversation ->"+n);const o=await Ea.removeConversation(e);return o!==t.SUCCESS?(E.warn("remove conversation fail ->"+o+":"+r(o)+","+n),{code:o,msg:r(o)}):{code:o}},Fa=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get draft ->"+r);const n=Ea.getConversationMessageDraft(e);return Promise.resolve({code:t.SUCCESS,data:n})},Ga=(e,r)=>{M("options",e,x,!0),M("draft",r,T,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;return E.debug("set draft ->"+n),Ea.saveConversationMessageDraft(e,r),Promise.resolve({code:t.SUCCESS})},qa=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;return E.debug("delete draft ->"+r),Ea.clearConversationMessageDraft(e),Promise.resolve({code:t.SUCCESS})},Ha=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;return E.debug("get unreadMentionedCount ->"+r),Promise.resolve({code:t.SUCCESS,data:Ea.getUnreadMentionedCount(e)})},za=()=>{E.debug("getAllUnreadMentionedCount");const e=Ea.getAllUnreadMentionedCount();return Promise.resolve({code:t.SUCCESS,data:e})},Ka=()=>{E.debug("getAllConversationState");const e=Ea.getAllConversationState();return Promise.resolve({code:t.SUCCESS,data:e})},Va=(e,r)=>{if(E.debug("get total unread count -> ConversationType:"+JSON.stringify(r)+" includeMuted:"+e),M("includeMuted",e,k,!1),M("conversationTypes",r,A,!1),r)for(const e of r)M("conversationType",e,N,!0);const n=Ea.getAllConversationUnreadCount(r??[],e??!1);return Promise.resolve({code:t.SUCCESS,data:n})},Wa=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get unreadCount ->"+r);const n=Ea.getConversationUnreadCount(e);return Promise.resolve({code:t.SUCCESS,data:n})},$a=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;return E.debug("clear unreadMsgNum ->"+r),Ea.clearConversationUnreadCount(e),Promise.resolve({code:t.SUCCESS})},Ja=()=>(E.debug("clear allMessagesUnreadStatus"),Ea.clearAllConversationsUnreadCount(),Promise.resolve({code:t.SUCCESS})),Za=e=>{M("options",e,x,!0),E.info("getConversationNotificationLevel ->targetId:"+e.targetId+",conversationType:"+e.conversationType);const r=Ea.getConversationNotificationLevel(e);return Promise.resolve({code:t.SUCCESS,data:r})},Xa=async(e,n)=>{M("options",e,x,!0),M("notificationStatus",n,(e=>1===e||2===e),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("set conversation status ->"+o);const i=await Ea.setConversationNotificationStatus(e,n);return i!==t.SUCCESS?(E.warn("set conversation status fail ->"+i+":"+r(i)+","+o),{code:i,msg:r(i)}):{code:i}},Ya=e=>{M("options",e,x,!0),E.info("getConversationNotificationStatus ->targetId:"+e.targetId+",conversationType:"+e.conversationType);const r=Ea.getConversationNotificationStatus(e);return Promise.resolve({code:t.SUCCESS,data:r})},Qa=()=>Ea.getBlockConversationList(),ec=async function(e){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];M("options",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("set conversation status ->"+o);const i=await Ea.setConversationToTop(e,n);return i!==t.SUCCESS?(E.warn("set conversation status fail ->"+i+":"+r(i)+","+o),{code:i,msg:r(i)}):{code:i}},tc=()=>Ea.getTopConversationList(),rc=(e,t,r,n,o)=>function(n){return o?new qo(e,n):r?new Go(e,n):t?new Fo(e,n):new Po(e,n)},nc=async(e,r,n)=>{if(r instanceof ho==!1)return E.warn("send message fail -> message parameter is not an instance of BaseMessage"),{code:t.PARAMETER_ERROR};M("conversation",e,x,!0),pc(e);const o=await Ea.sendMessage(e,r,n);return gc(e,o.code),o},oc=(e,t,r)=>{const n=new No(t);return nc(e,n,r)},ic=async(e,t,r,n)=>{M("conversation",e,x,!0),M("msgBody.file",t.file,(e=>e instanceof Blob&&e.type.startsWith("image/")),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("send message ->"+o),pc(e);const i=await Ea.sendImageMessage(e,t,r,n);return gc(e,i.code),i},sc=async(e,t,r,n)=>{M("conversation",e,x,!0),M("msgBody.file",t.file,(e=>e instanceof Blob&&e.type.endsWith("image/gif")),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("send message ->"+o),pc(e);const i=await Ea.sendGIFMessage(e,t,r,n);return gc(e,i.code),i},ac=async(e,t,r,n)=>{M("conversation",e,x,!0),M("msgBody.file",t.file,(e=>e instanceof Blob),!0),pc(e);const o=await Ea.sendHQVoiceMessage(e,t,r,n);return gc(e,o.code),o},cc=async(e,t,r,n)=>{M("conversation",e,x,!0),M("msgBody.file",t.file,(e=>e instanceof Blob),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("send message ->"+o),pc(e);const i=await Ea.sendFileMessage(e,t,r,n);return gc(e,i.code),i},lc=async(e,n)=>{M("options.messageUId",n.messageUId,T,!0),M("options.sentTime",n.sentTime,R,!0),M("conversation",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId+",messageUId:"+n.messageUId;E.debug("recall message ->"+o);const i=await Ea.recallMsg(e,n);return i.code!==t.SUCCESS&&E.warn("recall message fail ->"+i.code+":"+r(i.code)+","+o),i},uc=async(e,n)=>{M("options.timestamp",n.timestamp??0,R),M("options.count",n.count??0,R),M("options.order",n.order??0,(e=>0===e||1===e)),M("conversation",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get history message ->"+o);const i=await Ea.getRemoteHistoryMessages(e,n);return i.code!==t.SUCCESS&&E.warn("get history message fail ->"+i.code+":"+r(i.code)+","+o),i},dc=async(e,n)=>{M("options.timestamp",n.timestamp??0,R),M("options.count",n.count??0,R),M("options.order",n.order??0,(e=>0===e||1===e)),M("conversation",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get remote history message ->"+o);const i=await Ea.getRemoteHistoryMessages(e,n);return i.code!==t.SUCCESS&&E.warn("get remote history message fail ->"+i.code+":"+r(i.code)+","+o),i},hc=async(e,n)=>{M("messages",n,(e=>b(e)&&!!e.length),!0),n.forEach((e=>{M("messages.messageUId",e.messageUId,T,!0),M("messages.sentTime",e.sentTime,R,!1),M("messages.messageDirection",e.messageDirection,(e=>1===e||2===e),!1)})),M("conversation",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("delete messages ->"+o);const i=await Ea.deleteRemoteMessage(e,n);return i!==t.SUCCESS?(E.warn("delete message fail ->"+i+":"+r(i)+","+o),{code:i,msg:r(i)}):{code:t.SUCCESS}},fc=async(e,n)=>{M("timestamp",n,(e=>R(e)&&e>=0),!0),M("conversation",e,x);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("clear message ->"+o);const i=await Ea.deleteRemoteMessageByTimestamp(e,n);return i!==t.SUCCESS?(E.warn("clear message ->"+i+":"+r(i)+","+o),{code:i,msg:r(i)}):{code:t.SUCCESS}},pc=e=>{const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("send message ->"+t)},gc=(e,n)=>{if(n!==t.SUCCESS){const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.warn("send message fail ->"+n+":"+r(n)+","+t)}};export{Uo as CommandMessage,e as ConnectionStatus,n as ConversationType,t as ErrorCode,r as ErrorDesc,u as Events,Lo as FileMessage,Do as GIFMessage,Mo as HQVoiceMessage,xo as ImageMessage,l as LogLevel,o as MentionedType,s as MessageDirection,c as NotificationLevel,i as NotificationStatus,a as ReceivedStatus,No as TextMessage,Ma as addEventListener,Ja as clearAllMessagesUnreadStatus,fc as clearHistoryMessages,$a as clearMessagesUnreadStatus,qa as clearTextMessageDraft,Aa as connect,hc as deleteMessages,Na as disconnect,Ka as getAllConversationState,za as getAllUnreadMentionedCount,Qa as getBlockedConversationList,xa as getConnectionStatus,ja as getConversation,Ua as getConversationList,Za as getConversationNotificationLevel,Ya as getConversationNotificationStatus,uc as getHistoryMessages,dc as getRemoteHistoryMessages,Da as getServerTime,Fa as getTextMessageDraft,tc as getTopConversationList,Va as getTotalUnreadCount,Wa as getUnreadCount,Ha as getUnreadMentionedCount,ka as init,La as onceEventListener,lc as recallMessage,rc as registerMessageType,Pa as removeConversation,Ba as removeEventListener,Ga as saveTextMessageDraft,cc as sendFileMessage,sc as sendGIFMessage,ac as sendHQVoiceMessage,ic as sendImageMessage,nc as sendMessage,oc as sendTextMessage,Xa as setConversationNotificationStatus,ec as setConversationToTop};
|
37
|
+
*/var en=null;try{en=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function tn(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function rn(e){return!0===(e&&e.__isLong__)}function nn(e){var t=Math.clz32(e&-e);return e?31-t:t}tn.prototype.__isLong__,Object.defineProperty(tn.prototype,"__isLong__",{value:!0}),tn.isLong=rn;var on={},sn={};function an(e,t){var r,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=sn[e])?n:(r=ln(e,0,!0),o&&(sn[e]=r),r):(o=-128<=(e|=0)&&e<128)&&(n=on[e])?n:(r=ln(e,e<0?-1:0,!1),o&&(on[e]=r),r)}function cn(e,t){if(isNaN(e))return t?mn:vn;if(t){if(e<0)return mn;if(e>=pn)return _n}else{if(e<=-gn)return Sn;if(e+1>=gn)return Cn}return e<0?cn(-e,t).neg():ln(e%fn|0,e/fn|0,t)}function ln(e,t,r){return new tn(e,t,r)}tn.fromInt=an,tn.fromNumber=cn,tn.fromBits=ln;var un=Math.pow;function dn(e,t,r){if(0===e.length)throw Error("empty string");if("number"==typeof t?(r=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?mn:vn;if((r=r||10)<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return dn(e.substring(1),t,r).neg();for(var o=cn(un(r,8)),i=vn,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),c=parseInt(e.substring(s,s+a),r);if(a<8){var l=cn(un(r,a));i=i.mul(l).add(cn(c))}else i=(i=i.mul(o)).add(cn(c))}return i.unsigned=t,i}function hn(e,t){return"number"==typeof e?cn(e,t):"string"==typeof e?dn(e,t):ln(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}tn.fromString=dn,tn.fromValue=hn;var fn=4294967296,pn=fn*fn,gn=pn/2,yn=an(1<<24),vn=an(0);tn.ZERO=vn;var mn=an(0,!0);tn.UZERO=mn;var bn=an(1);tn.ONE=bn;var wn=an(1,!0);tn.UONE=wn;var On=an(-1);tn.NEG_ONE=On;var Cn=ln(-1,2147483647,!1);tn.MAX_VALUE=Cn;var _n=ln(-1,-1,!0);tn.MAX_UNSIGNED_VALUE=_n;var Sn=ln(0,-2147483648,!1);tn.MIN_VALUE=Sn;var In=tn.prototype;In.toInt=function(){return this.unsigned?this.low>>>0:this.low},In.toNumber=function(){return this.unsigned?(this.high>>>0)*fn+(this.low>>>0):this.high*fn+(this.low>>>0)},In.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(Sn)){var t=cn(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var o=cn(un(e,6),this.unsigned),i=this,s="";;){var a=i.div(o),c=(i.sub(a.mul(o)).toInt()>>>0).toString(e);if((i=a).isZero())return c+s;for(;c.length<6;)c="0"+c;s=""+c+s}},In.getHighBits=function(){return this.high},In.getHighBitsUnsigned=function(){return this.high>>>0},In.getLowBits=function(){return this.low},In.getLowBitsUnsigned=function(){return this.low>>>0},In.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Sn)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},In.isZero=function(){return 0===this.high&&0===this.low},In.eqz=In.isZero,In.isNegative=function(){return!this.unsigned&&this.high<0},In.isPositive=function(){return this.unsigned||this.high>=0},In.isOdd=function(){return 1==(1&this.low)},In.isEven=function(){return 0==(1&this.low)},In.equals=function(e){return rn(e)||(e=hn(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},In.eq=In.equals,In.notEquals=function(e){return!this.eq(e)},In.neq=In.notEquals,In.ne=In.notEquals,In.lessThan=function(e){return this.comp(e)<0},In.lt=In.lessThan,In.lessThanOrEqual=function(e){return this.comp(e)<=0},In.lte=In.lessThanOrEqual,In.le=In.lessThanOrEqual,In.greaterThan=function(e){return this.comp(e)>0},In.gt=In.greaterThan,In.greaterThanOrEqual=function(e){return this.comp(e)>=0},In.gte=In.greaterThanOrEqual,In.ge=In.greaterThanOrEqual,In.compare=function(e){if(rn(e)||(e=hn(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},In.comp=In.compare,In.negate=function(){return!this.unsigned&&this.eq(Sn)?Sn:this.not().add(bn)},In.neg=In.negate,In.add=function(e){rn(e)||(e=hn(e));var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16,c=0,l=0,u=0,d=0;return u+=(d+=o+(65535&e.low))>>>16,l+=(u+=n+a)>>>16,c+=(l+=r+s)>>>16,c+=t+i,ln((u&=65535)<<16|(d&=65535),(c&=65535)<<16|(l&=65535),this.unsigned)},In.subtract=function(e){return rn(e)||(e=hn(e)),this.add(e.neg())},In.sub=In.subtract,In.multiply=function(e){if(this.isZero())return this;if(rn(e)||(e=hn(e)),en)return ln(en.mul(this.low,this.high,e.low,e.high),en.get_high(),this.unsigned);if(e.isZero())return this.unsigned?mn:vn;if(this.eq(Sn))return e.isOdd()?Sn:vn;if(e.eq(Sn))return this.isOdd()?Sn:vn;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(yn)&&e.lt(yn))return cn(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,a=e.low>>>16,c=65535&e.low,l=0,u=0,d=0,h=0;return d+=(h+=o*c)>>>16,u+=(d+=n*c)>>>16,d&=65535,u+=(d+=o*a)>>>16,l+=(u+=r*c)>>>16,u&=65535,l+=(u+=n*a)>>>16,u&=65535,l+=(u+=o*s)>>>16,l+=t*c+r*a+n*s+o*i,ln((d&=65535)<<16|(h&=65535),(l&=65535)<<16|(u&=65535),this.unsigned)},In.mul=In.multiply,In.divide=function(e){if(rn(e)||(e=hn(e)),e.isZero())throw Error("division by zero");var t,r,n;if(en)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?ln((this.unsigned?en.div_u:en.div_s)(this.low,this.high,e.low,e.high),en.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?mn:vn;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return mn;if(e.gt(this.shru(1)))return wn;n=mn}else{if(this.eq(Sn))return e.eq(bn)||e.eq(On)?Sn:e.eq(Sn)?bn:(t=this.shr(1).div(e).shl(1)).eq(vn)?e.isNegative()?bn:On:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(Sn))return this.unsigned?mn:vn;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=vn}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),i=o<=48?1:un(2,o-48),s=cn(t),a=s.mul(e);a.isNegative()||a.gt(r);)a=(s=cn(t-=i,this.unsigned)).mul(e);s.isZero()&&(s=bn),n=n.add(s),r=r.sub(a)}return n},In.div=In.divide,In.modulo=function(e){return rn(e)||(e=hn(e)),en?ln((this.unsigned?en.rem_u:en.rem_s)(this.low,this.high,e.low,e.high),en.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},In.mod=In.modulo,In.rem=In.modulo,In.not=function(){return ln(~this.low,~this.high,this.unsigned)},In.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},In.clz=In.countLeadingZeros,In.countTrailingZeros=function(){return this.low?nn(this.low):nn(this.high)+32},In.ctz=In.countTrailingZeros,In.and=function(e){return rn(e)||(e=hn(e)),ln(this.low&e.low,this.high&e.high,this.unsigned)},In.or=function(e){return rn(e)||(e=hn(e)),ln(this.low|e.low,this.high|e.high,this.unsigned)},In.xor=function(e){return rn(e)||(e=hn(e)),ln(this.low^e.low,this.high^e.high,this.unsigned)},In.shiftLeft=function(e){return rn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ln(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):ln(0,this.low<<e-32,this.unsigned)},In.shl=In.shiftLeft,In.shiftRight=function(e){return rn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ln(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):ln(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},In.shr=In.shiftRight,In.shiftRightUnsigned=function(e){return rn(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?ln(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):ln(32===e?this.high:this.high>>>e-32,0,this.unsigned)},In.shru=In.shiftRightUnsigned,In.shr_u=In.shiftRightUnsigned,In.rotateLeft=function(e){var t;return rn(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?ln(this.high,this.low,this.unsigned):e<32?(t=32-e,ln(this.low<<e|this.high>>>t,this.high<<e|this.low>>>t,this.unsigned)):(t=32-(e-=32),ln(this.high<<e|this.low>>>t,this.low<<e|this.high>>>t,this.unsigned))},In.rotl=In.rotateLeft,In.rotateRight=function(e){var t;return rn(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?ln(this.high,this.low,this.unsigned):e<32?(t=32-e,ln(this.high<<t|this.low>>>e,this.low<<t|this.high>>>e,this.unsigned)):(t=32-(e-=32),ln(this.low<<t|this.high>>>e,this.high<<t|this.low>>>e,this.unsigned))},In.rotr=In.rotateRight,In.toSigned=function(){return this.unsigned?ln(this.low,this.high,!1):this},In.toUnsigned=function(){return this.unsigned?this:ln(this.low,this.high,!0)},In.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},In.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},In.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},tn.fromBytes=function(e,t,r){return r?tn.fromBytesLE(e,t):tn.fromBytesBE(e,t)},tn.fromBytesLE=function(e,t){return new tn(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},tn.fromBytesBE=function(e,t){return new tn(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};const En={webSocketTimeout:5e3,signalTimeout:3e4,pingInterval:15e3,pingTimeout:5e3,pingFailedTimes:2,reconnectIntervalMin:250,reconnectIntervalMax:64e3,reconnectRaisingBase:2};const Tn=t=>e[t],Rn=()=>{const e="ACDeviceId";let t="";const r=Rt.get(e);return r?t=r:(t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),Rt.set(e,t)),t},kn=e=>{const t=new Xr;return t.writeIn8(67),t.writeIn8(255),t.writeInt32(e.length+7),t.writeArr(Array.from(e)),t.writeIn8(0),new Int8Array(t.getBytesArray()).buffer},An=e=>{const t=new Yr(new Uint8Array(e));t.readInt8(),t.readInt8();const r=t.readInt32(),n=t.readArr(r-7);if(t.readInt8(),e.byteLength!==r)throw new Error("packet resolve failed");return n};var Nn=new class{constructor(t){d(this,"url",""),d(this,"watcher",void 0),d(this,"provider",void 0),d(this,"options",void 0),d(this,"socket",void 0),d(this,"status",e.DISCONNECTED),d(this,"autoReconnect",!1),d(this,"isAuthorized",!1),d(this,"profile",void 0),d(this,"responseCallbacks",new Map),d(this,"failedCount",0),d(this,"reconnectTimer",void 0),d(this,"token",""),d(this,"connectResolve",void 0),d(this,"idCount",0),this.options=Object.assign(En,t)}setServerInfo(e){this.url=e}setCallback(e,t){this.watcher=e,this.provider=t}async connect(r){return this.token=r,new Promise((r=>{this.connectResolve=r,this.open().then((e=>e===t.SUCCESS?!f(this.provider)||this.provider.needReAuth()?this.auth():t.SUCCESS:e)).then((n=>{var o;(r(n),n===t.SUCCESS)?(this.isAuthorized=!0,this.profile=null===(o=this.provider)||void 0===o?void 0:o.profile(),this.autoReconnect=!0,this.onConnect()):this.onDisconnect(n===t.TIMEOUT?e.NETWORK_UNAVAILABLE:e.WEBSOCKET_UNAVAILABLE)}))}))}async send(e,r,n){var o;let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.options.signalTimeout;const{code:s,data:a}=await this.sendRawData(e,f(r)&&f(n.encoder)?n.encoder.encode(r).finish():new Uint8Array,i);if(0!==s)return{code:s,msg:"time out",data:null};if(!f(a)||!f(n.decoder))return{code:t.SUCCESS,msg:""};const c=null===(o=n.decoder)||void 0===o?void 0:o.decode(a);return c.errorCode?{code:Qr(c.errorCode),msg:c.errorMessage,data:null}:{data:c,code:t.SUCCESS,msg:""}}async sendRawData(e,r){var n,o,i;let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.options.signalTimeout;if(!this.socket)return{code:t.RC_NET_CHANNEL_INVALID};if(!this.isAuthorized&&!this.isAuthCommand(e))return{code:t.RC_NET_CHANNEL_INVALID};const a=this.generateMessageSeq(),c={cmdId:e,messageSeq:tn.fromNumber(a),deviceId:(null===(n=this.profile)||void 0===n?void 0:n.deviceId)??tn.fromInt(7),sessionId:(null===(o=this.profile)||void 0===o?void 0:o.sessionId)??tn.ZERO,uid:(null===(i=this.profile)||void 0===i?void 0:i.uid)??tn.ZERO,protocolVersion:0,destId:"",body:r,token:this.token};E.reqInfo(`websocket send -> cmd: 0x${e.toString(16)}, messageSeq: ${a}`),this.socket.send(kn(Hr.encode(c).finish()));const l=await new Promise((e=>{this.responseCallbacks.set(a,e),setTimeout((()=>{this.responseCallbacks.get(a)&&this.responseCallbacks.delete(a),e(null)}),s)}));return l?{code:0,data:l}:(E.warn(`send timeout -> cmd: 0x${e.toString(16)}, messageSeq: ${a}, timeout: ${s}`),{code:t.TIMEOUT})}close(){var r;this.autoReconnect=!1,this.doClose(),this.setStatus(e.DISCONNECTED),null===(r=this.connectResolve)||void 0===r||r.call(this,t.RC_SOCKET_DISCONNECTED)}async open(){const r=this.url;E.info(`conenct start -> ${r}`),this.setStatus(e.CONNECTING);const n=function(e,t){const r=new WebSocket(e,t);return r.binaryType="arraybuffer",{onClose(e){r.onclose=t=>{const{code:r,reason:n}=t;null==e||e(r,n)}},onError(e){r.onerror=t=>{e(t)}},onMessage(e){r.onmessage=t=>{e(t.data)}},onOpen(e){r.onopen=e},send(e){r.send(e)},close(e,t){r.close(e,t)}}}(this.url);this.socket=n;return await new Promise((o=>{n.onMessage((e=>{"ArrayBuffer"===h(e)?this.onReceiveMessage(e):E.error("Socket received invalid data:",e)})),n.onClose(((r,n)=>{E.warn("websocket closed -> code:",r,"reason:",n),this.onDisconnect(e.CONNECTION_CLOSED),o(t.RC_SOCKET_DISCONNECTED)})),n.onError((r=>{E.error("websocket error -> ",r),this.onDisconnect(e.WEBSOCKET_ERROR),o(t.RC_SOCKET_NOT_CREATED)})),n.onOpen((()=>{E.info("websocket open -> ",r),o(t.SUCCESS)})),setTimeout((()=>{o(t.TIMEOUT)}),this.options.webSocketTimeout)}))}async auth(){var e,r,n,o;E.info(`start auth -> ${this.token}`);const i={token:this.token,deviceType:7,imei:Rn(),brand:"",model:"",apnsToken:"",bandId:""},{code:s,msg:a,data:c}=await this.send(j.Auth,i,{encoder:Kr,decoder:Zr.AuthSignIn2TokenResp},8e3);return s===t.SUCCESS||c?(E.info("auth success -> ",null===(e=c.user)||void 0===e||null===(r=e.uid)||void 0===r?void 0:r.toString()),null===(n=this.watcher)||void 0===n||null===(o=n.onAuth)||void 0===o||o.call(n,c),t.SUCCESS):(E.warn("auth failed -> "+a),t.RC_CONN_NOT_AUTHRORIZED)}async checkAlive(){if(!this.socket||!this.isAuthorized)return;E.debug("send ping ->");const r={pingId:tn.ZERO,disconnectDelay:tn.ZERO},{code:n}=await this.send(j.Heartbean,r,{encoder:zr},this.options.pingTimeout);n===t.SUCCESS?(E.debug("recv pong <-"),this.failedCount=0,setTimeout((()=>this.checkAlive()),this.options.pingInterval)):(this.failedCount+=1,E.warn(`ping failed count: ${this.failedCount}, code: ${n}`),this.failedCount>=this.options.pingFailedTimes?(this.failedCount=0,E.warn("ping timeout, close current websocket to reconnect!"),this.onDisconnect(e.NETWORK_UNAVAILABLE)):this.checkAlive())}onReceiveMessage(t){let r;try{const e=An(t);r=Zr.NetworkResponse.decode(e)}catch(t){return E.error("unpack payload error -> ",t),void this.onDisconnect(e.DISCONNECT_BY_SERVER)}if(r.code)return void this.onDisconnect(e.DISCONNECT_BY_SERVER);if(r.cmdId===j.SessionKilledPush)return void this.onDisconnect(e.KICKED_OFFLINE_BY_OTHER_CLIENT);if(r.cmdId===j.SignOutPish||r.cmdId===j.SignOutPish2)return void this.onDisconnect(e.DISCONNECT_BY_SERVER);if(r.cmdId===j.UserFrozenToLogin||r.cmdId===j.UserFrozenToLogin2)return void this.onDisconnect(e.BLOCKED);const n=tn.isLong(r.messageSeq)?r.messageSeq.toNumber():0;E.reqInfo(`websocket recv ack -> messageSeq: ${n}`);const o=this.responseCallbacks.get(n);var i;f(o)?(o(r.body),this.responseCallbacks.delete(n)):(E.reqInfo(`websocket recv -> cmd: 0x${r.cmdId.toString(16)}, messageSeq: ${n}`),null===(i=this.watcher)||void 0===i||i.message(r.cmdId,r.body))}async try2Reconnect(){this.reconnectTimer=setTimeout((()=>{this.reconnectTimer=null,this.connect(this.token)}),5e3)}onConnect(){this.setStatus(e.CONNECTED),this.checkAlive(),f(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}onDisconnect(e){f(this.socket)&&(this.doClose(),this.isConnectionAvailable()&&(this.setStatus(e),this.autoReconnect&&this.isConnectionAvailable()&&this.try2Reconnect()))}doClose(){if(f(this.socket)){const e=this.socket;this.socket=null,e.onClose(null),e.close()}f(this.reconnectTimer)&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.isAuthorized=!1,this.profile=null;for(const e of this.responseCallbacks.values())e(null);this.responseCallbacks.clear()}isConnectionAvailable(){return this.status!==e.DISCONNECTED&&this.status!==e.KICKED_OFFLINE_BY_OTHER_CLIENT&&this.status!==e.BLOCKED&&this.status!==e.DISCONNECT_BY_SERVER}setStatus(e){var t;e!==this.status&&(E.info(`socketServer is changing status from ${Tn(this.status)} to ${Tn(e)}`),this.status=e,null===(t=this.watcher)||void 0===t||t.status(e))}isAuthCommand(e){return e===j.Auth}generateMessageSeq(){return++this.idCount}};var xn=new class{constructor(){d(this,"_user",void 0),this._user=this.createDefaultUser()}get uid(){return this.user.uid.toString()}get user(){return this._user}setLogged(e,t){const r=e.user;f(r)&&(this._user={active:!0,uid:r.uid??tn.UZERO,deviceId:e.deviceId,sessionId:e.sessionId,token:t})}logOut(){this._user=this.createDefaultUser()}createDefaultUser(){return{active:!1,uid:tn.UZERO,deviceId:tn.UZERO,sessionId:tn.UZERO,token:""}}},Dn=At.exports,Mn=Dn.Reader,Ln=Dn.util,Bn=Dn.roots.default||(Dn.roots.default={});Bn.NewMessageNotificationResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.NewMessageNotificationResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.seqno=e.int64();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/NewMessageNotificationResp"},e}(),Bn.SendPrivateChatMessageResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.msgId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.SendPrivateChatMessageResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;case 6:n.seqno=e.int64();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageResp"},e}(),Bn.GetNewMessageResp=function(){function e(e){if(this.msg={},e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.offset=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.msg=Ln.emptyObject,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r,n,o=void 0===t?e.len:e.pos+t,i=new Bn.GetNewMessageResp;e.pos<o;){var s=e.uint32();switch(s>>>3){case 1:i.errorCode=e.int32();break;case 2:i.errorMessage=e.string();break;case 3:i.offset=e.int64();break;case 4:i.seqno=e.int64();break;case 5:i.msg===Ln.emptyObject&&(i.msg={});var a=e.uint32()+e.pos;for(r="",n=null;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:r=e.string();break;case 2:n=Bn.DialogMessageList.decode(e,e.uint32());break;default:e.skipType(7&c)}}i.msg[r]=n;break;default:e.skipType(7&s)}}return i},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageResp"},e}(),Bn.DialogMessageList=function(){function e(e){if(this.dialogMessage=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialogMessage=Ln.emptyArray,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.DialogMessageList;e.pos<r;){var o=e.uint32();if(o>>>3==1)n.dialogMessage&&n.dialogMessage.length||(n.dialogMessage=[]),n.dialogMessage.push(Bn.DialogMessage.decode(e,e.uint32()));else e.skipType(7&o)}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessageList"},e}(),Bn.DialogMessage=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.msgId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.localId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.msgStatus=0,e.prototype.srcId=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.destId="",e.prototype.isOut=!1,e.prototype.senderCategory=0,e.prototype.msgCategory=0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.msgSendTime=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.burnAfterReadingFlag=!1,e.prototype.atFlag=!1,e.prototype.replyFlag=!1,e.prototype.referenceFlag=!1,e.prototype.msgIdReferenced=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.uploadFlag=!1,e.prototype.burnAfterReadingTime=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.sharingGroupFlag=!1,e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.extra="",e.prototype.msgContent=Ln.newBuffer([]),e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.DialogMessage;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.msgId=e.int64();break;case 2:n.localId=e.int64();break;case 3:n.msgStatus=e.int32();break;case 4:n.srcId=e.int64();break;case 5:n.destId=e.string();break;case 6:n.isOut=e.bool();break;case 7:n.senderCategory=e.int32();break;case 8:n.msgCategory=e.int32();break;case 9:n.msgPreContent=e.string();break;case 10:n.msgPostContent=e.string();break;case 11:n.mediaFlag=e.bool();break;case 12:n.mediaConstructor=e.int32();break;case 13:n.mediaAttribute=e.string();break;case 14:n.msgSendTime=e.int64();break;case 15:n.burnAfterReadingFlag=e.bool();break;case 16:n.atFlag=e.bool();break;case 17:n.replyFlag=e.bool();break;case 18:n.referenceFlag=e.bool();break;case 19:n.msgIdReferenced=e.int64();break;case 20:n.uploadFlag=e.bool();break;case 21:n.burnAfterReadingTime=e.int64();break;case 22:n.sharingGroupFlag=e.bool();break;case 23:n.seqno=e.int64();break;case 24:n.extra=e.string();break;case 25:n.msgContent=e.bytes();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DialogMessage"},e}(),Bn.GetBriefDialogListResp=function(){function e(e){if(this.notExistDestId=[],this.briefDialog={},e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.notExistDestId=Ln.emptyArray,e.prototype.seqno=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.briefDialog=Ln.emptyObject,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r,n,o=void 0===t?e.len:e.pos+t,i=new Bn.GetBriefDialogListResp;e.pos<o;){var s=e.uint32();switch(s>>>3){case 1:i.errorCode=e.int32();break;case 2:i.errorMessage=e.string();break;case 3:if(i.notExistDestId&&i.notExistDestId.length||(i.notExistDestId=[]),2==(7&s))for(var a=e.uint32()+e.pos;e.pos<a;)i.notExistDestId.push(e.int64());else i.notExistDestId.push(e.int64());break;case 4:i.seqno=e.int64();break;case 5:i.briefDialog===Ln.emptyObject&&(i.briefDialog={});a=e.uint32()+e.pos;for(r="",n=null;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:r=e.string();break;case 2:n=Bn.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&c)}}i.briefDialog[r]=n;break;default:e.skipType(7&s)}}return i},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListResp"},e}(),Bn.BriefDialog=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.dialogTitle="",e.prototype.smallAvatarUrl="",e.prototype.backgroundImage="",e.prototype.stickyFlag=!1,e.prototype.muteFlag=!1,e.prototype.blockFlag=!1,e.prototype.burnAfterReadingFlag=!1,e.prototype.takeScreenshotFlag=!1,e.prototype.groupFlag=!1,e.prototype.pushNotificationLevel=0,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.BriefDialog;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.destId=e.string();break;case 2:n.dialogTitle=e.string();break;case 3:n.smallAvatarUrl=e.string();break;case 4:n.backgroundImage=e.string();break;case 5:n.stickyFlag=e.bool();break;case 6:n.muteFlag=e.bool();break;case 7:n.blockFlag=e.bool();break;case 8:n.burnAfterReadingFlag=e.bool();break;case 9:n.takeScreenshotFlag=e.bool();break;case 10:n.groupFlag=e.bool();break;case 15:n.pushNotificationLevel=e.int32();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/BriefDialog"},e}(),Bn.GetDialogKeyResp=function(){function e(e){if(this.retryUid=[],this.entry={},e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.dialogKeyVersion=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.prototype.retryUid=Ln.emptyArray,e.prototype.entry=Ln.emptyObject,e.prototype.serverSign="",e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r,n,o=void 0===t?e.len:e.pos+t,i=new Bn.GetDialogKeyResp;e.pos<o;){var s=e.uint32();switch(s>>>3){case 1:i.errorCode=e.int32();break;case 2:i.errorMessage=e.string();break;case 3:i.dialogKeyVersion=e.int64();break;case 4:if(i.retryUid&&i.retryUid.length||(i.retryUid=[]),2==(7&s))for(var a=e.uint32()+e.pos;e.pos<a;)i.retryUid.push(e.int64());else i.retryUid.push(e.int64());break;case 5:i.entry===Ln.emptyObject&&(i.entry={});a=e.uint32()+e.pos;for(r="",n=null;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:r=e.string();break;case 2:n=Bn.AesKeyAndIV.decode(e,e.uint32());break;default:e.skipType(7&c)}}i.entry[r]=n;break;case 6:i.serverSign=e.string();break;default:e.skipType(7&s)}}return i},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyResp"},e}(),Bn.AesKeyAndIV=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.aesKey="",e.prototype.aesIV="",e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.AesKeyAndIV;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.aesKey=e.string();break;case 2:n.aesIV=e.string();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/AesKeyAndIV"},e}(),Bn.GetHistoryMessageResp=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.msg=null,e.prototype.isEnd=!1,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.GetHistoryMessageResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.msg=Bn.DialogMessageList.decode(e,e.uint32());break;case 4:n.isEnd=e.bool();break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageResp"},e}(),Bn.GetWebDialogListResp=function(){function e(e){if(this.fullDialog=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.fullDialog=Ln.emptyArray,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.GetWebDialogListResp;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.fullDialog&&n.fullDialog.length||(n.fullDialog=[]),n.fullDialog.push(Bn.WebFullDialog.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListResp"},e}(),Bn.WebFullDialog=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialog=null,e.prototype.msg=null,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r=void 0===t?e.len:e.pos+t,n=new Bn.WebFullDialog;e.pos<r;){var o=e.uint32();switch(o>>>3){case 1:n.dialog=Bn.BriefDialog.decode(e,e.uint32());break;case 2:n.msg=Bn.DialogMessage.decode(e,e.uint32());break;default:e.skipType(7&o)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/WebFullDialog"},e}(),Bn.GetNewSettingDialogListResp=function(){function e(e){if(this.briefDialog={},e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.briefDialog=Ln.emptyObject,e.prototype.setTime=Ln.Long?Ln.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Mn||(e=Mn.create(e));for(var r,n,o=void 0===t?e.len:e.pos+t,i=new Bn.GetNewSettingDialogListResp;e.pos<o;){var s=e.uint32();switch(s>>>3){case 1:i.errorCode=e.int32();break;case 2:i.errorMessage=e.string();break;case 3:i.briefDialog===Ln.emptyObject&&(i.briefDialog={});var a=e.uint32()+e.pos;for(r="",n=null;e.pos<a;){var c=e.uint32();switch(c>>>3){case 1:r=e.string();break;case 2:n=Bn.BriefDialog.decode(e,e.uint32());break;default:e.skipType(7&c)}}i.briefDialog[r]=n;break;case 4:i.setTime=e.int64();break;default:e.skipType(7&s)}}return i},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListResp"},e}();var Un=Bn;var jn=new class{constructor(){d(this,"_token",""),d(this,"_uploadUrl",""),d(this,"_downloadUrl",""),d(this,"_cert","")}set imInitToken(e){this._token=e}get imInitToken(){return this._token}get fileUploadUrl(){return this._uploadUrl}get cert(){return this._cert}get fileDownloadUrl(){return this._downloadUrl}setFileServerInfo(e,t,r){this._uploadUrl=e,this._downloadUrl=t,this._cert=r}getFileAbsoluteUri(e){return O(e)?e.startsWith("http")?e:this.fileDownloadUrl+e:e}try2ExtractFileRelativeUri(e){return O(e)&&e.startsWith(this.fileDownloadUrl)?e.substring(this.fileDownloadUrl.length):e}};const Pn=e=>{if(!O(e.targetId+""))return"";switch(e.conversationType){case n.PRIVATE:return"P::"+e.targetId;case n.GROUP:return"G::"+e.targetId;case n.ULTRA_GROUP:return`SG::${e.targetId}_${e.channelId??""}`;default:return""}},Fn=e=>{if(!O(e))return null;const t=e.split("::");if(2!==t.length)return null;const r=t[0];if("G"===r)return{conversationType:n.GROUP,targetId:t[1]};if("P"===r)return{conversationType:n.PRIVATE,targetId:t[1]};if("SG"===r){const e=t[1].indexOf("_");if(e>0){const r=t[1].substring(0,e),o=t[1].substring(e+1);return{conversationType:n.ULTRA_GROUP,targetId:r,channelId:o}}return 0===e?null:{conversationType:n.ULTRA_GROUP,targetId:t[1]}}return null},Gn=e=>e.startsWith("SG")||e.startsWith("G");var qn=At.exports,Hn=qn.Writer,zn=qn.util,Kn=qn.roots.default||(qn.roots.default={});Kn.SendPrivateChatMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.localId=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.extra="",e.prototype.thumbnail="",e.prototype.msgContent=zn.newBuffer([]),e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.extra&&Object.hasOwnProperty.call(e,"extra")&&t.uint32(66).string(e.extra),null!=e.thumbnail&&Object.hasOwnProperty.call(e,"thumbnail")&&t.uint32(74).string(e.thumbnail),null!=e.msgContent&&Object.hasOwnProperty.call(e,"msgContent")&&t.uint32(82).bytes(e.msgContent),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendPrivateChatMessageReq"},e}(),Kn.DeletePrivateChatDialogReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatDialogReq"},e}(),Kn.GetNewMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.offset=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(8).int64(e.offset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(16).int32(e.rows),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewMessageReq"},e}(),Kn.UpdatePrivateChatDialogStickyConfigReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(16).bool(e.stickyFlag),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogStickyConfigReq"},e}(),Kn.UpdatePrivateChatDialogMuteConfigReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(16).bool(e.muteFlag),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdatePrivateChatDialogMuteConfigReq"},e}(),Kn.DeleteChatMessageReq=function(){function e(e){if(this.msgIdList=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.msgId=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.msgIdList=zn.emptyArray,e.encode=function(e,t){if(t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),null!=e.msgIdList&&e.msgIdList.length){t.uint32(26).fork();for(var r=0;r<e.msgIdList.length;++r)t.int64(e.msgIdList[r]);t.ldelim()}return t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteChatMessageReq"},e}(),Kn.DeletePrivateChatHistoryReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.msgId=zn.Long?zn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeletePrivateChatHistoryReq"},e}(),Kn.CleanHistoryMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.type=0,e.prototype.msgTime=zn.Long?zn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(16).int32(e.type),null!=e.msgTime&&Object.hasOwnProperty.call(e,"msgTime")&&t.uint32(24).int64(e.msgTime),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/CleanHistoryMessageReq"},e}(),Kn.GetBriefDialogListReq=function(){function e(e){if(this.destId=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=zn.emptyArray,e.encode=function(e,t){if(t||(t=Hn.create()),null!=e.destId&&e.destId.length)for(var r=0;r<e.destId.length;++r)t.uint32(10).string(e.destId[r]);return t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetBriefDialogListReq"},e}(),Kn.GetDialogKeyReq=function(){function e(e){if(this.destId=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId=zn.emptyArray,e.prototype.clientSign="",e.encode=function(e,t){if(t||(t=Hn.create()),null!=e.destId&&e.destId.length)for(var r=0;r<e.destId.length;++r)t.uint32(10).string(e.destId[r]);return null!=e.clientSign&&Object.hasOwnProperty.call(e,"clientSign")&&t.uint32(18).string(e.clientSign),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetDialogKeyReq"},e}(),Kn.RecallPrivateChatMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.destId="",e.prototype.msgId=zn.Long?zn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.destId&&Object.hasOwnProperty.call(e,"destId")&&t.uint32(10).string(e.destId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallPrivateChatMessageReq"},e}(),Kn.GetHistoryMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.dialogKeys="",e.prototype.offset=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.oldOffset=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.dialogKeys&&Object.hasOwnProperty.call(e,"dialogKeys")&&t.uint32(10).string(e.dialogKeys),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(16).int64(e.offset),null!=e.oldOffset&&Object.hasOwnProperty.call(e,"oldOffset")&&t.uint32(24).int64(e.oldOffset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(32).int32(e.rows),null!=e.newToOld&&Object.hasOwnProperty.call(e,"newToOld")&&t.uint32(40).bool(e.newToOld),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetHistoryMessageReq"},e}(),Kn.GetWebDialogListReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.type=0,e.prototype.offset=zn.Long?zn.Long.fromBits(0,0,!1):0,e.prototype.rows=0,e.prototype.newToOld=!1,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.type&&Object.hasOwnProperty.call(e,"type")&&t.uint32(8).int32(e.type),null!=e.offset&&Object.hasOwnProperty.call(e,"offset")&&t.uint32(16).int64(e.offset),null!=e.rows&&Object.hasOwnProperty.call(e,"rows")&&t.uint32(24).int32(e.rows),null!=e.newToOld&&Object.hasOwnProperty.call(e,"newToOld")&&t.uint32(32).bool(e.newToOld),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetWebDialogListReq"},e}(),Kn.GetNewSettingDialogListReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.time=zn.Long?zn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=Hn.create()),null!=e.time&&Object.hasOwnProperty.call(e,"time")&&t.uint32(8).int64(e.time),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/GetNewSettingDialogListReq"},e}();var Vn=Kn,Wn=At.exports,$n=Wn.Writer,Jn=Wn.util,Zn=Wn.roots.default||(Wn.roots.default={});Zn.SendGroupChatMessageReq=function(){function e(e){if(this.at=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.prototype.localId=Jn.Long?Jn.Long.fromBits(0,0,!1):0,e.prototype.msgPreContent="",e.prototype.msgPostContent="",e.prototype.mediaFlag=!1,e.prototype.mediaConstructor=0,e.prototype.mediaAttribute="",e.prototype.at=Jn.emptyArray,e.prototype.extra="",e.prototype.assign="",e.prototype.atAll=!1,e.prototype.msgContent=Jn.newBuffer([]),e.encode=function(e,t){if(t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),null!=e.localId&&Object.hasOwnProperty.call(e,"localId")&&t.uint32(16).int64(e.localId),null!=e.msgPreContent&&Object.hasOwnProperty.call(e,"msgPreContent")&&t.uint32(26).string(e.msgPreContent),null!=e.msgPostContent&&Object.hasOwnProperty.call(e,"msgPostContent")&&t.uint32(34).string(e.msgPostContent),null!=e.mediaFlag&&Object.hasOwnProperty.call(e,"mediaFlag")&&t.uint32(40).bool(e.mediaFlag),null!=e.mediaConstructor&&Object.hasOwnProperty.call(e,"mediaConstructor")&&t.uint32(48).int32(e.mediaConstructor),null!=e.mediaAttribute&&Object.hasOwnProperty.call(e,"mediaAttribute")&&t.uint32(58).string(e.mediaAttribute),null!=e.at&&e.at.length){t.uint32(66).fork();for(var r=0;r<e.at.length;++r)t.int64(e.at[r]);t.ldelim()}return null!=e.extra&&Object.hasOwnProperty.call(e,"extra")&&t.uint32(74).string(e.extra),null!=e.assign&&Object.hasOwnProperty.call(e,"assign")&&t.uint32(82).string(e.assign),null!=e.atAll&&Object.hasOwnProperty.call(e,"atAll")&&t.uint32(88).bool(e.atAll),null!=e.msgContent&&Object.hasOwnProperty.call(e,"msgContent")&&t.uint32(98).bytes(e.msgContent),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageReq"},e}(),Zn.DeleteGroupChatHistoryReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatHistoryReq"},e}(),Zn.UpdateGroupChatDialogStickyConfigReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.prototype.stickyFlag=!1,e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),null!=e.stickyFlag&&Object.hasOwnProperty.call(e,"stickyFlag")&&t.uint32(16).bool(e.stickyFlag),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogStickyConfigReq"},e}(),Zn.UpdateGroupChatDialogMuteConfigReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.prototype.muteFlag=!1,e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),null!=e.muteFlag&&Object.hasOwnProperty.call(e,"muteFlag")&&t.uint32(16).bool(e.muteFlag),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/UpdateGroupChatDialogMuteConfigReq"},e}(),Zn.RecallGroupChatMessageReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.prototype.msgId=Jn.Long?Jn.Long.fromBits(0,0,!1):0,e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),null!=e.msgId&&Object.hasOwnProperty.call(e,"msgId")&&t.uint32(16).int64(e.msgId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/RecallGroupChatMessageReq"},e}(),Zn.DeleteGroupChatDialogReq=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.groupId="",e.encode=function(e,t){return t||(t=$n.create()),null!=e.groupId&&Object.hasOwnProperty.call(e,"groupId")&&t.uint32(10).string(e.groupId),t},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/DeleteGroupChatDialogReq"},e}();var Xn=Zn;const Yn=At.exports.Reader,Qn=At.exports.util,eo=At.exports.roots.default||(At.exports.roots.default={}),to=eo.SendGroupChatMessageResp=(()=>{function e(e){if(e)for(let t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return e.prototype.errorCode=0,e.prototype.errorMessage="",e.prototype.localId=Qn.Long?Qn.Long.fromBits(0,0,!1):0,e.prototype.msgId=Qn.Long?Qn.Long.fromBits(0,0,!1):0,e.prototype.msgSendTime=Qn.Long?Qn.Long.fromBits(0,0,!1):0,e.prototype.seqno=Qn.Long?Qn.Long.fromBits(0,0,!1):0,e.decode=function(e,t){e instanceof Yn||(e=Yn.create(e));let r=void 0===t?e.len:e.pos+t,n=new eo.SendGroupChatMessageResp;for(;e.pos<r;){let t=e.uint32();switch(t>>>3){case 1:n.errorCode=e.int32();break;case 2:n.errorMessage=e.string();break;case 3:n.localId=e.int64();break;case 4:n.msgId=e.int64();break;case 5:n.msgSendTime=e.int64();break;case 6:n.seqno=e.int64();break;default:e.skipType(7&t)}}return n},e.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/SendGroupChatMessageResp"},e})();let ro=0;const no=async()=>{const e=(new Date).getTime(),{code:r,data:n}=await Nn.send(j.GetServerTime,null,{decoder:Zr.SystemCurrentTimeMillisResp});if(r===t.SUCCESS){const{currentTimeMillis:t}=n;ro=t.toNumber()-e}},oo=()=>(new Date).getTime()+ro,io=new Set;var so={addMessage(e){io.add(e)},remove(e){io.delete(e)},has:e=>io.has(e),reset(){io.clear()}};const ao=new Set;var co={addMessage(e){ao.add(e)},remove(e){ao.delete(e)},has:e=>ao.has(e),reset(){ao.clear()}};const lo=new Map;function uo(e){lo.set(e.getObjectId(),e.decode.bind(e))}class ho{constructor(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];d(this,"messageType",void 0),d(this,"content",void 0),d(this,"isPersited",void 0),d(this,"isCounted",void 0),d(this,"isStatusMessage",void 0),this.messageType=e,this.content=t,o?(this.isPersited=!1,this.isCounted=!1):(this.isPersited=r,this.isCounted=n),this.isStatusMessage=o}get objectId(){return this.constructor.getObjectId()}static getObjectId(){throw new Error("Method not implemented.")}static decode(e){throw new Error("Method not implemented.")}encode(){throw new Error("Method not implemented.")}}const fo=0,po=268439552,go=268439563,yo=268439562,vo=268439553,mo=268439581,bo=268439597,wo=268439613,Oo=268439629,Co=1610678301,_o=268439645,So="RC:TxtMsg",Io="RC:HQVCMsg",Eo="RC:FileMsg",To="RC:ImgMsg",Ro="RC:GIFMsg",ko="RC:RcCmd",Ao="RC:CmdMsg";class No extends ho{constructor(e){super(So,e)}static getObjectId(){return fo}static decode(e){const{user:t,extra:r,content:n}=e;return new No({user:t,extra:r,content:n})}encode(){const{user:e,extra:t,content:r}=this.content;return{user:e,extra:t,content:r}}}class xo extends ho{constructor(e){super(To,e)}static getObjectId(){return po}static decode(e){const{user:t,extra:r,thumbnailObjectKey:n,originalObjectKey:o,width:i,height:s}=e;return new xo({user:t,extra:r,content:n,imageUri:jn.getFileAbsoluteUri(o),width:i,height:s})}encode(){const{user:e,extra:t,content:r,imageUri:n,width:o,height:i}=this.content;return{user:e,extra:t,thumbnailObjectKey:r,originalObjectKey:jn.try2ExtractFileRelativeUri(n),width:o&&Math.floor(o),height:i&&Math.floor(i)}}}class Do extends ho{constructor(e){super(Ro,e)}static getObjectId(){return go}static decode(e){const{user:t,extra:r,size:n,originalObjectKey:o,width:i,height:s}=e;return new Do({user:t,extra:r,gifDataSize:n,remoteUrl:jn.getFileAbsoluteUri(o),width:i,height:s})}encode(){const{user:e,extra:t,gifDataSize:r,remoteUrl:n,width:o,height:i}=this.content;return{user:e,extra:t,size:r,originalObjectKey:jn.try2ExtractFileRelativeUri(n),width:o&&Math.floor(o),height:i&&Math.floor(i),extension:"gif"}}}class Mo extends ho{constructor(e){super(Io,e)}static getObjectId(){return vo}static decode(e){const{user:t,extra:r,length:n,audioObjectKey:o,extension:i}=e;return new Mo({user:t,extra:r,remoteUrl:jn.getFileAbsoluteUri(o),duration:n,type:i})}encode(){const{user:e,extra:t,remoteUrl:r,duration:n,type:o}=this.content;return{user:e,extra:t,length:n,audioObjectKey:jn.try2ExtractFileRelativeUri(r),extension:o}}}class Lo extends ho{constructor(e){super(Eo,e)}static getObjectId(){return yo}static decode(e){const{user:t,extra:r,title:n,extension:o,size:i,originalObjectKey:s}=e;return new Lo({user:t,extra:r,name:n,size:i,type:o,fileUrl:s})}encode(){const{user:e,extra:t,name:r,size:n,type:o,fileUrl:i}=this.content;return{user:e,extra:t,title:r,originalObjectKey:jn.try2ExtractFileRelativeUri(i),extension:o,size:n}}}class Bo extends ho{constructor(e){super(ko,e,!0,!1,!1)}static getObjectId(){return Co}static decode(e){return new Bo(e)}encode(){return this.content}}class Uo extends ho{constructor(e){super(Ao,e,!1,!1)}static getObjectId(){return _o}static decode(e){return new Uo(e)}encode(){return this.content}}class jo extends ho{static decode(e){const{messageType:t,fields:r,user:n,extra:o}=e;return new this(t,{...r,user:n,extra:o})}encode(){const{user:e,extra:t,mentionedInfo:r,...n}=this.content;return{messageType:this.messageType,fields:n,user:e,extra:t}}}class Po extends jo{constructor(e,t){super(e,t,!1,!1)}static getObjectId(){return mo}}class Fo extends jo{constructor(e,t){super(e,t,!0,!1)}static getObjectId(){return bo}}class Go extends jo{constructor(e,t){super(e,t,!0,!1)}static getObjectId(){return wo}}class qo extends jo{constructor(e,t){super(e,t,!1,!1,!0)}static getObjectId(){return Oo}}var Ho=new class{constructor(){d(this,"aesKeyRecord",new Map)}async getDialogAesKey(e){return O(e)?this.aesKeyRecord.has(e)?this.aesKeyRecord.get(e):new Promise((t=>{this.getDialogAesKeyListFromRemote([e]).then((r=>{t(r.get(e))})),setTimeout((()=>{t(null)}),8e3)})):null}getDialogAesKeyList(e){return new Promise((t=>{const r=new Map;this.getDialogAesKeyListInBatches(e,((n,o)=>{if(o.size)for(const[e,t]of o)r.set(e,t);(r.size===e.length||n)&&t(r)}))}))}getDialogAesKeyListInBatches(e,t){const r=new Map,n=[];e.forEach((e=>{if(!O(e))return;const t=this.getDialogAesKeyFromLocal(e);t?r.set(e,t):n.push(e)})),t(!1,r),n.length&&this.getDialogAesKeyListFromRemote(n).then((e=>{t(!0,e)}))}reset(){this.aesKeyRecord.clear()}async getDialogAesKeyListFromRemote(e){if(!e.length)return new Map;const{code:r,data:n}=await(o=e,Nn.send(j.GetDialogKey,{destId:o,clientSign:""},{encoder:Vn.GetDialogKeyReq,decoder:Un.GetDialogKeyResp}));var o;if(r===t.SUCCESS){const e=new Map;for(const t in n.entry){var i,s;const r=n.entry[t];if(null!==(i=r.aesKey)&&void 0!==i&&i.length&&null!==(s=r.aesIV)&&void 0!==s&&s.length){const n={key:r.aesKey,iv:r.aesIV};e.set(t,n),this.aesKeyRecord.set(t,n)}}return e}return new Map}getDialogAesKeyFromLocal(e){return O(e)?this.aesKeyRecord.get(e):null}};const zo="time",Ko=(e,t)=>[e,t,zo].join("_");class Vo{constructor(e,t){d(this,"appkey",void 0),d(this,"userId",void 0),d(this,"inBoxOffset",tn.ZERO),this.appkey=e,this.userId=t}setInboxOffset(e){if(this.inBoxOffset>e)return;this.inBoxOffset=e;const t=Ko(this.appkey,this.userId);Rt.set(t,e.toString())}getInboxOffset(){if(this.inBoxOffset.isZero()){const e=Ko(this.appkey,this.userId);this.inBoxOffset=tn.fromString(Rt.get(e)??"0")}return this.inBoxOffset}}const Wo=e=>{const t=[];let r,n,o;for(n=0;n<e.length;++n)for(r=e[n],o=3;o>=0;--o)t.push(r>>8*o&255);return new Uint8Array(t)};const $o=(e,t,r)=>{const n={};return e.forEach((e=>{const o=Jo(e,t.get(e),r.get(e));o.length&&(n[e]=o)})),n},Jo=(e,t,r)=>{const n=Fn(e);if(!n)return[];const o=new Set;let i=[];return t.forEach((e=>{const t=e;let c=t.mediaConstructor,l=Zo(t,r);if(!l)return;if(1610678290===c||1610743841===c){const{msgId:e,sendTime:r}=l,i={sentTime:r,messageUId:e,conversationType:n.conversationType,targetId:t.isOut?n.targetId:xn.uid,channelId:n.channelId};c=Co,l=i,o.add(e)}const u=function(e,t){const r=lo.get(e);return r?r(t):null}(c,l);if(f(u)){const e={...n,senderUserId:t.srcId.toString(),messageDirection:t.isOut?s.SEND:s.RECEIVE,isCounted:u.isCounted,isMentioned:t.atFlag,content:u.content,messageType:u.messageType,isOffLineMessage:!1,isPersited:u.isPersited,messageId:tn.isLong(t.localId)?t.localId.toNumber():void 0,messageUId:t.msgId.toString(),sentTime:t.seqno.toNumber(),receivedTime:oo(),isStatusMessage:u.isStatusMessage,receivedStatus:a.READ,disableNotification:!1};if(e.isStatusMessage&&oo()-e.sentTime>6e3)return;i.push(e)}})),o.size&&(i=i.filter((e=>!o.has(e.messageUId)))),i},Zo=(e,t)=>{try{var r,n;let o;o=null!==(r=e.msgContent)&&void 0!==r&&r.length?((e,t)=>{const r=window.btoa(String.fromCharCode(...e));return Ot.AES.decrypt(r,Ot.enc.Utf8.parse(t.key),{iv:f(t.iv)?Ot.enc.Utf8.parse(t.iv):void 0}).toString(Ot.enc.Utf8)})(e.msgContent,t):e.msgPreContent??"",1610678290!==e.mediaConstructor&&1610743841!==e.mediaConstructor||(o=Xo(o));let i={};return null!==(n=o)&&void 0!==n&&n.length&&(i=JSON.parse(o)),i}catch(t){return E.error("decode message content fail -> uid:",e.msgId.toString()),null}},Xo=e=>e.replace(/("msgId")\s*:\s*(\d+)/g,((e,t,r)=>`${t}:"${r}"`));var Yo={parse:function(e,t){const r=new Map;if(Object.keys(e).forEach((t=>{var n;const o=null===(n=e[t].dialogMessage)||void 0===n?void 0:n.filter((e=>!e.sharingGroupFlag));null!=o&&o.length&&r.set(t,o)})),!r.size)return void t(!0,{});const n=new Set(r.keys());Ho.getDialogAesKeyListInBatches([...r.keys()],((e,o)=>{if(o.size){const e=[...o.keys()];for(const t of e)n.delete(t);t(!n.size,$o(e,r,o))}n.size&&e&&t(!0,{})}))},parseSingleDialogMessages:Jo};function Qo(e){if(!f(e))return e;if(Array.isArray(e))return e.map((e=>Qo(e)));if(m(e)){const t={};return Object.keys(e).forEach((r=>{t[r]=Qo(e[r])})),t}return e}const ei={unreadMessageCount:{keyName:"c",defaultVal:0},lastUnreadTime:{keyName:"t",defaultVal:0},notificationStatus:{keyName:"nc",defaultVal:2},notificationLevel:{keyName:"nl",defaultVal:0},isTop:{keyName:"it",defaultVal:!1},mentionedUIds:{keyName:"mu",defaultVal:null}};class ti{constructor(e,t){d(this,"localStore",void 0);const r=`con-${e}-${t}`;this.localStore=new kt(r)}getStoreKey(e){return`${e.conversationType}_${e.targetId}_${e.channelId??""}`}getConOptionByKey(e){const t=(e=e||"").split("_");if(t.length>=2){const e=t.shift(),r=t.shift(),n=t.join("_");return{conversationType:Number(e),targetId:r,channelId:n}}return{conversationType:n.PRIVATE,targetId:"",channelId:""}}updateUnreadCount(e){const{conversationType:t,targetId:r,channelId:n,content:o,messageType:i,sentTime:a,isCounted:c,messageDirection:l}=e,u=l===s.SEND,d=i===ko,h=m(o),f={conversationType:t,targetId:r,channelId:n},p=this.get(f)||{},g=p.lastUnreadTime||0,y=p.unreadMessageCount||0;if(!(g>a)&&!u){if(c&&(p.unreadMessageCount=y+1,p.lastUnreadTime=a),d&&h){g>=o.sentTime&&y&&(p.unreadMessageCount=y-1)}this.set(f,p)}}updateMentionedData(e){const{conversationType:t,targetId:r,channelId:o,messageUId:i,messageType:a,isMentioned:c,messageDirection:l,content:u}=e;if(l===s.SEND||!c&&a!==ko)return;const d=this.getStoreKey({conversationType:t,targetId:r,channelId:o}),h=this.localStore.get(d)||{},f=ei.mentionedUIds.keyName,p=h[f]||[];if(c&&t===n.GROUP&&(p.includes(i)||p.push(i)),a===ko&&t===n.GROUP){const e=u,t=p.indexOf(e.messageUId);t>=0&&p.splice(t,1)}p.length?h[f]=p:delete h[f],C(h)?this.localStore.set(d,h):this.localStore.remove(d)}set(e,t){const r=this.getStoreKey(e),n=this.localStore.get(r)||{};for(const e of Ct(t)){const r=ei[e],o=t[e];if(y(null==r?void 0:r.keyName)||y(o))continue;o===r.defaultVal?delete n[r.keyName]:n[r.keyName]=o,n[ei.unreadMessageCount.keyName]||(delete n[ei.lastUnreadTime.keyName],delete n[ei.mentionedUIds.keyName])}C(n)?this.localStore.set(r,n):this.localStore.remove(r)}get(e){const t=this.getStoreKey(e),r=this.localStore.get(t)||{},n={};for(const e of Ct(ei)){const{keyName:t,defaultVal:i}=ei[e];var o;if("mentionedUIds"===e)n.unreadMentionedCount=(null===(o=r[t])||void 0===o?void 0:o.length)??0,n.hasMentioned=!!n.unreadMentionedCount;else n[e]=r[t]||Qo(i)}return n}getAll(){const e=this.localStore.getCache()||{},t=[];for(const r in e){const n=this.getConOptionByKey(r),o=e[r];for(const e of Ct(ei)){const{keyName:t,defaultVal:r}=ei[e];"mentionedUIds"!==e&&(n[e]=o[t]||Qo(r))}t.push(n)}return t}}const ri=e=>{const t=e.destId??"",r=Fn(t);if(!r)return;return{...r,unreadMessageCount:0,notificationStatus:e.muteFlag?i.OPEN:i.CLOSE,notificationLevel:p(e.pushNotificationLevel)&&0!==e.pushNotificationLevel&&f(c[e.pushNotificationLevel])?e.pushNotificationLevel:e.muteFlag?c.AT_USER_NOTIFICATION:c.NOT_SET,isTop:!!e.stickyFlag,lastUnreadTime:0}};class ni{constructor(e,t){d(this,"storageKey",void 0),d(this,"eventEmitter",void 0),d(this,"isPulling",!1),this.storageKey=`con-s-${e}-${t}`,this.eventEmitter=new B}async pull(){if(this.isPulling)return;let e;this.isPulling=!0;const r=Rt.get(this.storageKey);e=p(r)&&r>0?r:oo()-1e4;let{code:n,data:o}=await(e=>Nn.send(j.GetDialogChangedStatus,{time:tn.fromNumber(e)},{encoder:Vn.GetNewSettingDialogListReq,decoder:Un.GetNewSettingDialogListResp}))(e);n===t.SUCCESS&&(o.setTime.toNumber()>0&&Rt.set(this.storageKey,o.setTime.toNumber()),o.briefDialog&&Ct(o.briefDialog).forEach((e=>{const t=o.briefDialog[e],r=ri(t);r&&this.eventEmitter.emit("STATUS_CHANGED",r)}))),this.isPulling=!1}watch(e){this.eventEmitter.on("STATUS_CHANGED",(t=>{e(t)}))}}class oi{constructor(e,t,r){d(this,"updatedConversationFunc",void 0),d(this,"store",void 0),d(this,"draftMap",new Map),d(this,"localConversationSet",new Set),d(this,"updatedConversations",[]),d(this,"notify",void 0),d(this,"statusManager",void 0),this.updatedConversationFunc=r,this.store=new ti(e,t),this.notify=St(this.notifyConversationChanged.bind(this),0),this.statusManager=new ni(e,t),this.statusManager.watch((e=>{this.addStatus(e,!0)}))}getConversationKey(e){return`${e.conversationType}_${e.targetId}_${e.channelId??""}`}setUpdatedConversation(e){const t=this.updatedConversations.findIndex((t=>this.getConversationKey(e.conversation)===this.getConversationKey(t.conversation)));t>=0?(e={conversation:Object.assign(this.updatedConversations[t].conversation,e.conversation),updatedItems:Object.assign(this.updatedConversations[t].updatedItems,e.updatedItems)},this.updatedConversations[t]=e):this.updatedConversations.push(e),this.notify()}notifyConversationChanged(){var e;const t=this.updatedConversations.map((e=>({conversation:{...e.conversation,...this.store.get(e.conversation)},updatedItems:e.updatedItems})));this.updatedConversations=[],null===(e=this.updatedConversationFunc)||void 0===e||e.call(this,t)}syncConversationStatus(){this.statusManager.pull()}async loadConvsationsIfNotExist(e){if(null==e||!e.length)return;const r=e.filter((e=>!this.localConversationSet.has(this.getConversationKey(e))));if(!r.length)return;const n=r.map(Pn).filter(O);if(!n.length)return;const{code:o,data:i}=await(e=>Nn.send(j.GetBriefDialogList,{destId:e},{encoder:Vn.GetBriefDialogListReq,decoder:Un.GetBriefDialogListResp}))(n);o===t.SUCCESS&&Ct(i.briefDialog).forEach((e=>{const t=i.briefDialog[e],r=ri(t);r&&(this.localConversationSet.add(this.getConversationKey(r)),this.addStatus(r,!0))}))}addLocalConversation(e){const{conversationType:t,targetId:r,channelId:n,isTop:o,notificationStatus:i,notificationLevel:s}=e;this.localConversationSet.add(this.getConversationKey(e)),this.addStatus({conversationType:t,targetId:r,channelId:n,isTop:o,notificationStatus:i,notificationLevel:s},!1)}addStatus(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{conversationType:r,targetId:n,notificationStatus:o,notificationLevel:i,isTop:s,channelId:a}=e,c={conversationType:r,targetId:n,channelId:a},l=oo(),u=this.store.get(c),d={};f(i)&&u.notificationLevel!==i&&(d.notificationLevel={time:l,val:i}),f(o)&&u.notificationStatus!==o&&(d.notificationStatus={time:l,val:o}),f(s)&&u.isTop!==s&&(d.isTop={time:l,val:s}),this.store.set(c,{notificationStatus:o,isTop:s,notificationLevel:i}),Object.keys(d).length&&t&&this.setUpdatedConversation({conversation:c,updatedItems:d})}setConversationCacheByMessage(e){const{conversationType:t,isPersited:r,targetId:n,channelId:o}=e,i={conversationType:t,targetId:n,channelId:o},s={conversation:i,updatedItems:{}},a=Qo(this.get(i));this.store.updateUnreadCount(e),this.store.updateMentionedData(e);const c=this.get(i);a.unreadMessageCount!==c.unreadMessageCount&&(s.updatedItems.unreadMessageCount={time:e.sentTime,val:c.unreadMessageCount}),a.hasMentioned!==c.hasMentioned&&(s.updatedItems.hasMentioned={time:e.sentTime,val:c.hasMentioned}),a.unreadMentionedCount!==c.unreadMentionedCount&&(s.updatedItems.unreadMentionedCount={time:e.sentTime,val:c.unreadMentionedCount}),r&&(s.conversation.latestMessage=e,s.updatedItems.latestMessage={time:e.sentTime,val:e}),Object.keys(s.updatedItems).length&&this.setUpdatedConversation(s)}get(e){return this.store.get(e)}getAllUnreadCount(e,t){const r=this.store.getAll();let n=0;return r.forEach((r=>{let{unreadMessageCount:o,notificationStatus:s,notificationLevel:a,conversationType:c}=r;o=o||0;const l=s===i.OPEN||a>0;!t&&l||(e.length>0?e.includes(+c)&&(n+=+o):n+=+o)})),n}getUnreadCount(e){return this.store.get(e).unreadMessageCount||0}clearUnreadCount(e){const t=this.store.get(e),{unreadMessageCount:r,unreadMentionedCount:n}=t;(r||n)&&(t.unreadMessageCount=0,t.hasMentioned=!1,t.unreadMentionedCount=0),this.store.set(e,t);const o={};r&&(o.unreadMessageCount={val:0,time:oo()}),n&&(o.hasMentioned={val:!1,time:oo()},o.unreadMentionedCount={val:0,time:oo()}),Object.keys(o).length&&this.setUpdatedConversation({conversation:e,updatedItems:o})}clearAllUnreadCount(){this.store.getAll().forEach((e=>this.clearUnreadCount(e)))}getNotificationLevel(e){return this.store.get(e).notificationLevel}getNotificationStatus(e){return this.store.get(e).notificationStatus||2}setDraft(e,t){this.draftMap.set(this.getConversationKey(e),t)}getDraft(e){return this.draftMap.get(this.getConversationKey(e))??""}clearDraft(e){this.draftMap.delete(this.getConversationKey(e))}getBlockConversationList(){return this.store.getAll().filter((e=>e.notificationStatus===i.OPEN||e.notificationLevel>0)).map((e=>({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId})))}getTopConversationList(){return(this.store.getAll()||{}).filter((e=>e.isTop)).map((e=>({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId})))}getUnreadMentionedCount(e){return this.get(e).unreadMentionedCount||0}getAllUnreadMentionedCount(){const e=this.store.getAll();let t=0;return e.forEach((e=>{let{unreadMentionedCount:r}=e;r=r||0,t+=Number(r)})),t}getAllConversationState(){return this.store.getAll().map((e=>{let{unreadMessageCount:t,unreadMentionedCount:r,conversationType:n,targetId:o,channelId:i}=e;return{conversationType:n,targetId:o,channelId:i,unreadCount:t,unreadMentionedCount:r??0}})).filter((e=>e.unreadCount>0))}destroyed(){this.updatedConversationFunc=void 0}}const ii={addStatus:function(e,t){},setConversationCacheByMessage:function(e){},get:function(e){return null},getAllUnreadCount:function(e,t){return 0},getUnreadCount:function(e){return 0},clearUnreadCount:function(e){},clearAllUnreadCount(){},getNotificationLevel:function(e){return c.NOT_SET},getNotificationStatus:function(e){return i.CLOSE},setDraft:function(e,t){},getDraft:function(e){return""},clearDraft:function(e){},getBlockConversationList:function(){return[]},getTopConversationList:function(){return[]},getUnreadMentionedCount:function(e){return 0},getAllUnreadMentionedCount:function(){return 0},getAllConversationState:function(){return[]},addLocalConversation:function(e){},loadConvsationsIfNotExist:function(e){},destroyed(){},syncConversationStatus:function(){}};let si;var ai={create(e,t,r){si=new oi(e,t,r)},get:()=>si??ii};class ci{constructor(e,t){d(this,"watcher",void 0),d(this,"pullingMsg",!1),d(this,"letterbox",void 0),d(this,"serverMsgSeqno",tn.ZERO),d(this,"pullOfflineFinished",!1),d(this,"intervalTimer",void 0),d(this,"retryTimer",void 0),d(this,"latestSyncTimestamp",0),d(this,"started",!1),this.watcher=e,this.letterbox=new Vo(t.appkey,xn.uid)}start(){this.started=!0,this.pullOfflineFinished=!1,this.startPullInterval()}stop(){this.started=!1,this.stopPullInterval(),this.cancelRetryTask()}syncMsg(e){this.serverMsgSeqno=e,this.pullMsg()}startPullInterval(){this.stopPullInterval();this.intervalTimer=setInterval((()=>{Date.now()-this.latestSyncTimestamp>=18e4&&this.pullMsg()}),3e4),this.latestSyncTimestamp=Date.now(),this.pullMsg()}stopPullInterval(){this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null)}try2RePullMsg(){this.retryTimer=setTimeout((()=>{this.retryTimer=null,this.pullMsg()}),1e3)}cancelRetryTask(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}async pullMsg(){if(this.pullingMsg)return;if(!this.started)return;this.cancelRetryTask(),this.pullingMsg=!0;const e=this.letterbox.getInboxOffset();this.pullOfflineFinished||E.info(`pullMsg -> time: ${e}`),this.latestSyncTimestamp=Date.now();const{code:r,data:n}=await((e,t)=>Nn.send(j.GetNewMessage,{offset:e,rows:t},{encoder:Vn.GetNewMessageReq,decoder:Un.GetNewMessageResp}))(e,60);if(r!==t.SUCCESS)return this.pullOfflineFinished||E.warn("pullMsg failed -> code:",r),this.pullingMsg=!1,void this.try2RePullMsg();const{offset:o,seqno:i,msg:a}=n,c=Object.keys(a).map(Fn).filter((e=>f(e)));ai.get().loadConvsationsIfNotExist(c),Yo.parse(a,((e,t)=>{const r=[],n=[],a=!this.pullOfflineFinished;var c,l;(Object.keys(t).forEach((e=>{const o=t[e],i=[];if(o.forEach((e=>{e.messageDirection===s.SEND&&e.messageId&&so.has(e.messageId)?so.remove(e.messageId):e.messageType===ko&&co.has(e.content.messageUId)?co.remove(e.content.messageUId):(e.isOffLineMessage=a,ai.get().setConversationCacheByMessage(e),i.push(e))})),r.push(...i),this.isExistPersistedMessage(i)){const t=Fn(e);t&&n.push(t)}})),r.length)&&(null===(c=(l=this.watcher).batchMessage)||void 0===c||c.call(l,r));if(n.length&&ai.get().loadConvsationsIfNotExist(n),e){var u;i.ge(this.serverMsgSeqno)&&(this.serverMsgSeqno=i);const e=this.serverMsgSeqno.lessThanOrEqual(o);this.pullOfflineFinished||E.info(`pullMsg success -> syncTime: ${o}, finished: ${e}`),null===(u=this.letterbox)||void 0===u||u.setInboxOffset(o),this.pullingMsg=!1,e&&!this.pullOfflineFinished&&(this.pullOfflineFinished=!0,this.watcher.pullFinished&&this.watcher.pullFinished()),e||this.pullMsg()}}))}isExistPersistedMessage(e){return e.some((e=>e.isPersited))}}class li{static init(e){return this._loader||(this._loader=new li(e)),this._loader}static get loader(){return this._loader}constructor(t){d(this,"options",void 0),d(this,"connectionStatus",e.DISCONNECTED),d(this,"isInternalConnected",!1),d(this,"watcher",void 0),d(this,"messageLoader",void 0),this.options=t,this.watcher={onConnecting:void 0,onConnected:void 0,onDisconnect:void 0,onSuspend:void 0,pullFinished:void 0,batchMessage:void 0,conversationState:void 0},Nn.setServerInfo(this.getWebSocketUrl()),Nn.setCallback({status:this.connectionStatusListener.bind(this),message:this.messageListener.bind(this),onAuth:this.authListener.bind(this)},{needReAuth:this.needReAuthProvider.bind(this),profile:this.needProfileProvider.bind(this)}),this.registerMessage()}getWebSocketUrl(){var e;const t=null===(e=this.options)||void 0===e?void 0:e.serverInfo;return O(t)?w(r=t)&&/wss?:\/\//.test(r)?t:"ws://"+t:"wss://tt.mimelabs.xyz:8991";var r}registerMessage(){uo(No),uo(xo),uo(Do),uo(Mo),uo(Po),uo(Go),uo(Fo),uo(qo),uo(Bo),uo(Uo)}async connect(r){if(this.connectionStatus===e.CONNECTED)return{code:t.SUCCESS,userId:xn.uid+""};if(this.connectionStatus===e.CONNECTING)return{code:t.BIZ_ERROR_CONNECTING};if("string"!=typeof r||0===r.length)return{code:t.RC_CONN_USER_OR_PASSWD_ERROR};jn.imInitToken=r;const n=await Nn.connect(r);var o;n===t.SUCCESS&&(this.isInternalConnected=!0,ai.get().destroyed(),ai.create(this.options.appkey,xn.uid,this.watcher.conversationState),null===(o=this.messageLoader)||void 0===o||o.stop(),this.messageLoader=new ci(this.watcher,this.options),no(),so.reset(),co.reset(),Ho.reset());return{code:n,userId:xn.uid+""}}reconnect(){return this.isInternalConnected?Promise.resolve({code:t.CAN_NOT_RECONNECT}):this.connect(jn.imInitToken)}disconnect(){return this.isInternalConnected=!1,Nn.close(),Promise.resolve()}getConnectionStatus(){return this.connectionStatus}assignWatcher(e){Ct(this.watcher).forEach((t=>{if(Object.prototype.hasOwnProperty.call(e,t)){const r=e[t];this.watcher[t]=v(r)?r:void 0}}))}resetWatcher(){Ct(this.watcher).forEach((e=>{this.watcher[e]=void 0}))}async connectionStatusListener(t){this.connectionStatus=t,setTimeout((()=>{switch(t){case e.BLOCKED:case e.KICKED_OFFLINE_BY_OTHER_CLIENT:case e.DISCONNECT_BY_SERVER:this.handleDisconnect();break;case e.CONNECTING:this.handleConnecting();break;case e.CONNECTED:this.handleConnected();break;case e.DISCONNECTED:this.handleDisconnect()}}),0)}handleConnecting(){var e,t;null===(e=(t=this.watcher).onConnecting)||void 0===e||e.call(t)}handleConnected(){var t,r,n;null===(t=(r=this.watcher).onConnected)||void 0===t||t.call(r),null===(n=this.messageLoader)||void 0===n||n.start(),setTimeout((()=>{this.connectionStatus===e.CONNECTED&&ai.get().syncConversationStatus()}),2e3)}handleDisconnect(){var e,t,r;null===(e=(t=this.watcher).onDisconnect)||void 0===e||e.call(t),null===(r=this.messageLoader)||void 0===r||r.stop()}handleSuspend(){var e,t;null===(e=(t=this.watcher).onSuspend)||void 0===e||e.call(t)}messageListener(e,t){if(e===j.NewMessagePush){var r;const e=Un.NewMessageNotificationResp.decode(t);null===(r=this.messageLoader)||void 0===r||r.syncMsg(e.seqno)}else e===j.DialogChangedPush&&ai.get().syncConversationStatus()}authListener(e){jn.setFileServerInfo(e.fileDomain,e.dialogFileDomain,e.cert),xn.setLogged(e,jn.imInitToken)}needReAuthProvider(){return!xn.user.active||xn.user.token!==jn.imInitToken}needProfileProvider(){if(!this.needReAuthProvider()){const{deviceId:e,sessionId:t,uid:r}=xn.user;return{deviceId:e,sessionId:t,uid:r}}return null}}d(li,"_loader",void 0);var ui,di,hi,fi,pi={exports:{}},gi={exports:{}},yi={exports:{}},vi={exports:{}};var mi,bi={};var wi,Oi,Ci,_i,Si,Ii,Ei,Ti,Ri,ki,Ai,Ni,xi,Di={};function Mi(){return wi||(wi=1,function(e){var t=Di,r=fs(),n=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function o(e,t){var r=0,o={};for(t|=0;r<e.length;)o[n[r+t]]=e[r++];return o}t.basic=o([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),t.defaults=o([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",r.emptyArray,null]),t.long=o([0,0,0,1,1],7),t.mapKey=o([0,0,0,5,5,0,0,0,1,1,0,2],2),t.packed=o([1,5,0,0,0,5,5,0,0,0,1,1,0])}()),Di}function Li(){if(Ci)return Oi;Ci=1,Oi=s;var e=ps();((s.prototype=Object.create(e.prototype)).constructor=s).className="Field";var t,r=gs(),n=Mi(),o=fs(),i=/^required|optional|repeated$/;function s(t,r,s,a,c,l,u){if(o.isObject(a)?(u=c,l=a,a=c=void 0):o.isObject(c)&&(u=l,l=c,c=void 0),e.call(this,t,l),!o.isInteger(r)||r<0)throw TypeError("id must be a non-negative integer");if(!o.isString(s))throw TypeError("type must be a string");if(void 0!==a&&!i.test(a=a.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==c&&!o.isString(c))throw TypeError("extend must be a string");"proto3_optional"===a&&(a="optional"),this.rule=a&&"optional"!==a?a:void 0,this.type=s,this.id=r,this.extend=c||void 0,this.required="required"===a,this.optional=!this.required,this.repeated="repeated"===a,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!o.Long&&void 0!==n.long[s],this.bytes="bytes"===s,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=u}return s.fromJSON=function(e,t){return new s(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(s.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),s.prototype.setOption=function(t,r,n){return"packed"===t&&(this._packed=null),e.prototype.setOption.call(this,t,r,n)},s.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return o.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},s.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=n.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof t?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof r&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof r)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=o.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var i;o.base64.test(this.typeDefault)?o.base64.decode(this.typeDefault,i=o.newBuffer(o.base64.length(this.typeDefault)),0):o.utf8.write(this.typeDefault,i=o.newBuffer(o.utf8.length(this.typeDefault)),0),this.typeDefault=i}return this.map?this.defaultValue=o.emptyObject:this.repeated?this.defaultValue=o.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof t&&(this.parent.ctor.prototype[this.name]=this.defaultValue),e.prototype.resolve.call(this)},s.d=function(e,t,r,n){return"function"==typeof t?t=o.decorateType(t).name:t&&"object"==typeof t&&(t=o.decorateEnum(t).name),function(i,a){o.decorateType(i.constructor).add(new s(a,e,t,r,{default:n}))}},s._configure=function(e){t=e},Oi}function Bi(){if(Si)return _i;Si=1,_i=n;var e=ps();((n.prototype=Object.create(e.prototype)).constructor=n).className="OneOf";var t=Li(),r=fs();function n(t,r,n,o){if(Array.isArray(r)||(n=r,r=void 0),e.call(this,t,n),void 0!==r&&!Array.isArray(r))throw TypeError("fieldNames must be an Array");this.oneof=r||[],this.fieldsArray=[],this.comment=o}function o(e){if(e.parent)for(var t=0;t<e.fieldsArray.length;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}return n.fromJSON=function(e,t){return new n(e,t.oneof,t.options,t.comment)},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])},n.prototype.add=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,o(this),this},n.prototype.remove=function(e){if(!(e instanceof t))throw TypeError("field must be a Field");var r=this.fieldsArray.indexOf(e);if(r<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(r,1),(r=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(r,1),e.partOf=null,this},n.prototype.onAdd=function(t){e.prototype.onAdd.call(this,t);for(var r=0;r<this.oneof.length;++r){var n=t.get(this.oneof[r]);n&&!n.partOf&&(n.partOf=this,this.fieldsArray.push(n))}o(this)},n.prototype.onRemove=function(t){for(var r,n=0;n<this.fieldsArray.length;++n)(r=this.fieldsArray[n]).parent&&r.parent.remove(r);e.prototype.onRemove.call(this,t)},n.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(t,o){r.decorateType(t.constructor).add(new n(o,e)),Object.defineProperty(t,o,{get:r.oneOfGetter(e),set:r.oneOfSetter(e)})}},_i}function Ui(){if(Ei)return Ii;Ei=1,Ii=c;var e=ps();((c.prototype=Object.create(e.prototype)).constructor=c).className="Namespace";var t,r,n,o=Li(),i=fs(),s=Bi();function a(e,t){if(e&&e.length){for(var r={},n=0;n<e.length;++n)r[e[n].name]=e[n].toJSON(t);return r}}function c(t,r){e.call(this,t,r),this.nested=void 0,this._nestedArray=null}function l(e){return e._nestedArray=null,e}return c.fromJSON=function(e,t){return new c(e,t.options).addJSON(t.nested)},c.arrayToJSON=a,c.isReservedId=function(e,t){if(e)for(var r=0;r<e.length;++r)if("string"!=typeof e[r]&&e[r][0]<=t&&e[r][1]>t)return!0;return!1},c.isReservedName=function(e,t){if(e)for(var r=0;r<e.length;++r)if(e[r]===t)return!0;return!1},Object.defineProperty(c.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=i.toArray(this.nested))}}),c.prototype.toJSON=function(e){return i.toObject(["options",this.options,"nested",a(this.nestedArray,e)])},c.prototype.addJSON=function(e){if(e)for(var i,s=Object.keys(e),a=0;a<s.length;++a)i=e[s[a]],this.add((void 0!==i.fields?t.fromJSON:void 0!==i.values?n.fromJSON:void 0!==i.methods?r.fromJSON:void 0!==i.id?o.fromJSON:c.fromJSON)(s[a],i));return this},c.prototype.get=function(e){return this.nested&&this.nested[e]||null},c.prototype.getEnum=function(e){if(this.nested&&this.nested[e]instanceof n)return this.nested[e].values;throw Error("no such enum: "+e)},c.prototype.add=function(e){if(!(e instanceof o&&void 0!==e.extend||e instanceof t||e instanceof s||e instanceof n||e instanceof r||e instanceof c))throw TypeError("object must be a valid nested object");if(this.nested){var i=this.get(e.name);if(i){if(!(i instanceof c&&e instanceof c)||i instanceof t||i instanceof r)throw Error("duplicate name '"+e.name+"' in "+this);for(var a=i.nestedArray,u=0;u<a.length;++u)e.add(a[u]);this.remove(i),this.nested||(this.nested={}),e.setOptions(i.options,!0)}}else this.nested={};return this.nested[e.name]=e,e.onAdd(this),l(this)},c.prototype.remove=function(t){if(!(t instanceof e))throw TypeError("object must be a ReflectionObject");if(t.parent!==this)throw Error(t+" is not a member of "+this);return delete this.nested[t.name],Object.keys(this.nested).length||(this.nested=void 0),t.onRemove(this),l(this)},c.prototype.define=function(e,t){if(i.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&""===e[0])throw Error("path must be relative");for(var r=this;e.length>0;){var n=e.shift();if(r.nested&&r.nested[n]){if(!((r=r.nested[n])instanceof c))throw Error("path conflicts with non-namespace objects")}else r.add(r=new c(n))}return t&&r.addJSON(t),r},c.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t<e.length;)e[t]instanceof c?e[t++].resolveAll():e[t++].resolve();return this.resolve()},c.prototype.lookup=function(e,t,r){if("boolean"==typeof t?(r=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),i.isString(e)&&e.length){if("."===e)return this.root;e=e.split(".")}else if(!e.length)return this;if(""===e[0])return this.root.lookup(e.slice(1),t);var n=this.get(e[0]);if(n){if(1===e.length){if(!t||t.indexOf(n.constructor)>-1)return n}else if(n instanceof c&&(n=n.lookup(e.slice(1),t,!0)))return n}else for(var o=0;o<this.nestedArray.length;++o)if(this._nestedArray[o]instanceof c&&(n=this._nestedArray[o].lookup(e,t,!0)))return n;return null===this.parent||r?null:this.parent.lookup(e,t)},c.prototype.lookupType=function(e){var r=this.lookup(e,[t]);if(!r)throw Error("no such type: "+e);return r},c.prototype.lookupEnum=function(e){var t=this.lookup(e,[n]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},c.prototype.lookupTypeOrEnum=function(e){var r=this.lookup(e,[t,n]);if(!r)throw Error("no such Type or Enum '"+e+"' in "+this);return r},c.prototype.lookupService=function(e){var t=this.lookup(e,[r]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},c._configure=function(e,o,i){t=e,r=o,n=i},Ii}function ji(){if(Ri)return Ti;Ri=1,Ti=n;var e=Li();((n.prototype=Object.create(e.prototype)).constructor=n).className="MapField";var t=Mi(),r=fs();function n(t,n,o,i,s,a){if(e.call(this,t,n,i,void 0,void 0,s,a),!r.isString(o))throw TypeError("keyType must be a string");this.keyType=o,this.resolvedKeyType=null,this.map=!0}return n.fromJSON=function(e,t){return new n(e,t.id,t.keyType,t.type,t.options,t.comment)},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},n.prototype.resolve=function(){if(this.resolved)return this;if(void 0===t.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return e.prototype.resolve.call(this)},n.d=function(e,t,o){return"function"==typeof o?o=r.decorateType(o).name:o&&"object"==typeof o&&(o=r.decorateEnum(o).name),function(i,s){r.decorateType(i.constructor).add(new n(s,e,t,o))}},Ti}function Pi(){if(Ai)return ki;Ai=1,ki=r;var e=ps();((r.prototype=Object.create(e.prototype)).constructor=r).className="Method";var t=fs();function r(r,n,o,i,s,a,c,l,u){if(t.isObject(s)?(c=s,s=a=void 0):t.isObject(a)&&(c=a,a=void 0),void 0!==n&&!t.isString(n))throw TypeError("type must be a string");if(!t.isString(o))throw TypeError("requestType must be a string");if(!t.isString(i))throw TypeError("responseType must be a string");e.call(this,r,c),this.type=n||"rpc",this.requestType=o,this.requestStream=!!s||void 0,this.responseType=i,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=l,this.parsedOptions=u}return r.fromJSON=function(e,t){return new r(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},r.prototype.toJSON=function(e){var r=!!e&&Boolean(e.keepComments);return t.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",r?this.comment:void 0,"parsedOptions",this.parsedOptions])},r.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),e.prototype.resolve.call(this))},ki}function Fi(){if(xi)return Ni;xi=1,Ni=o;var e=Ui();((o.prototype=Object.create(e.prototype)).constructor=o).className="Service";var t=Pi(),r=fs(),n=Lr;function o(t,r){e.call(this,t,r),this.methods={},this._methodsArray=null}function i(e){return e._methodsArray=null,e}return o.fromJSON=function(e,r){var n=new o(e,r.options);if(r.methods)for(var i=Object.keys(r.methods),s=0;s<i.length;++s)n.add(t.fromJSON(i[s],r.methods[i[s]]));return r.nested&&n.addJSON(r.nested),n.comment=r.comment,n},o.prototype.toJSON=function(t){var n=e.prototype.toJSON.call(this,t),o=!!t&&Boolean(t.keepComments);return r.toObject(["options",n&&n.options||void 0,"methods",e.arrayToJSON(this.methodsArray,t)||{},"nested",n&&n.nested||void 0,"comment",o?this.comment:void 0])},Object.defineProperty(o.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=r.toArray(this.methods))}}),o.prototype.get=function(t){return this.methods[t]||e.prototype.get.call(this,t)},o.prototype.resolveAll=function(){for(var t=this.methodsArray,r=0;r<t.length;++r)t[r].resolve();return e.prototype.resolve.call(this)},o.prototype.add=function(r){if(this.get(r.name))throw Error("duplicate name '"+r.name+"' in "+this);return r instanceof t?(this.methods[r.name]=r,r.parent=this,i(this)):e.prototype.add.call(this,r)},o.prototype.remove=function(r){if(r instanceof t){if(this.methods[r.name]!==r)throw Error(r+" is not a member of "+this);return delete this.methods[r.name],r.parent=null,i(this)}return e.prototype.remove.call(this,r)},o.prototype.create=function(e,t,o){for(var i,s=new n.Service(e,t,o),a=0;a<this.methodsArray.length;++a){var c=r.lcFirst((i=this._methodsArray[a]).resolve().name).replace(/[^$\w_]/g,"");s[c]=r.codegen(["r","c"],r.isReserved(c)?c+"_":c)("return this.rpcCall(m,q,s,r,c)")({m:i,q:i.resolvedRequestType.ctor,s:i.resolvedResponseType.ctor})}return s},Ni}var Gi,qi,Hi,zi,Ki=Wi,Vi=Jt();function Wi(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)this[t[r]]=e[t[r]]}function $i(){if(qi)return Gi;qi=1,Gi=function(o){var i=r.codegen(["r","l"],o.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(o.fieldsArray.filter((function(e){return e.map})).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");o.group&&i("if((t&7)===4)")("break");i("switch(t>>>3){");for(var s=0;s<o.fieldsArray.length;++s){var a=o._fieldsArray[s].resolve(),c=a.resolvedType instanceof e?"int32":a.type,l="m"+r.safeProp(a.name);i("case %i: {",a.id),a.map?(i("if(%s===util.emptyObject)",l)("%s={}",l)("var c2 = r.uint32()+r.pos"),void 0!==t.defaults[a.keyType]?i("k=%j",t.defaults[a.keyType]):i("k=null"),void 0!==t.defaults[c]?i("value=%j",t.defaults[c]):i("value=null"),i("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",a.keyType)("case 2:"),void 0===t.basic[c]?i("value=types[%i].decode(r,r.uint32())",s):i("value=r.%s()",c),i("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==t.long[a.keyType]?i('%s[typeof k==="object"?util.longToHash(k):k]=value',l):i("%s[k]=value",l)):a.repeated?(i("if(!(%s&&%s.length))",l,l)("%s=[]",l),void 0!==t.packed[c]&&i("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",l,c)("}else"),void 0===t.basic[c]?i(a.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",l,s):i("%s.push(r.%s())",l,c)):void 0===t.basic[c]?i(a.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",l,s):i("%s=r.%s()",l,c),i("break")("}")}for(i("default:")("r.skipType(t&7)")("break")("}")("}"),s=0;s<o._fieldsArray.length;++s){var u=o._fieldsArray[s];u.required&&i("if(!m.hasOwnProperty(%j))",u.name)("throw util.ProtocolError(%j,{instance:m})",n(u))}return i("return m")};var e=gs(),t=Mi(),r=fs();function n(e){return"missing required '"+e.name+"'"}return Gi}function Ji(){if(zi)return Hi;zi=1,Hi=function(e){var i=t.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),s=e.oneofsArray,a={};s.length&&i("var p={}");for(var c=0;c<e.fieldsArray.length;++c){var l=e._fieldsArray[c].resolve(),u="m"+t.safeProp(l.name);if(l.optional&&i("if(%s!=null&&m.hasOwnProperty(%j)){",u,l.name),l.map)i("if(!util.isObject(%s))",u)("return%j",r(l,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),o(i,l,"k[i]"),n(i,l,c,u+"[k[i]]")("}");else if(l.repeated)i("if(!Array.isArray(%s))",u)("return%j",r(l,"array"))("for(var i=0;i<%s.length;++i){",u),n(i,l,c,u+"[i]")("}");else{if(l.partOf){var d=t.safeProp(l.partOf.name);1===a[l.partOf.name]&&i("if(p%s===1)",d)("return%j",l.partOf.name+": multiple values"),a[l.partOf.name]=1,i("p%s=1",d)}n(i,l,c,u)}l.optional&&i("}")}return i("return null")};var e=gs(),t=fs();function r(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function n(t,n,o,i){if(n.resolvedType)if(n.resolvedType instanceof e){t("switch(%s){",i)("default:")("return%j",r(n,"enum value"));for(var s=Object.keys(n.resolvedType.values),a=0;a<s.length;++a)t("case %i:",n.resolvedType.values[s[a]]);t("break")("}")}else t("{")("var e=types[%i].verify(%s);",o,i)("if(e)")("return%j+e",n.name+".")("}");else switch(n.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":t("if(!util.isInteger(%s))",i)("return%j",r(n,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":t("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",i,i,i,i)("return%j",r(n,"integer|Long"));break;case"float":case"double":t('if(typeof %s!=="number")',i)("return%j",r(n,"number"));break;case"bool":t('if(typeof %s!=="boolean")',i)("return%j",r(n,"boolean"));break;case"string":t("if(!util.isString(%s))",i)("return%j",r(n,"string"));break;case"bytes":t('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',i,i,i)("return%j",r(n,"buffer"))}return t}function o(e,t,n){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",n)("return%j",r(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",n)("return%j",r(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",n)("return%j",r(t,"boolean key"))}return e}return Hi}Wi.create=function(e){return this.$type.create(e)},Wi.encode=function(e,t){return this.$type.encode(e,t)},Wi.encodeDelimited=function(e,t){return this.$type.encodeDelimited(e,t)},Wi.decode=function(e){return this.$type.decode(e)},Wi.decodeDelimited=function(e){return this.$type.decodeDelimited(e)},Wi.verify=function(e){return this.$type.verify(e)},Wi.fromObject=function(e){return this.$type.fromObject(e)},Wi.toObject=function(e,t){return this.$type.toObject(e,t)},Wi.prototype.toJSON=function(){return this.$type.toObject(this,Vi.toJSONOptions)};var Zi,Xi={};function Yi(){return Zi||(Zi=1,function(e){var t=e,r=gs(),n=fs();function o(e,t,n,o){var i=!1;if(t.resolvedType)if(t.resolvedType instanceof r){e("switch(d%s){",o);for(var s=t.resolvedType.values,a=Object.keys(s),c=0;c<a.length;++c)s[a[c]]!==t.typeDefault||i||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',o,o,o),t.repeated||e("break"),i=!0),e("case%j:",a[c])("case %i:",s[a[c]])("m%s=%j",o,s[a[c]])("break");e("}")}else e('if(typeof d%s!=="object")',o)("throw TypeError(%j)",t.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",o,n,o);else{var l=!1;switch(t.type){case"double":case"float":e("m%s=Number(d%s)",o,o);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",o,o);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",o,o);break;case"uint64":l=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",o,o,l)('else if(typeof d%s==="string")',o)("m%s=parseInt(d%s,10)",o,o)('else if(typeof d%s==="number")',o)("m%s=d%s",o,o)('else if(typeof d%s==="object")',o)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",o,o,o,l?"true":"");break;case"bytes":e('if(typeof d%s==="string")',o)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",o,o,o)("else if(d%s.length >= 0)",o)("m%s=d%s",o,o);break;case"string":e("m%s=String(d%s)",o,o);break;case"bool":e("m%s=Boolean(d%s)",o,o)}}return e}function i(e,t,n,o){if(t.resolvedType)t.resolvedType instanceof r?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",o,n,o,o,n,o,o):e("d%s=types[%i].toObject(m%s,o)",o,n,o);else{var i=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",o,o,o,o);break;case"uint64":i=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',o)("d%s=o.longs===String?String(m%s):m%s",o,o,o)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",o,o,o,o,i?"true":"",o);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",o,o,o,o,o);break;default:e("d%s=m%s",o,o)}}return e}t.fromObject=function(e){var t=e.fieldsArray,i=n.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return i("return new this.ctor");i("var m=new this.ctor");for(var s=0;s<t.length;++s){var a=t[s].resolve(),c=n.safeProp(a.name);a.map?(i("if(d%s){",c)('if(typeof d%s!=="object")',c)("throw TypeError(%j)",a.fullName+": object expected")("m%s={}",c)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",c),o(i,a,s,c+"[ks[i]]")("}")("}")):a.repeated?(i("if(d%s){",c)("if(!Array.isArray(d%s))",c)("throw TypeError(%j)",a.fullName+": array expected")("m%s=[]",c)("for(var i=0;i<d%s.length;++i){",c),o(i,a,s,c+"[i]")("}")("}")):(a.resolvedType instanceof r||i("if(d%s!=null){",c),o(i,a,s,c),a.resolvedType instanceof r||i("}"))}return i("return m")},t.toObject=function(e){var t=e.fieldsArray.slice().sort(n.compareFieldsById);if(!t.length)return n.codegen()("return {}");for(var o=n.codegen(["m","o"],e.name+"$toObject")("if(!o)")("o={}")("var d={}"),s=[],a=[],c=[],l=0;l<t.length;++l)t[l].partOf||(t[l].resolve().repeated?s:t[l].map?a:c).push(t[l]);if(s.length){for(o("if(o.arrays||o.defaults){"),l=0;l<s.length;++l)o("d%s=[]",n.safeProp(s[l].name));o("}")}if(a.length){for(o("if(o.objects||o.defaults){"),l=0;l<a.length;++l)o("d%s={}",n.safeProp(a[l].name));o("}")}if(c.length){for(o("if(o.defaults){"),l=0;l<c.length;++l){var u=c[l],d=n.safeProp(u.name);if(u.resolvedType instanceof r)o("d%s=o.enums===String?%j:%j",d,u.resolvedType.valuesById[u.typeDefault],u.typeDefault);else if(u.long)o("if(util.Long){")("var n=new util.Long(%i,%i,%j)",u.typeDefault.low,u.typeDefault.high,u.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",d)("}else")("d%s=o.longs===String?%j:%i",d,u.typeDefault.toString(),u.typeDefault.toNumber());else if(u.bytes){var h="["+Array.prototype.slice.call(u.typeDefault).join(",")+"]";o("if(o.bytes===String)d%s=%j",d,String.fromCharCode.apply(String,u.typeDefault))("else{")("d%s=%s",d,h)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",d,d)("}")}else o("d%s=%j",d,u.typeDefault)}o("}")}var f=!1;for(l=0;l<t.length;++l){u=t[l];var p=e._fieldsArray.indexOf(u);d=n.safeProp(u.name);u.map?(f||(f=!0,o("var ks2")),o("if(m%s&&(ks2=Object.keys(m%s)).length){",d,d)("d%s={}",d)("for(var j=0;j<ks2.length;++j){"),i(o,u,p,d+"[ks2[j]]")("}")):u.repeated?(o("if(m%s&&m%s.length){",d,d)("d%s=[]",d)("for(var j=0;j<m%s.length;++j){",d),i(o,u,p,d+"[j]")("}")):(o("if(m%s!=null&&m.hasOwnProperty(%j)){",d,u.name),i(o,u,p,d),u.partOf&&o("if(o.oneofs)")("d%s=%j",n.safeProp(u.partOf.name),u.name)),o("}")}return o("return d")}}(Xi)),Xi}var Qi,es,ts,rs,ns,os,is,ss,as,cs,ls,us={};function ds(){if(es)return Qi;es=1,Qi=g;var e=Ui();((g.prototype=Object.create(e.prototype)).constructor=g).className="Type";var t=gs(),r=Bi(),n=Li(),o=ji(),i=Fi(),s=Ki,a=mr,c=Xt,l=fs(),u=ys(),d=$i(),h=Ji(),f=Yi(),p=us;function g(t,r){e.call(this,t,r),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function y(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}return Object.defineProperties(g.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t<e.length;++t){var r=this.fields[e[t]],n=r.id;if(this._fieldsById[n])throw Error("duplicate id "+n+" in "+this);this._fieldsById[n]=r}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=l.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=l.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=g.generateConstructor(this)())},set:function(e){var t=e.prototype;t instanceof s||((e.prototype=new s).constructor=e,l.merge(e.prototype,t)),e.$type=e.prototype.$type=this,l.merge(e,s,!0),this._ctor=e;for(var r=0;r<this.fieldsArray.length;++r)this._fieldsArray[r].resolve();var n={};for(r=0;r<this.oneofsArray.length;++r)n[this._oneofsArray[r].resolve().name]={get:l.oneOfGetter(this._oneofsArray[r].oneof),set:l.oneOfSetter(this._oneofsArray[r].oneof)};r&&Object.defineProperties(e.prototype,n)}}}),g.generateConstructor=function(e){for(var t,r=l.codegen(["p"],e.name),n=0;n<e.fieldsArray.length;++n)(t=e._fieldsArray[n]).map?r("this%s={}",l.safeProp(t.name)):t.repeated&&r("this%s=[]",l.safeProp(t.name));return r("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")},g.fromJSON=function(s,a){var c=new g(s,a.options);c.extensions=a.extensions,c.reserved=a.reserved;for(var l=Object.keys(a.fields),u=0;u<l.length;++u)c.add((void 0!==a.fields[l[u]].keyType?o.fromJSON:n.fromJSON)(l[u],a.fields[l[u]]));if(a.oneofs)for(l=Object.keys(a.oneofs),u=0;u<l.length;++u)c.add(r.fromJSON(l[u],a.oneofs[l[u]]));if(a.nested)for(l=Object.keys(a.nested),u=0;u<l.length;++u){var d=a.nested[l[u]];c.add((void 0!==d.id?n.fromJSON:void 0!==d.fields?g.fromJSON:void 0!==d.values?t.fromJSON:void 0!==d.methods?i.fromJSON:e.fromJSON)(l[u],d))}return a.extensions&&a.extensions.length&&(c.extensions=a.extensions),a.reserved&&a.reserved.length&&(c.reserved=a.reserved),a.group&&(c.group=!0),a.comment&&(c.comment=a.comment),c},g.prototype.toJSON=function(t){var r=e.prototype.toJSON.call(this,t),n=!!t&&Boolean(t.keepComments);return l.toObject(["options",r&&r.options||void 0,"oneofs",e.arrayToJSON(this.oneofsArray,t),"fields",e.arrayToJSON(this.fieldsArray.filter((function(e){return!e.declaringField})),t)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",r&&r.nested||void 0,"comment",n?this.comment:void 0])},g.prototype.resolveAll=function(){for(var t=this.fieldsArray,r=0;r<t.length;)t[r++].resolve();var n=this.oneofsArray;for(r=0;r<n.length;)n[r++].resolve();return e.prototype.resolveAll.call(this)},g.prototype.get=function(e){return this.fields[e]||this.oneofs&&this.oneofs[e]||this.nested&&this.nested[e]||null},g.prototype.add=function(t){if(this.get(t.name))throw Error("duplicate name '"+t.name+"' in "+this);if(t instanceof n&&void 0===t.extend){if(this._fieldsById?this._fieldsById[t.id]:this.fieldsById[t.id])throw Error("duplicate id "+t.id+" in "+this);if(this.isReservedId(t.id))throw Error("id "+t.id+" is reserved in "+this);if(this.isReservedName(t.name))throw Error("name '"+t.name+"' is reserved in "+this);return t.parent&&t.parent.remove(t),this.fields[t.name]=t,t.message=this,t.onAdd(this),y(this)}return t instanceof r?(this.oneofs||(this.oneofs={}),this.oneofs[t.name]=t,t.onAdd(this),y(this)):e.prototype.add.call(this,t)},g.prototype.remove=function(t){if(t instanceof n&&void 0===t.extend){if(!this.fields||this.fields[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.fields[t.name],t.parent=null,t.onRemove(this),y(this)}if(t instanceof r){if(!this.oneofs||this.oneofs[t.name]!==t)throw Error(t+" is not a member of "+this);return delete this.oneofs[t.name],t.parent=null,t.onRemove(this),y(this)}return e.prototype.remove.call(this,t)},g.prototype.isReservedId=function(t){return e.isReservedId(this.reserved,t)},g.prototype.isReservedName=function(t){return e.isReservedName(this.reserved,t)},g.prototype.create=function(e){return new this.ctor(e)},g.prototype.setup=function(){for(var e=this.fullName,t=[],r=0;r<this.fieldsArray.length;++r)t.push(this._fieldsArray[r].resolve().resolvedType);this.encode=u(this)({Writer:c,types:t,util:l}),this.decode=d(this)({Reader:a,types:t,util:l}),this.verify=h(this)({types:t,util:l}),this.fromObject=f.fromObject(this)({types:t,util:l}),this.toObject=f.toObject(this)({types:t,util:l});var n=p[e];if(n){var o=Object.create(this);o.fromObject=this.fromObject,this.fromObject=n.fromObject.bind(o),o.toObject=this.toObject,this.toObject=n.toObject.bind(o)}return this},g.prototype.encode=function(e,t){return this.setup().encode(e,t)},g.prototype.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},g.prototype.decode=function(e,t){return this.setup().decode(e,t)},g.prototype.decodeDelimited=function(e){return e instanceof a||(e=a.create(e)),this.decode(e,e.uint32())},g.prototype.verify=function(e){return this.setup().verify(e)},g.prototype.fromObject=function(e){return this.setup().fromObject(e)},g.prototype.toObject=function(e,t){return this.setup().toObject(e,t)},g.d=function(e){return function(t){l.decorateType(t,e)}},Qi}function hs(){if(rs)return ts;rs=1,ts=c;var e=Ui();((c.prototype=Object.create(e.prototype)).constructor=c).className="Root";var t,r,n,o=Li(),i=gs(),s=Bi(),a=fs();function c(t){e.call(this,"",t),this.deferred=[],this.files=[]}function l(){}c.fromJSON=function(e,t){return t||(t=new c),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},c.prototype.resolvePath=a.path.resolve,c.prototype.fetch=a.fetch,c.prototype.load=function e(t,o,i){"function"==typeof o&&(i=o,o=void 0);var s=this;if(!i)return a.asPromise(e,s,t,o);var c=i===l;function u(e,t){if(i){var r=i;if(i=null,c)throw e;r(e,t)}}function d(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in n)return r}return null}function h(e,t){try{if(a.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),a.isString(t)){r.filename=e;var n,i=r(t,s,o),l=0;if(i.imports)for(;l<i.imports.length;++l)(n=d(i.imports[l])||s.resolvePath(e,i.imports[l]))&&f(n);if(i.weakImports)for(l=0;l<i.weakImports.length;++l)(n=d(i.weakImports[l])||s.resolvePath(e,i.weakImports[l]))&&f(n,!0)}else s.setOptions(t.options).addJSON(t.nested)}catch(e){u(e)}c||p||u(null,s)}function f(e,t){if(e=d(e)||e,!(s.files.indexOf(e)>-1))if(s.files.push(e),e in n)c?h(e,n[e]):(++p,setTimeout((function(){--p,h(e,n[e])})));else if(c){var r;try{r=a.fs.readFileSync(e).toString("utf8")}catch(e){return void(t||u(e))}h(e,r)}else++p,s.fetch(e,(function(r,n){--p,i&&(r?t?p||u(null,s):u(r):h(e,n))}))}var p=0;a.isString(t)&&(t=[t]);for(var g,y=0;y<t.length;++y)(g=s.resolvePath("",t[y]))&&f(g);if(c)return s;p||u(null,s)},c.prototype.loadSync=function(e,t){if(!a.isNode)throw Error("not supported");return this.load(e,t,l)},c.prototype.resolveAll=function(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map((function(e){return"'extend "+e.extend+"' in "+e.parent.fullName})).join(", "));return e.prototype.resolveAll.call(this)};var u=/^[A-Z]/;function d(e,t){var r=t.parent.lookup(t.extend);if(r){var n=new o(t.fullName,t.id,t.type,t.rule,void 0,t.options);return r.get(n.name)||(n.declaringField=t,t.extensionField=n,r.add(n)),!0}return!1}return c.prototype._handleAdd=function(e){if(e instanceof o)void 0===e.extend||e.extensionField||d(0,e)||this.deferred.push(e);else if(e instanceof i)u.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof s)){if(e instanceof t)for(var r=0;r<this.deferred.length;)d(0,this.deferred[r])?this.deferred.splice(r,1):++r;for(var n=0;n<e.nestedArray.length;++n)this._handleAdd(e._nestedArray[n]);u.test(e.name)&&(e.parent[e.name]=e)}},c.prototype._handleRemove=function(t){if(t instanceof o){if(void 0!==t.extend)if(t.extensionField)t.extensionField.parent.remove(t.extensionField),t.extensionField=null;else{var r=this.deferred.indexOf(t);r>-1&&this.deferred.splice(r,1)}}else if(t instanceof i)u.test(t.name)&&delete t.parent[t.name];else if(t instanceof e){for(var n=0;n<t.nestedArray.length;++n)this._handleRemove(t._nestedArray[n]);u.test(t.name)&&delete t.parent[t.name]}},c._configure=function(e,o,i){t=e,r=o,n=i},ts}function fs(){return ns||(ns=1,function(e){var t,r,n=vi.exports=Jt(),o=Pr;n.codegen=function(){if(di)return ui;function e(t,r){"string"==typeof t&&(r=t,t=void 0);var n=[];function o(t){if("string"!=typeof t){var r=i();if(e.verbose&&console.log("codegen: "+r),r="return "+r,t){for(var s=Object.keys(t),a=new Array(s.length+1),c=new Array(s.length),l=0;l<s.length;)a[l]=s[l],c[l]=t[s[l++]];return a[l]=r,Function.apply(null,a).apply(null,c)}return Function(r)()}for(var u=new Array(arguments.length-1),d=0;d<u.length;)u[d]=arguments[++d];if(d=0,t=t.replace(/%([%dfijs])/g,(function(e,t){var r=u[d++];switch(t){case"d":case"f":return String(Number(r));case"i":return String(Math.floor(r));case"j":return JSON.stringify(r);case"s":return String(r)}return"%"})),d!==u.length)throw Error("parameter count mismatch");return n.push(t),o}function i(e){return"function "+(e||r||"")+"("+(t&&t.join(",")||"")+"){\n "+n.join("\n ")+"\n}"}return o.toString=i,o}return di=1,ui=e,e.verbose=!1,ui}(),n.fetch=function(){if(fi)return hi;fi=1,hi=r;var e=Dt,t=Ht();function r(n,o,i){return"function"==typeof o?(i=o,o={}):o||(o={}),i?!o.xhr&&t&&t.readFile?t.readFile(n,(function(e,t){return e&&"undefined"!=typeof XMLHttpRequest?r.xhr(n,o,i):e?i(e):i(null,o.binary?t:t.toString("utf8"))})):r.xhr(n,o,i):e(r,this,n,o)}return r.xhr=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){if(0!==n.status&&200!==n.status)return r(Error("status "+n.status));if(t.binary){var e=n.response;if(!e){e=[];for(var o=0;o<n.responseText.length;++o)e.push(255&n.responseText.charCodeAt(o))}return r(null,"undefined"!=typeof Uint8Array?new Uint8Array(e):e)}return r(null,n.responseText)}},t.binary&&("overrideMimeType"in n&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.responseType="arraybuffer"),n.open("GET",e),n.send()},hi}(),n.path=(mi||(mi=1,function(e){var t=e,r=t.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},n=t.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=r(e),o="";n&&(o=t.shift()+"/");for(var i=0;i<t.length;)".."===t[i]?i>0&&".."!==t[i-1]?t.splice(--i,2):n?t.splice(i,1):++i:"."===t[i]?t.splice(i,1):++i;return o+t.join("/")};t.resolve=function(e,t,o){return o||(t=n(t)),r(t)?t:(o||(e=n(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?n(e+"/"+t):t)}}(bi)),bi),n.fs=n.inquire("fs"),n.toArray=function(e){if(e){for(var t=Object.keys(e),r=new Array(t.length),n=0;n<t.length;)r[n]=e[t[n++]];return r}return[]},n.toObject=function(e){for(var t={},r=0;r<e.length;){var n=e[r++],o=e[r++];void 0!==o&&(t[n]=o)}return t};var i=/\\/g,s=/"/g;n.isReserved=function(e){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(e)},n.safeProp=function(e){return!/^[$\w_]+$/.test(e)||n.isReserved(e)?'["'+e.replace(i,"\\\\").replace(s,'\\"')+'"]':"."+e},n.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var a=/_([a-z])/g;n.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(a,(function(e,t){return t.toUpperCase()}))},n.compareFieldsById=function(e,t){return e.id-t.id},n.decorateType=function(e,r){if(e.$type)return r&&e.$type.name!==r&&(n.decorateRoot.remove(e.$type),e.$type.name=r,n.decorateRoot.add(e.$type)),e.$type;t||(t=ds());var o=new t(r||e.name);return n.decorateRoot.add(o),o.ctor=e,Object.defineProperty(e,"$type",{value:o,enumerable:!1}),Object.defineProperty(e.prototype,"$type",{value:o,enumerable:!1}),o};var c=0;n.decorateEnum=function(e){if(e.$type)return e.$type;r||(r=gs());var t=new r("Enum"+c++,e);return n.decorateRoot.add(t),Object.defineProperty(e,"$type",{value:t,enumerable:!1}),t},n.setProperty=function(e,t,r){if("object"!=typeof e)throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,r,n){var o=r.shift();if("__proto__"===o)return t;if(r.length>0)t[o]=e(t[o]||{},r,n);else{var i=t[o];i&&(n=[].concat(i).concat(n)),t[o]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(n,"decorateRoot",{get:function(){return o.decorated||(o.decorated=new(hs()))}})}()),vi.exports}function ps(){if(is)return os;is=1,os=r,r.className="ReflectionObject";var e,t=fs();function r(e,r){if(!t.isString(e))throw TypeError("name must be a string");if(r&&!t.isObject(r))throw TypeError("options must be an object");this.options=r,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}return Object.defineProperties(r.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),r.prototype.toJSON=function(){throw Error()},r.prototype.onAdd=function(t){this.parent&&this.parent!==t&&this.parent.remove(this),this.parent=t,this.resolved=!1;var r=t.root;r instanceof e&&r._handleAdd(this)},r.prototype.onRemove=function(t){var r=t.root;r instanceof e&&r._handleRemove(this),this.parent=null,this.resolved=!1},r.prototype.resolve=function(){return this.resolved||this.root instanceof e&&(this.resolved=!0),this},r.prototype.getOption=function(e){if(this.options)return this.options[e]},r.prototype.setOption=function(e,t,r){return r&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},r.prototype.setParsedOption=function(e,r,n){this.parsedOptions||(this.parsedOptions=[]);var o=this.parsedOptions;if(n){var i=o.find((function(t){return Object.prototype.hasOwnProperty.call(t,e)}));if(i){var s=i[e];t.setProperty(s,n,r)}else(i={})[e]=t.setProperty({},n,r),o.push(i)}else{var a={};a[e]=r,o.push(a)}return this},r.prototype.setOptions=function(e,t){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)this.setOption(r[n],e[r[n]],t);return this},r.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},r._configure=function(t){e=t},os}function gs(){if(as)return ss;as=1,ss=n;var e=ps();((n.prototype=Object.create(e.prototype)).constructor=n).className="Enum";var t=Ui(),r=fs();function n(t,r,n,o,i,s){if(e.call(this,t,n),r&&"object"!=typeof r)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=o,this.comments=i||{},this.valuesOptions=s,this.reserved=void 0,r)for(var a=Object.keys(r),c=0;c<a.length;++c)"number"==typeof r[a[c]]&&(this.valuesById[this.values[a[c]]=r[a[c]]]=a[c])}return n.fromJSON=function(e,t){var r=new n(e,t.values,t.options,t.comment,t.comments);return r.reserved=t.reserved,r},n.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return r.toObject(["options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",t?this.comment:void 0,"comments",t?this.comments:void 0])},n.prototype.add=function(e,t,n,o){if(!r.isString(e))throw TypeError("name must be a string");if(!r.isInteger(t))throw TypeError("id must be an integer");if(void 0!==this.values[e])throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(t))throw Error("id "+t+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(void 0!==this.valuesById[t]){if(!this.options||!this.options.allow_alias)throw Error("duplicate id "+t+" in "+this);this.values[e]=t}else this.valuesById[this.values[e]=t]=e;return o&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=o||null),this.comments[e]=n||null,this},n.prototype.remove=function(e){if(!r.isString(e))throw TypeError("name must be a string");var t=this.values[e];if(null==t)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[t],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this},n.prototype.isReservedId=function(e){return t.isReservedId(this.reserved,e)},n.prototype.isReservedName=function(e){return t.isReservedName(this.reserved,e)},ss}function ys(){if(ls)return cs;ls=1,cs=function(o){for(var i,s=r.codegen(["m","w"],o.name+"$encode")("if(!w)")("w=Writer.create()"),a=o.fieldsArray.slice().sort(r.compareFieldsById),c=0;c<a.length;++c){var l=a[c].resolve(),u=o._fieldsArray.indexOf(l),d=l.resolvedType instanceof e?"int32":l.type,h=t.basic[d];i="m"+r.safeProp(l.name),l.map?(s("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",i,l.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",i)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(l.id<<3|2)>>>0,8|t.mapKey[l.keyType],l.keyType),void 0===h?s("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,i):s(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|h,d,i),s("}")("}")):l.repeated?(s("if(%s!=null&&%s.length){",i,i),l.packed&&void 0!==t.packed[d]?s("w.uint32(%i).fork()",(l.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",i)("w.%s(%s[i])",d,i)("w.ldelim()"):(s("for(var i=0;i<%s.length;++i)",i),void 0===h?n(s,l,u,i+"[i]"):s("w.uint32(%i).%s(%s[i])",(l.id<<3|h)>>>0,d,i)),s("}")):(l.optional&&s("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",i,l.name),void 0===h?n(s,l,u,i):s("w.uint32(%i).%s(%s)",(l.id<<3|h)>>>0,d,i))}return s("return w")};var e=gs(),t=Mi(),r=fs();function n(e,t,r,n){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,n,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,n,(t.id<<3|2)>>>0)}return cs}!function(e){var t=Ki;e[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),r=this.lookup(t);if(r){var n="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===n.indexOf("/")&&(n="/"+n),this.create({type_url:n,value:r.encode(r.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,r){var n="",o="";if(r&&r.json&&e.type_url&&e.value){o=e.type_url.substring(e.type_url.lastIndexOf("/")+1),n=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var i=this.lookup(o);i&&(e=i.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof t){var s=e.$type.toObject(e,r);return""===n&&(n="type.googleapis.com/"),o=n+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),s["@type"]=o,s}return this.toObject(e,r)}}}(us),function(e){var t=yi.exports=Nt;t.build="light",t.load=function(e,r,n){return"function"==typeof r?(n=r,r=new t.Root):r||(r=new t.Root),r.load(e,n)},t.loadSync=function(e,r){return r||(r=new t.Root),r.loadSync(e)},t.encoder=ys(),t.decoder=$i(),t.verifier=Ji(),t.converter=Yi(),t.ReflectionObject=ps(),t.Namespace=Ui(),t.Root=hs(),t.Enum=gs(),t.Type=ds(),t.Field=Li(),t.OneOf=Bi(),t.MapField=ji(),t.Service=Fi(),t.Method=Pi(),t.Message=Ki,t.wrappers=us,t.types=Mi(),t.util=fs(),t.ReflectionObject._configure(t.Root),t.Namespace._configure(t.Type,t.Service,t.Enum),t.Root._configure(t.Type),t.Field._configure(t.Type)}();var vs=Rs,ms=/[\s{}=;:[\],'"()<>]/g,bs=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,ws=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,Os=/^ *[*/]+ */,Cs=/^\s*\*?\/*/,_s=/\n/g,Ss=/\s/,Is=/\\(.?)/g,Es={0:"\0",r:"\r",n:"\n",t:"\t"};function Ts(e){return e.replace(Is,(function(e,t){switch(t){case"\\":case"":return t;default:return Es[t]||""}}))}function Rs(e,t){e=e.toString();var r=0,n=e.length,o=1,i=0,s={},a=[],c=null;function l(e){return Error("illegal "+e+" (line "+o+")")}function u(t){return e.charAt(t)}function d(r,n,a){var c,l={type:e.charAt(r++),lineEmpty:!1,leading:a},u=r-(t?2:3);do{if(--u<0||"\n"===(c=e.charAt(u))){l.lineEmpty=!0;break}}while(" "===c||"\t"===c);for(var d=e.substring(r,n).split(_s),h=0;h<d.length;++h)d[h]=d[h].replace(t?Cs:Os,"").trim();l.text=d.join("\n").trim(),s[o]=l,i=o}function h(t){var r=f(t),n=e.substring(t,r);return/^\s*\/{1,2}/.test(n)}function f(e){for(var t=e;t<n&&"\n"!==u(t);)t++;return t}function p(){if(a.length>0)return a.shift();if(c)return function(){var t="'"===c?ws:bs;t.lastIndex=r-1;var n=t.exec(e);if(!n)throw l("string");return r=t.lastIndex,g(c),c=null,Ts(n[1])}();var i,s,p,y,v,m=0===r;do{if(r===n)return null;for(i=!1;Ss.test(p=u(r));)if("\n"===p&&(m=!0,++o),++r===n)return null;if("/"===u(r)){if(++r===n)throw l("comment");if("/"===u(r))if(t){if(y=r,v=!1,h(r)){v=!0;do{if((r=f(r))===n)break;if(r++,!m)break}while(h(r))}else r=Math.min(n,f(r)+1);v&&(d(y,r,m),m=!0),o++,i=!0}else{for(v="/"===u(y=r+1);"\n"!==u(++r);)if(r===n)return null;++r,v&&(d(y,r-1,m),m=!0),++o,i=!0}else{if("*"!==(p=u(r)))return"/";y=r+1,v=t||"*"===u(y);do{if("\n"===p&&++o,++r===n)throw l("comment");s=p,p=u(r)}while("*"!==s||"/"!==p);++r,v&&(d(y,r-2,m),m=!0),i=!0}}}while(i);var b=r;if(ms.lastIndex=0,!ms.test(u(b++)))for(;b<n&&!ms.test(u(b));)++b;var w=e.substring(r,r=b);return'"'!==w&&"'"!==w||(c=w),w}function g(e){a.push(e)}function y(){if(!a.length){var e=p();if(null===e)return null;g(e)}return a[0]}return Object.defineProperty({next:p,peek:y,push:g,skip:function(e,t){var r=y();if(r===e)return p(),!0;if(!t)throw l("token '"+r+"', '"+e+"' expected");return!1},cmnt:function(e){var r,n=null;return void 0===e?(r=s[o-1],delete s[o-1],r&&(t||"*"===r.type||r.lineEmpty)&&(n=r.leading?r.text:null)):(i<e&&y(),r=s[e],delete s[e],!r||r.lineEmpty||!t&&"/"!==r.type||(n=r.leading?null:r.text)),n}},"line",{get:function(){return o}})}Rs.unescape=Ts;var ks=Xs;Xs.filename=null,Xs.defaults={keepCase:!1};var As=vs,Ns=hs(),xs=ds(),Ds=Li(),Ms=ji(),Ls=Bi(),Bs=gs(),Us=Fi(),js=Pi(),Ps=Mi(),Fs=fs(),Gs=/^[1-9][0-9]*$/,qs=/^-?[1-9][0-9]*$/,Hs=/^0[x][0-9a-fA-F]+$/,zs=/^-?0[x][0-9a-fA-F]+$/,Ks=/^0[0-7]+$/,Vs=/^-?0[0-7]+$/,Ws=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,$s=/^[a-zA-Z_][a-zA-Z_0-9]*$/,Js=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,Zs=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function Xs(e,t,r){t instanceof Ns||(r=t,t=new Ns),r||(r=Xs.defaults);var n,o,i,s,a,c=r.preferTrailingComment||!1,l=As(e,r.alternateCommentMode||!1),u=l.next,d=l.push,h=l.peek,f=l.skip,p=l.cmnt,g=!0,y=!1,v=t,m=r.keepCase?function(e){return e}:Fs.camelCase;function b(e,t,r){var n=Xs.filename;return r||(Xs.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(n?n+", ":"")+"line "+l.line+")")}function w(){var e,t=[];do{if('"'!==(e=u())&&"'"!==e)throw b(e);t.push(u()),f(e),e=h()}while('"'===e||"'"===e);return t.join("")}function O(e){var t=u();switch(t){case"'":case'"':return d(t),w();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var r=1;"-"===e.charAt(0)&&(r=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return r*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(Gs.test(e))return r*parseInt(e,10);if(Hs.test(e))return r*parseInt(e,16);if(Ks.test(e))return r*parseInt(e,8);if(Ws.test(e))return r*parseFloat(e);throw b(e,"number",t)}(t,!0)}catch(r){if(e&&Js.test(t))return t;throw b(t,"value")}}function C(e,t){var r,n;do{!t||'"'!==(r=h())&&"'"!==r?e.push([n=_(u()),f("to",!0)?_(u()):n]):e.push(w())}while(f(",",!0));f(";")}function _(e,t){switch(e){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!t&&"-"===e.charAt(0))throw b(e,"id");if(qs.test(e))return parseInt(e,10);if(zs.test(e))return parseInt(e,16);if(Vs.test(e))return parseInt(e,8);throw b(e,"id")}function S(){if(void 0!==n)throw b("package");if(n=u(),!Js.test(n))throw b(n,"name");v=v.define(n),f(";")}function I(){var e,t=h();switch(t){case"weak":e=i||(i=[]),u();break;case"public":u();default:e=o||(o=[])}t=w(),f(";"),e.push(t)}function E(){if(f("="),s=w(),!(y="proto3"===s)&&"proto2"!==s)throw b(s,"syntax");f(";")}function T(e,t){switch(t){case"option":return x(e,t),f(";"),!0;case"message":return k(e,t),!0;case"enum":return N(e,t),!0;case"service":return function(e,t){if(!$s.test(t=u()))throw b(t,"service name");var r=new Us(t);R(r,(function(e){if(!T(r,e)){if("rpc"!==e)throw b(e);!function(e,t){var r=p(),n=t;if(!$s.test(t=u()))throw b(t,"name");var o,i,s,a,c=t;f("("),f("stream",!0)&&(i=!0);if(!Js.test(t=u()))throw b(t);o=t,f(")"),f("returns"),f("("),f("stream",!0)&&(a=!0);if(!Js.test(t=u()))throw b(t);s=t,f(")");var l=new js(c,n,o,s,i,a);l.comment=r,R(l,(function(e){if("option"!==e)throw b(e);x(l,e),f(";")})),e.add(l)}(r,e)}})),e.add(r)}(e,t),!0;case"extend":return function(e,t){if(!Js.test(t=u()))throw b(t,"reference");var r=t;R(null,(function(t){switch(t){case"required":case"repeated":A(e,t,r);break;case"optional":A(e,y?"proto3_optional":"optional",r);break;default:if(!y||!Js.test(t))throw b(t);d(t),A(e,"optional",r)}}))}(e,t),!0}return!1}function R(e,t,r){var n=l.line;if(e&&("string"!=typeof e.comment&&(e.comment=p()),e.filename=Xs.filename),f("{",!0)){for(var o;"}"!==(o=u());)t(o);f(";",!0)}else r&&r(),f(";"),e&&("string"!=typeof e.comment||c)&&(e.comment=p(n)||e.comment)}function k(e,t){if(!$s.test(t=u()))throw b(t,"type name");var r=new xs(t);R(r,(function(e){if(!T(r,e))switch(e){case"map":!function(e){f("<");var t=u();if(void 0===Ps.mapKey[t])throw b(t,"type");f(",");var r=u();if(!Js.test(r))throw b(r,"type");f(">");var n=u();if(!$s.test(n))throw b(n,"name");f("=");var o=new Ms(m(n),_(u()),t,r);R(o,(function(e){if("option"!==e)throw b(e);x(o,e),f(";")}),(function(){L(o)})),e.add(o)}(r);break;case"required":case"repeated":A(r,e);break;case"optional":A(r,y?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!$s.test(t=u()))throw b(t,"name");var r=new Ls(m(t));R(r,(function(e){"option"===e?(x(r,e),f(";")):(d(e),A(r,"optional"))})),e.add(r)}(r,e);break;case"extensions":C(r.extensions||(r.extensions=[]));break;case"reserved":C(r.reserved||(r.reserved=[]),!0);break;default:if(!y||!Js.test(e))throw b(e);d(e),A(r,"optional")}})),e.add(r)}function A(e,t,r){var n=u();if("group"!==n){if(!Js.test(n))throw b(n,"type");var o=u();if(!$s.test(o))throw b(o,"name");o=m(o),f("=");var i=new Ds(o,_(u()),n,t,r);if(R(i,(function(e){if("option"!==e)throw b(e);x(i,e),f(";")}),(function(){L(i)})),"proto3_optional"===t){var s=new Ls("_"+o);i.setOption("proto3_optional",!0),s.add(i),e.add(s)}else e.add(i);y||!i.repeated||void 0===Ps.packed[n]&&void 0!==Ps.basic[n]||i.setOption("packed",!1,!0)}else!function(e,t){var r=u();if(!$s.test(r))throw b(r,"name");var n=Fs.lcFirst(r);r===n&&(r=Fs.ucFirst(r));f("=");var o=_(u()),i=new xs(r);i.group=!0;var s=new Ds(n,o,r,t);s.filename=Xs.filename,R(i,(function(e){switch(e){case"option":x(i,e),f(";");break;case"required":case"repeated":A(i,e);break;case"optional":A(i,y?"proto3_optional":"optional");break;case"message":k(i,e);break;case"enum":N(i,e);break;default:throw b(e)}})),e.add(i).add(s)}(e,t)}function N(e,t){if(!$s.test(t=u()))throw b(t,"name");var r=new Bs(t);R(r,(function(e){switch(e){case"option":x(r,e),f(";");break;case"reserved":C(r.reserved||(r.reserved=[]),!0);break;default:!function(e,t){if(!$s.test(t))throw b(t,"name");f("=");var r=_(u(),!0),n={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};R(n,(function(e){if("option"!==e)throw b(e);x(n,e),f(";")}),(function(){L(n)})),e.add(t,r,n.comment,n.options)}(r,e)}})),e.add(r)}function x(e,t){var r=f("(",!0);if(!Js.test(t=u()))throw b(t,"name");var n,o=t,i=o;r&&(f(")"),i=o="("+o+")",t=h(),Zs.test(t)&&(n=t.slice(1),o+=t,u())),f("="),function(e,t,r,n){e.setParsedOption&&e.setParsedOption(t,r,n)}(e,i,D(e,o),n)}function D(e,t){if(f("{",!0)){for(var r={};!f("}",!0);){if(!$s.test(a=u()))throw b(a,"name");var n,o=a;if(f(":",!0),"{"===h())n=D(e,t+"."+a);else if("["===h()){var i;if(n=[],f("[",!0)){do{i=O(!0),n.push(i)}while(f(",",!0));f("]"),void 0!==i&&M(e,t+"."+a,i)}}else n=O(!0),M(e,t+"."+a,n);var s=r[o];s&&(n=[].concat(s).concat(n)),r[o]=n,f(",",!0),f(";",!0)}return r}var c=O(!0);return M(e,t,c),c}function M(e,t,r){e.setOption&&e.setOption(t,r)}function L(e){if(f("[",!0)){do{x(e,"option")}while(f(",",!0));f("]")}return e}for(;null!==(a=u());)switch(a){case"package":if(!g)throw b(a);S();break;case"import":if(!g)throw b(a);I();break;case"syntax":if(!g)throw b(a);E();break;case"option":x(v,a),f(";");break;default:if(T(v,a)){g=!1;continue}throw b(a)}return Xs.filename=null,{package:n,imports:o,weakImports:i,syntax:s,root:t}}var Ys,Qs=ta,ea=/\/|\./;function ta(e,t){ea.test(e)||(e="google/protobuf/"+e+".proto",t={nested:{google:{nested:{protobuf:{nested:t}}}}}),ta[e]=t}ta("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),ta("duration",{Duration:Ys={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),ta("timestamp",{Timestamp:Ys}),ta("empty",{Empty:{fields:{}}}),ta("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),ta("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),ta("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),ta.get=function(e){return ta[e]||null},function(e){var t=gi.exports=yi.exports;t.build="full",t.tokenize=vs,t.parse=ks,t.common=Qs,t.Root._configure(t.Type,t.parse,t.common)}();var ra=F(pi.exports=gi.exports);const na=e=>{const t=window.URL||window.webkitURL;return t?t.createObjectURL(e):""},oa=e=>{const t=e.name;return O(t)?t.substring(t.lastIndexOf(".")+1):e.type.indexOf("/")>0?e.type.substring(e.type.lastIndexOf("/")+1):""},ia=e=>{(window.URL||window.webkitURL).revokeObjectURL(e)},sa=e=>{const t=e.match(/data:([^;]+)/)[1],r=e.replace(/^[^,]+,/,""),n=window.atob(r);let o=n.length;const i=new Uint8Array(n.length);for(;o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:t})};class aa{constructor(e){d(this,"options",void 0),d(this,"xhr",void 0),this.options=e}upload(e,t){const r=new XMLHttpRequest;r.open("POST",this.options.uploadUrl,!0),r.onreadystatechange=()=>{if(4===r.readyState){const o=r.responseText||"{}",i=JSON.parse(o);if(200===r.status&&200===i.code){var e;let r={url:i.url};this.options.transformer&&(r=this.options.transformer(r)),null===(e=t.onCompleted)||void 0===e||e.call(t,r)}else{var n;null===(n=t.onError)||void 0===n||n.call(t,"upload fail")}}},r.setRequestHeader("device","7"),r.setRequestHeader("cert",this.options.cert??"");const n=oa(e),o=function(){let e=(new Date).getTime();return"xxxxxx4xxxyxxxxxxx".replace(/[xy]/g,(function(t){const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)}))}()+(n.length?`.${n}`:""),i=new FormData;i.append("file",e),i.append("name","file"),i.append("fileName",o),i.append("token",this.options.token),r.send(i),this.xhr=r}cancel(){var e;null===(e=this.xhr)||void 0===e||e.abort()}}const ca=e=>new Promise(((t,r)=>{const n=e=>{0!==e.width||0!==e.height?t(e):r()},o=new Image;if(o.addEventListener("load",(e=>n(e.target))),o.addEventListener("error",r),o.src=e,o.complete)return void n(o);const i=setInterval((()=>{o.complete&&(n(o),clearInterval(i))}),40)}));class la{constructor(e,t){d(this,"uploadInstance",void 0),d(this,"options",void 0),this.uploadInstance=e,this.options=t}async upload(e,t){try{const r=na(e),n=await ca(r);ia(r);const{imageFile:o,compressWidth:i,compressHeight:s}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"image/jpeg";t=Math.min(1,t);const n=e.width,o=e.height;let i=n,s=o;if(t<1){const e=n<o,t=e?o/1680:n/1680;n>1680&&o>1680?e?(s=1680,i/=t):(i=1680,s/=t):n>1680&&o>160?(i=1680,s/=t,s<160&&(s=160,i=n/(o/160))):o>1680&&n>160&&(s=1680,i/=t,i<160&&(i=160,s=o/(n/160)))}i=Math.floor(i),s=Math.floor(s);const a=document.createElement("canvas");a.width=i,a.height=s;const c=a.getContext("2d");return c.fillStyle="#FFF",c.fillRect(0,0,i,s),c.drawImage(e,0,0,n,o,0,0,i,s),r&&"image/png"!=r||(r="image/jpeg"),{imageFile:sa(a.toDataURL(r,Math.min(.92,t))),compressWidth:i,compressHeight:s}}(n,.85,e.type),a=((e,t)=>{const r=document.createElement("canvas"),n=r.getContext("2d"),o=function(e,t,r){const n=e<t;let o,i,s,a=0,c=0;const l=function(){return n?(o=e/100,i=100,s=t/o,c=(s-r.maxHeight)/2):(o=t/100,s=100,i=e/o,a=(i-r.maxWidth)/2),{w:i,h:s,x:-a,y:-c}},u=function(){return n?(o=t/r.maxHeight,s=r.maxHeight,i=e/o):(o=e/r.maxWidth,i=r.maxWidth,s=t/o),{w:i,h:s,x:-a,y:-c}};return(n?t/e:e/t)>r.scale?l():u()}(e.width,e.height,t);r.width=o.w>t.maxWidth?t.maxWidth:o.w,r.height=o.h>t.maxHeight?t.maxHeight:o.h,null==n||n.drawImage(e,o.x,o.y,o.w,o.h);try{let e=r.toDataURL("image/jpeg",t.quality);const n=new RegExp("^data:image/[^;]+;base64,");return e=e.replace(n,""),e}catch(e){throw new Error(e)}})(n,{maxHeight:160,maxWidth:160,quality:.6,scale:2.4});this.uploadInstance.upload(o,{...t,onCompleted:r=>{var n;null===(n=t.onCompleted)||void 0===n||n.call(t,{url:r.url,thumbnail:a,width:i,height:s,type:e.type})}})}catch(e){var r;null===(r=t.onError)||void 0===r||r.call(t,"MEDIA_EXCEPTION")}}cancel(){this.uploadInstance.cancel()}}class ua{constructor(e){d(this,"uploadInstance",void 0),this.uploadInstance=e}async upload(e,t){if(e.size>2097152)t.onError&&t.onError("GIF_MSG_SIZE_LIMIT_EXCEED");else try{const r=na(e),n=await ca(r);ia(r),this.uploadInstance.upload(e,{...t,onCompleted:r=>{var o;null===(o=t.onCompleted)||void 0===o||o.call(t,{url:r.url,size:e.size,width:n.width,height:n.height})}})}catch(e){var r;null===(r=t.onError)||void 0===r||r.call(t,"MEDIA_EXCEPTION")}}cancel(){this.uploadInstance.cancel()}}let da;class ha{constructor(e){d(this,"uploadInstance",void 0),this.uploadInstance=e}upload(e,t){var r;(r=e,_(r.arrayBuffer)?r.arrayBuffer():new Promise(((e,t)=>{const n=new FileReader;n.addEventListener("load",(r=>{r.target?e(r.target.result):t("null")})),n.addEventListener("error",(e=>t(e))),n.readAsArrayBuffer(r)}))).then(this.getAudioInfo).then((r=>{this.uploadInstance.upload(e,{...t,onCompleted:n=>{var o;null===(o=t.onCompleted)||void 0===o||o.call(t,{url:n.url,type:oa(e),...r})}})})).catch((()=>{var e;null===(e=t.onError)||void 0===e||e.call(t,"MEDIA_EXCEPTION")}))}cancel(){this.uploadInstance.cancel()}getAudioInfo(e){const t=da||new AudioContext;return da=t,new Promise(((r,n)=>{t.decodeAudioData(e,(function(e){r({duration:e.duration,length:e.length})}),n)}))}}class fa{constructor(e){d(this,"uploadInstance",void 0),this.uploadInstance=e}upload(e,t){if(e.size>104857600)t.onError&&t.onError("FILE_MSG_SIZE_LIMIT_EXCEED");else try{this.uploadInstance.upload(e,{...t,onCompleted:r=>{var n;null===(n=t.onCompleted)||void 0===n||n.call(t,{url:r.url,name:e.name,type:oa(e),size:e.size})}})}catch(e){var r;null===(r=t.onError)||void 0===r||r.call(t,"MEDIA_EXCEPTION")}}cancel(){this.uploadInstance.cancel()}}var pa;!function(e){e[e.IMAGE=1]="IMAGE",e[e.GIF=2]="GIF",e[e.AUDIO=3]="AUDIO",e[e.VIDEO=4]="VIDEO",e[e.FILE=5]="FILE",e[e.SIGHT=6]="SIGHT"}(pa||(pa={}));const ga=(e,t,r,n,o,i)=>({conversationType:e.conversationType,targetId:e.targetId,channelId:e.channelId,senderUserId:t,messageDirection:s.SEND,isCounted:r.isCounted,isMentioned:!1,content:r.content,messageType:r.messageType,isOffLineMessage:!1,isPersited:r.isPersited,messageId:n,messageUId:o,sentTime:i,receivedTime:0,isStatusMessage:r.isStatusMessage,receivedStatus:a.UNREAD,disableNotification:!1});let ya=0;const va=[To,Io];async function ma(r,i,s){var a;if(!li.loader||li.loader.getConnectionStatus()!==e.CONNECTED)return{code:t.RC_NET_CHANNEL_INVALID};s=s||{};const c=JSON.stringify(_t(i.encode()));if(function(e){let t=0;if("utf-16"===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf-8"))for(let r=0,n=e.length;r<n;r++)t+=e.charCodeAt(r)<=65535?2:4;else for(let r=0,n=e.length;r<n;r++){const n=e.charCodeAt(r);t+=n<127?1:n<=2047?2:n<=65535?3:4}return t}(c)>81920)return{code:t.RC_MSG_CONTENT_EXCEED_LIMIT};const l=Pn(r);let u;u=f(null===(a=s)||void 0===a?void 0:a.messageId)&&s.messageId>0?s.messageId:function(){ya++;const e=oo();return ya<e&&(ya=e),23e13+ya}(),so.addMessage(u);const d=ga(r,xn.uid,i,u,"",function(){Ea++;const e=oo();Ea<e&&(Ea=e);return Ea}());s.onSendBefore&&s.onSendBefore(d),i.isPersited&&ai.get().loadConvsationsIfNotExist([r]);const h=await Ho.getDialogAesKey(l);if(!h)return{code:t.MSG_ENCRYPT_ERROR,data:d};const p=((e,t)=>{if(!O(e))return new Uint8Array;const r=Ot.AES.encrypt(e,Ot.enc.Utf8.parse(t.key),{iv:f(t.iv)?Ot.enc.Utf8.parse(t.iv):void 0});return Wo(r.ciphertext.words)})(c,h),g={localId:tn.fromNumber(u),mediaFlag:va.includes(i.messageType),mediaConstructor:i.objectId,mediaAttribute:"",msgPreContent:"",msgPostContent:"",msgContent:p};let y;if(r.conversationType===n.GROUP){var v,m;const e={...g,groupId:l};if(null!==(v=s)&&void 0!==v&&null!==(m=v.directionalUserIdList)&&void 0!==m&&m.length&&(e.assign=s.directionalUserIdList.join(",")),f(i.content.mentionedInfo)){var b;const t=i.content.mentionedInfo;t.type===o.ALL?e.atAll=!0:t.type===o.SINGAL&&null!==(b=t.userIdList)&&void 0!==b&&b.length&&(e.at=t.userIdList.map((e=>tn.fromString(e))))}y=await(w=e,Nn.send(j.SendGroupChatMessage,w,{encoder:Xn.SendGroupChatMessageReq,decoder:to}))}else{const e={...g,destId:l};y=await(e=>Nn.send(j.SendPrivateChatMessage,e,{encoder:Vn.SendPrivateChatMessageReq,decoder:Un.SendPrivateChatMessageResp}))(e)}var w;return y.code===t.SUCCESS&&(d.sentTime=y.data.seqno.toNumber(),d.messageUId=y.data.msgId.toString(),ai.get().setConversationCacheByMessage(d)),{code:y.code,data:d}}const ba=Sa(pa.IMAGE,((e,t)=>new xo({content:e.thumbnail,imageUri:e.url,width:e.width,height:e.height,user:t.user,extra:t.extra}))),wa=Sa(pa.GIF,((e,t)=>new Do({gifDataSize:e.size,remoteUrl:e.url,width:e.width,height:e.height,user:t.user,extra:t.extra}))),Oa=Sa(pa.AUDIO,((e,t)=>new Mo({remoteUrl:e.url,duration:e.duration,type:e.type,user:t.user,extra:t.extra}))),Ca=Sa(pa.FILE,((e,t)=>new Lo({fileUrl:e.url,name:e.name,type:e.type,size:e.size,user:t.user,extra:t.extra}))),_a=async(e,r)=>{const n=Pn(e);co.addMessage(r.messageUId);const o=await((e,t)=>{let r;return r=Gn(e)?Nn.send(j.RecallGroupMessage,{groupId:e,msgId:tn.fromString(t)},{encoder:Xn.RecallGroupChatMessageReq,decoder:Zr.BaseResp}):Nn.send(j.RecallPrivateMessage,{destId:e,msgId:tn.fromString(t)},{encoder:Vn.RecallPrivateChatMessageReq,decoder:Zr.BaseResp}),r})(n,r.messageUId);if(o.code!==t.SUCCESS)return{code:o.code};const i=new Bo({sentTime:r.sentTime,messageUId:r.messageUId,...e}),s=ga(e,xn.uid,i,0,"",oo());return ai.get().setConversationCacheByMessage(s),{code:t.SUCCESS,data:s}};function Sa(e,r){return function(n,o,i,s){return new Promise((a=>{((e,t,r,n)=>{var o;const i=new aa({token:jn.imInitToken,uploadUrl:jn.fileUploadUrl,cert:jn.cert,transformer:e=>({...e,url:jn.getFileAbsoluteUri(e.url)})});let s;switch(t){case pa.IMAGE:s=new la(i,r);break;case pa.GIF:s=new ua(i);break;case pa.AUDIO:s=new ha(i);break;case pa.FILE:s=new fa(i)}null===(o=s)||void 0===o||o.upload(e,{onProgress:(e,t)=>n.onProgress(Math.floor(e/t*100)),onError:()=>n.onFail(),onCompleted:n.onSuccess})})(o.file,e,s,{onProgress:e=>(null==i?void 0:i.onProgress)&&i.onProgress(e),onSuccess:e=>{const t=(null==i?void 0:i.onComplete)&&i.onComplete({url:jn.getFileAbsoluteUri(e.url)})||r(e,o);ma(n,t,s).then(a)},onFail:()=>{a({code:t.UPLOAD_FILE_FAILED})}})}))}}let Ia,Ea=1;class Ta extends B{constructor(e){if(Ta.imClient)return E.error("Please do not perform the init method repeatedly"),Ta.imClient;super(),d(this,"options",void 0),d(this,"libLoader",void 0),d(this,"getServerTime",oo),d(this,"sendMessage",ma),d(this,"sendImageMessage",ba),d(this,"sendGIFMessage",wa),d(this,"sendHQVoiceMessage",Oa),d(this,"sendFileMessage",Ca),d(this,"recallMsg",_a),this.options=e,this.fixedProtobuf(),f(e.logLevel)&&E.setLogLevel(e.logLevel),f(e.logStdout)&&E.setLogStdout(e.logStdout),E.debug("IMClient.init -> ",e.appkey),this.libLoader=li.init(e),this.watch(),Ta.imClient=this}fixedProtobuf(){ra.util.Long=tn,ra.configure()}watch(){this.libLoader.assignWatcher({onConnecting:()=>{this.emit(u.CONNECTING)},onConnected:()=>{this.emit(u.CONNECTED)},onDisconnect:()=>{this.emit(u.DISCONNECT,this.libLoader.getConnectionStatus())},onSuspend:()=>{this.emit(u.SUSPEND,this.libLoader.getConnectionStatus())},batchMessage:e=>{this.emit(u.MESSAGES,{messages:e})},pullFinished:()=>{this.emit(u.PULL_OFFLINE_MESSAGE_FINISHED)},conversationState:e=>{this.emit(u.CONVERSATION,{conversations:e})}})}connect(e){return this.libLoader.connect(e)}disconnect(){return this.libLoader.disconnect()}getConnectionStatus(){return this.libLoader.getConnectionStatus()}async getRemoteHistoryMessages(e,n){const o=Pn(e);return(e=>{const t={dialogKeys:e.dialogId,newToOld:e.newToOld,rows:e.count};return e.newToOld?t.offset=tn.fromNumber(e.offset):t.oldOffset=tn.fromNumber(e.offset),Nn.send(e.dialogId.startsWith("SG")?j.GetSuperGroupRemoteMessages:j.GetRemoteMessages,t,{encoder:Vn.GetHistoryMessageReq,decoder:Un.GetHistoryMessageResp})})({dialogId:o,offset:n.timestamp??0,count:n.count??20,newToOld:0===n.order}).then((e=>{let{code:n,data:i}=e;return new Promise((e=>{n===t.SUCCESS?Yo.parse({[o]:i.msg??{}},((r,n)=>{const s=n[o]??[];s.sort(((e,t)=>e.sentTime-t.sentTime)),e({code:t.SUCCESS,data:{list:s,hasMore:!i.isEnd}})})):e({code:n,msg:r(n)})}))}))}async deleteRemoteMessage(e,t){return(r=Pn(e),n=t.map((e=>e.messageUId)),Nn.send(j.DeleteChatMessages,{destId:r,msgIdList:n.map((e=>tn.fromString(e)))},{encoder:Vn.DeleteChatMessageReq,decoder:Zr.BaseResp})).then((e=>e.code));var r,n}async deleteRemoteMessageByTimestamp(e,t){return((e,t)=>Nn.send(j.ClearChatHistoryMessage,{destId:e,type:Gn(e)?1:0,msgTime:tn.fromNumber(t)},{encoder:Vn.CleanHistoryMessageReq,decoder:Zr.BaseResp}))(Pn(e),0===t?Number.MAX_VALUE:t).then((e=>e.code))}async getConversationList(e,r,n,o){const i={rows:e,type:r??0,offset:tn.fromNumber(n),newToOld:0===o},{code:s,data:a}=await(e=>Nn.send(j.GetDialogList,e,{encoder:Vn.GetWebDialogListReq,decoder:Un.GetWebDialogListResp}))(i);if(s!==t.SUCCESS)return{code:s};const c=a.fullDialog.map((e=>{var t;return null===(t=e.dialog)||void 0===t?void 0:t.destId})).filter(O);await Ho.getDialogAesKeyList(c);const l=[];for(const e of a.fullDialog){const t=this.formatConversation(e);if(t){const e={conversationType:t.conversationType,targetId:t.targetId,channelId:t.channelId};ai.get().addLocalConversation(t);const r=ai.get().get(e);Object.assign(t,r),l.push(t)}}return{code:t.SUCCESS,data:l}}getBlockConversationList(){const e=ai.get().getBlockConversationList();return Promise.resolve({code:t.SUCCESS,data:e})}getTopConversationList(){const e=ai.get().getTopConversationList();return Promise.resolve({code:t.SUCCESS,data:e})}async getConversation(e){const r=ai.get().get(e);if(!r)return{code:t.CONVER_GET_ERROR};const{code:n,data:o}=await this.getRemoteHistoryMessages(e,{count:1,order:0});if(n!==t.SUCCESS)return{code:t.CONVER_GET_ERROR};const i=null==o?void 0:o.list[0],s={...e,...r,latestMessage:i};return{code:t.SUCCESS,data:s}}removeConversation(e){return(e=>{let t;return t=Gn(e)?Nn.send(j.DeleteGroupDialog,{groupId:e},{encoder:Xn.DeleteGroupChatDialogReq,decoder:Zr.BaseResp}):Nn.send(j.DeletePrivateDialog,{destId:e},{encoder:Vn.DeletePrivateChatDialogReq,decoder:Zr.BaseResp}),t})(Pn(e)).then((e=>e.code))}getUnreadMentionedCount(e){return ai.get().getUnreadMentionedCount(e)}getAllUnreadMentionedCount(){return ai.get().getAllUnreadMentionedCount()}getAllConversationState(){return ai.get().getAllConversationState()}getAllConversationUnreadCount(e,t){return ai.get().getAllUnreadCount(e,t)}getConversationUnreadCount(e){return ai.get().getUnreadCount(e)}clearConversationUnreadCount(e){ai.get().clearUnreadCount(e)}clearAllConversationsUnreadCount(){ai.get().clearAllUnreadCount()}getConversationNotificationLevel(e){return ai.get().getNotificationLevel(e)}setConversationNotificationStatus(e,t){return((e,t)=>{let r;return r=Gn(e)?Nn.send(j.UpdateGroupChatMuteConfig,{groupId:e,muteFlag:t},{encoder:Xn.UpdateGroupChatDialogMuteConfigReq,decoder:Zr.BaseResp}):Nn.send(j.UpdatePrivateChatMuteConfig,{destId:e,muteFlag:t},{encoder:Vn.UpdatePrivateChatDialogMuteConfigReq,decoder:Zr.BaseResp}),r})(Pn(e),t===i.OPEN).then((r=>(!r.code&&ai.get().addStatus({...e,notificationStatus:t,notificationLevel:t==i.OPEN?c.AT_USER_NOTIFICATION:c.NOT_SET},!0),r.code)))}getConversationNotificationStatus(e){return ai.get().getNotificationStatus(e)}setConversationToTop(e,t){return((e,t)=>{let r;return r=Gn(e)?Nn.send(j.UpdateGroupChatStickyConfig,{groupId:e,stickyFlag:t},{encoder:Xn.UpdateGroupChatDialogStickyConfigReq,decoder:Zr.BaseResp}):Nn.send(j.UpdatePrivateChatStickyConfig,{destId:e,stickyFlag:t},{encoder:Vn.UpdatePrivateChatDialogStickyConfigReq,decoder:Zr.BaseResp}),r})(Pn(e),t).then((r=>(!r.code&&ai.get().addStatus({...e,isTop:t},!0),r.code)))}saveConversationMessageDraft(e,t){ai.get().setDraft(e,t)}getConversationMessageDraft(e){return ai.get().getDraft(e)}clearConversationMessageDraft(e){ai.get().clearDraft(e)}formatConversation(e){const{dialog:t,msg:r}=e,n=t.destId??"",o=ri(t);if(!o)return;const i=Ho.getDialogAesKeyFromLocal(n);if(!i)return;const s=Yo.parseSingleDialogMessages(n,[r],i)[0];return s?(o.latestMessage=s,o):void 0}}d(Ta,"imClient",void 0);const Ra=e=>{Ia=Ia||new Ta(e)},ka=async e=>{M("token",e,T,!0);const n=await Ia.connect(e);return n.code===t.SUCCESS?{code:n.code,data:{userId:n.userId}}:{code:n.code,msg:r(n.code)}},Aa=()=>Ia.disconnect(),Na=()=>Ia.getConnectionStatus(),xa=()=>Ia.getServerTime(),Da=(e,t,r)=>{Ia.on(e,t,r)};function Ma(e,t,r){Ia.once(e,t,r)}const La=(e,t,r)=>{Ia.off(e,t,r)},Ba=async e=>{E.debug("get conversation list ->");const{code:n,data:o}=await Ia.getConversationList((null==e?void 0:e.count)??20,null,(null==e?void 0:e.startTime)??0,(null==e?void 0:e.order)??0);return n!==t.SUCCESS&&E.warn("get conversation list fail ->"+n+":"+r(n)),{code:n,msg:r(n),data:o}},Ua=async e=>{M("options",e,x,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get conversation ->"+n);const{code:o,data:i}=await Ia.getConversation(e);return o!==t.SUCCESS?(E.warn("get conversation fail ->"+o+":"+r(o)+","+n),{code:o,msg:r(o)}):{code:o,data:i}},ja=async e=>{M("options",e,x,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("remove conversation ->"+n);const o=await Ia.removeConversation(e);return o!==t.SUCCESS?(E.warn("remove conversation fail ->"+o+":"+r(o)+","+n),{code:o,msg:r(o)}):{code:o}},Pa=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get draft ->"+r);const n=Ia.getConversationMessageDraft(e);return Promise.resolve({code:t.SUCCESS,data:n})},Fa=(e,r)=>{M("options",e,x,!0),M("draft",r,T,!0);const n="conversationType:"+e.conversationType+",targetId:"+e.targetId;return E.debug("set draft ->"+n),Ia.saveConversationMessageDraft(e,r),Promise.resolve({code:t.SUCCESS})},Ga=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;return E.debug("delete draft ->"+r),Ia.clearConversationMessageDraft(e),Promise.resolve({code:t.SUCCESS})},qa=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;return E.debug("get unreadMentionedCount ->"+r),Promise.resolve({code:t.SUCCESS,data:Ia.getUnreadMentionedCount(e)})},Ha=()=>{E.debug("getAllUnreadMentionedCount");const e=Ia.getAllUnreadMentionedCount();return Promise.resolve({code:t.SUCCESS,data:e})},za=()=>{E.debug("getAllConversationState");const e=Ia.getAllConversationState();return Promise.resolve({code:t.SUCCESS,data:e})},Ka=(e,r)=>{if(E.debug("get total unread count -> ConversationType:"+JSON.stringify(r)+" includeMuted:"+e),M("includeMuted",e,k,!1),M("conversationTypes",r,A,!1),r)for(const e of r)M("conversationType",e,N,!0);const n=Ia.getAllConversationUnreadCount(r??[],e??!1);return Promise.resolve({code:t.SUCCESS,data:n})},Va=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get unreadCount ->"+r);const n=Ia.getConversationUnreadCount(e);return Promise.resolve({code:t.SUCCESS,data:n})},Wa=e=>{M("options",e,x,!0);const r="conversationType:"+e.conversationType+",targetId:"+e.targetId;return E.debug("clear unreadMsgNum ->"+r),Ia.clearConversationUnreadCount(e),Promise.resolve({code:t.SUCCESS})},$a=()=>(E.debug("clear allMessagesUnreadStatus"),Ia.clearAllConversationsUnreadCount(),Promise.resolve({code:t.SUCCESS})),Ja=e=>{M("options",e,x,!0),E.info("getConversationNotificationLevel ->targetId:"+e.targetId+",conversationType:"+e.conversationType);const r=Ia.getConversationNotificationLevel(e);return Promise.resolve({code:t.SUCCESS,data:r})},Za=async(e,n)=>{M("options",e,x,!0),M("notificationStatus",n,(e=>1===e||2===e),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("set conversation status ->"+o);const i=await Ia.setConversationNotificationStatus(e,n);return i!==t.SUCCESS?(E.warn("set conversation status fail ->"+i+":"+r(i)+","+o),{code:i,msg:r(i)}):{code:i}},Xa=e=>{M("options",e,x,!0),E.info("getConversationNotificationStatus ->targetId:"+e.targetId+",conversationType:"+e.conversationType);const r=Ia.getConversationNotificationStatus(e);return Promise.resolve({code:t.SUCCESS,data:r})},Ya=()=>Ia.getBlockConversationList(),Qa=async function(e){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];M("options",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("set conversation status ->"+o);const i=await Ia.setConversationToTop(e,n);return i!==t.SUCCESS?(E.warn("set conversation status fail ->"+i+":"+r(i)+","+o),{code:i,msg:r(i)}):{code:i}},ec=()=>Ia.getTopConversationList(),tc=(e,t,r,n,o)=>function(n){return o?new qo(e,n):r?new Go(e,n):t?new Fo(e,n):new Po(e,n)},rc=async(e,r,n)=>{if(r instanceof ho==!1)return E.warn("send message fail -> message parameter is not an instance of BaseMessage"),{code:t.PARAMETER_ERROR};M("conversation",e,x,!0),fc(e);const o=await Ia.sendMessage(e,r,n);return pc(e,o.code),o},nc=(e,t,r)=>{const n=new No(t);return rc(e,n,r)},oc=async(e,t,r,n)=>{M("conversation",e,x,!0),M("msgBody.file",t.file,(e=>e instanceof Blob&&e.type.startsWith("image/")),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("send message ->"+o),fc(e);const i=await Ia.sendImageMessage(e,t,r,n);return pc(e,i.code),i},ic=async(e,t,r,n)=>{M("conversation",e,x,!0),M("msgBody.file",t.file,(e=>e instanceof Blob&&e.type.endsWith("image/gif")),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("send message ->"+o),fc(e);const i=await Ia.sendGIFMessage(e,t,r,n);return pc(e,i.code),i},sc=async(e,t,r,n)=>{M("conversation",e,x,!0),M("msgBody.file",t.file,(e=>e instanceof Blob),!0),fc(e);const o=await Ia.sendHQVoiceMessage(e,t,r,n);return pc(e,o.code),o},ac=async(e,t,r,n)=>{M("conversation",e,x,!0),M("msgBody.file",t.file,(e=>e instanceof Blob),!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("send message ->"+o),fc(e);const i=await Ia.sendFileMessage(e,t,r,n);return pc(e,i.code),i},cc=async(e,n)=>{M("options.messageUId",n.messageUId,T,!0),M("options.sentTime",n.sentTime,R,!0),M("conversation",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId+",messageUId:"+n.messageUId;E.debug("recall message ->"+o);const i=await Ia.recallMsg(e,n);return i.code!==t.SUCCESS&&E.warn("recall message fail ->"+i.code+":"+r(i.code)+","+o),i},lc=async(e,n)=>{M("options.timestamp",n.timestamp??0,R),M("options.count",n.count??0,R),M("options.order",n.order??0,(e=>0===e||1===e)),M("conversation",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get history message ->"+o);const i=await Ia.getRemoteHistoryMessages(e,n);return i.code!==t.SUCCESS&&E.warn("get history message fail ->"+i.code+":"+r(i.code)+","+o),i},uc=async(e,n)=>{M("options.timestamp",n.timestamp??0,R),M("options.count",n.count??0,R),M("options.order",n.order??0,(e=>0===e||1===e)),M("conversation",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("get remote history message ->"+o);const i=await Ia.getRemoteHistoryMessages(e,n);return i.code!==t.SUCCESS&&E.warn("get remote history message fail ->"+i.code+":"+r(i.code)+","+o),i},dc=async(e,n)=>{M("messages",n,(e=>b(e)&&!!e.length),!0),n.forEach((e=>{M("messages.messageUId",e.messageUId,T,!0),M("messages.sentTime",e.sentTime,R,!1),M("messages.messageDirection",e.messageDirection,(e=>1===e||2===e),!1)})),M("conversation",e,x,!0);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("delete messages ->"+o);const i=await Ia.deleteRemoteMessage(e,n);return i!==t.SUCCESS?(E.warn("delete message fail ->"+i+":"+r(i)+","+o),{code:i,msg:r(i)}):{code:t.SUCCESS}},hc=async(e,n)=>{M("timestamp",n,(e=>R(e)&&e>=0),!0),M("conversation",e,x);const o="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("clear message ->"+o);const i=await Ia.deleteRemoteMessageByTimestamp(e,n);return i!==t.SUCCESS?(E.warn("clear message ->"+i+":"+r(i)+","+o),{code:i,msg:r(i)}):{code:t.SUCCESS}},fc=e=>{const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.debug("send message ->"+t)},pc=(e,n)=>{if(n!==t.SUCCESS){const t="conversationType:"+e.conversationType+",targetId:"+e.targetId;E.warn("send message fail ->"+n+":"+r(n)+","+t)}};export{Uo as CommandMessage,e as ConnectionStatus,n as ConversationType,t as ErrorCode,r as ErrorDesc,u as Events,Lo as FileMessage,Do as GIFMessage,Mo as HQVoiceMessage,xo as ImageMessage,l as LogLevel,o as MentionedType,s as MessageDirection,c as NotificationLevel,i as NotificationStatus,a as ReceivedStatus,No as TextMessage,Da as addEventListener,$a as clearAllMessagesUnreadStatus,hc as clearHistoryMessages,Wa as clearMessagesUnreadStatus,Ga as clearTextMessageDraft,ka as connect,dc as deleteMessages,Aa as disconnect,za as getAllConversationState,Ha as getAllUnreadMentionedCount,Ya as getBlockedConversationList,Na as getConnectionStatus,Ua as getConversation,Ba as getConversationList,Ja as getConversationNotificationLevel,Xa as getConversationNotificationStatus,lc as getHistoryMessages,uc as getRemoteHistoryMessages,xa as getServerTime,Pa as getTextMessageDraft,ec as getTopConversationList,Ka as getTotalUnreadCount,Va as getUnreadCount,qa as getUnreadMentionedCount,Ra as init,Ma as onceEventListener,cc as recallMessage,tc as registerMessageType,ja as removeConversation,La as removeEventListener,Fa as saveTextMessageDraft,ac as sendFileMessage,ic as sendGIFMessage,sc as sendHQVoiceMessage,oc as sendImageMessage,rc as sendMessage,nc as sendTextMessage,Za as setConversationNotificationStatus,Qa as setConversationToTop};
|