PageSourceSearch

https://damus.io/_next/static/chunks/118-4c32dfdd829d42e4.js

js damus.io collected 2026-10-03 20:14:49 UTC 89,979 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[118],{4297:function(e,t,r){r.d(t,{Z:function(){return createLucideIcon}});var n=r(7294),i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let toKebabCase=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),createLucideIcon=(e,t)=>{let r=(0,n.forwardRef)(({color:r="currentColor",size:o=24,strokeWidth:s=2,absoluteStrokeWidth:a,children:l,...u},c)=>(0,n.createElement)("svg",{ref:c,...i,width:o,height:o,stroke:r,strokeWidth:a?24*Number(s)/Number(o):s,className:`lucide lucide-${toKebabCase(e)}`,...u},[...t.map(([e,t])=>(0,n.createElement)(e,t)),...(Array.isArray(l)?l:[l])||[]]));return r.displayName=`${e}`,r}},3219:function(e,t,r){r.d(t,{Z:function(){return i}});var n=r(4297);let i=(0,n.Z)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},207:function(e,t,r){r.d(t,{Z:function(){return i}});var n=r(4297);let i=(0,n.Z)("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]])},3527:function(e,t,r){function number(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`Wrong positive integer: ${e}`)}function bytes(e,...t){if(!(e instanceof Uint8Array))throw Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}t.ZP={number,bool:function(e){if("boolean"!=typeof e)throw Error(`Expected boolean, not ${e}`)},bytes,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.wrapConstructor");number(e.outputLen),number(e.blockLen)},exists:function(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")},output:function(e,t){bytes(e);let r=t.outputLen;if(e.length<r)throw Error(`digestInto() expects output buffer of length at least ${r}`)}}},9905:function(e,t,r){r.d(t,{b:function(){return hmac}});var n=r(3527),i=r(6409);let HMAC=class HMAC extends i.kb{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,n.ZP.hash(e);let r=(0,i.O0)(t);if(this.iHash=e.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 o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return n.ZP.exists(this),this.iHash.update(e),this}digestInto(e){n.ZP.exists(this),n.ZP.bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=n,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};let hmac=(e,t,r)=>new HMAC(e,t).update(r).digest();hmac.create=(e,t)=>new HMAC(e,t)},1606:function(e,t,r){r.d(t,{J:function(){return l}});var n=r(3527),i=r(6409);let SHA2=class SHA2 extends i.kb{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,i.GL)(this.buffer)}update(e){n.ZP.exists(this);let{view:t,buffer:r,blockLen:o}=this;e=(0,i.O0)(e);let s=e.length;for(let n=0;n<s;){let a=Math.min(o-this.pos,s-n);if(a===o){let t=(0,i.GL)(e);for(;o<=s-n;n+=o)this.process(t,n);continue}r.set(e.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){n.ZP.exists(this),n.ZP.output(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:o,isLE:s}=this,{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let e=a;
1e<o;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,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;e.setUint32(t+l,s,n),e.setUint32(t+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);let l=(0,i.GL)(e),u=this.outputLen;if(u%4)throw Error("_sha2: outputLen should be aligned to 32bit");let c=u/4,d=this.get();if(c>d.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)l.setUint32(4*e,d[e],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.length=n,e.pos=s,e.finished=i,e.destroyed=o,n%t&&e.buffer.set(r),e}};let Chi=(e,t,r)=>e&t^~e&r,Maj=(e,t,r)=>e&t^e&r^t&r,o=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]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);let SHA256=class SHA256 extends SHA2{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){let{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,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(e,t){for(let r=0;r<16;r++,t+=4)a[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=a[e-15],r=a[e-2],n=(0,i.np)(t,7)^(0,i.np)(t,18)^t>>>3,o=(0,i.np)(r,17)^(0,i.np)(r,19)^r>>>10;a[e]=o+a[e-7]+n+a[e-16]|0}let{A:r,B:n,C:s,D:l,E:u,F:c,G:d,H:f}=this;for(let e=0;e<64;e++){let t=(0,i.np)(u,6)^(0,i.np)(u,11)^(0,i.np)(u,25),p=f+t+Chi(u,c,d)+o[e]+a[e]|0,y=(0,i.np)(r,2)^(0,i.np)(r,13)^(0,i.np)(r,22),g=y+Maj(r,n,s)|0;f=d,d=c,c=u,u=l+p|0,l=s,s=n,n=r,r=p+g|0}r=r+this.A|0,n=n+this.B|0,s=s+this.C|0,l=l+this.D|0,u=u+this.E|0,c=c+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(r,n,s,l,u,c,d,f)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};let SHA224=class SHA224 extends SHA256{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 l=(0,i.hE)(()=>new SHA256);(0,i.hE)(()=>new SHA224)},6409:function(e,t,r){r.d(t,{kb:function(){return Hash},ci:function(){return bytesToHex},eV:function(){return concatBytes},GL:function(){return createView},nr:function(){return hexToBytes},O6:function(){return randomBytes},np:function(){return rotr},O0:function(){return toBytes},iY:function(){return utf8ToBytes},hE:function(){return wrapConstructor}});let n="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a=e=>e instanceof Uint8Array,createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr=(e,t)=>e<<32-t|e>>>t,i=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!i)throw Error("Non little-endian hardware is not supported");let o=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bytesToHex(e){if(!u8a(e))throw Error("Uint8Array expected");let t="";for(let r=0;r<e.length;r++)t+=o[e[r]];return t}function hexToBytes(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);let t=e.length;if(t%2)throw Error("padded hex string expected, got unpadded hex of length "+t);let r=new Uint8Array(t/2);for(let t=0;t<r.length;t++){let n=2*t,i=e.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw Error("Invalid byte sequence");r[t]=o}return r}function utf8ToBytes(e){if("string"!=typeof e)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function toBytes(e){if("string"==typeof e&&(e=utf8ToBytes(e)),!u8a(e))throw Error(`expected Uint8Array, got ${typeof e}`);return e}function concatBytes(...e){let t=new Uint8Array(e.reduce((e,t)=>
1e+t.length,0)),r=0;return e.forEach(e=>{if(!u8a(e))throw Error("Uint8Array expected");t.set(e,r),r+=e.length}),t}let Hash=class Hash{clone(){return this._cloneInto()}};function wrapConstructor(e){let hashC=t=>e().update(toBytes(t)).digest(),t=e();return hashC.outputLen=t.outputLen,hashC.blockLen=t.blockLen,hashC.create=()=>e(),hashC}function randomBytes(e=32){if(n&&"function"==typeof n.getRandomValues)return n.getRandomValues(new Uint8Array(e));throw Error("crypto.getRandomValues must be defined")}},3188:function(e,t,r){r.d(t,{ZD:function(){return tL},uD:function(){return tN}});var n,i,o,s={};function number(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`Wrong positive integer: ${e}`)}function bytes(e,...t){if(!(e instanceof Uint8Array))throw Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function exists(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}r.r(s),r.d(s,{dQ:function(){return bitMask},ci:function(){return utils_bytesToHex},bytesToNumberBE:function(){return utils_bytesToNumberBE},ty:function(){return utils_bytesToNumberLE},eV:function(){return utils_concatBytes},n$:function(){return createHmacDrbg},ql:function(){return utils_ensureBytes},hexToBytes:function(){return utils_hexToBytes},tL:function(){return numberToBytesBE},S5:function(){return numberToBytesLE},FF:function(){return validateObject}});let a="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a=e=>e instanceof Uint8Array,utils_createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),rotr=(e,t)=>e<<32-t|e>>>t,l=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!l)throw Error("Non little-endian hardware is not supported");function toBytes(e){if("string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}(e)),!u8a(e))throw Error(`expected Uint8Array, got ${typeof e}`);return e}let Hash=class Hash{clone(){return this._cloneInto()}};function randomBytes(e=32){if(a&&"function"==typeof a.getRandomValues)return a.getRandomValues(new Uint8Array(e));throw Error("crypto.getRandomValues must be defined")}let SHA2=class SHA2 extends Hash{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=utils_createView(this.buffer)}update(e){exists(this);let{view:t,buffer:r,blockLen:n}=this;e=toBytes(e);let i=e.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){let t=utils_createView(e);for(;n<=i-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){exists(this),function(e,t){bytes(e);let r=t.outputLen;if(e.length<r)throw Error(`digestInto() expects output buffer of length at least ${r}`)}(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:n,isLE:i}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let e=o;e<n;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,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;e.setUint32(t+l,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);let s=utils_createView(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)s.setUint32(4*e,u[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.length=n,e.pos=s,e.finished=i,e.destroyed=o,n%t&&e.buffer.set(r),e}};let Chi=(e,t,r)=>e&t^~e&r,Maj=(e,t,r)=>
1e&t^e&r^t&r,u=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]),c=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),d=new Uint32Array(64);let SHA256=class SHA256 extends SHA2{constructor(){super(64,32,8,!1),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3],this.E=0|c[4],this.F=0|c[5],this.G=0|c[6],this.H=0|c[7]}get(){let{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,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(e,t){for(let r=0;r<16;r++,t+=4)d[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=d[e-15],r=d[e-2],n=rotr(t,7)^rotr(t,18)^t>>>3,i=rotr(r,17)^rotr(r,19)^r>>>10;d[e]=i+d[e-7]+n+d[e-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:l,H:c}=this;for(let e=0;e<64;e++){let t=rotr(s,6)^rotr(s,11)^rotr(s,25),f=c+t+Chi(s,a,l)+u[e]+d[e]|0,p=rotr(r,2)^rotr(r,13)^rotr(r,22),y=p+Maj(r,n,i)|0;c=l,l=a,a=s,s=o+f|0,o=i,i=n,n=r,r=f+y|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,c=c+this.H|0,this.set(r,n,i,o,s,a,l,c)}roundClean(){d.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};let f=function(e){let hashC=t=>e().update(toBytes(t)).digest(),t=e();return hashC.outputLen=t.outputLen,hashC.blockLen=t.blockLen,hashC.create=()=>e(),hashC}(()=>new SHA256);BigInt(0);let p=BigInt(1),y=BigInt(2),utils_u8a=e=>e instanceof Uint8Array,g=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function utils_bytesToHex(e){if(!utils_u8a(e))throw Error("Uint8Array expected");let t="";for(let r=0;r<e.length;r++)t+=g[e[r]];return t}function hexToNumber(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function utils_hexToBytes(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);let t=e.length;if(t%2)throw Error("padded hex string expected, got unpadded hex of length "+t);let r=new Uint8Array(t/2);for(let t=0;t<r.length;t++){let n=2*t,i=e.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw Error("Invalid byte sequence");r[t]=o}return r}function utils_bytesToNumberBE(e){return hexToNumber(utils_bytesToHex(e))}function utils_bytesToNumberLE(e){if(!utils_u8a(e))throw Error("Uint8Array expected");return hexToNumber(utils_bytesToHex(Uint8Array.from(e).reverse()))}function numberToBytesBE(e,t){return utils_hexToBytes(e.toString(16).padStart(2*t,"0"))}function numberToBytesLE(e,t){return numberToBytesBE(e,t).reverse()}function utils_ensureBytes(e,t,r){let n;if("string"==typeof t)try{n=utils_hexToBytes(t)}catch(r){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${r}`)}else if(utils_u8a(t))n=Uint8Array.from(t);else throw Error(`${e} must be hex string or Uint8Array`);let i=n.length;if("number"==typeof r&&i!==r)throw Error(`${e} expected ${r} bytes, got ${i}`);return n}function utils_concatBytes(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),r=0;return e.forEach(e=>{if(!utils_u8a(e))throw Error("Uint8Array expected");t.set(e,r),r+=e.length}),t}let bitMask=e=>(y<<BigInt(e-1))-p,u8n=e=>new Uint8Array(e),u8fr=e=>Uint8Array.from(e);function createHmacDrbg(e,t,r){if("number"!=typeof e||e<2)throw Error("hashLen must be a number");if("number"!=typeof t||t<2)throw Error("qByteLen must be a number");if("function"!=typeof r)throw Error("hmacFn must be a function");let n=u8n(e),i=u8n(e),o=0,reset=()=>{n.fill(1),i.fill(0),o=0},h=(...e)=>r(i,n,...e),reseed=(e=u8n())=>{i=h(u8fr([0]),e),n=h(),0!==e.length&&(i=h(u8fr([1]),e),n=h())},gen=()=>
1{if(o++>=1e3)throw Error("drbg: tried 1000 values");let e=0,r=[];for(;e<t;){n=h();let t=n.slice();r.push(t),e+=n.length}return utils_concatBytes(...r)};return(e,t)=>{let r;for(reset(),reseed(e);!(r=t(gen()));)reseed();return reset(),r}}let m={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function validateObject(e,t,r={}){let checkField=(t,r,n)=>{let i=m[r];if("function"!=typeof i)throw Error(`Invalid validator "${r}", expected function`);let o=e[t];if((!n||void 0!==o)&&!i(o,e))throw Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${r}`)};for(let[e,r]of Object.entries(t))checkField(e,r,!1);for(let[e,t]of Object.entries(r))checkField(e,t,!0);return e}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let b=BigInt(0),E=BigInt(1),w=BigInt(2),v=BigInt(3),x=BigInt(4),B=BigInt(5),_=BigInt(8);function modular_mod(e,t){let r=e%t;return r>=b?r:t+r}function pow2(e,t,r){let n=e;for(;t-- >b;)n*=n,n%=r;return n}function invert(e,t){if(e===b||t<=b)throw Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=modular_mod(e,t),n=t,i=b,o=E,s=E,a=b;for(;r!==b;){let e=n/r,t=n%r,l=i-s*e,u=o-a*e;n=r,r=t,i=s,o=a,s=l,a=u}let l=n;if(l!==E)throw Error("invert: does not exist");return modular_mod(i,t)}BigInt(9),BigInt(16);let A=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function nLength(e,t){let r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function getFieldBytesLength(e){if("bigint"!=typeof e)throw Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function getMinHashLength(e){let t=getFieldBytesLength(e);return t+Math.ceil(t/2)}let HMAC=class HMAC extends Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.wrapConstructor");number(e.outputLen),number(e.blockLen)}(e);let r=toBytes(t);if(this.iHash=e.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?e.create().update(r).digest():r);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return exists(this),this.iHash.update(e),this}digestInto(e){exists(this),bytes(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return e.finished=n,e.destroyed=i,e.blockLen=o,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};let hmac=(e,t,r)=>new HMAC(e,t).update(r).digest();hmac.create=(e,t)=>new HMAC(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let S=BigInt(0),T=BigInt(1);function validateBasic(e){return!function(e){let t=A.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});validateObject(e,t)}(e.Fp),validateObject(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}let{bytesToNumberBE:I,hexToBytes:L}=s,N={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){let{Err:t}=N;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");let r=e[1],n=e.subarray(2,r+2);if(!r||n.length!==r)throw new t("Invalid signature integer: wrong length");if(128&n[0])throw new t("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:I(n),l:e.subarray(r+2)}},toSig(e){let{Err:t}=N,r="string"==typeof e?L(e):e;if(!(r instanceof Uint8Array))throw Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new t("Invalid signature tag");if(r[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:i,l:o}=N._parseInt(r.subarray(2)),{d:s,l:a}=N._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(e){let slice=e=>8&Number.parseInt(e[0],16)?"00"+e:e,h=e=>{let t=e.toString(16);return 1&t.length?`0${t}`:t},t=slice(h(e.s)),r=slice(h(e.r)),n=t.length/2,i=r.length/2,o=h(n),s=h(i);return`30${h(i+n+4)}02${s}${r}02${o}${t}`}}
1,P=BigInt(0),R=BigInt(1),k=(BigInt(2),BigInt(3));BigInt(4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let U=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),C=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),O=BigInt(1),H=BigInt(2),divNearest=(e,t)=>(e+t/H)/t;function sqrtMod(e){let t=BigInt(3),r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),l=e*e*e%U,u=l*l*e%U,c=pow2(u,t,U)*u%U,d=pow2(c,t,U)*u%U,f=pow2(d,H,U)*l%U,p=pow2(f,n,U)*f%U,y=pow2(p,i,U)*p%U,g=pow2(y,s,U)*y%U,m=pow2(g,a,U)*g%U,b=pow2(m,s,U)*y%U,E=pow2(b,t,U)*u%U,w=pow2(E,o,U)*p%U,v=pow2(w,r,U)*l%U,x=pow2(v,H,U);if(!$.eql($.sqr(x),e))throw Error("Cannot find square root");return x}let $=function(e,t,r=!1,n={}){if(e<=b)throw Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:i,nByteLength:o}=nLength(e,t);if(o>2048)throw Error("Field lengths over 2048 bytes are not supported");let s=function(e){if(e%x===v){let t=(e+E)/x;return function(e,r){let n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw Error("Cannot find square root");return n}}if(e%_===B){let t=(e-B)/_;return function(e,r){let n=e.mul(r,w),i=e.pow(n,t),o=e.mul(r,i),s=e.mul(e.mul(o,w),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),r))throw Error("Cannot find square root");return a}}return function(e){let t,r,n;let i=(e-E)/w;for(t=e-E,r=0;t%w===b;t/=w,r++);for(n=w;n<e&&function(e,t,r){if(r<=b||t<b)throw Error("Expected power/modulo > 0");if(r===E)return b;let n=E;for(;t>b;)t&E&&(n=n*e%r),e=e*e%r,t>>=E;return n}(n,i,e)!==e-E;n++);if(1===r){let t=(e+E)/x;return function(e,r){let n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw Error("Cannot find square root");return n}}let o=(t+E)/w;return function(e,s){if(e.pow(s,i)===e.neg(e.ONE))throw Error("Cannot find square root");let a=r,l=e.pow(e.mul(e.ONE,n),t),u=e.pow(s,o),c=e.pow(s,t);for(;!e.eql(c,e.ONE);){if(e.eql(c,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(c);t<a&&!e.eql(r,e.ONE);t++)r=e.sqr(r);let r=e.pow(l,E<<BigInt(a-t-1));l=e.sqr(r),u=e.mul(u,r),c=e.mul(c,l),a=t}return u}}(e)}(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:bitMask(i),ZERO:b,ONE:E,create:t=>modular_mod(t,e),isValid:t=>{if("bigint"!=typeof t)throw Error(`Invalid field element: expected bigint, got ${typeof t}`);return b<=t&&t<e},is0:e=>e===b,isOdd:e=>(e&E)===E,neg:t=>modular_mod(-t,e),eql:(e,t)=>e===t,sqr:t=>modular_mod(t*t,e),add:(t,r)=>modular_mod(t+r,e),sub:(t,r)=>modular_mod(t-r,e),mul:(t,r)=>modular_mod(t*r,e),pow:(e,t)=>(function(e,t,r){if(r<b)throw Error("Expected power > 0");if(r===b)return e.ONE;if(r===E)return t;let n=e.ONE,i=t;for(;r>b;)r&E&&(n=e.mul(n,i)),i=e.sqr(i),r>>=E;return n})(a,e,t),div:(t,r)=>modular_mod(t*invert(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert(t,e),sqrt:n.sqrt||(e=>s(a,e)),invertBatch:e=>(function(e,t){let r=Array(t.length),n=t.reduce((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n)),e.ONE),i=e.inv(n);return t.reduceRight((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n)),i),r})(a,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?numberToBytesLE(e,o):numberToBytesBE(e,o),fromBytes:e=>{if(e.length!==o)throw Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return r?utils_bytesToNumberLE(e):utils_bytesToNumberBE(e)}});return Object.freeze(a)}(U,void 0,void 0,{sqrt:sqrtMod}),q=function(e,t){let create=t=>(function(e){let t=function(e){let t=validateBasic(e);return validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:r,n:n}=t,i=r.BYTES+1,o=2*r.BYTES+1;function modN(e){return modular_mod(e,n)}let{ProjectivePoint:s,normPrivateKeyToScalar:a,weierstrassEquation:l,isWithinCurveOrder:u}=function(e){let t=/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function(e){let t=validateBasic(e);validateObject(t,{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}=t;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({...t})}(e),{Fp:r}=t,n=t.toBytes||((e,t,n)=>{let i=t.toAffine();return utils_concatBytes(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=t.fromBytes||(e=>{let t=e.subarray(1),n=r.fromBytes(t.subarray(0,r.BYTES)),i=r.fromBytes(t.subarray(r.BYTES,2*r.BYTES));return{x:n,y:i}});function weierstrassEquation(e){let{a:n,b:i}
1=t,o=r.sqr(e),s=r.mul(o,e);return r.add(r.add(s,r.mul(e,n)),i)}if(!r.eql(r.sqr(t.Gy),weierstrassEquation(t.Gx)))throw Error("bad generator point: equation left != right");function isWithinCurveOrder(e){return"bigint"==typeof e&&P<e&&e<t.n}function assertGE(e){if(!isWithinCurveOrder(e))throw Error("Expected valid bigint: 0 < bigint < curve.n")}function normPrivateKeyToScalar(e){let r;let{allowedPrivateKeyLengths:n,nByteLength:i,wrapPrivateKey:o,n:s}=t;if(n&&"bigint"!=typeof e){if(e instanceof Uint8Array&&(e=utils_bytesToHex(e)),"string"!=typeof e||!n.includes(e.length))throw Error("Invalid key");e=e.padStart(2*i,"0")}try{r="bigint"==typeof e?e:utils_bytesToNumberBE(utils_ensureBytes("private key",e,i))}catch(t){throw Error(`private key must be ${i} bytes, hex or bigint, not ${typeof e}`)}return o&&(r=modular_mod(r,s)),assertGE(r),r}let o=new Map;function assertPrjPoint(e){if(!(e instanceof Point))throw Error("ProjectivePoint expected")}let Point=class Point{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!r.isValid(e))throw Error("x required");if(null==t||!r.isValid(t))throw Error("y required");if(null==n||!r.isValid(n))throw Error("z required")}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error("invalid affine point");if(e instanceof Point)throw Error("projective point not allowed");let is0=e=>r.eql(e,r.ZERO);return is0(t)&&is0(n)?Point.ZERO:new Point(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){let t=r.invertBatch(e.map(e=>e.pz));return e.map((e,r)=>e.toAffine(t[r])).map(Point.fromAffine)}static fromHex(e){let t=Point.fromAffine(i(utils_ensureBytes("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return Point.BASE.multiply(normPrivateKeyToScalar(e))}_setWindowSize(e){this._WINDOW_SIZE=e,o.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!r.is0(this.py))return;throw Error("bad point: ZERO")}let{x:e,y:n}=this.toAffine();if(!r.isValid(e)||!r.isValid(n))throw Error("bad point: x or y not FE");let i=r.sqr(n),o=weierstrassEquation(e);if(!r.eql(i,o))throw Error("bad point: equation left != right");if(!this.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw Error("Field doesn't support isOdd")}equals(e){assertPrjPoint(e);let{px:t,py:n,pz:i}=this,{px:o,py:s,pz:a}=e,l=r.eql(r.mul(t,a),r.mul(o,i)),u=r.eql(r.mul(n,a),r.mul(s,i));return l&&u}negate(){return new Point(this.px,r.neg(this.py),this.pz)}double(){let{a:e,b:n}=t,i=r.mul(n,k),{px:o,py:s,pz:a}=this,l=r.ZERO,u=r.ZERO,c=r.ZERO,d=r.mul(o,o),f=r.mul(s,s),p=r.mul(a,a),y=r.mul(o,s);return y=r.add(y,y),c=r.mul(o,a),c=r.add(c,c),l=r.mul(e,c),u=r.mul(i,p),u=r.add(l,u),l=r.sub(f,u),u=r.add(f,u),u=r.mul(l,u),l=r.mul(y,l),c=r.mul(i,c),p=r.mul(e,p),y=r.sub(d,p),y=r.mul(e,y),y=r.add(y,c),c=r.add(d,d),d=r.add(c,d),d=r.add(d,p),d=r.mul(d,y),u=r.add(u,d),p=r.mul(s,a),p=r.add(p,p),d=r.mul(p,y),l=r.sub(l,d),c=r.mul(p,f),c=r.add(c,c),c=r.add(c,c),new Point(l,u,c)}add(e){assertPrjPoint(e);let{px:n,py:i,pz:o}=this,{px:s,py:a,pz:l}=e,u=r.ZERO,c=r.ZERO,d=r.ZERO,f=t.a,p=r.mul(t.b,k),y=r.mul(n,s),g=r.mul(i,a),m=r.mul(o,l),b=r.add(n,i),E=r.add(s,a);b=r.mul(b,E),E=r.add(y,g),b=r.sub(b,E),E=r.add(n,o);let w=r.add(s,l);return E=r.mul(E,w),w=r.add(y,m),E=r.sub(E,w),w=r.add(i,o),u=r.add(a,l),w=r.mul(w,u),u=r.add(g,m),w=r.sub(w,u),d=r.mul(f,E),u=r.mul(p,m),d=r.add(u,d),u=r.sub(g,d),d=r.add(g,d),c=r.mul(u,d),g=r.add(y,y),g=r.add(g,y),m=r.mul(f,m),E=r.mul(p,E),g=r.add(g,m),m=r.sub(y,m),m=r.mul(f,m),E=r.add(E,m),y=r.mul(g,E),c=r.add(c,y),y=r.mul(w,E),u=r.mul(b,u),u=r.sub(u,y),y=r.mul(b,g),d=r.mul(w,d),d=r.add(d,y),new Point(u,c,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(Point.ZERO)}wNAF(e){return a.wNAFCached(this,o,e,e=>{let t=r.invertBatch(e.map(e=>e.pz));return e.map((e,r)=>e.toAffine(t[r])).map(Point.fromAffine)})}multiplyUnsafe(e){let n=Point.ZERO;if(e===P)return n;if(assertGE(e),e===R)return this;let{endo:i}=t;if(!i)return a.unsafeLadder(this,e);
1let{k1neg:o,k1:s,k2neg:l,k2:u}=i.splitScalar(e),c=n,d=n,f=this;for(;s>P||u>P;)s&R&&(c=c.add(f)),u&R&&(d=d.add(f)),f=f.double(),s>>=R,u>>=R;return o&&(c=c.negate()),l&&(d=d.negate()),d=new Point(r.mul(d.px,i.beta),d.py,d.pz),c.add(d)}multiply(e){let n,i;assertGE(e);let{endo:o}=t;if(o){let{k1neg:t,k1:s,k2neg:l,k2:u}=o.splitScalar(e),{p:c,f:d}=this.wNAF(s),{p:f,f:p}=this.wNAF(u);c=a.constTimeNegate(t,c),f=a.constTimeNegate(l,f),f=new Point(r.mul(f.px,o.beta),f.py,f.pz),n=c.add(f),i=d.add(p)}else{let{p:t,f:r}=this.wNAF(e);n=t,i=r}return Point.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(e,t,r){let n=Point.BASE,mul=(e,t)=>t!==P&&t!==R&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),i=mul(this,t).add(mul(e,r));return i.is0()?void 0:i}toAffine(e){let{px:t,py:n,pz:i}=this,o=this.is0();null==e&&(e=o?r.ONE:r.inv(i));let s=r.mul(t,e),a=r.mul(n,e),l=r.mul(i,e);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:e,isTorsionFree:r}=t;if(e===R)return!0;if(r)return r(Point,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:e,clearCofactor:r}=t;return e===R?this:r?r(Point,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),n(Point,this,e)}toHex(e=!0){return utils_bytesToHex(this.toRawBytes(e))}};Point.BASE=new Point(t.Gx,t.Gy,r.ONE),Point.ZERO=new Point(r.ZERO,r.ONE,r.ZERO);let s=t.nBitLength,a=function(e,t){let constTimeNegate=(e,t)=>
1{let r=t.negate();return e?r:t},opts=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate,unsafeLadder(t,r){let n=e.ZERO,i=t;for(;r>S;)r&T&&(n=n.add(i)),i=i.double(),r>>=T;return n},precomputeWindow(e,t){let{windows:r,windowSize:n}=opts(t),i=[],o=e,s=o;for(let e=0;e<r;e++){s=o,i.push(s);for(let e=1;e<n;e++)s=s.add(o),i.push(s);o=s.double()}return i},wNAF(t,r,n){let{windows:i,windowSize:o}=opts(t),s=e.ZERO,a=e.BASE,l=BigInt(2**t-1),u=2**t,c=BigInt(t);for(let e=0;e<i;e++){let t=e*o,i=Number(n&l);n>>=c,i>o&&(i-=u,n+=T);let d=t+Math.abs(i)-1,f=e%2!=0,p=i<0;0===i?a=a.add(constTimeNegate(f,r[t])):s=s.add(constTimeNegate(p,r[d]))}return{p:s,f:a}},wNAFCached(e,t,r,n){let i=e._WINDOW_SIZE||1,o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,n(o))),this.wNAF(i,o,r)}}}(Point,t.endo?Math.ceil(s/2):s);return{CURVE:t,ProjectivePoint:Point,normPrivateKeyToScalar,weierstrassEquation,isWithinCurveOrder}}({...t,toBytes(e,t,n){let i=t.toAffine(),o=r.toBytes(i.x),s=utils_concatBytes;return n?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(e){let t=e.length,n=e[0],s=e.subarray(1);if(t===i&&(2===n||3===n)){let e=utils_bytesToNumberBE(s);if(!(P<e&&e<r.ORDER))throw Error("Point is not on curve");let t=l(e),i=r.sqrt(t),o=(i&R)===R;return(1&n)==1!==o&&(i=r.neg(i)),{x:e,y:i}}if(t===o&&4===n){let e=r.fromBytes(s.subarray(0,r.BYTES)),t=r.fromBytes(s.subarray(r.BYTES,2*r.BYTES));return{x:e,y:t}}throw Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),numToNByteStr=e=>utils_bytesToHex(numberToBytesBE(e,t.nByteLength));function isBiggerThanHalfOrder(e){let t=n>>R;return e>t}let slcNum=(e,t,r)=>utils_bytesToNumberBE(e.slice(t,r));let Signature=class Signature{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){let r=t.nByteLength;return e=utils_ensureBytes("compactSignature",e,2*r),new Signature(slcNum(e,0,r),slcNum(e,r,2*r))}static fromDER(e){let{r:t,s:r}=N.toSig(utils_ensureBytes("DER",e));return new Signature(t,r)}assertValidity(){if(!u(this.r))throw Error("r must be 0 < r < CURVE.n");if(!u(this.s))throw Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new Signature(this.r,this.s,e)}recoverPublicKey(e){let{r:i,s:o,recovery:a}=this,l=d(utils_ensureBytes("msgHash",e));if(null==a||![0,1,2,3].includes(a))throw Error("recovery id invalid");let u=2===a||3===a?i+t.n:i;if(u>=r.ORDER)throw Error("recovery id 2 or 3 invalid");let c=(1&a)==0?"02":"03",f=s.fromHex(c+numToNByteStr(u)),p=invert(u,n),y=modN(-l*p),g=modN(o*p),m=s.BASE.multiplyAndAddUnsafe(f,y,g);if(!m)throw Error("point at infinify");return m.assertValidity(),m}hasHighS(){return isBiggerThanHalfOrder(this.s)}normalizeS(){return this.hasHighS()?new Signature(this.r,modN(-this.s),this.recovery):this}toDERRawBytes(){return utils_hexToBytes(this.toDERHex())}toDERHex(){return N.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return utils_hexToBytes(this.toCompactHex())}toCompactHex(){return numToNByteStr(this.r)+numToNByteStr(this.s)}};function isProbPub(e){let t=e instanceof Uint8Array,r="string"==typeof e,n=(t||r)&&e.length;return t?n===i||n===o:r?n===2*i||n===2*o:e instanceof s}let c=t.bits2int||function(e){let r=utils_bytesToNumberBE(e),n=8*e.length-t.nBitLength;return n>0?r>>BigInt(n):r},d=t.bits2int_modN||function(e){return modN(c(e))},f=bitMask(t.nBitLength);function int2octets(e){if("bigint"!=typeof e)throw Error("bigint expected");if(!(P<=e&&e<f))throw Error(`bigint expected < 2^${t.nBitLength}`);return numberToBytesBE(e,t.nByteLength)}let p={lowS:t.lowS,prehash:!1},y={lowS:t.lowS,prehash:!1};return s.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return s.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(isProbPub(e))throw Error("first arg must be private key");if(!isProbPub(t))throw Error("second arg must be public key");let n=s.fromHex(t);return n.multiply(a(e)).toRawBytes(r)},sign:function(e,i,o=p){let{seed:l,k2sig:f}=function(e,i,o=p){if(["recovered","canonical"].some(e=>e in o))throw Error("sign() legacy options not supported");let{hash:l,randomBytes:f}=t,{lowS:y,prehash:g,extraEntropy:m}=o;null==y&&(y=!0),e=utils_ensureBytes("msgHash",e),g&&(e=utils_ensureBytes("prehashed msgHash",l(e)));let b=d(e),E=a(i),w=[int2octets(E),int2octets(b)];if(null!=m){let e=!0===m?f(r.BYTES):m;w.push(utils_ensureBytes("extraEntropy",e))}let v=utils_concatBytes(...w);return{seed:v,k2sig:function(e){let t=c(e);if(!u(t))return;let r=invert(t,n),i=s.BASE.multiply(t).toAffine(),o=modN(i.x);if(o===P)return;let a=modN(r*modN(b+o*E));if(a===P)return;let l=(i.x===o?0:2)|Number(i.y&R),d=a;
1return y&&isBiggerThanHalfOrder(a)&&(d=isBiggerThanHalfOrder(a)?modN(-a):a,l^=1),new Signature(o,d,l)}}}(e,i,o),y=createHmacDrbg(t.hash.outputLen,t.nByteLength,t.hmac);return y(l,f)},verify:function(e,r,i,o=y){let a,l;if(r=utils_ensureBytes("msgHash",r),i=utils_ensureBytes("publicKey",i),"strict"in o)throw Error("options.strict was renamed to lowS");let{lowS:u,prehash:c}=o;try{if("string"==typeof e||e instanceof Uint8Array)try{l=Signature.fromDER(e)}catch(t){if(!(t instanceof N.Err))throw t;l=Signature.fromCompact(e)}else if("object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s){let{r:t,s:r}=e;l=new Signature(t,r)}else throw Error("PARSE");a=s.fromHex(i)}catch(e){if("PARSE"===e.message)throw Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&l.hasHighS())return!1;c&&(r=t.hash(r));let{r:f,s:p}=l,g=d(r),m=invert(p,n),b=modN(g*m),E=modN(f*m),w=s.BASE.multiplyAndAddUnsafe(a,b,E)?.toAffine();if(!w)return!1;let v=modN(w.x);return v===f},ProjectivePoint:s,Signature,utils:{isValidPrivateKey(e){try{return a(e),!0}catch(e){return!1}},normPrivateKeyToScalar:a,randomPrivateKey:()=>{let e=getMinHashLength(t.n);return function(e,t,r=!1){let n=e.length,i=getFieldBytesLength(t),o=getMinHashLength(t);if(n<16||n<o||n>1024)throw Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?utils_bytesToNumberBE(e):utils_bytesToNumberLE(e),a=modular_mod(s,t-E)+E;return r?numberToBytesLE(a,i):numberToBytesBE(a,i)}(t.randomBytes(e),t.n)},precompute:(e=8,t=s.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}})({...e,hash:t,hmac:(e,...r)=>hmac(t,e,function(...e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),r=0;return e.forEach(e=>{if(!u8a(e))throw Error("Uint8Array expected");t.set(e,r),r+=e.length}),t}(...r)),randomBytes:randomBytes});return Object.freeze({...create(t),create})}({a:BigInt(0),b:BigInt(7),Fp:$,n:C,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-O*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),n=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=BigInt("0x100000000000000000000000000000000"),o=divNearest(t*e,C),s=divNearest(-r*e,C),a=modular_mod(e-o*t-s*n,C),l=modular_mod(-o*r-s*t,C),u=a>i,c=l>i;
1if(u&&(a=C-a),c&&(l=C-l),a>i||l>i)throw Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:u,k1:a,k2neg:c,k2:l}}}},f),M=BigInt(0),fe=e=>"bigint"==typeof e&&M<e&&e<U,ge=e=>"bigint"==typeof e&&M<e&&e<C,j={};function taggedHash(e,...t){let r=j[e];if(void 0===r){let t=f(Uint8Array.from(e,e=>e.charCodeAt(0)));r=utils_concatBytes(t,t),j[e]=r}return f(utils_concatBytes(r,...t))}let pointToBytes=e=>e.toRawBytes(!0).slice(1),numTo32b=e=>numberToBytesBE(e,32),modP=e=>modular_mod(e,U),modN=e=>modular_mod(e,C),V=q.ProjectivePoint,GmulAdd=(e,t,r)=>V.BASE.multiplyAndAddUnsafe(e,t,r);function schnorrGetExtPubKey(e){let t=q.utils.normPrivateKeyToScalar(e),r=V.fromPrivateKey(t),n=r.hasEvenY()?t:modN(-t);return{scalar:n,bytes:pointToBytes(r)}}function lift_x(e){if(!fe(e))throw Error("bad x: need 0 < x < p");let t=modP(e*e),r=modP(t*e+BigInt(7)),n=sqrtMod(r);n%H!==M&&(n=modP(-n));let i=new V(e,n,O);return i.assertValidity(),i}function challenge(...e){return modN(utils_bytesToNumberBE(taggedHash("BIP0340/challenge",...e)))}function schnorrVerify(e,t,r){let n=utils_ensureBytes("signature",e,64),i=utils_ensureBytes("message",t),o=utils_ensureBytes("publicKey",r,32);try{let e=lift_x(utils_bytesToNumberBE(o)),t=utils_bytesToNumberBE(n.subarray(0,32));if(!fe(t))return!1;let r=utils_bytesToNumberBE(n.subarray(32,64));if(!ge(r))return!1;let s=challenge(numTo32b(t),pointToBytes(e),i),a=GmulAdd(e,r,modN(-s));if(!a||!a.hasEvenY()||a.toAffine().x!==t)return!1;return!0}catch(e){return!1}}let K={getPublicKey:function(e){return schnorrGetExtPubKey(e).bytes},sign:function(e,t,r=randomBytes(32)){let n=utils_ensureBytes("message",e),{bytes:i,scalar:o}=schnorrGetExtPubKey(t),s=utils_ensureBytes("auxRand",r,32),a=numTo32b(o^utils_bytesToNumberBE(taggedHash("BIP0340/aux",s))),l=taggedHash("BIP0340/nonce",a,i,n),u=modN(utils_bytesToNumberBE(l));if(u===M)throw Error("sign failed: k is zero");let{bytes:c,scalar:d}=schnorrGetExtPubKey(u),f=challenge(c,i,n),p=new Uint8Array(64);if(p.set(c,0),p.set(numTo32b(modN(d+f*o)),32),!schnorrVerify(p,n,i))throw Error("sign: Invalid signature produced");return p},verify:schnorrVerify,utils:{randomPrivateKey:q.utils.randomPrivateKey,lift_x,pointToBytes,numberToBytesBE:numberToBytesBE,bytesToNumberBE:utils_bytesToNumberBE,taggedHash,mod:modular_mod}};var Z=r(6409),z=r(1606);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function assertNumber(e){if(!Number.isSafeInteger(e))throw Error(`Wrong integer: ${e}`)}function chain(...e){let wrap=(e,t)=>r=>e(t(r)),t=Array.from(e).reverse().reduce((e,t)=>e?wrap(e,t.encode):t.encode,void 0),r=e.reduce((e,t)=>e?wrap(e,t.decode):t.decode,void 0);return{encode:t,decode:r}}function alphabet(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(assertNumber(t),t<0||t>=e.length)throw Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw Error(`alphabet.decode: not string element=${t}`);let r=e.indexOf(t);if(-1===r)throw Error(`Unknown letter: "${t}". Allowed: ${e}`);return r})}}}function join(e=""){if("string"!=typeof e)throw Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw Error("join.decode input should be string");return t.split(e)}}}function padding(e,t="="){if(assertNumber(e),"string"!=typeof t)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 e of r)if("string"!=typeof e)throw Error(`padding.encode: non-string input=${e}`);for(;r.length*e%8;)r.push(t);return r},decode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw Error("padding.encode input should be array of str
1ings");for(let e of r)if("string"!=typeof e)throw Error(`padding.decode: non-string input=${e}`);let n=r.length;if(n*e%8)throw Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===t;n--)if(!((n-1)*e%8))throw Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function normalize(e){if("function"!=typeof e)throw Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function convertRadix(e,t,r){if(t<2)throw Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(r<2)throw Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw Error("convertRadix: data should be array");if(!e.length)return[];let n=0,i=[],o=Array.from(e);for(o.forEach(e=>{if(assertNumber(e),e<0||e>=t)throw Error(`Wrong integer: ${e}`)});;){let e=0,s=!0;for(let i=n;i<o.length;i++){let a=o[i],l=t*e+a;if(!Number.isSafeInteger(l)||t*e/t!==e||l-a!=t*e||(e=l%r,o[i]=Math.floor(l/r),!Number.isSafeInteger(o[i])||o[i]*r+e!==l))throw Error("convertRadix: carry overflow");s&&(o[i]?s=!1:n=i)}if(i.push(e),s)break}for(let t=0;t<e.length-1&&0===e[t];t++)i.push(0);return i.reverse()}let gcd=(e,t)=>t?gcd(t,e%t):e,radix2carry=(e,t)=>e+(t-gcd(e,t));function convertRadix2(e,t,r,n){if(!Array.isArray(e))throw Error("convertRadix2: data should be array");if(t<=0||t>32)throw Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw Error(`convertRadix2: wrong to=${r}`);if(radix2carry(t,r)>32)throw Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${radix2carry(t,r)}`);let i=0,o=0,s=2**r-1,a=[];for(let n of e){if(assertNumber(n),n>=2**t)throw Error(`convertRadix2: invalid data word=${n} from=${t}`);if(i=i<<t|n,o+t>32)throw Error(`convertRadix2: carry overflow pos=${o} from=${t}`);for(o+=t;o>=r;o-=r)a.push((i>>o-r&s)>>>0);i&=2**o-1}if(i=i<<r-o&s,!n&&o>=t)throw Error("Excess padding");if(!n&&i)throw Error(`Non-zero padding: ${i}`);return n&&o>0&&a.push(i>>>0),a}function radix2(e,t=!1){if(assertNumber(e),e<=0||e>32)throw Error("radix2: bits should be in (0..32]");if(radix2carry(8,e)>32||radix2carry(e,8)>32)throw Error("radix2: carry overflow");return{encode:r=>{if(!(r instanceof Uint8Array))throw Error("radix2.encode input should be Uint8Array");return convertRadix2(Array.from(r),8,e,!t)},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(convertRadix2(r,e,8,t))}}}function unsafeWrapper(e){if("function"!=typeof e)throw Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}chain(radix2(4),alphabet("0123456789ABCDEF"),join("")),chain(radix2(5),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),padding(5),join("")),chain(radix2(5),alphabet("0123456789ABCDEFGHIJKLMNOPQRSTUV"),padding(5),join("")),chain(radix2(5),alphabet("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),join(""),normalize(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));let D=chain(radix2(6),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),padding(6),join("")),F=(chain(radix2(6),alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),padding(6),join("")),e=>chain((assertNumber(58),{encode:e=>{if(!(e instanceof Uint8Array))throw Error("radix.encode input should be Uint8Array");return convertRadix(Array.from(e),256,58)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw Error("radix.decode input should be array of strings");return Uint8Array.from(convertRadix(e,58,256))}}),alphabet(e),join("")));F("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),F("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),F("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");let G=chain(alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),join("")),W=[996825010,642813549,513874426,1027748829,705979059];function bech32Polymod(e){let t=e>>25,r=(33554431&e)<<5;for(let e=0;e<W.length;e++)(t>>e&1)==1&&(r^=W[e]);return r}function bechChecksum(e,t,r=1){let n=e.length,i=1;for(let t=0;t<n;t++){let r=e.charCodeAt(t);if(r<33||r>126)throw Error(`Invalid prefix (${e})`);i=bech32Polymod(i)^r>>5}i=bech32Polymod(i);for(let t=0;t<n;t++)i=bech32Polymod(i)^31&e.charCodeAt(t);for(let e of t)i=bech32Polymod(i)^e;for(let e=0;e<6;e++)i=bech32Polymod(i);return i^=r,G.encode(convertRadix2([i%1073741824],30,5,!1))}function genBech32(e){let t="bech32"===e?1:734539939,r=radix2(5),n=r.decode,i=r.encode,o=unsafeWrapper(n);function decode(e,r=90){if("string"!=typeof e)throw Error(`bech32.decode input should be string, not ${typeof e}`);if(e.length<8||!1!==r&&e.length>
1r)throw TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${r})`);let n=e.toLowerCase();if(e!==n&&e!==e.toUpperCase())throw Error("String must be lowercase or uppercase");e=n;let i=e.lastIndexOf("1");if(0===i||-1===i)throw Error('Letter "1" must be present between prefix and data only');let o=e.slice(0,i),s=e.slice(i+1);if(s.length<6)throw Error("Data must be at least 6 characters long");let a=G.decode(s).slice(0,-6),l=bechChecksum(o,a,t);if(!s.endsWith(l))throw Error(`Invalid checksum in ${e}: expected "${l}"`);return{prefix:o,words:a}}let s=unsafeWrapper(decode);return{encode:function(e,r,n=90){if("string"!=typeof e)throw Error(`bech32.encode prefix should be string, not ${typeof e}`);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=e.length+7+r.length;if(!1!==n&&i>n)throw TypeError(`Length ${i} exceeds limit ${n}`);return e=e.toLowerCase(),`${e}1${G.encode(r)}${bechChecksum(e,r,t)}`},decode,decodeToBytes:function(e){let{prefix:t,words:r}=decode(e,!1);return{prefix:t,words:r,bytes:n(r)}},decodeUnsafe:s,fromWords:n,fromWordsUnsafe:o,toWords:i}}let J=genBech32("bech32");genBech32("bech32m"),chain(radix2(4),alphabet("0123456789abcdef"),join(""),normalize(e=>{if("string"!=typeof e||e.length%2)throw TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));let esm_utils_u8a=e=>e instanceof Uint8Array,utils_u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Y=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!Y)throw Error("Non little-endian hardware is not supported");function esm_utils_utf8ToBytes(e){if("string"!=typeof e)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function utils_toBytes(e){if("string"==typeof e&&(e=esm_utils_utf8ToBytes(e)),!esm_utils_u8a(e))throw Error(`expected Uint8Array, got ${typeof e}`);return e}let isPlainObject=e=>"[object Object]"===Object.prototype.toString.call(e)&&e.constructor===Object;function esm_utils_ensureBytes(e,t){if(!(e instanceof Uint8Array))throw Error("Uint8Array expected");if("number"==typeof t&&e.length!==t)throw Error(`Uint8Array length ${t} expected`)}function _assert_number(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`Wrong positive integer: ${e}`)}function _assert_bytes(e,...t){if(!(e instanceof Uint8Array))throw Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}var Q={number:_assert_number,bool:function(e){if("boolean"!=typeof e)throw Error(`Expected boolean, not ${e}`)},bytes:_assert_bytes,hash:function(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("hash must be wrapped by utils.wrapConstructor");_assert_number(e.outputLen),_assert_number(e.blockLen)},exists:function(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")},output:function(e,t){_assert_bytes(e);let r=t.outputLen;if(e.length<r)throw Error(`digestInto() expects output buffer of length at least ${r}`)}};let u8to16=(e,t)=>255&e[t++]|(255&e[t++])<<8;let Poly1305=class Poly1305{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,esm_utils_ensureBytes(e=utils_toBytes(e),32);let t=u8to16(e,0),r=u8to16(e,2),n=u8to16(e,4),i=u8to16(e,6),o=u8to16(e,8),s=u8to16(e,10),a=u8to16(e,12),l=u8to16(e,14);this.r[0]=8191&t,this.r[1]=(t>>>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 t=0;t<8;t++)this.pad[t]=u8to16(e,16+2*t)}process(e,t,r=!1){let{h:n,r:i}=this,o=i[0],s=i[1],a=i[2],l=i[3],u=i[4],c=i[5],d=i[6],f=i[7],p=i[8],y=i[9],g=u8to16(e,t+0),m=u8to16(e,t+2),b=u8to16(e,t+4),E=u8to16(e,t+6),w=u8to16(e,t+8),v=u8to16(e,t+10),x=u8to16(e,t+12),B=u8to16(e,t+14),_=n[0]+(8191&g),A=n[1]+((g>>>13|m<<3)&8191),S=n[2]+((m>>>10|b<<6)&8191),T=n[3]+((b>>>7|E<<9)&8191),I=n[4]+((E>>>4|w<<12)&8191),L=n[5]+(w>>>1&8191),N=n[6]+((w>>>14|v<<2)&8191),P=n[7]+((v>>>11|x<<5)&8191),R=n[8]+((x>>>8|B<<8)&8191),k=n[9]+(B>>>5|(r?0:2048)),U=0,C=0+_*o+A*(5*y)+S*(5*p)+T*(5*f)+I*(5*d);U=C>>>13,C&=8191,C+=L*(5*c)+N*(5*u)+P*(5*l)+R*(5*a)+k*(5*s),U+=C>>>13,C&=8191;let O=U+_*s+A*o+S*(5*y)+T*(5*p)+I*(5*f);U=O>>>13,O&=8191,O+=L*(5*d)+N*(5*c)+P*(5*u)+R*(5*l)+k*(5*a),U+=O>>>13,O&=8191;let H=U+_*a+A*s+S*o+T*(5*y)+I*(5*p);U=H>>>13,H&=8191,H+=L*(5*f)+N*(5*d)+P*(5*c)+R*(5*u)+k*(5*l),U+=H>>>13,H&=8191;let $=U+_*l+A*a+S*s+T*o+I*(5*y);U=$>>>13,$&=8191,$+=L*(5*p)+N*(5*f)+P*(5*d)+R*(5*c)+k*(5*u),U+=$>>>13,$&=8191;let q=U+_*u+A*l+S*a+T*s+I*o;U=q>>>13,q&=8191,q+=L*(5*y)+N*(5*p)+P*(5*f)+R*(5*d)+k*(5*c),U+=q>>>13,q&=8191;let M=U+_*c+A*u+S*l+T*a+I*s;U=M>>>13,M&=8191,M+=L*o+N*(5*y)+P*(5*p)+R*(5*f)+k*(5*d),U+=M>>>13,M&=8191;let j=U+_*d+A*c+S*u+T*l+I*a;U=j>>>13,j&=8191,j+=L*s+N*o+P*(5*y)+R*(5*p)+k*(5*f),U+=j>>>13,j&=8191;let V=U+_*f+A*d+S*c+T*u+I*l;U=V>>>13,V&=8191,V+=L*a+N*s+P*o+R*(5*y)+k*(5*p),U+=V>>>13,V&=8191;let K=U+_*p+A*f+S*d+T*c+I*u;U=K>>>13,K&=8191,K+=L*l+N*a+P*s+R*o+k*(5*y),U+=K>>>13,K&=8191;let Z=U+_*y+A*p+S*f+T*d+I*c;U=Z>>>
113,Z&=8191,Z+=L*u+N*l+P*a+R*s+k*o,U+=Z>>>13,Z&=8191,C=8191&(U=(U=(U<<2)+U|0)+C|0),U>>>=13,O+=U,n[0]=C,n[1]=O,n[2]=H,n[3]=$,n[4]=q,n[5]=M,n[6]=j,n[7]=V,n[8]=K,n[9]=Z}finalize(){let{h:e,pad:t}=this,r=new Uint16Array(10),n=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=n,n=e[t]>>>13,e[t]&=8191;e[0]+=5*n,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,r[0]=e[0]+5,n=r[0]>>>13,r[0]&=8191;for(let t=1;t<10;t++)r[t]=e[t]+n,n=r[t]>>>13,r[t]&=8191;r[9]-=8192;let i=(1^n)-1;for(let e=0;e<10;e++)r[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|r[t];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]+t[0];e[0]=65535&o;for(let r=1;r<8;r++)o=(e[r]+t[r]|0)+(o>>>16)|0,e[r]=65535&o}update(e){Q.exists(this);let{buffer:t,blockLen:r}=this;e=utils_toBytes(e);let n=e.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(e,i);continue}t.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===r&&(this.process(t,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(e){Q.exists(this),Q.output(e,this),this.finished=!0;let{buffer:t,h:r}=this,{pos:n}=this;if(n){for(t[n++]=1;n<16;n++)t[n]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=r[t]>>>0,e[i++]=r[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}};!function(e){let hashC=(t,r)=>e(r).update(utils_toBytes(t)).digest(),t=e(new Uint8Array(32));hashC.outputLen=t.outputLen,hashC.blockLen=t.blockLen,hashC.create=t=>e(t)}(e=>new Poly1305(e));let X=esm_utils_utf8ToBytes("expand 16-byte k"),ee=esm_utils_utf8ToBytes("expand 32-byte k"),et=utils_u32(X),er=utils_u32(ee),isAligned32=e=>!(e.byteOffset%4),rotl=(e,t)=>e<<t|e>>>32-t,en=(e=>{let{core:t,rounds:r,counterRight:n,counterLen:i,allow128bitKeys:o,extendNonceFn:s,blockLen:a}=function(e,t){if(void 0!==t&&("object"!=typeof t||!isPlainObject(t)))throw Error("options must be object or undefined");let r=Object.assign(e,t);return r}({rounds:20,counterRight:!1,counterLen:8,allow128bitKeys:!0,blockLen:64},e);Q.number(i),Q.number(r),Q.number(a),Q.bool(n),Q.bool(o);let l=a/4;if(a%4!=0)throw Error("Salsa/ChaCha: blockLen must be aligned to 4 bytes");return(e,u,c,d,f=0)=>{let p,y;if(Q.bytes(e),Q.bytes(u),Q.bytes(c),d||(d=new Uint8Array(c.length)),Q.bytes(d),Q.number(f),f<0||f>=4294967296-1)throw Error("Salsa/ChaCha: counter overflow");if(d.length<c.length)throw Error(`Salsa/ChaCha: output (${d.length}) is shorter than data (${c.length})`);let g=[];if(32===e.length)p=e,y=er;else if(16===e.length&&o)(p=new Uint8Array(32)).set(e),p.set(e,16),y=et,g.push(p);else throw Error(`Salsa/ChaCha: invalid 32-byte key, got length=${e.length}`);if(s){if(u.length<=16)throw Error("Salsa/ChaCha: extended nonce must be bigger than 16 bytes");p=s(y,p,u.subarray(0,16),new Uint8Array(32)),g.push(p),u=u.subarray(16)}let m=16-i;if(u.length!==m)throw Error(`Salsa/ChaCha: nonce must be ${m} or 16 bytes`);if(12!==m){let e=new Uint8Array(12);e.set(u,n?0:12-u.length),g.push(u=e)}let b=new Uint8Array(a),E=utils_u32(b),w=utils_u32(p),v=utils_u32(u),x=isAligned32(c)&&utils_u32(c),B=isAligned32(d)&&utils_u32(d);g.push(E);let _=c.length;for(let e=0,n=f;e<_;n++){if(t(y,w,v,E,n,r),n>=4294967296-1)throw Error("Salsa/ChaCha: counter overflow");let i=Math.min(a,_-e);if(i===a&&B&&x){let t=e/4;if(e%4!=0)throw Error("Salsa/ChaCha: invalid block position");for(let e=0;e<l;e++)B[t+e]=x[t+e]^E[e];e+=a;continue}for(let t=0;t<i;t++)d[e+t]=c[e+t]^b[t];e+=i}for(let e=0;e<g.length;e++)g[e].fill(0);return d}})({core:function(e,t,r,n,i,o=20){let s=e[0],a=e[1],l=e[2],u=e[3],c=t[0],d=t[1],f=t[2],p=t[3],y=t[4],g=t[5],m=t[6],b=t[7],E=r[0],w=r[1],v=r[2],x=s,B=a,_=l,A=u,S=c,T=d,I=f,L=p,N=y,P=g,R=m,k=b,U=i,C=E,O=w,H=v;for(let e=0;e<o;e+=2)N=N+(U=rotl(U^(x=x+S|0),16))|0,x=x+(S=rotl(S^N,12))|0,N=N+(U=rotl(U^x,8))|0,S=rotl(S^N,7),P=P+(C=rotl(C^(B=B+T|0),16))|0,B=B+(T=rotl(T^P,12))|0,P=P+(C=rotl(C^B,8))|0,T=rotl(T^P,7),R=R+(O=rotl(O^(_=_+
1I|0),16))|0,_=_+(I=rotl(I^R,12))|0,R=R+(O=rotl(O^_,8))|0,I=rotl(I^R,7),k=k+(H=rotl(H^(A=A+L|0),16))|0,A=A+(L=rotl(L^k,12))|0,k=k+(H=rotl(H^A,8))|0,L=rotl(L^k,7),R=R+(H=rotl(H^(x=x+T|0),16))|0,x=x+(T=rotl(T^R,12))|0,R=R+(H=rotl(H^x,8))|0,T=rotl(T^R,7),k=k+(U=rotl(U^(B=B+I|0),16))|0,B=B+(I=rotl(I^k,12))|0,k=k+(U=rotl(U^B,8))|0,I=rotl(I^k,7),N=N+(C=rotl(C^(_=_+L|0),16))|0,_=_+(L=rotl(L^N,12))|0,N=N+(C=rotl(C^_,8))|0,L=rotl(L^N,7),P=P+(O=rotl(O^(A=A+S|0),16))|0,A=A+(S=rotl(S^P,12))|0,P=P+(O=rotl(O^A,8))|0,S=rotl(S^P,7);let $=0;n[$++]=s+x|0,n[$++]=a+B|0,n[$++]=l+_|0,n[$++]=u+A|0,n[$++]=c+S|0,n[$++]=d+T|0,n[$++]=f+I|0,n[$++]=p+L|0,n[$++]=y+N|0,n[$++]=g+P|0,n[$++]=m+R|0,n[$++]=b+k|0,n[$++]=i+U|0,n[$++]=E+C|0,n[$++]=w+O|0,n[$++]=v+H|0},counterRight:!1,counterLen:4,allow128bitKeys:!1}),ei=new Uint8Array(16);var eo=r(3527),es=r(9905);let ea=new Uint8Array([0]),el=new Uint8Array;var eu=Object.defineProperty,__export=(e,t)=>{for(var r in t)eu(e,r,{get:t[r],enumerable:!0})},ec=Symbol("verified"),isRecord=e=>e instanceof Object;function validateEvent(e){if(!isRecord(e)||"number"!=typeof e.kind||"string"!=typeof e.content||"number"!=typeof e.created_at||"string"!=typeof e.pubkey||!e.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let r=e.tags[t];if(!Array.isArray(r))return!1;for(let e=0;e<r.length;e++)if("object"==typeof r[e])return!1}return!0}__export({},{Queue:()=>ep,QueueNode:()=>ef,binarySearch:()=>binarySearch,insertEventIntoAscendingList:()=>insertEventIntoAscendingList,insertEventIntoDescendingList:()=>insertEventIntoDescendingList,normalizeURL:()=>normalizeURL,utf8Decoder:()=>eh,utf8Encoder:()=>ed});var eh=new TextDecoder("utf-8"),ed=new TextEncoder;function normalizeURL(e){let t=new URL(e);return t.pathname=t.pathname.replace(/\/+/g,"/"),t.pathname.endsWith("/")&&(t.pathname=t.pathname.slice(0,-1)),("80"===t.port&&"ws:"===t.protocol||"443"===t.port&&"wss:"===t.protocol)&&(t.port=""),t.searchParams.sort(),t.hash="",t.toString()}function insertEventIntoDescendingList(e,t){let[r,n]=binarySearch(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:e.created_at-t.created_at);return n||e.splice(r,0,t),e}function insertEventIntoAscendingList(e,t){let[r,n]=binarySearch(e,e=>t.id===e.id?0:t.created_at===e.created_at?-1:t.created_at-e.created_at);return n||e.splice(r,0,t),e}function binarySearch(e,t){let r=0,n=e.length-1;for(;r<=n;){let i=Math.floor((r+n)/2),o=t(e[i]);if(0===o)return[i,!0];o<0?n=i-1:r=i+1}return[r,!1]}var ef=class{value;next=null;prev=null;constructor(e){this.value=e}},ep=class{first;last;constructor(){this.first=null,this.last=null}enqueue(e){let t=new ef(e);return this.last?this.last===this.first?(this.last=t,this.last.prev=this.first,this.first.next=t):(t.prev=this.last,this.last.next=t,this.last=t):(this.first=t,this.last=t),!0}dequeue(){if(!this.first)return null;if(this.first===this.last){let e=this.first;return this.first=null,this.last=null,e.value}let e=this.first;return this.first=e.next,e.value}};function getEventHash(e){let t=(0,z.J)(ed.encode(function(e){if(!validateEvent(e))throw Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}(e)));return(0,Z.ci)(t)}var ey=new class{generateSecretKey(){return K.utils.randomPrivateKey()}getPublicKey(e){return(0,Z.ci)(K.getPublicKey(e))}finalizeEvent(e,t){return e.pubkey=(0,Z.ci)(K.getPublicKey(t)),e.id=getEventHash(e),e.sig=(0,Z.ci)(K.sign(getEventHash(e),t)),e[ec]=!0,e}verifyEvent(e){if("boolean"==typeof e[ec])return e[ec];let t=getEventHash(e);if(t!==e.id)return e[ec]=!1,!1;try{let r=K.verify(e.sig,t,e.pubkey);return e[ec]=r,r}catch(t){return e[ec]=!1,!1}}};ey.generateSecretKey,ey.getPublicKey;var eg=ey.finalizeEvent,em=ey.verifyEvent;function getHex64(e,t){let r=t.length+3,n=e.indexOf(`"${t}":`)+r,i=e.slice(n).indexOf('"')+n+1;return e.slice(i,i+64)}function getInt(e,t){let r=t.length,n=e.indexOf(`"${t}":`)+r+3,i=e.slice(n),o=Math.min(i.indexOf(","),i.indexOf("}"));return parseInt(i.slice(0,o),10)}function getSubscriptionId(e){let t=e.slice(0,22).indexOf('"EVENT"');if(-1===t)return null;let r=e.slice(t+7+1).indexOf('"');if(-1===r)return null;let n=t+7+1+r,i=e.slice(n+1,80).indexOf('"');if(-1===i)return null;let o=n+1+i;return e.slice(n+1,o)}
1function matchEventId(e,t){return t===getHex64(e,"id")}function matchEventPubkey(e,t){return t===getHex64(e,"pubkey")}function matchEventKind(e,t){return t===getInt(e,"kind")}function isRegularKind(e){return 1e3<=e&&e<1e4||[1,2,4,5,6,7,8,16,40,41,42,43,44].includes(e)}function isReplaceableKind(e){return[0,3].includes(e)||1e4<=e&&e<2e4}function isEphemeralKind(e){return 2e4<=e&&e<3e4}function isParameterizedReplaceableKind(e){return 3e4<=e&&e<4e4}function classifyKind(e){return isRegularKind(e)?"regular":isReplaceableKind(e)?"replaceable":isEphemeralKind(e)?"ephemeral":isParameterizedReplaceableKind(e)?"parameterized":"unknown"}__export({},{getHex64:()=>getHex64,getInt:()=>getInt,getSubscriptionId:()=>getSubscriptionId,matchEventId:()=>matchEventId,matchEventKind:()=>matchEventKind,matchEventPubkey:()=>matchEventPubkey}),__export({},{makeAuthEvent:()=>makeAuthEvent}),__export({},{Application:()=>ty,BadgeAward:()=>eS,BadgeDefinition:()=>eH,BlockedRelaysList:()=>e3,BookmarkList:()=>e0,Bookmarksets:()=>ts,Calendar:()=>tx,CalendarEventRSVP:()=>tB,ChannelCreation:()=>eT,ChannelHideMessage:()=>eN,ChannelMessage:()=>eL,ChannelMetadata:()=>eI,ChannelMuteUser:()=>eP,ClassifiedListing:()=>tb,ClientAuth:()=>eO,CommunitiesList:()=>e1,CommunityDefinition:()=>tS,CommunityPostApproval:()=>eD,Contacts:()=>ev,CreateOrUpdateProduct:()=>th,CreateOrUpdateStall:()=>tc,Curationsets:()=>ta,Date:()=>tw,DraftClassifiedListing:()=>tE,DraftLong:()=>tf,Emojisets:()=>tp,EncryptedDirectMessage:()=>ex,EncryptedDirectMessages:()=>eq,EventDeletion:()=>eB,FileMetadata:()=>e$,Followsets:()=>tn,GenericRepost:()=>eM,Genericlists:()=>ti,HTTPAuth:()=>tr,Handlerinformation:()=>tA,Handlerrecommendation:()=>t_,Highlights:()=>eY,InterestsList:()=>e4,Interestsets:()=>tu,JobFeedback:()=>eW,JobRequest:()=>eF,JobResult:()=>eG,Label:()=>ez,LightningPubRPC:()=>e9,LiveChatMessage:()=>eV,LiveEvent:()=>tg,LongFormArticle:()=>td,Metadata:()=>eb,Mutelist:()=>eQ,NWCWalletInfo:()=>e6,NWCWalletRequest:()=>e7,NWCWalletResponse:()=>te,NostrConnect:()=>tt,OpenTimestamps:()=>ej,Pinlist:()=>eX,ProblemTracker:()=>eK,ProfileBadges:()=>tl,PublicChatsList:()=>e2,Reaction:()=>eA,RecommendRelay:()=>ew,RelayList:()=>eC,Relaysets:()=>to,Report:()=>eR,Reporting:()=>eZ,Repost:()=>e_,SearchRelaysList:()=>e8,ShortTextNote:()=>eE,Time:()=>tv,UserEmojiList:()=>e5,UserStatuses:()=>tm,Zap:()=>eU,ZapGoal:()=>eJ,ZapRequest:()=>ek,classifyKind:()=>classifyKind,isEphemeralKind:()=>isEphemeralKind,isParameterizedReplaceableKind:()=>isParameterizedReplaceableKind,isRegularKind:()=>isRegularKind,isReplaceableKind:()=>isReplaceableKind});var eb=0,eE=1,ew=2,ev=3,ex=4,eB=5,e_=6,eA=7,eS=8,eT=40,eI=41,eL=42,eN=43,eP=44,eR=1984,ek=9734,eU=9735,eC=10002,eO=22242,eH=30009,e$=1063,eq=4,eM=16,ej=1040,eV=1311,eK=1971,eZ=1984,ez=1985,eD=4550,eF=5999,eG=6999,eW=7e3,eJ=9041,eY=9802,eQ=1e4,eX=10001,e0=10003,e1=10004,e2=10005,e3=10006,e8=10007,e4=10015,e5=10030,e6=13194,e9=21e3,e7=23194,te=23195,tt=24133,tr=27235,tn=3e4,ti=30001,to=30002,ts=30003,ta=30004,tl=30008,tu=30015,tc=30017,th=30018,td=30023,tf=30024,tp=30030,ty=30078,tg=30311,tm=30315,tb=30402,tE=30403,tw=31922,tv=31923,tx=31924,tB=31925,t_=31989,tA=31990,tS=34550;function makeAuthEvent(e,t){return{kind:eO,created_at:Math.floor(Date.now()/1e3),tags:[["relay",e],["challenge",t]],content:""}}async function yieldThread(){return new Promise(e=>{let t=new MessageChannel,handler=()=>{t.port1.removeEventListener("message",handler),e()};t.port1.addEventListener("message",handler),t.port2.postMessage(0),t.port1.start()})}var tT=class{url;_connected=!1;onclose=null;onnotice=e=>console.debug(`NOTICE from ${this.url}: ${e}`);baseEoseTimeout=4400;connectionTimeout=4400;openSubs=new Map;connectionTimeoutHandle;connectionPromise;openCountRequests=new Map;openEventPublishes=new Map;ws;incomingMessageQueue=new ep;queueRunning=!1;challenge;serial=0;verifyEvent;constructor(e,t){this.url=normalizeURL(e),this.verifyEvent=t.verifyEvent}static async connect(e,t){let r=new tT(e,t);return await r.connect(),r}closeAllSubscriptions(e){for(let[t,r]of this.openSubs)r.close(e);for(let[t,r]of(this.openSubs.clear(),this.openEventPublishes))r.reject(Error(e));for(let[t,r]of(this.openEventPublishes.clear(),this.openCountRequests))r.reject(Error(e));this.openCountRequests.clear()}get connected(){return this._connected}async connect(){return this.connectionPromise||(this.challenge=void 0,this.connectionPromise=new Promise((e,t)=>
1{this.connectionTimeoutHandle=setTimeout(()=>{t("connection timed out"),this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection timed out")},this.connectionTimeout);try{this.ws=new WebSocket(this.url)}catch(e){t(e);return}this.ws.onopen=()=>{clearTimeout(this.connectionTimeoutHandle),this._connected=!0,e()},this.ws.onerror=e=>{t(e.message),this._connected&&(this.onclose?.(),this.closeAllSubscriptions("relay connection errored"),this._connected=!1)},this.ws.onclose=async()=>{this.connectionPromise=void 0,this.onclose?.(),this.closeAllSubscriptions("relay connection closed"),this._connected=!1},this.ws.onmessage=this._onmessage.bind(this)})),this.connectionPromise}async runQueue(){for(this.queueRunning=!0;!1!==this.handleNext();)await yieldThread();this.queueRunning=!1}handleNext(){let e=this.incomingMessageQueue.dequeue();if(!e)return!1;let t=getSubscriptionId(e);if(t){let r=this.openSubs.get(t);if(!r)return;let n=getHex64(e,"id"),i=r.alreadyHaveEvent?.(n);if(r.receivedEvent?.(this,n),i)return}try{let t=JSON.parse(e);switch(t[0]){case"EVENT":{let e=this.openSubs.get(t[1]),r=t[2];this.verifyEvent(r)&&function(e,t){for(let r=0;r<e.length;r++)if(function(e,t){if(e.ids&&-1===e.ids.indexOf(t.id)&&!e.ids.some(e=>t.id.startsWith(e))||e.kinds&&-1===e.kinds.indexOf(t.kind)||e.authors&&-1===e.authors.indexOf(t.pubkey)&&!e.authors.some(e=>t.pubkey.startsWith(e)))return!1;for(let r in e)if("#"===r[0]){let n=r.slice(1),i=e[`#${n}`];if(i&&!t.tags.find(([e,t])=>e===r.slice(1)&&-1!==i.indexOf(t)))return!1}return(!e.since||!(t.created_at<e.since))&&(!e.until||!(t.created_at>e.until))}(e[r],t))return!0;return!1}(e.filters,r)&&e.onevent(r);return}case"COUNT":{let e=t[1],r=t[2],n=this.openCountRequests.get(e);n&&(n.resolve(r.count),this.openCountRequests.delete(e));return}case"EOSE":{let e=this.openSubs.get(t[1]);if(!e)return;e.receivedEose();return}case"OK":{let e=t[1],r=t[2],n=t[3],i=this.openEventPublishes.get(e);r?i.resolve(n):i.reject(Error(n)),this.openEventPublishes.delete(e);return}case"CLOSED":{let e=t[1],r=this.openSubs.get(e);if(!r)return;r.closed=!0,r.close(t[2]);return}case"NOTICE":this.onnotice(t[1]);return;case"AUTH":this.challenge=t[1];return}}catch(e){return}}async send(e){if(!this.connectionPromise)throw Error("sending on closed connection");this.connectionPromise.then(()=>{this.ws?.send(e)})}async auth(e){if(!this.challenge)throw Error("can't perform auth, no challenge was received");let t=await e(makeAuthEvent(this.url,this.challenge)),r=new Promise((e,r)=>{this.openEventPublishes.set(t.id,{resolve:e,reject:r})});return this.send('["AUTH",'+JSON.stringify(t)+"]"),r}async publish(e){let t=new Promise((t,r)=>{this.openEventPublishes.set(e.id,{resolve:t,reject:r})});return this.send('["EVENT",'+JSON.stringify(e)+"]"),t}async count(e,t){this.serial++;let r=t?.id||"count:"+this.serial,n=new Promise((e,t)=>{this.openCountRequests.set(r,{resolve:e,reject:t})});return this.send('["COUNT","'+r+'",'+JSON.stringify(e)+"]"),n}subscribe(e,t){let r=this.prepareSubscription(e,t);return r.fire(),r}prepareSubscription(e,t){this.serial++;let r=t.id||"sub:"+this.serial,n=new tI(this,r,e,t);return this.openSubs.set(r,n),n}close(){this.closeAllSubscriptions("relay connection closed by us"),this._connected=!1,this.ws?.close()}_onmessage(e){this.incomingMessageQueue.enqueue(e.data),this.queueRunning||this.runQueue()}},tI=class{relay;id;closed=!1;eosed=!1;filters;alreadyHaveEvent;receivedEvent;onevent;oneose;onclose;eoseTimeout;eoseTimeoutHandle;constructor(e,t,r,n){this.relay=e,this.filters=r,this.id=t,this.alreadyHaveEvent=n.alreadyHaveEvent,this.receivedEvent=n.receivedEvent,this.eoseTimeout=n.eoseTimeout||e.baseEoseTimeout,this.oneose=n.oneose,this.onclose=n.onclose,this.onevent=n.onevent||(e=>{console.warn(`onevent() callback not defined for subscription '${this.id}' in relay ${this.relay.url}. event received:`,e)})}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(e="closed by caller"){this.closed||(this.relay.send('["CLOSE",'+JSON.stringify(this.id)+"]"),this.closed=!0),this.relay.openSubs.delete(this.id
1),this.onclose?.(e)}},tL=class extends tT{constructor(e){super(e,{verifyEvent:em})}static async connect(e){let t=new tL(e);return await t.connect(),t}},tN={};__export(tN,{BECH32_REGEX:()=>tP,decode:()=>decode,naddrEncode:()=>naddrEncode,neventEncode:()=>neventEncode,noteEncode:()=>noteEncode,nprofileEncode:()=>nprofileEncode,npubEncode:()=>npubEncode,nrelayEncode:()=>nrelayEncode,nsecEncode:()=>nsecEncode});var tP=/[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;function decode(e){let{prefix:t,words:r}=J.decode(e,5e3),n=new Uint8Array(J.fromWords(r));switch(t){case"nprofile":{let e=parseTLV(n);if(!e[0]?.[0])throw Error("missing TLV 0 for nprofile");if(32!==e[0][0].length)throw Error("TLV 0 should be 32 bytes");return{type:"nprofile",data:{pubkey:(0,Z.ci)(e[0][0]),relays:e[1]?e[1].map(e=>eh.decode(e)):[]}}}case"nevent":{let e=parseTLV(n);if(!e[0]?.[0])throw Error("missing TLV 0 for nevent");if(32!==e[0][0].length)throw Error("TLV 0 should be 32 bytes");if(e[2]&&32!==e[2][0].length)throw Error("TLV 2 should be 32 bytes");if(e[3]&&4!==e[3][0].length)throw Error("TLV 3 should be 4 bytes");return{type:"nevent",data:{id:(0,Z.ci)(e[0][0]),relays:e[1]?e[1].map(e=>eh.decode(e)):[],author:e[2]?.[0]?(0,Z.ci)(e[2][0]):void 0,kind:e[3]?.[0]?parseInt((0,Z.ci)(e[3][0]),16):void 0}}}case"naddr":{let e=parseTLV(n);if(!e[0]?.[0])throw Error("missing TLV 0 for naddr");if(!e[2]?.[0])throw Error("missing TLV 2 for naddr");if(32!==e[2][0].length)throw Error("TLV 2 should be 32 bytes");if(!e[3]?.[0])throw Error("missing TLV 3 for naddr");if(4!==e[3][0].length)throw Error("TLV 3 should be 4 bytes");return{type:"naddr",data:{identifier:eh.decode(e[0][0]),pubkey:(0,Z.ci)(e[2][0]),kind:parseInt((0,Z.ci)(e[3][0]),16),relays:e[1]?e[1].map(e=>eh.decode(e)):[]}}}case"nrelay":{let e=parseTLV(n);if(!e[0]?.[0])throw Error("missing TLV 0 for nrelay");return{type:"nrelay",data:eh.decode(e[0][0])}}case"nsec":return{type:t,data:n};case"npub":case"note":return{type:t,data:(0,Z.ci)(n)};default:throw Error(`unknown prefix ${t}`)}}function parseTLV(e){let t={},r=e;for(;r.length>0;){let e=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 ${e}`);t[e]=t[e]||[],t[e].push(i)}return t}function nsecEncode(e){return encodeBech32("nsec",e)}function npubEncode(e){var t;return encodeBech32("npub",(0,Z.nr)(e))}function noteEncode(e){var t;return encodeBech32("note",(0,Z.nr)(e))}function encodeBech32(e,t){let r=J.toWords(t);return J.encode(e,r,5e3)}function nprofileEncode(e){return encodeBech32("nprofile",encodeTLV({0:[(0,Z.nr)(e.pubkey)],1:(e.relays||[]).map(e=>ed.encode(e))}))}function neventEncode(e){let t;return void 0!==e.kind&&(t=function(e){let t=new Uint8Array(4);return t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t}(e.kind)),encodeBech32("nevent",encodeTLV({0:[(0,Z.nr)(e.id)],1:(e.relays||[]).map(e=>ed.encode(e)),2:e.author?[(0,Z.nr)(e.author)]:[],3:t?[new Uint8Array(t)]:[]}))}function naddrEncode(e){let t=new ArrayBuffer(4);return new DataView(t).setUint32(0,e.kind,!1),encodeBech32("naddr",encodeTLV({0:[ed.encode(e.identifier)],1:(e.relays||[]).map(e=>ed.encode(e)),2:[(0,Z.nr)(e.pubkey)],3:[new Uint8Array(t)]}))}function nrelayEncode(e){return encodeBech32("nrelay",encodeTLV({0:[ed.encode(e)]}))}function encodeTLV(e){let t=[];return Object.entries(e).reverse().forEach(([e,r])=>{r.forEach(r=>{let n=new Uint8Array(r.length+2);n.set([parseInt(e)],0),n.set([r.length],1),n.set(r,2),t.push(n)})}),(0,Z.eV)(...t)}async function encrypt(e,t,r){let n=e instanceof Uint8Array?(0,Z.ci)(e):e,i=q.getSharedSecret(n,"02"+t),o=getNormalizedX(i),s=Uint8Array.from((0,Z.O6)(16)),a=ed.encode(r),l=await crypto.subtle.importKey("raw",o,{name:"AES-CBC"},!1,["encrypt"]),u=await crypto.subtle.encrypt({name:"AES-CBC",iv:s},l,a),c=D.encode(new Uint8Array(u)),d=D.encode(new Uint8Array(s.buffer));return`${c}?iv=${d}`}async function decrypt(e,t,r){let n=e instanceof Uint8Array?(0,Z.ci)(e):e,[i,o]=r.split("?iv="),s=getNormalizedX(q.getSharedSecret(n,"02"+t)),a=await crypto.subtle.importKey("raw",s,{name:"AES-CBC"},!1,["decrypt"]),l=D.decode(i),u=D.decode(o),c=await crypto.subtle.decrypt({
1name:"AES-CBC",iv:u},a,l);return eh.decode(c)}function getNormalizedX(e){return e.slice(1,33)}__export({},{decrypt:()=>decrypt,encrypt:()=>encrypt}),"undefined"!=typeof crypto&&!crypto.subtle&&crypto.webcrypto&&(crypto.subtle=crypto.webcrypto.subtle),__export({},{NIP05_REGEX:()=>tR,queryProfile:()=>queryProfile,searchDomain:()=>searchDomain,useFetchImplementation:()=>useFetchImplementation});var tR=/^(?:([\w.+-]+)@)?([\w.-]+)$/;try{n=fetch}catch{}function useFetchImplementation(e){n=e}async function searchDomain(e,t=""){try{return(await (await n(`https://${e}/.well-known/nostr.json?name=${t}`)).json()).names}catch(e){return{}}}async function queryProfile(e){let t=e.match(tR);if(!t)return null;let[r,i="_",o]=t;try{let e=await n(`https://${o}/.well-known/nostr.json?name=${i}`),{names:t,relays:r}=function(e){let t={names:{}};for(let[r,n]of Object.entries(e.names))"string"==typeof r&&"string"==typeof n&&(t.names[r]=n);if(e.relays)for(let[r,n]of(t.relays={},Object.entries(e.relays)))"string"==typeof r&&Array.isArray(n)&&(t.relays[r]=n.filter(e=>"string"==typeof e));return t}(await e.json()),s=t[i];return s?{pubkey:s,relays:r?.[s]}:null}catch(e){return null}}function parse(e){let t={reply:void 0,root:void 0,mentions:[],profiles:[]},r=[];for(let n of e.tags)"e"===n[0]&&n[1]&&r.push(n),"p"===n[0]&&n[1]&&t.profiles.push({pubkey:n[1],relays:n[2]?[n[2]]:[]});for(let e=0;e<r.length;e++){let n=r[e],[i,o,s,a]=n,l={id:o,relays:s?[s]:[]},u=0===e,c=e===r.length-1;if("root"===a){t.root=l;continue}if("reply"===a){t.reply=l;continue}if("mention"===a){t.mentions.push(l);continue}if(u){t.root=l;continue}if(c){t.reply=l;continue}t.mentions.push(l)}return t}__export({},{parse:()=>parse}),__export({},{fetchRelayInformation:()=>fetchRelayInformation,useFetchImplementation:()=>useFetchImplementation2});try{fetch}catch{}function useFetchImplementation2(e){}async function fetchRelayInformation(e){return await (await fetch(e.replace("ws://","http://").replace("wss://","https://"),{headers:{Accept:"application/nostr+json"}})).json()}function getPow(e){let t=0;for(let r=0;r<e.length;r++){let n=parseInt(e[r],16);if(0===n)t+=4;else{t+=Math.clz32(n)-28;break}}return t}function minePow(e,t){let r=0,n=["nonce",r.toString(),t.toString()];for(e.tags.push(n);;){let i=Math.floor(new Date().getTime()/1e3);if(i!==e.created_at&&(r=0,e.created_at=i),n[1]=(++r).toString(),e.id=getEventHash(e),getPow(e.id)>=t)break}return e}function finishRepostEvent(e,t,r,n){return eg({kind:e_,tags:[...e.tags??[],["e",t.id,r],["p",t.pubkey]],content:""===e.content?"":JSON.stringify(t),created_at:e.created_at},n)}function getRepostedEventPointer(e){let t,r;if(e.kind===e_){for(let n=e.tags.length-1;n>=0&&(void 0===t||void 0===r);n--){let i=e.tags[n];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===r&&(r=i))}if(void 0!==t)return{id:t[1],relays:[t[2],r?.[2]].filter(e=>"string"==typeof e),author:r?.[1]}}}function getRepostedEvent(e,{skipVerification:t}={}){let r;let n=getRepostedEventPointer(e);if(void 0!==n&&""!==e.content){try{r=JSON.parse(e.content)}catch(e){return}if(r.id===n.id&&(t||em(r)))return r}}__export({},{getPow:()=>getPow,minePow:()=>minePow}),__export({},{finishRepostEvent:()=>finishRepostEvent,getRepostedEvent:()=>getRepostedEvent,getRepostedEventPointer:()=>getRepostedEventPointer}),__export({},{NOSTR_URI_REGEX:()=>tk,parse:()=>parse2,test:()=>test});var tk=RegExp(`nostr:(${tP.source})`);function test(e){return"string"==typeof e&&RegExp(`^${tk.source}$`).test(e)}function parse2(e){let t=e.match(RegExp(`^${tk.source}$`));if(!t)throw Error(`Invalid Nostr URI: ${e}`);return{uri:t[0],value:t[1],decoded:decode(t[1])}}function finishReactionEvent(e,t,r){let n=t.tags.filter(e=>e.length>=2&&("e"===e[0]||"p"===e[0]));return eg({...e,kind:eA,tags:[...e.tags??[],...n,["e",t.id],["p",t.pubkey]],content:e.content??"+"},r)}function getReactedEventPointer(e){let t,r;if(e.kind===eA){for(let n=e.tags.length-1;n>=0&&(void 0===t||void 0===r);n--){let i=e.tags[n];i.length>=2&&("e"===i[0]&&void 0===t?t=i:"p"===i[0]&&void 0===r&&(r=i))}if(void 0!==t&&void 0!==r)return{id:t[1],relays:[t[2],r[2]].filter(e=>void 0!==e),author:r[1]}}}__export({},{finishReactionEvent:()=>finishReactionEvent,getReactedEventPointer:()=>getReactedEventPointer}),__export({},{matchAll:()=>matchAll,regex:()=>regex,replaceAll:()=>replaceAll});var regex=()=>RegExp(`\\b${tk.source}\\b`,"g");function*matchAll(e){let t=e.matchAll(regex());for(let e of t)try{let[t,r]=e;yield{uri:t,value:r,decoded:decode(r),start:e.index,end:e.index+t.length}}catch(e){}}function replaceAll(e,t){return e.replaceAll(regex(),(e,r)=>t({uri:e,value:r,decoded:decode(r)}))}__export({},{channelCreateEvent:()=>channelCreateEvent,channelHideMessageEvent:()=>channelHideMessageEvent,channelMessageEvent:()=>channelMessageEvent,channelMetadataEvent:()=>channelMetadataEvent,channelMuteUserEvent:()=>channelMuteUserEvent});var channelCreateEvent=(e,t)=>
1{let r;if("object"==typeof e.content)r=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;r=e.content}return eg({kind:eT,tags:[...e.tags??[]],content:r,created_at:e.created_at},t)},channelMetadataEvent=(e,t)=>{let r;if("object"==typeof e.content)r=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;r=e.content}return eg({kind:eI,tags:[["e",e.channel_create_event_id],...e.tags??[]],content:r,created_at:e.created_at},t)},channelMessageEvent=(e,t)=>{let r=[["e",e.channel_create_event_id,e.relay_url,"root"]];return e.reply_to_channel_message_event_id&&r.push(["e",e.reply_to_channel_message_event_id,e.relay_url,"reply"]),eg({kind:eL,tags:[...r,...e.tags??[]],content:e.content,created_at:e.created_at},t)},channelHideMessageEvent=(e,t)=>{let r;if("object"==typeof e.content)r=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;r=e.content}return eg({kind:eN,tags:[["e",e.channel_message_event_id],...e.tags??[]],content:r,created_at:e.created_at},t)},channelMuteUserEvent=(e,t)=>{let r;if("object"==typeof e.content)r=JSON.stringify(e.content);else{if("string"!=typeof e.content)return;r=e.content}return eg({kind:eP,tags:[["p",e.pubkey_to_mute],...e.tags??[]],content:r,created_at:e.created_at},t)};__export({},{EMOJI_SHORTCODE_REGEX:()=>tU,matchAll:()=>matchAll2,regex:()=>regex2,replaceAll:()=>replaceAll2});var tU=/:(\w+):/,regex2=()=>RegExp(`\\B${tU.source}\\B`,"g");function*matchAll2(e){let t=e.matchAll(regex2());for(let e of t)try{let[t,r]=e;yield{shortcode:t,name:r,start:e.index,end:e.index+t.length}}catch(e){}}function replaceAll2(e,t){return e.replaceAll(regex2(),(e,r)=>t({shortcode:e,name:r}))}__export({},{useFetchImplementation:()=>useFetchImplementation3,validateGithub:()=>validateGithub});try{i=fetch}catch{}function useFetchImplementation3(e){i=e}async function validateGithub(e,t,r){try{return await (await i(`https://gist.github.com/${t}/${r}/raw`)).text()===`Verifying that I control the following Nostr public key: ${e}`}catch(e){return!1}}__export({},{default:()=>t$,v2:()=>tH});var tC=new TextDecoder,tO={minPlaintextSize:1,maxPlaintextSize:65535,utf8Encode:Z.iY,utf8Decode:e=>tC.decode(e),getConversationKey(e,t){var r,n;let i=q.getSharedSecret(e,"02"+t).subarray(1,33);return r=z.J,n="nip44-v2",eo.ZP.hash(r),void 0===n&&(n=new Uint8Array(r.outputLen)),(0,es.b)(r,(0,Z.O0)(n),(0,Z.O0)(i))},getMessageKeys(e,t){esm_utils_ensureBytes(e,32),esm_utils_ensureBytes(t,32);let r=function(e,t,r,n=32){if(eo.ZP.hash(e),eo.ZP.number(n),n>255*e.outputLen)throw Error("Length should be <= 255*HashLen");let i=Math.ceil(n/e.outputLen);void 0===r&&(r=el);let o=new Uint8Array(i*e.outputLen),s=es.b.create(e,t),a=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let t=0;t<i;t++)ea[0]=t+1,a.update(0===t?el:l).update(r).update(ea).digestInto(l),o.set(l,e.outputLen*t),s._cloneInto(a);return s.destroy(),a.destroy(),l.fill(0),ea.fill(0),o.slice(0,n)}(z.J,e,t,76);return{chacha_key:r.subarray(0,32),chacha_nonce:r.subarray(32,44),hmac_key:r.subarray(44,76)}},calcPaddedLen(e){if(!Number.isSafeInteger(e)||e<1)throw Error("expected positive integer");if(e<=32)return 32;let t=1<<Math.floor(Math.log2(e-1))+1,r=t<=256?32:t/8;return r*(Math.floor((e-1)/r)+1)},writeU16BE(e){if(!Number.isSafeInteger(e)||e<tO.minPlaintextSize||e>tO.maxPlaintextSize)throw Error("invalid plaintext size: must be between 1 and 65535 bytes");let t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!1),t},pad(e){let t=tO.utf8Encode(e),r=t.length,n=tO.writeU16BE(r),i=new Uint8Array(tO.calcPaddedLen(r)-r);return(0,Z.eV)(n,t,i)},unpad(e){let t=new DataView(e.buffer).getUint16(0),r=e.subarray(2,2+t);if(t<tO.minPlaintextSize||t>tO.maxPlaintextSize||r.length!==t||e.length!==2+tO.calcPaddedLen(t))throw Error("invalid padding");return tO.utf8Decode(r)},hmacAad(e,t,r){if(32!==r.length)throw Error("AAD associated data must be 32 bytes");let n=(0,Z.eV)(r,t);return(0,es.b)(z.J,e,n)},decodePayload(e){let t;if("string"!=typeof e)throw Error("payload must be a valid string");let r=e.length;if(r<132||r>87472)throw Error("invalid payload length: "+r);if("#"===e[0])throw Error("unknown encryption version");try{t=D.decode(e)}catch(e){throw Error("invalid base64: "+e.message)}let n=t.length;if(n<99||n>65603)throw Error("invalid data length: "+n);let i=t[0];if(2!==i)throw Error("unknown encryption version "+i);return{nonce:t.subarray(1,33),ciphertext:t.subarray(33,-32),mac:t.subarray(-32)}}},tH={utils:tO,encrypt:function(e,t,r=(0,Z.O6)(32)){let{chacha_key:n,chacha_nonce:i,hmac_key:o}=tO.getMessageKeys(t,r),s=tO.pad(e),a=en(n,i,s),l=tO.hmacAad(o,a,r);
1return D.encode((0,Z.eV)(new Uint8Array([2]),r,a,l))},decrypt:function(e,t){let{nonce:r,ciphertext:n,mac:i}=tO.decodePayload(e),{chacha_key:o,chacha_nonce:s,hmac_key:a}=tO.getMessageKeys(t,r),l=tO.hmacAad(a,n,r);if(!function(e,t){if(e.length!==t.length)throw Error("equalBytes: Different size of Uint8Arrays");let r=!0;for(let n=0;n<e.length;n++)r&&(r=e[n]===t[n]);return r}(l,i))throw Error("invalid MAC");let u=en(o,s,n);return tO.unpad(u)}},t$={v2:tH};function parseConnectionString(e){let{pathname:t,searchParams:r}=new URL(e),n=r.get("relay"),i=r.get("secret");if(!t||!n||!i)throw Error("invalid connection string");return{pubkey:t,relay:n,secret:i}}async function makeNwcRequestEvent(e,t,r){let n=await encrypt(t,e,JSON.stringify({method:"pay_invoice",params:{invoice:r}})),i={kind:e7,created_at:Math.round(Date.now()/1e3),content:n,tags:[["p",e]]};return eg(i,t)}__export({},{makeNwcRequestEvent:()=>makeNwcRequestEvent,parseConnectionString:()=>parseConnectionString}),__export({},{getZapEndpoint:()=>getZapEndpoint,makeZapReceipt:()=>makeZapReceipt,makeZapRequest:()=>makeZapRequest,useFetchImplementation:()=>useFetchImplementation4,validateZapRequest:()=>validateZapRequest});try{o=fetch}catch{}function useFetchImplementation4(e){o=e}async function getZapEndpoint(e){try{let t="",{lud06:r,lud16:n}=JSON.parse(e.content);if(r){let{words:e}=J.decode(r,1e3),n=J.fromWords(e);t=eh.decode(n)}else{if(!n)return null;let[e,r]=n.split("@");t=`https://${r}/.well-known/lnurlp/${e}`}let i=await o(t),s=await i.json();if(s.allowsNostr&&s.nostrPubkey)return s.callback}catch(e){}return null}function makeZapRequest({profile:e,event:t,amount:r,relays:n,comment:i=""}){if(!r)throw Error("amount not given");if(!e)throw Error("profile not given");let o={kind:9734,created_at:Math.round(Date.now()/1e3),content:i,tags:[["p",e],["amount",r.toString()],["relays",...n]]};return t&&o.tags.push(["e",t]),o}function validateZapRequest(e){let t;try{t=JSON.parse(e)}catch(e){return"Invalid zap request JSON."}if(!validateEvent(t))return"Zap request is not a valid Nostr event.";if(!em(t))return"Invalid signature on zap request.";let r=t.tags.find(([e,t])=>"p"===e&&t);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=t.tags.find(([e,t])=>"e"===e&&t);return n&&!n[1].match(/^[a-f0-9]{64}$/)?"Zap request 'e' tag is not valid hex.":t.tags.find(([e,t])=>"relays"===e&&t)?null:"Zap request doesn't have a 'relays' tag."}function makeZapReceipt({zapRequest:e,preimage:t,bolt11:r,paidAt:n}){let i=JSON.parse(e),o=i.tags.filter(([e])=>"e"===e||"p"===e||"a"===e),s={kind:9735,created_at:Math.round(n.getTime()/1e3),content:"",tags:[...o,["P",i.pubkey],["bolt11",r],["description",e]]};return t&&s.tags.push(["preimage",t]),s}__export({},{getToken:()=>getToken,hashPayload:()=>hashPayload,unpackEventFromToken:()=>unpackEventFromToken,validateEvent:()=>validateEvent2,validateToken:()=>validateToken});var tq="Nostr ";function hashPayload(e){let t=(0,z.J)(ed.encode(JSON.stringify(e)));return(0,Z.ci)(t)}async function getToken(e,t,r,n=!1,i){let o={kind:tr,tags:[["u",e],["method",t]],created_at:Math.round(new Date().getTime()/1e3),content:""};i&&o.tags.push(["payload",(0,Z.ci)((0,z.J)(ed.encode(JSON.stringify(i))))]);let s=await r(o),a=n?tq:"";return a+D.encode(ed.encode(JSON.stringify(s)))}async function validateToken(e,t,r){let n=await unpackEventFromToken(e).catch(e=>{throw e}),i=await validateEvent2(n,t,r).catch(e=>{throw e});return i}async function unpackEventFromToken(e){if(!e)throw Error("Missing token");e=e.replace(tq,"");let t=eh.decode(D.decode(e));if(!t||0===t.length||!t.startsWith("{"))throw Error("Invalid token");let r=JSON.parse(t);return r}async function validateEvent2(e,t,r,n){if(!e)throw Error("Invalid nostr event");if(!em(e))throw Error("Invalid nostr event, signature invalid");if(e.kind!==tr)throw Error("Invalid nostr event, kind invalid");if(!e.created_at)throw Error("Invalid nostr event, created_at invalid");if(Math.round(new Date().getTime()/1e3)-e.created_at>60)throw Error("Invalid nostr event, expired");let i=e.tags.find(e=>"u"===e[0]);if(i?.length!==1&&i?.[1]!==t)throw Error("Invalid nostr event, url tag invalid");let o=e.tags.find(e=>"method"===e[0]);if(o?.length!==1&&o?.[1].toLowerCase()!==r.toLowerCase())throw Error("Invalid nostr event, method tag invalid");if(n&&Object.keys(n).length>0){let t=e.tags.find(e=>"payload"===e[0]),r=(0,Z.ci)((0,z.J)(ed.encode(JSON.stringify(n))));if(t?.[1]!==r)throw Error("Invalid payload tag hash, does not match request body hash")}return!0}}}]);

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.