import{ah as e1,ai as Ye,g as t1,e as Pd,r as Gn,w as Jf,y as Tt,N as $t,j as r1,aj as k0,ak as O0,al as U0,am as L0,an as M0,ao as j0,ap as n1}from"../vendor-25kWu5S3.js";var eg={exports:{}};function a1(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Sc={exports:{}};const s1={},i1=Object.freeze(Object.defineProperty({__proto__:null,default:s1},Symbol.toStringTag,{value:"Module"})),o1=e1(i1);var F0;function it(){return F0||(F0=1,function(e,t){(function(r,n){e.exports=n()})(Ye,function(){var r=r||function(n,a){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof Ye<"u"&&Ye.crypto&&(s=Ye.crypto),!s&&typeof a1=="function")try{s=o1}catch{}var i=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function m(){}return function(v){var S;return m.prototype=v,S=new m,m.prototype=null,S}}(),c={},u=c.lib={},l=u.Base=function(){return{extend:function(m){var v=o(this);return m&&v.mixIn(m),(!v.hasOwnProperty("init")||this.init===v.init)&&(v.init=function(){v.$super.init.apply(this,arguments)}),v.init.prototype=v,v.$super=this,v},create:function(){var m=this.extend();return m.init.apply(m,arguments),m},init:function(){},mixIn:function(m){for(var v in m)m.hasOwnProperty(v)&&(this[v]=m[v]);m.hasOwnProperty("toString")&&(this.toString=m.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=u.WordArray=l.extend({init:function(m,v){m=this.words=m||[],v!=a?this.sigBytes=v:this.sigBytes=m.length*4},toString:function(m){return(m||p).stringify(this)},concat:function(m){var v=this.words,S=m.words,C=this.sigBytes,E=m.sigBytes;if(this.clamp(),C%4)for(var w=0;w<E;w++){var _=S[w>>>2]>>>24-w%4*8&255;v[C+w>>>2]|=_<<24-(C+w)%4*8}else for(var P=0;P<E;P+=4)v[C+P>>>2]=S[P>>>2];return this.sigBytes+=E,this},clamp:function(){var m=this.words,v=this.sigBytes;m[v>>>2]&=4294967295<<32-v%4*8,m.length=n.ceil(v/4)},clone:function(){var m=l.clone.call(this);return m.words=this.words.slice(0),m},random:function(m){for(var v=[],S=0;S<m;S+=4)v.push(i());return new d.init(v,m)}}),h=c.enc={},p=h.Hex={stringify:function(m){for(var v=m.words,S=m.sigBytes,C=[],E=0;E<S;E++){var w=v[E>>>2]>>>24-E%4*8&255;C.push((w>>>4).toString(16)),C.push((w&15).toString(16))}return C.join("")},parse:function(m){for(var v=m.length,S=[],C=0;C<v;C+=2)S[C>>>3]|=parseInt(m.substr(C,2),16)<<24-C%8*4;return new d.init(S,v/2)}},f=h.Latin1={stringify:function(m){for(var v=m.words,S=m.sigBytes,C=[],E=0;E<S;E++){var w=v[E>>>2]>>>24-E%4*8&255;C.push(String.fromCharCode(w))}return C.join("")},parse:function(m){for(var v=m.length,S=[],C=0;C<v;C++)S[C>>>2]|=(m.charCodeAt(C)&255)<<24-C%4*8;return new d.init(S,v)}},g=h.Utf8={stringify:function(m){try{return decodeURIComponent(escape(f.stringify(m)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(m){return f.parse(unescape(encodeURIComponent(m)))}},y=u.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(m){typeof m=="string"&&(m=g.parse(m)),this._data.concat(m),this._nDataBytes+=m.sigBytes},_process:function(m){var v,S=this._data,C=S.words,E=S.sigBytes,w=this.blockSize,_=w*4,P=E/_;m?P=n.ceil(P):P=n.max((P|0)-this._minBufferSize,0);var x=P*w,R=n.min(x*4,E);if(x){for(var B=0;B<x;B+=w)this._doProcessBlock(C,B);v=C.splice(0,x),S.sigBytes-=R}return new d.init(v,R)},clone:function(){var m=l.clone.call(this);return m._data=this._data.clone(),m},_minBufferSize:0});u.Hasher=y.extend({cfg:l.extend(),init:function(m){this.cfg=this.cfg.extend(m),this.reset()},reset:function(){y.reset.call(this),this._doReset()},update:function(m){return this._append(m),this._process(),this},finalize:function(m){m&&this._append(m);var v=this._doFinalize();return v},blockSize:16,_createHelper:function(m){return function(v,S){return new m.init(S).finalize(v)}},_createHmacHelper:function(m){return function(v,S){return new b.HMAC.init(m,S).finalize(v)}}});var b=c.algo={};return c}(Math);return r})}(Sc)),Sc.exports}var Ec={exports:{}},q0;function Do(){return q0||(q0=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){return function(n){var a=r,s=a.lib,i=s.Base,o=s.WordArray,c=a.x64={};c.Word=i.extend({init:function(u,l){this.high=u,this.low=l}}),c.WordArray=i.extend({init:function(u,l){u=this.words=u||[],l!=n?this.sigBytes=l:this.sigBytes=u.length*8},toX32:function(){for(var u=this.words,l=u.length,d=[],h=0;h<l;h++){var p=u[h];d.push(p.high),d.push(p.low)}return o.create(d,this.sigBytes)},clone:function(){for(var u=i.clone.call(this),l=u.words=this.words.slice(0),d=l.length,h=0;h<d;h++)l[h]=l[h].clone();return u}})}(),r})}(Ec)),Ec.exports}var xc={exports:{}},H0;function c1(){return H0||(H0=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){return function(){if(typeof ArrayBuffer=="function"){var n=r,a=n.lib,s=a.WordArray,i=s.init,o=s.init=function(c){if(c instanceof ArrayBuffer&&(c=new Uint8Array(c)),(c instanceof Int8Array||typeof Uint8ClampedArray<"u"&&c instanceof Uint8ClampedArray||c instanceof Int16Array||c instanceof Uint16Array||c instanceof Int32Array||c instanceof Uint32Array||c instanceof Float32Array||c instanceof Float64Array)&&(c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength)),c instanceof Uint8Array){for(var u=c.byteLength,l=[],d=0;d<u;d++)l[d>>>2]|=c[d]<<24-d%4*8;i.call(this,l,u)}else i.apply(this,arguments)};o.prototype=s}}(),r.lib.WordArray})}(xc)),xc.exports}var wc={exports:{}},K0;function u1(){return K0||(K0=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.WordArray,i=n.enc;i.Utf16=i.Utf16BE={stringify:function(c){for(var u=c.words,l=c.sigBytes,d=[],h=0;h<l;h+=2){var p=u[h>>>2]>>>16-h%4*8&65535;d.push(String.fromCharCode(p))}return d.join("")},parse:function(c){for(var u=c.length,l=[],d=0;d<u;d++)l[d>>>1]|=c.charCodeAt(d)<<16-d%2*16;return s.create(l,u*2)}},i.Utf16LE={stringify:function(c){for(var u=c.words,l=c.sigBytes,d=[],h=0;h<l;h+=2){var p=o(u[h>>>2]>>>16-h%4*8&65535);d.push(String.fromCharCode(p))}return d.join("")},parse:function(c){for(var u=c.length,l=[],d=0;d<u;d++)l[d>>>1]|=o(c.charCodeAt(d)<<16-d%2*16);return s.create(l,u*2)}};function o(c){return c<<8&4278255360|c>>>8&16711935}}(),r.enc.Utf16})}(wc)),wc.exports}var Tc={exports:{}},V0;function os(){return V0||(V0=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.WordArray,i=n.enc;i.Base64={stringify:function(c){var u=c.words,l=c.sigBytes,d=this._map;c.clamp();for(var h=[],p=0;p<l;p+=3)for(var f=u[p>>>2]>>>24-p%4*8&255,g=u[p+1>>>2]>>>24-(p+1)%4*8&255,y=u[p+2>>>2]>>>24-(p+2)%4*8&255,b=f<<16|g<<8|y,m=0;m<4&&p+m*.75<l;m++)h.push(d.charAt(b>>>6*(3-m)&63));var v=d.charAt(64);if(v)for(;h.length%4;)h.push(v);return h.join("")},parse:function(c){var u=c.length,l=this._map,d=this._reverseMap;if(!d){d=this._reverseMap=[];for(var h=0;h<l.length;h++)d[l.charCodeAt(h)]=h}var p=l.charAt(64);if(p){var f=c.indexOf(p);f!==-1&&(u=f)}return o(c,u,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function o(c,u,l){for(var d=[],h=0,p=0;p<u;p++)if(p%4){var f=l[c.charCodeAt(p-1)]<<p%4*2,g=l[c.charCodeAt(p)]>>>6-p%4*2,y=f|g;d[h>>>2]|=y<<24-h%4*8,h++}return s.create(d,h)}}(),r.enc.Base64})}(Tc)),Tc.exports}var $c={exports:{}},z0;function l1(){return z0||(z0=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.WordArray,i=n.enc;i.Base64url={stringify:function(c,u=!0){var l=c.words,d=c.sigBytes,h=u?this._safe_map:this._map;c.clamp();for(var p=[],f=0;f<d;f+=3)for(var g=l[f>>>2]>>>24-f%4*8&255,y=l[f+1>>>2]>>>24-(f+1)%4*8&255,b=l[f+2>>>2]>>>24-(f+2)%4*8&255,m=g<<16|y<<8|b,v=0;v<4&&f+v*.75<d;v++)p.push(h.charAt(m>>>6*(3-v)&63));var S=h.charAt(64);if(S)for(;p.length%4;)p.push(S);return p.join("")},parse:function(c,u=!0){var l=c.length,d=u?this._safe_map:this._map,h=this._reverseMap;if(!h){h=this._reverseMap=[];for(var p=0;p<d.length;p++)h[d.charCodeAt(p)]=p}var f=d.charAt(64);if(f){var g=c.indexOf(f);g!==-1&&(l=g)}return o(c,l,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function o(c,u,l){for(var d=[],h=0,p=0;p<u;p++)if(p%4){var f=l[c.charCodeAt(p-1)]<<p%4*2,g=l[c.charCodeAt(p)]>>>6-p%4*2,y=f|g;d[h>>>2]|=y<<24-h%4*8,h++}return s.create(d,h)}}(),r.enc.Base64url})}($c)),$c.exports}var Ac={exports:{}},G0;function cs(){return G0||(G0=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){return function(n){var a=r,s=a.lib,i=s.WordArray,o=s.Hasher,c=a.algo,u=[];(function(){for(var g=0;g<64;g++)u[g]=n.abs(n.sin(g+1))*4294967296|0})();var l=c.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(g,y){for(var b=0;b<16;b++){var m=y+b,v=g[m];g[m]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360}var S=this._hash.words,C=g[y+0],E=g[y+1],w=g[y+2],_=g[y+3],P=g[y+4],x=g[y+5],R=g[y+6],B=g[y+7],K=g[y+8],re=g[y+9],ee=g[y+10],ie=g[y+11],se=g[y+12],Ce=g[y+13],Ie=g[y+14],ye=g[y+15],L=S[0],X=S[1],ne=S[2],U=S[3];L=d(L,X,ne,U,C,7,u[0]),U=d(U,L,X,ne,E,12,u[1]),ne=d(ne,U,L,X,w,17,u[2]),X=d(X,ne,U,L,_,22,u[3]),L=d(L,X,ne,U,P,7,u[4]),U=d(U,L,X,ne,x,12,u[5]),ne=d(ne,U,L,X,R,17,u[6]),X=d(X,ne,U,L,B,22,u[7]),L=d(L,X,ne,U,K,7,u[8]),U=d(U,L,X,ne,re,12,u[9]),ne=d(ne,U,L,X,ee,17,u[10]),X=d(X,ne,U,L,ie,22,u[11]),L=d(L,X,ne,U,se,7,u[12]),U=d(U,L,X,ne,Ce,12,u[13]),ne=d(ne,U,L,X,Ie,17,u[14]),X=d(X,ne,U,L,ye,22,u[15]),L=h(L,X,ne,U,E,5,u[16]),U=h(U,L,X,ne,R,9,u[17]),ne=h(ne,U,L,X,ie,14,u[18]),X=h(X,ne,U,L,C,20,u[19]),L=h(L,X,ne,U,x,5,u[20]),U=h(U,L,X,ne,ee,9,u[21]),ne=h(ne,U,L,X,ye,14,u[22]),X=h(X,ne,U,L,P,20,u[23]),L=h(L,X,ne,U,re,5,u[24]),U=h(U,L,X,ne,Ie,9,u[25]),ne=h(ne,U,L,X,_,14,u[26]),X=h(X,ne,U,L,K,20,u[27]),L=h(L,X,ne,U,Ce,5,u[28]),U=h(U,L,X,ne,w,9,u[29]),ne=h(ne,U,L,X,B,14,u[30]),X=h(X,ne,U,L,se,20,u[31]),L=p(L,X,ne,U,x,4,u[32]),U=p(U,L,X,ne,K,11,u[33]),ne=p(ne,U,L,X,ie,16,u[34]),X=p(X,ne,U,L,Ie,23,u[35]),L=p(L,X,ne,U,E,4,u[36]),U=p(U,L,X,ne,P,11,u[37]),ne=p(ne,U,L,X,B,16,u[38]),X=p(X,ne,U,L,ee,23,u[39]),L=p(L,X,ne,U,Ce,4,u[40]),U=p(U,L,X,ne,C,11,u[41]),ne=p(ne,U,L,X,_,16,u[42]),X=p(X,ne,U,L,R,23,u[43]),L=p(L,X,ne,U,re,4,u[44]),U=p(U,L,X,ne,se,11,u[45]),ne=p(ne,U,L,X,ye,16,u[46]),X=p(X,ne,U,L,w,23,u[47]),L=f(L,X,ne,U,C,6,u[48]),U=f(U,L,X,ne,B,10,u[49]),ne=f(ne,U,L,X,Ie,15,u[50]),X=f(X,ne,U,L,x,21,u[51]),L=f(L,X,ne,U,se,6,u[52]),U=f(U,L,X,ne,_,10,u[53]),ne=f(ne,U,L,X,ee,15,u[54]),X=f(X,ne,U,L,E,21,u[55]),L=f(L,X,ne,U,K,6,u[56]),U=f(U,L,X,ne,ye,10,u[57]),ne=f(ne,U,L,X,R,15,u[58]),X=f(X,ne,U,L,Ce,21,u[59]),L=f(L,X,ne,U,P,6,u[60]),U=f(U,L,X,ne,ie,10,u[61]),ne=f(ne,U,L,X,w,15,u[62]),X=f(X,ne,U,L,re,21,u[63]),S[0]=S[0]+L|0,S[1]=S[1]+X|0,S[2]=S[2]+ne|0,S[3]=S[3]+U|0},_doFinalize:function(){var g=this._data,y=g.words,b=this._nDataBytes*8,m=g.sigBytes*8;y[m>>>5]|=128<<24-m%32;var v=n.floor(b/4294967296),S=b;y[(m+64>>>9<<4)+15]=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,y[(m+64>>>9<<4)+14]=(S<<8|S>>>24)&16711935|(S<<24|S>>>8)&4278255360,g.sigBytes=(y.length+1)*4,this._process();for(var C=this._hash,E=C.words,w=0;w<4;w++){var _=E[w];E[w]=(_<<8|_>>>24)&16711935|(_<<24|_>>>8)&4278255360}return C},clone:function(){var g=o.clone.call(this);return g._hash=this._hash.clone(),g}});function d(g,y,b,m,v,S,C){var E=g+(y&b|~y&m)+v+C;return(E<<S|E>>>32-S)+y}function h(g,y,b,m,v,S,C){var E=g+(y&m|b&~m)+v+C;return(E<<S|E>>>32-S)+y}function p(g,y,b,m,v,S,C){var E=g+(y^b^m)+v+C;return(E<<S|E>>>32-S)+y}function f(g,y,b,m,v,S,C){var E=g+(b^(y|~m))+v+C;return(E<<S|E>>>32-S)+y}a.MD5=o._createHelper(l),a.HmacMD5=o._createHmacHelper(l)}(Math),r.MD5})}(Ac)),Ac.exports}var Ic={exports:{}},Q0;function _d(){return Q0||(Q0=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.WordArray,i=a.Hasher,o=n.algo,c=[],u=o.SHA1=i.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(l,d){for(var h=this._hash.words,p=h[0],f=h[1],g=h[2],y=h[3],b=h[4],m=0;m<80;m++){if(m<16)c[m]=l[d+m]|0;else{var v=c[m-3]^c[m-8]^c[m-14]^c[m-16];c[m]=v<<1|v>>>31}var S=(p<<5|p>>>27)+b+c[m];m<20?S+=(f&g|~f&y)+1518500249:m<40?S+=(f^g^y)+1859775393:m<60?S+=(f&g|f&y|g&y)-1894007588:S+=(f^g^y)-899497514,b=y,y=g,g=f<<30|f>>>2,f=p,p=S}h[0]=h[0]+p|0,h[1]=h[1]+f|0,h[2]=h[2]+g|0,h[3]=h[3]+y|0,h[4]=h[4]+b|0},_doFinalize:function(){var l=this._data,d=l.words,h=this._nDataBytes*8,p=l.sigBytes*8;return d[p>>>5]|=128<<24-p%32,d[(p+64>>>9<<4)+14]=Math.floor(h/4294967296),d[(p+64>>>9<<4)+15]=h,l.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var l=i.clone.call(this);return l._hash=this._hash.clone(),l}});n.SHA1=i._createHelper(u),n.HmacSHA1=i._createHmacHelper(u)}(),r.SHA1})}(Ic)),Ic.exports}var Pc={exports:{}},W0;function tg(){return W0||(W0=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){return function(n){var a=r,s=a.lib,i=s.WordArray,o=s.Hasher,c=a.algo,u=[],l=[];(function(){function p(b){for(var m=n.sqrt(b),v=2;v<=m;v++)if(!(b%v))return!1;return!0}function f(b){return(b-(b|0))*4294967296|0}for(var g=2,y=0;y<64;)p(g)&&(y<8&&(u[y]=f(n.pow(g,1/2))),l[y]=f(n.pow(g,1/3)),y++),g++})();var d=[],h=c.SHA256=o.extend({_doReset:function(){this._hash=new i.init(u.slice(0))},_doProcessBlock:function(p,f){for(var g=this._hash.words,y=g[0],b=g[1],m=g[2],v=g[3],S=g[4],C=g[5],E=g[6],w=g[7],_=0;_<64;_++){if(_<16)d[_]=p[f+_]|0;else{var P=d[_-15],x=(P<<25|P>>>7)^(P<<14|P>>>18)^P>>>3,R=d[_-2],B=(R<<15|R>>>17)^(R<<13|R>>>19)^R>>>10;d[_]=x+d[_-7]+B+d[_-16]}var K=S&C^~S&E,re=y&b^y&m^b&m,ee=(y<<30|y>>>2)^(y<<19|y>>>13)^(y<<10|y>>>22),ie=(S<<26|S>>>6)^(S<<21|S>>>11)^(S<<7|S>>>25),se=w+ie+K+l[_]+d[_],Ce=ee+re;w=E,E=C,C=S,S=v+se|0,v=m,m=b,b=y,y=se+Ce|0}g[0]=g[0]+y|0,g[1]=g[1]+b|0,g[2]=g[2]+m|0,g[3]=g[3]+v|0,g[4]=g[4]+S|0,g[5]=g[5]+C|0,g[6]=g[6]+E|0,g[7]=g[7]+w|0},_doFinalize:function(){var p=this._data,f=p.words,g=this._nDataBytes*8,y=p.sigBytes*8;return f[y>>>5]|=128<<24-y%32,f[(y+64>>>9<<4)+14]=n.floor(g/4294967296),f[(y+64>>>9<<4)+15]=g,p.sigBytes=f.length*4,this._process(),this._hash},clone:function(){var p=o.clone.call(this);return p._hash=this._hash.clone(),p}});a.SHA256=o._createHelper(h),a.HmacSHA256=o._createHmacHelper(h)}(Math),r.SHA256})}(Pc)),Pc.exports}var _c={exports:{}},Z0;function d1(){return Z0||(Z0=1,function(e,t){(function(r,n,a){e.exports=n(it(),tg())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.WordArray,i=n.algo,o=i.SHA256,c=i.SHA224=o.extend({_doReset:function(){this._hash=new s.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var u=o._doFinalize.call(this);return u.sigBytes-=4,u}});n.SHA224=o._createHelper(c),n.HmacSHA224=o._createHmacHelper(c)}(),r.SHA224})}(_c)),_c.exports}var Dc={exports:{}},Y0;function rg(){return Y0||(Y0=1,function(e,t){(function(r,n,a){e.exports=n(it(),Do())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.Hasher,i=n.x64,o=i.Word,c=i.WordArray,u=n.algo;function l(){return o.create.apply(o,arguments)}var d=[l(1116352408,3609767458),l(1899447441,602891725),l(3049323471,3964484399),l(3921009573,2173295548),l(961987163,4081628472),l(1508970993,3053834265),l(2453635748,2937671579),l(2870763221,3664609560),l(3624381080,2734883394),l(310598401,1164996542),l(607225278,1323610764),l(1426881987,3590304994),l(1925078388,4068182383),l(2162078206,991336113),l(2614888103,633803317),l(3248222580,3479774868),l(3835390401,2666613458),l(4022224774,944711139),l(264347078,2341262773),l(604807628,2007800933),l(770255983,1495990901),l(1249150122,1856431235),l(1555081692,3175218132),l(1996064986,2198950837),l(2554220882,3999719339),l(2821834349,766784016),l(2952996808,2566594879),l(3210313671,3203337956),l(3336571891,1034457026),l(3584528711,2466948901),l(113926993,3758326383),l(338241895,168717936),l(666307205,1188179964),l(773529912,1546045734),l(1294757372,1522805485),l(1396182291,2643833823),l(1695183700,2343527390),l(1986661051,1014477480),l(2177026350,1206759142),l(2456956037,344077627),l(2730485921,1290863460),l(2820302411,3158454273),l(3259730800,3505952657),l(3345764771,106217008),l(3516065817,3606008344),l(3600352804,1432725776),l(4094571909,1467031594),l(275423344,851169720),l(430227734,3100823752),l(506948616,1363258195),l(659060556,3750685593),l(883997877,3785050280),l(958139571,3318307427),l(1322822218,3812723403),l(1537002063,2003034995),l(1747873779,3602036899),l(1955562222,1575990012),l(2024104815,1125592928),l(2227730452,2716904306),l(2361852424,442776044),l(2428436474,593698344),l(2756734187,3733110249),l(3204031479,2999351573),l(3329325298,3815920427),l(3391569614,3928383900),l(3515267271,566280711),l(3940187606,3454069534),l(4118630271,4000239992),l(116418474,1914138554),l(174292421,2731055270),l(289380356,3203993006),l(460393269,320620315),l(685471733,587496836),l(852142971,1086792851),l(1017036298,365543100),l(1126000580,2618297676),l(1288033470,3409855158),l(1501505948,4234509866),l(1607167915,987167468),l(1816402316,1246189591)],h=[];(function(){for(var f=0;f<80;f++)h[f]=l()})();var p=u.SHA512=s.extend({_doReset:function(){this._hash=new c.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(f,g){for(var y=this._hash.words,b=y[0],m=y[1],v=y[2],S=y[3],C=y[4],E=y[5],w=y[6],_=y[7],P=b.high,x=b.low,R=m.high,B=m.low,K=v.high,re=v.low,ee=S.high,ie=S.low,se=C.high,Ce=C.low,Ie=E.high,ye=E.low,L=w.high,X=w.low,ne=_.high,U=_.low,be=P,xe=x,Ne=R,he=B,_e=K,I=re,D=ee,N=ie,q=se,k=Ce,V=Ie,W=ye,j=L,z=X,Z=ne,M=U,te=0;te<80;te++){var ge,G,Ge=h[te];if(te<16)G=Ge.high=f[g+te*2]|0,ge=Ge.low=f[g+te*2+1]|0;else{var gt=h[te-15],ot=gt.high,Ke=gt.low,ht=(ot>>>1|Ke<<31)^(ot>>>8|Ke<<24)^ot>>>7,Ut=(Ke>>>1|ot<<31)^(Ke>>>8|ot<<24)^(Ke>>>7|ot<<25),Qr=h[te-2],Xt=Qr.high,pr=Qr.low,xr=(Xt>>>19|pr<<13)^(Xt<<3|pr>>>29)^Xt>>>6,qr=(pr>>>19|Xt<<13)^(pr<<3|Xt>>>29)^(pr>>>6|Xt<<26),zt=h[te-7],qt=zt.high,xt=zt.low,As=h[te-16],hc=As.high,Is=As.low;ge=Ut+xt,G=ht+qt+(ge>>>0<Ut>>>0?1:0),ge=ge+qr,G=G+xr+(ge>>>0<qr>>>0?1:0),ge=ge+Is,G=G+hc+(ge>>>0<Is>>>0?1:0),Ge.high=G,Ge.low=ge}var pc=q&V^~q&j,Ps=k&W^~k&z,fc=be&Ne^be&_e^Ne&_e,gc=xe&he^xe&I^he&I,mc=(be>>>28|xe<<4)^(be<<30|xe>>>2)^(be<<25|xe>>>7),_s=(xe>>>28|be<<4)^(xe<<30|be>>>2)^(xe<<25|be>>>7),yc=(q>>>14|k<<18)^(q>>>18|k<<14)^(q<<23|k>>>9),vc=(k>>>14|q<<18)^(k>>>18|q<<14)^(k<<23|q>>>9),Ds=d[te],bc=Ds.high,Rs=Ds.low,vt=M+vc,Jt=Z+yc+(vt>>>0<M>>>0?1:0),vt=vt+Ps,Jt=Jt+pc+(vt>>>0<Ps>>>0?1:0),vt=vt+Rs,Jt=Jt+bc+(vt>>>0<Rs>>>0?1:0),vt=vt+ge,Jt=Jt+G+(vt>>>0<ge>>>0?1:0),Ns=_s+gc,Cc=mc+fc+(Ns>>>0<_s>>>0?1:0);Z=j,M=z,j=V,z=W,V=q,W=k,k=N+vt|0,q=D+Jt+(k>>>0<N>>>0?1:0)|0,D=_e,N=I,_e=Ne,I=he,Ne=be,he=xe,xe=vt+Ns|0,be=Jt+Cc+(xe>>>0<vt>>>0?1:0)|0}x=b.low=x+xe,b.high=P+be+(x>>>0<xe>>>0?1:0),B=m.low=B+he,m.high=R+Ne+(B>>>0<he>>>0?1:0),re=v.low=re+I,v.high=K+_e+(re>>>0<I>>>0?1:0),ie=S.low=ie+N,S.high=ee+D+(ie>>>0<N>>>0?1:0),Ce=C.low=Ce+k,C.high=se+q+(Ce>>>0<k>>>0?1:0),ye=E.low=ye+W,E.high=Ie+V+(ye>>>0<W>>>0?1:0),X=w.low=X+z,w.high=L+j+(X>>>0<z>>>0?1:0),U=_.low=U+M,_.high=ne+Z+(U>>>0<M>>>0?1:0)},_doFinalize:function(){var f=this._data,g=f.words,y=this._nDataBytes*8,b=f.sigBytes*8;g[b>>>5]|=128<<24-b%32,g[(b+128>>>10<<5)+30]=Math.floor(y/4294967296),g[(b+128>>>10<<5)+31]=y,f.sigBytes=g.length*4,this._process();var m=this._hash.toX32();return m},clone:function(){var f=s.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:1024/32});n.SHA512=s._createHelper(p),n.HmacSHA512=s._createHmacHelper(p)}(),r.SHA512})}(Dc)),Dc.exports}var Rc={exports:{}},X0;function h1(){return X0||(X0=1,function(e,t){(function(r,n,a){e.exports=n(it(),Do(),rg())})(Ye,function(r){return function(){var n=r,a=n.x64,s=a.Word,i=a.WordArray,o=n.algo,c=o.SHA512,u=o.SHA384=c.extend({_doReset:function(){this._hash=new i.init([new s.init(3418070365,3238371032),new s.init(1654270250,914150663),new s.init(2438529370,812702999),new s.init(355462360,4144912697),new s.init(1731405415,4290775857),new s.init(2394180231,1750603025),new s.init(3675008525,1694076839),new s.init(1203062813,3204075428)])},_doFinalize:function(){var l=c._doFinalize.call(this);return l.sigBytes-=16,l}});n.SHA384=c._createHelper(u),n.HmacSHA384=c._createHmacHelper(u)}(),r.SHA384})}(Rc)),Rc.exports}var Nc={exports:{}},J0;function p1(){return J0||(J0=1,function(e,t){(function(r,n,a){e.exports=n(it(),Do())})(Ye,function(r){return function(n){var a=r,s=a.lib,i=s.WordArray,o=s.Hasher,c=a.x64,u=c.Word,l=a.algo,d=[],h=[],p=[];(function(){for(var y=1,b=0,m=0;m<24;m++){d[y+5*b]=(m+1)*(m+2)/2%64;var v=b%5,S=(2*y+3*b)%5;y=v,b=S}for(var y=0;y<5;y++)for(var b=0;b<5;b++)h[y+5*b]=b+(2*y+3*b)%5*5;for(var C=1,E=0;E<24;E++){for(var w=0,_=0,P=0;P<7;P++){if(C&1){var x=(1<<P)-1;x<32?_^=1<<x:w^=1<<x-32}C&128?C=C<<1^113:C<<=1}p[E]=u.create(w,_)}})();var f=[];(function(){for(var y=0;y<25;y++)f[y]=u.create()})();var g=l.SHA3=o.extend({cfg:o.cfg.extend({outputLength:512}),_doReset:function(){for(var y=this._state=[],b=0;b<25;b++)y[b]=new u.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(y,b){for(var m=this._state,v=this.blockSize/2,S=0;S<v;S++){var C=y[b+2*S],E=y[b+2*S+1];C=(C<<8|C>>>24)&16711935|(C<<24|C>>>8)&4278255360,E=(E<<8|E>>>24)&16711935|(E<<24|E>>>8)&4278255360;var w=m[S];w.high^=E,w.low^=C}for(var _=0;_<24;_++){for(var P=0;P<5;P++){for(var x=0,R=0,B=0;B<5;B++){var w=m[P+5*B];x^=w.high,R^=w.low}var K=f[P];K.high=x,K.low=R}for(var P=0;P<5;P++)for(var re=f[(P+4)%5],ee=f[(P+1)%5],ie=ee.high,se=ee.low,x=re.high^(ie<<1|se>>>31),R=re.low^(se<<1|ie>>>31),B=0;B<5;B++){var w=m[P+5*B];w.high^=x,w.low^=R}for(var Ce=1;Ce<25;Ce++){var x,R,w=m[Ce],Ie=w.high,ye=w.low,L=d[Ce];L<32?(x=Ie<<L|ye>>>32-L,R=ye<<L|Ie>>>32-L):(x=ye<<L-32|Ie>>>64-L,R=Ie<<L-32|ye>>>64-L);var X=f[h[Ce]];X.high=x,X.low=R}var ne=f[0],U=m[0];ne.high=U.high,ne.low=U.low;for(var P=0;P<5;P++)for(var B=0;B<5;B++){var Ce=P+5*B,w=m[Ce],be=f[Ce],xe=f[(P+1)%5+5*B],Ne=f[(P+2)%5+5*B];w.high=be.high^~xe.high&Ne.high,w.low=be.low^~xe.low&Ne.low}var w=m[0],he=p[_];w.high^=he.high,w.low^=he.low}},_doFinalize:function(){var y=this._data,b=y.words;this._nDataBytes*8;var m=y.sigBytes*8,v=this.blockSize*32;b[m>>>5]|=1<<24-m%32,b[(n.ceil((m+1)/v)*v>>>5)-1]|=128,y.sigBytes=b.length*4,this._process();for(var S=this._state,C=this.cfg.outputLength/8,E=C/8,w=[],_=0;_<E;_++){var P=S[_],x=P.high,R=P.low;x=(x<<8|x>>>24)&16711935|(x<<24|x>>>8)&4278255360,R=(R<<8|R>>>24)&16711935|(R<<24|R>>>8)&4278255360,w.push(R),w.push(x)}return new i.init(w,C)},clone:function(){for(var y=o.clone.call(this),b=y._state=this._state.slice(0),m=0;m<25;m++)b[m]=b[m].clone();return y}});a.SHA3=o._createHelper(g),a.HmacSHA3=o._createHmacHelper(g)}(Math),r.SHA3})}(Nc)),Nc.exports}var Bc={exports:{}},eh;function f1(){return eh||(eh=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){/** @preserve
			(c) 2012 by Cédric Mesnil. All rights reserved.

			Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

			    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
			    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

			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.
			*/return function(n){var a=r,s=a.lib,i=s.WordArray,o=s.Hasher,c=a.algo,u=i.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]),l=i.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]),d=i.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]),h=i.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]),p=i.create([0,1518500249,1859775393,2400959708,2840853838]),f=i.create([1352829926,1548603684,1836072691,2053994217,0]),g=c.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(E,w){for(var _=0;_<16;_++){var P=w+_,x=E[P];E[P]=(x<<8|x>>>24)&16711935|(x<<24|x>>>8)&4278255360}var R=this._hash.words,B=p.words,K=f.words,re=u.words,ee=l.words,ie=d.words,se=h.words,Ce,Ie,ye,L,X,ne,U,be,xe,Ne;ne=Ce=R[0],U=Ie=R[1],be=ye=R[2],xe=L=R[3],Ne=X=R[4];for(var he,_=0;_<80;_+=1)he=Ce+E[w+re[_]]|0,_<16?he+=y(Ie,ye,L)+B[0]:_<32?he+=b(Ie,ye,L)+B[1]:_<48?he+=m(Ie,ye,L)+B[2]:_<64?he+=v(Ie,ye,L)+B[3]:he+=S(Ie,ye,L)+B[4],he=he|0,he=C(he,ie[_]),he=he+X|0,Ce=X,X=L,L=C(ye,10),ye=Ie,Ie=he,he=ne+E[w+ee[_]]|0,_<16?he+=S(U,be,xe)+K[0]:_<32?he+=v(U,be,xe)+K[1]:_<48?he+=m(U,be,xe)+K[2]:_<64?he+=b(U,be,xe)+K[3]:he+=y(U,be,xe)+K[4],he=he|0,he=C(he,se[_]),he=he+Ne|0,ne=Ne,Ne=xe,xe=C(be,10),be=U,U=he;he=R[1]+ye+xe|0,R[1]=R[2]+L+Ne|0,R[2]=R[3]+X+ne|0,R[3]=R[4]+Ce+U|0,R[4]=R[0]+Ie+be|0,R[0]=he},_doFinalize:function(){var E=this._data,w=E.words,_=this._nDataBytes*8,P=E.sigBytes*8;w[P>>>5]|=128<<24-P%32,w[(P+64>>>9<<4)+14]=(_<<8|_>>>24)&16711935|(_<<24|_>>>8)&4278255360,E.sigBytes=(w.length+1)*4,this._process();for(var x=this._hash,R=x.words,B=0;B<5;B++){var K=R[B];R[B]=(K<<8|K>>>24)&16711935|(K<<24|K>>>8)&4278255360}return x},clone:function(){var E=o.clone.call(this);return E._hash=this._hash.clone(),E}});function y(E,w,_){return E^w^_}function b(E,w,_){return E&w|~E&_}function m(E,w,_){return(E|~w)^_}function v(E,w,_){return E&_|w&~_}function S(E,w,_){return E^(w|~_)}function C(E,w){return E<<w|E>>>32-w}a.RIPEMD160=o._createHelper(g),a.HmacRIPEMD160=o._createHmacHelper(g)}(),r.RIPEMD160})}(Bc)),Bc.exports}var kc={exports:{}},th;function Dd(){return th||(th=1,function(e,t){(function(r,n){e.exports=n(it())})(Ye,function(r){(function(){var n=r,a=n.lib,s=a.Base,i=n.enc,o=i.Utf8,c=n.algo;c.HMAC=s.extend({init:function(u,l){u=this._hasher=new u.init,typeof l=="string"&&(l=o.parse(l));var d=u.blockSize,h=d*4;l.sigBytes>h&&(l=u.finalize(l)),l.clamp();for(var p=this._oKey=l.clone(),f=this._iKey=l.clone(),g=p.words,y=f.words,b=0;b<d;b++)g[b]^=1549556828,y[b]^=909522486;p.sigBytes=f.sigBytes=h,this.reset()},reset:function(){var u=this._hasher;u.reset(),u.update(this._iKey)},update:function(u){return this._hasher.update(u),this},finalize:function(u){var l=this._hasher,d=l.finalize(u);l.reset();var h=l.finalize(this._oKey.clone().concat(d));return h}})})()})}(kc)),kc.exports}var Oc={exports:{}},rh;function g1(){return rh||(rh=1,function(e,t){(function(r,n,a){e.exports=n(it(),_d(),Dd())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.Base,i=a.WordArray,o=n.algo,c=o.SHA1,u=o.HMAC,l=o.PBKDF2=s.extend({cfg:s.extend({keySize:128/32,hasher:c,iterations:1}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,h){for(var p=this.cfg,f=u.create(p.hasher,d),g=i.create(),y=i.create([1]),b=g.words,m=y.words,v=p.keySize,S=p.iterations;b.length<v;){var C=f.update(h).finalize(y);f.reset();for(var E=C.words,w=E.length,_=C,P=1;P<S;P++){_=f.finalize(_),f.reset();for(var x=_.words,R=0;R<w;R++)E[R]^=x[R]}g.concat(C),m[0]++}return g.sigBytes=v*4,g}});n.PBKDF2=function(d,h,p){return l.create(p).compute(d,h)}}(),r.PBKDF2})}(Oc)),Oc.exports}var Uc={exports:{}},nh;function Aa(){return nh||(nh=1,function(e,t){(function(r,n,a){e.exports=n(it(),_d(),Dd())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.Base,i=a.WordArray,o=n.algo,c=o.MD5,u=o.EvpKDF=s.extend({cfg:s.extend({keySize:128/32,hasher:c,iterations:1}),init:function(l){this.cfg=this.cfg.extend(l)},compute:function(l,d){for(var h,p=this.cfg,f=p.hasher.create(),g=i.create(),y=g.words,b=p.keySize,m=p.iterations;y.length<b;){h&&f.update(h),h=f.update(l).finalize(d),f.reset();for(var v=1;v<m;v++)h=f.finalize(h),f.reset();g.concat(h)}return g.sigBytes=b*4,g}});n.EvpKDF=function(l,d,h){return u.create(h).compute(l,d)}}(),r.EvpKDF})}(Uc)),Uc.exports}var Lc={exports:{}},ah;function ar(){return ah||(ah=1,function(e,t){(function(r,n,a){e.exports=n(it(),Aa())})(Ye,function(r){r.lib.Cipher||function(n){var a=r,s=a.lib,i=s.Base,o=s.WordArray,c=s.BufferedBlockAlgorithm,u=a.enc;u.Utf8;var l=u.Base64,d=a.algo,h=d.EvpKDF,p=s.Cipher=c.extend({cfg:i.extend(),createEncryptor:function(x,R){return this.create(this._ENC_XFORM_MODE,x,R)},createDecryptor:function(x,R){return this.create(this._DEC_XFORM_MODE,x,R)},init:function(x,R,B){this.cfg=this.cfg.extend(B),this._xformMode=x,this._key=R,this.reset()},reset:function(){c.reset.call(this),this._doReset()},process:function(x){return this._append(x),this._process()},finalize:function(x){x&&this._append(x);var R=this._doFinalize();return R},keySize:128/32,ivSize:128/32,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function x(R){return typeof R=="string"?P:E}return function(R){return{encrypt:function(B,K,re){return x(K).encrypt(R,B,K,re)},decrypt:function(B,K,re){return x(K).decrypt(R,B,K,re)}}}}()});s.StreamCipher=p.extend({_doFinalize:function(){var x=this._process(!0);return x},blockSize:1});var f=a.mode={},g=s.BlockCipherMode=i.extend({createEncryptor:function(x,R){return this.Encryptor.create(x,R)},createDecryptor:function(x,R){return this.Decryptor.create(x,R)},init:function(x,R){this._cipher=x,this._iv=R}}),y=f.CBC=function(){var x=g.extend();x.Encryptor=x.extend({processBlock:function(B,K){var re=this._cipher,ee=re.blockSize;R.call(this,B,K,ee),re.encryptBlock(B,K),this._prevBlock=B.slice(K,K+ee)}}),x.Decryptor=x.extend({processBlock:function(B,K){var re=this._cipher,ee=re.blockSize,ie=B.slice(K,K+ee);re.decryptBlock(B,K),R.call(this,B,K,ee),this._prevBlock=ie}});function R(B,K,re){var ee,ie=this._iv;ie?(ee=ie,this._iv=n):ee=this._prevBlock;for(var se=0;se<re;se++)B[K+se]^=ee[se]}return x}(),b=a.pad={},m=b.Pkcs7={pad:function(x,R){for(var B=R*4,K=B-x.sigBytes%B,re=K<<24|K<<16|K<<8|K,ee=[],ie=0;ie<K;ie+=4)ee.push(re);var se=o.create(ee,K);x.concat(se)},unpad:function(x){var R=x.words[x.sigBytes-1>>>2]&255;x.sigBytes-=R}};s.BlockCipher=p.extend({cfg:p.cfg.extend({mode:y,padding:m}),reset:function(){var x;p.reset.call(this);var R=this.cfg,B=R.iv,K=R.mode;this._xformMode==this._ENC_XFORM_MODE?x=K.createEncryptor:(x=K.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==x?this._mode.init(this,B&&B.words):(this._mode=x.call(K,this,B&&B.words),this._mode.__creator=x)},_doProcessBlock:function(x,R){this._mode.processBlock(x,R)},_doFinalize:function(){var x,R=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(R.pad(this._data,this.blockSize),x=this._process(!0)):(x=this._process(!0),R.unpad(x)),x},blockSize:128/32});var v=s.CipherParams=i.extend({init:function(x){this.mixIn(x)},toString:function(x){return(x||this.formatter).stringify(this)}}),S=a.format={},C=S.OpenSSL={stringify:function(x){var R,B=x.ciphertext,K=x.salt;return K?R=o.create([1398893684,1701076831]).concat(K).concat(B):R=B,R.toString(l)},parse:function(x){var R,B=l.parse(x),K=B.words;return K[0]==1398893684&&K[1]==1701076831&&(R=o.create(K.slice(2,4)),K.splice(0,4),B.sigBytes-=16),v.create({ciphertext:B,salt:R})}},E=s.SerializableCipher=i.extend({cfg:i.extend({format:C}),encrypt:function(x,R,B,K){K=this.cfg.extend(K);var re=x.createEncryptor(B,K),ee=re.finalize(R),ie=re.cfg;return v.create({ciphertext:ee,key:B,iv:ie.iv,algorithm:x,mode:ie.mode,padding:ie.padding,blockSize:x.blockSize,formatter:K.format})},decrypt:function(x,R,B,K){K=this.cfg.extend(K),R=this._parse(R,K.format);var re=x.createDecryptor(B,K).finalize(R.ciphertext);return re},_parse:function(x,R){return typeof x=="string"?R.parse(x,this):x}}),w=a.kdf={},_=w.OpenSSL={execute:function(x,R,B,K){K||(K=o.random(64/8));var re=h.create({keySize:R+B}).compute(x,K),ee=o.create(re.words.slice(R),B*4);return re.sigBytes=R*4,v.create({key:re,iv:ee,salt:K})}},P=s.PasswordBasedCipher=E.extend({cfg:E.cfg.extend({kdf:_}),encrypt:function(x,R,B,K){K=this.cfg.extend(K);var re=K.kdf.execute(B,x.keySize,x.ivSize);K.iv=re.iv;var ee=E.encrypt.call(this,x,R,re.key,K);return ee.mixIn(re),ee},decrypt:function(x,R,B,K){K=this.cfg.extend(K),R=this._parse(R,K.format);var re=K.kdf.execute(B,x.keySize,x.ivSize,R.salt);K.iv=re.iv;var ee=E.decrypt.call(this,x,R,re.key,K);return ee}})}()})}(Lc)),Lc.exports}var Mc={exports:{}},sh;function m1(){return sh||(sh=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.mode.CFB=function(){var n=r.lib.BlockCipherMode.extend();n.Encryptor=n.extend({processBlock:function(s,i){var o=this._cipher,c=o.blockSize;a.call(this,s,i,c,o),this._prevBlock=s.slice(i,i+c)}}),n.Decryptor=n.extend({processBlock:function(s,i){var o=this._cipher,c=o.blockSize,u=s.slice(i,i+c);a.call(this,s,i,c,o),this._prevBlock=u}});function a(s,i,o,c){var u,l=this._iv;l?(u=l.slice(0),this._iv=void 0):u=this._prevBlock,c.encryptBlock(u,0);for(var d=0;d<o;d++)s[i+d]^=u[d]}return n}(),r.mode.CFB})}(Mc)),Mc.exports}var jc={exports:{}},ih;function y1(){return ih||(ih=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.mode.CTR=function(){var n=r.lib.BlockCipherMode.extend(),a=n.Encryptor=n.extend({processBlock:function(s,i){var o=this._cipher,c=o.blockSize,u=this._iv,l=this._counter;u&&(l=this._counter=u.slice(0),this._iv=void 0);var d=l.slice(0);o.encryptBlock(d,0),l[c-1]=l[c-1]+1|0;for(var h=0;h<c;h++)s[i+h]^=d[h]}});return n.Decryptor=a,n}(),r.mode.CTR})}(jc)),jc.exports}var Fc={exports:{}},oh;function v1(){return oh||(oh=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){/** @preserve
 * Counter block mode compatible with  Dr Brian Gladman fileenc.c
 * derived from CryptoJS.mode.CTR
 * Jan Hruby jhruby.web@gmail.com
 */return r.mode.CTRGladman=function(){var n=r.lib.BlockCipherMode.extend();function a(o){if((o>>24&255)===255){var c=o>>16&255,u=o>>8&255,l=o&255;c===255?(c=0,u===255?(u=0,l===255?l=0:++l):++u):++c,o=0,o+=c<<16,o+=u<<8,o+=l}else o+=1<<24;return o}function s(o){return(o[0]=a(o[0]))===0&&(o[1]=a(o[1])),o}var i=n.Encryptor=n.extend({processBlock:function(o,c){var u=this._cipher,l=u.blockSize,d=this._iv,h=this._counter;d&&(h=this._counter=d.slice(0),this._iv=void 0),s(h);var p=h.slice(0);u.encryptBlock(p,0);for(var f=0;f<l;f++)o[c+f]^=p[f]}});return n.Decryptor=i,n}(),r.mode.CTRGladman})}(Fc)),Fc.exports}var qc={exports:{}},ch;function b1(){return ch||(ch=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.mode.OFB=function(){var n=r.lib.BlockCipherMode.extend(),a=n.Encryptor=n.extend({processBlock:function(s,i){var o=this._cipher,c=o.blockSize,u=this._iv,l=this._keystream;u&&(l=this._keystream=u.slice(0),this._iv=void 0),o.encryptBlock(l,0);for(var d=0;d<c;d++)s[i+d]^=l[d]}});return n.Decryptor=a,n}(),r.mode.OFB})}(qc)),qc.exports}var Hc={exports:{}},uh;function C1(){return uh||(uh=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.mode.ECB=function(){var n=r.lib.BlockCipherMode.extend();return n.Encryptor=n.extend({processBlock:function(a,s){this._cipher.encryptBlock(a,s)}}),n.Decryptor=n.extend({processBlock:function(a,s){this._cipher.decryptBlock(a,s)}}),n}(),r.mode.ECB})}(Hc)),Hc.exports}var Kc={exports:{}},lh;function S1(){return lh||(lh=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.pad.AnsiX923={pad:function(n,a){var s=n.sigBytes,i=a*4,o=i-s%i,c=s+o-1;n.clamp(),n.words[c>>>2]|=o<<24-c%4*8,n.sigBytes+=o},unpad:function(n){var a=n.words[n.sigBytes-1>>>2]&255;n.sigBytes-=a}},r.pad.Ansix923})}(Kc)),Kc.exports}var Vc={exports:{}},dh;function E1(){return dh||(dh=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.pad.Iso10126={pad:function(n,a){var s=a*4,i=s-n.sigBytes%s;n.concat(r.lib.WordArray.random(i-1)).concat(r.lib.WordArray.create([i<<24],1))},unpad:function(n){var a=n.words[n.sigBytes-1>>>2]&255;n.sigBytes-=a}},r.pad.Iso10126})}(Vc)),Vc.exports}var zc={exports:{}},hh;function x1(){return hh||(hh=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.pad.Iso97971={pad:function(n,a){n.concat(r.lib.WordArray.create([2147483648],1)),r.pad.ZeroPadding.pad(n,a)},unpad:function(n){r.pad.ZeroPadding.unpad(n),n.sigBytes--}},r.pad.Iso97971})}(zc)),zc.exports}var Gc={exports:{}},ph;function w1(){return ph||(ph=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.pad.ZeroPadding={pad:function(n,a){var s=a*4;n.clamp(),n.sigBytes+=s-(n.sigBytes%s||s)},unpad:function(n){for(var a=n.words,s=n.sigBytes-1,s=n.sigBytes-1;s>=0;s--)if(a[s>>>2]>>>24-s%4*8&255){n.sigBytes=s+1;break}}},r.pad.ZeroPadding})}(Gc)),Gc.exports}var Qc={exports:{}},fh;function T1(){return fh||(fh=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return r.pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding})}(Qc)),Qc.exports}var Wc={exports:{}},gh;function $1(){return gh||(gh=1,function(e,t){(function(r,n,a){e.exports=n(it(),ar())})(Ye,function(r){return function(n){var a=r,s=a.lib,i=s.CipherParams,o=a.enc,c=o.Hex,u=a.format;u.Hex={stringify:function(l){return l.ciphertext.toString(c)},parse:function(l){var d=c.parse(l);return i.create({ciphertext:d})}}}(),r.format.Hex})}(Wc)),Wc.exports}var Zc={exports:{}},mh;function A1(){return mh||(mh=1,function(e,t){(function(r,n,a){e.exports=n(it(),os(),cs(),Aa(),ar())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.BlockCipher,i=n.algo,o=[],c=[],u=[],l=[],d=[],h=[],p=[],f=[],g=[],y=[];(function(){for(var v=[],S=0;S<256;S++)S<128?v[S]=S<<1:v[S]=S<<1^283;for(var C=0,E=0,S=0;S<256;S++){var w=E^E<<1^E<<2^E<<3^E<<4;w=w>>>8^w&255^99,o[C]=w,c[w]=C;var _=v[C],P=v[_],x=v[P],R=v[w]*257^w*16843008;u[C]=R<<24|R>>>8,l[C]=R<<16|R>>>16,d[C]=R<<8|R>>>24,h[C]=R;var R=x*16843009^P*65537^_*257^C*16843008;p[w]=R<<24|R>>>8,f[w]=R<<16|R>>>16,g[w]=R<<8|R>>>24,y[w]=R,C?(C=_^v[v[v[x^_]]],E^=v[v[E]]):C=E=1}})();var b=[0,1,2,4,8,16,32,64,128,27,54],m=i.AES=s.extend({_doReset:function(){var v;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var S=this._keyPriorReset=this._key,C=S.words,E=S.sigBytes/4,w=this._nRounds=E+6,_=(w+1)*4,P=this._keySchedule=[],x=0;x<_;x++)x<E?P[x]=C[x]:(v=P[x-1],x%E?E>6&&x%E==4&&(v=o[v>>>24]<<24|o[v>>>16&255]<<16|o[v>>>8&255]<<8|o[v&255]):(v=v<<8|v>>>24,v=o[v>>>24]<<24|o[v>>>16&255]<<16|o[v>>>8&255]<<8|o[v&255],v^=b[x/E|0]<<24),P[x]=P[x-E]^v);for(var R=this._invKeySchedule=[],B=0;B<_;B++){var x=_-B;if(B%4)var v=P[x];else var v=P[x-4];B<4||x<=4?R[B]=v:R[B]=p[o[v>>>24]]^f[o[v>>>16&255]]^g[o[v>>>8&255]]^y[o[v&255]]}}},encryptBlock:function(v,S){this._doCryptBlock(v,S,this._keySchedule,u,l,d,h,o)},decryptBlock:function(v,S){var C=v[S+1];v[S+1]=v[S+3],v[S+3]=C,this._doCryptBlock(v,S,this._invKeySchedule,p,f,g,y,c);var C=v[S+1];v[S+1]=v[S+3],v[S+3]=C},_doCryptBlock:function(v,S,C,E,w,_,P,x){for(var R=this._nRounds,B=v[S]^C[0],K=v[S+1]^C[1],re=v[S+2]^C[2],ee=v[S+3]^C[3],ie=4,se=1;se<R;se++){var Ce=E[B>>>24]^w[K>>>16&255]^_[re>>>8&255]^P[ee&255]^C[ie++],Ie=E[K>>>24]^w[re>>>16&255]^_[ee>>>8&255]^P[B&255]^C[ie++],ye=E[re>>>24]^w[ee>>>16&255]^_[B>>>8&255]^P[K&255]^C[ie++],L=E[ee>>>24]^w[B>>>16&255]^_[K>>>8&255]^P[re&255]^C[ie++];B=Ce,K=Ie,re=ye,ee=L}var Ce=(x[B>>>24]<<24|x[K>>>16&255]<<16|x[re>>>8&255]<<8|x[ee&255])^C[ie++],Ie=(x[K>>>24]<<24|x[re>>>16&255]<<16|x[ee>>>8&255]<<8|x[B&255])^C[ie++],ye=(x[re>>>24]<<24|x[ee>>>16&255]<<16|x[B>>>8&255]<<8|x[K&255])^C[ie++],L=(x[ee>>>24]<<24|x[B>>>16&255]<<16|x[K>>>8&255]<<8|x[re&255])^C[ie++];v[S]=Ce,v[S+1]=Ie,v[S+2]=ye,v[S+3]=L},keySize:256/32});n.AES=s._createHelper(m)}(),r.AES})}(Zc)),Zc.exports}var Yc={exports:{}},yh;function I1(){return yh||(yh=1,function(e,t){(function(r,n,a){e.exports=n(it(),os(),cs(),Aa(),ar())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.WordArray,i=a.BlockCipher,o=n.algo,c=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],u=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],l=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],d=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],h=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],p=o.DES=i.extend({_doReset:function(){for(var b=this._key,m=b.words,v=[],S=0;S<56;S++){var C=c[S]-1;v[S]=m[C>>>5]>>>31-C%32&1}for(var E=this._subKeys=[],w=0;w<16;w++){for(var _=E[w]=[],P=l[w],S=0;S<24;S++)_[S/6|0]|=v[(u[S]-1+P)%28]<<31-S%6,_[4+(S/6|0)]|=v[28+(u[S+24]-1+P)%28]<<31-S%6;_[0]=_[0]<<1|_[0]>>>31;for(var S=1;S<7;S++)_[S]=_[S]>>>(S-1)*4+3;_[7]=_[7]<<5|_[7]>>>27}for(var x=this._invSubKeys=[],S=0;S<16;S++)x[S]=E[15-S]},encryptBlock:function(b,m){this._doCryptBlock(b,m,this._subKeys)},decryptBlock:function(b,m){this._doCryptBlock(b,m,this._invSubKeys)},_doCryptBlock:function(b,m,v){this._lBlock=b[m],this._rBlock=b[m+1],f.call(this,4,252645135),f.call(this,16,65535),g.call(this,2,858993459),g.call(this,8,16711935),f.call(this,1,1431655765);for(var S=0;S<16;S++){for(var C=v[S],E=this._lBlock,w=this._rBlock,_=0,P=0;P<8;P++)_|=d[P][((w^C[P])&h[P])>>>0];this._lBlock=w,this._rBlock=E^_}var x=this._lBlock;this._lBlock=this._rBlock,this._rBlock=x,f.call(this,1,1431655765),g.call(this,8,16711935),g.call(this,2,858993459),f.call(this,16,65535),f.call(this,4,252645135),b[m]=this._lBlock,b[m+1]=this._rBlock},keySize:64/32,ivSize:64/32,blockSize:64/32});function f(b,m){var v=(this._lBlock>>>b^this._rBlock)&m;this._rBlock^=v,this._lBlock^=v<<b}function g(b,m){var v=(this._rBlock>>>b^this._lBlock)&m;this._lBlock^=v,this._rBlock^=v<<b}n.DES=i._createHelper(p);var y=o.TripleDES=i.extend({_doReset:function(){var b=this._key,m=b.words;if(m.length!==2&&m.length!==4&&m.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var v=m.slice(0,2),S=m.length<4?m.slice(0,2):m.slice(2,4),C=m.length<6?m.slice(0,2):m.slice(4,6);this._des1=p.createEncryptor(s.create(v)),this._des2=p.createEncryptor(s.create(S)),this._des3=p.createEncryptor(s.create(C))},encryptBlock:function(b,m){this._des1.encryptBlock(b,m),this._des2.decryptBlock(b,m),this._des3.encryptBlock(b,m)},decryptBlock:function(b,m){this._des3.decryptBlock(b,m),this._des2.encryptBlock(b,m),this._des1.decryptBlock(b,m)},keySize:192/32,ivSize:64/32,blockSize:64/32});n.TripleDES=i._createHelper(y)}(),r.TripleDES})}(Yc)),Yc.exports}var Xc={exports:{}},vh;function P1(){return vh||(vh=1,function(e,t){(function(r,n,a){e.exports=n(it(),os(),cs(),Aa(),ar())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.StreamCipher,i=n.algo,o=i.RC4=s.extend({_doReset:function(){for(var l=this._key,d=l.words,h=l.sigBytes,p=this._S=[],f=0;f<256;f++)p[f]=f;for(var f=0,g=0;f<256;f++){var y=f%h,b=d[y>>>2]>>>24-y%4*8&255;g=(g+p[f]+b)%256;var m=p[f];p[f]=p[g],p[g]=m}this._i=this._j=0},_doProcessBlock:function(l,d){l[d]^=c.call(this)},keySize:256/32,ivSize:0});function c(){for(var l=this._S,d=this._i,h=this._j,p=0,f=0;f<4;f++){d=(d+1)%256,h=(h+l[d])%256;var g=l[d];l[d]=l[h],l[h]=g,p|=l[(l[d]+l[h])%256]<<24-f*8}return this._i=d,this._j=h,p}n.RC4=s._createHelper(o);var u=i.RC4Drop=o.extend({cfg:o.cfg.extend({drop:192}),_doReset:function(){o._doReset.call(this);for(var l=this.cfg.drop;l>0;l--)c.call(this)}});n.RC4Drop=s._createHelper(u)}(),r.RC4})}(Xc)),Xc.exports}var Jc={exports:{}},bh;function _1(){return bh||(bh=1,function(e,t){(function(r,n,a){e.exports=n(it(),os(),cs(),Aa(),ar())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.StreamCipher,i=n.algo,o=[],c=[],u=[],l=i.Rabbit=s.extend({_doReset:function(){for(var h=this._key.words,p=this.cfg.iv,f=0;f<4;f++)h[f]=(h[f]<<8|h[f]>>>24)&16711935|(h[f]<<24|h[f]>>>8)&4278255360;var g=this._X=[h[0],h[3]<<16|h[2]>>>16,h[1],h[0]<<16|h[3]>>>16,h[2],h[1]<<16|h[0]>>>16,h[3],h[2]<<16|h[1]>>>16],y=this._C=[h[2]<<16|h[2]>>>16,h[0]&4294901760|h[1]&65535,h[3]<<16|h[3]>>>16,h[1]&4294901760|h[2]&65535,h[0]<<16|h[0]>>>16,h[2]&4294901760|h[3]&65535,h[1]<<16|h[1]>>>16,h[3]&4294901760|h[0]&65535];this._b=0;for(var f=0;f<4;f++)d.call(this);for(var f=0;f<8;f++)y[f]^=g[f+4&7];if(p){var b=p.words,m=b[0],v=b[1],S=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,C=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,E=S>>>16|C&4294901760,w=C<<16|S&65535;y[0]^=S,y[1]^=E,y[2]^=C,y[3]^=w,y[4]^=S,y[5]^=E,y[6]^=C,y[7]^=w;for(var f=0;f<4;f++)d.call(this)}},_doProcessBlock:function(h,p){var f=this._X;d.call(this),o[0]=f[0]^f[5]>>>16^f[3]<<16,o[1]=f[2]^f[7]>>>16^f[5]<<16,o[2]=f[4]^f[1]>>>16^f[7]<<16,o[3]=f[6]^f[3]>>>16^f[1]<<16;for(var g=0;g<4;g++)o[g]=(o[g]<<8|o[g]>>>24)&16711935|(o[g]<<24|o[g]>>>8)&4278255360,h[p+g]^=o[g]},blockSize:128/32,ivSize:64/32});function d(){for(var h=this._X,p=this._C,f=0;f<8;f++)c[f]=p[f];p[0]=p[0]+1295307597+this._b|0,p[1]=p[1]+3545052371+(p[0]>>>0<c[0]>>>0?1:0)|0,p[2]=p[2]+886263092+(p[1]>>>0<c[1]>>>0?1:0)|0,p[3]=p[3]+1295307597+(p[2]>>>0<c[2]>>>0?1:0)|0,p[4]=p[4]+3545052371+(p[3]>>>0<c[3]>>>0?1:0)|0,p[5]=p[5]+886263092+(p[4]>>>0<c[4]>>>0?1:0)|0,p[6]=p[6]+1295307597+(p[5]>>>0<c[5]>>>0?1:0)|0,p[7]=p[7]+3545052371+(p[6]>>>0<c[6]>>>0?1:0)|0,this._b=p[7]>>>0<c[7]>>>0?1:0;for(var f=0;f<8;f++){var g=h[f]+p[f],y=g&65535,b=g>>>16,m=((y*y>>>17)+y*b>>>15)+b*b,v=((g&4294901760)*g|0)+((g&65535)*g|0);u[f]=m^v}h[0]=u[0]+(u[7]<<16|u[7]>>>16)+(u[6]<<16|u[6]>>>16)|0,h[1]=u[1]+(u[0]<<8|u[0]>>>24)+u[7]|0,h[2]=u[2]+(u[1]<<16|u[1]>>>16)+(u[0]<<16|u[0]>>>16)|0,h[3]=u[3]+(u[2]<<8|u[2]>>>24)+u[1]|0,h[4]=u[4]+(u[3]<<16|u[3]>>>16)+(u[2]<<16|u[2]>>>16)|0,h[5]=u[5]+(u[4]<<8|u[4]>>>24)+u[3]|0,h[6]=u[6]+(u[5]<<16|u[5]>>>16)+(u[4]<<16|u[4]>>>16)|0,h[7]=u[7]+(u[6]<<8|u[6]>>>24)+u[5]|0}n.Rabbit=s._createHelper(l)}(),r.Rabbit})}(Jc)),Jc.exports}var eu={exports:{}},Ch;function D1(){return Ch||(Ch=1,function(e,t){(function(r,n,a){e.exports=n(it(),os(),cs(),Aa(),ar())})(Ye,function(r){return function(){var n=r,a=n.lib,s=a.StreamCipher,i=n.algo,o=[],c=[],u=[],l=i.RabbitLegacy=s.extend({_doReset:function(){var h=this._key.words,p=this.cfg.iv,f=this._X=[h[0],h[3]<<16|h[2]>>>16,h[1],h[0]<<16|h[3]>>>16,h[2],h[1]<<16|h[0]>>>16,h[3],h[2]<<16|h[1]>>>16],g=this._C=[h[2]<<16|h[2]>>>16,h[0]&4294901760|h[1]&65535,h[3]<<16|h[3]>>>16,h[1]&4294901760|h[2]&65535,h[0]<<16|h[0]>>>16,h[2]&4294901760|h[3]&65535,h[1]<<16|h[1]>>>16,h[3]&4294901760|h[0]&65535];this._b=0;for(var y=0;y<4;y++)d.call(this);for(var y=0;y<8;y++)g[y]^=f[y+4&7];if(p){var b=p.words,m=b[0],v=b[1],S=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,C=(v<<8|v>>>24)&16711935|(v<<24|v>>>8)&4278255360,E=S>>>16|C&4294901760,w=C<<16|S&65535;g[0]^=S,g[1]^=E,g[2]^=C,g[3]^=w,g[4]^=S,g[5]^=E,g[6]^=C,g[7]^=w;for(var y=0;y<4;y++)d.call(this)}},_doProcessBlock:function(h,p){var f=this._X;d.call(this),o[0]=f[0]^f[5]>>>16^f[3]<<16,o[1]=f[2]^f[7]>>>16^f[5]<<16,o[2]=f[4]^f[1]>>>16^f[7]<<16,o[3]=f[6]^f[3]>>>16^f[1]<<16;for(var g=0;g<4;g++)o[g]=(o[g]<<8|o[g]>>>24)&16711935|(o[g]<<24|o[g]>>>8)&4278255360,h[p+g]^=o[g]},blockSize:128/32,ivSize:64/32});function d(){for(var h=this._X,p=this._C,f=0;f<8;f++)c[f]=p[f];p[0]=p[0]+1295307597+this._b|0,p[1]=p[1]+3545052371+(p[0]>>>0<c[0]>>>0?1:0)|0,p[2]=p[2]+886263092+(p[1]>>>0<c[1]>>>0?1:0)|0,p[3]=p[3]+1295307597+(p[2]>>>0<c[2]>>>0?1:0)|0,p[4]=p[4]+3545052371+(p[3]>>>0<c[3]>>>0?1:0)|0,p[5]=p[5]+886263092+(p[4]>>>0<c[4]>>>0?1:0)|0,p[6]=p[6]+1295307597+(p[5]>>>0<c[5]>>>0?1:0)|0,p[7]=p[7]+3545052371+(p[6]>>>0<c[6]>>>0?1:0)|0,this._b=p[7]>>>0<c[7]>>>0?1:0;for(var f=0;f<8;f++){var g=h[f]+p[f],y=g&65535,b=g>>>16,m=((y*y>>>17)+y*b>>>15)+b*b,v=((g&4294901760)*g|0)+((g&65535)*g|0);u[f]=m^v}h[0]=u[0]+(u[7]<<16|u[7]>>>16)+(u[6]<<16|u[6]>>>16)|0,h[1]=u[1]+(u[0]<<8|u[0]>>>24)+u[7]|0,h[2]=u[2]+(u[1]<<16|u[1]>>>16)+(u[0]<<16|u[0]>>>16)|0,h[3]=u[3]+(u[2]<<8|u[2]>>>24)+u[1]|0,h[4]=u[4]+(u[3]<<16|u[3]>>>16)+(u[2]<<16|u[2]>>>16)|0,h[5]=u[5]+(u[4]<<8|u[4]>>>24)+u[3]|0,h[6]=u[6]+(u[5]<<16|u[5]>>>16)+(u[4]<<16|u[4]>>>16)|0,h[7]=u[7]+(u[6]<<8|u[6]>>>24)+u[5]|0}n.RabbitLegacy=s._createHelper(l)}(),r.RabbitLegacy})}(eu)),eu.exports}(function(e,t){(function(r,n,a){e.exports=n(it(),Do(),c1(),u1(),os(),l1(),cs(),_d(),tg(),d1(),rg(),h1(),p1(),f1(),Dd(),g1(),Aa(),ar(),m1(),y1(),v1(),b1(),C1(),S1(),E1(),x1(),w1(),T1(),$1(),A1(),I1(),P1(),_1(),D1())})(Ye,function(r){return r})})(eg);var R1=eg.exports;const jn=t1(R1);var Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function us(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ng(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}),r}var ag={exports:{}};(function(e,t){(function(){function r(c,u){if(typeof c!==u)throw new TypeError("Expected '"+u+"' but instead found '"+typeof c+"'")}function n(c){var u,l;return!!(c&&typeof c=="object"&&(u=Object.getOwnPropertyNames(c).sort(),l=u.length,l===1&&(u[0]==="get"&&typeof c.get=="function"||u[0]==="set"&&typeof c.set=="function")||l===2&&u[0]==="get"&&typeof c.get=="function"&&u[1]==="set"&&typeof c.set=="function"))}function a(c,u,l){var d={},h,p,f,g=l||u,y=l&&u;for(l=g&&typeof g=="object"?g:{},u=y&&typeof y=="object"?y:{},p=Object.getOwnPropertyNames(l),f=p.length,h=0;h<f;h++)n(l[p[h]])?d[p[h]]={configurable:!!u.configurable,enumerable:!!u.enumerable,get:l[p[h]].get,set:l[p[h]].set}:d[p[h]]={configurable:!!u.configurable,enumerable:!!u.enumerable,writable:!!u.writable,value:l[p[h]]};return Object.defineProperties(c,d),c}var s={defineProperties:function(c,u){return a(this,c,u),this},getProto:function(){return Object.getPrototypeOf(this)},getSuper:function(){return Object.getPrototypeOf(this.constructor.prototype)}},i={isGeneration:function(c){r(c,"function");var u=this;return u.prototype.isPrototypeOf(c.prototype)},isCreation:function(c){var u=this;return c instanceof u},generate:function(c){r(c,"function");var u=this;return a(c,{configurable:!1,enumerable:!1,writable:!1},{prototype:Object.create(u.prototype)}),a(c,{configurable:!1,enumerable:!1,writable:!1},i),a(c.prototype,{configurable:!1,enumerable:!1,writable:!1},{constructor:c,generator:c}),c},definePrototype:function(c,u){return a(this.prototype,c,u),this}};function o(){}a(o,{configurable:!1,enumerable:!1,writable:!1},{prototype:o.prototype}),a(o.prototype,{configurable:!1,enumerable:!1,writable:!1},s),a(o,{configurable:!1,enumerable:!1,writable:!1},i),a(o,{configurable:!1,enumerable:!1,writable:!1},{isGenerator:function(c){return this.isGeneration(c)},toGenerator:function(c,u){return console.warn("Generator.toGenerator is depreciated please use Generator.generateFrom"),this.generateFrom(c,u)},generateFrom:function(c,u){return r(c,"function"),r(u,"function"),a(u,{configurable:!1,enumerable:!1,writable:!1},{prototype:Object.create(c.prototype)}),a(u,{configurable:!1,enumerable:!1,writable:!1},i),a(u.prototype,{configurable:!1,enumerable:!1,writable:!1},{constructor:u,generator:u}),a(u.prototype,{configurable:!1,enumerable:!1,writable:!1},s),u}}),Object.freeze(o),Object.freeze(o.prototype),e.exports=o})()})(ag);var N1=ag.exports,B1=N1,Rd=B1.generate(function(e,t){var r=this;r.storage=e,t&&(r.hash=t.hash,r.encrypt=t.encrypt,r.decrypt=t.decrypt)});function tu(e){return e}Rd.definePrototype({hash:tu,encrypt:tu,decrypt:tu},{writable:!0});Rd.definePrototype({getItem:function(e){var t=this;e=t.hash(e);var r=t.storage.getItem(e);return typeof r!="string"?r:(r=t.decrypt(r),JSON.parse(r))},setItem:function(e,t){var r=this;return e=r.hash(e),t=JSON.stringify(t),t=r.encrypt(t),r.storage.setItem(e,t)},removeItem:function(e){var t=this;return e=t.hash(e),t.storage.removeItem(e)},clear:function(){var e=this;return e.storage.clear()},key:function(e){var t=this;return t.storage.key(e)},length:{get:function(){var e=this;return e.storage.length}}});var k1=Rd;const sg=us(k1);var O1={exports:{}};function U1(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Sh={exports:{}};const L1={},M1=Object.freeze(Object.defineProperty({__proto__:null,default:L1},Symbol.toStringTag,{value:"Module"})),Ro=ng(M1);var Eh;function ig(){return Eh||(Eh=1,function(e,t){(function(r,n){e.exports=n()})(Cn,function(){var r=r||function(n,a){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof Cn<"u"&&Cn.crypto&&(s=Cn.crypto),!s&&typeof U1=="function")try{s=Ro}catch{}var i=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function m(){}return function(v){var S;return m.prototype=v,S=new m,m.prototype=null,S}}(),c={},u=c.lib={},l=u.Base=function(){return{extend:function(m){var v=o(this);return m&&v.mixIn(m),(!v.hasOwnProperty("init")||this.init===v.init)&&(v.init=function(){v.$super.init.apply(this,arguments)}),v.init.prototype=v,v.$super=this,v},create:function(){var m=this.extend();return m.init.apply(m,arguments),m},init:function(){},mixIn:function(m){for(var v in m)m.hasOwnProperty(v)&&(this[v]=m[v]);m.hasOwnProperty("toString")&&(this.toString=m.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),d=u.WordArray=l.extend({init:function(m,v){m=this.words=m||[],v!=a?this.sigBytes=v:this.sigBytes=m.length*4},toString:function(m){return(m||p).stringify(this)},concat:function(m){var v=this.words,S=m.words,C=this.sigBytes,E=m.sigBytes;if(this.clamp(),C%4)for(var w=0;w<E;w++){var _=S[w>>>2]>>>24-w%4*8&255;v[C+w>>>2]|=_<<24-(C+w)%4*8}else for(var P=0;P<E;P+=4)v[C+P>>>2]=S[P>>>2];return this.sigBytes+=E,this},clamp:function(){var m=this.words,v=this.sigBytes;m[v>>>2]&=4294967295<<32-v%4*8,m.length=n.ceil(v/4)},clone:function(){var m=l.clone.call(this);return m.words=this.words.slice(0),m},random:function(m){for(var v=[],S=0;S<m;S+=4)v.push(i());return new d.init(v,m)}}),h=c.enc={},p=h.Hex={stringify:function(m){for(var v=m.words,S=m.sigBytes,C=[],E=0;E<S;E++){var w=v[E>>>2]>>>24-E%4*8&255;C.push((w>>>4).toString(16)),C.push((w&15).toString(16))}return C.join("")},parse:function(m){for(var v=m.length,S=[],C=0;C<v;C+=2)S[C>>>3]|=parseInt(m.substr(C,2),16)<<24-C%8*4;return new d.init(S,v/2)}},f=h.Latin1={stringify:function(m){for(var v=m.words,S=m.sigBytes,C=[],E=0;E<S;E++){var w=v[E>>>2]>>>24-E%4*8&255;C.push(String.fromCharCode(w))}return C.join("")},parse:function(m){for(var v=m.length,S=[],C=0;C<v;C++)S[C>>>2]|=(m.charCodeAt(C)&255)<<24-C%4*8;return new d.init(S,v)}},g=h.Utf8={stringify:function(m){try{return decodeURIComponent(escape(f.stringify(m)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(m){return f.parse(unescape(encodeURIComponent(m)))}},y=u.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new d.init,this._nDataBytes=0},_append:function(m){typeof m=="string"&&(m=g.parse(m)),this._data.concat(m),this._nDataBytes+=m.sigBytes},_process:function(m){var v,S=this._data,C=S.words,E=S.sigBytes,w=this.blockSize,_=w*4,P=E/_;m?P=n.ceil(P):P=n.max((P|0)-this._minBufferSize,0);var x=P*w,R=n.min(x*4,E);if(x){for(var B=0;B<x;B+=w)this._doProcessBlock(C,B);v=C.splice(0,x),S.sigBytes-=R}return new d.init(v,R)},clone:function(){var m=l.clone.call(this);return m._data=this._data.clone(),m},_minBufferSize:0});u.Hasher=y.extend({cfg:l.extend(),init:function(m){this.cfg=this.cfg.extend(m),this.reset()},reset:function(){y.reset.call(this),this._doReset()},update:function(m){return this._append(m),this._process(),this},finalize:function(m){m&&this._append(m);var v=this._doFinalize();return v},blockSize:16,_createHelper:function(m){return function(v,S){return new m.init(S).finalize(v)}},_createHmacHelper:function(m){return function(v,S){return new b.HMAC.init(m,S).finalize(v)}}});var b=c.algo={};return c}(Math);return r})}(Sh)),Sh.exports}var xh={exports:{}},wh;function j1(){return wh||(wh=1,function(e,t){(function(r,n){e.exports=n(ig())})(Cn,function(r){return function(n){var a=r,s=a.lib,i=s.Base,o=s.WordArray,c=a.x64={};c.Word=i.extend({init:function(u,l){this.high=u,this.low=l}}),c.WordArray=i.extend({init:function(u,l){u=this.words=u||[],l!=n?this.sigBytes=l:this.sigBytes=u.length*8},toX32:function(){for(var u=this.words,l=u.length,d=[],h=0;h<l;h++){var p=u[h];d.push(p.high),d.push(p.low)}return o.create(d,this.sigBytes)},clone:function(){for(var u=i.clone.call(this),l=u.words=this.words.slice(0),d=l.length,h=0;h<d;h++)l[h]=l[h].clone();return u}})}(),r})}(xh)),xh.exports}(function(e,t){(function(r,n,a){e.exports=n(ig(),j1())})(Cn,function(r){return function(){var n=r,a=n.lib,s=a.Hasher,i=n.x64,o=i.Word,c=i.WordArray,u=n.algo;function l(){return o.create.apply(o,arguments)}var d=[l(1116352408,3609767458),l(1899447441,602891725),l(3049323471,3964484399),l(3921009573,2173295548),l(961987163,4081628472),l(1508970993,3053834265),l(2453635748,2937671579),l(2870763221,3664609560),l(3624381080,2734883394),l(310598401,1164996542),l(607225278,1323610764),l(1426881987,3590304994),l(1925078388,4068182383),l(2162078206,991336113),l(2614888103,633803317),l(3248222580,3479774868),l(3835390401,2666613458),l(4022224774,944711139),l(264347078,2341262773),l(604807628,2007800933),l(770255983,1495990901),l(1249150122,1856431235),l(1555081692,3175218132),l(1996064986,2198950837),l(2554220882,3999719339),l(2821834349,766784016),l(2952996808,2566594879),l(3210313671,3203337956),l(3336571891,1034457026),l(3584528711,2466948901),l(113926993,3758326383),l(338241895,168717936),l(666307205,1188179964),l(773529912,1546045734),l(1294757372,1522805485),l(1396182291,2643833823),l(1695183700,2343527390),l(1986661051,1014477480),l(2177026350,1206759142),l(2456956037,344077627),l(2730485921,1290863460),l(2820302411,3158454273),l(3259730800,3505952657),l(3345764771,106217008),l(3516065817,3606008344),l(3600352804,1432725776),l(4094571909,1467031594),l(275423344,851169720),l(430227734,3100823752),l(506948616,1363258195),l(659060556,3750685593),l(883997877,3785050280),l(958139571,3318307427),l(1322822218,3812723403),l(1537002063,2003034995),l(1747873779,3602036899),l(1955562222,1575990012),l(2024104815,1125592928),l(2227730452,2716904306),l(2361852424,442776044),l(2428436474,593698344),l(2756734187,3733110249),l(3204031479,2999351573),l(3329325298,3815920427),l(3391569614,3928383900),l(3515267271,566280711),l(3940187606,3454069534),l(4118630271,4000239992),l(116418474,1914138554),l(174292421,2731055270),l(289380356,3203993006),l(460393269,320620315),l(685471733,587496836),l(852142971,1086792851),l(1017036298,365543100),l(1126000580,2618297676),l(1288033470,3409855158),l(1501505948,4234509866),l(1607167915,987167468),l(1816402316,1246189591)],h=[];(function(){for(var f=0;f<80;f++)h[f]=l()})();var p=u.SHA512=s.extend({_doReset:function(){this._hash=new c.init([new o.init(1779033703,4089235720),new o.init(3144134277,2227873595),new o.init(1013904242,4271175723),new o.init(2773480762,1595750129),new o.init(1359893119,2917565137),new o.init(2600822924,725511199),new o.init(528734635,4215389547),new o.init(1541459225,327033209)])},_doProcessBlock:function(f,g){for(var y=this._hash.words,b=y[0],m=y[1],v=y[2],S=y[3],C=y[4],E=y[5],w=y[6],_=y[7],P=b.high,x=b.low,R=m.high,B=m.low,K=v.high,re=v.low,ee=S.high,ie=S.low,se=C.high,Ce=C.low,Ie=E.high,ye=E.low,L=w.high,X=w.low,ne=_.high,U=_.low,be=P,xe=x,Ne=R,he=B,_e=K,I=re,D=ee,N=ie,q=se,k=Ce,V=Ie,W=ye,j=L,z=X,Z=ne,M=U,te=0;te<80;te++){var ge,G,Ge=h[te];if(te<16)G=Ge.high=f[g+te*2]|0,ge=Ge.low=f[g+te*2+1]|0;else{var gt=h[te-15],ot=gt.high,Ke=gt.low,ht=(ot>>>1|Ke<<31)^(ot>>>8|Ke<<24)^ot>>>7,Ut=(Ke>>>1|ot<<31)^(Ke>>>8|ot<<24)^(Ke>>>7|ot<<25),Qr=h[te-2],Xt=Qr.high,pr=Qr.low,xr=(Xt>>>19|pr<<13)^(Xt<<3|pr>>>29)^Xt>>>6,qr=(pr>>>19|Xt<<13)^(pr<<3|Xt>>>29)^(pr>>>6|Xt<<26),zt=h[te-7],qt=zt.high,xt=zt.low,As=h[te-16],hc=As.high,Is=As.low;ge=Ut+xt,G=ht+qt+(ge>>>0<Ut>>>0?1:0),ge=ge+qr,G=G+xr+(ge>>>0<qr>>>0?1:0),ge=ge+Is,G=G+hc+(ge>>>0<Is>>>0?1:0),Ge.high=G,Ge.low=ge}var pc=q&V^~q&j,Ps=k&W^~k&z,fc=be&Ne^be&_e^Ne&_e,gc=xe&he^xe&I^he&I,mc=(be>>>28|xe<<4)^(be<<30|xe>>>2)^(be<<25|xe>>>7),_s=(xe>>>28|be<<4)^(xe<<30|be>>>2)^(xe<<25|be>>>7),yc=(q>>>14|k<<18)^(q>>>18|k<<14)^(q<<23|k>>>9),vc=(k>>>14|q<<18)^(k>>>18|q<<14)^(k<<23|q>>>9),Ds=d[te],bc=Ds.high,Rs=Ds.low,vt=M+vc,Jt=Z+yc+(vt>>>0<M>>>0?1:0),vt=vt+Ps,Jt=Jt+pc+(vt>>>0<Ps>>>0?1:0),vt=vt+Rs,Jt=Jt+bc+(vt>>>0<Rs>>>0?1:0),vt=vt+ge,Jt=Jt+G+(vt>>>0<ge>>>0?1:0),Ns=_s+gc,Cc=mc+fc+(Ns>>>0<_s>>>0?1:0);Z=j,M=z,j=V,z=W,V=q,W=k,k=N+vt|0,q=D+Jt+(k>>>0<N>>>0?1:0)|0,D=_e,N=I,_e=Ne,I=he,Ne=be,he=xe,xe=vt+Ns|0,be=Jt+Cc+(xe>>>0<vt>>>0?1:0)|0}x=b.low=x+xe,b.high=P+be+(x>>>0<xe>>>0?1:0),B=m.low=B+he,m.high=R+Ne+(B>>>0<he>>>0?1:0),re=v.low=re+I,v.high=K+_e+(re>>>0<I>>>0?1:0),ie=S.low=ie+N,S.high=ee+D+(ie>>>0<N>>>0?1:0),Ce=C.low=Ce+k,C.high=se+q+(Ce>>>0<k>>>0?1:0),ye=E.low=ye+W,E.high=Ie+V+(ye>>>0<W>>>0?1:0),X=w.low=X+z,w.high=L+j+(X>>>0<z>>>0?1:0),U=_.low=U+M,_.high=ne+Z+(U>>>0<M>>>0?1:0)},_doFinalize:function(){var f=this._data,g=f.words,y=this._nDataBytes*8,b=f.sigBytes*8;g[b>>>5]|=128<<24-b%32,g[(b+128>>>10<<5)+30]=Math.floor(y/4294967296),g[(b+128>>>10<<5)+31]=y,f.sigBytes=g.length*4,this._process();var m=this._hash.toX32();return m},clone:function(){var f=s.clone.call(this);return f._hash=this._hash.clone(),f},blockSize:1024/32});n.SHA512=s._createHelper(p),n.HmacSHA512=s._createHmacHelper(p)}(),r.SHA512})})(O1);var Ze={options:{usePureJavaScript:!1}},Nd={},F1=Nd,Th={};Nd.encode=function(e,t,r){if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');if(r!==void 0&&typeof r!="number")throw new TypeError('"maxline" must be a number.');var n="";if(!(e instanceof Uint8Array))n=q1(e,t);else{var a=0,s=t.length,i=t.charAt(0),o=[0];for(a=0;a<e.length;++a){for(var c=0,u=e[a];c<o.length;++c)u+=o[c]<<8,o[c]=u%s,u=u/s|0;for(;u>0;)o.push(u%s),u=u/s|0}for(a=0;e[a]===0&&a<e.length-1;++a)n+=i;for(a=o.length-1;a>=0;--a)n+=t[o[a]]}if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join(`\r
`)}return n};Nd.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var r=Th[t];if(!r){r=Th[t]=[];for(var n=0;n<t.length;++n)r[t.charCodeAt(n)]=n}e=e.replace(/\s/g,"");for(var a=t.length,s=t.charAt(0),i=[0],n=0;n<e.length;n++){var o=r[e.charCodeAt(n)];if(o===void 0)return;for(var c=0,u=o;c<i.length;++c)u+=i[c]*a,i[c]=u&255,u>>=8;for(;u>0;)i.push(u&255),u>>=8}for(var l=0;e[l]===s&&l<e.length-1;++l)i.push(0);return typeof Buffer<"u"?Buffer.from(i.reverse()):new Uint8Array(i.reverse())};function q1(e,t){var r=0,n=t.length,a=t.charAt(0),s=[0];for(r=0;r<e.length();++r){for(var i=0,o=e.at(r);i<s.length;++i)o+=s[i]<<8,s[i]=o%n,o=o/n|0;for(;o>0;)s.push(o%n),o=o/n|0}var c="";for(r=0;e.at(r)===0&&r<e.length()-1;++r)c+=a;for(r=s.length-1;r>=0;--r)c+=t[s[r]];return c}var $h=Ze,Ah=F1,H=$h.util=$h.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){H.nextTick=process.nextTick,typeof setImmediate=="function"?H.setImmediate=setImmediate:H.setImmediate=H.nextTick;return}if(typeof setImmediate=="function"){H.setImmediate=function(){return setImmediate.apply(void 0,arguments)},H.nextTick=function(i){return setImmediate(i)};return}if(H.setImmediate=function(i){setTimeout(i,0)},typeof window<"u"&&typeof window.postMessage=="function"){let i=function(o){if(o.source===window&&o.data===e){o.stopPropagation();var c=t.slice();t.length=0,c.forEach(function(u){u()})}};var e="forge.setImmediate",t=[];H.setImmediate=function(o){t.push(o),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",i,!0)}if(typeof MutationObserver<"u"){var r=Date.now(),n=!0,a=document.createElement("div"),t=[];new MutationObserver(function(){var o=t.slice();t.length=0,o.forEach(function(c){c()})}).observe(a,{attributes:!0});var s=H.setImmediate;H.setImmediate=function(o){Date.now()-r>15?(r=Date.now(),s(o)):(t.push(o),t.length===1&&a.setAttribute("a",n=!n))}}H.nextTick=H.setImmediate})();H.isNodejs=typeof process<"u"&&process.versions&&process.versions.node;H.globalScope=function(){return H.isNodejs?Cn:typeof self>"u"?window:self}();H.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};H.isArrayBuffer=function(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer};H.isArrayBufferView=function(e){return e&&H.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function ui(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}H.ByteBuffer=Bd;function Bd(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(H.isArrayBuffer(e)||H.isArrayBufferView(e))if(typeof Buffer<"u"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var r=0;r<t.length;++r)this.putByte(t[r])}}else(e instanceof Bd||typeof e=="object"&&typeof e.data=="string"&&typeof e.read=="number")&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}H.ByteStringBuffer=Bd;var H1=4096;H.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>H1&&(this.data.substr(0,1),this._constructedStringLength=0)};H.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};H.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};H.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))};H.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)t&1&&(r+=e),t>>>=1,t>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this};H.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this};H.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(H.encodeUtf8(e))};H.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};H.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};H.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))};H.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))};H.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))};H.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))};H.ByteStringBuffer.prototype.putInt=function(e,t){ui(t);var r="";do t-=8,r+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(r)};H.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)};H.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())};H.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};H.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e};H.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e};H.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e};H.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e};H.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e};H.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e};H.ByteStringBuffer.prototype.getInt=function(e){ui(e);var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t};H.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t};H.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};H.ByteStringBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};H.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)};H.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this};H.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};H.ByteStringBuffer.prototype.copy=function(){var e=H.createBuffer(this.data);return e.read=this.read,e};H.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};H.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};H.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this};H.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e};H.ByteStringBuffer.prototype.toString=function(){return H.decodeUtf8(this.bytes())};function K1(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var r=H.isArrayBuffer(e),n=H.isArrayBufferView(e);if(r||n){r?this.data=new DataView(e):this.data=new DataView(e.buffer,e.byteOffset,e.byteLength),this.write="writeOffset"in t?t.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,e!=null&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)}H.DataBuffer=K1;H.DataBuffer.prototype.length=function(){return this.write-this.read};H.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};H.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this};H.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this};H.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this};H.DataBuffer.prototype.putBytes=function(e,t){if(H.isArrayBufferView(e)){var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=r.byteLength-r.byteOffset;this.accommodate(n);var a=new Uint8Array(this.data.buffer,this.write);return a.set(r),this.write+=n,this}if(H.isArrayBuffer(e)){var r=new Uint8Array(e);this.accommodate(r.byteLength);var a=new Uint8Array(this.data.buffer);return a.set(r,this.write),this.write+=r.byteLength,this}if(e instanceof H.DataBuffer||typeof e=="object"&&typeof e.read=="number"&&typeof e.write=="number"&&H.isArrayBufferView(e.data)){var r=new Uint8Array(e.data.byteLength,e.read,e.length());this.accommodate(r.byteLength);var a=new Uint8Array(e.data.byteLength,this.write);return a.set(r),this.write+=r.byteLength,this}if(e instanceof H.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary",typeof e=="string"){var s;if(t==="hex")return this.accommodate(Math.ceil(e.length/2)),s=new Uint8Array(this.data.buffer,this.write),this.write+=H.binary.hex.decode(e,s,this.write),this;if(t==="base64")return this.accommodate(Math.ceil(e.length/4)*3),s=new Uint8Array(this.data.buffer,this.write),this.write+=H.binary.base64.decode(e,s,this.write),this;if(t==="utf8"&&(e=H.encodeUtf8(e),t="binary"),t==="binary"||t==="raw")return this.accommodate(e.length),s=new Uint8Array(this.data.buffer,this.write),this.write+=H.binary.raw.decode(s),this;if(t==="utf16")return this.accommodate(e.length*2),s=new Uint16Array(this.data.buffer,this.write),this.write+=H.text.utf16.encode(s),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)};H.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this};H.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")};H.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this};H.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this};H.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this};H.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this};H.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this};H.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this};H.DataBuffer.prototype.putInt=function(e,t){ui(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this};H.DataBuffer.prototype.putSignedInt=function(e,t){return ui(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)};H.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};H.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e};H.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e};H.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e};H.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e};H.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e};H.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e};H.DataBuffer.prototype.getInt=function(e){ui(e);var t=0;do t=(t<<8)+this.data.getInt8(this.read++),e-=8;while(e>0);return t};H.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t};H.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t};H.DataBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)};H.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)};H.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this};H.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};H.DataBuffer.prototype.copy=function(){return new H.DataBuffer(this)};H.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this};H.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};H.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this};H.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e};H.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if(e=e||"utf8",e==="binary"||e==="raw")return H.binary.raw.encode(t);if(e==="hex")return H.binary.hex.encode(t);if(e==="base64")return H.binary.base64.encode(t);if(e==="utf8")return H.text.utf8.decode(t);if(e==="utf16")return H.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)};H.createBuffer=function(e,t){return t=t||"raw",e!==void 0&&t==="utf8"&&(e=H.encodeUtf8(e)),new H.ByteBuffer(e)};H.fillString=function(e,t){for(var r="";t>0;)t&1&&(r+=e),t>>>=1,t>0&&(e+=e);return r};H.xorBytes=function(e,t,r){for(var n="",a="",s="",i=0,o=0;r>0;--r,++i)a=e.charCodeAt(i)^t.charCodeAt(i),o>=10&&(n+=s,s="",o=0),s+=String.fromCharCode(a),++o;return n+=s,n};H.hexToBytes=function(e){var t="",r=0;for(e.length&!0&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t};H.bytesToHex=function(e){return H.createBuffer(e).toHex()};H.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var Fn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",qn=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],og="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";H.encode64=function(e,t){for(var r="",n="",a,s,i,o=0;o<e.length;)a=e.charCodeAt(o++),s=e.charCodeAt(o++),i=e.charCodeAt(o++),r+=Fn.charAt(a>>2),r+=Fn.charAt((a&3)<<4|s>>4),isNaN(s)?r+="==":(r+=Fn.charAt((s&15)<<2|i>>6),r+=isNaN(i)?"=":Fn.charAt(i&63)),t&&r.length>t&&(n+=r.substr(0,t)+`\r
`,r=r.substr(t));return n+=r,n};H.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t="",r,n,a,s,i=0;i<e.length;)r=qn[e.charCodeAt(i++)-43],n=qn[e.charCodeAt(i++)-43],a=qn[e.charCodeAt(i++)-43],s=qn[e.charCodeAt(i++)-43],t+=String.fromCharCode(r<<2|n>>4),a!==64&&(t+=String.fromCharCode((n&15)<<4|a>>2),s!==64&&(t+=String.fromCharCode((a&3)<<6|s)));return t};H.encodeUtf8=function(e){return unescape(encodeURIComponent(e))};H.decodeUtf8=function(e){return decodeURIComponent(escape(e))};H.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:Ah.encode,decode:Ah.decode}};H.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)};H.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length)),r=r||0;for(var a=r,s=0;s<e.length;++s)n[a++]=e.charCodeAt(s);return t?a-r:n};H.binary.hex.encode=H.bytesToHex;H.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2))),r=r||0;var a=0,s=r;for(e.length&1&&(a=1,n[s++]=parseInt(e[0],16));a<e.length;a+=2)n[s++]=parseInt(e.substr(a,2),16);return t?s-r:n};H.binary.base64.encode=function(e,t){for(var r="",n="",a,s,i,o=0;o<e.byteLength;)a=e[o++],s=e[o++],i=e[o++],r+=Fn.charAt(a>>2),r+=Fn.charAt((a&3)<<4|s>>4),isNaN(s)?r+="==":(r+=Fn.charAt((s&15)<<2|i>>6),r+=isNaN(i)?"=":Fn.charAt(i&63)),t&&r.length>t&&(n+=r.substr(0,t)+`\r
`,r=r.substr(t));return n+=r,n};H.binary.base64.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/4)*3)),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),r=r||0;for(var a,s,i,o,c=0,u=r;c<e.length;)a=qn[e.charCodeAt(c++)-43],s=qn[e.charCodeAt(c++)-43],i=qn[e.charCodeAt(c++)-43],o=qn[e.charCodeAt(c++)-43],n[u++]=a<<2|s>>4,i!==64&&(n[u++]=(s&15)<<4|i>>2,o!==64&&(n[u++]=(i&3)<<6|o));return t?u-r:n.subarray(0,u)};H.binary.base58.encode=function(e,t){return H.binary.baseN.encode(e,og,t)};H.binary.base58.decode=function(e,t){return H.binary.baseN.decode(e,og,t)};H.text={utf8:{},utf16:{}};H.text.utf8.encode=function(e,t,r){e=H.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length)),r=r||0;for(var a=r,s=0;s<e.length;++s)n[a++]=e.charCodeAt(s);return t?a-r:n};H.text.utf8.decode=function(e){return H.decodeUtf8(String.fromCharCode.apply(null,e))};H.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length*2));var a=new Uint16Array(n.buffer);r=r||0;for(var s=r,i=r,o=0;o<e.length;++o)a[i++]=e.charCodeAt(o),s+=2;return t?s-r:n};H.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))};H.deflate=function(e,t,r){if(t=H.decode64(e.deflate(H.encode64(t)).rval),r){var n=2,a=t.charCodeAt(1);a&32&&(n=6),t=t.substring(n,t.length-4)}return t};H.inflate=function(e,t,r){var n=e.inflate(H.encode64(t)).rval;return n===null?null:H.decode64(n)};var kd=function(e,t,r){if(!e)throw new Error("WebStorage not available.");var n;if(r===null?n=e.removeItem(t):(r=H.encode64(JSON.stringify(r)),n=e.setItem(t,r)),typeof n<"u"&&n.rval!==!0){var a=new Error(n.error.message);throw a.id=n.error.id,a.name=n.error.name,a}},Od=function(e,t){if(!e)throw new Error("WebStorage not available.");var r=e.getItem(t);if(e.init)if(r.rval===null){if(r.error){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}r=null}else r=r.rval;return r!==null&&(r=JSON.parse(H.decode64(r))),r},V1=function(e,t,r,n){var a=Od(e,t);a===null&&(a={}),a[r]=n,kd(e,t,a)},z1=function(e,t,r){var n=Od(e,t);return n!==null&&(n=r in n?n[r]:null),n},G1=function(e,t,r){var n=Od(e,t);if(n!==null&&r in n){delete n[r];var a=!0;for(var s in n){a=!1;break}a&&(n=null),kd(e,t,n)}},Q1=function(e,t){kd(e,t,null)},No=function(e,t,r){var n=null;typeof r>"u"&&(r=["web","flash"]);var a,s=!1,i=null;for(var o in r){a=r[o];try{if(a==="flash"||a==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");n=e.apply(this,t),s=a==="flash"}(a==="web"||a==="both")&&(t[0]=localStorage,n=e.apply(this,t),s=!0)}catch(c){i=c}if(s)break}if(!s)throw i;return n};H.setItem=function(e,t,r,n,a){No(V1,arguments,a)};H.getItem=function(e,t,r,n){return No(z1,arguments,n)};H.removeItem=function(e,t,r,n){No(G1,arguments,n)};H.clearItems=function(e,t,r){No(Q1,arguments,r)};H.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0};H.format=function(e){for(var t=/%./g,r,n,a=0,s=[],i=0;r=t.exec(e);){n=e.substring(i,t.lastIndex-2),n.length>0&&s.push(n),i=t.lastIndex;var o=r[0][1];switch(o){case"s":case"o":a<arguments.length?s.push(arguments[a+++1]):s.push("<?>");break;case"%":s.push("%");break;default:s.push("<%"+o+"?>")}}return s.push(e.substring(i)),s.join("")};H.formatNumber=function(e,t,r,n){var a=e,s=isNaN(t=Math.abs(t))?2:t,i=r===void 0?",":r,o=n===void 0?".":n,c=a<0?"-":"",u=parseInt(a=Math.abs(+a||0).toFixed(s),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+o:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+o)+(s?i+Math.abs(a-u).toFixed(s).slice(2):"")};H.formatSize=function(e){return e>=1073741824?e=H.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?e=H.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?e=H.formatNumber(e/1024,0)+" KiB":e=H.formatNumber(e,0)+" bytes",e};H.bytesFromIP=function(e){return e.indexOf(".")!==-1?H.bytesFromIPv4(e):e.indexOf(":")!==-1?H.bytesFromIPv6(e):null};H.bytesFromIPv4=function(e){if(e=e.split("."),e.length!==4)return null;for(var t=H.createBuffer(),r=0;r<e.length;++r){var n=parseInt(e[r],10);if(isNaN(n))return null;t.putByte(n)}return t.getBytes()};H.bytesFromIPv6=function(e){var t=0;e=e.split(":").filter(function(i){return i.length===0&&++t,!0});for(var r=(8-e.length+t)*2,n=H.createBuffer(),a=0;a<8;++a){if(!e[a]||e[a].length===0){n.fillWithByte(0,r),r=0;continue}var s=H.hexToBytes(e[a]);s.length<2&&n.putByte(0),n.putBytes(s)}return n.getBytes()};H.bytesToIP=function(e){return e.length===4?H.bytesToIPv4(e):e.length===16?H.bytesToIPv6(e):null};H.bytesToIPv4=function(e){if(e.length!==4)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")};H.bytesToIPv6=function(e){if(e.length!==16)return null;for(var t=[],r=[],n=0,a=0;a<e.length;a+=2){for(var s=H.bytesToHex(e[a]+e[a+1]);s[0]==="0"&&s!=="0";)s=s.substr(1);if(s==="0"){var i=r[r.length-1],o=t.length;!i||o!==i.end+1?r.push({start:o,end:o}):(i.end=o,i.end-i.start>r[n].end-r[n].start&&(n=r.length-1))}t.push(s)}if(r.length>0){var c=r[n];c.end-c.start>0&&(t.splice(c.start,c.end-c.start+1,""),c.start===0&&t.unshift(""),c.end===7&&t.push(""))}return t.join(":")};H.estimateCores=function(e,t){if(typeof e=="function"&&(t=e,e={}),e=e||{},"cores"in H&&!e.update)return t(null,H.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return H.cores=navigator.hardwareConcurrency,t(null,H.cores);if(typeof Worker>"u")return H.cores=1,t(null,H.cores);if(typeof Blob>"u")return H.cores=2,t(null,H.cores);var r=URL.createObjectURL(new Blob(["(",(function(){self.addEventListener("message",function(i){var o=Date.now(),c=o+4;self.postMessage({st:o,et:c})})}).toString(),")()"],{type:"application/javascript"}));n([],5,16);function n(i,o,c){if(o===0){var u=Math.floor(i.reduce(function(l,d){return l+d},0)/i.length);return H.cores=Math.max(1,u),URL.revokeObjectURL(r),t(null,H.cores)}a(c,function(l,d){i.push(s(c,d)),n(i,o-1,c)})}function a(i,o){for(var c=[],u=[],l=0;l<i;++l){var d=new Worker(r);d.addEventListener("message",function(h){if(u.push(h.data),u.length===i){for(var p=0;p<i;++p)c[p].terminate();o(null,u)}}),c.push(d)}for(var l=0;l<i;++l)c[l].postMessage(l)}function s(i,o){for(var c=[],u=0;u<i;++u)for(var l=o[u],d=c[u]=[],h=0;h<i;++h)if(u!==h){var p=o[h];(l.st>p.st&&l.st<p.et||p.st>l.st&&p.st<l.et)&&d.push(h)}return c.reduce(function(f,g){return Math.max(f,g.length)},0)}};var Zt=Ze;Zt.cipher=Zt.cipher||{};Zt.cipher.algorithms=Zt.cipher.algorithms||{};Zt.cipher.createCipher=function(e,t){var r=e;if(typeof r=="string"&&(r=Zt.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+e);return new Zt.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})};Zt.cipher.createDecipher=function(e,t){var r=e;if(typeof r=="string"&&(r=Zt.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+e);return new Zt.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})};Zt.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),Zt.cipher.algorithms[e]=t};Zt.cipher.getAlgorithm=function(e){return e=e.toUpperCase(),e in Zt.cipher.algorithms?Zt.cipher.algorithms[e]:null};var Ud=Zt.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};Ud.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=Zt.util.createBuffer(),this.output=e.output||Zt.util.createBuffer(),this.mode.start(t)};Ud.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};Ud.prototype.finish=function(e){e&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(r){return e(this.blockSize,r,!1)},this.mode.unpad=function(r){return e(this.blockSize,r,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t))};var Wt=Ze;Wt.cipher=Wt.cipher||{};var tt=Wt.cipher.modes=Wt.cipher.modes||{};tt.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};tt.ecb.prototype.start=function(e){};tt.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])};tt.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])};tt.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0};tt.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return n>this.blockSize<<2?!1:(e.truncate(n),!0)};tt.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};tt.cbc.prototype.start=function(e){if(e.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in e)this._iv=Bo(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};tt.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock};tt.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)};tt.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0};tt.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return n>this.blockSize<<2?!1:(e.truncate(n),!0)};tt.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=Wt.util.createBuffer(),this._partialBytes=0};tt.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Bo(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};tt.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var a=0;a<this._ints;++a)this._inBlock[a]=e.getInt32()^this._outBlock[a],t.putInt32(this._inBlock[a]);return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var a=0;a<this._ints;++a)this._partialBlock[a]=e.getInt32()^this._outBlock[a],this._partialOutput.putInt32(this._partialBlock[a]);if(s>0)e.read-=this.blockSize;else for(var a=0;a<this._ints;++a)this._inBlock[a]=this._partialBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};tt.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var a=0;a<this._ints;++a)this._inBlock[a]=e.getInt32(),t.putInt32(this._inBlock[a]^this._outBlock[a]);return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var a=0;a<this._ints;++a)this._partialBlock[a]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[a]^this._outBlock[a]);if(s>0)e.read-=this.blockSize;else for(var a=0;a<this._ints;++a)this._inBlock[a]=this._partialBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};tt.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Wt.util.createBuffer(),this._partialBytes=0};tt.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Bo(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};tt.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(e.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var a=0;a<this._ints;++a)t.putInt32(e.getInt32()^this._outBlock[a]),this._inBlock[a]=this._outBlock[a];return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(s>0)e.read-=this.blockSize;else for(var a=0;a<this._ints;++a)this._inBlock[a]=this._outBlock[a];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};tt.ofb.prototype.decrypt=tt.ofb.prototype.encrypt;tt.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Wt.util.createBuffer(),this._partialBytes=0};tt.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=Bo(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};tt.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize)for(var a=0;a<this._ints;++a)t.putInt32(e.getInt32()^this._outBlock[a]);else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(s>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}ko(this._inBlock)};tt.ctr.prototype.decrypt=tt.ctr.prototype.encrypt;tt.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=Wt.util.createBuffer(),this._partialBytes=0,this._R=3774873600};tt.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=Wt.util.createBuffer(e.iv);this._cipherLength=0;var r;if("additionalData"in e?r=Wt.util.createBuffer(e.additionalData):r=Wt.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=Wt.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var n=t.length();if(n===12)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(_u(n*8)))}this._inBlock=this._j0.slice(0),ko(this._inBlock),this._partialBytes=0,r=Wt.util.createBuffer(r),this._aDataLength=_u(r.length()*8);var a=r.length()%this.blockSize;for(a&&r.fillWithByte(0,this.blockSize-a),this._s=[0,0,0,0];r.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])};tt.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var a=0;a<this._ints;++a)t.putInt32(this._outBlock[a]^=e.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(s<=0||r){if(r){var i=n%this.blockSize;this._cipherLength+=i,this._partialOutput.truncate(this.blockSize-i)}else this._cipherLength+=this.blockSize;for(var a=0;a<this._ints;++a)this._outBlock[a]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),ko(this._inBlock)};tt.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n<this.blockSize&&!(r&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),ko(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var a=0;a<this._ints;++a)t.putInt32(this._outBlock[a]^this._hashBlock[a]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize};tt.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=Wt.util.createBuffer();var n=this._aDataLength.concat(_u(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,n);var a=[];this.cipher.encrypt(this._j0,a);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^a[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r};tt.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),a=0;a<128;++a){var s=e[a/32|0]&1<<31-a%32;s&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r};tt.gcm.prototype.pow=function(e,t){for(var r=e[3]&1,n=3;n>0;--n)t[n]=e[n]>>>1|(e[n-1]&1)<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)};tt.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=r/8|0,a=e[n]>>>(7-r%8)*4&15,s=this._m[r][a];t[0]^=s[0],t[1]^=s[1],t[2]^=s[2],t[3]^=s[3]}return t};tt.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)};tt.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,a=16*r,s=new Array(a),i=0;i<a;++i){var o=[0,0,0,0],c=i/n|0,u=(n-1-i%n)*t;o[c]=1<<t-1<<u,s[i]=this.generateSubHashTable(this.multiply(o,e),t)}return s};tt.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,a=new Array(r);a[n]=e.slice(0);for(var s=n>>>1;s>0;)this.pow(a[2*s],a[s]=[]),s>>=1;for(s=2;s<n;){for(var i=1;i<s;++i){var o=a[s],c=a[i];a[s+i]=[o[0]^c[0],o[1]^c[1],o[2]^c[2],o[3]^c[3]]}s*=2}for(a[0]=[0,0,0,0],s=n+1;s<r;++s){var u=a[s^n];a[s]=[e[0]^u[0],e[1]^u[1],e[2]^u[2],e[3]^u[3]]}return a};function Bo(e,t){if(typeof e=="string"&&(e=Wt.util.createBuffer(e)),Wt.util.isArray(e)&&e.length>4){var r=e;e=Wt.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!Wt.util.isArray(e)){for(var a=[],s=t/4,n=0;n<s;++n)a.push(e.getInt32());e=a}return e}function ko(e){e[e.length-1]=e[e.length-1]+1&4294967295}function _u(e){return[e/4294967296|0,e&4294967295]}var At=Ze;At.aes=At.aes||{};At.aes.startEncrypting=function(e,t,r,n){var a=Oo({key:e,output:r,decrypt:!1,mode:n});return a.start(t),a};At.aes.createEncryptionCipher=function(e,t){return Oo({key:e,output:null,decrypt:!1,mode:t})};At.aes.startDecrypting=function(e,t,r,n){var a=Oo({key:e,output:r,decrypt:!0,mode:n});return a.start(t),a};At.aes.createDecryptionCipher=function(e,t){return Oo({key:e,output:null,decrypt:!0,mode:t})};At.aes.Algorithm=function(e,t){Ld||ug();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(n,a){return Ru(r._w,n,a,!1)},decrypt:function(n,a){return Ru(r._w,n,a,!0)}}}),r._init=!1};At.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t=e.key,r;if(typeof t=="string"&&(t.length===16||t.length===24||t.length===32))t=At.util.createBuffer(t);else if(At.util.isArray(t)&&(t.length===16||t.length===24||t.length===32)){r=t,t=At.util.createBuffer();for(var n=0;n<r.length;++n)t.putByte(r[n])}if(!At.util.isArray(t)){r=t,t=[];var a=r.length();if(a===16||a===24||a===32){a=a>>>2;for(var n=0;n<a;++n)t.push(r.getInt32())}}if(!At.util.isArray(t)||!(t.length===4||t.length===6||t.length===8))throw new Error("Invalid key parameter.");var s=this.mode.name,i=["CFB","OFB","CTR","GCM"].indexOf(s)!==-1;this._w=lg(t,e.decrypt&&!i),this._init=!0}};At.aes._expandKey=function(e,t){return Ld||ug(),lg(e,t)};At.aes._updateBlock=Ru;ls("AES-ECB",At.cipher.modes.ecb);ls("AES-CBC",At.cipher.modes.cbc);ls("AES-CFB",At.cipher.modes.cfb);ls("AES-OFB",At.cipher.modes.ofb);ls("AES-CTR",At.cipher.modes.ctr);ls("AES-GCM",At.cipher.modes.gcm);function ls(e,t){var r=function(){return new At.aes.Algorithm(e,t)};At.cipher.registerAlgorithm(e,r)}var Ld=!1,La=4,fr,Du,cg,pa,Kr;function ug(){Ld=!0,cg=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;fr=new Array(256),Du=new Array(256),pa=new Array(4),Kr=new Array(4);for(var t=0;t<4;++t)pa[t]=new Array(256),Kr[t]=new Array(256);for(var r=0,n=0,a,s,i,o,c,u,l,t=0;t<256;++t){o=n^n<<1^n<<2^n<<3^n<<4,o=o>>8^o&255^99,fr[r]=o,Du[o]=r,c=e[o],a=e[r],s=e[a],i=e[s],u=c<<24^o<<16^o<<8^(o^c),l=(a^s^i)<<24^(r^i)<<16^(r^s^i)<<8^(r^a^i);for(var d=0;d<4;++d)pa[d][r]=u,Kr[d][o]=l,u=u<<24|u>>>8,l=l<<24|l>>>8;r===0?r=n=1:(r=a^e[e[e[a^i]]],n^=e[e[n]])}}function lg(e,t){for(var r=e.slice(0),n,a=1,s=r.length,i=s+6+1,o=La*i,c=s;c<o;++c)n=r[c-1],c%s===0?(n=fr[n>>>16&255]<<24^fr[n>>>8&255]<<16^fr[n&255]<<8^fr[n>>>24]^cg[a]<<24,a++):s>6&&c%s===4&&(n=fr[n>>>24]<<24^fr[n>>>16&255]<<16^fr[n>>>8&255]<<8^fr[n&255]),r[c]=r[c-s]^n;if(t){var u,l=Kr[0],d=Kr[1],h=Kr[2],p=Kr[3],f=r.slice(0);o=r.length;for(var c=0,g=o-La;c<o;c+=La,g-=La)if(c===0||c===o-La)f[c]=r[g],f[c+1]=r[g+3],f[c+2]=r[g+2],f[c+3]=r[g+1];else for(var y=0;y<La;++y)u=r[g+y],f[c+(3&-y)]=l[fr[u>>>24]]^d[fr[u>>>16&255]]^h[fr[u>>>8&255]]^p[fr[u&255]];r=f}return r}function Ru(e,t,r,n){var a=e.length/4-1,s,i,o,c,u;n?(s=Kr[0],i=Kr[1],o=Kr[2],c=Kr[3],u=Du):(s=pa[0],i=pa[1],o=pa[2],c=pa[3],u=fr);var l,d,h,p,f,g,y;l=t[0]^e[0],d=t[n?3:1]^e[1],h=t[2]^e[2],p=t[n?1:3]^e[3];for(var b=3,m=1;m<a;++m)f=s[l>>>24]^i[d>>>16&255]^o[h>>>8&255]^c[p&255]^e[++b],g=s[d>>>24]^i[h>>>16&255]^o[p>>>8&255]^c[l&255]^e[++b],y=s[h>>>24]^i[p>>>16&255]^o[l>>>8&255]^c[d&255]^e[++b],p=s[p>>>24]^i[l>>>16&255]^o[d>>>8&255]^c[h&255]^e[++b],l=f,d=g,h=y;r[0]=u[l>>>24]<<24^u[d>>>16&255]<<16^u[h>>>8&255]<<8^u[p&255]^e[++b],r[n?3:1]=u[d>>>24]<<24^u[h>>>16&255]<<16^u[p>>>8&255]<<8^u[l&255]^e[++b],r[2]=u[h>>>24]<<24^u[p>>>16&255]<<16^u[l>>>8&255]<<8^u[d&255]^e[++b],r[n?1:3]=u[p>>>24]<<24^u[l>>>16&255]<<16^u[d>>>8&255]<<8^u[h&255]^e[++b]}function Oo(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),r="AES-"+t,n;e.decrypt?n=At.cipher.createDecipher(r,e.key):n=At.cipher.createCipher(r,e.key);var a=n.start;return n.start=function(s,i){var o=null;i instanceof At.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,a.call(n,i)},n}var Ks=Ze;Ks.pki=Ks.pki||{};var Nu=Ks.pki.oids=Ks.oids=Ks.oids||{};function de(e,t){Nu[e]=t,Nu[t]=e}function pt(e,t){Nu[e]=t}de("1.2.840.113549.1.1.1","rsaEncryption");de("1.2.840.113549.1.1.4","md5WithRSAEncryption");de("1.2.840.113549.1.1.5","sha1WithRSAEncryption");de("1.2.840.113549.1.1.7","RSAES-OAEP");de("1.2.840.113549.1.1.8","mgf1");de("1.2.840.113549.1.1.9","pSpecified");de("1.2.840.113549.1.1.10","RSASSA-PSS");de("1.2.840.113549.1.1.11","sha256WithRSAEncryption");de("1.2.840.113549.1.1.12","sha384WithRSAEncryption");de("1.2.840.113549.1.1.13","sha512WithRSAEncryption");de("1.3.101.112","EdDSA25519");de("1.2.840.10040.4.3","dsa-with-sha1");de("1.3.14.3.2.7","desCBC");de("1.3.14.3.2.26","sha1");de("1.3.14.3.2.29","sha1WithRSASignature");de("2.16.840.1.101.3.4.2.1","sha256");de("2.16.840.1.101.3.4.2.2","sha384");de("2.16.840.1.101.3.4.2.3","sha512");de("2.16.840.1.101.3.4.2.4","sha224");de("2.16.840.1.101.3.4.2.5","sha512-224");de("2.16.840.1.101.3.4.2.6","sha512-256");de("1.2.840.113549.2.2","md2");de("1.2.840.113549.2.5","md5");de("1.2.840.113549.1.7.1","data");de("1.2.840.113549.1.7.2","signedData");de("1.2.840.113549.1.7.3","envelopedData");de("1.2.840.113549.1.7.4","signedAndEnvelopedData");de("1.2.840.113549.1.7.5","digestedData");de("1.2.840.113549.1.7.6","encryptedData");de("1.2.840.113549.1.9.1","emailAddress");de("1.2.840.113549.1.9.2","unstructuredName");de("1.2.840.113549.1.9.3","contentType");de("1.2.840.113549.1.9.4","messageDigest");de("1.2.840.113549.1.9.5","signingTime");de("1.2.840.113549.1.9.6","counterSignature");de("1.2.840.113549.1.9.7","challengePassword");de("1.2.840.113549.1.9.8","unstructuredAddress");de("1.2.840.113549.1.9.14","extensionRequest");de("1.2.840.113549.1.9.20","friendlyName");de("1.2.840.113549.1.9.21","localKeyId");de("1.2.840.113549.1.9.22.1","x509Certificate");de("1.2.840.113549.1.12.10.1.1","keyBag");de("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");de("1.2.840.113549.1.12.10.1.3","certBag");de("1.2.840.113549.1.12.10.1.4","crlBag");de("1.2.840.113549.1.12.10.1.5","secretBag");de("1.2.840.113549.1.12.10.1.6","safeContentsBag");de("1.2.840.113549.1.5.13","pkcs5PBES2");de("1.2.840.113549.1.5.12","pkcs5PBKDF2");de("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");de("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");de("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");de("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");de("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");de("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");de("1.2.840.113549.2.7","hmacWithSHA1");de("1.2.840.113549.2.8","hmacWithSHA224");de("1.2.840.113549.2.9","hmacWithSHA256");de("1.2.840.113549.2.10","hmacWithSHA384");de("1.2.840.113549.2.11","hmacWithSHA512");de("1.2.840.113549.3.7","des-EDE3-CBC");de("2.16.840.1.101.3.4.1.2","aes128-CBC");de("2.16.840.1.101.3.4.1.22","aes192-CBC");de("2.16.840.1.101.3.4.1.42","aes256-CBC");de("2.5.4.3","commonName");de("2.5.4.4","surname");de("2.5.4.5","serialNumber");de("2.5.4.6","countryName");de("2.5.4.7","localityName");de("2.5.4.8","stateOrProvinceName");de("2.5.4.9","streetAddress");de("2.5.4.10","organizationName");de("2.5.4.11","organizationalUnitName");de("2.5.4.12","title");de("2.5.4.13","description");de("2.5.4.15","businessCategory");de("2.5.4.17","postalCode");de("2.5.4.42","givenName");de("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");de("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");de("2.16.840.1.113730.1.1","nsCertType");de("2.16.840.1.113730.1.13","nsComment");pt("2.5.29.1","authorityKeyIdentifier");pt("2.5.29.2","keyAttributes");pt("2.5.29.3","certificatePolicies");pt("2.5.29.4","keyUsageRestriction");pt("2.5.29.5","policyMapping");pt("2.5.29.6","subtreesConstraint");pt("2.5.29.7","subjectAltName");pt("2.5.29.8","issuerAltName");pt("2.5.29.9","subjectDirectoryAttributes");pt("2.5.29.10","basicConstraints");pt("2.5.29.11","nameConstraints");pt("2.5.29.12","policyConstraints");pt("2.5.29.13","basicConstraints");de("2.5.29.14","subjectKeyIdentifier");de("2.5.29.15","keyUsage");pt("2.5.29.16","privateKeyUsagePeriod");de("2.5.29.17","subjectAltName");de("2.5.29.18","issuerAltName");de("2.5.29.19","basicConstraints");pt("2.5.29.20","cRLNumber");pt("2.5.29.21","cRLReason");pt("2.5.29.22","expirationDate");pt("2.5.29.23","instructionCode");pt("2.5.29.24","invalidityDate");pt("2.5.29.25","cRLDistributionPoints");pt("2.5.29.26","issuingDistributionPoint");pt("2.5.29.27","deltaCRLIndicator");pt("2.5.29.28","issuingDistributionPoint");pt("2.5.29.29","certificateIssuer");pt("2.5.29.30","nameConstraints");de("2.5.29.31","cRLDistributionPoints");de("2.5.29.32","certificatePolicies");pt("2.5.29.33","policyMappings");pt("2.5.29.34","policyConstraints");de("2.5.29.35","authorityKeyIdentifier");pt("2.5.29.36","policyConstraints");de("2.5.29.37","extKeyUsage");pt("2.5.29.46","freshestCRL");pt("2.5.29.54","inhibitAnyPolicy");de("1.3.6.1.4.1.11129.2.4.2","timestampList");de("1.3.6.1.5.5.7.1.1","authorityInfoAccess");de("1.3.6.1.5.5.7.3.1","serverAuth");de("1.3.6.1.5.5.7.3.2","clientAuth");de("1.3.6.1.5.5.7.3.3","codeSigning");de("1.3.6.1.5.5.7.3.4","emailProtection");de("1.3.6.1.5.5.7.3.8","timeStamping");var Pt=Ze,Se=Pt.asn1=Pt.asn1||{};Se.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};Se.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30};Se.create=function(e,t,r,n,a){if(Pt.util.isArray(n)){for(var s=[],i=0;i<n.length;++i)n[i]!==void 0&&s.push(n[i]);n=s}var o={tagClass:e,type:t,constructed:r,composed:r||Pt.util.isArray(n),value:n};return a&&"bitStringContents"in a&&(o.bitStringContents=a.bitStringContents,o.original=Se.copy(o)),o};Se.copy=function(e,t){var r;if(Pt.util.isArray(e)){r=[];for(var n=0;n<e.length;++n)r.push(Se.copy(e[n],t));return r}return typeof e=="string"?e:(r={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:Se.copy(e.value,t)},t&&!t.excludeBitStringContents&&(r.bitStringContents=e.bitStringContents),r)};Se.equals=function(e,t,r){if(Pt.util.isArray(e)){if(!Pt.util.isArray(t)||e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(!Se.equals(e[n],t[n]))return!1;return!0}if(typeof e!=typeof t)return!1;if(typeof e=="string")return e===t;var a=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&Se.equals(e.value,t.value);return r&&r.includeBitStringContents&&(a=a&&e.bitStringContents===t.bitStringContents),a};Se.getBerValueLength=function(e){var t=e.getByte();if(t!==128){var r,n=t&128;return n?r=e.getInt((t&127)<<3):r=t,r}};function Ms(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}var W1=function(e,t){var r=e.getByte();if(t--,r!==128){var n,a=r&128;if(!a)n=r;else{var s=r&127;Ms(e,t,s),n=e.getInt(s<<3)}if(n<0)throw new Error("Negative length: "+n);return n}};Se.fromDer=function(e,t){t===void 0&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof t=="boolean"&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),typeof e=="string"&&(e=Pt.util.createBuffer(e));var r=e.length(),n=Mi(e,e.length(),0,t);if(t.parseAllBytes&&e.length()!==0){var a=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw a.byteCount=r,a.remaining=e.length(),a}return n};function Mi(e,t,r,n){var a;Ms(e,t,2);var s=e.getByte();t--;var i=s&192,o=s&31;a=e.length();var c=W1(e,t);if(t-=a-e.length(),c!==void 0&&c>t){if(n.strict){var u=new Error("Too few bytes to read ASN.1 value.");throw u.available=e.length(),u.remaining=t,u.requested=c,u}c=t}var l,d,h=(s&32)===32;if(h)if(l=[],c===void 0)for(;;){if(Ms(e,t,2),e.bytes(2)==="\0\0"){e.getBytes(2),t-=2;break}a=e.length(),l.push(Mi(e,t,r+1,n)),t-=a-e.length()}else for(;c>0;)a=e.length(),l.push(Mi(e,c,r+1,n)),t-=a-e.length(),c-=a-e.length();if(l===void 0&&i===Se.Class.UNIVERSAL&&o===Se.Type.BITSTRING&&(d=e.bytes(c)),l===void 0&&n.decodeBitStrings&&i===Se.Class.UNIVERSAL&&o===Se.Type.BITSTRING&&c>1){var p=e.read,f=t,g=0;if(o===Se.Type.BITSTRING&&(Ms(e,t,1),g=e.getByte(),t--),g===0)try{a=e.length();var y={strict:!0,decodeBitStrings:!0},b=Mi(e,t,r+1,y),m=a-e.length();t-=m,o==Se.Type.BITSTRING&&m++;var v=b.tagClass;m===c&&(v===Se.Class.UNIVERSAL||v===Se.Class.CONTEXT_SPECIFIC)&&(l=[b])}catch{}l===void 0&&(e.read=p,t=f)}if(l===void 0){if(c===void 0){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");c=t}if(o===Se.Type.BMPSTRING)for(l="";c>0;c-=2)Ms(e,t,2),l+=String.fromCharCode(e.getInt16()),t-=2;else l=e.getBytes(c),t-=c}var S=d===void 0?null:{bitStringContents:d};return Se.create(i,o,h,l,S)}Se.toDer=function(e){var t=Pt.util.createBuffer(),r=e.tagClass|e.type,n=Pt.util.createBuffer(),a=!1;if("bitStringContents"in e&&(a=!0,e.original&&(a=Se.equals(e,e.original))),a)n.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:n.putByte(0);for(var s=0;s<e.value.length;++s)e.value[s]!==void 0&&n.putBuffer(Se.toDer(e.value[s]))}else if(e.type===Se.Type.BMPSTRING)for(var s=0;s<e.value.length;++s)n.putInt16(e.value.charCodeAt(s));else e.type===Se.Type.INTEGER&&e.value.length>1&&(e.value.charCodeAt(0)===0&&!(e.value.charCodeAt(1)&128)||e.value.charCodeAt(0)===255&&(e.value.charCodeAt(1)&128)===128)?n.putBytes(e.value.substr(1)):n.putBytes(e.value);if(t.putByte(r),n.length()<=127)t.putByte(n.length()&127);else{var i=n.length(),o="";do o+=String.fromCharCode(i&255),i=i>>>8;while(i>0);t.putByte(o.length|128);for(var s=o.length-1;s>=0;--s)t.putByte(o.charCodeAt(s))}return t.putBuffer(n),t};Se.oidToDer=function(e){var t=e.split("."),r=Pt.util.createBuffer();r.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var n,a,s,i,o=2;o<t.length;++o){n=!0,a=[],s=parseInt(t[o],10);do i=s&127,s=s>>>7,n||(i|=128),a.push(i),n=!1;while(s>0);for(var c=a.length-1;c>=0;--c)r.putByte(a[c])}return r};Se.derToOid=function(e){var t;typeof e=="string"&&(e=Pt.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)r=e.getByte(),n=n<<7,r&128?n+=r&127:(t+="."+(n+r),n=0);return t};Se.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,a=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var c=e.charAt(10),u=10;c!=="+"&&c!=="-"&&(o=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,a),t.setUTCHours(s,i,o,0),u&&(c=e.charAt(u),c==="+"||c==="-")){var l=parseInt(e.substr(u+1,2),10),d=parseInt(e.substr(u+4,2),10),h=l*60+d;h*=6e4,c==="+"?t.setTime(+t-h):t.setTime(+t+h)}return t};Se.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,a=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),i=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;e.charAt(e.length-1)==="Z"&&(l=!0);var d=e.length-5,h=e.charAt(d);if(h==="+"||h==="-"){var p=parseInt(e.substr(d+1,2),10),f=parseInt(e.substr(d+4,2),10);u=p*60+f,u*=6e4,h==="+"&&(u*=-1),l=!0}return e.charAt(14)==="."&&(c=parseFloat(e.substr(14),10)*1e3),l?(t.setUTCFullYear(r,n,a),t.setUTCHours(s,i,o,c),t.setTime(+t+u)):(t.setFullYear(r,n,a),t.setHours(s,i,o,c)),t};Se.dateToUtcTime=function(e){if(typeof e=="string")return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z",t};Se.dateToGeneralizedTime=function(e){if(typeof e=="string")return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z",t};Se.integerToDer=function(e){var t=Pt.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r};Se.derToInteger=function(e){typeof e=="string"&&(e=Pt.util.createBuffer(e));var t=e.length()*8;if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)};Se.validate=function(e,t,r,n){var a=!1;if((e.tagClass===t.tagClass||typeof t.tagClass>"u")&&(e.type===t.type||typeof t.type>"u"))if(e.constructed===t.constructed||typeof t.constructed>"u"){if(a=!0,t.value&&Pt.util.isArray(t.value))for(var s=0,i=0;a&&i<t.value.length;++i)a=t.value[i].optional||!1,e.value[s]&&(a=Se.validate(e.value[s],t.value[i],r,n),a?++s:t.value[i].optional&&(a=!0)),!a&&n&&n.push("["+t.name+'] Tag class "'+t.tagClass+'", type "'+t.type+'" expected value length "'+t.value.length+'", got "'+e.value.length+'"');if(a&&r&&(t.capture&&(r[t.capture]=e.value),t.captureAsn1&&(r[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(r[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)r[t.captureBitStringValue]="";else{var o=e.bitStringContents.charCodeAt(0);if(o!==0)throw new Error("captureBitStringValue only supported for zero unused bits");r[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else n&&n.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');else n&&(e.tagClass!==t.tagClass&&n.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&n.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));return a};var Ih=/[^\\u0000-\\u00ff]/;Se.prettyPrint=function(e,t,r){var n="";t=t||0,r=r||2,t>0&&(n+=`
`);for(var a="",s=0;s<t*r;++s)a+=" ";switch(n+=a+"Tag: ",e.tagClass){case Se.Class.UNIVERSAL:n+="Universal:";break;case Se.Class.APPLICATION:n+="Application:";break;case Se.Class.CONTEXT_SPECIFIC:n+="Context-Specific:";break;case Se.Class.PRIVATE:n+="Private:";break}if(e.tagClass===Se.Class.UNIVERSAL)switch(n+=e.type,e.type){case Se.Type.NONE:n+=" (None)";break;case Se.Type.BOOLEAN:n+=" (Boolean)";break;case Se.Type.INTEGER:n+=" (Integer)";break;case Se.Type.BITSTRING:n+=" (Bit string)";break;case Se.Type.OCTETSTRING:n+=" (Octet string)";break;case Se.Type.NULL:n+=" (Null)";break;case Se.Type.OID:n+=" (Object Identifier)";break;case Se.Type.ODESC:n+=" (Object Descriptor)";break;case Se.Type.EXTERNAL:n+=" (External or Instance of)";break;case Se.Type.REAL:n+=" (Real)";break;case Se.Type.ENUMERATED:n+=" (Enumerated)";break;case Se.Type.EMBEDDED:n+=" (Embedded PDV)";break;case Se.Type.UTF8:n+=" (UTF8)";break;case Se.Type.ROID:n+=" (Relative Object Identifier)";break;case Se.Type.SEQUENCE:n+=" (Sequence)";break;case Se.Type.SET:n+=" (Set)";break;case Se.Type.PRINTABLESTRING:n+=" (Printable String)";break;case Se.Type.IA5String:n+=" (IA5String (ASCII))";break;case Se.Type.UTCTIME:n+=" (UTC time)";break;case Se.Type.GENERALIZEDTIME:n+=" (Generalized time)";break;case Se.Type.BMPSTRING:n+=" (BMP String)";break}else n+=e.type;if(n+=`
`,n+=a+"Constructed: "+e.constructed+`
`,e.composed){for(var i=0,o="",s=0;s<e.value.length;++s)e.value[s]!==void 0&&(i+=1,o+=Se.prettyPrint(e.value[s],t+1,r),s+1<e.value.length&&(o+=","));n+=a+"Sub values: "+i+o}else{if(n+=a+"Value: ",e.type===Se.Type.OID){var c=Se.derToOid(e.value);n+=c,Pt.pki&&Pt.pki.oids&&c in Pt.pki.oids&&(n+=" ("+Pt.pki.oids[c]+") ")}if(e.type===Se.Type.INTEGER)try{n+=Se.derToInteger(e.value)}catch{n+="0x"+Pt.util.bytesToHex(e.value)}else if(e.type===Se.Type.BITSTRING){if(e.value.length>1?n+="0x"+Pt.util.bytesToHex(e.value.slice(1)):n+="(none)",e.value.length>0){var u=e.value.charCodeAt(0);u==1?n+=" (1 unused bit shown)":u>1&&(n+=" ("+u+" unused bits shown)")}}else if(e.type===Se.Type.OCTETSTRING)Ih.test(e.value)||(n+="("+e.value+") "),n+="0x"+Pt.util.bytesToHex(e.value);else if(e.type===Se.Type.UTF8)try{n+=Pt.util.decodeUtf8(e.value)}catch(l){if(l.message==="URI malformed")n+="0x"+Pt.util.bytesToHex(e.value)+" (malformed UTF8)";else throw l}else e.type===Se.Type.PRINTABLESTRING||e.type===Se.Type.IA5String?n+=e.value:Ih.test(e.value)?n+="0x"+Pt.util.bytesToHex(e.value):e.value.length===0?n+="[null]":n+=e.value}return n};var ro=Ze;ro.md=ro.md||{};ro.md.algorithms=ro.md.algorithms||{};var vn=Ze,Z1=vn.hmac=vn.hmac||{};Z1.create=function(){var e=null,t=null,r=null,n=null,a={};return a.start=function(s,i){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in vn.md.algorithms)t=vn.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else t=s;if(i===null)i=e;else{if(typeof i=="string")i=vn.util.createBuffer(i);else if(vn.util.isArray(i)){var o=i;i=vn.util.createBuffer();for(var c=0;c<o.length;++c)i.putByte(o[c])}var u=i.length();u>t.blockLength&&(t.start(),t.update(i.bytes()),i=t.digest()),r=vn.util.createBuffer(),n=vn.util.createBuffer(),u=i.length();for(var c=0;c<u;++c){var o=i.at(c);r.putByte(54^o),n.putByte(92^o)}if(u<t.blockLength)for(var o=t.blockLength-u,c=0;c<o;++c)r.putByte(54),n.putByte(92);e=i,r=r.bytes(),n=n.bytes()}t.start(),t.update(r)},a.update=function(s){t.update(s)},a.getMac=function(){var s=t.digest().bytes();return t.start(),t.update(n),t.update(s),t.digest()},a.digest=a.getMac,a};var tn=Ze,dg=tn.md5=tn.md5||{};tn.md.md5=tn.md.algorithms.md5=dg;dg.create=function(){hg||Y1();var e=null,t=tn.util.createBuffer(),r=new Array(16),n={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var a=n.messageLengthSize/4,s=0;s<a;++s)n.fullMessageLength.push(0);return t=tn.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},n},n.start(),n.update=function(a,s){s==="utf8"&&(a=tn.util.encodeUtf8(a));var i=a.length;n.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=i[1],i[1]=i[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(a),Ph(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),n},n.digest=function(){var a=tn.util.createBuffer();a.putBytes(t.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,i=s&n.blockLength-1;a.putBytes(Bu.substr(0,n.blockLength-i));for(var o,c=0,u=n.fullMessageLength.length-1;u>=0;--u)o=n.fullMessageLength[u]*8+c,c=o/4294967296>>>0,a.putInt32Le(o>>>0);var l={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};Ph(l,r,a);var d=tn.util.createBuffer();return d.putInt32Le(l.h0),d.putInt32Le(l.h1),d.putInt32Le(l.h2),d.putInt32Le(l.h3),d},n};var Bu=null,ji=null,js=null,Ka=null,hg=!1;function Y1(){Bu="",Bu+=tn.util.fillString("\0",64),ji=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],js=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],Ka=new Array(64);for(var e=0;e<64;++e)Ka[e]=Math.floor(Math.abs(Math.sin(e+1))*4294967296);hg=!0}function Ph(e,t,r){for(var n,a,s,i,o,c,u,l,d=r.length();d>=64;){for(a=e.h0,s=e.h1,i=e.h2,o=e.h3,l=0;l<16;++l)t[l]=r.getInt32Le(),c=o^s&(i^o),n=a+c+Ka[l]+t[l],u=js[l],a=o,o=i,i=s,s+=n<<u|n>>>32-u;for(;l<32;++l)c=i^o&(s^i),n=a+c+Ka[l]+t[ji[l]],u=js[l],a=o,o=i,i=s,s+=n<<u|n>>>32-u;for(;l<48;++l)c=s^i^o,n=a+c+Ka[l]+t[ji[l]],u=js[l],a=o,o=i,i=s,s+=n<<u|n>>>32-u;for(;l<64;++l)c=i^(s|~o),n=a+c+Ka[l]+t[ji[l]],u=js[l],a=o,o=i,i=s,s+=n<<u|n>>>32-u;e.h0=e.h0+a|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,d-=64}}var no=Ze,pg=no.pem=no.pem||{};pg.encode=function(e,t){t=t||{};var r="-----BEGIN "+e.type+`-----\r
`,n;if(e.procType&&(n={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]},r+=Ti(n)),e.contentDomain&&(n={name:"Content-Domain",values:[e.contentDomain]},r+=Ti(n)),e.dekInfo&&(n={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&n.values.push(e.dekInfo.parameters),r+=Ti(n)),e.headers)for(var a=0;a<e.headers.length;++a)r+=Ti(e.headers[a]);return e.procType&&(r+=`\r
`),r+=no.util.encode64(e.body,t.maxline||64)+`\r
`,r+="-----END "+e.type+`-----\r
`,r};pg.decode=function(e){for(var t=[],r=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,n=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,a=/\r?\n/,s;s=r.exec(e),!!s;){var i=s[1];i==="NEW CERTIFICATE REQUEST"&&(i="CERTIFICATE REQUEST");var o={type:i,procType:null,contentDomain:null,dekInfo:null,headers:[],body:no.util.decode64(s[3])};if(t.push(o),!!s[2]){for(var c=s[2].split(a),u=0;s&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),d=u+1;d<c.length;++d){var h=c[d];if(!/\s/.test(h[0]))break;l+=h,u=d}if(s=l.match(n),s){for(var p={name:s[1],values:[]},f=s[2].split(","),g=0;g<f.length;++g)p.values.push(X1(f[g]));if(o.procType)if(!o.contentDomain&&p.name==="Content-Domain")o.contentDomain=f[0]||"";else if(!o.dekInfo&&p.name==="DEK-Info"){if(p.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');o.dekInfo={algorithm:f[0],parameters:f[1]||null}}else o.headers.push(p);else{if(p.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(p.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');o.procType={version:f[0],type:f[1]}}}++u}if(o.procType==="ENCRYPTED"&&!o.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(t.length===0)throw new Error("Invalid PEM formatted message.");return t};function Ti(e){for(var t=e.name+": ",r=[],n=function(c,u){return" "+u},a=0;a<e.values.length;++a)r.push(e.values[a].replace(/^(\S+\r\n)/,n));t+=r.join(",")+`\r
`;for(var s=0,i=-1,a=0;a<t.length;++a,++s)if(s>65&&i!==-1){var o=t[i];o===","?(++i,t=t.substr(0,i)+`\r
 `+t.substr(i)):t=t.substr(0,i)+`\r
`+o+t.substr(i+1),s=a-i-1,i=-1,++a}else(t[a]===" "||t[a]==="	"||t[a]===",")&&(i=a);return t}function X1(e){return e.replace(/^\s+/,"")}var kt=Ze;kt.des=kt.des||{};kt.des.startEncrypting=function(e,t,r,n){var a=Uo({key:e,output:r,decrypt:!1,mode:n||(t===null?"ECB":"CBC")});return a.start(t),a};kt.des.createEncryptionCipher=function(e,t){return Uo({key:e,output:null,decrypt:!1,mode:t})};kt.des.startDecrypting=function(e,t,r,n){var a=Uo({key:e,output:r,decrypt:!0,mode:n||(t===null?"ECB":"CBC")});return a.start(t),a};kt.des.createDecryptionCipher=function(e,t){return Uo({key:e,output:null,decrypt:!0,mode:t})};kt.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(n,a){return _h(r._keys,n,a,!1)},decrypt:function(n,a){return _h(r._keys,n,a,!0)}}}),r._init=!1};kt.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=kt.util.createBuffer(e.key);if(this.name.indexOf("3DES")===0&&t.length()!==24)throw new Error("Invalid Triple-DES key size: "+t.length()*8);this._keys=ov(t),this._init=!0}};dn("DES-ECB",kt.cipher.modes.ecb);dn("DES-CBC",kt.cipher.modes.cbc);dn("DES-CFB",kt.cipher.modes.cfb);dn("DES-OFB",kt.cipher.modes.ofb);dn("DES-CTR",kt.cipher.modes.ctr);dn("3DES-ECB",kt.cipher.modes.ecb);dn("3DES-CBC",kt.cipher.modes.cbc);dn("3DES-CFB",kt.cipher.modes.cfb);dn("3DES-OFB",kt.cipher.modes.ofb);dn("3DES-CTR",kt.cipher.modes.ctr);function dn(e,t){var r=function(){return new kt.des.Algorithm(e,t)};kt.cipher.registerAlgorithm(e,r)}var J1=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],ev=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],tv=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],rv=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],nv=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],av=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],sv=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],iv=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function ov(e){for(var t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],r=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],a=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],i=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],o=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],u=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],l=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],h=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],f=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=e.length()>8?3:1,y=[],b=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],m=0,v,S=0;S<g;S++){var C=e.getInt32(),E=e.getInt32();v=(C>>>4^E)&252645135,E^=v,C^=v<<4,v=(E>>>-16^C)&65535,C^=v,E^=v<<-16,v=(C>>>2^E)&858993459,E^=v,C^=v<<2,v=(E>>>-16^C)&65535,C^=v,E^=v<<-16,v=(C>>>1^E)&1431655765,E^=v,C^=v<<1,v=(E>>>8^C)&16711935,C^=v,E^=v<<8,v=(C>>>1^E)&1431655765,E^=v,C^=v<<1,v=C<<8|E>>>20&240,C=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=v;for(var w=0;w<b.length;++w){b[w]?(C=C<<2|C>>>26,E=E<<2|E>>>26):(C=C<<1|C>>>27,E=E<<1|E>>>27),C&=-15,E&=-15;var _=t[C>>>28]|r[C>>>24&15]|n[C>>>20&15]|a[C>>>16&15]|s[C>>>12&15]|i[C>>>8&15]|o[C>>>4&15],P=c[E>>>28]|u[E>>>24&15]|l[E>>>20&15]|d[E>>>16&15]|h[E>>>12&15]|p[E>>>8&15]|f[E>>>4&15];v=(P>>>16^_)&65535,y[m++]=_^v,y[m++]=P^v<<16}}return y}function _h(e,t,r,n){var a=e.length===32?3:9,s;a===3?s=n?[30,-2,-2]:[0,32,2]:s=n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var i,o=t[0],c=t[1];i=(o>>>4^c)&252645135,c^=i,o^=i<<4,i=(o>>>16^c)&65535,c^=i,o^=i<<16,i=(c>>>2^o)&858993459,o^=i,c^=i<<2,i=(c>>>8^o)&16711935,o^=i,c^=i<<8,i=(o>>>1^c)&1431655765,c^=i,o^=i<<1,o=o<<1|o>>>31,c=c<<1|c>>>31;for(var u=0;u<a;u+=3){for(var l=s[u+1],d=s[u+2],h=s[u];h!=l;h+=d){var p=c^e[h],f=(c>>>4|c<<28)^e[h+1];i=o,o=c,c=i^(ev[p>>>24&63]|rv[p>>>16&63]|av[p>>>8&63]|iv[p&63]|J1[f>>>24&63]|tv[f>>>16&63]|nv[f>>>8&63]|sv[f&63])}i=o,o=c,c=i}o=o>>>1|o<<31,c=c>>>1|c<<31,i=(o>>>1^c)&1431655765,c^=i,o^=i<<1,i=(c>>>8^o)&16711935,o^=i,c^=i<<8,i=(c>>>2^o)&858993459,o^=i,c^=i<<2,i=(o>>>16^c)&65535,c^=i,o^=i<<16,i=(o>>>4^c)&252645135,c^=i,o^=i<<4,r[0]=o,r[1]=c}function Uo(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),r="DES-"+t,n;e.decrypt?n=kt.cipher.createDecipher(r,e.key):n=kt.cipher.createCipher(r,e.key);var a=n.start;return n.start=function(s,i){var o=null;i instanceof kt.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,a.call(n,i)},n}var gr=Ze,cv=gr.pkcs5=gr.pkcs5||{},yn;gr.util.isNodejs&&!gr.options.usePureJavaScript&&(yn=Ro);gr.pbkdf2=cv.pbkdf2=function(e,t,r,n,a,s){if(typeof a=="function"&&(s=a,a=null),gr.util.isNodejs&&!gr.options.usePureJavaScript&&yn.pbkdf2&&(a===null||typeof a!="object")&&(yn.pbkdf2Sync.length>4||!a||a==="sha1"))return typeof a!="string"&&(a="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),s?yn.pbkdf2Sync.length===4?yn.pbkdf2(e,t,r,n,function(v,S){if(v)return s(v);s(null,S.toString("binary"))}):yn.pbkdf2(e,t,r,n,a,function(v,S){if(v)return s(v);s(null,S.toString("binary"))}):yn.pbkdf2Sync.length===4?yn.pbkdf2Sync(e,t,r,n).toString("binary"):yn.pbkdf2Sync(e,t,r,n,a).toString("binary");if((typeof a>"u"||a===null)&&(a="sha1"),typeof a=="string"){if(!(a in gr.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=gr.md[a].create()}var i=a.digestLength;if(n>4294967295*i){var o=new Error("Derived key is too long.");if(s)return s(o);throw o}var c=Math.ceil(n/i),u=n-(c-1)*i,l=gr.hmac.create();l.start(a,e);var d="",h,p,f;if(!s){for(var g=1;g<=c;++g){l.start(null,null),l.update(t),l.update(gr.util.int32ToBytes(g)),h=f=l.digest().getBytes();for(var y=2;y<=r;++y)l.start(null,null),l.update(f),p=l.digest().getBytes(),h=gr.util.xorBytes(h,p,i),f=p;d+=g<c?h:h.substr(0,u)}return d}var g=1,y;function b(){if(g>c)return s(null,d);l.start(null,null),l.update(t),l.update(gr.util.int32ToBytes(g)),h=f=l.digest().getBytes(),y=2,m()}function m(){if(y<=r)return l.start(null,null),l.update(f),p=l.digest().getBytes(),h=gr.util.xorBytes(h,p,i),f=p,++y,gr.util.setImmediate(m);d+=g<c?h:h.substr(0,u),++g,b()}b()};var rn=Ze,fg=rn.sha256=rn.sha256||{};rn.md.sha256=rn.md.algorithms.sha256=fg;fg.create=function(){gg||uv();var e=null,t=rn.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var a=n.messageLengthSize/4,s=0;s<a;++s)n.fullMessageLength.push(0);return t=rn.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n},n.start(),n.update=function(a,s){s==="utf8"&&(a=rn.util.encodeUtf8(a));var i=a.length;n.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=i[1],i[1]=i[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(a),Dh(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),n},n.digest=function(){var a=rn.util.createBuffer();a.putBytes(t.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,i=s&n.blockLength-1;a.putBytes(ku.substr(0,n.blockLength-i));for(var o,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)o=n.fullMessageLength[l+1]*8,c=o/4294967296>>>0,u+=c,a.putInt32(u>>>0),u=o>>>0;a.putInt32(u);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};Dh(d,r,a);var h=rn.util.createBuffer();return h.putInt32(d.h0),h.putInt32(d.h1),h.putInt32(d.h2),h.putInt32(d.h3),h.putInt32(d.h4),h.putInt32(d.h5),h.putInt32(d.h6),h.putInt32(d.h7),h},n};var ku=null,gg=!1,mg=null;function uv(){ku="",ku+=rn.util.fillString("\0",64),mg=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],gg=!0}function Dh(e,t,r){for(var n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m=r.length();m>=64;){for(u=0;u<16;++u)t[u]=r.getInt32();for(;u<64;++u)n=t[u-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,a=t[u-15],a=(a>>>7|a<<25)^(a>>>18|a<<14)^a>>>3,t[u]=n+t[u-7]+a+t[u-16]|0;for(l=e.h0,d=e.h1,h=e.h2,p=e.h3,f=e.h4,g=e.h5,y=e.h6,b=e.h7,u=0;u<64;++u)i=(f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7),o=y^f&(g^y),s=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),c=l&d|h&(l^d),n=b+i+o+mg[u]+t[u],a=s+c,b=y,y=g,g=f,f=p+n>>>0,p=h,h=d,d=l,l=n+a>>>0;e.h0=e.h0+l|0,e.h1=e.h1+d|0,e.h2=e.h2+h|0,e.h3=e.h3+p|0,e.h4=e.h4+f|0,e.h5=e.h5+g|0,e.h6=e.h6+y|0,e.h7=e.h7+b|0,m-=64}}var Xr=Ze,Fi=null;Xr.util.isNodejs&&!Xr.options.usePureJavaScript&&!process.versions["node-webkit"]&&(Fi=Ro);var lv=Xr.prng=Xr.prng||{};lv.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,n=new Array(32),a=0;a<32;++a)n[a]=r.create();t.pools=n,t.pool=0,t.generate=function(u,l){if(!l)return t.generateSync(u);var d=t.plugin.cipher,h=t.plugin.increment,p=t.plugin.formatKey,f=t.plugin.formatSeed,g=Xr.util.createBuffer();t.key=null,y();function y(b){if(b)return l(b);if(g.length()>=u)return l(null,g.getBytes(u));if(t.generated>1048575&&(t.key=null),t.key===null)return Xr.util.nextTick(function(){s(y)});var m=d(t.key,t.seed);t.generated+=m.length,g.putBytes(m),t.key=p(d(t.key,h(t.seed))),t.seed=f(d(t.key,t.seed)),Xr.util.setImmediate(y)}},t.generateSync=function(u){var l=t.plugin.cipher,d=t.plugin.increment,h=t.plugin.formatKey,p=t.plugin.formatSeed;t.key=null;for(var f=Xr.util.createBuffer();f.length()<u;){t.generated>1048575&&(t.key=null),t.key===null&&i();var g=l(t.key,t.seed);t.generated+=g.length,f.putBytes(g),t.key=h(l(t.key,d(t.seed))),t.seed=p(l(t.key,t.seed))}return f.getBytes(u)};function s(u){if(t.pools[0].messageLength>=32)return o(),u();var l=32-t.pools[0].messageLength<<5;t.seedFile(l,function(d,h){if(d)return u(d);t.collect(h),o(),u()})}function i(){if(t.pools[0].messageLength>=32)return o();var u=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(u)),o()}function o(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var u=t.plugin.md.create();u.update(t.keyBytes);for(var l=1,d=0;d<32;++d)t.reseeds%l===0&&(u.update(t.pools[d].digest().getBytes()),t.pools[d].start()),l=l<<1;t.keyBytes=u.digest().getBytes(),u.start(),u.update(t.keyBytes);var h=u.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(h),t.generated=0}function c(u){var l=null,d=Xr.util.globalScope,h=d.crypto||d.msCrypto;h&&h.getRandomValues&&(l=function(C){return h.getRandomValues(C)});var p=Xr.util.createBuffer();if(l)for(;p.length()<u;){var f=Math.max(1,Math.min(u-p.length(),65536)/4),g=new Uint32Array(Math.floor(f));try{l(g);for(var y=0;y<g.length;++y)p.putInt32(g[y])}catch(C){if(!(typeof QuotaExceededError<"u"&&C instanceof QuotaExceededError))throw C}}if(p.length()<u)for(var b,m,v,S=Math.floor(Math.random()*65536);p.length()<u;){m=16807*(S&65535),b=16807*(S>>16),m+=(b&32767)<<16,m+=b>>15,m=(m&2147483647)+(m>>31),S=m&4294967295;for(var y=0;y<3;++y)v=S>>>(y<<3),v^=Math.floor(Math.random()*256),p.putByte(v&255)}return p.getBytes(u)}return Fi?(t.seedFile=function(u,l){Fi.randomBytes(u,function(d,h){if(d)return l(d);l(null,h.toString())})},t.seedFileSync=function(u){return Fi.randomBytes(u).toString()}):(t.seedFile=function(u,l){try{l(null,c(u))}catch(d){l(d)}},t.seedFileSync=c),t.collect=function(u){for(var l=u.length,d=0;d<l;++d)t.pools[t.pool].update(u.substr(d,1)),t.pool=t.pool===31?0:t.pool+1},t.collectInt=function(u,l){for(var d="",h=0;h<l;h+=8)d+=String.fromCharCode(u>>h&255);t.collect(d)},t.registerWorker=function(u){if(u===self)t.seedFile=function(d,h){function p(f){var g=f.data;g.forge&&g.forge.prng&&(self.removeEventListener("message",p),h(g.forge.prng.err,g.forge.prng.bytes))}self.addEventListener("message",p),self.postMessage({forge:{prng:{needed:d}}})};else{var l=function(d){var h=d.data;h.forge&&h.forge.prng&&t.seedFile(h.forge.prng.needed,function(p,f){u.postMessage({forge:{prng:{err:p,bytes:f}}})})};u.addEventListener("message",l)}},t};var Gt=Ze;(function(){if(Gt.random&&Gt.random.getBytes){Gt.random;return}(function(e){var t={},r=new Array(4),n=Gt.util.createBuffer();t.formatKey=function(d){var h=Gt.util.createBuffer(d);return d=new Array(4),d[0]=h.getInt32(),d[1]=h.getInt32(),d[2]=h.getInt32(),d[3]=h.getInt32(),Gt.aes._expandKey(d,!1)},t.formatSeed=function(d){var h=Gt.util.createBuffer(d);return d=new Array(4),d[0]=h.getInt32(),d[1]=h.getInt32(),d[2]=h.getInt32(),d[3]=h.getInt32(),d},t.cipher=function(d,h){return Gt.aes._updateBlock(d,h,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},t.increment=function(d){return++d[3],d},t.md=Gt.md.sha256;function a(){var d=Gt.prng.create(t);return d.getBytes=function(h,p){return d.generate(h,p)},d.getBytesSync=function(h){return d.generate(h)},d}var s=a(),i=null,o=Gt.util.globalScope,c=o.crypto||o.msCrypto;if(c&&c.getRandomValues&&(i=function(d){return c.getRandomValues(d)}),Gt.options.usePureJavaScript||!Gt.util.isNodejs&&!i){if(s.collectInt(+new Date,32),typeof navigator<"u"){var u="";for(var l in navigator)try{typeof navigator[l]=="string"&&(u+=navigator[l])}catch{}s.collect(u),u=null}e&&(e().mousemove(function(d){s.collectInt(d.clientX,16),s.collectInt(d.clientY,16)}),e().keypress(function(d){s.collectInt(d.charCode,8)}))}if(!Gt.random)Gt.random=s;else for(var l in s)Gt.random[l]=s[l];Gt.random.createInstance=a,Gt.random})(typeof jQuery<"u"?jQuery:null)})();var wr=Ze,ru=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],Rh=[1,2,3,5],dv=function(e,t){return e<<t&65535|(e&65535)>>16-t},hv=function(e,t){return(e&65535)>>t|e<<16-t&65535};wr.rc2=wr.rc2||{};wr.rc2.expandKey=function(e,t){typeof e=="string"&&(e=wr.util.createBuffer(e)),t=t||128;var r=e,n=e.length(),a=t,s=Math.ceil(a/8),i=255>>(a&7),o;for(o=n;o<128;o++)r.putByte(ru[r.at(o-1)+r.at(o-n)&255]);for(r.setAt(128-s,ru[r.at(128-s)&i]),o=127-s;o>=0;o--)r.setAt(o,ru[r.at(o+1)^r.at(o+s)]);return r};var yg=function(e,t,r){var n=!1,a=null,s=null,i=null,o,c,u,l,d=[];for(e=wr.rc2.expandKey(e,t),u=0;u<64;u++)d.push(e.getInt16Le());r?(o=function(f){for(u=0;u<4;u++)f[u]+=d[l]+(f[(u+3)%4]&f[(u+2)%4])+(~f[(u+3)%4]&f[(u+1)%4]),f[u]=dv(f[u],Rh[u]),l++},c=function(f){for(u=0;u<4;u++)f[u]+=d[f[(u+3)%4]&63]}):(o=function(f){for(u=3;u>=0;u--)f[u]=hv(f[u],Rh[u]),f[u]-=d[l]+(f[(u+3)%4]&f[(u+2)%4])+(~f[(u+3)%4]&f[(u+1)%4]),l--},c=function(f){for(u=3;u>=0;u--)f[u]-=d[f[(u+3)%4]&63]});var h=function(f){var g=[];for(u=0;u<4;u++){var y=a.getInt16Le();i!==null&&(r?y^=i.getInt16Le():i.putInt16Le(y)),g.push(y&65535)}l=r?0:63;for(var b=0;b<f.length;b++)for(var m=0;m<f[b][0];m++)f[b][1](g);for(u=0;u<4;u++)i!==null&&(r?i.putInt16Le(g[u]):g[u]^=i.getInt16Le()),s.putInt16Le(g[u])},p=null;return p={start:function(f,g){f&&typeof f=="string"&&(f=wr.util.createBuffer(f)),n=!1,a=wr.util.createBuffer(),s=g||new wr.util.createBuffer,i=f,p.output=s},update:function(f){for(n||a.putBuffer(f);a.length()>=8;)h([[5,o],[1,c],[6,o],[1,c],[5,o]])},finish:function(f){var g=!0;if(r)if(f)g=f(8,a,!r);else{var y=a.length()===8?8:8-a.length();a.fillWithByte(y,y)}if(g&&(n=!0,p.update()),!r&&(g=a.length()===0,g))if(f)g=f(8,s,!r);else{var b=s.length(),m=s.at(b-1);m>b?g=!1:s.truncate(m)}return g}},p};wr.rc2.startEncrypting=function(e,t,r){var n=wr.rc2.createEncryptionCipher(e,128);return n.start(t,r),n};wr.rc2.createEncryptionCipher=function(e,t){return yg(e,t,!0)};wr.rc2.startDecrypting=function(e,t,r){var n=wr.rc2.createDecryptionCipher(e,128);return n.start(t,r),n};wr.rc2.createDecryptionCipher=function(e,t){return yg(e,t,!1)};var Ou=Ze;Ou.jsbn=Ou.jsbn||{};var Sn;function le(e,t,r){this.data=[],e!=null&&(typeof e=="number"?this.fromNumber(e,t,r):t==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,t))}Ou.jsbn.BigInteger=le;function lt(){return new le(null)}function pv(e,t,r,n,a,s){for(;--s>=0;){var i=t*this.data[e++]+r.data[n]+a;a=Math.floor(i/67108864),r.data[n++]=i&67108863}return a}function fv(e,t,r,n,a,s){for(var i=t&32767,o=t>>15;--s>=0;){var c=this.data[e]&32767,u=this.data[e++]>>15,l=o*c+u*i;c=i*c+((l&32767)<<15)+r.data[n]+(a&1073741823),a=(c>>>30)+(l>>>15)+o*u+(a>>>30),r.data[n++]=c&1073741823}return a}function Nh(e,t,r,n,a,s){for(var i=t&16383,o=t>>14;--s>=0;){var c=this.data[e]&16383,u=this.data[e++]>>14,l=o*c+u*i;c=i*c+((l&16383)<<14)+r.data[n]+a,a=(c>>28)+(l>>14)+o*u,r.data[n++]=c&268435455}return a}typeof navigator>"u"?(le.prototype.am=Nh,Sn=28):navigator.appName=="Microsoft Internet Explorer"?(le.prototype.am=fv,Sn=30):navigator.appName!="Netscape"?(le.prototype.am=pv,Sn=26):(le.prototype.am=Nh,Sn=28);le.prototype.DB=Sn;le.prototype.DM=(1<<Sn)-1;le.prototype.DV=1<<Sn;var Md=52;le.prototype.FV=Math.pow(2,Md);le.prototype.F1=Md-Sn;le.prototype.F2=2*Sn-Md;var gv="0123456789abcdefghijklmnopqrstuvwxyz",Lo=new Array,ds,kr;ds=48;for(kr=0;kr<=9;++kr)Lo[ds++]=kr;ds=97;for(kr=10;kr<36;++kr)Lo[ds++]=kr;ds=65;for(kr=10;kr<36;++kr)Lo[ds++]=kr;function Bh(e){return gv.charAt(e)}function vg(e,t){var r=Lo[e.charCodeAt(t)];return r??-1}function mv(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function yv(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function Hn(e){var t=lt();return t.fromInt(e),t}function vv(e,t){var r;if(t==16)r=4;else if(t==8)r=3;else if(t==256)r=8;else if(t==2)r=1;else if(t==32)r=5;else if(t==4)r=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var n=e.length,a=!1,s=0;--n>=0;){var i=r==8?e[n]&255:vg(e,n);if(i<0){e.charAt(n)=="-"&&(a=!0);continue}a=!1,s==0?this.data[this.t++]=i:s+r>this.DB?(this.data[this.t-1]|=(i&(1<<this.DB-s)-1)<<s,this.data[this.t++]=i>>this.DB-s):this.data[this.t-1]|=i<<s,s+=r,s>=this.DB&&(s-=this.DB)}r==8&&e[0]&128&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),a&&le.ZERO.subTo(this,this)}function bv(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t}function Cv(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var r=(1<<t)-1,n,a=!1,s="",i=this.t,o=this.DB-i*this.DB%t;if(i-- >0)for(o<this.DB&&(n=this.data[i]>>o)>0&&(a=!0,s=Bh(n));i>=0;)o<t?(n=(this.data[i]&(1<<o)-1)<<t-o,n|=this.data[--i]>>(o+=this.DB-t)):(n=this.data[i]>>(o-=t)&r,o<=0&&(o+=this.DB,--i)),n>0&&(a=!0),a&&(s+=Bh(n));return a?s:"0"}function Sv(){var e=lt();return le.ZERO.subTo(this,e),e}function Ev(){return this.s<0?this.negate():this}function xv(e){var t=this.s-e.s;if(t!=0)return t;var r=this.t;if(t=r-e.t,t!=0)return this.s<0?-t:t;for(;--r>=0;)if((t=this.data[r]-e.data[r])!=0)return t;return 0}function Mo(e){var t=1,r;return(r=e>>>16)!=0&&(e=r,t+=16),(r=e>>8)!=0&&(e=r,t+=8),(r=e>>4)!=0&&(e=r,t+=4),(r=e>>2)!=0&&(e=r,t+=2),(r=e>>1)!=0&&(e=r,t+=1),t}function wv(){return this.t<=0?0:this.DB*(this.t-1)+Mo(this.data[this.t-1]^this.s&this.DM)}function Tv(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s}function $v(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s}function Av(e,t){var r=e%this.DB,n=this.DB-r,a=(1<<n)-1,s=Math.floor(e/this.DB),i=this.s<<r&this.DM,o;for(o=this.t-1;o>=0;--o)t.data[o+s+1]=this.data[o]>>n|i,i=(this.data[o]&a)<<r;for(o=s-1;o>=0;--o)t.data[o]=0;t.data[s]=i,t.t=this.t+s+1,t.s=this.s,t.clamp()}function Iv(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t){t.t=0;return}var n=e%this.DB,a=this.DB-n,s=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var i=r+1;i<this.t;++i)t.data[i-r-1]|=(this.data[i]&s)<<a,t.data[i-r]=this.data[i]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&s)<<a),t.t=this.t-r,t.clamp()}function Pv(e,t){for(var r=0,n=0,a=Math.min(e.t,this.t);r<a;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()}function _v(e,t){var r=this.abs(),n=e.abs(),a=r.t;for(t.t=a+n.t;--a>=0;)t.data[a]=0;for(a=0;a<n.t;++a)t.data[a+r.t]=r.am(0,n.data[a],t,a,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&le.ZERO.subTo(t,t)}function Dv(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()}function Rv(e,t,r){var n=e.abs();if(!(n.t<=0)){var a=this.abs();if(a.t<n.t){t!=null&&t.fromInt(0),r!=null&&this.copyTo(r);return}r==null&&(r=lt());var s=lt(),i=this.s,o=e.s,c=this.DB-Mo(n.data[n.t-1]);c>0?(n.lShiftTo(c,s),a.lShiftTo(c,r)):(n.copyTo(s),a.copyTo(r));var u=s.t,l=s.data[u-1];if(l!=0){var d=l*(1<<this.F1)+(u>1?s.data[u-2]>>this.F2:0),h=this.FV/d,p=(1<<this.F1)/d,f=1<<this.F2,g=r.t,y=g-u,b=t??lt();for(s.dlShiftTo(y,b),r.compareTo(b)>=0&&(r.data[r.t++]=1,r.subTo(b,r)),le.ONE.dlShiftTo(u,b),b.subTo(s,s);s.t<u;)s.data[s.t++]=0;for(;--y>=0;){var m=r.data[--g]==l?this.DM:Math.floor(r.data[g]*h+(r.data[g-1]+f)*p);if((r.data[g]+=s.am(0,m,r,y,0,u))<m)for(s.dlShiftTo(y,b),r.subTo(b,r);r.data[g]<--m;)r.subTo(b,r)}t!=null&&(r.drShiftTo(u,t),i!=o&&le.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),i<0&&le.ZERO.subTo(r,r)}}}function Nv(e){var t=lt();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(le.ZERO)>0&&e.subTo(t,t),t}function Ia(e){this.m=e}function Bv(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function kv(e){return e}function Ov(e){e.divRemTo(this.m,null,e)}function Uv(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function Lv(e,t){e.squareTo(t),this.reduce(t)}Ia.prototype.convert=Bv;Ia.prototype.revert=kv;Ia.prototype.reduce=Ov;Ia.prototype.mulTo=Uv;Ia.prototype.sqrTo=Lv;function Mv(){if(this.t<1)return 0;var e=this.data[0];if(!(e&1))return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Pa(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function jv(e){var t=lt();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(le.ZERO)>0&&this.m.subTo(t,t),t}function Fv(e){var t=lt();return e.copyTo(t),this.reduce(t),t}function qv(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=e.data[t]&32767,n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function Hv(e,t){e.squareTo(t),this.reduce(t)}function Kv(e,t,r){e.multiplyTo(t,r),this.reduce(r)}Pa.prototype.convert=jv;Pa.prototype.revert=Fv;Pa.prototype.reduce=qv;Pa.prototype.mulTo=Kv;Pa.prototype.sqrTo=Hv;function Vv(){return(this.t>0?this.data[0]&1:this.s)==0}function zv(e,t){if(e>4294967295||e<1)return le.ONE;var r=lt(),n=lt(),a=t.convert(this),s=Mo(e)-1;for(a.copyTo(r);--s>=0;)if(t.sqrTo(r,n),(e&1<<s)>0)t.mulTo(n,a,r);else{var i=r;r=n,n=i}return t.revert(r)}function Gv(e,t){var r;return e<256||t.isEven()?r=new Ia(t):r=new Pa(t),this.exp(e,r)}le.prototype.copyTo=mv;le.prototype.fromInt=yv;le.prototype.fromString=vv;le.prototype.clamp=bv;le.prototype.dlShiftTo=Tv;le.prototype.drShiftTo=$v;le.prototype.lShiftTo=Av;le.prototype.rShiftTo=Iv;le.prototype.subTo=Pv;le.prototype.multiplyTo=_v;le.prototype.squareTo=Dv;le.prototype.divRemTo=Rv;le.prototype.invDigit=Mv;le.prototype.isEven=Vv;le.prototype.exp=zv;le.prototype.toString=Cv;le.prototype.negate=Sv;le.prototype.abs=Ev;le.prototype.compareTo=xv;le.prototype.bitLength=wv;le.prototype.mod=Nv;le.prototype.modPowInt=Gv;le.ZERO=Hn(0);le.ONE=Hn(1);function Qv(){var e=lt();return this.copyTo(e),e}function Wv(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function Zv(){return this.t==0?this.s:this.data[0]<<24>>24}function Yv(){return this.t==0?this.s:this.data[0]<<16>>16}function Xv(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function Jv(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function e2(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=Hn(r),a=lt(),s=lt(),i="";for(this.divRemTo(n,a,s);a.signum()>0;)i=(r+s.intValue()).toString(e).substr(1)+i,a.divRemTo(n,a,s);return s.intValue().toString(e)+i}function t2(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),a=!1,s=0,i=0,o=0;o<e.length;++o){var c=vg(e,o);if(c<0){e.charAt(o)=="-"&&this.signum()==0&&(a=!0);continue}i=t*i+c,++s>=r&&(this.dMultiply(n),this.dAddOffset(i,0),s=0,i=0)}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(i,0)),a&&le.ZERO.subTo(this,this)}function r2(e,t,r){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(le.ONE.shiftLeft(e-1),jd,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(le.ONE.shiftLeft(e-1),this);else{var n=new Array,a=e&7;n.length=(e>>3)+1,t.nextBytes(n),a>0?n[0]&=(1<<a)-1:n[0]=0,this.fromString(n,256)}}function n2(){var e=this.t,t=new Array;t[0]=this.s;var r=this.DB-e*this.DB%8,n,a=0;if(e-- >0)for(r<this.DB&&(n=this.data[e]>>r)!=(this.s&this.DM)>>r&&(t[a++]=n|this.s<<this.DB-r);e>=0;)r<8?(n=(this.data[e]&(1<<r)-1)<<8-r,n|=this.data[--e]>>(r+=this.DB-8)):(n=this.data[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),n&128&&(n|=-256),a==0&&(this.s&128)!=(n&128)&&++a,(a>0||n!=this.s)&&(t[a++]=n);return t}function a2(e){return this.compareTo(e)==0}function s2(e){return this.compareTo(e)<0?this:e}function i2(e){return this.compareTo(e)>0?this:e}function o2(e,t,r){var n,a,s=Math.min(e.t,this.t);for(n=0;n<s;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(a=e.s&this.DM,n=s;n<this.t;++n)r.data[n]=t(this.data[n],a);r.t=this.t}else{for(a=this.s&this.DM,n=s;n<e.t;++n)r.data[n]=t(a,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}function c2(e,t){return e&t}function u2(e){var t=lt();return this.bitwiseTo(e,c2,t),t}function jd(e,t){return e|t}function l2(e){var t=lt();return this.bitwiseTo(e,jd,t),t}function bg(e,t){return e^t}function d2(e){var t=lt();return this.bitwiseTo(e,bg,t),t}function Cg(e,t){return e&~t}function h2(e){var t=lt();return this.bitwiseTo(e,Cg,t),t}function p2(){for(var e=lt(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e}function f2(e){var t=lt();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function g2(e){var t=lt();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function m2(e){if(e==0)return-1;var t=0;return e&65535||(e>>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function y2(){for(var e=0;e<this.t;++e)if(this.data[e]!=0)return e*this.DB+m2(this.data[e]);return this.s<0?this.t*this.DB:-1}function v2(e){for(var t=0;e!=0;)e&=e-1,++t;return t}function b2(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=v2(this.data[r]^t);return e}function C2(e){var t=Math.floor(e/this.DB);return t>=this.t?this.s!=0:(this.data[t]&1<<e%this.DB)!=0}function S2(e,t){var r=le.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}function E2(e){return this.changeBit(e,jd)}function x2(e){return this.changeBit(e,Cg)}function w2(e){return this.changeBit(e,bg)}function T2(e,t){for(var r=0,n=0,a=Math.min(e.t,this.t);r<a;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()}function $2(e){var t=lt();return this.addTo(e,t),t}function A2(e){var t=lt();return this.subTo(e,t),t}function I2(e){var t=lt();return this.multiplyTo(e,t),t}function P2(e){var t=lt();return this.divRemTo(e,t,null),t}function _2(e){var t=lt();return this.divRemTo(e,null,t),t}function D2(e){var t=lt(),r=lt();return this.divRemTo(e,t,r),new Array(t,r)}function R2(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function N2(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function li(){}function Sg(e){return e}function B2(e,t,r){e.multiplyTo(t,r)}function k2(e,t){e.squareTo(t)}li.prototype.convert=Sg;li.prototype.revert=Sg;li.prototype.mulTo=B2;li.prototype.sqrTo=k2;function O2(e){return this.exp(e,new li)}function U2(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;var a;for(a=r.t-this.t;n<a;++n)r.data[n+this.t]=this.am(0,e.data[n],r,n,0,this.t);for(a=Math.min(e.t,t);n<a;++n)this.am(0,e.data[n],r,n,0,t-n);r.clamp()}function L2(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)}function hs(e){this.r2=lt(),this.q3=lt(),le.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function M2(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=lt();return e.copyTo(t),this.reduce(t),t}function j2(e){return e}function F2(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function q2(e,t){e.squareTo(t),this.reduce(t)}function H2(e,t,r){e.multiplyTo(t,r),this.reduce(r)}hs.prototype.convert=M2;hs.prototype.revert=j2;hs.prototype.reduce=F2;hs.prototype.mulTo=H2;hs.prototype.sqrTo=q2;function K2(e,t){var r=e.bitLength(),n,a=Hn(1),s;if(r<=0)return a;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?s=new Ia(t):t.isEven()?s=new hs(t):s=new Pa(t);var i=new Array,o=3,c=n-1,u=(1<<n)-1;if(i[1]=s.convert(this),n>1){var l=lt();for(s.sqrTo(i[1],l);o<=u;)i[o]=lt(),s.mulTo(l,i[o-2],i[o]),o+=2}var d=e.t-1,h,p=!0,f=lt(),g;for(r=Mo(e.data[d])-1;d>=0;){for(r>=c?h=e.data[d]>>r-c&u:(h=(e.data[d]&(1<<r+1)-1)<<c-r,d>0&&(h|=e.data[d-1]>>this.DB+r-c)),o=n;!(h&1);)h>>=1,--o;if((r-=o)<0&&(r+=this.DB,--d),p)i[h].copyTo(a),p=!1;else{for(;o>1;)s.sqrTo(a,f),s.sqrTo(f,a),o-=2;o>0?s.sqrTo(a,f):(g=a,a=f,f=g),s.mulTo(f,i[h],a)}for(;d>=0&&!(e.data[d]&1<<r);)s.sqrTo(a,f),g=a,a=f,f=g,--r<0&&(r=this.DB-1,--d)}return s.revert(a)}function V2(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var a=t.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return t;for(a<s&&(s=a),s>0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(a=t.getLowestSetBit())>0&&t.rShiftTo(a,t),(a=r.getLowestSetBit())>0&&r.rShiftTo(a,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function z2(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(t==0)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r}function G2(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return le.ZERO;for(var r=e.clone(),n=this.clone(),a=Hn(1),s=Hn(0),i=Hn(0),o=Hn(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!a.isEven()||!s.isEven())&&(a.addTo(this,a),s.subTo(e,s)),a.rShiftTo(1,a)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),t?((!i.isEven()||!o.isEven())&&(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);r.compareTo(n)>=0?(r.subTo(n,r),t&&a.subTo(i,a),s.subTo(o,s)):(n.subTo(r,n),t&&i.subTo(a,i),o.subTo(s,o))}if(n.compareTo(le.ONE)!=0)return le.ZERO;if(o.compareTo(e)>=0)return o.subtract(e);if(o.signum()<0)o.addTo(e,o);else return o;return o.signum()<0?o.add(e):o}var Hr=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],Q2=(1<<26)/Hr[Hr.length-1];function W2(e){var t,r=this.abs();if(r.t==1&&r.data[0]<=Hr[Hr.length-1]){for(t=0;t<Hr.length;++t)if(r.data[0]==Hr[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<Hr.length;){for(var n=Hr[t],a=t+1;a<Hr.length&&n<Q2;)n*=Hr[a++];for(n=r.modInt(n);t<a;)if(n%Hr[t++]==0)return!1}return r.millerRabin(e)}function Z2(e){var t=this.subtract(le.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n=t.shiftRight(r),a=Y2(),s,i=0;i<e;++i){do s=new le(this.bitLength(),a);while(s.compareTo(le.ONE)<=0||s.compareTo(t)>=0);var o=s.modPow(n,this);if(o.compareTo(le.ONE)!=0&&o.compareTo(t)!=0){for(var c=1;c++<r&&o.compareTo(t)!=0;)if(o=o.modPowInt(2,this),o.compareTo(le.ONE)==0)return!1;if(o.compareTo(t)!=0)return!1}}return!0}function Y2(){return{nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(Math.random()*256)}}}le.prototype.chunkSize=Xv;le.prototype.toRadix=e2;le.prototype.fromRadix=t2;le.prototype.fromNumber=r2;le.prototype.bitwiseTo=o2;le.prototype.changeBit=S2;le.prototype.addTo=T2;le.prototype.dMultiply=R2;le.prototype.dAddOffset=N2;le.prototype.multiplyLowerTo=U2;le.prototype.multiplyUpperTo=L2;le.prototype.modInt=z2;le.prototype.millerRabin=Z2;le.prototype.clone=Qv;le.prototype.intValue=Wv;le.prototype.byteValue=Zv;le.prototype.shortValue=Yv;le.prototype.signum=Jv;le.prototype.toByteArray=n2;le.prototype.equals=a2;le.prototype.min=s2;le.prototype.max=i2;le.prototype.and=u2;le.prototype.or=l2;le.prototype.xor=d2;le.prototype.andNot=h2;le.prototype.not=p2;le.prototype.shiftLeft=f2;le.prototype.shiftRight=g2;le.prototype.getLowestSetBit=y2;le.prototype.bitCount=b2;le.prototype.testBit=C2;le.prototype.setBit=E2;le.prototype.clearBit=x2;le.prototype.flipBit=w2;le.prototype.add=$2;le.prototype.subtract=A2;le.prototype.multiply=I2;le.prototype.divide=P2;le.prototype.remainder=_2;le.prototype.divideAndRemainder=D2;le.prototype.modPow=K2;le.prototype.modInverse=G2;le.prototype.pow=O2;le.prototype.gcd=V2;le.prototype.isProbablePrime=W2;var nn=Ze,Eg=nn.sha1=nn.sha1||{};nn.md.sha1=nn.md.algorithms.sha1=Eg;Eg.create=function(){xg||X2();var e=null,t=nn.util.createBuffer(),r=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var a=n.messageLengthSize/4,s=0;s<a;++s)n.fullMessageLength.push(0);return t=nn.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n},n.start(),n.update=function(a,s){s==="utf8"&&(a=nn.util.encodeUtf8(a));var i=a.length;n.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=n.fullMessageLength.length-1;o>=0;--o)n.fullMessageLength[o]+=i[1],i[1]=i[0]+(n.fullMessageLength[o]/4294967296>>>0),n.fullMessageLength[o]=n.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(a),kh(e,r,t),(t.read>2048||t.length()===0)&&t.compact(),n},n.digest=function(){var a=nn.util.createBuffer();a.putBytes(t.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,i=s&n.blockLength-1;a.putBytes(Uu.substr(0,n.blockLength-i));for(var o,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)o=n.fullMessageLength[l+1]*8,c=o/4294967296>>>0,u+=c,a.putInt32(u>>>0),u=o>>>0;a.putInt32(u);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};kh(d,r,a);var h=nn.util.createBuffer();return h.putInt32(d.h0),h.putInt32(d.h1),h.putInt32(d.h2),h.putInt32(d.h3),h.putInt32(d.h4),h},n};var Uu=null,xg=!1;function X2(){Uu="",Uu+=nn.util.fillString("\0",64),xg=!0}function kh(e,t,r){for(var n,a,s,i,o,c,u,l,d=r.length();d>=64;){for(a=e.h0,s=e.h1,i=e.h2,o=e.h3,c=e.h4,l=0;l<16;++l)n=r.getInt32(),t[l]=n,u=o^s&(i^o),n=(a<<5|a>>>27)+u+c+1518500249+n,c=o,o=i,i=(s<<30|s>>>2)>>>0,s=a,a=n;for(;l<20;++l)n=t[l-3]^t[l-8]^t[l-14]^t[l-16],n=n<<1|n>>>31,t[l]=n,u=o^s&(i^o),n=(a<<5|a>>>27)+u+c+1518500249+n,c=o,o=i,i=(s<<30|s>>>2)>>>0,s=a,a=n;for(;l<32;++l)n=t[l-3]^t[l-8]^t[l-14]^t[l-16],n=n<<1|n>>>31,t[l]=n,u=s^i^o,n=(a<<5|a>>>27)+u+c+1859775393+n,c=o,o=i,i=(s<<30|s>>>2)>>>0,s=a,a=n;for(;l<40;++l)n=t[l-6]^t[l-16]^t[l-28]^t[l-32],n=n<<2|n>>>30,t[l]=n,u=s^i^o,n=(a<<5|a>>>27)+u+c+1859775393+n,c=o,o=i,i=(s<<30|s>>>2)>>>0,s=a,a=n;for(;l<60;++l)n=t[l-6]^t[l-16]^t[l-28]^t[l-32],n=n<<2|n>>>30,t[l]=n,u=s&i|o&(s^i),n=(a<<5|a>>>27)+u+c+2400959708+n,c=o,o=i,i=(s<<30|s>>>2)>>>0,s=a,a=n;for(;l<80;++l)n=t[l-6]^t[l-16]^t[l-28]^t[l-32],n=n<<2|n>>>30,t[l]=n,u=s^i^o,n=(a<<5|a>>>27)+u+c+3395469782+n,c=o,o=i,i=(s<<30|s>>>2)>>>0,s=a,a=n;e.h0=e.h0+a|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,e.h4=e.h4+c|0,d-=64}}var sn=Ze,wg=sn.pkcs1=sn.pkcs1||{};wg.encode_rsa_oaep=function(e,t,r){var n,a,s,i;typeof r=="string"?(n=r,a=arguments[3]||void 0,s=arguments[4]||void 0):r&&(n=r.label||void 0,a=r.seed||void 0,s=r.md||void 0,r.mgf1&&r.mgf1.md&&(i=r.mgf1.md)),s?s.start():s=sn.md.sha1.create(),i||(i=s);var o=Math.ceil(e.n.bitLength()/8),c=o-2*s.digestLength-2;if(t.length>c){var u=new Error("RSAES-OAEP input message length is too long.");throw u.length=t.length,u.maxLength=c,u}n||(n=""),s.update(n,"raw");for(var l=s.digest(),d="",h=c-t.length,p=0;p<h;p++)d+="\0";var f=l.getBytes()+d+""+t;if(!a)a=sn.random.getBytes(s.digestLength);else if(a.length!==s.digestLength){var u=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw u.seedLength=a.length,u.digestLength=s.digestLength,u}var g=ao(a,o-s.digestLength-1,i),y=sn.util.xorBytes(f,g,f.length),b=ao(y,s.digestLength,i),m=sn.util.xorBytes(a,b,a.length);return"\0"+m+y};wg.decode_rsa_oaep=function(e,t,r){var n,a,s;typeof r=="string"?(n=r,a=arguments[3]||void 0):r&&(n=r.label||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md));var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var o=new Error("RSAES-OAEP encoded message length is invalid.");throw o.length=t.length,o.expectedLength=i,o}if(a===void 0?a=sn.md.sha1.create():a.start(),s||(s=a),i<2*a.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),a.update(n,"raw");for(var c=a.digest().getBytes(),u=t.charAt(0),l=t.substring(1,a.digestLength+1),d=t.substring(1+a.digestLength),h=ao(d,a.digestLength,s),p=sn.util.xorBytes(l,h,l.length),f=ao(p,i-a.digestLength-1,s),g=sn.util.xorBytes(d,f,d.length),y=g.substring(0,a.digestLength),o=u!=="\0",b=0;b<a.digestLength;++b)o|=c.charAt(b)!==y.charAt(b);for(var m=1,v=a.digestLength,S=a.digestLength;S<g.length;S++){var C=g.charCodeAt(S),E=C&1^1,w=m?65534:0;o|=C&w,m=m&E,v+=m}if(o||g.charCodeAt(v)!==1)throw new Error("Invalid RSAES-OAEP padding.");return g.substring(v+1)};function ao(e,t,r){r||(r=sn.md.sha1.create());for(var n="",a=Math.ceil(t/r.digestLength),s=0;s<a;++s){var i=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);r.start(),r.update(e+i),n+=r.digest().getBytes()}return n.substring(0,t)}var Nn=Ze;(function(){if(Nn.prime){Nn.prime;return}var e=Nn.prime=Nn.prime||{},t=Nn.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new t(null);n.fromInt(30);var a=function(d,h){return d|h};e.generateProbablePrime=function(d,h,p){typeof h=="function"&&(p=h,h={}),h=h||{};var f=h.algorithm||"PRIMEINC";typeof f=="string"&&(f={name:f}),f.options=f.options||{};var g=h.prng||Nn.random,y={nextBytes:function(b){for(var m=g.getBytesSync(b.length),v=0;v<b.length;++v)b[v]=m.charCodeAt(v)}};if(f.name==="PRIMEINC")return s(d,y,f.options,p);throw new Error("Invalid prime generation algorithm: "+f.name)};function s(d,h,p,f){return"workers"in p?c(d,h,p,f):i(d,h,p,f)}function i(d,h,p,f){var g=u(d,h),y=0,b=l(g.bitLength());"millerRabinTests"in p&&(b=p.millerRabinTests);var m=10;"maxBlockTime"in p&&(m=p.maxBlockTime),o(g,d,h,y,b,m,f)}function o(d,h,p,f,g,y,b){var m=+new Date;do{if(d.bitLength()>h&&(d=u(h,p)),d.isProbablePrime(g))return b(null,d);d.dAddOffset(r[f++%8],0)}while(y<0||+new Date-m<y);Nn.util.setImmediate(function(){o(d,h,p,f,g,y,b)})}function c(d,h,p,f){if(typeof Worker>"u")return i(d,h,p,f);var g=u(d,h),y=p.workers,b=p.workLoad||100,m=b*30/8,v=p.workerScript||"forge/prime.worker.js";if(y===-1)return Nn.util.estimateCores(function(C,E){C&&(E=2),y=E-1,S()});S();function S(){y=Math.max(1,y);for(var C=[],E=0;E<y;++E)C[E]=new Worker(v);for(var E=0;E<y;++E)C[E].addEventListener("message",_);var w=!1;function _(P){if(!w){var x=P.data;if(x.found){for(var R=0;R<C.length;++R)C[R].terminate();return w=!0,f(null,new t(x.prime,16))}g.bitLength()>d&&(g=u(d,h));var B=g.toString(16);P.target.postMessage({hex:B,workLoad:b}),g.dAddOffset(m,0)}}}}function u(d,h){var p=new t(d,h),f=d-1;return p.testBit(f)||p.bitwiseTo(t.ONE.shiftLeft(f),a,p),p.dAddOffset(31-p.mod(n).byteValue(),0),p}function l(d){return d<=100?27:d<=150?18:d<=200?15:d<=250?12:d<=300?9:d<=350?8:d<=400?7:d<=500?6:d<=600?5:d<=800?4:d<=1250?3:2}})();var Ue=Ze;if(typeof ut>"u")var ut=Ue.jsbn.BigInteger;var Lu=Ue.util.isNodejs?Ro:null,Y=Ue.asn1,Or=Ue.util;Ue.pki=Ue.pki||{};Ue.pki.rsa=Ue.rsa=Ue.rsa||{};var Ve=Ue.pki,J2=[6,4,2,4,2,4,6,2],eb={name:"PrivateKeyInfo",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},tb={name:"RSAPrivateKey",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},rb={name:"RSAPublicKey",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:Y.Class.UNIVERSAL,type:Y.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},nb=Ue.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:Y.Class.UNIVERSAL,type:Y.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},ab={name:"DigestInfo",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:Y.Class.UNIVERSAL,type:Y.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:Y.Class.UNIVERSAL,type:Y.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:Y.Class.UNIVERSAL,type:Y.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},sb=function(e){var t;if(e.algorithm in Ve.oids)t=Ve.oids[e.algorithm];else{var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}var n=Y.oidToDer(t).getBytes(),a=Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[]),s=Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[]);s.value.push(Y.create(Y.Class.UNIVERSAL,Y.Type.OID,!1,n)),s.value.push(Y.create(Y.Class.UNIVERSAL,Y.Type.NULL,!1,""));var i=Y.create(Y.Class.UNIVERSAL,Y.Type.OCTETSTRING,!1,e.digest().getBytes());return a.value.push(s),a.value.push(i),Y.toDer(a).getBytes()},Tg=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||(t.dP=t.d.mod(t.p.subtract(ut.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(ut.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var n;do n=new ut(Ue.util.bytesToHex(Ue.random.getBytes(t.n.bitLength()/8)),16);while(n.compareTo(t.n)>=0||!n.gcd(t.n).equals(ut.ONE));e=e.multiply(n.modPow(t.e,t.n)).mod(t.n);for(var a=e.mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);a.compareTo(s)<0;)a=a.add(t.p);var i=a.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s);return i=i.multiply(n.modInverse(t.n)).mod(t.n),i};Ve.rsa.encrypt=function(e,t,r){var n=r,a,s=Math.ceil(t.n.bitLength()/8);r!==!1&&r!==!0?(n=r===2,a=$g(e,t,r)):(a=Ue.util.createBuffer(),a.putBytes(e));for(var i=new ut(a.toHex(),16),o=Tg(i,t,n),c=o.toString(16),u=Ue.util.createBuffer(),l=s-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(Ue.util.hexToBytes(c)),u.getBytes()};Ve.rsa.decrypt=function(e,t,r,n){var a=Math.ceil(t.n.bitLength()/8);if(e.length!==a){var s=new Error("Encrypted message length is invalid.");throw s.length=e.length,s.expected=a,s}var i=new ut(Ue.util.createBuffer(e).toHex(),16);if(i.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var o=Tg(i,t,r),c=o.toString(16),u=Ue.util.createBuffer(),l=a-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(Ue.util.hexToBytes(c)),n!==!1?so(u.getBytes(),t,r):u.getBytes()};Ve.rsa.createKeyPairGenerationState=function(e,t,r){typeof e=="string"&&(e=parseInt(e,10)),e=e||2048,r=r||{};var n=r.prng||Ue.random,a={nextBytes:function(o){for(var c=n.getBytesSync(o.length),u=0;u<o.length;++u)o[u]=c.charCodeAt(u)}},s=r.algorithm||"PRIMEINC",i;if(s==="PRIMEINC")i={algorithm:s,state:0,bits:e,rng:a,eInt:t||65537,e:new ut(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},i.e.fromInt(i.eInt);else throw new Error("Invalid key generation algorithm: "+s);return i};Ve.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new ut(null);r.fromInt(30);for(var n=0,a=function(d,h){return d|h},s=+new Date,i,o=0;e.keys===null&&(t<=0||o<t);){if(e.state===0){var c=e.p===null?e.pBits:e.qBits,u=c-1;e.pqState===0?(e.num=new ut(c,e.rng),e.num.testBit(u)||e.num.bitwiseTo(ut.ONE.shiftLeft(u),a,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),n=0,++e.pqState):e.pqState===1?e.num.bitLength()>c?e.pqState=0:e.num.isProbablePrime(ob(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(J2[n++%8],0):e.pqState===2?e.pqState=e.num.subtract(ut.ONE).gcd(e.e).compareTo(ut.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(ut.ONE),e.q1=e.q.subtract(ut.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(ut.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var l=e.e.modInverse(e.phi);e.keys={privateKey:Ve.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:Ve.rsa.setPublicKey(e.n,e.e)}}i=+new Date,o+=i-s,s=i}return e.keys!==null};Ve.rsa.generateKeyPair=function(e,t,r,n){if(arguments.length===1?typeof e=="object"?(r=e,e=void 0):typeof e=="function"&&(n=e,e=void 0):arguments.length===2?typeof e=="number"?typeof t=="function"?(n=t,t=void 0):typeof t!="number"&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):arguments.length===3&&(typeof t=="number"?typeof r=="function"&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},e===void 0&&(e=r.bits||2048),t===void 0&&(t=r.e||65537),!Ue.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(n){if(Oh("generateKeyPair"))return Lu.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(o,c,u){if(o)return n(o);n(null,{privateKey:Ve.privateKeyFromPem(u),publicKey:Ve.publicKeyFromPem(c)})});if(Uh("generateKey")&&Uh("exportKey"))return Or.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Mh(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(o){return Or.globalScope.crypto.subtle.exportKey("pkcs8",o.privateKey)}).then(void 0,function(o){n(o)}).then(function(o){if(o){var c=Ve.privateKeyFromAsn1(Y.fromDer(Ue.util.createBuffer(o)));n(null,{privateKey:c,publicKey:Ve.setRsaPublicKey(c.n,c.e)})}});if(Lh("generateKey")&&Lh("exportKey")){var a=Or.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:Mh(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);a.oncomplete=function(o){var c=o.target.result,u=Or.globalScope.msCrypto.subtle.exportKey("pkcs8",c.privateKey);u.oncomplete=function(l){var d=l.target.result,h=Ve.privateKeyFromAsn1(Y.fromDer(Ue.util.createBuffer(d)));n(null,{privateKey:h,publicKey:Ve.setRsaPublicKey(h.n,h.e)})},u.onerror=function(l){n(l)}},a.onerror=function(o){n(o)};return}}else if(Oh("generateKeyPairSync")){var s=Lu.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:Ve.privateKeyFromPem(s.privateKey),publicKey:Ve.publicKeyFromPem(s.publicKey)}}}var i=Ve.rsa.createKeyPairGenerationState(e,t,r);if(!n)return Ve.rsa.stepKeyPairGenerationState(i,0),i.keys;ib(i,r,n)};Ve.setRsaPublicKey=Ve.rsa.setPublicKey=function(e,t){var r={n:e,e:t};return r.encrypt=function(n,a,s){if(typeof a=="string"?a=a.toUpperCase():a===void 0&&(a="RSAES-PKCS1-V1_5"),a==="RSAES-PKCS1-V1_5")a={encode:function(o,c,u){return $g(o,c,2).getBytes()}};else if(a==="RSA-OAEP"||a==="RSAES-OAEP")a={encode:function(o,c){return Ue.pkcs1.encode_rsa_oaep(c,o,s)}};else if(["RAW","NONE","NULL",null].indexOf(a)!==-1)a={encode:function(o){return o}};else if(typeof a=="string")throw new Error('Unsupported encryption scheme: "'+a+'".');var i=a.encode(n,r,!0);return Ve.rsa.encrypt(i,r,!0)},r.verify=function(n,a,s,i){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),i===void 0&&(i={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in i||(i._parseAllDigestBytes=!0),s==="RSASSA-PKCS1-V1_5"?s={verify:function(c,u){u=so(u,r,!0);var l=Y.fromDer(u,{parseAllBytes:i._parseAllDigestBytes}),d={},h=[];if(!Y.validate(l,ab,d,h)){var p=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw p.errors=h,p}var f=Y.derToOid(d.algorithmIdentifier);if(!(f===Ue.oids.md2||f===Ue.oids.md5||f===Ue.oids.sha1||f===Ue.oids.sha224||f===Ue.oids.sha256||f===Ue.oids.sha384||f===Ue.oids.sha512||f===Ue.oids["sha512-224"]||f===Ue.oids["sha512-256"])){var p=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw p.oid=f,p}if((f===Ue.oids.md2||f===Ue.oids.md5)&&!("parameters"in d))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return c===d.digest}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(c,u){return u=so(u,r,!0),c===u}});var o=Ve.rsa.decrypt(a,r,!0,!1);return s.verify(n,o,r.n.bitLength())},r};Ve.setRsaPrivateKey=Ve.rsa.setPrivateKey=function(e,t,r,n,a,s,i,o){var c={n:e,e:t,d:r,p:n,q:a,dP:s,dQ:i,qInv:o};return c.decrypt=function(u,l,d){typeof l=="string"?l=l.toUpperCase():l===void 0&&(l="RSAES-PKCS1-V1_5");var h=Ve.rsa.decrypt(u,c,!1,!1);if(l==="RSAES-PKCS1-V1_5")l={decode:so};else if(l==="RSA-OAEP"||l==="RSAES-OAEP")l={decode:function(p,f){return Ue.pkcs1.decode_rsa_oaep(f,p,d)}};else if(["RAW","NONE","NULL",null].indexOf(l)!==-1)l={decode:function(p){return p}};else throw new Error('Unsupported encryption scheme: "'+l+'".');return l.decode(h,c,!1)},c.sign=function(u,l){var d=!1;typeof l=="string"&&(l=l.toUpperCase()),l===void 0||l==="RSASSA-PKCS1-V1_5"?(l={encode:sb},d=1):(l==="NONE"||l==="NULL"||l===null)&&(l={encode:function(){return u}},d=1);var h=l.encode(u,c.n.bitLength());return Ve.rsa.encrypt(h,c,d)},c};Ve.wrapRsaPrivateKey=function(e){return Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Y.integerToDer(0).getBytes()),Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OID,!1,Y.oidToDer(Ve.oids.rsaEncryption).getBytes()),Y.create(Y.Class.UNIVERSAL,Y.Type.NULL,!1,"")]),Y.create(Y.Class.UNIVERSAL,Y.Type.OCTETSTRING,!1,Y.toDer(e).getBytes())])};Ve.privateKeyFromAsn1=function(e){var t={},r=[];if(Y.validate(e,eb,t,r)&&(e=Y.fromDer(Ue.util.createBuffer(t.privateKey))),t={},r=[],!Y.validate(e,tb,t,r)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=r,n}var a,s,i,o,c,u,l,d;return a=Ue.util.createBuffer(t.privateKeyModulus).toHex(),s=Ue.util.createBuffer(t.privateKeyPublicExponent).toHex(),i=Ue.util.createBuffer(t.privateKeyPrivateExponent).toHex(),o=Ue.util.createBuffer(t.privateKeyPrime1).toHex(),c=Ue.util.createBuffer(t.privateKeyPrime2).toHex(),u=Ue.util.createBuffer(t.privateKeyExponent1).toHex(),l=Ue.util.createBuffer(t.privateKeyExponent2).toHex(),d=Ue.util.createBuffer(t.privateKeyCoefficient).toHex(),Ve.setRsaPrivateKey(new ut(a,16),new ut(s,16),new ut(i,16),new ut(o,16),new ut(c,16),new ut(u,16),new ut(l,16),new ut(d,16))};Ve.privateKeyToAsn1=Ve.privateKeyToRSAPrivateKey=function(e){return Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Y.integerToDer(0).getBytes()),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.n)),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.e)),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.d)),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.p)),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.q)),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.dP)),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.dQ)),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.qInv))])};Ve.publicKeyFromAsn1=function(e){var t={},r=[];if(Y.validate(e,nb,t,r)){var n=Y.derToOid(t.publicKeyOid);if(n!==Ve.oids.rsaEncryption){var a=new Error("Cannot read public key. Unknown OID.");throw a.oid=n,a}e=t.rsaPublicKey}if(r=[],!Y.validate(e,rb,t,r)){var a=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw a.errors=r,a}var s=Ue.util.createBuffer(t.publicKeyModulus).toHex(),i=Ue.util.createBuffer(t.publicKeyExponent).toHex();return Ve.setRsaPublicKey(new ut(s,16),new ut(i,16))};Ve.publicKeyToAsn1=Ve.publicKeyToSubjectPublicKeyInfo=function(e){return Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.OID,!1,Y.oidToDer(Ve.oids.rsaEncryption).getBytes()),Y.create(Y.Class.UNIVERSAL,Y.Type.NULL,!1,"")]),Y.create(Y.Class.UNIVERSAL,Y.Type.BITSTRING,!1,[Ve.publicKeyToRSAPublicKey(e)])])};Ve.publicKeyToRSAPublicKey=function(e){return Y.create(Y.Class.UNIVERSAL,Y.Type.SEQUENCE,!0,[Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.n)),Y.create(Y.Class.UNIVERSAL,Y.Type.INTEGER,!1,Zr(e.e))])};function $g(e,t,r){var n=Ue.util.createBuffer(),a=Math.ceil(t.n.bitLength()/8);if(e.length>a-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=a-11,s}n.putByte(0),n.putByte(r);var i=a-3-e.length,o;if(r===0||r===1){o=r===0?0:255;for(var c=0;c<i;++c)n.putByte(o)}else for(;i>0;){for(var u=0,l=Ue.random.getBytes(i),c=0;c<i;++c)o=l.charCodeAt(c),o===0?++u:n.putByte(o);i=u}return n.putByte(0),n.putBytes(e),n}function so(e,t,r,n){var a=Math.ceil(t.n.bitLength()/8),s=Ue.util.createBuffer(e),i=s.getByte(),o=s.getByte();if(i!==0||r&&o!==0&&o!==1||!r&&o!=2||r&&o===0&&typeof n>"u")throw new Error("Encryption block is invalid.");var c=0;if(o===0){c=a-3-n;for(var u=0;u<c;++u)if(s.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(o===1)for(c=0;s.length()>1;){if(s.getByte()!==255){--s.read;break}++c}else if(o===2)for(c=0;s.length()>1;){if(s.getByte()===0){--s.read;break}++c}var l=s.getByte();if(l!==0||c!==a-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function ib(e,t,r){typeof t=="function"&&(r=t,t={}),t=t||{};var n={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(n.prng=t.prng),a();function a(){s(e.pBits,function(o,c){if(o)return r(o);if(e.p=c,e.q!==null)return i(o,e.q);s(e.qBits,i)})}function s(o,c){Ue.prime.generateProbablePrime(o,n,c)}function i(o,c){if(o)return r(o);if(e.q=c,e.p.compareTo(e.q)<0){var u=e.p;e.p=e.q,e.q=u}if(e.p.subtract(ut.ONE).gcd(e.e).compareTo(ut.ONE)!==0){e.p=null,a();return}if(e.q.subtract(ut.ONE).gcd(e.e).compareTo(ut.ONE)!==0){e.q=null,s(e.qBits,i);return}if(e.p1=e.p.subtract(ut.ONE),e.q1=e.q.subtract(ut.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(ut.ONE)!==0){e.p=e.q=null,a();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,s(e.qBits,i);return}var l=e.e.modInverse(e.phi);e.keys={privateKey:Ve.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:Ve.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}}function Zr(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=Ue.util.hexToBytes(t);return r.length>1&&(r.charCodeAt(0)===0&&!(r.charCodeAt(1)&128)||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)===128)?r.substr(1):r}function ob(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function Oh(e){return Ue.util.isNodejs&&typeof Lu[e]=="function"}function Uh(e){return typeof Or.globalScope<"u"&&typeof Or.globalScope.crypto=="object"&&typeof Or.globalScope.crypto.subtle=="object"&&typeof Or.globalScope.crypto.subtle[e]=="function"}function Lh(e){return typeof Or.globalScope<"u"&&typeof Or.globalScope.msCrypto=="object"&&typeof Or.globalScope.msCrypto.subtle=="object"&&typeof Or.globalScope.msCrypto.subtle[e]=="function"}function Mh(e){for(var t=Ue.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n<t.length;++n)r[n]=t.charCodeAt(n);return r}var Te=Ze;if(typeof cb>"u")var cb=Te.jsbn.BigInteger;var ae=Te.asn1,Qe=Te.pki=Te.pki||{};Qe.pbe=Te.pbe=Te.pbe||{};var oa=Qe.oids,ub={name:"EncryptedPrivateKeyInfo",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:ae.Class.UNIVERSAL,type:ae.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:ae.Class.UNIVERSAL,type:ae.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},lb={name:"PBES2Algorithms",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:ae.Class.UNIVERSAL,type:ae.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:ae.Class.UNIVERSAL,type:ae.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:ae.Class.UNIVERSAL,type:ae.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:ae.Class.UNIVERSAL,type:ae.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:ae.Class.UNIVERSAL,type:ae.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:ae.Class.UNIVERSAL,type:ae.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:ae.Class.UNIVERSAL,type:ae.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},db={name:"pkcs-12PbeParams",tagClass:ae.Class.UNIVERSAL,type:ae.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:ae.Class.UNIVERSAL,type:ae.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:ae.Class.UNIVERSAL,type:ae.Type.INTEGER,constructed:!1,capture:"iterations"}]};Qe.encryptPrivateKeyInfo=function(e,t,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n=Te.random.getBytesSync(r.saltSize),a=r.count,s=ae.integerToDer(a),i,o,c;if(r.algorithm.indexOf("aes")===0||r.algorithm==="des"){var u,l,d;switch(r.algorithm){case"aes128":i=16,u=16,l=oa["aes128-CBC"],d=Te.aes.createEncryptionCipher;break;case"aes192":i=24,u=16,l=oa["aes192-CBC"],d=Te.aes.createEncryptionCipher;break;case"aes256":i=32,u=16,l=oa["aes256-CBC"],d=Te.aes.createEncryptionCipher;break;case"des":i=8,u=8,l=oa.desCBC,d=Te.des.createEncryptionCipher;break;default:var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var p="hmacWith"+r.prfAlgorithm.toUpperCase(),f=Ig(p),g=Te.pkcs5.pbkdf2(t,n,a,i,f),y=Te.random.getBytesSync(u),b=d(g);b.start(y),b.update(ae.toDer(e)),b.finish(),c=b.output.getBytes();var m=hb(n,s,i,p);o=ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[ae.create(ae.Class.UNIVERSAL,ae.Type.OID,!1,ae.oidToDer(oa.pkcs5PBES2).getBytes()),ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[ae.create(ae.Class.UNIVERSAL,ae.Type.OID,!1,ae.oidToDer(oa.pkcs5PBKDF2).getBytes()),m]),ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[ae.create(ae.Class.UNIVERSAL,ae.Type.OID,!1,ae.oidToDer(l).getBytes()),ae.create(ae.Class.UNIVERSAL,ae.Type.OCTETSTRING,!1,y)])])])}else if(r.algorithm==="3des"){i=24;var v=new Te.util.ByteBuffer(n),g=Qe.pbe.generatePkcs12Key(t,v,1,a,i),y=Qe.pbe.generatePkcs12Key(t,v,2,a,i),b=Te.des.createEncryptionCipher(g);b.start(y),b.update(ae.toDer(e)),b.finish(),c=b.output.getBytes(),o=ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[ae.create(ae.Class.UNIVERSAL,ae.Type.OID,!1,ae.oidToDer(oa["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[ae.create(ae.Class.UNIVERSAL,ae.Type.OCTETSTRING,!1,n),ae.create(ae.Class.UNIVERSAL,ae.Type.INTEGER,!1,s.getBytes())])])}else{var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var S=ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[o,ae.create(ae.Class.UNIVERSAL,ae.Type.OCTETSTRING,!1,c)]);return S};Qe.decryptPrivateKeyInfo=function(e,t){var r=null,n={},a=[];if(!ae.validate(e,ub,n,a)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=a,s}var i=ae.derToOid(n.encryptionOid),o=Qe.pbe.getCipher(i,n.encryptionParams,t),c=Te.util.createBuffer(n.encryptedData);return o.update(c),o.finish()&&(r=ae.fromDer(o.output)),r};Qe.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:ae.toDer(e).getBytes()};return Te.pem.encode(r,{maxline:t})};Qe.encryptedPrivateKeyFromPem=function(e){var t=Te.pem.decode(e)[0];if(t.type!=="ENCRYPTED PRIVATE KEY"){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return ae.fromDer(t.body)};Qe.encryptRsaPrivateKey=function(e,t,r){if(r=r||{},!r.legacy){var n=Qe.wrapRsaPrivateKey(Qe.privateKeyToAsn1(e));return n=Qe.encryptPrivateKeyInfo(n,t,r),Qe.encryptedPrivateKeyToPem(n)}var a,s,i,o;switch(r.algorithm){case"aes128":a="AES-128-CBC",i=16,s=Te.random.getBytesSync(16),o=Te.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",i=24,s=Te.random.getBytesSync(16),o=Te.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",i=32,s=Te.random.getBytesSync(16),o=Te.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",i=24,s=Te.random.getBytesSync(8),o=Te.des.createEncryptionCipher;break;case"des":a="DES-CBC",i=8,s=Te.random.getBytesSync(8),o=Te.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=Te.pbe.opensslDeriveBytes(t,s.substr(0,8),i),l=o(u);l.start(s),l.update(ae.toDer(Qe.privateKeyToAsn1(e))),l.finish();var d={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:Te.util.bytesToHex(s).toUpperCase()},body:l.output.getBytes()};return Te.pem.encode(d)};Qe.decryptRsaPrivateKey=function(e,t){var r=null,n=Te.pem.decode(e)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var a=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw a.headerType=a,a}if(n.procType&&n.procType.type==="ENCRYPTED"){var s,i;switch(n.dekInfo.algorithm){case"DES-CBC":s=8,i=Te.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,i=Te.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,i=Te.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,i=Te.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,i=Te.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,i=function(d){return Te.rc2.createDecryptionCipher(d,40)};break;case"RC2-64-CBC":s=8,i=function(d){return Te.rc2.createDecryptionCipher(d,64)};break;case"RC2-128-CBC":s=16,i=function(d){return Te.rc2.createDecryptionCipher(d,128)};break;default:var a=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw a.algorithm=n.dekInfo.algorithm,a}var o=Te.util.hexToBytes(n.dekInfo.parameters),c=Te.pbe.opensslDeriveBytes(t,o.substr(0,8),s),u=i(c);if(u.start(o),u.update(Te.util.createBuffer(n.body)),u.finish())r=u.output.getBytes();else return r}else r=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?r=Qe.decryptPrivateKeyInfo(ae.fromDer(r),t):r=ae.fromDer(r),r!==null&&(r=Qe.privateKeyFromAsn1(r)),r};Qe.pbe.generatePkcs12Key=function(e,t,r,n,a,s){var i,o;if(typeof s>"u"||s===null){if(!("sha1"in Te.md))throw new Error('"sha1" hash algorithm unavailable.');s=Te.md.sha1.create()}var c=s.digestLength,u=s.blockLength,l=new Te.util.ByteBuffer,d=new Te.util.ByteBuffer;if(e!=null){for(o=0;o<e.length;o++)d.putInt16(e.charCodeAt(o));d.putInt16(0)}var h=d.length(),p=t.length(),f=new Te.util.ByteBuffer;f.fillWithByte(r,u);var g=u*Math.ceil(p/u),y=new Te.util.ByteBuffer;for(o=0;o<g;o++)y.putByte(t.at(o%p));var b=u*Math.ceil(h/u),m=new Te.util.ByteBuffer;for(o=0;o<b;o++)m.putByte(d.at(o%h));var v=y;v.putBuffer(m);for(var S=Math.ceil(a/c),C=1;C<=S;C++){var E=new Te.util.ByteBuffer;E.putBytes(f.bytes()),E.putBytes(v.bytes());for(var w=0;w<n;w++)s.start(),s.update(E.getBytes()),E=s.digest();var _=new Te.util.ByteBuffer;for(o=0;o<u;o++)_.putByte(E.at(o%c));var P=Math.ceil(p/u)+Math.ceil(h/u),x=new Te.util.ByteBuffer;for(i=0;i<P;i++){var R=new Te.util.ByteBuffer(v.getBytes(u)),B=511;for(o=_.length()-1;o>=0;o--)B=B>>8,B+=_.at(o)+R.at(o),R.setAt(o,B&255);x.putBuffer(R)}v=x,l.putBuffer(E)}return l.truncate(l.length()-a),l};Qe.pbe.getCipher=function(e,t,r){switch(e){case Qe.oids.pkcs5PBES2:return Qe.pbe.getCipherForPBES2(e,t,r);case Qe.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case Qe.oids["pbewithSHAAnd40BitRC2-CBC"]:return Qe.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};Qe.pbe.getCipherForPBES2=function(e,t,r){var n={},a=[];if(!ae.validate(t,lb,n,a)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=a,s}if(e=ae.derToOid(n.kdfOid),e!==Qe.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=e,s.supportedOids=["pkcs5PBKDF2"],s}if(e=ae.derToOid(n.encOid),e!==Qe.oids["aes128-CBC"]&&e!==Qe.oids["aes192-CBC"]&&e!==Qe.oids["aes256-CBC"]&&e!==Qe.oids["des-EDE3-CBC"]&&e!==Qe.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=e,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var i=n.kdfSalt,o=Te.util.createBuffer(n.kdfIterationCount);o=o.getInt(o.length()<<3);var c,u;switch(Qe.oids[e]){case"aes128-CBC":c=16,u=Te.aes.createDecryptionCipher;break;case"aes192-CBC":c=24,u=Te.aes.createDecryptionCipher;break;case"aes256-CBC":c=32,u=Te.aes.createDecryptionCipher;break;case"des-EDE3-CBC":c=24,u=Te.des.createDecryptionCipher;break;case"desCBC":c=8,u=Te.des.createDecryptionCipher;break}var l=Ag(n.prfOid),d=Te.pkcs5.pbkdf2(r,i,o,c,l),h=n.encIv,p=u(d);return p.start(h),p};Qe.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},a=[];if(!ae.validate(t,db,n,a)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=a,s}var i=Te.util.createBuffer(n.salt),o=Te.util.createBuffer(n.iterations);o=o.getInt(o.length()<<3);var c,u,l;switch(e){case Qe.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,l=Te.des.startDecrypting;break;case Qe.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,l=function(g,y){var b=Te.rc2.createDecryptionCipher(g,40);return b.start(y,null),b};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=e,s}var d=Ag(n.prfOid),h=Qe.pbe.generatePkcs12Key(r,i,1,o,c,d);d.start();var p=Qe.pbe.generatePkcs12Key(r,i,2,o,u,d);return l(h,p)};Qe.pbe.opensslDeriveBytes=function(e,t,r,n){if(typeof n>"u"||n===null){if(!("md5"in Te.md))throw new Error('"md5" hash algorithm unavailable.');n=Te.md.md5.create()}t===null&&(t="");for(var a=[jh(n,e+t)],s=16,i=1;s<r;++i,s+=16)a.push(jh(n,a[i-1]+e+t));return a.join("").substr(0,r)};function jh(e,t){return e.start().update(t).digest().getBytes()}function Ag(e){var t;if(!e)t="hmacWithSHA1";else if(t=Qe.oids[ae.derToOid(e)],!t){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}return Ig(t)}function Ig(e){var t=Te.md;switch(e){case"hmacWithSHA224":t=Te.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}function hb(e,t,r,n){var a=ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[ae.create(ae.Class.UNIVERSAL,ae.Type.OCTETSTRING,!1,e),ae.create(ae.Class.UNIVERSAL,ae.Type.INTEGER,!1,t.getBytes())]);return n!=="hmacWithSHA1"&&a.value.push(ae.create(ae.Class.UNIVERSAL,ae.Type.INTEGER,!1,Te.util.hexToBytes(r.toString(16))),ae.create(ae.Class.UNIVERSAL,ae.Type.SEQUENCE,!0,[ae.create(ae.Class.UNIVERSAL,ae.Type.OID,!1,ae.oidToDer(Qe.oids[n]).getBytes()),ae.create(ae.Class.UNIVERSAL,ae.Type.NULL,!1,"")])),a}var Ja=Ze,Ee=Ja.asn1,ps=Ja.pkcs7asn1=Ja.pkcs7asn1||{};Ja.pkcs7=Ja.pkcs7||{};Ja.pkcs7.asn1=ps;var Pg={name:"ContentInfo",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:Ee.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};ps.contentInfoValidator=Pg;var _g={name:"EncryptedContentInfo",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:Ee.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:Ee.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};ps.envelopedDataValidator={name:"EnvelopedData",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(_g)};ps.encryptedDataValidator={name:"EncryptedData",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.INTEGER,constructed:!1,capture:"version"}].concat(_g)};var pb={name:"SignerInfo",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:Ee.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:Ee.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:Ee.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};ps.signedDataValidator={name:"SignedData",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},Pg,{name:"SignedData.Certificates",tagClass:Ee.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:Ee.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SET,capture:"signerInfos",optional:!0,value:[pb]}]};ps.recipientInfoValidator={name:"RecipientInfo",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:Ee.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:Ee.Class.UNIVERSAL,type:Ee.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]};var ga=Ze;ga.mgf=ga.mgf||{};var fb=ga.mgf.mgf1=ga.mgf1=ga.mgf1||{};fb.create=function(e){var t={generate:function(r,n){for(var a=new ga.util.ByteBuffer,s=Math.ceil(n/e.digestLength),i=0;i<s;i++){var o=new ga.util.ByteBuffer;o.putInt32(i),e.start(),e.update(r+o.getBytes()),a.putBuffer(e.digest())}return a.truncate(a.length()-n),a.getBytes()}};return t};var io=Ze;io.mgf=io.mgf||{};io.mgf.mgf1=io.mgf1;var ua=Ze,gb=ua.pss=ua.pss||{};gb.create=function(e){arguments.length===3&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t=e.md,r=e.mgf,n=t.digestLength,a=e.salt||null;typeof a=="string"&&(a=ua.util.createBuffer(a));var s;if("saltLength"in e)s=e.saltLength;else if(a!==null)s=a.length();else throw new Error("Salt length not specified or specific salt not given.");if(a!==null&&a.length()!==s)throw new Error("Given salt length does not match length of given salt.");var i=e.prng||ua.random,o={};return o.encode=function(c,u){var l,d=u-1,h=Math.ceil(d/8),p=c.digest().getBytes();if(h<n+s+2)throw new Error("Message is too long to encrypt.");var f;a===null?f=i.getBytesSync(s):f=a.bytes();var g=new ua.util.ByteBuffer;g.fillWithByte(0,8),g.putBytes(p),g.putBytes(f),t.start(),t.update(g.getBytes());var y=t.digest().getBytes(),b=new ua.util.ByteBuffer;b.fillWithByte(0,h-s-n-2),b.putByte(1),b.putBytes(f);var m=b.getBytes(),v=h-n-1,S=r.generate(y,v),C="";for(l=0;l<v;l++)C+=String.fromCharCode(m.charCodeAt(l)^S.charCodeAt(l));var E=65280>>8*h-d&255;return C=String.fromCharCode(C.charCodeAt(0)&~E)+C.substr(1),C+y+"¼"},o.verify=function(c,u,l){var d,h=l-1,p=Math.ceil(h/8);if(u=u.substr(-p),p<n+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(u.charCodeAt(p-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var f=p-n-1,g=u.substr(0,f),y=u.substr(f,n),b=65280>>8*p-h&255;if(g.charCodeAt(0)&b)throw new Error("Bits beyond keysize not zero as expected.");var m=r.generate(y,f),v="";for(d=0;d<f;d++)v+=String.fromCharCode(g.charCodeAt(d)^m.charCodeAt(d));v=String.fromCharCode(v.charCodeAt(0)&~b)+v.substr(1);var S=p-n-s-2;for(d=0;d<S;d++)if(v.charCodeAt(d)!==0)throw new Error("Leftmost octets not zero as expected");if(v.charCodeAt(S)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var C=v.substr(-s),E=new ua.util.ByteBuffer;E.fillWithByte(0,8),E.putBytes(c),E.putBytes(C),t.start(),t.update(E.getBytes());var w=t.digest().getBytes();return y===w},o};var Le=Ze,T=Le.asn1,fe=Le.pki=Le.pki||{},st=fe.oids,Mt={};Mt.CN=st.commonName;Mt.commonName="CN";Mt.C=st.countryName;Mt.countryName="C";Mt.L=st.localityName;Mt.localityName="L";Mt.ST=st.stateOrProvinceName;Mt.stateOrProvinceName="ST";Mt.O=st.organizationName;Mt.organizationName="O";Mt.OU=st.organizationalUnitName;Mt.organizationalUnitName="OU";Mt.E=st.emailAddress;Mt.emailAddress="E";var Dg=Le.pki.rsa.publicKeyValidator,mb={name:"Certificate",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:T.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:T.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:T.Class.UNIVERSAL,type:T.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:T.Class.UNIVERSAL,type:T.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:T.Class.UNIVERSAL,type:T.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:T.Class.UNIVERSAL,type:T.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},Dg,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:T.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:T.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:T.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:T.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},yb={name:"rsapss",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:T.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:T.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:T.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:T.Class.UNIVERSAL,type:T.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:T.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:T.Class.UNIVERSAL,type:T.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},vb={name:"CertificationRequestInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},Dg,{name:"CertificationRequestInfo.attributes",tagClass:T.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:T.Class.UNIVERSAL,type:T.Type.SET,constructed:!0}]}]}]},bb={name:"CertificationRequest",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[vb,{name:"CertificationRequest.signatureAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:T.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};fe.RDNAttributesAsArray=function(e,t){for(var r=[],n,a,s,i=0;i<e.value.length;++i){n=e.value[i];for(var o=0;o<n.value.length;++o)s={},a=n.value[o],s.type=T.derToOid(a.value[0].value),s.value=a.value[1].value,s.valueTagClass=a.value[1].type,s.type in st&&(s.name=st[s.type],s.name in Mt&&(s.shortName=Mt[s.name])),t&&(t.update(s.type),t.update(s.value)),r.push(s)}return r};fe.CRIAttributesAsArray=function(e){for(var t=[],r=0;r<e.length;++r)for(var n=e[r],a=T.derToOid(n.value[0].value),s=n.value[1].value,i=0;i<s.length;++i){var o={};if(o.type=a,o.value=s[i].value,o.valueTagClass=s[i].type,o.type in st&&(o.name=st[o.type],o.name in Mt&&(o.shortName=Mt[o.name])),o.type===st.extensionRequest){o.extensions=[];for(var c=0;c<o.value.length;++c)o.extensions.push(fe.certificateExtensionFromAsn1(o.value[c]))}t.push(o)}return t};function Wn(e,t){typeof t=="string"&&(t={shortName:t});for(var r=null,n,a=0;r===null&&a<e.attributes.length;++a)n=e.attributes[a],(t.type&&t.type===n.type||t.name&&t.name===n.name||t.shortName&&t.shortName===n.shortName)&&(r=n);return r}var oo=function(e,t,r){var n={};if(e!==st["RSASSA-PSS"])return n;r&&(n={hash:{algorithmOid:st.sha1},mgf:{algorithmOid:st.mgf1,hash:{algorithmOid:st.sha1}},saltLength:20});var a={},s=[];if(!T.validate(t,yb,a,s)){var i=new Error("Cannot read RSASSA-PSS parameter block.");throw i.errors=s,i}return a.hashOid!==void 0&&(n.hash=n.hash||{},n.hash.algorithmOid=T.derToOid(a.hashOid)),a.maskGenOid!==void 0&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=T.derToOid(a.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=T.derToOid(a.maskGenHashOid)),a.saltLength!==void 0&&(n.saltLength=a.saltLength.charCodeAt(0)),n},jo=function(e){switch(st[e.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return Le.md.sha1.create();case"md5WithRSAEncryption":return Le.md.md5.create();case"sha256WithRSAEncryption":return Le.md.sha256.create();case"sha384WithRSAEncryption":return Le.md.sha384.create();case"sha512WithRSAEncryption":return Le.md.sha512.create();case"RSASSA-PSS":return Le.md.sha256.create();default:var t=new Error("Could not compute "+e.type+" digest. Unknown signature OID.");throw t.signatureOid=e.signatureOid,t}},Rg=function(e){var t=e.certificate,r;switch(t.signatureOid){case st.sha1WithRSAEncryption:case st.sha1WithRSASignature:break;case st["RSASSA-PSS"]:var n,a;if(n=st[t.signatureParameters.mgf.hash.algorithmOid],n===void 0||Le.md[n]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=t.signatureParameters.mgf.hash.algorithmOid,s.name=n,s}if(a=st[t.signatureParameters.mgf.algorithmOid],a===void 0||Le.mgf[a]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=t.signatureParameters.mgf.algorithmOid,s.name=a,s}if(a=Le.mgf[a].create(Le.md[n].create()),n=st[t.signatureParameters.hash.algorithmOid],n===void 0||Le.md[n]===void 0){var s=new Error("Unsupported RSASSA-PSS hash function.");throw s.oid=t.signatureParameters.hash.algorithmOid,s.name=n,s}r=Le.pss.create(Le.md[n].create(),a,t.signatureParameters.saltLength);break}return t.publicKey.verify(e.md.digest().getBytes(),e.signature,r)};fe.certificateFromPem=function(e,t,r){var n=Le.pem.decode(e)[0];if(n.type!=="CERTIFICATE"&&n.type!=="X509 CERTIFICATE"&&n.type!=="TRUSTED CERTIFICATE"){var a=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw a.headerType=n.type,a}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=T.fromDer(n.body,r);return fe.certificateFromAsn1(s,t)};fe.certificateToPem=function(e,t){var r={type:"CERTIFICATE",body:T.toDer(fe.certificateToAsn1(e)).getBytes()};return Le.pem.encode(r,{maxline:t})};fe.publicKeyFromPem=function(e){var t=Le.pem.decode(e)[0];if(t.type!=="PUBLIC KEY"&&t.type!=="RSA PUBLIC KEY"){var r=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw r.headerType=t.type,r}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var n=T.fromDer(t.body);return fe.publicKeyFromAsn1(n)};fe.publicKeyToPem=function(e,t){var r={type:"PUBLIC KEY",body:T.toDer(fe.publicKeyToAsn1(e)).getBytes()};return Le.pem.encode(r,{maxline:t})};fe.publicKeyToRSAPublicKeyPem=function(e,t){var r={type:"RSA PUBLIC KEY",body:T.toDer(fe.publicKeyToRSAPublicKey(e)).getBytes()};return Le.pem.encode(r,{maxline:t})};fe.getPublicKeyFingerprint=function(e,t){t=t||{};var r=t.md||Le.md.sha1.create(),n=t.type||"RSAPublicKey",a;switch(n){case"RSAPublicKey":a=T.toDer(fe.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":a=T.toDer(fe.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+t.type+'".')}r.start(),r.update(a);var s=r.digest();if(t.encoding==="hex"){var i=s.toHex();return t.delimiter?i.match(/.{2}/g).join(t.delimiter):i}else{if(t.encoding==="binary")return s.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return s};fe.certificationRequestFromPem=function(e,t,r){var n=Le.pem.decode(e)[0];if(n.type!=="CERTIFICATE REQUEST"){var a=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw a.headerType=n.type,a}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=T.fromDer(n.body,r);return fe.certificationRequestFromAsn1(s,t)};fe.certificationRequestToPem=function(e,t){var r={type:"CERTIFICATE REQUEST",body:T.toDer(fe.certificationRequestToAsn1(e)).getBytes()};return Le.pem.encode(r,{maxline:t})};fe.createCertificate=function(){var e={};return e.version=2,e.serialNumber="00",e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return Wn(e.issuer,t)},e.issuer.addField=function(t){Ur([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return Wn(e.subject,t)},e.subject.addField=function(t){Ur([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,r){Ur(t),e.subject.attributes=t,delete e.subject.uniqueId,r&&(e.subject.uniqueId=r),e.subject.hash=null},e.setIssuer=function(t,r){Ur(t),e.issuer.attributes=t,delete e.issuer.uniqueId,r&&(e.issuer.uniqueId=r),e.issuer.hash=null},e.setExtensions=function(t){for(var r=0;r<t.length;++r)Ng(t[r],{cert:e});e.extensions=t},e.getExtension=function(t){typeof t=="string"&&(t={name:t});for(var r=null,n,a=0;r===null&&a<e.extensions.length;++a)n=e.extensions[a],(t.id&&n.id===t.id||t.name&&n.name===t.name)&&(r=n);return r},e.sign=function(t,r){e.md=r||Le.md.sha1.create();var n=st[e.md.algorithm+"WithRSAEncryption"];if(!n){var a=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw a.algorithm=e.md.algorithm,a}e.signatureOid=e.siginfo.algorithmOid=n,e.tbsCertificate=fe.getTBSCertificate(e);var s=T.toDer(e.tbsCertificate);e.md.update(s.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var r=!1;if(!e.issued(t)){var n=t.issuer,a=e.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=a.attributes,s.actualIssuer=n.attributes,s}var i=t.md;if(i===null){i=jo({signatureOid:t.signatureOid,type:"certificate"});var o=t.tbsCertificate||fe.getTBSCertificate(t),c=T.toDer(o);i.update(c.getBytes())}return i!==null&&(r=Rg({certificate:e,md:i,signature:t.signature})),r},e.isIssuer=function(t){var r=!1,n=e.issuer,a=t.subject;if(n.hash&&a.hash)r=n.hash===a.hash;else if(n.attributes.length===a.attributes.length){r=!0;for(var s,i,o=0;r&&o<n.attributes.length;++o)s=n.attributes[o],i=a.attributes[o],(s.type!==i.type||s.value!==i.value)&&(r=!1)}return r},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return fe.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=st.subjectKeyIdentifier,r=0;r<e.extensions.length;++r){var n=e.extensions[r];if(n.id===t){var a=e.generateSubjectKeyIdentifier().getBytes();return Le.util.hexToBytes(n.subjectKeyIdentifier)===a}}return!1},e};fe.certificateFromAsn1=function(e,t){var r={},n=[];if(!T.validate(e,mb,r,n)){var a=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw a.errors=n,a}var s=T.derToOid(r.publicKeyOid);if(s!==fe.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=fe.createCertificate();i.version=r.certVersion?r.certVersion.charCodeAt(0):0;var o=Le.util.createBuffer(r.certSerialNumber);i.serialNumber=o.toHex(),i.signatureOid=Le.asn1.derToOid(r.certSignatureOid),i.signatureParameters=oo(i.signatureOid,r.certSignatureParams,!0),i.siginfo.algorithmOid=Le.asn1.derToOid(r.certinfoSignatureOid),i.siginfo.parameters=oo(i.siginfo.algorithmOid,r.certinfoSignatureParams,!1),i.signature=r.certSignature;var c=[];if(r.certValidity1UTCTime!==void 0&&c.push(T.utcTimeToDate(r.certValidity1UTCTime)),r.certValidity2GeneralizedTime!==void 0&&c.push(T.generalizedTimeToDate(r.certValidity2GeneralizedTime)),r.certValidity3UTCTime!==void 0&&c.push(T.utcTimeToDate(r.certValidity3UTCTime)),r.certValidity4GeneralizedTime!==void 0&&c.push(T.generalizedTimeToDate(r.certValidity4GeneralizedTime)),c.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(c.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(i.validity.notBefore=c[0],i.validity.notAfter=c[1],i.tbsCertificate=r.tbsCertificate,t){i.md=jo({signatureOid:i.signatureOid,type:"certificate"});var u=T.toDer(i.tbsCertificate);i.md.update(u.getBytes())}var l=Le.md.sha1.create(),d=T.toDer(r.certIssuer);l.update(d.getBytes()),i.issuer.getField=function(f){return Wn(i.issuer,f)},i.issuer.addField=function(f){Ur([f]),i.issuer.attributes.push(f)},i.issuer.attributes=fe.RDNAttributesAsArray(r.certIssuer),r.certIssuerUniqueId&&(i.issuer.uniqueId=r.certIssuerUniqueId),i.issuer.hash=l.digest().toHex();var h=Le.md.sha1.create(),p=T.toDer(r.certSubject);return h.update(p.getBytes()),i.subject.getField=function(f){return Wn(i.subject,f)},i.subject.addField=function(f){Ur([f]),i.subject.attributes.push(f)},i.subject.attributes=fe.RDNAttributesAsArray(r.certSubject),r.certSubjectUniqueId&&(i.subject.uniqueId=r.certSubjectUniqueId),i.subject.hash=h.digest().toHex(),r.certExtensions?i.extensions=fe.certificateExtensionsFromAsn1(r.certExtensions):i.extensions=[],i.publicKey=fe.publicKeyFromAsn1(r.subjectPublicKeyInfo),i};fe.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r<e.value.length;++r)for(var n=e.value[r],a=0;a<n.value.length;++a)t.push(fe.certificateExtensionFromAsn1(n.value[a]));return t};fe.certificateExtensionFromAsn1=function(e){var t={};if(t.id=T.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===T.Type.BOOLEAN?(t.critical=e.value[1].value.charCodeAt(0)!==0,t.value=e.value[2].value):t.value=e.value[1].value,t.id in st){if(t.name=st[t.id],t.name==="keyUsage"){var r=T.fromDer(t.value),n=0,a=0;r.value.length>1&&(n=r.value.charCodeAt(1),a=r.value.length>2?r.value.charCodeAt(2):0),t.digitalSignature=(n&128)===128,t.nonRepudiation=(n&64)===64,t.keyEncipherment=(n&32)===32,t.dataEncipherment=(n&16)===16,t.keyAgreement=(n&8)===8,t.keyCertSign=(n&4)===4,t.cRLSign=(n&2)===2,t.encipherOnly=(n&1)===1,t.decipherOnly=(a&128)===128}else if(t.name==="basicConstraints"){var r=T.fromDer(t.value);r.value.length>0&&r.value[0].type===T.Type.BOOLEAN?t.cA=r.value[0].value.charCodeAt(0)!==0:t.cA=!1;var s=null;r.value.length>0&&r.value[0].type===T.Type.INTEGER?s=r.value[0].value:r.value.length>1&&(s=r.value[1].value),s!==null&&(t.pathLenConstraint=T.derToInteger(s))}else if(t.name==="extKeyUsage")for(var r=T.fromDer(t.value),i=0;i<r.value.length;++i){var o=T.derToOid(r.value[i].value);o in st?t[st[o]]=!0:t[o]=!0}else if(t.name==="nsCertType"){var r=T.fromDer(t.value),n=0;r.value.length>1&&(n=r.value.charCodeAt(1)),t.client=(n&128)===128,t.server=(n&64)===64,t.email=(n&32)===32,t.objsign=(n&16)===16,t.reserved=(n&8)===8,t.sslCA=(n&4)===4,t.emailCA=(n&2)===2,t.objCA=(n&1)===1}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.altNames=[];for(var c,r=T.fromDer(t.value),u=0;u<r.value.length;++u){c=r.value[u];var l={type:c.type,value:c.value};switch(t.altNames.push(l),c.type){case 1:case 2:case 6:break;case 7:l.ip=Le.util.bytesToIP(c.value);break;case 8:l.oid=T.derToOid(c.value);break}}}else if(t.name==="subjectKeyIdentifier"){var r=T.fromDer(t.value);t.subjectKeyIdentifier=Le.util.bytesToHex(r.value)}}return t};fe.certificationRequestFromAsn1=function(e,t){var r={},n=[];if(!T.validate(e,bb,r,n)){var a=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw a.errors=n,a}var s=T.derToOid(r.publicKeyOid);if(s!==fe.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=fe.createCertificationRequest();if(i.version=r.csrVersion?r.csrVersion.charCodeAt(0):0,i.signatureOid=Le.asn1.derToOid(r.csrSignatureOid),i.signatureParameters=oo(i.signatureOid,r.csrSignatureParams,!0),i.siginfo.algorithmOid=Le.asn1.derToOid(r.csrSignatureOid),i.siginfo.parameters=oo(i.siginfo.algorithmOid,r.csrSignatureParams,!1),i.signature=r.csrSignature,i.certificationRequestInfo=r.certificationRequestInfo,t){i.md=jo({signatureOid:i.signatureOid,type:"certification request"});var o=T.toDer(i.certificationRequestInfo);i.md.update(o.getBytes())}var c=Le.md.sha1.create();return i.subject.getField=function(u){return Wn(i.subject,u)},i.subject.addField=function(u){Ur([u]),i.subject.attributes.push(u)},i.subject.attributes=fe.RDNAttributesAsArray(r.certificationRequestInfoSubject,c),i.subject.hash=c.digest().toHex(),i.publicKey=fe.publicKeyFromAsn1(r.subjectPublicKeyInfo),i.getAttribute=function(u){return Wn(i,u)},i.addAttribute=function(u){Ur([u]),i.attributes.push(u)},i.attributes=fe.CRIAttributesAsArray(r.certificationRequestInfoAttributes||[]),i};fe.createCertificationRequest=function(){var e={};return e.version=0,e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return Wn(e.subject,t)},e.subject.addField=function(t){Ur([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return Wn(e,t)},e.addAttribute=function(t){Ur([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){Ur(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){Ur(t),e.attributes=t},e.sign=function(t,r){e.md=r||Le.md.sha1.create();var n=st[e.md.algorithm+"WithRSAEncryption"];if(!n){var a=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw a.algorithm=e.md.algorithm,a}e.signatureOid=e.siginfo.algorithmOid=n,e.certificationRequestInfo=fe.getCertificationRequestInfo(e);var s=T.toDer(e.certificationRequestInfo);e.md.update(s.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,r=e.md;if(r===null){r=jo({signatureOid:e.signatureOid,type:"certification request"});var n=e.certificationRequestInfo||fe.getCertificationRequestInfo(e),a=T.toDer(n);r.update(a.getBytes())}return r!==null&&(t=Rg({certificate:e,md:r,signature:e.signature})),t},e};function es(e){for(var t=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),r,n,a=e.attributes,s=0;s<a.length;++s){r=a[s];var i=r.value,o=T.Type.PRINTABLESTRING;"valueTagClass"in r&&(o=r.valueTagClass,o===T.Type.UTF8&&(i=Le.util.encodeUtf8(i))),n=T.create(T.Class.UNIVERSAL,T.Type.SET,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(r.type).getBytes()),T.create(T.Class.UNIVERSAL,o,!1,i)])]),t.value.push(n)}return t}function Ur(e){for(var t,r=0;r<e.length;++r){if(t=e[r],typeof t.name>"u"&&(t.type&&t.type in fe.oids?t.name=fe.oids[t.type]:t.shortName&&t.shortName in Mt&&(t.name=fe.oids[Mt[t.shortName]])),typeof t.type>"u")if(t.name&&t.name in fe.oids)t.type=fe.oids[t.name];else{var n=new Error("Attribute type not specified.");throw n.attribute=t,n}if(typeof t.shortName>"u"&&t.name&&t.name in Mt&&(t.shortName=Mt[t.name]),t.type===st.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=T.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var a=0;a<t.extensions.length;++a)t.value.push(fe.certificateExtensionToAsn1(Ng(t.extensions[a])))}if(typeof t.value>"u"){var n=new Error("Attribute value not specified.");throw n.attribute=t,n}}}function Ng(e,t){if(t=t||{},typeof e.name>"u"&&e.id&&e.id in fe.oids&&(e.name=fe.oids[e.id]),typeof e.id>"u")if(e.name&&e.name in fe.oids)e.id=fe.oids[e.name];else{var r=new Error("Extension ID not specified.");throw r.extension=e,r}if(typeof e.value<"u")return e;if(e.name==="keyUsage"){var n=0,a=0,s=0;e.digitalSignature&&(a|=128,n=7),e.nonRepudiation&&(a|=64,n=6),e.keyEncipherment&&(a|=32,n=5),e.dataEncipherment&&(a|=16,n=4),e.keyAgreement&&(a|=8,n=3),e.keyCertSign&&(a|=4,n=2),e.cRLSign&&(a|=2,n=1),e.encipherOnly&&(a|=1,n=0),e.decipherOnly&&(s|=128,n=7);var i=String.fromCharCode(n);s!==0?i+=String.fromCharCode(a)+String.fromCharCode(s):a!==0&&(i+=String.fromCharCode(a)),e.value=T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,i)}else if(e.name==="basicConstraints")e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(T.create(T.Class.UNIVERSAL,T.Type.BOOLEAN,!1,"ÿ")),"pathLenConstraint"in e&&e.value.value.push(T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(e.pathLenConstraint).getBytes()));else if(e.name==="extKeyUsage"){e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);var o=e.value.value;for(var c in e)e[c]===!0&&(c in st?o.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(st[c]).getBytes())):c.indexOf(".")!==-1&&o.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(c).getBytes())))}else if(e.name==="nsCertType"){var n=0,a=0;e.client&&(a|=128,n=7),e.server&&(a|=64,n=6),e.email&&(a|=32,n=5),e.objsign&&(a|=16,n=4),e.reserved&&(a|=8,n=3),e.sslCA&&(a|=4,n=2),e.emailCA&&(a|=2,n=1),e.objCA&&(a|=1,n=0);var i=String.fromCharCode(n);a!==0&&(i+=String.fromCharCode(a)),e.value=T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,i)}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);for(var u,l=0;l<e.altNames.length;++l){u=e.altNames[l];var i=u.value;if(u.type===7&&u.ip){if(i=Le.util.bytesFromIP(u.ip),i===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=e,r}}else u.type===8&&(u.oid?i=T.oidToDer(T.oidToDer(u.oid)):i=T.oidToDer(i));e.value.value.push(T.create(T.Class.CONTEXT_SPECIFIC,u.type,!1,i))}}else if(e.name==="nsComment"&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=T.create(T.Class.UNIVERSAL,T.Type.IA5STRING,!1,e.comment)}else if(e.name==="subjectKeyIdentifier"&&t.cert){var d=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=d.toHex(),e.value=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,d.getBytes())}else if(e.name==="authorityKeyIdentifier"&&t.cert){e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);var o=e.value.value;if(e.keyIdentifier){var h=e.keyIdentifier===!0?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;o.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!1,h))}if(e.authorityCertIssuer){var p=[T.create(T.Class.CONTEXT_SPECIFIC,4,!0,[es(e.authorityCertIssuer===!0?t.cert.issuer:e.authorityCertIssuer)])];o.push(T.create(T.Class.CONTEXT_SPECIFIC,1,!0,p))}if(e.serialNumber){var f=Le.util.hexToBytes(e.serialNumber===!0?t.cert.serialNumber:e.serialNumber);o.push(T.create(T.Class.CONTEXT_SPECIFIC,2,!1,f))}}else if(e.name==="cRLDistributionPoints"){e.value=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);for(var o=e.value.value,g=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),y=T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[]),u,l=0;l<e.altNames.length;++l){u=e.altNames[l];var i=u.value;if(u.type===7&&u.ip){if(i=Le.util.bytesFromIP(u.ip),i===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=e,r}}else u.type===8&&(u.oid?i=T.oidToDer(T.oidToDer(u.oid)):i=T.oidToDer(i));y.value.push(T.create(T.Class.CONTEXT_SPECIFIC,u.type,!1,i))}g.value.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[y])),o.push(g)}if(typeof e.value>"u"){var r=new Error("Extension value not specified.");throw r.extension=e,r}return e}function Fd(e,t){switch(e){case st["RSASSA-PSS"]:var r=[];return t.hash.algorithmOid!==void 0&&r.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.hash.algorithmOid).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")])])),t.mgf.algorithmOid!==void 0&&r.push(T.create(T.Class.CONTEXT_SPECIFIC,1,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.mgf.algorithmOid).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.mgf.hash.algorithmOid).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")])])])),t.saltLength!==void 0&&r.push(T.create(T.Class.CONTEXT_SPECIFIC,2,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.saltLength).getBytes())])),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,r);default:return T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")}}function Cb(e){var t=T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[]);if(e.attributes.length===0)return t;for(var r=e.attributes,n=0;n<r.length;++n){var a=r[n],s=a.value,i=T.Type.UTF8;"valueTagClass"in a&&(i=a.valueTagClass),i===T.Type.UTF8&&(s=Le.util.encodeUtf8(s));var o=!1;"valueConstructed"in a&&(o=a.valueConstructed);var c=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(a.type).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SET,!0,[T.create(T.Class.UNIVERSAL,i,o,s)])]);t.value.push(c)}return t}var Sb=new Date("1950-01-01T00:00:00Z"),Eb=new Date("2050-01-01T00:00:00Z");function Fh(e){return e>=Sb&&e<Eb?T.create(T.Class.UNIVERSAL,T.Type.UTCTIME,!1,T.dateToUtcTime(e)):T.create(T.Class.UNIVERSAL,T.Type.GENERALIZEDTIME,!1,T.dateToGeneralizedTime(e))}fe.getTBSCertificate=function(e){var t=Fh(e.validity.notBefore),r=Fh(e.validity.notAfter),n=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(e.version).getBytes())]),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,Le.util.hexToBytes(e.serialNumber)),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(e.siginfo.algorithmOid).getBytes()),Fd(e.siginfo.algorithmOid,e.siginfo.parameters)]),es(e.issuer),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[t,r]),es(e.subject),fe.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&n.value.push(T.create(T.Class.CONTEXT_SPECIFIC,1,!0,[T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,"\0"+e.issuer.uniqueId)])),e.subject.uniqueId&&n.value.push(T.create(T.Class.CONTEXT_SPECIFIC,2,!0,[T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,"\0"+e.subject.uniqueId)])),e.extensions.length>0&&n.value.push(fe.certificateExtensionsToAsn1(e.extensions)),n};fe.getCertificationRequestInfo=function(e){var t=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(e.version).getBytes()),es(e.subject),fe.publicKeyToAsn1(e.publicKey),Cb(e)]);return t};fe.distinguishedNameToAsn1=function(e){return es(e)};fe.certificateToAsn1=function(e){var t=e.tbsCertificate||fe.getTBSCertificate(e);return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[t,T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(e.signatureOid).getBytes()),Fd(e.signatureOid,e.signatureParameters)]),T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,"\0"+e.signature)])};fe.certificateExtensionsToAsn1=function(e){var t=T.create(T.Class.CONTEXT_SPECIFIC,3,!0,[]),r=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);t.value.push(r);for(var n=0;n<e.length;++n)r.value.push(fe.certificateExtensionToAsn1(e[n]));return t};fe.certificateExtensionToAsn1=function(e){var t=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);t.value.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(e.id).getBytes())),e.critical&&t.value.push(T.create(T.Class.UNIVERSAL,T.Type.BOOLEAN,!1,"ÿ"));var r=e.value;return typeof e.value!="string"&&(r=T.toDer(r).getBytes()),t.value.push(T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,r)),t};fe.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||fe.getCertificationRequestInfo(e);return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[t,T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(e.signatureOid).getBytes()),Fd(e.signatureOid,e.signatureParameters)]),T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,"\0"+e.signature)])};fe.createCaStore=function(e){var t={certs:{}};t.getIssuer=function(i){var o=r(i.issuer);return o},t.addCertificate=function(i){if(typeof i=="string"&&(i=Le.pki.certificateFromPem(i)),n(i.subject),!t.hasCertificate(i))if(i.subject.hash in t.certs){var o=t.certs[i.subject.hash];Le.util.isArray(o)||(o=[o]),o.push(i),t.certs[i.subject.hash]=o}else t.certs[i.subject.hash]=i},t.hasCertificate=function(i){typeof i=="string"&&(i=Le.pki.certificateFromPem(i));var o=r(i.subject);if(!o)return!1;Le.util.isArray(o)||(o=[o]);for(var c=T.toDer(fe.certificateToAsn1(i)).getBytes(),u=0;u<o.length;++u){var l=T.toDer(fe.certificateToAsn1(o[u])).getBytes();if(c===l)return!0}return!1},t.listAllCertificates=function(){var i=[];for(var o in t.certs)if(t.certs.hasOwnProperty(o)){var c=t.certs[o];if(!Le.util.isArray(c))i.push(c);else for(var u=0;u<c.length;++u)i.push(c[u])}return i},t.removeCertificate=function(i){var o;if(typeof i=="string"&&(i=Le.pki.certificateFromPem(i)),n(i.subject),!t.hasCertificate(i))return null;var c=r(i.subject);if(!Le.util.isArray(c))return o=t.certs[i.subject.hash],delete t.certs[i.subject.hash],o;for(var u=T.toDer(fe.certificateToAsn1(i)).getBytes(),l=0;l<c.length;++l){var d=T.toDer(fe.certificateToAsn1(c[l])).getBytes();u===d&&(o=c[l],c.splice(l,1))}return c.length===0&&delete t.certs[i.subject.hash],o};function r(i){return n(i),t.certs[i.hash]||null}function n(i){if(!i.hash){var o=Le.md.sha1.create();i.attributes=fe.RDNAttributesAsArray(es(i),o),i.hash=o.digest().toHex()}}if(e)for(var a=0;a<e.length;++a){var s=e[a];t.addCertificate(s)}return t};fe.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};fe.verifyCertificateChain=function(e,t,r){typeof r=="function"&&(r={verify:r}),r=r||{},t=t.slice(0);var n=t.slice(0),a=r.validityCheckDate;typeof a>"u"&&(a=new Date);var s=!0,i=null,o=0;do{var c=t.shift(),u=null,l=!1;if(a&&(a<c.validity.notBefore||a>c.validity.notAfter)&&(i={message:"Certificate is not valid yet or has expired.",error:fe.certificateError.certificate_expired,notBefore:c.validity.notBefore,notAfter:c.validity.notAfter,now:a}),i===null){if(u=t[0]||e.getIssuer(c),u===null&&c.isIssuer(c)&&(l=!0,u=c),u){var d=u;Le.util.isArray(d)||(d=[d]);for(var h=!1;!h&&d.length>0;){u=d.shift();try{h=u.verify(c)}catch{}}h||(i={message:"Certificate signature is invalid.",error:fe.certificateError.bad_certificate})}i===null&&(!u||l)&&!e.hasCertificate(c)&&(i={message:"Certificate is not trusted.",error:fe.certificateError.unknown_ca})}if(i===null&&u&&!c.isIssuer(u)&&(i={message:"Certificate issuer is invalid.",error:fe.certificateError.bad_certificate}),i===null)for(var p={keyUsage:!0,basicConstraints:!0},f=0;i===null&&f<c.extensions.length;++f){var g=c.extensions[f];g.critical&&!(g.name in p)&&(i={message:"Certificate has an unsupported critical extension.",error:fe.certificateError.unsupported_certificate})}if(i===null&&(!s||t.length===0&&(!u||l))){var y=c.getExtension("basicConstraints"),b=c.getExtension("keyUsage");if(b!==null&&(!b.keyCertSign||y===null)&&(i={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:fe.certificateError.bad_certificate}),i===null&&y!==null&&!y.cA&&(i={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:fe.certificateError.bad_certificate}),i===null&&b!==null&&"pathLenConstraint"in y){var m=o-1;m>y.pathLenConstraint&&(i={message:"Certificate basicConstraints pathLenConstraint violated.",error:fe.certificateError.bad_certificate})}}var v=i===null?!0:i.error,S=r.verify?r.verify(v,o,n):v;if(S===!0)i=null;else throw v===!0&&(i={message:"The application rejected the certificate.",error:fe.certificateError.bad_certificate}),(S||S===0)&&(typeof S=="object"&&!Le.util.isArray(S)?(S.message&&(i.message=S.message),S.error&&(i.error=S.error)):typeof S=="string"&&(i.error=S)),i;s=!1,++o}while(t.length>0);return!0};var wt=Ze,O=wt.asn1,Je=wt.pki,Xs=wt.pkcs12=wt.pkcs12||{},Bg={name:"ContentInfo",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:O.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},xb={name:"PFX",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,capture:"version"},Bg,{name:"PFX.macData",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:O.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:O.Class.UNIVERSAL,type:O.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:O.Class.UNIVERSAL,type:O.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:O.Class.UNIVERSAL,type:O.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},wb={name:"SafeBag",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:O.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:O.Class.UNIVERSAL,type:O.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},Tb={name:"Attribute",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:O.Class.UNIVERSAL,type:O.Type.SET,constructed:!0,capture:"values"}]},$b={name:"CertBag",tagClass:O.Class.UNIVERSAL,type:O.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:O.Class.UNIVERSAL,type:O.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:O.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:O.Class.UNIVERSAL,type:O.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function Bs(e,t,r,n){for(var a=[],s=0;s<e.length;s++)for(var i=0;i<e[s].safeBags.length;i++){var o=e[s].safeBags[i];if(!(n!==void 0&&o.type!==n)){if(t===null){a.push(o);continue}o.attributes[t]!==void 0&&o.attributes[t].indexOf(r)>=0&&a.push(o)}}return a}Xs.pkcs12FromAsn1=function(e,t,r){typeof t=="string"?(r=t,t=!0):t===void 0&&(t=!0);var n={},a=[];if(!O.validate(e,xb,n,a)){var s=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw s.errors=s,s}var i={version:n.version.charCodeAt(0),safeContents:[],getBags:function(y){var b={},m;return"localKeyId"in y?m=y.localKeyId:"localKeyIdHex"in y&&(m=wt.util.hexToBytes(y.localKeyIdHex)),m===void 0&&!("friendlyName"in y)&&"bagType"in y&&(b[y.bagType]=Bs(i.safeContents,null,null,y.bagType)),m!==void 0&&(b.localKeyId=Bs(i.safeContents,"localKeyId",m,y.bagType)),"friendlyName"in y&&(b.friendlyName=Bs(i.safeContents,"friendlyName",y.friendlyName,y.bagType)),b},getBagsByFriendlyName:function(y,b){return Bs(i.safeContents,"friendlyName",y,b)},getBagsByLocalKeyId:function(y,b){return Bs(i.safeContents,"localKeyId",y,b)}};if(n.version.charCodeAt(0)!==3){var s=new Error("PKCS#12 PFX of version other than 3 not supported.");throw s.version=n.version.charCodeAt(0),s}if(O.derToOid(n.contentType)!==Je.oids.data){var s=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw s.oid=O.derToOid(n.contentType),s}var o=n.content.value[0];if(o.tagClass!==O.Class.UNIVERSAL||o.type!==O.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(o=qd(o),n.mac){var c=null,u=0,l=O.derToOid(n.macAlgorithm);switch(l){case Je.oids.sha1:c=wt.md.sha1.create(),u=20;break;case Je.oids.sha256:c=wt.md.sha256.create(),u=32;break;case Je.oids.sha384:c=wt.md.sha384.create(),u=48;break;case Je.oids.sha512:c=wt.md.sha512.create(),u=64;break;case Je.oids.md5:c=wt.md.md5.create(),u=16;break}if(c===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+l);var d=new wt.util.ByteBuffer(n.macSalt),h="macIterations"in n?parseInt(wt.util.bytesToHex(n.macIterations),16):1,p=Xs.generateKey(r,d,3,h,u,c),f=wt.hmac.create();f.start(c,p),f.update(o.value);var g=f.getMac();if(g.getBytes()!==n.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return Ab(i,o.value,t,r),i};function qd(e){if(e.composed||e.constructed){for(var t=wt.util.createBuffer(),r=0;r<e.value.length;++r)t.putBytes(e.value[r].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function Ab(e,t,r,n){if(t=O.fromDer(t,r),t.tagClass!==O.Class.UNIVERSAL||t.type!==O.Type.SEQUENCE||t.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var a=0;a<t.value.length;a++){var s=t.value[a],i={},o=[];if(!O.validate(s,Bg,i,o)){var c=new Error("Cannot read ContentInfo.");throw c.errors=o,c}var u={encrypted:!1},l=null,d=i.content.value[0];switch(O.derToOid(i.contentType)){case Je.oids.data:if(d.tagClass!==O.Class.UNIVERSAL||d.type!==O.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");l=qd(d).value;break;case Je.oids.encryptedData:l=Ib(d,n),u.encrypted=!0;break;default:var c=new Error("Unsupported PKCS#12 contentType.");throw c.contentType=O.derToOid(i.contentType),c}u.safeBags=Pb(l,r,n),e.safeContents.push(u)}}function Ib(e,t){var r={},n=[];if(!O.validate(e,wt.pkcs7.asn1.encryptedDataValidator,r,n)){var a=new Error("Cannot read EncryptedContentInfo.");throw a.errors=n,a}var s=O.derToOid(r.contentType);if(s!==Je.oids.data){var a=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw a.oid=s,a}s=O.derToOid(r.encAlgorithm);var i=Je.pbe.getCipher(s,r.encParameter,t),o=qd(r.encryptedContentAsn1),c=wt.util.createBuffer(o.value);if(i.update(c),!i.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return i.output.getBytes()}function Pb(e,t,r){if(!t&&e.length===0)return[];if(e=O.fromDer(e,t),e.tagClass!==O.Class.UNIVERSAL||e.type!==O.Type.SEQUENCE||e.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var n=[],a=0;a<e.value.length;a++){var s=e.value[a],i={},o=[];if(!O.validate(s,wb,i,o)){var c=new Error("Cannot read SafeBag.");throw c.errors=o,c}var u={type:O.derToOid(i.bagId),attributes:_b(i.bagAttributes)};n.push(u);var l,d,h=i.bagValue.value[0];switch(u.type){case Je.oids.pkcs8ShroudedKeyBag:if(h=Je.decryptPrivateKeyInfo(h,r),h===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case Je.oids.keyBag:try{u.key=Je.privateKeyFromAsn1(h)}catch{u.key=null,u.asn1=h}continue;case Je.oids.certBag:l=$b,d=function(){if(O.derToOid(i.certId)!==Je.oids.x509Certificate){var f=new Error("Unsupported certificate type, only X.509 supported.");throw f.oid=O.derToOid(i.certId),f}var g=O.fromDer(i.cert,t);try{u.cert=Je.certificateFromAsn1(g,!0)}catch{u.cert=null,u.asn1=g}};break;default:var c=new Error("Unsupported PKCS#12 SafeBag type.");throw c.oid=u.type,c}if(l!==void 0&&!O.validate(h,l,i,o)){var c=new Error("Cannot read PKCS#12 "+l.name);throw c.errors=o,c}d()}return n}function _b(e){var t={};if(e!==void 0)for(var r=0;r<e.length;++r){var n={},a=[];if(!O.validate(e[r],Tb,n,a)){var s=new Error("Cannot read PKCS#12 BagAttribute.");throw s.errors=a,s}var i=O.derToOid(n.oid);if(Je.oids[i]!==void 0){t[Je.oids[i]]=[];for(var o=0;o<n.values.length;++o)t[Je.oids[i]].push(n.values[o].value)}}return t}Xs.toPkcs12Asn1=function(e,t,r,n){n=n||{},n.saltSize=n.saltSize||8,n.count=n.count||2048,n.algorithm=n.algorithm||n.encAlgorithm||"aes128","useMac"in n||(n.useMac=!0),"localKeyId"in n||(n.localKeyId=null),"generateLocalKeyId"in n||(n.generateLocalKeyId=!0);var a=n.localKeyId,s;if(a!==null)a=wt.util.hexToBytes(a);else if(n.generateLocalKeyId)if(t){var i=wt.util.isArray(t)?t[0]:t;typeof i=="string"&&(i=Je.certificateFromPem(i));var o=wt.md.sha1.create();o.update(O.toDer(Je.certificateToAsn1(i)).getBytes()),a=o.digest().getBytes()}else a=wt.random.getBytes(20);var c=[];a!==null&&c.push(O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.localKeyId).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SET,!0,[O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,a)])])),"friendlyName"in n&&c.push(O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.friendlyName).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SET,!0,[O.create(O.Class.UNIVERSAL,O.Type.BMPSTRING,!1,n.friendlyName)])])),c.length>0&&(s=O.create(O.Class.UNIVERSAL,O.Type.SET,!0,c));var u=[],l=[];t!==null&&(wt.util.isArray(t)?l=t:l=[t]);for(var d=[],h=0;h<l.length;++h){t=l[h],typeof t=="string"&&(t=Je.certificateFromPem(t));var p=h===0?s:void 0,f=Je.certificateToAsn1(t),g=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.certBag).getBytes()),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.x509Certificate).getBytes()),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,O.toDer(f).getBytes())])])]),p]);d.push(g)}if(d.length>0){var y=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,d),b=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.data).getBytes()),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,O.toDer(y).getBytes())])]);u.push(b)}var m=null;if(e!==null){var v=Je.wrapRsaPrivateKey(Je.privateKeyToAsn1(e));r===null?m=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.keyBag).getBytes()),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[v]),s]):m=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.pkcs8ShroudedKeyBag).getBytes()),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[Je.encryptPrivateKeyInfo(v,r,n)]),s]);var S=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[m]),C=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.data).getBytes()),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,O.toDer(S).getBytes())])]);u.push(C)}var E=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,u),w;if(n.useMac){var o=wt.md.sha1.create(),_=new wt.util.ByteBuffer(wt.random.getBytes(n.saltSize)),P=n.count,e=Xs.generateKey(r,_,3,P,20),x=wt.hmac.create();x.start(o,e),x.update(O.toDer(E).getBytes());var R=x.getMac();w=O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.sha1).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.NULL,!1,"")]),O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,R.getBytes())]),O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,_.getBytes()),O.create(O.Class.UNIVERSAL,O.Type.INTEGER,!1,O.integerToDer(P).getBytes())])}return O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.INTEGER,!1,O.integerToDer(3).getBytes()),O.create(O.Class.UNIVERSAL,O.Type.SEQUENCE,!0,[O.create(O.Class.UNIVERSAL,O.Type.OID,!1,O.oidToDer(Je.oids.data).getBytes()),O.create(O.Class.CONTEXT_SPECIFIC,0,!0,[O.create(O.Class.UNIVERSAL,O.Type.OCTETSTRING,!1,O.toDer(E).getBytes())])]),w])};Xs.generateKey=wt.pbe.generatePkcs12Key;var Zn=Ze,Hd=Zn.asn1,ts=Zn.pki=Zn.pki||{};ts.pemToDer=function(e){var t=Zn.pem.decode(e)[0];if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return Zn.util.createBuffer(t.body)};ts.privateKeyFromPem=function(e){var t=Zn.pem.decode(e)[0];if(t.type!=="PRIVATE KEY"&&t.type!=="RSA PRIVATE KEY"){var r=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var n=Hd.fromDer(t.body);return ts.privateKeyFromAsn1(n)};ts.privateKeyToPem=function(e,t){var r={type:"RSA PRIVATE KEY",body:Hd.toDer(ts.privateKeyToAsn1(e)).getBytes()};return Zn.pem.encode(r,{maxline:t})};ts.privateKeyInfoToPem=function(e,t){var r={type:"PRIVATE KEY",body:Hd.toDer(e).getBytes()};return Zn.pem.encode(r,{maxline:t})};var ue=Ze,Fo=function(e,t,r,n){var a=ue.util.createBuffer(),s=e.length>>1,i=s+(e.length&1),o=e.substr(0,i),c=e.substr(s,i),u=ue.util.createBuffer(),l=ue.hmac.create();r=t+r;var d=Math.ceil(n/16),h=Math.ceil(n/20);l.start("MD5",o);var p=ue.util.createBuffer();u.putBytes(r);for(var f=0;f<d;++f)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),p.putBuffer(l.digest());l.start("SHA1",c);var g=ue.util.createBuffer();u.clear(),u.putBytes(r);for(var f=0;f<h;++f)l.start(null,null),l.update(u.getBytes()),u.putBuffer(l.digest()),l.start(null,null),l.update(u.bytes()+r),g.putBuffer(l.digest());return a.putBytes(ue.util.xorBytes(p.getBytes(),g.getBytes(),n)),a},Db=function(e,t,r){var n=ue.hmac.create();n.start("SHA1",e);var a=ue.util.createBuffer();return a.putInt32(t[0]),a.putInt32(t[1]),a.putByte(r.type),a.putByte(r.version.major),a.putByte(r.version.minor),a.putInt16(r.length),a.putBytes(r.fragment.bytes()),n.update(a.getBytes()),n.digest().getBytes()},Rb=function(e,t,r){var n=!1;try{var a=e.deflate(t.fragment.getBytes());t.fragment=ue.util.createBuffer(a),t.length=a.length,n=!0}catch{}return n},Nb=function(e,t,r){var n=!1;try{var a=e.inflate(t.fragment.getBytes());t.fragment=ue.util.createBuffer(a),t.length=a.length,n=!0}catch{}return n},Ir=function(e,t){var r=0;switch(t){case 1:r=e.getByte();break;case 2:r=e.getInt16();break;case 3:r=e.getInt24();break;case 4:r=e.getInt32();break}return ue.util.createBuffer(e.getBytes(r))},Nr=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},A={};A.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}};A.SupportedVersions=[A.Versions.TLS_1_1,A.Versions.TLS_1_0];A.Version=A.SupportedVersions[0];A.MaxFragment=15360;A.ConnectionEnd={server:0,client:1};A.PRFAlgorithm={tls_prf_sha256:0};A.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2};A.CipherType={stream:0,block:1,aead:2};A.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4};A.CompressionMethod={none:0,deflate:1};A.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24};A.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20};A.Alert={};A.Alert.Level={warning:1,fatal:2};A.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100};A.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2};A.CipherSuites={};A.getCipherSuite=function(e){var t=null;for(var r in A.CipherSuites){var n=A.CipherSuites[r];if(n.id[0]===e.charCodeAt(0)&&n.id[1]===e.charCodeAt(1)){t=n;break}}return t};A.handleUnexpected=function(e,t){var r=!e.open&&e.entity===A.ConnectionEnd.client;r||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.unexpected_message}})};A.handleHelloRequest=function(e,t,r){!e.handshaking&&e.handshakes>0&&(A.queue(e,A.createAlert(e,{level:A.Alert.Level.warning,description:A.Alert.Description.no_renegotiation})),A.flush(e)),e.process()};A.parseHelloMessage=function(e,t,r){var n=null,a=e.entity===A.ConnectionEnd.client;if(r<38)e.error(e,{message:a?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.illegal_parameter}});else{var s=t.fragment,i=s.length();if(n={version:{major:s.getByte(),minor:s.getByte()},random:ue.util.createBuffer(s.getBytes(32)),session_id:Ir(s,1),extensions:[]},a?(n.cipher_suite=s.getBytes(2),n.compression_method=s.getByte()):(n.cipher_suites=Ir(s,2),n.compression_methods=Ir(s,1)),i=r-(i-s.length()),i>0){for(var o=Ir(s,2);o.length()>0;)n.extensions.push({type:[o.getByte(),o.getByte()],data:Ir(o,2)});if(!a)for(var c=0;c<n.extensions.length;++c){var u=n.extensions[c];if(u.type[0]===0&&u.type[1]===0)for(var l=Ir(u.data,2);l.length()>0;){var d=l.getByte();if(d!==0)break;e.session.extensions.server_name.serverNameList.push(Ir(l,2).getBytes())}}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.protocol_version}});if(a)e.session.cipherSuite=A.getCipherSuite(n.cipher_suite);else for(var h=ue.util.createBuffer(n.cipher_suites.bytes());h.length()>0&&(e.session.cipherSuite=A.getCipherSuite(h.getBytes(2)),e.session.cipherSuite===null););if(e.session.cipherSuite===null)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.handshake_failure},cipherSuite:ue.util.bytesToHex(n.cipher_suite)});a?e.session.compressionMethod=n.compression_method:e.session.compressionMethod=A.CompressionMethod.none}return n};A.createSecurityParameters=function(e,t){var r=e.entity===A.ConnectionEnd.client,n=t.random.bytes(),a=r?e.session.sp.client_random:n,s=r?n:A.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:A.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:a,server_random:s}};A.handleServerHello=function(e,t,r){var n=A.parseHelloMessage(e,t,r);if(!e.fail){if(n.version.minor<=e.version.minor)e.version.minor=n.version.minor;else return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.protocol_version}});e.session.version=e.version;var a=n.session_id.bytes();a.length>0&&a===e.session.id?(e.expect=kg,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=kb,e.session.resuming=!1,A.createSecurityParameters(e,n)),e.session.id=a,e.process()}};A.handleClientHello=function(e,t,r){var n=A.parseHelloMessage(e,t,r);if(!e.fail){var a=n.session_id.bytes(),s=null;if(e.sessionCache&&(s=e.sessionCache.getSession(a),s===null?a="":(s.version.major!==n.version.major||s.version.minor>n.version.minor)&&(s=null,a="")),a.length===0&&(a=ue.random.getBytes(32)),e.session.id=a,e.session.clientHelloVersion=n.version,e.session.sp={},s)e.version=e.session.version=s.version,e.session.sp=s.sp;else{for(var i,o=1;o<A.SupportedVersions.length&&(i=A.SupportedVersions[o],!(i.minor<=n.version.minor));++o);e.version={major:i.major,minor:i.minor},e.session.version=e.version}s!==null?(e.expect=Kd,e.session.resuming=!0,e.session.sp.client_random=n.random.bytes()):(e.expect=e.verifyClient!==!1?qb:Mu,e.session.resuming=!1,A.createSecurityParameters(e,n)),e.open=!0,A.queue(e,A.createRecord(e,{type:A.ContentType.handshake,data:A.createServerHello(e)})),e.session.resuming?(A.queue(e,A.createRecord(e,{type:A.ContentType.change_cipher_spec,data:A.createChangeCipherSpec()})),e.state.pending=A.createConnectionState(e),e.state.current.write=e.state.pending.write,A.queue(e,A.createRecord(e,{type:A.ContentType.handshake,data:A.createFinished(e)}))):(A.queue(e,A.createRecord(e,{type:A.ContentType.handshake,data:A.createCertificate(e)})),e.fail||(A.queue(e,A.createRecord(e,{type:A.ContentType.handshake,data:A.createServerKeyExchange(e)})),e.verifyClient!==!1&&A.queue(e,A.createRecord(e,{type:A.ContentType.handshake,data:A.createCertificateRequest(e)})),A.queue(e,A.createRecord(e,{type:A.ContentType.handshake,data:A.createServerHelloDone(e)})))),A.flush(e),e.process()}};A.handleCertificate=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.illegal_parameter}});var n=t.fragment,a={certificate_list:Ir(n,3)},s,i,o=[];try{for(;a.certificate_list.length()>0;)s=Ir(a.certificate_list,3),i=ue.asn1.fromDer(s),s=ue.pki.certificateFromAsn1(i,!0),o.push(s)}catch(u){return e.error(e,{message:"Could not parse certificate list.",cause:u,send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.bad_certificate}})}var c=e.entity===A.ConnectionEnd.client;(c||e.verifyClient===!0)&&o.length===0?e.error(e,{message:c?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.illegal_parameter}}):o.length===0?e.expect=c?qh:Mu:(c?e.session.serverCertificate=o[0]:e.session.clientCertificate=o[0],A.verifyCertificateChain(e,o)&&(e.expect=c?qh:Mu)),e.process()};A.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.unsupported_certificate}});e.expect=Ob,e.process()};A.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.unsupported_certificate}});var n=t.fragment,a={enc_pre_master_secret:Ir(n,2).getBytes()},s=null;if(e.getPrivateKey)try{s=e.getPrivateKey(e,e.session.serverCertificate),s=ue.pki.privateKeyFromPem(s)}catch(c){e.error(e,{message:"Could not get private key.",cause:c,send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.internal_error}})}if(s===null)return e.error(e,{message:"No private key set.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.internal_error}});try{var i=e.session.sp;i.pre_master_secret=s.decrypt(a.enc_pre_master_secret);var o=e.session.clientHelloVersion;if(o.major!==i.pre_master_secret.charCodeAt(0)||o.minor!==i.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{i.pre_master_secret=ue.random.getBytes(48)}e.expect=Kd,e.session.clientCertificate!==null&&(e.expect=Hb),e.process()};A.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.illegal_parameter}});var n=t.fragment,a={certificate_types:Ir(n,1),certificate_authorities:Ir(n,2)};e.session.certificateRequest=a,e.expect=Ub,e.process()};A.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var a=n.bytes();n.read+=4;var s={signature:Ir(n,2).getBytes()},i=ue.util.createBuffer();i.putBuffer(e.session.md5.digest()),i.putBuffer(e.session.sha1.digest()),i=i.getBytes();try{var o=e.session.clientCertificate;if(!o.publicKey.verify(i,s.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(a),e.session.sha1.update(a)}catch{return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.handshake_failure}})}e.expect=Kd,e.process()};A.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.record_overflow}});if(e.serverCertificate===null){var n={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.insufficient_security}},a=0,s=e.verify(e,n.alert.description,a,[]);if(s!==!0)return(s||s===0)&&(typeof s=="object"&&!ue.util.isArray(s)?(s.message&&(n.message=s.message),s.alert&&(n.alert.description=s.alert)):typeof s=="number"&&(n.alert.description=s)),e.error(e,n)}e.session.certificateRequest!==null&&(t=A.createRecord(e,{type:A.ContentType.handshake,data:A.createCertificate(e)}),A.queue(e,t)),t=A.createRecord(e,{type:A.ContentType.handshake,data:A.createClientKeyExchange(e)}),A.queue(e,t),e.expect=jb;var i=function(o,c){o.session.certificateRequest!==null&&o.session.clientCertificate!==null&&A.queue(o,A.createRecord(o,{type:A.ContentType.handshake,data:A.createCertificateVerify(o,c)})),A.queue(o,A.createRecord(o,{type:A.ContentType.change_cipher_spec,data:A.createChangeCipherSpec()})),o.state.pending=A.createConnectionState(o),o.state.current.write=o.state.pending.write,A.queue(o,A.createRecord(o,{type:A.ContentType.handshake,data:A.createFinished(o)})),o.expect=kg,A.flush(o),o.process()};if(e.session.certificateRequest===null||e.session.clientCertificate===null)return i(e,null);A.getClientSignature(e,i)};A.handleChangeCipherSpec=function(e,t){if(t.fragment.getByte()!==1)return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.illegal_parameter}});var r=e.entity===A.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=A.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?Lb:Kb,e.process()};A.handleFinished=function(e,t,r){var n=t.fragment;n.read-=4;var a=n.bytes();n.read+=4;var s=t.fragment.getBytes();n=ue.util.createBuffer(),n.putBuffer(e.session.md5.digest()),n.putBuffer(e.session.sha1.digest());var i=e.entity===A.ConnectionEnd.client,o=i?"server finished":"client finished",c=e.session.sp,u=12,l=Fo;if(n=l(c.master_secret,o,n.getBytes(),u),n.getBytes()!==s)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.decrypt_error}});e.session.md5.update(a),e.session.sha1.update(a),(e.session.resuming&&i||!e.session.resuming&&!i)&&(A.queue(e,A.createRecord(e,{type:A.ContentType.change_cipher_spec,data:A.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,A.queue(e,A.createRecord(e,{type:A.ContentType.handshake,data:A.createFinished(e)}))),e.expect=i?Mb:Vb,e.handshaking=!1,++e.handshakes,e.peerCertificate=i?e.session.serverCertificate:e.session.clientCertificate,A.flush(e),e.isConnected=!0,e.connected(e),e.process()};A.handleAlert=function(e,t){var r=t.fragment,n={level:r.getByte(),description:r.getByte()},a;switch(n.description){case A.Alert.Description.close_notify:a="Connection closed.";break;case A.Alert.Description.unexpected_message:a="Unexpected message.";break;case A.Alert.Description.bad_record_mac:a="Bad record MAC.";break;case A.Alert.Description.decryption_failed:a="Decryption failed.";break;case A.Alert.Description.record_overflow:a="Record overflow.";break;case A.Alert.Description.decompression_failure:a="Decompression failed.";break;case A.Alert.Description.handshake_failure:a="Handshake failure.";break;case A.Alert.Description.bad_certificate:a="Bad certificate.";break;case A.Alert.Description.unsupported_certificate:a="Unsupported certificate.";break;case A.Alert.Description.certificate_revoked:a="Certificate revoked.";break;case A.Alert.Description.certificate_expired:a="Certificate expired.";break;case A.Alert.Description.certificate_unknown:a="Certificate unknown.";break;case A.Alert.Description.illegal_parameter:a="Illegal parameter.";break;case A.Alert.Description.unknown_ca:a="Unknown certificate authority.";break;case A.Alert.Description.access_denied:a="Access denied.";break;case A.Alert.Description.decode_error:a="Decode error.";break;case A.Alert.Description.decrypt_error:a="Decrypt error.";break;case A.Alert.Description.export_restriction:a="Export restriction.";break;case A.Alert.Description.protocol_version:a="Unsupported protocol version.";break;case A.Alert.Description.insufficient_security:a="Insufficient security.";break;case A.Alert.Description.internal_error:a="Internal error.";break;case A.Alert.Description.user_canceled:a="User canceled.";break;case A.Alert.Description.no_renegotiation:a="Renegotiation not supported.";break;default:a="Unknown error.";break}if(n.description===A.Alert.Description.close_notify)return e.close();e.error(e,{message:a,send:!1,origin:e.entity===A.ConnectionEnd.client?"server":"client",alert:n}),e.process()};A.handleHandshake=function(e,t){var r=t.fragment,n=r.getByte(),a=r.getInt24();if(a>r.length())return e.fragmented=t,t.fragment=ue.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var s=r.bytes(a+4);r.read+=4,n in co[e.entity][e.expect]?(e.entity===A.ConnectionEnd.server&&!e.open&&!e.fail&&(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:ue.md.md5.create(),sha1:ue.md.sha1.create()}),n!==A.HandshakeType.hello_request&&n!==A.HandshakeType.certificate_verify&&n!==A.HandshakeType.finished&&(e.session.md5.update(s),e.session.sha1.update(s)),co[e.entity][e.expect][n](e,t,a)):A.handleUnexpected(e,t)};A.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()};A.handleHeartbeat=function(e,t){var r=t.fragment,n=r.getByte(),a=r.getInt16(),s=r.getBytes(a);if(n===A.HeartbeatMessageType.heartbeat_request){if(e.handshaking||a>s.length)return e.process();A.queue(e,A.createRecord(e,{type:A.ContentType.heartbeat,data:A.createHeartbeat(A.HeartbeatMessageType.heartbeat_response,s)})),A.flush(e)}else if(n===A.HeartbeatMessageType.heartbeat_response){if(s!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,ue.util.createBuffer(s))}e.process()};var Bb=0,kb=1,qh=2,Ob=3,Ub=4,kg=5,Lb=6,Mb=7,jb=8,Fb=0,qb=1,Mu=2,Hb=3,Kd=4,Kb=5,Vb=6,$=A.handleUnexpected,Og=A.handleChangeCipherSpec,er=A.handleAlert,mr=A.handleHandshake,Ug=A.handleApplicationData,tr=A.handleHeartbeat,Vd=[];Vd[A.ConnectionEnd.client]=[[$,er,mr,$,tr],[$,er,mr,$,tr],[$,er,mr,$,tr],[$,er,mr,$,tr],[$,er,mr,$,tr],[Og,er,$,$,tr],[$,er,mr,$,tr],[$,er,mr,Ug,tr],[$,er,mr,$,tr]];Vd[A.ConnectionEnd.server]=[[$,er,mr,$,tr],[$,er,mr,$,tr],[$,er,mr,$,tr],[$,er,mr,$,tr],[Og,er,$,$,tr],[$,er,mr,$,tr],[$,er,mr,Ug,tr],[$,er,mr,$,tr]];var Bn=A.handleHelloRequest,zb=A.handleServerHello,Lg=A.handleCertificate,Hh=A.handleServerKeyExchange,nu=A.handleCertificateRequest,$i=A.handleServerHelloDone,Mg=A.handleFinished,co=[];co[A.ConnectionEnd.client]=[[$,$,zb,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$],[Bn,$,$,$,$,$,$,$,$,$,$,Lg,Hh,nu,$i,$,$,$,$,$,$],[Bn,$,$,$,$,$,$,$,$,$,$,$,Hh,nu,$i,$,$,$,$,$,$],[Bn,$,$,$,$,$,$,$,$,$,$,$,$,nu,$i,$,$,$,$,$,$],[Bn,$,$,$,$,$,$,$,$,$,$,$,$,$,$i,$,$,$,$,$,$],[Bn,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$],[Bn,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,Mg],[Bn,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$],[Bn,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$]];var Gb=A.handleClientHello,Qb=A.handleClientKeyExchange,Wb=A.handleCertificateVerify;co[A.ConnectionEnd.server]=[[$,Gb,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$],[$,$,$,$,$,$,$,$,$,$,$,Lg,$,$,$,$,$,$,$,$,$],[$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,Qb,$,$,$,$],[$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,Wb,$,$,$,$,$],[$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$],[$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,Mg],[$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$],[$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$,$]];A.generateKeys=function(e,t){var r=Fo,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var a=2*t.mac_key_length+2*t.enc_key_length,s=e.version.major===A.Versions.TLS_1_0.major&&e.version.minor===A.Versions.TLS_1_0.minor;s&&(a+=2*t.fixed_iv_length);var i=r(t.master_secret,"key expansion",n,a),o={client_write_MAC_key:i.getBytes(t.mac_key_length),server_write_MAC_key:i.getBytes(t.mac_key_length),client_write_key:i.getBytes(t.enc_key_length),server_write_key:i.getBytes(t.enc_key_length)};return s&&(o.client_write_IV=i.getBytes(t.fixed_iv_length),o.server_write_IV=i.getBytes(t.fixed_iv_length)),o};A.createConnectionState=function(e){var t=e.entity===A.ConnectionEnd.client,r=function(){var s={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(i){return!0},compressionState:null,compressFunction:function(i){return!0},updateSequenceNumber:function(){s.sequenceNumber[1]===4294967295?(s.sequenceNumber[1]=0,++s.sequenceNumber[0]):++s.sequenceNumber[1]}};return s},n={read:r(),write:r()};if(n.read.update=function(s,i){return n.read.cipherFunction(i,n.read)?n.read.compressFunction(s,i,n.read)||s.error(s,{message:"Could not decompress record.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.decompression_failure}}):s.error(s,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.bad_record_mac}}),!s.fail},n.write.update=function(s,i){return n.write.compressFunction(s,i,n.write)?n.write.cipherFunction(i,n.write)||s.error(s,{message:"Could not encrypt record.",send:!1,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.internal_error}}):s.error(s,{message:"Could not compress record.",send:!1,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.internal_error}}),!s.fail},e.session){var a=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(a),a.keys=A.generateKeys(e,a),n.read.macKey=t?a.keys.server_write_MAC_key:a.keys.client_write_MAC_key,n.write.macKey=t?a.keys.client_write_MAC_key:a.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,a),a.compression_algorithm){case A.CompressionMethod.none:break;case A.CompressionMethod.deflate:n.read.compressFunction=Nb,n.write.compressFunction=Rb;break;default:throw new Error("Unsupported compression algorithm.")}}return n};A.createRandom=function(){var e=new Date,t=+e+e.getTimezoneOffset()*6e4,r=ue.util.createBuffer();return r.putInt32(t),r.putBytes(ue.random.getBytes(28)),r};A.createRecord=function(e,t){if(!t.data)return null;var r={type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data};return r};A.createAlert=function(e,t){var r=ue.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),A.createRecord(e,{type:A.ContentType.alert,data:r})};A.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=ue.util.createBuffer(),r=0;r<e.cipherSuites.length;++r){var n=e.cipherSuites[r];t.putByte(n.id[0]),t.putByte(n.id[1])}var a=t.length(),s=ue.util.createBuffer();s.putByte(A.CompressionMethod.none);var i=s.length(),o=ue.util.createBuffer();if(e.virtualHost){var c=ue.util.createBuffer();c.putByte(0),c.putByte(0);var u=ue.util.createBuffer();u.putByte(0),Nr(u,2,ue.util.createBuffer(e.virtualHost));var l=ue.util.createBuffer();Nr(l,2,u),Nr(c,2,l),o.putBuffer(c)}var d=o.length();d>0&&(d+=2);var h=e.session.id,p=h.length+1+2+4+28+2+a+1+i+d,f=ue.util.createBuffer();return f.putByte(A.HandshakeType.client_hello),f.putInt24(p),f.putByte(e.version.major),f.putByte(e.version.minor),f.putBytes(e.session.sp.client_random),Nr(f,1,ue.util.createBuffer(h)),Nr(f,2,t),Nr(f,1,s),d>0&&Nr(f,2,o),f};A.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,n=ue.util.createBuffer();return n.putByte(A.HandshakeType.server_hello),n.putInt24(r),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),Nr(n,1,ue.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n};A.createCertificate=function(e){var t=e.entity===A.ConnectionEnd.client,r=null;if(e.getCertificate){var n;t?n=e.session.certificateRequest:n=e.session.extensions.server_name.serverNameList,r=e.getCertificate(e,n)}var a=ue.util.createBuffer();if(r!==null)try{ue.util.isArray(r)||(r=[r]);for(var s=null,i=0;i<r.length;++i){var o=ue.pem.decode(r[i])[0];if(o.type!=="CERTIFICATE"&&o.type!=="X509 CERTIFICATE"&&o.type!=="TRUSTED CERTIFICATE"){var c=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw c.headerType=o.type,c}if(o.procType&&o.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var u=ue.util.createBuffer(o.body);s===null&&(s=ue.asn1.fromDer(u.bytes(),!1));var l=ue.util.createBuffer();Nr(l,3,u),a.putBuffer(l)}r=ue.pki.certificateFromAsn1(s),t?e.session.clientCertificate=r:e.session.serverCertificate=r}catch(p){return e.error(e,{message:"Could not send certificate list.",cause:p,send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.bad_certificate}})}var d=3+a.length(),h=ue.util.createBuffer();return h.putByte(A.HandshakeType.certificate),h.putInt24(d),Nr(h,3,a),h};A.createClientKeyExchange=function(e){var t=ue.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(ue.random.getBytes(46));var r=e.session.sp;r.pre_master_secret=t.getBytes();var n=e.session.serverCertificate.publicKey;t=n.encrypt(r.pre_master_secret);var a=t.length+2,s=ue.util.createBuffer();return s.putByte(A.HandshakeType.client_key_exchange),s.putInt24(a),s.putInt16(t.length),s.putBytes(t),s};A.createServerKeyExchange=function(e){var t=ue.util.createBuffer();return t};A.getClientSignature=function(e,t){var r=ue.util.createBuffer();r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest()),r=r.getBytes(),e.getSignature=e.getSignature||function(n,a,s){var i=null;if(n.getPrivateKey)try{i=n.getPrivateKey(n,n.session.clientCertificate),i=ue.pki.privateKeyFromPem(i)}catch(o){n.error(n,{message:"Could not get private key.",cause:o,send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.internal_error}})}i===null?n.error(n,{message:"No private key set.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.internal_error}}):a=i.sign(a,null),s(n,a)},e.getSignature(e,r,t)};A.createCertificateVerify=function(e,t){var r=t.length+2,n=ue.util.createBuffer();return n.putByte(A.HandshakeType.certificate_verify),n.putInt24(r),n.putInt16(t.length),n.putBytes(t),n};A.createCertificateRequest=function(e){var t=ue.util.createBuffer();t.putByte(1);var r=ue.util.createBuffer();for(var n in e.caStore.certs){var a=e.caStore.certs[n],s=ue.pki.distinguishedNameToAsn1(a.subject),i=ue.asn1.toDer(s);r.putInt16(i.length()),r.putBuffer(i)}var o=1+t.length()+2+r.length(),c=ue.util.createBuffer();return c.putByte(A.HandshakeType.certificate_request),c.putInt24(o),Nr(c,1,t),Nr(c,2,r),c};A.createServerHelloDone=function(e){var t=ue.util.createBuffer();return t.putByte(A.HandshakeType.server_hello_done),t.putInt24(0),t};A.createChangeCipherSpec=function(){var e=ue.util.createBuffer();return e.putByte(1),e};A.createFinished=function(e){var t=ue.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var r=e.entity===A.ConnectionEnd.client,n=e.session.sp,a=12,s=Fo,i=r?"client finished":"server finished";t=s(n.master_secret,i,t.getBytes(),a);var o=ue.util.createBuffer();return o.putByte(A.HandshakeType.finished),o.putInt24(t.length()),o.putBuffer(t),o};A.createHeartbeat=function(e,t,r){typeof r>"u"&&(r=t.length);var n=ue.util.createBuffer();n.putByte(e),n.putInt16(r),n.putBytes(t);var a=n.length(),s=Math.max(16,a-r-3);return n.putBytes(ue.random.getBytes(s)),n};A.queue=function(e,t){if(t&&!(t.fragment.length()===0&&(t.type===A.ContentType.handshake||t.type===A.ContentType.alert||t.type===A.ContentType.change_cipher_spec))){if(t.type===A.ContentType.handshake){var r=t.fragment.bytes();e.session.md5.update(r),e.session.sha1.update(r),r=null}var n;if(t.fragment.length()<=A.MaxFragment)n=[t];else{n=[];for(var a=t.fragment.bytes();a.length>A.MaxFragment;)n.push(A.createRecord(e,{type:t.type,data:ue.util.createBuffer(a.slice(0,A.MaxFragment))})),a=a.slice(A.MaxFragment);a.length>0&&n.push(A.createRecord(e,{type:t.type,data:ue.util.createBuffer(a)}))}for(var s=0;s<n.length&&!e.fail;++s){var i=n[s],o=e.state.current.write;o.update(e,i)&&e.records.push(i)}}};A.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var au=function(e){switch(e){case!0:return!0;case ue.pki.certificateError.bad_certificate:return A.Alert.Description.bad_certificate;case ue.pki.certificateError.unsupported_certificate:return A.Alert.Description.unsupported_certificate;case ue.pki.certificateError.certificate_revoked:return A.Alert.Description.certificate_revoked;case ue.pki.certificateError.certificate_expired:return A.Alert.Description.certificate_expired;case ue.pki.certificateError.certificate_unknown:return A.Alert.Description.certificate_unknown;case ue.pki.certificateError.unknown_ca:return A.Alert.Description.unknown_ca;default:return A.Alert.Description.bad_certificate}},Zb=function(e){switch(e){case!0:return!0;case A.Alert.Description.bad_certificate:return ue.pki.certificateError.bad_certificate;case A.Alert.Description.unsupported_certificate:return ue.pki.certificateError.unsupported_certificate;case A.Alert.Description.certificate_revoked:return ue.pki.certificateError.certificate_revoked;case A.Alert.Description.certificate_expired:return ue.pki.certificateError.certificate_expired;case A.Alert.Description.certificate_unknown:return ue.pki.certificateError.certificate_unknown;case A.Alert.Description.unknown_ca:return ue.pki.certificateError.unknown_ca;default:return ue.pki.certificateError.bad_certificate}};A.verifyCertificateChain=function(e,t){try{var r={};for(var n in e.verifyOptions)r[n]=e.verifyOptions[n];r.verify=function(s,i,o){var c=au(s),u=e.verify(e,s,i,o);if(u!==!0){if(typeof u=="object"&&!ue.util.isArray(u)){var l=new Error("The application rejected the certificate.");throw l.send=!0,l.alert={level:A.Alert.Level.fatal,description:A.Alert.Description.bad_certificate},u.message&&(l.message=u.message),u.alert&&(l.alert.description=u.alert),l}u!==s&&(u=Zb(u))}return u},ue.pki.verifyCertificateChain(e.caStore,t,r)}catch(s){var a=s;(typeof a!="object"||ue.util.isArray(a))&&(a={send:!0,alert:{level:A.Alert.Level.fatal,description:au(s)}}),"send"in a||(a.send=!0),"alert"in a||(a.alert={level:A.Alert.Level.fatal,description:au(a.error)}),e.error(e,a)}return!e.fail};A.createSessionCache=function(e,t){var r=null;if(e&&e.getSession&&e.setSession&&e.order)r=e;else{r={},r.cache=e||{},r.capacity=Math.max(t||100,1),r.order=[];for(var n in e)r.order.length<=t?r.order.push(n):delete e[n];r.getSession=function(a){var s=null,i=null;if(a?i=ue.util.bytesToHex(a):r.order.length>0&&(i=r.order[0]),i!==null&&i in r.cache){s=r.cache[i],delete r.cache[i];for(var o in r.order)if(r.order[o]===i){r.order.splice(o,1);break}}return s},r.setSession=function(a,s){if(r.order.length===r.capacity){var i=r.order.shift();delete r.cache[i]}var i=ue.util.bytesToHex(a);r.order.push(i),r.cache[i]=s}}return r};A.createConnection=function(e){var t=null;e.caStore?ue.util.isArray(e.caStore)?t=ue.pki.createCaStore(e.caStore):t=e.caStore:t=ue.pki.createCaStore();var r=e.cipherSuites||null;if(r===null){r=[];for(var n in A.CipherSuites)r.push(A.CipherSuites[n])}var a=e.server?A.ConnectionEnd.server:A.ConnectionEnd.client,s=e.sessionCache?A.createSessionCache(e.sessionCache):null,i={version:{major:A.Version.major,minor:A.Version.minor},entity:a,sessionId:e.sessionId,caStore:t,sessionCache:s,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(l,d,h,p){return d},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:ue.util.createBuffer(),tlsData:ue.util.createBuffer(),data:ue.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(l,d){d.origin=d.origin||(l.entity===A.ConnectionEnd.client?"client":"server"),d.send&&(A.queue(l,A.createAlert(l,d.alert)),A.flush(l));var h=d.fatal!==!1;h&&(l.fail=!0),e.error(l,d),h&&l.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null};i.reset=function(l){i.version={major:A.Version.major,minor:A.Version.minor},i.record=null,i.session=null,i.peerCertificate=null,i.state={pending:null,current:null},i.expect=i.entity===A.ConnectionEnd.client?Bb:Fb,i.fragmented=null,i.records=[],i.open=!1,i.handshakes=0,i.handshaking=!1,i.isConnected=!1,i.fail=!(l||typeof l>"u"),i.input.clear(),i.tlsData.clear(),i.data.clear(),i.state.current=A.createConnectionState(i)},i.reset();var o=function(l,d){var h=d.type-A.ContentType.change_cipher_spec,p=Vd[l.entity][l.expect];h in p?p[h](l,d):A.handleUnexpected(l,d)},c=function(l){var d=0,h=l.input,p=h.length();if(p<5)d=5-p;else{l.record={type:h.getByte(),version:{major:h.getByte(),minor:h.getByte()},length:h.getInt16(),fragment:ue.util.createBuffer(),ready:!1};var f=l.record.version.major===l.version.major;f&&l.session&&l.session.version&&(f=l.record.version.minor===l.version.minor),f||l.error(l,{message:"Incompatible TLS version.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.protocol_version}})}return d},u=function(l){var d=0,h=l.input,p=h.length();if(p<l.record.length)d=l.record.length-p;else{l.record.fragment.putBytes(h.getBytes(l.record.length)),h.compact();var f=l.state.current.read;f.update(l,l.record)&&(l.fragmented!==null&&(l.fragmented.type===l.record.type?(l.fragmented.fragment.putBuffer(l.record.fragment),l.record=l.fragmented):l.error(l,{message:"Invalid fragmented record.",send:!0,alert:{level:A.Alert.Level.fatal,description:A.Alert.Description.unexpected_message}})),l.record.ready=!0)}return d};return i.handshake=function(l){if(i.entity!==A.ConnectionEnd.client)i.error(i,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(i.handshaking)i.error(i,{message:"Handshake already in progress.",fatal:!1});else{i.fail&&!i.open&&i.handshakes===0&&(i.fail=!1),i.handshaking=!0,l=l||"";var d=null;l.length>0&&(i.sessionCache&&(d=i.sessionCache.getSession(l)),d===null&&(l="")),l.length===0&&i.sessionCache&&(d=i.sessionCache.getSession(),d!==null&&(l=d.id)),i.session={id:l,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:ue.md.md5.create(),sha1:ue.md.sha1.create()},d&&(i.version=d.version,i.session.sp=d.sp),i.session.sp.client_random=A.createRandom().getBytes(),i.open=!0,A.queue(i,A.createRecord(i,{type:A.ContentType.handshake,data:A.createClientHello(i)})),A.flush(i)}},i.process=function(l){var d=0;return l&&i.input.putBytes(l),i.fail||(i.record!==null&&i.record.ready&&i.record.fragment.isEmpty()&&(i.record=null),i.record===null&&(d=c(i)),!i.fail&&i.record!==null&&!i.record.ready&&(d=u(i)),!i.fail&&i.record!==null&&i.record.ready&&o(i,i.record)),d},i.prepare=function(l){return A.queue(i,A.createRecord(i,{type:A.ContentType.application_data,data:ue.util.createBuffer(l)})),A.flush(i)},i.prepareHeartbeatRequest=function(l,d){return l instanceof ue.util.ByteBuffer&&(l=l.bytes()),typeof d>"u"&&(d=l.length),i.expectedHeartbeatPayload=l,A.queue(i,A.createRecord(i,{type:A.ContentType.heartbeat,data:A.createHeartbeat(A.HeartbeatMessageType.heartbeat_request,l,d)})),A.flush(i)},i.close=function(l){if(!i.fail&&i.sessionCache&&i.session){var d={id:i.session.id,version:i.session.version,sp:i.session.sp};d.sp.keys=null,i.sessionCache.setSession(d.id,d)}i.open&&(i.open=!1,i.input.clear(),(i.isConnected||i.handshaking)&&(i.isConnected=i.handshaking=!1,A.queue(i,A.createAlert(i,{level:A.Alert.Level.warning,description:A.Alert.Description.close_notify})),A.flush(i)),i.closed(i)),i.reset(l)},i};ue.tls=ue.tls||{};for(var su in A)typeof A[su]!="function"&&(ue.tls[su]=A[su]);ue.tls.prf_tls1=Fo;ue.tls.hmac_sha1=Db;ue.tls.createSessionCache=A.createSessionCache;ue.tls.createConnection=A.createConnection;var Qn=Ze,Lr=Qn.tls;Lr.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=Lr.BulkCipherAlgorithm.aes,e.cipher_type=Lr.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=Lr.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:jg};Lr.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=Lr.BulkCipherAlgorithm.aes,e.cipher_type=Lr.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=Lr.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:jg};function jg(e,t,r){var n=t.entity===Qn.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:Qn.cipher.createDecipher("AES-CBC",n?r.keys.server_write_key:r.keys.client_write_key),iv:n?r.keys.server_write_IV:r.keys.client_write_IV},e.write.cipherState={init:!1,cipher:Qn.cipher.createCipher("AES-CBC",n?r.keys.client_write_key:r.keys.server_write_key),iv:n?r.keys.client_write_IV:r.keys.server_write_IV},e.read.cipherFunction=eC,e.write.cipherFunction=Yb,e.read.macLength=e.write.macLength=r.mac_length,e.read.macFunction=e.write.macFunction=Lr.hmac_sha1}function Yb(e,t){var r=!1,n=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(n),t.updateSequenceNumber();var a;e.version.minor===Lr.Versions.TLS_1_0.minor?a=t.cipherState.init?null:t.cipherState.iv:a=Qn.random.getBytesSync(16),t.cipherState.init=!0;var s=t.cipherState.cipher;return s.start({iv:a}),e.version.minor>=Lr.Versions.TLS_1_1.minor&&s.output.putBytes(a),s.update(e.fragment),s.finish(Xb)&&(e.fragment=s.output,e.length=e.fragment.length(),r=!0),r}function Xb(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function Jb(e,t,r){var n=!0;if(r){for(var a=t.length(),s=t.last(),i=a-1-s;i<a-1;++i)n=n&&t.at(i)==s;n&&t.truncate(s+1)}return n}function eC(e,t){var r=!1,n;e.version.minor===Lr.Versions.TLS_1_0.minor?n=t.cipherState.init?null:t.cipherState.iv:n=e.fragment.getBytes(16),t.cipherState.init=!0;var a=t.cipherState.cipher;a.start({iv:n}),a.update(e.fragment),r=a.finish(Jb);var s=t.macLength,i=Qn.random.getBytesSync(s),o=a.output.length();o>=s?(e.fragment=a.output.getBytes(o-s),i=a.output.getBytes(s)):e.fragment=a.output.getBytes(),e.fragment=Qn.util.createBuffer(e.fragment),e.length=e.fragment.length();var c=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),r=tC(t.macKey,i,c)&&r,r}function tC(e,t,r){var n=Qn.hmac.create();return n.start("SHA1",e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(r),r=n.digest().getBytes(),t===r}var Dt=Ze,di=Dt.sha512=Dt.sha512||{};Dt.md.sha512=Dt.md.algorithms.sha512=di;var Fg=Dt.sha384=Dt.sha512.sha384=Dt.sha512.sha384||{};Fg.create=function(){return di.create("SHA-384")};Dt.md.sha384=Dt.md.algorithms.sha384=Fg;Dt.sha512.sha256=Dt.sha512.sha256||{create:function(){return di.create("SHA-512/256")}};Dt.md["sha512/256"]=Dt.md.algorithms["sha512/256"]=Dt.sha512.sha256;Dt.sha512.sha224=Dt.sha512.sha224||{create:function(){return di.create("SHA-512/224")}};Dt.md["sha512/224"]=Dt.md.algorithms["sha512/224"]=Dt.sha512.sha224;di.create=function(e){if(qg||rC(),typeof e>"u"&&(e="SHA-512"),!(e in la))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=la[e],r=null,n=Dt.util.createBuffer(),a=new Array(80),s=0;s<80;++s)a[s]=new Array(2);var i=64;switch(e){case"SHA-384":i=48;break;case"SHA-512/256":i=32;break;case"SHA-512/224":i=28;break}var o={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:i,messageLength:0,fullMessageLength:null,messageLengthSize:16};return o.start=function(){o.messageLength=0,o.fullMessageLength=o.messageLength128=[];for(var c=o.messageLengthSize/4,u=0;u<c;++u)o.fullMessageLength.push(0);n=Dt.util.createBuffer(),r=new Array(t.length);for(var u=0;u<t.length;++u)r[u]=t[u].slice(0);return o},o.start(),o.update=function(c,u){u==="utf8"&&(c=Dt.util.encodeUtf8(c));var l=c.length;o.messageLength+=l,l=[l/4294967296>>>0,l>>>0];for(var d=o.fullMessageLength.length-1;d>=0;--d)o.fullMessageLength[d]+=l[1],l[1]=l[0]+(o.fullMessageLength[d]/4294967296>>>0),o.fullMessageLength[d]=o.fullMessageLength[d]>>>0,l[0]=l[1]/4294967296>>>0;return n.putBytes(c),Kh(r,a,n),(n.read>2048||n.length()===0)&&n.compact(),o},o.digest=function(){var c=Dt.util.createBuffer();c.putBytes(n.bytes());var u=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize,l=u&o.blockLength-1;c.putBytes(ju.substr(0,o.blockLength-l));for(var d,h,p=o.fullMessageLength[0]*8,f=0;f<o.fullMessageLength.length-1;++f)d=o.fullMessageLength[f+1]*8,h=d/4294967296>>>0,p+=h,c.putInt32(p>>>0),p=d>>>0;c.putInt32(p);for(var g=new Array(r.length),f=0;f<r.length;++f)g[f]=r[f].slice(0);Kh(g,a,c);var y=Dt.util.createBuffer(),b;e==="SHA-512"?b=g.length:e==="SHA-384"?b=g.length-2:b=g.length-4;for(var f=0;f<b;++f)y.putInt32(g[f][0]),(f!==b-1||e!=="SHA-512/224")&&y.putInt32(g[f][1]);return y},o};var ju=null,qg=!1,Fu=null,la=null;function rC(){ju="",ju+=Dt.util.fillString("\0",128),Fu=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],la={},la["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],la["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],la["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],la["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],qg=!0}function Kh(e,t,r){for(var n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m,v,S,C,E,w,_,P,x,R,B,K,re,ee,ie,se,Ce,Ie,ye,L,X=r.length();X>=128;){for(ee=0;ee<16;++ee)t[ee][0]=r.getInt32()>>>0,t[ee][1]=r.getInt32()>>>0;for(;ee<80;++ee)Ce=t[ee-2],ie=Ce[0],se=Ce[1],n=((ie>>>19|se<<13)^(se>>>29|ie<<3)^ie>>>6)>>>0,a=((ie<<13|se>>>19)^(se<<3|ie>>>29)^(ie<<26|se>>>6))>>>0,ye=t[ee-15],ie=ye[0],se=ye[1],s=((ie>>>1|se<<31)^(ie>>>8|se<<24)^ie>>>7)>>>0,i=((ie<<31|se>>>1)^(ie<<24|se>>>8)^(ie<<25|se>>>7))>>>0,Ie=t[ee-7],L=t[ee-16],se=a+Ie[1]+i+L[1],t[ee][0]=n+Ie[0]+s+L[0]+(se/4294967296>>>0)>>>0,t[ee][1]=se>>>0;for(g=e[0][0],y=e[0][1],b=e[1][0],m=e[1][1],v=e[2][0],S=e[2][1],C=e[3][0],E=e[3][1],w=e[4][0],_=e[4][1],P=e[5][0],x=e[5][1],R=e[6][0],B=e[6][1],K=e[7][0],re=e[7][1],ee=0;ee<80;++ee)u=((w>>>14|_<<18)^(w>>>18|_<<14)^(_>>>9|w<<23))>>>0,l=((w<<18|_>>>14)^(w<<14|_>>>18)^(_<<23|w>>>9))>>>0,d=(R^w&(P^R))>>>0,h=(B^_&(x^B))>>>0,o=((g>>>28|y<<4)^(y>>>2|g<<30)^(y>>>7|g<<25))>>>0,c=((g<<4|y>>>28)^(y<<30|g>>>2)^(y<<25|g>>>7))>>>0,p=(g&b|v&(g^b))>>>0,f=(y&m|S&(y^m))>>>0,se=re+l+h+Fu[ee][1]+t[ee][1],n=K+u+d+Fu[ee][0]+t[ee][0]+(se/4294967296>>>0)>>>0,a=se>>>0,se=c+f,s=o+p+(se/4294967296>>>0)>>>0,i=se>>>0,K=R,re=B,R=P,B=x,P=w,x=_,se=E+a,w=C+n+(se/4294967296>>>0)>>>0,_=se>>>0,C=v,E=S,v=b,S=m,b=g,m=y,se=a+i,g=n+s+(se/4294967296>>>0)>>>0,y=se>>>0;se=e[0][1]+y,e[0][0]=e[0][0]+g+(se/4294967296>>>0)>>>0,e[0][1]=se>>>0,se=e[1][1]+m,e[1][0]=e[1][0]+b+(se/4294967296>>>0)>>>0,e[1][1]=se>>>0,se=e[2][1]+S,e[2][0]=e[2][0]+v+(se/4294967296>>>0)>>>0,e[2][1]=se>>>0,se=e[3][1]+E,e[3][0]=e[3][0]+C+(se/4294967296>>>0)>>>0,e[3][1]=se>>>0,se=e[4][1]+_,e[4][0]=e[4][0]+w+(se/4294967296>>>0)>>>0,e[4][1]=se>>>0,se=e[5][1]+x,e[5][0]=e[5][0]+P+(se/4294967296>>>0)>>>0,e[5][1]=se>>>0,se=e[6][1]+B,e[6][0]=e[6][0]+R+(se/4294967296>>>0)>>>0,e[6][1]=se>>>0,se=e[7][1]+re,e[7][0]=e[7][0]+K+(se/4294967296>>>0)>>>0,e[7][1]=se>>>0,X-=128}}var zd={},nC=Ze,Qt=nC.asn1;zd.privateKeyValidator={name:"PrivateKeyInfo",tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]};zd.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:Qt.Class.UNIVERSAL,type:Qt.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]};var rr=Ze,Hg=zd,aC=Hg.publicKeyValidator,sC=Hg.privateKeyValidator;if(typeof iC>"u")var iC=rr.jsbn.BigInteger;var qu=rr.util.ByteBuffer,Tr=typeof Buffer>"u"?Uint8Array:Buffer;rr.pki=rr.pki||{};rr.pki.ed25519=rr.ed25519=rr.ed25519||{};var et=rr.ed25519;et.constants={};et.constants.PUBLIC_KEY_BYTE_LENGTH=32;et.constants.PRIVATE_KEY_BYTE_LENGTH=64;et.constants.SEED_BYTE_LENGTH=32;et.constants.SIGN_BYTE_LENGTH=64;et.constants.HASH_BYTE_LENGTH=64;et.generateKeyPair=function(e){e=e||{};var t=e.seed;if(t===void 0)t=rr.random.getBytesSync(et.constants.SEED_BYTE_LENGTH);else if(typeof t=="string"){if(t.length!==et.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+et.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=wn({message:t,encoding:"binary"});for(var r=new Tr(et.constants.PUBLIC_KEY_BYTE_LENGTH),n=new Tr(et.constants.PRIVATE_KEY_BYTE_LENGTH),a=0;a<32;++a)n[a]=t[a];return lC(r,n),{publicKey:r,privateKey:n}};et.privateKeyFromAsn1=function(e){var t={},r=[],n=rr.asn1.validate(e,sC,t,r);if(!n){var a=new Error("Invalid Key.");throw a.errors=r,a}var s=rr.asn1.derToOid(t.privateKeyOid),i=rr.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.privateKey,c=wn({message:rr.asn1.fromDer(o).value,encoding:"binary"});return{privateKeyBytes:c}};et.publicKeyFromAsn1=function(e){var t={},r=[],n=rr.asn1.validate(e,aC,t,r);if(!n){var a=new Error("Invalid Key.");throw a.errors=r,a}var s=rr.asn1.derToOid(t.publicKeyOid),i=rr.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.ed25519PublicKey;if(o.length!==et.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return wn({message:o,encoding:"binary"})};et.publicKeyFromPrivateKey=function(e){e=e||{};var t=wn({message:e.privateKey,encoding:"binary"});if(t.length!==et.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+et.constants.PRIVATE_KEY_BYTE_LENGTH);for(var r=new Tr(et.constants.PUBLIC_KEY_BYTE_LENGTH),n=0;n<r.length;++n)r[n]=t[32+n];return r};et.sign=function(e){e=e||{};var t=wn(e),r=wn({message:e.privateKey,encoding:"binary"});if(r.length===et.constants.SEED_BYTE_LENGTH){var n=et.generateKeyPair({seed:r});r=n.privateKey}else if(r.length!==et.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+et.constants.SEED_BYTE_LENGTH+" or "+et.constants.PRIVATE_KEY_BYTE_LENGTH);var a=new Tr(et.constants.SIGN_BYTE_LENGTH+t.length);dC(a,t,t.length,r);for(var s=new Tr(et.constants.SIGN_BYTE_LENGTH),i=0;i<s.length;++i)s[i]=a[i];return s};et.verify=function(e){e=e||{};var t=wn(e);if(e.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var r=wn({message:e.signature,encoding:"binary"});if(r.length!==et.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+et.constants.SIGN_BYTE_LENGTH);var n=wn({message:e.publicKey,encoding:"binary"});if(n.length!==et.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+et.constants.PUBLIC_KEY_BYTE_LENGTH);var a=new Tr(et.constants.SIGN_BYTE_LENGTH+t.length),s=new Tr(et.constants.SIGN_BYTE_LENGTH+t.length),i;for(i=0;i<et.constants.SIGN_BYTE_LENGTH;++i)a[i]=r[i];for(i=0;i<t.length;++i)a[i+et.constants.SIGN_BYTE_LENGTH]=t[i];return hC(s,a,a.length,n)>=0};function wn(e){var t=e.message;if(t instanceof Uint8Array||t instanceof Tr)return t;var r=e.encoding;if(t===void 0)if(e.md)t=e.md.digest().getBytes(),r="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof t=="string"&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof t=="string"){if(typeof Buffer<"u")return Buffer.from(t,r);t=new qu(t,r)}else if(!(t instanceof qu))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new Tr(t.length()),a=0;a<n.length;++a)n[a]=t.at(a);return n}var Hu=Fe(),uo=Fe([1]),oC=Fe([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),cC=Fe([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Vh=Fe([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),zh=Fe([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),iu=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),uC=Fe([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function Vs(e,t){var r=rr.md.sha512.create(),n=new qu(e);r.update(n.getBytes(t),"binary");var a=r.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(a,"binary");for(var s=new Tr(et.constants.HASH_BYTE_LENGTH),i=0;i<64;++i)s[i]=a.charCodeAt(i);return s}function lC(e,t){var r=[Fe(),Fe(),Fe(),Fe()],n,a=Vs(t,32);for(a[0]&=248,a[31]&=127,a[31]|=64,Qd(r,a),Gd(e,r),n=0;n<32;++n)t[n+32]=e[n];return 0}function dC(e,t,r,n){var a,s,i=new Float64Array(64),o=[Fe(),Fe(),Fe(),Fe()],c=Vs(n,32);c[0]&=248,c[31]&=127,c[31]|=64;var u=r+64;for(a=0;a<r;++a)e[64+a]=t[a];for(a=0;a<32;++a)e[32+a]=c[32+a];var l=Vs(e.subarray(32),r+32);for(Ku(l),Qd(o,l),Gd(e,o),a=32;a<64;++a)e[a]=n[a];var d=Vs(e,r+64);for(Ku(d),a=32;a<64;++a)i[a]=0;for(a=0;a<32;++a)i[a]=l[a];for(a=0;a<32;++a)for(s=0;s<32;s++)i[a+s]+=d[a]*c[s];return Kg(e.subarray(32),i),u}function hC(e,t,r,n){var a,s,i=new Tr(32),o=[Fe(),Fe(),Fe(),Fe()],c=[Fe(),Fe(),Fe(),Fe()];if(s=-1,r<64||pC(c,n))return-1;for(a=0;a<r;++a)e[a]=t[a];for(a=0;a<32;++a)e[a+32]=n[a];var u=Vs(e,r);if(Ku(u),Gg(o,c,u),Qd(c,t.subarray(32)),Vu(o,c),Gd(i,o),r-=64,Vg(t,0,i,0)){for(a=0;a<r;++a)e[a]=0;return-1}for(a=0;a<r;++a)e[a]=t[a+64];return s=r,s}function Kg(e,t){var r,n,a,s;for(n=63;n>=32;--n){for(r=0,a=n-32,s=n-12;a<s;++a)t[a]+=r-16*t[n]*iu[a-(n-32)],r=t[a]+128>>8,t[a]-=r*256;t[a]+=r,t[n]=0}for(r=0,a=0;a<32;++a)t[a]+=r-(t[31]>>4)*iu[a],r=t[a]>>8,t[a]&=255;for(a=0;a<32;++a)t[a]-=r*iu[a];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=t[n]&255}function Ku(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;Kg(e,t)}function Vu(e,t){var r=Fe(),n=Fe(),a=Fe(),s=Fe(),i=Fe(),o=Fe(),c=Fe(),u=Fe(),l=Fe();Va(r,e[1],e[0]),Va(l,t[1],t[0]),bt(r,r,l),qa(n,e[0],e[1]),qa(l,t[0],t[1]),bt(n,n,l),bt(a,e[3],t[3]),bt(a,a,cC),bt(s,e[2],t[2]),qa(s,s,s),Va(i,n,r),Va(o,s,a),qa(c,s,a),qa(u,n,r),bt(e[0],i,o),bt(e[1],u,c),bt(e[2],c,o),bt(e[3],i,u)}function Gh(e,t,r){for(var n=0;n<4;++n)Qg(e[n],t[n],r)}function Gd(e,t){var r=Fe(),n=Fe(),a=Fe();yC(a,t[2]),bt(r,t[0],a),bt(n,t[1],a),lo(e,n),e[31]^=zg(r)<<7}function lo(e,t){var r,n,a,s=Fe(),i=Fe();for(r=0;r<16;++r)i[r]=t[r];for(ou(i),ou(i),ou(i),n=0;n<2;++n){for(s[0]=i[0]-65517,r=1;r<15;++r)s[r]=i[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=i[15]-32767-(s[14]>>16&1),a=s[15]>>16&1,s[14]&=65535,Qg(i,s,1-a)}for(r=0;r<16;r++)e[2*r]=i[r]&255,e[2*r+1]=i[r]>>8}function pC(e,t){var r=Fe(),n=Fe(),a=Fe(),s=Fe(),i=Fe(),o=Fe(),c=Fe();return Kn(e[2],uo),fC(e[1],t),da(a,e[1]),bt(s,a,oC),Va(a,a,e[2]),qa(s,e[2],s),da(i,s),da(o,i),bt(c,o,i),bt(r,c,a),bt(r,r,s),gC(r,r),bt(r,r,a),bt(r,r,s),bt(r,r,s),bt(e[0],r,s),da(n,e[0]),bt(n,n,s),Qh(n,a)&&bt(e[0],e[0],uC),da(n,e[0]),bt(n,n,s),Qh(n,a)?-1:(zg(e[0])===t[31]>>7&&Va(e[0],Hu,e[0]),bt(e[3],e[0],e[1]),0)}function fC(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function gC(e,t){var r=Fe(),n;for(n=0;n<16;++n)r[n]=t[n];for(n=250;n>=0;--n)da(r,r),n!==1&&bt(r,r,t);for(n=0;n<16;++n)e[n]=r[n]}function Qh(e,t){var r=new Tr(32),n=new Tr(32);return lo(r,e),lo(n,t),Vg(r,0,n,0)}function Vg(e,t,r,n){return mC(e,t,r,n,32)}function mC(e,t,r,n,a){var s,i=0;for(s=0;s<a;++s)i|=e[t+s]^r[n+s];return(1&i-1>>>8)-1}function zg(e){var t=new Tr(32);return lo(t,e),t[0]&1}function Gg(e,t,r){var n,a;for(Kn(e[0],Hu),Kn(e[1],uo),Kn(e[2],uo),Kn(e[3],Hu),a=255;a>=0;--a)n=r[a/8|0]>>(a&7)&1,Gh(e,t,n),Vu(t,e),Vu(e,e),Gh(e,t,n)}function Qd(e,t){var r=[Fe(),Fe(),Fe(),Fe()];Kn(r[0],Vh),Kn(r[1],zh),Kn(r[2],uo),bt(r[3],Vh,zh),Gg(e,r,t)}function Kn(e,t){var r;for(r=0;r<16;r++)e[r]=t[r]|0}function yC(e,t){var r=Fe(),n;for(n=0;n<16;++n)r[n]=t[n];for(n=253;n>=0;--n)da(r,r),n!==2&&n!==4&&bt(r,r,t);for(n=0;n<16;++n)e[n]=r[n]}function ou(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-n*65536;e[0]+=n-1+37*(n-1)}function Qg(e,t,r){for(var n,a=~(r-1),s=0;s<16;++s)n=a&(e[s]^t[s]),e[s]^=n,t[s]^=n}function Fe(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;++t)r[t]=e[t];return r}function qa(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]+r[n]}function Va(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]-r[n]}function da(e,t){bt(e,t,t)}function bt(e,t,r){var n,a,s=0,i=0,o=0,c=0,u=0,l=0,d=0,h=0,p=0,f=0,g=0,y=0,b=0,m=0,v=0,S=0,C=0,E=0,w=0,_=0,P=0,x=0,R=0,B=0,K=0,re=0,ee=0,ie=0,se=0,Ce=0,Ie=0,ye=r[0],L=r[1],X=r[2],ne=r[3],U=r[4],be=r[5],xe=r[6],Ne=r[7],he=r[8],_e=r[9],I=r[10],D=r[11],N=r[12],q=r[13],k=r[14],V=r[15];n=t[0],s+=n*ye,i+=n*L,o+=n*X,c+=n*ne,u+=n*U,l+=n*be,d+=n*xe,h+=n*Ne,p+=n*he,f+=n*_e,g+=n*I,y+=n*D,b+=n*N,m+=n*q,v+=n*k,S+=n*V,n=t[1],i+=n*ye,o+=n*L,c+=n*X,u+=n*ne,l+=n*U,d+=n*be,h+=n*xe,p+=n*Ne,f+=n*he,g+=n*_e,y+=n*I,b+=n*D,m+=n*N,v+=n*q,S+=n*k,C+=n*V,n=t[2],o+=n*ye,c+=n*L,u+=n*X,l+=n*ne,d+=n*U,h+=n*be,p+=n*xe,f+=n*Ne,g+=n*he,y+=n*_e,b+=n*I,m+=n*D,v+=n*N,S+=n*q,C+=n*k,E+=n*V,n=t[3],c+=n*ye,u+=n*L,l+=n*X,d+=n*ne,h+=n*U,p+=n*be,f+=n*xe,g+=n*Ne,y+=n*he,b+=n*_e,m+=n*I,v+=n*D,S+=n*N,C+=n*q,E+=n*k,w+=n*V,n=t[4],u+=n*ye,l+=n*L,d+=n*X,h+=n*ne,p+=n*U,f+=n*be,g+=n*xe,y+=n*Ne,b+=n*he,m+=n*_e,v+=n*I,S+=n*D,C+=n*N,E+=n*q,w+=n*k,_+=n*V,n=t[5],l+=n*ye,d+=n*L,h+=n*X,p+=n*ne,f+=n*U,g+=n*be,y+=n*xe,b+=n*Ne,m+=n*he,v+=n*_e,S+=n*I,C+=n*D,E+=n*N,w+=n*q,_+=n*k,P+=n*V,n=t[6],d+=n*ye,h+=n*L,p+=n*X,f+=n*ne,g+=n*U,y+=n*be,b+=n*xe,m+=n*Ne,v+=n*he,S+=n*_e,C+=n*I,E+=n*D,w+=n*N,_+=n*q,P+=n*k,x+=n*V,n=t[7],h+=n*ye,p+=n*L,f+=n*X,g+=n*ne,y+=n*U,b+=n*be,m+=n*xe,v+=n*Ne,S+=n*he,C+=n*_e,E+=n*I,w+=n*D,_+=n*N,P+=n*q,x+=n*k,R+=n*V,n=t[8],p+=n*ye,f+=n*L,g+=n*X,y+=n*ne,b+=n*U,m+=n*be,v+=n*xe,S+=n*Ne,C+=n*he,E+=n*_e,w+=n*I,_+=n*D,P+=n*N,x+=n*q,R+=n*k,B+=n*V,n=t[9],f+=n*ye,g+=n*L,y+=n*X,b+=n*ne,m+=n*U,v+=n*be,S+=n*xe,C+=n*Ne,E+=n*he,w+=n*_e,_+=n*I,P+=n*D,x+=n*N,R+=n*q,B+=n*k,K+=n*V,n=t[10],g+=n*ye,y+=n*L,b+=n*X,m+=n*ne,v+=n*U,S+=n*be,C+=n*xe,E+=n*Ne,w+=n*he,_+=n*_e,P+=n*I,x+=n*D,R+=n*N,B+=n*q,K+=n*k,re+=n*V,n=t[11],y+=n*ye,b+=n*L,m+=n*X,v+=n*ne,S+=n*U,C+=n*be,E+=n*xe,w+=n*Ne,_+=n*he,P+=n*_e,x+=n*I,R+=n*D,B+=n*N,K+=n*q,re+=n*k,ee+=n*V,n=t[12],b+=n*ye,m+=n*L,v+=n*X,S+=n*ne,C+=n*U,E+=n*be,w+=n*xe,_+=n*Ne,P+=n*he,x+=n*_e,R+=n*I,B+=n*D,K+=n*N,re+=n*q,ee+=n*k,ie+=n*V,n=t[13],m+=n*ye,v+=n*L,S+=n*X,C+=n*ne,E+=n*U,w+=n*be,_+=n*xe,P+=n*Ne,x+=n*he,R+=n*_e,B+=n*I,K+=n*D,re+=n*N,ee+=n*q,ie+=n*k,se+=n*V,n=t[14],v+=n*ye,S+=n*L,C+=n*X,E+=n*ne,w+=n*U,_+=n*be,P+=n*xe,x+=n*Ne,R+=n*he,B+=n*_e,K+=n*I,re+=n*D,ee+=n*N,ie+=n*q,se+=n*k,Ce+=n*V,n=t[15],S+=n*ye,C+=n*L,E+=n*X,w+=n*ne,_+=n*U,P+=n*be,x+=n*xe,R+=n*Ne,B+=n*he,K+=n*_e,re+=n*I,ee+=n*D,ie+=n*N,se+=n*q,Ce+=n*k,Ie+=n*V,s+=38*C,i+=38*E,o+=38*w,c+=38*_,u+=38*P,l+=38*x,d+=38*R,h+=38*B,p+=38*K,f+=38*re,g+=38*ee,y+=38*ie,b+=38*se,m+=38*Ce,v+=38*Ie,a=1,n=s+a+65535,a=Math.floor(n/65536),s=n-a*65536,n=i+a+65535,a=Math.floor(n/65536),i=n-a*65536,n=o+a+65535,a=Math.floor(n/65536),o=n-a*65536,n=c+a+65535,a=Math.floor(n/65536),c=n-a*65536,n=u+a+65535,a=Math.floor(n/65536),u=n-a*65536,n=l+a+65535,a=Math.floor(n/65536),l=n-a*65536,n=d+a+65535,a=Math.floor(n/65536),d=n-a*65536,n=h+a+65535,a=Math.floor(n/65536),h=n-a*65536,n=p+a+65535,a=Math.floor(n/65536),p=n-a*65536,n=f+a+65535,a=Math.floor(n/65536),f=n-a*65536,n=g+a+65535,a=Math.floor(n/65536),g=n-a*65536,n=y+a+65535,a=Math.floor(n/65536),y=n-a*65536,n=b+a+65535,a=Math.floor(n/65536),b=n-a*65536,n=m+a+65535,a=Math.floor(n/65536),m=n-a*65536,n=v+a+65535,a=Math.floor(n/65536),v=n-a*65536,n=S+a+65535,a=Math.floor(n/65536),S=n-a*65536,s+=a-1+37*(a-1),a=1,n=s+a+65535,a=Math.floor(n/65536),s=n-a*65536,n=i+a+65535,a=Math.floor(n/65536),i=n-a*65536,n=o+a+65535,a=Math.floor(n/65536),o=n-a*65536,n=c+a+65535,a=Math.floor(n/65536),c=n-a*65536,n=u+a+65535,a=Math.floor(n/65536),u=n-a*65536,n=l+a+65535,a=Math.floor(n/65536),l=n-a*65536,n=d+a+65535,a=Math.floor(n/65536),d=n-a*65536,n=h+a+65535,a=Math.floor(n/65536),h=n-a*65536,n=p+a+65535,a=Math.floor(n/65536),p=n-a*65536,n=f+a+65535,a=Math.floor(n/65536),f=n-a*65536,n=g+a+65535,a=Math.floor(n/65536),g=n-a*65536,n=y+a+65535,a=Math.floor(n/65536),y=n-a*65536,n=b+a+65535,a=Math.floor(n/65536),b=n-a*65536,n=m+a+65535,a=Math.floor(n/65536),m=n-a*65536,n=v+a+65535,a=Math.floor(n/65536),v=n-a*65536,n=S+a+65535,a=Math.floor(n/65536),S=n-a*65536,s+=a-1+37*(a-1),e[0]=s,e[1]=i,e[2]=o,e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=h,e[8]=p,e[9]=f,e[10]=g,e[11]=y,e[12]=b,e[13]=m,e[14]=v,e[15]=S}var _r=Ze;_r.kem=_r.kem||{};var Wh=_r.jsbn.BigInteger;_r.kem.rsa={};_r.kem.rsa.create=function(e,t){t=t||{};var r=t.prng||_r.random,n={};return n.encrypt=function(a,s){var i=Math.ceil(a.n.bitLength()/8),o;do o=new Wh(_r.util.bytesToHex(r.getBytesSync(i)),16).mod(a.n);while(o.compareTo(Wh.ONE)<=0);o=_r.util.hexToBytes(o.toString(16));var c=i-o.length;c>0&&(o=_r.util.fillString("\0",c)+o);var u=a.encrypt(o,"NONE"),l=e.generate(o,s);return{encapsulation:u,key:l}},n.decrypt=function(a,s,i){var o=a.decrypt(s,"NONE");return e.generate(o,i)},n};_r.kem.kdf1=function(e,t){Wg(this,e,0,t||e.digestLength)};_r.kem.kdf2=function(e,t){Wg(this,e,1,t||e.digestLength)};function Wg(e,t,r,n){e.generate=function(a,s){for(var i=new _r.util.ByteBuffer,o=Math.ceil(s/n)+r,c=new _r.util.ByteBuffer,u=r;u<o;++u){c.putInt32(u),t.start(),t.update(a+c.getBytes());var l=t.digest();i.putBytes(l.getBytes(n))}return i.truncate(i.length()-s),i.getBytes()}}var rt=Ze;rt.log=rt.log||{};rt.log.levels=["none","error","warning","info","debug","verbose","max"];var ho={},zu=[],zs=null;rt.log.LEVEL_LOCKED=2;rt.log.NO_LEVEL_CHECK=4;rt.log.INTERPOLATE=8;for(var Vn=0;Vn<rt.log.levels.length;++Vn){var Zh=rt.log.levels[Vn];ho[Zh]={index:Vn,name:Zh.toUpperCase()}}rt.log.logMessage=function(e){for(var t=ho[e.level].index,r=0;r<zu.length;++r){var n=zu[r];if(n.flags&rt.log.NO_LEVEL_CHECK)n.f(e);else{var a=ho[n.level].index;t<=a&&n.f(n,e)}}};rt.log.prepareStandard=function(e){"standard"in e||(e.standard=ho[e.level].name+" ["+e.category+"] "+e.message)};rt.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]),e.full=rt.util.format.apply(this,t)}};rt.log.prepareStandardFull=function(e){"standardFull"in e||(rt.log.prepareStandard(e),e.standardFull=e.standard)};for(var Yh=["error","warning","info","debug","verbose"],Vn=0;Vn<Yh.length;++Vn)(function(t){rt.log[t]=function(r,n){var a=Array.prototype.slice.call(arguments).slice(2),s={timestamp:new Date,level:t,category:r,message:n,arguments:a};rt.log.logMessage(s)}})(Yh[Vn]);rt.log.makeLogger=function(e){var t={flags:0,f:e};return rt.log.setLevel(t,"none"),t};rt.log.setLevel=function(e,t){var r=!1;if(e&&!(e.flags&rt.log.LEVEL_LOCKED))for(var n=0;n<rt.log.levels.length;++n){var a=rt.log.levels[n];if(t==a){e.level=t,r=!0;break}}return r};rt.log.lock=function(e,t){typeof t>"u"||t?e.flags|=rt.log.LEVEL_LOCKED:e.flags&=~rt.log.LEVEL_LOCKED};rt.log.addLogger=function(e){zu.push(e)};if(typeof console<"u"&&"log"in console){var ks;if(console.error&&console.warn&&console.info&&console.debug){var vC={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},Wd=function(e,t){rt.log.prepareStandard(t);var r=vC[t.level],n=[t.standard];n=n.concat(t.arguments.slice()),r.apply(console,n)};ks=rt.log.makeLogger(Wd)}else{var Wd=function(t,r){rt.log.prepareStandardFull(r),console.log(r.standardFull)};ks=rt.log.makeLogger(Wd)}rt.log.setLevel(ks,"debug"),rt.log.addLogger(ks),zs=ks}else console={log:function(){}};if(zs!==null&&typeof window<"u"&&window.location){var Ai=new URL(window.location.href).searchParams;if(Ai.has("console.level")&&rt.log.setLevel(zs,Ai.get("console.level").slice(-1)[0]),Ai.has("console.lock")){var bC=Ai.get("console.lock").slice(-1)[0];bC=="true"&&rt.log.lock(zs)}}rt.log.consoleLogger=zs;var ve=Ze,F=ve.asn1,yr=ve.pkcs7=ve.pkcs7||{};yr.messageFromPem=function(e){var t=ve.pem.decode(e)[0];if(t.type!=="PKCS7"){var r=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw r.headerType=t.type,r}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var n=F.fromDer(t.body);return yr.messageFromAsn1(n)};yr.messageToPem=function(e,t){var r={type:"PKCS7",body:F.toDer(e.toAsn1()).getBytes()};return ve.pem.encode(r,{maxline:t})};yr.messageFromAsn1=function(e){var t={},r=[];if(!F.validate(e,yr.asn1.contentInfoValidator,t,r)){var n=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw n.errors=r,n}var a=F.derToOid(t.contentType),s;switch(a){case ve.pki.oids.envelopedData:s=yr.createEnvelopedData();break;case ve.pki.oids.encryptedData:s=yr.createEncryptedData();break;case ve.pki.oids.signedData:s=yr.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+a+" is not (yet) supported.")}return s.fromAsn1(t.content.value[0]),s};yr.createSignedData=function(){var e=null;return e={type:ve.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(n){if(Zd(e,n,yr.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var a=e.rawCapture.certificates.value,s=0;s<a.length;++s)e.certificates.push(ve.pki.certificateFromAsn1(a[s]))},toAsn1:function(){e.contentInfo||e.sign();for(var n=[],a=0;a<e.certificates.length;++a)n.push(ve.pki.certificateToAsn1(e.certificates[a]));var s=[],i=F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(e.version).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return n.length>0&&i.value[0].value.push(F.create(F.Class.CONTEXT_SPECIFIC,0,!0,n)),s.length>0&&i.value[0].value.push(F.create(F.Class.CONTEXT_SPECIFIC,1,!0,s)),i.value[0].value.push(F.create(F.Class.UNIVERSAL,F.Type.SET,!0,e.signerInfos)),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.type).getBytes()),i])},addSigner:function(n){var a=n.issuer,s=n.serialNumber;if(n.certificate){var i=n.certificate;typeof i=="string"&&(i=ve.pki.certificateFromPem(i)),a=i.issuer.attributes,s=i.serialNumber}var o=n.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof o=="string"&&(o=ve.pki.privateKeyFromPem(o));var c=n.digestAlgorithm||ve.pki.oids.sha1;switch(c){case ve.pki.oids.sha1:case ve.pki.oids.sha256:case ve.pki.oids.sha384:case ve.pki.oids.sha512:case ve.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+c)}var u=n.authenticatedAttributes||[];if(u.length>0){for(var l=!1,d=!1,h=0;h<u.length;++h){var p=u[h];if(!l&&p.type===ve.pki.oids.contentType){if(l=!0,d)break;continue}if(!d&&p.type===ve.pki.oids.messageDigest){if(d=!0,l)break;continue}}if(!l||!d)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:o,version:1,issuer:a,serialNumber:s,digestAlgorithm:c,signatureAlgorithm:ve.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:u,unauthenticatedAttributes:[]})},sign:function(n){if(n=n||{},(typeof e.content!="object"||e.contentInfo===null)&&(e.contentInfo=F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(ve.pki.oids.data).getBytes())]),"content"in e)){var a;e.content instanceof ve.util.ByteBuffer?a=e.content.bytes():typeof e.content=="string"&&(a=ve.util.encodeUtf8(e.content)),n.detached?e.detachedContent=F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,a):e.contentInfo.value.push(F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,a)]))}if(e.signers.length!==0){var s=t();r(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(n){typeof n=="string"&&(n=ve.pki.certificateFromPem(n)),e.certificates.push(n)},addCertificateRevokationList:function(n){throw new Error("PKCS#7 CRL support not yet implemented.")}},e;function t(){for(var n={},a=0;a<e.signers.length;++a){var s=e.signers[a],i=s.digestAlgorithm;i in n||(n[i]=ve.md[ve.pki.oids[i]].create()),s.authenticatedAttributes.length===0?s.md=n[i]:s.md=ve.md[ve.pki.oids[i]].create()}e.digestAlgorithmIdentifiers=[];for(var i in n)e.digestAlgorithmIdentifiers.push(F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(i).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")]));return n}function r(n){var a;if(e.detachedContent?a=e.detachedContent:(a=e.contentInfo.value[1],a=a.value[0]),!a)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=F.derToOid(e.contentInfo.value[0].value),i=F.toDer(a);i.getByte(),F.getBerValueLength(i),i=i.getBytes();for(var o in n)n[o].start().update(i);for(var c=new Date,u=0;u<e.signers.length;++u){var l=e.signers[u];if(l.authenticatedAttributes.length===0){if(s!==ve.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{l.authenticatedAttributesAsn1=F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var d=F.create(F.Class.UNIVERSAL,F.Type.SET,!0,[]),h=0;h<l.authenticatedAttributes.length;++h){var p=l.authenticatedAttributes[h];p.type===ve.pki.oids.messageDigest?p.value=n[l.digestAlgorithm].digest():p.type===ve.pki.oids.signingTime&&(p.value||(p.value=c)),d.value.push(Gu(p)),l.authenticatedAttributesAsn1.value.push(Gu(p))}i=F.toDer(d).getBytes(),l.md.start().update(i)}l.signature=l.key.sign(l.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=TC(e.signers)}};yr.createEncryptedData=function(){var e=null;return e={type:ve.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:ve.pki.oids["aes256-CBC"]},fromAsn1:function(t){Zd(e,t,yr.asn1.encryptedDataValidator)},decrypt:function(t){t!==void 0&&(e.encryptedContent.key=t),Zg(e)}},e};yr.createEnvelopedData=function(){var e=null;return e={type:ve.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:ve.pki.oids["aes256-CBC"]},fromAsn1:function(t){var r=Zd(e,t,yr.asn1.envelopedDataValidator);e.recipients=EC(r.recipientInfos.value)},toAsn1:function(){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.type).getBytes()),F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(e.version).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SET,!0,xC(e.recipients)),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,$C(e.encryptedContent))])])])},findRecipient:function(t){for(var r=t.issuer.attributes,n=0;n<e.recipients.length;++n){var a=e.recipients[n],s=a.issuer;if(a.serialNumber===t.serialNumber&&s.length===r.length){for(var i=!0,o=0;o<r.length;++o)if(s[o].type!==r[o].type||s[o].value!==r[o].value){i=!1;break}if(i)return a}}return null},decrypt:function(t,r){if(e.encryptedContent.key===void 0&&t!==void 0&&r!==void 0)switch(t.encryptedContent.algorithm){case ve.pki.oids.rsaEncryption:case ve.pki.oids.desCBC:var n=r.decrypt(t.encryptedContent.content);e.encryptedContent.key=ve.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}Zg(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:ve.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(e.encryptedContent.content===void 0){r=r||e.encryptedContent.algorithm,t=t||e.encryptedContent.key;var n,a,s;switch(r){case ve.pki.oids["aes128-CBC"]:n=16,a=16,s=ve.aes.createEncryptionCipher;break;case ve.pki.oids["aes192-CBC"]:n=24,a=16,s=ve.aes.createEncryptionCipher;break;case ve.pki.oids["aes256-CBC"]:n=32,a=16,s=ve.aes.createEncryptionCipher;break;case ve.pki.oids["des-EDE3-CBC"]:n=24,a=8,s=ve.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(t===void 0)t=ve.util.createBuffer(ve.random.getBytes(n));else if(t.length()!=n)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+n+".");e.encryptedContent.algorithm=r,e.encryptedContent.key=t,e.encryptedContent.parameter=ve.util.createBuffer(ve.random.getBytes(a));var i=s(t);if(i.start(e.encryptedContent.parameter.copy()),i.update(e.content),!i.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=i.output}for(var o=0;o<e.recipients.length;++o){var c=e.recipients[o];if(c.encryptedContent.content===void 0)switch(c.encryptedContent.algorithm){case ve.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}},e};function CC(e){var t={},r=[];if(!F.validate(e,yr.asn1.recipientInfoValidator,t,r)){var n=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw n.errors=r,n}return{version:t.version.charCodeAt(0),issuer:ve.pki.RDNAttributesAsArray(t.issuer),serialNumber:ve.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:F.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function SC(e){return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(e.version).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[ve.pki.distinguishedNameToAsn1({attributes:e.issuer}),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ve.util.hexToBytes(e.serialNumber))]),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.encryptedContent.algorithm).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")]),F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function EC(e){for(var t=[],r=0;r<e.length;++r)t.push(CC(e[r]));return t}function xC(e){for(var t=[],r=0;r<e.length;++r)t.push(SC(e[r]));return t}function wC(e){var t=F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,F.integerToDer(e.version).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[ve.pki.distinguishedNameToAsn1({attributes:e.issuer}),F.create(F.Class.UNIVERSAL,F.Type.INTEGER,!1,ve.util.hexToBytes(e.serialNumber))]),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.digestAlgorithm).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.signatureAlgorithm).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.NULL,!1,"")])),t.value.push(F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var r=F.create(F.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<e.unauthenticatedAttributes.length;++n){var a=e.unauthenticatedAttributes[n];r.values.push(Gu(a))}t.value.push(r)}return t}function TC(e){for(var t=[],r=0;r<e.length;++r)t.push(wC(e[r]));return t}function Gu(e){var t;if(e.type===ve.pki.oids.contentType)t=F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.value).getBytes());else if(e.type===ve.pki.oids.messageDigest)t=F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===ve.pki.oids.signingTime){var r=new Date("1950-01-01T00:00:00Z"),n=new Date("2050-01-01T00:00:00Z"),a=e.value;if(typeof a=="string"){var s=Date.parse(a);isNaN(s)?a.length===13?a=F.utcTimeToDate(a):a=F.generalizedTimeToDate(a):a=new Date(s)}a>=r&&a<n?t=F.create(F.Class.UNIVERSAL,F.Type.UTCTIME,!1,F.dateToUtcTime(a)):t=F.create(F.Class.UNIVERSAL,F.Type.GENERALIZEDTIME,!1,F.dateToGeneralizedTime(a))}return F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.type).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SET,!0,[t])])}function $C(e){return[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(ve.pki.oids.data).getBytes()),F.create(F.Class.UNIVERSAL,F.Type.SEQUENCE,!0,[F.create(F.Class.UNIVERSAL,F.Type.OID,!1,F.oidToDer(e.algorithm).getBytes()),e.parameter?F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.parameter.getBytes()):void 0]),F.create(F.Class.CONTEXT_SPECIFIC,0,!0,[F.create(F.Class.UNIVERSAL,F.Type.OCTETSTRING,!1,e.content.getBytes())])]}function Zd(e,t,r){var n={},a=[];if(!F.validate(t,r,n,a)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var i=F.derToOid(n.contentType);if(i!==ve.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var o="";if(ve.util.isArray(n.encryptedContent))for(var c=0;c<n.encryptedContent.length;++c){if(n.encryptedContent[c].type!==F.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=n.encryptedContent[c].value}else o=n.encryptedContent;e.encryptedContent={algorithm:F.derToOid(n.encAlgorithm),parameter:ve.util.createBuffer(n.encParameter.value),content:ve.util.createBuffer(o)}}if(n.content){var o="";if(ve.util.isArray(n.content))for(var c=0;c<n.content.length;++c){if(n.content[c].type!==F.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=n.content[c].value}else o=n.content;e.content=ve.util.createBuffer(o)}return e.version=n.version.charCodeAt(0),e.rawCapture=n,n}function Zg(e){if(e.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(e.content===void 0){var t;switch(e.encryptedContent.algorithm){case ve.pki.oids["aes128-CBC"]:case ve.pki.oids["aes192-CBC"]:case ve.pki.oids["aes256-CBC"]:t=ve.aes.createDecryptionCipher(e.encryptedContent.key);break;case ve.pki.oids.desCBC:case ve.pki.oids["des-EDE3-CBC"]:t=ve.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}var jt=Ze,qo=jt.ssh=jt.ssh||{};qo.privateKeyToPutty=function(e,t,r){r=r||"",t=t||"";var n="ssh-rsa",a=t===""?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: "+n+`\r
`;s+="Encryption: "+a+`\r
`,s+="Comment: "+r+`\r
`;var i=jt.util.createBuffer();za(i,n),Jr(i,e.e),Jr(i,e.n);var o=jt.util.encode64(i.bytes(),64),c=Math.floor(o.length/66)+1;s+="Public-Lines: "+c+`\r
`,s+=o;var u=jt.util.createBuffer();Jr(u,e.d),Jr(u,e.p),Jr(u,e.q),Jr(u,e.qInv);var l;if(!t)l=jt.util.encode64(u.bytes(),64);else{var d=u.length()+16-1;d-=d%16;var h=Ii(u.bytes());h.truncate(h.length()-d+u.length()),u.putBuffer(h);var p=jt.util.createBuffer();p.putBuffer(Ii("\0\0\0\0",t)),p.putBuffer(Ii("\0\0\0",t));var f=jt.aes.createEncryptionCipher(p.truncate(8),"CBC");f.start(jt.util.createBuffer().fillWithByte(0,16)),f.update(u.copy()),f.finish();var g=f.output;g.truncate(16),l=jt.util.encode64(g.bytes(),64)}c=Math.floor(l.length/66)+1,s+=`\r
Private-Lines: `+c+`\r
`,s+=l;var y=Ii("putty-private-key-file-mac-key",t),b=jt.util.createBuffer();za(b,n),za(b,a),za(b,r),b.putInt32(i.length()),b.putBuffer(i),b.putInt32(u.length()),b.putBuffer(u);var m=jt.hmac.create();return m.start("sha1",y),m.update(b.bytes()),s+=`\r
Private-MAC: `+m.digest().toHex()+`\r
`,s};qo.publicKeyToOpenSSH=function(e,t){var r="ssh-rsa";t=t||"";var n=jt.util.createBuffer();return za(n,r),Jr(n,e.e),Jr(n,e.n),r+" "+jt.util.encode64(n.bytes())+" "+t};qo.privateKeyToOpenSSH=function(e,t){return t?jt.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):jt.pki.privateKeyToPem(e)};qo.getPublicKeyFingerprint=function(e,t){t=t||{};var r=t.md||jt.md.md5.create(),n="ssh-rsa",a=jt.util.createBuffer();za(a,n),Jr(a,e.e),Jr(a,e.n),r.start(),r.update(a.getBytes());var s=r.digest();if(t.encoding==="hex"){var i=s.toHex();return t.delimiter?i.match(/.{2}/g).join(t.delimiter):i}else{if(t.encoding==="binary")return s.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return s};function Jr(e,t){var r=t.toString(16);r[0]>="8"&&(r="00"+r);var n=jt.util.hexToBytes(r);e.putInt32(n.length),e.putBytes(n)}function za(e,t){e.putInt32(t.length),e.putString(t)}function Ii(){for(var e=jt.md.sha1.create(),t=arguments.length,r=0;r<t;++r)e.update(arguments[r]);return e.digest()}var AC=Ze;const cu=us(AC),Qa="S1C4RX1111AM2892021",Cr=new sg(typeof window<"u"?localStorage:null,{hash:function(e){return e=jn.SHA256(e,{SECRET_KEY:Qa}),e.toString()},encrypt:function(e){return e=jn.AES.encrypt(e,Qa),e=e.toString(),e},decrypt:function(e){return e=jn.AES.decrypt(e,Qa),e=e.toString(jn.enc.Utf8),e}}),me=new sg(typeof window<"u"?sessionStorage:null,{hash:function(e){return e=jn.SHA256(e,{SECRET_KEY:Qa}),e.toString()},encrypt:function(e){return e=jn.AES.encrypt(e,Qa),e=e.toString(),e},decrypt:function(e){return e=jn.AES.decrypt(e,Qa),e=e.toString(jn.enc.Utf8),e}});function IC(e,t){const r=`-----BEGIN PUBLIC KEY-----${t}-----END PUBLIC KEY-----`,n=cu.pki.publicKeyFromPem(r),a=cu.util.encodeUtf8(e),s=n.encrypt(a);return cu.util.encode64(s)}function Qu(e){this.message=e}Qu.prototype=new Error,Qu.prototype.name="InvalidCharacterError";var Xh=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new Qu("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,a=0,s=0,i="";n=t.charAt(s++);~n&&(r=a%4?64*r+n:n,a++%4)?i+=String.fromCharCode(255&r>>(-2*a&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return i};function PC(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(r){return decodeURIComponent(Xh(r).replace(/(.)/g,function(n,a){var s=a.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}(t)}catch{return Xh(t)}}function po(e){this.message=e}function cn(e,t){if(typeof e!="string")throw new po("Invalid token specified");var r=(t=t||{}).header===!0?0:1;try{return JSON.parse(PC(e.split(".")[r]))}catch(n){throw new po("Invalid token specified: "+n.message)}}po.prototype=new Error,po.prototype.name="InvalidTokenError";const Jh=e=>{let t;const r=new Set,n=(i,o)=>{const c=typeof i=="function"?i(t):i;if(!Object.is(c,t)){const u=t;t=o??typeof c!="object"?c:Object.assign({},t,c),r.forEach(l=>l(t,u))}},a=()=>t,s={setState:n,getState:a,subscribe:i=>(r.add(i),()=>r.delete(i)),destroy:()=>r.clear()};return t=e(n,a,s),s},_C=e=>e?Jh(e):Jh;var Yg={exports:{}},uu={},ep={exports:{}},lu={};/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var tp;function DC(){if(tp)return lu;tp=1;var e=Pd;function t(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,a=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function o(d,h){var p=h(),f=n({inst:{value:p,getSnapshot:h}}),g=f[0].inst,y=f[1];return s(function(){g.value=p,g.getSnapshot=h,c(g)&&y({inst:g})},[d,p,h]),a(function(){return c(g)&&y({inst:g}),d(function(){c(g)&&y({inst:g})})},[d]),i(p),p}function c(d){var h=d.getSnapshot;d=d.value;try{var p=h();return!r(d,p)}catch{return!0}}function u(d,h){return h()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:o;return lu.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:l,lu}var rp;function RC(){return rp||(rp=1,ep.exports=DC()),ep.exports}/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var np;function NC(){if(np)return uu;np=1;var e=Pd,t=RC();function r(u,l){return u===l&&(u!==0||1/u===1/l)||u!==u&&l!==l}var n=typeof Object.is=="function"?Object.is:r,a=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,o=e.useMemo,c=e.useDebugValue;return uu.useSyncExternalStoreWithSelector=function(u,l,d,h,p){var f=s(null);if(f.current===null){var g={hasValue:!1,value:null};f.current=g}else g=f.current;f=o(function(){function b(E){if(!m){if(m=!0,v=E,E=h(E),p!==void 0&&g.hasValue){var w=g.value;if(p(w,E))return S=w}return S=E}if(w=S,n(v,E))return w;var _=h(E);return p!==void 0&&p(w,_)?w:(v=E,S=_)}var m=!1,v,S,C=d===void 0?null:d;return[function(){return b(l())},C===null?void 0:function(){return b(C())}]},[l,d,h,p]);var y=a(u,f[0],f[1]);return i(function(){g.hasValue=!0,g.value=y},[y]),c(y),y},uu}Yg.exports=NC();var BC=Yg.exports;const kC=us(BC),{useSyncExternalStoreWithSelector:OC}=kC;function UC(e,t=e.getState,r){const n=OC(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return Gn.useDebugValue(n),n}const ap=e=>{const t=typeof e=="function"?_C(e):e,r=(n,a)=>UC(t,n,a);return Object.assign(r,t),r},Ae=e=>e?ap(e):ap;var du={VITE_BASE_URL:"https://api.sicarx.com/",VITE_BASE_URL_AWS:"https://7ew5wkc4jsnbb6ph2bd2r4o5540hqlea.lambda-url.us-east-1.on.aws",VITE_BASE_URL_AWS_SUBSCRIPTIONS:"https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws",VITE_BASE_URL_HISTORY:"https://us-central1-sx-production.cloudfunctions.net/history/v1/account",VITE_EA_URL_REGISTRY:"https://ea.sicarx.com/v1/registry",VITE_BASE_URL_AWS_CHIPS:"https://us-central1-sx-production.cloudfunctions.net",VITE_BASE_URL_WEB_SERVER:"https://backend-dot-sicar-x.uc.r.appspot.com/",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const LC=(e,t={})=>(r,n,a)=>{const{enabled:s,anonymousActionType:i,...o}=t;let c;try{c=(s??(du&&"production")!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(du&&"production")!=="production"&&s&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),e(r,n,a);const u=c.connect(o);let l=!0;a.setState=(p,f,g)=>{const y=r(p,f);return l&&u.send(g===void 0?{type:i||"anonymous"}:typeof g=="string"?{type:g}:g,n()),y};const d=(...p)=>{const f=l;l=!1,r(...p),l=f},h=e(a.setState,n,a);if(u.init(h),a.dispatchFromDevtools&&typeof a.dispatch=="function"){let p=!1;const f=a.dispatch;a.dispatch=(...g)=>{(du&&"production")!=="production"&&g[0].type==="__setState"&&!p&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),p=!0),f(...g)}}return u.subscribe(p=>{var f;switch(p.type){case"ACTION":if(typeof p.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return hu(p.payload,g=>{if(g.type==="__setState"){d(g.state);return}a.dispatchFromDevtools&&typeof a.dispatch=="function"&&a.dispatch(g)});case"DISPATCH":switch(p.payload.type){case"RESET":return d(h),u.init(a.getState());case"COMMIT":return u.init(a.getState());case"ROLLBACK":return hu(p.state,g=>{d(g),u.init(a.getState())});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return hu(p.state,g=>{d(g)});case"IMPORT_STATE":{const{nextLiftedState:g}=p.payload,y=(f=g.computedStates.slice(-1)[0])==null?void 0:f.state;if(!y)return;d(y),u.send(null,g);return}case"PAUSE_RECORDING":return l=!l}return}}),h},Be=LC,hu=(e,t)=>{let r;try{r=JSON.parse(e)}catch(n){console.error("[zustand devtools middleware] Could not parse the received json",n)}r!==void 0&&t(r)},fo=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(n){return fo(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return fo(n)(r)}}}},MC=(e,t)=>(r,n,a)=>{let s={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:y=>y,version:0,merge:(y,b)=>({...b,...y}),...t},i=!1;const o=new Set,c=new Set;let u;try{u=s.getStorage()}catch{}if(!u)return e((...y)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),r(...y)},n,a);const l=fo(s.serialize),d=()=>{const y=s.partialize({...n()});let b;const m=l({state:y,version:s.version}).then(v=>u.setItem(s.name,v)).catch(v=>{b=v});if(b)throw b;return m},h=a.setState;a.setState=(y,b)=>{h(y,b),d()};const p=e((...y)=>{r(...y),d()},n,a);let f;const g=()=>{var y;if(!u)return;i=!1,o.forEach(m=>m(n()));const b=((y=s.onRehydrateStorage)==null?void 0:y.call(s,n()))||void 0;return fo(u.getItem.bind(u))(s.name).then(m=>{if(m)return s.deserialize(m)}).then(m=>{if(m)if(typeof m.version=="number"&&m.version!==s.version){if(s.migrate)return s.migrate(m.state,m.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return m.state}).then(m=>{var v;return f=s.merge(m,(v=n())!=null?v:p),r(f,!0),d()}).then(()=>{b==null||b(f,void 0),i=!0,c.forEach(m=>m(f))}).catch(m=>{b==null||b(void 0,m)})};return a.persist={setOptions:y=>{s={...s,...y},y.getStorage&&(u=y.getStorage())},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:y=>(o.add(y),()=>{o.delete(y)}),onFinishHydration:y=>(c.add(y),()=>{c.delete(y)})},g(),f||p},Oe=MC,Et=typeof localStorage.getItem("fakeApi")=="string"&&localStorage.getItem("fakeApi")!==""?localStorage.getItem("fakeApi")??"":"https://api.sicarx.com/",dt="/agent/v1",Yt="/account/v1",jC="/login/v1",FC="/logout",Xg="documents/v1/client-payment",Rr="cfdi/v1",fs="pdf/v1",De="/company/v1",Pn="/catalogue/v1",we="/settings/v1",hi="documents/v1",We="/sales-reports/v1",qC="/sale/v1",_a="/cashregister-queries/v1",gs="/cashregisterbalancing-queries/v1",Da="/cashregister/v1",It="/graph/v1/",_n="document-graph/v1/graph-v2",hn="/subscription/v1",Ra="/mitec/v1",HC="/tax/v1",Jg="/documents/v1",Yd="/documents/v1",dr="tables/v1",em="dashboards/v1/",yt="rps/v1/",KC="stock-reports/v1/",Ho="order/v1",ra="/document-graph/v1/graph-v2",VC="/document-graph/v1",tm="/settings/v1/graphQL",sp=["/account/v1/extern/pin","/login/v1/account","/login/v1/login","/account/v1/account/complete","/company/v1/login","/account/v1/login/google","/account/v1/login/facebook","/account/v1/login/firebase","/account/v1/login/apple","/catalogue/v1/country/list","/account/v1/account/recovery","prices/v1/priceList/selection","prices/v1/priceList/list","/account/v1/firebase","/company/v1/user/pin"],ip=["/config","/login/v1/history/sessions/account","/company/v1/businessType/list","/company/v1/country/list","/company/v1/company/list","/company/v1/company/logo","/company/v1/branchOffice/list","/company/v1/company","/account/v1/config","/account/v1/account","/account/v1/account/logo","/account/v1/account/resend","/account/v1/account/checkStatus","/account/v1/history/sessions/account","/account/v1/account/secret","/account/v1/invoiceInfo/list","/account/v1/invoiceInfo/predeterminate","/account/v1/invoiceInfo","/catalogue/v1/satCatalogue/useCfdi/list","/catalogue/v1/businessType/list","/catalogue/v1/currency/list","/subscription-handler/v1/configProduct/active","/subscription/v1/subscription/token","/subscription/v1/payments/charge/token","/subscription/v1/payments/customer","/subscription/v1/payments/customer/card","/subscription/v1/payments/charge/subscription","/subscription/v1/payments/customer/card/lists","/dashboards/v1/","https://us-central1-sicar-x.cloudfunctions.net/history/v1/account","https://us-central1-sx-production.cloudfunctions.net/history/v1/account","/company/v1/company/invite","/company/v1/company/hide"];function rm(e,t){return function(){return e.apply(t,arguments)}}const{toString:nm}=Object.prototype,{getPrototypeOf:Xd}=Object,Jd=(e=>t=>{const r=nm.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Dn=e=>(e=e.toLowerCase(),t=>Jd(t)===e),Ko=e=>t=>typeof t===e,{isArray:ms}=Array,Js=Ko("undefined");function zC(e){return e!==null&&!Js(e)&&e.constructor!==null&&!Js(e.constructor)&&Sa(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const am=Dn("ArrayBuffer");function GC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&am(e.buffer),t}const QC=Ko("string"),Sa=Ko("function"),sm=Ko("number"),e0=e=>e!==null&&typeof e=="object",WC=e=>e===!0||e===!1,qi=e=>{if(Jd(e)!=="object")return!1;const t=Xd(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},ZC=Dn("Date"),YC=Dn("File"),XC=Dn("Blob"),JC=Dn("FileList"),eS=e=>e0(e)&&Sa(e.pipe),tS=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||nm.call(e)===t||Sa(e.toString)&&e.toString()===t)},rS=Dn("URLSearchParams"),nS=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pi(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,a;if(typeof e!="object"&&(e=[e]),ms(e))for(n=0,a=e.length;n<a;n++)t.call(null,e[n],n,e);else{const s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let o;for(n=0;n<i;n++)o=s[n],t.call(null,e[o],o,e)}}function im(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,a;for(;n-- >0;)if(a=r[n],t===a.toLowerCase())return a;return null}const om=typeof self>"u"?typeof global>"u"?void 0:global:self,cm=e=>!Js(e)&&e!==om;function Wu(){const{caseless:e}=cm(this)&&this||{},t={},r=(n,a)=>{const s=e&&im(t,a)||a;qi(t[s])&&qi(n)?t[s]=Wu(t[s],n):qi(n)?t[s]=Wu({},n):ms(n)?t[s]=n.slice():t[s]=n};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&pi(arguments[n],r);return t}const aS=(e,t,r,{allOwnKeys:n}={})=>(pi(t,(a,s)=>{r&&Sa(a)?e[s]=rm(a,r):e[s]=a},{allOwnKeys:n}),e),sS=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),iS=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},oS=(e,t,r,n)=>{let a,s,i;const o={};if(t=t||{},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),s=a.length;s-- >0;)i=a[s],(!n||n(i,e,t))&&!o[i]&&(t[i]=e[i],o[i]=!0);e=r!==!1&&Xd(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},cS=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},uS=e=>{if(!e)return null;if(ms(e))return e;let t=e.length;if(!sm(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},lS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Xd(Uint8Array)),dS=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const a=n.value;t.call(e,a[0],a[1])}},hS=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},pS=Dn("HTMLFormElement"),fS=e=>e.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(t,r,n){return r.toUpperCase()+n}),op=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),gS=Dn("RegExp"),um=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};pi(r,(a,s)=>{t(a,s,e)!==!1&&(n[s]=a)}),Object.defineProperties(e,n)},mS=e=>{um(e,(t,r)=>{if(Sa(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(Sa(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},yS=(e,t)=>{const r={},n=a=>{a.forEach(s=>{r[s]=!0})};return ms(e)?n(e):n(String(e).split(t)),r},vS=()=>{},bS=(e,t)=>(e=+e,Number.isFinite(e)?e:t),CS=e=>{const t=new Array(10),r=(n,a)=>{if(e0(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[a]=n;const s=ms(n)?[]:{};return pi(n,(i,o)=>{const c=r(i,a+1);!Js(c)&&(s[o]=c)}),t[a]=void 0,s}}return n};return r(e,0)},oe={isArray:ms,isArrayBuffer:am,isBuffer:zC,isFormData:tS,isArrayBufferView:GC,isString:QC,isNumber:sm,isBoolean:WC,isObject:e0,isPlainObject:qi,isUndefined:Js,isDate:ZC,isFile:YC,isBlob:XC,isRegExp:gS,isFunction:Sa,isStream:eS,isURLSearchParams:rS,isTypedArray:lS,isFileList:JC,forEach:pi,merge:Wu,extend:aS,trim:nS,stripBOM:sS,inherits:iS,toFlatObject:oS,kindOf:Jd,kindOfTest:Dn,endsWith:cS,toArray:uS,forEachEntry:dS,matchAll:hS,isHTMLForm:pS,hasOwnProperty:op,hasOwnProp:op,reduceDescriptors:um,freezeMethods:mS,toObjectSet:yS,toCamelCase:fS,noop:vS,toFiniteNumber:bS,findKey:im,global:om,isContextDefined:cm,toJSONObject:CS};function ct(e,t,r,n,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),a&&(this.response=a)}oe.inherits(ct,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:oe.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const lm=ct.prototype,dm={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{dm[e]={value:e}});Object.defineProperties(ct,dm);Object.defineProperty(lm,"isAxiosError",{value:!0});ct.from=(e,t,r,n,a,s)=>{const i=Object.create(lm);return oe.toFlatObject(e,i,function(o){return o!==Error.prototype},o=>o!=="isAxiosError"),ct.call(i,e.message,t,r,n,a),i.cause=e,i.name=e.name,s&&Object.assign(i,s),i};var SS=typeof self=="object"?self.FormData:window.FormData;const ES=us(SS);function Zu(e){return oe.isPlainObject(e)||oe.isArray(e)}function hm(e){return oe.endsWith(e,"[]")?e.slice(0,-2):e}function cp(e,t,r){return e?e.concat(t).map(function(n,a){return n=hm(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function xS(e){return oe.isArray(e)&&!e.some(Zu)}const wS=oe.toFlatObject(oe,{},null,function(e){return/^is[A-Z]/.test(e)});function TS(e){return e&&oe.isFunction(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator]}function Vo(e,t,r){if(!oe.isObject(e))throw new TypeError("target must be an object");t=t||new(ES||FormData),r=oe.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,f){return!oe.isUndefined(f[p])});const n=r.metaTokens,a=r.visitor||u,s=r.dots,i=r.indexes,o=(r.Blob||typeof Blob<"u"&&Blob)&&TS(t);if(!oe.isFunction(a))throw new TypeError("visitor must be a function");function c(p){if(p===null)return"";if(oe.isDate(p))return p.toISOString();if(!o&&oe.isBlob(p))throw new ct("Blob is not supported. Use a Buffer instead.");return oe.isArrayBuffer(p)||oe.isTypedArray(p)?o&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,f,g){let y=p;if(p&&!g&&typeof p=="object"){if(oe.endsWith(f,"{}"))f=n?f:f.slice(0,-2),p=JSON.stringify(p);else if(oe.isArray(p)&&xS(p)||oe.isFileList(p)||oe.endsWith(f,"[]")&&(y=oe.toArray(p)))return f=hm(f),y.forEach(function(b,m){!(oe.isUndefined(b)||b===null)&&t.append(i===!0?cp([f],m,s):i===null?f:f+"[]",c(b))}),!1}return Zu(p)?!0:(t.append(cp(g,f,s),c(p)),!1)}const l=[],d=Object.assign(wS,{defaultVisitor:u,convertValue:c,isVisitable:Zu});function h(p,f){if(!oe.isUndefined(p)){if(l.indexOf(p)!==-1)throw Error("Circular reference detected in "+f.join("."));l.push(p),oe.forEach(p,function(g,y){(!(oe.isUndefined(g)||g===null)&&a.call(t,g,oe.isString(y)?y.trim():y,f,d))===!0&&h(g,f?f.concat(y):[y])}),l.pop()}}if(!oe.isObject(e))throw new TypeError("data must be an object");return h(e),t}function up(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function t0(e,t){this._pairs=[],e&&Vo(e,this,t)}const pm=t0.prototype;pm.append=function(e,t){this._pairs.push([e,t])};pm.toString=function(e){const t=e?function(r){return e.call(this,r,up)}:up;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function $S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function fm(e,t,r){if(!t)return e;const n=r&&r.encode||$S,a=r&&r.serialize;let s;if(a?s=a(t,r):s=oe.isURLSearchParams(t)?t.toString():new t0(t,r).toString(n),s){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}let lp=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){oe.forEach(this.handlers,function(r){r!==null&&t(r)})}};const gm={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},AS=typeof URLSearchParams<"u"?URLSearchParams:t0,IS=FormData,PS=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),_S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",on={isBrowser:!0,classes:{URLSearchParams:AS,FormData:IS,Blob},isStandardBrowserEnv:PS,isStandardBrowserWebWorkerEnv:_S,protocols:["http","https","file","blob","url","data"]};function DS(e,t){return Vo(e,new on.classes.URLSearchParams,Object.assign({visitor:function(r,n,a,s){return on.isNode&&oe.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},t))}function RS(e){return oe.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function NS(e){const t={},r=Object.keys(e);let n;const a=r.length;let s;for(n=0;n<a;n++)s=r[n],t[s]=e[s];return t}function mm(e){function t(r,n,a,s){let i=r[s++];const o=Number.isFinite(+i),c=s>=r.length;return i=!i&&oe.isArray(a)?a.length:i,c?(oe.hasOwnProp(a,i)?a[i]=[a[i],n]:a[i]=n,!o):((!a[i]||!oe.isObject(a[i]))&&(a[i]=[]),t(r,n,a[i],s)&&oe.isArray(a[i])&&(a[i]=NS(a[i])),!o)}if(oe.isFormData(e)&&oe.isFunction(e.entries)){const r={};return oe.forEachEntry(e,(n,a)=>{t(RS(n),a,r,0)}),r}return null}const BS={"Content-Type":void 0};function kS(e,t,r){if(oe.isString(e))try{return(t||JSON.parse)(e),oe.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const ys={transitional:gm,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,a=oe.isObject(e);if(a&&oe.isHTMLForm(e)&&(e=new FormData(e)),oe.isFormData(e))return n&&n?JSON.stringify(mm(e)):e;if(oe.isArrayBuffer(e)||oe.isBuffer(e)||oe.isStream(e)||oe.isFile(e)||oe.isBlob(e))return e;if(oe.isArrayBufferView(e))return e.buffer;if(oe.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(a){if(r.indexOf("application/x-www-form-urlencoded")>-1)return DS(e,this.formSerializer).toString();if((s=oe.isFileList(e))||r.indexOf("multipart/form-data")>-1){const i=this.env&&this.env.FormData;return Vo(s?{"files[]":e}:e,i&&new i,this.formSerializer)}}return a||n?(t.setContentType("application/json",!1),kS(e)):e}],transformResponse:[function(e){const t=this.transitional||ys.transitional,r=t&&t.forcedJSONParsing,n=this.responseType==="json";if(e&&oe.isString(e)&&(r&&!this.responseType||n)){const a=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(s){if(a)throw s.name==="SyntaxError"?ct.from(s,ct.ERR_BAD_RESPONSE,this,null,this.response):s}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:on.classes.FormData,Blob:on.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};oe.forEach(["delete","get","head"],function(e){ys.headers[e]={}});oe.forEach(["post","put","patch"],function(e){ys.headers[e]=oe.merge(BS)});const OS=oe.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),US=e=>{const t={};let r,n,a;return e&&e.split(`
`).forEach(function(s){a=s.indexOf(":"),r=s.substring(0,a).trim().toLowerCase(),n=s.substring(a+1).trim(),!(!r||t[r]&&OS[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t},dp=Symbol("internals");function Os(e){return e&&String(e).trim().toLowerCase()}function Hi(e){return e===!1||e==null?e:oe.isArray(e)?e.map(Hi):String(e)}function LS(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}function MS(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function hp(e,t,r,n){if(oe.isFunction(n))return n.call(this,t,r);if(oe.isString(t)){if(oe.isString(n))return t.indexOf(n)!==-1;if(oe.isRegExp(n))return n.test(t)}}function jS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function FS(e,t){const r=oe.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(a,s,i){return this[n].call(this,t,a,s,i)},configurable:!0})})}let Mr=class{constructor(t){t&&this.set(t)}set(t,r,n){const a=this;function s(o,c,u){const l=Os(c);if(!l)throw new Error("header name must be a non-empty string");const d=oe.findKey(a,l);(!d||a[d]===void 0||u===!0||u===void 0&&a[d]!==!1)&&(a[d||c]=Hi(o))}const i=(o,c)=>oe.forEach(o,(u,l)=>s(u,l,c));return oe.isPlainObject(t)||t instanceof this.constructor?i(t,r):oe.isString(t)&&(t=t.trim())&&!MS(t)?i(US(t),r):t!=null&&s(r,t,n),this}get(t,r){if(t=Os(t),t){const n=oe.findKey(this,t);if(n){const a=this[n];if(!r)return a;if(r===!0)return LS(a);if(oe.isFunction(r))return r.call(this,a,n);if(oe.isRegExp(r))return r.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Os(t),t){const n=oe.findKey(this,t);return!!(n&&(!r||hp(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let a=!1;function s(i){if(i=Os(i),i){const o=oe.findKey(n,i);o&&(!r||hp(n,n[o],o,r))&&(delete n[o],a=!0)}}return oe.isArray(t)?t.forEach(s):s(t),a}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const r=this,n={};return oe.forEach(this,(a,s)=>{const i=oe.findKey(n,s);if(i){r[i]=Hi(a),delete r[s];return}const o=t?jS(s):String(s).trim();o!==s&&delete r[s],r[o]=Hi(a),n[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return oe.forEach(this,(n,a)=>{n!=null&&n!==!1&&(r[a]=t&&oe.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(a=>n.set(a)),n}static accessor(t){const r=(this[dp]=this[dp]={accessors:{}}).accessors,n=this.prototype;function a(s){const i=Os(s);r[i]||(FS(n,s),r[i]=!0)}return oe.isArray(t)?t.forEach(a):a(t),this}};Mr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]);oe.freezeMethods(Mr.prototype);oe.freezeMethods(Mr);function pu(e,t){const r=this||ys,n=t||r,a=Mr.from(n.headers);let s=n.data;return oe.forEach(e,function(i){s=i.call(r,s,a.normalize(),t?t.status:void 0)}),a.normalize(),s}function ym(e){return!!(e&&e.__CANCEL__)}function fi(e,t,r){ct.call(this,e??"canceled",ct.ERR_CANCELED,t,r),this.name="CanceledError"}oe.inherits(fi,ct,{__CANCEL__:!0});const qS=null;function HS(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new ct("Request failed with status code "+r.status,[ct.ERR_BAD_REQUEST,ct.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}const KS=on.isStandardBrowserEnv?function(){return{write:function(e,t,r,n,a,s){const i=[];i.push(e+"="+encodeURIComponent(t)),oe.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),oe.isString(n)&&i.push("path="+n),oe.isString(a)&&i.push("domain="+a),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read:function(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function VS(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function zS(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function vm(e,t){return e&&!VS(t)?zS(e,t):t}const GS=on.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function n(a){let s=a;return e&&(t.setAttribute("href",s),s=t.href),t.setAttribute("href",s),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(a){const s=oe.isString(a)?n(a):a;return s.protocol===r.protocol&&s.host===r.host}}():function(){return function(){return!0}}();function QS(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function WS(e,t){e=e||10;const r=new Array(e),n=new Array(e);let a=0,s=0,i;return t=t!==void 0?t:1e3,function(o){const c=Date.now(),u=n[s];i||(i=c),r[a]=o,n[a]=c;let l=s,d=0;for(;l!==a;)d+=r[l++],l=l%e;if(a=(a+1)%e,a===s&&(s=(s+1)%e),c-i<t)return;const h=u&&c-u;return h?Math.round(d*1e3/h):void 0}}function pp(e,t){let r=0;const n=WS(50,250);return a=>{const s=a.loaded,i=a.lengthComputable?a.total:void 0,o=s-r,c=n(o),u=s<=i;r=s;const l={loaded:s,total:i,progress:i?s/i:void 0,bytes:o,rate:c||void 0,estimated:c&&i&&u?(i-s)/c:void 0,event:a};l[t?"download":"upload"]=!0,e(l)}}const ZS=typeof XMLHttpRequest<"u",YS=ZS&&function(e){return new Promise(function(t,r){let n=e.data;const a=Mr.from(e.headers).normalize(),s=e.responseType;let i;function o(){e.cancelToken&&e.cancelToken.unsubscribe(i),e.signal&&e.signal.removeEventListener("abort",i)}oe.isFormData(n)&&(on.isStandardBrowserEnv||on.isStandardBrowserWebWorkerEnv)&&a.setContentType(!1);let c=new XMLHttpRequest;if(e.auth){const h=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.set("Authorization","Basic "+btoa(h+":"+p))}const u=vm(e.baseURL,e.url);c.open(e.method.toUpperCase(),fm(u,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function l(){if(!c)return;const h=Mr.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),p={data:!s||s==="text"||s==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:h,config:e,request:c};HS(function(f){t(f),o()},function(f){r(f),o()},p),c=null}if("onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(l)},c.onabort=function(){c&&(r(new ct("Request aborted",ct.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new ct("Network Error",ct.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let h=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const p=e.transitional||gm;e.timeoutErrorMessage&&(h=e.timeoutErrorMessage),r(new ct(h,p.clarifyTimeoutError?ct.ETIMEDOUT:ct.ECONNABORTED,e,c)),c=null},on.isStandardBrowserEnv){const h=(e.withCredentials||GS(u))&&e.xsrfCookieName&&KS.read(e.xsrfCookieName);h&&a.set(e.xsrfHeaderName,h)}n===void 0&&a.setContentType(null),"setRequestHeader"in c&&oe.forEach(a.toJSON(),function(h,p){c.setRequestHeader(p,h)}),oe.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&s!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",pp(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",pp(e.onUploadProgress)),(e.cancelToken||e.signal)&&(i=h=>{c&&(r(!h||h.type?new fi(null,e,c):h),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(i),e.signal&&(e.signal.aborted?i():e.signal.addEventListener("abort",i)));const d=QS(u);if(d&&on.protocols.indexOf(d)===-1){r(new ct("Unsupported protocol "+d+":",ct.ERR_BAD_REQUEST,e));return}c.send(n||null)})},Ki={http:qS,xhr:YS};oe.forEach(Ki,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const XS={getAdapter:e=>{e=oe.isArray(e)?e:[e];const{length:t}=e;let r,n;for(let a=0;a<t&&(r=e[a],!(n=oe.isString(r)?Ki[r.toLowerCase()]:r));a++);if(!n)throw n===!1?new ct(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(oe.hasOwnProp(Ki,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!oe.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:Ki};function fu(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new fi(null,e)}function fp(e){return fu(e),e.headers=Mr.from(e.headers),e.data=pu.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),XS.getAdapter(e.adapter||ys.adapter)(e).then(function(t){return fu(e),t.data=pu.call(e,e.transformResponse,t),t.headers=Mr.from(t.headers),t},function(t){return ym(t)||(fu(e),t&&t.response&&(t.response.data=pu.call(e,e.transformResponse,t.response),t.response.headers=Mr.from(t.response.headers))),Promise.reject(t)})}const gp=e=>e instanceof Mr?e.toJSON():e;function rs(e,t){t=t||{};const r={};function n(u,l,d){return oe.isPlainObject(u)&&oe.isPlainObject(l)?oe.merge.call({caseless:d},u,l):oe.isPlainObject(l)?oe.merge({},l):oe.isArray(l)?l.slice():l}function a(u,l,d){if(oe.isUndefined(l)){if(!oe.isUndefined(u))return n(void 0,u,d)}else return n(u,l,d)}function s(u,l){if(!oe.isUndefined(l))return n(void 0,l)}function i(u,l){if(oe.isUndefined(l)){if(!oe.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function o(u,l,d){if(d in t)return n(u,l);if(d in e)return n(void 0,u)}const c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:o,headers:(u,l)=>a(gp(u),gp(l),!0)};return oe.forEach(Object.keys(e).concat(Object.keys(t)),function(u){const l=c[u]||a,d=l(e[u],t[u],u);oe.isUndefined(d)&&l!==o||(r[u]=d)}),r}const bm="1.2.1",r0={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{r0[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const mp={};r0.transitional=function(e,t,r){function n(a,s){return"[Axios v"+bm+"] Transitional option '"+a+"'"+s+(r?". "+r:"")}return(a,s,i)=>{if(e===!1)throw new ct(n(s," has been removed"+(t?" in "+t:"")),ct.ERR_DEPRECATED);return t&&!mp[s]&&(mp[s]=!0,console.warn(n(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,s,i):!0}};function JS(e,t,r){if(typeof e!="object")throw new ct("options must be an object",ct.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let a=n.length;for(;a-- >0;){const s=n[a],i=t[s];if(i){const o=e[s],c=o===void 0||i(o,s,e);if(c!==!0)throw new ct("option "+s+" must be "+c,ct.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ct("Unknown option "+s,ct.ERR_BAD_OPTION)}}const Yu={assertOptions:JS,validators:r0},kn=Yu.validators;let ma=class{constructor(t){this.defaults=t,this.interceptors={request:new lp,response:new lp}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=rs(this.defaults,r);const{transitional:n,paramsSerializer:a,headers:s}=r;n!==void 0&&Yu.assertOptions(n,{silentJSONParsing:kn.transitional(kn.boolean),forcedJSONParsing:kn.transitional(kn.boolean),clarifyTimeoutError:kn.transitional(kn.boolean)},!1),a!==void 0&&Yu.assertOptions(a,{encode:kn.function,serialize:kn.function},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i;i=s&&oe.merge(s.common,s[r.method]),i&&oe.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),r.headers=Mr.concat(i,s);const o=[];let c=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(c=c&&f.synchronous,o.unshift(f.fulfilled,f.rejected))});const u=[];this.interceptors.response.forEach(function(f){u.push(f.fulfilled,f.rejected)});let l,d=0,h;if(!c){const f=[fp.bind(this),void 0];for(f.unshift.apply(f,o),f.push.apply(f,u),h=f.length,l=Promise.resolve(r);d<h;)l=l.then(f[d++],f[d++]);return l}h=o.length;let p=r;for(d=0;d<h;){const f=o[d++],g=o[d++];try{p=f(p)}catch(y){g.call(this,y);break}}try{l=fp.call(this,p)}catch(f){return Promise.reject(f)}for(d=0,h=u.length;d<h;)l=l.then(u[d++],u[d++]);return l}getUri(t){t=rs(this.defaults,t);const r=vm(t.baseURL,t.url);return fm(r,t.params,t.paramsSerializer)}};oe.forEach(["delete","get","head","options"],function(e){ma.prototype[e]=function(t,r){return this.request(rs(r||{},{method:e,url:t,data:(r||{}).data}))}});oe.forEach(["post","put","patch"],function(e){function t(r){return function(n,a,s){return this.request(rs(s||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:n,data:a}))}}ma.prototype[e]=t(),ma.prototype[e+"Form"]=t(!0)});let eE=class Cm{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(a){r=a});const n=this;this.promise.then(a=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](a);n._listeners=null}),this.promise.then=a=>{let s;const i=new Promise(o=>{n.subscribe(o),s=o}).then(a);return i.cancel=function(){n.unsubscribe(s)},i},t(function(a,s,i){n.reason||(n.reason=new fi(a,s,i),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new Cm(function(r){t=r}),cancel:t}}};function tE(e){return function(t){return e.apply(null,t)}}function rE(e){return oe.isObject(e)&&e.isAxiosError===!0}function Sm(e){const t=new ma(e),r=rm(ma.prototype.request,t);return oe.extend(r,ma.prototype,t,{allOwnKeys:!0}),oe.extend(r,t,null,{allOwnKeys:!0}),r.create=function(n){return Sm(rs(e,n))},r}const Rt=Sm(ys);Rt.Axios=ma;Rt.CanceledError=fi;Rt.CancelToken=eE;Rt.isCancel=ym;Rt.VERSION=bm;Rt.toFormData=Vo;Rt.AxiosError=ct;Rt.Cancel=Rt.CanceledError;Rt.all=function(e){return Promise.all(e)};Rt.spread=tE;Rt.isAxiosError=rE;Rt.mergeConfig=rs;Rt.AxiosHeaders=Mr;Rt.formToJSON=e=>mm(oe.isHTMLForm(e)?new FormData(e):e);Rt.default=Rt;var zo={exports:{}},Em={exports:{}},xm={exports:{}};(function(e){(function(t){var r,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,s=Math.floor,i="[BigNumber Error] ",o=i+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,l=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,p=1e9;function f(E){var w,_,P,x=U.prototype={constructor:U,toString:null,valueOf:null},R=new U(1),B=20,K=4,re=-7,ee=21,ie=-1e7,se=1e7,Ce=!1,Ie=1,ye=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},X="0123456789abcdefghijklmnopqrstuvwxyz",ne=!0;function U(I,D){var N,q,k,V,W,j,z,Z,M=this;if(!(M instanceof U))return new U(I,D);if(D==null){if(I&&I._isBigNumber===!0){M.s=I.s,!I.c||I.e>se?M.c=M.e=null:I.e<ie?M.c=[M.e=0]:(M.e=I.e,M.c=I.c.slice());return}if((j=typeof I=="number")&&I*0==0){if(M.s=1/I<0?(I=-I,-1):1,I===~~I){for(V=0,W=I;W>=10;W/=10,V++);V>se?M.c=M.e=null:(M.e=V,M.c=[I]);return}Z=String(I)}else{if(!n.test(Z=String(I)))return P(M,Z,j);M.s=Z.charCodeAt(0)==45?(Z=Z.slice(1),-1):1}(V=Z.indexOf("."))>-1&&(Z=Z.replace(".","")),(W=Z.search(/e/i))>0?(V<0&&(V=W),V+=+Z.slice(W+1),Z=Z.substring(0,W)):V<0&&(V=Z.length)}else{if(m(D,2,X.length,"Base"),D==10&&ne)return M=new U(I),he(M,B+M.e+1,K);if(Z=String(I),j=typeof I=="number"){if(I*0!=0)return P(M,Z,j,D);if(M.s=1/I<0?(Z=Z.slice(1),-1):1,U.DEBUG&&Z.replace(/^0\.0*|\./,"").length>15)throw Error(o+I)}else M.s=Z.charCodeAt(0)===45?(Z=Z.slice(1),-1):1;for(N=X.slice(0,D),V=W=0,z=Z.length;W<z;W++)if(N.indexOf(q=Z.charAt(W))<0){if(q=="."){if(W>V){V=z;continue}}else if(!k&&(Z==Z.toUpperCase()&&(Z=Z.toLowerCase())||Z==Z.toLowerCase()&&(Z=Z.toUpperCase()))){k=!0,W=-1,V=0;continue}return P(M,String(I),j,D)}j=!1,Z=_(Z,D,10,M.s),(V=Z.indexOf("."))>-1?Z=Z.replace(".",""):V=Z.length}for(W=0;Z.charCodeAt(W)===48;W++);for(z=Z.length;Z.charCodeAt(--z)===48;);if(Z=Z.slice(W,++z)){if(z-=W,j&&U.DEBUG&&z>15&&(I>l||I!==s(I)))throw Error(o+M.s*I);if((V=V-W-1)>se)M.c=M.e=null;else if(V<ie)M.c=[M.e=0];else{if(M.e=V,M.c=[],W=(V+1)%u,V<0&&(W+=u),W<z){for(W&&M.c.push(+Z.slice(0,W)),z-=u;W<z;)M.c.push(+Z.slice(W,W+=u));W=u-(Z=Z.slice(W)).length}else W-=z;for(;W--;Z+="0");M.c.push(+Z)}}else M.c=[M.e=0]}U.clone=f,U.ROUND_UP=0,U.ROUND_DOWN=1,U.ROUND_CEIL=2,U.ROUND_FLOOR=3,U.ROUND_HALF_UP=4,U.ROUND_HALF_DOWN=5,U.ROUND_HALF_EVEN=6,U.ROUND_HALF_CEIL=7,U.ROUND_HALF_FLOOR=8,U.EUCLID=9,U.config=U.set=function(I){var D,N;if(I!=null)if(typeof I=="object"){if(I.hasOwnProperty(D="DECIMAL_PLACES")&&(N=I[D],m(N,0,p,D),B=N),I.hasOwnProperty(D="ROUNDING_MODE")&&(N=I[D],m(N,0,8,D),K=N),I.hasOwnProperty(D="EXPONENTIAL_AT")&&(N=I[D],N&&N.pop?(m(N[0],-p,0,D),m(N[1],0,p,D),re=N[0],ee=N[1]):(m(N,-p,p,D),re=-(ee=N<0?-N:N))),I.hasOwnProperty(D="RANGE"))if(N=I[D],N&&N.pop)m(N[0],-p,-1,D),m(N[1],1,p,D),ie=N[0],se=N[1];else if(m(N,-p,p,D),N)ie=-(se=N<0?-N:N);else throw Error(i+D+" cannot be zero: "+N);if(I.hasOwnProperty(D="CRYPTO"))if(N=I[D],N===!!N)if(N)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Ce=N;else throw Ce=!N,Error(i+"crypto unavailable");else Ce=N;else throw Error(i+D+" not true or false: "+N);if(I.hasOwnProperty(D="MODULO_MODE")&&(N=I[D],m(N,0,9,D),Ie=N),I.hasOwnProperty(D="POW_PRECISION")&&(N=I[D],m(N,0,p,D),ye=N),I.hasOwnProperty(D="FORMAT"))if(N=I[D],typeof N=="object")L=N;else throw Error(i+D+" not an object: "+N);if(I.hasOwnProperty(D="ALPHABET"))if(N=I[D],typeof N=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(N))ne=N.slice(0,10)=="0123456789",X=N;else throw Error(i+D+" invalid: "+N)}else throw Error(i+"Object expected: "+I);return{DECIMAL_PLACES:B,ROUNDING_MODE:K,EXPONENTIAL_AT:[re,ee],RANGE:[ie,se],CRYPTO:Ce,MODULO_MODE:Ie,POW_PRECISION:ye,FORMAT:L,ALPHABET:X}},U.isBigNumber=function(I){if(!I||I._isBigNumber!==!0)return!1;if(!U.DEBUG)return!0;var D,N,q=I.c,k=I.e,V=I.s;e:if({}.toString.call(q)=="[object Array]"){if((V===1||V===-1)&&k>=-p&&k<=p&&k===s(k)){if(q[0]===0){if(k===0&&q.length===1)return!0;break e}if(D=(k+1)%u,D<1&&(D+=u),String(q[0]).length==D){for(D=0;D<q.length;D++)if(N=q[D],N<0||N>=c||N!==s(N))break e;if(N!==0)return!0}}}else if(q===null&&k===null&&(V===null||V===1||V===-1))return!0;throw Error(i+"Invalid BigNumber: "+I)},U.maximum=U.max=function(){return xe(arguments,-1)},U.minimum=U.min=function(){return xe(arguments,1)},U.random=function(){var I=9007199254740992,D=Math.random()*I&2097151?function(){return s(Math.random()*I)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(N){var q,k,V,W,j,z=0,Z=[],M=new U(R);if(N==null?N=B:m(N,0,p),W=a(N/u),Ce)if(crypto.getRandomValues){for(q=crypto.getRandomValues(new Uint32Array(W*=2));z<W;)j=q[z]*131072+(q[z+1]>>>11),j>=9e15?(k=crypto.getRandomValues(new Uint32Array(2)),q[z]=k[0],q[z+1]=k[1]):(Z.push(j%1e14),z+=2);z=W/2}else if(crypto.randomBytes){for(q=crypto.randomBytes(W*=7);z<W;)j=(q[z]&31)*281474976710656+q[z+1]*1099511627776+q[z+2]*4294967296+q[z+3]*16777216+(q[z+4]<<16)+(q[z+5]<<8)+q[z+6],j>=9e15?crypto.randomBytes(7).copy(q,z):(Z.push(j%1e14),z+=7);z=W/7}else throw Ce=!1,Error(i+"crypto unavailable");if(!Ce)for(;z<W;)j=D(),j<9e15&&(Z[z++]=j%1e14);for(W=Z[--z],N%=u,W&&N&&(j=d[u-N],Z[z]=s(W/j)*j);Z[z]===0;Z.pop(),z--);if(z<0)Z=[V=0];else{for(V=-1;Z[0]===0;Z.splice(0,1),V-=u);for(z=1,j=Z[0];j>=10;j/=10,z++);z<u&&(V-=u-z)}return M.e=V,M.c=Z,M}}(),U.sum=function(){for(var I=1,D=arguments,N=new U(D[0]);I<D.length;)N=N.plus(D[I++]);return N},_=function(){var I="0123456789";function D(N,q,k,V){for(var W,j=[0],z,Z=0,M=N.length;Z<M;){for(z=j.length;z--;j[z]*=q);for(j[0]+=V.indexOf(N.charAt(Z++)),W=0;W<j.length;W++)j[W]>k-1&&(j[W+1]==null&&(j[W+1]=0),j[W+1]+=j[W]/k|0,j[W]%=k)}return j.reverse()}return function(N,q,k,V,W){var j,z,Z,M,te,ge,G,Ge,gt=N.indexOf("."),ot=B,Ke=K;for(gt>=0&&(M=ye,ye=0,N=N.replace(".",""),Ge=new U(q),ge=Ge.pow(N.length-gt),ye=M,Ge.c=D(C(y(ge.c),ge.e,"0"),10,k,I),Ge.e=Ge.c.length),G=D(N,q,k,W?(j=X,I):(j=I,X)),Z=M=G.length;G[--M]==0;G.pop());if(!G[0])return j.charAt(0);if(gt<0?--Z:(ge.c=G,ge.e=Z,ge.s=V,ge=w(ge,Ge,ot,Ke,k),G=ge.c,te=ge.r,Z=ge.e),z=Z+ot+1,gt=G[z],M=k/2,te=te||z<0||G[z+1]!=null,te=Ke<4?(gt!=null||te)&&(Ke==0||Ke==(ge.s<0?3:2)):gt>M||gt==M&&(Ke==4||te||Ke==6&&G[z-1]&1||Ke==(ge.s<0?8:7)),z<1||!G[0])N=te?C(j.charAt(1),-ot,j.charAt(0)):j.charAt(0);else{if(G.length=z,te)for(--k;++G[--z]>k;)G[z]=0,z||(++Z,G=[1].concat(G));for(M=G.length;!G[--M];);for(gt=0,N="";gt<=M;N+=j.charAt(G[gt++]));N=C(N,Z,j.charAt(0))}return N}}(),w=function(){function I(q,k,V){var W,j,z,Z,M=0,te=q.length,ge=k%h,G=k/h|0;for(q=q.slice();te--;)z=q[te]%h,Z=q[te]/h|0,W=G*z+Z*ge,j=ge*z+W%h*h+M,M=(j/V|0)+(W/h|0)+G*Z,q[te]=j%V;return M&&(q=[M].concat(q)),q}function D(q,k,V,W){var j,z;if(V!=W)z=V>W?1:-1;else for(j=z=0;j<V;j++)if(q[j]!=k[j]){z=q[j]>k[j]?1:-1;break}return z}function N(q,k,V,W){for(var j=0;V--;)q[V]-=j,j=q[V]<k[V]?1:0,q[V]=j*W+q[V]-k[V];for(;!q[0]&&q.length>1;q.splice(0,1));}return function(q,k,V,W,j){var z,Z,M,te,ge,G,Ge,gt,ot,Ke,ht,Ut,Qr,Xt,pr,xr,qr,zt=q.s==k.s?1:-1,qt=q.c,xt=k.c;if(!qt||!qt[0]||!xt||!xt[0])return new U(!q.s||!k.s||(qt?xt&&qt[0]==xt[0]:!xt)?NaN:qt&&qt[0]==0||!xt?zt*0:zt/0);for(gt=new U(zt),ot=gt.c=[],Z=q.e-k.e,zt=V+Z+1,j||(j=c,Z=g(q.e/u)-g(k.e/u),zt=zt/u|0),M=0;xt[M]==(qt[M]||0);M++);if(xt[M]>(qt[M]||0)&&Z--,zt<0)ot.push(1),te=!0;else{for(Xt=qt.length,xr=xt.length,M=0,zt+=2,ge=s(j/(xt[0]+1)),ge>1&&(xt=I(xt,ge,j),qt=I(qt,ge,j),xr=xt.length,Xt=qt.length),Qr=xr,Ke=qt.slice(0,xr),ht=Ke.length;ht<xr;Ke[ht++]=0);qr=xt.slice(),qr=[0].concat(qr),pr=xt[0],xt[1]>=j/2&&pr++;do{if(ge=0,z=D(xt,Ke,xr,ht),z<0){if(Ut=Ke[0],xr!=ht&&(Ut=Ut*j+(Ke[1]||0)),ge=s(Ut/pr),ge>1)for(ge>=j&&(ge=j-1),G=I(xt,ge,j),Ge=G.length,ht=Ke.length;D(G,Ke,Ge,ht)==1;)ge--,N(G,xr<Ge?qr:xt,Ge,j),Ge=G.length,z=1;else ge==0&&(z=ge=1),G=xt.slice(),Ge=G.length;if(Ge<ht&&(G=[0].concat(G)),N(Ke,G,ht,j),ht=Ke.length,z==-1)for(;D(xt,Ke,xr,ht)<1;)ge++,N(Ke,xr<ht?qr:xt,ht,j),ht=Ke.length}else z===0&&(ge++,Ke=[0]);ot[M++]=ge,Ke[0]?Ke[ht++]=qt[Qr]||0:(Ke=[qt[Qr]],ht=1)}while((Qr++<Xt||Ke[0]!=null)&&zt--);te=Ke[0]!=null,ot[0]||ot.splice(0,1)}if(j==c){for(M=1,zt=ot[0];zt>=10;zt/=10,M++);he(gt,V+(gt.e=M+Z*u-1)+1,W,te)}else gt.e=Z,gt.r=+te;return gt}}();function be(I,D,N,q){var k,V,W,j,z;if(N==null?N=K:m(N,0,8),!I.c)return I.toString();if(k=I.c[0],W=I.e,D==null)z=y(I.c),z=q==1||q==2&&(W<=re||W>=ee)?S(z,W):C(z,W,"0");else if(I=he(new U(I),D,N),V=I.e,z=y(I.c),j=z.length,q==1||q==2&&(D<=V||V<=re)){for(;j<D;z+="0",j++);z=S(z,V)}else if(D-=W,z=C(z,V,"0"),V+1>j){if(--D>0)for(z+=".";D--;z+="0");}else if(D+=V-j,D>0)for(V+1==j&&(z+=".");D--;z+="0");return I.s<0&&k?"-"+z:z}function xe(I,D){for(var N,q,k=1,V=new U(I[0]);k<I.length;k++)q=new U(I[k]),(!q.s||(N=b(V,q))===D||N===0&&V.s===D)&&(V=q);return V}function Ne(I,D,N){for(var q=1,k=D.length;!D[--k];D.pop());for(k=D[0];k>=10;k/=10,q++);return(N=q+N*u-1)>se?I.c=I.e=null:N<ie?I.c=[I.e=0]:(I.e=N,I.c=D),I}P=function(){var I=/^(-?)0([xbo])(?=\w[\w.]*$)/i,D=/^([^.]+)\.$/,N=/^\.([^.]+)$/,q=/^-?(Infinity|NaN)$/,k=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(V,W,j,z){var Z,M=j?W:W.replace(k,"");if(q.test(M))V.s=isNaN(M)?null:M<0?-1:1;else{if(!j&&(M=M.replace(I,function(te,ge,G){return Z=(G=G.toLowerCase())=="x"?16:G=="b"?2:8,!z||z==Z?ge:te}),z&&(Z=z,M=M.replace(D,"$1").replace(N,"0.$1")),W!=M))return new U(M,Z);if(U.DEBUG)throw Error(i+"Not a"+(z?" base "+z:"")+" number: "+W);V.s=null}V.c=V.e=null}}();function he(I,D,N,q){var k,V,W,j,z,Z,M,te=I.c,ge=d;if(te){e:{for(k=1,j=te[0];j>=10;j/=10,k++);if(V=D-k,V<0)V+=u,W=D,z=te[Z=0],M=s(z/ge[k-W-1]%10);else if(Z=a((V+1)/u),Z>=te.length)if(q){for(;te.length<=Z;te.push(0));z=M=0,k=1,V%=u,W=V-u+1}else break e;else{for(z=j=te[Z],k=1;j>=10;j/=10,k++);V%=u,W=V-u+k,M=W<0?0:s(z/ge[k-W-1]%10)}if(q=q||D<0||te[Z+1]!=null||(W<0?z:z%ge[k-W-1]),q=N<4?(M||q)&&(N==0||N==(I.s<0?3:2)):M>5||M==5&&(N==4||q||N==6&&(V>0?W>0?z/ge[k-W]:0:te[Z-1])%10&1||N==(I.s<0?8:7)),D<1||!te[0])return te.length=0,q?(D-=I.e+1,te[0]=ge[(u-D%u)%u],I.e=-D||0):te[0]=I.e=0,I;if(V==0?(te.length=Z,j=1,Z--):(te.length=Z+1,j=ge[u-V],te[Z]=W>0?s(z/ge[k-W]%ge[W])*j:0),q)for(;;)if(Z==0){for(V=1,W=te[0];W>=10;W/=10,V++);for(W=te[0]+=j,j=1;W>=10;W/=10,j++);V!=j&&(I.e++,te[0]==c&&(te[0]=1));break}else{if(te[Z]+=j,te[Z]!=c)break;te[Z--]=0,j=1}for(V=te.length;te[--V]===0;te.pop());}I.e>se?I.c=I.e=null:I.e<ie&&(I.c=[I.e=0])}return I}function _e(I){var D,N=I.e;return N===null?I.toString():(D=y(I.c),D=N<=re||N>=ee?S(D,N):C(D,N,"0"),I.s<0?"-"+D:D)}return x.absoluteValue=x.abs=function(){var I=new U(this);return I.s<0&&(I.s=1),I},x.comparedTo=function(I,D){return b(this,new U(I,D))},x.decimalPlaces=x.dp=function(I,D){var N,q,k,V=this;if(I!=null)return m(I,0,p),D==null?D=K:m(D,0,8),he(new U(V),I+V.e+1,D);if(!(N=V.c))return null;if(q=((k=N.length-1)-g(this.e/u))*u,k=N[k])for(;k%10==0;k/=10,q--);return q<0&&(q=0),q},x.dividedBy=x.div=function(I,D){return w(this,new U(I,D),B,K)},x.dividedToIntegerBy=x.idiv=function(I,D){return w(this,new U(I,D),0,1)},x.exponentiatedBy=x.pow=function(I,D){var N,q,k,V,W,j,z,Z,M,te=this;if(I=new U(I),I.c&&!I.isInteger())throw Error(i+"Exponent not an integer: "+_e(I));if(D!=null&&(D=new U(D)),j=I.e>14,!te.c||!te.c[0]||te.c[0]==1&&!te.e&&te.c.length==1||!I.c||!I.c[0])return M=new U(Math.pow(+_e(te),j?I.s*(2-v(I)):+_e(I))),D?M.mod(D):M;if(z=I.s<0,D){if(D.c?!D.c[0]:!D.s)return new U(NaN);q=!z&&te.isInteger()&&D.isInteger(),q&&(te=te.mod(D))}else{if(I.e>9&&(te.e>0||te.e<-1||(te.e==0?te.c[0]>1||j&&te.c[1]>=24e7:te.c[0]<8e13||j&&te.c[0]<=9999975e7)))return V=te.s<0&&v(I)?-0:0,te.e>-1&&(V=1/V),new U(z?1/V:V);ye&&(V=a(ye/u+2))}for(j?(N=new U(.5),z&&(I.s=1),Z=v(I)):(k=Math.abs(+_e(I)),Z=k%2),M=new U(R);;){if(Z){if(M=M.times(te),!M.c)break;V?M.c.length>V&&(M.c.length=V):q&&(M=M.mod(D))}if(k){if(k=s(k/2),k===0)break;Z=k%2}else if(I=I.times(N),he(I,I.e+1,1),I.e>14)Z=v(I);else{if(k=+_e(I),k===0)break;Z=k%2}te=te.times(te),V?te.c&&te.c.length>V&&(te.c.length=V):q&&(te=te.mod(D))}return q?M:(z&&(M=R.div(M)),D?M.mod(D):V?he(M,ye,K,W):M)},x.integerValue=function(I){var D=new U(this);return I==null?I=K:m(I,0,8),he(D,D.e+1,I)},x.isEqualTo=x.eq=function(I,D){return b(this,new U(I,D))===0},x.isFinite=function(){return!!this.c},x.isGreaterThan=x.gt=function(I,D){return b(this,new U(I,D))>0},x.isGreaterThanOrEqualTo=x.gte=function(I,D){return(D=b(this,new U(I,D)))===1||D===0},x.isInteger=function(){return!!this.c&&g(this.e/u)>this.c.length-2},x.isLessThan=x.lt=function(I,D){return b(this,new U(I,D))<0},x.isLessThanOrEqualTo=x.lte=function(I,D){return(D=b(this,new U(I,D)))===-1||D===0},x.isNaN=function(){return!this.s},x.isNegative=function(){return this.s<0},x.isPositive=function(){return this.s>0},x.isZero=function(){return!!this.c&&this.c[0]==0},x.minus=function(I,D){var N,q,k,V,W=this,j=W.s;if(I=new U(I,D),D=I.s,!j||!D)return new U(NaN);if(j!=D)return I.s=-D,W.plus(I);var z=W.e/u,Z=I.e/u,M=W.c,te=I.c;if(!z||!Z){if(!M||!te)return M?(I.s=-D,I):new U(te?W:NaN);if(!M[0]||!te[0])return te[0]?(I.s=-D,I):new U(M[0]?W:K==3?-0:0)}if(z=g(z),Z=g(Z),M=M.slice(),j=z-Z){for((V=j<0)?(j=-j,k=M):(Z=z,k=te),k.reverse(),D=j;D--;k.push(0));k.reverse()}else for(q=(V=(j=M.length)<(D=te.length))?j:D,j=D=0;D<q;D++)if(M[D]!=te[D]){V=M[D]<te[D];break}if(V&&(k=M,M=te,te=k,I.s=-I.s),D=(q=te.length)-(N=M.length),D>0)for(;D--;M[N++]=0);for(D=c-1;q>j;){if(M[--q]<te[q]){for(N=q;N&&!M[--N];M[N]=D);--M[N],M[q]+=c}M[q]-=te[q]}for(;M[0]==0;M.splice(0,1),--Z);return M[0]?Ne(I,M,Z):(I.s=K==3?-1:1,I.c=[I.e=0],I)},x.modulo=x.mod=function(I,D){var N,q,k=this;return I=new U(I,D),!k.c||!I.s||I.c&&!I.c[0]?new U(NaN):!I.c||k.c&&!k.c[0]?new U(k):(Ie==9?(q=I.s,I.s=1,N=w(k,I,0,3),I.s=q,N.s*=q):N=w(k,I,0,Ie),I=k.minus(N.times(I)),!I.c[0]&&Ie==1&&(I.s=k.s),I)},x.multipliedBy=x.times=function(I,D){var N,q,k,V,W,j,z,Z,M,te,ge,G,Ge,gt,ot,Ke=this,ht=Ke.c,Ut=(I=new U(I,D)).c;if(!ht||!Ut||!ht[0]||!Ut[0])return!Ke.s||!I.s||ht&&!ht[0]&&!Ut||Ut&&!Ut[0]&&!ht?I.c=I.e=I.s=null:(I.s*=Ke.s,!ht||!Ut?I.c=I.e=null:(I.c=[0],I.e=0)),I;for(q=g(Ke.e/u)+g(I.e/u),I.s*=Ke.s,z=ht.length,te=Ut.length,z<te&&(Ge=ht,ht=Ut,Ut=Ge,k=z,z=te,te=k),k=z+te,Ge=[];k--;Ge.push(0));for(gt=c,ot=h,k=te;--k>=0;){for(N=0,ge=Ut[k]%ot,G=Ut[k]/ot|0,W=z,V=k+W;V>k;)Z=ht[--W]%ot,M=ht[W]/ot|0,j=G*Z+M*ge,Z=ge*Z+j%ot*ot+Ge[V]+N,N=(Z/gt|0)+(j/ot|0)+G*M,Ge[V--]=Z%gt;Ge[V]=N}return N?++q:Ge.splice(0,1),Ne(I,Ge,q)},x.negated=function(){var I=new U(this);return I.s=-I.s||null,I},x.plus=function(I,D){var N,q=this,k=q.s;if(I=new U(I,D),D=I.s,!k||!D)return new U(NaN);if(k!=D)return I.s=-D,q.minus(I);var V=q.e/u,W=I.e/u,j=q.c,z=I.c;if(!V||!W){if(!j||!z)return new U(k/0);if(!j[0]||!z[0])return z[0]?I:new U(j[0]?q:k*0)}if(V=g(V),W=g(W),j=j.slice(),k=V-W){for(k>0?(W=V,N=z):(k=-k,N=j),N.reverse();k--;N.push(0));N.reverse()}for(k=j.length,D=z.length,k-D<0&&(N=z,z=j,j=N,D=k),k=0;D;)k=(j[--D]=j[D]+z[D]+k)/c|0,j[D]=c===j[D]?0:j[D]%c;return k&&(j=[k].concat(j),++W),Ne(I,j,W)},x.precision=x.sd=function(I,D){var N,q,k,V=this;if(I!=null&&I!==!!I)return m(I,1,p),D==null?D=K:m(D,0,8),he(new U(V),I,D);if(!(N=V.c))return null;if(k=N.length-1,q=k*u+1,k=N[k]){for(;k%10==0;k/=10,q--);for(k=N[0];k>=10;k/=10,q++);}return I&&V.e+1>q&&(q=V.e+1),q},x.shiftedBy=function(I){return m(I,-l,l),this.times("1e"+I)},x.squareRoot=x.sqrt=function(){var I,D,N,q,k,V=this,W=V.c,j=V.s,z=V.e,Z=B+4,M=new U("0.5");if(j!==1||!W||!W[0])return new U(!j||j<0&&(!W||W[0])?NaN:W?V:1/0);if(j=Math.sqrt(+_e(V)),j==0||j==1/0?(D=y(W),(D.length+z)%2==0&&(D+="0"),j=Math.sqrt(+D),z=g((z+1)/2)-(z<0||z%2),j==1/0?D="5e"+z:(D=j.toExponential(),D=D.slice(0,D.indexOf("e")+1)+z),N=new U(D)):N=new U(j+""),N.c[0]){for(z=N.e,j=z+Z,j<3&&(j=0);;)if(k=N,N=M.times(k.plus(w(V,k,Z,1))),y(k.c).slice(0,j)===(D=y(N.c)).slice(0,j))if(N.e<z&&--j,D=D.slice(j-3,j+1),D=="9999"||!q&&D=="4999"){if(!q&&(he(k,k.e+B+2,0),k.times(k).eq(V))){N=k;break}Z+=4,j+=4,q=1}else{(!+D||!+D.slice(1)&&D.charAt(0)=="5")&&(he(N,N.e+B+2,1),I=!N.times(N).eq(V));break}}return he(N,N.e+B+1,K,I)},x.toExponential=function(I,D){return I!=null&&(m(I,0,p),I++),be(this,I,D,1)},x.toFixed=function(I,D){return I!=null&&(m(I,0,p),I=I+this.e+1),be(this,I,D)},x.toFormat=function(I,D,N){var q,k=this;if(N==null)I!=null&&D&&typeof D=="object"?(N=D,D=null):I&&typeof I=="object"?(N=I,I=D=null):N=L;else if(typeof N!="object")throw Error(i+"Argument not an object: "+N);if(q=k.toFixed(I,D),k.c){var V,W=q.split("."),j=+N.groupSize,z=+N.secondaryGroupSize,Z=N.groupSeparator||"",M=W[0],te=W[1],ge=k.s<0,G=ge?M.slice(1):M,Ge=G.length;if(z&&(V=j,j=z,z=V,Ge-=V),j>0&&Ge>0){for(V=Ge%j||j,M=G.substr(0,V);V<Ge;V+=j)M+=Z+G.substr(V,j);z>0&&(M+=Z+G.slice(V)),ge&&(M="-"+M)}q=te?M+(N.decimalSeparator||"")+((z=+N.fractionGroupSize)?te.replace(new RegExp("\\d{"+z+"}\\B","g"),"$&"+(N.fractionGroupSeparator||"")):te):M}return(N.prefix||"")+q+(N.suffix||"")},x.toFraction=function(I){var D,N,q,k,V,W,j,z,Z,M,te,ge,G=this,Ge=G.c;if(I!=null&&(j=new U(I),!j.isInteger()&&(j.c||j.s!==1)||j.lt(R)))throw Error(i+"Argument "+(j.isInteger()?"out of range: ":"not an integer: ")+_e(j));if(!Ge)return new U(G);for(D=new U(R),Z=N=new U(R),q=z=new U(R),ge=y(Ge),V=D.e=ge.length-G.e-1,D.c[0]=d[(W=V%u)<0?u+W:W],I=!I||j.comparedTo(D)>0?V>0?D:Z:j,W=se,se=1/0,j=new U(ge),z.c[0]=0;M=w(j,D,0,1),k=N.plus(M.times(q)),k.comparedTo(I)!=1;)N=q,q=k,Z=z.plus(M.times(k=Z)),z=k,D=j.minus(M.times(k=D)),j=k;return k=w(I.minus(N),q,0,1),z=z.plus(k.times(Z)),N=N.plus(k.times(q)),z.s=Z.s=G.s,V=V*2,te=w(Z,q,V,K).minus(G).abs().comparedTo(w(z,N,V,K).minus(G).abs())<1?[Z,q]:[z,N],se=W,te},x.toNumber=function(){return+_e(this)},x.toPrecision=function(I,D){return I!=null&&m(I,1,p),be(this,I,D,2)},x.toString=function(I){var D,N=this,q=N.s,k=N.e;return k===null?q?(D="Infinity",q<0&&(D="-"+D)):D="NaN":(I==null?D=k<=re||k>=ee?S(y(N.c),k):C(y(N.c),k,"0"):I===10&&ne?(N=he(new U(N),B+k+1,K),D=C(y(N.c),N.e,"0")):(m(I,2,X.length,"Base"),D=_(C(y(N.c),k,"0"),10,I,q,!0)),q<0&&N.c[0]&&(D="-"+D)),D},x.valueOf=x.toJSON=function(){return _e(this)},x._isBigNumber=!0,E!=null&&U.set(E),U}function g(E){var w=E|0;return E>0||E===w?w:w-1}function y(E){for(var w,_,P=1,x=E.length,R=E[0]+"";P<x;){for(w=E[P++]+"",_=u-w.length;_--;w="0"+w);R+=w}for(x=R.length;R.charCodeAt(--x)===48;);return R.slice(0,x+1||1)}function b(E,w){var _,P,x=E.c,R=w.c,B=E.s,K=w.s,re=E.e,ee=w.e;if(!B||!K)return null;if(_=x&&!x[0],P=R&&!R[0],_||P)return _?P?0:-K:B;if(B!=K)return B;if(_=B<0,P=re==ee,!x||!R)return P?0:!x^_?1:-1;if(!P)return re>ee^_?1:-1;for(K=(re=x.length)<(ee=R.length)?re:ee,B=0;B<K;B++)if(x[B]!=R[B])return x[B]>R[B]^_?1:-1;return re==ee?0:re>ee^_?1:-1}function m(E,w,_,P){if(E<w||E>_||E!==s(E))throw Error(i+(P||"Argument")+(typeof E=="number"?E<w||E>_?" out of range: ":" not an integer: ":" not a primitive number: ")+String(E))}function v(E){var w=E.c.length-1;return g(E.e/u)==w&&E.c[w]%2!=0}function S(E,w){return(E.length>1?E.charAt(0)+"."+E.slice(1):E)+(w<0?"e":"e+")+w}function C(E,w,_){var P,x;if(w<0){for(x=_+".";++w;x+=_);E=x+E}else if(P=E.length,++w>P){for(x=_,w-=P;--w;x+=_);E+=x}else w<P&&(E=E.slice(0,w)+"."+E.slice(w));return E}r=f(),r.default=r.BigNumber=r,e.exports?e.exports=r:(t||(t=typeof self<"u"&&self?self:window),t.BigNumber=r)})(Cn)})(xm);var wm=xm.exports;(function(e){var t=wm,r=e.exports;(function(){var n=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a,s,i={"\b":"\\b","	":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},o;function c(l){return n.lastIndex=0,n.test(l)?'"'+l.replace(n,function(d){var h=i[d];return typeof h=="string"?h:"\\u"+("0000"+d.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+l+'"'}function u(l,d){var h,p,f,g,y=a,b,m=d[l],v=m!=null&&(m instanceof t||t.isBigNumber(m));switch(m&&typeof m=="object"&&typeof m.toJSON=="function"&&(m=m.toJSON(l)),typeof o=="function"&&(m=o.call(d,l,m)),typeof m){case"string":return v?m:c(m);case"number":return isFinite(m)?String(m):"null";case"boolean":case"null":case"bigint":return String(m);case"object":if(!m)return"null";if(a+=s,b=[],Object.prototype.toString.apply(m)==="[object Array]"){for(g=m.length,h=0;h<g;h+=1)b[h]=u(h,m)||"null";return f=b.length===0?"[]":a?`[
`+a+b.join(`,
`+a)+`
`+y+"]":"["+b.join(",")+"]",a=y,f}if(o&&typeof o=="object")for(g=o.length,h=0;h<g;h+=1)typeof o[h]=="string"&&(p=o[h],f=u(p,m),f&&b.push(c(p)+(a?": ":":")+f));else Object.keys(m).forEach(function(S){var C=u(S,m);C&&b.push(c(S)+(a?": ":":")+C)});return f=b.length===0?"{}":a?`{
`+a+b.join(`,
`+a)+`
`+y+"}":"{"+b.join(",")+"}",a=y,f}}typeof r.stringify!="function"&&(r.stringify=function(l,d,h){var p;if(a="",s="",typeof h=="number")for(p=0;p<h;p+=1)s+=" ";else typeof h=="string"&&(s=h);if(o=d,d&&typeof d!="function"&&(typeof d!="object"||typeof d.length!="number"))throw new Error("JSON.stringify");return u("",{"":l})})})()})(Em);var nE=Em.exports,Pi=null;const aE=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,sE=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;var iE=function(e){var t={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(e!=null){if(e.strict===!0&&(t.strict=!0),e.storeAsString===!0&&(t.storeAsString=!0),t.alwaysParseAsBig=e.alwaysParseAsBig===!0?e.alwaysParseAsBig:!1,t.useNativeBigInt=e.useNativeBigInt===!0?e.useNativeBigInt:!1,typeof e.constructorAction<"u")if(e.constructorAction==="error"||e.constructorAction==="ignore"||e.constructorAction==="preserve")t.constructorAction=e.constructorAction;else throw new Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${e.constructorAction}`);if(typeof e.protoAction<"u")if(e.protoAction==="error"||e.protoAction==="ignore"||e.protoAction==="preserve")t.protoAction=e.protoAction;else throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${e.protoAction}`)}var r,n,a={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
`,r:"\r",t:"	"},s,i=function(g){throw{name:"SyntaxError",message:g,at:r,text:s}},o=function(g){return g&&g!==n&&i("Expected '"+g+"' instead of '"+n+"'"),n=s.charAt(r),r+=1,n},c=function(){var g,y="";for(n==="-"&&(y="-",o("-"));n>="0"&&n<="9";)y+=n,o();if(n===".")for(y+=".";o()&&n>="0"&&n<="9";)y+=n;if(n==="e"||n==="E")for(y+=n,o(),(n==="-"||n==="+")&&(y+=n,o());n>="0"&&n<="9";)y+=n,o();if(g=+y,!isFinite(g))i("Bad number");else return Pi==null&&(Pi=wm),y.length>15?t.storeAsString?y:t.useNativeBigInt?BigInt(y):new Pi(y):t.alwaysParseAsBig?t.useNativeBigInt?BigInt(g):new Pi(g):g},u=function(){var g,y,b="",m;if(n==='"')for(var v=r;o();){if(n==='"')return r-1>v&&(b+=s.substring(v,r-1)),o(),b;if(n==="\\"){if(r-1>v&&(b+=s.substring(v,r-1)),o(),n==="u"){for(m=0,y=0;y<4&&(g=parseInt(o(),16),!!isFinite(g));y+=1)m=m*16+g;b+=String.fromCharCode(m)}else if(typeof a[n]=="string")b+=a[n];else break;v=r}}i("Bad string")},l=function(){for(;n&&n<=" ";)o()},d=function(){switch(n){case"t":return o("t"),o("r"),o("u"),o("e"),!0;case"f":return o("f"),o("a"),o("l"),o("s"),o("e"),!1;case"n":return o("n"),o("u"),o("l"),o("l"),null}i("Unexpected '"+n+"'")},h,p=function(){var g=[];if(n==="["){if(o("["),l(),n==="]")return o("]"),g;for(;n;){if(g.push(h()),l(),n==="]")return o("]"),g;o(","),l()}}i("Bad array")},f=function(){var g,y=Object.create(null);if(n==="{"){if(o("{"),l(),n==="}")return o("}"),y;for(;n;){if(g=u(),l(),o(":"),t.strict===!0&&Object.hasOwnProperty.call(y,g)&&i('Duplicate key "'+g+'"'),aE.test(g)===!0?t.protoAction==="error"?i("Object contains forbidden prototype property"):t.protoAction==="ignore"?h():y[g]=h():sE.test(g)===!0?t.constructorAction==="error"?i("Object contains forbidden constructor property"):t.constructorAction==="ignore"?h():y[g]=h():y[g]=h(),l(),n==="}")return o("}"),y;o(","),l()}}i("Bad object")};return h=function(){switch(l(),n){case"{":return f();case"[":return p();case'"':return u();case"-":return c();default:return n>="0"&&n<="9"?c():d()}},function(g,y){var b;return s=g+"",r=0,n=" ",b=h(),l(),n&&i("Syntax error"),typeof y=="function"?function m(v,S){var C,E=v[S];return E&&typeof E=="object"&&Object.keys(E).forEach(function(w){C=m(E,w),C!==void 0?E[w]=C:delete E[w]}),y.call(v,S,E)}({"":b},""):b}},oE=iE,Tm=nE.stringify,$m=oE;zo.exports=function(e){return{parse:$m(e),stringify:Tm}};zo.exports.parse=$m();zo.exports.stringify=Tm;var cE=zo.exports;const na=us(cE),Am=e=>{const t=r=>!Number.isSafeInteger(+r);try{return JSON.parse(((r,n)=>r.replace(/([:\s\[,]*)(\-?\d+\.?\d*)([\s,\]]*)/g,(a,s,i,o)=>n(i)?`${s}"${i}"${o}`:a))(e,t))}catch(r){return r}},n0=e=>{try{return JSON.parse((t=>t.replace(/([:\s\[,])(\-?\d+\.?\d*)([\s,\]]*)/g,(r,n,a,s)=>`${n}"${a}"${s}`))(e))}catch(t){return console.log(t),t}},hr=e=>{const t=r=>Object.entries(r).reduce((n,[a,s])=>(typeof s=="string"&&!Number.isNaN(Number(s))?s=s.replace(new RegExp("(\\.0*|(?<=(\\..*))0*)$"),""):typeof s=="object"&&!Array.isArray(s)&&(s=t(s)),{...n,[a]:s}),{});try{return t(na({storeAsString:!0}).parse(e))}catch{return JSON.parse(e)}},Go=()=>({array:()=>[e=>e!=""?na({storeAsString:!0}).parse(e):[]]}),$e=Rt.create({baseURL:Et,timeout:3e4}),Q=(e,t={timeout:25e3,contenType:"application/json;charset=UTF-8",maxRedirects:0})=>$e.get(e,{maxRedirects:t.maxRedirects,headers:{"Content-Type":t.contenType},timeout:t.timeout,...(t==null?void 0:t.responseType)&&{responseType:t==null?void 0:t.responseType}}),uE=async(e,t="application/json;charset=UTF-8",r="")=>await $e.get(e,{headers:{"Content-Type":t,...r&&{"Content-ID":r}}}),Na=(e,t)=>$e.get(e,{headers:{Authorization:t}}),gi=e=>$e.get(e,{transformResponse:[t=>t]}),vs=e=>$e.get(e,{transformResponse:[t=>{try{return na.parse(t===""?"{}":t)}catch(r){return Promise.reject(r)}}]}),J=async(e,t,r="application/json;charset=UTF-8")=>await $e.post(e,t,{headers:{"Content-Type":r}}),jr=async(e,t,r)=>await $e.post(e,t,{headers:{"Content-Type":"application/json;charset=UTF-8",...r}}),ze=async(e,t,r="application/json;charset=UTF-8")=>await $e.patch(e,t,{headers:{"Content-Type":r}}),pn=(e,t)=>$e.post(e,t,{headers:{"Content-Type":"application/graphql"},transformResponse:[r=>hr(r)]}),lE=async(e,t,r="application/json;charset=UTF-8",n)=>await $e.put(e,t,{headers:{"Content-Type":r,...!!n&&{"Set-Authorization":n}}}),Re=async(e,t,r="application/json;charset=UTF-8")=>await $e.put(e,t,{headers:{"Content-Type":r}}),dE=(e,t,r)=>$e.put(e,r,{headers:{Authorization:t}}),ft=e=>$e.delete(e);var sr={},bs={};/** @license MIT License (c) copyright 2010-2014 original author or authors */bs.compare=hE;bs.reduce=pE;var Qo,Wo,Wa;bs.REMOVE=Qo=-1;bs.ADD=Wo=1;bs.EQUAL=Wa=0;function hE(e,t){var r=e.length,n=t.length,a=fE(e,t),s=a<r&&a<n?gE(e,t):0,i=s+a-1;r-=i,n-=i;for(var o=yE(r,n),c=r-1;c>=0;--c)for(var u=n-1;u>=0;--u)o[u][c]=mE(o,e,t,a,c,u);return{prefix:a,matrix:o,suffix:s}}function pE(e,t,r){var n,a,s,i,o=r.matrix,c=r.prefix;for(n=0;n<c;++n)t=e(t,Wa,n,n);for(s=n,c=o.length,n=0,a=0;n<c;)switch(i=o[n][a].type,t=e(t,i,n+s,a+s),i){case Wa:++n,++a;break;case Qo:++a;break;case Wo:++n;break}for(n+=s,a+=s,c=r.suffix,s=0;s<c;++s)t=e(t,Wa,n+s,a+s);return t}function fE(e,t){for(var r=0,n=Math.min(e.length,t.length);r<n&&e[r]===t[r];)++r;return r}function gE(e,t){for(var r=e.length-1,n=t.length-1,a=Math.min(r,n),s=0;s<a&&e[r-s]===t[n-s];)++s;return s}function mE(e,t,r,n,a,s){return t[a+n]===r[s+n]?{value:e[s+1][a+1].value,type:Wa}:e[s][a+1].value<e[s+1][a].value?{value:e[s][a+1].value+1,type:Qo}:{value:e[s+1][a].value+1,type:Wo}}function yE(e,t){var r=[],n,a,s;for(s=r[t]=[],a=0;a<e;++a)s[a]={value:e-a,type:Qo};for(n=0;n<t;++n)r[n]=[],r[n][e]={value:t-n,type:Wo};return r[t][e]={value:0,type:Wa},r}var mi={};/** @license MIT License (c) copyright 2010-2014 original author or authors */mi.cons=vE;mi.tail=bE;mi.map=CE;function vE(e,t){var r=t.length,n=new Array(r+1);n[0]=e;for(var a=0;a<r;++a)n[a+1]=t[a];return n}function bE(e){for(var t=e.length-1,r=new Array(t),n=0;n<t;++n)r[n]=e[n+1];return r}function CE(e,t){for(var r=new Array(t.length),n=0;n<t.length;++n)r[n]=e(t[n]);return r}var Cs={},aa={},Fr={};/** @license MIT License (c) copyright 2010-2014 original author or authors */var SE=wE,_i=/\/|~1|~0/g,gu="/",EE="~",xE="~1";function wE(e,t){var r,n,a,s;for(r=e.charAt(0)===gu?1:0,n="",_i.lastIndex=r;a=_i.exec(e);)if(s=a[0],n+=e.slice(r,_i.lastIndex-s.length),r=_i.lastIndex,s===gu){if(t(n)===!1)return e;n=""}else n+=s===xE?gu:EE;return n+=e.slice(r),t(n),e}/** @license MIT License (c) copyright 2010-2014 original author or authors */var Im=SE;Fr.find=RE;Fr.join=BE;Fr.absolute=NE;Fr.parse=kE;Fr.contains=OE;Fr.encodeSegment=LE;Fr.decodeSegment=UE;Fr.parseArrayIndex=Xu;Fr.isValidArrayIndex=Pm;var ns="/",TE=/\//g,$E="~1",AE=/~1/g,IE="~",PE=/~/g,_E="~0",DE=/~0/g;function RE(e,t,r,n){if(typeof t=="string"){if(t==="")return{target:e,key:void 0};if(t===ns)return{target:e,key:""};var a=e,s,i=n!==void 0;return Im(t,function(o){if(e==null)return a=null,!1;Array.isArray(e)?s=i?jE(r,Xu(o),e,n):o==="-"?o:Xu(o):s=o,a=e,e=e[s]}),a===null?void 0:{target:a,key:s}}}function NE(e){return e[0]===ns?e:ns+e}function BE(e){return e.join(ns)}function kE(e){var t=[];return Im(e,t.push.bind(t)),t}function OE(e,t){return t.indexOf(e)===0&&t[e.length]===ns}function UE(e){return e.replace(AE,ns).replace(DE,IE)}function LE(e){return e.replace(PE,_E).replace(TE,$E)}var ME=/^(0|[1-9]\d*)$/;function Pm(e){return ME.test(e)}function Xu(e){if(Pm(e))return+e;throw new SyntaxError("invalid array index "+e)}function jE(e,t,r,n){var a=t;if(a<0)throw new Error("array index out of bounds "+a);if(n!==void 0&&typeof e=="function"&&(a=e(t,r,n),a<0))throw new Error("could not find patch context "+n);return a}/** @license MIT License (c) copyright 2010-2014 original author or authors */var _m=a0;function a0(e){return e==null||typeof e!="object"?e:Array.isArray(e)?FE(e):qE(e)}function FE(e){for(var t=e.length,r=new Array(t),n=0;n<t;++n)r[n]=a0(e[n]);return r}function qE(e){for(var t=Object.keys(e),r={},n,a=0,s=t.length;a<s;++a)n=t[a],r[n]=a0(e[n]);return r}var HE=s0;function s0(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?KE(e,t):typeof e=="object"&&typeof t=="object"?VE(e,t):!1}function KE(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;++r)if(!s0(e[r],t[r]))return!1;return!0}function VE(e,t){if(e===null&&t!==null||e!==null&&t===null)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var a=0,s;a<r.length;++a)if(s=r[a],!(s in t&&s0(e[s],t[s])))return!1;return!0}var or=Fr,zE=function(e,t){var r=or.parse(e.path),n=or.parse(t.path),a=YE(r,n),s=WE(r,n,a.length),i=vp(e),o=vp(t);return a.length===0&&!s?[o,i]:s?QE(i,r,o,n):GE(i,r,o)};function GE(e,t,r,n){if(e.path===r.path)throw new TypeError("cannot commute "+e.op+","+r.op+" with identical object paths");return[r,e]}function QE(e,t,r,n){return t.length===n.length?ZE(e,t,r,n):(t.length>n.length?(t=yp(r,n,e,t,-1),e.path=or.absolute(or.join(t))):(n=yp(e,t,r,n,1),r.path=or.absolute(or.join(n))),[r,e])}function WE(e,t,r){return or.isValidArrayIndex(e[r])&&or.isValidArrayIndex(t[r])}function ZE(e,t,r,n){var a=t.length-1,s=+t[a],i=+n[a],o;return s<i?e.op==="add"||e.op==="copy"?(o=n.slice(),o[a]=Math.max(0,i-1),r.path=or.absolute(or.join(o))):e.op==="remove"&&(o=n.slice(),o[a]=i+1,r.path=or.absolute(or.join(o))):r.op==="add"||r.op==="copy"?(o=t.slice(),o[a]=s+1,e.path=or.absolute(or.join(o))):s>i&&r.op==="remove"&&(o=t.slice(),o[a]=Math.max(0,s-1),e.path=or.absolute(or.join(o))),[r,e]}function yp(e,t,r,n,a){var s=t.length-1,i=+t[s],o=+n[s],c=n.slice();return i>o||(e.op==="add"||e.op==="copy"?c[s]=Math.max(0,o-a):e.op==="remove"&&(c[s]=Math.max(0,o+a))),c}function YE(e,t){var r=e.length,n=t.length;if(r===0||n===0||r<2&&n<2)return[];for(var a=r===n?r-1:Math.min(r,n),s=0;s<a&&e[s]===t[s];)++s;return e.slice(0,s)}function vp(e){return e.op==="remove"?{op:e.op,path:e.path}:e.op==="copy"||e.op==="move"?{op:e.op,path:e.path,from:e.from}:{op:e.op,path:e.path,value:e.value}}var Dm=go;function go(e){Error.call(this),this.name=this.constructor.name,this.message=e,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,this.constructor)}go.prototype=Object.create(Error.prototype);go.prototype.constructor=go;var i0=mo;function mo(e){Error.call(this),this.name=this.constructor.name,this.message=e,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,this.constructor)}mo.prototype=Object.create(Error.prototype);mo.prototype.constructor=mo;var Rm=yo;function yo(e){Error.call(this),this.name=this.constructor.name,this.message=e,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,this.constructor)}yo.prototype=Object.create(Error.prototype);yo.prototype.constructor=yo;var o0=Fr,c0=_m,XE=HE,yi=zE,vo=mi,JE=Dm,un=i0,u0=Rm,Yn=o0.find,Zo=o0.parseArrayIndex;aa.test={apply:ex,inverse:tx,commute:rx};aa.add={apply:nx,inverse:ax,commute:Nm};aa.remove={apply:cx,inverse:ux,commute:lx};aa.replace={apply:sx,inverse:ix,commute:ox};aa.move={apply:dx,inverse:hx,commute:px};aa.copy={apply:fx,inverse:gx,commute:Nm};function ex(e,t,r){var n=Yn(e,t.path,r.findContext,t.context),a=n.target,s,i;if(Array.isArray(a)?(s=Zo(n.key),i=a[s]):i=n.key===void 0?n.target:n.target[n.key],!XE(i,t.value))throw new JE("test failed "+JSON.stringify(t));return e}function tx(e,t){return e.push(t),1}function rx(e,t){if(e.path===t.path&&t.op==="remove")throw new TypeError("Can't commute test,remove -> remove,test for same path");return t.op==="test"||t.op==="replace"?[t,e]:yi(e,t)}function nx(e,t,r){var n=Yn(e,t.path,r.findContext,t.context);if(Yo(n))throw new un("path does not exist "+t.path);if(t.value===void 0)throw new un("missing value");var a=c0(t.value);return n.key===void 0?a:(l0(n,a),e)}function l0(e,t){var r=e.target;if(Array.isArray(r))if(e.key==="-")r.push(t);else{if(e.key>r.length)throw new un("target of add outside of array bounds");r.splice(e.key,0,t)}else if(Om(r))r[e.key]=t;else throw new un("target of add must be an object or array "+e.key)}function ax(e,t){var r=t.context;return r!==void 0&&(r={before:r.before,after:vo.cons(t.value,r.after)}),e.push({op:"test",path:t.path,value:t.value,context:r}),e.push({op:"remove",path:t.path,context:r}),1}function Nm(e,t){if(e.path===t.path&&t.op==="remove")throw new TypeError("Can't commute add,remove -> remove,add for same path");return yi(e,t)}function sx(e,t,r){var n=Yn(e,t.path,r.findContext,t.context);if(Yo(n)||km(n))throw new un("path does not exist "+t.path);if(t.value===void 0)throw new un("missing value");var a=c0(t.value);if(n.key===void 0)return a;var s=n.target;return Array.isArray(s)?s[Zo(n.key)]=a:s[n.key]=a,e}function ix(e,t,r,n){var a=n[r-1];if(a===void 0||a.op!=="test"||a.path!==t.path)throw new u0("cannot invert replace w/o test");var s=a.context;return s!==void 0&&(s={before:s.before,after:vo.cons(a.value,vo.tail(s.after))}),e.push({op:"test",path:a.path,value:t.value}),e.push({op:"replace",path:a.path,value:a.value}),2}function ox(e,t){if(e.path===t.path&&t.op==="remove")throw new TypeError("Can't commute replace,remove -> remove,replace for same path");return t.op==="test"||t.op==="replace"?[t,e]:yi(e,t)}function cx(e,t,r){var n=Yn(e,t.path,r.findContext,t.context);if(Yo(n)||n.target[n.key]===void 0)throw new un("path does not exist "+t.path);return Bm(n),e}function Bm(e){var t=e.target,r;if(Array.isArray(t))return r=t.splice(Zo(e.key),1),r[0];if(Om(t))return r=t[e.key],delete t[e.key],r;throw new un("target of remove must be an object or array")}function ux(e,t,r,n){var a=n[r-1];if(a===void 0||a.op!=="test"||a.path!==t.path)throw new u0("cannot invert remove w/o test");var s=a.context;return s!==void 0&&(s={before:s.before,after:vo.tail(s.after)}),e.push({op:"add",path:a.path,value:a.value,context:s}),2}function lx(e,t){return e.path===t.path&&t.op==="remove"?[t,e]:yi(e,t)}function dx(e,t,r){if(o0.contains(t.path,t.from))throw new un("move.from cannot be ancestor of move.path");var n=Yn(e,t.path,r.findContext,t.context),a=Yn(e,t.from,r.findContext,t.fromContext);return l0(n,Bm(a)),e}function hx(e,t){return e.push({op:"move",path:t.from,context:t.fromContext,from:t.path,fromContext:t.context}),1}function px(e,t){if(e.path===t.path&&t.op==="remove")throw new TypeError("Can't commute move,remove -> move,replace for same path");return yi(e,t)}function fx(e,t,r){var n=Yn(e,t.path,r.findContext,t.context),a=Yn(e,t.from,r.findContext,t.fromContext);if(Yo(a)||km(a))throw new un("copy.from must exist");var s=a.target,i;return Array.isArray(s)?i=s[Zo(a.key)]:i=s[a.key],l0(n,c0(i)),e}function gx(e,t){throw new u0("cannot invert "+t.op)}function Yo(e){return e===void 0||e.target==null&&e.key!==void 0}function km(e){return e.key!==void 0&&e.target[e.key]===void 0}function Om(e){return e!==null&&typeof e=="object"}/** @license MIT License (c) copyright 2010-2014 original author or authors */var mx=aa,Um=_m,yx=i0;Cs.apply=bx;Cs.applyInPlace=Lm;Cs.clone=Um;Cs.isValidObject=Mm;Cs.defaultHash=Cx;var vx={};function bx(e,t,r){return Lm(e,Um(t),r)}function Lm(e,t,r){if(r||(r=vx),!Array.isArray(e))return t;for(var n,a,s=0;s<e.length;++s){if(a=e[s],n=mx[a.op],n===void 0)throw new yx("invalid op "+JSON.stringify(a));t=n.apply(t,a,r)}return t}function Cx(e){return Mm(e)||Sx(e)?JSON.stringify(e):e}function Mm(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function Sx(e){return Object.prototype.toString.call(e)==="[object Array]"}var Ex=aa,xx=function(e){var t=[],r,n;for(r=e.length-1;r>=0;r-=n)n=wx(t,e[r],r,e);return t};function wx(e,t,r,n){var a=Ex[t.op];return a!==void 0&&typeof a.inverse=="function"?a.inverse(e,t,r,n):1}/** @license MIT License (c) copyright 2010-2014 original author or authors */var Vi=bs,bp=mi,vi=Cs,Tx=xx,$x=Fr,Cp=$x.encodeSegment;sr.diff=Ax;sr.patch=vi.apply;sr.patchInPlace=vi.applyInPlace;sr.inverse=Tx;sr.clone=vi.clone;sr.InvalidPatchOperationError=i0;sr.TestFailedError=Dm;sr.PatchNotInvertibleError=Rm;var Sp=vi.isValidObject,Ep=vi.defaultHash;function Ax(e,t,r){return d0(e,t,"",Ix(r,[])).patch}function Ix(e,t){return typeof e=="object"?{patch:t,hash:mu(yu,e.hash,Ep),makeContext:mu(yu,e.makeContext,xp),invertible:e.invertible!==!1}:{patch:t,hash:mu(yu,e,Ep),makeContext:xp,invertible:!0}}function d0(e,t,r,n){return Array.isArray(e)&&Array.isArray(t)?_x(e,t,r,n):Sp(e)&&Sp(t)?Px(e,t,r,n):Rx(e,t,r,n)}function Px(e,t,r,n){var a=Object.keys(t),s=n.patch,i,o;for(i=a.length-1;i>=0;--i){o=a[i];var c=r+"/"+Cp(o);e[o]!==void 0?d0(e[o],t[o],c,n):s.push({op:"add",path:c,value:t[o]})}for(a=Object.keys(e),i=a.length-1;i>=0;--i)if(o=a[i],t[o]===void 0){var u=r+"/"+Cp(o);n.invertible&&s.push({op:"test",path:u,value:e[o]}),s.push({op:"remove",path:u})}return n}function _x(e,t,r,n){var a=bp.map(n.hash,e),s=bp.map(n.hash,t),i=Vi.compare(a,s);return Dx(e,t,r,n,i)}function Dx(e,t,r,n,a){var s=0;return Vi.reduce(function(i,o,c,u){var l,d,h=i.patch,p=r+"/"+(u+s);return o===Vi.REMOVE?(l=h[h.length-1],d=i.makeContext(u,e),i.invertible&&h.push({op:"test",path:p,value:e[u],context:d}),l!==void 0&&l.op==="add"&&l.path===p?(l.op="replace",l.context=d):h.push({op:"remove",path:p,context:d}),s-=1):o===Vi.ADD?(h.push({op:"add",path:p,value:t[c],context:i.makeContext(u,e)}),s+=1):d0(e[u],t[c],p,i),i},n,a)}function Rx(e,t,r,n){return e!==t&&(n.invertible&&n.patch.push({op:"test",path:r,value:e}),n.patch.push({op:"replace",path:r,value:t})),n}function mu(e,t,r){return e(t)?t:r}function xp(){}function yu(e){return typeof e=="function"}var bo;(e=>{(t=>{t[t.NORMAL=0]="NORMAL",t[t.REQUEST=1]="REQUEST",t[t.DIRECT=2]="DIRECT"})(e.TransferType||(e.TransferType={})),(t=>{t[t.CREATED=0]="CREATED",t[t.LOCKED=1]="LOCKED",t[t.SEND=2]="SEND",t[t.APPLIED=3]="APPLIED",t[t.CANCELED=-1]="CANCELED"})(e.TransferStatus||(e.TransferStatus={}))})(bo||(bo={}));var Ea=(e=>(e.ENABLED="ENABLED",e.DISABLED="DISABLED",e))(Ea||{});function h0(e,t,r="uuid"){const n={};if(!Object.is(e,t)&&typeof e!==void 0)return!t||typeof t!="object"?t:(Object.keys(e||{}).concat(Object.keys(t||{})).forEach(a=>{a===r&&(n[a]=t[a]),t[a]!==(e==null?void 0:e[a])&&!Object.is(e==null?void 0:e[a],t[a])&&(n[a]=t[a])}),n)}function Xo(e,t){let r={};return Object.entries(t).filter(([n,a])=>{if((t==null?void 0:t[n])!==null&&typeof(t==null?void 0:t[n])=="object"){const s=h0(e==null?void 0:e[n],t==null?void 0:t[n]);s&&(r[n]=s)}else a!==(e==null?void 0:e[n])&&(r[n]=a)}),r}function bi(e){return Object.keys(e).forEach(function(t){(this[t]===""||this[t]==null)&&(this[t]=null)},e)}function as(e){return Object.keys(e).forEach(function(t){(this[t]===""||this[t]==null)&&delete this[t]},e)}const Nx="pdf/v1",Bx=new URL(Nx,Et),VP=async e=>{const t=new URLSearchParams(Object.entries(e));return Q(Bx.toString()+"/pdf/statementAccount?"+t,{responseType:"blob"}).then(r=>r.data)};/**
 * @license MIT <https://opensource.org/licenses/MIT>
 * @copyright Michael Hart 2022
 */const Ju=new TextEncoder,kx={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},Ox=new Set(["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"]);let Jo=class{constructor({accessKeyId:t,secretAccessKey:r,sessionToken:n,service:a,region:s,cache:i,retries:o,initRetryMs:c}){if(t==null)throw new TypeError("accessKeyId is a required option");if(r==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=t,this.secretAccessKey=r,this.sessionToken=n,this.service=a,this.region=s,this.cache=i||new Map,this.retries=o??10,this.initRetryMs=c||50}async sign(t,r){if(t instanceof Request){const{method:s,url:i,headers:o,body:c}=t;r=Object.assign({method:s,url:i,headers:o},r),r.body==null&&o.has("Content-Type")&&(r.body=c!=null&&o.has("X-Amz-Content-Sha256")?c:await t.clone().arrayBuffer()),t=i}const n=new Ux(Object.assign({url:t},r,this,r&&r.aws)),a=Object.assign({},r,await n.sign());delete a.aws;try{return new Request(a.url.toString(),a)}catch(s){if(s instanceof TypeError)return new Request(a.url.toString(),Object.assign({duplex:"half"},a));throw s}}async fetch(t,r){for(let n=0;n<=this.retries;n++){const a=fetch(await this.sign(t,r));if(n===this.retries)return a;const s=await a;if(s.status<500&&s.status!==429)return s;await new Promise(i=>setTimeout(i,Math.random()*this.initRetryMs*Math.pow(2,n)))}throw new Error("An unknown error occurred, ensure retries is not negative")}},Ux=class{constructor({method:t,url:r,headers:n,body:a,accessKeyId:s,secretAccessKey:i,sessionToken:o,service:c,region:u,cache:l,datetime:d,signQuery:h,appendSessionToken:p,allHeaders:f,singleEncode:g}){if(r==null)throw new TypeError("url is a required option");if(s==null)throw new TypeError("accessKeyId is a required option");if(i==null)throw new TypeError("secretAccessKey is a required option");this.method=t||(a?"POST":"GET"),this.url=new URL(r),this.headers=new Headers(n||{}),this.body=a,this.accessKeyId=s,this.secretAccessKey=i,this.sessionToken=o;let y,b;(!c||!u)&&([y,b]=Lx(this.url,this.headers)),this.service=c||y||"",this.region=u||b||"us-east-1",this.cache=l||new Map,this.datetime=d||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=h,this.appendSessionToken=p||this.service==="iotdevicegateway",this.headers.delete("Host"),this.service==="s3"&&!this.signQuery&&!this.headers.has("X-Amz-Content-Sha256")&&this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD");const m=this.signQuery?this.url.searchParams:this.headers;if(m.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&m.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(S=>f||!Ox.has(S)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(S=>S+":"+(S==="host"?this.url.host:(this.headers.get(S)||"").replace(/\s+/g," "))).join(`
`),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!m.has("X-Amz-Expires")&&m.set("X-Amz-Expires","86400"),m.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),m.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),m.set("X-Amz-SignedHeaders",this.signedHeaders)),this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch{this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");g||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=Tp(this.encodedPath);const v=new Set;this.encodedSearch=[...this.url.searchParams].filter(([S])=>{if(!S)return!1;if(this.service==="s3"){if(v.has(S))return!1;v.add(S)}return!0}).map(S=>S.map(C=>Tp(encodeURIComponent(C)))).sort(([S,C],[E,w])=>S<E?-1:S>E?1:C<w?-1:C>w?1:0).map(S=>S.join("=")).join("&")}async sign(){return this.signQuery?(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken&&this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)):this.headers.set("Authorization",await this.authHeader()),{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){const t=this.datetime.slice(0,8),r=[this.secretAccessKey,t,this.region,this.service].join();let n=this.cache.get(r);if(!n){const a=await Us("AWS4"+this.secretAccessKey,t),s=await Us(a,this.region),i=await Us(s,this.service);n=await Us(i,"aws4_request"),this.cache.set(r,n)}return vu(await Us(n,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,vu(await wp(await this.canonicalString()))].join(`
`)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
`,this.signedHeaders,await this.hexBodyHash()].join(`
`)}async hexBodyHash(){let t=this.headers.get("X-Amz-Content-Sha256")||(this.service==="s3"&&this.signQuery?"UNSIGNED-PAYLOAD":null);if(t==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");t=vu(await wp(this.body||""))}return t}};async function Us(e,t){const r=await crypto.subtle.importKey("raw",typeof e=="string"?Ju.encode(e):e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",r,Ju.encode(t))}async function wp(e){return crypto.subtle.digest("SHA-256",typeof e=="string"?Ju.encode(e):e)}function vu(e){return Array.prototype.map.call(new Uint8Array(e),t=>("0"+t.toString(16)).slice(-2)).join("")}function Tp(e){return e.replace(/[!'()*]/g,t=>"%"+t.charCodeAt(0).toString(16).toUpperCase())}function Lx(e,t){const{hostname:r,pathname:n}=e;if(r.endsWith(".r2.cloudflarestorage.com"))return["s3","auto"];if(r.endsWith(".backblazeb2.com")){const o=r.match(/^(?:[^.]+\.)?s3\.([^.]+)\.backblazeb2\.com$/);return o!=null?["s3",o[1]]:["",""]}const a=r.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/);let[s,i]=(a||["",""]).slice(1,3);if(i==="us-gov")i="us-gov-west-1";else if(i==="s3"||i==="s3-accelerate")i="us-east-1",s="s3";else if(s==="iot")r.startsWith("iot.")?s="execute-api":r.startsWith("data.jobs.iot.")?s="iot-jobs-data":s=n==="/mqtt"?"iotdevicegateway":"iotdata";else if(s==="autoscaling"){const o=(t.get("X-Amz-Target")||"").split(".")[0];o==="AnyScaleFrontendService"?s="application-autoscaling":o==="AnyScaleScalingPlannerFrontendService"&&(s="autoscaling-plans")}else i==null&&s.startsWith("s3-")?(i=s.slice(3).replace(/^fips-|^external-1/,""),s="s3"):s.endsWith("-fips")?s=s.slice(0,-5):i&&/-\d$/.test(s)&&!/-\d$/.test(i)&&([s,i]=[i,s]);return[kx[s]||s,i]}var Mx=Object.defineProperty,jx=(e,t,r)=>t in e?Mx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fx=(e,t,r)=>jx(e,t+"",r);const _t=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ft=Object.keys,ur=Array.isArray;function br(e,t){return typeof t!="object"||Ft(t).forEach(function(r){e[r]=t[r]}),e}typeof Promise>"u"||_t.Promise||(_t.Promise=Promise);const ei=Object.getPrototypeOf,qx={}.hasOwnProperty;function Dr(e,t){return qx.call(e,t)}function ss(e,t){typeof t=="function"&&(t=t(ei(e))),(typeof Reflect>"u"?Ft:Reflect.ownKeys)(t).forEach(r=>{Tn(e,r,t[r])})}const jm=Object.defineProperty;function Tn(e,t,r,n){jm(e,t,br(r&&Dr(r,"get")&&typeof r.get=="function"?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function Za(e){return{from:function(t){return e.prototype=Object.create(t.prototype),Tn(e.prototype,"constructor",e),{extend:ss.bind(null,e.prototype)}}}}const Hx=Object.getOwnPropertyDescriptor;function p0(e,t){let r;return Hx(e,t)||(r=ei(e))&&p0(r,t)}const Kx=[].slice;function Co(e,t,r){return Kx.call(e,t,r)}function Fm(e,t){return t(e)}function Fs(e){if(!e)throw new Error("Assertion Failed")}function qm(e){_t.setImmediate?setImmediate(e):setTimeout(e,0)}function Hm(e,t){return e.reduce((r,n,a)=>{var s=t(n,a);return s&&(r[s[0]]=s[1]),r},{})}function $n(e,t){if(Dr(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var r=[],n=0,a=t.length;n<a;++n){var s=$n(e,t[n]);r.push(s)}return r}var i=t.indexOf(".");if(i!==-1){var o=e[t.substr(0,i)];return o===void 0?void 0:$n(o,t.substr(i+1))}}function zr(e,t,r){if(e&&t!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){Fs(typeof r!="string"&&"length"in r);for(var n=0,a=t.length;n<a;++n)zr(e,t[n],r[n])}else{var s=t.indexOf(".");if(s!==-1){var i=t.substr(0,s),o=t.substr(s+1);if(o==="")r===void 0?ur(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=r;else{var c=e[i];c&&Dr(e,i)||(c=e[i]={}),zr(c,o,r)}}else r===void 0?ur(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function Km(e){var t={};for(var r in e)Dr(e,r)&&(t[r]=e[r]);return t}const Vx=[].concat;function Vm(e){return Vx.apply([],e)}const zm="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Vm([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>_t[e]),zx=zm.map(e=>_t[e]);Hm(zm,e=>[e,!0]);let Ln=null;function Ci(e){Ln=typeof WeakMap<"u"&&new WeakMap;const t=el(e);return Ln=null,t}function el(e){if(!e||typeof e!="object")return e;let t=Ln&&Ln.get(e);if(t)return t;if(ur(e)){t=[],Ln&&Ln.set(e,t);for(var r=0,n=e.length;r<n;++r)t.push(el(e[r]))}else if(zx.indexOf(e.constructor)>=0)t=e;else{const s=ei(e);for(var a in t=s===Object.prototype?{}:Object.create(s),Ln&&Ln.set(e,t),e)Dr(e,a)&&(t[a]=el(e[a]))}return t}const{toString:Gx}={};function tl(e){return Gx.call(e).slice(8,-1)}const rl=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Qx=typeof rl=="symbol"?function(e){var t;return e!=null&&(t=e[rl])&&t.apply(e)}:function(){return null},Ha={};function bn(e){var t,r,n,a;if(arguments.length===1){if(ur(e))return e.slice();if(this===Ha&&typeof e=="string")return[e];if(a=Qx(e)){for(r=[];!(n=a.next()).done;)r.push(n.value);return r}if(e==null)return[e];if(typeof(t=e.length)=="number"){for(r=new Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=new Array(t);t--;)r[t]=arguments[t];return r}const f0=typeof Symbol<"u"?e=>e[Symbol.toStringTag]==="AsyncFunction":()=>!1;var fn=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Gm(e,t){fn=e,Qm=t}var Qm=()=>!0;const Wx=!new Error("").stack;function Ba(){if(Wx)try{throw Ba.arguments,new Error}catch(e){return e}return new Error}function nl(e,t){var r=e.stack;return r?(t=t||0,r.indexOf(e.name)===0&&(t+=(e.name+e.message).split(`
`).length),r.split(`
`).slice(t).filter(Qm).map(n=>`
`+n).join("")):""}var Wm=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],g0=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Wm),Zx={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function Ya(e,t){this._e=Ba(),this.name=e,this.message=t}function Zm(e,t){return e+". Errors: "+Object.keys(t).map(r=>t[r].toString()).filter((r,n,a)=>a.indexOf(r)===n).join(`
`)}function So(e,t,r,n){this._e=Ba(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=Zm(e,t)}function Gs(e,t){this._e=Ba(),this.name="BulkError",this.failures=Object.keys(t).map(r=>t[r]),this.failuresByPos=t,this.message=Zm(e,t)}Za(Ya).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+nl(this._e,2))}},toString:function(){return this.name+": "+this.message}}),Za(So).from(Ya),Za(Gs).from(Ya);var m0=g0.reduce((e,t)=>(e[t]=t+"Error",e),{});const Yx=Ya;var qe=g0.reduce((e,t)=>{var r=t+"Error";function n(a,s){this._e=Ba(),this.name=r,a?typeof a=="string"?(this.message=`${a}${s?`
 `+s:""}`,this.inner=s||null):typeof a=="object"&&(this.message=`${a.name} ${a.message}`,this.inner=a):(this.message=Zx[t]||r,this.inner=null)}return Za(n).from(Yx),e[t]=n,e},{});qe.Syntax=SyntaxError,qe.Type=TypeError,qe.Range=RangeError;var $p=Wm.reduce((e,t)=>(e[t+"Error"]=qe[t],e),{}),zi=g0.reduce((e,t)=>(["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=qe[t]),e),{});function Ct(){}function ti(e){return e}function Xx(e,t){return e==null||e===ti?t:function(r){return t(e(r))}}function xa(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function Jx(e,t){return e===Ct?t:function(){var r=e.apply(this,arguments);r!==void 0&&(arguments[0]=r);var n=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var s=t.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?xa(n,this.onsuccess):n),a&&(this.onerror=this.onerror?xa(a,this.onerror):a),s!==void 0?s:r}}function ew(e,t){return e===Ct?t:function(){e.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?xa(r,this.onsuccess):r),n&&(this.onerror=this.onerror?xa(n,this.onerror):n)}}function tw(e,t){return e===Ct?t:function(r){var n=e.apply(this,arguments);br(r,n);var a=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?xa(a,this.onsuccess):a),s&&(this.onerror=this.onerror?xa(s,this.onerror):s),n===void 0?i===void 0?void 0:i:br(n,i)}}function rw(e,t){return e===Ct?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function y0(e,t){return e===Ct?t:function(){var r=e.apply(this,arguments);if(r&&typeof r.then=="function"){for(var n=this,a=arguments.length,s=new Array(a);a--;)s[a]=arguments[a];return r.then(function(){return t.apply(n,s)})}return t.apply(this,arguments)}}zi.ModifyError=So,zi.DexieError=Ya,zi.BulkError=Gs;var ri={};const[al,Eo,sl]=typeof Promise>"u"?[]:(()=>{let e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,ei(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,ei(t),e]})(),Ym=Eo&&Eo.then,Gi=al&&al.constructor,v0=!!sl;var il=!1,nw=sl?()=>{sl.then(Di)}:_t.setImmediate?setImmediate.bind(null,Di):_t.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{Di(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(Di,0)},Qs=function(e,t){qs.push([e,t]),xo&&(nw(),xo=!1)},ol=!0,xo=!0,ya=[],Qi=[],cl=null,ul=ti,Xa={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Ip,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{Ip(e[0],e[1])}catch{}})}},Me=Xa,qs=[],va=0,Wi=[];function Pe(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=Ct,this._lib=!1;var t=this._PSD=Me;if(fn&&(this._stackHolder=Ba(),this._prev=null,this._numPrev=0),typeof e!="function"){if(e!==ri)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&dl(this,this._value))}this._state=null,this._value=null,++t.ref,Jm(this,e)}const ll={get:function(){var e=Me,t=wo;function r(n,a){var s=!e.global&&(e!==Me||t!==wo);const i=s&&!An();var o=new Pe((c,u)=>{b0(this,new Xm(To(n,e,s,i),To(a,e,s,i),c,u,e))});return fn&&ry(o,this),o}return r.prototype=ri,r},set:function(e){Tn(this,"then",e&&e.prototype===ri?ll:{get:function(){return e},set:ll.set})}};function Xm(e,t,r,n,a){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=r,this.reject=n,this.psd=a}function Jm(e,t){try{t(r=>{if(e._state===null){if(r===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&Si();r&&typeof r.then=="function"?Jm(e,(a,s)=>{r instanceof Pe?r._then(a,s):r.then(a,s)}):(e._state=!0,e._value=r,ey(e)),n&&Ei()}},dl.bind(null,e))}catch(r){dl(e,r)}}function dl(e,t){if(Qi.push(t),e._state===null){var r=e._lib&&Si();t=ul(t),e._state=!1,e._value=t,fn&&t!==null&&typeof t=="object"&&!t._promise&&function(n,a,s){try{n.apply(null,s)}catch{}}(()=>{var n=p0(t,"stack");t._promise=e,Tn(t,"stack",{get:()=>il?n&&(n.get?n.get.apply(t):n.value):e.stack})}),function(n){ya.some(a=>a._value===n._value)||ya.push(n)}(e),ey(e),r&&Ei()}}function ey(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)b0(e,t[r]);var a=e._PSD;--a.ref||a.finalize(),va===0&&(++va,Qs(()=>{--va==0&&C0()},[]))}function b0(e,t){if(e._state!==null){var r=e._state?t.onFulfilled:t.onRejected;if(r===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++va,Qs(aw,[r,e,t])}else e._listeners.push(t)}function aw(e,t,r){try{cl=t;var n,a=t._value;t._state?n=e(a):(Qi.length&&(Qi=[]),n=e(a),Qi.indexOf(a)===-1&&function(s){for(var i=ya.length;i;)if(ya[--i]._value===s._value)return void ya.splice(i,1)}(t)),r.resolve(n)}catch(s){r.reject(s)}finally{cl=null,--va==0&&C0(),--r.psd.ref||r.psd.finalize()}}function ty(e,t,r){if(t.length===r)return t;var n="";if(e._state===!1){var a,s,i=e._value;i!=null?(a=i.name||"Error",s=i.message||i,n=nl(i,0)):(a=i,s=""),t.push(a+(s?": "+s:"")+n)}return fn&&((n=nl(e._stackHolder,2))&&t.indexOf(n)===-1&&t.push(n),e._prev&&ty(e._prev,t,r)),t}function ry(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function Di(){Si()&&Ei()}function Si(){var e=ol;return ol=!1,xo=!1,e}function Ei(){var e,t,r;do for(;qs.length>0;)for(e=qs,qs=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(qs.length>0);ol=!0,xo=!0}function C0(){var e=ya;ya=[],e.forEach(n=>{n._PSD.onunhandled.call(null,n._value,n)});for(var t=Wi.slice(0),r=t.length;r;)t[--r]()}function Ri(e){return new Pe(ri,!1,e)}function Bt(e,t){var r=Me;return function(){var n=Si(),a=Me;try{return Jn(r,!0),e.apply(this,arguments)}catch(s){t&&t(s)}finally{Jn(a,!1),n&&Ei()}}}ss(Pe.prototype,{then:ll,_then:function(e,t){b0(this,new Xm(null,null,e,t,Me))},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=arguments[0],r=arguments[1];return typeof t=="function"?this.then(null,n=>n instanceof t?r(n):Ri(n)):this.then(null,n=>n&&n.name===t?r(n):Ri(n))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),Ri(t)))},stack:{get:function(){if(this._stack)return this._stack;try{il=!0;var e=ty(this,[],20).join(`
From previous: `);return this._state!==null&&(this._stack=e),e}finally{il=!1}}},timeout:function(e,t){return e<1/0?new Pe((r,n)=>{var a=setTimeout(()=>n(new qe.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,a))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&Tn(Pe.prototype,Symbol.toStringTag,"Dexie.Promise"),Xa.env=ny(),ss(Pe,{all:function(){var e=bn.apply(null,arguments).map(Ni);return new Pe(function(t,r){e.length===0&&t([]);var n=e.length;e.forEach((a,s)=>Pe.resolve(a).then(i=>{e[s]=i,--n||t(e)},r))})},resolve:e=>{if(e instanceof Pe)return e;if(e&&typeof e.then=="function")return new Pe((r,n)=>{e.then(r,n)});var t=new Pe(ri,!0,e);return ry(t,cl),t},reject:Ri,race:function(){var e=bn.apply(null,arguments).map(Ni);return new Pe((t,r)=>{e.map(n=>Pe.resolve(n).then(t,r))})},PSD:{get:()=>Me,set:e=>Me=e},totalEchoes:{get:()=>wo},newPSD:Xn,usePSD:Es,scheduler:{get:()=>Qs,set:e=>{Qs=e}},rejectionMapper:{get:()=>ul,set:e=>{ul=e}},follow:(e,t)=>new Pe((r,n)=>Xn((a,s)=>{var i=Me;i.unhandleds=[],i.onunhandled=s,i.finalize=xa(function(){(function(o){function c(){o(),Wi.splice(Wi.indexOf(c),1)}Wi.push(c),++va,Qs(()=>{--va==0&&C0()},[])})(()=>{this.unhandleds.length===0?a():s(this.unhandleds[0])})},i.finalize),e()},t,r,n))}),Gi&&(Gi.allSettled&&Tn(Pe,"allSettled",function(){const e=bn.apply(null,arguments).map(Ni);return new Pe(t=>{e.length===0&&t([]);let r=e.length;const n=new Array(r);e.forEach((a,s)=>Pe.resolve(a).then(i=>n[s]={status:"fulfilled",value:i},i=>n[s]={status:"rejected",reason:i}).then(()=>--r||t(n)))})}),Gi.any&&typeof AggregateError<"u"&&Tn(Pe,"any",function(){const e=bn.apply(null,arguments).map(Ni);return new Pe((t,r)=>{e.length===0&&r(new AggregateError([]));let n=e.length;const a=new Array(n);e.forEach((s,i)=>Pe.resolve(s).then(o=>t(o),o=>{a[i]=o,--n||r(new AggregateError(a))}))})}));const cr={awaits:0,echoes:0,id:0};var sw=0,Zi=[],bu=0,wo=0,iw=0;function Xn(e,t,r,n){var a=Me,s=Object.create(a);s.parent=a,s.ref=0,s.global=!1,s.id=++iw;var i=Xa.env;s.env=v0?{Promise:Pe,PromiseProp:{value:Pe,configurable:!0,writable:!0},all:Pe.all,race:Pe.race,allSettled:Pe.allSettled,any:Pe.any,resolve:Pe.resolve,reject:Pe.reject,nthen:Ap(i.nthen,s),gthen:Ap(i.gthen,s)}:{},t&&br(s,t),++a.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var o=Es(s,e,r,n);return s.ref===0&&s.finalize(),o}function Ss(){return cr.id||(cr.id=++sw),++cr.awaits,cr.echoes+=100,cr.id}function An(){return!!cr.awaits&&(--cr.awaits==0&&(cr.id=0),cr.echoes=100*cr.awaits,!0)}function Ni(e){return cr.echoes&&e&&e.constructor===Gi?(Ss(),e.then(t=>(An(),t),t=>(An(),Vt(t)))):e}function ow(e){++wo,cr.echoes&&--cr.echoes!=0||(cr.echoes=cr.id=0),Zi.push(Me),Jn(e,!0)}function cw(){var e=Zi[Zi.length-1];Zi.pop(),Jn(e,!1)}function Jn(e,t){var r=Me;if((t?!cr.echoes||bu++&&e===Me:!bu||--bu&&e===Me)||ay(t?ow.bind(null,e):cw),e!==Me&&(Me=e,r===Xa&&(Xa.env=ny()),v0)){var n=Xa.env.Promise,a=e.env;Eo.then=a.nthen,n.prototype.then=a.gthen,(r.global||e.global)&&(Object.defineProperty(_t,"Promise",a.PromiseProp),n.all=a.all,n.race=a.race,n.resolve=a.resolve,n.reject=a.reject,a.allSettled&&(n.allSettled=a.allSettled),a.any&&(n.any=a.any))}}function ny(){var e=_t.Promise;return v0?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(_t,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:Eo.then,gthen:e.prototype.then}:{}}function Es(e,t,r,n,a){var s=Me;try{return Jn(e,!0),t(r,n,a)}finally{Jn(s,!1)}}function ay(e){Ym.call(al,e)}function To(e,t,r,n){return typeof e!="function"?e:function(){var a=Me;r&&Ss(),Jn(t,!0);try{return e.apply(this,arguments)}finally{Jn(a,!1),n&&ay(An)}}}function Ap(e,t){return function(r,n){return e.call(this,To(r,t),To(n,t))}}(""+Ym).indexOf("[native code]")===-1&&(Ss=An=Ct);function Ip(e,t){var r;try{r=t.onuncatched(e)}catch{}if(r!==!1)try{var n,a={promise:t,reason:e};if(_t.document&&document.createEvent?((n=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),br(n,a)):_t.CustomEvent&&br(n=new CustomEvent("unhandledrejection",{detail:a}),a),n&&_t.dispatchEvent&&(dispatchEvent(n),!_t.PromiseRejectionEvent&&_t.onunhandledrejection))try{_t.onunhandledrejection(n)}catch{}fn&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch{}}var Vt=Pe.reject;function hl(e,t,r,n){if(e.idbdb&&(e._state.openComplete||Me.letThrough||e._vip)){var a=e._createTransaction(t,r,e._dbSchema);try{a.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===m0.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>hl(e,t,r,n))):Vt(s)}return a._promise(t,(s,i)=>Xn(()=>(Me.trans=a,n(s,i,a)))).then(s=>a._completion.then(()=>s))}if(e._state.openComplete)return Vt(new qe.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return Vt(new qe.DatabaseClosed);e.open().catch(Ct)}return e._state.dbReadyPromise.then(()=>hl(e,t,r,n))}const fa="￿",mn="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Ws=[],ec=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),uw=ec,lw=ec,sy=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function wa(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const iy={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Bi(e){return typeof e!="string"||/\./.test(e)?t=>t:t=>(t[e]===void 0&&e in t&&delete(t=Ci(t))[e],t)}class dw{_trans(t,r,n){const a=this._tx||Me.trans,s=this.name;function i(c,u,l){if(!l.schema[s])throw new qe.NotFound("Table "+s+" not part of transaction");return r(l.idbtrans,l)}const o=Si();try{return a&&a.db===this.db?a===Me.trans?a._promise(t,i,n):Xn(()=>a._promise(t,i,n),{trans:a,transless:Me.transless||Me}):hl(this.db,t,[this.name],i)}finally{o&&Ei()}}get(t,r){return t&&t.constructor===Object?this.where(t).first(r):this._trans("readonly",n=>this.core.get({trans:n,key:t}).then(a=>this.hook.reading.fire(a))).then(r)}where(t){if(typeof t=="string")return new this.db.WhereClause(this,t);if(ur(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);const r=Ft(t);if(r.length===1)return this.where(r[0]).equals(t[r[0]]);const n=this.schema.indexes.concat(this.schema.primKey).filter(u=>u.compound&&r.every(l=>u.keyPath.indexOf(l)>=0)&&u.keyPath.every(l=>r.indexOf(l)>=0))[0];if(n&&this.db._maxKey!==fa)return this.where(n.name).equals(n.keyPath.map(u=>t[u]));!n&&fn&&console.warn(`The query ${JSON.stringify(t)} on ${this.name} would benefit of a compound index [${r.join("+")}]`);const{idxByName:a}=this.schema,s=this.db._deps.indexedDB;function i(u,l){try{return s.cmp(u,l)===0}catch{return!1}}const[o,c]=r.reduce(([u,l],d)=>{const h=a[d],p=t[d];return[u||h,u||!h?wa(l,h&&h.multi?f=>{const g=$n(f,d);return ur(g)&&g.some(y=>i(p,y))}:f=>i(p,$n(f,d))):l]},[null,null]);return o?this.where(o.name).equals(t[o.keyPath]).filter(c):n?this.filter(c):this.where(r).equals("")}filter(t){return this.toCollection().and(t)}count(t){return this.toCollection().count(t)}offset(t){return this.toCollection().offset(t)}limit(t){return this.toCollection().limit(t)}each(t){return this.toCollection().each(t)}toArray(t){return this.toCollection().toArray(t)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(t){return new this.db.Collection(new this.db.WhereClause(this,ur(t)?`[${t.join("+")}]`:t))}reverse(){return this.toCollection().reverse()}mapToClass(t){this.schema.mappedClass=t;const r=n=>{if(!n)return n;const a=Object.create(t.prototype);for(var s in n)if(Dr(n,s))try{a[s]=n[s]}catch{}return a};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=r,this.hook("reading",r),t}defineClass(){return this.mapToClass(function(t){br(this,t)})}add(t,r){const{auto:n,keyPath:a}=this.schema.primKey;let s=t;return a&&n&&(s=Bi(a)(t)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"add",keys:r!=null?[r]:null,values:[s]})).then(i=>i.numFailures?Pe.reject(i.failures[0]):i.lastResult).then(i=>{if(a)try{zr(t,a,i)}catch{}return i})}update(t,r){if(typeof t!="object"||ur(t))return this.where(":id").equals(t).modify(r);{const n=$n(t,this.schema.primKey.keyPath);if(n===void 0)return Vt(new qe.InvalidArgument("Given object does not contain its primary key"));try{typeof r!="function"?Ft(r).forEach(a=>{zr(t,a,r[a])}):r(t,{value:t,primKey:n})}catch{}return this.where(":id").equals(n).modify(r)}}put(t,r){const{auto:n,keyPath:a}=this.schema.primKey;let s=t;return a&&n&&(s=Bi(a)(t)),this._trans("readwrite",i=>this.core.mutate({trans:i,type:"put",values:[s],keys:r!=null?[r]:null})).then(i=>i.numFailures?Pe.reject(i.failures[0]):i.lastResult).then(i=>{if(a)try{zr(t,a,i)}catch{}return i})}delete(t){return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:[t]})).then(r=>r.numFailures?Pe.reject(r.failures[0]):void 0)}clear(){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"deleteRange",range:iy})).then(t=>t.numFailures?Pe.reject(t.failures[0]):void 0)}bulkGet(t){return this._trans("readonly",r=>this.core.getMany({keys:t,trans:r}).then(n=>n.map(a=>this.hook.reading.fire(a))))}bulkAdd(t,r,n){const a=Array.isArray(r)?r:void 0,s=(n=n||(a?void 0:r))?n.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:o,keyPath:c}=this.schema.primKey;if(c&&a)throw new qe.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==t.length)throw new qe.InvalidArgument("Arguments objects and keys must have the same length");const u=t.length;let l=c&&o?t.map(Bi(c)):t;return this.core.mutate({trans:i,type:"add",keys:a,values:l,wantResults:s}).then(({numFailures:d,results:h,lastResult:p,failures:f})=>{if(d===0)return s?h:p;throw new Gs(`${this.name}.bulkAdd(): ${d} of ${u} operations failed`,f)})})}bulkPut(t,r,n){const a=Array.isArray(r)?r:void 0,s=(n=n||(a?void 0:r))?n.allKeys:void 0;return this._trans("readwrite",i=>{const{auto:o,keyPath:c}=this.schema.primKey;if(c&&a)throw new qe.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==t.length)throw new qe.InvalidArgument("Arguments objects and keys must have the same length");const u=t.length;let l=c&&o?t.map(Bi(c)):t;return this.core.mutate({trans:i,type:"put",keys:a,values:l,wantResults:s}).then(({numFailures:d,results:h,lastResult:p,failures:f})=>{if(d===0)return s?h:p;throw new Gs(`${this.name}.bulkPut(): ${d} of ${u} operations failed`,f)})})}bulkDelete(t){const r=t.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:t})).then(({numFailures:n,lastResult:a,failures:s})=>{if(n===0)return a;throw new Gs(`${this.name}.bulkDelete(): ${n} of ${r} operations failed`,s)})}}function Zs(e){var t={},r=function(o,c){if(c){for(var u=arguments.length,l=new Array(u-1);--u;)l[u-1]=arguments[u];return t[o].subscribe.apply(null,l),e}if(typeof o=="string")return t[o]};r.addEventType=s;for(var n=1,a=arguments.length;n<a;++n)s(arguments[n]);return r;function s(o,c,u){if(typeof o=="object")return i(o);c||(c=rw),u||(u=Ct);var l={subscribers:[],fire:u,subscribe:function(d){l.subscribers.indexOf(d)===-1&&(l.subscribers.push(d),l.fire=c(l.fire,d))},unsubscribe:function(d){l.subscribers=l.subscribers.filter(function(h){return h!==d}),l.fire=l.subscribers.reduce(c,u)}};return t[o]=r[o]=l,l}function i(o){Ft(o).forEach(function(c){var u=o[c];if(ur(u))s(c,o[c][0],o[c][1]);else{if(u!=="asap")throw new qe.InvalidArgument("Invalid event config");var l=s(c,ti,function(){for(var d=arguments.length,h=new Array(d);d--;)h[d]=arguments[d];l.subscribers.forEach(function(p){qm(function(){p.apply(null,h)})})})}})}}function Ls(e,t){return Za(t).from({prototype:e}),t}function Ma(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Cu(e,t){e.filter=wa(e.filter,t)}function Su(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>wa(n(),t()):t,e.justLimit=r&&!n}function Yi(e,t){if(e.isPrimKey)return t.primaryKey;const r=t.getIndexByKeyPath(e.index);if(!r)throw new qe.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function Pp(e,t,r){const n=Yi(e,t.schema);return t.openCursor({trans:r,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:n,range:e.range}})}function ki(e,t,r,n){const a=e.replayFilter?wa(e.filter,e.replayFilter()):e.filter;if(e.or){const s={},i=(o,c,u)=>{if(!a||a(c,u,h=>c.stop(h),h=>c.fail(h))){var l=c.primaryKey,d=""+l;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(l)),Dr(s,d)||(s[d]=!0,t(o,c,u))}};return Promise.all([e.or._iterate(i,r),_p(Pp(e,n,r),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return _p(Pp(e,n,r),wa(e.algorithm,a),t,!e.keysOnly&&e.valueMapper)}function _p(e,t,r,n){var a=Bt(n?(s,i,o)=>r(n(s),i,o):r);return e.then(s=>{if(s)return s.start(()=>{var i=()=>s.continue();t&&!t(s,o=>i=o,o=>{s.stop(o),i=Ct},o=>{s.fail(o),i=Ct})||a(s.value,s,o=>i=o),i()})})}function vr(e,t){try{const r=Dp(e),n=Dp(t);if(r!==n)return r==="Array"?1:n==="Array"?-1:r==="binary"?1:n==="binary"?-1:r==="string"?1:n==="string"?-1:r==="Date"?1:n!=="Date"?NaN:-1;switch(r){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(a,s){const i=a.length,o=s.length,c=i<o?i:o;for(let u=0;u<c;++u)if(a[u]!==s[u])return a[u]<s[u]?-1:1;return i===o?0:i<o?-1:1}(Rp(e),Rp(t));case"Array":return function(a,s){const i=a.length,o=s.length,c=i<o?i:o;for(let u=0;u<c;++u){const l=vr(a[u],s[u]);if(l!==0)return l}return i===o?0:i<o?-1:1}(e,t)}}catch{}return NaN}function Dp(e){const t=typeof e;if(t!=="object")return t;if(ArrayBuffer.isView(e))return"binary";const r=tl(e);return r==="ArrayBuffer"?"binary":r}function Rp(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class hw{_read(t,r){var n=this._ctx;return n.error?n.table._trans(null,Vt.bind(null,n.error)):n.table._trans("readonly",t).then(r)}_write(t){var r=this._ctx;return r.error?r.table._trans(null,Vt.bind(null,r.error)):r.table._trans("readwrite",t,"locked")}_addAlgorithm(t){var r=this._ctx;r.algorithm=wa(r.algorithm,t)}_iterate(t,r){return ki(this._ctx,t,r,this._ctx.table.core)}clone(t){var r=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return t&&br(n,t),r._ctx=n,r}raw(){return this._ctx.valueMapper=null,this}each(t){var r=this._ctx;return this._read(n=>ki(r,t,n,r.table.core))}count(t){return this._read(r=>{const n=this._ctx,a=n.table.core;if(Ma(n,!0))return a.count({trans:r,query:{index:Yi(n,a.schema),range:n.range}}).then(i=>Math.min(i,n.limit));var s=0;return ki(n,()=>(++s,!1),r,a).then(()=>s)}).then(t)}sortBy(t,r){const n=t.split(".").reverse(),a=n[0],s=n.length-1;function i(u,l){return l?i(u[n[l]],l-1):u[a]}var o=this._ctx.dir==="next"?1:-1;function c(u,l){var d=i(u,s),h=i(l,s);return d<h?-o:d>h?o:0}return this.toArray(function(u){return u.sort(c)}).then(r)}toArray(t){return this._read(r=>{var n=this._ctx;if(n.dir==="next"&&Ma(n,!0)&&n.limit>0){const{valueMapper:a}=n,s=Yi(n,n.table.core.schema);return n.table.core.query({trans:r,limit:n.limit,values:!0,query:{index:s,range:n.range}}).then(({result:i})=>a?i.map(a):i)}{const a=[];return ki(n,s=>a.push(s),r,n.table.core).then(()=>a)}},t)}offset(t){var r=this._ctx;return t<=0||(r.offset+=t,Ma(r)?Su(r,()=>{var n=t;return(a,s)=>n===0||(n===1?(--n,!1):(s(()=>{a.advance(n),n=0}),!1))}):Su(r,()=>{var n=t;return()=>--n<0})),this}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Su(this._ctx,()=>{var r=t;return function(n,a,s){return--r<=0&&a(s),r>=0}},!0),this}until(t,r){return Cu(this._ctx,function(n,a,s){return!t(n.value)||(a(s),r)}),this}first(t){return this.limit(1).toArray(function(r){return r[0]}).then(t)}last(t){return this.reverse().first(t)}filter(t){var r,n;return Cu(this._ctx,function(a){return t(a.value)}),r=this._ctx,n=t,r.isMatch=wa(r.isMatch,n),this}and(t){return this.filter(t)}or(t){return new this.db.WhereClause(this._ctx.table,t,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(t){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,a){t(a.key,a)})}eachUniqueKey(t){return this._ctx.unique="unique",this.eachKey(t)}eachPrimaryKey(t){var r=this._ctx;return r.keysOnly=!r.isMatch,this.each(function(n,a){t(a.primaryKey,a)})}keys(t){var r=this._ctx;r.keysOnly=!r.isMatch;var n=[];return this.each(function(a,s){n.push(s.key)}).then(function(){return n}).then(t)}primaryKeys(t){var r=this._ctx;if(r.dir==="next"&&Ma(r,!0)&&r.limit>0)return this._read(a=>{var s=Yi(r,r.table.core.schema);return r.table.core.query({trans:a,values:!1,limit:r.limit,query:{index:s,range:r.range}})}).then(({result:a})=>a).then(t);r.keysOnly=!r.isMatch;var n=[];return this.each(function(a,s){n.push(s.primaryKey)}).then(function(){return n}).then(t)}uniqueKeys(t){return this._ctx.unique="unique",this.keys(t)}firstKey(t){return this.limit(1).keys(function(r){return r[0]}).then(t)}lastKey(t){return this.reverse().firstKey(t)}distinct(){var t=this._ctx,r=t.index&&t.table.schema.idxByName[t.index];if(!r||!r.multi)return this;var n={};return Cu(this._ctx,function(a){var s=a.primaryKey.toString(),i=Dr(n,s);return n[s]=!0,!i}),this}modify(t){var r=this._ctx;return this._write(n=>{var a;if(typeof t=="function")a=t;else{var s=Ft(t),i=s.length;a=function(g){for(var y=!1,b=0;b<i;++b){var m=s[b],v=t[m];$n(g,m)!==v&&(zr(g,m,v),y=!0)}return y}}const o=r.table.core,{outbound:c,extractKey:u}=o.schema.primaryKey,l=this.db._options.modifyChunkSize||200,d=[];let h=0;const p=[],f=(g,y)=>{const{failures:b,numFailures:m}=y;h+=g-m;for(let v of Ft(b))d.push(b[v])};return this.clone().primaryKeys().then(g=>{const y=b=>{const m=Math.min(l,g.length-b);return o.getMany({trans:n,keys:g.slice(b,b+m),cache:"immutable"}).then(v=>{const S=[],C=[],E=c?[]:null,w=[];for(let P=0;P<m;++P){const x=v[P],R={value:Ci(x),primKey:g[b+P]};a.call(R,R.value,R)!==!1&&(R.value==null?w.push(g[b+P]):c||vr(u(x),u(R.value))===0?(C.push(R.value),c&&E.push(g[b+P])):(w.push(g[b+P]),S.push(R.value)))}const _=Ma(r)&&r.limit===1/0&&(typeof t!="function"||t===Eu)&&{index:r.index,range:r.range};return Promise.resolve(S.length>0&&o.mutate({trans:n,type:"add",values:S}).then(P=>{for(let x in P.failures)w.splice(parseInt(x),1);f(S.length,P)})).then(()=>(C.length>0||_&&typeof t=="object")&&o.mutate({trans:n,type:"put",keys:E,values:C,criteria:_,changeSpec:typeof t!="function"&&t}).then(P=>f(C.length,P))).then(()=>(w.length>0||_&&t===Eu)&&o.mutate({trans:n,type:"delete",keys:w,criteria:_}).then(P=>f(w.length,P))).then(()=>g.length>b+m&&y(b+l))})};return y(0).then(()=>{if(d.length>0)throw new So("Error modifying one or more objects",d,h,p);return g.length})})})}delete(){var t=this._ctx,r=t.range;return Ma(t)&&(t.isPrimKey&&!lw||r.type===3)?this._write(n=>{const{primaryKey:a}=t.table.core.schema,s=r;return t.table.core.count({trans:n,query:{index:a,range:s}}).then(i=>t.table.core.mutate({trans:n,type:"deleteRange",range:s}).then(({failures:o,lastResult:c,results:u,numFailures:l})=>{if(l)throw new So("Could not delete some values",Object.keys(o).map(d=>o[d]),i-l);return i-l}))}):this.modify(Eu)}}const Eu=(e,t)=>t.value=null;function pw(e,t){return e<t?-1:e===t?0:1}function fw(e,t){return e>t?-1:e===t?0:1}function Ar(e,t,r){var n=e instanceof cy?new e.Collection(e):e;return n._ctx.error=r?new r(t):new TypeError(t),n}function ja(e){return new e.Collection(e,()=>oy("")).limit(0)}function gw(e,t,r,n,a,s){for(var i=Math.min(e.length,n.length),o=-1,c=0;c<i;++c){var u=t[c];if(u!==n[c])return a(e[c],r[c])<0?e.substr(0,c)+r[c]+r.substr(c+1):a(e[c],n[c])<0?e.substr(0,c)+n[c]+r.substr(c+1):o>=0?e.substr(0,o)+t[o]+r.substr(o+1):null;a(e[c],u)<0&&(o=c)}return i<n.length&&s==="next"?e+r.substr(e.length):i<e.length&&s==="prev"?e.substr(0,r.length):o<0?null:e.substr(0,o)+n[o]+r.substr(o+1)}function Oi(e,t,r,n){var a,s,i,o,c,u,l,d=r.length;if(!r.every(g=>typeof g=="string"))return Ar(e,"String expected.");function h(g){a=function(b){return b==="next"?m=>m.toUpperCase():m=>m.toLowerCase()}(g),s=function(b){return b==="next"?m=>m.toLowerCase():m=>m.toUpperCase()}(g),i=g==="next"?pw:fw;var y=r.map(function(b){return{lower:s(b),upper:a(b)}}).sort(function(b,m){return i(b.lower,m.lower)});o=y.map(function(b){return b.upper}),c=y.map(function(b){return b.lower}),u=g,l=g==="next"?"":n}h("next");var p=new e.Collection(e,()=>On(o[0],c[d-1]+n));p._ondirectionchange=function(g){h(g)};var f=0;return p._addAlgorithm(function(g,y,b){var m=g.key;if(typeof m!="string")return!1;var v=s(m);if(t(v,c,f))return!0;for(var S=null,C=f;C<d;++C){var E=gw(m,v,o[C],c[C],i,u);E===null&&S===null?f=C+1:(S===null||i(S,E)>0)&&(S=E)}return y(S!==null?function(){g.continue(S+l)}:b),!1}),p}function On(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function oy(e){return{type:1,lower:e,upper:e}}class cy{get Collection(){return this._ctx.table.db.Collection}between(t,r,n,a){n=n!==!1,a=a===!0;try{return this._cmp(t,r)>0||this._cmp(t,r)===0&&(n||a)&&(!n||!a)?ja(this):new this.Collection(this,()=>On(t,r,!n,!a))}catch{return Ar(this,mn)}}equals(t){return t==null?Ar(this,mn):new this.Collection(this,()=>oy(t))}above(t){return t==null?Ar(this,mn):new this.Collection(this,()=>On(t,void 0,!0))}aboveOrEqual(t){return t==null?Ar(this,mn):new this.Collection(this,()=>On(t,void 0,!1))}below(t){return t==null?Ar(this,mn):new this.Collection(this,()=>On(void 0,t,!1,!0))}belowOrEqual(t){return t==null?Ar(this,mn):new this.Collection(this,()=>On(void 0,t))}startsWith(t){return typeof t!="string"?Ar(this,"String expected."):this.between(t,t+fa,!0,!0)}startsWithIgnoreCase(t){return t===""?this.startsWith(t):Oi(this,(r,n)=>r.indexOf(n[0])===0,[t],fa)}equalsIgnoreCase(t){return Oi(this,(r,n)=>r===n[0],[t],"")}anyOfIgnoreCase(){var t=bn.apply(Ha,arguments);return t.length===0?ja(this):Oi(this,(r,n)=>n.indexOf(r)!==-1,t,"")}startsWithAnyOfIgnoreCase(){var t=bn.apply(Ha,arguments);return t.length===0?ja(this):Oi(this,(r,n)=>n.some(a=>r.indexOf(a)===0),t,fa)}anyOf(){const t=bn.apply(Ha,arguments);let r=this._cmp;try{t.sort(r)}catch{return Ar(this,mn)}if(t.length===0)return ja(this);const n=new this.Collection(this,()=>On(t[0],t[t.length-1]));n._ondirectionchange=s=>{r=s==="next"?this._ascending:this._descending,t.sort(r)};let a=0;return n._addAlgorithm((s,i,o)=>{const c=s.key;for(;r(c,t[a])>0;)if(++a,a===t.length)return i(o),!1;return r(c,t[a])===0||(i(()=>{s.continue(t[a])}),!1)}),n}notEqual(t){return this.inAnyRange([[-1/0,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const t=bn.apply(Ha,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending)}catch{return Ar(this,mn)}const r=t.reduce((n,a)=>n?n.concat([[n[n.length-1][1],a]]):[[-1/0,a]],null);return r.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(r,{includeLowers:!1,includeUppers:!1})}inAnyRange(t,r){const n=this._cmp,a=this._ascending,s=this._descending,i=this._min,o=this._max;if(t.length===0)return ja(this);if(!t.every(m=>m[0]!==void 0&&m[1]!==void 0&&a(m[0],m[1])<=0))return Ar(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",qe.InvalidArgument);const c=!r||r.includeLowers!==!1,u=r&&r.includeUppers===!0;let l,d=a;function h(m,v){return d(m[0],v[0])}try{l=t.reduce(function(m,v){let S=0,C=m.length;for(;S<C;++S){const E=m[S];if(n(v[0],E[1])<0&&n(v[1],E[0])>0){E[0]=i(E[0],v[0]),E[1]=o(E[1],v[1]);break}}return S===C&&m.push(v),m},[]),l.sort(h)}catch{return Ar(this,mn)}let p=0;const f=u?m=>a(m,l[p][1])>0:m=>a(m,l[p][1])>=0,g=c?m=>s(m,l[p][0])>0:m=>s(m,l[p][0])>=0;let y=f;const b=new this.Collection(this,()=>On(l[0][0],l[l.length-1][1],!c,!u));return b._ondirectionchange=m=>{m==="next"?(y=f,d=a):(y=g,d=s),l.sort(h)},b._addAlgorithm((m,v,S)=>{for(var C=m.key;y(C);)if(++p,p===l.length)return v(S),!1;return!!function(E){return!f(E)&&!g(E)}(C)||(this._cmp(C,l[p][1])===0||this._cmp(C,l[p][0])===0||v(()=>{d===a?m.continue(l[p][0]):m.continue(l[p][1])}),!1)}),b}startsWithAnyOf(){const t=bn.apply(Ha,arguments);return t.every(r=>typeof r=="string")?t.length===0?ja(this):this.inAnyRange(t.map(r=>[r,r+fa])):Ar(this,"startsWithAnyOf() only works with strings")}}function Yr(e){return Bt(function(t){return ni(t),e(t.target.error),!1})}function ni(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const ea=Zs(null,"storagemutated");class mw{_lock(){return Fs(!Me.global),++this._reculock,this._reculock!==1||Me.global||(Me.lockOwnerFor=this),this}_unlock(){if(Fs(!Me.global),--this._reculock==0)for(Me.global||(Me.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{Es(t[1],t[0])}catch{}}return this}_locked(){return this._reculock&&Me.lockOwnerFor!==this}create(t){if(!this.mode)return this;const r=this.db.idbdb,n=this.db._state.dbOpenError;if(Fs(!this.idbtrans),!t&&!r)switch(n&&n.name){case"DatabaseClosedError":throw new qe.DatabaseClosed(n);case"MissingAPIError":throw new qe.MissingAPI(n.message,n);default:throw new qe.OpenFailed(n)}if(!this.active)throw new qe.TransactionInactive;return Fs(this._completion._state===null),(t=this.idbtrans=t||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):r.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Bt(a=>{ni(a),this._reject(t.error)}),t.onabort=Bt(a=>{ni(a),this.active&&this._reject(new qe.Abort(t.error)),this.active=!1,this.on("abort").fire(a)}),t.oncomplete=Bt(()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&ea.storagemutated.fire(t.mutatedParts)}),this}_promise(t,r,n){if(t==="readwrite"&&this.mode!=="readwrite")return Vt(new qe.ReadOnly("Transaction is readonly"));if(!this.active)return Vt(new qe.TransactionInactive);if(this._locked())return new Pe((s,i)=>{this._blockedFuncs.push([()=>{this._promise(t,r,n).then(s,i)},Me])});if(n)return Xn(()=>{var s=new Pe((i,o)=>{this._lock();const c=r(i,o,this);c&&c.then&&c.then(i,o)});return s.finally(()=>this._unlock()),s._lib=!0,s});var a=new Pe((s,i)=>{var o=r(s,i,this);o&&o.then&&o.then(s,i)});return a._lib=!0,a}_root(){return this.parent?this.parent._root():this}waitFor(t){var r=this._root();const n=Pe.resolve(t);if(r._waitingFor)r._waitingFor=r._waitingFor.then(()=>n);else{r._waitingFor=n,r._waitingQueue=[];var a=r.idbtrans.objectStore(r.storeNames[0]);(function i(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(a.get(-1/0).onsuccess=i)})()}var s=r._waitingFor;return new Pe((i,o)=>{n.then(c=>r._waitingQueue.push(Bt(i.bind(null,c))),c=>r._waitingQueue.push(Bt(o.bind(null,c)))).finally(()=>{r._waitingFor===s&&(r._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new qe.Abort))}table(t){const r=this._memoizedTables||(this._memoizedTables={});if(Dr(r,t))return r[t];const n=this.schema[t];if(!n)throw new qe.NotFound("Table "+t+" not part of transaction");const a=new this.db.Table(t,n,this);return a.core=this.db.core.table(t),r[t]=a,a}}function pl(e,t,r,n,a,s,i){return{name:e,keyPath:t,unique:r,multi:n,auto:a,compound:s,src:(r&&!i?"&":"")+(n?"*":"")+(a?"++":"")+uy(t)}}function uy(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function ly(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:Hm(r,n=>[n.name,n])}}let ai=e=>{try{return e.only([[]]),ai=()=>[[]],[[]]}catch{return ai=()=>fa,fa}};function fl(e){return e==null?()=>{}:typeof e=="string"?function(t){return t.split(".").length===1?r=>r[t]:r=>$n(r,t)}(e):t=>$n(t,e)}function Np(e){return[].slice.call(e)}let yw=0;function Ys(e){return e==null?":id":typeof e=="string"?e:`[${e.join("+")}]`}function vw(e,t,r){function n(c){if(c.type===3)return null;if(c.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:u,upper:l,lowerOpen:d,upperOpen:h}=c;return u===void 0?l===void 0?null:t.upperBound(l,!!h):l===void 0?t.lowerBound(u,!!d):t.bound(u,l,!!d,!!h)}const{schema:a,hasGetAll:s}=function(c,u){const l=Np(c.objectStoreNames);return{schema:{name:c.name,tables:l.map(d=>u.objectStore(d)).map(d=>{const{keyPath:h,autoIncrement:p}=d,f=ur(h),g=h==null,y={},b={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:g,compound:f,keyPath:h,autoIncrement:p,unique:!0,extractKey:fl(h)},indexes:Np(d.indexNames).map(m=>d.index(m)).map(m=>{const{name:v,unique:S,multiEntry:C,keyPath:E}=m,w={name:v,compound:ur(E),keyPath:E,unique:S,multiEntry:C,extractKey:fl(E)};return y[Ys(E)]=w,w}),getIndexByKeyPath:m=>y[Ys(m)]};return y[":id"]=b.primaryKey,h!=null&&(y[Ys(h)]=b.primaryKey),b})},hasGetAll:l.length>0&&"getAll"in u.objectStore(l[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,r),i=a.tables.map(c=>function(u){const l=u.name;return{name:l,schema:u,mutate:function({trans:d,type:h,keys:p,values:f,range:g}){return new Promise((y,b)=>{y=Bt(y);const m=d.objectStore(l),v=m.keyPath==null,S=h==="put"||h==="add";if(!S&&h!=="delete"&&h!=="deleteRange")throw new Error("Invalid operation type: "+h);const{length:C}=p||f||{length:1};if(p&&f&&p.length!==f.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let E;const w=[],_=[];let P=0;const x=B=>{++P,ni(B)};if(h==="deleteRange"){if(g.type===4)return y({numFailures:P,failures:_,results:[],lastResult:void 0});g.type===3?w.push(E=m.clear()):w.push(E=m.delete(n(g)))}else{const[B,K]=S?v?[f,p]:[f,null]:[p,null];if(S)for(let re=0;re<C;++re)w.push(E=K&&K[re]!==void 0?m[h](B[re],K[re]):m[h](B[re])),E.onerror=x;else for(let re=0;re<C;++re)w.push(E=m[h](B[re])),E.onerror=x}const R=B=>{const K=B.target.result;w.forEach((re,ee)=>re.error!=null&&(_[ee]=re.error)),y({numFailures:P,failures:_,results:h==="delete"?p:w.map(re=>re.result),lastResult:K})};E.onerror=B=>{x(B),R(B)},E.onsuccess=R})},getMany:({trans:d,keys:h})=>new Promise((p,f)=>{p=Bt(p);const g=d.objectStore(l),y=h.length,b=new Array(y);let m,v=0,S=0;const C=w=>{const _=w.target;b[_._pos]=_.result,++S===v&&p(b)},E=Yr(f);for(let w=0;w<y;++w)h[w]!=null&&(m=g.get(h[w]),m._pos=w,m.onsuccess=C,m.onerror=E,++v);v===0&&p(b)}),get:({trans:d,key:h})=>new Promise((p,f)=>{p=Bt(p);const g=d.objectStore(l).get(h);g.onsuccess=y=>p(y.target.result),g.onerror=Yr(f)}),query:function(d){return h=>new Promise((p,f)=>{p=Bt(p);const{trans:g,values:y,limit:b,query:m}=h,v=b===1/0?void 0:b,{index:S,range:C}=m,E=g.objectStore(l),w=S.isPrimaryKey?E:E.index(S.name),_=n(C);if(b===0)return p({result:[]});if(d){const P=y?w.getAll(_,v):w.getAllKeys(_,v);P.onsuccess=x=>p({result:x.target.result}),P.onerror=Yr(f)}else{let P=0;const x=y||!("openKeyCursor"in w)?w.openCursor(_):w.openKeyCursor(_),R=[];x.onsuccess=B=>{const K=x.result;return K?(R.push(y?K.value:K.primaryKey),++P===b?p({result:R}):void K.continue()):p({result:R})},x.onerror=Yr(f)}})}(s),openCursor:function({trans:d,values:h,query:p,reverse:f,unique:g}){return new Promise((y,b)=>{y=Bt(y);const{index:m,range:v}=p,S=d.objectStore(l),C=m.isPrimaryKey?S:S.index(m.name),E=f?g?"prevunique":"prev":g?"nextunique":"next",w=h||!("openKeyCursor"in C)?C.openCursor(n(v),E):C.openKeyCursor(n(v),E);w.onerror=Yr(b),w.onsuccess=Bt(_=>{const P=w.result;if(!P)return void y(null);P.___id=++yw,P.done=!1;const x=P.continue.bind(P);let R=P.continuePrimaryKey;R&&(R=R.bind(P));const B=P.advance.bind(P),K=()=>{throw new Error("Cursor not stopped")};P.trans=d,P.stop=P.continue=P.continuePrimaryKey=P.advance=()=>{throw new Error("Cursor not started")},P.fail=Bt(b),P.next=function(){let re=1;return this.start(()=>re--?this.continue():this.stop()).then(()=>this)},P.start=re=>{const ee=new Promise((se,Ce)=>{se=Bt(se),w.onerror=Yr(Ce),P.fail=Ce,P.stop=Ie=>{P.stop=P.continue=P.continuePrimaryKey=P.advance=K,se(Ie)}}),ie=()=>{if(w.result)try{re()}catch(se){P.fail(se)}else P.done=!0,P.start=()=>{throw new Error("Cursor behind last entry")},P.stop()};return w.onsuccess=Bt(se=>{w.onsuccess=ie,ie()}),P.continue=x,P.continuePrimaryKey=R,P.advance=B,ie(),ee},y(P)},b)})},count({query:d,trans:h}){const{index:p,range:f}=d;return new Promise((g,y)=>{const b=h.objectStore(l),m=p.isPrimaryKey?b:b.index(p.name),v=n(f),S=v?m.count(v):m.count();S.onsuccess=Bt(C=>g(C.target.result)),S.onerror=Yr(y)})}}}(c)),o={};return i.forEach(c=>o[c.name]=c),{stack:"dbcore",transaction:e.transaction.bind(e),table(c){if(!o[c])throw new Error(`Table '${c}' not found`);return o[c]},MIN_KEY:-1/0,MAX_KEY:ai(t),schema:a}}function gl({_novip:e},t){const r=t.db,n=function(a,s,{IDBKeyRange:i,indexedDB:o},c){return{dbcore:function(u,l){return l.reduce((d,{create:h})=>({...d,...h(d)}),u)}(vw(s,i,c),a.dbcore)}}(e._middlewares,r,e._deps,t);e.core=n.dbcore,e.tables.forEach(a=>{const s=a.name;e.core.schema.tables.some(i=>i.name===s)&&(a.core=e.core.table(s),e[s]instanceof e.Table&&(e[s].core=a.core))})}function $o({_novip:e},t,r,n){r.forEach(a=>{const s=n[a];t.forEach(i=>{const o=p0(i,a);(!o||"value"in o&&o.value===void 0)&&(i===e.Transaction.prototype||i instanceof e.Transaction?Tn(i,a,{get(){return this.table(a)},set(c){jm(this,a,{value:c,writable:!0,configurable:!0,enumerable:!0})}}):i[a]=new e.Table(a,s))})})}function ml({_novip:e},t){t.forEach(r=>{for(let n in r)r[n]instanceof e.Table&&delete r[n]})}function bw(e,t){return e._cfg.version-t._cfg.version}function Cw(e,t,r,n){const a=e._dbSchema,s=e._createTransaction("readwrite",e._storeNames,a);s.create(r),s._completion.catch(n);const i=s._reject.bind(s),o=Me.transless||Me;Xn(()=>{Me.trans=s,Me.transless=o,t===0?(Ft(a).forEach(c=>{xu(r,c,a[c].primKey,a[c].indexes)}),gl(e,r),Pe.follow(()=>e.on.populate.fire(s)).catch(i)):function({_novip:c},u,l,d){const h=[],p=c._versions;let f=c._dbSchema=vl(c,c.idbdb,d),g=!1;function y(){return h.length?Pe.resolve(h.shift()(l.idbtrans)).then(y):Pe.resolve()}return p.filter(b=>b._cfg.version>=u).forEach(b=>{h.push(()=>{const m=f,v=b._cfg.dbschema;bl(c,m,d),bl(c,v,d),f=c._dbSchema=v;const S=dy(m,v);S.add.forEach(E=>{xu(d,E[0],E[1].primKey,E[1].indexes)}),S.change.forEach(E=>{if(E.recreate)throw new qe.Upgrade("Not yet support for changing primary key");{const w=d.objectStore(E.name);E.add.forEach(_=>yl(w,_)),E.change.forEach(_=>{w.deleteIndex(_.name),yl(w,_)}),E.del.forEach(_=>w.deleteIndex(_))}});const C=b._cfg.contentUpgrade;if(C&&b._cfg.version>u){gl(c,d),l._memoizedTables={},g=!0;let E=Km(v);S.del.forEach(x=>{E[x]=m[x]}),ml(c,[c.Transaction.prototype]),$o(c,[c.Transaction.prototype],Ft(E),E),l.schema=E;const w=f0(C);let _;w&&Ss();const P=Pe.follow(()=>{if(_=C(l),_&&w){var x=An.bind(null,null);_.then(x,x)}});return _&&typeof _.then=="function"?Pe.resolve(_):P.then(()=>_)}}),h.push(m=>{(!g||!uw)&&function(v,S){[].slice.call(S.db.objectStoreNames).forEach(C=>v[C]==null&&S.db.deleteObjectStore(C))}(b._cfg.dbschema,m),ml(c,[c.Transaction.prototype]),$o(c,[c.Transaction.prototype],c._storeNames,c._dbSchema),l.schema=c._dbSchema})}),y().then(()=>{var b,m;m=d,Ft(b=f).forEach(v=>{m.db.objectStoreNames.contains(v)||xu(m,v,b[v].primKey,b[v].indexes)})})}(e,t,s,r).catch(i)})}function dy(e,t){const r={del:[],add:[],change:[]};let n;for(n in e)t[n]||r.del.push(n);for(n in t){const a=e[n],s=t[n];if(a){const i={name:n,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(a.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||a.primKey.auto!==s.primKey.auto&&!ec)i.recreate=!0,r.change.push(i);else{const o=a.idxByName,c=s.idxByName;let u;for(u in o)c[u]||i.del.push(u);for(u in c){const l=o[u],d=c[u];l?l.src!==d.src&&i.change.push(d):i.add.push(d)}(i.del.length>0||i.add.length>0||i.change.length>0)&&r.change.push(i)}}else r.add.push([n,s])}return r}function xu(e,t,r,n){const a=e.db.createObjectStore(t,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(s=>yl(a,s)),a}function yl(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function vl(e,t,r){const n={};return Co(t.objectStoreNames,0).forEach(a=>{const s=r.objectStore(a);let i=s.keyPath;const o=pl(uy(i),i||"",!1,!1,!!s.autoIncrement,i&&typeof i!="string",!0),c=[];for(let l=0;l<s.indexNames.length;++l){const d=s.index(s.indexNames[l]);i=d.keyPath;var u=pl(d.name,i,!!d.unique,!!d.multiEntry,!1,i&&typeof i!="string",!1);c.push(u)}n[a]=ly(a,o,c)}),n}function bl({_novip:e},t,r){const n=r.db.objectStoreNames;for(let a=0;a<n.length;++a){const s=n[a],i=r.objectStore(s);e._hasGetAll="getAll"in i;for(let o=0;o<i.indexNames.length;++o){const c=i.indexNames[o],u=i.index(c).keyPath,l=typeof u=="string"?u:"["+Co(u).join("+")+"]";if(t[s]){const d=t[s].idxByName[l];d&&(d.name=c,delete t[s].idxByName[l],t[s].idxByName[c]=d)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&_t.WorkerGlobalScope&&_t instanceof _t.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class Sw{_parseStoresSpec(t,r){Ft(t).forEach(n=>{if(t[n]!==null){var a=t[n].split(",").map((i,o)=>{const c=(i=i.trim()).replace(/([&*]|\+\+)/g,""),u=/^\[/.test(c)?c.match(/^\[(.*)\]$/)[1].split("+"):c;return pl(c,u||null,/\&/.test(i),/\*/.test(i),/\+\+/.test(i),ur(u),o===0)}),s=a.shift();if(s.multi)throw new qe.Schema("Primary key cannot be multi-valued");a.forEach(i=>{if(i.auto)throw new qe.Schema("Only primary key can be marked as autoIncrement (++)");if(!i.keyPath)throw new qe.Schema("Index must have a name and cannot be an empty string")}),r[n]=ly(n,s,a)}})}stores(t){const r=this.db;this._cfg.storesSource=this._cfg.storesSource?br(this._cfg.storesSource,t):t;const n=r._versions,a={};let s={};return n.forEach(i=>{br(a,i._cfg.storesSource),s=i._cfg.dbschema={},i._parseStoresSpec(a,s)}),r._dbSchema=s,ml(r,[r._allTables,r,r.Transaction.prototype]),$o(r,[r._allTables,r,r.Transaction.prototype,this._cfg.tables],Ft(s),s),r._storeNames=Ft(s),this}upgrade(t){return this._cfg.contentUpgrade=y0(this._cfg.contentUpgrade||Ct,t),this}}function S0(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new Ta("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t}),r.version(1).stores({dbnames:"name"})),r.table("dbnames")}function E0(e){return e&&typeof e.databases=="function"}function Cl(e){return Xn(function(){return Me.letThrough=!0,e()})}function Ew(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(t){var r=function(){return indexedDB.databases().finally(t)};e=setInterval(r,100),r()}).finally(function(){return clearInterval(e)}):Promise.resolve()}function xw(e){const t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?Vt(t.dbOpenError):e);fn&&(t.openCanceller._stackHolder=Ba()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const n=t.openCanceller;function a(){if(t.openCanceller!==n)throw new qe.DatabaseClosed("db.open() was cancelled")}let s=t.dbReadyResolve,i=null,o=!1;return Pe.race([n,(typeof navigator>"u"?Pe.resolve():Ew()).then(()=>new Pe((c,u)=>{if(a(),!r)throw new qe.MissingAPI;const l=e.name,d=t.autoSchema?r.open(l):r.open(l,Math.round(10*e.verno));if(!d)throw new qe.MissingAPI;d.onerror=Yr(u),d.onblocked=Bt(e._fireOnBlocked),d.onupgradeneeded=Bt(h=>{if(i=d.transaction,t.autoSchema&&!e._options.allowEmptyDB){d.onerror=ni,i.abort(),d.result.close();const f=r.deleteDatabase(l);f.onsuccess=f.onerror=Bt(()=>{u(new qe.NoSuchDatabase(`Database ${l} doesnt exist`))})}else{i.onerror=Yr(u);var p=h.oldVersion>Math.pow(2,62)?0:h.oldVersion;o=p<1,e._novip.idbdb=d.result,Cw(e,p/10,i,u)}},u),d.onsuccess=Bt(()=>{i=null;const h=e._novip.idbdb=d.result,p=Co(h.objectStoreNames);if(p.length>0)try{const g=h.transaction((f=p).length===1?f[0]:f,"readonly");t.autoSchema?function({_novip:y},b,m){y.verno=b.version/10;const v=y._dbSchema=vl(0,b,m);y._storeNames=Co(b.objectStoreNames,0),$o(y,[y._allTables],Ft(v),v)}(e,h,g):(bl(e,e._dbSchema,g),function(y,b){const m=dy(vl(0,y.idbdb,b),y._dbSchema);return!(m.add.length||m.change.some(v=>v.add.length||v.change.length))}(e,g)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),gl(e,g)}catch{}var f;Ws.push(e),h.onversionchange=Bt(g=>{t.vcFired=!0,e.on("versionchange").fire(g)}),h.onclose=Bt(g=>{e.on("close").fire(g)}),o&&function({indexedDB:g,IDBKeyRange:y},b){!E0(g)&&b!=="__dbnames"&&S0(g,y).put({name:b}).catch(Ct)}(e._deps,l),c()},u)}))]).then(()=>(a(),t.onReadyBeingFired=[],Pe.resolve(Cl(()=>e.on.ready.fire(e.vip))).then(function c(){if(t.onReadyBeingFired.length>0){let u=t.onReadyBeingFired.reduce(y0,Ct);return t.onReadyBeingFired=[],Pe.resolve(Cl(()=>u(e.vip))).then(c)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(c=>{t.dbOpenError=c;try{i&&i.abort()}catch{}return n===t.openCanceller&&e._close(),Vt(c)}).finally(()=>{t.openComplete=!0,s()})}function Sl(e){var t=s=>e.next(s),r=a(t),n=a(s=>e.throw(s));function a(s){return i=>{var o=s(i),c=o.value;return o.done?c:c&&typeof c.then=="function"?c.then(r,n):ur(c)?Promise.all(c).then(r,n):r(c)}}return a(t)()}function ww(e,t,r){var n=arguments.length;if(n<2)throw new qe.InvalidArgument("Too few arguments");for(var a=new Array(n-1);--n;)a[n-1]=arguments[n];r=a.pop();var s=Vm(a);return[e,s,r]}function hy(e,t,r,n,a){return Pe.resolve().then(()=>{const s=Me.transless||Me,i=e._createTransaction(t,r,e._dbSchema,n),o={trans:i,transless:s};if(n)i.idbtrans=n.idbtrans;else try{i.create(),e._state.PR1398_maxLoop=3}catch(d){return d.name===m0.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>hy(e,t,r,null,a))):Vt(d)}const c=f0(a);let u;c&&Ss();const l=Pe.follow(()=>{if(u=a.call(i,i),u)if(c){var d=An.bind(null,null);u.then(d,d)}else typeof u.next=="function"&&typeof u.throw=="function"&&(u=Sl(u))},o);return(u&&typeof u.then=="function"?Pe.resolve(u).then(d=>i.active?d:Vt(new qe.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):l.then(()=>u)).then(d=>(n&&i._resolve(),i._completion.then(()=>d))).catch(d=>(i._reject(d),Vt(d)))})}function Ui(e,t,r){const n=ur(e)?e.slice():[e];for(let a=0;a<r;++a)n.push(t);return n}const Tw={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const r=e.table(t),{schema:n}=r,a={},s=[];function i(u,l,d){const h=Ys(u),p=a[h]=a[h]||[],f=u==null?0:typeof u=="string"?1:u.length,g=l>0,y={...d,isVirtual:g,keyTail:l,keyLength:f,extractKey:fl(u),unique:!g&&d.unique};return p.push(y),y.isPrimaryKey||s.push(y),f>1&&i(f===2?u[0]:u.slice(0,f-1),l+1,d),p.sort((b,m)=>b.keyTail-m.keyTail),y}const o=i(n.primaryKey.keyPath,0,n.primaryKey);a[":id"]=[o];for(const u of n.indexes)i(u.keyPath,0,u);function c(u){const l=u.query.index;return l.isVirtual?{...u,query:{index:l,range:(d=u.query.range,h=l.keyTail,{type:d.type===1?2:d.type,lower:Ui(d.lower,d.lowerOpen?e.MAX_KEY:e.MIN_KEY,h),lowerOpen:!0,upper:Ui(d.upper,d.upperOpen?e.MIN_KEY:e.MAX_KEY,h),upperOpen:!0})}}:u;var d,h}return{...r,schema:{...n,primaryKey:o,indexes:s,getIndexByKeyPath:function(u){const l=a[Ys(u)];return l&&l[0]}},count:u=>r.count(c(u)),query:u=>r.query(c(u)),openCursor(u){const{keyTail:l,isVirtual:d,keyLength:h}=u.query.index;return d?r.openCursor(c(u)).then(p=>p&&function(f){return Object.create(f,{continue:{value:function(g){g!=null?f.continue(Ui(g,u.reverse?e.MAX_KEY:e.MIN_KEY,l)):u.unique?f.continue(f.key.slice(0,h).concat(u.reverse?e.MIN_KEY:e.MAX_KEY,l)):f.continue()}},continuePrimaryKey:{value(g,y){f.continuePrimaryKey(Ui(g,e.MAX_KEY,l),y)}},primaryKey:{get:()=>f.primaryKey},key:{get(){const g=f.key;return h===1?g[0]:g.slice(0,h)}},value:{get:()=>f.value}})}(p)):r.openCursor(u)}}}}}};function x0(e,t,r,n){return r=r||{},n=n||"",Ft(e).forEach(a=>{if(Dr(t,a)){var s=e[a],i=t[a];if(typeof s=="object"&&typeof i=="object"&&s&&i){const o=tl(s);o!==tl(i)?r[n+a]=t[a]:o==="Object"?x0(s,i,r,n+a+"."):s!==i&&(r[n+a]=t[a])}else s!==i&&(r[n+a]=t[a])}else r[n+a]=void 0}),Ft(t).forEach(a=>{Dr(e,a)||(r[n+a]=t[a])}),r}const $w={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const r=e.table(t),{primaryKey:n}=r.schema;return{...r,mutate(a){const s=Me.trans,{deleting:i,creating:o,updating:c}=s.table(t).hook;switch(a.type){case"add":if(o.fire===Ct)break;return s._promise("readwrite",()=>u(a),!0);case"put":if(o.fire===Ct&&c.fire===Ct)break;return s._promise("readwrite",()=>u(a),!0);case"delete":if(i.fire===Ct)break;return s._promise("readwrite",()=>u(a),!0);case"deleteRange":if(i.fire===Ct)break;return s._promise("readwrite",()=>function(d){return l(d.trans,d.range,1e4)}(a),!0)}return r.mutate(a);function u(d){const h=Me.trans,p=d.keys||function(f,g){return g.type==="delete"?g.keys:g.keys||g.values.map(f.extractKey)}(n,d);if(!p)throw new Error("Keys missing");return(d=d.type==="add"||d.type==="put"?{...d,keys:p}:{...d}).type!=="delete"&&(d.values=[...d.values]),d.keys&&(d.keys=[...d.keys]),function(f,g,y){return g.type==="add"?Promise.resolve([]):f.getMany({trans:g.trans,keys:y,cache:"immutable"})}(r,d,p).then(f=>{const g=p.map((y,b)=>{const m=f[b],v={onerror:null,onsuccess:null};if(d.type==="delete")i.fire.call(v,y,m,h);else if(d.type==="add"||m===void 0){const S=o.fire.call(v,y,d.values[b],h);y==null&&S!=null&&(y=S,d.keys[b]=y,n.outbound||zr(d.values[b],n.keyPath,y))}else{const S=x0(m,d.values[b]),C=c.fire.call(v,S,y,m,h);if(C){const E=d.values[b];Object.keys(C).forEach(w=>{Dr(E,w)?E[w]=C[w]:zr(E,w,C[w])})}}return v});return r.mutate(d).then(({failures:y,results:b,numFailures:m,lastResult:v})=>{for(let S=0;S<p.length;++S){const C=b?b[S]:p[S],E=g[S];C==null?E.onerror&&E.onerror(y[S]):E.onsuccess&&E.onsuccess(d.type==="put"&&f[S]?d.values[S]:C)}return{failures:y,results:b,numFailures:m,lastResult:v}}).catch(y=>(g.forEach(b=>b.onerror&&b.onerror(y)),Promise.reject(y)))})}function l(d,h,p){return r.query({trans:d,values:!1,query:{index:n,range:h},limit:p}).then(({result:f})=>u({type:"delete",keys:f,trans:d}).then(g=>g.numFailures>0?Promise.reject(g.failures[0]):f.length<p?{failures:[],numFailures:0,lastResult:void 0}:l(d,{...h,lower:f[f.length-1],lowerOpen:!0},p)))}}}}})};function py(e,t,r){try{if(!t||t.keys.length<e.length)return null;const n=[];for(let a=0,s=0;a<t.keys.length&&s<e.length;++a)vr(t.keys[a],e[s])===0&&(n.push(r?Ci(t.values[a]):t.values[a]),++s);return n.length===e.length?n:null}catch{return null}}const Aw={stack:"dbcore",level:-1,create:e=>({table:t=>{const r=e.table(t);return{...r,getMany:n=>{if(!n.cache)return r.getMany(n);const a=py(n.keys,n.trans._cache,n.cache==="clone");return a?Pe.resolve(a):r.getMany(n).then(s=>(n.trans._cache={keys:n.keys,values:n.cache==="clone"?Ci(s):s},s))},mutate:n=>(n.type!=="add"&&(n.trans._cache=null),r.mutate(n))}}})};function w0(e){return!("from"in e)}const en=function(e,t){if(!this){const r=new en;return e&&"d"in e&&br(r,e),r}br(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function si(e,t,r){const n=vr(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(w0(e))return br(e,{from:t,to:r,d:1});const a=e.l,s=e.r;if(vr(r,e.from)<0)return a?si(a,t,r):e.l={from:t,to:r,d:1,l:null,r:null},Bp(e);if(vr(t,e.to)>0)return s?si(s,t,r):e.r={from:t,to:r,d:1,l:null,r:null},Bp(e);vr(t,e.from)<0&&(e.from=t,e.l=null,e.d=s?s.d+1:1),vr(r,e.to)>0&&(e.to=r,e.r=null,e.d=e.l?e.l.d+1:1);const i=!e.r;a&&!e.l&&ii(e,a),s&&i&&ii(e,s)}function ii(e,t){w0(t)||function r(n,{from:a,to:s,l:i,r:o}){si(n,a,s),i&&r(n,i),o&&r(n,o)}(e,t)}function fy(e,t){const r=El(t);let n=r.next();if(n.done)return!1;let a=n.value;const s=El(e);let i=s.next(a.from),o=i.value;for(;!n.done&&!i.done;){if(vr(o.from,a.to)<=0&&vr(o.to,a.from)>=0)return!0;vr(a.from,o.from)<0?a=(n=r.next(o.from)).value:o=(i=s.next(a.from)).value}return!1}function El(e){let t=w0(e)?null:{s:0,n:e};return{next(r){const n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&vr(r,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||vr(r,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Bp(e){var t,r;const n=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((r=e.l)===null||r===void 0?void 0:r.d)||0),a=n>1?"r":n<-1?"l":"";if(a){const s=a==="r"?"l":"r",i={...e},o=e[a];e.from=o.from,e.to=o.to,e[a]=o[a],i[a]=o[s],e[s]=i,i.d=kp(i)}e.d=kp(e)}function kp({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}ss(en.prototype,{add(e){return ii(this,e),this},addKey(e){return si(this,e,e),this},addKeys(e){return e.forEach(t=>si(this,t,t)),this},[rl](){return El(this)}});const Iw={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,r=new en(e.MIN_KEY,e.MAX_KEY);return{...e,table:n=>{const a=e.table(n),{schema:s}=a,{primaryKey:i}=s,{extractKey:o,outbound:c}=i,u={...a,mutate:h=>{const p=h.trans,f=p.mutatedParts||(p.mutatedParts={}),g=E=>{const w=`idb://${t}/${n}/${E}`;return f[w]||(f[w]=new en)},y=g(""),b=g(":dels"),{type:m}=h;let[v,S]=h.type==="deleteRange"?[h.range]:h.type==="delete"?[h.keys]:h.values.length<50?[[],h.values]:[];const C=h.trans._cache;return a.mutate(h).then(E=>{if(ur(v)){m!=="delete"&&(v=E.results),y.addKeys(v);const w=py(v,C);w||m==="add"||b.addKeys(v),(w||S)&&function(_,P,x,R){function B(K){const re=_(K.name||"");function ee(se){return se!=null?K.extractKey(se):null}const ie=se=>K.multiEntry&&ur(se)?se.forEach(Ce=>re.addKey(Ce)):re.addKey(se);(x||R).forEach((se,Ce)=>{const Ie=x&&ee(x[Ce]),ye=R&&ee(R[Ce]);vr(Ie,ye)!==0&&(Ie!=null&&ie(Ie),ye!=null&&ie(ye))})}P.indexes.forEach(B)}(g,s,w,S)}else if(v){const w={from:v.lower,to:v.upper};b.add(w),y.add(w)}else y.add(r),b.add(r),s.indexes.forEach(w=>g(w.name).add(r));return E})}},l=({query:{index:h,range:p}})=>{var f,g;return[h,new en((f=p.lower)!==null&&f!==void 0?f:e.MIN_KEY,(g=p.upper)!==null&&g!==void 0?g:e.MAX_KEY)]},d={get:h=>[i,new en(h.key)],getMany:h=>[i,new en().addKeys(h.keys)],count:l,query:l,openCursor:l};return Ft(d).forEach(h=>{u[h]=function(p){const{subscr:f}=Me;if(f){const g=S=>{const C=`idb://${t}/${n}/${S}`;return f[C]||(f[C]=new en)},y=g(""),b=g(":dels"),[m,v]=d[h](p);if(g(m.name||"").add(v),!m.isPrimaryKey){if(h!=="count"){const S=h==="query"&&c&&p.values&&a.query({...p,values:!1});return a[h].apply(this,arguments).then(C=>{if(h==="query"){if(c&&p.values)return S.then(({result:w})=>(y.addKeys(w),C));const E=p.values?C.result.map(o):C.result;p.values?y.addKeys(E):b.addKeys(E)}else if(h==="openCursor"){const E=C,w=p.values;return E&&Object.create(E,{key:{get:()=>(b.addKey(E.primaryKey),E.key)},primaryKey:{get(){const _=E.primaryKey;return b.addKey(_),_}},value:{get:()=>(w&&y.addKey(E.primaryKey),E.value)}})}return C})}b.add(r)}}return a[h].apply(this,arguments)}}),u}}}};let Ta=class Xi{constructor(t,r){this._middlewares={},this.verno=0;const n=Xi.dependencies;this._options=r={addons:Xi.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...r},this._deps={indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange};const{addons:a}=r;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:Ct,dbReadyPromise:null,cancelOpen:Ct,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new Pe(o=>{s.dbReadyResolve=o}),s.openCanceller=new Pe((o,c)=>{s.cancelOpen=c}),this._state=s,this.name=t,this.on=Zs(this,"populate","blocked","versionchange","close",{ready:[y0,Ct]}),this.on.ready.subscribe=Fm(this.on.ready.subscribe,o=>(c,u)=>{Xi.vip(()=>{const l=this._state;if(l.openComplete)l.dbOpenError||Pe.resolve().then(c),u&&o(c);else if(l.onReadyBeingFired)l.onReadyBeingFired.push(c),u&&o(c);else{o(c);const d=this;u||o(function h(){d.on.ready.unsubscribe(c),d.on.ready.unsubscribe(h)})}})}),this.Collection=(i=this,Ls(hw.prototype,function(o,c){this.db=i;let u=iy,l=null;if(c)try{u=c()}catch(f){l=f}const d=o._ctx,h=d.table,p=h.hook.reading.fire;this._ctx={table:h,index:d.index,isPrimKey:!d.index||h.schema.primKey.keyPath&&d.index===h.schema.primKey.name,range:u,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:l,or:d.or,valueMapper:p!==ti?p:null}})),this.Table=function(o){return Ls(dw.prototype,function(c,u,l){this.db=o,this._tx=l,this.name=c,this.schema=u,this.hook=o._allTables[c]?o._allTables[c].hook:Zs(null,{creating:[Jx,Ct],reading:[Xx,ti],updating:[tw,Ct],deleting:[ew,Ct]})})}(this),this.Transaction=function(o){return Ls(mw.prototype,function(c,u,l,d,h){this.db=o,this.mode=c,this.storeNames=u,this.schema=l,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=Zs(this,"complete","error","abort"),this.parent=h||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new Pe((p,f)=>{this._resolve=p,this._reject=f}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},p=>{var f=this.active;return this.active=!1,this.on.error.fire(p),this.parent?this.parent._reject(p):f&&this.idbtrans&&this.idbtrans.abort(),Vt(p)})})}(this),this.Version=function(o){return Ls(Sw.prototype,function(c){this.db=o,this._cfg={version:c,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(o){return Ls(cy.prototype,function(c,u,l){this.db=o,this._ctx={table:c,index:u===":id"?null:u,or:l};const d=o._deps.indexedDB;if(!d)throw new qe.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(h,p)=>d.cmp(p,h),this._max=(h,p)=>d.cmp(h,p)>0?h:p,this._min=(h,p)=>d.cmp(h,p)<0?h:p,this._IDBKeyRange=o._deps.IDBKeyRange})}(this),this.on("versionchange",o=>{o.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",o=>{!o.newVersion||o.newVersion<o.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${o.oldVersion/10}`)}),this._maxKey=ai(r.IDBKeyRange),this._createTransaction=(o,c,u,l)=>new this.Transaction(o,c,u,this._options.chromeTransactionDurability,l),this._fireOnBlocked=o=>{this.on("blocked").fire(o),Ws.filter(c=>c.name===this.name&&c!==this&&!c._state.vcFired).map(c=>c.on("versionchange").fire(o))},this.use(Tw),this.use($w),this.use(Iw),this.use(Aw),this.vip=Object.create(this,{_vip:{value:!0}}),a.forEach(o=>o(this))}version(t){if(isNaN(t)||t<.1)throw new qe.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new qe.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);const r=this._versions;var n=r.filter(a=>a._cfg.version===t)[0];return n||(n=new this.Version(t),r.push(n),r.sort(bw),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(t){return this.idbdb&&(this._state.openComplete||Me.letThrough||this._vip)?t():new Pe((r,n)=>{if(this._state.openComplete)return n(new qe.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new qe.DatabaseClosed);this.open().catch(Ct)}this._state.dbReadyPromise.then(r,n)}).then(t)}use({stack:t,create:r,level:n,name:a}){a&&this.unuse({stack:t,name:a});const s=this._middlewares[t]||(this._middlewares[t]=[]);return s.push({stack:t,create:r,level:n??10,name:a}),s.sort((i,o)=>i.level-o.level),this}unuse({stack:t,name:r,create:n}){return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(a=>n?a.create!==n:!!r&&a.name!==r)),this}open(){return xw(this)}_close(){const t=this._state,r=Ws.indexOf(this);if(r>=0&&Ws.splice(r,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}t.dbReadyPromise=new Pe(n=>{t.dbReadyResolve=n}),t.openCanceller=new Pe((n,a)=>{t.cancelOpen=a})}close(){this._close();const t=this._state;this._options.autoOpen=!1,t.dbOpenError=new qe.DatabaseClosed,t.isBeingOpened&&t.cancelOpen(t.dbOpenError)}delete(){const t=arguments.length>0,r=this._state;return new Pe((n,a)=>{const s=()=>{this.close();var i=this._deps.indexedDB.deleteDatabase(this.name);i.onsuccess=Bt(()=>{(function({indexedDB:o,IDBKeyRange:c},u){!E0(o)&&u!=="__dbnames"&&S0(o,c).delete(u).catch(Ct)})(this._deps,this.name),n()}),i.onerror=Yr(a),i.onblocked=this._fireOnBlocked};if(t)throw new qe.InvalidArgument("Arguments not allowed in db.delete()");r.isBeingOpened?r.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const t=this._state.dbOpenError;return t&&t.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return Ft(this._allTables).map(t=>this._allTables[t])}transaction(){const t=ww.apply(this,arguments);return this._transaction.apply(this,t)}_transaction(t,r,n){let a=Me.trans;a&&a.db===this&&t.indexOf("!")===-1||(a=null);const s=t.indexOf("?")!==-1;let i,o;t=t.replace("!","").replace("?","");try{if(o=r.map(u=>{var l=u instanceof this.Table?u.name:u;if(typeof l!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return l}),t=="r"||t==="readonly")i="readonly";else{if(t!="rw"&&t!="readwrite")throw new qe.InvalidArgument("Invalid transaction mode: "+t);i="readwrite"}if(a){if(a.mode==="readonly"&&i==="readwrite"){if(!s)throw new qe.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");a=null}a&&o.forEach(u=>{if(a&&a.storeNames.indexOf(u)===-1){if(!s)throw new qe.SubTransaction("Table "+u+" not included in parent transaction.");a=null}}),s&&a&&!a.active&&(a=null)}}catch(u){return a?a._promise(null,(l,d)=>{d(u)}):Vt(u)}const c=hy.bind(null,this,i,o,a,n);return a?a._promise(i,c,"lock"):Me.trans?Es(Me.transless,()=>this._whenReady(c)):this._whenReady(c)}table(t){if(!Dr(this._allTables,t))throw new qe.InvalidTable(`Table ${t} does not exist`);return this._allTables[t]}};const Pw=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";let _w=class{constructor(t){this._subscribe=t}subscribe(t,r,n){return this._subscribe(t&&typeof t!="function"?t:{next:t,error:r,complete:n})}[Pw](){return this}};function gy(e,t){return Ft(t).forEach(r=>{ii(e[r]||(e[r]=new en),t[r])}),e}function my(e){return new _w(t=>{const r=f0(e);let n=!1,a={},s={};const i={get closed(){return n},unsubscribe:()=>{n=!0,ea.storagemutated.unsubscribe(l)}};t.start&&t.start(i);let o=!1,c=!1;function u(){return Ft(s).some(h=>a[h]&&fy(a[h],s[h]))}const l=h=>{gy(a,h),u()&&d()},d=()=>{if(o||n)return;a={};const h={},p=function(f){r&&Ss();const g=()=>Xn(e,{subscr:f,trans:null}),y=Me.trans?Es(Me.transless,g):g();return r&&y.then(An,An),y}(h);c||(ea("storagemutated",l),c=!0),o=!0,Promise.resolve(p).then(f=>{o=!1,n||(u()?d():(a={},s=h,t.next&&t.next(f)))},f=>{o=!1,t.error&&t.error(f),i.unsubscribe()})};return d(),i})}let xl;try{xl={indexedDB:_t.indexedDB||_t.mozIndexedDB||_t.webkitIndexedDB||_t.msIndexedDB,IDBKeyRange:_t.IDBKeyRange||_t.webkitIDBKeyRange}}catch{xl={indexedDB:null,IDBKeyRange:null}}const ca=Ta;function Ji(e){let t=En;try{En=!0,ea.storagemutated.fire(e)}finally{En=t}}ss(ca,{...zi,delete:e=>new ca(e,{addons:[]}).delete(),exists:e=>new ca(e,{addons:[]}).open().then(t=>(t.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return function({indexedDB:t,IDBKeyRange:r}){return E0(t)?Promise.resolve(t.databases()).then(n=>n.map(a=>a.name).filter(a=>a!=="__dbnames")):S0(t,r).toCollection().primaryKeys()}(ca.dependencies).then(e)}catch{return Vt(new qe.MissingAPI)}},defineClass:()=>function(e){br(this,e)},ignoreTransaction:e=>Me.trans?Es(Me.transless,e):e(),vip:Cl,async:function(e){return function(){try{var t=Sl(e.apply(this,arguments));return t&&typeof t.then=="function"?t:Pe.resolve(t)}catch(r){return Vt(r)}}},spawn:function(e,t,r){try{var n=Sl(e.apply(r,t||[]));return n&&typeof n.then=="function"?n:Pe.resolve(n)}catch(a){return Vt(a)}},currentTransaction:{get:()=>Me.trans||null},waitFor:function(e,t){const r=Pe.resolve(typeof e=="function"?ca.ignoreTransaction(e):e).timeout(t||6e4);return Me.trans?Me.trans.waitFor(r):r},Promise:Pe,debug:{get:()=>fn,set:e=>{Gm(e,e==="dexie"?()=>!0:sy)}},derive:Za,extend:br,props:ss,override:Fm,Events:Zs,on:ea,liveQuery:my,extendObservabilitySet:gy,getByKeyPath:$n,setByKeyPath:zr,delByKeyPath:function(e,t){typeof t=="string"?zr(e,t,void 0):"length"in t&&[].map.call(t,function(r){zr(e,r,void 0)})},shallowClone:Km,deepClone:Ci,getObjectDiff:x0,cmp:vr,asap:qm,minKey:-1/0,addons:[],connections:Ws,errnames:m0,dependencies:xl,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),ca.maxKey=ai(ca.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(ea("storagemutated",e=>{if(!En){let t;ec?(t=document.createEvent("CustomEvent"),t.initCustomEvent("x-storagemutated-1",!0,!0,e)):t=new CustomEvent("x-storagemutated-1",{detail:e}),En=!0,dispatchEvent(t),En=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{En||Ji(e)}));let En=!1;if(typeof BroadcastChannel<"u"){const e=new BroadcastChannel("x-storagemutated-1");ea("storagemutated",t=>{En||e.postMessage(t)}),e.onmessage=t=>{t.data&&Ji(t.data)}}else if(typeof self<"u"&&typeof navigator<"u"){ea("storagemutated",t=>{try{En||(typeof localStorage<"u"&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:t})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(r=>r.postMessage({type:"x-storagemutated-1",changedParts:t})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",t=>{if(t.key==="x-storagemutated-1"){const r=JSON.parse(t.newValue);r&&Ji(r.changedParts)}});const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:t}){t&&t.type==="x-storagemutated-1"&&Ji(t.changedParts)})}Pe.rejectionMapper=function(e,t){if(!e||e instanceof Ya||e instanceof TypeError||e instanceof SyntaxError||!e.name||!$p[e.name])return e;var r=new $p[e.name](t||e.message,e);return"stack"in e&&Tn(r,"stack",{get:function(){return this.inner.stack}}),r},Gm(fn,sy);const Dw=Object.freeze(Object.defineProperty({__proto__:null,Dexie:Ta,RangeSet:en,default:Ta,liveQuery:my,mergeRanges:ii,rangesOverlap:fy},Symbol.toStringTag,{value:"Module"}));class Rw extends Ta{constructor(){super("sicarx_cache"),Fx(this,"products"),this.version(19).stores({products:"&uniqueId, uuid, contentId, sku, skus, description, descriptionNormalize, departmentUuid, categoryUuid, favorite, bulk, pesoSearch"})}}const WP=new Rw;/*!
 *  decimal.js v10.4.3
 *  An arbitrary-precision Decimal type for JavaScript.
 *  https://github.com/MikeMcl/decimal.js
 *  Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
 *  MIT Licence
 */var Ga=9e15,sa=1e9,wl="0123456789abcdef",Ao="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Io="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Tl={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Ga,maxE:Ga,crypto:!1},yy,xn,He=!0,tc="[DecimalError] ",ta=tc+"Invalid argument: ",vy=tc+"Precision limit exceeded",by=tc+"crypto unavailable",Cy="[object Decimal]",lr=Math.floor,Kt=Math.pow,Nw=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Bw=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,kw=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Sy=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Gr=1e7,je=7,Ow=9007199254740991,Uw=Ao.length-1,$l=Io.length-1,ce={toStringTag:Cy};ce.absoluteValue=ce.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),ke(e)};ce.ceil=function(){return ke(new this.constructor(this),this.e+1,2)};ce.clampedTo=ce.clamp=function(e,t){var r,n=this,a=n.constructor;if(e=new a(e),t=new a(t),!e.s||!t.s)return new a(NaN);if(e.gt(t))throw Error(ta+t);return r=n.cmp(e),r<0?e:n.cmp(t)>0?t:new a(n)};ce.comparedTo=ce.cmp=function(e){var t,r,n,a,s=this,i=s.d,o=(e=new s.constructor(e)).d,c=s.s,u=e.s;if(!i||!o)return!c||!u?NaN:c!==u?c:i===o?0:!i^c<0?1:-1;if(!i[0]||!o[0])return i[0]?c:o[0]?-u:0;if(c!==u)return c;if(s.e!==e.e)return s.e>e.e^c<0?1:-1;for(n=i.length,a=o.length,t=0,r=n<a?n:a;t<r;++t)if(i[t]!==o[t])return i[t]>o[t]^c<0?1:-1;return n===a?0:n>a^c<0?1:-1};ce.cosine=ce.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+je,n.rounding=1,r=Lw(n,$y(n,r)),n.precision=e,n.rounding=t,ke(xn==2||xn==3?r.neg():r,e,t,!0)):new n(1):new n(NaN)};ce.cubeRoot=ce.cbrt=function(){var e,t,r,n,a,s,i,o,c,u,l=this,d=l.constructor;if(!l.isFinite()||l.isZero())return new d(l);for(He=!1,s=l.s*Kt(l.s*l,1/3),!s||Math.abs(s)==1/0?(r=nr(l.d),e=l.e,(s=(e-r.length+1)%3)&&(r+=s==1||s==-2?"0":"00"),s=Kt(r,1/3),e=lr((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?r="5e"+e:(r=s.toExponential(),r=r.slice(0,r.indexOf("e")+1)+e),n=new d(r),n.s=l.s):n=new d(s.toString()),i=(e=d.precision)+3;;)if(o=n,c=o.times(o).times(o),u=c.plus(l),n=St(u.plus(l).times(o),u.plus(c),i+2,1),nr(o.d).slice(0,i)===(r=nr(n.d)).slice(0,i))if(r=r.slice(i-3,i+1),r=="9999"||!a&&r=="4999"){if(!a&&(ke(o,e+1,0),o.times(o).times(o).eq(l))){n=o;break}i+=4,a=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(ke(n,e+1,1),t=!n.times(n).times(n).eq(l));break}return He=!0,ke(n,e,d.rounding,t)};ce.decimalPlaces=ce.dp=function(){var e,t=this.d,r=NaN;if(t){if(e=t.length-1,r=(e-lr(this.e/je))*je,e=t[e],e)for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r};ce.dividedBy=ce.div=function(e){return St(this,new this.constructor(e))};ce.dividedToIntegerBy=ce.divToInt=function(e){var t=this,r=t.constructor;return ke(St(t,new r(e),0,1,1),r.precision,r.rounding)};ce.equals=ce.eq=function(e){return this.cmp(e)===0};ce.floor=function(){return ke(new this.constructor(this),this.e+1,3)};ce.greaterThan=ce.gt=function(e){return this.cmp(e)>0};ce.greaterThanOrEqualTo=ce.gte=function(e){var t=this.cmp(e);return t==1||t===0};ce.hyperbolicCosine=ce.cosh=function(){var e,t,r,n,a,s=this,i=s.constructor,o=new i(1);if(!s.isFinite())return new i(s.s?1/0:NaN);if(s.isZero())return o;r=i.precision,n=i.rounding,i.precision=r+Math.max(s.e,s.sd())+4,i.rounding=1,a=s.d.length,a<32?(e=Math.ceil(a/3),t=(1/nc(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),s=is(i,1,s.times(t),new i(1),!0);for(var c,u=e,l=new i(8);u--;)c=s.times(s),s=o.minus(c.times(l.minus(c.times(l))));return ke(s,i.precision=r,i.rounding=n,!0)};ce.hyperbolicSine=ce.sinh=function(){var e,t,r,n,a=this,s=a.constructor;if(!a.isFinite()||a.isZero())return new s(a);if(t=s.precision,r=s.rounding,s.precision=t+Math.max(a.e,a.sd())+4,s.rounding=1,n=a.d.length,n<3)a=is(s,2,a,a,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,a=a.times(1/nc(5,e)),a=is(s,2,a,a,!0);for(var i,o=new s(5),c=new s(16),u=new s(20);e--;)i=a.times(a),a=a.times(o.plus(i.times(c.times(i).plus(u))))}return s.precision=t,s.rounding=r,ke(a,t,r,!0)};ce.hyperbolicTangent=ce.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,St(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)};ce.inverseCosine=ce.acos=function(){var e,t=this,r=t.constructor,n=t.abs().cmp(1),a=r.precision,s=r.rounding;return n!==-1?n===0?t.isNeg()?Vr(r,a,s):new r(0):new r(NaN):t.isZero()?Vr(r,a+4,s).times(.5):(r.precision=a+6,r.rounding=1,t=t.asin(),e=Vr(r,a+4,s).times(.5),r.precision=a,r.rounding=s,e.minus(t))};ce.inverseHyperbolicCosine=ce.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,He=!1,r=r.times(r).minus(1).sqrt().plus(r),He=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)};ce.inverseHyperbolicSine=ce.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,He=!1,r=r.times(r).plus(1).sqrt().plus(r),He=!0,n.precision=e,n.rounding=t,r.ln())};ce.inverseHyperbolicTangent=ce.atanh=function(){var e,t,r,n,a=this,s=a.constructor;return a.isFinite()?a.e>=0?new s(a.abs().eq(1)?a.s/0:a.isZero()?a:NaN):(e=s.precision,t=s.rounding,n=a.sd(),Math.max(n,e)<2*-a.e-1?ke(new s(a),e,t,!0):(s.precision=r=n-a.e,a=St(a.plus(1),new s(1).minus(a),r+e,1),s.precision=e+4,s.rounding=1,a=a.ln(),s.precision=e,s.rounding=t,a.times(.5))):new s(NaN)};ce.inverseSine=ce.asin=function(){var e,t,r,n,a=this,s=a.constructor;return a.isZero()?new s(a):(t=a.abs().cmp(1),r=s.precision,n=s.rounding,t!==-1?t===0?(e=Vr(s,r+4,n).times(.5),e.s=a.s,e):new s(NaN):(s.precision=r+6,s.rounding=1,a=a.div(new s(1).minus(a.times(a)).sqrt().plus(1)).atan(),s.precision=r,s.rounding=n,a.times(2)))};ce.inverseTangent=ce.atan=function(){var e,t,r,n,a,s,i,o,c,u=this,l=u.constructor,d=l.precision,h=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&d+4<=$l)return i=Vr(l,d+4,h).times(.25),i.s=u.s,i}else{if(!u.s)return new l(NaN);if(d+4<=$l)return i=Vr(l,d+4,h).times(.5),i.s=u.s,i}for(l.precision=o=d+10,l.rounding=1,r=Math.min(28,o/je+2|0),e=r;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(He=!1,t=Math.ceil(o/je),n=1,c=u.times(u),i=new l(u),a=u;e!==-1;)if(a=a.times(c),s=i.minus(a.div(n+=2)),a=a.times(c),i=s.plus(a.div(n+=2)),i.d[t]!==void 0)for(e=t;i.d[e]===s.d[e]&&e--;);return r&&(i=i.times(2<<r-1)),He=!0,ke(i,l.precision=d,l.rounding=h,!0)};ce.isFinite=function(){return!!this.d};ce.isInteger=ce.isInt=function(){return!!this.d&&lr(this.e/je)>this.d.length-2};ce.isNaN=function(){return!this.s};ce.isNegative=ce.isNeg=function(){return this.s<0};ce.isPositive=ce.isPos=function(){return this.s>0};ce.isZero=function(){return!!this.d&&this.d[0]===0};ce.lessThan=ce.lt=function(e){return this.cmp(e)<0};ce.lessThanOrEqualTo=ce.lte=function(e){return this.cmp(e)<1};ce.logarithm=ce.log=function(e){var t,r,n,a,s,i,o,c,u=this,l=u.constructor,d=l.precision,h=l.rounding,p=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),r=e.d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=u.d,u.s<0||!r||!r[0]||u.eq(1))return new l(r&&!r[0]?-1/0:u.s!=1?NaN:r?0:1/0);if(t)if(r.length>1)s=!0;else{for(a=r[0];a%10===0;)a/=10;s=a!==1}if(He=!1,o=d+p,i=zn(u,o),n=t?Po(l,o+10):zn(e,o),c=St(i,n,o,1),oi(c.d,a=d,h))do if(o+=10,i=zn(u,o),n=t?Po(l,o+10):zn(e,o),c=St(i,n,o,1),!s){+nr(c.d).slice(a+1,a+15)+1==1e14&&(c=ke(c,d+1,0));break}while(oi(c.d,a+=10,h));return He=!0,ke(c,d,h)};ce.minus=ce.sub=function(e){var t,r,n,a,s,i,o,c,u,l,d,h,p=this,f=p.constructor;if(e=new f(e),!p.d||!e.d)return!p.s||!e.s?e=new f(NaN):p.d?e.s=-e.s:e=new f(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(u=p.d,h=e.d,o=f.precision,c=f.rounding,!u[0]||!h[0]){if(h[0])e.s=-e.s;else if(u[0])e=new f(p);else return new f(c===3?-0:0);return He?ke(e,o,c):e}if(r=lr(e.e/je),l=lr(p.e/je),u=u.slice(),s=l-r,s){for(d=s<0,d?(t=u,s=-s,i=h.length):(t=h,r=l,i=u.length),n=Math.max(Math.ceil(o/je),i)+2,s>n&&(s=n,t.length=1),t.reverse(),n=s;n--;)t.push(0);t.reverse()}else{for(n=u.length,i=h.length,d=n<i,d&&(i=n),n=0;n<i;n++)if(u[n]!=h[n]){d=u[n]<h[n];break}s=0}for(d&&(t=u,u=h,h=t,e.s=-e.s),i=u.length,n=h.length-i;n>0;--n)u[i++]=0;for(n=h.length;n>s;){if(u[--n]<h[n]){for(a=n;a&&u[--a]===0;)u[a]=Gr-1;--u[a],u[n]+=Gr}u[n]-=h[n]}for(;u[--i]===0;)u.pop();for(;u[0]===0;u.shift())--r;return u[0]?(e.d=u,e.e=rc(u,r),He?ke(e,o,c):e):new f(c===3?-0:0)};ce.modulo=ce.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?ke(new n(r),n.precision,n.rounding):(He=!1,n.modulo==9?(t=St(r,e.abs(),0,3,1),t.s*=e.s):t=St(r,e,0,n.modulo,1),t=t.times(e),He=!0,r.minus(t))};ce.naturalExponential=ce.exp=function(){return Al(this)};ce.naturalLogarithm=ce.ln=function(){return zn(this)};ce.negated=ce.neg=function(){var e=new this.constructor(this);return e.s=-e.s,ke(e)};ce.plus=ce.add=function(e){var t,r,n,a,s,i,o,c,u,l,d=this,h=d.constructor;if(e=new h(e),!d.d||!e.d)return!d.s||!e.s?e=new h(NaN):d.d||(e=new h(e.d||d.s===e.s?d:NaN)),e;if(d.s!=e.s)return e.s=-e.s,d.minus(e);if(u=d.d,l=e.d,o=h.precision,c=h.rounding,!u[0]||!l[0])return l[0]||(e=new h(d)),He?ke(e,o,c):e;if(s=lr(d.e/je),n=lr(e.e/je),u=u.slice(),a=s-n,a){for(a<0?(r=u,a=-a,i=l.length):(r=l,n=s,i=u.length),s=Math.ceil(o/je),i=s>i?s+1:i+1,a>i&&(a=i,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(i=u.length,a=l.length,i-a<0&&(a=i,r=l,l=u,u=r),t=0;a;)t=(u[--a]=u[a]+l[a]+t)/Gr|0,u[a]%=Gr;for(t&&(u.unshift(t),++n),i=u.length;u[--i]==0;)u.pop();return e.d=u,e.e=rc(u,n),He?ke(e,o,c):e};ce.precision=ce.sd=function(e){var t,r=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(ta+e);return r.d?(t=Ey(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t};ce.round=function(){var e=this,t=e.constructor;return ke(new t(e),e.e+1,t.rounding)};ce.sine=ce.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+je,n.rounding=1,r=jw(n,$y(n,r)),n.precision=e,n.rounding=t,ke(xn>2?r.neg():r,e,t,!0)):new n(NaN)};ce.squareRoot=ce.sqrt=function(){var e,t,r,n,a,s,i=this,o=i.d,c=i.e,u=i.s,l=i.constructor;if(u!==1||!o||!o[0])return new l(!u||u<0&&(!o||o[0])?NaN:o?i:1/0);for(He=!1,u=Math.sqrt(+i),u==0||u==1/0?(t=nr(o),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=lr((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),n=new l(t)):n=new l(u.toString()),r=(c=l.precision)+3;;)if(s=n,n=s.plus(St(i,s,r+2,1)).times(.5),nr(s.d).slice(0,r)===(t=nr(n.d)).slice(0,r))if(t=t.slice(r-3,r+1),t=="9999"||!a&&t=="4999"){if(!a&&(ke(s,c+1,0),s.times(s).eq(i))){n=s;break}r+=4,a=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(ke(n,c+1,1),e=!n.times(n).eq(i));break}return He=!0,ke(n,c,l.rounding,e)};ce.tangent=ce.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,r=r.sin(),r.s=1,r=St(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,ke(xn==2||xn==4?r.neg():r,e,t,!0)):new n(NaN)};ce.times=ce.mul=function(e){var t,r,n,a,s,i,o,c,u,l=this,d=l.constructor,h=l.d,p=(e=new d(e)).d;if(e.s*=l.s,!h||!h[0]||!p||!p[0])return new d(!e.s||h&&!h[0]&&!p||p&&!p[0]&&!h?NaN:!h||!p?e.s/0:e.s*0);for(r=lr(l.e/je)+lr(e.e/je),c=h.length,u=p.length,c<u&&(s=h,h=p,p=s,i=c,c=u,u=i),s=[],i=c+u,n=i;n--;)s.push(0);for(n=u;--n>=0;){for(t=0,a=c+n;a>n;)o=s[a]+p[n]*h[a-n-1]+t,s[a--]=o%Gr|0,t=o/Gr|0;s[a]=(s[a]+t)%Gr|0}for(;!s[--i];)s.pop();return t?++r:s.shift(),e.d=s,e.e=rc(s,r),He?ke(e,d.precision,d.rounding):e};ce.toBinary=function(e,t){return T0(this,2,e,t)};ce.toDecimalPlaces=ce.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:($r(e,0,sa),t===void 0?t=n.rounding:$r(t,0,8),ke(r,e+r.e+1,t))};ce.toExponential=function(e,t){var r,n=this,a=n.constructor;return e===void 0?r=ln(n,!0):($r(e,0,sa),t===void 0?t=a.rounding:$r(t,0,8),n=ke(new a(n),e+1,t),r=ln(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r};ce.toFixed=function(e,t){var r,n,a=this,s=a.constructor;return e===void 0?r=ln(a):($r(e,0,sa),t===void 0?t=s.rounding:$r(t,0,8),n=ke(new s(a),e+a.e+1,t),r=ln(n,!1,e+n.e+1)),a.isNeg()&&!a.isZero()?"-"+r:r};ce.toFraction=function(e){var t,r,n,a,s,i,o,c,u,l,d,h,p=this,f=p.d,g=p.constructor;if(!f)return new g(p);if(u=r=new g(1),n=c=new g(0),t=new g(n),s=t.e=Ey(f)-p.e-1,i=s%je,t.d[0]=Kt(10,i<0?je+i:i),e==null)e=s>0?t:u;else{if(o=new g(e),!o.isInt()||o.lt(u))throw Error(ta+o);e=o.gt(t)?s>0?t:u:o}for(He=!1,o=new g(nr(f)),l=g.precision,g.precision=s=f.length*je*2;d=St(o,t,0,1,1),a=r.plus(d.times(n)),a.cmp(e)!=1;)r=n,n=a,a=u,u=c.plus(d.times(a)),c=a,a=t,t=o.minus(d.times(a)),o=a;return a=St(e.minus(r),n,0,1,1),c=c.plus(a.times(u)),r=r.plus(a.times(n)),c.s=u.s=p.s,h=St(u,n,s,1).minus(p).abs().cmp(St(c,r,s,1).minus(p).abs())<1?[u,n]:[c,r],g.precision=l,He=!0,h};ce.toHexadecimal=ce.toHex=function(e,t){return T0(this,16,e,t)};ce.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),e==null){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),t===void 0?t=n.rounding:$r(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(He=!1,r=St(r,e,0,t,1).times(e),He=!0,ke(r)):(e.s=r.s,r=e),r};ce.toNumber=function(){return+this};ce.toOctal=function(e,t){return T0(this,8,e,t)};ce.toPower=ce.pow=function(e){var t,r,n,a,s,i,o=this,c=o.constructor,u=+(e=new c(e));if(!o.d||!e.d||!o.d[0]||!e.d[0])return new c(Kt(+o,u));if(o=new c(o),o.eq(1))return o;if(n=c.precision,s=c.rounding,e.eq(1))return ke(o,n,s);if(t=lr(e.e/je),t>=e.d.length-1&&(r=u<0?-u:u)<=Ow)return a=xy(c,o,r,n),e.s<0?new c(1).div(a):ke(a,n,s);if(i=o.s,i<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(i=1),o.e==0&&o.d[0]==1&&o.d.length==1)return o.s=i,o}return r=Kt(+o,u),t=r==0||!isFinite(r)?lr(u*(Math.log("0."+nr(o.d))/Math.LN10+o.e+1)):new c(r+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?i/0:0):(He=!1,c.rounding=o.s=1,r=Math.min(12,(t+"").length),a=Al(e.times(zn(o,n+r)),n),a.d&&(a=ke(a,n+5,1),oi(a.d,n,s)&&(t=n+10,a=ke(Al(e.times(zn(o,t+r)),t),t+5,1),+nr(a.d).slice(n+1,n+15)+1==1e14&&(a=ke(a,n+1,0)))),a.s=i,He=!0,c.rounding=s,ke(a,n,s))};ce.toPrecision=function(e,t){var r,n=this,a=n.constructor;return e===void 0?r=ln(n,n.e<=a.toExpNeg||n.e>=a.toExpPos):($r(e,1,sa),t===void 0?t=a.rounding:$r(t,0,8),n=ke(new a(n),e,t),r=ln(n,e<=n.e||n.e<=a.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r};ce.toSignificantDigits=ce.toSD=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):($r(e,1,sa),t===void 0?t=n.rounding:$r(t,0,8)),ke(new n(r),e,t)};ce.toString=function(){var e=this,t=e.constructor,r=ln(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r};ce.truncated=ce.trunc=function(){return ke(new this.constructor(this),this.e+1,1)};ce.valueOf=ce.toJSON=function(){var e=this,t=e.constructor,r=ln(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};function nr(e){var t,r,n,a=e.length-1,s="",i=e[0];if(a>0){for(s+=i,t=1;t<a;t++)n=e[t]+"",r=je-n.length,r&&(s+=Mn(r)),s+=n;i=e[t],n=i+"",r=je-n.length,r&&(s+=Mn(r))}else if(i===0)return"0";for(;i%10===0;)i/=10;return s+i}function $r(e,t,r){if(e!==~~e||e<t||e>r)throw Error(ta+e)}function oi(e,t,r,n){var a,s,i,o;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=je,a=0):(a=Math.ceil((t+1)/je),t%=je),s=Kt(10,je-t),o=e[a]%s|0,n==null?t<3?(t==0?o=o/100|0:t==1&&(o=o/10|0),i=r<4&&o==99999||r>3&&o==49999||o==5e4||o==0):i=(r<4&&o+1==s||r>3&&o+1==s/2)&&(e[a+1]/s/100|0)==Kt(10,t-2)-1||(o==s/2||o==0)&&(e[a+1]/s/100|0)==0:t<4?(t==0?o=o/1e3|0:t==1?o=o/100|0:t==2&&(o=o/10|0),i=(n||r<4)&&o==9999||!n&&r>3&&o==4999):i=((n||r<4)&&o+1==s||!n&&r>3&&o+1==s/2)&&(e[a+1]/s/1e3|0)==Kt(10,t-3)-1,i}function eo(e,t,r){for(var n,a=[0],s,i=0,o=e.length;i<o;){for(s=a.length;s--;)a[s]*=t;for(a[0]+=wl.indexOf(e.charAt(i++)),n=0;n<a.length;n++)a[n]>r-1&&(a[n+1]===void 0&&(a[n+1]=0),a[n+1]+=a[n]/r|0,a[n]%=r)}return a.reverse()}function Lw(e,t){var r,n,a;if(t.isZero())return t;n=t.d.length,n<32?(r=Math.ceil(n/3),a=(1/nc(4,r)).toString()):(r=16,a="2.3283064365386962890625e-10"),e.precision+=r,t=is(e,1,t.times(a),new e(1));for(var s=r;s--;){var i=t.times(t);t=i.times(i).minus(i).times(8).plus(1)}return e.precision-=r,t}var St=function(){function e(n,a,s){var i,o=0,c=n.length;for(n=n.slice();c--;)i=n[c]*a+o,n[c]=i%s|0,o=i/s|0;return o&&n.unshift(o),n}function t(n,a,s,i){var o,c;if(s!=i)c=s>i?1:-1;else for(o=c=0;o<s;o++)if(n[o]!=a[o]){c=n[o]>a[o]?1:-1;break}return c}function r(n,a,s,i){for(var o=0;s--;)n[s]-=o,o=n[s]<a[s]?1:0,n[s]=o*i+n[s]-a[s];for(;!n[0]&&n.length>1;)n.shift()}return function(n,a,s,i,o,c){var u,l,d,h,p,f,g,y,b,m,v,S,C,E,w,_,P,x,R,B,K=n.constructor,re=n.s==a.s?1:-1,ee=n.d,ie=a.d;if(!ee||!ee[0]||!ie||!ie[0])return new K(!n.s||!a.s||(ee?ie&&ee[0]==ie[0]:!ie)?NaN:ee&&ee[0]==0||!ie?re*0:re/0);for(c?(p=1,l=n.e-a.e):(c=Gr,p=je,l=lr(n.e/p)-lr(a.e/p)),R=ie.length,P=ee.length,b=new K(re),m=b.d=[],d=0;ie[d]==(ee[d]||0);d++);if(ie[d]>(ee[d]||0)&&l--,s==null?(E=s=K.precision,i=K.rounding):o?E=s+(n.e-a.e)+1:E=s,E<0)m.push(1),f=!0;else{if(E=E/p+2|0,d=0,R==1){for(h=0,ie=ie[0],E++;(d<P||h)&&E--;d++)w=h*c+(ee[d]||0),m[d]=w/ie|0,h=w%ie|0;f=h||d<P}else{for(h=c/(ie[0]+1)|0,h>1&&(ie=e(ie,h,c),ee=e(ee,h,c),R=ie.length,P=ee.length),_=R,v=ee.slice(0,R),S=v.length;S<R;)v[S++]=0;B=ie.slice(),B.unshift(0),x=ie[0],ie[1]>=c/2&&++x;do h=0,u=t(ie,v,R,S),u<0?(C=v[0],R!=S&&(C=C*c+(v[1]||0)),h=C/x|0,h>1?(h>=c&&(h=c-1),g=e(ie,h,c),y=g.length,S=v.length,u=t(g,v,y,S),u==1&&(h--,r(g,R<y?B:ie,y,c))):(h==0&&(u=h=1),g=ie.slice()),y=g.length,y<S&&g.unshift(0),r(v,g,S,c),u==-1&&(S=v.length,u=t(ie,v,R,S),u<1&&(h++,r(v,R<S?B:ie,S,c))),S=v.length):u===0&&(h++,v=[0]),m[d++]=h,u&&v[0]?v[S++]=ee[_]||0:(v=[ee[_]],S=1);while((_++<P||v[0]!==void 0)&&E--);f=v[0]!==void 0}m[0]||m.shift()}if(p==1)b.e=l,yy=f;else{for(d=1,h=m[0];h>=10;h/=10)d++;b.e=d+l*p-1,ke(b,o?s+b.e+1:s,i,f)}return b}}();function ke(e,t,r,n){var a,s,i,o,c,u,l,d,h,p=e.constructor;e:if(t!=null){if(d=e.d,!d)return e;for(a=1,o=d[0];o>=10;o/=10)a++;if(s=t-a,s<0)s+=je,i=t,l=d[h=0],c=l/Kt(10,a-i-1)%10|0;else if(h=Math.ceil((s+1)/je),o=d.length,h>=o)if(n){for(;o++<=h;)d.push(0);l=c=0,a=1,s%=je,i=s-je+1}else break e;else{for(l=o=d[h],a=1;o>=10;o/=10)a++;s%=je,i=s-je+a,c=i<0?0:l/Kt(10,a-i-1)%10|0}if(n=n||t<0||d[h+1]!==void 0||(i<0?l:l%Kt(10,a-i-1)),u=r<4?(c||n)&&(r==0||r==(e.s<0?3:2)):c>5||c==5&&(r==4||n||r==6&&(s>0?i>0?l/Kt(10,a-i):0:d[h-1])%10&1||r==(e.s<0?8:7)),t<1||!d[0])return d.length=0,u?(t-=e.e+1,d[0]=Kt(10,(je-t%je)%je),e.e=-t||0):d[0]=e.e=0,e;if(s==0?(d.length=h,o=1,h--):(d.length=h+1,o=Kt(10,je-s),d[h]=i>0?(l/Kt(10,a-i)%Kt(10,i)|0)*o:0),u)for(;;)if(h==0){for(s=1,i=d[0];i>=10;i/=10)s++;for(i=d[0]+=o,o=1;i>=10;i/=10)o++;s!=o&&(e.e++,d[0]==Gr&&(d[0]=1));break}else{if(d[h]+=o,d[h]!=Gr)break;d[h--]=0,o=1}for(s=d.length;d[--s]===0;)d.pop()}return He&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function ln(e,t,r){if(!e.isFinite())return Ty(e);var n,a=e.e,s=nr(e.d),i=s.length;return t?(r&&(n=r-i)>0?s=s.charAt(0)+"."+s.slice(1)+Mn(n):i>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):a<0?(s="0."+Mn(-a-1)+s,r&&(n=r-i)>0&&(s+=Mn(n))):a>=i?(s+=Mn(a+1-i),r&&(n=r-a-1)>0&&(s=s+"."+Mn(n))):((n=a+1)<i&&(s=s.slice(0,n)+"."+s.slice(n)),r&&(n=r-i)>0&&(a+1===i&&(s+="."),s+=Mn(n))),s}function rc(e,t){var r=e[0];for(t*=je;r>=10;r/=10)t++;return t}function Po(e,t,r){if(t>Uw)throw He=!0,r&&(e.precision=r),Error(vy);return ke(new e(Ao),t,1,!0)}function Vr(e,t,r){if(t>$l)throw Error(vy);return ke(new e(Io),t,r,!0)}function Ey(e){var t=e.length-1,r=t*je+1;if(t=e[t],t){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function Mn(e){for(var t="";e--;)t+="0";return t}function xy(e,t,r,n){var a,s=new e(1),i=Math.ceil(n/je+4);for(He=!1;;){if(r%2&&(s=s.times(t),Up(s.d,i)&&(a=!0)),r=lr(r/2),r===0){r=s.d.length-1,a&&s.d[r]===0&&++s.d[r];break}t=t.times(t),Up(t.d,i)}return He=!0,s}function Op(e){return e.d[e.d.length-1]&1}function wy(e,t,r){for(var n,a=new e(t[0]),s=0;++s<t.length;)if(n=new e(t[s]),n.s)a[r](n)&&(a=n);else{a=n;break}return a}function Al(e,t){var r,n,a,s,i,o,c,u=0,l=0,d=0,h=e.constructor,p=h.rounding,f=h.precision;if(!e.d||!e.d[0]||e.e>17)return new h(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(He=!1,c=f):c=t,o=new h(.03125);e.e>-2;)e=e.times(o),d+=5;for(n=Math.log(Kt(2,d))/Math.LN10*2+5|0,c+=n,r=s=i=new h(1),h.precision=c;;){if(s=ke(s.times(e),c,1),r=r.times(++l),o=i.plus(St(s,r,c,1)),nr(o.d).slice(0,c)===nr(i.d).slice(0,c)){for(a=d;a--;)i=ke(i.times(i),c,1);if(t==null)if(u<3&&oi(i.d,c-n,p,u))h.precision=c+=10,r=s=o=new h(1),l=0,u++;else return ke(i,h.precision=f,p,He=!0);else return h.precision=f,i}i=o}}function zn(e,t){var r,n,a,s,i,o,c,u,l,d,h,p=1,f=10,g=e,y=g.d,b=g.constructor,m=b.rounding,v=b.precision;if(g.s<0||!y||!y[0]||!g.e&&y[0]==1&&y.length==1)return new b(y&&!y[0]?-1/0:g.s!=1?NaN:y?0:g);if(t==null?(He=!1,l=v):l=t,b.precision=l+=f,r=nr(y),n=r.charAt(0),Math.abs(s=g.e)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)g=g.times(e),r=nr(g.d),n=r.charAt(0),p++;s=g.e,n>1?(g=new b("0."+r),s++):g=new b(n+"."+r.slice(1))}else return u=Po(b,l+2,v).times(s+""),g=zn(new b(n+"."+r.slice(1)),l-f).plus(u),b.precision=v,t==null?ke(g,v,m,He=!0):g;for(d=g,c=i=g=St(g.minus(1),g.plus(1),l,1),h=ke(g.times(g),l,1),a=3;;){if(i=ke(i.times(h),l,1),u=c.plus(St(i,new b(a),l,1)),nr(u.d).slice(0,l)===nr(c.d).slice(0,l))if(c=c.times(2),s!==0&&(c=c.plus(Po(b,l+2,v).times(s+""))),c=St(c,new b(p),l,1),t==null)if(oi(c.d,l-f,m,o))b.precision=l+=f,u=i=g=St(d.minus(1),d.plus(1),l,1),h=ke(g.times(g),l,1),a=o=1;else return ke(c,b.precision=v,m,He=!0);else return b.precision=v,c;c=u,a+=2}}function Ty(e){return String(e.s*e.s/0)}function Il(e,t){var r,n,a;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;n++);for(a=t.length;t.charCodeAt(a-1)===48;--a);if(t=t.slice(n,a),t){if(a-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%je,r<0&&(n+=je),n<a){for(n&&e.d.push(+t.slice(0,n)),a-=je;n<a;)e.d.push(+t.slice(n,n+=je));t=t.slice(n),n=je-t.length}else n-=a;for(;n--;)t+="0";e.d.push(+t),He&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function Mw(e,t){var r,n,a,s,i,o,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Sy.test(t))return Il(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Bw.test(t))r=16,t=t.toLowerCase();else if(Nw.test(t))r=2;else if(kw.test(t))r=8;else throw Error(ta+t);for(s=t.search(/p/i),s>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),i=s>=0,n=e.constructor,i&&(t=t.replace(".",""),o=t.length,s=o-s,a=xy(n,new n(r),s,s*2)),u=eo(t,r,Gr),l=u.length-1,s=l;u[s]===0;--s)u.pop();return s<0?new n(e.s*0):(e.e=rc(u,l),e.d=u,He=!1,i&&(e=St(e,a,o*4)),c&&(e=e.times(Math.abs(c)<54?Kt(2,c):ba.pow(2,c))),He=!0,e)}function jw(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:is(e,2,t,t);r=1.4*Math.sqrt(n),r=r>16?16:r|0,t=t.times(1/nc(5,r)),t=is(e,2,t,t);for(var a,s=new e(5),i=new e(16),o=new e(20);r--;)a=t.times(t),t=t.times(s.plus(a.times(i.times(a).minus(o))));return t}function is(e,t,r,n,a){var s,i,o,c,u=e.precision,l=Math.ceil(u/je);for(He=!1,c=r.times(r),o=new e(n);;){if(i=St(o.times(c),new e(t++*t++),u,1),o=a?n.plus(i):n.minus(i),n=St(i.times(c),new e(t++*t++),u,1),i=o.plus(n),i.d[l]!==void 0){for(s=l;i.d[s]===o.d[s]&&s--;);if(s==-1)break}s=o,o=n,n=i,i=s}return He=!0,i.d.length=l+1,i}function nc(e,t){for(var r=e;--t;)r*=e;return r}function $y(e,t){var r,n=t.s<0,a=Vr(e,e.precision,1),s=a.times(.5);if(t=t.abs(),t.lte(s))return xn=n?4:1,t;if(r=t.divToInt(a),r.isZero())xn=n?3:2;else{if(t=t.minus(r.times(a)),t.lte(s))return xn=Op(r)?n?2:3:n?4:1,t;xn=Op(r)?n?1:4:n?3:2}return t.minus(a).abs()}function T0(e,t,r,n){var a,s,i,o,c,u,l,d,h,p=e.constructor,f=r!==void 0;if(f?($r(r,1,sa),n===void 0?n=p.rounding:$r(n,0,8)):(r=p.precision,n=p.rounding),!e.isFinite())l=Ty(e);else{for(l=ln(e),i=l.indexOf("."),f?(a=2,t==16?r=r*4-3:t==8&&(r=r*3-2)):a=t,i>=0&&(l=l.replace(".",""),h=new p(1),h.e=l.length-i,h.d=eo(ln(h),10,a),h.e=h.d.length),d=eo(l,10,a),s=c=d.length;d[--c]==0;)d.pop();if(!d[0])l=f?"0p+0":"0";else{if(i<0?s--:(e=new p(e),e.d=d,e.e=s,e=St(e,h,r,n,0,a),d=e.d,s=e.e,u=yy),i=d[r],o=a/2,u=u||d[r+1]!==void 0,u=n<4?(i!==void 0||u)&&(n===0||n===(e.s<0?3:2)):i>o||i===o&&(n===4||u||n===6&&d[r-1]&1||n===(e.s<0?8:7)),d.length=r,u)for(;++d[--r]>a-1;)d[r]=0,r||(++s,d.unshift(1));for(c=d.length;!d[c-1];--c);for(i=0,l="";i<c;i++)l+=wl.charAt(d[i]);if(f){if(c>1)if(t==16||t==8){for(i=t==16?4:3,--c;c%i;c++)l+="0";for(d=eo(l,a,t),c=d.length;!d[c-1];--c);for(i=1,l="1.";i<c;i++)l+=wl.charAt(d[i])}else l=l.charAt(0)+"."+l.slice(1);l=l+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)l="0"+l;l="0."+l}else if(++s>c)for(s-=c;s--;)l+="0";else s<c&&(l=l.slice(0,s)+"."+l.slice(s))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function Up(e,t){if(e.length>t)return e.length=t,!0}function Fw(e){return new this(e).abs()}function qw(e){return new this(e).acos()}function Hw(e){return new this(e).acosh()}function Kw(e,t){return new this(e).plus(t)}function Vw(e){return new this(e).asin()}function zw(e){return new this(e).asinh()}function Gw(e){return new this(e).atan()}function Qw(e){return new this(e).atanh()}function Ww(e,t){e=new this(e),t=new this(t);var r,n=this.precision,a=this.rounding,s=n+4;return!e.s||!t.s?r=new this(NaN):!e.d&&!t.d?(r=Vr(this,s,1).times(t.s>0?.25:.75),r.s=e.s):!t.d||e.isZero()?(r=t.s<0?Vr(this,n,a):new this(0),r.s=e.s):!e.d||t.isZero()?(r=Vr(this,s,1).times(.5),r.s=e.s):t.s<0?(this.precision=s,this.rounding=1,r=this.atan(St(e,t,s,1)),t=Vr(this,s,1),this.precision=n,this.rounding=a,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(St(e,t,s,1)),r}function Zw(e){return new this(e).cbrt()}function Yw(e){return ke(e=new this(e),e.e+1,2)}function Xw(e,t,r){return new this(e).clamp(t,r)}function Jw(e){if(!e||typeof e!="object")throw Error(tc+"Object expected");var t,r,n,a=e.defaults===!0,s=["precision",1,sa,"rounding",0,8,"toExpNeg",-Ga,0,"toExpPos",0,Ga,"maxE",0,Ga,"minE",-Ga,0,"modulo",0,9];for(t=0;t<s.length;t+=3)if(r=s[t],a&&(this[r]=Tl[r]),(n=e[r])!==void 0)if(lr(n)===n&&n>=s[t+1]&&n<=s[t+2])this[r]=n;else throw Error(ta+r+": "+n);if(r="crypto",a&&(this[r]=Tl[r]),(n=e[r])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[r]=!0;else throw Error(by);else this[r]=!1;else throw Error(ta+r+": "+n);return this}function eT(e){return new this(e).cos()}function tT(e){return new this(e).cosh()}function Ay(e){var t,r,n;function a(s){var i,o,c,u=this;if(!(u instanceof a))return new a(s);if(u.constructor=a,Lp(s)){u.s=s.s,He?!s.d||s.e>a.maxE?(u.e=NaN,u.d=null):s.e<a.minE?(u.e=0,u.d=[0]):(u.e=s.e,u.d=s.d.slice()):(u.e=s.e,u.d=s.d?s.d.slice():s.d);return}if(c=typeof s,c==="number"){if(s===0){u.s=1/s<0?-1:1,u.e=0,u.d=[0];return}if(s<0?(s=-s,u.s=-1):u.s=1,s===~~s&&s<1e7){for(i=0,o=s;o>=10;o/=10)i++;He?i>a.maxE?(u.e=NaN,u.d=null):i<a.minE?(u.e=0,u.d=[0]):(u.e=i,u.d=[s]):(u.e=i,u.d=[s]);return}else if(s*0!==0){s||(u.s=NaN),u.e=NaN,u.d=null;return}return Il(u,s.toString())}else if(c!=="string")throw Error(ta+s);return(o=s.charCodeAt(0))===45?(s=s.slice(1),u.s=-1):(o===43&&(s=s.slice(1)),u.s=1),Sy.test(s)?Il(u,s):Mw(u,s)}if(a.prototype=ce,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=a.set=Jw,a.clone=Ay,a.isDecimal=Lp,a.abs=Fw,a.acos=qw,a.acosh=Hw,a.add=Kw,a.asin=Vw,a.asinh=zw,a.atan=Gw,a.atanh=Qw,a.atan2=Ww,a.cbrt=Zw,a.ceil=Yw,a.clamp=Xw,a.cos=eT,a.cosh=tT,a.div=rT,a.exp=nT,a.floor=aT,a.hypot=sT,a.ln=iT,a.log=oT,a.log10=uT,a.log2=cT,a.max=lT,a.min=dT,a.mod=hT,a.mul=pT,a.pow=fT,a.random=gT,a.round=mT,a.sign=yT,a.sin=vT,a.sinh=bT,a.sqrt=CT,a.sub=ST,a.sum=ET,a.tan=xT,a.tanh=wT,a.trunc=TT,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)e.hasOwnProperty(r=n[t++])||(e[r]=this[r]);return a.config(e),a}function rT(e,t){return new this(e).div(t)}function nT(e){return new this(e).exp()}function aT(e){return ke(e=new this(e),e.e+1,3)}function sT(){var e,t,r=new this(0);for(He=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return He=!0,new this(1/0);r=t}return He=!0,r.sqrt()}function Lp(e){return e instanceof ba||e&&e.toStringTag===Cy||!1}function iT(e){return new this(e).ln()}function oT(e,t){return new this(e).log(t)}function cT(e){return new this(e).log(2)}function uT(e){return new this(e).log(10)}function lT(){return wy(this,arguments,"lt")}function dT(){return wy(this,arguments,"gt")}function hT(e,t){return new this(e).mod(t)}function pT(e,t){return new this(e).mul(t)}function fT(e,t){return new this(e).pow(t)}function gT(e){var t,r,n,a,s=0,i=new this(1),o=[];if(e===void 0?e=this.precision:$r(e,1,sa),n=Math.ceil(e/je),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));s<n;)a=t[s],a>=429e7?t[s]=crypto.getRandomValues(new Uint32Array(1))[0]:o[s++]=a%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(n*=4);s<n;)a=t[s]+(t[s+1]<<8)+(t[s+2]<<16)+((t[s+3]&127)<<24),a>=214e7?crypto.randomBytes(4).copy(t,s):(o.push(a%1e7),s+=4);s=n/4}else throw Error(by);else for(;s<n;)o[s++]=Math.random()*1e7|0;for(n=o[--s],e%=je,n&&e&&(a=Kt(10,je-e),o[s]=(n/a|0)*a);o[s]===0;s--)o.pop();if(s<0)r=0,o=[0];else{for(r=-1;o[0]===0;r-=je)o.shift();for(n=1,a=o[0];a>=10;a/=10)n++;n<je&&(r-=je-n)}return i.e=r,i.d=o,i}function mT(e){return ke(e=new this(e),e.e+1,this.rounding)}function yT(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function vT(e){return new this(e).sin()}function bT(e){return new this(e).sinh()}function CT(e){return new this(e).sqrt()}function ST(e,t){return new this(e).sub(t)}function ET(){var e=0,t=arguments,r=new this(t[e]);for(He=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return He=!0,ke(r,this.precision,this.rounding)}function xT(e){return new this(e).tan()}function wT(e){return new this(e).tanh()}function TT(e){return ke(e=new this(e),e.e+1,1)}ce[Symbol.for("nodejs.util.inspect.custom")]=ce.toString;ce[Symbol.toStringTag]="Decimal";var ba=ce.constructor=Ay(Tl);Ao=new ba(Ao);Io=new ba(Io);const $T=e=>new Promise((t,r)=>{Q(`${we}/certificate/expirationDate?forCompany=${e}`).then(n=>{t(n)}).catch(n=>{r(n.response)})}),AT=async(e,t,r)=>{const n=new URLSearchParams;return t&&n.append("rfc",t),r&&n.append("businessName",r),J(`${we}/certificate/validate?${n}`,e).then(a=>a).catch(a=>{throw a.response})},IT=e=>new Promise((t,r)=>{ft(`${we}/certificate?forCompany=${e}`).then(n=>{t(n)}).catch(n=>{r(n.response)})}),PT=e=>new Promise((t,r)=>{gi(`${we}/currency/list${e?"/no-cache":""}`).then(n=>{n.data&&n.data.length>0&&(n.data=n0(n.data)),t(n)}).catch(n=>{r(n)})}),ZP=e=>new Promise((t,r)=>{gi(we+`/currency?iso=${e}`).then(n=>{n.data&&n.data!=null&&(n.data=n0(n.data)),t(n)}).catch(n=>{r(n)})}),_T=(e="MXN",t=!1)=>{const r=t?"/no-cache":"";return new Promise(n=>{Q(`${Pn}/currency/list?base=${e}${r}`).then(a=>{n(a)}).catch(a=>{n(a)})})},DT=e=>new Promise(t=>{J(we+"/currency/list",e).then(r=>{t(r)}).catch(r=>{t(r)})}),RT=e=>new Promise((t,r)=>{ze(we+`/currency/${e.iso}`,e).then(n=>{console.log(n),t(n)}).catch(n=>{r(n)})}),NT=e=>new Promise((t,r)=>{ft(we+"/currency?iso="+e).then(n=>{t(n)}).catch(n=>{r(n)})}),Mp=e=>new Promise((t,r)=>{gi(we+`/currencyDenomination?iso=${e}`).then(n=>{(n.status==200||n.status==201)&&(n.data=n0(n.data)),t(n)}).catch(n=>{r(n)})}),BT=e=>new Promise(t=>{J(we+"/currencyDenomination",{iso:e,denominations:[]}).then(r=>{t(r)}).catch(r=>{t(r)})}),kT=(e,t)=>{const r=sr.diff(t.prevState,t.newState,{invertible:!1,hash:n=>n.denomination});return new Promise((n,a)=>{ze(we+`/currencyDenomination/${e}`,r).then(s=>{n(s)}).catch(s=>{a(s)})})},YP=e=>new Promise(t=>{J(we+`/currency/autoUpdateCurrencyXR?autoUpdateCurrencyXR=${e}`,{}).then(r=>{t(r)}).catch(r=>{t(r)})}),XP=()=>new Promise((e,t)=>{Q(we+"/currency/autoUpdateCurrencyXR").then(r=>{e(r)}).catch(r=>{t(r)})}),JP=e=>{const t={...e,exchangeRate:1,predetermined:!0,main:!0,base:e.iso};return new Promise((r,n)=>{J(we+"/currency",t).then(a=>{r(a)}).catch(a=>{n(a)})})},OT=e=>new Promise(t=>{console.log(e),bi(e),J(we+"/invoiceInfo",e).then(r=>{console.log(r),t(r)}).catch(r=>{console.log(r),t(r.response)})}),Pl=async()=>J(`${we}/graphQL`,`query {
        invoiceInfo {
            rfc
            idCif
            businessName
            city
            claveSatRegimen
            country
            descripcionRegimen
            district
            extNumber
            intNumber
            state
            zipCode
            contentId
            county
            imssNumber
            street
            certificate {
                cerName
                keyName
                requestDate
                expirationDate
            }
        }
    }`,"application/graphql").then(e=>{if(e.data.errors)throw e.data.errors;return{data:e.data.data.invoiceInfo||null,status:e.status}}),UT=async()=>J(`${we}/graphQL`,`query {
        invoiceInfoLite {
            certificate {
                expirationDate
            }
        }
    }`,"application/graphql").then(e=>{if(e.data.errors)throw e.data.errors;return e.data.data.invoiceInfoLite}),LT=(e,t)=>{let r=Xo(t,e);return bi(r),r!=null&&r.certificate&&(Object.entries(r.certificate).length===0?delete r.certificate:r.certificate.certificate!==void 0?(delete r.certificate,r={...r,certificate:e.certificate},delete r.certificate.expirationDate,delete r.certificate.requestDate,delete r.certificate.id):delete r.certificate),new Promise(n=>{ze(we+"/invoiceInfo",r).then(a=>{a.data=r,n(a)}).catch(a=>{n(a)})})},e_=async(e,t)=>{const r=`query {
        invoiceInfoSat(rfc: "${(e==null?void 0:e.toUpperCase())??""}", idCif: "${t}") {
            businessName
            state
            county
            district
            street
            extNumber
            intNumber
            zipCode
            regimensSat {
                descripcionRegimen
                fechaDeAlta
            }
        }
    }`;return J(we+"/graphQL",r,"application/graphql").then(n=>(console.log("response",n),n.data.data.invoiceInfoSat||null)).catch(n=>{throw n.response})},MT=(e,t,r)=>{const n=sr.diff(e,t,{invertible:!1});return new Promise((a,s)=>{if(!n.length){a(null);return}const{document:i="sales",token:o}=r??{},c=o?{"Set-Authorization":`${o}`}:{};return $e.patch(`${we}/configuration/document/${i}`,n,{headers:{"Content-Type":"application/json;charset=UTF-8",...c}}).then(u=>{a(u)}).catch(u=>{s(u.response)})})},jT=async(e,t="sales",r)=>{const n=t==="sales"||t==="shared"?"put":"post",a=`${we}/configuration/document/${t==="shared"?"sales":t}${t!=="purchase"?"/default":""}${t==="sales"||t==="shared"||t==="order"?`?generalPublicName=${e}`:""}`,s=t==="purchase"?{mailUuid:null}:{},i=r?{"Set-Authorization":`${r}`}:{};return $e[n](a,s,{headers:{...i,"Content-Type":"application/json"}}).then(o=>o).catch(o=>{throw o.response})},FT=(e="sales",t)=>{const r=t?{"Set-Authorization":`${t}`}:{};return new Promise((n,a)=>{e==="sales"?$e.put(`${we}/configuration/document/sales/restoreDefaultValues`,{},{headers:{...r,"Content-Type":"application/json"}}).then(s=>n(s)).catch(s=>a(s.response)):$e.patch(`${we}/configuration/document/${e}/restoreDefaultValues`,{},{headers:{...r,"Content-Type":"application/json"}}).then(s=>n(s)).catch(s=>a(s.response))})},qT=async(e,t)=>new Promise((r,n)=>{Q(`${we}/dynamicDocumentPrintConf/dto/${e}/${t}`).then(a=>r(a)).catch(a=>n(a))}),HT=async(e,t)=>new Promise((r,n)=>{Q(`${we}/dynamicDocumentPrintConf/${e}/${t}`).then(a=>r(a)).catch(a=>n(a))}),KT=async(e,t,r,n)=>{const a=n?{"Set-Authorization":`${n}`}:{};return new Promise(s=>{$e.put(`${we}/dynamicDocumentPrintConf/${e}/${t}`,r,{headers:{"Content-Type":"application/json;charset=UTF-8",...a}}).then(i=>s(i)).catch(i=>s(i.response))})},VT=e=>{const t=e?"/no-cache":"";return new Promise((r,n)=>{Q(`${we}/paymentOption/list/byBranch${t}`).then(a=>{r(a)}).catch(a=>{n(a)})})},zT=(e,t)=>new Promise((r,n)=>{ze(we+`/paymentOption/${e}`,t).then(a=>{r(a)}).catch(a=>{n(a.response)})}),GT=e=>new Promise((t,r)=>{J(we+"/paymentOption",e).then(n=>{t(n)}).catch(n=>{r(n.response)})}),jp=1,QT=e=>{const t=Math.abs(e)||e;return new Promise((r,n)=>{gi(`${we}/serie/list?documentType=${t}`).then(a=>{a.status===204||a.status===304||(a.data=Am(a.data).map(s=>{const{contentId:i,branchOfficeId:o,documentType:c,serie:u}=s;return{...s,id:`${i}#${o}#${c}#${u}`}})),r(a)}).catch(a=>{n(a.response)})})},t_=(e,t)=>{const r=Math.abs(t)||t;return new Promise((n,a)=>{gi(`${we}/serie/${r}?serie=${encodeURIComponent(e)}`).then(s=>{const i={...Am(s.data)},{contentId:o,branchOfficeId:c,documentType:u,serie:l}=i;s.data={...i,id:`${o}#${c}#${u}#${l}`},n(s)}).catch(s=>{a(s.response)})})},r_=({serie:e,initialFolio:t,documentType:r},n)=>{const a=Math.abs(r)||r;return new Promise((s,i)=>{const o=n?{"Set-Authorization":`${n}`}:{};jr(`${we}/serie`,{serie:e.toUpperCase(),folio:t,documentType:a},{...o,"Content-Type":"application/json"}).then(c=>{s(c)}).catch(c=>{i(c.response)})})},n_=(e,t,r)=>{(e.documentType===-1||t.documentType===-1)&&(e.documentType=jp,t.documentType=jp);const n=h0(t,e);typeof(n==null?void 0:n.status)<"u"&&(n.status=n.status?1:-1);const a=r?{"Set-Authorization":`${r}`}:{};return new Promise((s,i)=>{Object.keys(n??{}).length>0?$e.patch(`${we}/serie/${e.documentType}?serie=${e.serie}`,n,{headers:{"Content-Type":"application/json",...a}}).then(o=>{s(o)}).catch(o=>{i(o.response)}):s({status:null})})},a_=(e,t,r)=>{const n=Math.abs(t)||t,a=r?{"Set-Authorization":`${r}`}:{};return new Promise((s,i)=>{$e.delete(`${we}/serie/${n}?serie=${encodeURIComponent(e)}`,{headers:{"Content-Type":"application/json",...a}}).then(o=>{s(o)}).catch(o=>{i(o.response)})})},s_=(e=1)=>{const t=Math.abs(e)||e;return new Promise((r,n)=>{J(`${we}/serie/default?documentType=${t}`,{}).then(a=>{r(a)}).catch(a=>{n(a.response)})})},WT=()=>new Promise(e=>{Q(we+"/configuration/general/amountPattern").then(t=>e(t)).catch(t=>e(t))}),ZT=e=>new Promise(t=>{Re(we+"/configuration/general/amountPattern",e).then(r=>t(r)).catch(r=>t(r))}),YT=(e="sales")=>new Promise((t,r)=>{Q(we+`/configuration/document/${e}`).then(n=>t(n)).catch(n=>r(n))}),i_=e=>new Promise((t,r)=>{Re(we+`/configuration/general/profitByMargin?profitByMargin=${e}`).then(n=>t(n)).catch(n=>r(n))}),o_=e=>{const t=sr.diff({},e,{invertible:!1});return new Promise((r,n)=>{ze(we+"/configuration/product",t).then(a=>r(a)).catch(a=>n(a))})},XT=()=>{const e=`{
        productConfiguration {
            priceDecimals
            profitByMargin
        }
    }`;return new Promise((t,r)=>{J(It,e,"application/graphql").then(n=>{const{data:a,...s}=n;t({...s,data:a.data})}).catch(n=>r(n))})},c_=e=>new Promise(t=>{Re(we+"/configuration/general/dateTimePattern",e).then(r=>t(r)).catch(r=>t(r))}),JT=()=>new Promise(e=>{Q(we+"/configuration/general/dateTimePattern").then(t=>e(t)).catch(t=>e(t))}),e$=e=>{const t=sr.diff({},{allowTransfersProductsNoStock:e},{invertible:!1});return ze(`${we}/configuration/stockTransfer`,t)},u_=()=>J(`${we}/configuration/stockTransfer/default`,null),t$=()=>new Promise((e,t)=>{Q(we+"/printProfile/list").then(r=>{e(r)}).catch(r=>{t(r.response)})}),r$=()=>new Promise(e=>{Q(we+"/printProfile/availableDocs").then(t=>{e(t)}).catch(t=>{e(t.response)})}),n$=e=>new Promise((t,r)=>{Re(we+"/printProfile",e).then(n=>{t(n)}).catch(n=>{r(n.response)})}),a$=()=>new Promise((e,t)=>{Re(we+"/printProfile/default").then(r=>{e(r)}).catch(r=>{t(r.response)})}),s$=e=>new Promise((t,r)=>{ft(we+"/printProfile?uuid="+e).then(n=>{t(n)}).catch(n=>{r(n.response)})}),i$=(e,t)=>{const r=sr.diff(e,t,{hash:n=>n.property||n.autoPrint||n.numCopies||n.selected,invertible:!1});return new Promise((n,a)=>{ze(we+"/printProfile/"+t.uuid,r).then(s=>{n(s)}).catch(s=>{a(s.response)})})},o$=()=>new Promise((e,t)=>{Q(we+"/configuration/general/logo").then(r=>{e(r)}).catch(r=>{t(r.response)})}),c$=e=>new Promise((t,r)=>{Re(we+"/configuration/general/logo",e).then(n=>{t(n)}).catch(n=>{r(n.response)})}),u$=()=>new Promise(e=>{Q(`${we}/ecommerce/config`).then(t=>e(t)).catch(t=>e(t))}),l$=()=>new Promise(e=>{Q(`${we}/ecommerce/list`).then(t=>e(t)).catch(t=>e(t))}),d$=e=>new Promise(t=>{ze(`${we}/ecommerce/changeDomain`,e).then(r=>t(r)).catch(r=>t(r))}),h$=e=>new Promise(t=>{Re(`${we}/ecommerce/config`,e).then(r=>t(r)).catch(r=>t(r))}),p$=e=>new Promise(t=>{J(`${we}/ecommerce/config`,e).then(r=>t(r)).catch(r=>t(r))}),f$=e=>new Promise(t=>{Re(`${we}/ecommerce/select?uuid=${e}`).then(r=>t(r)).catch(r=>t(r))}),Fp=()=>new Promise(e=>{Q(`${we}/ecommerce/isActive`).then(t=>e(t)).catch(t=>e(t))}),g$=e=>new Promise(t=>{Re(`${we}/ecommerce/switch`,e).then(r=>t(r)).catch(r=>t(r))}),m$=e=>new Promise(t=>{Q(`${we}/ecommerce/branchesByConfig?uuid=${e}`).then(r=>t(r)).catch(r=>t(r))}),y$=(e,t)=>new Promise(r=>{Re(`${we}/ecommerce/banner`,{uuid:e,base64Banner:t}).then(n=>r(n)).catch(n=>r(n))}),v$=()=>new Promise(e=>{ft(`${we}/ecommerce/branchConfig`).then(t=>e(t)).catch(t=>e(t))}),b$=()=>new Promise(e=>{Re(`${we}/ecommerce/refresh`).then(t=>e(t)).catch(t=>e(t))}),C$=(e,t=0,r)=>new Promise(n=>{const a=new URLSearchParams({page:t.toString(),...!!r&&{name:r}});Q(Pn+"/satCatalogue/"+e+`/list?${a.toString()}`).then(s=>n(s)).catch(s=>n(s))}),S$=e=>Q(Pn+`/country/list?lang=${e}`),Iy=e=>new Promise((t,r)=>{Q(`${Pn}/product?sku=${e}`).then(n=>{t(n)}).catch(n=>{r(n)})}),Py=e=>new Promise((t,r)=>{Q(`${Pn}/productImage?productId=${e}`).then(n=>{t(n)}).catch(n=>{r(n)})}),E$=(e="ESP")=>new Promise(t=>{Q(`${Pn}/businessType/list?lang=${e}`).then(r=>t(r)).catch(r=>t(r))}),x$=()=>new Promise((e,t)=>{Q(Pn+"/satCatalogue/regime/list").then(r=>e(r)).catch(r=>t(r))}),l_=()=>new Promise((e,t)=>{Q(Pn+"/timeZone/list").then(r=>e(r)).catch(r=>t(r))}),d_=e=>new Promise((t,r)=>{Q(Pn+`/satCatalogue/useCfdi/byRegimeId/${e}`).then(n=>t(n)).catch(n=>r(n))}),h_=e=>new Promise((t,r)=>{Iy(e).then(async n=>{const{data:a}=await Py(n.data.id);n.data.images=a,t(n)}).catch(r)});var w$=Object.defineProperty,T$=(e,t,r)=>t in e?w$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$$=(e,t,r)=>T$(e,t+"",r);let pe=class{constructor(t){$$(this,"fragmentList",[]),this.queries=t,this.queries=t||""}insertQuery(t,r=!0){return r&&(this.queries+=`
${t}
`),this}insertFragment(t){return this.fragmentList.push(t),this}build(t){var r;let n=`${t||""} {
 ${this.queries} 
}`;return(r=this.fragmentList)!=null&&r.length&&(n=n.concat(`
 ${this.fragmentList.join(`
`)}`)),n}static unwrap(t){const{data:r,...n}=t;return{...n,data:r.data,errors:r.errors}}static parseParam(t){return typeof t=="object"&&!Array.isArray(t)?`{ ${Object.keys(t).filter(r=>t[r]!==void 0).map(r=>`${r}:${JSON.stringify(t[r])}`).join(", ")} }`:JSON.stringify(t)}};const ac="department/v1/department",A$=async()=>{const e=new pe(`
		catalog {
			departments {
				uuid
			  	name
			  	selection {
					uuid
					order
			  	}	
			  	items
				order
			  	commission
			}
			categories {
				uuid
				name
			}
		}
	`).build();return pn(It,e).then(pe.unwrap)},I$=e=>Re(ac,e),P$=({uuid:e,...t})=>ze(`${ac}/${e}`,t),_$=e=>ft(`${ac}/${e}`),f_=e=>J(`${ac}/order`,e),sc="department/v1/category",D$=e=>Re(sc,e),R$=({uuid:e,...t})=>ze(`${sc}/${e}`,t),N$=e=>ft(`${sc}/${e}`),g_=e=>J(`${sc}/order`,e),ic="tax/v1/tax",B$=async()=>{const e=new pe(`
		content {
			taxes {
			uuid
			automatic
			name
			rate
			tras
			local
			order
			type
			claveSat
			taxOnTax
			taxOnTaxId
			over {
				uuid
				rate
				tras
				name
			}
			}
		}
	`).build();return pn(It,e).then(pe.unwrap)},k$=e=>Re(ic,e),O$=(e,t,r)=>ze(`${ic}/${e}?calculateNet=${r}`,t),U$=e=>ft(`${ic}/${e}`),m_=e=>Re(`${ic}/order`,e),$0="unit/v1/unit",L$=async()=>{const e=new pe(`
		content {
			units {
				uuid
				name
				shortName
				claveSat
			}
		}
	`).build();return pn(It,e).then(pe.unwrap)},M$=e=>Re($0,e),j$=(e,t)=>ze(`${$0}/${e}`,t),F$=e=>ft(`${$0}/${e}`),ir="product/v1",oc="search/v1",_l=e=>$e.post(`${ir}/product/list`,e,{headers:{"Content-Type":"application/json"},transformResponse:Go().array()}),y_=e=>Re(`${ir}/product`,e),v_=(e,t)=>ze(`${ir}/product/${e}`,t),q$=e=>ft(`${ir}/product/${e}`),H$=(e,t)=>{const r=new URLSearchParams(t).toString();return J(`${ir}/product/sku?${r}`,e,"text/plain;charset=UTF-8")},b_=e=>J("catalogue/v1/product/bySkus",e),K$=(e,t,r,n,a)=>{const s=new pe(`product(uuid:"${e}") {
            uuid
            bulk
            sku
            skus
            imageUrl
            type
            description
            details
            favorite
            departmentUuid
            categoryUuid
            salesUnitUuid
            created
            hidden
            lot
            tags
        }
        listImages (uuid:"${e}") {
            uuid
            url
            selected
        }`).insertQuery(`stockInfo(uuid:"${e}"${r?`, warehouse:"${r}"`:""}) {
            available
            lot
            series
            stock
            maxStock
            minStock
        }`,n==null?void 0:n.readStock).insertQuery(`prices(uuid:"${e}" priceList:"${t}") {
            price1
            price2
            price3
            price4
            price5
            price6
            price7
            price8
            price9
            price10
            netPrice1
            netPrice2
            netPrice3
            netPrice4
            netPrice5
            netPrice6
            netPrice7
            netPrice8
            netPrice9
            netPrice10
            profit1
            profit2
            profit3
            profit4
            profit5
            profit6
            profit7
            profit8
            profit9
            profit10
            margin1
            margin2
            margin3
            margin4
            margin5
            margin6
            margin7
            margin8
            margin9
            margin10
            costByUnit
            netCostByUnit
            saleTaxes
        }`,!!t&&(n==null?void 0:n.readPrices)).build();return $e.post(It,s,{transformResponse:[i=>hr(i)],headers:{"Content-Type":"application/graphql"},signal:a})},C_=(e,t,r)=>{const n=new pe(`
        product(uuid:"${e}") {
            type
            uuid
            sku
            skus
            description
            details
            favorite
            saleable
            bulk
            departmentUuid
            categoryUuid
            salesUnitUuid
            claveSat
            customsName
            customsDocDate
            customsDocNumber
            autoWeigh
            weight
            waste
            avgPurchasePrice
            minProfitPercentage
            propertyAccount
            lot
        }
        listImages (uuid:"${e}") {
            uuid
            url
            selected
        }`).insertQuery(`
        prices (uuid:"${e}" priceList:"${t}") {
            price1
            price2
            price3
            price4
            price5
            price6
            price7
            price8
            price9
            price10
            netPrice1
            netPrice2
            netPrice3
            netPrice4
            netPrice5
            netPrice6
            netPrice7
            netPrice8
            netPrice9
            netPrice10
            margin1
            margin2
            margin3
            margin4
            margin5
            margin6
            margin7
            margin8
            margin9
            margin10
            profit1
            profit2
            profit3
            profit4
            profit5
            profit6
            profit7
            profit8
            profit9
            profit10
            wholeSale1
            wholeSale2
            wholeSale3
            wholeSale4
            wholeSale5
            wholeSale6
            wholeSale7
            wholeSale8
            wholeSale9
            wholeSale10
            costByUnit
            netCostByUnit
            avgCostByUnit
            avgNetCostByUnit
            saleTaxes
            iso
        }         
    `,!!t&&r).build();return $e.post(It,n,{transformResponse:[a=>hr(a)],headers:{"Content-Type":"application/graphql"}}).then(pe.unwrap)},S_=async(e,t,r)=>{const n=` productForSku(sku:"${e}") {
            uuid
            type
            sku
            description
            claveSat
            imageUrl
            salesUnitUuid
            departmentUuid
            categoryUuid
            saleable
            bulk
            autoWeigh
            favorite
            avgPurchasePrice
            minProfitPercentage
            userModifierId
            modified
            created
            lot
            details
        }`,a=`pricesBySku (sku:"${e}" priceList:"${t}") {
            price1
            price2
            price3
            price4
            price5
            price6
            price7
            price8
            price9
            price10
            netPrice1
            netPrice2
            netPrice3
            netPrice4
            netPrice5
            netPrice6
            netPrice7
            netPrice8
            netPrice9
            netPrice10
            wholeSale1
            wholeSale2
            wholeSale3
            wholeSale4
            wholeSale5
            wholeSale6
            wholeSale7
            wholeSale8
            wholeSale9
            wholeSale10
            costByUnit
            netCostByUnit
            saleTaxes
            avgCostByUnit
            avgNetCostByUnit
            iso
        }`,s=`stockForSku(sku: "${e}"${r?`,warehouse:"${r}"`:""}) {
            stock
            minStock
            maxStock
            lots {
                stock
                lotNumber
                warehouseId
                initialStock
                fabricationDate
                expirationDate
            }
        }`,i=`query{
            ${n}
            ${a}
            ${s}
        }`;return J(It,i,"application/graphql").then(pe.unwrap)},E_=async(e,t,r,n)=>{const{lot:a=void 0}=n||{},s=`product(uuid:"${e}") {
            uuid
            claveSat
            details
        }`,i=`prices(uuid:"${e}" priceList:"${t}") {
            price1
            price2
            price3
            price4
            price5
            price6
            price7
            price8
            price9
            price10
            netPrice1
            netPrice2
            netPrice3
            netPrice4
            netPrice5
            netPrice6
            netPrice7
            netPrice8
            netPrice9
            netPrice10
            wholeSale1
            wholeSale2
            wholeSale3
            wholeSale4
            wholeSale5
            wholeSale6
            wholeSale7
            wholeSale8
            wholeSale9
            wholeSale10
            costByUnit
            netCostByUnit
            saleTaxes
            avgCostByUnit
            avgNetCostByUnit
            iso
        }`,o=`stockInfo(uuid: "${e}"${r?`, warehouse:"${r}"`:""}) {
            stock
            minStock
            maxStock
            lots {
                stock
                lotNumber
                warehouseId
                initialStock
                fabricationDate
                expirationDate
            }
        }`,c=`query{
            ${s}
            ${i}
            ${a?o:""}
        }`;return J(It,c,"application/graphql").then(pe.unwrap)},x_=async(e,t)=>{const r=`query{
            ${`stockInfo(uuid: "${e}"${t?`, warehouse:"${t}"`:""}) {
            stock
            minStock
            maxStock
            lots {
                stock
                lotNumber
                warehouseId
                initialStock
                fabricationDate
                expirationDate
            }
        }`}
        }`;return J(It,r,"application/graphql").then(pe.unwrap)},w_=async(e,t)=>{const{warehouse:r,priceListUuid:n}=t||{},a=r?`, warehouse: "${r}"`:"",s=`query {
        stockForProducts(uuids:[${'"'+e.join('","')+'"'}]${a}) {
            products {
                uuid,
                stock,
                minStock,
                maxStock
            }
        }
        pricesForProducts(uuids:[${'"'+e.join('","')+'"'}] priceList:"${n}") {
            price1
            price2
            price3
            price4
            price5
            price6
            price7
            price8
            price9
            price10
            netPrice1
            netPrice2
            netPrice3
            netPrice4
            netPrice5
            netPrice6
            netPrice7
            netPrice8
            netPrice9
            netPrice10
            margin1
            margin2
            margin3
            margin4
            margin5
            margin6
            margin7
            margin8
            margin9
            margin10
            profit1
            profit2
            profit3
            profit4
            profit5
            profit6
            profit7
            profit8
            profit9
            profit10
            wholeSale1
            wholeSale2
            wholeSale3
            wholeSale4
            wholeSale5
            wholeSale6
            wholeSale7
            wholeSale8
            wholeSale9
            wholeSale10
            costByUnit
            netCostByUnit
            avgCostByUnit
            avgNetCostByUnit
            productUuid
            saleTaxes
            iso
        }  
    }
    `;return J(It,s,"application/graphql").then(i=>{var o,c,u,l,d;if((o=i.data)!=null&&o.errors)throw i.data.errors;const h=((l=(u=(c=i.data.data)==null?void 0:c.stockForProducts)==null?void 0:u[0])==null?void 0:l.products)??[],p=((d=i.data.data)==null?void 0:d.pricesForProducts)??[];return[h,p]}).catch(i=>{throw i})},V$=(e,t,r,n)=>{const a=new URLSearchParams({from:t.toString(),size:r.toString()}).toString();return $e.post(`${oc}/search/product?${a}`,e,{...n,transformResponse:Go().array()})},T_=e=>{const t=new URLSearchParams({from:e.from.toString(),size:e.size.toString()}).toString();return $e.post(`${oc}/search/product?${t}`,{description:e.search,...(e==null?void 0:e.priceList)&&{priceListId:e==null?void 0:e.priceList},...(e==null?void 0:e.type)!=null&&{type:e.type}})},$_=e=>J(`${ir}/product/batch/department`,e),A_=e=>J(`${ir}/product/batch/category`,e),I_=(e,t)=>{const r=new URLSearchParams({...t!=null&&{warehouse:t}});return J(`${ir}/product/byIds?${r.toString()}`,e)},z$=e=>J(`${ir}/product/batch/product/delete`,e),P_=(e,t)=>{const r=`products(uuids:${pe.parseParam(e)}) {
            uuid
            type
            sku
            description
            claveSat
            imageUrl
            salesUnitUuid
            departmentUuid
            categoryUuid
            saleable
            bulk
            autoWeigh
            favorite
            avgPurchasePrice
            minProfitPercentage
            userModifierId
            modified
            created
            details
            lot
        }`,n=`pricesForProducts(uuids: ${pe.parseParam(e)} priceList: "${t}") {
            productUuid
            price1
            price2
            price3
            price4
            price5
            price6
            price7
            price8
            price9
            price10
            netPrice1
            netPrice2
            netPrice3
            netPrice4
            netPrice5
            netPrice6
            netPrice7
            netPrice8
            netPrice9
            netPrice10
            margin1
            margin2
            margin3
            margin4
            margin5
            margin6
            margin7
            margin8
            margin9
            margin10
            profit1
            profit2
            profit3
            profit4
            profit5
            profit6
            profit7
            profit8
            profit9
            profit10
            wholeSale1
            wholeSale2
            wholeSale3
            wholeSale4
            wholeSale5
            wholeSale6
            wholeSale7
            wholeSale8
            wholeSale9
            wholeSale10
            costByUnit
            netCostByUnit
            avgCostByUnit
            avgNetCostByUnit
            saleTaxes
            iso
        }`,a=`query{
            ${r}
            ${n}
        }`;return J(It,a,"application/graphql").then(pe.unwrap)},__=e=>J(`${ir}/product/bySkus`,e),D_=(e,t)=>$e.post(`${ir}/product/updateSatKeys`,e,{headers:{"Content-type":"application/json;charset=UTF-8",...t&&{"Set-Authorization":t}}}),G$=()=>{const e=new pe(`
        selectedPriceList{
        modified
    }
        `).build();return J(It,e,"application/graphql").then(pe.unwrap)},R_=(e,t,r)=>{const n=new pe(`
        productForSku(sku: "${e}") {
        uuid
            type
            sku
            description
            claveSat
            imageUrl
            salesUnitUuid
            departmentUuid
            categoryUuid
            bulk
            lot
            details
        }`).insertQuery(`
        pricesBySku(sku: "${e}" priceList: "${t}") {
        saleTaxes
            iso
            avgCostByUnit
            netCostByUnit
            avgNetCostByUnit
        }
    `).insertQuery(`
        stockForSku(sku: "${e}"${r?`, warehouse:"${r}"`:""}) {
            stock
                minStock
                maxStock
        }
    `).build();return J(It,n,"application/graphql").then(pe.unwrap)},N_=(e,t,r)=>{const n=new pe(`
        product(uuid: "${e}") {
            uuid
            type
            sku
            description
            claveSat
            imageUrl
            salesUnitUuid
            departmentUuid
            categoryUuid
            bulk
            lot
            details
        }`).insertQuery(`
        prices(uuid: "${e}" priceList: "${t}") {
            saleTaxes
            iso
            avgCostByUnit
            avgNetCostByUnit
            netCostByUnit
        }
    `).insertQuery(`stockInfo(uuid: "${e}"${r?`, warehouse:"${r}"`:""}) {
            stock
            maxStock
            minStock
                    lots {
                stock
                lotNumber
                warehouseId
                initialStock
                fabricationDate
                expirationDate
            }
        }`).build();return J(It,n,"application/graphql").then(pe.unwrap)},B_=async(e,t)=>{const r=new pe(`
        stockForProducts(uuids: ${pe.parseParam(e)}${t!=null?`, warehouse:${pe.parseParam(t)}`:""}) {
            products {
            uuid,
            stock
                lots {
                    stock
                    lotNumber
                    warehouseId
                    initialStock
                    fabricationDate
                    expirationDate
                }
            }
        } `).build();return J(It,r,"application/graphql").then(n=>{var a,s,i,o;return(o=(i=(s=(a=pe.unwrap(n))==null?void 0:a.data)==null?void 0:s.stockForProducts)==null?void 0:i[0])==null?void 0:o.products}).catch(n=>{throw n.response})},k_=e=>J(`${oc}/search/autocomplete`,e,"text/plain;charset=UTF-8"),O_=()=>Q(KC+"product/offline",{timeout:1e5}),U_=e=>J(`${ir}/product/count`,e),L_=async e=>{const t=new URLSearchParams;return e!=null&&t.append("offset",e.toString()),Q(`${ir}/product/paginate?${t.toString()}`).then(r=>{var n;return console.log("res",r),{status:r.status,data:r.data,nextPage:(n=r==null?void 0:r.headers)==null?void 0:n["content-range"]}}).catch(r=>{var n,a;throw console.log("err",r),{status:(n=r==null?void 0:r.response)==null?void 0:n.status,data:(a=r==null?void 0:r.response)==null?void 0:a.data}})},M_=async(e,t,r)=>{const n=String(new URLSearchParams({from:String(t),size:String(r)}));return J(`${oc}/search/product/paginate?${n}`,e).then(a=>{var s;return{data:a.data,status:a.status,nextPage:(s=a==null?void 0:a.headers)==null?void 0:s["content-range"]}}).catch(a=>{throw a})},j_=async(e,t,r)=>{const n={operationName:"ProductDataToExport",query:`query ProductDataToExport($uuids: [String]!, $warehouse: String, $priceList: UUID) {
        products(uuids: $uuids, warehouse: $warehouse) {
            autoWeigh
            uuid
            sku
            skus
            bulk
            description
            details
            favorite
            departmentUuid
            categoryUuid
            salesUnitUuid
            claveSat
            type
        }
        stockForProducts(uuids: $uuids, warehouse: $warehouse) {
            products {
                uuid
                stock
                maxStock
                minStock
            }
        }
        pricesForProducts(uuids: $uuids, priceList: $priceList) {
            productUuid
            price1
            price2
            price3
            price4
            price5
            price6
            price7
            price8
            price9
            price10
            netPrice1
            netPrice2
            netPrice3
            netPrice4
            netPrice5
            netPrice6
            netPrice7
            netPrice8
            netPrice9
            netPrice10
            wholeSale1
            wholeSale2
            wholeSale3
            wholeSale4
            wholeSale5
            wholeSale6
            wholeSale7
            wholeSale8
            wholeSale9
            wholeSale10
            costByUnit
            netCostByUnit
            saleTaxes
            taxes {
                rate
                name
                over {
                    uuid
                }
                taxOnTaxId
                uuid
                local
                taxOnTax
                tras
            }
        }
    }`,variables:{uuids:e,warehouse:r,priceList:t}};return $e.post(It,n,{transformResponse:[a=>hr(a)],headers:{"Content-Type":"application/json"}}).then(a=>{console.log("res",a.data);let s=null,i=null;const{products:o,stockForProducts:c,pricesForProducts:u}=a.data.data??{};c&&(s=Q$(c[0].products)),u&&(i=W$(u));const l=o.map(d=>{const h=(s==null?void 0:s[d.uuid])??null,p=(i==null?void 0:i[d.uuid])??null;return{...d,...h?{stockInfo:h}:{},...p?{priceList:p}:{}}});return console.log("productsToExport",l),l})};function Q$(e){return console.log("stocks",e),e.reduce((t,r)=>{const{uuid:n,...a}=r;return t[n]=a,t},{})}function W$(e){return console.log("prices",e),e.reduce((t,r)=>{if(!r.productUuid)return t;const{productUuid:n,...a}=r;return t[n]=a,t},{})}const F_=e=>Re(`${ir}/doctor`,e),q_=e=>Q(`${ir}/doctor/list?${e!==void 0?new URLSearchParams({offset:String(e)}):""}`),H_=e=>J(`${ir}/doctor/search`,e),K_=(e,t,r,n)=>{const a=String(new URLSearchParams(n?{warehouse:String(n),priceListId:String(t)}:{priceListId:String(t)}));return J(`${ir}/product/sku/${e}/batch?${a}`,r)},xs="stock/v1/stock",cc="stock/v1/warehouse",ws="stock/v1/lot",Ts="stock-reports/v1",_y=(e,t)=>$e.get(`${xs}/info/${t?t+"/"+e:e}`,{transformResponse:[r=>na({storeAsString:!0}).parse(r)]}),Z$=(e,t,r)=>$e.put(`${xs}/${e?e+"/"+t:t}`,r,{transformResponse:[n=>na({storeAsString:!0}).parse(n)]}),Y$=(e,t,r)=>$e.patch(`${xs}/${e?e+"/"+t:t}`,r,{transformResponse:[n=>na({storeAsString:!0}).parse(n)]}),V_=e=>J(`${Ts}/history`,e),z_=(e,t=0,r=20,n=!0)=>{const a=new URLSearchParams({offset:t==null?void 0:t.toString(),size:r.toString(),all:n?"true":"false"});return J(`${Ts}/report/stockValue?${a==null?void 0:a.toString()}`,e)},G_=e=>J(`${Ts}/report/stockValue/sum`,e),Q_=(e,t=!1,r)=>{const n=new URLSearchParams({all:t?"true":"false"});return $e.post(`${Ts}/report/stockValue/excel?${n==null?void 0:n.toString()}`,e,{responseType:"blob",timeout:6e4,...r!=null})},W_=e=>ft(`${xs}/reset${e?`/${e}`:""}`),X$=()=>Q(`${cc}/forBranch`),Z_=(e,t)=>ze(`${cc}/${e}`,t),Y_=e=>ft(`${cc}/${e}`),X_=(e,t)=>Q(`${xs}/${e}/all${t?`?${String(new URLSearchParams({branch:String(t)}))}`:""}`),J_=()=>Q("stock/v1/warehouse/selections"),eD=(e,t)=>Q(`${xs}/${e}/complete${t?"?branch="+t:""}`),tD=()=>Q(`${cc}/list`),rD=(e,t,r)=>{const n=`${ws}/`+(r?`${r}/${t}`:t);return $e.put(n,e,{transformResponse:[a=>na({storeAsString:!0}).parse(a)]})},nD=(e,t,r,n)=>{const a=`${ws}/${n?`${n}/`:""}${t}/${encodeURIComponent(r)}`;return $e.patch(a,e,{transformResponse:[s=>na({storeAsString:!0}).parse(s)]})},J$=(e,t)=>{const r=`${ws}/list/`+(t?`${t}/${e}`:e);return $e.get(r,{transformResponse:Go().array()})},aD=e=>$e.post(`${ws}/batch`,e,{transformResponse:Go().array()}),sD=(e,t,r)=>{const n=ws+`${r?`/${r}/`:"/"}${e}/${encodeURIComponent(t)}`;return ft(n)},iD=(e,t,r)=>{const n=ws+(r?`/${r}/${t}`:`/${t}`)+"/config";return Re(n,e)},oD=async()=>{const e=new pe(`
        list:warehouseList {
            name
            uuid
        }
    `).insertQuery(`selections:warehouseSelections {
            branchId
            warehouseUuid
        }`).build();return pn(It,e).then(t=>pe.unwrap(t))},cD=()=>$e.get(`${Ts}/product/torrey`,{responseType:"blob",timeout:6e4}),uD=e=>$e.post(`${Ts}/report/cofepris`,e,{timeout:6e4}),ia=`${Et}pdocument/v1/document`,e4=e=>Q(`${ia}/${e}`),qp=(e,t="",r="0",n="25")=>{let a={offset:r,items:n};return t&&(a.search=t),Q(`${ia}/${e}/detail/list?${new URLSearchParams(a).toString()}`)},t4=e=>Re(ia,e),r4=(e,t)=>Re(`${ia}/${e}/detail`,t),n4=(e,t)=>J(`${ia}/${e}/batch/category`,t),a4=(e,t)=>J(`${ia}/${e}/batch/department`,t),s4=(e,t)=>J(`${ia}/remove/${e}/detail`,t),i4=(e,t)=>J(`${ia}/${e}/apply`,t),xi="product/v1/deleted",o4=async(e,t)=>{const r=new URLSearchParams({offset:e.toString(),items:t.toString()});return Q(`${xi}/list?${r.toString()}`).catch(n=>Promise.reject(n.response))},c4=e=>J(`${xi}/destroy`,e).catch(t=>Promise.reject(t.response)),u4=()=>J(`${xi}/deleteAll`,"").catch(e=>Promise.reject(e.response)),lD=e=>Q(`${xi}/${e}`).catch(t=>Promise.reject(t.response)),dD=(e,t,r)=>{const n=new URLSearchParams({from:t.toString(),size:r.toString()});return J(`${xi}/search?${n.toString()}`,e).catch(a=>Promise.reject(a.response))},uc="prices/v1/prices",l4="importer/v1/prices",hD=(e,t)=>Re(`${uc}/${e}`,t),pD=(e,t)=>Q(`${uc}/${e}/${t}`),fD=(e,t,r)=>ze(`${uc}/${e}/${t}`,r),d4=e=>J("prices/v1/priceList",e),h4=e=>Na("prices/v1/priceList/selection",e),gD=async(e,t)=>{const r="text/plain";return(t?jr("prices/v1/priceList/recalculateMode",e,{"Set-Authorization":`${t}`,"Content-Type":r}):J("prices/v1/priceList/recalculateMode",e,r)).then(n=>n.data).catch(n=>n.response)},mD=async(e,t)=>{const r=new pe(`
        pricesForProducts(uuids:${pe.parseParam(t)}, priceList:"${e}") {
            productUuid
            price1
            price2
            price3
            price4
            price5
            price6
            price7
            price8
            price9
            price10
            netPrice1
            netPrice2
            netPrice3
            netPrice4
            netPrice5
            netPrice6
            netPrice7
            netPrice8
            netPrice9
            netPrice10
            margin1
            margin2
            margin3
            margin4
            margin5
            margin6
            margin7
            margin8
            margin9
            margin10
            profit1
            profit2
            profit3
            profit4
            profit5
            profit6
            profit7
            profit8
            profit9
            profit10
            wholeSale1
            wholeSale2
            wholeSale3
            wholeSale4
            wholeSale5
            wholeSale6
            wholeSale7
            wholeSale8
            wholeSale9
            wholeSale10
            costByUnit
            netCostByUnit
            avgCostByUnit
            avgNetCostByUnit
            saleTaxes
            iso
        }
    `).build();return $e.post(It,r,{transformResponse:[n=>hr(n)],headers:{"Content-Type":"application/graphql"}}).then(pe.unwrap)},yD=(e,t,r=!1,n)=>$e.put(`${uc}/batch/update/${e}?netCalculation=${r}`,t,{headers:{"Content-type":"application/json;charset=UTF-8",...n&&{"Set-Authorization":n}}}),vD=(e,t,r=!1)=>Re(`${l4}/batch/update/${e}?netCalculation=${r}`,t),bD=async(e,t)=>{const r=new pe(`
        pricesForProducts(uuids:${JSON.stringify(t)}, priceList:"${e}") {
            iso    
            price1
            netPrice1
            netCostByUnit
            avgCostByUnit
            avgNetCostByUnit
        }
    `).build();return $e.post(It,r,{transformResponse:[n=>hr(n)],headers:{"Content-Type":"application/graphql"}}).then(pe.unwrap)},CD=(e,t,r)=>$e.patch(`prices/v1/priceList/${e}`,t,{headers:{"Content-Type":"application/json;charset=UTF-8",...!!r&&{"Set-Authorization":r}}}),p4=e=>new Promise(t=>{Na("prices/v1/priceList/list",e).then(r=>t(r)).catch(r=>t(r))}),f4=async()=>{const e=new pe(`
        priceLists {
            uuid
            name
            parentId
            predetermined
            recalculateMode
        }
    `).insertQuery(`
        selectionPriceList {
            priceListUuid
            branchId
      }`).build();return pn(It,e).then(pe.unwrap)},SD=e=>J("prices/v1/priceList/select",e),Rn="movement/v1/movement",ED=e=>Re(`${Rn}`,e),xD=(e,t)=>ze(`${Rn}/${e}`,t),g4=(e,t,r)=>{const n=new URLSearchParams({offset:t.toString(),size:r.toString()}).toString();return J(`${Rn}/list?${n}`,e)},m4=e=>ft(`${Rn}/${e}`),wD=e=>Q(`${Rn}/${e}`),TD=e=>J(`${Rn}/apply`,e),$D=(e,t)=>J(`${Rn}/detail/${e}/drop`,t),AD=(e,t)=>Re(`${Rn}/detail/${e}`,t),ID=e=>J(`${Rn}/detail/list`,e),ka="importer/v1",PD=async(e,t)=>$e.put(`${ka}/product`,t,{headers:{"Content-Type":"application/json;charset=UTF-8","X-Importer-Id":e}}).then(r=>r).catch(r=>{throw r}),_D=async(e,t)=>$e.put(`${ka}/product`,e,{headers:{"Content-Type":"application/json;charset=UTF-8","X-Importer-Id":t}}).then(r=>r).catch(r=>{throw r}),DD=e=>J("catalogue/v1/satCatalogue/product/exists/byKeys",e),RD=async(e,t)=>$e.put(`${ka}/stock`,e,{headers:{"Content-Type":"application/json;charset=UTF-8","X-Importer-Id":t}}).then(r=>r).catch(r=>{throw r}),ND=async(e,t,r)=>$e.put(`${ka}/prices/${e}`,t,{headers:{"Content-Type":"application/json;charset=UTF-8","X-Importer-Id":r}}).then(n=>n).catch(n=>{throw n}),BD=async()=>Q(`${ka}/product/importProgress`).then(e=>e.data),kD=e=>Re("department/v1/category/batch",e),OD=e=>Re("department/v1/department/batch",e),y4=e=>new Promise(t=>{Q(`${ka}/prices/${e}/copyProgress`).then(r=>t(r)).catch(r=>t(r))}),UD=e=>Q(`${ka}/prices/${e}/copyProgress`),v4=()=>new Promise(e=>{Q(De+"/company/list").then(t=>{e(t)}).catch(t=>{e(t)})}),b4=(e,t)=>new Promise(r=>{t?Na(`${De}/branchOffice/list?companyUuid=${e}`,t).then(n=>r(n)).catch(n=>r(n)):Q(De+"/branchOffice/list?companyUuid="+e).then(n=>r(n)).catch(n=>r(n))}),C4=e=>new Promise(t=>{e?Na(De+"/branchOffice",e).then(r=>t(r)).catch(r=>t(r)):Q(De+"/branchOffice").then(r=>t(r)).catch(r=>t(r))}),S4=()=>Q(`${De}/branchOffice/list/byCompany`),E4=e=>new Promise(t=>{J(De+"/company",e).then(r=>t(r)).catch(r=>t(r.response))}),x4=e=>new Promise(t=>{ze(De+"/company",e).then(r=>t(r)).catch(r=>t(r.response))}),w4=(e,t)=>new Promise(r=>{Re(De+"/company/logo",{uuid:e,base64Image:t}).then(n=>r(n)).catch(n=>r(n.response))}),LD=(e,t,r)=>new Promise(n=>{Re(De+"/branchOffice/banner",{uuid:e,branchOfficeId:t,base64Image:r}).then(a=>n(a)).catch(a=>n(a.response))}),MD=()=>new Promise(e=>{Q(De+"/branchOffice/banner").then(t=>e(t)).catch(t=>e(t.response))}),T4=e=>new Promise(t=>{Q(`${De}/company/isOwner?companyUuid=${e}`).then(r=>t(r)).catch(r=>t(r.response))}),$4=e=>new Promise(t=>{Re(`${De}/company/currency?iso=${e}`).then(r=>t(r)).catch(r=>t(r.response))}),A4=(e,t)=>new Promise(r=>{t?Na(`${De}/company?companyUuid=${e}`,t).then(n=>r(n)).catch(n=>r(n.response)):Q(`${De}/company?companyUuid=${e}`).then(n=>r(n)).catch(n=>r(n.response))}),jD=e=>J(`${De}/company/invite`,e),I4=e=>new Promise(t=>{Re(`${De}/company/hide`,e).then(r=>t(r)).catch(r=>t(r.response))}),P4=(e,t)=>new Promise(r=>{dE(`${De}/user/pin`,e,t).then(n=>r(n)).catch(n=>r(n.response))}),_4=e=>new Promise(t=>{Na(`${De}/user/isPinRegistered`,e).then(r=>t(r)).catch(r=>t(r.response))}),D4=e=>new Promise(t=>{J(`${De}/records/auto`,e).then(r=>t(r)).catch(r=>t(r))}),R4=()=>new Promise(e=>{Q(`${De}/records/isAllowed`).then(t=>e(t)).catch(t=>e(t))}),N4=()=>new Promise(e=>{Q(`${De}/records/list`).then(t=>e(t)).catch(t=>e(t))}),Hp=()=>new Promise(e=>{Q(De+"/user/list").then(t=>{e(t)}).catch(t=>{e(t)})}),B4=()=>new Promise(e=>{Q(De+"/userType/list?status=1").then(t=>{e(t)}).catch(t=>{e(t)})}),k4=()=>new Promise(e=>{Q(De+"/user/self").then(t=>{e(t)}).catch(t=>{})}),O4=e=>new Promise(t=>{J(De+"/userType",e).then(r=>{t(r)}).catch(r=>{t(r)})}),U4=e=>new Promise(t=>{ft(De+"/userType?userTypeUuid="+e).then(r=>{t(r)}).catch(r=>{t(r)})}),L4=e=>new Promise(t=>{ze(De+"/userType",e).then(r=>{t(r)}).catch(r=>{t(r)})}),M4=()=>new Promise(e=>{Q(De+"/role/list").then(t=>{e(t)}).catch(t=>{e(t)})}),j4=()=>new Promise(e=>{Q(De+"/action/list").then(t=>{e(t)}).catch(t=>{e(t)})}),F4=e=>new Promise(t=>{J(De+"/role",e).then(r=>{t(r)}).catch(r=>{t(r)})}),q4=e=>new Promise(t=>{ze(De+"/role",e).then(r=>{t(r)}).catch(r=>{t(r)})}),H4=e=>new Promise(t=>{ft(De+"/role?roleUuid="+e).then(r=>{t(r)}).catch(r=>{t(r)})}),K4=e=>new Promise(t=>{Q(De+"/role/permissions?roleUuid="+e).then(r=>{t(r)}).catch(r=>{t(r)})}),V4=e=>new Promise(t=>{J(De+"/user",e).then(r=>{t(r)}).catch(r=>{t(r)})}),z4=e=>new Promise(t=>{J(De+"/user/updateAccount",e).then(r=>{t(r)}).catch(r=>{t(r)})}),G4=(e,t,r)=>{let n=Xo(t,r);return n!=null&&n.address&&(Object.entries(n.address).length===0?delete n.address:(delete n.address,n={...n,address:r.address})),n!=null&&n.emails&&(Object.entries(n.emails).length===0?delete n.emails:(delete n.emails,n={...n,emails:r.emails})),n!=null&&n.phoneNumbers&&(Object.entries(n.phoneNumbers).length===0?delete n.phoneNumbers:(delete n.phoneNumbers,n={...n,phoneNumbers:r.phoneNumbers})),n={...n,uuid:e},new Promise(a=>{ze(De+"/user",n).then(s=>{s.data=n,a(s)}).catch(s=>{a(s)})})},Q4=e=>new Promise(t=>{Re(De+"/user/logo",e).then(r=>{t(r)}).catch(r=>{t(r)})}),W4=e=>new Promise(t=>{ft(De+"/user?userUuid="+e).then(r=>{t(r)}).catch(r=>{t(r)})}),Z4=()=>new Promise(e=>{Q(De+"/mailServer/list").then(t=>{e(t)}).catch(t=>{e(t.response)})}),Y4=e=>new Promise(t=>{J(De+"/mailServer",e).then(r=>{t(r)}).catch(r=>{t(r.response)})}),FD=(e,t,r)=>{let n=Xo(t,r);return n={...n,uuid:e},new Promise(a=>{ze(De+"/mailServer",n).then(s=>{s.data=n,a(s)}).catch(s=>{a(s)})})},X4=e=>new Promise(t=>{ft(De+"/mailServer?uuid="+e).then(r=>{t(r)}).catch(r=>{t(r.response)})}),J4=(e,t)=>new Promise((r,n)=>{J(De+"/mail/user?userUuid="+e,t).then(a=>{r(a)}).catch(a=>{n(a.response)})}),eA=(e,t)=>{let r="";return t&&(r="&userUuid="+t),new Promise(n=>{ft(De+"/mail?uuid="+e+r).then(a=>{n(a)}).catch(a=>{n(a.response)})})},qD=(e,t)=>{let r="";return t&&(r="&userUuid="+t),new Promise((n,a)=>{Q(De+"/mail?uuid="+e+r).then(s=>{n(s)}).catch(s=>{a(s.response)})})},HD=e=>new Promise((t,r)=>{J(De+"/mail",e).then(n=>{t(n)}).catch(n=>{r(n.response)})}),KD=e=>new Promise(t=>{Re(De+"/mail/invite",e).then(r=>{t(r)}).catch(r=>{t(r)})}),VD=()=>new Promise(e=>{Q(De+"/mail/list").then(t=>{e(t)}).catch(t=>{e(t)})}),zD=e=>{let t="";return e&&(t="?document="+e),new Promise((r,n)=>{Q(De+"/mail/predetermined"+t).then(a=>{r(a)}).catch(a=>{n(a.response)})})},GD=e=>new Promise(t=>{Q(De+"/user/isEditable?uuid="+e).then(r=>{t(r)}).catch(r=>{t(r)})}),tA=(e,t)=>new Promise(r=>{jr(`${De}/branchOffice`,e,{Authorization:t}).then(n=>r(n)).catch(n=>r(n))}),rA=e=>new Promise(t=>{e&&e!==""?Na(`${De}/branchOffice/wizardStatus`,e).then(r=>t(r)).catch(r=>t(r)):Q(`${De}/branchOffice/wizardStatus`).then(r=>t(r)).catch(r=>t(r))}),nA=e=>new Promise(t=>{Re(`${De}/branchOffice/wizardStatus?status=${e}`).then(r=>t(r)).catch(r=>t(r.response))}),QD=e=>new Promise(t=>{Re(`${De}/branchOffice/timeZone?tz=${e}`).then(r=>t(r)).catch(r=>t(r.response))}),WD=()=>new Promise(e=>{Q(`${De}/branchOffice/list/byCompany`).then(t=>e(t)).catch(t=>e(t.response))}),aA=e=>new Promise(t=>{Re(`${De}/wizard`,e).then(r=>t(r)).catch(r=>t(r))}),sA=e=>new Promise(t=>{Re(`${De}/support?minutes=${e}`).then(r=>t(r)).catch(r=>t(r.response))}),$s="product/v1/tag",iA=e=>Re($s,e),oA=(e,t)=>ze(`${$s}/${e}`,t),cA=e=>ft(`${$s}/${e}`),uA=e=>Re(`${$s}/category`,e),lA=(e,t)=>ze(`${$s}/category/${e}`,t),dA=e=>ft(`${$s}/category/${e}`),hA=async e=>pn(It,new pe().insertQuery(`
            tagList(fetchUsage:${String(!!(e!=null&&e.fetchUsage))}) {
                name
                uuid
                value
                parentId
                usageCount
                categoryId
                categoryName
            }
        `,!!(e!=null&&e.tagList)).insertQuery(`
            categoryList:tagCategoryList {
                uuid
                name
                type
            }
        `,!!(e!=null&&e.categoryList)).insertQuery(`
            product(uuid:${pe.parseParam(e==null?void 0:e.productId)}) {
                tags
            }
        `,!!e.productId).build()).then(pe.unwrap),pA=e=>pn(It,`{
        product(uuid:${pe.parseParam(e)}) {
            tags
        }
    }`).then(pe.unwrap),fA=(e,t,r)=>{let n=Xo(t,e);return n!=null&&n.address&&(Object.entries(n.address).length===0?delete n.address:(delete n.address,n={...n,address:e.address})),n!=null&&n.phoneNumbers&&(Object.entries(n.phoneNumbers).length===0?delete n.phoneNumbers:(delete n.phoneNumbers,n={...n,phoneNumbers:e.phoneNumbers})),n!=null&&n.emails&&(Object.entries(n.emails).length===0?delete n.emails:n={...n,emails:e.emails}),n={...n,id:r},new Promise(a=>{ze(De+"/branchOffice",n).then(s=>{a(s)}).catch(s=>{a(s)})})},gA=e=>new Promise(t=>{Re(De+"/branchOffice/logo",e).then(r=>{t(r)}).catch(r=>{t(r)})});var mA=(e=>(e[e.INGRESS=0]="INGRESS",e[e.EGRESS=1]="EGRESS",e[e.FREE=2]="FREE",e))(mA||{}),Hs=(e=>(e[e.ERROR=-1]="ERROR",e[e.PRODUCT=0]="PRODUCT",e[e.COMBO=1]="COMBO",e[e.PACKET=2]="PACKET",e[e.SERVICE=3]="SERVICE",e[e.SUBSCRIPTION=4]="SUBSCRIPTION",e[e.RPC=5]="RPC",e[e.PRESENTATION=6]="PRESENTATION",e[e.RPC_COMISION=7]="RPC_COMISION",e[e.CONTROLLED=8]="CONTROLLED",e[e.VARIANT=9]="VARIANT",e[e.CONFIGURABLE_PACKAGE=10]="CONFIGURABLE_PACKAGE",e))(Hs||{});const Kp={address:{city:"",inner:"",county:"",district:"",state:"",street:"",zipCode:"",lat:0,lon:0,extNumber:"",reference:""},alias:"",businessTypeName:"",countryCode:"",countryName:"",description:"",emails:[],guuid:"",id:0,isoCurrency:"",logoUrl:"",name:"",phoneNumbers:[],representative:"",timeZone:""},yA=(e,t)=>({local:{},branchOffice:Kp,getLocal:()=>t().local[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id],getMainFormat:(r=1)=>{const n=t().getLocal();if(n&&n.mainFormat)return n.mainFormat[r];const a={name:"settings.settings_documents_printingFormat_ticket",id:1};return e({local:{...t().local,[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:{...n,mainFormat:{[r]:a}}}}),a},getConfigFormatTicket(r=1){var n;const a=t().getLocal();if(a&&a!=null&&a.configFormatTicket&&(n=a==null?void 0:a.configFormatTicket)!=null&&n[r])return a.configFormatTicket[r];const s={header:"",footer:"",showLogo:!0,taxBreakdown:!0,taxCaption:!0,discount:!0,parity:!0,...r!==1&&{sellerSign:!0},...r!==4&&{clientAddress:!0},productKey:!0,...r===2&&{productImages:!0},...r===2&&{characteristics:!0},weight:!0};return e({local:{...t().local,[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:{...a,configFormatTicket:{[r]:s}}}}),s},getConfigFormatLetter(r=1){var n;const a=t().getLocal();if(a&&a.configFormatLetter&&(n=a==null?void 0:a.configFormatLetter)!=null&&n[r])return a.configFormatLetter[r];const s={header:"",footer:"",showLogo:!0,taxBreakdown:!0,taxCaption:!0,discount:!0,parity:!0,...r!==1&&{sellerSign:!0},productKey:!0,productImages:!0,characteristics:!0,weight:!0};return e({local:{...t().local,[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:{...a,configFormatLetter:{[r]:s}}}}),s},setLocal:(r,n)=>{const{id:a=0}=JSON.parse(me.getItem("auth-company-storage")).state.authCompany,s=n?Object.getPrototypeOf(n)===Object.prototype:!1;a&&e(i=>{var o,c;return{...i,local:{...i.local,[a]:{...i.local[a],[r]:s?{...((c=(o=i==null?void 0:i.local)==null?void 0:o[a])==null?void 0:c[r])||{},...n}:n==="undefined"?void 0:n==="null"?null:n}}}})},setReset:()=>e(r=>({...r,local:{...r.local,[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:{}}})),resetBranchOffice:()=>{e(r=>({...r,branchOffice:Kp}))},setBranchOffice:r=>{e(n=>({...n,branchOffice:r}))}}),vA=e=>new Promise(t=>{e.deviceAlias=e.deviceAlias.substring(0,100),J(`${we}/login/register`,e).then(r=>t(r)).catch(r=>t(r))}),bA=[],CA=[],SA=[],EA=[],xA=[],wA=[],TA=(e,t)=>({printerSettings:bA,printerSettingsBranch:CA,weighingMachine:SA,cacheSettings:EA,labelPrinterSettings:xA,labelOptions:wA,setLabelOptions:()=>{const r=[{width:"51",height:"25",labelsPerRow:1,usage:"products",options:{companyName:!0,description:!0,price:!0}},{width:"51",height:"25",labelsPerRow:1,usage:"scale",options:{companyName:!0,description:!0,price:!0}},{width:"57",height:"40",labelsPerRow:1,usage:"products",options:{companyName:!0,description:!0,price:!0}},{width:"57",height:"40",labelsPerRow:1,usage:"scale",options:{companyName:!0,description:!0,price:!0}},{width:"65",height:"11",labelsPerRow:1,usage:"products",options:{description:!0,price:!0,productKey:!0}},{width:"63",height:"22",labelsPerRow:1,usage:"products",options:{description:!0,price:!0,productKey:!0}},{width:"62",height:"29",labelsPerRow:1,usage:"products",options:{companyName:!0,description:!0,price:!0}},{width:"27",height:"13",labelsPerRow:2,usage:"products",options:{description:!0}},{width:"27",height:"13",labelsPerRow:3,usage:"products",options:{description:!0}}];e(n=>({...n,labelOptions:r}))},setPrinterSettings:(r,n)=>{const a=t().printerSettingsBranch;e(i=>({...i,printerSettings:[...i.printerSettings,{...r}]}));let s=a.findIndex(i=>i.branchId===n.branchId);s===-1?e(i=>({...i,printerSettingsBranch:[...i.printerSettingsBranch,{...n}]})):(a[s].printers.push(n.printers[0]),e(i=>({...i,printerSettingsBranch:a})))},setPrinterSettingsBranch:r=>{e(n=>({...n,printerSettingsBranch:[...n.printerSettingsBranch,r]}))},editPrinterSettings:(r,n)=>{const a=t().printerSettings,s=t().printerSettingsBranch;let i=a.findIndex(o=>o.printerName===r.printerName);if(a.splice(i,1,r),e(o=>({...o,printerSettings:a})),n){let o=s.findIndex(l=>l.branchId===n.branchId),c=s[o].printers.findIndex(l=>l.printerName===r.printerName),u=s[o].printers[s[o].printers.findIndex(l=>l.printerName===r.printerName)].printerName;s[o].printers.splice(c,1,n.printers[n.printers.findIndex(l=>l.printerName===u)]),e(l=>({...l,printerSettingsBranch:s}))}},editPrinterBranch:r=>{const n=t().printerSettingsBranch;let a=n.findIndex(s=>s.branchId===r.branchId);n.splice(a,1,r),e(s=>({...s,printerSettingsBranch:n}))},deletePrinterSettings:(r,n)=>{e(i=>({...i,printerSettings:r}));const a=t().printerSettingsBranch;let s=a.findIndex(i=>i.branchId===n.branchId);a[s].printers[0]===void 0&&(a[s].printers=[]),e(i=>({...i,printerSettingsBranch:a}))},deletePrinterSettingsBranch:r=>{const n=t().printerSettingsBranch;let a=n.findIndex(s=>s.branchId===r.branchId);n[a].printers[0]===void 0&&(n[a].printers=[]),e(s=>({...s,printerSettingsBranch:n}))},setWeighingMachineSettings:r=>{e(n=>({...n,weighingMachine:[...n.weighingMachine,{...r}]}))},editWeighingMachineSettings:r=>{const n=t().weighingMachine;let a=n.findIndex(s=>s.advanced.portCOM===r.advanced.portCOM);n.splice(a,1,r),e(s=>({...s,weighingMachine:n}))},deleteWeighingMachineSettings:r=>{e(n=>({...n,weighingMachine:r}))},setCacheSettings:r=>{const n=t().cacheSettings;let a=n.findIndex(s=>s.module===r.module);n.splice(a,1,r),e(s=>({...s,cache:n}))},setLabelPrinterSettings:r=>{e(n=>({...n,labelPrinterSettings:[...n.labelPrinterSettings,{...r}]}))},editLabelPrinterSettings:r=>{const n=t().labelPrinterSettings;let a=n.findIndex(s=>s.printerName===r.printerName);n.splice(a,1,r),e(s=>({...s,labelPrinterSettings:n}))},deleteLabelPrinterSettings:r=>{e(n=>({...n,labelPrinterSettings:r}))},updateLogoTicket:(r,n,a,s,i,o)=>{const c=t().printerSettingsBranch.slice();let u=c.findIndex(h=>h.branchId===r);const l={logoBase64:n,align:a,size:s,intensity:i,luminosity:o};let d={...c[u],logo:l};c.splice(u,1,d),e(h=>({...h,printerSettingsBranch:c}))}}),$A={isDarksMode:!1},AA=e=>({darkMode:$A,darkModeToggle:()=>{e(t=>({darkMode:{isDarksMode:!t.darkMode.isDarksMode}}))}});function Vp(e,t){return t==="TICKET"?e==="SALE"?[{field:"header",type:"STRING",maxLength:128,required:!1},{field:"footer",type:"STRING",maxLength:128,required:!1},{field:"webPage",type:"STRING",maxLength:128,required:!1},{field:"general.logo",type:"BOOL",maxLength:0,required:!0},{field:"general.discount",type:"BOOL",maxLength:0,required:!0},{field:"general.parity",type:"BOOL",maxLength:0,required:!0},{field:"client.address",type:"BOOL",maxLength:0,required:!0},{field:"product.sku",type:"BOOL",maxLength:0,required:!0}]:e==="PURCHASE"?[{field:"header",type:"STRING",maxLength:128,required:!1},{field:"footer",type:"STRING",maxLength:128,required:!1},{field:"general.logo",type:"BOOL",maxLength:0,required:!0},{field:"general.discount",type:"BOOL",maxLength:0,required:!0},{field:"general.parity",type:"BOOL",maxLength:0,required:!0},{field:"product.sku",type:"BOOL",maxLength:0,required:!0}]:e==="QUOTATION"?[{field:"header",type:"STRING",maxLength:128,required:!1},{field:"footer",type:"STRING",maxLength:128,required:!1},{field:"webPage",type:"STRING",maxLength:128,required:!1},{field:"general.logo",type:"BOOL",maxLength:0,required:!0},{field:"general.discount",type:"BOOL",maxLength:0,required:!0},{field:"general.parity",type:"BOOL",maxLength:0,required:!0},{field:"general.sellerSign",type:"BOOL",maxLength:0,required:!0},{field:"client.address",type:"BOOL",maxLength:0,required:!0},{field:"product.sku",type:"BOOL",maxLength:0,required:!0}]:{}:t==="LETTER"?e==="SALE"?[{field:"header",type:"STRING",maxLength:128,required:!1},{field:"footer",type:"STRING",maxLength:128,required:!1},{field:"webPage",type:"STRING",maxLength:128,required:!1},{field:"general.discount",type:"BOOL",maxLength:0,required:!0},{field:"general.parity",type:"BOOL",maxLength:0,required:!0},{field:"product.sku",type:"BOOL",maxLength:0,required:!0},{field:"product.image",type:"BOOL",maxLength:0,required:!0},{field:"product.characteristics",type:"BOOL",maxLength:0,required:!0}]:e==="PURCHASE"?[{field:"header",type:"STRING",maxLength:128,required:!1},{field:"footer",type:"STRING",maxLength:128,required:!1},{field:"general.taxBreakdown",type:"BOOL",maxLength:0,required:!0},{field:"general.taxLegend",type:"BOOL",maxLength:0,required:!0},{field:"general.discount",type:"BOOL",maxLength:0,required:!0},{field:"general.parity",type:"BOOL",maxLength:0,required:!0},{field:"product.sku",type:"BOOL",maxLength:0,required:!0},{field:"product.image",type:"BOOL",maxLength:0,required:!0},{field:"product.characteristics",type:"BOOL",maxLength:0,required:!0}]:e==="QUOTATION"?[{field:"header",type:"STRING",maxLength:128,required:!1},{field:"footer",type:"STRING",maxLength:128,required:!1},{field:"webPage",type:"STRING",maxLength:128,required:!1},{field:"general.discount",type:"BOOL",maxLength:0,required:!0},{field:"general.parity",type:"BOOL",maxLength:0,required:!0},{field:"general.sellerSign",type:"BOOL",maxLength:0,required:!0},{field:"product.sku",type:"BOOL",maxLength:0,required:!0},{field:"product.image",type:"BOOL",maxLength:0,required:!0},{field:"product.characteristics",type:"BOOL",maxLength:0,required:!0}]:{}:{}}function zp(e,t){return t==="TICKET"?e==="SALE"?{header:"",footer:"",webPage:"",general:{logo:!0,discount:!0,parity:!0},client:{address:!0},product:{sku:!0}}:e==="PURCHASE"?{header:"",footer:"",general:{logo:!0,discount:!0,parity:!0},product:{sku:!0}}:e==="QUOTATION"?{header:"",footer:"",webPage:"",general:{parity:!0,sellerSign:!0,logo:!0,discount:!0},product:{sku:!0},client:{address:!0}}:{}:t==="LETTER"?e==="SALE"?{header:"",footer:"",webPage:"",general:{discount:!0,parity:!0},product:{sku:!0,image:!0,characteristics:!0}}:e==="PURCHASE"?{header:"",footer:"",general:{taxBreakdown:!0,taxLegend:!0,discount:!0,parity:!0},product:{sku:!0,image:!0,characteristics:!0}}:e==="QUOTATION"?{general:{parity:!0,sellerSign:!0,logo:!0,discount:!0},product:{image:!0,characteristics:!0,sku:!0},footer:"",header:"",webPage:""}:{}:{}}const IA=(e=!0,t=!0)=>{const r=new pe(new pe(`catalog {
                    departments {
                        uuid
                        name
                        order
                        selection {
                            uuid
                            order
                        }
                    }
                    categories {
                        uuid
                        name
                        commission
                    }
                }
                units {
                    uuid
                    name
                    shortName
                    claveSat
                }
                taxes {
                    uuid 
                    automatic
                    name 
                    rate 
                    tras 
                    local
                    order 
                    type
                    claveSat
                    taxOnTax
                    taxOnTaxId
                    over {
                        uuid
                        rate
                        tras
                        name
                    }
                }
        `).build("content")).insertQuery(`
        selectedPriceList {
            uuid
            name
            predetermined
            recalculateMode
            descPrice
        }`,e).insertQuery(`
        forBranch {
            uuid
            name
            description          
            priceListUuid
        }
    `,t).insertQuery(`
        tags:tagList(fetchUsage:true) {
            name
            uuid
            value
            parentId
            usageCount
            categoryId
            categoryName
        }
    `).insertQuery(`
        tagCategoryList {
            uuid
            name
            type
        }
      `).build();return J(It,r,"application/graphql").catch(n=>Promise.reject(n.response))};var PA=Object.defineProperty,_A=(e,t,r)=>t in e?PA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Br=(e,t,r)=>_A(e,typeof t!="symbol"?t+"":t,r);class DA{constructor(){Br(this,"stack","dbcore"),Br(this,"name","BranchMiddleware"),Br(this,"create",t=>{const r=_o.getBranchId(),n=_o.getContentId();return{...t,table(a){var s;const i=t.table(a),o=(s=i.schema.indexes)==null?void 0:s.some(c=>c.keyPath===Dy.BranchId);return{...i,async query(c){const u=c.trans.mode;return(u==="readonly"||u==="r")&&a!="excel"?o?i.query(c).then(l=>{var d,h;let p={...l};return p.result=(h=(d=p.result)==null?void 0:d.filter(f=>f.branchId===r))==null?void 0:h.map(({branchId:f,...g})=>({...g})),p}):i.query(c).then(l=>{var d,h;let p={...l};return p.result=(h=(d=p.result)==null?void 0:d.filter(f=>f.contentId===n))==null?void 0:h.map(({contentId:f,...g})=>({...g})),p}):i.query(c)}}}}})}}class RA extends Ta{constructor(){super("volatile"),Br(this,"departments"),Br(this,"categories"),Br(this,"taxes"),Br(this,"units"),Br(this,"priceLists"),Br(this,"warehouses"),Br(this,"excel"),this.version(8).upgrade(async()=>{Ta.delete("volatile").then(async()=>{try{await Pr.open();try{for await(const t of Object.keys(Pr._allTables))await Pr.table(t).bulkAdd([])}catch{}}catch{}finally{window.location.reload()}})}),this.version(9).stores({departments:"++uuid, contentId, uuid, name",categories:"++uuid, contentId, uuid, name",taxes:"++uuid, contentId, uuid, name",units:"++uuid, contentId, uuid, name",priceLists:"[uuid+branchId], branchId, uuid, predetermined",warehouses:"++uuid, branchId, uuid, name",excel:"++sku, sku, description"})}}const Pr=new RA;Pr.use(new DA);const Gp={name:"",uuid:"",owner:!1,emails:[],address:{},website:[],countryCode:"",countryName:"",description:"",isoCurrency:"",phoneNumbers:[],businessTypeId:"",businessTypeName:"",logoUrl:""},NA=(e,t)=>({account:{email:null},company:Gp,rememberedUsers:[],settings:{loginConfig:[]},logoutCompanyLocal:()=>{const r=t().resetBranchOffice;r(),e(n=>({...n,account:null,company:Gp}))},setAccountLocal:r=>e(n=>({...n,account:{...n.account,...r}})),setCompanyLocal:r=>e(n=>({...n,company:r})),getRememberUsersByBranch:r=>{const n=t().rememberedUsers.filter(a=>a.branchId===r);return n.length?n[0].users:[]},setUserPinRememberedByBranch:(r,n)=>e(a=>({...a,rememberedUsers:a.rememberedUsers.map(s=>(s.branchId===r&&(s.users=s.users.map(i=>(i.email.toLocaleLowerCase()===n.toLocaleLowerCase()&&(i.hasPin=!0),i))),s))})),editRememberUserByBranch:(r,n)=>e(a=>({...a,rememberedUsers:a.rememberedUsers.map(s=>(s.branchId===r&&(s.users=s.users.map(i=>(n.accountMail&&i.email.toLocaleLowerCase()===n.accountMail.toLocaleLowerCase()&&(i.logoUrl=n.imageUrl,i.firstName=n.firstName,i.lastName=n.lastName,i.alias=n.alias),i))),s))})),removeRememberUserByBranch:(r,n)=>{t().rememberedUsers.filter(a=>a.branchId===r)[0].users.length===1?e(a=>({...a,rememberedUsers:a.rememberedUsers.filter(s=>s.branchId!==r)})):e(a=>({...a,rememberedUsers:a.rememberedUsers.map(s=>(s.branchId===r&&(s.users=s.users.filter(i=>i.email.toLowerCase()!==n.email.toLowerCase())),s))}))},removeAllRememberUserByBranch:r=>e(n=>({...n,rememberedUsers:n.rememberedUsers.filter(a=>a.branchId!==r)})),addRememberUser:async(r,n)=>{const a=t().rememberedUsers.filter(s=>s.branchId===r);a.length===0?e(s=>({...s,rememberedUsers:[...s.rememberedUsers,{branchId:r,users:[n]}]})):a.length>=1&&(a[0].users.filter(s=>s.email.toLowerCase()===n.email.toLowerCase().trim()).length>=1||e(s=>({...s,rememberedUsers:s.rememberedUsers.map(i=>(i.branchId===r&&(i.users=[...i.users,n]),i))})))},getPkForLoginPIN:async r=>vA(r).then(n=>{var a,s;return n&&n.status===200?{message:"",status:"OK",data:n.data}:{data:null,status:"ERROR",message:(s=(a=n.response)==null?void 0:a.data)!=null&&s.message?n.response.data.message:""}}),getLoginConfigByBranch:r=>{const n={enableAnchorLogin:!1,requirePin:!1,redirectTo:"/dashboard",automaticLogin:!1,publicKey:null,identifier:null},a=t().settings.loginConfig.filter(s=>s.branchId===r);return a.length?a[0].config:n},updateLoginConfig:(r,n)=>{t().settings.loginConfig.filter(a=>a.branchId===r).length?e(a=>({...a,settings:{...a.settings,loginConfig:a.settings.loginConfig.map(s=>(s.branchId===r&&(s.config=n),s))}})):e(a=>({...a,settings:{...a.settings,loginConfig:[...a.settings.loginConfig,{branchId:r,config:n}]}}))},removePkForLoginPIN:r=>e(n=>({...n,settings:{...n.settings,loginConfig:n.settings.loginConfig.map(a=>(a.branchId===r&&(a.config.publicKey=null,a.config.identifier=null),a))}}))}),Qp={companies:{added:null,list:[],branchCompanies:[],branchListByCompany:[],branchOffice:{address:{city:"",inner:"",county:"",district:"",state:"",street:"",zipCode:"",lat:0,lon:0,extNumber:"",reference:""},alias:"",businessTypeName:"",countryCode:"",countryName:"",description:"",emails:[],guuid:"",id:0,isoCurrency:"",logoUrl:"",name:"",phoneNumbers:[],representative:"",timeZone:""},usersList:[],userTypeList:[],roleList:[],roleActionList:[],rolePermissions:{uuid:"",data:[]},records:{list:[],isActiveSICARPay:!1},mailServerList:[],wizardStatus:1,skipFormCompanyWizard:!1,openSelectCompanyDialog:!1,openAddBranchDialog:!1}},BA=(e,t)=>({...Qp,addCompany:async r=>E4(r).then(n=>n&&n.status===201?(e(a=>({...a,companies:{...a.companies,list:[r,...a.companies.list]}})),{error:!1,message:"",uuid:n.data}):{error:!0,message:n.data.message,uuid:null}),editCompany:async r=>x4(r).then(n=>{if(n&&n.status===200){const a=t().companies.list.map(s=>r.uuid===s.uuid?{...s,...r}:s);return e(s=>({...s,companies:{...s.companies,list:a}})),{error:!1,message:"",uuid:n.data}}return{error:!0,message:n.data.message,uuid:null}}),addCompanyLogo:async(r,n,a,s)=>w4(r,a).then(i=>{let o=!1,c=t().companies.list,u=c;return i&&(i.status===200||i.status===204)&&(o=!0,s&&(u=c.map(l=>(s.uuid===l.uuid&&(l.logoUrl=n),l)))),e(l=>({...l,companies:{...l.companies,list:u}})),o}),getCompany:async(r,n)=>A4(r,n).then(a=>a&&a.status===200?a.data:null),getCompanies:async r=>v4().then(n=>n&&n.status===200?(e(a=>({...a,companies:{...a.companies,list:n.data}})),r?n.data:!0):!1),resetBranchList:async()=>e(r=>({...r,companies:{...r.companies,branchCompanies:[]}})),getBranchCompanies:async(r,n,a)=>b4(r,a).then(s=>s.status===200?(n===void 0&&e(i=>({...i,companies:{...i.companies,branchCompanies:s.data}})),s.data):null),getRoleList:async()=>M4().then(r=>r.status===200?(e(n=>({...n,companies:{...n.companies,roleList:r.data}})),!0):(console.log("request",r),!1)),setRoleList:async r=>{e(n=>({...n,companies:{...n.companies,roleList:[...r]}}))},getRoleActionList:async()=>j4().then(r=>r.status===200?(e(n=>({...n,companies:{...n.companies,roleActionList:r.data}})),!0):(console.log("request",r),!1)),setRoleActionList:async r=>{e(n=>({...n,companies:{...n.companies,roleActionList:[...r]}}))},getRolePermissions:async r=>K4(r).then(n=>{if(n.status===200){let a={uuid:r,data:n.data};return e(s=>({...s,companies:{...s.companies,rolePermissions:a}})),{code:!0,data:a}}else return console.log("request",n),{code:!1,data:null}}),createRole:async r=>F4(r).then(n=>{if(n.status===201){let a=t().companies.roleList;const s={uuid:n.data,name:r.name,admin:!1};return a.push(s),e(i=>({...i,companies:{...i.companies,roleList:a}})),{status:!0,message:"Ok"}}else return console.log("request",n),{status:!1,message:n.response.data.message}}),editRole:async r=>q4(r).then(n=>{if(n.status===200){let a=t().companies.roleList;const s=a.findIndex(o=>o.uuid===r.uuid);let i=a[s];return i.name=r.name,a.splice(s,1,i),e(o=>({...o,companies:{...o.companies,roleList:a}})),{status:!0,message:"Ok"}}else return console.log("request",n),{status:!1,message:n.response.data.message}}),deleteRole:async r=>H4(r).then(n=>{if(n.status===200){let a=t().companies.roleList;const s=a.findIndex(i=>i.uuid===r);return a.splice(s,1),e(i=>({...i,companies:{...i.companies,roleList:[...a]}})),{status:!0,message:"Ok"}}else return console.log("request",n),{status:!1,message:n.response.data.message}}),getUserTypeList:async()=>B4().then(r=>r.status===200?(e(n=>({...n,companies:{...n.companies,userTypeList:r.data}})),!0):(console.log("request",r),!1)),setUserTypeList:async r=>{e(n=>({...n,companies:{...n.companies,userTypeList:r}}))},createUserType:async r=>O4(r).then(n=>{if(n.status===201){let a=t().companies.userTypeList;const s=n.data;return a.push(s),e(i=>({...i,companies:{...i.companies,userTypeList:a}})),{status:!0}}else return console.log("request",n),{status:!1,code:n.response.data.code,message:n.response.data.message}}),editUserType:async r=>L4(r).then(n=>{if(n.status===200){let a=t().companies.userTypeList;const s=a.findIndex(o=>o.uuid===r.uuid);let i=a[s];return i.name=r.name,a.splice(s,1,i),e(o=>({...o,companies:{...o.companies,userTypeList:a}})),{status:!0}}else return{status:!1,code:n.response.data.code,message:n.response.data.message}}),deleteUserType:async r=>U4(r).then(n=>{if(n.status===200){let a=t().companies.userTypeList;const s=a.findIndex(i=>i.uuid===r);return a.splice(s,1),e(i=>({...i,companies:{...i.companies,userTypeList:[...a]}})),!0}else return console.log("request",n),!1}),getBranchOffice:async r=>C4(r).then(n=>n&&n.status===200?(e(a=>({...a,companies:{...a.companies,branchOffice:n.data}})),!0):!1),addBranchOffice:async(r,n)=>tA(r,n).then(async a=>{if(a&&a.status===201){const s=await t().getBranchCompanies(r.companyUuid),i=a.headers.get("pricelist"),o=s==null?void 0:s.filter(u=>u.id==a.data);let c=null;return o!=null&&o.length&&(c=o[0]),{error:!1,branchOffice:c,priceListUuid:i,message:""}}return{error:!0,branchOffice:null,priceListUuid:null,message:a&&a.response?a.response.data.message:"validation_errorOccurred"}}),editBranchOffice:async(r,n,a)=>fA(r,n,a).then(s=>s&&s.status===200?(e(i=>({...i,companies:{...i.companies,branchOffice:{...i.companies.branchOffice,...r}}})),{error:!1,code:-1,message:""}):{error:!0,code:s?s.response.data.code:-1,message:s?s.response.data.message:"validation_errorOccurred"}),updateLogoBranch:async r=>gA(r).then(n=>{if(n.status===200){console.log(n);let a=t().companies.branchOffice;return a.logoUrl=n.data,e(s=>({...s,companies:{...s.companies,branchOffice:{...a}}})),!0}else if(n.status===204){console.log(n);let a=t().companies.branchOffice;return a.logoUrl="",e(s=>({...s,companies:{...s.companies,branchOffice:{...a}}})),!0}else return console.log("request",n),!1}),addAfiliation:async r=>D4(r).then(n=>n&&n.status===201?{error:!1,message:""}:{error:!0,message:n?n.response.data.message:"Operación fallida"}),getUserList:async()=>Hp().then(r=>r.status===200?(e(n=>({...n,companies:{...n.companies,usersList:r.data}})),!0):(console.log("request",r),!1)),getUserSelected:async r=>{e(n=>({...n,companies:{...n.companies,userSelected:r?{...r}:void 0}}))},setUserSelected:async r=>{e(n=>({...n,companies:{...n.companies,userSelected:r?{...r}:void 0}}))},setUserList:async r=>{e(n=>({...n,companies:{...n.companies,usersList:[...r]}}))},createUser:async r=>V4(r).then(n=>n.status===201?(Hp().then(a=>{if(a.status===200){let s=a.data.find(i=>i.uuid===n.data);e(i=>({...i,companies:{...i.companies,usersList:a.data}})),e(i=>({...i,companies:{...i.companies,userSelected:s}}))}else return console.log("request",a),{status:!1}}),{status:!0}):n.response.status===409?{status:!1,message:n.response.data.message,code:n.response.data.code}:(console.log("request",n),{status:!1,message:n.response.data.message,code:n.response.data.code})),updateAccount:async r=>z4(r).then(n=>{if(n.status===200){let a=t().companies.usersList,s=a.find(o=>o.uuid===r.userUuid);const i=a.findIndex(o=>o.uuid===r.userUuid);return s!==void 0&&(s.accountMail=r.accountMail,s.accountUuid=r.accountUuid,a.splice(i,1,s),e(o=>({...o,companies:{...o.companies,usersList:[...a]}})),e(o=>({...o,companies:{...o.companies,userSelected:{...s}}}))),{status:!0}}else return n.response.status===409?{status:!1,message:n.response.data.message,code:n.response.data.code}:(console.log("request",n),{status:!1,message:n.response.data.message,code:n.response.data.code})}),editUser:async(r,n,a,s,i)=>G4(r,n,a).then(o=>{if(o.status===200){let c=t().companies.userSelected,u=t().companies.usersList;Object.keys(o.data).map(d=>{d!=="uuid"&&c!==void 0&&(delete c[d],c={...c,[d]:o.data[d]})}),c={...c,roleName:s},c={...c,userTypeName:i};const l=u.findIndex(d=>d.uuid===o.data.uuid);return u.splice(l,1,c),e(d=>({...d,companies:{...d.companies,usersList:[...u]}})),e(d=>({...d,companies:{...d.companies,userSelected:{...c}}})),{status:!0}}else return o.response.status===409?{status:!1,message:o.response.data.message,code:o.response.data.code}:(console.log("request",o),{status:!1,message:o.response.data.message,code:o.response.data.code})}),updateUserLogo:async r=>Q4(r).then(n=>{if(n.status===200||n.status===204){let a=t().companies.userSelected,s=t().companies.usersList;if(a!==void 0){a.imageUrl=n.data;const i=s.findIndex(c=>c.uuid===(a==null?void 0:a.uuid));let o=s[i];o.imageUrl=n.data,s.splice(i,1,o),e(c=>({...c,companies:{...c.companies,userSelected:{...a}}})),e(c=>({...c,companies:{...c.companies,usersList:[...s]}}))}return!0}else return console.log("request",n),!1}),deleteUser:async r=>W4(r).then(n=>{if(n.status===200){let a=t().companies.usersList;const s=a.findIndex(i=>i.uuid===r);return a.splice(s,1),e(i=>({...i,companies:{...i.companies,usersList:[...a]}})),e(i=>({...i,companies:{...i.companies,userSelected:void 0}})),!0}else return console.log("request",n),!1}),getIsActiveSicarPay:async()=>R4().then(r=>r&&r.status===200?(e(n=>({...n,companies:{...n.companies,records:{...n.companies.records,isActiveSICARPay:r.data}}})),!0):!1),getAfiliations:async()=>N4().then(r=>r&&r.status===200?(e(n=>({...n,companies:{...n.companies,records:{...n.companies.records,list:r.data}}})),!0):!1),getMailServerList:async()=>Z4().then(r=>r.status===200?(e(n=>({...n,companies:{...n.companies,mailServerList:[...r.data]}})),!0):(console.log("request",r),!1)),createMailServer:async r=>Y4(r).then(n=>n.status===201?(t().companies.mailServerList.push(r),e(a=>({...a,companies:{...a.companies,mailServerList:n.data}})),{status:!0}):n.status===409?{status:!1,message:n.data.message,code:n.data.code}:(console.log("request",n),{status:!1,message:n.data.message,code:n.data.code})),deleteMailServer:async r=>X4(r).then(n=>{if(n.status===200){let a=t().companies.mailServerList;const s=a.findIndex(i=>i.uuid===r);return a.splice(s,1),e(i=>({...i,companies:{...i.companies,mailServerList:[...a]}})),!0}else return console.log("request",n),!1}),createSenderMail:async(r,n)=>J4(r,n).then(a=>{if(a.status===201){let s=t().companies.userSelected,i=t().companies.usersList;if(s!==void 0){s.senderMailUuid=a.data,s.senderMail=n.email;const o=i.findIndex(u=>u.uuid===(s==null?void 0:s.uuid));let c=i[o];c.senderMailUuid=n.uuid,c.senderMail=n.email,i.splice(o,1,c),e(u=>({...u,companies:{...u.companies,userSelected:{...s}}})),e(u=>({...u,companies:{...u.companies,usersList:[...i]}}))}return!0}else return console.log("request",a),!1}),deleteSenderMail:async(r,n)=>eA(r,n).then(a=>{if(a.status===200){let s=t().companies.userSelected,i=t().companies.usersList;if(s!==void 0){s.senderMailUuid="",s.senderMail="";const o=i.findIndex(u=>u.uuid===(s==null?void 0:s.uuid));let c=i[o];c.senderMailUuid="",c.senderMail="",i.splice(o,1,c),e(u=>({...u,companies:{...u.companies,userSelected:{...s}}})),e(u=>({...u,companies:{...u.companies,usersList:[...i]}}))}return{status:!0}}else return console.log("request",a),{status:!1,message:a.data.message,code:a.data.code}}),getWizardStatus:async r=>rA(r).then(async n=>n&&n.status===200?(n.data==1&&await t().setWizardStatus(2),e(a=>({...a,companies:{...a.companies,wizardStatus:n.data==1?2:n.data}})),n.data):0),setWizardStatus:async r=>nA(r).then(n=>n&&n.status===200?(e(a=>({...a,companies:{...a.companies,wizardStatus:r}})),!0):!1),configureWizard:async(r,n)=>aA(r).then(async a=>{if(a&&a.status===200){const s=t().setWizardStatus;return await s(n),!0}else return!1}),updateCompanyMainCurrency:async r=>$4(r).then(n=>n&&n.status===200?(e(a=>({...a,companies:{...a.companies,branchOffice:{...a.companies.branchOffice,isoCurrency:r}}})),!0):!1),setBranchOffice:async r=>e(n=>({...n,companies:{...n.companies,branchOffice:r}})),resetCompanies:()=>e(Qp),setCompanyAdded:r=>e(n=>({...n,companies:{...n.companies,added:r}})),setOpenSelectCompanyDialog:r=>e(n=>({...n,companies:{...n.companies,openSelectCompanyDialog:r}})),setOpenAddBranchDialog:r=>e(n=>({...n,companies:{...n.companies,openAddBranchDialog:r}})),setSkipFormCompanyWizard:r=>e(n=>({...n,companies:{...n.companies,skipFormCompanyWizard:r}})),createSupportAccess:async r=>sA(r).then(n=>!!(n&&n.status===201)),getBranchListByCompany:async()=>S4().then(r=>(e(n=>{var a;return{...n,companies:{...n.companies,branchListByCompany:r.status===204?[]:(a=r==null?void 0:r.data)==null?void 0:a.map(s=>({...s,id:s==null?void 0:s.branchId}))}}}),r)),hideBranchOffice:async r=>I4(r).then(n=>!!(n&&n.status===200)),createPIN:async(r,n)=>P4(r,n).then(a=>!!(a&&a.status===200)),isPinRegistered:async r=>_4(r).then(n=>n&&n.status===200?n.data:!1)}),$a=Ae()(Be(Oe((...e)=>({...BA(...e)}),{name:"companies-storage",getStorage:()=>me}),{name:"companies-storage",enabled:!1,anonymousActionType:"zustand"})),an=Ae(Be(Oe((...e)=>({...yA(...e),...NA(...e),...TA(...e),...AA(...e)}),{name:"storage",getStorage:()=>Cr}),{name:"local-storage",enabled:!1,anonymousActionType:"zustand"})),kA=(...e)=>({...OA(...e),...UA(...e),...jA(...e),...LA(...e),...MA(...e),...FA(...e),...qA(...e),...HA(...e),...KA(...e),...VA(...e),...zA(...e)}),wu={productDetail:null,suggested:null,selectedList:[],multiSelect:!1,openSelect:!1,selectAll:!1,selectBySearch:!1,countProducts:0,productList:{list:[],offset:void 0},search:{list:[],from:1,hasMore:!1,filter:{},total:0,filterView:[]}},OA=(e,t)=>({product:wu,setProduct(r){e(n=>({...n,product:{...n.product,...r}}))},getProductList:async(r,n,a)=>new Promise((s,i)=>{var o,c,u,l,d;const h=(c=(o=Ht.getState().prices)==null?void 0:o.priceList)==null?void 0:c.uuid,p=(d=(l=(u=an.getState())==null?void 0:u.getLocal())==null?void 0:l.warehouse)==null?void 0:d.uuid;_l({items:n,offset:r,priceListId:h,creationOrder:2,warehouse:p,stock:!0}).then(f=>{f.status===200?(e(g=>({...g,product:{...g.product,...a&&g.product.multiSelect&&{selectedList:Array.from(new Set([...g.product.selectedList,...f.data.map(y=>y.uuid)]))},productList:{...g.product.productList,list:a?[...g.product.productList.list,...f.data]:f.data,offset:f==null?void 0:f.headers["content-range"]}}})),s(f)):f.status===204?(e(g=>({...g,product:{...g.product,productList:{...g.product.productList,...!a&&{list:[]},offset:void 0}}})),s(f)):i()}).catch(f=>{e(g=>({...g,product:{...g.product,productList:{...g.product.productList,...!a&&{list:[]},offset:void 0}}})),i(f)})}),getProductDetail:async(r,n,a,s)=>new Promise((i,o)=>{var c,u;const l=(u=(c=an==null?void 0:an.getState())==null?void 0:c.getLocal())==null?void 0:u.warehouse;K$(r,n,l==null?void 0:l.uuid,a,s).then(({status:d,data:h})=>{var p,f;const g=h;let y=g.data;if(d===200)if((p=Object==null?void 0:Object.values(y))!=null&&p.every(b=>b==null))Tu(e,t).cleanProduct(r,(f=g==null?void 0:g.errors)==null?void 0:f.some(b=>{var m,v;return((m=b==null?void 0:b.extensions)==null?void 0:m.responseCode)===404&&((v=b==null?void 0:b.path)==null?void 0:v.includes("product"))})),o(g==null?void 0:g.errors);else{if((y==null?void 0:y.product)!=null)try{e(b=>({...b,product:{...b.product,productDetail:y}}))}catch{}i(y)}else o(g==null?void 0:g.errors)}).catch(o)}),getProductSuggested:async r=>new Promise((n,a)=>{Iy(r).then(async s=>{if(s.status===200){let i=s.data;const o=await Py(s.data.id);o.status===200&&(i.images=o.data),e(c=>({...c,product:{...c.product,suggested:i}})),n()}}).catch(a)}),searchProduct:async(r,n=1,a=40,s=!1)=>new Promise((i,o)=>{var c,u,l,d,h;if((c=Object.values(r))!=null&&c.some(p=>p!=null)){const p=(u=Ht.getState().prices.priceList)==null?void 0:u.uuid,f=(h=(d=(l=an.getState())==null?void 0:l.getLocal())==null?void 0:d.warehouse)==null?void 0:h.uuid;if(r.stock!=null){const g=n===1?null:String(n),y={...r};y.stock===2?(y.maximumStock=1e-6,y.stock=!0):y.stock===3?(y.maximumStock=0,y.stock=2):(y.minimumStock=0,y.stock=!0),_l({items:a,offset:g,creationOrder:2,priceListId:p,warehouse:f,...y}).then(b=>{e(m=>{var v,S;return{...m,product:{...m.product,search:{...m.product.search,hasMore:!!((v=b==null?void 0:b.headers)!=null&&v["content-range"]),filter:r,from:((S=b==null?void 0:b.headers)==null?void 0:S["content-range"])||0,list:b.status===200?s?[...m.product.search.list,...b==null?void 0:b.data]:b.data:s?m.product.search.list:[]}}}}),i(b)}).catch(o)}else{const g=(n-1)*a;V$({...r,priceListId:p,stock:!0,warehouse:f},g,a).then(y=>{e(b=>{var m,v;return{...b,product:{...b.product,...!b.product.countProducts&&{countProducts:Number(y.headers["x-total-hints"]||0)},...b.product.selectAll&&{selectedList:Array.from(new Set([...b.product.selectedList,...y.status===200?(m=y==null?void 0:y.data)==null?void 0:m.map(S=>S.uuid):[]]))},search:{...b.product.search,hasMore:!!((v=y==null?void 0:y.data)!=null&&v[a-1]),filter:r,from:y.status==200?n+1:1,list:y.status===200?s?[...b.product.search.list,...y.data]:y.data:s?b.product.search.list:[]}}}}),i(y)}).catch(y=>o(y))}}else e(p=>({...p,product:{...p.product,search:{...p.product.search,hasMore:!1,list:[],from:1,filter:r}}})),i(void 0)}),deleteProduct:async r=>new Promise((n,a)=>{q$(r).then(s=>{s.status===200?(Tu(e,t).cleanProduct(r),n(!0)):a(!1)}).catch(s=>{var i;((i=s==null?void 0:s.response)==null?void 0:i.status)===404&&Tu(e,t).cleanProduct(r),a(s)})}),deleteProductsByUuids:async r=>new Promise((n,a)=>{z$(r).then(({status:s,data:i})=>{var o,c,u,l,d,h,p,f;s===204&&(i=[]);const g=r==null?void 0:r.filter(y=>!(i!=null&&i.find(b=>b===y)));if(g!=null&&g.length){const y=(l=(u=(c=(o=t())==null?void 0:o.product)==null?void 0:c.productList)==null?void 0:u.list)==null?void 0:l.filter(m=>!(g!=null&&g.find(v=>v===(m==null?void 0:m.uuid)))),b=(f=(p=(h=(d=t())==null?void 0:d.product)==null?void 0:h.search)==null?void 0:p.list)==null?void 0:f.filter(m=>!(g!=null&&g.find(v=>v===(m==null?void 0:m.uuid))));e(m=>({...m,product:{...m.product,productList:{...m.product.productList,list:y,...(g==null?void 0:g.length)===20&&!(i!=null&&i.length)&&{offset:"0"}},search:{...m.product.search,list:b},productDetail:g!=null&&g.find(v=>{var S,C,E;return v===((E=(C=(S=m==null?void 0:m.product)==null?void 0:S.productDetail)==null?void 0:C.product)==null?void 0:E.uuid)})?null:m.product.productDetail,selectedList:i}}))}n(i)}).catch(s=>a(s))}),resetProduct:(r=!0)=>{r&&e(n=>({...n,product:wu}))},resetProductSlice:()=>e({product:wu})}),Wp={departmentFull:{departments:[],categories:[]}},UA=(e,t)=>({...Wp,setDepartmentFull(r){e(n=>({...n,departmentFull:{...n.departmentFull,...r}}))},getDepartmentFull:async()=>new Promise((r,n)=>{A$().then(a=>{a.status===200?(e(s=>{var i,o,c,u;return{...s,departmentFull:{departments:((o=(i=a==null?void 0:a.data)==null?void 0:i.catalog)==null?void 0:o.departments)||[],categories:((u=(c=a==null?void 0:a.data)==null?void 0:c.catalog)==null?void 0:u.categories)||[]}}}),r()):n()}).catch(a=>{n(a)})}),createDepartment:async r=>new Promise((n,a)=>{I$(r).then(async s=>{s.status===201?(await t().getDepartmentFull(),n(s)):a(s)}).catch(s=>a(s))}),createCategory:async r=>new Promise((n,a)=>{D$(r).then(async s=>{s.status===201?(await t().getDepartmentFull(),n(s)):a(s)}).catch(s=>a(s))}),editDepartment:async r=>new Promise((n,a)=>{P$(r).then(async s=>{s.status===200?(await t().getDepartmentFull(),n(s)):a()}).catch(a)}),editCategory:async r=>new Promise((n,a)=>{R$(r).then(async s=>{s.status===200?(await t().getDepartmentFull(),n(s)):a()}).catch(a)}),deleteDepartment:async r=>new Promise((n,a)=>{_$(r).then(async s=>{s.status===200?(await t().getDepartmentFull(),n(s)):a()}).catch(s=>a(s))}),deleteCategory:async r=>new Promise((n,a)=>{N$(r).then(s=>{s.status===200?(t().getDepartmentFull(),n(s)):a()}).catch(s=>a(s))}),resetProductDepartmentFull:()=>e(Wp)}),Zp={taxes:[]},LA=(e,t)=>({...Zp,setTaxes(r){e(n=>({...n,taxes:r}))},getTaxes:async()=>new Promise((r,n)=>{B$().then(a=>{e(s=>{var i,o;return{...s,taxes:((o=(i=a==null?void 0:a.data)==null?void 0:i.content)==null?void 0:o.taxes)||[]}}),r(a)}).catch(a=>{n(a)})}),createTax:async r=>new Promise((n,a)=>{k$(r).then(async s=>{s.status===201?(await t().getTaxes(),n(s)):a()}).catch(a)}),editTax:async(r,n,a)=>new Promise((s,i)=>{O$(r,n,a).then(async o=>{o.status===200?(await t().getTaxes(),s(o)):i()}).catch(i)}),deleteTax:async r=>new Promise((n,a)=>{U$(r).then(async s=>{s.status===200?(await t().getTaxes(),n(s)):a()}).catch(a)}),resetProductTax:()=>e(Zp)}),Yp={units:[]},MA=(e,t)=>({...Yp,setUnits(r){e(n=>({...n,units:r}))},getUnits:async()=>new Promise((r,n)=>{L$().then(a=>{e(s=>{var i,o;return{...s,units:((o=(i=a==null?void 0:a.data)==null?void 0:i.content)==null?void 0:o.units)||[]}}),r(a)}).catch(a=>{n(a)})}),createUnit:async r=>new Promise((n,a)=>{M$(r).then(async s=>{s.status===201?(await t().getUnits(),n(s)):a()}).catch(a)}),deleteUnit:async r=>new Promise((n,a)=>{F$(r).then(async s=>{s.status===200?(await t().getUnits(),n(s)):a()}).catch(a)}),editUnit:async(r,n)=>new Promise((a,s)=>{j$(r,n).then(async i=>{i.status===200?(await t().getUnits(),a(i)):s()}).catch(s)}),resetProductUnits:()=>e(Yp)}),Xp={stock:{warehouseList:[],stockInfo:null}},jA=e=>({...Xp,setStock(t){e(r=>({...r,stock:{...r.stock,...t}}))},getWarehouseList:async()=>X$().then(({status:t,data:r})=>(e(n=>({...n,stock:{...n.stock,warehouseList:t===200?r:[]}})),t===200)).catch(t=>!1),getStockInfo:async(t,r)=>_y(t,r).then(n=>{n.status===200&&e(a=>({...a,stock:{...a.stock,stockInfo:n.data}}))}).catch(n=>{}),createStock:async(t,r,n)=>new Promise((a,s)=>{Z$(t,r,n).then(i=>{i.status===201?(e(o=>({...o,stock:{...o.stock,stockInfo:{maxStock:n.max,minStock:n.min,stock:i.data}}})),a(i)):s()}).catch(i=>s(i))}),editStock:async(t,r,n)=>new Promise((a,s)=>{Y$(t,r,n).then(i=>{i.status===200?(e(o=>({...o,stock:{...o.stock,stockInfo:{maxStock:n.max,minStock:n.min,stock:i.data}}})),a(i)):s()}).catch(i=>s(i))}),resetProductStock:()=>e(Xp)}),Jp={importDocument:{status:0,documentUuid:"",fileName:"",detailList:[],searchDetailList:[]}},FA=(e,t)=>({...Jp,setImportDocument(r){e(n=>({...n,importDocument:{...n.importDocument,...r}}))},getProductDocument:async()=>{var r;const n=(r=t().importDocument)==null?void 0:r.documentUuid;return new Promise((a,s)=>{e4(n).then(i=>{i.status==200?(e(o=>({...o,importDocument:{...o.importDocument,status:i.data.status}})),a(i.data.status)):s()}).catch(s)})},getProductDocumentDetail:async(r="0",n=!1)=>{var a;const s=(a=t().importDocument)==null?void 0:a.documentUuid;return new Promise((i,o)=>{qp(s,"",r).then(c=>{c.status===200?(e(u=>({...u,importDocument:{...u.importDocument,detailList:n?[...u.importDocument.detailList,...c.data]:c.data}})),i(c.data)):o()}).catch(o)})},searchProductDocumentDetail:async r=>{var n;const a=(n=t().importDocument)==null?void 0:n.documentUuid;return new Promise((s,i)=>{qp(a,r).then(o=>{o.status===200?(e(c=>({...c,importDocument:{...c.importDocument,searchDetailList:o.data}})),s(o.data)):o.status===204&&e(c=>({...c,importDocument:{...c.importDocument,searchDetailList:[]}})),i()}).catch(i)})},applyDocument:async r=>{var n;const a=(n=t().importDocument)==null?void 0:n.documentUuid;return new Promise((s,i)=>{i4(a,r).then(o=>{var c,u;if(o.status===200){const l=(u=(c=t().importDocument)==null?void 0:c.detailList)==null?void 0:u.filter(d=>!(r!=null&&r.find(h=>h===d.sku)));e(d=>({...d,importDocument:{...d.importDocument,detailList:l}})),s()}else i()}).catch(i)})},categoryDocumentBatch:async r=>{var n;const a=(n=t().importDocument)==null?void 0:n.documentUuid;return new Promise((s,i)=>{n4(a,r).then(o=>{o.status===200?s():i()}).catch(i)})},departmentDocumentBatch:async r=>{var n;const a=(n=t().importDocument)==null?void 0:n.documentUuid;return new Promise((s,i)=>{a4(a,r).then(o=>{o.status===200?s():i()}).catch(i)})},removeDocumentBatch:async r=>{var n;const a=(n=t().importDocument)==null?void 0:n.documentUuid;return new Promise((s,i)=>{s4(a,r).then(o=>{o.status===200?s():i()}).catch(i)})},resetProductDocument:()=>e(Jp)}),ef={productsDeleted:{productList:[]}},qA=(e,t)=>({...ef,getProductsDeleted:async(r,n)=>o4(r||0,n||20).then(a=>(e(s=>({...s,productsDeleted:{...s.productsDeleted,productList:a.status===200||a.status===204&&Number(r)>0?Number(r)>0?[...s.productsDeleted.productList,...a.data]:a.data:[]}})),a==null?void 0:a.data)),deleteProductsPermanently:async r=>new Promise((n,a)=>{c4(r).then(s=>{var i;if(s.status===200){const o=(i=t().productsDeleted.productList)==null?void 0:i.filter(c=>!(r!=null&&r.find(u=>u===c.uuid)));e(c=>({...c,productsDeleted:{...c.productsDeleted,productList:o}})),n()}else a()}).catch(a)}),deleteProductsAll:async()=>new Promise((r,n)=>{u4().then(a=>{a.status===200?(e(s=>({...s,productsDeleted:{productList:[]}})),r()):n()}).catch(n)}),resetProductDelete:()=>e(ef)}),tf={inventory:{operationList:[],productList:[],productAux:null,adjustList:{departmentList:[],categoryList:[]},adjustOperationList:[],document:null,documentHold:{documentList:[],filter:{initialDate:"",endDate:"",branchId:""}},backupMixedList:[]}},HA=(e,t)=>({...tf,setInventory(r){e(n=>({...n,inventory:{...n.inventory,...r}}))},getProductListWithStock:async(r,n,a)=>new Promise((s,i)=>{var o,c;const u=(c=(o=Ht.getState().prices)==null?void 0:o.priceList)==null?void 0:c.uuid;_l({items:20,stock:!0,types:[Hs.PRODUCT,Hs.CONTROLLED],creationOrder:2,priceListId:u,...!!r&&{warehouse:r},...!!(n!=null&&n.length)&&{offset:n},...!!a&&{minimumStock:a}}).then(l=>{l.status===200?(e(d=>({...d,inventory:{...d.inventory,productList:Number(n)>0?[...d.inventory.productList,...l.data]:l.data}})),s((l==null?void 0:l.headers["content-range"])??"")):l.status===204?s(""):i()}).catch(i)}),getProductAux:(r,n,a,s)=>new Promise((i,o)=>{H$(r).then(async c=>{var u,l,d,h;if(c.status===200){const p=c.data.type;if(Array.of(Hs.PRODUCT,Hs.CONTROLLED).includes(p)){const f=c.data,g=t().inventory.operationList;if((d=(l=(u=c==null?void 0:c.data)==null?void 0:u.skus)==null?void 0:l.some)!=null&&d.call(l,y=>(y==null?void 0:y.toLowerCase())==(r==null?void 0:r.toLowerCase()))&&g!=null&&g.some(y=>{var b;return y.sku===((b=c==null?void 0:c.data)==null?void 0:b.sku)}))return i(c);if(await _y(c.data.uuid,n).then(({data:y})=>{f.stock=y.stock}).catch(()=>{}),f.lot){const{data:y}=await J$(f.uuid,n);f.lots=y}!(s!=null&&s.substract&&Number((f==null?void 0:f.stock)||0)<1e-6)&&!(s!=null&&s.adjust&&f!=null&&f.lot&&((h=f==null?void 0:f.lots)==null?void 0:h.length)>50)&&(f.amount=1,s!=null&&s.isDocument&&(f.new=!0),e(y=>({...y,inventory:{...y.inventory,...a?{operationList:[...y.inventory.operationList,f]}:{productAux:f}}})))}i(c)}else o()}).catch(o)}),getProductDocumentHoldList:r=>new Promise((n,a)=>{g4(r,0,30).then(s=>{e(i=>({...i,inventory:{...i.inventory,documentHold:{...i.inventory.documentHold,documentList:s.status===200?s.data:[],filter:r}}})),n(s)}).catch(a)}),createProductDocumentHold:(r,n,a)=>new Promise((s,i)=>{t4(n).then(async o=>{o.status===201?await r4(r,a).then(async c=>{c.status==201?s(c):i()}):i()}).catch(i)}),deleteProductDocumentHold:r=>new Promise((n,a)=>{const s=t().inventory.documentHold.filter;m4(r).then(async i=>{i.status===200?(s!=null&&await t().getProductDocumentHoldList(s),n(i)):a()}).catch(async i=>{var o;((o=i==null?void 0:i.response)==null?void 0:o.status)===404&&s!=null&&await t().getProductDocumentHoldList(s),a(i)})}),resetProductInventory:()=>e(tf)}),rf={inventoryQueries:{list:[],offset:1,filters:void 0,back:!1,filtersView:[],totalFilters:0}},KA=e=>({...rf,setInventoryQueries(t){e(r=>({...r,inventoryQueries:{...r.inventoryQueries,...t}}))},resetProductInventoryQueries:()=>e(rf)}),Tu=(e,t)=>({cleanProduct(r,n=!0){var a,s,i,o,c,u,l;if(n){const d=(o=(i=(s=(a=t())==null?void 0:a.product)==null?void 0:s.productList)==null?void 0:i.list)==null?void 0:o.filter(f=>f.uuid!=r),h=(u=(c=t().product)==null?void 0:c.search.list)==null?void 0:u.filter(f=>f.uuid!=r),p=(l=t().product)==null?void 0:l.selectedList.filter(f=>f!=r);e(f=>{var g,y;return{...f,product:{...f.product,selectedList:p,productList:{...(g=f.product)==null?void 0:g.productList,list:d},productDetail:null,search:{...(y=f==null?void 0:f.product)==null?void 0:y.search,list:h}}}})}else e(d=>({...d,product:{...d.product,productDetail:null}}))}}),nf={prices:{branchesPriceList:[],priceList:null,priceListSelection:{priceLists:[],selectionPriceList:[]}}},VA=e=>({...nf,setPriceList(t){e(r=>({...r,prices:{...r.prices,priceList:t}}))},getBranchesPriceList:async t=>h4(t).then(r=>r&&(r.status===200||r.status===204)?(e(n=>({...n,prices:{...n.prices,branchesPriceList:r.data}})),r.data):null),getPriceList:async t=>p4(t).then(r=>r&&(r.status===200||r.status===204)?r.data:null),getPriceListWithSelection:async()=>f4().then(t=>(e(r=>{var n,a;return{...r,prices:{...r.prices,priceListSelection:{priceLists:((n=t==null?void 0:t.data)==null?void 0:n.priceLists)||[],selectionPriceList:((a=t==null?void 0:t.data)==null?void 0:a.selectionPriceList)||[]}}}}),t)).catch(t=>t),resetPricesSlice:()=>{e(nf)}}),zA=()=>({getCopyProgress:async e=>y4(e).then(t=>t&&(t.status===200||t.status===204)?t.data:0)}),Ht=Ae()(Be(Oe((...e)=>({...kA(...e)}),{name:"product-storage",getStorage:()=>me}),{name:"product-storage",enabled:!1,anonymousActionType:"zustand"})),af={tags:{tagList:[],categoryList:[]}},GA=(e,t)=>({...af,setTags:r=>e(n=>({...n,tags:{...n.tags,tagList:r}})),setCategories:r=>e(n=>({...n,tags:{...n.tags,categoryList:r}})),updateTags:async r=>hA(r).then(n=>{const a=n.data;if(r.tagList){const s=((a==null?void 0:a.tagList)||[]).concat();return e(i=>{var o;return{...i,tags:{...i.tags,tagList:s,...r.categoryList&&{categoryList:(o=(a==null?void 0:a.categoryList)||[])==null?void 0:o.concat()}}}}),r!=null&&r.productId&&"product"in(n==null?void 0:n.data)&&Ht.setState(i=>{var o,c,u,l,d,h;return{...i,product:{...i.product,productDetail:(o=i==null?void 0:i.product)!=null&&o.productDetail?{...(c=i==null?void 0:i.product)==null?void 0:c.productDetail,product:{...(l=(u=i==null?void 0:i.product)==null?void 0:u.productDetail)==null?void 0:l.product,tags:(((h=(d=n.data)==null?void 0:d.product)==null?void 0:h.tags)||[]).concat()}}:null}}}),n}if(r!=null&&r.categoryList&&!(r!=null&&r.tagList)){const s=(a==null?void 0:a.categoryList)||[];e(i=>({...i,tags:{...i.tags,categoryList:s}}))}return n}),createTag:async r=>iA(r).then(n=>{var a;if(n.status===201){const s=r;s.categoryName=(a=t().tags.categoryList.find(i=>i.uuid===s.categoryId))==null?void 0:a.name,s.usageCount=1,e(i=>({...i,tags:{...i.tags,tagList:[...i.tags.tagList,s]}}))}return n}),updateTag:async(r,n)=>oA(r,n).then(a=>{var s,i;if(a.status===200)try{const o=t().tags.tagList.concat(),c=o.findIndex(u=>u.uuid===r);c>=0&&(((s=o==null?void 0:o[c])==null?void 0:s.categoryId)!==(n==null?void 0:n.categoryId)&&(o[c].categoryName=(i=t().tags.categoryList.find(u=>u.uuid===n.categoryId))==null?void 0:i.name),o[c]={...o[c],...n},e(u=>({...u,tags:{...u.tags,tagList:o}})))}catch{}return a}),deleteTag:async r=>cA(r).then(n=>(n.status===200&&e(a=>({...a,tags:{...a.tags,tagList:a.tags.tagList.filter(s=>s.uuid!==r)}})),n)),createTagCategory:async r=>uA(r).then(n=>(n.status===201&&e(a=>({...a,tags:{...a.tags,categoryList:[...a.tags.categoryList,r]}})),n)),updateTagCategory:async(r,n)=>lA(r,n).then(a=>{if(a.status===200)try{const s=t().tags.categoryList.concat(),i=s.findIndex(c=>c.uuid===r);s[i]={...s[i],...n};const o=t().tags.tagList.map(c=>({...c,categoryName:r===c.categoryId?n.name:c==null?void 0:c.categoryName}));e(c=>({...c,tags:{categoryList:s,tagList:o}}))}catch(s){console.log("Err",s)}return a}),deleteTagCategory:async r=>{const n=()=>e(a=>({...a,tags:{...a.tags,tagList:a.tags.tagList.map(s=>({...s,...r===(s==null?void 0:s.categoryId)&&{categoryId:void 0,categoryName:void 0}})),categoryList:a.tags.categoryList.filter(s=>s.uuid!==r)}}));return dA(r).then(a=>(a.status===200&&n(),a)).catch(a=>{var s;if(((s=a==null?void 0:a.response)==null?void 0:s.status)===404)return n(),a.response.status=200,a;throw a})},getTagsByProductId:pA,resetTags:()=>{e(af)}}),sf="tags-session-storage",Dl=Ae()(Be(Oe((...e)=>({...GA(...e)}),{name:sf,getStorage:()=>me}),{name:sf,enabled:!1,anonymousActionType:"zustand"}));var Dy=(e=>(e.BranchId="branchId",e.ContentId="contentId",e))(Dy||{});const Rl=class Un{async updateContent(t=!0,r=!0){return new Promise((n,a)=>{IA(t,r).then(async s=>{if((s==null?void 0:s.status)===200){const i=this.getDataForStore(s.data.data);this.initStore(i),n(void 0)}else a()}).catch(a)})}initStore(t){try{Ht.getState().setDepartmentFull({departments:t.departments,categories:t.categories}),Ht.getState().setUnits(t.units),Ht.getState().setTaxes(t.taxes),Dl.getState().setTags(t.tags),Dl.getState().setCategories(t.tagCategoryList),Ht.getState().setStock({warehouseList:t.warehouses}),Ht.getState().setPriceList(t.selectedPriceList)}catch{}}static update(t,r){const n=Un.getBranchId(),a=Un.getContentId();return Pr.transaction("rw",t,async()=>t.schema.indexes.some(s=>s.keyPath==="branchId")?(await t.where("branchId").equals(n).delete(),t.bulkAdd(Un.setBranchId(r,n))):(await t.where("contentId").equals(a).delete(),t.bulkAdd(Un.setContentId(r,a))))}async clearAllData(){const t=Un.getBranchId(),r=Un.getContentId();return Promise.allSettled([this.clearByBranch(t),this.clearByContent(r)])}async clearByBranch(t){return Promise.allSettled([Pr.priceLists.where("branchId").equals(t).delete(),Pr.warehouses.where("branchId").equals(t).delete()])}async clearByContent(t){return Promise.allSettled([Pr.departments.where("contentId").equals(t).delete(),Pr.categories.where("contentId").equals(t).delete(),Pr.taxes.where("contentId").equals(t).delete(),Pr.units.where("contentId").equals(t).delete()])}static setBranchId(t,r){return Array.isArray(t)?t.map(n=>({...n,branchId:r})):[]}static setContentId(t,r){return Array.isArray(t)?t.map(n=>({...n,contentId:r})):[]}parseList(t){return Array.isArray(t)?t:[]}static tableHook(t){return(t==null?void 0:t.contentId)!==void 0&&(Un.getBranchId(),t.branchId),t}getDataForStore(t){var r,n,a,s,i,o;return{departments:this.parseList((n=(r=t==null?void 0:t.content)==null?void 0:r.catalog)==null?void 0:n.departments),categories:this.parseList((s=(a=t==null?void 0:t.content)==null?void 0:a.catalog)==null?void 0:s.categories),taxes:this.parseList((i=t==null?void 0:t.content)==null?void 0:i.taxes),units:this.parseList((o=t==null?void 0:t.content)==null?void 0:o.units),warehouses:this.parseList(t==null?void 0:t.forBranch),selectedPriceList:t==null?void 0:t.selectedPriceList,tags:this.parseList(t==null?void 0:t.tags),tagCategoryList:this.parseList(t==null?void 0:t.tagCategoryList)}}};Br(Rl,"getBranchId",()=>$a.getState().companies.branchOffice.id),Br(Rl,"getContentId",()=>{var e,t,r;const n=me.getItem("auth-company-storage");return(r=(t=(e=JSON.parse(n))==null?void 0:e.state)==null?void 0:t.authCompany)==null?void 0:r.contentId});let _o=Rl;const of={settings:{amountPattern:{isoLanguage:"",isoCountry:""},cashRegisters:{list:[]},configurationSales:null,currencies:{list:[],catalogue:[]},dateTimePattern:{datePattern:"",timePattern:""},denominations:{contentId:0,denominations:[],id:"",iso:""},denominationsList:{list:[]},documentFormats:[],expirationDateCer:"",eCommerceSettings:null,formatsDTO:[],formatsDTOGetted:[{docType:"SALE",format:"TICKET",getted:!1},{docType:"SALE",format:"LETTER",getted:!1},{docType:"QUOTATION",format:"TICKET",getted:!1},{docType:"QUOTATION",format:"LETTER",getted:!1},{docType:"PURCHASE",format:"TICKET",getted:!1},{docType:"PURCHASE",format:"LETTER",getted:!1},{docType:"CFDI_INGRESO",format:"TICKET",getted:!1},{docType:"CFDI_PAGO",format:"TICKET",getted:!1},{docType:"ORDER",format:"TICKET",getted:!1}],formatsGetted:[{docType:"SALE",format:"TICKET",getted:!1},{docType:"SALE",format:"LETTER",getted:!1},{docType:"QUOTATION",format:"TICKET",getted:!1},{docType:"QUOTATION",format:"LETTER",getted:!1},{docType:"PURCHASE",format:"TICKET",getted:!1},{docType:"PURCHASE",format:"LETTER",getted:!1},{docType:"CFDI_INGRESO",format:"TICKET",getted:!1},{docType:"CFDI_PAGO",format:"TICKET",getted:!1},{docType:"ORDER",format:"TICKET",getted:!1}],invoiceInfo:{contentId:0,rfc:"",businessName:"",claveSatRegimen:"",descripcionRegimen:"",imssNumber:"",street:"",extNumber:"",intNumber:"",district:"",city:"",county:"",state:"",country:"",zipCode:"",certificate:{id:"",cerName:"",certificate:[""],keyName:"",key:[""],requestDate:"",expirationDate:"",pfx:[""],pwd:"",certificateEncoded:[""],keyEncoded:[""],serialNumber:"",businessName:"",rfc:"",contentId:0,branchOfficeId:0}},logoTicket:{base64:"",align:"center",intensity:170,luminosity:170,scale:1,size:250},paymentOptions:{list:[],predetermined:{banked:!1,claveSat:"",paymentOptionId:0,status:-1,predetermined:!1}},pPAvailableDocs:[],printProfileList:[],productConfiguration:{priceDecimals:-1,priceBehavior:-1,profitByMargin:!0},transferConfiguration:{allowNoStock:!1},purchaseOperability:null,quotationOperability:null,series:{list:[]},sharedOperability:null,orderOperability:null,cfdiOperability:null}},Li={sales:"configurationSales",shared:"sharedOperability",quotation:"quotationOperability",purchase:"purchaseOperability",order:"orderOperability","order/sale":"orderOperability",cfdi:"cfdiOperability"},QA=(e,t)=>({...of,getConfigurationSales:async(r="sales",n)=>YT(r).then(a=>{const s={[Li[r]]:a==null?void 0:a.data};return a.status!==304?(e(i=>({...i,settings:{...i.settings,...s}})),!0):a.status===304}).catch(a=>a.response.status===404?jT("Público en general",r,n).then(({data:s})=>{const i={[Li[r]]:s};return e(o=>({...o,settings:{...o.settings,...i}})),!0}).catch(s=>{throw s}):!1),resetDefaultOperabilitySales:async(r="sales",n)=>{const a=Li[r];return FT(r,n).then(({data:s})=>(e(i=>({...i,settings:{...i.settings,[a]:s}})),!0)).catch(()=>!1)},editConfigurationSales:async(r,n,a)=>{const{document:s="sales",token:i}=a??{},o=Object.keys(n)[0],c=Li[s];return MT(r,n,{document:s,token:i}).then(u=>(u==null?void 0:u.status)===200||(u==null?void 0:u.status)===204?(e(l=>{var d,h;return l.settings[c]!=null?{...l,settings:{...l.settings,[c]:{...l.settings[c],[o]:o!=="validityDays"&&o!=="recalculate"?{...(h=(d=l.settings)==null?void 0:d[c])==null?void 0:h[o],...n[o]}:n[o]}}}:{...l}}),!0):!1).catch(u=>{throw u})},getDenominationsList:async r=>Mp(r).then(n=>n.status===200||n.status===204?(e(a=>({...a,settings:{...a.settings,denominationsList:{list:[...a.settings.denominationsList.list.filter(s=>s.iso!=r),{iso:r,data:n==null?void 0:n.data}]}}})),!0):!1).catch(n=>!1),getSeries:async r=>QT(r).then(n=>{var a,s;if(n.status===200||n.status===204){let i=((a=n==null?void 0:n.data)==null?void 0:a.length)>0?n.data.sort((o,c)=>o.serie.localeCompare(c.serie)):[];return e(o=>({...o,settings:{...o.settings,series:{list:[...o.settings.series.list.filter(c=>{c.documentType}),{documentType:r,data:i}]}}})),i}return((s=t().settings.series.list.find(i=>i.documentType===r))==null?void 0:s.data)||[]}).catch(n=>{throw n}),getCashRegisters:async()=>WA().then(r=>{var n;if(r.status===200||r.status===204){let a=((n=r==null?void 0:r.data)==null?void 0:n.length)>0?r.data.sort((s,i)=>s.name.localeCompare(i.name)):[];return e(s=>({...s,settings:{...s.settings,cashRegisters:{list:[...a]}}})),a}return t().settings.cashRegisters.list}).catch(r=>t().settings.cashRegisters.list),editCashRegister:async(r,n)=>ZA(r,n).then(a=>(a.status===200&&e(s=>({...s,settings:{...s.settings,cashRegisters:{list:s.settings.cashRegisters.list.map(i=>i.uuid===r.uuid?{...r,status:r.status?Ea.ENABLED:Ea.DISABLED}:i)}}})),a)).catch(a=>{throw a}),getDenominations:async r=>Mp(r.iso).then(n=>n.status===200?n.data.denominations:n.status===404?BT(r.iso).then(a=>a.status===201?[]:(console.log("response",a.response.data),[])):(console.log("response",n),[])).catch(n=>{throw n}),patchDenominations:async(r,n)=>kT(r,n).then(a=>a.status===200?!0:(console.log("request",a.response.data),!1)),setPaymentOptionToggle:async r=>{const n=t().settings.paymentOptions.list;return n[r].status=n[r].status===1?-1:1,e(a=>({...a,settings:{...a.settings,paymentOptions:{...a.settings.paymentOptions,list:[...n]}}})),!0},getPaymentOptions:r=>VT(r),setPaymentOptions:r=>e(n=>({...n,settings:{...n.settings,paymentOptions:{...n.settings.paymentOptions,predetermined:r.find(a=>a.predetermined)??r[0],list:[...r]}}})),createPaymentOption:async r=>GT(r).then(n=>(console.log(n),n.status===201?(e(a=>({...a,settings:{...a.settings,paymentOptions:{...a.settings.paymentOptions,list:t().settings.paymentOptions.list.map(s=>s.paymentOptionId===r.paymentOptionId?{...r}:s.predetermined&&r.predetermined?{...s,predetermined:!1}:s),predetermined:r.predetermined?r:a.settings.paymentOptions.predetermined}}})),!0):(console.log("request",n.response.data),!1))).catch(n=>{throw console.log("err",n),n}),setPaymentOption:async r=>{try{return zT(r.paymentOptionId,r).then(n=>{if(n.status===200){const a=t().settings.paymentOptions.list,s=a.findIndex(i=>i.paymentOptionId===r.paymentOptionId);return r.status!==void 0&&(a[s].status=r.status),r.predetermined&&(a.map(i=>i.predetermined=!1),a[s].predetermined=r.predetermined),e(i=>({...i,settings:{...i.settings,paymentOptions:{...i.settings.paymentOptions,list:[...a],predetermined:a.find(o=>o.predetermined)??i.settings.paymentOptions.predetermined}}})),!0}else return console.log("request",n.response.data),!1}).catch(n=>{throw console.log(n),n})}catch(n){throw console.log(n),n}},getCatalogueCurrencies:async(r,n)=>_T(r,n).then(a=>a.status===200?(e(s=>({...s,settings:{...s.settings,currencies:{...s.settings.currencies,catalogue:[...a.data.sort(function(i,o){return i.main===o.main?0:i?-1:1})]}}})),a.data):(e(s=>({...s,settings:{...s.settings,currencies:{...s.settings.currencies,catalogue:[]}}})),t().settings.currencies.catalogue)),getCompanyCurrencies:r=>PT(r),addCurrencies:async r=>{console.log("currencies",r);try{return DT(r).then(n=>n.status===201?(e(a=>({...a,settings:{...a.settings,currencies:{...a.settings.currencies}}})),!0):(e(a=>({...a,settings:{...a.settings,currencies:{...a.settings.currencies}}})),!1))}catch{return!1}},updateCurrency:r=>RT(r),setCurrencies:r=>e(n=>({...n,settings:{...n.settings,currencies:{...n.settings.currencies,main:r.find(a=>a.main),list:[...r.sort((a,s)=>s.main<a.main?-1:s.main>a.main?1:s.predetermined<a.predetermined?-1:s.predetermined>a.predetermined?1:s.status<a.status?-1:s.status>a.status?1:0)]}}})),deleteCurrency:async r=>{try{return NT(r).then(n=>{if(n.status===200){const a=t().settings.currencies.list;return a.splice(a.findIndex(s=>s.iso===r),1),e(s=>({...s,settings:{...s.settings,currencies:{...s.settings.currencies,list:[...a]}}})),!0}else return e(a=>({...a,settings:{...a.settings,currencies:{...a.settings.currencies,list:[]}}})),!1}).catch(n=>(console.log(n.response),n)).finally(()=>{})}catch(n){return console.log(n.message),n}},createInvoiceInfo:async r=>OT(r).then(n=>(console.log(n),n&&n.status===201?(r.certificate&&e(a=>{var s;return{...a,settings:{...a.settings,expirationDateCer:(s=r.certificate)==null?void 0:s.expirationDate}}}),e(a=>({...a,settings:{...a.settings,invoiceInfo:r}})),!0):!1)),setInvoiceInfo:async r=>{r.certificate&&e(n=>{var a;return{...n,settings:{...n.settings,expirationDateCer:(a=r.certificate)==null?void 0:a.expirationDate}}}),e(n=>({...n,settings:{...n.settings,invoiceInfo:r}}))},getInvoiceInfo:()=>Pl(),loadInvoiceInfo:async()=>{try{const r=await Pl();if(r.status===200){console.log("RESPONSE",r);const n=r.data;let a={rfc:n.rfc,idCif:n.idCif??"",businessName:n.businessName,city:n.city??"",claveSatRegimen:n.claveSatRegimen,country:n.country??"",descripcionRegimen:n.descripcionRegimen,district:n.district??"",extNumber:n.extNumber??"",intNumber:n.intNumber??"",state:n.state??"",zipCode:n.zipCode,contentId:n.contentId,county:n.county??"",imssNumber:n.imssNumber??"",street:n.street??""};return n.certificate?a={...a,certificate:{id:"",cerName:n.certificate.cerName,keyName:n.certificate.keyName,requestDate:n.certificate.requestDate,expirationDate:n.certificate.expirationDate}}:a={...a,certificate:null},e(s=>{var i;return{...s,settings:{...s.settings,invoiceInfo:a,expirationDateCer:(i=a.certificate)==null?void 0:i.expirationDate}}}),a}return null}catch{return null}},updateInvoice:async(r,n)=>LT(r,n).then(a=>(console.log("RESPONSE API: ",a),a.status===200?(r.certificate===null&&e(s=>({...s,settings:{...s.settings,expirationDateCer:""}})),e(s=>({...s,settings:{...s.settings,invoiceInfo:r}})),!0):(console.log("request",a),a.response.data))).catch(a=>(console.log("CATCH: ",a),a)),getCertificateExpiration:async()=>$T(!0).then(r=>r.status===200?(console.log(r),e(n=>({...n,settings:{...n.settings,expirationDateCer:r.data}})),!0):(console.log("request",r),!1)),deleteCertificate:async r=>IT(r).then(n=>{if(n.status===200){console.log(n);let a=t().settings.invoiceInfo;return a.certificate={cerName:"",keyName:"",requestDate:null,expirationDate:null},e(s=>({...s,settings:{...s.settings,expirationDateCer:""}})),e(s=>({...s,settings:{...s.settings,invoiceInfo:a}})),console.log("NEW STORE INVOICE: ",a),!0}else return console.log("request",n),!1}),deleteExpirationDateCertificate:async()=>{e(r=>({...r,settings:{...r.settings,expirationDateCer:""}}))},getValidateCertificate:async(r,n,a)=>AT(r,n,a).then(s=>s.status===200?(console.log(s),{data:s.data}):(console.log("request",s),{data:!1})),setExpirationDateCertificate:async r=>{e(n=>({...n,settings:{...n.settings,expirationDateCer:r}}))},getAmountPattern:async()=>WT().then(async r=>r&&r.status===200?(e(n=>({...n,settings:{...n.settings,amountPattern:{isoLanguage:r.data.isoLanguage,isoCountry:r.data.isoCountry}}})),r.data):null),setAmountPattern:async r=>ZT(r).then(n=>n&&n.status===201?(e(a=>({...a,settings:{...a.settings,amountPattern:{isoLanguage:r.isoLanguage,isoCountry:r.isoCountry}}})),!0):!1),getProductConfiguration:async()=>XT().then(r=>{var n;if(r.status===200&&(n=r.data)!=null&&n.productConfiguration){const{priceDecimals:a,profitByMargin:s}=r.data.productConfiguration;return e(i=>({...i,settings:{...i.settings,productConfiguration:{priceDecimals:a,profitByMargin:s,priceBehavior:-1}}})),!0}return!1}).catch(()=>!1),setProductConfiguration(r){e(n=>({...n,settings:{...n.settings,productConfiguration:{...n.settings.productConfiguration,...r}}}))},getPrintProfileList:()=>t$(),setPrintProfileList:r=>e(n=>({...n,settings:{...n.settings,printProfileList:r}})),getPPAvailableDocs:async()=>r$().then(r=>r.status===200?(e(n=>({...n,settings:{...n.settings,pPAvailableDocs:r.data}})),!0):!1).catch(()=>!1),getDtoDocumentFormat:async(r,n)=>{const a=t().settings.formatsDTO,s=t().settings.formatsDTOGetted.slice(),i=s.findIndex(o=>o.docType===r&&o.format===n);if(a.length!==0&&s[i].getted){const o=a.findIndex(c=>c.docType===r&&c.format===n);return a[o]}return qT(r,n).then(o=>{if(o.status===200){const c=s.findIndex(h=>h.docType===r&&h.format===n),u=a,l={...s[c],getted:!0};s.splice(c,1,l);const d={docType:r,format:n,fields:o.data};return u.push(d),e(h=>({...h,settings:{...h.settings,formatsDTO:u}})),e(h=>({...h,settings:{...h.settings,formatsDTOGetted:s}})),d}else return Vp(r,n)}).catch(()=>Vp(r,n))},getDocumentFormat:async(r,n)=>{const a=t().settings.documentFormats.slice(),s=t().settings.formatsGetted.slice(),i=t().settings.eCommerceSettings,o=i||await Fp().then(u=>(u.status===200?e(l=>({...l,settings:{...l.settings,eCommerceSettings:u.data}})):e(l=>({...l,settings:{...l.settings,eCommerceSettings:{}}})),u.data)).catch(()=>null),c=s.findIndex(u=>u.docType===r&&u.format===n);if(a.length!==0&&c!=-1&&s[c].getted){const u=a.findIndex(l=>l.docType===r&&l.format===n);return{objFormats:a[u],objECommerce:o}}else return HT(r,n).then(u=>{if(u.status===200){const l=s.findIndex(f=>f.docType===r&&f.format===n),d=a,h={...s[l],getted:!0};s.splice(l,1,h);const p={docType:r,format:n,options:u.data.webPage===""?{...u.data,webPage:"sicarx.com"}:u.data};return d.push(p),e(f=>({...f,settings:{...f.settings,documentFormats:d}})),e(f=>({...f,settings:{...f.settings,formatsGetted:s}})),{objFormats:p,objECommerce:o}}else return{objFormats:zp(r,n),objECommerce:o}}).catch(()=>zp(r,n))},putDocumentFormat:async(r,n,a,s)=>KT(r,n,a,s).then(i=>{if(i.status===200){const o=t().settings.documentFormats,c=o.findIndex(u=>u.docType===r&&u.format===n);return o.splice(c,1,{docType:r,format:n,options:a}),e(u=>({...u,settings:{...u.settings,documentFormats:o}})),!0}else return i.response.data.message}).catch(()=>!1),getLogoTicket:async()=>{const r=t().settings.logoTicket;return o$().then(n=>{if(n.status===200){const a={base64:r==null?void 0:r.base64,...n.data};return e(s=>({...s,settings:{...s.settings,logoTicket:a}})),a}return r}).catch(n=>r)},putLogoTicket:async r=>c$(r).then(n=>n.status===200?(e(a=>({...a,settings:{...a.settings,logoTicket:r}})),!0):!1).catch(n=>{throw new Error(n)}),updateLogoTicket:async r=>{e(n=>({...n,settings:{...n.settings,logoTicket:r}}))},setDateTimePattern:async r=>{e(n=>({...n,settings:{...n.settings,dateTimePattern:{datePattern:r.datePattern,timePattern:r.timePattern}}}))},getDateTimePattern:async()=>JT().then(r=>r.status===200?(e(n=>({...n,settings:{...n.settings,dateTimePattern:r.data}})),!0):!1).catch(()=>!1),putPrintProfile:async r=>n$(r).then(async n=>{if(n.status===201){let a=t().settings.printProfileList;return a.push(r),e(s=>({...s,settings:{...s.settings,printProfileList:a}})),{status:!0}}else return{status:!1}}).catch(n=>({status:!1,code:n.data.code})),deletePrintProfile:async r=>s$(r).then(async n=>{if(n.status===200){let a=t().settings.printProfileList;const s=a.findIndex(i=>i.uuid===r);return a.splice(s,1),e(i=>({...i,settings:{...i.settings,printProfileList:[...a]}})),!0}return!1}).catch(()=>!1),patchPrintProfile:async(r,n)=>i$(r,n).then(async a=>{if(console.log("res",a),a.status===200){let s=t().settings.printProfileList;const i=s.findIndex(o=>o.uuid===n.uuid);return s.splice(i,1,n),e(o=>({...o,settings:{...o.settings,printProfileList:[...s]}})),{status:!0}}else return{status:!1}}).catch(a=>({status:!1,code:a.data.code})),async setTransferConfiguration(r){return e$(r).then(n=>(n.status===200&&e(a=>({...a,settings:{...a.settings,transferConfiguration:{allowNoStock:r}}})),n))},putEcommerceData:async r=>{e(n=>({...n,settings:{...n.settings,eCommerceSettings:r}}))},getEcommerceConfig:async()=>u$().then(r=>r&&r.status===200?r.data:null),getEcommerceList:async()=>l$().then(r=>r&&(r.status===200||r.status===204)?r.data:null),changeEcommerceDomain:async r=>d$(r).then(n=>{if(n)return n.status===200?n.data:n.response.data}),editEcommerceConfig:async r=>h$(r).then(n=>{if(n)return n.status===200?n.data:n.response.data}),addEcommerceConfig:async r=>p$(r).then(n=>{if(n)return n.status===200?n.data:n.response.data}),selectEcommerce:async r=>f$(r).then(n=>{if(n)return n.status===200?n.data:n.response.data}),isConfigEcommerceActive:async()=>Fp().then(r=>{if(r&&r.status===200)return r.data}),switchConfigEcommerce:async(r,n)=>g$({flag:r,disable:n}).then(a=>a&&a.status===200?a.data:null),branchesByConfig:async r=>m$(r).then(n=>n&&n.status===200?n.data:null),uploadEcommerceBanner:async(r,n)=>y$(r,n).then(a=>!!(a&&(a.status===200||a.status===204))),unlinkEcommerceConfig:async()=>v$().then(r=>{var n,a;return r&&r.status===200?{unlink:!0,code:0}:{unlink:!1,code:(a=(n=r.response)==null?void 0:n.data)!=null&&a.code?r.response.data.code:0}}),refreshEcommerceConfig:async()=>b$().then(r=>!!(r&&r.status===200)),resetSettings:()=>e(of)}),Ot=Ae()(Be(Oe((...e)=>({...QA(...e)}),{name:"settings-storage",getStorage:()=>me}),{name:"settings-storage",enabled:!1,anonymousActionType:"zustand"})),WA=()=>new Promise((e,t)=>{Q(_a+"/list").then(r=>{r.data=r.data.map(n=>({...n,status:n.status===Ea.ENABLED?1:-1})),e(r)}).catch(r=>{t(r)})}),ZD=e=>new Promise((t,r)=>{Q(`${_a}/${e}`).then(n=>{const{status:a}=n.data;n.data={...n.data,status:a===Ea.ENABLED?1:-1},t(n)}).catch(n=>{r(n)})}),YD=e=>new Promise((t,r)=>{J(`${Da}/cashRegister`,{name:e==null?void 0:e.name,uuid:e==null?void 0:e.uuid}).then(n=>{t(n)}).catch(n=>{r(n.response)})}),XD=e=>new Promise((t,r)=>{ft(`${Da}/cashRegister/${e}`).then(n=>{t(n)}).catch(n=>{r(n.response)})}),ZA=(e,t)=>{const r=h0(t,e,"");return typeof(r==null?void 0:r.status)<"u"&&(r.status=r.status?Ea.ENABLED:Ea.DISABLED),new Promise((n,a)=>{ze(`${Da}/cashRegister/${e==null?void 0:e.uuid}`,r).then(s=>{console.log(s),n(s)}).catch(s=>{console.log(s),a(s.response)})})},YA=e=>{const t={"CF-Access-Client-Id":"8fc5b7d7a5bc803480d13d418b3bff37.access","CF-Access-Client-Secret":"5a6ada4d843e323c6f0a953c82cc593d3833750b247a662c25c04de0b1589d0f"};return new Promise(r=>{Rt.post("https://ea.sicarx.com/v1/registry/complete",e,{headers:{...t}}).then(n=>r(n)).catch(n=>r(n))})},XA=()=>new Promise(e=>{Q(Yt+"/account").then(t=>e(t)).catch(t=>e(t))}),JA=e=>new Promise(t=>{ze(Yt+"/account",e).then(r=>t(r)).catch(r=>t(r))}),eI=e=>new Promise(t=>{Re(Yt+"/account/logo",e,"text/plain; charset=UTF-8").then(r=>t(r)).catch(r=>t(r.response))}),tI=e=>new Promise(t=>{Re(Yt+"/account/secret",e).then(r=>t(r)).catch(r=>t(r.response))}),rI=e=>new Promise(t=>{J(`${Yt}/account/recovery?email=${e}`,{}).then(r=>t(r)).catch(r=>t(r))}),nI=(e,t)=>new Promise(r=>{Re(`${Yt}/account/complete?set=${e}&password=${t}`).then(n=>r(n)).catch(n=>r(n))}),aI=()=>new Promise(e=>{Q(Yt+"/invoiceInfo/list").then(t=>e(t)).catch(t=>e(t))}),sI=e=>new Promise(t=>{J(Yt+"/invoiceInfo",e).then(r=>t(r)).catch(r=>t(r))}),iI=e=>new Promise(t=>{ze(Yt+"/invoiceInfo",e).then(r=>t(r)).catch(r=>t(r))}),oI=e=>new Promise(t=>{ft(Yt+`/invoiceInfo?invoiceInfoUuid=${e}`).then(r=>t(r)).catch(r=>t(r))}),cI=e=>new Promise(t=>{Re(Yt+`/invoiceInfo/predeterminate?invoiceInfoUuid=${e}`).then(r=>t(r)).catch(r=>t(r))}),uI=()=>new Promise(e=>{Q(FC).then(t=>e(t)).catch(t=>e(t))}),lI=e=>new Promise(t=>{Re(`${Yt}/config?lang=${e}`).then(r=>t(r)).catch(r=>t(r))}),JD=e=>new Promise(t=>{J(`${Yt}/firebase`,e).then(r=>t(r)).catch(r=>t(r))}),eR=()=>new Promise(e=>{Q(`${Yt}/survey`).then(t=>e(t)).catch(t=>e(t))}),tR=()=>new Promise(e=>{J(`${Yt}/survey`,{}).then(t=>e(t)).catch(t=>e(t))}),dI=()=>new Promise(e=>{Q(`${Yt}/account/checkStatus`).then(t=>e(t)).catch(t=>e(t))}),hI=()=>new Promise(e=>{J(`${Yt}/account/resend`,{}).then(t=>e(t)).catch(t=>e(t))}),pI=(e,t)=>new Promise(r=>{jr(`${Yt}/extern/pin`,t,{"x-pin-ids":e,"Content-Type":"text/plain; charset=UTF-8"}).then(n=>r(n)).catch(n=>r(n))});var In=(e=>(e.ACCESS_KEY_ID="AKIAVBBCH6IBIXWXO656",e.SECRET_ACCESS_KEY="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",e))(In||{});const fI=e=>new Jo({accessKeyId:In.ACCESS_KEY_ID,secretAccessKey:In.SECRET_ACCESS_KEY,service:"lambda"}).fetch("https://7ew5wkc4jsnbb6ph2bd2r4o5540hqlea.lambda-url.us-east-1.on.aws/login/v1/account",{body:JSON.stringify(e),method:"POST"}),cf=e=>new Jo({accessKeyId:In.ACCESS_KEY_ID,secretAccessKey:In.SECRET_ACCESS_KEY,service:"lambda"}).fetch("https://7ew5wkc4jsnbb6ph2bd2r4o5540hqlea.lambda-url.us-east-1.on.aws/login/v1/login",{body:JSON.stringify(e),method:"POST"}),gI=e=>new Jo({accessKeyId:In.ACCESS_KEY_ID,secretAccessKey:In.SECRET_ACCESS_KEY,service:"lambda"}).fetch("https://7ew5wkc4jsnbb6ph2bd2r4o5540hqlea.lambda-url.us-east-1.on.aws/login/v1/supp",{body:JSON.stringify(e),method:"POST"}),rR=(e,t)=>new Jo({accessKeyId:In.ACCESS_KEY_ID,secretAccessKey:In.SECRET_ACCESS_KEY,service:"lambda"}).fetch("https://7ew5wkc4jsnbb6ph2bd2r4o5540hqlea.lambda-url.us-east-1.on.aws/login/v1/authorization",{body:JSON.stringify(e),method:"POST",headers:{"SX-Authorization":t}}),$u={authAccount:{logged:!1,loggedSocial:!1,jwt:"",firstName:"",lastName:"",imageUrl:"",countryCode:"",phoneNumber:"",address:{city:"",inner:"",county:"",district:"",state:"",street:"",zipCode:"",lat:0,lon:0,extNumber:"",reference:""},country:"",accountUuid:"",email:"",language:"",status:-2}},mI=(e,t)=>({...$u,loginAccount:async(r,n,a,s,i,o)=>{try{return fI({deviceType:i,deviceId:a,deviceAlias:s,email:r,password:n}).then(c=>c.status===200?c.json():!1).then(c=>{if(typeof c=="boolean")return!1;{const u={...c,logged:!0};return o||o===void 0?(e(l=>({...l,authAccount:{...l.authAccount,...u}})),!0):u}}).catch(c=>(console.log(c),!1))}catch{return!1}},setAuthAccount:r=>e(n=>({...n,authAccount:{...n.authAccount,...r}})),getJwtAccount:()=>t().authAccount.jwt,logoutAccount:async()=>(await uI(),e($u),!0),createAccount:async r=>YA(r).then(async n=>n&&n.status===201?{code:0,message:"",isCreated:!0}:{isCreated:!1,code:n.response.data.code,message:n.response.data.message}),changeLanguaje:async r=>(await lI(r)).status===200?(e(n=>({...n,authAccount:{...n.authAccount,language:r}})),!0):!1,resetAuthAccount:()=>e($u),LoginAccountSocial:async r=>{const n={...r,logged:!0,loggedSocial:!0};return e(a=>({...a,authAccount:{...a.authAccount,...n}})),!0},checkStatus:async()=>dI().then(r=>r&&r.status===200?(e(n=>({...n,authAccount:{...n.authAccount,status:r.data}})),r.data):0),loginWithPin:async(r,n,a)=>{try{const s=JSON.stringify(a),i=IC(s,n);return pI(r,i).then(o=>{if(o&&o.status===200){const c={...o.data,logged:!0};return e(u=>({...u,authAccount:{...u.authAccount,...c}})),c}return null})}catch(s){return console.log(s),null}}}),ci=Ae()(Be(Oe((...e)=>({...mI(...e)}),{name:"auth-account-storage",getStorage:()=>me}),{name:"auth-account-storage",enabled:!1,anonymousActionType:"zustand"})),nR=({children:e})=>{const t=me.getItem("auth-account-storage"),r=me.getItem("auth-company-storage"),n=me.getItem("companies-storage"),a=Jf(),{state:s}=t===null?!1:JSON.parse(t),{state:i}=r===null?!1:JSON.parse(r),{state:o}=n===null?!1:JSON.parse(n);if(i.authCompany&&i.authCompany.isSupport)return Tt.jsx($t,{to:"/dashboard",replace:!0});if(s.authAccount.logged){const c=cn(s.authAccount.jwt),u=new Date,l=new Date(c.exp*1e3);if(u>=l)return ci(d=>d.logoutAccount()),Tt.jsx($t,{to:"/",replace:!0});if(i.authCompany.logged){const d=cn(i.authCompany.jwt),h=new Date,p=new Date(d.exp*1e3),f=i.authCompany.owner;return h>=p?e:o.companies.wizardStatus!==2&&f?Tt.jsx($t,{to:`/wizard/${o.companies.wizardStatus}`,replace:!0}):a.pathname.split("/").filter(g=>g.toLowerCase()==="account").length>0?e:Tt.jsx($t,{to:"/dashboard",replace:!0})}else return e}else return Tt.jsx($t,{to:"/",replace:!0})},A0=e=>{const t=new Date,r=new Date(e),n=1e3*60*60*24,a=r.getTime()-t.getTime();return Math.ceil(a/n)},aR=({children:e})=>{var t,r,n,a,s,i,o,c;const u=me.getItem("auth-company-storage"),l=me.getItem("companies-storage"),d=me.getItem("auth-account-storage"),{state:h}=u===null?!1:JSON.parse(u),{state:p}=l===null?!1:JSON.parse(l),{state:f}=d===null?!1:JSON.parse(d);if(h.authCompany.logged&&h.authCompany.jwt!==""){const g=(t=h==null?void 0:h.authCompany)==null?void 0:t.xStatus,y=(r=f==null?void 0:f.authAccount)==null?void 0:r.status,b=A0((a=(n=h==null?void 0:h.authCompany)==null?void 0:n.xNoAfter)==null?void 0:a.replaceAll("-","/"));if(y==3||g==="0"&&b<0||((s=h==null?void 0:h.authCompany)==null?void 0:s.xStatus)==="3"||((i=h==null?void 0:h.authCompany)==null?void 0:i.xStatus)==="4"||((o=h==null?void 0:h.authCompany)==null?void 0:o.xStatus)==="5"||((c=h==null?void 0:h.authCompany)==null?void 0:c.xStatus)==="2"&&b<-3)return location.pathname==="/dashboard"?e:Tt.jsx($t,{to:"/dashboard",replace:!0});{const m=cn(h.authCompany.jwt),v=new Date,S=new Date(m.exp*1e3),C=h.authCompany.owner;return v>=S?(ci(E=>E.logoutAccount()),Tt.jsx($t,{to:"/login-company",replace:!0})):p.companies.wizardStatus!==2&&C?Tt.jsx($t,{to:`/wizard/${p.companies.wizardStatus}`,replace:!0}):e}}else return Tt.jsx($t,{to:"/login-company",replace:!0})},sR=({children:e})=>{const[t]=r1(),r=t.get("email"),n=t.get("p"),a=me.getItem("auth-account-storage"),s=me.getItem("auth-company-storage"),i=Cr.getItem("storage"),{state:o}=sessionStorage===null?!1:JSON.parse(a),{state:c}=sessionStorage===null?!1:JSON.parse(s),{state:u}=i===null?!1:JSON.parse(i);if(c.authCompany&&c.authCompany.isSupport)return Tt.jsx($t,{to:"/dashboard",replace:!0});if(o){if(o.authAccount.logged&&!c.authCompany.logged){const l=cn(o.authAccount.jwt),d=new Date,h=new Date(l.exp*1e3);if(d>=h){if(ci(p=>p.logoutAccount()),u.branchOffice.id>0)return Tt.jsx($t,{to:"/login-company",replace:!0})}else return Tt.jsx($t,{to:"/companies",replace:!0})}else if(o.authAccount.logged&&c.authCompany.logged){const l=cn(c.authCompany.jwt),d=new Date,h=new Date(l.exp*1e3);if(d>=h){if(ci(p=>p.logoutAccount()),u.branchOffice.id>0)return Tt.jsx($t,{to:"/login-company",replace:!0})}else return Tt.jsx($t,{to:"/dashboard",replace:!0})}else if(!o.authAccount.logged&&!c.authCompany.logged&&u.branchOffice.id>0&&r===null&&n===null)return Tt.jsx($t,{to:"/login-company",replace:!0})}return e},iR=({children:e})=>{const t=me.getItem("auth-account-storage"),r=me.getItem("auth-company-storage"),n=Cr.getItem("storage"),{state:a}=sessionStorage===null?!1:JSON.parse(t),{state:s}=sessionStorage===null?!1:JSON.parse(r),{state:i}=n===null?!1:JSON.parse(n),o=a.authAccount,c=s.authCompany,u=i.branchOffice;return!o.logged&&!c.logged&&u.id===0?(console.log("IsMiddleLoginGuard1"),Tt.jsx($t,{to:"/",replace:!0})):o.logged&&c.logged?(console.log("IsMiddleLoginGuard2"),Tt.jsx($t,{to:"/dashboard",replace:!0})):o.logged&&!c.logged?(console.log("IsMiddleLoginGuard3"),Tt.jsx($t,{to:"/companies",replace:!0})):e},oR=({children:e})=>{const t=me.getItem("auth-account-storage"),r=me.getItem("auth-company-storage"),n=me.getItem("companies-storage"),a=Jf().pathname,{state:s}=t===null?!1:JSON.parse(t),{state:i}=r===null?!1:JSON.parse(r),{state:o}=n===null?!1:JSON.parse(n);if(s.authAccount.logged){const c=cn(s.authAccount.jwt),u=new Date,l=new Date(c.exp*1e3);if(u>=l)return Tt.jsx($t,{to:"/",replace:!0});if(i.authCompany.logged){const d=cn(i.authCompany.jwt),h=new Date,p=new Date(d.exp*1e3),f=i.authCompany.owner;return h>=p?Tt.jsx($t,{to:"/companies",replace:!0}):o.companies.wizardStatus===0&&f?a==="/wizard/0"?e:Tt.jsx($t,{to:"/wizard/0",replace:!0}):o.companies.wizardStatus===1&&f?a==="/wizard/1"?e:Tt.jsx($t,{to:"/wizard/1",replace:!0}):Tt.jsx($t,{to:"/dashboard",replace:!0})}else return Tt.jsx($t,{to:"/companies",replace:!0})}return Tt.jsx($t,{to:"/",replace:!0})},yI=(e,t)=>new Promise((r,n)=>{J(jC+"/login",{jwt:t,branchId:e}).then(a=>{r(a)}).catch(a=>{n(a)})}),vI=e=>Rt.get(`${Et}${Rr}/chip/default`,{headers:{Authorization:e}}),uf={authCompany:{logged:!1,id:0,name:"",alias:"",timeZone:"",countryCode:"",countryName:"",representative:"",guuid:"",emails:[],address:{lat:0,lon:0,city:"",inner:"",extNumber:"",state:"",district:"",street:"",zipCode:"",reference:"",county:""},phoneNumbers:[],permissions:{cashRegister:{authorizable:"",granted:"",dependencies:""},category:{authorizable:"",granted:"",dependencies:""},client:{authorizable:"",granted:"",dependencies:""},company:{authorizable:"",granted:"",dependencies:""},currency:{authorizable:"",granted:"",dependencies:""},department:{authorizable:"",granted:"c",dependencies:""},documentPrintConf:{authorizable:"",granted:"",dependencies:""},documentType:{authorizable:"",granted:"",dependencies:""},invoiceInfo:{authorizable:"",granted:"",dependencies:""},paymentOption:{authorizable:"",granted:"",dependencies:""},payments:{authorizable:"",granted:"",dependencies:""},product:{authorizable:"",granted:"",dependencies:""},rps:{authorizable:"",granted:"",dependencies:""},sale:{authorizable:"",granted:"",dependencies:""},serie:{authorizable:"",granted:"",dependencies:""},settings:{authorizable:"",granted:"",dependencies:""},tax:{authorizable:"",granted:"",dependencies:""},unit:{authorizable:"",granted:"",dependencies:""},user:{authorizable:"",granted:"",dependencies:""}},isSupport:!1,isAdmin:null,isOwner:!1,jwt:"",xNoAfter:"",xStatus:"",xPayment:"",contentId:0,isoCurrency:"",updatePermissions:!1,connection:!0,noTimbres:0,isInitConfigComplete:!1,hideVerifyDialog:!1}},bI=(e,t)=>({...uf,reAuthentication:async r=>yI(t().authCompany.id,r).then(n=>n.status===200?(e(a=>({...a,authCompany:{...a.authCompany,permissions:n.data}})),!0):!1),setUpdatePermission:async r=>(e(n=>({...n,authCompany:{...n.authCompany,updatePermissions:r}})),!0),setCompany:async r=>new Promise(n=>{e(a=>({...a,authCompany:{...a.authCompany,...r}})),n(!0)}),setTimbres:async r=>new Promise(()=>{e(n=>({...n,authCompany:{...n.authCompany,noTimbres:r}}))}),getJwtCompany:async(r,n,a,s,i,o)=>cf({branchId:r,deviceId:a,deviceAlias:s,deviceType:i,jwt:n}).then(c=>o?{jwt:c.headers.get("cauth"),xStatus:c.headers.get("x-status")}:c.headers.get("cauth")).catch(()=>""),loginCompany:async(r,n,a,s,i,o,c)=>{try{const u=localStorage.getItem("fbfcm");return cf({branchId:r,deviceId:s,deviceAlias:i,fcmId:u,deviceType:o,jwt:n}).then(l=>{var d;const h=(d=cn(l.headers.get("cauth")))==null?void 0:d.x;return e(p=>({...p,authCompany:{...p.authCompany,jwt:l.headers.get("cauth"),xNoAfter:l.headers.get("x-noafter"),xStatus:l.headers.get("x-status"),xPayment:l.headers.get("x-payment"),contentId:h}})),l.status===200?l.json():!1}).then(async l=>{var d;if(typeof l=="boolean")return{status:"error"};{const h=t().authCompany.xNoAfter,p=t().authCompany.xPayment,f=t().authCompany.xStatus,g=t().authCompany.jwt,y=A0(h.replaceAll("-","/"));try{await t().getNoTimbres(g)}catch{}const b=((d=cn(g))==null?void 0:d.p)==="ADMIN";return e(m=>({...m,authCompany:{...m.authCompany,logged:!0,id:r,permissions:l,isAdmin:b,isOwner:c!==void 0?c:!1}})),c===void 0&&y>=0&&await T4(a).then(m=>{m.status===200&&e(v=>({...v,authCompany:{...v.authCompany,isOwner:m.data}}))}),{status:"success",xNoAfter:h,xPayment:p,xStatus:f,jwt:g}}}).catch(l=>(console.log(l),{status:"error"}))}catch{return{status:"error"}}},getIsCompanyLogged:()=>t().authCompany.logged,getIsAdmin:()=>t().authCompany.isAdmin,getPermissions:()=>t().authCompany.permissions,setIsAdmin:r=>{e(n=>({...n,authCompany:{...n.authCompany,isAdmin:r}}))},updateIsoCurrency:r=>e(n=>({...n,authCompany:{...n.authCompany,isoCurrency:r}})),updateSubscriptionHeaders:(r,n)=>{e(a=>({...a,authCompany:{...a.authCompany,xNoAfter:r,xStatus:n}}))},resetAuthCompany:()=>e(uf),setUpdateConnection:async r=>(e(n=>({...n,authCompany:{...n.authCompany,connection:r}})),!0),supportLogin:async r=>{try{return gI(r).then(n=>{var a;const s=(a=cn(n.headers.get("cauth")))==null?void 0:a.x;return e(i=>({...i,authCompany:{...i.authCompany,jwt:n.headers.get("cauth"),contentId:s}})),n.status===200?n.json():!1}).then(n=>typeof n=="boolean"?!1:(e(a=>({...a,authCompany:{...a.authCompany,logged:!0,permissions:n,isSupport:!0,isAdmin:null,isOwner:!1,id:parseInt(r.supportId.slice(5,r.supportId.length))}})),!0)).catch(n=>(console.log(n),!1))}catch{return!1}},getNoTimbres:async r=>vI(r).then(n=>{if(n&&(n.status===200||n.status===409)){let a=0;return n.status===200&&(a=n.data.balance),e(s=>({...s,authCompany:{...s.authCompany,noTimbres:a}})),a}else return 0}),hideVerifyAccountDialog:()=>e(r=>({...r,authCompany:{...r.authCompany,hideVerifyDialog:!0}})),setInitConfigComplete:r=>e(n=>({...n,authCompany:{...n.authCompany,isInitConfigComplete:r}}))}),Ca=Ae()(Be(Oe((...e)=>({...bI(...e)}),{name:"auth-company-storage",getStorage:()=>me}),{name:"auth-company-storage",enabled:!1,anonymousActionType:"zustand"})),I0=()=>{const e=Ca(s=>s.getIsCompanyLogged),t=Ca(s=>s.getPermissions),r=Ca(s=>s.getIsAdmin),n=s=>e()&&t()[s]||null,a=(s,i)=>{if(!e())return 1;if(s==="NOT_EARLY_ACCESS")return 0;if(r())return 1;const o=s.split("/");if(o.length<2)throw new Error("Invalid action");const c=n(o[1]);return c?c.authorizable.split(",").includes(o[0])?2:i&&c.dependencies.split(",").includes(o[0])||c.granted.split(",").includes(o[0])?1:0:0};return{checkHasPermission:(s,i="every",o)=>{if(!e())return!1;const{checkDependencies:c=!1}=o||{};return typeof s=="string"?a(s,c)!==0:s[i].call(s,u=>a(u,c)!==0)},isGranted:(s,i)=>{if(!e())return!1;const{checkDependencies:o=!1,checkStrategy:c="every"}=i||{};return typeof s=="string"?a(s,o)===1:s[c].call(s,u=>a(u,o)===1)},checkPermissionStatus:a}},lf={loggedUser:null},CI=e=>({...lf,setLoggedUser:t=>{e(r=>({...r,loggedUser:t}))},getLoggedUser:async()=>k4().then(({data:t})=>(e(r=>({...r,loggedUser:t})),t)).catch(t=>(e(r=>({...r,loggedUser:null})),null)),resetLoggedUser:()=>e(lf)}),Ry=Ae()(Be(Oe((...e)=>({...CI(...e)}),{name:"logged-user-storage",getStorage:()=>me}),{name:"logged-user-storage",enabled:!1,anonymousActionType:"zustand"})),Ny={uuid:"",rfc:"",businessName:"",address:"",extNumber:"",intNumber:"",district:"",city:"",county:"",state:"",country:"",zipCode:"",use:""},df={account:{uuid:"",email:"",gender:0,address:{street:"",intNumber:"",extNumber:"",district:"",city:"",state:"",zipCode:"",reference:"",county:"",lat:0,lon:0},country:"",imageUrl:"",lastName:"",birthDate:"",firstName:"",countryCode:"",phoneNumber:"",isUpdatingLogo:!1},invoiceInfo:{list:[],predeterminate:Ny}},SI=(e,t)=>({...df,getAccount:async()=>XA().then(r=>r&&r.status===200?(e(n=>({...n,account:{...n.account,...r.data}})),!0):!1),editAccount:async r=>JA(r).then(n=>n&&n.status===200?(e(a=>({...a,account:{...a.account,...r}})),{status:200,code:0,message:""}):{status:n.response.status,code:n.response.data.code,message:n.response.data.message}),editAccountLogo:async(r,n)=>(e(a=>({...a,account:{...a.account,isUpdatingLogo:!0}})),eI(r).then(a=>a&&(a.status===200||a.status===204)?(e(s=>({...s,account:{...s.account,imageUrl:n,isUpdatingLogo:!1}})),!0):(e(s=>({...s,account:{...s.account,isUpdatingLogo:!1}})),!1))),changePassword:async r=>tI(r).then(n=>!!(n&&n.status===200)),sendRecoveryMail:async r=>rI(r).then(n=>!!(n&&n.status===201)),completeChangePassword:async(r,n)=>nI(r,n).then(a=>a&&a.status===200?{status:!0,action:""}:a.response.status===403?{status:!1,action:"redirect"}:{status:!1,action:""}),getInvoiceInfo:async()=>aI().then(r=>r&&r.status===200?(e(n=>({...n,invoiceInfo:{...n.invoiceInfo,list:[...r.data]}})),!0):!1),addInvoiceInfo:async r=>sI(r).then(async n=>{if(n&&n.status===201){const a=t().invoiceInfo.list,s=t().setPredeterminateInvoice;return e(i=>({...i,invoiceInfo:{list:[r,...i.invoiceInfo.list],predeterminate:a.length===0?r:i.invoiceInfo.predeterminate}})),a.length===0&&await s(r),{status:201,code:0,message:""}}return{status:n.response.status,code:n.response.data.code,message:n.response.data.message}}),setPredeterminateInvoice:async r=>r.predetermined?!0:cI(r.uuid?r.uuid:"").then(n=>n&&n.status===200?(e(a=>({...a,invoiceInfo:{predeterminate:r,list:a.invoiceInfo.list.map(s=>(s.uuid===r.uuid?s.predetermined=!0:s.predetermined=!1,s))}})),!0):!1),editInvoice:async r=>iI(r).then(n=>n&&n.status===200?(e(a=>({...a,invoiceInfo:{...a.invoiceInfo,list:a.invoiceInfo.list.map(s=>(r.uuid===s.uuid&&(s={...s,...r}),s))}})),{status:200,code:0,message:""}):{status:n.response.status,code:n.response.data.code,message:n.response.data.message}),deleteInvoice:async r=>oI(r).then(n=>n&&n.status===200?(e(a=>{let s=!1;return a.invoiceInfo.predeterminate.uuid===r&&(s=!0),{...a,invoiceInfo:{list:a.invoiceInfo.list.filter(i=>i.uuid!==r),predeterminate:s?Ny:a.invoiceInfo.predeterminate}}}),!0):!1),resendValidationMail:async()=>hI().then(r=>r&&r.status===200?(e(n=>({...n,account:{...n.account,...r.data}})),!0):!1),resetAccount:()=>e(df)}),EI=Ae()(Be(Oe((...e)=>({...SI(...e)}),{name:"account-storage",getStorage:()=>me}),{name:"account-storage",enabled:!1,anonymousActionType:"zustand"})),hf={selectedAgent:null,agent:{documentAgent:null}},xI=e=>({...hf,setSelectedAgent:t=>{e(r=>({...r,selectedAgent:t,agent:{documentAgent:t?{uuid:t.uuid,type:t.type,name:t.name,priceNumber:t.priceNumber,withHoldTaxes:!1}:null}}))},resetAgentSales:()=>e(hf)}),wI=Ae()(Be(Oe((...e)=>({...xI(...e)}),{name:"agent-sale-storage",getStorage:()=>me}),{name:"agent-sale-storage",enabled:!1,anonymousActionType:"zustand"})),pf={endpoints:[]},TI=(e,t)=>({...pf,setEndpointCache:r=>e(n=>{const a=[...t().endpoints],s=a.findIndex(i=>i.path===r.path);return s===-1?a.push(r):a[s].checksum=r.checksum,{...n,endpoints:[...a]}}),getEndpointCache:r=>t().endpoints.find(n=>n.path===r),printAllCache:()=>console.log(t().endpoints),resetCache:()=>e(pf)}),Nl=Ae()(Be(Oe((...e)=>({...TI(...e)}),{name:"cache-storage",getStorage:()=>me}),{name:"cache-storage",enabled:!1,anonymousActionType:"zustand"})),$I=e=>({cartStore:[],updateCartList:t=>{e(r=>({...r,cartStore:t}))},resetCartList:()=>{e({cartStore:[]})}}),AI=Ae()(Be(Oe((...e)=>({...$I(...e)}),{name:"cart-list-storage",getStorage:()=>me}),{name:"cart-list-storage",enabled:!1,anonymousActionType:"zustand"})),ff={cashRegisterSales:{flag:!1,type:0,cashMov:{uuid:"",cashRegister:"",amount:"",comment:"",exchangeRate:"",isoCurrency:"",paymentId:"",movType:1,user:"",date:0},cashCut:{folio:"",date:0}}},II=e=>({...ff,setCashMov:async t=>e(r=>({...r,cashRegisterSales:{...r.cashRegisterSales,cashMov:{...r.cashRegisterSales.cashMov,...t}}})),setCashCut:async t=>e(r=>({...r,cashRegisterSales:{...r.cashRegisterSales,cashCut:{...r.cashRegisterSales.cashCut,...t}}})),setCashRegisterSales:async t=>e(r=>({...r,cashRegisterSales:{...r.cashRegisterSales,...t}})),resetCashRegisterSales:()=>e(ff)}),PI=Ae()(Be(Oe((...e)=>({...II(...e)}),{name:"cash-register-sales-storage",getStorage:()=>me}),{name:"cash-register-sales-storage",enabled:!1,anonymousActionType:"zustand"})),_I=e=>({catalogStore:[],favoriteStore:void 0,catalogLastPagination:[],updateCatalogList:t=>{e(r=>({...r,catalogStore:t}))},updateFavoriteList:t=>{e(r=>({...r,favoriteStore:t}))},updateLastPagination:t=>{e(r=>({...r,catalogLastPagination:t}))},resetCatalogList:()=>{e({catalogStore:[],catalogLastPagination:[],favoriteStore:void 0})}}),DI=Ae()((...e)=>({..._I(...e)}));function RI(e){const t=NI(e);if(!t)return;const r={...gf};return Object.keys(gf).find(n=>r[n]===t)}function NI(e){const t={...BI};return Object.keys(t).find(r=>t[r]===e)}const By={AD:"EUR",AE:"AED",AF:"AFN",AG:"XCD",AI:"XCD",AL:"ALL",AM:"AMD",AO:"AOA",AQ:"USD",AR:"ARS",AS:"USD",AT:"EUR",AU:"AUD",AW:"AWG",AX:"EUR",AZ:"AZN",BA:"BAM",BB:"BBD",BD:"BDT",BE:"EUR",BF:"XOF",BG:"BGN",BH:"BHD",BI:"BIF",BJ:"XOF",BL:"EUR",BM:"BMD",BN:"BND",BO:"BOB",BQ:"USD",BR:"BRL",BS:"BSD",BT:"BTN",BV:"NOK",BW:"BWP",BY:"BYN",BZ:"BZD",CA:"CAD",CC:"AUD",CD:"CDF",CF:"XAF",CG:"CDF",CH:"CHF",CI:"XOF",CK:"NZD",CL:"CLP",CM:"XAF",CN:"CNY",CO:"COP",CR:"CRC",CU:"CUC",CV:"CVE",CW:"ANG",CX:"AUD",CY:"EUR",CZ:"CZK",DE:"EUR",DJ:"DJF",DK:"DKK",DO:"DOP",DZ:"DZD",EC:"USD",EE:"EUR",EG:"EGP",EH:"MAD",ER:"ERN",ES:"EUR",ET:"ETB",FI:"EUR",FJ:"FJD",FK:"FKP",FM:"USD",FO:"DKK",FR:"EUR",GA:"XAF",GB:"GBP",GD:"XCD",GE:"GEL",GF:"EUR",GG:"GBP",GH:"GHS",GI:"GIP",GL:"DKK",GM:"GMD",GN:"GNF",GP:"EUR",GQ:"XAF",GR:"EUR",GS:"GEL",GT:"GTQ",GU:"USD",GW:"XOF",GY:"GYD",HK:"HKD",HM:"AUD",HN:"HNL",HR:"HRK",HT:"HTG",HU:"HUF",ID:"IDR",IE:"EUR",IL:"ILS",IM:"GBP",IN:"INR",IO:"USD",IQ:"IQD",IR:"IRR",IS:"ISK",IT:"EUR",JE:"GBP",JM:"JMD",JO:"JOD",JP:"JPY",KE:"KES",KG:"KGS",KH:"KHR",KI:"AUD",KM:"KMF",KN:"XCD",KP:"KPW",KR:"KRW",KW:"KWD",KY:"KYD",KZ:"KZT",LA:"LAK",LB:"LBP",LC:"XCD",LI:"CHF",LK:"LKR",LR:"LRD",LS:"LSL",LT:"EUR",LU:"EUR",LV:"EUR",LY:"LYD",MA:"MAD",MC:"EUR",MD:"MDL",ME:"EUR",MF:"EUR",MG:"MGA",MH:"USD",MK:"MKD",ML:"XOF",MM:"MMK",MN:"MNT",MO:"MOP",MP:"USD",MQ:"EUR",MR:"MRU",MS:"XCD",MT:"EUR",MU:"MUR",MV:"MVR",MW:"MWK",MX:"MXN",MY:"MYR",MZ:"MZN",NA:"NAD",NC:"XPF",NE:"NGN",NF:"AUD",NG:"NGN",NI:"NIO",NL:"EUR",NO:"NOK",NP:"NPR",NR:"AUD",NU:"NZD",NZ:"NZD",OM:"OMR",PA:"PAB",PE:"PEN",PF:"XPF",PG:"PGK",PH:"PHP",PK:"PKR",PL:"PLN",PM:"EUR",PN:"NZD",PR:"USD",PS:"ILS",PT:"EUR",PW:"USD",PY:"PYG",QA:"QAR",RE:"EUR",RO:"RON",RS:"RSD",RU:"RUB",RW:"RWF",SA:"SAR",SB:"SBD",SC:"SCR",SD:"SDG",SE:"SEK",SG:"SGD",SH:"SHP",SI:"EUR",SJ:"NOK",SK:"EUR",SL:"SLL",SM:"EUR",SN:"XOF",SO:"SOS",SR:"SRD",SS:"SSP",ST:"STN",SV:"SVC",SX:"ANG",SY:"SYP",SZ:"SZL",TC:"USD",TD:"XAF",TF:"EUR",TG:"XOF",TH:"THB",TJ:"TJS",TK:"NZD",TL:"USD",TM:"TMT",TN:"TND",TO:"TOP",TR:"TRY",TT:"TTD",TV:"AUD",TW:"TWD",TZ:"TZS",UA:"UAH",UG:"UGX",UM:"USD",US:"USD",UY:"UYI",UZ:"UZS",VA:"EUR",VC:"XCD",VE:"VES",VG:"USD",VI:"USD",VN:"VND",VU:"VUV",WF:"XPF",WS:"USD",YE:"YER",YT:"EUR",ZA:"ZAR",ZM:"ZMW",ZW:"ZWL"},gf={"ar-DZ":"DZ","ar-BH":"BH","ar-EG":"EG","ar-IQ":"IQ","ar-JO":"JO","ar-KW":"KW","ar-LB":"LB","ar-LY":"LY","ar-MA":"MA","ar-OM":"OM","ar-QA":"QA","ar-SA":"SA","ar-SY":"SY","ar-TN":"TN","ar-AE":"AE","ar-YE":"YE","az-AZ":"AZ","zh-CN":"CN","zh-HK":"HK","zh-MO":"MO","zh-SG":"SG","zh-TW":"TW","nl-BE":"BE","nl-NL":"NL","en-AU":"AU","en-BZ":"BZ","en-CA":"CA","en-GB":"GB","en-IN":"IN","en-IE":"IE","en-JM":"JM","en-NZ":"NZ","en-PH":"PH","en-ZA":"ZA","en-TT":"TT","en-US":"US","fr-BE":"BE","fr-CA":"CA","fr-FR":"FR","fr-LU":"LU","fr-CH":"CH","gd-IE":"IE","de-AT":"AT","de-DE":"DE","de-LI":"LI","de-LU":"LU","de-CH":"CH","it-IT":"IT","it-CH":"CH","ms-BN":"BN","ms-MY":"MY","no-NO":"NO","pt-BR":"BR","pt-PT":"PT","ro-MO":"MO","ru-MO":"MO","sr-SP":"SP","es-AR":"AR","es-BO":"BO","es-CL":"CL","es-CO":"CO","es-CU":"CU","es-CR":"CR","es-DO":"DO","es-EC":"EC","es-SV":"SV","es-GT":"GT","es-HN":"HN","es-MX":"MX","es-NI":"NI","es-PA":"PA","es-PY":"PY","es-PE":"PE","es-PR":"PR","es-ES":"ES","es-UY":"UY","es-VE":"VE","sv-FI":"FI","sv-SE":"SE","uz-UZ":"UZ"},BI={AE:"AED",AR:"ARS",AT:"EUR",AU:"AUD",AZ:"AZN",BE:"EUR",BH:"BHD",BN:"BND",BO:"BOB",BR:"BRL",BZ:"BZD",CA:"CAD",CH:"CHF",CL:"CLP",CN:"CNY",CO:"COP",CU:"CUP",CR:"CRC",DE:"EUR",DO:"DOP",DZ:"DZD",EC:"USD",EG:"EGP",ES:"EUR",FI:"EUR",FR:"EUR",GB:"GBP",GT:"GTQ",HK:"HKD",HN:"HNL",IE:"EUR",IN:"INR",IQ:"IQD",IT:"EUR",JM:"JMD",JO:"JOD",KW:"KWD",LB:"LBP",LI:"CHF",LU:"EUR",LY:"LYD",MA:"MAD",MO:"MOP",MX:"MXN",MY:"MYR",NI:"NIO",NL:"EUR",NO:"NOK",NZ:"NZD",OM:"OMR",PA:"PAB",PE:"PEN",PH:"PHP",PR:"USD",PT:"EUR",PY:"PYG",QA:"QAR",SA:"SAR",SE:"SEK",SG:"SGD",SV:"SVC",SY:"SYP",TN:"TND",TT:"TTD",TW:"TWD",US:"USD",UY:"UYU",UZ:"UZS",VE:"VES",YE:"YER",ZA:"ZAR"},kI=[{iso:"aa",language:"afar"},{iso:"ab",language:"abjasio"},{iso:"ae",language:"avéstico"},{iso:"af",language:"afrikáans"},{iso:"ak",language:"akano"},{iso:"am",language:"amhárico"},{iso:"an",language:"aragonés"},{iso:"ar",language:"árabe"},{iso:"as",language:"asamés"},{iso:"av",language:"avar"},{iso:"ay",language:"aimara"},{iso:"az",language:"azerí"},{iso:"ba",language:"baskir"},{iso:"be",language:"bielorruso"},{iso:"bg",language:"búlgaro"},{iso:"bh",language:"bhoyapurí"},{iso:"bi",language:"bislama"},{iso:"bm",language:"bambara"},{iso:"bn",language:"bengalí"},{iso:"bo",language:"tibetano"},{iso:"br",language:"bretón"},{iso:"bs",language:"bosnio"},{iso:"ca",language:"catalán"},{iso:"ce",language:"checheno"},{iso:"ch",language:"chamorro"},{iso:"co",language:"corso"},{iso:"cr",language:"cree"},{iso:"cs",language:"checo"},{iso:"cu",language:"eslavo eclesiástico antiguo"},{iso:"cv",language:"chuvasio"},{iso:"cy",language:"galés"},{iso:"da",language:"danés"},{iso:"de",language:"alemán"},{iso:"dv",language:"maldivo"},{iso:"dz",language:"dzongkha"},{iso:"ee",language:"ewé"},{iso:"el",language:"griego"},{iso:"en",language:"inglés"},{iso:"eo",language:"esperanto"},{iso:"es",language:"español"},{iso:"et",language:"estonio"},{iso:"eu",language:"euskera"},{iso:"fa",language:"persa"},{iso:"ff",language:"fula"},{iso:"fi",language:"finés"},{iso:"fj",language:"fiyiano"},{iso:"fo",language:"feroés"},{iso:"fr",language:"francés"},{iso:"fy",language:"frisón"},{iso:"ga",language:"irlandés"},{iso:"gd",language:"gaélico escocés"},{iso:"gl",language:"gallego"},{iso:"gn",language:"guaraní"},{iso:"gu",language:"guyaratí"},{iso:"gv",language:"manés"},{iso:"ha",language:"hausa"},{iso:"he",language:"hebreo"},{iso:"hi",language:"hindi"},{iso:"ho",language:"hiri motu"},{iso:"hr",language:"croata"},{iso:"ht",language:"haitiano"},{iso:"hu",language:"húngaro"},{iso:"hy",language:"armenio"},{iso:"hz",language:"herero"},{iso:"ia",language:"interlingua"},{iso:"id",language:"indonesio"},{iso:"ie",language:"occidental"},{iso:"ig",language:"igbo"},{iso:"ii",language:"yi de Sichuán"},{iso:"ik",language:"iñupiaq"},{iso:"io",language:"ido"},{iso:"is",language:"islandés"},{iso:"it",language:"italiano"},{iso:"iu",language:"inuktitut"},{iso:"ja",language:"japonés"},{iso:"jv",language:"javanés"},{iso:"ka",language:"georgiano"},{iso:"kg",language:"kongo"},{iso:"ki",language:"kikuyu"},{iso:"kj",language:"kuanyama"},{iso:"kk",language:"kazajo"},{iso:"kl",language:"groenlandés"},{iso:"km",language:"camboyano"},{iso:"kn",language:"canarés"},{iso:"ko",language:"coreano"},{iso:"kr",language:"kanuri"},{iso:"ks",language:"cachemiro"},{iso:"ku",language:"kurdo"},{iso:"kv",language:"komi"},{iso:"kw",language:"córnico"},{iso:"ky",language:"kirguís"},{iso:"la",language:"latín"},{iso:"lb",language:"luxemburgués"},{iso:"lg",language:"luganda"},{iso:"li",language:"limburgués"},{iso:"ln",language:"lingala"},{iso:"lo",language:"lao"},{iso:"lt",language:"lituano"},{iso:"lu",language:"luba-katanga"},{iso:"lv",language:"letón"},{iso:"mg",language:"malgache"},{iso:"mh",language:"marshalés"},{iso:"mi",language:"maorí"},{iso:"mk",language:"macedonio"},{iso:"ml",language:"malayalam"},{iso:"mn",language:"mongol"},{iso:"mr",language:"maratí"},{iso:"ms",language:"malayo"},{iso:"mt",language:"maltés"},{iso:"my",language:"birmano"},{iso:"na",language:"nauruano"},{iso:"nb",language:"noruego bokmål"},{iso:"nd",language:"ndebele del norte"},{iso:"ne",language:"nepalí"},{iso:"ng",language:"ndonga"},{iso:"nl",language:"neerlandés"},{iso:"nn",language:"nynorsk"},{iso:"no",language:"noruego"},{iso:"nr",language:"ndebele del sur"},{iso:"nv",language:"navajo"},{iso:"ny",language:"chichewa"},{iso:"oc",language:"occitano"},{iso:"oj",language:"ojibwa"},{iso:"om",language:"oromo"},{iso:"or",language:"oriya"},{iso:"os",language:"osético"},{iso:"pa",language:"panyabí"},{iso:"pi",language:"pali"},{iso:"pl",language:"polaco"},{iso:"ps",language:"pastú"},{iso:"pt",language:"portugués"},{iso:"qu",language:"quechua"},{iso:"rm",language:"romanche"},{iso:"rn",language:"kirundi"},{iso:"ro",language:"rumano"},{iso:"ru",language:"ruso"},{iso:"rw",language:"ruandés"},{iso:"sa",language:"sánscrito"},{iso:"sc",language:"sardo"},{iso:"sd",language:"sindhi"},{iso:"se",language:"sami septentrional"},{iso:"sg",language:"sango"},{iso:"si",language:"cingalés"},{iso:"sk",language:"eslovaco"},{iso:"sl",language:"esloveno"},{iso:"sm",language:"samoano"},{iso:"sn",language:"shona"},{iso:"so",language:"somalí"},{iso:"sq",language:"albanés"},{iso:"sr",language:"serbio"},{iso:"ss",language:"suazi"},{iso:"st",language:"sesotho"},{iso:"su",language:"sundanés"},{iso:"sv",language:"sueco"},{iso:"sw",language:"suajili"},{iso:"ta",language:"tamil"},{iso:"te",language:"télugu"},{iso:"tg",language:"tayiko"},{iso:"th",language:"tailandés"},{iso:"ti",language:"tigriña"},{iso:"tk",language:"turcomano"},{iso:"tl",language:"tagalo"},{iso:"tn",language:"setsuana"},{iso:"to",language:"tongano"},{iso:"tr",language:"turco"},{iso:"ts",language:"tsonga"},{iso:"tt",language:"tártaro"},{iso:"tw",language:"twi"},{iso:"ty",language:"tahitiano"},{iso:"ug",language:"uigur"},{iso:"uk",language:"ucraniano"},{iso:"ur",language:"urdu"},{iso:"uz",language:"uzbeko"},{iso:"ve",language:"venda"},{iso:"vi",language:"vietnamita"},{iso:"vo",language:"volapük"},{iso:"wa",language:"valón"},{iso:"wo",language:"wolof"},{iso:"xh",language:"xhosa"},{iso:"yi",language:"yídish"},{iso:"yo",language:"yoruba"},{iso:"za",language:"chuan"},{iso:"zh",language:"chino"},{iso:"zu",language:"zulú"}],mf={catalogue:{currencies:[],countries:[],businessType:[],useCfdiList:[],regimes:[]}},OI=(e,t)=>({...mf,getLanguages:()=>kI,getIsoCurrency:r=>By[r],getCountries:()=>t().catalogue.countries,getCountries2:async r=>{const n=await S$(r);return n.status==200?(e(a=>({...a,catalogue:{...a.catalogue,countries:[...n.data]}})),n.data):[]},getSatCatalogueUseType:async(r,n)=>C$(r,n||0).then(a=>a&&a.status===200?(e(s=>({...s,catalogue:{...s.catalogue,[`${r}List`]:n==0||n===void 0?[...a.data]:[...s.catalogue[`${r}List`],...a.data]}})),!0):!1),getBusinessType:async r=>E$(r).then(n=>n&&n.status===200?(e(a=>({...a,catalogue:{...a.catalogue,businessType:[...n.data]}})),!0):!1),getRegimes:async()=>x$().then(r=>r&&r.status===200?(e(n=>({...n,catalogue:{...n.catalogue,regimes:[...r.data]}})),!0):!1),resetCatalogue:()=>e(mf)}),UI=Ae()((...e)=>({...OI(...e)})),yf={collapsedGrid:{collapsed:!1}},LI=e=>({...yf,setCollapsed:t=>e(r=>({...r,collapsedGrid:{collapsed:t}})),resetCollapsed:()=>e(yf)}),MI=Ae()((...e)=>({...LI(...e)})),vf={drawer:{open:!1,pinned:!1}},jI=e=>({...vf,drawerOpen:t=>{e(r=>({...r,drawer:{...r.drawer,open:t}}))},drawerPinned:t=>{e(r=>({...r,drawer:{...r.drawer,pinned:t}}))},resetDrawer:()=>e(vf)}),ky=Ae()((...e)=>({...jI(...e)})),bf={printerProfile:{isDelete:!1}},FI=e=>({...bf,setProfileIsDelete:t=>{e(r=>({...r,printerProfile:{...r,isDelete:t}}))},resetDeleteProfile:()=>e(bf)}),qI=Ae()(Be(Oe((...e)=>({...FI(...e)}),{name:"flag-storage",getStorage:()=>me}),{name:"flag-storage",enabled:!1,anonymousActionType:"zustand"})),Cf={feedback:{open:!1}},HI=e=>({...Cf,openFeedback(){e(t=>({...t,feedback:{...t.feedback,open:!0}}))},closeFeedback(){e(t=>({...t,feedback:{...t.feedback,open:!1}}))},resetFeedback(){e(Cf)}}),KI=Ae()((...e)=>({...HI(...e)})),Sf={hardware:{scale:!1,miniprint:!1}},VI=e=>({...Sf,setHardware:(t,r)=>{e(n=>({...n,hardware:{...n.hardware,[t]:r}}))},resetHardware:()=>e(Sf)}),zI=Ae()(Be(Oe((...e)=>({...VI(...e)}),{name:"hardware-storage",getStorage:()=>me}),{name:"hardware-storage",enabled:!1,anonymousActionType:"zustand"})),GI=(e,t)=>{const r=`?dateRange=${encodeURIComponent(e)}&timeZone=${t}`;return new Promise(n=>{Q(`https://us-central1-sx-production.cloudfunctions.net/history/v1/account${r}`).then(a=>n(a)).catch(a=>n(a))})},Ef={accountHistorySessions:[]},QI=e=>({...Ef,getAccountHistorySessions:async(t,r)=>GI(t,r).then(n=>n&&(n.status===200||n.status===204)?(console.log(n.headers),e(a=>({...a,accountHistorySessions:n.status===204?[]:n.data})),!0):(e(a=>({...a,accountHistorySessions:[]})),!1)),resetHistory:()=>e(Ef)}),WI=Ae()(Be(Oe((...e)=>({...QI(...e)}),{name:"history-storage",getStorage:()=>me}),{name:"history-storage",enabled:!1,anonymousActionType:"zustand"})),xf={loader:{open:!1,transparent:!1}},ZI=e=>({...xf,showLoader:t=>{e(r=>({...r,loader:{...r.loader,...typeof t=="boolean"?{open:t}:t}}))},resetLoader:()=>e(xf)}),Oy=Ae()((...e)=>({...ZI(...e)})),YI=(e,t)=>new Promise(r=>{J(`${window.location.origin}/api/mitec/crypt`,{type:e,deen:t}).then(n=>r(n)).catch(n=>r(n))}),XI=()=>new Promise(e=>{Q(`${Ra}/operation/params`).then(t=>e(t)).catch(t=>e(t))}),JI=()=>new Promise(e=>{Q(`${Ra}/subtrade/mccList`).then(t=>e(t)).catch(t=>e(t))}),e3=()=>new Promise(e=>{Q(`${Ra}/payment/types`).then(t=>e(t)).catch(t=>e(t))}),t3=e=>new Promise(t=>{J(`${Ra}/payment/url`,e).then(r=>t(r)).catch(r=>t(r))}),r3=e=>new Promise(t=>{J(`${Ra}/payment/url/refound`,e).then(r=>t(r)).catch(r=>t(r))}),n3=(e,t,r)=>new Promise(n=>{Q(`${Ra}/mitecResponse/list?startDate=${e}&endDate=${t}&limit=${r}`).then(a=>n(a)).catch(a=>n(a))}),a3=(e,t)=>new Promise(r=>{Q(`${Ra}/mitecResponse/list/nextPage?offset=${encodeURIComponent(e)}&limit=${t}`).then(n=>r(n)).catch(n=>r(n))}),wf={mitec:{businessId:0,businessType:[],paymentTypes:[]}},s3=e=>({...wf,getBusinessTypeMitec:async()=>JI().then(t=>t&&t.status===200?(e(r=>({...r,mitec:{...r.mitec,businessType:t.data}})),!0):!1),getPaymentTypes:async()=>e3().then(t=>t&&t.status===200?(e(r=>({...r,mitec:{...r.mitec,paymentTypes:t.data}})),!0):!1),generatePaymentUrl:async t=>t3(t).then(r=>r&&r.status===200?r.data:null),getOperationParams:async()=>XI().then(t=>t&&t.status===200?YI("de",t.data).then(r=>{if(r.data){const n=JSON.parse(r.data.data);return e(a=>({...a,mitec:{...a.mitec,businessId:n.businessId}})),n}return null}):null),getMitecPaymentsList:async(t,r,n)=>n3(t,r,n).then(a=>a&&a.status===200?{contentRange:a.headers["content-range"],data:a.data}:{contentRange:null,data:[]}),getNextPageMitecPaymentsList:async(t,r)=>a3(t,r).then(n=>n&&n.status===200?{contentRange:n.headers["content-range"],data:n.data}:{contentRange:null,data:[]}),refoundPayment:async t=>r3(t).then(r=>r&&r.status===200?r.data:{code:null,message:"Operación fallida"}),resetMitec:()=>e(wf)}),i3=Ae()(Be(Oe((...e)=>({...s3(...e)}),{name:"mitec-storage",getStorage:()=>me}),{name:"mitec-storage",enabled:!1,anonymousActionType:"zustand"})),Tf={document_queries:{sales:{filtersComponent:void 0,totalFiltersComponent:0,filters:{startDate:"",endDate:"",timeZone:"",dateField:"CREATION",agentUuid:"",sellerUuid:"",userUuid:"",serie:"0",status:"0",isoCurrency:"",productUuid:"",cashRegisterUuid:"",discount:void 0,paymentId:0,search:"",dateSelector:0},list:[],loaded:!1,loading:!1,contentRange:"",totalCount:0,requestId:"",sale:{uuid:"",detail:{uuid:"",type:"",decimals:0,serie:"0",comment:"",mainIsoCurrency:"",isoCurrency:"MXN",exchangeRate:0,total:0,folio:0,serieFolio:"",creationDate:0,documentDate:0,timeZone:"",opMode:"",status:0,userUuid:"",cancellationDate:0,cancellationUser:"",cancellationComment:"",agent:{withholdTaxes:!0,name:"",uuid:""},employee:{name:"",uuid:""},products:[],subtotal:0,taxes:[],cashRegisterUuid:"",payments:[],change:{exchangeRate:0,isoCurrency:"",convertedAmount:0,paymentId:0,amount:0},discount:0,discountTax:0,discountPercentage:0}}},invoices:{filtersComponent:void 0,totalFiltersComponent:0,filters:{startDate:"",endDate:"",timeZone:"",dateField:"CREATION",agentUuid:"",sellerUuid:"",userUuid:"",serie:"0",status:"0",isoCurrency:"",productUuid:"",cashRegisterUuid:"",discount:void 0,paymentId:0,search:"",dateSelector:0},list:[],loaded:!1,loading:!1,contentRange:"",totalCount:0,requestId:"",invoice:{uuid:"",detail:{contentId:0,branchId:0,type:"",uuid:"",serie:"",folio:0,serieFolio:"",date:"",documentDate:"",userAccount:"",userUuid:"",userAlias:"",agentUuid:"",agentName:"",employeeUuid:"",employeeName:"",total:0,isoCurrency:"",status:"",predPaymentId:"",cancellationDate:"",cancellationUserAccount:"",cancellationUserUuid:"",cancellationUserAlias:"",cancellationComment:"",timeZone:"",discountPercentage:0,mainIsoCurrency:"",totalMc:0,products:[],payments:[],cashRegisters:[],ieps:!1,withholdingTax:!1,posWithholding:!1,discount:0,discountTax:0,discountApplied:!1,subtotal:0,subtotalGeneral:0,cost:0,costTax:0,profit:0,profitTax:0,exchangeRate:0,subtotalMc:0,subtotalGeneralMc:0,discountMc:0,discountTaxMc:0,costMc:0,costTaxMc:0,profitMc:0,profitTaxMc:0,profitMargin:0,profitPercentage:0,profitMarginTax:0,profitPercentageTax:0,createdHis:"",userAccountHis:"",userUuidHis:"",userAliasHis:"",pk:"",sk:"",genDocUrl:"",oriDocUrl:"",cfdiXmlUrl:"",invoiceImplementation:"",version:0}}},cashRegisterBalancing:{cashRegister:{},contentRange:"",filters:{balanceDiff:"",cashRegisterUuid:"",dateField:"",dateSelector:0,endDate:"",folio:"",isoCurrency:"",startDate:"",timeZone:"",userUuid:""},filtersComponent:void 0,totalFiltersComponent:0,list:[],loaded:!1,loading:!1,requestId:"",totalCount:0}}},o3=e=>({...Tf,setSalesQueries:async t=>e(r=>({...r,document_queries:{...r.document_queries,sales:{...r.document_queries.sales,...t}}})),setFilterSales:async t=>e(r=>({...r,document_queries:{...r.document_queries,sales:{...r.document_queries.sales,filters:{...r.document_queries.sales.filters,...t}}}})),setSaleDetail:async t=>e(r=>({...r,document_queries:{...r.document_queries,sales:{...r.document_queries.sales,sale:{...r.document_queries.sales.sale,...t}}}})),setCashRegisterBalancingQueries:async t=>e(r=>({...r,document_queries:{...r.document_queries,cashRegisterBalancing:{...r.document_queries.cashRegisterBalancing,...t}}})),setFilterCashRegisterBalancing:async t=>e(r=>({...r,document_queries:{...r.document_queries,cashRegisterBalancing:{...r.document_queries.cashRegisterBalancing,filters:{...r.document_queries.cashRegisterBalancing.filters,...t}}}})),setCashRegisterBalancingDetail:async t=>e(r=>({...r,document_queries:{...r.document_queries,cashRegisterBalancing:{...r.document_queries.cashRegisterBalancing,cashRegister:{...r.document_queries.cashRegisterBalancing.cashRegister,...t}}}})),setInvoicesQueries:async t=>e(r=>({...r,document_queries:{...r.document_queries,invoices:{...r.document_queries.invoices,...t}}})),setFilterInvoices:async t=>e(r=>({...r,document_queries:{...r.document_queries,invoices:{...r.document_queries.invoices,filters:{...r.document_queries.invoices.filters,...t}}}})),setInvoiceDetail:async t=>e(r=>({...r,document_queries:{...r.document_queries,invoices:{...r.document_queries.invoices,invoice:{...r.document_queries.invoices.invoice,...t}}}})),resetQueries:()=>e(Tf)}),c3=Ae()(Be(Oe((...e)=>({...o3(...e)}),{name:"queries-storage",getStorage:()=>me}),{name:"queries-storage",enabled:!1,anonymousActionType:"zustand"})),$f={sales:{loading:!1,loaded:!1,refresh:!1,filters:{startDate:"",endDate:"",timeZone:"",dateField:"CREATION",agent:{},seller:{},user:{},serie:{},status:{},isoCurrency:{},discount:{},payment:{},paymentType:{},branchs:{},warehouse:{},search:"",dateSelector:0,withProfit:!1,withTaxes:!0,selecteds:0},list:[],summary:{cost:0,discount:0,profit:0,subtotal:0,total:0},contentRange:"",totalCount:0,requestId:""},setSalesReportsQueries:async()=>{},setFilterSalesReports:async()=>{},resetSalesReports:()=>{}},u3=(e,t)=>({...$f,setSalesReportsQueries:async r=>e(n=>({sales:{...n.sales,...r}})),setFilterSalesReports:async r=>e(n=>({sales:{...n.sales,filters:{...n.sales.filters,...r}}})),resetSalesReports:()=>e({sales:$f.sales})}),l3=Ae()(Be(Oe((...e)=>({...u3(...e)}),{name:"sales-reports-storage",getStorage:()=>me}),{name:"sales-reports-storage",enabled:!1,anonymousActionType:"zustand"})),Af={salesUtilities:{loading:!1,loaded:!1,refresh:!1,filters:{startDate:"",endDate:"",timeZone:"",dateField:"CREATION",agent:{},seller:{},user:{},serie:{},status:{},isoCurrency:{},discount:{},branchs:{},warehouse:{},payment:{},documentType:{},search:"",dateSelector:0,withProfit:!0,withTaxes:!0,selecteds:0},list:[],summary:{cost:0,discount:0,profit:0,subtotal:0,total:0},contentRange:"",totalCount:0,requestId:""},setSalesUtilitiesReportsQueries:async()=>{},setFilterSalesUtilitiesReports:async()=>{},resetSalesUtilitiesReports:()=>{}},d3=e=>({...Af,setSalesUtilitiesReportsQueries:async t=>e(r=>({salesUtilities:{...r.salesUtilities,...t}})),setFilterSalesUtilitiesReports:async t=>e(r=>({salesUtilities:{...r.salesUtilities,filters:{...r.salesUtilities.filters,...t}}})),resetSalesUtilitiesReports:()=>e({salesUtilities:Af.salesUtilities})}),h3=Ae()(Be(Oe((...e)=>({...d3(...e)}),{name:"sales-utilities-reports-storage",getStorage:()=>me}),{name:"sales-utilities-reports-storage",enabled:!1,anonymousActionType:"zustand"})),p3=(e,t)=>({lastSale:void 0,setLastSale:r=>{e(n=>({...n,lastSale:r}))},resetLastSale:()=>{e({lastSale:void 0})}}),f3=Ae()((...e)=>({...p3(...e)})),g3={multiSelected:!1,listMultiSelected:[],catalog:void 0,modeSearch:0,begin:!1,departmentsSelected:{name:"",order:0,uuid:""},categoriesSelected:{name:"",uuid:""},search:void 0,refresh:0,stocksUuid:[],searchRPS:null},m3={UI:g3},y3=(e,t)=>({modified:void 0,...m3,setUI:r=>{e(n=>({...n,UI:r}))},resetUI:(r=!1)=>{let n={multiSelected:!1,listMultiSelected:[],catalog:[],modeSearch:0,begin:!1,departmentsSelected:{name:"",order:0,uuid:""},categoriesSelected:{name:"",uuid:""},search:void 0,refresh:0,stocksUuid:[],searchRPS:null};e(r?{UI:n,modified:void 0}:{UI:n})},isResetCache:async()=>{const{modified:r}=JSON.parse(me.getItem("sales-ui-storage")).state;return new Promise(n=>{G$().then(a=>{var s,i;a.status===200&&((i=(s=a==null?void 0:a.data)==null?void 0:s.selectedPriceList)==null?void 0:i.modified)!==r&&(e(o=>{var c,u;return{...o,modified:(u=(c=a==null?void 0:a.data)==null?void 0:c.selectedPriceList)==null?void 0:u.modified}}),n(!0))})})}}),v3=Ae()((...e)=>({...y3(...e)})),b3=()=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/plans",{method:"GET"}),C3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/subscribe",{body:JSON.stringify(e),method:"POST"}),S3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/cards",{body:JSON.stringify({jwt:e}),method:"POST"}),E3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/storeInfo",{method:"POST",headers:{"Content-Type":"text/plain"},body:e}),x3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/buyStore",{body:JSON.stringify(e),method:"POST"}),cR=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/removeWarehouse",{body:JSON.stringify(e),method:"POST"}),w3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/check",{headers:{"Content-Type":"text/plain"},body:e,method:"POST"}),T3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/quotation",{method:"POST",body:JSON.stringify(e)}),$3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/updateCard",{method:"POST",body:JSON.stringify(e)}),A3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/branchCheck",{headers:{"Content-Type":"text/plain"},body:e,method:"POST"}),I3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/getDetail",{headers:{"Content-Type":"text/plain"},body:e,method:"POST"}),P3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/customerCancel",{method:"POST",body:JSON.stringify(e)}),_3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/buyChips",{method:"POST",body:JSON.stringify(e)}),D3=e=>fetch("https://lwi6mwjtflkdp6vbzipn6yxnq40mqqmj.lambda-url.us-east-1.on.aws/chipsList",{method:"GET",headers:{Authorization:e}}),If={UI:{subscriptionDialog:!1,chipsDialog:!1,buyNewBranch:!1,subscriptionDetails:null,dataForAddNewBranch:{company:null,newBranch:null,base64Image:null}}},R3=(e,t)=>({...If,getPlans:async()=>{const r=await b3();return r&&r.status===200?await r.json():[]},suscribe:async(r,n)=>{const a=await C3(r).catch(s=>(console.log(s),new Response(JSON.stringify({status:s.response.status}))));if(a&&a.status===200)try{const s=await a.json();return s.code===void 0?{created:!0,response:s}:{created:!1,response:s.message}}catch{return{created:!1,response:"operationFailed"}}else return t().checkSubscribe(n)},warehouseInfo:async r=>{const n=await E3(r);if(n&&n.status===200)try{const a=await n.json();return a.code===void 0?{status:"OK",response:a}:{status:"ERROR",response:a.message}}catch{return{status:"ERROR",response:"operationFailed"}}return{status:"ERROR",response:"operationFailed"}},buyWarehouse:async r=>{const n=await x3(r);if(n&&n.status===200)try{const a=await n.json();return a.code===void 0?{created:"OK",response:a}:{created:"ERROR",response:a.message}}catch{return{created:"ERROR",response:"operationFailed"}}return{created:"ERROR",response:"operationFailed"}},handleSubscriptionDialog:r=>e(n=>({...n,UI:{...n.UI,subscriptionDialog:r}})),setBuyNewBranch:r=>e(n=>({...n,UI:{...n.UI,buyNewBranch:r}})),setDateForAddNewBranch:(r,n,a)=>e(s=>({...s,UI:{...s.UI,dataForAddNewBranch:{company:r,newBranch:n,base64Image:a}}})),checkSubscribe:async r=>{const n=await w3(r).catch(a=>(console.log(a),new Response(JSON.stringify({status:a.response.status}))));if(n&&n.status===200)try{const a=await n.json();return a.code===void 0?{created:!0,response:a}:{created:!1,response:a.message}}catch{return{created:!1,response:"operationFailed"}}else return{created:!1,response:"operationFailed"}},quotation:async r=>{const n=await T3(r);if(n&&n.status===200)try{const a=await n.json();return a.code===void 0?{status:"OK",response:a}:{status:"ERROR",response:a.message}}catch{return{status:"ERROR",response:"operationFailed"}}return{status:"ERROR",response:"operationFailed"}},updateCard:async r=>{const n=await $3(r);if(n&&n.status===200)try{const a=await n.json();return a.code===void 0?{status:"OK",response:a}:{status:"ERROR",response:a.message}}catch{return{status:"ERROR",response:"operationFailed"}}return{status:"ERROR",response:"operationFailed"}},branchCheck:async r=>{const n=await A3(r);if(n&&n.status===200)try{const a=await n.json();return a.code===void 0?{status:"OK",response:a}:{status:"ERROR",response:a.message}}catch{return{status:"ERROR",response:"operationFailed"}}return{status:"ERROR",response:"operationFailed"}},setDetails:r=>{e(n=>({...n,UI:{...n.UI,subscriptionDetails:r}}))},getDetail:async r=>{const n=await I3(r);if(n&&n.status===200)try{const a=await n.json();return a.code===void 0?(e(s=>({...s,UI:{...s.UI,subscriptionDetails:a}})),{status:"OK",response:a}):{status:"ERROR",response:a.message}}catch{return{status:"ERROR",response:"operationFailed"}}return{status:"ERROR",response:"operationFailed"}},customerCancel:async r=>{const n=await P3(r);if(n&&n.status===200)try{const a=await n.json();return a.code===void 0?{status:"OK",response:a}:{status:"ERROR",response:a.message}}catch{return{status:"ERROR",response:"operationFailed"}}return{status:"ERROR",response:"operationFailed"}},buyChips:async r=>{try{const n=await _3(r);if(n&&n.status===200){const a=await n.json();return a.status&&a.status==="completed"?{created:!0,response:a}:{created:!1,response:a.message}}return{created:!1,response:"operationFailed"}}catch{return{created:!1,response:"operationFailed"}}},getTimbresList:async r=>{try{const n=await D3(r);return n&&n.status===200?await n.json():[]}catch{return[]}},handleChipsDialog:r=>e(n=>({...n,UI:{...n.UI,chipsDialog:r}})),resetSubscriptionHandler:()=>e(If)}),N3=Ae()(Be(Oe((...e)=>({...R3(...e)}),{name:"subscription-handler-storage",getStorage:()=>me}),{name:"subscription-handler-storage",enabled:!1,anonymousActionType:"zustand"})),B3=()=>new Promise(e=>{Q(hn+"/payments/customer").then(t=>e(t)).catch(t=>e(t))}),k3=()=>new Promise(e=>{Q(`${hn}/payments`).then(t=>e(t)).catch(t=>e(t))}),O3=e=>new Promise(t=>{J(hn+"/payments/customer/card",e).then(r=>t(r)).catch(r=>t(r))}),U3=e=>new Promise(t=>{J(`${hn}/payments/charge/request`,e).then(r=>t(r)).catch(r=>t(r))}),L3=e=>new Promise(t=>{J(`${hn}/payments/charge/store`,e).then(r=>t(r)).catch(r=>t(r))}),M3=e=>new Promise(t=>{J(`${hn}/payments/charge/bank`,e).then(r=>t(r)).catch(r=>t(r))}),j3=(e,t)=>new Promise(r=>{Q(`${hn}/payments/charge/lists?ini=${e}&fin=${t}`).then(n=>r(n)).catch(n=>r(n))}),F3=e=>new Promise(t=>{J(`${hn}/payments`,e).then(r=>t(r)).catch(r=>t(r))}),q3=()=>new Promise(e=>{ft(`${hn}/payments`).then(t=>e(t)).catch(t=>e(t))}),H3=e=>new Promise(t=>{J(`${hn}/payments/charge/refund`,e).then(r=>t(r)).catch(r=>t(r))}),Uy={merchantId:"",location:"",pk:"",sk:""},Pf={subscription:{cards:[],customerId:"",paymentKeys:Uy}},K3=e=>({...Pf,getCards:async t=>S3(t).then(async r=>{if(r&&r.status===200){const n=await r.json();return e(a=>({...a,subscription:{...a.subscription,cards:n}})),!0}return!!(r&&r.status===204)}),getCustomerId:async()=>B3().then(t=>t&&t.status===200?(e(r=>({...r,subscription:{...r.subscription,customerId:t.data}})),!0):!1),addCard:async t=>O3(t).then(async r=>r&&r.status===201?{error:!1,message:""}:{error:!0,message:r?r.response.data.message:"Operación fallida"}),createPaymentLink:async t=>U3(t).then(async r=>r&&r.status===201?r.data:null),createPaymentStore:async t=>L3(t).then(async r=>r&&r.status===201?r.data:null),createPaymentSPEI:async t=>M3(t).then(async r=>r&&r.status===201?r.data:null),getPaymentKeys:async()=>k3().then(t=>t&&t.status===200?(e(r=>({...r,subscription:{...r.subscription,paymentKeys:t.data}})),t.data):null),getOpenPayPaymentsList:async(t,r)=>j3(t,r).then(n=>n&&n.status===200?{data:n.data}:{data:[]}),createPaymentKeys:async t=>F3(t).then(async r=>!!(r&&r.status===201)),deletePaymentKeys:async()=>q3().then(t=>t&&t.status===200?(e(r=>({...r,subscription:{...r.subscription,paymentKeys:Uy}})),!0):!1),refundOpenPayPayment:async t=>H3(t).then(r=>!!(r&&r.status===201)),resetSubscription:()=>e(Pf)}),V3=Ae()(Be(Oe((...e)=>({...K3(...e)}),{name:"subscription-storage",getStorage:()=>me}),{name:"subscription-storage",enabled:!1,anonymousActionType:"zustand"})),z3=()=>new Promise(e=>{Q(`${HC}/tax/list`).then(t=>e(t)).catch(t=>e(t))}),_f={tax:{list:[]}},G3=e=>({..._f,getTaxList:async()=>z3().then(t=>t&&t.status===200?(e(r=>({...r,tax:{list:t.data}})),!0):!!(t&&t.status===204)),resetTax:()=>e(_f)}),Q3=Ae()(Be(Oe((...e)=>({...G3(...e)}),{name:"tax-storage",getStorage:()=>me}),{name:"tax-session-storage",enabled:!1,anonymousActionType:"zustand"})),Df={sales:{loading:!1,loaded:!1,refresh:!1,filters:{startDate:"",endDate:"",timeZone:"",dateField:"CREATION",agent:{},seller:{},user:{},serie:{},status:{},isoCurrency:{},product:{},warehouse:{},cashRegister:{},discount:{},payment:{},search:"",invoiced:{},dateSelector:0,selecteds:0,cfdiCancelStatus:{},creditStatus:{},hasChildDocs:{},childDocsType:{}},list:[],contentRange:"",sale:{id:"",branchId:0,uuid:"",timeZone:"",decimals:0,type:"SALE",serie:"",serieFolio:"",comment:"",mainIsoCurrency:"MXN",isoCurrency:"MXN",exchangeRate:0,opMode:"MX",subtotal:0,total:0,discountTax:0,taxesCfdi:[],discountPercentage:0,documentDate:"",creationDate:"",withholdingTax:0,userAccount:"",userAlias:"",userUuid:"",cancellationDate:"",agent:{uuid:"",name:"",withholdTaxes:!1,key:!1,priceNumber:0,emails:[],address:{street:"",extNumber:"",intNumber:"",district:"",city:"",county:"",state:"",country:"",zipCode:"",reference:""},phoneNumbers:[]},employee:{uuid:"",name:"",email:"",phoneNumbers:[],position:""},products:[],payments:[],loaded:!1,status:"ACTIVE"},saleMetadata:{},totalCount:0,requestId:"",selecteds:0},setSalesQueries:async()=>{},setFilterSales:async()=>{},setSaleDetail:async()=>{},clickSale:async()=>{},clickSelectAll:async()=>{},resetSalesQueries:()=>{}},W3=e=>({...Df,setSalesQueries:async t=>e(r=>({sales:{...r.sales,...t}})),setFilterSales:async t=>e(r=>({sales:{...r.sales,filters:{...r.sales.filters,...t}}})),setSaleDetail:async t=>e(r=>({sales:{...r.sales,sale:{...r.sales.sale,...t}}})),clickSale:async t=>e(r=>{const n=r.sales.list;let a=r.sales.selecteds;const s=r.sales.list.findIndex(i=>i.uuid===t);return n[s].selected?(n[s].selected=!1,a-=1):(n[s].selected=!0,a+=1),{sales:{...r.sales,selecteds:a,list:[...n]}}}),clickSelectAll:async()=>e(t=>{const r=t.sales.list;return r.every(n=>n.selected===!0)?{sales:{...t.sales,selecteds:0,list:r.map(n=>(n.selected=!1,n))}}:{sales:{...t.sales,selecteds:r.length,list:[...r.map(n=>(n.selected=!0,n))]}}}),resetSalesQueries:()=>e({sales:Df.sales})}),Z3=Ae()(Be(Oe((...e)=>({...W3(...e)}),{name:"sales-queries-storage",getStorage:()=>me}),{name:"sales-queries-storage",enabled:!1,anonymousActionType:"zustand"})),Rf={purchases:{loading:!1,loaded:!1,refresh:!1,filters:{startDate:"",endDate:"",timeZone:"",dateField:"CREATION",agent:{},seller:{},user:{},serie:{},status:{},isoCurrency:{},product:{},cashRegister:{},discount:{},payment:{},search:"",dateSelector:0,selecteds:0,cfdiCancelStatus:{},creditStatus:{},hasChildDocs:{},childDocsType:{},checkStatusPricesFilter:{},cancellationCheckStatusPricesFilter:{}},list:[],contentRange:"",purchase:{id:0,uuid:"",timeZone:"",decimals:0,type:"PURCHASE",serie:"",serieFolio:"",comment:"",mainIsoCurrency:"MXN",isoCurrency:"MXN",exchangeRate:0,opMode:"MX",subtotal:0,total:0,totalMc:0,discount:0,discountTax:0,taxesCfdi:[],discountPercentage:0,documentDate:"",creationDate:"",withholdingTax:0,userAccount:"",userAlias:"",userUuid:"",cancellationDate:"",agent:{uuid:"",name:"",withholdTaxes:!1,key:!1,priceNumber:0,emails:[],address:{street:"",extNumber:"",intNumber:"",district:"",city:"",county:"",state:"",country:"",zipCode:"",reference:""},phoneNumbers:[]},employee:{uuid:"",name:"",email:"",phoneNumbers:[],position:""},products:[],payments:[],loaded:!1,status:"ACTIVE"},purchaseMetadata:{},totalCount:0,requestId:""},setPurchasesQueries:async()=>{},setFilterPurchases:async()=>{},setPurchaseDetail:async()=>{},resetPurchasesQueries:()=>{},resetQueries:()=>{}},Y3=e=>({...Rf,setPurchasesQueries:async t=>e(r=>({purchases:{...r.purchases,...t}})),setFilterPurchases:async t=>e(r=>({purchases:{...r.purchases,filters:{...r.purchases.filters,...t}}})),setPurchaseDetail:async t=>e(r=>({purchases:{...r.purchases,purchase:{...r.purchases.purchase,...t}}})),resetPurchasesQueries:()=>e({purchases:Rf.purchases})}),X3=Ae()(Be(Oe((...e)=>({...Y3(...e)}),{name:"purchases-queries-storage",getStorage:()=>me}),{name:"purchases-queries-storage",enabled:!1,anonymousActionType:"zustand"})),Nf={invoices:{loading:!1,loaded:!1,refresh:!1,filters:{startDate:"",endDate:"",timeZone:"",dateField:"CREATION",agent:{},seller:{},user:{},serie:{},status:{},isoCurrency:{},product:{},cashRegister:{},discount:{},payment:{},search:"",dateSelector:0,selecteds:0,cfdiCancelStatus:{},creditStatus:{},hasChildDocs:{},childDocsType:{}},list:[],contentRange:"",invoice:{id:"",uuid:"",timeZone:"",decimals:0,type:"CFDI_INGRESO",serie:"",serieFolio:"",comment:"",mainIsoCurrency:"MXN",isoCurrency:"MXN",exchangeRate:0,opMode:"MX",subtotal:0,total:0,discountTax:0,taxesCfdi:[],discountPercentage:0,documentDate:"",creationDate:"",withholdingTax:0,userAccount:"",userAlias:"",userUuid:"",cancellationDate:"",agent:{uuid:"",name:"",withholdTaxes:!1,key:!1,priceNumber:0,emails:[],address:{street:"",extNumber:"",intNumber:"",district:"",city:"",county:"",state:"",country:"",zipCode:"",reference:""},phoneNumbers:[]},employee:{uuid:"",name:"",email:"",phoneNumbers:[],position:""},products:[],payments:[],loaded:!1,status:"ACTIVE"},totalCount:0,requestId:""},setInvoicesQueries:async()=>{},setFilterInvoices:async()=>{},setInvoiceDetail:async()=>{},resetInvoicesQueries:()=>{}},J3=e=>({...Nf,setInvoicesQueries:async t=>e(r=>({invoices:{...r.invoices,...t}})),setFilterInvoices:async t=>e(r=>({invoices:{...r.invoices,filters:{...r.invoices.filters,...t}}})),setInvoiceDetail:async t=>e(r=>({invoices:{...r.invoices,invoice:{...r.invoices.invoice,...t}}})),resetInvoicesQueries:()=>e({invoices:Nf.invoices})}),Bf=Ae()(Be(Oe((...e)=>({...J3(...e)}),{name:"invoices-queries-storage",getStorage:()=>me}),{name:"invoices-queries-storage",enabled:!1,anonymousActionType:"zustand"})),kf={cashMovs:{loading:!1,loaded:!1,refresh:!1,filters:{startDate:"",endDate:"",timeZone:"",cashRegister:{},payment:{},operationType:{},transactionType:{},user:{},branchs:{},dateSelector:0,isoCurrency:{},selecteds:0},list:[],summary:{income:0,expense:0},contentRange:"",totalCount:0,requestId:""},setCashMovsReportsQueries:async()=>{},setFilterCashMovsReports:async()=>{},resetCashMovsReports:()=>{}},e6=e=>({...kf,setCashMovsReportsQueries:async t=>e(r=>({cashMovs:{...r.cashMovs,...t}})),setFilterCashMovsReports:async t=>e(r=>({cashMovs:{...r.cashMovs,filters:{...r.cashMovs.filters,...t}}})),resetCashMovsReports:()=>e({cashMovs:kf.cashMovs})}),t6=Ae()(Be(Oe((...e)=>({...e6(...e)}),{name:"cash-movs-reports-storage",getStorage:()=>me}),{name:"cash-movs-reports-storage",enabled:!1,anonymousActionType:"zustand"})),Of={purchases:{loading:!1,loaded:!1,refresh:!1,filters:{startDate:"",endDate:"",timeZone:"",dateField:"CREATION",agent:{},seller:{},user:{},serie:{},status:{},isoCurrency:{},discount:{},payment:{},branchs:{},warehouse:{},invoiced:{},search:"",dateSelector:0,withProfit:!1,withTaxes:!0,selecteds:0},list:[],summary:{discount:0,subtotal:0,total:0},contentRange:"",totalCount:0,requestId:""},setPurchasesReportsQueries:async()=>{},setFilterPurchasesReports:async()=>{},resetPurchasesReports:()=>{}},r6=e=>({...Of,setPurchasesReportsQueries:async t=>e(r=>({purchases:{...r.purchases,...t}})),setFilterPurchasesReports:async t=>e(r=>({purchases:{...r.purchases,filters:{...r.purchases.filters,...t}}})),resetPurchasesReports:()=>e({purchases:Of.purchases})}),n6=Ae()(Be(Oe((...e)=>({...r6(...e)}),{name:"purchases-reports-storage",getStorage:()=>me}),{name:"purchases-reports-storage",enabled:!1,anonymousActionType:"zustand"})),Uf={cashregisters_balance:{loading:!1,loaded:!1,refresh:!1,list:[],cashregisters_balances_detail:{}},setCashregistersBalance:async()=>{},setCashregistersBalanceDetail:async()=>{},resetCashregistersBalance:()=>{}},a6=e=>({...Uf,setCashregistersBalance:async t=>e(r=>({cashregisters_balance:{...r.cashregisters_balance,...t}})),setCashregistersBalanceDetail:async t=>e(r=>({cashregisters_balance:{...r.cashregisters_balance,cashregisters_balances_detail:{...r.cashregisters_balance.cashregisters_balances_detail,...t}}})),resetCashregistersBalance:()=>e({cashregisters_balance:Uf.cashregisters_balance})}),s6=Ae()(Be(Oe((...e)=>({...a6(...e)}),{name:"cashregisters-balance-storage",getStorage:()=>me}),{name:"cashregisters-balance-storage",enabled:!1,anonymousActionType:"zustand"})),Wr={dashboard:{clientID:"",status:"",openLogin:!1,bagRecharges:{bag:"",bagId:0,balance:0},bagServicesPayment:{bag:"",bagId:0,balance:0}},paymentHistory:{loading:!1,loaded:!1,refresh:!1,hasMore:!1,filters:{startDate:Date.now(),endDate:Date.now(),bag:"ALL"},list:[],page:1},movementHistory:{loading:!1,loaded:!1,refresh:!1,hasMore:!1,filters:{startDate:Date.now(),endDate:Date.now()},list:[],page:1},transactionHistory:{loading:!1,loaded:!1,refresh:!1,hasMore:!1,filters:{startDate:Date.now(),endDate:Date.now()},list:[],page:1},catalogueProduct:{loading:!1,loaded:!1,refresh:!1,hasMore:!1,filters:{carrier:{},category:{},search:""},list:[],page:1},catalogueSaleProduct:{loading:!1,loaded:!1,refresh:!1,hasMore:!1,category:{},list:[],page:1},catalogueSaleRechargesProduct:{loading:!1,loaded:!1,refresh:!1,hasMore:!1,type:"",list:[],page:1},catalogueSaleSearchProduct:{loading:!1,loaded:!1,refresh:!1,hasMore:!1,search:"",list:[],page:1},catalogueSaleFavoriteProduct:{loading:!1,loaded:!1,refresh:!1,hasMore:!1,search:"",list:[],page:1},setDashboard:async()=>{},setPaymentHistory:async()=>{},setMovementHistory:async()=>{},setTransactionHistory:async()=>{},setCatalogueProduct:async()=>{},setCatalogueSaleProduct:async()=>{},setCatalogueSaleRechargesProduct:async()=>{},setCatalogueSaleSearchProduct:async()=>{},setCatalogueSaleFavoriteProduct:async()=>{},resetRPS:()=>{}},i6=e=>({...Wr,setDashboard:async t=>{e(r=>({...r,dashboard:{...r.dashboard,...t}}))},setPaymentHistory:async t=>{e(r=>({...r,paymentHistory:{...r.paymentHistory,...t}}))},setMovementHistory:async t=>{e(r=>({...r,movementHistory:{...r.movementHistory,...t}}))},setTransactionHistory:async t=>{e(r=>({...r,transactionHistory:{...r.transactionHistory,...t}}))},setCatalogueProduct:async t=>{e(r=>({...r,catalogueProduct:{...r.catalogueProduct,...t}}))},setCatalogueSaleProduct:async t=>{e(r=>({...r,catalogueSaleProduct:{...r.catalogueSaleProduct,...t}}))},setCatalogueSaleRechargesProduct:async t=>{e(r=>({...r,catalogueSaleRechargesProduct:{...r.catalogueSaleRechargesProduct,...t}}))},setCatalogueSaleSearchProduct:async t=>{e(r=>({...r,catalogueSaleSearchProduct:{...r.catalogueSaleSearchProduct,...t}}))},setCatalogueSaleFavoriteProduct:async t=>{e(r=>({...r,catalogueSaleFavoriteProduct:{...r.catalogueSaleFavoriteProduct,...t}}))},resetRPS:()=>e({dashboard:Wr.dashboard,paymentHistory:Wr.paymentHistory,movementHistory:Wr.movementHistory,transactionHistory:Wr.transactionHistory,catalogueProduct:Wr.catalogueProduct,catalogueSaleProduct:Wr.catalogueSaleProduct,catalogueSaleRechargesProduct:Wr.catalogueSaleRechargesProduct,catalogueSaleSearchProduct:Wr.catalogueSaleSearchProduct,catalogueSaleFavoriteProduct:Wr.catalogueSaleFavoriteProduct})}),o6=Ae()(Be(Oe((...e)=>({...i6(...e)}),{name:"rps-storage",getStorage:()=>me}),{name:"rps-storage",enabled:!1,anonymousActionType:"zustand"})),Sr="transfer/v1",uR=(e={},t=20,r=void 0)=>{const n=new URLSearchParams({size:String(t),...r!=null&&{offset:String(r)}});return J(`${Sr}/transfer/list/send?${String(n)}`,e)},c6=(e={},t=20,r=void 0)=>{const n=new URLSearchParams({size:String(t),...r!=null&&{offset:String(r)}});return J(`${Sr}/transfer/list/received?${String(n)}`,e)},lR=e=>new Promise((t,r)=>u6(e).then(({status:n,data:a})=>{n===200&&Rt.get(a.signedUrl).then(s=>{s.data.signedUrl=a.signedUrl,s.data.signedPdfUrl=a.signedPdfUrl,t(s)}).catch(r)}).catch(r)),u6=e=>Q(`${Sr}/transfer/${e}`),dR=e=>Re(`${Sr}/transfer`,e),hR=(e,t)=>Re(`${Sr}/transfer/${e}/detail`,t),pR=e=>J(`${Sr}/transfer/${e}/lock`,null),fR=(e,t)=>J(`${Sr}/transfer/${e}/send`,t),gR=(e,t)=>J(`${Sr}/transfer/accept`,{uuid:e,warehouseId:t}),mR=(e,t)=>J(`${Sr}/transfer/${e}/cancel`,t),yR=(e,t=20,r)=>{const n=new URLSearchParams({size:String(t),...r!=null&&{offset:String(r)}});return J(`${Sr}/search?${String(n)}`,e)},vR=(e,t)=>new Promise((r,n)=>{const a=new pe(`
                stock: transferStock(query: ${pe.parseParam(e)}) {
                    origin {
                        ...stockFields
                        lots {
                            lotNumber
                            warehouseId
                            created
                            expirationDate
                            fabricationDate
                            initialStock
                            stock
                            available                            
                        }
                    }
                    destine {
                        ...stockFields
                    }
                }
            `).insertQuery(`
                prices: pricesForProducts(uuids:${pe.parseParam(t==null?void 0:t.uuids)}, priceList:"${t==null?void 0:t.priceList}") {
                    productUuid
                    price1
                    netPrice1
                    avgCostByUnit
                    avgNetCostByUnit
                    costByUnit
                    netCostByUnit
                }
            `,!!t).insertFragment(`
                fragment stockFields on Stock {
                    uuid
                    stock
                    minStock
                    maxStock
                    available
                }
            `).build();pn(It,a).then(s=>r(pe.unwrap(s))).catch(n)}),bR=(e,t,r)=>new Promise((n,a)=>{const s=new pe().insertQuery(`
            origin {
                uuid
                stock
                minStock
                maxStock
                available
                lots {
                    lotNumber
                    warehouseId
                    created
                    expirationDate
                    fabricationDate
                    initialStock
                    stock
                    available                            
                }
            }
        `,t).insertQuery(`
            destine {
                uuid
                stock
                minStock
                maxStock
                available
            }
        `,r).build(`stock: transferStock(query: ${pe.parseParam(e)})`);pn(It,`{
 ${s} 
}`).then(i=>n(pe.unwrap(i))).catch(a)}),l6=(e,t=20,r=void 0)=>{const n=new URLSearchParams({size:String(t),...r!=null&&{offset:String(r)}});return J(`${Sr}/request/list/received?${String(n)}`,{status:e})},CR=e=>new Promise((t,r)=>{Q(`${Sr}/request/${e}`).then(({data:n})=>Rt.get(n).then(t).catch(r)).catch(r)}),SR=e=>Re(`${Sr}/request`,e),ER=e=>J(`${Sr}/request/${e}/cancel`,e),xR=e=>Q(`${Sr}/transfer/isCalculated/${e}`),Au={transfers:{loading:!1,receivedRequestList:[],receivedList:[]},transfersQueries:{list:[],loading:!1,searchList:[],end:void 0,start:void 0,filters:void 0,filtersView:void 0,totalFilters:0,back:!1,pageList:1,hasMoreList:!0,pageSearch:1,hasMoreSearch:!1}},d6=e=>({...Au,setTransfer(t){e(r=>({...r,transfers:{...r.transfers,...t}}))},setTransferQueries(t){e(r=>({...r,transfersQueries:{...r.transfersQueries,...t}}))},getTransferReceivedRequest:async(t=20,r)=>new Promise((n,a)=>{l6(bo.TransferStatus.CREATED,t,r).then(({status:s,data:i})=>{e(o=>({...o,transfers:{...o.transfers,receivedRequestList:s===200?i:[]}})),n(void 0)}).catch(a)}),getTransferReceived:async(t=20,r)=>new Promise((n,a)=>{c6({status:bo.TransferStatus.SEND},t,r).then(({status:s,data:i})=>{e(o=>({...o,transfers:{...o.transfers,receivedList:s===200?i:[]}})),n()}).catch(a)}),resetTransferSlice:()=>e({transfers:Au.transfers,transfersQueries:Au.transfersQueries})}),Lf="transfer-session-storage",h6=Ae()(Be(Oe((...e)=>({...d6(...e)}),{name:Lf,getStorage:()=>me}),{name:Lf,enabled:!1,anonymousActionType:"zustand"})),Mf={products:{list:[],loading:!1,withTaxes:!0,withProfits:!1,filterView:{},totalFilters:0,offset:void 0}},p6=(e,t)=>({...Mf,setInventoryReports(r){e(n=>({...n,products:{...n.products,...r}}))},resetStockReports:()=>e({products:Mf.products})}),f6=Ae()(Be(Oe((...e)=>({...p6(...e)}),{name:"stock-reports-storage",getStorage:()=>me}),{name:"stock-reports-storage",enabled:!1,anonymousActionType:"zustand"})),jf={cashregisters_balancing:{loading:!1,loaded:!1,refresh:!1,list:[],contentRange:"",filters:{startDate:"",endDate:"",timeZone:"",balanceDiff:{},user:{},isoCurrency:{},cashRegister:{},search:"",dateSelector:0,selecteds:0},cashregister_balancing:{}},setCashregistersBalancing:async()=>{},setFilterCashregistersBalancing:async()=>{},setCashregistersBalancingDetail:async()=>{},resetCashregistersBalancing:()=>{}},g6=e=>({...jf,setCashregistersBalancing:async t=>e(r=>({cashregisters_balancing:{...r.cashregisters_balancing,...t}})),setFilterCashregistersBalancing:async t=>e(r=>({cashregisters_balancing:{...r.cashregisters_balancing,filters:{...r.cashregisters_balancing.filters,...t}}})),setCashregistersBalancingDetail:async t=>e(r=>({cashregisters_balancing:{...r.cashregisters_balancing,cashregister_balancing:{...r.cashregisters_balancing.cashregister_balancing,...t}}})),resetCashregistersBalancing:()=>e({cashregisters_balancing:jf.cashregisters_balancing})}),m6=Ae()(Be(Oe((...e)=>({...g6(...e)}),{name:"cashregisters-balancing-storage",getStorage:()=>me}),{name:"cashregisters-balancing-storage",enabled:!1,anonymousActionType:"zustand"})),y6=e=>({catalog:[],addSaleCatalog:t=>{e(r=>({...r,catalog:[...r.catalog,t]}))},resetSaleCatalog:()=>{e({catalog:[]})}}),v6=Ae()((...e)=>({...y6(...e)}));var ha=(e=>(e[e.ACTIVE=1]="ACTIVE",e[e.EXPIRED=-1]="EXPIRED",e[e.UNCONFIGURED=0]="UNCONFIGURED",e))(ha||{});const b6=async()=>{try{const e=await Q(`${we}/configuration/autofactura`);return{status:e.status,data:e.data?e.data:void 0,code:1001,message:"ok"}}catch(e){const t=e;return{status:t.status?t.status:1e3,data:void 0,code:t.response&&t.response.data&&t.response.data.code?t.response.data.code:1e3,message:t.response&&t.response.data&&t.response.data.message?t.response.data.message:"fail"}}},wR=async(e,t)=>{try{const r=await lE(`${we}/configuration/autofactura`,e,void 0,t);return{status:r.status,data:r.data?r.data:void 0,code:1001,message:"ok"}}catch(r){const n=r;return{status:n.status?n.status:1e3,data:void 0,code:n.response&&n.response.data&&n.response.data.code?n.response.data.code:1e3,message:n.response&&n.response.data&&n.response.data.message?n.response.data.message:"fail"}}},Ff={selfBilling:void 0,statusCert:ha.UNCONFIGURED},C6=(e,t)=>({...Ff,setSelfBilling:async r=>{e(n=>({...n,selfBilling:r}))},setStatusCert:async r=>{e(n=>({...n,statusCert:r}))},initSelfBilling:async r=>{const n=await b6();if(n.status==200){const a=n.data;if(a){const s={active:a.active,serie:a.serie,expirationDays:a.vencimiento,consumo:a.consumo};return e(i=>({...i,selfBilling:s,statusCert:r})),{selfBilling:s,statusCert:r}}}return e(a=>({...a,selfBilling:void 0,statusCert:r})),null},resetSelfBilling:()=>e({selfBilling:void 0,statusCert:Ff.statusCert})}),Bl=Ae()(Be(Oe((...e)=>({...C6(...e)}),{name:"self-billing",getStorage:()=>me}),{name:"self-billing",enabled:!1,anonymousActionType:"zustand"})),qf={orders:{loading:!1,loaded:!1,refresh:!1,list:[],filters:{startDate:"",endDate:"",timeZone:"",agent:{},seller:{},user:{},serie:{},isoCurrency:{},discount:{},status:{},withTaxes:!0,branchs:{},dateSelector:0,selecteds:0},registries:{total:0},summary:{discount:0,total:0,subtotal:0},contentRange:"",totalCount:0},setFilterOrdersReports:async()=>{},resetOrdersReports:async()=>{},setOrdersReports:async()=>{}},S6=e=>({...qf,setOrdersReports:async t=>e(r=>({orders:{...r.orders,...t}})),setFilterOrdersReports:async t=>e(r=>({orders:{...r.orders,filters:{...r.orders.filters,...t}}})),resetOrdersReports:()=>e({orders:qf.orders})}),E6=Ae()(Be(Oe((...e)=>({...S6(...e)}),{name:"orders-reports-storage",getStorage:()=>me}),{name:"orders-reports-storage",enabled:!1,anonymousActionType:"zustand"})),Hf={sales:{loading:!1,loaded:!1,refresh:!1,filters:{start_date:"",end_date:"",time_zone:"",groupDepartments:!1,date_selector:0,departments:{},categories:{},with_taxes:!0,selecteds:0},list:[],summary:{amount:0},contentRange:"",totalCount:0},setSalesReportsByDepartmentQueries:async()=>{},setFilterSalesReportsByDepartment:async()=>{},resetSalesReportsByDepartment:()=>{}},x6=(e,t)=>({...Hf,setSalesReportsByDepartmentQueries:async r=>e(n=>({sales:{...n.sales,...r}})),setFilterSalesReportsByDepartment:async r=>e(n=>({sales:{...n.sales,filters:{...n.sales.filters,...r}}})),resetSalesReportsByDepartment:()=>e({sales:Hf.sales})}),w6=Ae()(Be(Oe((...e)=>({...x6(...e)}),{name:"sales-by-department-storage",getStorage:()=>me}),{name:"sales-by-department-storage",enabled:!1,anonymousActionType:"zustand"})),Kf={sales:{loading:!1,loaded:!1,refresh:!1,filters:{start_date:"",end_date:"",time_zone:"",dateField:"CREATION",date_selector:0,exclude_columns:[],sort_by:"DOCUMENTS_TOTAL",sort_order:"DESC",with_taxes:!0,selecteds:0},list:[],summary:{activeCount:0,canceledCount:0,canceledTotal:0,discount:0,documentsTotal:0,grandTotal:0},contentRange:"",totalCount:0},setSalesReportsByUserQueries:async()=>{},setFilterSalesReportsByUser:async()=>{},resetSalesReportsByUser:()=>{}},Ly=(e,t)=>({...Kf,setSalesReportsByUserQueries:async r=>e(n=>({sales:{...n.sales,...r}})),setFilterSalesReportsByUser:async r=>e(n=>({sales:{...n.sales,filters:{...n.sales.filters,...r}}})),resetSalesReportsByUser:()=>e({sales:Kf.sales})}),T6=Ae()(Be(Oe((...e)=>({...Ly(...e)}),{name:"sales-by-user-storage",getStorage:()=>me}),{name:"sales-by-user-storage",enabled:!1,anonymousActionType:"zustand"})),$6=Ae()(Be(Oe((...e)=>({...Ly(...e)}),{name:"sales-by-sellers-storage",getStorage:()=>me}),{name:"sales-by-sellers-storage",enabled:!1,anonymousActionType:"zustand"})),Vf={salesbyproduct:{loading:!1,loaded:!1,refresh:!1,list:[],filters:{startDate:"",endDate:"",timeZone:"",agent:{},seller:{},user:{},status:{},withTaxes:!0,sortBy:"QUANTITY",sortOrder:"DESC",dateSelector:0,category:[],department:[],groupProducts:!1,product:{},selecteds:0},registries:{total:0},summary:{amount:0,cost:0,profit:0},contentRange:"",totalCount:0},setFilterSalesByProductReports:async()=>{},resetSalesByProductReports:async()=>{},setSalesByProductReportsQueries:async()=>{}},A6=e=>({...Vf,setSalesByProductReportsQueries:async t=>e(r=>({salesbyproduct:{...r.salesbyproduct,...t}})),setFilterSalesByProductReports:async t=>e(r=>({salesbyproduct:{...r.salesbyproduct,filters:{...r.salesbyproduct.filters,...t}}})),resetSalesByProductReports:()=>e({salesbyproduct:Vf.salesbyproduct})}),I6=Ae()(Be(Oe((...e)=>({...A6(...e)}),{name:"salesByProduct-reports-storage",getStorage:()=>me}),{name:"salesByProduct-reports-storage",enabled:!1,anonymousActionType:"zustand"})),zf={sales:{loading:!1,loaded:!1,refresh:!1,filters:{start_date:"",end_date:"",time_zone:"",dateField:"CREATION",date_selector:0,exclude_columns:[],sort_by:"DOCUMENTS_TOTAL",sort_order:"DESC",with_taxes:!0,selecteds:0},list:[],summary:{activeCount:0,canceledCount:0,canceledTotal:0,discount:0,documentsTotal:0,grandTotal:0},contentRange:"",totalCount:0},setSalesReportsByWaitressQueries:async()=>{},setFilterSalesReportsByWaitress:async()=>{},resetSalesReportsByWaitress:()=>{}},P6=(e,t)=>({...zf,setSalesReportsByWaitressQueries:async r=>e(n=>({sales:{...n.sales,...r}})),setFilterSalesReportsByWaitress:async r=>e(n=>({sales:{...n.sales,filters:{...n.sales.filters,...r}}})),resetSalesReportsByWaitress:()=>e({sales:zf.sales})}),_6=Ae()(Be(Oe((...e)=>({...P6(...e)}),{name:"sales-by-waitress-storage",getStorage:()=>me}),{name:"sales-by-waitress-storage",enabled:!1,anonymousActionType:"zustand"})),Gf={handlerUpgradeNotification:{notifications:[],showing:!1},setNotification:async()=>{},setShowing:async()=>{},setShowed:async()=>{},cleanShowed:async()=>{},resetHandlerUpgradeNotification:()=>{}},D6=e=>({...Gf,setNotification:async t=>e(r=>({handlerUpgradeNotification:{...r.handlerUpgradeNotification,notifications:[...r.handlerUpgradeNotification.notifications,t]}})),setShowing:async t=>e(r=>({handlerUpgradeNotification:{...r.handlerUpgradeNotification,showing:t}})),setShowed:async t=>e(r=>({handlerUpgradeNotification:{...r.handlerUpgradeNotification,notifications:[...r.handlerUpgradeNotification.notifications.map(n=>(n.id===t&&(n.showed=!0),n))]}})),cleanShowed:async()=>e(t=>({handlerUpgradeNotification:{...t.handlerUpgradeNotification,notifications:[...t.handlerUpgradeNotification.notifications.filter(r=>r.showed===!1)]}})),resetHandlerUpgradeNotification:()=>e({handlerUpgradeNotification:Gf.handlerUpgradeNotification})}),R6=Ae()(Be((...e)=>({...D6(...e)}),{name:"handler-upgrade-notification-storage"})),N6=(e,t)=>({printServers:void 0,getPrintServers:()=>{var r,n,a;return(r=t())!=null&&r.printServers?(a=(n=t())==null?void 0:n.printServers)==null?void 0:a[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:void 0},setPrintServers:r=>{const{id:n=0}=JSON.parse(me.getItem("auth-company-storage")).state.authCompany;n&&e(a=>({...a,printServers:{...a.printServers,[n]:r}}))}}),TR=Ae(Be(Oe((...e)=>({...N6(...e)}),{name:"local-print-servers-storage",getStorage:()=>Cr}),{name:"local-print-servers-storage",enabled:!1,anonymousActionType:"zustand"})),B6=(e,t)=>({autoSaveQuickSale:void 0,getAutoQuickSale:()=>{var r,n,a;return(r=t())!=null&&r.autoSaveQuickSale?(a=(n=t())==null?void 0:n.autoSaveQuickSale)==null?void 0:a[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:void 0},setAutoQuickSale:r=>{const{id:n=0}=JSON.parse(me.getItem("auth-company-storage")).state.authCompany;n&&e(a=>({...a,autoSaveQuickSale:{...a.autoSaveQuickSale,[n]:r}}))}}),$R=Ae(Be(Oe((...e)=>({...B6(...e)}),{name:"local-quick-sales-storage",getStorage:()=>Cr}),{name:"local-quick-sales-storage",enabled:!1,anonymousActionType:"zustand"})),k6=(e,t)=>({autoSaveCommand:void 0,getExistCommand:r=>{var n,a,s,i;const{id:o=0}=(a=(n=JSON.parse(me.getItem("auth-company-storage")))==null?void 0:n.state)==null?void 0:a.authCompany;return((i=(s=t())==null?void 0:s.autoSaveCommand)==null?void 0:i[o+"_"+r])!==void 0},getAutoCommand:r=>{var n,a,s,i,o;const{id:c=0}=(a=(n=JSON.parse(me.getItem("auth-company-storage")))==null?void 0:n.state)==null?void 0:a.authCompany;return(s=t())!=null&&s.autoSaveCommand?(o=(i=t())==null?void 0:i.autoSaveCommand)==null?void 0:o[c+"_"+r]:void 0},setAutoCommand:(r,n)=>{const{id:a=0}=JSON.parse(me.getItem("auth-company-storage")).state.authCompany;a&&n&&e(s=>({...s,autoSaveCommand:{...s.autoSaveCommand,[a+"_"+n]:r}}))}}),AR=Ae(Be(Oe((...e)=>({...k6(...e)}),{name:"local-commander-storage",getStorage:()=>Cr}),{name:"local-commander-storage",enabled:!1,anonymousActionType:"zustand"})),O6=(e,t)=>({cache:[],setCache:r=>{var n,a,s,i;const o=(i=(s=(a=JSON==null?void 0:JSON.parse((n=me)==null?void 0:n.getItem("auth-company-storage")))==null?void 0:a.state)==null?void 0:s.authCompany)==null?void 0:i.id;o&&e(c=>({...c,cache:{...c.cache,[o]:r}}))},getCache:()=>{var r,n,a,s,i;let o=(r=t())==null?void 0:r.cache,c=(i=(s=(a=JSON==null?void 0:JSON.parse((n=me)==null?void 0:n.getItem("auth-company-storage")))==null?void 0:a.state)==null?void 0:s.authCompany)==null?void 0:i.id;return(o==null?void 0:o[c])||void 0}}),IR=Ae(Be(Oe((...e)=>({...O6(...e)}),{name:"local-cache-products-storage",getStorage:()=>Cr}),{name:"local-cache-products-storage",enabled:!1,anonymousActionType:"zustand"})),U6=e=>({flow:void 0,setFlow:t=>e(r=>({...r,flow:t}))}),PR=Ae(Be(Oe((...e)=>({...U6(...e)}),{name:"local-flow-storage",getStorage:()=>Cr}),{name:"local-flow-storage",enabled:!1,anonymousActionType:"zustand"})),L6=e=>({config:void 0,setConfig:t=>{e(r=>({...r,config:t}))}}),_R=Ae(Be(Oe((...e)=>({...L6(...e)}),{name:"local-scale-storage",getStorage:()=>Cr}),{name:"local-scale-storage",enabled:!1,anonymousActionType:"zustand"})),Qf={survey:{users:[]},setSurvey:async()=>{},resetSurvey:async()=>{}},M6=e=>({...Qf,setSurvey:async t=>e(r=>({survey:{...r.survey,users:[...t]}})),resetSurvey:()=>e({survey:Qf.survey})}),DR=Ae(Be(Oe((...e)=>({...M6(...e)}),{name:"local-survey-storage",getStorage:()=>Cr}),{name:"local-survey-storage",enabled:!1,anonymousActionType:"zustand"})),j6=(e,t)=>({autoSaveSale:void 0,getAutoSale:()=>{var r,n,a;return(r=t())!=null&&r.autoSaveSale?(a=(n=t())==null?void 0:n.autoSaveSale)==null?void 0:a[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:void 0},setAutoSale:r=>{const{id:n=0}=JSON.parse(me.getItem("auth-company-storage")).state.authCompany;n&&e(a=>({...a,autoSaveSale:{...a.autoSaveSale,[n]:r}}))}}),RR=Ae(Be(Oe((...e)=>({...j6(...e)}),{name:"local-sales-storage",getStorage:()=>Cr}),{name:"local-sales-storage",enabled:!1,anonymousActionType:"zustand"})),F6=(e,t)=>({autoSaveQuotation:void 0,getAutoQuotation:()=>{var r,n,a;return(r=t())!=null&&r.autoSaveQuotation?(a=(n=t())==null?void 0:n.autoSaveQuotation)==null?void 0:a[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:void 0},setAutoQuotation:r=>{const{id:n=0}=JSON.parse(me.getItem("auth-company-storage")).state.authCompany;n&&e(a=>({...a,autoSaveQuotation:{...a.autoSaveQuotation,[n]:r}}))}}),NR=Ae(Be(Oe((...e)=>({...F6(...e)}),{name:"local-quotations-storage",getStorage:()=>Cr}),{name:"local-quotations-storage",enabled:!1,anonymousActionType:"zustand"})),q6=(e,t)=>({autoSavePurchase:void 0,getAutoPurchase:()=>{var r,n,a;return(r=t())!=null&&r.autoSavePurchase?(a=(n=t())==null?void 0:n.autoSavePurchase)==null?void 0:a[JSON.parse(me.getItem("auth-company-storage")).state.authCompany.id]:void 0},setAutoPurchase:r=>{const{id:n=0}=JSON.parse(me.getItem("auth-company-storage")).state.authCompany;n&&e(a=>({...a,autoSavePurchase:{...a.autoSavePurchase,[n]:r}}))}}),BR=Ae(Be(Oe((...e)=>({...q6(...e)}),{name:"local-purchase-storage",getStorage:()=>Cr}),{name:"local-purchase-storage",enabled:!1,anonymousActionType:"zustand"})),Wf={refresh:0,zoneSelected:void 0,spaceSelected:void 0,actionsOrders:void 0,filterStatus:void 0,msj:void 0,showTotals:!0},H6=e=>({...Wf,setRefresh:()=>{e(t=>({...t,refresh:t.refresh+1}))},setZoneSelected:t=>{e(r=>({...r,zoneSelected:t}))},setSpaceSelected:t=>{e(r=>({...r,spaceSelected:t}))},setMjs:t=>{e(r=>({...r,msj:t}))},setShowTotals:t=>{e(r=>({...r,showTotals:t}))},setActionsOrders:(t,r)=>{let n;t&&r&&(n={action:t,orders:r}),e(a=>({...a,actionsOrders:n}))},setFilterStatus:t=>{e(r=>({...r,filterStatus:t}))},resetCommander:()=>e(Wf)}),kR=Ae()(Be(Oe((...e)=>({...H6(...e)}),{name:"commander-storage",getStorage:()=>me}),{name:"commander-storage",enabled:!1,anonymousActionType:"zustand"})),K6={excel:{status:0,fileName:null,data:[]}},V6=(e,t)=>({...K6,setExcel(r){e(n=>({...n,excel:{...n.excel,...r}}))},getExcel(){return t().excel}}),OR=Ae(Be(Oe((...e)=>({...V6(...e)}),{name:"excel-storage",getStorage:()=>Cr}),{name:"excel-storage",enabled:!1,anonymousActionType:"zustand"})),Zf={documents:{loading:!1,loaded:!1,refresh:!1,list:[],contentRange:""},setRelatedDocumentQueries:async()=>{},resetRelatedDocumentQueries:()=>{}},z6=e=>({...Zf,setRelatedDocumentQueries:async t=>e(r=>({documents:{...r.documents,...t}})),resetRelatedDocumentQueries:()=>e({documents:Zf.documents})}),UR=Ae()(Be((...e)=>({...z6(...e)}),{name:"related-documents-storage",enabled:!1,anonymousActionType:"zustand"})),G6={cfdis:{filters:{startDate:"",endDate:"",dateField:"CREATION",dateSelector:0}},setFiltersCfdiReports:async()=>{}},Q6=e=>({...G6,setFiltersCfdiReports:async t=>e(r=>({cfdis:{...r.cfdis,filters:{...r.cfdis.filters,...t}}}))}),LR=Ae()(Be((...e)=>({...Q6(...e)}))),Yf={sales:{loading:!1,loaded:!1,refresh:!1,list:[],contentRange:"",summary:{},filters:{start_date:"",end_date:"",date_range:!1,time_zone:"",date_selector:0,selecteds:0,date_pattern:"",date_field:"CREATION"},totalCount:0},setAgentCreditsFilter:async()=>{},setAgentCreditsReports:async()=>{},resetAgentCreditsReports:async()=>{}},W6=(e,t)=>({...Yf,setAgentCreditsReports:async r=>e(n=>({sales:{...n.sales,...r}})),setAgentCreditsFilter:async r=>e(n=>({sales:{...n.sales,filters:{...n.sales.filters,...r}}})),resetAgentCreditsReports:()=>e({sales:Yf.sales})}),MR=Ae()(Be(Oe((...e)=>({...W6(...e)}),{name:"agent-credits-reports-storage",getStorage:()=>me}),{name:"agent-credits-reports-storage",enabled:!1,anonymousActionType:"zustand"})),Xf={sales:{loading:!1,loaded:!1,refresh:!1,list:[],contentRange:"",summary:{},filters:{start_date:"",end_date:"",time_zone:"",date_selector:0,selecteds:0,date_pattern:"",agent:{},cash_register:{},date_field:"CREATION",user:{},paymentType:{}},totalCount:0},setAgentCreditsPaymentsFilter:async()=>{},setAgentCreditsPaymentsReports:async()=>{},resetAgentCreditsPaymentsReports:async()=>{}},Z6=(e,t)=>({...Xf,setAgentCreditsPaymentsReports:async r=>e(n=>({sales:{...n.sales,...r}})),setAgentCreditsPaymentsFilter:async r=>e(n=>({sales:{...n.sales,filters:{...n.sales.filters,...r}}})),resetAgentCreditsPaymentsReports:()=>e({sales:Xf.sales})}),jR=Ae()(Be(Oe((...e)=>({...Z6(...e)}),{name:"agent-credit-payments-reports-storage",getStorage:()=>me}),{name:"agent-credit-payments-reports-storage",enabled:!1,anonymousActionType:"zustand"})),Y6=(e,t)=>({productLabels:{},saveData:r=>e(n=>({...n,productLabels:{...n.productLabels,[Iu()]:r}})),getData:()=>{var r,n;return(n=(r=t())==null?void 0:r.productLabels)==null?void 0:n[Iu()]},clearData:()=>e(r=>({...r,productLabels:{...r.productLabels,[Iu()]:void 0}}))}),Iu=()=>$a.getState().companies.branchOffice.id,FR=Ae(Be(Oe((...e)=>({...Y6(...e)}),{name:"local-product-labels-storage",getStorage:()=>Cr}),{name:"local-product-labels-storage",enabled:!1,anonymousActionType:"zustand"}));var kl={exports:{}};const X6=ng(Dw);(function(e,t){(function(r,n){n(t,X6,Pd)})(Cn,function(r,n,a){function s(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}var i=s(a);function o(l,d,h){var p,f;typeof l=="function"?(p=d||[],f=h):(p=[],f=d);var g=i.default.useRef({hasResult:!1,result:f,error:null}),y=i.default.useReducer(function(v){return v+1},0);y[0];var b=y[1],m=i.default.useMemo(function(){var v=typeof l=="function"?l():l;if(!v||typeof v.subscribe!="function")throw l===v?new TypeError("Given argument to useObservable() was neither a valid observable nor a function."):new TypeError("Observable factory given to useObservable() did not return a valid observable.");if(!g.current.hasResult)if(typeof v.getValue=="function")g.current.result=v.getValue(),g.current.hasResult=!0;else{var S=v.subscribe(function(C){g.current.result=C,g.current.hasResult=!0});typeof S=="function"?S():S.unsubscribe()}return v},p);if(i.default.useDebugValue(g.current.result),i.default.useEffect(function(){var v=m.subscribe(function(S){var C=g.current;(C.error!==null||C.result!==S)&&(C.error=null,C.result=S,C.hasResult=!0,b())},function(S){var C=g.current;C.error!==S&&(C.error=S,b())});return typeof v=="function"?v:v.unsubscribe.bind(v)},p),g.current.error)throw g.current.error;return g.current.result}function c(l,d,h){return o(function(){return n.liveQuery(l)},d||[],h)}function u(l,d,h){if(!l)throw new TypeError("Invalid arguments to usePermissions(): undefined or null");var p;if(arguments.length>=3){if(!("transaction"in l))throw new TypeError("Invalid arguments to usePermission(db, table, obj): 1st arg must be a Dexie instance");if(typeof d!="string")throw new TypeError("Invalid arguments to usePermission(db, table, obj): 2nd arg must be string");if(!h||typeof h!="object")throw new TypeError("Invalid arguments to usePermission(db, table, obj): 3rd arg must be an object");p=l}else{if(l instanceof n.Dexie)throw new TypeError("Invalid arguments to usePermission(db, table, obj): Missing table and obj arguments.");if(typeof l.table=="function"&&typeof l.db=="object")p=l.db,h=l,d=l.table();else throw new TypeError("Invalid arguments to usePermissions(). Expected usePermissions(entity: DexieCloudEntity) or usePermissions(db: Dexie, table: string, obj: DexieCloudObject)")}if(!("cloud"in p))throw new Error("usePermissions() is only for Dexie Cloud but there's no dexie-cloud-addon active in given db.");if(!("permissions"in p.cloud))throw new Error("usePermissions() requires a newer version of dexie-cloud-addon. Please upgrade it.");return o(function(){return p.cloud.permissions(h,d)},[h.realmId,h.owner,d])}r.useLiveQuery=c,r.useObservable=o,r.usePermissions=u,Object.defineProperty(r,"__esModule",{value:!0})})})(kl,kl.exports);var My=kl.exports;const qR=({children:e,grant:t,checkStrategy:r,options:n})=>{const{checkHasPermission:a}=I0();return a(t,r,n)?e:Tt.jsx($t,{to:"/dashboard",replace:!0})},J6=()=>{const e=EI(G=>G.resetAccount),t=wI(G=>G.resetAgentSales),r=ci(G=>G.resetAuthAccount),n=Ca(G=>G.resetAuthCompany),a=Nl(G=>G.resetCache),s=PI(G=>G.resetCashRegisterSales),i=UI(G=>G.resetCatalogue),o=MI(G=>G.resetCollapsed),c=$a(G=>G.resetCompanies),u=ky(G=>G.resetDrawer),l=qI(G=>G.resetDeleteProfile),d=zI(G=>G.resetHardware),h=WI(G=>G.resetHistory),p=Oy(G=>G.resetLoader),f=Ry(G=>G.resetLoggedUser),g=i3(G=>G.resetMitec),y=Ht(G=>G.resetProduct),b=c3(G=>G.resetQueries),m=Z3(G=>G.resetSalesQueries),v=Bf(G=>G.resetInvoicesQueries),S=s6(G=>G.resetCashregistersBalance),C=X3(G=>G.resetPurchasesQueries),E=Bf(G=>G.resetInvoicesQueries),w=l3(G=>G.resetSalesReports),_=h3(G=>G.resetSalesUtilitiesReports),P=t6(G=>G.resetCashMovsReports),x=Ot(G=>G.resetSettings),R=N3(G=>G.resetSubscriptionHandler),B=V3(G=>G.resetSubscription),K=Q3(G=>G.resetTax),re=v3(G=>G.resetUI),ee=f3(G=>G.resetLastSale),ie=KI(G=>G.resetFeedback),se=DI(G=>G.resetCatalogList),Ce=AI(G=>G.resetCartList),Ie=Ht(G=>G.resetProductDepartmentFull),ye=Ht(G=>G.resetProductUnits),L=Ht(G=>G.resetProductTax),X=Ht(G=>G.resetProductStock),ne=Ht(G=>G.resetProductDelete),U=Ht(G=>G.resetProductInventory),be=Ht(G=>G.resetProductInventoryQueries),xe=n6(G=>G.resetPurchasesReports),Ne=o6(G=>G.resetRPS),he=h6(G=>G.resetTransferSlice),_e=Ht(G=>G.resetPricesSlice),I=f6(G=>G.resetStockReports),D=m6(G=>G.resetCashregistersBalancing),N=v6(G=>G.resetSaleCatalog),q=Dl(G=>G.resetTags),k=Bl(G=>G.resetSelfBilling),V=E6(G=>G.resetOrdersReports),W=w6(G=>G.resetSalesReportsByDepartment),j=I6(G=>G.resetSalesByProductReports),z=T6(G=>G.resetSalesReportsByUser),Z=$6(G=>G.resetSalesReportsByUser),M=_6(G=>G.resetSalesReportsByWaitress);function te(){e(),t(),r(),n(),a(),s(),i(),o(),c(),u(),l(),d(),h(),p(),f(),g(),y(),b(),m(),C(),E(),w(),_(),P(),x(),R(),B(),K(),ee(),ie(),se(),Ce(),re(!0),Ie(),ye(),L(),X(),ne(),U(),be(),m(),C(),E(),P(),xe(),S(),Ne(),he(),_e(),I(),D(),N(),q(),k(),V(),v(),W(),j(),z(),Z(),M()}function ge(){t(),a(),s(),i(),o(),u(),l(),d(),h(),g(),y(),b(),m(),C(),E(),w(),_(),P(),x(),R(),B(),K(),ee(),ie(),se(),Ce(),re(!0),Ie(),ye(),L(),X(),ne(),U(),be(),m(),C(),E(),P(),xe(),S(),Ne(),he(),_e(),I(),D(),N(),k(),V()}return{logoutResetState:te,resetChangeBranchOfficeState:ge}},HR=({children:e})=>{const t=Ca(c=>c.setUpdatePermission),r=Nl(c=>c.getEndpointCache),n=Nl(c=>c.setEndpointCache),{setNotification:a}=R6(),{logoutResetState:s}=J6(),[i,o]=Gn.useState(!1);return Gn.useEffect(()=>{i&&setTimeout(()=>{s(),o(!1)},100)},[i]),Gn.useMemo(()=>{$e.interceptors.request.use(async c=>{var u,l;if(((u=c==null?void 0:c.headers)==null?void 0:u.intercept)!=null&&!((l=c==null?void 0:c.headers)!=null&&l.intercept))return c.headers.intercept=void 0,c;const d=r(c.url.split("?",1)[0]??"");c.headers["x-path"]&&c.headers["x-path"].includes("no-cache")&&(c.url=c.headers["x-path"]),c.url.includes("no-cache")?(c.headers["x-path"]=c.url,c.headers["x-cache"]="",c.url=c.headers["x-path"].replace("/no-cache","")):d&&(c.headers["x-path"]=d.path,c.headers["x-cache"]=d.checksum);const h=me.getItem("auth-account-storage");let{state:p}=h===null?!1:JSON.parse(h);if(p&&c.url&&c.headers){const f=c.headers.Authorization!==void 0,g=c.method==="post"&&c.url==="/account/v1/account"||c.method==="post"&&c.url==="/company/v1/branchOffice"||c.headers.Authorization&&c.headers.Authorization!==""&&c.url==="/company/v1/branchOffice/wizardStatus";if(c&&(sp.includes(c.url.split("?")[0])||g))return c;if(!f&&(ip.includes(c.url.split("?")[0])||ip.includes("/"+c.url.split("?")[0])))return p.authAccount.logged?(c.headers.Authorization=p.authAccount.jwt,c):Promise.reject("401 UNAUTHORIZED PATHS ACCOUNT");{let{state:y}=h===null?!1:JSON.parse(me.getItem("auth-company-storage"));if(y&&!f){if(y.authCompany.jwt==="")return Promise.reject("401 UNAUTHORIZED COMPANY");c.headers.Authorization=y.authCompany.jwt}return c}}return c},c=>Promise.reject(c)),$e.interceptors.response.use(c=>(c.headers["x-cache"]&&c.headers["x-path"]&&c.config.method==="get"&&n({checksum:c.headers["x-cache"],path:c.headers["x-path"]}),c),c=>{var u,l,d,h,p,f,g,y,b,m,v,S;if(((u=c==null?void 0:c.response)==null?void 0:u.status)===423&&((d=(l=c==null?void 0:c.response)==null?void 0:l.data)==null?void 0:d.code)===423&&a({id:Math.floor(Math.random()*100),code:(h=c==null?void 0:c.response)==null?void 0:h.status,url:(p=c==null?void 0:c.response)==null?void 0:p.responseURL,showed:!1}),((f=c==null?void 0:c.response)==null?void 0:f.status)===401&&((y=(g=c==null?void 0:c.response)==null?void 0:g.data)==null?void 0:y.code)===4)return o(!0),Promise.reject(c);if(((b=c==null?void 0:c.response)==null?void 0:b.status)===401&&((v=(m=c==null?void 0:c.response)==null?void 0:m.data)==null?void 0:v.code)===401&&!(c!=null&&c.config&&(sp.includes(c==null?void 0:c.config.url.split("?")[0])||(c==null?void 0:c.config.method)==="post"&&(c==null?void 0:c.config.url)==="/account/v1/account")))t(!0);else return((S=c.response)==null?void 0:S.status)===304?c.response:Promise.reject(c)})},[]),e};var Ol={exports:{}},Ul={exports:{}},Ll={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n,a){if(n==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(n[s]=a[s]);return n}e.exports=t.default})(Ll,Ll.exports);var e8=Ll.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var r=n(e8);function n(s){return s&&s.__esModule?s:{default:s}}function a(s){return(0,r.default)({},s)}e.exports=t.default})(Ul,Ul.exports);var t8=Ul.exports,Ml={exports:{}},jl={exports:{}},Fl={exports:{}},ql={exports:{}},Hl={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n,a){if(a.length<n)throw new TypeError(n+" argument"+(n>1?"s":"")+" required, but only "+a.length+" present")}e.exports=t.default})(Hl,Hl.exports);var Er=Hl.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;var r=n(Er);function n(i){return i&&i.__esModule?i:{default:i}}function a(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?a=function(o){return typeof o}:a=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},a(i)}function s(i){return(0,r.default)(1,arguments),i instanceof Date||a(i)==="object"&&Object.prototype.toString.call(i)==="[object Date]"}e.exports=t.default})(ql,ql.exports);var r8=ql.exports,Kl={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;var r=n(Er);function n(i){return i&&i.__esModule?i:{default:i}}function a(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?a=function(o){return typeof o}:a=function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},a(i)}function s(i){(0,r.default)(1,arguments);var o=Object.prototype.toString.call(i);return i instanceof Date||a(i)==="object"&&o==="[object Date]"?new Date(i.getTime()):typeof i=="number"||o==="[object Number]"?new Date(i):((typeof i=="string"||o==="[object String]")&&typeof console<"u"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}e.exports=t.default})(Kl,Kl.exports);var gn=Kl.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var r=s(r8),n=s(gn),a=s(Er);function s(o){return o&&o.__esModule?o:{default:o}}function i(o){if((0,a.default)(1,arguments),!(0,r.default)(o)&&typeof o!="number")return!1;var c=(0,n.default)(o);return!isNaN(Number(c))}e.exports=t.default})(Fl,Fl.exports);var n8=Fl.exports,Vl={exports:{}},zl={exports:{}},Gl={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n){if(n===null||n===!0||n===!1)return NaN;var a=Number(n);return isNaN(a)?a:a<0?Math.ceil(a):Math.floor(a)}e.exports=t.default})(Gl,Gl.exports);var Oa=Gl.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var r=s(Oa),n=s(gn),a=s(Er);function s(o){return o&&o.__esModule?o:{default:o}}function i(o,c){(0,a.default)(2,arguments);var u=(0,n.default)(o).getTime(),l=(0,r.default)(c);return new Date(u+l)}e.exports=t.default})(zl,zl.exports);var a8=zl.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var r=s(a8),n=s(Er),a=s(Oa);function s(o){return o&&o.__esModule?o:{default:o}}function i(o,c){(0,n.default)(2,arguments);var u=(0,a.default)(c);return(0,r.default)(o,-u)}e.exports=t.default})(Vl,Vl.exports);var s8=Vl.exports,Ql={exports:{}},Wl={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var r=a(gn),n=a(Er);function a(o){return o&&o.__esModule?o:{default:o}}var s=864e5;function i(o){(0,n.default)(1,arguments);var c=(0,r.default)(o),u=c.getTime();c.setUTCMonth(0,1),c.setUTCHours(0,0,0,0);var l=c.getTime(),d=u-l;return Math.floor(d/s)+1}e.exports=t.default})(Wl,Wl.exports);var i8=Wl.exports,Zl={exports:{}},Yl={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;var r=a(gn),n=a(Er);function a(i){return i&&i.__esModule?i:{default:i}}function s(i){(0,n.default)(1,arguments);var o=1,c=(0,r.default)(i),u=c.getUTCDay(),l=(u<o?7:0)+u-o;return c.setUTCDate(c.getUTCDate()-l),c.setUTCHours(0,0,0,0),c}e.exports=t.default})(Yl,Yl.exports);var P0=Yl.exports,Xl={exports:{}},Jl={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var r=s(gn),n=s(Er),a=s(P0);function s(o){return o&&o.__esModule?o:{default:o}}function i(o){(0,n.default)(1,arguments);var c=(0,r.default)(o),u=c.getUTCFullYear(),l=new Date(0);l.setUTCFullYear(u+1,0,4),l.setUTCHours(0,0,0,0);var d=(0,a.default)(l),h=new Date(0);h.setUTCFullYear(u,0,4),h.setUTCHours(0,0,0,0);var p=(0,a.default)(h);return c.getTime()>=d.getTime()?u+1:c.getTime()>=p.getTime()?u:u-1}e.exports=t.default})(Jl,Jl.exports);var jy=Jl.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var r=s(jy),n=s(P0),a=s(Er);function s(o){return o&&o.__esModule?o:{default:o}}function i(o){(0,a.default)(1,arguments);var c=(0,r.default)(o),u=new Date(0);u.setUTCFullYear(c,0,4),u.setUTCHours(0,0,0,0);var l=(0,n.default)(u);return l}e.exports=t.default})(Xl,Xl.exports);var o8=Xl.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var r=i(gn),n=i(P0),a=i(o8),s=i(Er);function i(u){return u&&u.__esModule?u:{default:u}}var o=6048e5;function c(u){(0,s.default)(1,arguments);var l=(0,r.default)(u),d=(0,n.default)(l).getTime()-(0,a.default)(l).getTime();return Math.round(d/o)+1}e.exports=t.default})(Zl,Zl.exports);var c8=Zl.exports,ed={exports:{}},td={exports:{}},Ua={};Object.defineProperty(Ua,"__esModule",{value:!0});Ua.getDefaultOptions=u8;Ua.setDefaultOptions=l8;var Fy={};function u8(){return Fy}function l8(e){Fy=e}(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var r=i(gn),n=i(Er),a=i(Oa),s=Ua;function i(c){return c&&c.__esModule?c:{default:c}}function o(c,u){var l,d,h,p,f,g,y,b;(0,n.default)(1,arguments);var m=(0,s.getDefaultOptions)(),v=(0,a.default)((l=(d=(h=(p=u==null?void 0:u.weekStartsOn)!==null&&p!==void 0?p:u==null||(f=u.locale)===null||f===void 0||(g=f.options)===null||g===void 0?void 0:g.weekStartsOn)!==null&&h!==void 0?h:m.weekStartsOn)!==null&&d!==void 0?d:(y=m.locale)===null||y===void 0||(b=y.options)===null||b===void 0?void 0:b.weekStartsOn)!==null&&l!==void 0?l:0);if(!(v>=0&&v<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");var S=(0,r.default)(c),C=S.getUTCDay(),E=(C<v?7:0)+C-v;return S.setUTCDate(S.getUTCDate()-E),S.setUTCHours(0,0,0,0),S}e.exports=t.default})(td,td.exports);var _0=td.exports,rd={exports:{}},nd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var r=o(gn),n=o(Er),a=o(_0),s=o(Oa),i=Ua;function o(u){return u&&u.__esModule?u:{default:u}}function c(u,l){var d,h,p,f,g,y,b,m;(0,n.default)(1,arguments);var v=(0,r.default)(u),S=v.getUTCFullYear(),C=(0,i.getDefaultOptions)(),E=(0,s.default)((d=(h=(p=(f=l==null?void 0:l.firstWeekContainsDate)!==null&&f!==void 0?f:l==null||(g=l.locale)===null||g===void 0||(y=g.options)===null||y===void 0?void 0:y.firstWeekContainsDate)!==null&&p!==void 0?p:C.firstWeekContainsDate)!==null&&h!==void 0?h:(b=C.locale)===null||b===void 0||(m=b.options)===null||m===void 0?void 0:m.firstWeekContainsDate)!==null&&d!==void 0?d:1);if(!(E>=1&&E<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var w=new Date(0);w.setUTCFullYear(S+1,0,E),w.setUTCHours(0,0,0,0);var _=(0,a.default)(w,l),P=new Date(0);P.setUTCFullYear(S,0,E),P.setUTCHours(0,0,0,0);var x=(0,a.default)(P,l);return v.getTime()>=_.getTime()?S+1:v.getTime()>=x.getTime()?S:S-1}e.exports=t.default})(nd,nd.exports);var qy=nd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var r=o(qy),n=o(Er),a=o(_0),s=o(Oa),i=Ua;function o(u){return u&&u.__esModule?u:{default:u}}function c(u,l){var d,h,p,f,g,y,b,m;(0,n.default)(1,arguments);var v=(0,i.getDefaultOptions)(),S=(0,s.default)((d=(h=(p=(f=l==null?void 0:l.firstWeekContainsDate)!==null&&f!==void 0?f:l==null||(g=l.locale)===null||g===void 0||(y=g.options)===null||y===void 0?void 0:y.firstWeekContainsDate)!==null&&p!==void 0?p:v.firstWeekContainsDate)!==null&&h!==void 0?h:(b=v.locale)===null||b===void 0||(m=b.options)===null||m===void 0?void 0:m.firstWeekContainsDate)!==null&&d!==void 0?d:1),C=(0,r.default)(u,l),E=new Date(0);E.setUTCFullYear(C,0,S),E.setUTCHours(0,0,0,0);var w=(0,a.default)(E,l);return w}e.exports=t.default})(rd,rd.exports);var d8=rd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var r=i(gn),n=i(_0),a=i(d8),s=i(Er);function i(u){return u&&u.__esModule?u:{default:u}}var o=6048e5;function c(u,l){(0,s.default)(1,arguments);var d=(0,r.default)(u),h=(0,n.default)(d,l).getTime()-(0,a.default)(d,l).getTime();return Math.round(h/o)+1}e.exports=t.default})(ed,ed.exports);var h8=ed.exports,ad={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n,a){for(var s=n<0?"-":"",i=Math.abs(n).toString();i.length<a;)i="0"+i;return s+i}e.exports=t.default})(ad,ad.exports);var Hy=ad.exports,sd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(Hy);function n(i){return i&&i.__esModule?i:{default:i}}var a={y:function(i,o){var c=i.getUTCFullYear(),u=c>0?c:1-c;return(0,r.default)(o==="yy"?u%100:u,o.length)},M:function(i,o){var c=i.getUTCMonth();return o==="M"?String(c+1):(0,r.default)(c+1,2)},d:function(i,o){return(0,r.default)(i.getUTCDate(),o.length)},a:function(i,o){var c=i.getUTCHours()/12>=1?"pm":"am";switch(o){case"a":case"aa":return c.toUpperCase();case"aaa":return c;case"aaaaa":return c[0];case"aaaa":default:return c==="am"?"a.m.":"p.m."}},h:function(i,o){return(0,r.default)(i.getUTCHours()%12||12,o.length)},H:function(i,o){return(0,r.default)(i.getUTCHours(),o.length)},m:function(i,o){return(0,r.default)(i.getUTCMinutes(),o.length)},s:function(i,o){return(0,r.default)(i.getUTCSeconds(),o.length)},S:function(i,o){var c=o.length,u=i.getUTCMilliseconds(),l=Math.floor(u*Math.pow(10,c-3));return(0,r.default)(l,o.length)}},s=a;t.default=s,e.exports=t.default})(sd,sd.exports);var p8=sd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=u(i8),n=u(c8),a=u(jy),s=u(h8),i=u(qy),o=u(Hy),c=u(p8);function u(y){return y&&y.__esModule?y:{default:y}}var l={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},d={G:function(y,b,m){var v=y.getUTCFullYear()>0?1:0;switch(b){case"G":case"GG":case"GGG":return m.era(v,{width:"abbreviated"});case"GGGGG":return m.era(v,{width:"narrow"});case"GGGG":default:return m.era(v,{width:"wide"})}},y:function(y,b,m){if(b==="yo"){var v=y.getUTCFullYear(),S=v>0?v:1-v;return m.ordinalNumber(S,{unit:"year"})}return c.default.y(y,b)},Y:function(y,b,m,v){var S=(0,i.default)(y,v),C=S>0?S:1-S;if(b==="YY"){var E=C%100;return(0,o.default)(E,2)}return b==="Yo"?m.ordinalNumber(C,{unit:"year"}):(0,o.default)(C,b.length)},R:function(y,b){var m=(0,a.default)(y);return(0,o.default)(m,b.length)},u:function(y,b){var m=y.getUTCFullYear();return(0,o.default)(m,b.length)},Q:function(y,b,m){var v=Math.ceil((y.getUTCMonth()+1)/3);switch(b){case"Q":return String(v);case"QQ":return(0,o.default)(v,2);case"Qo":return m.ordinalNumber(v,{unit:"quarter"});case"QQQ":return m.quarter(v,{width:"abbreviated",context:"formatting"});case"QQQQQ":return m.quarter(v,{width:"narrow",context:"formatting"});case"QQQQ":default:return m.quarter(v,{width:"wide",context:"formatting"})}},q:function(y,b,m){var v=Math.ceil((y.getUTCMonth()+1)/3);switch(b){case"q":return String(v);case"qq":return(0,o.default)(v,2);case"qo":return m.ordinalNumber(v,{unit:"quarter"});case"qqq":return m.quarter(v,{width:"abbreviated",context:"standalone"});case"qqqqq":return m.quarter(v,{width:"narrow",context:"standalone"});case"qqqq":default:return m.quarter(v,{width:"wide",context:"standalone"})}},M:function(y,b,m){var v=y.getUTCMonth();switch(b){case"M":case"MM":return c.default.M(y,b);case"Mo":return m.ordinalNumber(v+1,{unit:"month"});case"MMM":return m.month(v,{width:"abbreviated",context:"formatting"});case"MMMMM":return m.month(v,{width:"narrow",context:"formatting"});case"MMMM":default:return m.month(v,{width:"wide",context:"formatting"})}},L:function(y,b,m){var v=y.getUTCMonth();switch(b){case"L":return String(v+1);case"LL":return(0,o.default)(v+1,2);case"Lo":return m.ordinalNumber(v+1,{unit:"month"});case"LLL":return m.month(v,{width:"abbreviated",context:"standalone"});case"LLLLL":return m.month(v,{width:"narrow",context:"standalone"});case"LLLL":default:return m.month(v,{width:"wide",context:"standalone"})}},w:function(y,b,m,v){var S=(0,s.default)(y,v);return b==="wo"?m.ordinalNumber(S,{unit:"week"}):(0,o.default)(S,b.length)},I:function(y,b,m){var v=(0,n.default)(y);return b==="Io"?m.ordinalNumber(v,{unit:"week"}):(0,o.default)(v,b.length)},d:function(y,b,m){return b==="do"?m.ordinalNumber(y.getUTCDate(),{unit:"date"}):c.default.d(y,b)},D:function(y,b,m){var v=(0,r.default)(y);return b==="Do"?m.ordinalNumber(v,{unit:"dayOfYear"}):(0,o.default)(v,b.length)},E:function(y,b,m){var v=y.getUTCDay();switch(b){case"E":case"EE":case"EEE":return m.day(v,{width:"abbreviated",context:"formatting"});case"EEEEE":return m.day(v,{width:"narrow",context:"formatting"});case"EEEEEE":return m.day(v,{width:"short",context:"formatting"});case"EEEE":default:return m.day(v,{width:"wide",context:"formatting"})}},e:function(y,b,m,v){var S=y.getUTCDay(),C=(S-v.weekStartsOn+8)%7||7;switch(b){case"e":return String(C);case"ee":return(0,o.default)(C,2);case"eo":return m.ordinalNumber(C,{unit:"day"});case"eee":return m.day(S,{width:"abbreviated",context:"formatting"});case"eeeee":return m.day(S,{width:"narrow",context:"formatting"});case"eeeeee":return m.day(S,{width:"short",context:"formatting"});case"eeee":default:return m.day(S,{width:"wide",context:"formatting"})}},c:function(y,b,m,v){var S=y.getUTCDay(),C=(S-v.weekStartsOn+8)%7||7;switch(b){case"c":return String(C);case"cc":return(0,o.default)(C,b.length);case"co":return m.ordinalNumber(C,{unit:"day"});case"ccc":return m.day(S,{width:"abbreviated",context:"standalone"});case"ccccc":return m.day(S,{width:"narrow",context:"standalone"});case"cccccc":return m.day(S,{width:"short",context:"standalone"});case"cccc":default:return m.day(S,{width:"wide",context:"standalone"})}},i:function(y,b,m){var v=y.getUTCDay(),S=v===0?7:v;switch(b){case"i":return String(S);case"ii":return(0,o.default)(S,b.length);case"io":return m.ordinalNumber(S,{unit:"day"});case"iii":return m.day(v,{width:"abbreviated",context:"formatting"});case"iiiii":return m.day(v,{width:"narrow",context:"formatting"});case"iiiiii":return m.day(v,{width:"short",context:"formatting"});case"iiii":default:return m.day(v,{width:"wide",context:"formatting"})}},a:function(y,b,m){var v=y.getUTCHours(),S=v/12>=1?"pm":"am";switch(b){case"a":case"aa":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"aaa":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return m.dayPeriod(S,{width:"narrow",context:"formatting"});case"aaaa":default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},b:function(y,b,m){var v=y.getUTCHours(),S;switch(v===12?S=l.noon:v===0?S=l.midnight:S=v/12>=1?"pm":"am",b){case"b":case"bb":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"bbb":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return m.dayPeriod(S,{width:"narrow",context:"formatting"});case"bbbb":default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},B:function(y,b,m){var v=y.getUTCHours(),S;switch(v>=17?S=l.evening:v>=12?S=l.afternoon:v>=4?S=l.morning:S=l.night,b){case"B":case"BB":case"BBB":return m.dayPeriod(S,{width:"abbreviated",context:"formatting"});case"BBBBB":return m.dayPeriod(S,{width:"narrow",context:"formatting"});case"BBBB":default:return m.dayPeriod(S,{width:"wide",context:"formatting"})}},h:function(y,b,m){if(b==="ho"){var v=y.getUTCHours()%12;return v===0&&(v=12),m.ordinalNumber(v,{unit:"hour"})}return c.default.h(y,b)},H:function(y,b,m){return b==="Ho"?m.ordinalNumber(y.getUTCHours(),{unit:"hour"}):c.default.H(y,b)},K:function(y,b,m){var v=y.getUTCHours()%12;return b==="Ko"?m.ordinalNumber(v,{unit:"hour"}):(0,o.default)(v,b.length)},k:function(y,b,m){var v=y.getUTCHours();return v===0&&(v=24),b==="ko"?m.ordinalNumber(v,{unit:"hour"}):(0,o.default)(v,b.length)},m:function(y,b,m){return b==="mo"?m.ordinalNumber(y.getUTCMinutes(),{unit:"minute"}):c.default.m(y,b)},s:function(y,b,m){return b==="so"?m.ordinalNumber(y.getUTCSeconds(),{unit:"second"}):c.default.s(y,b)},S:function(y,b){return c.default.S(y,b)},X:function(y,b,m,v){var S=v._originalDate||y,C=S.getTimezoneOffset();if(C===0)return"Z";switch(b){case"X":return p(C);case"XXXX":case"XX":return f(C);case"XXXXX":case"XXX":default:return f(C,":")}},x:function(y,b,m,v){var S=v._originalDate||y,C=S.getTimezoneOffset();switch(b){case"x":return p(C);case"xxxx":case"xx":return f(C);case"xxxxx":case"xxx":default:return f(C,":")}},O:function(y,b,m,v){var S=v._originalDate||y,C=S.getTimezoneOffset();switch(b){case"O":case"OO":case"OOO":return"GMT"+h(C,":");case"OOOO":default:return"GMT"+f(C,":")}},z:function(y,b,m,v){var S=v._originalDate||y,C=S.getTimezoneOffset();switch(b){case"z":case"zz":case"zzz":return"GMT"+h(C,":");case"zzzz":default:return"GMT"+f(C,":")}},t:function(y,b,m,v){var S=v._originalDate||y,C=Math.floor(S.getTime()/1e3);return(0,o.default)(C,b.length)},T:function(y,b,m,v){var S=v._originalDate||y,C=S.getTime();return(0,o.default)(C,b.length)}};function h(y,b){var m=y>0?"-":"+",v=Math.abs(y),S=Math.floor(v/60),C=v%60;if(C===0)return m+String(S);var E=b;return m+String(S)+E+(0,o.default)(C,2)}function p(y,b){if(y%60===0){var m=y>0?"-":"+";return m+(0,o.default)(Math.abs(y)/60,2)}return f(y,b)}function f(y,b){var m=b||"",v=y>0?"-":"+",S=Math.abs(y),C=(0,o.default)(Math.floor(S/60),2),E=(0,o.default)(S%60,2);return v+C+m+E}var g=d;t.default=g,e.exports=t.default})(Ql,Ql.exports);var f8=Ql.exports,id={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(o,c){switch(o){case"P":return c.date({width:"short"});case"PP":return c.date({width:"medium"});case"PPP":return c.date({width:"long"});case"PPPP":default:return c.date({width:"full"})}},n=function(o,c){switch(o){case"p":return c.time({width:"short"});case"pp":return c.time({width:"medium"});case"ppp":return c.time({width:"long"});case"pppp":default:return c.time({width:"full"})}},a=function(o,c){var u=o.match(/(P+)(p+)?/)||[],l=u[1],d=u[2];if(!d)return r(o,c);var h;switch(l){case"P":h=c.dateTime({width:"short"});break;case"PP":h=c.dateTime({width:"medium"});break;case"PPP":h=c.dateTime({width:"long"});break;case"PPPP":default:h=c.dateTime({width:"full"});break}return h.replace("{{date}}",r(l,c)).replace("{{time}}",n(d,c))},s={p:n,P:a},i=s;t.default=i,e.exports=t.default})(id,id.exports);var g8=id.exports,od={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n){var a=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()));return a.setUTCFullYear(n.getFullYear()),n.getTime()-a.getTime()}e.exports=t.default})(od,od.exports);var Ky=od.exports,wi={};Object.defineProperty(wi,"__esModule",{value:!0});wi.isProtectedDayOfYearToken=v8;wi.isProtectedWeekYearToken=b8;wi.throwProtectedError=C8;var m8=["D","DD"],y8=["YY","YYYY"];function v8(e){return m8.indexOf(e)!==-1}function b8(e){return y8.indexOf(e)!==-1}function C8(e,t,r){if(e==="YYYY")throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(t,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="YY")throw new RangeError("Use `yy` instead of `YY` (in `".concat(t,"`) for formatting years to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="D")throw new RangeError("Use `d` instead of `D` (in `".concat(t,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));if(e==="DD")throw new RangeError("Use `dd` instead of `DD` (in `".concat(t,"`) for formatting days of the month to the input `").concat(r,"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"))}var cd={exports:{}},ud={exports:{}},ld={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},n=function(s,i,o){var c,u=r[s];return typeof u=="string"?c=u:i===1?c=u.one:c=u.other.replace("{{count}}",i.toString()),o!=null&&o.addSuffix?o.comparison&&o.comparison>0?"in "+c:c+" ago":c},a=n;t.default=a,e.exports=t.default})(ld,ld.exports);var S8=ld.exports,dd={exports:{}},hd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n){return function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=a.width?String(a.width):n.defaultWidth,i=n.formats[s]||n.formats[n.defaultWidth];return i}}e.exports=t.default})(hd,hd.exports);var E8=hd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(E8);function n(u){return u&&u.__esModule?u:{default:u}}var a={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},s={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},i={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},o={date:(0,r.default)({formats:a,defaultWidth:"full"}),time:(0,r.default)({formats:s,defaultWidth:"full"}),dateTime:(0,r.default)({formats:i,defaultWidth:"full"})},c=o;t.default=c,e.exports=t.default})(dd,dd.exports);var x8=dd.exports,pd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},n=function(s,i,o,c){return r[s]},a=n;t.default=a,e.exports=t.default})(pd,pd.exports);var w8=pd.exports,fd={exports:{}},gd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n){return function(a,s){var i=s!=null&&s.context?String(s.context):"standalone",o;if(i==="formatting"&&n.formattingValues){var c=n.defaultFormattingWidth||n.defaultWidth,u=s!=null&&s.width?String(s.width):c;o=n.formattingValues[u]||n.formattingValues[c]}else{var l=n.defaultWidth,d=s!=null&&s.width?String(s.width):n.defaultWidth;o=n.values[d]||n.values[l]}var h=n.argumentCallback?n.argumentCallback(a):a;return o[h]}}e.exports=t.default})(gd,gd.exports);var T8=gd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(T8);function n(p){return p&&p.__esModule?p:{default:p}}var a={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},s={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},i={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},o={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},c={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},u={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},l=function(p,f){var g=Number(p),y=g%100;if(y>20||y<10)switch(y%10){case 1:return g+"st";case 2:return g+"nd";case 3:return g+"rd"}return g+"th"},d={ordinalNumber:l,era:(0,r.default)({values:a,defaultWidth:"wide"}),quarter:(0,r.default)({values:s,defaultWidth:"wide",argumentCallback:function(p){return p-1}}),month:(0,r.default)({values:i,defaultWidth:"wide"}),day:(0,r.default)({values:o,defaultWidth:"wide"}),dayPeriod:(0,r.default)({values:c,defaultWidth:"wide",formattingValues:u,defaultFormattingWidth:"wide"})},h=d;t.default=h,e.exports=t.default})(fd,fd.exports);var $8=fd.exports,md={exports:{}},yd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(s){return function(i){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},c=o.width,u=c&&s.matchPatterns[c]||s.matchPatterns[s.defaultMatchWidth],l=i.match(u);if(!l)return null;var d=l[0],h=c&&s.parsePatterns[c]||s.parsePatterns[s.defaultParseWidth],p=Array.isArray(h)?a(h,function(y){return y.test(d)}):n(h,function(y){return y.test(d)}),f;f=s.valueCallback?s.valueCallback(p):p,f=o.valueCallback?o.valueCallback(f):f;var g=i.slice(d.length);return{value:f,rest:g}}}function n(s,i){for(var o in s)if(s.hasOwnProperty(o)&&i(s[o]))return o}function a(s,i){for(var o=0;o<s.length;o++)if(i(s[o]))return o}e.exports=t.default})(yd,yd.exports);var A8=yd.exports,vd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n){return function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=a.match(n.matchPattern);if(!i)return null;var o=i[0],c=a.match(n.parsePattern);if(!c)return null;var u=n.valueCallback?n.valueCallback(c[0]):c[0];u=s.valueCallback?s.valueCallback(u):u;var l=a.slice(o.length);return{value:u,rest:l}}}e.exports=t.default})(vd,vd.exports);var I8=vd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=a(A8),n=a(I8);function a(v){return v&&v.__esModule?v:{default:v}}var s=/^(\d+)(th|st|nd|rd)?/i,i=/\d+/i,o={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},c={any:[/^b/i,/^(a|c)/i]},u={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},l={any:[/1/i,/2/i,/3/i,/4/i]},d={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},h={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},p={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},f={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},g={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},y={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},b={ordinalNumber:(0,n.default)({matchPattern:s,parsePattern:i,valueCallback:function(v){return parseInt(v,10)}}),era:(0,r.default)({matchPatterns:o,defaultMatchWidth:"wide",parsePatterns:c,defaultParseWidth:"any"}),quarter:(0,r.default)({matchPatterns:u,defaultMatchWidth:"wide",parsePatterns:l,defaultParseWidth:"any",valueCallback:function(v){return v+1}}),month:(0,r.default)({matchPatterns:d,defaultMatchWidth:"wide",parsePatterns:h,defaultParseWidth:"any"}),day:(0,r.default)({matchPatterns:p,defaultMatchWidth:"wide",parsePatterns:f,defaultParseWidth:"any"}),dayPeriod:(0,r.default)({matchPatterns:g,defaultMatchWidth:"any",parsePatterns:y,defaultParseWidth:"any"})},m=b;t.default=m,e.exports=t.default})(md,md.exports);var P8=md.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=o(S8),n=o(x8),a=o(w8),s=o($8),i=o(P8);function o(l){return l&&l.__esModule?l:{default:l}}var c={code:"en-US",formatDistance:r.default,formatLong:n.default,formatRelative:a.default,localize:s.default,match:i.default,options:{weekStartsOn:0,firstWeekContainsDate:1}},u=c;t.default=u,e.exports=t.default})(ud,ud.exports);var _8=ud.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(_8);function n(s){return s&&s.__esModule?s:{default:s}}var a=r.default;t.default=a,e.exports=t.default})(cd,cd.exports);var D8=cd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=v;var r=p(n8),n=p(s8),a=p(gn),s=p(f8),i=p(g8),o=p(Ky),c=wi,u=p(Oa),l=p(Er),d=Ua,h=p(D8);function p(C){return C&&C.__esModule?C:{default:C}}var f=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,g=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,y=/^'([^]*?)'?$/,b=/''/g,m=/[a-zA-Z]/;function v(C,E,w){var _,P,x,R,B,K,re,ee,ie,se,Ce,Ie,ye,L,X,ne,U,be;(0,l.default)(2,arguments);var xe=String(E),Ne=(0,d.getDefaultOptions)(),he=(_=(P=w==null?void 0:w.locale)!==null&&P!==void 0?P:Ne.locale)!==null&&_!==void 0?_:h.default,_e=(0,u.default)((x=(R=(B=(K=w==null?void 0:w.firstWeekContainsDate)!==null&&K!==void 0?K:w==null||(re=w.locale)===null||re===void 0||(ee=re.options)===null||ee===void 0?void 0:ee.firstWeekContainsDate)!==null&&B!==void 0?B:Ne.firstWeekContainsDate)!==null&&R!==void 0?R:(ie=Ne.locale)===null||ie===void 0||(se=ie.options)===null||se===void 0?void 0:se.firstWeekContainsDate)!==null&&x!==void 0?x:1);if(!(_e>=1&&_e<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");var I=(0,u.default)((Ce=(Ie=(ye=(L=w==null?void 0:w.weekStartsOn)!==null&&L!==void 0?L:w==null||(X=w.locale)===null||X===void 0||(ne=X.options)===null||ne===void 0?void 0:ne.weekStartsOn)!==null&&ye!==void 0?ye:Ne.weekStartsOn)!==null&&Ie!==void 0?Ie:(U=Ne.locale)===null||U===void 0||(be=U.options)===null||be===void 0?void 0:be.weekStartsOn)!==null&&Ce!==void 0?Ce:0);if(!(I>=0&&I<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");if(!he.localize)throw new RangeError("locale must contain localize property");if(!he.formatLong)throw new RangeError("locale must contain formatLong property");var D=(0,a.default)(C);if(!(0,r.default)(D))throw new RangeError("Invalid time value");var N=(0,o.default)(D),q=(0,n.default)(D,N),k={firstWeekContainsDate:_e,weekStartsOn:I,locale:he,_originalDate:D},V=xe.match(g).map(function(W){var j=W[0];if(j==="p"||j==="P"){var z=i.default[j];return z(W,he.formatLong)}return W}).join("").match(f).map(function(W){if(W==="''")return"'";var j=W[0];if(j==="'")return S(W);var z=s.default[j];if(z)return!(w!=null&&w.useAdditionalWeekYearTokens)&&(0,c.isProtectedWeekYearToken)(W)&&(0,c.throwProtectedError)(W,E,String(C)),!(w!=null&&w.useAdditionalDayOfYearTokens)&&(0,c.isProtectedDayOfYearToken)(W)&&(0,c.throwProtectedError)(W,E,String(C)),z(q,W,he.localize,k);if(j.match(m))throw new RangeError("Format string contains an unescaped latin alphabet character `"+j+"`");return W}).join("");return V}function S(C){var E=C.match(y);return E?E[1].replace(b,"'"):C}e.exports=t.default})(jl,jl.exports);var R8=jl.exports,bd={exports:{}},Cd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(i,o,c){var u=s(i,c.timeZone,c.locale);return u.formatToParts?n(u,o):a(u,o)}function n(i,o){for(var c=i.formatToParts(o),u=c.length-1;u>=0;--u)if(c[u].type==="timeZoneName")return c[u].value}function a(i,o){var c=i.format(o).replace(/\u200E/g,""),u=/ [\w-+ ]+$/.exec(c);return u?u[0].substr(1):""}function s(i,o,c){if(c&&!c.code)throw new Error("date-fns-tz error: Please set a language code on the locale object imported from date-fns, e.g. `locale.code = 'en-US'`");return new Intl.DateTimeFormat(c?[c.code,"en-US"]:void 0,{timeZone:o,timeZoneName:i})}e.exports=t.default})(Cd,Cd.exports);var N8=Cd.exports,Sd={exports:{}},Ed={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(c,u){var l=o(u);return l.formatToParts?a(l,c):s(l,c)}var n={year:0,month:1,day:2,hour:3,minute:4,second:5};function a(c,u){try{for(var l=c.formatToParts(u),d=[],h=0;h<l.length;h++){var p=n[l[h].type];p>=0&&(d[p]=parseInt(l[h].value,10))}return d}catch(f){if(f instanceof RangeError)return[NaN];throw f}}function s(c,u){var l=c.format(u).replace(/\u200E/g,""),d=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(l);return[d[3],d[1],d[2],d[4],d[5],d[6]]}var i={};function o(c){if(!i[c]){var u=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),l=u==="06/25/2014, 00:00:00"||u==="‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";i[c]=l?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:c,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:c,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return i[c]}e.exports=t.default})(Ed,Ed.exports);var B8=Ed.exports,xd={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;function r(n,a,s,i,o,c,u){var l=new Date(0);return l.setUTCFullYear(n,a,s),l.setUTCHours(i,o,c,u),l}e.exports=t.default})(xd,xd.exports);var k8=xd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var r=a(B8),n=a(k8);function a(g){return g&&g.__esModule?g:{default:g}}var s=36e5,i=6e4,o={timezone:/([Z+-].*)$/,timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function c(g,y,b){var m,v;if(g===""||(m=o.timezoneZ.exec(g),m))return 0;var S;if(m=o.timezoneHH.exec(g),m)return S=parseInt(m[1],10),h(S)?-(S*s):NaN;if(m=o.timezoneHHMM.exec(g),m){S=parseInt(m[1],10);var C=parseInt(m[2],10);return h(S,C)?(v=Math.abs(S)*s+C*i,S>0?-v:v):NaN}if(f(g)){y=new Date(y||Date.now());var E=b?y:u(y),w=l(E,g),_=b?w:d(y,w,g);return-_}return NaN}function u(g){return(0,n.default)(g.getFullYear(),g.getMonth(),g.getDate(),g.getHours(),g.getMinutes(),g.getSeconds(),g.getMilliseconds())}function l(g,y){var b=(0,r.default)(g,y),m=(0,n.default)(b[0],b[1]-1,b[2],b[3]%24,b[4],b[5],0).getTime(),v=g.getTime(),S=v%1e3;return v-=S>=0?S:1e3+S,m-v}function d(g,y,b){var m=g.getTime(),v=m-y,S=l(new Date(v),b);if(y===S)return y;v-=S-y;var C=l(new Date(v),b);return S===C?S:Math.max(S,C)}function h(g,y){return-23<=g&&g<=23&&(y==null||0<=y&&y<=59)}var p={};function f(g){if(p[g])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:g}),p[g]=!0,!0}catch{return!1}}e.exports=t.default})(Sd,Sd.exports);var D0=Sd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=a(N8),n=a(D0);function a(p){return p&&p.__esModule?p:{default:p}}var s=60*1e3,i={X:function(p,f,g,y){var b=o(y.timeZone,y._originalDate||p);if(b===0)return"Z";switch(f){case"X":return l(b);case"XXXX":case"XX":return u(b);case"XXXXX":case"XXX":default:return u(b,":")}},x:function(p,f,g,y){var b=o(y.timeZone,y._originalDate||p);switch(f){case"x":return l(b);case"xxxx":case"xx":return u(b);case"xxxxx":case"xxx":default:return u(b,":")}},O:function(p,f,g,y){var b=o(y.timeZone,y._originalDate||p);switch(f){case"O":case"OO":case"OOO":return"GMT"+d(b,":");case"OOOO":default:return"GMT"+u(b,":")}},z:function(p,f,g,y){var b=y._originalDate||p;switch(f){case"z":case"zz":case"zzz":return(0,r.default)("short",b,y);case"zzzz":default:return(0,r.default)("long",b,y)}}};function o(p,f){var g=p?(0,n.default)(p,f,!0)/s:f.getTimezoneOffset();if(Number.isNaN(g))throw new RangeError("Invalid time zone specified: "+p);return g}function c(p,f){for(var g=p<0?"-":"",y=Math.abs(p).toString();y.length<f;)y="0"+y;return g+y}function u(p,f){var g=f||"",y=p>0?"-":"+",b=Math.abs(p),m=c(Math.floor(b/60),2),v=c(Math.floor(b%60),2);return y+m+g+v}function l(p,f){if(p%60===0){var g=p>0?"-":"+";return g+c(Math.abs(p)/60,2)}return u(p,f)}function d(p,f){var g=p>0?"-":"+",y=Math.abs(p),b=Math.floor(y/60),m=y%60;if(m===0)return g+String(b);var v=f;return g+String(b)+v+c(m,2)}var h=i;t.default=h,e.exports=t.default})(bd,bd.exports);var O8=bd.exports,wd={exports:{}},Td={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,n=r;t.default=n,e.exports=t.default})(Td,Td.exports);var U8=Td.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=d;var r=i(Oa),n=i(Ky),a=i(D0),s=i(U8);function i(_){return _&&_.__esModule?_:{default:_}}var o=36e5,c=6e4,u=2,l={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,plainTime:/:/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:s.default};function d(_,P){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(_===null)return new Date(NaN);var x=P||{},R=x.additionalDigits==null?u:(0,r.default)(x.additionalDigits);if(R!==2&&R!==1&&R!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(_ instanceof Date||typeof _=="object"&&Object.prototype.toString.call(_)==="[object Date]")return new Date(_.getTime());if(typeof _=="number"||Object.prototype.toString.call(_)==="[object Number]")return new Date(_);if(!(typeof _=="string"||Object.prototype.toString.call(_)==="[object String]"))return new Date(NaN);var B=h(_),K=p(B.date,R),re=K.year,ee=K.restDateString,ie=f(ee,re);if(isNaN(ie))return new Date(NaN);if(ie){var se=ie.getTime(),Ce=0,Ie;if(B.time&&(Ce=g(B.time),isNaN(Ce)))return new Date(NaN);if(B.timeZone||x.timeZone){if(Ie=(0,a.default)(B.timeZone||x.timeZone,new Date(se+Ce)),isNaN(Ie))return new Date(NaN)}else Ie=(0,n.default)(new Date(se+Ce)),Ie=(0,n.default)(new Date(se+Ce+Ie));return new Date(se+Ce+Ie)}else return new Date(NaN)}function h(_){var P={},x=l.dateTimePattern.exec(_),R;if(x?(P.date=x[1],R=x[3]):(x=l.datePattern.exec(_),x?(P.date=x[1],R=x[2]):(P.date=null,R=_)),R){var B=l.timeZone.exec(R);B?(P.time=R.replace(B[1],""),P.timeZone=B[1].trim()):P.time=R}return P}function p(_,P){var x=l.YYY[P],R=l.YYYYY[P],B;if(B=l.YYYY.exec(_)||R.exec(_),B){var K=B[1];return{year:parseInt(K,10),restDateString:_.slice(K.length)}}if(B=l.YY.exec(_)||x.exec(_),B){var re=B[1];return{year:parseInt(re,10)*100,restDateString:_.slice(re.length)}}return{year:null}}function f(_,P){if(P===null)return null;var x,R,B,K;if(_.length===0)return R=new Date(0),R.setUTCFullYear(P),R;if(x=l.MM.exec(_),x)return R=new Date(0),B=parseInt(x[1],10)-1,S(P,B)?(R.setUTCFullYear(P,B),R):new Date(NaN);if(x=l.DDD.exec(_),x){R=new Date(0);var re=parseInt(x[1],10);return C(P,re)?(R.setUTCFullYear(P,0,re),R):new Date(NaN)}if(x=l.MMDD.exec(_),x){R=new Date(0),B=parseInt(x[1],10)-1;var ee=parseInt(x[2],10);return S(P,B,ee)?(R.setUTCFullYear(P,B,ee),R):new Date(NaN)}if(x=l.Www.exec(_),x)return K=parseInt(x[1],10)-1,E(P,K)?y(P,K):new Date(NaN);if(x=l.WwwD.exec(_),x){K=parseInt(x[1],10)-1;var ie=parseInt(x[2],10)-1;return E(P,K,ie)?y(P,K,ie):new Date(NaN)}return null}function g(_){var P,x,R;if(P=l.HH.exec(_),P)return x=parseFloat(P[1].replace(",",".")),w(x)?x%24*o:NaN;if(P=l.HHMM.exec(_),P)return x=parseInt(P[1],10),R=parseFloat(P[2].replace(",",".")),w(x,R)?x%24*o+R*c:NaN;if(P=l.HHMMSS.exec(_),P){x=parseInt(P[1],10),R=parseInt(P[2],10);var B=parseFloat(P[3].replace(",","."));return w(x,R,B)?x%24*o+R*c+B*1e3:NaN}return null}function y(_,P,x){P=P||0,x=x||0;var R=new Date(0);R.setUTCFullYear(_,0,4);var B=R.getUTCDay()||7,K=P*7+x+1-B;return R.setUTCDate(R.getUTCDate()+K),R}var b=[31,28,31,30,31,30,31,31,30,31,30,31],m=[31,29,31,30,31,30,31,31,30,31,30,31];function v(_){return _%400===0||_%4===0&&_%100!==0}function S(_,P,x){if(P<0||P>11)return!1;if(x!=null){if(x<1)return!1;var R=v(_);if(R&&x>m[P]||!R&&x>b[P])return!1}return!0}function C(_,P){if(P<1)return!1;var x=v(_);return!(x&&P>366||!x&&P>365)}function E(_,P,x){return!(P<0||P>52||x!=null&&(x<0||x>6))}function w(_,P,x){return!(_!=null&&(_<0||_>=25)||P!=null&&(P<0||P>=60)||x!=null&&(x<0||x>=60))}e.exports=t.default})(wd,wd.exports);var Vy=wd.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var r=s(R8),n=s(O8),a=s(Vy);function s(c){return c&&c.__esModule?c:{default:c}}var i=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function o(c,u,l){var d=String(u),h=l||{},p=d.match(i);if(p){var f=(0,a.default)(c,h);d=p.reduce(function(g,y){if(y[0]==="'")return g;var b=g.indexOf(y),m=g[b-1]==="'",v=g.replace(y,"'"+n.default[y[0]](f,y,null,h)+"'");return m?v.substring(0,b-1)+v.substring(b+1):v},d)}return(0,r.default)(c,d,h)}e.exports=t.default})(Ml,Ml.exports);var L8=Ml.exports,$d={exports:{}};(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;var r=a(D0),n=a(Vy);function a(i){return i&&i.__esModule?i:{default:i}}function s(i,o,c){var u=(0,n.default)(i,c),l=(0,r.default)(o,u,!0),d=new Date(u.getTime()-l),h=new Date(0);return h.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),h.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),h}e.exports=t.default})($d,$d.exports);var M8=$d.exports;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var r=s(t8),n=s(L8),a=s(M8);function s(o){return o&&o.__esModule?o:{default:o}}function i(o,c,u,l){var d=(0,r.default)(l);return d.timeZone=c,(0,n.default)((0,a.default)(o,c),u,d)}e.exports=t.default})(Ol,Ol.exports);var j8=Ol.exports;const Fa=us(j8),KR=()=>{const e=$a(r=>r.companies.branchOffice.timeZone==="-6"||r.companies.branchOffice.timeZone===""?"America/Mexico_City":r.companies.branchOffice.timeZone??"America/Mexico_City"),t=Ot(r=>`${r.settings.dateTimePattern.datePattern} ${r.settings.dateTimePattern.timePattern}`.trim()===""?"dd/MM/yyyy hh:mm:ss a":`${r.settings.dateTimePattern.datePattern} ${r.settings.dateTimePattern.timePattern}`);return{formatDateTimeZone:(r,n,a,s)=>{let i=new Date(r??0);if(n!==void 0&&r!==void 0&&(i=k0(O0(U0(i,n.year??0),n.month??0),n.days??0)),s!==void 0&&r!==void 0&&(i=L0(M0(j0(i,s.year??0),s.month??0),s.days??0)),a&&r){const o=Fa(i,e,t).substring(0,10);t.substring(0,10)==="dd/MM/yyyy"?i=new Date(a.year??Number(o.split("/")[2]),a.month??Number(o.split("/")[1])-1,a.days??Number(o.split("/")[0])):i=new Date(a.year??Number(o.split("/")[2]),a.month??Number(o.split("/")[0])-1,a.days??Number(o.split("/")[1]));const c=new Date(Fa(new Date().getTime(),e,"MM/dd/yyyy hh:mm:ss a")).getHours();i=new Date((i.getTime()??0)+c*3600*1e3)}return r===void 0?"":Fa(i,e,t)},dateParserToServer:r=>t.substring(0,10)==="dd/MM/yyyy"?r.split("/")[2]+"-"+r.split("/")[1]+"-"+r.split("/")[0]:r.split("/")[2]+"-"+r.split("/")[0]+"-"+r.split("/")[1],formatDateTimeZoneFromCalendar:r=>{const n=new Date(r??0);return r===void 0?"":Fa(n,e,t)},formatDateTimeZone2:(r,n,a,s)=>{let i=new Date(r??0);if(n!==void 0&&r!==void 0&&(i=k0(O0(U0(i,n.year??0),n.month??0),n.days??0)),s!==void 0&&r!==void 0&&(i=L0(M0(j0(i,s.year??0),s.month??0),s.days??0)),a&&r){const o=Fa(i,e,t).substring(0,10);t.substring(0,10)==="dd/MM/yyyy"?i=new Date(a.year??Number(o.split("/")[2]),a.month??Number(o.split("/")[1])-1,a.days??Number(o.split("/")[0])):i=new Date(a.year??Number(o.split("/")[2]),a.month??Number(o.split("/")[0])-1,a.days??Number(o.split("/")[1]));const c=new Date(Fa(new Date().getTime(),e,"MM/dd/yyyy hh:mm:ss a")).getHours();i=new Date((i.getTime()??0)+c*3600*1e3)}return r===void 0?"":i.getTime()},dateTransform:r=>t.substring(0,10)==="dd/MM/yyyy"?r.split("-")[2]+"/"+r.split("-")[1]+"/"+r.split("-")[0]:r.split("-")[1]+"/"+r.split("-")[2]+"/"+r.split("-")[0]}},VR=e=>{const{isoCountry:t="MX",isoLanguage:r="es"}=Ot(o=>o.settings.amountPattern),n=$a(o=>o.companies.branchOffice.isoCurrency),a=(o,c="MXN",u="currency")=>{var l,d,h,p,f,g,y;if(e!=null&&e<2)throw new Error("decimals must be greater than 2");const b=c||n,m=me.getItem("tmpLocale")||`${r||"es"}-${t||"MX"}`,v=e||Pu(o),S={style:u,currency:b,currencyDisplay:"narrowSymbol",minimumFractionDigits:2,maximumFractionDigits:v},C=`${o}`.split("."),E=(l=Intl==null?void 0:Intl.NumberFormat(m,S))==null?void 0:l.formatToParts(`0.${C[1]||0}`),w=((d=E==null?void 0:E.find(x=>x.type==="currency"))==null?void 0:d.value)||"",_=((h=E==null?void 0:E.find(x=>x.type==="decimal"))==null?void 0:h.value)||".",P=((p=E==null?void 0:E.find(x=>x.type==="fraction"))==null?void 0:p.value)||"00";return`${((g=(f=Intl==null?void 0:Intl.NumberFormat(m,S))==null?void 0:f.format(`${C[0]||0}`))==null?void 0:g.split(_)[0])||"0"}${_}${P} ${((y=E[0])==null?void 0:y.type)!=="currency"?w:""}`},s=(o,c=n,u)=>{if(e!=null&&e<2)throw new Error("decimals must be greater than 2");c=c||n||"MXN";const l=`${r||"es"}-${t||"MX"}`,d=e||Pu(o),h={style:"currency",currency:c,currencyDisplay:"narrowSymbol",minimumFractionDigits:u||d,maximumFractionDigits:d},{symbol:p,isPrefix:f}=F8(l,h);return`${f?p:""}${i(o,u)} ${f?"":p}`},i=(o,c)=>{var u,l;if(e!=null&&e<2)throw new Error("decimals must be greater than 2");const d=e||Pu(o),h={minimumFractionDigits:c||d,maximumFractionDigits:d},p=`${r||"es"}-${t||"MX"}`,[f=0,g=0]=`${o}`.split("."),y=Intl.NumberFormat(p,h).formatToParts(`0.${g}`),b=((u=y.find(v=>v.type==="decimal"))==null?void 0:u.value)||".",m=((l=y.find(v=>v.type==="fraction"))==null?void 0:l.value)||"00";return`${Intl.NumberFormat(p,h).format(`${f}`).split(b)[0]||"0"}${b}${m}`};return{numericFormatter:a,formatCurrency:s,formatNumber:i,truncNumber:(o,c)=>{var u,l,d;let h=c||e;if(!o)return 0 .toFixed(h);const p=(u=String(o))==null?void 0:u.split(".");return(l=p==null?void 0:p.at(1))!=null&&l.length?`${p.at(0)}.${(d=p.at(1))==null?void 0:d.substring(0,h)}`:Number(o).toFixed(h)},country_isos:By}},Pu=e=>{var t;const r=((t=`${e}`.split(".")[1])==null?void 0:t.length)||2;return r<2?2:r},F8=(e,t)=>{var r;if(!t.currency)throw"Must provide a currency";const n=RI(t.currency)||e,a=Intl.NumberFormat(n,{...t,currencyDisplay:"narrowSymbol"}).formatToParts(0),s=Intl.NumberFormat(e,{...t,currencyDisplay:"narrowSymbol"}).formatToParts(0);return{symbol:(r=a==null?void 0:a.find(i=>i.type==="currency"))==null?void 0:r.value,isPrefix:s[0].type==="currency"}};var q8=(e=>(e.READ="general.read/settings",e.UPDATE="general.update/settings",e))(q8||{}),H8=(e=>(e.READ_DECIMALS="product.readDecimals/settings",e.PRODUCT_UPDATE="product.update/settings",e))(H8||{}),K8=(e=>(e.READ_CASH_CLOSING="cashRegister.readBalanceCashClosing/settings",e.CREATE_CASH_CLOSING="cashRegister.createCashClosing/settings",e.CASH_MOVE_EXPENSE="cashRegister.createExpenseTransaction/settings",e.CASH_MOVE_INCOME="cashRegister.createIncomeTransaction/settings",e))(K8||{}),V8=(e=>(e.OPEN="cashRegister.open/settings",e.READ="cashRegister.read/settings",e.CREATE="cashRegister.create/settings",e.UPDATE="cashRegister.update/settings",e.DELETE="cashRegister.delete/settings",e.UPDATE_PREDETERMINED="cashRegister.updatePredetermined/settings",e))(V8||{}),z8=(e=>(e.CREATE="category.create/product",e.UPDATE="category.update/product",e.DELETE="category.delete/product",e))(z8||{}),G8=(e=>(e.IMPORT="import.importProducts/product",e.EXPORT="export.exportProducts/product",e))(G8||{}),Q8=(e=>(e.READ="read/client",e.CREATE="create/client",e.UPDATE="update/client",e.DELETE="delete/client",e.RECOVER="recover/client",e.UPDATE_CREDIT_LIMIT="NOT_EARLY_ACCESS",e.UPDATE_PRICE_NUMBER="updatePriceNumber/client",e.READ_INVOICE_INFO="readInvoiceInfo/client",e.CREATE_INVOICE_INFO="createInvoiceInfo/client",e.UPDATE_INVOICE_INFO="updateInvoiceInfo/client",e.DELETE_INVOICE_INFO="deleteInvoiceInfo/client",e.UPDATE_PREDETERMINED_INVOICE_INFO="updatePredeterminedInvoiceInfo/client",e.READ_ADDRESS="readAddress/client",e.CREATE_ADDRESS="createAddress/client",e.UPDATE_ADDRESS="updateAddress/client",e.DELETE_ADDRESS="deleteAddress/client",e.UPDATE_PREDETERMINED_ADDRESS="updatePredeterminedAddress/client",e.CLIENT_DATA_TABS="NOT_EARLY_ACCESS",e))(Q8||{}),W8=(e=>(e.CREDIT_PAYMENT="creditPayment/client",e.READ="readCreditClientConfiguration/client",e.UPDATE="updateCreditClientConfiguration/client",e.CANCEL="cancelCreditPayment/client",e.READ_CREDIT_SALES="readCreditSales/client",e.READ_ALL_USER_CREDIT_SALES="readAllUserCreditSales/client",e.EXPORT_ACCOUNT_STATEMENT="exportAccountStatement/client",e))(W8||{}),Z8=(e=>(e.READ_CONFIG="readCreditSupplierConfiguration/supplier",e.READ_CREDIT_PURCHASES="readCreditPurchases/supplier",e.UPDATE_CREDIT_LIMITS="updateCreditLimits/supplier",e.CANCEL="cancelCreditPayment/supplier",e.PAY_CREDIT="creditPayment/supplier",e.READ_ALL_USER_CREDIT_PURCHASES="readAllUserCreditPurchases/supplier",e.UPDATE_CONFIG="updateCreditSupplierConfiguration/supplier",e))(Z8||{}),Y8=(e=>(e.READ="read/supplier",e.CREATE="create/supplier",e.UPDATE="update/supplier",e.DELETE="delete/supplier",e.RECOVER="recover/supplier",e.UPDATE_CREDIT_LIMIT="updateCreditLimits/supplier",e.UPDATE_PRICE_NUMBER="updatePriceNumber/supplier",e.READ_INVOICE_INFO="readInvoiceInfo/supplier",e.CREATE_INVOICE_INFO="createInvoiceInfo/supplier",e.UPDATE_INVOICE_INFO="updateInvoiceInfo/supplier",e.DELETE_INVOICE_INFO="deleteInvoiceInfo/supplier",e.UPDATE_PREDETERMINED_INVOICE_INFO="updatePredeterminedInvoiceInfo/supplier",e.READ_ADDRESS="readAddress/supplier",e.CREATE_ADDRESS="createAddress/supplier",e.UPDATE_ADDRESS="updateAddress/supplier",e.DELETE_ADDRESS="deleteAddress/supplier",e.UPDATE_PREDETERMINED_ADDRESS="updatePredeterminedAddress/supplier",e.SUPPLIER_DATA_TABS="NOT_EARLY_ACCESS",e))(Y8||{}),X8=(e=>(e.CREATE="department.create/product",e.UPDATE="department.update/product",e.DELETE="department.delete/product",e))(X8||{}),zy=(e=>(e.READ="branchOffice.readInvoiceInfo/settings",e.CREATE="branchOffice.createInvoiceInfo/settings",e.UPDATE="branchOffice.updateInvoiceInfo/settings",e))(zy||{}),J8=(e=>(e.READ_SALES="operation.readSales/settings",e.UPDATE_SALES="operation.updateSales/settings",e.READ_QUOTATION="operation.readQuotation/settings",e.UPDATE_QUOTATION="operation.updateQuotation/settings",e.READ_PURCHASE="operation.readPurchase/settings",e.UPDATE_PURCHASE="operation.updatePurchase/settings",e.READ_CREDIT_CONFIG="operation.readOperationCreditClient/settings",e.UPDATE_CREDIT_CONFIG="operation.updateOperationCreditClient/settings",e.UPDATE_ORDER="operation.updateOrder/settings",e.READ_ORDER="operation.readOrder/settings",e.READ_CFDI="operation.readOperationCfdi/settings",e.UPDATE_CFDI="operation.updateOperationCfdi/settings",e.CHANGE_CFDI_WALLET="operation.changeCfdiWallet/settings",e))(J8||{}),Ad=(e=>(e.READ="currency.read/settings",e.CREATE="currency.create/settings",e.UPDATE="currency.update/settings",e.DELETE="currency.delete/settings",e))(Ad||{}),e5=(e=>(e.READ="documentPrintConf.read/settings",e.UPDATE="documentPrintConf.update/settings",e))(e5||{}),Gy=(e=>(e.READ="paymentOption.read/settings",e.UPDATE="paymentOption.update/settings",e))(Gy||{}),t5=(e=>(e.CREATE="tax.create/product",e.UPDATE="tax.update/product",e.DELETE="tax.delete/product",e))(t5||{}),r5=(e=>(e.CREATE="unit.create/product",e.UPDATE="unit.update/product",e.DELETE="unit.delete/product",e))(r5||{}),n5=(e=>(e.READ="product.read/product",e.CREATE="product.create/product",e.UPDATE="product.update/product",e.DELETE="product.delete/product",e.CLONE="product.clone/product",e.ADD_STOCK="product.addstock/product",e.DELETED_DESTROY_ALL="product.destroyAllProductDeleted/product",e.DELETED_PRODUCT="product.destroyProductDeleted/product",e.DELETED_READ="product.readProductDeleted/product",e.UPDATE_SATKEY="product.updateSatKeys/product",e))(n5||{}),Qy=(e=>(e.READ="warehouse.read/settings",e.CREATE="warehouse.create/settings",e.UPDATE="warehouse.update/settings",e.DELETE="warehouse.delete/settings",e.UPDATE_PREDETERMINED="warehouse.updatePredetermined/settings",e))(Qy||{}),a5=(e=>(e.READ="stock.read/product",e.CREATE="stock.create/product",e.UPDATE="stock.update/product",e.DELETE="stock.delete/product",e.READ_HISTORY="stock.readHistory/product",e.RESET="stock.reset/product",e.LOCALIZATION_READ="localization.stock.read/product",e.LOCALIZATION_CREATE="localization.create/product",e.LOCALIZATION_UPDATE="localization.update/product",e.LOCALIZATION_DELETE="localization.delete/product",e))(a5||{}),s5=(e=>(e.SEND_BALANCING_BY_EMAIL="cashregBalancing.sendBalancingByEmail/queries",e.PRINT_BALANCING="cashregBalancing.printBalancing/queries",e.SHARE_BALANCING="cashregBalancing.shareBalancing/queries",e.SEND_BALANCING_BY_WHATS="cashregBalancing.sendBalancingByWhats/queries",e.READ_BALANCING="cashregBalancing.readBalancing/queries",e))(s5||{}),i5=(e=>(e.READ_BALANCE="cashRegister.readBalance/queries",e))(i5||{}),o5=(e=>(e.CANCEL_SALES="sales.cancelSales/queries",e.EDIT_SALE_COMMENT="sales.editSaleComment/queries",e.EDIT_SALE_SELLER="sales.editSaleSeller/queries",e.PRINT_SALES="sales.printSales/queries",e.READ_ALL_USER_SALES="sales.readAllUserSales/queries",e.SEND_SALES_BY_EMAIL="sales.sendSalesByEmail/queries",e.SEND_SALES_BY_WHATS="sales.sendSalesByWhats/queries",e.SHARE_SALES="sales.shareSales/queries",e.READ_SALES="sales.readSales/queries",e))(o5||{}),c5=(e=>(e.READ_CFDIS="cfdi.readCfdis/queries",e.READ_ALL_USER_CFDIS="cfdi.readAllUserCfdis/queries",e.CANCEL_CFDIS="cfdi.cancelCfdis/queries",e))(c5||{}),u5=(e=>(e.CREATE_GLOBAL_CFDI="createGlobal/cfdi",e.CREATE_CFDI="createCfdi/cfdi",e.CHANGE_SERIE_CFDI="changeCfdiSerie/cfdi",e))(u5||{}),l5=(e=>(e.CANCEL_PURCHASES="purchases.cancelPurchases/queries",e.READ_ALL_USER_PURCHASES="purchases.readAllUserPurchases/queries",e.READ_PURCHASES="purchases.readPurchases/queries",e))(l5||{}),d5=(e=>(e.GENERAL_SALES_EXPORT="generalSales.export/reports",e.READ_GENERALS_SALES="generalSales.readGeneralSales/reports",e.READ_ALL_USER_SALES_GENERALS_SALES="generalSales.readAllUserSales/reports",e.READ_GENERALS_SALES_PROFIT="generalSales.readGeneralSalesProfit/reports",e.PROFIT_READ_ALL_BRANCH_OFFICES="profitSales.readBranchesProfitSales/reports",e.GENERALS_SALES_SEND_BY_EMAIL="generalSales.sendGeneralSalesByEmail/reports",e.READ_ALL_BRANCH_OFFICES="generalSales.readBranchesSales/reports",e.READ_ALL_USER_CFDI="cfdi.readAllUserCfdi/reports",e.READ_GENERAL_CFDI="cfdi.readGeneralCfdi/reports",e.READ_ALL_USER_SALESBYPRODUCT="salesByProduct.readAllUserSalesByProduct/reports",e.READ_GENERAL_SALESBYPRODUCT="salesByProduct.readSalesByProduct/reports",e.READ_ALL_BRANCHES_ORDERS="orders.readBranchesOrders/reports",e.READ_ALL_USERS_ORDERS="orders.readAllUserOrders/reports",e.READ_ORDERS="orders.readOrders/reports",e.EXPORT_ORDERS="orders.export/reports",e.TRANSACTIONS_EXPORT="transactions.export/reports",e.READ_TRANSACTIONS="transactions.readTransactions/reports",e.TRANSACTIONS_READ_BRANCHES="transactions.readBranchesTransactions/reports",e.GENERAL_PURCHASES_EXPORT="generalPurchases.export/reports",e.GENERAL_PURCHASES_READ_ALL_USERS_PURCHASES="generalPurchases.readAllUserPurchases/reports",e.GENERAL_PURCHASES_READ_BRANCHES_PURCHASES="generalPurchases.readBranchesPurchases/reports",e.GENERAL_PURCHASES_READ_GENERAL_PURCHASES="generalPurchases.readGeneralPurchases/reports",e.GENERAL_PURCHASES_SEND_GENERAL_PURCHASES_BY_EMAIL="generalPurchases.sendGeneralPurchasesByEmail/reports",e.PROFIT_EXPORTS="profitSales.export/reports",e.PROFIT_READ_SALES="profitSales.readProfitSales/reports",e.PROFIT_READ_ALL_USERS="profitSales.readAllUserProfitSales/reports",e.DEP_CAT_EXPORTS="salesByDepartmentAndCategories.export/reports",e.DEP_CAT_READ_SALES="salesByDepartmentAndCategories.readSalesByDepartmentAndCategories/reports",e.DEP_CAT_READ_ALL_USERS="salesByDepartmentAndCategories.readAllUserSalesByDepartmentAndCategories/reports",e.SALE_BY_USER_EXPORT="salesByUser.export/reports",e.READSALE_BY_USER="salesByUser.readSalesByUser/reports",e.SALE_BY_SELLER_EXPORT="salesBySeller.export/reports",e.READSALE_BY_SELLER="salesBySeller.readSalesBySeller/reports",e.ORDERS_BY_USER_EXPORT="ordersByUser.export/reports",e.READ_ORDERS_BY_USER="ordersByUser.readOrdersByUser/reports",e.PRODUCT_COFEPRIS_EXPORT="products.exportCofepris/reports",e))(d5||{}),h5=(e=>(e.READ="read/user",e.CREATE="create/user",e.UPDATE="edit/user",e.DELETE="delete/user",e.ASSIGN_ROLE="assignRole/user",e))(h5||{}),p5=(e=>(e.READ="read/userType",e.CREATE="create/userType",e.UPDATE="edit/userType",e.DELETE="delete/userType",e))(p5||{}),f5=(e=>(e.CREATE_SPACE="space.createSpace/orders",e.UPDATE_SPACE="space.updateSpace/orders",e.DELETE_SPACE="space.deleteSpace/orders",e.CHANGE_SPACE_STATUS="space.changeSpaceStatus/orders",e.MANAGE_ZONES="space.manageZones/orders",e.CREATE_TEMP_SPACE="space.createTempSpace/orders",e.CHANGE_DATE="order.changeDate/orders",e.PAY_BILL="order.payBill/orders",e.REOPEN_BILL="order.reopenBill/orders",e.CLOSE_BILL="order.closeBill/orders",e.CANCEL_ORDERS="order.cancelOrders/orders",e.TRANSFER_ORDERS="order.transferOrders/orders",e.SET_UNLIMITED_DISCOUNTS="order.setUnlimitedDiscounts/orders",e.CHANGE_CUSTOMER="order.changeCustomer/orders",e.CHANGE_PRODUCT_DESCRIPTION="order.changeProductDescription/orders",e.REMOVE_PRODUCTS="order.removeProducts/orders",e.REPRINT_ORDER="order.reprintOrder/orders",e.SET_DISCOUNTS="order.setDiscounts/orders",e.CHANGE_CURRENCY="order.changeCurrency/orders",e.CREATE_ORDER="order.createOrder/orders",e.DECREASE_PRODUCT_QUANTITY="order.decreaseProductQuantity/orders",e.CREATE_QUICK_PRODUCT="order.createQuickProduct/orders",e.CREATE_BILL_ON_CREDIT="order.createBillOnCredit/orders",e.CHANGE_EXCHANGE_RATE="order.changeExchangeRate/orders",e.CREATE_QUICK_SALE="order.createQuickSale/orders",e.CHANGE_SELLER="order.changeSeller/orders",e.CHANGE_SERIE="order.changeSerie/orders",e))(f5||{}),to=(e=>(e.CHANGE_CURRENCY="changeCurrency/sales",e.CHANGE_CUSTOMER="changeCustomer/sales",e.CHANGE_DATE="changeDate/sales",e.CHANGE_DEVICE_SALES_SETTINGS="changeDeviceSalesSettings/sales",e.CHANGE_DIVICE_SERIE="changeDeviceSerie/sales",e.CHANGE_EXCHANGE_RATE="changeExchangeRate/sales",e.CHANGE_PRICE_NUMBER="changePriceNumber/sales",e.CHANGE_PRODUCT_DESCRIPTION="changeProductDescription/sales",e.CHANGE_PRODUCT_TAXES="changeProductTaxes/sales",e.CHANGE_SELLER="changeSeller/sales",e.CHANGE_SERIE="changeSaleSerie/sales",e.CREATE_QUICK_PRODUCT="createQuickProduct/sales",e.CREATE_SALE="createSale/sales",e.DECREASE_PRODUCT_QUANTITY="decreaseProductQuantity/sales",e.PRINT_LAST_SALE="printLastSale/sales",e.PUT_SALE_ON_HOLD="putSaleOnHold/sales",e.REMOVE_PRODUCTS="removeProducts/sales",e.SALE_WITHOUT_PROFIT="saleWithoutProfit/sales",e.SET_DISCOUNTS="setDiscounts/sales",e.SET_UNLIMITED_DISCOUNTS="setUnlimitedDiscounts/sales",e.LOAD_QUOTATIONS="loadQuotations/sales",e.LOAD_ALL_USER_QUOTATIONS="loadAllUserQuotations/sales",e.CREATE_SALE_ON_CREDIT="createSaleOnCredit/sales",e))(to||{}),g5=(e=>(e.CHANGE_CURRENCY="changeCurrency/quotations",e.CHANGE_CUSTOMER="changeCustomer/quotations",e.CHANGE_DATE="changeDate/quotations",e.CHANGE_DIVICE_SERIE="changeDeviceSerie/quotations",e.CHANGE_EXCHANGE_RATE="changeExchangeRate/quotations",e.CHANGE_PRICE_NUMBER="changePriceNumber/quotations",e.CHANGE_PRODUCT_DESCRIPTION="changeProductDescription/quotations",e.CHANGE_SELLER="changeSeller/quotations",e.CHANGE_SERIE="changeQuotationSerie/quotations",e.CREATE_QUICK_PRODUCT="createQuickProduct/quotations",e.CREATE_QUOTATION="createQuotation/quotations",e.DECREASE_PRODUCT_QUANTITY="decreaseProductQuantity/quotations",e.REMOVE_PRODUCTS="removeProducts/quotations",e.SET_DISCOUNTS="setDiscounts/quotations",e.SET_UNLIMITED_DISCOUNTS="setUnlimitedDiscounts/quotations",e.SHOW_PROFIT="showProfit/quotations",e.READ_ALL_USER_QUOTATIONS="readAllUserQuotations/quotations",e.READ_QUOTATIONS="readQuotations/quotations",e.CANCEL_QUOTATIONS="cancelQuotations/quotations",e.CHANGE_EXPIRATION_DATE="changeExpirationDate/quotations",e))(g5||{}),m5=(e=>(e.CHANGE_CHECK_STATUS="changeCheckStatus/purchases",e.CHANGE_CURRENCY="changeCurrency/purchases",e.CHANGE_DATE="changeDate/purchases",e.CHANGE_SERIE="changePurchaseSerie/purchases",e.CREATE_QUICK_PRODUCT="createQuickProduct/purchases",e.CREATE_PURCHASE="createPurchase/purchases",e.PUT_PURCHASE_ON_HOLD="putPurchaseOnHold/purchases",e.CHANGE_WAREHOUSE="changeWarehouse/purchases",e.DOWNLOAD_CFDI="downloadCfdi/purchases",e.IMPORT_CFDI="importCfdi/purchases",e))(m5||{}),y5=(e=>(e.READ_GENERALL_STATISTICS="readGeneralStatistics/statistics",e))(y5||{}),Wy=(e=>(e.PRICE_LIST_READ="priceList.read/product",e.PRICE_LIST_CREATE="priceList.create/product",e.PRICE_LIST_UPDATE="priceList.update/product",e.PRICE_LIST_DELETE="priceList.delete/product",e.PRICE_LIST_SELECT="priceList.selectPriceList/product",e.PRICE_LIST_UPDATE_RECALCULATE_MODE="priceList.updateRecalculateMode/product",e.PRICES_READ="prices.read/product",e.PRICES_CREATE="prices.create/product",e.PRICES_UPDATE="prices.update/product",e.PRICES_DELETE="prices.delete/product",e.PRICES_READ_HISTORY="prices.readHistory/product",e))(Wy||{}),v5=(e=>(e.READ="read/role",e.CREATE="create/role",e.UPDATE="edit/role",e.DELETE="delete/role",e))(v5||{}),b5=(e=>(e.APPLY="movement.apply/product",e.READ="movement.read/product",e.CREATE="movement.create/product",e.DELETE="movement.delete/product",e.UPDATE="movement.update/product",e))(b5||{}),C5=(e=>(e.READ="printProfile.read/settings",e.CREATE="printProfile.create/settings",e.UPDATE="printProfile.edit/settings",e.DELETE="printProfile.delete/settings",e))(C5||{}),S5=(e=>(e.UPDATE="hardware.update/settings",e.PRINT_SERVER="hardware.configurePrintServer/settings",e))(S5||{}),E5=(e=>(e.READ="branchOffice.read/settings",e.UPDATE="branchOffice.edit/settings",e))(E5||{}),x5=(e=>(e.READ="read/mail",e.CREATE="create/mail",e.UPDATE="edit/mail",e.DELETE="delete/mail",e))(x5||{}),w5=(e=>(e.TRANSFER_READ="transfer.read/transfers",e.TRANSFER_CREATE="transfer.create/transfers",e.TRANSFER_CANCEL="transfer.cancel/transfers",e.TRANSFER_ACCEPT="transfer.accept/transfers",e.WITHOUT_STOCK_CONFIG="transfer.transferWithoutStockConfig/transfers",e.REQUEST_READ="request.read/transfers",e.REQUEST_CREATE="request.create/transfers",e.REQUEST_CANCEL="request.cancel/transfers",e))(w5||{}),T5=(e=>(e.READ="ecommerceConfig.read/settings",e.CREATE="ecommerceConfig.create/settings",e.CONFIGURE="ecommerceConfig.configure/settings",e.UNLINK="ecommerceConfig.unlink/settings",e.UPDATE="ecommerceConfig.update/settings",e))(T5||{}),$5=(e=>(e.CHANGE_EXTRA_CHARGE="changeExtraCharge/rps",e.CREATE_CREDENTIALS="createCredentials/rps",e.CREATE_TRANSACTION="createTransaction/rps",e.READ_CATALOGUE="readCatalogue/rps",e.READ_DASHBOARD="readDashboard/rps",e.READ_LOGS="readLogs/rps",e.READ_PAYMENTS="readPayments/rps",e.READ_TRANSACTION="readTransaction/rps",e.REPORT_PAYMENTS="reportPayments/rps",e.UPDATE_ANTI_THEFT="updateAntiTheft/rps",e))($5||{}),A5=(e=>(e.READ="lot.read/product",e.CREATE="lot.create/product",e.UPDATE="lot.update/product",e.DELETE="lot.delete/product",e))(A5||{}),I5=(e=>(e.CONFIGURE="login.configureLogin/settings",e.REMOVE="login.remove/settings",e))(I5||{}),P5=(e=>(e.CREATE="tag.create/product",e.UPDATE="tag.update/product",e.DELETE="tag.delete/product",e))(P5||{});const _5=()=>{const{checkHasPermission:e}=I0(),t=an(s=>s.getLocal),r=Gn.useCallback(s=>new _o().updateContent(s??e(Wy.PRICE_LIST_READ,"every",{checkDependencies:!0}),s??e(Qy.READ,"every",{checkDependencies:!0})),[e]),n=Gn.useCallback(async()=>{const s=await Pr.priceLists.toArray();if(!(s!=null&&s.length))return d4({uuid:"5df9f7e4-746b-4882-8f4b-099c5702a866",name:"Price List",predetermined:!0}).then(({status:i,data:o})=>{if(i===201)try{_o.update(Pr.priceLists,[o])}catch{}})},[]),a=Gn.useCallback(()=>{var s;const i=(s=t())==null?void 0:s.warehouse,o=Ht.getState().stock.warehouseList;return i?o.some(c=>c.uuid===(i==null?void 0:i.uuid)):!0},[]);return{updateProductContent:r,createPriceList:n,existWarehousePredetermined:a}},zR=(e,t)=>{const r=s=>{new Proxy(s,{get(i,o){if(o==="then")return i.then.bind(i)}})},n=async(s,i,o)=>{const c=i;let u=o;if(c===void 0)throw new Error("ms required");if(u===void 0)throw new Error("retryNumber required");const l=()=>{u=0};let d=!1;for(;u>0;)u-=1,d=u===0,await a(c),await s.call(void 0,{done:l,isFinished:d})},a=s=>new Promise(i=>setTimeout(i,s));return{setRetry:r,setRetryControlled:n,delay:a}};let D5=class Zy{constructor(t){this.queryBuilder=t}static config(){return new Zy(new pe)}withAmmountPattern(t){return this.queryBuilder.insertQuery(`
            amountPattern {
                isoCountry
                isoLanguage
            }
        `,t),this}withDateTimePattern(t){return this.queryBuilder.insertQuery(`
            datetimePattern {
                timePattern
                datePattern
            }
        `,t),this}withProductConfiguration(t=!0){return this.queryBuilder.insertQuery(`
            productConfiguration {
                priceDecimals
                profitByMargin
            }
        `,t),this}withTransferConfiguration(t=!0){return this.queryBuilder.insertQuery(`
            transferConfiguration {
                allowNoStock
            }
        `,t),this}setState(t){const r=Ot.getState().settings;t!=null&&t.amountPattern&&(r.amountPattern=t.amountPattern),t!=null&&t.datetimePattern&&(r.dateTimePattern=t.datetimePattern),t!=null&&t.productConfiguration&&(r.productConfiguration=t.productConfiguration),t!=null&&t.transferConfiguration&&(r.transferConfiguration=t.transferConfiguration),Ot.setState({settings:r})}async build(){const t=this.queryBuilder.build();return pn(It,t).then(pe.unwrap).then(r=>(this.setState(r.data),r))}};const R5=()=>{const e=Ot(h=>h.settings.invoiceInfo),t=Bl(h=>h.selfBilling),r=Ot(h=>h.loadInvoiceInfo),n=Bl(h=>h.initSelfBilling),a=async()=>{const h=await i(),p=l(h);return await n(p)},s=async()=>{const h=o(),p=l(h);return c(p,!0)??await u(p,!0)??!1},i=async()=>{const h=await r();return h&&h.certificate?h.certificate.expirationDate:null},o=()=>{const h=e;return h&&h.certificate?h.certificate.expirationDate:null},c=(h,p=!1)=>{const f=t;return f?p?f.active:f.active&&h==ha.ACTIVE:null},u=async(h,p=!1)=>{const f=await n(h);return f?p?f.selfBilling.active:f.selfBilling.active&&h==ha.ACTIVE:null},l=h=>{let p=ha.UNCONFIGURED;if(h)if(typeof h!="string")p=d(h.valueOf());else{const f=Date.parse(h);p=d(f)}return p},d=h=>{const p=Date.now();return h<p?ha.EXPIRED:ha.ACTIVE};return{printSelfBilling:s,loadSelfBilling:a}},GR=()=>{let e=0;const{getLoggedUser:t}=Ry(L=>L),{checkHasPermission:r}=I0(),n=ky(L=>L.drawerOpen),a=Oy(L=>L.showLoader),{updateProductContent:s}=_5(),i=Ot(L=>L.setInvoiceInfo),{loadSelfBilling:o}=R5(),c=$a(L=>L.companies.branchOffice),u=Ot(L=>L.settings.amountPattern),l=Ot(L=>L.settings.logoTicket),d=Ot(L=>L.settings.currencies.list),h=Ca(L=>L.authCompany.isSupport),p=Ot(L=>L.settings.dateTimePattern),f=Ot(L=>L.settings.printProfileList),g=Ot(L=>{var X;return(X=L==null?void 0:L.settings)==null?void 0:X.configurationSales}),y=an(L=>L.printerSettings),b=an(L=>L.printerSettingsBranch),m=Ot(L=>L.getConfigurationSales),v=Ot(L=>L.getLogoTicket),S=Ot(L=>L.setCurrencies),C=an(L=>L.setLabelOptions),E=an(L=>L.editPrinterBranch),w=Ot(L=>L.setPaymentOptions),_=Ot(L=>L.getPaymentOptions),P=Ca(L=>L.setInitConfigComplete),x=Ot(L=>L.getConfigurationSales),R=Ot(L=>L.setPrintProfileList),B=$a(L=>L.getBranchListByCompany),K=an(L=>L.setPrinterSettingsBranch),re=Ot(L=>L.getPrintProfileList),ee=Ot(L=>L.getCompanyCurrencies),ie=Gn.useRef(l),se=async()=>v().then(L=>{ie.current=L}).catch(L=>{console.log("GET_LOGO ERROR"),console.log(L)});async function Ce(){return a$().then(L=>[{...L.data}]).catch(L=>(console.log("Error al generar perfil DEFAULT: ",L),"err"))}const Ie=(L,X)=>new Promise(async ne=>{try{await se()}catch{}finally{const U=X[X.findIndex(be=>be.system===!0)];if(L.length!==0){const be=L,xe=be.findIndex(_e=>_e.branchId===c.id),Ne=be[xe],he=Ne?Ne.printers:void 0;if(Ne!==void 0){const _e=[];for(let I=0;I<y.length;I++)he.findIndex(D=>D.printerName===y[I].printerName)===-1&&_e.push(y[I]);if(_e.length!==0){const I=he;for(let N=0;N<_e.length;N++)I.push({printerName:_e[N].printerName,printerProfile:U});const D={branchId:c.id,printers:I};be.splice(xe,1,D),E(be[xe])}}else if(y.length!==0){const _e=Object.assign(JSON.parse(JSON.stringify(be[0].printers)));for(let I=0;I<be[0].printers.length;I++)_e[I].printerProfile=U;K({branchId:c.id,printers:_e})}else K({branchId:c.id,printers:[]});if(Ne!==void 0&&U!==void 0){for(let _e=0;_e<he.length;_e++){const I=X.findIndex(D=>D.uuid===he[_e].printerProfile.uuid);I===-1?he[_e].printerProfile=U:X[I]!==he[_e].printerProfile&&(he[_e].printerProfile=X[I])}E(Ne)}}ne(!0)}}),ye=()=>new Promise(L=>{try{re().then(async X=>{if(X.status===200)R(X.data),await Ie(b,X.data);else if(X.status===204){const ne=await Ce();ne!=="err"?await Ie(b,ne):e<3?(e++,ye()):console.log("branchPrintProfile ERROR")}else X.status===304&&await Ie(b,f)}).catch(X=>{console.log("branchPrintProfile ERROR"),console.log(X.response.data.message)})}catch(X){console.log("branchPrintProfile ERROR"),console.log(X)}finally{L(!0)}});return{run:()=>new Promise(async L=>{var X,ne,U,be,xe,Ne,he;try{const _e=me.getItem("auth-company-storage"),I=me.getItem("auth-account-storage"),{state:D}=_e===null?!1:JSON.parse(_e),{state:N}=I===null?!1:JSON.parse(I);if(!((X=D==null?void 0:D.authCompany)!=null&&X.logged)||!((ne=N==null?void 0:N.authAccount)!=null&&ne.logged))return;const q=(U=D==null?void 0:D.authCompany)==null?void 0:U.xStatus,k=(be=D==null?void 0:D.authCompany)==null?void 0:be.xNoAfter,V=(xe=D==null?void 0:D.authCompany)==null?void 0:xe.isOwner,W=(Ne=D==null?void 0:D.authCompany)==null?void 0:Ne.isAdmin,j=(he=N==null?void 0:N.authAccount)==null?void 0:he.status;console.log("----------------- START INIT CONFIG -----------------"),console.log(),console.log(`xStatus: ${q}`),console.log(`xNoAfter: ${k}`),console.log(`accountStatus: ${j}`),console.log(`isOwner: ${V}`),console.log(`isAdmin: ${W}`);const z=A0(k.replaceAll("-","/"));if((q==="0"||q==="2")&&z>=0||q==="6"||h){if(d.length===0&&(r(Ad.READ,"every",{checkDependencies:!0})||r(to.CREATE_SALE))){const Z=await ee();Z.status===200&&S(Z.data)}if(r(Gy.READ,"every",{checkDependencies:!0})||r(to.CREATE_SALE)){const Z=await _();Z.status===200&&w(Z.data)}g||r(to.CREATE_SALE)&&x(),await D5.config().withAmmountPattern(u.isoCountry===""&&u.isoLanguage===""&&r(Ad.READ)).withDateTimePattern(p.datePattern==="").withTransferConfiguration().withProductConfiguration().build(),await t(),C(),await ye(),await s(!0),await B(),o(),r(zy.READ)?await Pl().then(Z=>{if(Z.status===200){const M=Z.data;let te={rfc:(M==null?void 0:M.rfc)??"",idCif:(M==null?void 0:M.idCif)??"",businessName:M==null?void 0:M.businessName,city:(M==null?void 0:M.city)??"",claveSatRegimen:M==null?void 0:M.claveSatRegimen,country:(M==null?void 0:M.country)??"",descripcionRegimen:M==null?void 0:M.descripcionRegimen,district:(M==null?void 0:M.district)??"",extNumber:(M==null?void 0:M.extNumber)??"",intNumber:(M==null?void 0:M.intNumber)??"",state:(M==null?void 0:M.state)??"",zipCode:M==null?void 0:M.zipCode,contentId:M==null?void 0:M.contentId,county:(M==null?void 0:M.county)??"",imssNumber:(M==null?void 0:M.imssNumber)??"",street:(M==null?void 0:M.street)??""};M!=null&&M.certificate?te={...te,certificate:{id:M==null?void 0:M.certificate.id,cerName:M==null?void 0:M.certificate.cerName,keyName:M==null?void 0:M.certificate.keyName,requestDate:M==null?void 0:M.certificate.requestDate,expirationDate:M==null?void 0:M.certificate.expirationDate}}:te={...te,certificate:null},i(te)}}):await UT().then(Z=>{var M;let te={rfc:"",idCif:"",businessName:"",city:"",claveSatRegimen:"",country:"",descripcionRegimen:"",district:"",extNumber:"",intNumber:"",state:"",zipCode:"",contentId:-1,county:"",imssNumber:"",street:""};te={...te,certificate:{id:"",cerName:"",keyName:"",requestDate:"",expirationDate:(M=Z==null?void 0:Z.certificate)==null?void 0:M.expirationDate}},i(te)})}await m("cfdi"),n(!0),console.log(),console.log("----------------- FINISH INIT CONFIG -----------------")}catch{a(!1),console.log(),console.log("SOME REQUESTS FAILED OR NOT FOUND 404"),console.log(),console.log("----------------- FINISH INIT CONFIG -----------------")}finally{a(!1),L(!0),P(!0)}})}},QR=()=>{const e=(n,{chunckSize:a=100,field:s,onResponse:i}={})=>async(...o)=>{const c=t(o,s);if(!c)throw Error("argument not found");const u=r(c,a),l=[],d=[];let h={};try{for await(const p of u){const f=await n(p);i&&i(f);const{data:g,...y}=f;"errors"in y&&y!=null&&y.errors&&d.push(...y.errors),h=y,l.push(...Array.isArray(g)?g:[])}return Promise.resolve({...h,data:l,status:l!=null&&l.length?200:204,...(d==null?void 0:d.length)&&{errors:d}})}catch(p){return Promise.reject(p)}},t=(n,a)=>{var s;if(a==null){const i=n==null?void 0:n.reduce((o,c)=>[...o,...c instanceof Object&&c.constructor===Object?Object.values(c):[c]],[]);return i==null?void 0:i.find(o=>Array.isArray(o))}return typeof a=="number"?n==null?void 0:n[a]:(s=n==null?void 0:n.find(i=>i instanceof Object&&i.constructor===Object&&a in i))==null?void 0:s[a]},r=(n,a)=>{const s=[];for(let i=0;i<n.length;i+=a)s.push(n.slice(i,i+a));return s};return{chuncked:r,chunckedRequest:e}},N5=e=>["SX","RPSCOM","RPS","ARTRAP","ARTNCR","ARTNCRO","AJXPUB","AJXRED","ARTCOMRPS","AJXPER"].some(t=>e.startsWith(t))?"":e;var B5=Object.defineProperty,k5=(e,t,r)=>t in e?B5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nt=(e,t,r)=>k5(e,typeof t!="symbol"?t+"":t,r);let R0=class{constructor(){nt(this,"model",""),nt(this,"opMode","MX"),nt(this,"id",""),nt(this,"uuid",""),nt(this,"fid",""),nt(this,"serie",null),nt(this,"folio",""),nt(this,"decimals",2),nt(this,"documentType",0),nt(this,"documentDate",null),nt(this,"documentDateString",null),nt(this,"createDate",null),nt(this,"createDateString",null),nt(this,"timeZone",""),nt(this,"mainIsoCurrency",""),nt(this,"totalQuantity","0"),nt(this,"totalBase","0"),nt(this,"totalBaseTax","0"),nt(this,"total","0"),nt(this,"totalTax","0"),nt(this,"totalDiscountPercentage","0"),nt(this,"totalDiscount","0"),nt(this,"totalDiscountTax","0"),nt(this,"totalWithoutTax","0"),nt(this,"totalWithoutTaxConv","0"),nt(this,"totalCost","0"),nt(this,"totalNetCost","0"),nt(this,"totalUtility","0"),nt(this,"totalDiff","0"),nt(this,"profitByMargin",!0),nt(this,"status"),nt(this,"sourceModule"),nt(this,"action"),nt(this,"userUuid"),nt(this,"userAlias")}};var O5=Object.defineProperty,U5=(e,t,r)=>t in e?O5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,at=(e,t,r)=>U5(e,typeof t!="symbol"?t+"":t,r);let ZR=class extends R0{constructor(t,r,n,a,s,i,o,c){var u;super(),at(this,"model","sales"),at(this,"documentType",1),at(this,"wait",!0),at(this,"searchQuotation",!0),at(this,"multiServices",!0),at(this,"cashMove",!0),at(this,"details",[]),at(this,"comment",""),at(this,"seller",null),at(this,"checkPrice",!0),at(this,"cashCut",!0),at(this,"editDate","menu"),at(this,"printLast",!0),at(this,"configuration",!0),at(this,"cashRegisterUuid",""),at(this,"isoCurrency",""),at(this,"exchangeRate",1),at(this,"paymentsOptions",[]),at(this,"table"),at(this,"change",{amount:0,isoCurrency:"",exchangeRate:1}),at(this,"agent",{uuid:"-1",key:"",name:"PUBLICO EN GENERAL",priceNumber:1,withholdTaxes:!1,emails:[]}),at(this,"relatedDocs",null),at(this,"quotationFolio",null),at(this,"creditDueDate",null),at(this,"creditBalance",null),at(this,"creditCounter",null),at(this,"warehouseId",null),at(this,"idFormat",null),at(this,"rpsResponse"),at(this,"prescription"),at(this,"init",async l=>{this.id=l.id,this.uuid=l.uuid,this.change=l.change,this.comment=l.comment,this.details=l.details,this.documentType=l.documentType,this.editDate=l.editDate,this.documentDate=l.documentDate,this.timeZone=l.timeZone,this.mainIsoCurrency=l.mainIsoCurrency,this.isoCurrency=l.isoCurrency,this.exchangeRate=l.exchangeRate,this.paymentsOptions=[],this.serie=l.serie,this.decimals=l.decimals<2||!l.decimals?2:l.decimals,this.totalDiscountPercentage=l.totalDiscountPercentage,this.totalBaseTax=l.totalBaseTax,this.totalTax=l.totalTax,this.totalDiscount=l.totalDiscount,this.totalDiscountTax=l.totalDiscountTax,this.totalWithoutTax=l.totalWithoutTax,this.totalQuantity=l.totalQuantity,this.cashRegisterUuid=l.cashRegisterUuid,this.agent=l.agent,this.seller=l.seller,this.relatedDocs=l.relatedDocs,this.quotationFolio=l.quotationFolio,this.creditDueDate=l.creditDueDate,this.warehouseId=l.warehouseId,this.table=l.table,this.prescription=l.prescription}),at(this,"setEntity",l=>{var d;this.uuid=l.uuid,this.decimals=l.decimals<2||!l.decimals?2:l.decimals,this.serie=l.serie,this.mainIsoCurrency=l.mainIsoCurrency,this.isoCurrency=l.isoCurrency,this.exchangeRate=l.exchangeRate??1,this.folio="",this.documentDate=null,this.comment=(l==null?void 0:l.comment)??"",this.timeZone=l.timeZone,this.relatedDocs=l!=null&&l.relatedDocs?l.relatedDocs:null,this.quotationFolio=l!=null&&l.folio?l.folio:null,this.creditDueDate=l.creditDueDate,this.warehouseId=l.warehouseId,this.table=l.table,this.prescription=l.prescription,(d=l==null?void 0:l.agent)!=null&&d.uuid?this.agent=l==null?void 0:l.agent:this.agent={uuid:"-1",key:"",name:"PUBLICO EN GENERAL",priceNumber:1,withholdTaxes:!1,emails:[]},this.seller=l!=null&&l.employee?l==null?void 0:l.employee:null,this.details=[]}),at(this,"setEntityOrder",l=>{var d;this.model="order",this.documentType=-1,this.id=l.id,this.uuid=l.uuid,this.decimals=l.decimals<2||!l.decimals?2:l.decimals,this.mainIsoCurrency=l.mainIsoCurrency,this.isoCurrency=l.isoCurrency,this.exchangeRate=l.exchangeRate??1,this.folio=l.folio,this.createDate=l==null?void 0:l.createDate,this.documentDate=l==null?void 0:l.documentDate,this.comment=(l==null?void 0:l.comment)||"",this.timeZone=l.timeZone,this.relatedDocs=l!=null&&l.relatedDocs?l.relatedDocs:null,this.creditDueDate=l.creditDueDate,this.warehouseId=l.warehouseId,this.table=l.table,this.totalWithoutTax=l.withholdingTax||0,this.status=l.status,this.userUuid=(l==null?void 0:l.userUuid)||void 0,this.userAlias=(l==null?void 0:l.userAlias)||void 0,(d=l==null?void 0:l.agent)!=null&&d.uuid?this.agent=l==null?void 0:l.agent:this.agent={uuid:"-1",key:"",name:"PUBLICO EN GENERAL",priceNumber:1,withholdTaxes:!1,emails:[]},this.seller=l!=null&&l.employee?l==null?void 0:l.employee:null,this.details=[]}),at(this,"getOrderPay",()=>{var l;let d=["CASH","DEBIT_CARD","CREDIT_CARD","ELECTRONIC_TRANSFER","CHECK","GROCERY_VOUCHER"],h={id:this.id||"",total:Number(this.totalTax)};if(this.creditDueDate?h={...h,creditDueDate:this.creditDueDate}:h={...h,cashRegisterUuid:this.cashRegisterUuid,payments:[]},this.paymentsOptions.length>0&&!this.creditDueDate){let p=[];this.paymentsOptions.filter(f=>f.amount>0).map(f=>{let g={paymentId:d[Number(f.paymentOptionId)-1],amount:f.amount};f!=null&&f.comment&&(g={...g,comment:f.comment}),f!=null&&f.isoCurrency&&this.mainIsoCurrency!==f.isoCurrency&&(g={...g,isoCurrency:f.isoCurrency,exchangeRate:f.exchangeRate,convertedAmount:f.convertedAmount}),p.push(g)}),h={...h,payments:p}}if(Number((l=this.change)==null?void 0:l.amount)!=0&&!this.creditDueDate){let p={amount:this.change.amount};this.change.isoCurrency!==this.mainIsoCurrency&&(p={...p,isoCurrency:this.change.isoCurrency,exchangeRate:this.change.exchangeRate,convertedAmount:this.change.convertedAmount}),h={...h,change:p}}return h!=null&&h.payments&&h.payments.length===0?Object.fromEntries(Object.entries(h).filter(p=>p[0]!=="cashRegisterUuid"&&p[0]!=="payments")):h}),at(this,"getSale",()=>{var l,d,h,p,f,g,y,b;let m=["CASH","DEBIT_CARD","CREDIT_CARD","ELECTRONIC_TRANSFER","CHECK","GROCERY_VOUCHER"],v={uuid:this.uuid,type:"SALE",decimals:this.decimals,isoCurrency:this.isoCurrency,opMode:"MX",total:Number(this.totalTax),serie:this.serie,timeZone:this.timeZone,products:[]};if(this.prescription&&(console.log("this.prescription",this.prescription),v={...v,prescription:this.prescription}),this.sourceModule&&(v={...v,sourceModule:this.sourceModule}),this.table&&(v={...v,table:this.table}),this.totalWithoutTax&&Number(this.totalWithoutTax)>0&&(v={...v,withholdingTax:Number(this.totalWithoutTax),withholdingTaxMc:Number(this.totalWithoutTaxConv)>0?Number(this.totalWithoutTaxConv):void 0}),this.warehouseId&&(v={...v,warehouseId:this.warehouseId}),this.creditDueDate?v={...v,creditDueDate:this.creditDueDate}:v={...v,cashRegisterUuid:this.cashRegisterUuid,payments:[]},this.warehouseId&&(v={...v,warehouseId:this.warehouseId}),this.relatedDocs&&(v={...v,relatedDocs:this.relatedDocs}),this.comment!=""&&(v={...v,comment:this.comment}),this.seller){let S={uuid:String(this.seller.uuid),name:this.seller.name,email:(l=this.seller)==null?void 0:l.email,phoneNumbers:(h=(d=this.seller)==null?void 0:d.phoneNumbers)!=null&&h.length?(p=this.seller)==null?void 0:p.phoneNumbers:[],position:((f=this.seller)==null?void 0:f.position)??""},C=Object.fromEntries((g=Object.entries(S))==null?void 0:g.filter(E=>{var w;return(E==null?void 0:E[1])!==""&&(E==null?void 0:E[1])!==null&&(E==null?void 0:E[1])!==void 0&&((w=E==null?void 0:E[1])==null?void 0:w.length)!==0}));v={...v,employee:C}}if(this.agent&&this.agent.uuid&&this.agent.uuid!="-1"){let S={key:this.agent.key??"",uuid:this.agent.uuid??"",name:this.agent.name,withholdTaxes:this.agent.withholdTaxes,priceNumber:this.agent.priceNumber,phoneNumbers:this.agent.phoneNumbers,emails:this.agent.emails,address:this.agent.address},C=Object.fromEntries((y=Object.entries(S))==null?void 0:y.filter(E=>{var w;return(E==null?void 0:E[1])!==""&&(E==null?void 0:E[1])!==null&&(E==null?void 0:E[1])!==void 0&&((w=E==null?void 0:E[1])==null?void 0:w.length)!==0}));v={...v,agent:C}}if(this.documentDateString!=null&&(v={...v,documentDate:this.documentDateString}),this.paymentsOptions.length>0&&!this.creditDueDate){let S=[];this.paymentsOptions.filter(C=>C.amount>0).map(C=>{let E={paymentId:m[Number(C.paymentOptionId)-1],amount:C.amount};C!=null&&C.comment&&(E={...E,comment:C.comment}),C!=null&&C.isoCurrency&&this.mainIsoCurrency!==C.isoCurrency&&(E={...E,isoCurrency:C.isoCurrency,exchangeRate:C.exchangeRate,convertedAmount:C.convertedAmount}),S.push(E)}),v={...v,payments:S}}if(this.details.length>0){let S=[];this.details.map(C=>{var E,w,_;let P=[];C.taxes.map(B=>{P.push(B.uuid??B.taxId)});let x={uuid:C.fastProduct||(C==null?void 0:C.type)==5||(C==null?void 0:C.type)==7?null:C.uuid,sku:C.fastProduct||(C==null?void 0:C.type)==5||(C==null?void 0:C.type)==7?null:C.sku,type:C.type,description:C.description,unit:C.unit,quantity:C.quantity,priceBaseTax:C.priceBaseTax,priceBaseTaxConv:C.priceBaseTaxConv,priceTax:C.priceTax,priceBaseConv:C.priceBaseConv,priceConv:C.priceConv,priceTaxConv:C.priceTaxConv,amountTax:C.amountTax,purchasePriceTax:C.netCostByPurchaseUnit,additionalInfo:C.additionalInfo||"",timeQty:0,unitTime:0,taxesIds:P.length==0?null:P};Number((w=(E=C==null?void 0:C.stockInfoSelect)==null?void 0:E.lots)==null?void 0:w.length)>0&&(x={...x,lots:(_=C==null?void 0:C.stockInfoSelect)==null?void 0:_.lots}),C!=null&&C.rps&&(x={...x,rps:C.rps}),C!=null&&C.claveSat&&(x={...x,claveProdServ:C.claveSat}),C!=null&&C.claveUnidad&&(x={...x,claveUnidad:C.claveUnidad}),C!=null&&C.comment&&C.comment!=""&&(x={...x,comment:C.comment});let R=Object.fromEntries(Object.entries(x).filter(B=>(B==null?void 0:B[1])!==""&&(B==null?void 0:B[1])!==null&&(B==null?void 0:B[1])!==void 0));S.push(R)}),v={...v,products:S}}if(Number((b=this.change)==null?void 0:b.amount)!=0&&!this.creditDueDate){let S={amount:this.change.amount};this.change.isoCurrency!==this.mainIsoCurrency&&(S={...S,isoCurrency:this.change.isoCurrency,exchangeRate:this.change.exchangeRate,convertedAmount:this.change.convertedAmount}),v={...v,change:S}}return this.mainIsoCurrency!==this.isoCurrency&&(v={...v,mainIsoCurrency:this.mainIsoCurrency,exchangeRate:this.exchangeRate}),v!=null&&v.payments&&v.payments.length===0?Object.fromEntries(Object.entries(v).filter(S=>S[0]!=="cashRegisterUuid"&&S[0]!=="payments")):v}),this.uuid=t,this.documentDate=null,this.timeZone=i,this.mainIsoCurrency=r,this.isoCurrency=n,this.exchangeRate=a,this.cashRegisterUuid=s,this.change.isoCurrency=r,this.decimals=o<2||!o?2:o,c&&(this.agent.uuid=c!=null&&c.uuid?c.uuid:"-1",this.agent.name=c==null?void 0:c.name,this.agent.priceNumber=c==null?void 0:c.priceNumber,this.agent.emails=(u=c==null?void 0:c.emails)!=null&&u.length?c.emails:[])}};var L5=Object.defineProperty,M5=(e,t,r)=>t in e?L5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mt=(e,t,r)=>M5(e,typeof t!="symbol"?t+"":t,r);let XR=class extends R0{constructor(t,r,n,a,s,i,o,c){var u;super(),mt(this,"model","quotations"),mt(this,"documentType",3),mt(this,"wait",!0),mt(this,"searchQuotation",!0),mt(this,"duplicateQuotation",!0),mt(this,"details",[]),mt(this,"comment",""),mt(this,"seller",null),mt(this,"checkPrice",!0),mt(this,"expirationDate",null),mt(this,"expirationDateString",null),mt(this,"editDate","menu"),mt(this,"configuration",!0),mt(this,"isoCurrency",""),mt(this,"exchangeRate",1),mt(this,"agent",{uuid:"-1",key:"",name:"PUBLICO EN GENERAL",priceNumber:1,withholdTaxes:!1,emails:[]}),mt(this,"userAlias",""),mt(this,"cancellationComment",null),mt(this,"cancellationDate",null),mt(this,"cancellationUserAccount",null),mt(this,"cancellationUserAlias",null),mt(this,"cancellationUserUuid",null),mt(this,"childDocs",[]),mt(this,"parentDocs",[]),mt(this,"idFormat",null),mt(this,"init",async l=>{this.id=l.id,this.uuid=l.uuid,this.folio=l.folio,this.comment=l.comment,this.details=l.details,this.documentType=l.documentType,this.createDate=l.createDate,this.documentDate=l.documentDate,this.timeZone=l.timeZone,this.mainIsoCurrency=l.mainIsoCurrency,this.isoCurrency=l.isoCurrency,this.exchangeRate=l.exchangeRate,this.serie=l.serie,this.decimals=l.decimals<2||!l.decimals?2:l.decimals,this.totalDiscountPercentage=l.totalDiscountPercentage,this.totalBaseTax=l.totalBaseTax,this.totalTax=l.totalTax,this.totalDiscount=l.totalDiscount,this.totalDiscountTax=l.totalDiscountTax,this.totalWithoutTax=l.totalWithoutTax,this.totalQuantity=l.totalQuantity,this.totalCost=l.totalCost,this.totalDiff=l.totalDiff,this.totalUtility=l.totalUtility,this.agent=l.agent,this.seller=l.seller,this.userAlias=l.userAlias,this.status=l.status,this.cancellationComment=(l==null?void 0:l.cancellationComment)??null,this.cancellationDate=(l==null?void 0:l.cancellationDate)??null,this.cancellationUserAccount=(l==null?void 0:l.cancellationUserAccount)??null,this.cancellationUserAlias=(l==null?void 0:l.cancellationUserAlias)??null,this.cancellationUserUuid=(l==null?void 0:l.cancellationUserUuid)??null,this.expirationDate=l.expirationDate,this.expirationDateString=l.expirationDateString,this.idFormat=l.idFormat}),mt(this,"setEntity",l=>{var d,h;this.id=l.id,this.uuid=l.uuid,this.decimals=l.decimals<2||!l.decimals?2:l.decimals,this.serie=l.serie,this.mainIsoCurrency=l.mainIsoCurrency,this.isoCurrency=l.isoCurrency,this.exchangeRate=l.exchangeRate??1,this.folio=l.serieFolio,this.createDate=l.creationDate??l.createDate,this.documentDate=l.documentDate,this.comment=(l==null?void 0:l.comment)??"",this.timeZone=l.timeZone,this.userAlias=l.userAlias,this.status=l.status,this.expirationDate=l.expirationDate,this.expirationDateString=l.expirationDateString,this.cancellationComment=(l==null?void 0:l.cancellationComment)??null,this.cancellationDate=(l==null?void 0:l.cancellationDate)??null,this.cancellationUserAccount=(l==null?void 0:l.cancellationUserAccount)??null,this.cancellationUserAlias=(l==null?void 0:l.cancellationUserAlias)??null,this.cancellationUserUuid=(l==null?void 0:l.cancellationUserUuid)??null,this.agent=l==null?void 0:l.agent,this.agent.uuid=(d=l==null?void 0:l.agent)!=null&&d.uuid?(h=l==null?void 0:l.agent)==null?void 0:h.uuid:"-1",this.seller=l==null?void 0:l.employee,this.childDocs=(l==null?void 0:l.childDocs)??[],this.parentDocs=(l==null?void 0:l.parentDocs)??[],this.details=[]}),mt(this,"getQuotation",()=>{var l,d,h,p,f,g,y;let b={uuid:this.uuid,type:"QUOTATION",decimals:this.decimals,isoCurrency:this.isoCurrency,opMode:"MX",total:Number(this.totalTax),serie:this.serie===null?"":this.serie,timeZone:this.timeZone,products:[],expirationDate:this.expirationDateString};if(this.totalWithoutTax&&Number(this.totalWithoutTax)>0&&(b={...b,withholdingTax:Number(this.totalWithoutTax),withholdingTaxMc:Number(this.totalWithoutTaxConv)>0?Number(this.totalWithoutTaxConv):void 0}),this!=null&&this.comment&&(b={...b,comment:this.comment}),this.seller){let m={uuid:String(this.seller.uuid),name:this.seller.name,email:(l=this.seller)==null?void 0:l.email,phoneNumbers:(h=(d=this.seller)==null?void 0:d.phoneNumbers)!=null&&h.length?(p=this.seller)==null?void 0:p.phoneNumbers:[],position:((f=this.seller)==null?void 0:f.position)??""},v=Object.fromEntries((g=Object.entries(m))==null?void 0:g.filter(S=>{var C;return(S==null?void 0:S[1])!==""&&(S==null?void 0:S[1])!==null&&(S==null?void 0:S[1])!==void 0&&((C=S==null?void 0:S[1])==null?void 0:C.length)!==0}));b={...b,employee:v}}if(this.agent&&this.agent.uuid&&this.agent.uuid!="-1"){let m={key:this.agent.key??"",uuid:this.agent.uuid??"",name:this.agent.name,withholdTaxes:this.agent.withholdTaxes,priceNumber:this.agent.priceNumber,phoneNumbers:this.agent.phoneNumbers,emails:this.agent.emails,address:this.agent.address},v=Object.fromEntries((y=Object.entries(m))==null?void 0:y.filter(S=>{var C;return(S==null?void 0:S[1])!==""&&(S==null?void 0:S[1])!==null&&(S==null?void 0:S[1])!==void 0&&((C=S==null?void 0:S[1])==null?void 0:C.length)!==0}));b={...b,agent:v}}if(this.documentDateString!=null&&(b={...b,documentDate:this.documentDateString}),this.details.length>0){let m=[];this.details.map(v=>{let S=[];v.taxes.map(w=>{w!=null&&w.uuid?S.push(w==null?void 0:w.uuid):S.push(w==null?void 0:w.taxId)});let C={uuid:v.fastProduct?null:v.uuid,sku:v.fastProduct?null:v.sku,type:v.type,description:v.description,unit:v.unit,quantity:v.quantity,priceBaseTax:v.priceBaseTax,priceBaseTaxConv:v.priceBaseTaxConv,priceTax:v.priceTax,priceBaseConv:v.priceBaseConv,priceConv:v.priceConv,priceTaxConv:v.priceTaxConv,amountTax:v.amountTax,purchasePrice:v.costByPurchaseUnit,purchasePriceTax:v.netCostByPurchaseUnit,additionalInfo:v.additionalInfo??"",timeQty:0,unitTime:0,taxesIds:S.length==0?null:S,edited:!!v.editRow};v!=null&&v.claveSat&&(C={...C,claveProdServ:v.claveSat}),v!=null&&v.claveUnidad&&(C={...C,claveUnidad:v.claveUnidad}),v!=null&&v.comment&&v.comment!=""&&(C={...C,comment:v.comment});let E=Object.fromEntries(Object.entries(C).filter(w=>(w==null?void 0:w[1])!==""&&(w==null?void 0:w[1])!==null&&(w==null?void 0:w[1])!==void 0));m.push(E)}),b={...b,products:m}}return this.mainIsoCurrency!==this.isoCurrency&&(b={...b,mainIsoCurrency:this.mainIsoCurrency,exchangeRate:this.exchangeRate}),b}),this.uuid=t,this.documentDate=null,this.timeZone=i,this.mainIsoCurrency=r,this.isoCurrency=n,this.exchangeRate=a,this.profitByMargin=s,this.decimals=o<2||!o?2:o,c&&(this.agent.uuid=c!=null&&c.uuid?c.uuid:"-1",this.agent.name=c==null?void 0:c.name,this.agent.priceNumber=c==null?void 0:c.priceNumber,this.agent.emails=(u=c==null?void 0:c.emails)!=null&&u.length?c.emails:[])}};var j5=Object.defineProperty,F5=(e,t,r)=>t in e?j5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xe=(e,t,r)=>F5(e,typeof t!="symbol"?t+"":t,r);let q5=class{constructor(){Xe(this,"id",""),Xe(this,"model",""),Xe(this,"opMode","MX"),Xe(this,"uuid",""),Xe(this,"serie",null),Xe(this,"folio",""),Xe(this,"decimals",2),Xe(this,"documentType",0),Xe(this,"documentDate",null),Xe(this,"documentDateString",null),Xe(this,"createDate",null),Xe(this,"createDateString",null),Xe(this,"timeZone",""),Xe(this,"mainIsoCurrency",""),Xe(this,"totalQuantity","0"),Xe(this,"totalDiscountPercentage","0"),Xe(this,"totalBase","0"),Xe(this,"totalBaseConv","0"),Xe(this,"totalBaseTax","0"),Xe(this,"totalBaseTaxConv","0"),Xe(this,"total","0"),Xe(this,"totalConv","0"),Xe(this,"totalTax","0"),Xe(this,"totalTaxTras","0"),Xe(this,"totalTaxConv","0"),Xe(this,"totalDiscount","0"),Xe(this,"totalDiscountConv","0"),Xe(this,"totalDiscountTax","0"),Xe(this,"totalDiscountTaxConv","0"),Xe(this,"totalWithoutTax","0"),Xe(this,"totalWithoutTaxConv","0"),Xe(this,"totalTaxesWithheld","0"),Xe(this,"totalCost","0"),Xe(this,"totalCostConv","0"),Xe(this,"status"),Xe(this,"withholdingTaxMc","0"),Xe(this,"creditDueDate","")}};var H5=Object.defineProperty,K5=(e,t,r)=>t in e?H5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Lt=(e,t,r)=>K5(e,typeof t!="symbol"?t+"":t,r);let tN=class extends q5{constructor(t,r,n,a,s,i,o){super(),Lt(this,"id",""),Lt(this,"model","purchase"),Lt(this,"documentType",4),Lt(this,"wait",!0),Lt(this,"details",[]),Lt(this,"detailsCFDI",[]),Lt(this,"comment",""),Lt(this,"seller",null),Lt(this,"checkPrice",!0),Lt(this,"printLast",!0),Lt(this,"isoCurrency",""),Lt(this,"exchangeRate",1),Lt(this,"paymentsOptions",[]),Lt(this,"agent",{uuid:"-1",key:"",name:"PUBLICO EN GENERAL",priceNumber:1,withholdTaxes:!1,emails:[]}),Lt(this,"externalFolio",""),Lt(this,"warehouseId",null),Lt(this,"idFormat",2),Lt(this,"cfdi",!1),Lt(this,"cfdiData"),Lt(this,"init",async c=>{this.uuid=(c==null?void 0:c.uuid)||this.uuid,this.comment=(c==null?void 0:c.comment)||this.comment,this.details=(c==null?void 0:c.details)||this.details,this.documentType=(c==null?void 0:c.documentType)||this.documentType,this.documentDate=(c==null?void 0:c.documentDate)||this.documentDate,this.timeZone=(c==null?void 0:c.timeZone)||this.timeZone,this.mainIsoCurrency=(c==null?void 0:c.mainIsoCurrency)||this.mainIsoCurrency,this.isoCurrency=(c==null?void 0:c.isoCurrency)||this.isoCurrency,this.exchangeRate=(c==null?void 0:c.exchangeRate)||this.exchangeRate,this.serie=(c==null?void 0:c.serie)||this.serie,this.externalFolio=(c==null?void 0:c.externalFolio)||this.externalFolio,this.decimals=c===void 0||c.decimals<2||!c.decimals?2:c.decimals,this.total=(c==null?void 0:c.total)||this.total,this.totalQuantity=(c==null?void 0:c.totalQuantity)||this.totalQuantity,this.totalDiscountPercentage=(c==null?void 0:c.totalDiscountPercentage)||this.totalDiscountPercentage,this.totalBaseTax=(c==null?void 0:c.totalBaseTax)||this.totalBaseTax,this.totalBaseConv=(c==null?void 0:c.totalBaseConv)||this.totalBaseConv,this.totalBaseTaxConv=(c==null?void 0:c.totalBaseTaxConv)||this.totalBaseTaxConv,this.totalTax=(c==null?void 0:c.totalTax)||this.totalTax,this.totalTaxTras=(c==null?void 0:c.totalTaxTras)||this.totalTaxTras,this.totalTaxConv=(c==null?void 0:c.totalTaxConv)||this.totalTaxConv,this.totalDiscount=(c==null?void 0:c.totalDiscount)||this.totalDiscount,this.totalDiscountTax=(c==null?void 0:c.totalDiscountTax)||this.totalDiscountTax,this.totalDiscountTaxConv=(c==null?void 0:c.totalDiscountTaxConv)||this.totalDiscountTaxConv,this.totalWithoutTax=(c==null?void 0:c.totalWithoutTax)||this.totalWithoutTax,this.totalTaxesWithheld=(c==null?void 0:c.totalTaxesWithheld)||this.totalTaxesWithheld,this.agent=(c==null?void 0:c.agent)||this.agent,this.seller=(c==null?void 0:c.seller)||this.seller,this.paymentsOptions=[],this.warehouseId=(c==null?void 0:c.warehouseId)||null,this.cfdi=(c==null?void 0:c.cfdi)!==void 0?c.cfdi:!1,this.detailsCFDI=(c==null?void 0:c.detailsCFDI)!==void 0?c.detailsCFDI:[],this.cfdiData=(c==null?void 0:c.cfdiData)!==void 0?c.cfdiData:void 0}),Lt(this,"setEntity",c=>{var u;this.uuid=c.uuid,this.decimals=c.decimals<2||!c.decimals?2:c.decimals,this.serie=c.serie,this.externalFolio=c.externalFolio,this.mainIsoCurrency=c.mainIsoCurrency,this.isoCurrency=c.isoCurrency,this.exchangeRate=c.exchangeRate??1,this.folio="",this.documentDate=null,this.comment=(c==null?void 0:c.comment)??"",this.timeZone=c.timeZone,this.warehouseId=(c==null?void 0:c.warehouseId)||null,this.cfdi=c.cfdi!==void 0?c.cfdi:!1,this.detailsCFDI=c.detailsCFDI!==void 0?c.detailsCFDI:[],this.cfdiData=c.cfdiData!==void 0?c.cfdiData:void 0,(u=c==null?void 0:c.agent)!=null&&u.uuid&&(this.agent=c==null?void 0:c.agent),c!=null&&c.employee&&(this.seller=c==null?void 0:c.employee),this.details=[]}),Lt(this,"getPurchase",c=>{var u,l,d,h,p,f,g;let y=["CASH","DEBIT_CARD","CREDIT_CARD","ELECTRONIC_TRANSFER","CHECK","GROCERY_VOUCHER"],b={key:this.agent.key??"",uuid:this.agent.uuid??"",name:this.agent.name,alias:this.agent.alias??null,withholdTaxes:this.agent.withholdTaxes,priceNumber:this.agent.priceNumber,phoneNumbers:this.agent.phoneNumbers,emails:this.agent.emails,address:this.agent.address},m=Object.fromEntries((u=Object.entries(b))==null?void 0:u.filter(S=>{var C;return(S==null?void 0:S[1])!==""&&(S==null?void 0:S[1])!==null&&(S==null?void 0:S[1])!==void 0&&((C=S==null?void 0:S[1])==null?void 0:C.length)!==0})),v={uuid:this.uuid,type:"PURCHASE",decimals:this.decimals,isoCurrency:this.isoCurrency,opMode:this.cfdi?"CFDI":"MX",total:Number(this.totalTax),serie:this.serie,timeZone:this.timeZone,products:[],payments:[],agent:m};if(this.warehouseId&&(v={...v,warehouseId:this.warehouseId}),this.externalFolio!=""&&(v={...v,externalFolio:this.externalFolio}),this.comment!=""&&(v={...v,comment:this.comment.trim()}),this.seller){let S={uuid:String(this.seller.uuid),name:this.seller.name,email:(l=this.seller)==null?void 0:l.email,phoneNumbers:(h=(d=this.seller)==null?void 0:d.phoneNumbers)!=null&&h.length?(p=this.seller)==null?void 0:p.phoneNumbers:[],position:((f=this.seller)==null?void 0:f.position)??""},C=Object.fromEntries((g=Object.entries(S))==null?void 0:g.filter(E=>{var w;return(E==null?void 0:E[1])!==""&&(E==null?void 0:E[1])!==null&&(E==null?void 0:E[1])!==void 0&&((w=E==null?void 0:E[1])==null?void 0:w.length)!==0}));v={...v,employee:C}}if(this.documentDateString!=null&&(v={...v,documentDate:this.documentDateString}),this.paymentsOptions.length>0&&this.creditDueDate===""){let S=[];this.paymentsOptions.filter(C=>C.amount>0).map(C=>{let E={paymentId:y[Number(C.paymentOptionId)-1],amount:C.amount};c&&C.paymentOptionId==1&&(E={...E,cashRegisterUuid:c}),C!=null&&C.comment&&(E={...E,comment:C.comment.trim()}),C!=null&&C.isoCurrency&&this.mainIsoCurrency!==C.isoCurrency&&(E={...E,isoCurrency:C.isoCurrency,exchangeRate:C.exchangeRate,convertedAmount:C.convertedAmount}),S.push(E)}),v={...v,payments:S}}if(this.creditDueDate!==""&&(v={...v,creditDueDate:this.creditDueDate}),this.details.length>0){const S=[];this.details.map(C=>{var E,w,_,P,x,R;this.agent.withholdTaxes&&(v.withholdingTax=new ba(v.withholdingTax||0).add(C.totalTaxesWithheld));let B=[];C.taxes.map(ee=>{B.push(ee.uuid??ee.taxId)});let K=this.cfdi?{uuid:C.fastProduct?null:C.uuid,type:C.type,sku:C.fastProduct?null:N5(((E=C.cfdi)==null?void 0:E.sxSku)||"")===""?(w=C.cfdi)==null?void 0:w.supplierSku:(_=C.cfdi)==null?void 0:_.sxSku,description:C.description,unit:C.unit,quantity:C.quantity,priceBase:C.priceBase,amount:C.amount,amountBase:C.amountBase,amountTaxConv:C.amountTaxConv,amountBaseTaxConv:C.amountBaseTaxConv,additionalInfo:C.additionalInfo||"",timeQty:0,unitTime:0,supplierSku:(P=C.cfdi)==null?void 0:P.supplierSku,factor:C!=null&&C.factor?C.factor:1}:{uuid:C.fastProduct?null:C.uuid,type:C.type,sku:C.fastProduct?null:C.sku,description:C.description,unit:C.unit,quantity:C.quantity,priceBaseTax:C.priceBaseTax,priceBaseTaxConv:C.priceBaseTaxConv,priceTax:C.priceTax,priceTaxConv:C.priceTaxConv,priceBaseConv:C.priceBaseConv,priceConv:C.priceConv,amountTax:C.amountTax,additionalInfo:C.additionalInfo||"",timeQty:0,unitTime:0,taxesIds:B.length==0?null:B,supplierSku:C.sku,factor:C!=null&&C.factor?C.factor:1};this.cfdi&&this.cfdiData&&(v={...v,invoiceUuid:this.cfdiData.invoiceUuid,emisor:this.cfdiData.emisor}),this.cfdi&&(x=C.cfdi)!=null&&x.taxes.length&&(K={...K,taxesCfdi:(R=C.cfdi)==null?void 0:R.taxes}),C!=null&&C.comment&&C.comment!=""&&(K={...K,comment:C.comment.trim()}),C.lot&&C.lots&&(C.lots=C.lots.map(ee=>(ee.fabricationDate&&ee.fabricationDate!==""&&(ee.fabricationDate=n1(ee.fabricationDate).getTime()),ee.quantity=new ba(ee.quantity).mul(new ba((C==null?void 0:C.factor)||1)).toString(),ee)),K={...K,lots:C.lots});let re=Object.fromEntries(Object.entries(K).filter(ee=>(ee==null?void 0:ee[1])!==""&&(ee==null?void 0:ee[1])!==null&&(ee==null?void 0:ee[1])!==void 0));S.push(re)}),v={...v,products:S}}return this.mainIsoCurrency!==this.isoCurrency&&(v={...v,mainIsoCurrency:this.mainIsoCurrency,exchangeRate:this.exchangeRate},this.agent.withholdTaxes&&this.withholdingTaxMc!="0"&&(v={...v,withholdingTaxMc:this.withholdingTaxMc})),v!=null&&v.payments&&v.payments.length===0?Object.fromEntries(Object.entries(v).filter(S=>S[0]!=="cashRegisterUuid"&&S[0]!=="payments")):v}),this.uuid=t,this.documentDate=null,this.timeZone=s,this.mainIsoCurrency=r,this.isoCurrency=n,this.exchangeRate=a,this.decimals=i<2||!i?2:i,this.warehouseId=o||null}};var V5=Object.defineProperty,z5=(e,t,r)=>t in e?V5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nt=(e,t,r)=>z5(e,typeof t!="symbol"?t+"":t,r);let nN=class extends R0{constructor(t,r,n,a,s,i,o,c,u){var l;super(),Nt(this,"model","order"),Nt(this,"documentType",8),Nt(this,"wait",!0),Nt(this,"searchQuotation",!0),Nt(this,"duplicateQuotation",!0),Nt(this,"details",[]),Nt(this,"comment",""),Nt(this,"seller",null),Nt(this,"checkPrice",!0),Nt(this,"editDate","menu"),Nt(this,"configuration",!0),Nt(this,"isoCurrency",""),Nt(this,"exchangeRate",1),Nt(this,"groupId"),Nt(this,"groupName"),Nt(this,"groupType"),Nt(this,"zoneId"),Nt(this,"zoneName"),Nt(this,"waiterName"),Nt(this,"agent",{uuid:"-1",key:"",name:"PUBLICO EN GENERAL",priceNumber:1,withholdTaxes:!1,emails:[]}),Nt(this,"idFormat",null),Nt(this,"init",async d=>{this.uuid=d.uuid,this.folio=d.folio,this.comment=d.comment,this.details=d.details,this.documentType=d.documentType,this.createDate=d.createDate,this.documentDate=d.documentDate,this.timeZone=d.timeZone,this.mainIsoCurrency=d.mainIsoCurrency,this.isoCurrency=d.isoCurrency,this.exchangeRate=d.exchangeRate,this.serie=d.serie,this.decimals=d.decimals<2||!d.decimals?2:d.decimals,this.totalDiscountPercentage=d.totalDiscountPercentage,this.totalBaseTax=d.totalBaseTax,this.totalTax=d.totalTax,this.totalDiscount=d.totalDiscount,this.totalDiscountTax=d.totalDiscountTax,this.totalWithoutTax=d.totalWithoutTax,this.totalQuantity=d.totalQuantity,this.totalCost=d.totalCost,this.totalDiff=d.totalDiff,this.totalUtility=d.totalUtility,this.agent=d.agent,this.seller=d.seller,this.status=d.status,this.groupId=d==null?void 0:d.groudId,this.groupName=d==null?void 0:d.groupName,this.groupType=d==null?void 0:d.groupType,this.zoneId=d==null?void 0:d.zoneId,this.zoneName=d==null?void 0:d.zoneName,this.waiterName=d==null?void 0:d.waiterName,this.idFormat=d.idFormat}),Nt(this,"setEntity",d=>{var h,p;this.uuid=d.uuid,this.decimals=d.decimals<2||!d.decimals?2:d.decimals,this.serie=d.serie,this.mainIsoCurrency=d.mainIsoCurrency,this.isoCurrency=d.isoCurrency,this.exchangeRate=d.exchangeRate??1,this.folio=d.serieFolio,this.createDate=d.creationDate??d.createDate,this.documentDate=d.documentDate,this.comment=(d==null?void 0:d.comment)??"",this.timeZone=d.timeZone,this.status=d.status,this.agent=d==null?void 0:d.agent,this.agent.uuid=(h=d==null?void 0:d.agent)!=null&&h.uuid?(p=d==null?void 0:d.agent)==null?void 0:p.uuid:"-1",this.seller=d==null?void 0:d.employee,this.groupId=d==null?void 0:d.groudId,this.groupName=d==null?void 0:d.groupName,this.groupType=d==null?void 0:d.groupType,this.zoneId=d==null?void 0:d.zoneId,this.zoneName=d==null?void 0:d.zoneName,this.waiterName=d==null?void 0:d.waiterName,this.details=[]}),Nt(this,"getOrder",()=>{var d,h,p,f,g,y,b;let m={uuid:this.uuid,type:"ORDER",decimals:this.decimals,isoCurrency:this.isoCurrency,opMode:"MX",total:Number(this.totalTax),serie:this.serie===null?"":this.serie,timeZone:this.timeZone,groupId:this.groupId,zoneId:this.zoneId,products:[]};if(this!=null&&this.comment&&(m={...m,comment:this.comment}),this.seller){let v={uuid:String(this.seller.uuid),name:this.seller.name,email:(d=this.seller)==null?void 0:d.email,phoneNumbers:(p=(h=this.seller)==null?void 0:h.phoneNumbers)!=null&&p.length?(f=this.seller)==null?void 0:f.phoneNumbers:[],position:((g=this.seller)==null?void 0:g.position)??""},S=Object.fromEntries((y=Object.entries(v))==null?void 0:y.filter(C=>{var E;return(C==null?void 0:C[1])!==""&&(C==null?void 0:C[1])!==null&&(C==null?void 0:C[1])!==void 0&&((E=C==null?void 0:C[1])==null?void 0:E.length)!==0}));m={...m,employee:S}}if(this.agent&&this.agent.uuid&&this.agent.uuid!="-1"){let v={key:this.agent.key??"",uuid:this.agent.uuid??"",name:this.agent.name,withholdTaxes:this.agent.withholdTaxes,priceNumber:this.agent.priceNumber,phoneNumbers:this.agent.phoneNumbers,emails:this.agent.emails,address:this.agent.address},S=Object.fromEntries((b=Object.entries(v))==null?void 0:b.filter(C=>{var E;return(C==null?void 0:C[1])!==""&&(C==null?void 0:C[1])!==null&&(C==null?void 0:C[1])!==void 0&&((E=C==null?void 0:C[1])==null?void 0:E.length)!==0}));m={...m,agent:S}}if(this.documentDateString!=null&&(m={...m,documentDate:this.documentDateString}),this.details.length>0){let v=[];this.details.map(C=>{let E=[];C.taxes.map(P=>{P!=null&&P.uuid?E.push(P==null?void 0:P.uuid):E.push(P==null?void 0:P.taxId)});let w={uuid:C.fastProduct?null:C.uuid,sku:C.fastProduct?null:C.sku,type:C.type,description:C.description,unit:C.unit,quantity:C.quantity,priceBaseTax:C.priceBaseTax,priceBaseTaxConv:C.priceBaseTaxConv,priceTax:C.priceTax,priceBaseConv:C.priceBaseConv,priceConv:C.priceConv,priceTaxConv:C.priceTaxConv,amountTax:C.amountTax,purchasePrice:C.costByPurchaseUnit,purchasePriceTax:C.netCostByPurchaseUnit,additionalInfo:C.additionalInfo??"",timeQty:0,unitTime:0,taxesIds:E.length==0?null:E,edited:!!C.editRow};C!=null&&C.separator&&(w={...w,separator:C.separator}),C!=null&&C.claveSat&&(w={...w,claveProdServ:C.claveSat}),C!=null&&C.claveUnidad&&(w={...w,claveUnidad:C.claveUnidad}),C!=null&&C.comment&&C.comment!=""&&(w={...w,comment:C.comment});let _=Object.fromEntries(Object.entries(w).filter(P=>(P==null?void 0:P[1])!==""&&(P==null?void 0:P[1])!==null&&(P==null?void 0:P[1])!==void 0));v.push(_)});let S=[];if((v==null?void 0:v.length)>0){let C;for(let E=Number(v==null?void 0:v.length)-1;E>=0;E--){let w=v==null?void 0:v[E];w!=null&&w.separator?C=w==null?void 0:w.separator:(C&&(w.separator=C),S.unshift(w))}}m={...m,products:S}}return this.mainIsoCurrency!==this.isoCurrency&&(m={...m,mainIsoCurrency:this.mainIsoCurrency,exchangeRate:this.exchangeRate}),m}),this.uuid=t,this.documentDate=null,this.timeZone=i,this.mainIsoCurrency=r,this.isoCurrency=n,this.exchangeRate=a,this.profitByMargin=s,this.decimals=o<2||!o?2:o,this.groupId=u,c&&(this.agent.uuid=c!=null&&c.uuid?c.uuid:"-1",this.agent.name=c==null?void 0:c.name,this.agent.priceNumber=c==null?void 0:c.priceNumber,this.agent.emails=(l=c==null?void 0:c.emails)!=null&&l.length?c.emails:[])}};const sN={1:"SALE",2:"CFDI_INGRESO",3:"QUOTATION",4:"PURCHASE",5:"CLIENT_PAYMENT",6:"TRANSFER",7:"CFDI_PAGO",8:"ORDER"};var Id=(e=>(e.CFDIINGRESO="CFDI_INGRESO",e.SALE="SALE",e.QUOTATION="QUOTATION",e.PURCHASE="PURCHASE",e.CLIENTPAYMENT="CLIENT_PAYMENT",e.SUPPLIERPAYMENT="SUPPLIER_PAYMENT",e))(Id||{}),Yy=(e=>(e.MX="MX",e.US="US",e))(Yy||{}),Xy=(e=>(e.CASH="CASH",e.DEBITCARD="DEBIT_CARD",e.CREDITCARD="CREDIT_CARD",e.ELECTRONICTRANSFER="ELECTRONIC_TRANSFER",e.CHECK="CHECK",e.GROCERYVOUCHER="GROCERY_VOUCHER",e))(Xy||{}),G5=(e=>(e.Cuota="cuota",e.Tasa="tasa",e.Exento="exento",e))(G5||{});const iN=e=>(bi(e),new Promise((t,r)=>{J(`${dt}/agent`,e).then(n=>{t(n)}).catch(n=>{r(n.response)})})),oN=(e,t,r=1)=>{as(e),as(t),"phoneInputIdxFocus"in t&&delete t.phoneInputIdxFocus,"phoneInputIdxFocus"in e&&delete e.phoneInputIdxFocus,"emailInputIdxFocus"in t&&delete t.emailInputIdxFocus,"emailInputIdxFocus"in e&&delete e.emailInputIdxFocus;const n=sr.diff(e,t,{invertible:!1});return new Promise((a,s)=>{ze(`${dt}/agent/${e.uuid}/${r}`,n).then(i=>{a(i)}).catch(i=>{s(i.response)})})},cN=(e,t=1,r)=>new Promise((n,a)=>{ze(`${dt}/agent/status/${e}/${t}?status=${r}`,{}).then(s=>{n(s)}).catch(s=>{a(s)})}),uN=async(e,t)=>{const r=`query {
        invoiceInfo(uuid: "${e}", agentType: ${t}){
            uuid
            rfc
            businessName
            claveSatRegimen
            street
            extNumber
            intNumber
            district
            city
            county
            state
            country
            zipCode
            retention
            ieps
            idCif
            usoCfdi
            emails
        }
    }`;return J(`${dt}/catalogue/graphToSpecification`,r,"application/graphql").then(n=>{if(n.data.errors)throw n.data.errors;if(!n.data.data.invoiceInfo)throw new Error("No data");return{data:n.data.data.invoiceInfo}})},lN=(e,t,r=1)=>{const{blob:n,base64:a=""}=t,s=n!=null?{contentType:n.type,contentLength:n.size}:null;return new Promise((i,o)=>{Re(`${dt}/agent/image/${e}/${r}`,s).then(c=>{c.data?Rt.put(c.data,n,{headers:{"Content-Type":n==null?void 0:n.type}}).then(()=>i(a)).catch(u=>o(u.response)):i(c)}).catch(c=>{o(c.response)})})},dN=(e,t=1)=>new Promise((r,n)=>{Q(`${dt}/agent/byKey/${t}?key=${e}`).then(a=>{r(a)}).catch(a=>{n(a.response)})}),hN=async({type:e,offset:t=null,status:r=1,purchased:n=null,size:a=20,search:s="",withCredit:i=!1,creditStatus:o,timeZone:c="America/Mexico_City",rfc:u})=>{const l=t!=null?`"${t}"`:t,d=o?`dueDays: "${o}"`:"",h=d?`timeZone: "${c||"America/Mexico_City"}"`:"",p=u?`invoiceInfoRfc: "${u}"`:"",f=`{
        agentsWithCredit(
                type:${e}, 
                status: ${r},
                purchased: ${n},
                search : "${s}",
                offset: ${l},
                size: ${a},
                withCredit: ${i}
                ${d}
                ${h}
                ${p}
            ) {
            hasNext
            offset
            ${`elements {
        alias
        emails
        imageUrl
        key
        modified
        name
        phoneNumbers {
            phoneCode
            phoneNumber
        }
        purchased
        type
        uuid
        ${i?`agentCredit {
        debtBalance
        documentCreditDue {
            dueDate
        }
    }`:""}
    }
    `}
        }
    }`;return J(`${dt}/catalogue/graphToSpecification`,f,"application/graphql").then(g=>(g.data=Object.entries(g.data)[0][1],g.data.agentsWithCredit)).catch(g=>{throw g.response})},pN=async({uuid:e,type:t=1,status:r=1,requestInvoiceInfoMails:n=!1,requestInvoiceInfoWithoutAgentMails:a=!1,invoiceUuid:s})=>{const i=`{
       ${e&&e!==""?` agentId(id:"${e}",type:${t},status:${r}) {
            emails
        }`:""}
        ${n?`predeterminedInvoiceInfo(agentUuid:"${e}",agentType:${t}) {
            emails
        }`:""}
        ${a&&typeof s=="string"&&s!==""?`invoiceInfo(
          uuid:"${s}"
          agentType: 1
        ) {
         emails
      }`:""}
    }`;return J(`${dt}/catalogue/graphToSpecification`,i,"application/graphql").then(o=>{if(o.data.errors)throw o.data.errors;return o.data}).catch(o=>{throw o.response})},fN=async({uuid:e,type:t=1,status:r=1,permissions:{canReadAddress:n,canReadInvoice:a}})=>{const s=`query {
        agentId(id:"${e}",type:${t},status:${r}) {
            key
            uuid
            name
            alias
            emails
            priceNumber
            phoneNumbers {
                phoneCode
                phoneNumber
                phoneType
            }
            status
            imageUrl
            type
            curp
            comment
            birthday
        }
        ${n?`predeterminedAddress(agentUuid:"${e}",agentType:${t}) {
            city
            country
            county
            district
            extNumber
            intNumber
            state
            street
            uuid
            zipCode
        }`:""}
        ${a?`predeterminedInvoiceInfo(agentUuid:"${e}",agentType:${t}) {
            uuid
            rfc
            businessName
            claveSatRegimen
            street
            extNumber
            intNumber
            district
            city
            county
            state
            country
            zipCode
            retention
            ieps
            emails
        }`:""}
    }`;return J(`${dt}/catalogue/graphToSpecification`,s,"application/graphql").then(i=>({data:i.data.data,errors:i.data.errors})).catch(i=>{throw i.response})},N0=`${dt}/catalogue/graphToSpecification`,gN=(e,t,r,n=1)=>{r.forEach(s=>bi(s));let a=[];return t!=null&&a.push(`predeterminedInvoiceInfoUuid=${t}`),e!=null&&a.push(`agentUuid=${e}`),new Promise((s,i)=>{J(`${dt}/invoiceInfo/${n}${a.length?`?${a.join("&")}`:""}`,r).then(o=>{s(o)}).catch(o=>{i(o.response)})})},mN=(e,t=1)=>new Promise((r,n)=>{Q(`${dt}/invoiceInfo/predetermined/${e}/${t}`).then(a=>r(a)).catch(a=>n(a.response))}),yN=(e,t=1)=>new Promise((r,n)=>{Q(`${dt}/invoiceInfo/agentUuids/${e}/${t}`).then(a=>{r(a)}).catch(a=>{n(a.response)})}),vN=(e,t,r=1)=>new Promise((n,a)=>{ze(`${dt}/invoiceInfo/changePredetermined/${e}/${r}?invoiceInfoUuid=${t}`,{}).then(s=>{n(s)}).catch(s=>{a(s.response)})}),bN=(e,t,r=1)=>{console.log("breakpoint"),as(e),as(t),"emailInputIdxFocus"in t&&delete t.emailInputIdxFocus,"emailInputIdxFocus"in e&&delete e.emailInputIdxFocus;const n=sr.diff(e,t,{invertible:!1});return new Promise((a,s)=>{if(!n.length){a("ok");return}ze(`${dt}/invoiceInfo/${t.uuid}/${r}`,n).then(i=>{a(i)}).catch(i=>{s(i.response)})})},CN=(e,t,r)=>{const n=r?{"Set-Authorization":r}:"";return new Promise((a,s)=>{$e.patch(`${dt}/invoiceInfo/${t}/1/usoCfdi`,{usoCfdi:e},{headers:{"Content-Type":"application/json;charset=UTF-8",...n}}).then(i=>{a(i)}).catch(i=>{s(i.response)})})},SN=async(e,t=1)=>{const r=`query {
            agentInvoiceInfos(agentUuid: "${e}", agentType:${t}) {
                invoiceInfos {
                    uuid
                    rfc
                    businessName
                    usoCfdi
                    claveSatRegimen
                    street
                    extNumber
                    intNumber
                    district
                    city
                    county
                    state
                    country
                    zipCode
                    retention
                    ieps
                    emails
                }
                predeterminedInvoiceInfoUuid
            }
        }`;return J(N0,r,"application/graphql").then(n=>{if(!n.data.data.agentInvoiceInfos)throw{status:404,data:{errors:[{message:"No se encontraron datos"}]}};return{data:n.data.data.agentInvoiceInfos,errors:n.data.errors,status:n.status}})},EN=async(e,t=1,r=null,n=5)=>{const a=`query {
        byRfcInvoiceInfos(agentType:${t}, rfc:${e?`"${e}"`:"null"}, offset:${r?`"${r}"`:"null"}, limit:${n}) {
            elements {
                uuid
                rfc
                businessName
                claveSatRegimen
                street
                extNumber
                intNumber
                district
                city
                county
                state
                country
                zipCode
                retention
                ieps
                usoCfdi
                emails
            }
            hasNext
            offset
        }
    }`;return e&&e.length<3?Promise.resolve({data:[],hasNext:!1,offset:null}):J(N0,a,"application/graphql").then(s=>{var i,o;if(s.data.errors)throw s.data.errors;const{elements:c,hasNext:u,offset:l}=((o=(i=s==null?void 0:s.data)==null?void 0:i.data)==null?void 0:o.byRfcInvoiceInfos)??{elements:[],hasNext:!1,offset:null};return{data:c,hasNext:u,offset:l}})},xN=async(e,t=1,r=null,n=5)=>{const a=`query {  
            byBusinessNameInvoiceInfos(agentType:${t}, businessName:${e?`"${e}"`:"null"}, offset:${r?`"${r}"`:"null"}, limit:${n}) {
                elements {
                    uuid
                    rfc
                    businessName
                    claveSatRegimen
                    street
                    extNumber
                    intNumber
                    district
                    city
                    county
                    state
                    country
                    zipCode
                    retention
                    ieps
                    emails
                }
                hasNext
                offset
        }
    }`;return J(N0,a,"application/graphql").then(s=>{if(s.data.errors)throw s.data.errors;const{elements:i,hasNext:o,offset:c}=s.data.data.byBusinessNameInvoiceInfos;return{data:i,hasNext:o,offset:c}}).catch(s=>{throw s.response})},wN=(e,t,r,n=1)=>new Promise((a,s)=>{ze(`${dt}/invoiceInfo/add/${e}/${n}${typeof r<"u"&&r!==null?"?predeterminedInvoiceInfoUuid="+r:""}`,t).then(i=>{a(i)}).catch(i=>{s(i.response)})}),TN=(e,t=1)=>new Promise((r,n)=>{ft(`${dt}/invoiceInfo/${e}/${t}`).then(a=>{r(a)}).catch(a=>{n(a.response)})}),$N=(e,t,r=1)=>new Promise((n,a)=>{ze(`${dt}/invoiceInfo/remove/${e}/${r}`,t).then(s=>{n(s)}).catch(s=>{a(s.response)})}),AN=(e,t,r,n=1)=>(e.forEach(a=>bi(a)),new Promise((a,s)=>{J(`${dt}/address/${t}/${n}${r!==null?"?predeterminedAddressUuid="+r:""}`,e).then(i=>{a(i)}).catch(i=>{s(i.response)})})),IN=async(e,t,r=1)=>{const n=`query {
		address(uuid:"${e}", agentUuid:"${t}", agentType:${r}) {
			uuid
			street
			extNumber
			intNumber
			district
			city
			county
			state
			country
			zipCode
			reference
		}
	}`;return J(`${dt}/catalogue/graphToSpecification`,n,"application/graphql").then(a=>{if(a.data.errors)throw a.data.errors;if(!a.data.data.address)throw new Error("Address not found");return{data:a.data.data.address}}).catch(a=>{throw a.response})},PN=(e,t,r,n)=>{as(t),as(r);const a=sr.diff(t,r,{invertible:!1});return new Promise((s,i)=>{ze(`${dt}/address/${r.uuid}/${e}/${n}`,a).then(o=>{s(o)}).catch(o=>{i(o.response)})})},_N=(e,t,r)=>new Promise((n,a)=>{ft(`${dt}/address/${e}/${t}/${r}`).then(s=>{n(s)}).catch(s=>{a(s.response)})}),DN=(e,t,r)=>new Promise((n,a)=>{ze(`${dt}/address/changePredetermined/${e}/${r}?addressUuid=${t}`,{}).then(s=>{n(s)}).catch(s=>{a(s.response)})}),RN=async(e,t=1)=>{const r=`query {
		agentAddress(agentUuid:"${e}", agentType:${t}) {
			addresses {
				uuid
    			street
    			extNumber
    			intNumber
    			district
    			city
    			county
    			state
    			country
    			zipCode
			}
    		predeterminedAddressUuid
		}
	}`;return J(`${dt}/catalogue/graphToSpecification`,r,"application/graphql").then(n=>({data:n.data.data.agentAddress,errors:n.data.errors})).catch(n=>{throw n.response})},Q5=(e,t)=>{const{canReadList:r=!0,canReadSummary:n=!0}=t||{},a=e&&n;return`query CreditsInfo(${r?"$creditListFilter: CreditListFilter!":""}${a?", $agentUuid: String!, $timeZone: String!":""}) {
		${r?`creditListV2(creditListFilter: $creditListFilter) {
				list {
					id
					agent {
						uuid
						name
					}
					branchId
					uuid
					type
					serie
					folio
					serieFolio
					creationDate
					documentDate
					timeZone
					userAlias
					userAccount
					userUuid
					total
					creditBalance
					creditStatus
					childDocs {
						id
						serieFolio
						status
						uuid
						type
					} 
					parentDocs {
						serieFolio
						status
						uuid
						type
					}
					uninvoicedPayment {
						ids
					}
					creditDueDate
					creditPayments
					cfdiPaymentMethod
				}
				nextPage
			}`:""}
		${a?"overdueBalance(agentUuid: $agentUuid, timeZone: $timeZone)":""}
	}`},W5=`query DocumentReceptor($filter: IdsFilter) {
	byIds(filter: $filter) {
		id
		branchId
			receptor {
				address {
				street
				extNumber
				intNumber
				district
				city
				zipCode
				state
				country
			}
			uuid
			nombre
			rfc
			regimenFiscal
			usoCfdi
			codigoPostal
			breakdownIeps
			withholdTaxes
		}
			emisor {
			rfc
		}
			comprobante {
			metodoDePago
		}
			agent {
			name
			uuid
		}
	}
} `,Z5=`query DocumentReceptor($filter: IdsFilter) {
	byIds(filter: $filter) {
		uuid
		id
		branchId
		serieFolio
		documentDate
		predPaymentId
		isoCurrency
		total
		creditBalance
		paymentId
			payments {
			paymentId
			amount
			isoCurrency
			exchangeRate
			convertedAmount
		}
			childDocs {
			id
			uuid
			type
			serieFolio
			status
		}
			parentDocs {
			id
			uuid
			type
			serieFolio
			status
		}
		comment
	}
} `,Y5=`query CreditSummary($agentType: String!, $agentId: UUID!){
	agentCreditDto(agentId: $agentId, agentType: $agentType) {
		agentId
		creditListId
		creditLimit
		creditDays
		debtBalance
		creditAvailable
		blockCreditIfOverdue
			documentCreditDue {
			dueDate
		}
		documentCreditDueCounter
	}
} `,X5=`query CfdiPayment($objectId: String!, $branchId: Long) {
	generated(objectId: $objectId, branchId: $branchId) {
		id
		uuid
		type
		documentDate
		serie
		folio
		creationDate
		timeZone
		userAccount
		userUuid
		userAlias
			agent {
			uuid
			name
			alias      
			address{
				city
				country
				district
				extNumber
				intNumber
				state
				street
				zipCode
			},
			phoneNumbers {
				phoneCode
				phoneNumber
				phoneType
			}
		}
		cfdiCancelStatus
		total
		mainIsoCurrency
		isoCurrency
		status,
			payments{
			paymentId
			cashRegisterUuid
			amount
			comment
			isoCurrency
			exchangeRate
			convertedAmount
		}
			childDocs {
			id
			branchId
			type
			uuid
			serieFolio
			status
		}
		global
		cancellationDate
		cancellationUserAccount
		cancellationUserAlias
		cancellationUserUuid
		cancellationComment
		cashRegisterUuid
		discount
		discountTax
		discountPercentage
		discountPercentageTax
		invoiceUuid
		subtotal
		subtotalGeneral
		exchangeRate
		subtotalMc
		subtotalGeneralMc
		discountMc
		discountTaxMc
		totalMc
		profitMargin
			parentDocs{
			id
			uuid
			serieFolio
			branchId
			status
			type
		}
		warehouseId
		cancellationWarehouseId
		externalFolio
		checkStatus
		cancellationCheckStatus
		comment
		discountPercentageMc
		discountPercentageTaxMc
			products{
			claveProdServ
			claveUnidad
			uuid
			type
			sku
			description
			objetoImp
			unit
			priceBaseTax
			quantity
			priceBaseTax
			priceTax
			priceBase
			price
			amountBase
			amount
			amountTax
			amountBaseTax
			additionalInfo
			comment
			unitPrice
			unitPriceTax
			unitPriceMc
			unitPriceTaxMc
			discount
			discountTax
			discountAmount
			discountAmountTax
			discountPercentage
				taxes{
				taxId
				name
				rate
				claveSat
				base
				total
				type
				tras
			}
		}
			taxesCfdi{
			taxId
			name
			rate
			type
			claveSat
			base
			total
			tras
		}
			receptor {
			uuid
			nombre
			rfc
			regimenFiscal
			usoCfdi
			codigoPostal
			breakdownIeps
			withholdTaxes
			  address{
				reference
				state
				country
				district
				street
				extNumber
				intNumber
				county
				zipCode
				city
			}
		}
			emisor {
			rfc
			nombre
			regimenFiscal
			lugarExpedicion
			  address{
				reference
				state
				country
				district
				street
				extNumber
				intNumber
				county
				zipCode
				city
			}
		}
			comprobante{
			version
			metodoDePago
			formaPago
			exportacion
			tipoDeComprobante
			  timbre{
				version
				noCertificadoSAT
				selloCFD
				selloSAT
				uuid
				fechaTimbrado
			}
			  complementoPago {
				formaDePagoP
				fechaPago
			}
			codigo
			lugarExpedicion
			certificadoCsd
			tipoCambio
			cadenaOriginal
			fechaEmision
			  basicGlobalInfo{
				periodicityKey
				monthKey
				year
			}
			  impuestosLocales{
				version
				totaldeRetenciones
				totaldeTraslados
				trasladosLocales{
					impLocTrasladado
					tasadeTraslado
					importe
				}
				retencionesLocales{
					impLocRetenido
					tasadeRetencion
					importe
				}
			}
		}
		recalculateMode
		cancellationRecalculateMode
			cfdiPayments {
				payments {
				idDocumento
				monedaDR
				equivalenciaDR
				serie
				folio
				impPagado
				impSaldoAnt
				impSaldoInsoluto
				numParcialidad
				objetoImpDR
					impuestosDR {
					taxId
					name
					rate
					claveSat
					base
					total
					type
				}
			}
			tipoCambioP
		}
	}
} `,J5=`query CanceledCfdiPayment($objectId: String!, $branchId: Long) {
	generated(objectId: $objectId, branchId: $branchId) {
		id
		uuid
		type
		serie
		folio
		creationDate
		documentDate
		timeZone
		userAccount
		userUuid
		userAlias
        agent {
			uuid
			name
			alias      
        address{
				city
				country
				district
				extNumber
				intNumber
				state
				street
				zipCode
			},
        phoneNumbers {
				phoneCode
				phoneNumber
				phoneType
			}
		}
		cfdiCancelStatus
		total
		mainIsoCurrency
		isoCurrency
		status,
			payments{
			paymentId
			cashRegisterUuid
			amount
			comment
			isoCurrency
			exchangeRate
			convertedAmount
		}
        childDocs {
			id
			branchId
			type
			uuid
			serieFolio
			status
		}
		global
		cancellationDate
		cancellationUserAccount
		cancellationUserAlias
		cancellationUserUuid
		cancellationComment
		cashRegisterUuid
		discount
		discountTax
		discountPercentage
		discountPercentageTax
		subtotal
		subtotalGeneral
		exchangeRate
		subtotalMc
		subtotalGeneralMc
		discountMc
		discountTaxMc
		totalMc
		profitMargin
        parentDocs{
			id
			uuid
			serieFolio
			branchId
			status
			type
		}
		warehouseId
		cancellationWarehouseId
		externalFolio
		checkStatus
		cancellationCheckStatus
		comment
		discountPercentageMc
		discountPercentageTaxMc
        products{
			claveProdServ
			claveUnidad
			uuid
			type
			sku
			description
			objetoImp
			unit
			priceBaseTax
			quantity
			priceBaseTax
			priceTax
			priceBase
			price
			amountBase
			amount
			amountTax
			amountBaseTax
			additionalInfo
			comment
			unitPrice
			unitPriceTax
			unitPriceMc
			unitPriceTaxMc
			discount
			discountTax
			discountAmount
			discountAmountTax
			discountPercentage
            taxes{
				taxId
				name
				rate
				claveSat
				base
				total
				type
				tras
			}
		}
        taxesCfdi{
			taxId
			name
			rate
			type
			claveSat
			base
			total
			tras
		}
        receptor {
			uuid
			nombre
			rfc
			regimenFiscal
			usoCfdi
			codigoPostal
			breakdownIeps
			withholdTaxes
          address{
				reference
				state
				country
				district
				street
				extNumber
				intNumber
				county
				zipCode
				city
			}
		}
        emisor {
			rfc
			nombre
			regimenFiscal
			lugarExpedicion
          address{
				reference
				state
				country
				district
				street
				extNumber
				intNumber
				county
				zipCode
				city
			}
		}
        comprobante{
			version
			metodoDePago
			formaPago
			exportacion
			tipoDeComprobante
          timbre{
				version
				noCertificadoSAT
				selloCFD
				selloSAT
				uuid
				fechaTimbrado
			}
			codigo
			lugarExpedicion
			certificadoCsd
			tipoCambio
			cadenaOriginal
			fechaEmision
          basicGlobalInfo{
				periodicityKey
				monthKey
				year
			}
          impuestosLocales{
				version
				totaldeRetenciones
				totaldeTraslados
            trasladosLocales{
					impLocTrasladado
					tasadeTraslado
					importe
				}
            retencionesLocales{
					impLocRetenido
					tasadeRetencion
					importe
				}
			}
		}
        acuse{
			selloDigital
			fecha
		}
		recalculateMode
		cancellationRecalculateMode
	}
} `,eP=`${Et}${hi}`,NN=async(e,t,r=!0,n)=>{const a=Q5(r,n),s={operationName:"CreditsInfo",variables:{creditListFilter:e,agentUuid:e.agentUuid,timeZone:t},query:a};return J(_n,s,"application/json").then(i=>{if(console.log(i.data),i.data.errors)throw i.data.errors;const{list:o,nextPage:c}=i.data.data.creditListV2??{list:[],nextPage:null},u=i.data.data.overdueBalance;return{credits:o,offset:c??null,overdueBalance:u}}).catch(i=>{throw i!=null&&i.response?i.response:i})},BN=async e=>{const t={operationName:"DocumentReceptor",variables:{filter:e},query:W5};return J(`${Et}document-graph/v1/`,t,"application/json").then(r=>{if(r.data.errors)throw r.data.errors;return r.data.data.byIds})},kN=async e=>{const t={operationName:"DocumentReceptor",variables:{filter:e},query:Z5};return J(`${Et}document-graph/v1/`,t,"application/json").then(r=>{if(r.data.errors)throw r.data.errors;return r.data.data.byIds})},ON=async({uuid:e,timeZone:t="America/Mexico_City",decimals:r=2,serie:n,comment:a,mainIsoCurrency:s,isoCurrency:i="MXN",exchangeRate:o,opMode:c=Yy.MX,total:u,documentDate:l,agent:d,paymentId:h=Xy.CASH,cashRegisterUuid:p,creditPayments:f},g=1)=>{const y={uuid:e,timeZone:t,decimals:r,type:g===1?Id.CLIENTPAYMENT:Id.SUPPLIERPAYMENT,serie:n,comment:a,mainIsoCurrency:s,isoCurrency:i,exchangeRate:o,opMode:c,total:u,documentDate:l,agent:d,paymentId:h,cashRegisterUuid:p,creditPayments:f},b=g===1?`${Xg}/pay`:`${eP}/purchase/credit/payment`;return J(b,y).then(m=>m.data).catch(m=>{throw m.response})},Jy=async e=>Q(`${Et}cfdi/v1/payment/checkStatus/${e}`).then(t=>t.data).catch(t=>{throw t.response}),UN=async(e,t=10,r=5)=>{let n=0,a=null;for(;n<t;)try{if(await B0(r*1e3),a=await Jy(e),a.status==="ACTIVE")break;if(a.status==="FAILED")throw{response:{data:{errorCode:a.errorCode,errorMessage:a.errorMessage}}};if(n+1===t)throw{response:{data:{code:999,message:"Payment timeout"}}};n++}catch(s){throw(s==null?void 0:s.response)??s}return a},tP=async(e,t)=>jr(`${Et}cfdi/v1/stamp/cfdi40/cancel/check`,{uuid:e,documentType:"CFDI_PAGO"},{"COntent-Type":"application/json",...t?{"Set-Authorization":t}:{}}).then(r=>r.data).catch(r=>{throw r.response}),LN=async(e,t)=>{const{token:r,retries:n=10,delay:a=5}=t??{};let s=0;return jr(`${Et}cfdi/v1/stamp/cfdi40/payment`,e,{"Content-Type":"application/json",...r?{"Set-Authorization":r}:{}}).then(async i=>{let o=i.data;if(o.status==="PENDING")for(;s<n;){await B0(a*1e3);const c=await Jy(e.uuid);if(c.status==="ACTIVE"){o=c;break}if(c.status==="FAILED")throw{response:{data:{errorCode:c.errorCode,errorMessage:c.errorMessage}}};if(s++,s===n)throw{response:{data:{code:999,message:"Payment timeout"}}}}return o}).catch(i=>{throw i.response})},MN=async({branchId:e,uuid:t,cashRegisterUuid:r,comment:n,refund:a,token:s})=>{const i={branchId:e,uuid:t,cashRegisterUuid:r,comment:n,refund:a},o=s?{"Set-Authorization":s}:"";return jr(`${Xg}/cancel`,i,o).then(c=>c.data).catch(c=>{throw c.response})},jN=async({type:e=1,agentId:t})=>{const r={operationName:"CreditSummary",variables:{agentType:e===1?"CLIENT":"SUPPLIER",agentId:t},query:Y5};return J(`${dt}/catalogue/graphToSpecification`,r,"application/json").then(n=>{if(n.data.errors)throw n.data.errors;const{agentCreditDto:a}=n.data.data;return a})},FN=async({type:e=1,agentId:t,creditLimit:r,creditDays:n,blockCreditIfOverdue:a})=>{const s={agentType:e===1?"CLIENT":"SUPPLIER",agentId:t,creditLimit:r,creditDays:n,blockCreditIfOverdue:a};return J(`${dt}/credit/list/agent`,s).then(i=>i).catch(i=>{throw i})},qN=async(e,t,r=1,n)=>{const a=sr.diff(e,t,{invertible:!1});if(!a.length)return;const s=[`${dt}/credit/list/agent/${r===1?"CLIENT":"SUPPLIER"}/${t.agentId}`,a];return(n==null?$e.patch(...s):$e.patch(...s,{headers:{"Content-Type":"application/json;charset=UTF-8","Set-Authorization":`${n}`}})).then(i=>i).catch(i=>{throw i})},HN=async e=>{const t=`${Et}pdf/v1/pdf/cfdi/payment/${e}`;return Q(t).then(r=>r.data).catch(r=>{throw r.response})},KN=async e=>{const t=`${Et}cfdi/v1/payment/xml/${e}`;return Q(t).then(r=>r.data).catch(r=>{throw r.response})},VN=async e=>{const t=X5,r={operationName:"CfdiPayment",variables:{...e},query:t};return J(`${Et}document-graph/v1/`,r,"application/json").then(n=>{if(n.data.errors)throw n.data.errors;return n.data.data.generated}).catch(n=>{throw n})},zN=async(e,t)=>{const{delay:r=5,retries:n=10,token:a}=t??{};let s=0;const i=`${Et}cfdi/v1/stamp/cfdi40/cancel`;return jr(i,e,{"Content-Type":"application/json",...a?{"Set-Authorization":a}:{}}).then(async o=>{let c=o.data;if(c.cancelStatus==="PENDING")for(;s<n;){await B0(r*1e3);const u=await tP(e.uuid,a);if(u.status==="CANCELED"){c=u;break}if(s+1===n)throw{response:{data:{code:999,message:"Cancellation timeout"}}};s++}return c}).catch(o=>{throw o.response})},GN=async({objectId:e,branchId:t})=>{const r={operationName:"CanceledCfdiPayment",variables:{objectId:e,branchId:t},query:J5};return J(`${Et}document-graph/v1/`,r,"application/json").then(n=>n.data.data.generated).catch(n=>n.response)},QN=async e=>Q(`${Et}cfdi/v1/payment/acuse/${e}`).then(t=>t.data).catch(t=>{throw t.response}),B0=e=>new Promise(t=>setTimeout(t,e)),rP=e=>new Promise((t,r)=>{Re(we+"/printService",e).then(n=>{t(n)}).catch(n=>{r(n)})}),nP=(e,t)=>new Promise((r,n)=>{ze(we+"/printService/edit?printServiceId="+e,{active:t}).then(a=>{r(a)}).catch(a=>{n(a)})}),aP=e=>new Promise((t,r)=>{ft(we+"/printService?printServiceId="+e).then(n=>{t(n)}).catch(n=>{r(n)})}),sP=(e,t)=>new Promise((r,n)=>{ze(we+"/printService/addQueue?printServiceId="+e,t).then(a=>{r(a)}).catch(a=>{n(a)})}),iP=(e,t)=>new Promise((r,n)=>{ze(we+"/printService/removeQueue?printServiceId="+e,t).then(a=>{r(a)}).catch(a=>{n(a)})}),oP=e=>{const t=new pe(`
        printService(id:"${e}") {
            id
            name
            queues {
                id
                documentType
                docId
                module
                created
            }
        }`).build();return new Promise((r,n)=>{J(tm,t,"application/graphql").then(a=>{r(pe.unwrap(a))}).catch(a=>{n(a)})})},cP=()=>{const e=new pe(`
        printServicesByBranch {
            id
            name
            active
        }`).build();return new Promise((t,r)=>{J(tm,e,"application/graphql").then(n=>{t(pe.unwrap(n))}).catch(n=>{r(n)})})},uP=e=>{const t=new pe(`
        generatedV2(
            objectId:"${e}"
        ) {
            id
            uuid
            type
            serie
            folio
            creationDate
            documentDate
            timeZone
            withholdingTax
            userUuid
            userAlias
            cashRegisterUuid
            expirationDate
            cancellationUserAccount
            cancellationUserUuid
            cancellationUserAlias
            cancellationDate
            cancellationComment
            payments{
                cashRegisterUuid
                paymentId
                amount
                comment
                isoCurrency
                exchangeRate
                convertedAmount
            }
            agent {
                uuid
                name
                withholdTaxes      
                address{
                    city
                    country
                    district
                    extNumber
                    intNumber
                    state
                    street
                    zipCode
                },
                phoneNumbers {
                    phoneCode
                    phoneNumber
                    phoneType
                }  
            }
            employee {
                uuid
                name
                email
                position
                phoneNumbers {
                    phoneCode
                    phoneNumber
                    phoneType
                }  
            }
            total
            mainIsoCurrency
            isoCurrency
            status,
            exchangeRate
            warehouseId
            externalFolio
            comment
            rps
            rpsCommission
            rpsInvoice
            rpsResponse{
                transactionId
                transactionDate
                posTransactionId
                legalInformation
                providerAuthorization
                reference1Name
                reference2Name
                reference3Name
                reference1
                reference2
                reference3
                responseCode
                responseMessage
                success
                errorCode
                errorMessage
            }
            creditDueDate
            change{
                paymentId
                amount
                isoCurrency
                exchangeRate
                convertedAmount
            }
            products{
                uuid
                type
                sku
                description
                unit
                quantity
                originPriceBaseTax
                priceBaseTax
                priceBaseTaxConv
                priceTax
                priceTaxConv
                priceBase
                priceBaseConv
                price
                priceConv
                amountBase
                amount
                amountTax
                originAmountTax
                amountBaseTax
                additionalInfo
                comment
                unitPrice
                unitPriceTax
                unitPriceMc
                unitPriceTaxMc
                discount
                discountTax
                discountAmount
                discountAmountTax
                discountPercentage
                edited
                separator
                departmentId
                categoryId
                taxes{
                    taxId
                    name
                    rate
                    claveSat
                    base
                    total
                    type
                    tras
                }
                lot
                lots{
                    lotNumber
                    quantity
                    expirationDate
                }
            }
            childDocs{
                id
                uuid
                status
            }
            sourceModule
            groupId
            zoneId
            groupName
            groupType
        }`).build();return new Promise((r,n)=>{J(ra,t,"application/graphql").then(a=>{r(pe.unwrap(a))}).catch(a=>{n(a)})})},WN=Object.freeze(Object.defineProperty({__proto__:null,activeServer:nP,addQueue:sP,createServer:rP,deleteServer:aP,getPrintDocumentId:uP,getPrintService:oP,getServerList:cP,removeQueue:iP},Symbol.toStringTag,{value:"Module"})),ZN=async({type:e=1,id:t,name:r})=>{const n={agentType:e===1?"CLIENT":"SUPPLIER",id:t,name:r};return J(`${dt}/credit/list`,n).then(a=>a.data)},YN=async({type:e=1})=>Q(`${dt}/credit/list/all/assigned?agentType=${e===1?"CLIENT":"SUPPLIER"}`).then(t=>t.data).catch(t=>{throw t.response}),XN=async({type:e=1,creditListId:t},r)=>{const n=e===1?"CLIENT":"SUPPLIER";return r?ze(`${dt}/credit/list/assigned/${n}/${t}`,{}).then(a=>a.data).catch(a=>{throw a.response}):J(`${dt}/credit/list/assigned/${n}/${t}`,{}).then(a=>a.data).catch(a=>{throw a.response})},JN=async({type:e=1})=>{const t=e===1?"CLIENT":"SUPPLIER",r=`query { 
		assignedCreditList(agentType: "${t}") {
			creditListId
		}
		allAssignedCreditListBranches(agentType: "${t}") {
			creditListId
    		creditListName
    		branchLiteList {
				alias
				id
				name
			}
		}
	}`;return J(`${dt}/catalogue/graphToSpecification`,r,"application/graphql").then(n=>n.data).catch(n=>{throw n.response})},lP="cfdi/v1",lc=`${Et}${lP}`,eB=async()=>Q(`${lc}/chip/list`).then(e=>(console.log(e),e.status===204?[]:e.data)).catch(e=>{throw e.response}),tB=async e=>{const t={name:e,uuid:crypto.randomUUID(),type:"TIMBRES"};return J(`${lc}/chip`,t).then(r=>r.data).catch(r=>{throw r.response})},rB=async()=>Q(`${lc}/chip/default`).then(e=>e.data).catch(e=>{throw e.response}),nB=async e=>Re(`${lc}/chip/configure/${e}`).then(t=>t.data).catch(t=>{throw t.response}),aB=async e=>$e.post("https://us-central1-sx-production.cloudfunctions.net/chips-report",e,{responseType:"blob"}).then(t=>t.status===204?null:t.data).catch(t=>{throw t.response}),dc="image/v1/image",sB=(e,t)=>J(`${dc}/select/${e}/${t}`,"").catch(r=>Promise.reject(r.response)),iB=(e,t)=>J(`${dc}/remove/${e}`,t),oB=(e,t,r="image/png",n,a)=>J(`${dc}/signUrl`,{productUuid:e,imageUuid:t,contentType:r,contentLength:n,selected:!!a}),cB=(e,t)=>J(`${dc}/url/${e}`,t),uB=(e,t,r,n,a)=>Rt.put(e,t,{headers:{"Content-Type":t.type,"x-amz-meta-content-id":a,"x-amz-meta-product-id":r,"x-amz-meta-selected":n?"true":"false"}}),dP="feedback/v1/feedback",lB=e=>J(dP,e),hP="store/order",dB=(e,t)=>new Promise((r,n)=>{uE(`${hP}/${e}`,"application/json;charset=UTF-8",t).then(a=>{r(a)}).catch(a=>{n(a)})}),hB=async(e,t)=>{const r={variables:{branchId:t,uuid:e,type:"SALE"},query:`query Transaction($branchId: Long, $uuid: String!, $type: String!){
        transactions(
            branchId: $branchId,
            uuid: $uuid,
            type: $type
        ) {
            branchId
            cashRegisterUuid
            uuid
            date
            paymentId
            amount
            isoCurrency
            exchangeRate
            convertedAmount
            type
            userUuid
            operationType
            documents {
                branchId
                uuid
                date
                type
                serieFolio
                isoCurrency
                origin
                childDocs {
                    id
                    branchId
                    type
                    status
                    serieFolio
                    uuid
                }
            }
        }
    }`,operationName:"Transaction"};return J(`${Et}document-graph/v1/`,r,"application/json").then(n=>({status:200,data:n.data.data.transactions??[]})).catch(n=>n.response)},pB=e=>new Promise((t,r)=>{ze(`${hi}/sale/edit/seller`,e).then(n=>{t(n)}).catch(n=>{r(n.response)})}),fB=e=>new Promise((t,r)=>{ze(`${hi}/sale/edit/comment`,e).then(n=>{t(n)}).catch(n=>{r(n.response)})}),gB=e=>{const t=e.token?{"Set-Authorization":e.token}:"";return new Promise((r,n)=>{$e.post(`${hi}/sale/cancel`,e,{headers:{"Content-Type":"application/json;charset=UTF-8",...t}}).then(a=>{r(a)}).catch(a=>{n(a.response)})})},mB=e=>Q(`${hi}/sale/checkStatus/${e}`),yB=e=>new Promise((t,r)=>{var n,a,s,i,o;Q(`${gs}/list?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&folio=${e.folio}${((n=Object.keys(e.isoCurrency))==null?void 0:n.length)>0?`&isoCurrency=${(a=e.isoCurrency)==null?void 0:a.iso}`:""}${((s=Object.keys(e.cashRegister))==null?void 0:s.length)>0?`&cashRegisterUuid=${e.cashRegister.uuid}`:""}${((i=Object.keys(e.user))==null?void 0:i.length)>0?`&userUuid=${e.user.uuid}`:""}${((o=Object.keys(e.balanceDiff))==null?void 0:o.length)>0?`&balanceDiff=${e.balanceDiff.uuid}`:""}`).then(c=>{t(c)}).catch(c=>{r(c)})}),vB=e=>new Promise((t,r)=>{Q(`${gs}/list/nextPage?offset=${e}`).then(n=>{t(n)}).catch(n=>{r(n.response)})}),bB=(e,t)=>new Promise((r,n)=>{Q(`${gs}/${e}/${t}`).then(a=>{r(a)}).catch(a=>{n(a.response)})}),CB=(e,t,r,n)=>new Promise((a,s)=>{Q(`${gs}/transactions/${e}/${t}/${r}${n===void 0?"":`/${n}`}`).then(i=>{a(i)}).catch(i=>{s(i.response)})}),SB=(e,t,r,n,a)=>new Promise((s,i)=>{Q(`${gs}/transactions/${e}/${t}/${r}${n===void 0?"":`/${n}`}?offset=${a}`).then(o=>{s(o)}).catch(o=>{i(o.response)})}),EB=(e,t,r,n)=>new Promise((a,s)=>{Q(`${gs}/resume/${e}/${t}/${r}${n===void 0?"":`/${n}`}`).then(i=>{a(i)}).catch(i=>{s(i.response)})}),xB=()=>new Promise((e,t)=>{vs(`${_a}/balance/list`).then(r=>{e(r)}).catch(r=>{t(r.response)})}),wB=e=>new Promise((t,r)=>{vs(`${_a}/balance/${e}`).then(n=>{t(n)}).catch(n=>{r(n.response)})}),TB=(e,t,r)=>new Promise((n,a)=>{vs(`${_a}/transactions/${e}/${t}${r===void 0?"":`/${r}`}`).then(s=>{n(s)}).catch(s=>{a(s.response)})}),$B=(e,t,r,n)=>new Promise((a,s)=>{vs(`${_a}/transactions/${e}/${t}${r===void 0?"":`/${r}`}?offset=${n}`).then(i=>{a(i)}).catch(i=>{s(i.response)})}),AB=(e,t,r)=>new Promise((n,a)=>{Q(`${_a}/resume/${e}/${t}${r===void 0?"":`/${r}`}`).then(s=>{n(s)}).catch(s=>{a(s.response)})}),IB=e=>new Promise((t,r)=>{Re(`${Rr}/operations/period/request`,e).then(t).catch(r)}),PB=()=>new Promise((e,t)=>{ft(`${Rr}/operations/period/request`).then(e).catch(t)}),_B=e=>new Promise((t,r)=>{J(`${Rr}/stamp/cfdi40/period/exec/async`,e).then(t).catch(r)}),DB=e=>new Promise((t,r)=>{Q(`${Rr}/checkStatus/${e}`).then(t).catch(r)}),RB=(e,t)=>new Promise((r,n)=>{J(`${Rr}/stamp/cfdi40/cancel/check`,{uuid:e,documentType:"CFDI_INGRESO"}).then(r).catch(n)}),NB=e=>{const t=e.token?{"Set-Authorization":e.token}:"";return new Promise((r,n)=>{$e.post(`${Rr}/stamp/cfdi40/exec/async`,e,{headers:{"Content-Type":"application/json;charset=UTF-8",...t}}).then(a=>{r(a)}).catch(a=>{n(a.response)})})},BB=e=>new Promise((t,r)=>{Q(`${Rr}/xml/${e}`).then(n=>{t(n)}).catch(n=>{r(n.response)})}),kB=e=>new Promise((t,r)=>{Q(`${Rr}/acuse/${e}`).then(n=>{t(n)}).catch(n=>{r(n.response)})}),OB=e=>{const t=e.token?{"Set-Authorization":e.token}:"";return new Promise((r,n)=>{$e.post(`${Rr}/stamp/cfdi40/cancel`,e,{headers:{"Content-Type":"application/json;charset=UTF-8",...t}}).then(a=>{r(a)}).catch(a=>{n(a.response)})})},UB=()=>new Promise((e,t)=>{Q(`${Rr}/catalogue/periodicity`).then(e).catch(t)}),LB=e=>new Promise((t,r)=>{Q(`${Rr}/catalogue/period/months?bimonthly=${e}`).then(t).catch(r)}),MB=e=>new Promise((t,r)=>{Q(`${fs}/pdf/cfdi/ingress/${e}`).then(t).catch(r)}),jB=e=>new Promise((t,r)=>{Q(`${fs}/pdf/cfdi/acuse/${e}`).then(t).catch(r)}),FB=()=>new Promise((e,t)=>{Q(`${Rr}/chip/default`).then(r=>{e(r)}).catch(r=>{t(r)})}),qB=(e,t,r,n,a="",s="",i="",o="",c="",u="",l="",d=void 0,h="",p,f)=>{let g=`{
        documentType: QUOTATION,
        startDate: "${e}",
        endDate: "${t}",
        timeZone: "${r}",
        dateField: ${n},
        ${h?`search:"${h}"`:""}
        ${a?`agentUuid:"${a}"`:""}
        ${s?`sellerUuid:"${s}"`:""}
        ${i?`userUuid:"${i}"`:""}
        ${o?`serie:"${o}"`:""}
        ${c?`status:${c}`:""}
        ${u?`isoCurrency:"${u}"`:""}
        ${l?`productUuid:"${l}"`:""}
        ${d?`discount:"${d}"`:""}
        ${p?`hasChildDocs:${p}`:""}
        limit: 20
        pageNumber: ${f||0}
    }`;const y=new pe(`
        documentListV2(
            documentFilter: ${g}
        ) {
            list{
                id
                uuid
                serie
                folio
                creationDate
                documentDate
                timeZone
                userAlias
                userAccount
                expirationDate
                parentDocs{
                    id
                    status
                }
                agent {
                    uuid
                    name
                }
                employee{
                    uuid
                    name
                }
                cancellationDate
                cancellationUserUuid
                cancellationUserAccount
                isoCurrency
                withholdingTax
                userUuid
                childDocs{
                    id
                    status
                }
                total
                status
            },
            nextPage
        }`).build();return new Promise((b,m)=>{J(ra,y,"application/graphql").then(v=>b(pe.unwrap(v))).catch(v=>{m(v)})})},HB=e=>{const t=new pe(`
        generatedV2(
            objectId:"${e}"
        ) {
            id
            branchId
            uuid
            type
            decimals
            serie
            mainIsoCurrency
            isoCurrency
            exchangeRate
            total
            totalMc
            folio
            serieFolio
            creationDate
            documentDate
            timeZone
            opMode
            status
            discount
            discountMc
            discountTax
            discountPercentage
            discountPercentageMc
            discountPercentageTax
            discountPercentageTaxMc
            expirationDate
            withholdingTax
            warehouseId
            comment
            agent {
                uuid
                name
                priceNumber
                withholdTaxes      
                address{
                    city
                    country
                    district
                    extNumber
                    intNumber
                    state
                    street
                    zipCode
                },
                phoneNumbers {
                    phoneCode
                    phoneNumber
                    phoneType
                }  
            }
            employee {
                uuid
                name
            }
            products{
                uuid
                type
                sku
                description
                unit
                quantity
                priceBaseTax
                priceBaseTaxConv
                priceTax
                priceTaxConv
                priceBase
                priceBaseConv
                price
                priceConv
                amountBase
                amount
                amountTax
                amountBaseTax
                additionalInfo
                comment
                unitPrice
                unitPriceTax
                unitPriceMc
                unitPriceTaxMc
                discount
                discountTax
                discountAmount
                discountAmountTax
                discountPercentage
                originPriceBaseTax
                originAmountTax
                taxes{
                    taxId
                    name
                    rate
                    claveSat
                    base
                    total
                    type
                    tras
                }
            }
        }`).build();return new Promise((r,n)=>{J(ra,t,"application/graphql").then(a=>r(pe.unwrap(a))).catch(a=>{n(a)})})},KB=e=>new Promise((t,r)=>{Rt.get(`${e}`).then(n=>{t(n)}).catch(n=>{r(n.response)})}),VB=async(e,t)=>{const r={variables:{branchId:t,uuid:e,type:"PURCHASE"},query:`query Transaction($branchId: Long, $uuid: String!, $type: String!){
        transactions(
            branchId: $branchId,
            uuid: $uuid,
            type: $type
        ) {
            branchId
            cashRegisterUuid
            uuid
            date
            paymentId
            amount
            isoCurrency
            exchangeRate
            convertedAmount
            type
            userUuid
            operationType
            documents {
                branchId
                uuid
                date
                type
                serieFolio
                isoCurrency
                origin
                childDocs {
                    id
                    branchId
                    type
                    status
                    serieFolio
                    uuid
                }
            }
        }
    }`,operationName:"Transaction"};return J(`${Et}document-graph/v1/`,r,"application/json").then(n=>({status:200,data:n.data.data.transactions??[]})).catch(n=>n.response)},zB=e=>{const t=e.token?{"Set-Authorization":e.token}:"";return new Promise((r,n)=>{$e.post("/documents/v1/purchase/cancel",e,{headers:{"Content-Type":"application/json;charset=UTF-8",...t}}).then(a=>{r(a)}).catch(a=>{n(a.response)})})},GB=e=>Q(`${VC}/migration/metadata/generated/signedUrl?${new URLSearchParams({uuid:e.uuid,type:e.type,branchId:String(e.branchId),contentId:String(e.contentId)})}`),QB=e=>{var t,r,n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m;const v=new pe(`
      documentListV2(
        documentFilter: {
          documentType: SALE,
          startDate: "${e.startDate}",
          endDate: "${e.endDate}",
          timeZone: "${e.timeZone}",
          dateField: ${e.dateField},
          search: "${e.search}",
          ${((t=Object.keys(e.user))==null?void 0:t.length)>0?`userUuid:"${e.user.uuid}"`:""}
          ${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`agentUuid:"${(n=e.agent)==null?void 0:n.uuid}"`:""}
          ${((a=Object.keys(e.seller))==null?void 0:a.length)>0?`employeeUuid:"${e.seller.uuid}"`:""}
          ${((s=Object.keys(e.serie))==null?void 0:s.length)>0?`serie:"${e.serie.uuid}"`:""}
          ${((i=Object.keys(e.status))==null?void 0:i.length)>0?`status:${e.status.uuid}`:""}
          ${((o=Object.keys(e.isoCurrency))==null?void 0:o.length)>0?`isoCurrency:"${e.isoCurrency.iso}"`:""}
          ${((c=Object.keys(e.product))==null?void 0:c.length)>0?`productUuid:"${e.product.uuid}"`:""}
          ${((u=Object.keys(e.paymentOption))==null?void 0:u.length)>0?`paymentId:"${e.paymentOption.uuid}"`:""}
          ${((l=Object.keys(e.cashRegister))==null?void 0:l.length)>0?`cashRegisterUuid:"${e.cashRegister.uuid}"`:""}
          ${((d=Object.keys(e.discount))==null?void 0:d.length)>0?`discount:${e.discount.uuid}`:""}
          ${((h=Object.keys(e.hasChildDocs))==null?void 0:h.length)>0?`hasChildDocs:${e.hasChildDocs.uuid}`:""}
          ${((p=Object.keys(e.childDocsType))==null?void 0:p.length)>0?`childDocsType:${e.childDocsType.uuid}`:""}
          ${((f=Object.keys(e.creditStatus))==null?void 0:f.length)>0?`creditStatus:${e.creditStatus.uuid}`:""}
          ${((g=Object.keys(e.invoiced))==null?void 0:g.length)>0?`invoiced:${(y=e==null?void 0:e.invoiced)==null?void 0:y.uuid}`:""}
          ${((b=Object.keys(e.cfdiCancelStatus))==null?void 0:b.length)>0?`cfdiCancelStatus:"${e.cfdiCancelStatus.uuid}"`:""}
          ${((e==null?void 0:e.warehouse)??[]).length>0?`warehouseId:"${(m=((e==null?void 0:e.warehouse)??[])[0])==null?void 0:m.uuid}"`:""}
          limit: 20
          pageNumber: ${e.page}
        }
      ) {
        list {
            id
            uuid
            userUuid
            serie
            folio
            serieFolio
            comprobante {
              impuestosLocales{
                totaldeRetenciones
                retencionesLocales{
                  impLocRetenido
                  tasadeRetencion
                  importe
                }
              }
            }
            agent{
              uuid
              name
              withholdTaxes
            }
            discountPercentageTax
            creationDate
            documentDate
            discount
            isoCurrency
            creditBalance
            creditDueDate
            cancellationDate
            employee {
              uuid
              name
            }
            withholdingTax
            childDocs {
              id
              branchId
              type
              uuid
              serieFolio
              status
            }
            cfdiCancelStatus
            cancellationUserUuid
            total
            status
            restaurantBill
            payments {
              paymentId
            }
        },
        nextPage
      }
`).build();return new Promise((S,C)=>{$e.post(`${Et}${_n}`,v,{transformResponse:[E=>hr(E)],headers:{"Content-Type":"application/graphql"}}).then(E=>S(pe.unwrap(E))).catch(E=>{C(E)})})},WB=e=>{var t,r,n,a,s,i,o,c,u,l,d,h;const p=new pe(`
      documentListV2(
        documentFilter: {
          documentType: PURCHASE,
          startDate: "${e.startDate}",
          endDate: "${e.endDate}",
          timeZone: "${e.timeZone}",
          dateField: ${e.dateField},
          search: "${e.search}",
          ${((t=Object.keys(e.user))==null?void 0:t.length)>0?`userUuid:"${e.user.uuid}"`:""}
	        ${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`agentUuid:"${(n=e.agent)==null?void 0:n.uuid}"`:""}
          ${((a=Object.keys(e.status))==null?void 0:a.length)>0?`status:${e.status.uuid}`:""}
          ${((s=Object.keys(e.isoCurrency))==null?void 0:s.length)>0?`isoCurrency:"${e.isoCurrency.iso}"`:""}
          ${((i=Object.keys(e.product))==null?void 0:i.length)>0?`productUuid:"${e.product.uuid}"`:""}
          ${((o=Object.keys(e.paymentOption))==null?void 0:o.length)>0?`paymentId:"${e.paymentOption.uuid}"`:""}
          ${((c=Object.keys(e.cashRegister))==null?void 0:c.length)>0?`cashRegisterUuid:"${e.cashRegister.uuid}"`:""}
          ${((u=Object.keys(e.discount))==null?void 0:u.length)>0?`discount:${e.discount.uuid}`:""}
          ${((l=Object.keys(e.checkStatusPricesFilter))==null?void 0:l.length)>0?`checkStatus:${e.checkStatusPricesFilter.uuid}`:""}
          ${((d=Object.keys(e.cancelationCheckStatusPricesFilter))==null?void 0:d.length)>0?`cancellationCheckStatus:${e.cancelationCheckStatusPricesFilter.uuid}`:""}
          ${((e==null?void 0:e.warehouse)??[]).length>0?`warehouseId:"${(h=((e==null?void 0:e.warehouse)??[])[0])==null?void 0:h.uuid}"`:""}
          limit: 20
          pageNumber: ${e.page}
        }
      ) {
        list {
            id
            uuid
            userUuid
            serie
            folio
            serieFolio
            externalFolio
            agent{
              uuid
              name
              alias
            }
            discountPercentageTax
            creationDate
            documentDate
            discount
            discountTax
            isoCurrency
            cancellationDate
            employee {
              uuid
              name
            }
            emisor{
              nombre
              rfc
            }
            invoiceUuid
            externalFolio
            cancellationUserUuid
            total
            status
            checkStatus
            cancellationCheckStatus
        },
        nextPage
      }
    
`).build();return new Promise((f,g)=>{$e.post(`${Et}${_n}`,p,{transformResponse:[y=>hr(y)],headers:{"Content-Type":"application/graphql"}}).then(y=>f(pe.unwrap(y))).catch(y=>{g(y)})})},ZB=e=>{var t,r,n,a,s,i,o,c,u,l,d,h,p,f,g;const y=new pe(`
      documentListV2(
        documentFilter: {
          documentType: CFDI_INGRESO,
          startDate: "${e.startDate}",
          endDate: "${e.endDate}",
          timeZone: "${e.timeZone}",
          dateField: ${e.dateField},
          search: "${e.search}",
          ${((t=Object.keys(e.user))==null?void 0:t.length)>0?`userUuid:"${e.user.uuid}"`:""}
          ${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`agentUuid:"${(n=e.agent)==null?void 0:n.uuid}"`:""}
          ${((a=Object.keys(e.seller))==null?void 0:a.length)>0?`employeeUuid:"${e.seller.uuid}"`:""}
          ${((s=Object.keys(e.serie))==null?void 0:s.length)>0?`serie:"${e.serie.uuid}"`:""}
          ${((i=Object.keys(e.status))==null?void 0:i.length)>0?`status:${e.status.uuid}`:""}
          ${((o=Object.keys(e.isoCurrency))==null?void 0:o.length)>0?`isoCurrency:"${e.isoCurrency.iso}"`:""}
          ${((c=Object.keys(e.product))==null?void 0:c.length)>0?`productUuid:"${e.product.uuid}"`:""}
          ${((u=Object.keys(e.paymentOption))==null?void 0:u.length)>0?`paymentId:"${e.paymentOption.uuid}"`:""}
          ${((l=Object.keys(e.cashRegister))==null?void 0:l.length)>0?`cashRegisterUuid:"${e.cashRegister.uuid}"`:""}
          ${((d=Object.keys(e.discount))==null?void 0:d.length)>0?`discount:${e.discount.uuid}`:""}
          ${((h=Object.keys(e.hasChildDocs))==null?void 0:h.length)>0?`hasChildDocs:"${e.hasChildDocs.uuid}"`:""}
          ${((p=Object.keys(e.creditStatus))==null?void 0:p.length)>0?`creditStatus:${e.creditStatus.uuid}`:""}
          ${((f=Object.keys(e.cfdiCancelStatus))==null?void 0:f.length)>0?`cfdiCancelStatus:"${e.cfdiCancelStatus.uuid}"`:""}
          ${((e==null?void 0:e.warehouse)??[]).length>0?`warehouseId:"${(g=((e==null?void 0:e.warehouse)??[])[0])==null?void 0:g.uuid}"`:""}
          limit: 20
          pageNumber: ${e.page}
        }
      ) {
        list {
            id
            uuid
            userUuid
            serie
            folio
            serieFolio
            agent{
              uuid
              name
              withholdTaxes
            }
            creationDate
            documentDate
            isoCurrency
            cancellationDate
            parentDocs{
              uuid
              serieFolio
              branchId
              status
              type
            }
            receptor {
              nombre
              rfc
              invoiceUuid
            }
            global
            cfdiCancelStatus
            cancellationUserUuid
            total
            status
            withholdingTax
        },
        nextPage
      }
    
`).build();return new Promise((b,m)=>{$e.post(`${Et}${_n}`,y,{transformResponse:[v=>hr(v)],headers:{"Content-Type":"application/graphql"}}).then(v=>b(pe.unwrap(v))).catch(v=>{m(v)})})},YB=e=>{const t=new pe(`
      generatedV2(
        objectId:"${e.id}"
        branchId:"${e.branchId}"
      ) {
        uuid
        type
        serie
        folio
        creationDate
        documentDate
        timeZone
        userAccount
        userUuid
        userAlias
        withholdingTax
        cfdiPaymentMethod
        agent {
          uuid
          name      
        address{
          city
          country
          district
          extNumber
          intNumber
          state
          street
          zipCode
        },
        phoneNumbers {
          phoneCode
          phoneNumber
          phoneType
        }  
        }
        employee {
          uuid
          name
        }
        total
        mainIsoCurrency
        isoCurrency
        status,
        payments{
          paymentId
          amount
          isoCurrency
          convertedAmount
          exchangeRate
        }
        childDocs {
          id
          branchId
          type
          uuid
          serieFolio
          status
        }
        uninvoicedPayment{
          ids
        }
        cancellationDate
        cancellationUserAccount
        cancellationUserAlias
        cancellationUserUuid
        cancellationComment
        cashRegisterUuid
        discount
        discountTax
        discountPercentage
        discountPercentageTax
        subtotal
        subtotalGeneral
        cost
        costTax
        profit
        profitTax
        exchangeRate
        subtotalMc
        subtotalGeneralMc
        discountMc
        discountTaxMc
        costMc
        costTaxMc
        profitMc
        profitTaxMc
        totalMc
        profitMargin
        profitPercentage
        profitMarginTax
        profitPercentageTax
        parentDocs{
          id
          uuid
          serieFolio
          branchId
          status
          type
        }
        warehouseId
        cancellationWarehouseId
        expirationDate
        creditDueDate
        creditStatus
        creditBalance
        creditBalanceMc
        creditPayments
        creditPaymentsMc
        externalFolio
        rps
        rpsCommission
        rpsInvoice
        comment
        discountPercentageMc
        discountPercentageTaxMc
        products{
            uuid
            type
            sku
            description
            unit
            priceBaseTax
            quantity
            priceBaseTax
            priceTax
            priceBase
            price
            amountBase
            amount
            amountTax
            amountBaseTax
            additionalInfo
            comment
            unitPrice
            unitPriceTax
            unitPriceMc
            unitPriceTaxMc
            discount
            discountTax
            discountAmount
            discountAmountTax
            discountPercentage
            taxes{
              taxId
              name
              rate
              claveSat
              base
              total
              type
              tras
            }
              lots{
                lotNumber
                quantity
                fabricationDate
                expirationDate
              }
        }
        taxesCfdi{
          taxId
          name
          rate
          type
          claveSat
          base
          tras
          total
        }
        change{
          paymentId
          amount
          isoCurrency
          exchangeRate
          convertedAmount
        }
        rpsResponse{
          transactionId
          transactionDate
          posTransactionId
          legalInformation
          providerAuthorization
          reference1Name
          reference2Name
          reference3Name
          reference1
          reference2
          reference3
          responseCode
          responseMessage
          success
          errorCode
          errorMessage
        }
        table{
          groupId
          zoneId
          groupName
          groupType
        }
        prescription{
          doctorId
          doctorName
          prescriptionFolio
          observations
          retained
        }
        sourceModule
        withholdingProds
        restaurantBill
      }
`).build();return new Promise((r,n)=>{$e.post(`${Et}${_n}`,t,{transformResponse:[a=>hr(a)],headers:{"Content-Type":"application/graphql"}}).then(a=>r(pe.unwrap(a))).catch(a=>{n(a)})})},XB=e=>{const t=new pe(`
      generatedV2(
        objectId:"${e.id}"
        branchId:"${e.branchId}"
      ) {
        uuid
        type
        serie
        folio
        creationDate
        documentDate
        timeZone
        userAccount
        userUuid
        userAlias
        emisor {
          rfc
          nombre
        }
        agent {
          uuid
          name
          alias      
        address{
          city
          country
          district
          extNumber
          intNumber
          state
          street
          zipCode
        },
        phoneNumbers {
          phoneCode
          phoneNumber
          phoneType
        }  
        }
        total
        mainIsoCurrency
        isoCurrency
        status,
        payments{
          paymentId
          cashRegisterUuid
          amount
          comment
          isoCurrency
          exchangeRate
          convertedAmount
        }
        cancellationDate
        cancellationUserAccount
        cancellationUserAlias
        cancellationUserUuid
        cancellationComment
        cashRegisterUuid
        discount
        discountTax
        discountPercentage
        discountPercentageTax
        subtotal
        subtotalGeneral
        exchangeRate
        subtotalMc
        subtotalGeneralMc
        discountMc
        discountTaxMc
        totalMc
        profitMargin
        
        parentDocs{
          uuid
          serieFolio
          branchId
          status
          type
        }
        warehouseId
        cancellationWarehouseId
        externalFolio
        checkStatus
        cancellationCheckStatus
        comment
        discountPercentageMc
        discountPercentageTaxMc
        products{
            uuid
            type
            sku
            description
            unit
            priceBaseTax
            quantity
            priceBaseTax
            priceTax
            priceBase
            price
            amountBase
            amount
            amountTax
            amountBaseTax
            additionalInfo
            comment
            unitPrice
            unitPriceTax
            unitPriceMc
            unitPriceTaxMc
            discount
            discountTax
            discountAmount
            discountAmountTax
            discountPercentage
            taxes{
              taxId
              name
              rate
              claveSat
              base
              total
              type
              tras
            }
            lots{
                lotNumber
                quantity
                fabricationDate
                expirationDate
            }
        }
        taxesCfdi{
          taxId
          name
          rate
          type
          claveSat
          base
          total
        }
        recalculateMode
        cancellationRecalculateMode
      }
    
`).build();return new Promise((r,n)=>{$e.post(`${Et}${_n}`,t,{transformResponse:[a=>hr(a)],headers:{"Content-Type":"application/graphql"}}).then(a=>r(pe.unwrap(a))).catch(a=>{n(a)})})},JB=e=>{const t=new pe(`
      generatedV2(
        objectId:"${e.id}"
        branchId:"${e.branchId}"
      ) {
        uuid
        type
        serie
        folio
        creationDate
        documentDate
        timeZone
        userAccount
        userUuid
        userAlias
        agent {
          uuid
          name
          alias      
        address{
          city
          country
          district
          extNumber
          intNumber
          state
          street
          zipCode
        },
        phoneNumbers {
          phoneCode
          phoneNumber
          phoneType
        }  
        }
        cfdiCancelStatus
        total
        mainIsoCurrency
        isoCurrency
        status,
        payments{
          paymentId
          cashRegisterUuid
          amount
          comment
          isoCurrency
          exchangeRate
          convertedAmount
        }
        childDocs {
          id
          branchId
          type
          uuid
          serieFolio
          status
        }
        global
        cancellationDate
        cancellationUserAccount
        cancellationUserAlias
        cancellationUserUuid
        cancellationComment
        cashRegisterUuid
        discount
        discountTax
        discountPercentage
        discountPercentageTax
        subtotal
        subtotalGeneral
        exchangeRate
        subtotalMc
        subtotalGeneralMc
        discountMc
        discountTaxMc
        totalMc
        profitMargin
        parentDocs{
          id
          uuid
          serieFolio
          branchId
          status
          type
        }
        warehouseId
        cancellationWarehouseId
        externalFolio
        checkStatus
        cancellationCheckStatus
        comment
        discountPercentageMc
        discountPercentageTaxMc
        products{
            claveProdServ
            claveUnidad
            uuid
            type
            sku
            description
            objetoImp
            unit
            priceBaseTax
            quantity
            priceBaseTax
            priceTax
            priceBase
            price
            amountBase
            amount
            amountTax
            amountBaseTax
            additionalInfo
            comment
            unitPrice
            unitPriceTax
            unitPriceMc
            unitPriceTaxMc
            discount
            discountTax
            discountAmount
            discountAmountTax
            discountPercentage
            taxes{
              taxId
              name
              rate
              claveSat
              base
              total
              type
              tras
            }
                  lots{
                lotNumber
                quantity
                fabricationDate
                expirationDate
              }
        }
        taxesCfdi{
          taxId
          name
          rate
          type
          claveSat
          base
          total
          tras
        }
        receptor {
          uuid
          nombre
          rfc
          regimenFiscal
          usoCfdi
          codigoPostal
          breakdownIeps
          withholdTaxes
          invoiceUuid
          address{
            reference
            state
            country
            district
            street
            extNumber
            intNumber
            county
            zipCode
            city 
          }
        }
        emisor {
          rfc
          nombre
          regimenFiscal
          lugarExpedicion
          address{
            reference
            state
            country
            district
            street
            extNumber
            intNumber
            county
            zipCode
            city 
          }
        }
        comprobante{
          version
          metodoDePago
          formaPago
          exportacion
          tipoDeComprobante
          timbre{
            version
            noCertificadoSAT
            selloCFD
            selloSAT
            uuid
            fechaTimbrado
          }
          codigo
          lugarExpedicion
          certificadoCsd
          tipoCambio
          cadenaOriginal
          fechaEmision
          basicGlobalInfo{
            periodicityKey
            monthKey
            year
          }
          impuestosLocales{
            version
            totaldeRetenciones
            totaldeTraslados
            trasladosLocales{
              impLocTrasladado
              tasadeTraslado
              importe
            }
            retencionesLocales{
              impLocRetenido
              tasadeRetencion
              importe
            }
          }
        }
        acuse{
          selloDigital
        }
        recalculateMode
        cancellationRecalculateMode
      }
    
`).build();return new Promise((r,n)=>{$e.post(`${Et}${_n}`,t,{transformResponse:[a=>hr(a)],headers:{"Content-Type":"application/graphql"}}).then(a=>r(pe.unwrap(a))).catch(a=>{n(a)})})},ek=e=>{var t;const r=new pe(`
      byIdsV2(
        filter: {
          ids:[${(t=e==null?void 0:e.ids)==null?void 0:t.map(n=>`"${n}"`)}]
        }
        ) {
        id,
        branchId,
        uuid,
        type,
        serie,
        folio,
        status,
        creationDate
        userAccount
        userUuid
        userAlias
        agent{
          uuid
          name
          alias
        }
        employee{
          uuid
          name
        }
        parentDocs{
          id
          type
        }
        total
        isoCurrency
        status
        cancellationDate
        cancellationUserAccount
        cancellationUserUuid
        cancellationUserAlias
        cancellationComment
        cfdiCancelStatus
      }
`).build();return new Promise((n,a)=>{$e.post(`${Et}${_n}`,r,{transformResponse:[s=>hr(s)],headers:{"Content-Type":"application/graphql"}}).then(s=>n(pe.unwrap(s))).catch(s=>{a(s)})})},tk=(e,t=0)=>{const r=new pe(`
  relatedDocsInvoiceV2(
          id:"${e}"
          pageNumber: ${t}
          limit: 20
        ) {
          list{
            id
            branchId
            uuid
            type
            serie
            folio
            status
            creationDate
            userAccount
            userUuid
            userAlias
            agent {
              uuid
              name
              alias
            },
            employee{
              uuid
              name
              email
              position
            }
            total
            isoCurrency
            cancellationDate
            cancellationUserAccount
            cancellationUserUuid
            cancellationUserAlias
            cancellationComment
            cfdiCancelStatus
          }
         nextPage
      }
`).build();return new Promise((n,a)=>{$e.post(`${Et}${_n}`,r,{transformResponse:[s=>hr(s)],headers:{"Content-Type":"application/graphql"}}).then(s=>n(pe.unwrap(s))).catch(s=>{a(s)})})},rk=e=>new Promise(t=>{J(`${Da}/cashRegister/transaction`,e).then(r=>{t(r)}).catch(r=>{t(r)})}),nk=e=>new Promise(t=>{J(`${Da}/cashRegister/lock`,e,"text/plain").then(r=>{t(r)}).catch(r=>{t(r)})}),ak=e=>new Promise(t=>{J(`${Da}/cashRegister/unlock`,e,"text/plain").then(r=>{t(r)}).catch(r=>{t(r)})}),sk=e=>new Promise(t=>{J(`${Da}/cashRegister/close`,e).then(r=>{t(r)}).catch(r=>{t(r)})}),ik=e=>new Promise(t=>{Q(`cashregister-queries/v1/balance/${e}`).then(r=>{t(r)}).catch(r=>{t(r)})}),ok=(e,t)=>{let r=t?{"Set-Authorization":t}:"";return new Promise((n,a)=>{jr(`${qC}/sale`,e,r).then(s=>{n(s)}).catch(s=>{a(s)})})},ck=(e,t,r)=>new Promise((n,a)=>{Q(`${fs}/pdf/sale/${e}?name=${t}`+(r?"&downloadable=true":"")).then(n).catch(a)}),uk=e=>new Promise((t,r)=>{J(`${Jg}/quotation`,e).then(n=>{t(n)}).catch(n=>{r(n)})}),lk=(e,t)=>{let r=t?{"Set-Authorization":t}:"";return new Promise((n,a)=>{jr(`${Jg}/quotation/cancel`,e,r).then(s=>{n(s)}).catch(s=>{a(s)})})},dk=(e,t,r)=>new Promise((n,a)=>{Q(`${fs}/pdf/quotation/${e}?name=${t}`+(r?"&downloadable=true":"")).then(n).catch(a)}),hk=(e,t=!1)=>new Promise((r,n)=>{J(`${Yd}/purchase${t?"/cfdi":""}`,e).then(a=>{r(a)}).catch(a=>{n(a)})}),pk=(e,t)=>$e.post(`${Yd}/purchase/checked`,e,{headers:{"Content-type":"text/plain;charset=UTF-8",...t&&{"Set-Authorization":t}}}),fk=(e,t)=>$e.post(`${Yd}/purchase/cancellationChecked`,e,{headers:{"Content-type":"text/plain;charset=UTF-8",...t&&{"Set-Authorization":t}}}),gk=async e=>{const t=new pe(`checkPurchaseCfdi(invoiceUuid:"${e}")`).build();return J(ra,t,"application/graphql").then(r=>{var n,a;return(a=(n=pe.unwrap(r))==null?void 0:n.data)==null?void 0:a.checkPurchaseCfdi}).catch(r=>{throw r.response})},mk=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m,v;Q(`${We}/salesProfitMongo/withTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}&pageNumber=${e.pageNumber}
		&language=${e.language??((n=localStorage.getItem("lng"))==null?void 0:n.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
		${((a=Object.keys(e.agent))==null?void 0:a.length)>0?`&agentUuid=${(s=e.agent)==null?void 0:s.uuid}`:""}
		${((i=Object.keys(e.seller))==null?void 0:i.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((o=Object.keys(e.user))==null?void 0:o.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((c=Object.keys(e.serie))==null?void 0:c.length)>0?`&serie=${e.serie.uuid}`:""}
		${((u=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:u.length)>0?`&paymentId=${(l=e==null?void 0:e.payment)==null?void 0:l.uuid}`:""}
		${((d=Object.keys(e.status))==null?void 0:d.length)>0?`&status=${e.status.uuid}`:""}
		${((h=Object.keys(e.isoCurrency))==null?void 0:h.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((p=Object.keys(e.discount))==null?void 0:p.length)>0?`&discount=${e.discount.uuid}`:""}
		${((f=Object.keys((e==null?void 0:e.documentType)??{}))==null?void 0:f.length)>0?`&documentType=${(g=e==null?void 0:e.documentType)==null?void 0:g.uuid}`:""}
		${((y=e==null?void 0:e.warehouses)==null?void 0:y.length)??!1?`&warehouseId=${(b=e==null?void 0:e.warehouses)==null?void 0:b.map(S=>S.uuid)}`:""}
		${((m=e==null?void 0:e.branchs)==null?void 0:m.length)??!1?`&branch=${(v=e==null?void 0:e.branchs)==null?void 0:v.map(S=>S.uuid)}`:""}
		`).then(S=>{t(S)}).catch(S=>{r(S)})}),yk=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m,v;Q(`${We}/salesProfitMongo/withoutTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}&pageNumber=${e.pageNumber}
		&language=${e.language??((n=localStorage.getItem("lng"))==null?void 0:n.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
		${((a=Object.keys(e.agent))==null?void 0:a.length)>0?`&agentUuid=${(s=e.agent)==null?void 0:s.uuid}`:""}
		${((i=Object.keys(e.seller))==null?void 0:i.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((o=Object.keys(e.user))==null?void 0:o.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((c=Object.keys(e.serie))==null?void 0:c.length)>0?`&serie=${e.serie.uuid}`:""}
		${((u=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:u.length)>0?`&paymentId=${(l=e==null?void 0:e.payment)==null?void 0:l.uuid}`:""}
		${((d=Object.keys(e.status))==null?void 0:d.length)>0?`&status=${e.status.uuid}`:""}
		${((h=Object.keys(e.isoCurrency))==null?void 0:h.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((p=Object.keys(e.discount))==null?void 0:p.length)>0?`&discount=${e.discount.uuid}`:""}
		${((f=Object.keys((e==null?void 0:e.documentType)??{}))==null?void 0:f.length)>0?`&documentType=${(g=e==null?void 0:e.documentType)==null?void 0:g.uuid}`:""}
		${((y=e==null?void 0:e.warehouses)==null?void 0:y.length)??!1?`&warehouseId=${(b=e==null?void 0:e.warehouses)==null?void 0:b.map(S=>S.uuid)}`:""}
		${((m=e==null?void 0:e.branchs)==null?void 0:m.length)??!1?`&branch=${(v=e==null?void 0:e.branchs)==null?void 0:v.map(S=>S.uuid)}`:""}
		`).then(S=>{t(S)}).catch(S=>{r(S)})}),vk=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m,v;Q(`${We}/generalSalesMongo/withTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}&pageNumber=${e.pageNumber}
		&language=${e.language??((n=localStorage.getItem("lng"))==null?void 0:n.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
		${((a=Object.keys(e.agent))==null?void 0:a.length)>0?`&agentUuid=${(s=e.agent)==null?void 0:s.uuid}`:""}
		${((i=Object.keys(e.seller))==null?void 0:i.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((o=Object.keys(e.user))==null?void 0:o.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((c=Object.keys(e.serie))==null?void 0:c.length)>0?`&serie=${e.serie.uuid}`:""}
		${((u=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:u.length)>0?`&paymentId=${(l=e==null?void 0:e.payment)==null?void 0:l.uuid}`:""}
		${((d=Object.keys(e.status))==null?void 0:d.length)>0?`&status=${e.status.uuid}`:""}
		${((h=Object.keys(e.isoCurrency))==null?void 0:h.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((p=Object.keys(e.discount))==null?void 0:p.length)>0?`&discount=${e.discount.uuid}`:""}
		${((f=Object.keys((e==null?void 0:e.paymentType)??{}))==null?void 0:f.length)>0?`&salePayment=${(g=e==null?void 0:e.paymentType)==null?void 0:g.uuid}`:""}
		${((y=e==null?void 0:e.warehouses)==null?void 0:y.length)??!1?`&warehouseId=${(b=e==null?void 0:e.warehouses)==null?void 0:b.map(S=>S.uuid)}`:""}
		${((m=e==null?void 0:e.branchs)==null?void 0:m.length)??!1?`&branch=${(v=e==null?void 0:e.branchs)==null?void 0:v.map(S=>S.uuid)}`:""}
		`).then(S=>{t(S)}).catch(S=>{r(S)})}),bk=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m,v;Q(`${We}/generalSalesMongo/withoutTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}&pageNumber=${e.pageNumber}
		&language=${e.language??((n=localStorage.getItem("lng"))==null?void 0:n.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
		${((a=Object.keys(e.agent))==null?void 0:a.length)>0?`&agentUuid=${(s=e.agent)==null?void 0:s.uuid}`:""}
		${((i=Object.keys(e.seller))==null?void 0:i.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((o=Object.keys(e.user))==null?void 0:o.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((c=Object.keys(e.serie))==null?void 0:c.length)>0?`&serie=${e.serie.uuid}`:""}
		${((u=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:u.length)>0?`&paymentId=${(l=e==null?void 0:e.payment)==null?void 0:l.uuid}`:""}
		${((d=Object.keys(e.status))==null?void 0:d.length)>0?`&status=${e.status.uuid}`:""}
		${((h=Object.keys(e.isoCurrency))==null?void 0:h.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((p=Object.keys(e.discount))==null?void 0:p.length)>0?`&discount=${e.discount.uuid}`:""}
		${((f=Object.keys((e==null?void 0:e.paymentType)??{}))==null?void 0:f.length)>0?`&salePayment=${(g=e==null?void 0:e.paymentType)==null?void 0:g.uuid}`:""}
		${((y=e==null?void 0:e.warehouses)==null?void 0:y.length)??!1?`&warehouseId=${(b=e==null?void 0:e.warehouses)==null?void 0:b.map(S=>S.uuid)}`:""}
		${((m=e==null?void 0:e.branchs)==null?void 0:m.length)??!1?`&branch=${(v=e==null?void 0:e.branchs)==null?void 0:v.map(S=>S.uuid)}`:""}
		`).then(S=>{t(S)}).catch(S=>{r(S)})}),Ck=e=>{var t,r,n,a,s,i,o,c,u,l,d,h,p,f,g,y,b;return console.log(e),Q(`${We}/generalSalesMongo/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
		${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:o.length)>0?`&paymentId=${(c=e==null?void 0:e.payment)==null?void 0:c.uuid}`:""}
		${((u=Object.keys(e.status))==null?void 0:u.length)>0?`&status=${e.status.uuid}`:""}
		${((l=Object.keys(e.isoCurrency))==null?void 0:l.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((d=Object.keys(e.discount))==null?void 0:d.length)>0?`&discount=${e.discount.uuid}`:""}
		${((h=Object.keys((e==null?void 0:e.paymentType)??{}))==null?void 0:h.length)>0?`&salePayment=${(p=e==null?void 0:e.paymentType)==null?void 0:p.uuid}`:""}
		${((f=e==null?void 0:e.warehouses)==null?void 0:f.length)??!1?`&warehouseId=${(g=e==null?void 0:e.warehouses)==null?void 0:g.map(m=>m.uuid)}`:""}
		${((y=e==null?void 0:e.branchs)==null?void 0:y.length)??!1?`&branch=${(b=e==null?void 0:e.branchs)==null?void 0:b.map(m=>m.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},Sk=e=>{var t,r,n,a,s,i,o,c,u,l,d,h,p,f,g,y,b;return Q(`${We}/generalSalesMongo/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
		${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:o.length)>0?`&paymentId=${(c=e==null?void 0:e.payment)==null?void 0:c.uuid}`:""}
		${((u=Object.keys(e.status))==null?void 0:u.length)>0?`&status=${e.status.uuid}`:""}
		${((l=Object.keys(e.isoCurrency))==null?void 0:l.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((d=Object.keys(e.discount))==null?void 0:d.length)>0?`&discount=${e.discount.uuid}`:""}
		${((h=Object.keys((e==null?void 0:e.paymentType)??{}))==null?void 0:h.length)>0?`&salePayment=${(p=e==null?void 0:e.paymentType)==null?void 0:p.uuid}`:""}
		${((f=e==null?void 0:e.warehouses)==null?void 0:f.length)??!1?`&warehouseId=${(g=e==null?void 0:e.warehouses)==null?void 0:g.map(m=>m.uuid)}`:""}
		${((y=e==null?void 0:e.branchs)==null?void 0:y.length)??!1?`&branch=${(b=e==null?void 0:e.branchs)==null?void 0:b.map(m=>m.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},Ek=e=>{var t,r,n,a,s,i,o,c,u,l,d,h,p,f,g,y,b;return console.log("body",e),Q(`${We}/salesProfitMongo/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
		${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:o.length)>0?`&paymentId=${(c=e==null?void 0:e.payment)==null?void 0:c.uuid}`:""}
		${((u=Object.keys(e.status))==null?void 0:u.length)>0?`&status=${e.status.uuid}`:""}
		${((l=Object.keys(e.isoCurrency))==null?void 0:l.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((d=Object.keys(e.discount))==null?void 0:d.length)>0?`&discount=${e.discount.uuid}`:""}
		${((h=Object.keys((e==null?void 0:e.documentType)??{}))==null?void 0:h.length)>0?`&documentType=${(p=e==null?void 0:e.documentType)==null?void 0:p.uuid}`:""}
		${((f=e==null?void 0:e.warehouses)==null?void 0:f.length)??!1?`&warehouseId=${(g=e==null?void 0:e.warehouses)==null?void 0:g.map(m=>m.uuid)}`:""}
		${((y=e==null?void 0:e.branchs)==null?void 0:y.length)??!1?`&branch=${(b=e==null?void 0:e.branchs)==null?void 0:b.map(m=>m.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},xk=e=>{var t,r,n,a,s,i,o,c,u,l,d,h,p,f,g,y,b;return Q(`${We}/salesProfitMongo/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
		${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:o.length)>0?`&paymentId=${(c=e==null?void 0:e.payment)==null?void 0:c.uuid}`:""}
		${((u=Object.keys(e.status))==null?void 0:u.length)>0?`&status=${e.status.uuid}`:""}
		${((l=Object.keys(e.isoCurrency))==null?void 0:l.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((d=Object.keys(e.discount))==null?void 0:d.length)>0?`&discount=${e.discount.uuid}`:""}
		${((h=Object.keys((e==null?void 0:e.documentType)??{}))==null?void 0:h.length)>0?`&documentType=${(p=e==null?void 0:e.documentType)==null?void 0:p.uuid}`:""}
		${((f=e==null?void 0:e.warehouses)==null?void 0:f.length)??!1?`&warehouseId=${(g=e==null?void 0:e.warehouses)==null?void 0:g.map(m=>m.uuid)}`:""}
		${((y=e==null?void 0:e.branchs)==null?void 0:y.length)??!1?`&branch=${(b=e==null?void 0:e.branchs)==null?void 0:b.map(m=>m.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},wk=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m;vs(`${We}/generalPurchasesMongo/withTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}&pageNumber=${e.pageNumber}
		&language=${e.language??((n=localStorage.getItem("lng"))==null?void 0:n.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
			${((a=Object.keys(e.agent??{}))==null?void 0:a.length)>0?`&agentUuid=${(s=e.agent)==null?void 0:s.uuid}`:""}
		${((i=Object.keys(e.seller??{}))==null?void 0:i.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((o=Object.keys(e.user??{}))==null?void 0:o.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((c=Object.keys(e.serie??{}))==null?void 0:c.length)>0?`&serie=${e.serie.uuid}`:""}
		${((u=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:u.length)>0?`&paymentId=${(l=e==null?void 0:e.payment)==null?void 0:l.uuid}`:""}
		${((d=Object.keys(e.status??{}))==null?void 0:d.length)>0?`&status=${e.status.uuid}`:""}
		${((h=Object.keys(e.isoCurrency??{}))==null?void 0:h.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((p=Object.keys(e.invoiced??{}))==null?void 0:p.length)>0?`&invoiced=${e.invoiced.uuid}`:""}
		${((f=Object.keys(e.discount??{}))==null?void 0:f.length)>0?`&discount=${e.discount.uuid}`:""}
		${((g=e==null?void 0:e.warehouse)==null?void 0:g.length)??!1?`&warehouseId=${(y=e==null?void 0:e.warehouse)==null?void 0:y.map(v=>v.uuid)}`:""}
		${((b=e==null?void 0:e.branchs)==null?void 0:b.length)??!1?`&branch=${(m=e==null?void 0:e.branchs)==null?void 0:m.map(v=>v.uuid)}`:""}
		`).then(v=>{t(v)}).catch(v=>{r(v)})}),Tk=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d,h,p,f,g,y,b,m;vs(`${We}/generalPurchasesMongo/withoutTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}&pageNumber=${e.pageNumber}
		&language=${e.language??((n=localStorage.getItem("lng"))==null?void 0:n.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
		${((a=Object.keys(e.agent??{}))==null?void 0:a.length)>0?`&agentUuid=${(s=e.agent)==null?void 0:s.uuid}`:""}
		${((i=Object.keys(e.seller??{}))==null?void 0:i.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((o=Object.keys(e.user??{}))==null?void 0:o.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((c=Object.keys(e.serie??{}))==null?void 0:c.length)>0?`&serie=${e.serie.uuid}`:""}
		${((u=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:u.length)>0?`&paymentId=${(l=e==null?void 0:e.payment)==null?void 0:l.uuid}`:""}
		${((d=Object.keys(e.status??{}))==null?void 0:d.length)>0?`&status=${e.status.uuid}`:""}
		${((h=Object.keys(e.isoCurrency??{}))==null?void 0:h.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((p=Object.keys(e.invoiced??{}))==null?void 0:p.length)>0?`&invoiced=${e.invoiced.uuid}`:""}
		${((f=Object.keys(e.discount??{}))==null?void 0:f.length)>0?`&discount=${e.discount.uuid}`:""}
		${((g=e==null?void 0:e.warehouse)==null?void 0:g.length)??!1?`&warehouseId=${(y=e==null?void 0:e.warehouse)==null?void 0:y.map(v=>v.uuid)}`:""}
		${((b=e==null?void 0:e.branchs)==null?void 0:b.length)??!1?`&branch=${(m=e==null?void 0:e.branchs)==null?void 0:m.map(v=>v.uuid)}`:""}
		`).then(v=>{t(v)}).catch(v=>{r(v)})}),$k=e=>{var t,r,n,a,s,i,o,c,u,l,d,h,p,f,g,y;return Q(`${We}/generalPurchasesMongo/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
		${((r=Object.keys(e.agent??{}))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller??{}))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user??{}))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie??{}))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:o.length)>0?`&paymentId=${(c=e==null?void 0:e.payment)==null?void 0:c.uuid}`:""}
		${((u=Object.keys(e.status??{}))==null?void 0:u.length)>0?`&status=${e.status.uuid}`:""}
		${((l=Object.keys(e.isoCurrency??{}))==null?void 0:l.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((d=Object.keys(e.invoiced??{}))==null?void 0:d.length)>0?`&invoiced=${e.invoiced.uuid}`:""}
		${((h=Object.keys(e.discount??{}))==null?void 0:h.length)>0?`&discount=${e.discount.uuid}`:""}
		${((p=e==null?void 0:e.warehouse)==null?void 0:p.length)??!1?`&warehouseId=${(f=e==null?void 0:e.warehouse)==null?void 0:f.map(b=>b.uuid)}`:""}
		${((g=e==null?void 0:e.branchs)==null?void 0:g.length)??!1?`&branch=${(y=e==null?void 0:e.branchs)==null?void 0:y.map(b=>b.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},Ak=e=>{var t,r,n,a,s,i,o,c,u,l,d,h,p,f,g,y;return Q(`${We}/generalPurchasesMongo/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&search=${e.search}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
			${((r=Object.keys(e.agent??{}))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller??{}))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user??{}))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie??{}))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys((e==null?void 0:e.payment)??{}))==null?void 0:o.length)>0?`&paymentId=${(c=e==null?void 0:e.payment)==null?void 0:c.uuid}`:""}
		${((u=Object.keys(e.status??{}))==null?void 0:u.length)>0?`&status=${e.status.uuid}`:""}
		${((l=Object.keys(e.isoCurrency??{}))==null?void 0:l.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((d=Object.keys(e.invoiced??{}))==null?void 0:d.length)>0?`&invoiced=${e.invoiced.uuid}`:""}
		${((h=Object.keys(e.discount??{}))==null?void 0:h.length)>0?`&discount=${e.discount.uuid}`:""}
		${((p=e==null?void 0:e.warehouse)==null?void 0:p.length)??!1?`&warehouseId=${(f=e==null?void 0:e.warehouse)==null?void 0:f.map(b=>b.uuid)}`:""}
		${((g=e==null?void 0:e.branchs)==null?void 0:g.length)??!1?`&branch=${(y=e==null?void 0:e.branchs)==null?void 0:y.map(b=>b.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},Ik=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d;Q(`${We}/transactionsBranches?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}
		&language=${e.language??((n=localStorage.getItem("lng"))==null?void 0:n.includes("en"))?"EN":"ES"}
		&datePattern=${e.datePattern}
		${((a=Object.keys(e.transactionType))==null?void 0:a.length)>0?`&transactionType=${e.transactionType.uuid}`:""}
		${((s=Object.keys(e.operationType))==null?void 0:s.length)>0?`&operationType=${e.operationType.uuid}`:""}
		${((i=Object.keys(e.paymentOption))==null?void 0:i.length)>0?`&paymentOption=${e.paymentOption.uuid}`:""}
		${((o=Object.keys(e.isoCurrency))==null?void 0:o.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((c=Object.keys(e.cashRegister))==null?void 0:c.length)>0?`&cashRegisterUuid=${e.cashRegister.uuid}`:""}
		${((u=Object.keys(e.user))==null?void 0:u.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((l=e==null?void 0:e.branchs)==null?void 0:l.length)??!1?`&branch=${(d=e==null?void 0:e.branchs)==null?void 0:d.map(h=>h.uuid)}`:""}
		`).then(h=>{t(h)}).catch(h=>{r(h)})}),Pk=e=>new Promise((t,r)=>{Q(`${We}/transactionsBranches/nextPage?offset=${e}`).then(n=>{t(n)}).catch(n=>{r(n)})}),_k=(e,t)=>new Promise((r,n)=>{Q(`${We}/transactionsBranches/exportCsv?jobId=${e}&fileName=${t}`).then(a=>{r(a)}).catch(a=>{n(a)})}),pP=e=>new Promise((t,r)=>{Re(`${dr}/zone`,e).then(n=>{t(n)}).catch(n=>{r(n)})}),fP=e=>{let t=e.id,r={name:e.name};return new Promise((n,a)=>{ze(`${dr}/zone/`+t,r).then(s=>{n(s)}).catch(s=>{a(s)})})},gP=e=>new Promise((t,r)=>{Re(`${dr}/zone/order`,e).then(n=>{t(n)}).catch(n=>{r(n)})}),mP=e=>new Promise((t,r)=>{ft(`${dr}/zone/`+e).then(n=>{t(n)}).catch(n=>{r(n)})}),yP=()=>new Promise((e,t)=>{Q(`${dr}/zone/list`).then(r=>{e(r)}).catch(r=>{t(r)})}),vP=(e,t)=>{var r;let n=Object.fromEntries((r=Object.entries(t))==null?void 0:r.filter(a=>{var s;return(a==null?void 0:a[1])!==""&&(a==null?void 0:a[1])!==null&&(a==null?void 0:a[1])!==void 0&&((s=a==null?void 0:a[1])==null?void 0:s.length)!==0}));return new Promise((a,s)=>{Re(`${dr}/table/`+e,n).then(i=>{a(i)}).catch(i=>{s(i)})})},bP=(e,t)=>{var r;let n=Object.fromEntries((r=Object.entries(t))==null?void 0:r.filter(a=>{var s;return(a==null?void 0:a[1])!==""&&(a==null?void 0:a[1])!==null&&(a==null?void 0:a[1])!==void 0&&((s=a==null?void 0:a[1])==null?void 0:s.length)!==0}));return n={...n,zoneId:e},new Promise((a,s)=>{Re(`${dr}/group`,n).then(i=>{a(i)}).catch(i=>{s(i)})})},CP=e=>{var t;const{id:r,temporal:n,...a}=e||{};let s=Object.fromEntries((t=Object.entries(a))==null?void 0:t.filter(i=>{var o;return(i==null?void 0:i[1])!==""&&(i==null?void 0:i[1])!==null&&(i==null?void 0:i[1])!==void 0&&((o=i==null?void 0:i[1])==null?void 0:o.length)!==0}));return new Promise((i,o)=>{ze(`${dr}/table/`+r,s).then(c=>{i(c)}).catch(c=>{o(c)})})},SP=e=>new Promise((t,r)=>{Re(`${dr}/table/order`,e).then(n=>{t(n)}).catch(n=>{r(n)})}),EP=(e,t,r)=>{let n={status:t,comment:r||""};return new Promise((a,s)=>{J(`${dr}/table/status/`+e,n).then(i=>{a(i)}).catch(i=>{s(i)})})},xP=(e,t,r)=>{let n={groupDestination:e,groupOrigin:t,documents:r};return new Promise((a,s)=>{J(`${dr}/document/transfer`,n).then(i=>{a(i)}).catch(i=>{s(i)})})},wP=e=>new Promise((t,r)=>{ft(`${dr}/table/`+e).then(n=>{t(n)}).catch(n=>{r(n)})}),TP=e=>new Promise((t,r)=>{Q(`${dr}/table/list/`+e).then(n=>{t(n)}).catch(n=>{r(n)})}),$P=()=>new Promise((e,t)=>{Q(`${dr}/metadata/tableTypes`).then(r=>{e(r)}).catch(r=>{t(r)})}),AP=e=>{const t=new pe(`
        byIdsV2(filter:{ ids: ${pe.parseParam(e)}}) {
            id
            creationDate
            uuid
            mainIsoCurrency
            isoCurrency
            exchangeRate
            total
            status
            serieFolio
            documentDate
            cancellationDate
            cancellationComment
            cancellationUserUuid
            userUuid
            discount
            comment
        }`).build();return new Promise((r,n)=>{J(ra,t,"application/graphql").then(a=>r(pe.unwrap(a))).catch(a=>{n(a)})})},IP=e=>{const t=new pe(`
        byIdsV2(filter:{ ids: ${pe.parseParam(e)}}) {
            id
            creationDate
            uuid
            mainIsoCurrency
            isoCurrency
            totalMc
            total
            agent {
                name
                uuid
            }
            employee {
                name
                uuid
            }
            status
            serieFolio
            documentDate
            cancellationDate
            cancellationComment
            cancellationUserUuid
            userUuid
            discount
            products {
                uuid
                sku
                type
                description
                unit
                quantity
                priceBaseTax
                priceBaseTaxConv
                priceTax
                priceTaxConv
                priceBase
                priceBaseConv
                price
                priceConv
                amountBase
                amount
                amountBaseTax
                amountTax
                additionalInfo
                comment
                taxesIds
                discount
                discountTax
                discountPercentage
                claveProdServ
                claveUnidad
                separator
                avgPurchasePrice
                avgPurchasePriceTax
                edited
                departmentId
                categoryId
            }
        }`).build();return new Promise((r,n)=>{J(ra,t,"application/graphql").then(a=>r(pe.unwrap(a))).catch(a=>{n(a)})})},PP=e=>{const t=new pe(`
        byIdsV2(filter:{ ids: ${pe.parseParam(e)}}) {
            id
            products {
                uuid
                sku
                type
                description
                unit
                quantity
                priceBaseTax
                priceBaseTaxConv
                priceTax
                priceTaxConv
                priceBase
                priceBaseConv
                price
                priceConv
                amountBase
                amount
                amountBaseTax
                amountTax
                additionalInfo
                comment
                taxesIds
                discount
                discountTax
                discountAmountTax
                discountPercentage
                claveProdServ
                claveUnidad
                separator
                avgPurchasePrice
                avgPurchasePriceTax
                departmentId
                categoryId
            }
        }`).build();return new Promise((r,n)=>{J(ra,t,"application/graphql").then(a=>r(pe.unwrap(a))).catch(a=>{n(a)})})},_P=e=>new Promise((t,r)=>{J(`${Ho}/order`,e).then(n=>{t(n)}).catch(n=>{r(n)})}),DP=(e,t)=>{let r=t?{"Set-Authorization":t}:"";return new Promise((n,a)=>{jr(`${Ho}/bill/pay`,e,r).then(s=>{n(s)}).catch(s=>{a(s)})})},RP=(e,t)=>{let r=t?{"Set-Authorization":t}:"";return new Promise((n,a)=>{jr(`${Ho}/order/cancel`,e,r).then(s=>{n(s)}).catch(s=>{a(s)})})},NP=e=>new Promise((t,r)=>{J(`${Ho}/bill/reopen`,{id:e}).then(n=>{t(n)}).catch(n=>{r(n)})}),BP=e=>{const t=new pe(`
        generatedV2(
            objectId:"${e}"
        ) {
            id
            uuid
            type
            serie
            folio
            creationDate
            documentDate
            timeZone
            withholdingTax
            userUuid
            userAlias
            agent {
                uuid
                name
                withholdTaxes      
                address{
                    city
                    country
                    district
                    extNumber
                    intNumber
                    state
                    street
                    zipCode
                },
                phoneNumbers {
                    phoneCode
                    phoneNumber
                    phoneType
                }  
            }
            employee {
                uuid
                name
            }
            total
            mainIsoCurrency
            isoCurrency
            status,
            exchangeRate
            warehouseId
            externalFolio
            comment
            products{
                uuid
                type
                sku
                description
                unit
                quantity
                originPriceBaseTax
                priceBaseTax
                priceBaseTaxConv
                priceTax
                priceTaxConv
                priceBase
                priceBaseConv
                price
                priceConv
                amountBase
                amount
                amountTax
                originAmountTax
                amountBaseTax
                additionalInfo
                comment
                unitPrice
                unitPriceTax
                unitPriceMc
                unitPriceTaxMc
                discount
                discountTax
                discountAmount
                discountAmountTax
                discountPercentage
                edited
                taxes{
                    taxId
                    name
                    rate
                    claveSat
                    base
                    total
                    type
                    tras
                }
            }
        }`).build();return new Promise((r,n)=>{J(ra,t,"application/graphql").then(a=>r(pe.unwrap(a))).catch(a=>{n(a)})})},kP=()=>new Promise((e,t)=>{Q(`${dr}/view`).then(r=>{e(r)}).catch(r=>{t(r)})}),OP=e=>new Promise((t,r)=>{Q(`${dr}/view/space/${e}`).then(n=>{t(n)}).catch(n=>{r(n)})}),Dk=Object.freeze(Object.defineProperty({__proto__:null,cancelOrder:RP,changeSpaceTables:xP,createOrder:_P,createSpace:vP,createTemporalSpace:bP,createZone:pP,deleteSpace:wP,deleteZone:mP,editSpace:CP,editSpaceOrder:SP,editSpaceStatus:EP,editZone:fP,editZoneOrder:gP,getDocumentId:BP,getProductsBySpaces:PP,getSpaceId:OP,getSpacesByZone:TP,getSpacesOrder:AP,getSpacesOrderClose:IP,getSpacesTableTypes:$P,getView:kP,getZones:yP,payOrder:DP,reOpenOrder:NP},Symbol.toStringTag,{value:"Module"})),Rk=e=>new Promise(t=>{J(`${yt}rpsCredentials/registry`,e).then(r=>t(r)).catch(r=>t(r))}),Nk=e=>new Promise(t=>{J(`${yt}rpsCredentials/save`,e).then(r=>t(r)).catch(r=>t(r))}),Bk=()=>new Promise(e=>{Q(`${yt}rpsBag/dashboard`).then(t=>e(t)).catch(t=>e(t))}),kk=()=>new Promise(e=>{Q(`${yt}rpsPayments/paymentMethods`).then(t=>e(t)).catch(t=>e(t))}),Ok=()=>new Promise(e=>{Q(`${yt}rpsPayments/availableBanks`).then(t=>e(t)).catch(t=>e(t))}),Uk=e=>new Promise(t=>{Re(`${yt}rpsPayments`,e).then(r=>t(r)).catch(r=>t(r))}),Lk=(e,t,r,n)=>new Promise(a=>{Q(`${yt}rpsPayments/list?startDate=${e}&endDate=${t}${r?"&page="+r:""}${n?"&bag="+n:""}`).then(s=>a(s)).catch(s=>a(s))}),Mk=(e,t,r)=>new Promise(n=>{Q(`${yt}rpsLogs/list?startDate=${e}&endDate=${t}${r?"&page="+r:""}`).then(a=>n(a)).catch(a=>n(a))}),jk=(e,t,r,n)=>{let a="",s=[];return n&&s.push("filter="+n),t&&s.push("carrierId="+t),r&&s.push("categoryId="+r),e&&s.push("page="+e),s.length>0&&(a="?",s.length==1?a=a+s[0]:a=a+s.join("&")),new Promise(i=>{Q(`${yt}rpsCatalogue/products/list${a}`).then(o=>i(o)).catch(o=>i(o))})},Fk=e=>new Promise(t=>{Re(`${yt}rpsCatalogue/products/extraCharge`,e).then(r=>t(r)).catch(r=>t(r))}),qk=()=>new Promise(e=>{Q(`${yt}rpsCatalogue/categories`).then(t=>e(t)).catch(t=>e(t))}),Hk=()=>new Promise(e=>{Q(`${yt}rpsCatalogue/carriersForRecharges`).then(t=>e(t)).catch(t=>e(t))}),Kk=()=>new Promise(e=>{Q(`${yt}rpsCatalogue/carriers`).then(t=>e(t)).catch(t=>e(t))}),Vk=(e,t,r)=>new Promise(n=>{Q(`${yt}rpsTransactions/csv?startDate=${e}&endDate=${t}${r?"&timeZone="+r:""}`).then(a=>n(a)).catch(a=>n(a))}),zk=(e,t,r)=>new Promise(n=>{Q(`${yt}rpsTransactions/list?startDate=${e}&endDate=${t}${r?"&page="+r:""}`).then(a=>n(a)).catch(a=>n(a))}),Gk=(e,t,r)=>new Promise(n=>{Q(`${yt}rpsTransactions/print?startDate=${e}&endDate=${t}${r?"&timeZone="+r:""}`).then(a=>n(a)).catch(a=>n(a))}),Qk=(e,t,r)=>new Promise(n=>{Q(`${yt}rpsPayments/print?startDate=${e}&endDate=${t}${r?"&timeZone="+r:""}`).then(a=>n(a)).catch(a=>n(a))}),Wk=()=>new Promise(e=>{Q(`${yt}rpsAntiTheft`).then(t=>e(t)).catch(t=>e(t))}),Zk=e=>new Promise(t=>{Re(`${yt}rpsAntiTheft`,e).then(r=>t(r)).catch(r=>t(r))}),Yk=e=>new Promise(t=>{J(`${yt}rpsTransactions/checkReference`,e).then(r=>t(r)).catch(r=>t(r))}),Xk=e=>new Promise(t=>{J(`${yt}rpsTransactions/consult`,e).then(r=>t(r)).catch(r=>t(r))}),Jk=()=>new Promise(e=>{Q(`${yt}rpsCredentials/isActive`).then(t=>e(t)).catch(t=>e(t))}),eO=(e,t,r)=>new Promise(n=>{Q(`${yt}rpsLogs/print?startDate=${e}&endDate=${t}${r?"&timeZone="+r:""}`).then(a=>n(a)).catch(a=>n(a))}),tO=()=>new Promise(e=>{Re(`${yt}rpsCatalogue/products/refresh`).then(t=>e(t)).catch(t=>e(t))}),rO=()=>new Promise(e=>{Q(`${yt}rpsCatalogue/products/favorites`).then(t=>e(t)).catch(t=>e(t))}),nO=e=>new Promise(t=>{Q(`${yt}rpsCatalogue/products/recharges?carrierId=${e}`).then(r=>t(r)).catch(r=>t(r))}),aO=e=>new Promise(t=>{Q(`${yt}rpsCatalogue/products/paymentsAndGifts?category=${e}`).then(r=>t(r)).catch(r=>t(r))}),sO=e=>new Promise(t=>{Q(`${yt}rpsCatalogue/products/findByKey?key=${e}`).then(r=>t(r)).catch(r=>t(r))}),iO=e=>{var t,r,n;return Q(`${We}/cfdiReport/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&dateField=${e.dateField}&language=${((t=localStorage.getItem("lng"))!=null&&t.includes("en-US")?"EN":"ES")??"ES"}
		&datePattern=${e.datePattern}
		${((r=Object.keys(e.status))==null?void 0:r.length)>0?`&status=${e.status.uuid}`:""}
		${((n=Object.keys(e.isoCurrency))==null?void 0:n.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		`,{responseType:"blob"})},oO=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d,h,p;Q(`${We}/products/withTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&pageNumber=${e.pageNumber}&limit=20
		&language=${(n=localStorage.getItem("lng"))!=null&&n.includes("en-US")?"EN":"ES"}
		${((a=Object.keys(e.agent))==null?void 0:a.length)>0?`&agentUuid=${(s=e.agent)==null?void 0:s.uuid}`:""}
		${((i=Object.keys(e.seller))==null?void 0:i.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((o=Object.keys(e.user))==null?void 0:o.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((c=Object.keys(e.status))==null?void 0:c.length)>0?`&status=${e.status.uuid}`:""}
        ${((u=Object.keys(e.product))==null?void 0:u.length)>0?`&productUuid=${e.product.uuid}`:""}
        &groupProducts=${e.groupProducts}
        &sortBy=${e.sortBy}
        &sortOrder=${e.sortOrder}
		${((l=e==null?void 0:e.department)==null?void 0:l.length)??!1?`&department=${(d=e==null?void 0:e.department)==null?void 0:d.map(f=>f.uuid)}`:""}
		${((h=e==null?void 0:e.category)==null?void 0:h.length)??!1?`&category=${(p=e==null?void 0:e.category)==null?void 0:p.map(f=>f.uuid)}`:""}
		`.replace(/\s/g,"")).then(f=>{t(f)}).catch(f=>{r(f)})}),cO=e=>new Promise((t,r)=>{var n,a,s,i,o,c,u,l,d,h,p;Q(`${We}/products/withoutTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&pageNumber=${e.pageNumber}&limit=20
		&language=${(n=localStorage.getItem("lng"))!=null&&n.includes("en-US")?"EN":"ES"}
		${((a=Object.keys(e.agent))==null?void 0:a.length)>0?`&agentUuid=${(s=e.agent)==null?void 0:s.uuid}`:""}
		${((i=Object.keys(e.seller))==null?void 0:i.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((o=Object.keys(e.user))==null?void 0:o.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((c=Object.keys(e.status))==null?void 0:c.length)>0?`&status=${e.status.uuid}`:""}
        ${((u=Object.keys(e.product))==null?void 0:u.length)>0?`&productUuid=${e.product.uuid}`:""}
        &groupProducts=${e.groupProducts}
        &sortBy=${e.sortBy}
        &sortOrder=${e.sortOrder}
		${((l=e==null?void 0:e.department)==null?void 0:l.length)??!1?`&department=${(d=e==null?void 0:e.department)==null?void 0:d.map(f=>f.uuid)}`:""}
		${((h=e==null?void 0:e.category)==null?void 0:h.length)??!1?`&category=${(p=e==null?void 0:e.category)==null?void 0:p.map(f=>f.uuid)}`:""}
		`.replace(/\s/g,"")).then(f=>{t(f)}).catch(f=>{r(f)})}),uO=e=>{var t,r,n,a,s,i,o,c,u,l,d;return Q(`${We}/products/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&pageNumber=${e.pageNumber}&limit=20
&language=${(t=localStorage.getItem("lng"))!=null&&t.includes("en-US")?"EN":"ES"}
		${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.status))==null?void 0:i.length)>0?`&status=${e.status.uuid}`:""}
        ${((o=Object.keys(e.product))==null?void 0:o.length)>0?`&productUuid=${e.product.uuid}`:""}
        &groupProducts=${e.groupProducts}
        &sortBy=${e.sortBy}
        &sortOrder=${e.sortOrder}
		${((c=e==null?void 0:e.department)==null?void 0:c.length)??!1?`&department=${(u=e==null?void 0:e.department)==null?void 0:u.map(h=>h.uuid)}`:""}
		${((l=e==null?void 0:e.category)==null?void 0:l.length)??!1?`&category=${(d=e==null?void 0:e.category)==null?void 0:d.map(h=>h.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},lO=e=>{var t,r,n,a,s,i,o,c,u,l,d;return Q(`${We}/products/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&pageNumber=${e.pageNumber}&limit=20
		&language=${(t=localStorage.getItem("lng"))!=null&&t.includes("en-US")?"EN":"ES"}
		${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.status))==null?void 0:i.length)>0?`&status=${e.status.uuid}`:""}
        ${((o=Object.keys(e.product))==null?void 0:o.length)>0?`&productUuid=${e.product.uuid}`:""}
        &groupProducts=${e.groupProducts}
        &sortBy=${e.sortBy}
        &sortOrder=${e.sortOrder}
		${((c=e==null?void 0:e.department)==null?void 0:c.length)??!1?`&department=${(u=e==null?void 0:e.department)==null?void 0:u.map(h=>h.uuid)}`:""}
		${((l=e==null?void 0:e.category)==null?void 0:l.length)??!1?`&category=${(d=e==null?void 0:e.category)==null?void 0:d.map(h=>h.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},dO=e=>{var t,r,n,a,s,i,o,c,u,l,d;return Q(`${We}/generalOrders/withoutTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&search=${e.search}&pageNumber=${e.page}&limit=20
		&language=${(t=localStorage.getItem("lng"))!=null&&t.includes("en")?"EN":"ES"}
		${((r=Object.keys(e.agent??{}))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller??{}))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user??{}))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie??{}))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys(e.status??{}))==null?void 0:o.length)>0?`&status=${e.status.uuid}`:""}
		${((c=Object.keys(e.isoCurrency??{}))==null?void 0:c.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((u=Object.keys(e.discount??{}))==null?void 0:u.length)>0?`&discount=${e.discount.uuid}`:""}
		${((l=e==null?void 0:e.branchs)==null?void 0:l.length)??!1?`&branch=${(d=e==null?void 0:e.branchs)==null?void 0:d.map(h=>h.uuid)}`:""}
		`)},hO=e=>{var t,r,n,a,s,i,o,c,u,l,d;return Q(`${We}/generalOrders/withTaxes?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&search=${e.search}&pageNumber=${e.page}&limit=20
		&language=${(t=localStorage.getItem("lng"))!=null&&t.includes("en")?"EN":"ES"}
		${((r=Object.keys(e.agent??{}))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller??{}))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user??{}))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie??{}))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys(e.status??{}))==null?void 0:o.length)>0?`&status=${e.status.uuid}`:""}
		${((c=Object.keys(e.isoCurrency??{}))==null?void 0:c.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((u=Object.keys(e.discount??{}))==null?void 0:u.length)>0?`&discount=${e.discount.uuid}`:""}
		${((l=e==null?void 0:e.branchs)==null?void 0:l.length)??!1?`&branch=${(d=e==null?void 0:e.branchs)==null?void 0:d.map(h=>h.uuid)}`:""}
		`)},pO=e=>{var t,r,n,a,s,i,o,c,u,l,d;return Q(`${We}/generalOrders/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&search=${e.search}&language=${(t=localStorage.getItem("lng"))!=null&&t.includes("en")?"EN":"ES"}
		${((r=Object.keys(e.agent??{}))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller??{}))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user??{}))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie??{}))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys(e.status??{}))==null?void 0:o.length)>0?`&status=${e.status.uuid}`:""}
		${((c=Object.keys(e.isoCurrency??{}))==null?void 0:c.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((u=Object.keys(e.discount??{}))==null?void 0:u.length)>0?`&discount=${e.discount.uuid}`:""}
		${((l=e==null?void 0:e.branchs)==null?void 0:l.length)??!1?`&branch=${(d=e==null?void 0:e.branchs)==null?void 0:d.map(h=>h.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},fO=e=>{var t,r,n,a,s,i,o,c,u,l,d;return Q(`${We}/generalOrders/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}&search=${e.search}&language=${(t=localStorage.getItem("lng"))!=null&&t.includes("en")?"EN":"ES"}
		${((r=Object.keys(e.agent??{}))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
		${((a=Object.keys(e.seller??{}))==null?void 0:a.length)>0?`&sellerUuid=${e.seller.uuid}`:""}
		${((s=Object.keys(e.user??{}))==null?void 0:s.length)>0?`&userUuid=${e.user.uuid}`:""}
		${((i=Object.keys(e.serie??{}))==null?void 0:i.length)>0?`&serie=${e.serie.uuid}`:""}
		${((o=Object.keys(e.status??{}))==null?void 0:o.length)>0?`&status=${e.status.uuid}`:""}
		${((c=Object.keys(e.isoCurrency??{}))==null?void 0:c.length)>0?`&isoCurrency=${e.isoCurrency.iso}`:""}
		${((u=Object.keys(e.discount??{}))==null?void 0:u.length)>0?`&discount=${e.discount.uuid}`:""}
		${((l=e==null?void 0:e.branchs)==null?void 0:l.length)??!1?`&branch=${(d=e==null?void 0:e.branchs)==null?void 0:d.map(h=>h.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},gO=e=>{var t,r,n,a,s;return Q(`${We}/salesByDepartment/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &groupDepartments=${e.groupDepartments}
		${((r=e==null?void 0:e.departments)==null?void 0:r.length)??!1?`&department=${(n=e==null?void 0:e.departments)==null?void 0:n.map(i=>i.uuid)}`:""}
        ${((a=e==null?void 0:e.categories)==null?void 0:a.length)??!1?`&category=${(s=e==null?void 0:e.categories)==null?void 0:s.map(i=>i.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},mO=e=>{var t,r,n,a,s;return Q(`${We}/salesByDepartment/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&timeZone=${e.timeZone}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &groupDepartments=${e.groupDepartments}
		${((r=e==null?void 0:e.departments)==null?void 0:r.length)??!1?`&department=${(n=e==null?void 0:e.departments)==null?void 0:n.map(i=>i.uuid)}`:""}
        ${((a=e==null?void 0:e.categories)==null?void 0:a.length)??!1?`&category=${(s=e==null?void 0:e.categories)==null?void 0:s.map(i=>i.uuid)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},yO=e=>{var t,r,n;return Q(`${We}/salesByUser/withTaxes?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &seller=false${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""))},vO=e=>{var t,r,n;return Q(`${We}/salesByUser/withoutTaxes?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &seller=false&${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`)},bO=e=>{var t,r,n;return Q(`${We}/salesByUser/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &seller=false&${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},CO=e=>{var t,r,n;return Q(`${We}/salesByUser/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &seller=false&${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},SO=e=>{var t,r,n;return Q(`${We}/salesByUser/withTaxes?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &seller=true&${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`)},EO=e=>{var t,r,n;return Q(`${We}/salesByUser/withoutTaxes?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &seller=true&${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`)},xO=e=>{var t,r,n;return Q(`${We}/salesByUser/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &seller=true&${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},wO=e=>{var t,r,n;return Q(`${We}/salesByUser/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &seller=true&${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},TO=e=>{var t,r,n;return Q(`${We}/ordersByUser/withTaxes?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        ${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""))},$O=e=>{var t,r,n;return Q(`${We}/ordersByUser/withoutTaxes?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        ${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""))},AO=e=>{var t,r,n;return Q(`${We}/ordersByUser/withTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        ${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},IO=e=>{var t,r,n;return Q(`${We}/ordersByUser/withoutTaxes/export?startDate=${e.startDate}&endDate=${e.endDate}&sortBy=${e.sort_by}&sortOder=${e.sort_order}
        &timeZone=${e.timeZone}&dateField=${e.dateField}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        ${((r=e==null?void 0:e.exclude_columns)==null?void 0:r.length)??!1?`&excludeColumns=${(n=e==null?void 0:e.exclude_columns)==null?void 0:n.map(a=>a)}`:""}
		`.replace(/\s/g,""),{responseType:"blob"})},PO=e=>{var t;return Q(`${We}/agentCreditsReport/export?
        ${e.date_range?`startDate=${e.startDate}&endDate=${e.endDate}`:""}&datePattern=${e.datePattern}
        &timeZone=${e.timeZone}&pageNumber=${e.pageNumber}
		&language=${e.language??((t=localStorage.getItem("lng"))==null?void 0:t.includes("en"))?"EN":"ES"}
        &agentType=CLIENT`.replace(/\s/g,""),{responseType:"blob"})},_O=e=>{var t,r,n,a,s,i,o,c,u;return Q(`${We}/agentPaymentsReport/export?
        ${e.date_range?`startDate=${e.start_date}&endDate=${e.end_date}`:""}&datePattern=${e.date_pattern}
        &timeZone=${e.time_zone}&pageNumber=${e.pageNumber}
        &dateFieldReport=${e.date_field}
		&language=${(t=localStorage.getItem("lng"))!=null&&t.includes("en")?"EN":"ES"}
        ${((r=Object.keys(e.agent))==null?void 0:r.length)>0?`&agentUuid=${(n=e.agent)==null?void 0:n.uuid}`:""}
        ${((a=Object.keys(e.cash_register))==null?void 0:a.length)>0?`&cashRegisterUuid=${(s=e.cash_register)==null?void 0:s.uuid}`:""}
        ${((i=Object.keys(e.user))==null?void 0:i.length)>0?`&userUuid=${(o=e.user)==null?void 0:o.uuid}`:""}
        ${((c=Object.keys(e.payment_type))==null?void 0:c.length)>0?`&paymentType=${(u=e.payment_type)==null?void 0:u.uuid}`:""}
        &agentType=CLIENT`.replace(/\s/g,""),{responseType:"blob"})},DO=({id:e,downloadable:t=!1,name:r=""})=>new Promise((n,a)=>{Q(`${fs}/pdf/sale/${e}?downloadable=${t}&name=${r}`).then(s=>{n(s)}).catch(s=>{a(s)})}),RO=({id:e,downloadable:t=!1,name:r=""})=>new Promise((n,a)=>{Q(`${fs}/pdf/purchase/${e}?downloadable=${t}&name=${r}`).then(s=>{n(s)}).catch(s=>{a(s)})}),NO={INC_CLIENT_PAYMENT:{key:"credit_payment",ns:"credits"},EXP_CLIENT_PAYMENT:{key:"credit_payment",ns:"credits"},INC_TRANSACTION:{key:"movement_ingress",ns:"global"},EXP_TRANSACTION:{key:"movement_egress",ns:"global"},INC_SALE:{key:"sale",ns:"global"},EXP_SALE:{key:"sale_canceled",ns:"document"},INC_CHANGE:{key:"changeMoney_ingress",ns:"document"},EXP_CHANGE:{key:"changeMoney_egress",ns:"document"},INC_PURCHASE:{key:"purchase",ns:"document"},EXP_PURCHASE:{key:"purchase",ns:"document"}};var UP=(e=>(e[e.DUPLICATE=400]="DUPLICATE",e[e.INUSE=401]="INUSE",e[e.NOTFOUND=404]="NOTFOUND",e))(UP||{}),LP=(e=>(e[e.UNIT_NOTFOUND=790526]="UNIT_NOTFOUND",e[e.DEPARTMENT_NOTFOUND=3385]="DEPARTMENT_NOTFOUND",e[e.CATEGORY_NOTFOUND=3239]="CATEGORY_NOTFOUND",e[e.SKU_DUPLICATE=47806]="SKU_DUPLICATE",e[e.HAS_STOCK=22284]="HAS_STOCK",e[e.DESCRIPTION_REPEATED=401]="DESCRIPTION_REPEATED",e[e.NOTFOUND=404]="NOTFOUND",e))(LP||{}),MP=(e=>(e[e.INUSE=401]="INUSE",e[e.NOTFOUND=404]="NOTFOUND",e[e.TAXONTAX_NOTFOUND=72500]="TAXONTAX_NOTFOUND",e[e.TAX_EQUAL=72501]="TAX_EQUAL",e[e.INUSE_BY_PRICES=72502]="INUSE_BY_PRICES",e[e.TAX_EQUAL_AUTOMATIC=72509]="TAX_EQUAL_AUTOMATIC",e))(MP||{}),jP=(e=>(e.INCOME="INCOME",e.EXPENSE="EXPENSE",e))(jP||{});const BO=(e,t,r,n,a)=>{const s=new pe(`
        document(timezone:"`+e+'", date:"'+t+'", range:"'+r+'", doctype:"'+n+`"){
            totalDocuments
            totalDocumentsCanceled
            documentsGenerated
            documentsCanceled
            ticketAvg
            totalDiscount
            totalProfit
            totalPayments {
                total
                payment
            }
            totalByHour{
                total
                hour
            }
        }`).insertQuery(`
        totals(timezone:"`+e+'", date:"'+t+'", doctype:"'+n+`"){
            day
            month
            year
        }       
    `).insertQuery(`
        transaction(timezone : "`+e+'", date : "'+t+'" , range : "'+r+`"){
            totalIncome
            totalExpense
        }      
    `).insertQuery(`
        graphic(timezone:"`+e+'", date:"'+t+'", range:"'+r+'", doctype:"'+n+`"){
            now{
                total
                detail{
                    value
                    key
                }
            }
            before{
                total
                detail{
                    value
                    key
                }
            }
            last{
                total
                detail{
                    value
                    key
                }
            }
        }
    `).build();return new Promise((i,o)=>{$e.post(em+"dashboards",s,{transformResponse:[c=>hr(c)],headers:{"Content-Type":"application/graphql",...a&&{Authorization:a},...a&&{intercept:!1}}}).then(c=>i(pe.unwrap(c))).catch(c=>{o(c)})})},kO=(e,t,r,n,a)=>{const s=new pe(`
        document(timezone:"`+e+'", date:"'+t+'", range:"'+r+'", doctype:"'+n+`"){
            totalDocuments
            totalDocumentsCanceled
            documentsGenerated
            documentsCanceled
            ticketAvg
            totalDiscount
            totalPayments {
                total
                payment
            }
            totalByHour{
                total
                hour
            }
        }`).insertQuery(`
        totals(timezone:"`+e+'", date:"'+t+'", doctype:"'+n+`"){
            day
            month
            year
        }       
    `).insertQuery(`
        graphic(timezone:"`+e+'", date:"'+t+'", range:"'+r+'", doctype:"'+n+`"){
            now{
                total
                detail{
                    value
                    key
                }
            }
            before{
                total
                detail{
                    value
                    key
                }
            }
            last{
                total
                detail{
                    value
                    key
                }
            }
        }
    `).build();return new Promise((i,o)=>{$e.post(em+"dashboards",s,{transformResponse:[c=>hr(c)],headers:{"Content-Type":"application/graphql",...a&&{Authorization:a},...a&&{intercept:!1}}}).then(c=>i(pe.unwrap(c))).catch(c=>{o(c)})})},OO=My.useLiveQuery;My.useObservable;export{BN as $,KN as A,TN as B,Ca as C,Ot as D,_N as E,SN as F,$N as G,jB as H,sR as I,J6 as J,N3 as K,cN as L,s_ as M,ci as N,JD as O,QN as P,u5 as Q,Ry as R,RN as S,AN as T,IN as U,Xy as V,pN as W,GR as X,ON as Y,VR as Z,UT as _,$a as a,T5 as a$,eB as a0,tB as a1,nB as a2,J8 as a3,e_ as a4,UI as a5,EN as a6,xN as a7,mN as a8,kN as a9,Ht as aA,TR as aB,WN as aC,qI as aD,R5 as aE,MI as aF,nk as aG,ak as aH,o5 as aI,l5 as aJ,i5 as aK,s5 as aL,b5 as aM,d5 as aN,q8 as aO,zy as aP,S5 as aQ,Ad as aR,Gy as aS,V8 as aT,v5 as aU,p5 as aV,H8 as aW,z8 as aX,X8 as aY,t5 as aZ,r5 as a_,UN as aa,VN as ab,LN as ac,W8 as ad,Z3 as ae,Z8 as af,FN as ag,qN as ah,h5 as ai,hN as aj,me as ak,fN as al,iN as am,oN as an,aR as ao,qR as ap,Y8 as aq,dN as ar,wI as as,c5 as at,zN as au,MN as av,GN as aw,Hp as ax,ky as ay,oR as az,V3 as b,PR as b$,I5 as b0,to as b1,K8 as b2,g5 as b3,f5 as b4,m5 as b5,n5 as b6,G8 as b7,y5 as b8,rR as b9,rO as bA,nO as bB,jk as bC,Yk as bD,Xk as bE,Bk as bF,Hk as bG,$5 as bH,Jk as bI,sO as bJ,qk as bK,Kk as bL,IR as bM,O_ as bN,WP as bO,_o as bP,S_ as bQ,KI as bR,lB as bS,WD as bT,eD as bU,N5 as bV,jn as bW,v3 as bX,qB as bY,HB as bZ,P_ as b_,_l as ba,Hs as bb,tD as bc,J_ as bd,Dl as be,T_ as bf,Wy as bg,gD as bh,CD as bi,e5 as bj,f3 as bk,j4 as bl,M4 as bm,U4 as bn,B4 as bo,VD as bp,HD as bq,Et as br,MD as bs,zD as bt,qD as bu,FD as bv,x5 as bw,KD as bx,o6 as by,aO as bz,Oy as c,ID as c$,kR as c0,DI as c1,_5 as c2,a5 as c3,V$ as c4,dk as c5,AI as c6,K$ as c7,x_ as c8,E_ as c9,zR as cA,X3 as cB,s6 as cC,m6 as cD,Bf as cE,BB as cF,kB as cG,VB as cH,hB as cI,NO as cJ,JB as cK,H$ as cL,_y as cM,G5 as cN,MP as cO,UP as cP,C$ as cQ,D_ as cR,Qy as cS,j$ as cT,nD as cU,rD as cV,J$ as cW,B_ as cX,LP as cY,P5 as cZ,v_ as c_,PI as ca,bB as cb,YB as cc,ck as cd,ok as ce,NR as cf,Cr as cg,_R as ch,RR as ci,$R as cj,ZR as ck,uk as cl,XR as cm,AR as cn,Dk as co,nN as cp,mA as cq,h6 as cr,yR as cs,FB as ct,UB as cu,LB as cv,IB as cw,PB as cx,_B as cy,DB as cz,nR as d,OD as d$,$D as d0,TD as d1,AD as d2,FR as d3,ED as d4,xD as d5,m4 as d6,bR as d7,u6 as d8,vR as d9,V_ as dA,aD as dB,k_ as dC,OO as dD,A5 as dE,sD as dF,oB as dG,uB as dH,hD as dI,cB as dJ,fD as dK,iB as dL,sB as dM,y_ as dN,C_ as dO,lD as dP,h_ as dQ,U_ as dR,M_ as dS,L_ as dT,A_ as dU,$_ as dV,z$ as dW,__ as dX,dD as dY,W_ as dZ,Pr as d_,yD as da,fk as db,pk as dc,GB as dd,KB as de,w5 as df,bo as dg,dR as dh,hR as di,pR as dj,fR as dk,SR as dl,lR as dm,gR as dn,mR as dp,ER as dq,xR as dr,I_ as ds,CR as dt,QR as du,vD as dv,X_ as dw,iD as dx,Y$ as dy,Z$ as dz,DN as e,a$ as e$,kD as e0,mD as e1,j_ as e2,OR as e3,cD as e4,H_ as e5,q_ as e6,F_ as e7,gk as e8,bD as e9,pO as eA,AO as eB,IO as eC,PO as eD,_O as eE,Ck as eF,Sk as eG,Ek as eH,xk as eI,$k as eJ,Ak as eK,_k as eL,vk as eM,yk as eN,mk as eO,f6 as eP,Q_ as eQ,z_ as eR,G_ as eS,yO as eT,vO as eU,SO as eV,EO as eW,hO as eX,dO as eY,TO as eZ,$O as e_,pD as ea,N_ as eb,R_ as ec,BR as ed,tN as ee,l3 as ef,h3 as eg,n6 as eh,t6 as ei,I6 as ej,w6 as ek,T6 as el,$6 as em,_6 as en,MR as eo,jR as ep,E6 as eq,lO as er,uO as es,gO as et,mO as eu,bO as ev,CO as ew,xO as ex,wO as ey,fO as ez,yN as f,wk as f$,C5 as f0,XN as f1,JN as f2,t_ as f3,a_ as f4,n_ as f5,r_ as f6,sN as f7,Bl as f8,ha as f9,tO as fA,LR as fB,iO as fC,wD as fD,RO as fE,GD as fF,tR as fG,DR as fH,eR as fI,OB as fJ,RB as fK,ZB as fL,rk as fM,jP as fN,LD as fO,i_ as fP,l_ as fQ,QD as fR,Ik as fS,Pk as fT,yB as fU,vB as fV,uR as fW,c6 as fX,K_ as fY,oO as fZ,cO as f_,wR as fa,jT as fb,aB as fc,rB as fd,kO as fe,BO as ff,WI as fg,JT as fh,c_ as fi,UR as fj,tk as fk,ek as fl,d_ as fm,NB as fn,CN as fo,MB as fp,xB as fq,PD as fr,hk as fs,lk as ft,ik as fu,sk as fv,jD as fw,dB as fx,m_ as fy,Fk as fz,EI as g,BD as g$,Tk as g0,g4 as g1,AB as g2,TB as g3,$B as g4,wB as g5,QB as g6,mB as g7,WB as g8,XD as g9,pB as gA,fB as gB,gB as gC,DO as gD,kT as gE,XP as gF,YP as gG,ZP as gH,JP as gI,Ok as gJ,kk as gK,Uk as gL,Lk as gM,Qk as gN,Mk as gO,eO as gP,zk as gQ,Gk as gR,Vk as gS,Wk as gT,Zk as gU,b_ as gV,DD as gW,_D as gX,ND as gY,RD as gZ,w_ as g_,YD as ga,ZD as gb,bk as gc,EB as gd,CB as ge,SB as gf,c3 as gg,zB as gh,XB as gi,o_ as gj,u$ as gk,m$ as gl,SD as gm,UD as gn,d4 as go,Nk as gp,Rk as gq,u_ as gr,D5 as gs,f_ as gt,g_ as gu,Y_ as gv,cR as gw,Z_ as gx,oD as gy,uD as gz,iR as h,R6 as h0,HR as h1,vN as i,gN as j,wN as k,bN as l,I0 as m,uN as n,lN as o,jN as p,PN as q,YN as r,ZN as s,Q8 as t,NN as u,VP as v,an as w,KR as x,HN as y,E5 as z};
