"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[952],{3320:function(t,e,r){var n=r(373);r.o(n,"useRouter")&&r.d(e,{useRouter:function(){return n.useRouter}}),r.o(n,"useSearchParams")&&r.d(e,{useSearchParams:function(){return n.useSearchParams}})},241:function(t,e,r){r.d(e,{xW:function(){return tP},kA:function(){return tE}});var n={};function i(t){if(!Number.isSafeInteger(t)||t<0)throw Error(`Wrong positive integer: ${t}`)}function o(t,...e){if(!(t instanceof Uint8Array))throw Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function s(t,e=!0){if(t.destroyed)throw Error("Hash instance has been destroyed");if(e&&t.finished)throw Error("Hash#digest() has already been called")}r.r(n),r.d(n,{dQ:function(){return P},ci:function(){return S},bytesToNumberBE:function(){return L},ty:function(){return O},eV:function(){return _},n$:function(){return C},ql:function(){return N},hexToBytes:function(){return k},tL:function(){return R},S5:function(){return $},FF:function(){return M}});let a="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,l=t=>t instanceof Uint8Array,u=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),f=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw Error("Non little-endian hardware is not supported");function h(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}(t)),!l(t))throw Error(`expected Uint8Array, got ${typeof t}`);return t}class c{clone(){return this._cloneInto()}}function d(t=32){if(a&&"function"==typeof a.getRandomValues)return a.getRandomValues(new Uint8Array(t));throw Error("crypto.getRandomValues must be defined")}class p extends c{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=u(this.buffer)}update(t){s(this);let{view:e,buffer:r,blockLen:n}=this,i=(t=h(t)).length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){let e=u(t);for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){s(this),function(t,e){o(t);let r=e.outputLen;if(t.length<r)throw Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished=!0;let{buffer:e,view:r,blockLen:n,isLE:i}=this,{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>n-a&&(this.process(r,0),a=0);for(let t=a;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),l=n?4:0,u=n?0:4;t.setUint32(e+l,s,n),t.setUint32(e+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);let l=u(t),f=this.outputLen;if(f%4)throw Error("_sha2: outputLen should be aligned to 32bit");let h=f/4,c=this.get();if(h>c.length)throw Error("_sha2: outputLen bigger than state");for(let t=0;t<h;t++)l.setUint32(4*t,c[t],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}let g=(t,e,r)=>t&e^~t&r,y=(t,e,r)=>t&e^t&r^e&r,w=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),E=new Uint32Array(64);class m extends p{constructor(){super(64,32,8,!1),this.A=0|b[0],this.B=0|b[1],this.C=0|b[2],this.D=0|b[3],this.E=0|b[4],this.F=0|b[5],this.G=0|b[6],this.H=0|b[7]}get(){let{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)E[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){let e=E[t-15],r=E[t-2],n=f(e,7)^f(e,18)^e>>>3,i=f(r,17)^f(r,19)^r>>>10;E[t]=i+E[t-7]+n+E[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:l,H:u}=this;for(let t=0;t<64;t++){let e=u+(f(s,6)^f(s,11)^f(s,25))+g(s,a,l)+w[t]+E[t]|0,h=(f(r,2)^f(r,13)^f(r,22))+y(r,n,i)|0;u=l,l=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(r,n,i,o,s,a,l,u)}roundClean(){E.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}let v=function(t){let e=e=>t().update(h(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}(()=>new m);BigInt(0);let A=BigInt(1),x=BigInt(2),I=t=>t instanceof Uint8Array,U=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function S(t){if(!I(t))throw Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=U[t[r]];return e}function B(t){if("string"!=typeof t)throw Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function k(t){if("string"!=typeof t)throw Error("hex string expected, got "+typeof t);let e=t.length;if(e%2)throw Error("padded hex string expected, got unpadded hex of length "+e);let r=new Uint8Array(e/2);for(let e=0;e<r.length;e++){let n=2*e,i=Number.parseInt(t.slice(n,n+2),16);if(Number.isNaN(i)||i<0)throw Error("Invalid byte sequence");r[e]=i}return r}function L(t){return B(S(t))}function O(t){if(!I(t))throw Error("Uint8Array expected");return B(S(Uint8Array.from(t).reverse()))}function R(t,e){return k(t.toString(16).padStart(2*e,"0"))}function $(t,e){return R(t,e).reverse()}function N(t,e,r){let n;if("string"==typeof e)try{n=k(e)}catch(r){throw Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else if(I(e))n=Uint8Array.from(e);else throw Error(`${t} must be hex string or Uint8Array`);let i=n.length;if("number"==typeof r&&i!==r)throw Error(`${t} expected ${r} bytes, got ${i}`);return n}function _(...t){let e=new Uint8Array(t.reduce((t,e)=>t+e.length,0)),r=0;return t.forEach(t=>{if(!I(t))throw Error("Uint8Array expected");e.set(t,r),r+=t.length}),e}let P=t=>(x<<BigInt(t-1))-A,T=t=>new Uint8Array(t),H=t=>Uint8Array.from(t);function C(t,e,r){if("number"!=typeof t||t<2)throw Error("hashLen must be a number");if("number"!=typeof e||e<2)throw Error("qByteLen must be a number");if("function"!=typeof r)throw Error("hmacFn must be a function");let n=T(t),i=T(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...t)=>r(i,n,...t),l=(t=T())=>{i=a(H([0]),t),n=a(),0!==t.length&&(i=a(H([1]),t),n=a())},u=()=>{if(o++>=1e3)throw Error("drbg: tried 1000 values");let t=0,r=[];for(;t<e;){let e=(n=a()).slice();r.push(e),t+=n.length}return _(...r)};return(t,e)=>{let r;for(s(),l(t);!(r=e(u()));)l();return s(),r}}let q={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function M(t,e,r={}){let n=(e,r,n)=>{let i=q[r];if("function"!=typeof i)throw Error(`Invalid validator "${r}", expected function`);let o=t[e];if((!n||void 0!==o)&&!i(o,t))throw Error(`Invalid param ${String(e)}=${o} (${typeof o}), expected ${r}`)};for(let[t,r]of Object.entries(e))n(t,r,!1);for(let[t,e]of Object.entries(r))n(t,e,!0);return t}let V=BigInt(0),z=BigInt(1),D=BigInt(2),j=BigInt(3),Z=BigInt(4),F=BigInt(5),W=BigInt(8);function K(t,e){let r=t%e;return r>=V?r:e+r}function J(t,e,r){let n=t;for(;e-- >V;)n*=n,n%=r;return n}function G(t,e){if(t===V||e<=V)throw Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=K(t,e),n=e,i=V,o=z,s=z,a=V;for(;r!==V;){let t=n/r,e=n%r,l=i-s*t,u=o-a*t;n=r,r=e,i=s,o=a,s=l,a=u}if(n!==z)throw Error("invert: does not exist");return K(i,e)}BigInt(9),BigInt(16);let Y=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Q(t,e){let r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function X(t){if("bigint"!=typeof t)throw Error("field order must be bigint");return Math.ceil(t.toString(2).length/8)}function tt(t){let e=X(t);return e+Math.ceil(e/2)}class te extends c{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw Error("Hash should be wrapped by utils.wrapConstructor");i(t.outputLen),i(t.blockLen)}(t);let r=h(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),o.fill(0)}update(t){return s(this),this.iHash.update(t),this}digestInto(t){s(this),o(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let tr=(t,e,r)=>new te(t,e).update(r).digest();tr.create=(t,e)=>new te(t,e);let tn=BigInt(0),ti=BigInt(1);function to(t){return M(t.Fp,Y.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),M(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Q(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}let{bytesToNumberBE:ts,hexToBytes:ta}=n,tl={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){let{Err:e}=tl;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:ts(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=tl,r="string"==typeof t?ta(t):t;if(!(r instanceof Uint8Array))throw Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=tl._parseInt(r.subarray(2)),{d:s,l:a}=tl._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{let e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),l=r(s);return`30${r(s+o+4)}02${l}${i}02${a}${n}`}},tu=BigInt(0),tf=BigInt(1),th=(BigInt(2),BigInt(3));BigInt(4);let tc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),td=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),tp=BigInt(1),tg=BigInt(2),ty=(t,e)=>(t+e/tg)/e;function tw(t){let e=BigInt(3),r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),l=t*t*t%tc,u=l*l*t%tc,f=J(u,e,tc)*u%tc,h=J(f,e,tc)*u%tc,c=J(h,tg,tc)*l%tc,d=J(c,n,tc)*c%tc,p=J(d,i,tc)*d%tc,g=J(p,s,tc)*p%tc,y=J(g,a,tc)*g%tc,w=J(y,s,tc)*p%tc,b=J(w,e,tc)*u%tc,E=J(b,o,tc)*d%tc,m=J(E,r,tc)*l%tc,v=J(m,tg,tc);if(!tb.eql(tb.sqr(v),t))throw Error("Cannot find square root");return v}let tb=function(t,e,r=!1,n={}){if(t<=V)throw Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=Q(t,e);if(o>2048)throw Error("Field lengths over 2048 bytes are not supported");let s=function(t){if(t%Z===j){let e=(t+z)/Z;return function(t,r){let n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw Error("Cannot find square root");return n}}if(t%W===F){let e=(t-F)/W;return function(t,r){let n=t.mul(r,D),i=t.pow(n,e),o=t.mul(r,i),s=t.mul(t.mul(o,D),i),a=t.mul(o,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),r))throw Error("Cannot find square root");return a}}return function(t){let e,r,n;let i=(t-z)/D;for(e=t-z,r=0;e%D===V;e/=D,r++);for(n=D;n<t&&function(t,e,r){if(r<=V||e<V)throw Error("Expected power/modulo > 0");if(r===z)return V;let n=z;for(;e>V;)e&z&&(n=n*t%r),t=t*t%r,e>>=z;return n}(n,i,t)!==t-z;n++);if(1===r){let e=(t+z)/Z;return function(t,r){let n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw Error("Cannot find square root");return n}}let o=(e+z)/D;return function(t,s){if(t.pow(s,i)===t.neg(t.ONE))throw Error("Cannot find square root");let a=r,l=t.pow(t.mul(t.ONE,n),e),u=t.pow(s,o),f=t.pow(s,e);for(;!t.eql(f,t.ONE);){if(t.eql(f,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(f);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);let r=t.pow(l,z<<BigInt(a-e-1));l=t.sqr(r),u=t.mul(u,r),f=t.mul(f,l),a=e}return u}}(t)}(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:P(i),ZERO:V,ONE:z,create:e=>K(e,t),isValid:e=>{if("bigint"!=typeof e)throw Error(`Invalid field element: expected bigint, got ${typeof e}`);return V<=e&&e<t},is0:t=>t===V,isOdd:t=>(t&z)===z,neg:e=>K(-e,t),eql:(t,e)=>t===e,sqr:e=>K(e*e,t),add:(e,r)=>K(e+r,t),sub:(e,r)=>K(e-r,t),mul:(e,r)=>K(e*r,t),pow:(t,e)=>(function(t,e,r){if(r<V)throw Error("Expected power > 0");if(r===V)return t.ONE;if(r===z)return e;let n=t.ONE,i=e;for(;r>V;)r&z&&(n=t.mul(n,i)),i=t.sqr(i),r>>=z;return n})(a,t,e),div:(e,r)=>K(e*G(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>G(e,t),sqrt:n.sqrt||(t=>s(a,t)),invertBatch:t=>(function(t,e){let r=Array(e.length),n=e.reduce((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n)),t.ONE),i=t.inv(n);return e.reduceRight((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n)),i),r})(a,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?$(t,o):R(t,o),fromBytes:t=>{if(t.length!==o)throw Error(`Fp.fromBytes: expected ${o}, got ${t.length}`);return r?O(t):L(t)}});return Object.freeze(a)}(tc,void 0,void 0,{sqrt:tw}),tE=function(t,e){let r=e=>(function(t){let e=function(t){let e=to(t);return M(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n:n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(t){return K(t,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=function(t){let e=function(t){let e=to(t);M(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{let i=e.toAffine();return _(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{let e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){let{a:n,b:i}=e,o=r.sqr(t),s=r.mul(o,t);return r.add(r.add(s,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&tu<t&&t<e.n}function a(t){if(!s(t))throw Error("Expected valid bigint: 0 < bigint < curve.n")}function l(t){let r;let{allowedPrivateKeyLengths:n,nByteLength:i,wrapPrivateKey:o,n:s}=e;if(n&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=S(t)),"string"!=typeof t||!n.includes(t.length))throw Error("Invalid key");t=t.padStart(2*i,"0")}try{r="bigint"==typeof t?t:L(N("private key",t,i))}catch(e){throw Error(`private key must be ${i} bytes, hex or bigint, not ${typeof t}`)}return o&&(r=K(r,s)),a(r),r}let u=new Map;function f(t){if(!(t instanceof h))throw Error("ProjectivePoint expected")}class h{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw Error("x required");if(null==e||!r.isValid(e))throw Error("y required");if(null==n||!r.isValid(n))throw Error("z required")}static fromAffine(t){let{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw Error("invalid affine point");if(t instanceof h)throw Error("projective point not allowed");let i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?h.ZERO:new h(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){let e=r.invertBatch(t.map(t=>t.pz));return t.map((t,r)=>t.toAffine(e[r])).map(h.fromAffine)}static fromHex(t){let e=h.fromAffine(i(N("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return h.BASE.multiply(l(t))}_setWindowSize(t){this._WINDOW_SIZE=t,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw Error("bad point: ZERO")}let{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw Error("bad point: x or y not FE");let i=r.sqr(n),s=o(t);if(!r.eql(i,s))throw Error("bad point: equation left != right");if(!this.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw Error("Field doesn't support isOdd")}equals(t){f(t);let{px:e,py:n,pz:i}=this,{px:o,py:s,pz:a}=t,l=r.eql(r.mul(e,a),r.mul(o,i)),u=r.eql(r.mul(n,a),r.mul(s,i));return l&&u}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:t,b:n}=e,i=r.mul(n,th),{px:o,py:s,pz:a}=this,l=r.ZERO,u=r.ZERO,f=r.ZERO,c=r.mul(o,o),d=r.mul(s,s),p=r.mul(a,a),g=r.mul(o,s);return g=r.add(g,g),f=r.mul(o,a),f=r.add(f,f),l=r.mul(t,f),u=r.mul(i,p),u=r.add(l,u),l=r.sub(d,u),u=r.add(d,u),u=r.mul(l,u),l=r.mul(g,l),f=r.mul(i,f),p=r.mul(t,p),g=r.sub(c,p),g=r.mul(t,g),g=r.add(g,f),f=r.add(c,c),c=r.add(f,c),c=r.add(c,p),c=r.mul(c,g),u=r.add(u,c),p=r.mul(s,a),p=r.add(p,p),c=r.mul(p,g),l=r.sub(l,c),f=r.mul(p,d),f=r.add(f,f),new h(l,u,f=r.add(f,f))}add(t){f(t);let{px:n,py:i,pz:o}=this,{px:s,py:a,pz:l}=t,u=r.ZERO,c=r.ZERO,d=r.ZERO,p=e.a,g=r.mul(e.b,th),y=r.mul(n,s),w=r.mul(i,a),b=r.mul(o,l),E=r.add(n,i),m=r.add(s,a);E=r.mul(E,m),m=r.add(y,w),E=r.sub(E,m),m=r.add(n,o);let v=r.add(s,l);return m=r.mul(m,v),v=r.add(y,b),m=r.sub(m,v),v=r.add(i,o),u=r.add(a,l),v=r.mul(v,u),u=r.add(w,b),v=r.sub(v,u),d=r.mul(p,m),u=r.mul(g,b),d=r.add(u,d),u=r.sub(w,d),d=r.add(w,d),c=r.mul(u,d),w=r.add(y,y),w=r.add(w,y),b=r.mul(p,b),m=r.mul(g,m),w=r.add(w,b),b=r.sub(y,b),b=r.mul(p,b),m=r.add(m,b),y=r.mul(w,m),c=r.add(c,y),y=r.mul(v,m),u=r.mul(E,u),u=r.sub(u,y),y=r.mul(E,w),d=r.mul(v,d),new h(u,c,d=r.add(d,y))}subtract(t){return this.add(t.negate())}is0(){return this.equals(h.ZERO)}wNAF(t){return d.wNAFCached(this,u,t,t=>{let e=r.invertBatch(t.map(t=>t.pz));return t.map((t,r)=>t.toAffine(e[r])).map(h.fromAffine)})}multiplyUnsafe(t){let n=h.ZERO;if(t===tu)return n;if(a(t),t===tf)return this;let{endo:i}=e;if(!i)return d.unsafeLadder(this,t);let{k1neg:o,k1:s,k2neg:l,k2:u}=i.splitScalar(t),f=n,c=n,p=this;for(;s>tu||u>tu;)s&tf&&(f=f.add(p)),u&tf&&(c=c.add(p)),p=p.double(),s>>=tf,u>>=tf;return o&&(f=f.negate()),l&&(c=c.negate()),c=new h(r.mul(c.px,i.beta),c.py,c.pz),f.add(c)}multiply(t){let n,i;a(t);let{endo:o}=e;if(o){let{k1neg:e,k1:s,k2neg:a,k2:l}=o.splitScalar(t),{p:u,f:f}=this.wNAF(s),{p:c,f:p}=this.wNAF(l);u=d.constTimeNegate(e,u),c=d.constTimeNegate(a,c),c=new h(r.mul(c.px,o.beta),c.py,c.pz),n=u.add(c),i=f.add(p)}else{let{p:e,f:r}=this.wNAF(t);n=e,i=r}return h.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){let n=h.BASE,i=(t,e)=>e!==tu&&e!==tf&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){let{px:e,py:n,pz:i}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(i));let s=r.mul(e,t),a=r.mul(n,t),l=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){let{h:t,isTorsionFree:r}=e;if(t===tf)return!0;if(r)return r(h,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:t,clearCofactor:r}=e;return t===tf?this:r?r(h,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(h,this,t)}toHex(t=!0){return S(this.toRawBytes(t))}}h.BASE=new h(e.Gx,e.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let c=e.nBitLength,d=function(t,e){let r=(t,e)=>{let r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>tn;)r&ti&&(n=n.add(i)),i=i.double(),r>>=ti;return n},precomputeWindow(t,e){let{windows:r,windowSize:i}=n(e),o=[],s=t,a=s;for(let t=0;t<r;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(e,i,o){let{windows:s,windowSize:a}=n(e),l=t.ZERO,u=t.BASE,f=BigInt(2**e-1),h=2**e,c=BigInt(e);for(let t=0;t<s;t++){let e=t*a,n=Number(o&f);o>>=c,n>a&&(n-=h,o+=ti);let s=e+Math.abs(n)-1,d=t%2!=0,p=n<0;0===n?u=u.add(r(d,i[e])):l=l.add(r(p,i[s]))}return{p:l,f:u}},wNAFCached(t,e,r,n){let i=t._WINDOW_SIZE||1,o=e.get(t);return o||(o=this.precomputeWindow(t,i),1!==i&&e.set(t,n(o))),this.wNAF(i,o,r)}}}(h,e.endo?Math.ceil(c/2):c);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:l,weierstrassEquation:o,isWithinCurveOrder:s}}({...e,toBytes(t,e,n){let i=e.toAffine(),o=r.toBytes(i.x),s=_;return n?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(t){let e=t.length,n=t[0],s=t.subarray(1);if(e===i&&(2===n||3===n)){let t=L(s);if(!(tu<t&&t<r.ORDER))throw Error("Point is not on curve");let e=u(t),i=r.sqrt(e);return(1&n)==1!=((i&tf)===tf)&&(i=r.neg(i)),{x:t,y:i}}if(e===o&&4===n)return{x:r.fromBytes(s.subarray(0,r.BYTES)),y:r.fromBytes(s.subarray(r.BYTES,2*r.BYTES))};throw Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),h=t=>S(R(t,e.nByteLength)),c=(t,e,r)=>L(t.slice(e,r));class d{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){let r=e.nByteLength;return new d(c(t=N("compactSignature",t,2*r),0,r),c(t,r,2*r))}static fromDER(t){let{r:e,s:r}=tl.toSig(N("DER",t));return new d(e,r)}assertValidity(){if(!f(this.r))throw Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new d(this.r,this.s,t)}recoverPublicKey(t){let{r:i,s:o,recovery:l}=this,u=y(N("msgHash",t));if(null==l||![0,1,2,3].includes(l))throw Error("recovery id invalid");let f=2===l||3===l?i+e.n:i;if(f>=r.ORDER)throw Error("recovery id 2 or 3 invalid");let c=(1&l)==0?"02":"03",d=a.fromHex(c+h(f)),p=G(f,n),g=s(-u*p),w=s(o*p),b=a.BASE.multiplyAndAddUnsafe(d,g,w);if(!b)throw Error("point at infinify");return b.assertValidity(),b}hasHighS(){return this.s>n>>tf}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return k(this.toDERHex())}toDERHex(){return tl.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return k(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}function p(t){let e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===o:r?n===2*i||n===2*o:t instanceof a}let g=e.bits2int||function(t){let r=L(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},y=e.bits2int_modN||function(t){return s(g(t))},w=P(e.nBitLength);function b(t){if("bigint"!=typeof t)throw Error("bigint expected");if(!(tu<=t&&t<w))throw Error(`bigint expected < 2^${e.nBitLength}`);return R(t,e.nByteLength)}let E={lowS:e.lowS,prehash:!1},m={lowS:e.lowS,prehash:!1};return a.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return a.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(p(t))throw Error("first arg must be private key");if(!p(e))throw Error("second arg must be public key");return a.fromHex(e).multiply(l(t)).toRawBytes(r)},sign:function(t,i,o=E){let{seed:u,k2sig:h}=function(t,i,o=E){if(["recovered","canonical"].some(t=>t in o))throw Error("sign() legacy options not supported");let{hash:u,randomBytes:h}=e,{lowS:c,prehash:p,extraEntropy:w}=o;null==c&&(c=!0),t=N("msgHash",t),p&&(t=N("prehashed msgHash",u(t)));let m=y(t),v=l(i),A=[b(v),b(m)];if(null!=w){let t=!0===w?h(r.BYTES):w;A.push(N("extraEntropy",t))}return{seed:_(...A),k2sig:function(t){let e=g(t);if(!f(e))return;let r=G(e,n),i=a.BASE.multiply(e).toAffine(),o=s(i.x);if(o===tu)return;let l=s(r*s(m+o*v));if(l===tu)return;let u=(i.x===o?0:2)|Number(i.y&tf),h=l;if(c&&l>n>>tf)h=l>n>>tf?s(-l):l,u^=1;return new d(o,h,u)}}}(t,i,o);return C(e.hash.outputLen,e.nByteLength,e.hmac)(u,h)},verify:function(t,r,i,o=m){let l,u;if(r=N("msgHash",r),i=N("publicKey",i),"strict"in o)throw Error("options.strict was renamed to lowS");let{lowS:f,prehash:h}=o;try{if("string"==typeof t||t instanceof Uint8Array)try{u=d.fromDER(t)}catch(e){if(!(e instanceof tl.Err))throw e;u=d.fromCompact(t)}else if("object"==typeof t&&"bigint"==typeof t.r&&"bigint"==typeof t.s){let{r:e,s:r}=t;u=new d(e,r)}else throw Error("PARSE");l=a.fromHex(i)}catch(t){if("PARSE"===t.message)throw Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(f&&u.hasHighS())return!1;h&&(r=e.hash(r));let{r:c,s:p}=u,g=y(r),w=G(p,n),b=s(g*w),E=s(c*w),v=a.BASE.multiplyAndAddUnsafe(l,b,E)?.toAffine();return!!v&&s(v.x)===c},ProjectivePoint:a,Signature:d,utils:{isValidPrivateKey(t){try{return l(t),!0}catch(t){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let t=tt(e.n);return function(t,e,r=!1){let n=t.length,i=X(e),o=tt(e);if(n<16||n<o||n>1024)throw Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=K(r?L(t):O(t),e-z)+z;return r?$(s,i):R(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=a.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)}}})({...t,hash:e,hmac:(t,...r)=>tr(e,t,function(...t){let e=new Uint8Array(t.reduce((t,e)=>t+e.length,0)),r=0;return t.forEach(t=>{if(!l(t))throw Error("Uint8Array expected");e.set(t,r),r+=t.length}),e}(...r)),randomBytes:d});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:tb,n:td,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-tp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),n=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=BigInt("0x100000000000000000000000000000000"),o=ty(e*t,td),s=ty(-r*t,td),a=K(t-o*e-s*n,td),l=K(-o*r-s*e,td),u=a>i,f=l>i;if(u&&(a=td-a),f&&(l=td-l),a>i||l>i)throw Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:a,k2neg:f,k2:l}}}},v),tm=BigInt(0),tv=t=>"bigint"==typeof t&&tm<t&&t<tc,tA=t=>"bigint"==typeof t&&tm<t&&t<td,tx={};function tI(t,...e){let r=tx[t];if(void 0===r){let e=v(Uint8Array.from(t,t=>t.charCodeAt(0)));r=_(e,e),tx[t]=r}return v(_(r,...e))}let tU=t=>t.toRawBytes(!0).slice(1),tS=t=>R(t,32),tB=t=>K(t,tc),tk=t=>K(t,td),tL=tE.ProjectivePoint,tO=(t,e,r)=>tL.BASE.multiplyAndAddUnsafe(t,e,r);function tR(t){let e=tE.utils.normPrivateKeyToScalar(t),r=tL.fromPrivateKey(e);return{scalar:r.hasEvenY()?e:tk(-e),bytes:tU(r)}}function t$(t){if(!tv(t))throw Error("bad x: need 0 < x < p");let e=tB(t*t),r=tw(tB(e*t+BigInt(7)));r%tg!==tm&&(r=tB(-r));let n=new tL(t,r,tp);return n.assertValidity(),n}function tN(...t){return tk(L(tI("BIP0340/challenge",...t)))}function t_(t,e,r){let n=N("signature",t,64),i=N("message",e),o=N("publicKey",r,32);try{let t=t$(L(o)),e=L(n.subarray(0,32));if(!tv(e))return!1;let r=L(n.subarray(32,64));if(!tA(r))return!1;let s=tN(tS(e),tU(t),i),a=tO(t,r,tk(-s));if(!a||!a.hasEvenY()||a.toAffine().x!==e)return!1;return!0}catch(t){return!1}}let tP={getPublicKey:function(t){return tR(t).bytes},sign:function(t,e,r=d(32)){let n=N("message",t),{bytes:i,scalar:o}=tR(e),s=tS(o^L(tI("BIP0340/aux",N("auxRand",r,32)))),a=tk(L(tI("BIP0340/nonce",s,i,n)));if(a===tm)throw Error("sign failed: k is zero");let{bytes:l,scalar:u}=tR(a),f=tN(l,i,n),h=new Uint8Array(64);if(h.set(l,0),h.set(tS(tk(u+f*o)),32),!t_(h,n,i))throw Error("sign: Invalid signature produced");return h},verify:t_,utils:{randomPrivateKey:tE.utils.randomPrivateKey,lift_x:t$,pointToBytes:tU,numberToBytesBE:R,bytesToNumberBE:L,taggedHash:tI,mod:K}}},1522:function(t,e,r){function n(t){if(!Number.isSafeInteger(t)||t<0)throw Error(`Wrong positive integer: ${t}`)}function i(t,...e){if(!(t instanceof Uint8Array))throw Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}e.ZP={number:n,bool:function(t){if("boolean"!=typeof t)throw Error(`Expected boolean, not ${t}`)},bytes:i,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw Error("Hash should be wrapped by utils.wrapConstructor");n(t.outputLen),n(t.blockLen)},exists:function(t,e=!0){if(t.destroyed)throw Error("Hash instance has been destroyed");if(e&&t.finished)throw Error("Hash#digest() has already been called")},output:function(t,e){i(t);let r=e.outputLen;if(t.length<r)throw Error(`digestInto() expects output buffer of length at least ${r}`)}}},9273:function(t,e,r){r.d(e,{J:function(){return d}});var n=r(1522),i=r(6744);class o extends i.kb{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.GL)(this.buffer)}update(t){n.ZP.exists(this);let{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.O0)(t)).length;for(let n=0;n<s;){let a=Math.min(o-this.pos,s-n);if(a===o){let e=(0,i.GL)(t);for(;o<=s-n;n+=o)this.process(e,n);continue}r.set(t.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){n.ZP.exists(this),n.ZP.output(t,this),this.finished=!0;let{buffer:e,view:r,blockLen:o,isLE:s}=this,{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let t=a;t<o;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),l=n?4:0,u=n?0:4;t.setUint32(e+l,s,n),t.setUint32(e+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);let l=(0,i.GL)(t),u=this.outputLen;if(u%4)throw Error("_sha2: outputLen should be aligned to 32bit");let f=u/4,h=this.get();if(f>h.length)throw Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)l.setUint32(4*t,h[t],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}let s=(t,e,r)=>t&e^~t&r,a=(t,e,r)=>t&e^t&r^e&r,l=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),u=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),f=new Uint32Array(64);class h extends o{constructor(){super(64,32,8,!1),this.A=0|u[0],this.B=0|u[1],this.C=0|u[2],this.D=0|u[3],this.E=0|u[4],this.F=0|u[5],this.G=0|u[6],this.H=0|u[7]}get(){let{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)f[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){let e=f[t-15],r=f[t-2],n=(0,i.np)(e,7)^(0,i.np)(e,18)^e>>>3,o=(0,i.np)(r,17)^(0,i.np)(r,19)^r>>>10;f[t]=o+f[t-7]+n+f[t-16]|0}let{A:r,B:n,C:o,D:u,E:h,F:c,G:d,H:p}=this;for(let t=0;t<64;t++){let e=p+((0,i.np)(h,6)^(0,i.np)(h,11)^(0,i.np)(h,25))+s(h,c,d)+l[t]+f[t]|0,g=((0,i.np)(r,2)^(0,i.np)(r,13)^(0,i.np)(r,22))+a(r,n,o)|0;p=d,d=c,c=h,h=u+e|0,u=o,o=n,n=r,r=e+g|0}r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,u=u+this.D|0,h=h+this.E|0,c=c+this.F|0,d=d+this.G|0,p=p+this.H|0,this.set(r,n,o,u,h,c,d,p)}roundClean(){f.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class c extends h{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}let d=(0,i.hE)(()=>new h);(0,i.hE)(()=>new c)},6744:function(t,e,r){r.d(e,{kb:function(){return c},ci:function(){return l},eV:function(){return h},GL:function(){return o},nr:function(){return u},O6:function(){return p},np:function(){return s},O0:function(){return f},hE:function(){return d}});let n="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,i=t=>t instanceof Uint8Array,o=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),s=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw Error("Non little-endian hardware is not supported");let a=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function l(t){if(!i(t))throw Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=a[t[r]];return e}function u(t){if("string"!=typeof t)throw Error("hex string expected, got "+typeof t);let e=t.length;if(e%2)throw Error("padded hex string expected, got unpadded hex of length "+e);let r=new Uint8Array(e/2);for(let e=0;e<r.length;e++){let n=2*e,i=Number.parseInt(t.slice(n,n+2),16);if(Number.isNaN(i)||i<0)throw Error("Invalid byte sequence");r[e]=i}return r}function f(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}(t)),!i(t))throw Error(`expected Uint8Array, got ${typeof t}`);return t}function h(...t){let e=new Uint8Array(t.reduce((t,e)=>t+e.length,0)),r=0;return t.forEach(t=>{if(!i(t))throw Error("Uint8Array expected");e.set(t,r),r+=t.length}),e}class c{clone(){return this._cloneInto()}}function d(t){let e=e=>t().update(f(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function p(t=32){if(n&&"function"==typeof n.getRandomValues)return n.getRandomValues(new Uint8Array(t));throw Error("crypto.getRandomValues must be defined")}},5380:function(t,e,r){r.d(e,{ZD:function(){return rI},_W:function(){return t2},cV:function(){return t0},$3:function(){return t1},ex:function(){return rd},_J:function(){return rM},uD:function(){return rU},cy:function(){return nx}});var n,i,o,s,a,l,u=r(241),f=r(6744),h=r(9273);function c(t){if(!Number.isSafeInteger(t))throw Error(`Wrong integer: ${t}`)}function d(...t){let e=(t,e)=>r=>t(e(r));return{encode:Array.from(t).reverse().reduce((t,r)=>t?e(t,r.encode):r.encode,void 0),decode:t.reduce((t,r)=>t?e(t,r.decode):r.decode,void 0)}}function p(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw Error("alphabet.encode input should be an array of numbers");return e.map(e=>{if(c(e),e<0||e>=t.length)throw Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]})},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw Error("alphabet.decode input should be array of strings");return e.map(e=>{if("string"!=typeof e)throw Error(`alphabet.decode: not string element=${e}`);let r=t.indexOf(e);if(-1===r)throw Error(`Unknown letter: "${e}". Allowed: ${t}`);return r})}}}function g(t=""){if("string"!=typeof t)throw Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw Error("join.decode input should be string");return e.split(t)}}}function y(t,e="="){if(c(t),"string"!=typeof e)throw Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function w(t){if("function"!=typeof t)throw Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function b(t,e,r){if(e<2)throw Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(r<2)throw Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(t))throw Error("convertRadix: data should be array");if(!t.length)return[];let n=0,i=[],o=Array.from(t);for(o.forEach(t=>{if(c(t),t<0||t>=e)throw Error(`Wrong integer: ${t}`)});;){let t=0,s=!0;for(let i=n;i<o.length;i++){let a=o[i],l=e*t+a;if(!Number.isSafeInteger(l)||e*t/e!==t||l-a!=e*t||(t=l%r,o[i]=Math.floor(l/r),!Number.isSafeInteger(o[i])||o[i]*r+t!==l))throw Error("convertRadix: carry overflow");s&&(o[i]?s=!1:n=i)}if(i.push(t),s)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}let E=(t,e)=>e?E(e,t%e):t,m=(t,e)=>t+(e-E(t,e));function v(t,e,r,n){if(!Array.isArray(t))throw Error("convertRadix2: data should be array");if(e<=0||e>32)throw Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw Error(`convertRadix2: wrong to=${r}`);if(m(e,r)>32)throw Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${m(e,r)}`);let i=0,o=0,s=2**r-1,a=[];for(let n of t){if(c(n),n>=2**e)throw Error(`convertRadix2: invalid data word=${n} from=${e}`);if(i=i<<e|n,o+e>32)throw Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=r;o-=r)a.push((i>>o-r&s)>>>0);i&=2**o-1}if(i=i<<r-o&s,!n&&o>=e)throw Error("Excess padding");if(!n&&i)throw Error(`Non-zero padding: ${i}`);return n&&o>0&&a.push(i>>>0),a}function A(t,e=!1){if(c(t),t<=0||t>32)throw Error("radix2: bits should be in (0..32]");if(m(8,t)>32||m(t,8)>32)throw Error("radix2: carry overflow");return{encode:r=>{if(!(r instanceof Uint8Array))throw Error("radix2.encode input should be Uint8Array");return v(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw Error("radix2.decode input should be array of strings");return Uint8Array.from(v(r,t,8,e))}}}function x(t){if("function"!=typeof t)throw Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(t){}}}d(A(4),p("0123456789ABCDEF"),g("")),d(A(5),p("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),y(5),g("")),d(A(5),p("0123456789ABCDEFGHIJKLMNOPQRSTUV"),y(5),g("")),d(A(5),p("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),g(""),w(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));let I=d(A(6),p("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),y(6),g("")),U=(d(A(6),p("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),y(6),g("")),t=>d((c(58),{encode:t=>{if(!(t instanceof Uint8Array))throw Error("radix.encode input should be Uint8Array");return b(Array.from(t),256,58)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw Error("radix.decode input should be array of strings");return Uint8Array.from(b(t,58,256))}}),p(t),g("")));U("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),U("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),U("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");let S=d(p("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),g("")),B=[996825010,642813549,513874426,1027748829,705979059];function k(t){let e=t>>25,r=(33554431&t)<<5;for(let t=0;t<B.length;t++)(e>>t&1)==1&&(r^=B[t]);return r}function L(t,e,r=1){let n=t.length,i=1;for(let e=0;e<n;e++){let r=t.charCodeAt(e);if(r<33||r>126)throw Error(`Invalid prefix (${t})`);i=k(i)^r>>5}i=k(i);for(let e=0;e<n;e++)i=k(i)^31&t.charCodeAt(e);for(let t of e)i=k(i)^t;for(let t=0;t<6;t++)i=k(i);return i^=r,S.encode(v([i%1073741824],30,5,!1))}function O(t){let e="bech32"===t?1:734539939,r=A(5),n=r.decode,i=r.encode,o=x(n);function s(t,r=90){if("string"!=typeof t)throw Error(`bech32.decode input should be string, not ${typeof t}`);if(t.length<8||!1!==r&&t.length>r)throw TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);let n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw Error("String must be lowercase or uppercase");let i=(t=n).lastIndexOf("1");if(0===i||-1===i)throw Error('Letter "1" must be present between prefix and data only');let o=t.slice(0,i),s=t.slice(i+1);if(s.length<6)throw Error("Data must be at least 6 characters long");let a=S.decode(s).slice(0,-6),l=L(o,a,e);if(!s.endsWith(l))throw Error(`Invalid checksum in ${t}: expected "${l}"`);return{prefix:o,words:a}}let a=x(s);return{encode:function(t,r,n=90){if("string"!=typeof t)throw Error(`bech32.encode prefix should be string, not ${typeof t}`);if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw Error(`bech32.encode words should be array of numbers, not ${typeof r}`);let i=t.length+7+r.length;if(!1!==n&&i>n)throw TypeError(`Length ${i} exceeds limit ${n}`);return t=t.toLowerCase(),`${t}1${S.encode(r)}${L(t,r,e)}`},decode:s,decodeToBytes:function(t){let{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:a,fromWords:n,fromWordsUnsafe:o,toWords:i}}let R=O("bech32");function $(t){if(!Number.isSafeInteger(t)||t<0)throw Error(`positive integer expected, not ${t}`)}function N(t){if("boolean"!=typeof t)throw Error(`boolean expected, not ${t}`)}function _(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function P(t,...e){if(!_(t))throw Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function T(t,e=!0){if(t.destroyed)throw Error("Hash instance has been destroyed");if(e&&t.finished)throw Error("Hash#digest() has already been called")}function H(t,e){P(t);let r=e.outputLen;if(t.length<r)throw Error(`digestInto() expects output buffer of length at least ${r}`)}O("bech32m"),d(A(4),p("0123456789abcdef"),g(""),w(t=>{if("string"!=typeof t||t.length%2)throw TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));let C=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),q=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw Error("Non little-endian hardware is not supported");function M(t){if("string"==typeof t)t=function(t){if("string"!=typeof t)throw Error(`string expected, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}(t);else if(_(t))t=t.slice();else throw Error(`Uint8Array expected, got ${typeof t}`);return t}function V(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r}function z(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),l=n?4:0,u=n?0:4;t.setUint32(e+l,s,n),t.setUint32(e+u,a,n)}let D=new Uint8Array(16),j=C(D),Z=(t,e,r,n)=>({s3:r<<31|n>>>1,s2:e<<31|r>>>1,s1:t<<31|e>>>1,s0:t>>>1^-520093696&-(1&n&1)}),F=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0,W=t=>t>65536?8:t>1024?4:2;class K{constructor(t,e){this.blockLen=16,this.outputLen=16,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,P(t=M(t),16);let r=q(t),n=r.getUint32(0,!1),i=r.getUint32(4,!1),o=r.getUint32(8,!1),s=r.getUint32(12,!1),a=[];for(let t=0;t<128;t++)a.push({s0:F(n),s1:F(i),s2:F(o),s3:F(s)}),{s0:n,s1:i,s2:o,s3:s}=Z(n,i,o,s);let l=W(e||1024);if(![1,2,4,8].includes(l))throw Error(`ghash: wrong window size=${l}, should be 2, 4 or 8`);this.W=l;let u=128/l,f=this.windowSize=2**l,h=[];for(let t=0;t<u;t++)for(let e=0;e<f;e++){let r=0,n=0,i=0,o=0;for(let s=0;s<l;s++){if(!(e>>>l-s-1&1))continue;let{s0:u,s1:f,s2:h,s3:c}=a[l*t+s];r^=u,n^=f,i^=h,o^=c}h.push({s0:r,s1:n,s2:i,s3:o})}this.t=h}_updateBlock(t,e,r,n){t^=this.s0,e^=this.s1,r^=this.s2,n^=this.s3;let{W:i,t:o,windowSize:s}=this,a=0,l=0,u=0,f=0,h=(1<<i)-1,c=0;for(let d of[t,e,r,n])for(let t=0;t<4;t++){let e=d>>>8*t&255;for(let t=8/i-1;t>=0;t--){let{s0:r,s1:n,s2:d,s3:p}=o[c*s+(e>>>i*t&h)];a^=r,l^=n,u^=d,f^=p,c+=1}}this.s0=a,this.s1=l,this.s2=u,this.s3=f}update(t){t=M(t),T(this);let e=C(t),r=Math.floor(t.length/16),n=t.length%16;for(let t=0;t<r;t++)this._updateBlock(e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]);return n&&(D.set(t.subarray(16*r)),this._updateBlock(j[0],j[1],j[2],j[3]),j.fill(0)),this}destroy(){let{t}=this;for(let e of t)e.s0=0,e.s1=0,e.s2=0,e.s3=0}digestInto(t){T(this),H(t,this),this.finished=!0;let{s0:e,s1:r,s2:n,s3:i}=this,o=C(t);return o[0]=e,o[1]=r,o[2]=n,o[3]=i,t}digest(){let t=new Uint8Array(16);return this.digestInto(t),this.destroy(),t}}class J extends K{constructor(t,e){let r=function(t){t.reverse();let e=1&t[15],r=0;for(let e=0;e<t.length;e++){let n=t[e];t[e]=n>>>1|r,r=(1&n)<<7}return t[0]^=225&-e,t}((t=M(t)).slice());super(r,e),r.fill(0)}update(t){t=M(t),T(this);let e=C(t),r=t.length%16,n=Math.floor(t.length/16);for(let t=0;t<n;t++)this._updateBlock(F(e[4*t+3]),F(e[4*t+2]),F(e[4*t+1]),F(e[4*t+0]));return r&&(D.set(t.subarray(16*n)),this._updateBlock(F(j[3]),F(j[2]),F(j[1]),F(j[0])),j.fill(0)),this}digestInto(t){T(this),H(t,this),this.finished=!0;let{s0:e,s1:r,s2:n,s3:i}=this,o=C(t);return o[0]=e,o[1]=r,o[2]=n,o[3]=i,t.reverse()}}function G(t){let e=(e,r)=>t(r,e.length).update(M(e)).digest(),r=t(new Uint8Array(16),0);return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=(e,r)=>t(e,r),e}function Y(t){return t<<1^283&-(t>>7)}function Q(t,e){let r=0;for(;e>0;e>>=1)r^=t&-(1&e),t=Y(t);return r}G((t,e)=>new K(t,e)),G((t,e)=>new J(t,e)),new Uint8Array(16);let X=(()=>{let t=new Uint8Array(256);for(let e=0,r=1;e<256;e++,r^=Y(r))t[e]=r;let e=new Uint8Array(256);e[0]=99;for(let r=0;r<255;r++){let n=t[255-r];n|=n<<8,e[t[r]]=(n^n>>4^n>>5^n>>6^n>>7^99)&255}return e})(),tt=X.map((t,e)=>X.indexOf(e)),te=t=>t<<24|t>>>8,tr=t=>t<<8|t>>>24;function tn(t,e){if(256!==t.length)throw Error("Wrong sbox length");let r=new Uint32Array(256).map((r,n)=>e(t[n])),n=r.map(tr),i=n.map(tr),o=i.map(tr),s=new Uint32Array(65536),a=new Uint32Array(65536),l=new Uint16Array(65536);for(let e=0;e<256;e++)for(let u=0;u<256;u++){let f=256*e+u;s[f]=r[e]^n[u],a[f]=i[e]^o[u],l[f]=t[e]<<8|t[u]}return{sbox:t,sbox2:l,T0:r,T1:n,T2:i,T3:o,T01:s,T23:a}}let ti=tn(X,t=>Q(t,3)<<24|t<<16|t<<8|Q(t,2)),to=tn(tt,t=>Q(t,11)<<24|Q(t,13)<<16|Q(t,9)<<8|Q(t,14)),ts=(()=>{let t=new Uint8Array(16);for(let e=0,r=1;e<16;e++,r=Y(r))t[e]=r;return t})();function ta(t){P(t);let e=t.length;if(![16,24,32].includes(e))throw Error(`aes: wrong key size: should be 16, 24 or 32, got: ${e}`);let{sbox2:r}=ti,n=C(t),i=n.length,o=t=>tu(r,t,t,t,t),s=new Uint32Array(e+28);s.set(n);for(let t=i;t<s.length;t++){let e=s[t-1];t%i==0?e=o(te(e))^ts[t/i-1]:i>6&&t%i==4&&(e=o(e)),s[t]=s[t-i]^e}return s}function tl(t,e,r,n,i,o){return t[r<<8&65280|n>>>8&255]^e[i>>>8&65280|o>>>24&255]}function tu(t,e,r,n,i){return t[255&e|65280&r]|t[n>>>16&255|i>>>16&65280]<<16}function tf(t,e,r,n,i){let{sbox2:o,T01:s,T23:a}=ti,l=0;e^=t[l++],r^=t[l++],n^=t[l++],i^=t[l++];let u=t.length/4-2;for(let o=0;o<u;o++){let o=t[l++]^tl(s,a,e,r,n,i),u=t[l++]^tl(s,a,r,n,i,e),f=t[l++]^tl(s,a,n,i,e,r),h=t[l++]^tl(s,a,i,e,r,n);e=o,r=u,n=f,i=h}let f=t[l++]^tu(o,e,r,n,i);return{s0:f,s1:t[l++]^tu(o,r,n,i,e),s2:t[l++]^tu(o,n,i,e,r),s3:t[l++]^tu(o,i,e,r,n)}}function th(t,e){if(!e)return new Uint8Array(t);if(P(e),e.length<t)throw Error(`aes: wrong destination length, expected at least ${t}, got: ${e.length}`);return e}let tc=(n={blockSize:16,nonceLength:16},Object.assign(i=function(t,e,r={}){P(t),P(e,16);let n=!r.disablePadding;return{encrypt:(r,i)=>{let o=ta(t),{b:s,o:a,out:l}=function(t,e,r){let n=t.length,i=n%16;if(!e&&0!==i)throw Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");let o=C(t);if(e){let t=16-i;t||(t=16),n+=t}let s=th(n,r);return{b:o,o:C(s),out:s}}(r,n,i),u=C(e),f=u[0],h=u[1],c=u[2],d=u[3],p=0;for(;p+4<=s.length;)f^=s[p+0],h^=s[p+1],c^=s[p+2],d^=s[p+3],({s0:f,s1:h,s2:c,s3:d}=tf(o,f,h,c,d)),a[p++]=f,a[p++]=h,a[p++]=c,a[p++]=d;if(n){let t=function(t){let e=new Uint8Array(16),r=C(e);e.set(t);let n=16-t.length;for(let t=16-n;t<16;t++)e[t]=n;return r}(r.subarray(4*p));f^=t[0],h^=t[1],c^=t[2],d^=t[3],({s0:f,s1:h,s2:c,s3:d}=tf(o,f,h,c,d)),a[p++]=f,a[p++]=h,a[p++]=c,a[p++]=d}return o.fill(0),l},decrypt:(r,i)=>{!function(t){if(P(t),t.length%16!=0)throw Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}(r);let o=function(t){let e=ta(t),r=e.slice(),n=e.length,{sbox2:i}=ti,{T0:o,T1:s,T2:a,T3:l}=to;for(let t=0;t<n;t+=4)for(let i=0;i<4;i++)r[t+i]=e[n-t-4+i];e.fill(0);for(let t=4;t<n-4;t++){let e=r[t],n=tu(i,e,e,e,e);r[t]=o[255&n]^s[n>>>8&255]^a[n>>>16&255]^l[n>>>24]}return r}(t),s=C(e),a=th(r.length,i),l=C(r),u=C(a),f=s[0],h=s[1],c=s[2],d=s[3];for(let t=0;t+4<=l.length;){let e=f,r=h,n=c,i=d;f=l[t+0];let{s0:s,s1:a,s2:p,s3:g}=function(t,e,r,n,i){let{sbox2:o,T01:s,T23:a}=to,l=0;e^=t[l++],r^=t[l++],n^=t[l++],i^=t[l++];let u=t.length/4-2;for(let o=0;o<u;o++){let o=t[l++]^tl(s,a,e,i,n,r),u=t[l++]^tl(s,a,r,e,i,n),f=t[l++]^tl(s,a,n,r,e,i),h=t[l++]^tl(s,a,i,n,r,e);e=o,r=u,n=f,i=h}let f=t[l++]^tu(o,e,i,n,r);return{s0:f,s1:t[l++]^tu(o,r,e,i,n),s2:t[l++]^tu(o,n,r,e,i),s3:t[l++]^tu(o,i,n,r,e)}}(o,f,h=l[t+1],c=l[t+2],d=l[t+3]);u[t++]=s^e,u[t++]=a^r,u[t++]=p^n,u[t++]=g^i}return o.fill(0),function(t,e){if(!e)return t;let r=t.length;if(!r)throw Error("aes/pcks5: empty ciphertext not allowed");let n=t[r-1];if(n<=0||n>16)throw Error(`aes/pcks5: wrong padding byte: ${n}`);let i=t.subarray(0,-n);for(let e=0;e<n;e++)if(t[r-e-1]!==n)throw Error("aes/pcks5: wrong padding");return i}(a,n)}}},n),i),td=(t,e)=>255&t[e++]|(255&t[e++])<<8;class tp{constructor(t){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,P(t=M(t),32);let e=td(t,0),r=td(t,2),n=td(t,4),i=td(t,6),o=td(t,8),s=td(t,10),a=td(t,12),l=td(t,14);this.r[0]=8191&e,this.r[1]=(e>>>13|r<<3)&8191,this.r[2]=(r>>>10|n<<6)&7939,this.r[3]=(n>>>7|i<<9)&8191,this.r[4]=(i>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|s<<2)&8191,this.r[7]=(s>>>11|a<<5)&8065,this.r[8]=(a>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let e=0;e<8;e++)this.pad[e]=td(t,16+2*e)}process(t,e,r=!1){let{h:n,r:i}=this,o=i[0],s=i[1],a=i[2],l=i[3],u=i[4],f=i[5],h=i[6],c=i[7],d=i[8],p=i[9],g=td(t,e+0),y=td(t,e+2),w=td(t,e+4),b=td(t,e+6),E=td(t,e+8),m=td(t,e+10),v=td(t,e+12),A=td(t,e+14),x=n[0]+(8191&g),I=n[1]+((g>>>13|y<<3)&8191),U=n[2]+((y>>>10|w<<6)&8191),S=n[3]+((w>>>7|b<<9)&8191),B=n[4]+((b>>>4|E<<12)&8191),k=n[5]+(E>>>1&8191),L=n[6]+((E>>>14|m<<2)&8191),O=n[7]+((m>>>11|v<<5)&8191),R=n[8]+((v>>>8|A<<8)&8191),$=n[9]+(A>>>5|(r?0:2048)),N=0,_=0+x*o+5*p*I+5*d*U+5*c*S+5*h*B;N=_>>>13,_&=8191,_+=5*f*k+5*u*L+5*l*O+5*a*R+5*s*$,N+=_>>>13,_&=8191;let P=N+x*s+I*o+5*p*U+5*d*S+5*c*B;N=P>>>13,P&=8191,P+=5*h*k+5*f*L+5*u*O+5*l*R+5*a*$,N+=P>>>13,P&=8191;let T=N+x*a+I*s+U*o+5*p*S+5*d*B;N=T>>>13,T&=8191,T+=5*c*k+5*h*L+5*f*O+5*u*R+5*l*$,N+=T>>>13,T&=8191;let H=N+x*l+I*a+U*s+S*o+5*p*B;N=H>>>13,H&=8191,H+=5*d*k+5*c*L+5*h*O+5*f*R+5*u*$,N+=H>>>13,H&=8191;let C=N+x*u+I*l+U*a+S*s+B*o;N=C>>>13,C&=8191,C+=5*p*k+5*d*L+5*c*O+5*h*R+5*f*$,N+=C>>>13,C&=8191;let q=N+x*f+I*u+U*l+S*a+B*s;N=q>>>13,q&=8191,q+=k*o+5*p*L+5*d*O+5*c*R+5*h*$,N+=q>>>13,q&=8191;let M=N+x*h+I*f+U*u+S*l+B*a;N=M>>>13,M&=8191,M+=k*s+L*o+5*p*O+5*d*R+5*c*$,N+=M>>>13,M&=8191;let V=N+x*c+I*h+U*f+S*u+B*l;N=V>>>13,V&=8191,V+=k*a+L*s+O*o+5*p*R+5*d*$,N+=V>>>13,V&=8191;let z=N+x*d+I*c+U*h+S*f+B*u;N=z>>>13,z&=8191,z+=k*l+L*a+O*s+R*o+5*p*$,N+=z>>>13,z&=8191;let D=N+x*p+I*d+U*c+S*h+B*f;N=D>>>13,D&=8191,D+=k*u+L*l+O*a+R*s+$*o,N+=D>>>13,D&=8191,_=8191&(N=(N=(N<<2)+N|0)+_|0),N>>>=13,P+=N,n[0]=_,n[1]=P,n[2]=T,n[3]=H,n[4]=C,n[5]=q,n[6]=M,n[7]=V,n[8]=z,n[9]=D}finalize(){let{h:t,pad:e}=this,r=new Uint16Array(10),n=t[1]>>>13;t[1]&=8191;for(let e=2;e<10;e++)t[e]+=n,n=t[e]>>>13,t[e]&=8191;t[0]+=5*n,n=t[0]>>>13,t[0]&=8191,t[1]+=n,n=t[1]>>>13,t[1]&=8191,t[2]+=n,r[0]=t[0]+5,n=r[0]>>>13,r[0]&=8191;for(let e=1;e<10;e++)r[e]=t[e]+n,n=r[e]>>>13,r[e]&=8191;r[9]-=8192;let i=(1^n)-1;for(let t=0;t<10;t++)r[t]&=i;i=~i;for(let e=0;e<10;e++)t[e]=t[e]&i|r[e];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let o=t[0]+e[0];t[0]=65535&o;for(let r=1;r<8;r++)o=(t[r]+e[r]|0)+(o>>>16)|0,t[r]=65535&o}update(t){T(this);let{buffer:e,blockLen:r}=this,n=(t=M(t)).length;for(let i=0;i<n;){let o=Math.min(r-this.pos,n-i);if(o===r){for(;r<=n-i;i+=r)this.process(t,i);continue}e.set(t.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===r&&(this.process(e,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(t){T(this),H(t,this),this.finished=!0;let{buffer:e,h:r}=this,{pos:n}=this;if(n){for(e[n++]=1;n<16;n++)e[n]=0;this.process(e,0,!0)}this.finalize();let i=0;for(let e=0;e<8;e++)t[i++]=r[e]>>>0,t[i++]=r[e]>>>8;return t}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let r=t.slice(0,e);return this.destroy(),r}}let tg=function(t){let e=(e,r)=>t(r).update(M(e)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e}(t=>new tp(t)),ty=t=>Uint8Array.from(t.split("").map(t=>t.charCodeAt(0))),tw=ty("expand 16-byte k"),tb=ty("expand 32-byte k"),tE=C(tw),tm=C(tb);function tv(t,e){return t<<e|t>>>32-e}function tA(t){return t.byteOffset%4==0}tm.slice();let tx=4294967296-1,tI=new Uint32Array;function tU(t,e){let{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=function(t,e){if(null==e||"object"!=typeof e)throw Error("options must be defined");return Object.assign(t,e)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if("function"!=typeof t)throw Error("core must be a function");return $(i),$(s),N(o),N(r),(e,a,l,u,f=0)=>{P(e),P(a),P(l);let h=l.length;if(u||(u=new Uint8Array(h)),P(u),$(f),f<0||f>=tx)throw Error("arx: counter overflow");if(u.length<h)throw Error(`arx: output (${u.length}) is shorter than data (${h})`);let c=[],d=e.length,p,g;if(32===d)p=e.slice(),c.push(p),g=tm;else if(16===d&&r)(p=new Uint8Array(32)).set(e),p.set(e,16),g=tE,c.push(p);else throw Error(`arx: invalid 32-byte key, got length=${d}`);tA(a)||(a=a.slice(),c.push(a));let y=C(p);if(n){if(24!==a.length)throw Error("arx: extended nonce must be 24 bytes");n(g,y,C(a.subarray(0,16)),y),a=a.subarray(16)}let w=16-i;if(w!==a.length)throw Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){let t=new Uint8Array(12);t.set(a,o?0:12-a.length),a=t,c.push(a)}for(function(t,e,r,n,i,o,s,a){let l=i.length,u=new Uint8Array(64),f=C(u),h=tA(i)&&tA(o),c=h?C(i):tI,d=h?C(o):tI;for(let p=0;p<l;s++){if(t(e,r,n,f,s,a),s>=tx)throw Error("arx: counter overflow");let g=Math.min(64,l-p);if(h&&64===g){let t=p/4;if(p%4!=0)throw Error("arx: invalid block position");for(let e=0,r;e<16;e++)d[r=t+e]=c[r]^f[e];p+=64;continue}for(let t=0,e;t<g;t++)o[e=p+t]=i[e]^u[t];p+=g}}(t,g,y,C(a),l,u,f,s);c.length>0;)c.pop().fill(0);return u}}function tS(t,e,r,n,i,o=20){let s=t[0],a=t[1],l=t[2],u=t[3],f=e[0],h=e[1],c=e[2],d=e[3],p=e[4],g=e[5],y=e[6],w=e[7],b=r[0],E=r[1],m=r[2],v=s,A=a,x=l,I=u,U=f,S=h,B=c,k=d,L=p,O=g,R=y,$=w,N=i,_=b,P=E,T=m;for(let t=0;t<o;t+=2)L=L+(N=tv(N^(v=v+U|0),16))|0,v=v+(U=tv(U^L,12))|0,L=L+(N=tv(N^v,8))|0,U=tv(U^L,7),O=O+(_=tv(_^(A=A+S|0),16))|0,A=A+(S=tv(S^O,12))|0,O=O+(_=tv(_^A,8))|0,S=tv(S^O,7),R=R+(P=tv(P^(x=x+B|0),16))|0,x=x+(B=tv(B^R,12))|0,R=R+(P=tv(P^x,8))|0,B=tv(B^R,7),$=$+(T=tv(T^(I=I+k|0),16))|0,I=I+(k=tv(k^$,12))|0,$=$+(T=tv(T^I,8))|0,k=tv(k^$,7),R=R+(T=tv(T^(v=v+S|0),16))|0,v=v+(S=tv(S^R,12))|0,R=R+(T=tv(T^v,8))|0,S=tv(S^R,7),$=$+(N=tv(N^(A=A+B|0),16))|0,A=A+(B=tv(B^$,12))|0,$=$+(N=tv(N^A,8))|0,B=tv(B^$,7),L=L+(_=tv(_^(x=x+k|0),16))|0,x=x+(k=tv(k^L,12))|0,L=L+(_=tv(_^x,8))|0,k=tv(k^L,7),O=O+(P=tv(P^(I=I+U|0),16))|0,I=I+(U=tv(U^O,12))|0,O=O+(P=tv(P^I,8))|0,U=tv(U^O,7);let H=0;n[H++]=s+v|0,n[H++]=a+A|0,n[H++]=l+x|0,n[H++]=u+I|0,n[H++]=f+U|0,n[H++]=h+S|0,n[H++]=c+B|0,n[H++]=d+k|0,n[H++]=p+L|0,n[H++]=g+O|0,n[H++]=y+R|0,n[H++]=w+$|0,n[H++]=i+N|0,n[H++]=b+_|0,n[H++]=E+P|0,n[H++]=m+T|0}let tB=tU(tS,{counterRight:!1,counterLength:4,allowShortKeys:!1}),tk=tU(tS,{counterRight:!1,counterLength:8,extendNonceFn:function(t,e,r,n){let i=t[0],o=t[1],s=t[2],a=t[3],l=e[0],u=e[1],f=e[2],h=e[3],c=e[4],d=e[5],p=e[6],g=e[7],y=r[0],w=r[1],b=r[2],E=r[3];for(let t=0;t<20;t+=2)c=c+(y=tv(y^(i=i+l|0),16))|0,i=i+(l=tv(l^c,12))|0,c=c+(y=tv(y^i,8))|0,l=tv(l^c,7),d=d+(w=tv(w^(o=o+u|0),16))|0,o=o+(u=tv(u^d,12))|0,d=d+(w=tv(w^o,8))|0,u=tv(u^d,7),p=p+(b=tv(b^(s=s+f|0),16))|0,s=s+(f=tv(f^p,12))|0,p=p+(b=tv(b^s,8))|0,f=tv(f^p,7),g=g+(E=tv(E^(a=a+h|0),16))|0,a=a+(h=tv(h^g,12))|0,g=g+(E=tv(E^a,8))|0,h=tv(h^g,7),p=p+(E=tv(E^(i=i+u|0),16))|0,i=i+(u=tv(u^p,12))|0,p=p+(E=tv(E^i,8))|0,u=tv(u^p,7),g=g+(y=tv(y^(o=o+f|0),16))|0,o=o+(f=tv(f^g,12))|0,g=g+(y=tv(y^o,8))|0,f=tv(f^g,7),c=c+(w=tv(w^(s=s+h|0),16))|0,s=s+(h=tv(h^c,12))|0,c=c+(w=tv(w^s,8))|0,h=tv(h^c,7),d=d+(b=tv(b^(a=a+l|0),16))|0,a=a+(l=tv(l^d,12))|0,d=d+(b=tv(b^a,8))|0,l=tv(l^d,7);let m=0;n[m++]=i,n[m++]=o,n[m++]=s,n[m++]=a,n[m++]=y,n[m++]=w,n[m++]=b,n[m++]=E},allowShortKeys:!1}),tL=new Uint8Array(16),tO=(t,e)=>{t.update(e);let r=e.length%16;r&&t.update(tL.subarray(r))},tR=new Uint8Array(32);function t$(t,e,r,n,i){let o=t(e,r,tR),s=tg.create(o);i&&tO(s,i),tO(s,n);let a=new Uint8Array(16),l=q(a);z(l,0,BigInt(i?i.length:0),!0),z(l,8,BigInt(n.length),!0),s.update(a);let u=s.digest();return o.fill(0),u}let tN=t=>(e,r,n)=>(P(e,32),P(r),{encrypt:(i,o)=>{let s=i.length,a=s+16;o?P(o,a):o=new Uint8Array(a),t(e,r,i,o,1);let l=t$(t,e,r,o.subarray(0,-16),n);return o.set(l,s),o},decrypt:(i,o)=>{let s=i.length,a=s-16;if(s<16)throw Error("encrypted data must be at least 16 bytes");o?P(o,a):o=new Uint8Array(a);let l=i.subarray(0,-16);if(!V(i.subarray(-16),t$(t,e,r,l,n)))throw Error("invalid tag");return t(e,r,l,o,1),o}});tN(tB),tN(tk);var t_=r(1522);class tP extends f.kb{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,t_.ZP.hash(t);let r=(0,f.O0)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return t_.ZP.exists(this),this.iHash.update(t),this}digestInto(t){t_.ZP.exists(this),t_.ZP.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let tT=(t,e,r)=>new tP(t,e).update(r).digest();tT.create=(t,e)=>new tP(t,e);let tH=new Uint8Array([0]),tC=new Uint8Array;var tq=Object.defineProperty,tM=(t,e)=>{for(var r in e)tq(t,r,{get:e[r],enumerable:!0})},tV=Symbol("verified"),tz=t=>t instanceof Object;function tD(t){if(!tz(t)||"number"!=typeof t.kind||"string"!=typeof t.content||"number"!=typeof t.created_at||"string"!=typeof t.pubkey||!t.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(t.tags))return!1;for(let e=0;e<t.tags.length;e++){let r=t.tags[e];if(!Array.isArray(r))return!1;for(let t=0;t<r.length;t++)if("object"==typeof r[t])return!1}return!0}tM({},{Queue:()=>tY,QueueNode:()=>tG,binarySearch:()=>tJ,insertEventIntoAscendingList:()=>tK,insertEventIntoDescendingList:()=>tW,normalizeURL:()=>tF,utf8Decoder:()=>tj,utf8Encoder:()=>tZ});var tj=new TextDecoder("utf-8"),tZ=new TextEncoder;function tF(t){-1===t.indexOf("://")&&(t="wss://"+t);let e=new URL(t);return e.pathname=e.pathname.replace(/\/+/g,"/"),e.pathname.endsWith("/")&&(e.pathname=e.pathname.slice(0,-1)),("80"===e.port&&"ws:"===e.protocol||"443"===e.port&&"wss:"===e.protocol)&&(e.port=""),e.searchParams.sort(),e.hash="",e.toString()}function tW(t,e){let[r,n]=tJ(t,t=>e.id===t.id?0:e.created_at===t.created_at?-1:t.created_at-e.created_at);return n||t.splice(r,0,e),t}function tK(t,e){let[r,n]=tJ(t,t=>e.id===t.id?0:e.created_at===t.created_at?-1:e.created_at-t.created_at);return n||t.splice(r,0,e),t}function tJ(t,e){let r=0,n=t.length-1;for(;r<=n;){let i=Math.floor((r+n)/2),o=e(t[i]);if(0===o)return[i,!0];o<0?n=i-1:r=i+1}return[r,!1]}var tG=class{value;next=null;prev=null;constructor(t){this.value=t}},tY=class{first;last;constructor(){this.first=null,this.last=null}enqueue(t){let e=new tG(t);return this.last?this.last===this.first?(this.last=e,this.last.prev=this.first,this.first.next=e):(e.prev=this.last,this.last.next=e,this.last=e):(this.first=e,this.last=e),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){let t=this.first;return this.first=null,this.last=null,t.value}let t=this.first;return this.first=t.next,t.value}};function tQ(t){let e=(0,h.J)(tZ.encode(function(t){if(!tD(t))throw Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content])}(t)));return(0,f.ci)(e)}var tX=new class{generateSecretKey(){return u.xW.utils.randomPrivateKey()}getPublicKey(t){return(0,f.ci)(u.xW.getPublicKey(t))}finalizeEvent(t,e){return t.pubkey=(0,f.ci)(u.xW.getPublicKey(e)),t.id=tQ(t),t.sig=(0,f.ci)(u.xW.sign(tQ(t),e)),t[tV]=!0,t}verifyEvent(t){if("boolean"==typeof t[tV])return t[tV];let e=tQ(t);if(e!==t.id)return t[tV]=!1,!1;try{let r=u.xW.verify(t.sig,e,t.pubkey);return t[tV]=r,r}catch(e){return t[tV]=!1,!1}}},t0=tX.generateSecretKey,t1=tX.getPublicKey,t2=tX.finalizeEvent,t3=tX.verifyEvent;function t8(t){return 1e3<=t&&t<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(t)}function t5(t){return[0,3].includes(t)||1e4<=t&&t<2e4}function t4(t){return 2e4<=t&&t<3e4}function t6(t){return 3e4<=t&&t<4e4}function t9(t){return t8(t)?"regular":t5(t)?"replaceable":t4(t)?"ephemeral":t6(t)?"parameterized":"unknown"}function t7(t,e){return tD(t)&&(e instanceof Array?e:[e]).includes(t.kind)||!1}tM({},{Application:()=>re,BadgeAward:()=>el,BadgeDefinition:()=>e8,BlockedRelaysList:()=>eq,BookmarkList:()=>eT,Bookmarksets:()=>e1,Calendar:()=>rl,CalendarEventRSVP:()=>ru,ChannelCreation:()=>ec,ChannelHideMessage:()=>eg,ChannelMessage:()=>ep,ChannelMetadata:()=>ed,ChannelMuteUser:()=>ey,ClassifiedListing:()=>ri,ClientAuth:()=>eW,CommunitiesList:()=>eH,CommunityDefinition:()=>rc,CommunityPostApproval:()=>eU,Contacts:()=>en,CreateOrUpdateProduct:()=>e6,CreateOrUpdateStall:()=>e4,Curationsets:()=>e2,Date:()=>rs,DirectMessageRelaysList:()=>eD,DraftClassifiedListing:()=>ro,DraftLong:()=>e7,Emojisets:()=>rt,EncryptedDirectMessage:()=>ei,EventDeletion:()=>eo,FileMetadata:()=>eE,FileServerPreference:()=>ej,Followsets:()=>eQ,GenericRepost:()=>eh,Genericlists:()=>eX,GiftWrap:()=>eb,HTTPAuth:()=>eY,Handlerinformation:()=>rh,Handlerrecommendation:()=>rf,Highlights:()=>e$,InterestsList:()=>eV,Interestsets:()=>e5,JobFeedback:()=>ek,JobRequest:()=>eS,JobResult:()=>eB,Label:()=>eI,LightningPubRPC:()=>eF,LiveChatMessage:()=>em,LiveEvent:()=>rr,LongFormArticle:()=>e9,Metadata:()=>et,Mutelist:()=>eN,NWCWalletInfo:()=>eZ,NWCWalletRequest:()=>eK,NWCWalletResponse:()=>eJ,NostrConnect:()=>eG,OpenTimestamps:()=>ew,Pinlist:()=>e_,PrivateDirectMessage:()=>ef,ProblemTracker:()=>ev,ProfileBadges:()=>e3,PublicChatsList:()=>eC,Reaction:()=>ea,RecommendRelay:()=>er,RelayList:()=>eP,Relaysets:()=>e0,Report:()=>eA,Reporting:()=>ex,Repost:()=>es,Seal:()=>eu,SearchRelaysList:()=>eM,ShortTextNote:()=>ee,Time:()=>ra,UserEmojiList:()=>ez,UserStatuses:()=>rn,Zap:()=>eR,ZapGoal:()=>eL,ZapRequest:()=>eO,classifyKind:()=>t9,isEphemeralKind:()=>t4,isKind:()=>t7,isParameterizedReplaceableKind:()=>t6,isRegularKind:()=>t8,isReplaceableKind:()=>t5});var et=0,ee=1,er=2,en=3,ei=4,eo=5,es=6,ea=7,el=8,eu=13,ef=14,eh=16,ec=40,ed=41,ep=42,eg=43,ey=44,ew=1040,eb=1059,eE=1063,em=1311,ev=1971,eA=1984,ex=1984,eI=1985,eU=4550,eS=5999,eB=6999,ek=7e3,eL=9041,eO=9734,eR=9735,e$=9802,eN=1e4,e_=10001,eP=10002,eT=10003,eH=10004,eC=10005,eq=10006,eM=10007,eV=10015,ez=10030,eD=10050,ej=10096,eZ=13194,eF=21e3,eW=22242,eK=23194,eJ=23195,eG=24133,eY=27235,eQ=3e4,eX=30001,e0=30002,e1=30003,e2=30004,e3=30008,e8=30009,e5=30015,e4=30017,e6=30018,e9=30023,e7=30024,rt=30030,re=30078,rr=30311,rn=30315,ri=30402,ro=30403,rs=31922,ra=31923,rl=31924,ru=31925,rf=31989,rh=31990,rc=34550;function rd(t,e){if(t.ids&&-1===t.ids.indexOf(e.id)||t.kinds&&-1===t.kinds.indexOf(e.kind)||t.authors&&-1===t.authors.indexOf(e.pubkey))return!1;for(let r in t)if("#"===r[0]){let n=r.slice(1),i=t[`#${n}`];if(i&&!e.tags.find(([t,e])=>t===r.slice(1)&&-1!==i.indexOf(e)))return!1}return(!t.since||!(e.created_at<t.since))&&(!t.until||!(e.created_at>t.until))}function rp(t,e){let r=e.length+3,n=t.indexOf(`"${e}":`)+r,i=t.slice(n).indexOf('"')+n+1;return t.slice(i,i+64)}function rg(t,e){let r=e.length,n=t.indexOf(`"${e}":`)+r+3,i=t.slice(n),o=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,o),10)}function ry(t){let e=t.slice(0,22).indexOf('"EVENT"');if(-1===e)return null;let r=t.slice(e+7+1).indexOf('"');if(-1===r)return null;let n=e+7+1+r,i=t.slice(n+1,80).indexOf('"');return -1===i?null:t.slice(n+1,n+1+i)}function rw(t,e){return e===rp(t,"id")}function rb(t,e){return e===rp(t,"pubkey")}function rE(t,e){return e===rg(t,"kind")}function rm(t,e){return{kind:eW,created_at:Math.floor(Date.now()/1e3),tags:[["relay",t],["challenge",e]],content:""}}async function rv(){return new Promise(t=>{let e=new MessageChannel,r=()=>{e.port1.removeEventListener("message",r),t()};e.port1.addEventListener("message",r),e.port2.postMessage(0),e.port1.start()})}tM({},{getHex64:()=>rp,getInt:()=>rg,getSubscriptionId:()=>ry,matchEventId:()=>rw,matchEventKind:()=>rE,matchEventPubkey:()=>rb}),tM({},{makeAuthEvent:()=>rm});var rA=class{url;_connected=!1;onclose=null;onnotice=t=>console.debug(`NOTICE from ${this.url}: ${t}`);_onauth=null;baseEoseTimeout=4400;connectionTimeout=4400;openSubs=new Map;connectionTimeoutHandle;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new tY;queueRunning=!1;challenge;serial=0;verifyEvent;_WebSocket;constructor(t,e){this.url=tF(t),this.verifyEvent=e.verifyEvent,this._WebSocket=e.websocketImplementation||WebSocket}static async connect(t,e){let r=new rA(t,e);return await r.connect(),r}closeAllSubscriptions(t){for(let[e,r]of this.openSubs)r.close(t);for(let[e,r]of(this.openSubs.clear(),this.openEventPublishes))r.reject(Error(t));for(let[e,r]of(this.openEventPublishes.clear(),this.openCountRequests))r.reject(Error(t));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise||(this.challenge=void 0,this.connectionPromise=new Promise((t,e)=>{this.connectionTimeoutHandle=setTimeout(()=>{e("connection timed out"),this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new this._WebSocket(this.url)}catch(t){e(t);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,t()},this.ws.onerror=t=>{e(t.message||"websocket error"),this._connected&&(this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection errored"))},this.ws.onclose=async()=>{this._connected&&(this._connected=!1,this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection closed"))},this.ws.onmessage=this._onmessage.bind(this)})),this.connectionPromise}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await rv();this.queueRunning=!1}handleNext(){let t=this.incomingMessageQueue.dequeue();if(!t)return!1;let e=ry(t);if(e){let r=this.openSubs.get(e);if(!r)return;let n=rp(t,"id"),i=r.alreadyHaveEvent?.(n);if(r.receivedEvent?.(this,n),i)return}try{let e=JSON.parse(t);switch(e[0]){case"EVENT":{let t=this.openSubs.get(e[1]),r=e[2];this.verifyEvent(r)&&function(t,e){for(let r=0;r<t.length;r++)if(rd(t[r],e))return!0;return!1}(t.filters,r)&&t.onevent(r);return}case"COUNT":{let t=e[1],r=e[2],n=this.openCountRequests.get(t);n&&(n.resolve(r.count),this.openCountRequests.delete(t));return}case"EOSE":{let t=this.openSubs.get(e[1]);if(!t)return;t.receivedEose();return}case"OK":{let t=e[1],r=e[2],n=e[3],i=this.openEventPublishes.get(t);r?i.resolve(n):i.reject(Error(n)),this.openEventPublishes.delete(t);return}case"CLOSED":{let t=e[1],r=this.openSubs.get(t);if(!r)return;r.closed=!0,r.close(e[2]);return}case"NOTICE":this.onnotice(e[1]);return;case"AUTH":this.challenge=e[1],this._onauth?.(e[1]);return}}catch(t){return}}async send(t){if(!this.connectionPromise)throw Error("sending on closed connection");this.connectionPromise.then(()=>{this.ws?.send(t)})}async auth(t){if(!this.challenge)throw Error("can't perform auth, no challenge was received");let e=await t(rm(this.url,this.challenge)),r=new Promise((t,r)=>{this.openEventPublishes.set(e.id,{resolve:t,reject:r})});return this.send('["AUTH",'+JSON.stringify(e)+"]"),r}async publish(t){let e=new Promise((e,r)=>{this.openEventPublishes.set(t.id,{resolve:e,reject:r})});return this.send('["EVENT",'+JSON.stringify(t)+"]"),e}async count(t,e){this.serial++;let r=e?.id||"count:"+this.serial,n=new Promise((t,e)=>{this.openCountRequests.set(r,{resolve:t,reject:e})});return this.send('["COUNT","'+r+'",'+JSON.stringify(t).substring(1)),n}subscribe(t,e){let r=this.prepareSubscription(t,e);return r.fire(),r}prepareSubscription(t,e){this.serial++;let r=e.id||"sub:"+this.serial,n=new rx(this,r,t,e);return this.openSubs.set(r,n),n}close(){this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.ws?.close()}_onmessage(t){this.incomingMessageQueue.enqueue(t.data),this.queueRunning||this.runQueue()}},rx=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(t,e,r,n){this.relay=t,this.filters=r,this.id=e,this.alreadyHaveEvent=n.alreadyHaveEvent,this.receivedEvent=n.receivedEvent,this.eoseTimeout=n.eoseTimeout||t.baseEoseTimeout,this.oneose=n.oneose,this.onclose=n.onclose,this.onevent=n.onevent||(t=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,t)})}fire(){this.relay.send('["REQ","'+this.id+'",'+JSON.stringify(this.filters).substring(1)),this.eoseTimeoutHandle=setTimeout(this.receivedEose.bind(this),this.eoseTimeout)}receivedEose(){this.eosed||(clearTimeout(this.eoseTimeoutHandle),this.eosed=!0,this.oneose?.())}close(t="closed by caller"){!this.closed&&this.relay.connected&&(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id),this.onclose?.(t)}};try{o=WebSocket}catch{}var rI=class extends rA{constructor(t){super(t,{verifyEvent:t3,websocketImplementation:o})}static async connect(t){let e=new rI(t);return await e.connect(),e}};try{WebSocket}catch{}var rU={};tM(rU,{BECH32_REGEX:()=>rk,Bech32MaxSize:()=>rB,NostrTypeGuard:()=>rS,decode:()=>rL,encodeBytes:()=>rP,naddrEncode:()=>rC,neventEncode:()=>rH,noteEncode:()=>rN,nprofileEncode:()=>rT,npubEncode:()=>r$,nsecEncode:()=>rR});var rS={isNProfile:t=>/^nprofile1[a-z\d]+$/.test(t||""),isNEvent:t=>/^nevent1[a-z\d]+$/.test(t||""),isNAddr:t=>/^naddr1[a-z\d]+$/.test(t||""),isNSec:t=>/^nsec1[a-z\d]{58}$/.test(t||""),isNPub:t=>/^npub1[a-z\d]{58}$/.test(t||""),isNote:t=>/^note1[a-z\d]+$/.test(t||""),isNcryptsec:t=>/^ncryptsec1[a-z\d]+$/.test(t||"")},rB=5e3,rk=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function rL(t){let{prefix:e,words:r}=R.decode(t,rB),n=new Uint8Array(R.fromWords(r));switch(e){case"nprofile":{let t=rO(n);if(!t[0]?.[0])throw Error("missing TLV 0 for nprofile");if(32!==t[0][0].length)throw Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:(0,f.ci)(t[0][0]),relays:t[1]?t[1].map(t=>tj.decode(t)):[]}}}case"nevent":{let t=rO(n);if(!t[0]?.[0])throw Error("missing TLV 0 for nevent");if(32!==t[0][0].length)throw Error("TLV 0 should be 32 bytes");if(t[2]&&32!==t[2][0].length)throw Error("TLV 2 should be 32 bytes");if(t[3]&&4!==t[3][0].length)throw Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:(0,f.ci)(t[0][0]),relays:t[1]?t[1].map(t=>tj.decode(t)):[],author:t[2]?.[0]?(0,f.ci)(t[2][0]):void 0,kind:t[3]?.[0]?parseInt((0,f.ci)(t[3][0]),16):void 0}}}case"naddr":{let t=rO(n);if(!t[0]?.[0])throw Error("missing TLV 0 for naddr");if(!t[2]?.[0])throw Error("missing TLV 2 for naddr");if(32!==t[2][0].length)throw Error("TLV 2 should be 32 bytes");if(!t[3]?.[0])throw Error("missing TLV 3 for naddr");if(4!==t[3][0].length)throw Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:tj.decode(t[0][0]),pubkey:(0,f.ci)(t[2][0]),kind:parseInt((0,f.ci)(t[3][0]),16),relays:t[1]?t[1].map(t=>tj.decode(t)):[]}}}case"nsec":return{type:e,data:n};case"npub":case"note":return{type:e,data:(0,f.ci)(n)};default:throw Error(`unknown prefix ${e}`)}}function rO(t){let e={},r=t;for(;r.length>0;){let t=r[0],n=r[1],i=r.slice(2,2+n);if(r=r.slice(2+n),i.length<n)throw Error(`not enough data to read on TLV ${t}`);e[t]=e[t]||[],e[t].push(i)}return e}function rR(t){return r_("nsec",t)}function r$(t){return r_("npub",(0,f.nr)(t))}function rN(t){return r_("note",(0,f.nr)(t))}function r_(t,e){let r=R.toWords(e);return R.encode(t,r,rB)}function rP(t,e){return r_(t,e)}function rT(t){return r_("nprofile",rq({0:[(0,f.nr)(t.pubkey)],1:(t.relays||[]).map(t=>tZ.encode(t))}))}function rH(t){let e;return void 0!==t.kind&&(e=function(t){let e=new Uint8Array(4);return e[0]=t>>24&255,e[1]=t>>16&255,e[2]=t>>8&255,e[3]=255&t,e}(t.kind)),r_("nevent",rq({0:[(0,f.nr)(t.id)],1:(t.relays||[]).map(t=>tZ.encode(t)),2:t.author?[(0,f.nr)(t.author)]:[],3:e?[new Uint8Array(e)]:[]}))}function rC(t){let e=new ArrayBuffer(4);return new DataView(e).setUint32(0,t.kind,!1),r_("naddr",rq({0:[tZ.encode(t.identifier)],1:(t.relays||[]).map(t=>tZ.encode(t)),2:[(0,f.nr)(t.pubkey)],3:[new Uint8Array(e)]}))}function rq(t){let e=[];return Object.entries(t).reverse().forEach(([t,r])=>{r.forEach(r=>{let n=new Uint8Array(r.length+2);n.set([parseInt(t)],0),n.set([r.length],1),n.set(r,2),e.push(n)})}),(0,f.eV)(...e)}var rM={};async function rV(t,e,r){let n=t instanceof Uint8Array?(0,f.ci)(t):t,i=rD(u.kA.getSharedSecret(n,"02"+e)),o=Uint8Array.from((0,f.O6)(16)),s=tZ.encode(r),a=tc(i,o).encrypt(s),l=I.encode(new Uint8Array(a)),h=I.encode(new Uint8Array(o.buffer));return`${l}?iv=${h}`}async function rz(t,e,r){let n=t instanceof Uint8Array?(0,f.ci)(t):t,[i,o]=r.split("?iv="),s=rD(u.kA.getSharedSecret(n,"02"+e)),a=I.decode(o),l=I.decode(i),h=tc(s,a).decrypt(l);return tj.decode(h)}function rD(t){return t.slice(1,33)}tM(rM,{decrypt:()=>rz,encrypt:()=>rV}),tM({},{NIP05_REGEX:()=>rj,isNip05:()=>rZ,isValid:()=>rJ,queryProfile:()=>rK,searchDomain:()=>rW,useFetchImplementation:()=>rF});var rj=/^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/,rZ=t=>rj.test(t||"");try{s=fetch}catch{}function rF(t){s=t}async function rW(t,e=""){try{let r=`https://${t}/.well-known/nostr.json?name=${e}`,n=await s(r,{redirect:"error"});return(await n.json()).names}catch(t){return{}}}async function rK(t){let e=t.match(rj);if(!e)return null;let[r,n="_",i]=e;try{let t=`https://${i}/.well-known/nostr.json?name=${n}`,e=await (await s(t,{redirect:"error"})).json(),r=e.names[n];return r?{pubkey:r,relays:e.relays?.[r]}:null}catch(t){return null}}async function rJ(t,e){let r=await rK(e);return!!r&&r.pubkey===t}function rG(t){let e={reply:void 0,root:void 0,mentions:[],profiles:[]},r=[];for(let n of t.tags)"e"===n[0]&&n[1]&&r.push(n),"p"===n[0]&&n[1]&&e.profiles.push({pubkey:n[1],relays:n[2]?[n[2]]:[]});for(let t=0;t<r.length;t++){let[n,i,o,s]=r[t],a={id:i,relays:o?[o]:[]},l=0===t,u=t===r.length-1;if("root"===s){e.root=a;continue}if("reply"===s){e.reply=a;continue}if("mention"===s){e.mentions.push(a);continue}if(l){e.root=a;continue}if(u){e.reply=a;continue}e.mentions.push(a)}return e}tM({},{parse:()=>rG}),tM({},{fetchRelayInformation:()=>rQ,useFetchImplementation:()=>rY});try{fetch}catch{}function rY(t){}async function rQ(t){return await (await fetch(t.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function rX(t){let e=0;for(let r=0;r<64;r+=8){let n=parseInt(t.substring(r,r+8),16);if(0===n)e+=32;else{e+=Math.clz32(n);break}}return e}function r0(t,e){let r=0,n=["nonce","0",e.toString()];for(t.tags.push(n);;){let i=Math.floor(new Date().getTime()/1e3);if(i!==t.created_at&&(r=0,t.created_at=i),n[1]=(++r).toString(),t.id=r1(t),rX(t.id)>=e)break}return t}function r1(t){return(0,f.ci)((0,h.J)(tZ.encode(JSON.stringify([0,t.pubkey,t.created_at,t.kind,t.tags,t.content]))))}function r2(t,e,r,n){return t2({kind:es,tags:[...t.tags??[],["e",e.id,r],["p",e.pubkey]],content:""===t.content?"":JSON.stringify(e),created_at:t.created_at},n)}function r3(t){let e,r;if(t.kind===es){for(let n=t.tags.length-1;n>=0&&(void 0===e||void 0===r);n--){let i=t.tags[n];i.length>=2&&("e"===i[0]&&void 0===e?e=i:"p"===i[0]&&void 0===r&&(r=i))}if(void 0!==e)return{id:e[1],relays:[e[2],r?.[2]].filter(t=>"string"==typeof t),author:r?.[1]}}}function r8(t,{skipVerification:e}={}){let r;let n=r3(t);if(void 0!==n&&""!==t.content){try{r=JSON.parse(t.content)}catch(t){return}if(r.id===n.id&&(e||t3(r)))return r}}tM({},{fastEventHash:()=>r1,getPow:()=>rX,minePow:()=>r0}),tM({},{finishRepostEvent:()=>r2,getRepostedEvent:()=>r8,getRepostedEventPointer:()=>r3}),tM({},{NOSTR_URI_REGEX:()=>r5,parse:()=>r6,test:()=>r4});var r5=RegExp(`nostr:(${rk.source})`);function r4(t){return"string"==typeof t&&RegExp(`^${r5.source}$`).test(t)}function r6(t){let e=t.match(RegExp(`^${r5.source}$`));if(!e)throw Error(`Invalid Nostr URI: ${t}`);return{uri:e[0],value:e[1],decoded:rL(e[1])}}function r9(t,e,r){let n=e.tags.filter(t=>t.length>=2&&("e"===t[0]||"p"===t[0]));return t2({...t,kind:ea,tags:[...t.tags??[],...n,["e",e.id],["p",e.pubkey]],content:t.content??"+"},r)}function r7(t){let e,r;if(t.kind===ea){for(let n=t.tags.length-1;n>=0&&(void 0===e||void 0===r);n--){let i=t.tags[n];i.length>=2&&("e"===i[0]&&void 0===e?e=i:"p"===i[0]&&void 0===r&&(r=i))}if(void 0!==e&&void 0!==r)return{id:e[1],relays:[e[2],r[2]].filter(t=>void 0!==t),author:r[1]}}}tM({},{finishReactionEvent:()=>r9,getReactedEventPointer:()=>r7}),tM({},{matchAll:()=>ne,regex:()=>nt,replaceAll:()=>nr});var nt=()=>RegExp(`\\b${r5.source}\\b`,"g");function*ne(t){for(let e of t.matchAll(nt()))try{let[t,r]=e;yield{uri:t,value:r,decoded:rL(r),start:e.index,end:e.index+t.length}}catch(t){}}function nr(t,e){return t.replaceAll(nt(),(t,r)=>e({uri:t,value:r,decoded:rL(r)}))}tM({},{channelCreateEvent:()=>nn,channelHideMessageEvent:()=>ns,channelMessageEvent:()=>no,channelMetadataEvent:()=>ni,channelMuteUserEvent:()=>na});var nn=(t,e)=>{let r;if("object"==typeof t.content)r=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;r=t.content}return t2({kind:ec,tags:[...t.tags??[]],content:r,created_at:t.created_at},e)},ni=(t,e)=>{let r;if("object"==typeof t.content)r=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;r=t.content}return t2({kind:ed,tags:[["e",t.channel_create_event_id],...t.tags??[]],content:r,created_at:t.created_at},e)},no=(t,e)=>{let r=[["e",t.channel_create_event_id,t.relay_url,"root"]];return t.reply_to_channel_message_event_id&&r.push(["e",t.reply_to_channel_message_event_id,t.relay_url,"reply"]),t2({kind:ep,tags:[...r,...t.tags??[]],content:t.content,created_at:t.created_at},e)},ns=(t,e)=>{let r;if("object"==typeof t.content)r=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;r=t.content}return t2({kind:eg,tags:[["e",t.channel_message_event_id],...t.tags??[]],content:r,created_at:t.created_at},e)},na=(t,e)=>{let r;if("object"==typeof t.content)r=JSON.stringify(t.content);else{if("string"!=typeof t.content)return;r=t.content}return t2({kind:ey,tags:[["p",t.pubkey_to_mute],...t.tags??[]],content:r,created_at:t.created_at},e)};tM({},{EMOJI_SHORTCODE_REGEX:()=>nl,matchAll:()=>nf,regex:()=>nu,replaceAll:()=>nh});var nl=/:(\w+):/,nu=()=>RegExp(`\\B${nl.source}\\B`,"g");function*nf(t){for(let e of t.matchAll(nu()))try{let[t,r]=e;yield{shortcode:t,name:r,start:e.index,end:e.index+t.length}}catch(t){}}function nh(t,e){return t.replaceAll(nu(),(t,r)=>e({shortcode:t,name:r}))}tM({},{useFetchImplementation:()=>nc,validateGithub:()=>nd});try{a=fetch}catch{}function nc(t){a=t}async function nd(t,e,r){try{return await (await a(`https://gist.github.com/${e}/${r}/raw`)).text()===`Verifying that I control the following Nostr public key: ${t}`}catch(t){return!1}}function np(t,e){var r,n;let i=u.kA.getSharedSecret(t,"02"+e).subarray(1,33);return r=h.J,n="nip44-v2",t_.ZP.hash(r),void 0===n&&(n=new Uint8Array(r.outputLen)),tT(r,(0,f.O0)(n),(0,f.O0)(i))}function ng(t,e){let r=function(t,e,r,n=32){if(t_.ZP.hash(t),t_.ZP.number(n),n>255*t.outputLen)throw Error("Length should be <= 255*HashLen");let i=Math.ceil(n/t.outputLen);void 0===r&&(r=tC);let o=new Uint8Array(i*t.outputLen),s=tT.create(t,e),a=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let e=0;e<i;e++)tH[0]=e+1,a.update(0===e?tC:l).update(r).update(tH).digestInto(l),o.set(l,t.outputLen*e),s._cloneInto(a);return s.destroy(),a.destroy(),l.fill(0),tH.fill(0),o.slice(0,n)}(h.J,t,e,76);return{chacha_key:r.subarray(0,32),chacha_nonce:r.subarray(32,44),hmac_key:r.subarray(44,76)}}function ny(t){if(!Number.isSafeInteger(t)||t<1)throw Error("expected positive integer");if(t<=32)return 32;let e=1<<Math.floor(Math.log2(t-1))+1,r=e<=256?32:e/8;return r*(Math.floor((t-1)/r)+1)}function nw(t,e,r){if(32!==r.length)throw Error("AAD associated data must be 32 bytes");let n=(0,f.eV)(r,e);return tT(h.J,t,n)}function nb(t,e,r=(0,f.O6)(32)){let{chacha_key:n,chacha_nonce:i,hmac_key:o}=ng(e,r),s=tB(n,i,function(t){let e=tZ.encode(t),r=e.length,n=function(t){if(!Number.isSafeInteger(t)||t<1||t>65535)throw Error("invalid plaintext size: must be between 1 and 65535 bytes");let e=new Uint8Array(2);return new DataView(e.buffer).setUint16(0,t,!1),e}(r),i=new Uint8Array(ny(r)-r);return(0,f.eV)(n,e,i)}(t)),a=nw(o,s,r);return I.encode((0,f.eV)(new Uint8Array([2]),r,s,a))}function nE(t,e){let{nonce:r,ciphertext:n,mac:i}=function(t){let e;if("string"!=typeof t)throw Error("payload must be a valid string");let r=t.length;if(r<132||r>87472)throw Error("invalid payload length: "+r);if("#"===t[0])throw Error("unknown encryption version");try{e=I.decode(t)}catch(t){throw Error("invalid base64: "+t.message)}let n=e.length;if(n<99||n>65603)throw Error("invalid data length: "+n);let i=e[0];if(2!==i)throw Error("unknown encryption version "+i);return{nonce:e.subarray(1,33),ciphertext:e.subarray(33,-32),mac:e.subarray(-32)}}(t),{chacha_key:o,chacha_nonce:s,hmac_key:a}=ng(e,r);if(!V(nw(a,n,r),i))throw Error("invalid MAC");return function(t){let e=new DataView(t.buffer).getUint16(0),r=t.subarray(2,2+e);if(e<1||e>65535||r.length!==e||t.length!==2+ny(e))throw Error("invalid padding");return tj.decode(r)}(tB(o,s,n))}tM({},{decrypt:()=>nE,encrypt:()=>nb,getConversationKey:()=>np,v2:()=>nm});var nm={utils:{getConversationKey:np,calcPaddedLen:ny},encrypt:nb,decrypt:nE};function nv(t){let{pathname:e,searchParams:r}=new URL(t),n=r.get("relay"),i=r.get("secret");if(!e||!n||!i)throw Error("invalid connection string");return{pubkey:e,relay:n,secret:i}}async function nA(t,e,r){let n=await rV(e,t,JSON.stringify({method:"pay_invoice",params:{invoice:r}}));return t2({kind:eK,created_at:Math.round(Date.now()/1e3),content:n,tags:[["p",t]]},e)}tM({},{makeNwcRequestEvent:()=>nA,parseConnectionString:()=>nv});var nx={};tM(nx,{getZapEndpoint:()=>nU,makeZapReceipt:()=>nk,makeZapRequest:()=>nS,useFetchImplementation:()=>nI,validateZapRequest:()=>nB});try{l=fetch}catch{}function nI(t){l=t}async function nU(t){try{let e="",{lud06:r,lud16:n}=JSON.parse(t.content);if(r){let{words:t}=R.decode(r,1e3),n=R.fromWords(t);e=tj.decode(n)}else{if(!n)return null;let[t,r]=n.split("@");e=new URL(`/.well-known/lnurlp/${t}`,`https://${r}`).toString()}let i=await l(e),o=await i.json();if(o.allowsNostr&&o.nostrPubkey)return o.callback}catch(t){}return null}function nS({profile:t,event:e,amount:r,relays:n,comment:i=""}){if(!r)throw Error("amount not given");if(!t)throw Error("profile not given");let o={kind:9734,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",t],["amount",r.toString()],["relays",...n]]};return e&&o.tags.push(["e",e]),o}function nB(t){let e;try{e=JSON.parse(t)}catch(t){return"Invalid zap request JSON."}if(!tD(e))return"Zap request is not a valid Nostr event.";if(!t3(e))return"Invalid signature on zap request.";let r=e.tags.find(([t,e])=>"p"===t&&e);if(!r)return"Zap request doesn't have a 'p' tag.";if(!r[1].match(/^[a-f0-9]{64}$/))return"Zap request 'p' tag is not valid hex.";let n=e.tags.find(([t,e])=>"e"===t&&e);return n&&!n[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":e.tags.find(([t,e])=>"relays"===t&&e)?null:"Zap request doesn't have a 'relays' tag."}function nk({zapRequest:t,preimage:e,bolt11:r,paidAt:n}){let i=JSON.parse(t),o=i.tags.filter(([t])=>"e"===t||"p"===t||"a"===t),s={kind:9735,created_at:Math.round(n.getTime()/1e3),content:"",tags:[...o,["P",i.pubkey],["bolt11",r],["description",t]]};return e&&s.tags.push(["preimage",e]),s}tM({},{createRumor:()=>n_,createSeal:()=>nP,createWrap:()=>nT,unwrapEvent:()=>nC,wrapEvent:()=>nH});var nL=()=>Math.round(Date.now()/1e3),nO=()=>Math.round(nL()-172800*Math.random()),nR=(t,e)=>np(t,e),n$=(t,e,r)=>nb(JSON.stringify(t),nR(e,r)),nN=(t,e)=>JSON.parse(nE(t.content,nR(e,t.pubkey)));function n_(t,e){let r={created_at:nL(),content:"",tags:[],...t,pubkey:t1(e)};return r.id=tQ(r),r}function nP(t,e,r){return t2({kind:eu,content:n$(t,e,r),created_at:nO(),tags:[]},e)}function nT(t,e){let r=t0();return t2({kind:eb,content:n$(t,r,e),created_at:nO(),tags:[["p",e]]},r)}function nH(t,e,r){return nT(nP(n_(t,e),e,r),r)}function nC(t,e){let r=nN(t,e);return nN(r,e)}tM({},{getToken:()=>nM,hashPayload:()=>nW,unpackEventFromToken:()=>nz,validateEvent:()=>nJ,validateEventKind:()=>nj,validateEventMethodTag:()=>nF,validateEventPayloadTag:()=>nK,validateEventTimestamp:()=>nD,validateEventUrlTag:()=>nZ,validateToken:()=>nV});var nq="Nostr ";async function nM(t,e,r,n=!1,i){let o={kind:eY,tags:[["u",t],["method",e]],created_at:Math.round(new Date().getTime()/1e3),content:""};i&&o.tags.push(["payload",nW(i)]);let s=await r(o);return(n?nq:"")+I.encode(tZ.encode(JSON.stringify(s)))}async function nV(t,e,r){let n=await nz(t).catch(t=>{throw t});return await nJ(n,e,r).catch(t=>{throw t})}async function nz(t){if(!t)throw Error("Missing token");t=t.replace(nq,"");let e=tj.decode(I.decode(t));if(!e||0===e.length||!e.startsWith("{"))throw Error("Invalid token");return JSON.parse(e)}function nD(t){return!!t.created_at&&Math.round(new Date().getTime()/1e3)-t.created_at<60}function nj(t){return t.kind===eY}function nZ(t,e){let r=t.tags.find(t=>"u"===t[0]);return!!r&&r.length>0&&r[1]===e}function nF(t,e){let r=t.tags.find(t=>"method"===t[0]);return!!r&&r.length>0&&r[1].toLowerCase()===e.toLowerCase()}function nW(t){let e=(0,h.J)(tZ.encode(JSON.stringify(t)));return(0,f.ci)(e)}function nK(t,e){let r=t.tags.find(t=>"payload"===t[0]);if(!r)return!1;let n=nW(e);return r.length>0&&r[1]===n}async function nJ(t,e,r,n){if(!t3(t))throw Error("Invalid nostr event, signature invalid");if(!nj(t))throw Error("Invalid nostr event, kind invalid");if(!nD(t))throw Error("Invalid nostr event, created_at timestamp invalid");if(!nZ(t,e))throw Error("Invalid nostr event, url tag invalid");if(!nF(t,r))throw Error("Invalid nostr event, method tag invalid");if(n&&"object"==typeof n&&Object.keys(n).length>0&&!nK(t,n))throw Error("Invalid nostr event, payload tag does not match request body hash");return!0}}}]);