vendor: 36,169 bytes, line 1
1var dd=Object.defineProperty;var pd=(t,e,s)=>e in t?dd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var G=(t,e,s)=>(pd(t,typeof e!="symbol"?e+"":e,s),s);import{t0 as fd,t1 as Ss,t2 as Vn,t3 as mt,t4 as gd,nW as Gn,ll as sn,t5 as _d,t6 as Mo,a as Fr,t7 as fs,t8 as md,t9 as Xc,ta as yd,tb as wd,tc as Zc,td as Jc,te as Qc,tf as bd,tg as Ed,th as el,b as xs,ti as Wn,tj as qr,lo as $t,tk as zr,lm as cs,ln as jr,s as Hr,E as vd,G as Id,hr as Sd,k as tl,K as xd,tl as Dd,J as gi,lh as Ve,g8 as gs,lk as Kr,_ as Od}from"./index-23810fa3.js";import{b as hn,a as kd}from"./index-1b0d714e.js";import{c as Ad,g as Lo,s as Td,d as Rd,k as Pd,a as $d}from"./index-accd8060.js";import{f as Fo}from"./browser-ponyfill-72c2a02e.js";const Nd=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),he=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),L=new Uint32Array(32);function xt(t,e,s,n,i,r){const o=i[r],a=i[r+1];let c=L[2*t],l=L[2*t+1],h=L[2*e],u=L[2*e+1],d=L[2*s],p=L[2*s+1],f=L[2*n],g=L[2*n+1],_=el(c,h,o);l=Xc(_,l,u,a),c=_|0,{Dh:g,Dl:f}={Dh:g^l,Dl:f^c},{Dh:g,Dl:f}={Dh:yd(g,f),Dl:wd(g)},{h:p,l:d}=Zc(p,d,g,f),{Bh:u,Bl:h}={Bh:u^p,Bl:h^d},{Bh:u,Bl:h}={Bh:Jc(u,h,24),Bl:Qc(u,h,24)},L[2*t]=c,L[2*t+1]=l,L[2*e]=h,L[2*e+1]=u,L[2*s]=d,L[2*s+1]=p,L[2*n]=f,L[2*n+1]=g}function Dt(t,e,s,n,i,r){const o=i[r],a=i[r+1];let c=L[2*t],l=L[2*t+1],h=L[2*e],u=L[2*e+1],d=L[2*s],p=L[2*s+1],f=L[2*n],g=L[2*n+1],_=el(c,h,o);l=Xc(_,l,u,a),c=_|0,{Dh:g,Dl:f}={Dh:g^l,Dl:f^c},{Dh:g,Dl:f}={Dh:Jc(g,f,16),Dl:Qc(g,f,16)},{h:p,l:d}=Zc(p,d,g,f),{Bh:u,Bl:h}={Bh:u^p,Bl:h^d},{Bh:u,Bl:h}={Bh:bd(u,h,63),Bl:Ed(u,h,63)},L[2*t]=c,L[2*t+1]=l,L[2*e]=h,L[2*e+1]=u,L[2*s]=d,L[2*s+1]=p,L[2*n]=f,L[2*n+1]=g}function Cd(t,e={},s,n,i){if(sn(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");const{key:r,salt:o,personalization:a}=e;if(r!==void 0&&(r.length<1||r.length>s))throw new Error("key length must be undefined or 1.."+s);if(o!==void 0&&o.length!==n)throw new Error("salt must be undefined or "+n);if(a!==void 0&&a.length!==i)throw new Error("personalization must be undefined or "+i)}class Bd extends _d{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,sn(e),sn(s),this.blockLen=e,this.outputLen=s,this.buffer=new Uint8Array(e),this.buffer32=Vn(this.buffer)}update(e){Mo(this),e=Ss(e),Fr(e);const{blockLen:s,buffer:n,buffer32:i}=this,r=e.length,o=e.byteOffset,a=e.buffer;for(let c=0;c<r;){this.pos===s&&(fs(i),this.compress(i,0,!1),fs(i),this.pos=0);const l=Math.min(s-this.pos,r-c),h=o+c;if(l===s&&!(h%4)&&c+l<r){const u=new Uint32Array(a,h,Math.floor((r-c)/4));fs(u);for(let d=0;c+s<r;d+=i.length,c+=s)this.length+=s,this.compress(u,d,!1);fs(u);continue}n.set(e.subarray(c,c+l),this.pos),this.pos+=l,this.length+=l,c+=l}return this}digestInto(e){Mo(this),md(e,this);const{pos:s,buffer32:n}=this;this.finished=!0,Gn(this.buffer.subarray(s)),fs(n),this.compress(n,0,!0),fs(n);const i=Vn(e);this.get().forEach((r,o)=>i[o]=mt(r))}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}_cloneInto(e){const{buffer:s,length:n,finished:i,destroyed:r,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(s),e.destroyed=r,e.finished=i,e.length=n,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class Ud extends Bd{constructor(e={}){const s=e.dkLen===void 0?64:e.dkLen;super(128,s),this.v0l=he[0]|0,this.v0h=he[1]|0,this.v1l=he[2]|0,this.v1h=he[3]|0,this.v2l=he[4]|0,this.v2h=he[5]|0,this.v3l=he[6]|0,this.v3h=he[7]|0,this.v4l=he[8]|0,this.v4h=he[9]|0,this.v5l=he[10]|0,this.v5h=he[11]|0,this.v6l=he[12]|0,this.v6h=he[13]|0,this.v7l=he[14]|0,this.v7h=he[15]|0,Cd(s,e,64,16,16);let{key:n,personalization:i,salt:r}=e,o=0;if(n!==void 0&&(n=Ss(n),o=n.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,r!==void 0){r=Ss(r);const a=Vn(r);this.v4l^=mt(a[0]),this.v4h^=mt(a[1]),this.v5l^=mt(a[2]),this.v5h^=mt(a[3])}if(i!==void 0){i=Ss(i);const a=Vn(i);this.v6l^=mt(a[0]),this.v6h^=mt(a[1]),this.v7l^=mt(a[2]),this.v7h^=mt(a[3])}if(n!==void 0){const a=new Uint8Array(this.blockLen);a.set(n),this.update(a)}}get(){let{v0l:e,v0h:s,v1l:n,v1h:i,v2l:r,v2h:o,v3l:a,v3h:c,v4l:l,v4h:h,v5l:u,v5h:d,v6l:p,v6h:f,v7l:g,v7h:_}=this;return[e,s,n,i,r,o,a,c,l,h,u,d,p,f,g,_]}set(e,s,n,i,r,o,a,c,l,h,u,d,p,f,g,_){this.v0l=e|0,this.v0h=s|0,this.v1l=n|0,this.v1h=i|0,this.v2l=r|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=l|0,this.v4h=h|0,this.v5l=u|0,this.v5h=d|0,this.v6l=p|0,this.v6h=f|0,this.v7l=g|0,this.v7h=_|0}compress(e,s,n){this.get().forEach((c,l)=>L[l]=c),L.set(he,16);let{h:i,l:r}=gd(BigInt(this.length));L[24]=he[8]^r,L[25]=he[9]^i,n&&(L[28]=~L[28],L[29]=~L[29]);let o=0;const a=Nd;for(let c=0;c<12;c++)xt(0,4,8,12,e,s+2*a[o++]),Dt(0,4,8,12,e,s+2*a[o++]),xt(1,5,9,13,e,s+2*a[o++]),Dt(1,5,9,13,e,s+2*a[o++]),xt(2,6,10,14,e,s+2*a[o++]),Dt(2,6,10,14,e,s+2*a[o++]),xt(3,7,11,15,e,s+2*a[o++]),Dt(3,7,11,15,e,s+2*a[o++]),xt(0,5,10,15,e,s+2*a[o++]),Dt(0,5,10,15,e,s+2*a[o++]),xt(1,6,11,12,e,s+2*a[o++]),Dt(1,6,11,12,e,s+2*a[o++]),xt(2,7,8,13,e,s+2*a[o++]),Dt(2,7,8,13,e,s+2*a[o++]),xt(3,4,9,14,e,s+2*a[o++]),Dt(3,4,9,14,e,s+2*a[o++]);this.v0l^=L[0]^L[16],this.v0h^=L[1]^L[17],this.v1l^=L[2]^L[18],this.v1h^=L[3]^L[19],this.v2l^=L[4]^L[20],this.v2h^=L[5]^L[21],this.v3l^=L[6]^L[22],this.v3h^=L[7]^L[23],this.v4l^=L[8]^L[24],this.v4h^=L[9]^L[25],this.v5l^=L[10]^L[26],this.v5h^=L[11]^L[27],this.v6l^=L[12]^L[28],this.v6h^=L[13]^L[29],this.v7l^=L[14]^L[30],this.v7h^=L[15]^L[31],Gn(L)}destroy(){this.destroyed=!0,Gn(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Md=fd(t=>new Ud(t));const Vr=BigInt(0),dr=BigInt(1);function Yn(t,e=""){if(typeof t!="boolean"){const s=e&&`"${e}"`;throw new Error(s+"expected boolean, got type="+typeof t)}return t}function Jt(t,e,s=""){const n=qr(t),i=t==null?void 0:t.length,r=e!==void 0;if(!n||r&&i!==e){const o=s&&`"${s}" `,a=r?` of length ${e}`:"",c=n?`length=${i}`:`type=${typeof t}`;throw new Error(o+"expected Uint8Array"+a+", got "+c)}return t}function yn(t){const e=t.toString(16);return e.length&1?"0"+e:e}function sl(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Vr:BigInt("0x"+t)}function _i(t){return sl(xs(t))}function Xn(t){return Fr(t),sl(xs(Uint8Array.from(t).reverse()))}function Gr(t,e){return Wn(t.toString(16).padStart(e*2,"0"))}function Wr(t,e){return Gr(t,e).reverse()}function xe(t,e,s){let n;if(typeof e=="string")try{n=Wn(e)}catch(r){throw new Error(t+" must be hex string or Uint8Array, cause: "+r)}else if(qr(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=n.length;if(typeof s=="number"&&i!==s)throw new Error(t+" of length "+s+" expected, got "+i);return n}const Ai=t=>typeof t=="bigint"&&Vr<=t;function Ld(t,e,s){return Ai(t)&&Ai(e)&&Ai(s)&&e<=t&&t<s}function pr(t,e,s,n){if(!Ld(e,s,n))throw new Error("expected valid "+t+": "+s+" <= n < "+n+", got "+e)}function nl(t){let e;for(e=0;t>Vr;t>>=dr,e+=1);return e}const un=t=>(dr<<BigInt(t))-dr;function Fd(t,e,s){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof s!="function")throw new Error("hmacFn must be a function");const n=p=>new Uint8Array(p),i=p=>Uint8Array.of(p);let r=n(t),o=n(t),a=0;const c=()=>{r.fill(1),o.fill(0),a=0},l=(...p)=>s(o,r,...p),h=(p=n(0))=>{o=l(i(0),p),r=l(),p.length!==0&&(o=l(i(1),p),r=l())},u=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let p=0;const f=[];for(;p<e;){r=l();const g=r.slice();f.push(g),p+=r.length}return $t(...f)};return(p,f)=>{c(),h(p);let g;for(;!(g=f(u()));)h();return c(),g}}function mi(t,e,s={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,r,o){const a=t[i];if(o&&a===void 0)return;const c=typeof a;if(c!==r||a===null)throw new Error(`param "${i}" is invalid: expected ${r}, got ${c}`)}Object.entries(e).forEach(([i,r])=>n(i,r,!1)),Object.entries(s).forEach(([i,r])=>n(i,r,!0))}function qo(t){const e=new WeakMap;return(s,...n)=>{const i=e.get(s);if(i!==void 0)return i;const r=t(s,...n);return e.set(s,r),r}}const $e=BigInt(0),Oe=BigInt(1),Qt=BigInt(2),il=BigInt(3),rl=BigInt(4),ol=BigInt(5),qd=BigInt(7),al=BigInt(8),zd=BigInt(9),cl=BigInt(16);function Ue(t,e){const s=t%e;return s>=$e?s:e+s}function Xe(t,e,s){let n=t;for(;e-- >$e;)n*=n,n%=s;return n}function zo(t,e){if(t===$e)throw new Error("invert: expected non-zero number");if(e<=$e)throw new Error("invert: expected positive modulus, got "+e);let s=Ue(t,e),n=e,i=$e,r=Oe;for(;s!==$e;){const a=n/s,c=n%s,l=i-r*a;n=s,s=c,i=r,r=l}if(n!==Oe)throw new Error("invert: does not exist");return Ue(i,e)}function Yr(t,e,s){if(!t.eql(t.sqr(e),s))throw new Error("Cannot find square root")}function ll(t,e){const s=(t.ORDER+Oe)/rl,n=t.pow(e,s);return Yr(t,n,e),n}function jd(t,e){const s=(t.ORDER-ol)/al,n=t.mul(e,Qt),i=t.pow(n,s),r=t.mul(e,i),o=t.mul(t.mul(r,Qt),i),a=t.mul(r,t.sub(o,t.ONE));return Yr(t,a,e),a}function Hd(t){const e=zt(t),s=hl(t),n=s(e,e.neg(e.ONE)),i=s(e,n),r=s(e,e.neg(n)),o=(t+qd)/cl;return(a,c)=>{let l=a.pow(c,o),h=a.mul(l,n);const u=a.mul(l,i),d=a.mul(l,r),p=a.eql(a.sqr(h),c),f=a.eql(a.sqr(u),c);l=a.cmov(l,h,p),h=a.cmov(d,u,f);const g=a.eql(a.sqr(h),c),_=a.cmov(l,h,g);return Yr(a,_,c),_}}function hl(t){if(t<il)throw new Error("sqrt is not defined for small field");let e=t-Oe,s=0;for(;e%Qt===$e;)e/=Qt,s++;let n=Qt;const i=zt(t);for(;jo(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(s===1)return ll;let r=i.pow(n,e);const o=(e+Oe)/Qt;return function(c,l){if(c.is0(l))return l;if(jo(c,l)!==1)throw new Error("Cannot find square root");let h=s,u=c.mul(c.ONE,r),d=c.pow(l,e),p=c.pow(l,o);for(;!c.eql(d,c.ONE);){if(c.is0(d))return c.ZERO;let f=1,g=c.sqr(d);for(;!c.eql(g,c.ONE);)if(f++,g=c.sqr(g),f===h)throw new Error("Cannot find square root");const _=Oe<<BigInt(h-f-1),v=c.pow(u,_);h=f,u=c.sqr(v),d=c.mul(d,u),p=c.mul(p,v)}return p}}function Kd(t){return t%rl===il?ll:t%al===ol?jd:t%cl===zd?Hd(t):hl(t)}const Vd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Gd(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},s=Vd.reduce((n,i)=>(n[i]="function",n),e);return mi(t,s),t}function Wd(t,e,s){if(s<$e)throw new Error("invalid exponent, negatives unsupported");if(s===$e)return t.ONE;if(s===Oe)return e;let n=t.ONE,i=e;for(;s>$e;)s&Oe&&(n=t.mul(n,i)),i=t.sqr(i),s>>=Oe;return n}function ul(t,e,s=!1){const n=new Array(e.length).fill(s?t.ZERO:void 0),i=e.reduce((o,a,c)=>t.is0(a)?o:(n[c]=o,t.mul(o,a)),t.ONE),r=t.inv(i);return e.reduceRight((o,a,c)=>t.is0(a)?o:(n[c]=t.mul(o,n[c]),t.mul(o,a)),r),n}function jo(t,e){const s=(t.ORDER-Oe)/Qt,n=t.pow(e,s),i=t.eql(n,t.ONE),r=t.eql(n,t.ZERO),o=t.eql(n,t.neg(t.ONE));if(!i&&!r&&!o)throw new Error("invalid Legendre symbol result");return i?1:r?0:-1}function dl(t,e){e!==void 0&&sn(e);const s=e!==void 0?e:t.toString(2).length,n=Math.ceil(s/8);return{nBitLength:s,nByteLength:n}}function zt(t,e,s=!1,n={}){if(t<=$e)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,r,o=!1,a;if(typeof e=="object"&&e!=null){if(n.sqrt||s)throw new Error("cannot specify opts in two arguments");const d=e;d.BITS&&(i=d.BITS),d.sqrt&&(r=d.sqrt),typeof d.isLE=="boolean"&&(s=d.isLE),typeof d.modFromBytes=="boolean"&&(o=d.modFromBytes),a=d.allowedLengths}else typeof e=="number"&&(i=e),n.sqrt&&(r=n.sqrt);const{nBitLength:c,nByteLength:l}=dl(t,i);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let h;const u=Object.freeze({ORDER:t,isLE:s,BITS:c,BYTES:l,MASK:un(c),ZERO:$e,ONE:Oe,allowedLengths:a,create:d=>Ue(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return $e<=d&&d<t},is0:d=>d===$e,isValidNot0:d=>!u.is0(d)&&u.isValid(d),isOdd:d=>(d&Oe)===Oe,neg:d=>Ue(-d,t),eql:(d,p)=>d===p,sqr:d=>Ue(d*d,t),add:(d,p)=>Ue(d+p,t),sub:(d,p)=>Ue(d-p,t),mul:(d,p)=>Ue(d*p,t),pow:(d,p)=>Wd(u,d,p),div:(d,p)=>Ue(d*zo(p,t),t),sqrN:d=>d*d,addN:(d,p)=>d+p,subN:(d,p)=>d-p,mulN:(d,p)=>d*p,inv:d=>zo(d,t),sqrt:r||(d=>(h||(h=Kd(t)),h(u,d))),toBytes:d=>s?Wr(d,l):Gr(d,l),fromBytes:(d,p=!0)=>{if(a){if(!a.includes(d.length)||d.length>l)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);const g=new Uint8Array(l);g.set(d,s?0:g.length-d.length),d=g}if(d.length!==l)throw new Error("Field.fromBytes: expected "+l+" bytes, got "+d.length);let f=s?Xn(d):_i(d);if(o&&(f=Ue(f,t)),!p&&!u.isValid(f))throw new Error("invalid field element: outside of range 0..ORDER");return f},invertBatch:d=>ul(u,d),cmov:(d,p,f)=>f?p:d});return Object.freeze(u)}function pl(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function fl(t){const e=pl(t);return e+Math.ceil(e/2)}function Yd(t,e,s=!1){const n=t.length,i=pl(e),r=fl(e);if(n<16||n<r||n>1024)throw new Error("expected "+r+"-1024 bytes of input, got "+n);const o=s?Xn(t):_i(t),a=Ue(o,e-Oe)+Oe;return s?Wr(a,i):Gr(a,i)}const Rs=BigInt(0),es=BigInt(1);function Zn(t,e){const s=e.negate();return t?s:e}function Ti(t,e){const s=ul(t.Fp,e.map(n=>n.Z));return e.map((n,i)=>t.fromAffine(n.toAffine(s[i])))}function gl(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ri(t,e){gl(t,e);const s=Math.ceil(e/t)+1,n=2**(t-1),i=2**t,r=un(t),o=BigInt(t);return{windows:s,windowSize:n,mask:r,maxNumber:i,shiftBy:o}}function Ho(t,e,s){const{windowSize:n,mask:i,maxNumber:r,shiftBy:o}=s;let a=Number(t&i),c=t>>o;a>n&&(a-=r,c+=es);const l=e*n,h=l+Math.abs(a)-1,u=a===0,d=a<0,p=e%2!==0;return{nextN:c,offset:h,isZero:u,isNeg:d,isNegF:p,offsetF:l}}function Xd(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((s,n)=>{if(!(s instanceof e))throw new Error("invalid point at index "+n)})}function Zd(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((s,n)=>{if(!e.isValid(s))throw new Error("invalid scalar at index "+n)})}const Pi=new WeakMap,_l=new WeakMap;function $i(t){return _l.get(t)||1}function Ko(t){if(t!==Rs)throw new Error("invalid wNAF")}class Jd{constructor(e,s){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=s}_unsafeLadder(e,s,n=this.ZERO){let i=e;for(;s>Rs;)s&es&&(n=n.add(i)),i=i.double(),s>>=es;return n}precomputeWindow(e,s){const{windows:n,windowSize:i}=Ri(s,this.bits),r=[];let o=e,a=o;for(let c=0;c<n;c++){a=o,r.push(a);for(let l=1;l<i;l++)a=a.add(o),r.push(a);o=a.double()}return r}wNAF(e,s,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,r=this.BASE;const o=Ri(e,this.bits);for(let a=0;a<o.windows;a++){const{nextN:c,offset:l,isZero:h,isNeg:u,isNegF:d,offsetF:p}=Ho(n,a,o);n=c,h?r=r.add(Zn(d,s[p])):i=i.add(Zn(u,s[l]))}return Ko(n),{p:i,f:r}}wNAFUnsafe(e,s,n,i=this.ZERO){const r=Ri(e,this.bits);for(let o=0;o<r.windows&&n!==Rs;o++){const{nextN:a,offset:c,isZero:l,isNeg:h}=Ho(n,o,r);if(n=a,!l){const u=s[c];i=i.add(h?u.negate():u)}}return Ko(n),i}getPrecomputes(e,s,n){let i=Pi.get(s);return i||(i=this.precomputeWindow(s,e),e!==1&&(typeof n=="function"&&(i=n(i)),Pi.set(s,i))),i}cached(e,s,n){const i=$i(e);return this.wNAF(i,this.getPrecomputes(i,e,n),s)}unsafe(e,s,n,i){const r=$i(e);return r===1?this._unsafeLadder(e,s,i):this.wNAFUnsafe(r,this.getPrecomputes(r,e,n),s,i)}createCache(e,s){gl(s,this.bits),_l.set(e,s),Pi.delete(e)}hasCache(e){return $i(e)!==1}}function Qd(t,e,s,n){let i=e,r=t.ZERO,o=t.ZERO;for(;s>Rs||n>Rs;)s&es&&(r=r.add(i)),n&es&&(o=o.add(i)),i=i.double(),s>>=es,n>>=es;return{p1:r,p2:o}}function ep(t,e,s,n){Xd(s,t),Zd(n,e);const i=s.length,r=n.length;if(i!==r)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=nl(BigInt(i));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=un(c),h=new Array(Number(l)+1).fill(o),u=Math.floor((e.BITS-1)/c)*c;let d=o;for(let p=u;p>=0;p-=c){h.fill(o);for(let g=0;g<r;g++){const _=n[g],v=Number(_>>BigInt(p)&l);h[v]=h[v].add(s[g])}let f=o;for(let g=h.length-1,_=o;g>0;g--)_=_.add(h[g]),f=f.add(_);if(d=d.add(f),p!==0)for(let g=0;g<c;g++)d=d.double()}return d}function Vo(t,e,s){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Gd(e),e}else return zt(t,{isLE:s})}function tp(t,e,s={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const c of["p","n","h"]){const l=e[c];if(!(typeof l=="bigint"&&l>Rs))throw new Error(`CURVE.${c} must be positive bigint`)}const i=Vo(e.p,s.Fp,n),r=Vo(e.n,s.Fn,n),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(const c of a)if(!i.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:i,Fn:r}}const Go=(t,e)=>(t+(t>=0?e:-e)/ml)/e;function sp(t,e,s){const[[n,i],[r,o]]=e,a=Go(o*t,s),c=Go(-i*t,s);let l=t-a*n-c*r,h=-a*i-c*o;const u=l<Et,d=h<Et;u&&(l=-l),d&&(h=-h);const p=un(Math.ceil(nl(s)/2))+Ds;if(l<Et||l>=p||h<Et||h>=p)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:u,k1:l,k2neg:d,k2:h}}function fr(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Ni(t,e){const s={};for(let n of Object.keys(e))s[n]=t[n]===void 0?e[n]:t[n];return Yn(s.lowS,"lowS"),Yn(s.prehash,"prehash"),s.format!==void 0&&fr(s.format),s}class np extends Error{constructor(e=""){super(e)}}const bt={Err:np,_tlv:{encode:(t,e)=>{const{Err:s}=bt;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length&1)throw new s("tlv.encode: unpadded data");const n=e.length/2,i=yn(n);if(i.length/2&128)throw new s("tlv.encode: long form length too big");const r=n>127?yn(i.length/2|128):"";return yn(t)+r+i+e},decode(t,e){const{Err:s}=bt;let n=0;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new s("tlv.decode: wrong tlv");const i=e[n++],r=!!(i&128);let o=0;if(!r)o=i;else{const c=i&127;if(!c)throw new s("tlv.decode(long): indefinite length not supported");if(c>4)throw new s("tlv.decode(long): byte length is too big");const l=e.subarray(n,n+c);if(l.length!==c)throw new s("tlv.decode: length bytes not complete");if(l[0]===0)throw new s("tlv.decode(long): zero leftmost byte");for(const h of l)o=o<<8|h;if(n+=c,o<128)throw new s("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new s("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){const{Err:e}=bt;if(t<Et)throw new e("integer: negative integers are not allowed");let s=yn(t);if(Number.parseInt(s[0],16)&8&&(s="00"+s),s.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return s},decode(t){const{Err:e}=bt;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return _i(t)}},toSig(t){const{Err:e,_int:s,_tlv:n}=bt,i=xe("signature",t),{v:r,l:o}=n.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=n.decode(2,r),{v:l,l:h}=n.decode(2,c);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:s.decode(a),s:s.decode(l)}},hexFromSig(t){const{_tlv:e,_int:s}=bt,n=e.encode(2,s.encode(t.r)),i=e.encode(2,s.encode(t.s)),r=n+i;return e.encode(48,r)}},Et=BigInt(0),Ds=BigInt(1),ml=BigInt(2),wn=BigInt(3),ip=BigInt(4);function bs(t,e){const{BYTES:s}=t;let n;if(typeof e=="bigint")n=e;else{let i=xe("private key",e);try{n=t.fromBytes(i)}catch{throw new Error(`invalid private key: expected ui8a of size ${s}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function rp(t,e={}){const s=tp("weierstrass",t,e),{Fp:n,Fn:i}=s;let r=s.CURVE;const{h:o,n:a}=r;mi(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=e;if(c&&(!n.is0(r.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=wl(n,i);function h(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u(B,b,E){const{x:m,y}=b.toAffine(),I=n.toBytes(m);if(Yn(E,"isCompressed"),E){h();const D=!n.isOdd(y);return $t(yl(D),I)}else return $t(Uint8Array.of(4),I,n.toBytes(y))}function d(B){Jt(B,void 0,"Point");const{publicKey:b,publicKeyUncompressed:E}=l,m=B.length,y=B[0],I=B.subarray(1);if(m===b&&(y===2||y===3)){const D=n.fromBytes(I);if(!n.isValid(D))throw new Error("bad point: is not on curve, wrong x");const w=g(D);let x;try{x=n.sqrt(w)}catch(j){const z=j instanceof Error?": "+j.message:"";throw new Error("bad point: is not on curve, sqrt error"+z)}h();const O=n.isOdd(x);return(y&1)===1!==O&&(x=n.neg(x)),{x:D,y:x}}else if(m===E&&y===4){const D=n.BYTES,w=n.fromBytes(I.subarray(0,D)),x=n.fromBytes(I.subarray(D,D*2));if(!_(w,x))throw new Error("bad point: is not on curve");return{x:w,y:x}}else throw new Error(`bad point: got length ${m}, expected compressed=${b} or uncompressed=${E}`)}const p=e.toBytes||u,f=e.fromBytes||d;function g(B){const b=n.sqr(B),E=n.mul(b,B);return n.add(n.add(E,n.mul(B,r.a)),r.b)}function _(B,b){const E=n.sqr(b),m=g(B);return n.eql(E,m)}if(!_(r.Gx,r.Gy))throw new Error("bad curve params: generator point");const v=n.mul(n.pow(r.a,wn),ip),A=n.mul(n.sqr(r.b),BigInt(27));if(n.is0(n.add(v,A)))throw new Error("bad curve params: a or b");function S(B,b,E=!1){if(!n.isValid(b)||E&&n.is0(b))throw new Error(`bad point coordinate ${B}`);return b}function C(B){if(!(B instanceof k))throw new Error("ProjectivePoint expected")}function F(B){if(!c||!c.basises)throw new Error("no endo");return sp(B,c.basises,i.ORDER)}const $=qo((B,b)=>{const{X:E,Y:m,Z:y}=B;if(n.eql(y,n.ONE))return{x:E,y:m};const I=B.is0();b==null&&(b=I?n.ONE:n.inv(y));const D=n.mul(E,b),w=n.mul(m,b),x=n.mul(y,b);if(I)return{x:n.ZERO,y:n.ZERO};if(!n.eql(x,n.ONE))throw new Error("invZ was invalid");return{x:D,y:w}}),U=qo(B=>{if(B.is0()){if(e.allowInfinityPoint&&!n.is0(B.Y))return;throw new Error("bad point: ZERO")}const{x:b,y:E}=B.toAffine();if(!n.isValid(b)||!n.isValid(E))throw new Error("bad point: x or y not field elements");if(!_(b,E))throw new Error("bad point: equation left != right");if(!B.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function N(B,b,E,m,y){return E=new k(n.mul(E.X,B),E.Y,E.Z),b=Zn(m,b),E=Zn(y,E),b.add(E)}class k{constructor(b,E,m){this.X=S("x",b),this.Y=S("y",E,!0),this.Z=S("z",m),Object.freeze(this)}static CURVE(){return r}static fromAffine(b){const{x:E,y:m}=b||{};if(!b||!n.isValid(E)||!n.isValid(m))throw new Error("invalid affine point");if(b instanceof k)throw new Error("projective point not allowed");return n.is0(E)&&n.is0(m)?k.ZERO:new k(E,m,n.ONE)}static fromBytes(b){const E=k.fromAffine(f(Jt(b,void 0,"point")));return E.assertValidity(),E}static fromHex(b){return k.fromBytes(xe("pointHex",b))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(b=8,E=!0){return H.createCache(this,b),E||this.multiply(wn),this}assertValidity(){U(this)}hasEvenY(){const{y:b}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(b)}equals(b){C(b);const{X:E,Y:m,Z:y}=this,{X:I,Y:D,Z:w}=b,x=n.eql(n.mul(E,w),n.mul(I,y)),O=n.eql(n.mul(m,w),n.mul(D,y));return x&&O}negate(){return new k(this.X,n.neg(this.Y),this.Z)}double(){const{a:b,b:E}=r,m=n.mul(E,wn),{X:y,Y:I,Z:D}=this;let w=n.ZERO,x=n.ZERO,O=n.ZERO,T=n.mul(y,y),j=n.mul(I,I),z=n.mul(D,D),q=n.mul(y,I);return q=n.add(q,q),O=n.mul(y,D),O=n.add(O,O),w=n.mul(b,O),x=n.mul(m,z),x=n.add(w,x),w=n.sub(j,x),x=n.add(j,x),x=n.mul(w,x),w=n.mul(q,w),O=n.mul(m,O),z=n.mul(b,z),q=n.sub(T,z),q=n.mul(b,q),q=n.add(q,O),O=n.add(T,T),T=n.add(O,T),T=n.add(T,z),T=n.mul(T,q),x=n.add(x,T),z=n.mul(I,D),z=n.add(z,z),T=n.mul(z,q),w=n.sub(w,T),O=n.mul(z,j),O=n.add(O,O),O=n.add(O,O),new k(w,x,O)}add(b){C(b);const{X:E,Y:m,Z:y}=this,{X:I,Y:D,Z:w}=b;let x=n.ZERO,O=n.ZERO,T=n.ZERO;const j=r.a,z=n.mul(r.b,wn);let q=n.mul(E,I),K=n.mul(m,D),W=n.mul(y,w),Z=n.add(E,m),V=n.add(I,D);Z=n.mul(Z,V),V=n.add(q,K),Z=n.sub(Z,V),V=n.add(E,y);let ee=n.add(I,w);return V=n.mul(V,ee),ee=n.add(q,W),V=n.sub(V,ee),ee=n.add(m,y),x=n.add(D,w),ee=n.mul(ee,x),x=n.add(K,W),ee=n.sub(ee,x),T=n.mul(j,V),x=n.mul(z,W),T=n.add(x,T),x=n.sub(K,T),T=n.add(K,T),O=n.mul(x,T),K=n.add(q,q),K=n.add(K,q),W=n.mul(j,W),V=n.mul(z,V),K=n.add(K,W),W=n.sub(q,W),W=n.mul(j,W),V=n.add(V,W),q=n.mul(K,V),O=n.add(O,q),q=n.mul(ee,V),x=n.mul(Z,x),x=n.sub(x,q),q=n.mul(Z,K),T=n.mul(ee,T),T=n.add(T,q),new k(x,O,T)}subtract(b){return this.add(b.negate())}is0(){return this.equals(k.ZERO)}multiply(b){const{endo:E}=e;if(!i.isValidNot0(b))throw new Error("invalid scalar: out of range");let m,y;const I=D=>H.cached(this,D,w=>Ti(k,w));if(E){const{k1neg:D,k1:w,k2neg:x,k2:O}=F(b),{p:T,f:j}=I(w),{p:z,f:q}=I(O);y=j.add(q),m=N(E.beta,T,z,D,x)}else{const{p:D,f:w}=I(b);m=D,y=w}return Ti(k,[m,y])[0]}multiplyUnsafe(b){const{endo:E}=e,m=this;if(!i.isValid(b))throw new Error("invalid scalar: out of range");if(b===Et||m.is0())return k.ZERO;if(b===Ds)return m;if(H.hasCache(this))return this.multiply(b);if(E){const{k1neg:y,k1:I,k2neg:D,k2:w}=F(b),{p1:x,p2:O}=Qd(k,m,I,w);return N(E.beta,x,O,y,D)}else return H.unsafe(m,b)}multiplyAndAddUnsafe(b,E,m){const y=this.multiplyUnsafe(E).add(b.multiplyUnsafe(m));return y.is0()?void 0:y}toAffine(b){return $(this,b)}isTorsionFree(){const{isTorsionFree:b}=e;return o===Ds?!0:b?b(k,this):H.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:b}=e;return o===Ds?this:b?b(k,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(b=!0){return Yn(b,"isCompressed"),this.assertValidity(),p(k,this,b)}toHex(b=!0){return xs(this.toBytes(b))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(b=!0){return this.toBytes(b)}_setWindowSize(b){this.precompute(b)}static normalizeZ(b){return Ti(k,b)}static msm(b,E){return ep(k,i,b,E)}static fromPrivateKey(b){return k.BASE.multiply(bs(i,b))}}k.BASE=new k(r.Gx,r.Gy,n.ONE),k.ZERO=new k(n.ZERO,n.ONE,n.ZERO),k.Fp=n,k.Fn=i;const M=i.BITS,H=new Jd(k,e.endo?Math.ceil(M/2):M);return k.BASE.precompute(8),k}function yl(t){return Uint8Array.of(t?2:3)}function wl(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function op(t,e={}){const{Fn:s}=t,n=e.randomBytes||cs,i=Object.assign(wl(t.Fp,s),{seed:fl(s.ORDER)});function r(p){try{return!!bs(s,p)}catch{return!1}}function o(p,f){const{publicKey:g,publicKeyUncompressed:_}=i;try{const v=p.length;return f===!0&&v!==g||f===!1&&v!==_?!1:!!t.fromBytes(p)}catch{return!1}}function a(p=n(i.seed)){return Yd(Jt(p,i.seed,"seed"),s.ORDER)}function c(p,f=!0){return t.BASE.multiply(bs(s,p)).toBytes(f)}function l(p){const f=a(p);return{secretKey:f,publicKey:c(f)}}function h(p){if(typeof p=="bigint")return!1;if(p instanceof t)return!0;const{secretKey:f,publicKey:g,publicKeyUncompressed:_}=i;if(s.allowedLengths||f===g)return;const v=xe("key",p).length;return v===g||v===_}function u(p,f,g=!0){if(h(p)===!0)throw new Error("first arg must be private key");if(h(f)===!1)throw new Error("second arg must be public key");const _=bs(s,p);return t.fromHex(f).multiply(_).toBytes(g)}return Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:l,Point:t,utils:{isValidSecretKey:r,isValidPublicKey:o,randomSecretKey:a,isValidPrivateKey:r,randomPrivateKey:a,normPrivateKeyToScalar:p=>bs(s,p),precompute(p=8,f=t.BASE){return f.precompute(p,!1)}},lengths:i})}function ap(t,e,s={}){zr(e),mi(s,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=s.randomBytes||cs,i=s.hmac||((E,...m)=>jr(e,E,$t(...m))),{Fp:r,Fn:o}=t,{ORDER:a,BITS:c}=o,{keygen:l,getPublicKey:h,getSharedSecret:u,utils:d,lengths:p}=op(t,s),f={prehash:!1,lowS:typeof s.lowS=="boolean"?s.lowS:!1,format:void 0,extraEntropy:!1},g="compact";function _(E){const m=a>>Ds;return E>m}function v(E,m){if(!o.isValidNot0(m))throw new Error(`invalid signature ${E}: out of range 1..Point.Fn.ORDER`);return m}function A(E,m){fr(m);const y=p.signature,I=m==="compact"?y:m==="recovered"?y+1:void 0;return Jt(E,I,`${m} signature`)}class S{constructor(m,y,I){this.r=v("r",m),this.s=v("s",y),I!=null&&(this.recovery=I),Object.freeze(this)}static fromBytes(m,y=g){A(m,y);let I;if(y==="der"){const{r:O,s:T}=bt.toSig(Jt(m));return new S(O,T)}y==="recovered"&&(I=m[0],y="compact",m=m.subarray(1));const D=o.BYTES,w=m.subarray(0,D),x=m.subarray(D,D*2);return new S(o.fromBytes(w),o.fromBytes(x),I)}static fromHex(m,y){return this.fromBytes(Wn(m),y)}addRecoveryBit(m){return new S(this.r,this.s,m)}recoverPublicKey(m){const y=r.ORDER,{r:I,s:D,recovery:w}=this;if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");if(a*ml<y&&w>1)throw new Error("recovery id is ambiguous for h>1 curve");const O=w===2||w===3?I+a:I;if(!r.isValid(O))throw new Error("recovery id 2 or 3 invalid");const T=r.toBytes(O),j=t.fromBytes($t(yl((w&1)===0),T)),z=o.inv(O),q=F(xe("msgHash",m)),K=o.create(-q*z),W=o.create(D*z),Z=t.BASE.multiplyUnsafe(K).add(j.multiplyUnsafe(W));if(Z.is0())throw new Error("point at infinify");return Z.assertValidity(),Z}hasHighS(){return _(this.s)}toBytes(m=g){if(fr(m),m==="der")return Wn(bt.hexFromSig(this));const y=o.toBytes(this.r),I=o.toBytes(this.s);if(m==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return $t(Uint8Array.of(this.recovery),y,I)}return $t(y,I)}toHex(m){return xs(this.toBytes(m))}assertValidity(){}static fromCompact(m){return S.fromBytes(xe("sig",m),"compact")}static fromDER(m){return S.fromBytes(xe("sig",m),"der")}normalizeS(){return this.hasHighS()?new S(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return xs(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return xs(this.toBytes("compact"))}}const C=s.bits2int||function(m){if(m.length>8192)throw new Error("input is too large");const y=_i(m),I=m.length*8-c;return I>0?y>>BigInt(I):y},F=s.bits2int_modN||function(m){return o.create(C(m))},$=un(c);function U(E){return pr("num < 2^"+c,E,Et,$),o.toBytes(E)}function N(E,m){return Jt(E,void 0,"message"),m?Jt(e(E),void 0,"prehashed message"):E}function k(E,m,y){if(["recovered","canonical"].some(K=>K in y))throw new Error("sign() legacy options not supported");const{lowS:I,prehash:D,extraEntropy:w}=Ni(y,f);E=N(E,D);const x=F(E),O=bs(o,m),T=[U(O),U(x)];if(w!=null&&w!==!1){const K=w===!0?n(p.secretKey):w;T.push(xe("extraEntropy",K))}const j=$t(...T),z=x;function q(K){const W=C(K);if(!o.isValidNot0(W))return;const Z=o.inv(W),V=t.BASE.multiply(W).toAffine(),ee=o.create(V.x);if(ee===Et)return;const pe=o.create(Z*o.create(z+ee*O));if(pe===Et)return;let Ce=(V.x===ee?0:2)|Number(V.y&Ds),et=pe;return I&&_(pe)&&(et=o.neg(pe),Ce^=1),new S(ee,et,Ce)}return{seed:j,k2sig:q}}function M(E,m,y={}){E=xe("message",E);const{seed:I,k2sig:D}=k(E,m,y);return Fd(e.outputLen,o.BYTES,i)(I,D)}function H(E){let m;const y=typeof E=="string"||qr(E),I=!y&&E!==null&&typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!y&&!I)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(I)m=new S(E.r,E.s);else if(y){try{m=S.fromBytes(xe("sig",E),"der")}catch(D){if(!(D instanceof bt.Err))throw D}if(!m)try{m=S.fromBytes(xe("sig",E),"compact")}catch{return!1}}return m||!1}function B(E,m,y,I={}){const{lowS:D,prehash:w,format:x}=Ni(I,f);if(y=xe("publicKey",y),m=N(xe("message",m),w),"strict"in I)throw new Error("options.strict was renamed to lowS");const O=x===void 0?H(E):S.fromBytes(xe("sig",E),x);if(O===!1)return!1;try{const T=t.fromBytes(y);if(D&&O.hasHighS())return!1;const{r:j,s:z}=O,q=F(m),K=o.inv(z),W=o.create(q*K),Z=o.create(j*K),V=t.BASE.multiplyUnsafe(W).add(T.multiplyUnsafe(Z));return V.is0()?!1:o.create(V.x)===j}catch{return!1}}function b(E,m,y={}){const{prehash:I}=Ni(y,f);return m=N(m,I),S.fromBytes(E,"recovered").recoverPublicKey(m).toBytes()}return Object.freeze({keygen:l,getPublicKey:h,getSharedSecret:u,utils:d,lengths:p,Point:t,sign:M,verify:B,recoverPublicKey:b,Signature:S,hash:e})}function cp(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},s=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(o=>Math.ceil(o/2)))):void 0;const i=zt(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),r={Fp:s,Fn:i,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:r}}function lp(t){const{CURVE:e,curveOpts:s}=cp(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:s,hash:t.hash,ecdsaOpts:n}}function hp(t,e){const s=e.Point;return Object.assign({},e,{ProjectivePoint:s,CURVE:Object.assign({},t,dl(s.Fn.ORDER,s.Fn.BITS))})}function up(t){const{CURVE:e,curveOpts:s,hash:n,ecdsaOpts:i}=lp(t),r=rp(e,s),o=ap(r,n,i);return hp(t,o)}function Xr(t,e){const s=n=>up({...t,hash:n});return{...s(e),create:s}}function bl(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function gr(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Ci(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Pe(t,...e){if(!bl(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Wo(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function dp(t,e){Pe(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Mt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ps(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function pp(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const fp=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function gp(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function _r(t){if(typeof t=="string")t=gp(t);else if(bl(t))t=mr(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function _p(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function mp(t,e){if(t.length!==e.length)return!1;let s=0;for(let n=0;n<t.length;n++)s|=t[n]^e[n];return s===0}const yp=(t,e)=>{function s(n,...i){if(Pe(n),!fp)throw new Error("Non little-endian hardware is not yet supported");if(t.nonceLength!==void 0){const h=i[0];if(!h)throw new Error("nonce / iv required");t.varSizeNonce?Pe(h):Pe(h,t.nonceLength)}const r=t.tagLength;r&&i[1]!==void 0&&Pe(i[1]);const o=e(n,...i),a=(h,u)=>{if(u!==void 0){if(h!==2)throw new Error("cipher output not supported");Pe(u)}};let c=!1;
1return{encrypt(h,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,Pe(h),a(o.encrypt.length,u),o.encrypt(h,u)},decrypt(h,u){if(Pe(h),r&&h.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return a(o.decrypt.length,u),o.decrypt(h,u)}}}return Object.assign(s,t),s};function Yo(t,e,s=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(s&&!bp(e))throw new Error("invalid output, must be aligned");return e}function Xo(t,e,s,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,n);const i=BigInt(32),r=BigInt(4294967295),o=Number(s>>i&r),a=Number(s&r),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}function wp(t,e,s){gr(s);const n=new Uint8Array(16),i=pp(n);return Xo(i,0,BigInt(e),s),Xo(i,8,BigInt(t),s),n}function bp(t){return t.byteOffset%4===0}function mr(t){return Uint8Array.from(t)}const El={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},vl={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},Il={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},Ep=zt(El.p),vp=zt(vl.p),Ip=zt(Il.p),Sp=Xr({...El,Fp:Ep,lowS:!1},Hr);Xr({...vl,Fp:vp,lowS:!1},vd);Xr({...Il,Fp:Ip,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},Id);const xp=Sp;var Zo=globalThis&&globalThis.__spreadArray||function(t,e,s){if(s||arguments.length===2)for(var n=0,i=e.length,r;n<i;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))},Dp=function(){function t(e,s,n){this.name=e,this.version=s,this.os=n,this.type="browser"}return t}(),Op=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),kp=function(){function t(e,s,n,i){this.name=e,this.version=s,this.os=n,this.bot=i,this.type="bot-device"}return t}(),Ap=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Tp=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Rp=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yaho
vendor: 9,290 bytes, line 1
1o!|yandex/,Pp=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Jo=3,$p=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Rp]],Qo=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Np(t){return t?ea(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Tp:typeof navigator<"u"?ea(navigator.userAgent):Up()}function Cp(t){return t!==""&&$p.reduce(function(e,s){var n=s[0],i=s[1];if(e)return e;var r=i.exec(t);return!!r&&[n,r]},!1)}function ea(t){var e=Cp(t);if(!e)return null;var s=e[0],n=e[1];if(s==="searchbot")return new Ap;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Jo&&(i=Zo(Zo([],i,!0),Mp(Jo-i.length),!0)):i=[];var r=i.join("."),o=Bp(t),a=Pp.exec(t);return a&&a[1]?new kp(s,r,o,a[1]):new Dp(s,r,o)}function Bp(t){for(var e=0,s=Qo.length;e<s;e++){var n=Qo[e],i=n[0],r=n[1],o=r.exec(t);if(o)return i}return null}function Up(){var t=typeof process<"u"&&process.version;return t?new Op(process.version.slice(1)):null}function Mp(t){for(var e=[],s=0;s<t;s++)e.push("0");return e}var R={};var yr=function(t,e){return yr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,n){s.__proto__=n}||function(s,n){for(var i in n)n.hasOwnProperty(i)&&(s[i]=n[i])},yr(t,e)};function Lp(t,e){yr(t,e);function s(){this.constructor=t}t.prototype=e===null?Object.create(e):(s.prototype=e.prototype,new s)}var wr=function(){return wr=Object.assign||function(e){for(var s,n=1,i=arguments.length;n<i;n++){s=arguments[n];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e},wr.apply(this,arguments)};function Fp(t,e){var s={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(s[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(s[n[i]]=t[n[i]]);return s}function qp(t,e,s,n){var i=arguments.length,r=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,s):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,s,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(i<3?o(r):i>3?o(e,s,r):o(e,s))||r);return i>3&&r&&Object.defineProperty(e,s,r),r}function zp(t,e){return function(s,n){e(s,n,t)}}function jp(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Hp(t,e,s,n){function i(r){return r instanceof s?r:new s(function(o){o(r)})}return new(s||(s=Promise))(function(r,o){function a(h){try{l(n.next(h))}catch(u){o(u)}}function c(h){try{l(n.throw(h))}catch(u){o(u)}}function l(h){h.done?r(h.value):i(h.value).then(a,c)}l((n=n.apply(t,e||[])).next())})}function Kp(t,e){var s={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,i,r,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=l[0]&2?i.return:l[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;switch(i=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,i=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(r=s.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){s=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){s.label=l[1];break}if(l[0]===6&&s.label<r[1]){s.label=r[1],r=l;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(l);break}r[2]&&s.ops.pop(),s.trys.pop();continue}l=e.call(t,s)}catch(h){l=[6,h],i=0}finally{n=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Vp(t,e,s,n){n===void 0&&(n=s),t[n]=e[s]}function Gp(t,e){for(var s in t)s!=="default"&&!e.hasOwnProperty(s)&&(e[s]=t[s])}function br(t){var e=typeof Symbol=="function"&&Symbol.iterator,s=e&&t[e],n=0;if(s)return s.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Sl(t,e){var s=typeof Symbol=="function"&&t[Symbol.iterator];if(!s)return t;var n=s.call(t),i,r=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)r.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.error}}return r}function Wp(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Sl(arguments[e]));return t}function Yp(){for(var t=0,e=0,s=arguments.length;e<s;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<s;e++)for(var r=arguments[e],o=0,a=r.length;o<a;o++,i++)n[i]=r[o];return n}function nn(t){return this instanceof nn?(this.v=t,this):new nn(t)}function Xp(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=s.apply(t,e||[]),i,r=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(d){n[d]&&(i[d]=function(p){return new Promise(function(f,g){r.push([d,p,f,g])>1||a(d,p)})})}function a(d,p){try{c(n[d](p))}catch(f){u(r[0][3],f)}}function c(d){d.value instanceof nn?Promise.resolve(d.value.v).then(l,h):u(r[0][2],d)}function l(d){a("next",d)}function h(d){a("throw",d)}function u(d,p){d(p),r.shift(),r.length&&a(r[0][0],r[0][1])}}function Zp(t){var e,s;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,r){e[i]=t[i]?function(o){return(s=!s)?{value:nn(t[i](o)),done:i==="return"}:r?r(o):o}:r}}function Jp(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],s;return e?e.call(t):(t=typeof br=="function"?br(t):t[Symbol.iterator](),s={},n("next"),n("throw"),n("return"),s[Symbol.asyncIterator]=function(){return this},s);function n(r){s[r]=t[r]&&function(o){return new Promise(function(a,c){o=t[r](o),i(a,c,o.done,o.value)})}}function i(r,o,a,c){Promise.resolve(c).then(function(l){r({value:l,done:a})},o)}}function Qp(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function ef(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var s in t)Object.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e.default=t,e}function tf(t){return t&&t.__esModule?t:{default:t}}function sf(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function nf(t,e,s){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,s),s}const rf=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return wr},__asyncDelegator:Zp,__asyncGenerator:Xp,__asyncValues:Jp,__await:nn,__awaiter:Hp,__classPrivateFieldGet:sf,__classPrivateFieldSet:nf,__createBinding:Vp,__decorate:qp,__exportStar:Gp,__extends:Lp,__generator:Kp,__importDefault:tf,__importStar:ef,__makeTemplateOb
1ject:Qp,__metadata:jp,__param:zp,__read:Sl,__rest:Fp,__spread:Wp,__spreadArrays:Yp,__values:br},Symbol.toStringTag,{value:"Module"})),dn=Sd(rf);var Bi={},Us={},ta;function of(){if(ta)return Us;ta=1,Object.defineProperty(Us,"__esModule",{value:!0}),Us.delay=void 0;function t(e){return new Promise(s=>{setTimeout(()=>{s(!0)},e)})}return Us.delay=t,Us}var Ht={},Ui={},Kt={},sa;function af(){return sa||(sa=1,Object.defineProperty(Kt,"__esModule",{value:!0}),Kt.ONE_THOUSAND=Kt.ONE_HUNDRED=void 0,Kt.ONE_HUNDRED=100,Kt.ONE_THOUSAND=1e3),Kt}var Mi={},na;function cf(){return na||(na=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(Mi)),Mi}var ia;function xl(){return ia||(ia=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=dn;e.__exportStar(af(),t),e.__exportStar(cf(),t)}(Ui)),Ui}var ra;function lf(){if(ra)return Ht;ra=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.fromMiliseconds=Ht.toMiliseconds=void 0;const t=xl();function e(n){return n*t.ONE_THOUSAND}Ht.toMiliseconds=e;function s(n){return Math.floor(n/t.ONE_THOUSAND)}return Ht.fromMiliseconds=s,Ht}var oa;function hf(){return oa||(oa=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=dn;e.__exportStar(of(),t),e.__exportStar(lf(),t)}(Bi)),Bi}var _s={},aa;function uf(){if(aa)return _s;aa=1,Object.defineProperty(_s,"__esModule",{value:!0}),_s.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(s){if(this.timestamps.has(s))throw new Error(`Watch already started for label: ${s}`);this.timestamps.set(s,{started:Date.now()})}stop(s){const n=this.get(s);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${s}`);const i=Date.now()-n.started;this.timestamps.set(s,{started:n.started,elapsed:i})}get(s){const n=this.timestamps.get(s);if(typeof n>"u")throw new Error(`No timestamp found for label: ${s}`);return n}elapsed(s){const n=this.get(s);return n.elapsed||Date.now()-n.started}}return _s.Watch=t,_s.default=t,_s}var Li={},Ms={},ca;function df(){if(ca)return Ms;ca=1,Object.defineProperty(Ms,"__esModule",{value:!0}),Ms.IWatch=void 0;class t{}return Ms.IWatch=t,Ms}var la;function pf(){return la||(la=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),dn.__exportStar(df(),t)}(Li)),Li}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=dn;e.__exportStar(hf(),t),e.__exportStar(uf(),t),e.__exportStar(pf(),t),e.__exportStar(xl(),t)})(R);var se={};Object.defineProperty(se,"__esModule",{value:!0});se.getLocalStorage=se.getLocalStorageOrThrow=se.getCrypto=se.getCryptoOrThrow=Dl=se.getLocation=se.getLocationOrThrow=Zr=se.getNavigator=se.getNavigatorOrThrow=ns=se.getDocument=se.getDocumentOrThrow=se.getFromWindowOrThrow=se.getFromWindow=void 0;function ls(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}se.getFromWindow=ls;function $s(t){const e=ls(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}se.getFromWindowOrThrow=$s;function ff(){return $s("document")}se.getDocumentOrThrow=ff;function gf(){return ls("document")}var ns=se.getDocument=gf;function _f(){return $s("navigator")}se.getNavigatorOrThrow=_f;function mf(){return ls("navigator")}var Zr=se.getNavigator=mf;function yf(){return $s("location")}se.getLocationOrThrow=yf;function wf(){return ls("location")}var Dl=se.getLocation=wf;function bf(){return $s("crypto")}se.getCryptoOrThrow=bf;function Ef(){return ls("crypto")}se.getCrypto=Ef;function vf(){return $s("localStorage")}se.getLocalStorageOrThrow=vf;function If(){return ls("localStorage")}se.getLocalStorage=If;var Jr={};
vendor: 14,071 bytes, lines 1-2
1Object.defineProperty(Jr,"__esModule",{value:!0});var Ol=Jr.getWindowMetadata=void 0;const ha=se;function Sf(){let t,e;try{t=ha.getDocumentOrThrow(),e=ha.getLocationOrThrow()}catch{return null}function s(){const u=t.getElementsByTagName("link"),d=[];for(let p=0;p<u.length;p++){const f=u[p],g=f.getAttribute("rel");if(g&&g.toLowerCase().indexOf("icon")>-1){const _=f.getAttribute("href");if(_)if(_.toLowerCase().indexOf("https:")===-1&&_.toLowerCase().indexOf("http:")===-1&&_.indexOf("//")!==0){let v=e.protocol+"//"+e.host;if(_.indexOf("/")===0)v+=_;else{const A=e.pathname.split("/");A.pop();const S=A.join("/");v+=S+"/"+_}d.push(v)}else if(_.indexOf("//")===0){const v=e.protocol+_;d.push(v)}else d.push(_)}}return d}function n(...u){const d=t.getElementsByTagName("meta");for(let p=0;p<d.length;p++){const f=d[p],g=["itemprop","property","name"].map(_=>f.getAttribute(_)).filter(_=>_?u.includes(_):!1);if(g.length&&g){const _=f.getAttribute("content");if(_)return _}}return""}function i(){let u=n("name","og:site_name","og:title","twitter:title");return u||(u=t.title),u}function r(){return n("description","og:description","twitter:description","keywords")}const o=i(),a=r(),c=e.origin,l=s();return{description:a,url:c,icons:l,name:o}}Ol=Jr.getWindowMetadata=Sf;const xf="0.1.1";function Df(){return xf}class re extends Error{constructor(e,s={}){const n=(()=>{var c;if(s.cause instanceof re){if(s.cause.details)return s.cause.details;if(s.cause.shortMessage)return s.cause.shortMessage}return s.cause&&"details"in s.cause&&typeof s.cause.details=="string"?s.cause.details:(c=s.cause)!=null&&c.message?s.cause.message:s.details})(),i=(()=>s.cause instanceof re&&s.cause.docsPath||s.docsPath)(),o=`https://oxlib.sh${i??""}`,a=[e||"An error occurred.",...s.metaMessages?["",...s.metaMessages]:[],...n||i?["",n?`Details: ${n}`:void 0,i?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(` 2`);super(a,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Df()}`}),this.cause=s.cause,this.details=n,this.docs=o,this.docsPath=i,this.shortMessage=e}walk(e){return kl(this,e)}}function kl(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?kl(t.cause,e):e?null:t}function Of(t,e){if(fa(t)>e)throw new Wf({givenSize:fa(t),maxSize:e})}const dt={zero:48,nine:57,A:65,F:70,a:97,f:102};function ua(t){if(t>=dt.zero&&t<=dt.nine)return t-dt.zero;if(t>=dt.A&&t<=dt.F)return t-(dt.A-10);if(t>=dt.a&&t<=dt.f)return t-(dt.a-10)}function kf(t,e={}){const{dir:s,size:n=32}=e;if(n===0)return t;if(t.length>n)throw new Yf({size:t.length,targetSize:n,type:"Bytes"});const i=new Uint8Array(n);for(let r=0;r<n;r++){const o=s==="right";i[o?r:n-r-1]=t[o?r:t.length-r-1]}return i}function Al(t,e){if(qt(t)>e)throw new Mf({givenSize:qt(t),maxSize:e})}function Af(t,e){if(typeof e=="number"&&e>0&&e>qt(t)-1)throw new Pl({offset:e,position:"start",size:qt(t)})}function Tf(t,e,s){if(typeof e=="number"&&typeof s=="number"&&qt(t)!==s-e)throw new Pl({offset:s,position:"end",size:qt(t)})}function Tl(t,e={}){const{dir:s,size:n=32}=e;if(n===0)return t;const i=t.replace("0x","");if(i.length>n*2)throw new Lf({size:Math.ceil(i.length/2),targetSize:n,type:"Hex"});return`0x${i[s==="right"?"padEnd":"padStart"](n*2,"0")}`}const Rf="#__bigint";function Qr(t,e,s){return JSON.stringify(t,(n,i)=>typeof e=="function"?e(n,i):typeof i=="bigint"?i.toString()+Rf:i,s)}const Pf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function $f(t,e={}){const{strict:s=!1}=e;if(!t)throw new da(t);if(typeof t!="string")throw new da(t);if(s&&!/^0x[0-9a-fA-F]*$/.test(t))throw new pa(t);if(!t.startsWith("0x"))throw new pa(t)}function Nf(...t){return`0x${t.reduce((e,s)=>e+s.replace("0x",""),"")}`}function eo(t){return t instanceof Uint8Array?Jn(t):Array.isArray(t)?Jn(new Uint8Array(t)):t}function Jn(t,e={}){let s="";for(let i=0;i<t.length;i++)s+=Pf[t[i]];const n=`0x${s}`;return typeof e.size=="number"?(Al(n,e.size),Rl(n,e.size)):n}function Fi(t,e={}){const{signed:s,size:n}=e,i=BigInt(t);let r;n?s?r=(1n<<BigInt(n)*8n-1n)-1n:r=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(r=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof r=="bigint"&&s?-r-1n:0;if(r&&i>r||i<o){const l=typeof t=="bigint"?"n":"";throw new Uf({max:r?`${r}${l}`:void 0,min:`${o}${l}`,signed:s,size:n,value:`${t}${l}`})}const c=`0x${(s&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?Cf(c,n):c}function Cf(t,e){return Tl(t,{dir:"left",size:e})}function Rl(t,e){return Tl(t,{dir:"right",size:e})}function wt(t,e,s,n={}){const{strict:i}=n;Af(t,e);const r=`0x${t.replace("0x","").slice((e??0)*2,(s??t.length)*2)}`;return i&&Tf(r,e,s),r}function qt(t){return Math.ceil((t.length-2)/2)}function Bf(t,e={}){const{strict:s=!1}=e;try{return $f(t,{strict:s}),!0}catch{return!1}}class Uf extends re{constructor({max:e,min:s,signed:n,size:i,value:r}){super(`Number \`${r}\` is not in safe${i?` ${i*8}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${s}\` to \`${e}\`)`:`(above \`${s}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class da extends re{constructor(e){super(`Value \`${typeof e=="object"?Qr(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class pa extends re{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}let Mf=class extends re{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed \`${s}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}};class Pl extends re{constructor({offset:e,position:s,size:n}){super(`Slice ${s==="start"?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}let Lf=class extends re{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${s}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}};const Ff=new TextEncoder;function qf(t){if(!(t instanceof Uint8Array)){if(!t)throw new bn(t);if(typeof t!="object")throw new bn(t);if(!("BYTES_PER_ELEMENT"in t))throw new bn(t);if(t.BYTES_PER_ELEMENT!==1||t.constructor.name!=="Uint8Array")throw new bn(t)}}function zf(t){return t instanceof Uint8Array?t:typeof t=="string"?Hf(t):jf(t)}function jf(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function Hf(t,e={}){const{size:s}=e;let n=t;s&&(Al(t,s),n=Rl(t,s));let i=n.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,o=new Uint8Array(r);for(let a=0,c=0;a<r;a++){const l=ua(i.charCodeAt(c++)),h=ua(i.charCodeAt(c++));if(l===void 0||h===void 0)throw new re(`Invalid byte sequence ("${i[c-2]}${i[c-1]}" in "${i}").`);o[a]=l*16+h}return o}function Kf(t,e={}){const{size:s}=e,n=Ff.encode(t);return typeof s=="number"?(Of(n,s),Vf(n,s)):n}function Vf(t,e){return kf(t,{dir:"right",size:e})}function fa(t){return t.length}function Gf(t){try{return qf(t),!0}catch{return!1}}class bn extends re{constructor(e){super(`Value \`${typeof e=="object"?Qr(e):e}\` of type \`${typeof e}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}class Wf extends re{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed \`${s}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class Yf extends re{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${s}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function $l(t,e={}){const{as:s=typeof t=="string"?"Hex":"Bytes"}=e,n=tl(zf(t));return s==="Bytes"?n:Jn(n)}class Xf extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const Zf={checksum:new Xf(8192)},qi=Zf.checksum;function Nl(t,e={}){const{compressed:s}=e,{prefix:n,x:i,y:r}=t;if(s===!1||typeof i=="bigint"&&typeof r=="bigint"){if(n!==4)throw new ga({prefix:n,cause:new ng});return}if(s===!0||typeof i=="bigint"&&typeof r>"u"){if(n!==3&&n!==2)throw new ga({prefix:n,cause:new sg});return}throw new tg({publicKey:t})}function Jf(t){const e=(()=>{if(Bf(t))return Cl(t);if(Gf(t))return Qf(t);const{prefix:s,x:n,y:i}=t;return typeof n=="bigint"&&typeof i=="bigint"?{prefix:s??4,x:n,y:i}:{prefix:s,x:n}})();return Nl(e),e}function Qf(t){return Cl(Jn(t))}function Cl(t){if(t.length!==132&&t.length!==130&&t.length!==68)throw new ig({publicKey:t});if(t.length===130){const n=BigInt(wt(t,0,32)),i=BigInt(wt(t,32,64));return{prefix:4,x:n,y:i}}if(t.length===132){const n=Number(wt(t,0,1)),i=BigInt(wt(t,1,33)),r=BigInt(wt(t,33,65));return{prefix:n,x:i,y:r}}const e=Number(wt(t,0,1)),s=BigInt(wt(t,1,33));return{prefix:e,x:s}}function eg(t,e={}){Nl(t);const{prefix:s,x:n,y:i}=t,{includePrefix:r=!0}=e;return Nf(r?Fi(s,{size:1}):"0x",Fi(n,{size:32}),typeof i=="bigint"?Fi(i,{size:32}):"0x")}class tg extends re{constructor({publicKey:e}){super(`Value \`${Qr(e)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class ga extends re{constructor({prefix:e,cause:s}){super(`Prefix "${e}" is invalid.`,{cause:s}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class sg extends re{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class ng extends re{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let ig=class extends re{constructor({publicKey:e}){super(`Value \`${e}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${qt(eo(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const rg=/^0x[a-fA-F0-9]{40}$/;function Bl(t,e={}){const{strict:s=!0}=e;if(!rg.test(t))throw new _a({address:t,cause:new cg});if(s){if(t.toLowerCase()===t)return;if(Ul(t)!==t)throw new _a({address:t,cause:new lg})}}function Ul(t){if(qi.has(t))return qi.get(t);Bl(t,{strict:!1});const e=t.substring(2).toLowerCase(),s=$l(Kf(e),{as:"Bytes"}),n=e.split("");for(let r=0;r<40;r+=2)s[r>>1]>>4>=8&&n[r]&&(n[r]=n[r].toUpperCase()),(s[r>>1]&15)>=8&&n[r+1]&&(n[r+1]=n[r+1].toUpperCase());const i=`0x${n.join("")}`;return qi.set(t,i),i}function og(t,e={}){const{checksum:s=!1}=e;return Bl(t),s?Ul(t):t}function ag(t,e={}){const s=$l(`0x${eg(t).slice(4)}`).substring(26);return og(`0x${s}`,e)}class _a extends re{constructor({address:e,cause:s}){super(`Address "${e}" is invalid.`,{cause:s}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class cg extends re{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class lg extends re{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}function hg(t){if(t.length!==130&&t.length!==132)throw new dg({signature:t});const e=BigInt(wt(t,0,32)),s=BigInt(wt(t,32,64)),n=(()=>{const i=+`0x${t.slice(130)}`;if(!Number.isNaN(i))try{return ug(i)}catch{throw new pg({value:i})}})();return typeof n>"u"?{r:e,s}:{r:e,s,yParity:n}}function ug(t){if(t===0||t===27)return 0;if(t===1||t===28)return 1;if(t>=35)return t%2===0?1:0;throw new fg({value:t})}class dg extends re{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${qt(eo(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class pg extends re{constructor({value:e}){super(`Value \`${e}
2\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class fg extends re{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function gg(t){return ag(_g(t))}function _g(t){const{payload:e,signature:s}=t,{r:n,s:i,yParity:r}=s,a=new xd.Signature(BigInt(n),BigInt(i)).addRecoveryBit(r).recoverPublicKey(eo(e).substring(2));return Jf(a)}function mg(t){const e=t.length;let s=0,n=0;for(;n<e;){let i=t.charCodeAt(n++);if(i&4294967168)if(!(i&4294965248))s+=2;else{if(i>=55296&&i<=56319&&n<e){const r=t.charCodeAt(n);(r&64512)===56320&&(++n,i=((i&1023)<<10)+(r&1023)+65536)}i&4294901760?s+=4:s+=3}else{s++;continue}}return s}function yg(t,e,s){const n=t.length;let i=s,r=0;for(;r<n;){let o=t.charCodeAt(r++);if(o&4294967168)if(!(o&4294965248))e[i++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&r<n){const a=t.charCodeAt(r);(a&64512)===56320&&(++r,o=((o&1023)<<10)+(a&1023)+65536)}o&4294901760?(e[i++]=o>>18&7|240,e[i++]=o>>12&63|128,e[i++]=o>>6&63|128):(e[i++]=o>>12&15|224,e[i++]=o>>6&63|128)}else{e[i++]=o;continue}e[i++]=o&63|128}}const wg=new TextEncoder,bg=50;function Eg(t,e,s){wg.encodeInto(t,e.subarray(s))}function vg(t,e,s){t.length>bg?Eg(t,e,s):yg(t,e,s)}const Ig=4096;function Ml(t,e,s){let n=e;const i=n+s,r=[];let o="";for(;n<i;){const a=t[n++];if(!(a&128))r.push(a);else if((a&224)===192){const c=t[n++]&63;r.push((a&31)<<6|c)}else if((a&240)===224){const c=t[n++]&63,l=t[n++]&63;r.push((a&31)<<12|c<<6|l)}else if((a&248)===240){const c=t[n++]&63,l=t[n++]&63,h=t[n++]&63;let u=(a&7)<<18|c<<12|l<<6|h;u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|u&1023),r.push(u)}else r.push(a);r.length>=Ig&&(o+=String.fromCharCode(...r),r.length=0)}return r.length>0&&(o+=String.fromCharCode(...r)),o}const Sg=new TextDecoder,xg=200;function Dg(t,e,s){const n=t.subarray(e,e+s);return Sg.decode(n)}function Og(t,e,s){return s>xg?Dg(t,e,s):Ml(t,e,s)}class En{constructor(e,s){G(this,"type");G(this,"data");this.type=e,this.data=s}}class Me extends Error{constructor(e){super(e);const s=Object.create(Me.prototype);Object.setPrototypeOf(this,s),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:Me.name})}}const Ls=4294967295;function kg(t,e,s){const n=s/4294967296,i=s;t.setUint32(e,n),t.setUint32(e+4,i)}function Ll(t,e,s){const n=Math.floor(s/4294967296),i=s;t.setUint32(e,n),t.setUint32(e+4,i)}function Fl(t,e){const s=t.getInt32(e),n=t.getUint32(e+4);return s*4294967296+n}function Ag(t,e){const s=t.getUint32(e),n=t.getUint32(e+4);return s*4294967296+n}const Tg=-1,Rg=4294967296-1,Pg=17179869184-1;function $g({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=Pg)if(e===0&&t<=Rg){const s=new Uint8Array(4);return new DataView(s.buffer).setUint32(0,t),s}else{const s=t/4294967296,n=t&4294967295,i=new Uint8Array(8),r=new DataView(i.buffer);return r.setUint32(0,e<<2|s&3),r.setUint32(4,n),i}else{const s=new Uint8Array(12),n=new DataView(s.buffer);return n.setUint32(0,e),Ll(n,4,t),s}}function Ng(t){const e=t.getTime(),s=Math.floor(e/1e3),n=(e-s*1e3)*1e6,i=Math.floor(n/1e9);return{sec:s+i,nsec:n-i*1e9}}function Cg(t){if(t instanceof Date){const e=Ng(t);return $g(e)}else return null}function Bg(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const s=e.getUint32(0),n=e.getUint32(4),i=(s&3)*4294967296+n,r=s>>>2;return{sec:i,nsec:r}}case 12:{const s=Fl(e,4),n=e.getUint32(0);return{sec:s,nsec:n}}default:throw new Me(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function Ug(t){const e=Bg(t);return new Date(e.sec*1e3+e.nsec/1e6)}const Mg={type:Tg,encode:Cg,decode:Ug},fi=class fi{constructor(){G(this,"__brand");G(this,"builtInEncoders",[]);G(this,"builtInDecoders",[]);G(this,"encoders",[]);G(this,"decoders",[]);this.register(Mg)}register({type:e,encode:s,decode:n}){if(e>=0)this.encoders[e]=s,this.decoders[e]=n;else{const i=-1-e;this.builtInEncoders[i]=s,this.builtInDecoders[i]=n}}tryToEncode(e,s){for(let n=0;n<this.builtInEncoders.length;n++){const i=this.builtInEncoders[n];if(i!=null){const r=i(e,s);if(r!=null){const o=-1-n;return new En(o,r)}}}for(let n=0;n<this.encoders.length;n++){const i=this.encoders[n];if(i!=null){const r=i(e,s);if(r!=null){const o=n;return new En(o,r)}}}return e instanceof En?e:null}decode(e,s,n){const i=s<0?this.builtInDecoders[-1-s]:this.decoders[s];return i?i(e,s,n):new En(s,e)}};G(fi,"defaultCodec",new fi);let Qn=fi;function Lg(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function Er(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Lg(t)?new Uint8Array(t):Uint8Array.from(t)}const Fg=100,qg=2048;let zg=class ql{constructor(e){G(this,"extensionCodec");G(this,"context");G(this,"useBigInt64");G(this,"maxDepth");G(this,"initialBufferSize");
vendor: 20,675 bytes, line 2
2G(this,"sortKeys");G(this,"forceFloat32");G(this,"ignoreUndefined");G(this,"forceIntegerToFloat");G(this,"pos");G(this,"view");G(this,"bytes");G(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??Qn.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??Fg,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??qg,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new ql({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,s){if(s>this.maxDepth)throw new Error(`Too deep objects in depth ${s}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,s)}ensureBufferSizeToWrite(e){const s=this.pos+e;this.view.byteLength<s&&this.resizeBuffer(s*2)}resizeBuffer(e){const s=new ArrayBuffer(e),n=new Uint8Array(s),i=new DataView(s);n.set(this.bytes),this.view=i,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const n=mg(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),vg(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,s){const n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,s);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,s);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const s=e.byteLength;if(s<256)this.writeU8(196),this.writeU8(s);else if(s<65536)this.writeU8(197),this.writeU16(s);else if(s<4294967296)this.writeU8(198),this.writeU32(s);else throw new Error(`Too large binary: ${s}`);const n=Er(e);this.writeU8a(n)}encodeArray(e,s){const n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(const i of e)this.doEncode(i,s+1)}countWithoutUndefined(e,s){let n=0;for(const i of s)e[i]!==void 0&&n++;return n}encodeMap(e,s){const n=Object.keys(e);this.sortKeys&&n.sort();const i=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(const r of n){const o=e[r];this.ignoreUndefined&&o===void 0||(this.encodeString(r),this.doEncode(o,s+1))}}encodeExtension(e){if(typeof e.data=="function"){const n=e.data(this.pos+6),i=n.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(n);return}const s=e.data.length;if(s===1)this.writeU8(212);else if(s===2)this.writeU8(213);else if(s===4)this.writeU8(214);else if(s===8)this.writeU8(215);else if(s===16)this.writeU8(216);else if(s<256)this.writeU8(199),this.writeU8(s);else if(s<65536)this.writeU8(200),this.writeU16(s);else if(s<4294967296)this.writeU8(201),this.writeU32(s);else throw new Error(`Too large extension object: ${s}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const s=e.length;this.ensureBufferSizeToWrite(s),this.bytes.set(e,this.pos),this.pos+=s}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),kg(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Ll(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function jg(t,e){return new zg(e).encodeSharedRef(t)}function zi(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}const Hg=16,Kg=16;class Vg{constructor(e=Hg,s=Kg){G(this,"hit",0);G(this,"miss",0);G(this,"caches");G(this,"maxKeyLength");G(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=s,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,s,n){const i=this.caches[n-1];e:for(const r of i){const o=r.bytes;for(let a=0;a<n;a++)if(o[a]!==e[s+a])continue e;return r.str}return null}store(e,s){const n=this.caches[e.length-1],i={bytes:e,str:s};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)}decode(e,s,n){const i=this.find(e,s,n);if(i!=null)return this.hit++,i;this.miss++;const r=Ml(e,s,n),o=Uint8Array.prototype.slice.call(e,s,s+n);return this.store(o,r),r}}const vr="array",Xs="map_key",zl="map_value",Gg=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new Me("The type of key must be string or number but "+typeof t)};class Wg{constructor(){G(this,"stack",[]);G(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const s=this.getUninitializedStateFromPool();s.type=vr,s.position=0,s.size=e,s.array=new Array(e)}pushMapState(e){const s=this.getUninitializedStateFromPool();s.type=Xs,s.readCount=0,s.size=e,s.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===vr){const n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===Xs||e.type===zl){const n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const Fs=-1,to=new DataView(new ArrayBuffer(0)),Yg=new Uint8Array(to.buffer);try{to.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const ma=new RangeError("Insufficient data"),Xg=new Vg;let Zg=class jl{constructor(e){G(this,"extensionCodec");G(this,"context");G(this,"useBigInt64");G(this,"rawStrings");G(this,"maxStrLength");G(this,"maxBinLength");G(this,"maxArrayLength");G(this,"maxMapLength");G(this,"maxExtLength");G(this,"keyDecoder");G(this,"mapKeyConverter");G(this,"totalPos",0);G(this,"pos",0);G(this,"view",to);G(this,"bytes",Yg);G(this,"headByte",Fs);G(this,"stack",new Wg);G(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??Qn.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??Ls,this.maxBinLength=(e==null?void 0:e.maxBinLength)??Ls,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??Ls,this.maxMapLength=(e==null?void 0:e.maxMapLength)??Ls,this.maxExtLength=(e==null?void 0:e.maxExtLength)??Ls,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:Xg,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??Gg}clone(){return new jl({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Fs,this.stack.reset()}setBuffer(e){const s=Er(e);this.bytes=s,this.view=new DataView(s.buffer,s.byteOffset,s.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Fs&&!this.hasRemaining(1))this.setBuffer(e);else{const s=this.bytes.subarray(this.pos),n=Er(e),i=new Uint8Array(s.length+n.length);i.set(s),i.set(n,s.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:s,pos:n}=this;return new RangeError(`Extra ${s.byteLength-n} of ${s.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const s=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return s}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let s=!1,n;for await(const a of e){if(s)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),s=!0}catch(c){if(!(c instanceof RangeError))throw c}this.totalPos+=this.pos}if(s){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}const{headByte:i,pos:r,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${zi(i)} at ${o} (${r} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,s){if(this.entered){yield*this.clone().decodeMultiAsync(e,s);return}try{this.entered=!0;let n=s,i=-1;for await(const r of e){if(s&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(r),n&&(i=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let s;if(e>=224)s=e-256;else if(e<192)if(e<128)s=e;else if(e<144){const i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else s={}}else if(e<160){const i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else s=[]}else{const i=e-160;s=this.decodeString(i,0)}else if(e===192)s=null;else if(e===194)s=!1;else if(e===195)s=!0;else if(e===202)s=this.readF32();else if(e===203)s=this.readF64();else if(e===204)s=this.readU8();else if(e===205)s=this.readU16();else if(e===206)s=this.readU32();else if(e===207)this.useBigInt64?s=this.readU64AsBigInt():s=this.readU64();else if(e===208)s=this.readI8();else if(e===209)s=this.readI16();else if(e===210)s=this.readI32();else if(e===211)this.useBigInt64?s=this.readI64AsBigInt():s=this.readI64();else if(e===217){const i=this.lookU8();s=this.decodeString(i,1)}else if(e===218){const i=this.lookU16();s=this.decodeString(i,2)}else if(e===219){const i=this.lookU32();s=this.decodeString(i,4)}else if(e===220){const i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else s=[]}else if(e===221){const i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else s=[]}else if(e===222){const i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else s={}}else if(e===223){const i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else s={}}else if(e===196){const i=this.lookU8();s=this.decodeBinary(i,1)}else if(e===197){const i=this.lookU16();s=this.decodeBinary(i,2)}else if(e===198){const i=this.lookU32();s=this.decodeBinary(i,4)}else if(e===212)s=this.decodeExtension(1,0);else if(e===213)s=this.decodeExtension(2,0);else if(e===214)s=this.decodeExtension(4,0);else if(e===215)s=this.decodeExtension(8,0);else if(e===216)s=this.decodeExtension(16,0);else if(e===199){const i=this.lookU8();s=this.decodeExtension(i,1)}else if(e===200){const i=this.lookU16();s=this.decodeExtension(i,2)}else if(e===201){const i=this.lookU32();s=this.decodeExtension(i,4)}else throw new Me(`Unrecognized type byte: ${zi(e)}`);this.complete();const n=this.stack;for(;n.length>0;){const i=n.top();if(i.type===vr)if(i.array[i.position]=s,i.position++,i.position===i.size)s=i.array,n.release(i);else continue e;else if(i.type===Xs){if(s==="__proto__")throw new Me("The key __proto__ is not allowed");i.key=this.mapKeyConverter(s),i.type=zl;continue e}else if(i.map[i.key]=s,i.readCount++,i.readCount===i.size)s=i.map,n.release(i);else{i.key=null,i.type=Xs;continue e}}return s}}readHeadByte(){return this.headByte===Fs&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Fs}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new Me(`Unrecognized array type byte: ${zi(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new Me(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new Me(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,s){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,s):this.decodeBinary(e,s)}decodeUtf8String(e,s){var r;if(e>this.maxStrLength)throw new Me(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+s+e)throw ma;const n=this.pos+s;let i;return this.stateIsMapKey()&&((r=this.keyDecoder)!=null&&r.canBeCached(e))?i=this.keyDecoder.decode(this.bytes,n,e):i=Og(this.bytes,n,e),this.pos+=s+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Xs:!1}decodeBinary(e,s){if(e>this.maxBinLength)throw new Me(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+s))throw ma;const n=this.pos+s,i=this.bytes.subarray(n,n+e);return this.pos+=s+e,i}decodeExtension(e,s){if(e>this.maxExtLength)throw new Me(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const n=this.view.getInt8(this.pos+s),i=this.decodeBinary(e,s+1);return this.extensionCodec.decode(i,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=Ag(this.view,this.pos);return this.pos+=8,e}readI64(){const e=Fl(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Jg(t,e){return new Zg(e).decode(t)}function so(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Hl(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?so(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function ss(t,e){e||(e=t.reduce((i,r)=>i+r.length,0));const s=Hl(e);let n=0;for(const i of t)s.set(i,n),n+=i.length;return so(s)}function Qg(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var i=0;i<t.length;i++){var r=t.charAt(i),o=r.charCodeAt(0);if(s[o]!==255)throw new TypeError(r+" is ambiguous");s[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,_=0,v=0,A=f.length;v!==A&&f[v]===0;)v++,g++;for(var S=(A-v)*h+1>>>0,C=new Uint8Array(S);v!==A;){for(var F=f[v],$=0,U=S-1;(F!==0||$<_)&&U!==-1;U--,$++)F+=256*C[U]>>>0,C[U]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");_=$,v++}for(var N=S-_;N!==S&&C[N]===0;)N++;for(var k=c.repeat(g);N<S;++N)k+=t.charAt(C[N]);return k}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var _=0,v=0;f[g]===c;)_++,g++;for(var A=(f.length-g)*l+1>>>0,S=new Uint8Array(A);f[g];){var C=s[f.charCodeAt(g)];if(C===255)return;for(var F=0,$=A-1;(C!==0||F<v)&&$!==-1;$--,F++)C+=a*S[$]>>>0,S[$]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");v=F,g++}if(f[g]!==" "){for(var U=A-v;U!==A&&S[U]===0;)U++;for(var N=new Uint8Array(_+(A-U)),k=_;U!==A;)N[k++]=S[U++];return N}}}function p(f){var g=d(f);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:d,decode:p}}var e_=Qg,t_=e_;const s_=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},n_=t=>new TextEncoder().encode(t),i_=t=>new TextDecoder().decode(t);class r_{constructor(e,s,n){this.name=e,this.prefix=s,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class o_{constructor(e,s,n){if(this.name=e,this.prefix=s,s.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name}
2 decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Kl(this,e)}}class a_{constructor(e){this.decoders=e}or(e){return Kl(this,e)}decode(e){const s=e[0],n=this.decoders[s];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Kl=(t,e)=>new a_({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class c_{constructor(e,s,n,i){this.name=e,this.prefix=s,this.baseEncode=n,this.baseDecode=i,this.encoder=new r_(e,s,n),this.decoder=new o_(e,s,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const yi=({name:t,prefix:e,encode:s,decode:n})=>new c_(t,e,s,n),pn=({prefix:t,name:e,alphabet:s})=>{const{encode:n,decode:i}=t_(s,e);return yi({prefix:t,name:e,encode:n,decode:r=>s_(i(r))})},l_=(t,e,s,n)=>{const i={};for(let h=0;h<e.length;++h)i[e[h]]=h;let r=t.length;for(;t[r-1]==="=";)--r;const o=new Uint8Array(r*s/8|0);let a=0,c=0,l=0;for(let h=0;h<r;++h){const u=i[t[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<s|u,a+=s,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},h_=(t,e,s)=>{const n=e[e.length-1]==="=",i=(1<<s)-1;let r="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>s;)o-=s,r+=e[i&a>>o];if(o&&(r+=e[i&a<<s-o]),n)for(;r.length*s&7;)r+="=";return r},Ee=({name:t,prefix:e,bitsPerChar:s,alphabet:n})=>yi({prefix:e,name:t,encode(i){return h_(i,n,s)},decode(i){return l_(i,n,s,t)}}),u_=yi({prefix:"\0",name:"identity",encode:t=>i_(t),decode:t=>n_(t)}),d_=Object.freeze(Object.defineProperty({__proto__:null,identity:u_},Symbol.toStringTag,{value:"Module"})),p_=Ee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),f_=Object.freeze(Object.defineProperty({__proto__:null,base2:p_},Symbol.toStringTag,{value:"Module"})),g_=Ee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),__=Object.freeze(Object.defineProperty({__proto__:null,base8:g_},Symbol.toStringTag,{value:"Module"})),m_=pn({prefix:"9",name:"base10",alphabet:"0123456789"}),y_=Object.freeze(Object.defineProperty({__proto__:null,base10:m_},Symbol.toStringTag,{value:"Module"})),w_=Ee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),b_=Ee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),E_=Object.freeze(Object.defineProperty({__proto__:null,base16:w_,base16upper:b_},Symbol.toStringTag,{value:"Module"})),v_=Ee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),I_=Ee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),S_=Ee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),x_=Ee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),D_=Ee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),O_=Ee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),k_=Ee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),A_=Ee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),T_=Ee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),R_=Object.freeze(Object.defineProperty({__proto__:null,base32:v_,base32hex:D_,base32hexpad:k_,base32hexpadupper:A_,base32hexupper:O_,base32pad:S_,base32padupper:x_,base32upper:I_,base32z:T_},Symbol.toStringTag,{value:"Module"})),P_=pn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$_=pn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),N_=Object.freeze(Object.defineProperty({__proto__:null,base36:P_,base36upper:$_},Symbol.toStringTag,{value:"Module"})),C_=pn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),B_=pn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),U_=Object.freeze(Object.defineProperty({__proto__:null,base58btc:C_,base58flickr:B_},Symbol.toStringTag,{value:"Module"})),M_=Ee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
2+/",bitsPerChar:6}),L_=Ee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),F_=Ee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),q_=Ee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),z_=Object.freeze(Object.defineProperty({__proto__:null,base64:M_,base64pad:L_,base64url:F_,base64urlpad:q_},Symbol.toStringTag,{value:"Module"})),Vl=Array.from("ððªâð°ðððððððððððððâð»ð¥ð¾ð¿ðâ¤ðð¤£ððððððð
ððð¥ð¥°ðððð¢ð¤ðððªðâºðð¤ððððð¹ð¤¦ððââ¨ð¤·ð±ðð¸ððððððððð¤©ððð¤ðð¯ððð¶ðð¤â£ððððªðð¥ððð©ð¡ð¤ªðð¥³ð¥ð¤¤ððð³âððð´ðð¬ððð·ð»ðââ
ð¥ºððð¤ð¦âð£ððâ¹ððð âððºðð»ððððð¹ð£ð«ðððµð¤ðð´ð¤ð¼ð«â½ð¤âðð¤«ðð®ðð»ðð¶ðð²ð¿ð§¡ðâ¡ððââðð°ð¤¨ð¶ð¤ð¶ð°ðð¢ð¤ðð¨ð¨ð¤¬âððºð¤ððð±ðð¶ð¥´â¶â¡âðð¸â¬ð¨ðð¦ð·ðºâ ð
ððµðð¤²ð¤ ð¤§ððµð
ð§ð¾ððð¤ðð¤¯ð·âð§ð¯ððð¤ððâð´ð£ð¸ððð¥ð¤¢ð
ð¡ð©ðð¸ð»ð¤ð¤®ð¼ð¥µð©ððð¼ðð£ð¥"),j_=Vl.reduce((t,e,s)=>(t[s]=e,t),[]),H_=Vl.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function K_(t){return t.reduce((e,s)=>(e+=j_[s],e),"")}function V_(t){const e=[];for(const s of t){const n=H_[s.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(n)}return new Uint8Array(e)}const G_=yi({prefix:"ð",name:"base256emoji",encode:K_,decode:V_}),W_=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:G_},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const ya={...d_,...f_,...__,...y_,...E_,...R_,...N_,...U_,...z_,...W_};function Gl(t,e,s,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:n}}}const wa=Gl("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ji=Gl("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=Hl(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),Wl={utf8:wa,"utf-8":wa,hex:ya.base16,latin1:ji,ascii:ji,binary:ji,...ya};function De(t,e="utf8"){const s=Wl[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?so(globalThis.Buffer.from(t,"utf-8")):s.decoder.decode(`${s.prefix}${t}`)}function _e(t,e="utf8"){const s=Wl[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):s.encoder.encode(t).substring(1)}const Yl=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),Y_=Yl("expand 16-byte k"),X_=Yl("expand 32-byte k"),Z_=Mt(Y_),J_=Mt(X_);function J(t,e){return t<<e|t>>>32-e}function Ir(t){return t.byteOffset%4===0}const vn=64,Q_=16,Xl=2**32-1,ba=new Uint32Array;function em(t,e,s,n,i,r,o,a){const c=i.length,l=new Uint8Array(vn),h=Mt(l),u=Ir(i)&&Ir(r),d=u?Mt(i):ba,p=u?Mt(r):ba;for(let f=0;f<c;o++){if(t(e,s,n,h,o,a),o>=Xl)throw new Error("arx: counter overflow");const g=Math.min(vn,c-f);if(u&&g===vn){const _=f/4;if(f%4!==0)throw new Error("arx: invalid block position");for(let v=0,A;v<Q_;v++)A=_+v,p[A]=d[A]^h[v];f+=vn;continue}for(let _=0,v;_<g;_++)v=f+_,r[v]=i[v]^l[_];f+=g}}function tm(t,e){const{allowShortKeys:s,extendNonceFn:n,counterLength:i,counterRight:r,rounds:o}=_p({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Ci(i),Ci(o),gr(r),gr(s),(a,c,l,h,u=0)=>{Pe(a),Pe(c),Pe(l);const d=l.length;if(h===void 0&&(h=new Uint8Array(d)),Pe(h),Ci(u),u<0||u>=Xl)throw new Error("arx: counter overflow");if(h.length<d)throw new Error(`arx: output (${h.length}) is shorter than data (${d})`);const p=[];let f=a.length,g,_;if(f===32)p.push(g=mr(a)),_=J_;
vendor: 14,657 bytes, line 2
2else if(f===16&&s)g=new Uint8Array(32),g.set(a),g.set(a,16),_=Z_,p.push(g);else throw new Error(`arx: invalid 32-byte key, got length=${f}`);Ir(c)||p.push(c=mr(c));const v=Mt(g);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(_,v,Mt(c.subarray(0,16)),v),c=c.subarray(16)}const A=16-i;if(A!==c.length)throw new Error(`arx: nonce must be ${A} or 16 bytes`);if(A!==12){const C=new Uint8Array(12);C.set(c,r?0:12-c.length),c=C,p.push(c)}const S=Mt(c);return em(t,_,v,S,l,h,u,o),Ps(...p),h}}const me=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class sm{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=_r(e),Pe(e,32);const s=me(e,0),n=me(e,2),i=me(e,4),r=me(e,6),o=me(e,8),a=me(e,10),c=me(e,12),l=me(e,14);this.r[0]=s&8191,this.r[1]=(s>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|r<<9)&8191,this.r[4]=(r>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let h=0;h<8;h++)this.pad[h]=me(e,16+2*h)}process(e,s,n=!1){const i=n?0:2048,{h:r,r:o}=this,a=o[0],c=o[1],l=o[2],h=o[3],u=o[4],d=o[5],p=o[6],f=o[7],g=o[8],_=o[9],v=me(e,s+0),A=me(e,s+2),S=me(e,s+4),C=me(e,s+6),F=me(e,s+8),$=me(e,s+10),U=me(e,s+12),N=me(e,s+14);let k=r[0]+(v&8191),M=r[1]+((v>>>13|A<<3)&8191),H=r[2]+((A>>>10|S<<6)&8191),B=r[3]+((S>>>7|C<<9)&8191),b=r[4]+((C>>>4|F<<12)&8191),E=r[5]+(F>>>1&8191),m=r[6]+((F>>>14|$<<2)&8191),y=r[7]+(($>>>11|U<<5)&8191),I=r[8]+((U>>>8|N<<8)&8191),D=r[9]+(N>>>5|i),w=0,x=w+k*a+M*(5*_)+H*(5*g)+B*(5*f)+b*(5*p);w=x>>>13,x&=8191,x+=E*(5*d)+m*(5*u)+y*(5*h)+I*(5*l)+D*(5*c),w+=x>>>13,x&=8191;let O=w+k*c+M*a+H*(5*_)+B*(5*g)+b*(5*f);w=O>>>13,O&=8191,O+=E*(5*p)+m*(5*d)+y*(5*u)+I*(5*h)+D*(5*l),w+=O>>>13,O&=8191;let T=w+k*l+M*c+H*a+B*(5*_)+b*(5*g);w=T>>>13,T&=8191,T+=E*(5*f)+m*(5*p)+y*(5*d)+I*(5*u)+D*(5*h),w+=T>>>13,T&=8191;let j=w+k*h+M*l+H*c+B*a+b*(5*_);w=j>>>13,j&=8191,j+=E*(5*g)+m*(5*f)+y*(5*p)+I*(5*d)+D*(5*u),w+=j>>>13,j&=8191;let z=w+k*u+M*h+H*l+B*c+b*a;w=z>>>13,z&=8191,z+=E*(5*_)+m*(5*g)+y*(5*f)+I*(5*p)+D*(5*d),w+=z>>>13,z&=8191;let q=w+k*d+M*u+H*h+B*l+b*c;w=q>>>13,q&=8191,q+=E*a+m*(5*_)+y*(5*g)+I*(5*f)+D*(5*p),w+=q>>>13,q&=8191;let K=w+k*p+M*d+H*u+B*h+b*l;w=K>>>13,K&=8191,K+=E*c+m*a+y*(5*_)+I*(5*g)+D*(5*f),w+=K>>>13,K&=8191;let W=w+k*f+M*p+H*d+B*u+b*h;w=W>>>13,W&=8191,W+=E*l+m*c+y*a+I*(5*_)+D*(5*g),w+=W>>>13,W&=8191;let Z=w+k*g+M*f+H*p+B*d+b*u;w=Z>>>13,Z&=8191,Z+=E*h+m*l+y*c+I*a+D*(5*_),w+=Z>>>13,Z&=8191;let V=w+k*_+M*g+H*f+B*p+b*d;w=V>>>13,V&=8191,V+=E*u+m*h+y*l+I*c+D*a,w+=V>>>13,V&=8191,w=(w<<2)+w|0,w=w+x|0,x=w&8191,w=w>>>13,O+=w,r[0]=x,r[1]=O,r[2]=T,r[3]=j,r[4]=z,r[5]=q,r[6]=K,r[7]=W,r[8]=Z,r[9]=V}finalize(){const{h:e,pad:s}=this,n=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let r=(i^1)-1;for(let a=0;a<10;a++)n[a]&=r;r=~r;for(let a=0;a<10;a++)e[a]=e[a]&r|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+s[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+s[a]|0)+(o>>>16)|0,e[a]=o&65535;Ps(n)}update(e){Wo(this),e=_r(e),Pe(e);const{buffer:s,blockLen:n}=this,i=e.length;for(let r=0;r<i;){const o=Math.min(n-this.pos,i-r);if(o===n){for(;n<=i-r;r+=n)this.process(e,r);continue}s.set(e.subarray(r,r+o),this.pos),this.pos+=o,r+=o,this.pos===n&&(this.process(s,0,!1),this.pos=0)}return this}destroy(){Ps(this.h,this.r,this.buffer,this.pad)}digestInto(e){Wo(this),dp(e,this),this.finished=!0;const{buffer:s,h:n}=this;let{pos:i}=this;if(i){for(s[i++]=1;i<16;i++)s[i]=0;this.process(s,0,!0)}this.finalize();let r=0;for(let o=0;o<8;o++)e[r++]=n[o]>>>0,e[r++]=n[o]>>>8;return e}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}}function nm(t){const e=(n,i)=>t(i).update(_r(n)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=n=>t(n),e}const im=nm(t=>new sm(t));function rm(t,e,s,n,i,r=20){let o=t[0],a=t[1],c=t[2],l=t[3],h=e[0],u=e[1],d=e[2],p=e[3],f=e[4],g=e[5],_=e[6],v=e[7],A=i,S=s[0],C=s[1],F=s[2],$=o,U=a,N=c,k=l,M=h,H=u,B=d,b=p,E=f,m=g,y=_,I=v,D=A,w=S,x=C,O=F;for(let j=0;j<r;j+=2)$=$+M|0,D=J(D^$,16),E=E+D|0,M=J(M^E,12),$=$+M|0,D=J(D^$,8),E=E+D|0,M=J(M^E,7),U=U+H|0,w=J(w^U,16),m=m+w|0,H=J(H^m,12),U=U+H|0,w=J(w^U,8),m=m+w|0,H=J(H^m,7),N=N+B|0,x=J(x^N,16),y=y+x|0,B=J(B^y,12),N=N+B|0,x=J(x^N,8),y=y+x|0,B=J(B^y,7),k=k+b|0,O=J(O^k,16),I=I+O|0,b=J(b^I,12),k=k+b|0,O=J(O^k,8),I=I+O|0,b=J(b^I,7),$=$+H|0,O=J(O^$,16),y=y+O|0,H=J(H^y,12),$=$+H|0,O=J(O^$,8),y=y+O|0,H=J(H^y,7),U=U+B|0,D=J(D^U,16),I=I+D|0,B=J(B^I,12),U=U+B|0,D=J(D^U,8),I=I+D|0,B=J(B^I,7),N=N+b|0,w=J(w^N,16),E=E+w|0,b=J(b^E,12),N=N+b|0,w=J(w^N,8),E=E+w|0,b=J(b^E,7),k=k+M|0,x=J(x^k,16),m=m+x|0,M=J(M^m,12),k=k+M|0,x=J(x^k,8),m=m+x|0,M=J(M^m,7);let T=0;n[T++]=o+$|0,n[T++]=a+U|0,n[T++]=c+N|0,n[T++]=l+k|0,n[T++]=h+M|0,n[T++]=u+H|0,n[T++]=d+B|0,n[T++]=p+b|0,n[T++]=f+E|0,n[T++]=g+m|0,n[T++]=_+y|0,n[T++]=v+I|0,n[T++]=A+D|0,n[T++]=S+w|0,n[T++]=C+x|0,n[T++]=F+O|0}const om=tm(rm,{counterRight:!1,counterLength:4,allowShortKeys:!1}),am=new Uint8Array(16),Ea=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(am.subarray(s))},cm=new Uint8Array(32);function va(t,e,s,n,i){const r=t(e,s,cm),o=im.create(r);i&&Ea(o,i),Ea(o,n);const a=wp(n.length,i?i.length:0,!0);o.update(a);const c=o.digest();return Ps(r,a),c}const lm=t=>(e,s,n)=>({encrypt(r,o){const a=r.length;o=Yo(a+16,o,!1),o.set(r);const c=o.subarray(0,-16);t(e,s,c,c,1);const l=va(t,e,s,c,n);return o.set(l,a),Ps(l),o},decrypt(r,o){o=Yo(r.length-16,o,!1);const a=r.subarray(0,-16),c=r.subarray(-16),l=va(t,e,s,a,n);if(!mp(c,l))throw new Error("invalid tag");return o.set(r.subarray(0,-16)),t(e,s,o,o,1),Ps(l),o}}),Zl=yp({blockSize:64,nonceLength:12,tagLength:16},lm(om));function hm(t,e,s){return zr(t),s===void 0&&(s=new Uint8Array(t.outputLen)),jr(t,Ss(s),Ss(e))}const Hi=Uint8Array.from([0]),Ia=Uint8Array.of();function um(t,e,s,n=32){zr(t),sn(n);const i=t.outputLen;if(n>255*i)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(n/i);s===void 0&&(s=Ia);const o=new Uint8Array(r*i),a=jr.create(t,e),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let h=0;h<r;h++)Hi[0]=h+1,c.update(h===0?Ia:l).update(s).update(Hi).digestInto(l),o.set(l,i*h),a._cloneInto(c);return a.destroy(),c.destroy(),Gn(l,Hi),o.slice(0,n)}const dm=(t,e,s,n,i)=>um(t,hm(t,e,s),n,i);const qs=BigInt(0),ms=BigInt(1),In=BigInt(2);function pm(t){return mi(t,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...t})}function fm(t){const e=pm(t),{P:s,type:n,adjustScalarBytes:i,powPminus2:r,randomBytes:o}=e,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");const c=o||cs,l=a?255:448,h=a?32:56,u=BigInt(a?9:5),d=BigInt(a?121665:39081),p=a?In**BigInt(254):In**BigInt(447),f=a?BigInt(8)*In**BigInt(251)-ms:BigInt(4)*In**BigInt(445)-ms,g=p+f+ms,_=b=>Ue(b,s),v=A(u);function A(b){return Wr(_(b),h)}function S(b){const E=xe("u coordinate",b,h);return a&&(E[31]&=127),_(Xn(E))}function C(b){return Xn(i(xe("scalar",b,h)))}function F(b,E){const m=N(S(E),C(b));if(m===qs)throw new Error("invalid private or public key received");return A(m)}function $(b){return F(b,v)}function U(b,E,m){const y=_(b*(E-m));return E=_(E-y),m=_(m+y),{x_2:E,x_3:m}}function N(b,E){pr("u",b,qs,s),pr("scalar",E,p,g);const m=E,y=b;let I=ms,D=qs,w=b,x=ms,O=qs;for(let j=BigInt(l-1);j>=qs;j--){const z=m>>j&ms;O^=z,{x_2:I,x_3:w}=U(O,I,w),{x_2:D,x_3:x}=U(O,D,x),O=z;const q=I+D,K=_(q*q),W=I-D,Z=_(W*W),V=K-Z,ee=w+x,pe=w-x,Ce=_(pe*q),et=_(ee*W),ut=Ce+et,ps=Ce-et;w=_(ut*ut),x=_(y*_(ps*ps)),I=_(K*Z),D=_(V*(K+_(d*V)))}({x_2:I,x_3:w}=U(O,I,w)),{x_2:D,x_3:x}=U(O,D,x);const T=r(D);return _(I*T)}const k={secretKey:h,publicKey:h,seed:h},M=(b=c(h))=>(Fr(b,k.seed),b);function H(b){const E=M(b);return{secretKey:E,publicKey:$(E)}}return{keygen:H,getSharedSecret:(b,E)=>F(b,E),getPublicKey:b=>$(b),scalarMult:F,scalarMultBase:$,utils:{randomSecretKey:M,randomPrivateKey:M},GuBytes:v.slice(),lengths:k}}const gm=BigInt(1),Sa=BigInt(2),_m=BigInt(3),mm=BigInt(5),ym=BigInt(8),Jl=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),wm=(()=>({p:Jl,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:ym,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function bm(t){const e=BigInt(10),s=BigInt(20),n=BigInt(40),i=BigInt(80),r=Jl,a=t*t%r*t%r,c=Xe(a,Sa,r)*a%r,l=Xe(c,gm,r)*t%r,h=Xe(l,mm,r)*l%r,u=Xe(h,e,r)*h%r,d=Xe(u,s,r)*u%r,p=Xe(d,n,r)*d%r,f=Xe(p,i,r)*p%r,g=Xe(f,i,r)*p%r,_=Xe(g,e,r)*h%r;return{pow_p_5_8:Xe(_,Sa,r)*t%r,b2:a}}function Em(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const vm=(()=>zt(wm.p,{isLE:!0}))(),Sr=(()=>{const t=vm.ORDER;return fm({P:t,type:"x25519",powPminus2:e=>{const{pow_p_5_8:s,b2:n}=bm(e);return Ue(Xe(s,_m,t)*n,t)},adjustScalarBytes:Em})})(),Im=t=>JSON.stringify(t,(e,s)=>typeof s=="bigint"?s.toString()+"n":s),Sm=t=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,s=t.replace(e,'$1"$2n"$3');return JSON.parse(s,(n,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function is(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return Sm(t)}catch{return t}}function rs(t){return typeof t=="string"?t:Im(t)||""}function xm(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ql(t,...e){if(!xm(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function xa(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Dm(t,e){Ql(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const ys=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;const Ki=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);function Om(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function eh(t){return typeof t=="string"&&(t=Om(t)),Ql(t),t}let km=class{clone(){return this._cloneInto()}};function Am(t){const e=n=>t().update(eh(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function th(t=32){if(ys&&typeof ys.getRandomValues=="function")return ys.getRandomValues(new Uint8Array(t));if(ys&&typeof ys.randomBytes=="function")return ys.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Tm(t,e,s,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,n);const i=BigInt(32),r=BigInt(4294967295),o=Number(s>>i&r),a=Number(s&r),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}let Rm=class extends km{constructor(e,s,n,i){super(),this.blockLen=e,this.outputLen=s,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ki(this.buffer)}update(e){xa(this);const{view:s,buffer:n,blockLen:i}=this;e=eh(e);const r=e.length;for(let o=0;o<r;){const a=Math.min(i-this.pos,r-o);if(a===i){const c=Ki(e);for(;i<=r-o;o+=i)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(s,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){xa(this),Dm(e,this),this.finished=!0;const{buffer:s,view:n,blockLen:i,isLE:r}=this;let{pos:o}=this;s[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let u=o;u<i;u++)s[u]=0;Tm(n,i-8,BigInt(this.length*8),r),this.process(n,0);const a=Ki(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,h[u],r)}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:s,buffer:n,length:i,finished:r,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=r,e.destroyed=o,i%s&&e.buffer.set(n),e}};const Sn=BigInt(2**32-1),xr=BigInt(32);function sh(t,e=!1){return e?{h:Number(t&Sn),l:Number(t>>xr&Sn)}:{h:Number(t>>xr&Sn)|0,l:Number(t&Sn)|0}}function Pm(t,e=!1){let s=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:r,l:o}=sh(t[i],e);[s[i],n[i]]=[r,o]}return[s,n]}const $m=(t,e)=>BigInt(t>>>0)<<xr|BigInt(e>>>0),Nm=(t,e,s)=>t>>>s,Cm=(t,e,s)=>t<<32-s|e>>>s,Bm=(t,e,s)=>t>>>s|e<<32-s,Um=(t,e,s)=>t<<32-s|e>>>s,Mm=(t,e,s)=>t<<64-s|e>>>s-32,Lm=(t,e,s)=>t>>>s-32|e<<64-s,Fm=(t,e)=>e,qm=(t,e)=>t,zm=(t,e,s)=>t<<s|e>>>32-s,jm=(t,e,s)=>e<<s|t>>>32-s,Hm=(t,e,s)=>e<<s-32|t>>>64-s,Km=(t,e,s)=>t<<s-32|e>>>64-s;function Vm(t,e,s,n){const i=(e>>>0)+(n>>>0);return{h:t+s+(i/2**32|0)|0,l:i|0}}const Gm=(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0),Wm=(t,e,s,n)=>e+s+n+(t/2**32|0)|0,Ym=(t,e,s,n)=>(t>>>0)+(e>>>0)+(s>>>0)+(n>>>0),Xm=(t,e,s,n,i)=>e+s+n+i+(t/2**32|0)|0,Zm=(t,e,s,n,i)=>(t>>>0)+(e>>>0)+(s>>>0)+(n>>>0)+(i>>>0),Jm=(t,e,s,n,i,r)=>e+s+n+i+r+(t/2**32|0)|0,X={fromBig:sh,split:Pm,toBig:$m,shrSH:Nm,shrSL:Cm,rotrSH:Bm,rotrSL:Um,rotrBH:Mm,rotrBL:Lm,rotr32H:Fm,rotr32L:qm,rotlSH:zm,rotlSL:jm,rotlBH:Hm,rotlBL:Km,add:Vm,add3L:Gm,add3H:Wm,add4L:Ym,add4H:Xm,add5H:Jm,add5L:Zm},[Qm,ey]=(()=>X.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b89
26f","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(t=>BigInt(t))))(),Ot=new Uint32Array(80),kt=new Uint32Array(80);let ty=class extends Rm{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:s,Bh:n,Bl:i,Ch:r,Cl:o,Dh:a,Dl:c,Eh:l,El:h,Fh:u,Fl:d,Gh:p,Gl:f,Hh:g,Hl:_}=this;return[e,s,n,i,r,o,a,c,l,h,u,d,p,f,g,_]}set(e,s,n,i,r,o,a,c,l,h,u,d,p,f,g,_){this.Ah=e|0,this.Al=s|0,this.Bh=n|0,this.Bl=i|0,this.Ch=r|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=u|0,this.Fl=d|0,this.Gh=p|0,this.Gl=f|0,this.Hh=g|0,this.Hl=_|0}process(e,s){for(let S=0;S<16;S++,s+=4)Ot[S]=e.getUint32(s),kt[S]=e.getUint32(s+=4);for(let S=16;S<80;S++){const C=Ot[S-15]|0,F=kt[S-15]|0,$=X.rotrSH(C,F,1)^X.rotrSH(C,F,8)^X.shrSH(C,F,7),U=X.rotrSL(C,F,1)^X.rotrSL(C,F,8)^X.shrSL(C,F,7),N=Ot[S-2]|0,k=kt[S-2]|0,M=X.rotrSH(N,k,19)^X.rotrBH(N,k,61)^X.shrSH(N,k,6),H=X.rotrSL(N,k,19)^X.rotrBL(N,k,61)^X.shrSL(N,k,6),B=X.add4L(U,H,kt[S-7],kt[S-16]),b=X.add4H(B,$,M,Ot[S-7],Ot[S-16]);Ot[S]=b|0,kt[S]=B|0}let{Ah:n,Al:i,Bh:r,Bl:o,Ch:a,Cl:c,Dh:l,Dl:h,Eh:u,El:d,Fh:p,Fl:f,Gh:g,Gl:_,Hh:v,Hl:A}=this;for(let S=0;S<80;S++){const C=X.rotrSH(u,d,14)^X.rotrSH(u,d,18)^X.rotrBH(u,d,41),F=X.rotrSL(u,d,14)^X.rotrSL(u,d,18)^X.rotrBL(u,d,41),$=u&p^~u&g,U=d&f^~d&_,N=X.add5L(A,F,U,ey[S],kt[S]),k=X.add5H(N,v,C,$,Qm[S],Ot[S]),M=N|0,H=X.rotrSH(n,i,28)^X.rotrBH(n,i,34)^X.rotrBH(n,i,39),B=X.rotrSL(n,i,28)^X.rotrBL(n,i,34)^X.rotrBL(n,i,39),b=n&r^n&a^r&a,E=i&o^i&c^o&c;v=g|0,A=_|0,g=p|0,_=f|0,p=u|0,f=d|0,{h:u,l:d}=X.add(l|0,h|0,k|0,M|0),l=a|0,h=c|0,a=r|0,c=o|0,r=n|0,o=i|0;const m=X.add3L(M,B,E);n=X.add3H(m,k,H,b),i=m|0}({h:n,l:i}=X.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:r,l:o}=X.add(this.Bh|0,this.Bl|0,r|0,o|0),{h:a,l:c}=X.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=X.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:u,l:d}=X.add(this.Eh|0,this.El|0,u|0,d|0),{h:p,l:f}=X.add(this.Fh|0,this.Fl|0,p|0,f|0),{h:g,l:_}=X.add(this.Gh|0,this.Gl|0,g|0,_|0),{h:v,l:A}=X.add(this.Hh|0,this.Hl|0,v|0,A|0),this.set(n,i,r,o,a,c,l,h,u,d,p,f,g,_,v,A)}roundClean(){Ot.fill(0),kt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};const sy=Am(()=>new ty);const no=BigInt(0),nh=BigInt(1),ny=BigInt(2);function io(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ro(t){if(!io(t))throw new Error("Uint8Array expected")}function Vi(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}const iy=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function oo(t){ro(t);let e="";for(let s=0;s<t.length;s++)e+=iy[t[s]];return e}function ih(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?no:BigInt("0x"+t)}const pt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Da(t){if(t>=pt._0&&t<=pt._9)return t-pt._0;if(t>=pt.A&&t<=pt.F)return t-(pt.A-10);if(t>=pt.a&&t<=pt.f)return t-(pt.a-10)}function rh(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(s);for(let i=0,r=0;i<s;i++,r+=2){const o=Da(t.charCodeAt(r)),a=Da(t.charCodeAt(r+1));if(o===void 0||a===void 0){const c=t[r]+t[r+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+r)}n[i]=o*16+a}return n}function ry(t){return ih(oo(t))}function Mn(t){return ro(t),ih(oo(Uint8Array.from(t).reverse()))}function oh(t,e){return rh(t.toString(16).padStart(e*2,"0"))}function Dr(t,e){return oh(t,e).reverse()}function ft(t,e,s){let n;if(typeof e=="string")try{n=rh(e)}catch(r){throw new Error(t+" must be hex string or Uint8Array, cause: "+r)}else if(io(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=n.length;if(typeof s=="number"&&i!==s)throw new Error(t+" of length "+s+" expected, got "+i);return n}function Oa(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];ro(i),e+=i.length}const s=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const r=t[n];s.set(r,i),i+=r.length}return s}const Gi=t=>typeof t=="bigint"&&no<=t;function oy(t,e,s){return Gi(t)&&Gi(e)&&Gi(s)&&e<=t&&t<s}function zs(t,e,s,n){if(!oy(e,s,n))throw new Error("expected valid "+t+": "+s+" <= n < "+n+", got "+e)}function ay(t){let e;for(e=0;t>no;t>>=nh,e+=1);return e}const cy=t=>(ny<<BigInt(t-1))-nh,ly={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||io(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ao(t,e,s={}){const n=(i,r,o)=>{const a=ly[r];if(typeof a!="function")throw new Error("invalid validator function");const c=t[i];if(!(o&&c===void 0)&&!a(c,t))throw new Error("param "+String(i)+" is invali
2d. Expected "+r+", got "+c)};for(const[i,r]of Object.entries(e))n(i,r,!1);for(const[i,r]of Object.entries(s))n(i,r,!0);return t}function ka(t){const e=new WeakMap;return(s,...n)=>{const i=e.get(s);if(i!==void 0)return i;const r=t(s,...n);return e.set(s,r),r}}const ge=BigInt(0),ae=BigInt(1),Xt=BigInt(2),hy=BigInt(3),Or=BigInt(4),Aa=BigInt(5),Ta=BigInt(8);function ue(t,e){const s=t%e;return s>=ge?s:e+s}function uy(t,e,s){if(e<ge)throw new Error("invalid exponent, negatives unsupported");if(s<=ge)throw new Error("invalid modulus");if(s===ae)return ge;let n=ae;for(;e>ge;)e&ae&&(n=n*t%s),t=t*t%s,e>>=ae;return n}function tt(t,e,s){let n=t;for(;e-- >ge;)n*=n,n%=s;return n}function Ra(t,e){if(t===ge)throw new Error("invert: expected non-zero number");if(e<=ge)throw new Error("invert: expected positive modulus, got "+e);let s=ue(t,e),n=e,i=ge,r=ae;for(;s!==ge;){const o=n/s,a=n%s,c=i-r*o;n=s,s=a,i=r,r=c}if(n!==ae)throw new Error("invert: does not exist");return ue(i,e)}function dy(t){const e=(t-ae)/Xt;let s,n,i;for(s=t-ae,n=0;s%Xt===ge;s/=Xt,n++);for(i=Xt;i<t&&uy(i,e,t)!==t-ae;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const o=(t+ae)/Or;return function(a,c){const l=a.pow(c,o);if(!a.eql(a.sqr(l),c))throw new Error("Cannot find square root");return l}}const r=(s+ae)/Xt;return function(o,a){if(o.pow(a,e)===o.neg(o.ONE))throw new Error("Cannot find square root");let c=n,l=o.pow(o.mul(o.ONE,i),s),h=o.pow(a,r),u=o.pow(a,s);for(;!o.eql(u,o.ONE);){if(o.eql(u,o.ZERO))return o.ZERO;let d=1;for(let f=o.sqr(u);d<c&&!o.eql(f,o.ONE);d++)f=o.sqr(f);const p=o.pow(l,ae<<BigInt(c-d-1));l=o.sqr(p),h=o.mul(h,p),u=o.mul(u,l),c=d}return h}}function py(t){if(t%Or===hy){const e=(t+ae)/Or;return function(s,n){const i=s.pow(n,e);if(!s.eql(s.sqr(i),n))throw new Error("Cannot find square root");return i}}if(t%Ta===Aa){const e=(t-Aa)/Ta;return function(s,n){const i=s.mul(n,Xt),r=s.pow(i,e),o=s.mul(n,r),a=s.mul(s.mul(o,Xt),r),c=s.mul(o,s.sub(a,s.ONE));if(!s.eql(s.sqr(c),n))throw new Error("Cannot find square root");return c}}return dy(t)}const fy=(t,e)=>(ue(t,e)&ae)===ae,gy=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function _y(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},s=gy.reduce((n,i)=>(n[i]="function",n),e);return ao(t,s)}function my(t,e,s){if(s<ge)throw new Error("invalid exponent, negatives unsupported");if(s===ge)return t.ONE;if(s===ae)return e;let n=t.ONE,i=e;for(;s>ge;)s&ae&&(n=t.mul(n,i)),i=t.sqr(i),s>>=ae;return n}function yy(t,e){const s=new Array(e.length),n=e.reduce((r,o,a)=>t.is0(o)?r:(s[a]=r,t.mul(r,o)),t.ONE),i=t.inv(n);return e.reduceRight((r,o,a)=>t.is0(o)?r:(s[a]=t.mul(r,s[a]),t.mul(r,o)),i),s}function ah(t,e){const s=e!==void 0?e:t.toString(2).length,n=Math.ceil(s/8);return{nBitLength:s,nByteLength:n}}function ch(t,e,s=!1,n={}){if(t<=ge)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:r}=ah(t,e);if(r>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:s,BITS:i,BYTES:r,MASK:cy(i),ZERO:ge,ONE:ae,create:c=>ue(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ge<=c&&c<t},is0:c=>c===ge,isOdd:c=>(c&ae)===ae,neg:c=>ue(-c,t),eql:(c,l)=>c===l,sqr:c=>ue(c*c,t),add:(c,l)=>ue(c+l,t),sub:(c,l)=>ue(c-l,t),mul:(c,l)=>ue(c*l,t),pow:(c,l)=>my(a,c,l),div:(c,l)=>ue(c*Ra(l,t),t),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Ra(c,t),sqrt:n.sqrt||(c=>(o||(o=py(t)),o(a,c))),invertBatch:c=>yy(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>s?Dr(c,r):oh(c,r),fromBytes:c=>{if(c.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+c.length);return s?Mn(c):ry(c)}});return Object.freeze(a)}const Pa=BigInt(0),xn=BigInt(1);function Wi(t,e){const s=e.negate();return t?s:e}function lh(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Yi(t,e){lh(t,e);const s=Math.ceil(e/t)+1,n=2**(t-1);return{windows:s,windowSize:n}}function wy(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((s,n)=>{if(!(s instanceof e))throw new Error("invalid point at index "+n)})}function by(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((s,n)=>{if(!e.isValid(s))throw new Error("invalid scalar at index "+n)})}const Xi=new WeakMap,hh=new WeakMap;function Zi(t){return hh.get(t)||1}function Ey(t,e){return{constTimeNegate:Wi,hasPrecomputes(s){return Zi(s)!==1},unsafeLadder(s,n,i=t.ZERO){let r=s;for(;n>Pa;)n&xn&&(i=i.add(r)),r=r.double(),n>>=xn;return i},precomputeWindow(s,n){const{windows:i,windowSize:r}=Yi(n,e),o=[];let a=s,c=a;for(let l=0;l<i;l++){c=a,o.push(c);for(let h=1;h<r;h++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(s,n,i){const{windows:r,windowSize:o}=Yi(s,e);let a=t.ZERO,c=t.BASE;const l=BigInt(2**s-1),h=2**s,u=BigInt(s);for(let d=0;d<r;d++){const p=d*o;let f=Number(i&l);i>>=u,f>o&&(f-=h,i+=xn);const g=p,_=p+Math.abs(f)-1,v=d%2!==0,A=f<0;f===0?c=c.add(Wi(v,n[g])):a=a.add(Wi(A,n[_]))}return{p:a,f:c}},wNAFUnsafe(s,n,i,r=t.ZERO){const{windows:o,windowSize:a}=Yi(s,e),c=BigInt(2**s-1),l=2**s,h=BigInt(s);for(let u=0;u<o;u++){const d=u*a;if(i===Pa)break;let p=Number(i&c);if(i>>=h,p>a&&(p-=l,i+=xn),p===0)continue;let f=n[d+Math.abs(p)-1];p<0&&(f=f.negate()),r=r.add(f)}return r}
vendor: 3,260 bytes, line 2
2,getPrecomputes(s,n,i){let r=Xi.get(n);return r||(r=this.precomputeWindow(n,s),s!==1&&Xi.set(n,i(r))),r},wNAFCached(s,n,i){const r=Zi(s);return this.wNAF(r,this.getPrecomputes(r,s,i),n)},wNAFCachedUnsafe(s,n,i,r){const o=Zi(s);return o===1?this.unsafeLadder(s,n,r):this.wNAFUnsafe(o,this.getPrecomputes(o,s,i),n,r)},setWindowSize(s,n){lh(n,e),hh.set(s,n),Xi.delete(s)}}}function vy(t,e,s,n){if(wy(s,t),by(n,e),s.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const i=t.ZERO,r=ay(BigInt(s.length)),o=r>12?r-3:r>4?r-2:r?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i),l=Math.floor((e.BITS-1)/o)*o;let h=i;for(let u=l;u>=0;u-=o){c.fill(i);for(let p=0;p<n.length;p++){const f=n[p],g=Number(f>>BigInt(u)&BigInt(a));c[g]=c[g].add(s[p])}let d=i;for(let p=c.length-1,f=i;p>0;p--)f=f.add(c[p]),d=d.add(f);if(h=h.add(d),u!==0)for(let p=0;p<o;p++)h=h.double()}return h}function Iy(t){return _y(t.Fp),ao(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ah(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const Ge=BigInt(0),Ae=BigInt(1),Dn=BigInt(2),Sy=BigInt(8),xy={zip215:!0};function Dy(t){const e=Iy(t);return ao(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Oy(t){const e=Dy(t),{Fp:s,n,prehash:i,hash:r,randomBytes:o,nByteLength:a,h:c}=e,l=Dn<<BigInt(a*8)-Ae,h=s.create,u=ch(e.n,e.nBitLength),d=e.uvRatio||((m,y)=>{try{return{isValid:!0,value:s.sqrt(m*s.inv(y))}}catch{return{isValid:!1,value:Ge}}}),p=e.adjustScalarBytes||(m=>m),f=e.domain||((m,y,I)=>{if(Vi("phflag",I),y.length||I)throw new Error("Contexts/pre-hash are not supported");return m});function g(m,y){zs("coordinate "+m,y,Ge,l)}function _(m){if(!(m instanceof S))throw new Error("ExtendedPoint expected")}const v=ka((m,y)=>{const{ex:I,ey:D,ez:w}=m,x=m.is0();y==null&&(y=x?Sy:s.inv(w));const O=h(I*y),T=h(D*y),j=h(w*y);if(x)return{x:Ge,y:Ae};if(j!==Ae)throw new Error("invZ was invalid");return{x:O,y:T}}),A=ka(m=>{const{a:y,d:I}=e;if(m.is0())throw new Error("bad point: ZERO");const{ex:D,ey:w,ez:x,et:O}=m,T=h(D*D),j=h(w*w),z=h(x*x),q=h(z*z),K=h(T*y),W=h(z*h(K+j)),Z=h(q+h(I*h(T*j)));if(W!==Z)throw new Error("bad point: equation left != right (1)");const V=h(D*w),ee=h(x*O);if(V!==ee)throw new Error("bad point: equation left != right (2)");return!0});class S{constructor(y,I,D,w){this.ex=y,this.ey=I,this.ez=D,this.et=w,g("x",y),g("y",I),g("z",D),g("t",w),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(y){if(y instanceof S)throw new Error("extended point not allowed");const{x:I,y:D}=y||{};return g("x",I),g("y",D),new S(I,D,Ae,h(I*D))}static normalizeZ(y){const I=s.invertBatch(y.map(D=>D.ez));return y.map((D,w)=>D.toAffine(I[w])).map(S.fromAffine)}static msm(y,I){return vy(S,u,y,I)}_setWindowSize(y){$.setWindowSize(this,y)}assertValidity(){A(this)}equals(y){_(y);const{ex:I,ey:D,ez:w}=this,{ex:x,ey:O,ez:T}=y,j=h(I*T),z=h(x*w),q=h(D*T),K=h(O*w);return j===z&&q===K}is0(){return this.equals(S.ZERO)}negate(){return new S(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:y}=e,{ex:I,ey:D,ez:w}
vendor: 11,678 bytes, line 2
2=this,x=h(I*I),O=h(D*D),T=h(Dn*h(w*w)),j=h(y*x),z=I+D,q=h(h(z*z)-x-O),K=j+O,W=K-T,Z=j-O,V=h(q*W),ee=h(K*Z),pe=h(q*Z),Ce=h(W*K);return new S(V,ee,Ce,pe)}add(y){_(y);const{a:I,d:D}=e,{ex:w,ey:x,ez:O,et:T}=this,{ex:j,ey:z,ez:q,et:K}=y;if(I===BigInt(-1)){const Ro=h((x-w)*(z+j)),Po=h((x+w)*(z-j)),ki=h(Po-Ro);if(ki===Ge)return this.double();const $o=h(O*Dn*K),No=h(T*Dn*q),Co=No+$o,Bo=Po+Ro,Uo=No-$o,cd=h(Co*ki),ld=h(Bo*Uo),hd=h(Co*Uo),ud=h(ki*Bo);return new S(cd,ld,ud,hd)}const W=h(w*j),Z=h(x*z),V=h(T*D*K),ee=h(O*q),pe=h((w+x)*(j+z)-W-Z),Ce=ee-V,et=ee+V,ut=h(Z-I*W),ps=h(pe*Ce),rd=h(et*ut),od=h(pe*ut),ad=h(Ce*et);return new S(ps,rd,ad,od)}subtract(y){return this.add(y.negate())}wNAF(y){return $.wNAFCached(this,y,S.normalizeZ)}multiply(y){const I=y;zs("scalar",I,Ae,n);const{p:D,f:w}=this.wNAF(I);return S.normalizeZ([D,w])[0]}multiplyUnsafe(y,I=S.ZERO){const D=y;return zs("scalar",D,Ge,n),D===Ge?F:this.is0()||D===Ae?this:$.wNAFCachedUnsafe(this,D,S.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return $.unsafeLadder(this,n).is0()}toAffine(y){return v(this,y)}clearCofactor(){const{h:y}=e;return y===Ae?this:this.multiplyUnsafe(y)}static fromHex(y,I=!1){const{d:D,a:w}=e,x=s.BYTES;y=ft("pointHex",y,x),Vi("zip215",I);const O=y.slice(),T=y[x-1];O[x-1]=T&-129;const j=Mn(O),z=I?l:s.ORDER;zs("pointHex.y",j,Ge,z);const q=h(j*j),K=h(q-Ae),W=h(D*q-w);let{isValid:Z,value:V}=d(K,W);if(!Z)throw new Error("Point.fromHex: invalid y coordinate");const ee=(V&Ae)===Ae,pe=(T&128)!==0;if(!I&&V===Ge&&pe)throw new Error("Point.fromHex: x=0 and x_0=1");return pe!==ee&&(V=h(-V)),S.fromAffine({x:V,y:j})}static fromPrivateKey(y){return k(y).point}toRawBytes(){const{x:y,y:I}=this.toAffine(),D=Dr(I,s.BYTES);return D[D.length-1]|=y&Ae?128:0,D}toHex(){return oo(this.toRawBytes())}}S.BASE=new S(e.Gx,e.Gy,Ae,h(e.Gx*e.Gy)),S.ZERO=new S(Ge,Ae,Ae,Ge);const{BASE:C,ZERO:F}=S,$=Ey(S,a*8);function U(m){return ue(m,n)}function N(m){return U(Mn(m))}function k(m){const y=s.BYTES;m=ft("private key",m,y);const I=ft("hashed private key",r(m),2*y),D=p(I.slice(0,y)),w=I.slice(y,2*y),x=N(D),O=C.multiply(x),T=O.toRawBytes();return{head:D,prefix:w,scalar:x,point:O,pointBytes:T}}function M(m){return k(m).pointBytes}function H(m=new Uint8Array,...y){const I=Oa(...y);return N(r(f(I,ft("context",m),!!i)))}function B(m,y,I={}){m=ft("message",m),i&&(m=i(m));const{prefix:D,scalar:w,pointBytes:x}=k(y),O=H(I.context,D,m),T=C.multiply(O).toRawBytes(),j=H(I.context,T,x,m),z=U(O+j*w);zs("signature.s",z,Ge,n);const q=Oa(T,Dr(z,s.BYTES));return ft("result",q,s.BYTES*2)}const b=xy;function E(m,y,I,D=b){const{context:w,zip215:x}=D,O=s.BYTES;m=ft("signature",m,2*O),y=ft("message",y),I=ft("publicKey",I,O),x!==void 0&&Vi("zip215",x),i&&(y=i(y));const T=Mn(m.slice(O,2*O));let j,z,q;try{j=S.fromHex(I,x),z=S.fromHex(m.slice(0,O),x),q=C.multiplyUnsafe(T)}catch{return!1}if(!x&&j.isSmallOrder())return!1;const K=H(w,z.toRawBytes(),j.toRawBytes(),y);return z.add(j.multiplyUnsafe(K)).subtract(q).clearCofactor().equals(S.ZERO)}return C._setWindowSize(8),{CURVE:e,getPublicKey:M,sign:B,verify:E,ExtendedPoint:S,utils:{getExtendedPublicKey:k,randomPrivateKey:()=>o(s.BYTES),precompute(m=8,y=S.BASE){return y._setWindowSize(m),y.multiply(BigInt(3)),y}}}}BigInt(0),BigInt(1);const co=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),$a=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const ky=BigInt(1),Na=BigInt(2);BigInt(3);const Ay=BigInt(5),Ty=BigInt(8);function Ry(t){const e=BigInt(10),s=BigInt(20),n=BigInt(40),i=BigInt(80),r=co,o=t*t%r*t%r,a=tt(o,Na,r)*o%r,c=tt(a,ky,r)*t%r,l=tt(c,Ay,r)*c%r,h=tt(l,e,r)*l%r,u=tt(h,s,r)*h%r,d=tt(u,n,r)*u%r,p=tt(d,i,r)*d%r,f=tt(p,i,r)*d%r,g=tt(f,e,r)*l%r;return{pow_p_5_8:tt(g,Na,r)*t%r,b2:o}}function Py(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function $y(t,e){const s=co,n=ue(e*e*e,s),i=ue(n*n*e,s),r=Ry(t*i).pow_p_5_8;let o=ue(t*n*r,s);const a=ue(e*o*o,s),c=o,l=ue(o*$a,s),h=a===t,u=a===ue(-t,s),d=a===ue(-t*$a,s);return h&&(o=c),(u||d)&&(o=l),fy(o,s)&&(o=ue(-o,s)),{isValid:h||u,value:o}}const Ny=(()=>ch(co,void 0,!0))(),Cy=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ny,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ty,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sy,randomBytes:th,adjustScalarBytes:Py,uvRatio:$y}))(),uh=(()=>Oy(Cy))(),By="EdDSA",Uy="JWT",ei=".",wi="base64url",dh="utf8",ph="utf8",My=":",Ly="did",Fy="key",Ca="base58btc",qy="z",zy="K36",jy=32;function lo(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function fh(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?lo(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function gh(t,e){e||(e=t.reduce((i,r)=>i+r.length,0));const s=fh(e);let n=0;for(const i of t)s.set(i,n),n+=i.length;return lo(s)}function Hy(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var i=0;i<t.length;i++){var r=t.charAt(i),o=r.charCodeAt(0);if(s[o]!==255)throw new TypeError(r+" is ambiguous");s[o]=i}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var g=0,_=0,v=0,A=f.length;v!==A&&f[v]===0;)v++,g++;for(var S=(A-v)*h+1>>>0,C=new Uint8Array(S);v!==A;){for(var F=f[v],$=0,U=S-1;(F!==0||$<_)&&U!==-1;U--,$++)F+=256*C[U]>>>0,C[U]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");_=$,v++}for(var N=S-_;N!==S&&C[N]===0;)N++;for(var k=c.repeat(g);N<S;++N)k+=t.charAt(C[N]);return k}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var g=0;if(f[g]!==" "){for(var _=0,v=0;f[g]===c;)_++,g++;for(var A=(f.length-g)*l+1>>>0,S=new Uint8Array(A);f[g];){var C=s[f.charCodeAt(g)];if(C===255)return;for(var F=0,$=A-1;(C!==0||F<v)&&$!==-1;$--,F++)C+=a*S[$]>>>0,S[$]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");v=F,g++}if(f[g]!==" "){for(var U=A-v;U!==A&&S[U]===0;)U++;for(var N=new Uint8Array(_+(A-U)),k=_;U!==A;)N[k++]=S[U++];return N}}}function p(f){var g=d(f);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:d,decode:p}}var Ky=Hy,Vy=Ky;const _h=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Gy=t=>new TextEncoder().encode(t),Wy=t=>new TextDecoder().decode(t);class Yy{constructor(e,s,n){this.name=e,this.prefix=s,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}let Xy=class{constructor(e,s,n){if(this.name=e,this.prefix=s,s.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return mh(this,e)}},Zy=class{constructor(e){this.decoders=e}or(e){return mh(this,e)}decode(e){const s=e[0],n=this.decoders[s];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const mh=(t,e)=>new Zy({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});let Jy=class{constructor(e,s,n,i){this.name=e,this.prefix=s,this.baseEncode=n,this.baseDecode=i,this.encoder=new Yy(e,s,n),this.decoder=new Xy(e,s,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const bi=({name:t,prefix:e,encode:s,decode:n})=>new Jy(t,e,s,n),fn=({prefix:t,name:e,alphabet:s})=>{const{encode:n,decode:i}=Vy(s,e);return bi({prefix:t,name:e,encode:n,decode:r=>_h(i(r))})},Qy=(t,e,s,n)=>{const i={};for(let h=0;h<e.length;++h)i[e[h]]=h;let r=t.length;for(;t[r-1]==="=";)--r;const o=new Uint8Array(r*s/8|0);let a=0,c=0,l=0;for(let h=0;h<r;++h){const u=i[t[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<s|u,a+=s,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},ew=(t,e,s)=>{const n=e[e.length-1]==="=",i=(1<<s)-1;let r="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>s;)o-=s,r+=e[i&a>>o];if(o&&(r+=e[i&a<<s-o]),n)for(;r.length*s&7;)r+="=";return r},ve=({name:t,prefix:e,bitsPerChar:s,alphabet:n})=>bi({prefix:e,name:t,encode(i){return ew(i,n,s)},decode(i){return Qy(i,n,s,t)}}),tw=bi({prefix:"\0",name:"identity",encode:t=>Wy(t),decode:t=>Gy(t)});var sw=Object.freeze({__proto__:null,identity:tw});const nw=ve({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var iw=Object.freeze({__proto__:null,base2:nw});const rw=ve({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ow=Object.freeze({__proto__:null,base8:rw});const aw=fn({prefix:"9",name:"base10",alphabet:"0123456789"});var cw=Object.freeze({__proto__:null,base10:aw});const lw=ve({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hw=ve({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var uw=Object.freeze({__proto__:null,base16:lw,base16upper:hw});const dw=ve({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pw=ve({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),fw=ve({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gw=ve({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_w=ve({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),mw=ve({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yw=ve({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ww=ve({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),bw=ve({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ew=Object.freeze({__proto__:null,base32:dw,base32upper:pw,base32pad:fw,base32padupper:gw,base32hex:_w,base32hexupper:mw,base32hexpad:yw,base32hexpadupper:ww,base32z:bw});const vw=fn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Iw=fn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Sw=Object.freeze({__proto__:null,base36:vw,base36upper:Iw});const xw=fn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Dw=fn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ow=Object.freeze({__proto__:null,base58btc:xw,base58flickr:Dw});const kw=ve({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
2+/",bitsPerChar:6}),Aw=ve({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Tw=ve({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Rw=ve({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pw=Object.freeze({__proto__:null,base64:kw,base64pad:Aw,base64url:Tw,base64urlpad:Rw});const yh=Array.from("ððªâð°ðððððððððððððâð»ð¥ð¾ð¿ðâ¤ðð¤£ððððððð ððð¥ð¥°ðððð¢ð¤ðððªðâºðð¤ððððð¹ð¤¦ððââ¨ð¤·ð±ðð¸ððððððððð¤©ððð¤ðð¯ððð¶ðð¤â£ððððªðð¥ððð©ð¡ð¤ªðð¥³ð¥ð¤¤ððð³âððð´ðð¬ððð·ð»ðââ ð¥ºððð¤ð¦âð£ððâ¹ððð âððºðð»ððððð¹ð£ð«ðððµð¤ðð´ð¤ð¼ð«â½ð¤âðð¤«ðð®ðð»ðð¶ðð²ð¿ð§¡ðâ¡ððââðð°ð¤¨ð¶ð¤ð¶ð°ðð¢ð¤ðð¨ð¨ð¤¬âððºð¤ððð±ðð¶ð¥´â¶â¡âðð¸â¬ð¨ðð¦ð·ðºâ ð ððµðð¤²ð¤ ð¤§ððµð ð§ð¾ððð¤ðð¤¯ð·âð§ð¯ððð¤ððâð´ð£ð¸ððð¥ð¤¢ð ð¡ð©ðð¸ð»ð¤ð¤®ð¼ð¥µð©ððð¼ðð£ð¥"),$w=yh.reduce((t,e,s)=>(t[s]=e,t),[]),Nw=yh.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function Cw(t){return t.reduce((e,s)=>(e+=$w[s],e),"")}function Bw(t){const e=[];for(const s of t){const n=Nw[s.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(n)}return new Uint8Array(e)}const Uw=bi({prefix:"ð",name:"base256emoji",encode:Cw,decode:Bw});var Mw=Object.freeze({__proto__:null,base256emoji:Uw}),Lw=wh,Ba=128,Fw=127,qw=~Fw,zw=Math.pow(2,31);function wh(t,e,s){e=e||[],s=s||0;for(var n=s;t>=zw;)e[s++]=t&255|Ba,t/=128;for(;t&qw;)e[s++]=t&255|Ba,t>>>=7;return e[s]=t|0,wh.bytes=s-n+1,e}var jw=kr,Hw=128,Ua=127;function kr(t,n){var s=0,n=n||0,i=0,r=n,o,a=t.length;do{if(r>=a)throw kr.bytes=0,new RangeError("Could not decode varint");o=t[r++],s+=i<28?(o&Ua)<<i:(o&Ua)*Math.pow(2,i),i+=7}while(o>=Hw);return kr.bytes=r-n,s}var Kw=Math.pow(2,7),Vw=Math.pow(2,14),Gw=Math.pow(2,21),Ww=Math.pow(2,28),Yw=Math.pow(2,35),Xw=Math.pow(2,42),Zw=Math.pow(2,49),Jw=Math.pow(2,56),Qw=Math.pow(2,63),e0=function(t){return t<Kw?1:t<Vw?2:t<Gw?3:t<Ww?4:t<Yw?5:t<Xw?6:t<Zw?7:t<Jw?8:t<Qw?9:10},t0={encode:Lw,decode:jw,encodingLength:e0},bh=t0;const Ma=(t,e,s=0)=>(bh.encode(t,e,s),e),La=t=>bh.encodingLength(t),Ar=(t,e)=>{const s=e.byteLength,n=La(t),i=n+La(s),r=new Uint8Array(i+s);return Ma(t,r,0),Ma(s,r,n),r.set(e,i),new s0(t,s,e,r)};class s0{constructor(e,s,n,i){this.code=e,this.size=s,this.digest=n,this.bytes=i}}const Eh=({name:t,code:e,encode:s})=>new n0(t,e,s);class n0{constructor(e,s,n){this.name=e,this.code=s,this.encode=n}digest(e){if(e instanceof Uint8Array){const s=this.encode(e);return s instanceof Uint8Array?Ar(this.code,s):s.then(n=>Ar(this.code,n))}else throw Error("Unknown type, must be binary type")}}const vh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),i0=Eh({name:"sha2-256",code:18,encode:vh("SHA-256")}),r0=Eh({name:"sha2-512",code:19,encode:vh("SHA-512")});var o0=Object.freeze({__proto__:null,sha256:i0,sha512:r0});const Ih=0,a0="identity",Sh=_h,c0=t=>Ar(Ih,Sh(t)),l0={code:Ih,name:a0,encode:Sh,digest:c0};var h0=Object.freeze({__proto__:null,identity:l0});new TextEncoder,new TextDecoder;const Fa={...sw,...iw,...ow,...cw,...uw,...Ew,...Sw,...Ow,...Pw,...Mw};({...o0,...h0});function xh(t,e,s,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:n}}}const qa=xh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ji=xh("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=fh(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),Dh={utf8:qa,"utf-8":qa,hex:Fa.base16,latin1:Ji,ascii:Ji,binary:Ji,...Fa};function Ei(t,e="utf8"){const s=Dh[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):s.encoder.encode(t).substring(1)}function Ns(t,e="utf8"){const s=Dh[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?lo(globalThis.Buffer.from(t,"utf-8")):s.decoder.decode(`${s.prefix}${t}`)}function za(t){return is(Ei(Ns(t,wi),dh))}function ti(t){return Ei(Ns(rs(t),dh),wi)}function Oh(t){const e=Ns(zy,Ca),s=qy+Ei(gh([e,t]),Ca);return[Ly,Fy,s].join(My)}function u0(t){return Ei(t,wi)}function d0(t){return Ns(t,wi)}function p0(t){return Ns([ti(t.header),ti(t.payload)].join(ei),ph)}function f0(t){return[ti(t.header),ti(t.payload),u0(t.signature)].join(ei)}function Tr(t){const e=t.split(ei),s=za(e[0]),n=za(e[1]),i=d0(e[2]),r=Ns(e.slice(0,2).join(ei),ph);return{header:s,payload:n,signature:i,data:r}}function ja(t=th(jy)){const e=uh.getPublicKey(t);return{secretKey:gh([t,e]),publicKey:e}}async function g0(t,e,s,n,i=R.fromMiliseconds(Date.now())){const r={alg:By,typ:Uy},o=Oh(n.publicKey),a=i+s,c={iss:o,sub:t,aud:e,iat:i,exp:a},l=p0({header:r,payload:c}),h=uh.sign(l,n.secretKey.slice(0,32));return f0({header:r,payload:c,signature:h})}const _0={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}},m0="Input must be an string, Buffer or Uint8Array";function y0(t){let e;if(t instanceof Uint8Array)e=t;else if(typeof t=="string")e=new TextEncoder().encode(t);else throw new Error(m0);return e}function w0(t){return Array.prototype.map.call(t,function(e){return(e<16?"0":"")+e.toString(16)}).join("")}function On(t){return(4294967296+t).toString(16).substring(1)}function b0(t,e,s){let n=` 3`+t+" = ";for(let i=0;i<e.length;i+=2){if(s===32)n+=On(e[i]).toUpperCase(),n+=" ",n+=On(e[i+1]).toUpperCase();else if(s===64)n+=On(e[i+1]).toUpperCase(),n+=On(e[i]).toUpperCase();else throw new Error("Invalid size "+s);i%6===4?n+=` 4`+new Array(t.length+4).join(" "):i<e.length-2&&(n+=" ")}}function E0(t,e,s){let n=new Date().getTime();const i=new Uint8Array(e);for(let o=0;o<e;o++)i[o]=o%256;const r=new Date().getTime();""+(r-n),n=r;for(let o=0;o<s;o++){const a=t(i),c=new Date().getTime(),l=c-n;
vendor: 21,621 bytes, line 4
4n=c,""+l+a.substring(0,20),Math.round(e/(1<<20)/(l/1e3)*100)/100+""}}var kh={normalizeInput:y0,toHex:w0,debugPrint:b0,testSpeed:E0};const Ln=kh;function kn(t,e,s){const n=t[e]+t[s];let i=t[e+1]+t[s+1];n>=4294967296&&i++,t[e]=n,t[e+1]=i}function Ha(t,e,s,n){let i=t[e]+s;s<0&&(i+=4294967296);let r=t[e+1]+n;i>=4294967296&&r++,t[e]=i,t[e+1]=r}function Ah(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}function At(t,e,s,n,i,r){const o=Ws[i],a=Ws[i+1],c=Ws[r],l=Ws[r+1];kn(Y,t,e),Ha(Y,t,o,a);let h=Y[n]^Y[t],u=Y[n+1]^Y[t+1];Y[n]=u,Y[n+1]=h,kn(Y,s,n),h=Y[e]^Y[s],u=Y[e+1]^Y[s+1],Y[e]=h>>>24^u<<8,Y[e+1]=u>>>24^h<<8,kn(Y,t,e),Ha(Y,t,c,l),h=Y[n]^Y[t],u=Y[n+1]^Y[t+1],Y[n]=h>>>16^u<<16,Y[n+1]=u>>>16^h<<16,kn(Y,s,n),h=Y[e]^Y[s],u=Y[e+1]^Y[s+1],Y[e]=u>>>31^h<<1,Y[e+1]=h>>>31^u<<1}const Th=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),v0=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],Ie=new Uint8Array(v0.map(function(t){return t*2})),Y=new Uint32Array(32),Ws=new Uint32Array(32);function Rh(t,e){let s=0;for(s=0;s<16;s++)Y[s]=t.h[s],Y[s+16]=Th[s];for(Y[24]=Y[24]^t.t,Y[25]=Y[25]^t.t/4294967296,e&&(Y[28]=~Y[28],Y[29]=~Y[29]),s=0;s<32;s++)Ws[s]=Ah(t.b,4*s);for(s=0;s<12;s++)At(0,8,16,24,Ie[s*16+0],Ie[s*16+1]),At(2,10,18,26,Ie[s*16+2],Ie[s*16+3]),At(4,12,20,28,Ie[s*16+4],Ie[s*16+5]),At(6,14,22,30,Ie[s*16+6],Ie[s*16+7]),At(0,10,20,30,Ie[s*16+8],Ie[s*16+9]),At(2,12,22,24,Ie[s*16+10],Ie[s*16+11]),At(4,14,16,26,Ie[s*16+12],Ie[s*16+13]),At(6,8,18,28,Ie[s*16+14],Ie[s*16+15]);for(s=0;s<16;s++)t.h[s]=t.h[s]^Y[s]^Y[s+16]}const Tt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function Ph(t,e,s,n){if(t===0||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(e&&e.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(s&&s.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(n&&n.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const i={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};Tt.fill(0),Tt[0]=t,e&&(Tt[1]=e.length),Tt[2]=1,Tt[3]=1,s&&Tt.set(s,32),n&&Tt.set(n,48);for(let r=0;r<16;r++)i.h[r]=Th[r]^Ah(Tt,r*4);return e&&(ho(i,e),i.c=128),i}function ho(t,e){for(let s=0;s<e.length;s++)t.c===128&&(t.t+=t.c,Rh(t,!1),t.c=0),t.b[t.c++]=e[s]}function $h(t){for(t.t+=t.c;t.c<128;)t.b[t.c++]=0;Rh(t,!0);const e=new Uint8Array(t.outlen);for(let s=0;s<t.outlen;s++)e[s]=t.h[s>>2]>>8*(s&3);return e}function Nh(t,e,s,n,i){s=s||64,t=Ln.normalizeInput(t),n&&(n=Ln.normalizeInput(n)),i&&(i=Ln.normalizeInput(i));const r=Ph(s,e,n,i);return ho(r,t),$h(r)}function I0(t,e,s,n,i){const r=Nh(t,e,s,n,i);return Ln.toHex(r)}var S0={blake2b:Nh,blake2bHex:I0,blake2bInit:Ph,blake2bUpdate:ho,blake2bFinal:$h};const Ch=kh;function x0(t,e){return t[e]^t[e+1]<<8^t[e+2]<<16^t[e+3]<<24}function Rt(t,e,s,n,i,r){Q[t]=Q[t]+Q[e]+i,Q[n]=An(Q[n]^Q[t],16),Q[s]=Q[s]+Q[n],Q[e]=An(Q[e]^Q[s],12),Q[t]=Q[t]+Q[e]+r,Q[n]=An(Q[n]^Q[t],8),Q[s]=Q[s]+Q[n],Q[e]=An(Q[e]^Q[s],7)}function An(t,e){return t>>>e^t<<32-e}const Bh=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Se=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),Q=new Uint32Array(16),ye=new Uint32Array(16);function Uh(t,e){let s=0;for(s=0;s<8;s++)Q[s]=t.h[s],Q[s+8]=Bh[s];for(Q[12]^=t.t,Q[13]^=t.t/4294967296,e&&(Q[14]=~Q[14]),s=0;s<16;s++)ye[s]=x0(t.b,4*s);for(s=0;s<10;s++)Rt(0,4,8,12,ye[Se[s*16+0]],ye[Se[s*16+1]]),Rt(1,5,9,13,ye[Se[s*16+2]],ye[Se[s*16+3]]),Rt(2,6,10,14,ye[Se[s*16+4]],ye[Se[s*16+5]]),Rt(3,7,11,15,ye[Se[s*16+6]],ye[Se[s*16+7]]),Rt(0,5,10,15,ye[Se[s*16+8]],ye[Se[s*16+9]]),Rt(1,6,11,12,ye[Se[s*16+10]],ye[Se[s*16+11]]),Rt(2,7,8,13,ye[Se[s*16+12]],ye[Se[s*16+13]]),Rt(3,4,9,14,ye[Se[s*16+14]],ye[Se[s*16+15]]);for(s=0;s<8;s++)t.h[s]^=Q[s]^Q[s+8]}function Mh(t,e){if(!(t>0&&t<=32))throw new Error("Incorrect output length, should be in [1, 32]");const s=e?e.length:0;if(e&&!(s>0&&s<=32))throw new Error("Incorrect key length, should be in [1, 32]");const n={h:new Uint32Array(Bh),b:new Uint8Array(64),c:0,t:0,outlen:t};return n.h[0]^=16842752^s<<8^t,s>0&&(uo(n,e),n.c=64),n}function uo(t,e){for(let s=0;s<e.length;s++)t.c===64&&(t.t+=t.c,Uh(t,!1),t.c=0),t.b[t.c++]=e[s]}function Lh(t){for(t.t+=t.c;t.c<64;)t.b[t.c++]=0;Uh(t,!0);const e=new Uint8Array(t.outlen);for(let s=0;s<t.outlen;s++)e[s]=t.h[s>>2]>>8*(s&3)&255;return e}function Fh(t,e,s){s=s||32,t=Ch.normalizeInput(t);const n=Mh(s,e);return uo(n,t),Lh(n)}function D0(t,e,s){const n=Fh(t,e,s);return Ch.toHex(n)}var O0={blake2s:Fh,blake2sHex:D0,blake2sInit:Mh,blake2sUpdate:uo,blake2sFinal:Lh};const js=S0,Hs=O0;var k0={blake2b:js.blake2b,blake2bHex:js.blake2bHex,blake2bInit:js.blake2bInit,blake2bUpdate:js.blake2bUpdate,blake2bFinal:js.blake2bFinal,blake2s:Hs.blake2s,blake2sHex:Hs.blake2sHex,blake2sInit:Hs.blake2sInit,blake2sUpdate:Hs.blake2sUpdate,blake2sFinal:Hs.blake2sFinal},at={exports:{}};function A0(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var T0=R0;function R0(t,e,s){var n=s&&s.stringify||A0,i=1;if(typeof t=="object"&&t!==null){var r=e.length+i;if(r===1)return t;var o=new Array(r);o[0]=n(t);for(var a=1;a<r;a++)o[a]=n(e[a]);return o.join(" ")}if(typeof t!="string")return t;var c=e.length;if(c===0)return t;for(var l="",h=1-i,u=-1,d=t&&t.length||0,p=0;p<d;){if(t.charCodeAt(p)===37&&p+1<d){switch(u=u>-1?u:0,t.charCodeAt(p+1)){case 100:case 102:if(h>=c||e[h]==null)break;u<p&&(l+=t.slice(u,p)),l+=Number(e[h]),u=p+2,p++;break;case 105:if(h>=c||e[h]==null)break;u<p&&(l+=t.slice(u,p)),l+=Math.floor(Number(e[h])),u=p+2,p++;break;case 79:case 111:case 106:if(h>=c||e[h]===void 0)break;u<p&&(l+=t.slice(u,p));var f=typeof e[h];if(f==="string"){l+="'"+e[h]+"'",u=p+2,p++;break}if(f==="function"){l+=e[h].name||"<anonymous>",u=p+2,p++;break}l+=n(e[h]),u=p+2,p++;break;case 115:if(h>=c)break;u<p&&(l+=t.slice(u,p)),l+=String(e[h]),u=p+2,p++;break;case 37:u<p&&(l+=t.slice(u,p)),l+="%",u=p+2,p++,h--;break}++h}++p}return u===-1?t:(u<d&&(l+=t.slice(u)),l)}const Ka=T0;at.exports=vt;const rn=V0().console||{},P0={mapHttpRequest:Tn,mapHttpResponse:Tn,wrapRequestSerializer:Qi,wrapResponseSerializer:Qi,wrapErrorSerializer:Qi,req:Tn,res:Tn,err:Ga,errWithCause:Ga};function Bt(t,e){return t==="silent"?1/0:e.levels.values[t]}const po=Symbol("pino.logFuncs"),Rr=Symbol("pino.hierarchy"),$0={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function Va(t,e){const s={logger:e,parent:t[Rr]};e[Rr]=s}function N0(t,e,s){const n={};e.forEach(i=>{n[i]=s[i]?s[i]:rn[i]||rn[$0[i]||"log"]||Os}),t[po]=n}function C0(t,e){return Array.isArray(t)?t.filter(function(s){return s!=="!stdSerializers.err"}):t===!0?Object.keys(e):!1}function vt(t){t=t||{},t.browser=t.browser||{};const e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");const s=t.browser.write||rn;t.browser.write&&(t.browser.asObject=!0);const n=t.serializers||{},i=C0(t.browser.serialize,n);let r=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(r=!1);const o=Object.keys(t.customLevels||{}),a=["error","fatal","warn","info","debug","trace"].concat(o);typeof s=="function"&&a.forEach(function(g){s[g]=s}),(t.enabled===!1||t.browser.disabled)&&(t.level="silent");const c=t.level||"info",l=Object.create(s);l.log||(l.log=Os),N0(l,a,s),Va({},l),Object.defineProperty(l,"levelVal",{get:u}),Object.defineProperty(l,"level",{get:d,set:p});const h={transmit:e,serialize:i,asObject:t.browser.asObject,asObjectBindingsOnly:t.browser.asObjectBindingsOnly,formatters:t.browser.formatters,levels:a,timestamp:j0(t),messageKey:t.messageKey||"msg",onChild:t.onChild||Os};l.levels=B0(t),l.level=c,l.isLevelEnabled=function(g){return this.levels.values[g]?this.levels.values[g]>=this.levels.values[this.level]:!1},l.setMaxListeners=l.getMaxListeners=l.emit=l.addListener=l.on=l.prependListener=l.once=l.prependOnceListener=l.removeListener=l.removeAllListeners=l.listeners=l.listenerCount=l.eventNames=l.write=l.flush=Os,l.serializers=n,l._serialize=i,l._stdErrSerialize=r,l.child=function(...g){return f.call(this,h,...g)},e&&(l._logEvent=Pr());function u(){return Bt(this.level,this)}function d(){return this._level}function p(g){if(g!=="silent"&&!this.levels.values[g])throw Error("unknown level "+g);this._level=g,Vt(this,h,l,"error"),Vt(this,h,l,"fatal"),Vt(this,h,l,"warn"),Vt(this,h,l,"info"),Vt(this,h,l,"debug"),Vt(this,h,l,"trace"),o.forEach(_=>{Vt(this,h,l,_)})}function f(g,_,v){if(!_)throw new Error("missing bindings for child Pino");v=v||{},i&&_.serializers&&(v.serializers=_.serializers);const A=v.serializers;if(i&&A){var S=Object.assign({},n,A),C=t.browser.serialize===!0?Object.keys(S):i;delete _.serializers,fo([_],C,S,this._stdErrSerialize)}function F(U){this._childLevel=(U._childLevel|0)+1,this.bindings=_,S&&(this.serializers=S,this._serialize=C),e&&(this._logEvent=Pr([].concat(U._logEvent.bindings,_)))}F.prototype=this;const $=new F(this);return Va(this,$),$.child=function(...U){return f.call(this,g,...U)},$.level=v.level||this.level,g.onChild($),$}return l}function B0(t){const e=t.customLevels||{},s=Object.assign({},vt.levels.values,e),n=Object.assign({},vt.levels.labels,U0(e));return{values:s,labels:n}}function U0(t){const e={};return Object.keys(t).forEach(function(s){e[t[s]]=s}),e}vt.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},vt.stdSerializers=P0,vt.stdTimeFunctions=Object.assign({},{nullTime:qh,epochTime:zh,unixTime:H0,isoTime:K0});function M0(t){const e=[];t.bindings&&e.push(t.bindings);let s=t[Rr];for(;s.parent;)s=s.parent,s.logger.bindings&&e.push(s.logger.bindings);return e.reverse()}function Vt(t,e,s,n){if(Object.defineProperty(t,n,{value:Bt(t.level,s)>Bt(n,s)?Os:s[po][n],writable:!0,enumerable:!0,configurable:!0}),t[n]===Os){if(!e.transmit)return;const r=e.transmit.level||t.level,o=Bt(r,s);if(Bt(n,s)<o)return}t[n]=F0(t,e,s,n);const i=M0(t);i.length!==0&&(t[n]=L0(i,t[n]))}function L0(t,e){return function(){return e.apply(this,[...t,...arguments])}}function F0(t,e,s,n){return function(i){return function(){const r=e.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===rn?rn:this;for(var c=0;c<o.length;c++)o[c]=arguments[c];var l=!1;if(e.serialize&&(fo(o,this._serialize,this.serializers,this._stdErrSerialize),l=!0),e.asObject||e.formatters?i.call(a,...q0(this,n,o,r,e)):i.apply(a,o),e.transmit){const h=e.transmit.level||t._level,u=Bt(h,s),d=Bt(n,s);if(d<u)return;z0(this,{ts:r,methodLevel:n,methodValue:d,transmitLevel:h,transmitValue:s.levels.values[e.transmit.level||t._level],send:e.transmit.send,val:Bt(t._level,s)},o,l)}}}(t[po][n])}function q0(t,e,s,n,i){const{level:r,log:o=u=>u}=i.formatters||{},a=s.slice();let c=a[0];const l={};let h=(t._childLevel|0)+1;if(h<1&&(h=1),n&&(l.time=n),r){const u=r(e,t.levels.values[e]);Object.assign(l,u)}else l.level=t.levels.values[e];if(i.asObjectBindingsOnly){if(c!==null&&typeof c=="object")for(;h--&&typeof a[0]=="object";)Object.assign(l,a.shift());return[o(l),...a]}else{if(c!==null&&typeof c=="object"){for(;h--&&typeof a[0]=="object";)Object.assign(l,a.shift());c=a.length?Ka(a.shift(),a):void 0}else typeof c=="string"&&(c=Ka(a.shift(),a));return c!==void 0&&(l[i.messageKey]=c),[o(l)]}}function fo(t,e,s,n){for(const i in t)if(n&&t[i]instanceof Error)t[i]=vt.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i])&&e)for(const r in t[i])e.indexOf(r)>-1&&r in s&&(t[i][r]=s[r](t[i][r]))}function z0(t,e,s,n=!1){const i=e.send,r=e.ts,o=e.methodLevel,a=e.methodValue,c=e.val,l=t._logEvent.bindings;n||fo(s,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=r,t._logEvent.messages=s.filter(function(h){return l.indexOf(h)===-1}),t._logEvent.level.label=o,t._logEvent.level.value=a,i(o,t._logEvent,c),t._logEvent=Pr(l)}function Pr(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Ga(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const s in t)e[s]===void 0&&(e[s]=t[s]);return e}function j0(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?qh:zh}function Tn(){return{}}function Qi(t){return t}function Os(){}function qh(){return!1}function zh(){return Date.now()}function H0(){return Math.round(Date.now()/1e3)}function K0(){return new Date(Date.now()).toISOString()}function V0(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}at.exports.default=vt;at.exports.pino=vt;const G0={level:"info"},vi="custom_context",go=1e3*1024;var W0=Object.defineProperty,Y0=(t,e,s)=>e in t?W0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Nt=(t,e,s)=>Y0(t,typeof e!="symbol"?e+"":e,s);class X0{constructor(e){Nt(this,"nodeValue"),Nt(this,"sizeInBytes"),Nt(this,"next"),this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}let Wa=class{constructor(e){Nt(this,"lengthInNodes"),Nt(this,"sizeInBytes"),Nt(this,"head"),Nt(this,"tail"),Nt(this,"maxSizeInBytes"),this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const s=new X0(e);if(s.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${s.size}`);for(;this.size+s.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=s),this.tail=s):(this.head=s,this.tail=s),this.lengthInNodes++,this.sizeInBytes+=s.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let s=this.head;for(;s!==null;)e.push(s.value),s=s.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const s=e.value;return e=e.next,{done:!1,value:s}}}}};const Z0=t=>JSON.stringify(t,(e,s)=>typeof s=="bigint"?s.toString()+"n":s);function Ya(t){return typeof t=="string"?t:Z0(t)||""}var J0=Object.defineProperty,Q0=(t,e,s)=>e in t?J0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Rn=(t,e,s)=>Q0(t,typeof e!="symbol"?e+"":e,s);let jh=class{constructor(e,s=go){Rn(this,"logs"),Rn(this,"level"),Rn(this,"levelValue"),Rn(this,"MAX_LOG_SIZE_IN_BYTES"),this.level=e??"error",this.levelValue=at.exports.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=s,this.logs=new Wa(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,s){s===at.exports.levels.values.error?console.error(e):s===at.exports.levels.values.warn?console.warn(e):s===at.exports.levels.values.debug||s===at.exports.levels.values.trace&&console.trace(e)}appendToLogs(e){this.logs.append(Ya({timestamp:new Date().toISOString(),log:e}));const s=typeof e=="string"?JSON.parse(e).level:e.level;s>=this.levelValue&&this.forwardToConsole(e,s)}getLogs(){return this.logs}clearLogs(){this.logs=new Wa(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const s=this.getLogArray();return s.push(Ya({extraMetadata:e})),new Blob(s,{type:"application/json"})}};var eb=Object.defineProperty,tb=(t,e,s)=>e in t?eb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,sb=(t,e,s)=>tb(t,typeof e!="symbol"?e+"":e,s);let nb=class{constructor(e,s=go){sb(this,"baseChunkLogger"),this.baseChunkLogger=new jh(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const s=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=s,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}};var ib=Object.defineProperty,rb=(t,e,s)=>e in t?ib(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ob=(t,e,s)=>rb(t,typeof e!="symbol"?e+"":e,s);class ab{constructor(e,s=go){ob(this,"baseChunkLogger"),this.baseChunkLogger=new jh(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var cb=Object.defineProperty,lb=Object.defineProperties,hb=Object.getOwnPropertyDescriptors,Xa=Object.getOwnPropertySymbols,ub=Object.prototype.hasOwnProperty,db=Object.prototype.propertyIsEnumerable,Za=(t,e,s)=>e in t?cb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Lt=(t,e)=>{for(var s in e||(e={}))ub.call(e,s)&&Za(t,s,e[s]);if(Xa)for(var s of Xa(e))db.call(e,s)&&Za(t,s,e[s]);return t},Ft=(t,e)=>lb(t,hb(e));function pb(t){return Ft(Lt({},t),{level:(t==null?void 0:t.level)||G0.level})}function fb(t,e,s=vi){return t[s]=e,t}function Ne(t,e=vi){return t[e]||""}function gb(t,e,s=vi){const n=Ne(t,s);return n.trim()?`${n}/${e}`:e}function Fe(t,e,s=vi){const n=gb(t,e,s),i=t.child({context:n});return fb(i,n,s)}function _b(t){var e,s;const n=new nb((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:at.exports(Ft(Lt({},t.opts),{level:"trace",browser:Ft(Lt({},(s=t.opts)==null?void 0:s.browser),{write:i=>n.write(i)})})),chunkLoggerController:n}}function mb(t){var e,s;const n=new ab((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:at.exports(Ft(Lt({},t.opts),{level:"trace",browser:Ft(Lt({},(s=t.opts)==null?void 0:s.browser),{write:i=>n.write(i)})}),n),chunkLoggerController:n}}function Hh(t){var e;if(typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string")return{logger:t.loggerOverride,chunkLoggerController:null};const s=Ft(Lt({},t.opts),{level:typeof t.loggerOverride=="string"?t.loggerOverride:(e=t.opts)==null?void 0:e.level});return typeof window<"u"?_b(Ft(Lt({},t),{opts:s})):mb(Ft(Lt({},t),{opts:s}))}const yb=":";function It(t){const[e,s]=t.split(yb);return{namespace:e,reference:s}}function Ja(t,e=[]){const s=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];s.push(...i.accounts)}),s}function Kh(t,e){return t.includes(":")?[t]:e.chains||[]}const wb={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},bb={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function P(t,e){const{message:s,code:n}=bb[t];return{message:e?`${s} ${e}
4`:s,code:n}}function ie(t,e){const{message:s,code:n}=wb[t];return{message:e?`${s} ${e}`:s,code:n}}const Eb="ReactNative",Le={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},vb="js";function si(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function jt(){return!ns()&&!!Zr()&&navigator.product===Eb}function Ib(){return jt()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Sb(){return jt()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function Cs(){return!si()&&!!Zr()&&!!ns()}function gn(){return jt()?Le.reactNative:si()?Le.node:Cs()?Le.browser:Le.unknown}function Qa(){var t;try{return jt()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function xb(t,e){const s=new URLSearchParams(t);return Object.entries(e).sort(([n],[i])=>n.localeCompare(i)).forEach(([n,i])=>{i!=null&&s.set(n,String(i))}),s.toString()}function Db(t){var s,n;const e=Vh();try{return t!=null&&t.url&&e.url&&new URL(t.url).host!==new URL(e.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${e.url}. This is probably unintended and can lead to issues.`),t.url=e.url),(s=t==null?void 0:t.icons)!=null&&s.length&&t.icons.length>0&&(t.icons=t.icons.filter(i=>i!=="")),{...e,...t,url:(t==null?void 0:t.url)||e.url,name:(t==null?void 0:t.name)||e.name,description:(t==null?void 0:t.description)||e.description,icons:(n=t==null?void 0:t.icons)!=null&&n.length&&t.icons.length>0?t.icons:e.icons}}catch(i){return console.warn("Error populating app metadata",i),t||e}}function Vh(){return Ol()||{name:"",description:"",url:"",icons:[""]}}function Ob(){if(gn()===Le.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:s,Version:n}=global.Platform;return[s,n].join("-")}const t=Np();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function kb(){var e;const t=gn();return t===Le.browser?[t,((e=Dl())==null?void 0:e.host)||"unknown"].join(":"):t}function Gh(t,e,s){const n=Ob(),i=kb();return[[t,e].join("-"),[vb,s].join("-"),n,i].join("/")}function Ab({protocol:t,version:e,relayUrl:s,sdkVersion:n,auth:i,projectId:r,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),h=Gh(t,e,n),u={auth:i,ua:h,projectId:r,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},d=xb(l[1]||"",u);return l[0]+"?"+d}function ts(t,e){return t.filter(s=>e.includes(s)).length===t.length}function $r(t){return Object.fromEntries(t.entries())}function Nr(t){return new Map(Object.entries(t))}function Yt(t=R.FIVE_MINUTES,e){const s=R.toMiliseconds(t||R.FIVE_MINUTES);let n,i,r,o;return{resolve:a=>{r&&n&&(clearTimeout(r),n(a),o=Promise.resolve(a))},reject:a=>{r&&i&&(clearTimeout(r),i(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);r=setTimeout(()=>{const l=P("EXPIRED"),h=new Error(e||l.message);h.code=l.code,c(h)},s),n=a,i=c})}}function Qe(t,e,s){return new Promise(async(n,i)=>{const r=setTimeout(()=>i(new Error(s)),e);try{const o=await t;n(o)}catch(o){i(o)}clearTimeout(r)})}function Wh(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function Tb(t){return Wh("topic",t)}function Rb(t){return Wh("id",t)}function Yh(t){const[e,s]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof s=="string")n.topic=s;else if(e==="id"&&Number.isInteger(Number(s)))n.id=Number(s);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${s}`);return n}function ce(t,e){return R.fromMiliseconds((e||Date.now())+R.toMiliseconds(t))}function ot(t){return Date.now()>=R.toMiliseconds(t)}function te(t,e){return`${t}${e?`:${e}`:""}`}function ct(t=[],e=[]){return[...new Set([...t,...e])]}async function Pb({id:t,topic:e,wcDeepLink:s}){var n,i;try{if(!s)return;const r=(n=typeof s=="string"?JSON.parse(s):s)==null?void 0:n.href;if(typeof r!="string")return;const o=$b(r,t,e),a=gn();if(a===Le.browser){if(!((i=ns())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Nb(o)}else a===Le.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(r){console.error(r)}}function $b(t,e,s){const n=`requestId=${e}&sessionTopic=${s}`;
vendor: 13,418 bytes, line 4
4t.endsWith("/")&&(t=t.slice(0,-1));let i=`${t}`;if(t.startsWith("https://t.me")){const r=t.includes("?")?"&startapp=":"?startapp=";i=`${i}${r}${Mb(n,!0)}`}else i=`${i}/wc?${n}`;return i}function Nb(t){let e="_self";Ub()?e="_top":(Bb()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function Cb(t,e){let s="";try{if(Cs()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(n){console.error(n)}return s}function ec(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),n=s.indexOf(e);return s[n+2]}function tc(){return typeof crypto<"u"&&(crypto!=null&&crypto.randomUUID)?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function _o(){return typeof process<"u"&&{GITHUB_STATE:"/home/runner/work/_temp/_runner_file_commands/save_state_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",npm_package_dependencies__across_protocol_app_sdk:"^0.6.1",npm_package_dependencies__reduxjs_toolkit:"^2.8.0",npm_package_dependencies_zod:"3.23.8",npm_package_devDependencies__types_node:"^20.8.8",npm_package_devDependencies_vite_tsconfig_paths:"^4.0.8",DOTNET_NOLOGO:"1",npm_package_scripts_test_smoke:"vitest run --config vitest.smoke.config.ts --mode production",npm_package_devDependencies_vitest:"^1.6.0",USER:"runner",npm_config_always_auth:"",npm_config_user_agent:"pnpm/8.9.2 npm/? node/v21.0.0 linux x64",CI:"false",npm_package_dependencies__near_wallet_selector_my_near_wallet:"^8.10.2",npm_package_dependencies_react_device_detect:"^1.17.0",npm_package_devDependencies__lingui_swc_plugin:"^4.0.4",USE_BAZEL_FALLBACK_VERSION:"silent:",RUNNER_ENVIRONMENT:"github-hosted",GITHUB_ENV:"/home/runner/work/_temp/_runner_file_commands/set_env_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",PIPX_HOME:"/opt/pipx",npm_package_dependencies__coinbase_wallet_sdk:"^4.3.7",npm_package_dependencies__kyberswap_price_slider:"workspace:*",npm_package_dependencies__walletconnect_ethereum_provider:"^2.21.1",npm_package_devDependencies__types_react_window_infinite_loader:"^1.0.6",npm_package_devDependencies_vite:"^4.3.9",npm_node_execpath:"/opt/hostedtoolcache/node/21.0.0/x64/bin/node",JAVA_HOME_8_X64:"/usr/lib/jvm/temurin-8-jdk-amd64",NODE_AUTH_TOKEN:"XXXXX-XXXXX-XXXXX-XXXXX",SHLVL:"1",HCA_CLOUD_PROVIDER:"azure",npm_package_dependencies__metamask_connect_evm:"^2.1.0",npm_package_dependencies_process:"^0.11.10",npm_package_dependencies_wagmi:"^3.6.20",npm_config__kybernetwork_registry:"https://npm.pkg.github.com",HOME:"/home/runner",npm_package_devDependencies__types_react_window:"^1.8.5",npm_package_devDependencies__typescript_eslint_parser:"^5.58.0",RUNNER_TEMP:"/home/runner/work/_temp",GITHUB_EVENT_PATH:"/home/runner/work/_temp/_github_workflow/event.json",npm_package_dependencies__formo_analytics:"^1.38.0",npm_package_devDependencies_eslint_config_prettier:"^8.5.0",JAVA_HOME_11_X64:"/usr/lib/jvm/temurin-11-jdk-amd64",PIPX_BIN_DIR:"/opt/pipx_bin",GITHUB_REPOSITORY_OWNER:"KyberNetwork",npm_package_dependencies__kyberswap_zap_out_widgets:"workspace:*",npm_package_dependencies_framer_motion:"^11.18.2",NODE_OPTIONS:"--max_old_space_size=4096",GRADLE_HOME:"/usr/share/gradle-9.7.1",ANDROID_NDK_LATEST_HOME:"/usr/local/lib/android/sdk/ndk/29.0.14206865",JAVA_HOME_21_X64:"/usr/lib/jvm/temurin-21-jdk-amd64",GITHUB_RETENTION_DAYS:"1",npm_package_dependencies__kyber_schema:"workspace:^",npm_package_dependencies_ua_parser_js:"^1.0.33",GITHUB_REPOSITORY_OWNER_ID:"28812853",POWERSHELL_DISTRIBUTION_CHANNEL:"GitHub-Actions-Linux",AZURE_EXTENSION_DIR:"/opt/az/azcliextensions",GITHUB_HEAD_REF:"",npm_package_dependencies__kyber_hooks:"workspace:^",npm_package_dependencies__kyberswap_zap_migration_widgets:"workspace:*",npm_package_dependencies__solana_web3_js:"^1.98.2",npm_package_dependencies_class_variance_authority:"^0.7.0",npm_package_dependencies_html2canvas:"^1.4.1",npm_package_dependencies_react_feather:"^2.0.10",npm_package_dependencies_react_indiana_drag_scroll:"^2.0.1",npm_package_dependencies_walktour:"^5.2.0",npm_config_userconfig:"/home/runner/work/_temp/.npmrc",SYSTEMD_EXEC_PID:"1959",BUILD_DATE:"2026-09-29T06:42:17+0000",ACTIONS_ORCHESTRATION_ID:"aee56758-a70d-4762-b6f5-93897fd52d40.build.__default",npm_package_dependencies__defuse_protocol_one_click_sdk_typescript:"^0.1.2",npm_package_dependencies__kyberswap_ks_sdk_core:"1.1.19",npm_package_dependencies__near_wallet_selector_sender:"^8.10.2",npm_package_dependencies_dayjs:"^1.11.6",npm_package_devDependencies_eslint_plugin_react_hooks:"^4.6.0",GITHUB_GRAPHQL_URL:"https://api.github.com/graphql",npm_package_description:"KyberSwap Interface",npm_package_dependencies__kyberswap_ks_sdk_classic:"^1.0.3",npm_package_dependencies_react_qrcode_logo:"^4.1.0",npm_package_dependencies_react_router_dom:"6.5.0",npm_package_devDependencies__lingui_cli:"^4.6.0",npm_package_devDependencies_tailwindcss:"^3.4.13",npm_package_devDependencies_typescript:"^5.7.3",npm_package_devDependencies_vite_plugin_svgr:"^2.4.0",JAVA_HOME_25_X64:"/usr/lib/jvm/temurin-25-jdk-amd64",NVM_DIR:"/home/runner/.nvm",npm_package_homepage:"/",npm_package_dependencies_jsbi:"^3.2.5",npm_package_devDependencies__types_react_dom:"^19.0.0",DOTNET_SKIP_FIRST_TIME_EXPERIENCE:"1",JAVA_HOME_17_X64:"/usr/lib/jvm/temurin-17-jdk-amd64",ImageVersion:"20260920.314.1",VITE_TAG:"v7.11.3",npm_package_scripts_dev:"vite --mode production --host",npm_package_dependencies__kyber_rpc_client:"workspace:*",npm_package_dependencies__lifi_sdk:"^3.6.8",npm_package_devDependencies__types_lodash_debounce:"^4.0.9",npm_package_devDependencies__vitejs_plugin_react_swc:"^3.5.0",npm_package_devDependencies_prettier:"^2.7.1",npm_package_devDependencies_vite_plugin_checker:"^0.5.6",LOGNAME:"runner",RUNNER_OS:"Linux",GITHUB_API_URL:"https://api.github.com",GITHUB_ARTIFACTS:"/home/runner/work/_temp/_runner_file_commands/artifacts_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",SWIFT_PATH:"/usr/share/swift/usr/bin",npm_package_scripts_i18n:"pnpm run i18n:extract && pnpm run i18n:compile",npm_package_scripts_i18n_extract:"lingui extract",npm_package_dependencies__kyberswap_ks_sdk_elastic:"^1.1.2",npm_package_dependencies__relayprotocol_relay_sdk:"^5.1.0",npm_package_dependencies__safe_global_safe_apps_sdk:"^9.1.0",npm_package_dependencies_react_popper:"^2.2.3",npm_package_dependencies_react_window_infinite_loader:"^1.0.8",npm_package_devDependencies__babel_preset_typescript:"^7.21.4",CHROMEWEBDRIVER:"/usr/local/share/chromedriver-linux64",JOURNAL_STREAM:"9:11910",GITHUB_WORKFLOW:"KyberSwap Interface Release",_:"/home/runner/setup-pnpm/node_modules/.bin/pnpm",npm_package_private:"true",npm_package_dependencies__near_wallet_selector_hot_wallet:"^8.10.2",npm_package_dependencies__reach_portal:"^0.17.0",npm_package_dependencies_events:"^3.3.0",npm_package_dependencies_tiny_invariant:"^1.3.3",npm_package_devDependencies__babel_preset_react:"^7.18.6",npm_package_devDependencies_autoprefixer:"^10.4.20",MEMORY_PRESSURE_WATCH:"/sys/fs/cgroup/system.slice/hosted-compute-agent.service/memory.pressure",GOROOT_1_24_X64:"/opt/hostedtoolcache/go/1.24.13/x64",npm_package_scripts_lint:"eslint --ext ts,tsx src",npm_package_dependencies__near_wallet_selector_modal_ui:"^8.10.2",npm_package_dependencies_react_window:"^1.8.9",npm_package_devDependencies__types_uuid:"^8.3.4",npm_package_devDependencies__typescript_eslint_eslint_plugin:"^5.58.0",npm_config_registry:"https://registry.npmjs.org/",ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE:"/opt/actionarchivecache",GOROOT_1_25_X64:"/opt/hostedtoolcache/go/1.25.14/x64",GITHUB_RUN_ID:"36532455599",VERSION_TAG:"v7.11.3",npm_package_dependencies__lingui_react:"^4.6.0",npm_package_devDependencies__babel_core:"^7.21.4",GITHUB_REF_TYPE:"branch",BOOTSTRAP_HASKELL_NONINTERACTIVE:"1",GITHUB_WORKFLOW_SHA:"fdc34852d18af13946b75f101d7604f5c07f291a",GOROOT_1_26_X64:"/opt/hostedtoolcache/go/1.26.8/x64",GITHUB_BASE_REF:"",ImageOS:"ubuntu24",npm_package_dependencies__kyberswap_zap_create_widgets:"workspace:*",npm_package_dependencies__use_gesture_react:"^10.2.27",npm_package_dependencies_tailwind_merge:"^2.5.5",GITHUB_WORKFLOW_REF:"KyberNetwork/kyberswap-interface/.github/workflows/ks-interface-release.yaml@refs/heads/main",GITHUB_ACTION_REPOSITORY:"",ENABLE_RUNNER_TRACING:"true",npm_package_dependencies__near_wallet_selector_nightly:"^8.10.2",npm_package_dependencies_axios:"1.2.1",npm_package_dependencies_recharts:"2.15.4",npm_package_devDependencies__types_mixpanel_browser:"^2.38.0",npm_package_devDependencies_prettier_plugin_tailwindcss:"0.4.1",npm_config_node_gyp:"/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/kyberswap-interface/kyberswap-interface/apps/kyberswap-interface/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.bin:/opt/hostedtoolcache/node/21.0.0/x64/bin:/home/runner/setup-pnpm/node_modules/.bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",ANT_HOME:"/usr/share/ant",DOTNET_MULTILEVEL_LOOKUP:"0",RUNNER_TRACKING_ID:"github_7212fc8c-ceb2-467a-b36c-c7189475cb3b",INVOCATION_ID:"776ff34c8e8949c2aa2f6eb830c69a14",NPM_CONFIG_USERCONFIG:"/home/runner/work/_temp/.npmrc",RUNNER_TOOL_CACHE:"/opt/hostedtoolcache",npm_package_name:"@kyberswap/interface",npm_package_dependencies__lingui_macro:"^4.6.0",npm_package_dependencies__reach_dialog:"^0.17.0",npm_package_dependencies_swiper:"^8.4.4",npm_package_devDependencies__types_crypto_js:"4.1.1",npm_package_devDependencies__types_react_gtm_module:"^2.0.1",NODE:"/opt/hostedtoolcache/node/21.0.0/x64/bin/node",GITHUB_ACTION:"__run_5",GITHUB_RUN_NUMBER:"413",GITHUB_TRIGGERING_ACTOR:"tienkane",RUNNER_ARCH:"X64",XDG_RUNTIME_DIR:"/run/user/1001",AGENT_TOOLSDIRECTORY:"/opt/hostedtoolcache",npm_package_scripts_analyze:"NODE_OPTIONS=--max_old_space_size=8192 ANALYZE=1 vite build",npm_package_dependencies__safe_global_safe_apps_provider:"^0.18.6",npm_package_dependencies_react_redux:"^9.2.0",npm_package_dependencies_viem:"^2.48.11",npm_package_devDependencies__types_numeral:"^2.0.0",npm_package_devDependencies_eslint_plugin_jsx_a11y:"^6.7.1",npm_config_frozen_lockfile:"",npm_package_dependencies__kyber_utils:"workspace:*",npm_package_dependencies_memoize_one:"^6.0.0",npm_package_devDependencies_tailwindcss_animate:"^1.0.7",SERVICE:"kyberswap-interface",LANG:"C.UTF-8",VCPKG_INSTALLATION_ROOT:"/usr/local/share/vcpkg",npm_package_dependencies__solana_wallet_adapter_react:"^0.15.39",npm_package_dependencies_bitcoinjs_lib:"^6.1.7",npm_package_dependencies_react_dom:"^19.2.6",npm_package_dependencies_use_sound:"^5.0.0",npm_package_devDependencies__types_lodash_throttle:"^4.1.9",npm_package_devDependencies_eslint:"^8.38.0",CONDA:"/usr/share/miniconda",RUNNER_NAME:"GitHub Actions 1000076050",XDG_CONFIG_HOME:"/home/runner/.config",GITHUB_REF_NAME:"main",GITHUB_REPOSITORY:"KyberNetwork/kyberswap-interface",npm_package_browserslist_0:"chrome >= 52",npm_package_dependencies__mayanfinance_swap_sdk:"^13.2.0",npm_package_dependencies__near_wallet_selector_meteor_wallet:"^8.10.2",npm_package_dependencies__solana_wallet_adapter_base:"^0.9.27",npm_package_dependencies_lodash_debounce:"^4.0.8",npm_package_devDependencies_babel_plugin_lodash:"^3.3.4",npm_lifecycle_script:"pnpm run i18n && tsc && vite build && pnpm run prerender",ANDROID_NDK_ROOT:"/usr/local/lib/android/sdk/ndk/27.3.13750724",GITHUB_ACTION_REF:"",DEBIAN_FRONTEND:"noninteractive",npm_package_scripts_test:"vitest run --exclude '**/*.smoke.test.*'",npm_package_browserslist_1:"opera >= 39",npm_package_dependencies__bitcoinerlab_secp256k1:"^1.2.0",npm_package_dependencies_react_router:"^6.5.0",npm_package_dependencies_workbox_precaching:"^6.5.4",npm_package_dependencies_workbox_strategies:"^7.3.0",npm_package_devDependencies__trivago_prettier_plugin_sort_imports:"^3.3.1",SHELL:"/bin/bash",GITHUB_REPOSITORY_ID:"343321701",GITHUB_ACTIONS:"true",NODE_PATH:"/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/bin/node_modules:/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/node_modules:/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.pnpm/[email protected]_@[email protected]/node_modules:/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/bin/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/node_modules",npm_package_browserslist_2:"edge >= 14",npm_package_dependencies__esbuild_plugins_node_globals_polyfill:"^0.2.3",npm_package_dependencies__solana_spl_token:"^0.4.13",npm_package_devDependencies__types_react:"^19.0.0",npm_package_devDependencies_eslint_plugin_unused_imports:"^2.0.0",npm_lifecycle_event:"build",GITHUB_REF_PROTECTED:"true",npm_package_scripts_build:"pn
4pm run i18n && tsc && vite build && pnpm run prerender",npm_package_browserslist_3:"firefox >= 52",npm_package_dependencies_buffer:"^6.0.3",npm_package_dependencies_react_rnd:"10.4.1",npm_package_dependencies_react_virtualized_auto_sizer:"^1.0.7",npm_package_dependencies_uuid:"^11.1.0",GITHUB_WORKSPACE:"/home/runner/work/kyberswap-interface/kyberswap-interface",ACCEPT_EULA:"Y",GITHUB_JOB:"build",npm_package_scripts_check_bundle_size:"node scripts/check-entry-size.mjs",npm_package_browserslist_4:"safari >= 10.1",npm_package_dependencies__near_wallet_selector_core:"^8.10.2",npm_package_dependencies_siwe:"^2.3.2",GITHUB_SHA:"fdc34852d18af13946b75f101d7604f5c07f291a",GITHUB_RUN_ATTEMPT:"1",npm_package_browserslist_5:"node >= 7",npm_package_dependencies__tanstack_react_query:"^5.52.1",npm_package_devDependencies_eslint_plugin_tailwindcss:"^3.17.5",ACTIONS_RUNNER_RETURN_JOB_RESULT_FOR_HOSTED:"1",GITHUB_REF:"refs/heads/main",GITHUB_ACTOR:"tienkane",ANDROID_SDK_ROOT:"/usr/local/lib/android/sdk",npm_package_license:"GPL-3.0-or-later",npm_package_browserslist_6:"ios >= 10.3",npm_package_dependencies__kyber_token_selector:"workspace:^",npm_package_dependencies_clsx:"^2.1.1",npm_package_dependencies_lightweight_charts:"^3.3.0",npm_package_dependencies_mixpanel_browser:"^2.45.0",npm_package_dependencies_workbox_core:"^6.5.4",npm_package_dependencies_workbox_routing:"^6.5.4",npm_package_devDependencies_eslint_plugin_react:"^7.31.10",npm_package_scripts_format:"prettier --write .",npm_package_browserslist_7:"samsung >= 6",npm_package_dependencies__kyberswap_oauth2:"1.0.2",npm_package_dependencies__ledgerhq_hw_app_btc:"^10.9.1",npm_package_dependencies__zkmelabs_widget:"^0.1.3",npm_package_dependencies_crypto_js:"4.1.1",npm_package_dependencies_firebase:"^9.8.2",npm_package_dependencies_html5_qrcode:"^2.3.8",npm_package_dependencies_react_date_picker:"12.0.2",npm_package_dependencies_react_gtm_module:"^2.0.11",npm_package_dependencies_stream_browserify:"^3.0.0",npm_package_devDependencies__lingui_vite_plugin:"^4.6.0",npm_package_devDependencies_eslint_plugin_prettier:"^4.2.1",GITHUB_PATH:"/home/runner/work/_temp/_runner_file_commands/add_path_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",JAVA_HOME:"/usr/lib/jvm/temurin-17-jdk-amd64",PWD:"/home/runner/work/kyberswap-interface/kyberswap-interface/apps/kyberswap-interface",GITHUB_ACTOR_ID:"41465652",RUNNER_WORKSPACE:"/home/runner/work/kyberswap-interface",npm_package_browserslist_8:"electron >= 1.3",npm_package_dependencies__kyberswap_liquidity_widgets:"workspace:*",npm_package_dependencies__lingui_core:"^4.6.0",npm_package_dependencies__near_wallet_selector_math_wallet:"^8.10.2",npm_package_dependencies_numeral:"^2.0.6",npm_execpath:"/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/bin/pnpm.cjs",HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS:"3650",GITHUB_EVENT_NAME:"workflow_dispatch",HOMEBREW_NO_AUTO_UPDATE:"1",ANDROID_HOME:"/usr/local/lib/android/sdk",GITHUB_SERVER_URL:"https://github.com",GECKOWEBDRIVER:"/usr/local/share/gecko_driver",GHCUP_INSTALL_BASE_PREFIX:"/usr/local",GITHUB_OUTPUT:"/home/runner/work/_temp/_runner_file_commands/set_output_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",npm_package_browserslist_9:"ChromeAndroid >= 52",npm_package_dependencies__popperjs_core:"^2.11.6",npm_package_dependencies_dompurify:"^3.0.6",npm_package_dependencies_near_api_js:"^5.1.1",npm_package_devDependencies_vite_plugin_compression2:"^2.5.3",EDGEWEBDRIVER:"/usr/local/share/edge_driver",npm_package_dependencies__kyber_ui:"workspace:^",npm_package_dependencies__ledgerhq_hw_transport:"^6.31.5",npm_package_dependencies__near_wallet_selector_react_hook:"^9.0.0",npm_package_dependencies__solana_wallet_standard_wallet_adapter_react:"^1.1.4",npm_package_dependencies__wagmi_core:"^3.5.4",npm_package_dependencies_date_fns:"^4.1.0",npm_package_dependencies_lodash_throttle:"^4.1.1",npm_package_dependencies_util:"^0.12.5",npm_package_devDependencies_babel_plugin_macros:"^3.1.0",npm_package_devDependencies_eslint_plugin_lingui:"^0.2.0",npm_package_devDependencies_postcss:"^8.4.47",npm_command:"run-script",PNPM_SCRIPT_SRC_DIR:"/home/runner/work/kyberswap-interface/kyberswap-interface/apps/kyberswap-interface",ANDROID_NDK:"/usr/local/lib/android/sdk/ndk/27.3.13750724",GITHUB_ARTIFACTS_LIST:"/home/runner/work/_temp/_runner_file_commands/artifacts_list_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",SGX_AESM_ADDR:"1",PSModulePath:"/root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules:/usr/share/az_15.6.1",CHROME_BIN:"/usr/bin/google-chrome",npm_package_scripts_preview:"vite preview",npm_package_scripts_i18n_compile:"lingui compile",npm_package_dependencies__near_wallet_selector_ledger:"^8.10.2",npm_package_dependencies_countries_and_timezones:"^3.7.2",npm_package_dependencies_porto:"^0.2.37",npm_package_devDependencies_rollup_plugin_visualizer:"^7.0.1",SELENIUM_JAR_PATH:"/usr/share/java/selenium-server.jar",MEMORY_PRESSURE_WRITE:"c29tZSAyMDAwMDAgMjAwMDAwMAA=",PNPM_HOME:"/home/runner/setup-pnpm/node_modules/.bin",npm_package_dependencies__kyberswap_compounding_widget:"workspace:*",npm_package_dependencies__ledgerhq_hw_transport_webusb:"^6.29.5",npm_package_dependencies_react_loading_skeleton:"^3.1.0",npm_package_dependencies_react_use:"^15.3.4",npm_package_devDependencies__types_ua_parser_js:"^0.7.36",ANDROID_NDK_HOME:"/usr/local/lib/android/sdk/ndk/27.3.13750724",GITHUB_STEP_SUMMARY:"/home/runner/work/_temp/_runner_file_commands/step_summary_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",npm_package_scripts_prerender:"node scripts/prerender.mjs",npm_package_dependencies__kyberswap_liquidity_chart:"workspace:*",npm_package_dependencies_react:"^19.2.6",npm_package_dependencies_redux_localstorage_simple:"^2.5.1",INIT_CWD:"/home/runner/work/kyberswap-interface/kyberswap-interface/apps/kyberswap-interface",NODE_ENV:"production"}.IS_VITEST==="true"}function Bb(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Ub(){try{return window.self!==window.top}catch{return!1}}function Mb(t,e=!1){const s=new TextEncoder().encode(t),n=new Array(s.length);for(let r=0;r<s.length;r++)n[r]=String.fromCharCode(s[r]);const i=btoa(n.join(""));return e?i.replace(/[=]/g,""):i}function Xh(t){const e=t+"=".repeat((4-t.length%4)%4),s=atob(e),n=new Uint8Array(s.length);for(let i=0;i<s.length;i++)n[i]=s.charCodeAt(i);return new TextDecoder().decode(n)}
vendor: 5,724 bytes, lines 4-7
4function Lb(t){return new Promise(e=>setTimeout(e,t))}class Fb{constructor({limit:e}){this.limit=e,this.set=new Set}add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const s=this.set.values().next().value;s&&this.set.delete(s)}this.set.add(e)}}has(e){return this.set.has(e)}}const qb="https://rpc.walletconnect.org/v1";function ks(t){const e=t+"=".repeat((4-t.length%4)%4),s=atob(e),n=new Uint8Array(s.length);for(let i=0;i<s.length;i++)n[i]=s.charCodeAt(i);return n}function Zh(t){const e=`�Ethereum Signed Message: 5${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+_e(tl(s),"base16")}async function zb(t,e,s,n,i,r){switch(s.t){case"eip191":return await jb(t,e,s.s);case"eip1271":return await Hb(t,e,s.s,n,i,r);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}function jb(t,e,s){const n=hg(s);return gg({payload:Zh(e),signature:n}).toLowerCase()===t.toLowerCase()}async function Hb(t,e,s,n,i,r){const o=It(n);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${n}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l=s.substring(2),h=(l.length/2).toString(16).padStart(64,"0"),u=(e.startsWith("0x")?e:Zh(e)).substring(2),d=a+u+c+h+l,p=await fetch(`${r||qb}/?chainId=${n}&projectId=${i}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:Kb(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:d},"latest"]})}),{result:f}=await p.json();return f?f.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function Kb(){return Date.now()+Math.floor(Math.random()*1e3)}function Vb(t){const e=ks(t),s=e[0];if(s===0)throw new Error("No signatures found");const n=1+s*64;if(e.length<n)throw new Error("Transaction data too short for claimed signature count");if(e.length<100)throw new Error("Transaction too short");const i=e.slice(1,65);return hn.encode(i)}function Gb(t){const e=ks(t),s=new TextEncoder().encode("TransactionData::"),n=new Uint8Array(s.length+e.length);n.set(s),n.set(e,s.length);const i=Md(n,{dkLen:32});return hn.encode(i)}function sc(t){const e=new Uint8Array(Hr(Wb(t)));return hn.encode(e)}function Wb(t){if(t instanceof Uint8Array)return t;if(Array.isArray(t))return new Uint8Array(t);if(typeof t=="object"&&(t!=null&&t.data))return new Uint8Array(Object.values(t.data));if(typeof t=="object"&&t)return new Uint8Array(Object.values(t));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function nc(t){const e=ks(t),s=Jg(e).txn;if(!s)throw new Error("Invalid signed transaction: missing 'txn' field");const n=jg(s),i=new TextEncoder().encode("TX"),r=ss([i,new Uint8Array(n)]),o=Dd(r);return kd.encode(o).replace(/=+$/,"")}function er(t){const e=[];let s=BigInt(t);for(;s>=0x80n;)e.push(Number(s&0x7fn|0x80n)),s>>=7n;return e.push(Number(s)),new Uint8Array(e)}function Yb(t){const e=ks(t.signed.bodyBytes),s=ks(t.signed.authInfoBytes),n=ks(t.signature.signature),i=[];i.push(new Uint8Array([10])),i.push(er(e.length)),i.push(e),i.push(new Uint8Array([18])),i.push(er(s.length)),i.push(s),i.push(new Uint8Array([26])),i.push(er(n.length)),i.push(n);const r=ss(i),o=Hr(r);return _e(o,"base16").toUpperCase()}function Xb(t){var s,n;const e=[];try{if(typeof t=="string")return e.push(t),e;if(typeof t!="object")return e;t!=null&&t.id&&e.push(t.id);const i=(n=(s=t==null?void 0:t.capabilities)==null?void 0:s.caip345)==null?void 0:n.transactionHashes;i&&e.push(...i)}catch(i){console.warn("getWalletSendCallsHashes failed: ",i)}return e}const Jh="did:pkh:",Zb={eip155:"Ethereum",solana:"Solana",bip122:"Bitcoin"},Jb=t=>t?Zb[t]||t:"",Ii=t=>t==null?void 0:t.split(":"),Qb=t=>{const e=t&&Ii(t);if(e)return t.includes(Jh)?e[3]:e[1]},e1=t=>{const e=t&&Ii(t);if(e)return t.includes(Jh)?e[2]:e[0]},Cr=t=>{const e=t&&Ii(t);if(e)return e[2]+":"+e[3]},ni=t=>{const e=t&&Ii(t);if(e)return e.pop()};async function ic(t){const{cacao:e,projectId:s}=t,{s:n,p:i}=e,r=Qh(i,i.iss),o=ni(i.iss);return await zb(o,r,n,Cr(i.iss),s)}const Qh=(t,e)=>{const s=e1(e);if(!s)throw new Error("Invalid issuer: "+e);const n=`${t.domain} wants you to sign in with your ${Jb(s)} account:`,i=ni(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=t.statement||void 0;const o=`URI: ${t.aud||t.uri}`,a=`Version: ${t.version}`,c=`Chain ID: ${Qb(e)}`,l=`Nonce: ${t.nonce}`,h=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,d=t.nbf?`Not Before: ${t.nbf}`:void 0,p=t.requestId?`Request ID: ${t.requestId}`:void 0,f=t.resources?`Resources:${t.resources.map(_=>` 6- ${_}`).join("")}`:void 0,g=Fn(t.resources);if(g){const _=on(g);r=l1(r,_)}return[n,i,"",r,"",o,a,c,l,h,u,d,p,f].filter(_=>_!=null).join(` 7`)};function t1(t){const e=JSON.stringify(t),s=new TextEncoder().encode(e),n=new Array(s.length);for(let i=0;i<s.length;i++)n[i]=String.fromCharCode(s[i]);return btoa(n.join(""))}function s1(t){const e=t+"=".repeat((4-t.length%4)%4),s=atob(e),n=new Uint8Array(s.length);for(let i=0;i<s.length;i++)n[i]=s.charCodeAt(i);return JSON.parse(new TextDecoder().decode(n))}function os(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(s=>{const n=t.att[s];if(Array.isArray(n))throw new Error(`Resource must be an object: ${s}`);if(typeof n!="object")throw new Error(`Resource must be an object: ${s}`);if(!Object.keys(n).length)throw new Error(`Resource object is empty: ${s}`);
7Object.keys(n).forEach(i=>{const r=n[i];if(!Array.isArray(r))throw new Error(`Ability limits ${i} must be an array of objects, found: ${r}`);if(!r.length)throw new Error(`Value of ${i} is empty array, must be an array with objects`);r.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${i}) must be an array of objects, found: ${o}`)})})})}function n1(t,e,s,n={}){return s==null||s.sort((i,r)=>i.localeCompare(r)),{att:{[t]:i1(e,s,n)}}}function i1(t,e,s={}){e=e==null?void 0:e.sort((i,r)=>i.localeCompare(r));const n=e.map(i=>({[`${t}/${i}`]:[s]}));return Object.assign({},...n)}function eu(t){return os(t),`urn:recap:${t1(t).replace(/=/g,"")}`}function on(t){const e=s1(t.replace("urn:recap:",""));return os(e),e}function r1(t,e,s){const n=n1(t,e,s);return eu(n)}function o1(t){return t&&t.includes("urn:recap:")}function a1(t,e){const s=on(t),n=on(e),i=c1(s,n);return eu(i)}function c1(t,e){os(t),os(e);const s=Object.keys(t.att).concat(Object.keys(e.att)).sort((i,r)=>i.localeCompare(r)),n={att:{}};return s.forEach(i=>{var r,o;Object.keys(((r=t.att)==null?void 0:r[i])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[i])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,l;n.att[i]={...n.att[i],[a]:((c=t.att[i])==null?void 0:c[a])||((l=e.att[i])==null?void 0:l[a])}})}),n}function l1(t="",e){os(e);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(s))return t;const n=[];let i=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(u=>({ability:u.split("/")[0],action:u.split("/")[1]}));c.sort((u,d)=>u.action.localeCompare(d.action));const l={};
7c.forEach(u=>{l[u.ability]||(l[u.ability]=[]),l[u.ability].push(u.action)});const h=Object.keys(l).map(u=>(i++,`(${i}) '${u}': '${l[u].join("', '")}' for '${a}'.`));n.push(h.join(", ").replace(".,","."))});const r=n.join(" "),o=`${s}${r}`;return`${t?t+" ":""}${o}`}function rc(t){var n;const e=on(t);os(e);const s=(n=e.att)==null?void 0:n.eip155;return s?Object.keys(s).map(i=>i.split("/")[1]):[]}function oc(t){const e=on(t);os(e);const s=[];return Object.values(e.att).forEach(n=>{Object.values(n).forEach(i=>{var r;(r=i==null?void 0:i[0])!=null&&r.chains&&s.push(i[0].chains)})}),[...new Set(s.flat())]}function Fn(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return o1(e)?e:void 0}const tu="base10",ke="base16",be="base64pad",Ct="base64url",_n="utf8",su=0,St=1,mn=2,h1=0,ac=1,Zs=12,mo=32;function u1(){const t=Sr.utils.randomPrivateKey(),e=Sr.getPublicKey(t);return{privateKey:_e(t,ke),publicKey:_e(e,ke)}}function Br(){const t=cs(mo);return _e(t,ke)}function d1(t,e){const s=Sr.getSharedSecret(De(t,ke),De(e,ke)),n=dm(gi,s,void 0,void 0,mo);return _e(n,ke)}function qn(t){const e=gi(De(t,ke));return _e(e,ke)}function je(t){const e=gi(De(t,_n));return _e(e,ke)}function nu(t){return De(`${t}`,tu)}function as(t){return Number(_e(t,tu))}function iu(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ii(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),s=(4-e.length%4)%4;return e+"=".repeat(s)}function p1(t){const e=nu(typeof t.type<"u"?t.type:su);if(as(e)===St&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof t.senderPublicKey<"u"?De(t.senderPublicKey,ke):void 0,n=typeof t.iv<"u"?De(t.iv,ke):cs(Zs),i=De(t.symKey,ke),r=Zl(i,n).encrypt(De(t.message,_n)),o=ru({type:e,sealed:r,iv:n,senderPublicKey:s});return t.encoding===Ct?iu(o):o}function f1(t){const e=De(t.symKey,ke),{sealed:s,iv:n}=an({encoded:t.encoded,encoding:t.encoding}),i=Zl(e,n).decrypt(s);if(i===null)throw new Error("Failed to decrypt");return _e(i,_n)}function g1(t,e){const s=nu(mn),n=cs(Zs),i=De(t,_n),r=ru({type:s,sealed:i,iv:n});return e===Ct?iu(r):r}function _1(t,e){const{sealed:s}=an({encoded:t,encoding:e});return _e(s,_n)}function ru(t){if(as(t.type)===mn)return _e(ss([t.type,t.sealed]),be);if(as(t.type)===St){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return _e(ss([t.type,t.senderPublicKey,t.iv,t.sealed]),be)}return _e(ss([t.type,t.iv,t.sealed]),be)}function an(t){const e=(t.encoding||be)===Ct?ii(t.encoded):t.encoded,s=De(e,be),n=s.slice(h1,ac),i=ac;if(as(n)===St){const c=i+mo,l=c+Zs,h=s.slice(i,c),u=s.slice(c,l),d=s.slice(l);return{type:n,sealed:d,iv:u,senderPublicKey:h}}if(as(n)===mn){const c=s.slice(i),l=cs(Zs);return{type:n,sealed:c,iv:l}}const r=i+Zs,o=s.slice(i,r),a=s.slice(r);return{type:n,sealed:a,iv:o}}function m1(t,e){const s=an({encoded:t,encoding:e==null?void 0:e.encoding});return ou({type:as(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?_e(s.senderPublicKey,ke):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function ou(t){const e=(t==null?void 0:t.type)||su;if(e===St){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function cc(t){return t.type===St&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function lc(t){return t.type===mn}function y1(t){const e=De(ii(t.x),be),s=De(ii(t.y),be);return ss([new Uint8Array([4]),e,s])}function w1(t,e){const[s,n,i]=t.split("."),r=De(ii(i),be);if(r.length!==64)throw new Error("Invalid signature length");const o=r.slice(0,32),a=r.slice(32,64),c=`${s}.${n}`,l=gi(c),h=y1(e);if(!xp.verify(ss([o,a]),l,h))throw new Error("Invalid signature");return Tr(t).payload}const b1="irn";function ri(t){return(t==null?void 0:t.relay)||{protocol:b1}}function Es(t){const e=_0[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}function E1(t,e="-"){const s={},n="relay"+e;return Object.keys(t).forEach(i=>
vendor: 4,457 bytes, line 7
7{if(i.startsWith(n)){const r=i.replace(n,""),o=t[i];s[r]=o}}),s}function hc(t){if(!t.includes("wc:")){const l=Xh(t);l!=null&&l.includes("wc:")&&(t=l)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),s=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,s).split("@"),r=typeof s<"u"?t.substring(s):"",o=new URLSearchParams(r),a=Object.fromEntries(o.entries()),c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:n,topic:v1(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:E1(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function v1(t){return t.startsWith("//")?t.substring(2):t}function I1(t,e="-"){const s="relay",n={};return Object.keys(t).forEach(i=>{const r=i,o=s+e+r;t[r]&&(n[o]=t[r])}),n}function uc(t){const e=new URLSearchParams,s={...I1(t.relay),symKey:t.symKey,...t.expiryTimestamp&&{expiryTimestamp:t.expiryTimestamp.toString()},...t.methods&&{methods:t.methods.join(",")}};return Object.entries(s).sort(([n],[i])=>n.localeCompare(i)).forEach(([n,i])=>{i!==void 0&&e.append(n,String(i))}),`${t.protocol}:${t.topic}@${t.version}?${e}`}function Pn(t,e,s){return`${t}?wc_ev=${s}&topic=${e}`}function Bs(t){const e=[];return t.forEach(s=>{const[n,i]=s.split(":");e.push(`${n}:${i}`)}),e}function au(t){const e=[];return Object.values(t).forEach(s=>{e.push(...Bs(s.accounts))}),[...new Set(e)]}function S1(t){const e=[];return Object.values(t).forEach(s=>{e.push(...s.methods)}),[...new Set(e)]}function x1(t){const e=[];return Object.values(t).forEach(s=>{e.push(...s.events)}),[...new Set(e)]}function D1(t,e){const s=[];return Object.values(t).forEach(n=>{Bs(n.accounts).includes(e)&&s.push(...n.methods)}),s}function O1(t,e){const s=[];return Object.values(t).forEach(n=>{Bs(n.accounts).includes(e)&&s.push(...n.events)}),s}function Si(t){return t.includes(":")}function vs(t){return Si(t)?t.split(":")[0]:t}function dc(t){var s,n,i;const e={};if(!lt(t))return e;for(const[r,o]of Object.entries(t)){const a=Si(r)?[r]:o.chains,c=o.methods||[],l=o.events||[],h=vs(r);e[h]={...e[h],chains:ct(a,(s=e[h])==null?void 0:s.chains),methods:ct(c,(n=e[h])==null?void 0:n.methods),events:ct(l,(i=e[h])==null?void 0:i.events)}}return e}function k1(t){const e={};return t==null||t.forEach(s=>{var r;const[n,i]=s.split(":");e[n]||(e[n]={accounts:[],chains:[],events:[],methods:[]}),e[n].accounts.push(s),(r=e[n].chains)==null||r.push(`${n}:${i}`)}),e}function pc(t,e){e=e.map(n=>n.replace("did:pkh:",""));const s=k1(e);for(const[n,i]of Object.entries(s))i.methods?i.methods=ct(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return s}function A1(t,e){var o,a,c,l,h,u;const s=dc(t),n=dc(e),i={},r=Object.keys(s).concat(Object.keys(n));for(const d of r)i[d]={chains:ct((o=s[d])==null?void 0:o.chains,(a=n[d])==null?void 0:a.chains),methods:ct((c=s[d])==null?void 0:c.methods,(l=n[d])==null?void 0:l.methods),events:ct((h=s[d])==null?void 0:h.events,(u=n[d])==null?void 0:u.events)};return i}function Ke(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function lt(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function de(t){return typeof t>"u"}function le(t,e){return e&&de(t)?!0:typeof t=="string"&&!!t.trim().length}function yo(t,e){return e&&de(t)?!0:typeof t=="number"&&!isNaN(t)}function T1(t,e){const{requiredNamespaces:s}=e,n=Object.keys(t.namespaces),i=Object.keys(s);let r=!0;return ts(i,n)?(n.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],h=Bs(a),u=s[o];(!ts(Kh(o,u),h)||!ts(u.methods,c)||!ts(u.events,l))&&(r=!1)}),r):!1}function oi(t){return le(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function R1(t){if(le(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const s=e[0]+":"+e[1];return!!e[2]&&oi(s)}}return!1}function P1(t){function e(s){try{return typeof new URL(s)<"u"}catch{return!1}}try{if(le(t,!1)){if(e(t))return!0;const s=Xh(t);return e(s)}}catch{}return!1}function $1(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function N1(t){return t==null?void 0:t.topic}function C1(t,e){let s=null;return le(t==null?void 0:t.publicKey,!1)||(s=P("MISSING_OR_INVALID",`${e} controller public key should be a string`)),s}function fc(t){let e=!0;return Ke(t)?t.length&&(e=t.every(s=>le(s,!1))):e=!1,e}function B1(t,e,s){let n=null;return Ke(e)&&e.length?e.forEach(i=>
7{n||oi(i)||(n=ie("UNSUPPORTED_CHAINS",`${s}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):oi(t)||(n=ie("UNSUPPORTED_CHAINS",`${s}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),n}function U1(t,e,s){let n=null;return Object.entries(t).forEach(([i,r])=>{if(n)return;const o=B1(i,Kh(i,r),`${e} ${s}`);o&&(n=o)}),n}function M1(t,e){let s=null;return Ke(t)?t.forEach(n=>{s||R1(n)||(s=ie("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):s=ie("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}function L1(t,e){let s=null;return Object.values(t).forEach(n=>{if(s)return;const i=M1(n==null?void 0:n.accounts,`${e} namespace`);i&&(s=i)}),s}function F1(t,e){let s=null;return fc(t==null?void 0:t.methods)?fc(t==null?void 0:t.events)||(s=ie("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):s=ie("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),s}function cu(t,e){let s=null;return Object.values(t).forEach(n=>{if(s)return;const i=F1(n,`${e}, namespace`);i&&(s=i)}),s}function q1(t,e,s){let n=null;if(t&<(t)){const i=cu(t,e);i&&(n=i);const r=U1(t,e,s);r&&(n=r)}else n=P("MISSING_OR_INVALID",`${e}, ${s} should be an object with data`);return n}function tr(t,e){let s=null;if(t&<(t)){const n=cu(t,e);n&&(s=n);const i=L1(t,e);i&&(s=i)}else s=P("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return s}function lu(t){return le(t.protocol,!0)}function z1(t,e){let s=!1;return e&&!t?s=!0:t&&Ke(t)&&t.length&&t.forEach(n=>{s=lu(n)}),s}function j1(t){return typeof t=="number"}function Re(t){return typeof t<"u"&&typeof t!==null}function H1(t){return!(!t||typeof t!="object"||!t.code||!yo(t.code,!1)||!t.message||!le(t.message,!1))}function K1(t){return!(de(t)||!le(t.method,!1))}function V1(t){return!(de(t)||de(t.result)&&de(t.error)||!yo(t.id,!1)||!le(t.jsonrpc,!1))}function G1(t){return!(de(t)||!le(t.name,!1))}function gc(t,e){return!(!oi(e)||!au(t).includes(e))}function W1(t,e,s){return le(s,!1)?D1(t,e).includes(s):!1}function Y1(t,e,s){return le(s,!1)?O1(t,e).includes(s):!1}function _c(t,e,s){let n=null;const i=X1(t),r=Z1(e),o=Object.keys(i),a=Object.keys(r),c=mc(Object.keys(t)),l=mc(Object.keys(e)),h=c.filter(u=>!l.includes(u));return h.length&&(n=P("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces. 8 Required: ${h.toString()} 9 Received: ${Object.keys(e).toString()}`)),ts(o,a)||(n=P("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces. 10 Required: ${o.toString()} 11 Approved: ${a.toString()}`)),Object.keys(e).forEach(u=>{if(!u.includes(":")||n)return;const d=Bs(e[u].accounts);d.includes(u)||(n=P("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${u} 12 Required: ${u} 13 Approved: ${d.toString()}`))}),o.forEach(u=>{n||(ts(i[u].methods,r[u].methods)?ts(i[u].events,r[u].events)||(n=P("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${u}`)):n=P("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${u}`))}),n}function X1(t){const e={};return Object.keys(t).forEach(s=>{var n;s.includes(":")?e[s]=t[s]:(n=t[s].chains)==null||n.forEach(i=>{e[i]={methods:t[s].methods,events:t[s].events}})}),e}function mc(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function Z1(t){const e={};return Object.keys(t).forEach(s=>{var n;s.includes(":")?e[s]=t[s]:(n=Bs(t[s].accounts))==null||n.forEach(i=>{e[i]={accounts:t[s].accounts.filter(r=>r.includes(`${i}:`)),methods:t[s].methods,events:t[s].events}})}),e}function J1(t,e){return yo(t,!1)&&t<=e.max&&t>=e.min}function yc(){const t=gn();return new Promise(e=>{switch(t){case Le.browser:e(Q1());break;case Le.reactNative:e(eE());break;case Le.node:e(tE());break;default:e(!0)}})}function Q1(){return Cs()&&(navigator==null?void 0:navigator.onLine)}async function eE(){var t;return jt()&&typeof global<"u"&&(global!=null&&global.NetInfo)?(t=await(global==null?void 0:global.NetInfo.fetch()))==null?void 0:t.isConnected:!0}function tE(){return!0}function sE(t){switch(gn()){case Le.browser:nE(t);break;case Le.reactNative:iE(t);break}}function nE(t){!jt()&&Cs()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function iE(t){jt()&&typeof global<"u"&&(global!=null&&global.NetInfo)&&(global==null||global.NetInfo.addEventListener(e=>t(e==null?void 0:e.isConnected)))}function rE(){var t;return Cs()&&ns()?((t=ns())==null?void 0:t.visibilityState)==="visible":!0}const sr={};class Ks{static get(e){return sr[e]}static set(e,s){sr[e]=s}static delete(e){delete sr[e]}}function oE(t){const e=hn.decode(t);if(e.length<33)throw new Error("Too short to contain a public key");return e.slice(1,33)}function aE({publicKey:t,signature:e,payload:s}){var p;const n=ai(s.method),i=128|parseInt(((p=s.version)==null?void 0:p.toString())||"4"),r=hE(s.address),o=s.era==="00"?new Uint8Array([0]):ai(s.era);if(o.length!==1&&o.length!==2)throw new Error("Invalid era length");const a=parseInt(s.nonce,16),c=new Uint8Array([a&255,a>>8&255]),l=BigInt(`0x${lE(s.tip)}`),h=dE(l),u=new Uint8Array([0,...t,r,...e,...o,...c,...h,...n]),d=uE(u.length+1);return new Uint8Array([...d,i,...u])}function cE(t){const e=ai(t),s=k0.blake2b(e,void 0,32);return"0x"+_e(s,"base16")}function ai(t){return new Uint8Array(t.replace(/^0x/,"").match(/.{1,2}/g).map(e=>parseInt(e,16)))}function lE(t){return t.startsWith("0x")?t.slice(2):t}function hE(t){const e=hn.decode(t)[0];return e===42?0:e===60?2:1}function uE(t){if(t<64)return new Uint8Array([t<<2]);if(t<16384){const e=t<<2|1;return new Uint8Array([e&255,e>>
138&255])}else if(t<1<<30){const e=t<<2|2;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}else throw new Error("Compact encoding > 2^30 not supported")}function dE(t){if(t<1n<<6n)return new Uint8Array([Number(t<<2n)]);if(t<1n<<14n){const e=t<<2n|0x01n;return new Uint8Array([Number(e&0xffn),Number(e>>8n&0xffn)])}else if(t<1n<<30n){const e=t<<2n|0x02n;return new Uint8Array([Number(e&0xffn),Number(e>>8n&0xffn),Number(e>>16n&0xffn),Number(e>>24n&0xffn)])}else throw new Error("BigInt compact encoding not supported > 2^30")}function pE(t){const e=ai(t.signature),s=oE(t.transaction.address),n=aE({publicKey:s,signature:e,payload:t.transaction}),i=_e(n,"base16");return cE(i)}function wo({logger:t,name:e}){const s=typeof t=="string"?Hh({opts:{level:t,name:e}}).logger:t;return s.level=typeof t=="string"?t:t.level,s}class hs{}let fE=class extends hs{constructor(e){super()}};const wc=R.FIVE_SECONDS,us={pulse:"heartbeat_pulse"};class bo extends fE{constructor(e){super(e),this.events=new Ve.EventEmitter,this.interval=wc,this.interval=(e==null?void 0:e.interval)||wc}static async init(e){const s=new bo(e);return await s.init(),s}
13async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),R.toMiliseconds(this.interval))}pulse(){this.events.emit(us.pulse)}}const gE=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,_E=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,mE=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function yE(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){wE(t);return}return e}function wE(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function $n(t,e={}){if(typeof t!="string")return t;const s=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return s.slice(1,-1);if(s.length<=9){const n=s.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!mE.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(gE.test(t)||_E.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,yE)}return JSON.parse(t)}catch(n){if(e.strict)throw n;return t}}function bE(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function fe(t,...e){try{return bE(t(...e))}catch(s){return Promise.reject(s)}}function EE(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function vE(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function zn(t){if(EE(t))return String(t);if(vE(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return zn(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function hu(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Ur="base64:";function IE(t){if(typeof t=="string")return t;hu();const e=Buffer.from(t).toString("base64");return Ur+e}function SE(t){return typeof t!="string"||!t.startsWith(Ur)?t:(hu(),Buffer.from(t.slice(Ur.length),"base64"))}function Te(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function xE(...t){return Te(t.join(":"))}function Nn(t){return t=Te(t),t?t+":":""}const DE="memory",OE=()=>{const t=new Map;return{name:DE,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,s){t.set(e,s)},setItemRaw(e,s){t.set(e,s)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function kE(t={}){const e={mounts:{"":t.driver||OE()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},s=l=>{for(const h of e.mountpoints)if(l.startsWith(h))return{base:h,relativeKey:l.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:l,driver:e.mounts[""]}},n=(l,h)=>e.mountpoints.filter(u=>u.startsWith(l)||h&&l.startsWith(u)).map(u=>({relativeBase:l.length>u.length?l.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),i=(l,h)=>{if(e.watching){h=Te(h);for(const u of e.watchListeners)u(l,h)}},r=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await bc(e.mounts[l],i,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,h,u)=>{const d=new Map,p=f=>{let g=d.get(f.base);return g||(g={driver:f.driver,base:f.base,items:[]},d.set(f.base,g)),g};for(const f of l){const g=typeof f=="string",_=Te(g?f:f.key),v=g?void 0:f.value,A=g||!f.options?h:{...h,...f.options},S=s(_);p(S).items.push({key:_,value:v,relativeKey:S.relativeKey,options:A})}return Promise.all([...d.values()].map(f=>u(f))).then(f=>f.flat())},c={hasItem(l,h={}){l=Te(l);const{relativeKey:u,driver:d}=s(l);return fe(d.hasItem,u,h)},getItem(l,h={}){l=Te(l);const{relativeKey:u,driver:d}=s(l);return fe(d.getItem,u,h).then(p=>$n(p))},getItems(l,h){return a(l,h,u=>u.driver.getItems?fe(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(p=>({key:xE(u.base,p.key),value:$n(p.value)}))):Promise.all(u.items.map(d=>fe(u.driver.getItem,d.relativeKey,d.options).then(p=>({key:d.key,value:$n(p)})))))},getItemRaw(l,h={}){l=Te(l);const{relativeKey:u,driver:d}=s(l);return d.getItemRaw?fe(d.getItemRaw,u,h):fe(d.getItem,u,h).then(p=>SE(p))},async setItem(l,h,u={}){if(h===void 0)return c.removeItem(l);l=Te(l);const{relativeKey:d,driver:p}=s(l);
vendor: 8,711 bytes, line 13
13p.setItem&&(await fe(p.setItem,d,zn(h),u),p.watch||i("update",l))},async setItems(l,h){await a(l,h,async u=>{if(u.driver.setItems)return fe(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:zn(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>fe(u.driver.setItem,d.relativeKey,zn(d.value),d.options)))})},async setItemRaw(l,h,u={}){if(h===void 0)return c.removeItem(l,u);l=Te(l);const{relativeKey:d,driver:p}=s(l);if(p.setItemRaw)await fe(p.setItemRaw,d,h,u);else if(p.setItem)await fe(p.setItem,d,IE(h),u);else return;p.watch||i("update",l)},async removeItem(l,h={}){typeof h=="boolean"&&(h={removeMeta:h}),l=Te(l);const{relativeKey:u,driver:d}=s(l);d.removeItem&&(await fe(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await fe(d.removeItem,u+"$",h),d.watch||i("remove",l))},async getMeta(l,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),l=Te(l);const{relativeKey:u,driver:d}=s(l),p=Object.create(null);if(d.getMeta&&Object.assign(p,await fe(d.getMeta,u,h)),!h.nativeOnly){const f=await fe(d.getItem,u+"$",h).then(g=>$n(g));f&&typeof f=="object"&&(typeof f.atime=="string"&&(f.atime=new Date(f.atime)),typeof f.mtime=="string"&&(f.mtime=new Date(f.mtime)),Object.assign(p,f))}return p},setMeta(l,h,u={}){return this.setItem(l+"$",h,u)},removeMeta(l,h={}){return this.removeItem(l+"$",h)},async getKeys(l,h={}){l=Nn(l);const u=n(l,!0);let d=[];const p=[];for(const f of u){const g=await fe(f.driver.getKeys,f.relativeBase,h);for(const _ of g){const v=f.mountpoint+Te(_);d.some(A=>v.startsWith(A))||p.push(v)}d=[f.mountpoint,...d.filter(_=>!_.startsWith(f.mountpoint))]}return l?p.filter(f=>f.startsWith(l)&&f[f.length-1]!=="$"):p.filter(f=>f[f.length-1]!=="$")},async clear(l,h={}){l=Nn(l),await Promise.all(n(l,!1).map(async u=>{if(u.driver.clear)return fe(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(p=>u.driver.removeItem(p,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>Ec(l)))},async watch(l){return await r(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,h){if(l=Nn(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[l]=h,e.watching&&Promise.resolve(bc(h,i,l)).then(u=>{e.unwatch[l]=u}).catch(console.error),c},async unmount(l,h=!0){l=Nn(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&(e.unwatch[l](),delete e.unwatch[l]),h&&await Ec(e.mounts[l]),e.mountpoints=e.mountpoints.filter(u=>u!==l),delete e.mounts[l])},getMount(l=""){l=Te(l)+":";const h=s(l);return{driver:h.driver,base:h.base}},getMounts(l="",h={}){return l=Te(l),n(l,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(l,h={})=>c.getKeys(l,h),get:(l,h={})=>c.getItem(l,h),set:(l,h,u={})=>c.setItem(l,h,u),has:(l,h={})=>c.hasItem(l,h),del:(l,h={})=>c.removeItem(l,h),remove:(l,h={})=>c.removeItem(l,h)};return c}function bc(t,e,s){return t.watch?t.watch((n,i)=>e(n,s+i)):()=>{}}async function Ec(t){typeof t.dispose=="function"&&await fe(t.dispose)}const AE="idb-keyval";var TE=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",s=i=>e+i;let n;return t.dbName&&t.storeName&&(n=Ad(t.dbName,t.storeName)),{name:AE,options:t,async hasItem(i){return!(typeof await Lo(s(i),n)>"u")},async getItem(i){return await Lo(s(i),n)??null},setItem(i,r){return Td(s(i),r,n)},removeItem(i){return Rd(s(i),n)},getKeys(){return Pd(n)},clear(){return $d(n)}}};const RE="WALLET_CONNECT_V2_INDEXED_DB",PE="keyvaluestorage";let $E=class{constructor(){this.indexedDb=kE({driver:TE({dbName:RE,storeName:PE})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const s=await this.indexedDb.getItem(e);if(s!==null)return s}async setItem(e,s){await this.indexedDb.setItem(e,rs(s))}async removeItem(e){await this.indexedDb.removeItem(e)}};var nr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},jn={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(s){return this.hasOwnProperty(s)?String(this[s]):null},t.prototype.setItem=function(s,n){this[s]=String(n)},t.prototype.removeItem=function(s){delete this[s]},t.prototype.clear=function(){const s=this;Object.keys(s).forEach(function(n){s[n]=void 0,delete s[n]})},t.prototype.key=function(s){return s=s||0,Object.keys(this)[s]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof nr<"u"&&nr.localStorage?jn.exports=nr.localStorage:typeof window<"u"&&window.localStorage?jn.exports=window.localStorage:jn.exports=new e})();function NE(t){var e;return[t[0],is((e=t[1])!=null?e:"")]}class CE{constructor(){this.localStorage=jn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(NE)}async getItem(e){const s=this.localStorage.getItem(e);if(s!==null)return is(s)}async setItem(e,s){this.localStorage.setItem(e,rs(s))}async removeItem(e){this.localStorage.removeItem(e)}}const BE="wc_storage_version",vc=1,UE=async(t,e,s)=>{const n=BE,i=await e.getItem(n);if(i&&i>=vc){s(e);return}const r=await t.getKeys();if(!r.length){s(e);return}const o=[];for(;r.length;){const a=r.shift();if(!a)continue;const c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){const l=await t.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(n,vc),s(e),ME(t,o)},ME=async(t,e)=>{e.length&&e.forEach(async s=>{await t.removeItem(s)})};let LE=class{constructor(){this.initialized=!1,this.setInitialized=s=>{this.storage=s,this.initialized=!0};const e=new CE;this.storage=e;try{const s=new $E;UE(e,s,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,s){return await this.initialize(),this.storage.setItem(e,s)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const s=setInterval(()=>{this.initialized&&(clearInterval(s),e())},20)})}},FE=class extends hs{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},qE=class extends hs{constructor(e,s){super(),this.core=e,this.logger=s,this.records=new Map}};class zE{constructor(e,s){this.logger=e,this.core=s}}let jE=class extends hs{constructor(e,s){super(),this.relayer=e,this.logger=s}},HE=class extends hs{constructor(e){super()}},KE=class{constructor(e,s,n,i){this.core=e,this.logger=s,this.name=n}},VE=class extends hs{constructor(e,s){super(),this.relayer=e,this.logger=s}},GE=class extends hs{constructor(e,s){super(),this.core=e,this.logger=s}},WE=class{constructor(e,s,n){this.core=e,this.logger=s,this.store=n}},YE=class{constructor(e,s){this.projectId=e,this.logger=s}};class XE{constructor(e,s,n){this.core=e,this.logger=s,this.telemetryEnabled=n}}let ZE=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},JE=class{constructor(e){this.client=e}};const QE="PARSE_ERROR",ev="INVALID_REQUEST",tv="METHOD_NOT_FOUND",sv="INVALID_PARAMS",uu="INTERNAL_ERROR",Eo="SERVER_ERROR",nv=[-32700,-32600,-32601,-32602,-32603],Js={[QE]:{code:-32700,message:"Parse error"},[ev]:{code:-32600,message:"Invalid Request"},[tv]:{code:-32601,message:"Method not found"},[sv]:{code:-32602,message:"Invalid params"},[uu]:{code:-32603,message:"Internal error"},[Eo]:{code:-32e3,message:"Server error"}},du=Eo;function iv(t){return nv.includes(t)}function Ic(t){return Object.keys(Js).includes(t)?Js[t]:Js[du]}function rv(t){const e=Object.values(Js).find(s=>s.code===t);return e||Js[du]}function pu(t,e,s){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${s} RPC url at ${e}`):t}var fu={},gt={},Sc;function ov(){if(Sc)return gt;Sc=1,Object.defineProperty(gt,"__esModule",{value:!0}),gt.isBrowserCryptoAvailable=gt.getSubtleCrypto=gt.getBrowerCrypto=void 0;function t(){return(gs===null||gs===void 0?void 0:gs.crypto)||(gs===null||gs===void 0?void 0:gs.msCrypto)||{}}gt.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}gt.getSubtleCrypto=e;function s(){return!!t()&&!!e()}return gt.isBrowserCryptoAvailable=s,gt}var _t={},xc;function av(){if(xc)return _t;
vendor: 5,796 bytes, line 13
13xc=1,Object.defineProperty(_t,"__esModule",{value:!0}),_t.isBrowser=_t.isNode=_t.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}_t.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}_t.isNode=e;function s(){return!t()&&!e()}return _t.isBrowser=s,_t}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=dn;e.__exportStar(ov(),t),e.__exportStar(av(),t)})(fu);function it(t=3){const e=Date.now()*Math.pow(10,t),s=Math.floor(Math.random()*Math.pow(10,t));return e+s}function Ut(t=6){return BigInt(it(t))}function Je(t,e,s){return{id:s||it(),jsonrpc:"2.0",method:t,params:e}}function cn(t,e){return{id:t,jsonrpc:"2.0",result:e}}function xi(t,e,s){return{id:t,jsonrpc:"2.0",error:cv(e,s)}}function cv(t,e){return typeof t>"u"?Ic(uu):(typeof t=="string"&&(t=Object.assign(Object.assign({},Ic(Eo)),{message:t})),typeof e<"u"&&(t.data=e),iv(t.code)&&(t=rv(t.code)),t)}class lv{}class hv extends lv{constructor(){super()}}class uv extends hv{constructor(e){super()}}const dv="^https?:",pv="^wss?:";function fv(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function gu(t,e){const s=fv(t);return typeof s>"u"?!1:new RegExp(e).test(s)}function Dc(t){return gu(t,dv)}function Oc(t){return gu(t,pv)}function gv(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function _u(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function vo(t){return _u(t)&&"method"in t}function Di(t){return _u(t)&&(rt(t)||He(t))}function rt(t){return"result"in t}function He(t){return"error"in t}class Io extends uv{constructor(e){super(e),this.events=new Ve.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async request(e,s){return this.requestStrict(Je(e.method,e.params||[],e.id||Ut().toString()),s)}async requestStrict(e,s){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(r){i(r)}this.events.on(`${e.id}`,r=>{He(r)?i(r.error):n(r.result)});try{await this.connection.send(e,s)}catch(r){i(r)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Di(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const _v=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),mv=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",kc=t=>t.split("?")[0],Ac=10,yv=_v();let wv=class{constructor(e){if(this.url=e,this.events=new Ve.EventEmitter,this.registering=!1,!Oc(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,s)=>{if(typeof this.socket>"u"){s(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(rs(e))}catch(s){this.onError(e.id,s)}}register(e=this.url){if(!Oc(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const s=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=s||this.events.listenerCount("open")>=s)&&this.events.setMaxListeners(s+1),new Promise((n,i)=>{this.events.once("register_error",r=>{this.resetMaxListeners(),i(r)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((s,n)=>{const i=fu.isReactNative()?void 0:{rejectUnauthorized:!gv(e)},r=new yv(e,[],i);mv()?r.onerror=o=>{const a=o;n(this.emitError(a.error))}:r.on("error",o=>{n(this.emitError(o))}),r.onopen=()=>{this.onOpen(r),s(r)}})}onOpen(e){e.onmessage=s=>this.onPayload(s),e.onclose=s=>this.onClose(s),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;
vendor: 20,057 bytes, line 13
13const s=typeof e.data=="string"?is(e.data):e.data;this.events.emit("payload",s)}onError(e,s){const n=this.parseError(s),i=n.message||n.toString(),r=xi(e,i);this.events.emit("payload",r)}parseError(e,s=this.url){return pu(e,kc(s),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Ac&&this.events.setMaxListeners(Ac)}emitError(e){const s=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${kc(this.url)}`));return this.events.emit("register_error",s),s}};function bv(t){return Number.isSafeInteger(t)&&t>=0}function Ev(t){return t!=null&&typeof t!="function"&&bv(t.length)}function vv(t){return t==="__proto__"}function So(t){return t==null||typeof t!="object"&&typeof t!="function"}function Iv(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function ci(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function ln(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const mu="[object RegExp]",xo="[object String]",Do="[object Number]",Oo="[object Boolean]",li="[object Arguments]",yu="[object Symbol]",wu="[object Date]",bu="[object Map]",Eu="[object Set]",vu="[object Array]",Sv="[object Function]",Iu="[object ArrayBuffer]",Qs="[object Object]",xv="[object Error]",Su="[object DataView]",xu="[object Uint8Array]",Du="[object Uint8ClampedArray]",Ou="[object Uint16Array]",ku="[object Uint32Array]",Dv="[object BigUint64Array]",Au="[object Int8Array]",Tu="[object Int16Array]",Ru="[object Int32Array]",Ov="[object BigInt64Array]",Pu="[object Float32Array]",$u="[object Float64Array]";function ko(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function kv(t,e){return Is(t,void 0,t,new Map,e)}function Is(t,e,s,n=new Map,i=void 0){const r=i==null?void 0:i(t,e,s,n);if(r!==void 0)return r;if(So(t))return t;if(n.has(t))return n.get(t);if(Array.isArray(t)){const o=new Array(t.length);n.set(t,o);for(let a=0;a<t.length;a++)o[a]=Is(t[a],a,s,n,i);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;n.set(t,o);for(const[a,c]of t)o.set(a,Is(c,a,s,n,i));return o}if(t instanceof Set){const o=new Set;n.set(t,o);for(const a of t)o.add(Is(a,void 0,s,n,i));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(ko(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);n.set(t,o);for(let a=0;a<t.length;a++)o[a]=Is(t[a],a,s,n,i);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return n.set(t,o),Ze(o,t,s,n,i),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return n.set(t,o),Ze(o,t,s,n,i),o}if(typeof Blob<"u"&&t instanceof Blob){const o=new Blob([t],{type:t.type});return n.set(t,o),Ze(o,t,s,n,i),o}if(t instanceof Error){const o=new t.constructor;return n.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,Ze(o,t,s,n,i),o}if(t instanceof Boolean){const o=new Boolean(t.valueOf());return n.set(t,o),Ze(o,t,s,n,i),o}if(t instanceof Number){const o=new Number(t.valueOf());return n.set(t,o),Ze(o,t,s,n,i),o}if(t instanceof String){const o=new String(t.valueOf());return n.set(t,o),Ze(o,t,s,n,i),o}if(typeof t=="object"&&Av(t)){const o=Object.create(Object.getPrototypeOf(t));return n.set(t,o),Ze(o,t,s,n,i),o}return t}function Ze(t,e,s=t,n,i){const r=[...Object.keys(e),...ci(e)];for(let o=0;o<r.length;o++){const a=r[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=Is(e[a],a,s,n,i))}}function Av(t){switch(ln(t)){case li:case vu:case Iu:case Su:case Oo:case wu:case Pu:case $u:case Au:case Tu:case Ru:case bu:case Do:case Qs:case mu:case Eu:case xo:case yu:case xu:case Du:case Ou:case ku:return!0;default:return!1}}function Tv(t,e){return kv(t,(s,n,i,r)=>{const o=e==null?void 0:e(s,n,i,r);if(o!==void 0)return o;if(typeof t=="object"){if(ln(t)===Qs&&typeof t.constructor!="function"){const a={};return r.set(t,a),Ze(a,t,i,r),a}switch(Object.prototype.toString.call(t)){case Do:case xo:case Oo:{const a=new t.constructor(t==null?void 0:t.valueOf());return Ze(a,t),a}case li:{const a={};return Ze(a,t),a.length=t.length,a[Symbol.iterator]=t[Symbol.iterator],a}default:return}}})}function Tc(t){return Tv(t)}function Rc(t){return t!==null&&typeof t=="object"&&ln(t)==="[object Arguments]"}function Mr(t){return typeof t=="object"&&t!==null}function Rv(t){return Mr(t)&&Ev(t)}function Pc(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function Pv(t,e,s){return Ys(t,e,void 0,void 0,void 0,void 0,s)}function Ys(t,e,s,n,i,r,o){const a=o(t,e,s,n,i,r);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return en(t,e,r,o)}return en(t,e,r,o)}function en(t,e,s,n){if(Object.is(t,e))return!0;let i=ln(t),r=ln(e);if(i===li&&(i=Qs),r===li&&(r=Qs),i!==r)return!1;switch(i){case xo:return t.toString()===e.toString();case Do:{const c=t.valueOf(),l=e.valueOf();return Iv(c,l)}case Oo:case wu:case yu:return Object.is(t.valueOf(),e.valueOf());case mu:return t.source===e.source&&t.flags===e.flags;case Sv:return t===e}s=s??new Map;const o=s.get(t),a=s.get(e);if(o!=null&&a!=null)return o===e;s.set(t,e),s.set(e,t);try{switch(i){case bu:{if(t.size!==e.size)return!1;for(const[c,l]of t.entries())if(!e.has(c)||!Ys(l,e.get(c),c,t,e,s,n))return!1;return!0}case Eu:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),l=Array.from(e.values());for(let h=0;h<c.length;h++){const u=c[h],d=l.findIndex(p=>Ys(u,p,void 0,t,e,s,n));if(d===-1)return!1;l.splice(d,1)}return!0}case vu:case xu:case Du:case Ou:case ku:case Dv:case Au:case Tu:case Ru:case Ov:case Pu:case $u:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Ys(t[c],e[c],c,t,e,s,n))return!1;return!0}case Iu:return t.byteLength!==e.byteLength?!1:en(new Uint8Array(t),new Uint8Array(e),s,n);case Su:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:en(new Uint8Array(t),new Uint8Array(e),s,n);case xv:return t.name===e.name&&t.message===e.message;case Qs:{if(!(en(t.constructor,e.constructor,s,n)||Pc(t)&&Pc(e)))return!1;const l=[...Object.keys(t),...ci(t)],h=[...Object.keys(e),...ci(e)];if(l.length!==h.length)return!1;for(let u=0;u<l.length;u++){const d=l[u],p=t[d];if(!Object.hasOwn(e,d))return!1;const f=e[d];if(!Ys(p,f,d,t,e,s,n))return!1}return!0}default:return!1}}finally{s.delete(t),s.delete(e)}}function Nu(){}function $v(t,e){return Pv(t,e,Nu)}function ir(t){return ko(t)}function rr(t){var s;if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const n=t[Symbol.toStringTag];return n==null||!((s=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag))!=null&&s.writable)?!1:t.toString()===`[object ${n}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function Nv(t){if(So(t))return t;if(Array.isArray(t)||ko(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t);if(e==null)return Object.assign(Object.create(e),t);const s=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new s(t);if(t instanceof RegExp){const n=new s(t);return n.lastIndex=t.lastIndex,n}if(t instanceof DataView)return new s(t.buffer.slice(0));if(t instanceof Error){let n;return t instanceof AggregateError?n=new s(t.errors,t.message,{cause:t.cause}):n=new s(t.message,{cause:t.cause}),n.stack=t.stack,Object.assign(n,t),n}if(typeof File<"u"&&t instanceof File)return new s([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const n=Object.create(e);return Object.assign(n,t)}return t}function Cv(t,...e){const s=e.slice(0,-1),n=e[e.length-1];let i=t;for(let r=0;r<s.length;r++){const o=s[r];i=Hn(i,o,n,new Map)}return i}function Hn(t,e,s,n){if(So(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(n.has(e))return Nv(n.get(e));if(n.set(e,t),Array.isArray(e)){e=e.slice();for(let r=0;r<e.length;r++)e[r]=e[r]??void 0}const i=[...Object.keys(e),...ci(e)];for(let r=0;r<i.length;r++){const o=i[r];if(vv(o))continue;let a=e[o],c=t[o];if(Rc(a)&&(a={...a}),Rc(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=Tc(a)),Array.isArray(a))if(Array.isArray(c)){const h=[],u=Reflect.ownKeys(c);for(let d=0;d<u.length;d++){const p=u[d];h[p]=c[p]}c=h}else if(Rv(c)){const h=[];for(let u=0;u<c.length;u++)h[u]=c[u];c=h}else c=[];const l=s(c,a,o,t,e,n);l!==void 0?t[o]=l:Array.isArray(a)||Mr(c)&&Mr(a)&&(rr(c)||rr(a)||ir(c)||ir(a))?t[o]=Hn(c,a,s,n):c==null&&rr(a)?t[o]=Hn({},a,s,n):c==null&&ir(a)?t[o]=Tc(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function Bv(t,...e){return Cv(t,...e,Nu)}const Cu="wc",Bu=2,hi="core",ht=`${Cu}@2:${hi}:`,Uv={name:hi,logger:"error"},Mv={database:":memory:"},Lv="crypto",$c="client_ed25519_seed",Fv=R.ONE_DAY,qv="keychain",zv="0.3",jv="messages",Hv="0.3",Kv=R.SIX_HOURS,Vv="publisher",Uu="irn",Gv="error",Mu="wss://relay.walletconnect.org",Wv="relayer",oe={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},Yv="_subscription",qe={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Xv=.1,Lr="2.23.9",ne={link_mode:"link_mode",relay:"relay"},Kn={inbound:"inbound",outbound:"outbound"},Zv="0.3",Jv="WALLETCONNECT_CLIENT_ID",Nc="WALLETCONNECT_LINK_MODE_APPS",Be={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Qv="subscription",e2="0.3",t2="pairing",s2="0.3",Vs={wc_pairingDelete:{req:{ttl:R.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:R.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:R.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:R.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:R.ONE_DAY,prompt:!1,tag:0},res:{ttl:R.ONE_DAY,prompt:!1,tag:0}}},Zt={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},We={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},n2="history",i2="0.3",r2="expirer",ze={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},o2="0.3",a2="verify-api",c2="https://verify.walletconnect.com",Lu="https://verify.walletconnect.org",tn=Lu,l2=`${tn}/v3`,h2=[c2,Lu],u2="echo",d2="https://echo.walletconnect.com",nt={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},yt={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Ye={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success",session_request_response_started:"session_request_response_started",session_request_response_validation_success:"session_request_response_validation_success",session_request_response_publish_started:"session_request_response_publish_started"},Gt={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found",session_request_response_validation_failure:"session_request_response_validation_failure",session_request_response_publish_failure:"session_request_response_publish_failure"},Wt={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Gs={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},p2=.1,f2="event-client",g2=86400,_2="https://pulse.walletconnect.org/batch";let m2=class{constructor(e,s){this.core=e,this.logger=s,this.keychain=new Map,this.name=qv,this.version=zv,this.initialized=!1,this.storagePrefix=ht,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:r}=P("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(r)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=Fe(s,this.name)}get context(){return Ne(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,$r(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Nr(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}},y2=class{constructor(e,s,n){this.core=e,this.logger=s,this.name=Lv,this.randomSessionIdentifier=Br(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{if(this.isInitialized(),this.clientId)return this.clientId;const i=await this.getClientSeed(),r=ja(i),o=Oh(r.publicKey);return this.clientId=o,o},this.generateKeyPair=()=>{this.isInitialized();const i=u1();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const r=await this.getClientSeed(),o=ja(r),a=this.randomSessionIdentifier;return await g0(a,i,Fv,o)},this.generateSharedKey=(i,r,o)=>{this.isInitialized();const a=this.getPrivateKey(i),c=d1(a,r);return this.setSymKey(c,o)},this.setSymKey=async(i,r)=>{this.isInitialized();const o=r||qn(i);return await this.keychain.set(o,i),o},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,r,o)=>{this.isInitialized();const a=ou(o),c=rs(r);if(lc(a))return g1(c,o==null?void 0:o.encoding);if(cc(a)){const d=a.senderPublicKey,p=a.receiverPublicKey;i=await this.generateSharedKey(d,p)}const l=this.getSymKey(i),{type:h,senderPublicKey:u}=a;return p1({type:h,symKey:l,message:c,senderPublicKey:u,encoding:o==null?void 0:o.encoding})},this.decode=async(i,r,o)=>{this.isInitialized();const a=m1(r,o);if(lc(a)){const c=_1(r,o==null?void 0:o.encoding);return is(c)}if(cc(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;i=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(i),l=f1({symKey:c,encoded:r,encoding:o==null?void 0:o.encoding});return is(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}},this.getPayloadType=(i,r=be)=>{const o=an({encoded:i,encoding:r});return as(o.type)},this.getPayloadSenderPublicKey=(i,r=be)=>{const o=an({encoded:i,encoding:r});return o.senderPublicKey?_e(o.senderPublicKey,ke):void 0},this.core=e,this.logger=Fe(s,this.name),this.keychain=n||new m2(this.core,this.logger)}get context(){return Ne(this.logger)}async setPrivateKey(e,s){return await this.keychain.set(e,s),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get($c)}catch{e=Br(),await this.keychain.set($c,e)}return De(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}},w2=class extends zE{constructor(e,s){super(e,s),this.logger=e,this.core=s,this.messages=new Map,this.messagesWithoutClientAck=new Map,this.name=jv,this.version=Hv,this.initialized=!1,this.storagePrefix=ht,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n);const i=await this.getRelayerMessagesWithoutClientAck();typeof i<"u"&&(this.messagesWithoutClientAck=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i,r)=>{this.isInitialized();const o=je(i);let a=this.messages.get(n);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=i,this.messages.set(n,a),r===Kn.inbound){const c=this.messagesWithoutClientAck.get(n)||{};this.messagesWithoutClientAck.set(n,{...c,[o]:i}
13)}return await this.persist(),o},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.getWithoutAck=n=>{this.isInitialized();const i={};for(const r of n){const o=this.messagesWithoutClientAck.get(r)||{};i[r]=Object.values(o)}return i},this.has=(n,i)=>{this.isInitialized();const r=this.get(n),o=je(i);return typeof r[o]<"u"},this.ack=async(n,i)=>{this.isInitialized();const r=this.messagesWithoutClientAck.get(n);if(typeof r>"u")return;const o=je(i);delete r[o],Object.keys(r).length===0?this.messagesWithoutClientAck.delete(n):this.messagesWithoutClientAck.set(n,r),await this.persist()},this.del=async n=>{this.isInitialized(),this.messages.delete(n),this.messagesWithoutClientAck.delete(n),await this.persist()},this.logger=Fe(e,this.name),this.core=s}get context(){return Ne(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,$r(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,$r(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Nr(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?Nr(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}};class b2 extends jE{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,this.events=new Ve.EventEmitter,this.name=Vv,this.queue=new Map,this.publishTimeout=R.toMiliseconds(R.ONE_MINUTE),this.initialPublishTimeout=R.toMiliseconds(R.ONE_SECOND*15),this.needsTransportRestart=!1,this.publish=async(n,i,r)=>{var p,f,g,_,v;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:r}});const o=(r==null?void 0:r.ttl)||Kv,a=(r==null?void 0:r.prompt)||!1,c=(r==null?void 0:r.tag)||0,l=(r==null?void 0:r.id)||Ut().toString(),h=Es(ri().protocol),u={id:l,method:(r==null?void 0:r.publishMethod)||h.publish,params:{topic:n,message:i,ttl:o,prompt:a,tag:c,attestation:r==null?void 0:r.attestation,...r==null?void 0:r.tvf}},d=`Failed to publish payload, please try again. id:${l} tag:${c}`;try{de((p=u.params)==null?void 0:p.prompt)&&((f=u.params)==null||delete f.prompt),de((g=u.params)==null?void 0:g.tag)&&((_=u.params)==null||delete _.tag);const A=new Promise(async S=>{const C=({id:$})=>{var U;((U=u.id)==null?void 0:U.toString())===$.toString()&&(this.removeRequestFromQueue($),this.relayer.events.removeListener(oe.publish,C),S())};this.relayer.events.on(oe.publish,C);const F=Qe(new Promise(($,U)=>{this.rpcPublish(u,r).then($).catch(N=>{this.logger.warn(N,N==null?void 0:N.message),U(N)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${l} tag:${c}`);try{await F,this.events.removeListener(oe.publish,C)}catch($){this.queue.set(l,{request:u,opts:r,attempt:1}),this.logger.warn($,$==null?void 0:$.message)}});this.logger.trace({type:"method",method:"publish",params:{id:l,topic:n,message:i,opts:r}}),await Qe(A,this.publishTimeout,d)}catch(A){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(A),(v=r==null?void 0:r.internal)==null?void 0:v.throwOnFailedPublish)throw A}finally{this.queue.delete(l)}},this.publishCustom=async n=>{var v,A,S,C,F;this.logger.debug("Publishing custom payload"),this.logger.trace({type:"method",method:"publishCustom",params:n});const{payload:i,opts:r={}}=n,{attestation:o,tvf:a,publishMethod:c,prompt:l,tag:h,ttl:u=R.FIVE_MINUTES}=r,d=r.id||Ut().toString(),p=Es(ri().protocol),f=c||p.publish,g={id:d,method:f,params:{...i,ttl:u,prompt:l,tag:h,attestation:o,...a}},_=`Failed to publish custom payload, please try again. id:${d} tag:${h}`;try{de((v=g.params)==null?void 0:v.prompt)&&((A=g.params)==null||delete A.prompt),de((S=g.params)==null?void 0:S.tag)&&((C=g.params)==null||delete C.tag);const $=new Promise(async U=>{const N=({id:M})=>{var H;((H=g.id)==null?void 0:H.toString())===M.toString()&&(this.removeRequestFromQueue(M),this.relayer.events.removeListener(oe.publish,N),U())};this.relayer.events.on(oe.publish,N);const k=Qe(new Promise((M,H)=>{this.rpcPublish(g,r).then(M).catch(B=>{this.logger.warn(B,B==null?void 0:B.message),H(B)})}),this.initialPublishTimeout,`Failed initial custom payload publish, retrying.... method:${f} id:${d} tag:${h}`);try{await k,this.events.removeListener(oe.publish,N)}catch(M){this.queue.set(d,{request:g,opts:r,attempt:1}),this.logger.warn(M,M==null?void 0:M.message)}});this.logger.trace({type:"method",method:"publish",params:{id:d,payload:i,opts:r}}),await Qe($,this.publishTimeout,_)}catch($){if(this.logger.debug("Failed to Publish Payload"),this.logger.error($),(F=r==null?void 0:r.internal)==null?void 0:F.throwOnFailedPublish)throw $}finally{this.queue.delete(d)}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Fe(s,this.name),this.registerEventListeners()}get context(){return Ne(this.logger)}async rpcPublish(e,s){this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:e});const n=await this.relayer.request(e);return this.relayer.events.emit(oe.publish,{...e,...s}),this.logger.debug("Successfully Published Payload"),n}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,s)=>{var i;const n=e.attempt+1;this.queue.set(s,{...e,attempt:n}),this.logger.warn({},`Publisher: queue->publishing: ${e.request.id}, tag: ${(i=e.request.params)==null?void 0:i.tag}, attempt: ${n}`),await this.rpcPublish(e.request,e.opts),this.logger.warn({},`Publisher: queue->published: ${e.request.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(us.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(oe.connection_stalled);return}this.checkQueue()}),this.relayer.on(oe.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class E2{constructor(){this.map=new Map,this.set=(e,s)=>{const n=this.get(e);this.exists(e,s)||this.map.set(e,[...n,s])},this.get=e=>this.map.get(e)||[],this.exists=(e,s)=>this.get(e).includes(s),this.delete=(e,s)=>{if(typeof s>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,s))return;const i=n.filter(r=>r!==s);if(!i.length){this.map.delete(e);return}this.map.set(e,i)},this.clear=()=>{this.map.clear()}}
vendor: 13,015 bytes, line 13
13get topics(){return Array.from(this.map.keys())}}let v2=class extends VE{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,this.subscriptions=new Map,this.topicMap=new E2,this.events=new Ve.EventEmitter,this.name=Qv,this.version=e2,this.pending=new Map,this.cached=[],this.initialized=!1,this.storagePrefix=ht,this.subscribeTimeout=R.toMiliseconds(R.ONE_MINUTE),this.initialSubscribeTimeout=R.toMiliseconds(R.ONE_SECOND*15),this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0},this.subscribe=async(n,i)=>{var r;this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const o=ri(i),a={topic:n,relay:o,transportType:i==null?void 0:i.transportType};(r=i==null?void 0:i.internal)!=null&&r.skipSubscribe||this.pending.set(n,a);const c=await this.rpcSubscribe(n,o,i);return typeof c=="string"&&(this.onSubscribe(c,a),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}})),c}catch(o){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(o),o}},this.unsubscribe=async(n,i)=>{this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=n=>new Promise(i=>{i(this.topicMap.topics.includes(n))}),this.isKnownTopic=n=>new Promise(i=>{i(this.topicMap.topics.includes(n)||this.pending.has(n)||this.cached.some(r=>r.topic===n))}),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{await this.restore(),await this.onRestart()},this.checkPending=async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const n=[];this.pending.forEach(i=>{n.push(i)}),await this.batchSubscribe(n)},this.registerEventListeners=()=>{this.relayer.core.heartbeat.on(us.pulse,async()=>{await this.checkPending()}),this.events.on(Be.created,async n=>{const i=Be.created;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:n}),await this.persist()}),this.events.on(Be.deleted,async n=>{const i=Be.deleted;this.logger.info(`Emitting ${i}`),this.logger.debug({type:"event",event:i,data:n}),await this.persist()})},this.relayer=e,this.logger=Fe(s,this.name),this.clientId=""}get context(){return Ne(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,s){let n=!1;try{n=this.getSubscription(e).topic===s}catch{}return n}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,s){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,s)))}async unsubscribeById(e,s,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:n}});try{const i=ie("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,s,i);const r=ri(n);await this.restartToComplete({topic:e,id:s,relay:r}),await this.rpcUnsubscribe(e,s,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,s,n){var a,c;const i=await this.getSubscriptionId(e);if((a=n==null?void 0:n.internal)!=null&&a.skipSubscribe)return i;(!n||(n==null?void 0:n.transportType)===ne.relay)&&await this.restartToComplete({topic:e,id:e,relay:s});const r={method:Es(s.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});const o=(c=n==null?void 0:n.internal)==null?void 0:c.throwOnFailedPublish;try{if((n==null?void 0:n.transportType)===ne.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(r).catch(u=>this.logger.warn(u))},R.toMiliseconds(R.ONE_SECOND)),i;const l=new Promise(async u=>{const d=p=>{p.topic===e&&(this.events.removeListener(Be.created,d),u(p.id))};this.events.on(Be.created,d);try{const p=await Qe(new Promise((f,g)=>{this.relayer.request(r).catch(_=>{this.logger.warn(_,_==null?void 0:_.message),g(_)}).then(f)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(Be.created,d),u(p)}catch{}}),h=await Qe(l,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!h&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return h?i:null}catch(l){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(oe.connection_stalled),o)throw l}return null}async rpcBatchSubscribe(e){if(!e.length)return!0;const s=e[0].relay,n={method:Es(s.protocol).batchSubscribe,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await Qe(new Promise((i,r)=>{this.relayer.request(n).then(i).catch(o=>{this.logger.warn(o),r(o)})}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again"),!0}catch{return this.relayer.events.emit(oe.connection_stalled),!1}}async rpcBatchFetchMessages(e){if(!e.length)return;const s=e[0].relay,n={method:Es(s.protocol).batchFetchMessages,params:{topics:e.map(r=>r.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=await await Qe(new Promise((r,o)=>{this.relayer.request(n).catch(a=>{this.logger.warn(a),o(a)}).then(r)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(oe.connection_stalled)}return i}rpcUnsubscribe(e,s,n){const i={method:Es(n.protocol).unsubscribe,params:{topic:e,id:s}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,s){this.setSubscription(e,{...s,id:e}),this.pending.delete(s.topic)}onBatchSubscribe(e){e.length&&e.forEach(s=>{this.setSubscription(s.id,{...s}),this.pending.delete(s.topic)})}async onUnsubscribe(e,s,n){this.events.removeAllListeners(s),this.hasSubscription(s,e)&&this.deleteSubscription(s,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,s){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:s}),this.addSubscription(e,s)}addSubscription(e,s){this.subscriptions.set(e,{...s}),this.topicMap.set(s.topic,e),this.events.emit(Be.created,s)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const s=this.subscriptions.get(e);if(!s){const{message:n}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return s}deleteSubscription(e,s){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:s});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Be.deleted,{...n,reason:s})}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Be.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],s=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let n=0;n<s;n++){const i=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(i)}}this.events.emit(Be.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size&&!e.every(s=>{var n;return s.topic===((n=this.subscriptions.get(s.id))==null?void 0:n.topic)})){const{message:s}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(e.length){if(!await this.rpcBatchSubscribe(e)){this.logger.warn(`Batch subscribe failed for ${e.length} topics, adding to pending for retry`),e.forEach(s=>{this.pending.set(s.topic,s)});return}this.onBatchSubscribe(await Promise.all(e.map(async s=>({...s,id:await this.getSubscriptionId(s.topic)}))))}}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const s=await this.rpcBatchFetchMessages(e);s&&s.messages&&(await Lb(R.toMiliseconds(R.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(s.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return je(e+await this.getClientId())}},I2=class extends HE{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ve.EventEmitter,this.name=Wv,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1,this.heartBeatTimeout=R.toMiliseconds(R.THIRTY_SECONDS+R.FIVE_SECONDS),this.reconnectInProgress=!1,this.requestsInFlight=[],this.connectTimeout=R.toMiliseconds(R.ONE_SECOND*15),this.stalledRestartInProgress=!1,this.stalledRestartBackoff=0,this.stalledRestartBaseInterval=R.toMiliseconds(R.ONE_SECOND*2),this.stalledRestartMaxInterval=R.toMiliseconds(R.THIRTY_SECONDS),this.request=async s=>{var i,r;this.logger.debug("Publishing Request Payload");const n=s.id||Ut().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:s.method,topic:(i=s.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${n}:${((r=s.params)==null?void 0:r.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(s);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}},this.resetPingTimeout=()=>{si()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var s,n,i,r;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(r=(i=(n=(s=this.provider)==null?void 0:s.connection)==null?void 0:n.socket)==null?void 0:i.terminate)==null||r.call(i)}catch(o){this.logger.warn(o,o==null?void 0:o.message)}},this.heartBeatTimeout))},this.onPayloadHandler=s=>{this.onProviderPayload(s),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.warn({},"Relayer connected ð"),this.startPingTimeout(),this.stalledRestartBackoff=0,this.events.emit(oe.connect)},this.onDisconnectHandler=()=>{this.logger.warn({},"Relayer disconnected ð"),this.requestsInFlight=[],this.onProviderDisconnect()},this.onProviderErrorHandler=s=>{this.logger.fatal(`Fatal socket error: ${s.message}`),this.events.emit(oe.error,s),this.logger.fatal("Fatal socket error received, closing transport"),this.transportExplicitlyClosed=!0,clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.reconnectInProgress=!1,this.transportClose().catch(n=>this.logger.warn(n))},this.registerProviderListeners=()=>{this.provider.on(qe.payload,this.onPayloadHandler),this.provider.on(qe.connect,this.onConnectHandler),this.provider.on(qe.disconnect,this.onDisconnectHandler),this.provider.on(qe.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=wo({logger:e.logger??Gv,name:this.name}),this.messages=new w2(this.logger,e.core),this.subscriber=new v2(this,this.logger),this.publisher=new b2(this,this.logger),this.projectId=e.projectId,this.relayUrl=e.relayUrl||Mu,Ib()?this.packageName=Qa():Sb()&&(this.bundleId=Qa()),this.provider={}}
13async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.transportOpen().catch(e=>this.logger.warn(e,e==null?void 0:e.message))}get context(){return Ne(this.logger)}get connected(){var e,s,n;return((n=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:n.readyState)===1}get connecting(){var e,s,n;return((n=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:n.readyState)===0||this.connectPromise!==void 0}async publish(e,s,n){this.isInitialized(),await this.publisher.publish(e,s,n),await this.recordMessageEvent({topic:e,message:s,publishedAt:Date.now(),transportType:ne.relay},Kn.outbound)}async publishCustom(e){this.isInitialized(),await this.publisher.publishCustom(e)}async subscribe(e,s){var a,c;this.isInitialized(),(!(s!=null&&s.transportType)||(s==null?void 0:s.transportType)==="relay")&&await this.toEstablishConnection();const n=((a=s==null?void 0:s.internal)==null?void 0:a.throwOnFailedPublish)??!0;let i=((c=this.subscriber.topicMap.get(e))==null?void 0:c[0])||"",r;const o=l=>{l.topic===e&&(this.subscriber.off(Be.created,o),r())};return await Promise.all([new Promise(l=>{r=l,this.subscriber.on(Be.created,o)}),new Promise((l,h)=>{this.subscriber.subscribe(e,{internal:{throwOnFailedPublish:n},...s}).then(u=>{i=u||i,l()}).catch(u=>{n?h(u):l()})})]),i}async unsubscribe(e,s){this.isInitialized(),await this.subscriber.unsubscribe(e,s)}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Qe(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,clearTimeout(this.stalledRestartTimeout),this.stalledRestartInProgress=!1,this.stalledRestartBackoff=0,await this.resetTransport()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.info("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=this.connect(e).finally(()=>{this.connectPromise=void 0}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.resetTransport(),await this.transportOpen())}async resetTransport(){this.reconnectInProgress=!0,clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,await this.transportDisconnect(),await this.subscriber.stop(),this.reconnectInProgress=!1}async confirmOnlineStateOrThrow(){if(!await yc())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const s=e.sort((n,i)=>n.publishedAt-i.publishedAt);this.logger.debug(`Batch of ${s.length} message events sorted`);for(const n of s)try{await this.onMessageEvent(n)}catch(i){this.logger.warn(i,"Error while processing batch message event: "+(i==null?void 0:i.message))}this.logger.trace(`Batch of ${s.length} message events processed`)}async onLinkMessageEvent(e,s){const{topic:n}=e;if(!s.sessionExists){const i=ce(R.FIVE_MINUTES),r={topic:n,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(n,r)}this.events.emit(oe.message,e),await this.recordMessageEvent(e,Kn.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.transportExplicitlyClosed=!1;let s=1;try{for(;s<6;){this.connectionAttemptInProgress=!0;try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${s}...`),await this.createProvider(),await new Promise((n,i)=>{const r=()=>
vendor: 5,665 bytes, line 13
13{i(new Error("Connection interrupted while trying to connect"))};this.provider.once(qe.disconnect,r),Qe(this.provider.connect(),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).then(()=>n()).catch(i).finally(()=>{this.provider.off(qe.disconnect,r),clearTimeout(this.reconnectTimeout)})}),await new Promise((n,i)=>{const r=()=>{i(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(qe.disconnect,r),this.subscriber.start().then(n).catch(i).finally(()=>{this.provider.off(qe.disconnect,r)})}),this.hasExperiencedNetworkDisruption=!1}catch(n){await this.subscriber.stop();const i=n;this.logger.warn({},i.message),this.hasExperiencedNetworkDisruption=!0}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${s}`);break}await new Promise(n=>setTimeout(n,R.toMiliseconds(s*1))),s++}}finally{this.connectionAttemptInProgress=!1,clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.reconnectInProgress=!1}}startPingTimeout(){var e,s,n;if(si())try{(n=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null||n.on("ping",()=>{this.resetPingTimeout()}),this.resetPingTimeout()}catch(i){this.logger.warn(i,i==null?void 0:i.message)}}async createProvider(){if(this.provider.connection&&(this.unregisterProviderListeners(),this.connected))try{await Qe(this.provider.disconnect(),1e3,"Closing previous provider")}catch{}const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Io(new wv(Ab({sdkVersion:Lr,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,s){const{topic:n,message:i}=e;await this.messages.set(n,i,s)}async shouldIgnoreMessageEvent(e){const{topic:s,message:n}=e;if(!n||n.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isKnownTopic(s))return this.logger.warn(`Ignoring message for unknown topic ${s}`),!0;const i=this.messages.has(s,n);return i&&this.logger.warn(`Ignoring duplicate message: ${n}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),vo(e)){if(!e.method.endsWith(Yv))return;const s=e.params,{topic:n,message:i,publishedAt:r,attestation:o}=s.data,a={topic:n,message:i,publishedAt:r,transportType:ne.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace({type:"event",event:s.id,...a}),this.events.emit(s.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Di(e)&&this.events.emit(oe.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Kn.inbound),this.events.emit(oe.message,e))}async acknowledgePayload(e){const s=cn(e.id,!0);await this.provider.connection.send(s)}unregisterProviderListeners(){this.provider.off(qe.payload,this.onPayloadHandler),this.provider.off(qe.connect,this.onConnectHandler),this.provider.off(qe.disconnect,this.onDisconnectHandler),this.provider.off(qe.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await yc();sE(async s=>{e!==s&&(e=s,s?await this.transportOpen().catch(n=>this.logger.error(n,n==null?void 0:n.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(us.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&rE())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(s){this.logger.warn(s,s==null?void 0:s.message)}}),this.events.on(oe.connection_stalled,()=>{if(this.transportExplicitlyClosed||this.stalledRestartInProgress)return;this.stalledRestartInProgress=!0;const s=this.stalledRestartBackoff===0?0:Math.min(Math.pow(2,this.stalledRestartBackoff-1)*this.stalledRestartBaseInterval,this.stalledRestartMaxInterval);this.stalledRestartBackoff++,this.logger.warn(`Connection stalled, restarting transport${s?` in ${s}ms`:""}...`),this.stalledRestartTimeout=setTimeout(async()=>{try{if(this.transportExplicitlyClosed)return;await this.restartTransport()}catch(n){this.logger.error(n,n==null?void 0:n.message)}finally{this.stalledRestartInProgress=!1}},s)})}async onProviderDisconnect(){if(clearTimeout(this.pingTimeout),this.events.emit(oe.disconnect),!this.reconnectInProgress){this.reconnectInProgress=!0;try{await this.subscriber.stop()}catch(e){this.logger.warn(e,"subscriber.stop() failed during disconnect")}if(!this.subscriber.hasAnyTopics||this.transportExplicitlyClosed){this.reconnectInProgress=!1;return}this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},R.toMiliseconds(Xv))}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}this.connectPromise=this.connect().finally(()=>{this.connectPromise=void 0}),await this.connectPromise}}},ds=class extends KE{constructor(e,s,n,i=ht,r=void 0){super(e,s,n,i),this.core=e,this.logger=s,this.name=n,this.map=new Map,this.version=Zv,this.cached=[],this.initialized=!1,this.storagePrefix=ht,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(
13),this.cached.forEach(o=>{this.getKey&&o!==null&&!de(o)?this.map.set(this.getKey(o),o):$1(o)?this.map.set(o.id,o):N1(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>$v(a[c],o[c]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c={...this.getData(o),...a};this.map.set(o,c),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=Fe(s,this.name),this.storagePrefix=i,this.getKey=r}get context(){return Ne(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const s=this.map.get(e);if(!s){if(this.recentlyDeleted.includes(e)){const{message:i}=P("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:n}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return s}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:s}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}};class S2{constructor(e,s){this.core=e,this.logger=s,this.name=t2,this.version=s2,this.events=new Kr,this.initialized=!1,this.storagePrefix=ht,this.ignoredPayloadTypes=[St],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async n=>{this.isInitialized();const i=Br(),r=await this.core.crypto.setSymKey(i),o=ce(R.FIVE_MINUTES),a={protocol:Uu},c={topic:r,expiry:o,relay:a,active:!1,methods:n==null?void 0:n.methods},l=uc({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:i,relay:a,expiryTimestamp:o,methods:n==null?void 0:n.methods});return this.events.emit(Zt.create,c),this.core.expirer.set(r,o),await this.pairings.set(r,c),await this.core.relayer.subscribe(r,{transportType:n==null?void 0:n.transportType,internal:n==null?void 0:n.internal}),{topic:r,uri:l}},this.pair=async n=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:n==null?void 0:n.uri,trace:[nt.pairing_started]}});this.isValidPair(n,i);const{topic:r,symKey:o,relay:a,expiryTimestamp:c,methods:l}=hc(n.uri);i.props.properties.topic=r,i.addTrace(nt.pairing_uri_validation_success),i.addTrace(nt.pairing_uri_not_expired);let h;if(this.pairings.keys.includes(r)){if(h=this.pairings.get(r),i.addTrace(nt.existing_pairing),h.active)throw i.setError(yt.active_pairing_already_exists),new Error(`Pairing already exists: ${r}. Please try again with a new connection URI.`);
vendor: 7,530 bytes, line 13
13i.addTrace(nt.pairing_not_expired)}const u=c||ce(R.FIVE_MINUTES),d={topic:r,relay:a,expiry:u,active:!1,methods:l};this.core.expirer.set(r,u),await this.pairings.set(r,d),i.addTrace(nt.store_new_pairing),n.activatePairing&&await this.activate({topic:r}),this.events.emit(Zt.create,d),i.addTrace(nt.emit_inactive_pairing),this.core.crypto.keychain.has(r)||await this.core.crypto.setSymKey(o,r),i.addTrace(nt.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(yt.no_internet_connection)}try{await this.core.relayer.subscribe(r,{relay:a})}catch(p){throw i.setError(yt.subscribe_pairing_topic_failure),p}return i.addTrace(nt.subscribe_pairing_topic_success),d},this.activate=async({topic:n})=>{this.isInitialized();const i=ce(R.FIVE_MINUTES);this.core.expirer.set(n,i),await this.pairings.update(n,{active:!0,expiry:i})},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:i}=n;if(this.pairings.keys.includes(i)){const r=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Yt();this.events.once(te("pairing_ping",r),({error:l})=>{l?c(l):a()}),await o()}},this.updateExpiry=async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})},this.updateMetadata=async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:i}=n;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",ie("USER_DISCONNECTED")),await this.deletePairing(i))},this.formatUriFromPairing=n=>{this.isInitialized();const{topic:i,relay:r,expiry:o,methods:a}=n,c=this.core.crypto.keychain.get(i);return uc({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:r,expiryTimestamp:o,methods:a})},this.sendRequest=async(n,i,r)=>{const o=Je(i,r),a=await this.core.crypto.encode(n,o),c=Vs[i].req;return this.core.history.set(n,o),this.core.relayer.publish(n,a,c),o.id},this.sendResult=async(n,i,r)=>{const o=cn(n,r),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,n)).request.method,l=Vs[c].res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)},this.sendError=async(n,i,r)=>{const o=xi(n,r),a=await this.core.crypto.encode(i,o),c=(await this.core.history.get(i,n)).request.method,l=Vs[c]?Vs[c].res:Vs.unregistered_method.res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,ie("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(i=>ot(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=async n=>{const{topic:i,payload:r}=n;switch(r.method){case"wc_pairingPing":return await this.onPairingPingRequest(i,r);case"wc_pairingDelete":return await this.onPairingDeleteRequest(i,r);default:return await this.onUnknownRpcMethodRequest(i,r)}},this.onRelayEventResponse=async n=>{const{topic:i,payload:r}=n,o=(await this.core.history.get(i,r.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,r);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(n,i)=>{const{id:r}=i;try{this.isValidPing({topic:n}),await this.sendResult(r,n,!0),this.events.emit(Zt.ping,{id:r,topic:n})}catch(o){await this.sendError(r,n,o),this.logger.error(o)}},this.onPairingPingResponse=(n,i)=>{const{id:r}=i;setTimeout(()=>{rt(i)?this.events.emit(te("pairing_ping",r),{}):He(i)&&this.events.emit(te("pairing_ping",r),{error:i.error})},500)},this.onPairingDeleteRequest=async(n,i)=>{const{id:r}=i;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit(Zt.delete,{id:r,topic:n})}catch(o){await this.sendError(r,n,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:r,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=ie("WC_METHOD_UNSUPPORTED",o);await this.sendError(r,n,a),this.logger.error(a)}catch(a){await this.sendError(r,n,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(ie("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=(n,i)=>{var o;if(!Re(n)){const{message:a}=P("MISSING_OR_INVALID",`pair() params: ${n}`);throw i.setError(yt.malformed_pairing_uri),new Error(a)}if(!P1(n.uri)){const{message:a}=P("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw i.setError(yt.malformed_pairing_uri),new Error(a)}const r=hc(n==null?void 0:n.uri);if(!((o=r==null?void 0:r.relay)!=null&&o.protocol)){const{message:a}=P("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(yt.malformed_pairing_uri),new Error(a)}if(!(r!=null&&r.symKey)){const{message:a}=P("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(yt.malformed_pairing_uri),new Error(a)}if(r!=null&&r.expiryTimestamp&&R.toMiliseconds(r==null?void 0:r.expiryTimestamp)<Date.now()){i.setError(yt.pairing_expired);const{message:a}=P("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}},this.isValidPing=async n=>{if(!Re(n)){const{message:r}=P("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(r)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidDisconnect=async n=>{if(!Re(n)){const{message:r}=P("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(r)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidPairingTopic=async n=>{if(!le(n,!1)){const{message:i}=P("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=P("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(ot(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=P("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}},this.core=e,this.logger=Fe(s,this.name),this.pairings=new ds(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Ne(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(oe.message,async e=>{const{topic:s,message:n,transportType:i}=e;if(this.pairings.keys.includes(s)&&i!==ne.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))try{const r=await this.core.crypto.decode(s,n);vo(r)?(this.core.history.set(s,r),await this.onRelayEventRequest({topic:s,payload:r})):Di(r)&&(await this.core.history.resolve(r),await this.onRelayEventResponse({topic:s,payload:r}),this.core.history.delete(s,r.id)),await this.core.relayer.messages.ack(s,n)}catch(r){this.logger.error(r)}})}registerExpirerEvents(){this.core.expirer.on(ze.expired,async e=>{const{topic:s}=Yh(e.target);s&&this.pairings.keys.includes(s)&&(await this.deletePairing(s,!0),this.events.emit(Zt.expire,{topic:s}))})}}class x2 extends qE{constructor(e,s){super(e,s),this.core=e,this.logger=s,this.records=new Map,this.events=new Ve.EventEmitter,this.name=n2,this.version=i2,this.cached=[],this.initialized=!1,this.storagePrefix=ht,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(
vendor: 4,183 bytes, line 13
13),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:r}),this.records.has(i.id))return;const o={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:r,expiry:ce(R.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(We.created,o)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response<"u"||(i.response=He(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.persist(),this.events.emit(We.updated,i))},this.get=async(n,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),await this.getRecord(i)),this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(r=>{if(r.topic===n){if(typeof i<"u"&&r.id!==i)return;this.records.delete(r.id),this.events.emit(We.deleted,r)}}),this.persist()},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Fe(s,this.name)}get context(){return Ne(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(s=>{if(typeof s.response<"u")return;const n={topic:s.topic,request:Je(s.request.method,s.request.params,s.id),chainId:s.chainId};return e.push(n)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const s=this.records.get(e);if(!s){const{message:n}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return s}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(We.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:s}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(We.created,e=>{const s=We.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(We.updated,e=>{const s=We.updated;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(We.deleted,e=>{const s=We.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.core.heartbeat.on(us.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(s=>{R.toMiliseconds(s.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${s.id}`),this.records.delete(s.id),this.events.emit(We.deleted,s,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class D2 extends GE{constructor(e,s){super(e,s),this.core=e,this.logger=s,this.expirations=new Map,this.events=new Ve.EventEmitter,this.name=r2,this.version=o2,this.cached=[],this.initialized=!1,this.storagePrefix=ht,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(
vendor: 4,183 bytes, line 13
13),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const r=this.formatTarget(n),o={target:r,expiry:i};this.expirations.set(r,o),this.checkExpiry(r,o),this.events.emit(ze.created,{target:r,expiration:o})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{if(this.isInitialized(),this.has(n)){const i=this.formatTarget(n),r=this.getExpiration(i);this.expirations.delete(i),this.events.emit(ze.deleted,{target:i,expiration:r})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Fe(s,this.name)}get context(){return Ne(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Tb(e);if(typeof e=="number")return Rb(e);const{message:s}=P("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(s)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(ze.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:s}=P("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const s=this.expirations.get(e);if(!s){const{message:n}=P("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(n),new Error(n)}return s}checkExpiry(e,s){const{expiry:n}=s;R.toMiliseconds(n)-Date.now()<=0&&this.expire(e,s)}expire(e,s){this.expirations.delete(e),this.events.emit(ze.expired,{target:e,expiration:s})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,s)=>this.checkExpiry(s,e))}registerEventListeners(){this.core.heartbeat.on(us.pulse,()=>this.checkExpirations()),this.events.on(ze.created,e=>{const s=ze.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(ze.expired,e=>{const s=ze.expired;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(ze.deleted,e=>{const s=ze.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}}class O2 extends WE{constructor(e,s,n){super(e,s,n),this.core=e,this.logger=s,this.store=n,this.name=a2,this.verifyUrlV3=l2,this.storagePrefix=ht,this.version=Bu,this.init=async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&R.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async i=>{if(!Cs()||this.isDevEnv)return;const r=window.location.origin,{id:o,decryptedId:a}=i,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${r}&id=${o}&decryptedId=${a}`;try{const l=ns(),h=this.startAbortTimer(R.ONE_SECOND*5),u=await new Promise((d,p)=>{const f=()=>{window.removeEventListener("message",_),l.body.removeChild(g),p("attestation aborted")};this.abortController.signal.addEventListener("abort",f);const g=l.createElement("iframe");g.src=c,g.style.display="none",g.addEventListener("error",f,{signal:this.abortController.signal});const _=v=>
vendor: 4,146 bytes, line 13
13{if(v.data&&typeof v.data=="string")try{const A=JSON.parse(v.data);if(A.type==="verify_attestation"){if(Tr(A.attestation).payload.id!==o)return;clearInterval(h),l.body.removeChild(g),this.abortController.signal.removeEventListener("abort",f),window.removeEventListener("message",_),d(A.attestation===null?"":A.attestation)}}catch(A){this.logger.warn(A)}};l.body.appendChild(g),window.addEventListener("message",_,{signal:this.abortController.signal})});return this.logger.debug(u,"jwt attestation"),u}catch(l){this.logger.warn(l)}return""},this.resolve=async i=>{if(this.isDevEnv)return"";const{attestationId:r,hash:o,encryptedId:a}=i;if(r===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(r){if(Tr(r).payload.id!==a)return;const l=await this.isValidJwtAttestation(r);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,c)},this.fetchAttestation=async(i,r)=>{this.logger.debug(`resolving attestation: ${i} from url: ${r}`);const o=this.startAbortTimer(R.ONE_SECOND*5),a=await fetch(`${r}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=i=>{let r=i||tn;return h2.includes(r)||(this.logger.info(`verify url: ${r}, not included in trusted list, assigning default: ${tn}`),r=tn),r},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(R.FIVE_SECONDS),r=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),await r.json()}catch(i){this.logger.warn(i)}},this.persistPublicKey=async i=>{this.logger.debug(i,"persisting public key to local storage"),await this.store.setItem(this.storeKey,i),this.publicKey=i},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async i=>{const r=await this.getPublicKey();try{if(r)return this.validateAttestation(i,r)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async r=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),r(o))});const i=await this.fetchPromise;return this.fetchPromise=void 0,i},this.validateAttestation=(i,r)=>{const o=w1(i,r.publicKey),a={hasExpired:R.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}},this.logger=Fe(s,this.name),this.abortController=new AbortController,this.isDevEnv=_o(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Ne(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),R.toMiliseconds(e))}}class k2 extends YE{constructor(e,s){super(e,s),this.projectId=e,this.logger=s,this.context=u2,this.registerDeviceToken=async n=>{const{clientId:i,token:r,notificationType:o,enableEncrypted:a=!1}=n,c=`${d2}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:r,always_raw:a})})},this.logger=Fe(s,this.context)}}let A2=class extends XE{constructor(e,s,n=!0){super(e,s,n),this.core=e,this.logger=s,this.context=f2,this.storagePrefix=ht,this.storageVersion=p2,this.events=new Map,this.shouldPersist=!1,this.init=async()=>
13{if(!_o())try{const i={eventId:tc(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Gh(this.core.relayer.protocol,this.core.relayer.version,Lr)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}},this.createEvent=i=>{const{event:r="ERROR",type:o="",properties:{topic:a,trace:c}}=i,l=tc(),h=this.core.projectId||"",u=Date.now(),d={eventId:l,timestamp:u,props:{event:r,type:o,properties:{topic:a,trace:c}},bundleId:h,domain:this.getAppDomain(),...this.setMethods(l)};return this.telemetryEnabled&&(this.events.set(l,d),this.shouldPersist=!0),d},this.getEvent=i=>{const{eventId:r,topic:o}=i;if(r)return this.events.get(r);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return{...a,...this.setMethods(a.eventId)}},this.deleteEvent=i=>{const{eventId:r}=i;this.events.delete(r),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(us.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{R.fromMiliseconds(Date.now())-R.fromMiliseconds(i.timestamp)>g2&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})},this.setMethods=i=>({addTrace:r=>this.addTrace(i,r),setError:r=>this.setError(i,r)}),this.addTrace=(i,r)=>{const o=this.events.get(i);o&&(o.props.properties.trace.push(r),this.events.set(i,o),this.shouldPersist=!0)},this.setError=(i,r)=>{const o=this.events.get(i);o&&(o.props.type=r,o.timestamp=Date.now(),this.events.set(i,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(r=>{this.events.set(r.eventId,{...r,...this.setMethods(r.eventId)})})}catch(i){this.logger.warn(i)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const i=[];for(const[r,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((await this.sendEvent(i)).ok)for(const r of i)this.events.delete(r.eventId),this.shouldPersist=!0}catch(r){this.logger.warn(r)}},this.sendEvent=async i=>{const r=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${_2}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Lr}${r}`,{method:"POST",body:JSON.stringify(i)})},this.getAppDomain=()=>Vh().url,this.logger=Fe(s,this.context),this.telemetryEnabled=n,n?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},T2=class Fu extends FE{constructor(e){var o;super(e),this.protocol=Cu,this.version=Bu,this.name=hi,this.events=new Ve.EventEmitter,this.initialized=!1,this.on=(a,c)=>this.events.on(a,c),this.once=(a,c)=>this.events.once(a,c),this.off=(a,c)=>this.events.off(a,c),this.removeListener=(a,c)=>this.events.removeListener(a,c),this.dispatchEnvelope=({topic:a,message:c,sessionExists:l})=>{if(!a||!c)return;const h={topic:a,message:c,publishedAt:Date.now(),transportType:ne.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:l})};const s=this.getGlobalCore(e==null?void 0:e.customStoragePrefix);if(s)try{return this.customStoragePrefix=s.customStoragePrefix,this.logger=s.logger,this.heartbeat=s.heartbeat,this.crypto=s.crypto,this.history=s.history,this.expirer=s.expirer,this.storage=s.storage,this.relayer=s.relayer,this.pairing=s.pairing,this.verify=s.verify,this.echoClient=s.echoClient,this.linkModeSupportedApps=s.linkModeSupportedApps,this.eventClient=s.eventClient,this.initialized=s.initialized,this.logChunkController=s.logChunkController,s}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Mu,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const n=pb({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:Uv.logger,name:hi}),{logger:i,chunkLoggerController:r}=Hh({opts:n,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=r,(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Fe(i,this.name),this.heartbeat=new bo,this.crypto=new y2(this,this.logger,e==null?void 0:e.keychain),this.history=new x2(this,this.logger),this.expirer=new D2(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new LE({...Mv,...e==null?void 0:e.storageOptions}),this.relayer=new I2({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new S2(this,this.logger),this.verify=new O2(this,this.logger,this.storage),this.echoClient=new k2(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new A2(this,this.logger,e==null?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const s=new Fu(e);await s.initialize();const n=await s.crypto.getClientId();return await s.storage.setItem(Jv,n),s}get context(){return Ne(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Nc,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(
vendor: 13,561 bytes, line 13
13),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Nc)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(e,`Core Initialization Failure at epoch ${Date.now()}`),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const s=`_walletConnectCore_${e}`,n=`${s}_count`;return globalThis[n]=(globalThis[n]||0)+1,globalThis[n]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[n]} times.`),globalThis[s]}catch(s){console.warn("Failed to get global WalletConnect core",s);return}}setGlobalCore(e){var s;try{if(this.isGlobalCoreDisabled())return;const n=`_walletConnectCore_${((s=e.opts)==null?void 0:s.customStoragePrefix)||""}`;globalThis[n]=e}catch(n){console.warn("Failed to set global WalletConnect core",n)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&{GITHUB_STATE:"/home/runner/work/_temp/_runner_file_commands/save_state_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",npm_package_dependencies__across_protocol_app_sdk:"^0.6.1",npm_package_dependencies__reduxjs_toolkit:"^2.8.0",npm_package_dependencies_zod:"3.23.8",npm_package_devDependencies__types_node:"^20.8.8",npm_package_devDependencies_vite_tsconfig_paths:"^4.0.8",DOTNET_NOLOGO:"1",npm_package_scripts_test_smoke:"vitest run --config vitest.smoke.config.ts --mode production",npm_package_devDependencies_vitest:"^1.6.0",USER:"runner",npm_config_always_auth:"",npm_config_user_agent:"pnpm/8.9.2 npm/? node/v21.0.0 linux x64",CI:"false",npm_package_dependencies__near_wallet_selector_my_near_wallet:"^8.10.2",npm_package_dependencies_react_device_detect:"^1.17.0",npm_package_devDependencies__lingui_swc_plugin:"^4.0.4",USE_BAZEL_FALLBACK_VERSION:"silent:",RUNNER_ENVIRONMENT:"github-hosted",GITHUB_ENV:"/home/runner/work/_temp/_runner_file_commands/set_env_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",PIPX_HOME:"/opt/pipx",npm_package_dependencies__coinbase_wallet_sdk:"^4.3.7",npm_package_dependencies__kyberswap_price_slider:"workspace:*",npm_package_dependencies__walletconnect_ethereum_provider:"^2.21.1",npm_package_devDependencies__types_react_window_infinite_loader:"^1.0.6",npm_package_devDependencies_vite:"^4.3.9",npm_node_execpath:"/opt/hostedtoolcache/node/21.0.0/x64/bin/node",JAVA_HOME_8_X64:"/usr/lib/jvm/temurin-8-jdk-amd64",NODE_AUTH_TOKEN:"XXXXX-XXXXX-XXXXX-XXXXX",SHLVL:"1",HCA_CLOUD_PROVIDER:"azure",npm_package_dependencies__metamask_connect_evm:"^2.1.0",npm_package_dependencies_process:"^0.11.10",npm_package_dependencies_wagmi:"^3.6.20",npm_config__kybernetwork_registry:"https://npm.pkg.github.com",HOME:"/home/runner",npm_package_devDependencies__types_react_window:"^1.8.5",npm_package_devDependencies__typescript_eslint_parser:"^5.58.0",RUNNER_TEMP:"/home/runner/work/_temp",GITHUB_EVENT_PATH:"/home/runner/work/_temp/_github_workflow/event.json",npm_package_dependencies__formo_analytics:"^1.38.0",npm_package_devDependencies_eslint_config_prettier:"^8.5.0",JAVA_HOME_11_X64:"/usr/lib/jvm/temurin-11-jdk-amd64",PIPX_BIN_DIR:"/opt/pipx_bin",GITHUB_REPOSITORY_OWNER:"KyberNetwork",npm_package_dependencies__kyberswap_zap_out_widgets:"workspace:*",npm_package_dependencies_framer_motion:"^11.18.2",NODE_OPTIONS:"--max_old_space_size=4096",GRADLE_HOME:"/usr/share/gradle-9.7.1",ANDROID_NDK_LATEST_HOME:"/usr/local/lib/android/sdk/ndk/29.0.14206865",JAVA_HOME_21_X64:"/usr/lib/jvm/temurin-21-jdk-amd64",GITHUB_RETENTION_DAYS:"1",npm_package_dependencies__kyber_schema:"workspace:^",npm_package_dependencies_ua_parser_js:"^1.0.33",GITHUB_REPOSITORY_OWNER_ID:"28812853",POWERSHELL_DISTRIBUTION_CHANNEL:"GitHub-Actions-Linux",AZURE_EXTENSION_DIR:"/opt/az/azcliextensions",GITHUB_HEAD_REF:"",npm_package_dependencies__kyber_hooks:"workspace:^",npm_package_dependencies__kyberswap_zap_migration_widgets:"workspace:*",npm_package_dependencies__solana_web3_js:"^1.98.2",npm_package_dependencies_class_variance_authority:"^0.7.0",npm_package_dependencies_html2canvas:"^1.4.1",npm_package_dependencies_react_feather:"^2.0.10",npm_package_dependencies_react_indiana_drag_scroll:"^2.0.1",npm_package_dependencies_walktour:"^5.2.0",npm_config_userconfig:"/home/runner/work/_temp/.npmrc",SYSTEMD_EXEC_PID:"1959",BUILD_DATE:"2026-09-29T06:42:17+0000",ACTIONS_ORCHESTRATION_ID:"aee56758-a70d-4762-b6f5-93897fd52d40.build.__default",npm_package_dependencies__defuse_protocol_one_click_sdk_typescript:"^0.1.2",npm_package_dependencies__kyberswap_ks_sdk_core:"1.1.19",npm_package_dependencies__near_wallet_selector_sender:"^8.10.2",npm_package_dependencies_dayjs:"^1.11.6",npm_package_devDependencies_eslint_plugin_react_hooks:"^4.6.0",GITHUB_GRAPHQL_URL:"https://api.github.com/graphql",npm_package_description:"KyberSwap Interface",npm_package_dependencies__kyberswap_ks_sdk_classic:"^1.0.3",npm_package_dependencies_react_qrcode_logo:"^4.1.0",npm_package_dependencies_react_router_dom:"6.5.0",npm_package_devDependencies__lingui_cli:"^4.6.0",npm_package_devDependencies_tailwindcss:"^3.4.13",npm_package_devDependencies_typescript:"^5.7.3",npm_package_devDependencies_vite_plugin_svgr:"^2.4.0",JAVA_HOME_25_X64:"/usr/lib/jvm/temurin-25-jdk-amd64",NVM_DIR:"/home/runner/.nvm",npm_package_homepage:"/",npm_package_dependencies_jsbi:"^3.2.5",npm_package_devDependencies__types_react_dom:"^19.0.0",DOTNET_SKIP_FIRST_TIME_EXPERIENCE:"1",JAVA_HOME_17_X64:"/usr/lib/jvm/temurin-17-jdk-amd64",ImageVersion:"20260920.314.1",VITE_TAG:"v7.11.3",npm_package_scripts_dev:"vite --mode production --host",npm_package_dependencies__kyber_rpc_client:"workspace:*",npm_package_dependencies__lifi_sdk:"^3.6.8",npm_package_devDependencies__types_lodash_debounce:"^4.0.9",npm_package_devDependencies__vitejs_plugin_react_swc:"^3.5.0",npm_package_devDependencies_prettier:"^2.7.1",npm_package_devDependencies_vite_plugin_checker:"^0.5.6",LOGNAME:"runner",RUNNER_OS:"Linux",GITHUB_API_URL:"https://api.github.com",GITHUB_ARTIFACTS:"/home/runner/work/_temp/_runner_file_commands/artifacts_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",SWIFT_PATH:"/usr/share/swift/usr/bin",npm_package_scripts_i18n:"pnpm run i18n:extract && pnpm run i18n:compile",npm_package_scripts_i18n_extract:"lingui extract",npm_package_dependencies__kyberswap_ks_sdk_elastic:"^1.1.2",npm_package_dependencies__relayprotocol_relay_sdk:"^5.1.0",npm_package_dependencies__safe_global_safe_apps_sdk:"^9.1.0",npm_package_dependencies_react_popper:"^2.2.3",npm_package_dependencies_react_window_infinite_loader:"^1.0.8",npm_package_devDependencies__babel_preset_typescript:"^7.21.4",CHROMEWEBDRIVER:"/usr/local/share/chromedriver-linux64",JOURNAL_STREAM:"9:11910",GITHUB_WORKFLOW:"KyberSwap Interface Release",_:"/home/runner/setup-pnpm/node_modules/.bin/pnpm",npm_package_private:"true",npm_package_dependencies__near_wallet_selector_hot_wallet:"^8.10.2",npm_package_dependencies__reach_portal:"^0.17.0",npm_package_dependencies_events:"^3.3.0",npm_package_dependencies_tiny_invariant:"^1.3.3",npm_package_devDependencies__babel_preset_react:"^7.18.6",npm_package_devDependencies_autoprefixer:"^10.4.20",MEMORY_PRESSURE_WATCH:"/sys/fs/cgroup/system.slice/hosted-compute-agent.service/memory.pressure",GOROOT_1_24_X64:"/opt/hostedtoolcache/go/1.24.13/x64",npm_package_scripts_lint:"eslint --ext ts,tsx src",npm_package_dependencies__near_wallet_selector_modal_ui:"^8.10.2",npm_package_dependencies_react_window:"^1.8.9",npm_package_devDependencies__types_uuid:"^8.3.4",npm_package_devDependencies__typescript_eslint_eslint_plugin:"^5.58.0",npm_config_registry:"https://registry.npmjs.org/",ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE:"/opt/actionarchivecache",GOROOT_1_25_X64:"/opt/hostedtoolcache/go/1.25.14/x64",GITHUB_RUN_ID:"36532455599",VERSION_TAG:"v7.11.3",npm_package_dependencies__lingui_react:"^4.6.0",npm_package_devDependencies__babel_core:"^7.21.4",GITHUB_REF_TYPE:"branch",BOOTSTRAP_HASKELL_NONINTERACTIVE:"1",GITHUB_WORKFLOW_SHA:"fdc34852d18af13946b75f101d7604f5c07f291a",GOROOT_1_26_X64:"/opt/hostedtoolcache/go/1.26.8/x64",GITHUB_BASE_REF:"",ImageOS:"ubuntu24",npm_package_dependencies__kyberswap_zap_create_widgets:"workspace:*",npm_package_dependencies__use_gesture_react:"^10.2.27",npm_package_dependencies_tailwind_merge:"^2.5.5",GITHUB_WORKFLOW_REF:"KyberNetwork/kyberswap-interface/.github/workflows/ks-interface-release.yaml@refs/heads/main",GITHUB_ACTION_REPOSITORY:"",ENABLE_RUNNER_TRACING:"true",npm_package_dependencies__near_wallet_selector_nightly:"^8.10.2",npm_package_dependencies_axios:"1.2.1",npm_package_dependencies_recharts:"2.15.4",npm_package_devDependencies__types_mixpanel_browser:"^2.38.0",npm_package_devDependencies_prettier_plugin_tailwindcss:"0.4.1",npm_config_node_gyp:"/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js",PATH:"/home/runner/work/kyberswap-interface/kyberswap-interface/apps/kyberswap-interface/node_modules/.bin:/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/dist/node-gyp-bin:/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.bin:/opt/hostedtoolcache/node/21.0.0/x64/bin:/home/runner/setup-pnpm/node_modules/.bin:/snap/bin:/home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",ANT_HOME:"/usr/share/ant",DOTNET_MULTILEVEL_LOOKUP:"0",RUNNER_TRACKING_ID:"github_7212fc8c-ceb2-467a-b36c-c7189475cb3b",INVOCATION_ID:"776ff34c8e8949c2aa2f6eb830c69a14",NPM_CONFIG_USERCONFIG:"/home/runner/work/_temp/.npmrc",RUNNER_TOOL_CACHE:"/opt/hostedtoolcache",npm_package_name:"@kyberswap/interface",npm_package_dependencies__lingui_macro:"^4.6.0",npm_package_dependencies__reach_dialog:"^0.17.0",npm_package_dependencies_swiper:"^8.4.4",npm_package_devDependencies__types_crypto_js:"4.1.1",npm_package_devDependencies__types_react_gtm_module:"^2.0.1",NODE:"/opt/hostedtoolcache/node/21.0.0/x64/bin/node",GITHUB_ACTION:"__run_5",GITHUB_RUN_NUMBER:"413",GITHUB_TRIGGERING_ACTOR:"tienkane",RUNNER_ARCH:"X64",XDG_RUNTIME_DIR:"/run/user/1001",AGENT_TOOLSDIRECTORY:"/opt/hostedtoolcache",npm_package_scripts_analyze:"NODE_OPTIONS=--max_old_space_size=8192 ANALYZE=1 vite build",npm_package_dependencies__safe_global_safe_apps_provider:"^0.18.6",npm_package_dependencies_react_redux:"^9.2.0",npm_package_dependencies_viem:"^2.48.11",npm_package_devDependencies__types_numeral:"^2.0.0",npm_package_devDependencies_eslint_plugin_jsx_a11y:"^6.7.1",npm_config_frozen_lockfile:"",npm_package_dependencies__kyber_utils:"workspace:*",npm_package_dependencies_memoize_one:"^6.0.0",npm_package_devDependencies_tailwindcss_animate:"^1.0.7",SERVICE:"kyberswap-interface",LANG:"C.UTF-8",VCPKG_INSTALLATION_ROOT:"/usr/local/share/vcpkg",npm_package_dependencies__solana_wallet_adapter_react:"^0.15.39",npm_package_dependencies_bitcoinjs_lib:"^6.1.7",npm_package_dependencies_react_dom:"^19.2.6",npm_package_dependencies_use_sound:"^5.0.0",npm_package_devDependencies__types_lodash_throttle:"^4.1.9",npm_package_devDependencies_eslint:"^8.38.0",CONDA:"/usr/share/miniconda",RUNNER_NAME:"GitHub Actions 1000076050",XDG_CONFIG_HOME:"/home/runner/.config",GITHUB_REF_NAME:"main",GITHUB_REPOSITORY:"KyberNetwork/kyberswap-interface",npm_package_browserslist_0:"chrome >= 52",npm_package_dependencies__mayanfinance_swap_sdk:"^13.2.0",npm_package_dependencies__near_wallet_selector_meteor_wallet:"^8.10.2",npm_package_dependencies__solana_wallet_adapter_base:"^0.9.27",npm_package_dependencies_lodash_debounce:"^4.0.8",npm_package_devDependencies_babel_plugin_lodash:"^3.3.4",npm_lifecycle_script:"pnpm run i18n && tsc && vite build && pnpm run prerender",ANDROID_NDK_ROOT:"/usr/local/lib/android/sdk/ndk/27.3.13750724",GITHUB_ACTION_REF:"",DEBIAN_FRONTEND:"noninteractive",npm_package_scripts_test:"vitest run --exclude '**/*.smoke.test.*'",npm_package_browserslist_1:"opera >= 39",npm_package_dependencies__bitcoinerlab_secp256k1:"^1.2.0",npm_package_dependencies_react_router:"^6.5.0",npm_package_dependencies_workbox_precaching:"^6.5.4",npm_package_dependencies_workbox_strategies:"^7.3.0",npm_package_devDependencies__trivago_prettier_plugin_sort_imports:"^3.3.1",SHELL:"/bin/bash",GITHUB_REPOSITORY_ID:"343321701",GITHUB_ACTIONS:"true",NODE_PATH:"/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/bin/node_modules:/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/node_modules:/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.pnpm/[email protected]_@[email protected]/node_modules:/home/runner/work/kyberswap-interface/kyberswap-interface/node_modules/.pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/bin/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules:/home/runner/setup-pnpm/node_modules/.pnpm/node_modules",npm_package_browserslist_2:"edge >= 14",npm_package_dependencies__esbuild_plugins_node_globals_polyfill:"^0.2.3",npm_package_dependencies__solana_spl_token:"^0.4.13",npm_package_devDependencies__types_react:"^19.0.0",npm_package_devDependencies_eslint_plugin_unused_imports:"^2.0.0",npm_lifecycle_event:"build",GITHUB_REF_PROTECTED:"true",npm_package_scripts_build:"pn
13pm run i18n && tsc && vite build && pnpm run prerender",npm_package_browserslist_3:"firefox >= 52",npm_package_dependencies_buffer:"^6.0.3",npm_package_dependencies_react_rnd:"10.4.1",npm_package_dependencies_react_virtualized_auto_sizer:"^1.0.7",npm_package_dependencies_uuid:"^11.1.0",GITHUB_WORKSPACE:"/home/runner/work/kyberswap-interface/kyberswap-interface",ACCEPT_EULA:"Y",GITHUB_JOB:"build",npm_package_scripts_check_bundle_size:"node scripts/check-entry-size.mjs",npm_package_browserslist_4:"safari >= 10.1",npm_package_dependencies__near_wallet_selector_core:"^8.10.2",npm_package_dependencies_siwe:"^2.3.2",GITHUB_SHA:"fdc34852d18af13946b75f101d7604f5c07f291a",GITHUB_RUN_ATTEMPT:"1",npm_package_browserslist_5:"node >= 7",npm_package_dependencies__tanstack_react_query:"^5.52.1",npm_package_devDependencies_eslint_plugin_tailwindcss:"^3.17.5",ACTIONS_RUNNER_RETURN_JOB_RESULT_FOR_HOSTED:"1",GITHUB_REF:"refs/heads/main",GITHUB_ACTOR:"tienkane",ANDROID_SDK_ROOT:"/usr/local/lib/android/sdk",npm_package_license:"GPL-3.0-or-later",npm_package_browserslist_6:"ios >= 10.3",npm_package_dependencies__kyber_token_selector:"workspace:^",npm_package_dependencies_clsx:"^2.1.1",npm_package_dependencies_lightweight_charts:"^3.3.0",npm_package_dependencies_mixpanel_browser:"^2.45.0",npm_package_dependencies_workbox_core:"^6.5.4",npm_package_dependencies_workbox_routing:"^6.5.4",npm_package_devDependencies_eslint_plugin_react:"^7.31.10",npm_package_scripts_format:"prettier --write .",npm_package_browserslist_7:"samsung >= 6",npm_package_dependencies__kyberswap_oauth2:"1.0.2",npm_package_dependencies__ledgerhq_hw_app_btc:"^10.9.1",npm_package_dependencies__zkmelabs_widget:"^0.1.3",npm_package_dependencies_crypto_js:"4.1.1",npm_package_dependencies_firebase:"^9.8.2",npm_package_dependencies_html5_qrcode:"^2.3.8",npm_package_dependencies_react_date_picker:"12.0.2",npm_package_dependencies_react_gtm_module:"^2.0.11",npm_package_dependencies_stream_browserify:"^3.0.0",npm_package_devDependencies__lingui_vite_plugin:"^4.6.0",npm_package_devDependencies_eslint_plugin_prettier:"^4.2.1",GITHUB_PATH:"/home/runner/work/_temp/_runner_file_commands/add_path_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",JAVA_HOME:"/usr/lib/jvm/temurin-17-jdk-amd64",PWD:"/home/runner/work/kyberswap-interface/kyberswap-interface/apps/kyberswap-interface",GITHUB_ACTOR_ID:"41465652",RUNNER_WORKSPACE:"/home/runner/work/kyberswap-interface",npm_package_browserslist_8:"electron >= 1.3",npm_package_dependencies__kyberswap_liquidity_widgets:"workspace:*",npm_package_dependencies__lingui_core:"^4.6.0",npm_package_dependencies__near_wallet_selector_math_wallet:"^8.10.2",npm_package_dependencies_numeral:"^2.0.6",npm_execpath:"/home/runner/setup-pnpm/node_modules/.pnpm/[email protected]/node_modules/pnpm/bin/pnpm.cjs",HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS:"3650",GITHUB_EVENT_NAME:"workflow_dispatch",HOMEBREW_NO_AUTO_UPDATE:"1",ANDROID_HOME:"/usr/local/lib/android/sdk",GITHUB_SERVER_URL:"https://github.com",GECKOWEBDRIVER:"/usr/local/share/gecko_driver",GHCUP_INSTALL_BASE_PREFIX:"/usr/local",GITHUB_OUTPUT:"/home/runner/work/_temp/_runner_file_commands/set_output_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",npm_package_browserslist_9:"ChromeAndroid >= 52",npm_package_dependencies__popperjs_core:"^2.11.6",npm_package_dependencies_dompurify:"^3.0.6",npm_package_dependencies_near_api_js:"^5.1.1",npm_package_devDependencies_vite_plugin_compression2:"^2.5.3",EDGEWEBDRIVER:"/usr/local/share/edge_driver",npm_package_dependencies__kyber_ui:"workspace:^",npm_package_dependencies__ledgerhq_hw_transport:"^6.31.5",npm_package_dependencies__near_wallet_selector_react_hook:"^9.0.0",npm_package_dependencies__solana_wallet_standard_wallet_adapter_react:"^1.1.4",npm_package_dependencies__wagmi_core:"^3.5.4",npm_package_dependencies_date_fns:"^4.1.0",npm_package_dependencies_lodash_throttle:"^4.1.1",npm_package_dependencies_util:"^0.12.5",npm_package_devDependencies_babel_plugin_macros:"^3.1.0",npm_package_devDependencies_eslint_plugin_lingui:"^0.2.0",npm_package_devDependencies_postcss:"^8.4.47",npm_command:"run-script",PNPM_SCRIPT_SRC_DIR:"/home/runner/work/kyberswap-interface/kyberswap-interface/apps/kyberswap-interface",ANDROID_NDK:"/usr/local/lib/android/sdk/ndk/27.3.13750724",GITHUB_ARTIFACTS_LIST:"/home/runner/work/_temp/_runner_file_commands/artifacts_list_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",SGX_AESM_ADDR:"1",PSModulePath:"/root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules:/usr/share/az_15.6.1",CHROME_BIN:"/usr/bin/google-chrome",npm_package_scripts_preview:"vite preview",npm_package_scripts_i18n_compile:"lingui compile",npm_package_dependencies__near_wallet_selector_ledger:"^8.10.2",npm_package_dependencies_countries_and_timezones:"^3.7.2",npm_package_dependencies_porto:"^0.2.37",npm_package_devDependencies_rollup_plugin_visualizer:"^7.0.1",SELENIUM_JAR_PATH:"/usr/share/java/selenium-server.jar",MEMORY_PRESSURE_WRITE:"c29tZSAyMDAwMDAgMjAwMDAwMAA=",PNPM_HOME:"/home/runner/setup-pnpm/node_modules/.bin",npm_package_dependencies__kyberswap_compounding_widget:"workspace:*",npm_package_dependencies__ledgerhq_hw_transport_webusb:"^6.29.5",npm_package_dependencies_react_loading_skeleton:"^3.1.0",npm_package_dependencies_react_use:"^15.3.4",npm_package_devDependencies__types_ua_parser_js:"^0.7.36",ANDROID_NDK_HOME:"/usr/local/lib/android/sdk/ndk/27.3.13750724",GITHUB_STEP_SUMMARY:"/home/runner/work/_temp/_runner_file_commands/step_summary_00eed7e6-001e-4d7c-ae7a-d6a8bff47f64",npm_package_scripts_prerender:"node scripts/prerender.mjs",npm_package_dependencies__kyberswap_liquidity_chart:"workspace:*",npm_package_dependencies_react:"^19.2.6",npm_package_dependencies_redux_localstorage_simple:"^2.5.1",INIT_CWD:"/home/runner/work/kyberswap-interface/kyberswap-interface/apps/kyberswap-interface",NODE_ENV:"production"}.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const R2=T2,qu="wc",zu=2,ju="client",Ao=`${qu}@${zu}:${ju}:`,or={name:ju,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},Cc="WALLETCONNECT_DEEPLINK_CHOICE",P2="proposal",Bc="Proposal expired",$2="session",ws=R.SEVEN_DAYS,N2="engine",we={wc_sessionPropose:{req:{ttl:R.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:R.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:R.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:R.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:R.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:R.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:R.ONE_DAY,prompt:!1,tag:1104},res:{ttl:R.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:R.ONE_DAY,prompt:!1,tag:1106},res:{ttl:R.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:R.FIVE_MINUTES*3,prompt:!0,tag:1108},res:{ttl:R.FIVE_MINUTES*3,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:R.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:R.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:R.ONE_DAY,prompt:!1,tag:1112},res:{ttl:R.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:R.ONE_DAY,prompt:!1,tag:1114},res:{ttl:R.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:R.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:R.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:R.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:R.FIVE_MINUTES,prompt:!1,tag:1119}}},ar={min:R.FIVE_MINUTES,max:R.SEVEN_DAYS},st={idle:"IDLE",active:"ACTIVE"},C2={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"},sui_signAndExecuteTransaction:{key:"digest"},sui_signTransaction:{key:""},hedera_signAndExecuteTransaction:{key:"transactionId"},hedera_executeTransaction:{key:"transactionId"},near_signTransaction:{key:""},near_signTransactions:{key:""},tron_signTransaction:{key:"txID"},xrpl_signTransaction:{key:""},xrpl_signTransactionFor:{key:""},algo_signTxn:{key:""},sendTransfer:{key:"txid"},stacks_stxTransfer:{key:"txId"},polkadot_signTransaction:{key:""}
vendor: 42,907 bytes, line 13
13,cosmos_signDirect:{key:""}},B2="request",U2=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],M2="wc",L2="auth",F2="authKeys",q2="pairingTopics",z2="requests",Oi=`${M2}@${1.5}:${L2}:`,Pt=`${Oi}:PUB_KEY`;class j2 extends JE{constructor(e){super(e),this.name=N2,this.events=new Kr,this.initialized=!1,this.requestQueue={state:st.idle,queue:[]},this.sessionRequestQueue={state:st.idle,queue:[]},this.emittedSessionRequests=new Fb({limit:500}),this.requestQueueDelay=R.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.pendingSessions=new Map,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.registerSubscriptionCleanup(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(we)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},R.toMiliseconds(this.requestQueueDelay)))},this.connect=async s=>{var N;this.isInitialized(),await this.confirmOnlineStateOrThrow();const n={...s,requiredNamespaces:s.requiredNamespaces||{},optionalNamespaces:s.optionalNamespaces||{}};await this.isValidConnect(n),n.optionalNamespaces=A1(n.requiredNamespaces,n.optionalNamespaces),n.requiredNamespaces={};const{pairingTopic:i,requiredNamespaces:r,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:l,authentication:h,walletPay:u}=n,d=((N=h==null?void 0:h[0])==null?void 0:N.ttl)||we.wc_sessionPropose.req.ttl||R.FIVE_MINUTES;this.validateRequestExpiry(d);let p=i,f,g=!1;try{if(p){const k=this.client.core.pairing.pairings.get(p);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),g=k.active}}catch(k){throw this.client.logger.error(`connect() -> pairing.get(${p}) failed`),k}if(!p||!g){const{topic:k,uri:M}=await this.client.core.pairing.create({internal:{skipSubscribe:!0}});p=k,f=M}if(!p){const{message:k}=P("NO_MATCHING_KEY",`connect() pairing topic: ${p}`);throw new Error(k)}const _=await this.client.core.crypto.generateKeyPair(),v=ce(d),A={requiredNamespaces:r,optionalNamespaces:o,relays:l??[{protocol:Uu}],proposer:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:v,pairingTopic:p,...a&&{sessionProperties:a},...c&&{scopedProperties:c},id:it(),...(h||u)&&{requests:{authentication:h==null?void 0:h.map(k=>{const{domain:M,chains:H,nonce:B,uri:b,exp:E,nbf:m,type:y,statement:I,requestId:D,resources:w,signatureTypes:x}=k;return{domain:M,chains:H,nonce:B,type:y??"caip122",aud:b,version:"1",iat:new Date().toISOString(),exp:E,nbf:m,statement:I,requestId:D,resources:w,signatureTypes:x}}),walletPay:u}}},S=te("session_connect",A.id),{reject:C,resolve:F,done:$}=Yt(d,Bc),U=({id:k})=>{if(k===A.id){this.client.events.off("proposal_expire",U);const M=this.pendingSessions.get(A.id);if(M){const{sessionTopic:H,publicKey:B}=M;Promise.all([this.client.core.relayer.unsubscribe(H),this.client.core.crypto.keychain.has(H)?this.client.core.crypto.deleteSymKey(H):Promise.resolve(),this.client.core.crypto.keychain.has(B)?this.client.core.crypto.deleteKeyPair(B):Promise.resolve()]).catch(b=>this.client.logger.warn(b))}this.pendingSessions.delete(A.id),this.events.emit(S,{error:{message:Bc,code:0}})}};return this.client.events.on("proposal_expire",U),this.events.once(S,({error:k,session:M})=>{this.client.events.off("proposal_expire",U),k?C(k):M&&F(M)}),await this.setProposal(A.id,A),await this.sendProposeSession({proposal:A,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:A.id}}}).catch(k=>{throw this.deleteProposal(A.id),k}),{uri:f,approval:$}},this.pair=async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(s)}catch(n){throw this.client.logger.error("pair() failed"),n}},this.approve=async s=>{var U,N,k;const n=this.client.core.eventClient.createEvent({properties:{topic:(U=s==null?void 0:s.id)==null?void 0:U.toString(),trace:[Ye.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(M){throw n.setError(Gt.no_internet_connection),M}try{await this.isValidProposalId(s==null?void 0:s.id)}catch(M){throw this.client.logger.error(`approve() -> proposal.get(${s==null?void 0:s.id}) failed`),n.setError(Gt.proposal_not_found),M}try{await this.isValidApprove(s)}catch(M){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError(Gt.session_approve_namespace_validation_failure),M}const{id:i,relayProtocol:r,namespaces:o,sessionProperties:a,scopedProperties:c,sessionConfig:l,proposalRequestsResponses:h}=s,u=this.client.proposal.get(i);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:d,proposer:p,requiredNamespaces:f,optionalNamespaces:g}=u;let _=(N=this.client.core.eventClient)==null?void 0:N.getEvent({topic:d});_||(_=(k=this.client.core.eventClient)==null?void 0:k.createEvent({type:Ye.session_approve_started,properties:{topic:d,trace:[Ye.session_approve_started,Ye.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),A=p.publicKey,S=await this.client.core.crypto.generateSharedKey(v,A),C={relay:{protocol:r??"irn"},namespaces:o,controller:{publicKey:v,metadata:this.client.metadata},expiry:ce(ws),...a&&{sessionProperties:a},...c&&{scopedProperties:c},...l&&{sessionConfig:l},proposalRequestsResponses:h},F=ne.relay;_.addTrace(Ye.subscribing_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:F,internal:{skipSubscribe:!0}})}catch(M){throw _.setError(Gt.subscribe_session_topic_failure),M}_.addTrace(Ye.subscribe_session_topic_success);const $={...C,topic:S,requiredNamespaces:f,optionalNamespaces:g,pairingTopic:d,acknowledged:!1,self:C.controller,peer:{publicKey:p.publicKey,metadata:p.metadata},controller:v,transportType:ne.relay,authentication:h==null?void 0:h.authentication,walletPayResult:h==null?void 0:h.walletPay};await this.client.session.set(S,$),_.addTrace(Ye.store_session);try{await this.sendApproveSession({sessionTopic:S,proposal:u,pairingProposalResponse:{relay:{protocol:r??"irn"},responderPublicKey:v},sessionSettleRequest:C,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:i,...this.getTVFApproveParams($)}}}),_.addTrace(Ye.session_approve_publish_success)}catch(M){throw this.client.logger.error(M),this.client.session.delete(S,ie("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(S),M}return this.client.core.eventClient.deleteEvent({eventId:_.eventId}),await this.client.core.pairing.updateMetadata({topic:d,metadata:p.metadata}),await this.deleteProposal(i),await this.client.core.pairing.activate({topic:d}),await this.setExpiry(S,ce(ws)),{topic:S,acknowledged:()=>Promise.resolve(this.client.session.get(S))}},this.reject=async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(s)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:n,reason:i}=s;let r;try{r=this.client.proposal.get(n).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`),o}r&&await this.sendError({id:n,topic:r,error:i,rpcOpts:we.wc_sessionPropose.reject}),await this.deleteProposal(n)},this.update=async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(s)}catch(u){throw this.client.logger.error("update() -> isValidUpdate() failed"),u}const{topic:n,namespaces:i}=s,{done:r,resolve:o,reject:a}=Yt(R.FIVE_MINUTES,"Session update request expired without receiving any acknowledgement"),c=it(),l=Ut().toString(),h=this.client.session.get(n).namespaces;return this.events.once(te("session_update",c),({error:u})=>{u?a(u):o()}),await this.client.session.update(n,{namespaces:i}),await this.sendRequest({topic:n,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:l}).catch(u=>{this.client.logger.error(u),this.client.session.update(n,{namespaces:h}),a(u)}),{acknowledged:r}},this.extend=async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(s)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:n}=s,i=it(),{done:r,resolve:o,reject:a}=Yt(R.FIVE_MINUTES,"Session extend request expired without receiving any acknowledgement");return this.events.once(te("session_extend",i),({error:c})=>{c?a(c):o()}),await this.setExpiry(n,ce(ws)),this.sendRequest({topic:n,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:r}},this.request=async s=>{this.isInitialized();try{await this.isValidRequest(s)}catch(_){throw this.client.logger.error("request() -> isValidRequest() failed"),_}const{chainId:n,request:i,topic:r,expiry:o=we.wc_sessionRequest.req.ttl}=s,a=this.client.session.get(r);(a==null?void 0:a.transportType)===ne.relay&&await this.confirmOnlineStateOrThrow();const c=it(),l=Ut().toString(),{done:h,resolve:u,reject:d}=Yt(o,"Request expired. Please try again.");this.events.once(te("session_request",c),({error:_,result:v})=>{_?d(_):u(v)});const p="wc_sessionRequest",f=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(f)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:r,method:p,params:{request:{...i,expiryTimestamp:ce(o)},chainId:n},expiry:o,throwOnFailedPublish:!0,appLink:f}).catch(_=>d(_)),this.client.events.emit("session_request_sent",{topic:r,request:i,chainId:n,id:c}),await h();const g={request:{...i,expiryTimestamp:ce(o)},chainId:n};return await Promise.all([new Promise(async _=>{await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:r,method:p,params:g,expiry:o,throwOnFailedPublish:!0,tvf:this.getTVFParams(c,g)}).catch(v=>d(v)),this.client.events.emit("session_request_sent",{topic:r,request:i,chainId:n,id:c}),_()}),new Promise(async _=>{var v;if(!((v=a.sessionConfig)!=null&&v.disableDeepLink)){const A=await Cb(this.client.core.storage,Cc);await Pb({id:c,topic:r,wcDeepLink:A})}_()}),h()]).then(_=>_[2])},this.respond=async s=>{var l,h;this.isInitialized();const n=this.client.core.eventClient.createEvent({properties:{topic:(s==null?void 0:s.topic)||((h=(l=s==null?void 0:s.response)==null?void 0:l.id)==null?void 0:h.toString()),trace:[Ye.session_request_response_started]}});try{await this.isValidRespond(s)}catch(u){throw n.addTrace(u==null?void 0:u.message),n.setError(Gt.session_request_response_validation_failure),u}n.addTrace(Ye.session_request_response_validation_success);const{topic:i,response:r}=s,{id:o}=r,a=this.client.session.get(i);a.transportType===ne.relay&&await this.confirmOnlineStateOrThrow();const c=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);try{n.addTrace(Ye.session_request_response_publish_started),rt(r)?await this.sendResult({id:o,topic:i,result:r.result,throwOnFailedPublish:!0,appLink:c}):He(r)&&await this.sendError({id:o,topic:i,error:r.error,appLink:c}),this.cleanupAfterResponse(s)}catch(u){throw n.addTrace(u==null?void 0:u.message),n.setError(Gt.session_request_response_publish_failure),u}},this.ping=async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(s)}catch(i){throw this.client.logger.error("ping() -> isValidPing() failed"),i}const{topic:n}=s;if(this.client.session.keys.includes(n)){const i=it(),r=Ut().toString(),{done:o,resolve:a,reject:c}=Yt(R.FIVE_MINUTES,"Ping request expired without receiving any acknowledgement");this.events.once(te("session_ping",i),({error:l})=>{l?c(l):a()}),await Promise.all([this.sendRequest({topic:n,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:i,relayRpcId:r}),o()])}else this.client.core.pairing.pairings.keys.includes(n)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:n}))},this.emit=async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(s);const{topic:n,event:i,chainId:r}=s,o=Ut().toString(),a=it();await this.sendRequest({topic:n,method:"wc_sessionEvent",params:{event:i,chainId:r},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})},this.disconnect=async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(s);const{topic:n}=s;if(this.client.session.keys.includes(n))await this.sendRequest({topic:n,method:"wc_sessionDelete",params:ie("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:n,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(n))await this.client.core.pairing.disconnect({topic:n});else{const{message:i}=P("MISMATCHED_TOPIC",`Session or pairing topic not found: ${n}`);throw new Error(i)}},this.find=s=>(this.isInitialized(),this.client.session.getAll().filter(n=>T1(n,s))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(s,n)=>{var D;this.isInitialized(),this.isValidAuthenticate(s);const i=n&&this.client.core.linkModeSupportedApps.includes(n)&&((D=this.client.metadata.redirect)==null?void 0:D.linkMode),r=i?ne.link_mode:ne.relay;r===ne.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:a="",uri:c,domain:l,nonce:h,type:u,exp:d,nbf:p,methods:f=[],expiry:g}=s,_=[...s.resources||[]],{topic:v,uri:A}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:r});if(this.client.logger.info({message:"Generated new pairing",pairing:{topic:v,uri:A}}),this.client.auth.authKeys.keys.includes(Pt)){const{responseTopic:w,publicKey:x}=this.client.auth.authKeys.get(Pt);w&&(await this.client.core.relayer.unsubscribe(w).catch(O=>this.client.logger.warn(O)),await this.client.auth.pairingTopics.delete(w,{message:"replaced",code:0}).catch(O=>this.client.logger.warn(O))),x&&this.client.core.crypto.keychain.has(x)&&await this.client.core.crypto.deleteKeyPair(x)}const S=await this.client.core.crypto.generateKeyPair(),C=qn(S);if(await Promise.all([this.client.auth.authKeys.set(Pt,{responseTopic:C,publicKey:S}),this.client.auth.pairingTopics.set(C,{topic:C,pairingTopic:v})]),await this.client.core.relayer.subscribe(C,{transportType:r}),this.client.logger.info(`sending request to new pairing topic: ${v}`),f.length>0){const{namespace:w}=It(o[0]);let x=r1(w,"request",f);Fn(_)&&(x=a1(x,_.pop())),_.push(x)}const F=g&&g>we.wc_sessionAuthenticate.req.ttl?g:we.wc_sessionAuthenticate.req.ttl,$={authPayload:{type:u??"caip122",chains:o,statement:a,aud:c,domain:l,version:"1",nonce:h,iat:new Date().toISOString(),exp:d,nbf:p,resources:_},requester:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:ce(F)},U={eip155:{chains:o,methods:[...new Set(["personal_sign",...f])],events:["chainChanged","accountsChanged"]}},N={requiredNamespaces:{},optionalNamespaces:U,relays:[{protocol:"irn"}],pairingTopic:v,proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:ce(we.wc_sessionPropose.req.ttl),id:it()},{done:k,resolve:M,reject:H}=Yt(F,"Request expired"),B=it(),b=te("session_connect",N.id),E=te("session_request",B),m=async({error:w,session:x})=>{this.events.off(E,y),w?H(w):x&&M({session:x})},y=async w=>{var K,W,Z;if(await this.deletePendingAuthRequest(B,{message:"fulfilled",code:0}),w.error){const V=ie("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return w.error.code===V.code?void 0:(this.events.off(b,m),H(w.error.message))}await this.deleteProposal(N.id),this.events.off(b,m);const{cacaos:x,responder:O}=w.result,T=[],j=[];for(const V of x){await ic({cacao:V,projectId:this.client.core.projectId})||(this.client.logger.error(V,"Signature verification failed"),H(ie("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:ee}=V,pe=Fn(ee.resources),Ce=[Cr(ee.iss)],et=ni(ee.iss);if(pe){const ut=rc(pe),ps=oc(pe);T.push(...ut),Ce.push(...ps)}for(const ut of Ce)j.push(`${ut}:${et}`)}const z=await this.client.core.crypto.generateSharedKey(S,O.publicKey);let q;T.length>0&&(q={topic:z,acknowledged:!0,self:{publicKey:S,metadata:this.client.metadata},peer:O,controller:O.publicKey,expiry:ce(ws),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:v,namespaces:pc([...new Set(T)],[...new Set(j)]),transportType:r},await this.client.core.relayer.subscribe(z,{transportType:r}),await this.client.session.set(z,q),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:O.metadata}),q=this.client.session.get(z)),(K=this.client.metadata.redirect)!=null&&K.linkMode&&((W=O.metadata.redirect)!=null&&W.linkMode)&&((Z=O.metadata.redirect)!=null&&Z.universal)&&n&&(this.client.core.addLinkModeSupportedApp(O.metadata.redirect.universal),this.client.session.update(z,{transportType:ne.link_mode})),M({auths:x,session:q})};this.events.once(b,m),this.events.once(E,y);let I;try{if(i){const w=Je("wc_sessionAuthenticate",$,B);this.client.core.history.set(v,w);const x=await this.client.core.crypto.encode("",w,{type:mn,encoding:Ct});I=Pn(n,v,x)}else await Promise.all([this.sendRequest({topic:v,method:"wc_sessionAuthenticate",params:$,expiry:s.expiry,throwOnFailedPublish:!0,clientRpcId:B}),this.sendRequest({topic:v,method:"wc_sessionPropose",params:N,expiry:we.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:N.id})])}catch(w){throw this.events.off(b,m),this.events.off(E,y),w}return await this.setProposal(N.id,N),await this.setAuthRequest(B,{request:{...$,verifyContext:{}},pairingTopic:v,transportType:r}),{uri:I??A,response:k}},this.approveSessionAuthenticate=async s=>{const{id:n,auths:i}=s,r=this.client.core.eventClient.createEvent({properties:{topic:n.toString(),trace:[Wt.authenticated_session_approve_started]}});try{this.isInitialized()}catch(_){throw r.setError(Gs.no_internet_connection),_}const o=this.getPendingAuthRequest(n);if(!o)throw r.setError(Gs.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${n}`);const a=o.transportType||ne.relay;a===ne.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),h=qn(c),u={type:St,receiverPublicKey:c,senderPublicKey:l},d=[],p=[];for(const _ of i){if(!await ic({cacao:_,projectId:this.client.core.projectId})){r.setError(Gs.invalid_cacao);const F=ie("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:n,topic:h,error:F,encodeOpts:u}),new Error(F.message)}r.addTrace(Wt.cacaos_verified);const{p:v}=_,A=Fn(v.resources),S=[Cr(v.iss)],C=ni(v.iss);if(A){const F=rc(A),$=oc(A);d.push(...F),S.push(...$)}for(const F of S)p.push(`${F}:${C}`)}const f=await this.client.core.crypto.generateSharedKey(l,c);r.addTrace(Wt.create_authenticated_session_topic);let g;if((d==null?void 0:d.length)>0){g={topic:f,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:ce(ws),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:pc([...new Set(d)],[...new Set(p)]),transportType:a},r.addTrace(Wt.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(f,{transportType:a})}catch(_){throw r.setError(Gs.subscribe_authenticated_session_topic_failure),_}r.addTrace(Wt.subscribe_authenticated_session_topic_success),await this.client.session.set(f,g),r.addTrace(Wt.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}r.addTrace(Wt.publishing_authenticated_session_approve);try{await this.sendResult({topic:h,id:n,result:{cacaos:i,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:u,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(_){throw r.setError(Gs.authenticated_session_approve_publish_failure),_}return await this.client.auth.requests.delete(n,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:g}},this.rejectSessionAuthenticate=async s=>{this.isInitialized();const{id:n,reason:i}=s,r=this.getPendingAuthRequest(n);if(!r)throw new Error(`Could not find pending auth request with id ${n}`);r.transportType===ne.relay&&await this.confirmOnlineStateOrThrow();const o=r.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=qn(o),l={type:St,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:n,topic:c,error:i,encodeOpts:l,rpcOpts:we.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(r.requester.metadata,r.transportType)}),await this.client.auth.requests.delete(n,{message:"rejected",code:0}),await this.deleteProposal(n)},this.formatAuthMessage=s=>{this.isInitialized();const{request:n,iss:i}=s;return Qh(n,i)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const s=this.relayMessageCache.shift();s&&await this.onRelayMessage(s)}catch(s){this.client.logger.error(s)}},50)},this.cleanupDuplicatePairings=async s=>{if(s.pairingTopic)try{const n=this.client.core.pairing.pairings.get(s.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(r=>{var o,a;return((o=r.peerMetadata)==null?void 0:o.url)&&((a=r.peerMetadata)==null?void 0:a.url)===s.peer.metadata.url&&r.topic&&r.topic!==n.topic});if(i.length===0)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(r=>this.client.core.pairing.disconnect({topic:r.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}},this.deleteSession=async s=>{var c;const{topic:n,expirerHasDeleted:i=!1,emitEvent:r=!0,id:o=0}=s,{self:a}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ie("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(a.publicKey)&&await this.client.core.crypto.deleteKeyPair(a.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),i||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Cc).catch(l=>this.client.logger.warn(l)),n===((c=this.sessionRequestQueue.queue[0])==null?void 0:c.topic)&&(this.sessionRequestQueue.state=st.idle),await Promise.all(this.getPendingSessionRequests().filter(l=>l.topic===n).map(l=>this.deletePendingSessionRequest(l.id,ie("USER_DISCONNECTED")))),r&&this.client.events.emit("session_delete",{id:o,topic:n})},this.deleteProposal=async(s,n)=>{var i;if(n)try{const r=this.client.proposal.get(s);(i=this.client.core.eventClient.getEvent({topic:r.pairingTopic}))==null||i.setError(Gt.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(s,ie("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"proposal")},this.deletePendingSessionRequest=async(s,n,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(s,n),i?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(r=>r.id!==s),i&&(this.sessionRequestQueue.state=st.idle,this.client.events.emit("session_request_expire",{id:s}))},this.deletePendingAuthRequest=async(s,n,i=!1)=>{await Promise.all([this.client.auth.requests.delete(s,n),i?Promise.resolve():this.client.core.expirer.del(s)])},this.setExpiry=async(s,n)=>{this.client.session.keys.includes(s)&&(this.client.core.expirer.set(s,n),await this.client.session.update(s,{expiry:n}))},this.setProposal=async(s,n)=>{this.client.core.expirer.set(s,ce(we.wc_sessionPropose.req.ttl)),await this.client.proposal.set(s,n)},this.setAuthRequest=async(s,n)=>{const{request:i,pairingTopic:r,transportType:o=ne.relay}=n;this.client.core.expirer.set(s,i.expiryTimestamp),await this.client.auth.requests.set(s,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:s,pairingTopic:r,verifyContext:i.verifyContext,transportType:o})},this.setPendingSessionRequest=async s=>{const{id:n,topic:i,params:r,verifyContext:o}=s,a=r.request.expiryTimestamp||ce(we.wc_sessionRequest.req.ttl);this.client.core.expirer.set(n,a),await this.client.pendingRequest.set(n,{id:n,topic:i,params:r,verifyContext:o})},this.sendRequest=async s=>{const{topic:n,method:i,params:r,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:h,tvf:u,publishOpts:d={}}=s,p=Je(i,r,c);let f;const g=!!h;try{const A=g?Ct:be;f=await this.client.core.crypto.encode(n,p,{encoding:A})}catch(A){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${n} failed`),A}let _;if(U2.includes(i)){const A=je(JSON.stringify(p)),S=je(f);_=await this.client.core.verify.register({id:S,decryptedId:A})}const v={...we[i].req,...d};if(v.attestation=_,o&&(v.ttl=o),a&&(v.id=a),this.client.core.history.set(n,p),g){const A=Pn(h,n,f);await global.Linking.openURL(A,this.client.name)}else v.tvf={...u,correlationId:p.id},l?(v.internal={...v.internal,throwOnFailedPublish:!0},await this.client.core.relayer.publish(n,f,v)):this.client.core.relayer.publish(n,f,v).catch(A=>this.client.logger.error(A));return p.id},this.sendProposeSession=async s=>{const{proposal:n,publishOpts:i}=s,r=Je("wc_sessionPropose",n,n.id);this.client.core.history.set(n.pairingTopic,r);const o=await this.client.core.crypto.encode(n.pairingTopic,r,{encoding:be}),a=je(JSON.stringify(r)),c=je(o),l=await this.client.core.verify.register({id:c,decryptedId:a});await this.client.core.relayer.publishCustom({payload:{pairingTopic:n.pairingTopic,sessionProposal:o},opts:{...i,publishMethod:"wc_proposeSession",attestation:l}})},this.sendApproveSession=async s=>{const{sessionTopic:n,pairingProposalResponse:i,proposal:r,sessionSettleRequest:o,publishOpts:a}=s,c=cn(r.id,i),l=await this.client.core.crypto.encode(r.pairingTopic,c,{encoding:be}),h=Je("wc_sessionSettle",o,a==null?void 0:a.id),u=await this.client.core.crypto.encode(n,h,{encoding:be});this.client.core.history.set(n,h),await this.client.core.relayer.publishCustom({payload:{sessionTopic:n,pairingTopic:r.pairingTopic,sessionProposalResponse:l,sessionSettlementRequest:u},opts:{...a,publishMethod:"wc_approveSession"}})},this.sendResult=async s=>{const{id:n,topic:i,result:r,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=s,l=cn(n,r);let h;const u=c&&typeof(global==null?void 0:global.Linking)<"u";try{const f=u?Ct:be;h=await this.client.core.crypto.encode(i,l,{...a||{},encoding:f})}catch(f){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),f}let d,p;try{d=await this.client.core.history.get(i,n);const f=d.request;try{p=this.getTVFParams(n,f.params,r)}catch(g){this.client.logger.warn(`sendResult() -> getTVFParams() failed: ${g==null?void 0:g.message}`)}}catch(f){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${n}) failed`),f}if(u){const f=Pn(c,i,h);await global.Linking.openURL(f,this.client.name)}else{const f=d.request.method,g=we[f].res;g.tvf={...p,correlationId:n},o?(g.internal={...g.internal,throwOnFailedPublish:!0},await this.client.core.relayer.publish(i,h,g)):this.client.core.relayer.publish(i,h,g).catch(_=>this.client.logger.error(_))}await this.client.core.history.resolve(l)},this.sendError=async s=>{const{id:n,topic:i,error:r,encodeOpts:o,rpcOpts:a,appLink:c}=s,l=xi(n,r);let h;const u=c&&typeof(global==null?void 0:global.Linking)<"u";try{const p=u?Ct:be;h=await this.client.core.crypto.encode(i,l,{...o||{},encoding:p})}catch(p){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),p}let d;try{d=await this.client.core.history.get(i,n)}catch(p){throw this.client.logger.error(`sendError() -> history.get(${i}, ${n}) failed`),p}if(u){const p=Pn(c,i,h);await global.Linking.openURL(p,this.client.name)}else{const p=d.request.method,f=a||we[p].res;this.client.core.relayer.publish(i,h,f)}await this.client.core.history.resolve(l)},this.cleanup=async()=>{const s=[],n=[];this.client.session.getAll().forEach(i=>{let r=!1;ot(i.expiry)&&(r=!0),this.client.core.crypto.keychain.has(i.topic)||(r=!0),r&&s.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{ot(i.expiryTimestamp)&&n.push(i.id)}),await Promise.all([...s.map(i=>this.deleteSession({topic:i})),...n.map(i=>this.deleteProposal(i))])},this.onProviderMessageEvent=async s=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(s):await this.onRelayMessage(s)},this.onRelayEventRequest=async s=>{this.requestQueue.queue.push(s),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===st.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=st.active;const s=this.requestQueue.queue.shift();if(s)try{await this.processRequest(s)}catch(n){this.client.logger.warn(n)}}this.requestQueue.state=st.idle},this.processRequest=async s=>{const{topic:n,payload:i,attestation:r,transportType:o,encryptedId:a}=s,c=i.method;if(!this.shouldIgnorePairingRequest({topic:n,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:n,payload:i,attestation:r,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(n,i);case"wc_sessionPing":return await this.onSessionPingRequest(n,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:n,payload:i,attestation:r,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(n,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:n,payload:i,attestation:r,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}},this.onRelayEventResponse=async s=>{const{topic:n,payload:i,transportType:r}=s,o=(await this.client.core.history.get(n,i.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i,r);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=s=>{const{topic:n}=s,{message:i}=P("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)},this.shouldIgnorePairingRequest=s=>{const{topic:n,requestMethod:i}=s,r=this.expectedPairingMethodMap.get(n);return!r||r.includes(i)?!1:!!(r.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async s=>{const{topic:n,payload:i,attestation:r,encryptedId:o}=s,{params:a,id:c}=i;try{const l=this.client.core.eventClient.getEvent({topic:n});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l==null||l.setError(yt.proposal_listener_not_found)),this.isValidConnect({...i.params});const h=a.expiryTimestamp||ce(we.wc_sessionPropose.req.ttl),u={id:c,pairingTopic:n,expiryTimestamp:h,attestation:r,encryptedId:o,...a};await this.setProposal(c,u);const d=await this.getVerifyContext({attestationId:r,hash:je(JSON.stringify(i)),encryptedId:o,metadata:u.proposer.metadata});l==null||l.addTrace(nt.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:u,verifyContext:d})}catch(l){await this.sendError({id:c,topic:n,error:l,rpcOpts:we.wc_sessionPropose.autoReject}),this.client.logger.error(l)}},this.onSessionProposeResponse=async(s,n,i)=>{const{id:r}=n;if(rt(n)){const{result:o}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(r);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const h=await this.client.core.crypto.generateSharedKey(c,l);this.pendingSessions.set(r,{sessionTopic:h,pairingTopic:s,proposalId:r,publicKey:c});const u=await this.client.core.relayer.subscribe(h,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:u}),await this.client.core.pairing.activate({topic:s})}else if(He(n)){await this.deleteProposal(r);const o=te("session_connect",r);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:n.error})}},this.onSessionSettleRequest=async(s,n)=>{const{id:i,params:r}=n;try{this.isValidSessionSettleRequest(r);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:h,scopedProperties:u,sessionConfig:d,proposalRequestsResponses:p}=n.params,f=[...this.pendingSessions.values()].find(v=>v.sessionTopic===s);if(!f)return this.client.logger.error(`Pending session not found for topic ${s}`);const g=this.client.proposal.get(f.proposalId),_={topic:s,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:f.pairingTopic,requiredNamespaces:g.requiredNamespaces,optionalNamespaces:g.optionalNamespaces,controller:a.publicKey,self:{publicKey:f.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata},...h&&{sessionProperties:h},...u&&{scopedProperties:u},...d&&{sessionConfig:d},transportType:ne.relay,authentication:p==null?void 0:p.authentication,walletPayResult:p==null?void 0:p.walletPay};await this.client.session.set(_.topic,_),await this.setExpiry(_.topic,_.expiry),await this.client.core.pairing.updateMetadata({topic:f.pairingTopic,metadata:_.peer.metadata}),this.pendingSessions.delete(f.proposalId),this.deleteProposal(f.proposalId,!1),this.cleanupDuplicatePairings(_),await this.sendResult({id:n.id,topic:s,throwOnFailedPublish:!0,result:!0}),this.client.events.emit("session_connect",{session:_}),this.events.emit(te("session_connect",f.proposalId),{session:_})}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(s,n)=>{const{id:i}=n;rt(n)?(await this.client.session.update(s,{acknowledged:!0}),this.events.emit(te("session_approve",i),{})):He(n)&&(await this.deleteSession({topic:s,emitEvent:!1}),this.events.emit(te("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(s,n)=>{const{params:i,id:r}=n;try{const o=`${s}_session_update`,a=Ks.get(o);if(a&&this.isRequestOutOfSync(a,r)){this.client.logger.warn(`Discarding out of sync request - ${r}`),this.sendError({id:r,topic:s,error:ie("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate({topic:s,...i});try{Ks.set(o,r),await this.client.session.update(s,{namespaces:i.namespaces}),await this.sendResult({id:r,topic:s,result:!0})}catch(c){throw Ks.delete(o),c}this.client.events.emit("session_update",{id:r,topic:s,params:i})}catch(o){await this.sendError({id:r,topic:s,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(s,n)=>n.toString().slice(0,-3)<s.toString().slice(0,-3),this.onSessionUpdateResponse=(s,n)=>{const{id:i}=n,r=te("session_update",i);if(this.events.listenerCount(r)===0)throw new Error(`emitting ${r} without any listeners`);rt(n)?this.events.emit(te("session_update",i),{}):He(n)&&this.events.emit(te("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(s,n)=>{const{id:i}=n;try{this.isValidExtend({topic:s}),await this.setExpiry(s,ce(ws)),await this.sendResult({id:i,topic:s,result:!0}),this.client.events.emit("session_extend",{id:i,topic:s})}catch(r){await this.sendError({id:i,topic:s,error:r}),this.client.logger.error(r)}},this.onSessionExtendResponse=(s,n)=>{const{id:i}=n,r=te("session_extend",i);if(this.events.listenerCount(r)===0)throw new Error(`emitting ${r} without any listeners`);rt(n)?this.events.emit(te("session_extend",i),{}):He(n)&&this.events.emit(te("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(s,n)=>{const{id:i}=n;try{this.isValidPing({topic:s}),await this.sendResult({id:i,topic:s,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:s})}catch(r){await this.sendError({id:i,topic:s,error:r}),this.client.logger.error(r)}},this.onSessionPingResponse=(s,n)=>{const{id:i}=n,r=te("session_ping",i);setTimeout(()=>{if(this.events.listenerCount(r)===0)throw new Error(`emitting ${r} without any listeners 2176`);rt(n)?this.events.emit(te("session_ping",i),{}):He(n)&&this.events.emit(te("session_ping",i),{error:n.error})},500)},this.onSessionDeleteRequest=async(s,n)=>{const{id:i}=n;try{await this.isValidDisconnect({topic:s,reason:n.params}),this.cleanupPendingSentRequestsForTopic({topic:s,error:ie("USER_DISCONNECTED")}),await this.deleteSession({topic:s,id:i})}catch(r){this.client.logger.error(r)}},this.onSessionRequest=async s=>{var h,u,d;const{topic:n,payload:i,attestation:r,encryptedId:o,transportType:a}=s,{id:c,params:l}=i;try{await this.isValidRequest({topic:n,...l});const p=this.client.session.get(n),f=await this.getVerifyContext({attestationId:r,hash:je(JSON.stringify(Je("wc_sessionRequest",l,c))),encryptedId:o,metadata:p.peer.metadata,transportType:a}),g={id:c,topic:n,params:l,verifyContext:f};await this.setPendingSessionRequest(g),a===ne.link_mode&&((h=p.peer.metadata.redirect)!=null&&h.universal)&&this.client.core.addLinkModeSupportedApp((u=p.peer.metadata.redirect)==null?void 0:u.universal),(d=this.client.signConfig)!=null&&d.disableRequestQueue?this.emitSessionRequest(g):(this.addSessionRequestToSessionRequestQueue(g),this.processSessionRequestQueue())}catch(p){await this.sendError({id:c,topic:n,error:p}),this.client.logger.error(p)}},this.onSessionRequestResponse=(s,n)=>{const{id:i}=n,r=te("session_request",i);if(this.events.listenerCount(r)===0)throw new Error(`emitting ${r} without any listeners`);rt(n)?this.events.emit(te("session_request",i),{result:n.result}):He(n)&&this.events.emit(te("session_request",i),{error:n.error})},this.onSessionEventRequest=async(s,n)=>{const{id:i,params:r}=n;try{const o=`${s}_session_event_${r.event.name}`,a=Ks.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit({topic:s,...r}),this.client.events.emit("session_event",{id:i,topic:s,params:r}),Ks.set(o,i)}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(s,n)=>{const{id:i}=n;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:s,payload:n}),rt(n)?this.events.emit(te("session_request",i),{result:n.result}):He(n)&&this.events.emit(te("session_request",i),{error:n.error})},this.onSessionAuthenticateRequest=async s=>{var c;const{topic:n,payload:i,attestation:r,encryptedId:o,transportType:a}=s;try{const{requester:l,authPayload:h,expiryTimestamp:u}=i.params,d=await this.getVerifyContext({attestationId:r,hash:je(JSON.stringify(i)),encryptedId:o,metadata:l.metadata,transportType:a}),p={requester:l,pairingTopic:n,id:i.id,authPayload:h,verifyContext:d,expiryTimestamp:u};await this.setAuthRequest(i.id,{request:p,pairingTopic:n,transportType:a}),a===ne.link_mode&&((c=l.metadata.redirect)!=null&&c.universal)&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:i.params,id:i.id,verifyContext:d})}catch(l){this.client.logger.error(l);const h=i.params.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(i.params.requester.metadata,a),p={type:St,receiverPublicKey:h,senderPublicKey:u};await this.sendError({id:i.id,topic:n,error:l,encodeOpts:p,rpcOpts:we.wc_sessionAuthenticate.autoReject,appLink:d})}},this.addSessionRequestToSessionRequestQueue=s=>{this.sessionRequestQueue.queue.push(s)},this.cleanupAfterResponse=s=>{this.deletePendingSessionRequest(s.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=st.idle,this.processSessionRequestQueue()},R.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:s,error:n})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(r=>r.topic===s&&r.request.method==="wc_sessionRequest").forEach(r=>{this.events.emit(te("session_request",r.request.id),{error:n})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===st.active){this.client.logger.info("session request queue is already active.");return}const s=this.sessionRequestQueue.queue[0];if(!s){this.client.logger.info("session request queue is empty.");return}try{this.emitSessionRequest(s)}catch(n){this.client.logger.error(n)}},this.emitSessionRequest=s=>{if(this.emittedSessionRequests.has(s.id)){this.client.logger.warn({id:s.id},`Skipping emitting \`session_request\` event for duplicate request. id: ${s.id}`);return}this.sessionRequestQueue.state=st.active,this.emittedSessionRequests.add(s.id),this.client.events.emit("session_request",s)},this.cleanupInProgress=!1,this.cleanupOrphanedSubscriptions=async()=>{const s=this.client.core.relayer.subscriber.topics;if(s.length===0)return;const n=new Set(this.client.session.keys),i=new Set(this.client.core.pairing.pairings.keys),r=new Set([...this.pendingSessions.values()].map(a=>a.sessionTopic));let o;if(this.client.auth.authKeys.keys.includes(Pt)){const{responseTopic:a}=this.client.auth.authKeys.get(Pt);o=a}for(const a of s)if(!n.has(a)&&!i.has(a)&&!r.has(a)&&a!==o){this.client.logger.info(`Cleaning up orphaned subscriber topic: ${a}`);try{await this.client.core.relayer.subscriber.unsubscribe(a)}catch(c){this.client.logger.warn(c,`Failed to clean up orphaned subscription: ${a}`)}}},this.onPairingCreated=s=>{if(s.methods&&this.expectedPairingMethodMap.set(s.topic,s.methods),s.active)return;const n=this.client.proposal.getAll().find(i=>i.pairingTopic===s.topic);
vendor: 4,072 bytes, line 13
13n&&this.onSessionProposeRequest({topic:s.topic,payload:Je("wc_sessionPropose",{...n,requiredNamespaces:n.requiredNamespaces,optionalNamespaces:n.optionalNamespaces,relays:n.relays,proposer:n.proposer,sessionProperties:n.sessionProperties,scopedProperties:n.scopedProperties},n.id),attestation:n.attestation,encryptedId:n.encryptedId})},this.isValidConnect=async s=>{if(!Re(s)){const{message:l}=P("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(s)}`);throw new Error(l)}const{pairingTopic:n,requiredNamespaces:i,optionalNamespaces:r,sessionProperties:o,scopedProperties:a,relays:c}=s;if(de(n)||await this.isValidPairingTopic(n),!z1(c,!0)){const{message:l}=P("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}if(i&&!de(i)&<(i)!==0){const l="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(l):this.client.logger.warn(l),this.validateNamespaces(i,"requiredNamespaces")}if(r&&!de(r)&<(r)!==0&&this.validateNamespaces(r,"optionalNamespaces"),o&&!de(o)&&this.validateSessionProps(o,"sessionProperties"),a&&!de(a)){this.validateSessionProps(a,"scopedProperties");const l=Object.keys(i||{}).concat(Object.keys(r||{}));if(!Object.keys(a).every(h=>l.includes(h.split(":")[0])))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(l)}`)}},this.validateNamespaces=(s,n)=>{const i=q1(s,"connect()",n);if(i)throw new Error(i.message)},this.isValidApprove=async s=>{if(!Re(s))throw new Error(P("MISSING_OR_INVALID",`approve() params: ${s}`).message);const{id:n,namespaces:i,relayProtocol:r,sessionProperties:o,scopedProperties:a}=s;this.checkRecentlyDeleted(n),await this.isValidProposalId(n);const c=this.client.proposal.get(n),l=tr(i,"approve()");if(l)throw new Error(l.message);const h=_c(c.requiredNamespaces,i,"approve()");if(h)throw new Error(h.message);if(!le(r,!0)){const{message:u}=P("MISSING_OR_INVALID",`approve() relayProtocol: ${r}`);throw new Error(u)}if(o&&!de(o)&&this.validateSessionProps(o,"sessionProperties"),a&&!de(a)){this.validateSessionProps(a,"scopedProperties");const u=new Set(Object.keys(i));if(!Object.keys(a).every(d=>u.has(d.split(":")[0])))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(u).join(", ")}`)}},this.isValidReject=async s=>{if(!Re(s)){const{message:r}=P("MISSING_OR_INVALID",`reject() params: ${s}`);throw new Error(r)}const{id:n,reason:i}=s;if(this.checkRecentlyDeleted(n),await this.isValidProposalId(n),!H1(i)){const{message:r}=P("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(r)}},this.isValidSessionSettleRequest=s=>{if(!Re(s)){const{message:l}=P("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${s}`);throw new Error(l)}const{relay:n,controller:i,namespaces:r,expiry:o}=s;if(!lu(n)){const{message:l}=P("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=C1(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=tr(r,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(ot(o)){const{message:l}=P("EXPIRED","onSessionSettleRequest()");throw new Error(l)}},this.isValidUpdate=async s=>{if(!Re(s)){const{message:c}=P("MISSING_OR_INVALID",`update() params: ${s}`);throw new Error(c)}const{topic:n,namespaces:i}=s;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const r=this.client.session.get(n),o=tr(i,"update()");if(o)throw new Error(o.message);const a=_c(r.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async s=>{if(!Re(s)){const{message:i}=P("MISSING_OR_INVALID",`extend() params: ${s}`);throw new Error(i)}const{topic:n}=s;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n)},this.isValidRequest=async s=>{if(!Re(s)){const{message:c}=P("MISSING_OR_INVALID",`request() params: ${s}`);throw new Error(c)}
vendor: 38,087 bytes, line 13
13const{topic:n,request:i,chainId:r,expiry:o}=s;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!gc(a,r)){const{message:c}=P("MISSING_OR_INVALID",`request() chainId: ${r}`);throw new Error(c)}if(!K1(i)){const{message:c}=P("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(c)}if(!W1(a,r,i.method)){const{message:c}=P("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(c)}this.validateRequestExpiry(o)},this.isValidRespond=async s=>{var o;if(!Re(s)){const{message:a}=P("MISSING_OR_INVALID",`respond() params: ${s}`);throw new Error(a)}const{topic:n,response:i}=s;try{await this.isValidSessionTopic(n)}catch(a){throw(o=s==null?void 0:s.response)!=null&&o.id&&this.cleanupAfterResponse(s),a}if(!V1(i)){const{message:a}=P("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(a)}const r=this.client.pendingRequest.get(i.id);if(r.topic!==n){const{message:a}=P("MISMATCHED_TOPIC",`Request response topic mismatch. reqId: ${i.id}, expected topic: ${r.topic}, received topic: ${n}`);throw new Error(a)}},this.isValidPing=async s=>{if(!Re(s)){const{message:i}=P("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(i)}const{topic:n}=s;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async s=>{if(!Re(s)){const{message:a}=P("MISSING_OR_INVALID",`emit() params: ${s}`);throw new Error(a)}const{topic:n,event:i,chainId:r}=s;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!gc(o,r)){const{message:a}=P("MISSING_OR_INVALID",`emit() chainId: ${r}`);throw new Error(a)}if(!G1(i)){const{message:a}=P("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!Y1(o,r,i.name)){const{message:a}=P("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}},this.isValidDisconnect=async s=>{if(!Re(s)){const{message:i}=P("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(i)}const{topic:n}=s;await this.isValidSessionOrPairingTopic(n)},this.isValidAuthenticate=s=>{const{chains:n,uri:i,domain:r,nonce:o}=s;if(!Array.isArray(n)||n.length===0)throw new Error("chains is required and must be a non-empty array");if(!le(i,!1))throw new Error("uri is required parameter");if(!le(r,!1))throw new Error("domain is required parameter");if(!le(o,!1))throw new Error("nonce is required parameter");if([...new Set(n.map(c=>It(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=It(n[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async s=>{const{attestationId:n,hash:i,encryptedId:r,metadata:o,transportType:a}=s,c={verified:{verifyUrl:o.verifyUrl||tn,validation:"UNKNOWN",origin:o.url||""}};try{if(a===ne.link_mode){const h=this.getAppLinkIfEnabled(o,a);return c.verified.validation=h&&new URL(h).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:n,hash:i,encryptedId:r,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c},this.validateSessionProps=(s,n)=>{Object.values(s).forEach((i,r)=>{if(i==null){const{message:o}=P("MISSING_OR_INVALID",`${n} must contain an existing value for each key. Received: ${i} for key ${Object.keys(s)[r]}`);throw new Error(o)}})},this.getPendingAuthRequest=s=>{const n=this.client.auth.requests.get(s);return typeof n=="object"?n:void 0},this.addToRecentlyDeleted=(s,n)=>{if(this.recentlyDeletedMap.set(s,n),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let i=0;const r=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(i++>=r)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=s=>{const n=this.recentlyDeletedMap.get(s);if(n){const{message:i}=P("MISSING_OR_INVALID",`Record was recently deleted - ${n}: ${s}`);throw new Error(i)}},this.isLinkModeEnabled=(s,n)=>{var i,r,o,a,c,l,h,u,d;return!s||n!==ne.link_mode?!1:((r=(i=this.client.metadata)==null?void 0:i.redirect)==null?void 0:r.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((h=s==null?void 0:s.redirect)==null?void 0:h.universal)!==void 0&&((u=s==null?void 0:s.redirect)==null?void 0:u.universal)!==""&&((d=s==null?void 0:s.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(s.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(s,n)=>{var i;return this.isLinkModeEnabled(s,n)?(i=s==null?void 0:s.redirect)==null?void 0:i.universal:void 0},this.handleLinkModeMessage=({url:s})=>{if(!s||!s.includes("wc_ev")||!s.includes("topic"))return;const n=ec(s,"topic")||"",i=decodeURIComponent(ec(s,"wc_ev")||""),r=this.client.session.keys.includes(n);r&&this.client.session.update(n,{transportType:ne.link_mode}),this.client.core.dispatchEnvelope({topic:n,message:i,sessionExists:r})},this.registerLinkModeListeners=async()=>{var s;if(_o()||jt()&&((s=this.client.metadata.redirect)!=null&&s.linkMode)){const n=global==null?void 0:global.Linking;if(typeof n<"u"){n.addEventListener("url",this.handleLinkModeMessage,this.client.name);const i=await n.getInitialURL();i&&setTimeout(()=>{this.handleLinkModeMessage({url:i})},50)}}},this.getTVFApproveParams=s=>{try{const n=au(s.namespaces),i=S1(s.namespaces),r=x1(s.namespaces),o=s.sessionProperties,a=s.scopedProperties;return{approvedChains:n,approvedMethods:i,approvedEvents:r,sessionProperties:o,scopedProperties:a}}catch(n){return this.client.logger.warn(n,"Error getting TVF approve params"),{}}},this.getTVFParams=(s,n,i)=>{var o,a,c;if(!((o=n.request)!=null&&o.method))return{};const r={correlationId:s,rpcMethods:[n.request.method],chainId:n.chainId};try{const l=this.extractTxHashesFromResult(n.request,i);r.txHashes=l,r.contractAddresses=this.isValidContractData(n.request.params)?[(c=(a=n.request.params)==null?void 0:a[0])==null?void 0:c.to]:[]}catch(l){this.client.logger.warn(l,"Error getting TVF params")}return r},this.isValidContractData=s=>{var n;if(!s)return!1;try{const i=(s==null?void 0:s.data)||((n=s==null?void 0:s[0])==null?void 0:n.data);if(!i.startsWith("0x"))return!1;const r=i.slice(2);return/^[0-9a-fA-F]*$/.test(r)?r.length%2===0:!1}catch{}return!1},this.extractTxHashesFromResult=(s,n)=>{var i;try{if(!n)return[];const r=s.method,o=C2[r];if(r==="sui_signTransaction")return[Gb(n.transactionBytes)];if(r==="near_signTransaction")return[sc(n)];if(r==="near_signTransactions")return n.map(c=>sc(c));if(r==="xrpl_signTransactionFor"||r==="xrpl_signTransaction")return[(i=n.tx_json)==null?void 0:i.hash];if(r==="polkadot_signTransaction")return[pE({transaction:s.params.transactionPayload,signature:n.signature})];if(r==="algo_signTxn")return Ke(n)?n.map(c=>nc(c)):[nc(n)];if(r==="cosmos_signDirect")return[Yb(n)];if(r==="wallet_sendCalls")return Xb(n);if(typeof n=="string")return[n];const a=n[o.key];if(Ke(a))return r==="solana_signAllTransactions"?a.map(c=>Vb(c)):a;if(typeof a=="string")return[a]}catch(r){this.client.logger.warn(r,"Error extracting tx hashes from result")}return[]}}async processPendingMessageEvents(){try{const e=this.client.session.keys,s=this.client.core.relayer.messages.getWithoutAck(e);for(const[n,i]of Object.entries(s))for(const r of i)try{await this.onProviderMessageEvent({topic:n,message:r,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${n}, message: ${r}`)}}catch(e){this.client.logger.warn(e,"processPendingMessageEvents failed")}}isInitialized(){if(!this.initialized){const{message:e}=P("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(oe.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:s,message:n,attestation:i,transportType:r}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Pt)?this.client.auth.authKeys.get(Pt):{publicKey:void 0};try{const a=await this.client.core.crypto.decode(s,n,{receiverPublicKey:o,encoding:r===ne.link_mode?Ct:be});vo(a)?(this.client.core.history.set(s,a),await this.onRelayEventRequest({topic:s,payload:a,attestation:i,transportType:r,encryptedId:je(n)})):Di(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:s,payload:a,transportType:r}),this.client.core.history.delete(s,a.id)):(this.client.logger.error(`onRelayMessage() -> unknown payload: ${JSON.stringify(a)}`),await this.onRelayEventUnknownPayload({topic:s,payload:a,transportType:r})),await this.client.core.relayer.messages.ack(s,n)}catch(a){this.client.logger.error(`onRelayMessage() -> failed to process an inbound message: ${n}`),this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(ze.expired,async e=>{const{topic:s,id:n}=Yh(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,P("EXPIRED"),!0);if(n&&this.client.auth.requests.keys.includes(n))return await this.deletePendingAuthRequest(n,P("EXPIRED"),!0);s?this.client.session.keys.includes(s)&&(await this.deleteSession({topic:s,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:s})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}registerSubscriptionCleanup(){this.client.core.heartbeat.on("heartbeat_pulse",async()=>{if(!this.cleanupInProgress){this.cleanupInProgress=!0;try{await this.cleanupOrphanedSubscriptions()}catch(e){this.client.logger.warn(e)}finally{this.cleanupInProgress=!1}}})}registerPairingEvents(){this.client.core.pairing.events.on(Zt.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Zt.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!le(e,!1)){const{message:s}=P("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(s)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:s}=P("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(s)}if(ot(this.client.core.pairing.pairings.get(e).expiry)){const{message:s}=P("EXPIRED",`pairing topic: ${e}`);throw new Error(s)}}async isValidSessionTopic(e){if(!le(e,!1)){const{message:s}=P("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(s)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:s}=P("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(s)}if(ot(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:s}=P("EXPIRED",`session topic: ${e}`);throw new Error(s)}if(!this.client.core.crypto.keychain.has(e)){const{message:s}=P("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(s)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(le(e,!1)){const{message:s}=P("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(s)}else{const{message:s}=P("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(s)}}async isValidProposalId(e){if(!j1(e)){const{message:s}=P("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(s)}if(!this.client.proposal.keys.includes(e)){const{message:s}=P("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(s)}if(ot(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:s}=P("EXPIRED",`proposal id: ${e}`);throw new Error(s)}}validateRequestExpiry(e){if(e&&!J1(e,ar)){const{message:s}=P("MISSING_OR_INVALID",`request() expiry: ${e}. Expiry must be a number (in seconds) between ${ar.min} and ${ar.max}`);throw new Error(s)}}}class H2 extends ds{constructor(e,s){super(e,s,P2,Ao),this.core=e,this.logger=s}}class K2 extends ds{constructor(e,s){super(e,s,$2,Ao),this.core=e,this.logger=s}}class V2 extends ds{constructor(e,s){super(e,s,B2,Ao,n=>n.id),this.core=e,this.logger=s}}class G2 extends ds{constructor(e,s){super(e,s,F2,Oi,()=>Pt),this.core=e,this.logger=s}}class W2 extends ds{constructor(e,s){super(e,s,q2,Oi),this.core=e,this.logger=s}}class Y2 extends ds{constructor(e,s){super(e,s,z2,Oi,n=>n.id),this.core=e,this.logger=s}}class X2{constructor(e,s){this.core=e,this.logger=s,this.authKeys=new G2(this.core,this.logger),this.pairingTopics=new W2(this.core,this.logger),this.requests=new Y2(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}let Z2=class Hu extends ZE{constructor(e){super(e),this.protocol=qu,this.version=zu,this.name=or.name,this.events=new Ve.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.authenticate=async(n,i)=>{try{return await this.engine.authenticate(n,i)}catch(r){throw this.logger.error(r.message),r}},this.formatAuthMessage=n=>{try{return this.engine.formatAuthMessage(n)}catch(i){throw this.logger.error(i.message),i}},this.approveSessionAuthenticate=async n=>{try{return await this.engine.approveSessionAuthenticate(n)}catch(i){throw this.logger.error(i.message),i}},this.rejectSessionAuthenticate=async n=>{try{return await this.engine.rejectSessionAuthenticate(n)}catch(i){throw this.logger.error(i.message),i}},this.name=(e==null?void 0:e.name)||or.name,this.metadata=Db(e==null?void 0:e.metadata),this.signConfig=e==null?void 0:e.signConfig;const s=wo({logger:(e==null?void 0:e.logger)||or.logger,name:this.name});this.logger=s,this.core=(e==null?void 0:e.core)||new R2(e),this.session=new K2(this.core,this.logger),this.proposal=new H2(this.core,this.logger),this.pendingRequest=new V2(this.core,this.logger),this.engine=new j2(this),this.auth=new X2(this.core,this.logger)}static async init(e){const s=new Hu(e);return await s.initialize(),s}get context(){return Ne(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const J2=Z2;var Q2=Object.defineProperty,eI=Object.defineProperties,tI=Object.getOwnPropertyDescriptors,Uc=Object.getOwnPropertySymbols,sI=Object.prototype.hasOwnProperty,nI=Object.prototype.propertyIsEnumerable,Mc=(t,e,s)=>e in t?Q2(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Lc=(t,e)=>{for(var s in e||(e={}))sI.call(e,s)&&Mc(t,s,e[s]);if(Uc)for(var s of Uc(e))nI.call(e,s)&&Mc(t,s,e[s]);return t},Fc=(t,e)=>eI(t,tI(e));const iI={Accept:"application/json","Content-Type":"application/json"},rI="POST",qc={headers:iI,method:rI},zc=10;let Ku=class{constructor(e,s=!1){if(this.url=e,this.disableProviderPing=s,this.events=new Ve.EventEmitter,this.isAvailable=!1,this.registering=!1,!Dc(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=s}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const s=rs(e),n=await(await Fo(this.url,Fc(Lc({},qc),{body:s}))).json();this.onPayload({data:n})}catch(s){this.onError(e.id,s)}}async register(e=this.url){if(!Dc(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const s=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=s||this.events.listenerCount("open")>=s)&&this.events.setMaxListeners(s+1),new Promise((n,i)=>{this.events.once("register_error",r=>{this.resetMaxListeners(),i(r)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const s=rs({id:1,jsonrpc:"2.0",method:"test",params:[]});await Fo(e,Fc(Lc({},qc),{body:s}))}this.onOpen()}catch(s){const n=this.parseError(s);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const s=typeof e.data=="string"?is(e.data):e.data;this.events.emit("payload",s)}onError(e,s){const n=this.parseError(s),i=n.message||n.toString(),r=xi(e,i);this.events.emit("payload",r)}parseError(e,s=this.url){return pu(e,s,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>zc&&this.events.setMaxListeners(zc)}};const jc="error",oI="wss://relay.walletconnect.org",aI="wc",Vu="universal_provider",Cn=`${aI}@2:${Vu}:`,Gu="https://rpc.walletconnect.org/v1/",Wu="generic",cI=`${Gu}bundler`,As="call_status",lI=86400,To={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function Yu(t,e,s){var i;const n=It(t);return((i=e.rpcMap)==null?void 0:i[n.reference])||`${Gu}?chainId=${n.namespace}:${n.reference}&projectId=${s}`}function hI(t){return t.includes(":")?t.split(":")[1]:t}function Xu(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function uI(t,e){const s=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!s.length)return[];const n=[];return s.forEach(i=>{const r=e.namespaces[i].accounts;n.push(...r)}),n}function Hc(t){return Object.fromEntries(Object.entries(t).filter(([e,s])=>{var n,i;return((n=s==null?void 0:s.chains)==null?void 0:n.length)&&((i=s==null?void 0:s.chains)==null?void 0:i.length)>0}))}function Bn(t={},e={}){const s=Hc(Kc(t)),n=Hc(Kc(e));return Bv(s,n)}function Kc(t){var s,n,i,r,o;const e={};if(!lt(t))return e;for(const[a,c]of Object.entries(t)){const l=Si(a)?[a]:c.chains,h=c.methods||[],u=c.events||[],d=c.rpcMap||{},p=vs(a);e[p]={...e[p],...c,chains:ct(l,(s=e[p])==null?void 0:s.chains),methods:ct(h,(n=e[p])==null?void 0:n.methods),events:ct(u,(i=e[p])==null?void 0:i.events)},(lt(d)||lt(((r=e[p])==null?void 0:r.rpcMap)||{}))&&(e[p].rpcMap={...d,...(o=e[p])==null?void 0:o.rpcMap})}return e}function Vc(t){return t.includes(":")?t.split(":")[2]:t}function Gc(t){const e={};for(const[s,n]of Object.entries(t)){const i=n.methods||[],r=n.events||[],o=n.accounts||[],a=Si(s)?[s]:n.chains?n.chains:Xu(n.accounts);e[s]={chains:a,methods:i,events:r,accounts:o}}return e}function cr(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}function dI(t){try{const e=JSON.parse(t);return typeof e=="object"&&e!==null&&!Array.isArray(e)}catch{return!1}}const Zu={},Ts=t=>Zu[t],lr=(t,e)=>{Zu[t]=e},Wc="eip155",pI=["atomic","flow-control","paymasterService","sessionKeys","auxiliaryFunds"],fI=t=>t&&t.startsWith("0x")?BigInt(t).toString(10):t,hr=t=>t&&t.startsWith("0x")?t:`0x${BigInt(t).toString(16)}`,Yc=t=>Object.keys(t).filter(e=>pI.includes(e)).reduce((e,s)=>(e[s]=gI(t[s]),e),{}),gI=t=>typeof t=="string"&&dI(t)?JSON.parse(t):t,_I=(t,e,s)=>{const{sessionProperties:n={},scopedProperties:i={}}=t,r={};if(!lt(i)&&!lt(n))return;const o=Yc(n);for(const a of s){const c=fI(a);if(!c)continue;r[hr(c)]=o;const l=i==null?void 0:i[`${Wc}:${c}`];if(l){const h=l==null?void 0:l[`${Wc}:${c}:${e}`];r[hr(c)]={...r[hr(c)],...Yc(h||l)}}}for(const[a,c]of Object.entries(r))Object.keys(c).length===0&&delete r[a];return Object.keys(r).length>0?r:void 0};let ur,mI=class Ju{constructor(e){this.storage=e}async getItem(e){return await this.storage.getItem(e)}async setItem(e,s){return await this.storage.setItem(e,s)}async removeItem(e){return await this.storage.removeItem(e)}static getStorage(e){return ur||(ur=new Ju(e)),ur}};async function yI(t,e){const s=It(t.result.capabilities.caip345.caip2),n=t.result.capabilities.caip345.transactionHashes,i=await Promise.allSettled(n.map(u=>wI(s.reference,u,e))),r=i.filter(u=>u.status==="fulfilled").map(u=>u.value).filter(u=>u);i.filter(u=>u.status==="rejected").forEach(u=>console.warn("Failed to fetch transaction receipt:",u.reason));const o=!r.length||r.some(u=>!u),a=r.every(u=>(u==null?void 0:u.status)==="0x1"),c=r.every(u=>(u==null?void 0:u.status)==="0x0"),l=r.some(u=>(u==null?void 0:u.status)==="0x0");let h;return o?h=100:a?h=200:c?h=500:l&&(h=600),{id:t.result.id,version:t.request.version,atomic:t.request.atomicRequired,chainId:t.request.chainId,capabilities:t.result.capabilities,receipts:r,status:h}}async function wI(t,e,s){return await s(parseInt(t)).request(Je("eth_getTransactionReceipt",[e]))}async function bI({sendCalls:t,storage:e}){const s=await e.getItem(As);await e.setItem(As,{...s,[t.result.id]:{request:t.request,result:t.result,expiry:ce(lI)}})}async function EI({resultId:t,storage:e}){const s=await e.getItem(As);if(s){delete s[t],await e.setItem(As,s);for(const n in s)ot(s[n].expiry)&&delete s[n];await e.setItem(As,s)}}async function vI({resultId:t,storage:e}){var n;const s=(n=await e.getItem(As))==null?void 0:n[t];if(s&&!ot(s.expiry))return s;await EI({resultId:t,storage:e})}class II{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Ts("events"),this.client=Ts("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain()),this.storage=mI.getStorage(this.client.core.storage)}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e);case"wallet_sendCalls":return await this.sendCalls(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(parseInt(e),s);const n=this.chainId;this.chainId=parseInt(e),this.events.emit(To.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${n}`})}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,s){const n=s||Yu(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Io(new Ku(n,Ts("disableProviderPing")))}setHttpProvider(e,s){const n=this.createHttpProvider(e,s);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var i;const n=parseInt(hI(s));e[n]=this.createHttpProvider(n,(i=this.namespace.rpcMap)==null?void 0:i[s])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}getHttpProvider(e){const s=e||this.chainId;return this.httpProviders[s]||(this.httpProviders={...this.httpProviders,[s]:this.createHttpProvider(s)},this.httpProviders[s])}async handleSwitchChain(e){var i,r;let s=e.request.params?(i=e.request.params[0])==null?void 0:i.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const n=parseInt(s,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:(r=this.namespace.chains)==null?void 0:r[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var u,d,p,f,g;const s=(d=(u=e.request)==null?void 0:u.params)==null?void 0:d[0],n=((f=(p=e.request)==null?void 0:p.params)==null?void 0:f[1])||[];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const i=this.client.session.get(e.topic),r=((g=i==null?void 0:i.sessionProperties)==null?void 0:g.capabilities)||{},o=n.length>0?n.join(","):`0x${this.chainId.toString(16)}`,a=`${s}${o}`,c=r==null?void 0:r[a];if(c)return c;let l;try{l=_I(i,s,n)}catch(_){console.warn("Failed to extract capabilities from session",_)}if(l)return l;const h=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:{...i.sessionProperties||{},capabilities:{...r||{},[a]:h}}})}catch(_){console.warn("Failed to update session with capabilities",_)}return h}async getCallStatus(e){var o,a,c;const s=this.client.session.get(e.topic),n=(o=s.sessionProperties)==null?void 0:o.bundler_name;if(n){const l=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(l,e)}catch(h){console.warn("Failed to fetch call status from bundler",h,l)}}const i=(a=s.sessionProperties)==null?void 0:a.bundler_url;if(i)try{return await this.getUserOperationReceipt(i,e)}catch(l){console.warn("Failed to fetch call status from custom bundler",l,i)}const r=await vI({resultId:(c=e.request.params)==null?void 0:c[0],storage:this.storage});if(r)try{return await yI(r,this.getHttpProvider.bind(this))}catch(l){console.warn("Failed to fetch call status from stored send calls",l,r)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,s){var r;const n=new URL(e),i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Je("eth_getUserOperationReceipt",[(r=s.request.params)==null?void 0:r[0]]))});if(!i.ok)throw new Error(`Failed to fetch user operation receipt - ${i.status}`);return await i.json()}getBundlerUrl(e,s){return`${cI}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${s}`}async sendCalls(e){var c,l,h;const s=await this.client.request(e),n=(c=e.request.params)==null?void 0:c[0],i=s==null?void 0:s.id,r=(s==null?void 0:s.capabilities)||{},o=(l=r==null?void 0:r.caip345)==null?void 0:l.caip2,a=(h=r==null?void 0:r.caip345)==null?void 0:h.transactionHashes;return!i||!o||!(a!=null&&a.length)||await bI({sendCalls:{request:n,result:s},storage:this.storage}),s}}class SI{constructor(e){this.name=Wu,this.namespace=e.namespace,this.events=Ts("events"),this.client=Ts("client"),this.chainId=this.getDefaultChain(),this.name=this.getNamespaceName(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,s){this.httpProviders[e]||this.setHttpProvider(e,s);const n=this.chainId;this.chainId=e,this.events.emit(To.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${n}`})}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getNamespaceName(){const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return It(e).namespace}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){var s,n;const e={};return(n=(s=this.namespace)==null?void 0:s.accounts)==null||n.forEach(i=>{var a,c;const r=It(i),o=(c=(a=this.namespace)==null?void 0:a.rpcMap)==null?void 0:c[`${r.namespace}:${r.reference}`];e[r.reference]=this.createHttpProvider(i,o)}),e}getHttpProvider(e){const s=It(e).reference,n=this.httpProviders[s];if(typeof n>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return n}setHttpProvider(e,s){const n=this.createHttpProvider(e,s);n&&(this.httpProviders[e]=n)}createHttpProvider(e,s){const n=s||Yu(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Io(new Ku(n,Ts("disableProviderPing")))}}let xI=class Qu{constructor(e){this.events=new Kr,this.rpcProviders={},this.disableProviderPing=!1,this.providerOpts=e,this.logger=wo({logger:e.logger??jc,name:this.providerOpts.name??Vu}),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const s=new Qu(e);return await s.initialize(),s}async request(e,s,n){const[i,r]=this.validateChain(s);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:{...e},chainId:`${i}:${r}`,topic:this.session.topic,expiry:n})}sendAsync(e,s,n,i){const r=new Date().getTime();this.request(e,n,i).then(o=>s(null,cn(r,o))).catch(o=>s(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:ie("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.connectParams=e,this.setNamespaces(e),this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,s){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,s);n&&(this.uri=n,this.events.emit("display_uri",n));const r=await i();if(this.session=r.session,this.session){const o=Gc(this.session.namespaces);this.namespaces=Bn(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return r}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}removeListener(e,s){this.events.removeListener(e,s)}off(e,s){this.events.off(e,s)}get isWalletConnect(){return!0}async pair(e){var o,a;const{uri:s,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties,authentication:(o=this.connectParams)==null?void 0:o.authentication,walletPay:(a=this.connectParams)==null?void 0:a.walletPay});s&&(this.uri=s,this.events.emit("display_uri",s));const i=await n();this.session=i;const r=Gc(i.namespaces);return this.namespaces=Bn(this.namespaces,r),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,s){try{if(!this.session)return;const[n,i]=this.validateChain(e),r=this.getProvider(n);r?r.setDefaultChain(i,s):this.session&&this.logger.warn(`Provider for namespace '${n}' not found in setDefaultChain`)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){try{this.logger.info("Cleaning up inactive pairings...");const s=this.client.pairing.getAll();if(!Ke(s))return;for(const n of s)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${s.length}`)}catch(s){this.logger.warn(s,"Failed to cleanup pending pairings")}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,s;if(this.client=this.providerOpts.client||await J2.init({core:this.providerOpts.core,logger:this.providerOpts.logger||jc,relayUrl:this.providerOpts.relayUrl||oI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(n){throw this.logger.error(n,"Failed to get session"),new Error(`The provided session: ${(s=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:s.topic} doesn't exist in the Sign client`)}else{const n=this.client.session.getAll();this.session=n[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(s=>vs(s)))];lr("client",this.client),lr("events",this.events),lr("disableProviderPing",this.disableProviderPing),e.forEach(s=>{if(!this.session)return;const n=uI(s,this.session);if((n==null?void 0:n.length)===0)return;const i=Xu(n),r={...Bn(this.namespaces,this.optionalNamespaces)[s],accounts:n,chains:i};switch(s){case"eip155":this.rpcProviders[s]=new II({namespace:r});break;default:this.rpcProviders[s]=new SI({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var n;const{topic:s}=e;s===((n=this.session)==null?void 0:n.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var r;const{params:s,topic:n}=e;if(n!==((r=this.session)==null?void 0:r.topic))return;const{event:i}=s;if(i.name==="accountsChanged"){const o=i.data;o&&Ke(o)&&this.events.emit("accountsChanged",o.map(Vc))}else if(i.name==="chainChanged"){const o=s.chainId,a=s.event.data,c=vs(o),l=cr(o)!==cr(a)?`${c}:${cr(a)}`:o;this.onChainChanged({currentCaipChainId:l})}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:s})=>{var r,o;if(e!==((r=this.session)==null?void 0:r.topic))return;const{namespaces:n}=s,i=(o=this.client)==null?void 0:o.session.get(e);this.session={...i,namespaces:n},this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:s})}),this.client.on("session_delete",async e=>{var s;e.topic===((s=this.session)==null?void 0:s.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",{...ie("USER_DISCONNECTED"),data:e.topic}))}),this.on(To.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged({...e,internal:!0})})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Wu]}
13onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var s;this.getProvider(e).updateNamespace((s=this.session)==null?void 0:s.namespaces[e])})}setNamespaces(e){const{namespaces:s={},optionalNamespaces:n={},sessionProperties:i,scopedProperties:r}=e;this.optionalNamespaces=Bn(s,n),this.sessionProperties=i,this.scopedProperties=r}validateChain(e){const[s,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[s,n];if(s&&!Object.keys(this.namespaces||{}).map(o=>vs(o)).includes(s))throw new Error(`Namespace '${s}' is not configured. Please call connect() first with namespace config.`);if(s&&n)return[s,n];const i=vs(Object.keys(this.namespaces)[0]),r=this.rpcProviders[i].getDefaultChain();return[i,r]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged({currentCaipChainId:e,previousCaipChainId:s,internal:n=!1}){if(!this.namespaces)return;const[i,r]=this.validateChain(e);if(r){if(this.updateNamespaceChain(i,r),n)this.events.emit("chainChanged",r),this.emitAccountsChangedOnChainChange({namespace:i,currentCaipChainId:e,previousCaipChainId:s});else{const o=this.getProvider(i);o?o.setDefaultChain(r):this.session&&this.logger.warn(`Provider for namespace '${i}' not found during chain change`)}await this.persist("namespaces",this.namespaces)}}emitAccountsChangedOnChainChange({namespace:e,currentCaipChainId:s,previousCaipChainId:n}){var i,r;try{if(n===s)return;const o=(r=(i=this.session)==null?void 0:i.namespaces[e])==null?void 0:r.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${s}:`)).map(Vc);if(!Ke(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn(o,"Failed to emit accountsChanged on chain change")}}updateNamespaceChain(e,s){if(!this.namespaces)return;const n=this.namespaces[e]?e:`${e}:${s}`,i={chains:[],methods:[],events:[],defaultChain:s};this.namespaces[n]?this.namespaces[n]&&(this.namespaces[n].defaultChain=s):this.namespaces[n]=i}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.connectParams=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,s){var i;const n=((i=this.session)==null?void 0:i.topic)||"";await this.client.core.storage.setItem(`${Cn}/${e}${n}`,s)}async getFromStore(e){var n;const s=((n=this.session)==null?void 0:n.topic)||"";return await this.client.core.storage.getItem(`${Cn}/${e}${s}`)}async deleteFromStore(e){var n;const s=((n=this.session)==null?void 0:n.topic)||"";await this.client.core.storage.removeItem(`${Cn}/${e}${s}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const s=await this.client.core.storage.getKeys();for(const n of s)n.startsWith(Cn)&&await this.client.core.storage.removeItem(n)}catch(s){this.logger.warn(s,"Failed to cleanup storage")}}};const DI=xI,OI="wc",kI="ethereum_provider",AI=`${OI}@2:${kI}:`,TI="https://rpc.walletconnect.org/v1/",ui=["eth_sendTransaction","personal_sign"],ed=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],di=["chainChanged","accountsChanged"],td=["chainChanged","accountsChanged","message","disconnect","connect"],RI=async()=>{const{createAppKit:t}=await Od(()=>import("./core-e07ff3bc.js").then(e=>e.a5),["assets/core-e07ff3bc.js","assets/index-23810fa3.js","assets/index-91beb138.css","assets/index-3c3d7d8c.js","assets/index-1b0d714e.js","assets/browser-ponyfill-72c2a02e.js"]);return t};function pi(t){return Number(t[0].split(":")[1])}function Un(t){return`0x${t.toString(16)}`}function PI(t){const{chains:e,optionalChains:s,methods:n,optionalMethods:i,events:r,optionalEvents:o,rpcMap:a}=t;if(!Ke(e))throw new Error("Invalid chains");const c={chains:e,methods:n||ui,events:r||di,rpcMap:{...e.length?{[pi(e)]:a[pi(e)]}:{}}},l=r==null?void 0:r.filter(p=>!di.includes(p)),h=n==null?void 0:n.filter(p=>!ui.includes(p));if(!s&&!o&&!i&&!(l!=null&&l.length)&&!(h!=null&&h.length))return{required:e.length?c:void 0};const u=(l==null?void 0:l.length)&&(h==null?void 0:h.length)||!s,d={chains:[...new Set(u?c.chains.concat(s||[]):s)],methods:[...new Set(c.methods.concat(i!=null&&i.length?i:ed))],events:[...new Set(c.events.concat(o!=null&&o.length?o:td))],rpcMap:a};return{required:e.length?c:void 0,optional:s.length?d:void 0}}let sd=class nd{constructor(){this.events=new Ve.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=AI,this.on=(e,s)=>
13(this.events.on(e,s),this),this.once=(e,s)=>(this.events.once(e,s),this),this.removeListener=(e,s)=>(this.events.removeListener(e,s),this),this.off=(e,s)=>(this.events.off(e,s),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const s=new nd;return await s.initialize(e),s}async request(e,s){return await this.signer.request(e,this.formatChainId(this.chainId),s)}sendAsync(e,s,n){this.signer.sendAsync(e,s,this.formatChainId(this.chainId),n)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){var i;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:s,optional:n}=PI(this.rpc);try{const r=await new Promise(async(a,c)=>{var h,u;this.rpc.showQrModal&&((h=this.modal)==null||h.open(),(u=this.modal)==null||u.subscribeState(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),c(new Error("Connection request reset. Please try again.")))}));const l=e!=null&&e.scopedProperties?{[this.namespace]:e.scopedProperties}:void 0;await this.signer.connect({namespaces:{...s&&{[this.namespace]:s}},...n&&{optionalNamespaces:{[this.namespace]:n}},pairingTopic:e==null?void 0:e.pairingTopic,scopedProperties:l}).then(d=>{a(d)}).catch(d=>{var p;(p=this.modal)==null||p.showErrorMessage("Unable to connect"),c(new Error(d.message))})});if(!r)return;const o=Ja(r.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Un(this.chainId)})}catch(r){throw this.signer.logger.error(r),r}finally{(i=this.modal)==null||i.close()}}async authenticate(e,s){var n;if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const i=await new Promise(async(o,a)=>{var c,l;this.rpc.showQrModal&&((c=this.modal)==null||c.open(),(l=this.modal)==null||l.subscribeState(h=>{!h.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate({...e,chains:this.rpc.chains},s).then(h=>{o(h)}).catch(h=>{var u;(u=this.modal)==null||u.showErrorMessage("Unable to connect"),a(new Error(h.message))})}),r=i.session;if(r){const o=Ja(r.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Un(this.chainId)})}return i}catch(i){throw this.signer.logger.error(i),i}finally{(n=this.modal)==null||n.close()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:s}=e,{event:n}=s;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",e)}),this.signer.on("accountsChanged",e=>{this.accounts=this.parseAccounts(e),this.events.emit("accountsChanged",this.accounts)}),this.signer.on("chainChanged",e=>{const s=parseInt(e);this.chainId=s,this.events.emit("chainChanged",Un(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",{...ie("USER_DISCONNECTED"),data:e.topic,name:"USER_DISCONNECTED"})}),this.signer.on("display_uri",e=>{this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const s=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));s.length&&(this.chainId=s[0],this.events.emit("chainChanged",Un(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const s=this.parseChainId(e);this.chainId=s,this.switchEthereumChain(s)}}parseAccountId(e){const[s,n,i]=e.split(":");return{chainId:`${s}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(s=>this.parseChainId(this.parseAccountId(s).chainId)===this.chainId).map(s=>this.parseAccountId(s).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){const s=(e==null?void 0:e.chains)??[],n=(e==null?void 0:e.optionalChains)??[],i=s.concat(n);if(!i.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const r=s.length?(e==null?void 0:e.methods)||ui:[],o=s.length?(e==null?void 0:e.events)||di:[],a=(e==null?void 0:e.optionalMethods)||[],c=(e==null?void 0:e.optionalEvents)||[],l=(e==null?void 0:e.rpcMap)||this.buildRpcMap(i,e.projectId),h=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:s==null?void 0:s.map(u=>this.formatChainId(u)),optionalChains:n.map(u=>this.formatChainId(u)),methods:r,events:o,optionalMethods:a,optionalEvents:c,rpcMap:l,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:h,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,s){const n={};return e.forEach(i=>
13{n[i]=this.getRpcUrl(i,s)}),n}async initialize(e){var s;if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?pi(this.rpc.chains):pi(this.rpc.optionalChains),this.signer=await DI.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let n;try{const i=await RI(),{convertWCMToAppKitOptions:r}=await Promise.resolve().then(function(){return UI}),o=r({...this.rpc.qrModalOptions,chains:[...new Set([...this.rpc.chains,...this.rpc.optionalChains])],metadata:this.rpc.metadata,projectId:this.rpc.projectId});if(!o.networks.length)throw new Error("No networks found for WalletConnect");n=i({...o,universalProvider:this.signer,manualWCControl:!0,enableMobileFullScreen:((s=this.rpc.qrModalOptions)==null?void 0:s.enableMobileFullScreen)===!0})}catch(i){throw console.warn(i),new Error("To use QR modal, please install @reown/appkit package")}if(n)try{this.modal=n}catch(i){throw this.signer.logger.error(i),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:s,optionalChains:n,rpcMap:i}=e;s&&Ke(s)&&(this.rpc.chains=s.map(r=>this.formatChainId(r)),s.forEach(r=>{this.rpc.rpcMap[r]=(i==null?void 0:i[r])||this.getRpcUrl(r)})),n&&Ke(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(r=>this.formatChainId(r)),n.forEach(r=>{this.rpc.rpcMap[r]=(i==null?void 0:i[r])||this.getRpcUrl(r)}))}getRpcUrl(e,s){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${TI}?chainId=eip155:${e}&projectId=${s||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),s=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:s==null?void 0:s.accounts),this.setAccounts(s==null?void 0:s.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(s=>this.signer.logger.warn(s))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(s=>this.parseAccount(s))}};const $I=sd;function NI(t){if(t)return{"--w3m-font-family":t["--wcm-font-family"],"--w3m-accent":t["--wcm-accent-color"],"--w3m-color-mix":t["--wcm-background-color"],"--w3m-z-index":t["--wcm-z-index"]?Number(t["--wcm-z-index"]):void 0,"--w3m-qr-color":t["--wcm-accent-color"],"--w3m-font-size-master":t["--wcm-text-medium-regular-size"],"--w3m-border-radius-master":t["--wcm-container-border-radius"],"--w3m-color-mix-strength":0}}const CI=t=>{const[e,s]=t.split(":");return id({id:s,caipNetworkId:t,chainNamespace:e,name:"",nativeCurrency:{name:"",symbol:"",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}})};function BI(t){var i,r,o,a,c,l,h;const e=(i=t.chains)==null?void 0:i.map(CI).filter(Boolean);if(e.length===0)throw new Error("At least one chain must be specified");const s=e.find(u=>{var d;return u.id===((d=t.defaultChain)==null?void 0:d.id)}),n={projectId:t.projectId,networks:e,themeMode:t.themeMode,themeVariables:NI(t.themeVariables),chainImages:t.chainImages,connectorImages:t.walletImages,defaultNetwork:s,metadata:{...t.metadata,name:((r=t.metadata)==null?void 0:r.name)||"WalletConnect",description:((o=t.metadata)==null?void 0:o.description)||"Connect to WalletConnect-compatible wallets",url:((a=t.metadata)==null?void 0:a.url)||"https://walletconnect.org",icons:((c=t.metadata)==null?void 0:c.icons)||["https://walletconnect.org/walletconnect-logo.png"]},showWallets:!0,featuredWalletIds:t.explorerRecommendedWalletIds==="NONE"?[]:Array.isArray(t.explorerRecommendedWalletIds)?t.explorerRecommendedWalletIds:[],excludeWalletIds:t.explorerExcludedWalletIds==="ALL"?[]:Array.isArray(t.explorerExcludedWalletIds)?t.explorerExcludedWalletIds:[],enableEIP6963:!1,enableInjected:!1,enableCoinbase:!0,enableWalletConnect:!0,features:{email:!1,socials:!1}};if((l=t.mobileWallets)!=null&&l.length||(h=t.desktopWallets)!=null&&h.length){const u=[...(t.mobileWallets||[]).map(f=>({id:f.id,name:f.name,links:f.links})),...(t.desktopWallets||[]).map(f=>({id:f.id,name:f.name,links:{native:f.links.native,universal:f.links.universal}}))],d=[...n.featuredWalletIds||[],...n.excludeWalletIds||[]],p=u.filter(f=>!d.includes(f.id));p.length&&(n.customWallets=p)}return n}function id(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}var UI=Object.freeze({__proto__:null,convertWCMToAppKitOptions:BI,defineChain:id});const SS=Object.freeze(Object.defineProperty({__proto__:null,EthereumProvider:$I,OPTIONAL_EVENTS:td,OPTIONAL_METHODS:ed,REQUIRED_EVENTS:di,REQUIRED_METHODS:ui,default:sd},Symbol.toStringTag,{value:"Module"}));
13export{Ut as A,xi as B,_0 as C,rt as D,He as E,it as F,pb as G,Ku as H,hs as I,SS as J,ja as P,Oh as Q,Fe as R,Hh as U,ns as a,Zr as b,R as c,hg as d,k0 as e,De as f,Ol as g,Np as h,Dl as i,ss as j,Ne as k,bo as l,LE as m,wv as n,Io as o,vo as p,Di as q,gg as r,Tr as s,_e as t,cn as u,us as v,Je as w,g0 as x,rs as y,is as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.