avo-inspector 2.2.2-alpha.8 → 2.2.2-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{"use strict";var e={7678:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.aes256cbc=t.aes256gcm=void 0;var r=n(469);t.aes256gcm=function(e,t,n){return(0,r.gcm)(e,t,n)},t.aes256cbc=function(e,t,n){return(0,r.cbc)(e,t)}},83:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.chacha20=t.xchacha20=void 0;var r=n(8900);t.xchacha20=function(e,t,n){return(0,r.xchacha20poly1305)(e,t,n)},t.chacha20=function(e,t,n){return(0,r.chacha20poly1305)(e,t,n)}},2506:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rotl=function(e,t){return e<<t|e>>>32-t},t.createCipher=function(e,t){const{allowShortKeys:n,extendNonceFn:o,counterLength:s,counterRight:i,rounds:p}=(0,r.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return(0,r.anumber)(s),(0,r.anumber)(p),(0,r.abool)(i),(0,r.abool)(n),(t,y,g,v,m=0)=>{(0,r.abytes)(t),(0,r.abytes)(y),(0,r.abytes)(g);const b=g.length;if(void 0===v&&(v=new Uint8Array(b)),(0,r.abytes)(v),(0,r.anumber)(m),m<0||m>=h)throw new Error("arx: counter overflow");if(v.length<b)throw new Error(`arx: output (${v.length}) is shorter than data (${b})`);const w=[];let E,S,x=t.length;if(32===x)w.push(E=(0,r.copyBytes)(t)),S=c;else{if(16!==x||!n)throw new Error(`arx: invalid 32-byte key, got length=${x}`);E=new Uint8Array(32),E.set(t),E.set(t,16),S=a,w.push(E)}u(y)||w.push(y=(0,r.copyBytes)(y));const B=(0,r.u32)(E);if(o){if(24!==y.length)throw new Error("arx: extended nonce must be 24 bytes");o(S,B,(0,r.u32)(y.subarray(0,16)),B),y=y.subarray(16)}const I=16-s;if(I!==y.length)throw new Error(`arx: nonce must be ${I} or 16 bytes`);if(12!==I){const e=new Uint8Array(12);e.set(y,i?0:12-y.length),y=e,w.push(y)}const A=(0,r.u32)(y);return function(e,t,n,o,s,i,a,c){const p=s.length,y=new Uint8Array(l),g=(0,r.u32)(y),v=u(s)&&u(i),m=v?(0,r.u32)(s):d,b=v?(0,r.u32)(i):d;for(let r=0;r<p;a++){if(e(t,n,o,g,a,c),a>=h)throw new Error("arx: counter overflow");const u=Math.min(l,p-r);if(v&&u===l){const e=r/4;if(r%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<f;n++)t=e+n,b[t]=m[t]^g[n];r+=l}else{for(let e,t=0;t<u;t++)e=r+t,i[e]=s[e]^y[t];r+=u}}}(e,S,B,A,g,v,m,p),(0,r.clean)(...w),v}};const r=n(6527),o=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),s=o("expand 16-byte k"),i=o("expand 32-byte k"),a=(0,r.u32)(s),c=(0,r.u32)(i);function u(e){return e.byteOffset%4==0}const l=64,f=16,h=2**32-1,d=new Uint32Array},1210:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.poly1305=void 0,t.wrapConstructorWithKey=i;const r=n(6527),o=(e,t)=>255&e[t++]|(255&e[t++])<<8;class s{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=(0,r.toBytes)(e),(0,r.abytes)(e,32);const t=o(e,0),n=o(e,2),s=o(e,4),i=o(e,6),a=o(e,8),c=o(e,10),u=o(e,12),l=o(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|s<<6),this.r[3]=8191&(s>>>7|i<<9),this.r[4]=255&(i>>>4|a<<12),this.r[5]=a>>>1&8190,this.r[6]=8191&(a>>>14|c<<2),this.r[7]=8065&(c>>>11|u<<5),this.r[8]=8191&(u>>>8|l<<8),this.r[9]=l>>>5&127;for(let t=0;t<8;t++)this.pad[t]=o(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:s,r:i}=this,a=i[0],c=i[1],u=i[2],l=i[3],f=i[4],h=i[5],d=i[6],p=i[7],y=i[8],g=i[9],v=o(e,t+0),m=o(e,t+2),b=o(e,t+4),w=o(e,t+6),E=o(e,t+8),S=o(e,t+10),x=o(e,t+12),B=o(e,t+14);let I=s[0]+(8191&v),A=s[1]+(8191&(v>>>13|m<<3)),_=s[2]+(8191&(m>>>10|b<<6)),O=s[3]+(8191&(b>>>7|w<<9)),P=s[4]+(8191&(w>>>4|E<<12)),L=s[5]+(E>>>1&8191),T=s[6]+(8191&(E>>>14|S<<2)),H=s[7]+(8191&(S>>>11|x<<5)),C=s[8]+(8191&(x>>>8|B<<8)),R=s[9]+(B>>>5|r),F=0,N=F+I*a+A*(5*g)+_*(5*y)+O*(5*p)+P*(5*d);F=N>>>13,N&=8191,N+=L*(5*h)+T*(5*f)+H*(5*l)+C*(5*u)+R*(5*c),F+=N>>>13,N&=8191;let k=F+I*c+A*a+_*(5*g)+O*(5*y)+P*(5*p);F=k>>>13,k&=8191,k+=L*(5*d)+T*(5*h)+H*(5*f)+C*(5*l)+R*(5*u),F+=k>>>13,k&=8191;let V=F+I*u+A*c+_*a+O*(5*g)+P*(5*y);F=V>>>13,V&=8191,V+=L*(5*p)+T*(5*d)+H*(5*h)+C*(5*f)+R*(5*l),F+=V>>>13,V&=8191;let U=F+I*l+A*u+_*c+O*a+P*(5*g);F=U>>>13,U&=8191,U+=L*(5*y)+T*(5*p)+H*(5*d)+C*(5*h)+R*(5*f),F+=U>>>13,U&=8191;let K=F+I*f+A*l+_*u+O*c+P*a;F=K>>>13,K&=8191,K+=L*(5*g)+T*(5*y)+H*(5*p)+C*(5*d)+R*(5*h),F+=K>>>13,K&=8191;let j=F+I*h+A*f+_*l+O*u+P*c;F=j>>>13,j&=8191,j+=L*a+T*(5*g)+H*(5*y)+C*(5*p)+R*(5*d),F+=j>>>13,j&=8191;let M=F+I*d+A*h+_*f+O*l+P*u;F=M>>>13,M&=8191,M+=L*c+T*a+H*(5*g)+C*(5*y)+R*(5*p),F+=M>>>13,M&=8191;let D=F+I*p+A*d+_*h+O*f+P*l;F=D>>>13,D&=8191,D+=L*u+T*c+H*a+C*(5*g)+R*(5*y),F+=D>>>13,D&=8191;let q=F+I*y+A*p+_*d+O*h+P*f;F=q>>>13,q&=8191,q+=L*l+T*u+H*c+C*a+R*(5*g),F+=q>>>13,q&=8191;let Z=F+I*g+A*y+_*p+O*d+P*h;F=Z>>>13,Z&=8191,Z+=L*f+T*l+H*u+C*c+R*a,F+=Z>>>13,Z&=8191,F=(F<<2)+F|0,F=F+N|0,N=8191&F,F>>>=13,k+=F,s[0]=N,s[1]=k,s[2]=V,s[3]=U,s[4]=K,s[5]=j,s[6]=M,s[7]=D,s[8]=q,s[9]=Z}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let o=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=o,o=e[t]>>>13,e[t]&=8191;e[0]+=5*o,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,n[0]=e[0]+5,o=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+o,o=n[t]>>>13,n[t]&=8191;n[9]-=8192;let s=(1^o)-1;for(let e=0;e<10;e++)n[e]&=s;s=~s;for(let t=0;t<10;t++)e[t]=e[t]&s|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let i=e[0]+t[0];e[0]=65535&i;for(let n=1;n<8;n++)i=(e[n]+t[n]|0)+(i>>>16)|0,e[n]=65535&i;(0,r.clean)(n)}update(e){(0,r.aexists)(this),e=(0,r.toBytes)(e),(0,r.abytes)(e);const{buffer:t,blockLen:n}=this,o=e.length;for(let r=0;r<o;){const s=Math.min(n-this.pos,o-r);if(s!==n)t.set(e.subarray(r,r+s),this.pos),this.pos+=s,r+=s,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=o-r;r+=n)this.process(e,r)}return this}destroy(){(0,r.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:o}=this;if(o){for(t[o++]=1;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let s=0;for(let t=0;t<8;t++)e[s++]=n[t]>>>0,e[s++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function i(e){const t=(t,n)=>e(n).update((0,r.toBytes)(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}t.poly1305=i((e=>new s(e)))},22:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.polyval=t.ghash=void 0,t._toGHASHKey=c;const r=n(6527),o=16,s=new Uint8Array(16),i=(0,r.u32)(s),a=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255;function c(e){e.reverse();const t=1&e[15];let n=0;for(let t=0;t<e.length;t++){const r=e[t];e[t]=r>>>1|n,n=(1&r)<<7}return e[0]^=225&-t,e}class u{constructor(e,t){this.blockLen=o,this.outputLen=o,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=(0,r.toBytes)(e),(0,r.abytes)(e,16);const n=(0,r.createView)(e);let s=n.getUint32(0,!1),i=n.getUint32(4,!1),c=n.getUint32(8,!1),u=n.getUint32(12,!1);const l=[];for(let e=0;e<128;e++)l.push({s0:a(s),s1:a(i),s2:a(c),s3:a(u)}),({s0:s,s1:i,s2:c,s3:u}={s3:(d=c)<<31|(p=u)>>>1,s2:(h=i)<<31|d>>>1,s1:(f=s)<<31|h>>>1,s0:f>>>1^225<<24&-(1&p)});var f,h,d,p;const y=(g=t||1024)>65536?8:g>1024?4:2;var g;if(![1,2,4,8].includes(y))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=y;const v=128/y,m=this.windowSize=2**y,b=[];for(let e=0;e<v;e++)for(let t=0;t<m;t++){let n=0,r=0,o=0,s=0;for(let i=0;i<y;i++){if(!(t>>>y-i-1&1))continue;const{s0:a,s1:c,s2:u,s3:f}=l[y*e+i];n^=a,r^=c,o^=u,s^=f}b.push({s0:n,s1:r,s2:o,s3:s})}this.t=b}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;const{W:o,t:s,windowSize:i}=this;let a=0,c=0,u=0,l=0;const f=(1<<o)-1;let h=0;for(const d of[e,t,n,r])for(let e=0;e<4;e++){const t=d>>>8*e&255;for(let e=8/o-1;e>=0;e--){const n=t>>>o*e&f,{s0:r,s1:d,s2:p,s3:y}=s[h*i+n];a^=r,c^=d,u^=p,l^=y,h+=1}}this.s0=a,this.s1=c,this.s2=u,this.s3=l}update(e){(0,r.aexists)(this),e=(0,r.toBytes)(e),(0,r.abytes)(e);const t=(0,r.u32)(e),n=Math.floor(e.length/o),a=e.length%o;for(let e=0;e<n;e++)this._updateBlock(t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]);return a&&(s.set(e.subarray(n*o)),this._updateBlock(i[0],i[1],i[2],i[3]),(0,r.clean)(i)),this}destroy(){const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{s0:t,s1:n,s2:o,s3:s}=this,i=(0,r.u32)(e);return i[0]=t,i[1]=n,i[2]=o,i[3]=s,e}digest(){const e=new Uint8Array(o);return this.digestInto(e),this.destroy(),e}}class l extends u{constructor(e,t){e=(0,r.toBytes)(e),(0,r.abytes)(e);const n=c((0,r.copyBytes)(e));super(n,t),(0,r.clean)(n)}update(e){e=(0,r.toBytes)(e),(0,r.aexists)(this);const t=(0,r.u32)(e),n=e.length%o,c=Math.floor(e.length/o);for(let e=0;e<c;e++)this._updateBlock(a(t[4*e+3]),a(t[4*e+2]),a(t[4*e+1]),a(t[4*e+0]));return n&&(s.set(e.subarray(c*o)),this._updateBlock(a(i[3]),a(i[2]),a(i[1]),a(i[0])),(0,r.clean)(i)),this}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{s0:t,s1:n,s2:o,s3:s}=this,i=(0,r.u32)(e);return i[0]=t,i[1]=n,i[2]=o,i[3]=s,e.reverse()}}function f(e){const t=(t,n)=>e(n,t.length).update((0,r.toBytes)(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}t.ghash=f(((e,t)=>new u(e,t))),t.polyval=f(((e,t)=>new l(e,t)))},469:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unsafe=t.aeskwp=t.aeskw=t.siv=t.gcmsiv=t.gcm=t.cfb=t.cbc=t.ecb=t.ctr=void 0;const r=n(22),o=n(6527),s=16,i=new Uint8Array(s),a=283;function c(e){return e<<1^a&-(e>>7)}function u(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=c(e);return n}const l=(()=>{const e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=c(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return(0,o.clean)(e),t})(),f=l.map(((e,t)=>l.indexOf(t))),h=e=>e<<24|e>>>8,d=e=>e<<8|e>>>24,p=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function y(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((n,r)=>t(e[r]))),r=n.map(d),o=r.map(d),s=o.map(d),i=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let u=0;u<256;u++){const l=256*t+u;i[l]=n[t]^r[u],a[l]=o[t]^s[u],c[l]=e[t]<<8|e[u]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:o,T3:s,T01:i,T23:a}}const g=y(l,(e=>u(e,3)<<24|e<<16|e<<8|u(e,2))),v=y(f,(e=>u(e,11)<<24|u(e,13)<<16|u(e,9)<<8|u(e,14))),m=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=c(n))e[t]=n;return e})();function b(e){(0,o.abytes)(e);const t=e.length;if(![16,24,32].includes(t))throw new Error("aes: invalid key size, should be 16, 24 or 32, got "+t);const{sbox2:n}=g,r=[];(0,o.isAligned32)(e)||r.push(e=(0,o.copyBytes)(e));const s=(0,o.u32)(e),i=s.length,a=e=>S(n,e,e,e,e),c=new Uint32Array(t+28);c.set(s);for(let e=i;e<c.length;e++){let t=c[e-1];e%i==0?t=a(h(t))^m[e/i-1]:i>6&&e%i==4&&(t=a(t)),c[e]=c[e-i]^t}return(0,o.clean)(...r),c}function w(e){const t=b(e),n=t.slice(),r=t.length,{sbox2:s}=g,{T0:i,T1:a,T2:c,T3:u}=v;for(let e=0;e<r;e+=4)for(let o=0;o<4;o++)n[e+o]=t[r-e-4+o];(0,o.clean)(t);for(let e=4;e<r-4;e++){const t=n[e],r=S(s,t,t,t,t);n[e]=i[255&r]^a[r>>>8&255]^c[r>>>16&255]^u[r>>>24]}return n}function E(e,t,n,r,o,s){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|s>>>24&255]}function S(e,t,n,r,o){return e[255&t|65280&n]|e[r>>>16&255|o>>>16&65280]<<16}function x(e,t,n,r,o){const{sbox2:s,T01:i,T23:a}=g;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],o^=e[c++];const u=e.length/4-2;for(let s=0;s<u;s++){const s=e[c++]^E(i,a,t,n,r,o),u=e[c++]^E(i,a,n,r,o,t),l=e[c++]^E(i,a,r,o,t,n),f=e[c++]^E(i,a,o,t,n,r);t=s,n=u,r=l,o=f}return{s0:e[c++]^S(s,t,n,r,o),s1:e[c++]^S(s,n,r,o,t),s2:e[c++]^S(s,r,o,t,n),s3:e[c++]^S(s,o,t,n,r)}}function B(e,t,n,r,o){const{sbox2:s,T01:i,T23:a}=v;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],o^=e[c++];const u=e.length/4-2;for(let s=0;s<u;s++){const s=e[c++]^E(i,a,t,o,r,n),u=e[c++]^E(i,a,n,t,o,r),l=e[c++]^E(i,a,r,n,t,o),f=e[c++]^E(i,a,o,r,n,t);t=s,n=u,r=l,o=f}return{s0:e[c++]^S(s,t,o,r,n),s1:e[c++]^S(s,n,t,o,r),s2:e[c++]^S(s,r,n,t,o),s3:e[c++]^S(s,o,r,n,t)}}function I(e,t,n,r){(0,o.abytes)(t,s),(0,o.abytes)(n);const i=n.length;r=(0,o.getOutput)(i,r),(0,o.complexOverlapBytes)(n,r);const a=t,c=(0,o.u32)(a);let{s0:u,s1:l,s2:f,s3:h}=x(e,c[0],c[1],c[2],c[3]);const d=(0,o.u32)(n),p=(0,o.u32)(r);for(let t=0;t+4<=d.length;t+=4){p[t+0]=d[t+0]^u,p[t+1]=d[t+1]^l,p[t+2]=d[t+2]^f,p[t+3]=d[t+3]^h;let n=1;for(let e=a.length-1;e>=0;e--)n=n+(255&a[e])|0,a[e]=255&n,n>>>=8;({s0:u,s1:l,s2:f,s3:h}=x(e,c[0],c[1],c[2],c[3]))}const y=s*Math.floor(d.length/4);if(y<i){const e=new Uint32Array([u,l,f,h]),t=(0,o.u8)(e);for(let e=y,o=0;e<i;e++,o++)r[e]=n[e]^t[o];(0,o.clean)(e)}return r}function A(e,t,n,r,i){(0,o.abytes)(n,s),(0,o.abytes)(r),i=(0,o.getOutput)(r.length,i);const a=n,c=(0,o.u32)(a),u=(0,o.createView)(a),l=(0,o.u32)(r),f=(0,o.u32)(i),h=t?0:12,d=r.length;let p=u.getUint32(h,t),{s0:y,s1:g,s2:v,s3:m}=x(e,c[0],c[1],c[2],c[3]);for(let n=0;n+4<=l.length;n+=4)f[n+0]=l[n+0]^y,f[n+1]=l[n+1]^g,f[n+2]=l[n+2]^v,f[n+3]=l[n+3]^m,p=p+1>>>0,u.setUint32(h,p,t),({s0:y,s1:g,s2:v,s3:m}=x(e,c[0],c[1],c[2],c[3]));const b=s*Math.floor(l.length/4);if(b<d){const e=new Uint32Array([y,g,v,m]),t=(0,o.u8)(e);for(let e=b,n=0;e<d;e++,n++)i[e]=r[e]^t[n];(0,o.clean)(e)}return i}function _(e){if((0,o.abytes)(e),e.length%s!=0)throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size 16")}function O(e,t,n){(0,o.abytes)(e);let r=e.length;const i=r%s;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,o.isAligned32)(e)||(e=(0,o.copyBytes)(e));const a=(0,o.u32)(e);if(t){let e=s-i;e||(e=s),r+=e}return n=(0,o.getOutput)(r,n),(0,o.complexOverlapBytes)(e,n),{b:a,o:(0,o.u32)(n),out:n}}function P(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const o=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function L(e){const t=new Uint8Array(16),n=(0,o.u32)(t);t.set(e);const r=s-e.length;for(let e=s-r;e<s;e++)t[e]=r;return n}function T(e,t,n,r,s){const i=s?s.length:0,a=e.create(n,r.length+i);s&&a.update(s);const c=(0,o.u64Lengths)(8*r.length,8*i,t);a.update(r),a.update(c);const u=a.digest();return(0,o.clean)(c),u}t.ctr=(0,o.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r){if((0,o.abytes)(n),void 0!==r&&((0,o.abytes)(r),!(0,o.isAligned32)(r)))throw new Error("unaligned destination");const s=b(e),i=(0,o.copyBytes)(t),a=[s,i];(0,o.isAligned32)(n)||a.push(n=(0,o.copyBytes)(n));const c=I(s,i,n,r);return(0,o.clean)(...a),c}return{encrypt:(e,t)=>n(e,t),decrypt:(e,t)=>n(e,t)}})),t.ecb=(0,o.wrapCipher)({blockSize:16},(function(e,t={}){const n=!t.disablePadding;return{encrypt(t,r){const{b:s,o:i,out:a}=O(t,n,r),c=b(e);let u=0;for(;u+4<=s.length;){const{s0:e,s1:t,s2:n,s3:r}=x(c,s[u+0],s[u+1],s[u+2],s[u+3]);i[u++]=e,i[u++]=t,i[u++]=n,i[u++]=r}if(n){const e=L(t.subarray(4*u)),{s0:n,s1:r,s2:o,s3:s}=x(c,e[0],e[1],e[2],e[3]);i[u++]=n,i[u++]=r,i[u++]=o,i[u++]=s}return(0,o.clean)(c),a},decrypt(t,r){_(t);const s=w(e);r=(0,o.getOutput)(t.length,r);const i=[s];(0,o.isAligned32)(t)||i.push(t=(0,o.copyBytes)(t)),(0,o.complexOverlapBytes)(t,r);const a=(0,o.u32)(t),c=(0,o.u32)(r);for(let e=0;e+4<=a.length;){const{s0:t,s1:n,s2:r,s3:o}=B(s,a[e+0],a[e+1],a[e+2],a[e+3]);c[e++]=t,c[e++]=n,c[e++]=r,c[e++]=o}return(0,o.clean)(...i),P(r,n)}}})),t.cbc=(0,o.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t,n={}){const r=!n.disablePadding;return{encrypt(n,s){const i=b(e),{b:a,o:c,out:u}=O(n,r,s);let l=t;const f=[i];(0,o.isAligned32)(l)||f.push(l=(0,o.copyBytes)(l));const h=(0,o.u32)(l);let d=h[0],p=h[1],y=h[2],g=h[3],v=0;for(;v+4<=a.length;)d^=a[v+0],p^=a[v+1],y^=a[v+2],g^=a[v+3],({s0:d,s1:p,s2:y,s3:g}=x(i,d,p,y,g)),c[v++]=d,c[v++]=p,c[v++]=y,c[v++]=g;if(r){const e=L(n.subarray(4*v));d^=e[0],p^=e[1],y^=e[2],g^=e[3],({s0:d,s1:p,s2:y,s3:g}=x(i,d,p,y,g)),c[v++]=d,c[v++]=p,c[v++]=y,c[v++]=g}return(0,o.clean)(...f),u},decrypt(n,s){_(n);const i=w(e);let a=t;const c=[i];(0,o.isAligned32)(a)||c.push(a=(0,o.copyBytes)(a));const u=(0,o.u32)(a);s=(0,o.getOutput)(n.length,s),(0,o.isAligned32)(n)||c.push(n=(0,o.copyBytes)(n)),(0,o.complexOverlapBytes)(n,s);const l=(0,o.u32)(n),f=(0,o.u32)(s);let h=u[0],d=u[1],p=u[2],y=u[3];for(let e=0;e+4<=l.length;){const t=h,n=d,r=p,o=y;h=l[e+0],d=l[e+1],p=l[e+2],y=l[e+3];const{s0:s,s1:a,s2:c,s3:u}=B(i,h,d,p,y);f[e++]=s^t,f[e++]=a^n,f[e++]=c^r,f[e++]=u^o}return(0,o.clean)(...c),P(s,r)}}})),t.cfb=(0,o.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r,i){(0,o.abytes)(n);const a=n.length;if(i=(0,o.getOutput)(a,i),(0,o.overlapBytes)(n,i))throw new Error("overlapping src and dst not supported.");const c=b(e);let u=t;const l=[c];(0,o.isAligned32)(u)||l.push(u=(0,o.copyBytes)(u)),(0,o.isAligned32)(n)||l.push(n=(0,o.copyBytes)(n));const f=(0,o.u32)(n),h=(0,o.u32)(i),d=r?h:f,p=(0,o.u32)(u);let y=p[0],g=p[1],v=p[2],m=p[3];for(let e=0;e+4<=f.length;){const{s0:t,s1:n,s2:r,s3:o}=x(c,y,g,v,m);h[e+0]=f[e+0]^t,h[e+1]=f[e+1]^n,h[e+2]=f[e+2]^r,h[e+3]=f[e+3]^o,y=d[e++],g=d[e++],v=d[e++],m=d[e++]}const w=s*Math.floor(f.length/4);if(w<a){({s0:y,s1:g,s2:v,s3:m}=x(c,y,g,v,m));const e=(0,o.u8)(new Uint32Array([y,g,v,m]));for(let t=w,r=0;t<a;t++,r++)i[t]=n[t]^e[r];(0,o.clean)(e)}return(0,o.clean)(...l),i}return{encrypt:(e,t)=>n(e,!0,t),decrypt:(e,t)=>n(e,!1,t)}})),t.gcm=(0,o.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},(function(e,t,n){if(t.length<8)throw new Error("aes/gcm: invalid nonce length");function s(e,t,o){const s=T(r.ghash,!1,e,o,n);for(let e=0;e<t.length;e++)s[e]^=t[e];return s}function a(){const n=b(e),s=i.slice(),a=i.slice();if(A(n,!1,a,a,s),12===t.length)a.set(t);else{const e=i.slice(),n=(0,o.createView)(e);(0,o.setBigUint64)(n,8,BigInt(8*t.length),!1);const c=r.ghash.create(s).update(t).update(e);c.digestInto(a),c.destroy()}return{xk:n,authKey:s,counter:a,tagMask:A(n,!1,a,i)}}return{encrypt(e){const{xk:t,authKey:n,counter:r,tagMask:i}=a(),c=new Uint8Array(e.length+16),u=[t,n,r,i];(0,o.isAligned32)(e)||u.push(e=(0,o.copyBytes)(e)),A(t,!1,r,e,c.subarray(0,e.length));const l=s(n,i,c.subarray(0,c.length-16));return u.push(l),c.set(l,e.length),(0,o.clean)(...u),c},decrypt(e){const{xk:t,authKey:n,counter:r,tagMask:i}=a(),c=[t,n,i,r];(0,o.isAligned32)(e)||c.push(e=(0,o.copyBytes)(e));const u=e.subarray(0,-16),l=e.subarray(-16),f=s(n,i,u);if(c.push(f),!(0,o.equalBytes)(f,l))throw new Error("aes/gcm: invalid ghash tag");const h=A(t,!1,r,u);return(0,o.clean)(...c),h}}}));const H=(e,t,n)=>r=>{if(!Number.isSafeInteger(r)||t>r||r>n)throw new Error(e+": expected value in range ["+t+".."+n+"], got "+r)};function C(e){return e instanceof Uint32Array||ArrayBuffer.isView(e)&&"Uint32Array"===e.constructor.name}function R(e,t){if((0,o.abytes)(t,16),!C(e))throw new Error("_encryptBlock accepts result of expandKeyLE");const n=(0,o.u32)(t);let{s0:r,s1:s,s2:i,s3:a}=x(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=s,n[2]=i,n[3]=a,t}function F(e,t){if((0,o.abytes)(t,16),!C(e))throw new Error("_decryptBlock accepts result of expandKeyLE");const n=(0,o.u32)(t);let{s0:r,s1:s,s2:i,s3:a}=B(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=s,n[2]=i,n[3]=a,t}t.gcmsiv=(0,o.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},(function(e,t,n){const s=H("AAD",0,2**36),i=H("plaintext",0,2**36),a=H("nonce",12,12),c=H("ciphertext",16,2**36+16);function u(){const n=b(e),r=new Uint8Array(e.length),s=new Uint8Array(16),i=[n,r];let a=t;(0,o.isAligned32)(a)||i.push(a=(0,o.copyBytes)(a));const c=(0,o.u32)(a);let u=0,l=c[0],f=c[1],h=c[2],d=0;for(const e of[s,r].map(o.u32)){const t=(0,o.u32)(e);for(let e=0;e<t.length;e+=2){const{s0:r,s1:o}=x(n,u,l,f,h);t[e+0]=r,t[e+1]=o,u=++d}}const p={authKey:s,encKey:b(r)};return(0,o.clean)(...i),p}function l(e,s,i){const a=T(r.polyval,!0,s,i,n);for(let e=0;e<12;e++)a[e]^=t[e];a[15]&=127;const c=(0,o.u32)(a);let u=c[0],l=c[1],f=c[2],h=c[3];return({s0:u,s1:l,s2:f,s3:h}=x(e,u,l,f,h)),c[0]=u,c[1]=l,c[2]=f,c[3]=h,a}function f(e,t,n){let r=(0,o.copyBytes)(t);r[15]|=128;const s=A(e,!0,r,n);return(0,o.clean)(r),s}return(0,o.abytes)(e,16,24,32),a(t.length),void 0!==n&&s(n.length),{encrypt(e){i(e.length);const{encKey:t,authKey:n}=u(),r=l(t,n,e),s=[t,n,r];(0,o.isAligned32)(e)||s.push(e=(0,o.copyBytes)(e));const a=new Uint8Array(e.length+16);return a.set(r,e.length),a.set(f(t,r,e)),(0,o.clean)(...s),a},decrypt(e){c(e.length);const t=e.subarray(-16),{encKey:n,authKey:r}=u(),s=[n,r];(0,o.isAligned32)(e)||s.push(e=(0,o.copyBytes)(e));const i=f(n,t,e.subarray(0,-16)),a=l(n,r,i);if(s.push(a),!(0,o.equalBytes)(t,a))throw(0,o.clean)(...s),new Error("invalid polyval tag");return(0,o.clean)(...s),i}}})),t.siv=t.gcmsiv;const N={encrypt(e,t){if(t.length>=2**32)throw new Error("plaintext should be less than 4gb");const n=b(e);if(16===t.length)R(n,t);else{const e=(0,o.u32)(t);let r=e[0],s=e[1];for(let t=0,o=1;t<6;t++)for(let t=2;t<e.length;t+=2,o++){const{s0:i,s1:a,s2:c,s3:u}=x(n,r,s,e[t],e[t+1]);r=i,s=a^p(o),e[t]=c,e[t+1]=u}e[0]=r,e[1]=s}n.fill(0)},decrypt(e,t){if(t.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const n=w(e),r=t.length/8-1;if(1===r)F(n,t);else{const e=(0,o.u32)(t);let s=e[0],i=e[1];for(let t=0,o=6*r;t<6;t++)for(let t=2*r;t>=1;t-=2,o--){i^=p(o);const{s0:r,s1:a,s2:c,s3:u}=B(n,s,i,e[t],e[t+1]);s=r,i=a,e[t]=c,e[t+1]=u}e[0]=s,e[1]=i}n.fill(0)}},k=new Uint8Array(8).fill(166);t.aeskw=(0,o.wrapCipher)({blockSize:8},(e=>({encrypt(t){if(!t.length||t.length%8!=0)throw new Error("invalid plaintext length");if(8===t.length)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const n=(0,o.concatBytes)(k,t);return N.encrypt(e,n),n},decrypt(t){if(t.length%8!=0||t.length<24)throw new Error("invalid ciphertext length");const n=(0,o.copyBytes)(t);if(N.decrypt(e,n),!(0,o.equalBytes)(n.subarray(0,8),k))throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8)}})));const V=2790873510;t.aeskwp=(0,o.wrapCipher)({blockSize:8},(e=>({encrypt(t){if(!t.length)throw new Error("invalid plaintext length");const n=8*Math.ceil(t.length/8),r=new Uint8Array(8+n);r.set(t,8);const s=(0,o.u32)(r);return s[0]=V,s[1]=p(t.length),N.encrypt(e,r),r},decrypt(t){if(t.length<16)throw new Error("invalid ciphertext length");const n=(0,o.copyBytes)(t),r=(0,o.u32)(n);N.decrypt(e,n);const s=p(r[1])>>>0,i=8*Math.ceil(s/8);if(r[0]!==V||n.length-8!==i)throw new Error("integrity check failed");for(let e=s;e<i;e++)if(0!==n[8+e])throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8,8+s)}}))),t.unsafe={expandKeyLE:b,expandKeyDecLE:w,encrypt:x,decrypt:B,encryptBlock:R,decryptBlock:F,ctrCounter:I,ctr32:A}},8900:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xchacha20poly1305=t.chacha20poly1305=t._poly1305_aead=t.chacha12=t.chacha8=t.xchacha20=t.chacha20=t.chacha20orig=void 0,t.hchacha=a;const r=n(2506),o=n(1210),s=n(6527);function i(e,t,n,o,s,i=20){let a=e[0],c=e[1],u=e[2],l=e[3],f=t[0],h=t[1],d=t[2],p=t[3],y=t[4],g=t[5],v=t[6],m=t[7],b=s,w=n[0],E=n[1],S=n[2],x=a,B=c,I=u,A=l,_=f,O=h,P=d,L=p,T=y,H=g,C=v,R=m,F=b,N=w,k=E,V=S;for(let e=0;e<i;e+=2)x=x+_|0,F=(0,r.rotl)(F^x,16),T=T+F|0,_=(0,r.rotl)(_^T,12),x=x+_|0,F=(0,r.rotl)(F^x,8),T=T+F|0,_=(0,r.rotl)(_^T,7),B=B+O|0,N=(0,r.rotl)(N^B,16),H=H+N|0,O=(0,r.rotl)(O^H,12),B=B+O|0,N=(0,r.rotl)(N^B,8),H=H+N|0,O=(0,r.rotl)(O^H,7),I=I+P|0,k=(0,r.rotl)(k^I,16),C=C+k|0,P=(0,r.rotl)(P^C,12),I=I+P|0,k=(0,r.rotl)(k^I,8),C=C+k|0,P=(0,r.rotl)(P^C,7),A=A+L|0,V=(0,r.rotl)(V^A,16),R=R+V|0,L=(0,r.rotl)(L^R,12),A=A+L|0,V=(0,r.rotl)(V^A,8),R=R+V|0,L=(0,r.rotl)(L^R,7),x=x+O|0,V=(0,r.rotl)(V^x,16),C=C+V|0,O=(0,r.rotl)(O^C,12),x=x+O|0,V=(0,r.rotl)(V^x,8),C=C+V|0,O=(0,r.rotl)(O^C,7),B=B+P|0,F=(0,r.rotl)(F^B,16),R=R+F|0,P=(0,r.rotl)(P^R,12),B=B+P|0,F=(0,r.rotl)(F^B,8),R=R+F|0,P=(0,r.rotl)(P^R,7),I=I+L|0,N=(0,r.rotl)(N^I,16),T=T+N|0,L=(0,r.rotl)(L^T,12),I=I+L|0,N=(0,r.rotl)(N^I,8),T=T+N|0,L=(0,r.rotl)(L^T,7),A=A+_|0,k=(0,r.rotl)(k^A,16),H=H+k|0,_=(0,r.rotl)(_^H,12),A=A+_|0,k=(0,r.rotl)(k^A,8),H=H+k|0,_=(0,r.rotl)(_^H,7);let U=0;o[U++]=a+x|0,o[U++]=c+B|0,o[U++]=u+I|0,o[U++]=l+A|0,o[U++]=f+_|0,o[U++]=h+O|0,o[U++]=d+P|0,o[U++]=p+L|0,o[U++]=y+T|0,o[U++]=g+H|0,o[U++]=v+C|0,o[U++]=m+R|0,o[U++]=b+F|0,o[U++]=w+N|0,o[U++]=E+k|0,o[U++]=S+V|0}function a(e,t,n,o){let s=e[0],i=e[1],a=e[2],c=e[3],u=t[0],l=t[1],f=t[2],h=t[3],d=t[4],p=t[5],y=t[6],g=t[7],v=n[0],m=n[1],b=n[2],w=n[3];for(let e=0;e<20;e+=2)s=s+u|0,v=(0,r.rotl)(v^s,16),d=d+v|0,u=(0,r.rotl)(u^d,12),s=s+u|0,v=(0,r.rotl)(v^s,8),d=d+v|0,u=(0,r.rotl)(u^d,7),i=i+l|0,m=(0,r.rotl)(m^i,16),p=p+m|0,l=(0,r.rotl)(l^p,12),i=i+l|0,m=(0,r.rotl)(m^i,8),p=p+m|0,l=(0,r.rotl)(l^p,7),a=a+f|0,b=(0,r.rotl)(b^a,16),y=y+b|0,f=(0,r.rotl)(f^y,12),a=a+f|0,b=(0,r.rotl)(b^a,8),y=y+b|0,f=(0,r.rotl)(f^y,7),c=c+h|0,w=(0,r.rotl)(w^c,16),g=g+w|0,h=(0,r.rotl)(h^g,12),c=c+h|0,w=(0,r.rotl)(w^c,8),g=g+w|0,h=(0,r.rotl)(h^g,7),s=s+l|0,w=(0,r.rotl)(w^s,16),y=y+w|0,l=(0,r.rotl)(l^y,12),s=s+l|0,w=(0,r.rotl)(w^s,8),y=y+w|0,l=(0,r.rotl)(l^y,7),i=i+f|0,v=(0,r.rotl)(v^i,16),g=g+v|0,f=(0,r.rotl)(f^g,12),i=i+f|0,v=(0,r.rotl)(v^i,8),g=g+v|0,f=(0,r.rotl)(f^g,7),a=a+h|0,m=(0,r.rotl)(m^a,16),d=d+m|0,h=(0,r.rotl)(h^d,12),a=a+h|0,m=(0,r.rotl)(m^a,8),d=d+m|0,h=(0,r.rotl)(h^d,7),c=c+u|0,b=(0,r.rotl)(b^c,16),p=p+b|0,u=(0,r.rotl)(u^p,12),c=c+u|0,b=(0,r.rotl)(b^c,8),p=p+b|0,u=(0,r.rotl)(u^p,7);let E=0;o[E++]=s,o[E++]=i,o[E++]=a,o[E++]=c,o[E++]=v,o[E++]=m,o[E++]=b,o[E++]=w}t.chacha20orig=(0,r.createCipher)(i,{counterRight:!1,counterLength:8,allowShortKeys:!0}),t.chacha20=(0,r.createCipher)(i,{counterRight:!1,counterLength:4,allowShortKeys:!1}),t.xchacha20=(0,r.createCipher)(i,{counterRight:!1,counterLength:8,extendNonceFn:a,allowShortKeys:!1}),t.chacha8=(0,r.createCipher)(i,{counterRight:!1,counterLength:4,rounds:8}),t.chacha12=(0,r.createCipher)(i,{counterRight:!1,counterLength:4,rounds:12});const c=new Uint8Array(16),u=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(c.subarray(n))},l=new Uint8Array(32);function f(e,t,n,r,i){const a=e(t,n,l),c=o.poly1305.create(a);i&&u(c,i),u(c,r);const f=(0,s.u64Lengths)(r.length,i?i.length:0,!0);c.update(f);const h=c.digest();return(0,s.clean)(a,f),h}t._poly1305_aead=e=>(t,n,r)=>({encrypt(o,i){const a=o.length;(i=(0,s.getOutput)(a+16,i,!1)).set(o);const c=i.subarray(0,-16);e(t,n,c,c,1);const u=f(e,t,n,c,r);return i.set(u,a),(0,s.clean)(u),i},decrypt(o,i){i=(0,s.getOutput)(o.length-16,i,!1);const a=o.subarray(0,-16),c=o.subarray(-16),u=f(e,t,n,a,r);if(!(0,s.equalBytes)(c,u))throw new Error("invalid tag");return i.set(o.subarray(0,-16)),e(t,n,i,i,1),(0,s.clean)(u),i}}),t.chacha20poly1305=(0,s.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,t._poly1305_aead)(t.chacha20)),t.xchacha20poly1305=(0,s.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,t._poly1305_aead)(t.xchacha20))},5297:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},6527:(e,t)=>{function n(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function r(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function o(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!n(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function i(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapCipher=t.Hash=t.nextTick=t.isLE=void 0,t.isBytes=n,t.abool=r,t.anumber=o,t.abytes=s,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");o(e.outputLen),o(e.blockLen)},t.aexists=function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},t.aoutput=function(e,t){s(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=i,t.bytesToHex=u,t.hexToBytes=h,t.hexToNumber=d,t.bytesToNumberBE=function(e){return d(u(e))},t.numberToBytesBE=function(e,t){return h(e.toString(16).padStart(2*t,"0"))},t.utf8ToBytes=p,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=function(e){if("string"==typeof e)e=p(e);else{if(!n(e))throw new Error("Uint8Array expected, got "+typeof e);e=m(e)}return e},t.overlapBytes=y,t.complexOverlapBytes=function(e,t){if(y(e,t)&&e.byteOffset<t.byteOffset)throw new Error("complex overlap of input and output is not supported")},t.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];s(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n},t.checkOpts=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)},t.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},t.getOutput=function(e,t,n=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(n&&!v(t))throw new Error("invalid output, must be aligned");return t},t.setBigUint64=g,t.u64Lengths=function(e,t,n){r(n);const o=new Uint8Array(16),s=i(o);return g(s,0,BigInt(t),n),g(s,8,BigInt(e),n),o},t.isAligned32=v,t.copyBytes=m,t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];const a=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),c=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function u(e){if(s(e),a)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=c[e[n]];return t}const l={_0:48,_9:57,A:65,F:70,a:97,f:102};function f(e){return e>=l._0&&e<=l._9?e-l._0:e>=l.A&&e<=l.F?e-(l.A-10):e>=l.a&&e<=l.f?e-(l.a-10):void 0}function h(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(a)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,o=0;t<n;t++,o+=2){const n=f(e.charCodeAt(o)),s=f(e.charCodeAt(o+1));if(void 0===n||void 0===s){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+s}return r}function d(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":"0x"+e)}function p(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function y(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function g(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}function v(e){return e.byteOffset%4==0}function m(e){return Uint8Array.from(e)}t.nextTick=async()=>{},t.Hash=class{},t.wrapCipher=(e,n)=>{function r(r,...o){if(s(r),!t.isLE)throw new Error("Non little-endian hardware is not yet supported");if(void 0!==e.nonceLength){const t=o[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?s(t):s(t,e.nonceLength)}const i=e.tagLength;i&&void 0!==o[1]&&s(o[1]);const a=n(r,...o),c=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");s(t)}};let u=!1;return{encrypt(e,t){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,s(e),c(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(s(e),i&&e.length<i)throw new Error("invalid ciphertext length: smaller than tagLength="+i);return c(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(r,e),r}},8489:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gcm=t.ctr=t.cbc=t.utils=void 0,t.randomBytes=s,t.getWebcryptoSubtle=i,t.managedNonce=function(e){const{nonceLength:t}=e;return(0,o.anumber)(t),(n,...r)=>({encrypt(i,...a){const c=s(t),u=e(n,c,...r).encrypt(i,...a),l=(0,o.concatBytes)(c,u);return u.fill(0),l},decrypt(o,...s){const i=o.subarray(0,t),a=o.subarray(t);return e(n,i,...r).decrypt(a,...s)}})};const r=n(5297),o=n(6527);function s(e=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(e));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return Uint8Array.from(r.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function i(){if(r.crypto&&"object"==typeof r.crypto.subtle&&null!=r.crypto.subtle)return r.crypto.subtle;throw new Error("crypto.subtle must be defined")}t.utils={async encrypt(e,t,n,r){const o=i(),s=await o.importKey("raw",e,t,!0,["encrypt"]),a=await o.encrypt(n,s,r);return new Uint8Array(a)},async decrypt(e,t,n,r){const o=i(),s=await o.importKey("raw",e,t,!0,["decrypt"]),a=await o.decrypt(n,s,r);return new Uint8Array(a)}};const a="AES-CBC",c="AES-CTR",u="AES-GCM";function l(e){return(n,r,s)=>{(0,o.abytes)(n),(0,o.abytes)(r);const i={name:e,length:8*n.length},l=function(e,t,n){if(e===a)return{name:a,iv:t};if(e===c)return{name:c,counter:t,length:64};if(e===u)return n?{name:u,iv:t,additionalData:n}:{name:u,iv:t};throw new Error("unknown aes block mode")}(e,r,s);let f=!1;return{encrypt(e){if((0,o.abytes)(e),f)throw new Error("Cannot encrypt() twice with same key / nonce");return f=!0,t.utils.encrypt(n,i,l,e)},decrypt:e=>((0,o.abytes)(e),t.utils.decrypt(n,i,l,e))}}}t.cbc=l(a),t.ctr=l(c),t.gcm=(()=>l(u))()},3562:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getHash=function(e){return{hash:e}},t.createCurve=function(e,t){const n=t=>(0,r.weierstrass)({...e,hash:t});return{...n(t),create:n}};const r=n(1705)},2422:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wNAF=void 0,t.negateCt=a,t.normalizeZ=function(e,t){const n=(0,o.FpInvertBatch)(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))},t.mulEndoUnsafe=function(e,t,n,r){let o=t,a=e.ZERO,c=e.ZERO;for(;n>s||r>s;)n&i&&(a=a.add(o)),r&i&&(c=c.add(o)),o=o.double(),n>>=i,r>>=i;return{p1:a,p2:c}},t.pippenger=function(e,t,n,o){f(n,e),h(o,t);const s=n.length,i=o.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,c=(0,r.bitLen)(BigInt(s));let u=1;c>12?u=c-3:c>4?u=c-2:c>0&&(u=2);const l=(0,r.bitMask)(u),d=new Array(Number(l)+1).fill(a);let p=a;for(let e=Math.floor((t.BITS-1)/u)*u;e>=0;e-=u){d.fill(a);for(let t=0;t<i;t++){const r=o[t],s=Number(r>>BigInt(e)&l);d[s]=d[s].add(n[t])}let t=a;for(let e=d.length-1,n=a;e>0;e--)n=n.add(d[e]),t=t.add(n);if(p=p.add(t),0!==e)for(let e=0;e<u;e++)p=p.double()}return p},t.precomputeMSMUnsafe=function(e,t,n,o){c(o,t.BITS),f(n,e);const s=e.ZERO,i=2**o-1,a=Math.ceil(t.BITS/o),u=(0,r.bitMask)(o),l=n.map((e=>{const t=[];for(let n=0,r=e;n<i;n++)t.push(r),r=r.add(e);return t}));return e=>{if(h(e,t),e.length>n.length)throw new Error("array of scalars must be smaller than array of points");let r=s;for(let t=0;t<a;t++){if(r!==s)for(let e=0;e<o;e++)r=r.double();const n=BigInt(a*o-(t+1)*o);for(let t=0;t<e.length;t++){const o=e[t],s=Number(o>>n&u);s&&(r=r.add(l[t][s-1]))}}return r}},t.validateBasic=function(e){return(0,o.validateField)(e.Fp),(0,r.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,o.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})},t._createCurveFields=function(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>s))throw new Error(`CURVE.${e} must be positive bigint`)}const o=v(t.p,n.Fp,r),i=v(t.n,n.Fn,r),a=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of a)if(!o.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:o,Fn:i}};const r=n(8627),o=n(4967),s=BigInt(0),i=BigInt(1);function a(e,t){const n=t.negate();return e?n:t}function c(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function u(e,t){c(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:(0,r.bitMask)(e),maxNumber:n,shiftBy:BigInt(e)}}function l(e,t,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:a}=n;let c=Number(e&o),u=e>>a;c>r&&(c-=s,u+=i);const l=t*r;return{nextN:u,offset:l+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:t%2!=0,offsetF:l}}function f(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}function h(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}const d=new WeakMap,p=new WeakMap;function y(e){return p.get(e)||1}function g(e){if(e!==s)throw new Error("invalid wNAF")}function v(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return(0,o.validateField)(t),t}return(0,o.Field)(e,{isLE:n})}t.wNAF=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>s;)t&i&&(n=n.add(r)),r=r.double(),t>>=i;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=u(t,this.bits),o=[];let s=e,i=s;for(let e=0;e<n;e++){i=s,o.push(i);for(let e=1;e<r;e++)i=i.add(s),o.push(i);s=i.double()}return o}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const s=u(e,this.bits);for(let e=0;e<s.windows;e++){const{nextN:i,offset:c,isZero:u,isNeg:f,isNegF:h,offsetF:d}=l(n,e,s);n=i,u?o=o.add(a(h,t[d])):r=r.add(a(f,t[c]))}return g(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=u(e,this.bits);for(let e=0;e<o.windows&&n!==s;e++){const{nextN:s,offset:i,isZero:a,isNeg:c}=l(n,e,o);if(n=s,!a){const e=t[i];r=r.add(c?e.negate():e)}}return g(n),r}getPrecomputes(e,t,n){let r=d.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),d.set(t,r))),r}cached(e,t,n){const r=y(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=y(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){c(t,this.bits),p.set(e,t),d.delete(e)}hasCache(e){return 1!==y(e)}}},6377:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PrimeEdwardsPoint=void 0,t.edwards=l,t.eddsa=f,t.twistedEdwards=function(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:o}=function(e){const t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:(0,s.Field)(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}(e,f(l(t,n),r,o))};const r=n(8627),o=n(2422),s=n(4967),i=BigInt(0),a=BigInt(1),c=BigInt(2),u=BigInt(8);function l(e,t={}){const n=(0,o._createCurveFields)("edwards",e,t,t.FpFnLE),{Fp:s,Fn:l}=n;let f=n.CURVE;const{h}=f;(0,r._validateObject)(t,{},{uvRatio:"function"});const d=c<<BigInt(8*l.BYTES)-a,p=e=>s.create(e),y=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:s.sqrt(s.div(e,t))}}catch(e){return{isValid:!1,value:i}}});if(!function(e,t,n,r){const o=e.sqr(n),s=e.sqr(r),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}(s,f,f.Gx,f.Gy))throw new Error("bad curve params: generator point");function g(e,t,n=!1){const o=n?a:i;return(0,r.aInRange)("coordinate "+e,t,o,d),t}function v(e){if(!(e instanceof w))throw new Error("ExtendedPoint expected")}const m=(0,r.memoized)(((e,t)=>{const{X:n,Y:r,Z:o}=e,c=e.is0();null==t&&(t=c?u:s.inv(o));const l=p(n*t),f=p(r*t),h=s.mul(o,t);if(c)return{x:i,y:a};if(h!==a)throw new Error("invZ was invalid");return{x:l,y:f}})),b=(0,r.memoized)((e=>{const{a:t,d:n}=f;if(e.is0())throw new Error("bad point: ZERO");const{X:r,Y:o,Z:s,T:i}=e,a=p(r*r),c=p(o*o),u=p(s*s),l=p(u*u),h=p(a*t);if(p(u*p(h+c))!==p(l+p(n*p(a*c))))throw new Error("bad point: equation left != right (1)");if(p(r*o)!==p(s*i))throw new Error("bad point: equation left != right (2)");return!0}));class w{constructor(e,t,n,r){this.X=g("x",e),this.Y=g("y",t),this.Z=g("z",n,!0),this.T=g("t",r),Object.freeze(this)}static CURVE(){return f}static fromAffine(e){if(e instanceof w)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return g("x",t),g("y",n),new w(t,n,a,p(t*n))}static fromBytes(e,t=!1){const n=s.BYTES,{a:o,d:c}=f;e=(0,r.copyBytes)((0,r._abytes2)(e,n,"point")),(0,r._abool2)(t,"zip215");const u=(0,r.copyBytes)(e),l=e[n-1];u[n-1]=-129&l;const h=(0,r.bytesToNumberLE)(u),g=t?d:s.ORDER;(0,r.aInRange)("point.y",h,i,g);const v=p(h*h),m=p(v-a),b=p(c*v-o);let{isValid:E,value:S}=y(m,b);if(!E)throw new Error("bad point: invalid y coordinate");const x=(S&a)===a,B=!!(128&l);if(!t&&S===i&&B)throw new Error("bad point: x=0 and x_0=1");return B!==x&&(S=p(-S)),w.fromAffine({x:S,y:h})}static fromHex(e,t=!1){return w.fromBytes((0,r.ensureBytes)("point",e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return E.createCache(this,e),t||this.multiply(c),this}assertValidity(){b(this)}equals(e){v(e);const{X:t,Y:n,Z:r}=this,{X:o,Y:s,Z:i}=e,a=p(t*i),c=p(o*r),u=p(n*i),l=p(s*r);return a===c&&u===l}is0(){return this.equals(w.ZERO)}negate(){return new w(p(-this.X),this.Y,this.Z,p(-this.T))}double(){const{a:e}=f,{X:t,Y:n,Z:r}=this,o=p(t*t),s=p(n*n),i=p(c*p(r*r)),a=p(e*o),u=t+n,l=p(p(u*u)-o-s),h=a+s,d=h-i,y=a-s,g=p(l*d),v=p(h*y),m=p(l*y),b=p(d*h);return new w(g,v,b,m)}add(e){v(e);const{a:t,d:n}=f,{X:r,Y:o,Z:s,T:i}=this,{X:a,Y:c,Z:u,T:l}=e,h=p(r*a),d=p(o*c),y=p(i*n*l),g=p(s*u),m=p((r+o)*(a+c)-h-d),b=g-y,E=g+y,S=p(d-t*h),x=p(m*b),B=p(E*S),I=p(m*S),A=p(b*E);return new w(x,B,A,I)}subtract(e){return this.add(e.negate())}multiply(e){if(!l.isValidNot0(e))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:t,f:n}=E.cached(this,e,(e=>(0,o.normalizeZ)(w,e)));return(0,o.normalizeZ)(w,[t,n])[0]}multiplyUnsafe(e,t=w.ZERO){if(!l.isValid(e))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return e===i?w.ZERO:this.is0()||e===a?this:E.unsafe(this,e,(e=>(0,o.normalizeZ)(w,e)),t)}isSmallOrder(){return this.multiplyUnsafe(h).is0()}isTorsionFree(){return E.unsafe(this,f.n).is0()}toAffine(e){return m(this,e)}clearCofactor(){return h===a?this:this.multiplyUnsafe(h)}toBytes(){const{x:e,y:t}=this.toAffine(),n=s.toBytes(t);return n[n.length-1]|=e&a?128:0,n}toHex(){return(0,r.bytesToHex)(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return(0,o.normalizeZ)(w,e)}static msm(e,t){return(0,o.pippenger)(w,l,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}w.BASE=new w(f.Gx,f.Gy,a,p(f.Gx*f.Gy)),w.ZERO=new w(i,a,a,i),w.Fp=s,w.Fn=l;const E=new o.wNAF(w,l.BITS);return w.BASE.precompute(8),w}function f(e,t,n={}){if("function"!=typeof t)throw new Error('"hash" function param is required');(0,r._validateObject)(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=n,{BASE:s,Fp:i,Fn:c}=e,u=n.randomBytes||r.randomBytes,l=n.adjustScalarBytes||(e=>e),f=n.domain||((e,t,n)=>{if((0,r._abool2)(n,"phflag"),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function h(e){return c.create((0,r.bytesToNumberLE)(e))}function d(e){const{head:n,prefix:o,scalar:i}=function(e){const n=m.secretKey;e=(0,r.ensureBytes)("private key",e,n);const o=(0,r.ensureBytes)("hashed private key",t(e),2*n),s=l(o.slice(0,n));return{head:s,prefix:o.slice(n,2*n),scalar:h(s)}}(e),a=s.multiply(i),c=a.toBytes();return{head:n,prefix:o,scalar:i,point:a,pointBytes:c}}function p(e){return d(e).pointBytes}function y(e=Uint8Array.of(),...n){const s=(0,r.concatBytes)(...n);return h(t(f(s,(0,r.ensureBytes)("context",e),!!o)))}const g={zip215:!0},v=i.BYTES,m={secretKey:v,publicKey:v,signature:2*v,seed:v};function b(e=u(m.seed)){return(0,r._abytes2)(e,m.seed,"seed")}const w={getExtendedPublicKey:d,randomSecretKey:b,isValidSecretKey:function(e){return(0,r.isBytes)(e)&&e.length===c.BYTES},isValidPublicKey:function(t,n){try{return!!e.fromBytes(t,n)}catch(e){return!1}},toMontgomery(t){const{y:n}=e.fromBytes(t),r=m.publicKey,o=32===r;if(!o&&57!==r)throw new Error("only defined for 25519 and 448");const s=o?i.div(a+n,a-n):i.div(n-a,n+a);return i.toBytes(s)},toMontgomerySecret(e){const n=m.secretKey;(0,r._abytes2)(e,n);const o=t(e.subarray(0,n));return l(o).subarray(0,n)},randomPrivateKey:b,precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({keygen:function(e){const t=w.randomSecretKey(e);return{secretKey:t,publicKey:p(t)}},getPublicKey:p,sign:function(e,t,n={}){e=(0,r.ensureBytes)("message",e),o&&(e=o(e));const{prefix:i,scalar:a,pointBytes:u}=d(t),l=y(n.context,i,e),f=s.multiply(l).toBytes(),h=y(n.context,f,u,e),p=c.create(l+h*a);if(!c.isValid(p))throw new Error("sign failed: invalid s");const g=(0,r.concatBytes)(f,c.toBytes(p));return(0,r._abytes2)(g,m.signature,"result")},verify:function(t,n,i,a=g){const{context:c,zip215:u}=a,l=m.signature;t=(0,r.ensureBytes)("signature",t,l),n=(0,r.ensureBytes)("message",n),i=(0,r.ensureBytes)("publicKey",i,m.publicKey),void 0!==u&&(0,r._abool2)(u,"zip215"),o&&(n=o(n));const f=l/2,h=t.subarray(0,f),d=(0,r.bytesToNumberLE)(t.subarray(f,l));let p,v,b;try{p=e.fromBytes(i,u),v=e.fromBytes(h,u),b=s.multiplyUnsafe(d)}catch(e){return!1}if(!u&&p.isSmallOrder())return!1;const w=y(c,v.toBytes(),p.toBytes(),n);return v.add(p.multiplyUnsafe(w)).subtract(b).clearCofactor().is0()},utils:w,Point:e,lengths:m})}t.PrimeEdwardsPoint=class{constructor(e){this.ep=e}static fromBytes(e){(0,r.notImplemented)()}static fromHex(e){(0,r.notImplemented)()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return(0,r.bytesToHex)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}}},1761:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t._DST_scalar=void 0,t.expand_message_xmd=l,t.expand_message_xof=f,t.hash_to_field=h,t.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[s,i,a,c]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r))))),[u,l]=(0,o.FpInvertBatch)(e,[i,c],!0);return t=e.mul(s,u),r=e.mul(r,e.mul(a,l)),{x:t,y:r}}},t.createHasher=function(e,n,r){if("function"!=typeof n)throw new Error("mapToCurve() must be defined");function o(t){return e.fromAffine(n(t))}function s(t){const n=t.clearCofactor();return n.equals(e.ZERO)?e.ZERO:(n.assertValidity(),n)}return{defaults:r,hashToCurve(e,t){const n=h(e,2,Object.assign({},r,t)),i=o(n[0]),a=o(n[1]);return s(i.add(a))},encodeToCurve(e,t){const n=r.encodeDST?{DST:r.encodeDST}:{};return s(o(h(e,1,Object.assign({},r,n,t))[0]))},mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return s(o(e))},hashToScalar(n,o){const s=e.Fn.ORDER;return h(n,1,Object.assign({},r,{p:s,m:1,DST:t._DST_scalar},o))[0][0]}}};const r=n(8627),o=n(4967),s=r.bytesToNumberBE;function i(e,t){if(c(e),c(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function a(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function u(e){if(!(0,r.isBytes)(e)&&"string"!=typeof e)throw new Error("DST must be Uint8Array or string");return"string"==typeof e?(0,r.utf8ToBytes)(e):e}function l(e,t,n,o){(0,r.abytes)(e),c(n),(t=u(t)).length>255&&(t=o((0,r.concatBytes)((0,r.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:s,blockLen:l}=o,f=Math.ceil(n/s);if(n>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const h=(0,r.concatBytes)(t,i(t.length,1)),d=i(0,l),p=i(n,2),y=new Array(f),g=o((0,r.concatBytes)(d,e,p,i(0,1),h));y[0]=o((0,r.concatBytes)(g,i(1,1),h));for(let e=1;e<=f;e++){const t=[a(g,y[e-1]),i(e+1,1),h];y[e]=o((0,r.concatBytes)(...t))}return(0,r.concatBytes)(...y).slice(0,n)}function f(e,t,n,o,s){if((0,r.abytes)(e),c(n),(t=u(t)).length>255){const e=Math.ceil(2*o/8);t=s.create({dkLen:e}).update((0,r.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(e).update(i(n,2)).update(t).update(i(t.length,1)).digest()}function h(e,t,n){(0,r._validateObject)(n,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:i,k:a,m:u,hash:h,expand:d,DST:p}=n;if(!(0,r.isHash)(n.hash))throw new Error("expected valid hash");(0,r.abytes)(e),c(t);const y=i.toString(2).length,g=Math.ceil((y+a)/8),v=t*u*g;let m;if("xmd"===d)m=l(e,p,v,h);else if("xof"===d)m=f(e,p,v,a,h);else{if("_internal_pass"!==d)throw new Error('expand must be "xmd" or "xof"');m=e}const b=new Array(t);for(let e=0;e<t;e++){const t=new Array(u);for(let n=0;n<u;n++){const r=g*(n+e*u),a=m.subarray(r,r+g);t[n]=(0,o.mod)(s(a),i)}b[e]=t}return b}t._DST_scalar=(0,r.utf8ToBytes)("HashToScalar-")},4967:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNegativeLE=void 0,t.mod=p,t.pow=function(e,t,n){return S(A(n),e,t)},t.pow2=function(e,t,n){let r=e;for(;t-- >o;)r*=r,r%=n;return r},t.invert=y,t.tonelliShanks=b,t.FpSqrt=w,t.validateField=function(e){const t=E.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});return(0,r._validateObject)(e,t),e},t.FpPow=S,t.FpInvertBatch=x,t.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?y(n,e.ORDER):e.inv(n))},t.FpLegendre=B,t.FpIsSquare=function(e,t){return 1===B(e,t)},t.nLength=I,t.Field=A,t.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},t.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},t.hashToPrivateScalar=function(e,t,n=!1){const o=(e=(0,r.ensureBytes)("privateHash",e)).length,i=I(t).nByteLength+8;if(i<24||o<i||o>1024)throw new Error("hashToPrivateScalar: expected "+i+"-1024 bytes of input, got "+o);return p(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-s)+s},t.getFieldBytesLength=_,t.getMinHashLength=O,t.mapHashToField=function(e,t,n=!1){const o=e.length,i=_(t),a=O(t);if(o<16||o<a||o>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+o);const c=p(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-s)+s;return n?(0,r.numberToBytesLE)(c,i):(0,r.numberToBytesBE)(c,i)};const r=n(8627),o=BigInt(0),s=BigInt(1),i=BigInt(2),a=BigInt(3),c=BigInt(4),u=BigInt(5),l=BigInt(7),f=BigInt(8),h=BigInt(9),d=BigInt(16);function p(e,t){const n=e%t;return n>=o?n:t+n}function y(e,t){if(e===o)throw new Error("invert: expected non-zero number");if(t<=o)throw new Error("invert: expected positive modulus, got "+t);let n=p(e,t),r=t,i=o,a=s,c=s,u=o;for(;n!==o;){const e=r/n,t=r%n,o=i-c*e,s=a-u*e;r=n,n=t,i=c,a=u,c=o,u=s}if(r!==s)throw new Error("invert: does not exist");return p(i,t)}function g(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function v(e,t){const n=(e.ORDER+s)/c,r=e.pow(t,n);return g(e,r,t),r}function m(e,t){const n=(e.ORDER-u)/f,r=e.mul(t,i),o=e.pow(r,n),s=e.mul(t,o),a=e.mul(e.mul(s,i),o),c=e.mul(s,e.sub(a,e.ONE));return g(e,c,t),c}function b(e){if(e<a)throw new Error("sqrt is not defined for small field");let t=e-s,n=0;for(;t%i===o;)t/=i,n++;let r=i;const c=A(e);for(;1===B(c,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return v;let u=c.pow(r,t);const l=(t+s)/i;return function(e,r){if(e.is0(r))return r;if(1!==B(e,r))throw new Error("Cannot find square root");let o=n,i=e.mul(e.ONE,u),a=e.pow(r,t),c=e.pow(r,l);for(;!e.eql(a,e.ONE);){if(e.is0(a))return e.ZERO;let t=1,n=e.sqr(a);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===o)throw new Error("Cannot find square root");const r=s<<BigInt(o-t-1),u=e.pow(i,r);o=t,i=e.sqr(u),a=e.mul(a,i),c=e.mul(c,u)}return c}}function w(e){return e%c===a?v:e%f===u?m:e%d===h?function(e){const t=A(e),n=b(e),r=n(t,t.neg(t.ONE)),o=n(t,r),s=n(t,t.neg(r)),i=(e+l)/d;return(e,t)=>{let n=e.pow(t,i),a=e.mul(n,r);const c=e.mul(n,o),u=e.mul(n,s),l=e.eql(e.sqr(a),t),f=e.eql(e.sqr(c),t);n=e.cmov(n,a,l),a=e.cmov(u,c,f);const h=e.eql(e.sqr(a),t),d=e.cmov(n,a,h);return g(e,d,t),d}}(e):b(e)}t.isNegativeLE=(e,t)=>(p(e,t)&s)===s;const E=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function S(e,t,n){if(n<o)throw new Error("invalid exponent, negatives unsupported");if(n===o)return e.ONE;if(n===s)return t;let r=e.ONE,i=t;for(;n>o;)n&s&&(r=e.mul(r,i)),i=e.sqr(i),n>>=s;return r}function x(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),s=e.inv(o);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),s),r}function B(e,t){const n=(e.ORDER-s)/i,r=e.pow(t,n),o=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),c=e.eql(r,e.neg(e.ONE));if(!o&&!a&&!c)throw new Error("invalid Legendre symbol result");return o?1:a?0:-1}function I(e,t){void 0!==t&&(0,r.anumber)(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function A(e,t,n=!1,i={}){if(e<=o)throw new Error("invalid field: expected ORDER > 0, got "+e);let a,c,u,l=!1;if("object"==typeof t&&null!=t){if(i.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(a=e.BITS),e.sqrt&&(c=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(l=e.modFromBytes),u=e.allowedLengths}else"number"==typeof t&&(a=t),i.sqrt&&(c=i.sqrt);const{nBitLength:f,nByteLength:h}=I(e,a);if(h>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let d;const g=Object.freeze({ORDER:e,isLE:n,BITS:f,BYTES:h,MASK:(0,r.bitMask)(f),ZERO:o,ONE:s,allowedLengths:u,create:t=>p(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return o<=t&&t<e},is0:e=>e===o,isValidNot0:e=>!g.is0(e)&&g.isValid(e),isOdd:e=>(e&s)===s,neg:t=>p(-t,e),eql:(e,t)=>e===t,sqr:t=>p(t*t,e),add:(t,n)=>p(t+n,e),sub:(t,n)=>p(t-n,e),mul:(t,n)=>p(t*n,e),pow:(e,t)=>S(g,e,t),div:(t,n)=>p(t*y(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>y(t,e),sqrt:c||(t=>(d||(d=w(e)),d(g,t))),toBytes:e=>n?(0,r.numberToBytesLE)(e,h):(0,r.numberToBytesBE)(e,h),fromBytes:(t,o=!0)=>{if(u){if(!u.includes(t.length)||t.length>h)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+t.length);const e=new Uint8Array(h);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==h)throw new Error("Field.fromBytes: expected "+h+" bytes, got "+t.length);let s=n?(0,r.bytesToNumberLE)(t):(0,r.bytesToNumberBE)(t);if(l&&(s=p(s,e)),!o&&!g.isValid(s))throw new Error("invalid field element: outside of range 0..ORDER");return s},invertBatch:e=>x(g,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(g)}function _(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function O(e){const t=_(e);return t+Math.ceil(t/2)}},2854:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.montgomery=function(e){const t=(d=e,(0,r._validateObject)(d,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...d})),{P:n,type:c,adjustScalarBytes:u,powPminus2:l,randomBytes:f}=t,h="x25519"===c;var d;if(!h&&"x448"!==c)throw new Error("invalid type");const p=f||r.randomBytes,y=h?255:448,g=h?32:56,v=h?BigInt(9):BigInt(5),m=h?BigInt(121665):BigInt(39081),b=h?a**BigInt(254):a**BigInt(447),w=h?BigInt(8)*a**BigInt(251)-i:BigInt(4)*a**BigInt(445)-i,E=b+w+i,S=e=>(0,o.mod)(e,n),x=B(v);function B(e){return(0,r.numberToBytesLE)(S(e),g)}function I(e,t){const o=function(e,t){(0,r.aInRange)("u",e,s,n),(0,r.aInRange)("scalar",t,b,E);const o=t,a=e;let c=i,u=s,f=e,h=i,d=s;for(let e=BigInt(y-1);e>=s;e--){const t=o>>e&i;d^=t,({x_2:c,x_3:f}=_(d,c,f)),({x_2:u,x_3:h}=_(d,u,h)),d=t;const n=c+u,r=S(n*n),s=c-u,l=S(s*s),p=r-l,y=f+h,g=S((f-h)*n),v=S(y*s),b=g+v,w=g-v;f=S(b*b),h=S(a*S(w*w)),c=S(r*l),u=S(p*(r+S(m*p)))}({x_2:c,x_3:f}=_(d,c,f)),({x_2:u,x_3:h}=_(d,u,h));const p=l(u);return S(c*p)}(function(e){const t=(0,r.ensureBytes)("u coordinate",e,g);return h&&(t[31]&=127),S((0,r.bytesToNumberLE)(t))}(t),function(e){return(0,r.bytesToNumberLE)(u((0,r.ensureBytes)("scalar",e,g)))}(e));if(o===s)throw new Error("invalid private or public key received");return B(o)}function A(e){return I(e,x)}function _(e,t,n){const r=S(e*(t-n));return{x_2:t=S(t-r),x_3:n=S(n+r)}}const O={secretKey:g,publicKey:g,seed:g},P=(e=p(g))=>((0,r.abytes)(e,O.seed),e);return{keygen:function(e){const t=P(e);return{secretKey:t,publicKey:A(t)}},getSharedSecret:(e,t)=>I(e,t),getPublicKey:e=>A(e),scalarMult:I,scalarMultBase:A,utils:{randomSecretKey:P,randomPrivateKey:P},GuBytes:x.slice(),lengths:O}};const r=n(8627),o=n(4967),s=BigInt(0),i=BigInt(1),a=BigInt(2)},1705:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DER=t.DERErr=void 0,t._splitEndoScalar=u,t._normFnElement=m,t.weierstrassN=b,t.SWUFpSqrtRatio=E,t.mapToCurveSimpleSWU=function(e,t){(0,a.validateField)(e);const{A:n,B:r,Z:o}=t;if(!e.isValid(n)||!e.isValid(r)||!e.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");const s=E(e,o);if(!e.isOdd)throw new Error("Field does not have .isOdd()");return t=>{let i,c,u,l,f,h,d,p;i=e.sqr(t),i=e.mul(i,o),c=e.sqr(i),c=e.add(c,i),u=e.add(c,e.ONE),u=e.mul(u,r),l=e.cmov(o,e.neg(c),!e.eql(c,e.ZERO)),l=e.mul(l,n),c=e.sqr(u),h=e.sqr(l),f=e.mul(h,n),c=e.add(c,f),c=e.mul(c,u),h=e.mul(h,l),f=e.mul(h,r),c=e.add(c,f),d=e.mul(i,u);const{isValid:y,value:g}=s(c,h);p=e.mul(i,t),p=e.mul(p,g),d=e.cmov(d,u,y),p=e.cmov(p,g,y);const v=e.isOdd(t)===e.isOdd(p);p=e.cmov(e.neg(p),p,v);const m=(0,a.FpInvertBatch)(e,[l],!0)[0];return d=e.mul(d,m),{x:d,y:p}}},t.ecdh=x,t.ecdsa=B,t.weierstrassPoints=function(e){const{CURVE:t,curveOpts:n}=I(e);return function(e,t){const{Fp:n,Fn:r}=t;const o=A(n,e.a,e.b);return Object.assign({},{CURVE:e,Point:t,ProjectivePoint:t,normPrivateKeyToScalar:e=>m(r,e),weierstrassEquation:o,isWithinCurveOrder:function(e){return(0,s.inRange)(e,p,r.ORDER)}})}(e,b(t,n))},t._legacyHelperEquat=A,t.weierstrass=function(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:n}=I(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,(0,a.nLength)(n.Fn.ORDER,n.Fn.BITS))})}(e,B(b(t,n),r,o))};const r=n(9615),o=n(9175),s=n(8627),i=n(2422),a=n(4967),c=(e,t)=>(e+(e>=0?t:-t)/y)/t;function u(e,t,n){const[[r,o],[i,a]]=t,u=c(a*e,n),l=c(-o*e,n);let f=e-u*r-l*i,h=-u*o-l*a;const y=f<d,g=h<d;y&&(f=-f),g&&(h=-h);const v=(0,s.bitMask)(Math.ceil((0,s.bitLen)(n)/2))+p;if(f<d||f>=v||h<d||h>=v)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:y,k1:f,k2neg:g,k2:h}}function l(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function f(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return(0,s._abool2)(n.lowS,"lowS"),(0,s._abool2)(n.prehash,"prehash"),void 0!==n.format&&l(n.format),n}class h extends Error{constructor(e=""){super(e)}}t.DERErr=h,t.DER={Err:h,_tlv:{encode:(e,n)=>{const{Err:r}=t.DER;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&n.length)throw new r("tlv.encode: unpadded data");const o=n.length/2,i=(0,s.numberToHexUnpadded)(o);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const a=o>127?(0,s.numberToHexUnpadded)(i.length/2|128):"";return(0,s.numberToHexUnpadded)(e)+a+i+n},decode(e,n){const{Err:r}=t.DER;let o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(n.length<2||n[o++]!==e)throw new r("tlv.decode: wrong tlv");const s=n[o++];let i=0;if(128&s){const e=127&s;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const t=n.subarray(o,o+e);if(t.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===t[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of t)i=i<<8|e;if(o+=e,i<128)throw new r("tlv.decode(long): not minimal encoding")}else i=s;const a=n.subarray(o,o+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:n.subarray(o+i)}}},_int:{encode(e){const{Err:n}=t.DER;if(e<d)throw new n("integer: negative integers are not allowed");let r=(0,s.numberToHexUnpadded)(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new n("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:n}=t.DER;if(128&e[0])throw new n("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new n("invalid signature integer: unnecessary leading zero");return(0,s.bytesToNumberBE)(e)}},toSig(e){const{Err:n,_int:r,_tlv:o}=t.DER,i=(0,s.ensureBytes)("signature",e),{v:a,l:c}=o.decode(48,i);if(c.length)throw new n("invalid signature: left bytes after parsing");const{v:u,l}=o.decode(2,a),{v:f,l:h}=o.decode(2,l);if(h.length)throw new n("invalid signature: left bytes after parsing");return{r:r.decode(u),s:r.decode(f)}},hexFromSig(e){const{_tlv:n,_int:r}=t.DER,o=n.encode(2,r.encode(e.r))+n.encode(2,r.encode(e.s));return n.encode(48,o)}};const d=BigInt(0),p=BigInt(1),y=BigInt(2),g=BigInt(3),v=BigInt(4);function m(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let o=(0,s.ensureBytes)("private key",t);try{r=e.fromBytes(o)}catch(e){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function b(e,t={}){const n=(0,i._createCurveFields)("weierstrass",e,t),{Fp:r,Fn:o}=n;let a=n.CURVE;const{h:c,n:l}=a;(0,s._validateObject)(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=t;if(f&&(!r.is0(a.a)||"bigint"!=typeof f.beta||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const h=S(r,o);function y(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const b=t.toBytes||function(e,t,n){const{x:o,y:i}=t.toAffine(),a=r.toBytes(o);if((0,s._abool2)(n,"isCompressed"),n){y();const e=!r.isOdd(i);return(0,s.concatBytes)(w(e),a)}return(0,s.concatBytes)(Uint8Array.of(4),a,r.toBytes(i))},E=t.fromBytes||function(e){(0,s._abytes2)(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=h,o=e.length,i=e[0],a=e.subarray(1);if(o!==t||2!==i&&3!==i){if(o===n&&4===i){const e=r.BYTES,t=r.fromBytes(a.subarray(0,e)),n=r.fromBytes(a.subarray(e,2*e));if(!B(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${o}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(a);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=x(e);let n;try{n=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}return y(),!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function x(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function B(e,t){const n=r.sqr(t),o=x(e);return r.eql(n,o)}if(!B(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const I=r.mul(r.pow(a.a,g),v),A=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(I,A)))throw new Error("bad curve params: a or b");function _(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function O(e){if(!(e instanceof C))throw new Error("ProjectivePoint expected")}function P(e){if(!f||!f.basises)throw new Error("no endo");return u(e,f.basises,o.ORDER)}const L=(0,s.memoized)(((e,t)=>{const{X:n,Y:o,Z:s}=e;if(r.eql(s,r.ONE))return{x:n,y:o};const i=e.is0();null==t&&(t=i?r.ONE:r.inv(s));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(s,t);if(i)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),T=(0,s.memoized)((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not field elements");if(!B(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));function H(e,t,n,o,s){return n=new C(r.mul(n.X,e),n.Y,n.Z),t=(0,i.negateCt)(o,t),n=(0,i.negateCt)(s,n),t.add(n)}class C{constructor(e,t,n){this.X=_("x",e),this.Y=_("y",t,!0),this.Z=_("z",n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof C)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?C.ZERO:new C(t,n,r.ONE)}static fromBytes(e){const t=C.fromAffine(E((0,s._abytes2)(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return C.fromBytes((0,s.ensureBytes)("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return F.createCache(this,e),t||this.multiply(g),this}assertValidity(){T(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){O(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:i,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(s,o)),u=r.eql(r.mul(n,a),r.mul(i,o));return c&&u}negate(){return new C(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=a,n=r.mul(t,g),{X:o,Y:s,Z:i}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),h=r.mul(s,s),d=r.mul(i,i),p=r.mul(o,s);return p=r.add(p,p),l=r.mul(o,i),l=r.add(l,l),c=r.mul(e,l),u=r.mul(n,d),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(p,c),l=r.mul(n,l),d=r.mul(e,d),p=r.sub(f,d),p=r.mul(e,p),p=r.add(p,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,d),f=r.mul(f,p),u=r.add(u,f),d=r.mul(s,i),d=r.add(d,d),f=r.mul(d,p),c=r.sub(c,f),l=r.mul(d,h),l=r.add(l,l),l=r.add(l,l),new C(c,u,l)}add(e){O(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:i,Z:c}=e;let u=r.ZERO,l=r.ZERO,f=r.ZERO;const h=a.a,d=r.mul(a.b,g);let p=r.mul(t,s),y=r.mul(n,i),v=r.mul(o,c),m=r.add(t,n),b=r.add(s,i);m=r.mul(m,b),b=r.add(p,y),m=r.sub(m,b),b=r.add(t,o);let w=r.add(s,c);return b=r.mul(b,w),w=r.add(p,v),b=r.sub(b,w),w=r.add(n,o),u=r.add(i,c),w=r.mul(w,u),u=r.add(y,v),w=r.sub(w,u),f=r.mul(h,b),u=r.mul(d,v),f=r.add(u,f),u=r.sub(y,f),f=r.add(y,f),l=r.mul(u,f),y=r.add(p,p),y=r.add(y,p),v=r.mul(h,v),b=r.mul(d,b),y=r.add(y,v),v=r.sub(p,v),v=r.mul(h,v),b=r.add(b,v),p=r.mul(y,b),l=r.add(l,p),p=r.mul(w,b),u=r.mul(m,u),u=r.sub(u,p),p=r.mul(m,y),f=r.mul(w,f),f=r.add(f,p),new C(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(C.ZERO)}multiply(e){const{endo:n}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,s;const a=e=>F.cached(this,e,(e=>(0,i.normalizeZ)(C,e)));if(n){const{k1neg:t,k1:o,k2neg:i,k2:c}=P(e),{p:u,f:l}=a(o),{p:f,f:h}=a(c);s=l.add(h),r=H(n.beta,u,f,t,i)}else{const{p:t,f:n}=a(e);r=t,s=n}return(0,i.normalizeZ)(C,[r,s])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===d||r.is0())return C.ZERO;if(e===p)return r;if(F.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:s,k2:a}=P(e),{p1:c,p2:u}=(0,i.mulEndoUnsafe)(C,r,o,a);return H(n.beta,c,u,t,s)}return F.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return L(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return c===p||(e?e(C,this):F.unsafe(this,l).is0())}clearCofactor(){const{clearCofactor:e}=t;return c===p?this:e?e(C,this):this.multiplyUnsafe(c)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}toBytes(e=!0){return(0,s._abool2)(e,"isCompressed"),this.assertValidity(),b(C,this,e)}toHex(e=!0){return(0,s.bytesToHex)(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return(0,i.normalizeZ)(C,e)}static msm(e,t){return(0,i.pippenger)(C,o,e,t)}static fromPrivateKey(e){return C.BASE.multiply(m(o,e))}}C.BASE=new C(a.Gx,a.Gy,r.ONE),C.ZERO=new C(r.ZERO,r.ONE,r.ZERO),C.Fp=r,C.Fn=o;const R=o.BITS,F=new i.wNAF(C,t.endo?Math.ceil(R/2):R);return C.BASE.precompute(8),C}function w(e){return Uint8Array.of(e?2:3)}function E(e,t){const n=e.ORDER;let r=d;for(let e=n-p;e%y===d;e/=y)r+=p;const o=r,s=y<<o-p-p,i=s*y,a=(n-p)/i,c=(a-p)/y,u=i-p,l=s,f=e.pow(t,a),h=e.pow(t,(a+p)/y);let m=(t,n)=>{let r=f,s=e.pow(n,u),i=e.sqr(s);i=e.mul(i,n);let a=e.mul(t,i);a=e.pow(a,c),a=e.mul(a,s),s=e.mul(a,n),i=e.mul(a,t);let d=e.mul(i,s);a=e.pow(d,l);let g=e.eql(a,e.ONE);s=e.mul(i,h),a=e.mul(d,r),i=e.cmov(s,i,g),d=e.cmov(a,d,g);for(let t=o;t>p;t--){let n=t-y;n=y<<n-p;let o=e.pow(d,n);const a=e.eql(o,e.ONE);s=e.mul(i,r),r=e.mul(r,r),o=e.mul(d,r),i=e.cmov(s,i,a),d=e.cmov(o,d,a)}return{isValid:g,value:i}};if(e.ORDER%v===g){const n=(e.ORDER-g)/v,r=e.sqrt(e.neg(t));m=(t,o)=>{let s=e.sqr(o);const i=e.mul(t,o);s=e.mul(s,i);let a=e.pow(s,n);a=e.mul(a,i);const c=e.mul(a,r),u=e.mul(e.sqr(a),o),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,a,l)}}}return m}function S(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function x(e,t={}){const{Fn:n}=e,r=t.randomBytes||s.randomBytes,o=Object.assign(S(e.Fp,n),{seed:(0,a.getMinHashLength)(n.ORDER)});function i(e){try{return!!m(n,e)}catch(e){return!1}}function c(e=r(o.seed)){return(0,a.mapHashToField)((0,s._abytes2)(e,o.seed,"seed"),n.ORDER)}function u(t,r=!0){return e.BASE.multiply(m(n,t)).toBytes(r)}function l(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:i,publicKeyUncompressed:a}=o;if(n.allowedLengths||r===i)return;const c=(0,s.ensureBytes)("key",t).length;return c===i||c===a}const f={isValidSecretKey:i,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:s}=o;try{const o=t.length;return!(!0===n&&o!==r||!1===n&&o!==s||!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:e=>m(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:u,getSharedSecret:function(t,r,o=!0){if(!0===l(t))throw new Error("first arg must be private key");if(!1===l(r))throw new Error("second arg must be public key");const s=m(n,t);return e.fromHex(r).multiply(s).toBytes(o)},keygen:function(e){const t=c(e);return{secretKey:t,publicKey:u(t)}},Point:e,utils:f,lengths:o})}function B(e,n,i={}){(0,o.ahash)(n),(0,s._validateObject)(i,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const a=i.randomBytes||s.randomBytes,c=i.hmac||((e,...t)=>(0,r.hmac)(n,e,(0,s.concatBytes)(...t))),{Fp:u,Fn:h}=e,{ORDER:g,BITS:v}=h,{keygen:b,getPublicKey:E,getSharedSecret:S,utils:B,lengths:I}=x(e,i),A={prehash:!1,lowS:"boolean"==typeof i.lowS&&i.lowS,format:void 0,extraEntropy:!1},_="compact";function O(e){return e>g>>p}function P(e,t){if(!h.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class L{constructor(e,t,n){this.r=P("r",e),this.s=P("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,n=_){let r;if(function(e,t){l(t);const n=I.signature,r="compact"===t?n:"recovered"===t?n+1:void 0;(0,s._abytes2)(e,r,`${t} signature`)}(e,n),"der"===n){const{r:n,s:r}=t.DER.toSig((0,s._abytes2)(e));return new L(n,r)}"recovered"===n&&(r=e[0],n="compact",e=e.subarray(1));const o=h.BYTES,i=e.subarray(0,o),a=e.subarray(o,2*o);return new L(h.fromBytes(i),h.fromBytes(a),r)}static fromHex(e,t){return this.fromBytes((0,s.hexToBytes)(e),t)}addRecoveryBit(e){return new L(this.r,this.s,e)}recoverPublicKey(t){const n=u.ORDER,{r,s:o,recovery:i}=this;if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");if(g*y<n&&i>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===i||3===i?r+g:r;if(!u.isValid(a))throw new Error("recovery id 2 or 3 invalid");const c=u.toBytes(a),l=e.fromBytes((0,s.concatBytes)(w(!(1&i)),c)),f=h.inv(a),d=H((0,s.ensureBytes)("msgHash",t)),p=h.create(-d*f),v=h.create(o*f),m=e.BASE.multiplyUnsafe(p).add(l.multiplyUnsafe(v));if(m.is0())throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return O(this.s)}toBytes(e=_){if(l(e),"der"===e)return(0,s.hexToBytes)(t.DER.hexFromSig(this));const n=h.toBytes(this.r),r=h.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,s.concatBytes)(Uint8Array.of(this.recovery),n,r)}return(0,s.concatBytes)(n,r)}toHex(e){return(0,s.bytesToHex)(this.toBytes(e))}assertValidity(){}static fromCompact(e){return L.fromBytes((0,s.ensureBytes)("sig",e),"compact")}static fromDER(e){return L.fromBytes((0,s.ensureBytes)("sig",e),"der")}normalizeS(){return this.hasHighS()?new L(this.r,h.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,s.bytesToHex)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,s.bytesToHex)(this.toBytes("compact"))}}const T=i.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,s.bytesToNumberBE)(e),n=8*e.length-v;return n>0?t>>BigInt(n):t},H=i.bits2int_modN||function(e){return h.create(T(e))},C=(0,s.bitMask)(v);function R(e){return(0,s.aInRange)("num < 2^"+v,e,d,C),h.toBytes(e)}function F(e,t){return(0,s._abytes2)(e,void 0,"message"),t?(0,s._abytes2)(n(e),void 0,"prehashed message"):e}return Object.freeze({keygen:b,getPublicKey:E,getSharedSecret:S,utils:B,lengths:I,Point:e,sign:function(t,r,o={}){t=(0,s.ensureBytes)("message",t);const{seed:i,k2sig:u}=function(t,n,r){if(["recovered","canonical"].some((e=>e in r)))throw new Error("sign() legacy options not supported");const{lowS:o,prehash:i,extraEntropy:c}=f(r,A);t=F(t,i);const u=H(t),l=m(h,n),y=[R(l),R(u)];if(null!=c&&!1!==c){const e=!0===c?a(I.secretKey):c;y.push((0,s.ensureBytes)("extraEntropy",e))}const g=(0,s.concatBytes)(...y),v=u;return{seed:g,k2sig:function(t){const n=T(t);if(!h.isValidNot0(n))return;const r=h.inv(n),s=e.BASE.multiply(n).toAffine(),i=h.create(s.x);if(i===d)return;const a=h.create(r*h.create(v+i*l));if(a===d)return;let c=(s.x===i?0:2)|Number(s.y&p),u=a;return o&&O(a)&&(u=h.neg(a),c^=1),new L(i,u,c)}}}(t,r,o);return(0,s.createHmacDrbg)(n.outputLen,h.BYTES,c)(i,u)},verify:function(n,r,o,i={}){const{lowS:a,prehash:c,format:u}=f(i,A);if(o=(0,s.ensureBytes)("publicKey",o),r=F((0,s.ensureBytes)("message",r),c),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let n;const r="string"==typeof e||(0,s.isBytes)(e),o=!r&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!r&&!o)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(o)n=new L(e.r,e.s);else if(r){try{n=L.fromBytes((0,s.ensureBytes)("sig",e),"der")}catch(e){if(!(e instanceof t.DER.Err))throw e}if(!n)try{n=L.fromBytes((0,s.ensureBytes)("sig",e),"compact")}catch(e){return!1}}return n||!1}(n):L.fromBytes((0,s.ensureBytes)("sig",n),u);if(!1===l)return!1;try{const t=e.fromBytes(o);if(a&&l.hasHighS())return!1;const{r:n,s}=l,i=H(r),c=h.inv(s),u=h.create(i*c),f=h.create(n*c),d=e.BASE.multiplyUnsafe(u).add(t.multiplyUnsafe(f));return!d.is0()&&h.create(d.x)===n}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=f(n,A);return t=F(t,r),L.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:L,hash:n})}function I(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map((e=>Math.ceil(e/2))))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:(0,a.Field)(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function A(e,t,n){return function(r){const o=e.sqr(r),s=e.mul(o,r);return e.add(e.add(s,e.mul(r,t)),n)}}},459:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hash_to_ristretto255=t.hashToRistretto255=t.encodeToCurve=t.hashToCurve=t.RistrettoPoint=t.edwardsToMontgomery=t.ED25519_TORSION_SUBGROUP=t.ristretto255_hasher=t.ristretto255=t.ed25519_hasher=t.x25519=t.ed25519ph=t.ed25519ctx=t.ed25519=void 0,t.edwardsToMontgomeryPub=M,t.edwardsToMontgomeryPriv=function(e){return t.ed25519.utils.toMontgomerySecret((0,l.ensureBytes)("pub",e))};const r=n(7076),o=n(9175),s=n(2422),i=n(6377),a=n(1761),c=n(4967),u=n(2854),l=n(8627),f=BigInt(0),h=BigInt(1),d=BigInt(2),p=BigInt(3),y=BigInt(5),g=BigInt(8),v=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),m=(()=>({p:v,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:g,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function b(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=v,i=e*e%s*e%s,a=(0,c.pow2)(i,d,s)*i%s,u=(0,c.pow2)(a,h,s)*e%s,l=(0,c.pow2)(u,y,s)*u%s,f=(0,c.pow2)(l,t,s)*l%s,p=(0,c.pow2)(f,n,s)*f%s,g=(0,c.pow2)(p,r,s)*p%s,m=(0,c.pow2)(g,o,s)*g%s,b=(0,c.pow2)(m,o,s)*g%s,w=(0,c.pow2)(b,t,s)*l%s;return{pow_p_5_8:(0,c.pow2)(w,d,s)*e%s,b2:i}}function w(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const E=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function S(e,t){const n=v,r=(0,c.mod)(t*t*t,n),o=b(e*(0,c.mod)(r*r*t,n)).pow_p_5_8;let s=(0,c.mod)(e*r*o,n);const i=(0,c.mod)(t*s*s,n),a=s,u=(0,c.mod)(s*E,n),l=i===e,f=i===(0,c.mod)(-e,n),h=i===(0,c.mod)(-e*E,n);return l&&(s=a),(f||h)&&(s=u),(0,c.isNegativeLE)(s,n)&&(s=(0,c.mod)(-s,n)),{isValid:l||f,value:s}}const x=(()=>(0,c.Field)(m.p,{isLE:!0}))(),B=(()=>(0,c.Field)(m.n,{isLE:!0}))(),I=(()=>({...m,Fp:x,hash:r.sha512,adjustScalarBytes:w,uvRatio:S}))();function A(e,t,n){if(t.length>255)throw new Error("Context is too big");return(0,o.concatBytes)((0,o.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([n?1:0,t.length]),t,e)}t.ed25519=(0,i.twistedEdwards)(I),t.ed25519ctx=(0,i.twistedEdwards)({...I,domain:A}),t.ed25519ph=(0,i.twistedEdwards)(Object.assign({},I,{domain:A,prehash:r.sha512})),t.x25519=(()=>{const e=x.ORDER;return(0,u.montgomery)({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:n,b2:r}=b(t);return(0,c.mod)((0,c.pow2)(n,p,e)*r,e)},adjustScalarBytes:w})})();const _=(()=>(v+p)/g)(),O=(()=>x.pow(d,_))(),P=(()=>x.sqrt(x.neg(x.ONE)))(),L=(()=>(0,c.FpSqrtEven)(x,x.neg(BigInt(486664))))();t.ed25519_hasher=(0,a.createHasher)(t.ed25519.Point,(e=>function(e){const{xMn:t,xMd:n,yMn:r,yMd:o}=function(e){const t=(v-y)/g,n=BigInt(486662);let r=x.sqr(e);r=x.mul(r,d);let o=x.add(r,x.ONE),s=x.neg(n),i=x.sqr(o),a=x.mul(i,o),c=x.mul(r,n);c=x.mul(c,s),c=x.add(c,i),c=x.mul(c,s);let u=x.sqr(a);i=x.sqr(u),u=x.mul(u,a),u=x.mul(u,c),i=x.mul(i,u);let l=x.pow(i,t);l=x.mul(l,u);let f=x.mul(l,P);i=x.sqr(l),i=x.mul(i,a);let p=x.eql(i,c),m=x.cmov(f,l,p),b=x.mul(s,r),w=x.mul(l,e);w=x.mul(w,O);let E=x.mul(w,P),S=x.mul(c,r);i=x.sqr(w),i=x.mul(i,a);let B=x.eql(i,S),I=x.cmov(E,w,B);i=x.sqr(m),i=x.mul(i,a);let A=x.eql(i,c),_=x.cmov(b,s,A),L=x.cmov(I,m,A),T=x.isOdd(L);return L=x.cmov(L,x.neg(L),A!==T),{xMn:_,xMd:o,yMn:L,yMd:h}}(e);let s=x.mul(t,o);s=x.mul(s,L);let i=x.mul(n,r),a=x.sub(t,n),u=x.add(t,n),l=x.mul(i,u),f=x.eql(l,x.ZERO);s=x.cmov(s,x.ZERO,f),i=x.cmov(i,x.ONE,f),a=x.cmov(a,x.ONE,f),u=x.cmov(u,x.ONE,f);const[p,m]=(0,c.FpInvertBatch)(x,[i,u],!0);return{x:x.mul(s,p),y:x.mul(a,m)}}(e[0])),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:v,m:1,k:128,expand:"xmd",hash:r.sha512});const T=E,H=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),C=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),R=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),F=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),N=e=>S(h,e),k=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),V=e=>t.ed25519.Point.Fp.create((0,l.bytesToNumberLE)(e)&k);function U(e){const{d:n}=m,r=v,o=e=>x.create(e),s=o(T*e*e),i=o((s+h)*R);let a=BigInt(-1);const u=o((a-n*s)*o(s+n));let{isValid:l,value:f}=S(i,u),d=o(f*e);(0,c.isNegativeLE)(d,r)||(d=o(-d)),l||(f=d),l||(a=s);const p=o(a*(s-h)*F-u),y=f*f,g=o((f+f)*u),b=o(p*H),w=o(h-y),E=o(h+y);return new t.ed25519.Point(o(g*E),o(w*b),o(b*E),o(g*w))}function K(e){(0,o.abytes)(e,64);const t=U(V(e.subarray(0,32))),n=U(V(e.subarray(32,64)));return new j(t.add(n))}class j extends i.PrimeEdwardsPoint{constructor(e){super(e)}static fromAffine(e){return new j(t.ed25519.Point.fromAffine(e))}assertSame(e){if(!(e instanceof j))throw new Error("RistrettoPoint expected")}init(e){return new j(e)}static hashToCurve(e){return K((0,l.ensureBytes)("ristrettoHash",e,64))}static fromBytes(e){(0,o.abytes)(e,32);const{a:n,d:r}=m,s=v,i=e=>x.create(e),a=V(e);if(!(0,l.equalBytes)(x.toBytes(a),e)||(0,c.isNegativeLE)(a,s))throw new Error("invalid ristretto255 encoding 1");const u=i(a*a),d=i(h+n*u),p=i(h-n*u),y=i(d*d),g=i(p*p),b=i(n*r*y-g),{isValid:w,value:E}=N(i(b*g)),S=i(E*p),B=i(E*S*b);let I=i((a+a)*S);(0,c.isNegativeLE)(I,s)&&(I=i(-I));const A=i(d*B),_=i(I*A);if(!w||(0,c.isNegativeLE)(_,s)||A===f)throw new Error("invalid ristretto255 encoding 2");return new j(new t.ed25519.Point(I,A,h,_))}static fromHex(e){return j.fromBytes((0,l.ensureBytes)("ristrettoHex",e,32))}static msm(e,n){return(0,s.pippenger)(j,t.ed25519.Point.Fn,e,n)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep;const o=v,s=e=>x.create(e),i=s(s(n+t)*s(n-t)),a=s(e*t),u=s(a*a),{value:l}=N(s(i*u)),f=s(l*i),h=s(l*a),d=s(f*h*r);let p;if((0,c.isNegativeLE)(r*d,o)){let n=s(t*T),r=s(e*T);e=n,t=r,p=s(f*C)}else p=h;(0,c.isNegativeLE)(e*d,o)&&(t=s(-t));let y=s((n-t)*p);return(0,c.isNegativeLE)(y,o)&&(y=s(-y)),x.toBytes(y)}equals(e){this.assertSame(e);const{X:t,Y:n}=this.ep,{X:r,Y:o}=e.ep,s=e=>x.create(e),i=s(t*o)===s(n*r),a=s(n*o)===s(t*r);return i||a}is0(){return this.equals(j.ZERO)}}function M(e){return t.ed25519.utils.toMontgomery((0,l.ensureBytes)("pub",e))}j.BASE=(()=>new j(t.ed25519.Point.BASE))(),j.ZERO=(()=>new j(t.ed25519.Point.ZERO))(),j.Fp=(()=>x)(),j.Fn=(()=>B)(),t.ristretto255={Point:j},t.ristretto255_hasher={hashToCurve(e,t){const n=t?.DST||"ristretto255_XMD:SHA-512_R255MAP_RO_";return K((0,a.expand_message_xmd)(e,n,64,r.sha512))},hashToScalar(e,t={DST:a._DST_scalar}){const n=(0,a.expand_message_xmd)(e,t.DST,64,r.sha512);return B.create((0,l.bytesToNumberLE)(n))}},t.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],t.edwardsToMontgomery=M,t.RistrettoPoint=j,t.hashToCurve=t.ed25519_hasher.hashToCurve,t.encodeToCurve=t.ed25519_hasher.encodeToCurve,t.hashToRistretto255=t.ristretto255_hasher.hashToCurve,t.hash_to_ristretto255=t.ristretto255_hasher.hashToCurve},8510:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeToCurve=t.hashToCurve=t.secp256k1_hasher=t.schnorr=t.secp256k1=void 0;const r=n(7076),o=n(9175),s=n(3562),i=n(1761),a=n(4967),c=n(1705),u=n(8627),l={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},h=BigInt(0),d=BigInt(1),p=BigInt(2),y=(0,a.Field)(l.p,{sqrt:function(e){const t=l.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),u=BigInt(88),f=e*e*e%t,h=f*f*e%t,d=(0,a.pow2)(h,n,t)*h%t,g=(0,a.pow2)(d,n,t)*h%t,v=(0,a.pow2)(g,p,t)*f%t,m=(0,a.pow2)(v,o,t)*v%t,b=(0,a.pow2)(m,s,t)*m%t,w=(0,a.pow2)(b,c,t)*b%t,E=(0,a.pow2)(w,u,t)*w%t,S=(0,a.pow2)(E,c,t)*b%t,x=(0,a.pow2)(S,n,t)*h%t,B=(0,a.pow2)(x,i,t)*m%t,I=(0,a.pow2)(B,r,t)*f%t,A=(0,a.pow2)(I,p,t);if(!y.eql(y.sqr(A),e))throw new Error("Cannot find square root");return A}});t.secp256k1=(0,s.createCurve)({...l,Fp:y,lowS:!0,endo:f},r.sha256);const g={};function v(e,...t){let n=g[e];if(void 0===n){const t=(0,r.sha256)((0,u.utf8ToBytes)(e));n=(0,u.concatBytes)(t,t),g[e]=n}return(0,r.sha256)((0,u.concatBytes)(n,...t))}const m=e=>e.toBytes(!0).slice(1),b=(()=>t.secp256k1.Point)(),w=e=>e%p===h;function E(e){const{Fn:t,BASE:n}=b,r=(0,c._normFnElement)(t,e),o=n.multiply(r);return{scalar:w(o.y)?r:t.neg(r),bytes:m(o)}}function S(e){const t=y;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),r=t.create(n*e+BigInt(7));let o=t.sqrt(r);w(o)||(o=t.neg(o));const s=b.fromAffine({x:e,y:o});return s.assertValidity(),s}const x=u.bytesToNumberBE;function B(...e){return b.Fn.create(x(v("BIP0340/challenge",...e)))}function I(e){return E(e).bytes}function A(e,t,n=(0,o.randomBytes)(32)){const{Fn:r}=b,s=(0,u.ensureBytes)("message",e),{bytes:i,scalar:a}=E(t),c=(0,u.ensureBytes)("auxRand",n,32),l=r.toBytes(a^x(v("BIP0340/aux",c))),f=v("BIP0340/nonce",l,i,s),{bytes:h,scalar:d}=E(f),p=B(h,i,s),y=new Uint8Array(64);if(y.set(h,0),y.set(r.toBytes(r.create(d+p*a)),32),!_(y,s,i))throw new Error("sign: Invalid signature produced");return y}function _(e,t,n){const{Fn:r,BASE:o}=b,s=(0,u.ensureBytes)("signature",e,64),i=(0,u.ensureBytes)("message",t),a=(0,u.ensureBytes)("publicKey",n,32);try{const e=S(x(a)),t=x(s.subarray(0,32));if(!(0,u.inRange)(t,d,l.p))return!1;const n=x(s.subarray(32,64));if(!(0,u.inRange)(n,d,l.n))return!1;const c=B(r.toBytes(t),m(e),i),f=o.multiplyUnsafe(n).add(e.multiplyUnsafe(r.neg(c))),{x:h,y:p}=f.toAffine();return!(f.is0()||!w(p)||h!==t)}catch(e){return!1}}t.schnorr=(()=>{const e=(e=(0,o.randomBytes)(48))=>(0,a.mapHashToField)(e,l.n);return t.secp256k1.utils.randomSecretKey,{keygen:function(t){const n=e(t);return{secretKey:n,publicKey:I(n)}},getPublicKey:I,sign:A,verify:_,Point:b,utils:{randomSecretKey:e,randomPrivateKey:e,taggedHash:v,lift_x:S,pointToBytes:m,numberToBytesBE:u.numberToBytesBE,bytesToNumberBE:u.bytesToNumberBE,mod:a.mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();const O=(()=>(0,i.isogenyMap)(y,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))(),P=(()=>(0,c.mapToCurveSimpleSWU)(y,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:y.create(BigInt("-11"))}))();t.secp256k1_hasher=(0,i.createHasher)(t.secp256k1.Point,(e=>{const{x:t,y:n}=P(y.create(e[0]));return O(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:y.ORDER,m:1,k:128,expand:"xmd",hash:r.sha256}),t.hashToCurve=t.secp256k1_hasher.hashToCurve,t.encodeToCurve=t.secp256k1_hasher.encodeToCurve},8627:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notImplemented=t.bitMask=t.utf8ToBytes=t.randomBytes=t.isBytes=t.hexToBytes=t.concatBytes=t.bytesToUtf8=t.bytesToHex=t.anumber=t.abytes=void 0,t.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},t._abool2=function(e,t=""){if("boolean"!=typeof e)throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e);return e},t._abytes2=function(e,t,n=""){const o=(0,r.isBytes)(e),s=e?.length,i=void 0!==t;if(!o||i&&s!==t)throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(o?`length=${s}`:"type="+typeof e));return e},t.numberToHexUnpadded=a,t.hexToNumber=c,t.bytesToNumberBE=function(e){return c((0,r.bytesToHex)(e))},t.bytesToNumberLE=function(e){return(0,r.abytes)(e),c((0,r.bytesToHex)(Uint8Array.from(e).reverse()))},t.numberToBytesBE=u,t.numberToBytesLE=function(e,t){return u(e,t).reverse()},t.numberToVarBytesBE=function(e){return(0,r.hexToBytes)(a(e))},t.ensureBytes=function(e,t,n){let o;if("string"==typeof t)try{o=(0,r.hexToBytes)(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!(0,r.isBytes)(t))throw new Error(e+" must be hex string or Uint8Array");o=Uint8Array.from(t)}const s=o.length;if("number"==typeof n&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return o},t.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},t.copyBytes=function(e){return Uint8Array.from(e)},t.asciiToBytes=function(e){return Uint8Array.from(e,((t,n)=>{const r=t.charCodeAt(0);if(1!==t.length||r>127)throw new Error(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r}))},t.inRange=f,t.aInRange=function(e,t,n,r){if(!f(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)},t.bitLen=function(e){let t;for(t=0;e>s;e>>=i,t+=1);return t},t.bitGet=function(e,t){return e>>BigInt(t)&i},t.bitSet=function(e,t,n){return e|(n?i:s)<<BigInt(t)},t.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const o=e=>new Uint8Array(e),s=e=>Uint8Array.of(e);let i=o(e),a=o(e),c=0;const u=()=>{i.fill(1),a.fill(0),c=0},l=(...e)=>n(a,i,...e),f=(e=o(0))=>{a=l(s(0),e),i=l(),0!==e.length&&(a=l(s(1),e),i=l())},h=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=l();const t=i.slice();n.push(t),e+=i.length}return(0,r.concatBytes)(...n)};return(e,t)=>{let n;for(u(),f(e);!(n=t(h()));)f();return u(),n}},t.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const o=h[n];if("function"!=typeof o)throw new Error("invalid validator function");const s=e[t];if(!(r&&void 0===s||o(s,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+s)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},t.isHash=function(e){return"function"==typeof e&&Number.isSafeInteger(e.outputLen)},t._validateObject=function(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const o=e[t];if(r&&void 0===o)return;const s=typeof o;if(s!==n||null===o)throw new Error(`param "${t}" is invalid: expected ${n}, got ${s}`)}Object.entries(t).forEach((([e,t])=>r(e,t,!1))),Object.entries(n).forEach((([e,t])=>r(e,t,!0)))},t.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const s=e(n,...r);return t.set(n,s),s}};const r=n(9175);var o=n(9175);Object.defineProperty(t,"abytes",{enumerable:!0,get:function(){return o.abytes}}),Object.defineProperty(t,"anumber",{enumerable:!0,get:function(){return o.anumber}}),Object.defineProperty(t,"bytesToHex",{enumerable:!0,get:function(){return o.bytesToHex}}),Object.defineProperty(t,"bytesToUtf8",{enumerable:!0,get:function(){return o.bytesToUtf8}}),Object.defineProperty(t,"concatBytes",{enumerable:!0,get:function(){return o.concatBytes}}),Object.defineProperty(t,"hexToBytes",{enumerable:!0,get:function(){return o.hexToBytes}}),Object.defineProperty(t,"isBytes",{enumerable:!0,get:function(){return o.isBytes}}),Object.defineProperty(t,"randomBytes",{enumerable:!0,get:function(){return o.randomBytes}}),Object.defineProperty(t,"utf8ToBytes",{enumerable:!0,get:function(){return o.utf8ToBytes}});const s=BigInt(0),i=BigInt(1);function a(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function c(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?s:BigInt("0x"+e)}function u(e,t){return(0,r.hexToBytes)(e.toString(16).padStart(2*t,"0"))}const l=e=>"bigint"==typeof e&&s<=e;function f(e,t,n){return l(e)&&l(t)&&l(n)&&t<=e&&e<n}t.bitMask=e=>(i<<BigInt(e))-i;const h={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||(0,r.isBytes)(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};t.notImplemented=()=>{throw new Error("not implemented")}},7202:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SHA512_IV=t.SHA384_IV=t.SHA224_IV=t.SHA256_IV=t.HashMD=void 0,t.setBigUint64=o,t.Chi=function(e,t,n){return e&t^~e&n},t.Maj=function(e,t,n){return e&t^e&n^t&n};const r=n(9175);function o(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}class s extends r.Hash{constructor(e,t,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=(0,r.createView)(this.buffer)}update(e){(0,r.aexists)(this),e=(0,r.toBytes)(e),(0,r.abytes)(e);const{view:t,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a!==o)n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(t,0),this.pos=0);else{const t=(0,r.createView)(e);for(;o<=s-i;i+=o)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:i}=this;let{pos:a}=this;t[a++]=128,(0,r.clean)(this.buffer.subarray(a)),this.padOffset>s-a&&(this.process(n,0),a=0);for(let e=a;e<s;e++)t[e]=0;o(n,s-8,BigInt(8*this.length),i),this.process(n,0);const c=(0,r.createView)(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)c.setUint32(4*e,f[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=r,e.pos=i,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}t.HashMD=s,t.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),t.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),t.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])},2318:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toBig=t.shrSL=t.shrSH=t.rotrSL=t.rotrSH=t.rotrBL=t.rotrBH=t.rotr32L=t.rotr32H=t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=t.add5L=t.add5H=t.add4L=t.add4H=t.add3L=t.add3H=void 0,t.add=b,t.fromBig=o,t.split=s;const n=BigInt(2**32-1),r=BigInt(32);function o(e,t=!1){return t?{h:Number(e&n),l:Number(e>>r&n)}:{h:0|Number(e>>r&n),l:0|Number(e&n)}}function s(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:a}=o(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]}const i=(e,t)=>BigInt(e>>>0)<<r|BigInt(t>>>0);t.toBig=i;const a=(e,t,n)=>e>>>n;t.shrSH=a;const c=(e,t,n)=>e<<32-n|t>>>n;t.shrSL=c;const u=(e,t,n)=>e>>>n|t<<32-n;t.rotrSH=u;const l=(e,t,n)=>e<<32-n|t>>>n;t.rotrSL=l;const f=(e,t,n)=>e<<64-n|t>>>n-32;t.rotrBH=f;const h=(e,t,n)=>e>>>n-32|t<<64-n;t.rotrBL=h;const d=(e,t)=>t;t.rotr32H=d;const p=(e,t)=>e;t.rotr32L=p;const y=(e,t,n)=>e<<n|t>>>32-n;t.rotlSH=y;const g=(e,t,n)=>t<<n|e>>>32-n;t.rotlSL=g;const v=(e,t,n)=>t<<n-32|e>>>64-n;t.rotlBH=v;const m=(e,t,n)=>e<<n-32|t>>>64-n;function b(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:0|o}}t.rotlBL=m;const w=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);t.add3L=w;const E=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;t.add3H=E;const S=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);t.add4L=S;const x=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0;t.add4H=x;const B=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0);t.add5L=B;const I=(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0;t.add5H=I;const A={fromBig:o,split:s,toBig:i,shrSH:a,shrSL:c,rotrSH:u,rotrSL:l,rotrBH:f,rotrBL:h,rotr32H:d,rotr32L:p,rotlSH:y,rotlSL:g,rotlBH:v,rotlBL:m,add:b,add3L:w,add3H:E,add4L:S,add4H:x,add5H:I,add5L:B};t.default=A},5145:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},4139:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hkdf=void 0,t.extract=s,t.expand=c;const r=n(9615),o=n(9175);function s(e,t,n){return(0,o.ahash)(e),void 0===n&&(n=new Uint8Array(e.outputLen)),(0,r.hmac)(e,(0,o.toBytes)(n),(0,o.toBytes)(t))}const i=Uint8Array.from([0]),a=Uint8Array.of();function c(e,t,n,s=32){(0,o.ahash)(e),(0,o.anumber)(s);const c=e.outputLen;if(s>255*c)throw new Error("Length should be <= 255*HashLen");const u=Math.ceil(s/c);void 0===n&&(n=a);const l=new Uint8Array(u*c),f=r.hmac.create(e,t),h=f._cloneInto(),d=new Uint8Array(f.outputLen);for(let e=0;e<u;e++)i[0]=e+1,h.update(0===e?a:d).update(n).update(i).digestInto(d),l.set(d,c*e),f._cloneInto(h);return f.destroy(),h.destroy(),(0,o.clean)(d,i),l.slice(0,s)}t.hkdf=(e,t,n,r,o)=>c(e,s(e,t,n),r,o)},9615:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const r=n(9175);class o extends r.Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,(0,r.ahash)(e);const n=(0,r.toBytes)(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),(0,r.clean)(s)}update(e){return(0,r.aexists)(this),this.iHash.update(e),this}digestInto(e){(0,r.aexists)(this),(0,r.abytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:s,outputLen:i}=this;return e.finished=r,e.destroyed=o,e.blockLen=s,e.outputLen=i,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}t.HMAC=o,t.hmac=(e,t,n)=>new o(e,t).update(n).digest(),t.hmac.create=(e,t)=>new o(e,t)},7076:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_224=t.sha512_256=t.sha384=t.sha512=t.sha224=t.sha256=t.SHA512_256=t.SHA512_224=t.SHA384=t.SHA512=t.SHA224=t.SHA256=void 0;const r=n(7202),o=n(2318),s=n(9175),i=Uint32Array.from([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]),a=new Uint32Array(64);class c extends r.HashMD{constructor(e=32){super(64,e,8,!1),this.A=0|r.SHA256_IV[0],this.B=0|r.SHA256_IV[1],this.C=0|r.SHA256_IV[2],this.D=0|r.SHA256_IV[3],this.E=0|r.SHA256_IV[4],this.F=0|r.SHA256_IV[5],this.G=0|r.SHA256_IV[6],this.H=0|r.SHA256_IV[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:i,H:a}=this;return[e,t,n,r,o,s,i,a]}set(e,t,n,r,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)a[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=a[e-15],n=a[e-2],r=(0,s.rotr)(t,7)^(0,s.rotr)(t,18)^t>>>3,o=(0,s.rotr)(n,17)^(0,s.rotr)(n,19)^n>>>10;a[e]=o+a[e-7]+r+a[e-16]|0}let{A:n,B:o,C:c,D:u,E:l,F:f,G:h,H:d}=this;for(let e=0;e<64;e++){const t=d+((0,s.rotr)(l,6)^(0,s.rotr)(l,11)^(0,s.rotr)(l,25))+(0,r.Chi)(l,f,h)+i[e]+a[e]|0,p=((0,s.rotr)(n,2)^(0,s.rotr)(n,13)^(0,s.rotr)(n,22))+(0,r.Maj)(n,o,c)|0;d=h,h=f,f=l,l=u+t|0,u=c,c=o,o=n,n=t+p|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,u=u+this.D|0,l=l+this.E|0,f=f+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(n,o,c,u,l,f,h,d)}roundClean(){(0,s.clean)(a)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,s.clean)(this.buffer)}}t.SHA256=c;class u extends c{constructor(){super(28),this.A=0|r.SHA224_IV[0],this.B=0|r.SHA224_IV[1],this.C=0|r.SHA224_IV[2],this.D=0|r.SHA224_IV[3],this.E=0|r.SHA224_IV[4],this.F=0|r.SHA224_IV[5],this.G=0|r.SHA224_IV[6],this.H=0|r.SHA224_IV[7]}}t.SHA224=u;const l=(()=>o.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),f=(()=>l[0])(),h=(()=>l[1])(),d=new Uint32Array(80),p=new Uint32Array(80);class y extends r.HashMD{constructor(e=64){super(128,e,16,!1),this.Ah=0|r.SHA512_IV[0],this.Al=0|r.SHA512_IV[1],this.Bh=0|r.SHA512_IV[2],this.Bl=0|r.SHA512_IV[3],this.Ch=0|r.SHA512_IV[4],this.Cl=0|r.SHA512_IV[5],this.Dh=0|r.SHA512_IV[6],this.Dl=0|r.SHA512_IV[7],this.Eh=0|r.SHA512_IV[8],this.El=0|r.SHA512_IV[9],this.Fh=0|r.SHA512_IV[10],this.Fl=0|r.SHA512_IV[11],this.Gh=0|r.SHA512_IV[12],this.Gl=0|r.SHA512_IV[13],this.Hh=0|r.SHA512_IV[14],this.Hl=0|r.SHA512_IV[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:o,Cl:s,Dh:i,Dl:a,Eh:c,El:u,Fh:l,Fl:f,Gh:h,Gl:d,Hh:p,Hl:y}=this;return[e,t,n,r,o,s,i,a,c,u,l,f,h,d,p,y]}set(e,t,n,r,o,s,i,a,c,u,l,f,h,d,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|f,this.Gh=0|h,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let n=0;n<16;n++,t+=4)d[n]=e.getUint32(t),p[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|d[e-15],n=0|p[e-15],r=o.rotrSH(t,n,1)^o.rotrSH(t,n,8)^o.shrSH(t,n,7),s=o.rotrSL(t,n,1)^o.rotrSL(t,n,8)^o.shrSL(t,n,7),i=0|d[e-2],a=0|p[e-2],c=o.rotrSH(i,a,19)^o.rotrBH(i,a,61)^o.shrSH(i,a,6),u=o.rotrSL(i,a,19)^o.rotrBL(i,a,61)^o.shrSL(i,a,6),l=o.add4L(s,u,p[e-7],p[e-16]),f=o.add4H(l,r,c,d[e-7],d[e-16]);d[e]=0|f,p[e]=0|l}let{Ah:n,Al:r,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:y,El:g,Fh:v,Fl:m,Gh:b,Gl:w,Hh:E,Hl:S}=this;for(let e=0;e<80;e++){const t=o.rotrSH(y,g,14)^o.rotrSH(y,g,18)^o.rotrBH(y,g,41),x=o.rotrSL(y,g,14)^o.rotrSL(y,g,18)^o.rotrBL(y,g,41),B=y&v^~y&b,I=g&m^~g&w,A=o.add5L(S,x,I,h[e],p[e]),_=o.add5H(A,E,t,B,f[e],d[e]),O=0|A,P=o.rotrSH(n,r,28)^o.rotrBH(n,r,34)^o.rotrBH(n,r,39),L=o.rotrSL(n,r,28)^o.rotrBL(n,r,34)^o.rotrBL(n,r,39),T=n&s^n&a^s&a,H=r&i^r&c^i&c;E=0|b,S=0|w,b=0|v,w=0|m,v=0|y,m=0|g,({h:y,l:g}=o.add(0|u,0|l,0|_,0|O)),u=0|a,l=0|c,a=0|s,c=0|i,s=0|n,i=0|r;const C=o.add3L(O,L,H);n=o.add3H(C,_,P,T),r=0|C}({h:n,l:r}=o.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:s,l:i}=o.add(0|this.Bh,0|this.Bl,0|s,0|i)),({h:a,l:c}=o.add(0|this.Ch,0|this.Cl,0|a,0|c)),({h:u,l}=o.add(0|this.Dh,0|this.Dl,0|u,0|l)),({h:y,l:g}=o.add(0|this.Eh,0|this.El,0|y,0|g)),({h:v,l:m}=o.add(0|this.Fh,0|this.Fl,0|v,0|m)),({h:b,l:w}=o.add(0|this.Gh,0|this.Gl,0|b,0|w)),({h:E,l:S}=o.add(0|this.Hh,0|this.Hl,0|E,0|S)),this.set(n,r,s,i,a,c,u,l,y,g,v,m,b,w,E,S)}roundClean(){(0,s.clean)(d,p)}destroy(){(0,s.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=y;class g extends y{constructor(){super(48),this.Ah=0|r.SHA384_IV[0],this.Al=0|r.SHA384_IV[1],this.Bh=0|r.SHA384_IV[2],this.Bl=0|r.SHA384_IV[3],this.Ch=0|r.SHA384_IV[4],this.Cl=0|r.SHA384_IV[5],this.Dh=0|r.SHA384_IV[6],this.Dl=0|r.SHA384_IV[7],this.Eh=0|r.SHA384_IV[8],this.El=0|r.SHA384_IV[9],this.Fh=0|r.SHA384_IV[10],this.Fl=0|r.SHA384_IV[11],this.Gh=0|r.SHA384_IV[12],this.Gl=0|r.SHA384_IV[13],this.Hh=0|r.SHA384_IV[14],this.Hl=0|r.SHA384_IV[15]}}t.SHA384=g;const v=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),m=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class b extends y{constructor(){super(28),this.Ah=0|v[0],this.Al=0|v[1],this.Bh=0|v[2],this.Bl=0|v[3],this.Ch=0|v[4],this.Cl=0|v[5],this.Dh=0|v[6],this.Dl=0|v[7],this.Eh=0|v[8],this.El=0|v[9],this.Fh=0|v[10],this.Fl=0|v[11],this.Gh=0|v[12],this.Gl=0|v[13],this.Hh=0|v[14],this.Hl=0|v[15]}}t.SHA512_224=b;class w extends y{constructor(){super(32),this.Ah=0|m[0],this.Al=0|m[1],this.Bh=0|m[2],this.Bl=0|m[3],this.Ch=0|m[4],this.Cl=0|m[5],this.Dh=0|m[6],this.Dl=0|m[7],this.Eh=0|m[8],this.El=0|m[9],this.Fh=0|m[10],this.Fl=0|m[11],this.Gh=0|m[12],this.Gl=0|m[13],this.Hh=0|m[14],this.Hl=0|m[15]}}t.SHA512_256=w,t.sha256=(0,s.createHasher)((()=>new c)),t.sha224=(0,s.createHasher)((()=>new u)),t.sha512=(0,s.createHasher)((()=>new y)),t.sha384=(0,s.createHasher)((()=>new g)),t.sha512_256=(0,s.createHasher)((()=>new w)),t.sha512_224=(0,s.createHasher)((()=>new b))},9175:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.Hash=t.nextTick=t.swap32IfBE=t.byteSwapIfBE=t.swap8IfBE=t.isLE=void 0,t.isBytes=o,t.anumber=s,t.abytes=i,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");s(e.outputLen),s(e.blockLen)},t.aexists=function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},t.aoutput=function(e,t){i(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},t.rotr=function(e,t){return e<<32-t|e>>>t},t.rotl=function(e,t){return e<<t|e>>>32-t>>>0},t.byteSwap=a,t.byteSwap32=c,t.bytesToHex=function(e){if(i(e),u)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=l[e[n]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(u)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,o=0;t<n;t++,o+=2){const n=h(e.charCodeAt(o)),s=h(e.charCodeAt(o+1));if(void 0===n||void 0===s){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+s}return r},t.asyncLoop=async function(e,n,r){let o=Date.now();for(let s=0;s<e;s++){r(s);const e=Date.now()-o;e>=0&&e<n||(await(0,t.nextTick)(),o+=e)}},t.utf8ToBytes=d,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=p,t.kdfInputToBytes=function(e){return"string"==typeof e&&(e=d(e)),i(e),e},t.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];i(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n},t.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)},t.createHasher=y,t.createOptHasher=g,t.createXOFer=v,t.randomBytes=function(e=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(e));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return Uint8Array.from(r.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")};const r=n(5145);function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function s(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function i(e,...t){if(!o(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function c(e){for(let t=0;t<e.length;t++)e[t]=a(e[t]);return e}t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.swap8IfBE=t.isLE?e=>e:e=>a(e),t.byteSwapIfBE=t.swap8IfBE,t.swap32IfBE=t.isLE?e=>e:c;const u=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),l=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0"))),f={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(e){return e>=f._0&&e<=f._9?e-f._0:e>=f.A&&e<=f.F?e-(f.A-10):e>=f.a&&e<=f.f?e-(f.a-10):void 0}function d(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function p(e){return"string"==typeof e&&(e=d(e)),i(e),e}function y(e){const t=t=>e().update(p(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function g(e){const t=(t,n)=>e(n).update(p(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function v(e){const t=(t,n)=>e(n).update(p(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}t.nextTick=async()=>{},t.Hash=class{},t.wrapConstructor=y,t.wrapConstructorWithOpts=g,t.wrapXOFConstructorWithOpts=v},4928:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ephemeralKeySize=t.symmetricNonceLength=t.symmetricAlgorithm=t.isHkdfKeyCompressed=t.isEphemeralKeyCompressed=t.ellipticCurve=t.ECIES_CONFIG=void 0;var r=n(1666);t.ECIES_CONFIG=new function(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16},t.ellipticCurve=function(){return t.ECIES_CONFIG.ellipticCurve},t.isEphemeralKeyCompressed=function(){return t.ECIES_CONFIG.isEphemeralKeyCompressed},t.isHkdfKeyCompressed=function(){return t.ECIES_CONFIG.isHkdfKeyCompressed},t.symmetricAlgorithm=function(){return t.ECIES_CONFIG.symmetricAlgorithm},t.symmetricNonceLength=function(){return t.ECIES_CONFIG.symmetricNonceLength},t.ephemeralKeySize=function(){var e={secp256k1:t.ECIES_CONFIG.isEphemeralKeyCompressed?r.COMPRESSED_PUBLIC_KEY_SIZE:r.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:r.CURVE25519_PUBLIC_KEY_SIZE,ed25519:r.CURVE25519_PUBLIC_KEY_SIZE};if(t.ECIES_CONFIG.ellipticCurve in e)return e[t.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")}},1666:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AEAD_TAG_LENGTH=t.XCHACHA20_NONCE_LENGTH=t.CURVE25519_PUBLIC_KEY_SIZE=t.ETH_PUBLIC_KEY_SIZE=t.UNCOMPRESSED_PUBLIC_KEY_SIZE=t.COMPRESSED_PUBLIC_KEY_SIZE=t.SECRET_KEY_LENGTH=void 0,t.SECRET_KEY_LENGTH=32,t.COMPRESSED_PUBLIC_KEY_SIZE=33,t.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,t.ETH_PUBLIC_KEY_SIZE=64,t.CURVE25519_PUBLIC_KEY_SIZE=32,t.XCHACHA20_NONCE_LENGTH=24,t.AEAD_TAG_LENGTH=16},6748:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.PublicKey=t.PrivateKey=t.ECIES_CONFIG=void 0,t.encrypt=function(e,t){return Buffer.from(function(e,t){var n=(0,o.ellipticCurve)(),a=new s.PrivateKey(void 0,n),c=e instanceof Uint8Array?new s.PublicKey(e,n):s.PublicKey.fromHex(e,n),u=a.encapsulate(c,(0,o.isHkdfKeyCompressed)()),l=a.publicKey.toBytes((0,o.isEphemeralKeyCompressed)()),f=(0,i.symEncrypt)(u,t);return(0,r.concatBytes)(l,f)}(e,t))},t.decrypt=function(e,t){return Buffer.from(function(e,t){var n=(0,o.ellipticCurve)(),r=e instanceof Uint8Array?new s.PrivateKey(e,n):s.PrivateKey.fromHex(e,n),a=(0,o.ephemeralKeySize)(),c=new s.PublicKey(t.subarray(0,a),n),u=t.subarray(a),l=c.decapsulate(r,(0,o.isHkdfKeyCompressed)());return(0,i.symDecrypt)(l,u)}(e,t))};var r=n(6527),o=n(4928),s=n(9065),i=n(2158),a=n(4928);Object.defineProperty(t,"ECIES_CONFIG",{enumerable:!0,get:function(){return a.ECIES_CONFIG}});var c=n(9065);Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return c.PrivateKey}}),Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return c.PublicKey}}),t.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}},5295:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PrivateKey=void 0;var r=n(6527),o=n(2158),s=n(2557),i=function(){function e(e,t){if(this.curve=t,void 0===e)this.data=(0,o.getValidSecret)(t);else{if(!(0,o.isValidPrivateKey)(e,t))throw new Error("Invalid private key");this.data=e}this.publicKey=new s.PublicKey((0,o.getPublicKey)(this.data,t),t)}return e.fromHex=function(t,n){return new e((0,o.decodeHex)(t),n)},Object.defineProperty(e.prototype,"secret",{get:function(){return Buffer.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(){return(0,r.bytesToHex)(this.data)},e.prototype.encapsulate=function(e,t){void 0===t&&(t=!1);var n=this.publicKey.toBytes(t),r=this.multiply(e,t);return(0,o.getSharedKey)(n,r)},e.prototype.multiply=function(e,t){return void 0===t&&(t=!1),(0,o.getSharedPoint)(this.data,e.toBytes(!0),t,this.curve)},e.prototype.equals=function(e){return(0,r.equalBytes)(this.data,e.data)},e}();t.PrivateKey=i},2557:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PublicKey=void 0;var r=n(6527),o=n(2158),s=function(){function e(e,t){var n=(0,o.convertPublicKeyFormat)(e,!0,t),r=(0,o.convertPublicKeyFormat)(e,!1,t);this.data=n,this.dataUncompressed=n.length!==r.length?r:null}return e.fromHex=function(t,n){return new e((0,o.hexToPublicKey)(t,n),n)},Object.defineProperty(e.prototype,"_uncompressed",{get:function(){return null!==this.dataUncompressed?this.dataUncompressed:this.data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uncompressed",{get:function(){return Buffer.from(this._uncompressed)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"compressed",{get:function(){return Buffer.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toBytes=function(e){return void 0===e&&(e=!0),e?this.data:this._uncompressed},e.prototype.toHex=function(e){return void 0===e&&(e=!0),(0,r.bytesToHex)(this.toBytes(e))},e.prototype.decapsulate=function(e,t){void 0===t&&(t=!1);var n=this.toBytes(t),r=e.multiply(this,t);return(0,o.getSharedKey)(n,r)},e.prototype.equals=function(e){return(0,r.equalBytes)(this.data,e.data)},e}();t.PublicKey=s},9065:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PublicKey=t.PrivateKey=void 0;var r=n(5295);Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return r.PrivateKey}});var o=n(2557);Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return o.PublicKey}})},9378:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hexToPublicKey=t.convertPublicKeyFormat=t.getSharedPoint=t.getPublicKey=t.isValidPrivateKey=t.getValidSecret=void 0;var r=n(8489),o=n(459),s=n(8510),i=n(4928),a=n(1666),c=n(3503);function u(e,t,n,r){var a=e||(0,i.ellipticCurve)();if("secp256k1"===a)return t(s.secp256k1);if("x25519"===a)return n(o.x25519);if("ed25519"===a)return r(o.ed25519);throw new Error("Not implemented")}t.getValidSecret=function(e){var n;do{n=(0,r.randomBytes)(a.SECRET_KEY_LENGTH)}while(!(0,t.isValidPrivateKey)(n,e));return n},t.isValidPrivateKey=function(e,t){return u(t,(function(t){return t.utils.isValidSecretKey(e)}),(function(){return!0}),(function(){return!0}))},t.getPublicKey=function(e,t){return u(t,(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}))},t.getSharedPoint=function(e,t,n,r){return u(r,(function(r){return r.getSharedSecret(e,t,n)}),(function(n){return n.getSharedSecret(e,t)}),(function(n){return f(n,e,t)}))},t.convertPublicKeyFormat=function(e,t,n){return u(n,(function(n){return n.getSharedSecret(Uint8Array.from(Array(31).fill(0).concat([1])),e,t)}),(function(){return e}),(function(){return e}))},t.hexToPublicKey=function(e,t){var n=(0,c.decodeHex)(e);return u(t,(function(){return l(n)}),(function(){return n}),(function(){return n}))};var l=function(e){if(e.length===a.ETH_PUBLIC_KEY_SIZE){var t=new Uint8Array(1+e.length);return t.set([4]),t.set(e,1),t}return e},f=function(e,t,n){var r=e.utils.getExtendedPublicKey(t).scalar;return e.Point.fromBytes(n).multiply(r).toBytes()}},244:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSharedKey=t.deriveKey=void 0;var r=n(6527),o=n(4139),s=n(7076);t.deriveKey=function(e,t,n){return(0,o.hkdf)(s.sha256,e,t,n,32)},t.getSharedKey=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(0,t.deriveKey)(r.concatBytes.apply(void 0,e))}},3503:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decodeHex=t.remove0x=void 0;var r=n(6527);t.remove0x=function(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e},t.decodeHex=function(e){return(0,r.hexToBytes)((0,t.remove0x)(e))}},2158:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(9378),t),o(n(244),t),o(n(3503),t),o(n(7757),t)},7757:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.aesDecrypt=t.aesEncrypt=t.symDecrypt=t.symEncrypt=void 0;var r=n(7678),o=n(83),s=n(6527),i=n(8489),a=n(4928),c=n(1666);function u(e,t,n,s){var i=(0,a.symmetricAlgorithm)();if("aes-256-gcm"===i)return e(r.aes256gcm,t,n,(0,a.symmetricNonceLength)(),c.AEAD_TAG_LENGTH,s);if("xchacha20"===i)return e(o.xchacha20,t,n,c.XCHACHA20_NONCE_LENGTH,c.AEAD_TAG_LENGTH,s);if("aes-256-cbc"===i)return e(r.aes256cbc,t,n,16,0);throw new Error("Not implemented")}function l(e,t,n,r,o,a){var c=(0,i.randomBytes)(r),u=e(t,c,a).encrypt(n);if(0===o)return(0,s.concatBytes)(c,u);var l=u.length-o,f=u.subarray(0,l),h=u.subarray(l);return(0,s.concatBytes)(c,h,f)}function f(e,t,n,r,o,i){var a=n.subarray(0,r),c=e(t,Uint8Array.from(a),i),u=n.subarray(r);if(0===o)return c.decrypt(u);var l=u.subarray(0,o),f=u.subarray(o);return c.decrypt((0,s.concatBytes)(f,l))}t.symEncrypt=function(e,t,n){return u(l,e,t,n)},t.symDecrypt=function(e,t,n){return u(f,e,t,n)},t.aesEncrypt=t.symEncrypt,t.aesDecrypt=t.symDecrypt},669:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoBatcher=void 0;var r=n(3611),o=function(){function e(t){var n=this;this.events=[],this.networkCallsHandler=t,this.batchFlushAttemptTimestamp=Date.now(),r.AvoInspector.avoStorage.getItemAsync(e.cacheKey).then((function(e){if(null!==e){var t=e.filter((function(e){return null!==e}));n.events=n.events.concat(t),n.checkIfBatchNeedsToBeSent()}})).catch((function(e){console.error("Avo Inspector: error getting events from cache",e)}))}return e.prototype.handleSessionStarted=function(){this.events.push(this.networkCallsHandler.bodyForSessionStartedCall()),this.saveEvents(),this.checkIfBatchNeedsToBeSent()},e.prototype.handleTrackSchema=function(e,t,n,o,s){this.events.push(this.networkCallsHandler.bodyForEventSchemaCall(e,t,n,o,s)),this.saveEvents(),r.AvoInspector.shouldLog&&console.log("Avo Inspector: saved event "+e+" with schema "+JSON.stringify(t)),this.checkIfBatchNeedsToBeSent()},e.prototype.checkIfBatchNeedsToBeSent=function(){var e=this.events.length,t=Date.now(),n=t-this.batchFlushAttemptTimestamp,o=e%r.AvoInspector.batchSize==0,s=n>=1e3*r.AvoInspector.batchFlushSeconds,i=this;if(o||s){this.batchFlushAttemptTimestamp=t;var a=i.events;i.events=[],this.networkCallsHandler.callInspectorWithBatchBody(a,(function(e){null!=e?(i.events=i.events.concat(a),r.AvoInspector.shouldLog&&console.log("Avo Inspector: batch sending failed: "+e.message+". We will attempt to send your schemas with next batch")):r.AvoInspector.shouldLog&&console.log("Avo Inspector: batch sent successfully."),i.saveEvents()}))}},e.prototype.saveEvents=function(){if(this.events.length>1e3){var t=this.events.length-1e3;this.events.splice(0,t)}r.AvoInspector.avoStorage.setItem(e.cacheKey,this.events)},Object.defineProperty(e,"cacheKey",{get:function(){return"AvoInspectorEvents"},enumerable:!1,configurable:!0}),e}();t.AvoBatcher=o},3492:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoDeduplicator=void 0;var r=n(924),o=n(6185),s=function(){function e(){this.avoFunctionsEvents={},this.manualEvents={},this.avoFunctionsEventsParams={},this.manualEventsParams={}}return e.prototype.shouldRegisterEvent=function(e,t,n){this.clearOldEvents(),n?(this.avoFunctionsEvents[Date.now()]=e,this.avoFunctionsEventsParams[e]=t):(this.manualEvents[Date.now()]=e,this.manualEventsParams[e]=t);var r=!n;return!this.hasSameEventAs(e,t,r)},e.prototype.hasSameEventAs=function(e,t,n){var r=!1;return n?this.lookForEventIn(e,t,this.avoFunctionsEventsParams)&&(r=!0):this.lookForEventIn(e,t,this.manualEventsParams)&&(r=!0),r&&(delete this.avoFunctionsEventsParams[e],delete this.manualEventsParams[e]),r},e.prototype.lookForEventIn=function(e,t,n){for(var r in n)if(n.hasOwnProperty(r)&&r===e){var s=n[e];if(s&&(0,o.deepEquals)(t,s))return!0}return!1},e.prototype.hasSeenEventParams=function(e,t){var n=!1;return t?this.lookForEventParamsIn(e,this.avoFunctionsEventsParams)&&(n=!0):this.lookForEventParamsIn(e,this.manualEventsParams)&&(n=!0),n},e.prototype.lookForEventParamsIn=function(e,t){for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];if(r&&(0,o.deepEquals)(e,r))return!0}return!1},e.prototype.shouldRegisterSchemaFromManually=function(e,t){return this.clearOldEvents(),!this.hasSameShapeInAvoFunctionsAs(e,t)},e.prototype.hasSameShapeInAvoFunctionsAs=function(e,t){var n=!1;return this.lookForEventSchemaIn(e,t,this.avoFunctionsEventsParams)&&(n=!0),n&&delete this.avoFunctionsEventsParams[e],n},e.prototype.lookForEventSchemaIn=function(e,t,n){for(var s in n)if(n.hasOwnProperty(s)&&s===e){var i=r.AvoSchemaParser.extractSchema(n[e]);if(i&&(0,o.deepEquals)(t,i))return!0}return!1},e.prototype.clearOldEvents=function(){var e=Date.now();for(var t in this.avoFunctionsEvents)if(this.avoFunctionsEvents.hasOwnProperty(t)&&e-(Number(t)||0)>300){var n=this.avoFunctionsEvents[t];delete this.avoFunctionsEvents[t],delete this.avoFunctionsEventsParams[n]}for(var t in this.manualEvents)this.manualEvents.hasOwnProperty(t)&&e-(Number(t)||0)>300&&(n=this.manualEvents[t],delete this.manualEvents[t],delete this.manualEventsParams[n])},e.prototype._clearEvents=function(){this.avoFunctionsEvents={},this.manualEvents={},this.avoFunctionsEventsParams={},this.manualEventsParams={}},e}();t.AvoDeduplicator=s},8945:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decryptValue=t.encryptValue=t.generateKeyPair=void 0;var r=n(6748);t.generateKeyPair=function(){var e=new r.PrivateKey,t=e.publicKey;return{privateKey:e.toHex(),publicKey:t.toHex()}},t.encryptValue=function(e,t){try{var n=void 0===e?"null":JSON.stringify(e);if(void 0===n)throw new Error("Cannot encrypt undefined value");var o="string"==typeof t?t:String(t),s=new Uint8Array(Buffer.from(n,"utf8")),i=(0,r.encrypt)(o,s);return Buffer.from(i).toString("base64")}catch(e){throw new Error("Failed to encrypt value. Please check that the public key is valid. Error: ".concat(e instanceof Error?e.message:String(e)))}},t.decryptValue=function(e,t){try{var n=new Uint8Array(Buffer.from(e,"base64")),o="string"==typeof t?t:String(t),s=(0,r.decrypt)(o,n),i=Buffer.from(s).toString("utf8");return JSON.parse(i)}catch(e){throw new Error("Failed to decrypt value. Please check that the private key is valid and matches the public key used for encryption. Error: ".concat(e instanceof Error?e.message:String(e)))}}},7249:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},e}();t.default=n},3611:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AvoInspector=void 0;var s=n(6844),i=n(924),a=n(669),c=n(4243),u=n(3491),l=n(3492),f=n(1499),h=n(4190),d=n(4829),p=n(5916),y=n(6185),g=n(8330).rE,v=function(){function e(t){if((0,y.isValueEmpty)(t.env)?(this.environment=s.AvoInspectorEnv.Dev,console.warn("[Avo Inspector] No environment provided. Defaulting to dev.")):Object.values(s.AvoInspectorEnv).includes(t.env)?this.environment=t.env:(this.environment=s.AvoInspectorEnv.Dev,console.warn("[Avo Inspector] Unsupported environment provided. Defaulting to dev. Supported environments - Dev, Staging, Prod.")),(0,y.isValueEmpty)(t.apiKey))throw new Error("[Avo Inspector] No API key provided. Inspector can't operate without API key.");if(this.apiKey=t.apiKey,(0,y.isValueEmpty)(t.version))throw new Error("[Avo Inspector] No version provided. Many features of Inspector rely on versioning. Please provide comparable string version, i.e. integer or semantic.");this.version=t.version,this.environment===s.AvoInspectorEnv.Dev?(e._batchSize=1,e._shouldLog=!0):(e._batchSize=30,e._batchFlushSeconds=30,e._shouldLog=!1),e.avoStorage=new u.AvoStorage(e._shouldLog,null!=t.suffix?t.suffix:""),this.avoNetworkCallsHandler=new c.AvoNetworkCallsHandler(this.apiKey,this.environment.toString(),t.appName||"",this.version,g),this.avoBatcher=new a.AvoBatcher(this.avoNetworkCallsHandler),this.avoDeduplicator=new l.AvoDeduplicator,this.publicEncryptionKey=t.publicEncryptionKey,this.streamId=d.AvoStreamId.streamId,this.streamId&&(this.eventSpecCache=new f.EventSpecCache(e._shouldLog),this.eventSpecFetcher=new h.AvoEventSpecFetcher(e._networkTimeout,e._shouldLog,this.environment),e._shouldLog&&(console.log("[Avo Inspector] Event spec fetching and validation enabled"),this.publicEncryptionKey&&console.log("[Avo Inspector] Property value encryption enabled")))}return Object.defineProperty(e,"batchSize",{get:function(){return this._batchSize},set:function(e){this._batchSize=e<1?1:e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"batchFlushSeconds",{get:function(){return this._batchFlushSeconds},enumerable:!1,configurable:!0}),Object.defineProperty(e,"shouldLog",{get:function(){return this._shouldLog},set:function(e){this._shouldLog=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"networkTimeout",{get:function(){return this._networkTimeout},set:function(e){this._networkTimeout=e},enumerable:!1,configurable:!0}),e.prototype.trackSchemaFromEvent=function(t,n){return r(this,void 0,void 0,(function(){var r,s,i,a;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.avoDeduplicator.shouldRegisterEvent(t,n,!1)?(e.shouldLog&&console.log("Avo Inspector: supplied event "+t+" with params "+JSON.stringify(n)),r=this.extractSchema(n,!1),e.shouldLog&&0===r.length&&n&&Object.keys(n).length>0&&console.warn("[Avo Inspector] WARNING: extractSchema returned empty array but eventProperties had ".concat(Object.keys(n).length," keys. This may indicate a parsing error.")),[4,this.fetchAndValidateEvent(t,n)]):[3,2];case 1:return(s=o.sent())?(i=this.mergeValidationResults(r,s),e.shouldLog&&console.log("[Avo Inspector] Sending event with ".concat(i.length," properties (validation available)")),this.sendEventWithValidation(t,i,null,null,s)):this.trackSchemaInternal(t,r,null,null),[2,r];case 2:return e.shouldLog&&console.log("Avo Inspector: Deduplicated event: "+t),[2,[]];case 3:return[3,5];case 4:return a=o.sent(),console.error("Avo Inspector: something went wrong. Please report to support@avo.app.",a),[2,[]];case 5:return[2]}}))}))},e.prototype._avoFunctionTrackSchemaFromEvent=function(t,n,s,i){return r(this,void 0,void 0,(function(){var r,a,c,u;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.avoDeduplicator.shouldRegisterEvent(t,n,!0)?(e.shouldLog&&console.log("Avo Inspector: supplied event "+t+" with params "+JSON.stringify(n)),r=this.extractSchema(n,!1),[4,this.fetchAndValidateEvent(t,n)]):[3,2];case 1:return(a=o.sent())?(c=this.mergeValidationResults(r,a),this.sendEventWithValidation(t,c,s,i,a)):this.trackSchemaInternal(t,r,s,i),[2,r];case 2:return e.shouldLog&&console.log("Avo Inspector: Deduplicated event: "+t),[2,[]];case 3:return[3,5];case 4:return u=o.sent(),console.error("Avo Inspector: something went wrong. Please report to support@avo.app.",u),[2,[]];case 5:return[2]}}))}))},e.prototype.trackSchema=function(t,n){return r(this,void 0,void 0,(function(){var r;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.avoDeduplicator.shouldRegisterSchemaFromManually(t,n)?(e.shouldLog&&console.log("Avo Inspector: supplied event "+t+" with schema "+JSON.stringify(n)),[4,this.fetchEventSpecIfNeeded(t)]):[3,2];case 1:return o.sent(),this.trackSchemaInternal(t,n,null,null),[3,3];case 2:e.shouldLog&&console.log("Avo Inspector: Deduplicated event: "+t),o.label=3;case 3:return[3,5];case 4:return r=o.sent(),console.error("Avo Inspector: something went wrong. Please report to support@avo.app.",r),[3,5];case 5:return[2]}}))}))},e.prototype.trackSchemaInternal=function(e,t,n,r){try{this.avoBatcher.handleTrackSchema(e,t,n,r)}catch(e){console.error("Avo Inspector: something went wrong. Please report to support@avo.app.",e)}},e.prototype.enableLogging=function(t){e._shouldLog=t},e.prototype.extractSchema=function(t,n){void 0===n&&(n=!0);try{this.avoDeduplicator.hasSeenEventParams(t,!0)&&n&&e.shouldLog&&console.warn("Avo Inspector: WARNING! You are trying to extract schema shape that was just reported by your Avo Codegen. This is an indicator of duplicate inspector reporting. Please reach out to support@avo.app for advice if you are not sure how to handle this."),e.shouldLog&&console.log("Avo Inspector: extracting schema from "+JSON.stringify(t));var r=i.AvoSchemaParser.extractSchema(t,this.publicEncryptionKey,this.environment);return e.shouldLog&&console.log("[Avo Inspector] Extracted schema has ".concat(r.length," properties")),r}catch(e){return console.error("Avo Inspector: something went wrong in extractSchema. Please report to support@avo.app.",e),[]}},e.prototype.setBatchSize=function(t){e._batchSize=t},e.prototype.setBatchFlushSeconds=function(t){e._batchFlushSeconds=t},e.prototype.fetchEventSpecIfNeeded=function(t){return r(this,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:if(this.environment===s.AvoInspectorEnv.Prod)return[2];if(!this.eventSpecCache||!this.eventSpecFetcher||!this.streamId)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),this.eventSpecCache.get(this.apiKey,this.streamId,t)?[2]:[4,this.eventSpecFetcher.fetch({apiKey:this.apiKey,streamId:this.streamId,eventName:t})];case 2:return(n=o.sent())&&this.eventSpecCache&&this.streamId&&this.eventSpecCache.set(this.apiKey,this.streamId,t,n),[3,4];case 3:return r=o.sent(),e.shouldLog&&console.error("[Avo Inspector] Error fetching event spec for ".concat(t,":"),r),[3,4];case 4:return[2]}}))}))},e.prototype.fetchAndValidateEvent=function(t,n){return r(this,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:if(this.environment===s.AvoInspectorEnv.Prod)return[2,null];if(!this.eventSpecCache||!this.eventSpecFetcher||!this.streamId)return[2,null];o.label=1;case 1:return o.trys.push([1,4,,5]),(r=this.eventSpecCache.get(this.apiKey,this.streamId,t))?[3,3]:[4,this.eventSpecFetcher.fetch({apiKey:this.apiKey,streamId:this.streamId,eventName:t})];case 2:(r=o.sent())&&this.eventSpecCache&&this.streamId&&this.eventSpecCache.set(this.apiKey,this.streamId,t,r),o.label=3;case 3:return r?[2,(0,p.validateEvent)(n,r)]:[2,null];case 4:return i=o.sent(),e.shouldLog&&console.error("[Avo Inspector] Error validating event ".concat(t,":"),i),[2,null];case 5:return[2]}}))}))},e.prototype.mergeValidationResults=function(e,t){var n=this;return e.map((function(e){var r=t.propertyResults[e.propertyName];return n.mergePropertyValidation(e,r)}))},e.prototype.mergePropertyValidation=function(e,t){var n=this,r={propertyName:e.propertyName,propertyType:e.propertyType};return e.encryptedPropertyValue&&(r.encryptedPropertyValue=e.encryptedPropertyValue),e.children&&Array.isArray(e.children)&&(r.children=e.children.map((function(e){var r;if("string"==typeof e)return e;if(e&&"object"==typeof e&&e.propertyName){var o=null===(r=null==t?void 0:t.children)||void 0===r?void 0:r[e.propertyName];return n.mergePropertyValidation(e,o)}return e}))),t&&(t.failedEventIds&&(r.failedEventIds=t.failedEventIds),t.passedEventIds&&(r.passedEventIds=t.passedEventIds)),r},e.prototype.sendEventWithValidation=function(t,n,r,o,s){var i,a,c=this;e.shouldLog&&n.some((function(e){return e.failedEventIds&&e.failedEventIds.length>0}))&&console.log('[Avo Inspector] Validation failures for event "'.concat(t,'":'),n.filter((function(e){return e.failedEventIds&&e.failedEventIds.length>0})).map((function(e){return{property:e.propertyName,failedEventIds:e.failedEventIds}})));var u=this.avoNetworkCallsHandler.bodyForEventSchemaCall(t,n,r,o,null!==(i=s.metadata)&&void 0!==i?i:void 0,null===(a=s.metadata)||void 0===a?void 0:a.branchId);this.avoNetworkCallsHandler.callInspectorImmediately(u,(function(s){s?(e.shouldLog&&console.error('[Avo Inspector] Failed to send event "'.concat(t,'" with validation:'),s),c.avoBatcher.handleTrackSchema(t,n,r,o)):e.shouldLog&&console.log('[Avo Inspector] Event "'.concat(t,'" sent successfully with validation'))}))},e._batchSize=30,e._batchFlushSeconds=30,e._shouldLog=!1,e._networkTimeout=2e3,e}();t.AvoInspector=v},6844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoInspectorEnv=void 0,t.AvoInspectorEnv={Prod:"prod",Dev:"dev",Staging:"staging"}},4243:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoNetworkCallsHandler=void 0;var r=n(7249),o=n(3611),s=n(4829),i=function(){function e(e,t,n,r,o){this.samplingRate=1,this.sending=!1,this.apiKey=e,this.envName=t,this.appName=n,this.appVersion=r,this.libVersion=o}return e.prototype.callInspectorWithBatchBody=function(e,t){var n=this;if(this.sending)t(new Error("Batch sending cancelled because another batch sending is in progress. Your events will be sent with next batch."));else{var r=e.filter((function(e){return null!=e}));this.fixStreamIds(r),0!==r.length&&(this.shouldDropBySampling()?o.AvoInspector.shouldLog&&console.log("Avo Inspector: last event schema dropped due to sampling rate."):(o.AvoInspector.shouldLog&&(console.log("Avo Inspector: events",r),r.forEach((function(e){"sessionStarted"===e.type?console.log("Avo Inspector: sending session started event."):"event"===e.type&&console.log("Avo Inspector: sending event "+e.eventName+" with schema "+JSON.stringify(e.eventProperties))}))),this.sending=!0,this.callInspectorApi(r,(function(e){n.sending=!1,t(e)}))))}},e.prototype.fixStreamIds=function(e){var t=null;e.forEach((function(e){null!==e.streamId&&void 0!==e.streamId&&"unknown"!==e.streamId&&(t=e.streamId)})),e.forEach((function(e){"unknown"===e.streamId&&(e.streamId=null!=t?t:s.AvoStreamId.streamId)}))},e.prototype.bodyForSessionStartedCall=function(){var e=this.createBaseCallBody();return e.type="sessionStarted",e},e.prototype.bodyForEventSchemaCall=function(e,t,n,r,o,s){var i=this.createBaseCallBody();return i.type="event",i.eventName=e,i.eventProperties=t,null!=n?(i.avoFunction=!0,i.eventId=n,i.eventHash=r):(i.avoFunction=!1,i.eventId=null,i.eventHash=null),o&&(i.eventSpecMetadata=o),s&&(i.validatedBranchId=s),i},e.prototype.createBaseCallBody=function(){return{apiKey:this.apiKey,appName:this.appName,appVersion:this.appVersion,libVersion:this.libVersion,env:this.envName,libPlatform:"web",messageId:r.default.newGuid(),trackingId:"",createdAt:(new Date).toISOString(),sessionId:"",streamId:s.AvoStreamId.streamId,samplingRate:this.samplingRate}},e.prototype.callInspectorImmediately=function(e,t){"unknown"===e.streamId&&(e.streamId=s.AvoStreamId.streamId),o.AvoInspector.shouldLog&&(console.log("Avo Inspector: calling inspector immediately (with validation)",e.eventName),console.log("Avo Inspector: event body",e)),this.callInspectorApi([e],t)},e.prototype.shouldDropBySampling=function(){return Math.random()>this.samplingRate},e.prototype.callInspectorApi=function(t,n){var r=this,s=new XMLHttpRequest;s.open("POST",e.trackingEndpoint,!0),s.setRequestHeader("Content-Type","text/plain"),s.timeout=o.AvoInspector.networkTimeout,s.send(JSON.stringify(t)),s.onload=function(){if(200!==s.status)n(new Error("Error ".concat(s.status,": ").concat(s.statusText)));else{var e=void 0;try{e=JSON.parse(s.response)}catch(e){return void n(new Error("Failed to parse response: ".concat(e instanceof Error?e.message:String(e))))}null==e||"number"!=typeof e.samplingRate||isNaN(e.samplingRate)||(r.samplingRate=e.samplingRate),n(null)}},s.onerror=function(){n(new Error("Request failed"))},s.ontimeout=function(){n(new Error("Request timed out"))}},e.trackingEndpoint="https://api.avo.app/inspector/v1/track",e}();t.AvoNetworkCallsHandler=i},924:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoSchemaParser=void 0;var r=n(8945),o=function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=function(){function e(){}return e.canSendEncryptedValues=function(e,t){return null!=e&&""!==e&&("dev"===t||"staging"===t)},e.getEncryptedPropertyValueIfEnabled=function(e,t,n){if(t&&n)try{return(0,r.encryptValue)(e,n)}catch(e){return void console.error("[Avo Inspector] Failed to encrypt property value:",e instanceof Error?e.message:String(e))}},e.extractSchema=function(e,t,n){var r=this;if(null==e)return console.warn("[Avo Inspector] extractSchema: eventProperties is null or undefined"),[];if(0===Object.keys(e).length)return console.warn("[Avo Inspector] extractSchema: eventProperties has no keys"),[];var s=this.canSendEncryptedValues(t,n),i=function(e){if(o(e)){var n=e.map((function(e){return i(e)}));return r.removeDuplicates(n)}if("object"==typeof e){var a=[];for(var c in e)if(e.hasOwnProperty(c)){var u=e[c],l={propertyName:c,propertyType:r.getPropValueType(u)};if("object"==typeof u&&null!=u)l.children=i(u);else if(void 0!==u){var f=r.getEncryptedPropertyValueIfEnabled(u,s,t);void 0!==f&&(l.encryptedPropertyValue=f)}a.push(l)}return a}return r.getPropValueType(e)};return i(e)},e.removeDuplicates=function(e){var t={boolean:{},number:{},string:{}},n=[];return e.filter((function(e){var r=typeof e;return r in t&&"string"==typeof e?!t[r].hasOwnProperty(e)&&(t[r][e]=!0):!n.includes(e)&&n.push(e)}))},e.getPropValueType=function(e){var t=typeof e;return null==e?"null":"string"===t?"string":"number"===t||"bigint"===t?(e+"").includes(".")?"float":"int":"boolean"===t?"boolean":"object"===t?o(e)?"list":"object":"unknown"},e}();t.AvoSchemaParser=s},3491:function(e,t){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AvoStorage=void 0;var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.useFallbackStorage=!1,t.fallbackStorage={},t.storageInitialized=!1,t.onStorageInitFuncs=[],t.shouldLog=!1,t.suffix="",t}return r(t,e),t.prototype.init=function(e,t){this.shouldLog=e,this.suffix=t,this.initializeStorageWeb(this.isLocalStorageAvailable())},t.prototype.initializeStorageWeb=function(e){this.storageInitialized=!0,e||(this.useFallbackStorage=!0),this.onStorageInitFuncs.forEach((function(e){e()}))},t.prototype.isLocalStorageAvailable=function(){var e=(new Date).toISOString();try{return window.localStorage.setItem(e,e),window.localStorage.getItem(e)===e&&(window.localStorage.removeItem(e),!0)}catch(e){return!1}},t.prototype.isInitialized=function(){return this.storageInitialized},t.prototype.getItemAsync=function(e){return o(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,r){t.runAfterInit((function(){if(t.useFallbackStorage){var r=t.fallbackStorage[e+t.suffix];n(t.parseJson(r))}else if("undefined"!=typeof window){r=void 0;try{r=window.localStorage.getItem(e+t.suffix)}catch(e){t.shouldLog&&console.error("Avo Inspector Storage getItemAsync error:",e),n(null)}n(t.parseJson(r))}else n(null)}))}))];case 1:return[2,n.sent()]}}))}))},t.prototype.getItem=function(e){var t;if(this.storageInitialized){if(this.useFallbackStorage)t=this.fallbackStorage[e+this.suffix];else if("undefined"!=typeof window)try{t=window.localStorage.getItem(e+this.suffix)}catch(e){this.shouldLog&&console.error("Avo Inspector Storage getItem error:",e)}}else t=null;return this.parseJson(t)},t.prototype.setItem=function(e,t){var n=this;this.runAfterInit((function(){if(n.useFallbackStorage)n.fallbackStorage[e+n.suffix]=JSON.stringify(t);else if("undefined"!=typeof window)try{window.localStorage.setItem(e+n.suffix,JSON.stringify(t))}catch(e){n.shouldLog&&console.error("Avo Inspector Storage setItem error:",e)}}))},t.prototype.removeItem=function(e){var t=this;this.runAfterInit((function(){if(t.useFallbackStorage)t.fallbackStorage[e+t.suffix]=null;else if("undefined"!=typeof window)try{window.localStorage.removeItem(e+t.suffix)}catch(e){t.shouldLog&&console.error("Avo Inspector Storage removeItem error:",e)}}))},t.prototype.runAfterInit=function(e){this.storageInitialized?e():this.onStorageInitFuncs.push(e)},t}(function(){function e(){}return e.prototype.parseJson=function(e){return null!=e?JSON.parse(e):null},e}()),a=function(){function e(e,t){void 0===t&&(t=""),this.Platform=null,this.Platform="browser",this.storageImpl=new i,this.storageImpl.init(e,t)}return e.prototype.isInitialized=function(){return this.storageImpl.isInitialized()},e.prototype.getItemAsync=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.storageImpl.getItemAsync(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getItem=function(e){return this.storageImpl.getItem(e)},e.prototype.setItem=function(e,t){this.storageImpl.setItem(e,t)},e.prototype.removeItem=function(e){this.storageImpl.removeItem(e)},e.prototype.runAfterInit=function(e){this.storageImpl.runAfterInit(e)},e}();t.AvoStorage=a},4829:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoStreamId=void 0;var r=n(7249),o=n(3611),s=function(){function e(){}return Object.defineProperty(e,"streamId",{get:function(){return null===e._streamId||e.shouldReset()?o.AvoInspector.avoStorage.isInitialized()?(e.loadFromStorage(),null!==e._streamId&&e.shouldReset()||null===e._streamId?e.generateAndStoreNew():(e.updateLastActivity(),e._streamId)):"unknown":(e.updateLastActivity(),e._streamId)},enumerable:!1,configurable:!0}),e.shouldReset=function(){if(null===e._createdAt||null===e._lastActivityAt)return!1;var t=Date.now(),n=t-e._createdAt,r=t-e._lastActivityAt;return n>e.MAX_AGE_MS&&r>e.IDLE_THRESHOLD_MS},e.loadFromStorage=function(){try{var t=o.AvoInspector.avoStorage.getItem(e.STREAM_ID_KEY),n=o.AvoInspector.avoStorage.getItem(e.CREATED_AT_KEY),r=o.AvoInspector.avoStorage.getItem(e.LAST_ACTIVITY_KEY);null!=t&&(e._streamId=t,e._createdAt=null!=n?n:Date.now(),e._lastActivityAt=null!=r?r:Date.now())}catch(e){console.error("Avo Inspector: Error reading stream ID from storage. Please report to support@avo.app.",e)}},e.generateAndStoreNew=function(){var t=Date.now();e._streamId=r.default.newGuid(),e._createdAt=t,e._lastActivityAt=t;try{o.AvoInspector.avoStorage.setItem(e.STREAM_ID_KEY,e._streamId),o.AvoInspector.avoStorage.setItem(e.CREATED_AT_KEY,e._createdAt),o.AvoInspector.avoStorage.setItem(e.LAST_ACTIVITY_KEY,e._lastActivityAt)}catch(e){console.error("Avo Inspector: Error saving stream ID to storage. Please report to support@avo.app.",e)}return e._streamId},e.updateLastActivity=function(){var t=Date.now();e._lastActivityAt=t;try{o.AvoInspector.avoStorage.setItem(e.LAST_ACTIVITY_KEY,t)}catch(e){}},Object.defineProperty(e,"storageKey",{get:function(){return e.STREAM_ID_KEY},enumerable:!1,configurable:!0}),Object.defineProperty(e,"createdAtKey",{get:function(){return e.CREATED_AT_KEY},enumerable:!1,configurable:!0}),Object.defineProperty(e,"lastActivityKey",{get:function(){return e.LAST_ACTIVITY_KEY},enumerable:!1,configurable:!0}),e.clearCache=function(){e._streamId=null,e._createdAt=null,e._lastActivityAt=null},e._streamId=null,e._createdAt=null,e._lastActivityAt=null,e.MAX_AGE_MS=144e5,e.IDLE_THRESHOLD_MS=72e5,e.STREAM_ID_KEY="AvoInspectorStreamId",e.CREATED_AT_KEY="AvoInspectorStreamIdCreatedAt",e.LAST_ACTIVITY_KEY="AvoInspectorStreamIdLastActivityAt",e}();t.AvoStreamId=s},1499:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventSpecCache=void 0;var n=function(){function e(e){void 0===e&&(e=!1),this.TTL_MS=3e5,this.MAX_EVENT_COUNT=50,this.globalEventCount=0,this.cache=new Map,this.shouldLog=e}return e.prototype.generateKey=function(e,t,n){return"".concat(e,":").concat(t,":").concat(n)},e.prototype.get=function(e,t,n){var r=this.generateKey(e,t,n),o=this.cache.get(r);return o?this.shouldEvict(o)?(this.shouldLog&&console.log("[EventSpecCache] Cache entry expired for key: ".concat(r)),this.cache.delete(r),null):(this.shouldLog&&console.log("[EventSpecCache] Cache hit for key: ".concat(r)),o.lastAccessed=Date.now(),o.eventCount++,this.globalEventCount++,this.globalEventCount>=this.MAX_EVENT_COUNT&&(this.evictOldest(),this.globalEventCount=0),o.spec):(this.shouldLog&&console.log("[EventSpecCache] Cache miss for key: ".concat(r)),null)},e.prototype.set=function(e,t,n,r){var o=this.generateKey(e,t,n),s=Date.now(),i={spec:r,timestamp:s,lastAccessed:s,eventCount:0};this.cache.set(o,i),this.shouldLog&&console.log("[EventSpecCache] Cached spec for key: ".concat(o))},e.prototype.shouldEvict=function(e){var t=Date.now()-e.timestamp>this.TTL_MS,n=e.eventCount>=this.MAX_EVENT_COUNT;return t||n},e.prototype.evictOldest=function(){if(0!==this.cache.size){var e=null,t=1/0;this.cache.forEach((function(n,r){n.lastAccessed<t&&(t=n.lastAccessed,e=r)})),null!==e&&(this.cache.delete(e),this.shouldLog&&console.log("[EventSpecCache] Evicted LRU entry: ".concat(e)))}},e.prototype.clear=function(){this.cache.clear(),this.globalEventCount=0,this.shouldLog&&console.log("[EventSpecCache] Cache cleared")},e.prototype.size=function(){return this.cache.size},e.prototype.getStats=function(){var e=[],t=Date.now();return this.cache.forEach((function(n,r){e.push({key:r,age:t-n.timestamp,lastAccessedAgo:t-n.lastAccessed,eventCount:n.eventCount})})),{size:this.cache.size,globalEventCount:this.globalEventCount,entries:e}},e}();t.EventSpecCache=n},4190:function(e,t){var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},o=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.AvoEventSpecFetcher=void 0;var s=function(){function e(e,t,n,r){void 0===e&&(e=2e3),void 0===t&&(t=!1),void 0===r&&(r="https://api.avo.app"),this.baseUrl=r,this.timeout=e,this.shouldLog=t,this.env=n,this.inFlightRequests=new Map}return e.prototype.generateRequestKey=function(e){return"".concat(e.streamId,":").concat(e.eventName)},e.prototype.fetch=function(e){return n(this,void 0,void 0,(function(){var t,n,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.generateRequestKey(e),n=this.inFlightRequests.get(t))return this.shouldLog&&console.log("[EventSpecFetcher] Returning existing in-flight request for streamId=".concat(e.streamId,", eventName=").concat(e.eventName)),[2,n];o=this.fetchInternal(e),this.inFlightRequests.set(t,o),r.label=1;case 1:return r.trys.push([1,,3,4]),[4,o];case 2:return[2,r.sent()];case 3:return this.inFlightRequests.delete(t),[7];case 4:return[2]}}))}))},e.prototype.fetchInternal=function(t){return n(this,void 0,void 0,(function(){var n,o,s,i;return r(this,(function(r){switch(r.label){case 0:if("dev"!==this.env&&"staging"!==this.env)return[2,null];n=this.buildUrl(t),this.shouldLog&&(console.log("[EventSpecFetcher] Fetching event spec for: ".concat(t.eventName)),console.log("[EventSpecFetcher] Using base URL: ".concat(this.baseUrl))),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.makeRequest(n)];case 2:return(o=r.sent())?this.hasExpectedShape(o)?(s=e.parseEventSpecResponse(o),this.shouldLog&&console.log("[EventSpecFetcher] Successfully fetched event spec for: ".concat(t.eventName)),[2,s]):(this.shouldLog&&console.warn("[EventSpecFetcher] Invalid event spec response for: ".concat(t.eventName)),[2,null]):(this.shouldLog&&console.warn("[EventSpecFetcher] Failed to fetch event spec for: ".concat(t.eventName)),[2,null]);case 3:return i=r.sent(),this.shouldLog&&console.error("[EventSpecFetcher] Error fetching event spec for: ".concat(t.eventName),i),[2,null];case 4:return[2]}}))}))},e.prototype.buildUrl=function(e){var t=new URLSearchParams({apiKey:e.apiKey,streamId:e.streamId,eventName:e.eventName});return"".concat(this.baseUrl,"/trackingPlan/eventSpec?").concat(t.toString())},e.prototype.makeRequest=function(e){var t=this;return new Promise((function(n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.timeout=t.timeout,r.onload=function(){if(200===r.status)try{var e=JSON.parse(r.responseText);n(e)}catch(e){t.shouldLog&&console.error("[EventSpecFetcher] Failed to parse response:",e),n(null)}else t.shouldLog&&console.warn("[EventSpecFetcher] Request failed with status: ".concat(r.status)),n(null)},r.onerror=function(){t.shouldLog&&console.error("[EventSpecFetcher] Network error occurred"),n(null)},r.ontimeout=function(){t.shouldLog&&console.error("[EventSpecFetcher] Request timed out after ".concat(t.timeout,"ms")),n(null)},r.send()}))},e.prototype.hasExpectedShape=function(e){return e&&"object"==typeof e&&"string"==typeof e.branchId&&e.baseEvent&&"object"==typeof e.baseEvent&&"string"==typeof e.baseEvent.name&&"string"==typeof e.baseEvent.id&&e.baseEvent.props&&"object"==typeof e.baseEvent.props&&Array.isArray(e.variants)},e.parseEventSpecResponse=function(t){var n=t.baseEvent.id,r=t.variants.map((function(e){return e.eventId})),s=o([n],r,!0),i=e.parseAndMergeProps(t.baseEvent.props,n,t.variants,s);return{events:[{branchId:t.branchId,baseEventId:n,variantIds:r,props:i}],metadata:{schemaId:"",branchId:t.branchId,latestActionId:""}}},e.parseAndMergeProps=function(t,n,r,o){for(var s={},i=new Set(Object.keys(t)),a=0,c=r;a<c.length;a++)for(var u=c[a],l=0,f=Object.keys(u.props);l<f.length;l++){var h=f[l];i.add(h)}for(var d=function(i){var a=t[i],c=r.map((function(e){return{eventId:e.eventId,prop:e.props[i]}}));s[i]=e.mergePropertyConstraints(i,a,n,c,o)},p=0,y=Array.from(i);p<y.length;p++)d(h=y[p]);return s},e.mergePropertyConstraints=function(t,n,r,o,s){var i="unknown",a=!1,c=!1;if(n)i=e.getTypeString(n),a=n.r,c=!0===n.l;else for(var u=0,l=o;u<l.length;u++)if((g=l[u]).prop){i=e.getTypeString(g.prop),a=g.prop.r,c=!0===g.prop.l;break}var f={type:c?"list":i,required:a},h={},d={};n&&e.addConstraintsFromProp(n,r,h,d);for(var p=0,y=o;p<y.length;p++){var g;(g=y[p]).prop&&e.addConstraintsFromProp(g.prop,g.eventId,h,d)}Object.keys(h).length>0&&(f.allowedValues=h),Object.keys(d).length>0&&(f.minMaxRanges=d);var v=e.getNestedSchema(n);if(v){f.children={};for(var m=function(t,n){var i=o.map((function(n){var r;return{eventId:n.eventId,prop:n.prop?null===(r=e.getNestedSchema(n.prop))||void 0===r?void 0:r[t]:void 0}}));f.children[t]=e.mergePropertyConstraints(t,n,r,i,s)},b=0,w=Object.entries(v);b<w.length;b++){var E=w[b];m(E[0],E[1])}}return f},e.getTypeString=function(e){return"string"==typeof e.t?e.t:"object"},e.getNestedSchema=function(e){if(e)return"object"==typeof e.t&&null!==e.t?e.t:void 0},e.addConstraintsFromProp=function(e,t,n,r){var o,s;if(e.v&&Array.isArray(e.v)&&(n[i=JSON.stringify(e.v)]||(n[i]=[]),n[i].push(t)),void 0!==e.min||void 0!==e.max){var i,a=null!==(o=e.min)&&void 0!==o?o:Number.MIN_SAFE_INTEGER,c=null!==(s=e.max)&&void 0!==s?s:Number.MAX_SAFE_INTEGER;r[i="".concat(a,",").concat(c)]||(r[i]=[]),r[i].push(t)}},e}();t.AvoEventSpecFetcher=s},5916:function(e,t){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},r=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function o(e){for(var t={},n=0,o=Object.entries(e);n<o.length;n++){var s=o[n],i=s[0],a=s[1];t[i]=r([],a,!0)}return t}function s(e){for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var i=r[n],a=i[0],c=i[1];t[a]={type:c.type,required:c.required,pinnedValues:c.pinnedValues?o(c.pinnedValues):void 0,allowedValues:c.allowedValues?o(c.allowedValues):void 0,regexPatterns:c.regexPatterns?o(c.regexPatterns):void 0,minMaxRanges:c.minMaxRanges?o(c.minMaxRanges):void 0,children:c.children?s(c.children):void 0}}return t}function i(e,t){for(var n=0,r=Object.entries(t);n<r.length;n++){var c=r[n],u=c[0],l=c[1];if(e[u]){var f=e[u];a(f,l),l.children&&(f.children?i(f.children,l.children):f.children=s(l.children))}else e[u]={type:l.type,required:l.required,pinnedValues:l.pinnedValues?o(l.pinnedValues):void 0,allowedValues:l.allowedValues?o(l.allowedValues):void 0,regexPatterns:l.regexPatterns?o(l.regexPatterns):void 0,minMaxRanges:l.minMaxRanges?o(l.minMaxRanges):void 0,children:l.children?s(l.children):void 0}}}function a(e,t){if(t.pinnedValues){e.pinnedValues||(e.pinnedValues={});for(var n=0,o=Object.keys(t.pinnedValues);n<o.length;n++){var s=o[n];if(e.pinnedValues[s]){for(var i=new Set(e.pinnedValues[s]),a=0,c=t.pinnedValues[s];a<c.length;a++){var u=c[a];i.add(u)}e.pinnedValues[s]=Array.from(i)}else e.pinnedValues[s]=r([],t.pinnedValues[s],!0)}}if(t.allowedValues){e.allowedValues||(e.allowedValues={});for(var l=0,f=Object.keys(t.allowedValues);l<f.length;l++)if(s=f[l],e.allowedValues[s]){i=new Set(e.allowedValues[s]);for(var h=0,d=t.allowedValues[s];h<d.length;h++)u=d[h],i.add(u);e.allowedValues[s]=Array.from(i)}else e.allowedValues[s]=r([],t.allowedValues[s],!0)}if(t.regexPatterns){e.regexPatterns||(e.regexPatterns={});for(var p=0,y=Object.keys(t.regexPatterns);p<y.length;p++)if(s=y[p],e.regexPatterns[s]){i=new Set(e.regexPatterns[s]);for(var g=0,v=t.regexPatterns[s];g<v.length;g++)u=v[g],i.add(u);e.regexPatterns[s]=Array.from(i)}else e.regexPatterns[s]=r([],t.regexPatterns[s],!0)}if(t.minMaxRanges){e.minMaxRanges||(e.minMaxRanges={});for(var m=0,b=Object.keys(t.minMaxRanges);m<b.length;m++)if(s=b[m],e.minMaxRanges[s]){i=new Set(e.minMaxRanges[s]);for(var w=0,E=t.minMaxRanges[s];w<E.length;w++)u=E[w],i.add(u);e.minMaxRanges[s]=Array.from(i)}else e.minMaxRanges[s]=r([],t.minMaxRanges[s],!0)}}Object.defineProperty(t,"__esModule",{value:!0}),t.validateEvent=void 0;var c=new Map;function u(e){var t=c.get(e);return t||(t=new RegExp(e),c.set(e,t)),t}t.validateEvent=function(e,t){for(var r=function(e){for(var t=[],n=0,r=e;n<r.length;n++){var o=r[n];t.push(o.baseEventId);for(var s=0;s<o.variantIds.length;s++)t.push(o.variantIds[s])}return t}(t.events),o=function(e){if(0===e.length)return{};if(1===e.length)return e[0].props;for(var t={},r=0,o=e;r<o.length;r++)for(var c=o[r],u=0,l=Object.entries(c.props);u<l.length;u++){var f=l[u],h=f[0],d=f[1];if(t[h]){var p=t[h];a(p,d),d.children&&(p.children?i(p.children,d.children):p.children=s(d.children))}else t[h]={type:d.type,required:d.required,pinnedValues:d.pinnedValues?n({},d.pinnedValues):void 0,allowedValues:d.allowedValues?n({},d.allowedValues):void 0,regexPatterns:d.regexPatterns?n({},d.regexPatterns):void 0,minMaxRanges:d.minMaxRanges?n({},d.minMaxRanges):void 0,children:d.children?s(d.children):void 0}}return t}(t.events),c={},u=0,l=Object.keys(e);u<l.length;u++){var h=l[u],d=e[h],p=o[h];if(p){var y=f(d,p,r);c[h]=y}else c[h]={}}return{metadata:t.metadata,propertyResults:c}};var l=100;function f(e,t,n,r){void 0===r&&(r=0);var o={};if(r>l)return console.warn("[Avo Inspector] Max validation depth (".concat(l,") exceeded, stopping recursive validation")),o;if(t.children){for(var s={},i="object"!=typeof e||null===e||Array.isArray(e)?{}:e,a=0,c=Object.entries(t.children);a<c.length;a++){var p=c[a],y=p[0],g=p[1],v=f(i[y],g,n,r+1);(v.failedEventIds||v.passedEventIds||v.children)&&(s[y]=v)}return Object.keys(s).length>0&&(o.children=s),o}var m=new Set;t.pinnedValues&&function(e,t,n){for(var r=d(e),o=0,s=Object.entries(t);o<s.length;o++){var i=s[o],a=i[0],c=i[1];r!==a&&h(c,n)}}(e,t.pinnedValues,m),t.allowedValues&&function(e,t,n){for(var r=d(e),o=0,s=Object.entries(t);o<s.length;o++){var i=s[o],a=i[0],c=i[1];try{JSON.parse(a).includes(r)||h(c,n)}catch(e){console.warn("[Avo Inspector] Invalid allowed values JSON: ".concat(a))}}}(e,t.allowedValues,m),t.regexPatterns&&function(e,t,n){if("string"==typeof e)for(var r=0,o=Object.entries(t);r<o.length;r++){var s=o[r],i=s[0],a=s[1];try{u(i).test(e)||h(a,n)}catch(e){console.warn("[Avo Inspector] Invalid regex pattern: ".concat(i))}}else for(var c=0,l=Object.values(t);c<l.length;c++)h(a=l[c],n)}(e,t.regexPatterns,m),t.minMaxRanges&&function(e,t,n){if("number"==typeof e)if(Number.isNaN(e)){console.warn("[Avo Inspector] NaN value fails min/max constraint");for(var r=0,o=Object.values(t);r<o.length;r++)h(u=o[r],n)}else for(var s=0,i=Object.entries(t);s<i.length;s++){var a=i[s],c=a[0],u=a[1],l=c.split(","),f=l[0],d=l[1],p=parseFloat(f),y=parseFloat(d);isNaN(p)||isNaN(y)?console.warn("[Avo Inspector] Invalid min/max range: ".concat(c)):(e<p||e>y)&&h(u,n)}else for(var g=0,v=Object.values(t);g<v.length;g++)h(u=v[g],n)}(e,t.minMaxRanges,m);var b=n.filter((function(e){return!m.has(e)})),w=Array.from(m);return 0===w.length&&0===b.length?{}:b.length<w.length&&b.length>0?{passedEventIds:b}:w.length>0?{failedEventIds:w}:{}}function h(e,t){for(var n=0,r=e;n<r.length;n++){var o=r[n];t.add(o)}}function d(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e)return String(e);if(Array.isArray(e)||"object"==typeof e)try{return JSON.stringify(e)}catch(t){return console.warn("[Avo Inspector] Failed to stringify value: ".concat(t)),String(e)}return String(e)}},6185:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEquals=t.isValueEmpty=void 0,t.isValueEmpty=function(e){return null==e||0==e.trim().length},t.deepEquals=function e(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!=typeof t[r])return!1;if(!e(t[r],n[r]))return!1}}for(r in n)if(n.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}},8330:e=>{e.exports=JSON.parse('{"rE":"2.2.2-alpha.8"}')}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.AvoInspectorEnv=e.AvoInspector=void 0;var t=n(3611);Object.defineProperty(e,"AvoInspector",{enumerable:!0,get:function(){return t.AvoInspector}});var o=n(6844);Object.defineProperty(e,"AvoInspectorEnv",{enumerable:!0,get:function(){return o.AvoInspectorEnv}})})(),r})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{"use strict";var e={7678:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.aes256cbc=t.aes256gcm=void 0;var r=n(469);t.aes256gcm=function(e,t,n){return(0,r.gcm)(e,t,n)},t.aes256cbc=function(e,t,n){return(0,r.cbc)(e,t)}},83:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.chacha20=t.xchacha20=void 0;var r=n(8900);t.xchacha20=function(e,t,n){return(0,r.xchacha20poly1305)(e,t,n)},t.chacha20=function(e,t,n){return(0,r.chacha20poly1305)(e,t,n)}},2506:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.rotl=function(e,t){return e<<t|e>>>32-t},t.createCipher=function(e,t){const{allowShortKeys:n,extendNonceFn:o,counterLength:s,counterRight:i,rounds:p}=(0,r.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return(0,r.anumber)(s),(0,r.anumber)(p),(0,r.abool)(i),(0,r.abool)(n),(t,y,g,v,m=0)=>{(0,r.abytes)(t),(0,r.abytes)(y),(0,r.abytes)(g);const b=g.length;if(void 0===v&&(v=new Uint8Array(b)),(0,r.abytes)(v),(0,r.anumber)(m),m<0||m>=h)throw new Error("arx: counter overflow");if(v.length<b)throw new Error(`arx: output (${v.length}) is shorter than data (${b})`);const w=[];let E,S,B=t.length;if(32===B)w.push(E=(0,r.copyBytes)(t)),S=c;else{if(16!==B||!n)throw new Error(`arx: invalid 32-byte key, got length=${B}`);E=new Uint8Array(32),E.set(t),E.set(t,16),S=a,w.push(E)}u(y)||w.push(y=(0,r.copyBytes)(y));const x=(0,r.u32)(E);if(o){if(24!==y.length)throw new Error("arx: extended nonce must be 24 bytes");o(S,x,(0,r.u32)(y.subarray(0,16)),x),y=y.subarray(16)}const I=16-s;if(I!==y.length)throw new Error(`arx: nonce must be ${I} or 16 bytes`);if(12!==I){const e=new Uint8Array(12);e.set(y,i?0:12-y.length),y=e,w.push(y)}const A=(0,r.u32)(y);return function(e,t,n,o,s,i,a,c){const p=s.length,y=new Uint8Array(l),g=(0,r.u32)(y),v=u(s)&&u(i),m=v?(0,r.u32)(s):d,b=v?(0,r.u32)(i):d;for(let r=0;r<p;a++){if(e(t,n,o,g,a,c),a>=h)throw new Error("arx: counter overflow");const u=Math.min(l,p-r);if(v&&u===l){const e=r/4;if(r%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<f;n++)t=e+n,b[t]=m[t]^g[n];r+=l}else{for(let e,t=0;t<u;t++)e=r+t,i[e]=s[e]^y[t];r+=u}}}(e,S,x,A,g,v,m,p),(0,r.clean)(...w),v}};const r=n(6527),o=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),s=o("expand 16-byte k"),i=o("expand 32-byte k"),a=(0,r.u32)(s),c=(0,r.u32)(i);function u(e){return e.byteOffset%4==0}const l=64,f=16,h=2**32-1,d=new Uint32Array},1210:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.poly1305=void 0,t.wrapConstructorWithKey=i;const r=n(6527),o=(e,t)=>255&e[t++]|(255&e[t++])<<8;class s{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=(0,r.toBytes)(e),(0,r.abytes)(e,32);const t=o(e,0),n=o(e,2),s=o(e,4),i=o(e,6),a=o(e,8),c=o(e,10),u=o(e,12),l=o(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|s<<6),this.r[3]=8191&(s>>>7|i<<9),this.r[4]=255&(i>>>4|a<<12),this.r[5]=a>>>1&8190,this.r[6]=8191&(a>>>14|c<<2),this.r[7]=8065&(c>>>11|u<<5),this.r[8]=8191&(u>>>8|l<<8),this.r[9]=l>>>5&127;for(let t=0;t<8;t++)this.pad[t]=o(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:s,r:i}=this,a=i[0],c=i[1],u=i[2],l=i[3],f=i[4],h=i[5],d=i[6],p=i[7],y=i[8],g=i[9],v=o(e,t+0),m=o(e,t+2),b=o(e,t+4),w=o(e,t+6),E=o(e,t+8),S=o(e,t+10),B=o(e,t+12),x=o(e,t+14);let I=s[0]+(8191&v),A=s[1]+(8191&(v>>>13|m<<3)),_=s[2]+(8191&(m>>>10|b<<6)),O=s[3]+(8191&(b>>>7|w<<9)),P=s[4]+(8191&(w>>>4|E<<12)),L=s[5]+(E>>>1&8191),T=s[6]+(8191&(E>>>14|S<<2)),H=s[7]+(8191&(S>>>11|B<<5)),C=s[8]+(8191&(B>>>8|x<<8)),R=s[9]+(x>>>5|r),F=0,N=F+I*a+A*(5*g)+_*(5*y)+O*(5*p)+P*(5*d);F=N>>>13,N&=8191,N+=L*(5*h)+T*(5*f)+H*(5*l)+C*(5*u)+R*(5*c),F+=N>>>13,N&=8191;let k=F+I*c+A*a+_*(5*g)+O*(5*y)+P*(5*p);F=k>>>13,k&=8191,k+=L*(5*d)+T*(5*h)+H*(5*f)+C*(5*l)+R*(5*u),F+=k>>>13,k&=8191;let V=F+I*u+A*c+_*a+O*(5*g)+P*(5*y);F=V>>>13,V&=8191,V+=L*(5*p)+T*(5*d)+H*(5*h)+C*(5*f)+R*(5*l),F+=V>>>13,V&=8191;let U=F+I*l+A*u+_*c+O*a+P*(5*g);F=U>>>13,U&=8191,U+=L*(5*y)+T*(5*p)+H*(5*d)+C*(5*h)+R*(5*f),F+=U>>>13,U&=8191;let K=F+I*f+A*l+_*u+O*c+P*a;F=K>>>13,K&=8191,K+=L*(5*g)+T*(5*y)+H*(5*p)+C*(5*d)+R*(5*h),F+=K>>>13,K&=8191;let j=F+I*h+A*f+_*l+O*u+P*c;F=j>>>13,j&=8191,j+=L*a+T*(5*g)+H*(5*y)+C*(5*p)+R*(5*d),F+=j>>>13,j&=8191;let M=F+I*d+A*h+_*f+O*l+P*u;F=M>>>13,M&=8191,M+=L*c+T*a+H*(5*g)+C*(5*y)+R*(5*p),F+=M>>>13,M&=8191;let D=F+I*p+A*d+_*h+O*f+P*l;F=D>>>13,D&=8191,D+=L*u+T*c+H*a+C*(5*g)+R*(5*y),F+=D>>>13,D&=8191;let q=F+I*y+A*p+_*d+O*h+P*f;F=q>>>13,q&=8191,q+=L*l+T*u+H*c+C*a+R*(5*g),F+=q>>>13,q&=8191;let Z=F+I*g+A*y+_*p+O*d+P*h;F=Z>>>13,Z&=8191,Z+=L*f+T*l+H*u+C*c+R*a,F+=Z>>>13,Z&=8191,F=(F<<2)+F|0,F=F+N|0,N=8191&F,F>>>=13,k+=F,s[0]=N,s[1]=k,s[2]=V,s[3]=U,s[4]=K,s[5]=j,s[6]=M,s[7]=D,s[8]=q,s[9]=Z}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let o=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=o,o=e[t]>>>13,e[t]&=8191;e[0]+=5*o,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,n[0]=e[0]+5,o=n[0]>>>13,n[0]&=8191;for(let t=1;t<10;t++)n[t]=e[t]+o,o=n[t]>>>13,n[t]&=8191;n[9]-=8192;let s=(1^o)-1;for(let e=0;e<10;e++)n[e]&=s;s=~s;for(let t=0;t<10;t++)e[t]=e[t]&s|n[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let i=e[0]+t[0];e[0]=65535&i;for(let n=1;n<8;n++)i=(e[n]+t[n]|0)+(i>>>16)|0,e[n]=65535&i;(0,r.clean)(n)}update(e){(0,r.aexists)(this),e=(0,r.toBytes)(e),(0,r.abytes)(e);const{buffer:t,blockLen:n}=this,o=e.length;for(let r=0;r<o;){const s=Math.min(n-this.pos,o-r);if(s!==n)t.set(e.subarray(r,r+s),this.pos),this.pos+=s,r+=s,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=o-r;r+=n)this.process(e,r)}return this}destroy(){(0,r.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:o}=this;if(o){for(t[o++]=1;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let s=0;for(let t=0;t<8;t++)e[s++]=n[t]>>>0,e[s++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function i(e){const t=(t,n)=>e(n).update((0,r.toBytes)(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}t.poly1305=i((e=>new s(e)))},22:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.polyval=t.ghash=void 0,t._toGHASHKey=c;const r=n(6527),o=16,s=new Uint8Array(16),i=(0,r.u32)(s),a=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255;function c(e){e.reverse();const t=1&e[15];let n=0;for(let t=0;t<e.length;t++){const r=e[t];e[t]=r>>>1|n,n=(1&r)<<7}return e[0]^=225&-t,e}class u{constructor(e,t){this.blockLen=o,this.outputLen=o,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=(0,r.toBytes)(e),(0,r.abytes)(e,16);const n=(0,r.createView)(e);let s=n.getUint32(0,!1),i=n.getUint32(4,!1),c=n.getUint32(8,!1),u=n.getUint32(12,!1);const l=[];for(let e=0;e<128;e++)l.push({s0:a(s),s1:a(i),s2:a(c),s3:a(u)}),({s0:s,s1:i,s2:c,s3:u}={s3:(d=c)<<31|(p=u)>>>1,s2:(h=i)<<31|d>>>1,s1:(f=s)<<31|h>>>1,s0:f>>>1^225<<24&-(1&p)});var f,h,d,p;const y=(g=t||1024)>65536?8:g>1024?4:2;var g;if(![1,2,4,8].includes(y))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=y;const v=128/y,m=this.windowSize=2**y,b=[];for(let e=0;e<v;e++)for(let t=0;t<m;t++){let n=0,r=0,o=0,s=0;for(let i=0;i<y;i++){if(!(t>>>y-i-1&1))continue;const{s0:a,s1:c,s2:u,s3:f}=l[y*e+i];n^=a,r^=c,o^=u,s^=f}b.push({s0:n,s1:r,s2:o,s3:s})}this.t=b}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;const{W:o,t:s,windowSize:i}=this;let a=0,c=0,u=0,l=0;const f=(1<<o)-1;let h=0;for(const d of[e,t,n,r])for(let e=0;e<4;e++){const t=d>>>8*e&255;for(let e=8/o-1;e>=0;e--){const n=t>>>o*e&f,{s0:r,s1:d,s2:p,s3:y}=s[h*i+n];a^=r,c^=d,u^=p,l^=y,h+=1}}this.s0=a,this.s1=c,this.s2=u,this.s3=l}update(e){(0,r.aexists)(this),e=(0,r.toBytes)(e),(0,r.abytes)(e);const t=(0,r.u32)(e),n=Math.floor(e.length/o),a=e.length%o;for(let e=0;e<n;e++)this._updateBlock(t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]);return a&&(s.set(e.subarray(n*o)),this._updateBlock(i[0],i[1],i[2],i[3]),(0,r.clean)(i)),this}destroy(){const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{s0:t,s1:n,s2:o,s3:s}=this,i=(0,r.u32)(e);return i[0]=t,i[1]=n,i[2]=o,i[3]=s,e}digest(){const e=new Uint8Array(o);return this.digestInto(e),this.destroy(),e}}class l extends u{constructor(e,t){e=(0,r.toBytes)(e),(0,r.abytes)(e);const n=c((0,r.copyBytes)(e));super(n,t),(0,r.clean)(n)}update(e){e=(0,r.toBytes)(e),(0,r.aexists)(this);const t=(0,r.u32)(e),n=e.length%o,c=Math.floor(e.length/o);for(let e=0;e<c;e++)this._updateBlock(a(t[4*e+3]),a(t[4*e+2]),a(t[4*e+1]),a(t[4*e+0]));return n&&(s.set(e.subarray(c*o)),this._updateBlock(a(i[3]),a(i[2]),a(i[1]),a(i[0])),(0,r.clean)(i)),this}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{s0:t,s1:n,s2:o,s3:s}=this,i=(0,r.u32)(e);return i[0]=t,i[1]=n,i[2]=o,i[3]=s,e.reverse()}}function f(e){const t=(t,n)=>e(n,t.length).update((0,r.toBytes)(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}t.ghash=f(((e,t)=>new u(e,t))),t.polyval=f(((e,t)=>new l(e,t)))},469:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unsafe=t.aeskwp=t.aeskw=t.siv=t.gcmsiv=t.gcm=t.cfb=t.cbc=t.ecb=t.ctr=void 0;const r=n(22),o=n(6527),s=16,i=new Uint8Array(s),a=283;function c(e){return e<<1^a&-(e>>7)}function u(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=c(e);return n}const l=(()=>{const e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=c(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return(0,o.clean)(e),t})(),f=l.map(((e,t)=>l.indexOf(t))),h=e=>e<<24|e>>>8,d=e=>e<<8|e>>>24,p=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function y(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((n,r)=>t(e[r]))),r=n.map(d),o=r.map(d),s=o.map(d),i=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let u=0;u<256;u++){const l=256*t+u;i[l]=n[t]^r[u],a[l]=o[t]^s[u],c[l]=e[t]<<8|e[u]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:o,T3:s,T01:i,T23:a}}const g=y(l,(e=>u(e,3)<<24|e<<16|e<<8|u(e,2))),v=y(f,(e=>u(e,11)<<24|u(e,13)<<16|u(e,9)<<8|u(e,14))),m=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=c(n))e[t]=n;return e})();function b(e){(0,o.abytes)(e);const t=e.length;if(![16,24,32].includes(t))throw new Error("aes: invalid key size, should be 16, 24 or 32, got "+t);const{sbox2:n}=g,r=[];(0,o.isAligned32)(e)||r.push(e=(0,o.copyBytes)(e));const s=(0,o.u32)(e),i=s.length,a=e=>S(n,e,e,e,e),c=new Uint32Array(t+28);c.set(s);for(let e=i;e<c.length;e++){let t=c[e-1];e%i==0?t=a(h(t))^m[e/i-1]:i>6&&e%i==4&&(t=a(t)),c[e]=c[e-i]^t}return(0,o.clean)(...r),c}function w(e){const t=b(e),n=t.slice(),r=t.length,{sbox2:s}=g,{T0:i,T1:a,T2:c,T3:u}=v;for(let e=0;e<r;e+=4)for(let o=0;o<4;o++)n[e+o]=t[r-e-4+o];(0,o.clean)(t);for(let e=4;e<r-4;e++){const t=n[e],r=S(s,t,t,t,t);n[e]=i[255&r]^a[r>>>8&255]^c[r>>>16&255]^u[r>>>24]}return n}function E(e,t,n,r,o,s){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|s>>>24&255]}function S(e,t,n,r,o){return e[255&t|65280&n]|e[r>>>16&255|o>>>16&65280]<<16}function B(e,t,n,r,o){const{sbox2:s,T01:i,T23:a}=g;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],o^=e[c++];const u=e.length/4-2;for(let s=0;s<u;s++){const s=e[c++]^E(i,a,t,n,r,o),u=e[c++]^E(i,a,n,r,o,t),l=e[c++]^E(i,a,r,o,t,n),f=e[c++]^E(i,a,o,t,n,r);t=s,n=u,r=l,o=f}return{s0:e[c++]^S(s,t,n,r,o),s1:e[c++]^S(s,n,r,o,t),s2:e[c++]^S(s,r,o,t,n),s3:e[c++]^S(s,o,t,n,r)}}function x(e,t,n,r,o){const{sbox2:s,T01:i,T23:a}=v;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],o^=e[c++];const u=e.length/4-2;for(let s=0;s<u;s++){const s=e[c++]^E(i,a,t,o,r,n),u=e[c++]^E(i,a,n,t,o,r),l=e[c++]^E(i,a,r,n,t,o),f=e[c++]^E(i,a,o,r,n,t);t=s,n=u,r=l,o=f}return{s0:e[c++]^S(s,t,o,r,n),s1:e[c++]^S(s,n,t,o,r),s2:e[c++]^S(s,r,n,t,o),s3:e[c++]^S(s,o,r,n,t)}}function I(e,t,n,r){(0,o.abytes)(t,s),(0,o.abytes)(n);const i=n.length;r=(0,o.getOutput)(i,r),(0,o.complexOverlapBytes)(n,r);const a=t,c=(0,o.u32)(a);let{s0:u,s1:l,s2:f,s3:h}=B(e,c[0],c[1],c[2],c[3]);const d=(0,o.u32)(n),p=(0,o.u32)(r);for(let t=0;t+4<=d.length;t+=4){p[t+0]=d[t+0]^u,p[t+1]=d[t+1]^l,p[t+2]=d[t+2]^f,p[t+3]=d[t+3]^h;let n=1;for(let e=a.length-1;e>=0;e--)n=n+(255&a[e])|0,a[e]=255&n,n>>>=8;({s0:u,s1:l,s2:f,s3:h}=B(e,c[0],c[1],c[2],c[3]))}const y=s*Math.floor(d.length/4);if(y<i){const e=new Uint32Array([u,l,f,h]),t=(0,o.u8)(e);for(let e=y,o=0;e<i;e++,o++)r[e]=n[e]^t[o];(0,o.clean)(e)}return r}function A(e,t,n,r,i){(0,o.abytes)(n,s),(0,o.abytes)(r),i=(0,o.getOutput)(r.length,i);const a=n,c=(0,o.u32)(a),u=(0,o.createView)(a),l=(0,o.u32)(r),f=(0,o.u32)(i),h=t?0:12,d=r.length;let p=u.getUint32(h,t),{s0:y,s1:g,s2:v,s3:m}=B(e,c[0],c[1],c[2],c[3]);for(let n=0;n+4<=l.length;n+=4)f[n+0]=l[n+0]^y,f[n+1]=l[n+1]^g,f[n+2]=l[n+2]^v,f[n+3]=l[n+3]^m,p=p+1>>>0,u.setUint32(h,p,t),({s0:y,s1:g,s2:v,s3:m}=B(e,c[0],c[1],c[2],c[3]));const b=s*Math.floor(l.length/4);if(b<d){const e=new Uint32Array([y,g,v,m]),t=(0,o.u8)(e);for(let e=b,n=0;e<d;e++,n++)i[e]=r[e]^t[n];(0,o.clean)(e)}return i}function _(e){if((0,o.abytes)(e),e.length%s!=0)throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size 16")}function O(e,t,n){(0,o.abytes)(e);let r=e.length;const i=r%s;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,o.isAligned32)(e)||(e=(0,o.copyBytes)(e));const a=(0,o.u32)(e);if(t){let e=s-i;e||(e=s),r+=e}return n=(0,o.getOutput)(r,n),(0,o.complexOverlapBytes)(e,n),{b:a,o:(0,o.u32)(n),out:n}}function P(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const o=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function L(e){const t=new Uint8Array(16),n=(0,o.u32)(t);t.set(e);const r=s-e.length;for(let e=s-r;e<s;e++)t[e]=r;return n}function T(e,t,n,r,s){const i=s?s.length:0,a=e.create(n,r.length+i);s&&a.update(s);const c=(0,o.u64Lengths)(8*r.length,8*i,t);a.update(r),a.update(c);const u=a.digest();return(0,o.clean)(c),u}t.ctr=(0,o.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r){if((0,o.abytes)(n),void 0!==r&&((0,o.abytes)(r),!(0,o.isAligned32)(r)))throw new Error("unaligned destination");const s=b(e),i=(0,o.copyBytes)(t),a=[s,i];(0,o.isAligned32)(n)||a.push(n=(0,o.copyBytes)(n));const c=I(s,i,n,r);return(0,o.clean)(...a),c}return{encrypt:(e,t)=>n(e,t),decrypt:(e,t)=>n(e,t)}})),t.ecb=(0,o.wrapCipher)({blockSize:16},(function(e,t={}){const n=!t.disablePadding;return{encrypt(t,r){const{b:s,o:i,out:a}=O(t,n,r),c=b(e);let u=0;for(;u+4<=s.length;){const{s0:e,s1:t,s2:n,s3:r}=B(c,s[u+0],s[u+1],s[u+2],s[u+3]);i[u++]=e,i[u++]=t,i[u++]=n,i[u++]=r}if(n){const e=L(t.subarray(4*u)),{s0:n,s1:r,s2:o,s3:s}=B(c,e[0],e[1],e[2],e[3]);i[u++]=n,i[u++]=r,i[u++]=o,i[u++]=s}return(0,o.clean)(c),a},decrypt(t,r){_(t);const s=w(e);r=(0,o.getOutput)(t.length,r);const i=[s];(0,o.isAligned32)(t)||i.push(t=(0,o.copyBytes)(t)),(0,o.complexOverlapBytes)(t,r);const a=(0,o.u32)(t),c=(0,o.u32)(r);for(let e=0;e+4<=a.length;){const{s0:t,s1:n,s2:r,s3:o}=x(s,a[e+0],a[e+1],a[e+2],a[e+3]);c[e++]=t,c[e++]=n,c[e++]=r,c[e++]=o}return(0,o.clean)(...i),P(r,n)}}})),t.cbc=(0,o.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t,n={}){const r=!n.disablePadding;return{encrypt(n,s){const i=b(e),{b:a,o:c,out:u}=O(n,r,s);let l=t;const f=[i];(0,o.isAligned32)(l)||f.push(l=(0,o.copyBytes)(l));const h=(0,o.u32)(l);let d=h[0],p=h[1],y=h[2],g=h[3],v=0;for(;v+4<=a.length;)d^=a[v+0],p^=a[v+1],y^=a[v+2],g^=a[v+3],({s0:d,s1:p,s2:y,s3:g}=B(i,d,p,y,g)),c[v++]=d,c[v++]=p,c[v++]=y,c[v++]=g;if(r){const e=L(n.subarray(4*v));d^=e[0],p^=e[1],y^=e[2],g^=e[3],({s0:d,s1:p,s2:y,s3:g}=B(i,d,p,y,g)),c[v++]=d,c[v++]=p,c[v++]=y,c[v++]=g}return(0,o.clean)(...f),u},decrypt(n,s){_(n);const i=w(e);let a=t;const c=[i];(0,o.isAligned32)(a)||c.push(a=(0,o.copyBytes)(a));const u=(0,o.u32)(a);s=(0,o.getOutput)(n.length,s),(0,o.isAligned32)(n)||c.push(n=(0,o.copyBytes)(n)),(0,o.complexOverlapBytes)(n,s);const l=(0,o.u32)(n),f=(0,o.u32)(s);let h=u[0],d=u[1],p=u[2],y=u[3];for(let e=0;e+4<=l.length;){const t=h,n=d,r=p,o=y;h=l[e+0],d=l[e+1],p=l[e+2],y=l[e+3];const{s0:s,s1:a,s2:c,s3:u}=x(i,h,d,p,y);f[e++]=s^t,f[e++]=a^n,f[e++]=c^r,f[e++]=u^o}return(0,o.clean)(...c),P(s,r)}}})),t.cfb=(0,o.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r,i){(0,o.abytes)(n);const a=n.length;if(i=(0,o.getOutput)(a,i),(0,o.overlapBytes)(n,i))throw new Error("overlapping src and dst not supported.");const c=b(e);let u=t;const l=[c];(0,o.isAligned32)(u)||l.push(u=(0,o.copyBytes)(u)),(0,o.isAligned32)(n)||l.push(n=(0,o.copyBytes)(n));const f=(0,o.u32)(n),h=(0,o.u32)(i),d=r?h:f,p=(0,o.u32)(u);let y=p[0],g=p[1],v=p[2],m=p[3];for(let e=0;e+4<=f.length;){const{s0:t,s1:n,s2:r,s3:o}=B(c,y,g,v,m);h[e+0]=f[e+0]^t,h[e+1]=f[e+1]^n,h[e+2]=f[e+2]^r,h[e+3]=f[e+3]^o,y=d[e++],g=d[e++],v=d[e++],m=d[e++]}const w=s*Math.floor(f.length/4);if(w<a){({s0:y,s1:g,s2:v,s3:m}=B(c,y,g,v,m));const e=(0,o.u8)(new Uint32Array([y,g,v,m]));for(let t=w,r=0;t<a;t++,r++)i[t]=n[t]^e[r];(0,o.clean)(e)}return(0,o.clean)(...l),i}return{encrypt:(e,t)=>n(e,!0,t),decrypt:(e,t)=>n(e,!1,t)}})),t.gcm=(0,o.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},(function(e,t,n){if(t.length<8)throw new Error("aes/gcm: invalid nonce length");function s(e,t,o){const s=T(r.ghash,!1,e,o,n);for(let e=0;e<t.length;e++)s[e]^=t[e];return s}function a(){const n=b(e),s=i.slice(),a=i.slice();if(A(n,!1,a,a,s),12===t.length)a.set(t);else{const e=i.slice(),n=(0,o.createView)(e);(0,o.setBigUint64)(n,8,BigInt(8*t.length),!1);const c=r.ghash.create(s).update(t).update(e);c.digestInto(a),c.destroy()}return{xk:n,authKey:s,counter:a,tagMask:A(n,!1,a,i)}}return{encrypt(e){const{xk:t,authKey:n,counter:r,tagMask:i}=a(),c=new Uint8Array(e.length+16),u=[t,n,r,i];(0,o.isAligned32)(e)||u.push(e=(0,o.copyBytes)(e)),A(t,!1,r,e,c.subarray(0,e.length));const l=s(n,i,c.subarray(0,c.length-16));return u.push(l),c.set(l,e.length),(0,o.clean)(...u),c},decrypt(e){const{xk:t,authKey:n,counter:r,tagMask:i}=a(),c=[t,n,i,r];(0,o.isAligned32)(e)||c.push(e=(0,o.copyBytes)(e));const u=e.subarray(0,-16),l=e.subarray(-16),f=s(n,i,u);if(c.push(f),!(0,o.equalBytes)(f,l))throw new Error("aes/gcm: invalid ghash tag");const h=A(t,!1,r,u);return(0,o.clean)(...c),h}}}));const H=(e,t,n)=>r=>{if(!Number.isSafeInteger(r)||t>r||r>n)throw new Error(e+": expected value in range ["+t+".."+n+"], got "+r)};function C(e){return e instanceof Uint32Array||ArrayBuffer.isView(e)&&"Uint32Array"===e.constructor.name}function R(e,t){if((0,o.abytes)(t,16),!C(e))throw new Error("_encryptBlock accepts result of expandKeyLE");const n=(0,o.u32)(t);let{s0:r,s1:s,s2:i,s3:a}=B(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=s,n[2]=i,n[3]=a,t}function F(e,t){if((0,o.abytes)(t,16),!C(e))throw new Error("_decryptBlock accepts result of expandKeyLE");const n=(0,o.u32)(t);let{s0:r,s1:s,s2:i,s3:a}=x(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=s,n[2]=i,n[3]=a,t}t.gcmsiv=(0,o.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},(function(e,t,n){const s=H("AAD",0,2**36),i=H("plaintext",0,2**36),a=H("nonce",12,12),c=H("ciphertext",16,2**36+16);function u(){const n=b(e),r=new Uint8Array(e.length),s=new Uint8Array(16),i=[n,r];let a=t;(0,o.isAligned32)(a)||i.push(a=(0,o.copyBytes)(a));const c=(0,o.u32)(a);let u=0,l=c[0],f=c[1],h=c[2],d=0;for(const e of[s,r].map(o.u32)){const t=(0,o.u32)(e);for(let e=0;e<t.length;e+=2){const{s0:r,s1:o}=B(n,u,l,f,h);t[e+0]=r,t[e+1]=o,u=++d}}const p={authKey:s,encKey:b(r)};return(0,o.clean)(...i),p}function l(e,s,i){const a=T(r.polyval,!0,s,i,n);for(let e=0;e<12;e++)a[e]^=t[e];a[15]&=127;const c=(0,o.u32)(a);let u=c[0],l=c[1],f=c[2],h=c[3];return({s0:u,s1:l,s2:f,s3:h}=B(e,u,l,f,h)),c[0]=u,c[1]=l,c[2]=f,c[3]=h,a}function f(e,t,n){let r=(0,o.copyBytes)(t);r[15]|=128;const s=A(e,!0,r,n);return(0,o.clean)(r),s}return(0,o.abytes)(e,16,24,32),a(t.length),void 0!==n&&s(n.length),{encrypt(e){i(e.length);const{encKey:t,authKey:n}=u(),r=l(t,n,e),s=[t,n,r];(0,o.isAligned32)(e)||s.push(e=(0,o.copyBytes)(e));const a=new Uint8Array(e.length+16);return a.set(r,e.length),a.set(f(t,r,e)),(0,o.clean)(...s),a},decrypt(e){c(e.length);const t=e.subarray(-16),{encKey:n,authKey:r}=u(),s=[n,r];(0,o.isAligned32)(e)||s.push(e=(0,o.copyBytes)(e));const i=f(n,t,e.subarray(0,-16)),a=l(n,r,i);if(s.push(a),!(0,o.equalBytes)(t,a))throw(0,o.clean)(...s),new Error("invalid polyval tag");return(0,o.clean)(...s),i}}})),t.siv=t.gcmsiv;const N={encrypt(e,t){if(t.length>=2**32)throw new Error("plaintext should be less than 4gb");const n=b(e);if(16===t.length)R(n,t);else{const e=(0,o.u32)(t);let r=e[0],s=e[1];for(let t=0,o=1;t<6;t++)for(let t=2;t<e.length;t+=2,o++){const{s0:i,s1:a,s2:c,s3:u}=B(n,r,s,e[t],e[t+1]);r=i,s=a^p(o),e[t]=c,e[t+1]=u}e[0]=r,e[1]=s}n.fill(0)},decrypt(e,t){if(t.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const n=w(e),r=t.length/8-1;if(1===r)F(n,t);else{const e=(0,o.u32)(t);let s=e[0],i=e[1];for(let t=0,o=6*r;t<6;t++)for(let t=2*r;t>=1;t-=2,o--){i^=p(o);const{s0:r,s1:a,s2:c,s3:u}=x(n,s,i,e[t],e[t+1]);s=r,i=a,e[t]=c,e[t+1]=u}e[0]=s,e[1]=i}n.fill(0)}},k=new Uint8Array(8).fill(166);t.aeskw=(0,o.wrapCipher)({blockSize:8},(e=>({encrypt(t){if(!t.length||t.length%8!=0)throw new Error("invalid plaintext length");if(8===t.length)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const n=(0,o.concatBytes)(k,t);return N.encrypt(e,n),n},decrypt(t){if(t.length%8!=0||t.length<24)throw new Error("invalid ciphertext length");const n=(0,o.copyBytes)(t);if(N.decrypt(e,n),!(0,o.equalBytes)(n.subarray(0,8),k))throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8)}})));const V=2790873510;t.aeskwp=(0,o.wrapCipher)({blockSize:8},(e=>({encrypt(t){if(!t.length)throw new Error("invalid plaintext length");const n=8*Math.ceil(t.length/8),r=new Uint8Array(8+n);r.set(t,8);const s=(0,o.u32)(r);return s[0]=V,s[1]=p(t.length),N.encrypt(e,r),r},decrypt(t){if(t.length<16)throw new Error("invalid ciphertext length");const n=(0,o.copyBytes)(t),r=(0,o.u32)(n);N.decrypt(e,n);const s=p(r[1])>>>0,i=8*Math.ceil(s/8);if(r[0]!==V||n.length-8!==i)throw new Error("integrity check failed");for(let e=s;e<i;e++)if(0!==n[8+e])throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8,8+s)}}))),t.unsafe={expandKeyLE:b,expandKeyDecLE:w,encrypt:B,decrypt:x,encryptBlock:R,decryptBlock:F,ctrCounter:I,ctr32:A}},8900:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.xchacha20poly1305=t.chacha20poly1305=t._poly1305_aead=t.chacha12=t.chacha8=t.xchacha20=t.chacha20=t.chacha20orig=void 0,t.hchacha=a;const r=n(2506),o=n(1210),s=n(6527);function i(e,t,n,o,s,i=20){let a=e[0],c=e[1],u=e[2],l=e[3],f=t[0],h=t[1],d=t[2],p=t[3],y=t[4],g=t[5],v=t[6],m=t[7],b=s,w=n[0],E=n[1],S=n[2],B=a,x=c,I=u,A=l,_=f,O=h,P=d,L=p,T=y,H=g,C=v,R=m,F=b,N=w,k=E,V=S;for(let e=0;e<i;e+=2)B=B+_|0,F=(0,r.rotl)(F^B,16),T=T+F|0,_=(0,r.rotl)(_^T,12),B=B+_|0,F=(0,r.rotl)(F^B,8),T=T+F|0,_=(0,r.rotl)(_^T,7),x=x+O|0,N=(0,r.rotl)(N^x,16),H=H+N|0,O=(0,r.rotl)(O^H,12),x=x+O|0,N=(0,r.rotl)(N^x,8),H=H+N|0,O=(0,r.rotl)(O^H,7),I=I+P|0,k=(0,r.rotl)(k^I,16),C=C+k|0,P=(0,r.rotl)(P^C,12),I=I+P|0,k=(0,r.rotl)(k^I,8),C=C+k|0,P=(0,r.rotl)(P^C,7),A=A+L|0,V=(0,r.rotl)(V^A,16),R=R+V|0,L=(0,r.rotl)(L^R,12),A=A+L|0,V=(0,r.rotl)(V^A,8),R=R+V|0,L=(0,r.rotl)(L^R,7),B=B+O|0,V=(0,r.rotl)(V^B,16),C=C+V|0,O=(0,r.rotl)(O^C,12),B=B+O|0,V=(0,r.rotl)(V^B,8),C=C+V|0,O=(0,r.rotl)(O^C,7),x=x+P|0,F=(0,r.rotl)(F^x,16),R=R+F|0,P=(0,r.rotl)(P^R,12),x=x+P|0,F=(0,r.rotl)(F^x,8),R=R+F|0,P=(0,r.rotl)(P^R,7),I=I+L|0,N=(0,r.rotl)(N^I,16),T=T+N|0,L=(0,r.rotl)(L^T,12),I=I+L|0,N=(0,r.rotl)(N^I,8),T=T+N|0,L=(0,r.rotl)(L^T,7),A=A+_|0,k=(0,r.rotl)(k^A,16),H=H+k|0,_=(0,r.rotl)(_^H,12),A=A+_|0,k=(0,r.rotl)(k^A,8),H=H+k|0,_=(0,r.rotl)(_^H,7);let U=0;o[U++]=a+B|0,o[U++]=c+x|0,o[U++]=u+I|0,o[U++]=l+A|0,o[U++]=f+_|0,o[U++]=h+O|0,o[U++]=d+P|0,o[U++]=p+L|0,o[U++]=y+T|0,o[U++]=g+H|0,o[U++]=v+C|0,o[U++]=m+R|0,o[U++]=b+F|0,o[U++]=w+N|0,o[U++]=E+k|0,o[U++]=S+V|0}function a(e,t,n,o){let s=e[0],i=e[1],a=e[2],c=e[3],u=t[0],l=t[1],f=t[2],h=t[3],d=t[4],p=t[5],y=t[6],g=t[7],v=n[0],m=n[1],b=n[2],w=n[3];for(let e=0;e<20;e+=2)s=s+u|0,v=(0,r.rotl)(v^s,16),d=d+v|0,u=(0,r.rotl)(u^d,12),s=s+u|0,v=(0,r.rotl)(v^s,8),d=d+v|0,u=(0,r.rotl)(u^d,7),i=i+l|0,m=(0,r.rotl)(m^i,16),p=p+m|0,l=(0,r.rotl)(l^p,12),i=i+l|0,m=(0,r.rotl)(m^i,8),p=p+m|0,l=(0,r.rotl)(l^p,7),a=a+f|0,b=(0,r.rotl)(b^a,16),y=y+b|0,f=(0,r.rotl)(f^y,12),a=a+f|0,b=(0,r.rotl)(b^a,8),y=y+b|0,f=(0,r.rotl)(f^y,7),c=c+h|0,w=(0,r.rotl)(w^c,16),g=g+w|0,h=(0,r.rotl)(h^g,12),c=c+h|0,w=(0,r.rotl)(w^c,8),g=g+w|0,h=(0,r.rotl)(h^g,7),s=s+l|0,w=(0,r.rotl)(w^s,16),y=y+w|0,l=(0,r.rotl)(l^y,12),s=s+l|0,w=(0,r.rotl)(w^s,8),y=y+w|0,l=(0,r.rotl)(l^y,7),i=i+f|0,v=(0,r.rotl)(v^i,16),g=g+v|0,f=(0,r.rotl)(f^g,12),i=i+f|0,v=(0,r.rotl)(v^i,8),g=g+v|0,f=(0,r.rotl)(f^g,7),a=a+h|0,m=(0,r.rotl)(m^a,16),d=d+m|0,h=(0,r.rotl)(h^d,12),a=a+h|0,m=(0,r.rotl)(m^a,8),d=d+m|0,h=(0,r.rotl)(h^d,7),c=c+u|0,b=(0,r.rotl)(b^c,16),p=p+b|0,u=(0,r.rotl)(u^p,12),c=c+u|0,b=(0,r.rotl)(b^c,8),p=p+b|0,u=(0,r.rotl)(u^p,7);let E=0;o[E++]=s,o[E++]=i,o[E++]=a,o[E++]=c,o[E++]=v,o[E++]=m,o[E++]=b,o[E++]=w}t.chacha20orig=(0,r.createCipher)(i,{counterRight:!1,counterLength:8,allowShortKeys:!0}),t.chacha20=(0,r.createCipher)(i,{counterRight:!1,counterLength:4,allowShortKeys:!1}),t.xchacha20=(0,r.createCipher)(i,{counterRight:!1,counterLength:8,extendNonceFn:a,allowShortKeys:!1}),t.chacha8=(0,r.createCipher)(i,{counterRight:!1,counterLength:4,rounds:8}),t.chacha12=(0,r.createCipher)(i,{counterRight:!1,counterLength:4,rounds:12});const c=new Uint8Array(16),u=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(c.subarray(n))},l=new Uint8Array(32);function f(e,t,n,r,i){const a=e(t,n,l),c=o.poly1305.create(a);i&&u(c,i),u(c,r);const f=(0,s.u64Lengths)(r.length,i?i.length:0,!0);c.update(f);const h=c.digest();return(0,s.clean)(a,f),h}t._poly1305_aead=e=>(t,n,r)=>({encrypt(o,i){const a=o.length;(i=(0,s.getOutput)(a+16,i,!1)).set(o);const c=i.subarray(0,-16);e(t,n,c,c,1);const u=f(e,t,n,c,r);return i.set(u,a),(0,s.clean)(u),i},decrypt(o,i){i=(0,s.getOutput)(o.length-16,i,!1);const a=o.subarray(0,-16),c=o.subarray(-16),u=f(e,t,n,a,r);if(!(0,s.equalBytes)(c,u))throw new Error("invalid tag");return i.set(o.subarray(0,-16)),e(t,n,i,i,1),(0,s.clean)(u),i}}),t.chacha20poly1305=(0,s.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,t._poly1305_aead)(t.chacha20)),t.xchacha20poly1305=(0,s.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,t._poly1305_aead)(t.xchacha20))},5297:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},6527:(e,t)=>{function n(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function r(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function o(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!n(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function i(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}Object.defineProperty(t,"__esModule",{value:!0}),t.wrapCipher=t.Hash=t.nextTick=t.isLE=void 0,t.isBytes=n,t.abool=r,t.anumber=o,t.abytes=s,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");o(e.outputLen),o(e.blockLen)},t.aexists=function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},t.aoutput=function(e,t){s(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=i,t.bytesToHex=u,t.hexToBytes=h,t.hexToNumber=d,t.bytesToNumberBE=function(e){return d(u(e))},t.numberToBytesBE=function(e,t){return h(e.toString(16).padStart(2*t,"0"))},t.utf8ToBytes=p,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=function(e){if("string"==typeof e)e=p(e);else{if(!n(e))throw new Error("Uint8Array expected, got "+typeof e);e=m(e)}return e},t.overlapBytes=y,t.complexOverlapBytes=function(e,t){if(y(e,t)&&e.byteOffset<t.byteOffset)throw new Error("complex overlap of input and output is not supported")},t.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];s(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n},t.checkOpts=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)},t.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},t.getOutput=function(e,t,n=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(n&&!v(t))throw new Error("invalid output, must be aligned");return t},t.setBigUint64=g,t.u64Lengths=function(e,t,n){r(n);const o=new Uint8Array(16),s=i(o);return g(s,0,BigInt(t),n),g(s,8,BigInt(e),n),o},t.isAligned32=v,t.copyBytes=m,t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];const a=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),c=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function u(e){if(s(e),a)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=c[e[n]];return t}const l={_0:48,_9:57,A:65,F:70,a:97,f:102};function f(e){return e>=l._0&&e<=l._9?e-l._0:e>=l.A&&e<=l.F?e-(l.A-10):e>=l.a&&e<=l.f?e-(l.a-10):void 0}function h(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(a)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,o=0;t<n;t++,o+=2){const n=f(e.charCodeAt(o)),s=f(e.charCodeAt(o+1));if(void 0===n||void 0===s){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+s}return r}function d(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":"0x"+e)}function p(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function y(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function g(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}function v(e){return e.byteOffset%4==0}function m(e){return Uint8Array.from(e)}t.nextTick=async()=>{},t.Hash=class{},t.wrapCipher=(e,n)=>{function r(r,...o){if(s(r),!t.isLE)throw new Error("Non little-endian hardware is not yet supported");if(void 0!==e.nonceLength){const t=o[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?s(t):s(t,e.nonceLength)}const i=e.tagLength;i&&void 0!==o[1]&&s(o[1]);const a=n(r,...o),c=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");s(t)}};let u=!1;return{encrypt(e,t){if(u)throw new Error("cannot encrypt() twice with same key + nonce");return u=!0,s(e),c(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(s(e),i&&e.length<i)throw new Error("invalid ciphertext length: smaller than tagLength="+i);return c(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(r,e),r}},8489:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.gcm=t.ctr=t.cbc=t.utils=void 0,t.randomBytes=s,t.getWebcryptoSubtle=i,t.managedNonce=function(e){const{nonceLength:t}=e;return(0,o.anumber)(t),(n,...r)=>({encrypt(i,...a){const c=s(t),u=e(n,c,...r).encrypt(i,...a),l=(0,o.concatBytes)(c,u);return u.fill(0),l},decrypt(o,...s){const i=o.subarray(0,t),a=o.subarray(t);return e(n,i,...r).decrypt(a,...s)}})};const r=n(5297),o=n(6527);function s(e=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(e));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return Uint8Array.from(r.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function i(){if(r.crypto&&"object"==typeof r.crypto.subtle&&null!=r.crypto.subtle)return r.crypto.subtle;throw new Error("crypto.subtle must be defined")}t.utils={async encrypt(e,t,n,r){const o=i(),s=await o.importKey("raw",e,t,!0,["encrypt"]),a=await o.encrypt(n,s,r);return new Uint8Array(a)},async decrypt(e,t,n,r){const o=i(),s=await o.importKey("raw",e,t,!0,["decrypt"]),a=await o.decrypt(n,s,r);return new Uint8Array(a)}};const a="AES-CBC",c="AES-CTR",u="AES-GCM";function l(e){return(n,r,s)=>{(0,o.abytes)(n),(0,o.abytes)(r);const i={name:e,length:8*n.length},l=function(e,t,n){if(e===a)return{name:a,iv:t};if(e===c)return{name:c,counter:t,length:64};if(e===u)return n?{name:u,iv:t,additionalData:n}:{name:u,iv:t};throw new Error("unknown aes block mode")}(e,r,s);let f=!1;return{encrypt(e){if((0,o.abytes)(e),f)throw new Error("Cannot encrypt() twice with same key / nonce");return f=!0,t.utils.encrypt(n,i,l,e)},decrypt:e=>((0,o.abytes)(e),t.utils.decrypt(n,i,l,e))}}}t.cbc=l(a),t.ctr=l(c),t.gcm=(()=>l(u))()},3562:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getHash=function(e){return{hash:e}},t.createCurve=function(e,t){const n=t=>(0,r.weierstrass)({...e,hash:t});return{...n(t),create:n}};const r=n(1705)},2422:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wNAF=void 0,t.negateCt=a,t.normalizeZ=function(e,t){const n=(0,o.FpInvertBatch)(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))},t.mulEndoUnsafe=function(e,t,n,r){let o=t,a=e.ZERO,c=e.ZERO;for(;n>s||r>s;)n&i&&(a=a.add(o)),r&i&&(c=c.add(o)),o=o.double(),n>>=i,r>>=i;return{p1:a,p2:c}},t.pippenger=function(e,t,n,o){f(n,e),h(o,t);const s=n.length,i=o.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,c=(0,r.bitLen)(BigInt(s));let u=1;c>12?u=c-3:c>4?u=c-2:c>0&&(u=2);const l=(0,r.bitMask)(u),d=new Array(Number(l)+1).fill(a);let p=a;for(let e=Math.floor((t.BITS-1)/u)*u;e>=0;e-=u){d.fill(a);for(let t=0;t<i;t++){const r=o[t],s=Number(r>>BigInt(e)&l);d[s]=d[s].add(n[t])}let t=a;for(let e=d.length-1,n=a;e>0;e--)n=n.add(d[e]),t=t.add(n);if(p=p.add(t),0!==e)for(let e=0;e<u;e++)p=p.double()}return p},t.precomputeMSMUnsafe=function(e,t,n,o){c(o,t.BITS),f(n,e);const s=e.ZERO,i=2**o-1,a=Math.ceil(t.BITS/o),u=(0,r.bitMask)(o),l=n.map((e=>{const t=[];for(let n=0,r=e;n<i;n++)t.push(r),r=r.add(e);return t}));return e=>{if(h(e,t),e.length>n.length)throw new Error("array of scalars must be smaller than array of points");let r=s;for(let t=0;t<a;t++){if(r!==s)for(let e=0;e<o;e++)r=r.double();const n=BigInt(a*o-(t+1)*o);for(let t=0;t<e.length;t++){const o=e[t],s=Number(o>>n&u);s&&(r=r.add(l[t][s-1]))}}return r}},t.validateBasic=function(e){return(0,o.validateField)(e.Fp),(0,r.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,o.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})},t._createCurveFields=function(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const e of["p","n","h"]){const n=t[e];if(!("bigint"==typeof n&&n>s))throw new Error(`CURVE.${e} must be positive bigint`)}const o=v(t.p,n.Fp,r),i=v(t.n,n.Fn,r),a=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const e of a)if(!o.isValid(t[e]))throw new Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:o,Fn:i}};const r=n(8627),o=n(4967),s=BigInt(0),i=BigInt(1);function a(e,t){const n=t.negate();return e?n:t}function c(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function u(e,t){c(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:(0,r.bitMask)(e),maxNumber:n,shiftBy:BigInt(e)}}function l(e,t,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:a}=n;let c=Number(e&o),u=e>>a;c>r&&(c-=s,u+=i);const l=t*r;return{nextN:u,offset:l+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:t%2!=0,offsetF:l}}function f(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}function h(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}const d=new WeakMap,p=new WeakMap;function y(e){return p.get(e)||1}function g(e){if(e!==s)throw new Error("invalid wNAF")}function v(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return(0,o.validateField)(t),t}return(0,o.Field)(e,{isLE:n})}t.wNAF=class{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>s;)t&i&&(n=n.add(r)),r=r.double(),t>>=i;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=u(t,this.bits),o=[];let s=e,i=s;for(let e=0;e<n;e++){i=s,o.push(i);for(let e=1;e<r;e++)i=i.add(s),o.push(i);s=i.double()}return o}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const s=u(e,this.bits);for(let e=0;e<s.windows;e++){const{nextN:i,offset:c,isZero:u,isNeg:f,isNegF:h,offsetF:d}=l(n,e,s);n=i,u?o=o.add(a(h,t[d])):r=r.add(a(f,t[c]))}return g(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=u(e,this.bits);for(let e=0;e<o.windows&&n!==s;e++){const{nextN:s,offset:i,isZero:a,isNeg:c}=l(n,e,o);if(n=s,!a){const e=t[i];r=r.add(c?e.negate():e)}}return g(n),r}getPrecomputes(e,t,n){let r=d.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),d.set(t,r))),r}cached(e,t,n){const r=y(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=y(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){c(t,this.bits),p.set(e,t),d.delete(e)}hasCache(e){return 1!==y(e)}}},6377:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PrimeEdwardsPoint=void 0,t.edwards=l,t.eddsa=f,t.twistedEdwards=function(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:o}=function(e){const t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n={Fp:e.Fp,Fn:(0,s.Field)(t.n,e.nBitLength,!0),uvRatio:e.uvRatio},r={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:n,hash:e.hash,eddsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}(e,f(l(t,n),r,o))};const r=n(8627),o=n(2422),s=n(4967),i=BigInt(0),a=BigInt(1),c=BigInt(2),u=BigInt(8);function l(e,t={}){const n=(0,o._createCurveFields)("edwards",e,t,t.FpFnLE),{Fp:s,Fn:l}=n;let f=n.CURVE;const{h}=f;(0,r._validateObject)(t,{},{uvRatio:"function"});const d=c<<BigInt(8*l.BYTES)-a,p=e=>s.create(e),y=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:s.sqrt(s.div(e,t))}}catch(e){return{isValid:!1,value:i}}});if(!function(e,t,n,r){const o=e.sqr(n),s=e.sqr(r),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}(s,f,f.Gx,f.Gy))throw new Error("bad curve params: generator point");function g(e,t,n=!1){const o=n?a:i;return(0,r.aInRange)("coordinate "+e,t,o,d),t}function v(e){if(!(e instanceof w))throw new Error("ExtendedPoint expected")}const m=(0,r.memoized)(((e,t)=>{const{X:n,Y:r,Z:o}=e,c=e.is0();null==t&&(t=c?u:s.inv(o));const l=p(n*t),f=p(r*t),h=s.mul(o,t);if(c)return{x:i,y:a};if(h!==a)throw new Error("invZ was invalid");return{x:l,y:f}})),b=(0,r.memoized)((e=>{const{a:t,d:n}=f;if(e.is0())throw new Error("bad point: ZERO");const{X:r,Y:o,Z:s,T:i}=e,a=p(r*r),c=p(o*o),u=p(s*s),l=p(u*u),h=p(a*t);if(p(u*p(h+c))!==p(l+p(n*p(a*c))))throw new Error("bad point: equation left != right (1)");if(p(r*o)!==p(s*i))throw new Error("bad point: equation left != right (2)");return!0}));class w{constructor(e,t,n,r){this.X=g("x",e),this.Y=g("y",t),this.Z=g("z",n,!0),this.T=g("t",r),Object.freeze(this)}static CURVE(){return f}static fromAffine(e){if(e instanceof w)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return g("x",t),g("y",n),new w(t,n,a,p(t*n))}static fromBytes(e,t=!1){const n=s.BYTES,{a:o,d:c}=f;e=(0,r.copyBytes)((0,r._abytes2)(e,n,"point")),(0,r._abool2)(t,"zip215");const u=(0,r.copyBytes)(e),l=e[n-1];u[n-1]=-129&l;const h=(0,r.bytesToNumberLE)(u),g=t?d:s.ORDER;(0,r.aInRange)("point.y",h,i,g);const v=p(h*h),m=p(v-a),b=p(c*v-o);let{isValid:E,value:S}=y(m,b);if(!E)throw new Error("bad point: invalid y coordinate");const B=(S&a)===a,x=!!(128&l);if(!t&&S===i&&x)throw new Error("bad point: x=0 and x_0=1");return x!==B&&(S=p(-S)),w.fromAffine({x:S,y:h})}static fromHex(e,t=!1){return w.fromBytes((0,r.ensureBytes)("point",e),t)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return E.createCache(this,e),t||this.multiply(c),this}assertValidity(){b(this)}equals(e){v(e);const{X:t,Y:n,Z:r}=this,{X:o,Y:s,Z:i}=e,a=p(t*i),c=p(o*r),u=p(n*i),l=p(s*r);return a===c&&u===l}is0(){return this.equals(w.ZERO)}negate(){return new w(p(-this.X),this.Y,this.Z,p(-this.T))}double(){const{a:e}=f,{X:t,Y:n,Z:r}=this,o=p(t*t),s=p(n*n),i=p(c*p(r*r)),a=p(e*o),u=t+n,l=p(p(u*u)-o-s),h=a+s,d=h-i,y=a-s,g=p(l*d),v=p(h*y),m=p(l*y),b=p(d*h);return new w(g,v,b,m)}add(e){v(e);const{a:t,d:n}=f,{X:r,Y:o,Z:s,T:i}=this,{X:a,Y:c,Z:u,T:l}=e,h=p(r*a),d=p(o*c),y=p(i*n*l),g=p(s*u),m=p((r+o)*(a+c)-h-d),b=g-y,E=g+y,S=p(d-t*h),B=p(m*b),x=p(E*S),I=p(m*S),A=p(b*E);return new w(B,x,A,I)}subtract(e){return this.add(e.negate())}multiply(e){if(!l.isValidNot0(e))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:t,f:n}=E.cached(this,e,(e=>(0,o.normalizeZ)(w,e)));return(0,o.normalizeZ)(w,[t,n])[0]}multiplyUnsafe(e,t=w.ZERO){if(!l.isValid(e))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return e===i?w.ZERO:this.is0()||e===a?this:E.unsafe(this,e,(e=>(0,o.normalizeZ)(w,e)),t)}isSmallOrder(){return this.multiplyUnsafe(h).is0()}isTorsionFree(){return E.unsafe(this,f.n).is0()}toAffine(e){return m(this,e)}clearCofactor(){return h===a?this:this.multiplyUnsafe(h)}toBytes(){const{x:e,y:t}=this.toAffine(),n=s.toBytes(t);return n[n.length-1]|=e&a?128:0,n}toHex(){return(0,r.bytesToHex)(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(e){return(0,o.normalizeZ)(w,e)}static msm(e,t){return(0,o.pippenger)(w,l,e,t)}_setWindowSize(e){this.precompute(e)}toRawBytes(){return this.toBytes()}}w.BASE=new w(f.Gx,f.Gy,a,p(f.Gx*f.Gy)),w.ZERO=new w(i,a,a,i),w.Fp=s,w.Fn=l;const E=new o.wNAF(w,l.BITS);return w.BASE.precompute(8),w}function f(e,t,n={}){if("function"!=typeof t)throw new Error('"hash" function param is required');(0,r._validateObject)(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=n,{BASE:s,Fp:i,Fn:c}=e,u=n.randomBytes||r.randomBytes,l=n.adjustScalarBytes||(e=>e),f=n.domain||((e,t,n)=>{if((0,r._abool2)(n,"phflag"),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function h(e){return c.create((0,r.bytesToNumberLE)(e))}function d(e){const{head:n,prefix:o,scalar:i}=function(e){const n=m.secretKey;e=(0,r.ensureBytes)("private key",e,n);const o=(0,r.ensureBytes)("hashed private key",t(e),2*n),s=l(o.slice(0,n));return{head:s,prefix:o.slice(n,2*n),scalar:h(s)}}(e),a=s.multiply(i),c=a.toBytes();return{head:n,prefix:o,scalar:i,point:a,pointBytes:c}}function p(e){return d(e).pointBytes}function y(e=Uint8Array.of(),...n){const s=(0,r.concatBytes)(...n);return h(t(f(s,(0,r.ensureBytes)("context",e),!!o)))}const g={zip215:!0},v=i.BYTES,m={secretKey:v,publicKey:v,signature:2*v,seed:v};function b(e=u(m.seed)){return(0,r._abytes2)(e,m.seed,"seed")}const w={getExtendedPublicKey:d,randomSecretKey:b,isValidSecretKey:function(e){return(0,r.isBytes)(e)&&e.length===c.BYTES},isValidPublicKey:function(t,n){try{return!!e.fromBytes(t,n)}catch(e){return!1}},toMontgomery(t){const{y:n}=e.fromBytes(t),r=m.publicKey,o=32===r;if(!o&&57!==r)throw new Error("only defined for 25519 and 448");const s=o?i.div(a+n,a-n):i.div(n-a,n+a);return i.toBytes(s)},toMontgomerySecret(e){const n=m.secretKey;(0,r._abytes2)(e,n);const o=t(e.subarray(0,n));return l(o).subarray(0,n)},randomPrivateKey:b,precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({keygen:function(e){const t=w.randomSecretKey(e);return{secretKey:t,publicKey:p(t)}},getPublicKey:p,sign:function(e,t,n={}){e=(0,r.ensureBytes)("message",e),o&&(e=o(e));const{prefix:i,scalar:a,pointBytes:u}=d(t),l=y(n.context,i,e),f=s.multiply(l).toBytes(),h=y(n.context,f,u,e),p=c.create(l+h*a);if(!c.isValid(p))throw new Error("sign failed: invalid s");const g=(0,r.concatBytes)(f,c.toBytes(p));return(0,r._abytes2)(g,m.signature,"result")},verify:function(t,n,i,a=g){const{context:c,zip215:u}=a,l=m.signature;t=(0,r.ensureBytes)("signature",t,l),n=(0,r.ensureBytes)("message",n),i=(0,r.ensureBytes)("publicKey",i,m.publicKey),void 0!==u&&(0,r._abool2)(u,"zip215"),o&&(n=o(n));const f=l/2,h=t.subarray(0,f),d=(0,r.bytesToNumberLE)(t.subarray(f,l));let p,v,b;try{p=e.fromBytes(i,u),v=e.fromBytes(h,u),b=s.multiplyUnsafe(d)}catch(e){return!1}if(!u&&p.isSmallOrder())return!1;const w=y(c,v.toBytes(),p.toBytes(),n);return v.add(p.multiplyUnsafe(w)).subtract(b).clearCofactor().is0()},utils:w,Point:e,lengths:m})}t.PrimeEdwardsPoint=class{constructor(e){this.ep=e}static fromBytes(e){(0,r.notImplemented)()}static fromHex(e){(0,r.notImplemented)()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(e){return this.ep.toAffine(e)}toHex(){return(0,r.bytesToHex)(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(e){return this.assertSame(e),this.init(this.ep.add(e.ep))}subtract(e){return this.assertSame(e),this.init(this.ep.subtract(e.ep))}multiply(e){return this.init(this.ep.multiply(e))}multiplyUnsafe(e){return this.init(this.ep.multiplyUnsafe(e))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(e,t){return this.init(this.ep.precompute(e,t))}toRawBytes(){return this.toBytes()}}},1761:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t._DST_scalar=void 0,t.expand_message_xmd=l,t.expand_message_xof=f,t.hash_to_field=h,t.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[s,i,a,c]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r))))),[u,l]=(0,o.FpInvertBatch)(e,[i,c],!0);return t=e.mul(s,u),r=e.mul(r,e.mul(a,l)),{x:t,y:r}}},t.createHasher=function(e,n,r){if("function"!=typeof n)throw new Error("mapToCurve() must be defined");function o(t){return e.fromAffine(n(t))}function s(t){const n=t.clearCofactor();return n.equals(e.ZERO)?e.ZERO:(n.assertValidity(),n)}return{defaults:r,hashToCurve(e,t){const n=h(e,2,Object.assign({},r,t)),i=o(n[0]),a=o(n[1]);return s(i.add(a))},encodeToCurve(e,t){const n=r.encodeDST?{DST:r.encodeDST}:{};return s(o(h(e,1,Object.assign({},r,n,t))[0]))},mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return s(o(e))},hashToScalar(n,o){const s=e.Fn.ORDER;return h(n,1,Object.assign({},r,{p:s,m:1,DST:t._DST_scalar},o))[0][0]}}};const r=n(8627),o=n(4967),s=r.bytesToNumberBE;function i(e,t){if(c(e),c(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function a(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function u(e){if(!(0,r.isBytes)(e)&&"string"!=typeof e)throw new Error("DST must be Uint8Array or string");return"string"==typeof e?(0,r.utf8ToBytes)(e):e}function l(e,t,n,o){(0,r.abytes)(e),c(n),(t=u(t)).length>255&&(t=o((0,r.concatBytes)((0,r.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:s,blockLen:l}=o,f=Math.ceil(n/s);if(n>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const h=(0,r.concatBytes)(t,i(t.length,1)),d=i(0,l),p=i(n,2),y=new Array(f),g=o((0,r.concatBytes)(d,e,p,i(0,1),h));y[0]=o((0,r.concatBytes)(g,i(1,1),h));for(let e=1;e<=f;e++){const t=[a(g,y[e-1]),i(e+1,1),h];y[e]=o((0,r.concatBytes)(...t))}return(0,r.concatBytes)(...y).slice(0,n)}function f(e,t,n,o,s){if((0,r.abytes)(e),c(n),(t=u(t)).length>255){const e=Math.ceil(2*o/8);t=s.create({dkLen:e}).update((0,r.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:n}).update(e).update(i(n,2)).update(t).update(i(t.length,1)).digest()}function h(e,t,n){(0,r._validateObject)(n,{p:"bigint",m:"number",k:"number",hash:"function"});const{p:i,k:a,m:u,hash:h,expand:d,DST:p}=n;if(!(0,r.isHash)(n.hash))throw new Error("expected valid hash");(0,r.abytes)(e),c(t);const y=i.toString(2).length,g=Math.ceil((y+a)/8),v=t*u*g;let m;if("xmd"===d)m=l(e,p,v,h);else if("xof"===d)m=f(e,p,v,a,h);else{if("_internal_pass"!==d)throw new Error('expand must be "xmd" or "xof"');m=e}const b=new Array(t);for(let e=0;e<t;e++){const t=new Array(u);for(let n=0;n<u;n++){const r=g*(n+e*u),a=m.subarray(r,r+g);t[n]=(0,o.mod)(s(a),i)}b[e]=t}return b}t._DST_scalar=(0,r.utf8ToBytes)("HashToScalar-")},4967:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNegativeLE=void 0,t.mod=p,t.pow=function(e,t,n){return S(A(n),e,t)},t.pow2=function(e,t,n){let r=e;for(;t-- >o;)r*=r,r%=n;return r},t.invert=y,t.tonelliShanks=b,t.FpSqrt=w,t.validateField=function(e){const t=E.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});return(0,r._validateObject)(e,t),e},t.FpPow=S,t.FpInvertBatch=B,t.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?y(n,e.ORDER):e.inv(n))},t.FpLegendre=x,t.FpIsSquare=function(e,t){return 1===x(e,t)},t.nLength=I,t.Field=A,t.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},t.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},t.hashToPrivateScalar=function(e,t,n=!1){const o=(e=(0,r.ensureBytes)("privateHash",e)).length,i=I(t).nByteLength+8;if(i<24||o<i||o>1024)throw new Error("hashToPrivateScalar: expected "+i+"-1024 bytes of input, got "+o);return p(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-s)+s},t.getFieldBytesLength=_,t.getMinHashLength=O,t.mapHashToField=function(e,t,n=!1){const o=e.length,i=_(t),a=O(t);if(o<16||o<a||o>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+o);const c=p(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-s)+s;return n?(0,r.numberToBytesLE)(c,i):(0,r.numberToBytesBE)(c,i)};const r=n(8627),o=BigInt(0),s=BigInt(1),i=BigInt(2),a=BigInt(3),c=BigInt(4),u=BigInt(5),l=BigInt(7),f=BigInt(8),h=BigInt(9),d=BigInt(16);function p(e,t){const n=e%t;return n>=o?n:t+n}function y(e,t){if(e===o)throw new Error("invert: expected non-zero number");if(t<=o)throw new Error("invert: expected positive modulus, got "+t);let n=p(e,t),r=t,i=o,a=s,c=s,u=o;for(;n!==o;){const e=r/n,t=r%n,o=i-c*e,s=a-u*e;r=n,n=t,i=c,a=u,c=o,u=s}if(r!==s)throw new Error("invert: does not exist");return p(i,t)}function g(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function v(e,t){const n=(e.ORDER+s)/c,r=e.pow(t,n);return g(e,r,t),r}function m(e,t){const n=(e.ORDER-u)/f,r=e.mul(t,i),o=e.pow(r,n),s=e.mul(t,o),a=e.mul(e.mul(s,i),o),c=e.mul(s,e.sub(a,e.ONE));return g(e,c,t),c}function b(e){if(e<a)throw new Error("sqrt is not defined for small field");let t=e-s,n=0;for(;t%i===o;)t/=i,n++;let r=i;const c=A(e);for(;1===x(c,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return v;let u=c.pow(r,t);const l=(t+s)/i;return function(e,r){if(e.is0(r))return r;if(1!==x(e,r))throw new Error("Cannot find square root");let o=n,i=e.mul(e.ONE,u),a=e.pow(r,t),c=e.pow(r,l);for(;!e.eql(a,e.ONE);){if(e.is0(a))return e.ZERO;let t=1,n=e.sqr(a);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===o)throw new Error("Cannot find square root");const r=s<<BigInt(o-t-1),u=e.pow(i,r);o=t,i=e.sqr(u),a=e.mul(a,i),c=e.mul(c,u)}return c}}function w(e){return e%c===a?v:e%f===u?m:e%d===h?function(e){const t=A(e),n=b(e),r=n(t,t.neg(t.ONE)),o=n(t,r),s=n(t,t.neg(r)),i=(e+l)/d;return(e,t)=>{let n=e.pow(t,i),a=e.mul(n,r);const c=e.mul(n,o),u=e.mul(n,s),l=e.eql(e.sqr(a),t),f=e.eql(e.sqr(c),t);n=e.cmov(n,a,l),a=e.cmov(u,c,f);const h=e.eql(e.sqr(a),t),d=e.cmov(n,a,h);return g(e,d,t),d}}(e):b(e)}t.isNegativeLE=(e,t)=>(p(e,t)&s)===s;const E=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function S(e,t,n){if(n<o)throw new Error("invalid exponent, negatives unsupported");if(n===o)return e.ONE;if(n===s)return t;let r=e.ONE,i=t;for(;n>o;)n&s&&(r=e.mul(r,i)),i=e.sqr(i),n>>=s;return r}function B(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),s=e.inv(o);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),s),r}function x(e,t){const n=(e.ORDER-s)/i,r=e.pow(t,n),o=e.eql(r,e.ONE),a=e.eql(r,e.ZERO),c=e.eql(r,e.neg(e.ONE));if(!o&&!a&&!c)throw new Error("invalid Legendre symbol result");return o?1:a?0:-1}function I(e,t){void 0!==t&&(0,r.anumber)(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function A(e,t,n=!1,i={}){if(e<=o)throw new Error("invalid field: expected ORDER > 0, got "+e);let a,c,u,l=!1;if("object"==typeof t&&null!=t){if(i.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(a=e.BITS),e.sqrt&&(c=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(l=e.modFromBytes),u=e.allowedLengths}else"number"==typeof t&&(a=t),i.sqrt&&(c=i.sqrt);const{nBitLength:f,nByteLength:h}=I(e,a);if(h>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let d;const g=Object.freeze({ORDER:e,isLE:n,BITS:f,BYTES:h,MASK:(0,r.bitMask)(f),ZERO:o,ONE:s,allowedLengths:u,create:t=>p(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return o<=t&&t<e},is0:e=>e===o,isValidNot0:e=>!g.is0(e)&&g.isValid(e),isOdd:e=>(e&s)===s,neg:t=>p(-t,e),eql:(e,t)=>e===t,sqr:t=>p(t*t,e),add:(t,n)=>p(t+n,e),sub:(t,n)=>p(t-n,e),mul:(t,n)=>p(t*n,e),pow:(e,t)=>S(g,e,t),div:(t,n)=>p(t*y(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>y(t,e),sqrt:c||(t=>(d||(d=w(e)),d(g,t))),toBytes:e=>n?(0,r.numberToBytesLE)(e,h):(0,r.numberToBytesBE)(e,h),fromBytes:(t,o=!0)=>{if(u){if(!u.includes(t.length)||t.length>h)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+t.length);const e=new Uint8Array(h);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==h)throw new Error("Field.fromBytes: expected "+h+" bytes, got "+t.length);let s=n?(0,r.bytesToNumberLE)(t):(0,r.bytesToNumberBE)(t);if(l&&(s=p(s,e)),!o&&!g.isValid(s))throw new Error("invalid field element: outside of range 0..ORDER");return s},invertBatch:e=>B(g,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(g)}function _(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function O(e){const t=_(e);return t+Math.ceil(t/2)}},2854:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.montgomery=function(e){const t=(d=e,(0,r._validateObject)(d,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...d})),{P:n,type:c,adjustScalarBytes:u,powPminus2:l,randomBytes:f}=t,h="x25519"===c;var d;if(!h&&"x448"!==c)throw new Error("invalid type");const p=f||r.randomBytes,y=h?255:448,g=h?32:56,v=h?BigInt(9):BigInt(5),m=h?BigInt(121665):BigInt(39081),b=h?a**BigInt(254):a**BigInt(447),w=h?BigInt(8)*a**BigInt(251)-i:BigInt(4)*a**BigInt(445)-i,E=b+w+i,S=e=>(0,o.mod)(e,n),B=x(v);function x(e){return(0,r.numberToBytesLE)(S(e),g)}function I(e,t){const o=function(e,t){(0,r.aInRange)("u",e,s,n),(0,r.aInRange)("scalar",t,b,E);const o=t,a=e;let c=i,u=s,f=e,h=i,d=s;for(let e=BigInt(y-1);e>=s;e--){const t=o>>e&i;d^=t,({x_2:c,x_3:f}=_(d,c,f)),({x_2:u,x_3:h}=_(d,u,h)),d=t;const n=c+u,r=S(n*n),s=c-u,l=S(s*s),p=r-l,y=f+h,g=S((f-h)*n),v=S(y*s),b=g+v,w=g-v;f=S(b*b),h=S(a*S(w*w)),c=S(r*l),u=S(p*(r+S(m*p)))}({x_2:c,x_3:f}=_(d,c,f)),({x_2:u,x_3:h}=_(d,u,h));const p=l(u);return S(c*p)}(function(e){const t=(0,r.ensureBytes)("u coordinate",e,g);return h&&(t[31]&=127),S((0,r.bytesToNumberLE)(t))}(t),function(e){return(0,r.bytesToNumberLE)(u((0,r.ensureBytes)("scalar",e,g)))}(e));if(o===s)throw new Error("invalid private or public key received");return x(o)}function A(e){return I(e,B)}function _(e,t,n){const r=S(e*(t-n));return{x_2:t=S(t-r),x_3:n=S(n+r)}}const O={secretKey:g,publicKey:g,seed:g},P=(e=p(g))=>((0,r.abytes)(e,O.seed),e);return{keygen:function(e){const t=P(e);return{secretKey:t,publicKey:A(t)}},getSharedSecret:(e,t)=>I(e,t),getPublicKey:e=>A(e),scalarMult:I,scalarMultBase:A,utils:{randomSecretKey:P,randomPrivateKey:P},GuBytes:B.slice(),lengths:O}};const r=n(8627),o=n(4967),s=BigInt(0),i=BigInt(1),a=BigInt(2)},1705:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DER=t.DERErr=void 0,t._splitEndoScalar=u,t._normFnElement=m,t.weierstrassN=b,t.SWUFpSqrtRatio=E,t.mapToCurveSimpleSWU=function(e,t){(0,a.validateField)(e);const{A:n,B:r,Z:o}=t;if(!e.isValid(n)||!e.isValid(r)||!e.isValid(o))throw new Error("mapToCurveSimpleSWU: invalid opts");const s=E(e,o);if(!e.isOdd)throw new Error("Field does not have .isOdd()");return t=>{let i,c,u,l,f,h,d,p;i=e.sqr(t),i=e.mul(i,o),c=e.sqr(i),c=e.add(c,i),u=e.add(c,e.ONE),u=e.mul(u,r),l=e.cmov(o,e.neg(c),!e.eql(c,e.ZERO)),l=e.mul(l,n),c=e.sqr(u),h=e.sqr(l),f=e.mul(h,n),c=e.add(c,f),c=e.mul(c,u),h=e.mul(h,l),f=e.mul(h,r),c=e.add(c,f),d=e.mul(i,u);const{isValid:y,value:g}=s(c,h);p=e.mul(i,t),p=e.mul(p,g),d=e.cmov(d,u,y),p=e.cmov(p,g,y);const v=e.isOdd(t)===e.isOdd(p);p=e.cmov(e.neg(p),p,v);const m=(0,a.FpInvertBatch)(e,[l],!0)[0];return d=e.mul(d,m),{x:d,y:p}}},t.ecdh=B,t.ecdsa=x,t.weierstrassPoints=function(e){const{CURVE:t,curveOpts:n}=I(e);return function(e,t){const{Fp:n,Fn:r}=t;const o=A(n,e.a,e.b);return Object.assign({},{CURVE:e,Point:t,ProjectivePoint:t,normPrivateKeyToScalar:e=>m(r,e),weierstrassEquation:o,isWithinCurveOrder:function(e){return(0,s.inRange)(e,p,r.ORDER)}})}(e,b(t,n))},t._legacyHelperEquat=A,t.weierstrass=function(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:n}=I(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,(0,a.nLength)(n.Fn.ORDER,n.Fn.BITS))})}(e,x(b(t,n),r,o))};const r=n(9615),o=n(9175),s=n(8627),i=n(2422),a=n(4967),c=(e,t)=>(e+(e>=0?t:-t)/y)/t;function u(e,t,n){const[[r,o],[i,a]]=t,u=c(a*e,n),l=c(-o*e,n);let f=e-u*r-l*i,h=-u*o-l*a;const y=f<d,g=h<d;y&&(f=-f),g&&(h=-h);const v=(0,s.bitMask)(Math.ceil((0,s.bitLen)(n)/2))+p;if(f<d||f>=v||h<d||h>=v)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:y,k1:f,k2neg:g,k2:h}}function l(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function f(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return(0,s._abool2)(n.lowS,"lowS"),(0,s._abool2)(n.prehash,"prehash"),void 0!==n.format&&l(n.format),n}class h extends Error{constructor(e=""){super(e)}}t.DERErr=h,t.DER={Err:h,_tlv:{encode:(e,n)=>{const{Err:r}=t.DER;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&n.length)throw new r("tlv.encode: unpadded data");const o=n.length/2,i=(0,s.numberToHexUnpadded)(o);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const a=o>127?(0,s.numberToHexUnpadded)(i.length/2|128):"";return(0,s.numberToHexUnpadded)(e)+a+i+n},decode(e,n){const{Err:r}=t.DER;let o=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(n.length<2||n[o++]!==e)throw new r("tlv.decode: wrong tlv");const s=n[o++];let i=0;if(128&s){const e=127&s;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const t=n.subarray(o,o+e);if(t.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===t[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of t)i=i<<8|e;if(o+=e,i<128)throw new r("tlv.decode(long): not minimal encoding")}else i=s;const a=n.subarray(o,o+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:n.subarray(o+i)}}},_int:{encode(e){const{Err:n}=t.DER;if(e<d)throw new n("integer: negative integers are not allowed");let r=(0,s.numberToHexUnpadded)(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new n("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:n}=t.DER;if(128&e[0])throw new n("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new n("invalid signature integer: unnecessary leading zero");return(0,s.bytesToNumberBE)(e)}},toSig(e){const{Err:n,_int:r,_tlv:o}=t.DER,i=(0,s.ensureBytes)("signature",e),{v:a,l:c}=o.decode(48,i);if(c.length)throw new n("invalid signature: left bytes after parsing");const{v:u,l}=o.decode(2,a),{v:f,l:h}=o.decode(2,l);if(h.length)throw new n("invalid signature: left bytes after parsing");return{r:r.decode(u),s:r.decode(f)}},hexFromSig(e){const{_tlv:n,_int:r}=t.DER,o=n.encode(2,r.encode(e.r))+n.encode(2,r.encode(e.s));return n.encode(48,o)}};const d=BigInt(0),p=BigInt(1),y=BigInt(2),g=BigInt(3),v=BigInt(4);function m(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let o=(0,s.ensureBytes)("private key",t);try{r=e.fromBytes(o)}catch(e){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function b(e,t={}){const n=(0,i._createCurveFields)("weierstrass",e,t),{Fp:r,Fn:o}=n;let a=n.CURVE;const{h:c,n:l}=a;(0,s._validateObject)(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=t;if(f&&(!r.is0(a.a)||"bigint"!=typeof f.beta||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const h=S(r,o);function y(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const b=t.toBytes||function(e,t,n){const{x:o,y:i}=t.toAffine(),a=r.toBytes(o);if((0,s._abool2)(n,"isCompressed"),n){y();const e=!r.isOdd(i);return(0,s.concatBytes)(w(e),a)}return(0,s.concatBytes)(Uint8Array.of(4),a,r.toBytes(i))},E=t.fromBytes||function(e){(0,s._abytes2)(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=h,o=e.length,i=e[0],a=e.subarray(1);if(o!==t||2!==i&&3!==i){if(o===n&&4===i){const e=r.BYTES,t=r.fromBytes(a.subarray(0,e)),n=r.fromBytes(a.subarray(e,2*e));if(!x(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${o}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(a);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=B(e);let n;try{n=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("bad point: is not on curve, sqrt error"+t)}return y(),!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function B(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function x(e,t){const n=r.sqr(t),o=B(e);return r.eql(n,o)}if(!x(a.Gx,a.Gy))throw new Error("bad curve params: generator point");const I=r.mul(r.pow(a.a,g),v),A=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(I,A)))throw new Error("bad curve params: a or b");function _(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function O(e){if(!(e instanceof C))throw new Error("ProjectivePoint expected")}function P(e){if(!f||!f.basises)throw new Error("no endo");return u(e,f.basises,o.ORDER)}const L=(0,s.memoized)(((e,t)=>{const{X:n,Y:o,Z:s}=e;if(r.eql(s,r.ONE))return{x:n,y:o};const i=e.is0();null==t&&(t=i?r.ONE:r.inv(s));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(s,t);if(i)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),T=(0,s.memoized)((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not field elements");if(!x(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));function H(e,t,n,o,s){return n=new C(r.mul(n.X,e),n.Y,n.Z),t=(0,i.negateCt)(o,t),n=(0,i.negateCt)(s,n),t.add(n)}class C{constructor(e,t,n){this.X=_("x",e),this.Y=_("y",t,!0),this.Z=_("z",n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof C)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?C.ZERO:new C(t,n,r.ONE)}static fromBytes(e){const t=C.fromAffine(E((0,s._abytes2)(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return C.fromBytes((0,s.ensureBytes)("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return F.createCache(this,e),t||this.multiply(g),this}assertValidity(){T(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){O(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:i,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(s,o)),u=r.eql(r.mul(n,a),r.mul(i,o));return c&&u}negate(){return new C(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=a,n=r.mul(t,g),{X:o,Y:s,Z:i}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),h=r.mul(s,s),d=r.mul(i,i),p=r.mul(o,s);return p=r.add(p,p),l=r.mul(o,i),l=r.add(l,l),c=r.mul(e,l),u=r.mul(n,d),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(p,c),l=r.mul(n,l),d=r.mul(e,d),p=r.sub(f,d),p=r.mul(e,p),p=r.add(p,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,d),f=r.mul(f,p),u=r.add(u,f),d=r.mul(s,i),d=r.add(d,d),f=r.mul(d,p),c=r.sub(c,f),l=r.mul(d,h),l=r.add(l,l),l=r.add(l,l),new C(c,u,l)}add(e){O(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:i,Z:c}=e;let u=r.ZERO,l=r.ZERO,f=r.ZERO;const h=a.a,d=r.mul(a.b,g);let p=r.mul(t,s),y=r.mul(n,i),v=r.mul(o,c),m=r.add(t,n),b=r.add(s,i);m=r.mul(m,b),b=r.add(p,y),m=r.sub(m,b),b=r.add(t,o);let w=r.add(s,c);return b=r.mul(b,w),w=r.add(p,v),b=r.sub(b,w),w=r.add(n,o),u=r.add(i,c),w=r.mul(w,u),u=r.add(y,v),w=r.sub(w,u),f=r.mul(h,b),u=r.mul(d,v),f=r.add(u,f),u=r.sub(y,f),f=r.add(y,f),l=r.mul(u,f),y=r.add(p,p),y=r.add(y,p),v=r.mul(h,v),b=r.mul(d,b),y=r.add(y,v),v=r.sub(p,v),v=r.mul(h,v),b=r.add(b,v),p=r.mul(y,b),l=r.add(l,p),p=r.mul(w,b),u=r.mul(m,u),u=r.sub(u,p),p=r.mul(m,y),f=r.mul(w,f),f=r.add(f,p),new C(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(C.ZERO)}multiply(e){const{endo:n}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,s;const a=e=>F.cached(this,e,(e=>(0,i.normalizeZ)(C,e)));if(n){const{k1neg:t,k1:o,k2neg:i,k2:c}=P(e),{p:u,f:l}=a(o),{p:f,f:h}=a(c);s=l.add(h),r=H(n.beta,u,f,t,i)}else{const{p:t,f:n}=a(e);r=t,s=n}return(0,i.normalizeZ)(C,[r,s])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===d||r.is0())return C.ZERO;if(e===p)return r;if(F.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:s,k2:a}=P(e),{p1:c,p2:u}=(0,i.mulEndoUnsafe)(C,r,o,a);return H(n.beta,c,u,t,s)}return F.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return L(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return c===p||(e?e(C,this):F.unsafe(this,l).is0())}clearCofactor(){const{clearCofactor:e}=t;return c===p?this:e?e(C,this):this.multiplyUnsafe(c)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}toBytes(e=!0){return(0,s._abool2)(e,"isCompressed"),this.assertValidity(),b(C,this,e)}toHex(e=!0){return(0,s.bytesToHex)(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return(0,i.normalizeZ)(C,e)}static msm(e,t){return(0,i.pippenger)(C,o,e,t)}static fromPrivateKey(e){return C.BASE.multiply(m(o,e))}}C.BASE=new C(a.Gx,a.Gy,r.ONE),C.ZERO=new C(r.ZERO,r.ONE,r.ZERO),C.Fp=r,C.Fn=o;const R=o.BITS,F=new i.wNAF(C,t.endo?Math.ceil(R/2):R);return C.BASE.precompute(8),C}function w(e){return Uint8Array.of(e?2:3)}function E(e,t){const n=e.ORDER;let r=d;for(let e=n-p;e%y===d;e/=y)r+=p;const o=r,s=y<<o-p-p,i=s*y,a=(n-p)/i,c=(a-p)/y,u=i-p,l=s,f=e.pow(t,a),h=e.pow(t,(a+p)/y);let m=(t,n)=>{let r=f,s=e.pow(n,u),i=e.sqr(s);i=e.mul(i,n);let a=e.mul(t,i);a=e.pow(a,c),a=e.mul(a,s),s=e.mul(a,n),i=e.mul(a,t);let d=e.mul(i,s);a=e.pow(d,l);let g=e.eql(a,e.ONE);s=e.mul(i,h),a=e.mul(d,r),i=e.cmov(s,i,g),d=e.cmov(a,d,g);for(let t=o;t>p;t--){let n=t-y;n=y<<n-p;let o=e.pow(d,n);const a=e.eql(o,e.ONE);s=e.mul(i,r),r=e.mul(r,r),o=e.mul(d,r),i=e.cmov(s,i,a),d=e.cmov(o,d,a)}return{isValid:g,value:i}};if(e.ORDER%v===g){const n=(e.ORDER-g)/v,r=e.sqrt(e.neg(t));m=(t,o)=>{let s=e.sqr(o);const i=e.mul(t,o);s=e.mul(s,i);let a=e.pow(s,n);a=e.mul(a,i);const c=e.mul(a,r),u=e.mul(e.sqr(a),o),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,a,l)}}}return m}function S(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function B(e,t={}){const{Fn:n}=e,r=t.randomBytes||s.randomBytes,o=Object.assign(S(e.Fp,n),{seed:(0,a.getMinHashLength)(n.ORDER)});function i(e){try{return!!m(n,e)}catch(e){return!1}}function c(e=r(o.seed)){return(0,a.mapHashToField)((0,s._abytes2)(e,o.seed,"seed"),n.ORDER)}function u(t,r=!0){return e.BASE.multiply(m(n,t)).toBytes(r)}function l(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:i,publicKeyUncompressed:a}=o;if(n.allowedLengths||r===i)return;const c=(0,s.ensureBytes)("key",t).length;return c===i||c===a}const f={isValidSecretKey:i,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:s}=o;try{const o=t.length;return!(!0===n&&o!==r||!1===n&&o!==s||!e.fromBytes(t))}catch(e){return!1}},randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:e=>m(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:u,getSharedSecret:function(t,r,o=!0){if(!0===l(t))throw new Error("first arg must be private key");if(!1===l(r))throw new Error("second arg must be public key");const s=m(n,t);return e.fromHex(r).multiply(s).toBytes(o)},keygen:function(e){const t=c(e);return{secretKey:t,publicKey:u(t)}},Point:e,utils:f,lengths:o})}function x(e,n,i={}){(0,o.ahash)(n),(0,s._validateObject)(i,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const a=i.randomBytes||s.randomBytes,c=i.hmac||((e,...t)=>(0,r.hmac)(n,e,(0,s.concatBytes)(...t))),{Fp:u,Fn:h}=e,{ORDER:g,BITS:v}=h,{keygen:b,getPublicKey:E,getSharedSecret:S,utils:x,lengths:I}=B(e,i),A={prehash:!1,lowS:"boolean"==typeof i.lowS&&i.lowS,format:void 0,extraEntropy:!1},_="compact";function O(e){return e>g>>p}function P(e,t){if(!h.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class L{constructor(e,t,n){this.r=P("r",e),this.s=P("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,n=_){let r;if(function(e,t){l(t);const n=I.signature,r="compact"===t?n:"recovered"===t?n+1:void 0;(0,s._abytes2)(e,r,`${t} signature`)}(e,n),"der"===n){const{r:n,s:r}=t.DER.toSig((0,s._abytes2)(e));return new L(n,r)}"recovered"===n&&(r=e[0],n="compact",e=e.subarray(1));const o=h.BYTES,i=e.subarray(0,o),a=e.subarray(o,2*o);return new L(h.fromBytes(i),h.fromBytes(a),r)}static fromHex(e,t){return this.fromBytes((0,s.hexToBytes)(e),t)}addRecoveryBit(e){return new L(this.r,this.s,e)}recoverPublicKey(t){const n=u.ORDER,{r,s:o,recovery:i}=this;if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");if(g*y<n&&i>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===i||3===i?r+g:r;if(!u.isValid(a))throw new Error("recovery id 2 or 3 invalid");const c=u.toBytes(a),l=e.fromBytes((0,s.concatBytes)(w(!(1&i)),c)),f=h.inv(a),d=H((0,s.ensureBytes)("msgHash",t)),p=h.create(-d*f),v=h.create(o*f),m=e.BASE.multiplyUnsafe(p).add(l.multiplyUnsafe(v));if(m.is0())throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return O(this.s)}toBytes(e=_){if(l(e),"der"===e)return(0,s.hexToBytes)(t.DER.hexFromSig(this));const n=h.toBytes(this.r),r=h.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return(0,s.concatBytes)(Uint8Array.of(this.recovery),n,r)}return(0,s.concatBytes)(n,r)}toHex(e){return(0,s.bytesToHex)(this.toBytes(e))}assertValidity(){}static fromCompact(e){return L.fromBytes((0,s.ensureBytes)("sig",e),"compact")}static fromDER(e){return L.fromBytes((0,s.ensureBytes)("sig",e),"der")}normalizeS(){return this.hasHighS()?new L(this.r,h.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return(0,s.bytesToHex)(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return(0,s.bytesToHex)(this.toBytes("compact"))}}const T=i.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,s.bytesToNumberBE)(e),n=8*e.length-v;return n>0?t>>BigInt(n):t},H=i.bits2int_modN||function(e){return h.create(T(e))},C=(0,s.bitMask)(v);function R(e){return(0,s.aInRange)("num < 2^"+v,e,d,C),h.toBytes(e)}function F(e,t){return(0,s._abytes2)(e,void 0,"message"),t?(0,s._abytes2)(n(e),void 0,"prehashed message"):e}return Object.freeze({keygen:b,getPublicKey:E,getSharedSecret:S,utils:x,lengths:I,Point:e,sign:function(t,r,o={}){t=(0,s.ensureBytes)("message",t);const{seed:i,k2sig:u}=function(t,n,r){if(["recovered","canonical"].some((e=>e in r)))throw new Error("sign() legacy options not supported");const{lowS:o,prehash:i,extraEntropy:c}=f(r,A);t=F(t,i);const u=H(t),l=m(h,n),y=[R(l),R(u)];if(null!=c&&!1!==c){const e=!0===c?a(I.secretKey):c;y.push((0,s.ensureBytes)("extraEntropy",e))}const g=(0,s.concatBytes)(...y),v=u;return{seed:g,k2sig:function(t){const n=T(t);if(!h.isValidNot0(n))return;const r=h.inv(n),s=e.BASE.multiply(n).toAffine(),i=h.create(s.x);if(i===d)return;const a=h.create(r*h.create(v+i*l));if(a===d)return;let c=(s.x===i?0:2)|Number(s.y&p),u=a;return o&&O(a)&&(u=h.neg(a),c^=1),new L(i,u,c)}}}(t,r,o);return(0,s.createHmacDrbg)(n.outputLen,h.BYTES,c)(i,u)},verify:function(n,r,o,i={}){const{lowS:a,prehash:c,format:u}=f(i,A);if(o=(0,s.ensureBytes)("publicKey",o),r=F((0,s.ensureBytes)("message",r),c),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let n;const r="string"==typeof e||(0,s.isBytes)(e),o=!r&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!r&&!o)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(o)n=new L(e.r,e.s);else if(r){try{n=L.fromBytes((0,s.ensureBytes)("sig",e),"der")}catch(e){if(!(e instanceof t.DER.Err))throw e}if(!n)try{n=L.fromBytes((0,s.ensureBytes)("sig",e),"compact")}catch(e){return!1}}return n||!1}(n):L.fromBytes((0,s.ensureBytes)("sig",n),u);if(!1===l)return!1;try{const t=e.fromBytes(o);if(a&&l.hasHighS())return!1;const{r:n,s}=l,i=H(r),c=h.inv(s),u=h.create(i*c),f=h.create(n*c),d=e.BASE.multiplyUnsafe(u).add(t.multiplyUnsafe(f));return!d.is0()&&h.create(d.x)===n}catch(e){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=f(n,A);return t=F(t,r),L.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:L,hash:n})}function I(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map((e=>Math.ceil(e/2))))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:(0,a.Field)(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function A(e,t,n){return function(r){const o=e.sqr(r),s=e.mul(o,r);return e.add(e.add(s,e.mul(r,t)),n)}}},459:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hash_to_ristretto255=t.hashToRistretto255=t.encodeToCurve=t.hashToCurve=t.RistrettoPoint=t.edwardsToMontgomery=t.ED25519_TORSION_SUBGROUP=t.ristretto255_hasher=t.ristretto255=t.ed25519_hasher=t.x25519=t.ed25519ph=t.ed25519ctx=t.ed25519=void 0,t.edwardsToMontgomeryPub=M,t.edwardsToMontgomeryPriv=function(e){return t.ed25519.utils.toMontgomerySecret((0,l.ensureBytes)("pub",e))};const r=n(7076),o=n(9175),s=n(2422),i=n(6377),a=n(1761),c=n(4967),u=n(2854),l=n(8627),f=BigInt(0),h=BigInt(1),d=BigInt(2),p=BigInt(3),y=BigInt(5),g=BigInt(8),v=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),m=(()=>({p:v,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:g,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function b(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=v,i=e*e%s*e%s,a=(0,c.pow2)(i,d,s)*i%s,u=(0,c.pow2)(a,h,s)*e%s,l=(0,c.pow2)(u,y,s)*u%s,f=(0,c.pow2)(l,t,s)*l%s,p=(0,c.pow2)(f,n,s)*f%s,g=(0,c.pow2)(p,r,s)*p%s,m=(0,c.pow2)(g,o,s)*g%s,b=(0,c.pow2)(m,o,s)*g%s,w=(0,c.pow2)(b,t,s)*l%s;return{pow_p_5_8:(0,c.pow2)(w,d,s)*e%s,b2:i}}function w(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const E=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function S(e,t){const n=v,r=(0,c.mod)(t*t*t,n),o=b(e*(0,c.mod)(r*r*t,n)).pow_p_5_8;let s=(0,c.mod)(e*r*o,n);const i=(0,c.mod)(t*s*s,n),a=s,u=(0,c.mod)(s*E,n),l=i===e,f=i===(0,c.mod)(-e,n),h=i===(0,c.mod)(-e*E,n);return l&&(s=a),(f||h)&&(s=u),(0,c.isNegativeLE)(s,n)&&(s=(0,c.mod)(-s,n)),{isValid:l||f,value:s}}const B=(()=>(0,c.Field)(m.p,{isLE:!0}))(),x=(()=>(0,c.Field)(m.n,{isLE:!0}))(),I=(()=>({...m,Fp:B,hash:r.sha512,adjustScalarBytes:w,uvRatio:S}))();function A(e,t,n){if(t.length>255)throw new Error("Context is too big");return(0,o.concatBytes)((0,o.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([n?1:0,t.length]),t,e)}t.ed25519=(0,i.twistedEdwards)(I),t.ed25519ctx=(0,i.twistedEdwards)({...I,domain:A}),t.ed25519ph=(0,i.twistedEdwards)(Object.assign({},I,{domain:A,prehash:r.sha512})),t.x25519=(()=>{const e=B.ORDER;return(0,u.montgomery)({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:n,b2:r}=b(t);return(0,c.mod)((0,c.pow2)(n,p,e)*r,e)},adjustScalarBytes:w})})();const _=(()=>(v+p)/g)(),O=(()=>B.pow(d,_))(),P=(()=>B.sqrt(B.neg(B.ONE)))(),L=(()=>(0,c.FpSqrtEven)(B,B.neg(BigInt(486664))))();t.ed25519_hasher=(0,a.createHasher)(t.ed25519.Point,(e=>function(e){const{xMn:t,xMd:n,yMn:r,yMd:o}=function(e){const t=(v-y)/g,n=BigInt(486662);let r=B.sqr(e);r=B.mul(r,d);let o=B.add(r,B.ONE),s=B.neg(n),i=B.sqr(o),a=B.mul(i,o),c=B.mul(r,n);c=B.mul(c,s),c=B.add(c,i),c=B.mul(c,s);let u=B.sqr(a);i=B.sqr(u),u=B.mul(u,a),u=B.mul(u,c),i=B.mul(i,u);let l=B.pow(i,t);l=B.mul(l,u);let f=B.mul(l,P);i=B.sqr(l),i=B.mul(i,a);let p=B.eql(i,c),m=B.cmov(f,l,p),b=B.mul(s,r),w=B.mul(l,e);w=B.mul(w,O);let E=B.mul(w,P),S=B.mul(c,r);i=B.sqr(w),i=B.mul(i,a);let x=B.eql(i,S),I=B.cmov(E,w,x);i=B.sqr(m),i=B.mul(i,a);let A=B.eql(i,c),_=B.cmov(b,s,A),L=B.cmov(I,m,A),T=B.isOdd(L);return L=B.cmov(L,B.neg(L),A!==T),{xMn:_,xMd:o,yMn:L,yMd:h}}(e);let s=B.mul(t,o);s=B.mul(s,L);let i=B.mul(n,r),a=B.sub(t,n),u=B.add(t,n),l=B.mul(i,u),f=B.eql(l,B.ZERO);s=B.cmov(s,B.ZERO,f),i=B.cmov(i,B.ONE,f),a=B.cmov(a,B.ONE,f),u=B.cmov(u,B.ONE,f);const[p,m]=(0,c.FpInvertBatch)(B,[i,u],!0);return{x:B.mul(s,p),y:B.mul(a,m)}}(e[0])),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:v,m:1,k:128,expand:"xmd",hash:r.sha512});const T=E,H=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),C=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),R=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),F=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),N=e=>S(h,e),k=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),V=e=>t.ed25519.Point.Fp.create((0,l.bytesToNumberLE)(e)&k);function U(e){const{d:n}=m,r=v,o=e=>B.create(e),s=o(T*e*e),i=o((s+h)*R);let a=BigInt(-1);const u=o((a-n*s)*o(s+n));let{isValid:l,value:f}=S(i,u),d=o(f*e);(0,c.isNegativeLE)(d,r)||(d=o(-d)),l||(f=d),l||(a=s);const p=o(a*(s-h)*F-u),y=f*f,g=o((f+f)*u),b=o(p*H),w=o(h-y),E=o(h+y);return new t.ed25519.Point(o(g*E),o(w*b),o(b*E),o(g*w))}function K(e){(0,o.abytes)(e,64);const t=U(V(e.subarray(0,32))),n=U(V(e.subarray(32,64)));return new j(t.add(n))}class j extends i.PrimeEdwardsPoint{constructor(e){super(e)}static fromAffine(e){return new j(t.ed25519.Point.fromAffine(e))}assertSame(e){if(!(e instanceof j))throw new Error("RistrettoPoint expected")}init(e){return new j(e)}static hashToCurve(e){return K((0,l.ensureBytes)("ristrettoHash",e,64))}static fromBytes(e){(0,o.abytes)(e,32);const{a:n,d:r}=m,s=v,i=e=>B.create(e),a=V(e);if(!(0,l.equalBytes)(B.toBytes(a),e)||(0,c.isNegativeLE)(a,s))throw new Error("invalid ristretto255 encoding 1");const u=i(a*a),d=i(h+n*u),p=i(h-n*u),y=i(d*d),g=i(p*p),b=i(n*r*y-g),{isValid:w,value:E}=N(i(b*g)),S=i(E*p),x=i(E*S*b);let I=i((a+a)*S);(0,c.isNegativeLE)(I,s)&&(I=i(-I));const A=i(d*x),_=i(I*A);if(!w||(0,c.isNegativeLE)(_,s)||A===f)throw new Error("invalid ristretto255 encoding 2");return new j(new t.ed25519.Point(I,A,h,_))}static fromHex(e){return j.fromBytes((0,l.ensureBytes)("ristrettoHex",e,32))}static msm(e,n){return(0,s.pippenger)(j,t.ed25519.Point.Fn,e,n)}toBytes(){let{X:e,Y:t,Z:n,T:r}=this.ep;const o=v,s=e=>B.create(e),i=s(s(n+t)*s(n-t)),a=s(e*t),u=s(a*a),{value:l}=N(s(i*u)),f=s(l*i),h=s(l*a),d=s(f*h*r);let p;if((0,c.isNegativeLE)(r*d,o)){let n=s(t*T),r=s(e*T);e=n,t=r,p=s(f*C)}else p=h;(0,c.isNegativeLE)(e*d,o)&&(t=s(-t));let y=s((n-t)*p);return(0,c.isNegativeLE)(y,o)&&(y=s(-y)),B.toBytes(y)}equals(e){this.assertSame(e);const{X:t,Y:n}=this.ep,{X:r,Y:o}=e.ep,s=e=>B.create(e),i=s(t*o)===s(n*r),a=s(n*o)===s(t*r);return i||a}is0(){return this.equals(j.ZERO)}}function M(e){return t.ed25519.utils.toMontgomery((0,l.ensureBytes)("pub",e))}j.BASE=(()=>new j(t.ed25519.Point.BASE))(),j.ZERO=(()=>new j(t.ed25519.Point.ZERO))(),j.Fp=(()=>B)(),j.Fn=(()=>x)(),t.ristretto255={Point:j},t.ristretto255_hasher={hashToCurve(e,t){const n=t?.DST||"ristretto255_XMD:SHA-512_R255MAP_RO_";return K((0,a.expand_message_xmd)(e,n,64,r.sha512))},hashToScalar(e,t={DST:a._DST_scalar}){const n=(0,a.expand_message_xmd)(e,t.DST,64,r.sha512);return x.create((0,l.bytesToNumberLE)(n))}},t.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],t.edwardsToMontgomery=M,t.RistrettoPoint=j,t.hashToCurve=t.ed25519_hasher.hashToCurve,t.encodeToCurve=t.ed25519_hasher.encodeToCurve,t.hashToRistretto255=t.ristretto255_hasher.hashToCurve,t.hash_to_ristretto255=t.ristretto255_hasher.hashToCurve},8510:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeToCurve=t.hashToCurve=t.secp256k1_hasher=t.schnorr=t.secp256k1=void 0;const r=n(7076),o=n(9175),s=n(3562),i=n(1761),a=n(4967),c=n(1705),u=n(8627),l={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},h=BigInt(0),d=BigInt(1),p=BigInt(2),y=(0,a.Field)(l.p,{sqrt:function(e){const t=l.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),u=BigInt(88),f=e*e*e%t,h=f*f*e%t,d=(0,a.pow2)(h,n,t)*h%t,g=(0,a.pow2)(d,n,t)*h%t,v=(0,a.pow2)(g,p,t)*f%t,m=(0,a.pow2)(v,o,t)*v%t,b=(0,a.pow2)(m,s,t)*m%t,w=(0,a.pow2)(b,c,t)*b%t,E=(0,a.pow2)(w,u,t)*w%t,S=(0,a.pow2)(E,c,t)*b%t,B=(0,a.pow2)(S,n,t)*h%t,x=(0,a.pow2)(B,i,t)*m%t,I=(0,a.pow2)(x,r,t)*f%t,A=(0,a.pow2)(I,p,t);if(!y.eql(y.sqr(A),e))throw new Error("Cannot find square root");return A}});t.secp256k1=(0,s.createCurve)({...l,Fp:y,lowS:!0,endo:f},r.sha256);const g={};function v(e,...t){let n=g[e];if(void 0===n){const t=(0,r.sha256)((0,u.utf8ToBytes)(e));n=(0,u.concatBytes)(t,t),g[e]=n}return(0,r.sha256)((0,u.concatBytes)(n,...t))}const m=e=>e.toBytes(!0).slice(1),b=(()=>t.secp256k1.Point)(),w=e=>e%p===h;function E(e){const{Fn:t,BASE:n}=b,r=(0,c._normFnElement)(t,e),o=n.multiply(r);return{scalar:w(o.y)?r:t.neg(r),bytes:m(o)}}function S(e){const t=y;if(!t.isValidNot0(e))throw new Error("invalid x: Fail if x ≥ p");const n=t.create(e*e),r=t.create(n*e+BigInt(7));let o=t.sqrt(r);w(o)||(o=t.neg(o));const s=b.fromAffine({x:e,y:o});return s.assertValidity(),s}const B=u.bytesToNumberBE;function x(...e){return b.Fn.create(B(v("BIP0340/challenge",...e)))}function I(e){return E(e).bytes}function A(e,t,n=(0,o.randomBytes)(32)){const{Fn:r}=b,s=(0,u.ensureBytes)("message",e),{bytes:i,scalar:a}=E(t),c=(0,u.ensureBytes)("auxRand",n,32),l=r.toBytes(a^B(v("BIP0340/aux",c))),f=v("BIP0340/nonce",l,i,s),{bytes:h,scalar:d}=E(f),p=x(h,i,s),y=new Uint8Array(64);if(y.set(h,0),y.set(r.toBytes(r.create(d+p*a)),32),!_(y,s,i))throw new Error("sign: Invalid signature produced");return y}function _(e,t,n){const{Fn:r,BASE:o}=b,s=(0,u.ensureBytes)("signature",e,64),i=(0,u.ensureBytes)("message",t),a=(0,u.ensureBytes)("publicKey",n,32);try{const e=S(B(a)),t=B(s.subarray(0,32));if(!(0,u.inRange)(t,d,l.p))return!1;const n=B(s.subarray(32,64));if(!(0,u.inRange)(n,d,l.n))return!1;const c=x(r.toBytes(t),m(e),i),f=o.multiplyUnsafe(n).add(e.multiplyUnsafe(r.neg(c))),{x:h,y:p}=f.toAffine();return!(f.is0()||!w(p)||h!==t)}catch(e){return!1}}t.schnorr=(()=>{const e=(e=(0,o.randomBytes)(48))=>(0,a.mapHashToField)(e,l.n);return t.secp256k1.utils.randomSecretKey,{keygen:function(t){const n=e(t);return{secretKey:n,publicKey:I(n)}},getPublicKey:I,sign:A,verify:_,Point:b,utils:{randomSecretKey:e,randomPrivateKey:e,taggedHash:v,lift_x:S,pointToBytes:m,numberToBytesBE:u.numberToBytesBE,bytesToNumberBE:u.bytesToNumberBE,mod:a.mod},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})();const O=(()=>(0,i.isogenyMap)(y,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))(),P=(()=>(0,c.mapToCurveSimpleSWU)(y,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:y.create(BigInt("-11"))}))();t.secp256k1_hasher=(0,i.createHasher)(t.secp256k1.Point,(e=>{const{x:t,y:n}=P(y.create(e[0]));return O(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:y.ORDER,m:1,k:128,expand:"xmd",hash:r.sha256}),t.hashToCurve=t.secp256k1_hasher.hashToCurve,t.encodeToCurve=t.secp256k1_hasher.encodeToCurve},8627:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notImplemented=t.bitMask=t.utf8ToBytes=t.randomBytes=t.isBytes=t.hexToBytes=t.concatBytes=t.bytesToUtf8=t.bytesToHex=t.anumber=t.abytes=void 0,t.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},t._abool2=function(e,t=""){if("boolean"!=typeof e)throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e);return e},t._abytes2=function(e,t,n=""){const o=(0,r.isBytes)(e),s=e?.length,i=void 0!==t;if(!o||i&&s!==t)throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(i?` of length ${t}`:"")+", got "+(o?`length=${s}`:"type="+typeof e));return e},t.numberToHexUnpadded=a,t.hexToNumber=c,t.bytesToNumberBE=function(e){return c((0,r.bytesToHex)(e))},t.bytesToNumberLE=function(e){return(0,r.abytes)(e),c((0,r.bytesToHex)(Uint8Array.from(e).reverse()))},t.numberToBytesBE=u,t.numberToBytesLE=function(e,t){return u(e,t).reverse()},t.numberToVarBytesBE=function(e){return(0,r.hexToBytes)(a(e))},t.ensureBytes=function(e,t,n){let o;if("string"==typeof t)try{o=(0,r.hexToBytes)(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!(0,r.isBytes)(t))throw new Error(e+" must be hex string or Uint8Array");o=Uint8Array.from(t)}const s=o.length;if("number"==typeof n&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return o},t.equalBytes=function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},t.copyBytes=function(e){return Uint8Array.from(e)},t.asciiToBytes=function(e){return Uint8Array.from(e,((t,n)=>{const r=t.charCodeAt(0);if(1!==t.length||r>127)throw new Error(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r}))},t.inRange=f,t.aInRange=function(e,t,n,r){if(!f(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)},t.bitLen=function(e){let t;for(t=0;e>s;e>>=i,t+=1);return t},t.bitGet=function(e,t){return e>>BigInt(t)&i},t.bitSet=function(e,t,n){return e|(n?i:s)<<BigInt(t)},t.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const o=e=>new Uint8Array(e),s=e=>Uint8Array.of(e);let i=o(e),a=o(e),c=0;const u=()=>{i.fill(1),a.fill(0),c=0},l=(...e)=>n(a,i,...e),f=(e=o(0))=>{a=l(s(0),e),i=l(),0!==e.length&&(a=l(s(1),e),i=l())},h=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=l();const t=i.slice();n.push(t),e+=i.length}return(0,r.concatBytes)(...n)};return(e,t)=>{let n;for(u(),f(e);!(n=t(h()));)f();return u(),n}},t.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const o=h[n];if("function"!=typeof o)throw new Error("invalid validator function");const s=e[t];if(!(r&&void 0===s||o(s,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+s)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},t.isHash=function(e){return"function"==typeof e&&Number.isSafeInteger(e.outputLen)},t._validateObject=function(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const o=e[t];if(r&&void 0===o)return;const s=typeof o;if(s!==n||null===o)throw new Error(`param "${t}" is invalid: expected ${n}, got ${s}`)}Object.entries(t).forEach((([e,t])=>r(e,t,!1))),Object.entries(n).forEach((([e,t])=>r(e,t,!0)))},t.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const s=e(n,...r);return t.set(n,s),s}};const r=n(9175);var o=n(9175);Object.defineProperty(t,"abytes",{enumerable:!0,get:function(){return o.abytes}}),Object.defineProperty(t,"anumber",{enumerable:!0,get:function(){return o.anumber}}),Object.defineProperty(t,"bytesToHex",{enumerable:!0,get:function(){return o.bytesToHex}}),Object.defineProperty(t,"bytesToUtf8",{enumerable:!0,get:function(){return o.bytesToUtf8}}),Object.defineProperty(t,"concatBytes",{enumerable:!0,get:function(){return o.concatBytes}}),Object.defineProperty(t,"hexToBytes",{enumerable:!0,get:function(){return o.hexToBytes}}),Object.defineProperty(t,"isBytes",{enumerable:!0,get:function(){return o.isBytes}}),Object.defineProperty(t,"randomBytes",{enumerable:!0,get:function(){return o.randomBytes}}),Object.defineProperty(t,"utf8ToBytes",{enumerable:!0,get:function(){return o.utf8ToBytes}});const s=BigInt(0),i=BigInt(1);function a(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function c(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?s:BigInt("0x"+e)}function u(e,t){return(0,r.hexToBytes)(e.toString(16).padStart(2*t,"0"))}const l=e=>"bigint"==typeof e&&s<=e;function f(e,t,n){return l(e)&&l(t)&&l(n)&&t<=e&&e<n}t.bitMask=e=>(i<<BigInt(e))-i;const h={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||(0,r.isBytes)(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};t.notImplemented=()=>{throw new Error("not implemented")}},7202:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SHA512_IV=t.SHA384_IV=t.SHA224_IV=t.SHA256_IV=t.HashMD=void 0,t.setBigUint64=o,t.Chi=function(e,t,n){return e&t^~e&n},t.Maj=function(e,t,n){return e&t^e&n^t&n};const r=n(9175);function o(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),a=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,a,r)}class s extends r.Hash{constructor(e,t,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=(0,r.createView)(this.buffer)}update(e){(0,r.aexists)(this),e=(0,r.toBytes)(e),(0,r.abytes)(e);const{view:t,buffer:n,blockLen:o}=this,s=e.length;for(let i=0;i<s;){const a=Math.min(o-this.pos,s-i);if(a!==o)n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(t,0),this.pos=0);else{const t=(0,r.createView)(e);for(;o<=s-i;i+=o)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:i}=this;let{pos:a}=this;t[a++]=128,(0,r.clean)(this.buffer.subarray(a)),this.padOffset>s-a&&(this.process(n,0),a=0);for(let e=a;e<s;e++)t[e]=0;o(n,s-8,BigInt(8*this.length),i),this.process(n,0);const c=(0,r.createView)(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)c.setUint32(4*e,f[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:i}=this;return e.destroyed=s,e.finished=o,e.length=r,e.pos=i,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}t.HashMD=s,t.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),t.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),t.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),t.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])},2318:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toBig=t.shrSL=t.shrSH=t.rotrSL=t.rotrSH=t.rotrBL=t.rotrBH=t.rotr32L=t.rotr32H=t.rotlSL=t.rotlSH=t.rotlBL=t.rotlBH=t.add5L=t.add5H=t.add4L=t.add4H=t.add3L=t.add3H=void 0,t.add=b,t.fromBig=o,t.split=s;const n=BigInt(2**32-1),r=BigInt(32);function o(e,t=!1){return t?{h:Number(e&n),l:Number(e>>r&n)}:{h:0|Number(e>>r&n),l:0|Number(e&n)}}function s(e,t=!1){const n=e.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:n,l:a}=o(e[i],t);[r[i],s[i]]=[n,a]}return[r,s]}const i=(e,t)=>BigInt(e>>>0)<<r|BigInt(t>>>0);t.toBig=i;const a=(e,t,n)=>e>>>n;t.shrSH=a;const c=(e,t,n)=>e<<32-n|t>>>n;t.shrSL=c;const u=(e,t,n)=>e>>>n|t<<32-n;t.rotrSH=u;const l=(e,t,n)=>e<<32-n|t>>>n;t.rotrSL=l;const f=(e,t,n)=>e<<64-n|t>>>n-32;t.rotrBH=f;const h=(e,t,n)=>e>>>n-32|t<<64-n;t.rotrBL=h;const d=(e,t)=>t;t.rotr32H=d;const p=(e,t)=>e;t.rotr32L=p;const y=(e,t,n)=>e<<n|t>>>32-n;t.rotlSH=y;const g=(e,t,n)=>t<<n|e>>>32-n;t.rotlSL=g;const v=(e,t,n)=>t<<n-32|e>>>64-n;t.rotlBH=v;const m=(e,t,n)=>e<<n-32|t>>>64-n;function b(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:0|o}}t.rotlBL=m;const w=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);t.add3L=w;const E=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;t.add3H=E;const S=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);t.add4L=S;const B=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0;t.add4H=B;const x=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0);t.add5L=x;const I=(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0;t.add5H=I;const A={fromBig:o,split:s,toBig:i,shrSH:a,shrSL:c,rotrSH:u,rotrSL:l,rotrBH:f,rotrBL:h,rotr32H:d,rotr32L:p,rotlSH:y,rotlSL:g,rotlBH:v,rotlBL:m,add:b,add3L:w,add3H:E,add4L:S,add4H:B,add5H:I,add5L:x};t.default=A},5145:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},4139:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hkdf=void 0,t.extract=s,t.expand=c;const r=n(9615),o=n(9175);function s(e,t,n){return(0,o.ahash)(e),void 0===n&&(n=new Uint8Array(e.outputLen)),(0,r.hmac)(e,(0,o.toBytes)(n),(0,o.toBytes)(t))}const i=Uint8Array.from([0]),a=Uint8Array.of();function c(e,t,n,s=32){(0,o.ahash)(e),(0,o.anumber)(s);const c=e.outputLen;if(s>255*c)throw new Error("Length should be <= 255*HashLen");const u=Math.ceil(s/c);void 0===n&&(n=a);const l=new Uint8Array(u*c),f=r.hmac.create(e,t),h=f._cloneInto(),d=new Uint8Array(f.outputLen);for(let e=0;e<u;e++)i[0]=e+1,h.update(0===e?a:d).update(n).update(i).digestInto(d),l.set(d,c*e),f._cloneInto(h);return f.destroy(),h.destroy(),(0,o.clean)(d,i),l.slice(0,s)}t.hkdf=(e,t,n,r,o)=>c(e,s(e,t,n),r,o)},9615:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const r=n(9175);class o extends r.Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,(0,r.ahash)(e);const n=(0,r.toBytes)(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),(0,r.clean)(s)}update(e){return(0,r.aexists)(this),this.iHash.update(e),this}digestInto(e){(0,r.aexists)(this),(0,r.abytes)(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:s,outputLen:i}=this;return e.finished=r,e.destroyed=o,e.blockLen=s,e.outputLen=i,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}t.HMAC=o,t.hmac=(e,t,n)=>new o(e,t).update(n).digest(),t.hmac.create=(e,t)=>new o(e,t)},7076:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sha512_224=t.sha512_256=t.sha384=t.sha512=t.sha224=t.sha256=t.SHA512_256=t.SHA512_224=t.SHA384=t.SHA512=t.SHA224=t.SHA256=void 0;const r=n(7202),o=n(2318),s=n(9175),i=Uint32Array.from([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]),a=new Uint32Array(64);class c extends r.HashMD{constructor(e=32){super(64,e,8,!1),this.A=0|r.SHA256_IV[0],this.B=0|r.SHA256_IV[1],this.C=0|r.SHA256_IV[2],this.D=0|r.SHA256_IV[3],this.E=0|r.SHA256_IV[4],this.F=0|r.SHA256_IV[5],this.G=0|r.SHA256_IV[6],this.H=0|r.SHA256_IV[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:i,H:a}=this;return[e,t,n,r,o,s,i,a]}set(e,t,n,r,o,s,i,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|i,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)a[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=a[e-15],n=a[e-2],r=(0,s.rotr)(t,7)^(0,s.rotr)(t,18)^t>>>3,o=(0,s.rotr)(n,17)^(0,s.rotr)(n,19)^n>>>10;a[e]=o+a[e-7]+r+a[e-16]|0}let{A:n,B:o,C:c,D:u,E:l,F:f,G:h,H:d}=this;for(let e=0;e<64;e++){const t=d+((0,s.rotr)(l,6)^(0,s.rotr)(l,11)^(0,s.rotr)(l,25))+(0,r.Chi)(l,f,h)+i[e]+a[e]|0,p=((0,s.rotr)(n,2)^(0,s.rotr)(n,13)^(0,s.rotr)(n,22))+(0,r.Maj)(n,o,c)|0;d=h,h=f,f=l,l=u+t|0,u=c,c=o,o=n,n=t+p|0}n=n+this.A|0,o=o+this.B|0,c=c+this.C|0,u=u+this.D|0,l=l+this.E|0,f=f+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(n,o,c,u,l,f,h,d)}roundClean(){(0,s.clean)(a)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,s.clean)(this.buffer)}}t.SHA256=c;class u extends c{constructor(){super(28),this.A=0|r.SHA224_IV[0],this.B=0|r.SHA224_IV[1],this.C=0|r.SHA224_IV[2],this.D=0|r.SHA224_IV[3],this.E=0|r.SHA224_IV[4],this.F=0|r.SHA224_IV[5],this.G=0|r.SHA224_IV[6],this.H=0|r.SHA224_IV[7]}}t.SHA224=u;const l=(()=>o.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),f=(()=>l[0])(),h=(()=>l[1])(),d=new Uint32Array(80),p=new Uint32Array(80);class y extends r.HashMD{constructor(e=64){super(128,e,16,!1),this.Ah=0|r.SHA512_IV[0],this.Al=0|r.SHA512_IV[1],this.Bh=0|r.SHA512_IV[2],this.Bl=0|r.SHA512_IV[3],this.Ch=0|r.SHA512_IV[4],this.Cl=0|r.SHA512_IV[5],this.Dh=0|r.SHA512_IV[6],this.Dl=0|r.SHA512_IV[7],this.Eh=0|r.SHA512_IV[8],this.El=0|r.SHA512_IV[9],this.Fh=0|r.SHA512_IV[10],this.Fl=0|r.SHA512_IV[11],this.Gh=0|r.SHA512_IV[12],this.Gl=0|r.SHA512_IV[13],this.Hh=0|r.SHA512_IV[14],this.Hl=0|r.SHA512_IV[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:r,Ch:o,Cl:s,Dh:i,Dl:a,Eh:c,El:u,Fh:l,Fl:f,Gh:h,Gl:d,Hh:p,Hl:y}=this;return[e,t,n,r,o,s,i,a,c,u,l,f,h,d,p,y]}set(e,t,n,r,o,s,i,a,c,u,l,f,h,d,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|o,this.Cl=0|s,this.Dh=0|i,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|f,this.Gh=0|h,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let n=0;n<16;n++,t+=4)d[n]=e.getUint32(t),p[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|d[e-15],n=0|p[e-15],r=o.rotrSH(t,n,1)^o.rotrSH(t,n,8)^o.shrSH(t,n,7),s=o.rotrSL(t,n,1)^o.rotrSL(t,n,8)^o.shrSL(t,n,7),i=0|d[e-2],a=0|p[e-2],c=o.rotrSH(i,a,19)^o.rotrBH(i,a,61)^o.shrSH(i,a,6),u=o.rotrSL(i,a,19)^o.rotrBL(i,a,61)^o.shrSL(i,a,6),l=o.add4L(s,u,p[e-7],p[e-16]),f=o.add4H(l,r,c,d[e-7],d[e-16]);d[e]=0|f,p[e]=0|l}let{Ah:n,Al:r,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:y,El:g,Fh:v,Fl:m,Gh:b,Gl:w,Hh:E,Hl:S}=this;for(let e=0;e<80;e++){const t=o.rotrSH(y,g,14)^o.rotrSH(y,g,18)^o.rotrBH(y,g,41),B=o.rotrSL(y,g,14)^o.rotrSL(y,g,18)^o.rotrBL(y,g,41),x=y&v^~y&b,I=g&m^~g&w,A=o.add5L(S,B,I,h[e],p[e]),_=o.add5H(A,E,t,x,f[e],d[e]),O=0|A,P=o.rotrSH(n,r,28)^o.rotrBH(n,r,34)^o.rotrBH(n,r,39),L=o.rotrSL(n,r,28)^o.rotrBL(n,r,34)^o.rotrBL(n,r,39),T=n&s^n&a^s&a,H=r&i^r&c^i&c;E=0|b,S=0|w,b=0|v,w=0|m,v=0|y,m=0|g,({h:y,l:g}=o.add(0|u,0|l,0|_,0|O)),u=0|a,l=0|c,a=0|s,c=0|i,s=0|n,i=0|r;const C=o.add3L(O,L,H);n=o.add3H(C,_,P,T),r=0|C}({h:n,l:r}=o.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:s,l:i}=o.add(0|this.Bh,0|this.Bl,0|s,0|i)),({h:a,l:c}=o.add(0|this.Ch,0|this.Cl,0|a,0|c)),({h:u,l}=o.add(0|this.Dh,0|this.Dl,0|u,0|l)),({h:y,l:g}=o.add(0|this.Eh,0|this.El,0|y,0|g)),({h:v,l:m}=o.add(0|this.Fh,0|this.Fl,0|v,0|m)),({h:b,l:w}=o.add(0|this.Gh,0|this.Gl,0|b,0|w)),({h:E,l:S}=o.add(0|this.Hh,0|this.Hl,0|E,0|S)),this.set(n,r,s,i,a,c,u,l,y,g,v,m,b,w,E,S)}roundClean(){(0,s.clean)(d,p)}destroy(){(0,s.clean)(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}t.SHA512=y;class g extends y{constructor(){super(48),this.Ah=0|r.SHA384_IV[0],this.Al=0|r.SHA384_IV[1],this.Bh=0|r.SHA384_IV[2],this.Bl=0|r.SHA384_IV[3],this.Ch=0|r.SHA384_IV[4],this.Cl=0|r.SHA384_IV[5],this.Dh=0|r.SHA384_IV[6],this.Dl=0|r.SHA384_IV[7],this.Eh=0|r.SHA384_IV[8],this.El=0|r.SHA384_IV[9],this.Fh=0|r.SHA384_IV[10],this.Fl=0|r.SHA384_IV[11],this.Gh=0|r.SHA384_IV[12],this.Gl=0|r.SHA384_IV[13],this.Hh=0|r.SHA384_IV[14],this.Hl=0|r.SHA384_IV[15]}}t.SHA384=g;const v=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),m=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class b extends y{constructor(){super(28),this.Ah=0|v[0],this.Al=0|v[1],this.Bh=0|v[2],this.Bl=0|v[3],this.Ch=0|v[4],this.Cl=0|v[5],this.Dh=0|v[6],this.Dl=0|v[7],this.Eh=0|v[8],this.El=0|v[9],this.Fh=0|v[10],this.Fl=0|v[11],this.Gh=0|v[12],this.Gl=0|v[13],this.Hh=0|v[14],this.Hl=0|v[15]}}t.SHA512_224=b;class w extends y{constructor(){super(32),this.Ah=0|m[0],this.Al=0|m[1],this.Bh=0|m[2],this.Bl=0|m[3],this.Ch=0|m[4],this.Cl=0|m[5],this.Dh=0|m[6],this.Dl=0|m[7],this.Eh=0|m[8],this.El=0|m[9],this.Fh=0|m[10],this.Fl=0|m[11],this.Gh=0|m[12],this.Gl=0|m[13],this.Hh=0|m[14],this.Hl=0|m[15]}}t.SHA512_256=w,t.sha256=(0,s.createHasher)((()=>new c)),t.sha224=(0,s.createHasher)((()=>new u)),t.sha512=(0,s.createHasher)((()=>new y)),t.sha384=(0,s.createHasher)((()=>new g)),t.sha512_256=(0,s.createHasher)((()=>new w)),t.sha512_224=(0,s.createHasher)((()=>new b))},9175:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.Hash=t.nextTick=t.swap32IfBE=t.byteSwapIfBE=t.swap8IfBE=t.isLE=void 0,t.isBytes=o,t.anumber=s,t.abytes=i,t.ahash=function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");s(e.outputLen),s(e.blockLen)},t.aexists=function(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")},t.aoutput=function(e,t){i(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)},t.u8=function(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},t.u32=function(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))},t.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)},t.createView=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)},t.rotr=function(e,t){return e<<32-t|e>>>t},t.rotl=function(e,t){return e<<t|e>>>32-t>>>0},t.byteSwap=a,t.byteSwap32=c,t.bytesToHex=function(e){if(i(e),u)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=l[e[n]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(u)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,o=0;t<n;t++,o+=2){const n=h(e.charCodeAt(o)),s=h(e.charCodeAt(o+1));if(void 0===n||void 0===s){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+s}return r},t.asyncLoop=async function(e,n,r){let o=Date.now();for(let s=0;s<e;s++){r(s);const e=Date.now()-o;e>=0&&e<n||(await(0,t.nextTick)(),o+=e)}},t.utf8ToBytes=d,t.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},t.toBytes=p,t.kdfInputToBytes=function(e){return"string"==typeof e&&(e=d(e)),i(e),e},t.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];i(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n},t.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("options should be object or undefined");return Object.assign(e,t)},t.createHasher=y,t.createOptHasher=g,t.createXOFer=v,t.randomBytes=function(e=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(e));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return Uint8Array.from(r.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")};const r=n(5145);function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function s(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function i(e,...t){if(!o(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function c(e){for(let t=0;t<e.length;t++)e[t]=a(e[t]);return e}t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.swap8IfBE=t.isLE?e=>e:e=>a(e),t.byteSwapIfBE=t.swap8IfBE,t.swap32IfBE=t.isLE?e=>e:c;const u=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),l=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0"))),f={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(e){return e>=f._0&&e<=f._9?e-f._0:e>=f.A&&e<=f.F?e-(f.A-10):e>=f.a&&e<=f.f?e-(f.a-10):void 0}function d(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function p(e){return"string"==typeof e&&(e=d(e)),i(e),e}function y(e){const t=t=>e().update(p(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function g(e){const t=(t,n)=>e(n).update(p(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function v(e){const t=(t,n)=>e(n).update(p(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}t.nextTick=async()=>{},t.Hash=class{},t.wrapConstructor=y,t.wrapConstructorWithOpts=g,t.wrapXOFConstructorWithOpts=v},4928:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ephemeralKeySize=t.symmetricNonceLength=t.symmetricAlgorithm=t.isHkdfKeyCompressed=t.isEphemeralKeyCompressed=t.ellipticCurve=t.ECIES_CONFIG=void 0;var r=n(1666);t.ECIES_CONFIG=new function(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16},t.ellipticCurve=function(){return t.ECIES_CONFIG.ellipticCurve},t.isEphemeralKeyCompressed=function(){return t.ECIES_CONFIG.isEphemeralKeyCompressed},t.isHkdfKeyCompressed=function(){return t.ECIES_CONFIG.isHkdfKeyCompressed},t.symmetricAlgorithm=function(){return t.ECIES_CONFIG.symmetricAlgorithm},t.symmetricNonceLength=function(){return t.ECIES_CONFIG.symmetricNonceLength},t.ephemeralKeySize=function(){var e={secp256k1:t.ECIES_CONFIG.isEphemeralKeyCompressed?r.COMPRESSED_PUBLIC_KEY_SIZE:r.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:r.CURVE25519_PUBLIC_KEY_SIZE,ed25519:r.CURVE25519_PUBLIC_KEY_SIZE};if(t.ECIES_CONFIG.ellipticCurve in e)return e[t.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")}},1666:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AEAD_TAG_LENGTH=t.XCHACHA20_NONCE_LENGTH=t.CURVE25519_PUBLIC_KEY_SIZE=t.ETH_PUBLIC_KEY_SIZE=t.UNCOMPRESSED_PUBLIC_KEY_SIZE=t.COMPRESSED_PUBLIC_KEY_SIZE=t.SECRET_KEY_LENGTH=void 0,t.SECRET_KEY_LENGTH=32,t.COMPRESSED_PUBLIC_KEY_SIZE=33,t.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,t.ETH_PUBLIC_KEY_SIZE=64,t.CURVE25519_PUBLIC_KEY_SIZE=32,t.XCHACHA20_NONCE_LENGTH=24,t.AEAD_TAG_LENGTH=16},6748:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.PublicKey=t.PrivateKey=t.ECIES_CONFIG=void 0,t.encrypt=function(e,t){return Buffer.from(function(e,t){var n=(0,o.ellipticCurve)(),a=new s.PrivateKey(void 0,n),c=e instanceof Uint8Array?new s.PublicKey(e,n):s.PublicKey.fromHex(e,n),u=a.encapsulate(c,(0,o.isHkdfKeyCompressed)()),l=a.publicKey.toBytes((0,o.isEphemeralKeyCompressed)()),f=(0,i.symEncrypt)(u,t);return(0,r.concatBytes)(l,f)}(e,t))},t.decrypt=function(e,t){return Buffer.from(function(e,t){var n=(0,o.ellipticCurve)(),r=e instanceof Uint8Array?new s.PrivateKey(e,n):s.PrivateKey.fromHex(e,n),a=(0,o.ephemeralKeySize)(),c=new s.PublicKey(t.subarray(0,a),n),u=t.subarray(a),l=c.decapsulate(r,(0,o.isHkdfKeyCompressed)());return(0,i.symDecrypt)(l,u)}(e,t))};var r=n(6527),o=n(4928),s=n(9065),i=n(2158),a=n(4928);Object.defineProperty(t,"ECIES_CONFIG",{enumerable:!0,get:function(){return a.ECIES_CONFIG}});var c=n(9065);Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return c.PrivateKey}}),Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return c.PublicKey}}),t.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}},5295:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PrivateKey=void 0;var r=n(6527),o=n(2158),s=n(2557),i=function(){function e(e,t){if(this.curve=t,void 0===e)this.data=(0,o.getValidSecret)(t);else{if(!(0,o.isValidPrivateKey)(e,t))throw new Error("Invalid private key");this.data=e}this.publicKey=new s.PublicKey((0,o.getPublicKey)(this.data,t),t)}return e.fromHex=function(t,n){return new e((0,o.decodeHex)(t),n)},Object.defineProperty(e.prototype,"secret",{get:function(){return Buffer.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(){return(0,r.bytesToHex)(this.data)},e.prototype.encapsulate=function(e,t){void 0===t&&(t=!1);var n=this.publicKey.toBytes(t),r=this.multiply(e,t);return(0,o.getSharedKey)(n,r)},e.prototype.multiply=function(e,t){return void 0===t&&(t=!1),(0,o.getSharedPoint)(this.data,e.toBytes(!0),t,this.curve)},e.prototype.equals=function(e){return(0,r.equalBytes)(this.data,e.data)},e}();t.PrivateKey=i},2557:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PublicKey=void 0;var r=n(6527),o=n(2158),s=function(){function e(e,t){var n=(0,o.convertPublicKeyFormat)(e,!0,t),r=(0,o.convertPublicKeyFormat)(e,!1,t);this.data=n,this.dataUncompressed=n.length!==r.length?r:null}return e.fromHex=function(t,n){return new e((0,o.hexToPublicKey)(t,n),n)},Object.defineProperty(e.prototype,"_uncompressed",{get:function(){return null!==this.dataUncompressed?this.dataUncompressed:this.data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uncompressed",{get:function(){return Buffer.from(this._uncompressed)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"compressed",{get:function(){return Buffer.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toBytes=function(e){return void 0===e&&(e=!0),e?this.data:this._uncompressed},e.prototype.toHex=function(e){return void 0===e&&(e=!0),(0,r.bytesToHex)(this.toBytes(e))},e.prototype.decapsulate=function(e,t){void 0===t&&(t=!1);var n=this.toBytes(t),r=e.multiply(this,t);return(0,o.getSharedKey)(n,r)},e.prototype.equals=function(e){return(0,r.equalBytes)(this.data,e.data)},e}();t.PublicKey=s},9065:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PublicKey=t.PrivateKey=void 0;var r=n(5295);Object.defineProperty(t,"PrivateKey",{enumerable:!0,get:function(){return r.PrivateKey}});var o=n(2557);Object.defineProperty(t,"PublicKey",{enumerable:!0,get:function(){return o.PublicKey}})},9378:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hexToPublicKey=t.convertPublicKeyFormat=t.getSharedPoint=t.getPublicKey=t.isValidPrivateKey=t.getValidSecret=void 0;var r=n(8489),o=n(459),s=n(8510),i=n(4928),a=n(1666),c=n(3503);function u(e,t,n,r){var a=e||(0,i.ellipticCurve)();if("secp256k1"===a)return t(s.secp256k1);if("x25519"===a)return n(o.x25519);if("ed25519"===a)return r(o.ed25519);throw new Error("Not implemented")}t.getValidSecret=function(e){var n;do{n=(0,r.randomBytes)(a.SECRET_KEY_LENGTH)}while(!(0,t.isValidPrivateKey)(n,e));return n},t.isValidPrivateKey=function(e,t){return u(t,(function(t){return t.utils.isValidSecretKey(e)}),(function(){return!0}),(function(){return!0}))},t.getPublicKey=function(e,t){return u(t,(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}))},t.getSharedPoint=function(e,t,n,r){return u(r,(function(r){return r.getSharedSecret(e,t,n)}),(function(n){return n.getSharedSecret(e,t)}),(function(n){return f(n,e,t)}))},t.convertPublicKeyFormat=function(e,t,n){return u(n,(function(n){return n.getSharedSecret(Uint8Array.from(Array(31).fill(0).concat([1])),e,t)}),(function(){return e}),(function(){return e}))},t.hexToPublicKey=function(e,t){var n=(0,c.decodeHex)(e);return u(t,(function(){return l(n)}),(function(){return n}),(function(){return n}))};var l=function(e){if(e.length===a.ETH_PUBLIC_KEY_SIZE){var t=new Uint8Array(1+e.length);return t.set([4]),t.set(e,1),t}return e},f=function(e,t,n){var r=e.utils.getExtendedPublicKey(t).scalar;return e.Point.fromBytes(n).multiply(r).toBytes()}},244:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSharedKey=t.deriveKey=void 0;var r=n(6527),o=n(4139),s=n(7076);t.deriveKey=function(e,t,n){return(0,o.hkdf)(s.sha256,e,t,n,32)},t.getSharedKey=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(0,t.deriveKey)(r.concatBytes.apply(void 0,e))}},3503:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decodeHex=t.remove0x=void 0;var r=n(6527);t.remove0x=function(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e},t.decodeHex=function(e){return(0,r.hexToBytes)((0,t.remove0x)(e))}},2158:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(9378),t),o(n(244),t),o(n(3503),t),o(n(7757),t)},7757:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.aesDecrypt=t.aesEncrypt=t.symDecrypt=t.symEncrypt=void 0;var r=n(7678),o=n(83),s=n(6527),i=n(8489),a=n(4928),c=n(1666);function u(e,t,n,s){var i=(0,a.symmetricAlgorithm)();if("aes-256-gcm"===i)return e(r.aes256gcm,t,n,(0,a.symmetricNonceLength)(),c.AEAD_TAG_LENGTH,s);if("xchacha20"===i)return e(o.xchacha20,t,n,c.XCHACHA20_NONCE_LENGTH,c.AEAD_TAG_LENGTH,s);if("aes-256-cbc"===i)return e(r.aes256cbc,t,n,16,0);throw new Error("Not implemented")}function l(e,t,n,r,o,a){var c=(0,i.randomBytes)(r),u=e(t,c,a).encrypt(n);if(0===o)return(0,s.concatBytes)(c,u);var l=u.length-o,f=u.subarray(0,l),h=u.subarray(l);return(0,s.concatBytes)(c,h,f)}function f(e,t,n,r,o,i){var a=n.subarray(0,r),c=e(t,Uint8Array.from(a),i),u=n.subarray(r);if(0===o)return c.decrypt(u);var l=u.subarray(0,o),f=u.subarray(o);return c.decrypt((0,s.concatBytes)(f,l))}t.symEncrypt=function(e,t,n){return u(l,e,t,n)},t.symDecrypt=function(e,t,n){return u(f,e,t,n)},t.aesEncrypt=t.symEncrypt,t.aesDecrypt=t.symDecrypt},669:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoBatcher=void 0;var r=n(3611),o=function(){function e(t){var n=this;this.events=[],this.networkCallsHandler=t,this.batchFlushAttemptTimestamp=Date.now(),r.AvoInspector.avoStorage.getItemAsync(e.cacheKey).then((function(e){if(null!==e){var t=e.filter((function(e){return null!==e}));n.events=n.events.concat(t),n.checkIfBatchNeedsToBeSent()}})).catch((function(e){console.error("Avo Inspector: error getting events from cache",e)}))}return e.prototype.handleSessionStarted=function(){this.events.push(this.networkCallsHandler.bodyForSessionStartedCall()),this.saveEvents(),this.checkIfBatchNeedsToBeSent()},e.prototype.handleTrackSchema=function(e,t,n,o,s){this.events.push(this.networkCallsHandler.bodyForEventSchemaCall(e,t,n,o,s)),this.saveEvents(),r.AvoInspector.shouldLog&&console.log("Avo Inspector: saved event "+e+" with schema "+JSON.stringify(t)),this.checkIfBatchNeedsToBeSent()},e.prototype.checkIfBatchNeedsToBeSent=function(){var e=this.events.length,t=Date.now(),n=t-this.batchFlushAttemptTimestamp,o=e%r.AvoInspector.batchSize==0,s=n>=1e3*r.AvoInspector.batchFlushSeconds,i=this;if(o||s){this.batchFlushAttemptTimestamp=t;var a=i.events;i.events=[],this.networkCallsHandler.callInspectorWithBatchBody(a,(function(e){null!=e?(i.events=i.events.concat(a),r.AvoInspector.shouldLog&&console.log("Avo Inspector: batch sending failed: "+e.message+". We will attempt to send your schemas with next batch")):r.AvoInspector.shouldLog&&console.log("Avo Inspector: batch sent successfully."),i.saveEvents()}))}},e.prototype.saveEvents=function(){if(this.events.length>1e3){var t=this.events.length-1e3;this.events.splice(0,t)}r.AvoInspector.avoStorage.setItem(e.cacheKey,this.events)},Object.defineProperty(e,"cacheKey",{get:function(){return"AvoInspectorEvents"},enumerable:!1,configurable:!0}),e}();t.AvoBatcher=o},3492:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoDeduplicator=void 0;var r=n(924),o=n(6185),s=function(){function e(){this.avoFunctionsEvents={},this.manualEvents={},this.avoFunctionsEventsParams={},this.manualEventsParams={}}return e.prototype.shouldRegisterEvent=function(e,t,n){this.clearOldEvents(),n?(this.avoFunctionsEvents[Date.now()]=e,this.avoFunctionsEventsParams[e]=t):(this.manualEvents[Date.now()]=e,this.manualEventsParams[e]=t);var r=!n;return!this.hasSameEventAs(e,t,r)},e.prototype.hasSameEventAs=function(e,t,n){var r=!1;return n?this.lookForEventIn(e,t,this.avoFunctionsEventsParams)&&(r=!0):this.lookForEventIn(e,t,this.manualEventsParams)&&(r=!0),r&&(delete this.avoFunctionsEventsParams[e],delete this.manualEventsParams[e]),r},e.prototype.lookForEventIn=function(e,t,n){for(var r in n)if(n.hasOwnProperty(r)&&r===e){var s=n[e];if(s&&(0,o.deepEquals)(t,s))return!0}return!1},e.prototype.hasSeenEventParams=function(e,t){var n=!1;return t?this.lookForEventParamsIn(e,this.avoFunctionsEventsParams)&&(n=!0):this.lookForEventParamsIn(e,this.manualEventsParams)&&(n=!0),n},e.prototype.lookForEventParamsIn=function(e,t){for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];if(r&&(0,o.deepEquals)(e,r))return!0}return!1},e.prototype.shouldRegisterSchemaFromManually=function(e,t){return this.clearOldEvents(),!this.hasSameShapeInAvoFunctionsAs(e,t)},e.prototype.hasSameShapeInAvoFunctionsAs=function(e,t){var n=!1;return this.lookForEventSchemaIn(e,t,this.avoFunctionsEventsParams)&&(n=!0),n&&delete this.avoFunctionsEventsParams[e],n},e.prototype.lookForEventSchemaIn=function(e,t,n){for(var s in n)if(n.hasOwnProperty(s)&&s===e){var i=r.AvoSchemaParser.extractSchema(n[e]);if(i&&(0,o.deepEquals)(t,i))return!0}return!1},e.prototype.clearOldEvents=function(){var e=Date.now();for(var t in this.avoFunctionsEvents)if(this.avoFunctionsEvents.hasOwnProperty(t)&&e-(Number(t)||0)>300){var n=this.avoFunctionsEvents[t];delete this.avoFunctionsEvents[t],delete this.avoFunctionsEventsParams[n]}for(var t in this.manualEvents)this.manualEvents.hasOwnProperty(t)&&e-(Number(t)||0)>300&&(n=this.manualEvents[t],delete this.manualEvents[t],delete this.manualEventsParams[n])},e.prototype._clearEvents=function(){this.avoFunctionsEvents={},this.manualEvents={},this.avoFunctionsEventsParams={},this.manualEventsParams={}},e}();t.AvoDeduplicator=s},8945:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.decryptValue=t.encryptValue=t.generateKeyPair=void 0;var r=n(6748);t.generateKeyPair=function(){var e=new r.PrivateKey,t=e.publicKey;return{privateKey:e.toHex(),publicKey:t.toHex()}},t.encryptValue=function(e,t){try{var n=void 0===e?"null":JSON.stringify(e);if(void 0===n)throw new Error("Cannot encrypt undefined value");var o="string"==typeof t?t:String(t),s=new Uint8Array(Buffer.from(n,"utf8")),i=(0,r.encrypt)(o,s);return Buffer.from(i).toString("base64")}catch(e){throw new Error("Failed to encrypt value. Please check that the public key is valid. Error: ".concat(e instanceof Error?e.message:String(e)))}},t.decryptValue=function(e,t){try{var n=new Uint8Array(Buffer.from(e,"base64")),o="string"==typeof t?t:String(t),s=(0,r.decrypt)(o,n),i=Buffer.from(s).toString("utf8");return JSON.parse(i)}catch(e){throw new Error("Failed to decrypt value. Please check that the private key is valid and matches the public key used for encryption. Error: ".concat(e instanceof Error?e.message:String(e)))}}},7249:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){}return e.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},e}();t.default=n},3611:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AvoInspector=void 0;var s=n(6844),i=n(924),a=n(669),c=n(4243),u=n(3491),l=n(3492),f=n(1499),h=n(4190),d=n(4829),p=n(5916),y=n(6185),g=n(8330).rE,v=function(){function e(t){if((0,y.isValueEmpty)(t.env)?(this.environment=s.AvoInspectorEnv.Dev,console.warn("[Avo Inspector] No environment provided. Defaulting to dev.")):Object.values(s.AvoInspectorEnv).includes(t.env)?this.environment=t.env:(this.environment=s.AvoInspectorEnv.Dev,console.warn("[Avo Inspector] Unsupported environment provided. Defaulting to dev. Supported environments - Dev, Staging, Prod.")),(0,y.isValueEmpty)(t.apiKey))throw new Error("[Avo Inspector] No API key provided. Inspector can't operate without API key.");if(this.apiKey=t.apiKey,(0,y.isValueEmpty)(t.version))throw new Error("[Avo Inspector] No version provided. Many features of Inspector rely on versioning. Please provide comparable string version, i.e. integer or semantic.");this.version=t.version,this.environment===s.AvoInspectorEnv.Dev?(e._batchSize=1,e._shouldLog=!0):(e._batchSize=30,e._batchFlushSeconds=30,e._shouldLog=!1),e.avoStorage=new u.AvoStorage(e._shouldLog,null!=t.suffix?t.suffix:""),this.avoNetworkCallsHandler=new c.AvoNetworkCallsHandler(this.apiKey,this.environment.toString(),t.appName||"",this.version,g),this.avoBatcher=new a.AvoBatcher(this.avoNetworkCallsHandler),this.avoDeduplicator=new l.AvoDeduplicator,this.publicEncryptionKey=t.publicEncryptionKey,this.streamId=d.AvoStreamId.streamId,this.streamId&&(this.eventSpecCache=new f.EventSpecCache(e._shouldLog),this.eventSpecFetcher=new h.AvoEventSpecFetcher(e._networkTimeout,e._shouldLog,this.environment),e._shouldLog&&(console.log("[Avo Inspector] Event spec fetching and validation enabled"),this.publicEncryptionKey&&console.log("[Avo Inspector] Property value encryption enabled")))}return Object.defineProperty(e,"batchSize",{get:function(){return this._batchSize},set:function(e){this._batchSize=e<1?1:e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"batchFlushSeconds",{get:function(){return this._batchFlushSeconds},enumerable:!1,configurable:!0}),Object.defineProperty(e,"shouldLog",{get:function(){return this._shouldLog},set:function(e){this._shouldLog=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"networkTimeout",{get:function(){return this._networkTimeout},set:function(e){this._networkTimeout=e},enumerable:!1,configurable:!0}),e.prototype.trackSchemaFromEvent=function(t,n){return r(this,void 0,void 0,(function(){var r,s,i,a;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.avoDeduplicator.shouldRegisterEvent(t,n,!1)?(e.shouldLog&&console.log("Avo Inspector: supplied event "+t+" with params "+JSON.stringify(n)),r=this.extractSchema(n,!1),[4,this.fetchAndValidateEvent(t,n)]):[3,2];case 1:return(s=o.sent())?(i=this.mergeValidationResults(r,s),this.sendEventWithValidation(t,i,null,null,s)):this.trackSchemaInternal(t,r,null,null),[2,r];case 2:return e.shouldLog&&console.log("Avo Inspector: Deduplicated event: "+t),[2,[]];case 3:return[3,5];case 4:return a=o.sent(),console.error("Avo Inspector: something went wrong. Please report to support@avo.app.",a),[2,[]];case 5:return[2]}}))}))},e.prototype._avoFunctionTrackSchemaFromEvent=function(t,n,s,i){return r(this,void 0,void 0,(function(){var r,a,c,u;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.avoDeduplicator.shouldRegisterEvent(t,n,!0)?(e.shouldLog&&console.log("Avo Inspector: supplied event "+t+" with params "+JSON.stringify(n)),r=this.extractSchema(n,!1),[4,this.fetchAndValidateEvent(t,n)]):[3,2];case 1:return(a=o.sent())?(c=this.mergeValidationResults(r,a),this.sendEventWithValidation(t,c,s,i,a)):this.trackSchemaInternal(t,r,s,i),[2,r];case 2:return e.shouldLog&&console.log("Avo Inspector: Deduplicated event: "+t),[2,[]];case 3:return[3,5];case 4:return u=o.sent(),console.error("Avo Inspector: something went wrong. Please report to support@avo.app.",u),[2,[]];case 5:return[2]}}))}))},e.prototype.trackSchema=function(t,n){return r(this,void 0,void 0,(function(){var r;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.avoDeduplicator.shouldRegisterSchemaFromManually(t,n)?(e.shouldLog&&console.log("Avo Inspector: supplied event "+t+" with schema "+JSON.stringify(n)),[4,this.fetchEventSpecIfNeeded(t)]):[3,2];case 1:return o.sent(),this.trackSchemaInternal(t,n,null,null),[3,3];case 2:e.shouldLog&&console.log("Avo Inspector: Deduplicated event: "+t),o.label=3;case 3:return[3,5];case 4:return r=o.sent(),console.error("Avo Inspector: something went wrong. Please report to support@avo.app.",r),[3,5];case 5:return[2]}}))}))},e.prototype.trackSchemaInternal=function(e,t,n,r){try{this.avoBatcher.handleTrackSchema(e,t,n,r)}catch(e){console.error("Avo Inspector: something went wrong. Please report to support@avo.app.",e)}},e.prototype.enableLogging=function(t){e._shouldLog=t},e.prototype.extractSchema=function(t,n){void 0===n&&(n=!0);try{return this.avoDeduplicator.hasSeenEventParams(t,!0)&&n&&e.shouldLog&&console.warn("Avo Inspector: WARNING! You are trying to extract schema shape that was just reported by your Avo Codegen. This is an indicator of duplicate inspector reporting. Please reach out to support@avo.app for advice if you are not sure how to handle this."),e.shouldLog&&console.log("Avo Inspector: extracting schema from "+JSON.stringify(t)),i.AvoSchemaParser.extractSchema(t,this.publicEncryptionKey,this.environment)}catch(e){return console.error("Avo Inspector: something went wrong in extractSchema. Please report to support@avo.app.",e),[]}},e.prototype.setBatchSize=function(t){e._batchSize=t},e.prototype.setBatchFlushSeconds=function(t){e._batchFlushSeconds=t},e.prototype.fetchEventSpecIfNeeded=function(t){return r(this,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:if(this.environment===s.AvoInspectorEnv.Prod)return[2];if(!this.eventSpecCache||!this.eventSpecFetcher||!this.streamId)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),this.eventSpecCache.get(this.apiKey,this.streamId,t)?[2]:[4,this.eventSpecFetcher.fetch({apiKey:this.apiKey,streamId:this.streamId,eventName:t})];case 2:return(n=o.sent())&&this.eventSpecCache&&this.streamId&&this.eventSpecCache.set(this.apiKey,this.streamId,t,n),[3,4];case 3:return r=o.sent(),e.shouldLog&&console.error("[Avo Inspector] Error fetching event spec for ".concat(t,":"),r),[3,4];case 4:return[2]}}))}))},e.prototype.fetchAndValidateEvent=function(t,n){return r(this,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:if(this.environment===s.AvoInspectorEnv.Prod)return[2,null];if(!this.eventSpecCache||!this.eventSpecFetcher||!this.streamId)return[2,null];o.label=1;case 1:return o.trys.push([1,4,,5]),(r=this.eventSpecCache.get(this.apiKey,this.streamId,t))?[3,3]:[4,this.eventSpecFetcher.fetch({apiKey:this.apiKey,streamId:this.streamId,eventName:t})];case 2:(r=o.sent())&&this.eventSpecCache&&this.streamId&&this.eventSpecCache.set(this.apiKey,this.streamId,t,r),o.label=3;case 3:return r?[2,(0,p.validateEvent)(n,r)]:[2,null];case 4:return i=o.sent(),e.shouldLog&&console.error("[Avo Inspector] Error validating event ".concat(t,":"),i),[2,null];case 5:return[2]}}))}))},e.prototype.mergeValidationResults=function(e,t){var n=this;return e.map((function(e){var r=t.propertyResults[e.propertyName];return n.mergePropertyValidation(e,r)}))},e.prototype.mergePropertyValidation=function(e,t){var n=this,r={propertyName:e.propertyName,propertyType:e.propertyType};return e.encryptedPropertyValue&&(r.encryptedPropertyValue=e.encryptedPropertyValue),e.children&&Array.isArray(e.children)&&(r.children=e.children.map((function(e){var r;if("string"==typeof e)return e;if(e&&"object"==typeof e&&e.propertyName){var o=null===(r=null==t?void 0:t.children)||void 0===r?void 0:r[e.propertyName];return n.mergePropertyValidation(e,o)}return e}))),t&&(t.failedEventIds&&(r.failedEventIds=t.failedEventIds),t.passedEventIds&&(r.passedEventIds=t.passedEventIds)),r},e.prototype.sendEventWithValidation=function(t,n,r,o,s){var i,a,c=this;e.shouldLog&&n.some((function(e){return e.failedEventIds&&e.failedEventIds.length>0}))&&console.log('[Avo Inspector] Validation failures for event "'.concat(t,'":'),n.filter((function(e){return e.failedEventIds&&e.failedEventIds.length>0})).map((function(e){return{property:e.propertyName,failedEventIds:e.failedEventIds}})));var u=this.avoNetworkCallsHandler.bodyForEventSchemaCall(t,n,r,o,null!==(i=s.metadata)&&void 0!==i?i:void 0,null===(a=s.metadata)||void 0===a?void 0:a.branchId);this.avoNetworkCallsHandler.callInspectorImmediately(u,(function(s){s?(e.shouldLog&&console.error('[Avo Inspector] Failed to send event "'.concat(t,'" with validation:'),s),c.avoBatcher.handleTrackSchema(t,n,r,o)):e.shouldLog&&console.log('[Avo Inspector] Event "'.concat(t,'" sent successfully with validation'))}))},e._batchSize=30,e._batchFlushSeconds=30,e._shouldLog=!1,e._networkTimeout=2e3,e}();t.AvoInspector=v},6844:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoInspectorEnv=void 0,t.AvoInspectorEnv={Prod:"prod",Dev:"dev",Staging:"staging"}},4243:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoNetworkCallsHandler=void 0;var r=n(7249),o=n(3611),s=n(4829),i=function(){function e(e,t,n,r,o){this.samplingRate=1,this.sending=!1,this.apiKey=e,this.envName=t,this.appName=n,this.appVersion=r,this.libVersion=o}return e.prototype.callInspectorWithBatchBody=function(e,t){var n=this;if(this.sending)t(new Error("Batch sending cancelled because another batch sending is in progress. Your events will be sent with next batch."));else{var r=e.filter((function(e){return null!=e}));this.fixStreamIds(r),0!==r.length&&(this.shouldDropBySampling()?o.AvoInspector.shouldLog&&console.log("Avo Inspector: last event schema dropped due to sampling rate."):(o.AvoInspector.shouldLog&&(console.log("Avo Inspector: events",r),r.forEach((function(e){"sessionStarted"===e.type?console.log("Avo Inspector: sending session started event."):"event"===e.type&&console.log("Avo Inspector: sending event "+e.eventName+" with schema "+JSON.stringify(e.eventProperties))}))),this.sending=!0,this.callInspectorApi(r,(function(e){n.sending=!1,t(e)}))))}},e.prototype.fixStreamIds=function(e){var t=null;e.forEach((function(e){null!==e.streamId&&void 0!==e.streamId&&"unknown"!==e.streamId&&(t=e.streamId)})),e.forEach((function(e){"unknown"===e.streamId&&(e.streamId=null!=t?t:s.AvoStreamId.streamId)}))},e.prototype.bodyForSessionStartedCall=function(){var e=this.createBaseCallBody();return e.type="sessionStarted",e},e.prototype.bodyForEventSchemaCall=function(e,t,n,r,o,s){var i=this.createBaseCallBody();return i.type="event",i.eventName=e,i.eventProperties=t,null!=n?(i.avoFunction=!0,i.eventId=n,i.eventHash=r):(i.avoFunction=!1,i.eventId=null,i.eventHash=null),o&&(i.eventSpecMetadata=o),s&&(i.validatedBranchId=s),i},e.prototype.createBaseCallBody=function(){return{apiKey:this.apiKey,appName:this.appName,appVersion:this.appVersion,libVersion:this.libVersion,env:this.envName,libPlatform:"web",messageId:r.default.newGuid(),trackingId:"",createdAt:(new Date).toISOString(),sessionId:"",streamId:s.AvoStreamId.streamId,samplingRate:this.samplingRate}},e.prototype.callInspectorImmediately=function(e,t){"unknown"===e.streamId&&(e.streamId=s.AvoStreamId.streamId),o.AvoInspector.shouldLog&&(console.log("Avo Inspector: calling inspector immediately (with validation)",e.eventName),console.log("Avo Inspector: event body",e)),this.callInspectorApi([e],t)},e.prototype.shouldDropBySampling=function(){return Math.random()>this.samplingRate},e.prototype.callInspectorApi=function(t,n){var r=this,s=new XMLHttpRequest;s.open("POST",e.trackingEndpoint,!0),s.setRequestHeader("Content-Type","text/plain"),s.timeout=o.AvoInspector.networkTimeout,s.send(JSON.stringify(t)),s.onload=function(){if(200!==s.status)n(new Error("Error ".concat(s.status,": ").concat(s.statusText)));else{var e=void 0;try{e=JSON.parse(s.response)}catch(e){return void n(new Error("Failed to parse response: ".concat(e instanceof Error?e.message:String(e))))}null==e||"number"!=typeof e.samplingRate||isNaN(e.samplingRate)||(r.samplingRate=e.samplingRate),n(null)}},s.onerror=function(){n(new Error("Request failed"))},s.ontimeout=function(){n(new Error("Request timed out"))}},e.trackingEndpoint="https://api.avo.app/inspector/v1/track",e}();t.AvoNetworkCallsHandler=i},924:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoSchemaParser=void 0;var r=n(8945),o=function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=function(){function e(){}return e.canSendEncryptedValues=function(e,t){return null!=e&&""!==e&&("dev"===t||"staging"===t)},e.getEncryptedPropertyValueIfEnabled=function(e,t,n){if(t&&n)try{return(0,r.encryptValue)(e,n)}catch(e){return void console.error("[Avo Inspector] Failed to encrypt property value:",e instanceof Error?e.message:String(e))}},e.extractSchema=function(e,t,n){var r=this;if(null==e)return[];var s=this.canSendEncryptedValues(t,n),i=function(e){if(o(e)){var n=e.map((function(e){return i(e)}));return r.removeDuplicates(n)}if("object"==typeof e){var a=[];for(var c in e)if(e.hasOwnProperty(c)){var u=e[c],l={propertyName:c,propertyType:r.getPropValueType(u)};if("object"==typeof u&&null!=u)l.children=i(u);else if(void 0!==u){var f=r.getEncryptedPropertyValueIfEnabled(u,s,t);void 0!==f&&(l.encryptedPropertyValue=f)}a.push(l)}return a}return r.getPropValueType(e)};return i(e)},e.removeDuplicates=function(e){var t={boolean:{},number:{},string:{}},n=[];return e.filter((function(e){var r=typeof e;return r in t&&"string"==typeof e?!t[r].hasOwnProperty(e)&&(t[r][e]=!0):!n.includes(e)&&n.push(e)}))},e.getPropValueType=function(e){var t=typeof e;return null==e?"null":"string"===t?"string":"number"===t||"bigint"===t?(e+"").includes(".")?"float":"int":"boolean"===t?"boolean":"object"===t?o(e)?"list":"object":"unknown"},e}();t.AvoSchemaParser=s},3491:function(e,t){var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AvoStorage=void 0;var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.useFallbackStorage=!1,t.fallbackStorage={},t.storageInitialized=!1,t.onStorageInitFuncs=[],t.shouldLog=!1,t.suffix="",t}return r(t,e),t.prototype.init=function(e,t){this.shouldLog=e,this.suffix=t,this.initializeStorageWeb(this.isLocalStorageAvailable())},t.prototype.initializeStorageWeb=function(e){this.storageInitialized=!0,e||(this.useFallbackStorage=!0),this.onStorageInitFuncs.forEach((function(e){e()}))},t.prototype.isLocalStorageAvailable=function(){var e=(new Date).toISOString();try{return window.localStorage.setItem(e,e),window.localStorage.getItem(e)===e&&(window.localStorage.removeItem(e),!0)}catch(e){return!1}},t.prototype.isInitialized=function(){return this.storageInitialized},t.prototype.getItemAsync=function(e){return o(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,r){t.runAfterInit((function(){if(t.useFallbackStorage){var r=t.fallbackStorage[e+t.suffix];n(t.parseJson(r))}else if("undefined"!=typeof window){r=void 0;try{r=window.localStorage.getItem(e+t.suffix)}catch(e){t.shouldLog&&console.error("Avo Inspector Storage getItemAsync error:",e),n(null)}n(t.parseJson(r))}else n(null)}))}))];case 1:return[2,n.sent()]}}))}))},t.prototype.getItem=function(e){var t;if(this.storageInitialized){if(this.useFallbackStorage)t=this.fallbackStorage[e+this.suffix];else if("undefined"!=typeof window)try{t=window.localStorage.getItem(e+this.suffix)}catch(e){this.shouldLog&&console.error("Avo Inspector Storage getItem error:",e)}}else t=null;return this.parseJson(t)},t.prototype.setItem=function(e,t){var n=this;this.runAfterInit((function(){if(n.useFallbackStorage)n.fallbackStorage[e+n.suffix]=JSON.stringify(t);else if("undefined"!=typeof window)try{window.localStorage.setItem(e+n.suffix,JSON.stringify(t))}catch(e){n.shouldLog&&console.error("Avo Inspector Storage setItem error:",e)}}))},t.prototype.removeItem=function(e){var t=this;this.runAfterInit((function(){if(t.useFallbackStorage)t.fallbackStorage[e+t.suffix]=null;else if("undefined"!=typeof window)try{window.localStorage.removeItem(e+t.suffix)}catch(e){t.shouldLog&&console.error("Avo Inspector Storage removeItem error:",e)}}))},t.prototype.runAfterInit=function(e){this.storageInitialized?e():this.onStorageInitFuncs.push(e)},t}(function(){function e(){}return e.prototype.parseJson=function(e){return null!=e?JSON.parse(e):null},e}()),a=function(){function e(e,t){void 0===t&&(t=""),this.Platform=null,this.Platform="browser",this.storageImpl=new i,this.storageImpl.init(e,t)}return e.prototype.isInitialized=function(){return this.storageImpl.isInitialized()},e.prototype.getItemAsync=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.storageImpl.getItemAsync(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getItem=function(e){return this.storageImpl.getItem(e)},e.prototype.setItem=function(e,t){this.storageImpl.setItem(e,t)},e.prototype.removeItem=function(e){this.storageImpl.removeItem(e)},e.prototype.runAfterInit=function(e){this.storageImpl.runAfterInit(e)},e}();t.AvoStorage=a},4829:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AvoStreamId=void 0;var r=n(7249),o=n(3611),s=function(){function e(){}return Object.defineProperty(e,"streamId",{get:function(){return null===e._streamId||e.shouldReset()?o.AvoInspector.avoStorage.isInitialized()?(e.loadFromStorage(),null!==e._streamId&&e.shouldReset()||null===e._streamId?e.generateAndStoreNew():(e.updateLastActivity(),e._streamId)):"unknown":(e.updateLastActivity(),e._streamId)},enumerable:!1,configurable:!0}),e.shouldReset=function(){if(null===e._createdAt||null===e._lastActivityAt)return!1;var t=Date.now(),n=t-e._createdAt,r=t-e._lastActivityAt;return n>e.MAX_AGE_MS&&r>e.IDLE_THRESHOLD_MS},e.loadFromStorage=function(){try{var t=o.AvoInspector.avoStorage.getItem(e.STREAM_ID_KEY),n=o.AvoInspector.avoStorage.getItem(e.CREATED_AT_KEY),r=o.AvoInspector.avoStorage.getItem(e.LAST_ACTIVITY_KEY);null!=t&&(e._streamId=t,e._createdAt=null!=n?n:Date.now(),e._lastActivityAt=null!=r?r:Date.now())}catch(e){console.error("Avo Inspector: Error reading stream ID from storage. Please report to support@avo.app.",e)}},e.generateAndStoreNew=function(){var t=Date.now();e._streamId=r.default.newGuid(),e._createdAt=t,e._lastActivityAt=t;try{o.AvoInspector.avoStorage.setItem(e.STREAM_ID_KEY,e._streamId),o.AvoInspector.avoStorage.setItem(e.CREATED_AT_KEY,e._createdAt),o.AvoInspector.avoStorage.setItem(e.LAST_ACTIVITY_KEY,e._lastActivityAt)}catch(e){console.error("Avo Inspector: Error saving stream ID to storage. Please report to support@avo.app.",e)}return e._streamId},e.updateLastActivity=function(){var t=Date.now();e._lastActivityAt=t;try{o.AvoInspector.avoStorage.setItem(e.LAST_ACTIVITY_KEY,t)}catch(e){}},Object.defineProperty(e,"storageKey",{get:function(){return e.STREAM_ID_KEY},enumerable:!1,configurable:!0}),Object.defineProperty(e,"createdAtKey",{get:function(){return e.CREATED_AT_KEY},enumerable:!1,configurable:!0}),Object.defineProperty(e,"lastActivityKey",{get:function(){return e.LAST_ACTIVITY_KEY},enumerable:!1,configurable:!0}),e.clearCache=function(){e._streamId=null,e._createdAt=null,e._lastActivityAt=null},e._streamId=null,e._createdAt=null,e._lastActivityAt=null,e.MAX_AGE_MS=144e5,e.IDLE_THRESHOLD_MS=72e5,e.STREAM_ID_KEY="AvoInspectorStreamId",e.CREATED_AT_KEY="AvoInspectorStreamIdCreatedAt",e.LAST_ACTIVITY_KEY="AvoInspectorStreamIdLastActivityAt",e}();t.AvoStreamId=s},1499:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventSpecCache=void 0;var n=function(){function e(e){void 0===e&&(e=!1),this.TTL_MS=3e5,this.MAX_EVENT_COUNT=50,this.globalEventCount=0,this.cache=new Map,this.shouldLog=e}return e.prototype.generateKey=function(e,t,n){return"".concat(e,":").concat(t,":").concat(n)},e.prototype.get=function(e,t,n){var r=this.generateKey(e,t,n),o=this.cache.get(r);return o?this.shouldEvict(o)?(this.shouldLog&&console.log("[EventSpecCache] Cache entry expired for key: ".concat(r)),this.cache.delete(r),null):(this.shouldLog&&console.log("[EventSpecCache] Cache hit for key: ".concat(r)),o.lastAccessed=Date.now(),o.eventCount++,this.globalEventCount++,this.globalEventCount>=this.MAX_EVENT_COUNT&&(this.evictOldest(),this.globalEventCount=0),o.spec):(this.shouldLog&&console.log("[EventSpecCache] Cache miss for key: ".concat(r)),null)},e.prototype.set=function(e,t,n,r){var o=this.generateKey(e,t,n),s=Date.now(),i={spec:r,timestamp:s,lastAccessed:s,eventCount:0};this.cache.set(o,i),this.shouldLog&&console.log("[EventSpecCache] Cached spec for key: ".concat(o))},e.prototype.shouldEvict=function(e){var t=Date.now()-e.timestamp>this.TTL_MS,n=e.eventCount>=this.MAX_EVENT_COUNT;return t||n},e.prototype.evictOldest=function(){if(0!==this.cache.size){var e=null,t=1/0;this.cache.forEach((function(n,r){n.lastAccessed<t&&(t=n.lastAccessed,e=r)})),null!==e&&(this.cache.delete(e),this.shouldLog&&console.log("[EventSpecCache] Evicted LRU entry: ".concat(e)))}},e.prototype.clear=function(){this.cache.clear(),this.globalEventCount=0,this.shouldLog&&console.log("[EventSpecCache] Cache cleared")},e.prototype.size=function(){return this.cache.size},e.prototype.getStats=function(){var e=[],t=Date.now();return this.cache.forEach((function(n,r){e.push({key:r,age:t-n.timestamp,lastAccessedAgo:t-n.lastAccessed,eventCount:n.eventCount})})),{size:this.cache.size,globalEventCount:this.globalEventCount,entries:e}},e}();t.EventSpecCache=n},4190:function(e,t){var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},o=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.AvoEventSpecFetcher=void 0;var s=function(){function e(e,t,n,r){void 0===e&&(e=2e3),void 0===t&&(t=!1),void 0===r&&(r="https://api.avo.app"),this.baseUrl=r,this.timeout=e,this.shouldLog=t,this.env=n,this.inFlightRequests=new Map}return e.prototype.generateRequestKey=function(e){return"".concat(e.streamId,":").concat(e.eventName)},e.prototype.fetch=function(e){return n(this,void 0,void 0,(function(){var t,n,o;return r(this,(function(r){switch(r.label){case 0:if(t=this.generateRequestKey(e),n=this.inFlightRequests.get(t))return this.shouldLog&&console.log("[EventSpecFetcher] Returning existing in-flight request for streamId=".concat(e.streamId,", eventName=").concat(e.eventName)),[2,n];o=this.fetchInternal(e),this.inFlightRequests.set(t,o),r.label=1;case 1:return r.trys.push([1,,3,4]),[4,o];case 2:return[2,r.sent()];case 3:return this.inFlightRequests.delete(t),[7];case 4:return[2]}}))}))},e.prototype.fetchInternal=function(t){return n(this,void 0,void 0,(function(){var n,o,s,i;return r(this,(function(r){switch(r.label){case 0:if("dev"!==this.env&&"staging"!==this.env)return[2,null];n=this.buildUrl(t),this.shouldLog&&(console.log("[EventSpecFetcher] Fetching event spec for: ".concat(t.eventName)),console.log("[EventSpecFetcher] Using base URL: ".concat(this.baseUrl))),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.makeRequest(n)];case 2:return(o=r.sent())?this.hasExpectedShape(o)?(s=e.parseEventSpecResponse(o),this.shouldLog&&console.log("[EventSpecFetcher] Successfully fetched event spec for: ".concat(t.eventName)),[2,s]):(this.shouldLog&&console.warn("[EventSpecFetcher] Invalid event spec response for: ".concat(t.eventName)),[2,null]):(this.shouldLog&&console.warn("[EventSpecFetcher] Failed to fetch event spec for: ".concat(t.eventName)),[2,null]);case 3:return i=r.sent(),this.shouldLog&&console.error("[EventSpecFetcher] Error fetching event spec for: ".concat(t.eventName),i),[2,null];case 4:return[2]}}))}))},e.prototype.buildUrl=function(e){var t=new URLSearchParams({apiKey:e.apiKey,streamId:e.streamId,eventName:e.eventName});return"".concat(this.baseUrl,"/trackingPlan/eventSpec?").concat(t.toString())},e.prototype.makeRequest=function(e){var t=this;return new Promise((function(n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.timeout=t.timeout,r.onload=function(){if(200===r.status)try{var e=JSON.parse(r.responseText);n(e)}catch(e){t.shouldLog&&console.error("[EventSpecFetcher] Failed to parse response:",e),n(null)}else t.shouldLog&&console.warn("[EventSpecFetcher] Request failed with status: ".concat(r.status)),n(null)},r.onerror=function(){t.shouldLog&&console.error("[EventSpecFetcher] Network error occurred"),n(null)},r.ontimeout=function(){t.shouldLog&&console.error("[EventSpecFetcher] Request timed out after ".concat(t.timeout,"ms")),n(null)},r.send()}))},e.prototype.hasExpectedShape=function(e){return e&&"object"==typeof e&&"string"==typeof e.branchId&&e.baseEvent&&"object"==typeof e.baseEvent&&"string"==typeof e.baseEvent.name&&"string"==typeof e.baseEvent.id&&e.baseEvent.props&&"object"==typeof e.baseEvent.props&&Array.isArray(e.variants)},e.parseEventSpecResponse=function(t){var n=t.baseEvent.id,r=t.variants.map((function(e){return e.eventId})),s=o([n],r,!0),i=e.parseAndMergeProps(t.baseEvent.props,n,t.variants,s);return{events:[{branchId:t.branchId,baseEventId:n,variantIds:r,props:i}],metadata:{schemaId:"",branchId:t.branchId,latestActionId:""}}},e.parseAndMergeProps=function(t,n,r,o){for(var s={},i=new Set(Object.keys(t)),a=0,c=r;a<c.length;a++)for(var u=c[a],l=0,f=Object.keys(u.props);l<f.length;l++){var h=f[l];i.add(h)}for(var d=function(i){var a=t[i],c=r.map((function(e){return{eventId:e.eventId,prop:e.props[i]}}));s[i]=e.mergePropertyConstraints(i,a,n,c,o)},p=0,y=Array.from(i);p<y.length;p++)d(h=y[p]);return s},e.mergePropertyConstraints=function(t,n,r,o,s){var i="unknown",a=!1,c=!1;if(n)i=e.getTypeString(n),a=n.r,c=!0===n.l;else for(var u=0,l=o;u<l.length;u++)if((g=l[u]).prop){i=e.getTypeString(g.prop),a=g.prop.r,c=!0===g.prop.l;break}var f={type:c?"list":i,required:a},h={},d={};n&&e.addConstraintsFromProp(n,r,h,d);for(var p=0,y=o;p<y.length;p++){var g;(g=y[p]).prop&&e.addConstraintsFromProp(g.prop,g.eventId,h,d)}Object.keys(h).length>0&&(f.allowedValues=h),Object.keys(d).length>0&&(f.minMaxRanges=d);var v=e.getNestedSchema(n);if(v){f.children={};for(var m=function(t,n){var i=o.map((function(n){var r;return{eventId:n.eventId,prop:n.prop?null===(r=e.getNestedSchema(n.prop))||void 0===r?void 0:r[t]:void 0}}));f.children[t]=e.mergePropertyConstraints(t,n,r,i,s)},b=0,w=Object.entries(v);b<w.length;b++){var E=w[b];m(E[0],E[1])}}return f},e.getTypeString=function(e){return"string"==typeof e.t?e.t:"object"},e.getNestedSchema=function(e){if(e)return"object"==typeof e.t&&null!==e.t?e.t:void 0},e.addConstraintsFromProp=function(e,t,n,r){var o,s;if(e.v&&Array.isArray(e.v)&&(n[i=JSON.stringify(e.v)]||(n[i]=[]),n[i].push(t)),void 0!==e.min||void 0!==e.max){var i,a=null!==(o=e.min)&&void 0!==o?o:Number.MIN_SAFE_INTEGER,c=null!==(s=e.max)&&void 0!==s?s:Number.MAX_SAFE_INTEGER;r[i="".concat(a,",").concat(c)]||(r[i]=[]),r[i].push(t)}},e}();t.AvoEventSpecFetcher=s},5916:function(e,t){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},r=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};function o(e){for(var t={},n=0,o=Object.entries(e);n<o.length;n++){var s=o[n],i=s[0],a=s[1];t[i]=r([],a,!0)}return t}function s(e){for(var t={},n=0,r=Object.entries(e);n<r.length;n++){var i=r[n],a=i[0],c=i[1];t[a]={type:c.type,required:c.required,pinnedValues:c.pinnedValues?o(c.pinnedValues):void 0,allowedValues:c.allowedValues?o(c.allowedValues):void 0,regexPatterns:c.regexPatterns?o(c.regexPatterns):void 0,minMaxRanges:c.minMaxRanges?o(c.minMaxRanges):void 0,children:c.children?s(c.children):void 0}}return t}function i(e,t){for(var n=0,r=Object.entries(t);n<r.length;n++){var c=r[n],u=c[0],l=c[1];if(e[u]){var f=e[u];a(f,l),l.children&&(f.children?i(f.children,l.children):f.children=s(l.children))}else e[u]={type:l.type,required:l.required,pinnedValues:l.pinnedValues?o(l.pinnedValues):void 0,allowedValues:l.allowedValues?o(l.allowedValues):void 0,regexPatterns:l.regexPatterns?o(l.regexPatterns):void 0,minMaxRanges:l.minMaxRanges?o(l.minMaxRanges):void 0,children:l.children?s(l.children):void 0}}}function a(e,t){if(t.pinnedValues){e.pinnedValues||(e.pinnedValues={});for(var n=0,o=Object.keys(t.pinnedValues);n<o.length;n++){var s=o[n];if(e.pinnedValues[s]){for(var i=new Set(e.pinnedValues[s]),a=0,c=t.pinnedValues[s];a<c.length;a++){var u=c[a];i.add(u)}e.pinnedValues[s]=Array.from(i)}else e.pinnedValues[s]=r([],t.pinnedValues[s],!0)}}if(t.allowedValues){e.allowedValues||(e.allowedValues={});for(var l=0,f=Object.keys(t.allowedValues);l<f.length;l++)if(s=f[l],e.allowedValues[s]){i=new Set(e.allowedValues[s]);for(var h=0,d=t.allowedValues[s];h<d.length;h++)u=d[h],i.add(u);e.allowedValues[s]=Array.from(i)}else e.allowedValues[s]=r([],t.allowedValues[s],!0)}if(t.regexPatterns){e.regexPatterns||(e.regexPatterns={});for(var p=0,y=Object.keys(t.regexPatterns);p<y.length;p++)if(s=y[p],e.regexPatterns[s]){i=new Set(e.regexPatterns[s]);for(var g=0,v=t.regexPatterns[s];g<v.length;g++)u=v[g],i.add(u);e.regexPatterns[s]=Array.from(i)}else e.regexPatterns[s]=r([],t.regexPatterns[s],!0)}if(t.minMaxRanges){e.minMaxRanges||(e.minMaxRanges={});for(var m=0,b=Object.keys(t.minMaxRanges);m<b.length;m++)if(s=b[m],e.minMaxRanges[s]){i=new Set(e.minMaxRanges[s]);for(var w=0,E=t.minMaxRanges[s];w<E.length;w++)u=E[w],i.add(u);e.minMaxRanges[s]=Array.from(i)}else e.minMaxRanges[s]=r([],t.minMaxRanges[s],!0)}}Object.defineProperty(t,"__esModule",{value:!0}),t.validateEvent=void 0;var c=new Map;function u(e){var t=c.get(e);return t||(t=new RegExp(e),c.set(e,t)),t}t.validateEvent=function(e,t){for(var r=function(e){for(var t=[],n=0,r=e;n<r.length;n++){var o=r[n];t.push(o.baseEventId);for(var s=0;s<o.variantIds.length;s++)t.push(o.variantIds[s])}return t}(t.events),o=function(e){if(0===e.length)return{};if(1===e.length)return e[0].props;for(var t={},r=0,o=e;r<o.length;r++)for(var c=o[r],u=0,l=Object.entries(c.props);u<l.length;u++){var f=l[u],h=f[0],d=f[1];if(t[h]){var p=t[h];a(p,d),d.children&&(p.children?i(p.children,d.children):p.children=s(d.children))}else t[h]={type:d.type,required:d.required,pinnedValues:d.pinnedValues?n({},d.pinnedValues):void 0,allowedValues:d.allowedValues?n({},d.allowedValues):void 0,regexPatterns:d.regexPatterns?n({},d.regexPatterns):void 0,minMaxRanges:d.minMaxRanges?n({},d.minMaxRanges):void 0,children:d.children?s(d.children):void 0}}return t}(t.events),c={},u=0,l=Object.keys(e);u<l.length;u++){var h=l[u],d=e[h],p=o[h];if(p){var y=f(d,p,r);c[h]=y}else c[h]={}}return{metadata:t.metadata,propertyResults:c}};var l=100;function f(e,t,n,r){void 0===r&&(r=0);var o={};if(r>l)return console.warn("[Avo Inspector] Max validation depth (".concat(l,") exceeded, stopping recursive validation")),o;if(t.children){for(var s={},i="object"!=typeof e||null===e||Array.isArray(e)?{}:e,a=0,c=Object.entries(t.children);a<c.length;a++){var p=c[a],y=p[0],g=p[1],v=f(i[y],g,n,r+1);(v.failedEventIds||v.passedEventIds||v.children)&&(s[y]=v)}return Object.keys(s).length>0&&(o.children=s),o}var m=new Set;t.pinnedValues&&function(e,t,n){for(var r=d(e),o=0,s=Object.entries(t);o<s.length;o++){var i=s[o],a=i[0],c=i[1];r!==a&&h(c,n)}}(e,t.pinnedValues,m),t.allowedValues&&function(e,t,n){for(var r=d(e),o=0,s=Object.entries(t);o<s.length;o++){var i=s[o],a=i[0],c=i[1];try{JSON.parse(a).includes(r)||h(c,n)}catch(e){console.warn("[Avo Inspector] Invalid allowed values JSON: ".concat(a))}}}(e,t.allowedValues,m),t.regexPatterns&&function(e,t,n){if("string"==typeof e)for(var r=0,o=Object.entries(t);r<o.length;r++){var s=o[r],i=s[0],a=s[1];try{u(i).test(e)||h(a,n)}catch(e){console.warn("[Avo Inspector] Invalid regex pattern: ".concat(i))}}else for(var c=0,l=Object.values(t);c<l.length;c++)h(a=l[c],n)}(e,t.regexPatterns,m),t.minMaxRanges&&function(e,t,n){if("number"==typeof e)if(Number.isNaN(e)){console.warn("[Avo Inspector] NaN value fails min/max constraint");for(var r=0,o=Object.values(t);r<o.length;r++)h(u=o[r],n)}else for(var s=0,i=Object.entries(t);s<i.length;s++){var a=i[s],c=a[0],u=a[1],l=c.split(","),f=l[0],d=l[1],p=parseFloat(f),y=parseFloat(d);isNaN(p)||isNaN(y)?console.warn("[Avo Inspector] Invalid min/max range: ".concat(c)):(e<p||e>y)&&h(u,n)}else for(var g=0,v=Object.values(t);g<v.length;g++)h(u=v[g],n)}(e,t.minMaxRanges,m);var b=n.filter((function(e){return!m.has(e)})),w=Array.from(m);return 0===w.length&&0===b.length?{}:b.length<w.length&&b.length>0?{passedEventIds:b}:w.length>0?{failedEventIds:w}:{}}function h(e,t){for(var n=0,r=e;n<r.length;n++){var o=r[n];t.add(o)}}function d(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e)return String(e);if(Array.isArray(e)||"object"==typeof e)try{return JSON.stringify(e)}catch(t){return console.warn("[Avo Inspector] Failed to stringify value: ".concat(t)),String(e)}return String(e)}},6185:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.deepEquals=t.isValueEmpty=void 0,t.isValueEmpty=function(e){return null==e||0==e.trim().length},t.deepEquals=function e(t,n){if(t===n)return!0;if(!(t instanceof Object&&n instanceof Object))return!1;if(t.constructor!==n.constructor)return!1;for(var r in t)if(t.hasOwnProperty(r)){if(!n.hasOwnProperty(r))return!1;if(t[r]!==n[r]){if("object"!=typeof t[r])return!1;if(!e(t[r],n[r]))return!1}}for(r in n)if(n.hasOwnProperty(r)&&!t.hasOwnProperty(r))return!1;return!0}},8330:e=>{e.exports=JSON.parse('{"rE":"2.2.2-alpha.9"}')}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.AvoInspectorEnv=e.AvoInspector=void 0;var t=n(3611);Object.defineProperty(e,"AvoInspector",{enumerable:!0,get:function(){return t.AvoInspector}});var o=n(6844);Object.defineProperty(e,"AvoInspectorEnv",{enumerable:!0,get:function(){return o.AvoInspectorEnv}})})(),r})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "avo-inspector",
3
- "version": "2.2.2-alpha.8",
3
+ "version": "2.2.2-alpha.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "browser": "dist/index.js",